Skip to content

Commit 0188c31

Browse files
Improve webworker detection to support ServiceWorker and SharedWorker (#1346)
* Improve webworker detection to support ServiceWorker and SharedWorker * Apply suggestions from code review Co-authored-by: Joshua Lochner <admin@xenova.com> --------- Co-authored-by: Joshua Lochner <admin@xenova.com>
1 parent b1a8389 commit 0188c31

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const VERSION = '3.6.0';
3030

3131
// Check if various APIs are available (depends on environment)
3232
const IS_BROWSER_ENV = typeof window !== "undefined" && typeof window.document !== "undefined";
33-
const IS_WEBWORKER_ENV = typeof self !== "undefined" && self.constructor?.name === 'DedicatedWorkerGlobalScope';
33+
const IS_WEBWORKER_ENV = typeof self !== "undefined" && (['DedicatedWorkerGlobalScope', 'ServiceWorkerGlobalScope', 'SharedWorkerGlobalScope'].includes(self.constructor?.name));
3434
const IS_WEB_CACHE_AVAILABLE = typeof self !== "undefined" && 'caches' in self;
3535
const IS_WEBGPU_AVAILABLE = typeof navigator !== 'undefined' && 'gpu' in navigator;
3636
const IS_WEBNN_AVAILABLE = typeof navigator !== 'undefined' && 'ml' in navigator;

0 commit comments

Comments
 (0)