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 { ParsedPdfDocument } from './types/parsed-pdf';
import type { TTSSentenceAlignment } from '../types/tts';
import type { ParsedPdfDocument } from '../types/parsed-pdf';
export type {
TTSAudioBuffer,
TTSAudioBytes,
TTSSentenceAlignment,
TTSSentenceWord,
} from './types/tts';
} from '../types/tts';
export type {
ParsedPdfBlockKind,
ParsedPdfBlockFragment,
ParsedPdfBlock,
ParsedPdfPage,
ParsedPdfDocument,
} from './types/parsed-pdf';
} from '../types/parsed-pdf';
export const ALIGN_QUEUE_NAME = 'whisper-align';
export const PDF_LAYOUT_QUEUE_NAME = 'pdf-layout';

View file

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

View file

@ -2,7 +2,7 @@ import path from 'path';
import { fileURLToPath } from 'url';
import { createHash } from 'crypto';
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';
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 type { LayoutRegion, PdfTextItem } from './types';
import { ensureModel, MODEL_CONFIG_PATH, MODEL_PREPROCESSOR_PATH } from './ensureModel';
import { getOnnxThreadsPerJob } from '../runtime/cpu-budget';
import { getOnnxThreadsPerJob } from '../config/cpu-budget';
interface RunLayoutInput {
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 JSZip from 'jszip';
import type { TTSAudioBuffer, TTSAudioBytes, TTSSentenceAlignment } from '../types/tts';
import { getFFmpegPath } from '../runtime/ffmpeg';
import { getOnnxThreadsPerJob } from '../runtime/cpu-budget';
import { getComputeTimeoutConfig } from '../runtime/timeout-config';
import { getFFmpegPath } from '../platform/ffmpeg';
import { getOnnxThreadsPerJob } from '../config/cpu-budget';
import { getComputeTimeoutConfig } from '../config/timeout';
import {
mapWordsToSentenceOffsets,
type WhisperWord,

View file

@ -2,7 +2,7 @@ import path from 'path';
import { fileURLToPath } from 'url';
import { createHash } from 'crypto';
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';
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));