Skip to content

Commit 768132c

Browse files
authored
feat: add PWA support with vite-plugin-pwa and update assets (#5)
- Added vite-plugin-pwa to enable Progressive Web App features. - Created and configured PWA manifest with app details and icons. - Added mobile and desktop screenshots for better user experience. - Included new asset files: desktop.png, logo-192.png, logo-512.png, and mobile.png.
1 parent f356a4a commit 768132c

10 files changed

Lines changed: 11132 additions & 2468 deletions

File tree

dev-dist/registerSW.js

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

dev-dist/sw.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
let 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+
let 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+
let 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-7a5e81cd"], function (workbox) {
72+
"use strict";
73+
74+
self.addEventListener("message", (event) => {
75+
if (event.data && event.data.type === "SKIP_WAITING") {
76+
self.skipWaiting();
77+
}
78+
});
79+
80+
/**
81+
* The precacheAndRoute() method efficiently caches and responds to
82+
* requests for URLs in the manifest.
83+
* See https://goo.gl/S9QRab
84+
*/
85+
workbox.precacheAndRoute(
86+
[
87+
{
88+
url: "registerSW.js",
89+
revision: "3ca0b8505b4bec776b69afdba2768812",
90+
},
91+
{
92+
url: "index.html",
93+
revision: "0.78kklfuv5do",
94+
},
95+
],
96+
{},
97+
);
98+
workbox.cleanupOutdatedCaches();
99+
workbox.registerRoute(
100+
new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
101+
allowlist: [/^\/$/],
102+
}),
103+
);
104+
});

0 commit comments

Comments
 (0)