refactor(compute-core): split runtime into config/platform and move contracts barrel

This commit is contained in:
Richard R 2026-05-21 21:40:16 -06:00
parent 37b6999c2c
commit 3a2c6ffa42
11 changed files with 12 additions and 27 deletions

View file

@ -1,19 +1,19 @@
import type { TTSSentenceAlignment } from './types/tts'; import type { TTSSentenceAlignment } from '../types/tts';
import type { ParsedPdfDocument } from './types/parsed-pdf'; import type { ParsedPdfDocument } from '../types/parsed-pdf';
export type { export type {
TTSAudioBuffer, TTSAudioBuffer,
TTSAudioBytes, TTSAudioBytes,
TTSSentenceAlignment, TTSSentenceAlignment,
TTSSentenceWord, TTSSentenceWord,
} from './types/tts'; } from '../types/tts';
export type { export type {
ParsedPdfBlockKind, ParsedPdfBlockKind,
ParsedPdfBlockFragment, ParsedPdfBlockFragment,
ParsedPdfBlock, ParsedPdfBlock,
ParsedPdfPage, ParsedPdfPage,
ParsedPdfDocument, ParsedPdfDocument,
} from './types/parsed-pdf'; } from '../types/parsed-pdf';
export const ALIGN_QUEUE_NAME = 'whisper-align'; export const ALIGN_QUEUE_NAME = 'whisper-align';
export const PDF_LAYOUT_QUEUE_NAME = 'pdf-layout'; export const PDF_LAYOUT_QUEUE_NAME = 'pdf-layout';

View file

@ -3,7 +3,7 @@ export {
getComputeJobConcurrency, getComputeJobConcurrency,
getAvailableCpuCores, getAvailableCpuCores,
getOnnxThreadsPerJob, getOnnxThreadsPerJob,
} from './runtime/cpu-budget'; } from './config/cpu-budget';
export { export {
getComputeTimeoutConfig, getComputeTimeoutConfig,
getWorkerClientWaitTimeoutMs, getWorkerClientWaitTimeoutMs,
@ -12,7 +12,7 @@ export {
type ComputeTimeoutConfig, type ComputeTimeoutConfig,
type ComputeOperationKind, type ComputeOperationKind,
type IdleTimeoutAndHardCapInput, type IdleTimeoutAndHardCapInput,
} from './runtime/timeout-config'; } from './config/timeout';
export { renderPage } from './pdf-layout/renderPage'; export { renderPage } from './pdf-layout/renderPage';
export { mergeTextWithRegions } from './pdf-layout/mergeTextWithRegions'; export { mergeTextWithRegions } from './pdf-layout/mergeTextWithRegions';
export { stitchCrossPageBlocks } from './pdf-layout/stitchCrossPageBlocks'; export { stitchCrossPageBlocks } from './pdf-layout/stitchCrossPageBlocks';

View file

@ -2,7 +2,7 @@ import path from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { createHash } from 'crypto'; import { createHash } from 'crypto';
import { access, mkdir, rename, writeFile, readFile, unlink, copyFile } from 'fs/promises'; import { access, mkdir, rename, writeFile, readFile, unlink, copyFile } from 'fs/promises';
import { DOCSTORE_DIR } from '../runtime/docstore'; import { DOCSTORE_DIR } from '../platform/docstore';
import manifest from './model/manifest.json'; import manifest from './model/manifest.json';
const DEFAULT_MODEL_BASE_URL = 'https://huggingface.co/Bei0001/PP-DocLayoutV3-ONNX/resolve/main'; const DEFAULT_MODEL_BASE_URL = 'https://huggingface.co/Bei0001/PP-DocLayoutV3-ONNX/resolve/main';

View file

@ -2,7 +2,7 @@ import * as ort from 'onnxruntime-node';
import { readFile } from 'fs/promises'; import { readFile } from 'fs/promises';
import type { LayoutRegion, PdfTextItem } from './types'; import type { LayoutRegion, PdfTextItem } from './types';
import { ensureModel, MODEL_CONFIG_PATH, MODEL_PREPROCESSOR_PATH } from './ensureModel'; import { ensureModel, MODEL_CONFIG_PATH, MODEL_PREPROCESSOR_PATH } from './ensureModel';
import { getOnnxThreadsPerJob } from '../runtime/cpu-budget'; import { getOnnxThreadsPerJob } from '../config/cpu-budget';
interface RunLayoutInput { interface RunLayoutInput {
pageWidth: number; pageWidth: number;

View file

@ -1,15 +0,0 @@
export {
getComputeJobConcurrency,
getAvailableCpuCores,
getOnnxThreadsPerJob,
} from './cpu-budget';
export {
getComputeTimeoutConfig,
getWorkerClientWaitTimeoutMs,
withTimeout,
withIdleTimeoutAndHardCap,
type ComputeTimeoutConfig,
type ComputeOperationKind,
type IdleTimeoutAndHardCapInput,
} from './timeout-config';

View file

@ -8,9 +8,9 @@ import * as ort from 'onnxruntime-node';
import { Tokenizer } from '@huggingface/tokenizers'; import { Tokenizer } from '@huggingface/tokenizers';
import JSZip from 'jszip'; import JSZip from 'jszip';
import type { TTSAudioBuffer, TTSAudioBytes, TTSSentenceAlignment } from '../types/tts'; import type { TTSAudioBuffer, TTSAudioBytes, TTSSentenceAlignment } from '../types/tts';
import { getFFmpegPath } from '../runtime/ffmpeg'; import { getFFmpegPath } from '../platform/ffmpeg';
import { getOnnxThreadsPerJob } from '../runtime/cpu-budget'; import { getOnnxThreadsPerJob } from '../config/cpu-budget';
import { getComputeTimeoutConfig } from '../runtime/timeout-config'; import { getComputeTimeoutConfig } from '../config/timeout';
import { import {
mapWordsToSentenceOffsets, mapWordsToSentenceOffsets,
type WhisperWord, type WhisperWord,

View file

@ -2,7 +2,7 @@ import path from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { createHash } from 'crypto'; import { createHash } from 'crypto';
import { access, copyFile, mkdir, readFile, rename, unlink, writeFile } from 'fs/promises'; import { access, copyFile, mkdir, readFile, rename, unlink, writeFile } from 'fs/promises';
import { DOCSTORE_DIR } from '../runtime/docstore'; import { DOCSTORE_DIR } from '../platform/docstore';
import manifest from './model/manifest.json'; import manifest from './model/manifest.json';
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url)); const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));