-
Notifications
You must be signed in to change notification settings - Fork 2
/
pygbag060.js
33 lines (32 loc) · 1.16 KB
/
pygbag060.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
self.addEventListener('install', (event) => {
const base_dir = "https://pygame-web.github.io/archives/0.6";
console.log("installing service worker");
event.waitUntil(async function () {
const cache = await caches.open('pygbag0.6.0');
await cache.addAll([
`${base_dir}/browserfs.min.js`,
`${base_dir}/vt.js`,
`${base_dir}/vtx.js`,
`${base_dir}/vtx.js`,
`${base_dir}/vt/xterm-addon.image.js`,
`${base_dir}/vt/xterm.css`,
`${base_dir}/vt/xterm.js`,
`${base_dir}/pythons.js`,
`${base_dir}/python311/main.data`,
`${base_dir}/python311/main.js`,
`${base_dir}/python311/main.wasm`,
''
]);
}());
});
self.addEventListener('fetch', (event) => {
event.respondWith(async function () {
const cachedResponse = await (await caches.open('pygbag0.6.0')).match(event.request);
if (cachedResponse) {
console.log("CACHED", event.request);
return cachedResponse;
}
const networkResponse = await fetch(event.request);
return networkResponse;
}());
});