Skip to content

Commit 3cc068c

Browse files
committed
mode check added
1 parent e7fa920 commit 3cc068c

File tree

7 files changed

+3651
-2
lines changed

7 files changed

+3651
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,5 @@ $RECYCLE.BIN/
273273
# Windows shortcuts
274274
*.lnk
275275

276+
276277
# End of https://www.toptal.com/developers/gitignore/api/windows,linux,macos,react,visualstudiocode,node

biome.jsonc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
}
1111
},
1212
"files": {
13-
"ignore": ["dist", "node_modules", "pnpm-lock.yaml"]
13+
"ignore": ["dist", "node_modules", "pnpm-lock.yaml", "dev-dist"]
1414
}
1515
}

dev-dist/registerSW.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if ("serviceWorker" in navigator)
2+
navigator.serviceWorker.register("/react_pwa/dev-sw.js?dev-sw", {
3+
scope: "/react_pwa/",
4+
type: "classic",
5+
});

dev-dist/sw.js

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
* Copyright 2018 Google Inc. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
// If the loader is already loaded, just stop.
15+
if (!self.define) {
16+
const registry = {};
17+
18+
// Used for `eval` and `importScripts` where we can't get script URL by other means.
19+
// In both cases, it's safe to use a global var because those functions are synchronous.
20+
let nextDefineUri;
21+
22+
const singleRequire = (uri, parentUri) => {
23+
uri = new URL(uri + ".js", parentUri).href;
24+
return (
25+
registry[uri] ||
26+
new Promise((resolve) => {
27+
if ("document" in self) {
28+
const script = document.createElement("script");
29+
script.src = uri;
30+
script.onload = resolve;
31+
document.head.appendChild(script);
32+
} else {
33+
nextDefineUri = uri;
34+
importScripts(uri);
35+
resolve();
36+
}
37+
}).then(() => {
38+
const promise = registry[uri];
39+
if (!promise) {
40+
throw new Error(`Module ${uri} didn’t register its module`);
41+
}
42+
return promise;
43+
})
44+
);
45+
};
46+
47+
self.define = (depsNames, factory) => {
48+
const uri =
49+
nextDefineUri ||
50+
("document" in self ? document.currentScript.src : "") ||
51+
location.href;
52+
if (registry[uri]) {
53+
// Module is already loading or loaded.
54+
return;
55+
}
56+
const exports = {};
57+
const require = (depUri) => singleRequire(depUri, uri);
58+
const specialDeps = {
59+
module: { uri },
60+
exports,
61+
require,
62+
};
63+
registry[uri] = Promise.all(
64+
depsNames.map((depName) => specialDeps[depName] || require(depName)),
65+
).then((deps) => {
66+
factory(...deps);
67+
return exports;
68+
});
69+
};
70+
}
71+
define(["./workbox-c676b6d3"], (workbox) => {
72+
self.skipWaiting();
73+
workbox.clientsClaim();
74+
75+
/**
76+
* The precacheAndRoute() method efficiently caches and responds to
77+
* requests for URLs in the manifest.
78+
* See https://goo.gl/S9QRab
79+
*/
80+
workbox.precacheAndRoute(
81+
[
82+
{
83+
url: "registerSW.js",
84+
revision: "711bd134fba5e3500fbfc72b61696bf7",
85+
},
86+
{
87+
url: "index.html",
88+
revision: "0.gg92c0fmgi",
89+
},
90+
],
91+
{},
92+
);
93+
workbox.cleanupOutdatedCaches();
94+
workbox.registerRoute(
95+
new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
96+
allowlist: [/^\/$/],
97+
}),
98+
);
99+
});

0 commit comments

Comments
 (0)