3.4 KiB
3.4 KiB
CONTRACT — step-06 phase 2 compose
- date: 2026-10-11 | flow: ship-feature (executor) | branch: feature/step-06-pdf-archives
- status: active
- spec: docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md Part II §14 "composeViewSvg", §13 (Rasterizer not in scope here)
REQUEST (IMMUTABLE)
Promote the Node-side view composer of the curation pipeline (packages/anatomy/src/curation/app-review.ts) into the shared renderer as composeViewSvg, with an optional highlight applied on the LayerElement tree before it becomes DOM, so the PDF engine (Phase 3) can compose a highlighted view without a browser and without querySelector. The review drawings stay byte-identical.
ACCEPTANCE CRITERIA
packages/anatomy/src/render/compose.tsexportscomposeViewSvg(input: { root: Element; document: AnatomicalSheetDocumentInput; viewId: string; highlight?: { annotationIds: ReadonlySet<string>; halo: boolean } }): ElementandHALO_FILTER_ID = 'osteo-halo'; it uses only DOM Level 2 APIs onrootandroot.ownerDocument(no xmldom import, no querySelector, noel.remove()); exported frompackages/anatomy/src/render/index.ts. CHECK: grep -n "querySelector|.remove()|xmldom" packages/anatomy/src/render/compose.ts; echo "rc=$?" EXPECT: rc=1- Without
highlight, output = today'srenderAppReviewDrawingoutput:curation/app-review.tsbecomes a thin caller (parse with xmldom, callcomposeViewSvg, serialise) and the committed review drawings do not drift. CHECK: cd packages/anatomy && corepack pnpm test:run 2>&1 | tail -3 EXPECT: Tests .* passed (including the existing golden-artifacts test) - With
highlight: only layer elements whose annotation id is inannotationIdsremain; each getsfill="#b85a3f",fill-opacity="0.85"and, whenhalo,filter="url(#osteo-halo)"; nodata-*attribute is emitted on any layer element;<title>children are kept; whenhalo, a<defs>(created as FIRST child when the asset has none) holds theosteo-halofilter exactly asapps/app/src/pdf/render/observationPage.ts:157-197(x/y "-100%", width/height "300%", filterUnits userSpaceOnUse, feGaussianBlur stdDeviation 18 result haloWide, feGaussianBlur stdDeviation 8 result haloTight, both in=SourceGraphic, feMerge of haloWide×3, haloTight×2, SourceGraphic); the layer<g>is appended last;viewBoxset fromviewBoxOf(view)when present;width/heightremoved from the root. CHECK: cd packages/anatomy && corepack pnpm vitest run tests/render.compose.test.ts 2>&1 | tail -3 EXPECT: Tests .* passed - Tests (xmldom, draft document + draft horse.svg): main view with two selected annotations (one point → both hitbox and twin highlighted, one spine zone), head view (no halo), nothing selected (layer empty), unknown view throws, idempotent halo (no duplicate filter when called on a root that already has one), highlight keeps
<title>, zerodata-attributes in the serialised output, review-mode output byte-identical to the previousrenderAppReviewDrawingfor both views. pnpm typecheck && pnpm lint && pnpm test:rungreen in packages/anatomy; no other package changed. CHECK: git -C $HOME/Documents/faunosteo status --short | grep -v "^?? packages/anatomy|^ M packages/anatomy" | grep -v ".claude/" | wc -l EXPECT: 0
FILE SCOPE
packages/anatomy/src/render/compose.ts (new), packages/anatomy/src/render/index.ts, packages/anatomy/src/curation/app-review.ts, packages/anatomy/tests/render.compose.test.ts (new). Nothing else.