mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
Multi-slider carousel
This commit is contained in:
parent
b75bad1e3d
commit
8b007a3efc
2
dist/index.html
vendored
2
dist/index.html
vendored
@ -1,4 +1,4 @@
|
|||||||
<!doctype html><html lang="en"><head><title>Webpack Bootstrap 4 UI Demo</title><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="description" content="UI Kit"/><meta name="author" content="Tony Air <tony@twma.pro>"/><meta name="ping" content="/Security/ping"/><meta name="api_url" content="http://127.0.0.1/graphql"/><meta name="api_static_domain" content="http://127.0.0.1"/><meta name="swversion" content="sw-1630869010121"/><base href=""/><script defer="defer" src="js/app.js"></script><script defer="defer" src="js/app_sw.js"></script><script defer="defer" src="js/app_map.api.js"></script><link href="css/app.css" rel="stylesheet"/><link href="css/app_map.api.css" rel="stylesheet"/></head><body data-default-lng="0" data-default-lat="0"><div class="wrapper"><style>@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}100%{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0,0)}100%{transform:translate(1.35rem,0)}}body,html{font-size:14px;margin:0;padding:0;background:#fff;color:#333;overflow-x:hidden}@media (min-width:2000px){body,html{font-size:.9vw}}#PageLoading{position:fixed;left:0;top:0;margin:0;width:100%!important;height:100%!important;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;z-index:2000;will-change:opacity;background:#212529;color:#212529}#PageLoading .logo{filter:invert(1);margin-left:20px;margin-left:2vw;width:100px;width:12.5vw}#PageLoading .tagline{color:#fff;font-size:1.8rem;font-size:4vh;letter-spacing:.25em}.main-bn{position:fixed;top:0;left:0;width:100%;z-index:99999999;padding:.5rem 1rem;text-align:center;color:#fff;background:red}iframe,img{max-width:100%}.loading-spinner{text-align:center}.lds-ellipsis{display:inline-block;position:relative;width:4.57rem;height:1rem;color:#fff}.lds-ellipsis div{position:absolute;top:.15rem;width:.78rem;height:.78rem;border-radius:50%;background:#888;animation-timing-function:cubic-bezier(0,1,1,0)}.lds-ellipsis div:nth-child(1){left:.42rem;animation:lds-ellipsis1 .6s infinite}.lds-ellipsis div:nth-child(2){left:.9rem;animation:lds-ellipsis2 .6s infinite}.lds-ellipsis div:nth-child(3){left:1.85rem;animation:lds-ellipsis2 .6s infinite}.lds-ellipsis div:nth-child(4){left:3.21rem;animation:lds-ellipsis3 .6s infinite}@keyframes lds-text{from{font-size:1em}to{font-size:1.5em}}.lds-text{position:absolute;top:50%;left:50%;margin-left:-5rem;margin-top:8rem;font-size:.8rem;letter-spacing:.25em;color:#fff}.lds-text b{font-weight:300;animation:lds-text 5s ease infinite alternate}.lds-text b:nth-child(1){animation-delay:.5s}.lds-text b:nth-child(2){animation-delay:1s}.lds-text b:nth-child(3){animation-delay:1.5s}.lds-text b:nth-child(4){animation-delay:2s}.lds-text b:nth-child(5){animation-delay:2.5s}.lds-text b:nth-child(6){animation-delay:3s}.lds-text b:nth-child(7){animation-delay:3.5s}.lds-text b:nth-child(8){animation-delay:4s}.lds-text b:nth-child(9){animation-delay:4.5s}.lds-text b:nth-child(10){animation-delay:5s}@media (orientation:portrait){#PageLoading .logo{width:50vw}#PageLoading .tagline{font-size:4vw}}</style><div id="PageLoading"><div class="loading-spinner"><img class="logo" src="../img/logo.svg" width="200" alt="UI Kit"/><br/><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div><br/><div class="lds-placeholder">LOADING...</div><div class="lds-text"><b>L</b> <b>O</b> <b>A</b> <b>D</b> <b>I</b> <b>N</b> <b>G</b> <b>.</b> <b>.</b> <b>.</b></div></div></div><div id="SiteWideAlerts" class="offline-message"><div class="alert alert-danger alert-offline alert-dismissible fade show" role="alert"><div class="typography">The Internet connection is missing right now, but you're able to browse previously opened pages offline.</div><button type="button" class="btn btn-danger btn-close" data-bs-dismiss="alert" aria-label="Close"><i class="fas fa-times"></i></button></div><noscript><div class="main-bn alert alert-fixed-top alert-danger" role="alert">Please, enable javascript.</div></noscript><!--[if lt IE 11
|
<!doctype html><html lang="en"><head><title>Webpack Bootstrap 4 UI Demo</title><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="description" content="UI Kit"/><meta name="author" content="Tony Air <tony@twma.pro>"/><meta name="ping" content="/Security/ping"/><meta name="api_url" content="http://127.0.0.1/graphql"/><meta name="api_static_domain" content="http://127.0.0.1"/><meta name="swversion" content="sw-1630869477281"/><base href=""/><script defer="defer" src="js/app.js"></script><script defer="defer" src="js/app_sw.js"></script><script defer="defer" src="js/app_map.api.js"></script><link href="css/app.css" rel="stylesheet"/><link href="css/app_map.api.css" rel="stylesheet"/></head><body data-default-lng="0" data-default-lat="0"><div class="wrapper"><style>@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}100%{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0,0)}100%{transform:translate(1.35rem,0)}}body,html{font-size:14px;margin:0;padding:0;background:#fff;color:#333;overflow-x:hidden}@media (min-width:2000px){body,html{font-size:.9vw}}#PageLoading{position:fixed;left:0;top:0;margin:0;width:100%!important;height:100%!important;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;z-index:2000;will-change:opacity;background:#212529;color:#212529}#PageLoading .logo{filter:invert(1);margin-left:20px;margin-left:2vw;width:100px;width:12.5vw}#PageLoading .tagline{color:#fff;font-size:1.8rem;font-size:4vh;letter-spacing:.25em}.main-bn{position:fixed;top:0;left:0;width:100%;z-index:99999999;padding:.5rem 1rem;text-align:center;color:#fff;background:red}iframe,img{max-width:100%}.loading-spinner{text-align:center}.lds-ellipsis{display:inline-block;position:relative;width:4.57rem;height:1rem;color:#fff}.lds-ellipsis div{position:absolute;top:.15rem;width:.78rem;height:.78rem;border-radius:50%;background:#888;animation-timing-function:cubic-bezier(0,1,1,0)}.lds-ellipsis div:nth-child(1){left:.42rem;animation:lds-ellipsis1 .6s infinite}.lds-ellipsis div:nth-child(2){left:.9rem;animation:lds-ellipsis2 .6s infinite}.lds-ellipsis div:nth-child(3){left:1.85rem;animation:lds-ellipsis2 .6s infinite}.lds-ellipsis div:nth-child(4){left:3.21rem;animation:lds-ellipsis3 .6s infinite}@keyframes lds-text{from{font-size:1em}to{font-size:1.5em}}.lds-text{position:absolute;top:50%;left:50%;margin-left:-5rem;margin-top:8rem;font-size:.8rem;letter-spacing:.25em;color:#fff}.lds-text b{font-weight:300;animation:lds-text 5s ease infinite alternate}.lds-text b:nth-child(1){animation-delay:.5s}.lds-text b:nth-child(2){animation-delay:1s}.lds-text b:nth-child(3){animation-delay:1.5s}.lds-text b:nth-child(4){animation-delay:2s}.lds-text b:nth-child(5){animation-delay:2.5s}.lds-text b:nth-child(6){animation-delay:3s}.lds-text b:nth-child(7){animation-delay:3.5s}.lds-text b:nth-child(8){animation-delay:4s}.lds-text b:nth-child(9){animation-delay:4.5s}.lds-text b:nth-child(10){animation-delay:5s}@media (orientation:portrait){#PageLoading .logo{width:50vw}#PageLoading .tagline{font-size:4vw}}</style><div id="PageLoading"><div class="loading-spinner"><img class="logo" src="../img/logo.svg" width="200" alt="UI Kit"/><br/><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div><br/><div class="lds-placeholder">LOADING...</div><div class="lds-text"><b>L</b> <b>O</b> <b>A</b> <b>D</b> <b>I</b> <b>N</b> <b>G</b> <b>.</b> <b>.</b> <b>.</b></div></div></div><div id="SiteWideAlerts" class="offline-message"><div class="alert alert-danger alert-offline alert-dismissible fade show" role="alert"><div class="typography">The Internet connection is missing right now, but you're able to browse previously opened pages offline.</div><button type="button" class="btn btn-danger btn-close" data-bs-dismiss="alert" aria-label="Close"><i class="fas fa-times"></i></button></div><noscript><div class="main-bn alert alert-fixed-top alert-danger" role="alert">Please, enable javascript.</div></noscript><!--[if lt IE 11
|
||||||
]><div class="main-bn alert alert-danger" role="alert">
|
]><div class="main-bn alert alert-danger" role="alert">
|
||||||
<a
|
<a
|
||||||
href="https://www.google.com/chrome/browser/desktop/"
|
href="https://www.google.com/chrome/browser/desktop/"
|
||||||
|
2
dist/report.html
vendored
2
dist/report.html
vendored
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
<title>@a2nt/ss-bootstrap-ui-webpack-boilerplate-react [5 Sep 2021 at 21:12]</title>
|
<title>@a2nt/ss-bootstrap-ui-webpack-boilerplate-react [5 Sep 2021 at 21:20]</title>
|
||||||
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJI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7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT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MV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -8,118 +8,118 @@
|
|||||||
* - Please do NOT serve this file on production.
|
* - Please do NOT serve this file on production.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const INTEGRITY_CHECKSUM = "f0a916b13c8acc2b526a03a6d26df85f";
|
const INTEGRITY_CHECKSUM = 'f0a916b13c8acc2b526a03a6d26df85f'
|
||||||
const bypassHeaderName = "x-msw-bypass";
|
const bypassHeaderName = 'x-msw-bypass'
|
||||||
const activeClientIds = new Set();
|
const activeClientIds = new Set()
|
||||||
|
|
||||||
self.addEventListener("install", function () {
|
self.addEventListener('install', function () {
|
||||||
return self.skipWaiting();
|
return self.skipWaiting()
|
||||||
});
|
})
|
||||||
|
|
||||||
self.addEventListener("activate", async function (event) {
|
self.addEventListener('activate', async function (event) {
|
||||||
return self.clients.claim();
|
return self.clients.claim()
|
||||||
});
|
})
|
||||||
|
|
||||||
self.addEventListener("message", async function (event) {
|
self.addEventListener('message', async function (event) {
|
||||||
const clientId = event.source.id;
|
const clientId = event.source.id
|
||||||
|
|
||||||
if (!clientId || !self.clients) {
|
if (!clientId || !self.clients) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = await self.clients.get(clientId);
|
const client = await self.clients.get(clientId)
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const allClients = await self.clients.matchAll();
|
const allClients = await self.clients.matchAll()
|
||||||
|
|
||||||
switch (event.data) {
|
switch (event.data) {
|
||||||
case "KEEPALIVE_REQUEST": {
|
case 'KEEPALIVE_REQUEST': {
|
||||||
sendToClient(client, {
|
sendToClient(client, {
|
||||||
type: "KEEPALIVE_RESPONSE",
|
type: 'KEEPALIVE_RESPONSE',
|
||||||
});
|
})
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "INTEGRITY_CHECK_REQUEST": {
|
case 'INTEGRITY_CHECK_REQUEST': {
|
||||||
sendToClient(client, {
|
sendToClient(client, {
|
||||||
type: "INTEGRITY_CHECK_RESPONSE",
|
type: 'INTEGRITY_CHECK_RESPONSE',
|
||||||
payload: INTEGRITY_CHECKSUM,
|
payload: INTEGRITY_CHECKSUM,
|
||||||
});
|
})
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "MOCK_ACTIVATE": {
|
case 'MOCK_ACTIVATE': {
|
||||||
activeClientIds.add(clientId);
|
activeClientIds.add(clientId)
|
||||||
|
|
||||||
sendToClient(client, {
|
sendToClient(client, {
|
||||||
type: "MOCKING_ENABLED",
|
type: 'MOCKING_ENABLED',
|
||||||
payload: true,
|
payload: true,
|
||||||
});
|
})
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "MOCK_DEACTIVATE": {
|
case 'MOCK_DEACTIVATE': {
|
||||||
activeClientIds.delete(clientId);
|
activeClientIds.delete(clientId)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case "CLIENT_CLOSED": {
|
case 'CLIENT_CLOSED': {
|
||||||
activeClientIds.delete(clientId);
|
activeClientIds.delete(clientId)
|
||||||
|
|
||||||
const remainingClients = allClients.filter((client) => {
|
const remainingClients = allClients.filter((client) => {
|
||||||
return client.id !== clientId;
|
return client.id !== clientId
|
||||||
});
|
})
|
||||||
|
|
||||||
// Unregister itself when there are no more clients
|
// Unregister itself when there are no more clients
|
||||||
if (remainingClients.length === 0) {
|
if (remainingClients.length === 0) {
|
||||||
self.registration.unregister();
|
self.registration.unregister()
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
// Resolve the "master" client for the given event.
|
// Resolve the "master" client for the given event.
|
||||||
// Client that issues a request doesn't necessarily equal the client
|
// Client that issues a request doesn't necessarily equal the client
|
||||||
// that registered the worker. It's with the latter the worker should
|
// that registered the worker. It's with the latter the worker should
|
||||||
// communicate with during the response resolving phase.
|
// communicate with during the response resolving phase.
|
||||||
async function resolveMasterClient(event) {
|
async function resolveMasterClient(event) {
|
||||||
const client = await self.clients.get(event.clientId);
|
const client = await self.clients.get(event.clientId)
|
||||||
|
|
||||||
if (client.frameType === "top-level") {
|
if (client.frameType === 'top-level') {
|
||||||
return client;
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
const allClients = await self.clients.matchAll();
|
const allClients = await self.clients.matchAll()
|
||||||
|
|
||||||
return allClients
|
return allClients
|
||||||
.filter((client) => {
|
.filter((client) => {
|
||||||
// Get only those clients that are currently visible.
|
// Get only those clients that are currently visible.
|
||||||
return client.visibilityState === "visible";
|
return client.visibilityState === 'visible'
|
||||||
})
|
})
|
||||||
.find((client) => {
|
.find((client) => {
|
||||||
// Find the client ID that's recorded in the
|
// Find the client ID that's recorded in the
|
||||||
// set of clients that have registered the worker.
|
// set of clients that have registered the worker.
|
||||||
return activeClientIds.has(client.id);
|
return activeClientIds.has(client.id)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleRequest(event, requestId) {
|
async function handleRequest(event, requestId) {
|
||||||
const client = await resolveMasterClient(event);
|
const client = await resolveMasterClient(event)
|
||||||
const response = await getResponse(event, client, requestId);
|
const response = await getResponse(event, client, requestId)
|
||||||
|
|
||||||
// Send back the response clone for the "response:*" life-cycle events.
|
// Send back the response clone for the "response:*" life-cycle events.
|
||||||
// Ensure MSW is active and ready to handle the message, otherwise
|
// Ensure MSW is active and ready to handle the message, otherwise
|
||||||
// this message will pend indefinitely.
|
// this message will pend indefinitely.
|
||||||
if (client && activeClientIds.has(client.id)) {
|
if (client && activeClientIds.has(client.id)) {
|
||||||
(async function () {
|
;(async function () {
|
||||||
const clonedResponse = response.clone();
|
const clonedResponse = response.clone()
|
||||||
sendToClient(client, {
|
sendToClient(client, {
|
||||||
type: "RESPONSE",
|
type: 'RESPONSE',
|
||||||
payload: {
|
payload: {
|
||||||
requestId,
|
requestId,
|
||||||
type: clonedResponse.type,
|
type: clonedResponse.type,
|
||||||
@ -131,21 +131,21 @@ async function handleRequest(event, requestId) {
|
|||||||
headers: serializeHeaders(clonedResponse.headers),
|
headers: serializeHeaders(clonedResponse.headers),
|
||||||
redirected: clonedResponse.redirected,
|
redirected: clonedResponse.redirected,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
})();
|
})()
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getResponse(event, client, requestId) {
|
async function getResponse(event, client, requestId) {
|
||||||
const { request } = event;
|
const { request } = event
|
||||||
const requestClone = request.clone();
|
const requestClone = request.clone()
|
||||||
const getOriginalResponse = () => fetch(requestClone);
|
const getOriginalResponse = () => fetch(requestClone)
|
||||||
|
|
||||||
// Bypass mocking when the request client is not active.
|
// Bypass mocking when the request client is not active.
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return getOriginalResponse();
|
return getOriginalResponse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bypass initial page load requests (i.e. static assets).
|
// Bypass initial page load requests (i.e. static assets).
|
||||||
@ -153,29 +153,29 @@ async function getResponse(event, client, requestId) {
|
|||||||
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
|
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
|
||||||
// and is not ready to handle requests.
|
// and is not ready to handle requests.
|
||||||
if (!activeClientIds.has(client.id)) {
|
if (!activeClientIds.has(client.id)) {
|
||||||
return await getOriginalResponse();
|
return await getOriginalResponse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bypass requests with the explicit bypass header
|
// Bypass requests with the explicit bypass header
|
||||||
if (requestClone.headers.get(bypassHeaderName) === "true") {
|
if (requestClone.headers.get(bypassHeaderName) === 'true') {
|
||||||
const cleanRequestHeaders = serializeHeaders(requestClone.headers);
|
const cleanRequestHeaders = serializeHeaders(requestClone.headers)
|
||||||
|
|
||||||
// Remove the bypass header to comply with the CORS preflight check.
|
// Remove the bypass header to comply with the CORS preflight check.
|
||||||
delete cleanRequestHeaders[bypassHeaderName];
|
delete cleanRequestHeaders[bypassHeaderName]
|
||||||
|
|
||||||
const originalRequest = new Request(requestClone, {
|
const originalRequest = new Request(requestClone, {
|
||||||
headers: new Headers(cleanRequestHeaders),
|
headers: new Headers(cleanRequestHeaders),
|
||||||
});
|
})
|
||||||
|
|
||||||
return fetch(originalRequest);
|
return fetch(originalRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the request to the client-side MSW.
|
// Send the request to the client-side MSW.
|
||||||
const reqHeaders = serializeHeaders(request.headers);
|
const reqHeaders = serializeHeaders(request.headers)
|
||||||
const body = await request.text();
|
const body = await request.text()
|
||||||
|
|
||||||
const clientMessage = await sendToClient(client, {
|
const clientMessage = await sendToClient(client, {
|
||||||
type: "REQUEST",
|
type: 'REQUEST',
|
||||||
payload: {
|
payload: {
|
||||||
id: requestId,
|
id: requestId,
|
||||||
url: request.url,
|
url: request.url,
|
||||||
@ -193,31 +193,31 @@ async function getResponse(event, client, requestId) {
|
|||||||
bodyUsed: request.bodyUsed,
|
bodyUsed: request.bodyUsed,
|
||||||
keepalive: request.keepalive,
|
keepalive: request.keepalive,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
switch (clientMessage.type) {
|
switch (clientMessage.type) {
|
||||||
case "MOCK_SUCCESS": {
|
case 'MOCK_SUCCESS': {
|
||||||
return delayPromise(
|
return delayPromise(
|
||||||
() => respondWithMock(clientMessage),
|
() => respondWithMock(clientMessage),
|
||||||
clientMessage.payload.delay
|
clientMessage.payload.delay,
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "MOCK_NOT_FOUND": {
|
case 'MOCK_NOT_FOUND': {
|
||||||
return getOriginalResponse();
|
return getOriginalResponse()
|
||||||
}
|
}
|
||||||
|
|
||||||
case "NETWORK_ERROR": {
|
case 'NETWORK_ERROR': {
|
||||||
const { name, message } = clientMessage.payload;
|
const { name, message } = clientMessage.payload
|
||||||
const networkError = new Error(message);
|
const networkError = new Error(message)
|
||||||
networkError.name = name;
|
networkError.name = name
|
||||||
|
|
||||||
// Rejecting a request Promise emulates a network error.
|
// Rejecting a request Promise emulates a network error.
|
||||||
throw networkError;
|
throw networkError
|
||||||
}
|
}
|
||||||
|
|
||||||
case "INTERNAL_ERROR": {
|
case 'INTERNAL_ERROR': {
|
||||||
const parsedBody = JSON.parse(clientMessage.payload.body);
|
const parsedBody = JSON.parse(clientMessage.payload.body)
|
||||||
|
|
||||||
console.error(
|
console.error(
|
||||||
`\
|
`\
|
||||||
@ -228,54 +228,54 @@ ${parsedBody.location}
|
|||||||
This exception has been gracefully handled as a 500 response, however, it's strongly recommended to resolve this error, as it indicates a mistake in your code. If you wish to mock an error response, please see this guide: https://mswjs.io/docs/recipes/mocking-error-responses\
|
This exception has been gracefully handled as a 500 response, however, it's strongly recommended to resolve this error, as it indicates a mistake in your code. If you wish to mock an error response, please see this guide: https://mswjs.io/docs/recipes/mocking-error-responses\
|
||||||
`,
|
`,
|
||||||
request.method,
|
request.method,
|
||||||
request.url
|
request.url,
|
||||||
);
|
)
|
||||||
|
|
||||||
return respondWithMock(clientMessage);
|
return respondWithMock(clientMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getOriginalResponse();
|
return getOriginalResponse()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.addEventListener("fetch", function (event) {
|
self.addEventListener('fetch', function (event) {
|
||||||
const { request } = event;
|
const { request } = event
|
||||||
const accept = request.headers.get("accept") || "";
|
const accept = request.headers.get('accept') || ''
|
||||||
|
|
||||||
// Bypass server-sent events.
|
// Bypass server-sent events.
|
||||||
if (accept.includes("text/event-stream")) {
|
if (accept.includes('text/event-stream')) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bypass navigation requests.
|
// Bypass navigation requests.
|
||||||
if (request.mode === "navigate") {
|
if (request.mode === 'navigate') {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opening the DevTools triggers the "only-if-cached" request
|
// Opening the DevTools triggers the "only-if-cached" request
|
||||||
// that cannot be handled by the worker. Bypass such requests.
|
// that cannot be handled by the worker. Bypass such requests.
|
||||||
if (request.cache === "only-if-cached" && request.mode !== "same-origin") {
|
if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bypass all requests when there are no active clients.
|
// Bypass all requests when there are no active clients.
|
||||||
// Prevents the self-unregistered worked from handling requests
|
// Prevents the self-unregistered worked from handling requests
|
||||||
// after it's been deleted (still remains active until the next reload).
|
// after it's been deleted (still remains active until the next reload).
|
||||||
if (activeClientIds.size === 0) {
|
if (activeClientIds.size === 0) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestId = uuidv4();
|
const requestId = uuidv4()
|
||||||
|
|
||||||
return event.respondWith(
|
return event.respondWith(
|
||||||
handleRequest(event, requestId).catch((error) => {
|
handleRequest(event, requestId).catch((error) => {
|
||||||
if (error.name === "NetworkError") {
|
if (error.name === 'NetworkError') {
|
||||||
console.warn(
|
console.warn(
|
||||||
'[MSW] Successfully emulated a network error for the "%s %s" request.',
|
'[MSW] Successfully emulated a network error for the "%s %s" request.',
|
||||||
request.method,
|
request.method,
|
||||||
request.url
|
request.url,
|
||||||
);
|
)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, any exception indicates an issue with the original request/response.
|
// At this point, any exception indicates an issue with the original request/response.
|
||||||
@ -284,55 +284,55 @@ self.addEventListener("fetch", function (event) {
|
|||||||
[MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`,
|
[MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`,
|
||||||
request.method,
|
request.method,
|
||||||
request.url,
|
request.url,
|
||||||
`${error.name}: ${error.message}`
|
`${error.name}: ${error.message}`,
|
||||||
);
|
)
|
||||||
})
|
}),
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
|
|
||||||
function serializeHeaders(headers) {
|
function serializeHeaders(headers) {
|
||||||
const reqHeaders = {};
|
const reqHeaders = {}
|
||||||
headers.forEach((value, name) => {
|
headers.forEach((value, name) => {
|
||||||
reqHeaders[name] = reqHeaders[name]
|
reqHeaders[name] = reqHeaders[name]
|
||||||
? [].concat(reqHeaders[name]).concat(value)
|
? [].concat(reqHeaders[name]).concat(value)
|
||||||
: value;
|
: value
|
||||||
});
|
})
|
||||||
return reqHeaders;
|
return reqHeaders
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendToClient(client, message) {
|
function sendToClient(client, message) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const channel = new MessageChannel();
|
const channel = new MessageChannel()
|
||||||
|
|
||||||
channel.port1.onmessage = (event) => {
|
channel.port1.onmessage = (event) => {
|
||||||
if (event.data && event.data.error) {
|
if (event.data && event.data.error) {
|
||||||
return reject(event.data.error);
|
return reject(event.data.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(event.data);
|
resolve(event.data)
|
||||||
};
|
}
|
||||||
|
|
||||||
client.postMessage(JSON.stringify(message), [channel.port2]);
|
client.postMessage(JSON.stringify(message), [channel.port2])
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function delayPromise(cb, duration) {
|
function delayPromise(cb, duration) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
setTimeout(() => resolve(cb()), duration);
|
setTimeout(() => resolve(cb()), duration)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function respondWithMock(clientMessage) {
|
function respondWithMock(clientMessage) {
|
||||||
return new Response(clientMessage.payload.body, {
|
return new Response(clientMessage.payload.body, {
|
||||||
...clientMessage.payload,
|
...clientMessage.payload,
|
||||||
headers: clientMessage.payload.headers,
|
headers: clientMessage.payload.headers,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function uuidv4() {
|
function uuidv4() {
|
||||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
const r = (Math.random() * 16) | 0;
|
const r = (Math.random() * 16) | 0
|
||||||
const v = c == "x" ? r : (r & 0x3) | 0x8;
|
const v = c == 'x' ? r : (r & 0x3) | 0x8
|
||||||
return v.toString(16);
|
return v.toString(16)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user