@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,40 @@
1
+ /**
2
+ * `@tanqory/theme-kit/runtime` — the low-level runtime pieces `createRender` and `hydrate` are built
3
+ * from. For a theme's own tests (render a section tree under the real providers) and for custom
4
+ * entries. A theme's components never import this; they use `@tanqory/theme-kit`.
5
+ *
6
+ * Alpha surface: these names may still move between pre-releases.
7
+ */
8
+ // the theme bundle slot + section registration
9
+ export { setThemeBundle, getThemeBundle } from './runtime/slots.js';
10
+ export { sectionModules } from './runtime/entries/sections.js';
11
+ export { registerSections, getSection, allSections } from './runtime/kit/registry.js';
12
+ export { SectionTree } from './runtime/kit/SectionTree.js';
13
+ // providers
14
+ export { DataProvider } from './runtime/kit/data.js';
15
+ export { ThemeProvider } from './runtime/kit/theme-context.js';
16
+ export { PreviewModeProvider } from './runtime/shell/preview-mode.js';
17
+ export { localeStrings, themeLocaleOf } from './runtime/platform/locale.js';
18
+ // the ABI v2 layer: page, data plan, data API, wire, cart, loyalty
19
+ export { AbiShell } from './abi/shell.js';
20
+ export { nodesOf, notFoundTree, locationOf } from './abi/page.js';
21
+ export { loadPageData, pageNeeds, pageParamsOf, variantOf, cartLinkOf, searchQueryOf, searchSortOf, listingQueryOfRequest, localizationOf, marketsOf, } from './abi/page-data.js';
22
+ export { createDataApi, searchKey, searchOrder, SEARCH_SORTS } from './abi/data-api.js';
23
+ export * as convert from './abi/convert.js';
24
+ export { createAbiRemote, AbiWireError, parseRetryAfter } from './abi/wire.js';
25
+ export { AbiCartProvider, refusalOf, wireCode, retryDelay } from './abi/cart.js';
26
+ export { AbiRewardsProvider, HOST_OFFERS_LOYALTY, rewardsStateOf } from './abi/rewards.js';
27
+ export { AbiReferralsProvider, keepRefCode, referralStateOf, friendOfferOf, REF_COOKIE, CLAIM_COOKIE } from './abi/referrals.js';
28
+ export { homeHead, heroImageOf, hreflangAlternates } from './abi/seo.js';
29
+ export { canonicalize } from './abi/jcs.js';
30
+ // live edit on the editor canvas
31
+ export { CANVAS_EVENT, CANVAS_LIVE_EVENT, CANVAS_BRIDGE_EVENT, LIVE_TYPES, blocksOf, applyCanvasMessage, createCanvasStore, connectCanvas, } from './abi/canvas-live.js';
32
+ // SEO
33
+ export { computeHead, headFrom, shopNameOf } from './runtime/seo/head.js';
34
+ export { jsonLdTag } from './runtime/seo/structured-data.js';
35
+ // store data → the shapes components read
36
+ export { toLocalization, toShop, toCart, toProduct, consentBannerShows } from './runtime/data/to-ui.js';
37
+ // render helpers
38
+ export { localeHref } from './runtime/render/section-actions.js';
39
+ export { listingQueryOf, metafieldBooleanLabelKey, queryOfState, stateFromQuery, withListingQuery } from './runtime/render/listing-query.js';
40
+ export { copyPlanOf, localizeShippedCopy, shippedCopyOf, unknownCopyRefs } from './runtime/render/localized-copy.js';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `<AppBlock>`: how a theme renders a block of an installed app (theme-abi-v2.md §7.2 "App blocks (`@app`)").
3
+ *
4
+ * A section or block that lists `'@app'` in its accepted blocks receives the app's nodes among its saved blocks, with
5
+ * a type `app:<appHandle>/<blockHandle>` (`isAppBlock`). The theme places each where it wants and renders it with this
6
+ * component, which writes only the platform placeholder:
7
+ *
8
+ * <div data-tq-app-block="<type>" data-tq-node="<id>" data-tq-type="<type>" class="tq-app-block">
9
+ * <script type="application/json">{settings}</script>
10
+ * </div>
11
+ *
12
+ * The gateway adds the app's stylesheet and script (served from the shop's own origin, with integrity) and the
13
+ * platform mount script to the page; the app's script fills the placeholder in the browser. The settings are inert
14
+ * JSON: every `<`, `>` and `&` is written as a \u escape, so no value can end the element. No `style` attribute.
15
+ */
16
+ import type { SavedBlock } from './store.js';
17
+ /** Whether a saved block is a block of an installed app (render it with `<AppBlock>`). */
18
+ export declare function isAppBlock(block: {
19
+ type?: unknown;
20
+ } | null | undefined): boolean;
21
+ /** The settings as JSON that is safe inside `<script type="application/json">`. */
22
+ export declare function appBlockSettingsJson(settings: Readonly<Record<string, unknown>> | undefined): string;
23
+ export interface AppBlockProps {
24
+ block: SavedBlock;
25
+ /** Extra class names for the theme's own layout (spacing, grid placement). */
26
+ className?: string;
27
+ }
28
+ /** The placeholder of one app block; nothing for a node that is not an app block. */
29
+ export declare function AppBlock({ block, className }: AppBlockProps): JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { isAppBlockType } from '../runtime/kit/contract/content.js';
3
+ /** Whether a saved block is a block of an installed app (render it with `<AppBlock>`). */
4
+ export function isAppBlock(block) {
5
+ return !!block && isAppBlockType(block.type);
6
+ }
7
+ /** The settings as JSON that is safe inside `<script type="application/json">`. */
8
+ export function appBlockSettingsJson(settings) {
9
+ return JSON.stringify(settings ?? {})
10
+ .replace(/</g, '\\u003c')
11
+ .replace(/>/g, '\\u003e')
12
+ .replace(/&/g, '\\u0026')
13
+ .replace(/\u2028/g, '\\u2028')
14
+ .replace(/\u2029/g, '\\u2029');
15
+ }
16
+ /** The placeholder of one app block; nothing for a node that is not an app block. */
17
+ export function AppBlock({ block, className }) {
18
+ if (!isAppBlock(block))
19
+ return null;
20
+ const id = typeof block.id === 'string' && block.id ? block.id : undefined;
21
+ return (_jsx("div", { "data-tq-app-block": block.type, ...(id ? { 'data-tq-node': id } : {}), "data-tq-type": block.type, className: className ? `tq-app-block ${className}` : 'tq-app-block', suppressHydrationWarning: true, children: _jsx("script", { type: "application/json", dangerouslySetInnerHTML: { __html: appBlockSettingsJson(block.settings) } }) }));
22
+ }
@@ -0,0 +1,7 @@
1
+ import { type ThemeFont } from './fonts.js';
2
+ /**
3
+ * A font setting's value as a CSS `font-family` stack, and the font loads: a catalogue family is imported by the server
4
+ * render (or fetched by the browser when the merchant picks it on the canvas); a theme font is the theme's own
5
+ * `@font-face`; a system face loads nothing. Undefined when the value is '' or not a font this theme offers.
6
+ */
7
+ export declare function useFont(value: unknown, themeFonts?: readonly ThemeFont[]): string | undefined;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * useFont (fonts.ts): a font setting's value as a CSS `font-family` stack, and the font loads.
3
+ */
4
+ import { useEffect } from 'react';
5
+ import { registerFontFamily } from './sx.js';
6
+ import { fontStack, isCatalogueFont, loadCatalogueFont } from './fonts.js';
7
+ /**
8
+ * A font setting's value as a CSS `font-family` stack, and the font loads: a catalogue family is imported by the server
9
+ * render (or fetched by the browser when the merchant picks it on the canvas); a theme font is the theme's own
10
+ * `@font-face`; a system face loads nothing. Undefined when the value is '' or not a font this theme offers.
11
+ */
12
+ export function useFont(value, themeFonts = []) {
13
+ const family = isCatalogueFont(value) ? value : null;
14
+ if (family)
15
+ registerFontFamily(family);
16
+ useEffect(() => {
17
+ if (family)
18
+ void loadCatalogueFont(family);
19
+ }, [family]);
20
+ return fontStack(value, themeFonts);
21
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Fonts for a theme (TS-7, 2026-11-19): the platform catalogue first, a font the theme ships under assets/ second, the
3
+ * device's own faces third. One setting helper for each place a font is chosen, and one hook that makes the choice
4
+ * load:
5
+ *
6
+ * fontSetting({ label, default: 'Prompt' }) a theme setting (defineSettings): the editor's font picker
7
+ * field.font('Prompt', { label }) a section or block setting, the same picker
8
+ * const family = useFont(settings.headingFont) the CSS font-family stack, and the font loads
9
+ *
10
+ * Where each font comes from, and why no rule of the storefront has to change:
11
+ *
12
+ * catalogue The edge's same-origin `/_tq/fonts/*` (storefront-edge core/fonts-route.ts), which fetches Google Fonts
13
+ * (all SIL Open Font License) and rewrites every file URL to `/_tq/fonts/s/...`. The page never names
14
+ * another host. On the server the kit puts `@import url("/_tq/fonts/css2?...")` in its own inline
15
+ * `<style>`, which is announced by hash like every other block (theme-abi §5 `style-src-elem 'self'`);
16
+ * there is no `<link>`, so §10.2's "every `<link rel=stylesheet>` under assets.base with integrity"
17
+ * does not apply, and §10.5 allows a style request to same-origin `/_tq/*`. In the browser (a font the
18
+ * merchant picks on the editor canvas, which the server did not import) the kit reads the same CSS with
19
+ * `fetch` (connect-src 'self', §10.5 `/_tq/*`), keeps only `@font-face` rules whose every declaration
20
+ * matches a fixed grammar and whose `src` is a `/_tq/fonts/s/` file, and inserts the rebuilt rules into
21
+ * a constructed stylesheet (CSSOM, which CSP does not govern). A constructed sheet cannot `@import`:
22
+ * CSSOM §6.1.2 insertRule step 5 "If parsed rule is an @import rule, and the constructed flag is set,
23
+ * throw a SyntaxError", and replace()/replaceSync() drop them (read 2026-11-19), hence the fetch.
24
+ * theme A WOFF2 file the theme ships under assets/ (checked before the build, @tanqory/theme-standard
25
+ * woff2.js) with the theme's own `@font-face` in its CSS; the build serves it from the asset base as
26
+ * `font/woff2` (§5 `font-src`). The kit only names the family.
27
+ * system The device's faces (`system-sans`, `system-serif`, `system-mono`, `system-rounded`): nothing loads.
28
+ *
29
+ * Every family name the kit writes into CSS matches FAMILY_NAME (letters, digits, spaces, hyphens), so a value never
30
+ * leaves its declaration.
31
+ */
32
+ import type { SettingSpec } from './theme.js';
33
+ export type FontScript = 'latin' | 'thai';
34
+ export type FontFallback = 'sans-serif' | 'serif' | 'monospace';
35
+ /** A family of the platform catalogue (served by the edge's `/_tq/fonts`). */
36
+ export interface CatalogueFont {
37
+ readonly family: string;
38
+ /** The writing systems its files cover (the editor's font picker tags Thai). */
39
+ readonly scripts: readonly FontScript[];
40
+ readonly fallback: FontFallback;
41
+ }
42
+ /**
43
+ * The platform catalogue. Each family was requested through the Dev edge's `/_tq/fonts/css2` with weights 400-700 on
44
+ * 2026-11-19 and answered 200 `text/css` with `@font-face` rules and `font/woff2` files (scratchpad font-probe.sh).
45
+ * The Thai families are the ones Nova V3 offers (themes/nova-v3/src/styles/fonts.ts) plus Mitr.
46
+ */
47
+ export declare const FONT_CATALOGUE: readonly CatalogueFont[];
48
+ /** The weights the kit asks the catalogue for (every catalogue family has them; probed 2026-11-19). */
49
+ export declare const FONT_WEIGHTS: readonly [400, 500, 600, 700];
50
+ /** The device's own faces: the value is the id, the stack is what the page uses. The editor shows the same four. */
51
+ export declare const SYSTEM_FONTS: readonly [{
52
+ readonly value: "system-sans";
53
+ readonly label: "System sans-serif";
54
+ readonly stack: "system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif";
55
+ }, {
56
+ readonly value: "system-serif";
57
+ readonly label: "System serif";
58
+ readonly stack: "ui-serif, Georgia, \"Times New Roman\", serif";
59
+ }, {
60
+ readonly value: "system-mono";
61
+ readonly label: "System monospace";
62
+ readonly stack: "ui-monospace, \"SF Mono\", Menlo, Consolas, monospace";
63
+ }, {
64
+ readonly value: "system-rounded";
65
+ readonly label: "System rounded";
66
+ readonly stack: "ui-rounded, \"SF Pro Rounded\", system-ui, sans-serif";
67
+ }];
68
+ /** A family the theme ships itself: a WOFF2 under assets/ and an `@font-face` for `family` in the theme's CSS. */
69
+ export interface ThemeFont {
70
+ readonly family: string;
71
+ /** The picker's name for it; the family when absent. */
72
+ readonly label?: string;
73
+ readonly scripts?: readonly FontScript[];
74
+ readonly fallback?: FontFallback;
75
+ }
76
+ /** A family name the kit writes into CSS: what the edge's `/_tq/fonts` grammar allows for a name, nothing that quotes. */
77
+ export declare const FAMILY_NAME: RegExp;
78
+ /** Families in one `/_tq/fonts/css2` request at most (the edge's MAX_FAMILIES). */
79
+ export declare const FAMILIES_PER_REQUEST = 8;
80
+ export declare const FONTS_CSS_PATH = "/_tq/fonts/css2";
81
+ /** True when `family` is in the platform catalogue. */
82
+ export declare const isCatalogueFont: (family: unknown) => family is string;
83
+ /** One option of a font setting, with the editor's picker hints (`group`, `scripts`). */
84
+ export interface FontOption {
85
+ readonly value: string;
86
+ readonly label: string;
87
+ readonly group: 'Library' | 'Theme' | 'System' | 'Default';
88
+ readonly scripts?: readonly FontScript[];
89
+ }
90
+ export interface FontOptionsInput {
91
+ /** Fonts the theme ships (assets/*.woff2 + its own `@font-face`). */
92
+ readonly themeFonts?: readonly ThemeFont[];
93
+ /** Only these catalogue families (in this order); every family when absent. */
94
+ readonly catalogue?: readonly string[];
95
+ /** Offer the device's faces (default true). */
96
+ readonly system?: boolean;
97
+ /** An empty value ("not set") and its label, e.g. "Same as body font". */
98
+ readonly unset?: string;
99
+ }
100
+ /** The options of a font setting: the catalogue first, then the theme's own fonts, then the device's faces. */
101
+ export declare function fontOptions(input?: FontOptionsInput): FontOption[];
102
+ /**
103
+ * The CSS `font-family` value of a font setting's value: a catalogue or theme family with its fallback, a system face's
104
+ * stack; undefined for '' (not set) or anything else (a value no option offers is never written into CSS).
105
+ */
106
+ export declare function fontStack(value: unknown, themeFonts?: readonly ThemeFont[]): string | undefined;
107
+ /** The same-origin stylesheet URL(s) of catalogue families, at most FAMILIES_PER_REQUEST each. */
108
+ export declare function fontCssHrefs(families: Iterable<string>): string[];
109
+ /** The inline CSS the server emits for the catalogue families a render used: `@import` lines only. */
110
+ export declare function fontImportCss(families: Iterable<string>): string;
111
+ /** id of the server's `<style>` holding the page's font `@import`s. */
112
+ export declare const FONT_IMPORTS_ID = "tq-font-imports";
113
+ /**
114
+ * The `@font-face` rules of a `/_tq/fonts/css2` answer for `family`, rebuilt from declarations that each match DECL
115
+ * (and a `font-family` equal to `family`). A rule with any other declaration, or none of `src`, is dropped whole.
116
+ */
117
+ export declare function safeFontFaces(css: string, family: string): string[];
118
+ /** Loads a catalogue family in the browser when the page does not have it yet (no-op on the server and for others). */
119
+ export declare function loadCatalogueFont(family: string): Promise<boolean>;
120
+ /** For tests: forget what the browser loader has seen. */
121
+ export declare function resetFontLoader(): void;
122
+ /** The editor's picker hints of a font select: its group and scripts per option (the ABI manifest keeps value/label). */
123
+ export interface FontEditorHints {
124
+ readonly control: 'font';
125
+ readonly weight_setting?: string;
126
+ readonly options: Readonly<Record<string, {
127
+ readonly group: string;
128
+ readonly scripts?: readonly FontScript[];
129
+ }>>;
130
+ }
131
+ export declare const fontEditorHints: (options: readonly FontOption[], weightSetting?: string) => FontEditorHints;
132
+ export interface FontSettingInput extends FontOptionsInput {
133
+ readonly label: string;
134
+ readonly group?: string;
135
+ readonly info?: string;
136
+ /** A catalogue, theme or system value; the first catalogue family when absent ('' when `unset` is given). */
137
+ readonly default?: string;
138
+ /** The id of the select setting holding this font's weight (the picker sets both). */
139
+ readonly weightSetting?: string;
140
+ }
141
+ /** A theme setting (defineSettings) the editor draws as its font picker: the catalogue, the theme's fonts, the device's. */
142
+ export declare function fontSetting(input: FontSettingInput): SettingSpec;
143
+ /** What a font select may hold: '' (when offered), a catalogue family, a system face, or a theme family name. */
144
+ export declare function fontValueProblem(value: string, themeFamilies: ReadonlySet<string>): string | null;
@@ -0,0 +1,241 @@
1
+ /**
2
+ * The platform catalogue. Each family was requested through the Dev edge's `/_tq/fonts/css2` with weights 400-700 on
3
+ * 2026-11-19 and answered 200 `text/css` with `@font-face` rules and `font/woff2` files (scratchpad font-probe.sh).
4
+ * The Thai families are the ones Nova V3 offers (themes/nova-v3/src/styles/fonts.ts) plus Mitr.
5
+ */
6
+ export const FONT_CATALOGUE = Object.freeze([
7
+ { family: 'Noto Sans Thai', scripts: ['thai', 'latin'], fallback: 'sans-serif' },
8
+ { family: 'Noto Serif Thai', scripts: ['thai', 'latin'], fallback: 'serif' },
9
+ { family: 'IBM Plex Sans Thai', scripts: ['thai', 'latin'], fallback: 'sans-serif' },
10
+ { family: 'Sarabun', scripts: ['thai', 'latin'], fallback: 'sans-serif' },
11
+ { family: 'Prompt', scripts: ['thai', 'latin'], fallback: 'sans-serif' },
12
+ { family: 'Kanit', scripts: ['thai', 'latin'], fallback: 'sans-serif' },
13
+ { family: 'Anuphan', scripts: ['thai', 'latin'], fallback: 'sans-serif' },
14
+ { family: 'Mitr', scripts: ['thai', 'latin'], fallback: 'sans-serif' },
15
+ { family: 'Geist', scripts: ['latin'], fallback: 'sans-serif' },
16
+ { family: 'Inter', scripts: ['latin'], fallback: 'sans-serif' },
17
+ { family: 'DM Sans', scripts: ['latin'], fallback: 'sans-serif' },
18
+ { family: 'Space Grotesk', scripts: ['latin'], fallback: 'sans-serif' },
19
+ { family: 'Fraunces', scripts: ['latin'], fallback: 'serif' },
20
+ { family: 'Playfair Display', scripts: ['latin'], fallback: 'serif' },
21
+ { family: 'Lora', scripts: ['latin'], fallback: 'serif' },
22
+ { family: 'Libre Baskerville', scripts: ['latin'], fallback: 'serif' },
23
+ { family: 'Geist Mono', scripts: ['latin'], fallback: 'monospace' },
24
+ ].map((f) => Object.freeze({ ...f, scripts: Object.freeze([...f.scripts]) })));
25
+ /** The weights the kit asks the catalogue for (every catalogue family has them; probed 2026-11-19). */
26
+ export const FONT_WEIGHTS = Object.freeze([400, 500, 600, 700]);
27
+ /** The device's own faces: the value is the id, the stack is what the page uses. The editor shows the same four. */
28
+ export const SYSTEM_FONTS = Object.freeze([
29
+ { value: 'system-sans', label: 'System sans-serif', stack: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif' },
30
+ { value: 'system-serif', label: 'System serif', stack: 'ui-serif, Georgia, "Times New Roman", serif' },
31
+ { value: 'system-mono', label: 'System monospace', stack: 'ui-monospace, "SF Mono", Menlo, Consolas, monospace' },
32
+ { value: 'system-rounded', label: 'System rounded', stack: 'ui-rounded, "SF Pro Rounded", system-ui, sans-serif' },
33
+ ]);
34
+ /** A family name the kit writes into CSS: what the edge's `/_tq/fonts` grammar allows for a name, nothing that quotes. */
35
+ export const FAMILY_NAME = /^[A-Za-z0-9][A-Za-z0-9 -]{0,63}$/;
36
+ /** Families in one `/_tq/fonts/css2` request at most (the edge's MAX_FAMILIES). */
37
+ export const FAMILIES_PER_REQUEST = 8;
38
+ export const FONTS_CSS_PATH = '/_tq/fonts/css2';
39
+ const BY_FAMILY = new Map(FONT_CATALOGUE.map((f) => [f.family, f]));
40
+ const SYSTEM = new Map(SYSTEM_FONTS.map((f) => [f.value, f.stack]));
41
+ /** True when `family` is in the platform catalogue. */
42
+ export const isCatalogueFont = (family) => typeof family === 'string' && BY_FAMILY.has(family);
43
+ /** The options of a font setting: the catalogue first, then the theme's own fonts, then the device's faces. */
44
+ export function fontOptions(input = {}) {
45
+ const out = [];
46
+ if (input.unset)
47
+ out.push({ value: '', label: input.unset, group: 'Default' });
48
+ const families = input.catalogue ?? FONT_CATALOGUE.map((f) => f.family);
49
+ for (const family of families) {
50
+ const f = BY_FAMILY.get(family);
51
+ if (!f)
52
+ throw new Error(`fontOptions: "${family}" is not in the platform catalogue (FONT_CATALOGUE)`);
53
+ out.push({ value: f.family, label: f.family, group: 'Library', scripts: f.scripts });
54
+ }
55
+ for (const t of input.themeFonts ?? []) {
56
+ if (!FAMILY_NAME.test(t.family))
57
+ throw new Error(`fontOptions: theme font "${t.family}": a family name is letters, digits, spaces and hyphens`);
58
+ if (BY_FAMILY.has(t.family) || SYSTEM.has(t.family))
59
+ throw new Error(`fontOptions: theme font "${t.family}" has the name of a catalogue or system font`);
60
+ out.push({ value: t.family, label: t.label ?? t.family, group: 'Theme', ...(t.scripts ? { scripts: t.scripts } : {}) });
61
+ }
62
+ if (input.system !== false)
63
+ for (const s of SYSTEM_FONTS)
64
+ out.push({ value: s.value, label: s.label, group: 'System' });
65
+ const seen = new Set();
66
+ for (const o of out) {
67
+ if (seen.has(o.value))
68
+ throw new Error(`fontOptions: "${o.value}" is offered twice`);
69
+ seen.add(o.value);
70
+ }
71
+ return out;
72
+ }
73
+ const quoted = (family) => `"${family}"`;
74
+ /**
75
+ * The CSS `font-family` value of a font setting's value: a catalogue or theme family with its fallback, a system face's
76
+ * stack; undefined for '' (not set) or anything else (a value no option offers is never written into CSS).
77
+ */
78
+ export function fontStack(value, themeFonts = []) {
79
+ if (typeof value !== 'string' || value === '')
80
+ return undefined;
81
+ const system = SYSTEM.get(value);
82
+ if (system)
83
+ return system;
84
+ const c = BY_FAMILY.get(value);
85
+ if (c)
86
+ return `${quoted(c.family)}, ${c.fallback}`;
87
+ const t = themeFonts.find((f) => f.family === value);
88
+ if (t && FAMILY_NAME.test(t.family))
89
+ return `${quoted(t.family)}, ${t.fallback ?? 'sans-serif'}`;
90
+ return undefined;
91
+ }
92
+ /** The same-origin stylesheet URL(s) of catalogue families, at most FAMILIES_PER_REQUEST each. */
93
+ export function fontCssHrefs(families) {
94
+ const list = [...new Set([...families].filter((f) => BY_FAMILY.has(f)))].sort();
95
+ const out = [];
96
+ for (let i = 0; i < list.length; i += FAMILIES_PER_REQUEST) {
97
+ const q = list.slice(i, i + FAMILIES_PER_REQUEST).map((f) => `family=${f.replace(/ /g, '+')}:wght@${FONT_WEIGHTS.join(';')}`);
98
+ out.push(`${FONTS_CSS_PATH}?${q.join('&')}&display=swap`);
99
+ }
100
+ return out;
101
+ }
102
+ /** The inline CSS the server emits for the catalogue families a render used: `@import` lines only. */
103
+ export function fontImportCss(families) {
104
+ return fontCssHrefs(families).map((h) => `@import url("${h}");`).join('');
105
+ }
106
+ /** id of the server's `<style>` holding the page's font `@import`s. */
107
+ export const FONT_IMPORTS_ID = 'tq-font-imports';
108
+ // ── browser: a catalogue family the server did not import ─────────────────────────────────────────────────────────
109
+ const DECL = {
110
+ 'font-style': /^(normal|italic)$/,
111
+ 'font-weight': /^[1-9]00( [1-9]00)?$/,
112
+ 'font-display': /^(auto|block|swap|fallback|optional)$/,
113
+ 'font-stretch': /^[0-9]{1,3}%( [0-9]{1,3}%)?$/,
114
+ src: /^url\(\/_tq\/fonts\/s\/[a-z0-9]+\/v[0-9]+\/[A-Za-z0-9_-]+(\.[0-9]{1,3})?\.(woff2|woff|ttf)\) format\('(woff2|woff|truetype)'\)$/,
115
+ 'unicode-range': /^U\+[0-9A-Fa-f?]{1,6}(-[0-9A-Fa-f]{1,6})?(, U\+[0-9A-Fa-f?]{1,6}(-[0-9A-Fa-f]{1,6})?)*$/,
116
+ };
117
+ /**
118
+ * The `@font-face` rules of a `/_tq/fonts/css2` answer for `family`, rebuilt from declarations that each match DECL
119
+ * (and a `font-family` equal to `family`). A rule with any other declaration, or none of `src`, is dropped whole.
120
+ */
121
+ export function safeFontFaces(css, family) {
122
+ if (!BY_FAMILY.has(family) || css.length > 256 * 1024)
123
+ return [];
124
+ const out = [];
125
+ for (const m of css.replace(/\/\*[^*]*\*\//g, '').matchAll(/@font-face\s*\{([^{}]*)\}/g)) {
126
+ const decls = [];
127
+ let ok = true;
128
+ let named = false;
129
+ let src = false;
130
+ for (const part of m[1].split(';')) {
131
+ const d = part.trim();
132
+ if (!d)
133
+ continue;
134
+ const at = d.indexOf(':');
135
+ if (at < 0) {
136
+ ok = false;
137
+ break;
138
+ }
139
+ const prop = d.slice(0, at).trim().toLowerCase();
140
+ const value = d.slice(at + 1).trim();
141
+ if (prop === 'font-family') {
142
+ if (value !== `'${family}'` && value !== `"${family}"`) {
143
+ ok = false;
144
+ break;
145
+ }
146
+ named = true;
147
+ decls.push(`font-family:${quoted(family)}`);
148
+ continue;
149
+ }
150
+ const re = DECL[prop];
151
+ if (!re || !re.test(value)) {
152
+ ok = false;
153
+ break;
154
+ }
155
+ if (prop === 'src')
156
+ src = true;
157
+ decls.push(`${prop}:${value}`);
158
+ }
159
+ if (ok && named && src)
160
+ out.push(`@font-face{${decls.join(';')}}`);
161
+ }
162
+ return out;
163
+ }
164
+ let loaded = null;
165
+ let sheet = null;
166
+ function serverImported() {
167
+ const s = new Set();
168
+ const text = typeof document === 'undefined' ? '' : (document.getElementById(FONT_IMPORTS_ID)?.textContent ?? '');
169
+ for (const m of text.matchAll(/family=([A-Za-z0-9+ -]+):/g))
170
+ s.add(m[1].replace(/\+/g, ' '));
171
+ return s;
172
+ }
173
+ /** Loads a catalogue family in the browser when the page does not have it yet (no-op on the server and for others). */
174
+ export async function loadCatalogueFont(family) {
175
+ if (typeof document === 'undefined' || typeof fetch !== 'function' || !BY_FAMILY.has(family))
176
+ return false;
177
+ loaded ??= serverImported();
178
+ if (loaded.has(family))
179
+ return true;
180
+ loaded.add(family);
181
+ try {
182
+ const res = await fetch(fontCssHrefs([family])[0], { credentials: 'same-origin' });
183
+ if (!res.ok || !/^text\/css\b/i.test(res.headers.get('content-type') ?? ''))
184
+ return false;
185
+ const rules = safeFontFaces(await res.text(), family);
186
+ if (!rules.length)
187
+ return false;
188
+ if (!sheet && typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in document) {
189
+ sheet = new CSSStyleSheet();
190
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
191
+ }
192
+ if (!sheet)
193
+ return false;
194
+ for (const r of rules) {
195
+ try {
196
+ sheet.insertRule(r, sheet.cssRules.length);
197
+ }
198
+ catch {
199
+ /* a rule the browser rejects is not applied */
200
+ }
201
+ }
202
+ return true;
203
+ }
204
+ catch {
205
+ loaded.delete(family);
206
+ return false;
207
+ }
208
+ }
209
+ /** For tests: forget what the browser loader has seen. */
210
+ export function resetFontLoader() {
211
+ loaded = null;
212
+ sheet = null;
213
+ }
214
+ export const fontEditorHints = (options, weightSetting) => ({
215
+ control: 'font',
216
+ ...(weightSetting ? { weight_setting: weightSetting } : {}),
217
+ options: Object.fromEntries(options.map((o) => [o.value, { group: o.group, ...(o.scripts ? { scripts: o.scripts } : {}) }])),
218
+ });
219
+ /** A theme setting (defineSettings) the editor draws as its font picker: the catalogue, the theme's fonts, the device's. */
220
+ export function fontSetting(input) {
221
+ const options = fontOptions(input);
222
+ const def = input.default ?? (input.unset ? '' : options.find((o) => o.group === 'Library')?.value ?? options[0].value);
223
+ if (!options.some((o) => o.value === def))
224
+ throw new Error(`fontSetting: the default "${def}" is not one of its options`);
225
+ return {
226
+ type: 'select',
227
+ control: 'font',
228
+ ...(input.weightSetting ? { weight_setting: input.weightSetting } : {}),
229
+ label: input.label,
230
+ ...(input.group ? { group: input.group } : {}),
231
+ ...(input.info ? { info: input.info } : {}),
232
+ default: def,
233
+ options: options.map((o) => ({ value: o.value, label: o.label, group: o.group, ...(o.scripts ? { scripts: o.scripts } : {}) })),
234
+ };
235
+ }
236
+ /** What a font select may hold: '' (when offered), a catalogue family, a system face, or a theme family name. */
237
+ export function fontValueProblem(value, themeFamilies) {
238
+ if (value === '' || BY_FAMILY.has(value) || SYSTEM.has(value) || themeFamilies.has(value))
239
+ return null;
240
+ return FAMILY_NAME.test(value) ? `"${value}" is neither a catalogue font, a system face nor one of the theme's fonts` : `"${value}" is not a font family name (letters, digits, spaces, hyphens)`;
241
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @tanqory/theme-sdk — the public API a Tanqory theme is written against.
3
+ *
4
+ * schema defineSchema(), field.*, resolveSettings() — a section's persisted settings
5
+ * theme defineTheme(), defineSection() — how a theme describes itself
6
+ * runtime useThemeContext(), useThemeActions(), useSearchSuggestions()
7
+ * types Product, Collection, Cart, Menu, … — the data a theme renders
8
+ * rewards useRewards(), earnPoints(): the store's loyalty program, browser-only
9
+ * referrals useReferrals(), shareTargets(): the shopper's referral link and the friend offer, browser-only
10
+ * store StoreContext + imageFor / menuFor / collectionFor / productFor / productsFor … —
11
+ * read what the runtime put in the context
12
+ * sources useSourceText(): text that names dynamic sources, read against the page's resources
13
+ *
14
+ * Nothing here fetches or knows how the platform works.
15
+ */
16
+ export * from './schema.js';
17
+ export * from './types.js';
18
+ export * from './store.js';
19
+ export * from './store-lookup.js';
20
+ export { AppBlock, isAppBlock, appBlockSettingsJson, type AppBlockProps } from './app-block.js';
21
+ export { APP_BLOCKS } from '../runtime/kit/contract/content.js';
22
+ export * from './theme.js';
23
+ export * from './runtime-context.js';
24
+ export { ServerRenderProvider, useServerRender } from './server-render.js';
25
+ export * from './rewards.js';
26
+ export * from './referrals.js';
27
+ export { sx, cx as sxJoin, collectStyles, STYLE_RULES_ID } from './sx.js';
28
+ export { setCssVars, cssVarValue, prefersReducedMotion, onReducedMotionChange, reveal, exit, scrollProgress, presetFrames, type CssVars, type MotionPreset, type MotionOptions, type RevealOptions, type ScrollProgressOptions } from './motion.js';
29
+ export { useCssVars, useReducedMotion, useReveal, useScrollProgress } from './motion-hooks.js';
30
+ export { FONT_CATALOGUE, SYSTEM_FONTS, FONT_WEIGHTS, FONT_IMPORTS_ID, fontSetting, fontOptions, fontStack, fontCssHrefs, fontImportCss, safeFontFaces, loadCatalogueFont, isCatalogueFont, type CatalogueFont, type ThemeFont, type FontOption, type FontScript, type FontSettingInput, type FontEditorHints } from './fonts.js';
31
+ export { useFont } from './font-hooks.js';
32
+ export { sourceText, useSourceText } from '../runtime/kit/dynamic-source.js';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @tanqory/theme-sdk — the public API a Tanqory theme is written against.
3
+ *
4
+ * schema defineSchema(), field.*, resolveSettings() — a section's persisted settings
5
+ * theme defineTheme(), defineSection() — how a theme describes itself
6
+ * runtime useThemeContext(), useThemeActions(), useSearchSuggestions()
7
+ * types Product, Collection, Cart, Menu, … — the data a theme renders
8
+ * rewards useRewards(), earnPoints(): the store's loyalty program, browser-only
9
+ * referrals useReferrals(), shareTargets(): the shopper's referral link and the friend offer, browser-only
10
+ * store StoreContext + imageFor / menuFor / collectionFor / productFor / productsFor … —
11
+ * read what the runtime put in the context
12
+ * sources useSourceText(): text that names dynamic sources, read against the page's resources
13
+ *
14
+ * Nothing here fetches or knows how the platform works.
15
+ */
16
+ export * from './schema.js';
17
+ export * from './types.js';
18
+ export * from './store.js';
19
+ export * from './store-lookup.js';
20
+ export { AppBlock, isAppBlock, appBlockSettingsJson } from './app-block.js';
21
+ export { APP_BLOCKS } from '../runtime/kit/contract/content.js';
22
+ export * from './theme.js';
23
+ export * from './runtime-context.js';
24
+ export { ServerRenderProvider, useServerRender } from './server-render.js';
25
+ export * from './rewards.js';
26
+ export * from './referrals.js';
27
+ export { sx, cx as sxJoin, collectStyles, STYLE_RULES_ID } from './sx.js';
28
+ // Continuous values (CSS custom properties through the CSSOM) and motion (Web Animations, scroll progress), with
29
+ // prefers-reduced-motion honoured. Browser-only; no-ops on the server.
30
+ export { setCssVars, cssVarValue, prefersReducedMotion, onReducedMotionChange, reveal, exit, scrollProgress, presetFrames } from './motion.js';
31
+ export { useCssVars, useReducedMotion, useReveal, useScrollProgress } from './motion-hooks.js';
32
+ // Fonts: the platform catalogue (same-origin /_tq/fonts), a theme's own assets/*.woff2, the device's faces.
33
+ export { FONT_CATALOGUE, SYSTEM_FONTS, FONT_WEIGHTS, FONT_IMPORTS_ID, fontSetting, fontOptions, fontStack, fontCssHrefs, fontImportCss, safeFontFaces, loadCatalogueFont, isCatalogueFont } from './fonts.js';
34
+ export { useFont } from './font-hooks.js';
35
+ // Text that names dynamic sources (`{{ product.title }}`) read against the page's resources.
36
+ export { sourceText, useSourceText } from '../runtime/kit/dynamic-source.js';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * React hooks over `motion.ts`: each runs in an effect only (never during the server render, so nothing of it is in the
3
+ * server HTML), and undoes itself when the component unmounts or its inputs change.
4
+ *
5
+ * const ref = useRef<HTMLDivElement>(null)
6
+ * useReveal(ref, { preset: 'fade-up' })
7
+ * useScrollProgress(ref, { cssVar: '--tq-progress' }) // CSS: transform: translateY(calc(var(--tq-progress) * -40px))
8
+ * useCssVars(ref, { '--drag-x': x }) // a value that changes every frame
9
+ */
10
+ import { type RefObject } from 'react';
11
+ import { type CssVars, type RevealOptions, type ScrollProgressOptions } from './motion.js';
12
+ /** Custom properties of the element, written after each render that changes them (setCssVars). */
13
+ export declare function useCssVars(ref: RefObject<Element | null>, vars: CssVars): void;
14
+ /** The shopper's reduced-motion setting, following changes; false on the server and on the first render. */
15
+ export declare function useReducedMotion(): boolean;
16
+ /** The element fades or slides in when it comes on screen (reveal). */
17
+ export declare function useReveal(ref: RefObject<Element | null>, o?: RevealOptions): void;
18
+ /**
19
+ * How far the element has travelled through the screen (0 to 1, scrollProgress). With `cssVar` the value is written to
20
+ * that custom property and the hook answers nothing that re-renders (the cheap way: CSS reads the variable); without it,
21
+ * the value is React state, updated at most once a frame.
22
+ */
23
+ export declare function useScrollProgress(ref: RefObject<Element | null>, o?: ScrollProgressOptions): number | null;