UNPKG

@yoyo-org/progressive-json

Version:

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

109 lines (108 loc) 3.34 kB
/** * Domain-specific abstractions for Talmud text streaming * This module provides high-level hooks and utilities tailored for * Talmud analysis streaming use cases */ import type { PlaceholderStore } from "../resolve-placeholder"; export interface TalmudSugya { title: string; explanation: string; line_range: { start_line: number; end_line: number; }; gemara: Array<{ line: string; line_number: number; }>; rashi: Array<{ line: string; line_number: number; }>; biur?: string; } export interface TalmudProgressData { current_step: string; current_sugya: number; total_sugiyot: number; status: string; message: string; } export interface TalmudDafAnalysis extends PlaceholderStore { daf: string; masechet: string; include_biur: boolean; biur_level?: number; sugyot: TalmudSugya[]; progress: TalmudProgressData; metadata: { total_lines: number; analysis_complete: boolean; start_time?: number; }; analysis_raw?: string; } export interface TalmudStreamingState { sugiyot: Array<TalmudSugya & { isStreaming?: boolean; streamingBiur?: string; completeBiur?: string; biurProgress?: number; }>; isAnalyzing: boolean; analysisProgress: number; totalSugiyot: number; currentStreamingSugya: number | null; error: string | null; currentStep: string; statusMessage: string; isStreamingRaw: boolean; rawContent: string; } export interface UseTalmudStreamOptions { baseUrl?: string; onAnalysisComplete?: (data: TalmudDafAnalysis) => void; onSugyaComplete?: (sugya: TalmudSugya, index: number) => void; onBiurProgress?: (progress: number, sugyaIndex: number) => void; } /** * High-level hook for Talmud daf analysis streaming * Abstracts away the complexity of progressive JSON and provides * a clean, declarative API for Talmud-specific streaming */ export declare function useTalmudStream(options?: UseTalmudStreamOptions): { rawData: TalmudDafAnalysis | undefined; processedData: TalmudDafAnalysis | undefined; startAnalysis: (dafNumber: string, masechet?: string, includeBiur?: boolean, biurLevel?: number) => void; stopAnalysis: () => void; restartAnalysis: () => void; updateStreamOptions: (newOptions: Partial<import("../resolve-placeholder").StreamProcessorOptions<TalmudDafAnalysis>>) => void; sugiyot: Array<TalmudSugya & { isStreaming?: boolean; streamingBiur?: string; completeBiur?: string; biurProgress?: number; }>; isAnalyzing: boolean; analysisProgress: number; totalSugiyot: number; currentStreamingSugya: number | null; error: string | null; currentStep: string; statusMessage: string; isStreamingRaw: boolean; rawContent: string; }; /** * Utility hook for streaming individual biur generation * Provides a simpler API for biur-specific streaming */ export declare function useBiurStream(options?: { baseUrl?: string; }): { biur: string; isComplete: boolean; isStreaming: boolean; error: string | null; generateBiur: (dafNumber: string, sugyaIndex: number, level: number, sugyaTitle: string, sugyaContent: string, masechet?: string) => void; };