/** * 旧版画布的联合读取工具,并行取得目录元数据与v2快照。 * 它不协商canonical新模型,迁移感知的页面入口应使用canvas-entry中的分流流程。 */ import { CANVAS_ACCEPT } from "./canvas-v2.ts"; import { decodeSnapshot, type CanvasSnapshot, type CanvasRequest } from "./canvas-sync.ts"; import { matchesRef, type Board } from "./workspace.ts"; /** 逐段编码路由引用,校验board身份和工作区,再解码快照;AbortSignal传给两次请求。 * 返回数据不直接更新UI,导航是否仍有效由调用方控制。 */ export async function loadBoardCanvas(request: CanvasRequest, workspaceRef: string, boardRef: string, signal?: AbortSignal) { const path = `workspaces/${encodeURIComponent(workspaceRef)}/materials/${encodeURIComponent(boardRef)}`; const [board, snapshot] = await Promise.all([request(path, { signal }), request(path + "/canvas", { signal, headers: { Accept: CANVAS_ACCEPT } })]); if (board.kind !== "board" || !matchesRef(board, boardRef) || typeof board.workspace_id !== "string" || !board.workspace_id) throw new Error("invalid_reference"); return { board, snapshot: decodeSnapshot(snapshot) }; }