@safe-ugc-ui/types 0.4.0 → 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
@@ -26,444 +26,6 @@ function isAssetPath(value) {
26
26
 
27
27
  // src/styles.ts
28
28
  import { z as z2 } from "zod";
29
- var gradientStopSchema = z2.object({
30
- color: dynamicSchema(z2.string()),
31
- position: dynamicSchema(z2.string())
32
- // e.g. "0%", "100%"
33
- });
34
- var linearGradientSchema = z2.object({
35
- type: z2.literal("linear"),
36
- direction: dynamicSchema(z2.string()),
37
- // e.g. "135deg", "to right"
38
- stops: z2.array(gradientStopSchema)
39
- });
40
- var radialGradientSchema = z2.object({
41
- type: z2.literal("radial"),
42
- stops: z2.array(gradientStopSchema)
43
- });
44
- var gradientObjectSchema = z2.union([
45
- linearGradientSchema,
46
- radialGradientSchema
47
- ]);
48
- var shadowObjectSchema = z2.object({
49
- offsetX: dynamicSchema(z2.number()),
50
- offsetY: dynamicSchema(z2.number()),
51
- blur: dynamicSchema(z2.number()).optional(),
52
- spread: dynamicSchema(z2.number()).optional(),
53
- color: dynamicSchema(z2.string())
54
- });
55
- var borderStyleValueSchema = z2.enum(["solid", "dashed", "dotted", "none"]);
56
- var borderObjectSchema = z2.object({
57
- width: dynamicSchema(z2.number()),
58
- style: dynamicSchema(borderStyleValueSchema),
59
- color: dynamicSchema(z2.string())
60
- });
61
- var transformObjectSchema = z2.object({
62
- rotate: dynamicSchema(z2.string()).optional(),
63
- // e.g. "45deg"
64
- scale: dynamicSchema(z2.number()).optional(),
65
- // 0.1 ~ 1.5
66
- translateX: dynamicSchema(z2.number()).optional(),
67
- // -500 ~ 500
68
- translateY: dynamicSchema(z2.number()).optional()
69
- // -500 ~ 500
70
- });
71
- var positionValueSchema = z2.enum(["static", "relative", "absolute"]);
72
- var overflowValueSchema = z2.enum(["visible", "hidden", "auto"]);
73
- var displayValueSchema = z2.enum(["flex", "block", "none"]);
74
- var flexDirectionValueSchema = z2.enum([
75
- "row",
76
- "column",
77
- "row-reverse",
78
- "column-reverse"
79
- ]);
80
- var justifyContentValueSchema = z2.enum([
81
- "start",
82
- "flex-start",
83
- "center",
84
- "end",
85
- "flex-end",
86
- "space-between",
87
- "space-around",
88
- "space-evenly"
89
- ]);
90
- var alignItemsValueSchema = z2.enum([
91
- "start",
92
- "flex-start",
93
- "center",
94
- "end",
95
- "flex-end",
96
- "stretch",
97
- "baseline"
98
- ]);
99
- var alignSelfValueSchema = z2.enum([
100
- "auto",
101
- "start",
102
- "flex-start",
103
- "center",
104
- "end",
105
- "flex-end",
106
- "stretch"
107
- ]);
108
- var flexWrapValueSchema = z2.enum(["nowrap", "wrap", "wrap-reverse"]);
109
- var textAlignValueSchema = z2.enum([
110
- "left",
111
- "center",
112
- "right",
113
- "justify"
114
- ]);
115
- var textDecorationValueSchema = z2.enum([
116
- "none",
117
- "underline",
118
- "line-through"
119
- ]);
120
- var fontStyleValueSchema = z2.enum(["normal", "italic"]);
121
- var fontWeightValueSchema = z2.union([
122
- z2.enum(["normal", "bold"]),
123
- z2.literal("100"),
124
- z2.literal("200"),
125
- z2.literal("300"),
126
- z2.literal("400"),
127
- z2.literal("500"),
128
- z2.literal("600"),
129
- z2.literal("700"),
130
- z2.literal("800"),
131
- z2.literal("900"),
132
- z2.literal(100),
133
- z2.literal(200),
134
- z2.literal(300),
135
- z2.literal(400),
136
- z2.literal(500),
137
- z2.literal(600),
138
- z2.literal(700),
139
- z2.literal(800),
140
- z2.literal(900)
141
- ]);
142
- var easingValueSchema = z2.enum([
143
- "ease",
144
- "linear",
145
- "ease-in",
146
- "ease-out",
147
- "ease-in-out"
148
- ]);
149
- var transitionDefSchema = z2.object({
150
- property: z2.string(),
151
- duration: z2.number(),
152
- easing: easingValueSchema.optional(),
153
- delay: z2.number().optional()
154
- });
155
- var transitionFieldSchema = z2.union([transitionDefSchema, z2.array(transitionDefSchema)]).optional();
156
- var sizeValueSchema = z2.union([lengthSchema, percentageSchema, z2.literal("auto")]);
157
- var lineHeightValueSchema = z2.union([z2.number(), lengthSchema]);
158
- var coreStyleShape = {
159
- // -----------------------------------------------------------------------
160
- // Layout — Dynamic
161
- // -----------------------------------------------------------------------
162
- display: dynamicSchema(displayValueSchema).optional(),
163
- flexDirection: dynamicSchema(flexDirectionValueSchema).optional(),
164
- justifyContent: dynamicSchema(justifyContentValueSchema).optional(),
165
- alignItems: dynamicSchema(alignItemsValueSchema).optional(),
166
- alignSelf: dynamicSchema(alignSelfValueSchema).optional(),
167
- flexWrap: dynamicSchema(flexWrapValueSchema).optional(),
168
- flex: dynamicSchema(z2.number()).optional(),
169
- gap: dynamicSchema(lengthSchema).optional(),
170
- // -----------------------------------------------------------------------
171
- // Sizing — Dynamic
172
- // -----------------------------------------------------------------------
173
- width: dynamicSchema(sizeValueSchema).optional(),
174
- height: dynamicSchema(sizeValueSchema).optional(),
175
- minWidth: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
176
- maxWidth: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
177
- minHeight: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
178
- maxHeight: dynamicSchema(z2.union([lengthSchema, percentageSchema])).optional(),
179
- // -----------------------------------------------------------------------
180
- // Spacing — Dynamic
181
- // -----------------------------------------------------------------------
182
- padding: dynamicSchema(lengthSchema).optional(),
183
- paddingTop: dynamicSchema(lengthSchema).optional(),
184
- paddingRight: dynamicSchema(lengthSchema).optional(),
185
- paddingBottom: dynamicSchema(lengthSchema).optional(),
186
- paddingLeft: dynamicSchema(lengthSchema).optional(),
187
- margin: dynamicSchema(lengthSchema).optional(),
188
- marginTop: dynamicSchema(lengthSchema).optional(),
189
- marginRight: dynamicSchema(lengthSchema).optional(),
190
- marginBottom: dynamicSchema(lengthSchema).optional(),
191
- marginLeft: dynamicSchema(lengthSchema).optional(),
192
- // -----------------------------------------------------------------------
193
- // Colors — Dynamic
194
- // -----------------------------------------------------------------------
195
- backgroundColor: dynamicSchema(colorSchema).optional(),
196
- color: dynamicSchema(colorSchema).optional(),
197
- // -----------------------------------------------------------------------
198
- // Border radius — Dynamic
199
- // -----------------------------------------------------------------------
200
- borderRadius: dynamicSchema(lengthSchema).optional(),
201
- borderRadiusTopLeft: dynamicSchema(lengthSchema).optional(),
202
- borderRadiusTopRight: dynamicSchema(lengthSchema).optional(),
203
- borderRadiusBottomLeft: dynamicSchema(lengthSchema).optional(),
204
- borderRadiusBottomRight: dynamicSchema(lengthSchema).optional(),
205
- // -----------------------------------------------------------------------
206
- // Typography — Dynamic
207
- // -----------------------------------------------------------------------
208
- fontSize: dynamicSchema(lengthSchema).optional(),
209
- fontWeight: dynamicSchema(fontWeightValueSchema).optional(),
210
- fontStyle: dynamicSchema(fontStyleValueSchema).optional(),
211
- textAlign: dynamicSchema(textAlignValueSchema).optional(),
212
- textDecoration: dynamicSchema(textDecorationValueSchema).optional(),
213
- lineHeight: dynamicSchema(lineHeightValueSchema).optional(),
214
- letterSpacing: dynamicSchema(lengthSchema).optional(),
215
- // -----------------------------------------------------------------------
216
- // Opacity — Dynamic
217
- // -----------------------------------------------------------------------
218
- opacity: dynamicSchema(z2.number()).optional(),
219
- // -----------------------------------------------------------------------
220
- // Gradient — Static only
221
- // -----------------------------------------------------------------------
222
- backgroundGradient: gradientObjectSchema.optional(),
223
- // -----------------------------------------------------------------------
224
- // Shadow — Static only (single or array of shadows)
225
- // -----------------------------------------------------------------------
226
- boxShadow: z2.union([shadowObjectSchema, z2.array(shadowObjectSchema)]).optional(),
227
- // -----------------------------------------------------------------------
228
- // Borders — Static only
229
- // -----------------------------------------------------------------------
230
- border: borderObjectSchema.optional(),
231
- borderTop: borderObjectSchema.optional(),
232
- borderRight: borderObjectSchema.optional(),
233
- borderBottom: borderObjectSchema.optional(),
234
- borderLeft: borderObjectSchema.optional(),
235
- // -----------------------------------------------------------------------
236
- // Transform — Static only (skew excluded)
237
- // -----------------------------------------------------------------------
238
- transform: transformObjectSchema.optional(),
239
- // -----------------------------------------------------------------------
240
- // Overflow — Static only
241
- // -----------------------------------------------------------------------
242
- overflow: overflowValueSchema.optional(),
243
- // -----------------------------------------------------------------------
244
- // Position — Static only
245
- // -----------------------------------------------------------------------
246
- position: positionValueSchema.optional(),
247
- top: lengthSchema.optional(),
248
- right: lengthSchema.optional(),
249
- bottom: lengthSchema.optional(),
250
- left: lengthSchema.optional(),
251
- // -----------------------------------------------------------------------
252
- // Object-fit — Dynamic (for Image nodes)
253
- // -----------------------------------------------------------------------
254
- objectFit: dynamicSchema(z2.enum(["cover", "contain", "fill", "none", "scale-down"])).optional(),
255
- objectPosition: dynamicSchema(z2.string()).optional(),
256
- // -----------------------------------------------------------------------
257
- // Grid — Dynamic
258
- // -----------------------------------------------------------------------
259
- gridTemplateColumns: dynamicSchema(z2.string()).optional(),
260
- gridTemplateRows: dynamicSchema(z2.string()).optional(),
261
- gridColumn: dynamicSchema(z2.string()).optional(),
262
- gridRow: dynamicSchema(z2.string()).optional(),
263
- // -----------------------------------------------------------------------
264
- // z-index — Static only (0-100 enforced at validation layer)
265
- // -----------------------------------------------------------------------
266
- zIndex: z2.number().optional(),
267
- // -----------------------------------------------------------------------
268
- // $style — reference to a named style in card.styles
269
- // -----------------------------------------------------------------------
270
- $style: z2.string().optional()
271
- };
272
- var hoverStylePropsSchema = z2.object({
273
- ...coreStyleShape,
274
- transition: transitionFieldSchema
275
- });
276
- var stylePropsSchema = z2.object({
277
- ...coreStyleShape,
278
- hoverStyle: hoverStylePropsSchema.optional(),
279
- transition: transitionFieldSchema
280
- });
281
-
282
- // src/props.ts
283
- import { z as z3 } from "zod";
284
- var textPropsSchema = z3.object({
285
- content: dynamicSchema(z3.string())
286
- });
287
- var imagePropsSchema = z3.object({
288
- src: refOnlySchema(assetPathSchema),
289
- alt: dynamicSchema(z3.string()).optional()
290
- });
291
- var progressBarPropsSchema = z3.object({
292
- value: dynamicSchema(z3.number()),
293
- max: dynamicSchema(z3.number()),
294
- color: dynamicSchema(colorSchema).optional()
295
- });
296
- var avatarPropsSchema = z3.object({
297
- src: refOnlySchema(assetPathSchema),
298
- size: dynamicSchema(lengthSchema).optional()
299
- });
300
- var iconPropsSchema = z3.object({
301
- name: dynamicSchema(iconNameSchema),
302
- size: dynamicSchema(lengthSchema).optional(),
303
- color: dynamicSchema(colorSchema).optional()
304
- });
305
- var badgePropsSchema = z3.object({
306
- label: dynamicSchema(z3.string()),
307
- color: dynamicSchema(colorSchema).optional()
308
- });
309
- var chipPropsSchema = z3.object({
310
- label: dynamicSchema(z3.string()),
311
- color: dynamicSchema(colorSchema).optional()
312
- });
313
- var dividerPropsSchema = z3.object({
314
- color: dynamicSchema(colorSchema).optional(),
315
- thickness: dynamicSchema(lengthSchema).optional()
316
- });
317
- var spacerPropsSchema = z3.object({
318
- size: dynamicSchema(lengthSchema).optional()
319
- });
320
- var buttonPropsSchema = z3.object({
321
- label: dynamicSchema(z3.string()),
322
- action: z3.string()
323
- });
324
- var togglePropsSchema = z3.object({
325
- value: dynamicSchema(z3.boolean()),
326
- onToggle: z3.string()
327
- });
328
-
329
- // src/primitives.ts
330
- import { z as z4 } from "zod";
331
- var forLoopSchema = z4.object({
332
- for: z4.string(),
333
- in: z4.string(),
334
- template: z4.lazy(() => ugcNodeSchema)
335
- });
336
- var childrenSchema = z4.union([
337
- z4.array(z4.lazy(() => ugcNodeSchema)),
338
- forLoopSchema
339
- ]);
340
- var baseFields = {
341
- style: stylePropsSchema.optional()
342
- };
343
- var boxNodeSchema = z4.object({
344
- type: z4.literal("Box"),
345
- children: childrenSchema.optional(),
346
- ...baseFields
347
- });
348
- var rowNodeSchema = z4.object({
349
- type: z4.literal("Row"),
350
- children: childrenSchema.optional(),
351
- ...baseFields
352
- });
353
- var columnNodeSchema = z4.object({
354
- type: z4.literal("Column"),
355
- children: childrenSchema.optional(),
356
- ...baseFields
357
- });
358
- var stackNodeSchema = z4.object({
359
- type: z4.literal("Stack"),
360
- children: childrenSchema.optional(),
361
- ...baseFields
362
- });
363
- var gridNodeSchema = z4.object({
364
- type: z4.literal("Grid"),
365
- children: childrenSchema.optional(),
366
- ...baseFields
367
- });
368
- var textNodeSchema = z4.object({
369
- type: z4.literal("Text"),
370
- ...textPropsSchema.shape,
371
- ...baseFields
372
- });
373
- var imageNodeSchema = z4.object({
374
- type: z4.literal("Image"),
375
- ...imagePropsSchema.shape,
376
- ...baseFields
377
- });
378
- var progressBarNodeSchema = z4.object({
379
- type: z4.literal("ProgressBar"),
380
- ...progressBarPropsSchema.shape,
381
- ...baseFields
382
- });
383
- var avatarNodeSchema = z4.object({
384
- type: z4.literal("Avatar"),
385
- ...avatarPropsSchema.shape,
386
- ...baseFields
387
- });
388
- var iconNodeSchema = z4.object({
389
- type: z4.literal("Icon"),
390
- ...iconPropsSchema.shape,
391
- ...baseFields
392
- });
393
- var badgeNodeSchema = z4.object({
394
- type: z4.literal("Badge"),
395
- ...badgePropsSchema.shape,
396
- ...baseFields
397
- });
398
- var chipNodeSchema = z4.object({
399
- type: z4.literal("Chip"),
400
- ...chipPropsSchema.shape,
401
- ...baseFields
402
- });
403
- var dividerNodeSchema = z4.object({
404
- type: z4.literal("Divider"),
405
- ...dividerPropsSchema.shape,
406
- ...baseFields
407
- });
408
- var spacerNodeSchema = z4.object({
409
- type: z4.literal("Spacer"),
410
- ...spacerPropsSchema.shape,
411
- ...baseFields
412
- });
413
- var buttonNodeSchema = z4.object({
414
- type: z4.literal("Button"),
415
- ...buttonPropsSchema.shape,
416
- ...baseFields
417
- });
418
- var toggleNodeSchema = z4.object({
419
- type: z4.literal("Toggle"),
420
- ...togglePropsSchema.shape,
421
- ...baseFields
422
- });
423
- var ugcNodeSchema = z4.lazy(
424
- () => z4.discriminatedUnion("type", [
425
- boxNodeSchema,
426
- rowNodeSchema,
427
- columnNodeSchema,
428
- stackNodeSchema,
429
- gridNodeSchema,
430
- textNodeSchema,
431
- imageNodeSchema,
432
- progressBarNodeSchema,
433
- avatarNodeSchema,
434
- iconNodeSchema,
435
- badgeNodeSchema,
436
- chipNodeSchema,
437
- dividerNodeSchema,
438
- spacerNodeSchema,
439
- buttonNodeSchema,
440
- toggleNodeSchema
441
- ])
442
- );
443
- var phase1NodeSchema = z4.lazy(
444
- () => z4.discriminatedUnion("type", [
445
- boxNodeSchema,
446
- rowNodeSchema,
447
- columnNodeSchema,
448
- textNodeSchema,
449
- imageNodeSchema
450
- ])
451
- );
452
-
453
- // src/card.ts
454
- import { z as z5 } from "zod";
455
- var cardMetaSchema = z5.object({
456
- name: z5.string(),
457
- version: z5.string()
458
- });
459
- var styleNamePattern = /^[A-Za-z][A-Za-z0-9_-]*$/;
460
- var ugcCardSchema = z5.object({
461
- meta: cardMetaSchema,
462
- assets: z5.record(z5.string(), z5.string()).optional(),
463
- state: z5.record(z5.string(), z5.unknown()).optional(),
464
- styles: z5.record(z5.string().regex(styleNamePattern), stylePropsSchema).optional(),
465
- views: z5.record(z5.string(), ugcNodeSchema)
466
- });
467
29
 
468
30
  // src/constants.ts
469
31
  var CARD_JSON_MAX_BYTES = 1e6;
@@ -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,
@@ -785,6 +818,8 @@ export {
785
818
  PROTOTYPE_POLLUTION_SEGMENTS,
786
819
  STYLE_OBJECTS_TOTAL_MAX_BYTES,
787
820
  TEXT_CONTENT_TOTAL_MAX_BYTES,
821
+ TEXT_SHADOW_BLUR_MAX,
822
+ TEXT_SHADOW_MAX_COUNT,
788
823
  TRANSFORM_SCALE_MAX,
789
824
  TRANSFORM_SCALE_MIN,
790
825
  TRANSFORM_TRANSLATE_MAX,
@@ -818,6 +853,7 @@ export {
818
853
  easingValueSchema,
819
854
  flexDirectionValueSchema,
820
855
  flexWrapValueSchema,
856
+ fontFamilyValueSchema,
821
857
  fontStyleValueSchema,
822
858
  fontWeightValueSchema,
823
859
  forLoopSchema,
@@ -845,6 +881,7 @@ export {
845
881
  radialGradientSchema,
846
882
  refOnlySchema,
847
883
  refSchema,
884
+ repeatingLinearGradientSchema,
848
885
  rowNodeSchema,
849
886
  shadowObjectSchema,
850
887
  spacerNodeSchema,
@@ -855,6 +892,7 @@ export {
855
892
  textDecorationValueSchema,
856
893
  textNodeSchema,
857
894
  textPropsSchema,
895
+ textShadowObjectSchema,
858
896
  toggleNodeSchema,
859
897
  togglePropsSchema,
860
898
  transformObjectSchema,