/** * A class that manages parameters and expressions. * Supports nesting and scoped parameters through a shared runtime graph. * The architecture follows signal-graph ideas (explicit dependencies, batched * propagation, deterministic scheduling) while keeping GenomeSpy-specific * parameter and expression semantics. * * @typedef {import("../utils/expression.js").ExpressionFunction & { subscribe: (listener: () => void) => () => void, invalidate: () => void, identifier: () => string}} ExprRefFunction */ export default class ViewParamRuntime { /** * @param {() => ViewParamRuntime} [parentFinder] * @param {(channel: import("../spec/channel.js").ChannelWithScale) => import("../scales/scaleResolution.js").default | undefined} [scaleResolutionResolver] * Optional resolver for scale channels in this runtime's view scope. * N.B. The function must always return the same resolution for the * same channel in the same view hierarchy. */ constructor(parentFinder?: () => ViewParamRuntime, scaleResolutionResolver?: (channel: import("../spec/channel.js").ChannelWithScale) => import("../scales/scaleResolution.js").default | undefined); /** * Registers a parameter definition into this runtime scope. * * Returns a writable setter for writable parameters (`value`, `select`, * `push: "outer"`). For derived (`expr`) parameters, the returned setter * throws. * * A parameter name can be registered only once per runtime scope. * * @param {Parameter} param * @returns {ParameterSetter} */ registerParam(param: import("../spec/parameter.js").Parameter): (value: any) => void; /** * * @param {string} paramName * @param {T} initialValue * @param {boolean} [passive] If true, the setter will not notify listeners when the value changes. * @returns {(value: T) => void} * @template T */ allocateSetter(paramName: string, initialValue: T, passive?: boolean): (value: T) => void; /** * Sets a writable parameter value in this runtime scope. * * Only parameters with locally registered writable setters are supported. * This method does not resolve through ancestors. * * @param {string} paramName * @param {any} value */ setValue(paramName: string, value: any): void; /** * Get the value of a parameter from this runtime. * @param {string} paramName */ getValue(paramName: string): any; /** * Subscribe to changes of a parameter's value. The listener is called only * when the stored value changes. For expression parameters, the listener is * called when upstream changes re-evaluate to a different value. * * @param {string} paramName * @param {() => void} listener * @returns {() => void} */ subscribe(paramName: string, listener: () => void): () => void; /** * Get the value of a parameter from this runtime or its ancestors. * @param {string} paramName */ findValue(paramName: string): any; /** * Returns configs for all parameters that have been registered using `registerParam`. */ get paramConfigs(): ReadonlyMap; /** * Returns true if this runtime scope owns a local binding for the parameter. * * @param {string} paramName * @returns {boolean} */ hasLocalParam(paramName: string): boolean; /** * Returns true if this runtime scope or any ancestor scope contains a * parameter registered through `registerParam`. * * Auto-allocated setters such as layout width/height are intentionally * ignored so that only explicit parameter configs shadow descendant * auto-size params. * * @param {string} paramName * @returns {boolean} */ hasConfiguredParamInScopeChain(paramName: string): boolean; /** * * @param {string} paramName * @returns {ViewParamRuntime} */ findRuntimeForParam(paramName: string): ViewParamRuntime; /** * Parse expr and return a function that returns the value of the parameter. * * @param {string} expr */ createExpression(expr: string): import("./types.js").ExprRefFunction; /** * Creates an expression and subscribes a listener that is automatically * removed according to `options` lifecycle ownership. * * Lifecycle semantics: * 1. `scopeOwned: true` (default): unsubscribe is bound to runtime scope * disposal (`ViewParamRuntime.dispose()`). * 2. `scopeOwned: false`: caller must own teardown, typically via * `registerDisposer` or by storing and calling the returned unsubscribe. * 3. `registerDisposer` can be used regardless of `scopeOwned` to bind the * same unsubscribe to another lifecycle owner. * * @param {string} expr * @param {() => void} listener * @param {WatchExpressionOptions} [options] * @returns {ExprRefFunction} */ watchExpression(expr: string, listener: () => void, options?: { /** * Whether the subscription lifecycle is owned by this runtime scope. * When true, the listener is unsubscribed automatically during * `dispose()` via scope disposal. Set to false when another owner * (for example a `View` disposer registry) controls teardown. */ scopeOwned?: boolean; /** * Optional external disposer registration hook. When provided, the * unsubscribe callback is passed to this hook in addition to any * scope-owned registration. */ registerDisposer?: (disposer: () => void) => void; }): ExprRefFunction; /** * A convenience method for evaluating an expression. * * @param {string} expr */ evaluateAndGet(expr: string): any; /** * @template T * @param {() => T} fn * @returns {T} */ runInTransaction(fn: () => T): T; flushNow(): void; /** * Sync barrier only: resolves when DAG propagation/effects have flushed. * Must not be broadened to temporal/animation convergence semantics. * * @param {{ signal?: AbortSignal, timeoutMs?: number }} [options] */ whenPropagated(options?: { signal?: AbortSignal; timeoutMs?: number; }): Promise; dispose(): void; /** * Returns true if this runtime has any parameters that are point selections. * Point selections necessitate the use of uniqueIds in the data. * * @returns {boolean} */ hasPointSelections(): boolean; #private; } /** * A class that manages parameters and expressions. * Supports nesting and scoped parameters through a shared runtime graph. * The architecture follows signal-graph ideas (explicit dependencies, batched * propagation, deterministic scheduling) while keeping GenomeSpy-specific * parameter and expression semantics. */ export type ExprRefFunction = import("../utils/expression.js").ExpressionFunction & { subscribe: (listener: () => void) => () => void; invalidate: () => void; identifier: () => string; }; export { activateExprRefProps, getDefaultParamValue, isExprRef, isSelectionParameter, isVariableParameter, makeConstantExprRef, validateParameterName, withoutExprRef } from "./paramUtils.js"; //# sourceMappingURL=viewParamRuntime.d.ts.map