@json-render/solid 0.12.0

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.
@@ -0,0 +1,602 @@
1
+ import * as solid_js from 'solid-js';
2
+ import { ParentProps, Accessor, JSX, Component } from 'solid-js';
3
+ import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, UIElement, SchemaDefinition, Spec, ComputedFunction, FlatElement } from '@json-render/core';
4
+ export { Spec, StateModel, StateStore, createStateStore } from '@json-render/core';
5
+ export { ElementTreeSchema, ElementTreeSpec, SolidSchema, SolidSpec, elementTreeSchema, schema } from './schema.mjs';
6
+
7
+ interface StateContextValue {
8
+ state: StateModel;
9
+ get: (path: string) => unknown;
10
+ set: (path: string, value: unknown) => void;
11
+ update: (updates: Record<string, unknown>) => void;
12
+ getSnapshot: () => StateModel;
13
+ subscribeChanges: (listener: (changes: Array<{
14
+ path: string;
15
+ value: unknown;
16
+ }>) => void) => () => void;
17
+ }
18
+ interface StateProviderProps {
19
+ store?: StateStore;
20
+ initialState?: StateModel;
21
+ onStateChange?: (changes: Array<{
22
+ path: string;
23
+ value: unknown;
24
+ }>) => void;
25
+ }
26
+ declare function StateProvider(props: ParentProps<StateProviderProps>): solid_js.JSX.Element;
27
+ declare function useStateStore(): StateContextValue;
28
+ declare function useStateValue<T>(path: string): Accessor<T | undefined>;
29
+ declare function useStateBinding<T>(path: string): [Accessor<T | undefined>, (value: T) => void];
30
+
31
+ interface VisibilityContextValue {
32
+ isVisible: (condition: VisibilityCondition | undefined) => boolean;
33
+ ctx: VisibilityContext;
34
+ }
35
+ type VisibilityProviderProps = ParentProps;
36
+ declare function VisibilityProvider(props: VisibilityProviderProps): solid_js.JSX.Element;
37
+ declare function useVisibility(): VisibilityContextValue;
38
+ declare function useIsVisible(condition: VisibilityCondition | undefined): boolean;
39
+
40
+ interface PendingConfirmation {
41
+ action: ResolvedAction;
42
+ handler: ActionHandler;
43
+ resolve: () => void;
44
+ reject: () => void;
45
+ }
46
+ interface ActionContextValue {
47
+ handlers: Record<string, ActionHandler>;
48
+ loadingActions: Set<string>;
49
+ pendingConfirmation: PendingConfirmation | null;
50
+ execute: (binding: ActionBinding) => Promise<void>;
51
+ confirm: () => void;
52
+ cancel: () => void;
53
+ registerHandler: (name: string, handler: ActionHandler) => void;
54
+ }
55
+ interface ActionProviderProps {
56
+ handlers?: Record<string, ActionHandler>;
57
+ navigate?: (path: string) => void;
58
+ }
59
+ declare function ActionProvider(props: ParentProps<ActionProviderProps>): JSX.Element;
60
+ declare function useActions(): ActionContextValue;
61
+ declare function useAction(binding: ActionBinding): {
62
+ execute: () => Promise<void>;
63
+ isLoading: boolean;
64
+ };
65
+ interface ConfirmDialogProps {
66
+ confirm: ActionConfirm;
67
+ onConfirm: () => void;
68
+ onCancel: () => void;
69
+ }
70
+ declare function ConfirmDialog(props: ConfirmDialogProps): JSX.Element;
71
+
72
+ interface FieldValidationState {
73
+ touched: boolean;
74
+ validated: boolean;
75
+ result: ValidationResult | null;
76
+ }
77
+ interface ValidationContextValue {
78
+ customFunctions: Record<string, ValidationFunction>;
79
+ fieldStates: Record<string, FieldValidationState>;
80
+ validate: (path: string, config: ValidationConfig) => ValidationResult;
81
+ touch: (path: string) => void;
82
+ clear: (path: string) => void;
83
+ validateAll: () => boolean;
84
+ registerField: (path: string, config: ValidationConfig) => void;
85
+ }
86
+ interface ValidationProviderProps {
87
+ customFunctions?: Record<string, ValidationFunction>;
88
+ }
89
+ declare function ValidationProvider(props: ParentProps<ValidationProviderProps>): solid_js.JSX.Element;
90
+ declare function useValidation(): ValidationContextValue;
91
+ declare function useOptionalValidation(): ValidationContextValue | null;
92
+ declare function useFieldValidation(path: string, config?: ValidationConfig): {
93
+ state: Accessor<FieldValidationState>;
94
+ validate: () => ValidationResult;
95
+ touch: () => void;
96
+ clear: () => void;
97
+ errors: Accessor<string[]>;
98
+ isValid: Accessor<boolean>;
99
+ };
100
+
101
+ interface RepeatScopeValue {
102
+ item: unknown;
103
+ index: number;
104
+ basePath: string;
105
+ }
106
+ declare function RepeatScopeProvider(props: ParentProps<RepeatScopeValue>): solid_js.JSX.Element;
107
+ declare function useRepeatScope(): RepeatScopeValue | null;
108
+
109
+ /**
110
+ * State setter function for updating application state
111
+ */
112
+ type SetState = (updater: (prev: Record<string, unknown>) => Record<string, unknown>) => void;
113
+ /**
114
+ * Handle returned by the `on()` function for a specific event.
115
+ * Provides metadata about the event binding and a method to fire it.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const press = on("press");
120
+ * if (press.shouldPreventDefault) e.preventDefault();
121
+ * press.emit();
122
+ * ```
123
+ */
124
+ interface EventHandle {
125
+ /** Fire the event (resolve action bindings) */
126
+ emit: () => void;
127
+ /** Whether any binding requested preventDefault */
128
+ shouldPreventDefault: boolean;
129
+ /** Whether any handler is bound to this event */
130
+ bound: boolean;
131
+ }
132
+ /**
133
+ * Catalog-agnostic base type for component render function arguments.
134
+ * Use this when building reusable component libraries that are not tied
135
+ * to a specific catalog.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const Card = (ctx: BaseComponentProps<{ title?: string }>) => (
140
+ * <div>{ctx.props.title}{ctx.children}</div>
141
+ * );
142
+ * ```
143
+ */
144
+ interface BaseComponentProps<P = Record<string, unknown>> {
145
+ props: P;
146
+ children?: JSX.Element;
147
+ /** Simple event emitter (shorthand). Fires the event and returns void. */
148
+ emit: (event: string) => void;
149
+ /** Get an event handle with metadata. Use when you need shouldPreventDefault or bound checks. */
150
+ on: (event: string) => EventHandle;
151
+ /**
152
+ * Two-way binding paths resolved from `$bindState` / `$bindItem` expressions.
153
+ * Maps prop name → absolute state path for write-back.
154
+ */
155
+ bindings?: Record<string, string>;
156
+ loading?: boolean;
157
+ }
158
+ /**
159
+ * Context passed to component render functions
160
+ * @example
161
+ * const Button: ComponentFn<typeof catalog, 'Button'> = (ctx) => {
162
+ * return <button onClick={() => ctx.emit("press")}>{ctx.props.label}</button>
163
+ * }
164
+ */
165
+ interface ComponentContext<C extends Catalog, K extends keyof InferCatalogComponents<C>> extends BaseComponentProps<InferComponentProps<C, K>> {
166
+ }
167
+ /**
168
+ * Component render function type for Solid
169
+ * @example
170
+ * const Button: ComponentFn<typeof catalog, 'Button'> = (ctx) => (
171
+ * <button onClick={() => ctx.emit("press")}>{ctx.props.label}</button>
172
+ * );
173
+ */
174
+ type ComponentFn<C extends Catalog, K extends keyof InferCatalogComponents<C>> = (ctx: ComponentContext<C, K>) => JSX.Element;
175
+ /**
176
+ * Registry of all component render functions for a catalog
177
+ * @example
178
+ * const components: Components<typeof myCatalog> = {
179
+ * Button: (ctx) => <button>{ctx.props.label}</button>,
180
+ * Input: (ctx) => <input placeholder={ctx.props.placeholder} />,
181
+ * };
182
+ */
183
+ type Components<C extends Catalog> = {
184
+ [K in keyof InferCatalogComponents<C>]: ComponentFn<C, K>;
185
+ };
186
+ /**
187
+ * Action handler function type
188
+ * @example
189
+ * const viewCustomers: ActionFn<typeof catalog, 'viewCustomers'> = async (params, setState) => {
190
+ * const data = await fetch('/api/customers');
191
+ * setState(prev => ({ ...prev, customers: data }));
192
+ * };
193
+ */
194
+ type ActionFn<C extends Catalog, K extends keyof InferCatalogActions<C>> = (params: InferActionParams<C, K> | undefined, setState: SetState, state: StateModel) => Promise<void>;
195
+ /**
196
+ * Registry of all action handlers for a catalog
197
+ * @example
198
+ * const actions: Actions<typeof myCatalog> = {
199
+ * viewCustomers: async (params, setState) => { ... },
200
+ * createCustomer: async (params, setState) => { ... },
201
+ * };
202
+ */
203
+ type Actions<C extends Catalog> = {
204
+ [K in keyof InferCatalogActions<C>]: ActionFn<C, K>;
205
+ };
206
+ /**
207
+ * True when the catalog declares at least one action, false otherwise.
208
+ * Used by defineRegistry to conditionally require the `actions` field.
209
+ */
210
+ type CatalogHasActions<C extends Catalog> = [
211
+ InferCatalogActions<C>
212
+ ] extends [never] ? false : [keyof InferCatalogActions<C>] extends [never] ? false : true;
213
+
214
+ /**
215
+ * Props passed to component renderers
216
+ */
217
+ interface ComponentRenderProps<P = Record<string, unknown>> {
218
+ /** The element being rendered */
219
+ element: UIElement<string, P>;
220
+ /** Rendered children */
221
+ children?: JSX.Element;
222
+ /** Emit a named event. The renderer resolves the event to action binding(s) from the element's `on` field. Always provided by the renderer. */
223
+ emit: (event: string) => void;
224
+ /** Get an event handle with metadata (shouldPreventDefault, bound). Use when you need to inspect event bindings. */
225
+ on: (event: string) => EventHandle;
226
+ /**
227
+ * Two-way binding paths resolved from `$bindState` / `$bindItem` expressions.
228
+ * Maps prop name → absolute state path for write-back.
229
+ * Only present when at least one prop uses `{ $bindState: "..." }` or `{ $bindItem: "..." }`.
230
+ */
231
+ bindings?: Record<string, string>;
232
+ /** Whether the parent is loading */
233
+ loading?: boolean;
234
+ }
235
+ /**
236
+ * Component renderer type
237
+ */
238
+ type ComponentRenderer<P = Record<string, unknown>> = Component<ComponentRenderProps<P>>;
239
+ /**
240
+ * Registry of component renderers
241
+ */
242
+ type ComponentRegistry = Record<string, ComponentRenderer<any>>;
243
+ /**
244
+ * Props for the Renderer component
245
+ */
246
+ interface RendererProps {
247
+ /** The UI spec to render */
248
+ spec: Spec | null;
249
+ /** Component registry */
250
+ registry: ComponentRegistry;
251
+ /** Whether the spec is currently loading/streaming */
252
+ loading?: boolean;
253
+ /** Fallback component for unknown types */
254
+ fallback?: ComponentRenderer;
255
+ }
256
+ /**
257
+ * Main renderer component
258
+ */
259
+ declare function Renderer(props: RendererProps): JSX.Element;
260
+ /**
261
+ * Props for JSONUIProvider
262
+ */
263
+ interface JSONUIProviderProps {
264
+ /** Component registry */
265
+ registry: ComponentRegistry;
266
+ /**
267
+ * External store (controlled mode). When provided, `initialState` and
268
+ * `onStateChange` are ignored.
269
+ */
270
+ store?: StateStore;
271
+ /** Initial state model (uncontrolled mode) */
272
+ initialState?: Record<string, unknown>;
273
+ /** Action handlers */
274
+ handlers?: Record<string, (params: Record<string, unknown>) => Promise<unknown> | unknown>;
275
+ /** Navigation function */
276
+ navigate?: (path: string) => void;
277
+ /** Custom validation functions */
278
+ validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;
279
+ /** Named functions for `$computed` expressions in props */
280
+ functions?: Record<string, ComputedFunction>;
281
+ /** Callback when state changes (uncontrolled mode) */
282
+ onStateChange?: (changes: Array<{
283
+ path: string;
284
+ value: unknown;
285
+ }>) => void;
286
+ children: JSX.Element;
287
+ }
288
+ /**
289
+ * Combined provider for all JSONUI contexts
290
+ */
291
+ declare function JSONUIProvider(props: JSONUIProviderProps): JSX.Element;
292
+ /**
293
+ * Result returned by defineRegistry
294
+ */
295
+ interface DefineRegistryResult {
296
+ /** Component registry for `<Renderer registry={...} />` */
297
+ registry: ComponentRegistry;
298
+ /**
299
+ * Create ActionProvider-compatible handlers.
300
+ * Accepts getter functions so handlers always read the latest state/setState
301
+ * (e.g. from refs or closures).
302
+ */
303
+ handlers: (getSetState: () => SetState | undefined, getState: () => StateModel) => Record<string, (params: Record<string, unknown>) => Promise<void>>;
304
+ /**
305
+ * Execute an action by name imperatively
306
+ * (for use outside the Solid tree, e.g. initial state loading).
307
+ */
308
+ executeAction: (actionName: string, params: Record<string, unknown> | undefined, setState: SetState, state?: StateModel) => Promise<void>;
309
+ }
310
+ /**
311
+ * Options for defineRegistry.
312
+ *
313
+ * When the catalog declares actions, the `actions` field is required.
314
+ * When the catalog has no actions (or `actions: {}`), the field is optional.
315
+ */
316
+ type DefineRegistryOptions<C extends Catalog> = {
317
+ components?: Components<C>;
318
+ } & (CatalogHasActions<C> extends true ? {
319
+ actions: Actions<C>;
320
+ } : {
321
+ actions?: Actions<C>;
322
+ });
323
+ /**
324
+ * Create a registry from a catalog with components and/or actions.
325
+ *
326
+ * When the catalog declares actions, the `actions` field is required.
327
+ *
328
+ * @example
329
+ * ```tsx
330
+ * // Components only (catalog has no actions)
331
+ * const { registry } = defineRegistry(catalog, {
332
+ * components: {
333
+ * Card: (ctx) => (
334
+ * <div class="card">{ctx.props.title}{ctx.children}</div>
335
+ * ),
336
+ * },
337
+ * });
338
+ *
339
+ * // Both (catalog declares actions)
340
+ * const { registry, handlers, executeAction } = defineRegistry(catalog, {
341
+ * components: { ... },
342
+ * actions: { ... },
343
+ * });
344
+ * ```
345
+ */
346
+ declare function defineRegistry<C extends Catalog>(_catalog: C, options: DefineRegistryOptions<C>): DefineRegistryResult;
347
+ /**
348
+ * Props for renderers created with createRenderer
349
+ */
350
+ interface CreateRendererProps {
351
+ /** The spec to render (AI-generated JSON) */
352
+ spec: Spec | null;
353
+ /**
354
+ * External store (controlled mode). When provided, `state` and
355
+ * `onStateChange` are ignored.
356
+ */
357
+ store?: StateStore;
358
+ /** State context for dynamic values (uncontrolled mode) */
359
+ state?: Record<string, unknown>;
360
+ /** Action handler */
361
+ onAction?: (actionName: string, params?: Record<string, unknown>) => void;
362
+ /** Callback when state changes (uncontrolled mode) */
363
+ onStateChange?: (changes: Array<{
364
+ path: string;
365
+ value: unknown;
366
+ }>) => void;
367
+ /** Named functions for `$computed` expressions in props */
368
+ functions?: Record<string, ComputedFunction>;
369
+ /** Whether the spec is currently loading/streaming */
370
+ loading?: boolean;
371
+ /** Fallback component for unknown types */
372
+ fallback?: ComponentRenderer;
373
+ }
374
+ /**
375
+ * Component map type - maps component names to Solid components
376
+ */
377
+ type ComponentMap<TComponents extends Record<string, {
378
+ props: unknown;
379
+ }>> = {
380
+ [K in keyof TComponents]: Component<ComponentRenderProps<TComponents[K]["props"] extends {
381
+ _output: infer O;
382
+ } ? O : Record<string, unknown>>>;
383
+ };
384
+ /**
385
+ * Create a renderer from a catalog
386
+ *
387
+ * @example
388
+ * ```typescript
389
+ * const DashboardRenderer = createRenderer(dashboardCatalog, {
390
+ * Card: (renderProps) => <div class="card">{renderProps.children}</div>,
391
+ * Metric: (renderProps) => <span>{renderProps.element.props.value}</span>,
392
+ * });
393
+ *
394
+ * // Usage
395
+ * <DashboardRenderer spec={aiGeneratedSpec} state={state} />
396
+ * ```
397
+ */
398
+ declare function createRenderer<TDef extends SchemaDefinition, TCatalog extends {
399
+ components: Record<string, {
400
+ props: unknown;
401
+ }>;
402
+ }>(catalog: Catalog<TDef, TCatalog>, components: ComponentMap<TCatalog["components"]>): Component<CreateRendererProps>;
403
+
404
+ /**
405
+ * Token usage metadata from AI generation
406
+ */
407
+ interface TokenUsage {
408
+ promptTokens: number;
409
+ completionTokens: number;
410
+ totalTokens: number;
411
+ }
412
+ /**
413
+ * Options for useUIStream
414
+ */
415
+ interface UseUIStreamOptions {
416
+ /** API endpoint */
417
+ api: string;
418
+ /** Callback when complete */
419
+ onComplete?: (spec: Spec) => void;
420
+ /** Callback on error */
421
+ onError?: (error: Error) => void;
422
+ }
423
+ /**
424
+ * Return type for useUIStream
425
+ */
426
+ interface UseUIStreamReturn {
427
+ /** Current UI spec */
428
+ readonly spec: Spec | null;
429
+ /** Whether currently streaming */
430
+ readonly isStreaming: boolean;
431
+ /** Error if any */
432
+ readonly error: Error | null;
433
+ /** Token usage from the last generation */
434
+ readonly usage: TokenUsage | null;
435
+ /** Raw JSONL lines received from the stream (JSON patch lines) */
436
+ readonly rawLines: string[];
437
+ /** Send a prompt to generate UI */
438
+ send: (prompt: string, context?: Record<string, unknown>) => Promise<void>;
439
+ /** Clear the current spec */
440
+ clear: () => void;
441
+ }
442
+ /**
443
+ * Hook for streaming UI generation
444
+ */
445
+ declare function useUIStream(options: UseUIStreamOptions): UseUIStreamReturn;
446
+ /**
447
+ * Convert a flat element list to a Spec.
448
+ * Input elements use key/parentKey to establish identity and relationships.
449
+ * Output spec uses the map-based format where key is the map entry key
450
+ * and parent-child relationships are expressed through children arrays.
451
+ */
452
+ declare function flatToTree(elements: FlatElement[]): Spec;
453
+ /**
454
+ * Hook for two-way bound props. Returns `[value, setValue]` where:
455
+ *
456
+ * - `value` is the already-resolved prop value (passed through from render props)
457
+ * - `setValue` writes back to the bound state path (no-op if not bound)
458
+ *
459
+ * Designed to work with the `bindings` map that the renderer provides when
460
+ * a prop uses `{ $bindState: "/path" }` or `{ $bindItem: "field" }`.
461
+ *
462
+ * @example
463
+ * ```tsx
464
+ * import { useBoundProp } from "@json-render/solid";
465
+ *
466
+ * const Input: ComponentRenderer = (ctx) => {
467
+ * const [value, setValue] = useBoundProp<string>(ctx.props.value, ctx.bindings?.value);
468
+ * return <input value={value ?? ""} onInput={(e) => setValue(e.target.value)} />;
469
+ * };
470
+ * ```
471
+ */
472
+ declare function useBoundProp<T>(propValue: T | undefined, bindingPath: string | undefined): [T | undefined, (value: T) => void];
473
+ /**
474
+ * A single part from the AI SDK's `message.parts` array. This is a minimal
475
+ * structural type so that library helpers do not depend on the AI SDK.
476
+ * Fields are optional because different part types carry different data:
477
+ * - Text parts have `text`
478
+ * - Data parts have `data`
479
+ */
480
+ interface DataPart {
481
+ type: string;
482
+ text?: string;
483
+ data?: unknown;
484
+ }
485
+ declare function buildSpecFromParts(parts: DataPart[]): Spec | null;
486
+ /**
487
+ * Extract and join all text content from a message's parts array.
488
+ *
489
+ * Filters for parts with `type === "text"`, trims each one, and joins them
490
+ * with double newlines so that text from separate agent steps renders as
491
+ * distinct paragraphs in markdown.
492
+ *
493
+ * Has no AI SDK dependency -- operates on a generic `DataPart[]`.
494
+ *
495
+ * @example
496
+ * ```tsx
497
+ * const text = getTextFromParts(message.parts);
498
+ * if (text) {
499
+ * return <Streamdown>{text}</Streamdown>;
500
+ * }
501
+ * ```
502
+ */
503
+ declare function getTextFromParts(parts: DataPart[]): string;
504
+ /**
505
+ * Hook that extracts both the json-render spec and text content from a
506
+ * message's parts array. Combines `buildSpecFromParts` and `getTextFromParts`
507
+ * into a single call with memoized results.
508
+ *
509
+ * **Memoization behavior:** Results are recomputed only when the `parts`
510
+ * accessor returns a new array reference with a different length or last
511
+ * element. This is optimized for the typical AI SDK streaming pattern where
512
+ * parts are appended incrementally.
513
+ *
514
+ * @example
515
+ * ```tsx
516
+ * import { useJsonRenderMessage } from "@json-render/solid";
517
+ *
518
+ * function MessageBubble(props: { parts: DataPart[] }) {
519
+ * const msg = useJsonRenderMessage(() => props.parts);
520
+ *
521
+ * return (
522
+ * <div>
523
+ * {msg.text && <Markdown>{msg.text}</Markdown>}
524
+ * {msg.hasSpec && <MyRenderer spec={msg.spec!} />}
525
+ * </div>
526
+ * );
527
+ * }
528
+ * ```
529
+ */
530
+ declare function useJsonRenderMessage(getParts: () => DataPart[]): {
531
+ readonly spec: Spec | null;
532
+ readonly text: string;
533
+ readonly hasSpec: boolean;
534
+ };
535
+ /**
536
+ * A single message in the chat, which may contain text, a rendered UI spec, or both.
537
+ */
538
+ interface ChatMessage {
539
+ /** Unique message ID */
540
+ id: string;
541
+ /** Who sent this message */
542
+ role: "user" | "assistant";
543
+ /** Text content (conversational prose) */
544
+ text: string;
545
+ /** json-render Spec built from JSONL patches (null if no UI was generated) */
546
+ spec: Spec | null;
547
+ }
548
+ /**
549
+ * Options for useChatUI
550
+ */
551
+ interface UseChatUIOptions {
552
+ /** API endpoint that accepts `{ messages: Array<{ role, content }> }` and returns a text stream */
553
+ api: string;
554
+ /** Callback when streaming completes for a message */
555
+ onComplete?: (message: ChatMessage) => void;
556
+ /** Callback on error */
557
+ onError?: (error: Error) => void;
558
+ }
559
+ /**
560
+ * Return type for useChatUI
561
+ */
562
+ interface UseChatUIReturn {
563
+ /** All messages in the conversation */
564
+ readonly messages: ChatMessage[];
565
+ /** Whether currently streaming an assistant response */
566
+ readonly isStreaming: boolean;
567
+ /** Error from the last request, if any */
568
+ readonly error: Error | null;
569
+ /** Send a user message */
570
+ send: (text: string) => Promise<void>;
571
+ /** Clear all messages and reset the conversation */
572
+ clear: () => void;
573
+ }
574
+ /**
575
+ * Hook for chat + GenUI experiences.
576
+ *
577
+ * Manages a multi-turn conversation where each assistant message can contain
578
+ * both conversational text and a json-render UI spec. The hook sends the full
579
+ * message history to the API endpoint, reads the streamed response, and
580
+ * separates text lines from JSONL patch lines using `createMixedStreamParser`.
581
+ *
582
+ * @example
583
+ * ```tsx
584
+ * const chat = useChatUI({ api: "/api/chat" });
585
+ *
586
+ * // Send a message
587
+ * await chat.send("Compare weather in NYC and Tokyo");
588
+ *
589
+ * // Render messages
590
+ * <For each={chat.messages}>
591
+ * {(msg) => (
592
+ * <div>
593
+ * {msg.text && <p>{msg.text}</p>}
594
+ * {msg.spec && <MyRenderer spec={msg.spec} />}
595
+ * </div>
596
+ * )}
597
+ * </For>
598
+ * ```
599
+ */
600
+ declare function useChatUI(options: UseChatUIOptions): UseChatUIReturn;
601
+
602
+ export { type ActionContextValue, type ActionFn, ActionProvider, type ActionProviderProps, type Actions, type BaseComponentProps, type ChatMessage, type ComponentContext, type ComponentFn, type ComponentMap, type ComponentRegistry, type ComponentRenderProps, type ComponentRenderer, type Components, ConfirmDialog, type ConfirmDialogProps, type CreateRendererProps, type DataPart, type DefineRegistryResult, type EventHandle, type FieldValidationState, JSONUIProvider, type JSONUIProviderProps, type PendingConfirmation, Renderer, type RendererProps, RepeatScopeProvider, type RepeatScopeValue, type SetState, type StateContextValue, StateProvider, type StateProviderProps, type TokenUsage, type UseChatUIOptions, type UseChatUIReturn, type UseUIStreamOptions, type UseUIStreamReturn, type ValidationContextValue, ValidationProvider, type ValidationProviderProps, type VisibilityContextValue, VisibilityProvider, type VisibilityProviderProps, buildSpecFromParts, createRenderer, defineRegistry, flatToTree, getTextFromParts, useAction, useActions, useBoundProp, useChatUI, useFieldValidation, useIsVisible, useJsonRenderMessage, useOptionalValidation, useRepeatScope, useStateBinding, useStateStore, useStateValue, useUIStream, useValidation, useVisibility };