A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: worker env detection on safari

+11 -4
+11 -4
src/common/worker.js
··· 21 21 // happens before any top-level `await` pause) and replays them once `ostiary` 22 22 // sets up the real handler. 23 23 // 24 - // Detection: regular Workers have `globalThis.onmessage === null`; the main 25 - // thread and SharedWorkers do not. 24 + // Detection: regular Workers are instances of DedicatedWorkerGlobalScope. 25 + // Previously we checked `globalThis.onmessage === null`, but Safari initialises 26 + // that property as `undefined` rather than `null`, causing the check to fail. 26 27 27 28 /** @type {MessageEvent[]} */ 28 29 const _earlyMessages = []; ··· 30 31 /** @type {null | (() => void)} */ 31 32 let _flushEarlyMessages = null; 32 33 33 - if (/** @type {any} */ (globalThis).onmessage === null) { 34 + if ( 35 + typeof DedicatedWorkerGlobalScope !== "undefined" && 36 + globalThis instanceof DedicatedWorkerGlobalScope 37 + ) { 34 38 const handler = /** @type {EventListener} */ ((event) => { 35 39 _earlyMessages.push(/** @type {MessageEvent} */ (event)); 36 40 }); ··· 58 62 callback, 59 63 context = /** @type {T} */ (/** @type {unknown} */ (globalThis)), 60 64 ) { 61 - if (/** @type {any} */ (context).onmessage === null) { 65 + if ( 66 + typeof DedicatedWorkerGlobalScope !== "undefined" && 67 + context instanceof DedicatedWorkerGlobalScope 68 + ) { 62 69 callback(context, true, crypto.randomUUID()); 63 70 64 71 // Replay any messages that arrived before the handler was registered.