@tanqory/theme-kit 0.1.0 → 2.0.0-alpha.17

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 (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -10
  3. package/dist/abi/canvas-live.d.ts +67 -0
  4. package/dist/abi/canvas-live.js +154 -0
  5. package/dist/abi/cart.d.ts +59 -0
  6. package/dist/abi/cart.js +387 -0
  7. package/dist/abi/convert.d.ts +344 -0
  8. package/dist/abi/convert.js +1278 -0
  9. package/dist/abi/data-api.d.ts +15 -0
  10. package/dist/abi/data-api.js +209 -0
  11. package/dist/abi/jcs.d.ts +6 -0
  12. package/dist/abi/jcs.js +28 -0
  13. package/dist/abi/labels.d.ts +3 -0
  14. package/dist/abi/labels.js +34 -0
  15. package/dist/abi/page-data.d.ts +256 -0
  16. package/dist/abi/page-data.js +678 -0
  17. package/dist/abi/page.d.ts +28 -0
  18. package/dist/abi/page.js +57 -0
  19. package/dist/abi/referrals.d.ts +23 -0
  20. package/dist/abi/referrals.js +89 -0
  21. package/dist/abi/rewards.d.ts +27 -0
  22. package/dist/abi/rewards.js +82 -0
  23. package/dist/abi/seo.d.ts +47 -0
  24. package/dist/abi/seo.js +68 -0
  25. package/dist/abi/shell.d.ts +23 -0
  26. package/dist/abi/shell.js +10 -0
  27. package/dist/abi/state-pack.d.ts +17 -0
  28. package/dist/abi/state-pack.js +43 -0
  29. package/dist/abi/wire.d.ts +38 -0
  30. package/dist/abi/wire.js +84 -0
  31. package/dist/build.d.ts +116 -0
  32. package/dist/build.js +310 -0
  33. package/dist/client.d.ts +19 -0
  34. package/dist/client.js +87 -0
  35. package/dist/contract.d.ts +6 -0
  36. package/dist/contract.js +6 -0
  37. package/dist/headless/ai.d.ts +132 -0
  38. package/dist/headless/ai.js +99 -0
  39. package/dist/headless/hooks.d.ts +276 -0
  40. package/dist/headless/hooks.js +540 -0
  41. package/dist/headless/i18n.d.ts +13 -0
  42. package/dist/headless/i18n.js +45 -0
  43. package/dist/headless/index.d.ts +37 -0
  44. package/dist/headless/index.js +38 -0
  45. package/dist/headless/money.d.ts +25 -0
  46. package/dist/headless/money.js +61 -0
  47. package/dist/headless/page.d.ts +43 -0
  48. package/dist/headless/page.js +53 -0
  49. package/dist/headless/platform.d.ts +55 -0
  50. package/dist/headless/platform.js +77 -0
  51. package/dist/headless/primitives/cart.d.ts +90 -0
  52. package/dist/headless/primitives/cart.js +153 -0
  53. package/dist/headless/primitives/collection.d.ts +68 -0
  54. package/dist/headless/primitives/collection.js +80 -0
  55. package/dist/headless/primitives/product.d.ts +101 -0
  56. package/dist/headless/primitives/product.js +117 -0
  57. package/dist/headless/primitives/storefront.d.ts +106 -0
  58. package/dist/headless/primitives/storefront.js +186 -0
  59. package/dist/headless/primitives/util.d.ts +19 -0
  60. package/dist/headless/primitives/util.js +42 -0
  61. package/dist/headless/strings.d.ts +9 -0
  62. package/dist/headless/strings.js +190 -0
  63. package/dist/headless/structured-data.d.ts +31 -0
  64. package/dist/headless/structured-data.js +57 -0
  65. package/dist/headless/theme.d.ts +99 -0
  66. package/dist/headless/theme.js +54 -0
  67. package/dist/index.d.ts +20 -0
  68. package/dist/index.js +18 -553
  69. package/dist/runtime/data/StoreProvider.d.ts +84 -0
  70. package/dist/runtime/data/StoreProvider.js +373 -0
  71. package/dist/runtime/data/handle.d.ts +14 -0
  72. package/dist/runtime/data/handle.js +16 -0
  73. package/dist/runtime/data/routes.d.ts +87 -0
  74. package/dist/runtime/data/routes.js +158 -0
  75. package/dist/runtime/data/to-ui.d.ts +281 -0
  76. package/dist/runtime/data/to-ui.js +977 -0
  77. package/dist/runtime/entries/register.d.ts +9 -0
  78. package/dist/runtime/entries/register.js +9 -0
  79. package/dist/runtime/entries/sections.d.ts +16 -0
  80. package/dist/runtime/entries/sections.js +19 -0
  81. package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
  82. package/dist/runtime/kit/SectionTree.js +100 -0
  83. package/dist/runtime/kit/analytics.d.ts +63 -0
  84. package/dist/runtime/kit/analytics.js +250 -0
  85. package/dist/runtime/kit/cart.d.ts +215 -0
  86. package/dist/runtime/kit/cart.js +545 -0
  87. package/dist/{types → runtime/kit}/composition.d.ts +1 -1
  88. package/dist/runtime/kit/composition.js +3 -0
  89. package/dist/{types → runtime/kit}/config.d.ts +2 -2
  90. package/dist/runtime/kit/config.js +6 -0
  91. package/dist/runtime/kit/consent.d.ts +29 -0
  92. package/dist/runtime/kit/consent.js +159 -0
  93. package/dist/runtime/kit/contract/content.d.ts +199 -0
  94. package/dist/runtime/kit/contract/content.js +106 -0
  95. package/dist/runtime/kit/contract/field-types.d.ts +337 -0
  96. package/dist/runtime/kit/contract/field-types.js +206 -0
  97. package/dist/runtime/kit/contract/groups.d.ts +230 -0
  98. package/dist/runtime/kit/contract/groups.js +402 -0
  99. package/dist/runtime/kit/contract/index.d.ts +33 -0
  100. package/dist/runtime/kit/contract/index.js +33 -0
  101. package/dist/runtime/kit/contract/transform.d.ts +82 -0
  102. package/dist/runtime/kit/contract/transform.js +133 -0
  103. package/dist/runtime/kit/contract/validate.d.ts +75 -0
  104. package/dist/runtime/kit/contract/validate.js +480 -0
  105. package/dist/runtime/kit/data.d.ts +720 -0
  106. package/dist/runtime/kit/data.js +1117 -0
  107. package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
  108. package/dist/runtime/kit/defineSection.js +10 -0
  109. package/dist/{types → runtime/kit}/dynamic-source.d.ts +40 -18
  110. package/dist/runtime/kit/dynamic-source.js +294 -0
  111. package/dist/runtime/kit/index.d.ts +24 -0
  112. package/dist/runtime/kit/index.js +24 -0
  113. package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
  114. package/dist/runtime/kit/jsx-to-json.js +28 -0
  115. package/dist/{types → runtime/kit}/mount.d.ts +25 -4
  116. package/dist/runtime/kit/mount.js +124 -0
  117. package/dist/{types → runtime/kit}/registry.d.ts +1 -1
  118. package/dist/runtime/kit/registry.js +12 -0
  119. package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
  120. package/dist/runtime/kit/ssg.js +56 -0
  121. package/dist/runtime/kit/storefront.d.ts +639 -0
  122. package/dist/runtime/kit/storefront.js +723 -0
  123. package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
  124. package/dist/runtime/kit/theme-context.js +25 -0
  125. package/dist/runtime/kit/types.d.ts +147 -0
  126. package/dist/runtime/kit/types.js +1 -0
  127. package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
  128. package/dist/runtime/platform/TrackingPixels.js +63 -0
  129. package/dist/runtime/platform/environment.d.ts +68 -0
  130. package/dist/runtime/platform/environment.js +85 -0
  131. package/dist/runtime/platform/locale.d.ts +27 -0
  132. package/dist/runtime/platform/locale.js +42 -0
  133. package/dist/runtime/platform/route-analytics.d.ts +15 -0
  134. package/dist/runtime/platform/route-analytics.js +72 -0
  135. package/dist/runtime/platform/safe-href.d.ts +25 -0
  136. package/dist/runtime/platform/safe-href.js +69 -0
  137. package/dist/runtime/platform/safe-values.d.ts +37 -0
  138. package/dist/runtime/platform/safe-values.js +140 -0
  139. package/dist/runtime/render/SectionRenderer.d.ts +4 -0
  140. package/dist/runtime/render/SectionRenderer.js +166 -0
  141. package/dist/runtime/render/listing-query.d.ts +52 -0
  142. package/dist/runtime/render/listing-query.js +122 -0
  143. package/dist/runtime/render/localized-copy.d.ts +86 -0
  144. package/dist/runtime/render/localized-copy.js +129 -0
  145. package/dist/runtime/render/product-listing.d.ts +11 -0
  146. package/dist/runtime/render/product-listing.js +243 -0
  147. package/dist/runtime/render/section-actions.d.ts +66 -0
  148. package/dist/runtime/render/section-actions.js +202 -0
  149. package/dist/runtime/render/starter.d.ts +11 -0
  150. package/dist/runtime/render/starter.js +81 -0
  151. package/dist/runtime/seo/head.d.ts +115 -0
  152. package/dist/runtime/seo/head.js +281 -0
  153. package/dist/runtime/seo/structured-data.d.ts +83 -0
  154. package/dist/runtime/seo/structured-data.js +252 -0
  155. package/dist/runtime/shell/PageShell.d.ts +18 -0
  156. package/dist/runtime/shell/PageShell.js +113 -0
  157. package/dist/runtime/shell/RuntimeBridge.d.ts +14 -0
  158. package/dist/runtime/shell/RuntimeBridge.js +93 -0
  159. package/dist/runtime/shell/overlay-state.d.ts +31 -0
  160. package/dist/runtime/shell/overlay-state.js +59 -0
  161. package/dist/runtime/shell/preview-mode.d.ts +2 -0
  162. package/dist/runtime/shell/preview-mode.js +11 -0
  163. package/dist/runtime/shell/spa-router.d.ts +14 -0
  164. package/dist/runtime/shell/spa-router.js +76 -0
  165. package/dist/runtime/shell/url-redirects.d.ts +6 -0
  166. package/dist/runtime/shell/url-redirects.js +37 -0
  167. package/dist/runtime/slots.d.ts +74 -0
  168. package/dist/runtime/slots.js +16 -0
  169. package/dist/runtime.d.ts +34 -0
  170. package/dist/runtime.js +40 -0
  171. package/dist/sdk/app-block.d.ts +29 -0
  172. package/dist/sdk/app-block.js +22 -0
  173. package/dist/sdk/index.d.ts +26 -0
  174. package/dist/sdk/index.js +26 -0
  175. package/dist/sdk/referrals.d.ts +62 -0
  176. package/dist/sdk/referrals.js +20 -0
  177. package/dist/sdk/rewards.d.ts +85 -0
  178. package/dist/sdk/rewards.js +29 -0
  179. package/dist/sdk/runtime-context.d.ts +202 -0
  180. package/dist/sdk/runtime-context.js +73 -0
  181. package/dist/sdk/schema.d.ts +206 -0
  182. package/dist/sdk/schema.js +121 -0
  183. package/dist/sdk/server-render.d.ts +8 -0
  184. package/dist/sdk/server-render.js +12 -0
  185. package/dist/sdk/store-lookup.d.ts +27 -0
  186. package/dist/sdk/store-lookup.js +29 -0
  187. package/dist/sdk/store.d.ts +149 -0
  188. package/dist/sdk/store.js +5 -0
  189. package/dist/sdk/sx.d.ts +40 -0
  190. package/dist/sdk/sx.js +112 -0
  191. package/dist/sdk/theme.d.ts +191 -0
  192. package/dist/sdk/theme.js +10 -0
  193. package/dist/sdk/types.d.ts +757 -0
  194. package/dist/sdk/types.js +7 -0
  195. package/dist/server.d.ts +111 -0
  196. package/dist/server.js +533 -0
  197. package/docs/headless-api.md +220 -0
  198. package/package.json +76 -22
  199. package/dist/index.js.map +0 -1
  200. package/dist/ssg-BZ5FYTw7.js +0 -1802
  201. package/dist/ssg-BZ5FYTw7.js.map +0 -1
  202. package/dist/ssg.js +0 -8
  203. package/dist/ssg.js.map +0 -1
  204. package/dist/types/cart.d.ts +0 -86
  205. package/dist/types/data.d.ts +0 -357
  206. package/dist/types/editor.d.ts +0 -5
  207. package/dist/types/index.d.ts +0 -20
  208. package/dist/types/preview-bridge.d.ts +0 -9
  209. package/dist/types/storefront.d.ts +0 -333
  210. package/dist/types/types.d.ts +0 -44
@@ -0,0 +1,337 @@
1
+ /**
2
+ * THE field-type vocabulary. One hand-edited table; everything else derives.
3
+ *
4
+ * Before this file the vocabulary existed in eight places that disagreed:
5
+ * kit `AttrSpec['type']` (20) · studio-api `ATTR_TYPES` (20) ·
6
+ * studio-app `fields.tsx` switch (35) · studio-app `AI_TYPES` (5) ·
7
+ * ai-api `ALLOWED_FIELD_TYPES` (13) · ai-api section prompt (11) ·
8
+ * ai-api `extractImageKeys` regex (2) · studio-api dynamic-source `compat` (5)
9
+ *
10
+ * The kit's 20 and studio-api's 20 were set-identical — that pair was already
11
+ * right. The generator was the outlier, and it taught the model `image_picker`,
12
+ * which studio-api rewrites to `'text'`, so every AI section that wanted an
13
+ * image shipped a free-text box instead of the media-library picker.
14
+ *
15
+ * `AttrSpec['type']` is `FieldTypeId | FieldTypeAlias`, derived from this table
16
+ * — so the union and the table cannot disagree. Not "a gate catches it": the
17
+ * disagreement is inexpressible.
18
+ */
19
+ /** How the editor renders a control. Consumers assert against this, not the id. */
20
+ export type ControlKind = 'text-input' | 'textarea' | 'rich-text' | 'number-input' | 'slider' | 'color' | 'switch' | 'segmented' | 'select' | 'media-picker' | 'resource-picker' | 'link-picker' | 'color-palette';
21
+ /**
22
+ * The runtime shape a section component receives for this attribute. `palette` = `{ name, color }[]` (the theme's
23
+ * named colours, theme-abi registry 3 B.3).
24
+ */
25
+ export type ValueKind = 'string' | 'number' | 'boolean' | 'string[]' | 'palette';
26
+ export interface FieldTypeDef {
27
+ readonly id: string;
28
+ /**
29
+ * `core` — declarable in `defineSection({ attributes })`.
30
+ * `editorOnly` — the editor can render it from a raw schema block, but the
31
+ * kit has no concept for it, so a theme cannot declare it. Listed here so
32
+ * the gap is recorded rather than rediscovered.
33
+ */
34
+ readonly tier: 'core' | 'editorOnly';
35
+ readonly control: ControlKind;
36
+ readonly value: ValueKind;
37
+ /** Media kind, for `media-picker` controls. */
38
+ readonly media?: 'image' | 'video';
39
+ /** Resource kind, for `resource-picker` controls — what the picker lists. */
40
+ readonly resource?: 'product' | 'collection' | 'page' | 'blog' | 'article' | 'menu';
41
+ /** Constraint keys that are meaningful for THIS type (beyond the universal ones). */
42
+ readonly constraints: readonly string[];
43
+ /** May a merchant bind this to a dynamic source (the ⛁ "Insert dynamic source" UI)? */
44
+ readonly dynamicBindable: boolean;
45
+ /** Which metafield/source types the binding picker should offer. */
46
+ readonly dynamicSourceTypes: readonly string[];
47
+ /** May an AI generator emit this type? (policy, not capability) */
48
+ readonly aiGenerate: boolean;
49
+ readonly doc: string;
50
+ }
51
+ /**
52
+ * The 21 core types (the 20 above, plus `color_palette`). Set-identical to studio-api's `ATTR_TYPES`, which is the
53
+ * gate that actually decides what reaches the settings panel — anything outside
54
+ * it is silently rewritten to `'text'`.
55
+ */
56
+ export declare const FIELD_TYPES: readonly [{
57
+ readonly id: "text";
58
+ readonly tier: "core";
59
+ readonly control: "text-input";
60
+ readonly value: "string";
61
+ readonly constraints: readonly [];
62
+ readonly dynamicBindable: true;
63
+ readonly dynamicSourceTypes: readonly ["single_line_text_field"];
64
+ readonly aiGenerate: true;
65
+ readonly doc: "Single-line text.";
66
+ }, {
67
+ readonly id: "textarea";
68
+ readonly tier: "core";
69
+ readonly control: "textarea";
70
+ readonly value: "string";
71
+ readonly constraints: readonly [];
72
+ readonly dynamicBindable: true;
73
+ readonly dynamicSourceTypes: readonly ["multi_line_text_field"];
74
+ readonly aiGenerate: true;
75
+ readonly doc: "Multi-line plain text. No markup.";
76
+ }, {
77
+ readonly id: "richtext";
78
+ readonly tier: "core";
79
+ readonly control: "rich-text";
80
+ readonly value: "string";
81
+ readonly constraints: readonly [];
82
+ readonly dynamicBindable: true;
83
+ readonly dynamicSourceTypes: readonly ["rich_text_field"];
84
+ readonly aiGenerate: true;
85
+ readonly doc: "Formatted text. Value is sanitised HTML.";
86
+ }, {
87
+ readonly id: "html";
88
+ readonly tier: "core";
89
+ readonly control: "textarea";
90
+ readonly value: "string";
91
+ readonly constraints: readonly [];
92
+ readonly dynamicBindable: false;
93
+ readonly dynamicSourceTypes: readonly [];
94
+ readonly aiGenerate: false;
95
+ readonly doc: "Raw HTML. Author-trusted; never bind to shopper input.";
96
+ }, {
97
+ readonly id: "number";
98
+ readonly tier: "core";
99
+ readonly control: "number-input";
100
+ readonly value: "number";
101
+ readonly constraints: readonly ["min", "max", "step"];
102
+ readonly dynamicBindable: true;
103
+ readonly dynamicSourceTypes: readonly ["number_integer", "number_decimal"];
104
+ readonly aiGenerate: true;
105
+ readonly doc: "Numeric input.";
106
+ }, {
107
+ readonly id: "range";
108
+ readonly tier: "core";
109
+ readonly control: "slider";
110
+ readonly value: "number";
111
+ readonly constraints: readonly ["min", "max", "step", "unit"];
112
+ readonly dynamicBindable: false;
113
+ readonly dynamicSourceTypes: readonly [];
114
+ readonly aiGenerate: true;
115
+ readonly doc: "Slider. Declare min/max/step or it sits on the 0–100 default.";
116
+ }, {
117
+ readonly id: "boolean";
118
+ readonly tier: "core";
119
+ readonly control: "switch";
120
+ readonly value: "boolean";
121
+ readonly constraints: readonly [];
122
+ readonly dynamicBindable: false;
123
+ readonly dynamicSourceTypes: readonly ["boolean"];
124
+ readonly aiGenerate: true;
125
+ readonly doc: "On/off toggle.";
126
+ }, {
127
+ readonly id: "color";
128
+ readonly tier: "core";
129
+ readonly control: "color";
130
+ readonly value: "string";
131
+ readonly constraints: readonly [];
132
+ readonly dynamicBindable: true;
133
+ readonly dynamicSourceTypes: readonly ["color"];
134
+ readonly aiGenerate: true;
135
+ readonly doc: "Colour value (hex).";
136
+ }, {
137
+ readonly id: "select";
138
+ readonly tier: "core";
139
+ readonly control: "select";
140
+ readonly value: "string";
141
+ readonly constraints: readonly ["options"];
142
+ readonly dynamicBindable: false;
143
+ readonly dynamicSourceTypes: readonly [];
144
+ readonly aiGenerate: true;
145
+ readonly doc: "Dropdown. REQUIRES `options: [{value,label}]`.";
146
+ }, {
147
+ readonly id: "radio";
148
+ readonly tier: "core";
149
+ readonly control: "segmented";
150
+ readonly value: "string";
151
+ readonly constraints: readonly ["options"];
152
+ readonly dynamicBindable: false;
153
+ readonly dynamicSourceTypes: readonly [];
154
+ readonly aiGenerate: true;
155
+ readonly doc: "Segmented choice. REQUIRES `options: [{value,label}]`.";
156
+ }, {
157
+ readonly id: "text_alignment";
158
+ readonly tier: "core";
159
+ readonly control: "segmented";
160
+ readonly value: "string";
161
+ readonly constraints: readonly [];
162
+ readonly dynamicBindable: false;
163
+ readonly dynamicSourceTypes: readonly [];
164
+ readonly aiGenerate: true;
165
+ readonly doc: "Left/center/right. The editor supplies the three choices.";
166
+ }, {
167
+ readonly id: "url";
168
+ readonly tier: "core";
169
+ readonly control: "link-picker";
170
+ readonly value: "string";
171
+ readonly constraints: readonly [];
172
+ readonly dynamicBindable: true;
173
+ readonly dynamicSourceTypes: readonly ["url"];
174
+ readonly aiGenerate: true;
175
+ readonly doc: "A link. The editor offers a link picker, not a raw text box.";
176
+ }, {
177
+ readonly id: "image";
178
+ readonly tier: "core";
179
+ readonly control: "media-picker";
180
+ readonly value: "string";
181
+ readonly media: "image";
182
+ readonly constraints: readonly [];
183
+ readonly dynamicBindable: true;
184
+ readonly dynamicSourceTypes: readonly ["file_reference", "image"];
185
+ readonly aiGenerate: true;
186
+ readonly doc: "Media-library picker. Value is a plain URL string, consumed exactly like `url`. NOTE: the legacy spelling `image_picker` is an alias — declaring it downgrades the control to a free-text box.";
187
+ }, {
188
+ readonly id: "video";
189
+ readonly tier: "core";
190
+ readonly control: "media-picker";
191
+ readonly value: "string";
192
+ readonly media: "video";
193
+ readonly constraints: readonly [];
194
+ readonly dynamicBindable: true;
195
+ readonly dynamicSourceTypes: readonly ["file_reference"];
196
+ readonly aiGenerate: true;
197
+ readonly doc: "Media-library picker for a hosted video. For an EXTERNAL video URL use `url` — the editor renders this as a library browser, not a URL input.";
198
+ }, {
199
+ readonly id: "collection";
200
+ readonly tier: "core";
201
+ readonly control: "resource-picker";
202
+ readonly value: "string";
203
+ readonly resource: "collection";
204
+ readonly constraints: readonly [];
205
+ readonly dynamicBindable: true;
206
+ readonly dynamicSourceTypes: readonly ["collection_reference"];
207
+ readonly aiGenerate: true;
208
+ readonly doc: "Collection picker. Value is the collection HANDLE.";
209
+ }, {
210
+ readonly id: "product";
211
+ readonly tier: "core";
212
+ readonly control: "resource-picker";
213
+ readonly value: "string";
214
+ readonly resource: "product";
215
+ readonly constraints: readonly [];
216
+ readonly dynamicBindable: true;
217
+ readonly dynamicSourceTypes: readonly ["product_reference"];
218
+ readonly aiGenerate: true;
219
+ readonly doc: "Product picker. Value is the product HANDLE.";
220
+ }, {
221
+ readonly id: "page";
222
+ readonly tier: "core";
223
+ readonly control: "resource-picker";
224
+ readonly value: "string";
225
+ readonly resource: "page";
226
+ readonly constraints: readonly [];
227
+ readonly dynamicBindable: true;
228
+ readonly dynamicSourceTypes: readonly ["page_reference"];
229
+ readonly aiGenerate: true;
230
+ readonly doc: "Page picker. Value is the page HANDLE.";
231
+ }, {
232
+ readonly id: "blog";
233
+ readonly tier: "core";
234
+ readonly control: "resource-picker";
235
+ readonly value: "string";
236
+ readonly resource: "blog";
237
+ readonly constraints: readonly [];
238
+ readonly dynamicBindable: false;
239
+ readonly dynamicSourceTypes: readonly [];
240
+ readonly aiGenerate: true;
241
+ readonly doc: "Blog picker. Value is the blog HANDLE.";
242
+ }, {
243
+ readonly id: "article";
244
+ readonly tier: "core";
245
+ readonly control: "resource-picker";
246
+ readonly value: "string";
247
+ readonly resource: "article";
248
+ readonly constraints: readonly [];
249
+ readonly dynamicBindable: true;
250
+ readonly dynamicSourceTypes: readonly ["article_reference"];
251
+ readonly aiGenerate: true;
252
+ readonly doc: "Article picker. Value is the article HANDLE.";
253
+ }, {
254
+ readonly id: "menu";
255
+ readonly tier: "core";
256
+ readonly control: "resource-picker";
257
+ readonly value: "string";
258
+ readonly resource: "menu";
259
+ readonly constraints: readonly [];
260
+ readonly dynamicBindable: false;
261
+ readonly dynamicSourceTypes: readonly [];
262
+ readonly aiGenerate: true;
263
+ readonly doc: "Store menu picker (Dashboard → Navigation). Value is the menu HANDLE. `link_list` is an accepted alias.";
264
+ }, {
265
+ readonly id: "color_palette";
266
+ readonly tier: "core";
267
+ readonly control: "color-palette";
268
+ readonly value: "palette";
269
+ readonly constraints: readonly ["max"];
270
+ readonly dynamicBindable: false;
271
+ readonly dynamicSourceTypes: readonly [];
272
+ readonly aiGenerate: true;
273
+ readonly doc: "The theme's named colours: a list of { name, color } (color #rrggbb), at most 20, each name 1 to 30 characters and unique. The editor offers them in every colour picker. Needs field-type registry 3.";
274
+ }];
275
+ /** `color_palette`: the most colours, and the longest name (theme-abi B.3). */
276
+ export declare const PALETTE_MAX_COLOURS = 20;
277
+ export declare const PALETTE_NAME_MAX = 30;
278
+ /**
279
+ * Why a `color_palette` value is not one (`[]` when it is): entries `{ name, color }` only, names trimmed, 1 to 30
280
+ * characters and unique ignoring case, colours `#rrggbb`, at most `max` (never more than 20).
281
+ */
282
+ export declare function paletteValueProblems(value: unknown, max?: number): string[];
283
+ /**
284
+ * Accepted legacy / alternate spellings, normalised to a core id on input.
285
+ *
286
+ * These are not deprecated typos to reject outright — `fields.tsx` renders
287
+ * several of them identically, and models reach for them from other platforms'
288
+ * vocabularies. Accepting and normalising is what stops a silent downgrade to a
289
+ * text box; the validator still reports them so authored source gets corrected.
290
+ */
291
+ export declare const FIELD_TYPE_ALIASES: {
292
+ readonly image_picker: "image";
293
+ readonly link_list: "menu";
294
+ readonly checkbox: "boolean";
295
+ readonly color_background: "color";
296
+ };
297
+ /**
298
+ * Types the editor can render but a theme cannot declare, recorded so the gap
299
+ * is visible rather than rediscovered. Promoting one means adding it to
300
+ * FIELD_TYPES *and* to studio-api's gate in the same change.
301
+ */
302
+ export declare const EDITOR_ONLY_TYPES: readonly ["inline_richtext", "color_scheme", "color_scheme_group", "font_picker", "product_list", "collection_list", "metaobject", "video_url", "header", "paragraph", "article_list", "metaobject_list"];
303
+ export type FieldTypeId = (typeof FIELD_TYPES)[number]['id'];
304
+ export type FieldTypeAlias = keyof typeof FIELD_TYPE_ALIASES;
305
+ export type AnyFieldType = FieldTypeId | FieldTypeAlias;
306
+ /** Resolve an authored type (possibly an alias) to its canonical id, or null. */
307
+ export declare function canonicalFieldType(declared: unknown): FieldTypeId | null;
308
+ /** The definition for a canonical id. */
309
+ export declare function fieldType(id: string): FieldTypeDef | undefined;
310
+ /** Universal constraint keys, meaningful for every type. */
311
+ export declare const UNIVERSAL_CONSTRAINTS: readonly ["default", "label", "info", "placeholder", "group", "dynamic", "visible_if"];
312
+ /**
313
+ * O4 — a setting value connected to a dynamic source (the editor's "Connect dynamic source"): `{ '@source': path }`
314
+ * in place of the literal, resolved by the runtime against the page's resource. The path grammar:
315
+ * `<root>.metafields.<namespace>.<key>`, `<root>.<property>` (root = product | collection | page | article | shop),
316
+ * `metaobject.<field>` (a field of a metaobject page's own entry) or `metaobject:<type>:<handle>.<field>`. Only a field
317
+ * type with `dynamicBindable` may hold one.
318
+ */
319
+ export declare const BOUND_SOURCE_PATTERN: RegExp;
320
+ /**
321
+ * Several sources in one text setting: `{ '@template': 'Made by {{ product.vendor }} in {{ shop.name }}' }`. The
322
+ * text around the tokens is the merchant's own; each `{{ <path> }}` is a path BOUND_SOURCE_PATTERN accepts. At most
323
+ * 50 tokens (the reference platform's limit per setting, REF-help
324
+ * `/en/manual/custom-data/metafields/displaying-metafields-on-your-online-store`, fetched 2026-11-13) and 4,000
325
+ * characters.
326
+ */
327
+ export declare const BOUND_TEMPLATE_TOKEN: RegExp;
328
+ export declare const BOUND_TEMPLATE_MAX_TOKENS = 50;
329
+ /** Text field types that may hold a `{ '@template' }`. */
330
+ export declare const TEMPLATE_BINDABLE_TYPES: readonly string[];
331
+ export declare function isBoundTemplateValue(value: unknown): value is {
332
+ '@template': string;
333
+ };
334
+ /** Exactly `{ '@source': <a path BOUND_SOURCE_PATTERN accepts> }` — no other member. */
335
+ export declare function isBoundSourceValue(value: unknown): value is {
336
+ '@source': string;
337
+ };
@@ -0,0 +1,206 @@
1
+ /**
2
+ * THE field-type vocabulary. One hand-edited table; everything else derives.
3
+ *
4
+ * Before this file the vocabulary existed in eight places that disagreed:
5
+ * kit `AttrSpec['type']` (20) · studio-api `ATTR_TYPES` (20) ·
6
+ * studio-app `fields.tsx` switch (35) · studio-app `AI_TYPES` (5) ·
7
+ * ai-api `ALLOWED_FIELD_TYPES` (13) · ai-api section prompt (11) ·
8
+ * ai-api `extractImageKeys` regex (2) · studio-api dynamic-source `compat` (5)
9
+ *
10
+ * The kit's 20 and studio-api's 20 were set-identical — that pair was already
11
+ * right. The generator was the outlier, and it taught the model `image_picker`,
12
+ * which studio-api rewrites to `'text'`, so every AI section that wanted an
13
+ * image shipped a free-text box instead of the media-library picker.
14
+ *
15
+ * `AttrSpec['type']` is `FieldTypeId | FieldTypeAlias`, derived from this table
16
+ * — so the union and the table cannot disagree. Not "a gate catches it": the
17
+ * disagreement is inexpressible.
18
+ */
19
+ /**
20
+ * The 21 core types (the 20 above, plus `color_palette`). Set-identical to studio-api's `ATTR_TYPES`, which is the
21
+ * gate that actually decides what reaches the settings panel — anything outside
22
+ * it is silently rewritten to `'text'`.
23
+ */
24
+ export const FIELD_TYPES = [
25
+ { id: 'text', tier: 'core', control: 'text-input', value: 'string',
26
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['single_line_text_field'],
27
+ aiGenerate: true, doc: 'Single-line text.' },
28
+ { id: 'textarea', tier: 'core', control: 'textarea', value: 'string',
29
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['multi_line_text_field'],
30
+ aiGenerate: true, doc: 'Multi-line plain text. No markup.' },
31
+ { id: 'richtext', tier: 'core', control: 'rich-text', value: 'string',
32
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['rich_text_field'],
33
+ aiGenerate: true, doc: 'Formatted text. Value is sanitised HTML.' },
34
+ { id: 'html', tier: 'core', control: 'textarea', value: 'string',
35
+ constraints: [], dynamicBindable: false, dynamicSourceTypes: [],
36
+ aiGenerate: false, doc: 'Raw HTML. Author-trusted; never bind to shopper input.' },
37
+ { id: 'number', tier: 'core', control: 'number-input', value: 'number',
38
+ constraints: ['min', 'max', 'step'], dynamicBindable: true, dynamicSourceTypes: ['number_integer', 'number_decimal'],
39
+ aiGenerate: true, doc: 'Numeric input.' },
40
+ { id: 'range', tier: 'core', control: 'slider', value: 'number',
41
+ constraints: ['min', 'max', 'step', 'unit'], dynamicBindable: false, dynamicSourceTypes: [],
42
+ aiGenerate: true, doc: 'Slider. Declare min/max/step or it sits on the 0–100 default.' },
43
+ { id: 'boolean', tier: 'core', control: 'switch', value: 'boolean',
44
+ constraints: [], dynamicBindable: false, dynamicSourceTypes: ['boolean'],
45
+ aiGenerate: true, doc: 'On/off toggle.' },
46
+ { id: 'color', tier: 'core', control: 'color', value: 'string',
47
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['color'],
48
+ aiGenerate: true, doc: 'Colour value (hex).' },
49
+ { id: 'select', tier: 'core', control: 'select', value: 'string',
50
+ constraints: ['options'], dynamicBindable: false, dynamicSourceTypes: [],
51
+ aiGenerate: true, doc: 'Dropdown. REQUIRES `options: [{value,label}]`.' },
52
+ { id: 'radio', tier: 'core', control: 'segmented', value: 'string',
53
+ constraints: ['options'], dynamicBindable: false, dynamicSourceTypes: [],
54
+ aiGenerate: true, doc: 'Segmented choice. REQUIRES `options: [{value,label}]`.' },
55
+ { id: 'text_alignment', tier: 'core', control: 'segmented', value: 'string',
56
+ constraints: [], dynamicBindable: false, dynamicSourceTypes: [],
57
+ aiGenerate: true, doc: 'Left/center/right. The editor supplies the three choices.' },
58
+ { id: 'url', tier: 'core', control: 'link-picker', value: 'string',
59
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['url'],
60
+ aiGenerate: true, doc: 'A link. The editor offers a link picker, not a raw text box.' },
61
+ { id: 'image', tier: 'core', control: 'media-picker', value: 'string', media: 'image',
62
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['file_reference', 'image'],
63
+ aiGenerate: true,
64
+ doc: 'Media-library picker. Value is a plain URL string, consumed exactly like `url`. NOTE: the legacy spelling `image_picker` is an alias — declaring it downgrades the control to a free-text box.' },
65
+ { id: 'video', tier: 'core', control: 'media-picker', value: 'string', media: 'video',
66
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['file_reference'],
67
+ aiGenerate: true,
68
+ doc: 'Media-library picker for a hosted video. For an EXTERNAL video URL use `url` — the editor renders this as a library browser, not a URL input.' },
69
+ { id: 'collection', tier: 'core', control: 'resource-picker', value: 'string', resource: 'collection',
70
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['collection_reference'],
71
+ aiGenerate: true, doc: 'Collection picker. Value is the collection HANDLE.' },
72
+ { id: 'product', tier: 'core', control: 'resource-picker', value: 'string', resource: 'product',
73
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['product_reference'],
74
+ aiGenerate: true, doc: 'Product picker. Value is the product HANDLE.' },
75
+ { id: 'page', tier: 'core', control: 'resource-picker', value: 'string', resource: 'page',
76
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['page_reference'],
77
+ aiGenerate: true, doc: 'Page picker. Value is the page HANDLE.' },
78
+ { id: 'blog', tier: 'core', control: 'resource-picker', value: 'string', resource: 'blog',
79
+ constraints: [], dynamicBindable: false, dynamicSourceTypes: [],
80
+ aiGenerate: true, doc: 'Blog picker. Value is the blog HANDLE.' },
81
+ { id: 'article', tier: 'core', control: 'resource-picker', value: 'string', resource: 'article',
82
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['article_reference'],
83
+ aiGenerate: true, doc: 'Article picker. Value is the article HANDLE.' },
84
+ { id: 'menu', tier: 'core', control: 'resource-picker', value: 'string', resource: 'menu',
85
+ constraints: [], dynamicBindable: false, dynamicSourceTypes: [],
86
+ aiGenerate: true,
87
+ doc: 'Store menu picker (Dashboard → Navigation). Value is the menu HANDLE. `link_list` is an accepted alias.' },
88
+ { id: 'color_palette', tier: 'core', control: 'color-palette', value: 'palette',
89
+ constraints: ['max'], dynamicBindable: false, dynamicSourceTypes: [],
90
+ aiGenerate: true,
91
+ doc: 'The theme\'s named colours: a list of { name, color } (color #rrggbb), at most 20, each name 1 to 30 characters and unique. The editor offers them in every colour picker. Needs field-type registry 3.' },
92
+ ];
93
+ /** `color_palette`: the most colours, and the longest name (theme-abi B.3). */
94
+ export const PALETTE_MAX_COLOURS = 20;
95
+ export const PALETTE_NAME_MAX = 30;
96
+ /**
97
+ * Why a `color_palette` value is not one (`[]` when it is): entries `{ name, color }` only, names trimmed, 1 to 30
98
+ * characters and unique ignoring case, colours `#rrggbb`, at most `max` (never more than 20).
99
+ */
100
+ export function paletteValueProblems(value, max) {
101
+ if (!Array.isArray(value))
102
+ return ['A colour palette is a list of { name, color }.'];
103
+ const out = [];
104
+ const cap = Math.min(typeof max === 'number' ? max : PALETTE_MAX_COLOURS, PALETTE_MAX_COLOURS);
105
+ if (value.length > cap)
106
+ out.push(`A colour palette holds at most ${cap} colours; this one has ${value.length}.`);
107
+ const seen = new Set();
108
+ value.forEach((entry, i) => {
109
+ if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) {
110
+ out.push(`Colour ${i + 1} must be { name, color }.`);
111
+ return;
112
+ }
113
+ const extra = Object.keys(entry).filter((k) => k !== 'name' && k !== 'color');
114
+ if (extra.length)
115
+ out.push(`Colour ${i + 1} holds only "name" and "color" (found ${extra.join(', ')}).`);
116
+ const { name, color } = entry;
117
+ const trimmed = typeof name === 'string' ? name.trim() : '';
118
+ if (!trimmed || [...trimmed].length > PALETTE_NAME_MAX)
119
+ out.push(`Colour ${i + 1} needs a name of 1 to ${PALETTE_NAME_MAX} characters.`);
120
+ else if (seen.has(trimmed.toLowerCase()))
121
+ out.push(`Colour ${i + 1}: "${trimmed}" is already in the palette.`);
122
+ else
123
+ seen.add(trimmed.toLowerCase());
124
+ if (typeof color !== 'string' || !/^#[0-9a-fA-F]{6}$/.test(color))
125
+ out.push(`Colour ${i + 1} must be a colour like #1a2b3c.`);
126
+ });
127
+ return out;
128
+ }
129
+ /**
130
+ * Accepted legacy / alternate spellings, normalised to a core id on input.
131
+ *
132
+ * These are not deprecated typos to reject outright — `fields.tsx` renders
133
+ * several of them identically, and models reach for them from other platforms'
134
+ * vocabularies. Accepting and normalising is what stops a silent downgrade to a
135
+ * text box; the validator still reports them so authored source gets corrected.
136
+ */
137
+ export const FIELD_TYPE_ALIASES = {
138
+ image_picker: 'image',
139
+ link_list: 'menu',
140
+ checkbox: 'boolean',
141
+ color_background: 'color',
142
+ };
143
+ /**
144
+ * Types the editor can render but a theme cannot declare, recorded so the gap
145
+ * is visible rather than rediscovered. Promoting one means adding it to
146
+ * FIELD_TYPES *and* to studio-api's gate in the same change.
147
+ */
148
+ export const EDITOR_ONLY_TYPES = [
149
+ 'inline_richtext', 'color_scheme', 'color_scheme_group',
150
+ 'font_picker', 'product_list', 'collection_list', 'metaobject',
151
+ 'video_url', 'header', 'paragraph', 'article_list', 'metaobject_list',
152
+ ];
153
+ const BY_ID = new Map(FIELD_TYPES.map((t) => [t.id, t]));
154
+ /** Resolve an authored type (possibly an alias) to its canonical id, or null. */
155
+ export function canonicalFieldType(declared) {
156
+ if (typeof declared !== 'string')
157
+ return null;
158
+ const alias = FIELD_TYPE_ALIASES[declared];
159
+ const id = alias ?? declared;
160
+ return BY_ID.has(id) ? id : null;
161
+ }
162
+ /** The definition for a canonical id. */
163
+ export function fieldType(id) {
164
+ return BY_ID.get(id);
165
+ }
166
+ /** Universal constraint keys, meaningful for every type. */
167
+ export const UNIVERSAL_CONSTRAINTS = [
168
+ 'default', 'label', 'info', 'placeholder', 'group', 'dynamic', 'visible_if',
169
+ ];
170
+ /**
171
+ * O4 — a setting value connected to a dynamic source (the editor's "Connect dynamic source"): `{ '@source': path }`
172
+ * in place of the literal, resolved by the runtime against the page's resource. The path grammar:
173
+ * `<root>.metafields.<namespace>.<key>`, `<root>.<property>` (root = product | collection | page | article | shop),
174
+ * `metaobject.<field>` (a field of a metaobject page's own entry) or `metaobject:<type>:<handle>.<field>`. Only a field
175
+ * type with `dynamicBindable` may hold one.
176
+ */
177
+ export const BOUND_SOURCE_PATTERN = /^(?:(?:product|collection|page|article|shop)\.(?:metafields\.[^.\s]{1,64}\.[^\s]{1,64}|[A-Za-z][A-Za-z0-9_]{0,63})|metaobject\.[A-Za-z0-9_][A-Za-z0-9_-]{0,63}|metaobject:[^:\s]{1,64}:[^.\s]{1,255}\.[^\s]{1,64})$/;
178
+ /**
179
+ * Several sources in one text setting: `{ '@template': 'Made by {{ product.vendor }} in {{ shop.name }}' }`. The
180
+ * text around the tokens is the merchant's own; each `{{ <path> }}` is a path BOUND_SOURCE_PATTERN accepts. At most
181
+ * 50 tokens (the reference platform's limit per setting, REF-help
182
+ * `/en/manual/custom-data/metafields/displaying-metafields-on-your-online-store`, fetched 2026-11-13) and 4,000
183
+ * characters.
184
+ */
185
+ export const BOUND_TEMPLATE_TOKEN = /\{\{\s*([^{}\s]+)\s*\}\}/g;
186
+ export const BOUND_TEMPLATE_MAX_TOKENS = 50;
187
+ /** Text field types that may hold a `{ '@template' }`. */
188
+ export const TEMPLATE_BINDABLE_TYPES = ['text', 'textarea', 'richtext'];
189
+ export function isBoundTemplateValue(value) {
190
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
191
+ return false;
192
+ const keys = Object.keys(value);
193
+ const t = value['@template'];
194
+ if (keys.length !== 1 || keys[0] !== '@template' || typeof t !== 'string' || t.length > 4000)
195
+ return false;
196
+ const paths = [...t.matchAll(BOUND_TEMPLATE_TOKEN)].map((m) => m[1]);
197
+ return paths.length > 0 && paths.length <= BOUND_TEMPLATE_MAX_TOKENS && paths.every((p) => p.length <= 400 && BOUND_SOURCE_PATTERN.test(p));
198
+ }
199
+ /** Exactly `{ '@source': <a path BOUND_SOURCE_PATTERN accepts> }` — no other member. */
200
+ export function isBoundSourceValue(value) {
201
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
202
+ return false;
203
+ const keys = Object.keys(value);
204
+ const src = value['@source'];
205
+ return keys.length === 1 && keys[0] === '@source' && typeof src === 'string' && src.length <= 400 && BOUND_SOURCE_PATTERN.test(src);
206
+ }