# Tasks Work in this order, and finish each task's check before starting the next. Never log in to Cloudflare or deploy as part of these tasks. 1. **Set up (R27).** - Create one npm package with `src/client`, `src/worker` and `src/shared`. - Add `wrangler.jsonc` (assets, R2, the `Room` Durable Object, the three rate-limit bindings), the scripts and the two tsconfigs from `design.md`, then run `npm run types`. - If `spekkr.inputs.json` is missing at the repository root, generate it from the `customize.settings` defaults in `spekkr.json`: `{ "app_name": "Whiteboard", "accent_color": "#4c6ef5" }`. Read it into `src/shared/settings.ts`. Add `GET /api/health`. Check: `npm run dev` serves a page titled `app_name`, `/api/health` answers, and `npx wrangler deploy --dry-run --outdir /tmp/dry` bundles and lists the FILES, ROOMS, ASSETS, LINK_LIMIT, ROOM_LIMIT and FILE_LIMIT bindings. 2. **Scene model (R2–R6, R9–R12, R15).** In `src/shared`, write: - `types.ts`, `elements.ts` (new element, `bump`, duplicate, fractional indices that bump the version of re-keyed elements) - `geometry.ts`, `actions.ts`, `binding.ts`, `history.ts`, `reconcile.ts` Check: the "fractional indices", "reconcile", "z-order", "align, distribute, group, flip", "geometry", "arrow binding" and "undo history" unit tests pass. 3. **Files and crypto (R19, R20, R24).** Write `restore.ts` (restore, parse and serialize scenes and libraries), `crypto.ts` and `limits.ts`. Check: the "file format", "encryption" and "settings" unit tests pass. 4. **Rendering (R8, R6).** - `render.ts`: shape paths with roughjs and perfect-freehand, arrowheads, text, images, export to PNG and SVG. - `paint.ts`: the canvas frame, including the grid, selection, handles and collaborators. - Load Kalam. Check: the "R8 hand-drawn shapes" unit tests pass. A page that paints one of each element type shows filled hachure and solid shapes. 5. **Editor (R1–R17, R21, R22).** - `store.ts` and `controller.ts`: pointer, keyboard, wheel, touch and text editing. - The text editor layer (design "Text editor layer"): the textarea lives in `.text-editor-box`, whose scroll is turned into a canvas pan, so the toolbar and menus never scroll away on phones. - `Editor.tsx`: toolbar, style panel, menus, zoom/undo, help, context menu, and `window.__whiteboard`. - `StylePanel.tsx`, `theme.ts`. Check: the 1-canvas, 1-mobile and 2-style-actions e2e tests pass, except R23 persistence, which comes next. 6. **Browser canvas, files, library, export (R7, R18–R20, R23).** - `persist.ts`: localStorage and IndexedDB. - `files.ts`: image insert, downscale and SHA-1. - `dialogs.tsx`: export, open/save, library, shortcuts and confirm. - `main.tsx` / `pages.tsx`: the single canvas page and "Page not found". Check: R23 and the 3-files e2e tests pass. 7. **Shareable links (R24, R26).** - `POST /api/links` and `GET /api/links/:id` on R2 with the Origin check, id formats, the 10 MB limit, `LINK_LIMIT` (checked last, so refused requests don't count) and the blob headers. Links never expire. - `sealScene` / `openScene`: deflate with `CompressionStream` before encrypting. - The Share dialog's "Shareable link" section. - Opening `#json=` links with the banner and "Keep in this browser". Check: the 4-share e2e tests and `6-rate-limits.spec.ts` pass. 8. **Live collaboration (R25, R26).** - The `Room` Durable Object: hibernating WebSockets, peers and colours, at most 32 people, the chunked stored scene (`save` and snapshot broadcasts), and the 24-hour idle alarm that deletes storage and R2 images. - The room routes: the WebSocket forward (426 `{"error":"Expected a WebSocket upgrade"}` without an upgrade) with `ROOM_LIMIT`, and encrypted images with the size limits and then `FILE_LIMIT`. Rate limits are always the last check. - `collab.ts`: client-made room ids, sync, `save` after 1 s and on close, cursors, reconnect. - The session UI: name, avatars, cursors, Stop / Leave and the banner. Check: the 5-collab e2e tests pass. Run the first one with `--repeat-each=10` and confirm it passes every time. 9. **Finish (R26, R27).** - The README: what is stored where, "Anyone with the URL can use sharing" with the limits table and room expiry, the Cloudflare Access pointer, run, test and deploy. Check: `npm run typecheck`, `npm test` and `npm run e2e` all pass, and `npx wrangler deploy --dry-run --outdir /tmp/dry` succeeds.