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

Configure Feed

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

fix: tests

+60 -14
+1 -1
src/common/playlist.js
··· 2 2 * @import {PlaylistItem, Track} from "~/definitions/types.d.ts" 3 3 */ 4 4 5 - import { compareTimestamps } from "~/common/utils.js"; 5 + import { compareTimestamps } from "~/common/temporal.js"; 6 6 7 7 /** 8 8 * Filter tracks by playlist membership using an indexed lookup.
+11
src/common/temporal.js
··· 1 1 export const Temporal = /** @type {any} */ (globalThis).Temporal ?? 2 2 (await import("temporal-polyfill")).Temporal; 3 + 4 + /** 5 + * @param {string} a 6 + * @param {string} b 7 + */ 8 + export function compareTimestamps(a, b) { 9 + return Temporal.Instant.compare( 10 + Temporal.Instant.from(a), 11 + Temporal.Instant.from(b), 12 + ); 13 + }
-11
src/common/utils.js
··· 1 - import { Temporal } from "~/common/temporal.js"; 2 1 import { xxh32r } from "xxh32/dist/raw.js"; 3 2 4 3 /** ··· 34 33 return value === ""; 35 34 } 36 35 37 - /** 38 - * @param {string} a 39 - * @param {string} b 40 - */ 41 - export function compareTimestamps(a, b) { 42 - return Temporal.Instant.compare( 43 - Temporal.Instant.from(a), 44 - Temporal.Instant.from(b), 45 - ); 46 - } 47 36 48 37 /** 49 38 * @param {any} object
+47 -1
src/common/worker.js
··· 10 10 * @import {Announcement, MessengerRealm, ProxiedActions, Tunnel} from "./worker.d.ts" 11 11 */ 12 12 13 + // Early message buffer for regular Workers. 14 + // 15 + // If a Worker module (or its dependencies) contains a top-level `await`, the 16 + // browser can deliver queued incoming messages to `globalThis` while the module 17 + // evaluation is paused — before `ostiary`/`rpc()` has had a chance to register 18 + // a handler. Those messages would otherwise be silently dropped. 19 + // 20 + // This buffer captures such messages the moment this module is imported (which 21 + // happens before any top-level `await` pause) and replays them once `ostiary` 22 + // sets up the real handler. 23 + // 24 + // Detection: regular Workers have `globalThis.onmessage === null`; the main 25 + // thread and SharedWorkers do not. 26 + 27 + /** @type {MessageEvent[]} */ 28 + const _earlyMessages = []; 29 + 30 + /** @type {null | (() => void)} */ 31 + let _flushEarlyMessages = null; 32 + 33 + if (/** @type {any} */ (globalThis).onmessage === null) { 34 + const handler = /** @type {EventListener} */ ((event) => { 35 + _earlyMessages.push(/** @type {MessageEvent} */ (event)); 36 + }); 37 + 38 + globalThis.addEventListener("message", handler); 39 + 40 + _flushEarlyMessages = () => { 41 + globalThis.removeEventListener("message", handler); 42 + }; 43 + } 44 + 13 45 //////////////////////////////////////////// 14 46 // MISC 15 47 //////////////////////////////////////////// ··· 27 59 context = /** @type {T} */ (/** @type {unknown} */ (globalThis)), 28 60 ) { 29 61 if (/** @type {any} */ (context).onmessage === null) { 30 - return callback(context, true, crypto.randomUUID()); 62 + callback(context, true, crypto.randomUUID()); 63 + 64 + // Replay any messages that arrived before the handler was registered. 65 + if (_flushEarlyMessages) { 66 + _flushEarlyMessages(); 67 + _flushEarlyMessages = null; 68 + const ctx = /** @type {EventTarget} */ (/** @type {unknown} */ (context)); 69 + _earlyMessages.splice(0).forEach((e) => { 70 + ctx.dispatchEvent( 71 + new MessageEvent("message", { data: e.data, ports: [...e.ports] }), 72 + ); 73 + }); 74 + } 75 + 76 + return; 31 77 } 32 78 33 79 const c = /** @type {any} */ (context);
+1 -1
src/components/transformer/output/bytes/dasl-sync/element.js
··· 7 7 import * as CID from "~/common/cid.js"; 8 8 import { diff, strictEquality } from "~/common/compare.js"; 9 9 import { computed, signal } from "~/common/signal.js"; 10 - import { compareTimestamps } from "~/common/utils.js"; 10 + import { compareTimestamps } from "~/common/temporal.js"; 11 11 import { OutputTransformer } from "../../base.js"; 12 12 13 13 /**