Something went wrong. Try again.
Experiment to rebuild Diffuse using web applets.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334import { signal } from "spellcaster";import * as IDB from "idb-keyval";
import { fetchHandles, fetchHandlesList } from "./common";import { IDB_HANDLES } from "./constants";
////////////////////////////////////////////// SIGNALS////////////////////////////////////////////export const [mounts, setMounts] = signal(await fetchHandlesList());
////////////////////////////////////////////// ACTIONS////////////////////////////////////////////export const mount = async () => { await showDirectoryPicker() .then(async (handle) => { const existingHandles = await fetchHandles(); const id = crypto.randomUUID();
await handle.requestPermission({ mode: "read" }); await IDB.set(IDB_HANDLES, { ...existingHandles, [id]: handle }); setMounts(await fetchHandlesList()); }) .catch(() => {});};
export const unmount = async (handleId: string) => { const handles = await fetchHandles(); delete handles[handleId]; await IDB.set(IDB_HANDLES, { ...handles }); setMounts(await fetchHandlesList());};