Experiment to rebuild Diffuse using web applets.
0
fork

Configure Feed

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

chore: 🧹

+22 -10
-2
src/pages/configurator/input/_applet.astro
··· 32 32 </style> 33 33 34 34 <script> 35 - import type { Applet } from "@web-applets/sdk"; 36 - 37 35 import type { Track } from "@applets/core/types"; 38 36 import type { Tasks } from "@scripts/configurator/input/worker"; 39 37 import { applet, register, tunnel } from "@scripts/applet/common";
-4
src/pages/orchestrator/input-cache/_applet.astro
··· 50 50 worker: true, 51 51 }); 52 52 53 - console.log("CONTEXTUALIZED"); 54 - 55 53 const tracks = await input.sendAction<Track[]>("list", cachedTracks, { 56 54 timeoutDuration: 60000 * 60 * 24, 57 55 worker: true, 58 56 }); 59 - 60 - console.log("LISTED", tracks); 61 57 62 58 // Process 63 59 const tracksWithMetadata = await tracks.reduce(
+18 -1
src/pages/processor/artwork/_applet.astro
··· 1 1 <script> 2 + import type { Tasks } from "@scripts/processor/artwork/worker"; 3 + import type { ArtworkRequest } from "./types"; 2 4 import { register } from "@scripts/applet/common"; 3 5 import { endpoint, SharedWorker } from "@scripts/common"; 4 6 import manifest from "./_manifest.json"; ··· 6 8 //////////////////////////////////////////// 7 9 // SETUP 8 10 //////////////////////////////////////////// 9 - const worker = endpoint( 11 + const worker = endpoint<Tasks>( 10 12 new SharedWorker(new URL("../../../scripts/processor/artwork/worker", import.meta.url), { 11 13 type: "module", 12 14 name: manifest.name, ··· 15 17 16 18 // Register 17 19 const context = register({ worker }); 20 + 21 + //////////////////////////////////////////// 22 + // ACTIONS 23 + //////////////////////////////////////////// 24 + 25 + async function artwork(request: ArtworkRequest) { 26 + return await worker.artwork(request); 27 + } 28 + 29 + async function supply(items: ArtworkRequest[]) { 30 + return await worker.supply(items); 31 + } 32 + 33 + context.setActionHandler("artwork", artwork); 34 + context.setActionHandler("supply", supply); 18 35 </script>
-2
src/scripts/common.ts
··· 198 198 function _manage<C extends Record<string, any>>( 199 199 connections: Record<string, PromiseWithResolvers<Comlink.Remote<C>>>, 200 200 ) { 201 - console.log(connections); 202 - 203 201 return (connectionId: string, workerPort: MessagePort) => { 204 202 let conn = connections[connectionId]; 205 203 const remote = endpoint<C>(workerPort);
+4 -1
src/scripts/processor/artwork/worker.ts
··· 18 18 supply, 19 19 }; 20 20 21 - provide({ actions }); 21 + const { tasks } = provide({ actions, tasks: actions }); 22 + 23 + export type Actions = typeof actions; 24 + export type Tasks = typeof tasks; 22 25 23 26 //////////////////////////////////////////// 24 27 // ACTIONS