refactor(anchor): consume extracted evidence-anchor package (EANCH-WP-0001-T05)

Replace the in-repo src/anchor/ slice with a dependency on the extracted
@citation-evidence/evidence-anchor package (link:../evidence-anchor).

- package.json: add the link dependency
- repoint all @anchor/{index,selectors,types} imports and vi.mock targets to
  the package barrel; the node-env anchor-source-roundtrip test uses the pure
  ./selectors and ./types subpaths (no pdfjs pulled into a node environment)
- drop the @anchor alias from tsconfig paths and vite resolve
- delete src/anchor/ (behavior now owned by evidence-anchor)

Verified green: pnpm typecheck, pnpm test (26 files / 95 tests), pnpm build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
tegwick 2026-07-08 21:08:27 +02:00
parent cf57a9bb50
commit d14514891e
34 changed files with 39 additions and 1708 deletions

View file

@ -28,7 +28,7 @@ import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { Selector } from "@shared/selector";
import type { PdfSelectionCapture } from "@anchor/index";
import type { PdfSelectionCapture } from "@citation-evidence/evidence-anchor";
import manifest from "../../fixtures/pdfs/manifest.json" with { type: "json" };
// ---------------------------------------------------------------------------
@ -56,8 +56,8 @@ const viewerSnapshot: ViewerSnapshot = {
onSelectionCaptured: null,
};
vi.mock("@anchor/index", async (importOriginal) => {
const original = await importOriginal<typeof import("@anchor/index")>();
vi.mock("@citation-evidence/evidence-anchor", async (importOriginal) => {
const original = await importOriginal<typeof import("@citation-evidence/evidence-anchor")>();
const MockPdfSpikeViewer = (props: ViewerProps) => {
viewerSnapshot.pdfUrl = props.pdfUrl;
viewerSnapshot.storedAnnotationIds = props.storedAnnotations.map((a) => a.id);
@ -114,7 +114,7 @@ function syntheticCaptureFor(fixturePage: number, text: string): PdfSelectionCap
async function loadApp() {
// Late import so the vi.mock calls take effect before the module graph
// pulls in @anchor / @source.
// pulls in @citation-evidence/evidence-anchor / evidence-source.
const { App } = await import("@app/App");
return render(<App />);
}