Skip to content

Commit 7221d93

Browse files
Improve webworker detection to support ServiceWorker and SharedWorker
1 parent a5847c9 commit 7221d93

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.5.2';
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" && (self.constructor?.name === 'DedicatedWorkerGlobalScope' || self.constructor?.name === 'ServiceWorkerGlobalScope' || self.constructor?.name === 'SharedWorkerGlobalScope');
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)