UNPKG

@yoyo-org/progressive-json

Version:

Stream and render JSON data as it arrives - perfect for AI responses, large datasets, and real-time updates

45 lines (44 loc) 1.62 kB
import type { StreamProcessorOptions, PlaceholderStore } from "./resolve-placeholder"; import { RefPathMap } from "./utils/find-placeholders"; export declare class Processor<T extends PlaceholderStore = PlaceholderStore> { private store; private transformedStore; private selectedStore; private options; private decoder; private listeners; private refStore; private plugins; private isStreaming; private streamError; constructor(options: StreamProcessorOptions<T>); private startStreaming; private doHandleStreamError; private updateTransformedStore; getStore(): T | undefined; getRawStore(): T | undefined; getTransformedStore(): T | undefined; getRefStore(): RefPathMap; isCurrentlyStreaming(): boolean; getStreamError(): Error | null; subscribe(listener: () => void): () => void; startFetching(): void; updateOptions(newOptions: Partial<StreamProcessorOptions<T>>): void; processChunk(chunk: Uint8Array): void; private notifyListeners; private hasStoreChanged; stop(): void; onStreamComplete(finalData: T): void; handleStreamError(error: Error): void; destroy(): void; normalizeRefKey(key: string): string; getRefIdFromKey(refKey: string): number | null; private updateRefStore; updateAtPath(store: T, key: string, updater: (obj: Record<string | number, unknown>, lastKey: string | number) => void): T; private applyPushUpdate; private applyConcatUpdate; private applyRefUpdate; private applyStreamUpdate; private handleStreamLine; private handleInit; }