Skip to content

gitflarePublicPartly agent-ready50

cf-durable-whiteboard

Realtime collaborative whiteboard on Cloudflare Durable Objects: presence cursors, WebSocket hibernation, SQLite storage, undo, PNG export.

main
Keep board zoom and pan stable across reloads6eb4fbd
TypeScript19 lines835 B
import { describe, it, expect } from "vitest";// @ts-ignoreimport * as V from "../public/viewport.js";const mem = () => { const m = new Map<string, string>(); return { getItem: (k: string) => m.get(k) ?? null, setItem: (k: string, v: string) => void m.set(k, v) }; };describe("view state", () => {  it("first visit is 100% centered", () => {    expect(V.loadView(mem(), "abc", 800, 600)).toEqual({ x: 400, y: 300, k: 1 });  });  it("restores saved view per board", () => {    const s = mem(); V.saveView(s, "a", { x: 5, y: 6, k: 1.68 });    expect(V.loadView(s, "a", 800, 600)).toEqual({ x: 5, y: 6, k: 1.68 });    expect(V.loadView(s, "b", 800, 600).k).toBe(1);  });  it("ignores corrupt data", () => {    const s = mem(); s.setItem(V.viewKey("a"), "{bad");    expect(V.loadView(s, "a", 100, 100).k).toBe(1);  });});