@shoplix-ai/sdui-schema 1.0.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.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/dist/action.d.ts +26 -0
  3. package/dist/action.d.ts.map +1 -0
  4. package/dist/action.js +27 -0
  5. package/dist/action.js.map +1 -0
  6. package/dist/assets.d.ts +80 -0
  7. package/dist/assets.d.ts.map +1 -0
  8. package/dist/assets.js +101 -0
  9. package/dist/assets.js.map +1 -0
  10. package/dist/binding.d.ts +144 -0
  11. package/dist/binding.d.ts.map +1 -0
  12. package/dist/binding.js +80 -0
  13. package/dist/binding.js.map +1 -0
  14. package/dist/block-definition.d.ts +1639 -0
  15. package/dist/block-definition.d.ts.map +1 -0
  16. package/dist/block-definition.js +527 -0
  17. package/dist/block-definition.js.map +1 -0
  18. package/dist/block-type-id.d.ts +15 -0
  19. package/dist/block-type-id.d.ts.map +1 -0
  20. package/dist/block-type-id.js +43 -0
  21. package/dist/block-type-id.js.map +1 -0
  22. package/dist/block-type.d.ts +21 -0
  23. package/dist/block-type.d.ts.map +1 -0
  24. package/dist/block-type.js +24 -0
  25. package/dist/block-type.js.map +1 -0
  26. package/dist/blocks.d.ts +922 -0
  27. package/dist/blocks.d.ts.map +1 -0
  28. package/dist/blocks.js +353 -0
  29. package/dist/blocks.js.map +1 -0
  30. package/dist/definition-validator.d.ts +47 -0
  31. package/dist/definition-validator.d.ts.map +1 -0
  32. package/dist/definition-validator.js +340 -0
  33. package/dist/definition-validator.js.map +1 -0
  34. package/dist/display.d.ts +139 -0
  35. package/dist/display.d.ts.map +1 -0
  36. package/dist/display.js +118 -0
  37. package/dist/display.js.map +1 -0
  38. package/dist/envelope.d.ts +2721 -0
  39. package/dist/envelope.d.ts.map +1 -0
  40. package/dist/envelope.js +116 -0
  41. package/dist/envelope.js.map +1 -0
  42. package/dist/icons.d.ts +10 -0
  43. package/dist/icons.d.ts.map +1 -0
  44. package/dist/icons.js +49 -0
  45. package/dist/icons.js.map +1 -0
  46. package/dist/index.d.ts +38 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +20 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/locale.d.ts +11 -0
  51. package/dist/locale.d.ts.map +1 -0
  52. package/dist/locale.js +15 -0
  53. package/dist/locale.js.map +1 -0
  54. package/dist/manifest.d.ts +28 -0
  55. package/dist/manifest.d.ts.map +1 -0
  56. package/dist/manifest.js +242 -0
  57. package/dist/manifest.js.map +1 -0
  58. package/dist/parse.d.ts +33 -0
  59. package/dist/parse.d.ts.map +1 -0
  60. package/dist/parse.js +61 -0
  61. package/dist/parse.js.map +1 -0
  62. package/dist/path.d.ts +3 -0
  63. package/dist/path.d.ts.map +1 -0
  64. package/dist/path.js +14 -0
  65. package/dist/path.js.map +1 -0
  66. package/dist/primitives.d.ts +1206 -0
  67. package/dist/primitives.d.ts.map +1 -0
  68. package/dist/primitives.js +631 -0
  69. package/dist/primitives.js.map +1 -0
  70. package/dist/props.d.ts +9 -0
  71. package/dist/props.d.ts.map +1 -0
  72. package/dist/props.js +12 -0
  73. package/dist/props.js.map +1 -0
  74. package/dist/screen.d.ts +57 -0
  75. package/dist/screen.d.ts.map +1 -0
  76. package/dist/screen.js +76 -0
  77. package/dist/screen.js.map +1 -0
  78. package/dist/starters/electronics.d.ts +3 -0
  79. package/dist/starters/electronics.d.ts.map +1 -0
  80. package/dist/starters/electronics.js +235 -0
  81. package/dist/starters/electronics.js.map +1 -0
  82. package/dist/starters/fashion.d.ts +3 -0
  83. package/dist/starters/fashion.d.ts.map +1 -0
  84. package/dist/starters/fashion.js +232 -0
  85. package/dist/starters/fashion.js.map +1 -0
  86. package/dist/starters/index.d.ts +5 -0
  87. package/dist/starters/index.d.ts.map +1 -0
  88. package/dist/starters/index.js +10 -0
  89. package/dist/starters/index.js.map +1 -0
  90. package/dist/starters/minimal.d.ts +3 -0
  91. package/dist/starters/minimal.d.ts.map +1 -0
  92. package/dist/starters/minimal.js +232 -0
  93. package/dist/starters/minimal.js.map +1 -0
  94. package/dist/starters/starter-seed.d.ts +17 -0
  95. package/dist/starters/starter-seed.d.ts.map +1 -0
  96. package/dist/starters/starter-seed.js +2 -0
  97. package/dist/starters/starter-seed.js.map +1 -0
  98. package/dist/theme.d.ts +54 -0
  99. package/dist/theme.d.ts.map +1 -0
  100. package/dist/theme.js +68 -0
  101. package/dist/theme.js.map +1 -0
  102. package/dist/tokens.d.ts +115 -0
  103. package/dist/tokens.d.ts.map +1 -0
  104. package/dist/tokens.js +349 -0
  105. package/dist/tokens.js.map +1 -0
  106. package/dist/version.d.ts +11 -0
  107. package/dist/version.d.ts.map +1 -0
  108. package/dist/version.js +10 -0
  109. package/dist/version.js.map +1 -0
  110. package/package.json +50 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAmB,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtF,sDAAsD;AACtD,eAAO,MAAM,eAAe,yIAclB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,eAAO,MAAM,mBAAmB,QAA2B,CAAC;AAC5D,eAAO,MAAM,gBAAgB,aAK1B,CAAC;AAEJ,eAAO,MAAM,iBAAiB,QAAyC,CAAC;AACxE,eAAO,MAAM,cAAc,aAEqC,CAAC;AAEjE,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB;;kBAAuD,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,uEAMnB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAA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AC,MAAM,GAAG,MAAM,CAAC,EAAE,GACjC,aAAa,GAAG,SAAS,CAc3B;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAElE;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAa3F"}
