@tanqory/theme-kit 2.0.0-alpha.17 → 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 (92) hide show
  1. package/README.md +4 -1
  2. package/dist/abi/canvas-live.d.ts +7 -2
  3. package/dist/abi/canvas-live.js +8 -3
  4. package/dist/abi/cart.d.ts +5 -4
  5. package/dist/abi/cart.js +14 -5
  6. package/dist/abi/convert.d.ts +18 -2
  7. package/dist/abi/convert.js +56 -4
  8. package/dist/abi/data-api.js +4 -0
  9. package/dist/abi/page-data.d.ts +11 -3
  10. package/dist/abi/page-data.js +71 -3
  11. package/dist/abi/wire.d.ts +8 -0
  12. package/dist/abi/wire.js +32 -2
  13. package/dist/build.d.ts +7 -2
  14. package/dist/build.js +96 -5
  15. package/dist/chunks.d.ts +23 -0
  16. package/dist/chunks.js +41 -0
  17. package/dist/client.d.ts +7 -0
  18. package/dist/client.js +16 -2
  19. package/dist/headless/hooks.js +5 -1
  20. package/dist/headless/index.d.ts +8 -1
  21. package/dist/headless/index.js +11 -1
  22. package/dist/headless/lazy-component.d.ts +72 -0
  23. package/dist/headless/lazy-component.js +225 -0
  24. package/dist/headless/lazy-section.d.ts +38 -0
  25. package/dist/headless/lazy-section.js +97 -0
  26. package/dist/headless/model.d.ts +73 -0
  27. package/dist/headless/model.js +115 -0
  28. package/dist/headless/money.d.ts +1 -9
  29. package/dist/headless/money.js +24 -22
  30. package/dist/headless/page.d.ts +2 -0
  31. package/dist/headless/primitives/storefront.js +2 -1
  32. package/dist/headless/strings.js +8 -0
  33. package/dist/headless/tanqory-money.generated.d.ts +493 -0
  34. package/dist/headless/tanqory-money.generated.js +507 -0
  35. package/dist/headless/theme.d.ts +13 -3
  36. package/dist/headless/theme.js +12 -4
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +3 -0
  39. package/dist/runtime/data/StoreProvider.js +10 -3
  40. package/dist/runtime/data/to-ui.d.ts +12 -7
  41. package/dist/runtime/data/to-ui.js +48 -16
  42. package/dist/runtime/kit/cart.d.ts +10 -3
  43. package/dist/runtime/kit/contract/content.d.ts +14 -0
  44. package/dist/runtime/kit/contract/content.js +13 -0
  45. package/dist/runtime/kit/contract/field-types.d.ts +26 -3
  46. package/dist/runtime/kit/contract/field-types.js +11 -1
  47. package/dist/runtime/kit/contract/validate.d.ts +2 -0
  48. package/dist/runtime/kit/contract/validate.js +49 -9
  49. package/dist/runtime/kit/data.d.ts +12 -0
  50. package/dist/runtime/kit/data.js +36 -22
  51. package/dist/runtime/kit/dynamic-source.d.ts +12 -0
  52. package/dist/runtime/kit/dynamic-source.js +17 -0
  53. package/dist/runtime/kit/storefront.d.ts +14 -1
  54. package/dist/runtime/kit/types.d.ts +8 -0
  55. package/dist/runtime/render/SectionRenderer.js +44 -11
  56. package/dist/runtime/render/resolved.d.ts +47 -0
  57. package/dist/runtime/render/resolved.js +80 -0
  58. package/dist/runtime/render/section-actions.d.ts +2 -1
  59. package/dist/runtime/render/section-actions.js +4 -1
  60. package/dist/runtime/render/starter.js +19 -4
  61. package/dist/runtime/seo/head.d.ts +1 -1
  62. package/dist/runtime/shell/PageShell.js +6 -1
  63. package/dist/runtime/shell/RuntimeBridge.d.ts +4 -0
  64. package/dist/runtime/shell/RuntimeBridge.js +37 -6
  65. package/dist/runtime/slots.d.ts +1 -1
  66. package/dist/sdk/font-hooks.d.ts +7 -0
  67. package/dist/sdk/font-hooks.js +21 -0
  68. package/dist/sdk/fonts.d.ts +144 -0
  69. package/dist/sdk/fonts.js +241 -0
  70. package/dist/sdk/index.d.ts +7 -1
  71. package/dist/sdk/index.js +11 -1
  72. package/dist/sdk/motion-hooks.d.ts +23 -0
  73. package/dist/sdk/motion-hooks.js +46 -0
  74. package/dist/sdk/motion.d.ts +78 -0
  75. package/dist/sdk/motion.js +292 -0
  76. package/dist/sdk/runtime-context.d.ts +32 -4
  77. package/dist/sdk/schema.d.ts +47 -4
  78. package/dist/sdk/schema.js +47 -0
  79. package/dist/sdk/store-lookup.d.ts +5 -0
  80. package/dist/sdk/store-lookup.js +19 -0
  81. package/dist/sdk/store.d.ts +15 -0
  82. package/dist/sdk/sx.d.ts +5 -0
  83. package/dist/sdk/sx.js +7 -2
  84. package/dist/sdk/theme.d.ts +21 -0
  85. package/dist/sdk/theme.js +17 -0
  86. package/dist/sdk/types.d.ts +36 -4
  87. package/dist/server.d.ts +5 -4
  88. package/dist/server.js +76 -20
  89. package/dist/vite-chunks.d.ts +10 -0
  90. package/dist/vite-chunks.js +44 -0
  91. package/docs/headless-api.md +33 -3
  92. package/package.json +10 -18
@@ -146,11 +146,12 @@ export declare function toSocial(links: S.Shop['socialLinks']): Pick<UI.Shop, 's
146
146
  export declare function toProductMedia(list: R.Product['media'] | null | undefined): {
147
147
  media?: UI.ProductMediaItem[];
148
148
  };
