A music player that connects to your cloud/distributed storage.
at v4 34 lines 753 B view raw
1import * as TID from "@atcute/tid"; 2 3import { loadURI } from "../loader.js"; 4import * as CID from "../cid.js"; 5 6/** 7 * @import {Theme} from "~/definitions/types.d.ts" 8 */ 9 10/** 11 * @param {{ name: string; uri: string }} _args 12 * @param {{ fetchHTML: boolean }} options 13 */ 14export async function themeFromURI({ name, uri }, { fetchHTML }) { 15 const html = fetchHTML ? await loadURI(uri) : undefined; 16 const cid = html 17 ? await CID.create(0x55, new TextEncoder().encode(html)) 18 : undefined; 19 const timestamp = new Date().toISOString(); 20 21 /** @type {Theme} */ 22 const theme = { 23 $type: "sh.diffuse.output.theme", 24 createdAt: timestamp, 25 id: TID.now(), 26 cid, 27 html, 28 name, 29 updatedAt: timestamp, 30 uri, 31 }; 32 33 return theme; 34}