refactor(compute-core): capability-boundary exports for runtime and pdf-layout

This commit is contained in:
Richard R 2026-05-21 21:11:28 -06:00
parent d8c6d00de6
commit 1612e6694b
10 changed files with 14 additions and 11 deletions

View file

@ -16,7 +16,7 @@
"./contracts": "./src/contracts.ts",
"./local-runtime": "./src/local-runtime.ts",
"./runtime": "./src/runtime/index.ts",
"./runtime/timeout-config": "./src/runtime/timeout-config.ts",
"./pdf-layout/*": "./src/pdf-layout/*.ts"
"./pdf-layout": "./src/pdf-layout/index.ts",
"./pdf-layout/parse": "./src/pdf-layout/parsePdf.ts"
}
}

View file

@ -0,0 +1,3 @@
export { renderPage } from './renderPage';
export { mergeTextWithRegions } from './mergeTextWithRegions';
export { stitchCrossPageBlocks } from './stitchCrossPageBlocks';

View file

@ -31,7 +31,7 @@ import {
getComputeTimeoutConfig,
withIdleTimeoutAndHardCap,
withTimeout,
} from '@openreader/compute-core/runtime/timeout-config';
} from '@openreader/compute-core/runtime';
import {
type PdfLayoutJobRequest,
type PdfLayoutJobResult,

View file

@ -6,7 +6,7 @@ import {
getComputeTimeoutConfig,
withIdleTimeoutAndHardCap,
withTimeout,
} from '@openreader/compute-core/runtime/timeout-config';
} from '@openreader/compute-core/runtime';
import {
runPdfLayoutFromPdfBuffer,
runWhisperAlignmentFromAudioBuffer,

View file

@ -1,6 +1,6 @@
import { createHash, randomUUID } from 'node:crypto';
import type { ComputeBackend, PdfLayoutInput, WhisperAlignInput, WhisperAlignResult } from '@/lib/server/compute/types';
import { getWorkerClientWaitTimeoutMs } from '@openreader/compute-core/runtime/timeout-config';
import { getWorkerClientWaitTimeoutMs } from '@openreader/compute-core/runtime';
import type {
PdfLayoutJobRequest,
PdfLayoutJobResult,

View file

@ -2,7 +2,7 @@ import path from 'path';
import { createCanvas, loadImage } from '@napi-rs/canvas';
import JSZip from 'jszip';
import { XMLParser } from 'fast-xml-parser';
import { renderPage } from '@openreader/compute-core/pdf-layout/renderPage';
import { renderPage } from '@openreader/compute-core/pdf-layout';
export type RenderedDocumentPreview = {
bytes: Buffer;

View file

@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { mergeTextWithRegions } from '@openreader/compute-core/pdf-layout/mergeTextWithRegions';
import { mergeTextWithRegions } from '@openreader/compute-core/pdf-layout';
test.describe('mergeTextWithRegions', () => {
test('assigns text items to containing regions by centroid and joins in reading order', () => {

View file

@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import { normalizeTextItemsForLayout } from '@openreader/compute-core/pdf-layout/parsePdf';
import { normalizeTextItemsForLayout } from '@openreader/compute-core/pdf-layout/parse';
import type { TextItem } from 'pdfjs-dist/types/src/display/api';
function makeTextItem(

View file

@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test';
import { stitchCrossPageBlocks } from '@openreader/compute-core/pdf-layout/stitchCrossPageBlocks';
import { stitchCrossPageBlocks } from '@openreader/compute-core/pdf-layout';
import type { ParsedPdfBlock, ParsedPdfDocument, ParsedPdfBlockKind } from '../../src/types/parsed-pdf';
function makeBlock(

View file

@ -24,8 +24,8 @@
"@openreader/compute-core/contracts": ["./compute/core/src/contracts.ts"],
"@openreader/compute-core/local-runtime": ["./compute/core/src/local-runtime.ts"],
"@openreader/compute-core/runtime": ["./compute/core/src/runtime/index.ts"],
"@openreader/compute-core/runtime/timeout-config": ["./compute/core/src/runtime/timeout-config.ts"],
"@openreader/compute-core/pdf-layout/*": ["./compute/core/src/pdf-layout/*"]
"@openreader/compute-core/pdf-layout": ["./compute/core/src/pdf-layout/index.ts"],
"@openreader/compute-core/pdf-layout/parse": ["./compute/core/src/pdf-layout/parsePdf.ts"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],