import { EastTypeValue, ValueTypeOf, OptionType } from '@elaraai/east'; import { PlatformFunction } from '@elaraai/east/internal'; import { DataManifest, DataBindModeLiteral, DataBindModeType } from '@elaraai/e3-ui/internal'; import { TreePath } from '@elaraai/e3-types'; import { ReactiveDatasetCacheInterface } from './dataset-store.js'; import { StagedStoreInterface } from './staged-store.js'; /** * Per-binding metadata the Diff renderer needs to materialize a * binding's tree. Keyed by `datasetCacheKey(workspace, sourcePath)`. */ export interface BindingTypes { readonly workspace: string; readonly sourceType: EastTypeValue; readonly patchType: EastTypeValue; readonly mode: DataBindModeLiteral; readonly hasPatchDataset: boolean; } /** The struct returned by `Data.bind` — an East-side handle on a * dataset binding. JS-side test callers use the same shape. */ export interface BindHandle { read: () => unknown; write: (value: unknown) => null; writeAndStart: (value: unknown) => null; start: () => null; source: () => unknown; pending: () => boolean; commit: () => null; discard: () => null; has: () => boolean; status: () => unknown; binding: { source: TreePath; patch: ValueTypeOf>; mode: ValueTypeOf; }; } /** * A `BindRuntime` owns one set of bind-runtime state: pending writes * queue, error listeners, cache singleton, tracking context, and * binding-types registry. Exists as an instantiable class so tests can * construct an isolated runtime per `describe` rather than wrestling * with shared module state. The default process-global runtime is * {@link defaultBindRuntime}; production callers continue to use the * free-function exports. */ export declare class BindRuntime { private cache; private readonly staged; private readonly pendingWrites; private isProcessingWrites; private drainPromise; private resolveDrain; private readonly writeErrorListeners; private trackingContext; private readonly bindingRegistry; private readonly fallbackWarningEmitted; private readonly listCache; /** * @param staged - The staged store this runtime uses for * staged-mode buffers. Defaults to the package singleton. */ constructor(staged?: StagedStoreInterface); /** Read the active cache. Throws if none has been initialized. */ requireCache(): ReactiveDatasetCacheInterface; /** Read the active cache, returning null if not yet initialized. */ getCache(): ReactiveDatasetCacheInterface | null; /** Set the active cache. When the reference changes, drops any * leftover queued writes that captured the old cache. Same-cache * re-init (Strict Mode double-invoke; HMR) preserves the queue. */ initializeCache(cache: ReactiveDatasetCacheInterface): void; /** Clear the active cache and drop any queued writes. */ clearCache(): void; /** Subscribe to write-queue errors. Returns an unsubscribe fn. */ onWriteError(cb: (error: unknown) => void): () => void; /** Fan a write/persistence error out to every registered listener. */ private emitWriteError; /** Resolve once every currently-queued write has finished * (success or failure). Errors are NOT thrown — subscribe via * {@link onWriteError} for those. */ awaitPendingWrites(): Promise; /** Drop every queued write without running it. */ clearPendingWrites(): void; /** Queue a write — internal API used by the bind-handle closures. */ private queueWrite; private processWriteQueue; enableTracking(): Set; disableTracking(): string[]; isTracking(): boolean; trackPath(workspace: string, path: TreePath): void; getBindingTypes(workspace: string, sourcePath: TreePath): BindingTypes | undefined; /** Clear binding-registry entries. Pass a workspace to clear only * that workspace's entries. Match is by stored field, not key * prefix — workspace names that share a textual prefix never * collide. */ clearBindingRegistry(workspace?: string): void; private registerBindingTypes; /** * Build a bind handle for a single `(sourcePath, mode, patch?)` * triple. Public so tests can call this directly without going * through East's compile/dispatch pipeline. * * @throws `EastError` if the cache is uninitialized, the * workspace is not configured, or `allowed` is non-null and any * referenced path is not in it. */ buildBindHandle(sourceType: EastTypeValue, sourcePath: TreePath, patchPath: TreePath | undefined, mode: DataBindModeLiteral, allowed?: ReadonlySet): BindHandle; /** Build a `Data.bind` PlatformFunction bound to this runtime. * Pass `allowed=null` for an unscoped impl (the global * `BindPlatform`); pass a Set for manifest scoping. */ buildPlatform(allowed: ReadonlySet | null): PlatformFunction; preloadList(workspace: string, path: TreePath): Promise; clearListCache(): void; } /** Process-global runtime backing the `BindPlatform` export and the * free-function helpers. */ export declare const defaultBindRuntime: BindRuntime; /** Read the active cache singleton. Throws if no provider has been mounted. */ export declare function getReactiveDatasetCache(): ReactiveDatasetCacheInterface; /** Set the active cache singleton — called by the React provider on mount. */ export declare function initializeReactiveDatasetCache(cache: ReactiveDatasetCacheInterface): void; /** Clear the active cache singleton — called on unmount or test teardown. * Also drops any queued writes that captured the old cache. */ export declare function clearReactiveDatasetCache(): void; export declare function enableBindingTracking(): Set; export declare function disableBindingTracking(): string[]; export declare function isBindingTracking(): boolean; export declare function trackDatasetPath(workspace: string, path: TreePath): void; export declare function getBindingTypes(workspace: string, sourcePath: TreePath): BindingTypes | undefined; export declare function clearBindingRegistry(workspace?: string): void; /** Subscribe to write-queue errors. Called once for every failed write. */ export declare function onWriteError(cb: (error: unknown) => void): () => void; /** Resolve once every currently-queued write has finished. */ export declare function awaitPendingWrites(): Promise; /** Drop every queued write without running it. */ export declare function clearPendingWrites(): void; /** Global, manifest-unscoped `Data.bind` impl. Registered on module load. */ export declare const BindPlatform: PlatformFunction[]; /** Build a manifest-scoped `Data.bind` implementation. */ export declare function createScopedBindPlatform(manifest: DataManifest): PlatformFunction[]; export declare function preloadReactiveDatasetList(workspace: string, path: TreePath): Promise; export declare function clearReactiveDatasetListCache(): void; //# sourceMappingURL=bind-runtime.d.ts.map