@june-ai/june-ui 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -139,6 +139,13 @@ interface DocumentStore {
139
139
  remove(id: string): void;
140
140
  }
141
141
  declare function createDocumentStore(): DocumentStore;
142
+ /**
143
+ * Remembers content produced from the user's own edits (for example when JuneUI rewrites
144
+ * the OpenUI program). When that content comes back through the DocumentEditor props it is
145
+ * ignored instead of being treated as a new AI version.
146
+ */
147
+ declare function rememberDocumentEcho(store: DocumentStore, id: string, content: string): void;
148
+ declare function isDocumentEcho(store: DocumentStore, id: string, content: string): boolean;
142
149
  /** The shared in-memory store used when none is provided. Documents are keyed by documentId. */
143
150
  declare function getDefaultDocumentStore(): DocumentStore;
144
151
 
@@ -281,13 +288,49 @@ type JuneRendererProps = Omit<OpenUIRendererProps, "library" | "response" | "isS
281
288
  onJuneError?: (error: JuneError) => void;
282
289
  /** Document editor callbacks and store. Memoize this object. */
283
290
  documents?: JuneDocumentOptions;
291
+ /**
292
+ * Called with an updated OpenUI program when the user edits a document (body or title).
293
+ * The matching `DocumentEditor(id, title, content)` call is rewritten with the new title and
294
+ * the body as Markdown; nothing else in the program changes. Store the value and pass it back
295
+ * as `response` to keep your program (and any "OpenUI Lang" view) in sync with the editor.
296
+ */
297
+ onResponseChange?: (response: string, change: ResponseChangeInfo) => void;
298
+ /** Debounce for onResponseChange in ms (default 300). */
299
+ responseChangeDelay?: number;
284
300
  loadingFallback?: ReactNode;
285
301
  emptyFallback?: ReactNode;
286
302
  errorFallback?: ReactNode | ((args: FallbackArgs) => ReactNode);
287
303
  resetKeys?: readonly unknown[];
288
304
  };
305
+ interface ResponseChangeInfo {
306
+ documentId: string;
307
+ title: string;
308
+ /** The document body written into the program, as Markdown. */
309
+ markdown: string;
310
+ source: DocumentChange["source"];
311
+ }
289
312
  declare function JuneRenderer(props: JuneRendererProps): react.JSX.Element;
290
313
 
314
+ /**
315
+ * Rewrites the arguments of a `DocumentEditor(documentId, title, content, ...)` call inside an
316
+ * OpenUI Lang program, leaving every other character of the program untouched.
317
+ */
318
+ interface DocumentProgramUpdate {
319
+ title?: string;
320
+ /** New document body (Markdown or a Tiptap JSON string). */
321
+ content?: string;
322
+ }
323
+ /**
324
+ * Finds the DocumentEditor call whose first argument equals `documentId` and replaces its title
325
+ * and/or content. Returns the new program, or null when no matching call was found.
326
+ */
327
+ declare function updateDocumentInProgram(program: string, documentId: string, update: DocumentProgramUpdate, componentName?: string): string | null;
328
+ /** Reads the current title and content of a DocumentEditor call, or null. */
329
+ declare function readDocumentFromProgram(program: string, documentId: string, componentName?: string): {
330
+ title: string;
331
+ content: string;
332
+ } | null;
333
+
291
334
  declare function useResolvedTheme(mode: JuneThemeMode): JuneResolvedTheme;
