@xmachines/json-render-solid 0.19.0-xm.1

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.js ADDED
@@ -0,0 +1,1973 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ActionProvider: () => ActionProvider,
24
+ ConfirmDialog: () => ConfirmDialog,
25
+ JSONUIProvider: () => JSONUIProvider,
26
+ Renderer: () => Renderer,
27
+ RepeatScopeProvider: () => RepeatScopeProvider,
28
+ StateProvider: () => StateProvider,
29
+ ValidationProvider: () => ValidationProvider,
30
+ VisibilityProvider: () => VisibilityProvider,
31
+ buildSpecFromParts: () => buildSpecFromParts,
32
+ createRenderer: () => createRenderer,
33
+ createStateStore: () => import_core8.createStateStore,
34
+ defineRegistry: () => defineRegistry,
35
+ elementTreeSchema: () => elementTreeSchema,
36
+ flatToTree: () => flatToTree,
37
+ getTextFromParts: () => getTextFromParts,
38
+ schema: () => schema,
39
+ useAction: () => useAction,
40
+ useActions: () => useActions,
41
+ useBoundProp: () => useBoundProp,
42
+ useChatUI: () => useChatUI,
43
+ useFieldValidation: () => useFieldValidation,
44
+ useIsVisible: () => useIsVisible,
45
+ useJsonRenderMessage: () => useJsonRenderMessage,
46
+ useOptionalValidation: () => useOptionalValidation,
47
+ useRepeatScope: () => useRepeatScope,
48
+ useStateBinding: () => useStateBinding,
49
+ useStateStore: () => useStateStore,
50
+ useStateValue: () => useStateValue,
51
+ useUIStream: () => useUIStream,
52
+ useValidation: () => useValidation,
53
+ useVisibility: () => useVisibility
54
+ });
55
+ module.exports = __toCommonJS(index_exports);
56
+
57
+ // src/contexts/state.tsx
58
+ var import_web = require("solid-js/web");
59
+ var import_solid_js = require("solid-js");
60
+ var import_core = require("@xmachines/json-render-core");
61
+ var import_store_utils = require("@xmachines/json-render-core/store-utils");
62
+ var StateContext = (0, import_solid_js.createContext)(null);
63
+ function computeInitialFlat(isControlled, initialState) {
64
+ if (isControlled) return null;
65
+ if (Object.keys(initialState).length === 0) return {};
66
+ return (0, import_store_utils.flattenToPointers)(initialState);
67
+ }
68
+ function StateProvider(props) {
69
+ let internalStore;
70
+ if (!props.store) {
71
+ internalStore = (0, import_core.createStateStore)(props.initialState ?? {});
72
+ }
73
+ const store = () => props.store ?? internalStore;
74
+ const initialMode = props.store ? "controlled" : "uncontrolled";
75
+ let modeWarned = false;
76
+ if (typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV !== "production") {
77
+ (0, import_solid_js.createEffect)(() => {
78
+ const currentMode = props.store ? "controlled" : "uncontrolled";
79
+ if (currentMode !== initialMode && !modeWarned) {
80
+ modeWarned = true;
81
+ console.warn(`StateProvider: switching from ${initialMode} to ${currentMode} mode is not supported.`);
82
+ }
83
+ });
84
+ }
85
+ let prevInitialState = props.initialState;
86
+ let prevFlat = computeInitialFlat(!!props.store, props.initialState ?? {});
87
+ (0, import_solid_js.createEffect)(() => {
88
+ if (props.store) return;
89
+ const initialState = props.initialState ?? {};
90
+ if (initialState === prevInitialState) return;
91
+ prevInitialState = initialState;
92
+ const nextFlat = initialState && Object.keys(initialState).length > 0 ? (0, import_store_utils.flattenToPointers)(initialState) : {};
93
+ const prevFlatObj = prevFlat ?? {};
94
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(prevFlatObj), ...Object.keys(nextFlat)]);
95
+ const updates = {};
96
+ for (const key of allKeys) {
97
+ if (prevFlatObj[key] !== nextFlat[key]) {
98
+ updates[key] = key in nextFlat ? nextFlat[key] : void 0;
99
+ }
100
+ }
101
+ prevFlat = nextFlat;
102
+ if (Object.keys(updates).length > 0) {
103
+ store().update(updates);
104
+ }
105
+ });
106
+ const [state, setState] = (0, import_solid_js.createSignal)(store().getSnapshot(), {
107
+ equals: false
108
+ });
109
+ const changeListeners = /* @__PURE__ */ new Set();
110
+ const subscribeChanges = (listener) => {
111
+ changeListeners.add(listener);
112
+ return () => {
113
+ changeListeners.delete(listener);
114
+ };
115
+ };
116
+ const notifyChanges = (changes) => {
117
+ for (const listener of changeListeners) {
118
+ listener(changes);
119
+ }
120
+ };
121
+ (0, import_solid_js.createEffect)(() => {
122
+ const s = store();
123
+ setState(s.getSnapshot());
124
+ const unsubscribe = s.subscribe(() => {
125
+ setState(s.getSnapshot());
126
+ });
127
+ (0, import_solid_js.onCleanup)(unsubscribe);
128
+ });
129
+ const set = (path, value) => {
130
+ const s = store();
131
+ const prev = s.getSnapshot();
132
+ const prevValue = (0, import_core.getByPath)(prev, path);
133
+ s.set(path, value);
134
+ if (prevValue !== value) {
135
+ const changes = [{
136
+ path,
137
+ value
138
+ }];
139
+ notifyChanges(changes);
140
+ if (!props.store && s.getSnapshot() !== prev) {
141
+ props.onStateChange?.(changes);
142
+ }
143
+ }
144
+ };
145
+ const update = (updates) => {
146
+ const s = store();
147
+ const prev = s.getSnapshot();
148
+ s.update(updates);
149
+ const changes = [];
150
+ for (const [path, value] of Object.entries(updates)) {
151
+ if ((0, import_core.getByPath)(prev, path) !== value) {
152
+ changes.push({
153
+ path,
154
+ value
155
+ });
156
+ }
157
+ }
158
+ if (changes.length > 0) {
159
+ notifyChanges(changes);
160
+ if (!props.store && s.getSnapshot() !== prev) {
161
+ props.onStateChange?.(changes);
162
+ }
163
+ }
164
+ };
165
+ const get = (path) => store().get(path);
166
+ const getSnapshot = () => store().getSnapshot();
167
+ const ctx = {
168
+ get state() {
169
+ return state();
170
+ },
171
+ get,
172
+ set,
173
+ update,
174
+ getSnapshot,
175
+ subscribeChanges
176
+ };
177
+ return (0, import_web.createComponent)(StateContext.Provider, {
178
+ value: ctx,
179
+ get children() {
180
+ return props.children;
181
+ }
182
+ });
183
+ }
184
+ function useStateStore() {
185
+ const ctx = (0, import_solid_js.useContext)(StateContext);
186
+ if (!ctx) {
187
+ throw new Error("useStateStore must be used within a StateProvider");
188
+ }
189
+ return ctx;
190
+ }
191
+ function useStateValue(path) {
192
+ const store = useStateStore();
193
+ return (0, import_solid_js.createMemo)(() => (0, import_core.getByPath)(store.state, path));
194
+ }
195
+ function useStateBinding(path) {
196
+ const store = useStateStore();
197
+ const value = (0, import_solid_js.createMemo)(() => (0, import_core.getByPath)(store.state, path));
198
+ const setValue = (newValue) => store.set(path, newValue);
199
+ return [value, setValue];
200
+ }
201
+
202
+ // src/contexts/visibility.tsx
203
+ var import_web2 = require("solid-js/web");
204
+ var import_solid_js2 = require("solid-js");
205
+ var import_core2 = require("@xmachines/json-render-core");
206
+ var VisibilityContext = (0, import_solid_js2.createContext)(null);
207
+ function VisibilityProvider(props) {
208
+ const stateStore = useStateStore();
209
+ const visibilityCtx = {
210
+ get stateModel() {
211
+ return stateStore.state;
212
+ }
213
+ };
214
+ const value = {
215
+ isVisible: (condition) => (0, import_core2.evaluateVisibility)(condition, visibilityCtx),
216
+ ctx: visibilityCtx
217
+ };
218
+ return (0, import_web2.createComponent)(VisibilityContext.Provider, {
219
+ value,
220
+ get children() {
221
+ return props.children;
222
+ }
223
+ });
224
+ }
225
+ function useVisibility() {
226
+ const ctx = (0, import_solid_js2.useContext)(VisibilityContext);
227
+ if (!ctx) {
228
+ throw new Error("useVisibility must be used within a VisibilityProvider");
229
+ }
230
+ return ctx;
231
+ }
232
+ function useIsVisible(condition) {
233
+ const {
234
+ isVisible
235
+ } = useVisibility();
236
+ return isVisible(condition);
237
+ }
238
+
239
+ // src/contexts/actions.tsx
240
+ var import_web4 = require("solid-js/web");
241
+ var import_web5 = require("solid-js/web");
242
+ var import_web6 = require("solid-js/web");
243
+ var import_web7 = require("solid-js/web");
244
+ var import_web8 = require("solid-js/web");
245
+ var import_web9 = require("solid-js/web");
246
+ var import_web10 = require("solid-js/web");
247
+ var import_web11 = require("solid-js/web");
248
+ var import_solid_js4 = require("solid-js");
249
+ var import_core4 = require("@xmachines/json-render-core");
250
+
251
+ // src/contexts/validation.tsx
252
+ var import_web3 = require("solid-js/web");
253
+ var import_solid_js3 = require("solid-js");
254
+ var import_core3 = require("@xmachines/json-render-core");
255
+ var ValidationContext = (0, import_solid_js3.createContext)(null);
256
+ function dynamicArgsEqual(a, b) {
257
+ if (a === b) return true;
258
+ if (!a || !b) return false;
259
+ const keysA = Object.keys(a);
260
+ const keysB = Object.keys(b);
261
+ if (keysA.length !== keysB.length) return false;
262
+ for (const key of keysA) {
263
+ const va = a[key];
264
+ const vb = b[key];
265
+ if (va === vb) continue;
266
+ if (typeof va === "object" && va !== null && typeof vb === "object" && vb !== null) {
267
+ const sa = va.$state;
268
+ const sb = vb.$state;
269
+ if (typeof sa === "string" && sa === sb) continue;
270
+ }
271
+ return false;
272
+ }
273
+ return true;
274
+ }
275
+ function validationConfigEqual(a, b) {
276
+ if (a === b) return true;
277
+ if (a.validateOn !== b.validateOn) return false;
278
+ const ac = a.checks ?? [];
279
+ const bc = b.checks ?? [];
280
+ if (ac.length !== bc.length) return false;
281
+ for (let i = 0; i < ac.length; i++) {
282
+ const ca = ac[i];
283
+ const cb = bc[i];
284
+ if (ca.type !== cb.type) return false;
285
+ if (ca.message !== cb.message) return false;
286
+ if (!dynamicArgsEqual(ca.args, cb.args)) return false;
287
+ }
288
+ return true;
289
+ }
290
+ function ValidationProvider(props) {
291
+ const {
292
+ getSnapshot
293
+ } = useStateStore();
294
+ const customFunctions = () => props.customFunctions ?? {};
295
+ const [fieldStates, setFieldStates] = (0, import_solid_js3.createSignal)({});
296
+ let fieldStatesRef = {};
297
+ const [fieldConfigs, setFieldConfigs] = (0, import_solid_js3.createSignal)({});
298
+ const registerField = (path, config) => {
299
+ setFieldConfigs((prev) => {
300
+ const existing = prev[path];
301
+ if (existing && validationConfigEqual(existing, config)) {
302
+ return prev;
303
+ }
304
+ return {
305
+ ...prev,
306
+ [path]: config
307
+ };
308
+ });
309
+ };
310
+ const validate = (path, config) => {
311
+ const currentState = getSnapshot();
312
+ const segments = path.split("/").filter(Boolean);
313
+ let value2 = currentState;
314
+ for (const seg of segments) {
315
+ if (value2 != null && typeof value2 === "object") {
316
+ value2 = value2[seg];
317
+ } else {
318
+ value2 = void 0;
319
+ break;
320
+ }
321
+ }
322
+ const result = (0, import_core3.runValidation)(config, {
323
+ value: value2,
324
+ stateModel: currentState,
325
+ customFunctions: customFunctions()
326
+ });
327
+ const newFieldState = {
328
+ touched: fieldStatesRef[path]?.touched ?? true,
329
+ validated: true,
330
+ result
331
+ };
332
+ fieldStatesRef = {
333
+ ...fieldStatesRef,
334
+ [path]: newFieldState
335
+ };
336
+ setFieldStates(fieldStatesRef);
337
+ return result;
338
+ };
339
+ const touch = (path) => {
340
+ fieldStatesRef = {
341
+ ...fieldStatesRef,
342
+ [path]: {
343
+ ...fieldStatesRef[path],
344
+ touched: true,
345
+ validated: fieldStatesRef[path]?.validated ?? false,
346
+ result: fieldStatesRef[path]?.result ?? null
347
+ }
348
+ };
349
+ setFieldStates(fieldStatesRef);
350
+ };
351
+ const clear = (path) => {
352
+ const {
353
+ [path]: _,
354
+ ...rest
355
+ } = fieldStatesRef;
356
+ fieldStatesRef = rest;
357
+ setFieldStates(rest);
358
+ };
359
+ const validateAll = () => {
360
+ let allValid = true;
361
+ for (const [path, config] of Object.entries(fieldConfigs())) {
362
+ const result = validate(path, config);
363
+ if (!result.valid) {
364
+ allValid = false;
365
+ }
366
+ }
367
+ return allValid;
368
+ };
369
+ const value = {
370
+ get customFunctions() {
371
+ return customFunctions();
372
+ },
373
+ get fieldStates() {
374
+ fieldStates();
375
+ return fieldStatesRef;
376
+ },
377
+ validate,
378
+ touch,
379
+ clear,
380
+ validateAll,
381
+ registerField
382
+ };
383
+ return (0, import_web3.createComponent)(ValidationContext.Provider, {
384
+ value,
385
+ get children() {
386
+ return props.children;
387
+ }
388
+ });
389
+ }
390
+ function useValidation() {
391
+ const ctx = (0, import_solid_js3.useContext)(ValidationContext);
392
+ if (!ctx) {
393
+ throw new Error("useValidation must be used within a ValidationProvider");
394
+ }
395
+ return ctx;
396
+ }
397
+ function useOptionalValidation() {
398
+ return (0, import_solid_js3.useContext)(ValidationContext);
399
+ }
400
+ function useFieldValidation(path, config) {
401
+ const validation = useValidation();
402
+ (0, import_solid_js3.createEffect)(() => {
403
+ if (path && config) {
404
+ validation.registerField(path, config);
405
+ }
406
+ });
407
+ const state = (0, import_solid_js3.createMemo)(() => {
408
+ const current = validation.fieldStates[path];
409
+ return current ?? {
410
+ touched: false,
411
+ validated: false,
412
+ result: null
413
+ };
414
+ });
415
+ const validate = () => validation.validate(path, config ?? {
416
+ checks: []
417
+ });
418
+ const touch = () => validation.touch(path);
419
+ const clear = () => validation.clear(path);
420
+ const errors = (0, import_solid_js3.createMemo)(() => state().result?.errors ?? []);
421
+ const isValid = (0, import_solid_js3.createMemo)(() => state().result?.valid ?? true);
422
+ return {
423
+ state,
424
+ validate,
425
+ touch,
426
+ clear,
427
+ errors,
428
+ isValid
429
+ };
430
+ }
431
+
432
+ // src/contexts/actions.tsx
433
+ var _tmpl$ = /* @__PURE__ */ (0, import_web4.template)(`<div style="position:fixed;inset:0;background-color:rgba(0, 0, 0, 0.5);display:flex;align-items:center;justify-content:center;z-index:50"><div style="background-color:white;border-radius:8px;padding:24px;max-width:400px;width:100%;box-shadow:0 20px 25px -5px rgba(0, 0, 0, 0.1)"><h3 style="margin:0 0 8px 0;font-size:18px;font-weight:600"></h3><p style="margin:0 0 24px 0;color:#6b7280"></p><div style=display:flex;gap:12px;justify-content:flex-end><button style="padding:8px 16px;border-radius:6px;border:1px solid #d1d5db;background-color:white;cursor:pointer"></button><button style="padding:8px 16px;border-radius:6px;border:none;color:white;cursor:pointer">`);
434
+ var idCounter = 0;
435
+ function generateUniqueId() {
436
+ idCounter += 1;
437
+ return `${Date.now()}-${idCounter}`;
438
+ }
439
+ function deepResolveValue(value, get) {
440
+ if (value === null || value === void 0) return value;
441
+ if (value === "$id") {
442
+ return generateUniqueId();
443
+ }
444
+ if (typeof value === "object" && !Array.isArray(value)) {
445
+ const obj = value;
446
+ const keys = Object.keys(obj);
447
+ if (keys.length === 1 && typeof obj.$state === "string") {
448
+ return get(obj.$state);
449
+ }
450
+ if (keys.length === 1 && "$id" in obj) {
451
+ return generateUniqueId();
452
+ }
453
+ }
454
+ if (Array.isArray(value)) {
455
+ return value.map((item) => deepResolveValue(item, get));
456
+ }
457
+ if (typeof value === "object") {
458
+ const resolved = {};
459
+ for (const [key, val] of Object.entries(value)) {
460
+ resolved[key] = deepResolveValue(val, get);
461
+ }
462
+ return resolved;
463
+ }
464
+ return value;
465
+ }
466
+ var ActionContext = (0, import_solid_js4.createContext)(null);
467
+ function ActionProvider(props) {
468
+ const {
469
+ get,
470
+ set,
471
+ getSnapshot
472
+ } = useStateStore();
473
+ const validation = useOptionalValidation();
474
+ const [handlers, setHandlers] = (0, import_solid_js4.createSignal)(props.handlers ?? {});
475
+ const [loadingActions, setLoadingActions] = (0, import_solid_js4.createSignal)(/* @__PURE__ */ new Set());
476
+ const [pendingConfirmation, setPendingConfirmation] = (0, import_solid_js4.createSignal)(null);
477
+ const registerHandler = (name, handler) => {
478
+ setHandlers((prev) => ({
479
+ ...prev,
480
+ [name]: handler
481
+ }));
482
+ };
483
+ const execute = async (binding) => {
484
+ const resolved = (0, import_core4.resolveAction)(binding, getSnapshot());
485
+ const dispatchId = (0, import_core4.nextActionDispatchId)();
486
+ const dispatchedAt = Date.now();
487
+ (0, import_core4.notifyActionDispatch)({
488
+ id: dispatchId,
489
+ name: resolved.action,
490
+ params: resolved.params,
491
+ at: dispatchedAt
492
+ });
493
+ let __ok = true;
494
+ let __error = void 0;
495
+ try {
496
+ if (resolved.action === "setState" && resolved.params) {
497
+ const statePath = resolved.params.statePath;
498
+ const value = resolved.params.value;
499
+ if (statePath) {
500
+ set(statePath, value);
501
+ }
502
+ return;
503
+ }
504
+ if (resolved.action === "pushState" && resolved.params) {
505
+ const statePath = resolved.params.statePath;
506
+ const rawValue = resolved.params.value;
507
+ if (statePath) {
508
+ const resolvedValue = deepResolveValue(rawValue, get);
509
+ const arr = get(statePath) ?? [];
510
+ set(statePath, [...arr, resolvedValue]);
511
+ const clearStatePath = resolved.params.clearStatePath;
512
+ if (clearStatePath) {
513
+ set(clearStatePath, "");
514
+ }
515
+ }
516
+ return;
517
+ }
518
+ if (resolved.action === "removeState" && resolved.params) {
519
+ const statePath = resolved.params.statePath;
520
+ const index = resolved.params.index;
521
+ if (statePath !== void 0 && index !== void 0) {
522
+ const arr = get(statePath) ?? [];
523
+ set(statePath, arr.filter((_, i) => i !== index));
524
+ }
525
+ return;
526
+ }
527
+ if (resolved.action === "push" && resolved.params) {
528
+ const screen = resolved.params.screen;
529
+ if (screen) {
530
+ const currentScreen = get("/currentScreen");
531
+ const navStack = get("/navStack") ?? [];
532
+ if (currentScreen) {
533
+ set("/navStack", [...navStack, currentScreen]);
534
+ } else {
535
+ set("/navStack", [...navStack, ""]);
536
+ }
537
+ set("/currentScreen", screen);
538
+ }
539
+ return;
540
+ }
541
+ if (resolved.action === "pop") {
542
+ const navStack = get("/navStack") ?? [];
543
+ if (navStack.length > 0) {
544
+ const previousScreen = navStack[navStack.length - 1];
545
+ set("/navStack", navStack.slice(0, -1));
546
+ if (previousScreen) {
547
+ set("/currentScreen", previousScreen);
548
+ } else {
549
+ set("/currentScreen", void 0);
550
+ }
551
+ }
552
+ return;
553
+ }
554
+ if (resolved.action === "validateForm") {
555
+ const validateAll = validation?.validateAll;
556
+ if (!validateAll) {
557
+ console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");
558
+ return;
559
+ }
560
+ const valid = validateAll();
561
+ const errors = {};
562
+ for (const [path, fs] of Object.entries(validation.fieldStates)) {
563
+ if (fs.result && !fs.result.valid) {
564
+ errors[path] = fs.result.errors;
565
+ }
566
+ }
567
+ const statePath = resolved.params?.statePath || "/formValidation";
568
+ set(statePath, {
569
+ valid,
570
+ errors
571
+ });
572
+ return;
573
+ }
574
+ const handler = handlers()[resolved.action];
575
+ if (!handler) {
576
+ console.warn(`No handler registered for action: ${resolved.action}`);
577
+ return;
578
+ }
579
+ if (resolved.confirm) {
580
+ return new Promise((resolve, reject) => {
581
+ setPendingConfirmation({
582
+ action: resolved,
583
+ handler,
584
+ resolve: () => {
585
+ setPendingConfirmation(null);
586
+ resolve();
587
+ },
588
+ reject: () => {
589
+ setPendingConfirmation(null);
590
+ reject(new Error("Action cancelled"));
591
+ }
592
+ });
593
+ }).then(async () => {
594
+ setLoadingActions((prev) => new Set(prev).add(resolved.action));
595
+ try {
596
+ await (0, import_core4.executeAction)({
597
+ action: resolved,
598
+ handler,
599
+ setState: set,
600
+ navigate: props.navigate,
601
+ executeAction: async (name) => {
602
+ const subBinding = {
603
+ action: name
604
+ };
605
+ await execute(subBinding);
606
+ }
607
+ });
608
+ } finally {
609
+ setLoadingActions((prev) => {
610
+ const next = new Set(prev);
611
+ next.delete(resolved.action);
612
+ return next;
613
+ });
614
+ }
615
+ });
616
+ }
617
+ setLoadingActions((prev) => new Set(prev).add(resolved.action));
618
+ try {
619
+ await (0, import_core4.executeAction)({
620
+ action: resolved,
621
+ handler,
622
+ setState: set,
623
+ navigate: props.navigate,
624
+ executeAction: async (name) => {
625
+ const subBinding = {
626
+ action: name
627
+ };
628
+ await execute(subBinding);
629
+ }
630
+ });
631
+ } finally {
632
+ setLoadingActions((prev) => {
633
+ const next = new Set(prev);
634
+ next.delete(resolved.action);
635
+ return next;
636
+ });
637
+ }
638
+ } catch (err) {
639
+ __ok = false;
640
+ __error = err;
641
+ throw err;
642
+ } finally {
643
+ const now = Date.now();
644
+ (0, import_core4.notifyActionSettle)({
645
+ id: dispatchId,
646
+ name: resolved.action,
647
+ ok: __ok,
648
+ at: now,
649
+ durationMs: now - dispatchedAt,
650
+ error: __error
651
+ });
652
+ }
653
+ };
654
+ const confirm = () => {
655
+ pendingConfirmation()?.resolve();
656
+ };
657
+ const cancel = () => {
658
+ pendingConfirmation()?.reject();
659
+ };
660
+ const ctx = {
661
+ get handlers() {
662
+ return handlers();
663
+ },
664
+ get loadingActions() {
665
+ return loadingActions();
666
+ },
667
+ get pendingConfirmation() {
668
+ return pendingConfirmation();
669
+ },
670
+ execute,
671
+ confirm,
672
+ cancel,
673
+ registerHandler
674
+ };
675
+ return (0, import_web11.createComponent)(ActionContext.Provider, {
676
+ value: ctx,
677
+ get children() {
678
+ return props.children;
679
+ }
680
+ });
681
+ }
682
+ function useActions() {
683
+ const ctx = (0, import_solid_js4.useContext)(ActionContext);
684
+ if (!ctx) {
685
+ throw new Error("useActions must be used within an ActionProvider");
686
+ }
687
+ return ctx;
688
+ }
689
+ function useAction(binding) {
690
+ const actions = useActions();
691
+ return {
692
+ execute: () => actions.execute(binding),
693
+ get isLoading() {
694
+ return actions.loadingActions.has(binding.action);
695
+ }
696
+ };
697
+ }
698
+ function ConfirmDialog(props) {
699
+ const isDanger = () => props.confirm.variant === "danger";
700
+ return (() => {
701
+ var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.nextSibling, _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling;
702
+ (0, import_web10.addEventListener)(_el$, "click", props.onCancel, true);
703
+ _el$2.$$click = (e) => e.stopPropagation();
704
+ (0, import_web9.insert)(_el$3, () => props.confirm.title);
705
+ (0, import_web9.insert)(_el$4, () => props.confirm.message);
706
+ (0, import_web10.addEventListener)(_el$6, "click", props.onCancel, true);
707
+ (0, import_web9.insert)(_el$6, () => props.confirm.cancelLabel ?? "Cancel");
708
+ (0, import_web10.addEventListener)(_el$7, "click", props.onConfirm, true);
709
+ (0, import_web9.insert)(_el$7, () => props.confirm.confirmLabel ?? "Confirm");
710
+ (0, import_web7.effect)((_$p) => (0, import_web6.setStyleProperty)(_el$7, "background-color", isDanger() ? "#dc2626" : "#3b82f6"));
711
+ return _el$;
712
+ })();
713
+ }
714
+ (0, import_web5.delegateEvents)(["click"]);
715
+
716
+ // src/contexts/repeat-scope.tsx
717
+ var import_web12 = require("solid-js/web");
718
+ var import_solid_js5 = require("solid-js");
719
+ var RepeatScopeContext = (0, import_solid_js5.createContext)(null);
720
+ function RepeatScopeProvider(props) {
721
+ return (0, import_web12.createComponent)(RepeatScopeContext.Provider, {
722
+ get value() {
723
+ return {
724
+ item: props.item,
725
+ index: props.index,
726
+ basePath: props.basePath
727
+ };
728
+ },
729
+ get children() {
730
+ return props.children;
731
+ }
732
+ });
733
+ }
734
+ function useRepeatScope() {
735
+ return (0, import_solid_js5.useContext)(RepeatScopeContext);
736
+ }
737
+
738
+ // src/schema.ts
739
+ var import_core5 = require("@xmachines/json-render-core");
740
+ var schema = (0, import_core5.defineSchema)(
741
+ (s) => ({
742
+ // What the AI-generated SPEC looks like
743
+ spec: s.object({
744
+ /** Root element key */
745
+ root: s.string(),
746
+ /** Flat map of elements by key */
747
+ elements: s.record(
748
+ s.object({
749
+ /** Component type from catalog */
750
+ type: s.ref("catalog.components"),
751
+ /** Component props */
752
+ props: s.propsOf("catalog.components"),
753
+ /** Child element keys (flat reference) */
754
+ children: s.array(s.string()),
755
+ /** Visibility condition */
756
+ visible: s.any()
757
+ })
758
+ )
759
+ }),
760
+ // What the CATALOG must provide
761
+ catalog: s.object({
762
+ /** Component definitions */
763
+ components: s.map({
764
+ /** Zod schema for component props */
765
+ props: s.zod(),
766
+ /** Slots for this component. Use ['default'] for children, or named slots like ['header', 'footer'] */
767
+ slots: s.array(s.string()),
768
+ /** Description for AI generation hints */
769
+ description: s.string(),
770
+ /** Example prop values used in prompt examples (auto-generated from Zod schema if omitted) */
771
+ example: s.any()
772
+ }),
773
+ /** Action definitions (optional) */
774
+ actions: s.map({
775
+ /** Zod schema for action params */
776
+ params: s.zod(),
777
+ /** Description for AI generation hints */
778
+ description: s.string()
779
+ })
780
+ })
781
+ }),
782
+ {
783
+ builtInActions: [
784
+ {
785
+ name: "setState",
786
+ description: "Update a value in the state model at the given statePath. Params: { statePath: string, value: any }"
787
+ },
788
+ {
789
+ name: "pushState",
790
+ description: 'Append an item to an array in state. Params: { statePath: string, value: any, clearStatePath?: string }. Value can contain {"$state":"/path"} refs and "$id" for auto IDs.'
791
+ },
792
+ {
793
+ name: "removeState",
794
+ description: "Remove an item from an array in state by index. Params: { statePath: string, index: number }"
795
+ },
796
+ {
797
+ name: "validateForm",
798
+ description: "Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation. Result: { valid: boolean, errors: Record<string, string[]> }."
799
+ }
800
+ ],
801
+ defaultRules: [
802
+ // Element integrity
803
+ "CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.",
804
+ "SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",
805
+ // Field placement
806
+ 'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.',
807
+ 'CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',
808
+ // State and data
809
+ "When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).",
810
+ 'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',
811
+ // Design quality
812
+ "Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.",
813
+ "For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.",
814
+ "Always include realistic, professional-looking sample data. For blogs include 3-4 posts with varied titles, authors, dates, categories. For products include names, prices, images. Never leave data empty."
815
+ ]
816
+ }
817
+ );
818
+ var elementTreeSchema = schema;
819
+
820
+ // src/index.ts
821
+ var import_core8 = require("@xmachines/json-render-core");
822
+
823
+ // src/renderer.tsx
824
+ var import_web13 = require("solid-js/web");
825
+ var import_web14 = require("solid-js/web");
826
+ var import_web15 = require("solid-js/web");
827
+ var import_web16 = require("solid-js/web");
828
+ var import_web17 = require("solid-js/web");
829
+ var import_web18 = require("solid-js/web");
830
+ var import_solid_js6 = require("solid-js");
831
+ var import_core6 = require("@xmachines/json-render-core");
832
+ var _tmpl$2 = /* @__PURE__ */ (0, import_web13.template)(`<span style=display:contents>`);
833
+ function reportRenderError(registry, elementType, error) {
834
+ const onRenderError = registry?.onRenderError;
835
+ if (typeof onRenderError === "function") {
836
+ onRenderError(error, elementType);
837
+ return;
838
+ }
839
+ console.error(`[json-render] Rendering error in <${elementType}>:`, error);
840
+ }
841
+ var EMPTY_FUNCTIONS = {};
842
+ var FunctionsContext = (0, import_solid_js6.createContext)(EMPTY_FUNCTIONS);
843
+ function useFunctions() {
844
+ return (0, import_solid_js6.useContext)(FunctionsContext) ?? EMPTY_FUNCTIONS;
845
+ }
846
+ var DirectivesContext = (0, import_solid_js6.createContext)(void 0);
847
+ function useDirectives() {
848
+ return (0, import_solid_js6.useContext)(DirectivesContext);
849
+ }
850
+ function useDevtoolsActive() {
851
+ const [active, setActive] = (0, import_solid_js6.createSignal)((0, import_core6.isDevtoolsActive)());
852
+ const unsub = (0, import_core6.subscribeDevtoolsActive)(() => setActive((0, import_core6.isDevtoolsActive)()));
853
+ (0, import_solid_js6.onCleanup)(unsub);
854
+ return active;
855
+ }
856
+ function ElementRenderer(props) {
857
+ const repeatScope = useRepeatScope();
858
+ const {
859
+ ctx
860
+ } = useVisibility();
861
+ const {
862
+ execute
863
+ } = useActions();
864
+ const stateStore = useStateStore();
865
+ const getSnapshot = () => stateStore.getSnapshot();
866
+ const functions = useFunctions();
867
+ const directives = useDirectives();
868
+ const fullCtx = (0, import_solid_js6.createMemo)(() => {
869
+ const repeatItem = repeatScope?.item;
870
+ const repeatIndex = repeatScope?.index;
871
+ const repeatBasePath = repeatScope?.basePath;
872
+ return {
873
+ get stateModel() {
874
+ return ctx.stateModel;
875
+ },
876
+ ...repeatItem !== void 0 ? {
877
+ repeatItem
878
+ } : {},
879
+ ...repeatIndex !== void 0 ? {
880
+ repeatIndex
881
+ } : {},
882
+ ...repeatBasePath !== void 0 ? {
883
+ repeatBasePath
884
+ } : {},
885
+ functions,
886
+ directives
887
+ };
888
+ });
889
+ const isVisible = (0, import_solid_js6.createMemo)(() => props.element.visible === void 0 ? true : (0, import_core6.evaluateVisibility)(props.element.visible, fullCtx()));
890
+ const emit = async (eventName) => {
891
+ const onBindings = props.element.on;
892
+ const binding = onBindings?.[eventName];
893
+ if (!binding) return;
894
+ const actionBindings = Array.isArray(binding) ? binding : [binding];
895
+ for (const b of actionBindings) {
896
+ if (!b.params) {
897
+ await execute(b);
898
+ continue;
899
+ }
900
+ const liveCtx = {
901
+ ...fullCtx(),
902
+ stateModel: getSnapshot()
903
+ };
904
+ const resolved = {};
905
+ for (const [key, val] of Object.entries(b.params)) {
906
+ resolved[key] = (0, import_core6.resolveActionParam)(val, liveCtx);
907
+ }
908
+ await execute({
909
+ ...b,
910
+ params: resolved
911
+ });
912
+ }
913
+ };
914
+ const on = (eventName) => {
915
+ const onBindings = props.element.on;
916
+ const binding = onBindings?.[eventName];
917
+ if (!binding) {
918
+ return {
919
+ emit: () => {
920
+ },
921
+ shouldPreventDefault: false,
922
+ bound: false
923
+ };
924
+ }
925
+ const actionBindings = Array.isArray(binding) ? binding : [binding];
926
+ const shouldPreventDefault = actionBindings.some((b) => b.preventDefault);
927
+ return {
928
+ emit: () => emit(eventName),
929
+ shouldPreventDefault,
930
+ bound: true
931
+ };
932
+ };
933
+ (0, import_solid_js6.createEffect)(() => {
934
+ const watchConfig = props.element.watch;
935
+ if (!watchConfig) return;
936
+ const paths = Object.keys(watchConfig);
937
+ if (paths.length === 0) return;
938
+ const unsubscribe = stateStore.subscribeChanges((changes) => {
939
+ const changedPaths = new Set(changes.map((change) => change.path));
940
+ void (async () => {
941
+ for (const path of paths) {
942
+ if (!changedPaths.has(path)) continue;
943
+ const binding = watchConfig[path];
944
+ if (!binding) continue;
945
+ const bindings = Array.isArray(binding) ? binding : [binding];
946
+ for (const b of bindings) {
947
+ if (!b.params) {
948
+ await execute(b);
949
+ continue;
950
+ }
951
+ const liveCtx = {
952
+ ...fullCtx(),
953
+ stateModel: getSnapshot()
954
+ };
955
+ const resolved = {};
956
+ for (const [key, val] of Object.entries(b.params)) {
957
+ resolved[key] = (0, import_core6.resolveActionParam)(val, liveCtx);
958
+ }
959
+ await execute({
960
+ ...b,
961
+ params: resolved
962
+ });
963
+ }
964
+ }
965
+ })().catch(console.error);
966
+ });
967
+ (0, import_solid_js6.onCleanup)(() => {
968
+ unsubscribe();
969
+ });
970
+ });
971
+ const elementBindings = (0, import_solid_js6.createMemo)(() => {
972
+ const rawProps = props.element.props;
973
+ return (0, import_core6.resolveBindings)(rawProps, fullCtx());
974
+ });
975
+ const resolvedElement = (0, import_solid_js6.createMemo)(() => {
976
+ const rawProps = props.element.props;
977
+ const resolvedProps = (0, import_core6.resolveElementProps)(rawProps, fullCtx());
978
+ return resolvedProps !== props.element.props ? {
979
+ ...props.element,
980
+ props: resolvedProps
981
+ } : props.element;
982
+ });
983
+ return (0, import_web18.createComponent)(import_solid_js6.Show, {
984
+ get when() {
985
+ return isVisible();
986
+ },
987
+ get children() {
988
+ return (0, import_web18.createComponent)(import_solid_js6.ErrorBoundary, {
989
+ fallback: (err) => {
990
+ reportRenderError(props.registry, props.element.type, err);
991
+ return null;
992
+ },
993
+ get children() {
994
+ return (0, import_web18.createComponent)(ElementRendererContent, {
995
+ get resolvedElement() {
996
+ return resolvedElement();
997
+ },
998
+ get elementKey() {
999
+ return props.elementKey;
1000
+ },
1001
+ get spec() {
1002
+ return props.spec;
1003
+ },
1004
+ get registry() {
1005
+ return props.registry;
1006
+ },
1007
+ get loading() {
1008
+ return props.loading;
1009
+ },
1010
+ get fallback() {
1011
+ return props.fallback;
1012
+ },
1013
+ emit,
1014
+ on,
1015
+ get bindings() {
1016
+ return elementBindings();
1017
+ }
1018
+ });
1019
+ }
1020
+ });
1021
+ }
1022
+ });
1023
+ }
1024
+ function ElementRendererContent(props) {
1025
+ const devtoolsActive = useDevtoolsActive();
1026
+ const Comp = () => props.registry[props.resolvedElement.type] ?? props.fallback;
1027
+ return (0, import_web18.createComponent)(import_solid_js6.Show, {
1028
+ get when() {
1029
+ return Comp();
1030
+ },
1031
+ get fallback() {
1032
+ console.warn(`No renderer for component type: ${props.resolvedElement.type}`);
1033
+ return null;
1034
+ },
1035
+ children: (ComponentFn) => {
1036
+ const Component = ComponentFn();
1037
+ const children = () => props.resolvedElement.repeat ? (0, import_web18.createComponent)(RepeatChildren, {
1038
+ get element() {
1039
+ return props.resolvedElement;
1040
+ },
1041
+ get spec() {
1042
+ return props.spec;
1043
+ },
1044
+ get registry() {
1045
+ return props.registry;
1046
+ },
1047
+ get loading() {
1048
+ return props.loading;
1049
+ },
1050
+ get fallback() {
1051
+ return props.fallback;
1052
+ }
1053
+ }) : (0, import_web18.createComponent)(import_solid_js6.For, {
1054
+ get each() {
1055
+ return props.resolvedElement.children ?? [];
1056
+ },
1057
+ children: (childKey) => {
1058
+ const childElement = () => props.spec.elements[childKey];
1059
+ return (0, import_web18.createComponent)(import_solid_js6.Show, {
1060
+ get when() {
1061
+ return childElement();
1062
+ },
1063
+ get fallback() {
1064
+ if (!props.loading) {
1065
+ console.warn(`[json-render] Missing element "${childKey}" referenced as child of "${props.resolvedElement.type}". This element will not render.`);
1066
+ }
1067
+ return null;
1068
+ },
1069
+ children: (el) => (0, import_web18.createComponent)(ElementRenderer, {
1070
+ get element() {
1071
+ return el();
1072
+ },
1073
+ elementKey: childKey,
1074
+ get spec() {
1075
+ return props.spec;
1076
+ },
1077
+ get registry() {
1078
+ return props.registry;
1079
+ },
1080
+ get loading() {
1081
+ return props.loading;
1082
+ },
1083
+ get fallback() {
1084
+ return props.fallback;
1085
+ }
1086
+ })
1087
+ });
1088
+ }
1089
+ });
1090
+ const rendered = (0, import_web18.createComponent)(Component, {
1091
+ get element() {
1092
+ return props.resolvedElement;
1093
+ },
1094
+ get emit() {
1095
+ return props.emit;
1096
+ },
1097
+ get on() {
1098
+ return props.on;
1099
+ },
1100
+ get bindings() {
1101
+ return props.bindings;
1102
+ },
1103
+ get loading() {
1104
+ return props.loading;
1105
+ },
1106
+ get children() {
1107
+ return children();
1108
+ }
1109
+ });
1110
+ return (0, import_web18.createComponent)(import_solid_js6.Show, {
1111
+ get when() {
1112
+ return (0, import_web17.memo)(() => !!devtoolsActive())() && props.elementKey;
1113
+ },
1114
+ fallback: rendered,
1115
+ get children() {
1116
+ var _el$ = _tmpl$2();
1117
+ (0, import_web16.insert)(_el$, rendered);
1118
+ (0, import_web15.effect)(() => (0, import_web14.setAttribute)(_el$, "data-jr-key", props.elementKey));
1119
+ return _el$;
1120
+ }
1121
+ });
1122
+ }
1123
+ });
1124
+ }
1125
+ function RepeatChildren(props) {
1126
+ const stateStore = useStateStore();
1127
+ const repeat = () => props.element.repeat;
1128
+ const statePath = () => repeat().statePath;
1129
+ const items = () => (0, import_core6.getByPath)(stateStore.state, statePath()) ?? [];
1130
+ return (0, import_web18.createComponent)(import_solid_js6.For, {
1131
+ get each() {
1132
+ return items();
1133
+ },
1134
+ children: (itemValue, index) => {
1135
+ const key = () => {
1136
+ const r = repeat();
1137
+ return r.key && typeof itemValue === "object" && itemValue !== null ? String(itemValue[r.key] ?? index()) : String(index());
1138
+ };
1139
+ return (0, import_web18.createComponent)(RepeatScopeProvider, {
1140
+ item: itemValue,
1141
+ get index() {
1142
+ return index();
1143
+ },
1144
+ get basePath() {
1145
+ return `${statePath()}/${index()}`;
1146
+ },
1147
+ get children() {
1148
+ return (0, import_web18.createComponent)(import_solid_js6.For, {
1149
+ get each() {
1150
+ return props.element.children ?? [];
1151
+ },
1152
+ children: (childKey) => {
1153
+ const childElement = () => props.spec.elements[childKey];
1154
+ return (0, import_web18.createComponent)(import_solid_js6.Show, {
1155
+ get when() {
1156
+ return childElement();
1157
+ },
1158
+ get fallback() {
1159
+ if (!props.loading) {
1160
+ console.warn(`[json-render] Missing element "${childKey}" referenced as child of "${props.element.type}" (repeat). This element will not render.`);
1161
+ }
1162
+ return null;
1163
+ },
1164
+ children: (el) => (0, import_web18.createComponent)(ElementRenderer, {
1165
+ get element() {
1166
+ return el();
1167
+ },
1168
+ get spec() {
1169
+ return props.spec;
1170
+ },
1171
+ get registry() {
1172
+ return props.registry;
1173
+ },
1174
+ get loading() {
1175
+ return props.loading;
1176
+ },
1177
+ get fallback() {
1178
+ return props.fallback;
1179
+ }
1180
+ })
1181
+ });
1182
+ }
1183
+ });
1184
+ }
1185
+ });
1186
+ }
1187
+ });
1188
+ }
1189
+ function Renderer(props) {
1190
+ const rootElement = (0, import_solid_js6.createMemo)(() => {
1191
+ const spec = props.spec;
1192
+ if (!spec || !spec.root) return void 0;
1193
+ return spec.elements[spec.root];
1194
+ });
1195
+ const rendererRegistry = (0, import_solid_js6.createMemo)(() => {
1196
+ if (!props.onRenderError) return props.registry;
1197
+ const next = {
1198
+ ...props.registry
1199
+ };
1200
+ Object.defineProperty(next, "onRenderError", {
1201
+ value: props.onRenderError,
1202
+ enumerable: false,
1203
+ configurable: true
1204
+ });
1205
+ return next;
1206
+ });
1207
+ return (0, import_web18.createComponent)(import_solid_js6.Show, {
1208
+ get when() {
1209
+ return rootElement();
1210
+ },
1211
+ children: (el) => (0, import_web18.createComponent)(ElementRenderer, {
1212
+ get element() {
1213
+ return el();
1214
+ },
1215
+ get elementKey() {
1216
+ return props.spec.root;
1217
+ },
1218
+ get spec() {
1219
+ return props.spec;
1220
+ },
1221
+ get registry() {
1222
+ return rendererRegistry();
1223
+ },
1224
+ get loading() {
1225
+ return props.loading;
1226
+ },
1227
+ get fallback() {
1228
+ return props.fallback;
1229
+ }
1230
+ })
1231
+ });
1232
+ }
1233
+ function JSONUIProvider(props) {
1234
+ const directiveRegistry = (0, import_solid_js6.createMemo)(() => props.directives ? (0, import_core6.createDirectiveRegistry)(props.directives) : void 0);
1235
+ return (0, import_web18.createComponent)(StateProvider, {
1236
+ get store() {
1237
+ return props.store;
1238
+ },
1239
+ get initialState() {
1240
+ return props.initialState;
1241
+ },
1242
+ get onStateChange() {
1243
+ return props.onStateChange;
1244
+ },
1245
+ get children() {
1246
+ return (0, import_web18.createComponent)(VisibilityProvider, {
1247
+ get children() {
1248
+ return (0, import_web18.createComponent)(ValidationProvider, {
1249
+ get customFunctions() {
1250
+ return props.validationFunctions;
1251
+ },
1252
+ get children() {
1253
+ return (0, import_web18.createComponent)(ActionProvider, {
1254
+ get handlers() {
1255
+ return props.handlers;
1256
+ },
1257
+ get navigate() {
1258
+ return props.navigate;
1259
+ },
1260
+ get children() {
1261
+ return (0, import_web18.createComponent)(FunctionsContext.Provider, {
1262
+ get value() {
1263
+ return props.functions ?? EMPTY_FUNCTIONS;
1264
+ },
1265
+ get children() {
1266
+ return (0, import_web18.createComponent)(DirectivesContext.Provider, {
1267
+ get value() {
1268
+ return directiveRegistry();
1269
+ },
1270
+ get children() {
1271
+ return [(0, import_web17.memo)(() => props.children), (0, import_web18.createComponent)(ConfirmationDialogManager, {})];
1272
+ }
1273
+ });
1274
+ }
1275
+ });
1276
+ }
1277
+ });
1278
+ }
1279
+ });
1280
+ }
1281
+ });
1282
+ }
1283
+ });
1284
+ }
1285
+ function ConfirmationDialogManager() {
1286
+ const {
1287
+ pendingConfirmation,
1288
+ confirm,
1289
+ cancel
1290
+ } = useActions();
1291
+ return (0, import_web18.createComponent)(import_solid_js6.Show, {
1292
+ get when() {
1293
+ return pendingConfirmation?.action.confirm;
1294
+ },
1295
+ children: (confirmConfig) => (0, import_web18.createComponent)(ConfirmDialog, {
1296
+ get confirm() {
1297
+ return confirmConfig();
1298
+ },
1299
+ onConfirm: confirm,
1300
+ onCancel: cancel
1301
+ })
1302
+ });
1303
+ }
1304
+ function defineRegistry(_catalog, options) {
1305
+ const registry = {};
1306
+ if (options.components) {
1307
+ for (const [name, componentFn] of Object.entries(options.components)) {
1308
+ registry[name] = (renderProps) => {
1309
+ return componentFn({
1310
+ get props() {
1311
+ return renderProps.element.props;
1312
+ },
1313
+ get children() {
1314
+ return renderProps.children;
1315
+ },
1316
+ emit: renderProps.emit,
1317
+ on: renderProps.on,
1318
+ get bindings() {
1319
+ return renderProps.bindings;
1320
+ },
1321
+ get loading() {
1322
+ return renderProps.loading;
1323
+ }
1324
+ });
1325
+ };
1326
+ }
1327
+ }
1328
+ const actionMap = options.actions ? Object.entries(options.actions) : [];
1329
+ const handlers = (getSetState, getState) => {
1330
+ const result = {};
1331
+ for (const [name, actionFn] of actionMap) {
1332
+ result[name] = async (params) => {
1333
+ const setState = getSetState();
1334
+ const state = getState();
1335
+ if (setState) {
1336
+ await actionFn(params, setState, state);
1337
+ }
1338
+ };
1339
+ }
1340
+ return result;
1341
+ };
1342
+ const executeAction2 = async (actionName, params, setState, state = {}) => {
1343
+ const entry = actionMap.find(([name]) => name === actionName);
1344
+ if (entry) {
1345
+ await entry[1](params, setState, state);
1346
+ } else {
1347
+ console.warn(`Unknown action: ${actionName}`);
1348
+ }
1349
+ };
1350
+ if (options.onRenderError) {
1351
+ Object.defineProperty(registry, "onRenderError", {
1352
+ value: options.onRenderError,
1353
+ enumerable: false,
1354
+ configurable: true
1355
+ });
1356
+ }
1357
+ return {
1358
+ registry,
1359
+ handlers,
1360
+ executeAction: executeAction2
1361
+ };
1362
+ }
1363
+ function createRenderer(catalog, components) {
1364
+ const registry = components;
1365
+ return function CatalogRenderer(props) {
1366
+ const directiveRegistry = (0, import_solid_js6.createMemo)(() => props.directives ? (0, import_core6.createDirectiveRegistry)(props.directives) : void 0);
1367
+ const rendererRegistry = (0, import_solid_js6.createMemo)(() => {
1368
+ if (!props.onRenderError) return registry;
1369
+ const next = {
1370
+ ...registry
1371
+ };
1372
+ Object.defineProperty(next, "onRenderError", {
1373
+ value: props.onRenderError,
1374
+ enumerable: false,
1375
+ configurable: true
1376
+ });
1377
+ return next;
1378
+ });
1379
+ const actionHandlers = () => props.onAction ? new Proxy({}, {
1380
+ get: (_target, prop) => {
1381
+ return (params) => props.onAction(prop, params);
1382
+ },
1383
+ has: () => true
1384
+ }) : void 0;
1385
+ return (0, import_web18.createComponent)(StateProvider, {
1386
+ get store() {
1387
+ return props.store;
1388
+ },
1389
+ get initialState() {
1390
+ return props.state;
1391
+ },
1392
+ get onStateChange() {
1393
+ return props.onStateChange;
1394
+ },
1395
+ get children() {
1396
+ return (0, import_web18.createComponent)(VisibilityProvider, {
1397
+ get children() {
1398
+ return (0, import_web18.createComponent)(ValidationProvider, {
1399
+ get children() {
1400
+ return (0, import_web18.createComponent)(ActionProvider, {
1401
+ get handlers() {
1402
+ return actionHandlers();
1403
+ },
1404
+ get children() {
1405
+ return (0, import_web18.createComponent)(FunctionsContext.Provider, {
1406
+ get value() {
1407
+ return props.functions ?? EMPTY_FUNCTIONS;
1408
+ },
1409
+ get children() {
1410
+ return (0, import_web18.createComponent)(DirectivesContext.Provider, {
1411
+ get value() {
1412
+ return directiveRegistry();
1413
+ },
1414
+ get children() {
1415
+ return [(0, import_web18.createComponent)(Renderer, {
1416
+ get spec() {
1417
+ return props.spec;
1418
+ },
1419
+ get registry() {
1420
+ return rendererRegistry();
1421
+ },
1422
+ get loading() {
1423
+ return props.loading;
1424
+ },
1425
+ get fallback() {
1426
+ return props.fallback;
1427
+ }
1428
+ }), (0, import_web18.createComponent)(ConfirmationDialogManager, {})];
1429
+ }
1430
+ });
1431
+ }
1432
+ });
1433
+ }
1434
+ });
1435
+ }
1436
+ });
1437
+ }
1438
+ });
1439
+ }
1440
+ });
1441
+ };
1442
+ }
1443
+
1444
+ // src/hooks.ts
1445
+ var import_solid_js7 = require("solid-js");
1446
+ var import_core7 = require("@xmachines/json-render-core");
1447
+ function parseLine(line) {
1448
+ try {
1449
+ const trimmed = line.trim();
1450
+ if (!trimmed || trimmed.startsWith("//")) {
1451
+ return null;
1452
+ }
1453
+ const parsed = JSON.parse(trimmed);
1454
+ if (parsed.__meta === "usage") {
1455
+ return {
1456
+ type: "usage",
1457
+ usage: {
1458
+ promptTokens: parsed.promptTokens ?? 0,
1459
+ completionTokens: parsed.completionTokens ?? 0,
1460
+ totalTokens: parsed.totalTokens ?? 0
1461
+ }
1462
+ };
1463
+ }
1464
+ return { type: "patch", patch: parsed };
1465
+ } catch {
1466
+ return null;
1467
+ }
1468
+ }
1469
+ function setSpecValue(newSpec, path, value) {
1470
+ if (path === "/root") {
1471
+ newSpec.root = value;
1472
+ return;
1473
+ }
1474
+ if (path === "/state") {
1475
+ newSpec.state = value;
1476
+ return;
1477
+ }
1478
+ if (path.startsWith("/state/")) {
1479
+ if (!newSpec.state) newSpec.state = {};
1480
+ const statePath = path.slice("/state".length);
1481
+ (0, import_core7.setByPath)(newSpec.state, statePath, value);
1482
+ return;
1483
+ }
1484
+ if (path.startsWith("/elements/")) {
1485
+ const pathParts = path.slice("/elements/".length).split("/");
1486
+ const elementKey = pathParts[0];
1487
+ if (!elementKey) return;
1488
+ if (pathParts.length === 1) {
1489
+ newSpec.elements[elementKey] = value;
1490
+ } else {
1491
+ const element = newSpec.elements[elementKey];
1492
+ if (element) {
1493
+ const propPath = "/" + pathParts.slice(1).join("/");
1494
+ const newElement = { ...element };
1495
+ (0, import_core7.setByPath)(
1496
+ newElement,
1497
+ propPath,
1498
+ value
1499
+ );
1500
+ newSpec.elements[elementKey] = newElement;
1501
+ }
1502
+ }
1503
+ }
1504
+ }
1505
+ function removeSpecValue(newSpec, path) {
1506
+ if (path === "/state") {
1507
+ delete newSpec.state;
1508
+ return;
1509
+ }
1510
+ if (path.startsWith("/state/") && newSpec.state) {
1511
+ const statePath = path.slice("/state".length);
1512
+ (0, import_core7.removeByPath)(newSpec.state, statePath);
1513
+ return;
1514
+ }
1515
+ if (path.startsWith("/elements/")) {
1516
+ const pathParts = path.slice("/elements/".length).split("/");
1517
+ const elementKey = pathParts[0];
1518
+ if (!elementKey) return;
1519
+ if (pathParts.length === 1) {
1520
+ const { [elementKey]: _, ...rest } = newSpec.elements;
1521
+ newSpec.elements = rest;
1522
+ } else {
1523
+ const element = newSpec.elements[elementKey];
1524
+ if (element) {
1525
+ const propPath = "/" + pathParts.slice(1).join("/");
1526
+ const newElement = { ...element };
1527
+ (0, import_core7.removeByPath)(
1528
+ newElement,
1529
+ propPath
1530
+ );
1531
+ newSpec.elements[elementKey] = newElement;
1532
+ }
1533
+ }
1534
+ }
1535
+ }
1536
+ function getSpecValue(spec, path) {
1537
+ if (path === "/root") return spec.root;
1538
+ if (path === "/state") return spec.state;
1539
+ if (path.startsWith("/state/") && spec.state) {
1540
+ const statePath = path.slice("/state".length);
1541
+ return (0, import_core7.getByPath)(spec.state, statePath);
1542
+ }
1543
+ return (0, import_core7.getByPath)(spec, path);
1544
+ }
1545
+ function applyPatch(spec, patch) {
1546
+ const newSpec = {
1547
+ ...spec,
1548
+ elements: { ...spec.elements },
1549
+ ...spec.state ? { state: { ...spec.state } } : {}
1550
+ };
1551
+ switch (patch.op) {
1552
+ case "add":
1553
+ case "replace": {
1554
+ setSpecValue(newSpec, patch.path, patch.value);
1555
+ break;
1556
+ }
1557
+ case "remove": {
1558
+ removeSpecValue(newSpec, patch.path);
1559
+ break;
1560
+ }
1561
+ case "move": {
1562
+ if (!patch.from) break;
1563
+ const moveValue = getSpecValue(newSpec, patch.from);
1564
+ removeSpecValue(newSpec, patch.from);
1565
+ setSpecValue(newSpec, patch.path, moveValue);
1566
+ break;
1567
+ }
1568
+ case "copy": {
1569
+ if (!patch.from) break;
1570
+ const copyValue = getSpecValue(newSpec, patch.from);
1571
+ setSpecValue(newSpec, patch.path, copyValue);
1572
+ break;
1573
+ }
1574
+ case "test": {
1575
+ break;
1576
+ }
1577
+ }
1578
+ return newSpec;
1579
+ }
1580
+ function useUIStream(options) {
1581
+ const [spec, setSpec] = (0, import_solid_js7.createSignal)(null);
1582
+ const [isStreaming, setIsStreaming] = (0, import_solid_js7.createSignal)(false);
1583
+ const [error, setError] = (0, import_solid_js7.createSignal)(null);
1584
+ const [usage, setUsage] = (0, import_solid_js7.createSignal)(null);
1585
+ const [rawLines, setRawLines] = (0, import_solid_js7.createSignal)([]);
1586
+ let abortController = null;
1587
+ const clear = () => {
1588
+ setSpec(null);
1589
+ setError(null);
1590
+ };
1591
+ const send = async (prompt, context) => {
1592
+ abortController?.abort();
1593
+ abortController = new AbortController();
1594
+ setIsStreaming(true);
1595
+ setError(null);
1596
+ setUsage(null);
1597
+ setRawLines([]);
1598
+ const previousSpec = context?.previousSpec;
1599
+ let currentSpec = previousSpec && previousSpec.root ? { ...previousSpec, elements: { ...previousSpec.elements } } : { root: "", elements: {} };
1600
+ setSpec(currentSpec);
1601
+ try {
1602
+ const response = await fetch(options.api, {
1603
+ method: "POST",
1604
+ headers: { "Content-Type": "application/json" },
1605
+ body: JSON.stringify({
1606
+ prompt,
1607
+ context,
1608
+ currentSpec
1609
+ }),
1610
+ signal: abortController.signal
1611
+ });
1612
+ if (!response.ok) {
1613
+ let errorMessage = `HTTP error: ${response.status}`;
1614
+ try {
1615
+ const errorData = await response.json();
1616
+ if (errorData.message) {
1617
+ errorMessage = errorData.message;
1618
+ } else if (errorData.error) {
1619
+ errorMessage = errorData.error;
1620
+ }
1621
+ } catch {
1622
+ }
1623
+ throw new Error(errorMessage);
1624
+ }
1625
+ const reader = response.body?.getReader();
1626
+ if (!reader) {
1627
+ throw new Error("No response body");
1628
+ }
1629
+ const decoder = new TextDecoder();
1630
+ let buffer = "";
1631
+ while (true) {
1632
+ const { done, value } = await reader.read();
1633
+ if (done) break;
1634
+ buffer += decoder.decode(value, { stream: true });
1635
+ const lines = buffer.split("\n");
1636
+ buffer = lines.pop() ?? "";
1637
+ for (const line of lines) {
1638
+ const trimmed = line.trim();
1639
+ if (!trimmed) continue;
1640
+ const result = parseLine(trimmed);
1641
+ if (!result) continue;
1642
+ if (result.type === "usage") {
1643
+ setUsage(result.usage);
1644
+ } else {
1645
+ setRawLines((prev) => [...prev, trimmed]);
1646
+ currentSpec = applyPatch(currentSpec, result.patch);
1647
+ setSpec({ ...currentSpec });
1648
+ }
1649
+ }
1650
+ }
1651
+ if (buffer.trim()) {
1652
+ const trimmed = buffer.trim();
1653
+ const result = parseLine(trimmed);
1654
+ if (result) {
1655
+ if (result.type === "usage") {
1656
+ setUsage(result.usage);
1657
+ } else {
1658
+ setRawLines((prev) => [...prev, trimmed]);
1659
+ currentSpec = applyPatch(currentSpec, result.patch);
1660
+ setSpec({ ...currentSpec });
1661
+ }
1662
+ }
1663
+ }
1664
+ options.onComplete?.(currentSpec);
1665
+ } catch (err) {
1666
+ if (err.name === "AbortError") {
1667
+ return;
1668
+ }
1669
+ const resolvedError = err instanceof Error ? err : new Error(String(err));
1670
+ setError(resolvedError);
1671
+ options.onError?.(resolvedError);
1672
+ } finally {
1673
+ setIsStreaming(false);
1674
+ }
1675
+ };
1676
+ (0, import_solid_js7.onCleanup)(() => {
1677
+ abortController?.abort();
1678
+ });
1679
+ return {
1680
+ get spec() {
1681
+ return spec();
1682
+ },
1683
+ get isStreaming() {
1684
+ return isStreaming();
1685
+ },
1686
+ get error() {
1687
+ return error();
1688
+ },
1689
+ get usage() {
1690
+ return usage();
1691
+ },
1692
+ get rawLines() {
1693
+ return rawLines();
1694
+ },
1695
+ send,
1696
+ clear
1697
+ };
1698
+ }
1699
+ function flatToTree(elements) {
1700
+ const elementMap = {};
1701
+ let root = "";
1702
+ for (const element of elements) {
1703
+ elementMap[element.key] = {
1704
+ type: element.type,
1705
+ props: element.props,
1706
+ children: [],
1707
+ visible: element.visible
1708
+ };
1709
+ }
1710
+ for (const element of elements) {
1711
+ if (element.parentKey) {
1712
+ const parent = elementMap[element.parentKey];
1713
+ if (parent) {
1714
+ if (!parent.children) {
1715
+ parent.children = [];
1716
+ }
1717
+ parent.children.push(element.key);
1718
+ }
1719
+ } else {
1720
+ root = element.key;
1721
+ }
1722
+ }
1723
+ return { root, elements: elementMap };
1724
+ }
1725
+ function useBoundProp(propValue, bindingPath) {
1726
+ const { set } = useStateStore();
1727
+ const setValue = (value) => {
1728
+ if (bindingPath) set(bindingPath, value);
1729
+ };
1730
+ return [propValue, setValue];
1731
+ }
1732
+ function isSpecDataPart(data) {
1733
+ if (typeof data !== "object" || data === null) return false;
1734
+ const obj = data;
1735
+ switch (obj.type) {
1736
+ case "patch":
1737
+ return typeof obj.patch === "object" && obj.patch !== null;
1738
+ case "flat":
1739
+ case "nested":
1740
+ return typeof obj.spec === "object" && obj.spec !== null;
1741
+ default:
1742
+ return false;
1743
+ }
1744
+ }
1745
+ function buildSpecFromParts(parts) {
1746
+ const spec = { root: "", elements: {} };
1747
+ let hasSpec = false;
1748
+ for (const part of parts) {
1749
+ if (part.type === import_core7.SPEC_DATA_PART_TYPE) {
1750
+ if (!isSpecDataPart(part.data)) continue;
1751
+ const payload = part.data;
1752
+ if (payload.type === "patch") {
1753
+ hasSpec = true;
1754
+ (0, import_core7.applySpecPatch)(spec, payload.patch);
1755
+ } else if (payload.type === "flat") {
1756
+ hasSpec = true;
1757
+ Object.assign(spec, payload.spec);
1758
+ } else if (payload.type === "nested") {
1759
+ hasSpec = true;
1760
+ const flat = (0, import_core7.nestedToFlat)(payload.spec);
1761
+ Object.assign(spec, flat);
1762
+ }
1763
+ }
1764
+ }
1765
+ return hasSpec ? spec : null;
1766
+ }
1767
+ function getTextFromParts(parts) {
1768
+ return parts.filter(
1769
+ (p) => p.type === "text" && typeof p.text === "string"
1770
+ ).map((p) => p.text.trim()).filter(Boolean).join("\n\n");
1771
+ }
1772
+ function useJsonRenderMessage(getParts) {
1773
+ const result = (0, import_solid_js7.createMemo)(() => {
1774
+ const parts = getParts();
1775
+ return {
1776
+ spec: buildSpecFromParts(parts),
1777
+ text: getTextFromParts(parts)
1778
+ };
1779
+ });
1780
+ return {
1781
+ get spec() {
1782
+ return result().spec;
1783
+ },
1784
+ get text() {
1785
+ return result().text;
1786
+ },
1787
+ get hasSpec() {
1788
+ const s = result().spec;
1789
+ return s !== null && Object.keys(s.elements || {}).length > 0;
1790
+ }
1791
+ };
1792
+ }
1793
+ var chatMessageIdCounter = 0;
1794
+ function generateChatId() {
1795
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1796
+ return crypto.randomUUID();
1797
+ }
1798
+ chatMessageIdCounter += 1;
1799
+ return `msg-${Date.now()}-${chatMessageIdCounter}`;
1800
+ }
1801
+ function useChatUI(options) {
1802
+ const [messages, setMessages] = (0, import_solid_js7.createSignal)([]);
1803
+ const [isStreaming, setIsStreaming] = (0, import_solid_js7.createSignal)(false);
1804
+ const [error, setError] = (0, import_solid_js7.createSignal)(null);
1805
+ let abortController = null;
1806
+ const clear = () => {
1807
+ setMessages([]);
1808
+ setError(null);
1809
+ };
1810
+ const send = async (text) => {
1811
+ if (!text.trim()) return;
1812
+ abortController?.abort();
1813
+ abortController = new AbortController();
1814
+ const userMessage = {
1815
+ id: generateChatId(),
1816
+ role: "user",
1817
+ text: text.trim(),
1818
+ spec: null
1819
+ };
1820
+ const assistantId = generateChatId();
1821
+ const assistantMessage = {
1822
+ id: assistantId,
1823
+ role: "assistant",
1824
+ text: "",
1825
+ spec: null
1826
+ };
1827
+ setMessages((prev) => [...prev, userMessage, assistantMessage]);
1828
+ setIsStreaming(true);
1829
+ setError(null);
1830
+ const historyForApi = [
1831
+ ...messages().filter((m) => m.id !== userMessage.id && m.id !== assistantId).map((m) => ({
1832
+ role: m.role,
1833
+ content: m.text
1834
+ })),
1835
+ { role: "user", content: text.trim() }
1836
+ ];
1837
+ let accumulatedText = "";
1838
+ let currentSpec = { root: "", elements: {} };
1839
+ let hasSpec = false;
1840
+ try {
1841
+ const response = await fetch(options.api, {
1842
+ method: "POST",
1843
+ headers: { "Content-Type": "application/json" },
1844
+ body: JSON.stringify({ messages: historyForApi }),
1845
+ signal: abortController.signal
1846
+ });
1847
+ if (!response.ok) {
1848
+ let errorMessage = `HTTP error: ${response.status}`;
1849
+ try {
1850
+ const errorData = await response.json();
1851
+ if (errorData.message) {
1852
+ errorMessage = errorData.message;
1853
+ } else if (errorData.error) {
1854
+ errorMessage = errorData.error;
1855
+ }
1856
+ } catch {
1857
+ }
1858
+ throw new Error(errorMessage);
1859
+ }
1860
+ const reader = response.body?.getReader();
1861
+ if (!reader) {
1862
+ throw new Error("No response body");
1863
+ }
1864
+ const decoder = new TextDecoder();
1865
+ const parser = (0, import_core7.createMixedStreamParser)({
1866
+ onPatch(patch) {
1867
+ hasSpec = true;
1868
+ (0, import_core7.applySpecPatch)(currentSpec, patch);
1869
+ setMessages(
1870
+ (prev) => prev.map(
1871
+ (m) => m.id === assistantId ? {
1872
+ ...m,
1873
+ spec: {
1874
+ root: currentSpec.root,
1875
+ elements: { ...currentSpec.elements },
1876
+ ...currentSpec.state ? { state: { ...currentSpec.state } } : {}
1877
+ }
1878
+ } : m
1879
+ )
1880
+ );
1881
+ },
1882
+ onText(line) {
1883
+ accumulatedText += (accumulatedText ? "\n" : "") + line;
1884
+ setMessages(
1885
+ (prev) => prev.map(
1886
+ (m) => m.id === assistantId ? { ...m, text: accumulatedText } : m
1887
+ )
1888
+ );
1889
+ }
1890
+ });
1891
+ while (true) {
1892
+ const { done, value } = await reader.read();
1893
+ if (done) break;
1894
+ parser.push(decoder.decode(value, { stream: true }));
1895
+ }
1896
+ parser.flush();
1897
+ const finalMessage = {
1898
+ id: assistantId,
1899
+ role: "assistant",
1900
+ text: accumulatedText,
1901
+ spec: hasSpec ? {
1902
+ root: currentSpec.root,
1903
+ elements: { ...currentSpec.elements },
1904
+ ...currentSpec.state ? { state: { ...currentSpec.state } } : {}
1905
+ } : null
1906
+ };
1907
+ options.onComplete?.(finalMessage);
1908
+ } catch (err) {
1909
+ if (err.name === "AbortError") {
1910
+ return;
1911
+ }
1912
+ const resolvedError = err instanceof Error ? err : new Error(String(err));
1913
+ setError(resolvedError);
1914
+ setMessages(
1915
+ (prev) => prev.filter((m) => m.id !== assistantId || m.text.length > 0)
1916
+ );
1917
+ options.onError?.(resolvedError);
1918
+ } finally {
1919
+ setIsStreaming(false);
1920
+ }
1921
+ };
1922
+ (0, import_solid_js7.onCleanup)(() => {
1923
+ abortController?.abort();
1924
+ });
1925
+ return {
1926
+ get messages() {
1927
+ return messages();
1928
+ },
1929
+ get isStreaming() {
1930
+ return isStreaming();
1931
+ },
1932
+ get error() {
1933
+ return error();
1934
+ },
1935
+ send,
1936
+ clear
1937
+ };
1938
+ }
1939
+ // Annotate the CommonJS export names for ESM import in node:
1940
+ 0 && (module.exports = {
1941
+ ActionProvider,
1942
+ ConfirmDialog,
1943
+ JSONUIProvider,
1944
+ Renderer,
1945
+ RepeatScopeProvider,
1946
+ StateProvider,
1947
+ ValidationProvider,
1948
+ VisibilityProvider,
1949
+ buildSpecFromParts,
1950
+ createRenderer,
1951
+ createStateStore,
1952
+ defineRegistry,
1953
+ elementTreeSchema,
1954
+ flatToTree,
1955
+ getTextFromParts,
1956
+ schema,
1957
+ useAction,
1958
+ useActions,
1959
+ useBoundProp,
1960
+ useChatUI,
1961
+ useFieldValidation,
1962
+ useIsVisible,
1963
+ useJsonRenderMessage,
1964
+ useOptionalValidation,
1965
+ useRepeatScope,
1966
+ useStateBinding,
1967
+ useStateStore,
1968
+ useStateValue,
1969
+ useUIStream,
1970
+ useValidation,
1971
+ useVisibility
1972
+ });
1973
+ //# sourceMappingURL=index.js.map