Follow-up to the browser/cloud/threading sweep — everything that was guarding
against unreachable runtimes is now dead.
cacheManager.ts: Environment enum + this.environment field removed (only NODE
was reachable). StorageType narrowed to MEMORY + FILESYSTEM. navigator.deviceMemory
and performance.memory paths in detectOptimalCacheSize + detectAvailableMemory
deleted; node:os is the sole source. environmentConfig keeps the index signature
for future per-runtime tuning but only the node slot is wired.
Dead 'typeof window === undefined' guards (the check is always true on 8.0):
paramValidation, structuredLogger, mutex, brainy.ts stats block, and
networkTransport ws-dynamic-import all collapsed. IntegrationLoader's inverse
guard ('!== undefined' returning 'browser') deleted. mutex's createMutex default
type simplified from "(typeof window === 'undefined' ? 'file' : 'memory')" to
plain 'file'.
Redundant TextEncoder/TextDecoder polyfills: Node 22+ ships both as globals.
src/utils/textEncoding.ts deleted (applyTensorFlowPatch was named for a defunct
dep and only re-assigned globals already present). setup.ts collapsed to an
empty stable import target. unified.ts loses its applyTensorFlowPatch re-export.
modelAutoConfig.getModelPath() loses the unreachable trailing fallback now
that isNode() is effectively the only branch the function ever takes.
jsonProcessing.ts left unchanged — its 'typeof document' checks are value-shape
guards on the parsed JSON, not environment detection.
29 lines
705 B
TypeScript
29 lines
705 B
TypeScript
/**
|
|
* @module unified
|
|
* @description Unified entry point for Brainy. Re-exports the public surface
|
|
* from `index.js` and surfaces a tiny runtime-environment object the rest of
|
|
* the library can read.
|
|
*
|
|
* 8.0 supports Node-like runtimes only (Node.js, Bun, Deno); the browser
|
|
* detection helpers and Worker Thread plumbing are gone.
|
|
*/
|
|
|
|
import './setup.js'
|
|
|
|
import { isNode } from './utils/environment.js'
|
|
|
|
export const environment = {
|
|
get isNode() {
|
|
return isNode()
|
|
}
|
|
}
|
|
|
|
if (typeof globalThis !== 'undefined') {
|
|
;(globalThis as any).__ENV__ = environment
|
|
}
|
|
|
|
console.log(
|
|
`Brainy running on ${environment.isNode ? 'Node-like runtime' : 'unknown runtime'}`
|
|
)
|
|
|
|
export * from './index.js'
|