/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * TrackedChannelStore — shared base for the `Func.bind` / `Record.bind` * runtimes. Both expose one tracked channel per `(workspace, name)`: a * latest-wins async operation whose settling state is gated by a monotonic * `launchSeq`, plus a per-key reactive subscription shim that the renderer's * `Reactive.Root` machinery reads through (the same contract the dataset * cache uses). * * Subclasses supply their own API seam, per-channel entry shape, and the * operation body; the base owns the entries map, the tracking context, the * subscription shim, and the launch / settle / cancel latch. * * @packageDocumentation */ /** The minimal per-channel state the base manages. */ export interface ChannelEntry { /** Lifecycle tag — at least `"idle"` | `"running"` | `"cancelled"`, plus * whatever terminal states the subclass adds. */ status: string; /** Monotonic launch counter; a settling op whose seq is no longer current * is discarded (latest-wins, and `cancel` orphans by bumping it). */ launchSeq: number; } /** * Base for a runtime that manages latest-wins channels keyed by string, with * per-key reactive subscriptions. * * @typeParam E - The per-channel entry type (extends {@link ChannelEntry}). */ export declare abstract class TrackedChannelStore { protected readonly entries: Map; private readonly keySubscribers; private readonly keyVersions; private trackingContext; /** Build a fresh channel entry in its initial (idle) state. */ protected abstract createEntry(): E; enableTracking(): Set; disableTracking(): string[]; isTracking(): boolean; /** Record a channel-key dependency for the current render (no-op when not * tracking). */ protected track(key: string): void; subscribe(key: string, callback: () => void): () => void; getKeyVersion(key: string): number; protected notify(key: string): void; protected entry(key: string): E; /** * Open a latest-wins launch on a channel: bump the seq, mark the entry * `running`, optionally `reset` it (e.g. clear a prior error), notify, and * return a `settle` that applies a terminal mutation only if this launch is * still the current one (a superseded / cancelled launch settles to a * no-op). */ protected beginLaunch(key: string, reset?: (entry: E) => void): { entry: E; settle: (mutate: (entry: E) => void) => void; }; /** * Client-side cancel: if the channel is running, orphan the in-flight wait * (bump the seq) and mark it `cancelled`. `after` runs before the notify, * for subclass-specific cleanup (e.g. dropping an in-flight handle). */ protected cancelChannel(key: string, after?: (entry: E) => void): void; /** Drop all channel state (entries + subscriptions + versions). */ protected clearChannels(): void; } //# sourceMappingURL=tracked-channel.d.ts.map