Experiment to rebuild Diffuse using web applets.
1<script>
2 import type { Actions } from "@scripts/processor/metadata/worker";
3 import { register } from "@scripts/applet/common";
4 import { endpoint, SharedWorker } from "@scripts/common";
5
6 ////////////////////////////////////////////
7 // SETUP
8 ////////////////////////////////////////////
9 const worker = endpoint<Actions>(
10 new SharedWorker(new URL("../../../scripts/processor/metadata/worker", import.meta.url), {
11 type: "module",
12 }).port,
13 );
14
15 // Register applet
16 const context = register();
17
18 ////////////////////////////////////////////
19 // ACTIONS
20 ////////////////////////////////////////////
21 const supply: Actions["supply"] = (...args: Parameters<Actions["supply"]>) => {
22 return worker.call.supply(...args);
23 };
24
25 context.setActionHandler("supply", supply);
26</script>