alpha
Login
or
Join now
tokono.ma
/
diffuse-applets
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Experiment to rebuild Diffuse using web applets.
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
feat: first worker channel
author
Steven Vandevelde
date
11 months ago
(Jul 8, 2025, 4:44 PM +0200)
commit
63b85616
63b8561612d3af142610e6f225a855bbd6564c88
parent
833864e8
833864e8669925348f29d7b4c39af4f084d4abbb
+70
-12
5 changed files
Expand all
Collapse all
Unified
Split
package-lock.json
src
pages
constituent
blur
artwork-controller
_applet.astro
orchestrator
input-cache
_applet.astro
processor
artwork
_applet.astro
scripts
processor
artwork
worker.ts
+1
-1
package-lock.json
Reviewed
···
2230
2230
"node_modules/@web-applets/sdk": {
2231
2231
"version": "0.2.6",
2232
2232
"resolved": "https://gitpkg.vercel.app/unternet-co/web-applets/sdk?tokono.ma/experiment&scripts.postinstall=npm%20i%20%40types%2Fnode%20%26%26%20npx%20tsc",
2233
2233
-
"integrity": "sha512-AL1T69Yr2yA0MV+JaCWj+SufF83aSBfwLe3iPVh5WB7qH1nH4vu2cC7JJK1FYNBs8wEYmyh2SNHGQjKQyoFy4w==",
2233
2233
+
"integrity": "sha512-6fDpl977RqV7zMfKDPrGEaJs2nX2cpLERFv6mC4pdpw2PwdBb1rqADitBRlEIquLUakga0pCfqJFSHqfRRJMOw==",
2234
2234
"hasInstallScript": true,
2235
2235
"license": "MIT"
2236
2236
},
+1
src/pages/constituent/blur/artwork-controller/_applet.astro
Reviewed
···
510
510
},
511
511
{
512
512
timeoutDuration: 60000 * 5,
513
513
+
worker: true,
513
514
},
514
515
);
515
516
+9
-5
src/pages/orchestrator/input-cache/_applet.astro
Reviewed
···
24
24
};
25
25
26
26
// Start processing once settled and tracks are loaded
27
27
-
context
28
28
-
.settled()
29
29
-
.then(() => configurator.output)
30
30
-
.then((output) => wait(output, (d) => d?.tracks.state === "loaded"))
31
31
-
.then(() => (context.isMainInstance() ? process() : undefined));
27
27
+
// context
28
28
+
// .settled()
29
29
+
// .then(() => configurator.output)
30
30
+
// .then((output) => wait(output, (d) => d?.tracks.state === "loaded"))
31
31
+
// .then(() => (context.isMainInstance() ? process() : undefined));
32
32
33
33
////////////////////////////////////////////
34
34
// ACTIONS
···
49
49
timeoutDuration: 60000 * 5,
50
50
});
51
51
52
52
+
console.log("CONTEXTUALIZED");
53
53
+
52
54
const tracks = await input.sendAction<Track[]>("list", cachedTracks, {
53
55
timeoutDuration: 60000 * 60 * 24,
54
56
});
57
57
+
58
58
+
console.log("LISTED", tracks);
55
59
56
60
// Process
57
61
const tracksWithMetadata = await tracks.reduce(
+8
-2
src/pages/processor/artwork/_applet.astro
Reviewed
···
19
19
// Register
20
20
const context = register();
21
21
22
22
+
context.scope.onworkerport = (event) => {
23
23
+
if (!event.port) return;
24
24
+
worker.connect(transfer(event.port));
25
25
+
};
26
26
+
22
27
////////////////////////////////////////////
23
28
// ACTIONS
24
29
////////////////////////////////////////////
25
30
function artwork(request: ArtworkRequest) {
26
26
-
return worker.artwork(transfer(request));
31
31
+
// return worker.artwork(transfer(request));
32
32
+
return [];
27
33
}
28
34
29
35
function supply(items: ArtworkRequest[]) {
30
30
-
return worker.supply(transfer(items));
36
36
+
// return worker.supply(transfer(items));
31
37
}
32
38
33
39
context.setActionHandler("artwork", artwork);
+51
-4
src/scripts/processor/artwork/worker.ts
Reviewed
···
5
5
import { expose, transfer } from "@scripts/common";
6
6
import { IDB_ARTWORK_PREFIX } from "./constants";
7
7
import { musicMetadataTags } from "../metadata/common";
8
8
+
import { getTransferables } from "@okikio/transferables";
8
9
9
10
// State
10
11
let queue: ArtworkRequest[] = [];
···
12
13
////////////////////////////////////////////
13
14
// ACTIONS
14
15
////////////////////////////////////////////
15
15
-
const actions = expose({
16
16
+
const c = expose({
17
17
+
connect,
18
18
+
});
19
19
+
20
20
+
export type Actions = typeof c;
21
21
+
22
22
+
const actions: { [key: string]: Function } = {
16
23
artwork,
17
24
supply,
18
18
-
});
25
25
+
};
26
26
+
27
27
+
// ⚡️
19
28
20
20
-
export type Actions = typeof actions;
29
29
+
async function connect(port: MessagePort) {
30
30
+
port.onmessage = async (message) => {
31
31
+
switch (message.data?.type) {
32
32
+
case "action":
33
33
+
return handleAction(port, message.data);
34
34
+
}
35
35
+
};
36
36
+
}
37
37
+
38
38
+
async function handleAction(
39
39
+
port: MessagePort,
40
40
+
action: {
41
41
+
type: "action";
42
42
+
id: string;
43
43
+
actionId: string;
44
44
+
arguments: any;
45
45
+
},
46
46
+
) {
47
47
+
const result = await actions[action.actionId]?.(action.arguments);
48
48
+
return postMessage(port, action.id, result);
49
49
+
}
50
50
+
51
51
+
function postMessage<T>(port: MessagePort, id: string, result: T) {
52
52
+
port.postMessage(
53
53
+
{
54
54
+
type: "actioncomplete",
55
55
+
id,
56
56
+
result,
57
57
+
},
58
58
+
{
59
59
+
transfer: getTransferables(result),
60
60
+
},
61
61
+
);
62
62
+
}
21
63
22
64
// Actions
23
65
24
66
async function artwork(request: ArtworkRequest) {
25
67
const art = await processRequest(request);
26
26
-
return transfer(art);
68
68
+
return art;
27
69
}
28
70
29
71
function supply(items: ArtworkRequest[]) {
···
154
196
// TODO: Retry if none was found?
155
197
const cache = await IDB.get(`${IDB_ARTWORK_PREFIX}/${req.cacheId}`);
156
198
if (cache && Array.isArray(cache) && cache.length) return cache;
199
199
+
200
200
+
// Request override
201
201
+
if (req.tags?.artist?.toUpperCase() === "VA") {
202
202
+
req.variousArtists = true;
203
203
+
}
157
204
158
205
// 🚀
159
206
let art: Artwork[] = [];