v1.1.0: pooled runtime, 959 tests, production hardening (0 squash)

This commit is contained in:
John Dvorak
2025-08-15 10:00:00 -07:00
commit 92deb689cd
321 changed files with 79170 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
// Global configuration and project defaults for Imhotep
// Uses dependency injection patterns: configure() sets runtime globals,
// project() sets persistent project-level metadata.
export interface ImhotepConfig {
defaultTolerance?: { value: number; unit: 'px' | 'jnd' }
defaultFrame?: string
perceptualModel?: string
[key: string]: unknown
}
let globalConfig: ImhotepConfig = {}
/** Sets or updates global Imhotep runtime configuration. */
export function configure(config: ImhotepConfig): void {
globalConfig = { ...globalConfig, ...config }
}
/** Returns a shallow copy of the current global config. */
export function getConfig(): ImhotepConfig {
return { ...globalConfig }
}
export interface ProjectConfig {
name?: string
fontCorpus?: string
adapters?: string[]
environments?: unknown[]
[key: string]: unknown
}
let projectConfig: ProjectConfig = {}
/** Sets or updates project-level defaults, font corpora, and adapters. */
export function project(config: ProjectConfig): void {
projectConfig = { ...projectConfig, ...config }
}
/** Returns a shallow copy of the current project config. */
export function getProjectConfig(): ProjectConfig {
return { ...projectConfig }
}
/** Environment guard for responsive contracts.
* Only executes the callback when the condition is truthy.
*/
export function when(condition: unknown, fn: () => void): void {
if (condition) {
fn()
}
}