@safe-ugc-ui/types 0.3.1 → 0.5.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.js CHANGED
@@ -3,16 +3,13 @@ import { z } from "zod";
3
3
  var refSchema = z.object({
4
4
  $ref: z.string()
5
5
  });
6
- var exprSchema = z.object({
7
- $expr: z.string()
8
- });
9
6
  var assetPathSchema = z.string().startsWith("@assets/");
10
7
  var colorSchema = z.string();
11
8
  var lengthSchema = z.union([z.number(), z.string()]);
12
9
  var percentageSchema = z.string();
13
10
  var iconNameSchema = z.string();
14
11
  function dynamicSchema(schema) {
15
- return z.union([schema, refSchema, exprSchema]);
12
+ return z.union([schema, refSchema]);
16
13
  }
17
14
  function refOnlySchema(schema) {
18
15
  return z.union([schema, refSchema]);
@@ -20,11 +17,8 @@ function refOnlySchema(schema) {
20
17
  function isRef(value) {
21
18
  return typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string";
22
19
  }
23
- function isExpr(value) {
24
- return typeof value === "object" && value !== null && "$expr" in value && typeof value.$expr === "string";
25
- }
26
20
  function isDynamic(value) {
27
- return isRef(value) || isExpr(value);
21
+ return isRef(value);
28
22
  }
29
23
  function isAssetPath(value) {
30
24
  return typeof value === "string" && value.startsWith("@assets/");
@@ -32,430 +26,6 @@ function isAssetPath(value) {
32
26
 
33
27
  // src/styles.ts
34
28
  import { z as z2 } from "zod";
35
- var gradientStopSchema = z2.object({
36
- color: z2.string(),
37
- position: z2.string()
38
- // e.g. "0%", "100%"
39
- });
40
- var linearGradientSchema = z2.object({
41
- type: z2.literal("linear"),
42
- direction: z2.string(),
43
- // e.g. "135deg", "to right"
44
- stops: z2.array(gradientStopSchema)
45
- });
46
- var radialGradientSchema = z2.object({
47
- type: z2.literal("radial"),
48
- stops: z2.array(gradientStopSchema)
49
- });
50
- var gradientObjectSchema = z2.union([
51
- linearGradientSchema,
52
- radialGradientSchema
53
- ]);
54
- var shadowObjectSchema = z2.object({
55
- offsetX: z2.number(),
56
- offsetY: z2.number(),
57
- blur: z2.number().optional(),
58
- spread: z2.number().optional(),
59
- color: z2.string()
60
- });
61
- var borderObjectSchema = z2.object({
62
- width: z2.number(),
63
- style: z2.enum(["solid", "dashed", "dotted", "none"]),
64
- color: z2.string()
65
- });
66
- var transformObjectSchema = z2.object({
67
- rotate: z2.string().optional(),
68
- // e.g. "45deg"
69
- scale: z2.number().optional(),
70
- // 0.1 ~ 1.5
71
- translateX: z2.number().optional(),
72
- // -500 ~ 500
73
- translateY: z2.number().optional()
74
- // -500 ~ 500
75
- });
76
- var positionValueSchema = z2.enum(["static", "relative", "absolute"]);
77
- var overflowValueSchema = z2.enum(["visible", "hidden", "auto"]);
78
- var displayValueSchema = z2.enum(["flex", "block", "none"]);
79
- var flexDirectionValueSchema = z2.enum([
80
- "row",
81
- "column",
82
- "row-reverse",
83
- "column-reverse"
84
- ]);
85
- var justifyContentValueSchema = z2.enum([
86
- "start",
87
- "center",
88
- "end",
89
- "space-between",
90
- "space-around",
91
- "space-evenly"
92
- ]);
93
- var alignItemsValueSchema = z2.enum([
94
- "start",
95
- "center",
96
- "end",
97
- "stretch",
98
- "baseline"
99
- ]);
100
- var alignSelfValueSchema = z2.enum([
101
- "auto",
102
- "start",
103
- "center",
104
- "end",
105
- "stretch"
106
- ]);
107
- var flexWrapValueSchema = z2.enum(["nowrap", "wrap", "wrap-reverse"]);
108
- var textAlignValueSchema = z2.enum([
109
- "left",
110
- "center",
111
- "right",
112
- "justify"
113
- ]);
114
- var textDecorationValueSchema = z2.enum([
115
- "none",
116
- "underline",
117
- "line-through"
118
- ]);
119
- var fontStyleValueSchema = z2.enum(["normal", "italic"]);
120
- var fontWeightValueSchema = z2.union([
121
- z2.enum(["normal", "bold"]),
122
- z2.literal(100),
123
- z2.literal(200),
124
- z2.literal(300),
125
- z2.literal(400),
126
- z2.literal(500),
127
- z2.literal(600),
128
- z2.literal(700),
129
- z2.literal(800),
130
- z2.literal(900)
131
- ]);
132
- var easingValueSchema = z2.enum([
133
- "ease",
134
- "linear",
135
- "ease-in",
136
- "ease-out",
137
- "ease-in-out"
138
- ]);
139
- var transitionDefSchema = z2.object({
140
- property: z2.string(),
141
- duration: z2.number(),
142
- easing: easingValueSchema.optional(),
143
- delay: z2.number().optional()
144
- });
145
- var transitionFieldSchema = z2.union([transitionDefSchema, z2.array(transitionDefSchema)]).optional();
146
- var sizeValueSchema = z2.union([lengthSchema, percentageSchema, z2.literal("auto")]);
147
- var lineHeightValueSchema = z2.union([z2.number(), lengthSchema]);
148
- var coreStyleShape = {
149
- // -----------------------------------------------------------------------
150
- // Layout — Dynamic
151
- // -----------------------------------------------------------------------
152
- display: dynamicSchema(displayValueSchema).optional(),
153
- flexDirection: dynamicSchema(flexDirectionValueSchema).optional(),
154
- justifyContent: dynamicSchema(justifyContentValueSchema).optional(),
155
- alignItems: dynamicSchema(alignItemsValueSchema).optional(),
156
- alignSelf: dynamicSchema(alignSelfValueSchema).optional(),
157
- flexWrap: dynamicSchema(flexWrapValueSchema).optional(),
158
- flex: dynamicSchema(z2.number()).optional(),
159
- gap: dynamicSchema(lengthSchema).optional(),
160
- // -----------------------------------------------------------------------
161
- // Sizing — Dynamic
162
- // -----------------------------------------------------------------------
163
- width: dynamicSchema(sizeValueSchema).optional(),
164
- height: dynamicSchema(sizeValueSchema).optional(),
165
- minWidth: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
166
- maxWidth: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
167
- minHeight: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
168
- maxHeight: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
169
- // -----------------------------------------------------------------------
170
- // Spacing — Dynamic
171
- // -----------------------------------------------------------------------
172
- padding: dynamicSchema(lengthSchema).optional(),
173
- paddingTop: dynamicSchema(lengthSchema).optional(),
174
- paddingRight: dynamicSchema(lengthSchema).optional(),
175
- paddingBottom: dynamicSchema(lengthSchema).optional(),
176
- paddingLeft: dynamicSchema(lengthSchema).optional(),
177
- margin: dynamicSchema(lengthSchema).optional(),
178
- marginTop: dynamicSchema(lengthSchema).optional(),
179
- marginRight: dynamicSchema(lengthSchema).optional(),
180
- marginBottom: dynamicSchema(lengthSchema).optional(),
181
- marginLeft: dynamicSchema(lengthSchema).optional(),
182
- // -----------------------------------------------------------------------
183
- // Colors — Dynamic
184
- // -----------------------------------------------------------------------
185
- backgroundColor: dynamicSchema(colorSchema).optional(),
186
- color: dynamicSchema(colorSchema).optional(),
187
- // -----------------------------------------------------------------------
188
- // Border radius — Dynamic
189
- // -----------------------------------------------------------------------
190
- borderRadius: dynamicSchema(lengthSchema).optional(),
191
- borderRadiusTopLeft: dynamicSchema(lengthSchema).optional(),
192
- borderRadiusTopRight: dynamicSchema(lengthSchema).optional(),
193
- borderRadiusBottomLeft: dynamicSchema(lengthSchema).optional(),
194
- borderRadiusBottomRight: dynamicSchema(lengthSchema).optional(),
195
- // -----------------------------------------------------------------------
196
- // Typography — Dynamic
197
- // -----------------------------------------------------------------------
198
- fontSize: dynamicSchema(lengthSchema).optional(),
199
- fontWeight: dynamicSchema(fontWeightValueSchema).optional(),
200
- fontStyle: dynamicSchema(fontStyleValueSchema).optional(),
201
- textAlign: dynamicSchema(textAlignValueSchema).optional(),
202
- textDecoration: dynamicSchema(textDecorationValueSchema).optional(),
203
- lineHeight: dynamicSchema(lineHeightValueSchema).optional(),
204
- letterSpacing: dynamicSchema(lengthSchema).optional(),
205
- // -----------------------------------------------------------------------
206
- // Opacity — Dynamic
207
- // -----------------------------------------------------------------------
208
- opacity: dynamicSchema(z2.number()).optional(),
209
- // -----------------------------------------------------------------------
210
- // Gradient — Static only
211
- // -----------------------------------------------------------------------
212
- backgroundGradient: gradientObjectSchema.optional(),
213
- // -----------------------------------------------------------------------
214
- // Shadow — Static only (single or array of shadows)
215
- // -----------------------------------------------------------------------
216
- boxShadow: z2.union([shadowObjectSchema, z2.array(shadowObjectSchema)]).optional(),
217
- // -----------------------------------------------------------------------
218
- // Borders — Static only
219
- // -----------------------------------------------------------------------
220
- border: borderObjectSchema.optional(),
221
- borderTop: borderObjectSchema.optional(),
222
- borderRight: borderObjectSchema.optional(),
223
- borderBottom: borderObjectSchema.optional(),
224
- borderLeft: borderObjectSchema.optional(),
225
- // -----------------------------------------------------------------------
226
- // Transform — Static only (skew excluded)
227
- // -----------------------------------------------------------------------
228
- transform: transformObjectSchema.optional(),
229
- // -----------------------------------------------------------------------
230
- // Overflow — Static only
231
- // -----------------------------------------------------------------------
232
- overflow: overflowValueSchema.optional(),
233
- // -----------------------------------------------------------------------
234
- // Position — Static only
235
- // -----------------------------------------------------------------------
236
- position: positionValueSchema.optional(),
237
- top: lengthSchema.optional(),
238
- right: lengthSchema.optional(),
239
- bottom: lengthSchema.optional(),
240
- left: lengthSchema.optional(),
241
- // -----------------------------------------------------------------------
242
- // Object-fit — Dynamic (for Image nodes)
243
- // -----------------------------------------------------------------------
244
- objectFit: dynamicSchema(z2.enum(["cover", "contain", "fill", "none", "scale-down"])).optional(),
245
- objectPosition: dynamicSchema(z2.string()).optional(),
246
- // -----------------------------------------------------------------------
247
- // Grid — Dynamic
248
- // -----------------------------------------------------------------------
249
- gridTemplateColumns: dynamicSchema(z2.string()).optional(),
250
- gridTemplateRows: dynamicSchema(z2.string()).optional(),
251
- gridColumn: dynamicSchema(z2.string()).optional(),
252
- gridRow: dynamicSchema(z2.string()).optional(),
253
- // -----------------------------------------------------------------------
254
- // z-index — Static only (0-100 enforced at validation layer)
255
- // -----------------------------------------------------------------------
256
- zIndex: z2.number().optional(),
257
- // -----------------------------------------------------------------------
258
- // $style — reference to a named style in card.styles
259
- // -----------------------------------------------------------------------
260
- $style: z2.string().optional()
261
- };
262
- var { $style: _$styleField, ...coreStyleShapeWithout$style } = coreStyleShape;
263
- var hoverStylePropsSchema = z2.object({
264
- ...coreStyleShapeWithout$style,
265
- transition: transitionFieldSchema
266
- });
267
- var stylePropsSchema = z2.object({
268
- ...coreStyleShape,
269
- hoverStyle: hoverStylePropsSchema.optional(),
270
- transition: transitionFieldSchema
271
- });
272
-
273
- // src/props.ts
274
- import { z as z3 } from "zod";
275
- var textPropsSchema = z3.object({
276
- content: dynamicSchema(z3.string())
277
- });
278
- var imagePropsSchema = z3.object({
279
- src: refOnlySchema(assetPathSchema),
280
- alt: dynamicSchema(z3.string()).optional()
281
- });
282
- var progressBarPropsSchema = z3.object({
283
- value: dynamicSchema(z3.number()),
284
- max: dynamicSchema(z3.number()),
285
- color: dynamicSchema(colorSchema).optional()
286
- });
287
- var avatarPropsSchema = z3.object({
288
- src: refOnlySchema(assetPathSchema),
289
- size: dynamicSchema(lengthSchema).optional()
290
- });
291
- var iconPropsSchema = z3.object({
292
- name: iconNameSchema,
293
- size: dynamicSchema(lengthSchema).optional(),
294
- color: dynamicSchema(colorSchema).optional()
295
- });
296
- var badgePropsSchema = z3.object({
297
- label: dynamicSchema(z3.string()),
298
- color: dynamicSchema(colorSchema).optional()
299
- });
300
- var chipPropsSchema = z3.object({
301
- label: dynamicSchema(z3.string()),
302
- color: dynamicSchema(colorSchema).optional()
303
- });
304
- var dividerPropsSchema = z3.object({
305
- color: dynamicSchema(colorSchema).optional(),
306
- thickness: dynamicSchema(lengthSchema).optional()
307
- });
308
- var spacerPropsSchema = z3.object({
309
- size: dynamicSchema(lengthSchema).optional()
310
- });
311
- var buttonPropsSchema = z3.object({
312
- label: dynamicSchema(z3.string()),
313
- action: z3.string()
314
- });
315
- var togglePropsSchema = z3.object({
316
- value: dynamicSchema(z3.boolean()),
317
- onToggle: z3.string()
318
- });
319
-
320
- // src/primitives.ts
321
- import { z as z4 } from "zod";
322
- var forLoopSchema = z4.object({
323
- for: z4.string(),
324
- in: z4.string(),
325
- template: z4.lazy(() => ugcNodeSchema)
326
- });
327
- var childrenSchema = z4.union([
328
- z4.array(z4.lazy(() => ugcNodeSchema)),
329
- forLoopSchema
330
- ]);
331
- var baseFields = {
332
- style: stylePropsSchema.optional(),
333
- condition: exprSchema.optional()
334
- };
335
- var boxNodeSchema = z4.object({
336
- type: z4.literal("Box"),
337
- children: childrenSchema.optional(),
338
- ...baseFields
339
- });
340
- var rowNodeSchema = z4.object({
341
- type: z4.literal("Row"),
342
- children: childrenSchema.optional(),
343
- ...baseFields
344
- });
345
- var columnNodeSchema = z4.object({
346
- type: z4.literal("Column"),
347
- children: childrenSchema.optional(),
348
- ...baseFields
349
- });
350
- var stackNodeSchema = z4.object({
351
- type: z4.literal("Stack"),
352
- children: childrenSchema.optional(),
353
- ...baseFields
354
- });
355
- var gridNodeSchema = z4.object({
356
- type: z4.literal("Grid"),
357
- children: childrenSchema.optional(),
358
- ...baseFields
359
- });
360
- var textNodeSchema = z4.object({
361
- type: z4.literal("Text"),
362
- ...textPropsSchema.shape,
363
- ...baseFields
364
- });
365
- var imageNodeSchema = z4.object({
366
- type: z4.literal("Image"),
367
- ...imagePropsSchema.shape,
368
- ...baseFields
369
- });
370
- var progressBarNodeSchema = z4.object({
371
- type: z4.literal("ProgressBar"),
372
- ...progressBarPropsSchema.shape,
373
- ...baseFields
374
- });
375
- var avatarNodeSchema = z4.object({
376
- type: z4.literal("Avatar"),
377
- ...avatarPropsSchema.shape,
378
- ...baseFields
379
- });
380
- var iconNodeSchema = z4.object({
381
- type: z4.literal("Icon"),
382
- ...iconPropsSchema.shape,
383
- ...baseFields
384
- });
385
- var badgeNodeSchema = z4.object({
386
- type: z4.literal("Badge"),
387
- ...badgePropsSchema.shape,
388
- ...baseFields
389
- });
390
- var chipNodeSchema = z4.object({
391
- type: z4.literal("Chip"),
392
- ...chipPropsSchema.shape,
393
- ...baseFields
394
- });
395
- var dividerNodeSchema = z4.object({
396
- type: z4.literal("Divider"),
397
- ...dividerPropsSchema.shape,
398
- ...baseFields
399
- });
400
- var spacerNodeSchema = z4.object({
401
- type: z4.literal("Spacer"),
402
- ...spacerPropsSchema.shape,
403
- ...baseFields
404
- });
405
- var buttonNodeSchema = z4.object({
406
- type: z4.literal("Button"),
407
- ...buttonPropsSchema.shape,
408
- ...baseFields
409
- });
410
- var toggleNodeSchema = z4.object({
411
- type: z4.literal("Toggle"),
412
- ...togglePropsSchema.shape,
413
- ...baseFields
414
- });
415
- var ugcNodeSchema = z4.lazy(
416
- () => z4.discriminatedUnion("type", [
417
- boxNodeSchema,
418
- rowNodeSchema,
419
- columnNodeSchema,
420
- stackNodeSchema,
421
- gridNodeSchema,
422
- textNodeSchema,
423
- imageNodeSchema,
424
- progressBarNodeSchema,
425
- avatarNodeSchema,
426
- iconNodeSchema,
427
- badgeNodeSchema,
428
- chipNodeSchema,
429
- dividerNodeSchema,
430
- spacerNodeSchema,
431
- buttonNodeSchema,
432
- toggleNodeSchema
433
- ])
434
- );
435
- var phase1NodeSchema = z4.lazy(
436
- () => z4.discriminatedUnion("type", [
437
- boxNodeSchema,
438
- rowNodeSchema,
439
- columnNodeSchema,
440
- textNodeSchema,
441
- imageNodeSchema
442
- ])
443
- );
444
-
445
- // src/card.ts
446
- import { z as z5 } from "zod";
447
- var cardMetaSchema = z5.object({
448
- name: z5.string(),
449
- version: z5.string()
450
- });
451
- var styleNamePattern = /^[A-Za-z][A-Za-z0-9_-]*$/;
452
- var ugcCardSchema = z5.object({
453
- meta: cardMetaSchema,
454
- assets: z5.record(z5.string(), z5.string()).optional(),
455
- state: z5.record(z5.string(), z5.unknown()).optional(),
456
- styles: z5.record(z5.string().regex(styleNamePattern), stylePropsSchema).optional(),
457
- views: z5.record(z5.string(), ugcNodeSchema)
458
- });
459
29
 
460
30
  // src/constants.ts
461
31
  var CARD_JSON_MAX_BYTES = 1e6;
@@ -468,14 +38,6 @@ var MAX_LOOP_ITERATIONS = 1e3;
468
38
  var MAX_NESTED_LOOPS = 2;
469
39
  var MAX_OVERFLOW_AUTO_COUNT = 2;
470
40
  var MAX_STACK_NESTING = 3;
471
- var EXPR_MAX_LENGTH = 500;
472
- var EXPR_MAX_TOKENS = 50;
473
- var EXPR_MAX_NESTING = 10;
474
- var EXPR_MAX_CONDITION_NESTING = 3;
475
- var EXPR_MAX_STRING_LITERAL = 1e3;
476
- var EXPR_MAX_REF_DEPTH = 5;
477
- var EXPR_MAX_ARRAY_INDEX = 9999;
478
- var EXPR_MAX_FRACTIONAL_DIGITS = 10;
479
41
  var ZINDEX_MIN = 0;
480
42
  var ZINDEX_MAX = 100;
481
43
  var TRANSFORM_SCALE_MIN = 0.1;
@@ -484,6 +46,16 @@ var TRANSFORM_TRANSLATE_MIN = -500;
484
46
  var TRANSFORM_TRANSLATE_MAX = 500;
485
47
  var FONT_SIZE_MIN = 8;
486
48
  var FONT_SIZE_MAX = 72;
49
+ var ALLOWED_FONT_FAMILIES = [
50
+ "sans",
51
+ "serif",
52
+ "mono",
53
+ "rounded",
54
+ "display",
55
+ "handwriting"
56
+ ];
57
+ var TEXT_SHADOW_MAX_COUNT = 5;
58
+ var TEXT_SHADOW_BLUR_MAX = 100;
487
59
  var BOX_SHADOW_MAX_COUNT = 5;
488
60
  var BOX_SHADOW_BLUR_MAX = 100;
489
61
  var BOX_SHADOW_SPREAD_MAX = 50;
@@ -547,7 +119,8 @@ var ALLOWED_TRANSITION_PROPERTIES = [
547
119
  "gridColumn",
548
120
  "gridRow",
549
121
  "objectFit",
550
- "objectPosition"
122
+ "objectPosition",
123
+ "textShadow"
551
124
  ];
552
125
  var PHASE1_COMPONENT_TYPES = [
553
126
  "Box",
@@ -755,7 +328,467 @@ var CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
755
328
  "yellow",
756
329
  "yellowgreen"
757
330
  ]);
331
+
332
+ // src/styles.ts
333
+ var gradientStopSchema = z2.object({
334
+ color: dynamicSchema(z2.string()),
335
+ position: dynamicSchema(z2.string())
336
+ // e.g. "0%", "100%"
337
+ });
338
+ var linearGradientSchema = z2.object({
339
+ type: z2.literal("linear"),
340
+ direction: dynamicSchema(z2.string()),
341
+ // e.g. "135deg", "to right"
342
+ stops: z2.array(gradientStopSchema)
343
+ });
344
+ var radialGradientSchema = z2.object({
345
+ type: z2.literal("radial"),
346
+ stops: z2.array(gradientStopSchema)
347
+ });
348
+ var repeatingLinearGradientSchema = z2.object({
349
+ type: z2.literal("repeating-linear"),
350
+ direction: dynamicSchema(z2.string()),
351
+ // e.g. "180deg"
352
+ stops: z2.array(gradientStopSchema)
353
+ });
354
+ var gradientObjectSchema = z2.union([
355
+ linearGradientSchema,
356
+ radialGradientSchema,
357
+ repeatingLinearGradientSchema
358
+ ]);
359
+ var shadowObjectSchema = z2.object({
360
+ offsetX: dynamicSchema(z2.number()),
361
+ offsetY: dynamicSchema(z2.number()),
362
+ blur: dynamicSchema(z2.number()).optional(),
363
+ spread: dynamicSchema(z2.number()).optional(),
364
+ color: dynamicSchema(z2.string())
365
+ });
366
+ var textShadowObjectSchema = z2.object({
367
+ offsetX: dynamicSchema(z2.number()),
368
+ offsetY: dynamicSchema(z2.number()),
369
+ blur: dynamicSchema(z2.number()).optional(),
370
+ color: dynamicSchema(z2.string())
371
+ });
372
+ var borderStyleValueSchema = z2.enum(["solid", "dashed", "dotted", "none"]);
373
+ var borderObjectSchema = z2.object({
374
+ width: dynamicSchema(z2.number()),
375
+ style: dynamicSchema(borderStyleValueSchema),
376
+ color: dynamicSchema(z2.string())
377
+ });
378
+ var transformObjectSchema = z2.object({
379
+ rotate: dynamicSchema(z2.string()).optional(),
380
+ // e.g. "45deg"
381
+ scale: dynamicSchema(z2.number()).optional(),
382
+ // 0.1 ~ 1.5
383
+ translateX: dynamicSchema(z2.number()).optional(),
384
+ // -500 ~ 500
385
+ translateY: dynamicSchema(z2.number()).optional()
386
+ // -500 ~ 500
387
+ });
388
+ var positionValueSchema = z2.enum(["static", "relative", "absolute"]);
389
+ var overflowValueSchema = z2.enum(["visible", "hidden", "auto"]);
390
+ var displayValueSchema = z2.enum(["flex", "block", "none"]);
391
+ var flexDirectionValueSchema = z2.enum([
392
+ "row",
393
+ "column",
394
+ "row-reverse",
395
+ "column-reverse"
396
+ ]);
397
+ var justifyContentValueSchema = z2.enum([
398
+ "start",
399
+ "flex-start",
400
+ "center",
401
+ "end",
402
+ "flex-end",
403
+ "space-between",
404
+ "space-around",
405
+ "space-evenly"
406
+ ]);
407
+ var alignItemsValueSchema = z2.enum([
408
+ "start",
409
+ "flex-start",
410
+ "center",
411
+ "end",
412
+ "flex-end",
413
+ "stretch",
414
+ "baseline"
415
+ ]);
416
+ var alignSelfValueSchema = z2.enum([
417
+ "auto",
418
+ "start",
419
+ "flex-start",
420
+ "center",
421
+ "end",
422
+ "flex-end",
423
+ "stretch"
424
+ ]);
425
+ var flexWrapValueSchema = z2.enum(["nowrap", "wrap", "wrap-reverse"]);
426
+ var textAlignValueSchema = z2.enum([
427
+ "left",
428
+ "center",
429
+ "right",
430
+ "justify"
431
+ ]);
432
+ var textDecorationValueSchema = z2.enum([
433
+ "none",
434
+ "underline",
435
+ "line-through"
436
+ ]);
437
+ var fontStyleValueSchema = z2.enum(["normal", "italic"]);
438
+ var fontFamilyValueSchema = z2.enum(ALLOWED_FONT_FAMILIES);
439
+ var fontWeightValueSchema = z2.union([
440
+ z2.enum(["normal", "bold"]),
441
+ z2.literal("100"),
442
+ z2.literal("200"),
443
+ z2.literal("300"),
444
+ z2.literal("400"),
445
+ z2.literal("500"),
446
+ z2.literal("600"),
447
+ z2.literal("700"),
448
+ z2.literal("800"),
449
+ z2.literal("900"),
450
+ z2.literal(100),
451
+ z2.literal(200),
452
+ z2.literal(300),
453
+ z2.literal(400),
454
+ z2.literal(500),
455
+ z2.literal(600),
456
+ z2.literal(700),
457
+ z2.literal(800),
458
+ z2.literal(900)
459
+ ]);
460
+ var easingValueSchema = z2.enum([
461
+ "ease",
462
+ "linear",
463
+ "ease-in",
464
+ "ease-out",
465
+ "ease-in-out"
466
+ ]);
467
+ var transitionDefSchema = z2.object({
468
+ property: z2.string(),
469
+ duration: z2.number(),
470
+ easing: easingValueSchema.optional(),
471
+ delay: z2.number().optional()
472
+ });
473
+ var transitionFieldSchema = z2.union([transitionDefSchema, z2.array(transitionDefSchema)]).optional();
474
+ var sizeValueSchema = z2.union([lengthSchema, percentageSchema, z2.literal("auto")]);
475
+ var lineHeightValueSchema = z2.union([z2.number(), lengthSchema]);
476
+ var coreStyleShape = {
477
+ // -----------------------------------------------------------------------
478
+ // Layout — Dynamic
479
+ // -----------------------------------------------------------------------
480
+ display: dynamicSchema(displayValueSchema).optional(),
481
+ flexDirection: dynamicSchema(flexDirectionValueSchema).optional(),
482
+ justifyContent: dynamicSchema(justifyContentValueSchema).optional(),
483
+ alignItems: dynamicSchema(alignItemsValueSchema).optional(),
484
+ alignSelf: dynamicSchema(alignSelfValueSchema).optional(),
485
+ flexWrap: dynamicSchema(flexWrapValueSchema).optional(),
486
+ flex: dynamicSchema(z2.number()).optional(),
487
+ gap: dynamicSchema(lengthSchema).optional(),
488
+ // -----------------------------------------------------------------------
489
+ // Sizing — Dynamic
490
+ // -----------------------------------------------------------------------
491
+ width: dynamicSchema(sizeValueSchema).optional(),
492
+ height: dynamicSchema(sizeValueSchema).optional(),
493
+ minWidth: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
494
+ maxWidth: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
495
+ minHeight: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
496
+ maxHeight: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
497
+ // -----------------------------------------------------------------------
498
+ // Spacing — Dynamic
499
+ // -----------------------------------------------------------------------
500
+ padding: dynamicSchema(lengthSchema).optional(),
501
+ paddingTop: dynamicSchema(lengthSchema).optional(),
502
+ paddingRight: dynamicSchema(lengthSchema).optional(),
503
+ paddingBottom: dynamicSchema(lengthSchema).optional(),
504
+ paddingLeft: dynamicSchema(lengthSchema).optional(),
505
+ margin: dynamicSchema(lengthSchema).optional(),
506
+ marginTop: dynamicSchema(lengthSchema).optional(),
507
+ marginRight: dynamicSchema(lengthSchema).optional(),
508
+ marginBottom: dynamicSchema(lengthSchema).optional(),
509
+ marginLeft: dynamicSchema(lengthSchema).optional(),
510
+ // -----------------------------------------------------------------------
511
+ // Colors — Dynamic
512
+ // -----------------------------------------------------------------------
513
+ backgroundColor: dynamicSchema(colorSchema).optional(),
514
+ color: dynamicSchema(colorSchema).optional(),
515
+ // -----------------------------------------------------------------------
516
+ // Border radius — Dynamic
517
+ // -----------------------------------------------------------------------
518
+ borderRadius: dynamicSchema(lengthSchema).optional(),
519
+ borderRadiusTopLeft: dynamicSchema(lengthSchema).optional(),
520
+ borderRadiusTopRight: dynamicSchema(lengthSchema).optional(),
521
+ borderRadiusBottomLeft: dynamicSchema(lengthSchema).optional(),
522
+ borderRadiusBottomRight: dynamicSchema(lengthSchema).optional(),
523
+ // -----------------------------------------------------------------------
524
+ // Typography — Dynamic
525
+ // -----------------------------------------------------------------------
526
+ fontFamily: dynamicSchema(fontFamilyValueSchema).optional(),
527
+ fontSize: dynamicSchema(lengthSchema).optional(),
528
+ fontWeight: dynamicSchema(fontWeightValueSchema).optional(),
529
+ fontStyle: dynamicSchema(fontStyleValueSchema).optional(),
530
+ textAlign: dynamicSchema(textAlignValueSchema).optional(),
531
+ textDecoration: dynamicSchema(textDecorationValueSchema).optional(),
532
+ lineHeight: dynamicSchema(lineHeightValueSchema).optional(),
533
+ letterSpacing: dynamicSchema(lengthSchema).optional(),
534
+ // -----------------------------------------------------------------------
535
+ // Opacity — Dynamic
536
+ // -----------------------------------------------------------------------
537
+ opacity: dynamicSchema(z2.number()).optional(),
538
+ // -----------------------------------------------------------------------
539
+ // Gradient — Static only
540
+ // -----------------------------------------------------------------------
541
+ backgroundGradient: gradientObjectSchema.optional(),
542
+ // -----------------------------------------------------------------------
543
+ // Shadow — Static only (single or array of shadows)
544
+ // -----------------------------------------------------------------------
545
+ boxShadow: z2.union([shadowObjectSchema, z2.array(shadowObjectSchema)]).optional(),
546
+ // -----------------------------------------------------------------------
547
+ // Text shadow — Static only (single or array of shadows)
548
+ // -----------------------------------------------------------------------
549
+ textShadow: z2.union([textShadowObjectSchema, z2.array(textShadowObjectSchema)]).optional(),
550
+ // -----------------------------------------------------------------------
551
+ // Borders — Static only
552
+ // -----------------------------------------------------------------------
553
+ border: borderObjectSchema.optional(),
554
+ borderTop: borderObjectSchema.optional(),
555
+ borderRight: borderObjectSchema.optional(),
556
+ borderBottom: borderObjectSchema.optional(),
557
+ borderLeft: borderObjectSchema.optional(),
558
+ // -----------------------------------------------------------------------
559
+ // Transform — Static only (skew excluded)
560
+ // -----------------------------------------------------------------------
561
+ transform: transformObjectSchema.optional(),
562
+ // -----------------------------------------------------------------------
563
+ // Overflow — Static only
564
+ // -----------------------------------------------------------------------
565
+ overflow: overflowValueSchema.optional(),
566
+ // -----------------------------------------------------------------------
567
+ // Position — Static only
568
+ // -----------------------------------------------------------------------
569
+ position: positionValueSchema.optional(),
570
+ top: lengthSchema.optional(),
571
+ right: lengthSchema.optional(),
572
+ bottom: lengthSchema.optional(),
573
+ left: lengthSchema.optional(),
574
+ // -----------------------------------------------------------------------
575
+ // Object-fit — Dynamic (for Image nodes)
576
+ // -----------------------------------------------------------------------
577
+ objectFit: dynamicSchema(z2.enum(["cover", "contain", "fill", "none", "scale-down"])).optional(),
578
+ objectPosition: dynamicSchema(z2.string()).optional(),
579
+ // -----------------------------------------------------------------------
580
+ // Grid — Dynamic
581
+ // -----------------------------------------------------------------------
582
+ gridTemplateColumns: dynamicSchema(z2.string()).optional(),
583
+ gridTemplateRows: dynamicSchema(z2.string()).optional(),
584
+ gridColumn: dynamicSchema(z2.string()).optional(),
585
+ gridRow: dynamicSchema(z2.string()).optional(),
586
+ // -----------------------------------------------------------------------
587
+ // z-index — Static only (0-100 enforced at validation layer)
588
+ // -----------------------------------------------------------------------
589
+ zIndex: z2.number().optional(),
590
+ // -----------------------------------------------------------------------
591
+ // $style — reference to a named style in card.styles
592
+ // -----------------------------------------------------------------------
593
+ $style: z2.string().optional()
594
+ };
595
+ var hoverStylePropsSchema = z2.object({
596
+ ...coreStyleShape,
597
+ transition: transitionFieldSchema
598
+ });
599
+ var stylePropsSchema = z2.object({
600
+ ...coreStyleShape,
601
+ hoverStyle: hoverStylePropsSchema.optional(),
602
+ transition: transitionFieldSchema
603
+ });
604
+
605
+ // src/props.ts
606
+ import { z as z3 } from "zod";
607
+ var textPropsSchema = z3.object({
608
+ content: dynamicSchema(z3.string())
609
+ });
610
+ var imagePropsSchema = z3.object({
611
+ src: refOnlySchema(assetPathSchema),
612
+ alt: dynamicSchema(z3.string()).optional()
613
+ });
614
+ var progressBarPropsSchema = z3.object({
615
+ value: dynamicSchema(z3.number()),
616
+ max: dynamicSchema(z3.number()),
617
+ color: dynamicSchema(colorSchema).optional()
618
+ });
619
+ var avatarPropsSchema = z3.object({
620
+ src: refOnlySchema(assetPathSchema),
621
+ size: dynamicSchema(lengthSchema).optional()
622
+ });
623
+ var iconPropsSchema = z3.object({
624
+ name: dynamicSchema(iconNameSchema),
625
+ size: dynamicSchema(lengthSchema).optional(),
626
+ color: dynamicSchema(colorSchema).optional()
627
+ });
628
+ var badgePropsSchema = z3.object({
629
+ label: dynamicSchema(z3.string()),
630
+ color: dynamicSchema(colorSchema).optional()
631
+ });
632
+ var chipPropsSchema = z3.object({
633
+ label: dynamicSchema(z3.string()),
634
+ color: dynamicSchema(colorSchema).optional()
635
+ });
636
+ var dividerPropsSchema = z3.object({
637
+ color: dynamicSchema(colorSchema).optional(),
638
+ thickness: dynamicSchema(lengthSchema).optional()
639
+ });
640
+ var spacerPropsSchema = z3.object({
641
+ size: dynamicSchema(lengthSchema).optional()
642
+ });
643
+ var buttonPropsSchema = z3.object({
644
+ label: dynamicSchema(z3.string()),
645
+ action: z3.string()
646
+ });
647
+ var togglePropsSchema = z3.object({
648
+ value: dynamicSchema(z3.boolean()),
649
+ onToggle: z3.string()
650
+ });
651
+
652
+ // src/primitives.ts
653
+ import { z as z4 } from "zod";
654
+ var forLoopSchema = z4.object({
655
+ for: z4.string(),
656
+ in: z4.string(),
657
+ template: z4.lazy(() => ugcNodeSchema)
658
+ });
659
+ var childrenSchema = z4.union([
660
+ z4.array(z4.lazy(() => ugcNodeSchema)),
661
+ forLoopSchema
662
+ ]);
663
+ var baseFields = {
664
+ style: stylePropsSchema.optional()
665
+ };
666
+ var boxNodeSchema = z4.object({
667
+ type: z4.literal("Box"),
668
+ children: childrenSchema.optional(),
669
+ ...baseFields
670
+ });
671
+ var rowNodeSchema = z4.object({
672
+ type: z4.literal("Row"),
673
+ children: childrenSchema.optional(),
674
+ ...baseFields
675
+ });
676
+ var columnNodeSchema = z4.object({
677
+ type: z4.literal("Column"),
678
+ children: childrenSchema.optional(),
679
+ ...baseFields
680
+ });
681
+ var stackNodeSchema = z4.object({
682
+ type: z4.literal("Stack"),
683
+ children: childrenSchema.optional(),
684
+ ...baseFields
685
+ });
686
+ var gridNodeSchema = z4.object({
687
+ type: z4.literal("Grid"),
688
+ children: childrenSchema.optional(),
689
+ ...baseFields
690
+ });
691
+ var textNodeSchema = z4.object({
692
+ type: z4.literal("Text"),
693
+ ...textPropsSchema.shape,
694
+ ...baseFields
695
+ });
696
+ var imageNodeSchema = z4.object({
697
+ type: z4.literal("Image"),
698
+ ...imagePropsSchema.shape,
699
+ ...baseFields
700
+ });
701
+ var progressBarNodeSchema = z4.object({
702
+ type: z4.literal("ProgressBar"),
703
+ ...progressBarPropsSchema.shape,
704
+ ...baseFields
705
+ });
706
+ var avatarNodeSchema = z4.object({
707
+ type: z4.literal("Avatar"),
708
+ ...avatarPropsSchema.shape,
709
+ ...baseFields
710
+ });
711
+ var iconNodeSchema = z4.object({
712
+ type: z4.literal("Icon"),
713
+ ...iconPropsSchema.shape,
714
+ ...baseFields
715
+ });
716
+ var badgeNodeSchema = z4.object({
717
+ type: z4.literal("Badge"),
718
+ ...badgePropsSchema.shape,
719
+ ...baseFields
720
+ });
721
+ var chipNodeSchema = z4.object({
722
+ type: z4.literal("Chip"),
723
+ ...chipPropsSchema.shape,
724
+ ...baseFields
725
+ });
726
+ var dividerNodeSchema = z4.object({
727
+ type: z4.literal("Divider"),
728
+ ...dividerPropsSchema.shape,
729
+ ...baseFields
730
+ });
731
+ var spacerNodeSchema = z4.object({
732
+ type: z4.literal("Spacer"),
733
+ ...spacerPropsSchema.shape,
734
+ ...baseFields
735
+ });
736
+ var buttonNodeSchema = z4.object({
737
+ type: z4.literal("Button"),
738
+ ...buttonPropsSchema.shape,
739
+ ...baseFields
740
+ });
741
+ var toggleNodeSchema = z4.object({
742
+ type: z4.literal("Toggle"),
743
+ ...togglePropsSchema.shape,
744
+ ...baseFields
745
+ });
746
+ var ugcNodeSchema = z4.lazy(
747
+ () => z4.discriminatedUnion("type", [
748
+ boxNodeSchema,
749
+ rowNodeSchema,
750
+ columnNodeSchema,
751
+ stackNodeSchema,
752
+ gridNodeSchema,
753
+ textNodeSchema,
754
+ imageNodeSchema,
755
+ progressBarNodeSchema,
756
+ avatarNodeSchema,
757
+ iconNodeSchema,
758
+ badgeNodeSchema,
759
+ chipNodeSchema,
760
+ dividerNodeSchema,
761
+ spacerNodeSchema,
762
+ buttonNodeSchema,
763
+ toggleNodeSchema
764
+ ])
765
+ );
766
+ var phase1NodeSchema = z4.lazy(
767
+ () => z4.discriminatedUnion("type", [
768
+ boxNodeSchema,
769
+ rowNodeSchema,
770
+ columnNodeSchema,
771
+ textNodeSchema,
772
+ imageNodeSchema
773
+ ])
774
+ );
775
+
776
+ // src/card.ts
777
+ import { z as z5 } from "zod";
778
+ var cardMetaSchema = z5.object({
779
+ name: z5.string(),
780
+ version: z5.string()
781
+ });
782
+ var styleNamePattern = /^[A-Za-z][A-Za-z0-9_-]*$/;
783
+ var ugcCardSchema = z5.object({
784
+ meta: cardMetaSchema,
785
+ assets: z5.record(z5.string(), z5.string()).optional(),
786
+ state: z5.record(z5.string(), z5.unknown()).optional(),
787
+ styles: z5.record(z5.string().regex(styleNamePattern), stylePropsSchema).optional(),
788
+ views: z5.record(z5.string(), ugcNodeSchema)
789
+ });
758
790
  export {
791
+ ALLOWED_FONT_FAMILIES,
759
792
  ALLOWED_OVERFLOW_VALUES,
760
793
  ALLOWED_TRANSITION_PROPERTIES,
761
794
  ALL_COMPONENT_TYPES,
@@ -768,14 +801,6 @@ export {
768
801
  CARD_JSON_MAX_BYTES,
769
802
  CSS_NAMED_COLORS,
770
803
  DANGEROUS_CSS_FUNCTIONS,
771
- EXPR_MAX_ARRAY_INDEX,
772
- EXPR_MAX_CONDITION_NESTING,
773
- EXPR_MAX_FRACTIONAL_DIGITS,
774
- EXPR_MAX_LENGTH,
775
- EXPR_MAX_NESTING,
776
- EXPR_MAX_REF_DEPTH,
777
- EXPR_MAX_STRING_LITERAL,
778
- EXPR_MAX_TOKENS,
779
804
  FONT_SIZE_MAX,
780
805
  FONT_SIZE_MIN,
781
806
  FORBIDDEN_POSITION_VALUES,
@@ -793,6 +818,8 @@ export {
793
818
  PROTOTYPE_POLLUTION_SEGMENTS,
794
819
  STYLE_OBJECTS_TOTAL_MAX_BYTES,
795
820
  TEXT_CONTENT_TOTAL_MAX_BYTES,
821
+ TEXT_SHADOW_BLUR_MAX,
822
+ TEXT_SHADOW_MAX_COUNT,
796
823
  TRANSFORM_SCALE_MAX,
797
824
  TRANSFORM_SCALE_MIN,
798
825
  TRANSFORM_TRANSLATE_MAX,
@@ -810,6 +837,7 @@ export {
810
837
  badgeNodeSchema,
811
838
  badgePropsSchema,
812
839
  borderObjectSchema,
840
+ borderStyleValueSchema,
813
841
  boxNodeSchema,
814
842
  buttonNodeSchema,
815
843
  buttonPropsSchema,
@@ -823,9 +851,9 @@ export {
823
851
  dividerPropsSchema,
824
852
  dynamicSchema,
825
853
  easingValueSchema,
826
- exprSchema,
827
854
  flexDirectionValueSchema,
828
855
  flexWrapValueSchema,
856
+ fontFamilyValueSchema,
829
857
  fontStyleValueSchema,
830
858
  fontWeightValueSchema,
831
859
  forLoopSchema,
@@ -840,7 +868,6 @@ export {
840
868
  imagePropsSchema,
841
869
  isAssetPath,
842
870
  isDynamic,
843
- isExpr,
844
871
  isRef,
845
872
  justifyContentValueSchema,
846
873
  lengthSchema,
@@ -854,6 +881,7 @@ export {
854
881
  radialGradientSchema,
855
882
  refOnlySchema,
856
883
  refSchema,
884
+ repeatingLinearGradientSchema,
857
885
  rowNodeSchema,
858
886
  shadowObjectSchema,
859
887
  spacerNodeSchema,
@@ -864,6 +892,7 @@ export {
864
892
  textDecorationValueSchema,
865
893
  textNodeSchema,
866
894
  textPropsSchema,
895
+ textShadowObjectSchema,
867
896
  toggleNodeSchema,
868
897
  togglePropsSchema,
869
898
  transformObjectSchema,