Experiment to rebuild Diffuse using web applets.
0

Configure Feed

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

at main 1.0 kB View raw
1<script> 2 import type { Tasks } from "@scripts/processor/search/worker"; 3 import type { Track } from "@applets/core/types"; 4 import { register } from "@scripts/applet/common"; 5 import { endpoint, transfer } from "@scripts/common"; 6 import manifest from "./_manifest.json"; 7 8 //////////////////////////////////////////// 9 // SETUP 10 //////////////////////////////////////////// 11 const worker = endpoint<Tasks>( 12 new SharedWorker(new URL("../../../scripts/processor/search/worker", import.meta.url), { 13 type: "module", 14 name: manifest.name, 15 }).port, 16 ); 17 18 // Register applet 19 const context = register({ worker }); 20 21 //////////////////////////////////////////// 22 // ACTIONS 23 //////////////////////////////////////////// 24 context.setActionHandler("search", search); 25 context.setActionHandler("supply", supply); 26 27 async function search(term: string): Promise<Track[]> { 28 return worker.search(term); 29 } 30 31 async function supply(tracks: Track[]) { 32 return worker.supply(transfer(tracks)); 33 } 34</script>