openreader/scripts/check-compute-boundary.mjs
Richard R a56aaa2be9 Refactor PDF parsing and rendering logic; migrate to compute-worker protocol
- Removed deprecated functions related to document parsing and blob storage in blobstore.ts.
- Introduced new PDF rendering logic in pdf-preview-renderer.ts and pdf-preview-pdfjs-runtime.ts.
- Updated previews-render.ts to utilize the new PDF rendering functions.
- Refactored user-whisper-align-job.ts to use the compute-worker client for alignment requests.
- Enhanced artifact.ts and operation.ts to validate parsed PDF artifacts and resolve current PDF parses.
- Updated snapshot.ts to align with new worker operation types.
- Adjusted runtime-config.ts to check for compute-worker availability.
- Modified types in parsed-pdf.ts and tts.ts to reflect changes in the compute-worker protocol.
- Added unit tests for PDF artifact validation and compute-worker client contract.
- Removed obsolete pdf-op-key.vitest.spec.ts test file.
2026-06-12 13:43:33 -06:00

39 lines
1.1 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
const root = process.cwd();
const forbidden = [
'@openreader/compute-core',
'@openreader/compute-worker',
'compute/core',
'compute/worker',
'compute-worker/src',
];
const failures = [];
function walk(dir) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
walk(fullPath);
continue;
}
if (!entry.isFile() || !/\.(ts|tsx|js|mjs|cjs)$/.test(entry.name)) continue;
const text = fs.readFileSync(fullPath, 'utf8');
for (const pattern of forbidden) {
if (text.includes(pattern)) failures.push({ file: fullPath, pattern });
}
}
}
walk(path.join(root, 'src'));
if (failures.length > 0) {
console.error('[compute-boundary] Forbidden app-to-worker source coupling detected:');
for (const failure of failures) {
console.error(`- ${failure.pattern} in ${path.relative(root, failure.file)}`);
}
process.exit(1);
}
console.info('[compute-boundary] OK: app communicates with compute worker through protocol/client only');