@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
@@ -0,0 +1,220 @@
1
+ # Headless API (`@tanqory/theme-kit/headless`)
2
+
3
+ Every storefront function, none of the styling. Your theme owns all markup and CSS; the kit supplies data,
4
+ behaviour and accessible primitives that render semantic HTML carrying the platform's `tq-storefront-hooks/1`
5
+ attributes. Each primitive accepts `className` and most accept render-prop `children` for full control.
6
+
7
+ The kit ships no CSS. The only class it adds is `visuallyHidden()` (an `sx()` rule). There is never a `style=""`
8
+ attribute: the platform CSP has `style-src-attr 'none'`. Use classes or `sx()` for dynamic values.
9
+
10
+ ```
11
+ @tanqory/theme-kit/headless hooks, primitives, defineSection / defineBlock / defineTheme, t(), formatMoney, <Seo>, <Image>, ai.*
12
+ @tanqory/theme-kit/server createRender({ manifest, bundle, storefront: {} }) the ABI render(request, ctx)
13
+ @tanqory/theme-kit/client hydrate({ bundle }) the browser entry; live edit on the editor canvas
14
+ @tanqory/theme-kit/build buildManifest(...), checkContent, withKitStrings the manifest from your declarations (Node, pure)
15
+ ```
16
+
17
+ ## 1. A theme in four files
18
+
19
+ ```tsx
20
+ // theme.tsx
21
+ import { defineTheme, defineSection, defineBlock, field, ai, useMenu, CartToggle, CartDrawer, ConsentBanner } from '@tanqory/theme-kit/headless'
22
+
23
+ const header = defineSection({
24
+ type: 'header', title: 'Header', zone: 'header',
25
+ settings: { menu: field.resource('menu', 'main-menu', { label: 'Menu' }) },
26
+ ai: ai.headerMenu('menu'),
27
+ component: ({ settings }) => {
28
+ const menu = useMenu(settings.menu)
29
+ return <header className="mast"><nav aria-label="Main">…{menu?.items…}</nav><CartToggle className="mast__cart" /></header>
30
+ },
31
+ })
32
+
33
+ export default defineTheme({
34
+ name: 'My theme',
35
+ sections: [header, /* hero, product, collection, cart, search, footer, not-found … */],
36
+ Layout: ({ children }) => <>{children}<CartDrawer className="drawer">{(cart) => …}</CartDrawer><ConsentBanner className="consent" /></>,
37
+ })
38
+ ```
39
+
40
+ ```tsx
41
+ // entry.server.tsx — built into ONE file with no imports
42
+ import { createRender } from '@tanqory/theme-kit/server'
43
+ import { bundle } from './bundle'
44
+ import manifestJson from './generated/manifest.json'
45
+ export const manifest = manifestJson
46
+ export const render = createRender({ manifest, bundle, storefront: { plan: { localization: true } } })
47
+ ```
48
+
49
+ ```tsx
50
+ // entry.client.tsx
51
+ import { hydrate } from '@tanqory/theme-kit/client'
52
+ import { bundle } from './bundle'
53
+ hydrate({ bundle })
54
+ ```
55
+
56
+ ```ts
57
+ // bundle.ts
58
+ import type { ThemeBundle } from '@tanqory/theme-kit/headless'
59
+ import theme from './theme'
60
+ export const bundle: ThemeBundle = {
61
+ theme, templates: {}, groups: {}, settings: {}, settingsSchema: {}, customSections: {}, manifest: null,
62
+ locales: import.meta.glob('./locales/*.json', { eager: true }),
63
+ }
64
+ ```
65
+
66
+ The manifest comes from your declarations: `buildManifest({ name, version, theme, settings, templates, forms })`
67
+ (see §7). `examples/aurora` in this repository is a complete theme built this way.
68
+
69
+ ## 2. `createRender({ storefront })`
70
+
71
+ `storefront` turns on what the headless API relies on. `storefront: {}` is enough; every member defaults to on.
72
+ Without it, the render is the 2.0.0-alpha.0 one, plus the hreflang alternates every theme gets from 2.0.0-alpha.2 (`createRender({ hreflang: false })` leaves them out).
73
+
74
+ | Member | Default | Effect |
75
+ |---|---|---|
76
+ | `structuredData` | `true` | BreadcrumbList JSON-LD (product, collection, page, article) and CollectionPage + ItemList on a collection. The product page's single Product JSON-LD is printed in every mode |
77
+ | `merchantStrings` | `true` | Reads the merchant's dashboard wording for your strings (`ctx.data.localization.strings`, one call beside the first round; the data plan keeps the call limit with it) and lets `t()` prefer it |
78
+ | `plan.localization` | `false` | Reads the shopper's country and lists the store's countries (the page then varies on `x-tq-country`). Needed by `<LocalizationForm>`'s country select |
79
+ | `plan.account` | `false` | Reads `request.isSignedIn` (the page then varies on it) for `useCustomer().signedIn` |
80
+ | `plan.recommendations` | `false` | Loads the product's recommendations in the server render (otherwise the browser loads them) |
81
+ | `plan.collections` | `false` | Loads the store's collection list |
82
+
83
+ The data plan also keeps its section conventions: a `header` or `footer` section with a `showLocale: true`
84
+ setting reads the country, a `header` section reads sign-in state unless `showAccount` is `false`, a
85
+ `product-recommendations` section loads recommendations, and a `collection-list` section loads every
86
+ collection. A section of type `not-found` renders the body of a 404 page.
87
+
88
+ The render also provides `usePage()` (route kind, handle, params, canonical, languages, assets base, merchant
89
+ strings) and copies it into the hydration state, so the browser renders from the same bytes.
90
+
91
+ ## 3. Declaring sections and blocks
92
+
93
+ ```ts
94
+ defineSection({
95
+ type: 'hero', // persisted: never rename once stores saved it
96
+ title: 'Hero', description?, category?, zone?: 'header' | 'main' | 'footer',
97
+ settings: { heading: field.text('After dark', { label: 'Heading' }), image: field.resource('image') },
98
+ blocks?: [defineBlock({ type: 'slide', title: 'Slide', settings: {…} })],
99
+ presets?: [{ name: 'Hero', settings?, blocks? }], // presets[0] is the editor's "Add section" preview
100
+ requires?: ['product'], // offered only on templates of these route kinds
101
+ ai?: ai.hero({ heading: 'heading', image: 'image' }),
102
+ component: ({ settings, blocks }) => …,
103
+ })
104
+ ```
105
+
106
+ The component receives `settings` resolved against the schema (defaults filled, coerced; a resource setting is
107
+ its handle string) and `blocks` in the merchant's order (`{ type, settings }`). The section renderer wraps every
108
+ section in its `data-tq-node="<id>"` element (`class="tq-node"`; style it `display: contents` to keep it out of
109
+ your layout), and
110
+ on the editor canvas a setting edit re-renders the section in place (`tq:canvas`, announced with
111
+ `tq:canvas-live`). You write nothing for either.
112
+
113
+ `field.*`: `text`, `textarea`, `richtext`, `url`, `color`, `boolean`, `select(options, default, { optionLabels })`,
114
+ `range(default, min, max, step, { unit })`, `number(…)`, `resource('image' | 'video' | 'menu' | 'collection' |
115
+ 'product' | 'page' | 'blog' | 'article', default?)`. Every field takes `{ label, info, placeholder, group }`.
116
+
117
+ ## 4. Data hooks
118
+
119
+ | Hook | Returns |
120
+ |---|---|
121
+ | `useSettings()` | the theme's global settings: the manifest defaults with the store's saved values over them |
122
+ | `useShop()` | `Shop`: name, logo, contact, social, payment methods, policies, consent banner config |
123
+ | `useMenu(handle)` | `Menu \| null` (items carry `active` for the current route) |
124
+ | `useProduct(handleOrProduct?)` | `{ product, variant, options[{ name, values[{ value, selected, available, variantId }] }], selectOption, selectVariant, price, compareAtPrice, onSale, available, quantityAvailable, image, quantity, setQuantity, unavailable }`. Without an argument: the enclosing `<ProductForm>`'s product, else the route's, opened on `?variant=` in the server render. A variant choice keeps `?variant=` in the URL |
125
+ | `useCollection(handle?)` | `{ collection, products, total, status, facets, selected, price, filtered, toggleFilter, setPrice, clearFilters, sort, sortOptions, setSort, hasMore, loadMore, page, pageHref }`. Inside `<CollectionProvider>` every caller shares one state. The route collection's sort and filters live in the URL (`?sort=`, `?filter.<facet>=`); the server renders `?sort=` and `?page=N`, a change re-asks the data plane |
126
+ | `useSearch()` | `{ query, products, articles, pages, total, sort, sortOptions, href(q, sort?) }` for `/search?q=` |
127
+ | `usePredictiveSearch(query, { limit, debounceMs })` | `{ results: { products[{ handle, title, url, price, image }], collections, queries } \| null, loading }` (browser, `data:search`) |
128
+ | `useCart()` | `{ cart, lines, itemCount, subtotal, total, checkoutUrl, ready, loading, loadError, isOpen, justAdded, open, close, add(variantId, qty), setQuantity, remove, setNote, isBusy(id), hasFailed(id), refusal(id) }` |
129
+ | `useCustomer()` | `{ signedIn: boolean \| null, accountUrl, accountHref }`. Customer data never reaches theme code |
130
+ | `useLocalization()` | `{ country, language, countries[{ code, name, currencyCode, currencySymbol, current }], languages[{ code, name, current }], changeCountry, changeLanguage, href({ country, language }) }` |
131
+ | `useRecommendations()` | `{ products, loading }` for the route's product |
132
+ | `useConsent()` | `{ required, accept, reject, decide, reopen, privacyUrl, text }` (`required` is never true on a preview render) |
133
+ | `usePageContent()` / `useBlog(handle?)` / `useArticle()` / `usePolicy()` | the route's content page `{ title, html }`, blog (with its articles), article (with `contentHtml`), published policy |
134
+ | `usePage()` | `{ kind, handle, params, canonical, language, ui, languages, preview, assetsBase, strings }` |
135
+
136
+ ## 5. Primitives
137
+
138
+ | Primitive | Renders | Behaviour |
139
+ |---|---|---|
140
+ | `<ProductForm product?>` | `<form data-tq-product-form>` | shares one product state; submit adds the selected variant and quantity (`cart.create` / `cart.addLines`), which opens the cart; a sold-out variant is never sent |
141
+ | `<VariantPicker>` | `<div data-tq-variant-picker>` → `<fieldset><legend>` + a labelled `<input type="radio">` per value (`data-selected`, `data-available` on the label) | selecting updates price, stock, image and `?variant=`; `renderValue` for swatches |
142
+ | `<ProductPrice>` | `<span data-tq-price>`, regular price in `<s>` on a sale | formatted in the market currency |
143
+ | `<ProductQuantity>` | labelled `<input type="number" min="1">` | |
144
+ | `<AddToCart>` | `<button type="submit" data-tq-action="cart:add">` | disabled and "Sold out" when the variant cannot be bought; "Adding…" in flight |
145
+ | `<CartToggle drawer?>` | `<a href="/cart" data-tq-action="cart:open" aria-haspopup="dialog" aria-expanded>` | opens the drawer (plain link without JavaScript) |
146
+ | `<CartDrawer>` | `role="dialog" aria-modal="true"` (+ optional backdrop) while open | focus moves in, Tab is trapped, Escape closes, focus returns to the opener |
147
+ | `<CartLine line>` | `<li data-tq-cart-line>` | gives its controls the line |
148
+ | `<CartLineQuantity>` | labelled `<input type="number" data-tq-quantity>` | saved on Enter or blur; 0 removes; invalid input is put back |
149
+ | `<CartLineIncrement>` / `<CartLineDecrement>` / `<CartLineRemove>` | buttons `data-tq-action="cart:increment"` / `cart:decrement` / `cart:remove` | disabled while the line's request is open |
150
+ | `<CheckoutButton>` | `<a data-tq-action="cart:checkout" href={Cart.checkoutUrl}>` | checkout is the platform's |
151
+ | `<CollectionProvider handle?>` | nothing | one `useCollection()` state for the subtree |
152
+ | `<SortSelect>` | `<form method="get">` + labelled `<select name="sort" data-tq-sort>` | re-sorts in place; without JavaScript the form submits `?sort=` |
153
+ | `<FacetFilters>` | `<div data-tq-filter>` → `<fieldset>` + checkbox per value (`data-active`), price from/to, "Clear filters" | |
154
+ | `<Pagination>` | `<nav data-tq-pagination>` → "Load more" `<a rel="next" href="?page=N">` | appends in place; a real page link without JavaScript |
155
+ | `<SearchForm>` | `<form role="search" action="/search">` + `<input type="search" name="q" data-tq-search>` + polite live region | predictive suggestions as links |
156
+ | `<LocalizationForm>` | `<form method="get" data-tq-localization>` + `<select name="country">` ("Japan (JPY ¥)") + `<select name="locale">` | a choice loads `?country=` / `?locale=` |
157
+ | `<NewsletterForm>` / `<ContactForm>` | `<form method="post" data-tq-form="newsletter\|contact">` + honeypot | native platform post (declare `forms` in the manifest); the gateway's CSRF fields are kept on hydration; status messages after the post |
158
+ | `<ConsentBanner>` | `<section data-tq-consent-banner aria-label>` | only when the platform asks; the merchant's wording wins; never in preview |
159
+ | `<AccountSlot>` | `<iframe data-tq-slot="account" sandbox="allow-scripts allow-forms allow-same-origin">` | the platform's account area on the customer route |
160
+
161
+ ## 6. Platform helpers
162
+
163
+ - **`t()`**: `const t = useTranslate(); t('product.addToCart')`, `t('cart.cartCount', { count })`. Lookup order:
164
+ the merchant's dashboard wording → your `locales/<lang>.json` → the kit's words for that language
165
+ (`KIT_STRINGS`, English and Thai) → English → the key. `withKitStrings(locales)` (build) lays your files over
166
+ the kit's, so every key the primitives use exists in every locale you ship.
167
+ - **`formatMoney(money, { display, trimZeros })`**: `$37.50`, `¥5,625`, `฿1,312.50`, `1.250 KWD`. The currency's
168
+ own minor units (`currencyDecimals`), identical on the server and in the browser.
169
+ - **`<Image image alt>`**: `image` is an image from the data or an image setting's URL; `https:` URLs, or `asset:client/<file>` under the artifact's asset base; anything
170
+ else renders `fallback`. Intrinsic width/height, `loading="lazy"`, `decoding="async"` by default.
171
+ - **`<Seo title description image noindex jsonLd>`**: overrides for this page's head, collected during the
172
+ server render. Title, description, canonical, Open Graph and the Product/Collection/Breadcrumb
173
+ JSON-LD are already printed from the data, and so are the hreflang alternates (every theme, `createRender({ hreflang })`, default on); a Product object in `jsonLd` is ignored (exactly one per page).
174
+ - **`<SkipLink>`**: to `#main`, the `<main>` the section renderer wraps the page body in.
175
+
176
+ ## 7. The manifest (`@tanqory/theme-kit/build`)
177
+
178
+ ```js
179
+ import { buildManifest, checkContent, withKitStrings } from '@tanqory/theme-kit/build'
180
+ import { validateManifest, validateFieldValue } from '@tanqory/theme-abi'
181
+
182
+ const { manifest, problems } = buildManifest({
183
+ name: '@acme/theme', version: '1.0.0', theme,
184
+ settings, // defineSettings({...}) → settingsSchema, grouped by `group`
185
+ templates: { index: { route: 'home' }, product: { route: 'product' }, '404': { route: 'not_found' }, … },
186
+ forms: { newsletter: true, contact: true },
187
+ capabilities: { server: ['data:inventory'], browser: ['data:inventory'] },
188
+ checkValue: validateFieldValue,
189
+ })
190
+ ```
191
+
192
+ It derives `components` (sections and blocks with their attributes, regions, children, parents, requires,
193
+ presets), `settingsSchema`, `routes`, `templates`, `regions` (header and footer shared, `main` per template),
194
+ `forms` and `x-tanqory-ai`. Validate the result with `validateManifest` before writing it.
195
+
196
+ **Capabilities.** The defaults are what the kit's runtime calls (`SERVER_CAPABILITIES`, `BROWSER_CAPABILITIES`).
197
+ `data:shop` is always declared: the platform gives shop data to the browser snapshot only to a theme that
198
+ declares it (decision D6). Add `data:inventory` to show stock counts.
199
+
200
+ ## 8. AI compatibility
201
+
202
+ Declare which of your sections play the roles Tanqory AI fills; the build prints the profile as
203
+ `manifest["x-tanqory-ai"]` (draft v0) and `checkAiProfile` verifies every component, block and setting it names.
204
+
205
+ | Helper | Role | Keys (setting types) |
206
+ |---|---|---|
207
+ | `ai.hero({ heading, subheading?, image?, button?, link?, block? })` | `hero` | text / image / text / url |
208
+ | `ai.headerMenu(setting)` | `headerMenu` | a `menu` setting |
209
+ | `ai.footerMenu(setting, { block })` | `footerMenus` | a `menu` setting (usually on a block) |
210
+ | `ai.footerBrand({ block? })` | `footerBrand` | |
211
+ | `ai.productGrid(setting, { heading? })` | `productGrid` | a `collection` or `product` setting |
212
+ | `ai.richText({ heading?, body? })` | `richText` | text settings |
213
+
214
+ ## 9. Storefront hooks emitted (`tq-storefront-hooks/1`)
215
+
216
+ `data-tq-action="cart:add|cart:open|cart:checkout|cart:remove|cart:increment"`, `data-tq-quantity`,
217
+ `data-tq-price`, `data-tq-variant-picker`, `data-tq-sort`, `data-tq-filter`, `data-tq-pagination`,
218
+ `data-tq-localization`, `data-tq-search`, `data-tq-consent-banner`, plus `data-tq-form`, `data-tq-slot="account"`
219
+ and `data-tq-node` from the platform contract. A menu button for a mobile menu is the theme's own markup: give it
220
+ `data-tq-action="menu:open"`.
package/package.json CHANGED
@@ -1,43 +1,97 @@
1
1
  {
2
2
  "name": "@tanqory/theme-kit",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "description": "Framework for Tanqory React themes — block registry, JSON-tree renderer, data layer, mount(). Themes depend on this and only author blocks/ + pages/.",
3
+ "version": "2.0.0-alpha.17",
4
+ "description": "Tanqory theme kit for Theme ABI v2: the headless storefront API (data hooks, accessible commerce primitives, SEO, i18n, live edit), the runtime behind it (data plan, cart, wire client) and the render/hydrate entry factories a theme builds on.",
5
+ "license": "MIT",
6
+ "author": "Tanqory",
7
+ "keywords": [
8
+ "tanqory",
9
+ "theme",
10
+ "storefront",
11
+ "headless",
12
+ "react",
13
+ "ecommerce"
14
+ ],
6
15
  "repository": {
7
16
  "type": "git",
8
- "url": "git+https://github.com/tanqory/tanqory-platform-studio-new.git",
9
- "directory": "packages/theme-kit"
17
+ "url": "git+https://github.com/tanqory/tanqory-platform-theme-kit.git"
10
18
  },
11
- "publishConfig": {
12
- "registry": "https://registry.npmjs.org",
13
- "access": "public"
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=20.0.0",
22
+ "pnpm": ">=9.7.0"
14
23
  },
15
- "files": ["dist"],
24
+ "packageManager": "pnpm@9.15.4",
16
25
  "main": "./dist/index.js",
17
- "module": "./dist/index.js",
18
- "types": "./dist/types/index.d.ts",
26
+ "types": "./dist/index.d.ts",
19
27
  "exports": {
20
28
  ".": {
21
- "types": "./dist/types/index.d.ts",
29
+ "types": "./dist/index.d.ts",
22
30
  "default": "./dist/index.js"
23
31
  },
24
- "./ssg": {
25
- "types": "./dist/types/ssg.d.ts",
26
- "default": "./dist/ssg.js"
27
- }
32
+ "./server": {
33
+ "types": "./dist/server.d.ts",
34
+ "default": "./dist/server.js"
35
+ },
36
+ "./client": {
37
+ "types": "./dist/client.d.ts",
38
+ "default": "./dist/client.js"
39
+ },
40
+ "./headless": {
41
+ "types": "./dist/headless/index.d.ts",
42
+ "default": "./dist/headless/index.js"
43
+ },
44
+ "./runtime": {
45
+ "types": "./dist/runtime.d.ts",
46
+ "default": "./dist/runtime.js"
47
+ },
48
+ "./contract": {
49
+ "types": "./dist/contract.d.ts",
50
+ "default": "./dist/contract.js"
51
+ },
52
+ "./build": {
53
+ "types": "./dist/build.d.ts",
54
+ "default": "./dist/build.js"
55
+ },
56
+ "./package.json": "./package.json"
57
+ },
58
+ "files": [
59
+ "dist",
60
+ "docs",
61
+ "README.md",
62
+ "LICENSE"
63
+ ],
64
+ "publishConfig": {
65
+ "access": "public",
66
+ "registry": "https://registry.npmjs.org/",
67
+ "tag": "alpha"
28
68
  },
29
69
  "scripts": {
30
- "build": "vite build && tsc -p tsconfig.json --emitDeclarationOnly --declaration --outDir dist/types",
31
- "typecheck": "tsc -p tsconfig.json --noEmit"
70
+ "typecheck": "tsc -p tsconfig.json --noEmit",
71
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && node scripts/check-dist.mjs",
72
+ "test": "vitest run",
73
+ "check": "pnpm typecheck && pnpm test && pnpm build"
32
74
  },
33
75
  "peerDependencies": {
34
- "react": "^18 || ^19",
35
- "react-dom": "^18 || ^19"
76
+ "@tanqory/theme-abi": ">=2.0.0-alpha.11",
77
+ "react": "~18.3.1",
78
+ "react-dom": "~18.3.1"
36
79
  },
37
80
  "devDependencies": {
81
+ "@tanqory/theme-abi": "link:../theme-abi",
82
+ "@testing-library/dom": "^10.4.0",
83
+ "@testing-library/react": "^16.3.0",
84
+ "@testing-library/user-event": "^14.6.1",
85
+ "@types/node": "^22.20.5",
38
86
  "@types/react": "^18.3.12",
39
87
  "@types/react-dom": "^18.3.1",
40
- "typescript": "^5.6.3",
41
- "vite": "^5.4.10"
88
+ "axe-core": "^4.10.3",
89
+ "husky": "^9.1.7",
90
+ "jsdom": "^25.0.1",
91
+ "react": "18.3.1",
92
+ "react-dom": "18.3.1",
93
+ "typescript": "~5.9.3",
94
+ "vite": "^5.4.10",
95
+ "vitest": "^3.2.4"
42
96
  }
43
97
  }
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/defineSection.ts","../src/config.ts","../src/editor.tsx","../src/preview-bridge.tsx","../src/mount.tsx","../src/dynamic-source.tsx","../src/jsx-to-json.ts","../src/composition.ts"],"sourcesContent":["import type { SectionDef } from './types'\n\n/**\n * Declare a section (a top-level, editor-placeable unit). Attaches `blockName`\n * to the component so a JSX composition (`<Hero/>`) can be walked back into the\n * content tree (see jsx-to-json.ts).\n */\nexport function defineSection(def: SectionDef): SectionDef {\n ;(def.component as unknown as { blockName?: string }).blockName = def.name\n return def\n}\n","export interface ThemeConfig {\n name: string\n routes: Record<string, string>\n data: {\n mode: 'mock' | 'live'\n /** Cell store-api base, e.g. https://api-do-sgp1.tanqory.com (live mode). */\n endpoint?: string | undefined\n /** Store UUID to preview against (live mode). */\n storeId?: string | undefined\n /** Publishable storefront token — `x-publishable-key` (live mode, optional). */\n token?: string | undefined\n }\n tokens?: string\n}\n\nexport function defineTheme(config: ThemeConfig): ThemeConfig {\n return config\n}\n\nimport type { AttrSpec } from './types'\n\n/** Global theme settings schema (drives the editor's \"Theme settings\" panel). */\nexport type SettingsSchema = Record<string, AttrSpec>\n\nexport function defineSettings(schema: SettingsSchema): SettingsSchema {\n return schema\n}\n","import { useState } from 'react'\nimport type { AttrSpec, ContentNode } from './types'\nimport { getSection, allSections } from './registry'\nimport { SectionTree } from './SectionTree'\n\n// ─── tree helpers (path = number[] into nested .blocks) ─────────────────────\ntype Path = number[]\nconst samePath = (a: Path, b: Path) => a.length === b.length && a.every((v, i) => v === b[i])\n\nfunction nodeAt(tree: ContentNode[], path: Path): ContentNode | undefined {\n let nodes = tree\n let node: ContentNode | undefined\n for (const i of path) { node = nodes[i]; nodes = node?.blocks ?? [] }\n return node\n}\nfunction updateAt(tree: ContentNode[], path: Path, fn: (n: ContentNode) => ContentNode): ContentNode[] {\n const [i, ...rest] = path\n return tree.map((n, k) =>\n k !== i ? n : rest.length === 0 ? fn(n) : { ...n, blocks: updateAt(n.blocks ?? [], rest, fn) },\n )\n}\nfunction removeAt(tree: ContentNode[], path: Path): ContentNode[] {\n const [i, ...rest] = path\n if (rest.length === 0) return tree.filter((_, k) => k !== i)\n return tree.map((n, k) => (k !== i ? n : { ...n, blocks: removeAt(n.blocks ?? [], rest) }))\n}\nfunction insertChild(tree: ContentNode[], parent: Path, node: ContentNode): ContentNode[] {\n if (parent.length === 0) return [...tree, node]\n const [i, ...rest] = parent\n return tree.map((n, k) => (k !== i ? n : { ...n, blocks: insertChild(n.blocks ?? [], rest, node) }))\n}\nfunction reorder(tree: ContentNode[], parent: Path, from: number, to: number): ContentNode[] {\n const moveArr = (arr: ContentNode[]) => { const c = [...arr]; const [m] = c.splice(from, 1); c.splice(to, 0, m); return c }\n if (parent.length === 0) return moveArr(tree)\n const [i, ...rest] = parent\n return tree.map((n, k) => (k !== i ? n : { ...n, blocks: reorder(n.blocks ?? [], rest, from, to) }))\n}\nfunction defaultsFor(type: string): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n for (const [k, s] of Object.entries(getSection(type)?.attributes ?? {})) if (s.default !== undefined) out[k] = s.default\n return out\n}\nconst newNode = (type: string): ContentNode => ({ type, id: `${type}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`, settings: defaultsFor(type) })\n\n// ─── inputs ──────────────────────────────────────────────────────────────\nfunction Field({ name, spec, value, onChange }: { name: string; spec: AttrSpec; value: unknown; onChange: (v: unknown) => void }): JSX.Element {\n const label = spec.label ?? name\n const c = { style: { width: '100%', padding: '6px 8px', boxSizing: 'border-box' as const } }\n let input: JSX.Element\n if (spec.type === 'textarea') input = <textarea {...c} rows={3} value={String(value ?? '')} onChange={(e) => onChange(e.target.value)} />\n else if (spec.type === 'color') input = <input type=\"color\" value={String(value ?? '#000000')} onChange={(e) => onChange(e.target.value)} />\n else if (spec.type === 'number') input = <input {...c} type=\"number\" value={Number(value ?? 0)} onChange={(e) => onChange(Number(e.target.value))} />\n else if (spec.type === 'boolean') input = <input type=\"checkbox\" checked={Boolean(value)} onChange={(e) => onChange(e.target.checked)} />\n else input = <input {...c} type=\"text\" value={String(value ?? '')} onChange={(e) => onChange(e.target.value)} />\n return <label style={{ display: 'block', margin: '0 0 12px' }}><span style={{ display: 'block', fontSize: 12, color: '#666', marginBottom: 4 }}>{label}</span>{input}</label>\n}\nconst btn = (active = false): React.CSSProperties => ({ border: '1px solid', borderColor: active ? '#111' : '#e5e5e5', borderRadius: 6, background: active ? '#111' : '#fff', color: active ? '#fff' : '#111', cursor: 'pointer', font: 'inherit' })\n\n// ─── editor (multi-page + nested + drag-drop) ───────────────────────────────\nexport function Editor({ pages, initialPage = 'index' }: { pages: Record<string, ContentNode[]>; initialPage?: string }): JSX.Element {\n const pageNames = Object.keys(pages)\n const [trees, setTrees] = useState<Record<string, ContentNode[]>>(pages)\n const [page, setPage] = useState(pageNames.includes(initialPage) ? initialPage : pageNames[0] ?? 'index')\n const [sel, setSel] = useState<Path>([0])\n const [addParent, setAddParent] = useState<Path | null>(null)\n const [status, setStatus] = useState('')\n const [drag, setDrag] = useState<{ parent: string; index: number } | null>(null)\n\n const tree = trees[page] ?? []\n const setTree = (fn: (t: ContentNode[]) => ContentNode[]) => setTrees((all) => ({ ...all, [page]: fn(all[page] ?? []) }))\n const node = nodeAt(tree, sel)\n const def = node ? getSection(node.type) : undefined\n\n const save = async () => {\n setStatus('saving…')\n const res = await fetch('/__studio/save', {\n method: 'POST', headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ page, doc: { sections: trees[page] ?? [] } }),\n })\n setStatus(res.ok ? `saved ${page} ✓` : 'save failed')\n }\n\n const onDrop = (parent: Path, to: number) => {\n if (drag && drag.parent === parent.join('.')) setTree((t) => reorder(t, parent, drag.index, to))\n setDrag(null)\n }\n\n const inserter = (parent: Path, allow?: string[]) => {\n const opts = allSections().filter((s) => !allow || allow.includes(s.name))\n return (\n <div style={{ margin: '2px 0 8px', marginLeft: (parent.length + 1) * 14, border: '1px solid #eee', borderRadius: 6, padding: 6 }}>\n {opts.map((s) => (\n <button key={s.name} onClick={() => { setTree((t) => insertChild(t, parent, newNode(s.name))); setAddParent(null) }}\n style={{ ...btn(), display: 'block', width: '100%', textAlign: 'left', padding: '5px 8px', marginBottom: 2 }}>\n {s.icon ?? '▪'} {s.title}\n </button>\n ))}\n </div>\n )\n }\n\n const renderList = (nodes: ContentNode[], parent: Path): JSX.Element[] =>\n nodes.map((n, i) => {\n const path = [...parent, i]\n const sec = getSection(n.type)\n return (\n <div key={n.id ?? i}>\n <div draggable onDragStart={() => setDrag({ parent: parent.join('.'), index: i })}\n onDragOver={(e) => e.preventDefault()} onDrop={() => onDrop(parent, i)}\n style={{ display: 'flex', gap: 4, marginBottom: 4, marginLeft: parent.length * 14 }}>\n <span style={{ cursor: 'grab', color: '#bbb', padding: '0 2px' }}>⠿</span>\n <button onClick={() => setSel(path)} style={{ ...btn(samePath(path, sel)), flex: 1, textAlign: 'left', padding: '6px 8px' }}>\n {sec?.icon ?? '▪'} {sec?.title ?? n.type}\n </button>\n {sec?.allowedBlocks?.length ? <button title=\"add child\" onClick={() => setAddParent(path)} style={{ ...btn(), width: 26 }}>+</button> : null}\n <button title=\"remove\" onClick={() => { setTree((t) => removeAt(t, path)); setSel([0]) }} style={{ ...btn(), width: 26, color: '#c0392b' }}>✕</button>\n </div>\n {n.blocks?.length ? renderList(n.blocks, path) : null}\n {addParent && samePath(addParent, path) ? inserter(path, sec?.allowedBlocks) : null}\n </div>\n )\n })\n\n return (\n <div style={{ display: 'grid', gridTemplateColumns: '300px 1fr 320px', height: '100vh', fontFamily: 'system-ui' }}>\n {/* LEFT — section tree (drag to reorder, add / remove / nest) */}\n <aside style={{ borderRight: '1px solid #e5e5e5', overflow: 'auto', padding: 16 }}>\n <select value={page} onChange={(e) => { setPage(e.target.value); setSel([0]) }} style={{ width: '100%', padding: '6px 8px', marginBottom: 12 }}>\n {pageNames.map((p) => <option key={p} value={p}>{p}</option>)}\n </select>\n\n <strong style={{ fontSize: 13 }}>SECTIONS — drag ⠿ to reorder</strong>\n <div style={{ margin: '8px 0' }}>{renderList(tree, [])}</div>\n\n <button onClick={() => setAddParent([])} style={{ ...btn(), padding: '8px 10px', width: '100%' }}>+ Add section</button>\n {addParent && addParent.length === 0 ? inserter([]) : null}\n\n <button onClick={save} style={{ marginTop: 16, padding: '10px 16px', border: 'none', borderRadius: 6, background: '#111', color: '#fff', cursor: 'pointer', width: '100%' }}>Save</button>\n <div style={{ fontSize: 12, color: '#666', marginTop: 8 }}>{status}</div>\n </aside>\n\n {/* MIDDLE — live canvas */}\n <main style={{ overflow: 'auto' }}><SectionTree tree={tree} /></main>\n\n {/* RIGHT — props of the selected section (from its schema) */}\n <aside style={{ borderLeft: '1px solid #e5e5e5', overflow: 'auto', padding: 16 }}>\n {def ? (\n <>\n <strong style={{ fontSize: 13 }}>{def.title.toUpperCase()} SETTINGS</strong>\n <div style={{ marginTop: 8 }}>\n {Object.entries(def.attributes ?? {}).map(([k, spec]) => (\n <Field key={k} name={k} spec={spec} value={node!.settings?.[k] ?? spec.default}\n onChange={(v) => setTree((t) => updateAt(t, sel, (nn) => ({ ...nn, settings: { ...nn.settings, [k]: v } })))} />\n ))}\n </div>\n </>\n ) : (\n <div style={{ color: '#888', fontSize: 13 }}>Select a section in the tree to edit its settings.</div>\n )}\n </aside>\n </div>\n )\n}\n","import React, { useEffect, useRef, useState, type FC, type ReactNode } from 'react'\nimport { SectionTree } from './SectionTree'\nimport { useData } from './data'\nimport type { ContentNode } from './types'\n\n/**\n * Preview bridge — the EDIT-plane runtime that lives INSIDE the iframe.\n *\n * Unlike `?edit` (which mounts the whole editor inside the theme bundle), the\n * bridge ships no editor UI: it only (1) renders the content tree and (2) speaks\n * postMessage with the parent editor app. The editor chrome lives in a separate\n * app (apps/studio-editor) and drives this iframe.\n *\n * Protocol (namespaced `tq:`):\n * iframe → parent : { type:'tq:ready', pages } on mount\n * { type:'tq:select', path } when a section is clicked\n * parent → iframe : { type:'tq:set-content', page?, doc? } render this tree\n * { type:'tq:select', path } highlight a node\n */\nconst isMsg = (m: unknown): m is { type: string; [k: string]: unknown } =>\n !!m && typeof m === 'object' && typeof (m as { type?: unknown }).type === 'string'\n\nexport function PreviewBridge({\n pages,\n initialPage,\n Shell,\n}: {\n pages: Record<string, ContentNode[]>\n initialPage: string\n Shell: FC<{ children: ReactNode }>\n}): JSX.Element {\n const [tree, setTree] = useState<ContentNode[]>(pages[initialPage] ?? [])\n const [selected, setSelected] = useState<number[] | null>(null)\n const data = useData()\n // Post to the parent AND the top window. The editor canvas may nest this\n // preview inside another iframe (e.g. the block-editor canvas iframe), in which\n // case `window.parent` is that intermediate frame, not the editor window that\n // listens for selection/content messages — so we also target `window.top`.\n const send = (msg: object) => {\n try {\n window.parent?.postMessage(msg, '*')\n if (window.top && window.top !== window.parent) window.top.postMessage(msg, '*')\n } catch {\n /* cross-origin top access can throw — parent post already attempted */\n }\n }\n\n // Keep the latest tree in a ref so the message handler can return it on\n // demand (the editor's Publish reads the LIVE-edited content straight from\n // the preview — the source of truth for \"what's on screen\").\n const treeRef = useRef<ContentNode[]>(tree)\n useEffect(() => { treeRef.current = tree }, [tree])\n\n // Write-through (lovable-style): on every content change, push the current\n // content to the editor host so it persists the draft immediately — no\n // explicit \"save\". `firstRender` skips the initial mount so we don't re-save\n // the just-loaded draft. The host debounces.\n const firstRender = useRef(true)\n useEffect(() => {\n if (firstRender.current) { firstRender.current = false; return }\n send({ type: 'tanqory-content-changed', content: { sections: tree } })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tree])\n\n useEffect(() => {\n const onMsg = (e: MessageEvent) => {\n if (!isMsg(e.data)) return\n if (e.data.type === 'tanqory-get-content') {\n // reply with the current (live-edited) page content in theme-kit format\n send({ type: 'tanqory-content', requestId: e.data.requestId ?? null, content: { sections: treeRef.current } })\n } else if (e.data.type === 'tq:set-content') {\n if (Array.isArray(e.data.doc)) setTree(e.data.doc as ContentNode[])\n else if (typeof e.data.page === 'string' && pages[e.data.page]) setTree(pages[e.data.page])\n } else if (e.data.type === 'tq:select') {\n setSelected(Array.isArray(e.data.path) ? (e.data.path as number[]) : null)\n } else if (e.data.type === 'tanqory-preview-update-section') {\n // studio-editor edited a section's settings (and possibly its child\n // blocks) → merge + re-render live. The editor sends blocks in its\n // OWN shape (object map keyed by id + order[]) — convert to\n // theme-kit's array here so render code only ever sees arrays.\n const id = e.data.sectionId as string\n const s = (e.data.settings ?? {}) as Record<string, unknown>\n const rawBlocks = e.data.blocks as Record<string, ContentNode> | ContentNode[] | null\n const order = e.data.order as string[] | null\n let blocks: ContentNode[] | undefined\n if (Array.isArray(rawBlocks)) {\n blocks = rawBlocks\n } else if (rawBlocks && typeof rawBlocks === 'object') {\n const ids = Array.isArray(order) && order.length ? order : Object.keys(rawBlocks)\n blocks = ids\n .filter((bid) => rawBlocks[bid])\n .map((bid) => ({ ...rawBlocks[bid], id: rawBlocks[bid].id ?? bid }))\n }\n setTree((t) =>\n t.map((n) =>\n n.id === id\n ? { ...n, settings: { ...n.settings, ...s }, ...(blocks ? { blocks } : {}) }\n : n,\n ),\n )\n } else if (e.data.type === 'tanqory-preview-select') {\n const id = e.data.sectionId as string\n setTree((t) => { const i = t.findIndex((n) => n.id === id); setSelected(i >= 0 ? [i] : null); return t })\n // Scroll the canvas to the clicked section (editor tree → preview, like\n // Shopify). The section wrapper is `display:contents` (no layout box), so\n // scroll its first real child element into view instead.\n if (typeof document !== 'undefined' && id) {\n const sel = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(id) : id\n requestAnimationFrame(() => {\n const wrap = document.querySelector(`[data-tq-section-id=\"${sel}\"]`)\n const target = (wrap?.firstElementChild as HTMLElement | null) ?? (wrap as HTMLElement | null)\n target?.scrollIntoView({ behavior: 'smooth', block: 'start' })\n })\n }\n } else if (e.data.type === 'tanqory-preview-reorder-sections') {\n // Reorder the EXISTING nodes in place (same object refs, keyed by id)\n // so React moves the DOM instead of rebuilding the whole tree — this is\n // what kills the flicker on drag/swap. A full `tq:set-content` would\n // re-mount every section. Any node the editor didn't list is preserved.\n const order = e.data.order as string[]\n if (Array.isArray(order)) {\n setTree((t) => {\n const byId = new Map(t.map((n) => [n.id, n]))\n const next = order.map((id) => byId.get(id)).filter(Boolean) as ContentNode[]\n for (const n of t) if (!order.includes(n.id as string)) next.push(n)\n return next.length ? next : t\n })\n }\n } else if (e.data.type === 'tanqory-preview-remove-section') {\n const id = e.data.sectionId as string\n setTree((t) => t.filter((n) => n.id !== id))\n } else if (e.data.type === 'tanqory-preview-insert-section') {\n // Splice ONE new node in after `afterSectionId` (or at the top) — no\n // full-tree replace. Blocks arrive as the editor's id-map + order array;\n // convert to theme-kit's array shape (same as update-section).\n const id = e.data.sectionId as string\n const rawBlocks = e.data.blocks as Record<string, ContentNode> | ContentNode[] | null\n const order = e.data.order as string[] | null\n let blocks: ContentNode[] | undefined\n if (Array.isArray(rawBlocks)) {\n blocks = rawBlocks\n } else if (rawBlocks && typeof rawBlocks === 'object') {\n const ids = Array.isArray(order) && order.length ? order : Object.keys(rawBlocks)\n blocks = ids\n .filter((bid) => rawBlocks[bid])\n .map((bid) => ({ ...rawBlocks[bid], id: rawBlocks[bid].id ?? bid }))\n }\n const node: ContentNode = {\n id,\n type: e.data.sectionType as string,\n settings: (e.data.settings ?? {}) as Record<string, unknown>,\n ...(blocks ? { blocks } : {}),\n }\n const after = e.data.afterSectionId as string | null\n setTree((t) => {\n if (t.some((n) => n.id === id)) return t\n const idx = after ? t.findIndex((n) => n.id === after) : -1\n const next = [...t]\n next.splice(idx + 1, 0, node)\n return next\n })\n } else if (e.data.type === 'tanqory-request-collections') {\n // Editor needs to populate a `type: 'collection'` picker — reply with\n // every collection the bootstrap query loaded so the merchant sees\n // their actual storefront catalogue, not a typed-in handle.\n const collections = data.allCollections().map((c) => ({\n handle: c.handle,\n title: c.title,\n productCount: c.products.length,\n }))\n send({ type: 'tanqory-collections', requestId: e.data.requestId ?? null, collections })\n } else if (e.data.type === 'tanqory-request-menus') {\n // Editor needs to populate a `type: 'link_list'` picker — reply with\n // every menu the store has (Dashboard → Navigation), so the merchant\n // picks a real menu instead of typing a handle.\n const requestId = e.data.requestId ?? null\n void Promise.resolve(data.listMenus?.() ?? [])\n .then((menus) => send({ type: 'tanqory-menus', requestId, menus }))\n .catch(() => send({ type: 'tanqory-menus', requestId, menus: [] }))\n } else if (e.data.type === 'tanqory-request-products') {\n // Same idea as collections — flatten every product across collections,\n // dedupe by handle (first occurrence wins, matching SectionTree's\n // canonical-handle rule), and hand the editor enough metadata to\n // render a search/filter picker without a second round-trip.\n const seen = new Set<string>()\n const products: Array<{ handle: string; title: string; price: string; image: string | null }> = []\n for (const c of data.allCollections()) {\n for (const p of c.products) {\n if (seen.has(p.handle)) continue\n seen.add(p.handle)\n products.push({\n handle: p.handle,\n title: p.title,\n price: p.price?.amount ?? '',\n image: p.featuredImage?.url ?? null,\n })\n }\n }\n send({ type: 'tanqory-products', requestId: e.data.requestId ?? null, products })\n }\n }\n window.addEventListener('message', onMsg)\n send({ type: 'tq:ready', pages: Object.keys(pages) })\n return () => window.removeEventListener('message', onMsg)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n // Click any element inside a rendered section → report its identity so the\n // editor can highlight the matching row in the tree and surface its\n // settings panel. We send BOTH the legacy `tq:select` (with path) and the\n // editor's `tanqory-section-selected` (with sectionId) — the editor side\n // only listens to the latter, but external tooling may still be on tq:.\n //\n // Preview-mode click handling also short-circuits internal navigation:\n // anchors inside a section would otherwise pull the iframe off the page\n // the editor is editing. Section CTAs become \"select this\" while the\n // editor is open.\n const onClickCapture = (e: React.MouseEvent) => {\n const target = e.target as HTMLElement\n // The innermost wrapper is the node actually clicked — a child BLOCK when the\n // click lands inside one (RenderNode wraps every node), otherwise the section.\n const nodeEl = target.closest<HTMLElement>('[data-tq-section-id]')\n if (!nodeEl) return\n const nodeId = nodeEl.dataset.tqSectionId\n const pathAttr = nodeEl.dataset.tqPath\n if (target.closest('a, button[type=\"submit\"]')) {\n e.preventDefault()\n }\n // Visible selection feedback ON THE CANVAS. The node wrapper is\n // display:contents (no box of its own), so outline its first rendered child.\n // This is what makes a canvas click feel like an outline-tree selection.\n const root = e.currentTarget as HTMLElement\n const prevBox = root.querySelector<HTMLElement>('[data-tq-outlined]')\n if (prevBox) {\n prevBox.style.outline = ''\n prevBox.style.outlineOffset = ''\n prevBox.removeAttribute('data-tq-outlined')\n }\n const box = nodeEl.firstElementChild as HTMLElement | null\n if (box) {\n box.style.outline = '2px solid #2563eb'\n box.style.outlineOffset = '-2px'\n box.setAttribute('data-tq-outlined', '1')\n }\n if (pathAttr) {\n const path = pathAttr.split('.').map(Number)\n setSelected(path)\n send({ type: 'tq:select', path })\n }\n // A nested path (e.g. \"3.1\") means a child BLOCK was clicked — select it\n // WITHIN its parent section so the editor opens the block's settings, not the\n // whole section's. The parent section is the node at the path's first segment.\n // blockId is the block's id (data-tq-section-id), which the editor keys blocks\n // by — so it resolves to the same block the outline + settings panel use.\n const container = e.currentTarget as HTMLElement\n const isBlock = !!pathAttr && pathAttr.includes('.')\n if (isBlock && nodeId) {\n const sectionPath = (pathAttr as string).split('.')[0]\n const sectionEl =\n container.querySelector<HTMLElement>(`[data-tq-path=\"${sectionPath}\"]`) ??\n nodeEl.parentElement?.closest<HTMLElement>('[data-tq-section-id]')\n const sectionId = sectionEl?.dataset.tqSectionId\n if (sectionId) {\n send({ type: 'tanqory-block-selected', sectionId, blockId: nodeId })\n return\n }\n }\n if (nodeId) {\n send({ type: 'tanqory-section-selected', sectionId: nodeId })\n }\n }\n\n return (\n <div onClickCapture={onClickCapture} data-tq-selected={selected?.join('.') ?? ''}>\n <Shell>\n <SectionTree tree={tree} />\n </Shell>\n </div>\n )\n}\n","import React, { type FC, type ReactNode } from 'react'\nimport { createRoot, hydrateRoot } from 'react-dom/client'\n\nimport { registerSections } from './registry'\nimport { SectionTree } from './SectionTree'\nimport { DataProvider, type DataApi } from './data'\nimport { CartProvider } from './cart'\nimport { ThemeProvider } from './theme-context'\nimport { Editor } from './editor'\nimport { PreviewBridge } from './preview-bridge'\nimport type { SectionDef, PageDoc, ContentNode } from './types'\n\n// Vite's import.meta.glob(..., { eager: true }) types each value as `unknown`,\n// so the theme entry passes plain glob maps with no generics. We narrow here.\ntype GlobMap = Record<string, unknown>\n\nexport interface MountOptions {\n /** import.meta.glob('./sections/*.tsx', { eager: true }) — run in the THEME. */\n sections: GlobMap\n /** import.meta.glob('./templates/*.json', { eager: true }). */\n pages: GlobMap\n /** import.meta.glob('./layouts/*.tsx', { eager: true }) — optional. */\n shell?: GlobMap\n /** Data source the theme provides (createMockData(...) or a live client). */\n data: DataApi\n /** Global settings values (config/settings.json). */\n settings?: Record<string, unknown>\n /** Locale strings (locales/<lang>.json). */\n locale?: Record<string, string>\n /** Which page to render (default 'index'). */\n page?: string\n /** Mount target id (default 'root'). */\n rootId?: string\n /**\n * SWR refresh: the initial render uses `data` (the SSG snapshot — so\n * hydration matches the server markup by construction), then this runs once\n * after mount and the fresh result is swapped in. Return null/reject to keep\n * the snapshot data (e.g. the network is down).\n */\n revalidate?: () => Promise<DataApi | null>\n /**\n * Force client rendering even when SSG markup exists in the root (wipe +\n * createRoot instead of hydrateRoot). Pass when the prerendered markup is\n * known NOT to match what the client will render — a different page than the\n * one that was prerendered, or no data snapshot to hydrate with — because\n * hydrating against mismatched markup throws React #418/#425.\n */\n forceClientRender?: boolean\n}\n\nfunction defaultsOf<T>(map: GlobMap): T[] {\n return Object.values(map).map((m) => (m as { default: T }).default)\n}\n\nfunction pickByName<T>(map: GlobMap, name: string): T | undefined {\n const hit = Object.entries(map).find(\n ([key]) => key.endsWith(`/${name}.json`) || key.endsWith(`/${name}.tsx`),\n )\n return hit ? (hit[1] as { default: T }).default : undefined\n}\n\n/**\n * Boot a theme. The theme's entry passes its globbed sections/templates/layouts\n * (so Vite resolves them relative to the theme) plus a data source. Everything\n * else — registry, tree rendering, providers — is the framework.\n */\nexport function mount(opts: MountOptions): void {\n registerSections(defaultsOf<SectionDef>(opts.sections))\n\n const shells = opts.shell ? defaultsOf<FC<{ children: ReactNode }>>(opts.shell) : []\n const Shell: FC<{ children: ReactNode }> = shells[0] ?? (({ children }) => <>{children}</>)\n\n const pageDoc = pickByName<PageDoc>(opts.pages, opts.page ?? 'index') ?? { sections: [] }\n const rootEl = document.getElementById(opts.rootId ?? 'root')\n if (!rootEl) throw new Error('[tanqory] mount target not found')\n\n // `?edit=true` → visual editor (EDIT plane); otherwise the storefront (SERVE).\n // Bare `?edit` counts as on; an explicit falsey value (`?edit=false` / `?edit=0`)\n // stays on the storefront, so the flag can be toggled off from the URL without\n // dropping the param. Editing only persists on the EDIT-plane sandbox (vite dev,\n // `preview-<slug>`); the published `<slug>` is static and has no save endpoint.\n const params = typeof location !== 'undefined' ? new URLSearchParams(location.search) : new URLSearchParams()\n const on = (k: string) => { const v = params.get(k); return v !== null && v !== 'false' && v !== '0' }\n // PREVIEW plane = the dedicated `preview-<themeId>.<domain>` host (the editor\n // canvas) — render the postMessage bridge. `?preview`/`?edit` still work for\n // local/dev. Otherwise the storefront (SERVE plane / production <slug>).\n const previewHost = typeof location !== 'undefined' && /^preview-/.test(location.hostname)\n const previewMode = previewHost || on('preview')\n const editMode = on('edit')\n\n // All pages (name → sections) so the editor can switch between templates.\n const pagesByName: Record<string, ContentNode[]> = {}\n for (const [key, mod] of Object.entries(opts.pages)) {\n const name = key.replace(/^.*\\//, '').replace(/\\.json$/, '')\n pagesByName[name] = (mod as { default?: PageDoc }).default?.sections ?? []\n }\n\n const content = previewMode ? (\n <PreviewBridge pages={pagesByName} initialPage={opts.page ?? 'index'} Shell={Shell} />\n ) : editMode ? (\n <Editor pages={pagesByName} initialPage={opts.page ?? 'index'} />\n ) : (\n <Shell>\n <SectionTree tree={pageDoc.sections} />\n </Shell>\n )\n\n // Holds the DataApi in state so `revalidate` can swap fresh data in AFTER\n // hydration: first render = the SSG snapshot (markup matches the server\n // byte-for-byte), then the fresh fetch reconciles in place (SWR).\n const Root: FC = () => {\n const [data, setData] = React.useState(opts.data)\n React.useEffect(() => {\n if (!opts.revalidate) return\n let live = true\n opts\n .revalidate()\n .then((fresh) => {\n if (live && fresh) setData(fresh)\n })\n .catch(() => {\n /* keep the snapshot data — a failed refresh must not blank the page */\n })\n return () => {\n live = false\n }\n // mount() runs once per page load; opts never changes afterwards.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n return (\n <DataProvider value={data}>\n <ThemeProvider settings={opts.settings} locale={opts.locale}>\n <CartProvider>{content}</CartProvider>\n </ThemeProvider>\n </DataProvider>\n )\n }\n\n const app = (\n <React.StrictMode>\n <Root />\n </React.StrictMode>\n )\n\n // Storefront (SERVE plane) is prerendered to static HTML at build time (SSG,\n // see ssg.tsx) — hydrate it so the markup is reused (no flash, SEO-ready).\n // Preview/edit planes are always client-rendered (not prerendered).\n // forceClientRender = the SSG markup is known not to match (different page /\n // no snapshot): wipe it and client-render — hydrating would mismatch (#418).\n const isStorefront = !previewMode && !editMode\n const hasSSG = rootEl.firstChild != null\n if (isStorefront && hasSSG && !opts.forceClientRender) {\n hydrateRoot(rootEl, app)\n } else {\n if (hasSSG) rootEl.replaceChildren()\n createRoot(rootEl).render(app)\n }\n}\n","/**\n * Dynamic sources — bind a section/block setting to a live metafield, resource\n * property, or metaobject field (Shopify \"Insert dynamic source\", the ⛁ icon).\n *\n * A setting value is normally a primitive. When the merchant connects a dynamic\n * source the editor stores a `{ '@source': '<path>' }` object instead, and the\n * theme resolves it at render against the CURRENT page resource:\n *\n * product.metafields.custom.subtitle → the page product's metafield\n * collection.metafields.custom.tagline → the page collection's metafield\n * shop.metafields.custom.announcement → the store's metafield (any page)\n * product.title / shop.name → a plain resource property\n * metaobject:size:medium.label → a metaobject field (type:handle.key)\n *\n * The path grammar mirrors Shopify so themes/docs are portable. Resolution is\n * synchronous against already-loaded resources — the provider is responsible\n * for loading the bound metafields (see `collectBoundIdentifiers`).\n */\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useData } from './data'\nimport type { Product, Collection } from './data'\nimport type { Shop, Metaobject } from './storefront'\n\n/** A setting bound to a dynamic source instead of a literal value. */\nexport interface BoundSource {\n '@source': string\n}\n\nexport type Bound<T> = T | BoundSource\n\nexport function isBoundSource(v: unknown): v is BoundSource {\n return (\n typeof v === 'object' &&\n v !== null &&\n typeof (v as Record<string, unknown>)['@source'] === 'string'\n )\n}\n\n/** Resources a dynamic source can read from on the current page. */\nexport interface ResourceContextValue {\n shop?: (Shop & { metafields?: Record<string, string | null> }) | null\n product?: (Product & { metafields?: Record<string, string | null> }) | null\n collection?: (Collection & { metafields?: Record<string, string | null> }) | null\n /** Synchronous metaobject lookup (type, handle) → entry, from a warmed cache. */\n metaobject?: (type: string, handle: string) => Metaobject | null\n}\n\nconst ResourceContext = createContext<ResourceContextValue>({})\n\n/**\n * Provide the current page's resources to dynamic sources. Wrap the page once\n * (the layout does this). `shop` falls back to the data source so shop-level\n * bindings work on every page without extra wiring.\n */\nexport function DynamicSourceProvider({\n value,\n children,\n}: {\n value: ResourceContextValue\n children: ReactNode\n}): JSX.Element {\n return <ResourceContext.Provider value={value}>{children}</ResourceContext.Provider>\n}\n\nexport function useResourceContext(): ResourceContextValue {\n const data = useData()\n const ctx = useContext(ResourceContext)\n // Shop is always available from the data source; an explicit provider value\n // (carrying loaded shop metafields) takes precedence.\n return { shop: data.shop, ...ctx }\n}\n\nconst METAOBJECT_RE = /^metaobject:([^:]+):([^.]+)\\.(.+)$/\n\n/** Resolve a `@source` path against a resource context. Returns null if unbound. */\nexport function resolveBoundSource(\n source: string,\n ctx: ResourceContextValue,\n): string | null {\n const mo = source.match(METAOBJECT_RE)\n if (mo) {\n const [, type, handle, field] = mo\n const obj = ctx.metaobject?.(type, handle)\n return obj?.values?.[field] ?? null\n }\n const parts = source.split('.')\n const root = parts[0]\n const resource =\n root === 'product'\n ? ctx.product\n : root === 'collection'\n ? ctx.collection\n : root === 'shop'\n ? ctx.shop\n : null\n if (!resource) return null\n if (parts[1] === 'metafields') {\n const ns = parts[2]\n const key = parts.slice(3).join('.')\n if (!ns || !key) return null\n return resource.metafields?.[`${ns}.${key}`] ?? null\n }\n // Plain resource property: product.title, shop.name, collection.title…\n const direct = (resource as unknown as Record<string, unknown>)[parts[1]]\n return direct == null ? null : String(direct)\n}\n\n/**\n * Resolve a possibly-bound setting value for the current page.\n * const heading = useBound(attributes.heading) // string | the literal | null\n * A plain value passes through unchanged; a `{ '@source' }` object resolves to\n * the live value (or null when the source has no value on this resource).\n */\nexport function useBound(value: unknown): unknown {\n const ctx = useResourceContext()\n if (!isBoundSource(value)) return value\n return resolveBoundSource(value['@source'], ctx)\n}\n\n/** Convenience: resolve to a string (empty when null/unbound-empty). */\nexport function useBoundText(value: unknown, fallback = ''): string {\n const resolved = useBound(value)\n if (resolved == null) return fallback\n return typeof resolved === 'string' ? resolved : String(resolved)\n}\n\n/**\n * Walk a content tree's section/block settings and collect every bound metafield\n * identifier, grouped by resource. The provider uses this to request exactly the\n * metafields the page binds (the live product/collection query takes identifiers).\n */\nexport function collectBoundIdentifiers(\n nodes: Array<{ settings?: Record<string, unknown>; blocks?: unknown[] }> | undefined,\n): { product: Array<{ namespace: string; key: string }>; collection: Array<{ namespace: string; key: string }>; shop: Array<{ namespace: string; key: string }> } {\n const out = {\n product: [] as Array<{ namespace: string; key: string }>,\n collection: [] as Array<{ namespace: string; key: string }>,\n shop: [] as Array<{ namespace: string; key: string }>,\n }\n const seen = new Set<string>()\n const visitSettings = (settings?: Record<string, unknown>): void => {\n if (!settings) return\n for (const v of Object.values(settings)) {\n if (!isBoundSource(v)) continue\n const parts = v['@source'].split('.')\n const root = parts[0] as 'product' | 'collection' | 'shop'\n if (parts[1] !== 'metafields') continue\n const namespace = parts[2]\n const key = parts.slice(3).join('.')\n if (!namespace || !key || !(root in out)) continue\n const dedupe = `${root}:${namespace}.${key}`\n if (seen.has(dedupe)) continue\n seen.add(dedupe)\n out[root].push({ namespace, key })\n }\n }\n // Sections + blocks may store children as an array OR an object map (the\n // editor's `{ id: node }` shape) — normalize both before iterating.\n const toNodes = (v: unknown): Array<{ settings?: Record<string, unknown>; blocks?: unknown }> => {\n if (Array.isArray(v)) return v\n if (v && typeof v === 'object') return Object.values(v as Record<string, { settings?: Record<string, unknown>; blocks?: unknown }>)\n return []\n }\n const walk = (list?: unknown): void => {\n for (const node of toNodes(list)) {\n visitSettings(node.settings)\n walk(node.blocks)\n }\n }\n walk(nodes)\n return out\n}\n","import { Children, isValidElement, type ReactNode } from 'react'\nimport type { ContentNode } from './types'\n\n/**\n * Compile a *static* JSX composition into the canonical JSON block tree.\n *\n * <Hero settings={{…}}><Button settings={{…}} /></Hero>\n * → [{ type:'hero', settings:{…}, blocks:[{ type:'button', settings:{…} }] }]\n *\n * Only nesting + literal `settings` are read — there is no place for logic, which\n * is exactly what keeps a page round-trippable by the editor. (Logic lives in\n * the block components, never in a page composition.)\n */\nexport function jsxToJSON(node: ReactNode): ContentNode[] {\n return Children.toArray(node).flatMap((el): ContentNode[] => {\n if (!isValidElement(el)) return []\n const name = (el.type as { blockName?: string })?.blockName\n if (!name) return []\n const props = el.props as { settings?: Record<string, unknown>; children?: ReactNode }\n const out: ContentNode = { type: name }\n if (props.settings) out.settings = props.settings\n const blocks = jsxToJSON(props.children)\n if (blocks.length) out.blocks = blocks\n return [out]\n })\n}\n","import type { FC, ReactNode } from 'react'\nimport type { SectionDef } from './types'\n\n/**\n * A section used inside a *page composition* takes `settings` (literal) + nested\n * children — never `attributes`. `tag(SectionDef)` returns it typed for that\n * composition use. The element is only ever walked by jsxToJSON (never rendered\n * directly), which is what keeps page files pure data.\n */\nexport type Tag = FC<{ settings?: Record<string, unknown>; children?: ReactNode }>\n\nexport function tag(def: SectionDef): Tag {\n return def.component as unknown as Tag\n}\n"],"names":["b","i","k","c","e"],"mappings":";;;;;AAOO,SAAS,cAAc,KAA6B;AACvD,MAAI,UAAgD,YAAY,IAAI;AACtE,SAAO;AACT;ACKO,SAAS,YAAY,QAAkC;AAC5D,SAAO;AACT;AAOO,SAAS,eAAe,QAAwC;AACrE,SAAO;AACT;ACnBA,MAAM,WAAW,CAAC,GAASA,OAAY,EAAE,WAAWA,GAAE,UAAU,EAAE,MAAM,CAAC,GAAGC,OAAM,MAAMD,GAAEC,EAAC,CAAC;AAE5F,SAAS,OAAO,MAAqB,MAAqC;AACxE,MAAI,QAAQ;AACZ,MAAI;AACJ,aAAWA,MAAK,MAAM;AAAE,WAAO,MAAMA,EAAC;AAAG,YAAQ,MAAM,UAAU,CAAA;AAAA,EAAG;AACpE,SAAO;AACT;AACA,SAAS,SAAS,MAAqB,MAAY,IAAoD;AACrG,QAAM,CAACA,IAAG,GAAG,IAAI,IAAI;AACrB,SAAO,KAAK;AAAA,IAAI,CAAC,GAAGC,OAClBA,OAAMD,KAAI,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,GAA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