Add web/ — PTY+WebSocket server, xterm.js PWA client, Dockerfile, and PyInstaller notes
This commit is contained in:
22
web/static/sw.js
Normal file
22
web/static/sw.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const CACHE = "kanjin-v1";
|
||||
const PRECACHE = ["/", "/static/manifest.json"];
|
||||
|
||||
self.addEventListener("install", (e) => {
|
||||
e.waitUntil(
|
||||
caches.open(CACHE).then((c) => c.addAll(PRECACHE)).then(() => self.skipWaiting())
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("activate", (e) => {
|
||||
e.waitUntil(
|
||||
caches.keys().then((keys) =>
|
||||
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
|
||||
).then(() => self.clients.claim())
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (e) => {
|
||||
e.respondWith(
|
||||
caches.match(e.request).then((r) => r || fetch(e.request))
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user