@@ -0,0 +1,631 @@
1
+ import { z } from 'zod';
2
+ import { actionSchema } from './action.js';
3
+ import { ICON_NAMES } from './icons.js';
4
+ import { localeCodeSchema, localizedTextSchema } from './locale.js';
5
+ import { SEMANTIC_TOKENS } from './tokens.js';
6
+ /** The closed vocabulary a Composed Block may use. */
7
+ export const PRIMITIVE_TYPES = [
8
+ 'stack',
9
+ 'row',
10
+ 'grid',
11
+ 'spacer',
12
+ 'divider',
13
+ 'text',
14
+ 'image',
15
+ 'icon',
16
+ 'badge',
17
+ 'button',
18
+ 'repeater',
19
+ 'price',
20
+ 'availability',
21
+ ];
22
+ export const SETTING_KEY_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
23
+ export const settingKeySchema = z
24
+ .string()
25
+ .regex(SETTING_KEY_PATTERN, 'expected a setting key of lowercase letters, digits and underscores');
26
+ export const HEX_COLOR_PATTERN = /^#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
27
+ export const hexColorSchema = z
28
+ .string()
29
+ .regex(HEX_COLOR_PATTERN, 'expected "#rrggbb" or "#rrggbbaa"');
30
+ /** A reference to one of the Shop's semantic token roles, by role name. */
31
+ export const tokenReferenceSchema = z.strictObject({ token: z.string().min(1).max(64) });
32
+ /** The fields of the repeater's current item a text value may read. */
33
+ export const ITEM_TEXT_FIELDS = [
34
+ 'title',
35
+ 'handle',
36
+ 'vendor',
37
+ 'product_type',
38
+ 'description',
39
+ ];
40
+ /** The one field of the current item an image value may read. */
41
+ export const ITEM_IMAGE_FIELD = 'image';
42
+ function valueOf(literal, forms) {
43
+ const variants = [z.strictObject({ literal })];
44
+ if (forms.setting)
45
+ variants.push(z.strictObject({ setting: settingKeySchema }));
46
+ if (forms.token)
47
+ variants.push(tokenReferenceSchema);
48
+ if (forms.item)
49
+ variants.push(z.strictObject({ item: z.enum(forms.item) }));
50
+ return z.union(variants);
51
+ }
52
+ const dimensionValue = valueOf(z.number().min(0).max(1000), { setting: true, token: true });
53
+ const colorValue = valueOf(hexColorSchema, { setting: true, token: true });
54
+ const textValue = valueOf(localizedTextSchema, {
55
+ setting: true,
56
+ token: false,
57
+ item: ITEM_TEXT_FIELDS,
58
+ });
59
+ const booleanValue = valueOf(z.boolean(), { setting: true, token: false });
60
+ const numberValue = valueOf(z.number().positive().max(100), { setting: true, token: false });
61
+ const countValue = valueOf(z.int().min(1).max(24), { setting: true, token: false });
62
+ const assetValue = valueOf(z.uuid(), { setting: true, token: false, item: [ITEM_IMAGE_FIELD] });
63
+ const actionValue = valueOf(actionSchema, { setting: true, token: false });
64
+ const enumValue = (values) => valueOf(z.enum(values), { setting: true, token: false });
65
+ /**
66
+ * "show when" on any node: one member of a closed condition union, never an
67
+ * expression. A node whose condition is false draws nothing, and neither do
68
+ * its children.
69
+ */
70
+ export const SHOW_WHEN_CONDITIONS = [
71
+ 'setting_on',
72
+ 'item_has_image',
73
+ 'item_available',
74
+ 'language_is',
75
+ ];
76
+ export const showWhenSchema = z.discriminatedUnion('condition', [
77
+ z.strictObject({ condition: z.literal('setting_on'), setting: settingKeySchema }),
78
+ z.strictObject({ condition: z.literal('item_has_image') }),
79
+ z.strictObject({ condition: z.literal('item_available') }),
80
+ z.strictObject({ condition: z.literal('language_is'), language: localeCodeSchema }),
81
+ ]);
82
+ /** The two conditions that read the repeater's current item. */
83
+ export function readsItem(condition) {
84
+ return condition.condition === 'item_has_image' || condition.condition === 'item_available';
85
+ }
86
+ export const LAYOUT_ALIGNMENTS = ['start', 'center', 'end', 'stretch'];
87
+ export const TEXT_SIZES = ['sm', 'md', 'lg', 'xl'];
88
+ export const TEXT_WEIGHTS = ['regular', 'medium', 'bold'];
89
+ export const TEXT_ALIGNMENTS = ['start', 'center', 'end'];
90
+ export const IMAGE_SHAPES = ['square', 'rounded', 'circle'];
91
+ /** How many columns a grid lays out; named as text so a select setting can feed it. */
92
+ export const GRID_COLUMNS = ['2', '3'];
93
+ export const BUTTON_STYLES = ['solid', 'outline', 'ghost'];
94
+ const borderSchema = z.strictObject({ width: dimensionValue, color: colorValue });
95
+ /** Padding, gap, alignment, background, radius and border: what every layout Primitive takes. */
96
+ const layoutAttributes = {
97
+ padding: dimensionValue.optional(),
98
+ gap: dimensionValue.optional(),
99
+ width: dimensionValue.optional(),
100
+ align: enumValue(LAYOUT_ALIGNMENTS).optional(),
101
+ background: colorValue.optional(),
102
+ radius: dimensionValue.optional(),
103
+ border: borderSchema.optional(),
104
+ when: showWhenSchema.optional(),
105
+ };
106
+ const textStyleAttributes = {
107
+ size: enumValue(TEXT_SIZES).optional(),
108
+ weight: enumValue(TEXT_WEIGHTS).optional(),
109
+ align: enumValue(TEXT_ALIGNMENTS).optional(),
110
+ color: colorValue.optional(),
111
+ };
112
+ /** A row may run off the side; with snap on, each child settles under the finger. */
113
+ const rowAttributes = {
114
+ ...layoutAttributes,
115
+ scroll: booleanValue.optional(),
116
+ snap: booleanValue.optional(),
117
+ };
118
+ const gridAttributes = {
119
+ ...layoutAttributes,
120
+ columns: enumValue(GRID_COLUMNS).optional(),
121
+ };
122
+ export const spacerPrimitiveSchema = z.strictObject({
123
+ primitive: z.literal('spacer'),
124
+ size: dimensionValue.optional(),
125
+ when: showWhenSchema.optional(),
126
+ });
127
+ /** A hairline across the parent's width; thickness and color, nothing else. */
128
+ export const dividerPrimitiveSchema = z.strictObject({
129
+ primitive: z.literal('divider'),
130
+ thickness: dimensionValue.optional(),
131
+ color: colorValue.optional(),
132
+ when: showWhenSchema.optional(),
133
+ });
134
+ /** One glyph out of the app's icon set, sized and tinted like the text beside it. */
135
+ export const iconPrimitiveSchema = z.strictObject({
136
+ primitive: z.literal('icon'),
137
+ name: enumValue(ICON_NAMES),
138
+ size: dimensionValue.optional(),
139
+ color: colorValue.optional(),
140
+ when: showWhenSchema.optional(),
141
+ });
142
+ /** Text over a background: the small pill a card carries for "new" or "-20%". */
143
+ export const badgePrimitiveSchema = z.strictObject({
144
+ primitive: z.literal('badge'),
145
+ text: textValue,
146
+ ...textStyleAttributes,
147
+ uppercase: booleanValue.optional(),
148
+ background: colorValue.optional(),
149
+ padding: dimensionValue.optional(),
150
+ radius: dimensionValue.optional(),
151
+ when: showWhenSchema.optional(),
152
+ });
153
+ /**
154
+ * A label the buyer taps, dressed from the Shop's tokens, carrying one member
155
+ * of the closed action set. The runtime hands the action to the same router a
156
+ * platform block's action goes through, so a button opens a screen, the cart
157
+ * or a link and nothing else.
158
+ */
159
+ export const buttonPrimitiveSchema = z.strictObject({
160
+ primitive: z.literal('button'),
161
+ label: textValue,
162
+ action: actionValue,
163
+ style: enumValue(BUTTON_STYLES).optional(),
164
+ size: enumValue(TEXT_SIZES).optional(),
165
+ background: colorValue.optional(),
166
+ color: colorValue.optional(),
167
+ padding: dimensionValue.optional(),
168
+ radius: dimensionValue.optional(),
169
+ when: showWhenSchema.optional(),
170
+ });
171
+ export const textPrimitiveSchema = z.strictObject({
172
+ primitive: z.literal('text'),
173
+ text: textValue,
174
+ ...textStyleAttributes,
175
+ uppercase: booleanValue.optional(),
176
+ when: showWhenSchema.optional(),
177
+ });
178
+ export const imagePrimitiveSchema = z.strictObject({
179
+ primitive: z.literal('image'),
180
+ asset: assetValue,
181
+ shape: enumValue(IMAGE_SHAPES).optional(),
182
+ aspectRatio: numberValue.optional(),
183
+ when: showWhenSchema.optional(),
184
+ });
185
+ /**
186
+ * The current item's price as the Provider formatted it, in the buyer's
187
+ * country and language. The compare-at price rides alongside when the item
188
+ * carries one and the body asks for it.
189
+ */
190
+ export const pricePrimitiveSchema = z.strictObject({
191
+ primitive: z.literal('price'),
192
+ ...textStyleAttributes,
193
+ compareAt: booleanValue.optional(),
194
+ compareAtColor: colorValue.optional(),
195
+ when: showWhenSchema.optional(),
196
+ });
197
+ /**
198
+ * The current item's availability as a label the definition supplies in
199
+ * every language; the runtime picks which of the two to draw.
200
+ */
201
+ export const availabilityPrimitiveSchema = z.strictObject({
202
+ primitive: z.literal('availability'),
203
+ inStock: textValue,
204
+ soldOut: textValue,
205
+ ...textStyleAttributes,
206
+ soldOutColor: colorValue.optional(),
207
+ when: showWhenSchema.optional(),
208
+ });
209
+ const repeaterAttributes = {
210
+ limit: countValue.optional(),
211
+ when: showWhenSchema.optional(),
212
+ };
213
+ const stackPrimitiveSchema = z.lazy(() => z.strictObject({
214
+ primitive: z.literal('stack'),
215
+ ...layoutAttributes,
216
+ children: z.array(primitiveNodeSchema),
217
+ }));
218
+ const rowPrimitiveSchema = z.lazy(() => z.strictObject({
219
+ primitive: z.literal('row'),
220
+ ...rowAttributes,
221
+ children: z.array(primitiveNodeSchema),
222
+ }));
223
+ const gridPrimitiveSchema = z.lazy(() => z.strictObject({
224
+ primitive: z.literal('grid'),
225
+ ...gridAttributes,
226
+ children: z.array(primitiveNodeSchema),
227
+ }));
228
+ const repeaterPrimitiveSchema = z.lazy(() => z.strictObject({
229
+ primitive: z.literal('repeater'),
230
+ ...repeaterAttributes,
231
+ children: z.array(primitiveNodeSchema),
232
+ empty: z.array(primitiveNodeSchema).optional(),
233
+ }));
234
+ /**
235
+ * Discriminated on the `primitive` tag so later vocabulary is one more member,
236
+ * never a rewrite. A tag outside the vocabulary is refused at parse.
237
+ */
238
+ export const primitiveNodeSchema = z.lazy(() => z.discriminatedUnion('primitive', [
239
+ stackPrimitiveSchema,
240
+ rowPrimitiveSchema,
241
+ gridPrimitiveSchema,
242
+ repeaterPrimitiveSchema,
243
+ spacerPrimitiveSchema,
244
+ dividerPrimitiveSchema,
245
+ textPrimitiveSchema,
246
+ imagePrimitiveSchema,
247
+ iconPrimitiveSchema,
248
+ badgePrimitiveSchema,
249
+ buttonPrimitiveSchema,
250
+ pricePrimitiveSchema,
251
+ availabilityPrimitiveSchema,
252
+ ]));
253
+ const KNOWN_PRIMITIVES = new Set(PRIMITIVE_TYPES);
254
+ const envelopeChildrenSchema = z.lazy(() => z.array(envelopePrimitiveNodeSchema));
255
+ const envelopeStackPrimitiveSchema = z.strictObject({
256
+ primitive: z.literal('stack'),
257
+ ...layoutAttributes,
258
+ children: envelopeChildrenSchema,
259
+ });
260
+ const envelopeRowPrimitiveSchema = z.strictObject({
261
+ primitive: z.literal('row'),
262
+ ...rowAttributes,
263
+ children: envelopeChildrenSchema,
264
+ });
265
+ const envelopeGridPrimitiveSchema = z.strictObject({
266
+ primitive: z.literal('grid'),
267
+ ...gridAttributes,
268
+ children: envelopeChildrenSchema,
269
+ });
270
+ const envelopeRepeaterPrimitiveSchema = z.strictObject({
271
+ primitive: z.literal('repeater'),
272
+ ...repeaterAttributes,
273
+ children: envelopeChildrenSchema,
274
+ empty: envelopeChildrenSchema.optional(),
275
+ });
276
+ const unlistedPrimitiveNodeSchema = z.looseObject({ primitive: z.string().min(1).max(64) });
277
+ const ENVELOPE_NODE_SCHEMAS = {
278
+ stack: envelopeStackPrimitiveSchema,
279
+ row: envelopeRowPrimitiveSchema,
280
+ grid: envelopeGridPrimitiveSchema,
281
+ repeater: envelopeRepeaterPrimitiveSchema,
282
+ spacer: spacerPrimitiveSchema,
283
+ divider: dividerPrimitiveSchema,
284
+ text: textPrimitiveSchema,
285
+ image: imagePrimitiveSchema,
286
+ icon: iconPrimitiveSchema,
287
+ badge: badgePrimitiveSchema,
288
+ button: buttonPrimitiveSchema,
289
+ price: pricePrimitiveSchema,
290
+ availability: availabilityPrimitiveSchema,
291
+ };
292
+ /**
293
+ * Known tags parse strictly; an unknown tag falls back to the tolerant shape.
294
+ * A malformed known node never slips through as unknown.
295
+ */
296
+ export const envelopePrimitiveNodeSchema = z
297
+ .unknown()
298
+ .transform((value, ctx) => {
299
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
300
+ ctx.addIssue({ code: 'custom', message: 'expected a Primitive node' });
301
+ return z.NEVER;
302
+ }
303
+ const tag = value.primitive;
304
+ const schema = typeof tag === 'string' && KNOWN_PRIMITIVES.has(tag)
305
+ ? ENVELOPE_NODE_SCHEMAS[tag]
306
+ : unlistedPrimitiveNodeSchema;
307
+ const parsed = schema.safeParse(value);
308
+ if (!parsed.success) {
309
+ for (const issue of parsed.error.issues) {
310
+ ctx.addIssue({ code: 'custom', message: issue.message, path: [...issue.path] });
311
+ }
312
+ return z.NEVER;
313
+ }
314
+ return parsed.data;
315
+ });
316
+ export function isListedPrimitive(tag) {
317
+ return KNOWN_PRIMITIVES.has(tag);
318
+ }
319
+ /** The two slots a node holds other nodes in; both walk the same way. */
320
+ const CHILD_SLOTS = ['children', 'empty'];
321
+ /** Which slots each Primitive holds other nodes in; a leaf holds none. */
322
+ export const PRIMITIVE_CHILD_SLOTS = {
323
+ stack: ['children'],
324
+ row: ['children'],
325
+ grid: ['children'],
326
+ repeater: ['children', 'empty'],
327
+ spacer: [],
328
+ divider: [],
329
+ text: [],
330
+ image: [],
331
+ icon: [],
332
+ badge: [],
333
+ button: [],
334
+ price: [],
335
+ availability: [],
336
+ };
337
+ function childNodesOf(node) {
338
+ const found = [];
339
+ for (const slot of CHILD_SLOTS) {
340
+ const nodes = node[slot];
341
+ if (Array.isArray(nodes)) {
342
+ nodes.forEach((child, index) => found.push({ slot, index, node: child }));
343
+ }
344
+ }
345
+ return found;
346
+ }
347
+ /**
348
+ * Every node whose tag is outside the vocabulary, walked over the raw body
349
+ * before any parse so the refusal can name the tag and where it sits.
350
+ */
351
+ export function unknownPrimitivesOf(body) {
352
+ const found = [];
353
+ const walk = (node, path) => {
354
+ if (typeof node !== 'object' || node === null || Array.isArray(node))
355
+ return;
356
+ const tag = node.primitive;
357
+ if (typeof tag === 'string' && !KNOWN_PRIMITIVES.has(tag)) {
358
+ found.push({ path, primitive: tag });
359
+ }
360
+ for (const child of childNodesOf(node)) {
361
+ walk(child.node, [...path, child.slot, child.index]);
362
+ }
363
+ };
364
+ walk(body, []);
365
+ return found;
366
+ }
367
+ const SLOT_OF = {
368
+ padding: 'dimension',
369
+ gap: 'dimension',
370
+ radius: 'dimension',
371
+ size: 'dimension',
372
+ width: 'dimension',
373
+ thickness: 'dimension',
374
+ background: 'color',
375
+ color: 'color',
376
+ compareAtColor: 'color',
377
+ soldOutColor: 'color',
378
+ text: 'text',
379
+ label: 'text',
380
+ inStock: 'text',
381
+ soldOut: 'text',
382
+ uppercase: 'boolean',
383
+ compareAt: 'boolean',
384
+ scroll: 'boolean',
385
+ snap: 'boolean',
386
+ align: 'enum',
387
+ weight: 'enum',
388
+ shape: 'enum',
389
+ columns: 'enum',
390
+ style: 'enum',
391
+ name: 'enum',
392
+ aspectRatio: 'number',
393
+ limit: 'count',
394
+ asset: 'asset',
395
+ action: 'action',
396
+ };
397
+ /** The Primitives styled like text; their `size` and `align` are the text ones. */
398
+ const TEXT_STYLED = new Set([
399
+ 'text',
400
+ 'price',
401
+ 'availability',
402
+ 'badge',
403
+ 'button',
404
+ ]);
405
+ /** The text Primitive's `size` is an enum; the spacer's is a dimension. */
406
+ function slotFor(node, attribute) {
407
+ if (attribute === 'size' && TEXT_STYLED.has(node.primitive))
408
+ return 'enum';
409
+ return SLOT_OF[attribute] ?? 'enum';
410
+ }
411
+ function isReference(value) {
412
+ if (typeof value !== 'object' || value === null)
413
+ return false;
414
+ return 'setting' in value || 'token' in value;
415
+ }
416
+ function itemFieldOf(value) {
417
+ if (typeof value !== 'object' || value === null || !('item' in value))
418
+ return undefined;
419
+ const field = value.item;
420
+ return typeof field === 'string' ? field : undefined;
421
+ }
422
+ /**
423
+ * One pass over the body, carrying whether a repeater stands above each node.
424
+ * A repeater's `empty` slot is outside its own item scope: there is no
425
+ * current item when the Binding resolved to nothing.
426
+ */
427
+ function walkBody(body, visit) {
428
+ const walk = (node, state) => {
429
+ visit(node, state);
430
+ const under = state.underRepeater || node.primitive === 'repeater';
431
+ const item = state.inRepeater || node.primitive === 'repeater';
432
+ for (const child of childNodesOf(node)) {
433
+ walk(child.node, {
434
+ path: [...state.path, child.slot, child.index],
435
+ inRepeater: child.slot === 'empty' ? false : item,
436
+ underRepeater: under,
437
+ });
438
+ }
439
+ };
440
+ walk(body, { path: [], inRepeater: false, underRepeater: false });
441
+ }
442
+ /** Every setting and token the body reads, with the slot each feeds. */
443
+ export function composedBodyReferences(body) {
444
+ const found = [];
445
+ walkBody(body, (node, position) => {
446
+ for (const [attribute, value] of Object.entries(node)) {
447
+ if (attribute === 'primitive' || attribute === 'when')
448
+ continue;
449
+ if (CHILD_SLOTS.includes(attribute))
450
+ continue;
451
+ if (attribute === 'border' && typeof value === 'object' && value !== null) {
452
+ for (const [part, partValue] of Object.entries(value)) {
453
+ if (isReference(partValue)) {
454
+ found.push({
455
+ path: [...position.path, 'border', part],
456
+ inRepeater: position.inRepeater,
457
+ reference: partValue,
458
+ slot: slotFor(node, part),
459
+ });
460
+ }
461
+ }
462
+ continue;
463
+ }
464
+ if (isReference(value)) {
465
+ found.push({
466
+ path: [...position.path, attribute],
467
+ inRepeater: position.inRepeater,
468
+ reference: value,
469
+ slot: slotFor(node, attribute),
470
+ });
471
+ }
472
+ }
473
+ });
474
+ return found;
475
+ }
476
+ /**
477
+ * Every place the body reads the repeater's current item: a value naming one
478
+ * of its fields, a commerce leaf, or a condition asking about it.
479
+ */
480
+ export function composedBodyItemUses(body) {
481
+ const found = [];
482
+ walkBody(body, (node, position) => {
483
+ if (node.primitive === 'price' || node.primitive === 'availability') {
484
+ found.push({
485
+ path: position.path,
486
+ inRepeater: position.inRepeater,
487
+ use: `the ${node.primitive} Primitive`,
488
+ });
489
+ }
490
+ if (node.when !== undefined && readsItem(node.when)) {
491
+ found.push({
492
+ path: [...position.path, 'when'],
493
+ inRepeater: position.inRepeater,
494
+ use: `the "${node.when.condition}" condition`,
495
+ });
496
+ }
497
+ for (const [attribute, value] of Object.entries(node)) {
498
+ if (attribute === 'when')
499
+ continue;
500
+ const field = itemFieldOf(value);
501
+ if (field !== undefined) {
502
+ found.push({
503
+ path: [...position.path, attribute],
504
+ inRepeater: position.inRepeater,
505
+ use: `the item's "${field}"`,
506
+ });
507
+ }
508
+ }
509
+ });
510
+ return found;
511
+ }
512
+ /** Every "show when" the body carries, with where it sits. */
513
+ export function composedBodyConditions(body) {
514
+ const found = [];
515
+ walkBody(body, (node, position) => {
516
+ if (node.when === undefined)
517
+ return;
518
+ found.push({
519
+ path: [...position.path, 'when'],
520
+ inRepeater: position.inRepeater,
521
+ condition: node.when,
522
+ });
523
+ });
524
+ return found;
525
+ }
526
+ /** Every repeater the body carries; `nested` marks one standing inside another. */
527
+ export function composedBodyRepeaters(body) {
528
+ const found = [];
529
+ walkBody(body, (node, state) => {
530
+ if (node.primitive !== 'repeater')
531
+ return;
532
+ found.push({
533
+ path: state.path,
534
+ inRepeater: state.inRepeater,
535
+ nested: state.underRepeater,
536
+ });
537
+ });
538
+ return found;
539
+ }
540
+ /** The options an enum slot accepts, for a select setting bound to it. */
541
+ export function enumSlotValues(node, attribute) {
542
+ const textStyled = TEXT_STYLED.has(node.primitive);
543
+ if (attribute === 'align')
544
+ return textStyled ? TEXT_ALIGNMENTS : LAYOUT_ALIGNMENTS;
545
+ if (attribute === 'weight')
546
+ return TEXT_WEIGHTS;
547
+ if (attribute === 'shape')
548
+ return IMAGE_SHAPES;
549
+ if (attribute === 'columns')
550
+ return GRID_COLUMNS;
551
+ if (attribute === 'style')
552
+ return BUTTON_STYLES;
553
+ if (attribute === 'name')
554
+ return ICON_NAMES;
555
+ if (attribute === 'size' && textStyled)
556
+ return TEXT_SIZES;
557
+ return null;
558
+ }
559
+ /** Every asset the body names outright, with the path of the attribute naming it. */
560
+ export function composedBodyAssetReferences(body) {
561
+ const found = [];
562
+ const walk = (node, path) => {
563
+ if (typeof node !== 'object' || node === null || Array.isArray(node))
564
+ return;
565
+ const asset = node.asset;
566
+ if (typeof asset === 'object' && asset !== null && 'literal' in asset) {
567
+ const id = asset.literal;
568
+ if (typeof id === 'string')
569
+ found.push({ assetId: id, path: [...path, 'asset'] });
570
+ }
571
+ for (const child of childNodesOf(node))
572
+ walk(child.node, [...path, child.slot, child.index]);
573
+ };
574
+ walk(body, []);
575
+ return found;
576
+ }
577
+ export function composedBodyAssetIds(body) {
578
+ return composedBodyAssetReferences(body).map((reference) => reference.assetId);
579
+ }
580
+ export function composedBodyShape(body) {
581
+ let nodes = 0;
582
+ let depth = 0;
583
+ const walk = (node, level) => {
584
+ nodes += 1;
585
+ if (level > depth)
586
+ depth = level;
587
+ for (const child of childNodesOf(node))
588
+ walk(child.node, level + 1);
589
+ };
590
+ walk(body, 1);
591
+ return { nodes, depth };
592
+ }
593
+ /** The node at a body path, for a caller holding a reference's path. */
594
+ export function nodeAtBodyPath(body, path) {
595
+ let node = body;
596
+ for (let i = 0; i < path.length; i += 1) {
597
+ const slot = path[i];
598
+ if (typeof slot !== 'string' || !CHILD_SLOTS.includes(slot))
599
+ break;
600
+ const index = path[i + 1];
601
+ const children = node[slot];
602
+ if (typeof index !== 'number' || !Array.isArray(children))
603
+ return undefined;
604
+ const child = children[index];
605
+ if (child === undefined)
606
+ return undefined;
607
+ node = child;
608
+ i += 1;
609
+ }
610
+ return node;
611
+ }
612
+ export function isTokenRole(role) {
613
+ return Object.prototype.hasOwnProperty.call(SEMANTIC_TOKENS, role);
614
+ }
615
+ /** One role's value off a resolved theme style; undefined for a role that is not one. */
616
+ export function tokenRoleValue(style, role) {
617
+ if (!isTokenRole(role))
618
+ return undefined;
619
+ switch (role) {
620
+ case 'heading':
621
+ case 'body':
622
+ return style.fonts[role];
623
+ case 'radius':
624
+ return style.radius;
625
+ case 'spacing':
626
+ return style.spacing;
627
+ default:
628
+ return style.colors[role];
629
+ }
630
+ }
631
+ //# sourceMappingURL=primitives.js.map