8000 feat: Added `ServiceWorker` case · fuse-box/fuse-box@1b77d27 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 1b77d27

Browse files
pavelnchanged
authored andcommitted
feat: Added ServiceWorker case
Closes #1163
1 parent 70e0ce8 commit 1b77d27

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/loader/LoaderAPI.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ declare let __root__: any;
66
declare let __fbx__dnm__: any;
77
declare const WorkerGlobalScope: any;
88

9+
const $isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined";
910
const $isWebWorker = typeof WorkerGlobalScope !== "undefined";
10-
const $isBrowser = typeof window !== "undefined" && typeof window.navigator !== "undefined" || $isWebWorker;
11-
const g = $isBrowser ? ($isWebWorker ? {} : window) : global;
11+
const $isBrowser = typeof window !== "undefined" && typeof window.navigator !== "undefined" || $isWebWorker || $isServiceWorker;
12+
const g = $isBrowser ? (($isWebWorker || $isServiceWorker) ? {} : window) : global;
1213

1314

1415
/**
@@ -53,7 +54,7 @@ type FSBX = {
5354

5455
// Patching global variable
5556
if ($isBrowser) {
56-
g["global"] = $isWebWorker ? {} : window;
57+
g["global"] = ($isWebWorker || $isServiceWorker) ? {} : window;
5758
}
5859

5960
// Set root
@@ -64,7 +65,7 @@ __root__ = !$isBrowser || typeof __fbx__dnm__ !== "undefined" ? module.exports :
6465
/**
6566
* A runtime storage for FuseBox
6667
*/
67-
const $fsbx: FSBX = $isBrowser ? $isWebWorker ? {} : (window["__fsbx__"] = window["__fsbx__"] || {})
68+
const $fsbx: FSBX = $isBrowser ? ($isWebWorker || $isServiceWorker) ? {} : (window["__fsbx__"] = window["__fsbx__"] || {})
6869
: g["$fsbx"] = g["$fsbx"] || {}; // in case of nodejs
6970

7071
if (!$isBrowser) {

0 commit comments

Comments
 (0)
0