292
335
  interface JuneThemeProviderProps {
293
336
  /**
@@ -502,4 +545,4 @@ declare function JuneUI({ library, ...props }: JuneUIProps): react.JSX.Element;
502
545
  */
503
546
  declare const juneLibrary: Required<_openuidev_lang_core.Library<_openuidev_react_lang.ComponentRenderer<any>, _openuidev_lang_core.DefinedAction<any, string>>>;
504
547
 
505
- export { ALL_EXPORT_FORMATS, type ActionEventParser, type ActionOutcome, type ConfirmAction, type ConsumeStreamOptions, type DocJSON, type DocNode, type DocumentChange, type DocumentConflict, DocumentEditor, type DocumentEditorProps, type DocumentExportEvent, type DocumentExportFormat, type DocumentExporter, type DocumentInstructionOptions, type DocumentRecord, type DocumentSavePayload, type DocumentSnapshot, type DocumentStore, type ExportContext, type ExportResult, type FallbackArgs, type FetchStreamOptions, type JuneAction, type JuneActionContext, type JuneActionDefinition, type JuneActionMap, JuneDocumentContext, JuneDocumentEditorComponent, type JuneDocumentOptions, JuneError, JuneErrorBoundary, type JuneErrorBoundaryProps, type JuneErrorCode, type JuneErrorOptions, type JuneLibraryOptions, JuneRenderer, type JuneRendererProps, type JuneResolvedTheme, JuneRuntimeContext, type JuneStreamState, type JuneThemeMode, JuneThemeProvider, type JuneThemeProviderProps, type JuneThemeVars, JuneUI, type JuneUIProps, type OpenUIActionEvent, type OpenUILibrary, type OpenUIRendererProps, type ParsedActionEvent, type RunActionOptions, type SchemaLike, type SseOptions, type StreamChunk, type StreamSource, type StreamStarter, type StreamStatus, type UseJuneStreamOptions, type UseJuneStreamResult, consumeStream, copyDocumentToClipboard, createActionHandler, createDocumentStore, createJuneLibrary, darkTheme, defaultParseActionEvent, defineJuneAction, defineJuneComponent, documentPromptOptions, downloadResult, exportDocument, fetchStream, getDefaultDocumentStore, getDocumentEditorInstructions, getDocumentEditorRules, isJuneError, jsonFieldExtractor, juneLibrary, lightTheme, listDocumentExporters, mergeDocuments, registerDocumentExporter, runAction, serializeDocumentsForAgent, sseToText, toJuneError, useDocumentOptions, useJuneRuntime, useJuneStream, useJuneTheme, useResolvedTheme, withDocumentEditor };
548
+ export { ALL_EXPORT_FORMATS, type ActionEventParser, type ActionOutcome, type ConfirmAction, type ConsumeStreamOptions, type DocJSON, type DocNode, type DocumentChange, type DocumentConflict, DocumentEditor, type DocumentEditorProps, type DocumentExportEvent, type DocumentExportFormat, type DocumentExporter, type DocumentInstructionOptions, type DocumentProgramUpdate, type DocumentRecord, type DocumentSavePayload, type DocumentSnapshot, type DocumentStore, type ExportContext, type ExportResult, type FallbackArgs, type FetchStreamOptions, type JuneAction, type JuneActionContext, type JuneActionDefinition, type JuneActionMap, JuneDocumentContext, JuneDocumentEditorComponent, type JuneDocumentOptions, JuneError, JuneErrorBoundary, type JuneErrorBoundaryProps, type JuneErrorCode, type JuneErrorOptions, type JuneLibraryOptions, JuneRenderer, type JuneRendererProps, type JuneResolvedTheme, JuneRuntimeContext, type JuneStreamState, type JuneThemeMode, JuneThemeProvider, type JuneThemeProviderProps, type JuneThemeVars, JuneUI, type JuneUIProps, type OpenUIActionEvent, type OpenUILibrary, type OpenUIRendererProps, type ParsedActionEvent, type ResponseChangeInfo, type RunActionOptions, type SchemaLike, type SseOptions, type StreamChunk, type StreamSource, type StreamStarter, type StreamStatus, type UseJuneStreamOptions, type UseJuneStreamResult, consumeStream, copyDocumentToClipboard, createActionHandler, createDocumentStore, createJuneLibrary, darkTheme, defaultParseActionEvent, defineJuneAction, defineJuneComponent, documentPromptOptions, downloadResult, exportDocument, fetchStream, getDefaultDocumentStore, getDocumentEditorInstructions, getDocumentEditorRules, isDocumentEcho, isJuneError, jsonFieldExtractor, juneLibrary, lightTheme, listDocumentExporters, mergeDocuments, readDocumentFromProgram, registerDocumentExporter, rememberDocumentEcho, runAction, serializeDocumentsForAgent, sseToText, toJuneError, updateDocumentInProgram, useDocumentOptions, useJuneRuntime, useJuneStream, useJuneTheme, useResolvedTheme, withDocumentEditor };
package/dist/index.d.ts CHANGED
@@ -139,6 +139,13 @@ interface DocumentStore {
139
139
  remove(id: string): void;
140
140
  }
141
141
  declare function createDocumentStore(): DocumentStore;
142
+ /**
143
+ * Remembers content produced from the user's own edits (for example when JuneUI rewrites
144
+ * the OpenUI program). When that content comes back through the DocumentEditor props it is
145
+ * ignored instead of being treated as a new AI version.
146
+ */
147
+ declare function rememberDocumentEcho(store: DocumentStore, id: string, content: string): void;
148
+ declare function isDocumentEcho(store: DocumentStore, id: string, content: string): boolean;
142
149
  /** The shared in-memory store used when none is provided. Documents are keyed by documentId. */
143
150
  declare function getDefaultDocumentStore(): DocumentStore;
144
151
 
@@ -281,13 +288,49 @@ type JuneRendererProps = Omit<OpenUIRendererProps, "library" | "response" | "isS
281
288
  onJuneError?: (error: JuneError) => void;
282
289
  /** Document editor callbacks and store. Memoize this object. */
283
290
  documents?: JuneDocumentOptions;
291
+ /**
292
+ * Called with an updated OpenUI program when the user edits a document (body or title).
293
+ * The matching `DocumentEditor(id, title, content)` call is rewritten with the new title and
294
+ * the body as Markdown; nothing else in the program changes. Store the value and pass it back
295
+ * as `response` to keep your program (and any "OpenUI Lang" view) in sync with the editor.
296
+ */
297
+ onResponseChange?: (response: string, change: ResponseChangeInfo) => void;
298
+ /** Debounce for onResponseChange in ms (default 300). */
299
+ responseChangeDelay?: number;
284
300
  loadingFallback?: ReactNode;
285
301
  emptyFallback?: ReactNode;
286
302
  errorFallback?: ReactNode | ((args: FallbackArgs) => ReactNode);
287
303
  resetKeys?: readonly unknown[];
288
304
  };
