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

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 (204) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -10
  3. package/dist/abi/canvas-live.d.ts +49 -0
  4. package/dist/abi/canvas-live.js +88 -0
  5. package/dist/abi/cart.d.ts +48 -0
  6. package/dist/abi/cart.js +321 -0
  7. package/dist/abi/convert.d.ts +192 -0
  8. package/dist/abi/convert.js +670 -0
  9. package/dist/abi/data-api.d.ts +15 -0
  10. package/dist/abi/data-api.js +198 -0
  11. package/dist/abi/jcs.d.ts +6 -0
  12. package/dist/abi/jcs.js +28 -0
  13. package/dist/abi/page-data.d.ts +209 -0
  14. package/dist/abi/page-data.js +583 -0
  15. package/dist/abi/page.d.ts +23 -0
  16. package/dist/abi/page.js +46 -0
  17. package/dist/abi/referrals.d.ts +23 -0
  18. package/dist/abi/referrals.js +89 -0
  19. package/dist/abi/rewards.d.ts +27 -0
  20. package/dist/abi/rewards.js +82 -0
  21. package/dist/abi/seo.d.ts +47 -0
  22. package/dist/abi/seo.js +68 -0
  23. package/dist/abi/shell.d.ts +22 -0
  24. package/dist/abi/shell.js +10 -0
  25. package/dist/abi/wire.d.ts +38 -0
  26. package/dist/abi/wire.js +84 -0
  27. package/dist/build.d.ts +113 -0
  28. package/dist/build.js +294 -0
  29. package/dist/client.d.ts +19 -0
  30. package/dist/client.js +76 -0
  31. package/dist/contract.d.ts +6 -0
  32. package/dist/contract.js +6 -0
  33. package/dist/headless/ai.d.ts +132 -0
  34. package/dist/headless/ai.js +99 -0
  35. package/dist/headless/hooks.d.ts +273 -0
  36. package/dist/headless/hooks.js +533 -0
  37. package/dist/headless/i18n.d.ts +13 -0
  38. package/dist/headless/i18n.js +45 -0
  39. package/dist/headless/index.d.ts +36 -0
  40. package/dist/headless/index.js +38 -0
  41. package/dist/headless/money.d.ts +25 -0
  42. package/dist/headless/money.js +61 -0
  43. package/dist/headless/page.d.ts +43 -0
  44. package/dist/headless/page.js +53 -0
  45. package/dist/headless/platform.d.ts +55 -0
  46. package/dist/headless/platform.js +77 -0
  47. package/dist/headless/primitives/cart.d.ts +90 -0
  48. package/dist/headless/primitives/cart.js +153 -0
  49. package/dist/headless/primitives/collection.d.ts +68 -0
  50. package/dist/headless/primitives/collection.js +80 -0
  51. package/dist/headless/primitives/product.d.ts +101 -0
  52. package/dist/headless/primitives/product.js +117 -0
  53. package/dist/headless/primitives/storefront.d.ts +106 -0
  54. package/dist/headless/primitives/storefront.js +186 -0
  55. package/dist/headless/primitives/util.d.ts +19 -0
  56. package/dist/headless/primitives/util.js +42 -0
  57. package/dist/headless/strings.d.ts +9 -0
  58. package/dist/headless/strings.js +186 -0
  59. package/dist/headless/structured-data.d.ts +31 -0
  60. package/dist/headless/structured-data.js +57 -0
  61. package/dist/headless/theme.d.ts +99 -0
  62. package/dist/headless/theme.js +54 -0
  63. package/dist/index.d.ts +20 -0
  64. package/dist/index.js +18 -553
  65. package/dist/runtime/data/StoreProvider.d.ts +56 -0
  66. package/dist/runtime/data/StoreProvider.js +308 -0
  67. package/dist/runtime/data/handle.d.ts +14 -0
  68. package/dist/runtime/data/handle.js +16 -0
  69. package/dist/runtime/data/routes.d.ts +87 -0
  70. package/dist/runtime/data/routes.js +154 -0
  71. package/dist/runtime/data/to-ui.d.ts +258 -0
  72. package/dist/runtime/data/to-ui.js +820 -0
  73. package/dist/runtime/entries/register.d.ts +9 -0
  74. package/dist/runtime/entries/register.js +9 -0
  75. package/dist/runtime/entries/sections.d.ts +16 -0
  76. package/dist/runtime/entries/sections.js +19 -0
  77. package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
  78. package/dist/runtime/kit/SectionTree.js +100 -0
  79. package/dist/runtime/kit/analytics.d.ts +63 -0
  80. package/dist/runtime/kit/analytics.js +233 -0
  81. package/dist/runtime/kit/cart.d.ts +186 -0
  82. package/dist/runtime/kit/cart.js +545 -0
  83. package/dist/{types → runtime/kit}/composition.d.ts +1 -1
  84. package/dist/runtime/kit/composition.js +3 -0
  85. package/dist/{types → runtime/kit}/config.d.ts +2 -2
  86. package/dist/runtime/kit/config.js +6 -0
  87. package/dist/runtime/kit/consent.d.ts +29 -0
  88. package/dist/runtime/kit/consent.js +159 -0
  89. package/dist/runtime/kit/contract/content.d.ts +164 -0
  90. package/dist/runtime/kit/contract/content.js +83 -0
  91. package/dist/runtime/kit/contract/field-types.d.ts +290 -0
  92. package/dist/runtime/kit/contract/field-types.js +129 -0
  93. package/dist/runtime/kit/contract/groups.d.ts +230 -0
  94. package/dist/runtime/kit/contract/groups.js +402 -0
  95. package/dist/runtime/kit/contract/index.d.ts +33 -0
  96. package/dist/runtime/kit/contract/index.js +33 -0
  97. package/dist/runtime/kit/contract/transform.d.ts +82 -0
  98. package/dist/runtime/kit/contract/transform.js +133 -0
  99. package/dist/runtime/kit/contract/validate.d.ts +67 -0
  100. package/dist/runtime/kit/contract/validate.js +388 -0
  101. package/dist/runtime/kit/data.d.ts +636 -0
  102. package/dist/runtime/kit/data.js +1117 -0
  103. package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
  104. package/dist/runtime/kit/defineSection.js +10 -0
  105. package/dist/{types → runtime/kit}/dynamic-source.d.ts +4 -4
  106. package/dist/runtime/kit/dynamic-source.js +143 -0
  107. package/dist/runtime/kit/index.d.ts +24 -0
  108. package/dist/runtime/kit/index.js +24 -0
  109. package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
  110. package/dist/runtime/kit/jsx-to-json.js +28 -0
  111. package/dist/{types → runtime/kit}/mount.d.ts +25 -4
  112. package/dist/runtime/kit/mount.js +124 -0
  113. package/dist/{types → runtime/kit}/registry.d.ts +1 -1
  114. package/dist/runtime/kit/registry.js +12 -0
  115. package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
  116. package/dist/runtime/kit/ssg.js +56 -0
  117. package/dist/runtime/kit/storefront.d.ts +566 -0
  118. package/dist/runtime/kit/storefront.js +723 -0
  119. package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
  120. package/dist/runtime/kit/theme-context.js +25 -0
  121. package/dist/runtime/kit/types.d.ts +142 -0
  122. package/dist/runtime/kit/types.js +1 -0
  123. package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
  124. package/dist/runtime/platform/TrackingPixels.js +63 -0
  125. package/dist/runtime/platform/environment.d.ts +68 -0
  126. package/dist/runtime/platform/environment.js +85 -0
  127. package/dist/runtime/platform/locale.d.ts +27 -0
  128. package/dist/runtime/platform/locale.js +42 -0
  129. package/dist/runtime/platform/route-analytics.d.ts +15 -0
  130. package/dist/runtime/platform/route-analytics.js +72 -0
  131. package/dist/runtime/platform/safe-href.d.ts +25 -0
  132. package/dist/runtime/platform/safe-href.js +69 -0
  133. package/dist/runtime/platform/safe-values.d.ts +37 -0
  134. package/dist/runtime/platform/safe-values.js +140 -0
  135. package/dist/runtime/render/SectionRenderer.d.ts +4 -0
  136. package/dist/runtime/render/SectionRenderer.js +111 -0
  137. package/dist/runtime/render/listing-query.d.ts +47 -0
  138. package/dist/runtime/render/listing-query.js +114 -0
  139. package/dist/runtime/render/localized-copy.d.ts +86 -0
  140. package/dist/runtime/render/localized-copy.js +129 -0
  141. package/dist/runtime/render/product-listing.d.ts +11 -0
  142. package/dist/runtime/render/product-listing.js +240 -0
  143. package/dist/runtime/render/section-actions.d.ts +48 -0
  144. package/dist/runtime/render/section-actions.js +170 -0
  145. package/dist/runtime/render/starter.d.ts +11 -0
  146. package/dist/runtime/render/starter.js +81 -0
  147. package/dist/runtime/seo/head.d.ts +87 -0
  148. package/dist/runtime/seo/head.js +224 -0
  149. package/dist/runtime/seo/structured-data.d.ts +22 -0
  150. package/dist/runtime/seo/structured-data.js +115 -0
  151. package/dist/runtime/shell/PageShell.d.ts +18 -0
  152. package/dist/runtime/shell/PageShell.js +113 -0
  153. package/dist/runtime/shell/RuntimeBridge.d.ts +14 -0
  154. package/dist/runtime/shell/RuntimeBridge.js +85 -0
  155. package/dist/runtime/shell/overlay-state.d.ts +31 -0
  156. package/dist/runtime/shell/overlay-state.js +59 -0
  157. package/dist/runtime/shell/preview-mode.d.ts +2 -0
  158. package/dist/runtime/shell/preview-mode.js +11 -0
  159. package/dist/runtime/shell/spa-router.d.ts +14 -0
  160. package/dist/runtime/shell/spa-router.js +76 -0
  161. package/dist/runtime/shell/url-redirects.d.ts +6 -0
  162. package/dist/runtime/shell/url-redirects.js +37 -0
  163. package/dist/runtime/slots.d.ts +74 -0
  164. package/dist/runtime/slots.js +16 -0
  165. package/dist/runtime.d.ts +34 -0
  166. package/dist/runtime.js +40 -0
  167. package/dist/sdk/index.d.ts +24 -0
  168. package/dist/sdk/index.js +24 -0
  169. package/dist/sdk/referrals.d.ts +62 -0
  170. package/dist/sdk/referrals.js +20 -0
  171. package/dist/sdk/rewards.d.ts +85 -0
  172. package/dist/sdk/rewards.js +29 -0
  173. package/dist/sdk/runtime-context.d.ts +135 -0
  174. package/dist/sdk/runtime-context.js +73 -0
  175. package/dist/sdk/schema.d.ts +197 -0
  176. package/dist/sdk/schema.js +121 -0
  177. package/dist/sdk/server-render.d.ts +8 -0
  178. package/dist/sdk/server-render.js +12 -0
  179. package/dist/sdk/store-lookup.d.ts +27 -0
  180. package/dist/sdk/store-lookup.js +29 -0
  181. package/dist/sdk/store.d.ts +115 -0
  182. package/dist/sdk/store.js +1 -0
  183. package/dist/sdk/sx.d.ts +40 -0
  184. package/dist/sdk/sx.js +112 -0
  185. package/dist/sdk/theme.d.ts +152 -0
  186. package/dist/sdk/theme.js +10 -0
  187. package/dist/sdk/types.d.ts +470 -0
  188. package/dist/sdk/types.js +7 -0
  189. package/dist/server.d.ts +65 -0
  190. package/dist/server.js +370 -0
  191. package/docs/headless-api.md +220 -0
  192. package/package.json +77 -23
  193. package/dist/index.js.map +0 -1
  194. package/dist/ssg-BZ5FYTw7.js +0 -1802
  195. package/dist/ssg-BZ5FYTw7.js.map +0 -1
  196. package/dist/ssg.js +0 -8
  197. package/dist/ssg.js.map +0 -1
  198. package/dist/types/cart.d.ts +0 -86
  199. package/dist/types/data.d.ts +0 -357
  200. package/dist/types/editor.d.ts +0 -5
  201. package/dist/types/index.d.ts +0 -20
  202. package/dist/types/preview-bridge.d.ts +0 -9
  203. package/dist/types/storefront.d.ts +0 -333
  204. package/dist/types/types.d.ts +0 -44
