diff --git a/AGENTS.md b/AGENTS.md index 2452ed17..e04416e8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -703,7 +703,7 @@ door's first-tap prompt, shown once; features/lessons.js). `stripPins` so a plain reload keeps the device's arrangement and seeds the next bid — the both-places rule the sidebar filter scope uses. Wiped by the sign-out key list.) -- Per-project, in save/load: `codes` (rulebook slice 4 — `{ plumbing?, electrical?, hvac?, jurisdiction?, occupancy? }`, only what the project CHOSE (null = never chosen; `occupancy` is `'public' | 'private'`, the fixture-unit column the project reads, WATER-PLAN rung 1, set from the flip word in Project Settings' Codes row hint and resolved to public when unchosen); `getProjectCodes()` layers the device default (localStorage `codesDefault`, written on every change like `defaultTrade`) and `CODE_DEFAULTS` under it; rides every intake beside `ceilingHeightFt` — save payloads, hydrate, the IndexedDB backup, canvas JSON export/import, copy/load/pdf-intake), `trade` (`'plumbing' | 'electrical' | 'hvac' | null` — the Quick creator's vocabulary and the handoff's stamp; explicit, set from the Quick tab's Trade segment or Project Settings, null = never chosen = plumbing behavior), `ceilingHeightFt` + `makeUpFt` (vertical by default — with a counter's `mountHeightIn` the Chain tool writes ceiling − mount + make-up as the run's drop; Room Sizer rooms override the ceiling; null ceiling = off), `bidCheck` (S5 — `{ manual: { : true }, loadAmps?, volts? }`: the Bid Check's manual ticks and the voltage-drop defaults; the auto verdicts are computed, never stored; D9 adds the duct rows — `duct-*` ids from duct-model's `DUCT_BID_CHECK_ROWS`, ticked in the same `manual` map once the project has a duct run), `maxZoom`, `groups`, `ductSettings` (the Duct +- Per-project, in save/load: `codes` (rulebook slice 4 — `{ plumbing?, electrical?, hvac?, jurisdiction?, occupancy? }`, only what the project CHOSE (null = never chosen; `occupancy` is `'public' | 'private'`, the fixture-unit column the project reads, WATER-PLAN rung 1, set from the flip word in Project Settings' Codes row hint and resolved to public when unchosen); `getProjectCodes()` layers the device default (localStorage `codesDefault`, written on every change like `defaultTrade`) and `CODE_DEFAULTS` under it; rides every intake beside `ceilingHeightFt` — save payloads, hydrate, the IndexedDB backup, canvas JSON export/import, copy/load/pdf-intake), `trade` (`'plumbing' | 'electrical' | 'hvac' | null` — the Quick creator's vocabulary and the handoff's stamp; explicit, set from the Quick tab's Trade segment or Project Settings, null = never chosen = plumbing behavior), `ceilingHeightFt` + `makeUpFt` (vertical by default — with a counter's `mountHeightIn` the Chain tool writes ceiling − mount + make-up as the run's drop; Room Sizer rooms override the ceiling; null ceiling = off), `bidCheck` (S5 — `{ manual: { : true }, loadAmps?, volts? }`: the Bid Check's manual ticks and the voltage-drop defaults; the auto verdicts are computed, never stored; D9 adds the duct rows — `duct-*` ids from duct-model's `DUCT_BID_CHECK_ROWS`, ticked in the same `manual` map once the project has a duct run), `maxZoom` (the project's own zoom ceiling, 400% unset; DEEP-ZOOM 2026-10-14: `getMaxZoom()` holds it under the device's `deviceZoomCeiling()`, 1200% on a small canvas cap or a low-memory Chromium else 5000%, then the layout wall over the sheet's longest side, and the save blob keeps the project's own through `getProjectMaxZoom`, never the device's), `groups`, `ductSettings` (the Duct Schedule knobs — `seamWastePct` (+15 default), `fittingFactorPct` (40) and the Counted|Factor `fittingMode`, plus the D6 design-build ductulator knobs `frictionInPer100ft` (0.08) and `maxVelocityFpm` (1200), edited on the diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index a3a471ce..20883985 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -17,7 +17,7 @@ Implementation history (the sync-hardening work + the modularization arc) lives ## Large-file map (decomposition status) -Current first-party line counts (`wc -l`, 2026-10-13 — the **numbers and this +Current first-party line counts (`wc -l`, 2026-10-14 — the **numbers and this date are GENERATED** by `npm run build:filemap` ([scripts/build-filemap.js](scripts/build-filemap.js)); `npm run check` fails when they drift, so don't edit counts by hand. Which files are listed and every @@ -28,18 +28,18 @@ off — and where it doesn't. | File | Lines | Status / verdict | |------|------:|------------------| -| [app.js](app.js) | 7,171 | **The remaining monolith** — down from 16.2k (9.9k after save-engine Stage 6, 8.1k after the Tier-2 splits, then −987 from the canvas-draw extraction). The only file worth actively shrinking; the region table below says what's left and in what order. | +| [app.js](app.js) | 7,321 | **The remaining monolith** — down from 16.2k (9.9k after save-engine Stage 6, 8.1k after the Tier-2 splits, then −987 from the canvas-draw extraction). The only file worth actively shrinking; the region table below says what's left and in what order. | | [save-engine.js](save-engine.js) | 3,263 | Done — the extracted save/sync seam module (Stages 1–7), 91 node tests. R21 (2026-09-26) folded its repeated blocks inside the file; do not split it. Large but modular and fully node-testable; no further action. | | [pdf-tile-cache.js](pdf-tile-cache.js) | 867 | Done (stage 1, 2026-07-30) — the PDF raster-cache substrate extracted from app.js's "PDF render bitmap cache" section (`createPdfTileCache(ctx)`, the save-engine seam recipe): page-bitmap LRU, downsample pyramid, persisted zoom rungs, idle prefetch, full-document warm-up. Pinned by nine Playwright specs (page-switch-cache, pyramid, pyramid-persist, rung-prefetch, doc-warmup, zoom-ladder, commit-tile, crop-tile, tile-grid). Stage 2 (later): the Sharp crop tile / tile grid section. | | [canvas-draw.js](canvas-draw.js) | 1,417 | Done — the unified annotation draw core (`createCanvasDraw(deps)` + `drawAnnotationsCore`), node-tested, guarded by [render-pixels.spec.js](render-pixels.spec.js). Both draw paths are thin env-builders over it. | -| [app/index.html](app/index.html) | 3,880 | The shell: HTML structure + every modal, no inline JS. Flat markup with no build step to split it; grows roughly linearly with modal count. Leave. | -| [styles.css](styles.css) | 2,880 | All CSS, token-organized. Leave. | +| [app/index.html](app/index.html) | 3,882 | The shell: HTML structure + every modal, no inline JS. Flat markup with no build step to split it; grows roughly linearly with modal count. Leave. | +| [styles.css](styles.css) | 2,881 | All CSS, token-organized. Leave. | | [features/load-project.js](features/load-project.js) | 751 | Largest feature file (Load Project modal + filters), split 2026-07-30: the copy/fork domain moved to [features/copy-project.js](features/copy-project.js) at the file's documented domain boundary, and the row renderer was decomposed along its action boundaries (size / row HTML / actions / admin access / load click). Healthy — leave. | | [annotation-model.js](annotation-model.js) | 1,225 | Done — extracted canvas/annotation data model + node tests. | | [undo-stack.js](undo-stack.js) | 218 | Done (2026-07-30) — `createUndoStack(ctx)` split out of annotation-model.js: the model is pure-ish data transformation, the stack is a command-history controller with UI side-effect hooks in its ctx. Covered by the undo tests in [annotation-model.test.js](annotation-model.test.js) (interleaved with model tests, dual-require). | | [icons.js](icons.js) | 531 | Bundled icon data, mostly literals. Leave. | | [report.js](report.js) | 991 | Self-contained report builder with a frozen `window.*` contract. Leave. | -| `features/*.js` (108 files) | 37,513 total | Mostly single-feature files with their own specs. The largest are the teaching layer (tutorial 1,656; lessons 1,043, the three courses 609 to 725; tour-blank 794) and duct-tool (866); DECOMPOSITION_MAP.md has a verdict for every one. | +| `features/*.js` (108 files) | 37,531 total | Mostly single-feature files with their own specs. The largest are the teaching layer (tutorial 1,656; lessons 1,043, the three courses 609 to 725; tour-blank 794) and duct-tool (866); DECOMPOSITION_MAP.md has a verdict for every one. | ### What's left inside app.js (by `// SECTION:` size) @@ -123,14 +123,15 @@ modules. Candidates in priority order: | [zoom-ladder.spec.js](zoom-ladder.spec.js) | Playwright regression for the **zoom ladder** (commit-snap to rungs; `snapZoomToRung`/`nextRungUp`/`nextRungDown` in constants.js) — ± buttons step exactly one rung and invert; a wheel gesture keeps a continuous preview but its COMMIT lands on a rung with the cursor anchor preserved (±2px); bouncing between visited rungs adds zero visible-path rasters (cache-miss stat frozen, hits +4) — the point of the feature. `npx playwright test zoom-ladder.spec.js` | | [rung-prefetch.spec.js](rung-prefetch.spec.js) | Playwright regression for the **adjacent-rung idle prefetch** — after a commit lands on a rung, `runPdfBitmapPrefetch` warms rung±1 of the current page (before the neighbor-page fit prefetches); asserts the prefetched stat rises and the next `doZoomIn` needs zero new pdf.js render calls (pure blit). `npx playwright test rung-prefetch.spec.js` | | [commit-tile.spec.js](commit-tile.spec.js) | Playwright regression for **window-first cold commits** — wraps `pdfPage.render` so full-page rasters resolve ~1.2s late (tile renders run native), then asserts: a cold-rung wheel commit shows the sharp visible-window tile while the old base is still up, the committed zoom is already on a rung, the tile retires when the crisp base paints, and a warm commit (down-rung prefetched — gated on `App.__pdfBitmapCacheKeys`, since the `prefetched` stat is a lifetime counter) blits with no tile. `npx playwright test commit-tile.spec.js` | +| [deep-zoom.spec.js](deep-zoom.spec.js) | Playwright regression for **DEEP-ZOOM** (journeys/plans/DEEP-ZOOM.md, 2026-10-14): on the restaurant sheet at 3000%, `#annWindowCanvas` is visible, covers the wrapper, and is one screen of pixels at full density while `#annCanvas` is clamped under 0.4; the full-page buffers sit under 24 Mpx (part 3); a pixel probe at the seeded 8 px run's midpoint reads its colour on both canvases, and the SAME screen distance from the centre is clear on the window and still ink on the page overlay (sharp versus soft); twenty real Move drags re-cut the window at every mouse-up where the pan left the view with the ratchet untouched; hide-marks clears it; at 100% it retires. The ceiling case: `getMaxZoom()` is 50 on a capable device (12 under `deviceMemory < 4`), the layout wall over a 400,000 pt sheet gives 40, a 10 Mpx canvas cap gives 12, the project's own 8 wins under it; Zoom Settings on the small-cap device shows 1200 with the hint naming the project's 3000% and Done without moving leaves 3000% alone, a moved slider writes; the rail shows 14 ticks with a 2000% label at the full ceiling. `npx playwright test deep-zoom.spec.js` | | [crop-tile.spec.js](crop-tile.spec.js) | Playwright regression for the **deep-zoom sharp crop tile** (`#cropCanvas`, `// SECTION: Deep-zoom sharp crop tile` in app.js) — forces an `effectiveDpr` clamp via `App.setCanvasCaps` + zoom 3, then asserts the tile appears with ink after the 200ms debounce, covers the visible window at the right content-space position, respects the render-area budget, sits below the annotation overlay (z-order + DOM order), clears immediately on a page flip (`renderPdf` entry), and retires at a sharp zoom; no console/page errors. `npx playwright test crop-tile.spec.js` | | [render-pixels.spec.js](render-pixels.spec.js) | **The pixel-regression safety net** (baselines re-recorded 2026-10-12 for LABEL-SLIDE: the fixture's closed polyline's label moved from its closing leg near the first vertex to halfway round, the old walk's latent bug; every other pixel unchanged) for the draw paths — seeds a fixture takeoff exercising every mark kind (straight + arc quick lines with drops/labels/selection glow, closed polyline, highlight, multiply + scale zones, room box, wrapping note, counters with rings/outline/index numbers, group dots, legend, grid), then compares the raw canvas buffers of the live overlay (`renderAnnotations` → `#annCanvas`) and two export renders (`renderAnnotationsToContext` at export scale with `lineScale`/`markerScale`, and via `annotationsOverride`) against committed baselines in `render-pixels.spec.js-snapshots/` with `maxDiffPixels: 0`. Baselines are machine-rasterized — regenerate on a new machine with `--update-snapshots`. `npx playwright test render-pixels.spec.js` | | [features/canvas-repair.js](features/canvas-repair.js) | First feature-file split of the `app.js` IIFE (the `window.App` registry pilot) — the Canvas Repair modal (`openCanvasRepairModal` + `applyCanvasRepair`). Its own classic-script IIFE loaded **after** [app.js](app.js) (and before [report.js](report.js)); reads shared `state`/helpers from `window.App` at call time and registers `App.openCanvasRepairModal`/`App.applyCanvasRepair` back onto it. app.js invokes them via deferred bindings (`() => App.fn()`). See "Feature files / `window.App` registry" below | | [canvas-repair.spec.js](canvas-repair.spec.js) | Playwright regression for the registry pilot — uploads `test-2pages.pdf`, adds a page-0 marker, asserts `window.App.openCanvasRepairModal`/`applyCanvasRepair` are functions and `App.state === window.state`, opens the modal + clicks `#canvasRepairApply` (no-op default mapping), and asserts the marker survives with no console / page errors; `npx playwright test canvas-repair.spec.js` | | [features/note.js](features/note.js) | Second feature-file split (`window.App` registry pilot #2) — the Note add/edit modal (`openNoteModal` + its `noteModalCancel`/`noteModalDone` button bindings). Its own IIFE loaded **after** [app.js](app.js); reads shared `state`/helpers from `window.App` at call time, registers `App.openNoteModal`, and binds the modal's Cancel/Done at load. app.js's 5 inbound call sites (canvas click / dblclick / context-menu / touch handlers) call it via `App.openNoteModal(...)` | | [note.spec.js](note.spec.js) | Playwright regression for pilot #2 — uploads `test-2pages.pdf`, asserts `window.App.openNoteModal`/`ensureActiveCanvas`/`showLineColorModal` are functions, then exercises add (type + `#noteModalDone` persists a note), edit (reopen on the note object, change text), and cancel (`#noteModalCancel` clears `pendingNote`/`editingNote` and adds nothing), reading notes back via `window.App.ensureActiveCanvas`; asserts no console / page errors; `npx playwright test note.spec.js` | -| [features/zoom.js](features/zoom.js) | Third feature-file split (`window.App` registry pilot #3) — the Zoom Settings modal (`showZoomModal` + its `zoomModalClose`/`zoomMax`/`zoomSpeed` handlers). Its own IIFE loaded **after** [app.js](app.js); reads shared `state`/helpers from `window.App` at call time, registers `App.showZoomModal`, binds the modal inputs at load. `getMaxZoom`/`getWheelZoomSpeed` stay defined in app.js (used in ~10 places there) and are read via `App.*` — the first "publish-only, do-not-move" dep. its inbound call sites are the Zoom Rail's gear button ([features/zoom-rail.js](features/zoom-rail.js)) — the zoom-% click itself only toggles the rail | -| [features/zoom-rail.js](features/zoom-rail.js) | The **Zoom Rail** — the giant floating vertical zoom slider on the right edge, **toggled** by clicking the footer zoom-% (`#zoomPct`). Log-scale track (equal distance per doubling, 0.2 → `getMaxZoom()`) with round-percent tick marks (majors labelled), an accent-yellow %-readout draggable thumb with a light magnetic snap to ticks, +/− buttons, and a gear that opens the Zoom Settings modal (the modal's only entry point — the rail's z-index 300 sits above the modal overlay's 200, so both stay usable together). Drags anchor the zoom at the canvas-wrapper center and reuse app.js's cheap transform preview + debounced commit. Replaced the old `#zoomOverlay` popover (markup/handlers/dismisser removed). Registers `App.openZoomRail`/`App.closeZoomRail`/`App.toggleZoomRail` plus the `App.onZoomRailSync` core-→-feature callback (called from `updateUI` and the pinch rAF so the thumb tracks wheel/pinch/±/fit while open; also rebuilds ticks when Zoom Settings changes the max zoom, and closes the rail if the project unloads). Five publish-only deps `doZoomIn`/`doZoomOut`/`updateContainerTransform`/`commitWheelZoom`/`syncZoomIndicators` (the drag's per-move sync is the light `syncZoomIndicators` — zoom-% + thumb only, **never** the full `updateUI()`, whose all-pages sidebar rebuild made zoom gestures lag on large projects; the full `updateUI()` runs once in the commit — see [zoom-no-updateui-during-gesture.spec.js](zoom-no-updateui-during-gesture.spec.js)). Dismissal: re-click the zoom %, outside click (clicks inside `#zoomModal` don't count), or Escape — the rail **stays until dismissed** (B9/J15 removed the old ~5s idle auto-fade, an invisible timer that lost the rail mid-adjustment on a field pause) | +| [features/zoom.js](features/zoom.js) | Third feature-file split (`window.App` registry pilot #3) — the Zoom Settings modal (`showZoomModal` + its `zoomModalClose`/`zoomMax`/`zoomSpeed` handlers). Its own IIFE loaded **after** [app.js](app.js); reads shared `state`/helpers from `window.App` at call time, registers `App.showZoomModal`, binds the modal inputs at load. `getMaxZoom`/`getWheelZoomSpeed` stay defined in app.js (used in ~10 places there) and are read via `App.*` — the first "publish-only, do-not-move" dep. its inbound call sites are the Zoom Rail's gear button ([features/zoom-rail.js](features/zoom-rail.js)) — the zoom-% click itself only toggles the rail DEEP-ZOOM part 2 (2026-10-14): the slider runs to the device's ceiling (`App.getDeviceZoomCeiling()`, 5000% on a capable device, 1200% on a small-cap or low-memory one) and shows the PROJECT's own ceiling held to that range, with `#zoomMaxHint` saying where the device holds it; Done writes `state.maxZoom` only when the slider moved, so opening the dialog on a phone never lowers a project's 3000% to 1200%. | +| [features/zoom-rail.js](features/zoom-rail.js) | The **Zoom Rail** — the giant floating vertical zoom slider on the right edge, **toggled** by clicking the footer zoom-% (`#zoomPct`). Log-scale track (equal distance per doubling, 0.2 → `getMaxZoom()`) with round-percent tick marks (majors labelled), an accent-yellow %-readout draggable thumb with a light magnetic snap to ticks, +/− buttons, and a gear that opens the Zoom Settings modal (the modal's only entry point — the rail's z-index 300 sits above the modal overlay's 200, so both stay usable together). Drags anchor the zoom at the canvas-wrapper center and reuse app.js's cheap transform preview + debounced commit. Replaced the old `#zoomOverlay` popover (markup/handlers/dismisser removed). Registers `App.openZoomRail`/`App.closeZoomRail`/`App.toggleZoomRail` plus the `App.onZoomRailSync` core-→-feature callback (called from `updateUI` and the pinch rAF so the thumb tracks wheel/pinch/±/fit while open; also rebuilds ticks when Zoom Settings changes the max zoom, and closes the rail if the project unloads). Five publish-only deps `doZoomIn`/`doZoomOut`/`updateContainerTransform`/`commitWheelZoom`/`syncZoomIndicators` (the drag's per-move sync is the light `syncZoomIndicators` — zoom-% + thumb only, **never** the full `updateUI()`, whose all-pages sidebar rebuild made zoom gestures lag on large projects; the full `updateUI()` runs once in the commit — see [zoom-no-updateui-during-gesture.spec.js](zoom-no-updateui-during-gesture.spec.js)). Dismissal: re-click the zoom %, outside click (clicks inside `#zoomModal` don't count), or Escape — the rail **stays until dismissed** (B9/J15 removed the old ~5s idle auto-fade, an invisible timer that lost the rail mid-adjustment on a field pause) DEEP-ZOOM (2026-10-14): `TICK_PCTS` gains 2000, 3000 and 5000 (2000 a major), shown only when `getMaxZoom()` allows. | | [zoom-rail.spec.js](zoom-rail.spec.js) | Playwright regression for the Zoom Rail — uploads `test-2pages.pdf`, asserts the registry contract (`openZoomRail`/`closeZoomRail`/`toggleZoomRail`/`onZoomRailSync` + the 4 publish-only deps), `#zoomPct` click toggles the rail (modal does **not** open; gear opens it with the rail staying up), mouse-drags the track past the ends asserting `state.zoom` rises to max then clamps to 0.2 with `#zoomPct` in sync, stays-until-dismissed persistence (B9: no idle auto-fade; unrelated `updateUI` churn doesn't dismiss it either) + the accent-yellow thumb, tick rebuild when max zoom changes 400% → 1200% (8 → 11 ticks), external `state.zoom` writes resync the thumb, mobile viewport tap shows the rail without the modal (and `#zoomOverlay` is gone), and outside-click + Escape dismiss; asserts no console / page errors; `npx playwright test zoom-rail.spec.js` | | [page-switch-cache.spec.js](page-switch-cache.spec.js) | Perf regression for the **PDF render bitmap cache** (`// SECTION: PDF render bitmap cache` in app.js) — the LRU of recently-rendered page ImageBitmaps keyed by the self-validating tuple (pdfPage proxy + rotation + zoom + effDpr) that makes revisits and idle-prefetched neighbor visits a synchronous blit instead of a pdf.js raster. Wraps each page's `pdfPage.render` with a call-counting spy, then asserts: a revisit adds **zero** render calls with `App.__pdfBitmapCacheStats().hits` incremented and real canvas content; rotate + undo (which rewrites `page.rotation` in place) both force fresh rasters (key self-invalidation); 12 rapid no-wait page flips ride the new `pdfRenderTask.cancel()` path with no console errors and land on the right page; the ~250ms idle prefetch caches the neighbor so its first visit is a blit; and `App.clearPdfBitmapCache()` empties to size 0. `npx playwright test page-switch-cache.spec.js` | | [zoom-no-updateui-during-gesture.spec.js](zoom-no-updateui-during-gesture.spec.js) | Perf regression for the zoom-gesture paths — asserts wheel zooming does **not** run the full `updateUI()` per frame (sentinel child planted in `#pagesList` must survive the gesture — any `updateUI()` wipes it via `renderPagesList`'s innerHTML rebuild), that `#zoomPct` still tracks `state.zoom` per frame via the light `syncZoomIndicators()` (published on the registry), and that exactly one full `updateUI()` + re-render lands at the debounced `commitWheelZoom` (sentinel gone after the 150 ms window); uploads `samples/sample-plan.pdf`; asserts no console / page errors; `npx playwright test zoom-no-updateui-during-gesture.spec.js` | @@ -665,63 +666,64 @@ live list with current `app.js` line numbers is generated by `npm run build:toc` - L802 - Undo/redo stacks - L1012 - [sync] Checkout probe, hashing & PDF cache - L1074 - Math & Format Helpers -- L1594 - Coordinate Helpers -- L1602 - PDF render bitmap cache -- L1656 - Sharp crop tile (deep-zoom sharpening + window-first commits) -- L1667 - PDF Rendering -- L2542 - Recent bids -- L2569 - UI Render Functions -- L2926 - Placing selection (setActiveCounterType / setActiveLineType) -- L3037 - Inline rename & polyline edit mode -- L3153 - Modal primitives (showModal / hideModal) -- L3319 - Toasts & line color picker -- L3388 - Airboard cloud sync -- L3433 - Supabase RPC & presence heartbeat -- L3473 - User activity / event telemetry -- L3532 - Supabase auth & dev auth -- L3723 - [sync] Checkout subscription & permission refresh -- L3733 - Modals & Handlers -- L3801 - PDF intake (upload, test PDF, hashing) -- L3809 - Toolbar tool buttons -- L3970 - Tool sidebar buttons & legend overlay -- L4056 - Add Line Type modal -- L4138 - Line color & sidebar handlers -- L4209 - Polyline modal & drawing -- L4266 - Zoom bar & page navigation -- L4292 - Export canvas JSON -- L4317 - PDF download helpers -- L4326 - View-link URL helpers & show-highlights/notes -- L4358 - Custom icon upload handler -- L4368 - Macros & custom-icon tips openers -- L4388 - Sidebar drawer toggles -- L4419 - Mobile actions burger menu pointer & header logo -- L4431 - User Activity pointer (format.js + features/user-activity.js) -- L4443 - My Settings pointer (features/my-settings.js) -- L4468 - Project Settings pointer (features/project-settings.js) -- L4474 - Auth & settings entry buttons - - L4519 - Project Settings checkout & Save Status bell - - L4632 - [sync] Checkout expired recovery - - L4688 - [sync] Turn In - - L4753 - Share modal pointer & copy-project openers - - L4784 - Settings menu actions - - L4796 - Auth sign-in form - - L4821 - Save Project modal - - L4832 - Checkout expired recovery modal wiring - - L4935 - Last-session restore prompt -- L4947 - Canvas Event Handlers -- L5331 - Event Binding -- L5341 - Aim loupe (mobile press-hold precise placement) -- L5494 - Zoom transform preview & commit -- L5573 - Canvas mouse, wheel & touch handlers -- L6262 - Global dropdown dismissal & keyboard hotkeys -- L6440 - [sync] Manual save to cloud -- L6450 - [sync] Auto-save -- L6457 - [sync] Local backup (IndexedDB takeoff state) -- L6466 - [sync] Visibility & timers -- L6483 - [sync] Checkout keep-alive -- L6497 - App feature registry -- L6890 - View-only mode -- L6896 - Init / boot +- L1607 - Coordinate Helpers +- L1615 - PDF render bitmap cache +- L1669 - Sharp crop tile (deep-zoom sharpening + window-first commits) +- L1680 - PDF Rendering +- L2495 - Deep-zoom overlay window +- L2669 - Recent bids +- L2696 - UI Render Functions +- L3053 - Placing selection (setActiveCounterType / setActiveLineType) +- L3164 - Inline rename & polyline edit mode +- L3280 - Modal primitives (showModal / hideModal) +- L3446 - Toasts & line color picker +- L3515 - Airboard cloud sync +- L3560 - Supabase RPC & presence heartbeat +- L3600 - User activity / event telemetry +- L3659 - Supabase auth & dev auth +- L3850 - [sync] Checkout subscription & permission refresh +- L3860 - Modals & Handlers +- L3928 - PDF intake (upload, test PDF, hashing) +- L3936 - Toolbar tool buttons +- L4097 - Tool sidebar buttons & legend overlay +- L4183 - Add Line Type modal +- L4265 - Line color & sidebar handlers +- L4336 - Polyline modal & drawing +- L4393 - Zoom bar & page navigation +- L4419 - Export canvas JSON +- L4444 - PDF download helpers +- L4453 - View-link URL helpers & show-highlights/notes +- L4485 - Custom icon upload handler +- L4495 - Macros & custom-icon tips openers +- L4515 - Sidebar drawer toggles +- L4546 - Mobile actions burger menu pointer & header logo +- L4558 - User Activity pointer (format.js + features/user-activity.js) +- L4570 - My Settings pointer (features/my-settings.js) +- L4595 - Project Settings pointer (features/project-settings.js) +- L4601 - Auth & settings entry buttons + - L4646 - Project Settings checkout & Save Status bell + - L4759 - [sync] Checkout expired recovery + - L4815 - [sync] Turn In + - L4880 - Share modal pointer & copy-project openers + - L4911 - Settings menu actions + - L4923 - Auth sign-in form + - L4948 - Save Project modal + - L4959 - Checkout expired recovery modal wiring + - L5062 - Last-session restore prompt +- L5074 - Canvas Event Handlers +- L5458 - Event Binding +- L5468 - Aim loupe (mobile press-hold precise placement) +- L5637 - Zoom transform preview & commit +- L5717 - Canvas mouse, wheel & touch handlers +- L6410 - Global dropdown dismissal & keyboard hotkeys +- L6588 - [sync] Manual save to cloud +- L6598 - [sync] Auto-save +- L6605 - [sync] Local backup (IndexedDB takeoff state) +- L6614 - [sync] Visibility & timers +- L6631 - [sync] Checkout keep-alive +- L6645 - App feature registry +- L7040 - View-only mode +- L7046 - Init / boot @@ -1420,6 +1422,21 @@ Everything below is built on top of the [RECONSTITUTE.md](RECONSTITUTE.md) core. info modes, Esc cancels, sits above every other modal). No native `alert()` / `confirm()` / `prompt()` anywhere in app.js, features/, or report.js. - **Middle mouse pan** — hold middle button to pan regardless of tool. +- **Deep zoom** (DEEP-ZOOM, 2026-10-14, [journeys/plans/DEEP-ZOOM.md](journeys/plans/DEEP-ZOOM.md)) — zoom + runs to 5000% (`deviceZoomCeiling()`: 1200% on a small canvas cap or a low-memory Chromium, + then the layout wall over the sheet's longest side; `getMaxZoom()` is the project's own ceiling + under it, and only the project's rides the payload). Past the canvas budget the page overlay + `#annCanvas` is as soft as the PDF base, so `renderAnnotationWindow` (`// SECTION: Deep-zoom + overlay window`) paints the **overlay window** `#annWindowCanvas`: the visible area at full + density, the same `paintOverlay` body with `toCanvas` rebound to `state.zoom × dpr` minus the + window's origin (`overlayOffset`), boxed by the crop tile's math and re-cut on every overlay + paint, at pan end and at a cold zoom commit (`recutOverlayWindow`, a full overlay paint); the + window paints first so the page pass leaves every DOM anchor the overlays record in + page-buffer units, and the page pass ends by clearing the window's box out of `#annCanvas`, + so the soft overlay never halos the crisp marks and stands only in the strips a pan reveals; + the aim loupe samples the crop canvas and the window where they stand. Past 4× the full-page canvas is + only a backdrop under the tiles and the window, so `effectiveDpr` holds it to 24 Mpx + (`DEEP_ZOOM_BASE_MAX_AREA`). Spec: [deep-zoom.spec.js](deep-zoom.spec.js). - **Zoom Rail** — clicking the footer zoom % toggles a giant floating vertical slider on the right edge ([features/zoom-rail.js](features/zoom-rail.js)): log-scale track with labelled tick marks, a draggable accent-yellow %-readout diff --git a/CHANGELOG.md b/CHANGELOG.md index db3d29ad..d097fd11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,41 @@ expired recovery UX" work occupies that slot). --- +## feat(zoom): zoom past 1200% with a sharp overlay window (DEEP-ZOOM, 2026-10-14) + +Wendi wanted to zoom in past 1200%, and at depth her marks blurred while the sheet stayed crisp. +The plan (journeys/plans/DEEP-ZOOM.md, measured on main the same day) in three parts: + +- **The overlay window** (part 1). Past the canvas budget `#annCanvas` is sized to the clamped + `#pdfCanvas` buffer, so at 3000% the marks drew at a fifth of the screen's density. A third + canvas, `#annWindowCanvas`, is now the visible area at full density: `renderAnnotationsInner` + is split into the sizing and `paintOverlay(ctx, width, height, page)`, and + `renderAnnotationWindow` runs that same body with `currentRenderZoom`, `currentEffDpr` and a + new `overlayOffset` rebound around the call (restored in a finally), boxed by the crop tile's + math in container units with the k factor, so a mid-gesture paint and a tile-first commit are + screen-sharp too. Painted with every overlay paint (the window first, so the page pass leaves + the overlays' DOM anchors in page units), re-cut at the four pan-end sites beside + `scheduleCropTile` and at a cold zoom commit before its tile rasters; hidden while the page + overlay is not meaningfully soft (the crop tile's 1.15 deficit) and when one screen of pixels + would exceed the render budget. The page pass is byte-identical (render-pixels holds). + Found on the first 3000% screenshot: the window is transparent, and under it the page overlay + drew every mark fat and soft (raw buffer widths at a fifth of the density), haloing the crisp + marks; so the page pass ends by clearing the window's box out of itself, under the window only + the window shows, the soft overlay stands only in the strips a pan reveals, and a pan end or a + cold commit repaints the whole overlay (`recutOverlayWindow`). The aim loupe samples the crop + canvas and the window where they stand, so a tablet keeps sharp marks under the loupe at depth. +- **The ceiling** (part 2). `getMaxZoom()` is the project's own ceiling under + `deviceZoomCeiling()`: 1200% where the canvas probe found under 32 Mpx (iOS Safari) or Chromium + reports under 4 GB, else 5000%, then Firefox's layout wall as 16e6 over the sheet's longest + side. The save blob and the project payload carry `getProjectMaxZoom()`, never the device's. + Zoom Settings' slider runs to the device's ceiling, shows the project's own held to it with a + hint where the device holds it, and writes only when moved. The rail gains 2000, 3000 and 5000. +- **The backdrop budget** (part 3). Past 4× `effectiveDpr` holds the full-page buffer to 24 Mpx, + about half the peak memory at depth, since the tiles and the window carry the screen. +- app.js (`// SECTION: Deep-zoom overlay window`), app/index.html, styles.css, features/zoom.js, + features/zoom-rail.js, deep-zoom.spec.js (new), zoom.spec.js (the slider's max is the device's + ceiling), the ARCHITECTURE rows and catalog bullet, AGENTS.md's `maxZoom` field, the plan file's + Built section, the PUNCHLIST row closed, sw.js, the TOC and the file map restamped. ## docs: the hand-kept lists caught up to main at 655a023 (2026-10-13) A read of AGENTS.md, ARCHITECTURE.md, RECONSTITUTE.md, SUPABASE_SETUP.md, FEATURES.md, diff --git a/PUNCHLIST.md b/PUNCHLIST.md index 40b9ac91..48d11df5 100644 --- a/PUNCHLIST.md +++ b/PUNCHLIST.md @@ -39,4 +39,3 @@ How agents add to this list: AGENTS.md, "Recording a to-do". | ICON-STORE | Opening a project REPLACES the user's own icon store with its `customIconPaths` (annotation-model.js:509 and 444 into app.js:209, wholesale; a project with an empty list empties the store), and they ride the user's later saves. Since #268 they are inert, but should a project be able to add icons to a user's store at all? Decide, then build | decision | ⚑ call | — | | | DEMO-TRACK | The demo track behind the test drive's "Try it" is built for all three trades (phases 1 to 3 landed 2026-10-02). Left: a tester's real tablet and phone walk with a stopwatch against the 60 s target | test | tester | — | [DEMO-TRACK.md](journeys/plans/DEMO-TRACK.md#open-after-phase-2) | | BOARD-QUIET | All Bids for a lead: the board becomes a quiet list, actions on the hovered row, exceptions only, grouped by estimator once there are enough; PEOPLE-TWINS, REVIEW-BAR, DROP-CARD-BUTTONS and CLOUD-OFF-ICON shipped the first steps (the twin fleet off by default, the decision in the opened bid only, oldest waiting first, the cloud silent unless the PDF is missing) | build | agent | — | [BID-BOARD-QUIET.md](journeys/plans/BID-BOARD-QUIET.md#what-is-left) | -| DEEP-ZOOM | Zoom past 1200% for Wendi: a full-density overlay window for the marks at deep zoom, the ceiling to 5000% with the device and per-sheet guard rails, and a smaller full-page backdrop past 4×; measured safe to 30000% on main, the blur is the marks, not the sheet | build | agent | — | [DEEP-ZOOM.md](journeys/plans/DEEP-ZOOM.md#the-build) | diff --git a/app.js b/app.js index 591e00a7..4fd7ad38 100644 --- a/app.js +++ b/app.js @@ -698,7 +698,7 @@ // (the load paths write it). getServerClockOffsetMs: () => serverClockOffsetMs, captureDisplayInfoObj: () => captureDisplayInfoObj(), - getMaxZoom: () => getMaxZoom(), + getMaxZoom: () => getProjectMaxZoom(), // DEEP-ZOOM: the project's own ceiling rides the save blob, never the device's assertPdfWithinLimit: (bytes, context) => assertPdfWithinLimit(bytes, context), maybeLogProjectSaveEvent: (projectId) => maybeLogProjectSaveEvent(projectId), setLastSaveIncludedPdf: (v) => { lastSaveIncludedPdf = v; }, @@ -1256,6 +1256,7 @@ const pdfCanvas = document.getElementById('pdfCanvas'); const cropCanvas = document.getElementById('cropCanvas'); const annCanvas = document.getElementById('annCanvas'); + const annWindowCanvas = document.getElementById('annWindowCanvas'); // DEEP-ZOOM: the overlay window (the visible area, full density) // Low-latency presentation hint: desynchronize these canvases from the // compositor's vsync queue (Chrome honors it; others ignore it). Must be // the FIRST getContext call per canvas — every later plain getContext('2d') @@ -1264,6 +1265,7 @@ if (pdfCanvas) pdfCanvas.getContext('2d', { desynchronized: true }); if (cropCanvas) cropCanvas.getContext('2d', { desynchronized: true }); if (annCanvas) annCanvas.getContext('2d', { desynchronized: true }); + if (annWindowCanvas) annWindowCanvas.getContext('2d', { desynchronized: true }); } catch (_) { /* hint only */ } const aimLoupe = document.getElementById('aimLoupe'); @@ -1302,6 +1304,12 @@ const RENDER_AREA_SAFETY_MIN = 0.12; // ratchet floor — below this we accept a soft bitmap const RENDER_AREA_SAFETY_STEP = 0.6; // each ratchet step multiplies the knob let renderAreaSafety = RENDER_AREA_SAFETY_MAX; + // DEEP-ZOOM part 3 (journeys/plans/DEEP-ZOOM.md): past DEEP_ZOOM_BASE_FROM the full-page canvas is + // only a backdrop under the tile compositor and the overlay window, so its buffer is budgeted to + // DEEP_ZOOM_BASE_MAX_AREA and peak memory at depth about halves. The bitmap cache keys carry the + // effDpr, so cached rungs stay valid; the step only binds where the base is already clamped. + const DEEP_ZOOM_BASE_FROM = 4; + const DEEP_ZOOM_BASE_MAX_AREA = 24e6; // Does this canvas's far corner actually read back? A canvas that silently failed to // allocate its backing store (memory pressure / over the device cap) paints blank with @@ -1354,10 +1362,15 @@ // offscreen) can coexist without exhausting device memory. maxDim is left intact — // the failure is area/memory-driven, not single-axis overflow, and clampEffectiveDpr // already takes the min across both, so this only bites when area is the binding limit. - return clampEffectiveDpr({ pageW: vp.width, pageH: vp.height, zoom, dpr: window.devicePixelRatio || 1, maxDim: caps.maxDim, maxArea: caps.maxArea * renderAreaSafety }); + let maxArea = caps.maxArea * renderAreaSafety; + if (zoom > DEEP_ZOOM_BASE_FROM) maxArea = Math.min(maxArea, DEEP_ZOOM_BASE_MAX_AREA); // DEEP-ZOOM part 3 + return clampEffectiveDpr({ pageW: vp.width, pageH: vp.height, zoom, dpr: window.devicePixelRatio || 1, maxDim: caps.maxDim, maxArea }); } - function toCanvas(p) { const scale = currentRenderZoom * currentEffDpr; return { x: p.x * scale, y: p.y * scale }; } // buffer space — currentRenderZoom, NOT state.zoom (rung blits) + // DEEP-ZOOM: the overlay window's origin in its own buffer, subtracted while renderAnnotationWindow + // paints; zero for the page pass, so #annCanvas pixels stay byte-identical (x - 0 is exact). + let overlayOffset = { x: 0, y: 0 }; + function toCanvas(p) { const scale = currentRenderZoom * currentEffDpr; return { x: p.x * scale - overlayOffset.x, y: p.y * scale - overlayOffset.y }; } // buffer space — currentRenderZoom, NOT state.zoom (rung blits) function canvasToPdf(canvasX, canvasY) { return { x: (canvasX - state.pan.x) / state.zoom, y: (canvasY - state.pan.y) / state.zoom }; @@ -1713,6 +1726,7 @@ annCanvas.height = 0; annCanvas.style.width = '0'; annCanvas.style.height = '0'; + hideAnnotationWindow(); lastPaintedPdfPage = null; return; } @@ -2041,9 +2055,31 @@ annCanvas.height = pdfCanvas.height; annCanvas.style.width = pdfCanvas.style.width; annCanvas.style.height = pdfCanvas.style.height; - const ctx = annCanvas.getContext('2d'); + // DEEP-ZOOM: the window paints FIRST, so the page pass below is the last to run and every + // DOM anchor an overlay records while it paints (the duct cursor chip, the water card) is + // left in page-buffer units, as before the window existed. + renderAnnotationWindow(page); + paintOverlay(annCanvas.getContext('2d'), annCanvas.width, annCanvas.height, page); + // The window is transparent, and under it the page overlay draws every mark fat and soft + // (raw buffer widths at a fifth of the density), which haloed the crisp marks: the page pass + // ends by clearing the window's box out of itself, so under the window only the window + // shows, and the soft overlay stands only in the strips a pan reveals until pan end. + if (annWindowBox) { + const pageCssW = parseFloat(pdfCanvas.style.width) || 0, pageCssH = parseFloat(pdfCanvas.style.height) || 0; + if (pageCssW > 0 && pageCssH > 0) { + const b = annWindowBox, sx = annCanvas.width / pageCssW, sy = annCanvas.height / pageCssH; + annCanvas.getContext('2d').clearRect(b.x0 * sx, b.y0 * sy, b.w * sx, b.h * sy); + } + } + } + // Everything the live overlay draws, into `ctx` (a width × height buffer). The page pass + // (#annCanvas, sized to #pdfCanvas) and the DEEP-ZOOM window (#annWindowCanvas, the visible + // area at full density) run this one body; the window differs only through the module values + // the body and toCanvas read (currentRenderZoom, currentEffDpr, overlayOffset), which + // renderAnnotationWindow rebinds around its call. + function paintOverlay(ctx, width, height, page) { const z = currentRenderZoom; // buffer space (rung blits render at the rung, CSS carries the residual) - ctx.clearRect(0, 0, annCanvas.width, annCanvas.height); + ctx.clearRect(0, 0, width, height); // Hide-marks mode: the overlay is sized + cleared (so the bare PDF shows // through) but nothing is painted on it. Toggle via the header eye button. if (state.hideMarks) return; @@ -2456,6 +2492,75 @@ } } + // SECTION: Deep-zoom overlay window + // DEEP-ZOOM part 1 (2026-10-14, journeys/plans/DEEP-ZOOM.md). Past the canvas budget the page + // overlay (#annCanvas) is sized to the clamped #pdfCanvas buffer, so at 3000% its marks draw at a + // fifth of the screen's density and read as blur beside the sheet, which the tile compositor + // keeps crisp. The window is a third canvas over the overlay, the visible area only, at full + // density: the same painter, with toCanvas rebound to state.zoom × dpr minus the window's + // origin. Its box is the crop tile's math (pdf-tile-cache.js renderCropTile): container units of + // the last full render, scaled on screen by k = zoom / lastRenderedZoom, so a mid-gesture or a + // tile-first commit is screen-sharp too. Painted with every overlay paint, re-cut at the pan-end + // sites that schedule the crop tile and at a cold zoom commit; during a pan it rides the + // container transform and a newly exposed strip shows the page overlay until pan end, exactly as + // the PDF tiles behave. Hidden while the overlay is not meaningfully soft (the tile's deficit). + const ANN_WINDOW_MIN_DEFICIT = 1.15; // the crop tile's CROP_TILE_MIN_DEFICIT + let annWindowBox = null; // the last cut, { x0, y0, w, h, k, dpr, bw, bh }: the spec seam App.__annWindow + function hideAnnotationWindow() { + annWindowBox = null; + if (!annWindowCanvas) return; + if (annWindowCanvas.width || annWindowCanvas.height) { annWindowCanvas.width = 0; annWindowCanvas.height = 0; } + annWindowCanvas.style.display = 'none'; + } + // The gate reads the density the page overlay HAS or WILL have at this zoom (a cold zoom + // commit cuts the window before its raster lands), not only the one it last painted at. + function overlayWindowWanted(page) { + if (!annWindowCanvas || !page || !page.pdfPage) return false; + const baseEff = effectiveDpr(page, state.zoom); + return baseEff > 0 && (window.devicePixelRatio || 1) / baseEff >= ANN_WINDOW_MIN_DEFICIT; + } + // A pan end or a cold zoom commit: a full overlay paint, which cuts the window at the view's + // new place and the hole under it; nothing at all when no window is wanted (the old path). + function recutOverlayWindow() { + if (annWindowBox || overlayWindowWanted(state.pages[state.currentPage])) renderAnnotations(); + } + function renderAnnotationWindow(page) { + if (!annWindowCanvas) return; + page = page || state.pages[state.currentPage]; + const dpr = window.devicePixelRatio || 1; + if (!overlayWindowWanted(page)) { hideAnnotationWindow(); return; } + const r = cWrapper ? cWrapper.getBoundingClientRect() : null; + const pageCssW = parseFloat(pdfCanvas.style.width) || 0; + const pageCssH = parseFloat(pdfCanvas.style.height) || 0; + if (!r || !r.width || !r.height || !pageCssW || !pageCssH) { hideAnnotationWindow(); return; } + const k = lastRenderedZoom > 0 ? state.zoom / lastRenderedZoom : 1; + const x0 = Math.max(0, -state.pan.x / k); + const y0 = Math.max(0, -state.pan.y / k); + const w = Math.min(pageCssW, x0 + r.width / k) - x0; + const h = Math.min(pageCssH, y0 + r.height / k) - y0; + if (w <= 0 || h <= 0) { hideAnnotationWindow(); return; } + const bw = Math.ceil(w * k * dpr), bh = Math.ceil(h * k * dpr); + // One screen of pixels; past the render budget (a huge display on a ratcheted-down budget) + // the page overlay stands alone rather than risk a window that allocates blank. + if (bw * bh > getCanvasCaps().maxArea * renderAreaSafety) { hideAnnotationWindow(); return; } + if (annWindowCanvas.width !== bw || annWindowCanvas.height !== bh) { annWindowCanvas.width = bw; annWindowCanvas.height = bh; } + annWindowCanvas.style.width = w + 'px'; + annWindowCanvas.style.height = h + 'px'; + annWindowCanvas.style.left = x0 + 'px'; + annWindowCanvas.style.top = y0 + 'px'; + annWindowCanvas.style.display = ''; + annWindowBox = { x0, y0, w, h, k, dpr, bw, bh }; + const savedZoom = currentRenderZoom, savedEff = currentEffDpr, savedOffset = overlayOffset; + currentRenderZoom = state.zoom; + currentEffDpr = dpr; + overlayOffset = { x: x0 * k * dpr, y: y0 * k * dpr }; + try { + paintOverlay(annWindowCanvas.getContext('2d'), bw, bh, page); + } finally { + currentRenderZoom = savedZoom; currentEffDpr = savedEff; overlayOffset = savedOffset; + } + } + function renderAnnotationsToContext(ctx, page, scale, exportOverrides, annotationsOverride) { const tc = (p) => ({ x: p.x * scale, y: p.y * scale }); const ann = annotationsOverride ?? getActiveAnnotations(page); @@ -2516,7 +2621,29 @@ return { x: snappedX, y: snappedY }; } - function getMaxZoom() { return state.maxZoom ?? 4; } + // DEEP-ZOOM part 2: the project's ceiling (Zoom Settings, state.maxZoom; 400% unset) under the + // device's. 1200% where the canvas probe found a small cap (iOS Safari probes about 16.7 Mpx) + // or Chromium reports under 4 GB (deviceMemory is undefined on Safari and Firefox, so only a + // Chromium low-memory device), else 5000%; then the layout wall, Firefox's ~17.9 M CSS px per + // element side, as 16e6 over the current sheet's longest side in points. The payload keeps the + // project's own ceiling (getProjectMaxZoom), never the device's, so a phone cannot lower it. + const DEVICE_ZOOM_CEILING = 50, DEVICE_ZOOM_CEILING_SMALL = 12, DEVICE_ZOOM_SMALL_CAP_PX = 32e6, LAYOUT_WALL_CSS_PX = 16e6; + function deviceZoomCeiling() { + const caps = getCanvasCaps(); + const lowMemory = typeof navigator !== 'undefined' && navigator.deviceMemory != null && navigator.deviceMemory < 4; + let ceiling = (caps.maxArea < DEVICE_ZOOM_SMALL_CAP_PX || lowMemory) ? DEVICE_ZOOM_CEILING_SMALL : DEVICE_ZOOM_CEILING; + const page = state.pages[state.currentPage]; + if (page && page.pdfPage) { + try { + const vp = page.pdfPage.getViewport({ scale: 1, rotation: page.rotation ?? 0 }); + const longest = Math.max(vp.width, vp.height); + if (longest > 0) ceiling = Math.min(ceiling, Math.floor(LAYOUT_WALL_CSS_PX / longest)); + } catch (_) { /* a page mid-load keeps the device ceiling */ } + } + return Math.max(1, ceiling); + } + function getProjectMaxZoom() { return state.maxZoom ?? 4; } + function getMaxZoom() { return Math.min(getProjectMaxZoom(), deviceZoomCeiling()); } function getWheelZoomSpeed() { try { const s = localStorage.getItem('zoomSettings'); @@ -4301,7 +4428,7 @@ // "which marks did we bid to" snapshot. R12: the same payload the cloud save // writes, from the one builder (save-utils.js buildProjectData). function buildCanvasExportData() { - return buildProjectData(state, { customIconPaths: getUserCustomIcons(), maxZoom: getMaxZoom(), bakeFrame: computePageBakeFrame }); + return buildProjectData(state, { customIconPaths: getUserCustomIcons(), maxZoom: getProjectMaxZoom(), bakeFrame: computePageBakeFrame }); } document.getElementById('exportBtn').onclick = () => { if (!projectHasAnyCanvasMarkup()) return; @@ -5470,7 +5597,23 @@ lctx.imageSmoothingEnabled = true; try { lctx.drawImage(pdfCanvas, sx, sy, srcSize, srcSize, 0, 0, aimLoupe.width, aimLoupe.height); - lctx.drawImage(annCanvas, sx, sy, srcSize, srcSize, 0, 0, aimLoupe.width, aimLoupe.height); + // DEEP-ZOOM: at depth the page canvases are the soft backdrop (and the page overlay has + // the window's box cleared out of it), so the loupe samples the crop canvas and the + // overlay window where they stand, the same screen region, each boxed in container + // units (pdf pt × lastRenderedZoom) at its own density (buffer px per container px). + const cssW = parseFloat(pdfCanvas.style.width) || 0; + const basePerCss = cssW > 0 ? pdfCanvas.width / cssW : 0; + const layer = (canvas, x0, y0, cssBoxW) => { + const density = canvas.width / cssBoxW; + const lx = (state.aimPoint.x * lastRenderedZoom - x0) * density, ly = (state.aimPoint.y * lastRenderedZoom - y0) * density; + const ls = (srcSize / basePerCss) * density; + lctx.drawImage(canvas, lx - ls / 2, ly - ls / 2, ls, ls, 0, 0, aimLoupe.width, aimLoupe.height); + }; + if (basePerCss > 0 && cropCanvas && cropCanvas.width > 0 && cropCanvas.style.display !== 'none' && parseFloat(cropCanvas.style.width) > 0) { + layer(cropCanvas, parseFloat(cropCanvas.style.left) || 0, parseFloat(cropCanvas.style.top) || 0, parseFloat(cropCanvas.style.width)); + } + if (basePerCss > 0 && annWindowBox) layer(annWindowCanvas, annWindowBox.x0, annWindowBox.y0, annWindowBox.w); + else lctx.drawImage(annCanvas, sx, sy, srcSize, srcSize, 0, 0, aimLoupe.width, aimLoupe.height); } catch (_) { /* source rect partly off-canvas — drawImage clips */ } const cxp = aimLoupe.width / 2, cyp = aimLoupe.height / 2, rr = 14 * ratio; lctx.strokeStyle = '#e8c547'; lctx.lineWidth = 1.5 * ratio; @@ -5519,6 +5662,7 @@ return Math.abs(rung - state.zoom) > 1e-9 && pdfBitmapCacheGet(page.pdfPage, rot, rung, effectiveDpr(page, rung)); })(); if (!warm) { + recutOverlayWindow(); // DEEP-ZOOM: the marks are screen-sharp at the new zoom while the tile rasters (the k math) renderCropTile({ force: true, onDone: () => renderPdf() }); return; } @@ -5914,6 +6058,7 @@ state.isPanning = false; state.panStart = null; scheduleCropTile(); // pan settled — re-cover the new visible window + recutOverlayWindow(); // DEEP-ZOOM: and re-cut the overlay window return; } if (e.button !== 0) return; @@ -5952,6 +6097,7 @@ state.isPanning = false; state.panStart = null; scheduleCropTile(); // pan settled — re-cover the new visible window (no-ops when base is sharp) + recutOverlayWindow(); // DEEP-ZOOM: and re-cut the overlay window }); (cWrapper || pdfCanvas).addEventListener('mouseleave', () => { @@ -5981,6 +6127,7 @@ state.isPanning = false; state.panStart = null; scheduleCropTile(); + recutOverlayWindow(); // DEEP-ZOOM } // A drag released on the canvas was already ended by its mouseup; one still // live here came up off the canvas (MAP-RESETS, D21). @@ -6232,6 +6379,7 @@ state.touchPanning = false; state.touchPanStart = null; scheduleCropTile(); // touch pan settled + recutOverlayWindow(); // DEEP-ZOOM: and re-cut the overlay window return; } if (e.changedTouches && e.changedTouches.length && state.longPressTimer) { @@ -6552,6 +6700,8 @@ App.commitWheelZoom = commitWheelZoom; App.syncZoomIndicators = syncZoomIndicators; App.getCanvasCaps = getCanvasCaps; + App.getDeviceZoomCeiling = deviceZoomCeiling; // DEEP-ZOOM: features/zoom.js (the slider's max and its hint) + App.__annWindow = () => annWindowBox; // DEEP-ZOOM: the overlay window's last cut (deep-zoom.spec.js) App.setCanvasCaps = setCanvasCaps; App.effectiveDpr = effectiveDpr; App.__getRenderAreaSafety = () => renderAreaSafety; // debug/test seam (mirrors setCanvasCaps) diff --git a/app/index.html b/app/index.html index f8c129fa..5e5df375 100644 --- a/app/index.html +++ b/app/index.html @@ -554,6 +554,7 @@

Export Options

+ @@ -1294,7 +1295,8 @@

A viewer set a scale

- + +
diff --git a/deep-zoom.spec.js b/deep-zoom.spec.js new file mode 100644 index 00000000..dab9c7eb --- /dev/null +++ b/deep-zoom.spec.js @@ -0,0 +1,234 @@ +// @ts-check +/** + * DEEP-ZOOM (journeys/plans/DEEP-ZOOM.md): zoom past 1200%. + * + * Part 1, the overlay window: past the canvas budget the page overlay (#annCanvas) is + * clamped as soft as the PDF base, so its marks read as blur beside the crisp tiles. + * #annWindowCanvas is the visible area at full density, painted by the same painter with + * toCanvas rebound (app.js renderAnnotationWindow). Part 2, the ceiling: getMaxZoom() is + * the project's ceiling under the device's (12 on a small canvas cap or a low-memory + * Chromium, else 50, then the layout wall over the sheet's longest side), and the Zoom + * Settings slider follows it without ever lowering the project's own setting. Part 3, + * the backdrop: past 4x the full-page buffer is held to 24 Mpx. + * + * Headless Chromium runs at dpr 1, so the deficit here comes from part 3's cap: at 3000% + * on the 1224 x 792 pt restaurant sheet the base is clamped to about a sixth of the + * screen's density. The seeded run is 8 px wide so a probe at its centre reads solid; the + * sharp-versus-soft proof is that the SAME screen distance from the run's centre is still + * ink on the page overlay and clear on the window. The page overlay is read where the run + * leaves the window, since under the window its box is cleared (the window alone shows there). + */ +const { test, expect } = require('@playwright/test'); +const { bootApp, collectConsoleErrors, uploadPdf } = require('./spec-helpers'); + +const LINE_RGB = [71, 200, 142]; // #47c88e, the seeded run's colour +const RUN = { x1: 500, y1: 400, x2: 560, y2: 400 }; // a 60 pt horizontal run near the sheet's centre +const MID = { x: (RUN.x1 + RUN.x2) / 2, y: RUN.y1 }; +const EDGE = { x: RUN.x1 + 2, y: RUN.y1 }; // on the run, 1500 px left of the viewport at 3000%: outside the window +const DEEP = 30; // 3000% + +async function seed(page) { + await page.evaluate((L) => { + const st = window.state, App = window.App; + st.pages[0].scale = { pixelsPerUnit: 10, unit: 'ft' }; + st.lineTypes = [{ id: 'waste', name: 'Waste', color: '#47c88e', curveStyle: 'straight' }]; + st.counters = [{ id: 'wc', name: 'Water Closet', icon: '', color: '#e8c547' }]; + st.lineTypeSettings = Object.assign({}, st.lineTypeSettings, { lineSize: 8, opacity: 1 }); + const ann = App.getActiveAnnotations(st.pages[0]); + ann.quickLines = [{ x1: L.x1, y1: L.y1, x2: L.x2, y2: L.y2, id: 'q1', lineTypeId: 'waste', color: '#47c88e' }]; + ann.counterMarkers = { wc: [{ x: L.x1 - 20, y: L.y1 - 20, id: 'm1' }] }; + App.updateUI(); + }, RUN); +} + +// Zoom to `zoom` with the run's midpoint at the viewport's centre, then wait for the exact +// render to land (the window's k is 1 once lastRenderedZoom is the zoom asked for). +async function zoomTo(page, zoom) { + await page.evaluate(({ zoom, mid }) => { + const st = window.state, App = window.App; + st.maxZoom = 50; + const wrap = document.getElementById('canvasWrapper').getBoundingClientRect(); + st.zoom = zoom; + st.pan = { x: wrap.width / 2 - mid.x * zoom, y: wrap.height / 2 - mid.y * zoom }; + App.renderPdf(); + }, { zoom, mid: MID }); + await page.waitForFunction((zoom) => { + const c = /** @type {HTMLCanvasElement} */ (document.getElementById('pdfCanvas')); + const box = window.App.__annWindow(); + return !!c && c.width > 0 && Math.abs(window.state.zoom - zoom) < 1e-9 && !!box && Math.abs(box.k - 1) < 1e-9; + }, zoom, { timeout: 30000 }); + await page.waitForTimeout(300); +} + +// One probe of both canvases at the run's midpoint, in each canvas's own buffer units. +const probe = (page) => page.evaluate(({ mid, edge }) => { + const App = window.App, st = window.state; + const box = App.__annWindow(); + const win = /** @type {HTMLCanvasElement} */ (document.getElementById('annWindowCanvas')); + const base = /** @type {HTMLCanvasElement} */ (document.getElementById('annCanvas')); + const pdfC = /** @type {HTMLCanvasElement} */ (document.getElementById('pdfCanvas')); + const wrap = document.getElementById('canvasWrapper').getBoundingClientRect(); + const px = (canvas, x, y) => Array.from(canvas.getContext('2d').getImageData(Math.round(x), Math.round(y), 1, 1).data); + const effDpr = base.width / parseFloat(base.style.width); // the page overlay's buffer px per CSS px + const wx = mid.x * st.zoom * box.dpr - box.x0 * box.k * box.dpr; // the midpoint in the window's buffer + const wy = mid.y * st.zoom * box.dpr - box.y0 * box.k * box.dpr; + const bx = mid.x * st.zoom * effDpr, by = mid.y * st.zoom * effDpr; // and in the page overlay's (k is 1) + const ex = edge.x * st.zoom * effDpr, ey = edge.y * st.zoom * effDpr; // the run outside the window, page overlay units + const dCss = 3 / effDpr; // 3 page-overlay buffer px, in CSS px + return { + visible: win.style.display !== 'none' && win.width > 0, + box, effDpr, winDensity: box.bw / (box.w * box.k), + coversWrapper: Math.abs(box.w * box.k - wrap.width) <= 1 && Math.abs(box.h * box.k - wrap.height) <= 1, + winCentre: px(win, wx, wy), winNear: px(win, wx, wy - 2), winSameCssAway: px(win, wx, wy - dCss * box.dpr), + baseUnderWindow: px(base, bx, by), baseOutside: px(base, ex, ey), baseOutsideThreeAway: px(base, ex, ey - 3), + baseArea: pdfC.width * pdfC.height, overlayArea: base.width * base.height, + safety: App.__getRenderAreaSafety(), + }; +}, { mid: MID, edge: EDGE }); + +const isInk = (p) => p[3] === 255 && Math.abs(p[0] - LINE_RGB[0]) <= 8 && Math.abs(p[1] - LINE_RGB[1]) <= 8 && Math.abs(p[2] - LINE_RGB[2]) <= 8; + +test.describe('DEEP-ZOOM: zoom past 1200%', () => { + test('the overlay window is sharp at 3000% while the page overlay is soft; pans re-cut it; the backdrop is budgeted', async ({ page }) => { + const errors = collectConsoleErrors(page); + await bootApp(page); + await uploadPdf(page, 'samples/sample-plan-advanced.pdf'); + await seed(page); + + // At fit zoom the page overlay is sharp enough: no window. + const atFit = await page.evaluate(() => { + const win = /** @type {HTMLCanvasElement} */ (document.getElementById('annWindowCanvas')); + return { hidden: win.style.display === 'none' || win.width === 0, box: window.App.__annWindow() }; + }); + expect(atFit.hidden).toBe(true); + expect(atFit.box).toBeNull(); + + await zoomTo(page, DEEP); + const deep = await probe(page); + expect(deep.visible).toBe(true); + expect(deep.coversWrapper).toBe(true); + expect(deep.winDensity).toBeCloseTo(deep.box.dpr, 2); // the window is one screen of pixels at full density + expect(deep.effDpr).toBeLessThan(0.4); // the page overlay is clamped well under it + expect(deep.baseArea).toBeLessThanOrEqual(24e6); // part 3: the full-page backdrop budget past 4x + expect(deep.overlayArea).toBeLessThanOrEqual(24e6); + expect(isInk(deep.winCentre)).toBe(true); // the window paints the run where the offset math says + expect(isInk(deep.winNear)).toBe(true); + expect(deep.winSameCssAway[3]).toBe(0); // ...and its edge is a few DEVICE px away + expect(deep.baseUnderWindow[3]).toBe(0); // under the window the page overlay is cleared: no halo + expect(isInk(deep.baseOutside)).toBe(true); // outside it the page overlay still has the run + expect(isInk(deep.baseOutsideThreeAway)).toBe(true); // ...and the same screen distance is still ink there: soft + + // Twenty real drag pans (Move) re-cut the window at every mouse-up, land it where the + // pan went, and never trip the blank-canvas ratchet. + await page.keyboard.press('m'); + const wrap = await page.locator('#canvasWrapper').boundingBox(); + if (!wrap) throw new Error('no canvas wrapper'); + const cx = wrap.x + wrap.width / 2, cy = wrap.y + wrap.height / 2; + for (let i = 0; i < 20; i++) { + const dx = i % 2 === 0 ? 40 : -40; + await page.mouse.move(cx, cy); + await page.mouse.down(); + await page.mouse.move(cx + dx / 2, cy + 3); + await page.mouse.move(cx + dx, cy + 6); + await page.mouse.up(); + const after = await page.evaluate(() => { + const box = window.App.__annWindow(); + return { x0: box ? box.x0 : null, expectX0: Math.max(0, -window.state.pan.x), k: box ? box.k : null }; + }); + expect(after.k).toBe(1); + expect(Math.abs(after.x0 - after.expectX0)).toBeLessThanOrEqual(0.5); // cut where the pan left the view + } + const panned = await page.evaluate(() => ({ + blank: JSON.stringify(window.App.getSaveStatusLog ? window.App.getSaveStatusLog() : []).includes('canvas_render_blank'), + })); + expect(panned.blank).toBe(false); + const afterPans = await probe(page); + expect(afterPans.safety).toBe(0.5); // the ratchet never fired + expect(isInk(afterPans.winCentre)).toBe(true); // the run is where the window says it is + expect(afterPans.winSameCssAway[3]).toBe(0); + + // Hide marks clears the window too. + await page.evaluate(() => { window.state.hideMarks = true; window.App.renderAnnotations(); }); + const hidden = await probe(page); + expect(hidden.winCentre[3]).toBe(0); + await page.evaluate(() => { window.state.hideMarks = false; window.App.renderAnnotations(); }); + expect(isInk((await probe(page)).winCentre)).toBe(true); + + // Back at 100% the window retires. + await page.evaluate(() => { window.state.zoom = 1; window.state.pan = { x: 0, y: 0 }; window.App.renderPdf(); }); + await page.waitForFunction(() => window.App.__annWindow() === null && Math.abs(window.state.zoom - 1) < 1e-9, null, { timeout: 20000 }); + const atOne = await page.evaluate(() => { + const win = /** @type {HTMLCanvasElement} */ (document.getElementById('annWindowCanvas')); + return win.style.display === 'none' || win.width === 0; + }); + expect(atOne).toBe(true); + + errors.assertNoErrors(); + }); + + test('the ceiling: the project under the device, the layout wall, and a Zoom Settings slider that never lowers the project', async ({ page }) => { + const errors = collectConsoleErrors(page); + await bootApp(page); + await uploadPdf(page, 'samples/sample-plan-advanced.pdf'); + + const ceilings = await page.evaluate(() => { + const App = window.App, st = window.state; + const lowMemory = navigator.deviceMemory != null && navigator.deviceMemory < 4; + st.maxZoom = 50; + App.setCanvasCaps({ maxDim: 100000, maxArea: 300e6 }); + const big = App.getMaxZoom(); // 50 on a capable device + const pg = st.pages[st.currentPage]; + pg.pdfPage.getViewport = () => ({ width: 400000, height: 100 }); // a sheet past Firefox's wall: 16e6 / 400000 + const wall = App.getMaxZoom(); + delete pg.pdfPage.getViewport; + App.setCanvasCaps({ maxDim: 8192, maxArea: 10e6 }); // a small canvas cap (an iOS Safari probe) + const small = App.getMaxZoom(); + st.maxZoom = 8; + const project = App.getMaxZoom(); // the project's own 800% under the device's + st.maxZoom = 30; + return { lowMemory, big, wall, small, project }; + }); + const capable = ceilings.lowMemory ? 12 : 50; + expect(ceilings.big).toBe(capable); + expect(ceilings.wall).toBe(Math.min(capable, 40)); + expect(ceilings.small).toBe(12); + expect(ceilings.project).toBe(8); + + // Zoom Settings on the small-cap device, the project at 3000%: the slider runs to 1200 and + // shows 1200 with the hint; Done without moving it leaves the project's 3000% alone. + await page.evaluate(() => window.App.showZoomModal()); + await expect(page.locator('#zoomModal')).toBeVisible(); + expect(await page.locator('#zoomMax').getAttribute('max')).toBe('1200'); + expect(await page.locator('#zoomMax').inputValue()).toBe('1200'); + await expect(page.locator('#zoomMaxHint')).toBeVisible(); + await expect(page.locator('#zoomMaxHint')).toContainText('1200%'); + await expect(page.locator('#zoomMaxHint')).toContainText('3000%'); + await page.locator('#zoomModalClose').click(); + await expect(page.locator('#zoomModal')).toBeHidden(); + expect(await page.evaluate(() => window.state.maxZoom)).toBe(30); + + // A moved slider writes the project's ceiling as before. + await page.evaluate(() => window.App.showZoomModal()); + await page.evaluate(() => { const m = /** @type {HTMLInputElement} */ (document.getElementById('zoomMax')); m.value = '800'; m.dispatchEvent(new Event('input', { bubbles: true })); }); + await page.locator('#zoomModalClose').click(); + expect(await page.evaluate(() => window.state.maxZoom)).toBe(8); + + // A capable device runs the slider to its ceiling, with no hint. + await page.evaluate(() => { window.App.setCanvasCaps({ maxDim: 100000, maxArea: 300e6 }); window.App.showZoomModal(); }); + expect(await page.locator('#zoomMax').getAttribute('max')).toBe(String(capable * 100)); + if (!ceilings.lowMemory) await expect(page.locator('#zoomMaxHint')).toBeHidden(); + await page.locator('#zoomModalClose').click(); + + // The rail's ticks reach the new ceiling (the three past 1200 appear only when it allows). + if (!ceilings.lowMemory) { + await page.evaluate(() => { window.state.maxZoom = 50; }); + await page.locator('#zoomPct').click(); + await expect(page.locator('#zoomRail')).toBeVisible(); + expect(await page.locator('#zoomRailTicks .zoom-rail-tick').count()).toBe(14); + await expect(page.locator('#zoomRailTicks .zoom-rail-tick-label', { hasText: '2000%' })).toHaveCount(1); + await page.keyboard.press('Escape'); + } + + errors.assertNoErrors(); + }); +}); diff --git a/features/zoom-rail.js b/features/zoom-rail.js index 6fb14c96..3dfc8444 100644 --- a/features/zoom-rail.js +++ b/features/zoom-rail.js @@ -39,9 +39,9 @@ // The hard-coded zoom floor used across app.js (wheel, pinch, -, fit). const MIN_ZOOM = 0.2; // Round-percent tick candidates; filtered to [MIN_ZOOM*100, maxZoom*100]. - const TICK_PCTS = [25, 50, 75, 100, 150, 200, 300, 400, 600, 800, 1200]; + const TICK_PCTS = [25, 50, 75, 100, 150, 200, 300, 400, 600, 800, 1200, 2000, 3000, 5000]; // DEEP-ZOOM: three past 1200 // Majors get a wider mark + a text label (the 64px rail stays uncluttered). - const MAJOR_PCTS = [25, 50, 100, 200, 400, 800]; + const MAJOR_PCTS = [25, 50, 100, 200, 400, 800, 2000]; const rail = document.getElementById('zoomRail'); const track = document.getElementById('zoomRailTrack'); diff --git a/features/zoom.js b/features/zoom.js index 773ecec3..75ed3784 100644 --- a/features/zoom.js +++ b/features/zoom.js @@ -18,10 +18,28 @@ (function() { const App = (window.App = window.App || {}); + // DEEP-ZOOM part 2 (journeys/plans/DEEP-ZOOM.md): the slider runs to the device's ceiling + // (App.getDeviceZoomCeiling: 5000% on a capable device, 1200% on a small-cap or low-memory + // one) and shows the PROJECT's own ceiling held to that range; Done writes it back only when + // the slider moved, so opening the dialog on a phone never lowers a project's 3000% to 1200%. + let shownMaxPct = null; function showZoomModal() { - const maxVal = Math.round(App.getMaxZoom() * 100); - document.getElementById('zoomMax').value = maxVal; - document.getElementById('zoomMaxVal').textContent = maxVal; + const state = App.state; + const ceilingPct = Math.round(App.getDeviceZoomCeiling() * 100); + const slider = document.getElementById('zoomMax'); + slider.max = String(Math.max(100, ceilingPct)); + const projectPct = Math.round((state.maxZoom ?? 4) * 100); + shownMaxPct = Math.max(100, Math.min(ceilingPct, projectPct)); + slider.value = shownMaxPct; + document.getElementById('zoomMaxVal').textContent = shownMaxPct; + const hint = document.getElementById('zoomMaxHint'); + if (hint) { + const held = ceilingPct < 5000; + hint.textContent = held + ? 'This device holds zoom at ' + ceilingPct + '%.' + (projectPct > ceilingPct ? ' The project\'s ' + projectPct + '% applies on a larger screen.' : '') + : ''; + hint.style.display = held ? '' : 'none'; + } const speed = App.getWheelZoomSpeed(); const speedPct = Math.round(speed * 100); document.getElementById('zoomSpeed').value = speedPct; @@ -32,7 +50,7 @@ document.getElementById('zoomModalClose').onclick = () => { const state = App.state; const maxPct = parseInt(document.getElementById('zoomMax').value, 10); - state.maxZoom = maxPct / 100; + if (shownMaxPct == null || maxPct !== shownMaxPct) state.maxZoom = maxPct / 100; // DEEP-ZOOM: an untouched slider leaves the project's ceiling alone const speedPct = parseInt(document.getElementById('zoomSpeed').value, 10); const speed = speedPct / 100; try { localStorage.setItem('zoomSettings', JSON.stringify({ wheelZoomSpeed: speed })); } catch (_) {} diff --git a/journeys/plans/DEEP-ZOOM.md b/journeys/plans/DEEP-ZOOM.md index 1e4af6fb..8c88c614 100644 --- a/journeys/plans/DEEP-ZOOM.md +++ b/journeys/plans/DEEP-ZOOM.md @@ -120,6 +120,32 @@ effDpr, so cached rungs stay valid; pdf-tile-cache.js's own budgets are unchange - Then one run on Wendi's machine: the Save Status export already carries her probed cap, the safety knob and any blank events (the `display` block). +## Built (2026-10-14) + +All three parts, in the order above, one PR, with deep-zoom.spec.js (the tests listed below as +written) and the zoom, rail, tile and render-pixels specs green. Three refinements over the +proposal, each found while building: + +- The window's gate reads `effectiveDpr(page, state.zoom)`, the density the page overlay WILL + have at the zoom asked for, not the one it last painted at, so the cold-commit cut (made + before the raster lands) shows on the first deep zoom too. +- The window paints BEFORE the page pass, so the page pass is the last to run and every DOM + anchor an overlay records while painting (the duct cursor chip, the water card) stays in + page-buffer units; a second canvas painted last would have left them in window units. +- The device ceiling is read-time only: the save blob and the project payload carry + `getProjectMaxZoom()` (the project's own, 400% unset), and the Zoom Settings dialog shows + the project's own held to the device's range and writes it back only when the slider moved, + so a phone that opens the dialog cannot lower a project's 3000% to 1200%. +- The window is transparent, and the first 3000% screenshot showed the page overlay's fat, soft + marks haloing the crisp ones through it. The page pass now ends by clearing the window's box + out of `#annCanvas`, so under the window only the window shows and the soft overlay stands + only in the strips a pan reveals; a pan end and a cold commit repaint the whole overlay + (`recutOverlayWindow`), not the window alone, so the hole moves with it. The aim loupe + samples the crop canvas and the window where they stand, so a tablet keeps its marks under + the loupe at depth. + +Live check: see CHANGELOG.md's DEEP-ZOOM entry. + ## Decisions Assumed, Will to confirm: the ceiling is 5000%, and phones and small-cap devices hold 1200%. diff --git a/styles.css b/styles.css index bc1eac67..02f218d4 100644 --- a/styles.css +++ b/styles.css @@ -513,6 +513,7 @@ .canvas-container .crop-canvas { z-index: 0; pointer-events: none; } .canvas-container .ann-canvas { z-index: 1; pointer-events: none; } .canvas-container .ann-canvas.interactive { pointer-events: auto; } + .canvas-container .ann-window-canvas { z-index: 2; pointer-events: none; } /* DEEP-ZOOM: the overlay window, app.js renderAnnotationWindow */ .canvas-wrapper .aim-loupe { position: absolute; left: 0; top: 0; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 2px 10px rgba(0,0,0,.4); pointer-events: none; display: none; z-index: 240; background: #fff; will-change: transform; } /* B16 / J1: quiet cold-start hint in the empty canvas (updateUI toggles it). Anchored to .canvas-area, NOT .canvas-wrapper — the wrapper collapses to diff --git a/sw.js b/sw.js index 2f7e0015..65565d28 100644 --- a/sw.js +++ b/sw.js @@ -23,7 +23,7 @@ * visit once the CDN has settled. The app's admin "global force reload" clears caches * as a backstop. */ -const CACHE_VERSION = 'da3bce395e2b'; +const CACHE_VERSION = '95bd4a24164f'; const CACHE_NAME = `counttooling-shell-${CACHE_VERSION}`; // The full same-origin app shell. GENERATED by `npm run build:sw`, do not edit by hand: @@ -239,7 +239,7 @@ const PRECACHE_SHA256 = { '/vendor/jspdf.umd-2.5.1.min.js': '98ccf17aa10c20bb1301762618fcc9b6ab3a4e7f26b6071d64d0b41154df3875', '/vendor/supabase-js-2.108.0.min.js': '005a6b7d396160fbe924316baa98adf198dc6f99a63412e27edec9675c225270', '/vendor/tus-js-client-4.3.1.min.js': '8cbb1b63fccc3bba0ae73ad1deb160ce046c3750851d0c3e94921ae3ef070eb8', - '/styles.css': '60682afd8bad867e31856e85d619b9073f118e0b0781e4028a78bbc5f86e83ad', + '/styles.css': '79f69f69754f624857357424cc3df7bc9973c44949ab7be5893ba964c1051f45', '/icons.js': 'bb3c3506a859d25685287d0c1d3afb3231601754555aea403505e7ca8d68779b', '/icons-custom.js': 'efe6b960301031a5fb40abc2f54de18798e19f4b7b04e0eccb81b47f1e9cacad', '/icon-render.js': '41b09b835c3898be95b013b27a6c11e1453c629cb811326d49fdcbfec19439d8', @@ -273,7 +273,7 @@ const PRECACHE_SHA256 = { '/undo-stack.js': '34180b25071008b6f29c8b3c2529faa29e21c2957e9ee26b5510e5ef5750f69c', '/save-engine.js': 'd620a2ade982357362d0e7dd9c701df90a3cffe47e66f780dcd1d24b81fda918', '/pdf-tile-cache.js': 'd9d520d6399480191df2b97038ce0b453803666d79f1b804a995484e98fc5772', - '/app.js': '12bc08bcda9d8d7ac75e35f38262fe181e7ba7f769947261977126058e48f072', + '/app.js': 'e5648eccda69aff76e26985fca7865d9e863ec380e9ccf8773f4b776b38cbc5c', '/features/canvas-repair.js': 'b2dca5c86174ed9589d0c44091d9265c2e3af039c08cf4422eb151fa5fd8ec02', '/features/view-only.js': 'f4e6c4f5601c089aa1001a9583c409e61d9090a639acd6a69994bccd6ca0dbcc', '/features/save-project.js': '6f01819d040f4a05ee9805ccabdc5170973429a39d5d0c3e54381a0d43866ad2', @@ -281,8 +281,8 @@ const PRECACHE_SHA256 = { '/features/line-color.js': '2fd4c7594f1a3686fd9323b7bc4d97f5b9c151b32475d5a4428062a075378ecb', '/features/custom-icon-upload.js': 'cf0d6731862f3baa8b7ed55cbfc89759df42934f52d1c22586ac37d3b406ab06', '/features/note.js': 'b7cc88aa00ac8a2450c59299959108ae3bd5b18b0e420fd61264533c23347d6b', - '/features/zoom.js': 'cceb56f7ae4c91124aa17b246b276b9796463dc27ce93835a849f5a3d31f31fc', - '/features/zoom-rail.js': '02b27244833dc50a8eaf688070a486e2a0e167e3bd193ae89499538df9372da3', + '/features/zoom.js': '5bfd9362c676102d514c4b1e90cd2ca9b4a2d679f15ea134a30aac8935cf53a3', + '/features/zoom-rail.js': '408522adca830c44fc407ce1cf143097782c255c4b20261efb7119ff9a7edd1b', '/features/manage-icons.js': '9da0efb19f2e86b1d3b2f1d9bd6eda2a12ae3e307abba3a9f2c9b5da8d646382', '/features/multiply-zone-settings.js': 'e808757a5758d7c0ba64d989ef3f6e051266b40a26ff01ae9ea8187b7b834dee', '/features/scale-zone-settings.js': '67a8a802e7aeaf629a235dbd0e4d9c42ea5c746412ae6749b90ecf35be7a9c9f', @@ -405,8 +405,8 @@ const PRECACHE_SHA256 = { '/icons/icon-192.png': 'c807a7a2fda05dc5a74c60f16d7199bc1c617aa36948acc20e3712a412f943c2', '/icons/icon-512.png': '386919ae854bc73fd0c8fa39bcb8f16d2496ce0b487792ca17b0924d7a8eb137', '/icons/maskable-512.png': 'a5c54fa0ab699678992c5e5473721804d24257762a859f8c2183fb4049bfa164', - '/app/': '452f968fd1c1e2931521e62e84d319dfafb7453ee92c8c8e13dc11d6544034b9', - '/app/index.html': '452f968fd1c1e2931521e62e84d319dfafb7453ee92c8c8e13dc11d6544034b9', + '/app/': '62acb6cb0b7423f6a77b47dcc3d4207d979f5d7eacdf9de65962485f705f06a0', + '/app/index.html': '62acb6cb0b7423f6a77b47dcc3d4207d979f5d7eacdf9de65962485f705f06a0', '/render-worker.js': '97409f02a7150a5f9b5e456769083b49dca0c7baaae0263a34e2fc7a1d23a54d', '/vendor/pdf.worker.min-3.11.174.js': 'feabdf309770ed24bba31a5467836cdc8cf639c705af27d52b585b041bb8527b', '/rules/rules.json': 'bf4f68f9b25bd2bbc13e382bd204fce243c23945c8cf7bcb57da828f652e122b', diff --git a/zoom.spec.js b/zoom.spec.js index 00fec96b..0ffd06df 100644 --- a/zoom.spec.js +++ b/zoom.spec.js @@ -81,12 +81,13 @@ test.describe('window.App registry pilot - Zoom modal', () => { await page.evaluate(() => window.App.showZoomModal()); await page.waitForSelector('#zoomModal.visible', { timeout: 5000 }); - // The slider ceiling is now 1200 and it reflects the live 400% default. + // The slider runs to the device's ceiling (DEEP-ZOOM: 5000 on a capable device, 1200 on a + // small-cap or low-memory one) and it reflects the live 400% default. const slider = await page.evaluate(() => { const m = document.getElementById('zoomMax'); - return { max: m.max, value: m.value }; + return { max: m.max, value: m.value, ceiling: String(Math.round(window.App.getDeviceZoomCeiling() * 100)) }; }); - expect(slider.max).toBe('1200'); + expect(slider.max).toBe(slider.ceiling); expect(slider.value).toBe('400'); // Raise to 1200% and close -> persisted as 12. @@ -122,7 +123,7 @@ test.describe('window.App registry pilot - Zoom modal', () => { // with it (unlike the old popover, it does NOT dismiss). await page.locator('#zoomRailSettings').click(); await page.waitForSelector('#zoomModal.visible', { timeout: 3000 }); - expect(await page.evaluate(() => document.getElementById('zoomMax').max)).toBe('1200'); + expect(await page.evaluate(() => document.getElementById('zoomMax').max)).toBe(await page.evaluate(() => String(Math.round(window.App.getDeviceZoomCeiling() * 100)))); // DEEP-ZOOM: the device's ceiling expect(await page.evaluate(() => document.getElementById('zoomRail').classList.contains('visible'))).toBe(true); expect(errors).toEqual([]);