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

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 (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -10
  3. package/dist/abi/canvas-live.d.ts +72 -0
  4. package/dist/abi/canvas-live.js +159 -0
  5. package/dist/abi/cart.d.ts +60 -0
  6. package/dist/abi/cart.js +396 -0
  7. package/dist/abi/convert.d.ts +360 -0
  8. package/dist/abi/convert.js +1330 -0
  9. package/dist/abi/data-api.d.ts +15 -0
  10. package/dist/abi/data-api.js +213 -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 +264 -0
  16. package/dist/abi/page-data.js +746 -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 +46 -0
  30. package/dist/abi/wire.js +114 -0
  31. package/dist/build.d.ts +121 -0
  32. package/dist/build.js +401 -0
  33. package/dist/chunks.d.ts +23 -0
  34. package/dist/chunks.js +41 -0
  35. package/dist/client.d.ts +26 -0
  36. package/dist/client.js +101 -0
  37. package/dist/contract.d.ts +6 -0
  38. package/dist/contract.js +6 -0
  39. package/dist/headless/ai.d.ts +132 -0
  40. package/dist/headless/ai.js +99 -0
  41. package/dist/headless/hooks.d.ts +276 -0
  42. package/dist/headless/hooks.js +544 -0
  43. package/dist/headless/i18n.d.ts +13 -0
  44. package/dist/headless/i18n.js +45 -0
  45. package/dist/headless/index.d.ts +44 -0
  46. package/dist/headless/index.js +48 -0
  47. package/dist/headless/lazy-component.d.ts +72 -0
  48. package/dist/headless/lazy-component.js +225 -0
  49. package/dist/headless/lazy-section.d.ts +38 -0
  50. package/dist/headless/lazy-section.js +97 -0
  51. package/dist/headless/model.d.ts +73 -0
  52. package/dist/headless/model.js +115 -0
  53. package/dist/headless/money.d.ts +17 -0
  54. package/dist/headless/money.js +63 -0
  55. package/dist/headless/page.d.ts +45 -0
  56. package/dist/headless/page.js +53 -0
  57. package/dist/headless/platform.d.ts +55 -0
  58. package/dist/headless/platform.js +77 -0
  59. package/dist/headless/primitives/cart.d.ts +90 -0
  60. package/dist/headless/primitives/cart.js +153 -0
  61. package/dist/headless/primitives/collection.d.ts +68 -0
  62. package/dist/headless/primitives/collection.js +80 -0
  63. package/dist/headless/primitives/product.d.ts +101 -0
  64. package/dist/headless/primitives/product.js +117 -0
  65. package/dist/headless/primitives/storefront.d.ts +106 -0
  66. package/dist/headless/primitives/storefront.js +187 -0
  67. package/dist/headless/primitives/util.d.ts +19 -0
  68. package/dist/headless/primitives/util.js +42 -0
  69. package/dist/headless/strings.d.ts +9 -0
  70. package/dist/headless/strings.js +198 -0
  71. package/dist/headless/structured-data.d.ts +31 -0
  72. package/dist/headless/structured-data.js +57 -0
  73. package/dist/headless/tanqory-money.generated.d.ts +493 -0
  74. package/dist/headless/tanqory-money.generated.js +507 -0
  75. package/dist/headless/theme.d.ts +109 -0
  76. package/dist/headless/theme.js +62 -0
  77. package/dist/index.d.ts +21 -0
  78. package/dist/index.js +21 -553
  79. package/dist/runtime/data/StoreProvider.d.ts +84 -0
  80. package/dist/runtime/data/StoreProvider.js +380 -0
  81. package/dist/runtime/data/handle.d.ts +14 -0
  82. package/dist/runtime/data/handle.js +16 -0
  83. package/dist/runtime/data/routes.d.ts +87 -0
  84. package/dist/runtime/data/routes.js +158 -0
  85. package/dist/runtime/data/to-ui.d.ts +286 -0
  86. package/dist/runtime/data/to-ui.js +1009 -0
  87. package/dist/runtime/entries/register.d.ts +9 -0
  88. package/dist/runtime/entries/register.js +9 -0
  89. package/dist/runtime/entries/sections.d.ts +16 -0
  90. package/dist/runtime/entries/sections.js +19 -0
  91. package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
  92. package/dist/runtime/kit/SectionTree.js +100 -0
  93. package/dist/runtime/kit/analytics.d.ts +63 -0
  94. package/dist/runtime/kit/analytics.js +250 -0
  95. package/dist/runtime/kit/cart.d.ts +222 -0
  96. package/dist/runtime/kit/cart.js +545 -0
  97. package/dist/{types → runtime/kit}/composition.d.ts +1 -1
  98. package/dist/runtime/kit/composition.js +3 -0
  99. package/dist/{types → runtime/kit}/config.d.ts +2 -2
  100. package/dist/runtime/kit/config.js +6 -0
  101. package/dist/runtime/kit/consent.d.ts +29 -0
  102. package/dist/runtime/kit/consent.js +159 -0
  103. package/dist/runtime/kit/contract/content.d.ts +213 -0
  104. package/dist/runtime/kit/contract/content.js +119 -0
  105. package/dist/runtime/kit/contract/field-types.d.ts +360 -0
  106. package/dist/runtime/kit/contract/field-types.js +216 -0
  107. package/dist/runtime/kit/contract/groups.d.ts +230 -0
  108. package/dist/runtime/kit/contract/groups.js +402 -0
  109. package/dist/runtime/kit/contract/index.d.ts +33 -0
  110. package/dist/runtime/kit/contract/index.js +33 -0
  111. package/dist/runtime/kit/contract/transform.d.ts +82 -0
  112. package/dist/runtime/kit/contract/transform.js +133 -0
  113. package/dist/runtime/kit/contract/validate.d.ts +77 -0
  114. package/dist/runtime/kit/contract/validate.js +520 -0
  115. package/dist/runtime/kit/data.d.ts +732 -0
  116. package/dist/runtime/kit/data.js +1131 -0
  117. package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
  118. package/dist/runtime/kit/defineSection.js +10 -0
  119. package/dist/runtime/kit/dynamic-source.d.ts +118 -0
  120. package/dist/runtime/kit/dynamic-source.js +311 -0
  121. package/dist/runtime/kit/index.d.ts +24 -0
  122. package/dist/runtime/kit/index.js +24 -0
  123. package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
  124. package/dist/runtime/kit/jsx-to-json.js +28 -0
  125. package/dist/{types → runtime/kit}/mount.d.ts +25 -4
  126. package/dist/runtime/kit/mount.js +124 -0
  127. package/dist/{types → runtime/kit}/registry.d.ts +1 -1
  128. package/dist/runtime/kit/registry.js +12 -0
  129. package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
  130. package/dist/runtime/kit/ssg.js +56 -0
  131. package/dist/runtime/kit/storefront.d.ts +652 -0
  132. package/dist/runtime/kit/storefront.js +723 -0
  133. package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
  134. package/dist/runtime/kit/theme-context.js +25 -0
  135. package/dist/runtime/kit/types.d.ts +155 -0
  136. package/dist/runtime/kit/types.js +1 -0
  137. package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
  138. package/dist/runtime/platform/TrackingPixels.js +63 -0
  139. package/dist/runtime/platform/environment.d.ts +68 -0
  140. package/dist/runtime/platform/environment.js +85 -0
  141. package/dist/runtime/platform/locale.d.ts +27 -0
  142. package/dist/runtime/platform/locale.js +42 -0
  143. package/dist/runtime/platform/route-analytics.d.ts +15 -0
  144. package/dist/runtime/platform/route-analytics.js +72 -0
  145. package/dist/runtime/platform/safe-href.d.ts +25 -0
  146. package/dist/runtime/platform/safe-href.js +69 -0
  147. package/dist/runtime/platform/safe-values.d.ts +37 -0
  148. package/dist/runtime/platform/safe-values.js +140 -0
  149. package/dist/runtime/render/SectionRenderer.d.ts +4 -0
  150. package/dist/runtime/render/SectionRenderer.js +199 -0
  151. package/dist/runtime/render/listing-query.d.ts +52 -0
  152. package/dist/runtime/render/listing-query.js +122 -0
  153. package/dist/runtime/render/localized-copy.d.ts +86 -0
  154. package/dist/runtime/render/localized-copy.js +129 -0
  155. package/dist/runtime/render/product-listing.d.ts +11 -0
  156. package/dist/runtime/render/product-listing.js +243 -0
  157. package/dist/runtime/render/resolved.d.ts +47 -0
  158. package/dist/runtime/render/resolved.js +80 -0
  159. package/dist/runtime/render/section-actions.d.ts +67 -0
  160. package/dist/runtime/render/section-actions.js +205 -0
  161. package/dist/runtime/render/starter.d.ts +11 -0
  162. package/dist/runtime/render/starter.js +96 -0
  163. package/dist/runtime/seo/head.d.ts +115 -0
  164. package/dist/runtime/seo/head.js +281 -0
  165. package/dist/runtime/seo/structured-data.d.ts +83 -0
  166. package/dist/runtime/seo/structured-data.js +252 -0
  167. package/dist/runtime/shell/PageShell.d.ts +18 -0
  168. package/dist/runtime/shell/PageShell.js +118 -0
  169. package/dist/runtime/shell/RuntimeBridge.d.ts +18 -0
  170. package/dist/runtime/shell/RuntimeBridge.js +124 -0
  171. package/dist/runtime/shell/overlay-state.d.ts +31 -0
  172. package/dist/runtime/shell/overlay-state.js +59 -0
  173. package/dist/runtime/shell/preview-mode.d.ts +2 -0
  174. package/dist/runtime/shell/preview-mode.js +11 -0
  175. package/dist/runtime/shell/spa-router.d.ts +14 -0
  176. package/dist/runtime/shell/spa-router.js +76 -0
  177. package/dist/runtime/shell/url-redirects.d.ts +6 -0
  178. package/dist/runtime/shell/url-redirects.js +37 -0
  179. package/dist/runtime/slots.d.ts +74 -0
  180. package/dist/runtime/slots.js +16 -0
  181. package/dist/runtime.d.ts +34 -0
  182. package/dist/runtime.js +40 -0
  183. package/dist/sdk/app-block.d.ts +29 -0
  184. package/dist/sdk/app-block.js +22 -0
  185. package/dist/sdk/font-hooks.d.ts +7 -0
  186. package/dist/sdk/font-hooks.js +21 -0
  187. package/dist/sdk/fonts.d.ts +144 -0
  188. package/dist/sdk/fonts.js +241 -0
  189. package/dist/sdk/index.d.ts +32 -0
  190. package/dist/sdk/index.js +36 -0
  191. package/dist/sdk/motion-hooks.d.ts +23 -0
  192. package/dist/sdk/motion-hooks.js +46 -0
  193. package/dist/sdk/motion.d.ts +78 -0
  194. package/dist/sdk/motion.js +292 -0
  195. package/dist/sdk/referrals.d.ts +62 -0
  196. package/dist/sdk/referrals.js +20 -0
  197. package/dist/sdk/rewards.d.ts +85 -0
  198. package/dist/sdk/rewards.js +29 -0
  199. package/dist/sdk/runtime-context.d.ts +230 -0
  200. package/dist/sdk/runtime-context.js +73 -0
  201. package/dist/sdk/schema.d.ts +249 -0
  202. package/dist/sdk/schema.js +168 -0
  203. package/dist/sdk/server-render.d.ts +8 -0
  204. package/dist/sdk/server-render.js +12 -0
  205. package/dist/sdk/store-lookup.d.ts +32 -0
  206. package/dist/sdk/store-lookup.js +48 -0
  207. package/dist/sdk/store.d.ts +164 -0
  208. package/dist/sdk/store.js +5 -0
  209. package/dist/sdk/sx.d.ts +45 -0
  210. package/dist/sdk/sx.js +117 -0
  211. package/dist/sdk/theme.d.ts +212 -0
  212. package/dist/sdk/theme.js +27 -0
  213. package/dist/sdk/types.d.ts +789 -0
  214. package/dist/sdk/types.js +7 -0
  215. package/dist/server.d.ts +112 -0
  216. package/dist/server.js +589 -0
  217. package/dist/vite-chunks.d.ts +10 -0
  218. package/dist/vite-chunks.js +44 -0
  219. package/docs/headless-api.md +250 -0
  220. package/package.json +72 -26
  221. package/dist/index.js.map +0 -1
  222. package/dist/ssg-BZ5FYTw7.js +0 -1802
  223. package/dist/ssg-BZ5FYTw7.js.map +0 -1
  224. package/dist/ssg.js +0 -8
  225. package/dist/ssg.js.map +0 -1
  226. package/dist/types/cart.d.ts +0 -86
  227. package/dist/types/data.d.ts +0 -357
  228. package/dist/types/dynamic-source.d.ts +0 -84
  229. package/dist/types/editor.d.ts +0 -5
  230. package/dist/types/index.d.ts +0 -20
  231. package/dist/types/preview-bridge.d.ts +0 -9
  232. package/dist/types/storefront.d.ts +0 -333
  233. package/dist/types/types.d.ts +0 -44
@@ -0,0 +1,158 @@
1
+ /**
2
+ * The theme's ONE route table.
3
+ *
4
+ * `resolveTemplate` used to exist twice, byte-for-byte, in `browser-entry.tsx` and
5
+ * `layouts/layout.tsx`, each with a comment asking the next person to keep them
6
+ * in sync. They drive different things — the entry picks the template to mount,
7
+ * the layout picks the template to swap in on a soft navigation — so a route
8
+ * added to one and not the other renders a 404 on exactly one of the two paths.
9
+ *
10
+ * Route matching lives here. Anything that needs "what does this URL mean" reads
11
+ * it from this module.
12
+ */
13
+ import { decodeHandle } from './handle.js';
14
+ /** Strip the trailing slash(es) from a pathname, keeping "/" itself. */
15
+ function normalize(pathname) {
16
+ return pathname !== '/' ? pathname.replace(/\/+$/, '') || '/' : '/';
17
+ }
18
+ /**
19
+ * Match a URL pathname to a template + the resource it addresses.
20
+ *
21
+ * Order matters: `/blogs/<blog>/<article>` must be tested BEFORE
22
+ * `/blogs/<handle>` so the blog list doesn't shadow article detail.
23
+ */
24
+ export function matchRoute(pathname) {
25
+ const p = normalize(pathname);
26
+ if (p === '/')
27
+ return { template: 'index' };
28
+ if (p === '/cart')
29
+ return { template: 'cart' };
30
+ if (p === '/search')
31
+ return { template: 'search' };
32
+ if (p === '/contact')
33
+ return { template: 'contact' };
34
+ if (p === '/404')
35
+ return { template: '404' };
36
+ if (p === '/collections')
37
+ return { template: 'list-collections' };
38
+ let m;
39
+ if ((m = p.match(/^\/collections\/([^/]+)$/)))
40
+ return { template: 'collection', resource: 'collection', handle: decodeHandle(m[1]) };
41
+ if ((m = p.match(/^\/products\/([^/]+)$/)))
42
+ return { template: 'product', resource: 'product', handle: decodeHandle(m[1]) };
43
+ if ((m = p.match(/^\/pages\/([^/]+)$/)))
44
+ return { template: 'page', resource: 'page', handle: decodeHandle(m[1]) };
45
+ // A metaobject entry's web page (Theme ABI route kind `metaobject`): the handle is `<definition>/<entry>`, as the
46
+ // platform's `route.handle`. Its template is the platform's choice (the entry's type), never resolved here.
47
+ if ((m = p.match(/^\/pages\/([^/]+)\/([^/]+)$/)))
48
+ return { template: 'metaobject', resource: 'metaobject', handle: `${decodeHandle(m[1])}/${decodeHandle(m[2])}` };
49
+ // Shop policies (Settings) — a menu item of type "Policy" links to
50
+ // /policies/<handle> (privacy-policy, refund-policy, …).
51
+ if ((m = p.match(/^\/policies\/([^/]+)$/)))
52
+ return { template: 'policy', resource: 'policy', handle: decodeHandle(m[1]) };
53
+ // Customer account — /account and its sub-routes (login, orders, addresses).
54
+ if (p === '/account' || /^\/account\/[^/]+/.test(p))
55
+ return { template: 'account' };
56
+ // A blog filtered to one tag — the blog's own template, narrowed.
57
+ if ((m = p.match(/^\/blogs\/([^/]+)\/tagged\/([^/]+)$/)))
58
+ return { template: 'blog', resource: 'blog', handle: decodeHandle(m[1]), tag: decodeHandle(m[2]) };
59
+ if ((m = p.match(/^\/blogs\/([^/]+)\/([^/]+)$/)))
60
+ return {
61
+ template: 'article',
62
+ resource: 'article',
63
+ blogHandle: decodeHandle(m[1]),
64
+ handle: decodeHandle(m[2]),
65
+ };
66
+ if ((m = p.match(/^\/blogs\/([^/]+)$/)))
67
+ return { template: 'blog', resource: 'blog', handle: decodeHandle(m[1]) };
68
+ return { template: '404' };
69
+ }
70
+ /** Base template name for a pathname. */
71
+ export function resolveTemplate(pathname) {
72
+ return matchRoute(pathname).template;
73
+ }
74
+ /** The handle a pathname addresses for a given resource kind, else undefined. */
75
+ export function routeHandle(pathname, resource) {
76
+ const match = matchRoute(pathname);
77
+ return match.resource === resource ? match.handle : undefined;
78
+ }
79
+ /**
80
+ * The detail-route handle variables the bootstrap query should prefetch, so a
81
+ * record's `templateSuffix` is known before the template is chosen.
82
+ */
83
+ export function detailHandles(pathname) {
84
+ const m = matchRoute(pathname);
85
+ if (m.resource === 'policy')
86
+ return { policyBodies: true };
87
+ if (m.resource === 'page' && m.handle)
88
+ return { pageHandle: m.handle };
89
+ if (m.resource === 'product' && m.handle)
90
+ return { productHandle: m.handle };
91
+ if (m.resource === 'collection' && m.handle)
92
+ return { collectionHandle: m.handle };
93
+ return {};
94
+ }
95
+ /**
96
+ * `<base>.<suffix>` when the theme ships that template file, else `<base>`.
97
+ *
98
+ * `templateExists` is injected rather than globbed here so the entry and the
99
+ * layout can each pass the glob they already hold, and so this module stays
100
+ * testable without Vite.
101
+ */
102
+ export function variantOf(base, suffix, templateExists) {
103
+ const candidate = suffix ? `${base}.${suffix}` : base;
104
+ return templateExists(candidate) ? candidate : base;
105
+ }
106
+ /**
107
+ * The template to actually render for a pathname, including the merchant's
108
+ * per-resource template assignment (`templateSuffix`).
109
+ *
110
+ * This is the function the SPA router was missing: soft navigation looked up
111
+ * the BASE template only, so a product assigned `product.bundle` rendered
112
+ * `product` once the shopper arrived by clicking rather than by URL.
113
+ *
114
+ * Blog and article suffixes are resolved asynchronously by the caller (they are
115
+ * not in the sync bootstrap), so they are left at their base here.
116
+ */
117
+ export function resolvePageTemplate(pathname, data, templateExists) {
118
+ const m = matchRoute(pathname);
119
+ if (!m.resource || !m.handle)
120
+ return m.template;
121
+ let suffix;
122
+ if (m.resource === 'product')
123
+ suffix = data.productByHandle(m.handle)?.templateSuffix;
124
+ else if (m.resource === 'collection')
125
+ suffix = data.collectionByHandle(m.handle)?.templateSuffix;
126
+ else if (m.resource === 'page')
127
+ suffix = data.pageByHandle(m.handle)?.templateSuffix;
128
+ else
129
+ return m.template;
130
+ return variantOf(m.template, suffix, templateExists);
131
+ }
132
+ /**
133
+ * Blog and article records — and any page but the landing one — are not in the sync bootstrap, so their
134
+ * `templateSuffix` (`blog.featured`, `article.longform`) is looked up here —
135
+ * by the server before it renders, and by the SPA router before it swaps the
136
+ * tree. Any other route keeps the template it already resolved.
137
+ */
138
+ export async function resolveAsyncVariant(route, resolved, data, templateExists) {
139
+ try {
140
+ if (route.resource === 'article' && route.blogHandle && route.handle && data.articleByHandle) {
141
+ const a = await data.articleByHandle(route.blogHandle, route.handle);
142
+ return variantOf('article', a?.templateSuffix, templateExists);
143
+ }
144
+ if (route.resource === 'page' && route.handle && data.fetchPage) {
145
+ const p = await data.fetchPage(route.handle);
146
+ return variantOf('page', p?.templateSuffix, templateExists);
147
+ }
148
+ if (route.resource === 'blog' && route.handle && data.blogByHandle) {
149
+ // The same request the blog's sections make (12 posts), so it is answered once.
150
+ const b = await data.blogByHandle(route.handle, { articles: 12 });
151
+ return variantOf('blog', b?.templateSuffix, templateExists);
152
+ }
153
+ }
154
+ catch {
155
+ /* an unreachable record keeps its base template */
156
+ }
157
+ return resolved;
158
+ }
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Runtime shapes → UI shapes.
3
+ *
4
+ * app/platform/tanqory (DataApi · storefront · cart) ──► to-ui.ts ──► ui/types
5
+ *
6
+ * Every function here is PURE and TOTAL: no fetching, no globals, no throwing on
7
+ * a missing optional field. The runtime's payloads are partial by design — a
8
+ * card listing has no variants, the offline fixture has no ids or image
9
+ * dimensions, an older payload has no languages — so every read is guarded.
10
+ *
11
+ * Two rules decide what an absent value becomes:
12
+ * - A UI field that is optional (or nullable) stays undefined / null.
13
+ * - A UI field that is required gets the documented empty value ('' / [] / 0),
14
+ * never a made-up one. Nothing here invents a price, stock level, rating,
15
+ * review, badge or policy text.
16
+ *
17
+ * Money keeps the precision the backend sent: the runtime carries decimal
18
+ * strings ("5000" for JPY, "8.750" for KWD); the UI carries numbers and lets
19
+ * Intl pick the decimals when it formats. Nothing here rounds.
20
+ */
21
+ import type * as R from '../kit/data.js';
22
+ import type * as S from '../kit/storefront.js';
23
+ import type * as C from '../kit/cart.js';
24
+ import type * as UI from '../../sdk/index.js';
25
+ export declare const productUrl: (handle: string) => string;
26
+ export declare const collectionUrl: (handle: string) => string;
27
+ export declare const pageUrl: (handle: string) => string;
28
+ export declare const blogUrl: (handle: string) => string;
29
+ export declare const articleUrl: (blogHandle: string, articleHandle: string) => string;
30
+ export declare const policyUrl: (handle: string) => string;
31
+ type ImageLike = {
32
+ url?: string | null;
33
+ altText?: string | null;
34
+ width?: number | null;
35
+ height?: number | null;
36
+ } | null | undefined;
37
+ /**
38
+ * A runtime image → Image, or null when there is no URL.
39
+ *
40
+ * `width`/`height` are required by the UI type but optional in the runtime (the
41
+ * offline fixture, collection images, article images and the theme logo setting
42
+ * carry none). An unknown dimension is `0` — "unknown", never a guessed size.
43
+ * UI images are CSS-sized (`width:100%; height:100%; object-fit`), and a
44
+ * `0 / 0` aspect-ratio is invalid CSS, so the frame keeps its own ratio.
45
+ */
46
+ export declare function toImage(img: ImageLike): UI.Image | null;
47
+ /** Decimal string → number, keeping every digit the source sent. null when absent or not a number. */
48
+ export declare function toMoney(m: {
49
+ amount?: string | number | null;
50
+ currencyCode?: string | null;
51
+ } | null | undefined): UI.Money | null;
52
+ /**
53
+ * A runtime variant → ProductVariant.
54
+ *
55
+ * `quantityAvailable` is the on-hand count only when it LIMITS a purchase:
56
+ * `inventoryPolicy: CONTINUE` sells past zero, so there is no cap, and a
57
+ * negative count under DENY means nothing is purchasable (0). Unknown — no
58
+ * count, or a count that does not limit — is an ABSENT key, never 0 or null.
59
+ */
60
+ export declare function toVariant(v: R.ProductVariant, fallbackCurrency?: string): UI.ProductVariant;
61
+ /**
62
+ * A runtime product → Product.
63
+ *
64
+ * The runtime has two product shapes: the CARD (bootstrap, collection pages,
65
+ * search, recommendations) with one price, one compare-at and no variants; and
66
+ * the DETAIL (`fetchProduct`) with options + variants. Ranges come from the
67
+ * variants when they are there. On a card the runtime knows only the minimum
68
+ * price and the maximum compare-at, so both ends of each range are that one
69
+ * value — see the data-gap notes in the report.
70
+ */
71
+ export declare function toProduct(p: R.Product): UI.Product;
72
+ export declare const toProducts: (list: readonly R.Product[] | null | undefined) => UI.Product[];
73
+ /** One platform review (Theme ABI `ProductReview`) → the theme's `Review`. */
74
+ export declare function toReview(r: R.ProductReview): UI.Review;
75
+ /**
76
+ * The current product's reviews for `StoreContext.reviews` (12F): the platform's aggregate and its newest published
77
+ * reviews (storefront-query rev 2.38). A product nobody has reviewed yet answers `count: 0` with an empty list — the
78
+ * section shows "No reviews yet" and its Write-a-review form. A region that answered the aggregate but not the list
79
+ * (asked without `reviewsFirst`) gives the aggregate with an empty list.
80
+ */
81
+ export declare function toReviews(p: R.Product | null | undefined): UI.ReviewsData;
82
+ /**
83
+ * The runtime's selling plan groups → `Product.sellingPlanGroups` (NEW-SUB-1): only groups whose plans carry a
84
+ * schedule (the Theme ABI source does; the GraphQL driver's plans have none and are left out, as before).
85
+ */
86
+ export declare function toSellingPlanGroups(list: readonly R.SellingPlanGroup[] | null | undefined): {
87
+ sellingPlanGroups?: UI.ProductSellingPlanGroup[];
88
+ };
89
+ /** Products by handle, for StoreContext.products. */
90
+ export declare function toProductMap(list: readonly R.Product[] | null | undefined): Record<string, UI.Product>;
91
+ /**
92
+ * A runtime collection → Collection.
93
+ *
94
+ * `products`: pass the live page (`collectionProducts(...).products`) when you
95
+ * have it. Otherwise the bootstrap cache is used ONLY when it actually has
96
+ * products — an empty cached list can be a shell baked before products were
97
+ * assigned, so it maps to `products: undefined` ("not loaded"), not "empty".
98
+ * Pass `products: []` to state that the collection is known to be empty.
99
+ */
100
+ export declare function toCollection(c: R.Collection, opts?: {
101
+ products?: readonly R.Product[] | null;
102
+ }): UI.Collection;
103
+ /** Collections by handle, for StoreContext.collections (card-level: no product lists). */
104
+ export declare function toCollectionMap(list: readonly R.Collection[] | null | undefined, opts?: {
105
+ withProducts?: boolean;
106
+ }): Record<string, UI.Collection>;
107
+ export interface MenuOptions {
108
+ /** The current pathname — marks the matching item at each level `active`. */
109
+ currentPath?: string;
110
+ /** Hosts that ARE this store (e.g. `shop.primaryDomain.host`); their absolute URLs become paths. */
111
+ storeHosts?: readonly string[];
112
+ }
113
+ /**
114
+ * A menu URL the theme can render, or null.
115
+ *
116
+ * Unsafe schemes are dropped (app/platform/safe-href). A menu item that points at one of
117
+ * the store's own resources (any type but HTTP) — or at one of `storeHosts` —
118
+ * may still arrive as an absolute store URL; it becomes a same-origin path so
119
+ * soft navigation and the active rule both work. A genuine external HTTP link
120
+ * is kept absolute.
121
+ */
122
+ export declare function toMenuHref(url: string | null | undefined, type?: S.MenuItemType | string | null, storeHosts?: readonly string[]): string | null;
123
+ /** A runtime menu → Menu (recursive, every level). null when there is no menu. */
124
+ export declare function toMenu(menu: S.Menu | null | undefined, opts?: MenuOptions): UI.Menu | null;
125
+ /** Menus by handle, for StoreContext.menus. Missing menus are left out. */
126
+ export declare function toMenuMap(menus: ReadonlyArray<S.Menu | null | undefined>, opts?: MenuOptions): Record<string, UI.Menu>;
127
+ export declare function toPaymentMethods(settings: S.Shop['paymentSettings'] | null | undefined): UI.PaymentMethod[];
128
+ /**
129
+ * Settings → Social → the design's drawn networks (`social`) and the rest (`otherSocial`, generic
130
+ * link mark). Only https: URLs; one link per network, the first wins. Empty → both absent.
131
+ */
132
+ export declare function toSocial(links: S.Shop['socialLinks']): Pick<UI.Shop, 'social' | 'otherSocial'>;
133
+ /**
134
+ * The shop + the theme's Brand settings → Shop.
135
+ *
136
+ * Name: the store name (Settings › General), else the theme's `shopName` setting
137
+ * (a fallback only — D-13). Logo: the theme's
138
+ * `logo` setting, else Settings → Brand (the same precedence as
139
+ * app/platform/safe-values `resolveLogo`, which this reuses).
140
+ */
141
+ /**
142
+ * The product's gallery with its hosted videos (Theme ABI `Product.media`, storefront-query rev 2.34). Only `image` and
143
+ * `video` items with a playable source map; YouTube / Vimeo / 3D never do (the storefront plays no third-party
144
+ * player). No video left ⇒ absent, and the gallery stays `images`.
145
+ */
146
+ export declare function toProductMedia(list: R.Product['media'] | null | undefined): {
147
+ media?: UI.ProductMediaItem[];
148
+ };
149
+ /** The platform's same-origin model route (storefront-edge `/_tq/model/`), which serves a store's own `.glb` / `.usdz` uploads. */
150
+ export declare const MODEL_ROUTE = "/_tq/model/";
151
+ /**
152
+ * A store-media `.glb` / `.usdz` URL → its same-origin model route (`/_tq/model/stores/<store>/<path>`): the media host
153
+ * sends no CORS headers, and the page CSP lets a viewer read only its own origin. An already same-origin route path is
154
+ * kept (the read model may hand one over). Anything else ⇒ null (not shown).
155
+ */
156
+ export declare function modelSrc(url: string | null | undefined): string | null;
157
+ /** A merchant-published postal address → display lines: street (address1, address2), "city province zip", country. */
158
+ export declare function addressLines(a: {
159
+ address1?: string;
160
+ address2?: string;
161
+ city?: string;
162
+ province?: string;
163
+ zip?: string;
164
+ country?: string;
165
+ countryCode?: string;
166
+ } | null | undefined): string[];
167
+ export declare function toShop(shop: S.Shop | null | undefined, settings?: {
168
+ shopName?: string;
169
+ logo?: string;
170
+ }): UI.Shop;
171
+ /**
172
+ * Localization → Localization, or null (no Markets: the picker hides).
173
+ *
174
+ * The runtime publishes countries and languages as two independent lists —
175
+ * every published language is available in every country — so `available` is
176
+ * their product. `current` is always included in `available`.
177
+ */
178
+ export declare function toLocalization(loc: R.Localization | null | undefined): UI.Localization | null;
179
+ export declare function toCartSummary(cart: Pick<C.CartState, 'lines' | 'totalQuantity'> | null | undefined): UI.CartSummary;
180
+ /**
181
+ * One cart line → CartLine.
182
+ *
183
+ * A line carries id + title + image + price, its product as handle + title, and
184
+ * — when the cart source sends the whole variant (Theme ABI v2) — its options,
185
+ * compare-at and availability. No vendor and no stock. `variant.available` is
186
+ * true unless the source says otherwise: the backend accepted the line, and it
187
+ * refuses unpurchasable merchandise at add/update time.
188
+ */
189
+ export declare function toCartLine(line: C.CartLine): UI.CartLine;
190
+ /**
191
+ * The full cart (cart page). `discounts` is left out: the runtime keeps no per-code amount. The order-level
192
+ * discount is `discountTotal` (from the cart's own totals) and, when the host names them, `discountAllocations`.
193
+ */
194
+ export declare function toCart(cart: C.CartState | null | undefined): UI.Cart;
195
+ /** A page → the UI's page-body shape (StoreContext.currentPage / pages). */
196
+ export declare function toPage(page: R.Page | null | undefined): {
197
+ title: string;
198
+ html: string;
199
+ } | null;
200
+ /**
201
+ * An article → Article, or null when its blog is unknown (no URL can be built —
202
+ * search results arrive without one). Pass the blog handle when the caller
203
+ * knows it.
204
+ */
205
+ export declare function toArticle(a: S.Article | null | undefined, blogHandle?: string): UI.Article | null;
206
+ export declare function toBlog(blog: S.Blog | null | undefined): UI.Blog | null;
207
+ /**
208
+ * A shop policy → Policy. The URL is the theme's own policy route (the runtime's
209
+ * `url` may be absolute). `bodyHtml` is '' when the payload carries no body.
210
+ */
211
+ export declare function toPolicy(p: S.ShopPolicy | null | undefined): UI.Policy | null;
212
+ /** Every published policy by handle, for StoreContext.policies. */
213
+ export declare function toPolicies(shop: S.Shop | null | undefined): Record<string, UI.Policy>;
214
+ type RuntimeLocation = NonNullable<Awaited<ReturnType<NonNullable<R.DataApi['locations']>>>>[number];
215
+ /**
216
+ * Store locations: the postal address, phone, and (rev 2.73) the pickup / storefront marks and the weekly opening hours.
217
+ * No email, image or coordinates.
218
+ */
219
+ export declare function toLocations(list: readonly RuntimeLocation[] | null | undefined): UI.StoreLocation[];
220
+ /**
221
+ * Search → SearchResults. `total` is the backend's count across every type.
222
+ * Articles whose blog is unknown are left out (see toArticle).
223
+ */
224
+ export declare function toSearchResults(query: string, r: S.SearchResults | null | undefined): UI.SearchResults;
225
+ /**
226
+ * Listing filters → Facets. List filters map value-for-value; `active` is set
227
+ * for the values whose `input` the shopper has applied. A PRICE_RANGE filter
228
+ * becomes a price facet only when its input carries the store's bounds and a
229
+ * currency is known.
230
+ */
231
+ export declare function toFacets(filters: readonly S.Filter[] | null | undefined, opts?: {
232
+ activeInputs?: readonly string[];
233
+ currencyCode?: string;
234
+ }): UI.Facet[];
235
+ export interface BreadcrumbInput {
236
+ pathname: string;
237
+ /** Interface words, already translated by the caller. Without `home` there is no trail. */
238
+ labels: {
239
+ home: string;
240
+ collections?: string;
241
+ search?: string;
242
+ cart?: string;
243
+ account?: string;
244
+ };
245
+ /** The route's collection — or, on a product page, the collection the shopper came from. */
246
+ collection?: {
247
+ handle: string;
248
+ title: string;
249
+ } | null;
250
+ product?: {
251
+ title: string;
252
+ } | null;
253
+ page?: {
254
+ title: string;
255
+ } | null;
256
+ blog?: {
257
+ title: string;
258
+ } | null;
259
+ article?: {
260
+ title: string;
261
+ } | null;
262
+ policy?: {
263
+ title: string;
264
+ } | null;
265
+ }
266
+ /**
267
+ * The trail for a route. The last item is the current page and carries no URL.
268
+ * A route whose own title is unknown returns [] rather than a trail that ends
269
+ * on a link — the breadcrumbs section then renders nothing.
270
+ */
271
+ export declare function toBreadcrumbs(input: BreadcrumbInput): UI.BreadcrumbItem[];
272
+ /**
273
+ * Whether the cookie banner shows to a shopper who has not decided yet (Settings › Customer privacy,
274
+ * contract rev 2): the platform's `regionRequiresBanner` first (EEA, UK, unknown location, and the
275
+ * merchant's own regions — or a platform that does not say), then the merchant's switch: with "Use
276
+ * automated settings" the legal floor alone (board 35 #42: it showed to every visitor everywhere), else
277
+ * also the regions the merchant chose. No merchant config (older data) = shown, as before.
278
+ */
279
+ export declare function consentBannerShows(readout: {
280
+ regionRequiresBanner?: boolean;
281
+ geo?: {
282
+ country?: string;
283
+ region?: string;
284
+ };
285
+ }, banner: S.ConsentBannerConfig | null | undefined): boolean;
286
+ export {};