@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
package/README.md CHANGED
@@ -4,7 +4,10 @@
4
4
  > `docs/online-store/PORT_RUNTIME.md`). Old git history is not carried over; that commit is the source.
5
5
  > Changes on import, all wiring or naming (guards: brand term, old-system hosts):
6
6
 
7
- - Imported here (not by OS-ST-2) because build-service needs `2.0.0-alpha.17`, which is only on GitHub Packages.
7
+ - Imported here (not by OS-ST-2) because build-service needed `2.0.0-alpha.17`, then only on GitHub Packages. The repository's
8
+ copy changed under that number after it reached npmjs; since 2026-11-25 it is `2.0.0-alpha.18`, then `2.0.0-alpha.19` (storefront-query rev 2.73 store locations, board 35
9
+ #117), and every published
10
+ version is frozen in `tools/guards/published-packages.json`.
8
11
  - `@tanqory/theme-abi` (dev) is `link:../theme-abi`. Its own lockfile; not a member of the root pnpm workspace.
9
12
 
10
13
 
@@ -46,8 +46,13 @@ export interface SettingsStore {
46
46
  subscribe(listener: () => void): () => void;
47
47
  apply(msg: unknown): void;
48
48
  }
49
- /** The page's theme settings as an external store (preview only, like the section nodes). */
50
- export declare function createSettingsStore(rendered: Record<string, unknown>): SettingsStore;
49
+ /**
50
+ * The page's theme settings as an external store (preview only, like the section nodes). `finish` runs the theme's own
51
+ * settings hooks over the editor's settings laid over the render (effectiveSettings, then shopSettings with the page's
52
+ * shop record), as the server did: without it an empty colour in the editor's file hid the Settings > Brand colour the
53
+ * server had filled in (board 35 #110, Dev check 2026-11-24). Default: unchanged.
54
+ */
55
+ export declare function createSettingsStore(rendered: Record<string, unknown>, finish?: (settings: Record<string, unknown>) => Record<string, unknown>): SettingsStore;
51
56
  export interface CanvasStore {
52
57
  get(): ContentNode[];
53
58
  subscribe(listener: () => void): () => void;
@@ -102,8 +102,13 @@ export function applyThemeSettings(rendered, current, msg) {
102
102
  return rendered;
103
103
  return isObj(msg.settings) ? { ...rendered, ...msg.settings } : current;
104
104
  }
105
- /** The page's theme settings as an external store (preview only, like the section nodes). */
106
- export function createSettingsStore(rendered) {
105
+ /**
106
+ * The page's theme settings as an external store (preview only, like the section nodes). `finish` runs the theme's own
107
+ * settings hooks over the editor's settings laid over the render (effectiveSettings, then shopSettings with the page's
108
+ * shop record), as the server did: without it an empty colour in the editor's file hid the Settings > Brand colour the
109
+ * server had filled in (board 35 #110, Dev check 2026-11-24). Default: unchanged.
110
+ */
111
+ export function createSettingsStore(rendered, finish = (s) => s) {
107
112
  let current = rendered;
108
113
  const listeners = new Set();
109
114
  return {
@@ -116,7 +121,7 @@ export function createSettingsStore(rendered) {
116
121
  const next = applyThemeSettings(rendered, current, msg);
117
122
  if (next === current)
118
123
  return;
119
- current = next;
124
+ current = next === rendered ? rendered : finish(next);
120
125
  for (const l of listeners)
121
126
  l();
122
127
  },
@@ -16,8 +16,8 @@
16
16
  * "Couldn't load your cart — retrying". An add before the cart has loaded reads it first; it
17
17
  * never `cart.create`s over a cart it could not see.
18
18
  *
19
- * A refused write may say why (theme-abi Cart-1, alpha.13): `refusal` on the `invalid` CartResult,
20
- * or `error.refusal` when `cart.create` is refused. It is kept for `lastRefusal()`, so the surface
19
+ * A refused write may say why (theme-abi Cart-1, alpha.13; Cart-3 adds a company location's quantity rule): `refusal`
20
+ * on the `invalid` CartResult, or `error.refusal` when `cart.create` is refused. It is kept for `lastRefusal()`, so the surface
21
21
  * that made the write can word it ("You can buy up to 5 of this item").
22
22
  *
23
23
  * A line write the platform cut for stock (theme-abi Cart-2: the answered cart's `warnings`, the store's
@@ -33,8 +33,9 @@ import type { Cart as AbiCart } from '@tanqory/theme-abi';
33
33
  import { type CartAddStock, type CartRefusal } from '../runtime/kit/cart.js';
34
34
  import { type AbiRemote } from './wire.js';
35
35
  /**
36
- * The refusal the platform sent with a refused write (theme-abi Cart-1), or null. Only a code this
37
- * theme knows counts; `maxQuantity` only when it is a whole number of at least 1.
36
+ * The refusal the platform sent with a refused write (theme-abi Cart-1 / Cart-3), or null. Only a code this
37
+ * theme knows counts: `cart_limit_exceeded` (`maxQuantity` only when it is a whole number of at least 1) and
38
+ * `quantity_rule` with a `rule` of `minimum`, `maximum` or `increment` (anything else is no refusal).
38
39
  */
39
40
  export declare function refusalOf(raw: unknown): CartRefusal | null;
40
41
  /**
package/dist/abi/cart.js CHANGED
@@ -17,8 +17,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
17
17
  * "Couldn't load your cart — retrying". An add before the cart has loaded reads it first; it
18
18
  * never `cart.create`s over a cart it could not see.
19
19
  *
20
- * A refused write may say why (theme-abi Cart-1, alpha.13): `refusal` on the `invalid` CartResult,
21
- * or `error.refusal` when `cart.create` is refused. It is kept for `lastRefusal()`, so the surface
20
+ * A refused write may say why (theme-abi Cart-1, alpha.13; Cart-3 adds a company location's quantity rule): `refusal`
21
+ * on the `invalid` CartResult, or `error.refusal` when `cart.create` is refused. It is kept for `lastRefusal()`, so the surface
22
22
  * that made the write can word it ("You can buy up to 5 of this item").
23
23
  *
24
24
  * A line write the platform cut for stock (theme-abi Cart-2: the answered cart's `warnings`, the store's
@@ -42,12 +42,21 @@ function stateOf(c, ready) {
42
42
  const s = cartState(c);
43
43
  return { ...s, appliedGiftCards: [], loading: false, ready, error: null };
44
44
  }
45
+ const QUANTITY_RULE_PARTS = new Set(['minimum', 'maximum', 'increment']);
45
46
  /**
46
- * The refusal the platform sent with a refused write (theme-abi Cart-1), or null. Only a code this
47
- * theme knows counts; `maxQuantity` only when it is a whole number of at least 1.
47
+ * The refusal the platform sent with a refused write (theme-abi Cart-1 / Cart-3), or null. Only a code this
48
+ * theme knows counts: `cart_limit_exceeded` (`maxQuantity` only when it is a whole number of at least 1) and
49
+ * `quantity_rule` with a `rule` of `minimum`, `maximum` or `increment` (anything else is no refusal).
48
50
  */
49
51
  export function refusalOf(raw) {
50
- if (typeof raw !== 'object' || raw === null || raw.code !== 'cart_limit_exceeded')
52
+ if (typeof raw !== 'object' || raw === null)
53
+ return null;
54
+ const code = raw.code;
55
+ if (code === 'quantity_rule') {
56
+ const rule = raw.rule;
57
+ return typeof rule === 'string' && QUANTITY_RULE_PARTS.has(rule) ? { code: 'quantity_rule', rule: rule } : null;
58
+ }
59
+ if (code !== 'cart_limit_exceeded')
51
60
  return null;
52
61
  const max = raw.maxQuantity;
53
62
  return typeof max === 'number' && Number.isSafeInteger(max) && max >= 1 ? { code: 'cart_limit_exceeded', maxQuantity: max } : { code: 'cart_limit_exceeded' };
@@ -18,7 +18,7 @@
18
18
  import type { Filter as AbiFilter, Article as AbiArticle, Blog as AbiBlog, Cart as AbiCart, Collection as AbiCollection, Image as AbiImage, Menu as AbiMenu, Page as AbiPage, Policy as AbiPolicy, Product as AbiProduct, Shop as AbiShop, SearchResult as AbiSearchResult } from '@tanqory/theme-abi';
19
19
  import type { Collection, ImageRef, Page, Product, ProductMedia, ProductRating, ProductReview, SellingPlanGroup } from '../runtime/kit/data.js';
20
20
  import type { ShopLoyalty, ShopReferrals } from '../sdk/types.js';
21
- import type { Article, ArticleComments, Blog, Filter, Menu, SearchResults, Shop, ShopAddress, ShopLocation, ShopPolicy, ShopPopup } from '../runtime/kit/storefront.js';
21
+ import type { Article, ArticleComments, Blog, Filter, Menu, OpeningPeriod, SearchResults, Shop, ShopAddress, ShopLocation, ShopPolicy, ShopPopup } from '../runtime/kit/storefront.js';
22
22
  export declare function image(i: AbiImage | null | undefined): ImageRef | null;
23
23
  /** Plain text of an HTML body, for the surfaces that show text only (cards, meta description). */
24
24
  export declare function plainText(html: string | null | undefined): string;
@@ -133,6 +133,19 @@ export declare function shop(s: AbiShop, policies?: readonly AbiPolicy[], countr
133
133
  * no member, so the theme renders no widget (today's behaviour).
134
134
  */
135
135
  export declare function spamProtection(raw: unknown): NonNullable<Shop['spamProtection']> | null;
136
+ /**
137
+ * storefront-query rev 2.72 `Shop.brand.slogan` / `shortDescription` / `coverImage` (board 35 #110), each only when it
138
+ * is a non-empty string (at most 100 / 150 characters) or an image with a URL.
139
+ */
140
+ export declare function brandStoryOf(b: {
141
+ slogan?: unknown;
142
+ shortDescription?: unknown;
143
+ coverImage?: AbiImage | null;
144
+ } | null | undefined): {
145
+ slogan?: string;
146
+ shortDescription?: string;
147
+ coverImage?: ImageRef;
148
+ };
136
149
  /**
137
150
  * Settings › Brand fonts (`Shop.brand.fonts`, NEW-OS-12): the merchant's family names in priority order —
138
151
  * a theme maps `[0]` → headings, `[1]` → body (`Shop.brand.fonts` in runtime/kit/storefront.ts). Carried by
@@ -156,6 +169,8 @@ export declare function shopReferrals(raw: unknown): ShopReferrals | null;
156
169
  export declare function shopAddress(raw: unknown): ShopAddress | null;
157
170
  /** rev 2.34 `Shop.locations` → whole entries only (an id, a name, an address), in the platform's order, at most 50. */
158
171
  export declare function shopLocations(raw: unknown): ShopLocation[];
172
+ /** rev 2.73 `ShopLocation.openingHours` → whole periods only (a weekday once, 24-hour times), Monday first; null when absent. */
173
+ export declare function openingHours(raw: unknown): OpeningPeriod[] | null;
159
174
  /**
160
175
  * rev 2.37 `Shop.popups` → whole pop-ups only (an id, a known kind and trigger, a trigger value that fits it, a
161
176
  * frequency, at least one known page, a language, a heading and a button label), in the platform's order, at most 20.
@@ -267,11 +282,12 @@ export declare function cartState(c: AbiCart): {
267
282
  currencyCode: string;
268
283
  };
269
284
  };
270
- productHandle: string;
271
285
  attributes: {
272
286
  key: string;
273
287
  value: string;
274
288
  }[];
289
+ productId?: string | undefined;
290
+ productHandle: string;
275
291
  discountAllocations?: Array<{
276
292
  title: string | null;
277
293
  code: string | null;
@@ -347,13 +347,18 @@ export function productMedia(raw) {
347
347
  out.push({ id: `media-${i}`, type: 'external_video', alt, host, embedUrl });
348
348
  continue;
349
349
  }
350
- // rev 2.52 (alpha.24): a 3D model — one binary glTF file of the store's library
350
+ // rev 2.52 (alpha.24): a 3D model — one binary glTF file of the store's library, and its USDZ for iOS Quick Look when
351
+ // the merchant gave one (theme-abi-v2 "Host capability: 3D models"). A source is an https media URL or the platform's
352
+ // same-origin model path (`/_tq/model/…`, which the read model may hand over directly).
351
353
  if (r.mediaContentType === 'MODEL_3D' && Array.isArray(r.sources)) {
352
- const src = r.sources.find((s) => Boolean(s) && typeof s.url === 'string' && HTTPS.test(s.url) && s.mimeType === 'model/gltf-binary');
354
+ const sources = r.sources;
355
+ const pick = (type) => sources.find((s) => Boolean(s) && typeof s.url === 'string' && (HTTPS.test(s.url) || s.url.startsWith('/_tq/model/')) && s.mimeType === type);
356
+ const src = pick('model/gltf-binary');
353
357
  if (!src)
354
358
  continue;
359
+ const usdz = pick('model/vnd.usdz+zip');
355
360
  const poster = image(r.previewImage);
356
- out.push({ id: `media-${i}`, type: 'model_3d', alt, previewImage: poster && HTTPS.test(poster.url) ? poster : null, sources: [{ url: src.url, mimeType: src.mimeType, format: 'glb' }] });
361
+ out.push({ id: `media-${i}`, type: 'model_3d', alt, previewImage: poster && HTTPS.test(poster.url) ? poster : null, sources: [{ url: src.url, mimeType: src.mimeType, format: 'glb' }, ...(usdz ? [{ url: usdz.url, mimeType: usdz.mimeType, format: 'usdz' }] : [])] });
357
362
  continue;
358
363
  }
359
364
  if (r.mediaContentType !== 'VIDEO' || !Array.isArray(r.sources))
@@ -677,6 +682,8 @@ export function shop(s, policies = [], country = '') {
677
682
  squareLogo: image(s.brand.squareLogo),
678
683
  ...(primary ? { colors: { primary: [{ background: primary }], secondary: [] } } : {}),
679
684
  ...(fonts.length ? { fonts } : {}),
685
+ // storefront-query rev 2.72 (board 35 #110): Settings › Brand slogan, short description and cover image.
686
+ ...brandStoryOf(s.brand),
680
687
  }
681
688
  : null,
682
689
  policies: slots,
@@ -702,6 +709,17 @@ export function spamProtection(raw) {
702
709
  return null;
703
710
  return { contactForms: r.contactForms, authPages: r.authPages, siteKey: r.siteKey };
704
711
  }
712
+ /**
713
+ * storefront-query rev 2.72 `Shop.brand.slogan` / `shortDescription` / `coverImage` (board 35 #110), each only when it
714
+ * is a non-empty string (at most 100 / 150 characters) or an image with a URL.
715
+ */
716
+ export function brandStoryOf(b) {
717
+ const t = (v, max) => (typeof v === 'string' && v.trim() && v.trim().length <= max ? v.trim() : null);
718
+ const slogan = t(b?.slogan, 100);
719
+ const shortDescription = t(b?.shortDescription, 150);
720
+ const coverImage = image(b?.coverImage ?? null);
721
+ return { ...(slogan ? { slogan } : {}), ...(shortDescription ? { shortDescription } : {}), ...(coverImage ? { coverImage } : {}) };
722
+ }
705
723
  /**
706
724
  * Settings › Brand fonts (`Shop.brand.fonts`, NEW-OS-12): the merchant's family names in priority order —
707
725
  * a theme maps `[0]` → headings, `[1]` → body (`Shop.brand.fonts` in runtime/kit/storefront.ts). Carried by
@@ -885,10 +903,37 @@ export function shopLocations(raw) {
885
903
  const phone = text(r.phone, 50);
886
904
  // rev 2.52 (O3): the merchant's expected pickup time, one of five values
887
905
  const readyIn = typeof r.pickupReadyIn === 'string' && PICKUP_READY_IN.has(r.pickupReadyIn) ? r.pickupReadyIn : null;
888
- out.push({ id, name, address, ...(phone && /^[0-9+()\-. ]+$/.test(phone) ? { phone } : {}), ...(readyIn ? { pickupReadyIn: readyIn } : {}) });
906
+ // rev 2.73 (board 35 #117): pickup / storefront marks and the weekly opening hours
907
+ const hours = openingHours(r.openingHours);
908
+ out.push({
909
+ id,
910
+ name,
911
+ address,
912
+ ...(phone && /^[0-9+()\-. ]+$/.test(phone) ? { phone } : {}),
913
+ ...(readyIn ? { pickupReadyIn: readyIn } : {}),
914
+ ...(typeof r.pickup === 'boolean' ? { pickup: r.pickup } : {}),
915
+ ...(typeof r.storefront === 'boolean' ? { storefront: r.storefront } : {}),
916
+ ...(hours ? { openingHours: hours } : {}),
917
+ });
889
918
  }
890
919
  return out;
891
920
  }
921
+ const WEEKDAYS = ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'];
922
+ const HH_MM = /^([01]\d|2[0-3]):[0-5]\d$/;
923
+ /** rev 2.73 `ShopLocation.openingHours` → whole periods only (a weekday once, 24-hour times), Monday first; null when absent. */
924
+ export function openingHours(raw) {
925
+ if (!Array.isArray(raw))
926
+ return null;
927
+ const out = [];
928
+ for (const p of raw.slice(0, 7)) {
929
+ const r = (p && typeof p === 'object' ? p : {});
930
+ const day = WEEKDAYS.find((d) => d === r.day);
931
+ if (!day || out.some((o) => o.day === day) || typeof r.opens !== 'string' || typeof r.closes !== 'string' || !HH_MM.test(r.opens) || !HH_MM.test(r.closes))
932
+ continue;
933
+ out.push({ day, opens: r.opens, closes: r.closes });
934
+ }
935
+ return out.sort((a, b) => WEEKDAYS.indexOf(a.day) - WEEKDAYS.indexOf(b.day));
936
+ }
892
937
  const POPUP_KINDS = new Set(['newsletter', 'announcement']);
893
938
  const POPUP_TRIGGERS = new Set(['delay', 'scroll', 'exitIntent']);
894
939
  const POPUP_PAGES = new Set(['all', 'home', 'product', 'collection', 'cart']);
@@ -1030,6 +1075,10 @@ export function cookieBanner(raw) {
1030
1075
  const p = texts(r.preferences, PREFS_TEXT);
1031
1076
  const prefs = r.preferences && typeof r.preferences === 'object' ? r.preferences : null;
1032
1077
  const bullets = prefs?.bulletsEnabled === true && Array.isArray(prefs.bullets) ? prefs.bullets.map((b) => text(b, 500)).filter((b) => Boolean(b)).slice(0, 3) : [];
1078
+ // Rev 2.69 (board 35 #42): the merchant's custom colours, each `#rrggbb` or the whole set is dropped.
1079
+ const c = colorTheme === 'custom' && r.colors && typeof r.colors === 'object' ? r.colors : null;
1080
+ const hex = (v) => typeof v === 'string' && /^#[0-9a-f]{6}$/.test(v);
1081
+ const colors = c && hex(c.background) && hex(c.text) && hex(c.button) && hex(c.buttonText) ? { background: c.background, text: c.text, button: c.button, buttonText: c.buttonText } : null;
1033
1082
  return {
1034
1083
  enabled: r.enabled === true,
1035
1084
  // "Use automated settings" — never saved means on (contract rev 2).
@@ -1038,6 +1087,7 @@ export function cookieBanner(raw) {
1038
1087
  colorTheme,
1039
1088
  regions,
1040
1089
  ...(privacyLinkUrl ? { privacyLinkUrl } : {}),
1090
+ ...(colors ? { colors } : {}),
1041
1091
  text: t,
1042
1092
  preferences: { ...p, ...(bullets.length ? { bullets } : {}) },
1043
1093
  };
@@ -1212,6 +1262,8 @@ export function cartState(c) {
1212
1262
  ...(l.cost.totalAmount ? { lineTotal: l.cost.totalAmount } : {}),
1213
1263
  ...cartLineDiscountAllocations(l, c.cost.subtotalAmount?.currencyCode),
1214
1264
  productHandle: l.merchandise.product.handle,
1265
+ // theme-abi Cart-4: the line's product id, when the platform sends it
1266
+ ...(typeof l.merchandise.product.id === 'string' && l.merchandise.product.id ? { productId: l.merchandise.product.id } : {}),
1215
1267
  attributes: Object.entries(l.attributes).map(([key, value]) => ({ key, value })),
1216
1268
  ...cartLineSellingPlan(l.sellingPlanAllocation),
1217
1269
  })),
@@ -51,6 +51,10 @@ export function storeLocations(shop) {
51
51
  phone: l.phone ?? null,
52
52
  },
53
53
  ...(l.pickupReadyIn ? { pickupReadyIn: l.pickupReadyIn } : {}),
54
+ // rev 2.73 (board 35 #117)
55
+ ...(typeof l.pickup === 'boolean' ? { pickup: l.pickup } : {}),
56
+ ...(typeof l.storefront === 'boolean' ? { storefront: l.storefront } : {}),
57
+ ...(l.openingHours ? { openingHours: l.openingHours.map((p) => ({ ...p })) } : {}),
54
58
  }));
55
59
  }
56
60
  export function createDataApi(pd, remote) {
@@ -6,10 +6,13 @@
6
6
  * bytes the server rendered. Nothing here is cached across renders: a `PageData` is created inside
7
7
  * `render()` and dropped with it (§1 multi-tenant isolates, suite 9).
8
8
  *
9
- * Data plan (§3 counting, §8 limits — 4 calls / 2 rounds hard, 1 / 1 budget):
9
+ * Data plan (§3 counting, §8 limits — 4 calls / 8 sub-requests / 2 rounds hard; budget 3 / 3 / 1, DECISIONS row 272):
10
10
  * round 1 snapshot({ resolve: 'all' }) — shop, menus, the route's resource, and every
11
11
  * `resolve: true` setting the platform resolves into `refs`
12
- * round 2 only what round 1 did not answer, all started together: one `shop.menus([...])`,
12
+ * (round 1 also carries what is known before the snapshot answers: the collection list for a page that
13
+ * lists collections, the product page's recommendations)
14
+ * round 2 only what round 1 did not answer, all started together: one `shop.menus([...])` (only when the
15
+ * snapshot's menu list was cut at SNAPSHOT_MENUS_MAX, so a missing menu might exist),
13
16
  * `catalog.collections()` when a section lists every collection, then one
14
17
  * `catalog.collection` / `catalog.product` per unresolved ref — never past the hard
15
18
  * call limit. A ref the budget cannot cover renders as "not found", the section's own
@@ -172,7 +175,12 @@ export interface PagePlanOptions {
172
175
  /** Data calls the caller makes beside the plan in the same render; the plan stays inside the limit with them. */
173
176
  reservedCalls?: number;
174
177
  }
175
- /** Resource settings on this page (effective value = node setting, else the attribute default). */
178
+ /**
179
+ * Resource settings on this page (effective value = node setting, else the attribute default). A resource list
180
+ * (`{ type: 'list', items: { type: <kind> } }`) names one need per non-empty entry, keyed
181
+ * `${nodeId}.${settingKey}.${index}` exactly as the host keys its snapshot refs (storefront-edge core/snapshot-refs.ts):
182
+ * round 1 answers what fits in the snapshot, round 2 fetches the rest inside the call limit.
183
+ */
176
184
  export declare function pageNeeds(nodes: readonly ContentNode[], defs: (type: string) => SectionDef | undefined): {
177
185
  needs: Need[];
178
186
  listsCollections: boolean;
@@ -4,6 +4,8 @@ import { searchOrder } from './data-api.js';
4
4
  import { filterRequests, listingQueryOf, stateFromQuery } from '../runtime/render/listing-query.js';
5
5
  /** Hard limits (theme-abi-v2.md §8). The host enforces them; the theme plans inside them. */
6
6
  const MAX_DATA_CALLS = 4;
7
+ /** `snapshot.menus` holds every menu of the store up to this many, by handle order (storefront-query-v1 §9.1). */
8
+ const SNAPSHOT_MENUS_MAX = 20;
7
9
  /** Products per listing request — the page size platform/runtime/render/product-listing.ts asks for. */
8
10
  const LISTING_FIRST = 24;
9
11
  /** Product tags are the merchant's internal labels, never a shopper filter (product-listing.ts). */
@@ -151,7 +153,12 @@ function walk(nodes, visit) {
151
153
  walk(n.blocks, visit);
152
154
  }
153
155
  }
154
- /** Resource settings on this page (effective value = node setting, else the attribute default). */
156
+ /**
157
+ * Resource settings on this page (effective value = node setting, else the attribute default). A resource list
158
+ * (`{ type: 'list', items: { type: <kind> } }`) names one need per non-empty entry, keyed
159
+ * `${nodeId}.${settingKey}.${index}` exactly as the host keys its snapshot refs (storefront-edge core/snapshot-refs.ts):
160
+ * round 1 answers what fits in the snapshot, round 2 fetches the rest inside the call limit.
161
+ */
155
162
  export function pageNeeds(nodes, defs) {
156
163
  const needs = [];
157
164
  /** The menu handles the header shows: when every one is empty the drawer lists the collections instead. */
@@ -175,6 +182,17 @@ export function pageNeeds(nodes, defs) {
175
182
  if (n.type === 'header' && (settings.showAccount ?? def.attributes?.showAccount?.default) !== false)
176
183
  showsAccount = true;
177
184
  for (const [key, spec] of Object.entries(def.attributes ?? {})) {
185
+ if (spec.type === 'list') {
186
+ const kind = spec.items?.type;
187
+ const list = settings[key] ?? spec.default;
188
+ if (typeof kind !== 'string' || !RESOURCE_KINDS.has(kind) || !Array.isArray(list))
189
+ continue;
190
+ list.forEach((h, i) => {
191
+ if (typeof h === 'string' && h.trim())
192
+ needs.push({ kind: kind, handle: h.trim(), ref: `${n.id}.${key}.${i}` });
193
+ });
194
+ continue;
195
+ }
178
196
  if (!RESOURCE_KINDS.has(spec.type))
179
197
  continue;
180
198
  const value = settings[key] ?? spec.default;
@@ -341,6 +359,26 @@ plan) {
341
359
  // ctx.capabilities Nova does not ask for it at all: shop + menus in one round, and the template
342
360
  // renders its "nothing here" state. Either way nothing outside the grant is ever called.
343
361
  const resourceCap = RESOURCE_CAPABILITY[ctx.route.kind];
362
+ // Round 1 carries what the plan knows it needs before the snapshot answers (TS-10, 2026-11-19): the store's
363
+ // collection list for a page that lists collections, beside the snapshot, so such a page takes one round instead of
364
+ // two. Each extra round is a cross-region hop (theme-abi §8 `sequentialRounds`); calls inside one round run together.
365
+ // Dev, 2026-11-19 (Tanqory Demo Fashion, server-timing `render`, 12 runs each): a one-round page (/collections)
366
+ // rendered in 75 ms median, 100 ms p90. A route whose own resource is the list (`collections`) needs none of it.
367
+ let early = null;
368
+ if (listsAll && ctx.route.kind !== 'collections' && can('data:catalog') && calls + 2 <= MAX_DATA_CALLS) {
369
+ calls++;
370
+ early = ctx.data.catalog.collections({ first: 50 });
371
+ early.catch(() => undefined); // a refusal is read where it is awaited, never an unhandled rejection
372
+ }
373
+ // The product page's recommendations need only the route's handle, known before the snapshot answers: they ride in
374
+ // round 1 too (TS-10, 2026-11-20). A product that does not exist answers none; the page renders its own empty state.
375
+ const recRoute = ctx.route.kind === 'product' ? ctx.route.handle : undefined;
376
+ let earlyRecs = null;
377
+ if (showsRecommendations && recRoute && can('data:products.recommendations') && calls + 2 <= MAX_DATA_CALLS) {
378
+ calls++;
379
+ earlyRecs = ctx.data.catalog.recommendations(recRoute, 'related', 8);
380
+ earlyRecs.catch(() => undefined); // a refusal is read where it is awaited, never an unhandled rejection
381
+ }
344
382
  let snapshot;
345
383
  if (!resourceCap || can(resourceCap)) {
346
384
  calls++;
@@ -471,6 +509,19 @@ plan) {
471
509
  break;
472
510
  default: break;
473
511
  }
512
+ if (early) {
513
+ try {
514
+ const c = await early;
515
+ collectionList = c.nodes.map(convert.collection);
516
+ c.nodes.forEach(putCard);
517
+ }
518
+ catch (e) {
519
+ const name = e?.name;
520
+ if (name === 'DataLimitError' || name === 'CapabilityError')
521
+ throw e;
522
+ ctx.log.warn('page data: collection list unavailable', { error: String(e?.message ?? e) });
523
+ }
524
+ }
474
525
  // Picker settings bound to a metafield of the route's resource or the shop: their handles join the needs.
475
526
  const routeSources = {
476
527
  shop: { ...snapshot.shop, ...convert.metafieldsOf(snapshot.shop) },
@@ -521,7 +572,11 @@ plan) {
521
572
  const round = [];
522
573
  const unresolved = [];
523
574
  const take = () => (calls < MAX_DATA_CALLS ? (calls++, true) : false);
524
- const missingMenus = missing.filter((m) => m.kind === 'menu').map((m) => m.handle);
575
+ // The snapshot's `menus` is every menu of the store, up to SNAPSHOT_MENUS_MAX (storefront-query §9.1): when it holds
576
+ // fewer, a menu it does not list does not exist, and asking again in round 2 only costs a round (TS-10: Nova's three
577
+ // footer menus did that on every page of a store that has none of them).
578
+ const snapshotListsEveryMenu = Object.keys(snapshot.menus ?? {}).length < SNAPSHOT_MENUS_MAX;
579
+ const missingMenus = snapshotListsEveryMenu ? [] : missing.filter((m) => m.kind === 'menu').map((m) => m.handle);
525
580
  if (missingMenus.length) {
526
581
  if (take())
527
582
  round.push(ctx.data.shop.menus(missingMenus).then((list) => { for (const m of list)
@@ -577,7 +632,20 @@ plan) {
577
632
  }
578
633
  const recommendations = {};
579
634
  const recFor = ctx.route.kind === 'product' ? ctx.route.handle : undefined;
580
- if (showsRecommendations && recFor && products[recFor] && can('data:products.recommendations')) {
635
+ if (earlyRecs && recFor) {
636
+ try {
637
+ const list = await earlyRecs;
638
+ if (products[recFor])
639
+ recommendations[recFor] = list.map(convert.product);
640
+ }
641
+ catch (e) {
642
+ const name = e?.name;
643
+ if (name === 'DataLimitError' || name === 'CapabilityError')
644
+ throw e;
645
+ ctx.log.warn('page data: recommendations unavailable', { error: String(e?.message ?? e) });
646
+ }
647
+ }
648
+ else if (showsRecommendations && recFor && products[recFor] && can('data:products.recommendations')) {
581
649
  if (take())
582
650
  round.push(ctx.data.catalog.recommendations(recFor, 'related', 8).then((list) => { recommendations[recFor] = list.map(convert.product); }));
583
651
  else
@@ -34,5 +34,13 @@ export declare class AbiWireError extends Error {
34
34
  * the same budget (QA test-2 F1).
35
35
  */
36
36
  export declare function parseRetryAfter(value: string | null, now?: number): number | null;
37
+ /**
38
+ * How long a /_tq request may take before the page gives up on it. A request the gateway never answers left Add to cart
39
+ * on "Adding…" for good (Dev 2026-11-19, store Evermade, board 35 #85 side finding): the cart and the button await this
40
+ * promise, and fetch has no timeout of its own. Past it the request fails as `timeout` (status 0), which the cart reports
41
+ * like any failed request (the button returns, the cart says it could not update; a cart read backs off and retries).
42
+ */
43
+ export declare const WIRE_TIMEOUT_MS = 20000;
44
+ export declare function timedFetch(url: string, init: RequestInit, ms?: number): Promise<Response>;
37
45
  /** Browser-only; the routes are relative to the page's own origin. */
38
46
  export declare function createAbiRemote(): AbiRemote;
package/dist/abi/wire.js CHANGED
@@ -28,6 +28,36 @@ export function parseRetryAfter(value, now = Date.now()) {
28
28
  const at = Date.parse(v);
29
29
  return Number.isNaN(at) ? null : Math.max(0, at - now);
30
30
  }
31
+ /**
32
+ * How long a /_tq request may take before the page gives up on it. A request the gateway never answers left Add to cart
33
+ * on "Adding…" for good (Dev 2026-11-19, store Evermade, board 35 #85 side finding): the cart and the button await this
34
+ * promise, and fetch has no timeout of its own. Past it the request fails as `timeout` (status 0), which the cart reports
35
+ * like any failed request (the button returns, the cart says it could not update; a cart read backs off and retries).
36
+ */
37
+ export const WIRE_TIMEOUT_MS = 20_000;
38
+ export async function timedFetch(url, init, ms = WIRE_TIMEOUT_MS) {
39
+ // A plain timer, cleared as soon as the whole answer is read: no timer outlives its request (AbortSignal.timeout's
40
+ // would stay pending for the full 20 s, which a page that waits for idle, such as the theme checks' hydration run,
41
+ // reads as work still going on).
42
+ if (typeof AbortController === 'undefined')
43
+ return fetch(url, init);
44
+ const controller = new AbortController();
45
+ const timer = setTimeout(() => controller.abort(), ms);
46
+ try {
47
+ const res = await fetch(url, { ...init, signal: controller.signal });
48
+ // The body is read inside the timeout too: an answer whose body never ends is as stuck as no answer.
49
+ const body = await res.text();
50
+ return new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers });
51
+ }
52
+ catch (e) {
53
+ if (controller.signal.aborted)
54
+ throw new AbiWireError(0, 'timeout');
55
+ throw e;
56
+ }
57
+ finally {
58
+ clearTimeout(timer);
59
+ }
60
+ }
31
61
  function base64url(text) {
32
62
  const bytes = new TextEncoder().encode(text);
33
63
  let bin = '';
@@ -55,7 +85,7 @@ export function createAbiRemote() {
55
85
  return {
56
86
  async data(op, args) {
57
87
  const qs = args.length ? `?a=${base64url(canonicalize(args))}` : '';
58
- const res = await fetch(`${DATA}${op}${qs}`, { method: 'GET', credentials: 'same-origin', headers: { accept: 'application/json' } });
88
+ const res = await timedFetch(`${DATA}${op}${qs}`, { method: 'GET', credentials: 'same-origin', headers: { accept: 'application/json' } });
59
89
  const env = await envelope(res);
60
90
  if (!env.ok)
61
91
  throw new AbiWireError(res.status, env.error.code, parseRetryAfter(res.headers.get('retry-after')));
@@ -67,7 +97,7 @@ export function createAbiRemote() {
67
97
  throw new AbiWireError(413, 'invalid_argument');
68
98
  const post = async () => {
69
99
  const token = csrfToken();
70
- return fetch(`${ACTIONS}${name}`, {
100
+ return timedFetch(`${ACTIONS}${name}`, {
71
101
  method: 'POST',
72
102
  credentials: 'same-origin',
73
103
  headers: { 'content-type': 'application/json', accept: 'application/json', ...(token ? { 'x-tq-csrf': token } : {}) },
package/dist/build.d.ts CHANGED
@@ -77,15 +77,20 @@ export interface BuildManifestInput {
77
77
  contentVersion?: number;
78
78
  /**
79
79
  * `engines["tanqory-field-types"]` (default "2": `asset:client/…` image values in defaults and presets; "3" adds
80
- * `color_palette`, B.3).
80
+ * `color_palette`, B.3; "4" adds `model`, B.4). Unset and a section declares a `model` setting: "4".
81
81
  */
82
- fieldTypes?: '1' | '2' | '3';
82
+ fieldTypes?: '1' | '2' | '3' | '4';
83
83
  /** The AI-compat profile; from the sections' `ai` roles by default, `false` for none. */
84
84
  aiProfile?: AiProfile | false;
85
85
  /** Checks every default and preset value (e.g. `validateFieldValue` from `@tanqory/theme-abi`). */
86
86
  checkValue?: ValueCheck;
87
87
  /** Extra top-level `x-*` members. */
88
88
  extensions?: Readonly<Record<`x-${string}`, unknown>>;
89
+ /**
90
+ * The font families the theme ships itself (assets/*.woff2 with its own `@font-face`): a font setting may offer
91
+ * them. Absent: every Theme-group family a font setting names is taken as declared.
92
+ */
93
+ themeFontFamilies?: readonly string[];
89
94
  }
90
95
  export interface BuiltManifest {
91
96
  manifest: Record<string, unknown>;