RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-16 04:21:21 -07:00
commit b52eeb14a1
827 changed files with 241421 additions and 0 deletions
@@ -0,0 +1,21 @@
import type { Workspace } from "./model.ts";
import { boardKey, readCatalog } from "../storage/catalog.ts";
import { boardDocument } from "../storage/board.ts";
/**
* The board that opens first in this workspace: the `pm-board:` key of a saved board, the path of a legacy Markdown board,
* or undefined for All tasks. Settings → Project Management writes `defaultBoardId` and `defaultBoardPath` of the catalog.
*/
export async function defaultBoardPath(workspace: Workspace): Promise<string | undefined> {
const snapshot = await readCatalog(workspace);
if (typeof snapshot.value.defaultBoardId !== "string") return;
const board = snapshot.value.boards.find(board => board.value.id === snapshot.value.defaultBoardId);
if (board) return board.archived ? undefined : boardKey(board.value.id);
if (snapshot.value.deletedBoardIds?.includes(snapshot.value.defaultBoardId)) return;
const path = snapshot.value.defaultBoardPath;
if (typeof path !== "string" || path.startsWith(".") || path.includes("\\") || path.split("/").some(part => !part || part === "..")) return;
try {
const legacy = boardDocument(await workspace.read(path), path);
return legacy?.id === snapshot.value.defaultBoardId && !legacy.archived ? path : undefined;
} catch { return; }
}