This commit is contained in:
2023-11-13 02:01:23 +02:00
5 changed files with 45 additions and 7 deletions

View File

@ -36,6 +36,22 @@ if (!self.define) {
}
})
.then(() => {
return registry[uri] || (
new Promise(resolve => {
if ("document" in self) {
const script = document.createElement("script");
script.src = uri;
script.onload = resolve;
document.head.appendChild(script);
} else {
nextDefineUri = uri;
importScripts(uri);
resolve();
}
})
.then(() => {
let promise = registry[uri];
if (!promise) {
@ -54,11 +70,15 @@ if (!self.define) {
}
let exports = {};
const require = depUri => singleRequire(depUri, uri);
const require = depUri => singleRequire(depUri, uri);
const specialDeps = {
module: { uri },
exports,
require
};
registry[uri] = Promise.all(depsNames.map(
depName => specialDeps[depName] || require(depName)
)).then(deps => {
registry[uri] = Promise.all(depsNames.map(
depName => specialDeps[depName] || require(depName)
)).then(deps => {
@ -67,6 +87,7 @@ if (!self.define) {
});
};
}
define(['./workbox-b7fccfec'], (function (workbox) { 'use strict';
define(['./workbox-b7fccfec'], (function (workbox) { 'use strict';
self.skipWaiting();
@ -100,5 +121,21 @@ define(['./workbox-b7fccfec'], (function (workbox) { 'use strict';
})]
}), 'GET');
}));
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
allowlist: [/^\/$/]
}));
workbox.registerRoute(({
url
}) => [/^https:\/\/raw\.githubusercontent\.com\/.*/i, /^https:\/\/shabda\.ndre\.gr\/.*/i].some(regex => regex.test(url)), new workbox.CacheFirst({
"cacheName": "external-samples",
plugins: [new workbox.ExpirationPlugin({
maxEntries: 5000,
maxAgeSeconds: 2592000
}), new workbox.CacheableResponsePlugin({
statuses: [0, 200]
})]
}), 'GET');
}));
//# sourceMappingURL=sw.js.map