Experiment to rebuild Diffuse using web applets.
0
fork

Configure Feed

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

fix: worker issues

+9 -5
+5 -2
src/scripts/common.ts
··· 4 4 5 5 import type { Track } from "@applets/core/types"; 6 6 7 - export { SharedWorkerPolyfill as SharedWorker } from "@okikio/sharedworker"; 7 + // export { SharedWorkerPolyfill as SharedWorker } from "@okikio/sharedworker"; 8 + export const SharedWorker = globalThis.SharedWorker; 8 9 9 10 export function arrayShuffle<T>(array: Array<T>): Array<T> { 10 11 if (array.length === 0) { ··· 47 48 48 49 export function endpoint<T extends Record<string, any>>(port: MessagePort) { 49 50 const e = createEndpoint<T>(port); 50 - port.start(); 51 + if ("start" in port) port.start(); 52 + else 53 + console.warn("Missing `start` function in port, probably using a regular worker:", port as any); 51 54 return e; 52 55 } 53 56
+4 -3
src/scripts/processor/artwork/worker.ts
··· 3 3 4 4 import type { Actions as MetadataActions } from "../metadata/worker"; 5 5 import type { Artwork, ArtworkRequest } from "./types"; 6 - import { SharedWorker, endpoint, expose } from "@scripts/common"; 6 + import { expose } from "@scripts/common"; 7 7 import { IDB_ARTWORK_PREFIX } from "./constants"; 8 + import { createEndpoint } from "@remote-ui/rpc"; 8 9 9 10 // State 10 11 let queue: ArtworkRequest[] = []; 11 12 12 13 // Metadata worker 13 - const metadataWorker = endpoint<MetadataActions>( 14 - new SharedWorker(new URL("../metadata/worker", import.meta.url), { type: "module" }).port, 14 + const metadataWorker = createEndpoint<MetadataActions>( 15 + new Worker(new URL("../metadata/worker", import.meta.url), { type: "module" }), 15 16 ); 16 17 17 18 ////////////////////////////////////////////