Merge feature/step-06-pdf-archives into develop
ci / check (push) Canceled after 0s
ci / docker (push) Canceled after 0s
ci / supabase (push) Canceled after 0s

This commit is contained in:
bchanot committed 2026-10-11 17:32:15 +02:00
commit c746952d7f
184 files changed
+30390 -2073

No files matched your search

+7
View File
@@ -74,3 +74,10 @@ Status: resolved (commit on feature/step-04-anatomical-sheet-model).
Migration 20261010100000 replaces the CHECK with `document_schema_version = 2` without rewriting rows → errors on any DB seeded before 4c (dev only today). Cause: schema bump shipped as constraint change, not as data migration. Solution: before real data, data migration lifting stored documents (add `references: []`, `review_status` defaults) then CHECK; rule from user: incremental non-destructive migrations, never a reset. Documented ANATOMICAL_SHEET_MODEL.md §6.
Status: open (no real data yet; treat before Step 7+ persistence of user reports).
---
## BLK-009 | 2026-10-11 | pdf-lib inflates PDF object streams without cap at `PDFDocument.load` (import path)
Security audit Step 6 (MEDIUM, pre-existing since Step 1 import): `PDFDocument.load` decodes every `/ObjStm` and xref stream eagerly with its own uncapped FlateStream; measured 408 KB PDF → 400 MB in 1.4 s, 468 MB RSS; `MAX_PDF_BYTES` 50 MiB allows ~50 GB. Attachment cap (16 MiB) covers the attachment only. Impact: tab freeze/OOM for the practitioner on a crafted PDF, no code execution. Cannot refuse `/ObjStm` (pdf-lib `save()` emits object streams in our own PDFs). Options: parse in a Web Worker (bounded blast radius), or locate the attachment by scanning bytes without a full load, or a capped custom decoder. pdf-lib 1.17.1 unmaintained since 2021 (LOW in the same audit).
Status: MITIGATED on the browser import path 2026-10-11 (60ee712: byte-scan attachment reader, no `PDFDocument.load` on untrusted bytes, export without object streams; ObjStm bomb read in 5 ms, +0.5 MiB RSS). Then 3a6e926: inflater fed in 16 KiB slices (Chromium read-ahead defeated the cancel: 4 GiB bomb +2.2 GB → +192 MB measured), shared 16 MiB candidate budget, bounded endstream search; final loop: candidates sorted by offset, JSON depth pre-scan. Audits ×3 PASS; worst measured costs on crafted files: +192 MB single bomb, ~0.5 s / ≤0.4 GB for 32 failing inflations, ~1 s deep JSON (before the pre-scan). GATE STILL OPEN before any external-user import (BDR-040): Firefox/Safari inflater read-ahead unmeasured (no browser test runner), Worker/server import with time+memory budget, pdf-lib replacement decision (unmaintained), report collection caps on read, `<use>` nesting budget, low-end phone measurement. Plan: docs/development/PDF_IMPORT_HARDENING.md §5. Never close on passing tests alone.
+16
View File
@@ -327,3 +327,19 @@ Status: closed.
Sheet source: `SheetProvider` interface; Step 5 implementation = Vite virtual module `virtual:faunosteo-sheet` built from the seed draft (`vite/sheet-bundle.ts`), mode `SHEET_BUNDLE=draft|none`, default draft for dev server, none for builds/CI/Docker (`--build-arg SHEET_BUNDLE=draft` = explicit preview) → unvalidated draft never ships by accident (D2). Markers: pure renderer `@faunosteo/anatomy/render` (element tree, no DOM) reproduces legacy look (hitbox r + twin r−12, opacities 0.65/0.5, spine 0.3, trigger 0.06 dashed); colours = document data (`categories[].color`, additive `annotations[].color` for the head shades, schema_version stays 2 for additive optional fields); same renderer feeds `draft/review/app-<view>.svg` for visual checks. Report v3 in packages/domain: `(annotationId, viewId)` zones with label snapshots, `(findingZoneId, path)` findings, severity codes, `sheet {sheetId, versionId|null, documentSha256}`, `unresolved: true` for what migration cannot place, `localAnnotations: []` reserved. Migration map generated by the pipeline from applier records (replay renames/moves/removals + unique re-homing): 792 nodes → 571/180/7/34. Interaction = pure service + reducers (BDR-019 kept); store = v3 + persistence adapter (v2 draft migrated on restore). D4 applied: registry, matchers, SVG parser, editors, pathology-editor, public species assets deleted; legacy sources moved to `supabase/seed/.../legacy-sources/` (importer input).
Alt rejected: copying the draft into apps/app (duplication, drift); runtime fetch of `/sheets/*.json` (still public, no gain); UUID annotation ids (BDR-031); converting v3→v2 for attachments (lossy); per-view colour table in the app (horse knowledge in generic code).
Status: closed; awaiting user validation of Step 5.
---
## BDR-039 | 2026-10-11 | Step 6: autonomous PDF archives — lean-document snapshot, envelope v1, archived branding + labels, explicit rebase
User-validated design (docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md Part II). Attachment = envelope v1 `{format, envelopeVersion, exportedAt, locale, report v3, sheetSnapshot, branding, labels}` in one `osteo-report.json`, SVG inline as text. Snapshot = `{status, ref, document, assets}` where document = valid lean `AnatomicalSheetDocument` (all views/annotations/categories/regions, finding zones kept by id, trees pruned to used paths with ancestor labels, references emptied) → reuses sheet index, layer renderer, 21 integrity rules; no dedicated schema. Branding (logos base64/svg, credits, URLs) + label dict (fr+en) archived so future logo/wording changes never alter a re-render (user D7 adjustment). Engine `packages/pdf`: explicit inputs `{report, sheet, branding, labels, locale, rasterizer, exportedAt}`, no DOM lib, xmldom composition promoted from curation app-review, Rasterizer adapter (browser Image/canvas; resvg devDep for tests), per-view/per-logo degradation, export-side validation (caps, integrity, sheet invariant). Read = layered: report first (v3/v2 existing dispatch), envelope metadata tolerant, snapshot strict → `snapshotRejected` enum, report never lost; `attachment_stripped` via Info.Keywords stamp. Session: imported archive kept immutable (`osteo:archive`), working copy rebased explicitly on the loaded sheet (`rebaseReportOnSheet`, unresolved flags + labels from archived snapshot) (user D8 adjustment); re-export of the kept archive = technical support only, UX submitted after step. No CLI, no page change, no original v2 JSON re-embedded.
Alt rejected: dedicated SheetSnapshotSchema (rewrites lookups, loses integrity rules); separate embedded files per asset (first-EmbeddedFile reader, stripping risk); pruning views/annotations (saves ~0 KB, breaks trigger titles); snapshot discarded on import (user: keep for faithful re-read); crypto hash check of assets (self-referential; sha copied from catalog manifest as provenance pointer instead).
Status: closed (Step 6 validated by user 2026-10-11; D8 finalised in BDR-040).
---
## BDR-040 | 2026-10-11 | Step 6 closure: no "re-export the original archive" button, visible rebase, BLK-009 gate
User decisions after manual validation (logos and picker text confirmed OK on their side; Step 6 VALIDATED). (1) Re-export of the imported archive from the UI REFUSED permanently: the practitioner already holds the original PDF; no second button, no dedicated UX flow. Keep the archived snapshot, its integrity and the autonomy tests (engine `exportFromEnvelope` stays as the proof + future server use); the UI exports only the open working report. Do not propose this feature again. (2) Rebase on draft restore shown to the user (`editor.draft_rebased`) approved; import messages approved on principle with an explicit "full restoration" vs "partial recovery" headline. (3) BLK-009 treated now: byte-scan attachment extraction without pdf-lib load on import + export without object streams; remaining risks (worker/server import, pdf-lib replacement, read caps) stay an explicit BLOCKER gate before any external user import; never declared solved by passing tests alone.
Alt rejected: a re-export action on the home screen after import (same objection); a toast system for import feedback (no component, alert pattern kept).
Status: closed.
+18
View File
@@ -97,3 +97,21 @@ Result: verifier pass 1 ECARTS(2) = floor only (EVAL-011 prose "eslint-disable"
Anomalies: verifier stage runs after executor edits only (concurrent reads otherwise); gates.sh needs `EVIDENCE: PENDING` placeholder lines on new criteria. Residuals noted, not fixed: ZodError message echoes closed-vocabulary received values (never names), `compareReport` computes v3 lines twice, template-literal lines >80 chars, locals >5 in two functions.
Action: await user manual validation of Step 5; residuals in TODO follow-up.
---
## EVAL-013 | 2026-10-11 | Step 6 autonomous PDF archives — 5 phases by executors, 3 verifier passes, 4 security audits
Method: analysis (3 analyzers + measurements) challenged by 3 plan-challengers (correctness/robustness/simplicity, 48 findings folded in) → user validation with D7/D8/D13 adjustments → Part II contract (exact types) → one executor per phase (0 freeze goldens, 1 domain, 2 anatomy compose, 3 engine, 4 app) with closed contracts, orchestrator commits → whole-step verifier + security auditor → fix loops.
Result: Phase 0 froze 39 goldens (text/images/links per locale × logo mode, view facts) + 2 route characterisation tests with the OLD code; engine reproduced 36 goldens with 0 mismatch (views: data-* 2→0 and hidden-marker titles declared relaxed). Verifier pass 1 ECARTS(31) = all oracle/scope defects of MY contract (grep on parametrised table, xmldom filter, narrow FILE SCOPE, 3 deleted tests with moved coverage) → contract amended → pass 2 CONFORME 13/13. Security pass 1 BLOCK(1) HIGH real + PoC: archived branding URL written unescaped into `/URI` (PDF object injection via `exportFromEnvelope`), +3 MEDIUM/4 LOW → executor fixed (hex URI, strict URL schema, export re-validation, PNG IHDR budget, CSS-escape rules, NaN guard, file.size) → pass 2 PASS but 2 MEDIUM incl. a regression the fix introduced (UTF-16 BOM URI dead in poppler) + PNG double-IHDR bypass → executor → pass 3 PASS + 1 MEDIUM (UPNG nextZero spin on tEXt) → executor (chunk allowlist + IEND) → pass 4 PASS + 3 MEDIUM (UPNG `inflateRaw` spins on truncated IDAT with allowlisted chunks only; IHDR fields unvalidated; zero dimension) → executor: native bounded `inflateFlate` of the IDAT against the exact raw size, IHDR fields, sides ≥ 1, no interlace, raw ≤ 16 MiB → pass 5 focused. Lesson: a third-party decoder on untrusted bytes needs a native oracle in front, not a chunk allowlist. Final: 656 tests (194/21/130/88/223), typecheck, lint, build, docker ×4 green; goldens byte-identical since 8b86b92.
Anomalies: contract oracles written fast = 2 verifier passes lost (lesson: run every CHECK once before dispatching the verifier); security fix introduced a functional regression invisible to tests because the test reader decoded the BOM (lesson: assert raw bytes, cross-check with a real reader like poppler); executors denied `rm`/`git rm` (orchestrator deletes); one executor used `git stash` despite "no git state" (now forbidden explicitly in briefs); demo envelope with archived branding = 136 KB stored / 306 KB raw (raw > 250 KB, stored < 250 KB: reported, user said data first).
Action: await user manual validation + UX decision on re-export of the kept archive; BLK-009 (pdf-lib ObjStm inflation) before external users; react-router advisories (pre-existing) to bump in a chore.
---
## EVAL-014 | 2026-10-11 | Step 6 closure round — manual-test feedback, BLK-009 scanner, final audits
Method: user manual tests round 1 (logos absent, picker blurry) → reproduction attempts (headless Chromium dev/preview/Docker, Firefox 157 via esbuild harness + raw WebDriver BiDi client, CDP LayerTree, LCD-fringe metric, headed runs on the Wayland session) → fixes by executors → user round 2 confirmed both OK → closure decisions → BLK-009 implemented (byte-scan reader, no object streams) → verifier + 2 security audits + 1 fix loop.
Result: neither visual defect reproduced here (4 environments, 2 engines, 2 PDF renderers); shipped the environment-independent fixes (branding bundled, no fetch; warnings surfaced) and the user confirmed logos + crisp text. Scanner: verifier CONFORME 7/7; audit 1 PASS + 2 MEDIUM (Chromium DecompressionStream read-ahead defeats the cancel: +2.2 GB on a 4 GiB bomb; ×32 candidate CPU) → executor (16 KiB slice feeding, shared 16 MiB budget, monotonic bounded endstream search, `{` pre-check; 133 pdf tests) → audit 2 focused. Workspace 710 tests, build, docker green.
Anomalies: the blur fix of the previous round (will-change) had been marked PARTIALLY MET "desktop by user" — the user's "still blurry" came from that unverified half; this round could not verify real-GPU text rendering either (headless engines render grayscale AA, headed captures failed) → lesson: a screen-rendering defect needs the user's own capture + an A/B recipe early, not days of headless measurement. The Node vitest suite cannot observe browser stream read-ahead: record browser-only bounds as owed manual checks (PDF_IMPORT_HARDENING §5).
Action: BLK-009 stays "mitigated, gate open" (BDR-040); Step 6 finished into develop; release/0.2.0 prepped for the user's go.
+12
View File
@@ -199,3 +199,15 @@ Step 4 validated + finished into develop. User decisions on the 7 open points
## 2026-10-10 (session — Step 5 closed, Step 6 analysis)
Step 5 validated + closed by user; LRN-045 (permanent will-change blurs text) written on develop. Step 6 analysis on chore/step-06-pdf-archive-analysis: 3 analyzers (PDF pipeline, data model, app/tests) → facts: export reads live SheetIndex (labels, views, asset, all annotations of view), 4 fetched logos + 3 hard-coded URLs, DOM in drawing/highlight/raster, attachment = bare v3 Flate'd by pdf-lib, getAttachments dead on pdf-lib 1.17.1, no report↔sheet check anywhere. Measured: lean snapshot envelope 172 KB raw / 51 KB stored (3 obs), 228 / 54 worst; SVG = 90% of stored. Plan: snapshot = lean AnatomicalSheetDocument + assets inline (reuses index/renderer/integrity rules), packages/pdf engine (xmldom compose promoted from app-review.ts, Rasterizer + Branding inputs, no DOM lib), envelope v1 layered reading (report never lost), rebase on import/restore keeps report.sheet == snapshot.ref, export-side caps. 3 plan-challengers GO WITH FIXES (16+19+13 findings folded in). docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md; TODO 6.0–6.7. Awaiting user decisions D1/D4/D6/D7/D8/D10/D12/D13; no implementation.
## 2026-10-11 (Step 6 implementation)
User validated the Step 6 analysis with D7 (branding archived), D8 (imported snapshot kept, explicit rebase, no new UI without UX gate), D13 (explicit import messages). Analysis chore branch finished; feature/step-06-pdf-archives. Part II contract (exact types) + BDR-039. Phases by executors: 0 freeze (39 goldens, demo fixture, bare v3 PDF, route characterisation), 1 domain (archive/{snapshot,envelope,branding,labels}, sheet-index moved, rebase, bundle asset hashes), 2 anatomy (composeViewSvg + highlightLayer promoted from app-review), 3 engine packages/pdf (xmldom composition, allowlist sanitiser, safeText, Rasterizer, envelope v1, layered reader, resvg test), 4 app (export/import on the engine, archive in session `osteo:archive`, rebase + 4 messages, legacy modules removed). Verifier ECARTS(31, all my contract's oracles/scope) → CONFORME. Security BLOCK(1) HIGH (URI injection via archived branding) → 4 fix loops (hex URI → ASCII hex after poppler regression, URL schema, export re-validation, PNG IHDR budget → chunk allowlist + IEND → native IDAT inflation against exact raw size + IHDR fields, CSS escapes, NaN, file.size) → PASS. Docs: PDF-FORMAT.md real, CLAUDE/README/WORKSPACE/DEPLOY/CHANGELOG. 656 tests, build + docker green. Sizes: demo envelope 55 KB stored no logos / 136 KB with archived branding (306 KB raw). LRN-046, BLK-009, EVAL-013. Awaiting user validation + UX decision for re-export of the kept archive; Step 7 not started.
## 2026-10-11 (Step 6 manual-test feedback)
User: step not merged; findings-picker text still blurry; footer logos absent in their PDFs; decisions: re-export from archive wanted (UX to propose), restore-rebase must be visible, exact labels to validate; BLK-009 analysis. Done on feature/step-06-pdf-archives: logos NOT reproduced (real export in headless Chromium dev/preview/Docker image + Firefox 157 engine harness: 4 logos embedded, 0 warnings, poppler + pdf.js render them) → branding bundled into the app (`src/assets/brand`, `?inline`/`?raw`, no fetch at all) + export returns warnings + `editor.export_warnings` alert (293a6e0); blur NOT reproduced (headless Chromium/Firefox, DPR 1/1.25/2, scrolling 9-leaf list, CDP LayerTree: no composited layer, no lingering animation/will-change; headed runs on the user's Wayland display failed to capture) → analysis + A/B recipe for the user; restore rebase alert `editor.draft_rebased` (e8f1734); docs/development/PDF_IMPORT_HARDENING.md (byte-scan reader + no object streams now; worker/parser later) (5ed4a4b). Root check 660 tests, build, docker green. Awaiting user: browser/zoom for the blur, UX choice for re-export, label validation.
## 2026-10-11 (Step 6 closure)
User round 2: logos OK, picker text crisp, flows OK → STEP 6 VALIDATED. Decisions BDR-040: re-export-archive button refused for good; restore-rebase alert approved; import headlines full/partial (62b8a43). BLK-009: byte-scan attachment reader + export without object streams (60ee712), verifier CONFORME, audit PASS+2 MEDIUM → slice-fed inflater + candidate budget (3a6e926), focused re-audit. EVAL-014. Then: gitflow finish into develop, release/0.2.0 prep (Milestone A) up to the human go; Step 7 not started (UX/design to discuss with ChatGPT first).
+7
View File
@@ -345,3 +345,10 @@ Apply: any future CLI/log over report content (Step 6 server import, worker). Te
Context: findings picker text blurry on screen, crisp in PDF (Step 5 validation). `motion.ul` kept inline `will-change: transform, opacity` after its 220 ms slide (computed transform `none`); list sat at fractional offset inside height-animated card (left 561.1875 px desktop, top 735.77 px mobile) → element stayed on own compositor layer, text resampled at non-integer position → blur. Fix = drop the prop; motion promotes the element itself while animating (1f0b710).
Pattern: never set permanent `will-change` on text containers; let the animation lib promote for the duration. Diagnose with headless Chromium: computed `willChange`, bounding rect fractional offsets, edge-sharpness ratio before/after (headless has no LCD antialiasing → desktop delta flat, user confirms in real browser). Regression test = rendered element has no inline `will-change`.
Apply: any `motion.*`/CSS transition on lists, cards, modals holding text; design-review audits.
---
## LRN-046 | 2026-10-11 | Refactor a render pipeline behind goldens frozen in two fixture modes; lean-document snapshot beats a new schema
Step 6 moved the PDF pipeline into `packages/pdf` with zero visible change. What made it provable: Phase 0 froze drawn text (page, x, y, size, font), image placements, link annotations and per-view structural facts with the OLD code, in two harness modes (logos absent / present via a fetch stub serving the real public/ bytes) and per locale (footer geometry depends on label width). Golden JSON = oracle; the port had 0 mismatch; the two intentional differences (hidden markers absent, data-* gone) were declared as relaxed fields, never by editing goldens. Snapshot shaped as a valid lean `AnatomicalSheetDocument` reused the index, the renderer and 21 integrity rules (3 challengers killed the dedicated-schema idea). Node-side xmldom composer already existed in curation (`app-review.ts`): promote, don't rewrite. resvg 0.40 panics on gradient fills culled by a cropped root viewBox (head view) → test adapter renders the full box and crops pixels; Chrome is fine. Executors denied `rm`/`git rm`: orchestrator deletes on literal relative paths after checking importers.
Apply: any pipeline extraction (Step 13 Supabase provider, Step 14 worker); any "snapshot" design: reuse the live schema minus content before inventing one.
+10 -7
View File
@@ -100,14 +100,17 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
- [x] 5.10 final controls on the last lot: stale root script scaffold:species removed; verifier ×3 (2→1→CONFORME) + security ×2 PASS on criteria 16-18; EVAL-012
- [x] 5.11 user validation defect: findings picker text blurry on screen → permanent `will-change` on the list dropped (hotfix 1f0b710, regression test); PDF never affected
- [ ] 5.12 follow-up (not Step 5): equine sheet anatomical enrichment with the osteopath + future sheet editor (Step 17); the 28 draft annotations (carpus added, points moved) are NOT a final catalog
- [ ] Step 6 — autonomous PDF archives (analysis + plan 2026-10-10 on chore/step-06-pdf-archive-analysis: docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md, challenged on 3 lenses GO WITH FIXES; AWAITING USER VALIDATION of D1/D4/D6/D7/D8/D10/D12/D13 before implementation on feature/step-06-pdf-archives)
- [ ] Step 6 — autonomous PDF archives (analysis validated by user 2026-10-11 with D7 branding archived, D8 snapshot kept + explicit rebase, D13 messages → Part II contract + BDR-039; implementation on feature/step-06-pdf-archives, one executor per phase)
- [x] 6.0 analysis: 3 analyzers (pipeline, model, app/tests) + size measurements (envelope 172 KB raw / 51 KB stored for 3 obs, 228 / 54 worst case) + 3 plan-challengers → plan rewritten
- [ ] 6.1 Phase 0 freeze with current code: demo report fixture, migrated-v2-with-unresolved builder, G3 bare v3 PDF, G1 text goldens (logos absent + present), G2 structural facts/placements/links, T12 HomeRoute + T13 EditorRoute characterisation
- [ ] 6.2 Phase 1 domain: sheet-index moved, archive/snapshot (buildSheetSnapshot, assertSnapshot, caps), archive/envelope (schema v1, layered readArchiveDocument, SnapshotRejection), report/rebase (rebaseReportOnSheet), bundle carries asset sha + status/name, tests
- [ ] 6.3 Phase 2 anatomy: render/compose.ts promoted from curation/app-review.ts, highlight on the layer tree, review drawing golden unchanged
- [ ] 6.4 Phase 3 packages/pdf: scaffold (no DOM lib, restricted globals, vitest node, Dockerfile, CI, README), svg/sanitize allowlist + horse.svg zero-removal, render moved, Branding/Rasterizer/exportedAt/safeText/dict, exportReportArchive (T3 both logo modes), readReportArchive (filename-first, layered, attachment_stripped; T4-T6, T8), T1/T7/T9/T10 resvg/T11, xmldom bundle size ≤ 50 KB gz
- [ ] 6.5 Phase 4 app: browserRasterizer, branding.ts, export/import on the engine, rebase on import + draft restore, 2 new messages, old render/attachment/highlight code + pdf.* keys removed, report:compare on engine API, T2/T14/T15, suite migrated 1:1
- [ ] 6.6 Phase 5 docs + gates: PDF-FORMAT.md real, CLAUDE.md map, WORKSPACE.md rule, DEPLOY.md rollback note, CHANGELOG, BDR-014 note; pnpm check, docker build, verifier + security gates, EVAL; manual validation list
- [x] 6.1 Phase 0 freeze (8b86b92: 39 goldens, demo fixture, bare v3 PDF, T12/T13; 206 app tests) with current code: demo report fixture, migrated-v2-with-unresolved builder, G3 bare v3 PDF, G1 text goldens (logos absent + present), G2 structural facts/placements/links, T12 HomeRoute + T13 EditorRoute characterisation
- [x] 6.2 Phase 1 domain (cdc0943: 154 domain tests, snapshot 171 KB raw on the fixture): sheet-index moved, archive/snapshot (buildSheetSnapshot, assertSnapshot, caps), archive/envelope (schema v1, layered readArchiveDocument, SnapshotRejection), report/rebase (rebaseReportOnSheet), bundle carries asset sha + status/name, tests
- [x] 6.3 Phase 2 anatomy (6940926: composeViewSvg + highlightLayer, 130 anatomy tests): render/compose.ts promoted from curation/app-review.ts, highlight on the layer tree, review drawing golden unchanged
- [x] 6.4 Phase 3 packages/pdf (c179560: 53 engine tests, 36 goldens exact, resvg raster, demo envelope 55 KB / 136 KB stored): scaffold (no DOM lib, restricted globals, vitest node, Dockerfile, CI, README), svg/sanitize allowlist + horse.svg zero-removal, render moved, Branding/Rasterizer/exportedAt/safeText/dict, exportReportArchive (T3 both logo modes), readReportArchive (filename-first, layered, attachment_stripped; T4-T6, T8), T1/T7/T9/T10 resvg/T11, xmldom bundle size ≤ 50 KB gz
- [x] 6.5 Phase 4 app (9bd5173: 222 app tests, archive kept in session, rebase + alerts, legacy PDF modules removed, xmldom ≈ 31 KB gz in the main chunk): browserRasterizer, branding.ts, export/import on the engine, rebase on import + draft restore, 2 new messages, old render/attachment/highlight code + pdf.* keys removed, report:compare on engine API, T2/T14/T15, suite migrated 1:1
- [x] 6.6 Phase 5 docs + gates (docs synced; verifier ECARTS(31 oracle/scope) → CONFORME 13/13; security BLOCK(1) → 4 fix loops → PASS; 656 tests, build, docker ×4 green)
- [x] 6.8 user manual tests round 1 (2026-10-11): logos and picker text confirmed OK by the user after branding bundled (293a6e0) and the investigation; restore-rebase alert (e8f1734); STEP 6 VALIDATED BY USER 2026-10-11
- [x] 6.9 closure decisions (BDR-040): re-export-archive button REFUSED for good; import headlines full/partial (62b8a43); BLK-009 byte-scan reader + no object streams (60ee712), fresh security audit + verifier; gate before external users kept in PDF_IMPORT_HARDENING.md §5
- [ ] 6.10 finish into develop, release/0.2.0 prepped (Milestone A) — tag/merge to main on the user's go; Step 7 NOT started (UX/design discussion first)
- [ ] 6.7 follow-ups recorded for Step 13: catalog asset cap aligned with the archive cap (2 MiB), allowlist sanitiser at upload, app canvas sanitiser (EVAL-011)
- [ ] 5 follow-up: allowlist SVG sanitiser before Storage-served assets (Step 13); orphan findings UX (D5) at the report UX step; report:compare residuals (ZodError reason genericised, v3 lines computed once, long template lines); 16 MiB attachment cap without direct test
@@ -0,0 +1,23 @@
# CONTRACT — step-06 bounded attachment extraction (BLK-009, options A + B)
- date: 2026-10-11 | flow: ship-feature (executor, security loop) | branch: feature/step-06-pdf-archives
- status: active
- spec: docs/development/PDF_IMPORT_HARDENING.md §2-§4
## REQUEST (IMMUTABLE)
Remove pdf-lib's parser from the import path: locate the Faunosteo attachment by scanning the PDF bytes, inflate it with the capped native inflater, never call `PDFDocument.load` on untrusted input in the browser. Export without object streams so the Filespec name and the Info keywords stay visible to the scanner. Existing archives (with object streams) must still import. Tests include an object-stream bomb that the new reader never inflates.
## ACCEPTANCE CRITERIA
1. `packages/pdf/src/attachment/scan.ts`: `findEmbeddedFiles(bytes: Uint8Array): EmbeddedFileCandidate[]` walks the bytes (bounded by `MAX_PDF_BYTES`) for stream dictionaries containing `/Type /EmbeddedFile` (also `/Type/EmbeddedFile` without space), reads a direct `/Length N` when present else locates `endstream`, handles `stream\r\n` and `stream\n`, records `{ offset, length, filter: 'FlateDecode' | null, name: string | null }` where `name` comes from a visible `/Filespec` dict whose `/EF << /F n 0 R >>` points at that stream's object number (object header `n 0 obj` before the dict), when visible; candidates ordered: named `osteo-report*` first, then file order. `readAttachmentBytes(bytes): Promise<Uint8Array>`: for each candidate, raw bytes (or `inflateFlate` under `MAX_ATTACHMENT_BYTES` when Flate) → first whose decoded text parses as JSON with a numeric `envelopeVersion` or `version` wins; none → `no_attachment`, or `attachment_stripped` when the bytes carry the keyword stamp (`/Keywords` followed by a literal `(…)` or hex `<…>` string decoding to a text containing `faunosteo-archive`).
CHECK: cd packages/pdf && corepack pnpm vitest run tests/scan.test.ts 2>&1 | grep -E "Tests " | tail -1
EXPECT: Tests .* passed
2. `readReportArchive(bytes, map)` uses the scanner only: `%PDF-` header check + size cap → `invalid_pdf`; no `PDFDocument.load` anywhere under `packages/pdf/src/read.ts` or `src/attachment/`; `readAttachedDocument` becomes `readAttachedDocument(bytes: Uint8Array): Promise<unknown>` (bytes, not a PDFDocument) and the compare CLI (`apps/app/scripts/compare-reports.ts`) uses it without loading the PDF.
CHECK: grep -rn "PDFDocument.load\|PDFDocument\.load" packages/pdf/src apps/app/scripts | wc -l
EXPECT: 0
3. Export: `pdfDoc.save({ useObjectStreams: false })`; a test asserts the saved bytes contain the literal `/Type /Filespec` with `(osteo-report.json)` (or its hex) in clear and no `/Type /ObjStm`; every golden suite stays green (goldens record text/images/links only).
4. Compatibility tests (`tests/scan.test.ts` + existing `read.test.ts`): the frozen fixtures `apps/app/tests/fixtures/report-v2.full.pdf`, `report-v2.minimal.pdf`, `report-v3.bare.pdf` (all written WITH object streams) import with the same outcomes as before; a fresh envelope PDF imports; a PDF with two embedded files (a decoy `EmbeddedFile` first, then the Faunosteo one) picks the Faunosteo one; a PDF whose `/Length` is an indirect reference (craft by hand) is read through the `endstream` fallback; `\r\n` after `stream`; a foreign PDF → `no_attachment`; a stamped PDF without attachment → `attachment_stripped` (write it with `useObjectStreams: false` so the stamp is visible; also document that older stamped files with object streams fall back to `no_attachment`).
5. Bomb test: a PDF containing an object stream (`/Type /ObjStm /Filter /FlateDecode`) whose data is a deflate bomb (≥ 64 MiB of zeros compressed to a few hundred KB, built in the test with node:zlib) plus a valid Faunosteo attachment: `readReportArchive` returns the report in under 2 s and the process RSS does not grow by more than 64 MiB (measure `process.memoryUsage().rss` before/after); the same bytes also carry an attachment-sized bomb variant: an `EmbeddedFile` stream inflating past 16 MiB → `no_attachment` (inflate cancelled), never a hang.
6. Docs: `docs/PDF-FORMAT.md` "Reading an archive" step 2 (byte scan, no object-graph parse, object streams never inflated) and "Known limits" (pdf-lib removed from the import path; remaining: CLI on the same scanner, pdf-lib kept for generation, prerequisites unchanged for external users); `docs/development/PDF_IMPORT_HARDENING.md` §4 marked done with the commit, §5 unchanged.
7. Green from the root: `corepack pnpm typecheck && corepack pnpm lint && corepack pnpm test:run`; `git diff --quiet 8b86b92 HEAD -- apps/app/tests/fixtures/goldens`.
## FILE SCOPE
packages/pdf/src/{attachment/scan.ts (new), attachment/read.ts, attachment/inflate.ts, read.ts, export.ts, index.ts, errors.ts}, packages/pdf/tests/** , apps/app/scripts/compare-reports.ts, apps/app/scripts/compare/report.ts, apps/app/tests/unit/scripts.compare.test.ts, apps/app/tests/unit/pdf.import.test.ts (if it loads a PDFDocument), docs/PDF-FORMAT.md, docs/development/PDF_IMPORT_HARDENING.md. Nothing else.
@@ -0,0 +1,27 @@
# CONTRACT — step-06 phase 0 freeze
- 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 (§17 goldens, §13 types for naming only)
## REQUEST (IMMUTABLE)
Freeze the current PDF pipeline behaviour before any refactor: new fixtures, goldens generated once with the current code, characterisation tests of the two routes. Production code under apps/app/src is NOT modified in this phase.
## ACCEPTANCE CRITERIA
1. Fixture `apps/app/tests/fixtures/report-v3.demo.json`: valid Report v3 on the bundled draft (ids taken from draft/document.json), 6 observations covering: main view zones, head view zone, a spine zone with vertebrae, a bilateral zone with left and right sides, a vet-referral leaf (`requiresVetReferral: true`), a leaf whose label holds an en dash (U+2013), free-text findings, severities, comment, conclusion, recommendations, nextAppointment; `sheet` = the draft ref.
CHECK: cd apps/app && corepack pnpm vitest run tests/unit/pdf.goldens.test.ts 2>&1 | tail -3
EXPECT: Tests .* passed
2. Goldens under `apps/app/tests/fixtures/goldens/step6/` exactly as spec §17 (text/images/links per report × locale × logo mode, views per report), generated by `MAKE_GOLDEN=1 corepack pnpm vitest run tests/unit/pdf.goldens.test.ts`, then asserted by the same file without the flag. Reports: v2full, demo, v2unresolved. Logo modes: nologos, logos.
CHECK: ls apps/app/tests/fixtures/goldens/step6 | wc -l
EXPECT: >= 20
3. Fixture `apps/app/tests/fixtures/report-v3.bare.pdf`: the demo report exported by the current code (rasteriser stubbed 1×1, no logos), produced by the same MAKE_GOLDEN run; `tests/fixtures/README.md` documents the new files and the rule "never regenerate without a user decision".
CHECK: test -s apps/app/tests/fixtures/report-v3.bare.pdf && echo ok
EXPECT: ok
4. Characterisation tests `tests/unit/routes.HomeRoute.import.test.tsx` and `tests/unit/routes.EditorRoute.export.test.tsx` as spec §17 (import mocked at module level; alert text with count; the three current error kinds + generic; navigation to /editor; export call shape; download name; failure alert).
CHECK: cd apps/app && corepack pnpm vitest run tests/unit/routes.HomeRoute.import.test.tsx tests/unit/routes.EditorRoute.export.test.tsx 2>&1 | tail -3
EXPECT: Tests .* passed
5. Whole app suite, typecheck and lint green; no file under apps/app/src changed.
CHECK: cd apps/app && corepack pnpm typecheck && corepack pnpm lint && corepack pnpm test:run 2>&1 | tail -4; git -C /home/bchanot/Documents/faunosteo status --short apps/app/src | wc -l
EXPECT: Tests .* passed ; 0
## FILE SCOPE
apps/app/tests/** only (new test files, fixtures, goldens, helpers, README). No change under apps/app/src, packages/**, docs/**.
@@ -0,0 +1,26 @@
# CONTRACT — step-06 phase 1 domain
- 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 §13 (types), §14 "Read" steps 1-3 and "Bundle", §15 caps table (snapshot + branding rows), §2.2 (lean document content)
## REQUEST (IMMUTABLE)
Give the domain package the archive contracts (sheet snapshot, envelope v1, branding, labels), the layered reader, the report rebase, and move the sheet index into the domain; make the bundle carry the asset hashes. Pure TypeScript + Zod, no DOM, no pdf-lib. The app keeps compiling and its suite stays green through re-export shims; no app behaviour changes in this phase.
## ACCEPTANCE CRITERIA
1. `packages/domain/src/anatomical-sheet/sheet-index.ts` holds `buildSheetIndex`, `pickLabel`, `isObservable`, `SheetIndex`, `ObservableAnnotation`, `SheetIndexSource = { ref: { documentSha256: string }; document: AnatomicalSheetDocument; assets: Readonly<Record<string, string>> }` (generic so `SheetIndex['sheet']` keeps the caller's type: `buildSheetIndex<S extends SheetIndexSource>(sheet: S): SheetIndex<S>`); `pickLabel(text, locale: 'fr' | 'en')`. `apps/app/src/services/sheetIndex.ts` becomes a re-export of it (no other app file edited for this move).
CHECK: cd apps/app && corepack pnpm typecheck && corepack pnpm vitest run tests/unit/sheets.provider.test.ts 2>&1 | tail -2
EXPECT: passed
2. `packages/domain/src/archive/` with `snapshot.ts` (`SheetSnapshotRef`, `SheetSnapshotAsset`, `SheetSnapshot`, `SheetSnapshotSchema`, `SnapshotSource`, `buildSheetSnapshot`, `assertSnapshot`, `SnapshotError`, `SnapshotRejection`, `snapshotIndexSource(snapshot): SheetIndexSource`), `branding.ts` (`ImageAsset`, `Credit`, `Branding`, `BrandingSchema`), `labels.ts` (`PDF_LABEL_KEYS`, `PdfLabels`, `PdfLabelSet`, `PdfLabelSetSchema`), `envelope.ts` (`ENVELOPE_FORMAT`, `ENVELOPE_VERSION`, `ReportArchiveEnvelope`, `ReportArchiveEnvelopeSchema`, `ArchiveOrigin`, `ArchiveReadOutcome`, `readArchiveDocument`), `index.ts`; exported as `@faunosteo/domain/archive` (package.json exports) and from the root index. Types and behaviour exactly as spec §13/§14; `SnapshotSource = { status; ref: SheetRef; speciesId; schemaVersion; document; assets; assetHashes? }` so that `LoadedSheet` satisfies it; snapshot `ref` = `{ ...sheet.ref, schemaVersion, speciesId }`.
CHECK: cd packages/domain && corepack pnpm vitest run tests/archive.snapshot.test.ts tests/archive.envelope.test.ts tests/archive.branding-labels.test.ts 2>&1 | tail -3
EXPECT: Tests .* passed
3. `buildSheetSnapshot(sheet, report)` is pure and deterministic: document = all views, annotations, categories, vertebral_config, name/description/scope_disclaimer/attribution/species_id/schema_version kept; `references: []`; every finding zone kept as `{ id, name, categories }` where categories are pruned to the paths referenced by the report's findings (resolved or `unresolved`): category `{ id, kind, name, description: {}, reference_ids: [], review_status, children }`, node `{ id, name, description: {}, requires_vet_referral, reference_ids: [], review_status, children }`; zones not referenced have `categories: []`; assets = every asset reachable from a view (own `svg_asset_id` or parent chain), `sha256` from `assetHashes` or null. On the draft with the fixture report `apps/app/tests/fixtures/report-v2.full.json` migrated: the document passes `AnatomicalSheetDocumentSchema` and `validateSheetDocument` returns no `error` issue; pretty JSON of the snapshot (with the SVG) is under 250,000 bytes (print the number in the test output).
4. `assertSnapshot` order: iterative depth pre-check of `finding_zones[].categories[].children` (> 8 → `caps`) → `SheetSnapshotSchema.parse` (strict wrapper; failure → `schema`) → counters (views ≤ 64, annotations ≤ 1024, nodes ≤ 8192, any LocalizedText value > 512 chars, assets ≤ 4 / ≤ 2 MiB each / ≤ 6 MiB total → `caps`) → `validateSheetDocument` has an `error` → `integrity` → a view that reaches no asset present in `assets` → `integrity`. Tests cover each reason and the happy path.
5. `readArchiveDocument(data, map)` implements spec §14 "Read" steps 1-3 exactly, with these cases tested: bare v3 → `origin 'bare_v3'`, `archive null`, counts 0; bare v2 (fixture) → `'v2'`, `migrated true`, counts from the migration; envelope v1 valid → `'envelope_v1'`, `archive` = validated envelope, `migrated false`; envelope with `envelopeVersion: 2` and report v3 → report returned, `snapshotRejected 'unsupported_envelope'`; envelope v1 with report `version: 4` → throws `UnsupportedReportVersionError` with foundVersion 4; envelope v1 with unknown extra metadata key → accepted; envelope v1 with broken branding → `'schema'`; snapshot over caps → `'caps'`; snapshot ref sheetId/documentSha256 ≠ report.sheet → `'sheet_mismatch'`; `__proto__` keys harmless; non-object → throws.
6. `packages/domain/src/report/rebase.ts`: `rebaseReportOnSheet(report, index, archived)` as spec §13; tests: same sha → untouched, `rebased false`; different sha → unknown annotation → `unresolved: true` + labels from the archived snapshot's annotation name (both locales) when the zone had none; unknown viewId → unresolved; finding with no node → unresolved; already-unresolved items stay; resolved items untouched; `report.sheet` replaced by `index.sheet.ref`; output passes `ReportSchema`.
7. Bundle: `apps/app/vite/sheet-bundle.ts` payload gains `assetHashes` (from `assets.json` `sha256` by `svg_asset_id`); `apps/app/src/sheets/provider.ts` `BundledSheetData`/`LoadedSheet` gain `assetHashes: Readonly<Record<string, string>>` and `schemaVersion: number` (from `ref.schema_version`); `parseBundledSheet` fills them; `tests/unit/sheets.provider.test.ts` asserts the hash of the horse asset equals the manifest value.
8. Green everywhere: `corepack pnpm -r typecheck && corepack pnpm -r lint && corepack pnpm -r test:run` from the repo root (domain, anatomy, supabase, app). The Phase 0 golden tests and route characterisation tests under apps/app/tests must pass unchanged.
CHECK: cd /home/bchanot/Documents/faunosteo && corepack pnpm typecheck 2>&1 | tail -2 && corepack pnpm test:run 2>&1 | grep -E "Tests|Test Files" | tail -8
EXPECT: all passed
## FILE SCOPE
packages/domain/** (src/anatomical-sheet/sheet-index.ts new, src/archive/* new, src/report/rebase.ts new, index files, package.json exports, tests/archive.*.test.ts, tests/report.rebase.test.ts, tests/sheet-index.test.ts), apps/app/src/services/sheetIndex.ts (re-export only), apps/app/vite/sheet-bundle.ts, apps/app/src/sheets/provider.ts, apps/app/src/sheets/virtual-sheet.d.ts if needed, apps/app/tests/unit/sheets.provider.test.ts. Nothing under apps/app/src/pdf, packages/anatomy, packages/pdf.
@@ -0,0 +1,25 @@
# 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
1. `packages/anatomy/src/render/compose.ts` exports `composeViewSvg(input: { root: Element; document: AnatomicalSheetDocumentInput; viewId: string; highlight?: { annotationIds: ReadonlySet<string>; halo: boolean } }): Element` and `HALO_FILTER_ID = 'osteo-halo'`; it uses only DOM Level 2 APIs on `root` and `root.ownerDocument` (no xmldom import, no querySelector, no `el.remove()`); exported from `packages/anatomy/src/render/index.ts`.
CHECK: grep -n "querySelector\|\.remove()\|xmldom" packages/anatomy/src/render/compose.ts; echo "rc=$?"
EXPECT: rc=1
2. Without `highlight`, output = today's `renderAppReviewDrawing` output: `curation/app-review.ts` becomes a thin caller (parse with xmldom, call `composeViewSvg`, 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)
3. With `highlight`: only layer elements whose annotation id is in `annotationIds` remain; each gets `fill="#b85a3f"`, `fill-opacity="0.85"` and, when `halo`, `filter="url(#osteo-halo)"`; no `data-*` attribute is emitted on any layer element; `<title>` children are kept; when `halo`, a `<defs>` (created as FIRST child when the asset has none) holds the `osteo-halo` filter exactly as `apps/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; `viewBox` set from `viewBoxOf(view)` when present; `width`/`height` removed from the root.
CHECK: cd packages/anatomy && corepack pnpm vitest run tests/render.compose.test.ts 2>&1 | tail -3
EXPECT: Tests .* passed
4. 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>`, zero `data-` attributes in the serialised output, review-mode output byte-identical to the previous `renderAppReviewDrawing` for both views.
5. `pnpm typecheck && pnpm lint && pnpm test:run` green in packages/anatomy; no other package changed.
CHECK: git -C /home/bchanot/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.
@@ -0,0 +1,29 @@
# CONTRACT — step-06 phase 3 engine
- date: 2026-10-11 | flow: ship-feature (executor) | branch: feature/step-06-pdf-archives
- status: active (phases 1 and 2 landed)
- spec: docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md Part II §13 (packages/pdf block), §14 (Export, Label policy, View SVG, Read), §15 (caps, sanitiser, text), §17 (goldens the engine must reproduce), §3.3
## REQUEST (IMMUTABLE)
Create `packages/pdf` (`@faunosteo/pdf`): the browser-free PDF engine that exports a report archive from explicit inputs (report, sheet snapshot, branding, labels, locale, rasterizer, exportedAt) and reads an archive back (layered reading). Render code moves from `apps/app/src/pdf` with its behaviour frozen by the Phase 0 goldens. The app is NOT wired in this phase (Phase 4); `apps/app/src` is not modified.
## ACCEPTANCE CRITERIA
1. Package scaffold: `packages/pdf/{package.json,tsconfig.json,vitest.config.ts,eslint.config.js,src/,tests/}` following packages/domain conventions; dependencies `pdf-lib ^1.17.1`, `@pdf-lib/standard-fonts ^1.0.0` (for `Encodings.WinAnsi`), `@faunosteo/domain workspace:*`, `@faunosteo/anatomy workspace:*`, `@xmldom/xmldom ^0.9.8`; devDependencies as domain plus `@resvg/resvg-js` (latest 2.x) and `@pdf-lib/upng ^1.0.1` (PNG decode in tests); tsconfig `lib: ["ES2022"]`, `types: ["node","vitest/globals"]`; eslint on `src/**`: `no-restricted-globals` for fetch, window, document, Image, DOMParser, XMLSerializer, navigator, Buffer, process, require and `no-restricted-imports` for patterns `@/*`, `react*`, `node:*`; vitest `environment: 'node'`. Dockerfile copies `packages/pdf/package.json`; `packages/README.md` row updated.
CHECK: cd packages/pdf && corepack pnpm typecheck && corepack pnpm lint && echo ok
EXPECT: ok
2. Public API of `packages/pdf/src/index.ts` exactly spec §13: `exportReportArchive`, `exportFromEnvelope`, `readReportArchive`, `readAttachedDocument`, `ArchiveReadError` (kinds invalid_pdf | no_attachment | attachment_stripped | incompatible_version), `ArchiveExportError` (kinds snapshot_invalid | snapshot_too_large | sheet_mismatch | too_many_pages), `Rasterizer`, `ExportInput`, `ExportResult`, `ExportWarning`, `PdfLocale`, `defaultPdfLabels`, `PDF_KEYWORD`, `MAX_PDF_BYTES`, `MAX_ATTACHMENT_BYTES`, plus `composeHighlightedViewSvg(sheet: SheetSnapshot, viewId, observation): string` for tests and the app.
3. Export behaviour = spec §14 "Export" steps 1-10 and "Label policy"; branding images: `kind 'png'` → base64 decoded with `atob` → `embedPng`; `kind 'svg'` → sanitised + rasterised at width 1200 (height from its viewBox, same clamp) → `embedPng`; each slot fails alone (`logo_failed` warning); view raster failure → page without image + `view_raster_failed`; parallel rasterisation, sequential embedding in view order; `exportedAt` drives every date; `setKeywords([PDF_KEYWORD])`; envelope attached pretty-printed as `osteo-report.json`, description `Faunosteo report archive v1`.
4. Goldens (T3): `tests/goldens.test.ts` reproduces every Phase 0 golden under `apps/app/tests/fixtures/goldens/step6/` for the three reports (v2full migrated through the draft map, demo, v2unresolved rebuilt with the same recipe as Phase 0 — reuse the recipe by reading `apps/app/tests/helpers/legacyLeaves.ts` logic, copy what you need into `tests/helpers/`), two locales, two logo modes: text entries (page, text, x, y, size, font) identical; images identical; links identical (Phase 0 recorded images and links PER LOCALE: `images.<report>.<locale>.<logos>.json`, `links.<report>.<locale>.<logos>.json`, because the footer centres the powered-by block on the label width); views facts identical except `titles` and `dataAttributes` (hidden markers are absent in the engine and the layer `<g>` loses its `data-layer`/`data-view-id`: assert `titles` ≥ highlighted count and `dataAttributes === 0` instead of the golden's 2). Logo modes: `nologos` = Branding with every logo null and credits with fallback texts, fake rasterizer returning the 1×1 PNG; `logos` = Branding built from the real `apps/app/public` files (PNG base64, Paws SVG), fake rasterizer returning the 2×1 PNG for views AND for the partner SVG (same constants and the same single stub as Phase 0, see `apps/app/tests/helpers/goldens.ts`). Compose through `composeViewSvg` from `@faunosteo/anatomy/render` (generic `root: ComposeElement`, xmldom `Element` satisfies it) with `highlight: { annotationIds, halo: view.kind === 'main' }`. Any mismatch is a visible change: do not "fix" the golden; report it.
CHECK: cd packages/pdf && corepack pnpm vitest run tests/goldens.test.ts 2>&1 | tail -3
EXPECT: Tests .* passed
5. T1 no-sheet re-export (`tests/reexport.test.ts`): export demo from a snapshot built with `buildSheetSnapshot` on the draft loaded from `supabase/seed/anatomical-sheets/equine/draft/` → `readReportArchive` → `exportFromEnvelope` → identical text/images/views facts; envelope deep-equal minus `exportedAt`; the test file imports nothing that knows the draft after the first export (the second export receives only the envelope).
6. Read (`tests/read.test.ts`, T4 T5 T6): roundtrip envelope → `readReportArchive` → `archive` deep-equals the exported envelope, `origin 'envelope_v1'`; `apps/app/tests/fixtures/report-v2.full.pdf` and `report-v2.minimal.pdf` → `'v2'`, migrated, then re-export → import again equals; the 612-leaf v2 report (recipe from legacyLeaves) → 29 unresolved findings kept through export/import; `report-v3.bare.pdf` → `'bare_v3'`, `archive null`; envelope v2 wrapper → report kept + `snapshotRejected 'unsupported_envelope'`; envelope v1 with report v4 → `incompatible_version` foundVersion 4; bare `version: 7` → 7; a PDF with `Keywords` containing `faunosteo-archive` and no attachment → `attachment_stripped`; a foreign PDF → `no_attachment`; the Filespec named `osteo-report.json` is chosen over an earlier unrelated `EmbeddedFile` in a crafted PDF; > 50 MiB → `invalid_pdf`.
7. Security (`tests/security.test.ts`, T8): 5 assets, a 3 MiB asset, depth 9, 1,025 annotations, a view chain cycle, a dangling `svg_asset_id`, `sheet_mismatch` → report imported and `snapshotRejected` with the right reason; hostile SVG assets (`<script>`, `onload`, `javascript:` href, external `<image>`, `<!ENTITY>`, `<style>` with `url(http…)`, 257 `<use>`, root `viewBox="0 0 1 100000"`) → removed / refused / clamped as spec §15, the export still succeeds for the removable ones with the hostile parts gone, and `assertSnapshot` refuses the oversized ones at export with a typed error and no file; `__proto__` ids harmless; 24 MB inflate bomb → null (move the existing test); `horse.svg` and `Paws_in_harmony.svg` sanitise with `removed: []` and a serialisation byte-identical to the parsed input.
8. Text (`tests/text.test.ts`, T9): `safeText` keeps en dash, em dash, accented letters, `•`, `·`; replaces `⚠`, `→`, an emoji by `?`; strips `\t`, U+2028, ESC; `wrapLines` and every drawText go through it (a report with `⚠` in a comment exports without throwing); `formatDate` returns a non-ISO input unchanged.
9. Raster (`tests/raster.test.ts`, T10, resvg): a real `Rasterizer` built on `@resvg/resvg-js` (`fitTo width`) renders the demo report's main and head highlighted views: PNG width = 1200, height = requested ±1, pixels within ±24 of `#b85a3f` present, non-white ratio in [0.01, 0.9]; a rasterizer that throws yields a PDF whose page has no image and one `view_raster_failed` warning.
10. Size (T7): demo envelope attachment stored bytes (the EmbeddedFile stream `contents.length` found through `enumerateIndirectObjects`) < 250,000; the test prints stored and raw sizes for `nologos` and `logos` brandings.
11. Everything green: `corepack pnpm typecheck && corepack pnpm lint && corepack pnpm test:run` in packages/pdf, and `corepack pnpm -r typecheck` at the root; `apps/app/src` untouched.
CHECK: git -C /home/bchanot/Documents/faunosteo status --short apps/app/src | wc -l
EXPECT: 0
## FILE SCOPE
packages/pdf/** (new), Dockerfile (one COPY line), packages/README.md (one row), pnpm-lock.yaml (install). Nothing under apps/app/src, packages/domain, packages/anatomy.
@@ -0,0 +1,24 @@
# CONTRACT — step-06 phase 4 app
- date: 2026-10-11 | flow: ship-feature (executor) | branch: feature/step-06-pdf-archives
- status: draft (dispatched after phase 3 lands)
- spec: docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md Part II §14 "App session", "Branding in the app", §16 messages, §17 (T12/T13 kept green), Part I §7 T2/T14/T15
## REQUEST (IMMUTABLE)
Wire the application onto `@faunosteo/pdf`: export through the engine with a snapshot, branding and the browser rasterizer; import through the engine with layered reading, kept archive and explicit rebase; new import messages; old PDF code removed; `report:compare` on the engine read API. No visual change to pages or app layout; alerts follow the existing `window.alert` pattern.
## ACCEPTANCE CRITERIA
1. `apps/app/src/pdf/` contains only: `export.ts` (`exportReportToPdf(report, index, { locale }): Promise<Uint8Array>` kept as the route-facing signature, implemented as `exportReportArchive({ report, sheet: buildSheetSnapshot(index.sheet, report), branding: await loadBranding(), labels: defaultPdfLabels, locale, rasterizer: browserRasterizer, exportedAt: new Date() })`, warnings → `console.warn`), `import.ts` (`importReportFromPdf(bytes, map)` returning the engine's `ArchiveReadOutcome`; `ImportError` kinds `invalid_pdf | incompatible_version | no_attachment | attachment_stripped` mapped 1:1 from `ArchiveReadError`), `browserRasterizer.ts` (today's `svgToPng.ts` adapted to `(svg, { widthPx, heightPx }) => Promise<Uint8Array>`: the engine computes the size, the adapter sets width/height on the root and draws), `branding.ts` (`loadBranding(): Promise<Branding>` per spec §14). `render/`, `attachment.ts`, `fonts.ts`, `src/anatomy/drawing.ts`'s highlight code are deleted; `drawing.ts` keeps `buildViewSvg`/`parseDrawing`/`sanitizeSvg` for the canvas (unchanged behaviour).
CHECK: ls apps/app/src/pdf
EXPECT: branding.ts browserRasterizer.ts export.ts import.ts
2. Store/persistence per spec §14 "App session": `archive: ReportArchiveEnvelope | null` in `ReportStore`, `hydrateImport({ report, archive })`, `initReport`/`reset`/`hydrateReport` clear it, `osteo:archive` key written only on those actions, `restoreDraft(index)` rebases a stale draft and restores the archive; `ArchivePersistence` beside `ReportPersistence`; tests in `state.reportStore.test.ts` extended (archive kept across a draft restore, cleared on new report, not rewritten on edits: spy on setItem).
3. `HomeRoute`: `importReportFromPdf` → `rebaseReportOnSheet(outcome.report, sheet.index, outcome.archive?.sheetSnapshot ?? null)` → `hydrateImport` → one alert composed per spec §16 (lines: migrated / archive_ok / snapshot_rejected with reason label / rebased with count) → `/editor`; error mapping adds `attachment_stripped`. `EditorRoute` export path unchanged for the user (download name, failure alert). The Phase 0 characterisation tests `routes.HomeRoute.import.test.tsx` and `routes.EditorRoute.export.test.tsx` stay green with at most these edits: the mocked outcome objects gain `origin`/`archive` fields, and the export call-shape assertion stays `(report, index, { locale })`.
4. i18n: keys of spec §16 added to fr.ts and en.ts with the given wording; `pdf.*` keys removed from both app dicts (the engine owns them; `severity.*`, `lateral.*`, `footer.*` stay, the UI uses them); `i18n.keys.test.ts` parity green.
5. `scripts/compare-reports.ts` + `scripts/compare/report.ts`: read through `readAttachedDocument` from `@faunosteo/pdf` and `readArchiveDocument` from `@faunosteo/domain/archive`; an envelope prints one extra header line `archive v1 (snapshot kept | snapshot rejected: <reason>)` under the same escaping rules; `scripts.compare.test.ts` green.
6. New tests: `pdf.export.app.test.ts` (T2: export the demo fixture through `exportReportToPdf` with the real bundled sheet, then mutate a cloned LoadedSheet's labels and one geometry, re-export the ENVELOPE through `exportFromEnvelope` and assert the engine output facts equal the first export, not the mutated sheet; T13 call shape covered by Phase 0), `pdf.goldens.test.ts` adapted so the app export path reproduces the Phase 0 goldens through the engine (same spies; the `rasterizeSvg` mock becomes a mock of `@/pdf/browserRasterizer`), `routes.HomeRoute.archive.test.tsx` (T15: envelope import with same sha → archive kept in store, archive_ok alert; envelope whose sha differs → rebased alert with count, unresolved flags, labels filled, `report.sheet` updated; snapshot rejected outcome → snapshot_rejected alert with the reason label; `attachment_stripped` → its error message), `migration.leaves.test.ts` kept green (612 leaves through the new path).
7. Bundle cost: `SHEET_BUNDLE=draft corepack pnpm build` in apps/app succeeds; report the gzip size of the main JS chunk before (from `git stash`-free method: build develop in a worktree is NOT allowed; instead read the size printed by vite for the chunk containing xmldom and report the total gz of dist/assets/*.js) and the size of the xmldom portion if vite's output isolates it; ceiling 50 KB gz for xmldom's share, else report.
8. Green: from the repo root `corepack pnpm typecheck && corepack pnpm lint && corepack pnpm test:run && corepack pnpm build`; `grep -rn "fetch(" apps/app/src/pdf` shows only `branding.ts`.
CHECK: cd /home/bchanot/Documents/faunosteo && corepack pnpm test:run 2>&1 | grep -E "Test Files|Tests " | tail -8
EXPECT: all passed
## FILE SCOPE
apps/app/src/pdf/**, apps/app/src/anatomy/drawing.ts (removal of highlight-only code if any), apps/app/src/app/routes/{HomeRoute,EditorRoute,NewReportRoute}.tsx (minimal), apps/app/src/state/{reportStore,persistence}.ts, apps/app/src/i18n/{fr,en}.ts, apps/app/scripts/**, apps/app/package.json (dependency `@faunosteo/pdf: workspace:*`, drop `pdf-lib` only if no app code imports it anymore), apps/app/tests/** (adaptations named above; goldens JSON files never edited), CLAUDE.md folder map lines for apps/app/src/pdf (keep docs minimal; Phase 5 owns the docs). Nothing under packages/**.
@@ -0,0 +1,17 @@
# CONTRACT — step-06 security fix 2 (after re-audit PASS with 2 MEDIUM)
- date: 2026-10-11 | flow: ship-feature (executor, security loop) | branch: feature/step-06-pdf-archives
- status: active
## REQUEST (IMMUTABLE)
Close the two MEDIUM findings of the second audit without changing any page output: (1) the `/URI` written as `PDFHexString.fromText` is UTF-16BE with a BOM, so poppler-based viewers read a dead link (`þÿ…`); write the URL's ASCII bytes as a hex string instead, keeping the injection protection; (2) the PNG budget reads only the first IHDR while UPNG honours the last one: walk the chunk list, require exactly one IHDR (length 13) as the first chunk, refuse any later IHDR and the APNG chunks `acTL`, `fcTL`, `fdAT`.
## ACCEPTANCE CRITERIA
1. `packages/pdf/src/render/linkAnnotation.ts` writes `URI: PDFHexString.of(<hex of the ASCII bytes>)`; a test asserts the saved bytes contain the hex form of `https://faunosteo.com` (uppercase or lowercase hex, no `FEFF`), that a reload through pdf-lib decodes `/URI` to the URL, and that the injection payload (cast past the schema) still yields no `/JavaScript`, `/Next` or `/JS` in the bytes. A character above 0x7e in the URL throws (the schema already refuses it) — test.
CHECK: cd packages/pdf && corepack pnpm vitest run tests/security.test.ts tests/goldens.test.ts 2>&1 | grep -E "Tests " | tail -1
EXPECT: Tests .* passed
2. `packages/pdf/src/branding.ts` `pngHeaderIssue` walks chunks (length, type, data, CRC) until `IEND` or the end of the buffer: first chunk must be `IHDR` with length 13; any further `IHDR`, or `acTL`/`fcTL`/`fdAT`, or a chunk length that overruns the buffer → issue; the existing side/pixel caps stay. Tests: doubled IHDR (1×1 then 10000×10000) refused, APNG with `acTL` refused, truncated chunk length refused, the four real `public/` logos and the two fixture PNGs accepted; the export-level test asserts a doubled-IHDR header logo gives exactly `[{ kind: 'logo_failed', slot: 'headerLogo' }]` and `embedPng` never receives it.
3. `docs/PDF-FORMAT.md`: the PNG sentence says the chunk list is walked and a second IHDR or APNG chunk is refused (replace any "never decoded" wording); "Known limits" names the browser rasterizer (`apps/app/src/pdf/browserRasterizer.ts`) as the production path whose `<use>` expansion limits are not measured.
4. Green from the root: `corepack pnpm typecheck && corepack pnpm lint && corepack pnpm test:run`; `git diff --quiet 8b86b92 HEAD -- apps/app/tests/fixtures/goldens` (goldens untouched); link goldens still pass in both packages (the readers decode hex strings).
## FILE SCOPE
packages/pdf/src/render/linkAnnotation.ts, packages/pdf/src/branding.ts, packages/pdf/tests/security.test.ts (and tests/helpers if a reader needs the ASCII-hex form), docs/PDF-FORMAT.md. Nothing else.
@@ -0,0 +1,23 @@
# CONTRACT — step-06 security fix (after SECURITY BLOCK(1) + MEDIUM/LOW findings)
- date: 2026-10-11 | flow: ship-feature (executor, security loop) | branch: feature/step-06-pdf-archives
- status: verified (CONFORME on substance after oracle fix; security re-audit pending)
## REQUEST (IMMUTABLE)
Close the HIGH finding (PDF object injection through an archived branding URL) at the sink and at the schema, and the cheap MEDIUM/LOW findings listed below. No behaviour change for valid inputs: the Step 6 goldens must stay green. Findings deferred with a documented limit: pdf-lib uncapped object-stream inflation (pre-existing, needs a Worker or a pre-scan that would refuse our own PDFs), `<use>` nesting expansion (resvg already refuses), Report v3 collection caps on read.
## ACCEPTANCE CRITERIA
1. HIGH sink: `packages/pdf/src/render/linkAnnotation.ts` writes the URI as `PDFHexString.fromText(url)` (or escapes `\`, `(`, `)` and refuses control characters) so no URL can close the string literal; a test exports a PDF whose branding URL is `https://a.example/) /Next << /S /JavaScript /JS (app.alert\(1\)) >> /Z (` through `exportFromEnvelope` AFTER bypassing the schema with a cast, reloads the bytes with pdf-lib and asserts no `/JavaScript` action exists and the link's `/URI` decodes to the full original string (or the export is refused by criterion 3, in which case the test asserts the typed refusal and a second test proves the sink escaping on a URL with `)` that the schema accepts, if any).
CHECK: cd packages/pdf && corepack pnpm vitest run tests/security.test.ts 2>&1 | grep -E "Tests " | tail -1
EXPECT: Tests .* passed
EVIDENCE: 2026-10-11 verifier pass 1 ECARTS(1) = this oracle (`tail -2` kept only the Duration line), behaviour MET (33/33, sink + schema + refusal tests read). Oracle corrected by the orchestrator; literal run → `Tests 33 passed (33)`. MET.
2. Schema: `HttpUrlSchema` in `packages/domain/src/archive/branding.ts` accepts only `^https?://[^\s()\\<>"'\x00-\x1f\x7f]+$` (ASCII, no parentheses, backslash, quotes, angle brackets, whitespace, control characters) and ≤ 2048 chars; the current real URLs (`https://faunosteo.com`, `https://zenquality.fr`, `https://www.instagram.com/paws.iin.harmony`) pass; domain tests cover accept/reject.
3. Export re-validates its inputs: `exportReportArchive` runs `BrandingSchema.parse(input.branding)` and `PdfLabelSetSchema.parse(input.labels)` first; a failure → `ArchiveExportError('branding_invalid')` (new kind, documented) before any page is drawn; test.
4. PNG budget: `packages/pdf/src/branding.ts` reads the PNG IHDR (signature + width/height at bytes 16-23) before `embedPng`; refuse when width × height > 16,777,216 (4096²) or either side > 8192, or when the signature is wrong → that slot fails alone with a `logo_failed` warning; test with a crafted IHDR.
5. Sanitiser hardening in `packages/pdf/src/svg/sanitize.ts`: any attribute value containing a backslash `\` is removed; in `style` attributes and in every presentation attribute, any `(` not part of `url(#` is refused (attribute removed); `image-set(`, `expression(`, `@import`, `javascript:`, `behavior:` refused as today. `horse.svg` and `Paws_in_harmony.svg` still sanitise with `removed: []` (existing test stays green); new tests for `u\72l(`, `image-set(`, `fill="u\72l(http://evil/x)"`.
6. NaN guard: `packages/pdf/src/svg/view.ts` raster size uses `Number.isFinite` on the view box numbers; a non-finite or ≤ 0 box falls back to the 0.6 ratio; test with `viewBox="0 0 1e999 1e999"` → a valid size, no NaN.
7. `apps/app/src/app/routes/HomeRoute.tsx` checks `file.size > MAX_PDF_BYTES` before `arrayBuffer()` and maps it to the `invalid_pdf` message; route test updated (`routes.HomeRoute.import.test.tsx` gains one case, others unchanged).
8. `docs/PDF-FORMAT.md` "Limits" gains: the URL rule, the PNG budget, and a "Known limits" paragraph: pdf-lib inflates PDF object streams without a cap when loading (a crafted PDF of a few hundred KB can expand to hundreds of MB in the tab; mitigation planned: parse in a Worker or locate the attachment without a full load), `<use>` expansion bounded by the rasterizer, Report collections not capped on read (export refuses above 500 observations).
9. Green: `corepack pnpm typecheck && corepack pnpm lint && corepack pnpm test:run` from the root; goldens untouched (`git diff --stat 8b86b92 HEAD -- apps/app/tests/fixtures/goldens` empty).
## FILE SCOPE
packages/pdf/src/{render/linkAnnotation.ts,export.ts,errors.ts,branding.ts,svg/sanitize.ts,svg/view.ts,index.ts}, packages/pdf/tests/**, packages/domain/src/archive/branding.ts, packages/domain/tests/archive.branding-labels.test.ts, apps/app/src/app/routes/HomeRoute.tsx, apps/app/tests/unit/routes.HomeRoute.import.test.tsx, docs/PDF-FORMAT.md. Nothing else.
@@ -0,0 +1,51 @@
# CONTRACT — step-06 autonomous PDF archives (whole step, for the fresh verifier)
- date: 2026-10-11 | flow: ship-feature | branch: feature/step-06-pdf-archives
- status: active
- spec: docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md (Part II binding), docs/PDF-FORMAT.md; phase contracts 2026-10-11-step-06-phase-{0,1,2,3,4}-*.md
## REQUEST (verbatim user requirements, 2026-10-11 — IMMUTABLE)
Un PDF Faunosteo doit rester lisible, interprétable et réexportable dans le futur, même si : la fiche anatomique originale a disparu ; le catalogue de constats a changé ; les identifiants ou les traductions ont évolué ; le logo Faunosteo a changé ; les ressources du site ne sont plus disponibles ; le bilan contient des éléments hérités ou non résolus. L'export ne doit nécessiter aucun chargement réseau. Preuve automatisée des scénarios : (1) exporter un bilan v3, supprimer l'accès à sa fiche actuelle, puis l'importer et le réexporter depuis son instantané ; (2) modifier le catalogue anatomique courant sans affecter l'interprétation des anciennes archives ; (3) modifier le branding courant sans altérer les ressources historiques d'une archive réexportée ; (4) importer un PDF v2, migrer son bilan et conserver ses éventuels éléments non résolus ; (5) comparer le contenu et le rendu des PDF FR/EN aux références enregistrées avant la refactorisation ; (6) rejeter proprement les instantanés dangereux, invalides ou excessivement volumineux, sans perdre les données récupérables du bilan ; (7) vérifier qu'aucun chargement réseau n'est nécessaire à la génération ; (8) tester la rasterisation réelle des SVG. Aucun changement graphique des pages. Instantané importé conservé en session, rebase explicite sur copie de travail. Messages FR/EN explicites, jamais une importation dégradée présentée comme parfaite.
## ACCEPTANCE CRITERIA
1. Scenario 1 (no-sheet re-export) is a test in packages/pdf that re-exports from the envelope alone and compares text/images/views facts.
CHECK: grep -ln "exportFromEnvelope" packages/pdf/tests/*.test.ts | wc -l; cd packages/pdf && corepack pnpm vitest run tests/reexport.test.ts 2>&1 | tail -2
EXPECT: >= 1 ; passed
2. Scenario 2 (catalog changed) is a test in apps/app that mutates the loaded sheet (labels + geometry) and proves the envelope re-export ignores it.
CHECK: grep -n "mutat\|renamed\|changed sheet\|exportFromEnvelope" apps/app/tests/unit/pdf.export.app.test.ts | head -3; cd apps/app && corepack pnpm vitest run tests/unit/pdf.export.app.test.ts 2>&1 | tail -2
EXPECT: matches ; passed
3. Scenario 3 (branding changed) — the envelope carries `branding` and `labels`, and `exportFromEnvelope` uses them, not the caller's current branding: a test exports with branding A, re-exports the envelope while branding B is the app's current one, and the images/links/text of the re-export equal the first export.
CHECK: grep -rn "branding" packages/pdf/tests/reexport.test.ts apps/app/tests/unit/pdf.export.app.test.ts | grep -i "differ\|current\|B\b\|other" | head -3
EXPECT: at least one assertion that the re-export does not use the current branding (if absent → ECART)
4. Scenario 4 (v2 import with unresolved items kept): v2 fixtures and the 612-leaf report import, unresolved items survive export → import.
CHECK: cd packages/pdf && corepack pnpm vitest run tests/read.test.ts 2>&1 | tail -2; cd ../../apps/app && corepack pnpm vitest run tests/unit/migration.leaves.test.ts 2>&1 | tail -2
EXPECT: passed ; passed
5. Scenario 5 (goldens): the 39 Phase 0 goldens are unchanged in git since commit 8b86b92 and reproduced by the engine (packages/pdf/tests/goldens.test.ts) and by the app path (apps/app/tests/unit/pdf.goldens.test.ts).
CHECK: git diff --stat 8b86b92 HEAD -- apps/app/tests/fixtures/goldens | tail -1; cd packages/pdf && corepack pnpm vitest run tests/goldens.test.ts 2>&1 | tail -2; cd ../../apps/app && corepack pnpm vitest run tests/unit/pdf.goldens.test.ts 2>&1 | tail -2
EXPECT: empty diff ; passed ; passed
6. Scenario 6 (hostile/oversized snapshots rejected, report kept): security tests cover caps, cycles, dangling asset, sheet_mismatch, hostile SVG, entity, use bomb, viewBox bomb, inflate bomb, __proto__; every rejection keeps `report`.
CHECK: cd packages/pdf && corepack pnpm vitest run tests/security.test.ts 2>&1 | grep -E "Tests|✓|passed" | tail -3; grep -cE "^\s*\[?'(five assets|3 MiB|depth 9|1,?025|cycle|dangling|sheet_mismatch)|reason: '" packages/pdf/tests/security.test.ts
EXPECT: 20 passed ; the rejection table lists the 7 cases (count ≥ 7 rows carrying a `reason:`), each asserted to keep `outcome.report` (one shared assertion over the parametrised table is accepted)
7. Scenario 7 (no network): packages/pdf has no `fetch`/DOM usage (lint rule + grep) and its suite runs in vitest `node` environment; the only `fetch(` under apps/app/src/pdf is in branding.ts.
CHECK: grep -rnE "\bfetch\(|\bwindow\.|globalThis\.document|\bnew Image\(|navigator\." packages/pdf/src | wc -l; grep -rln "from '@xmldom/xmldom'" packages/pdf/src | wc -l; grep -rnE "DOMParser|XMLSerializer" packages/pdf/src -l | xargs grep -L "@xmldom/xmldom" | wc -l; grep -rln "fetch(" apps/app/src/pdf; grep -n "environment" packages/pdf/vitest.config.ts; grep -c "no-restricted-globals" packages/pdf/eslint.config.js
EXPECT: 0 ; >= 1 ; 0 (every file using DOMParser/XMLSerializer imports them from xmldom) ; apps/app/src/pdf/branding.ts only ; node ; >= 1
8. Scenario 8 (real raster): resvg-based test renders main and head views with dimension and highlight-colour assertions.
CHECK: cd packages/pdf && corepack pnpm vitest run tests/raster.test.ts 2>&1 | tail -2
EXPECT: passed
9. Pages unchanged: no edit to render constants/layout beyond the move (compare `packages/pdf/src/render/*.ts` against `git show 8b86b92:apps/app/src/pdf/render/*.ts` — differences limited to imports, labels source, SheetIndex source, rasterizer call, safeText); goldens green (criterion 5).
10. Session: store holds `archive`, persisted under `osteo:archive` only on hydrateImport/hydrateReport/initReport/reset; `rebaseReportOnSheet` runs on import and draft restore; tests exist.
CHECK: grep -n "osteo:archive\|hydrateImport\|rebaseReportOnSheet" apps/app/src/state/*.ts apps/app/src/app/routes/HomeRoute.tsx apps/app/src/app/routes/EditorRoute.tsx | wc -l
EXPECT: >= 5
11. Messages: fr.ts and en.ts carry `home.import.archive_ok`, `home.import.snapshot_rejected`, five `home.import.snapshot_reason.*`, `home.import.rebased`, `home.import.error_attachment_stripped`; HomeRoute composes them; i18n parity test green; `pdf.*` keys gone from the app dicts.
CHECK: grep -c "home.import.snapshot_reason\." apps/app/src/i18n/fr.ts apps/app/src/i18n/en.ts; grep -c "'pdf\." apps/app/src/i18n/fr.ts
EXPECT: 5 5 ; 0
12. Whole workspace green and buildable: `corepack pnpm typecheck && corepack pnpm lint && corepack pnpm test:run && corepack pnpm build` from the root; `docker build -t faunosteo-step6 .` succeeds.
EVIDENCE: 2026-10-11 orchestrator: root typecheck/lint/test:run (154+21+130+53+222 = 580 tests) and build rc 0 at 9bd5173; `docker build -t faunosteo-step6 .` exit 0 (log in the session scratchpad, image tagged). MET.
13. Docs: docs/PDF-FORMAT.md describes envelope v1, snapshot content, layered reading, rebase, caps, sizes; CLAUDE.md folder map lists packages/pdf and the new apps/app/src/pdf files; CHANGELOG has the Step 6 entry; DEPLOY.md has the rollback note.
CHECK: grep -c "envelopeVersion\|snapshotRejected\|rebase" docs/PDF-FORMAT.md; grep -n "packages/pdf" CLAUDE.md | head -2
EXPECT: >= 3 ; present
## CLARIFICATIONS
- 2026-10-11 (orchestrator, after verifier pass 1 ECARTS(31): oracle defects + scope): CHECKs of criteria 6 and 7 rewritten above (the behaviour was met, the oracles counted the wrong thing). FILE SCOPE widened below to the structurally necessary files. Deleted tests authorised: `apps/app/tests/unit/pdf.attachment.test.ts` → replaced by `packages/pdf/tests/read.test.ts` (roundtrip, no_attachment, oversized) and `apps/app/tests/unit/pdf.import.test.ts`; `pdf.attachment.inflate.test.ts` → `packages/pdf/tests/security.test.ts` (inflate bomb); `pdf.svgToPng.test.ts` → `apps/app/tests/unit/pdf.browserRasterizer.test.ts`. The spec (Part II §18, Phase 4 contract criterion 1) planned the removal of the legacy modules with their tests.
## FILE SCOPE
packages/pdf/**, packages/domain/** (src/archive, src/report/rebase.ts, src/anatomical-sheet/sheet-index.ts, barrels, package.json, tests), packages/anatomy/src/render/{compose,index}.ts, packages/anatomy/src/curation/app-review.ts, packages/anatomy/tests/render.compose.test.ts, apps/app/package.json, apps/app/src/services/sheetIndex.ts, .claude/** (memory, TODO, contracts), apps/app/src/pdf/**, apps/app/src/state/**, apps/app/src/app/routes/{HomeRoute,EditorRoute}.tsx, apps/app/src/i18n/{fr,en}.ts, apps/app/src/sheets/provider.ts, apps/app/vite/sheet-bundle.ts, apps/app/scripts/**, apps/app/tests/**, docs/**, CLAUDE.md, README.md, CHANGELOG.md, DEPLOY.md, Dockerfile, packages/README.md, pnpm-lock.yaml.
+2 -1
View File
@@ -6,8 +6,9 @@ Versions follow [Semantic Versioning](https://semver.org/).
## [Unreleased]
### Added (SaaS migration, plan Steps 3–4)
### Added (SaaS migration, plan Steps 3–6)
- **Autonomous PDF archives (Step 6)** — new `@faunosteo/pdf` engine (`packages/pdf`): the PDF is rendered from explicit inputs (report, sheet snapshot, branding, labels, locale, rasterizer, export date), with no network and no browser DOM; the attachment becomes a **report archive envelope v1** (`osteo-report.json`) carrying the Report v3, a lean but valid snapshot of the anatomical sheet (views, annotations, geometry, colours, relations, the finding paths used with their ancestor labels, the SVG drawing), the branding used at export and the FR/EN label dictionary, so an old bilan is reproduced identically after any catalog, wording or logo change. Layered reading keeps the report even when the wrapper or the snapshot is refused (closed reasons), v2 and bare v3 PDFs still import, a PDF whose attachment was stripped is recognised. Imported archives are kept in the session; a bilan reopened on a different sheet is rebased on a working copy with unresolved items flagged and their labels kept, and the import message says so. SVG assets go through an allowlist sanitiser with size and complexity caps checked at import and at export; a WinAnsi guard keeps any text from crashing the export. Pages unchanged (frozen by 39 goldens). `docs/PDF-FORMAT.md` written for real.
- **Supabase foundation** — local stack (`supabase/config.toml`), migrations (schemas `private` / `audit`, `profiles`, platform roles with audited RPCs), pgTAP suite run on PGlite (`pnpm test:run`) and on the real stack (`pnpm db:test`), `@faunosteo/supabase` typed client + generated types. No UI change.
- **Anatomical sheet model** — `@faunosteo/domain`: canonical sheet document (views tree, annotations with stable ids and explicit laterality, ordered vertebral regions, typed finding categories, explicit annotation → finding zone links, FR/EN labels) with integrity validation; tables `species`, `anatomical_sheets`, `anatomical_sheet_versions` (published rows immutable, one draft per sheet, deletion preconditions), `anatomical_sheet_assets`; lifecycle RPCs (create, draft, publish, deprecate, delete, fork with provenance, archive, assets) audited and under RLS. Spec: `docs/development/ANATOMICAL_SHEET_MODEL.md`.
+37 -23
View File
@@ -17,7 +17,12 @@ audit log exist; Step 4 added the canonical anatomical sheet model (`packages/do
tables `species`, `anatomical_sheets` / `_versions` / `_assets`). Step 5 moved the
application onto that model: the editor renders the bundled reference sheet (the
curated equine DRAFT, `SHEET_BUNDLE=draft`), writes Report v3 and imports v2 PDFs
through a generated migration map. The Supabase client is still unused by the UI.
through a generated migration map. Step 6 made the PDF an autonomous archive: the
`packages/pdf` engine renders from explicit inputs (report, sheet snapshot, branding,
labels, rasterizer) with no network and no DOM, and the attachment is an envelope v1
carrying the report, a lean sheet snapshot, the branding and the labels used, so an old
bilan is reproduced identically after any catalog, wording or logo change
(`docs/PDF-FORMAT.md`). The Supabase client is still unused by the UI.
MVP species: equine only. Open-source MIT.
---
@@ -148,10 +153,11 @@ pnpm format # Prettier write
```
faunosteo/
├─ apps/app/ ← @faunosteo/app (everything below until packages/)
├─ public/ ← logos only (no anatomy asset: the sheet is bundled)
├─ public/ ← favicons, env.js, site header logo only (PDF logos live in src/assets/brand; no anatomy asset)
├─ vite/sheet-bundle.ts ← Vite plugin: `virtual:faunosteo-sheet` (SHEET_BUNDLE=draft|none)
├─ scripts/compare-reports.ts ← `pnpm report:compare`: archive PDF vs v3 reading (pure part in scripts/compare/report.ts)
├─ src/
│ ├─ assets/brand/ ← the four PDF branding logos, bundled by Vite (?inline / ?raw / ?url), never fetched
│ ├─ app/
│ │ ├─ App.tsx ← root router
│ │ ├─ routes/{Home,NewReport,Editor,NotFound}Route.tsx
@@ -180,9 +186,9 @@ faunosteo/
│ │ ├─ report/{ReportHeader,PractitionerForm,AnimalForm,EditInfosDialog,DisclaimerDialog,
│ │ │ ConclusionPanel,NextAppointmentPicker}.tsx
│ │ └─ brand/{Brand,AppHeader,Footer,LanguageSwitcher}.tsx
│ ├─ pdf/
│ │ ├─ export.ts + import.ts + attachment.ts + fonts.ts
│ │ └─ render/{header,footer,observationPage,conclusionPage,svgToPng,text,logo,linkAnnotation}.ts
│ ├─ pdf/ ← app side of @faunosteo/pdf (engine in packages/pdf)
│ │ ├─ export.ts + import.ts ← exportReportToPdf (sheet snapshot + branding + browser rasterizer → engine), importReportFromPdf (ArchiveReadOutcome, ImportError kinds)
│ │ └─ branding.ts + browserRasterizer.ts ← bundled src/assets/brand logos (?inline / ?raw) → Branding; Image/canvas Rasterizer adapter
│ ├─ lib/{dates,id,assert,supabase}.ts ← supabase.ts: getSupabaseClient() | null
│ ├─ styles/{index,tokens}.css ← Tailwind v4 CSS-first
│ └─ main.tsx
@@ -201,10 +207,11 @@ faunosteo/
├─ eslint.config.js, index.html, package.json (@faunosteo/app)
├─ tsconfig*.json, vite.config.ts, vitest.config.ts
│ (end of apps/app)
├─ packages/domain/ ← @faunosteo/domain (pure, no DOM, zod only)
├─ packages/domain/ ← @faunosteo/domain (pure, no DOM, zod only): anatomical-sheet (document, integrity rules, sheet-index), report (v3, v2 migration, rebase), archive (sheet snapshot, envelope v1, branding, labels, layered reader)
│ ├─ src/anatomical-sheet/{schema,validate,create}.ts ← canonical sheet document + integrity rules
│ └─ tests/{fixtures/horse-slice.ts,*.test.ts}
├─ packages/anatomy/ ← @faunosteo/anatomy: legacy importer, curation pipeline, pure annotation-layer renderer (`./render`)
├─ packages/anatomy/ ← @faunosteo/anatomy: legacy importer, curation pipeline, pure annotation-layer renderer + view composer (`./render`)
├─ packages/pdf/ ← @faunosteo/pdf: browser-free PDF engine — src/{export,read,text,branding}.ts, attachment/, svg/{parse,sanitize,view}.ts, render/, i18n/; tests reproduce the Step 6 goldens
│ ├─ src/legacy/{svg,catalog,regions,ids,report,importer}.ts, src/cli/import-equine.ts
│ ├─ src/curation/{schema,targets,fields,ops,rename,apply,types,assets,labels,stats,changelog,review-report,overlay,seed,sources,pipeline}.ts ← changeset → draft
│ └─ tests/ ← counts preserved, special cases, determinism, curation ops, golden artifacts
@@ -250,19 +257,23 @@ SVG interaction
→ open_vertebra_picker / open_laterality_picker → pickers → reducers (ensureZone, addSides, syncVertebrae)
→ toggle / remove_both_sides → updateObservation() in store
PDF export
→ exportReportToPdf(report, sheet, { locale })
→ pdf-lib PDFDocument
→ embedFonts (Helvetica body + TimesRoman heading — WinAnsi StandardFonts; TTF Inter/Fraunces planned)
→ for each observation: addObservationPage (rasterize SVG → PNG)
→ addConclusionPage
→ attachReportJson (native EmbeddedFiles)
→ Uint8Array → browser download
PDF export (app side: apps/app/src/pdf, engine: packages/pdf)
→ exportReportToPdf(report, index, { locale })
→ buildSheetSnapshot(index.sheet, report) + loadBranding() (4 logos bundled at build time, no network) + defaultPdfLabels
→ exportReportArchive({ report, sheet, branding, labels, locale, rasterizer: browserRasterizer, exportedAt })
assertSnapshot (caps, integrity, sheet invariant) → fonts (WinAnsi StandardFonts, safeText guard)
→ per observation: composeHighlightedViewSvg (xmldom: sanitise allowlist → composeViewSvg highlight) → rasterizer → page
→ conclusion page, footer, envelope v1 attached as osteo-report.json, Keywords faunosteo-archive/1
→ { pdf, envelope, warnings } → { pdf, warnings } to EditorRoute → browser download, alert naming failed logo slots / views
→ exportFromEnvelope(envelope, …) re-exports an archive from its own snapshot, branding and labels (no sheet)
PDF import
→ importReportFromPdf(bytes, migrationMap)
→ extractReportJson → readReportDocument (v3 as is, v2 migrated, else incompatible_version)
→ hydrateReport() → navigate /editor (unresolved zones/findings kept and flagged)
→ importReportFromPdf(bytes, migrationMap) → readReportArchive (engine)
→ byte scan for the EmbeddedFile stream (no pdf-lib parse on untrusted bytes, BLK-009): named osteo-report* first,
capped native inflation → layered reading: report (v3 as is, v2 migrated, else incompatible_version),
envelope metadata tolerant, snapshot/branding/labels strict → archive kept or snapshotRejected (closed reason)
→ rebaseReportOnSheet(report, index, archivedSnapshot) when the loaded sheet differs (unresolved flags, labels kept)
→ hydrateImport({ report, archive }) → one alert (archive_ok / snapshot_rejected / rebased / migrated) → navigate /editor
Runtime config
→ Docker entrypoint writes env.js (window.__APP_CONFIG__)
@@ -295,7 +306,7 @@ Database (Supabase)
- Get the translate function in any component: `const t = useT()` then `t('common.cancel')`
- `src/state/localeStore.ts` holds current `Locale` (`'fr' | 'en'`), persisted to `localStorage` key `osteo:locale`; default: navigator-detected `fr`/`en`, or `'fr'` if no match
- Zone and finding names shown in the editor and the PDF come from the sheet document (`{ fr, en }` labels) and from the report's snapshots, not from the dict
- PDF static labels (section headings, metadata) come from the dict via `getDict(locale)` in `exportReportToPdf`
- PDF static labels (section headings, metadata) live in the engine (`packages/pdf/src/i18n`, `defaultPdfLabels`, 25 keys) and are archived in the envelope; the app dicts hold no `pdf.*` key
### Identity strings
- NEVER hardcode APP_SITE_NAME, APP_BRAND_NAME, APP_FOOTER_NAME, APP_TAGLINE
@@ -322,13 +333,15 @@ Database (Supabase)
### Stores
- No direct store mutation outside Zustand actions
- No business logic in components — delegate to store actions
- sessionStorage key: osteo:draft (auto-saved on every change, v3; a v2 draft is migrated on restore once the sheet is loaded)
- sessionStorage keys: osteo:draft (auto-saved on every change, v3; a v2 draft is migrated and a stale draft rebased on restore once the sheet is loaded) and osteo:archive (the imported archive envelope, written only on import / new report / reset, never on edits)
- localStorage key: osteo:lastPractitioner (practitioner prefill cache)
### PDF
- A4 portrait: 595.28 × 841.89 pt
- No raw URLs in PDF output — abbreviated citations only
- JSON attachment filename must start with osteo-report; content = Report v3; import accepts v2 (migrated) and v3
- JSON attachment filename must start with osteo-report; content = report archive envelope v1 (report v3 + sheet snapshot + branding + labels); import accepts bare v2 (migrated), bare v3 and envelope v1; a bad snapshot never loses the report
- The engine (`packages/pdf`) has no DOM lib, no fetch, no Node-only global (lint-enforced); rasterisation is an injected adapter; every SVG it receives is sanitised by allowlist with caps
- Page layout is frozen by the Step 6 goldens: any visible change needs a user decision and a golden regeneration
- Fonts are StandardFonts (Helvetica/TimesRoman, WinAnsi encoding) — TTF Inter/Fraunces planned but not yet embedded. Any non-Latin-1 glyph in PDF text must use an ASCII surrogate until the TTF migration lands (e.g. `(!)` instead of `⚠`).
### Anatomical sheet content
@@ -417,8 +430,9 @@ Database (Supabase)
- Annotation rendering changes require updating docs/ANNOTATION-RENDERING.md first.
- Never modify the legacy sources under `supabase/seed/anatomical-sheets/equine/legacy-sources/` — they are the
importer's input (the user's historical files).
- Ask before any change to importReportFromPdf, extractReportJson or readAttachedDocument — these handle user data.
- After PDF roundtrip tests fail: check attachment bytes, then Zod validation (v3, or v2 through the migration map), then DecompressionStream inflation.
- Ask before any change to `readReportArchive`, `readArchiveDocument`, `readAttachedDocument` or `rebaseReportOnSheet` — they handle user data; archive readers never drop a schema version (envelope v1, Report v2/v3, sheet document v2).
- Import never parses untrusted PDF object graphs: the attachment is located by byte scan and inflated under the 16 MiB cap (BLK-009). Opening the import to external users is gated by `docs/development/PDF_IMPORT_HARDENING.md` §5 (BDR-040).
- After PDF roundtrip tests fail: check attachment bytes, then the layered reader (report first, envelope metadata, snapshot/branding/labels), then DecompressionStream inflation. Goldens under `apps/app/tests/fixtures/goldens/step6` are never regenerated without a user decision.
- Node 24 / pnpm 10.13.1: `corepack enable` or `corepack pnpm`; never a global install.
- SQL change: `pnpm --filter @faunosteo/supabase test:run` (PGlite) before commit; `pnpm db:reset && pnpm db:test`
on the real stack when Docker is available; regenerate types (`pnpm db:types`).
+6
View File
@@ -242,6 +242,12 @@ For zero-downtime updates, `docker compose up --build -d` rebuilds the
image then recreates the container; the container restart is sub-second
because nginx:alpine boots instantly. There is no warmup phase.
Rollback note (PDF archives, Step 6): PDFs exported by a Step 6 build carry
a report archive envelope. A build older than Step 6 reads such a PDF as "no
attachment"; a Step 6 build reads every older PDF (bare v2 and v3). Roll back
only with that limit in mind and tell the practitioners which build produced
their files.
---
## Data persistence
+1
View File
@@ -13,6 +13,7 @@ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY apps/app/package.json apps/app/
COPY packages/domain/package.json packages/domain/
COPY packages/anatomy/package.json packages/anatomy/
COPY packages/pdf/package.json packages/pdf/
COPY packages/supabase/package.json packages/supabase/
RUN pnpm install --frozen-lockfile
+6 -3
View File
@@ -103,7 +103,9 @@ For production deployment (VPS provisioning, firewall, TLS, nginx reverse proxy,
- [docs/ANNOTATION-RENDERING.md](docs/ANNOTATION-RENDERING.md) — annotation layer contract (markers drawn from the sheet document)
- [docs/development/ANATOMICAL_SHEET_MODEL.md](docs/development/ANATOMICAL_SHEET_MODEL.md) — canonical anatomical sheet document, curation pipeline, report migration map
- [docs/development/STEP5_MIGRATION_ANALYSIS.md](docs/development/STEP5_MIGRATION_ANALYSIS.md) — how the application moved onto the canonical sheet (Report v3)
- [docs/PDF-FORMAT.md](docs/PDF-FORMAT.md) — PDF page layout and attachment contract
- [docs/PDF-FORMAT.md](docs/PDF-FORMAT.md) — PDF pages, report archive envelope (snapshot, branding, labels), reading and limits
- [docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md](docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md) — why and how the PDF became an autonomous archive (Step 6)
- [docs/development/PDF_IMPORT_HARDENING.md](docs/development/PDF_IMPORT_HARDENING.md) — PDF import against decompression bombs: what lands now, what is required before external users
- [docs/development/SUPABASE.md](docs/development/SUPABASE.md) — local Supabase stack, migrations, RLS tests, generated types
- [DEPLOY.md](DEPLOY.md) — production VPS deploy guide (Docker + nginx + TLS + hardening)
- [CHANGELOG.md](CHANGELOG.md) — versioned release notes
@@ -125,12 +127,13 @@ faunosteo/ pnpm workspace (see docs/development/WORKSPACE.md)
├─ src/state/ Zustand store (Report v3) + persistence adapter + locale store
├─ src/anatomy/ drawing: sanitised asset + annotation layer → inline SVG per view
├─ src/components/ UI primitives, canvas, observation, report
├─ src/pdf/ export/import/attachment/fonts + renderers
├─ src/pdf/ app side of the PDF: snapshot + branding + browser rasterizer → @faunosteo/pdf engine
├─ src/lib/ id, dates, assert utilities
├─ src/styles/ Tailwind v4 CSS + design tokens
├─ tests/unit/ vitest tests on the bundled sheet (+ frozen v2 fixtures)
├─ packages/domain/ @faunosteo/domain: canonical sheet document + report document (v3, v2 migration)
├─ packages/anatomy/ @faunosteo/anatomy: legacy importer, curation pipeline, annotation-layer renderer
├─ packages/anatomy/ @faunosteo/anatomy: legacy importer, curation pipeline, annotation-layer renderer + view composer
├─ packages/pdf/ @faunosteo/pdf: browser-free PDF engine (explicit inputs, archive envelope v1, layered reader)
├─ packages/supabase/ @faunosteo/supabase: typed client, generated types, PGlite SQL test harness
├─ supabase/ CLI config, SQL migrations, local seed (incl. the equine sheet), pgTAP tests
├─ docker/ entrypoint.sh + nginx.conf
+1
View File
@@ -17,6 +17,7 @@
"dependencies": {
"@faunosteo/anatomy": "workspace:*",
"@faunosteo/domain": "workspace:*",
"@faunosteo/pdf": "workspace:*",
"@faunosteo/supabase": "workspace:*",
"motion": "^11.11.17",
"pdf-lib": "^1.17.1",
+23 -11
View File
@@ -18,14 +18,15 @@
import { readFileSync, readdirSync, statSync } from 'node:fs'
import { basename, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { PDFDocument } from 'pdf-lib'
import {
readReportDocument,
REPORT_VERSION,
readArchiveDocument,
UnsupportedReportVersionError,
} from '@faunosteo/domain'
import { readAttachedDocument } from '../src/pdf/attachment'
import { MAX_PDF_BYTES } from '../src/pdf/import'
import {
ArchiveReadError,
MAX_PDF_BYTES,
readAttachedDocument,
} from '@faunosteo/pdf'
import { parseBundledSheet } from '../src/sheets/provider'
import { buildSheetIndex, type SheetIndex } from '../src/services/sheetIndex'
import {
@@ -57,6 +58,7 @@ function loadSheet(): SheetIndex {
document: json('document.json'),
migrationMap: json('report-migration-map.json'),
assets: {},
assetHashes: {},
}),
)
}
@@ -84,25 +86,35 @@ async function compareFile(
if (!st.isFile()) throw new Error('not a regular file')
if (st.size > MAX_PDF_BYTES) throw new Error('file too large')
const bytes = new Uint8Array(readFileSync(path))
const pdf = await PDFDocument.load(bytes, { ignoreEncryption: true })
const raw = await readAttachedDocument(pdf)
const version = (raw as { version: number }).version
// Byte-scan reader (BLK-009): the PDF object graph is never parsed here.
const raw = await readAttachedDocument(bytes)
try {
const outcome = readReportDocument(raw, sheet.sheet.migrationMap)
return compareReport(raw, outcome, version !== REPORT_VERSION, sheet, args)
const outcome = readArchiveDocument(raw, sheet.sheet.migrationMap)
return compareReport(raw, outcome, sheet, args)
} catch (err) {
if (err instanceof UnsupportedReportVersionError) {
throw new Error(`report version ${version} cannot be read`)
// The version is a number or null: nothing of the attachment is echoed.
throw new Error(`report version ${err.foundVersion} cannot be read`)
}
throw err
}
}
/** The engine's typed read failures, worded without echoing the file. */
const READ_FAILURES: Record<ArchiveReadError['kind'], string> = {
invalid_pdf: 'not a readable PDF',
no_attachment: 'no Faunosteo attachment found',
attachment_stripped:
'attachment stripped (the PDF is stamped as a Faunosteo archive)',
incompatible_version: 'report version cannot be read',
}
/** A missing or unreadable file is a failed entry, not a crash. */
function failureReason(err: unknown): string {
const code = (err as NodeJS.ErrnoException | undefined)?.code
if (code === 'ENOENT') return 'file not found'
if (code === 'EACCES') return 'file not readable'
if (err instanceof ArchiveReadError) return READ_FAILURES[err.kind]
// JSON.parse messages echo a fragment of the attachment.
if (err instanceof SyntaxError) return 'attachment is not valid JSON'
return err instanceof Error ? err.message : String(err)
+31 -10
View File
@@ -1,9 +1,9 @@
import {
ReportV2Schema,
findingPathKey,
type ArchiveReadOutcome,
type Finding,
type FindingV2,
type MigrationOutcome,
type ObservationZoneV2,
type Report,
type ReportZone,
@@ -15,7 +15,8 @@ import { pickLabel, type SheetIndex } from '../../src/services/sheetIndex'
* Pure comparison of a report document found in a PDF with its v3 reading:
* a v2 archive is shown legacy id → canonical id line by line, a v3 report
* is checked against the bundled sheet. Every item the sheet cannot place is
* marked `!! UNRESOLVED` with the reason, nothing is summarised away.
* marked `!! UNRESOLVED` with the reason, nothing is summarised away. A Step 6
* envelope adds one header line saying whether its snapshot was kept.
*/
export const UNRESOLVED = '!! UNRESOLVED'
@@ -186,13 +187,22 @@ function observationLines(
return lines
}
/** The report document inside the attachment: the envelope's, or the bare one. */
function reportDataOf(raw: unknown): unknown {
const isEnvelope =
typeof raw === 'object' &&
raw !== null &&
typeof (raw as { envelopeVersion?: unknown }).envelopeVersion === 'number'
return isEnvelope ? (raw as { report: unknown }).report : raw
}
function migratedObservationLines(
raw: unknown,
report: Report,
sheet: SheetIndex,
opts: CompareOptions,
): string[][] {
const v2 = ReportV2Schema.parse(raw)
const v2 = ReportV2Schema.parse(reportDataOf(raw))
return v2.observations.map((legacy, i) => {
const out = report.observations[i]!
const severity = legacy.severity
@@ -230,12 +240,22 @@ function countsOf(report: Report): Counts {
}
}
/** The envelope line: present only when the attachment was an archive. */
function archiveLine(outcome: ArchiveReadOutcome): string[] {
if (outcome.archive) return ['archive v1 (snapshot kept)']
if (outcome.snapshotRejected) {
return [`archive v1 (snapshot rejected: ${esc(outcome.snapshotRejected)})`]
}
return []
}
function headerLines(
source: 'v2' | 'v3',
report: Report,
outcome: ArchiveReadOutcome,
sheet: SheetIndex,
opts: CompareOptions,
): string[] {
const { report } = outcome
const ref = sheet.sheet.ref
const sameSheet =
report.sheet.sheetId === ref.sheetId &&
@@ -246,6 +266,7 @@ function headerLines(
const c = countsOf(report)
const lines = [
source === 'v2' ? 'v2 → v3 (migrated)' : 'v3 (read as is)',
...archiveLine(outcome),
sheetLine,
`id ${esc(report.id)} · date ${esc(report.date)} · ${c.observations} observations · ${c.zones} zones (${c.unresolvedZones} unresolved) · ${c.findings} findings (${c.unresolvedFindings} unresolved)`,
]
@@ -273,17 +294,17 @@ function footerLines(report: Report, full: boolean): string[] {
}
/**
* `raw` is the attachment as found in the PDF, `outcome` its v3 reading
* (`readReportDocument`); `migrated` tells which vocabulary the lines use.
* `raw` is the attachment as found in the PDF (bare report or envelope),
* `outcome` its layered reading (`readArchiveDocument`); `outcome.migrated`
* tells which vocabulary the lines use.
*/
export function compareReport(
raw: unknown,
outcome: MigrationOutcome,
migrated: boolean,
outcome: ArchiveReadOutcome,
sheet: SheetIndex,
opts: CompareOptions,
): Comparison {
const { report } = outcome
const { report, migrated } = outcome
const source = migrated ? 'v2' : 'v3'
const v3Lines = report.observations.map((o) =>
observationLines(o, sheet, opts),
@@ -295,7 +316,7 @@ export function compareReport(
]
return {
source,
header: headerLines(source, report, sheet, opts),
header: headerLines(source, outcome, sheet, opts),
observations: migrated
? migratedObservationLines(raw, report, sheet, opts)
: v3Lines,
+35 -6
View File
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
import DetailModal from '@/components/canvas/DetailModal'
@@ -28,11 +28,23 @@ import {
} from '@/services/zoneInteraction'
import type { ViewStates } from '@/anatomy/drawing'
import { exportReportToPdf } from '@/pdf/export'
import type { ExportWarning } from '@faunosteo/pdf'
import type { RebaseOutcome } from '@faunosteo/domain'
import { useT } from '@/i18n/useT'
import { DEFAULT_SPECIES_ID } from './NewReportRoute'
const DISCLAIMER_FLAG = 'osteo:disclaimer-shown'
/** What the PDF lacks, named for the practitioner: logo slots and view ids. */
function missingItemsOf(warnings: readonly ExportWarning[]): string[] {
return warnings.map((w) => (w.kind === 'logo_failed' ? w.slot : w.viewId))
}
/** Zones and findings a draft rebase could not find on the loaded sheet. */
function unresolvedCountOf(outcome: RebaseOutcome): number {
return outcome.unresolvedZones + outcome.unresolvedFindings
}
/** Editor on the reference sheet: wires the canvas, the pickers and the store. */
export default function EditorRoute() {
const navigate = useNavigate()
@@ -49,19 +61,28 @@ export default function EditorRoute() {
const [disclaimer, setDisclaimer] = useState<string | null>(null)
const [exporting, setExporting] = useState(false)
const [editDraft, setEditDraft] = useState<Identity | null>(null)
// One alert per restore, even if the effect runs again before the re-render.
const rebaseAlerted = useRef(false)
useEffect(() => {
window.scrollTo({ top: 0, left: 0, behavior: 'auto' })
}, [])
// No report in memory: restore the per-tab draft once the sheet is known.
// A draft rebased on another sheet is announced with its unresolved count.
useEffect(() => {
if (report) return
if (sheet.status === 'ready')
store.restoreDraft(sheet.index.sheet.migrationMap)
if (sheet.status === 'ready') {
const outcome = store.restoreDraft(sheet.index)
if (outcome?.rebased && !rebaseAlerted.current) {
rebaseAlerted.current = true
const count = String(unresolvedCountOf(outcome))
window.alert(t('editor.draft_rebased').replace('{count}', count))
}
}
if (sheet.status !== 'loading' && !useReportStore.getState().report)
navigate('/')
}, [report, sheet, store, navigate])
}, [report, sheet, store, navigate, t])
useEffect(() => {
if (sheet.status !== 'ready' || typeof sessionStorage === 'undefined')
@@ -145,14 +166,22 @@ export default function EditorRoute() {
if (!report) return
setExporting(true)
try {
const bytes = await exportReportToPdf(report, index, { locale })
const blob = new Blob([bytes as BlobPart], { type: 'application/pdf' })
const { pdf, warnings } = await exportReportToPdf(report, index, {
locale,
})
const blob = new Blob([pdf as BlobPart], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `bilan-${report.animal.name}-${report.date}.pdf`
a.click()
URL.revokeObjectURL(url)
const missing = missingItemsOf(warnings)
if (missing.length) {
window.alert(
t('editor.export_warnings').replace('{items}', missing.join(', ')),
)
}
} catch (err) {
console.error('PDF export failed', err)
window.alert(t('editor.export_failed'))
+114 -36
View File
@@ -1,64 +1,142 @@
import { useNavigate } from 'react-router-dom'
import { useRef, useState } from 'react'
import {
rebaseReportOnSheet,
type ArchiveReadOutcome,
type RebaseOutcome,
} from '@faunosteo/domain'
import AppHeader from '@/components/brand/AppHeader'
import Button from '@/components/ui/Button'
import Card from '@/components/ui/Card'
import { importReportFromPdf, ImportError } from '@/pdf/import'
import { importReportFromPdf, ImportError, MAX_PDF_BYTES } from '@/pdf/import'
import { useReportStore } from '@/state/reportStore'
import { useSheet } from '@/sheets/useSheet'
import type { SheetIndex } from '@/services/sheetIndex'
import { DEFAULT_SPECIES_ID } from './NewReportRoute'
import { useT } from '@/i18n/useT'
type Translate = ReturnType<typeof useT>
/**
* The detail lines of the import alert (STEP6 §16), in a fixed order: a
* lossy v2 migration, the archive kept, the snapshot dropped with its
* reason, the rebase onto the current sheet. Empty when nothing applies.
*/
function importDetailLines(
outcome: ArchiveReadOutcome,
rebase: RebaseOutcome,
t: Translate,
): string[] {
const lines: string[] = []
const lost = outcome.unresolvedFindings + outcome.unresolvedZones
if (outcome.migrated && lost > 0) {
lines.push(t('home.import.migrated').replace('{count}', String(lost)))
}
if (outcome.archive) lines.push(t('home.import.archive_ok'))
if (outcome.snapshotRejected) {
lines.push(
t('home.import.snapshot_rejected').replace(
'{reason}',
t(`home.import.snapshot_reason.${outcome.snapshotRejected}`),
),
)
}
if (rebase.rebased) {
const count = rebase.unresolvedZones + rebase.unresolvedFindings
lines.push(t('home.import.rebased').replace('{count}', String(count)))
}
return lines
}
/**
* Degraded recovery: something the practitioner must check. A rejected
* snapshot, a migration or a rebase that lost items. A rebase that resolved
* everything is a complete restoration on a different sheet.
*/
function isDegradedImport(
outcome: ArchiveReadOutcome,
rebase: RebaseOutcome,
): boolean {
const lost = outcome.unresolvedFindings + outcome.unresolvedZones
const rebaseLost = rebase.unresolvedZones + rebase.unresolvedFindings
return (
outcome.snapshotRejected !== undefined ||
(outcome.migrated && lost > 0) ||
(rebase.rebased && rebaseLost > 0)
)
}
/**
* The one alert shown after a successful import: a headline that says
* whether the restoration is complete or partial, then the detail lines.
* Empty (no alert) when there is nothing to say: a bare v3 on the same sheet.
*/
function importMessages(
outcome: ArchiveReadOutcome,
rebase: RebaseOutcome,
t: Translate,
): string[] {
const details = importDetailLines(outcome, rebase, t)
if (details.length === 0) return []
const headline = isDegradedImport(outcome, rebase)
? t('home.import.degraded')
: t('home.import.complete')
return [headline, ...details]
}
/** The error line under the import button, by ImportError kind. */
function importErrorMessage(err: unknown, t: Translate): string {
if (!(err instanceof ImportError)) return t('home.import.error_generic')
switch (err.kind) {
case 'incompatible_version':
return t('home.import.error_incompatible_version').replace(
'{version}',
String(err.foundVersion ?? '?'),
)
case 'invalid_pdf':
return t('home.import.error_invalid_pdf')
case 'attachment_stripped':
return t('home.import.error_attachment_stripped')
case 'no_attachment':
return t('home.import.error_no_attachment')
}
}
export default function HomeRoute() {
const navigate = useNavigate()
const fileRef = useRef<HTMLInputElement | null>(null)
const hydrate = useReportStore((s) => s.hydrateReport)
const hydrateImport = useReportStore((s) => s.hydrateImport)
const sheet = useSheet(DEFAULT_SPECIES_ID)
const [error, setError] = useState<string | null>(null)
const [busy, setBusy] = useState(false)
const t = useT()
/** Read, rebase onto the loaded sheet, open; the editor always works on that sheet. */
async function importFile(file: File, index: SheetIndex) {
// The engine refuses the same size; checking first keeps a huge file out of memory.
if (file.size > MAX_PDF_BYTES) throw new ImportError('invalid_pdf')
const bytes = new Uint8Array(await file.arrayBuffer())
const outcome = await importReportFromPdf(bytes, index.sheet.migrationMap)
const rebase = rebaseReportOnSheet(
outcome.report,
index,
outcome.archive?.sheetSnapshot ?? null,
)
hydrateImport({ report: rebase.report, archive: outcome.archive })
const lines = importMessages(outcome, rebase, t)
if (lines.length > 0) window.alert(lines.join('\n\n'))
navigate('/editor')
}
async function onPickFile(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0]
if (!file || sheet.status !== 'ready') return
setBusy(true)
setError(null)
try {
const bytes = new Uint8Array(await file.arrayBuffer())
const outcome = await importReportFromPdf(
bytes,
sheet.index.sheet.migrationMap,
)
if (
outcome.migrated &&
outcome.unresolvedFindings + outcome.unresolvedZones > 0
) {
window.alert(
t('home.import.migrated').replace(
'{count}',
String(outcome.unresolvedFindings + outcome.unresolvedZones),
),
)
}
hydrate(outcome.report)
navigate('/editor')
await importFile(file, sheet.index)
} catch (err) {
if (err instanceof ImportError) {
if (err.kind === 'incompatible_version') {
setError(
t('home.import.error_incompatible_version').replace(
'{version}',
String(err.foundVersion ?? '?'),
),
)
} else if (err.kind === 'invalid_pdf') {
setError(t('home.import.error_invalid_pdf'))
} else {
setError(t('home.import.error_no_attachment'))
}
} else {
setError(t('home.import.error_generic'))
}
setError(importErrorMessage(err, t))
} finally {
setBusy(false)
if (fileRef.current) fileRef.current.value = ''
+2 -1
View File
@@ -1,5 +1,6 @@
import { useConfig } from '@/app/providers/ConfigProvider'
import { useT } from '@/i18n/useT'
import pawsInHarmonyUrl from '@/assets/brand/paws-in-harmony.svg?url'
export default function Footer() {
const cfg = useConfig()
@@ -37,7 +38,7 @@ export default function Footer() {
className="text-[var(--color-accent)] hover:text-[var(--color-accent-strong)] transition-colors font-medium"
>
<img
src="/Paws_in_harmony.svg"
src={pawsInHarmonyUrl}
alt="Paws in Harmony"
className="h-6 w-auto inline-block align-middle"
/>
+22 -19
View File
@@ -30,8 +30,26 @@ export const en: Dict = {
'This PDF was not generated by Faunosteo (no data detected).',
'home.import.error_incompatible_version':
'This PDF uses format v{version}, which this version of the application cannot read (accepted formats: v2 and v3).',
'home.import.complete': 'Full restoration.',
'home.import.degraded':
'Partial recovery: check the items flagged below.',
'home.import.migrated':
'Report imported from an older format. Findings not found in the current sheet: {count} (kept with their labels).',
'home.import.archive_ok':
'Faunosteo archive imported: report and the original sheet snapshot kept.',
'home.import.snapshot_rejected':
'Report recovered, but the original sheet snapshot was rejected ({reason}): this archive cannot be reproduced as is.',
'home.import.snapshot_reason.unsupported_envelope':
'archive from a newer version',
'home.import.snapshot_reason.schema': 'invalid content',
'home.import.snapshot_reason.caps': 'size or complexity over the limits',
'home.import.snapshot_reason.integrity': 'inconsistent sheet',
'home.import.snapshot_reason.sheet_mismatch':
"sheet differs from the report's",
'home.import.rebased':
"Report opened on the current sheet, which differs from the archive's. Items not found: {count} (kept with their labels).",
'home.import.error_attachment_stripped':
'This Faunosteo PDF lost its embedded data (attachment removed by a viewer or an optimiser). Use the original file.',
'home.no_sheet.title': 'No anatomical sheet',
'home.no_sheet.description':
'This build of the application carries no anatomical sheet: no report can be created or imported.',
@@ -51,6 +69,10 @@ export const en: Dict = {
'editor.export': 'Export as PDF',
'editor.exporting': 'Generating…',
'editor.export_failed': 'PDF generation failed. Retry or contact support.',
'editor.export_warnings':
'PDF exported with missing elements: {items}. Check the browser console.',
'editor.draft_rebased':
'Draft restored on an anatomical sheet different from the one it was created on. Items not found: {count} (kept with their labels).',
'editor.edit_infos': 'Edit info',
'editor.edit_dialog_title': 'Edit information',
'editor.disclaimer_title': 'Legal scope of animal osteopathy',
@@ -150,25 +172,6 @@ export const en: Dict = {
'severity.moderate': 'moderate',
'severity.severe': 'severe',
'pdf.eyebrow.observation': 'OBSERVATION',
'pdf.eyebrow.synthesis': 'SYNTHESIS',
'pdf.title.conclusion': 'Conclusion',
'pdf.section.zones': 'ZONES',
'pdf.section.findings_prefix': 'FINDINGS — ',
'pdf.section.free_findings': 'FREE FINDINGS',
'pdf.section.severity': 'SEVERITY',
'pdf.section.comment': 'COMMENT',
'pdf.section.conclusion': 'CONCLUSION',
'pdf.section.recommendations': 'RECOMMENDATIONS',
'pdf.section.next_appointment': 'NEXT APPOINTMENT',
'pdf.view.general': 'GENERAL VIEW',
'pdf.view.detail_prefix': 'DETAIL VIEW — ',
'pdf.empty': '—',
'pdf.owner_prefix': 'Owner: ',
'pdf.siret_prefix': 'SIRET ',
'pdf.title.suffix.bilan': 'Osteo report — ',
'pdf.subject': 'Animal osteopathic report',
'lang.group_label': 'Language',
'lang.switch_to_fr': 'Passer en français',
'lang.switch_to_en': 'Switch to English',
+22 -20
View File
@@ -32,8 +32,26 @@ export const fr: Dict = {
"Ce PDF n'a pas été généré par Faunosteo (pas de données détectées).",
'home.import.error_incompatible_version':
"Ce PDF est au format v{version}, que cette version de l'application ne sait pas lire (formats acceptés : v2 et v3).",
'home.import.complete': 'Restauration complète.',
'home.import.degraded':
'Récupération partielle : vérifiez les éléments signalés.',
'home.import.migrated':
'Bilan importé depuis un ancien format. Constats non retrouvés dans la fiche actuelle : {count} (conservés avec leurs libellés).',
'home.import.archive_ok':
"Archive Faunosteo importée : bilan et instantané de la fiche d'origine conservés.",
'home.import.snapshot_rejected':
"Bilan récupéré, mais l'instantané de la fiche d'origine a été rejeté ({reason}) : cette archive ne pourra pas être reproduite telle quelle.",
'home.import.snapshot_reason.unsupported_envelope':
"archive d'une version plus récente",
'home.import.snapshot_reason.schema': 'contenu invalide',
'home.import.snapshot_reason.caps': 'taille ou complexité excessive',
'home.import.snapshot_reason.integrity': 'fiche incohérente',
'home.import.snapshot_reason.sheet_mismatch':
'fiche différente de celle du bilan',
'home.import.rebased':
"Bilan ouvert sur la fiche actuelle, différente de celle de l'archive. Éléments non retrouvés : {count} (conservés avec leurs libellés).",
'home.import.error_attachment_stripped':
"Ce PDF Faunosteo a perdu ses données embarquées (pièce jointe supprimée par un lecteur ou un optimiseur). Utilisez le fichier d'origine.",
'home.no_sheet.title': 'Aucune fiche anatomique',
'home.no_sheet.description':
"Cette version de l'application n'embarque aucune fiche anatomique : aucun bilan ne peut être créé ni importé.",
@@ -57,6 +75,10 @@ export const fr: Dict = {
'editor.exporting': 'Génération…',
'editor.export_failed':
'Échec de la génération du PDF. Réessayez ou contactez le support.',
'editor.export_warnings':
'PDF exporté avec des éléments manquants : {items}. Vérifiez la console du navigateur.',
'editor.draft_rebased':
'Brouillon restauré sur une fiche anatomique différente de celle où il a été créé. Éléments non retrouvés : {count} (conservés avec leurs libellés).',
'editor.edit_infos': 'Modifier les infos',
'editor.edit_dialog_title': 'Modifier les informations',
'editor.disclaimer_title': "Périmètre légal de l'ostéopathie animale",
@@ -165,26 +187,6 @@ export const fr: Dict = {
'severity.moderate': 'modérée',
'severity.severe': 'sévère',
// pdf
'pdf.eyebrow.observation': 'OBSERVATION',
'pdf.eyebrow.synthesis': 'SYNTHÈSE',
'pdf.title.conclusion': 'Conclusion',
'pdf.section.zones': 'ZONES',
'pdf.section.findings_prefix': 'CONSTATS — ',
'pdf.section.free_findings': 'CONSTATS LIBRES',
'pdf.section.severity': 'SÉVÉRITÉ',
'pdf.section.comment': 'COMMENTAIRE',
'pdf.section.conclusion': 'CONCLUSION',
'pdf.section.recommendations': 'RECOMMANDATIONS',
'pdf.section.next_appointment': 'PROCHAIN RENDEZ-VOUS',
'pdf.view.general': 'VUE GÉNÉRALE',
'pdf.view.detail_prefix': 'VUE DÉTAIL — ',
'pdf.empty': '—',
'pdf.owner_prefix': 'Propriétaire : ',
'pdf.siret_prefix': 'SIRET ',
'pdf.title.suffix.bilan': 'Bilan ostéo — ',
'pdf.subject': "Bilan d'ostéopathie animalière",
// language switcher
'lang.group_label': 'Langue',
'lang.switch_to_fr': 'Passer en français',
-200
View File
@@ -1,200 +0,0 @@
import { AFRelationship, type PDFDocument } from 'pdf-lib'
import {
readReportDocument,
REPORT_VERSION,
UnsupportedReportVersionError,
type MigrationOutcome,
type Report,
type ReportMigrationMap,
} from '@faunosteo/domain'
/**
* The report document travels inside the PDF as a native attachment.
* Written as v3; read back as v3, or as v2 migrated through the sheet's
* migration map (the practitioner's archive). Any other version is refused
* with the found version.
*/
const FILENAME = 'osteo-report.json'
export class IncompatibleReportVersionError extends Error {
constructor(public readonly foundVersion: number | null) {
super(`incompatible_version:${foundVersion ?? 'unknown'}`)
this.name = 'IncompatibleReportVersionError'
}
}
export async function attachReportJson(
pdfDoc: PDFDocument,
report: Report,
): Promise<void> {
const bytes = new TextEncoder().encode(JSON.stringify(report, null, 2))
await pdfDoc.attach(bytes, FILENAME, {
mimeType: 'application/json',
description: `Faunosteo state v${REPORT_VERSION}`,
creationDate: new Date(),
modificationDate: new Date(),
afRelationship: AFRelationship.Data,
})
}
export interface ExtractedReport extends MigrationOutcome {
/** True when the attachment was an older version lifted to v3. */
migrated: boolean
}
/**
* The raw report document carried by the PDF, of whatever version, before
* any migration: what the archive check tool shows next to the v3 result.
* Throws when the PDF carries no Faunosteo attachment or an oversized one.
*/
export async function readAttachedDocument(
pdfDoc: PDFDocument,
): Promise<unknown> {
const bytes = await attachmentBytes(pdfDoc)
if (bytes.byteLength > MAX_ATTACHMENT_BYTES) {
throw new Error('attachment too large')
}
const data: unknown = JSON.parse(new TextDecoder().decode(bytes))
// No numeric version at all: not a Faunosteo attachment (legacy message), not an old one.
if (versionOf(data) === null) {
throw new Error('attachment carries no report version')
}
return data
}
export async function extractReportJson(
pdfDoc: PDFDocument,
map: ReportMigrationMap,
): Promise<ExtractedReport> {
const data = await readAttachedDocument(pdfDoc)
try {
return {
...readReportDocument(data, map),
migrated: versionOf(data) !== REPORT_VERSION,
}
} catch (err) {
if (err instanceof UnsupportedReportVersionError) {
throw new IncompatibleReportVersionError(err.foundVersion)
}
throw err
}
}
async function attachmentBytes(pdfDoc: PDFDocument): Promise<Uint8Array> {
const maybeApi = pdfDoc as unknown as {
getAttachments?: () => Array<{ name: string; data: Uint8Array }>
}
if (typeof maybeApi.getAttachments === 'function') {
const list = maybeApi.getAttachments()
if (list && list.length) {
const hit =
list.find(
(a) => a.name.startsWith('osteo-report') && a.name.endsWith('.json'),
) ?? list[0]
return hit.data
}
}
const fallback = await traverseForJsonAttachment(pdfDoc)
if (!fallback) throw new Error('No osteo-report attachment found')
return fallback
}
/** Hard ceiling on an attachment (inflated or not): a report is a few hundred KB at most. */
const MAX_ATTACHMENT_BYTES = 16 * 1024 * 1024
function versionOf(data: unknown): number | null {
if (data === null || typeof data !== 'object') return null
const v = (data as { version?: unknown }).version
return typeof v === 'number' ? v : null
}
interface RawObj {
contents?: Uint8Array
dict?: { entries?: () => Array<[unknown, unknown]> }
}
/**
* Hard ceiling on inflated attachment size. A valid report JSON is far
* smaller; anything bigger is a decompression bomb or corruption.
*/
const MAX_INFLATED_BYTES = MAX_ATTACHMENT_BYTES
/** Exported for tests. Returns null on failure or when the cap is exceeded. */
export async function inflateFlate(
bytes: Uint8Array,
): Promise<Uint8Array | null> {
if (typeof DecompressionStream === 'undefined') return null
try {
const stream = new Blob([bytes as BlobPart])
.stream()
.pipeThrough(new DecompressionStream('deflate'))
const reader = stream.getReader()
const chunks: Uint8Array[] = []
let total = 0
for (;;) {
const { done, value } = await reader.read()
if (done) break
total += value.byteLength
if (total > MAX_INFLATED_BYTES) {
await reader.cancel()
return null
}
chunks.push(value)
}
const out = new Uint8Array(total)
let offset = 0
for (const c of chunks) {
out.set(c, offset)
offset += c.byteLength
}
return out
} catch {
return null
}
}
function dictHasFlateFilter(entries: Array<[unknown, unknown]>): boolean {
for (const [k, v] of entries) {
if (String(k).includes('Filter') && String(v).includes('FlateDecode'))
return true
}
return false
}
async function traverseForJsonAttachment(
pdfDoc: PDFDocument,
): Promise<Uint8Array | null> {
const ctx = (
pdfDoc as unknown as {
context: { enumerateIndirectObjects(): Array<[unknown, RawObj]> }
}
).context
for (const [, obj] of ctx.enumerateIndirectObjects()) {
if (!obj || typeof obj !== 'object') continue
if (!(obj.contents instanceof Uint8Array)) continue
const entries = obj.dict?.entries?.() ?? []
let isEmbeddedFile = false
let isJsonSubtype = false
for (const [k, v] of entries) {
const ks = String(k)
const vs = String(v)
if (ks.includes('Type') && vs.includes('EmbeddedFile'))
isEmbeddedFile = true
// PDF name syntax escapes '/' as '#2F': /application#2Fjson
if (
ks.includes('Subtype') &&
(vs.includes('application/json') || vs.includes('application#2Fjson'))
) {
isJsonSubtype = true
}
}
if (!isEmbeddedFile && !isJsonSubtype) continue
if (dictHasFlateFilter(entries)) {
const inflated = await inflateFlate(obj.contents)
if (inflated) return inflated
}
return obj.contents
}
return null
}
+44
View File
@@ -0,0 +1,44 @@
import type { Branding, ImageAsset } from '@faunosteo/domain'
import headerLogoDataUrl from '@/assets/brand/faunosteo-logo-horizontal-512.png?inline'
import footerLogoDataUrl from '@/assets/brand/faunosteo-horizontal-com-512.png?inline'
import poweredByLogoDataUrl from '@/assets/brand/zenquality-logo-fr.png?inline'
import partnerLogoSvg from '@/assets/brand/paws-in-harmony.svg?raw'
/**
* The visual identity the export embeds (STEP6 §14 "Branding in the app"):
* the four logo files bundled with the application (`src/assets/brand`), so
* an export needs no network and no deployed file, plus the credit URLs. The
* result travels inside the archive, so a re-export never needs them again.
*/
// shortcut: the site URL and the credit constants belong to the runtime
// config (ConfigProvider); they live here until AppConfig carries them.
const SITE_URL = 'https://faunosteo.com'
const POWERED_BY = {
url: 'https://zenquality.fr',
fallbackText: 'zenquality.fr',
}
const PARTNER = {
url: 'https://www.instagram.com/paws.iin.harmony',
fallbackText: '@paws.iin.harmony',
}
const PNG_DATA_URL_PREFIX = 'data:image/png;base64,'
/** A `?inline` PNG import is a base64 data URL; the engine wants the base64 alone. */
function pngAsset(dataUrl: string): ImageAsset {
if (!dataUrl.startsWith(PNG_DATA_URL_PREFIX)) {
throw new Error('bundled logo is not a base64 PNG data URL')
}
return { kind: 'png', base64: dataUrl.slice(PNG_DATA_URL_PREFIX.length) }
}
export async function loadBranding(): Promise<Branding> {
return {
siteUrl: SITE_URL,
headerLogo: pngAsset(headerLogoDataUrl),
footerLogo: pngAsset(footerLogoDataUrl),
poweredBy: { logo: pngAsset(poweredByLogoDataUrl), ...POWERED_BY },
partner: { logo: { kind: 'svg', svg: partnerLogoSvg }, ...PARTNER },
}
}
+100
View File
@@ -0,0 +1,100 @@
import type { Rasterizer } from '@faunosteo/pdf'
/**
* The browser side of the engine's rasterizer adapter: the engine has fixed
* the pixel size, this module only stamps it on the SVG root and lets the
* browser draw the SVG through an Image / canvas pair, which renders exactly
* what the practitioner sees in the inline anatomy canvas.
*/
const SVG_NS = 'http://www.w3.org/2000/svg'
const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]
function startsWithPngSignature(bytes: Uint8Array): boolean {
if (bytes.length < PNG_SIGNATURE.length) return false
return PNG_SIGNATURE.every((byte, i) => bytes[i] === byte)
}
/** The root carries the namespace and the engine's size; nothing else changes. */
function sizedSvg(svg: string, widthPx: number, heightPx: number): string {
const root = new DOMParser().parseFromString(
svg,
'image/svg+xml',
).documentElement
if (root.namespaceURI !== SVG_NS) root.setAttribute('xmlns', SVG_NS)
root.setAttribute('width', String(widthPx))
root.setAttribute('height', String(heightPx))
return new XMLSerializer().serializeToString(root)
}
function loadImage(svg: string): Promise<HTMLImageElement> {
const blob = new Blob([svg], { type: 'image/svg+xml;charset=utf-8' })
const url = URL.createObjectURL(blob)
const img = new Image()
img.decoding = 'sync'
img.crossOrigin = 'anonymous'
return new Promise<HTMLImageElement>((resolve, reject) => {
img.onload = () => resolve(img)
img.onerror = () =>
reject(new Error('Browser failed to render the SVG into an Image'))
img.src = url
}).finally(() => URL.revokeObjectURL(url))
}
function drawOnWhiteCanvas(
img: HTMLImageElement,
widthPx: number,
heightPx: number,
): HTMLCanvasElement {
const canvas = document.createElement('canvas')
canvas.width = widthPx
canvas.height = heightPx
const ctx = canvas.getContext('2d')
if (!ctx) throw new Error('Canvas 2D context unavailable')
ctx.fillStyle = '#ffffff'
ctx.fillRect(0, 0, widthPx, heightPx)
ctx.drawImage(img, 0, 0, widthPx, heightPx)
return canvas
}
function canvasBlob(canvas: HTMLCanvasElement): Promise<Blob | null> {
return new Promise((resolve) => canvas.toBlob(resolve, 'image/png'))
}
/** Fallback when toBlob yields nothing: decode the data URL by hand. */
function pngFromDataUrl(canvas: HTMLCanvasElement): Uint8Array {
const dataUrl = canvas.toDataURL('image/png')
if (!dataUrl.startsWith('data:image/png')) {
throw new Error(
`canvas.toDataURL produced non-PNG payload: ${dataUrl.slice(0, 32)}`,
)
}
const comma = dataUrl.indexOf(',')
if (comma < 0) {
throw new Error('canvas.toDataURL returned a data URL without a payload')
}
const binary = atob(dataUrl.slice(comma + 1))
const bytes = new Uint8Array(binary.length)
for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i)
if (!startsWithPngSignature(bytes)) {
throw new Error('canvas.toDataURL produced bytes without a PNG signature')
}
return bytes
}
async function canvasToPng(canvas: HTMLCanvasElement): Promise<Uint8Array> {
const blob = await canvasBlob(canvas)
if (blob) {
const bytes = new Uint8Array(await blob.arrayBuffer())
if (startsWithPngSignature(bytes)) return bytes
}
return pngFromDataUrl(canvas)
}
export const browserRasterizer: Rasterizer = async (
svg,
{ widthPx, heightPx },
) => {
const img = await loadImage(sizedSvg(svg, widthPx, heightPx))
return canvasToPng(drawOnWhiteCanvas(img, widthPx, heightPx))
}
+33 -84
View File
@@ -1,97 +1,46 @@
import { PDFDocument } from 'pdf-lib'
import type { Report } from '@faunosteo/domain'
import type { Locale } from '@/i18n/types'
import { getDict } from '@/i18n'
import type { SheetIndex } from '@/services/sheetIndex'
import { embedFonts } from './fonts'
import { addObservationPage } from './render/observationPage'
import { addConclusionPage } from './render/conclusionPage'
import { attachReportJson } from './attachment'
import { drawFooter } from './render/footer'
import { buildSheetSnapshot, type Report } from '@faunosteo/domain'
import {
loadFaunosteoLogo,
loadFaunosteoComLogo,
loadZenqualityLogo,
} from './render/logo'
import { rasterizeSvg } from './render/svgToPng'
defaultPdfLabels,
exportReportArchive,
type ExportWarning,
} from '@faunosteo/pdf'
import type { Locale } from '@/i18n/types'
import type { SheetIndex } from '@/services/sheetIndex'
import { loadBranding } from './branding'
import { browserRasterizer } from './browserRasterizer'
export interface PdfExportOptions {
locale: Locale
}
export interface PdfExportResult {
pdf: Uint8Array
/** Non-fatal engine warnings: a logo or a view that failed to embed. */
warnings: ExportWarning[]
}
/**
* Exports a report to PDF from the in-memory document and the loaded sheet:
* labels and drawings come from the sheet, nothing is fetched except the
* partner logos. The v3 document is attached for re-import.
* Exports the report as an archive PDF through the engine: the loaded sheet
* becomes the snapshot the pages are drawn from and the attachment carries,
* the branding comes from the bundled logos, the browser rasterises the
* views. Warnings are logged and returned for the caller to surface.
*/
export async function exportReportToPdf(
report: Report,
sheet: SheetIndex,
index: SheetIndex,
opts: PdfExportOptions,
): Promise<Uint8Array> {
const { locale } = opts
const dict = getDict(locale)
const pdfDoc = await PDFDocument.create()
pdfDoc.setTitle(`${dict['pdf.title.suffix.bilan']}${report.animal.name}`)
pdfDoc.setAuthor(report.practitioner.name)
pdfDoc.setSubject(dict['pdf.subject'])
pdfDoc.setCreationDate(new Date())
pdfDoc.setModificationDate(new Date())
const fonts = await embedFonts(pdfDoc)
let headerLogoPdf = null
let footerLogoPdf = null
let zqLogoPdfImage = null
let pawsLogoPdf = null
try {
headerLogoPdf = await pdfDoc.embedPng(await loadFaunosteoLogo())
} catch (err) {
console.warn('Faunosteo logo embed failed:', err)
}
try {
footerLogoPdf = await pdfDoc.embedPng(await loadFaunosteoComLogo())
} catch (err) {
console.warn('Faunosteo -com logo embed failed:', err)
}
try {
zqLogoPdfImage = await pdfDoc.embedPng(await loadZenqualityLogo())
} catch (err) {
console.warn('ZenQuality logo embed failed:', err)
}
try {
const resp = await fetch('/Paws_in_harmony.svg')
if (!resp.ok) throw new Error(`Paws logo fetch failed: HTTP ${resp.status}`)
pawsLogoPdf = await pdfDoc.embedPng(await rasterizeSvg(await resp.text()))
} catch (err) {
console.warn('Paws in Harmony logo embed failed:', err)
}
const headerAssets = { logoPng: headerLogoPdf }
for (let i = 0; i < report.observations.length; i += 1) {
await addObservationPage({
pdfDoc,
report,
observation: report.observations[i]!,
obsIndex: i,
fonts,
sheet,
locale,
headerAssets,
})
}
await addConclusionPage(pdfDoc, report, fonts, locale, headerAssets)
const pages = pdfDoc.getPages()
const footerAssets = {
logoPng: footerLogoPdf,
zqLogoPng: zqLogoPdfImage,
pawsLogoPng: pawsLogoPdf,
}
pages.forEach((page, idx) => {
drawFooter(page, fonts, idx + 1, pages.length, locale, footerAssets)
): Promise<PdfExportResult> {
const result = await exportReportArchive({
report,
sheet: buildSheetSnapshot(index.sheet, report),
branding: await loadBranding(),
labels: defaultPdfLabels,
locale: opts.locale,
rasterizer: browserRasterizer,
exportedAt: new Date(),
})
await attachReportJson(pdfDoc, report)
return pdfDoc.save()
for (const warning of result.warnings) {
console.warn('PDF export warning', warning)
}
return { pdf: result.pdf, warnings: result.warnings }
}
+17 -28
View File
@@ -1,15 +1,13 @@
import { PDFDocument } from 'pdf-lib'
import type { ReportMigrationMap } from '@faunosteo/domain'
import type { ArchiveReadOutcome, ReportMigrationMap } from '@faunosteo/domain'
import {
extractReportJson,
IncompatibleReportVersionError,
type ExtractedReport,
} from './attachment'
ArchiveReadError,
readReportArchive,
type ArchiveReadErrorKind,
} from '@faunosteo/pdf'
export type ImportErrorKind =
| 'invalid_pdf'
| 'incompatible_version'
| 'no_attachment'
export { MAX_PDF_BYTES } from '@faunosteo/pdf'
export type ImportErrorKind = ArchiveReadErrorKind
/**
* Localization-agnostic import error. Carries a kind discriminant + an
@@ -26,31 +24,22 @@ export class ImportError extends Error {
}
}
/** A Faunosteo PDF weighs a few hundred KB; anything larger is not one. */
export const MAX_PDF_BYTES = 50 * 1024 * 1024
/**
* Reads a Faunosteo PDF back into a report document (v3, or v2 migrated
* through the reference sheet's map). The outcome says whether a migration
* happened and how many zones or findings it could not place.
* Reads a Faunosteo PDF back through the engine: the report (v3 as is, v2
* migrated through the sheet's map) and, when the file is a Step 6 archive,
* the validated envelope or the reason its snapshot was dropped. Engine
* failures become ImportError kinds, one to one.
*/
export async function importReportFromPdf(
pdfBytes: Uint8Array,
map: ReportMigrationMap,
): Promise<ExtractedReport> {
if (pdfBytes.byteLength > MAX_PDF_BYTES) throw new ImportError('invalid_pdf')
let pdfDoc: PDFDocument
): Promise<ArchiveReadOutcome> {
try {
pdfDoc = await PDFDocument.load(pdfBytes, { ignoreEncryption: true })
} catch {
throw new ImportError('invalid_pdf')
}
try {
return await extractReportJson(pdfDoc, map)
return await readReportArchive(pdfBytes, map)
} catch (err) {
if (err instanceof IncompatibleReportVersionError) {
throw new ImportError('incompatible_version', err.foundVersion)
if (err instanceof ArchiveReadError) {
throw new ImportError(err.kind, err.foundVersion)
}
throw new ImportError('no_attachment')
throw err
}
}
-180
View File
@@ -1,180 +0,0 @@
import { rgb, type PDFPage, type PDFImage } from 'pdf-lib'
import type { EmbeddedFonts } from '@/pdf/fonts'
import type { Locale } from '@/i18n/types'
import { getDict } from '@/i18n'
import { addLinkAnnotation } from './linkAnnotation'
import { MARGIN_X, COLOR_MUTED } from './constants'
const FOOTER_BASE_Y = 20
const FONT_SIZE = 8
export interface FooterAssets {
logoPng: PDFImage | null
zqLogoPng: PDFImage | null
pawsLogoPng: PDFImage | null
}
export function drawFooter(
page: PDFPage,
fonts: EmbeddedFonts,
pageNumber: number,
totalPages: number,
locale: Locale,
assets: FooterAssets,
): void {
const dict = getDict(locale)
const { width } = page.getSize()
const accent = rgb(0.28, 0.56, 0.42)
const logoW = 80
const logoH = 30
const rowY = FOOTER_BASE_Y + 14
const separatorY = rowY + logoH + 6
page.drawLine({
start: { x: MARGIN_X, y: separatorY },
end: { x: width - MARGIN_X, y: separatorY },
thickness: 0.5,
color: rgb(0.85, 0.83, 0.8),
})
if (assets.logoPng) {
page.drawImage(assets.logoPng, {
x: MARGIN_X,
y: rowY,
width: logoW,
height: logoH,
})
addLinkAnnotation(page, {
x: MARGIN_X,
y: rowY,
width: logoW,
height: logoH,
url: 'https://faunosteo.com',
})
}
const poweredLabel = `${dict['footer.powered_by']} `
const poweredLabelW = fonts.bodyRegular.widthOfTextAtSize(
poweredLabel,
FONT_SIZE,
)
const zqLogoW = 70
const zqLogoH = 16
const zqFallback = 'zenquality.fr'
const zqFallbackW = fonts.bodyRegular.widthOfTextAtSize(zqFallback, FONT_SIZE)
const poweredBlockW = assets.zqLogoPng
? poweredLabelW + zqLogoW
: poweredLabelW + zqFallbackW
const poweredX = (width - poweredBlockW) / 2
const textBaseY = rowY + 6
page.drawText(poweredLabel, {
x: poweredX,
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: COLOR_MUTED,
})
const zqX = poweredX + poweredLabelW
if (assets.zqLogoPng) {
page.drawImage(assets.zqLogoPng, {
x: zqX,
y: rowY + 2,
width: zqLogoW,
height: zqLogoH,
})
addLinkAnnotation(page, {
x: zqX,
y: rowY + 2,
width: zqLogoW,
height: zqLogoH,
url: 'https://zenquality.fr',
})
} else {
page.drawText(zqFallback, {
x: zqX,
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: accent,
})
addLinkAnnotation(page, {
x: zqX,
y: textBaseY - 2,
width: zqFallbackW,
height: FONT_SIZE + 4,
url: 'https://zenquality.fr',
})
}
const partnerLabel = `${dict['footer.in_partnership']} `
const partnerLabelW = fonts.bodyRegular.widthOfTextAtSize(
partnerLabel,
FONT_SIZE,
)
const partnerUrl = 'https://www.instagram.com/paws.iin.harmony'
if (assets.pawsLogoPng) {
const pawsLogoH = 16
const pawsLogoW =
pawsLogoH * (assets.pawsLogoPng.width / assets.pawsLogoPng.height)
const partnerX = width - MARGIN_X - partnerLabelW - pawsLogoW
page.drawText(partnerLabel, {
x: partnerX,
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: COLOR_MUTED,
})
const pawsX = partnerX + partnerLabelW
page.drawImage(assets.pawsLogoPng, {
x: pawsX,
y: rowY + 2,
width: pawsLogoW,
height: pawsLogoH,
})
addLinkAnnotation(page, {
x: pawsX,
y: rowY + 2,
width: pawsLogoW,
height: pawsLogoH,
url: partnerUrl,
})
} else {
const handle = '@paws.iin.harmony'
const handleW = fonts.bodyRegular.widthOfTextAtSize(handle, FONT_SIZE)
const partnerX = width - MARGIN_X - partnerLabelW - handleW
page.drawText(partnerLabel, {
x: partnerX,
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: COLOR_MUTED,
})
page.drawText(handle, {
x: partnerX + partnerLabelW,
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: accent,
})
addLinkAnnotation(page, {
x: partnerX + partnerLabelW,
y: textBaseY - 2,
width: handleW,
height: FONT_SIZE + 4,
url: partnerUrl,
})
}
const pageText = `${pageNumber} / ${totalPages}`
const pageW = fonts.bodyRegular.widthOfTextAtSize(pageText, FONT_SIZE)
page.drawText(pageText, {
x: (width - pageW) / 2,
y: FOOTER_BASE_Y + 2,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: COLOR_MUTED,
})
}
-100
View File
@@ -1,100 +0,0 @@
import type { PDFPage, PDFImage } from 'pdf-lib'
import type { EmbeddedFonts } from '@/pdf/fonts'
import type { Report } from '@faunosteo/domain'
import type { Locale } from '@/i18n/types'
import { getDict } from '@/i18n'
import { formatDate } from '@/lib/dates'
import { addLinkAnnotation } from './linkAnnotation'
import { MARGIN_X, COLOR_INK, COLOR_MUTED } from './constants'
const TOP_Y = 800
const LOGO_WIDTH = 100
const LOGO_HEIGHT = 38
export interface HeaderAssets {
logoPng: PDFImage | null
}
export function drawHeader(
page: PDFPage,
report: Report,
fonts: EmbeddedFonts,
locale: Locale,
assets: HeaderAssets,
): void {
const dict = getDict(locale)
const { width } = page.getSize()
const y = TOP_Y
const left = [
report.practitioner.name,
report.practitioner.cabinet,
report.practitioner.contact,
report.practitioner.siret
? `${dict['pdf.siret_prefix']}${report.practitioner.siret}`
: undefined,
].filter(Boolean) as string[]
left.forEach((line, i) => {
page.drawText(line, {
x: MARGIN_X,
y: y - i * 12,
size: i === 0 ? 11 : 9,
font: i === 0 ? fonts.bodyBold : fonts.bodyRegular,
color: i === 0 ? COLOR_INK : COLOR_MUTED,
})
})
if (assets.logoPng) {
const logoX = (width - LOGO_WIDTH) / 2
const logoY = y - LOGO_HEIGHT + 10
page.drawImage(assets.logoPng, {
x: logoX,
y: logoY,
width: LOGO_WIDTH,
height: LOGO_HEIGHT,
})
addLinkAnnotation(page, {
x: logoX,
y: logoY,
width: LOGO_WIDTH,
height: LOGO_HEIGHT,
url: 'https://faunosteo.com',
})
}
const animalLine = [
report.animal.name,
report.animal.breed ? `(${report.animal.breed})` : '',
report.animal.age ? `· ${report.animal.age}` : '',
]
.filter(Boolean)
.join(' ')
const right = [
animalLine,
`${dict['pdf.owner_prefix']}${report.owner.name}`,
formatDate(report.date, locale),
]
right.forEach((line, i) => {
const size = i === 0 ? 11 : 9
const font = i === 0 ? fonts.bodyBold : fonts.bodyRegular
const w = font.widthOfTextAtSize(line, size)
page.drawText(line, {
x: width - MARGIN_X - w,
y: y - i * 12,
size,
font,
color: i === 0 ? COLOR_INK : COLOR_MUTED,
})
})
const separatorY = y - Math.max(left.length * 12, LOGO_HEIGHT) - 8
page.drawLine({
start: { x: MARGIN_X, y: separatorY },
end: { x: width - MARGIN_X, y: separatorY },
thickness: 0.5,
color: COLOR_MUTED,
})
}
-35
View File
@@ -1,35 +0,0 @@
import { PDFName, PDFArray, PDFString, type PDFPage } from 'pdf-lib'
export interface LinkRect {
x: number
y: number
width: number
height: number
url: string
}
export function addLinkAnnotation(page: PDFPage, rect: LinkRect): void {
const context = page.doc.context
const actionDict = context.obj({
Type: 'Action',
S: 'URI',
URI: PDFString.of(rect.url),
})
const annotDict = context.obj({
Type: 'Annot',
Subtype: 'Link',
Rect: [rect.x, rect.y, rect.x + rect.width, rect.y + rect.height],
Border: [0, 0, 0],
A: actionDict,
})
const annots = page.node.lookup(PDFName.of('Annots'), PDFArray)
if (annots) {
annots.push(context.register(annotDict))
} else {
const arr = context.obj([context.register(annotDict)])
page.node.set(PDFName.of('Annots'), arr)
}
}
-21
View File
@@ -1,21 +0,0 @@
const FAUNOSTEO_LOGO = '/assets/faunosteo_logo_horizontal-512.png'
const FAUNOSTEO_COM_LOGO = '/assets/faunosteo-horizontal-com-512.png'
const ZENQUALITY_LOGO = '/brand/zenquality-logo-fr.png'
async function fetchPngBytes(path: string): Promise<Uint8Array> {
const resp = await fetch(path)
if (!resp.ok) throw new Error(`Logo fetch failed: HTTP ${resp.status}`)
return new Uint8Array(await resp.arrayBuffer())
}
export async function loadFaunosteoLogo(): Promise<Uint8Array> {
return fetchPngBytes(FAUNOSTEO_LOGO)
}
export async function loadFaunosteoComLogo(): Promise<Uint8Array> {
return fetchPngBytes(FAUNOSTEO_COM_LOGO)
}
export async function loadZenqualityLogo(): Promise<Uint8Array> {
return fetchPngBytes(ZENQUALITY_LOGO)
}
-627
View File
@@ -1,627 +0,0 @@
import {
rgb,
PageSizes,
type PDFDocument,
type PDFPage,
type PDFImage,
} from 'pdf-lib'
import type {
Finding,
Observation,
Report,
ReportZone,
Severity,
} from '@faunosteo/domain'
import type { EmbeddedFonts } from '@/pdf/fonts'
import type { Locale, Dict } from '@/i18n/types'
import { getDict } from '@/i18n'
import { pickLabel, type SheetIndex } from '@/services/sheetIndex'
import { buildViewSvg } from '@/anatomy/drawing'
import { drawHeader, type HeaderAssets } from './header'
import { rasterizeSvg } from './svgToPng'
import { wrapLines } from './text'
import {
MARGIN_X,
EYEBROW_Y_OFFSET,
TITLE_Y_OFFSET,
TITLE_RULE_OFFSET,
TITLE_RULE_WIDTH,
SECTION_LABEL_GAP,
COLOR_INK,
COLOR_MUTED,
COLOR_ACCENT,
} from './constants'
const MARGIN_BOTTOM = 48
const IMAGE_TOP_GAP = 32
const IMAGE_LABEL_GAP = 14
const IMAGE_BOTTOM_GAP = 14
const IMAGE_COL_GAP = 16
const IMAGE_ROW_GAP = 12
const IMAGE_MIN_CELL_H = 60
const TEXT_TOP_GAP = 10
const TEXT_LINE_HEIGHT = 13
const SECTION_BLOCK_GAP = 10
const COLOR_WHITE = rgb(1, 1, 1)
const SEVERITY_BG: Record<Severity, ReturnType<typeof rgb>> = {
mild: rgb(0.55, 0.65, 0.45),
moderate: rgb(0.85, 0.55, 0.18),
severe: rgb(0.78, 0.2, 0.2),
}
const SECTION_TEXT_SIZE = 10
const SEPARATOR_GLYPH = '•'
const SEPARATOR_SIZE = 14
const SEPARATOR_SIDE_GAP = 5
/** Width of the visible separator block including the empty space on each side. */
function separatorWidth(fonts: EmbeddedFonts): number {
return (
fonts.bodyBold.widthOfTextAtSize(SEPARATOR_GLYPH, SEPARATOR_SIZE) +
SEPARATOR_SIDE_GAP * 2
)
}
/** Counts the line breaks a list of items would consume when laid out on a maxWidth line. */
function countSegmentedLines(
items: string[],
fonts: EmbeddedFonts,
maxWidth: number,
): number {
if (items.length === 0) return 1
const sepW = separatorWidth(fonts)
let lines = 1
let x = 0
for (let i = 0; i < items.length; i += 1) {
const itemW = fonts.bodyRegular.widthOfTextAtSize(
items[i]!,
SECTION_TEXT_SIZE,
)
if (x + itemW > maxWidth && x > 0) {
lines += 1
x = 0
}
x += itemW
if (i < items.length - 1) {
if (x + sepW > maxWidth) {
lines += 1
x = 0
} else {
x += sepW
}
}
}
return lines
}
/**
* Renders a list of items separated by a visibly larger accent-coloured
* bullet. Returns the cursor y *below* the last line drawn.
*/
function drawSegmentedText(
page: PDFPage,
items: string[],
startX: number,
startY: number,
maxWidth: number,
fonts: EmbeddedFonts,
): number {
if (items.length === 0) return startY - TEXT_LINE_HEIGHT
const sepW = separatorWidth(fonts)
const sepBaselineOffset = (SEPARATOR_SIZE - SECTION_TEXT_SIZE) * 0.3
let x = startX
let y = startY
for (let i = 0; i < items.length; i += 1) {
const item = items[i]!
const itemW = fonts.bodyRegular.widthOfTextAtSize(item, SECTION_TEXT_SIZE)
if (x + itemW > startX + maxWidth && x > startX) {
x = startX
y -= TEXT_LINE_HEIGHT
}
page.drawText(item, {
x,
y,
size: SECTION_TEXT_SIZE,
font: fonts.bodyRegular,
color: COLOR_INK,
})
x += itemW
if (i < items.length - 1) {
if (x + sepW > startX + maxWidth) {
x = startX
y -= TEXT_LINE_HEIGHT
} else {
page.drawText(SEPARATOR_GLYPH, {
x: x + SEPARATOR_SIDE_GAP,
y: y - sepBaselineOffset,
size: SEPARATOR_SIZE,
font: fonts.bodyBold,
color: COLOR_ACCENT,
})
x += sepW
}
}
}
return y - TEXT_LINE_HEIGHT
}
const SVG_NS = 'http://www.w3.org/2000/svg'
const HALO_FILTER_ID = 'osteo-halo'
/**
* Adds a Gaussian-blur "halo" filter so the highlighted markers stay
* visible on the whole-animal view once rasterised at print scale.
*/
function ensureHaloFilter(root: SVGSVGElement): void {
const doc = root.ownerDocument
if (root.querySelector(`#${HALO_FILTER_ID}`)) return
let defs = root.querySelector('defs')
if (!defs) {
defs = doc.createElementNS(SVG_NS, 'defs')
root.insertBefore(defs, root.firstChild)
}
const filter = doc.createElementNS(SVG_NS, 'filter')
filter.setAttribute('id', HALO_FILTER_ID)
filter.setAttribute('x', '-100%')
filter.setAttribute('y', '-100%')
filter.setAttribute('width', '300%')
filter.setAttribute('height', '300%')
filter.setAttribute('filterUnits', 'userSpaceOnUse')
const wide = doc.createElementNS(SVG_NS, 'feGaussianBlur')
wide.setAttribute('in', 'SourceGraphic')
wide.setAttribute('stdDeviation', '18')
wide.setAttribute('result', 'haloWide')
filter.appendChild(wide)
const tight = doc.createElementNS(SVG_NS, 'feGaussianBlur')
tight.setAttribute('in', 'SourceGraphic')
tight.setAttribute('stdDeviation', '8')
tight.setAttribute('result', 'haloTight')
filter.appendChild(tight)
const merge = doc.createElementNS(SVG_NS, 'feMerge')
for (const input of [
'haloWide',
'haloWide',
'haloWide',
'haloTight',
'haloTight',
'SourceGraphic',
]) {
const n = doc.createElementNS(SVG_NS, 'feMergeNode')
n.setAttribute('in', input)
merge.appendChild(n)
}
filter.appendChild(merge)
defs.appendChild(filter)
}
/**
* The view rendered from the sheet with the observation's zones of that
* view highlighted (legacy picture: accent fill, halo on the main view,
* other markers hidden, no data attributes left).
*/
export function highlightedViewSvg(
sheet: SheetIndex,
viewId: string,
observation: Observation,
): string {
const selected = new Set(
observation.zones
.filter((z) => z.viewId === viewId)
.map((z) => z.annotationId),
)
const root = buildViewSvg(sheet, viewId, new Map())
const applyHalo = sheet.view(viewId)?.kind === 'main'
if (applyHalo) ensureHaloFilter(root)
root.querySelectorAll<Element>('[data-anno-id]').forEach((el) => {
if (selected.has(el.getAttribute('data-anno-id') ?? '')) {
el.setAttribute('fill', '#b85a3f')
el.setAttribute('fill-opacity', '0.85')
if (applyHalo) el.setAttribute('filter', `url(#${HALO_FILTER_ID})`)
} else {
el.setAttribute('display', 'none')
}
Array.from(el.attributes)
.filter((a) => a.name.startsWith('data-'))
.forEach((a) => el.removeAttribute(a.name))
})
return new XMLSerializer().serializeToString(root)
}
/** Parameters needed to render one observation page. */
export interface ObservationPageContext {
pdfDoc: PDFDocument
report: Report
observation: Observation
obsIndex: number
fonts: EmbeddedFonts
sheet: SheetIndex
locale: Locale
headerAssets: HeaderAssets
}
interface PageDrawContext {
page: PDFPage
fonts: EmbeddedFonts
width: number
}
interface RenderedImage {
label: string
img: PDFImage
aspect: number
}
interface ObservationSection {
label: string
value: string
}
function drawObservationTitleBlock(
ctx: PageDrawContext,
dict: Dict,
obsIndex: number,
severity: Severity | undefined,
): number {
const { page, fonts } = ctx
const { height } = page.getSize()
const eyebrowY = height - EYEBROW_Y_OFFSET
const titleY = height - TITLE_Y_OFFSET
const obsLabel = String(obsIndex + 1).padStart(2, '0')
page.drawText(dict['pdf.eyebrow.observation']!, {
x: MARGIN_X,
y: eyebrowY,
size: 9,
font: fonts.bodyBold,
color: COLOR_ACCENT,
})
page.drawText(obsLabel, {
x: MARGIN_X,
y: titleY,
size: 22,
font: fonts.headingRegular,
color: COLOR_INK,
})
if (severity) {
const numW = fonts.headingRegular.widthOfTextAtSize(obsLabel, 22)
const sevText = (dict[`severity.${severity}`] ?? severity).toUpperCase()
const sevSize = 9
const padX = 8
const padY = 4
const pillW = fonts.bodyBold.widthOfTextAtSize(sevText, sevSize) + padX * 2
const pillH = sevSize + padY * 2
const pillX = MARGIN_X + numW + 14
const pillY = titleY + 4
page.drawRectangle({
x: pillX,
y: pillY,
width: pillW,
height: pillH,
color: SEVERITY_BG[severity] ?? COLOR_MUTED,
})
page.drawText(sevText, {
x: pillX + padX,
y: pillY + padY,
size: sevSize,
font: fonts.bodyBold,
color: COLOR_WHITE,
})
}
page.drawLine({
start: { x: MARGIN_X, y: titleY - TITLE_RULE_OFFSET },
end: { x: MARGIN_X + TITLE_RULE_WIDTH, y: titleY - TITLE_RULE_OFFSET },
thickness: 2,
color: COLOR_ACCENT,
})
return titleY
}
/** Every view the observation touches, main first, each rasterised with its highlights. */
async function buildObservationImages(
pdfDoc: PDFDocument,
sheet: SheetIndex,
observation: Observation,
locale: Locale,
dict: Dict,
): Promise<RenderedImage[]> {
const viewIds = [...new Set(observation.zones.map((z) => z.viewId))]
.filter((id) => sheet.view(id))
.sort(
(a, b) =>
Number(b === sheet.mainView.id) - Number(a === sheet.mainView.id),
)
return Promise.all(
viewIds.map(async (viewId) => {
const view = sheet.view(viewId)!
const label =
view.kind === 'main'
? dict['pdf.view.general']!
: `${dict['pdf.view.detail_prefix']}${pickLabel(view.name, locale).toUpperCase()}`
const png = await rasterizeSvg(
highlightedViewSvg(sheet, viewId, observation),
)
const img = await pdfDoc.embedPng(png)
return {
label,
img,
aspect: img.width > 0 ? img.height / img.width : 0.6,
}
}),
)
}
function zoneText(z: ReportZone, sheet: SheetIndex, locale: Locale): string {
const annotation = sheet.annotation(z.annotationId)
if (annotation) return pickLabel(sheet.name(annotation), locale)
const snapshot =
locale === 'en'
? z.labelEnSnapshot || z.labelFrSnapshot
: z.labelFrSnapshot || z.labelEnSnapshot
return snapshot || z.annotationId
}
function describeObservationZones(
zones: ReportZone[],
sheet: SheetIndex,
locale: Locale,
dict: Dict,
): string {
return zones
.map((z) => {
const v = z.vertebrae?.length
? ` (${z.vertebrae.map((x) => `${x.region}${x.index}`).join(', ')})`
: ''
const side = z.side
? ` (${dict[z.side === 'left' ? 'lateral.left' : 'lateral.right']})`
: ''
return `${zoneText(z, sheet, locale)}${v}${side}`
})
.join(' · ')
}
function findingZoneName(
zoneId: string,
sheet: SheetIndex,
locale: Locale,
): string {
const zone = sheet.findingZone(zoneId)
return zone ? pickLabel(zone.name, locale) : zoneId
}
/** Groups findings by zone+side, one section per group; snapshots give the text. */
function buildFindingsSections(
findings: Finding[],
sheet: SheetIndex,
locale: Locale,
dict: Dict,
): ObservationSection[] {
const byZoneSide = new Map<string, Finding[]>()
for (const f of findings) {
const key = f.side ? `${f.findingZoneId}:${f.side}` : f.findingZoneId
byZoneSide.set(key, [...(byZoneSide.get(key) ?? []), f])
}
const sections: ObservationSection[] = []
for (const [key, group] of byZoneSide) {
const zoneId = key.split(':')[0]!
const side = group[0]?.side
let zoneName = findingZoneName(zoneId, sheet, locale)
if (side)
zoneName = `${zoneName} (${dict[side === 'left' ? 'lateral.left' : 'lateral.right']})`
const value = group
.map((f) => {
const lbl = locale === 'en' ? f.labelEnSnapshot : f.labelFrSnapshot
return f.requiresVetReferral ? `(!) ${lbl}` : lbl
})
.join(' · ')
sections.push({
label: `${dict['pdf.section.findings_prefix']}${zoneName.toUpperCase()}`,
value,
})
}
return sections
}
function buildObservationSections(
observation: Observation,
sheet: SheetIndex,
locale: Locale,
dict: Dict,
): ObservationSection[] {
const zonesText = describeObservationZones(
observation.zones,
sheet,
locale,
dict,
)
const sections: ObservationSection[] = [
{
label: dict['pdf.section.zones']!,
value: zonesText || dict['pdf.empty']!,
},
...buildFindingsSections(observation.findings, sheet, locale, dict),
]
if (observation.freeTextFindings.length) {
sections.push({
label: dict['pdf.section.free_findings']!,
value: observation.freeTextFindings.join(' · '),
})
}
if (observation.severity) {
sections.push({
label: dict['pdf.section.severity']!,
value: dict[`severity.${observation.severity}`] ?? observation.severity,
})
}
if (observation.comment.trim()) {
sections.push({
label: dict['pdf.section.comment']!,
value: observation.comment.trim(),
})
}
return sections
}
function estimateSectionsHeight(
sections: ObservationSection[],
fonts: EmbeddedFonts,
maxTextW: number,
): number {
let h = TEXT_TOP_GAP
for (const { value } of sections) {
const lineCount = value.includes(' · ')
? countSegmentedLines(value.split(' · '), fonts, maxTextW)
: wrapLines(value, fonts.bodyRegular, SECTION_TEXT_SIZE, maxTextW).length
h +=
SECTION_LABEL_GAP + 9 + lineCount * TEXT_LINE_HEIGHT + SECTION_BLOCK_GAP
}
return h
}
/** Lays out the (up to 2-column) image grid; returns the cursor y below it. */
function drawObservationImageGrid(
ctx: PageDrawContext,
rendered: RenderedImage[],
startY: number,
reservedBottom: number,
): number {
const { page, fonts, width } = ctx
let cursorY = startY
if (rendered.length === 0) return cursorY
const isSingle = rendered.length === 1
const cols = isSingle ? 1 : 2
const rows = Math.ceil(rendered.length / cols)
const fullCellW = (width - MARGIN_X * 2 - IMAGE_COL_GAP * (cols - 1)) / cols
const cellW = isSingle ? fullCellW / 2 : fullCellW
const singleOffsetX = isSingle ? (fullCellW - cellW) / 2 : 0
const availH = Math.max(IMAGE_MIN_CELL_H, cursorY - reservedBottom)
const rowBudget = Math.max(
IMAGE_MIN_CELL_H,
(availH - rows * IMAGE_LABEL_GAP - (rows - 1) * IMAGE_ROW_GAP) / rows,
)
for (let r = 0; r < rows; r += 1) {
const rowItems = rendered.slice(r * cols, r * cols + cols)
const cellHs = rowItems.map((it) => Math.min(cellW * it.aspect, rowBudget))
const rowH = Math.max(0, ...cellHs)
rowItems.forEach((it, c) => {
const x = MARGIN_X + singleOffsetX + c * (cellW + IMAGE_COL_GAP)
page.drawText(it.label, {
x,
y: cursorY,
size: 8,
font: fonts.bodyBold,
color: COLOR_ACCENT,
})
})
cursorY -= IMAGE_LABEL_GAP
rowItems.forEach((it, c) => {
const x = MARGIN_X + singleOffsetX + c * (cellW + IMAGE_COL_GAP)
page.drawImage(it.img, {
x,
y: cursorY - cellHs[c]!,
width: cellW,
height: cellHs[c]!,
})
})
cursorY -= rowH
if (r < rows - 1) cursorY -= IMAGE_ROW_GAP
}
cursorY -= IMAGE_BOTTOM_GAP
return cursorY
}
function drawObservationSections(
ctx: PageDrawContext,
sections: ObservationSection[],
startY: number,
maxTextW: number,
): number {
const { page, fonts } = ctx
let cursorY = startY
for (const { label, value } of sections) {
page.drawText(label, {
x: MARGIN_X,
y: cursorY,
size: 8,
font: fonts.bodyBold,
color: COLOR_ACCENT,
})
cursorY -= SECTION_LABEL_GAP + 9
if (value.includes(' · ')) {
cursorY = drawSegmentedText(
page,
value.split(' · '),
MARGIN_X,
cursorY,
maxTextW,
fonts,
)
} else {
for (const line of wrapLines(
value,
fonts.bodyRegular,
SECTION_TEXT_SIZE,
maxTextW,
)) {
page.drawText(line, {
x: MARGIN_X,
y: cursorY,
size: SECTION_TEXT_SIZE,
font: fonts.bodyRegular,
color: COLOR_INK,
})
cursorY -= TEXT_LINE_HEIGHT
}
}
cursorY -= SECTION_BLOCK_GAP
}
return cursorY
}
export async function addObservationPage(
ctx: ObservationPageContext,
): Promise<void> {
const {
pdfDoc,
report,
observation,
obsIndex,
fonts,
sheet,
locale,
headerAssets,
} = ctx
const dict = getDict(locale)
const page = pdfDoc.addPage(PageSizes.A4)
const { width } = page.getSize()
drawHeader(page, report, fonts, locale, headerAssets)
const drawCtx: PageDrawContext = { page, fonts, width }
const titleY = drawObservationTitleBlock(
drawCtx,
dict,
obsIndex,
observation.severity,
)
const rendered = await buildObservationImages(
pdfDoc,
sheet,
observation,
locale,
dict,
)
const maxTextW = width - MARGIN_X * 2
const sections = buildObservationSections(observation, sheet, locale, dict)
const reservedBottom =
MARGIN_BOTTOM +
estimateSectionsHeight(sections, fonts, maxTextW) +
IMAGE_BOTTOM_GAP
let cursorY = drawObservationImageGrid(
drawCtx,
rendered,
titleY - IMAGE_TOP_GAP,
reservedBottom,
)
cursorY -= TEXT_TOP_GAP
drawObservationSections(drawCtx, sections, cursorY, maxTextW)
}
-124
View File
@@ -1,124 +0,0 @@
const TARGET_WIDTH = 1200
const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]
function startsWithPngSignature(bytes: Uint8Array): boolean {
if (bytes.length < PNG_SIGNATURE.length) return false
for (let i = 0; i < PNG_SIGNATURE.length; i += 1) {
if (bytes[i] !== PNG_SIGNATURE[i]) return false
}
return true
}
function ensureSvgAttributes(
svgString: string,
widthPx: number,
heightPx: number,
): string {
const doc = new DOMParser().parseFromString(svgString, 'image/svg+xml')
const root = doc.documentElement
if (root.namespaceURI !== 'http://www.w3.org/2000/svg') {
// Some serializers strip xmlns; force the SVG namespace so
// browsers will rasterize the blob URL as an image.
root.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
}
if (!root.getAttribute('width')) root.setAttribute('width', String(widthPx))
if (!root.getAttribute('height'))
root.setAttribute('height', String(heightPx))
return new XMLSerializer().serializeToString(root)
}
function readViewBox(svgString: string): {
widthPx: number
heightPx: number
} {
const doc = new DOMParser().parseFromString(svgString, 'image/svg+xml')
const vb = (doc.documentElement.getAttribute('viewBox') ?? '0 0 1000 600')
.split(/\s+/)
.map(Number)
const ratio = vb[3] > 0 && vb[2] > 0 ? vb[3] / vb[2] : 0.6
const widthPx = Math.max(1, Math.round(TARGET_WIDTH))
const heightPx = Math.max(1, Math.round(ratio * widthPx))
return { widthPx, heightPx }
}
async function rasterizeWithImageElement(
svgString: string,
widthPx: number,
heightPx: number,
): Promise<HTMLCanvasElement> {
const normalized = ensureSvgAttributes(svgString, widthPx, heightPx)
const svgBlob = new Blob([normalized], {
type: 'image/svg+xml;charset=utf-8',
})
const url = URL.createObjectURL(svgBlob)
const img = new Image()
img.decoding = 'sync'
img.crossOrigin = 'anonymous'
try {
await new Promise<void>((resolve, reject) => {
img.onload = () => resolve()
img.onerror = () =>
reject(new Error('Browser failed to render the SVG into an Image'))
img.src = url
})
} finally {
// The Blob URL is single-use — release it once the Image has loaded
// (or failed).
URL.revokeObjectURL(url)
}
const canvas = document.createElement('canvas')
canvas.width = widthPx
canvas.height = heightPx
const ctx = canvas.getContext('2d')
if (!ctx) throw new Error('Canvas 2D context unavailable')
ctx.fillStyle = '#ffffff'
ctx.fillRect(0, 0, widthPx, heightPx)
ctx.drawImage(img, 0, 0, widthPx, heightPx)
return canvas
}
async function canvasToPngBytes(
canvas: HTMLCanvasElement,
): Promise<Uint8Array> {
const blob = await new Promise<Blob | null>((resolve) => {
canvas.toBlob((b) => resolve(b), 'image/png')
})
if (blob) {
const bytes = new Uint8Array(await blob.arrayBuffer())
if (startsWithPngSignature(bytes)) return bytes
}
const dataUrl = canvas.toDataURL('image/png')
if (!dataUrl.startsWith('data:image/png')) {
throw new Error(
`canvas.toDataURL produced non-PNG payload: ${dataUrl.slice(0, 32)}`,
)
}
const comma = dataUrl.indexOf(',')
if (comma < 0) {
throw new Error('canvas.toDataURL returned a data URL without a payload')
}
const binary = atob(dataUrl.slice(comma + 1))
const bytes = new Uint8Array(binary.length)
for (let i = 0; i < binary.length; i += 1) {
bytes[i] = binary.charCodeAt(i)
}
if (!startsWithPngSignature(bytes)) {
throw new Error('canvas.toDataURL produced bytes without a PNG signature')
}
return bytes
}
/**
* Rasterizes an SVG string to a PNG byte array using the browser's native
* SVG-to-Image pipeline. The browser parses + draws the SVG via an
* Image/Blob URL pair, which renders identically to what the user sees in
* the inline anatomy canvas.
*
* @param svgString Serialized SVG (must declare `xmlns`)
*/
export async function rasterizeSvg(svgString: string): Promise<Uint8Array> {
const { widthPx, heightPx } = readViewBox(svgString)
const canvas = await rasterizeWithImageElement(svgString, widthPx, heightPx)
return canvasToPngBytes(canvas)
}
-27
View File
@@ -1,27 +0,0 @@
import type { PDFFont } from 'pdf-lib'
/**
* Greedy word-wrap: splits `text` into lines whose rendered width at
* `size` points stays within `max` for the given font.
*/
export function wrapLines(
text: string,
font: PDFFont,
size: number,
max: number,
): string[] {
const words = text.split(/\s+/)
const lines: string[] = []
let line = ''
for (const w of words) {
const test = line ? `${line} ${w}` : w
if (font.widthOfTextAtSize(test, size) > max && line) {
lines.push(line)
line = w
} else {
line = test
}
}
if (line) lines.push(line)
return lines
}
+7 -109
View File
@@ -1,113 +1,11 @@
import type {
Annotation,
FindingCategory,
FindingNode,
FindingZone,
LocalizedText,
SheetView,
VertebralRegion,
} from '@faunosteo/domain'
import type { Locale } from '@/i18n/types'
import type { SheetIndex as DomainSheetIndex } from '@faunosteo/domain'
import type { LoadedSheet } from '@/sheets/provider'
/**
* Read-only lookups over a loaded sheet. Everything the editor used to derive
* from SVG attributes, label matching or the species manifest comes from the
* document here, by stable id: no label drives logic.
* The sheet index lives in @faunosteo/domain since Step 6 (shared with the
* PDF engine). This shim keeps the app's import path and binds the index to
* the sheet the app loads, so `index.sheet` still carries the migration map.
*/
export type ObservableAnnotation = Extract<
Annotation,
{ kind: 'point' | 'zone' }
>
export interface SheetIndex {
sheet: LoadedSheet
mainView: SheetView
view(id: string): SheetView | undefined
annotation(id: string): Annotation | undefined
annotationsOfView(viewId: string): Annotation[]
findingZone(id: string): FindingZone | undefined
/** The category or node at a path, undefined when absent from the sheet. */
nodeAt(
zoneId: string,
path: readonly string[],
): FindingCategory | FindingNode | undefined
regions(): VertebralRegion[]
region(code: string): VertebralRegion | undefined
/** The annotation that opens the vertebra picker for a region on a view. */
spineAnnotation(
regionCode: string,
viewId: string,
): ObservableAnnotation | undefined
/** Whether an annotation opens the vertebra picker. */
isSpine(annotationId: string): boolean
name(annotation: Annotation): LocalizedText
}
export function pickLabel(
text: LocalizedText | null | undefined,
locale: Locale,
): string {
if (!text) return ''
return locale === 'en' ? text.en || text.fr : text.fr || text.en
}
export function isObservable(
a: Annotation | undefined,
): a is ObservableAnnotation {
return a !== undefined && a.kind !== 'detail_trigger'
}
export function buildSheetIndex(sheet: LoadedSheet): SheetIndex {
const { document } = sheet
const views = new Map(document.views.map((v) => [v.id, v]))
const annotations = new Map(document.annotations.map((a) => [a.id, a]))
const zones = new Map(document.finding_zones.map((z) => [z.id, z]))
const regions = new Map(
document.vertebral_config.regions.map((r) => [r.code, r]),
)
const mainView = document.views.find((v) => v.kind === 'main')
if (!mainView) throw new Error('sheet has no main view')
const nodeAt: SheetIndex['nodeAt'] = (zoneId, path) => {
const zone = zones.get(zoneId)
if (!zone || path.length === 0) return undefined
let node: FindingCategory | FindingNode | undefined = zone.categories.find(
(c) => c.id === path[0],
)
for (const segment of path.slice(1)) {
if (!node) return undefined
node = node.children.find((n) => n.id === segment)
}
return node
}
return {
sheet,
mainView,
view: (id) => views.get(id),
annotation: (id) => annotations.get(id),
annotationsOfView: (viewId) =>
document.annotations.filter((a) => a.view_id === viewId),
findingZone: (id) => zones.get(id),
nodeAt,
regions: () => document.vertebral_config.regions,
region: (code) => regions.get(code),
spineAnnotation: (code, viewId) =>
document.annotations.find(
(a): a is ObservableAnnotation =>
isObservable(a) &&
a.view_id === viewId &&
a.vertebral_region_code === code,
),
isSpine: (id) => {
const a = annotations.get(id)
return isObservable(a) && a.vertebral_region_code !== null
},
name: (a) =>
a.kind === 'detail_trigger'
? (a.name ?? views.get(a.opens_view_id)?.name ?? { fr: '', en: '' })
: a.name,
}
}
export { buildSheetIndex, isObservable, pickLabel } from '@faunosteo/domain'
export type { ObservableAnnotation } from '@faunosteo/domain'
export type SheetIndex = DomainSheetIndex<LoadedSheet>
+8
View File
@@ -28,15 +28,21 @@ export interface BundledSheetData {
document: unknown
migrationMap: unknown
assets: Record<string, string>
/** sha256 by `svg_asset_id`, from the seed manifest. */
assetHashes: Record<string, string>
}
export interface LoadedSheet {
status: SheetStatus
ref: SheetRef
speciesId: string
/** Document schema version of the sheet (`ref.schema_version`). */
schemaVersion: number
document: AnatomicalSheetDocument
/** SVG text by `svg_asset_id`. */
assets: Readonly<Record<string, string>>
/** sha256 by `svg_asset_id`; carried into a report archive as provenance. */
assetHashes: Readonly<Record<string, string>>
migrationMap: ReportMigrationMap
}
@@ -56,8 +62,10 @@ export function parseBundledSheet(data: BundledSheetData): LoadedSheet {
documentSha256: data.ref.document_sha256,
},
speciesId: data.ref.species_id,
schemaVersion: data.ref.schema_version,
document,
assets: data.assets,
assetHashes: data.assetHashes,
migrationMap,
}
}
+46 -7
View File
@@ -1,13 +1,18 @@
import {
readReportDocument,
ReportArchiveEnvelopeSchema,
type Report,
type ReportArchiveEnvelope,
type ReportMigrationMap,
} from '@faunosteo/domain'
/**
* Where the report document lives between renders. One implementation today
* (the per-tab sessionStorage draft, migrated from v2 on read); the Supabase
* and outbox adapters of later steps implement the same interface.
* Where the session lives between renders. The report draft is mirrored on
* every change; the archive an import brought along (the envelope of a
* Step 6 PDF) is written only when the session starts or ends, so a stale
* draft can still be rebased with the labels of its original sheet. One
* implementation today (per-tab sessionStorage); the Supabase and outbox
* adapters of later steps implement the same interfaces.
*/
export interface ReportPersistence {
@@ -15,12 +20,33 @@ export interface ReportPersistence {
save(report: Report | null): void
}
export interface ArchivePersistence {
load(): ReportArchiveEnvelope | null
save(archive: ReportArchiveEnvelope | null): void
}
export const DRAFT_KEY = 'osteo:draft'
export const ARCHIVE_KEY = 'osteo:archive'
function storage(): Storage | null {
return typeof sessionStorage === 'undefined' ? null : sessionStorage
}
function writeOrRemove(key: string, value: unknown): void {
const store = storage()
if (!store) return
if (value === null) {
store.removeItem(key)
return
}
try {
store.setItem(key, JSON.stringify(value))
} catch (err) {
// Quota exceeded: the session goes on, only the mirror is lost.
if (import.meta.env.DEV) console.warn(`${key} not saved`, err)
}
}
export const sessionStoragePersistence: ReportPersistence = {
load(map) {
const raw = storage()?.getItem(DRAFT_KEY)
@@ -33,9 +59,22 @@ export const sessionStoragePersistence: ReportPersistence = {
}
},
save(report) {
const store = storage()
if (!store) return
if (report) store.setItem(DRAFT_KEY, JSON.stringify(report))
else store.removeItem(DRAFT_KEY)
writeOrRemove(DRAFT_KEY, report)
},
}
export const sessionStorageArchivePersistence: ArchivePersistence = {
load() {
const raw = storage()?.getItem(ARCHIVE_KEY)
if (!raw) return null
try {
const parsed = ReportArchiveEnvelopeSchema.safeParse(JSON.parse(raw))
return parsed.success ? parsed.data : null
} catch {
return null
}
},
save(archive) {
writeOrRemove(ARCHIVE_KEY, archive)
},
}
+86 -31
View File
@@ -1,19 +1,24 @@
import { create } from 'zustand'
import {
rebaseReportOnSheet,
REPORT_VERSION,
type Animal,
type NextAppointment,
type Observation,
type Owner,
type Practitioner,
type RebaseOutcome,
type Report,
type ReportMigrationMap,
type ReportArchiveEnvelope,
type SheetRef,
} from '@faunosteo/domain'
import { generateId } from '@/lib/id'
import { nowIso } from '@/lib/dates'
import type { SheetIndex } from '@/services/sheetIndex'
import {
sessionStorageArchivePersistence,
sessionStoragePersistence,
type ArchivePersistence,
type ReportPersistence,
} from './persistence'
@@ -21,7 +26,10 @@ import {
* In-memory report document (v3) and its editing actions. Observation-level
* zone rules live in services/zoneInteraction; the store only replaces
* documents. The per-tab draft is mirrored through the persistence adapter
* and restored once the sheet (and its migration map) is known.
* and restored once the sheet is known; a draft written on another revision
* of the sheet is rebased on restore. The archive an import brought along
* (STEP6 §14 "App session") is kept beside the report for later operations
* and written only when the session starts or ends.
*/
/** What a new report needs before the store stamps version, id and dates. */
@@ -30,13 +38,26 @@ export type NewReportDraft = Omit<
'version' | 'id' | 'createdAt' | 'sheet' | 'localAnnotations'
>
export interface ImportedSession {
report: Report
archive: ReportArchiveEnvelope | null
}
export interface ReportStore {
report: Report | null
/** The envelope of the imported archive, as exported; null otherwise. */
archive: ReportArchiveEnvelope | null
activeObservationIndex: number
initReport: (draft: NewReportDraft, sheet: SheetRef) => void
hydrateReport: (report: Report) => void
/** Restores the per-tab draft; a no-op when a report is already open. */
restoreDraft: (map: ReportMigrationMap) => void
/** Opens an imported report (already rebased) with its archive. */
hydrateImport: (session: ImportedSession) => void
/**
* Restores the per-tab draft on the loaded sheet, rebasing it when it was
* written on another revision; a no-op when a report is already open.
* Returns the rebase outcome, null when nothing was restored.
*/
restoreDraft: (index: SheetIndex) => RebaseOutcome | null
addObservation: () => void
removeObservation: (index: number) => void
moveObservationUp: (index: number) => void
@@ -62,49 +83,79 @@ export function emptyObservation(): Observation {
}
}
/** A fresh v3 document: the store stamps version, id, dates and the sheet. */
function newReport(draft: NewReportDraft, sheet: SheetRef): Report {
return {
...draft,
version: REPORT_VERSION,
id: generateId(),
createdAt: nowIso(),
sheet,
observations:
draft.observations.length === 0
? [emptyObservation()]
: draft.observations,
localAnnotations: [],
}
}
function swapped(list: Observation[], i: number, j: number): Observation[] {
const next = [...list]
;[next[i], next[j]] = [next[j]!, next[i]!]
return next
}
type Patch = Partial<Pick<ReportStore, 'report' | 'activeObservationIndex'>>
type Patch = Partial<
Pick<ReportStore, 'report' | 'archive' | 'activeObservationIndex'>
>
type Setter = (fn: (s: ReportStore) => Patch | ReportStore) => void
function onReport(set: Setter, update: (r: Report, s: ReportStore) => Patch) {
set((s) => (s.report ? update(s.report, s) : s))
}
export function createReportStore(persistence: ReportPersistence) {
const store = create<ReportStore>((set) => ({
export function createReportStore(
persistence: ReportPersistence,
archives: ArchivePersistence,
) {
/** The archive mirror is explicit: these actions are the session's edges. */
const withArchive = (patch: Patch, archive: ReportArchiveEnvelope | null) => {
archives.save(archive)
return { ...patch, archive }
}
const store = create<ReportStore>((set, get) => ({
report: null,
archive: null,
activeObservationIndex: 0,
initReport: (draft, sheet) =>
set({
report: {
...draft,
version: REPORT_VERSION,
id: generateId(),
createdAt: nowIso(),
sheet,
observations:
draft.observations.length === 0
? [emptyObservation()]
: draft.observations,
localAnnotations: [],
},
activeObservationIndex: 0,
}),
set(
withArchive(
{ report: newReport(draft, sheet), activeObservationIndex: 0 },
null,
),
),
hydrateReport: (report) => set({ report, activeObservationIndex: 0 }),
hydrateReport: (report) =>
set(withArchive({ report, activeObservationIndex: 0 }, null)),
restoreDraft: (map) =>
set((s) => {
if (s.report) return s
const report = persistence.load(map)
return report ? { report, activeObservationIndex: 0 } : s
}),
hydrateImport: ({ report, archive }) =>
set(withArchive({ report, activeObservationIndex: 0 }, archive)),
restoreDraft: (index) => {
if (get().report) return null
const draft = persistence.load(index.sheet.migrationMap)
if (!draft) return null
const archive = archives.load()
const rebase = rebaseReportOnSheet(
draft,
index,
archive?.sheetSnapshot ?? null,
)
set({ report: rebase.report, archive, activeObservationIndex: 0 })
return rebase
},
addObservation: () =>
onReport(set, (r) => {
@@ -177,10 +228,14 @@ export function createReportStore(persistence: ReportPersistence) {
delete rest.nextAppointment
return { report: next ? { ...rest, nextAppointment: next } : rest }
}),
reset: () => set({ report: null, activeObservationIndex: 0 }),
reset: () =>
set(withArchive({ report: null, activeObservationIndex: 0 }, null)),
}))
store.subscribe((state) => persistence.save(state.report))
return store
}
export const useReportStore = createReportStore(sessionStoragePersistence)
export const useReportStore = createReportStore(
sessionStoragePersistence,
sessionStorageArchivePersistence,
)
+30 -5
View File
@@ -3,11 +3,36 @@
Golden inputs frozen for the characterisation tests (plan Step 1). They describe
the Report v2 document as the current application produces it.
| File | Content |
|---|---|
| `report-v2.full.json` | One report exercising every zone kind the editor can produce: plain hinge point, bilateral joint with both sides, spine zone with vertebrae, detail-popup zone, catalog findings (with and without vet referral and side), free text, severity, comment, conclusion, recommendations, dated next appointment. `boneId` values are the real `data-anno-id` of the legacy `Horse.svg` / `Horse_head.svg` now kept under `supabase/seed/anatomical-sheets/equine/legacy-sources/`; `zoneId`/`path` values exist in `pathologies.json`. |
| `report-v2.minimal.json` | Smallest valid v2 report (no observations). |
| `report-v2.full.pdf`, `report-v2.minimal.pdf` | The two reports exported by the v2 pipeline (commit 199e328, Step 5.0, rasteriser stubbed to a 1×1 PNG, no logos): the archive-like PDFs the v3 importer must read and migrate. Synthetic data only. |
| File | Content |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `report-v2.full.json` | One report exercising every zone kind the editor can produce: plain hinge point, bilateral joint with both sides, spine zone with vertebrae, detail-popup zone, catalog findings (with and without vet referral and side), free text, severity, comment, conclusion, recommendations, dated next appointment. `boneId` values are the real `data-anno-id` of the legacy `Horse.svg` / `Horse_head.svg` now kept under `supabase/seed/anatomical-sheets/equine/legacy-sources/`; `zoneId`/`path` values exist in `pathologies.json`. |
| `report-v2.minimal.json` | Smallest valid v2 report (no observations). |
| `report-v2.full.pdf`, `report-v2.minimal.pdf` | The two reports exported by the v2 pipeline (commit 199e328, Step 5.0, rasteriser stubbed to a 1×1 PNG, no logos): the archive-like PDFs the v3 importer must read and migrate. Synthetic data only. |
Do not edit these files to make a test pass: they are the behavioural oracle for
the Report v2 → v3 adapter and for PDF regression. Add a new fixture instead.
## Step 6 freeze (Phase 0, 2026-10-11)
What the PDF pipeline produced right before the Step 6 refactor, recorded by
`tests/unit/pdf.goldens.test.ts` on the bundled draft sheet
(`docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md` §17).
| File | Content |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `report-v3.demo.json` | Report v3 on the draft (ids from `draft/document.json`), 6 observations: main-view points, head-view points, spine zone with vertebrae, bilateral zone with both sides, a vet-referral leaf, a leaf whose label holds an en dash (U+2013), free-text findings, severities, comments, conclusion, recommendations, period next appointment; `sheet` = the draft ref at freeze time. |
| `report-v3.bare.pdf` | The demo report exported by the current code (rasteriser stubbed to a 1×1 PNG, no logos, FR): import fixture for the engine. |
| `goldens/step6/text.<report>.<locale>.<logos>.json` | Every `drawText` of the export, in drawing order: `{ page, text, x, y, size, font }`, numbers rounded to 2 decimals. |
| `goldens/step6/images.<report>.<locale>.<logos>.json` | Every `drawImage`: `{ page, x, y, width, height }`. Recorded per locale too: the footer centres the "powered by" block on the label width, so the ZenQuality logo shifts between FR and EN. |
| `goldens/step6/links.<report>.<locale>.<logos>.json` | Every `/Annot /Link` read back from the saved PDF: `{ page, rect, uri }`. Per locale for the same footer reason. |
| `goldens/step6/views.<report>.json` | Per `(observation, view)` of the report, the highlighted SVG parsed: `viewBox`, halo filter present, highlighted elements, visible non-highlighted markers, remaining `data-*` attributes, `<title>` count. |
Reports: `v2full` (`report-v2.full.json` migrated), `demo` (`report-v3.demo.json`),
`v2unresolved` (legacy `sphenoid` and `ssb` leaves plus one `frontal` leaf, migrated;
zone-less, so its `images` and `views` goldens are empty). Logo modes: `nologos`
(every branding slot empty, 1×1 rasteriser) and `logos` (the four logo files bundled
under `apps/app/src/assets/brand`, rasteriser stubbed to a 2×1 PNG).
Never regenerate these files without a user decision; the Step 6 engine must
reproduce them. Generation, once: `MAKE_GOLDEN=1 corepack pnpm vitest run
tests/unit/pdf.goldens.test.ts` from `apps/app`.
@@ -0,0 +1,247 @@
[
{
"page": 0,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 1,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 1,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 2,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 2,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 3,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 3,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 4,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 4,
"x": 36,
"y": 547.07,
"width": 253.64,
"height": 126.82
},
{
"page": 4,
"x": 305.64,
"y": 547.07,
"width": 253.64,
"height": 126.82
},
{
"page": 5,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 5,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 6,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 0,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 0,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 1,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 1,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 1,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 2,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 2,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 2,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 3,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 3,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 3,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 4,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 4,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 4,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 5,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 5,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 5,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 6,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 6,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 6,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
}
]
@@ -0,0 +1,51 @@
[
{
"page": 0,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 1,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 2,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 3,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 4,
"x": 36,
"y": 420.25,
"width": 253.64,
"height": 253.64
},
{
"page": 4,
"x": 305.64,
"y": 420.25,
"width": 253.64,
"height": 253.64
},
{
"page": 5,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
}
]
@@ -0,0 +1,247 @@
[
{
"page": 0,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 1,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 1,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 2,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 2,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 3,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 3,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 4,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 4,
"x": 36,
"y": 547.07,
"width": 253.64,
"height": 126.82
},
{
"page": 4,
"x": 305.64,
"y": 547.07,
"width": 253.64,
"height": 126.82
},
{
"page": 5,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 5,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 6,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 0,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 0,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 1,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 1,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 1,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 2,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 2,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 2,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 3,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 3,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 3,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 4,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 4,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 4,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 5,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 5,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 5,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 6,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 6,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 6,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
}
]
@@ -0,0 +1,51 @@
[
{
"page": 0,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 1,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 2,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 3,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 4,
"x": 36,
"y": 420.25,
"width": 253.64,
"height": 253.64
},
{
"page": 4,
"x": 305.64,
"y": 420.25,
"width": 253.64,
"height": 253.64
},
{
"page": 5,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
}
]
@@ -0,0 +1,135 @@
[
{
"page": 0,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 1,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 1,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 2,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 2,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 3,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 0,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 0,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 1,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 1,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 1,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 2,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 2,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 2,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 3,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 3,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 3,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
}
]
@@ -0,0 +1,23 @@
[
{
"page": 0,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 1,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 2,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
}
]
@@ -0,0 +1,135 @@
[
{
"page": 0,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 1,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 1,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 2,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 2,
"x": 166.82,
"y": 543.07,
"width": 261.64,
"height": 130.82
},
{
"page": 3,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 0,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 0,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 1,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 1,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 1,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 2,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 2,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 2,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 3,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 3,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 3,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
}
]
@@ -0,0 +1,23 @@
[
{
"page": 0,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 1,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
},
{
"page": 2,
"x": 166.82,
"y": 412.25,
"width": 261.64,
"height": 261.64
}
]
@@ -0,0 +1,114 @@
[
{
"page": 0,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 1,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 2,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 3,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 0,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 0,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 1,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 1,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 1,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 2,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 2,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 2,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 3,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 3,
"x": 284.49,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 3,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
}
]
@@ -0,0 +1 @@
[]
@@ -0,0 +1,114 @@
[
{
"page": 0,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 1,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 2,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 3,
"x": 247.64,
"y": 772,
"width": 100,
"height": 38
},
{
"page": 0,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 0,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 0,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 1,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 1,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 1,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 2,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 2,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 2,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
},
{
"page": 3,
"x": 36,
"y": 34,
"width": 80,
"height": 30
},
{
"page": 3,
"x": 286.43,
"y": 36,
"width": 70,
"height": 16
},
{
"page": 3,
"x": 527.28,
"y": 36,
"width": 32,
"height": 16
}
]
@@ -0,0 +1 @@
[]
@@ -0,0 +1,282 @@
[
{
"page": 0,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 4,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 4,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 4,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 4,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 5,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 5,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 5,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 5,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 6,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 6,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 6,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 6,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,142 @@
[
{
"page": 0,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 4,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 4,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 5,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 5,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 6,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 6,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,282 @@
[
{
"page": 0,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 4,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 4,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 4,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 4,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 5,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 5,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 5,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 5,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 6,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 6,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 6,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 6,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,142 @@
[
{
"page": 0,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 4,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 4,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 5,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 5,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 6,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 6,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,162 @@
[
{
"page": 0,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,82 @@
[
{
"page": 0,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,162 @@
[
{
"page": 0,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,82 @@
[
{
"page": 0,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,162 @@
[
{
"page": 0,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
284.49,
36,
354.49,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,82 @@
[
{
"page": 0,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
298.39,
38,
340.6,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,162 @@
[
{
"page": 0,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 0,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 1,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 2,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
247.64,
772,
347.64,
810
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
36,
34,
116,
64
],
"uri": "https://faunosteo.com"
},
{
"page": 3,
"rect": [
286.43,
36,
356.43,
52
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
527.28,
36,
559.28,
52
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
@@ -0,0 +1,82 @@
[
{
"page": 0,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 0,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 1,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 1,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 2,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 2,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
},
{
"page": 3,
"rect": [
300.32,
38,
342.53,
50
],
"uri": "https://zenquality.fr"
},
{
"page": 3,
"rect": [
489.12,
38,
559.28,
50
],
"uri": "https://www.instagram.com/paws.iin.harmony"
}
]
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,698 @@
[
{
"page": 0,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "01",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 0,
"text": "MODERATE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "GENERAL VIEW",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "ZONES",
"x": 36,
"y": 519.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "C7-T1 junction (cervicothoracic)",
"x": 36,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 182.34,
"y": 504.87,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hip joint (Left)",
"x": 192.24,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 259.48,
"y": 504.87,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hip joint (Right)",
"x": 269.38,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "FINDINGS — C7-T1 JUNCTION (CERVICOTHORACIC)",
"x": 36,
"y": 483.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Junction fixation",
"x": 36,
"y": 470.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "FINDINGS — HIP JOINT (LEFT)",
"x": 36,
"y": 447.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Flexion restriction",
"x": 36,
"y": 434.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "FREE FINDINGS",
"x": 36,
"y": 411.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Sensibilité au garrot",
"x": 36,
"y": 398.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "SEVERITY",
"x": 36,
"y": 375.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "moderate",
"x": 36,
"y": 362.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "COMMENT",
"x": 36,
"y": 339.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Réagit à la palpation du garrot.",
"x": 36,
"y": 326.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "02",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 1,
"text": "SEVERE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "GENERAL VIEW",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "ZONES",
"x": 36,
"y": 519.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Cervical vertebrae (C3, C4)",
"x": 36,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "FINDINGS — CERVICAL VERTEBRAE",
"x": 36,
"y": 483.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "(!) Reported stumbling / proprioceptive deficit",
"x": 36,
"y": 470.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "SEVERITY",
"x": 36,
"y": 447.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "severe",
"x": 36,
"y": 434.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "03",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 2,
"text": "DETAIL VIEW — HEAD (LEFT LATERAL VIEW)",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "ZONES",
"x": 36,
"y": 519.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Temporomandibular joint (TMJ)",
"x": 36,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "FINDINGS — TEMPOROMANDIBULAR JOINT (TMJ)",
"x": 36,
"y": 483.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "(!) Headshaking",
"x": 36,
"y": 470.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "COMMENT",
"x": 36,
"y": 447.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Vue détail tête.",
"x": 36,
"y": 434.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 3,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SYNTHESIS",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Conclusion",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 3,
"text": "CONCLUSION",
"x": 36,
"y": 691.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Dysfonction cervico-thoracique avec compensation du bassin.",
"x": 36,
"y": 677.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "RECOMMENDATIONS",
"x": 36,
"y": 645.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Repos 3 jours puis reprise progressive.",
"x": 36,
"y": 631.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "NEXT APPOINTMENT",
"x": 36,
"y": 599.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "July 1, 2026",
"x": 36,
"y": 585.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 0,
"text": "Powered by ",
"x": 240.79,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "In partnership with ",
"x": 459.38,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "1 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "Powered by ",
"x": 240.79,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "In partnership with ",
"x": 459.38,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "2 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "Powered by ",
"x": 240.79,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "In partnership with ",
"x": 459.38,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "3 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "Powered by ",
"x": 240.79,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "In partnership with ",
"x": 459.38,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "4 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
}
]
@@ -0,0 +1,762 @@
[
{
"page": 0,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "01",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 0,
"text": "MODERATE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "GENERAL VIEW",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "ZONES",
"x": 36,
"y": 388.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "C7-T1 junction (cervicothoracic)",
"x": 36,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 182.34,
"y": 374.05,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hip joint (Left)",
"x": 192.24,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 259.48,
"y": 374.05,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hip joint (Right)",
"x": 269.38,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "FINDINGS — C7-T1 JUNCTION (CERVICOTHORACIC)",
"x": 36,
"y": 352.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Junction fixation",
"x": 36,
"y": 339.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "FINDINGS — HIP JOINT (LEFT)",
"x": 36,
"y": 316.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Flexion restriction",
"x": 36,
"y": 303.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "FREE FINDINGS",
"x": 36,
"y": 280.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Sensibilité au garrot",
"x": 36,
"y": 267.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "SEVERITY",
"x": 36,
"y": 244.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "moderate",
"x": 36,
"y": 231.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "COMMENT",
"x": 36,
"y": 208.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Réagit à la palpation du garrot.",
"x": 36,
"y": 195.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "02",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 1,
"text": "SEVERE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "GENERAL VIEW",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "ZONES",
"x": 36,
"y": 388.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Cervical vertebrae (C3, C4)",
"x": 36,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "FINDINGS — CERVICAL VERTEBRAE",
"x": 36,
"y": 352.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "(!) Reported stumbling / proprioceptive deficit",
"x": 36,
"y": 339.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "SEVERITY",
"x": 36,
"y": 316.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "severe",
"x": 36,
"y": 303.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "03",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 2,
"text": "DETAIL VIEW — HEAD (LEFT LATERAL VIEW)",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "ZONES",
"x": 36,
"y": 388.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Temporomandibular joint (TMJ)",
"x": 36,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "FINDINGS — TEMPOROMANDIBULAR JOINT (TMJ)",
"x": 36,
"y": 352.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "(!) Headshaking",
"x": 36,
"y": 339.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "COMMENT",
"x": 36,
"y": 316.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Vue détail tête.",
"x": 36,
"y": 303.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 3,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Owner: Jean Martin",
"x": 480.58,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "June 1, 2026",
"x": 507.42,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SYNTHESIS",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Conclusion",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 3,
"text": "CONCLUSION",
"x": 36,
"y": 691.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Dysfonction cervico-thoracique avec compensation du bassin.",
"x": 36,
"y": 677.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "RECOMMENDATIONS",
"x": 36,
"y": 645.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Repos 3 jours puis reprise progressive.",
"x": 36,
"y": 631.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "NEXT APPOINTMENT",
"x": 36,
"y": 599.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "July 1, 2026",
"x": 36,
"y": 585.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 0,
"text": "Powered by ",
"x": 254.68,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "zenquality.fr",
"x": 298.39,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "In partnership with ",
"x": 421.22,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "1 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "Powered by ",
"x": 254.68,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "zenquality.fr",
"x": 298.39,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "In partnership with ",
"x": 421.22,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "2 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "Powered by ",
"x": 254.68,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "zenquality.fr",
"x": 298.39,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "In partnership with ",
"x": 421.22,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "3 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "Powered by ",
"x": 254.68,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "zenquality.fr",
"x": 298.39,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "In partnership with ",
"x": 421.22,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "4 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
}
]
@@ -0,0 +1,698 @@
[
{
"page": 0,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "01",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 0,
"text": "MODÉRÉE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "VUE GÉNÉRALE",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "ZONES",
"x": 36,
"y": 519.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Charnière C7-T1 (cervico-thoracique)",
"x": 36,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 207.04,
"y": 504.87,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hanche (coxo-fémorale) (Gauche)",
"x": 216.94,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 372.95,
"y": 504.87,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hanche (coxo-fémorale) (Droite)",
"x": 382.85,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "CONSTATS — CHARNIÈRE C7-T1 (CERVICO-THORACIQUE)",
"x": 36,
"y": 483.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Fixation de la charnière",
"x": 36,
"y": 470.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "CONSTATS — HANCHE (COXO-FÉMORALE) (GAUCHE)",
"x": 36,
"y": 447.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Restriction en flexion",
"x": 36,
"y": 434.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "CONSTATS LIBRES",
"x": 36,
"y": 411.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Sensibilité au garrot",
"x": 36,
"y": 398.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "SÉVÉRITÉ",
"x": 36,
"y": 375.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "modérée",
"x": 36,
"y": 362.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "COMMENTAIRE",
"x": 36,
"y": 339.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Réagit à la palpation du garrot.",
"x": 36,
"y": 326.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "02",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 1,
"text": "SÉVÈRE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "VUE GÉNÉRALE",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "ZONES",
"x": 36,
"y": 519.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Vertèbres cervicales (C3, C4)",
"x": 36,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "CONSTATS — VERTÈBRES CERVICALES",
"x": 36,
"y": 483.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "(!) Trébuchements / déficit proprioceptif rapporté",
"x": 36,
"y": 470.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "SÉVÉRITÉ",
"x": 36,
"y": 447.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "sévère",
"x": 36,
"y": 434.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "03",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 2,
"text": "VUE DÉTAIL — TÊTE (VUE LATÉRALE GAUCHE)",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "ZONES",
"x": 36,
"y": 519.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Articulation temporo-mandibulaire (ATM)",
"x": 36,
"y": 506.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "CONSTATS — ARTICULATION TEMPORO-MANDIBULAIRE (ATM)",
"x": 36,
"y": 483.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "(!) Headshaking (secouement de tête)",
"x": 36,
"y": 470.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "COMMENTAIRE",
"x": 36,
"y": 447.07,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Vue détail tête.",
"x": 36,
"y": 434.07,
"size": 10,
"font": "Helvetica"
},
{
"page": 3,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SYNTHÈSE",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Conclusion",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 3,
"text": "CONCLUSION",
"x": 36,
"y": 691.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Dysfonction cervico-thoracique avec compensation du bassin.",
"x": 36,
"y": 677.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "RECOMMANDATIONS",
"x": 36,
"y": 645.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Repos 3 jours puis reprise progressive.",
"x": 36,
"y": 631.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "PROCHAIN RENDEZ-VOUS",
"x": 36,
"y": 599.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "1 juillet 2026",
"x": 36,
"y": 585.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 0,
"text": "Propulsé par ",
"x": 238.85,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "En partenariat avec ",
"x": 455.61,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "1 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "Propulsé par ",
"x": 238.85,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "En partenariat avec ",
"x": 455.61,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "2 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "Propulsé par ",
"x": 238.85,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "En partenariat avec ",
"x": 455.61,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "3 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "Propulsé par ",
"x": 238.85,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "En partenariat avec ",
"x": 455.61,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "4 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
}
]
@@ -0,0 +1,762 @@
[
{
"page": 0,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 0,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "01",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 0,
"text": "MODÉRÉE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "VUE GÉNÉRALE",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "ZONES",
"x": 36,
"y": 388.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Charnière C7-T1 (cervico-thoracique)",
"x": 36,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 207.04,
"y": 374.05,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hanche (coxo-fémorale) (Gauche)",
"x": 216.94,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "•",
"x": 372.95,
"y": 374.05,
"size": 14,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Hanche (coxo-fémorale) (Droite)",
"x": 382.85,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "CONSTATS — CHARNIÈRE C7-T1 (CERVICO-THORACIQUE)",
"x": 36,
"y": 352.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Fixation de la charnière",
"x": 36,
"y": 339.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "CONSTATS — HANCHE (COXO-FÉMORALE) (GAUCHE)",
"x": 36,
"y": 316.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Restriction en flexion",
"x": 36,
"y": 303.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "CONSTATS LIBRES",
"x": 36,
"y": 280.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Sensibilité au garrot",
"x": 36,
"y": 267.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "SÉVÉRITÉ",
"x": 36,
"y": 244.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "modérée",
"x": 36,
"y": 231.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 0,
"text": "COMMENTAIRE",
"x": 36,
"y": 208.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 0,
"text": "Réagit à la palpation du garrot.",
"x": 36,
"y": 195.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 1,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "02",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 1,
"text": "SÉVÈRE",
"x": 80,
"y": 727.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "VUE GÉNÉRALE",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "ZONES",
"x": 36,
"y": 388.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "Vertèbres cervicales (C3, C4)",
"x": 36,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "CONSTATS — VERTÈBRES CERVICALES",
"x": 36,
"y": 352.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "(!) Trébuchements / déficit proprioceptif rapporté",
"x": 36,
"y": 339.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 1,
"text": "SÉVÉRITÉ",
"x": 36,
"y": 316.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 1,
"text": "sévère",
"x": 36,
"y": 303.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 2,
"text": "OBSERVATION",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "03",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 2,
"text": "VUE DÉTAIL — TÊTE (VUE LATÉRALE GAUCHE)",
"x": 166.82,
"y": 687.89,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "ZONES",
"x": 36,
"y": 388.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Articulation temporo-mandibulaire (ATM)",
"x": 36,
"y": 375.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "CONSTATS — ARTICULATION TEMPORO-MANDIBULAIRE (ATM)",
"x": 36,
"y": 352.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "(!) Headshaking (secouement de tête)",
"x": 36,
"y": 339.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 2,
"text": "COMMENTAIRE",
"x": 36,
"y": 316.25,
"size": 8,
"font": "Helvetica-Bold"
},
{
"page": 2,
"text": "Vue détail tête.",
"x": 36,
"y": 303.25,
"size": 10,
"font": "Helvetica"
},
{
"page": 3,
"text": "Dr. Claire Dupont",
"x": 36,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Cabinet Équi-Ostéo",
"x": 36,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "claire@example.test",
"x": 36,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SIRET 12345678901234",
"x": 36,
"y": 764,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "Mistral (Selle Français) · 9 ans",
"x": 402.16,
"y": 800,
"size": 11,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Propriétaire : Jean Martin",
"x": 458.2,
"y": 788,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "1 juin 2026",
"x": 515.25,
"y": 776,
"size": 9,
"font": "Helvetica"
},
{
"page": 3,
"text": "SYNTHÈSE",
"x": 36,
"y": 746.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Conclusion",
"x": 36,
"y": 719.89,
"size": 22,
"font": "Times-Roman"
},
{
"page": 3,
"text": "CONCLUSION",
"x": 36,
"y": 691.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Dysfonction cervico-thoracique avec compensation du bassin.",
"x": 36,
"y": 677.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "RECOMMANDATIONS",
"x": 36,
"y": 645.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "Repos 3 jours puis reprise progressive.",
"x": 36,
"y": 631.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 3,
"text": "PROCHAIN RENDEZ-VOUS",
"x": 36,
"y": 599.89,
"size": 9,
"font": "Helvetica-Bold"
},
{
"page": 3,
"text": "1 juillet 2026",
"x": 36,
"y": 585.89,
"size": 11,
"font": "Helvetica"
},
{
"page": 0,
"text": "Propulsé par ",
"x": 252.75,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "zenquality.fr",
"x": 300.32,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "En partenariat avec ",
"x": 417.45,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 0,
"text": "1 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "Propulsé par ",
"x": 252.75,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "zenquality.fr",
"x": 300.32,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "En partenariat avec ",
"x": 417.45,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 1,
"text": "2 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "Propulsé par ",
"x": 252.75,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "zenquality.fr",
"x": 300.32,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "En partenariat avec ",
"x": 417.45,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 2,
"text": "3 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "Propulsé par ",
"x": 252.75,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "zenquality.fr",
"x": 300.32,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "En partenariat avec ",
"x": 417.45,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "@paws.iin.harmony",
"x": 489.12,
"y": 40,
"size": 8,
"font": "Helvetica"
},
{
"page": 3,
"text": "4 / 4",
"x": 289.86,
"y": 22,
"size": 8,
"font": "Helvetica"
}
]
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+277
View File
@@ -0,0 +1,277 @@
[
{
"observationId": "obs-demo-1",
"viewId": "main",
"viewBox": "0 0 2073.4 1629.4",
"halo": true,
"highlighted": [
{
"tag": "circle",
"cx": "1118",
"cy": "528",
"r": "30",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "1118",
"cy": "528",
"r": "18",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "865",
"cy": "528",
"r": "30",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "865",
"cy": "528",
"r": "18",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 32
},
{
"observationId": "obs-demo-2",
"viewId": "main",
"viewBox": "0 0 2073.4 1629.4",
"halo": true,
"highlighted": [
{
"tag": "circle",
"cx": "1585",
"cy": "612",
"r": "34",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "1585",
"cy": "612",
"r": "22",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 32
},
{
"observationId": "obs-demo-3",
"viewId": "main",
"viewBox": "0 0 2073.4 1629.4",
"halo": true,
"highlighted": [
{
"tag": "polygon",
"cx": null,
"cy": null,
"r": null,
"points": "468,276 489,216 558,248 586,339 607,401 625,447 649,510 695.1,528.4 728.9,520.1 765.3,472.8 816.8,453 796.5,543.7 730,600 646,604 593,565 552,461 524,370",
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 32
},
{
"observationId": "obs-demo-4",
"viewId": "head",
"viewBox": "60 100 500 380",
"halo": false,
"highlighted": [
{
"tag": "circle",
"cx": "277",
"cy": "214",
"r": "27",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
},
{
"tag": "circle",
"cx": "277",
"cy": "214",
"r": "15",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
},
{
"tag": "circle",
"cx": "400",
"cy": "258",
"r": "27",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
},
{
"tag": "circle",
"cx": "400",
"cy": "258",
"r": "15",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 18
},
{
"observationId": "obs-demo-5",
"viewId": "main",
"viewBox": "0 0 2073.4 1629.4",
"halo": true,
"highlighted": [
{
"tag": "circle",
"cx": "1450",
"cy": "578",
"r": "34",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "1450",
"cy": "578",
"r": "22",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 32
},
{
"observationId": "obs-demo-5",
"viewId": "head",
"viewBox": "60 100 500 380",
"halo": false,
"highlighted": [
{
"tag": "circle",
"cx": "441",
"cy": "190",
"r": "27",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
},
{
"tag": "circle",
"cx": "441",
"cy": "190",
"r": "15",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 18
},
{
"observationId": "obs-demo-6",
"viewId": "main",
"viewBox": "0 0 2073.4 1629.4",
"halo": true,
"highlighted": [
{
"tag": "circle",
"cx": "1424",
"cy": "515",
"r": "30",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "1424",
"cy": "515",
"r": "18",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "polygon",
"cx": null,
"cy": null,
"r": null,
"points": "1401.3,457.1 1386,562 1232,562 1130,552 1131.4,503.2 1260,475 1361,454.4",
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 32
}
]
+112
View File
@@ -0,0 +1,112 @@
[
{
"observationId": "obs-1",
"viewId": "main",
"viewBox": "0 0 2073.4 1629.4",
"halo": true,
"highlighted": [
{
"tag": "circle",
"cx": "1585",
"cy": "612",
"r": "34",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "1585",
"cy": "612",
"r": "22",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "865",
"cy": "528",
"r": "30",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
},
{
"tag": "circle",
"cx": "865",
"cy": "528",
"r": "18",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 32
},
{
"observationId": "obs-2",
"viewId": "main",
"viewBox": "0 0 2073.4 1629.4",
"halo": true,
"highlighted": [
{
"tag": "polygon",
"cx": null,
"cy": null,
"r": null,
"points": "468,276 489,216 558,248 586,339 607,401 625,447 649,510 695.1,528.4 728.9,520.1 765.3,472.8 816.8,453 796.5,543.7 730,600 646,604 593,565 552,461 524,370",
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": "url(#osteo-halo)"
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 32
},
{
"observationId": "obs-3",
"viewId": "head",
"viewBox": "60 100 500 380",
"halo": false,
"highlighted": [
{
"tag": "circle",
"cx": "400",
"cy": "258",
"r": "27",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
},
{
"tag": "circle",
"cx": "400",
"cy": "258",
"r": "15",
"points": null,
"d": null,
"fill": "#b85a3f",
"fillOpacity": "0.85",
"filter": null
}
],
"nonHighlightedVisible": 0,
"dataAttributes": 2,
"titles": 18
}
]
@@ -0,0 +1 @@
[]
Binary file not shown.
+239
View File
@@ -0,0 +1,239 @@
{
"version": 3,
"id": "fixture-demo-v3",
"createdAt": "2026-10-11T09:30:00.000Z",
"date": "2026-10-11",
"practitioner": {
"name": "Dr. Claire Dupont",
"cabinet": "Cabinet Équi-Ostéo",
"contact": "claire@example.test",
"siret": "12345678901234"
},
"animal": {
"speciesId": "equine",
"name": "Mistral",
"breed": "Selle Français",
"age": "9 ans"
},
"owner": {
"name": "Jean Martin"
},
"sheet": {
"sheetId": "503dc301-a8b1-50d4-9e44-0919b2fc2916",
"versionId": null,
"documentSha256": "27c7383c445c73dc2001ebf4794a3ea63d416910bbbaa0d7848dd720de7c2660"
},
"observations": [
{
"id": "obs-demo-1",
"zones": [
{
"annotationId": "c7-t1",
"viewId": "main",
"labelFrSnapshot": "Charnière C7-T1 (cervico-thoracique)",
"labelEnSnapshot": "C7-T1 junction (cervicothoracic)"
},
{
"annotationId": "t18-l1",
"viewId": "main",
"labelFrSnapshot": "Charnière T18-L1 (thoraco-lombaire)",
"labelEnSnapshot": "T18-L1 junction (thoracolumbar)"
}
],
"findings": [
{
"findingZoneId": "c7-t1",
"path": ["c7-t1-dysfunctions", "segmental", "restriction-flexion"],
"labelFrSnapshot": "Restriction en flexion",
"labelEnSnapshot": "Flexion restriction"
},
{
"findingZoneId": "c7-t1",
"path": ["c7-t1-dysfunctions", "segmental", "restriction-extension"],
"labelFrSnapshot": "Restriction en extension",
"labelEnSnapshot": "Extension restriction"
}
],
"freeTextFindings": [],
"severity": "mild",
"comment": "Réagit à la palpation de la charnière."
},
{
"id": "obs-demo-2",
"zones": [
{
"annotationId": "hip",
"viewId": "main",
"side": "left",
"labelFrSnapshot": "Hanche (coxo-fémorale)",
"labelEnSnapshot": "Hip joint"
},
{
"annotationId": "hip",
"viewId": "main",
"side": "right",
"labelFrSnapshot": "Hanche (coxo-fémorale)",
"labelEnSnapshot": "Hip joint"
}
],
"findings": [
{
"findingZoneId": "hip",
"path": ["hip-dysfunctions", "articular", "restriction-flexion"],
"labelFrSnapshot": "Restriction en flexion",
"labelEnSnapshot": "Flexion restriction",
"side": "left"
},
{
"findingZoneId": "hip",
"path": [
"hip-dysfunctions",
"articular",
"restriction-abduction-adduction"
],
"labelFrSnapshot": "Restriction en abduction / adduction",
"labelEnSnapshot": "Abduction / adduction restriction",
"side": "right"
}
],
"freeTextFindings": [],
"severity": "moderate",
"comment": ""
},
{
"id": "obs-demo-3",
"zones": [
{
"annotationId": "cervical",
"viewId": "main",
"vertebrae": [
{
"region": "C",
"index": 3
},
{
"region": "C",
"index": 4
}
],
"labelFrSnapshot": "Vertèbres cervicales",
"labelEnSnapshot": "Cervical vertebrae"
}
],
"findings": [
{
"findingZoneId": "cervical",
"path": ["cervical-dysfunctions", "segmental", "localized-fixation"],
"labelFrSnapshot": "Fixation segmentaire localisée (C2–C7)",
"labelEnSnapshot": "Localized segmental fixation (C2–C7)"
}
],
"freeTextFindings": [],
"severity": "severe",
"comment": "Fixation nette en latéroflexion droite."
},
{
"id": "obs-demo-4",
"zones": [
{
"annotationId": "atm",
"viewId": "head",
"labelFrSnapshot": "Articulation temporo-mandibulaire (ATM)",
"labelEnSnapshot": "Temporomandibular joint (TMJ)"
},
{
"annotationId": "frontal",
"viewId": "head",
"labelFrSnapshot": "Frontal",
"labelEnSnapshot": "Frontal bone"
}
],
"findings": [
{
"findingZoneId": "frontal",
"path": ["frontal-consultation-reasons", "head-rubbing"],
"labelFrSnapshot": "Frottements répétés de la tête rapportés",
"labelEnSnapshot": "Reported repeated head rubbing",
"requiresVetReferral": true
},
{
"findingZoneId": "atm",
"path": ["atm-dysfunctions", "articular", "restriction-opening"],
"labelFrSnapshot": "Restriction à l'ouverture",
"labelEnSnapshot": "Opening restriction"
}
],
"freeTextFindings": [],
"comment": ""
},
{
"id": "obs-demo-5",
"zones": [
{
"annotationId": "sacroiliac",
"viewId": "main",
"side": "right",
"labelFrSnapshot": "Articulation sacro-iliaque",
"labelEnSnapshot": "Sacroiliac joint"
},
{
"annotationId": "occipital",
"viewId": "head",
"labelFrSnapshot": "Occipital",
"labelEnSnapshot": "Occipital bone"
}
],
"findings": [],
"freeTextFindings": [
"Sensibilité au garrot",
"Tension du ligament nuchal"
],
"severity": "mild",
"comment": "Compensation probable."
},
{
"id": "obs-demo-6",
"zones": [
{
"annotationId": "lumbar",
"viewId": "main",
"vertebrae": [
{
"region": "L",
"index": 2
},
{
"region": "L",
"index": 3
}
],
"labelFrSnapshot": "Vertèbres lombaires",
"labelEnSnapshot": "Lumbar vertebrae"
},
{
"annotationId": "l6-s1",
"viewId": "main",
"labelFrSnapshot": "Charnière L6-S1 (lombo-sacrée)",
"labelEnSnapshot": "L6-S1 junction (lumbosacral joint)"
}
],
"findings": [
{
"findingZoneId": "lumbar",
"path": ["lumbar-dysfunctions", "segmental", "restriction-extension"],
"labelFrSnapshot": "Restriction en extension",
"labelEnSnapshot": "Extension restriction"
}
],
"freeTextFindings": ["Raideur lombaire au pas"],
"comment": ""
}
],
"conclusion": "Dysfonction cervico-thoracique avec compensation du bassin et tension crânienne associée.",
"recommendations": "Repos 3 jours puis reprise progressive ; contrôle vétérinaire pour les frottements de tête.",
"nextAppointment": {
"kind": "period",
"text": "6 à 8 semaines"
},
"localAnnotations": []
}
+301
View File
@@ -0,0 +1,301 @@
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'
import { expect, vi } from 'vitest'
import {
PDFArray,
PDFDict,
PDFDocument,
PDFHexString,
PDFName,
PDFNumber,
PDFPage,
PDFString,
} from 'pdf-lib'
import type {
Branding,
Observation,
Report,
SheetSnapshot,
} from '@faunosteo/domain'
import { composeHighlightedViewSvg } from '@faunosteo/pdf'
import { nologosBranding } from './sheet'
/**
* Step 6 Phase 0 freeze: what the PDF pipeline drew before the engine,
* recorded as JSON goldens (docs/development/STEP6_PDF_ARCHIVE_ANALYSIS.md
* §17) that the app export path must still reproduce. The recorder spies on
* pdf-lib, the link reader parses the saved bytes, the view snapshot parses
* the engine's highlighted SVG with the browser DOM. Numbers are rounded to
* 2 decimals; nothing ordered by drawing order is sorted.
*/
/** 1×1 PNG (nologos: the legacy stub) and 2×1 PNG (logos: deterministic partner logo width). */
export const ONE_PX_PNG = Uint8Array.from(
Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
'base64',
),
)
export const TWO_BY_ONE_PNG = Uint8Array.from(
Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7QOjdAAAAD0lEQVR4nGPYEWX///9/AA0PBE/1T7nxAAAAAElFTkSuQmCC',
'base64',
),
)
const HERE = dirname(fileURLToPath(import.meta.url))
export const FIXTURES_DIR = resolve(HERE, '../fixtures')
export const GOLDEN_DIR = resolve(FIXTURES_DIR, 'goldens/step6')
/** `MAKE_GOLDEN=1` writes the goldens instead of asserting them. */
export const MAKE_GOLDEN = process.env.MAKE_GOLDEN === '1'
export type LogoMode = 'nologos' | 'logos'
export interface TextEntry {
page: number
text: string
x: number | null
y: number | null
size: number | null
font: string | null
}
export interface ImageEntry {
page: number
x: number | null
y: number | null
width: number | null
height: number | null
}
export interface LinkEntry {
page: number
rect: number[]
uri: string
}
export interface HighlightedElement {
tag: string
cx: string | null
cy: string | null
r: string | null
points: string | null
d: string | null
fill: string | null
fillOpacity: string | null
filter: string | null
}
export interface ViewSnapshot {
observationId: string
viewId: string
viewBox: string | null
halo: boolean
highlighted: HighlightedElement[]
nonHighlightedVisible: number
dataAttributes: number
titles: number
}
export function round2(value: unknown): number | null {
return typeof value === 'number' ? Math.round(value * 100) / 100 : null
}
/** Pages are appended in order and never moved: the index at draw time is final. */
function pageIndex(page: PDFPage): number {
return page.doc.getPages().indexOf(page)
}
export interface DrawRecording {
texts: TextEntry[]
images: ImageEntry[]
stop(): void
}
/** Records every drawText / drawImage while letting pdf-lib draw for real. */
export function recordDrawing(): DrawRecording {
const texts: TextEntry[] = []
const images: ImageEntry[] = []
const drawText = PDFPage.prototype.drawText
const drawImage = PDFPage.prototype.drawImage
const textSpy = vi
.spyOn(PDFPage.prototype, 'drawText')
.mockImplementation(function (this: PDFPage, text, options) {
texts.push({
page: pageIndex(this),
text,
x: round2(options?.x),
y: round2(options?.y),
size: round2(options?.size),
font: options?.font?.name ?? null,
})
return drawText.call(this, text, options)
})
const imageSpy = vi
.spyOn(PDFPage.prototype, 'drawImage')
.mockImplementation(function (this: PDFPage, image, options) {
images.push({
page: pageIndex(this),
x: round2(options?.x),
y: round2(options?.y),
width: round2(options?.width),
height: round2(options?.height),
})
return drawImage.call(this, image, options)
})
return {
texts,
images,
stop: () => {
textSpy.mockRestore()
imageSpy.mockRestore()
},
}
}
function linkOf(dict: PDFDict, page: number): LinkEntry | null {
if (dict.get(PDFName.of('Subtype')) !== PDFName.of('Link')) return null
const rect = dict
.lookup(PDFName.of('Rect'), PDFArray)
.asArray()
.map((n) => round2((n as PDFNumber).asNumber()) ?? 0)
const uri = dict.lookup(PDFName.of('A'), PDFDict).lookup(PDFName.of('URI'))
const text =
uri instanceof PDFString || uri instanceof PDFHexString
? uri.decodeText()
: String(uri)
return { page, rect, uri: text }
}
/** Every `/Annot /Link` of the saved PDF, page by page, in annotation order. */
export async function readLinks(bytes: Uint8Array): Promise<LinkEntry[]> {
const doc = await PDFDocument.load(bytes)
const out: LinkEntry[] = []
doc.getPages().forEach((page, index) => {
const annots = page.node.Annots()
if (!annots) return
for (let i = 0; i < annots.size(); i += 1) {
const link = linkOf(annots.lookup(i, PDFDict), index)
if (link) out.push(link)
}
})
return out
}
/**
* The branding of one logo mode, for a test that mocks `@/pdf/branding`:
* `logos` is the real module (the bundled files), `nologos` every slot
* empty with the credits' fallback texts (the Phase 0 fetch 404).
*/
export async function brandingOf(mode: LogoMode): Promise<Branding> {
if (mode === 'nologos') return nologosBranding()
const real =
await vi.importActual<typeof import('@/pdf/branding')>('@/pdf/branding')
return real.loadBranding()
}
const HIGHLIGHT_FILL = '#b85a3f'
function highlightedOf(el: Element): HighlightedElement {
const attr = (name: string) => el.getAttribute(name)
return {
tag: el.tagName,
cx: attr('cx'),
cy: attr('cy'),
r: attr('r'),
points: attr('points'),
d: attr('d'),
fill: attr('fill'),
fillOpacity: attr('fill-opacity'),
filter: attr('filter'),
}
}
/** Children of the annotation layer (last `<g>` of the root) still visible and not highlighted. */
function countVisibleNonHighlighted(root: Element): number {
const layer = Array.from(root.children)
.filter((c) => c.tagName === 'g')
.at(-1)
if (!layer) return 0
return Array.from(layer.children).filter(
(el) =>
el.getAttribute('fill') !== HIGHLIGHT_FILL &&
el.getAttribute('display') !== 'none',
).length
}
function countDataAttributes(root: Element): number {
return [root, ...Array.from(root.querySelectorAll('*'))].reduce(
(count, el) =>
count +
Array.from(el.attributes).filter((a) => a.name.startsWith('data-'))
.length,
0,
)
}
export function snapshotView(
sheet: SheetSnapshot,
observation: Observation,
viewId: string,
): ViewSnapshot {
const svg = composeHighlightedViewSvg(sheet, viewId, observation)
const root = new DOMParser().parseFromString(
svg,
'image/svg+xml',
).documentElement
return {
observationId: observation.id,
viewId,
viewBox: root.getAttribute('viewBox'),
halo: root.querySelector('filter#osteo-halo') !== null,
highlighted: Array.from(
root.querySelectorAll(`[fill="${HIGHLIGHT_FILL}"]`),
).map(highlightedOf),
nonHighlightedVisible: countVisibleNonHighlighted(root),
dataAttributes: countDataAttributes(root),
titles: root.getElementsByTagName('title').length,
}
}
/** The views an observation draws, in the pipeline's order: main first, then first appearance. */
export function viewIdsOf(
sheet: SheetSnapshot,
observation: Observation,
): string[] {
const views = new Set(sheet.document.views.map((v) => v.id))
const main = sheet.document.views.find((v) => v.kind === 'main')!.id
return [...new Set(observation.zones.map((z) => z.viewId))]
.filter((id) => views.has(id))
.sort((a, b) => Number(b === main) - Number(a === main))
}
export function snapshotViews(
sheet: SheetSnapshot,
report: Report,
): ViewSnapshot[] {
return report.observations.flatMap((observation) =>
viewIdsOf(sheet, observation).map((viewId) =>
snapshotView(sheet, observation, viewId),
),
)
}
export function readGolden<T = unknown>(name: string): T {
return JSON.parse(readFileSync(resolve(GOLDEN_DIR, name), 'utf8')) as T
}
/** Writes the golden under MAKE_GOLDEN, asserts deep equality otherwise. */
export function checkGolden(name: string, actual: unknown): void {
if (MAKE_GOLDEN) {
mkdirSync(GOLDEN_DIR, { recursive: true })
writeFileSync(
resolve(GOLDEN_DIR, name),
`${JSON.stringify(actual, null, 2)}\n`,
)
return
}
expect(actual, name).toEqual(readGolden(name))
}
+42
View File
@@ -1,8 +1,14 @@
import {
buildSheetSnapshot,
ENVELOPE_FORMAT,
ENVELOPE_VERSION,
REPORT_VERSION,
type Branding,
type Observation,
type Report,
type ReportArchiveEnvelope,
} from '@faunosteo/domain'
import { defaultPdfLabels } from '@faunosteo/pdf'
import { loadSheetIndex } from '@/sheets/useSheet'
import type { SheetIndex } from '@/services/sheetIndex'
@@ -37,3 +43,39 @@ export function minimalReport(
...patch,
}
}
/** The branding the app loads when every logo fetch fails (credits keep their text). */
export function nologosBranding(): Branding {
return {
siteUrl: 'https://faunosteo.com',
headerLogo: null,
footerLogo: null,
poweredBy: {
logo: null,
url: 'https://zenquality.fr',
fallbackText: 'zenquality.fr',
},
partner: {
logo: null,
url: 'https://www.instagram.com/paws.iin.harmony',
fallbackText: '@paws.iin.harmony',
},
}
}
/** A valid Step 6 envelope for `report`, snapshotted on `sheet` (no logos). */
export function archiveEnvelope(
sheet: SheetIndex,
report: Report,
): ReportArchiveEnvelope {
return {
format: ENVELOPE_FORMAT,
envelopeVersion: ENVELOPE_VERSION,
exportedAt: '2026-10-11T12:00:00.000Z',
locale: 'fr',
report,
sheetSnapshot: buildSheetSnapshot(sheet.sheet, report),
branding: nologosBranding(),
labels: defaultPdfLabels,
}
}
+15 -8
View File
@@ -3,6 +3,9 @@ import { fr } from '@/i18n/fr'
import { en } from '@/i18n/en'
import { pickLocaleLabel } from '@/i18n/pickLocaleLabel'
// The pdf.* keys left the app dicts with Step 6: the engine owns them
// (@faunosteo/pdf defaultPdfLabels, parity tested there).
const REQUIRED = [
'severity.mild',
'severity.moderate',
@@ -11,14 +14,15 @@ const REQUIRED = [
'home.import.error_invalid_pdf',
'home.import.error_no_attachment',
'home.import.error_generic',
'pdf.section.zones',
'pdf.section.findings_prefix',
'pdf.section.free_findings',
'pdf.section.severity',
'pdf.section.comment',
'pdf.view.general',
'pdf.view.detail_prefix',
'pdf.empty',
'home.import.error_attachment_stripped',
'home.import.archive_ok',
'home.import.complete',
'home.import.degraded',
'home.import.snapshot_reason.unsupported_envelope',
'home.import.snapshot_reason.schema',
'home.import.snapshot_reason.caps',
'home.import.snapshot_reason.integrity',
'home.import.snapshot_reason.sheet_mismatch',
'sheet.status.draft',
'sheet.loading',
'vertebra.range_note',
@@ -27,6 +31,9 @@ const REQUIRED = [
const PLACEHOLDERS: Record<string, string> = {
'home.import.error_incompatible_version': '{version}',
'home.import.migrated': '{count}',
'home.import.rebased': '{count}',
'home.import.snapshot_rejected': '{reason}',
'editor.draft_rebased': '{count}',
'vertebra.extend_to': '{max}',
}
+11 -11
View File
@@ -19,15 +19,11 @@ import {
loadLegacyBaseline,
} from '../helpers/legacyLeaves'
const ONE_PX_PNG = Uint8Array.from(
Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
'base64',
),
)
vi.mock('@/pdf/render/svgToPng', () => ({
rasterizeSvg: vi.fn(async () => ONE_PX_PNG),
}))
// The factory runs when the engine first loads the adapter: fixed 1×1 PNG.
vi.mock('@/pdf/browserRasterizer', async () => {
const { ONE_PX_PNG } = await import('../helpers/goldens')
return { browserRasterizer: vi.fn(async () => ONE_PX_PNG) }
})
let sheet: SheetIndex
let report: Report
@@ -60,10 +56,14 @@ describe('the 612 legacy leaves in the application', () => {
}
})
it('keeps every finding, resolved or not, through a v3 PDF export and import', async () => {
const bytes = await exportReportToPdf(report, sheet, { locale: 'fr' })
it('keeps every finding, resolved or not, through an archive PDF export and import', async () => {
const { pdf: bytes } = await exportReportToPdf(report, sheet, {
locale: 'fr',
})
const back = await importReportFromPdf(bytes, sheet.sheet.migrationMap)
expect(back.migrated).toBe(false)
expect(back.origin).toBe('envelope_v1')
expect(back.archive).not.toBeNull()
expect(back.report).toEqual(report)
const again = back.report.observations.flatMap((o) => o.findings)
expect(again.filter((f) => f.unresolved)).toHaveLength(29)
@@ -1,28 +0,0 @@
import { describe, it, expect } from 'vitest'
import { inflateFlate } from '@/pdf/attachment'
async function deflate(data: Uint8Array): Promise<Uint8Array> {
const stream = new Blob([data as BlobPart])
.stream()
.pipeThrough(new CompressionStream('deflate'))
return new Uint8Array(await new Response(stream).arrayBuffer())
}
describe('inflateFlate decompression cap', () => {
it('inflates a normal-size payload', async () => {
const payload = new TextEncoder().encode(
JSON.stringify({ version: 2, hello: 'world' }),
)
const out = await inflateFlate(await deflate(payload))
expect(out).not.toBeNull()
expect(new TextDecoder().decode(out!)).toContain('hello')
})
it('returns null for a decompression bomb above the cap', async () => {
// 24 MB of zeros deflates to a few KB but inflates past the 16 MB cap
const bomb = await deflate(new Uint8Array(24 * 1024 * 1024))
expect(bomb.byteLength).toBeLessThan(1024 * 1024)
const out = await inflateFlate(bomb)
expect(out).toBeNull()
})
})
@@ -1,50 +0,0 @@
import { describe, it, expect, beforeAll } from 'vitest'
import { PDFDocument } from 'pdf-lib'
import { attachReportJson, extractReportJson } from '@/pdf/attachment'
import type { SheetIndex } from '@/services/sheetIndex'
import { loadTestSheet, minimalReport } from '../helpers/sheet'
let sheet: SheetIndex
beforeAll(async () => {
sheet = await loadTestSheet()
})
describe('PDF attachment roundtrip', () => {
it('attaches and extracts the v3 report JSON', async () => {
const doc = await PDFDocument.create()
doc.addPage()
await attachReportJson(
doc,
minimalReport(sheet, { conclusion: 'tout va bien' }),
)
const bytes = await doc.save()
const reopened = await PDFDocument.load(bytes)
const out = await extractReportJson(reopened, sheet.sheet.migrationMap)
expect(out.report.conclusion).toBe('tout va bien')
expect(out.report.animal.name).toBe('Mistral')
expect(out.report.version).toBe(3)
expect(out.migrated).toBe(false)
})
it('throws on PDFs without the attachment', async () => {
const doc = await PDFDocument.create()
doc.addPage()
const bytes = await doc.save()
const reopened = await PDFDocument.load(bytes)
await expect(
extractReportJson(reopened, sheet.sheet.migrationMap),
).rejects.toThrow()
})
})
describe('size caps', () => {
it('refuses an oversized PDF before parsing it', async () => {
const { importReportFromPdf, ImportError, MAX_PDF_BYTES } =
await import('@/pdf/import')
const huge = new Uint8Array(MAX_PDF_BYTES + 1)
await expect(
importReportFromPdf(huge, sheet.sheet.migrationMap),
).rejects.toBeInstanceOf(ImportError)
})
})
@@ -0,0 +1,81 @@
/**
* Replaces pdf.svgToPng.test.ts: the browser rasterizer adapter stamps the
* engine's size on the SVG root, draws through Image/canvas and returns PNG
* bytes, with the toDataURL fallback when toBlob yields nothing.
*/
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { browserRasterizer } from '@/pdf/browserRasterizer'
const PNG_BYTES = new Uint8Array([
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x00,
])
const SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"/>'
const SIZE = { widthPx: 10, heightPx: 6 }
class MockImage {
decoding: 'sync' | 'async' | 'auto' = 'auto'
crossOrigin: string | null = null
onload: (() => void) | null = null
onerror: ((err?: unknown) => void) | null = null
private _src = ''
get src(): string {
return this._src
}
set src(value: string) {
this._src = value
queueMicrotask(() => this.onload?.())
}
}
const blobs: Blob[] = []
function mockCanvas(toBlob: (cb: BlobCallback) => void): HTMLCanvasElement {
const canvas = document.createElement('canvas')
canvas.getContext = (() => ({
fillStyle: '',
fillRect: () => undefined,
drawImage: () => undefined,
})) as unknown as HTMLCanvasElement['getContext']
canvas.toBlob = toBlob as HTMLCanvasElement['toBlob']
vi.spyOn(document, 'createElement').mockImplementation(((tag: string) =>
tag === 'canvas'
? canvas
: ({} as HTMLElement)) as typeof document.createElement)
return canvas
}
describe('browserRasterizer', () => {
beforeEach(() => {
blobs.length = 0
vi.stubGlobal('Image', MockImage)
vi.stubGlobal('URL', {
createObjectURL: (blob: Blob) => {
blobs.push(blob)
return 'blob:mock'
},
revokeObjectURL: () => undefined,
})
})
it('returns PNG bytes for a valid SVG, sized by the engine', async () => {
const canvas = mockCanvas((cb) =>
cb(new Blob([PNG_BYTES], { type: 'image/png' })),
)
const out = await browserRasterizer(SVG, SIZE)
expect(out).toBeInstanceOf(Uint8Array)
expect(Array.from(out.slice(0, 4))).toEqual([0x89, 0x50, 0x4e, 0x47])
expect([canvas.width, canvas.height]).toEqual([10, 6])
const served = await blobs[0]!.text()
expect(served).toContain('width="10"')
expect(served).toContain('height="6"')
})
it('falls back to toDataURL when toBlob returns null', async () => {
const canvas = mockCanvas((cb) => cb(null))
canvas.toDataURL = () =>
'data:image/png;base64,' + Buffer.from(PNG_BYTES).toString('base64')
const out = await browserRasterizer(SVG, SIZE)
expect(out[0]).toBe(0x89)
expect(out[1]).toBe(0x50)
})
})
+209
View File
@@ -0,0 +1,209 @@
/**
* T2 and user scenario 3 (STEP6 §7): the archive the app exports is
* self-sufficient. Once exported, the catalog may change its labels and
* geometry and the deployment may ship other logos: a re-export from the
* envelope alone reproduces the first export, not the current resources.
*/
import {
describe,
it,
expect,
vi,
beforeAll,
afterAll,
afterEach,
} from 'vitest'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import {
buildSheetIndex,
buildSheetSnapshot,
ReportSchema,
type Branding,
type FindingCategory,
type FindingNode,
type Report,
type ReportArchiveEnvelope,
} from '@faunosteo/domain'
import { exportFromEnvelope, readReportArchive } from '@faunosteo/pdf'
import { exportReportToPdf } from '@/pdf/export'
import { browserRasterizer } from '@/pdf/browserRasterizer'
import { loadBranding } from '@/pdf/branding'
import type { LoadedSheet } from '@/sheets/provider'
import type { SheetIndex } from '@/services/sheetIndex'
import { loadTestSheet } from '../helpers/sheet'
import {
FIXTURES_DIR,
ONE_PX_PNG,
readLinks,
recordDrawing,
snapshotViews,
type ImageEntry,
type LinkEntry,
type TextEntry,
} from '../helpers/goldens'
// Same fixed raster for every view and logo: images then depend on the
// branding and the layout only.
vi.mock('@/pdf/browserRasterizer', async () => {
const { TWO_BY_ONE_PNG } = await import('../helpers/goldens')
return { browserRasterizer: vi.fn(async () => TWO_BY_ONE_PNG) }
})
// The bundled branding, unless a scenario swaps the deployment's logos.
const branding = vi.hoisted(() => ({ current: null as Branding | null }))
vi.mock('@/pdf/branding', async (importOriginal) => {
const real = await importOriginal<typeof import('@/pdf/branding')>()
return {
loadBranding: vi.fn(async () => branding.current ?? real.loadBranding()),
}
})
let sheet: SheetIndex
let demo: Report
beforeAll(async () => {
sheet = await loadTestSheet()
demo = ReportSchema.parse(
JSON.parse(
readFileSync(resolve(FIXTURES_DIR, 'report-v3.demo.json'), 'utf8'),
),
)
vi.spyOn(console, 'warn').mockImplementation(() => undefined)
})
afterEach(() => {
branding.current = null
vi.unstubAllGlobals()
})
afterAll(() => vi.restoreAllMocks())
interface Facts {
texts: TextEntry[]
images: ImageEntry[]
links: LinkEntry[]
}
/** Runs an export under the drawing recorder and reads the links back. */
async function recorded<T extends { pdf: Uint8Array }>(
run: () => Promise<T>,
): Promise<T & Facts> {
const recording = recordDrawing()
try {
const result = await run()
const { texts, images } = recording
return { ...result, texts, images, links: await readLinks(result.pdf) }
} finally {
recording.stop()
}
}
const facts = ({ texts, images, links }: Facts): Facts => ({
texts,
images,
links,
})
/** The app export path, bundled logos, under the recorder. */
function appExport(index: SheetIndex): Promise<Facts & { pdf: Uint8Array }> {
return recorded(() => exportReportToPdf(demo, index, { locale: 'fr' }))
}
async function archiveOf(pdf: Uint8Array): Promise<ReportArchiveEnvelope> {
const outcome = await readReportArchive(pdf, sheet.sheet.migrationMap)
expect(outcome.origin).toBe('envelope_v1')
return outcome.archive!
}
const REEXPORT = {
locale: 'fr' as const,
rasterizer: browserRasterizer,
exportedAt: new Date('2027-01-01T00:00:00.000Z'),
}
function renameNodes(nodes: (FindingCategory | FindingNode)[]): void {
for (const node of nodes) {
node.name = {
fr: `${node.name.fr} (révisé)`,
en: `${node.name.en} (revised)`,
}
renameNodes(node.children)
}
}
/** The catalog after a revision: every label changed, the hip marker moved. */
function revisedSheet(source: LoadedSheet): LoadedSheet {
const next = structuredClone(source)
for (const a of next.document.annotations) {
if (a.name) {
a.name = { fr: `${a.name.fr} (révisé)`, en: `${a.name.en} (revised)` }
}
if (a.id === 'hip' && a.geometry?.type === 'circle') a.geometry.cx += 100
}
for (const zone of next.document.finding_zones) {
zone.name = {
fr: `${zone.name.fr} (révisé)`,
en: `${zone.name.en} (revised)`,
}
renameNodes(zone.categories)
}
return next
}
describe('the archive survives its resources', () => {
it('T2 catalog changed: the envelope re-exports the archived sheet, not the revised one', async () => {
const first = await appExport(sheet)
const archive = await archiveOf(first.pdf)
// The revision is visible through the app path (labels and geometry)...
const revised = buildSheetIndex(revisedSheet(sheet.sheet))
const onRevised = await appExport(revised)
expect(onRevised.texts).not.toEqual(first.texts)
const revisedViews = snapshotViews(
buildSheetSnapshot(revised.sheet, demo),
demo,
)
const archivedViews = snapshotViews(archive.sheetSnapshot, demo)
expect(revisedViews).not.toEqual(archivedViews)
// ...and absent from a re-export of the envelope alone.
const again = await recorded(() => exportFromEnvelope(archive, REEXPORT))
expect(again.warnings).toEqual([])
expect(facts(again)).toEqual(facts(first))
expect(
snapshotViews(again.envelope.sheetSnapshot, again.envelope.report),
).toEqual(archivedViews)
}, 60_000)
it('scenario 3 branding changed: the envelope re-exports the archived branding and never fetches', async () => {
const first = await appExport(sheet)
const archive = await archiveOf(first.pdf)
// The deployment now ships other logos: a 1×1 PNG everywhere, another partner SVG.
const onePx = {
kind: 'png' as const,
base64: Buffer.from(ONE_PX_PNG).toString('base64'),
}
const otherSvg =
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10"/></svg>'
branding.current = {
...archive.branding,
headerLogo: onePx,
footerLogo: onePx,
poweredBy: { ...archive.branding.poweredBy!, logo: onePx },
partner: {
...archive.branding.partner!,
logo: { kind: 'svg', svg: otherSvg },
},
}
const current = await loadBranding()
expect(current.headerLogo).not.toBeNull()
expect(current).not.toEqual(archive.branding)
const fetchSpy = vi.fn()
vi.stubGlobal('fetch', fetchSpy)
const again = await recorded(() => exportFromEnvelope(archive, REEXPORT))
expect(fetchSpy).not.toHaveBeenCalled()
expect(again.warnings).toEqual([])
expect(facts(again)).toEqual(facts(first))
expect(again.envelope.branding).toEqual(archive.branding)
}, 60_000)
})
+218
View File
@@ -0,0 +1,218 @@
/**
* Step 6 Phase 0 freeze (STEP6_PDF_ARCHIVE_ANALYSIS.md §17) replayed on the
* application export path: `exportReportToPdf` now runs the engine with the
* bundled sheet snapshotted, the bundled branding (mocked to every slot empty
* for the `nologos` mode, the real module for `logos`) and the browser
* rasterizer (mocked to fixed PNGs, as the Phase 0 stub was). Text,
* images and links goldens are asserted as frozen; `MAKE_GOLDEN=1` rewrites
* them, never without a user decision. Never regenerate `report-v3.bare.pdf`:
* it is the Step 5 bare export, an import fixture only.
*/
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'
import { PDFDocument } from 'pdf-lib'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import {
buildSheetSnapshot,
readReportDocument,
ReportSchema,
type Report,
} from '@faunosteo/domain'
import { exportReportToPdf } from '@/pdf/export'
import { importReportFromPdf } from '@/pdf/import'
import type { SheetIndex } from '@/services/sheetIndex'
import type { Locale } from '@/i18n/types'
import { loadTestSheet } from '../helpers/sheet'
import {
leavesAsV2Report,
legacyLeaves,
loadLegacyBaseline,
} from '../helpers/legacyLeaves'
import {
checkGolden,
FIXTURES_DIR,
ONE_PX_PNG,
readGolden,
readLinks,
recordDrawing,
snapshotViews,
TWO_BY_ONE_PNG,
type ImageEntry,
type LinkEntry,
type LogoMode,
type TextEntry,
type ViewSnapshot,
} from '../helpers/goldens'
const raster = vi.hoisted(() => ({ png: new Uint8Array() }))
vi.mock('@/pdf/browserRasterizer', () => ({
browserRasterizer: vi.fn(async () => raster.png),
}))
const logoMode = vi.hoisted(() => ({ current: 'nologos' as LogoMode }))
vi.mock('@/pdf/branding', async () => {
const { brandingOf } = await import('../helpers/goldens')
return { loadBranding: vi.fn(() => brandingOf(logoMode.current)) }
})
const REPORTS = ['v2full', 'demo', 'v2unresolved'] as const
type ReportName = (typeof REPORTS)[number]
const MODES: readonly LogoMode[] = ['nologos', 'logos']
const BARE_PDF = resolve(FIXTURES_DIR, 'report-v3.bare.pdf')
const readJson = (name: string): unknown =>
JSON.parse(readFileSync(resolve(FIXTURES_DIR, name), 'utf8'))
let sheet: SheetIndex
let reports: Record<ReportName, Report>
let unresolvedOfV2Unresolved = 0
/** sphenoid + ssb (the families the migration cannot place) plus one leaf that resolves. */
function buildV2Unresolved(): Report {
const leaves = legacyLeaves(loadLegacyBaseline())
const unresolvedFamilies = leaves.filter(
(l) => l.zoneId === 'sphenoid' || l.zoneId === 'ssb',
)
const resolved = leaves.find((l) => l.zoneId === 'frontal')!
const outcome = readReportDocument(
leavesAsV2Report([...unresolvedFamilies, resolved]),
sheet.sheet.migrationMap,
)
unresolvedOfV2Unresolved = outcome.unresolvedFindings
return outcome.report
}
beforeAll(async () => {
sheet = await loadTestSheet()
reports = {
v2full: readReportDocument(
readJson('report-v2.full.json'),
sheet.sheet.migrationMap,
).report,
demo: ReportSchema.parse(readJson('report-v3.demo.json')),
v2unresolved: buildV2Unresolved(),
}
vi.spyOn(console, 'warn').mockImplementation(() => undefined)
})
afterAll(() => vi.restoreAllMocks())
interface Exported {
bytes: Uint8Array
texts: TextEntry[]
images: ImageEntry[]
links: LinkEntry[]
}
async function exportWith(
report: Report,
mode: LogoMode,
locale: Locale,
): Promise<Exported> {
raster.png = mode === 'logos' ? TWO_BY_ONE_PNG : ONE_PX_PNG
logoMode.current = mode
const recording = recordDrawing()
try {
const { pdf: bytes } = await exportReportToPdf(report, sheet, { locale })
const { texts, images } = recording
return { bytes, texts, images, links: await readLinks(bytes) }
} finally {
recording.stop()
}
}
const pagesOf = (entries: readonly { page: number }[]) =>
entries.map((e) => e.page)
describe('golden inputs', () => {
it('the 2×1 PNG decodes as 2×1 and the 1×1 as 1×1', async () => {
const doc = await PDFDocument.create()
const two = await doc.embedPng(TWO_BY_ONE_PNG)
expect([two.width, two.height]).toEqual([2, 1])
const one = await doc.embedPng(ONE_PX_PNG)
expect([one.width, one.height]).toEqual([1, 1])
})
it('the demo report covers the sheet features the goldens must freeze', () => {
const { demo } = reports
expect(demo.observations).toHaveLength(6)
const zones = demo.observations.flatMap((o) => o.zones)
const findings = demo.observations.flatMap((o) => o.findings)
expect(zones.some((z) => z.viewId === 'head')).toBe(true)
expect(zones.some((z) => z.vertebrae?.length)).toBe(true)
expect(
zones.filter((z) => z.annotationId === 'hip').map((z) => z.side),
).toEqual(['left', 'right'])
expect(findings.some((f) => f.requiresVetReferral)).toBe(true)
expect(findings.some((f) => f.labelFrSnapshot.includes('–'))).toBe(true)
expect(demo.observations.some((o) => o.freeTextFindings.length)).toBe(true)
expect(demo.nextAppointment).toBeDefined()
})
it('the v2unresolved report really carries unresolved findings', () => {
expect(unresolvedOfV2Unresolved).toBeGreaterThan(0)
const findings = reports.v2unresolved.observations.flatMap(
(o) => o.findings,
)
expect(findings.filter((f) => f.unresolved)).toHaveLength(
unresolvedOfV2Unresolved,
)
expect(findings.some((f) => !f.unresolved)).toBe(true)
})
})
describe.each(REPORTS)('goldens of %s', (name) => {
describe.each(MODES)('%s', (mode) => {
// Images and links are recorded per locale too: the footer centres the
// "powered by" block on the label width, so the ZenQuality link (and its
// logo) shift between FR and EN. Only the pagination is locale-free.
it('text, images and links per locale; same pagination across locales', async () => {
const fr = await exportWith(reports[name], mode, 'fr')
const en = await exportWith(reports[name], mode, 'en')
for (const [locale, out] of [
['fr', fr],
['en', en],
] as const) {
checkGolden(`text.${name}.${locale}.${mode}.json`, out.texts)
checkGolden(`images.${name}.${locale}.${mode}.json`, out.images)
checkGolden(`links.${name}.${locale}.${mode}.json`, out.links)
}
expect(pagesOf(en.images)).toEqual(pagesOf(fr.images))
expect(pagesOf(en.links)).toEqual(pagesOf(fr.links))
}, 30_000)
})
// Hidden markers are absent in the engine (the browser hid them with
// display="none") and the layer <g> carries no data-* any more: `titles`
// shrinks to the highlighted markers plus the asset's own, and
// `dataAttributes` drops from 2 to 0. Everything else must match.
it('highlighted views: same facts but titles and data attributes', () => {
const snapshot = buildSheetSnapshot(sheet.sheet, reports[name])
const actual = snapshotViews(snapshot, reports[name])
const expected = readGolden<ViewSnapshot[]>(`views.${name}.json`)
const comparable = (v: ViewSnapshot) => ({
observationId: v.observationId,
viewId: v.viewId,
viewBox: v.viewBox,
halo: v.halo,
highlighted: v.highlighted,
nonHighlightedVisible: v.nonHighlightedVisible,
})
expect(actual.map(comparable)).toEqual(expected.map(comparable))
for (const view of actual) {
expect(view.dataAttributes).toBe(0)
expect(view.titles).toBeGreaterThanOrEqual(view.highlighted.length)
}
for (const view of expected) expect(view.dataAttributes).toBe(2)
})
})
describe('report-v3.bare.pdf', () => {
it('is the demo report exported bare by Step 5 and imports with no archive', async () => {
const bytes = new Uint8Array(readFileSync(BARE_PDF))
const outcome = await importReportFromPdf(bytes, sheet.sheet.migrationMap)
expect(outcome.origin).toBe('bare_v3')
expect(outcome.migrated).toBe(false)
expect(outcome.archive).toBeNull()
expect(outcome.snapshotRejected).toBeUndefined()
expect(outcome.report).toEqual(reports.demo)
})
})
+48
View File
@@ -0,0 +1,48 @@
/**
* Replaces pdf.attachment.test.ts and pdf.attachment.inflate.test.ts on the
* engine read API: the typed ImportError kinds the home route maps. The
* attachment roundtrip moved to pdf.roundtrip.test.ts ("attaches the
* envelope and roundtrips") and the engine's tests/read.test.ts (T4); the
* inflate bomb cap lives in the engine's tests/security.test.ts.
*/
import { describe, it, expect, beforeAll } from 'vitest'
import { PDFDocument } from 'pdf-lib'
import { importReportFromPdf, ImportError, MAX_PDF_BYTES } from '@/pdf/import'
import type { SheetIndex } from '@/services/sheetIndex'
import { loadTestSheet } from '../helpers/sheet'
let sheet: SheetIndex
beforeAll(async () => {
sheet = await loadTestSheet()
})
/** Saved like the export (no object streams, BLK-009) so the keyword stamp is in clear. */
async function pdfWithoutAttachment(keywords?: string[]): Promise<Uint8Array> {
const doc = await PDFDocument.create()
doc.addPage()
if (keywords) doc.setKeywords(keywords)
return doc.save({ useObjectStreams: false })
}
async function rejectsWith(bytes: Uint8Array, kind: string): Promise<void> {
const promise = importReportFromPdf(bytes, sheet.sheet.migrationMap)
await expect(promise).rejects.toBeInstanceOf(ImportError)
await expect(promise).rejects.toMatchObject({ kind })
}
describe('importReportFromPdf error kinds', () => {
it('no_attachment for a PDF without the attachment', async () => {
await rejectsWith(await pdfWithoutAttachment(), 'no_attachment')
})
it('attachment_stripped for a stamped archive whose attachment was removed', async () => {
await rejectsWith(
await pdfWithoutAttachment(['faunosteo-archive/1']),
'attachment_stripped',
)
})
it('invalid_pdf for an oversized file, before parsing it', async () => {
await rejectsWith(new Uint8Array(MAX_PDF_BYTES + 1), 'invalid_pdf')
})
})
Loaded 100 of 184 files, more files were not shown because too many files have changed in this diff. Show more