149
- /** The platform's same-origin model route (storefront-edge `/_tq/model/`), which serves a store's own `.glb` uploads. */
149
+ /** The platform's same-origin model route (storefront-edge `/_tq/model/`), which serves a store's own `.glb` / `.usdz` uploads. */
150
150
  export declare const MODEL_ROUTE = "/_tq/model/";
151
151
  /**
152
- * A store-media `.glb` URL → its same-origin model route (`/_tq/model/stores/<store>/<path>.glb`): the media host sends
153
- * no CORS headers, and the page CSP lets a viewer read only its own origin. Anything else ⇒ null (not shown).
152
+ * A store-media `.glb` / `.usdz` URL → its same-origin model route (`/_tq/model/stores/<store>/<path>`): the media host
153
+ * sends no CORS headers, and the page CSP lets a viewer read only its own origin. An already same-origin route path is
154
+ * kept (the read model may hand one over). Anything else ⇒ null (not shown).
154
155
  */
155
156
  export declare function modelSrc(url: string | null | undefined): string | null;
156
157
  /** A merchant-published postal address → display lines: street (address1, address2), "city province zip", country. */
@@ -211,7 +212,10 @@ export declare function toPolicy(p: S.ShopPolicy | null | undefined): UI.Policy
211
212
  /** Every published policy by handle, for StoreContext.policies. */
212
213
  export declare function toPolicies(shop: S.Shop | null | undefined): Record<string, UI.Policy>;
213
214
  type RuntimeLocation = NonNullable<Awaited<ReturnType<NonNullable<R.DataApi['locations']>>>>[number];
214
- /** Store locations. The platform returns a postal address only — no hours, email, image or coordinates. */
215
+ /**
216
+ * Store locations: the postal address, phone, and (rev 2.73) the pickup / storefront marks and the weekly opening hours.
217
+ * No email, image or coordinates.
218
+ */
215
219
  export declare function toLocations(list: readonly RuntimeLocation[] | null | undefined): UI.StoreLocation[];
216
220
  /**
217
221
  * Search → SearchResults. `total` is the backend's count across every type.
@@ -267,9 +271,10 @@ export interface BreadcrumbInput {
267
271
  export declare function toBreadcrumbs(input: BreadcrumbInput): UI.BreadcrumbItem[];
268
272
  /**
269
273
  * Whether the cookie banner shows to a shopper who has not decided yet (Settings › Customer privacy,
270
- * contract rev 2): the platform's legal floor first (EEA, UK, unknown location — or a platform that
271
- * does not say), then the merchant's switch — everywhere with "Use automated settings", else only in
272
- * the regions the merchant chose. No merchant config (older data) = shown, as before.
274
+ * contract rev 2): the platform's `regionRequiresBanner` first (EEA, UK, unknown location, and the
275
+ * merchant's own regions — or a platform that does not say), then the merchant's switch: with "Use
276
+ * automated settings" the legal floor alone (board 35 #42: it showed to every visitor everywhere), else
277
+ * also the regions the merchant chose. No merchant config (older data) = shown, as before.
273
278
  */
