blob: 83dd1b18fd347f321ec28ea0614f3734e148e738 (
plain) (
blame)
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
34
|
// import * as assert from "node:assert/strict";
// assert.deepEqual({a: 1}, {a: 1});
// console.log(123);
// console.log({ navigator });
const f1 = x => x + 1;
const f2 = x => x - 1;
const registerServiceWorker = async ({ serviceWorkerPath, err }) => {
try {
await navigator.serviceWorker?.register(path)
} catch (e) {
err(`Service worker registration failed: ${e}`);
}
};
export const main = async ({
serviceWorkerPath = "./service-worker.js",
out = console.log,
err = console.warn,
} = {}) => {
const env = {
serviceWorkerPath,
out,
err,
};
await registerServiceWorker(env);
out("main called");
};
// <body onload="setOnline()" ononline="setOnline()" onoffline="setOnline()" >
|