Something went wrong. Try again.
a proof of concept realtime collaborative todo list
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960import { signal } from "@preact/signals";
export const BASE = "/";
function getListUri() { return new URLSearchParams(location.search).get("list") ?? null;}
export const session = signal(null);export const listUri = signal(getListUri());
export const listName = signal("");export const listIsOwned = signal(false);export const listEditors = signal([]);export const showEditorsModal = signal(false);
window.addEventListener("popstate", () => { listUri.value = getListUri();});
export function navigate(uri) { const search = uri ? "?" + new URLSearchParams({ list: uri }) : ""; const full = BASE + search; if (full === location.pathname + location.search) return; history.pushState(null, "", full); listUri.value = uri ?? null;}
export const LIST_NSID = "com.jakelazaroff.atodo.list";export const ITEM_NSID = "com.jakelazaroff.atodo.item";export const TOMBSTONE_NSID = "com.jakelazaroff.atodo.tombstone";
export function parseAtUri(uri) { const m = uri.match(/^at:\/\/([^/]+)\/([^/]+)\/([^/]+)$/); return m ? { did: m[1], collection: m[2], rkey: m[3] } : null;}
export function makeAtUri(did, collection, rkey) { return `at://${did}/${collection}/${rkey}`;}
// Raw AT Protocol records for devtools inspection, populated by ListView.// Shape: { [nsid]: { [did]: Array<{ uri, value }> } }export const devtoolsRecords = signal({});export const devtoolsDids = signal([]);// { pause: () => void, resume: () => Promise<void> } while a list is active, null otherwise.export const devtoolsSubscription = signal(null);
// UI state for the resizable devtools panel. Lives here (rather than as local// component state) so other parts of the tree — like the editors modal — can// react to whether it's open and how tall it is.export const showDevtools = signal(false);export const devtoolsPanelHeight = signal(280);
// Kept in sync with the resize handle's height in style.css so other// components can compute the devtools panel's actual on-screen height// without measuring the DOM. (The panel's internal zoom only affects its// content, not its own box, so it isn't a factor here.)export const DEVTOOLS_HANDLE_HEIGHT = 6;