@@ -0,0 +1,290 @@
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';
21
+ /** The runtime shape a section component receives for this attribute. */
22
+ export type ValueKind = 'string' | 'number' | 'boolean' | 'string[]';
23
+ export interface FieldTypeDef {
24
+ readonly id: string;
25
+ /**
26
+ * `core` — declarable in `defineSection({ attributes })`.
27
+ * `editorOnly` — the editor can render it from a raw schema block, but the
28
+ * kit has no concept for it, so a theme cannot declare it. Listed here so
29
+ * the gap is recorded rather than rediscovered.
30
+ */
31
+ readonly tier: 'core' | 'editorOnly';
32
+ readonly control: ControlKind;
33
+ readonly value: ValueKind;
34
+ /** Media kind, for `media-picker` controls. */
35
+ readonly media?: 'image' | 'video';
36
+ /** Resource kind, for `resource-picker` controls — what the picker lists. */
37
+ readonly resource?: 'product' | 'collection' | 'page' | 'blog' | 'article' | 'menu';
38
+ /** Constraint keys that are meaningful for THIS type (beyond the universal ones). */
39
+ readonly constraints: readonly string[];
40
+ /** May a merchant bind this to a dynamic source (the ⛁ "Insert dynamic source" UI)? */
41
+ readonly dynamicBindable: boolean;
42
+ /** Which metafield/source types the binding picker should offer. */
43
+ readonly dynamicSourceTypes: readonly string[];
44
+ /** May an AI generator emit this type? (policy, not capability) */
45
+ readonly aiGenerate: boolean;
46
+ readonly doc: string;
47
+ }
48
+ /**
49
+ * The 20 core types. Set-identical to studio-api's `ATTR_TYPES`, which is the
50
+ * gate that actually decides what reaches the settings panel — anything outside
51
+ * it is silently rewritten to `'text'`.
52
+ */
53
+ export declare const FIELD_TYPES: readonly [{
54
+ readonly id: "text";
55
+ readonly tier: "core";
56
+ readonly control: "text-input";
57
+ readonly value: "string";
58
+ readonly constraints: readonly [];
59
+ readonly dynamicBindable: true;
60
+ readonly dynamicSourceTypes: readonly ["single_line_text_field"];
61
+ readonly aiGenerate: true;
62
+ readonly doc: "Single-line text.";
63
+ }, {
64
+ readonly id: "textarea";
65
+ readonly tier: "core";
66
+ readonly control: "textarea";
67
+ readonly value: "string";
68
+ readonly constraints: readonly [];
69
+ readonly dynamicBindable: true;
70
+ readonly dynamicSourceTypes: readonly ["multi_line_text_field"];
71
+ readonly aiGenerate: true;
72
+ readonly doc: "Multi-line plain text. No markup.";
73
+ }, {
74
+ readonly id: "richtext";
75
+ readonly tier: "core";
76
+ readonly control: "rich-text";
77
+ readonly value: "string";
78
+ readonly constraints: readonly [];
79
+ readonly dynamicBindable: true;
80
+ readonly dynamicSourceTypes: readonly ["rich_text_field"];
81
+ readonly aiGenerate: true;
82
+ readonly doc: "Formatted text. Value is sanitised HTML.";
83
+ }, {
84
+ readonly id: "html";
85
+ readonly tier: "core";
86
+ readonly control: "textarea";
87
+ readonly value: "string";
88
+ readonly constraints: readonly [];
89
+ readonly dynamicBindable: false;
90
+ readonly dynamicSourceTypes: readonly [];
91
+ readonly aiGenerate: false;
92
+ readonly doc: "Raw HTML. Author-trusted; never bind to shopper input.";
93
+ }, {
94
+ readonly id: "number";
95
+ readonly tier: "core";
96
+ readonly control: "number-input";
97
+ readonly value: "number";
98
+ readonly constraints: readonly ["min", "max", "step"];
99
+ readonly dynamicBindable: true;
100
+ readonly dynamicSourceTypes: readonly ["number_integer", "number_decimal"];
101
+ readonly aiGenerate: true;
102
+ readonly doc: "Numeric input.";
103
+ }, {
104
+ readonly id: "range";
105
+ readonly tier: "core";
106
+ readonly control: "slider";
107
+ readonly value: "number";
108
+ readonly constraints: readonly ["min", "max", "step", "unit"];
109
+ readonly dynamicBindable: false;
110
+ readonly dynamicSourceTypes: readonly [];
111
+ readonly aiGenerate: true;
112
+ readonly doc: "Slider. Declare min/max/step or it sits on the 0–100 default.";
113
+ }, {
114
+ readonly id: "boolean";
115
+ readonly tier: "core";
116
+ readonly control: "switch";
117
+ readonly value: "boolean";
118
+ readonly constraints: readonly [];
119
+ readonly dynamicBindable: false;
120
+ readonly dynamicSourceTypes: readonly ["boolean"];
121
+ readonly aiGenerate: true;
122
+ readonly doc: "On/off toggle.";
123
+ }, {
124
+ readonly id: "color";
125
+ readonly tier: "core";
126
+ readonly control: "color";
127
+ readonly value: "string";
128
+ readonly constraints: readonly [];
129
+ readonly dynamicBindable: false;
130
+ readonly dynamicSourceTypes: readonly ["color"];
131
+ readonly aiGenerate: true;
132
+ readonly doc: "Colour value (hex).";
133
+ }, {
134
+ readonly id: "select";
135
+ readonly tier: "core";
136
+ readonly control: "select";
137
+ readonly value: "string";
138
+ readonly constraints: readonly ["options"];
139
+ readonly dynamicBindable: false;
140
+ readonly dynamicSourceTypes: readonly [];
141
+ readonly aiGenerate: true;
142
+ readonly doc: "Dropdown. REQUIRES `options: [{value,label}]`.";
143
+ }, {
144
+ readonly id: "radio";
145
+ readonly tier: "core";
146
+ readonly control: "segmented";
147
+ readonly value: "string";
148
+ readonly constraints: readonly ["options"];
149
+ readonly dynamicBindable: false;
150
+ readonly dynamicSourceTypes: readonly [];
151
+ readonly aiGenerate: true;
152
+ readonly doc: "Segmented choice. REQUIRES `options: [{value,label}]`.";
153
+ }, {
154
+ readonly id: "text_alignment";
155
+ readonly tier: "core";
156
+ readonly control: "segmented";
157
+ readonly value: "string";
158
+ readonly constraints: readonly [];
159
+ readonly dynamicBindable: false;
160
+ readonly dynamicSourceTypes: readonly [];
161
+ readonly aiGenerate: true;
162
+ readonly doc: "Left/center/right. The editor supplies the three choices.";
163
+ }, {
164
+ readonly id: "url";
165
+ readonly tier: "core";
166
+ readonly control: "link-picker";
167
+ readonly value: "string";
168
+ readonly constraints: readonly [];
169
+ readonly dynamicBindable: true;
170
+ readonly dynamicSourceTypes: readonly ["url"];
171
+ readonly aiGenerate: true;
172
+ readonly doc: "A link. The editor offers a link picker, not a raw text box.";
173
+ }, {
174
+ readonly id: "image";
175
+ readonly tier: "core";
176
+ readonly control: "media-picker";
177
+ readonly value: "string";
178
+ readonly media: "image";
179
+ readonly constraints: readonly [];
180
+ readonly dynamicBindable: true;
181
+ readonly dynamicSourceTypes: readonly ["file_reference", "image"];
182
+ readonly aiGenerate: true;
183
+ 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.";
184
+ }, {
185
+ readonly id: "video";
186
+ readonly tier: "core";
187
+ readonly control: "media-picker";
188
+ readonly value: "string";
189
+ readonly media: "video";
190
+ readonly constraints: readonly [];
191
+ readonly dynamicBindable: false;
192
+ readonly dynamicSourceTypes: readonly ["file_reference"];
193
+ readonly aiGenerate: true;
194
+ 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.";
195
+ }, {
196
+ readonly id: "collection";
197
+ readonly tier: "core";
198
+ readonly control: "resource-picker";
199
+ readonly value: "string";
200
+ readonly resource: "collection";
201
+ readonly constraints: readonly [];
202
+ readonly dynamicBindable: false;
203
+ readonly dynamicSourceTypes: readonly ["collection_reference"];
204
+ readonly aiGenerate: true;
205
+ readonly doc: "Collection picker. Value is the collection HANDLE.";
206
+ }, {
207
+ readonly id: "product";
208
+ readonly tier: "core";
209
+ readonly control: "resource-picker";
210
+ readonly value: "string";
211
+ readonly resource: "product";
212
+ readonly constraints: readonly [];
213
+ readonly dynamicBindable: false;
214
+ readonly dynamicSourceTypes: readonly ["product_reference"];
215
+ readonly aiGenerate: true;
216
+ readonly doc: "Product picker. Value is the product HANDLE.";
217
+ }, {
218
+ readonly id: "page";
219
+ readonly tier: "core";
220
+ readonly control: "resource-picker";
221
+ readonly value: "string";
222
+ readonly resource: "page";
223
+ readonly constraints: readonly [];
224
+ readonly dynamicBindable: false;
225
+ readonly dynamicSourceTypes: readonly ["page_reference"];
226
+ readonly aiGenerate: true;
227
+ readonly doc: "Page picker. Value is the page HANDLE.";
228
+ }, {
229
+ readonly id: "blog";
230
+ readonly tier: "core";
231
+ readonly control: "resource-picker";
232
+ readonly value: "string";
233
+ readonly resource: "blog";
234
+ readonly constraints: readonly [];
235
+ readonly dynamicBindable: false;
236
+ readonly dynamicSourceTypes: readonly [];
237
+ readonly aiGenerate: true;
238
+ readonly doc: "Blog picker. Value is the blog HANDLE.";
239
+ }, {
240
+ readonly id: "article";
241
+ readonly tier: "core";
242
+ readonly control: "resource-picker";
243
+ readonly value: "string";
244
+ readonly resource: "article";
245
+ readonly constraints: readonly [];
246
+ readonly dynamicBindable: false;
247
+ readonly dynamicSourceTypes: readonly [];
248
+ readonly aiGenerate: true;
249
+ readonly doc: "Article picker. Value is the article HANDLE.";
250
+ }, {
251
+ readonly id: "menu";
252
+ readonly tier: "core";
253
+ readonly control: "resource-picker";
254
+ readonly value: "string";
255
+ readonly resource: "menu";
256
+ readonly constraints: readonly [];
257
+ readonly dynamicBindable: false;
258
+ readonly dynamicSourceTypes: readonly [];
259
+ readonly aiGenerate: true;
260
+ readonly doc: "Store menu picker (Dashboard → Navigation). Value is the menu HANDLE. `link_list` is an accepted alias.";
261
+ }];
262
+ /**
263
+ * Accepted legacy / alternate spellings, normalised to a core id on input.
264
+ *
265
+ * These are not deprecated typos to reject outright — `fields.tsx` renders
266
+ * several of them identically, and models reach for them from other platforms'
267
+ * vocabularies. Accepting and normalising is what stops a silent downgrade to a
268
+ * text box; the validator still reports them so authored source gets corrected.
269
+ */
270
+ export declare const FIELD_TYPE_ALIASES: {
271
+ readonly image_picker: "image";
272
+ readonly link_list: "menu";
273
+ readonly checkbox: "boolean";
274
+ readonly color_background: "color";
275
+ };
276
+ /**
277
+ * Types the editor can render but a theme cannot declare, recorded so the gap
278
+ * is visible rather than rediscovered. Promoting one means adding it to
279
+ * FIELD_TYPES *and* to studio-api's gate in the same change.
280
+ */
281
+ 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"];
282
+ export type FieldTypeId = (typeof FIELD_TYPES)[number]['id'];
283
+ export type FieldTypeAlias = keyof typeof FIELD_TYPE_ALIASES;
284
+ export type AnyFieldType = FieldTypeId | FieldTypeAlias;
285
+ /** Resolve an authored type (possibly an alias) to its canonical id, or null. */
286
+ export declare function canonicalFieldType(declared: unknown): FieldTypeId | null;
287
+ /** The definition for a canonical id. */
288
+ export declare function fieldType(id: string): FieldTypeDef | undefined;
289
+ /** Universal constraint keys, meaningful for every type. */
290
+ export declare const UNIVERSAL_CONSTRAINTS: readonly ["default", "label", "info", "placeholder", "group", "dynamic", "visible_if"];
@@ -0,0 +1,129 @@
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 20 core types. 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: false, 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: false, 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: false, 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: false, 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: false, 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: false, dynamicSourceTypes: [],
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
+ ];
89
+ /**
90
+ * Accepted legacy / alternate spellings, normalised to a core id on input.
91
+ *
92
+ * These are not deprecated typos to reject outright — `fields.tsx` renders
93
+ * several of them identically, and models reach for them from other platforms'
94
+ * vocabularies. Accepting and normalising is what stops a silent downgrade to a
95
+ * text box; the validator still reports them so authored source gets corrected.
96
+ */
97
+ export const FIELD_TYPE_ALIASES = {
98
+ image_picker: 'image',
99
+ link_list: 'menu',
100
+ checkbox: 'boolean',
101
+ color_background: 'color',
102
+ };
103
+ /**
104
+ * Types the editor can render but a theme cannot declare, recorded so the gap
105
+ * is visible rather than rediscovered. Promoting one means adding it to
106
+ * FIELD_TYPES *and* to studio-api's gate in the same change.
107
+ */
108
+ export const EDITOR_ONLY_TYPES = [
109
+ 'inline_richtext', 'color_scheme', 'color_scheme_group',
110
+ 'font_picker', 'product_list', 'collection_list', 'metaobject',
111
+ 'video_url', 'header', 'paragraph',
112
+ ];
113
+ const BY_ID = new Map(FIELD_TYPES.map((t) => [t.id, t]));
114
+ /** Resolve an authored type (possibly an alias) to its canonical id, or null. */
115
+ export function canonicalFieldType(declared) {
116
+ if (typeof declared !== 'string')
117
+ return null;
118
+ const alias = FIELD_TYPE_ALIASES[declared];
119
+ const id = alias ?? declared;
120
+ return BY_ID.has(id) ? id : null;
121
+ }
122
+ /** The definition for a canonical id. */
123
+ export function fieldType(id) {
124
+ return BY_ID.get(id);
125
+ }
126
+ /** Universal constraint keys, meaningful for every type. */
127
+ export const UNIVERSAL_CONSTRAINTS = [
128
+ 'default', 'label', 'info', 'placeholder', 'group', 'dynamic', 'visible_if',
129
+ ];
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Section groups — the shared header/footer contract.
3
+ *
4
+ * The problem this solves: every template carried its own copy of the header
5
+ * and footer (17 of Nova's 18 templates, and all 12 marketplace forks). Editing
6
+ * the header on the home page changed the home page only; the other sixteen
7
+ * copies drifted silently, and there was no way to say "this page is different
8
+ * on purpose" versus "nobody updated this copy".
9
+ *
10
+ * The model, in Tanqory's JSON-tree vocabulary:
11
+ *
12
+ * groups/<name>.json ONE source of truth per shared slot:
13
+ * { "type": "header", "sections": [ …ContractNode ] }
14
+ *
15
+ * templates/<slug>.json references the group instead of copying it:
16
+ * { "groups": { "header": "header", "footer": "footer" },
17
+ * "sections": [ …template-area sections only ] }
18
+ *
19
+ * or overrides it for THIS page, explicitly:
20
+ * { "groups": { "header": { "override": [ …nodes ] } } }
21
+ *
22
+ * `resolvePage` is the ONLY function that turns a template + its groups into
23
+ * the flat section list the runtime renders. The storefront, the SSG, the
24
+ * editor preview bridge, studio-api and the AI tools all call it, so "what
25
+ * does this page render" cannot be answered two different ways.
26
+ *
27
+ * Backward compatibility is total: a template with no `groups` key and inline
28
+ * header/footer sections (every template that exists today) resolves exactly
29
+ * as it did — those inline sections are treated as an implicit per-page
30
+ * override. Nothing has to migrate to keep working; migrating is what makes the
31
+ * header SHARED.
32
+ */
33
+ import { type ContractNode, type ContractPageDoc } from './content.js';
34
+ /** The slots a group can fill. `template` is the page body and is never shared. */
35
+ export type GroupSlot = 'header' | 'footer';
36
+ export declare const GROUP_SLOTS: readonly GroupSlot[];
37
+ /** A shared section group as stored at `groups/<name>.json`. */
38
+ export interface SectionGroupDoc {
39
+ /** Which slot this group fills. */
40
+ type: GroupSlot;
41
+ /** Human label for the editor; defaults to the file name. */
42
+ name?: string;
43
+ sections: ContractNode[];
44
+ contentVersion?: number;
45
+ }
46
+ /**
47
+ * How a template binds a slot.
48
+ * - a string → shorthand for `{ ref: <name> }`
49
+ * - `{ ref }` → the shared group at `groups/<ref>.json`
50
+ * - `{ override: [...] }`→ a page-specific composition; the shared group is
51
+ * NOT rendered on this page
52
+ */
53
+ export type GroupBinding = string | {
54
+ ref: string;
55
+ } | {
56
+ override: ContractNode[];
57
+ };
58
+ /** A template that knows about groups. Superset of `ContractPageDoc`. */
59
+ export interface GroupedPageDoc extends ContractPageDoc {
60
+ groups?: Partial<Record<GroupSlot, GroupBinding>>;
61
+ }
62
+ /** Where a resolved node came from — what the editor shows and what a save must respect. */
63
+ export type NodeSource = {
64
+ kind: 'group';
65
+ slot: GroupSlot;
66
+ group: string;
67
+ } | {
68
+ kind: 'override';
69
+ slot: GroupSlot;
70
+ } | {
71
+ kind: 'inline';
72
+ slot: GroupSlot;
73
+ } | {
74
+ kind: 'template';
75
+ };
76
+ export interface SlotResolution {
77
+ /** `ref` = shared group · `override` = explicit per-page · `inline` = legacy
78
+ * inline sections (implicit per-page) · `none` = the slot is empty. */
79
+ mode: 'ref' | 'override' | 'inline' | 'none';
80
+ group?: string;
81
+ sections: ContractNode[];
82
+ }
83
+ export interface ResolvedPage {
84
+ /** The flat list the runtime renders: header → template → footer. */
85
+ sections: ContractNode[];
86
+ /** nodeId → provenance. Every top-level node has an entry. */
87
+ provenance: Record<string, NodeSource>;
88
+ slots: Record<GroupSlot, SlotResolution>;
89
+ /** Groups that were referenced but not supplied — rendered as empty, reported here. */
90
+ missingGroups: string[];
91
+ }
92
+ export type GroupMap = Record<string, SectionGroupDoc>;
93
+ /** The slot a legacy inline node belongs to, from `area` first, then its type. */
94
+ export declare function inlineSlotOf(node: ContractNode): GroupSlot | 'template';
95
+ /**
96
+ * Resolve a template into the section list the runtime renders.
97
+ *
98
+ * Pure and deterministic: the same template + groups always produce the same
99
+ * list, so the storefront, the SSG, the preview and the editor agree by
100
+ * construction rather than by discipline.
101
+ */
102
+ export declare function resolvePage(template: GroupedPageDoc, groups?: GroupMap): ResolvedPage;
103
+ export interface SplitResult {
104
+ template: GroupedPageDoc;
105
+ /** Only the groups whose sections were part of this page and may have changed. */
106
+ groups: Partial<Record<GroupSlot, {
107
+ name: string;
108
+ doc: SectionGroupDoc;
109
+ }>>;
110
+ }
111
+ export interface SplitOptions {
112
+ /**
113
+ * Per slot, how the saved template should bind. Omitted slots keep the mode
114
+ * they were resolved with. `ref` needs a group name (the one to write to);
115
+ * `override` freezes the current nodes into the template; `none` drops the
116
+ * slot from this page.
117
+ */
118
+ slots?: Partial<Record<GroupSlot, {
119
+ mode: 'ref';
120
+ group: string;
121
+ } | {
122
+ mode: 'override';
123
+ } | {
124
+ mode: 'none';
125
+ }>>;
126
+ }
127
+ /**
128
+ * The inverse of `resolvePage`: take an edited flat list plus the provenance
129
+ * it was resolved with, and produce what to write to the template and to each
130
+ * group file.
131
+ *
132
+ * Rules that make this safe for a shared group:
133
+ * - A node whose provenance says `group` goes back to that group — and ONLY
134
+ * if the slot is still bound to that group. Nothing about a template save
135
+ * can silently rewrite a group the page no longer references.
136
+ * - A node with no provenance (newly inserted) lands where its `area` says.
137
+ * Inserted into a `ref`-bound slot, it becomes part of the shared group —
138
+ * that is the merchant editing "the header", which is shared by design and
139
+ * is reported as such by `groupImpact`.
140
+ * - Body nodes carry no `area` on disk unless they already had one, so a
141
+ * template that never used `area` on body nodes stays byte-identical.
142
+ */
143
+ export declare function splitPage(sections: ContractNode[], previous: ResolvedPage, opts?: SplitOptions): SplitResult;
144
+ /**
145
+ * Attach the source template to a resolution so `splitPage` can preserve any
146
+ * top-level keys it does not model (`contentVersion`, future additions).
147
+ */
148
+ export declare function resolvePageFrom(template: GroupedPageDoc, groups?: GroupMap): ResolvedPage & {
149
+ template: GroupedPageDoc;
150
+ };
151
+ /** Which templates render a given group — the blast radius of editing it. */
152
+ export declare function groupImpact(groupName: string, templates: Record<string, GroupedPageDoc>): string[];
153
+ export interface ExtractOptions {
154
+ /**
155
+ * Attribute defaults per section type, so two copies that differ only by an
156
+ * explicitly-written default (`{}` vs `{ sticky: 'always' }` when `always`
157
+ * IS the default) compare equal. Without this, the design-converted home
158
+ * page would look "different" from seventeen pages that merely omit defaults.
159
+ */
160
+ defaults?: Record<string, Record<string, unknown>>;
161
+ /** Group file names to write. */
162
+ names?: Partial<Record<GroupSlot, string>>;
163
+ }
164
+ export interface ExtractReport {
165
+ slot: GroupSlot;
166
+ group: string;
167
+ /** The signature that won and the templates that carried it. */
168
+ canonical: {
169
+ signature: string;
170
+ templates: string[];
171
+ };
172
+ /** Templates whose copy differs — kept as explicit overrides, never merged. */
173
+ overrides: Array<{
174
+ template: string;
175
+ signature: string;
176
+ differences: string[];
177
+ }>;
178
+ /** Templates that carried no section in this slot. */
179
+ empty: string[];
180
+ /** Templates that already bind this slot (a re-run) — untouched. */
181
+ alreadyBound: string[];
182
+ /**
183
+ * Ids that change for a template that binds the group: its own copy carried
184
+ * the same content under different ids, and a shared group has one set of
185
+ * ids. Reported so nothing about a merchant's ids changes silently; an
186
+ * override keeps every id verbatim.
187
+ */
188
+ idRemaps: Array<{
189
+ template: string;
190
+ from: string;
191
+ to: string;
192
+ }>;
193
+ }
194
+ export interface ExtractResult {
195
+ groups: Partial<Record<GroupSlot, {
196
+ name: string;
197
+ doc: SectionGroupDoc;
198
+ }>>;
199
+ templates: Record<string, GroupedPageDoc>;
200
+ report: ExtractReport[];
201
+ /** True when nothing needed to change — the second run of a migration. */
202
+ noop: boolean;
203
+ }
204
+ /**
205
+ * Canonical comparison form for a slot's nodes: type + settings-with-defaults
206
+ * + blocks, with ids REMOVED. Ids are identity, not content; two pages whose
207
+ * headers differ only in id are the same header.
208
+ */
209
+ export declare function slotSignature(nodes: ContractNode[], defaults?: ExtractOptions['defaults']): string;
210
+ /**
211
+ * Turn per-template inline header/footer copies into shared groups.
212
+ *
213
+ * Deterministic and idempotent:
214
+ * - The canonical composition for a slot is the one the MOST templates carry
215
+ * (ties broken by the alphabetically-first template that carries it).
216
+ * - A template whose copy matches canonical (after defaults) binds the group.
217
+ * - A template whose copy differs keeps its own nodes as an explicit
218
+ * `override` — the difference is REPORTED, never merged away.
219
+ * - A template with nothing in the slot binds nothing for it.
220
+ * - A template that already binds the slot is left alone, so running the
221
+ * migration twice changes nothing (`noop: true`).
222
+ *
223
+ * Ids, settings, blocks and order are carried verbatim into the group and into
224
+ * every override; nothing is re-minted.
225
+ */
226
+ export declare function extractGroups(templates: Record<string, GroupedPageDoc>, opts?: ExtractOptions): ExtractResult;
227
+ /** Validate a group document's own shape (the content validator checks its nodes). */
228
+ export declare function isSectionGroupDoc(v: unknown): v is SectionGroupDoc;
229
+ /** Group file names must be safe path segments. */
230
+ export declare const GROUP_NAME_PATTERN: RegExp;