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:
parent
cf57a9bb50
commit
d14514891e
34 changed files with 39 additions and 1708 deletions
|
|
@ -18,8 +18,8 @@ import { fileURLToPath } from "node:url";
|
|||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
|
||||
import { ingestPdf } from "@citation-evidence/evidence-source";
|
||||
import { createSelectors, resolveSelectors } from "@anchor/selectors";
|
||||
import type { PdfSelectionCapture } from "@anchor/types";
|
||||
import { createSelectors, resolveSelectors } from "@citation-evidence/evidence-anchor/selectors";
|
||||
import type { PdfSelectionCapture } from "@citation-evidence/evidence-anchor/types";
|
||||
import manifest from "../../fixtures/pdfs/manifest.json" with { type: "json" };
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
|
|
|||
|
|
@ -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 />);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import manifest from "../../fixtures/pdfs/manifest.json" with { type: "json" };
|
|||
|
||||
import { captureStateKey, loadCaptureState } from "@app/forms/capture-persistence";
|
||||
|
||||
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 = () => (
|
||||
<div data-testid="mock-pdf-viewer" />
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ 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" };
|
||||
import { seedSessionWithDoc } from "./helpers/seed-session";
|
||||
|
||||
|
|
@ -50,8 +50,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.onSelectionCaptured = props.onSelectionCaptured;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ 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" };
|
||||
|
||||
interface ViewerProps {
|
||||
|
|
@ -46,8 +46,8 @@ const viewerSnapshot: ViewerSnapshot = {
|
|||
storedAnnotationIds: [],
|
||||
};
|
||||
|
||||
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.scrollToAnnotationId = props.scrollToAnnotationId ?? null;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ 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" };
|
||||
|
||||
interface ViewerProps {
|
||||
|
|
@ -24,8 +24,8 @@ const viewerSnapshot: { onSelectionCaptured: ViewerProps["onSelectionCaptured"]
|
|||
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.onSelectionCaptured = props.onSelectionCaptured;
|
||||
return <div data-testid="mock-pdf-viewer" />;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|||
|
||||
import manifest from "../../fixtures/pdfs/manifest.json" with { type: "json" };
|
||||
|
||||
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 = () => (
|
||||
<div data-testid="mock-pdf-viewer" />
|
||||
);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ 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" };
|
||||
|
||||
interface ViewerProps {
|
||||
|
|
@ -30,8 +30,8 @@ interface ViewerSnapshot {
|
|||
|
||||
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.onSelectionCaptured = props.onSelectionCaptured;
|
||||
return <div data-testid="mock-pdf-viewer" />;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ 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" };
|
||||
|
||||
interface ViewerProps {
|
||||
|
|
@ -60,8 +60,8 @@ function fakeHighlightRect(): DOMRect {
|
|||
} as DOMRect;
|
||||
}
|
||||
|
||||
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.scrollToAnnotationId = props.scrollToAnnotationId ?? null;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ 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" };
|
||||
|
||||
interface ViewerProps {
|
||||
|
|
@ -24,8 +24,8 @@ const viewerSnapshot: { onSelectionCaptured: ViewerProps["onSelectionCaptured"]
|
|||
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.onSelectionCaptured = props.onSelectionCaptured;
|
||||
return <div data-testid="mock-pdf-viewer" />;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|||
import type { Document, DocumentRepresentation } from "@shared/document";
|
||||
import type { DocumentId, RepresentationId } from "@shared/ids";
|
||||
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" };
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -52,8 +52,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.onSelectionCaptured = props.onSelectionCaptured;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue