@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,636 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StorefrontExtensions, type Menu, type Blog, type Shop, type Filter } from './storefront.js';
3
+ export interface Money {
4
+ amount: string;
5
+ currencyCode: string;
6
+ }
7
+ export interface ProductOption {
8
+ name: string;
9
+ values: string[];
10
+ }
11
+ export interface ImageRef {
12
+ url: string;
13
+ altText?: string;
14
+ /** Intrinsic pixel dimensions (standard `image.width`/`image.height`). */
15
+ width?: number | null;
16
+ height?: number | null;
17
+ /** width / height (`image.aspect_ratio`) — for responsive layouts. */
18
+ aspectRatio?: number | null;
19
+ }
20
+ /** SEO snapshot (Product/Page/Article). */
21
+ export interface Seo {
22
+ title?: string | null;
23
+ description?: string | null;
24
+ keywords?: string[] | null;
25
+ }
26
+ /** standard `measurement` (a `dimension`/`volume`/`weight` metafield value). */
27
+ export interface Measurement {
28
+ value: number;
29
+ unit: string;
30
+ }
31
+ /** standard `rating` metafield value. */
32
+ export interface Rating {
33
+ value: number;
34
+ scaleMin: number;
35
+ scaleMax: number;
36
+ }
37
+ /** standard `focal_point` — normalized 0..1 crop centre. */
38
+ export interface FocalPoint {
39
+ x: number;
40
+ y: number;
41
+ }
42
+ /** standard `image_presentation`. */
43
+ export interface ImagePresentation {
44
+ focalPoint?: FocalPoint | null;
45
+ }
46
+ /** standard `model_source` (a 3D model file source). */
47
+ export interface ModelSource {
48
+ url: string;
49
+ format?: string | null;
50
+ mimeType?: string | null;
51
+ filesize?: number | null;
52
+ }
53
+ /** standard `video_source` (one encoding of a hosted video). */
54
+ export interface VideoSource {
55
+ url: string;
56
+ format?: string | null;
57
+ mimeType?: string | null;
58
+ width?: number | null;
59
+ height?: number | null;
60
+ }
61
+ /** standard `generic_file` (a File reference from a metafield). */
62
+ export interface GenericFile {
63
+ id?: string;
64
+ url: string;
65
+ previewImage?: ImageRef | null;
66
+ mimeType?: string | null;
67
+ originalFileSize?: number | null;
68
+ }
69
+ /** standard `recommendations` object — wraps the `productRecommendations()` list. */
70
+ export interface Recommendations {
71
+ products: Product[];
72
+ productsCount: number;
73
+ intent?: 'related' | 'complementary' | string;
74
+ performed?: boolean;
75
+ }
76
+ /** Build a `recommendations` object from a product list (parity with the commerce standard
77
+ * `recommendations` legacy templating object, whose `.products` our API returns directly). */
78
+ export declare function toRecommendations(products: Product[], intent?: string): Recommendations;
79
+ /** Per-variant cart quantity bounds (wholesale / case-of-N). Storefront cart enforces these. */
80
+ export interface QuantityRule {
81
+ minimum: number;
82
+ maximum: number | null;
83
+ increment: number;
84
+ }
85
+ /** Per-unit pricing ("$2.50 / 100ml"). */
86
+ export interface UnitPriceMeasurement {
87
+ measuredType: string;
88
+ quantityValue: number;
89
+ quantityUnit: string;
90
+ referenceValue: number;
91
+ referenceUnit: string;
92
+ }
93
+ /** Pickup / in-store stock for one location. */
94
+ export interface StoreAvailability {
95
+ available: boolean;
96
+ quantityAvailable: number;
97
+ pickUpTime?: string | null;
98
+ location: {
99
+ id: string;
100
+ name: string;
101
+ };
102
+ }
103
+ export interface SellingPlanOption {
104
+ name: string;
105
+ value: string;
106
+ }
107
+ export interface SellingPlan {
108
+ id: string;
109
+ name: string;
110
+ description?: string | null;
111
+ recurringDeliveries: boolean;
112
+ options: SellingPlanOption[];
113
+ }
114
+ export interface SellingPlanGroup {
115
+ name: string;
116
+ appName?: string | null;
117
+ options: Array<{
118
+ name: string;
119
+ values: string[];
120
+ }>;
121
+ sellingPlans: SellingPlan[];
122
+ }
123
+ export interface ProductVariant {
124
+ id: string;
125
+ title: string;
126
+ price: Money;
127
+ /** "Was" price — present when the variant is on sale (compareAtPrice > price). */
128
+ compareAtPrice?: Money | null;
129
+ availableForSale: boolean;
130
+ selectedOptions?: {
131
+ name: string;
132
+ value: string;
133
+ }[];
134
+ image?: ImageRef | null;
135
+ /** Stock-keeping unit. Only after `fetchProduct()`. */
136
+ sku?: string | null;
137
+ /** Barcode (ISBN, UPC, GTIN…). Only after `fetchProduct()`. */
138
+ barcode?: string | null;
139
+ /** On-hand stock for this variant (`inventory_quantity`). */
140
+ inventoryQuantity?: number | null;
141
+ /** `DENY` (stop selling at 0) or `CONTINUE` (oversell) — standard `inventory_policy`. */
142
+ inventoryPolicy?: 'DENY' | 'CONTINUE' | null;
143
+ /** Whether the variant needs shipping (physical vs digital/service). */
144
+ requiresShipping?: boolean | null;
145
+ /** Whether tax applies to the variant. */
146
+ taxable?: boolean | null;
147
+ /** Physical weight (for shipping display). */
148
+ weight?: {
149
+ value: number;
150
+ unit: string;
151
+ } | null;
152
+ /** Cart quantity bounds (min/max/increment). */
153
+ quantityRule?: QuantityRule;
154
+ /** Per-unit price ("$2.50 / 100ml") for measured products. */
155
+ unitPrice?: Money | null;
156
+ unitPriceMeasurement?: UnitPriceMeasurement | null;
157
+ /** Pickup availability per location (only after `fetchProduct()`). */
158
+ storeAvailability?: StoreAvailability[];
159
+ }
160
+ export interface Product {
161
+ /** Storefront GraphQL node id (present for live data). */
162
+ id?: string;
163
+ /** commerce-standard theme template variant (e.g. "bundle"). */
164
+ templateSuffix?: string | null;
165
+ handle: string;
166
+ title: string;
167
+ price: Money;
168
+ /** Highest variant price, when it differs from `price` — a card says "From". */
169
+ priceMax?: Money;
170
+ /** "Was" price paired with `price` (the lowest compareAtPrice) — sale badge on cards. */
171
+ compareAtPrice?: Money | null;
172
+ featuredImage?: ImageRef | null;
173
+ /** Default purchasable variant id (`firstAvailableVariant`) — enough to add
174
+ * to cart from a grid/card without loading the full variant list. */
175
+ variantId?: string;
176
+ availableForSale?: boolean;
177
+ /** The product's own low-stock threshold (Theme ABI `Product.lowStockThreshold`), when the merchant set one. */
178
+ lowStockThreshold?: number;
179
+ /**
180
+ * The store's automatic discounts that apply to this product without conditions (storefront-query rev 2.31
181
+ * `Product.automaticDiscounts`), active or scheduled: show one only while now ∈ [startsAt, endsAt). `value` is a
182
+ * percentage (0–100] or, for `fixed`, the amount off each item in the store's base currency. QA D8.
183
+ */
184
+ automaticDiscounts?: import('../../sdk/types.js').ProductAutomaticDiscount[];
185
+ /** Catalog facets (card badges / filtering). Present from boot. */
186
+ vendor?: string | null;
187
+ productType?: string | null;
188
+ tags?: string[];
189
+ /** Publish/create timestamps (standard `product.published_at`/`created_at`). */
190
+ publishedAt?: string | null;
191
+ createdAt?: string | null;
192
+ /** Canonical storefront URL (`product.url`). */
193
+ onlineStoreUrl?: string | null;
194
+ /** Long description as PLAINTEXT — only populated by `fetchProduct()` (PDP). */
195
+ description?: string;
196
+ /**
197
+ * The same body WITH the merchant's formatting (`Product.descriptionHtml`,
198
+ * `@cost(value: 0)`), already sanitised by store-api. Only populated by
199
+ * `fetchProduct()` (PDP). A theme renders it as HTML and must not re-sanitise
200
+ * it; `description` is the plaintext fallback for text-only surfaces.
201
+ */
202
+ descriptionHtml?: string;
203
+ /** Image gallery — only after `fetchProduct()` (PDP). */
204
+ images?: ImageRef[];
205
+ /** Full media gallery incl. video / 3D (`product.media`) — after `fetchProduct()`. */
206
+ media?: ProductMedia[];
207
+ /** Option definitions (Size, Color…) — only after `fetchProduct()`. */
208
+ options?: ProductOption[];
209
+ /** Full variant list — only after `fetchProduct()` (PDP). */
210
+ variants?: ProductVariant[];
211
+ /** Subscription / selling-plan groups — only after `fetchProduct()`. */
212
+ sellingPlanGroups?: SellingPlanGroup[];
213
+ /** Collections this product belongs to (`product.collections`) — after `fetchProduct()`. */
214
+ collections?: Array<{
215
+ handle: string;
216
+ title: string;
217
+ }>;
218
+ /** True for gift-card products (`product.gift_card`) — after `fetchProduct()`. */
219
+ isGiftCard?: boolean;
220
+ /** Total on-hand stock across variants (`product.totalInventory`). */
221
+ totalInventory?: number | null;
222
+ /** Requested custom metafields ("namespace.key" → value) — pass identifiers to fetchProduct(). */
223
+ metafields?: Record<string, string | null>;
224
+ /** SEO override — only after `fetchProduct()`. */
225
+ seo?: Seo | null;
226
+ }
227
+ /**
228
+ * A product media node — image, video, 3D model, or external (YouTube/Vimeo) video. On the Theme ABI path
229
+ * (storefront-query rev 2.34 `Product.media`) only `image` and hosted `video` (mp4 / webm / quicktime files in the
230
+ * store's own media library) ever appear, and `media` is present only when the product has at least one video.
231
+ */
232
+ export interface ProductMedia {
233
+ id: string;
234
+ type: 'image' | 'video' | 'model_3d' | 'external_video';
235
+ alt?: string | null;
236
+ /** Present for `image`. */
237
+ image?: ImageRef | null;
238
+ /** Poster frame for video / 3D. */
239
+ previewImage?: ImageRef | null;
240
+ /** Playable/loadable sources for `video` / `model_3d`. */
241
+ sources?: {
242
+ url: string;
243
+ mimeType?: string | null;
244
+ format?: string | null;
245
+ }[];
246
+ /** For `external_video` — 'YOUTUBE' | 'VIMEO'. */
247
+ host?: string | null;
248
+ /** For `external_video` — the embed URL. */
249
+ embedUrl?: string | null;
250
+ }
251
+ export interface Collection {
252
+ /** Backend collection id (`collection.id`). */
253
+ id?: string;
254
+ /** commerce-standard theme template variant (e.g. "featured"). */
255
+ templateSuffix?: string | null;
256
+ handle: string;
257
+ title: string;
258
+ /** Collection body/description HTML (`collection.description`). */
259
+ description?: string | null;
260
+ /** Optional hero image; falls back to first product's featuredImage. */
261
+ image?: {
262
+ url?: string;
263
+ altText?: string;
264
+ } | null;
265
+ products: Product[];
266
+ /** Total number of products in the collection (`products_count`). */
267
+ productsCount?: number;
268
+ /** Custom metafields ("namespace.key" → value) for dynamic sources. */
269
+ metafields?: Record<string, string | null>;
270
+ /** SEO title/description (merchant-edited) for the document head. */
271
+ seo?: Seo | null;
272
+ /** The collection's facets, when the platform answered them (Theme ABI `Collection.filters`). */
273
+ filters?: Filter[];
274
+ }
275
+ export interface Page {
276
+ handle: string;
277
+ title: string;
278
+ /** HTML body — rendered via dangerouslySetInnerHTML by the PageBody section. */
279
+ body: string;
280
+ bodySummary?: string;
281
+ author?: string | null;
282
+ publishedAt?: string;
283
+ updatedAt?: string;
284
+ /** commerce-standard template suffix (e.g. "contact"); the theme renders
285
+ * templates/page.<suffix>.json when set, else the default page template. */
286
+ templateSuffix?: string | null;
287
+ /** SEO title/description (merchant-edited) for the document head. */
288
+ seo?: Seo | null;
289
+ }
290
+ /**
291
+ * The data interface every block consumes. Themes provide an implementation.
292
+ *
293
+ * Core read methods (collections/products/pages/localization) are always
294
+ * present. The commerce-standard extensions (shop, menus, search, blog,
295
+ * recommendations, metaobjects, customer account) come from `StorefrontExtensions`
296
+ * and are LIVE-ONLY — undefined under mock data, so themes feature-detect them
297
+ * (`data.search?.(...)`, `data.customer?.login(...)`).
298
+ */
299
+ export interface DataApi extends StorefrontExtensions {
300
+ collectionByHandle: (handle: string) => Collection | null;
301
+ /** All known collections (used by CollectionList). */
302
+ allCollections: () => Collection[];
303
+ /**
304
+ * List every navigation menu the store has (Dashboard → Navigation), for the
305
+ * editor's `link_list` picker. Identity only (handle/title/count) — fetch a
306
+ * menu's items with `fetchMenu(handle)`. Optional: older payloads may omit it.
307
+ */
308
+ listMenus?: () => Promise<Array<{
309
+ handle: string;
310
+ title: string;
311
+ itemsCount: number;
312
+ }>>;
313
+ /** Connected tracking pixels (Settings → Customer events) to inject on the
314
+ * storefront. Optional — older payloads / mock mode return []. */
315
+ pixels?: () => Promise<Array<{
316
+ id: string;
317
+ name: string;
318
+ provider: string | null;
319
+ providerPixelId: string | null;
320
+ code: string | null;
321
+ }>>;
322
+ /**
323
+ * "Notify me when it's back": ask store-api to email `email` ONCE when a sold-out variant is available
324
+ * again. `available` = it is in stock right now (nothing stored). Resolves for both; rejects on a
325
+ * transport/HTTP failure so the form can say so. The address is used for this one email only — there is
326
+ * no marketing opt-in on this path.
327
+ */
328
+ notifyBackInStock?: (input: {
329
+ variantId: string;
330
+ email: string;
331
+ locale?: string;
332
+ country?: string;
333
+ }) => Promise<'subscribed' | 'available'>;
334
+ /** Physical store locations (Settings → Locations) for a store-locator. */
335
+ locations?: () => Promise<Array<{
336
+ id: string;
337
+ name: string;
338
+ code: string | null;
339
+ address: {
340
+ country: string | null;
341
+ address: string | null;
342
+ city: string | null;
343
+ province: string | null;
344
+ postalCode: string | null;
345
+ phone: string | null;
346
+ } | null;
347
+ }>>;
348
+ /**
349
+ * Look up a single product by its handle. Returns null when the handle
350
+ * isn't found. Required by FeaturedProduct / ProductDetails sections
351
+ * (ported from the canonical examples/react theme in PR #2).
352
+ */
353
+ productByHandle: (handle: string) => Product | null;
354
+ /**
355
+ * Look up a Page by handle (the storefront's `/pages/<handle>` content).
356
+ * Returns null if the handle wasn't prefetched at boot or the merchant
357
+ * hasn't published a page with that handle. Live data prefetches only the
358
+ * page matching the current URL, so other handles return null even when
359
+ * they exist in the backend — themes should only call this for the page
360
+ * the user is on.
361
+ */
362
+ pageByHandle: (handle: string) => Page | null;
363
+ /** A page by handle from the storefront — for a page reached by soft navigation;
364
+ * afterwards `pageByHandle` answers for it too. */
365
+ fetchPage?: (handle: string) => Promise<Page | null>;
366
+ /** Localization snapshot — what markets/countries the store has live.
367
+ * null = mock data; the country switcher should hide itself. */
368
+ localization: Localization | null;
369
+ /**
370
+ * Raw GraphQL escape hatch against the same storefront endpoint the live
371
+ * data source was booted with. Present ONLY for live data — undefined for
372
+ * mock data. Powers post-boot interactions (the cart's mutations live here).
373
+ */
374
+ graphql?: <T = unknown>(query: string, variables?: Record<string, unknown>) => Promise<T>;
375
+ /**
376
+ * Fetch a single product WITH its full options + variants on demand (for the
377
+ * product page's variant picker). Live data hits the backend; mock data
378
+ * resolves synchronously from the prefetched cache. Returns null if missing.
379
+ */
380
+ fetchProduct?: (handle: string, opts?: {
381
+ metafields?: Array<{
382
+ namespace: string;
383
+ key: string;
384
+ }>;
385
+ }) => Promise<Product | null>;
386
+ /**
387
+ * Fetch the shop's custom metafields by identifier (for dynamic sources).
388
+ * Live data queries `shop { metafields(identifiers) }`; mock data returns {}
389
+ * (no metafields offline). Result keys are "namespace.key".
390
+ */
391
+ fetchShopMetafields?: (identifiers: Array<{
392
+ namespace: string;
393
+ key: string;
394
+ }>) => Promise<Record<string, string | null>>;
395
+ /**
396
+ * Fetch a collection's custom metafields by identifier (for dynamic sources).
397
+ * Result keys are "namespace.key".
398
+ */
399
+ fetchCollectionMetafields?: (handle: string, identifiers: Array<{
400
+ namespace: string;
401
+ key: string;
402
+ }>) => Promise<Record<string, string | null>>;
403
+ /**
404
+ * The raw serializable bootstrap payload this live DataApi was built from
405
+ * (null for mock data). The SSG step embeds it into the page as
406
+ * `window.__TQ_STATE__` so the client can rebuild the identical DataApi
407
+ * synchronously at hydration via createLiveDataFromSnapshot — SSR markup and
408
+ * the client's first render match by construction.
409
+ */
410
+ getSnapshot?: () => unknown;
411
+ /** Records the server loaded for this route before rendering (`blog:<handle>`,
412
+ * `article:<blog>/<handle>`), keyed like the page's resource cache — so the
413
+ * server html carries them and hydration starts with them instead of refetching. */
414
+ preloaded?: Record<string, unknown>;
415
+ /** The policy handle this page renders (a `/policies/<handle>` route). */
416
+ policyHandle?: string;
417
+ /** A published policy by handle (browser: through /_tq), null when the store has not published it. */
418
+ fetchPolicy?: (handle: string) => Promise<import('./storefront.js').ShopPolicy | null>;
419
+ /** Whether the shopper has a customer session — not who (ABI `request.isSignedIn`). */
420
+ signedIn?: boolean;
421
+ /** ABI consent (browser only): `consent.get` / `consent.set` through /_tq. */
422
+ consent?: {
423
+ get: () => Promise<{
424
+ known: boolean;
425
+ analytics: boolean;
426
+ marketing: boolean;
427
+ functional: boolean;
428
+ region?: string;
429
+ bannerRequired: boolean;
430
+ geo?: {
431
+ country?: string;
432
+ region?: string;
433
+ };
434
+ regionRequiresBanner?: boolean;
435
+ }>;
436
+ set: (input: {
437
+ analytics: boolean;
438
+ marketing: boolean;
439
+ functional: boolean;
440
+ region?: string;
441
+ }) => Promise<void>;
442
+ };
443
+ /** Synchronous reads of what the server already loaded for this page (server and hydrating browser alike). */
444
+ blogSync?: (handle: string) => import('./storefront.js').Blog | null;
445
+ articleSync?: (blogHandle: string, handle: string) => import('./storefront.js').Article | null;
446
+ searchSync?: (query: string, sort?: string) => import('./storefront.js').SearchResults | null;
447
+ recommendationsSync?: (productHandle: string) => Product[] | null;
448
+ /** The route names a resource the platform does not have: the page answers 404. */
449
+ routeMissing?: boolean;
450
+ /** The Account BFF URL for the account slot. */
451
+ accountUrl?: (path?: 'orders' | 'addresses' | 'profile') => string;
452
+ /** The platform form endpoint of this page (ABI native forms), when the host has one. */
453
+ formEndpoint?: string;
454
+ /** The outcome of the native form POST this page answers. */
455
+ formResult?: {
456
+ formId: string;
457
+ status: 'ok' | 'invalid' | 'rate_limited' | 'unavailable' | 'expired';
458
+ email?: string;
459
+ };
460
+ }
461
+ /** Country/market shape mirrored from storefront GraphQL `Localization`. */
462
+ export interface LocalizedCurrency {
463
+ isoCode: string;
464
+ name?: string;
465
+ symbol?: string;
466
+ }
467
+ export interface LocalizedMarket {
468
+ id: string;
469
+ handle: string;
470
+ name: string;
471
+ }
472
+ export interface LocalizedCountry {
473
+ isoCode: string;
474
+ name: string;
475
+ currency: LocalizedCurrency;
476
+ market: LocalizedMarket | null;
477
+ /**
478
+ * The languages this country's market offers, when the platform names them per market
479
+ * (`ctx.locale.markets`). Absent ⇒ every language in `availableLanguages`.
480
+ */
481
+ availableLanguages?: LocalizedLanguage[];
482
+ }
483
+ /** A language the store has published (dashboard → Markets / Languages). */
484
+ export interface LocalizedLanguage {
485
+ isoCode: string;
486
+ name: string;
487
+ }
488
+ export interface Localization {
489
+ /** Currently-active country (resolved from the request's X-Tanqory-Country). */
490
+ country: LocalizedCountry;
491
+ /** Every country the store has an active Market for — what the picker shows. */
492
+ availableCountries: LocalizedCountry[];
493
+ /**
494
+ * Currently-active language + every language the store has PUBLISHED. These
495
+ * are STORE/dashboard data (the merchant's published locales), not a theme
496
+ * config list — the theme only ships the translations. Optional so older live
497
+ * payloads (countries only) still satisfy the type; the picker falls back to a
498
+ * single default when absent.
499
+ */
500
+ language?: LocalizedLanguage;
501
+ availableLanguages?: LocalizedLanguage[];
502
+ }
503
+ /** Wraps the app with a theme-provided data source (mock or live). */
504
+ export declare function DataProvider({ value, children }: {
505
+ value: DataApi;
506
+ children: ReactNode;
507
+ }): JSX.Element;
508
+ export declare function useData(): DataApi;
509
+ type MockLocation = NonNullable<Awaited<ReturnType<NonNullable<DataApi['locations']>>>>[number];
510
+ /**
511
+ * The richer fixture shape `createMockData` also accepts. `app/data/sample-store.json`
512
+ * is a plain `Collection[]` (the theme's own offline fixture); a content pack
513
+ * (`NOVA_CONTENT=<dir>`, e.g. `demo/halden/`) may instead provide this object so
514
+ * its menus, blog, pages, store locations, shop and markets match the store it
515
+ * depicts. Every key is optional; an absent one keeps the built-in sample.
516
+ */
517
+ export interface MockFixture {
518
+ collections: Collection[];
519
+ menus?: Menu[];
520
+ blogs?: Blog[];
521
+ pages?: Page[];
522
+ locations?: MockLocation[];
523
+ shop?: Partial<Shop>;
524
+ localization?: Localization;
525
+ /** Offline "You may also like": product handle → the handles to recommend,
526
+ * in order. Without an entry, the first four other products. */
527
+ recommendations?: Record<string, string[]>;
528
+ }
529
+ /** Build an offline data source from fixture collections (theme passes its JSON). */
530
+ export declare function createMockData(input: Collection[] | MockFixture): DataApi;
531
+ /**
532
+ * Live data source backed by the Tanqory Storefront GraphQL API.
533
+ *
534
+ * const data = await createLiveData({
535
+ * endpoint: 'https://api.example.com',
536
+ * storeId: '<store-uuid>',
537
+ * token: '<publishable-storefront-token>',
538
+ * prefetch: { collectionLimit: 20, productLimitPerCollection: 24 },
539
+ * })
540
+ *
541
+ * Returns the same `DataApi` shape as `createMockData` (sync read methods)
542
+ * by pre-fetching collections + their products at boot and serving every
543
+ * subsequent lookup from an in-memory cache. The trade-off: a single GraphQL
544
+ * round-trip at boot, then zero network on render — exactly what the SSG
545
+ * step + first hydration need.
546
+ *
547
+ * Per-handle pages (e.g. /products/<handle>) that miss the prefetch can
548
+ * still be fetched lazily via `dataApi.refresh()` (TODO) — for now, raise
549
+ * `prefetch.productLimitPerCollection` to cover the catalogue size.
550
+ */
551
+ export interface LiveDataOptions {
552
+ /** Base URL of the store-api (e.g. https://api.example.com). */
553
+ endpoint: string;
554
+ /** Store UUID (the `:storeId` path param). */
555
+ storeId: string;
556
+ /** Publishable storefront token — passed as `x-publishable-key`. */
557
+ token?: string;
558
+ /**
559
+ * ISO 3166 alpha-2 (e.g. "TH", "SG", "US"). When set, the backend resolves
560
+ * the matching Market for this country, applies its currency + exchange
561
+ * rate, and returns Money fields in that currency. Falls back to store
562
+ * base currency if no Market matches the country.
563
+ */
564
+ country?: string;
565
+ /**
566
+ * Content language (BCP-47-ish, e.g. "th", "zh-TW"). When set, the backend
567
+ * overlays the merchant's translations for this locale onto product/
568
+ * collection/page content (X-Tanqory-Lang). Falls back to default-language
569
+ * content when a resource has no translation. Independent of `country`.
570
+ */
571
+ locale?: string;
572
+ /** Optional fetch override (testing / SSR). */
573
+ fetcher?: typeof fetch;
574
+ /**
575
+ * Page handle (from `/pages/<handle>`) to fetch alongside the homepage
576
+ * bootstrap. The theme entry resolves the current URL once at boot and
577
+ * passes the matching handle here so the PageBody section can read
578
+ * `dataApi.pageByHandle(handle)` synchronously during hydration.
579
+ */
580
+ pageHandle?: string;
581
+ /** Handle of the product/collection detail route being loaded, so its
582
+ * template variant (templateSuffix) is prefetched into the bootstrap. */
583
+ productHandle?: string;
584
+ collectionHandle?: string;
585
+ /** A policy route: also load the policies' bodies (the shared bootstrap
586
+ * carries only their titles, which left /policies/* with a heading alone). */
587
+ policyBodies?: boolean;
588
+ /** Tune how much to load at boot. */
589
+ prefetch?: {
590
+ /** Max collections to fetch (default 20). */
591
+ collectionLimit?: number;
592
+ /** Max products to inline under each collection (default 24). */
593
+ productLimitPerCollection?: number;
594
+ /** Max products to fetch at the top level (default 24) — these power the
595
+ * synthesized `featured` / `all` virtual collections when the store has
596
+ * no real collections yet. */
597
+ topProductLimit?: number;
598
+ };
599
+ }
600
+ export declare function createLiveData(opts: LiveDataOptions): Promise<DataApi>;
601
+ /**
602
+ * Build a live DataApi SYNCHRONOUSLY from a previously-fetched bootstrap
603
+ * payload (`data.getSnapshot()`, serialized into the SSG HTML as
604
+ * `window.__TQ_STATE__` by the prerender step). This is what makes hydration
605
+ * deterministic: the client's first render uses the EXACT data the server
606
+ * rendered with — no network round-trip, no drift, no mock fallback — and
607
+ * mount()'s `revalidate` swaps in fresh data after hydration (SWR).
608
+ */
609
+ export declare function createLiveDataFromSnapshot(snapshot: unknown, opts: LiveDataOptions): DataApi;
610
+ /** standard `money` — symbol + amount (e.g. "฿120.00"). */
611
+ export declare function formatMoney(money: Money): string;
612
+ /** standard `money_with_currency` — symbol + amount + ISO code (e.g. "฿120.00 THB"). */
613
+ export declare function formatMoneyWithCurrency(money: Money): string;
614
+ /** standard `money_without_currency` — bare grouped amount (e.g. "120.00"). */
615
+ export declare function formatMoneyWithoutCurrency(money: Money): string;
616
+ /** standard `money_without_trailing_zeros` — symbol + amount, dropping a `.00`
617
+ * fraction (e.g. "฿120", but "฿120.50" stays). */
618
+ export declare function formatMoneyWithoutTrailingZeros(money: Money): string;
619
+ /** standard `date` / `time_tag` — format an ISO date deterministically (identical
620
+ * output on server + client to keep SSR hydration stable). Defaults to a medium
621
+ * date; pass Intl options to customize. */
622
+ export declare function formatDate(input: string | number | Date | null | undefined, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
623
+ /** standard `weight_with_unit` — format a variant weight (e.g. "1.5 kg"). */
624
+ export declare function formatWeight(weight: {
625
+ value: number;
626
+ unit: string;
627
+ } | null | undefined): string;
628
+ /** standard `image_url` — append CDN transform params (width/height/crop) to an
629
+ * image URL. No-op when the src is empty or no transform is requested. React
630
+ * themes render the `<img>` themselves, so there is no separate `image_tag`. */
631
+ export declare function imageUrl(src: string | null | undefined, opts?: {
632
+ width?: number;
633
+ height?: number;
634
+ crop?: string;
635
+ }): string;
636
+ export {};