@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
@@ -1,357 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import { type StorefrontExtensions } from './storefront';
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
- }
15
- /** SEO snapshot (Product/Page/Article). */
16
- export interface Seo {
17
- title?: string | null;
18
- description?: string | null;
19
- }
20
- /** Per-variant cart quantity bounds (wholesale / case-of-N). Storefront cart enforces these. */
21
- export interface QuantityRule {
22
- minimum: number;
23
- maximum: number | null;
24
- increment: number;
25
- }
26
- /** Per-unit pricing ("$2.50 / 100ml"). */
27
- export interface UnitPriceMeasurement {
28
- measuredType: string;
29
- quantityValue: number;
30
- quantityUnit: string;
31
- referenceValue: number;
32
- referenceUnit: string;
33
- }
34
- /** Pickup / in-store stock for one location. */
35
- export interface StoreAvailability {
36
- available: boolean;
37
- quantityAvailable: number;
38
- pickUpTime?: string | null;
39
- location: {
40
- id: string;
41
- name: string;
42
- };
43
- }
44
- export interface SellingPlanOption {
45
- name: string;
46
- value: string;
47
- }
48
- export interface SellingPlan {
49
- id: string;
50
- name: string;
51
- description?: string | null;
52
- recurringDeliveries: boolean;
53
- options: SellingPlanOption[];
54
- }
55
- export interface SellingPlanGroup {
56
- name: string;
57
- appName?: string | null;
58
- options: Array<{
59
- name: string;
60
- values: string[];
61
- }>;
62
- sellingPlans: SellingPlan[];
63
- }
64
- export interface ProductVariant {
65
- id: string;
66
- title: string;
67
- price: Money;
68
- /** "Was" price — present when the variant is on sale (compareAtPrice > price). */
69
- compareAtPrice?: Money | null;
70
- availableForSale: boolean;
71
- selectedOptions?: {
72
- name: string;
73
- value: string;
74
- }[];
75
- image?: ImageRef | null;
76
- /** Stock-keeping unit. Only after `fetchProduct()`. */
77
- sku?: string | null;
78
- /** Cart quantity bounds (min/max/increment). */
79
- quantityRule?: QuantityRule;
80
- /** Per-unit price ("$2.50 / 100ml") for measured products. */
81
- unitPrice?: Money | null;
82
- unitPriceMeasurement?: UnitPriceMeasurement | null;
83
- /** Pickup availability per location (only after `fetchProduct()`). */
84
- storeAvailability?: StoreAvailability[];
85
- }
86
- export interface Product {
87
- /** Storefront GraphQL node id (present for live data). */
88
- id?: string;
89
- handle: string;
90
- title: string;
91
- price: Money;
92
- /** Range "was" price (max compareAtPrice across variants) — sale badge on cards. */
93
- compareAtPrice?: Money | null;
94
- featuredImage?: ImageRef | null;
95
- /** Default purchasable variant id (`firstAvailableVariant`) — enough to add
96
- * to cart from a grid/card without loading the full variant list. */
97
- variantId?: string;
98
- availableForSale?: boolean;
99
- /** Catalog facets (card badges / filtering). Present from boot. */
100
- vendor?: string | null;
101
- productType?: string | null;
102
- tags?: string[];
103
- /** Long description — only populated by `fetchProduct()` (PDP). */
104
- description?: string;
105
- /** Image gallery — only after `fetchProduct()` (PDP). */
106
- images?: ImageRef[];
107
- /** Option definitions (Size, Color…) — only after `fetchProduct()`. */
108
- options?: ProductOption[];
109
- /** Full variant list — only after `fetchProduct()` (PDP). */
110
- variants?: ProductVariant[];
111
- /** Subscription / selling-plan groups — only after `fetchProduct()`. */
112
- sellingPlanGroups?: SellingPlanGroup[];
113
- /** Requested custom metafields ("namespace.key" → value) — pass identifiers to fetchProduct(). */
114
- metafields?: Record<string, string | null>;
115
- /** SEO override — only after `fetchProduct()`. */
116
- seo?: Seo | null;
117
- }
118
- export interface Collection {
119
- handle: string;
120
- title: string;
121
- /** Optional hero image; falls back to first product's featuredImage. */
122
- image?: {
123
- url?: string;
124
- altText?: string;
125
- } | null;
126
- products: Product[];
127
- /** Custom metafields ("namespace.key" → value) for dynamic sources. */
128
- metafields?: Record<string, string | null>;
129
- }
130
- export interface Page {
131
- handle: string;
132
- title: string;
133
- /** HTML body — rendered via dangerouslySetInnerHTML by the PageBody section. */
134
- body: string;
135
- bodySummary?: string;
136
- author?: string | null;
137
- publishedAt?: string;
138
- updatedAt?: string;
139
- }
140
- /**
141
- * The data interface every block consumes. Themes provide an implementation.
142
- *
143
- * Core read methods (collections/products/pages/localization) are always
144
- * present. The Shopify-compatible extensions (shop, menus, search, blog,
145
- * recommendations, metaobjects, customer account) come from `StorefrontExtensions`
146
- * and are LIVE-ONLY — undefined under mock data, so themes feature-detect them
147
- * (`data.search?.(...)`, `data.customer?.login(...)`).
148
- */
149
- export interface DataApi extends StorefrontExtensions {
150
- collectionByHandle: (handle: string) => Collection | null;
151
- /** All known collections (used by CollectionList). */
152
- allCollections: () => Collection[];
153
- /**
154
- * List every navigation menu the store has (Dashboard → Navigation), for the
155
- * editor's `link_list` picker. Identity only (handle/title/count) — fetch a
156
- * menu's items with `fetchMenu(handle)`. Optional: older payloads may omit it.
157
- */
158
- listMenus?: () => Promise<Array<{
159
- handle: string;
160
- title: string;
161
- itemsCount: number;
162
- }>>;
163
- /** Connected tracking pixels (Settings → Customer events) to inject on the
164
- * storefront. Optional — older payloads / mock mode return []. */
165
- pixels?: () => Promise<Array<{
166
- id: string;
167
- name: string;
168
- provider: string | null;
169
- providerPixelId: string | null;
170
- code: string | null;
171
- }>>;
172
- /** Physical store locations (Settings → Locations) for a store-locator. */
173
- locations?: () => Promise<Array<{
174
- id: string;
175
- name: string;
176
- code: string | null;
177
- address: {
178
- country: string | null;
179
- address: string | null;
180
- city: string | null;
181
- province: string | null;
182
- postalCode: string | null;
183
- phone: string | null;
184
- } | null;
185
- }>>;
186
- /**
187
- * Look up a single product by its handle. Returns null when the handle
188
- * isn't found. Required by FeaturedProduct / ProductDetails sections
189
- * (ported from the canonical examples/react theme in PR #2).
190
- */
191
- productByHandle: (handle: string) => Product | null;
192
- /**
193
- * Look up a Page by handle (the storefront's `/pages/<handle>` content).
194
- * Returns null if the handle wasn't prefetched at boot or the merchant
195
- * hasn't published a page with that handle. Live data prefetches only the
196
- * page matching the current URL, so other handles return null even when
197
- * they exist in the backend — themes should only call this for the page
198
- * the user is on.
199
- */
200
- pageByHandle: (handle: string) => Page | null;
201
- /** Localization snapshot — what markets/countries the store has live.
202
- * null = mock data; the country switcher should hide itself. */
203
- localization: Localization | null;
204
- /**
205
- * Raw GraphQL escape hatch against the same storefront endpoint the live
206
- * data source was booted with. Present ONLY for live data — undefined for
207
- * mock data. Powers post-boot interactions (the cart's mutations live here).
208
- */
209
- graphql?: <T = unknown>(query: string, variables?: Record<string, unknown>) => Promise<T>;
210
- /**
211
- * Fetch a single product WITH its full options + variants on demand (for the
212
- * product page's variant picker). Live data hits the backend; mock data
213
- * resolves synchronously from the prefetched cache. Returns null if missing.
214
- */
215
- fetchProduct?: (handle: string, opts?: {
216
- metafields?: Array<{
217
- namespace: string;
218
- key: string;
219
- }>;
220
- }) => Promise<Product | null>;
221
- /**
222
- * Fetch the shop's custom metafields by identifier (for dynamic sources).
223
- * Live data queries `shop { metafields(identifiers) }`; mock data returns {}
224
- * (no metafields offline). Result keys are "namespace.key".
225
- */
226
- fetchShopMetafields?: (identifiers: Array<{
227
- namespace: string;
228
- key: string;
229
- }>) => Promise<Record<string, string | null>>;
230
- /**
231
- * Fetch a collection's custom metafields by identifier (for dynamic sources).
232
- * Result keys are "namespace.key".
233
- */
234
- fetchCollectionMetafields?: (handle: string, identifiers: Array<{
235
- namespace: string;
236
- key: string;
237
- }>) => Promise<Record<string, string | null>>;
238
- /**
239
- * The raw serializable bootstrap payload this live DataApi was built from
240
- * (null for mock data). The SSG step embeds it into the page as
241
- * `window.__TQ_STATE__` so the client can rebuild the identical DataApi
242
- * synchronously at hydration via createLiveDataFromSnapshot — SSR markup and
243
- * the client's first render match by construction.
244
- */
245
- getSnapshot?: () => unknown;
246
- }
247
- /** Country/market shape mirrored from storefront GraphQL `Localization`. */
248
- export interface LocalizedCurrency {
249
- isoCode: string;
250
- name?: string;
251
- symbol?: string;
252
- }
253
- export interface LocalizedMarket {
254
- id: string;
255
- handle: string;
256
- name: string;
257
- }
258
- export interface LocalizedCountry {
259
- isoCode: string;
260
- name: string;
261
- currency: LocalizedCurrency;
262
- market: LocalizedMarket | null;
263
- }
264
- /** A language the store has published (dashboard → Markets / Languages). */
265
- export interface LocalizedLanguage {
266
- isoCode: string;
267
- name: string;
268
- }
269
- export interface Localization {
270
- /** Currently-active country (resolved from the request's X-Tanqory-Country). */
271
- country: LocalizedCountry;
272
- /** Every country the store has an active Market for — what the picker shows. */
273
- availableCountries: LocalizedCountry[];
274
- /**
275
- * Currently-active language + every language the store has PUBLISHED. These
276
- * are STORE/dashboard data (the merchant's published locales), not a theme
277
- * config list — the theme only ships the translations. Optional so older live
278
- * payloads (countries only) still satisfy the type; the picker falls back to a
279
- * single default when absent.
280
- */
281
- language?: LocalizedLanguage;
282
- availableLanguages?: LocalizedLanguage[];
283
- }
284
- /** Wraps the app with a theme-provided data source (mock or live). */
285
- export declare function DataProvider({ value, children }: {
286
- value: DataApi;
287
- children: ReactNode;
288
- }): JSX.Element;
289
- export declare function useData(): DataApi;
290
- /** Build an offline data source from fixture collections (theme passes its JSON). */
291
- export declare function createMockData(collections: Collection[]): DataApi;
292
- /**
293
- * Live data source backed by the Tanqory Storefront GraphQL API.
294
- *
295
- * const data = await createLiveData({
296
- * endpoint: 'https://api-do-sgp1.tanqory.com',
297
- * storeId: '<store-uuid>',
298
- * token: '<publishable-storefront-token>',
299
- * prefetch: { collectionLimit: 20, productLimitPerCollection: 24 },
300
- * })
301
- *
302
- * Returns the same `DataApi` shape as `createMockData` (sync read methods)
303
- * by pre-fetching collections + their products at boot and serving every
304
- * subsequent lookup from an in-memory cache. The trade-off: a single GraphQL
305
- * round-trip at boot, then zero network on render — exactly what the SSG
306
- * step + first hydration need.
307
- *
308
- * Per-handle pages (e.g. /products/<handle>) that miss the prefetch can
309
- * still be fetched lazily via `dataApi.refresh()` (TODO) — for now, raise
310
- * `prefetch.productLimitPerCollection` to cover the catalogue size.
311
- */
312
- export interface LiveDataOptions {
313
- /** Base URL of the store-api (e.g. https://api-do-sgp1.tanqory.com). */
314
- endpoint: string;
315
- /** Store UUID (the `:storeId` path param). */
316
- storeId: string;
317
- /** Publishable storefront token — passed as `x-publishable-key`. */
318
- token?: string;
319
- /**
320
- * ISO 3166 alpha-2 (e.g. "TH", "SG", "US"). When set, the backend resolves
321
- * the matching Market for this country, applies its currency + exchange
322
- * rate, and returns Money fields in that currency. Falls back to store
323
- * base currency if no Market matches the country.
324
- */
325
- country?: string;
326
- /** Optional fetch override (testing / SSR). */
327
- fetcher?: typeof fetch;
328
- /**
329
- * Page handle (from `/pages/<handle>`) to fetch alongside the homepage
330
- * bootstrap. The theme entry resolves the current URL once at boot and
331
- * passes the matching handle here so the PageBody section can read
332
- * `dataApi.pageByHandle(handle)` synchronously during hydration.
333
- */
334
- pageHandle?: string;
335
- /** Tune how much to load at boot. */
336
- prefetch?: {
337
- /** Max collections to fetch (default 20). */
338
- collectionLimit?: number;
339
- /** Max products to inline under each collection (default 24). */
340
- productLimitPerCollection?: number;
341
- /** Max products to fetch at the top level (default 24) — these power the
342
- * synthesized `featured` / `all` virtual collections when the store has
343
- * no real collections yet. */
344
- topProductLimit?: number;
345
- };
346
- }
347
- export declare function createLiveData(opts: LiveDataOptions): Promise<DataApi>;
348
- /**
349
- * Build a live DataApi SYNCHRONOUSLY from a previously-fetched bootstrap
350
- * payload (`data.getSnapshot()`, serialized into the SSG HTML as
351
- * `window.__TQ_STATE__` by the prerender step). This is what makes hydration
352
- * deterministic: the client's first render uses the EXACT data the server
353
- * rendered with — no network round-trip, no drift, no mock fallback — and
354
- * mount()'s `revalidate` swaps in fresh data after hydration (SWR).
355
- */
356
- export declare function createLiveDataFromSnapshot(snapshot: unknown, opts: LiveDataOptions): DataApi;
357
- export declare function formatMoney(money: Money): string;
@@ -1,5 +0,0 @@
1
- import type { ContentNode } from './types';
2
- export declare function Editor({ pages, initialPage }: {
3
- pages: Record<string, ContentNode[]>;
4
- initialPage?: string;
5
- }): JSX.Element;
@@ -1,20 +0,0 @@
1
- export { defineSection } from './defineSection';
2
- export { defineTheme, defineSettings, type ThemeConfig, type SettingsSchema } from './config';
3
- export { ThemeProvider, useSettings, useT } from './theme-context';
4
- export { mount, type MountOptions } from './mount';
5
- export { renderStorefrontHTML, renderSectionPreviewHTML } from './ssg';
6
- export { SectionTree } from './SectionTree';
7
- export { Editor } from './editor';
8
- export { registerSections, getSection, allSections } from './registry';
9
- export { DataProvider, useData, createMockData, createLiveData, createLiveDataFromSnapshot, formatMoney, } from './data';
10
- export { CartProvider, useCart } from './cart';
11
- export { DynamicSourceProvider, useResourceContext, useBound, useBoundText, isBoundSource, resolveBoundSource, collectBoundIdentifiers, } from './dynamic-source';
12
- export type { Bound, BoundSource, ResourceContextValue } from './dynamic-source';
13
- export type { CartApi, CartLine, CartState, AddToCartInput, AppliedDiscountCode, AppliedGiftCard, } from './cart';
14
- export type { LiveDataOptions, Localization, LocalizedCountry, LocalizedMarket, LocalizedCurrency, ProductOption, ProductVariant, ImageRef, QuantityRule, UnitPriceMeasurement, StoreAvailability, SellingPlan, SellingPlanOption, SellingPlanGroup, } from './data';
15
- export { jsxToJSON } from './jsx-to-json';
16
- export { tag, type Tag } from './composition';
17
- export type { Money, Product, Collection, DataApi } from './data';
18
- export type { SectionDef, SectionProps, ContentNode, PageDoc, AttrSpec } from './types';
19
- export { customerTokenStore } from './storefront';
20
- export type { StorefrontExtensions, Menu, MenuItem, MenuItemType, Blog, Article, SearchResults, CollectionProductsPage, PredictiveSearchResults, PageInfo, Filter, Metaobject, MetaobjectField, Shop, ShopPolicy, Image as StorefrontImage, Seo, CustomerApi, Customer, CustomerAddress, CustomerAddressInput, Order, OrderLineItem, AuthResult, MutationResult, } from './storefront';
@@ -1,9 +0,0 @@
1
- import { type FC, type ReactNode } from 'react';
2
- import type { ContentNode } from './types';
3
- export declare function PreviewBridge({ pages, initialPage, Shell, }: {
4
- pages: Record<string, ContentNode[]>;
5
- initialPage: string;
6
- Shell: FC<{
7
- children: ReactNode;
8
- }>;
9
- }): JSX.Element;