274
279
  export declare function consentBannerShows(readout: {
275
280
  regionRequiresBanner?: boolean;
@@ -469,9 +469,11 @@ export function toProductMedia(list) {
469
469
  const src = modelSrc((m.sources ?? []).find((s) => s && s.mimeType === 'model/gltf-binary')?.url);
470
470
  if (!src)
471
471
  continue;
472
+ // iOS Quick Look: the merchant's own USDZ when there is one (else the viewer makes one from the GLB on the device)
473
+ const iosSrc = modelSrc((m.sources ?? []).find((s) => s && s.mimeType === 'model/vnd.usdz+zip')?.url);
472
474
  const poster = toImage(m.previewImage ?? null);
473
475
  const alt = str(m.alt ?? undefined);
474
- out.push({ type: 'model', src, ...(poster ? { poster } : {}), ...(alt ? { alt } : {}) });
476
+ out.push({ type: 'model', src, ...(iosSrc ? { iosSrc } : {}), ...(poster ? { poster } : {}), ...(alt ? { alt } : {}) });
475
477
  continue;
476
478
  }
477
479
  if (m.type !== 'video')
@@ -485,16 +487,28 @@ export function toProductMedia(list) {
485
487
  }
486
488
  return out.some((m) => m.type !== 'image') ? { media: out } : {};
487
489
  }
488
- /** The platform's same-origin model route (storefront-edge `/_tq/model/`), which serves a store's own `.glb` uploads. */
490
+ /** The platform's same-origin model route (storefront-edge `/_tq/model/`), which serves a store's own `.glb` / `.usdz` uploads. */
489
491
  export const MODEL_ROUTE = '/_tq/model/';
490
- const MODEL_URL = /^https:\/\/(cdn\.tanqory\.com|pub-[0-9a-f]{32}\.r2\.dev)\/(stores\/[0-9a-z-]+\/[A-Za-z0-9._~\/-]+\.glb)$/;
491
492
  /**
492
- * A store-media `.glb` URL → its same-origin model route (`/_tq/model/stores/<store>/<path>.glb`): the media host sends
493
- * no CORS headers, and the page CSP lets a viewer read only its own origin. Anything else ⇒ null (not shown).
493
+ * The store-media hosts of the new system's buckets (storefront-edge core/media-hosts.ts): Prod `cdn.mytanqory.com`,
494
+ * Dev `cdn.tanqory.dev` / `cdn.mytanqory.dev`, and a bucket's `pub-<hex>.r2.dev` URL. The old system's `cdn.tanqory.com`
495
+ * serves nothing (404 on every path, 2026-11-19), so it is not one: with it as the only host, every model was dropped.
496
+ */
497
+ const MODEL_URL = /^https:\/\/(cdn\.mytanqory\.com|cdn\.tanqory\.dev|cdn\.mytanqory\.dev|pub-[0-9a-f]{32}\.r2\.dev)\/(stores\/[0-9A-Fa-f-]+\/[A-Za-z0-9._~\/-]+\.(?:glb|usdz))$/;
498
+ /**
499
+ * A store-media `.glb` / `.usdz` URL → its same-origin model route (`/_tq/model/stores/<store>/<path>`): the media host
500
+ * sends no CORS headers, and the page CSP lets a viewer read only its own origin. An already same-origin route path is
501
+ * kept (the read model may hand one over). Anything else ⇒ null (not shown).
494
502
  */
495
503
  export function modelSrc(url) {
496
- const m = typeof url === 'string' ? MODEL_URL.exec(url) : null;
497
- return m && !m[2].includes('..') ? `${MODEL_ROUTE}${m[2]}` : null;
504
+ if (typeof url !== 'string')
505
+ return null;
506
+ if (url.startsWith(MODEL_ROUTE)) {
507
+ const rest = url.slice(MODEL_ROUTE.length);
508
+ return /^stores\/[0-9A-Fa-f-]+\/[A-Za-z0-9._~\/-]+\.(?:glb|usdz)$/.test(rest) && !rest.split('/').some((s) => s === '.' || s === '..') ? url : null;
509
+ }
510
+ const m = MODEL_URL.exec(url);
511
+ return m && !m[2].split('/').some((s) => s === '.' || s === '..') ? `${MODEL_ROUTE}${m[2]}` : null;
498
512
  }
499
513
  /** A merchant-published postal address → display lines: street (address1, address2), "city province zip", country. */
500
514
  export function addressLines(a) {
@@ -521,9 +535,16 @@ export function toShop(shop, settings = {}) {
521
535
  const paymentMethods = toPaymentMethods(shop?.paymentSettings);
522
536
  const freeShipping = toMoney(shop?.freeShippingThreshold ?? null);
523
537
  const address = addressLines(shop?.address);
538
+ const slogan = str(shop?.brand?.slogan ?? undefined);
539
+ const shortDescription = str(shop?.brand?.shortDescription ?? undefined);
540
+ const cover = shop?.brand?.coverImage;
541
+ const coverImage = cover?.url ? toImage({ url: cover.url, altText: cover.altText ?? null, width: cover.width, height: cover.height }) : null;
524
542
  return {
525
543
  name,
526
544
  logo,
545
+ ...(slogan ? { slogan } : {}),
546
+ ...(shortDescription ? { shortDescription } : {}),
547
+ ...(coverImage ? { coverImage } : {}),
527
548
  ...(email ? { email } : {}),
528
549
  ...(phone ? { phone } : {}),
529
550
  ...(shop?.taxesIncluded === true ? { taxesIncluded: true } : {}),
@@ -661,7 +682,7 @@ export function toCartLine(line) {
661
682
  return {
662
683
  id: line?.id ?? '',
663
684
  quantity,
664
- product: { title: line?.title ?? '', handle, url: handle ? productUrl(handle) : '' },
685
+ product: { title: line?.title ?? '', handle, url: handle ? productUrl(handle) : '', ...(line?.productId ? { id: line.productId } : {}) },
665
686
  variant: {
666
687
  id: line?.variantId ?? '',
667
688
  title: line?.variantTitle ?? '',
@@ -813,14 +834,26 @@ export function toPolicies(shop) {
813
834
  }
814
835
  return out;
815
836
  }
816
- /** Store locations. The platform returns a postal address only — no hours, email, image or coordinates. */
837
+ /**
838
+ * Store locations: the postal address, phone, and (rev 2.73) the pickup / storefront marks and the weekly opening hours.
839
+ * No email, image or coordinates.
840
+ */
817
841
  export function toLocations(list) {
818
842
  return (list ?? []).filter(Boolean).map((l) => {
819
843
  const a = l.address;
820
844
  const cityLine = [a?.city, a?.province, a?.postalCode].filter((s) => Boolean(s && s.trim())).join(' ');
821
845
  const address = [a?.address, cityLine, a?.country].filter((s) => Boolean(s && s.trim()));
822
846
  const phone = str(a?.phone ?? undefined);
823
- return { id: l.id ?? '', name: l.name ?? '', address, ...(phone ? { phone } : {}), ...(l.pickupReadyIn ? { pickupReadyIn: l.pickupReadyIn } : {}) };
847
+ return {
848
+ id: l.id ?? '',
849
+ name: l.name ?? '',
850
+ address,
851
+ ...(phone ? { phone } : {}),
852
+ ...(l.pickupReadyIn ? { pickupReadyIn: l.pickupReadyIn } : {}),
853
+ ...(typeof l.pickup === 'boolean' ? { pickup: l.pickup } : {}),
854
+ ...(typeof l.storefront === 'boolean' ? { storefront: l.storefront } : {}),
855
+ ...(l.openingHours ? { openingHours: l.openingHours.map((p) => ({ ...p })) } : {}),
856
+ };
824
857
  });
825
858
  }
826
859
  // ── Search + listing ────────────────────────────────────────────────────────
@@ -958,19 +991,18 @@ export function toBreadcrumbs(input) {
958
991
  }
959
992
  /**
960
993
  * Whether the cookie banner shows to a shopper who has not decided yet (Settings › Customer privacy,
961
- * contract rev 2): the platform's legal floor first (EEA, UK, unknown location — or a platform that
962
- * does not say), then the merchant's switch — everywhere with "Use automated settings", else only in
963
- * the regions the merchant chose. No merchant config (older data) = shown, as before.
994
+ * contract rev 2): the platform's `regionRequiresBanner` first (EEA, UK, unknown location, and the
995
+ * merchant's own regions — or a platform that does not say), then the merchant's switch: with "Use
996
+ * automated settings" the legal floor alone (board 35 #42: it showed to every visitor everywhere), else
997
+ * also the regions the merchant chose. No merchant config (older data) = shown, as before.
964
998
  */
965
999
  export function consentBannerShows(readout, banner) {
966
1000
  if (readout.regionRequiresBanner !== false)
967
1001
  return true;
968
1002
  if (!banner)
969
1003
  return true;
970
- if (!banner.enabled)
1004
+ if (!banner.enabled || banner.automated)
971
1005
  return false;
972
- if (banner.automated)
973
- return true;
974
1006
  const country = readout.geo?.country?.toUpperCase();
975
1007
  const region = readout.geo?.region?.toUpperCase();
976
1008
  return Boolean((country && banner.regions.includes(country)) || (region && banner.regions.includes(region)));
@@ -22,6 +22,8 @@ export interface CartLine {
22
22
  lineTotal?: Money;
23
23
  /** Product handle for linking back to the PDP. */
24
24
  productHandle?: string;
25
+ /** The line's product id (theme-abi Cart-4 `merchandise.product.id`), when the cart source sends it. */
26
+ productId?: string;
25
27
  /** The variant's options (`Size: Queen`, `Colour: Oat`), when the cart source carries them. */
26
28
  selectedOptions?: Array<{
27
29
  name: string;
@@ -135,14 +137,19 @@ export interface AddToCartInput {
135
137
  };
136
138
  }
137
139
  /**
138
- * Why the platform refused a cart write, when it said (theme-abi 2.0.0-alpha.13 `CartRefusal`, Cart-1).
140
+ * Why the platform refused a cart write, when it said (theme-abi 2.0.0-alpha.13 `CartRefusal`, Cart-1 / Cart-3).
139
141
  * `cart_limit_exceeded`: more of one product than the merchant's "Maximum quantity per product" allows;
140
142
  * `maxQuantity` is that limit when the platform knows it.
143
+ * `quantity_rule`: the cart is bought for a company location and the quantity is outside its rule for the variant —
144
+ * below the `minimum`, above the `maximum`, or not a multiple of the `increment` (the rule's numbers are not sent).
141
145
  */
142
- export interface CartRefusal {
146
+ export type CartRefusal = {
143
147
  code: 'cart_limit_exceeded';
144
148
  maxQuantity?: number;
145
- }
149
+ } | {
150
+ code: 'quantity_rule';
151
+ rule: 'minimum' | 'maximum' | 'increment';
152
+ };
146
153
  export interface CartApi extends CartState {
147
154
  /** Re-read the cart after something outside this provider changed it. Never rejects. */
148
155
  reload?: (id?: string) => Promise<void>;
@@ -88,7 +88,16 @@ export interface AppBlockContract {
88
88
  /** The name the editor shows. */
89
89
  name?: string;
90
90
  settings: Record<string, AttrContract>;
91
+ /** Where the app lets it go: `section` (directly in a section), `block` (inside a block). Empty or absent: both. */
92
+ targets?: readonly string[];
93
+ /** The page kinds it is for (`product`, `home`, ...: the storefront's route kinds). Empty or absent: any page. */
94
+ requires?: readonly string[];
91
95
  }
96
+ /**
97
+ * The storefront route kind a page template is for, by its base name (`product.bundle` → `product`), as an app block's
98
+ * `requires` names it; null for a template that is not one route kind (`gift-card`).
99
+ */
100
+ export declare function routeKindOfTemplate(template: string | undefined): string | null;
92
101
  /**
93
102
  * Node ids must be URL-safe, stable across saves, and unique within their
94
103
  * parent. Readable prefixes are deliberate: `faq-item_a1b2c3d4` is greppable in
@@ -196,4 +205,9 @@ export interface AttrContract {
196
205
  value: string;
197
206
  label: string;
198
207
  }>;
208
+ /** `list` only: the element (`{ type: 'product', resolve: true }`). */
209
+ items?: {
210
+ type: string;
211
+ resolve?: boolean;
212
+ };
199
213
  }
@@ -37,6 +37,19 @@ export function isAppBlockType(type) {
37
37
  export function acceptsAppBlocks(allowed) {
38
38
  return Array.isArray(allowed) && allowed.includes(APP_BLOCKS);
39
39
  }
40
+ /**
41
+ * The storefront route kind a page template is for, by its base name (`product.bundle` → `product`), as an app block's
42
+ * `requires` names it; null for a template that is not one route kind (`gift-card`).
43
+ */
44
+ export function routeKindOfTemplate(template) {
45
+ const base = String(template ?? '').split('.')[0];
46
+ const kinds = {
47
+ index: 'home', product: 'product', collection: 'collection', 'list-collections': 'collections', page: 'page',
48
+ contact: 'page', blog: 'blog', article: 'article', search: 'search', cart: 'cart', account: 'customer',
49
+ customers: 'customer', policy: 'policy', metaobject: 'metaobject', '404': 'not_found',
50
+ };
51
+ return Object.prototype.hasOwnProperty.call(kinds, base) ? kinds[base] : null;
52
+ }
40
53
  /**
41
54
  * Node ids must be URL-safe, stable across saves, and unique within their
42
55
  * parent. Readable prefixes are deliberate: `faq-item_a1b2c3d4` is greppable in
@@ -17,7 +17,7 @@
17
17
  * disagreement is inexpressible.
18
18
  */
19
19
  /** How the editor renders a control. Consumers assert against this, not the id. */
20
- export type ControlKind = 'text-input' | 'textarea' | 'rich-text' | 'number-input' | 'slider' | 'color' | 'switch' | 'segmented' | 'select' | 'media-picker' | 'resource-picker' | 'link-picker' | 'color-palette';
20
+ export type ControlKind = 'text-input' | 'textarea' | 'rich-text' | 'number-input' | 'slider' | 'color' | 'switch' | 'segmented' | 'select' | 'media-picker' | 'resource-picker' | 'link-picker' | 'color-palette' | 'list';
21
21
  /**
22
22
  * The runtime shape a section component receives for this attribute. `palette` = `{ name, color }[]` (the theme's
23
23
  * named colours, theme-abi registry 3 B.3).
@@ -35,7 +35,7 @@ export interface FieldTypeDef {
35
35
  readonly control: ControlKind;
36
36
  readonly value: ValueKind;
37
37
  /** Media kind, for `media-picker` controls. */
38
- readonly media?: 'image' | 'video';
38
+ readonly media?: 'image' | 'video' | 'model';
39
39
  /** Resource kind, for `resource-picker` controls — what the picker lists. */
40
40
  readonly resource?: 'product' | 'collection' | 'page' | 'blog' | 'article' | 'menu';
41
41
  /** Constraint keys that are meaningful for THIS type (beyond the universal ones). */
@@ -49,7 +49,7 @@ export interface FieldTypeDef {
49
49
  readonly doc: string;
50
50
  }
51
51
  /**
52
- * The 21 core types (the 20 above, plus `color_palette`). Set-identical to studio-api's `ATTR_TYPES`, which is the
52
+ * The 22 core types (the 20 above, plus `color_palette` and `list`). Set-identical to studio-api's `ATTR_TYPES`, which is the
53
53
  * gate that actually decides what reaches the settings panel — anything outside
54
54
  * it is silently rewritten to `'text'`.
55
55
  */
@@ -195,6 +195,17 @@ export declare const FIELD_TYPES: readonly [{
195
195
  readonly dynamicSourceTypes: readonly ["file_reference"];
196
196
  readonly aiGenerate: true;
197
197
  readonly doc: "Media-library picker for a hosted video. For an EXTERNAL video URL use `url` — the editor renders this as a library browser, not a URL input.";
198
+ }, {
199
+ readonly id: "model";
200
+ readonly tier: "core";
201
+ readonly control: "media-picker";
202
+ readonly value: "string";
203
+ readonly media: "model";
204
+ readonly constraints: readonly [];
205
+ readonly dynamicBindable: true;
206
+ readonly dynamicSourceTypes: readonly ["file_reference"];
207
+ readonly aiGenerate: false;
208
+ readonly doc: "A 3D model of the store's files (.glb). The editor lists the store's MODEL_3D files; the value is the file's https URL. Show it with <ModelViewer media={{ src: value }} />; the platform viewer does the rest (theme-abi §2.6). Needs field-type registry 4.";
198
209
  }, {
199
210
  readonly id: "collection";
200
211
  readonly tier: "core";
@@ -271,7 +282,19 @@ export declare const FIELD_TYPES: readonly [{
271
282
  readonly dynamicSourceTypes: readonly [];
272
283
  readonly aiGenerate: true;
273
284
  readonly doc: "The theme's named colours: a list of { name, color } (color #rrggbb), at most 20, each name 1 to 30 characters and unique. The editor offers them in every colour picker. Needs field-type registry 3.";
285
+ }, {
286
+ readonly id: "list";
287
+ readonly tier: "core";
288
+ readonly control: "list";
289
+ readonly value: "string[]";
290
+ readonly constraints: readonly ["items", "min", "max"];
291
+ readonly dynamicBindable: false;
292
+ readonly dynamicSourceTypes: readonly [];
293
+ readonly aiGenerate: false;
294
+ readonly doc: "An ordered list of one element type, `items: { type }` (theme-abi registry `list`). A list of products, collections, pages, blogs or articles is a hand-picked list: the editor offers the multi picker, the value is the handles in the merchant's order, at most 50 (a lower `max` lowers it), and `items.resolve: true` has the platform resolve every entry. A list of colours (`items: { type: \"color\" }`) is a palette without names.";
274
295
  }];
296
+ /** Element types of a `list` whose entries are resource handles (the multi picker). */
297
+ export declare const LIST_RESOURCE_ITEMS: readonly string[];
275
298
  /** `color_palette`: the most colours, and the longest name (theme-abi B.3). */
276
299
  export declare const PALETTE_MAX_COLOURS = 20;
277
300
  export declare const PALETTE_NAME_MAX = 30;
@@ -17,7 +17,7 @@
17
17
  * disagreement is inexpressible.
18
18
  */
19
19
  /**
20
- * The 21 core types (the 20 above, plus `color_palette`). Set-identical to studio-api's `ATTR_TYPES`, which is the
20
+ * The 22 core types (the 20 above, plus `color_palette` and `list`). Set-identical to studio-api's `ATTR_TYPES`, which is the
21
21
  * gate that actually decides what reaches the settings panel — anything outside
22
22
  * it is silently rewritten to `'text'`.
23
23
  */
@@ -66,6 +66,10 @@ export const FIELD_TYPES = [
66
66
  constraints: [], dynamicBindable: true, dynamicSourceTypes: ['file_reference'],
67
67
  aiGenerate: true,
68
68
  doc: 'Media-library picker for a hosted video. For an EXTERNAL video URL use `url` — the editor renders this as a library browser, not a URL input.' },
69
+ { id: 'model', tier: 'core', control: 'media-picker', value: 'string', media: 'model',
70
+ constraints: [], dynamicBindable: true, dynamicSourceTypes: ['file_reference'],
71
+ aiGenerate: false,
72
+ doc: 'A 3D model of the store\'s files (.glb). The editor lists the store\'s MODEL_3D files; the value is the file\'s https URL. Show it with <ModelViewer media={{ src: value }} />; the platform viewer does the rest (theme-abi §2.6). Needs field-type registry 4.' },
69
73
  { id: 'collection', tier: 'core', control: 'resource-picker', value: 'string', resource: 'collection',
70
74
  constraints: [], dynamicBindable: true, dynamicSourceTypes: ['collection_reference'],
71
75
  aiGenerate: true, doc: 'Collection picker. Value is the collection HANDLE.' },
@@ -89,7 +93,13 @@ export const FIELD_TYPES = [
89
93
  constraints: ['max'], dynamicBindable: false, dynamicSourceTypes: [],
90
94
  aiGenerate: true,
91
95
  doc: 'The theme\'s named colours: a list of { name, color } (color #rrggbb), at most 20, each name 1 to 30 characters and unique. The editor offers them in every colour picker. Needs field-type registry 3.' },
96
+ { id: 'list', tier: 'core', control: 'list', value: 'string[]',
97
+ constraints: ['items', 'min', 'max'], dynamicBindable: false, dynamicSourceTypes: [],
98
+ aiGenerate: false,
99
+ doc: 'An ordered list of one element type, `items: { type }` (theme-abi registry `list`). A list of products, collections, pages, blogs or articles is a hand-picked list: the editor offers the multi picker, the value is the handles in the merchant\'s order, at most 50 (a lower `max` lowers it), and `items.resolve: true` has the platform resolve every entry. A list of colours (`items: { type: "color" }`) is a palette without names.' },
92
100
  ];
101
+ /** Element types of a `list` whose entries are resource handles (the multi picker). */
102
+ export const LIST_RESOURCE_ITEMS = ['product', 'collection', 'page', 'blog', 'article'];
93
103
  /** `color_palette`: the most colours, and the longest name (theme-abi B.3). */
94
104
  export const PALETTE_MAX_COLOURS = 20;
95
105
  export const PALETTE_NAME_MAX = 30;
@@ -50,6 +50,8 @@ export interface ValidateOptions {
50
50
  * writes in `defineSection({...})`.
51
51
  */
52
52
  export declare function validateSectionContract(def: SectionContract): ValidationResult;
53
+ /** What to write instead of an editor-only type that has a declarable form, or undefined (MCP limits item 7). */
54
+ export declare function editorOnlyReplacement(type: unknown): string | undefined;
53
55
  /**
54
56
  * Validate a template document against a section catalogue.
55
57
  *
@@ -13,8 +13,8 @@
13
13
  * repair loop, which is why they name the correct value rather than only
14
14
  * rejecting the wrong one.
15
15
  */
16
- import { canonicalFieldType, paletteValueProblems, fieldType, FIELD_TYPE_ALIASES, EDITOR_ONLY_TYPES, UNIVERSAL_CONSTRAINTS, isBoundSourceValue, isBoundTemplateValue, TEMPLATE_BINDABLE_TYPES, BOUND_TEMPLATE_MAX_TOKENS, } from './field-types.js';
17
- import { APP_BLOCKS, NODE_ID_PATTERN, NODE_NAME_MAX_LENGTH, TEMPLATE_AREAS, acceptsAppBlocks, isAppBlockType, isValidNodeName, roleOf, } from './content.js';
16
+ import { canonicalFieldType, paletteValueProblems, fieldType, FIELD_TYPE_ALIASES, EDITOR_ONLY_TYPES, UNIVERSAL_CONSTRAINTS, isBoundSourceValue, isBoundTemplateValue, TEMPLATE_BINDABLE_TYPES, BOUND_TEMPLATE_MAX_TOKENS, LIST_RESOURCE_ITEMS, } from './field-types.js';
17
+ import { NODE_ID_PATTERN, NODE_NAME_MAX_LENGTH, TEMPLATE_AREAS, acceptsAppBlocks, isAppBlockType, isValidNodeName, roleOf, routeKindOfTemplate, } from './content.js';
18
18
  import { GROUP_SLOTS, GROUP_NAME_PATTERN, isSectionGroupDoc, resolvePage, } from './groups.js';
19
19
  const err = (code, path, message, nodeId, suggestion) => ({
20
20
  severity: 'error', code, path, message,
@@ -37,9 +37,7 @@ export function validateSectionContract(def) {
37
37
  for (const [key, spec] of Object.entries(def.attributes ?? {})) {
38
38
  issues.push(...validateAttr(spec, `${base}.attributes.${key}`, def.name));
39
39
  }
40
- if (acceptsAppBlocks(def.allowedBlocks) && roleOf(def) === 'layout') {
41
- issues.push(err('invalid_placement', `${base}.allowedBlocks`, `"${def.name}" is a layout section and cannot accept app blocks ("${APP_BLOCKS}").`, def.name));
42
- }
40
+ // A section of any role may accept app blocks, a header or footer included (theme-abi §7.2 AppBlocks-1).
43
41
  for (const [i, preset] of (def.presets ?? []).entries()) {
44
42
  for (const [j, block] of (preset.blocks ?? []).entries()) {
45
43
  const p = `${base}.presets[${i}].blocks[${j}]`;
@@ -54,6 +52,17 @@ export function validateSectionContract(def) {
54
52
  }
55
53
  return { ok: !issues.some((i) => i.severity === 'error'), issues };
56
54
  }
55
+ /**
56
+ * Editor-only types that already have a declarable form, and what to write instead (MCP limits item 7): the message
57
+ * names the replacement rather than only refusing the type.
58
+ */
59
+ const EDITOR_ONLY_REPLACEMENTS = {
60
+ font_picker: "A font setting is a select the editor draws as its font picker: field.font('Prompt', { label }) in a section, or fontSetting({ label }) in src/settings.ts (@tanqory/theme-kit), offering the platform catalogue first, then the theme's own fonts; render it with useFont().",
61
+ };
62
+ /** What to write instead of an editor-only type that has a declarable form, or undefined (MCP limits item 7). */
63
+ export function editorOnlyReplacement(type) {
64
+ return typeof type === 'string' && own(EDITOR_ONLY_REPLACEMENTS, type) ? EDITOR_ONLY_REPLACEMENTS[type] : undefined;
65
+ }
57
66
  /** Validate one attribute declaration. */
58
67
  function validateAttr(spec, path, nodeId) {
59
68
  const issues = [];
@@ -61,7 +70,10 @@ function validateAttr(spec, path, nodeId) {
61
70
  const canonical = canonicalFieldType(declared);
62
71
  if (!canonical) {
63
72
  if (typeof declared === 'string' && EDITOR_ONLY_TYPES.includes(declared)) {
64
- issues.push(err('editor_only_field_type', `${path}.type`, `"${declared}" is rendered by the editor but cannot be declared by a theme. Use a core type; promoting it requires a contract change.`, nodeId));
73
+ const instead = editorOnlyReplacement(declared);
74
+ issues.push(err('editor_only_field_type', `${path}.type`, instead
75
+ ? `"${declared}" is rendered by the editor but cannot be declared by a theme. ${instead}`
76
+ : `"${declared}" is rendered by the editor but cannot be declared by a theme. Use a core type; promoting it requires a contract change.`, nodeId));
65
77
  }
66
78
  else {
67
79
  issues.push(err('unknown_field_type', `${path}.type`, `Unknown field type "${String(declared)}". It will be silently downgraded to a plain text box.`, nodeId));
@@ -77,6 +89,10 @@ function validateAttr(spec, path, nodeId) {
77
89
  if (def.constraints.includes('options') && !Array.isArray(spec.options)) {
78
90
  issues.push(err('missing_required_constraint', `${path}.options`, `Field type "${canonical}" requires \`options: [{ value, label }]\`.`, nodeId));
79
91
  }
92
+ // A list says what its entries are (theme-abi registry `list` requires `items`).
93
+ if (canonical === 'list' && !(spec.items && typeof spec.items === 'object' && typeof spec.items.type === 'string' && spec.items.type)) {
94
+ issues.push(err('missing_required_constraint', `${path}.items`, 'Field type "list" requires `items: { type }`, e.g. `{ type: "product", resolve: true }` for a hand-picked list of products.', nodeId));
95
+ }
80
96
  // Constraints that do nothing on this type are a sign the author expected
81
97
  // different behaviour — the `columns`-on-a-section class of mistake.
82
98
  for (const key of Object.keys(spec ?? {})) {
@@ -257,9 +273,6 @@ function walkAppBlock(node, path, parent, issues, opts) {
257
273
  else if (!acceptsAppBlocks(parent.allowedBlocks)) {
258
274
  issues.push(err('disallowed_nesting', path, `"${parent.name}" does not accept app blocks, so it cannot contain "${node.type}".`, id));
259
275
  }
260
- else if (roleOf(parent) === 'layout') {
261
- issues.push(err('invalid_placement', path, `"${parent.name}" is a layout section and cannot contain the app block "${node.type}".`, id));
262
- }
263
276
  if (Array.isArray(node.blocks) && node.blocks.length) {
264
277
  issues.push(err('leaf_cannot_nest', `${path}.blocks`, `The app block "${node.type}" cannot contain blocks.`, id));
265
278
  }
@@ -270,6 +283,23 @@ function walkAppBlock(node, path, parent, issues, opts) {
270
283
  issues.push(warn('app_block_unavailable', `${path}.type`, `The app block "${node.type}" is not available: its app is not installed, or its newest version no longer has this block. It is kept in the page and left out of the storefront until the app is installed again.`, id));
271
284
  return;
272
285
  }
286
+ // The app's own placement rules (its version's `targets` and `requires`): the editor's picker offers the block only
287
+ // where they allow, and a save from any other writer (the AI tools, the API) is held to the same rules here.
288
+ const name = def.name ?? node.type;
289
+ if (parent && def.targets?.length) {
290
+ const where = roleOf(parent) === 'block' ? 'block' : 'section';
291
+ if (!def.targets.includes(where)) {
292
+ issues.push(err('invalid_placement', path, where === 'block'
293
+ ? `The app block "${name}" can only be placed directly in a section, not inside the block "${parent.name}".`
294
+ : `The app block "${name}" can only be placed inside a block, not directly in the section "${parent.name}".`, id));
295
+ }
296
+ }
297
+ if (def.requires?.length && opts.template) {
298
+ const kind = routeKindOfTemplate(opts.template);
299
+ if (!kind || !def.requires.includes(kind)) {
300
+ issues.push(err('invalid_placement', path, `The app block "${name}" is for ${def.requires.join(', ')} pages, so it cannot be placed on the template "${opts.template}".`, id));
301
+ }
302
+ }
273
303
  for (const [key, value] of Object.entries(node.settings ?? {})) {
274
304
  const spec = own(def.settings ?? {}, key) ? def.settings[key] : undefined;
275
305
  const sPath = `${path}.settings.${key}`;
@@ -326,6 +356,16 @@ function validateSettingValue(spec, value, path, nodeId) {
326
356
  issues.push(err('invalid_value', path, `Expected ${def.value} for field type "${canonical}", got ${Array.isArray(value) ? 'array' : t}.`, nodeId));
327
357
  return issues;
328
358
  }
359
+ // A hand-picked list holds handles: each entry a non-empty handle (the count is studio-api's page check, too_many_items).
360
+ if (canonical === 'list' && typeof spec.items?.type === 'string' && LIST_RESOURCE_ITEMS.includes(spec.items.type)) {
361
+ ;
362
+ value.forEach((entry, i) => {
363
+ if (typeof entry !== 'string' || !/^\S+$/.test(entry)) {
364
+ issues.push(err('invalid_value', `${path}[${i}]`, `Entry ${i + 1} must be a ${spec.items.type} handle.`, nodeId));
365
+ }
366
+ });
367
+ return issues;
368
+ }
329
369
  // A palette's colours: named, unique, #rrggbb, at most 20 (theme-abi B.3).
330
370
  if (def.value === 'palette') {
331
371
  for (const message of paletteValueProblems(value, typeof spec.max === 'number' ? spec.max : undefined)) {
@@ -417,6 +417,15 @@ export interface DataApi extends StorefrontExtensions {
417
417
  } | null;
418
418
  /** rev 2.52 (O3): the expected pickup time; absent when the platform did not say. */
419
419
  pickupReadyIn?: '4h' | '24h' | '1-2d' | '2-4d' | '5d+';
420
+ /** rev 2.73 (board 35 #117): offers local pickup / Physical storefront on; absent ⇒ yes (the rev 2.34 reading). */
421
+ pickup?: boolean;
422
+ storefront?: boolean;
423
+ /** rev 2.73: weekly opening hours, Monday first, 24-hour `HH:MM`; a day not listed is closed; absent ⇒ not set. */
424
+ openingHours?: Array<{
425
+ day: 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
426
+ opens: string;
427
+ closes: string;
428
+ }>;
420
429
  }>>;
421
430
  /**
422
431
  * Look up a single product by its handle. Returns null when the handle
@@ -505,6 +514,9 @@ export interface DataApi extends StorefrontExtensions {
505
514
  region?: string;
506
515
  };
507
516
  regionRequiresBanner?: boolean;
517
+ regionRequiresOptOut?: boolean;
518
+ saleOfDataAllowed?: boolean;
519
+ gpc?: boolean;
508
520
  }>;
509
521
  set: (input: {
510
522
  analytics: boolean;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useContext } from 'react';
3
3
  import { createStorefrontMethods, BOOTSTRAP_SHOP_MENU, BOOTSTRAP_SHOP_MENU_FRAGMENTS, readBootstrapShopMenu, } from './storefront.js';
4
+ import { displayAmount } from '../../headless/tanqory-money.generated.js';
4
5
  /** Build a `recommendations` object from a product list (parity with the commerce standard
5
6
  * `recommendations` legacy templating object, whose `.products` our API returns directly). */
6
7
  export function toRecommendations(products, intent = 'related') {
@@ -1002,25 +1003,27 @@ function buildLiveData(boot, graphqlRequest, opts) {
1002
1003
  // differently, e.g. "THB 120.00" vs "฿120.00") — which breaks SSR hydration
1003
1004
  // (React #425 text mismatch). Format manually instead: identical output
1004
1005
  // everywhere, by construction.
1006
+ // The decimals come from the platform's one currency table (@tanqory/money, generated copy in
1007
+ // headless/tanqory-money.generated.ts; docs/STANDARDS.md API-6): ISO 4217's, HUF, IDR and TWD in whole units.
1005
1008
  const CURRENCY_FORMAT = {
1006
- THB: { symbol: '฿', decimals: 2 },
1007
- USD: { symbol: '$', decimals: 2 },
1008
- EUR: { symbol: '€', decimals: 2 },
1009
- GBP: { symbol: '£', decimals: 2 },
1010
- JPY: { symbol: '¥', decimals: 0 },
1011
- KRW: { symbol: '₩', decimals: 0 },
1012
- VND: { symbol: '₫', decimals: 0 },
1013
- IDR: { symbol: 'Rp', decimals: 0 },
1014
- SGD: { symbol: 'S$', decimals: 2 },
1015
- HKD: { symbol: 'HK$', decimals: 2 },
1016
- TWD: { symbol: 'NT$', decimals: 2 },
1017
- AUD: { symbol: 'A$', decimals: 2 },
1018
- NZD: { symbol: 'NZ$', decimals: 2 },
1019
- CAD: { symbol: 'CA$', decimals: 2 },
1020
- CNY: { symbol: 'CN¥', decimals: 2 },
1021
- INR: { symbol: '₹', decimals: 2 },
1022
- MYR: { symbol: 'RM', decimals: 2 },
1023
- PHP: { symbol: '₱', decimals: 2 },
1009
+ THB: { symbol: '฿' },
1010
+ USD: { symbol: '$' },
1011
+ EUR: { symbol: '€' },
1012
+ GBP: { symbol: '£' },
1013
+ JPY: { symbol: '¥' },
1014
+ KRW: { symbol: '₩' },
1015
+ VND: { symbol: '₫' },
1016
+ IDR: { symbol: 'Rp' },
1017
+ SGD: { symbol: 'S$' },
1018
+ HKD: { symbol: 'HK$' },
1019
+ TWD: { symbol: 'NT$' },
1020
+ AUD: { symbol: 'A$' },
1021
+ NZD: { symbol: 'NZ$' },
1022
+ CAD: { symbol: 'CA$' },
1023
+ CNY: { symbol: 'CN¥' },
1024
+ INR: { symbol: '₹' },
1025
+ MYR: { symbol: 'RM' },
1026
+ PHP: { symbol: '₱' },
1024
1027
  };
1025
1028
  /** The grouped numeric part of a Money, without symbol or code.
1026
1029
  * `stripZeros` drops a `.00`-style fraction (`money_without_trailing_zeros`). */
@@ -1028,13 +1031,24 @@ function moneyDigits(money, stripZeros = false) {
1028
1031
  const n = Number(money.amount);
1029
1032
  if (!Number.isFinite(n))
1030
1033
  return null;
1031
- const info = CURRENCY_FORMAT[money.currencyCode];
1032
- const decimals = info?.decimals ?? 2;
1033
- let [int, frac] = Math.abs(n).toFixed(decimals).split('.');
1034
+ // Exact decimal text (a JS number's toFixed rounds 1.005 to 1.00); the number itself only when the text is not a decimal.
1035
+ let fixed = null;
1036
+ for (const v of [money.amount, n]) {
1037
+ try {
1038
+ fixed = displayAmount(v, money.currencyCode);
1039
+ break;
1040
+ }
1041
+ catch {
1042
+ // the next form, then none
1043
+ }
1044
+ }
1045
+ if (fixed === null)
1046
+ return null;
1047
+ let [int, frac] = fixed.replace(/^-/, '').split('.');
1034
1048
  if (stripZeros && frac && /^0+$/.test(frac))
1035
1049
  frac = '';
1036
1050
  const grouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
1037
- return `${n < 0 ? '-' : ''}${grouped}${frac ? `.${frac}` : ''}`;
1051
+ return `${fixed.startsWith('-') ? '-' : ''}${grouped}${frac ? `.${frac}` : ''}`;
1038
1052
  }
1039
1053
  /** standard `money` — symbol + amount (e.g. "฿120.00"). */
1040
1054
  export function formatMoney(money) {
@@ -69,6 +69,18 @@ export declare function DynamicSourceProvider({ value, children, }: {
69
69
  children: ReactNode;
70
70
  }): JSX.Element;
71
71
  export declare function useResourceContext(): ResourceContextValue;
72
+ /**
73
+ * Text that names dynamic sources as plain text (`Goes well with {{ product.title }}`): a default the editor has not
74
+ * connected yet, a starter template, a section preview. Read with each source of this page ('' where it has none),
75
+ * exactly as the connected `{ '@template' }` value reads; never the literal braces. Text whose tokens are not all source
76
+ * paths (the contract's `isBoundTemplateValue`), or that names none, is returned as it is.
77
+ */
78
+ export declare function sourceText(text: string, ctx: ResourceContextValue): string;
79
+ /**
80
+ * `sourceText` against the page's resources, for a section component. Reads the resource context the page provides
81
+ * (StoreProvider: the route's resource and the shop), and works without one (a section rendered on its own).
82
+ */
83
+ export declare function useSourceText(text: string): string;
72
84
  /** The resources a `@source` path may start with. */
73
85
  export declare const BOUND_SOURCE_ROOTS: readonly ["product", "collection", "page", "article", "shop", "metaobject"];
74
86
  /** The `@source` grammar a saved setting may carry (the contract owns it; the validator refuses anything else). */