A music player that connects to your cloud/distributed storage.
at v4 64 lines 1.5 kB view raw
1import { DiffuseElement, whenElementsDefined } from "@common/element.js"; 2 3/** 4 * @import {ProxiedActions, Tunnel} from "@common/worker.d.ts" 5 * @import {InputActions, InputElement} from "@components/input/types.d.ts" 6 */ 7 8/** 9 * @typedef {{ element: InputElement, tunnel: Tunnel, worker: Worker | SharedWorker }} Input 10 */ 11 12//////////////////////////////////////////// 13// ELEMENT 14//////////////////////////////////////////// 15 16/** 17 * @implements {ProxiedActions<InputActions>} 18 */ 19class InputConfigurator extends DiffuseElement { 20 static NAME = "diffuse/configurator/input"; 21 static WORKER_URL = "components/configurator/input/worker.js"; 22 23 constructor() { 24 super(); 25 26 /** @type {ProxiedActions<InputActions>} */ 27 const proxy = this.workerProxy(); 28 29 this.consult = proxy.consult; 30 this.detach = proxy.detach; 31 this.groupConsult = proxy.groupConsult; 32 this.list = proxy.list; 33 this.resolve = proxy.resolve; 34 } 35 36 // WORKERS 37 38 /** 39 * @override 40 */ 41 dependencies() { 42 return this.inputs(); 43 } 44 45 inputs() { 46 return Object.fromEntries( 47 Array.from(this.children).map((element) => { 48 const input = /** @type {InputElement} */ (element); 49 return [input.SCHEME, input]; 50 }), 51 ); 52 } 53} 54 55export default InputConfigurator; 56 57//////////////////////////////////////////// 58// REGISTER 59//////////////////////////////////////////// 60 61export const CLASS = InputConfigurator; 62export const NAME = "dc-input"; 63 64customElements.define(NAME, CLASS);