mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
* chore(dead-code): drop 2k lines of unreachable exports and orphan modules Ran knip across every build entry (main, preload, renderer, popout, web, cli, relay, workers, forked sidecars, config scripts) and removed what no entry graph can reach. - 11 orphan modules nothing imported, plus one test that only covered them - 159 unused exports/types, with their now-dead helpers, imports and tests Each candidate was verified against dynamic references before deletion. 42 knip hits were false positives and are kept: shared modules consumed by the mobile/ workspace, the src/shared/plugins/** public API, vendored shadcn primitives, and relay wire-protocol constants held for compatibility. Adds knip.json + `pnpm audit:dead-code` so this stays measurable. Verified: pnpm typecheck, pnpm lint, and 2081 tests across the 73 affected test files all pass. * chore(dead-code): move knip config under config/ Root-level additions are blocked by the root directory guard. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
76 lines
2.7 KiB
TypeScript
76 lines
2.7 KiB
TypeScript
// Host API for crash-isolated @parcel/watcher children. Desktop uses one
|
|
// supervisor; runtime roots use a bounded pool with independent crash fuses.
|
|
import { WatcherProcessSupervisor } from './parcel-watcher-process-supervisor'
|
|
import type { WatcherProcessSubscribeOptions } from './parcel-watcher-process-protocol'
|
|
import type {
|
|
WatcherProcessCallback,
|
|
WatcherProcessHooks,
|
|
WatcherProcessSubscription
|
|
} from './parcel-watcher-process-subscription'
|
|
import { RuntimeWatcherProcessPool } from './runtime-watcher-process-pool'
|
|
|
|
export type {
|
|
WatcherProcessCallback,
|
|
WatcherProcessHooks,
|
|
WatcherProcessSubscription
|
|
} from './parcel-watcher-process-subscription'
|
|
export type {
|
|
WatcherProcessDeliveryOptions,
|
|
WatcherProcessEvent,
|
|
WatcherProcessSubscribeOptions
|
|
} from './parcel-watcher-process-protocol'
|
|
|
|
const sharedWatcherProcessSupervisor = new WatcherProcessSupervisor()
|
|
// Why: healthy roots share one child; only fault quarantine scales to four,
|
|
// containing a failed shard without paying that RSS cost during normal use.
|
|
const runtimeWatcherProcessPool = new RuntimeWatcherProcessPool()
|
|
|
|
export function createWatcherProcessSupervisor(): WatcherProcessSupervisor {
|
|
return new WatcherProcessSupervisor()
|
|
}
|
|
|
|
export function subscribeViaWatcherProcess(
|
|
dir: string,
|
|
callback: WatcherProcessCallback,
|
|
opts: WatcherProcessSubscribeOptions,
|
|
hooks: WatcherProcessHooks = {}
|
|
): Promise<WatcherProcessSubscription> {
|
|
return sharedWatcherProcessSupervisor.subscribe(dir, callback, opts, hooks)
|
|
}
|
|
|
|
export function subscribeViaRuntimeWatcherProcess(
|
|
dir: string,
|
|
callback: WatcherProcessCallback,
|
|
opts: WatcherProcessSubscribeOptions,
|
|
hooks: WatcherProcessHooks = {}
|
|
): Promise<WatcherProcessSubscription> {
|
|
return runtimeWatcherProcessPool.subscribe(dir, callback, opts, hooks)
|
|
}
|
|
|
|
/** Kill shared desktop and runtime watcher children at app/runtime shutdown. */
|
|
export function disposeWatcherProcess(): void {
|
|
// Why: Vitest reuses this module singleton after closeAllWatchers(), while
|
|
// production shutdown must remain final and reject any later subscription.
|
|
if (process.env.VITEST) {
|
|
sharedWatcherProcessSupervisor.resetForTest()
|
|
runtimeWatcherProcessPool.resetForTest()
|
|
} else {
|
|
sharedWatcherProcessSupervisor.dispose()
|
|
// Why: the runtime pool owns independent children that otherwise outlive a
|
|
// shutdown sequence that does not immediately exit the main process.
|
|
runtimeWatcherProcessPool.dispose()
|
|
}
|
|
}
|
|
|
|
export function resetWatcherProcessForTest(): void {
|
|
sharedWatcherProcessSupervisor.resetForTest()
|
|
}
|
|
|
|
export function resetRuntimeWatcherProcessForTest(): void {
|
|
runtimeWatcherProcessPool.resetForTest()
|
|
}
|
|
|
|
export function forgetRuntimeWatcherProcessRoot(rootPath: string): void {
|
|
runtimeWatcherProcessPool.forgetRoot(rootPath)
|
|
}
|