305
+ interface ResponseChangeInfo {
306
+ documentId: string;
307
+ title: string;
308
+ /** The document body written into the program, as Markdown. */
309
+ markdown: string;
310
+ source: DocumentChange["source"];
311
+ }
289
312
  declare function JuneRenderer(props: JuneRendererProps): react.JSX.Element;
290
313
 
314
+ /**
315
+ * Rewrites the arguments of a `DocumentEditor(documentId, title, content, ...)` call inside an
316
+ * OpenUI Lang program, leaving every other character of the program untouched.
317
+ */
318
+ interface DocumentProgramUpdate {
319
+ title?: string;
320
+ /** New document body (Markdown or a Tiptap JSON string). */
321
+ content?: string;
322
+ }
323
+ /**
324
+ * Finds the DocumentEditor call whose first argument equals `documentId` and replaces its title
325
+ * and/or content. Returns the new program, or null when no matching call was found.
326
+ */
327
+ declare function updateDocumentInProgram(program: string, documentId: string, update: DocumentProgramUpdate, componentName?: string): string | null;
328
+ /** Reads the current title and content of a DocumentEditor call, or null. */
329
+ declare function readDocumentFromProgram(program: string, documentId: string, componentName?: string): {
330
+ title: string;
331
+ content: string;
332
+ } | null;
333
+
291
334
  declare function useResolvedTheme(mode: JuneThemeMode): JuneResolvedTheme;
