/** * HotReloadBridge.ts * * Thin wiring layer that connects HotReloadManager → ModuleResolver. * * When a .hs file changes on disk, the bridge: * 1. Calls `resolver.invalidate(canonicalPath)` — clears the AST cache * so the next `resolver.load()` re-parses the updated source. * 2. Optionally fires a user-supplied `onReloaded` callback. * * This lives in `runtime/` rather than `compiler/` to avoid a circular * dependency (compiler/ must not import from runtime/). * * @module runtime/HotReloadBridge * @version 1.0.0 */ import { HotReloadManager } from './HotReloadManager'; import { ModuleResolver } from '@holoscript/core'; export type ModuleReloadCallback = (canonicalPath: string, version: number) => void; export interface HotReloadBridgeOptions { /** Called after resolver cache is invalidated, before user onReloaded. */ onInvalidated?: ModuleReloadCallback; /** Called after full successful reload sequence. */ onReloaded?: ModuleReloadCallback; /** If a watcher throws, this receives the error instead of crashing. */ onError?: (key: string, error: Error) => void; } export declare class HotReloadBridge { private readonly hotReload; private readonly resolver; private readonly opts; /** Track unsubscribe fns keyed by canonicalPath */ private unsubs; constructor(hotReload: HotReloadManager, resolver: ModuleResolver, options?: HotReloadBridgeOptions); /** * Watch a .hs file identified by its canonical path. * * When `hotReload.triggerReload(canonicalPath, newSource)` is called: * - `resolver.invalidate()` is called immediately * - `opts.onInvalidated` fires (if set) * - `opts.onReloaded` fires (if set) * * Returns an unsubscribe fn for this specific watcher. */ watchModule(canonicalPath: string, onReloaded?: ModuleReloadCallback): () => void; /** * Stop watching a specific module. */ unwatchModule(canonicalPath: string): void; /** * Whether a module is currently being watched via this bridge. */ isWatchingModule(canonicalPath: string): boolean; /** * Number of modules currently watched by this bridge. */ get watchedCount(): number; /** * Trigger a reload from the bridge — convenience wrapper that calls * `hotReload.triggerReload(canonicalPath, newSource)`. */ triggerReload(canonicalPath: string, newSource: string): void; /** * Stop watching ALL modules registered through this bridge. */ dispose(): void; } export default HotReloadBridge; //# sourceMappingURL=HotReloadBridge.d.ts.map