/** * Core-facing parameter runtime facade. * * `ParamRuntime` composes three internal subsystems: * 1. `ParamStore` for scoped name resolution (`scope` + `name` -> ref). * 2. `GraphRuntime` for reactive propagation and batching. * 3. `LifecycleRegistry` for owner-bound teardown. * * Most Core call sites should use this class (or `ViewParamRuntime`) instead * of interacting with `GraphRuntime` directly. * * Scope semantics used by this runtime: * 1. A scope is a runtime-only identity (`ScopeId`) with a parent pointer. * 2. Parameters are registered into exactly one scope. * 3. Name resolution is lexical/nearest-first: local scope, then parent chain. * 4. Shadowing is allowed across scopes (same param name in parent/child). * 5. Duplicate names are rejected within a single scope. * 6. `disposeScope` clears local bindings and owner resources while preserving * scope-chain structure for descendants that still resolve through parents. * * @typedef {string} ScopeId */ export default class ParamRuntime { /** * Creates a new parameter scope. * * If `parentScope` is provided, name resolution in this scope falls back to * the parent chain. * * @param {ScopeId} [parentScope] * @returns {ScopeId} */ createScope(parentScope?: ScopeId): ScopeId; /** * Disposes all runtime resources owned by the scope and clears the scope's * local parameter bindings. * * Descendant scopes remain valid and continue resolving through their own * parent chains. * * @param {ScopeId} scope */ disposeScope(scope: ScopeId): void; /** * Registers a disposer that is bound to the scope lifecycle. * * The disposer is called when `disposeScope(scope)` is executed. * * @param {ScopeId} scope * @param {() => void} disposer */ addScopeDisposer(scope: ScopeId, disposer: () => void): void; /** * Registers a writable base parameter in `scope`. * * @template T * @param {ScopeId} scope * @param {string} name * @param {T} initial * @param {{ notify?: boolean }} [options] * @returns {import("./types.js").WritableParamRef} */ registerBase(scope: ScopeId, name: string, initial: T, options?: { notify?: boolean; }): import("./types.js").WritableParamRef; /** * Registers a writable selection parameter in `scope`. * * Selection params are writable like base params but carry `kind: * "selection"` for downstream handling. * * @template T * @param {ScopeId} scope * @param {string} name * @param {T} initial * @param {{ notify?: boolean }} [options] * @returns {import("./types.js").WritableParamRef} */ registerSelection(scope: ScopeId, name: string, initial: T, options?: { notify?: boolean; }): import("./types.js").WritableParamRef; /** * Registers a derived read-only parameter in `scope`. * * The expression is bound to current scope resolution and re-evaluated by * the graph runtime when dependencies change. * * @template T * @param {ScopeId} scope * @param {string} name * @param {string} expr * @param {{ resolveScaleResolution?: (channel: string) => import("../scales/scaleResolution.js").default | undefined }} [options] * @returns {import("./types.js").ParamRef} */ registerDerived(scope: ScopeId, name: string, expr: string, options?: { resolveScaleResolution?: (channel: string) => import("../scales/scaleResolution.js").default | undefined; }): import("./types.js").ParamRef; /** * Creates an expression function bound to scope-based parameter resolution. * * The returned expression supports subscriptions (`subscribe`) * and can be used by callers that need expression-level reactivity without * registering a named derived parameter. * * @param {ScopeId} scope * @param {string} expr * @param {{ resolveScaleResolution?: (channel: string) => import("../scales/scaleResolution.js").default | undefined }} [options] * @returns {import("./types.js").ExprRefFunction} */ createExpression(scope: ScopeId, expr: string, options?: { resolveScaleResolution?: (channel: string) => import("../scales/scaleResolution.js").default | undefined; }): import("./types.js").ExprRefFunction; /** * Resolves a parameter by name from `scope`, searching parent scopes as needed. * Returns the nearest matching binding, if any. * * @template T * @param {ScopeId} scope * @param {string} name * @returns {import("./types.js").ParamRef | undefined} */ resolve(scope: ScopeId, name: string): import("./types.js").ParamRef | undefined; /** * Runs a transactional update against the underlying graph runtime. * * Multiple writes inside `fn` are batched and propagated after the * outermost transaction exits. * * @template T * @param {() => T} fn * @returns {T} */ runInTransaction(fn: () => T): T; /** * Forces immediate synchronous propagation of currently queued graph work. */ flushNow(): void; /** * Resolves when propagation/effects have settled in the graph runtime. * * @param {{ signal?: AbortSignal, timeoutMs?: number }} [options] * @returns {Promise} */ whenPropagated(options?: { signal?: AbortSignal; timeoutMs?: number; }): Promise; #private; } /** * Core-facing parameter runtime facade. * * `ParamRuntime` composes three internal subsystems: * 1. `ParamStore` for scoped name resolution (`scope` + `name` -> ref). * 2. `GraphRuntime` for reactive propagation and batching. * 3. `LifecycleRegistry` for owner-bound teardown. * * Most Core call sites should use this class (or `ViewParamRuntime`) instead * of interacting with `GraphRuntime` directly. * * Scope semantics used by this runtime: * 1. A scope is a runtime-only identity (`ScopeId`) with a parent pointer. * 2. Parameters are registered into exactly one scope. * 3. Name resolution is lexical/nearest-first: local scope, then parent chain. * 4. Shadowing is allowed across scopes (same param name in parent/child). * 5. Duplicate names are rejected within a single scope. * 6. `disposeScope` clears local bindings and owner resources while preserving * scope-chain structure for descendants that still resolve through parents. */ export type ScopeId = string; //# sourceMappingURL=paramRuntime.d.ts.map