forked from
tokono.ma/diffuse
A music player that connects to your cloud/distributed storage.
1import { defineElement, DiffuseElement, query } from "~/common/element.js";
2
3/**
4 * @import {ProxiedActions} from "~/common/worker.d.ts"
5 * @import {InputElement} from "~/components/input/types.d.ts"
6 * @import {Actions} from "~/components/artwork/types.d.ts"
7 */
8
9////////////////////////////////////////////
10// ELEMENT
11////////////////////////////////////////////
12
13/**
14 * @implements {ProxiedActions<Actions>}
15 */
16class InputArtwork extends DiffuseElement {
17 static NAME = "diffuse/artwork/input";
18 static WORKER_URL = "components/artwork/input/worker.js";
19
20 constructor() {
21 super();
22
23 /** @type {ProxiedActions<Actions>} */
24 const p = this.workerProxy();
25
26 this.get = p.get;
27 }
28
29 // LIFECYCLE
30
31 /** @override */
32 async connectedCallback() {
33 super.connectedCallback();
34
35 /** @type {InputElement} */
36 this.input = query(this, "input-selector");
37
38 await customElements.whenDefined(this.input.localName);
39 }
40
41 // WORKERS
42
43 /**
44 * @override
45 */
46 dependencies() {
47 if (!this.input) throw new Error("Input element not defined yet");
48 return { input: this.input };
49 }
50}
51
52export default InputArtwork;
53
54////////////////////////////////////////////
55// REGISTER
56////////////////////////////////////////////
57
58export const CLASS = InputArtwork;
59export const NAME = "da-input";
60
61defineElement(NAME, InputArtwork);