forked from
tokono.ma/diffuse
A music player that connects to your cloud/distributed storage.
1import { ostiary, rpc, workerProxy } from "~/common/worker.js";
2
3/**
4 * @import {ActionsWithTunnel, ProxiedActions} from "~/common/worker.d.ts"
5 * @import {Actions} from "~/components/artwork/types.d.ts"
6 * @import {Actions as ConfiguratorActions} from "./types.d.ts"
7 */
8
9////////////////////////////////////////////
10// ACTIONS
11////////////////////////////////////////////
12
13/**
14 * @type {ActionsWithTunnel<ConfiguratorActions>['get']}
15 */
16export async function get({ data, ports }) {
17 const track = data;
18
19 for (const port of Object.values(ports)) {
20 /** @type {ProxiedActions<Actions>} */
21 const artwork = workerProxy(() => {
22 port.start();
23 return port;
24 });
25
26 const bytes = await artwork.get(track);
27 if (bytes !== null) return bytes;
28 }
29
30 return null;
31}
32
33////////////////////////////////////////////
34// ⚡️
35////////////////////////////////////////////
36
37ostiary((context) => {
38 rpc(context, { get });
39});