@json-render/core 0.8.0 → 0.9.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.
package/dist/index.mjs CHANGED
@@ -1,598 +1,67 @@
1
- // src/types.ts
1
+ import {
2
+ DynamicBooleanSchema,
3
+ DynamicNumberSchema,
4
+ DynamicStringSchema,
5
+ DynamicValueSchema,
6
+ SPEC_DATA_PART,
7
+ SPEC_DATA_PART_TYPE,
8
+ addByPath,
9
+ applySpecPatch,
10
+ applySpecStreamPatch,
11
+ compileSpecStream,
12
+ createJsonRenderTransform,
13
+ createMixedStreamParser,
14
+ createSpecStreamCompiler,
15
+ createStateStore,
16
+ findFormValue,
17
+ getByPath,
18
+ nestedToFlat,
19
+ parseSpecStreamLine,
20
+ pipeJsonRender,
21
+ removeByPath,
22
+ resolveDynamicValue,
23
+ setByPath
24
+ } from "./chunk-4ZGEEX7K.mjs";
25
+
26
+ // src/visibility.ts
2
27
  import { z } from "zod";
3
- var DynamicValueSchema = z.union([
4
- z.string(),
5
- z.number(),
6
- z.boolean(),
7
- z.null(),
8
- z.object({ $state: z.string() })
9
- ]);
10
- var DynamicStringSchema = z.union([
11
- z.string(),
12
- z.object({ $state: z.string() })
13
- ]);
14
- var DynamicNumberSchema = z.union([
28
+ var numericOrStateRef = z.union([
15
29
  z.number(),
16
30
  z.object({ $state: z.string() })
17
31
  ]);
18
- var DynamicBooleanSchema = z.union([
19
- z.boolean(),
20
- z.object({ $state: z.string() })
21
- ]);
22
- function resolveDynamicValue(value, stateModel) {
23
- if (value === null || value === void 0) {
24
- return void 0;
25
- }
26
- if (typeof value === "object" && "$state" in value) {
27
- return getByPath(stateModel, value.$state);
28
- }
29
- return value;
30
- }
31
- function unescapeJsonPointer(token) {
32
- return token.replace(/~1/g, "/").replace(/~0/g, "~");
33
- }
34
- function parseJsonPointer(path) {
35
- const raw = path.startsWith("/") ? path.slice(1).split("/") : path.split("/");
36
- return raw.map(unescapeJsonPointer);
37
- }
38
- function getByPath(obj, path) {
39
- if (!path || path === "/") {
40
- return obj;
41
- }
42
- const segments = parseJsonPointer(path);
43
- let current = obj;
44
- for (const segment of segments) {
45
- if (current === null || current === void 0) {
46
- return void 0;
47
- }
48
- if (Array.isArray(current)) {
49
- const index = parseInt(segment, 10);
50
- current = current[index];
51
- } else if (typeof current === "object") {
52
- current = current[segment];
53
- } else {
54
- return void 0;
55
- }
56
- }
57
- return current;
58
- }
59
- function isNumericIndex(str) {
60
- return /^\d+$/.test(str);
61
- }
62
- function setByPath(obj, path, value) {
63
- const segments = parseJsonPointer(path);
64
- if (segments.length === 0) return;
65
- let current = obj;
66
- for (let i = 0; i < segments.length - 1; i++) {
67
- const segment = segments[i];
68
- const nextSegment = segments[i + 1];
69
- const nextIsNumeric = nextSegment !== void 0 && (isNumericIndex(nextSegment) || nextSegment === "-");
70
- if (Array.isArray(current)) {
71
- const index = parseInt(segment, 10);
72
- if (current[index] === void 0 || typeof current[index] !== "object") {
73
- current[index] = nextIsNumeric ? [] : {};
74
- }
75
- current = current[index];
76
- } else {
77
- if (!(segment in current) || typeof current[segment] !== "object") {
78
- current[segment] = nextIsNumeric ? [] : {};
79
- }
80
- current = current[segment];
81
- }
82
- }
83
- const lastSegment = segments[segments.length - 1];
84
- if (Array.isArray(current)) {
85
- if (lastSegment === "-") {
86
- current.push(value);
87
- } else {
88
- const index = parseInt(lastSegment, 10);
89
- current[index] = value;
90
- }
91
- } else {
92
- current[lastSegment] = value;
93
- }
94
- }
95
- function addByPath(obj, path, value) {
96
- const segments = parseJsonPointer(path);
97
- if (segments.length === 0) return;
98
- let current = obj;
99
- for (let i = 0; i < segments.length - 1; i++) {
100
- const segment = segments[i];
101
- const nextSegment = segments[i + 1];
102
- const nextIsNumeric = nextSegment !== void 0 && (isNumericIndex(nextSegment) || nextSegment === "-");
103
- if (Array.isArray(current)) {
104
- const index = parseInt(segment, 10);
105
- if (current[index] === void 0 || typeof current[index] !== "object") {
106
- current[index] = nextIsNumeric ? [] : {};
107
- }
108
- current = current[index];
109
- } else {
110
- if (!(segment in current) || typeof current[segment] !== "object") {
111
- current[segment] = nextIsNumeric ? [] : {};
112
- }
113
- current = current[segment];
114
- }
115
- }
116
- const lastSegment = segments[segments.length - 1];
117
- if (Array.isArray(current)) {
118
- if (lastSegment === "-") {
119
- current.push(value);
120
- } else {
121
- const index = parseInt(lastSegment, 10);
122
- current.splice(index, 0, value);
123
- }
124
- } else {
125
- current[lastSegment] = value;
126
- }
127
- }
128
- function removeByPath(obj, path) {
129
- const segments = parseJsonPointer(path);
130
- if (segments.length === 0) return;
131
- let current = obj;
132
- for (let i = 0; i < segments.length - 1; i++) {
133
- const segment = segments[i];
134
- if (Array.isArray(current)) {
135
- const index = parseInt(segment, 10);
136
- if (current[index] === void 0 || typeof current[index] !== "object") {
137
- return;
138
- }
139
- current = current[index];
140
- } else {
141
- if (!(segment in current) || typeof current[segment] !== "object") {
142
- return;
143
- }
144
- current = current[segment];
145
- }
146
- }
147
- const lastSegment = segments[segments.length - 1];
148
- if (Array.isArray(current)) {
149
- const index = parseInt(lastSegment, 10);
150
- if (index >= 0 && index < current.length) {
151
- current.splice(index, 1);
152
- }
153
- } else {
154
- delete current[lastSegment];
155
- }
156
- }
157
- function deepEqual(a, b) {
158
- if (a === b) return true;
159
- if (a === null || b === null) return false;
160
- if (typeof a !== typeof b) return false;
161
- if (typeof a !== "object") return false;
162
- if (Array.isArray(a)) {
163
- if (!Array.isArray(b)) return false;
164
- if (a.length !== b.length) return false;
165
- return a.every((item, i) => deepEqual(item, b[i]));
166
- }
167
- const aObj = a;
168
- const bObj = b;
169
- const aKeys = Object.keys(aObj);
170
- const bKeys = Object.keys(bObj);
171
- if (aKeys.length !== bKeys.length) return false;
172
- return aKeys.every((key) => deepEqual(aObj[key], bObj[key]));
173
- }
174
- function findFormValue(fieldName, params, state) {
175
- if (params?.[fieldName] !== void 0) {
176
- const val = params[fieldName];
177
- if (typeof val !== "string" || !val.includes(".")) {
178
- return val;
179
- }
180
- }
181
- if (params) {
182
- for (const key of Object.keys(params)) {
183
- if (key.endsWith(`.${fieldName}`)) {
184
- const val = params[key];
185
- if (typeof val !== "string" || !val.includes(".")) {
186
- return val;
187
- }
188
- }
189
- }
190
- }
191
- if (state) {
192
- for (const key of Object.keys(state)) {
193
- if (key === fieldName || key.endsWith(`.${fieldName}`)) {
194
- return state[key];
195
- }
196
- }
197
- const val = getByPath(state, fieldName);
198
- if (val !== void 0) {
199
- return val;
200
- }
201
- }
202
- return void 0;
203
- }
204
- function parseSpecStreamLine(line) {
205
- const trimmed = line.trim();
206
- if (!trimmed || !trimmed.startsWith("{")) return null;
207
- try {
208
- const patch = JSON.parse(trimmed);
209
- if (patch.op && patch.path !== void 0) {
210
- return patch;
211
- }
212
- return null;
213
- } catch {
214
- return null;
215
- }
216
- }
217
- function applySpecStreamPatch(obj, patch) {
218
- switch (patch.op) {
219
- case "add":
220
- addByPath(obj, patch.path, patch.value);
221
- break;
222
- case "replace":
223
- setByPath(obj, patch.path, patch.value);
224
- break;
225
- case "remove":
226
- removeByPath(obj, patch.path);
227
- break;
228
- case "move": {
229
- if (!patch.from) break;
230
- const moveValue = getByPath(obj, patch.from);
231
- removeByPath(obj, patch.from);
232
- addByPath(obj, patch.path, moveValue);
233
- break;
234
- }
235
- case "copy": {
236
- if (!patch.from) break;
237
- const copyValue = getByPath(obj, patch.from);
238
- addByPath(obj, patch.path, copyValue);
239
- break;
240
- }
241
- case "test": {
242
- const actual = getByPath(obj, patch.path);
243
- if (!deepEqual(actual, patch.value)) {
244
- throw new Error(
245
- `Test operation failed: value at "${patch.path}" does not match`
246
- );
247
- }
248
- break;
249
- }
250
- }
251
- return obj;
252
- }
253
- function applySpecPatch(spec, patch) {
254
- applySpecStreamPatch(spec, patch);
255
- return spec;
256
- }
257
- function nestedToFlat(nested) {
258
- const elements = {};
259
- let counter = 0;
260
- function walk(node) {
261
- const key = `el-${counter++}`;
262
- const { type, props, children: rawChildren, ...rest } = node;
263
- const childKeys = [];
264
- if (Array.isArray(rawChildren)) {
265
- for (const child of rawChildren) {
266
- if (child && typeof child === "object" && "type" in child) {
267
- childKeys.push(walk(child));
268
- }
269
- }
270
- }
271
- const element = {
272
- type: type ?? "unknown",
273
- props: props ?? {},
274
- children: childKeys
275
- };
276
- for (const [k, v] of Object.entries(rest)) {
277
- if (k !== "state" && v !== void 0) {
278
- element[k] = v;
279
- }
280
- }
281
- elements[key] = element;
282
- return key;
283
- }
284
- const root = walk(nested);
285
- const spec = { root, elements };
286
- if (nested.state && typeof nested.state === "object" && !Array.isArray(nested.state)) {
287
- spec.state = nested.state;
288
- }
289
- return spec;
290
- }
291
- function compileSpecStream(stream, initial = {}) {
292
- const lines = stream.split("\n");
293
- const result = { ...initial };
294
- for (const line of lines) {
295
- const patch = parseSpecStreamLine(line);
296
- if (patch) {
297
- applySpecStreamPatch(result, patch);
298
- }
299
- }
300
- return result;
301
- }
302
- function createSpecStreamCompiler(initial = {}) {
303
- let result = { ...initial };
304
- let buffer = "";
305
- const appliedPatches = [];
306
- const processedLines = /* @__PURE__ */ new Set();
307
- return {
308
- push(chunk) {
309
- buffer += chunk;
310
- const newPatches = [];
311
- const lines = buffer.split("\n");
312
- buffer = lines.pop() || "";
313
- for (const line of lines) {
314
- const trimmed = line.trim();
315
- if (!trimmed || processedLines.has(trimmed)) continue;
316
- processedLines.add(trimmed);
317
- const patch = parseSpecStreamLine(trimmed);
318
- if (patch) {
319
- applySpecStreamPatch(result, patch);
320
- appliedPatches.push(patch);
321
- newPatches.push(patch);
322
- }
323
- }
324
- if (newPatches.length > 0) {
325
- result = { ...result };
326
- }
327
- return { result, newPatches };
328
- },
329
- getResult() {
330
- if (buffer.trim()) {
331
- const patch = parseSpecStreamLine(buffer);
332
- if (patch && !processedLines.has(buffer.trim())) {
333
- processedLines.add(buffer.trim());
334
- applySpecStreamPatch(result, patch);
335
- appliedPatches.push(patch);
336
- result = { ...result };
337
- }
338
- buffer = "";
339
- }
340
- return result;
341
- },
342
- getPatches() {
343
- return [...appliedPatches];
344
- },
345
- reset(newInitial = {}) {
346
- result = { ...newInitial };
347
- buffer = "";
348
- appliedPatches.length = 0;
349
- processedLines.clear();
350
- }
351
- };
352
- }
353
- function createMixedStreamParser(callbacks) {
354
- let buffer = "";
355
- let inSpecFence = false;
356
- function processLine(line) {
357
- const trimmed = line.trim();
358
- if (!inSpecFence && trimmed.startsWith("```spec")) {
359
- inSpecFence = true;
360
- return;
361
- }
362
- if (inSpecFence && trimmed === "```") {
363
- inSpecFence = false;
364
- return;
365
- }
366
- if (!trimmed) return;
367
- if (inSpecFence) {
368
- const patch2 = parseSpecStreamLine(trimmed);
369
- if (patch2) {
370
- callbacks.onPatch(patch2);
371
- }
372
- return;
373
- }
374
- const patch = parseSpecStreamLine(trimmed);
375
- if (patch) {
376
- callbacks.onPatch(patch);
377
- } else {
378
- callbacks.onText(line);
379
- }
380
- }
381
- return {
382
- push(chunk) {
383
- buffer += chunk;
384
- const lines = buffer.split("\n");
385
- buffer = lines.pop() || "";
386
- for (const line of lines) {
387
- processLine(line);
388
- }
389
- },
390
- flush() {
391
- if (buffer.trim()) {
392
- processLine(buffer);
393
- }
394
- buffer = "";
395
- }
396
- };
397
- }
398
- var SPEC_FENCE_OPEN = "```spec";
399
- var SPEC_FENCE_CLOSE = "```";
400
- function createJsonRenderTransform() {
401
- let lineBuffer = "";
402
- let currentTextId = "";
403
- let buffering = false;
404
- let inSpecFence = false;
405
- let inTextBlock = false;
406
- let textIdCounter = 0;
407
- function closeTextBlock(controller) {
408
- if (inTextBlock) {
409
- controller.enqueue({ type: "text-end", id: currentTextId });
410
- inTextBlock = false;
411
- }
412
- }
413
- function ensureTextBlock(controller) {
414
- if (!inTextBlock) {
415
- textIdCounter++;
416
- currentTextId = String(textIdCounter);
417
- controller.enqueue({ type: "text-start", id: currentTextId });
418
- inTextBlock = true;
419
- }
420
- }
421
- function emitTextDelta(delta, controller) {
422
- ensureTextBlock(controller);
423
- controller.enqueue({ type: "text-delta", id: currentTextId, delta });
424
- }
425
- function emitPatch(patch, controller) {
426
- closeTextBlock(controller);
427
- controller.enqueue({
428
- type: SPEC_DATA_PART_TYPE,
429
- data: { type: "patch", patch }
430
- });
431
- }
432
- function flushBuffer(controller) {
433
- if (!lineBuffer) return;
434
- const trimmed = lineBuffer.trim();
435
- if (inSpecFence) {
436
- if (trimmed) {
437
- const patch = parseSpecStreamLine(trimmed);
438
- if (patch) emitPatch(patch, controller);
439
- }
440
- lineBuffer = "";
441
- buffering = false;
442
- return;
443
- }
444
- if (trimmed) {
445
- const patch = parseSpecStreamLine(trimmed);
446
- if (patch) {
447
- emitPatch(patch, controller);
448
- } else {
449
- emitTextDelta(lineBuffer, controller);
450
- }
451
- } else {
452
- emitTextDelta(lineBuffer, controller);
453
- }
454
- lineBuffer = "";
455
- buffering = false;
456
- }
457
- function processCompleteLine(line, controller) {
458
- const trimmed = line.trim();
459
- if (!inSpecFence && trimmed.startsWith(SPEC_FENCE_OPEN)) {
460
- inSpecFence = true;
461
- return;
462
- }
463
- if (inSpecFence && trimmed === SPEC_FENCE_CLOSE) {
464
- inSpecFence = false;
465
- return;
466
- }
467
- if (inSpecFence) {
468
- if (trimmed) {
469
- const patch2 = parseSpecStreamLine(trimmed);
470
- if (patch2) emitPatch(patch2, controller);
471
- }
472
- return;
473
- }
474
- if (!trimmed) {
475
- emitTextDelta("\n", controller);
476
- return;
477
- }
478
- const patch = parseSpecStreamLine(trimmed);
479
- if (patch) {
480
- emitPatch(patch, controller);
481
- } else {
482
- emitTextDelta(line + "\n", controller);
483
- }
484
- }
485
- return new TransformStream({
486
- transform(chunk, controller) {
487
- switch (chunk.type) {
488
- case "text-start": {
489
- const id = chunk.id;
490
- const idNum = parseInt(id, 10);
491
- if (!isNaN(idNum) && idNum >= textIdCounter) {
492
- textIdCounter = idNum;
493
- }
494
- currentTextId = id;
495
- inTextBlock = true;
496
- controller.enqueue(chunk);
497
- break;
498
- }
499
- case "text-delta": {
500
- const delta = chunk;
501
- const text = delta.delta;
502
- for (let i = 0; i < text.length; i++) {
503
- const ch = text.charAt(i);
504
- if (ch === "\n") {
505
- if (buffering) {
506
- processCompleteLine(lineBuffer, controller);
507
- lineBuffer = "";
508
- buffering = false;
509
- } else {
510
- if (!inSpecFence) {
511
- emitTextDelta("\n", controller);
512
- }
513
- }
514
- } else if (lineBuffer.length === 0 && !buffering) {
515
- if (inSpecFence || ch === "{" || ch === "`") {
516
- buffering = true;
517
- lineBuffer += ch;
518
- } else {
519
- emitTextDelta(ch, controller);
520
- }
521
- } else if (buffering) {
522
- lineBuffer += ch;
523
- } else {
524
- emitTextDelta(ch, controller);
525
- }
526
- }
527
- break;
528
- }
529
- case "text-end": {
530
- flushBuffer(controller);
531
- if (inTextBlock) {
532
- controller.enqueue({ type: "text-end", id: currentTextId });
533
- inTextBlock = false;
534
- }
535
- break;
536
- }
537
- default: {
538
- controller.enqueue(chunk);
539
- break;
540
- }
541
- }
542
- },
543
- flush(controller) {
544
- flushBuffer(controller);
545
- closeTextBlock(controller);
546
- }
547
- });
548
- }
549
- var SPEC_DATA_PART = "spec";
550
- var SPEC_DATA_PART_TYPE = `data-${SPEC_DATA_PART}`;
551
- function pipeJsonRender(stream) {
552
- return stream.pipeThrough(
553
- createJsonRenderTransform()
554
- );
555
- }
556
-
557
- // src/visibility.ts
558
- import { z as z2 } from "zod";
559
- var numericOrStateRef = z2.union([
560
- z2.number(),
561
- z2.object({ $state: z2.string() })
562
- ]);
563
32
  var comparisonOps = {
564
- eq: z2.unknown().optional(),
565
- neq: z2.unknown().optional(),
33
+ eq: z.unknown().optional(),
34
+ neq: z.unknown().optional(),
566
35
  gt: numericOrStateRef.optional(),
567
36
  gte: numericOrStateRef.optional(),
568
37
  lt: numericOrStateRef.optional(),
569
38
  lte: numericOrStateRef.optional(),
570
- not: z2.literal(true).optional()
39
+ not: z.literal(true).optional()
571
40
  };
572
- var StateConditionSchema = z2.object({
573
- $state: z2.string(),
41
+ var StateConditionSchema = z.object({
42
+ $state: z.string(),
574
43
  ...comparisonOps
575
44
  });
576
- var ItemConditionSchema = z2.object({
577
- $item: z2.string(),
45
+ var ItemConditionSchema = z.object({
46
+ $item: z.string(),
578
47
  ...comparisonOps
579
48
  });
580
- var IndexConditionSchema = z2.object({
581
- $index: z2.literal(true),
49
+ var IndexConditionSchema = z.object({
50
+ $index: z.literal(true),
582
51
  ...comparisonOps
583
52
  });
584
- var SingleConditionSchema = z2.union([
53
+ var SingleConditionSchema = z.union([
585
54
  StateConditionSchema,
586
55
  ItemConditionSchema,
587
56
  IndexConditionSchema
588
57
  ]);
589
- var VisibilityConditionSchema = z2.lazy(
590
- () => z2.union([
591
- z2.boolean(),
58
+ var VisibilityConditionSchema = z.lazy(
59
+ () => z.union([
60
+ z.boolean(),
592
61
  SingleConditionSchema,
593
- z2.array(SingleConditionSchema),
594
- z2.object({ $and: z2.array(VisibilityConditionSchema) }),
595
- z2.object({ $or: z2.array(VisibilityConditionSchema) })
62
+ z.array(SingleConditionSchema),
63
+ z.object({ $and: z.array(VisibilityConditionSchema) }),
64
+ z.object({ $or: z.array(VisibilityConditionSchema) })
596
65
  ])
597
66
  );
598
67
  function resolveComparisonValue(value, ctx) {
@@ -817,30 +286,30 @@ function resolveActionParam(value, ctx) {
817
286
  }
818
287
 
819
288
  // src/actions.ts
820
- import { z as z3 } from "zod";
821
- var ActionConfirmSchema = z3.object({
822
- title: z3.string(),
823
- message: z3.string(),
824
- confirmLabel: z3.string().optional(),
825
- cancelLabel: z3.string().optional(),
826
- variant: z3.enum(["default", "danger"]).optional()
289
+ import { z as z2 } from "zod";
290
+ var ActionConfirmSchema = z2.object({
291
+ title: z2.string(),
292
+ message: z2.string(),
293
+ confirmLabel: z2.string().optional(),
294
+ cancelLabel: z2.string().optional(),
295
+ variant: z2.enum(["default", "danger"]).optional()
827
296
  });
828
- var ActionOnSuccessSchema = z3.union([
829
- z3.object({ navigate: z3.string() }),
830
- z3.object({ set: z3.record(z3.string(), z3.unknown()) }),
831
- z3.object({ action: z3.string() })
297
+ var ActionOnSuccessSchema = z2.union([
298
+ z2.object({ navigate: z2.string() }),
299
+ z2.object({ set: z2.record(z2.string(), z2.unknown()) }),
300
+ z2.object({ action: z2.string() })
832
301
  ]);
833
- var ActionOnErrorSchema = z3.union([
834
- z3.object({ set: z3.record(z3.string(), z3.unknown()) }),
835
- z3.object({ action: z3.string() })
302
+ var ActionOnErrorSchema = z2.union([
303
+ z2.object({ set: z2.record(z2.string(), z2.unknown()) }),
304
+ z2.object({ action: z2.string() })
836
305
  ]);
837
- var ActionBindingSchema = z3.object({
838
- action: z3.string(),
839
- params: z3.record(z3.string(), DynamicValueSchema).optional(),
306
+ var ActionBindingSchema = z2.object({
307
+ action: z2.string(),
308
+ params: z2.record(z2.string(), DynamicValueSchema).optional(),
840
309
  confirm: ActionConfirmSchema.optional(),
841
310
  onSuccess: ActionOnSuccessSchema.optional(),
842
311
  onError: ActionOnErrorSchema.optional(),
843
- preventDefault: z3.boolean().optional()
312
+ preventDefault: z2.boolean().optional()
844
313
  });
845
314
  var ActionSchema = ActionBindingSchema;
846
315
  function resolveAction(binding, stateModel) {
@@ -924,15 +393,15 @@ var actionBinding = {
924
393
  var action = actionBinding;
925
394
 
926
395
  // src/validation.ts
927
- import { z as z4 } from "zod";
928
- var ValidationCheckSchema = z4.object({
929
- type: z4.string(),
930
- args: z4.record(z4.string(), DynamicValueSchema).optional(),
931
- message: z4.string()
396
+ import { z as z3 } from "zod";
397
+ var ValidationCheckSchema = z3.object({
398
+ type: z3.string(),
399
+ args: z3.record(z3.string(), DynamicValueSchema).optional(),
400
+ message: z3.string()
932
401
  });
933
- var ValidationConfigSchema = z4.object({
934
- checks: z4.array(ValidationCheckSchema).optional(),
935
- validateOn: z4.enum(["change", "blur", "submit"]).optional(),
402
+ var ValidationConfigSchema = z3.object({
403
+ checks: z3.array(ValidationCheckSchema).optional(),
404
+ validateOn: z3.enum(["change", "blur", "submit"]).optional(),
936
405
  enabled: VisibilityConditionSchema.optional()
937
406
  });
938
407
  var builtInValidationFunctions = {
@@ -1275,7 +744,7 @@ function formatSpecIssues(issues) {
1275
744
  }
1276
745
 
1277
746
  // src/schema.ts
1278
- import { z as z5 } from "zod";
747
+ import { z as z4 } from "zod";
1279
748
  function createBuilder() {
1280
749
  return {
1281
750
  string: () => ({ kind: "string" }),
@@ -1349,16 +818,16 @@ function buildZodSchemaFromDefinition(definition, catalogData) {
1349
818
  function buildZodType(schemaType, catalogData) {
1350
819
  switch (schemaType.kind) {
1351
820
  case "string":
1352
- return z5.string();
821
+ return z4.string();
1353
822
  case "number":
1354
- return z5.number();
823
+ return z4.number();
1355
824
  case "boolean":
1356
- return z5.boolean();
825
+ return z4.boolean();
1357
826
  case "any":
1358
- return z5.any();
827
+ return z4.any();
1359
828
  case "array": {
1360
829
  const inner = buildZodType(schemaType.inner, catalogData);
1361
- return z5.array(inner);
830
+ return z4.array(inner);
1362
831
  }
1363
832
  case "object": {
1364
833
  const shape = schemaType.inner;
@@ -1370,36 +839,36 @@ function buildZodType(schemaType, catalogData) {
1370
839
  }
1371
840
  zodShape[key] = zodType;
1372
841
  }
1373
- return z5.object(zodShape);
842
+ return z4.object(zodShape);
1374
843
  }
1375
844
  case "record": {
1376
845
  const inner = buildZodType(schemaType.inner, catalogData);
1377
- return z5.record(z5.string(), inner);
846
+ return z4.record(z4.string(), inner);
1378
847
  }
1379
848
  case "ref": {
1380
849
  const path = schemaType.inner;
1381
850
  const keys = getKeysFromPath(path, catalogData);
1382
851
  if (keys.length === 0) {
1383
- return z5.string();
852
+ return z4.string();
1384
853
  }
1385
854
  if (keys.length === 1) {
1386
- return z5.literal(keys[0]);
855
+ return z4.literal(keys[0]);
1387
856
  }
1388
- return z5.enum(keys);
857
+ return z4.enum(keys);
1389
858
  }
1390
859
  case "propsOf": {
1391
860
  const path = schemaType.inner;
1392
861
  const propsSchemas = getPropsFromPath(path, catalogData);
1393
862
  if (propsSchemas.length === 0) {
1394
- return z5.record(z5.string(), z5.unknown());
863
+ return z4.record(z4.string(), z4.unknown());
1395
864
  }
1396
865
  if (propsSchemas.length === 1) {
1397
866
  return propsSchemas[0];
1398
867
  }
1399
- return z5.record(z5.string(), z5.unknown());
868
+ return z4.record(z4.string(), z4.unknown());
1400
869
  }
1401
870
  default:
1402
- return z5.unknown();
871
+ return z4.unknown();
1403
872
  }
1404
873
  }
1405
874
  function getKeysFromPath(path, catalogData) {
@@ -1940,7 +1409,7 @@ function formatZodType(schema) {
1940
1409
  }
1941
1410
  case "ZodArray":
1942
1411
  case "array": {
1943
- const inner = def.type ?? def.element;
1412
+ const inner = typeof def.element === "object" ? def.element : typeof def.type === "object" ? def.type : void 0;
1944
1413
  return inner ? `Array<${formatZodType(inner)}>` : "Array<unknown>";
1945
1414
  }
1946
1415
  case "ZodObject":
@@ -2113,6 +1582,7 @@ export {
2113
1582
  createJsonRenderTransform,
2114
1583
  createMixedStreamParser,
2115
1584
  createSpecStreamCompiler,
1585
+ createStateStore,
2116
1586
  defineCatalog,
2117
1587
  defineSchema,
2118
1588
  evaluateVisibility,