import { Binding, type Injectable, type Subscription } from "@akala/core"; /** * The IScope interface defines the contract for a scope object in the application. * It provides methods for managing variables, dependency injection, and binding to observables. * @template T The type of the scope's data object. */ export interface IScope { $new(): IScope; $setAsync(expression: string, value: unknown): void; $set>(expression: U, value: T[U]): void; $set(expression: string, value: unknown): void; $watch(expression: string, handler: (value: unknown) => void): Subscription; $inject(f: (...args: unknown[]) => unknown): void; $bind(expression: string): Binding; } export type Scope = T & IScope; /** * Core implementation of the IScope interface providing variable management, dependency injection, and observable binding capabilities. * @template T The type of the scope's data object. */ export declare class ScopeImpl implements IScope { static readonly injectionToken: symbol; get $root(): this; /** * Dependency injection resolver for this scope */ private $$resolver; /** * Map of active bindings for observable properties */ $$watchers: Partial<{ [key in keyof T]: Binding; }>; /** * Creates a new child scope inheriting from this scope */ $new(): IScope; /** * Injects a service into the scope using dependency injection * @param f Injectable service constructor * @param params Optional parameters to override dependencies */ $inject(f: Injectable, params?: { [key: string]: unknown; }): T; /** * Sets the value of an expression in the scope * @param expression Property path (e.g. "user.name") * @param value New value */ $set(expression: string, value: unknown): void; /** * Sets the value of an expression asynchronously * @param expression Property path * @param value Promise resolving to new value */ $setAsync(expression: string, value: Promise): void; /** * Creates or retrieves a binding for an observable expression * @param expression Property path to bind * @returns Binding instance */ $bind(expression: string): Binding; /** * Watches for changes to an expression and calls handler when value changes * @param expression Property path to watch * @param handler Callback to execute on change * @returns Subscription to remove the watcher */ $watch(expression: string, handler: (value: unknown) => void): Subscription; }