evidence-source/tests/setup-pdf-worker.ts
tegwick cb93c322c0
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
feat(pdf): extract standalone PDF ingest package (ESRC-WP-0001)
Bootstrap evidence-source from the citation-evidence src/source PDF slice.

- Headless core (src/pdf): ingest/extract/fingerprint, importing domain
  contracts from @citation-evidence/engine/shared (no local copies)
- Browser upload helpers isolated under src/browser behind a ./browser
  entry point, with an eslint boundary keeping the core browser-free
- pnpm/TS/vitest/eslint scaffold; 52 tests (contract + determinism)
- Fixtures resolved from the sibling citation-evidence checkout, not
  duplicated (real PII) — see docs/ADR-0002; suites skip when absent
- Boundary + fixture decisions recorded as docs/ADR-0001 / ADR-0002
- README/SCOPE rewritten; capability.infotech.pdf-evidence-ingest
  registered, NO_CAPABILITIES removed
- Follow-on workplans ESRC-WP-0002..0004 queued; ESRC-WP-0001 finished

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 20:55:28 +02:00

17 lines
660 B
TypeScript

/**
* Vitest setup: point PDF.js at its legacy worker bundle for Node runs.
*
* `extractPdf` deliberately does no worker setup (so the same module loads in
* browsers and Node). In Node tests we configure `GlobalWorkerOptions.workerSrc`
* here, once per test file, before any extraction runs. The legacy bundle ships
* as plain JS and works through PDF.js's fake-worker fallback when no real
* Worker is available.
*/
import { createRequire } from "node:module";
import * as pdfjs from "pdfjs-dist";
const require = createRequire(import.meta.url);
pdfjs.GlobalWorkerOptions.workerSrc = require.resolve(
"pdfjs-dist/legacy/build/pdf.worker.mjs",
);