Something went wrong. Try again.
Experiment to rebuild Diffuse using web applets.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { computed, effect, type Signal } from "spellcaster";import { repeat, tags, text } from "spellcaster/hyperscript.js";
import { mount, mounts, unmount } from "./mounting";import { isSupported } from "./common";
////////////////////////////////////////////// SIGNALS////////////////////////////////////////////
// Mount buttondocument.getElementById("mount")?.addEventListener("click", () => { if (isSupported()) mount(); else alert("The File System Access API is not supported on this platform.");});
// Directoriesconst dirList = computed(() => { return new Map( mounts().map((mount) => { return [mount.id, mount]; }), );});
const Item = (signal: Signal<{ id: string; handle: FileSystemDirectoryHandle }>) => { const { id, handle } = signal();
return tags.li({}, [ tags.span( { onclick: () => unmount(id), style: "cursor: pointer;", title: "Click/tap to delete" }, text(handle.name), ), ]);};
const Directories = computed(() => { if (mounts().length === 0) { return tags.p({ id: "directories" }, [ tags.small({}, [ tags.em({}, text("No audio added yet, click the button below to add some.")), ]), ]); }
return tags.ul({ id: "directories" }, repeat(dirList, Item));});
// Add to DOMeffect(() => { document.getElementById("directories")?.replaceWith(Directories());});