Merge chore/tour-2026-07-12 into develop

This commit is contained in:
Bastien Chanot committed 2026-07-18 01:18:19 +02:00
commit 83e40af99b
74 files changed
+1055 -626

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
# BUGS-FOUND — behavior-changing findings quarantined by audits
Findings that fixing would change observable behavior — logged here by
audit/cleanup passes, never fixed by them. Route to /bugfix or /feat.
## Tour 2026-07-12 (clean-phase audit) — ALL FIXED 2026-07-12 (user-directed pass, same branch)
| id | file:line | description | severity |
|----|-----------|-------------|----------|
| B-1 (fixed 83f02c8) | src/components/ui/Dialog.tsx:54 | Close button `aria-label="Fermer"` hardcoded French — every dialog exposes a French label to EN-locale screen-reader users. No `common.close` key exists; fix = add key to both dicts + `t()` | low (a11y/i18n) |
| B-2 (fixed 83f02c8) | src/components/brand/LanguageSwitcher.tsx | Group `aria-label="Language"` hardcoded English — FR users get English group label. Fix = new dict key | low (a11y/i18n) |
| B-3 (fixed f58a49f) | src/state/reportStore.ts:145-152 | Draft persistence write-only: every change mirrors report to sessionStorage `osteo:draft`, but no code path restores it — refresh loses session despite the mirror. `readPersistedDraft()` (reportStore.ts:154) exists unused; either implement restore or remove mirror+helper. CLAUDE.md advertises the auto-save | medium (unfinished feature) |
| B-4 (fixed 255ab96) | src/i18n/fr.ts vs en.ts (`pdf.title_prefix`) | PDF title prefix semantics differ per locale: FR 'Bilan ostéo — ' vs EN 'Faunosteo — ' (document type vs brand). Possibly unintended discrepancy in exported PDF metadata | low |
| B-5 (fixed 74e1623) | src/app/routes/SvgEditorRoute.tsx:146,152,154 | Hardcoded placeholders `"head"`, `"ex: Hanche"`, `"ex: Hip joint"` bypass i18n on an otherwise localized page. Possibly intentional examples | low |
| B-6 (fixed b047d35) | src/domain/species/types.ts:19 + AnimalForm.tsx:32 | SpeciesManifest only carries `labelFr` — species dropdown shows "Cheval" to EN users. Fix requires manifest type change (labelEn) | low (i18n gap) |
+43
View File
@@ -0,0 +1,43 @@
# TOUR — grouped multi-axis sweep reports (append-only)
## Tour 2026-07-12 — branch chore/tour-2026-07-12 — 3 iterations — CONVERGED
Axes: security (semgrep floor ×3 + cso posture it1) · clean · reconcile (report-only) · doc.
Iteration 2 clean pass was delta-scoped (3 doc files — only changes since it1's full audit + PASS re-verify).
Iteration 3 ran because it2 surfaced 1 new tuning note; it3 = fresh semgrep on unchanged tree → identical result, 0 new → converged.
| ID | Axis | File | Sev | Finding | Status |
|----|------|------|-----|---------|--------|
| SEC-1 | security | package.json | crit/high | CVE deps: vite (GHSA-fx2h-pf6j-xcff HIGH), vitest (GHSA-5xrq-8626-4rwp CRIT dev), happy-dom (GHSA-37j7-fg3j-429f CRIT dev), esbuild, js-yaml | fixed 18865de — pnpm audit: 0 vulns |
| SEC-2 | security | SvgEditorRoute.tsx:498, pathology-editor.html:1126 | medium | user-dropped SVGs inserted without full sanitization (React editor: none; HTML editor: missed root on* + javascript: hrefs) | fixed 3f91a45 |
| SEC-3 | security | package.json | low | build toolchain (vite + plugins) in prod dependencies — inflated audit surface | fixed 187dfb5 |
| SEC-4 | security | Dockerfile:34 | high | semgrep BLOCK: no USER before ENTRYPOINT — container ran as root | fixed d8e478a — **BREAKING**: PORT env must now be >=1024 (default 8080 unaffected). Docker-verified: build, HTTP 200, SPA fallback, env override, ps = uid 101 |
| SEC-5 | security | .npmrc | medium | no minimum-release-age supply-chain guard | fixed a2bd884 (1440 min) |
| SEC-6 | security | Dockerfile:19 | low | unpinned nginx:alpine base | fixed c55da07 (nginx:1.31-alpine, build-verified) |
| SEC-7 | security | docker/nginx.conf:10,16,21 | medium | add_header inside location blocks — silently drops server-level headers if any are added later | open — defer to /harden (no server-level headers exist yet) |
| SEC-8 | security | src/pdf/attachment.ts:64-72 | low | no decompression-bomb cap on PDF import inflate | open — protected path (CLAUDE.md: ask before changing import) |
| SEC-9 | security | docker/entrypoint.sh:10-17 | low | unescaped env interpolation in env.js heredoc (operator-controlled input; a quote in APP_* breaks the JS) | open |
| SEC-10 | security | .npmrc | low | minimum-release-age=1440 below semgrep-recommended 10080 | open — deliberate 24h dev-velocity trade-off; human call |
| CLN-1 | clean | src (6 sites) | - | dead code: assertNever, canvg dep (never imported), VertebraPicker re-export shim, equine named export, validateBoneElement export, rasterizeSvg _scale param | fixed bbdc0e8 (−93 lines net) |
| CLN-2 | clean | pdf/render, EditorRoute, svgConvention | - | byte-identical word-wrap ×2 → pdf/render/text.ts; mergeBones block ×2 → helper; getBoneIdFromEvent dup walk-up → delegates | fixed bbdc0e8 |
| CLN-3 | clean | i18n/{fr,en}.ts, LanguageSwitcher | - | 6 dead dict keys; switcher hardcoded strings identical to existing lang.* keys | fixed 4ea8c90 (parity 204/204) |
| CLN-4 | clean | Brand.tsx:7 | - | hardcoded alt="Faunosteo" — identity rule violation | fixed 86ac366 (alt via useConfig) |
| CLN-5 | clean | reportStore.ts:154 | - | readPersistedDraft() never called — entangled with bug B-3 (write-only draft mirror); deleting would prejudge the product fix | open — see BUGS-FOUND.md B-3 |
| CLN-6 | clean | anatomy/types.ts:43 + styles/index.css:13 | - | BoneState 'linked'/'multi' never produced + 2 dead CSS rules — possible planned feature | open — human call |
| CLN-7 | clean | public/assets (22 of 24 PNGs) | - | unused logo sizes ship in every build/Docker image | open — confirm no external hotlinks before deleting |
| CLN-8 | clean | labels/canvas/pdf/EditorRoute | - | larger refactors: locale-fallback dedup (6+ sites), PDF constants module, onZoneClick ~60 logic lines, addObservationPage ~200 lines/9 params | open — beyond tour minimal-fix scope, route to /refactor |
| CLN-9 | clean | pdf/attachment.ts:23 | - | attachment description hardcodes brand ('Faunosteo state v2') — PDF format contract | open — confirm before touching (docs/PDF-FORMAT.md) |
| CLN-10 | clean | Dialog/LanguageSwitcher/reportStore/i18n/SvgEditorRoute/species types | - | 6 behavior-changing findings (hardcoded aria labels FR/EN, write-only draft, PDF title prefix asymmetry, i18n placeholders, labelFr-only species) | quarantined → BUGS-FOUND.md B-1..B-6, code untouched |
| REC-1 | reconcile | .claude/tasks/TODO.md:147-149 | - | declared cross-refs "BDR-001..008, LRN-001..010, BLK-001..004" \| real: 22 BDR / 29 LRN / 5 BLK | suggested — update ranges via /reconcile |
| REC-2 | reconcile | TODO.md:126 | - | declared "[ ] env-var brand identity verified" \| real: verified this tour (docker run APP_BRAND_NAME=TourCheck → env.js correct, non-root) | suggested — check box with evidence |
| REC-3 | reconcile | TODO.md:50 | - | declared "[x] sessionStorage draft mirror" \| real: mirror write-only, no restore path (B-3) | suggested — add open item "draft restore or drop mirror" |
| REC-4 | reconcile | CLAUDE.md | - | declared: canvg raster, svgToPngDataUrl(), ReportSchema.version=1, pako, pnpm at ~/.local/share/pnpm/bin \| real: native raster, rasterizeSvg, version 2, DecompressionStream, pnpm at ~/.local/bin | suggested — human-applied CLAUDE.md sync (tour never edits it) |
| DOC-1 | doc | README.md | - | canvg credited for PDF rasterization (feature bullet + stack list) | fixed 1078f74 |
| DOC-2 | doc | DEPLOY.md | - | stale: generic nginx:alpine, root container, no PORT constraint, `origin/master` reference (remote only has main/develop) | fixed 1078f74 |
| DOC-3 | doc | CHANGELOG.md | - | Unreleased section missing tour changes (canvg removal, base pin, security fixes) | fixed 1078f74 |
Checks: typecheck PASS · eslint PASS (0 warnings) · vitest 174/174 PASS · vite build PASS · docker build+run PASS (non-root verified).
Residuals: SEC-7..10, CLN-5..9 (all `open` above) + info: vite chunk >500 kB warning (pre-existing); CI build/push/deploy still unverified (TODO.md:130).
Iteration 2 cso pass skipped by design (iteration-1-only posture audit). semgrep floor ran every iteration (it1 BLOCK(1) → it2 PASS → it3 PASS identical).
Commits: 11 (6 security, 3 clean, 1 doc, 1 report). BREAKING: 1 (SEC-4 — PORT >=1024).
Branch chore/tour-2026-07-12 left UNMERGED — review, then `gitflow finish` on your GO.
+7
View File
@@ -28,3 +28,10 @@ Method: user manual export of a v2.0 horse report containing requires_vet_referr
Result: 154/154 tests stayed green; bug shipped to user-facing path. Static signal absent (the ⚠ literal was visible in the source but typecheck/lint don't flag font-encoding issues).
Anomaly: pdf.roundtrip.test.ts exercised export with empty observations + no vet findings. The ⚠ prefix was added in 60e1b04-era (`observationPage.ts:407` ternary) without a regression case covering a flagged leaf.
Action: hotfix swapped ⚠ → `(!) ` (WinAnsi-safe). Added regression `vet-referral marker is encodable by the body font` that calls `widthOfTextAtSize` on a prefixed label — would catch any future non-WinAnsi marker. LRN-021 captured the pdf-lib StandardFonts WinAnsi limitation. Follow-up: switch PDF body to embedded TTF (Inter/Fraunces per CLAUDE.md spec) so the catalog can carry arbitrary glyphs — out of hotfix scope.
## EVAL-004 | 2026-07-12 | Tour sweep converged 3 it. — agent spend-limit deaths resumable
Method: /tour full pipeline on faunosteo — semgrep floor ×3 + cso posture (it1) + full clean audit + fresh independent re-verify + doc-syncer. 13 fixed / 10 open residuals / 6 bugs quarantined; 11 commits on unmerged chore/tour-2026-07-12.
Result: re-verify PASS (0 findings on 20 modified files); checks green throughout (typecheck, lint 0, 174/174, build, docker run non-root). Convergence honest: it2 surfaced 1 new tuning note (min-release-age 1440 < 10080 rec) → triaged open → it3 semgrep identical → converged at 3-iteration bound.
Anomaly: both Phase A agents died mid-run on "monthly spend limit" — SendMessage to same agentId resumed from transcript, zero rework. PostToolUse hook false-positived 3× on 'dangerouslySetInnerHTML' as prose inside audit REPORTS (not code).
Action: none blocking. Consider excluding .claude/audits/*.md from sink-pattern hook scan.
+6
View File
@@ -159,3 +159,9 @@ feat(ui+pdf): footer partnership credit "Paws iin Harmony" text -> Paws_in_harmo
fix(editor) 2803cf7 — pathology-editor.html 404 in prod (faunosteo.com/pathology-editor.html). Root cause: file at repo root, Vite bundles only index.html -> never in dist/ -> nginx SPA-fallback -> React "Page introuvable". Worked in `pnpm dev` (serves root files), hid prod gap. Fix: git mv -> public/ (copied verbatim to dist/), href unchanged (public/=web root). Verified via vite preview: /pathology-editor.html=200 text/html. CLAUDE.md + README folder maps synced. LRN-029 captured. Pushed 97f8a92.
- Decided NOT to unify pathology-editor with svg-editor React-route pattern. BDR-022: asymmetry intentional (svg reuses app internals, pathology isolated zero-imports + produces prod JSON -> minimal-change zone). Verified editor fetches same prod assets as app (/species/equine/{pathologies.json,Horse.svg,Horse_head.svg}, all in dist/). No code change.
---
## 2026-07-12
/tour full sweep — branch chore/tour-2026-07-12, 11 commits, UNMERGED (human review pending). Security: CVE deps patched (pnpm audit 0), SVG import sanitized both editors, container non-root (BREAKING: PORT >=1024), nginx:1.31-alpine pin, min-release-age guard. Clean: -93 lines dead code (canvg dep dropped), 3 dedup extracts, i18n dead keys purged. Docs synced (README/DEPLOY/CHANGELOG, incl. stale origin/master). 6 bugs quarantined -> BUGS-FOUND.md (worst: B-3 draft mirror write-only). 4 reconcile suggestions pending /reconcile. Report: .claude/audits/TOUR.md. LRN-030/031, EVAL-004 captured.
+12
View File
@@ -232,3 +232,15 @@ Apply: any feature where "select X in modal → reflect in N places". Find the s
Extra .html at repo root never reaches dist/ — Vite build entry = index.html only. Prod 404: nginx try_files falls through to SPA index.html, React shows "Page introuvable". Fix: put standalone HTML in public/ (copied verbatim to dist/). Links resolve from web root, so href stays /file.html.
**Why:** pathology-editor.html shipped at root (BDR-020 standalone-HTML pattern), worked in `pnpm dev` (Vite serves root files in dev) but 404'd in prod (only public/ + bundled entries land in dist/). Dev-vs-prod gap hid it.
**How to apply:** standalone HTML tool / extra entry → public/, OR add to vite build.rollupOptions.input for hashed-asset processing. Verify via `vite preview` (serves real dist/), not just `pnpm dev`. Ties to [[BDR-020]].
## LRN-030 | 2026-07-12 | Dockerized SPA on port >=1024 — full non-root nginx works
nginx:alpine default = master root, workers nginx. Listen port >=1024 → USER nginx viable: chown /var/cache/nginx + pre-created /var/run/nginx.pid + /etc/nginx/conf.d (entrypoint envsubst rewrite) + html dir (env.js write). Official image log symlinks (/dev/stdout|stderr) work non-root.
**Why:** tour 2026-07-12 semgrep HIGH (no USER before ENTRYPOINT, Dockerfile:34). Fixed d8e478a; verified docker run: HTTP 200, SPA fallback, env override, ps = uid 101 master+workers.
**How to apply:** any nginx-served SPA container: keep listen >=1024, chown the 4 paths above, USER nginx. Contract change: PORT <1024 now fails to bind — flag BREAKING. Alt base: nginxinc/nginx-unprivileged.
## LRN-031 | 2026-07-12 | Build toolchain in dependencies inflates prod CVE audit surface
vite + @vitejs/plugin-react-swc + @tailwindcss/vite sat in dependencies → `pnpm audit --prod` reported their CVEs as prod findings. Build-time-only packages belong in devDependencies; SPA runtime imports none of them.
**Why:** tour 2026-07-12 cso posture audit — all 3 "prod" advisories were build-toolchain. Moved 187dfb5; build+tests green, prod audit clean.
**How to apply:** scaffold check: anything imported only by vite.config / build pipeline → devDependencies. Then `pnpm audit --prod` reflects real runtime surface. Docker multi-stage unaffected (builder installs all).
+9 -5
View File
@@ -38,6 +38,10 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
- [x] pathology-editor.html prod 404 fixed — served from public/ so it ships to dist (2803cf7, LRN-029)
- [x] gitflow socle + pre-commit hook adopted (4991c10)
### Tour + fixes 2026-07-12 (branch chore/tour-2026-07-12 — UNMERGED, review pending)
- [x] /tour sweep: CVE deps patched (pnpm audit 0), SVG import sanitized, container non-root (**BREAKING: PORT >=1024**), nginx:1.31-alpine pin, dead code −93 lines (canvg dropped), docs synced. Report: .claude/audits/TOUR.md
- [x] Post-tour fixes: aria-labels i18n (B-1/B-2), EN PDF title prefix (B-4), SvgEditor placeholders (B-5), species labelEn (B-6), draft restore (B-3, TDD), entrypoint escaping (SEC-9), PDF decompression cap (SEC-8, TDD), dead BoneState + 22 unused PNGs (CLN-6/7). 180/180 tests.
---
## Phase A — DONE (kept for reference)
@@ -47,7 +51,7 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
- [x] Anatomy: parseSvgBones, loadSvg, svgToPng raster
- [x] Zustand store: full action set (initReport, hydrateReport, observation CRUD,
conclusion/recommendations/nextAppointment setters, identity setters)
- [x] sessionStorage draft mirror + localStorage practitioner cache
- [x] sessionStorage draft mirror + localStorage practitioner cache (restore path was missing until f58a49f 2026-07-12 — refresh now keeps the session)
- [x] UI primitives: Button, Card, Dialog, Input, Label, Select, Textarea, Badge, Chip
- [x] Canvas: AnatomyCanvas (data-state highlighting, async-mount safe), DetailModal
- [x] Observation chain: ObservationList, ObservationCard, PathologyPicker (flat — REMOVED, replaced by FindingsTreePicker B2),
@@ -123,7 +127,7 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
- [ ] PDF QA manual pass: full flow → export → re-import roundtrip
- Fonts embed, JSON attached, multi-SVG grid OK, locale FR + EN exports
- [x] Docker build + compose up smoke test (VPS cold build validated — BLK-005, 990c8e7; local smoke not separately logged)
- [ ] env-var brand identity verified
- [x] env-var brand identity verified (tour 2026-07-12: docker run APP_BRAND_NAME=TourCheck → env.js correct, non-root; hostile-quotes case covered by 0214ae1)
- [x] README finalize (install, dev, Docker, env vars, locale, MIT)
- [x] CHANGELOG 0.1.0 entry
- [x] docs/PATHOLOGIES-FORMAT.md — schema doc + authoring guide (initial shipped 70f21cc 2026-05-20; refreshed for v2.0 boolean-only contract 2026-05-21 — scope section, 5 taxonomy patterns, structural rules, breaking-change notice, horse stats, changelog v1.0→v2.0)
@@ -144,9 +148,9 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
## Memory cross-refs
- BDR-001..BDR-008 — decisions registry
- LRN-001..LRN-010 — learnings registry
- BLK-001..BLK-004 — blockers (all resolved)
- BDR-001..BDR-022 — decisions registry
- LRN-001..LRN-031 — learnings registry
- BLK-001..BLK-005 — blockers (all resolved)
Apply when implementing B-phase:
- LRN-004 (data-anno-special opaque to parser) — zone IDs in JSON must match SVG `data-anno-id`
+2
View File
@@ -1,2 +1,4 @@
shamefully-hoist=false
strict-peer-dependencies=false
# Supply-chain guard: only install package versions published >= 24h ago
minimum-release-age=1440
+11
View File
@@ -21,10 +21,21 @@ Versions follow [Semantic Versioning](https://semver.org/).
- **Responsive mobile** — full phone/tablet adaptation across all components.
- **Project renamed** Zoosteo → Faunosteo across the whole codebase.
### Removed
- **`canvg` dependency** — PDF SVG rasterization now uses the browser's native `Image`/`canvas` pipeline (`src/pdf/render/svgToPng.ts`) instead of the `canvg` library.
### Fixed
- **`pathology-editor.html` 404 in production** — it lived at the repo root, Vite never bundled it into `dist/`; moved to `public/` so it ships (LRN-029).
- **Docker species caching** — `Cache-Control: no-cache` header added for `/species/` assets so an updated catalog is served fresh.
- **nginx runner base image** pinned to `nginx:1.31-alpine` (was the floating `nginx:alpine` tag).
### Security
- **Docker container runs fully as non-root** (`USER nginx`) — `PORT` must now be `>=1024` (default `8080` unaffected).
- **Supply-chain guard** — `.npmrc` gained `minimum-release-age=1440`, blocking install of package versions published less than 24h ago.
- **User-imported SVGs sanitized** — the SVG editor and the standalone pathology editor now strip `<script>`/`<foreignObject>` nodes, `on*` event-handler attributes, and `javascript:` hrefs before inserting an imported SVG into the DOM.
---
+11 -12
View File
@@ -29,7 +29,7 @@ MVP species: equine only. Open-source MIT.
| State | Zustand | 5 |
| Validation | Zod | 3 |
| PDF | pdf-lib | 1.17 |
| SVG raster | canvg | 4 |
| SVG raster | native Image/canvas (no dependency) | — |
| Animation | motion | 11 |
| Tests | vitest + happy-dom + @testing-library/react | 3.x |
| Deploy | Docker multi-stage → nginx:alpine | — |
@@ -77,8 +77,8 @@ docker compose up --build
docker compose down
```
Note: pnpm binary at `~/.local/share/pnpm/bin/pnpm` on dev host (corepack broken).
Add it to PATH: `export PATH="$HOME/.local/share/pnpm/bin:$PATH"`.
Note: pnpm binary at `~/.local/bin/pnpm` on dev host (corepack broken).
It is normally already on PATH; otherwise `export PATH="$HOME/.local/bin:$PATH"`.
---
@@ -113,7 +113,7 @@ osteo/
├─ src/
│ ├─ app/
│ │ ├─ App.tsx ← root router
│ │ ├─ routes/{Home,NewReport,Editor,SvgEditor,NotFound}Route.tsx
│ │ ├─ routes/{Home,NewReport,Editor,Editors,SvgEditor,NotFound}Route.tsx
│ │ └─ providers/ConfigProvider.tsx ← AppConfig context
│ ├─ config/env.ts ← runtime config resolution
│ ├─ domain/
@@ -139,20 +139,20 @@ osteo/
│ ├─ anatomy/
│ │ ├─ types.ts ← Bone, BoneCategory, BoneState
│ │ ├─ svgConvention.ts ← parseSvgBones()
│ │ ├─ svgLoader.ts ← loadSvg(), svgToPngDataUrl()
│ │ ├─ svgLoader.ts ← loadSvg()
│ │ └─ labels.ts ← boneLabel(bone, locale, fallback)
│ ├─ components/
│ │ ├─ ui/{Button,Card,Dialog,Input,Label,Select,Textarea,Badge,Chip}.tsx
│ │ ├─ canvas/{AnatomyCanvas,DetailModal}.tsx
│ │ ├─ observation/{ObservationList,ObservationCard,FindingsTreePicker,
│ │ │ VertebraPicker,SeveritySelector,
│ │ │ VertebraPicker,SeveritySelector,LateralityPicker,
│ │ │ FreeTextFindingInput}.tsx
│ │ ├─ report/{ReportHeader,PractitionerForm,AnimalForm,
│ │ │ ConclusionPanel,NextAppointmentPicker}.tsx
│ │ └─ brand/{Brand,LanguageSwitcher}.tsx
│ │ └─ brand/{Brand,AppHeader,Footer,LanguageSwitcher}.tsx
│ ├─ pdf/
│ │ ├─ export.ts + import.ts + attachment.ts + fonts.ts
│ │ └─ render/{header,footer,observationPage,conclusionPage,svgToPng}.ts
│ │ └─ render/{header,footer,observationPage,conclusionPage,svgToPng,text,logo,linkAnnotation}.ts
│ ├─ lib/{dates,id,assert,zoneMatch,spineZones}.ts
│ ├─ styles/{index,tokens,svg-editor}.css ← Tailwind v4 CSS-first + SVG editor styles
│ └─ main.tsx
@@ -253,7 +253,7 @@ Runtime config
### Schemas
- domain/schema/*.ts are the data contracts — never change without bumping version
- All user-provided data goes through Zod parse before hitting the store
- ReportSchema.version = 1 for MVP; future breaking changes → version 2
- ReportSchema.version = 2 (v1 attachments rejected at import with a typed error); future breaking changes → version 3
### Stores
- No direct store mutation outside Zustand actions
@@ -302,7 +302,6 @@ Runtime config
| zustand 5 | Lightweight global state |
| zod 3 | Schema validation + type inference |
| pdf-lib 1.17 | Pure-JS PDF generation + native attachments |
| canvg 4 | SVG → Canvas rasterization for PDF |
| motion 11 | Animations (modals, toasts, observation cards) |
| vitest 3 | Test runner |
| happy-dom | DOM environment for tests |
@@ -321,8 +320,8 @@ Runtime config
- Never modify anatomy SVGs in public/species/ — they are source assets from the user.
- Pathology DB entries must be source-cited before commit; client review required for MVP batch.
- Ask before any change to importReportFromPdf or extractReportJson — these handle user data.
- After PDF roundtrip tests fail: check attachment bytes, then Zod validation, then pako decompression.
- pnpm binary: `~/.local/share/pnpm/bin/pnpm` on dev host. Add to PATH in shell profile.
- After PDF roundtrip tests fail: check attachment bytes, then Zod validation, then DecompressionStream inflation.
- pnpm binary: `~/.local/bin/pnpm` on dev host (normally already on PATH).
## Commit message convention
+5 -4
View File
@@ -5,7 +5,8 @@ TLS. The container serves a static SPA bundle from `/usr/share/nginx/html`
and a runtime-injected `env.js`; there is no backend, no database, no
persistent server-side state. Praticien data lives in the browser
(`sessionStorage` / `localStorage`) and in the exported PDFs themselves
(JSON attached natively to each PDF).
(JSON attached natively to each PDF). The container runs entirely as a
non-root `nginx` user — no process is root after the image is built.
---
@@ -13,7 +14,7 @@ persistent server-side state. Praticien data lives in the browser
| Service | Image source | Port (container) | Port (host) | Role |
| ------- | ----------------------------------------- | ---------------- | --------------- | ----------------------------------------------------------------------------------- |
| `app` | local build (multi-stage `Dockerfile`) | `${PORT:-8080}` | `${PORT:-8080}` | Serves the SPA (`dist/`) + runtime `env.js`. nginx:alpine inside, SPA fallback to `index.html`. |
| `app` | local build (multi-stage `Dockerfile`) | `${PORT:-8080}` | `${PORT:-8080}` | Serves the SPA (`dist/`) + runtime `env.js`. `nginx:1.31-alpine` inside, runs as non-root `nginx` user, SPA fallback to `index.html`. |
The host should publish only ports `22`, `80`, `443` to the internet. The
container port (`8080` by default) should stay loopback-only — the host
@@ -34,7 +35,7 @@ each one explicitly.
| `APP_BRAND_NAME` | yes | `Faunosteo` | Header brand block, PDF header. Praticien-visible identity. |
| `APP_FOOTER_NAME` | yes | `Faunosteo` | Footer copyright line. |
| `APP_TAGLINE` | yes | `Outils pour ostéopathes animaliers` | Hero tagline on Home. |
| `PORT` | no | `8080` | Container listen port. Override to relocate the loopback bind. |
| `PORT` | no | `8080` | Container listen port. Must be `>=1024` — the container runs as a non-root `nginx` user and cannot bind privileged ports. |
No secrets are required — there is no API, no DB, no provider credential.
The `.env` file is not sensitive but should still be `chmod 600` to keep
@@ -176,7 +177,7 @@ VPS is the path:
```bash
cd ~/faunosteo
git fetch origin
git reset --hard origin/master # default branch is "master" on this remote
git reset --hard origin/main # default branch is "main" on this remote
docker compose up --build -d
docker image prune -f # reclaim old build layers
```
+10 -4
View File
@@ -16,7 +16,7 @@ COPY . .
RUN pnpm build
# ---- stage 2: runner ------------------------------------------------
FROM nginx:alpine AS runner
FROM nginx:1.31-alpine AS runner
# Copy built static assets
COPY --from=builder /app/dist /usr/share/nginx/html
@@ -25,10 +25,16 @@ COPY --from=builder /app/dist /usr/share/nginx/html
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Run fully as non-root (port 8080 is unprivileged). nginx needs to own:
# its runtime dirs, the config it rewrites at startup (PORT envsubst),
# and the html dir (entrypoint writes env.js there).
RUN chmod +x /entrypoint.sh \
&& touch /var/run/nginx.pid \
&& chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid \
/etc/nginx/conf.d /usr/share/nginx/html
USER nginx
# Drop root: nginx master runs as root for port binding, workers as nginx
# The entrypoint writes env.js before exec-ing nginx
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]
+1 -2
View File
@@ -24,7 +24,7 @@ contract.
- **Hierarchical findings tree** — per-zone picker with breadcrumb drill-down through the expert-authored catalog (26 zones for the horse), vet-referral badges on sensitive leaves, scope-disclaimer modal once per session
- **Vertebra picker** — region tabs (C/T/L/S/Cd) with multi-select chip grid for precise vertebral notation
- **Detail popups** — click a zone (e.g. head) to open a secondary SVG with finer-grained zones
- **PDF export** — A4 portrait with rasterized anatomy SVGs (canvg @ 2×), structured observations, and the full report JSON as a native PDF attachment
- **PDF export** — A4 portrait with rasterized anatomy SVGs (native browser `Image`/`canvas` pipeline), structured observations, and the full report JSON as a native PDF attachment
- **PDF re-import** — open a previously exported PDF to restore the session for a follow-up
- **Bilingual UI** — full FR/EN interface with a one-click language switcher; default locale auto-detected from the browser, then persisted
- **Configurable identity** — site name, brand, footer, tagline all come from env vars; nothing hardcoded
@@ -46,7 +46,6 @@ contract.
- Zustand 5 (state)
- Zod 3 (schema + runtime validation)
- pdf-lib 1.17 (PDF generation + native attachments)
- canvg 4 (SVG → canvas rasterization)
- motion 11 (animations)
- vitest 3 + happy-dom + @testing-library/react
+15 -4
View File
@@ -7,12 +7,23 @@ set -e
ENV_JS="/usr/share/nginx/html/env.js"
# Escapes a value for safe embedding in a double-quoted JS string literal
# (backslashes, double quotes; newlines collapsed to spaces).
js_escape() {
printf '%s' "$1" | tr '\n' ' ' | sed 's/\\/\\\\/g; s/"/\\"/g'
}
SITE_NAME=$(js_escape "${APP_SITE_NAME:-Faunosteo}")
BRAND_NAME=$(js_escape "${APP_BRAND_NAME:-Faunosteo}")
FOOTER_NAME=$(js_escape "${APP_FOOTER_NAME:-Faunosteo}")
TAGLINE=$(js_escape "${APP_TAGLINE:-Outils pour ostéopathes animaliers}")
cat > "$ENV_JS" <<EOF
window.__APP_CONFIG__ = {
siteName: "${APP_SITE_NAME:-Faunosteo}",
brandName: "${APP_BRAND_NAME:-Faunosteo}",
footerName: "${APP_FOOTER_NAME:-Faunosteo}",
tagline: "${APP_TAGLINE:-Outils pour ostéopathes animaliers}"
siteName: "${SITE_NAME}",
brandName: "${BRAND_NAME}",
footerName: "${FOOTER_NAME}",
tagline: "${TAGLINE}"
};
EOF
+2 -1
View File
@@ -113,9 +113,10 @@ files by absolute path starting with `/species/...`.
import type { SpeciesManifest } from '@/domain/species/types'
import { CANINE_VERTEBRAL_FORMULA } from './vertebrae'
export const canine: SpeciesManifest = {
const canine: SpeciesManifest = {
id: 'canine',
labelFr: 'Chien',
labelEn: 'Dog',
mainSvg: '/species/canine/Dog.svg',
details: {
head: '/species/canine/Dog_head.svg',
+5 -6
View File
@@ -20,33 +20,32 @@
"scaffold:species": "node scripts/scaffold-species.mjs"
},
"dependencies": {
"@tailwindcss/vite": "^4.3.0",
"@vitejs/plugin-react-swc": "^3.7.2",
"canvg": "^4.0.2",
"motion": "^11.11.17",
"pdf-lib": "^1.17.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^7.1.1",
"vite": "^7.0.0",
"zod": "^3.24.1",
"zustand": "^5.0.2"
},
"devDependencies": {
"@tailwindcss/vite": "^4.3.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^20.19.41",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
"@vitejs/plugin-react-swc": "^3.7.2",
"eslint": "^9.17.0",
"eslint-plugin-react": "^7.37.3",
"eslint-plugin-react-hooks": "^5.1.0",
"globals": "^15.14.0",
"happy-dom": "^16.3.0",
"happy-dom": "^20.10.6",
"prettier": "^3.4.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.19.0",
"vitest": "^3.0.0"
"vite": "^7.3.6",
"vitest": "^3.2.7"
}
}
+228 -236
View File
@@ -8,15 +8,6 @@ importers:
.:
dependencies:
'@tailwindcss/vite':
specifier: ^4.3.0
version: 4.3.0(vite@7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))
'@vitejs/plugin-react-swc':
specifier: ^3.7.2
version: 3.11.0(vite@7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))
canvg:
specifier: ^4.0.2
version: 4.0.3
motion:
specifier: ^11.11.17
version: 11.18.2(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
@@ -32,9 +23,6 @@ importers:
react-router-dom:
specifier: ^7.1.1
version: 7.15.1(react-dom@19.2.6(react@19.2.6))(react@19.2.6)
vite:
specifier: ^7.0.0
version: 7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
zod:
specifier: ^3.24.1
version: 3.25.76
@@ -42,6 +30,9 @@ importers:
specifier: ^5.0.2
version: 5.0.13(@types/react@19.2.14)(react@19.2.6)
devDependencies:
'@tailwindcss/vite':
specifier: ^4.3.0
version: 4.3.0(vite@7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))
'@testing-library/jest-dom':
specifier: ^6.6.3
version: 6.9.1
@@ -60,6 +51,9 @@ importers:
'@types/react-dom':
specifier: ^19.0.1
version: 19.2.3(@types/react@19.2.14)
'@vitejs/plugin-react-swc':
specifier: ^3.7.2
version: 3.11.0(vite@7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))
eslint:
specifier: ^9.17.0
version: 9.39.4(jiti@2.7.0)
@@ -73,8 +67,8 @@ importers:
specifier: ^15.14.0
version: 15.15.0
happy-dom:
specifier: ^16.3.0
version: 16.8.1
specifier: ^20.10.6
version: 20.10.6
prettier:
specifier: ^3.4.2
version: 3.8.3
@@ -84,9 +78,12 @@ importers:
typescript-eslint:
specifier: ^8.19.0
version: 8.59.3(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3)
vite:
specifier: ^7.3.6
version: 7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
vitest:
specifier: ^3.0.0
version: 3.2.4(@types/node@20.19.41)(happy-dom@16.8.1)(jiti@2.7.0)(lightningcss@1.32.0)
specifier: ^3.2.7
version: 3.2.7(@types/node@20.19.41)(happy-dom@20.10.6)(jiti@2.7.0)(lightningcss@1.32.0)
packages:
@@ -105,158 +102,158 @@ packages:
resolution: {integrity: sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==}
engines: {node: '>=6.9.0'}
'@esbuild/aix-ppc64@0.27.7':
resolution: {integrity: sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==}
'@esbuild/aix-ppc64@0.28.1':
resolution: {integrity: sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [aix]
'@esbuild/android-arm64@0.27.7':
resolution: {integrity: sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==}
'@esbuild/android-arm64@0.28.1':
resolution: {integrity: sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [android]
'@esbuild/android-arm@0.27.7':
resolution: {integrity: sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==}
'@esbuild/android-arm@0.28.1':
resolution: {integrity: sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==}
engines: {node: '>=18'}
cpu: [arm]
os: [android]
'@esbuild/android-x64@0.27.7':
resolution: {integrity: sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==}
'@esbuild/android-x64@0.28.1':
resolution: {integrity: sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==}
engines: {node: '>=18'}
cpu: [x64]
os: [android]
'@esbuild/darwin-arm64@0.27.7':
resolution: {integrity: sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==}
'@esbuild/darwin-arm64@0.28.1':
resolution: {integrity: sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==}
engines: {node: '>=18'}
cpu: [arm64]
os: [darwin]
'@esbuild/darwin-x64@0.27.7':
resolution: {integrity: sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==}
'@esbuild/darwin-x64@0.28.1':
resolution: {integrity: sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [darwin]
'@esbuild/freebsd-arm64@0.27.7':
resolution: {integrity: sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==}
'@esbuild/freebsd-arm64@0.28.1':
resolution: {integrity: sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==}
engines: {node: '>=18'}
cpu: [arm64]
os: [freebsd]
'@esbuild/freebsd-x64@0.27.7':
resolution: {integrity: sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==}
'@esbuild/freebsd-x64@0.28.1':
resolution: {integrity: sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [freebsd]
'@esbuild/linux-arm64@0.27.7':
resolution: {integrity: sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==}
'@esbuild/linux-arm64@0.28.1':
resolution: {integrity: sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==}
engines: {node: '>=18'}
cpu: [arm64]
os: [linux]
'@esbuild/linux-arm@0.27.7':
resolution: {integrity: sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==}
'@esbuild/linux-arm@0.28.1':
resolution: {integrity: sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==}
engines: {node: '>=18'}
cpu: [arm]
os: [linux]
'@esbuild/linux-ia32@0.27.7':
resolution: {integrity: sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==}
'@esbuild/linux-ia32@0.28.1':
resolution: {integrity: sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==}
engines: {node: '>=18'}
cpu: [ia32]
os: [linux]
'@esbuild/linux-loong64@0.27.7':
resolution: {integrity: sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==}
'@esbuild/linux-loong64@0.28.1':
resolution: {integrity: sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==}
engines: {node: '>=18'}
cpu: [loong64]
os: [linux]
'@esbuild/linux-mips64el@0.27.7':
resolution: {integrity: sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==}
'@esbuild/linux-mips64el@0.28.1':
resolution: {integrity: sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==}
engines: {node: '>=18'}
cpu: [mips64el]
os: [linux]
'@esbuild/linux-ppc64@0.27.7':
resolution: {integrity: sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==}
'@esbuild/linux-ppc64@0.28.1':
resolution: {integrity: sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [linux]
'@esbuild/linux-riscv64@0.27.7':
resolution: {integrity: sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==}
'@esbuild/linux-riscv64@0.28.1':
resolution: {integrity: sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==}
engines: {node: '>=18'}
cpu: [riscv64]
os: [linux]
'@esbuild/linux-s390x@0.27.7':
resolution: {integrity: sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==}
'@esbuild/linux-s390x@0.28.1':
resolution: {integrity: sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==}
engines: {node: '>=18'}
cpu: [s390x]
os: [linux]
'@esbuild/linux-x64@0.27.7':
resolution: {integrity: sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==}
'@esbuild/linux-x64@0.28.1':
resolution: {integrity: sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==}
engines: {node: '>=18'}
cpu: [x64]
os: [linux]
'@esbuild/netbsd-arm64@0.27.7':
resolution: {integrity: sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==}
'@esbuild/netbsd-arm64@0.28.1':
resolution: {integrity: sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==}
engines: {node: '>=18'}
cpu: [arm64]
os: [netbsd]
'@esbuild/netbsd-x64@0.27.7':
resolution: {integrity: sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==}
'@esbuild/netbsd-x64@0.28.1':
resolution: {integrity: sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==}
engines: {node: '>=18'}
cpu: [x64]
os: [netbsd]
'@esbuild/openbsd-arm64@0.27.7':
resolution: {integrity: sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==}
'@esbuild/openbsd-arm64@0.28.1':
resolution: {integrity: sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openbsd]
'@esbuild/openbsd-x64@0.27.7':
resolution: {integrity: sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==}
'@esbuild/openbsd-x64@0.28.1':
resolution: {integrity: sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==}
engines: {node: '>=18'}
cpu: [x64]
os: [openbsd]
'@esbuild/openharmony-arm64@0.27.7':
resolution: {integrity: sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==}
'@esbuild/openharmony-arm64@0.28.1':
resolution: {integrity: sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openharmony]
'@esbuild/sunos-x64@0.27.7':
resolution: {integrity: sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==}
'@esbuild/sunos-x64@0.28.1':
resolution: {integrity: sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==}
engines: {node: '>=18'}
cpu: [x64]
os: [sunos]
'@esbuild/win32-arm64@0.27.7':
resolution: {integrity: sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==}
'@esbuild/win32-arm64@0.28.1':
resolution: {integrity: sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==}
engines: {node: '>=18'}
cpu: [arm64]
os: [win32]
'@esbuild/win32-ia32@0.27.7':
resolution: {integrity: sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==}
'@esbuild/win32-ia32@0.28.1':
resolution: {integrity: sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==}
engines: {node: '>=18'}
cpu: [ia32]
os: [win32]
'@esbuild/win32-x64@0.27.7':
resolution: {integrity: sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==}
'@esbuild/win32-x64@0.28.1':
resolution: {integrity: sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==}
engines: {node: '>=18'}
cpu: [x64]
os: [win32]
@@ -719,9 +716,6 @@ packages:
'@types/node@20.19.41':
resolution: {integrity: sha512-ECymXOukMnOoVkC2bb1Vc/w/836DXncOg5m8Xj1RH7xSHZJWNYY6Zh7EH477vcnD5egKNNfy2RpNOmuChhFPgQ==}
'@types/raf@3.4.3':
resolution: {integrity: sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==}
'@types/react-dom@19.2.3':
resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==}
peerDependencies:
@@ -730,6 +724,12 @@ packages:
'@types/react@19.2.14':
resolution: {integrity: sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==}
'@types/whatwg-mimetype@3.0.2':
resolution: {integrity: sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==}
'@types/ws@8.18.1':
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
'@typescript-eslint/eslint-plugin@8.59.3':
resolution: {integrity: sha512-PwFvSKsXGShKGW6n5bZOhGHEcCZXM8HofLK9fNsEwZXzFRjoY+XT1Vsf1zgyXdwTr0ZYz1/2tkZ0DBTT9jZjhw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -794,11 +794,11 @@ packages:
peerDependencies:
vite: ^4 || ^5 || ^6 || ^7
'@vitest/expect@3.2.4':
resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==}
'@vitest/expect@3.2.7':
resolution: {integrity: sha512-E8eBXaKibuvH2pSZErOjdVb5vF4PbKYcrnluBTYxEk1l/VhhwZg1kZQsdtjq+CsF5CFydf2Rdkz7jDHKSisi3w==}
'@vitest/mocker@3.2.4':
resolution: {integrity: sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==}
'@vitest/mocker@3.2.7':
resolution: {integrity: sha512-Trr0hYO9CM3Wj6ksWHRhK9IZpIY6wTMO5u/MqXurMxT57sWBaOPEtP3Oq60ihZuh5JsiagKfz95OcxdEP6dBrA==}
peerDependencies:
msw: ^2.4.9
vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0
@@ -808,20 +808,20 @@ packages:
vite:
optional: true
'@vitest/pretty-format@3.2.4':
resolution: {integrity: sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==}
'@vitest/pretty-format@3.2.7':
resolution: {integrity: sha512-KUHlwqVu0sRlhCdyPdQ/wBoTfRahjUky1MubOmYw9fWfIZy1gNoHpuaaQBPAaMaVYdQYHJLurzj8ECCj5OwTqA==}
'@vitest/runner@3.2.4':
resolution: {integrity: sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==}
'@vitest/runner@3.2.7':
resolution: {integrity: sha512-sB9y4ovltoQP+WaUPwmSxO9WIg9Ig694Di5PalVPsYHklAdE027mehpWF2SQSVq+k6sFgaivbTjTJwZLSHbedA==}
'@vitest/snapshot@3.2.4':
resolution: {integrity: sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==}
'@vitest/snapshot@3.2.7':
resolution: {integrity: sha512-7C+MwShwtBSI5Buwoyg3s/iY1eHL9PKAf+O1wVh/TdnjXUtkoL/9YQtre90i4MtNXM6edP1wJ2zOBpfCyhIS7g==}
'@vitest/spy@3.2.4':
resolution: {integrity: sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==}
'@vitest/spy@3.2.7':
resolution: {integrity: sha512-Q2eQGI6d2L/hBtZ0qNuKcAGid68XK6cv1xsoaIma6PaJhHPoqcEJhYpXZ/5myCMqkNgtP6UKuBhbc0nHKnrkuQ==}
'@vitest/utils@3.2.4':
resolution: {integrity: sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==}
'@vitest/utils@3.2.7':
resolution: {integrity: sha512-x6BDOd7dyo3PFLY3I9/HJ25X/6OurhGXk2/B9gOZNPF7XDVjeBK4k01lQE5uvDpbuheErh91qYuE1E2OEjK3Rw==}
acorn-jsx@5.3.2:
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
@@ -912,6 +912,10 @@ packages:
resolution: {integrity: sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==}
engines: {node: 18 || 20 || >=22}
buffer-image-size@0.6.4:
resolution: {integrity: sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==}
engines: {node: '>=4.0'}
cac@6.7.14:
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
engines: {node: '>=8'}
@@ -932,10 +936,6 @@ packages:
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
engines: {node: '>=6'}
canvg@4.0.3:
resolution: {integrity: sha512-fKzMoMBwus3CWo1Uy8XJc4tqqn98RoRrGV6CsIkaNiQT5lOeHuMh4fOt+LXLzn2Wqtr4p/c2TOLz4xtu4oBlFA==}
engines: {node: '>=12.0.0'}
chai@5.3.3:
resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==}
engines: {node: '>=18'}
@@ -1034,6 +1034,10 @@ packages:
resolution: {integrity: sha512-QyL119InA+XXEkNLNTPCXPugSvOfhwv0JOlGNzvxs0hZaiHLNvXSpudUWsOlsXGWJh8G6ckCScEkVHfX3kw/2Q==}
engines: {node: '>=10.13.0'}
entities@7.0.1:
resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==}
engines: {node: '>=0.12'}
es-abstract@1.24.2:
resolution: {integrity: sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==}
engines: {node: '>= 0.4'}
@@ -1069,8 +1073,8 @@ packages:
resolution: {integrity: sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==}
engines: {node: '>= 0.4'}
esbuild@0.27.7:
resolution: {integrity: sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==}
esbuild@0.28.1:
resolution: {integrity: sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==}
engines: {node: '>=18'}
hasBin: true
@@ -1248,9 +1252,9 @@ packages:
graceful-fs@4.2.11:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
happy-dom@16.8.1:
resolution: {integrity: sha512-n0QrmT9lD81rbpKsyhnlz3DgnMZlaOkJPpgi746doA+HvaMC79bdWkwjrNnGJRvDrWTI8iOcJiVTJ5CdT/AZRw==}
engines: {node: '>=18.0.0'}
happy-dom@20.10.6:
resolution: {integrity: sha512-6QD0ilzDDt93tX44y8tbmZdAcdTRYDhUP+Asgi6pC8Pp5IA3cvaZGyoVN/EGtlq9ziT65iPuBBn3ASLr6hCgVw==}
engines: {node: '>=20.0.0'}
has-bigints@1.1.0:
resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==}
@@ -1419,8 +1423,8 @@ packages:
js-tokens@9.0.1:
resolution: {integrity: sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==}
js-yaml@4.1.1:
resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==}
js-yaml@4.3.0:
resolution: {integrity: sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==}
hasBin: true
json-buffer@3.0.1:
@@ -1660,9 +1664,6 @@ packages:
pdf-lib@1.17.1:
resolution: {integrity: sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==}
performance-now@2.1.0:
resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==}
picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
@@ -1698,9 +1699,6 @@ packages:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'}
raf@3.4.1:
resolution: {integrity: sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==}
react-dom@19.2.6:
resolution: {integrity: sha512-0prMI+hvBbPjsWnxDLxlCGyM8PN6UuWjEUCYmZhO67xIV9Xasa/r/vDnq+Xyq4Lo27g8QSbO5YzARu0D1Sps3g==}
peerDependencies:
@@ -1754,10 +1752,6 @@ packages:
engines: {node: '>= 0.4'}
hasBin: true
rgbcolor@1.0.1:
resolution: {integrity: sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==}
engines: {node: '>= 0.8.15'}
rollup@4.60.4:
resolution: {integrity: sha512-WHeFSbZYsPu3+bLoNRUuAO+wavNlocOPf3wSHTP7hcFKVnJeWsYlCDbr3mTS14FCizf9ccIxXA8sGL8zKeQN3g==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
@@ -1836,10 +1830,6 @@ packages:
stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
stackblur-canvas@2.7.0:
resolution: {integrity: sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==}
engines: {node: '>=0.1.14'}
std-env@3.10.0:
resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==}
@@ -1885,10 +1875,6 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
svg-pathdata@6.0.3:
resolution: {integrity: sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==}
engines: {node: '>=12.0.0'}
tailwindcss@4.3.0:
resolution: {integrity: sha512-y6nxMGB1nMW9R6k96e5gdIFzcfL/gTJRNaqGes1YvkLnPVXzWgbqFF2yLC0T8G774n24cx3Pe8XrKoniCOAH+Q==}
@@ -1977,8 +1963,8 @@ packages:
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
hasBin: true
vite@7.3.3:
resolution: {integrity: sha512-/4XH147Ui7OGTjg3HbdWe5arnZQSbfuRzdr9Ec7TQi5I7R+ir0Rlc9GIvD4v0XZurELqA035KVXJXpR61xhiTA==}
vite@7.3.6:
resolution: {integrity: sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
peerDependencies:
@@ -2017,16 +2003,16 @@ packages:
yaml:
optional: true
vitest@3.2.4:
resolution: {integrity: sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==}
vitest@3.2.7:
resolution: {integrity: sha512-KrxIJ62Fd89gfysR4WotlgZABiz2dqFPgqGzX7s+CwsqLFomRH7777ZcrOD6+WVAh7khPQP41A+BKbpcJFrdEg==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@types/debug': ^4.1.12
'@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0
'@vitest/browser': 3.2.4
'@vitest/ui': 3.2.4
'@vitest/browser': 3.2.7
'@vitest/ui': 3.2.7
happy-dom: '*'
jsdom: '*'
peerDependenciesMeta:
@@ -2045,10 +2031,6 @@ packages:
jsdom:
optional: true
webidl-conversions@7.0.0:
resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==}
engines: {node: '>=12'}
whatwg-mimetype@3.0.0:
resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==}
engines: {node: '>=12'}
@@ -2083,6 +2065,18 @@ packages:
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
engines: {node: '>=0.10.0'}
ws@8.21.0:
resolution: {integrity: sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
yocto-queue@0.1.0:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
@@ -2122,82 +2116,82 @@ snapshots:
'@babel/runtime@7.29.2': {}
'@esbuild/aix-ppc64@0.27.7':
'@esbuild/aix-ppc64@0.28.1':
optional: true
'@esbuild/android-arm64@0.27.7':
'@esbuild/android-arm64@0.28.1':
optional: true
'@esbuild/android-arm@0.27.7':
'@esbuild/android-arm@0.28.1':
optional: true
'@esbuild/android-x64@0.27.7':
'@esbuild/android-x64@0.28.1':
optional: true
'@esbuild/darwin-arm64@0.27.7':
'@esbuild/darwin-arm64@0.28.1':
optional: true
'@esbuild/darwin-x64@0.27.7':
'@esbuild/darwin-x64@0.28.1':
optional: true
'@esbuild/freebsd-arm64@0.27.7':
'@esbuild/freebsd-arm64@0.28.1':
optional: true
'@esbuild/freebsd-x64@0.27.7':
'@esbuild/freebsd-x64@0.28.1':
optional: true
'@esbuild/linux-arm64@0.27.7':
'@esbuild/linux-arm64@0.28.1':
optional: true
'@esbuild/linux-arm@0.27.7':
'@esbuild/linux-arm@0.28.1':
optional: true
'@esbuild/linux-ia32@0.27.7':
'@esbuild/linux-ia32@0.28.1':
optional: true
'@esbuild/linux-loong64@0.27.7':
'@esbuild/linux-loong64@0.28.1':
optional: true
'@esbuild/linux-mips64el@0.27.7':
'@esbuild/linux-mips64el@0.28.1':
optional: true
'@esbuild/linux-ppc64@0.27.7':
'@esbuild/linux-ppc64@0.28.1':
optional: true
'@esbuild/linux-riscv64@0.27.7':
'@esbuild/linux-riscv64@0.28.1':
optional: true
'@esbuild/linux-s390x@0.27.7':
'@esbuild/linux-s390x@0.28.1':
optional: true
'@esbuild/linux-x64@0.27.7':
'@esbuild/linux-x64@0.28.1':
optional: true
'@esbuild/netbsd-arm64@0.27.7':
'@esbuild/netbsd-arm64@0.28.1':
optional: true
'@esbuild/netbsd-x64@0.27.7':
'@esbuild/netbsd-x64@0.28.1':
optional: true
'@esbuild/openbsd-arm64@0.27.7':
'@esbuild/openbsd-arm64@0.28.1':
optional: true
'@esbuild/openbsd-x64@0.27.7':
'@esbuild/openbsd-x64@0.28.1':
optional: true
'@esbuild/openharmony-arm64@0.27.7':
'@esbuild/openharmony-arm64@0.28.1':
optional: true
'@esbuild/sunos-x64@0.27.7':
'@esbuild/sunos-x64@0.28.1':
optional: true
'@esbuild/win32-arm64@0.27.7':
'@esbuild/win32-arm64@0.28.1':
optional: true
'@esbuild/win32-ia32@0.27.7':
'@esbuild/win32-ia32@0.28.1':
optional: true
'@esbuild/win32-x64@0.27.7':
'@esbuild/win32-x64@0.28.1':
optional: true
'@eslint-community/eslint-utils@4.9.1(eslint@9.39.4(jiti@2.7.0))':
@@ -2231,7 +2225,7 @@ snapshots:
globals: 14.0.0
ignore: 5.3.2
import-fresh: 3.3.1
js-yaml: 4.1.1
js-yaml: 4.3.0
minimatch: 3.1.5
strip-json-comments: 3.1.1
transitivePeerDependencies:
@@ -2487,12 +2481,12 @@ snapshots:
'@tailwindcss/oxide-win32-arm64-msvc': 4.3.0
'@tailwindcss/oxide-win32-x64-msvc': 4.3.0
'@tailwindcss/vite@4.3.0(vite@7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))':
'@tailwindcss/vite@4.3.0(vite@7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))':
dependencies:
'@tailwindcss/node': 4.3.0
'@tailwindcss/oxide': 4.3.0
tailwindcss: 4.3.0
vite: 7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
vite: 7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
'@testing-library/dom@10.4.1':
dependencies:
@@ -2547,8 +2541,6 @@ snapshots:
dependencies:
undici-types: 6.21.0
'@types/raf@3.4.3': {}
'@types/react-dom@19.2.3(@types/react@19.2.14)':
dependencies:
'@types/react': 19.2.14
@@ -2557,6 +2549,12 @@ snapshots:
dependencies:
csstype: 3.2.3
'@types/whatwg-mimetype@3.0.2': {}
'@types/ws@8.18.1':
dependencies:
'@types/node': 20.19.41
'@typescript-eslint/eslint-plugin@8.59.3(@typescript-eslint/parser@8.59.3(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.4(jiti@2.7.0))(typescript@5.9.3)':
dependencies:
'@eslint-community/regexpp': 4.12.2
@@ -2648,53 +2646,53 @@ snapshots:
'@typescript-eslint/types': 8.59.3
eslint-visitor-keys: 5.0.1
'@vitejs/plugin-react-swc@3.11.0(vite@7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))':
'@vitejs/plugin-react-swc@3.11.0(vite@7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))':
dependencies:
'@rolldown/pluginutils': 1.0.0-beta.27
'@swc/core': 1.15.33
vite: 7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
vite: 7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
transitivePeerDependencies:
- '@swc/helpers'
'@vitest/expect@3.2.4':
'@vitest/expect@3.2.7':
dependencies:
'@types/chai': 5.2.3
'@vitest/spy': 3.2.4
'@vitest/utils': 3.2.4
'@vitest/spy': 3.2.7
'@vitest/utils': 3.2.7
chai: 5.3.3
tinyrainbow: 2.0.0
'@vitest/mocker@3.2.4(vite@7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))':
'@vitest/mocker@3.2.7(vite@7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))':
dependencies:
'@vitest/spy': 3.2.4
'@vitest/spy': 3.2.7
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
vite: 7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
vite: 7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
'@vitest/pretty-format@3.2.4':
'@vitest/pretty-format@3.2.7':
dependencies:
tinyrainbow: 2.0.0
'@vitest/runner@3.2.4':
'@vitest/runner@3.2.7':
dependencies:
'@vitest/utils': 3.2.4
'@vitest/utils': 3.2.7
pathe: 2.0.3
strip-literal: 3.1.0
'@vitest/snapshot@3.2.4':
'@vitest/snapshot@3.2.7':
dependencies:
'@vitest/pretty-format': 3.2.4
'@vitest/pretty-format': 3.2.7
magic-string: 0.30.21
pathe: 2.0.3
'@vitest/spy@3.2.4':
'@vitest/spy@3.2.7':
dependencies:
tinyspy: 4.0.4
'@vitest/utils@3.2.4':
'@vitest/utils@3.2.7':
dependencies:
'@vitest/pretty-format': 3.2.4
'@vitest/pretty-format': 3.2.7
loupe: 3.2.1
tinyrainbow: 2.0.0
@@ -2805,6 +2803,10 @@ snapshots:
dependencies:
balanced-match: 4.0.4
buffer-image-size@0.6.4:
dependencies:
'@types/node': 20.19.41
cac@6.7.14: {}
call-bind-apply-helpers@1.0.2:
@@ -2826,14 +2828,6 @@ snapshots:
callsites@3.1.0: {}
canvg@4.0.3:
dependencies:
'@types/raf': 3.4.3
raf: 3.4.1
rgbcolor: 1.0.1
stackblur-canvas: 2.7.0
svg-pathdata: 6.0.3
chai@5.3.3:
dependencies:
assertion-error: 2.0.1
@@ -2930,6 +2924,8 @@ snapshots:
graceful-fs: 4.2.11
tapable: 2.3.3
entities@7.0.1: {}
es-abstract@1.24.2:
dependencies:
array-buffer-byte-length: 1.0.2
@@ -3033,34 +3029,34 @@ snapshots:
is-date-object: 1.1.0
is-symbol: 1.1.1
esbuild@0.27.7:
esbuild@0.28.1:
optionalDependencies:
'@esbuild/aix-ppc64': 0.27.7
'@esbuild/android-arm': 0.27.7
'@esbuild/android-arm64': 0.27.7
'@esbuild/android-x64': 0.27.7
'@esbuild/darwin-arm64': 0.27.7
'@esbuild/darwin-x64': 0.27.7
'@esbuild/freebsd-arm64': 0.27.7
'@esbuild/freebsd-x64': 0.27.7
'@esbuild/linux-arm': 0.27.7
'@esbuild/linux-arm64': 0.27.7
'@esbuild/linux-ia32': 0.27.7
'@esbuild/linux-loong64': 0.27.7
'@esbuild/linux-mips64el': 0.27.7
'@esbuild/linux-ppc64': 0.27.7
'@esbuild/linux-riscv64': 0.27.7
'@esbuild/linux-s390x': 0.27.7
'@esbuild/linux-x64': 0.27.7
'@esbuild/netbsd-arm64': 0.27.7
'@esbuild/netbsd-x64': 0.27.7
'@esbuild/openbsd-arm64': 0.27.7
'@esbuild/openbsd-x64': 0.27.7
'@esbuild/openharmony-arm64': 0.27.7
'@esbuild/sunos-x64': 0.27.7
'@esbuild/win32-arm64': 0.27.7
'@esbuild/win32-ia32': 0.27.7
'@esbuild/win32-x64': 0.27.7
'@esbuild/aix-ppc64': 0.28.1
'@esbuild/android-arm': 0.28.1
'@esbuild/android-arm64': 0.28.1
'@esbuild/android-x64': 0.28.1
'@esbuild/darwin-arm64': 0.28.1
'@esbuild/darwin-x64': 0.28.1
'@esbuild/freebsd-arm64': 0.28.1
'@esbuild/freebsd-x64': 0.28.1
'@esbuild/linux-arm': 0.28.1
'@esbuild/linux-arm64': 0.28.1
'@esbuild/linux-ia32': 0.28.1
'@esbuild/linux-loong64': 0.28.1
'@esbuild/linux-mips64el': 0.28.1
'@esbuild/linux-ppc64': 0.28.1
'@esbuild/linux-riscv64': 0.28.1
'@esbuild/linux-s390x': 0.28.1
'@esbuild/linux-x64': 0.28.1
'@esbuild/netbsd-arm64': 0.28.1
'@esbuild/netbsd-x64': 0.28.1
'@esbuild/openbsd-arm64': 0.28.1
'@esbuild/openbsd-x64': 0.28.1
'@esbuild/openharmony-arm64': 0.28.1
'@esbuild/sunos-x64': 0.28.1
'@esbuild/win32-arm64': 0.28.1
'@esbuild/win32-ia32': 0.28.1
'@esbuild/win32-x64': 0.28.1
escape-string-regexp@4.0.0: {}
@@ -3264,10 +3260,18 @@ snapshots:
graceful-fs@4.2.11: {}
happy-dom@16.8.1:
happy-dom@20.10.6:
dependencies:
webidl-conversions: 7.0.0
'@types/node': 20.19.41
'@types/whatwg-mimetype': 3.0.2
'@types/ws': 8.18.1
buffer-image-size: 0.6.4
entities: 7.0.1
whatwg-mimetype: 3.0.0
ws: 8.21.0
transitivePeerDependencies:
- bufferutil
- utf-8-validate
has-bigints@1.1.0: {}
@@ -3435,7 +3439,7 @@ snapshots:
js-tokens@9.0.1: {}
js-yaml@4.1.1:
js-yaml@4.3.0:
dependencies:
argparse: 2.0.1
@@ -3649,8 +3653,6 @@ snapshots:
pako: 1.0.11
tslib: 1.14.1
performance-now@2.1.0: {}
picocolors@1.1.1: {}
picomatch@4.0.4: {}
@@ -3681,10 +3683,6 @@ snapshots:
punycode@2.3.1: {}
raf@3.4.1:
dependencies:
performance-now: 2.1.0
react-dom@19.2.6(react@19.2.6):
dependencies:
react: 19.2.6
@@ -3746,8 +3744,6 @@ snapshots:
path-parse: 1.0.7
supports-preserve-symlinks-flag: 1.0.0
rgbcolor@1.0.1: {}
rollup@4.60.4:
dependencies:
'@types/estree': 1.0.8
@@ -3868,8 +3864,6 @@ snapshots:
stackback@0.0.2: {}
stackblur-canvas@2.7.0: {}
std-env@3.10.0: {}
stop-iteration-iterator@1.1.0:
@@ -3937,8 +3931,6 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {}
svg-pathdata@6.0.3: {}
tailwindcss@4.3.0: {}
tapable@2.3.3: {}
@@ -4035,7 +4027,7 @@ snapshots:
debug: 4.4.3
es-module-lexer: 1.7.0
pathe: 2.0.3
vite: 7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
vite: 7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
transitivePeerDependencies:
- '@types/node'
- jiti
@@ -4050,9 +4042,9 @@ snapshots:
- tsx
- yaml
vite@7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0):
vite@7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0):
dependencies:
esbuild: 0.27.7
esbuild: 0.28.1
fdir: 6.5.0(picomatch@4.0.4)
picomatch: 4.0.4
postcss: 8.5.14
@@ -4064,16 +4056,16 @@ snapshots:
jiti: 2.7.0
lightningcss: 1.32.0
vitest@3.2.4(@types/node@20.19.41)(happy-dom@16.8.1)(jiti@2.7.0)(lightningcss@1.32.0):
vitest@3.2.7(@types/node@20.19.41)(happy-dom@20.10.6)(jiti@2.7.0)(lightningcss@1.32.0):
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.4
'@vitest/mocker': 3.2.4(vite@7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
'@vitest/spy': 3.2.4
'@vitest/utils': 3.2.4
'@vitest/expect': 3.2.7
'@vitest/mocker': 3.2.7(vite@7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0))
'@vitest/pretty-format': 3.2.7
'@vitest/runner': 3.2.7
'@vitest/snapshot': 3.2.7
'@vitest/spy': 3.2.7
'@vitest/utils': 3.2.7
chai: 5.3.3
debug: 4.4.3
expect-type: 1.3.0
@@ -4086,12 +4078,12 @@ snapshots:
tinyglobby: 0.2.16
tinypool: 1.1.1
tinyrainbow: 2.0.0
vite: 7.3.3(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
vite: 7.3.6(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
vite-node: 3.2.4(@types/node@20.19.41)(jiti@2.7.0)(lightningcss@1.32.0)
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 20.19.41
happy-dom: 16.8.1
happy-dom: 20.10.6
transitivePeerDependencies:
- jiti
- less
@@ -4106,8 +4098,6 @@ snapshots:
- tsx
- yaml
webidl-conversions@7.0.0: {}
whatwg-mimetype@3.0.0: {}
which-boxed-primitive@1.1.1:
@@ -4162,6 +4152,8 @@ snapshots:
word-wrap@1.2.5: {}
ws@8.21.0: {}
yocto-queue@0.1.0: {}
zod@3.25.76: {}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

+5 -2
View File
@@ -1125,9 +1125,12 @@
clearChildren(canvasInner);
var imported = document.importNode(svg, true);
imported.querySelectorAll('script, foreignObject').forEach(function (e) { e.remove(); });
imported.querySelectorAll('*').forEach(function (e) {
[imported].concat(Array.prototype.slice.call(imported.querySelectorAll('*'))).forEach(function (e) {
for (var i = e.attributes.length - 1; i >= 0; i--) {
if (e.attributes[i].name.match(/^on/i)) e.removeAttribute(e.attributes[i].name);
var a = e.attributes[i];
var isHandler = a.name.match(/^on/i);
var isJsHref = a.name.match(/href$/i) && a.value.match(/^\s*javascript:/i);
if (isHandler || isJsHref) e.removeAttribute(a.name);
}
});
canvasInner.appendChild(imported);
+6 -3
View File
@@ -65,16 +65,17 @@ function capitalize(s) {
return s.charAt(0).toUpperCase() + s.slice(1)
}
function indexTs({ id, labelFr, mainSvgPath, details, formulaConstName }) {
function indexTs({ id, labelFr, labelEn, mainSvgPath, details, formulaConstName }) {
const detailLines = details
.map((d) => ` ${d.key}: '${d.path}',`)
.join('\n')
return `import type { SpeciesManifest } from '@/domain/species/types'
import { ${formulaConstName} } from './vertebrae'
export const ${id}: SpeciesManifest = {
const ${id}: SpeciesManifest = {
id: '${id}',
labelFr: '${labelFr.replace(/'/g, "\\'")}',
labelEn: '${labelEn.replace(/'/g, "\\'")}',
mainSvg: '${mainSvgPath}',
details: {
${detailLines}
@@ -83,6 +84,8 @@ ${detailLines}
findings: () => import('./pathologies'),
}
// Default export is the convention picked up by the registry's
// import.meta.glob() auto-discovery.
export default ${id}
`
}
@@ -184,7 +187,7 @@ async function main() {
const formulaConstName = `${id.replace(/-/g, '_').toUpperCase()}_VERTEBRAL_FORMULA`
const speciesDir = resolve(PROJECT_ROOT, 'src/domain/species', id)
const targets = {
'index.ts': indexTs({ id, labelFr, mainSvgPath, details, formulaConstName }),
'index.ts': indexTs({ id, labelFr, labelEn, mainSvgPath, details, formulaConstName }),
'vertebrae.ts': vertebraeTs({ formulaConstName, labelFr, formula }),
'pathologies.ts': pathologiesTs(),
'pathologies.json': pathologiesJsonTemplate({ id, labelFr, labelEn }),
+2 -2
View File
@@ -1,4 +1,5 @@
import type { Locale } from '@/i18n/types'
import { pickLocaleLabel } from '@/i18n/pickLocaleLabel'
import type { Bone } from './types'
/**
@@ -14,6 +15,5 @@ export function boneLabel(
fallback: string,
): string {
if (!bone) return fallback
if (locale === 'en') return bone.en || bone.fr || fallback
return bone.fr || bone.en || fallback
return pickLocaleLabel(bone.fr, bone.en, locale, fallback)
}
+2 -8
View File
@@ -12,7 +12,7 @@ import type { Bone, BoneCategory } from './types'
* string is accepted. New SVGs are free to introduce new categories
* without touching this parser.
*/
export function validateBoneElement(el: Element): void {
function validateBoneElement(el: Element): void {
const boneId = el.getAttribute('data-anno-id') ?? ''
if (!boneId) {
throw new SvgConventionError(
@@ -94,13 +94,7 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map<string, Bone> {
* annotated element.
*/
export function getBoneIdFromEvent(event: Event): string | null {
let node = event.target as Element | null
while (node && node.nodeType === 1) {
const id = node.getAttribute?.('data-anno-id')
if (id) return id
node = node.parentElement
}
return null
return getAnnotatedElement(event)?.getAttribute('data-anno-id') || null
}
export function getAnnotatedElement(event: Event): Element | null {
+2 -2
View File
@@ -39,8 +39,8 @@ export interface Bone {
els: Element[]
}
/** Visual state applied to SVG elements for multi-observation colorization. */
export type BoneState = 'current' | 'linked' | 'multi' | 'default'
/** Visual state applied to SVG elements (active-observation highlight). */
export type BoneState = 'current' | 'default'
/** Error thrown when SVG violates the convention. */
export class SvgConventionError extends Error {
+117 -82
View File
@@ -3,9 +3,8 @@ import { useNavigate } from 'react-router-dom'
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
import DetailModal from '@/components/canvas/DetailModal'
import ObservationList from '@/components/observation/ObservationList'
import VertebraPicker, {
regionFromLabel,
} from '@/components/observation/VertebraPicker'
import VertebraPicker from '@/components/observation/VertebraPicker'
import { regionFromLabel } from '@/lib/spineZones'
import LateralityPicker from '@/components/observation/LateralityPicker'
import type { LateralSide } from '@/domain/schema/observation'
import ConclusionPanel from '@/components/report/ConclusionPanel'
@@ -22,6 +21,7 @@ import { parseSvgBones } from '@/anatomy/svgConvention'
import { collectSpineVertebrae, syncSpineZones } from '@/lib/spineZones'
import type { Bone, BoneState } from '@/anatomy/types'
import type { Observation, ObservationZone } from '@/domain/schema/observation'
import type { Report } from '@/domain/schema/report'
import type { SpeciesFindings } from '@/domain/schema/findings'
import type { Practitioner } from '@/domain/schema/practitioner'
import type { Animal, Owner } from '@/domain/schema/animal'
@@ -32,6 +32,15 @@ import { boneLabel } from '@/anatomy/labels'
const DISCLAIMER_FLAG = 'osteo:disclaimer-shown'
/** Merges newly parsed bones into the accumulated map without overwriting. */
function mergeBones(prev: Map<string, Bone>, parsed: Map<string, Bone>) {
const merged = new Map(prev)
parsed.forEach((b, id) => {
if (!merged.has(id)) merged.set(id, b)
})
return merged
}
export default function EditorRoute() {
const navigate = useNavigate()
const t = useT()
@@ -135,13 +144,7 @@ export default function EditorRoute() {
loadSvg(path)
.then((root) => {
const parsed = parseSvgBones(root)
setDetailBones((prev) => {
const merged = new Map(prev)
parsed.forEach((b, id) => {
if (!merged.has(id)) merged.set(id, b)
})
return merged
})
setDetailBones((prev) => mergeBones(prev, parsed))
})
.catch((err) => {
console.warn(`EditorRoute: failed to preload detail SVG ${path}`, err)
@@ -162,13 +165,7 @@ export default function EditorRoute() {
loadSvg(detail.src).then((root) => {
if (cancelled) return
const parsed = parseSvgBones(root)
setDetailBones((prev) => {
const merged = new Map(prev)
parsed.forEach((b, id) => {
if (!merged.has(id)) merged.set(id, b)
})
return merged
})
setDetailBones((prev) => mergeBones(prev, parsed))
})
return () => {
cancelled = true
@@ -201,78 +198,84 @@ export default function EditorRoute() {
setActiveObservation(activeIndex === index ? -1 : index)
}
function onZoneClick(boneId: string, detailSourceId?: string) {
if (!report) return
const bone = bones.get(boneId) ?? detailBones.get(boneId)
if (!bone) return
/** Opens the detail-popup modal for a bone that carries data-anno-opens-detail. */
function handleDetailOpen(bone: Bone, detailId: string, detailSrc: string) {
setDetail({
id: detailId,
src: detailSrc,
title: boneLabel(bone, locale, detailId),
})
}
if (bone.opensDetail && species?.details[bone.opensDetail]) {
setDetail({
id: bone.opensDetail,
src: species.details[bone.opensDetail],
title: boneLabel(bone, locale, bone.opensDetail),
})
return
}
/**
* No expanded observation — auto-expand the most recent one (or the
* first if no rows yet) so the click lands somewhere. Defers the actual
* zone add to the next render where activeObs is set.
*/
function activateFallbackObservation(report: Report) {
const fallbackIndex =
report.observations.length > 0 ? report.observations.length - 1 : -1
if (fallbackIndex < 0) return
setActiveObservation(fallbackIndex)
}
if (!activeObs || activeIndex < 0) {
// No expanded observation — auto-expand the most recent one (or the
// first if no rows yet) so the click lands somewhere.
const fallbackIndex =
report.observations.length > 0 ? report.observations.length - 1 : -1
if (fallbackIndex < 0) return
setActiveObservation(fallbackIndex)
// Defer the actual zone add to the next render where activeObs is set.
return
}
const matches = (z: ObservationZone) =>
z.boneId === boneId && z.detailSourceId === detailSourceId
const existingIndex = activeObs.zones.findIndex(matches)
if (bone.special === 'vertebral-precision') {
// Spine-zone behavior: always open VertebraPicker on click. Add the
// zone if missing; never toggle it off here (use the ✕ button).
let targetIndex = existingIndex
if (existingIndex < 0) {
const newZone: ObservationZone = {
boneId,
...(detailSourceId ? { detailSourceId } : {}),
}
const nextZones = [...activeObs.zones, newZone]
targetIndex = nextZones.length - 1
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
}
setVertebraTarget(targetIndex)
return
}
if (bone.lateral === 'bilateral') {
const sidesPresent = activeObs.zones
.filter(
(z) =>
z.boneId === boneId &&
z.detailSourceId === detailSourceId,
)
.map((z) => z.side)
.filter(Boolean) as LateralSide[]
if (sidesPresent.includes('left') && sidesPresent.includes('right')) {
const nextZones = activeObs.zones.filter(
(z) =>
!(z.boneId === boneId && z.detailSourceId === detailSourceId),
)
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
return
}
setLateralTarget({
/**
* Spine-zone behavior: always open VertebraPicker on click. Adds the
* zone if missing; never toggles it off here (use the ✕ button).
*/
function handleSpineZone(
activeObs: Observation,
boneId: string,
detailSourceId: string | undefined,
existingIndex: number,
) {
let targetIndex = existingIndex
if (existingIndex < 0) {
const newZone: ObservationZone = {
boneId,
...(detailSourceId ? { detailSourceId } : {}),
})
}
const nextZones = [...activeObs.zones, newZone]
targetIndex = nextZones.length - 1
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
}
setVertebraTarget(targetIndex)
}
/** Bilateral zone: adding a side, or clearing both once left+right are set. */
function handleBilateralZone(
activeObs: Observation,
boneId: string,
detailSourceId: string | undefined,
) {
const sidesPresent = activeObs.zones
.filter(
(z) => z.boneId === boneId && z.detailSourceId === detailSourceId,
)
.map((z) => z.side)
.filter(Boolean) as LateralSide[]
if (sidesPresent.includes('left') && sidesPresent.includes('right')) {
const nextZones = activeObs.zones.filter(
(z) => !(z.boneId === boneId && z.detailSourceId === detailSourceId),
)
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
return
}
setLateralTarget({
boneId,
...(detailSourceId ? { detailSourceId } : {}),
})
}
/** Plain zone: toggles it on the active observation. */
function toggleZone(
activeObs: Observation,
boneId: string,
detailSourceId: string | undefined,
existingIndex: number,
) {
const newZone: ObservationZone = {
boneId,
...(detailSourceId ? { detailSourceId } : {}),
@@ -284,6 +287,38 @@ export default function EditorRoute() {
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
}
function onZoneClick(boneId: string, detailSourceId?: string) {
if (!report) return
const bone = bones.get(boneId) ?? detailBones.get(boneId)
if (!bone) return
if (bone.opensDetail && species?.details[bone.opensDetail]) {
handleDetailOpen(bone, bone.opensDetail, species.details[bone.opensDetail])
return
}
if (!activeObs || activeIndex < 0) {
activateFallbackObservation(report)
return
}
const matches = (z: ObservationZone) =>
z.boneId === boneId && z.detailSourceId === detailSourceId
const existingIndex = activeObs.zones.findIndex(matches)
if (bone.special === 'vertebral-precision') {
handleSpineZone(activeObs, boneId, detailSourceId, existingIndex)
return
}
if (bone.lateral === 'bilateral') {
handleBilateralZone(activeObs, boneId, detailSourceId)
return
}
toggleZone(activeObs, boneId, detailSourceId, existingIndex)
}
async function onExport() {
if (!report) return
setExporting(true)
+36 -10
View File
@@ -4,7 +4,8 @@ import AppHeader from '@/components/brand/AppHeader'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import { getDict } from '@/i18n/index'
import { getAllSpecies } from '@/domain/species/registry'
import type { Locale } from '@/i18n/types'
import { getAllSpecies, speciesLabel } from '@/domain/species/registry'
import '@/styles/svg-editor.css'
type TFn = (key: string) => string
@@ -35,7 +36,7 @@ export default function SvgEditorRoute() {
const dict = getDict(locale)
const tFn: TFn = (key: string) => dict[key] ?? key
const cleanup = initSvgEditor(canvas, canvasInner, sidebar, tFn)
const cleanup = initSvgEditor(canvas, canvasInner, sidebar, tFn, locale)
cleanupRef.current = cleanup
return () => {
@@ -143,15 +144,24 @@ export default function SvgEditorRoute() {
</label>
<div id="svg-editor-detail-target-row" style={{ display: 'none', marginTop: '8px' }}>
<label>{t('svg_editor.detail_id_label')}</label>
<input id="svg-editor-edit-detail-target" placeholder="head" />
<input
id="svg-editor-edit-detail-target"
placeholder={t('svg_editor.detail_id_placeholder')}
/>
</div>
</div>
<div id="svg-editor-osteo-fields">
<label>{t('svg_editor.name_fr')}</label>
<input id="svg-editor-edit-fr" placeholder="ex: Hanche" />
<input
id="svg-editor-edit-fr"
placeholder={t('svg_editor.name_fr_placeholder')}
/>
<label>{t('svg_editor.name_en')}</label>
<input id="svg-editor-edit-en" placeholder="ex: Hip joint" />
<input
id="svg-editor-edit-en"
placeholder={t('svg_editor.name_en_placeholder')}
/>
<label>{t('svg_editor.category')}</label>
<select id="svg-editor-edit-category" />
<label>{t('svg_editor.lateral')}</label>
@@ -239,6 +249,7 @@ function initSvgEditor(
canvasInner: HTMLDivElement,
_sidebar: HTMLDivElement,
t: TFn,
locale: Locale,
): () => void {
const ac = new AbortController()
const sig = { signal: ac.signal }
@@ -392,13 +403,13 @@ function initSvgEditor(
}
function buildProjectPicker(container: HTMLElement) {
const speciesLabel = document.createElement('label')
speciesLabel.textContent = t('svg_editor.species')
const speciesLabelEl = document.createElement('label')
speciesLabelEl.textContent = t('svg_editor.species')
const speciesSel = document.createElement('select')
speciesList.forEach((sp) => {
const opt = document.createElement('option')
opt.value = sp.id
opt.textContent = sp.labelFr
opt.textContent = speciesLabel(sp, locale)
speciesSel.appendChild(opt)
})
@@ -450,7 +461,7 @@ function initSvgEditor(
})
})
container.append(speciesLabel, speciesSel, viewLabel, viewSel, loadBtn)
container.append(speciesLabelEl, speciesSel, viewLabel, viewSel, loadBtn)
}
function buildUploadPicker(container: HTMLElement) {
@@ -495,6 +506,19 @@ function initSvgEditor(
}, sig)
}
/** Strip active content from an untrusted SVG: scripts, foreignObject,
* event-handler attributes (root included) and javascript: hrefs. */
function sanitizeSvg(root: Element) {
root.querySelectorAll('script, foreignObject').forEach((el) => el.remove())
for (const el of [root, ...root.querySelectorAll('*')]) {
for (const attr of [...el.attributes]) {
const isHandler = /^on/i.test(attr.name)
const isJsHref = /href$/i.test(attr.name) && /^\s*javascript:/i.test(attr.value)
if (isHandler || isJsHref) el.removeAttribute(attr.name)
}
}
}
function loadSVG(svgText: string) {
const parser = new DOMParser()
const doc = parser.parseFromString(svgText, 'image/svg+xml')
@@ -505,8 +529,10 @@ function initSvgEditor(
return
}
const imported = document.importNode(parsedSvg, true)
sanitizeSvg(imported)
canvasInner.textContent = ''
canvasInner.appendChild(document.importNode(parsedSvg, true))
canvasInner.appendChild(imported)
svgRoot = canvasInner.querySelector('svg')
if (!svgRoot) {
alert(t('svg_editor.alert_invalid_svg'))
+4 -1
View File
@@ -1,10 +1,13 @@
import { useConfig } from '@/app/providers/ConfigProvider'
const HEIGHT = { sm: 'h-7', md: 'h-9', lg: 'h-11' } as const
export default function Brand({ size = 'md' }: { size?: 'sm' | 'md' | 'lg' }) {
const { brandName } = useConfig()
return (
<img
src="/logo-horizontal.svg"
alt="Faunosteo"
alt={brandName}
className={`${HEIGHT[size]} w-auto`}
/>
)
+8 -6
View File
@@ -1,18 +1,20 @@
import { useLocaleStore } from '@/state/localeStore'
import { useT } from '@/i18n/useT'
import type { Locale } from '@/i18n/types'
const ITEMS: { value: Locale; label: string; ariaLabel: string }[] = [
{ value: 'fr', label: 'FR', ariaLabel: 'Passer en français' },
{ value: 'en', label: 'EN', ariaLabel: 'Switch to English' },
const ITEMS: { value: Locale; labelKey: string; ariaKey: string }[] = [
{ value: 'fr', labelKey: 'lang.fr', ariaKey: 'lang.switch_to_fr' },
{ value: 'en', labelKey: 'lang.en', ariaKey: 'lang.switch_to_en' },
]
export default function LanguageSwitcher() {
const locale = useLocaleStore((s) => s.locale)
const setLocale = useLocaleStore((s) => s.setLocale)
const t = useT()
return (
<div
role="group"
aria-label="Language"
aria-label={t('lang.group_label')}
className="inline-flex rounded-full border border-[var(--color-border)] overflow-hidden text-xs font-medium"
>
{ITEMS.map((item) => {
@@ -21,7 +23,7 @@ export default function LanguageSwitcher() {
<button
key={item.value}
type="button"
aria-label={item.ariaLabel}
aria-label={t(item.ariaKey)}
aria-pressed={active}
onClick={() => setLocale(item.value)}
className={[
@@ -31,7 +33,7 @@ export default function LanguageSwitcher() {
: 'text-[var(--color-ink)] hover:bg-[var(--color-surface-strong)]',
].join(' ')}
>
{item.label}
{t(item.labelKey)}
</button>
)
})}
+2 -1
View File
@@ -6,6 +6,7 @@ import {
} from '@/anatomy/svgConvention'
import type { BoneState } from '@/anatomy/types'
import { useLocaleStore } from '@/state/localeStore'
import { pickLocaleLabel } from '@/i18n/pickLocaleLabel'
export interface AnatomyCanvasProps {
src: string
@@ -69,7 +70,7 @@ export default function AnatomyCanvas({
if (!tip) return
const fr = el.getAttribute('data-anno-name-fr') ?? ''
const en = el.getAttribute('data-anno-name-en') ?? ''
const label = locale === 'en' ? en || fr : fr || en
const label = pickLocaleLabel(fr, en, locale)
if (!label) { tip.style.opacity = '0'; return }
tip.textContent = label
tip.style.opacity = '1'
@@ -6,8 +6,6 @@ import type { Vertebra, VertebralRegion } from '@/domain/schema/observation'
import type { VertebralFormula } from '@/domain/species/types'
import { useT } from '@/i18n/useT'
export { regionFromLabel } from '@/lib/spineZones'
const REGIONS: VertebralRegion[] = ['C', 'T', 'L', 'S', 'Cd']
const REGION_KEY: Record<VertebralRegion, string> = {
C: 'vertebra.region.C',
+4 -2
View File
@@ -2,8 +2,9 @@ import type { Animal, Owner } from '@/domain/schema/animal'
import Label from '@/components/ui/Label'
import Input from '@/components/ui/Input'
import Select from '@/components/ui/Select'
import { getAllSpecies } from '@/domain/species/registry'
import { getAllSpecies, speciesLabel } from '@/domain/species/registry'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
export interface AnimalFormProps {
animal: Animal
@@ -14,6 +15,7 @@ export interface AnimalFormProps {
export default function AnimalForm({ animal, owner, onChangeAnimal, onChangeOwner }: AnimalFormProps) {
const t = useT()
const locale = useLocaleStore((s) => s.locale)
const species = getAllSpecies()
const setA = (patch: Partial<Animal>) => onChangeAnimal({ ...animal, ...patch })
return (
@@ -29,7 +31,7 @@ export default function AnimalForm({ animal, owner, onChangeAnimal, onChangeOwne
onChange={(e) => setA({ speciesId: e.target.value })}
>
{species.map((s) => (
<option key={s.id} value={s.id}>{s.labelFr}</option>
<option key={s.id} value={s.id}>{speciesLabel(s, locale)}</option>
))}
</Select>
</div>
+3 -1
View File
@@ -1,5 +1,6 @@
import { useEffect, type ReactNode } from 'react'
import { AnimatePresence, motion } from 'motion/react'
import { useT } from '@/i18n/useT'
export interface DialogProps {
open: boolean
@@ -17,6 +18,7 @@ const SIZE: Record<NonNullable<DialogProps['size']>, string> = {
}
export default function Dialog({ open, onClose, title, children, size = 'md' }: DialogProps) {
const t = useT()
useEffect(() => {
if (!open) return
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose()
@@ -51,7 +53,7 @@ export default function Dialog({ open, onClose, title, children, size = 'md' }:
<h2 className="text-lg font-semibold text-[var(--color-ink)]">{title}</h2>
<button
type="button"
aria-label="Fermer"
aria-label={t('common.close')}
onClick={onClose}
className="rounded-md p-1 text-[var(--color-ink-muted)] hover:bg-[var(--color-surface-strong)]"
>
+3 -3
View File
@@ -1,9 +1,10 @@
import type { SpeciesManifest } from '@/domain/species/types'
import { EQUINE_VERTEBRAL_FORMULA } from './vertebrae'
export const equine: SpeciesManifest = {
const equine: SpeciesManifest = {
id: 'equine',
labelFr: 'Cheval',
labelEn: 'Horse',
mainSvg: '/species/equine/Horse.svg',
details: {
head: '/species/equine/Horse_head.svg',
@@ -13,6 +14,5 @@ export const equine: SpeciesManifest = {
}
// Default export is the convention picked up by the registry's
// import.meta.glob() auto-discovery. Keep the named export for any
// code that still imports the manifest by name.
// import.meta.glob() auto-discovery.
export default equine
+6
View File
@@ -1,4 +1,5 @@
import type { SpeciesManifest } from './types'
import type { Locale } from '@/i18n/types'
/**
* Auto-discovers every species manifest in `src/domain/species/*\/index.ts`
@@ -49,3 +50,8 @@ export function getAllSpecies(): SpeciesManifest[] {
a.labelFr.localeCompare(b.labelFr, 'fr'),
)
}
/** Display label of a species for the given locale. */
export function speciesLabel(s: SpeciesManifest, locale: Locale): string {
return locale === 'en' ? s.labelEn : s.labelFr
}
+2
View File
@@ -17,6 +17,8 @@ export interface SpeciesManifest {
id: string
/** Display name in French */
labelFr: string
/** Display name in English */
labelEn: string
/** Absolute public path to the main anatomy SVG */
mainSvg: string
/**
+6 -7
View File
@@ -2,18 +2,17 @@ import type { Dict } from './types'
export const en: Dict = {
'common.cancel': 'Cancel',
'common.close': 'Close',
'common.save': 'Save',
'common.confirm': 'Confirm',
'common.delete': 'Delete',
'common.add': 'Add',
'common.back': 'Back',
'common.home': 'Home',
'common.understood': 'Got it',
'common.collapse': 'Collapse',
'common.expand': 'Expand',
'common.move_up': 'Move up',
'common.move_down': 'Move down',
'common.none': 'None',
'common.back_to_home': 'Back to home',
'home.new_report.title': 'New report',
@@ -37,7 +36,6 @@ export const en: Dict = {
'footer.in_partnership': 'In partnership with',
// editors page
'editors.title': 'Editors',
'editors.svg.title': 'SVG Editor',
'editors.svg.description':
'Annotate an anatomical SVG file: add clickable zones, categories, and FR/EN labels.',
@@ -135,8 +133,6 @@ export const en: Dict = {
'lateral.both': 'Both',
'lateral.left_short': 'L',
'lateral.right_short': 'R',
'lateral.bilateral': 'Bilateral',
'lateral.unpaired': 'Unilateral',
'severity.aria': 'Severity',
'severity.légère': 'mild',
@@ -159,10 +155,10 @@ export const en: Dict = {
'pdf.empty': '—',
'pdf.owner_prefix': 'Owner: ',
'pdf.siret_prefix': 'SIRET ',
'pdf.export_date_prefix': 'Exported on ',
'pdf.title.suffix.bilan': 'Faunosteo — ',
'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',
'lang.fr': 'FR',
@@ -188,8 +184,11 @@ export const en: Dict = {
'svg_editor.selected_element': 'Selected element',
'svg_editor.opens_detail': 'This zone opens a detail view',
'svg_editor.detail_id_label': 'Detail view ID (e.g. head, front-leg)',
'svg_editor.detail_id_placeholder': 'head',
'svg_editor.name_fr': 'French name',
'svg_editor.name_fr_placeholder': 'e.g. Hanche',
'svg_editor.name_en': 'English name',
'svg_editor.name_en_placeholder': 'e.g. Hip joint',
'svg_editor.category': 'Category',
'svg_editor.radius': 'Radius (circle)',
'svg_editor.fill_opacity': 'Fill opacity',
+5 -6
View File
@@ -3,18 +3,17 @@ import type { Dict } from './types'
export const fr: Dict = {
// common
'common.cancel': 'Annuler',
'common.close': 'Fermer',
'common.save': 'Enregistrer',
'common.confirm': 'Valider',
'common.delete': 'Supprimer',
'common.add': 'Ajouter',
'common.back': 'Retour',
'common.home': 'Accueil',
'common.understood': 'Compris',
'common.collapse': 'Réduire',
'common.expand': 'Développer',
'common.move_up': 'Monter',
'common.move_down': 'Descendre',
'common.none': 'Aucun',
'common.back_to_home': "Retour à l'accueil",
// home
@@ -41,7 +40,6 @@ export const fr: Dict = {
'footer.in_partnership': 'En partenariat avec',
// editors page
'editors.title': 'Éditeurs',
'editors.svg.title': 'Éditeur SVG',
'editors.svg.description':
'Annoter un fichier SVG anatomique : ajouter des zones cliquables, catégories et labels FR/EN.',
@@ -149,8 +147,6 @@ export const fr: Dict = {
'lateral.both': 'Les deux',
'lateral.left_short': 'G',
'lateral.right_short': 'D',
'lateral.bilateral': 'Bilatéral',
'lateral.unpaired': 'Unilatéral',
// severity
'severity.aria': 'Sévérité',
@@ -175,11 +171,11 @@ export const fr: Dict = {
'pdf.empty': '—',
'pdf.owner_prefix': 'Propriétaire : ',
'pdf.siret_prefix': 'SIRET ',
'pdf.export_date_prefix': 'Exporté le ',
'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',
'lang.switch_to_en': 'Switch to English',
'lang.fr': 'FR',
@@ -205,8 +201,11 @@ export const fr: Dict = {
'svg_editor.selected_element': 'Elément sélectionné',
'svg_editor.opens_detail': 'Cette zone ouvre une vue détaillée',
'svg_editor.detail_id_label': 'ID vue détaillée (ex. head, front-leg)',
'svg_editor.detail_id_placeholder': 'head',
'svg_editor.name_fr': 'Nom français',
'svg_editor.name_fr_placeholder': 'ex: Hanche',
'svg_editor.name_en': 'Nom anglais',
'svg_editor.name_en_placeholder': 'ex: Hip joint',
'svg_editor.category': 'Catégorie',
'svg_editor.radius': 'Rayon (cercle)',
'svg_editor.fill_opacity': 'Opacité du remplissage',
+16
View File
@@ -0,0 +1,16 @@
import type { Locale } from './types'
/**
* Resolves a bilingual label for the active locale. Falls back to the
* opposite language when the preferred one is missing/empty, then to the
* provided fallback, so callers never render an empty string.
*/
export function pickLocaleLabel(
fr: string | undefined,
en: string | undefined,
locale: Locale,
fallback = '',
): string {
if (locale === 'en') return en || fr || fallback
return fr || en || fallback
}
-8
View File
@@ -7,11 +7,3 @@ export function assert(condition: unknown, message: string): asserts condition {
throw new Error(`Assertion failed: ${message}`)
}
}
/**
* Marks a code path as unreachable for exhaustive switch coverage.
* TypeScript will error at compile time if the path is reachable.
*/
export function assertNever(value: never, message?: string): never {
throw new Error(message ?? `Unexpected value: ${JSON.stringify(value)}`)
}
+28 -2
View File
@@ -61,11 +61,37 @@ interface RawObj {
dict?: { entries?: () => Array<[unknown, unknown]> }
}
async function inflateFlate(bytes: Uint8Array): Promise<Uint8Array | null> {
/**
* 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 = 16 * 1024 * 1024
/** 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'))
return new Uint8Array(await new Response(stream).arrayBuffer())
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
}
+5 -5
View File
@@ -130,7 +130,7 @@ export async function exportReportToPdf(
const resp = await fetch('/Paws_in_harmony.svg')
if (!resp.ok) throw new Error(`Paws logo fetch failed: HTTP ${resp.status}`)
const svgText = await resp.text()
const pawsPngBytes = await rasterizeSvg(svgText, 1)
const pawsPngBytes = await rasterizeSvg(svgText)
pawsLogoPdf = await pdfDoc.embedPng(pawsPngBytes)
} catch (err) {
console.warn('Paws in Harmony logo embed failed:', err)
@@ -140,17 +140,17 @@ export async function exportReportToPdf(
const totalObs = report.observations.length
for (let i = 0; i < totalObs; i += 1) {
await addObservationPage(
await addObservationPage({
pdfDoc,
report,
report.observations[i],
i,
observation: report.observations[i],
obsIndex: i,
fonts,
zoneLabels,
findingsTree,
locale,
headerAssets,
)
})
}
await addConclusionPage(pdfDoc, report, fonts, locale, headerAssets)
+14 -29
View File
@@ -1,42 +1,27 @@
import { rgb, PageSizes, type PDFDocument, type PDFFont } from 'pdf-lib'
import { PageSizes, type PDFDocument } from 'pdf-lib'
import type { EmbeddedFonts } from '@/pdf/fonts'
import type { Report } from '@/domain/schema/report'
import type { Locale } from '@/i18n/types'
import { getDict } from '@/i18n'
import { drawHeader, type HeaderAssets } from './header'
import { wrapLines } from './text'
import { formatDate } from '@/lib/dates'
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_X = 36
const EYEBROW_Y_OFFSET = 95
const TITLE_Y_OFFSET = 122
const TITLE_RULE_OFFSET = 12
const TITLE_RULE_WIDTH = 48
const SECTION_TOP_GAP = 28
const SECTION_LABEL_GAP = 4
const SECTION_BLOCK_GAP = 18
const TEXT_LINE_HEIGHT = 14
const COLOR_INK = rgb(0.12, 0.11, 0.09)
const COLOR_MUTED = rgb(0.42, 0.39, 0.35)
const COLOR_ACCENT = rgb(0.72, 0.35, 0.25)
function wrap(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
}
export async function addConclusionPage(
pdfDoc: PDFDocument,
report: Report,
@@ -101,7 +86,7 @@ export async function addConclusionPage(
color: COLOR_ACCENT,
})
cursorY -= SECTION_LABEL_GAP + 10
wrap(body, fonts.bodyRegular, 11, max).forEach((line) => {
wrapLines(body, fonts.bodyRegular, 11, max).forEach((line) => {
page.drawText(line, {
x: MARGIN_X,
y: cursorY,
+19
View File
@@ -0,0 +1,19 @@
import { rgb } from 'pdf-lib'
/**
* Layout and color constants shared across PDF page renderers (header,
* footer, observation page, conclusion page). Only values that are
* byte-identical across all callers live here — a same-named constant
* with a different value per file stays local to that file.
*/
export const MARGIN_X = 36
export const EYEBROW_Y_OFFSET = 95
export const TITLE_Y_OFFSET = 122
export const TITLE_RULE_OFFSET = 12
export const TITLE_RULE_WIDTH = 48
export const SECTION_LABEL_GAP = 4
export const COLOR_INK = rgb(0.12, 0.11, 0.09)
export const COLOR_MUTED = rgb(0.42, 0.39, 0.35)
export const COLOR_ACCENT = rgb(0.72, 0.35, 0.25)
+5 -6
View File
@@ -3,8 +3,8 @@ 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 MARGIN_X = 36
const FOOTER_BASE_Y = 20
const FONT_SIZE = 8
@@ -24,7 +24,6 @@ export function drawFooter(
): void {
const dict = getDict(locale)
const { width } = page.getSize()
const muted = rgb(0.42, 0.39, 0.35)
const accent = rgb(0.28, 0.56, 0.42)
const logoW = 80
@@ -72,7 +71,7 @@ export function drawFooter(
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: muted,
color: COLOR_MUTED,
})
const zqX = poweredX + poweredLabelW
if (assets.zqLogoPng) {
@@ -119,7 +118,7 @@ export function drawFooter(
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: muted,
color: COLOR_MUTED,
})
const pawsX = partnerX + partnerLabelW
page.drawImage(assets.pawsLogoPng, {
@@ -144,7 +143,7 @@ export function drawFooter(
y: textBaseY,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: muted,
color: COLOR_MUTED,
})
page.drawText(handle, {
x: partnerX + partnerLabelW,
@@ -169,6 +168,6 @@ export function drawFooter(
y: FOOTER_BASE_Y + 2,
size: FONT_SIZE,
font: fonts.bodyRegular,
color: muted,
color: COLOR_MUTED,
})
}
+5 -7
View File
@@ -1,12 +1,12 @@
import { rgb, type PDFPage, type PDFImage } from 'pdf-lib'
import type { PDFPage, PDFImage } from 'pdf-lib'
import type { EmbeddedFonts } from '@/pdf/fonts'
import type { Report } from '@/domain/schema/report'
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 MARGIN_X = 36
const TOP_Y = 800
const LOGO_WIDTH = 100
const LOGO_HEIGHT = 38
@@ -24,8 +24,6 @@ export function drawHeader(
): void {
const dict = getDict(locale)
const { width } = page.getSize()
const ink = rgb(0.12, 0.11, 0.09)
const muted = rgb(0.42, 0.39, 0.35)
const y = TOP_Y
@@ -44,7 +42,7 @@ export function drawHeader(
y: y - i * 12,
size: i === 0 ? 11 : 9,
font: i === 0 ? fonts.bodyBold : fonts.bodyRegular,
color: i === 0 ? ink : muted,
color: i === 0 ? COLOR_INK : COLOR_MUTED,
})
})
@@ -88,7 +86,7 @@ export function drawHeader(
y: y - i * 12,
size,
font,
color: i === 0 ? ink : muted,
color: i === 0 ? COLOR_INK : COLOR_MUTED,
})
})
@@ -97,6 +95,6 @@ export function drawHeader(
start: { x: MARGIN_X, y: separatorY },
end: { x: width - MARGIN_X, y: separatorY },
thickness: 0.5,
color: muted,
color: COLOR_MUTED,
})
}
+236 -128
View File
@@ -1,23 +1,32 @@
import { rgb, PageSizes, type PDFDocument, type PDFFont, type PDFPage } from 'pdf-lib'
import { rgb, PageSizes, type PDFDocument, type PDFPage, type PDFImage } from 'pdf-lib'
import type { EmbeddedFonts } from '@/pdf/fonts'
import type { Report } from '@/domain/schema/report'
import type { Finding, Observation } from '@/domain/schema/observation'
import type { SpeciesFindings } from '@/domain/schema/findings'
import type { Locale } from '@/i18n/types'
import type { SpeciesManifest } from '@/domain/species/types'
import type { Locale, Dict } from '@/i18n/types'
import { getDict } from '@/i18n'
import { pickLocaleLabel } from '@/i18n/pickLocaleLabel'
import type { ZoneLabelPair } from '@/pdf/export'
import { drawHeader, type HeaderAssets } from './header'
import { rasterizeSvg } from './svgToPng'
import { wrapLines } from './text'
import { loadSvg } from '@/anatomy/svgLoader'
import { parseSvgBones } from '@/anatomy/svgConvention'
import { getSpecies } from '@/domain/species/registry'
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_X = 36
const MARGIN_BOTTOM = 48
const EYEBROW_Y_OFFSET = 95
const TITLE_Y_OFFSET = 122
const TITLE_RULE_OFFSET = 12
const TITLE_RULE_WIDTH = 48
const IMAGE_TOP_GAP = 32
const IMAGE_LABEL_GAP = 14
const IMAGE_BOTTOM_GAP = 14
@@ -26,12 +35,8 @@ const IMAGE_ROW_GAP = 12
const IMAGE_MIN_CELL_H = 60
const TEXT_TOP_GAP = 10
const TEXT_LINE_HEIGHT = 13
const SECTION_LABEL_GAP = 4
const SECTION_BLOCK_GAP = 10
const COLOR_INK = rgb(0.12, 0.11, 0.09)
const COLOR_MUTED = rgb(0.42, 0.39, 0.35)
const COLOR_ACCENT = rgb(0.72, 0.35, 0.25)
const COLOR_WHITE = rgb(1, 1, 1)
const SEVERITY_BG: Record<string, ReturnType<typeof rgb>> = {
@@ -141,23 +146,6 @@ function drawSegmentedText(
return y - TEXT_LINE_HEIGHT
}
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
}
const SVG_NS = 'http://www.w3.org/2000/svg'
const HALO_FILTER_ID = 'osteo-halo'
@@ -203,7 +191,7 @@ function ensureHaloFilter(root: SVGSVGElement): void {
const merge = doc.createElementNS(SVG_NS, 'feMerge')
// Stack the wide halo three times so its contribution survives the
// canvg → PNG → pdf-lib pipeline (each pass attenuates alpha) and
// SVG → PNG → pdf-lib pipeline (each pass attenuates alpha) and
// still reads as a strong glow at print scale.
for (let i = 0; i < 3; i += 1) {
const n = doc.createElementNS(SVG_NS, 'feMergeNode')
@@ -266,22 +254,52 @@ async function colorizedSvgString(
return new XMLSerializer().serializeToString(root)
}
export async function addObservationPage(
pdfDoc: PDFDocument,
report: Report,
observation: Observation,
obsIndex: number,
fonts: EmbeddedFonts,
zoneLabels: Map<string, ZoneLabelPair>,
findingsTree: SpeciesFindings | null,
locale: Locale,
headerAssets: HeaderAssets,
): Promise<void> {
const dict = getDict(locale)
const page = pdfDoc.addPage(PageSizes.A4)
const { width, height } = page.getSize()
drawHeader(page, report, fonts, locale, headerAssets)
/** Parameters needed to render one observation page. */
export interface ObservationPageContext {
pdfDoc: PDFDocument
report: Report
observation: Observation
obsIndex: number
fonts: EmbeddedFonts
zoneLabels: Map<string, ZoneLabelPair>
findingsTree: SpeciesFindings | null
locale: Locale
headerAssets: HeaderAssets
}
/** Shared draw handles threaded through the observation-page sub-renderers. */
interface PageDrawContext {
page: PDFPage
fonts: EmbeddedFonts
width: number
}
/** One rasterized anatomy view (main body or a detail popup) ready to embed. */
interface RenderedImage {
label: string
img: PDFImage
aspect: number
}
/** One label/value block drawn under the images (zones, findings, comment...). */
interface ObservationSection {
label: string
value: string
}
/**
* Draws the eyebrow, index/severity title, and accent rule for an
* observation page. Returns titleY so callers can lay out the content
* below it.
*/
function drawObservationTitleBlock(
ctx: PageDrawContext,
dict: Dict,
obsIndex: number,
severity: Observation['severity'],
): 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')
@@ -299,9 +317,9 @@ export async function addObservationPage(
font: fonts.headingRegular,
color: COLOR_INK,
})
if (observation.severity) {
if (severity) {
const numW = fonts.headingRegular.widthOfTextAtSize(obsLabel, 22)
const sev = observation.severity
const sev = severity
const sevLabel = dict[`severity.${sev}`] ?? sev
const sevText = sevLabel.toUpperCase()
const sevSize = 9
@@ -333,10 +351,19 @@ export async function addObservationPage(
thickness: 2,
color: COLOR_ACCENT,
})
return titleY
}
const species = getSpecies(report.animal.speciesId)
if (!species) return
/**
* Resolves the main-body view plus every detail-popup view referenced by
* the observation, rasterizing each to a PNG ready for pdf-lib.
*/
async function buildObservationImages(
pdfDoc: PDFDocument,
species: SpeciesManifest,
observation: Observation,
dict: Dict,
): Promise<RenderedImage[]> {
const hasMainZones = observation.zones.some((z) => !z.detailSourceId)
const detailIds = Array.from(
new Set(observation.zones.map((z) => z.detailSourceId).filter(Boolean) as string[]),
@@ -356,22 +383,28 @@ export async function addObservationPage(
})
}
const rendered = await Promise.all(
return Promise.all(
items.map(async (it) => {
const svgStr = await colorizedSvgString(it.src, observation, it.sourceId)
const png = await rasterizeSvg(svgStr, 2)
const png = await rasterizeSvg(svgStr)
const img = await pdfDoc.embedPng(png)
const aspect = img.width > 0 ? img.height / img.width : 0.6
return { label: it.label, img, aspect }
}),
)
}
const zonesText = observation.zones
/** Renders the "Zones" section value: bilingual labels + vertebra/side suffixes. */
function describeObservationZones(
zones: Observation['zones'],
zoneLabels: Map<string, ZoneLabelPair>,
locale: Locale,
dict: Dict,
): string {
return zones
.map((z) => {
const pair = zoneLabels.get(z.boneId)
const label = pair
? (locale === 'en' ? pair.en || pair.fr : pair.fr || pair.en) || z.boneId
: z.boneId
const label = pickLocaleLabel(pair?.fr, pair?.en, locale, z.boneId)
const v = z.vertebrae?.length
? ` (${z.vertebrae.map((x) => `${x.region}${x.index}`).join(', ')})`
: ''
@@ -381,22 +414,28 @@ export async function addObservationPage(
return `${label}${v}${side}`
})
.join(' · ')
}
const sections: Array<{ label: string; value: string }> = [
{ label: dict['pdf.section.zones'], value: zonesText || dict['pdf.empty'] },
]
const findingsByZoneSide = new Map<string, Finding[]>()
for (const f of observation.findings) {
/** Groups findings by zone+side, one label/value section entry per group. */
function buildFindingsSections(
findings: Finding[],
findingsTree: SpeciesFindings | null,
locale: Locale,
dict: Dict,
): ObservationSection[] {
const byZoneSide = new Map<string, Finding[]>()
for (const f of findings) {
const key = f.side ? `${f.zoneId}:${f.side}` : f.zoneId
const list = findingsByZoneSide.get(key)
const list = byZoneSide.get(key)
if (list) {
list.push(f)
} else {
findingsByZoneSide.set(key, [f])
byZoneSide.set(key, [f])
}
}
for (const [key, group] of findingsByZoneSide) {
const sections: ObservationSection[] = []
for (const [key, group] of byZoneSide) {
const zoneId = key.split(':')[0]
const side = group[0]?.side
const zoneTree = findingsTree?.zones[zoneId]
@@ -420,6 +459,22 @@ export async function addObservationPage(
value,
})
}
return sections
}
/** Assembles the ordered label/value sections drawn below the images. */
function buildObservationSections(
observation: Observation,
zoneLabels: Map<string, ZoneLabelPair>,
findingsTree: SpeciesFindings | null,
locale: Locale,
dict: Dict,
): ObservationSection[] {
const zonesText = describeObservationZones(observation.zones, zoneLabels, locale, dict)
const sections: ObservationSection[] = [
{ label: dict['pdf.section.zones'], value: zonesText || dict['pdf.empty'] },
]
sections.push(...buildFindingsSections(observation.findings, findingsTree, locale, dict))
if (observation.freeTextFindings.length) {
sections.push({
@@ -434,74 +489,95 @@ export async function addObservationPage(
if (observation.comment.trim()) {
sections.push({ label: dict['pdf.section.comment'], value: observation.comment.trim() })
}
return sections
}
const maxTextW = width - MARGIN_X * 2
function estimateTextHeight(): 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
/** Estimates the vertical space the given sections will occupy once drawn. */
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
}
let cursorY = titleY - IMAGE_TOP_GAP
/**
* Lays out and draws the (up to 2-column) image grid for an observation
* page. Returns the cursor y directly below the images — unchanged from
* startY when there is nothing to draw.
*/
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
if (rendered.length > 0) {
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
// Single-image observations get rendered at half the available width
// and centered, so they don't dominate the page when the surrounding
// text is short.
const cellW = isSingle ? fullCellW / 2 : fullCellW
const singleOffsetX = isSingle ? (fullCellW - cellW) / 2 : 0
const reservedBottom = MARGIN_BOTTOM + estimateTextHeight() + IMAGE_BOTTOM_GAP
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,
)
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
// Single-image observations get rendered at half the available width
// and centered, so they don't dominate the page when the surrounding
// text is short.
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,
})
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 -= 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
})
cursorY -= rowH
if (r < rows - 1) cursorY -= IMAGE_ROW_GAP
}
cursorY -= IMAGE_BOTTOM_GAP
return cursorY
}
cursorY -= TEXT_TOP_GAP
/** Draws each label/value section, returns the cursor y below the last one. */
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,
@@ -521,12 +597,7 @@ export async function addObservationPage(
fonts,
)
} else {
const lines = wrapLines(
value,
fonts.bodyRegular,
SECTION_TEXT_SIZE,
maxTextW,
)
const lines = wrapLines(value, fonts.bodyRegular, SECTION_TEXT_SIZE, maxTextW)
for (const line of lines) {
page.drawText(line, {
x: MARGIN_X,
@@ -540,4 +611,41 @@ export async function addObservationPage(
}
cursorY -= SECTION_BLOCK_GAP
}
return cursorY
}
export async function addObservationPage(
ctx: ObservationPageContext,
): Promise<void> {
const {
pdfDoc,
report,
observation,
obsIndex,
fonts,
zoneLabels,
findingsTree,
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 species = getSpecies(report.animal.speciesId)
if (!species) return
const rendered = await buildObservationImages(pdfDoc, species, observation, dict)
const maxTextW = width - MARGIN_X * 2
const sections = buildObservationSections(observation, zoneLabels, findingsTree, 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)
}
+1 -7
View File
@@ -113,14 +113,8 @@ async function canvasToPngBytes(canvas: HTMLCanvasElement): Promise<Uint8Array>
* the inline anatomy canvas.
*
* @param svgString Serialized SVG (must declare `xmlns`)
* @param _scale Reserved — current implementation renders at a fixed
* TARGET_WIDTH derived from the viewBox; kept for API
* compatibility.
*/
export async function rasterizeSvg(
svgString: string,
_scale: number,
): Promise<Uint8Array> {
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
@@ -0,0 +1,27 @@
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
}
+17 -15
View File
@@ -36,8 +36,24 @@ function emptyObservation(): Observation {
}
}
const DRAFT_KEY = 'osteo:draft'
/** Reads the auto-saved draft back from sessionStorage (null if absent/invalid). */
export function readPersistedDraft(): Report | null {
if (typeof sessionStorage === 'undefined') return null
const raw = sessionStorage.getItem(DRAFT_KEY)
if (!raw) return null
try {
const parsed = ReportSchema.safeParse(JSON.parse(raw))
return parsed.success ? parsed.data : null
} catch {
return null
}
}
export const useReportStore = create<ReportStore>((set) => ({
report: null,
// Restore the per-tab draft so a page refresh never loses the session.
report: readPersistedDraft(),
activeObservationIndex: 0,
initReport: (draft) =>
@@ -140,8 +156,6 @@ export const useReportStore = create<ReportStore>((set) => ({
reset: () => set({ report: null, activeObservationIndex: 0 }),
}))
const DRAFT_KEY = 'osteo:draft'
useReportStore.subscribe((state) => {
if (typeof sessionStorage === 'undefined') return
if (state.report) {
@@ -150,15 +164,3 @@ useReportStore.subscribe((state) => {
sessionStorage.removeItem(DRAFT_KEY)
}
})
export function readPersistedDraft(): Report | null {
if (typeof sessionStorage === 'undefined') return null
const raw = sessionStorage.getItem(DRAFT_KEY)
if (!raw) return null
try {
const parsed = ReportSchema.safeParse(JSON.parse(raw))
return parsed.success ? parsed.data : null
} catch {
return null
}
}
-2
View File
@@ -10,8 +10,6 @@ body {
}
.svg-canvas [data-state='current'] { fill: var(--color-accent) !important; fill-opacity: 0.85 !important; }
.svg-canvas [data-state='linked'] { stroke-dasharray: 4 3; stroke: var(--color-accent); fill-opacity: 0.35 !important; }
.svg-canvas [data-state='multi'] { fill: var(--color-accent) !important; fill-opacity: 0.65 !important; stroke: var(--color-ink); stroke-width: 1.5; }
.svg-canvas [data-anno-id] { cursor: pointer; }
.svg-canvas [data-anno-id]:hover { filter: brightness(1.05); }
@@ -1,9 +1,8 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import VertebraPicker, {
regionFromLabel,
} from '@/components/observation/VertebraPicker'
import VertebraPicker from '@/components/observation/VertebraPicker'
import { regionFromLabel } from '@/lib/spineZones'
import { EQUINE_VERTEBRAL_FORMULA } from '@/domain/species/equine/vertebrae'
import { useLocaleStore } from '@/state/localeStore'
+26
View File
@@ -0,0 +1,26 @@
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()
})
})
-2
View File
@@ -48,7 +48,6 @@ describe('rasterizeSvg', () => {
const out = await rasterizeSvg(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"/>',
2,
)
expect(out).toBeInstanceOf(Uint8Array)
expect(out[0]).toBe(0x89)
@@ -79,7 +78,6 @@ describe('rasterizeSvg', () => {
const out = await rasterizeSvg(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"/>',
2,
)
expect(out[0]).toBe(0x89)
expect(out[1]).toBe(0x50)
+1
View File
@@ -6,6 +6,7 @@ describe('species registry', () => {
const eq = getSpecies('equine')
expect(eq).toBeDefined()
expect(eq?.labelFr).toBe('Cheval')
expect(eq?.labelEn).toBe('Horse')
expect(eq?.mainSvg).toBe('/species/equine/Horse.svg')
expect(eq?.details.head).toBe('/species/equine/Horse_head.svg')
expect(eq?.vertebralFormula).toEqual({ C: 7, T: 18, L: 6, S: 5, Cd: 18 })
@@ -0,0 +1,58 @@
import { describe, it, expect, beforeEach, vi } from 'vitest'
const draft = {
date: '2026-05-18',
practitioner: { name: 'Dr. Dupont' },
animal: { speciesId: 'equine', name: 'Mistral' },
owner: { name: 'Jean Martin' },
observations: [],
conclusion: '',
recommendations: '',
}
/** Fresh module instance = simulated page load. */
async function freshStore() {
const mod = await import('@/state/reportStore')
return mod.useReportStore
}
beforeEach(() => {
vi.resetModules()
sessionStorage.clear()
})
describe('reportStore draft restore', () => {
it('restores the sessionStorage draft on store init (page refresh)', async () => {
const store1 = await freshStore()
store1.getState().initReport(draft)
const saved = store1.getState().report!
vi.resetModules() // simulate refresh: new module, sessionStorage intact
const store2 = await freshStore()
expect(store2.getState().report).not.toBeNull()
expect(store2.getState().report!.id).toBe(saved.id)
expect(store2.getState().report!.animal.name).toBe('Mistral')
})
it('starts empty when the stored draft is invalid', async () => {
sessionStorage.setItem('osteo:draft', '{"version":999,"garbage":true}')
const store = await freshStore()
expect(store.getState().report).toBeNull()
})
it('starts empty when no draft exists', async () => {
const store = await freshStore()
expect(store.getState().report).toBeNull()
})
it('clears the draft after reset (no resurrection on next load)', async () => {
const store1 = await freshStore()
store1.getState().initReport(draft)
store1.getState().reset()
vi.resetModules()
const store2 = await freshStore()
expect(store2.getState().report).toBeNull()
})
})