import type { SuperJSON } from "superjson"; type Events = "open" | "data" | "close"; type Listener = (data: T) => void; /** * FsDuplex (Filesystem Duplex) * * An abstract class that provides a standardized, duplex (two-way) communication channel * over a file-based system. It abstracts away the underlying filesystem implementation * (e.g., Node.js `fs` vs. a browser-based filesystem shim) and offers a consistent, * event-driven, and streamable interface. * * It is designed to manage the lifecycle of a single task file. * * @template T The type of the data object being exchanged (e.g., a `Task`). */ export declare abstract class FsDuplex { protected superjson: SuperJSON; protected _currentData: T | undefined; protected _isClosed: boolean; private _events; private _resolveNextData; private _nextDataPromise; private _resolveClosed; private _closedPromise; /** * @param superjson The SuperJSON instance for serialization/deserialization. */ constructor(superjson: SuperJSON); /** * Subscribes to an event. * @param event The event name ('open', 'data', 'close'). * @param listener The callback function. * @returns A function to unsubscribe. */ on(event: Events, listener: Listener): () => void; /** * Emits an event to all subscribed listeners. * @param event The event name. * @param data The data to pass to listeners. */ protected _emit(event: Events, data: T): void; /** * Handles the reception of new data, updating state and notifying listeners. * This method is intended to be called by subclasses when they detect a file change. * @param data The new data object. */ protected _onData(data: T): void; /** * Handles the closing of the channel, notifying listeners. * This method is intended to be called by subclasses when they detect file deletion. */ protected _onClose(): void; /** * Returns the most recently received data object. * @returns The current data, or undefined if none has been received. */ data(): T | undefined; /** * Returns a promise that resolves with the next data object received. */ nextData(): Promise; /** * Returns a promise that resolves when the communication channel is closed. */ get closed(): Promise; /** * Provides an async generator to iterate over incoming data objects. * The loop terminates when the channel is closed. */ stream(): AsyncGenerator; /** * Abstract method to be implemented by subclasses. * This should contain the logic to start listening for file changes. */ abstract start(): void; /** * Abstract method to write data to the filesystem. * @param payload The partial data to merge and write. */ abstract write(payload: Partial): Promise; /** * Abstract method to signal the end of communication and clean up resources. */ abstract destroy(): Promise; } export {}; //# sourceMappingURL=fs-duplex.d.ts.map