292
335
  interface JuneThemeProviderProps {
293
336
  /**
@@ -502,4 +545,4 @@ declare function JuneUI({ library, ...props }: JuneUIProps): react.JSX.Element;
502
545
  */
503
546
  declare const juneLibrary: Required<_openuidev_lang_core.Library<_openuidev_react_lang.ComponentRenderer<any>, _openuidev_lang_core.DefinedAction<any, string>>>;
504
547
 
505
- export { ALL_EXPORT_FORMATS, type ActionEventParser, type ActionOutcome, type ConfirmAction, type ConsumeStreamOptions, type DocJSON, type DocNode, type DocumentChange, type DocumentConflict, DocumentEditor, type DocumentEditorProps, type DocumentExportEvent, type DocumentExportFormat, type DocumentExporter, type DocumentInstructionOptions, type DocumentRecord, type DocumentSavePayload, type DocumentSnapshot, type DocumentStore, type ExportContext, type ExportResult, type FallbackArgs, type FetchStreamOptions, type JuneAction, type JuneActionContext, type JuneActionDefinition, type JuneActionMap, JuneDocumentContext, JuneDocumentEditorComponent, type JuneDocumentOptions, JuneError, JuneErrorBoundary, type JuneErrorBoundaryProps, type JuneErrorCode, type JuneErrorOptions, type JuneLibraryOptions, JuneRenderer, type JuneRendererProps, type JuneResolvedTheme, JuneRuntimeContext, type JuneStreamState, type JuneThemeMode, JuneThemeProvider, type JuneThemeProviderProps, type JuneThemeVars, JuneUI, type JuneUIProps, type OpenUIActionEvent, type OpenUILibrary, type OpenUIRendererProps, type ParsedActionEvent, type RunActionOptions, type SchemaLike, type SseOptions, type StreamChunk, type StreamSource, type StreamStarter, type StreamStatus, type UseJuneStreamOptions, type UseJuneStreamResult, consumeStream, copyDocumentToClipboard, createActionHandler, createDocumentStore, createJuneLibrary, darkTheme, defaultParseActionEvent, defineJuneAction, defineJuneComponent, documentPromptOptions, downloadResult, exportDocument, fetchStream, getDefaultDocumentStore, getDocumentEditorInstructions, getDocumentEditorRules, isJuneError, jsonFieldExtractor, juneLibrary, lightTheme, listDocumentExporters, mergeDocuments, registerDocumentExporter, runAction, serializeDocumentsForAgent, sseToText, toJuneError, useDocumentOptions, useJuneRuntime, useJuneStream, useJuneTheme, useResolvedTheme, withDocumentEditor };
548
+ export { ALL_EXPORT_FORMATS, type ActionEventParser, type ActionOutcome, type ConfirmAction, type ConsumeStreamOptions, type DocJSON, type DocNode, type DocumentChange, type DocumentConflict, DocumentEditor, type DocumentEditorProps, type DocumentExportEvent, type DocumentExportFormat, type DocumentExporter, type DocumentInstructionOptions, type DocumentProgramUpdate, type DocumentRecord, type DocumentSavePayload, type DocumentSnapshot, type DocumentStore, type ExportContext, type ExportResult, type FallbackArgs, type FetchStreamOptions, type JuneAction, type JuneActionContext, type JuneActionDefinition, type JuneActionMap, JuneDocumentContext, JuneDocumentEditorComponent, type JuneDocumentOptions, JuneError, JuneErrorBoundary, type JuneErrorBoundaryProps, type JuneErrorCode, type JuneErrorOptions, type JuneLibraryOptions, JuneRenderer, type JuneRendererProps, type JuneResolvedTheme, JuneRuntimeContext, type JuneStreamState, type JuneThemeMode, JuneThemeProvider, type JuneThemeProviderProps, type JuneThemeVars, JuneUI, type JuneUIProps, type OpenUIActionEvent, type OpenUILibrary, type OpenUIRendererProps, type ParsedActionEvent, type ResponseChangeInfo, type RunActionOptions, type SchemaLike, type SseOptions, type StreamChunk, type StreamSource, type StreamStarter, type StreamStatus, type UseJuneStreamOptions, type UseJuneStreamResult, consumeStream, copyDocumentToClipboard, createActionHandler, createDocumentStore, createJuneLibrary, darkTheme, defaultParseActionEvent, defineJuneAction, defineJuneComponent, documentPromptOptions, downloadResult, exportDocument, fetchStream, getDefaultDocumentStore, getDocumentEditorInstructions, getDocumentEditorRules, isDocumentEcho, isJuneError, jsonFieldExtractor, juneLibrary, lightTheme, listDocumentExporters, mergeDocuments, readDocumentFromProgram, registerDocumentExporter, rememberDocumentEcho, runAction, serializeDocumentsForAgent, sseToText, toJuneError, updateDocumentInProgram, useDocumentOptions, useJuneRuntime, useJuneStream, useJuneTheme, useResolvedTheme, withDocumentEditor };