@utoo/web 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { ServiceWorkerHandShake } from "./message";
|
|
2
2
|
export async function installServiceWorker(url, scope, targetDirToCwd) {
|
|
3
|
-
const
|
|
3
|
+
const swUrl = new URL(url, window.location.href);
|
|
4
|
+
swUrl.searchParams.set("scope", scope);
|
|
5
|
+
if (targetDirToCwd) {
|
|
6
|
+
swUrl.searchParams.set("targetDirToCwd", targetDirToCwd);
|
|
7
|
+
}
|
|
8
|
+
const registration = await navigator.serviceWorker.register(swUrl.toString(), {
|
|
4
9
|
scope: "/",
|
|
5
10
|
});
|
|
6
11
|
return new Promise((resolve) => {
|
|
7
12
|
function sendMessage(sw) {
|
|
8
13
|
sw.postMessage({
|
|
9
14
|
[ServiceWorkerHandShake]: true,
|
|
10
|
-
scope,
|
|
11
|
-
targetDirToCwd,
|
|
12
15
|
});
|
|
13
16
|
resolve();
|
|
14
17
|
}
|
package/esm/serviceWorker.js
CHANGED
|
@@ -5,8 +5,9 @@ let _promise = new Promise((resolve) => {
|
|
|
5
5
|
_resolve = resolve;
|
|
6
6
|
});
|
|
7
7
|
let _projectEndpoint;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const params = new URLSearchParams(self.location.search);
|
|
9
|
+
const _serviceWorkerScope = params.get("scope");
|
|
10
|
+
const _targetDirToCwd = params.get("targetDirToCwd");
|
|
10
11
|
self.addEventListener("install", (event) => {
|
|
11
12
|
event.waitUntil(self.skipWaiting());
|
|
12
13
|
});
|
|
@@ -15,27 +16,23 @@ self.addEventListener("activate", (event) => {
|
|
|
15
16
|
});
|
|
16
17
|
self.addEventListener("message", (event) => {
|
|
17
18
|
if (event.data && event.data[ServiceWorkerHandShake] === true) {
|
|
18
|
-
_serviceWorkerScope = event.data.scope;
|
|
19
|
-
_targetDirToCwd = event.data.targetDirToCwd;
|
|
20
19
|
_projectEndpoint = Project.fork(new MessageChannel(), event.source);
|
|
21
20
|
_resolve();
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
self.addEventListener("fetch", (event) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
let { url: urlStr } = event.request;
|
|
25
|
+
let url = new URL(urlStr);
|
|
26
|
+
if (typeof _serviceWorkerScope === "string") {
|
|
27
|
+
if (url.pathname.startsWith(_serviceWorkerScope)) {
|
|
28
|
+
event.respondWith((async () => {
|
|
29
|
+
await _promise;
|
|
30
|
+
const relativePathToCwd = (_targetDirToCwd !== null && _targetDirToCwd !== void 0 ? _targetDirToCwd : ".") +
|
|
31
|
+
url.pathname.replace(_serviceWorkerScope, "");
|
|
32
|
+
return readFileFromProject(relativePathToCwd);
|
|
33
|
+
})());
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
return fetch(event.request);
|
|
37
|
-
}
|
|
38
|
-
})());
|
|
35
|
+
}
|
|
39
36
|
});
|
|
40
37
|
async function readFileFromProject(projectPath) {
|
|
41
38
|
try {
|
package/esm/utoo/index.js
CHANGED
|
@@ -315,8 +315,8 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
315
315
|
export function wasm_thread_entry_point(ptr) {
|
|
316
316
|
wasm.wasm_thread_entry_point(ptr);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
wasm.__wbindgen_export_6(arg0, arg1);
|
|
318
|
+
function __wbg_adapter_4(arg0, arg1, arg2) {
|
|
319
|
+
wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
|
|
320
320
|
}
|
|
321
321
|
let stack_pointer = 128;
|
|
322
322
|
function addBorrowedObject(obj) {
|
|
@@ -325,7 +325,7 @@ function addBorrowedObject(obj) {
|
|
|
325
325
|
heap[--stack_pointer] = obj;
|
|
326
326
|
return stack_pointer;
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function __wbg_adapter_7(arg0, arg1, arg2) {
|
|
329
329
|
try {
|
|
330
330
|
wasm.__wbindgen_export_7(arg0, arg1, addBorrowedObject(arg2));
|
|
331
331
|
}
|
|
@@ -333,11 +333,11 @@ function __wbg_adapter_15(arg0, arg1, arg2) {
|
|
|
333
333
|
heap[stack_pointer++] = undefined;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function __wbg_adapter_10(arg0, arg1, arg2) {
|
|
337
337
|
wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2));
|
|
338
338
|
}
|
|
339
|
-
function
|
|
340
|
-
wasm.__wbindgen_export_9(arg0, arg1
|
|
339
|
+
function __wbg_adapter_15(arg0, arg1) {
|
|
340
|
+
wasm.__wbindgen_export_9(arg0, arg1);
|
|
341
341
|
}
|
|
342
342
|
function __wbg_adapter_94(arg0, arg1, arg2, arg3) {
|
|
343
343
|
wasm.__wbindgen_export_10(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
@@ -1627,12 +1627,12 @@ function __wbg_get_imports() {
|
|
|
1627
1627
|
};
|
|
1628
1628
|
imports.wbg.__wbindgen_cast_228b11ff07fcd80f = function (arg0, arg1) {
|
|
1629
1629
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 8687, function: Function { arguments: [], shim_idx: 600, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1630
|
-
const ret = makeMutClosure(arg0, arg1, 8687,
|
|
1630
|
+
const ret = makeMutClosure(arg0, arg1, 8687, __wbg_adapter_15);
|
|
1631
1631
|
return addHeapObject(ret);
|
|
1632
1632
|
};
|
|
1633
1633
|
imports.wbg.__wbindgen_cast_3255823a0b603d96 = function (arg0, arg1) {
|
|
1634
1634
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 8661, function: Function { arguments: [Ref(NamedExternref("MessageEvent"))], shim_idx: 8685, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1635
|
-
const ret = makeMutClosure(arg0, arg1, 8661,
|
|
1635
|
+
const ret = makeMutClosure(arg0, arg1, 8661, __wbg_adapter_7);
|
|
1636
1636
|
return addHeapObject(ret);
|
|
1637
1637
|
};
|
|
1638
1638
|
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function (arg0) {
|
|
@@ -1642,12 +1642,12 @@ function __wbg_get_imports() {
|
|
|
1642
1642
|
};
|
|
1643
1643
|
imports.wbg.__wbindgen_cast_4c807b347a3d0cbf = function (arg0, arg1) {
|
|
1644
1644
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 599, function: Function { arguments: [], shim_idx: 600, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1645
|
-
const ret = makeMutClosure(arg0, arg1, 599,
|
|
1645
|
+
const ret = makeMutClosure(arg0, arg1, 599, __wbg_adapter_15);
|
|
1646
1646
|
return addHeapObject(ret);
|
|
1647
1647
|
};
|
|
1648
1648
|
imports.wbg.__wbindgen_cast_535e935a655d72df = function (arg0, arg1) {
|
|
1649
1649
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 8680, function: Function { arguments: [Externref], shim_idx: 8681, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1650
|
-
const ret = makeMutClosure(arg0, arg1, 8680,
|
|
1650
|
+
const ret = makeMutClosure(arg0, arg1, 8680, __wbg_adapter_4);
|
|
1651
1651
|
return addHeapObject(ret);
|
|
1652
1652
|
};
|
|
1653
1653
|
imports.wbg.__wbindgen_cast_76322aab70622876 = function (arg0, arg1) {
|
|
@@ -1676,12 +1676,12 @@ function __wbg_get_imports() {
|
|
|
1676
1676
|
};
|
|
1677
1677
|
imports.wbg.__wbindgen_cast_ded0188a991d8b3c = function (arg0, arg1) {
|
|
1678
1678
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 8680, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 8681, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1679
|
-
const ret = makeMutClosure(arg0, arg1, 8680,
|
|
1679
|
+
const ret = makeMutClosure(arg0, arg1, 8680, __wbg_adapter_4);
|
|
1680
1680
|
return addHeapObject(ret);
|
|
1681
1681
|
};
|
|
1682
1682
|
imports.wbg.__wbindgen_cast_ffa04fbd359d627f = function (arg0, arg1) {
|
|
1683
1683
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 8661, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 8662, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
|
|
1684
|
-
const ret = makeClosure(arg0, arg1, 8661,
|
|
1684
|
+
const ret = makeClosure(arg0, arg1, 8661, __wbg_adapter_10);
|
|
1685
1685
|
return addHeapObject(ret);
|
|
1686
1686
|
};
|
|
1687
1687
|
imports.wbg.__wbindgen_link_dd5153a359f2e504 = function (arg0) {
|
package/esm/utoo/index_bg.wasm
CHANGED
|
Binary file
|