Experiment to rebuild Diffuse using web applets.
1<script>
2 import type { Tasks } from "@scripts/processor/metadata/worker";
3 import type { Extraction, Urls } from "./types";
4 import { register } from "@scripts/applet/common";
5 import { endpoint, SharedWorker, 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/metadata/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 async function supply(args: {
25 includeArtwork?: boolean;
26 mimeType?: string;
27 stream?: ReadableStream;
28 urls?: Urls;
29 }): Promise<Extraction> {
30 return worker.supply(transfer(args));
31 }
32
33 context.setActionHandler("supply", supply);
34</script>