A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4 59 lines 1.5 kB view raw
1import { defineElement, 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 WebdavInput extends DiffuseElement { 20 static NAME = "diffuse/input/webdav"; 21 static WORKER_URL = "components/input/webdav/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 return Object.values(serversFromTracks(tracks)).map((server) => ({ 44 label: `WebDAV (${server.host}${server.dir})`, 45 uri: buildURI(server), 46 })); 47 } 48} 49 50export default WebdavInput; 51 52//////////////////////////////////////////// 53// REGISTER 54//////////////////////////////////////////// 55 56export const CLASS = WebdavInput; 57export const NAME = "di-webdav"; 58 59defineElement(NAME, CLASS);