mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 09:27:29 +00:00
* WIP: guard blocking main-process APIs with file ratchets * Cover declared SQLite receivers and preserve daemon guards * Cover SQL iteration and shared synchronous IPC in ratchets
26 lines
788 B
JavaScript
26 lines
788 B
JavaScript
import { existsSync, readFileSync } from 'node:fs'
|
|
import { isTestOnlySourcePath } from './test-only-source-path.mjs'
|
|
|
|
// Exact entry files only: dependencies remain guarded, even when a worker imports them.
|
|
const entries = JSON.parse(
|
|
readFileSync(new URL('../../../main-blocking-worker-entries.json', import.meta.url), 'utf8')
|
|
)
|
|
for (const [file, reason] of Object.entries(entries)) {
|
|
if (
|
|
!file.startsWith('src/main/') ||
|
|
!reason.trim() ||
|
|
!existsSync(new URL(`../../../../${file}`, import.meta.url))
|
|
) {
|
|
throw new Error(`Invalid worker entry: ${file}`)
|
|
}
|
|
}
|
|
|
|
export function isMainBlockingSource(file) {
|
|
return (
|
|
/\.[cm]?[jt]sx?$/.test(file) &&
|
|
!/\.d\.[cm]?ts$/.test(file) &&
|
|
!isTestOnlySourcePath(file) &&
|
|
!Object.hasOwn(entries, file)
|
|
)
|
|
}
|