@yoyo-org/progressive-json
Version:
Stream and render JSON data as it arrives - perfect for AI responses, large datasets, and real-time updates
47 lines (46 loc) • 1.53 kB
TypeScript
import type { StreamProcessorOptions, PlaceholderStore } from "./resolve-placeholder";
export interface SSEProcessorOptions<T extends PlaceholderStore> extends StreamProcessorOptions<T> {
useSSE?: boolean;
headers?: Record<string, string>;
}
export declare class ProcessorSSE<T extends PlaceholderStore = PlaceholderStore> {
private store;
private transformedStore;
private selectedStore;
private options;
private decoder;
private listeners;
private refStore;
private plugins;
private isStreaming;
private streamError;
private abortController;
private eventSource;
constructor(options: SSEProcessorOptions<T>);
private startStreaming;
private handleStreamError;
processChunk(chunk: Uint8Array): void;
private processMessage;
private createPluginContext;
startFetching(): void;
updateOptions(newOptions: Partial<SSEProcessorOptions<T>>): void;
private updateRefStore;
private updateValue;
private pushToArray;
private concatToArray;
stop(): void;
onStreamComplete(finalData: T): void;
onStreamError(error: Error): void;
destroy(): void;
getStore(): T | undefined;
getRawStore(): T | undefined;
getTransformedStore(): T | undefined;
isCurrentlyStreaming(): boolean;
getStreamError(): Error | null;
subscribe(listener: () => void): () => void;
private notifyListeners;
private updateTransformedStore;
private getValueByRef;
private setValueAtPath;
private getValueAtPath;
}