A music player that connects to your cloud/distributed storage.
at v4 60 lines 1.6 kB view raw
1import { DiffuseElement } from "@common/element.js"; 2import { SCHEME } from "./constants.js"; 3import { buildURI, serversFromTracks } 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 OpensubsonicInput extends DiffuseElement { 20 static NAME = "diffuse/input/opensubsonic"; 21 static WORKER_URL = "components/input/opensubsonic/worker.js"; 22 23 SCHEME = SCHEME; 24 25 constructor() { 26 super(); 27 28 /** @type {ProxiedActions<InputActions>} */ 29 this.proxy = this.workerProxy(); 30 31 this.consult = this.proxy.consult; 32 this.detach = this.proxy.detach; 33 this.groupConsult = this.proxy.groupConsult; 34 this.list = this.proxy.list; 35 this.resolve = this.proxy.resolve; 36 } 37 38 // 🛠️ 39 40 /** @param {Track[]} tracks */ 41 sources(tracks) { 42 return Object.values(serversFromTracks(tracks)).map((server) => { 43 return { 44 label: `${server.host} (${server.username ?? server.apiKey})`, 45 uri: buildURI(server), 46 }; 47 }); 48 } 49} 50 51export default OpensubsonicInput; 52 53//////////////////////////////////////////// 54// REGISTER 55//////////////////////////////////////////// 56 57export const CLASS = OpensubsonicInput; 58export const NAME = "di-opensubsonic"; 59 60customElements.define(NAME, CLASS);