A music player that connects to your cloud/distributed storage.
at v4 1.6 kB view raw
1import { DiffuseElement } from "@common/element.js"; 2import { SCHEME } from "./constants.js"; 3import { bucketsFromTracks, buildURI } 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 * @import {Demo} from "./types.d.ts" 10 */ 11 12//////////////////////////////////////////// 13// ELEMENT 14//////////////////////////////////////////// 15 16/** 17 * @implements {ProxiedActions<InputActions>} 18 * @implements {InputSchemeProvider} 19 */ 20class S3Input extends DiffuseElement { 21 static NAME = "diffuse/input/s3"; 22 static WORKER_URL = "components/input/s3/worker.js"; 23 24 SCHEME = SCHEME; 25 26 constructor() { 27 super(); 28 29 /** @type {ProxiedActions<InputActions & { demo: () => Demo }>} */ 30 this.proxy = this.workerProxy(); 31 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 this.demo = this.proxy.demo; 39 } 40 41 // 🛠️ 42 43 /** @param {Track[]} tracks */ 44 sources(tracks) { 45 return Object.values(bucketsFromTracks(tracks)).map((server) => { 46 return { 47 label: `${server.bucketName} (${server.host})`, 48 uri: buildURI(server), 49 }; 50 }); 51 } 52} 53 54export default S3Input; 55 56//////////////////////////////////////////// 57// REGISTER 58//////////////////////////////////////////// 59 60export const CLASS = S3Input; 61export const NAME = "di-s3"; 62 63customElements.define(NAME, CLASS);