src
pages
configurator
constituent
engine
input
native-fs
opensubsonic
s3
output
processor
scripts
···
41
41
import { CONNECTIONS } from "@scripts/configurator/input/constants";
42
42
import { applet, register } from "@scripts/applet/common";
43
43
import { endpoint, groupTracksPerScheme, transfer } from "@scripts/common";
44
44
+
import manifest from "./_manifest.json";
44
45
45
46
////////////////////////////////////////////
46
47
// SETUP
···
48
49
const worker = endpoint<Actions>(
49
50
new SharedWorker(new URL("../../../scripts/configurator/input/worker", import.meta.url), {
50
51
type: "module",
52
52
+
name: manifest.name,
51
53
}).port,
52
54
);
53
55
···
329
329
import type * as QueueEngine from "@applets/engine/queue/types.d.ts";
330
330
331
331
import type { Artwork } from "@applets/processor/artwork/types";
332
332
+
import { debounce } from "throttle-debounce";
332
333
333
334
// Register
334
335
const context = register();
···
436
437
// 🎢 QUEUE
437
438
////////////////////////////////////////////
438
439
439
439
-
// React to active queue item.
440
440
+
// Set active track based on active queue item.
440
441
441
442
reactive(
442
443
engine.queue,
443
444
(data) => comparable(data.future),
444
444
-
async () => {
445
445
+
() => {
445
446
const track = engine.queue.data.now;
446
447
447
448
if (!track) {
448
449
setActiveTrack(undefined);
449
449
-
setArtwork([]);
450
450
return;
451
451
}
452
452
453
453
setActiveTrack(track);
454
454
+
},
455
455
+
);
456
456
+
457
457
+
// Changed artwork based on active queue item.
458
458
+
// (debounced)
459
459
+
460
460
+
reactive(engine.queue, (data) => comparable(data.future), debounce(2000, changeArtwork));
461
461
+
462
462
+
async function changeArtwork() {
463
463
+
const track = engine.queue.data.now;
454
464
455
455
-
const cacheId = await trackArtworkCacheId(track);
456
456
-
const art = await processor.artwork.sendAction(
457
457
-
"artwork",
458
458
-
{
459
459
-
cacheId,
460
460
-
tags: track.tags,
461
461
-
urls: {
462
462
-
get: await inputUrl(configurator.input, track.uri, "GET").then((a) => a?.url),
463
463
-
head: await inputUrl(configurator.input, track.uri, "HEAD").then((a) => a?.url),
464
464
-
},
465
465
+
if (!track) {
466
466
+
setArtwork([]);
467
467
+
return;
468
468
+
}
469
469
+
470
470
+
const cacheId = await trackArtworkCacheId(track);
471
471
+
const art = await processor.artwork.sendAction(
472
472
+
"artwork",
473
473
+
{
474
474
+
cacheId,
475
475
+
tags: track.tags,
476
476
+
urls: {
477
477
+
get: await inputUrl(configurator.input, track.uri, "GET").then((a) => a?.url),
478
478
+
head: await inputUrl(configurator.input, track.uri, "HEAD").then((a) => a?.url),
465
479
},
466
466
-
{
467
467
-
timeoutDuration: 60000 * 5,
468
468
-
},
469
469
-
);
480
480
+
},
481
481
+
{
482
482
+
timeoutDuration: 60000 * 5,
483
483
+
},
484
484
+
);
470
485
471
471
-
const currTrack = activeTrack();
472
472
-
const currCacheId = currTrack ? await trackArtworkCacheId(currTrack) : undefined;
473
473
-
if (cacheId === currCacheId) setArtwork(art);
474
474
-
},
475
475
-
);
486
486
+
const currTrack = activeTrack();
487
487
+
const currCacheId = currTrack ? await trackArtworkCacheId(currTrack) : undefined;
488
488
+
if (cacheId === currCacheId) setArtwork(art);
489
489
+
}
476
490
477
491
////////////////////////////////////////////
478
492
// UI
···
5
5
6
6
import { register } from "@scripts/applet/common";
7
7
import { endpoint, SharedWorker, transfer } from "@scripts/common";
8
8
+
import manifest from "./_manifest.json";
8
9
9
10
////////////////////////////////////////////
10
11
// SETUP
···
12
13
const worker = endpoint<Actions>(
13
14
new SharedWorker(new URL("../../../scripts/engine/queue/worker", import.meta.url), {
14
15
type: "module",
16
16
+
name: manifest.name,
15
17
}).port,
16
18
);
17
19
···
21
21
import { register } from "@scripts/applet/common";
22
22
import { endpoint, inIframe, SharedWorker, transfer } from "@scripts/common";
23
23
import * as Mounting from "@scripts/input/native-fs/mounting";
24
24
+
import manifest from "./_manifest.json";
24
25
25
26
////////////////////////////////////////////
26
27
// SETUP
···
28
29
const worker = endpoint<Actions>(
29
30
new SharedWorker(new URL("../../../scripts/input/native-fs/worker", import.meta.url), {
30
31
type: "module",
32
32
+
name: manifest.name,
31
33
}).port,
32
34
);
33
35
···
22
22
import type { Track } from "@applets/core/types.d.ts";
23
23
import { register } from "@scripts/applet/common";
24
24
import { endpoint, inIframe, SharedWorker, transfer } from "@scripts/common";
25
25
+
import manifest from "./_manifest.json";
25
26
26
27
////////////////////////////////////////////
27
28
// SETUP
···
29
30
const worker = endpoint<Actions>(
30
31
new SharedWorker(new URL("../../../scripts/input/opensubsonic/worker", import.meta.url), {
31
32
type: "module",
33
33
+
name: manifest.name,
32
34
}).port,
33
35
);
34
36
···
42
42
import type { Track } from "@applets/core/types.d.ts";
43
43
import { register } from "@scripts/applet/common";
44
44
import { endpoint, inIframe, SharedWorker, transfer } from "@scripts/common";
45
45
+
import manifest from "./_manifest.json";
45
46
46
47
////////////////////////////////////////////
47
48
// SETUP
···
49
50
const worker = endpoint<Actions>(
50
51
new SharedWorker(new URL("../../../scripts/input/s3/worker", import.meta.url), {
51
52
type: "module",
53
53
+
name: manifest.name,
52
54
}).port,
53
55
);
54
56
···
4
4
import { register } from "@scripts/applet/common";
5
5
import { SharedWorker, endpoint, transfer } from "@scripts/common";
6
6
import { INITIAL_MANAGED_OUTPUT, outputManager } from "@scripts/output/common";
7
7
+
import manifest from "./_manifest.json";
7
8
8
9
////////////////////////////////////////////
9
10
// SETUP
···
11
12
const worker = endpoint<Actions>(
12
13
new SharedWorker(new URL("../../../scripts/output/indexed-db/worker", import.meta.url), {
13
14
type: "module",
15
15
+
name: manifest.name,
14
16
}).port,
15
17
);
16
18
···
8
8
import { INITIAL_MANAGED_OUTPUT, outputManager } from "@scripts/output/common";
9
9
import { endpoint, SharedWorker, transfer } from "@scripts/common";
10
10
import { IDB_DEVICE_KEY } from "@scripts/output/native-fs/constants";
11
11
+
import manifest from "./_manifest.json";
11
12
12
13
////////////////////////////////////////////
13
14
// SETUP
···
15
16
const worker = endpoint<Actions>(
16
17
new SharedWorker(new URL("../../../scripts/output/native-fs/worker", import.meta.url), {
17
18
type: "module",
19
19
+
name: manifest.name,
18
20
}).port,
19
21
);
20
22
···
4
4
import { register } from "@scripts/applet/common";
5
5
import { endpoint, SharedWorker } from "@scripts/common";
6
6
import { transfer } from "@scripts/common";
7
7
+
import manifest from "./_manifest.json";
7
8
8
9
////////////////////////////////////////////
9
10
// SETUP
···
11
12
const worker = endpoint<Actions>(
12
13
new SharedWorker(new URL("../../../scripts/processor/artwork/worker", import.meta.url), {
13
14
type: "module",
15
15
+
name: manifest.name,
14
16
}).port,
15
17
);
16
18
···
2
2
import type { Actions } from "@scripts/processor/metadata/worker";
3
3
import { register } from "@scripts/applet/common";
4
4
import { endpoint, SharedWorker, transfer } from "@scripts/common";
5
5
+
import manifest from "./_manifest.json";
5
6
6
7
////////////////////////////////////////////
7
8
// SETUP
···
9
10
const worker = endpoint<Actions>(
10
11
new SharedWorker(new URL("../../../scripts/processor/metadata/worker", import.meta.url), {
11
12
type: "module",
13
13
+
name: manifest.name,
12
14
}).port,
13
15
);
14
16
···
3
3
import type { Track } from "@applets/core/types";
4
4
import { register } from "@scripts/applet/common";
5
5
import { endpoint, transfer } from "@scripts/common";
6
6
+
import manifest from "./_manifest.json";
6
7
7
8
////////////////////////////////////////////
8
9
// SETUP
···
10
11
const worker = endpoint<Actions>(
11
12
new SharedWorker(new URL("../../../scripts/processor/search/worker", import.meta.url), {
12
13
type: "module",
14
14
+
name: manifest.name,
13
15
}).port,
14
16
);
15
17
···
261
261
arguments: args,
262
262
};
263
263
264
264
-
console.log("📣", actionMessage);
265
265
-
266
264
return await new Promise((resolve) => {
267
265
const actionCallback = (event: MessageEvent) => {
268
266
if (
···
22
22
// Actions
23
23
24
24
async function artwork(request: ArtworkRequest) {
25
25
-
console.log("INSERT REQ", request);
26
25
const art = await processRequest(request);
27
26
return transfer(art);
28
27
}
···
26
26
27
27
let meta;
28
28
29
29
-
console.log(urls?.get, stream, includeArtwork);
30
30
-
31
29
if (urls?.get.startsWith("blob:")) {
32
30
const blob = await fetch(urls.get).then((r) => r.blob());
33
31
meta = await parseBlob(blob, { skipCovers: !includeArtwork });