A music player that connects to your cloud/distributed storage.
1import { DiffuseElement } from "~/common/element.js";
2import { SCHEME } from "./constants.js";
3import { hostsFromTracks } from "./common.js";
4
5/**
6 * @import {InputActions, InputSchemeProvider} from "~/components/input/types.d.ts"
7 * @import {ProxiedActions} from "~/common/worker.d.ts"
8 * @import {Track} from "~/definitions/types.d.ts"
9 */
10
11////////////////////////////////////////////
12// ELEMENT
13////////////////////////////////////////////
14
15/**
16 * @implements {ProxiedActions<InputActions>}
17 * @implements {InputSchemeProvider}
18 */
19class HttpsInput extends DiffuseElement {
20 static NAME = "diffuse/input/https";
21 static WORKER_URL = "components/input/https/worker.js";
22
23 SCHEME = SCHEME;
24
25 constructor() {
26 super();
27
28 /** @type {ProxiedActions<InputActions>} */
29 this.proxy = this.workerProxy();
30
31 this.artwork = this.proxy.artwork;
32 this.consult = this.proxy.consult;
33 this.detach = this.proxy.detach;
34 this.groupConsult = this.proxy.groupConsult;
35 this.list = this.proxy.list;
36 this.resolve = this.proxy.resolve;
37 }
38
39 // 🛠️
40
41 /** @param {Track[]} tracks */
42 sources(tracks) {
43 const hosts = Object.values(hostsFromTracks(tracks));
44
45 return hosts.map((host) => ({
46 label: host,
47 uri: `https://${host}`,
48 }));
49 }
50}
51
52export default HttpsInput;
53
54////////////////////////////////////////////
55// REGISTER
56////////////////////////////////////////////
57
58export const CLASS = HttpsInput;
59export const NAME = "di-https";
60
61customElements.define(NAME, CLASS);