@tanqory/theme-kit 0.1.0 → 2.0.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +128 -10
- package/dist/abi/canvas-live.d.ts +72 -0
- package/dist/abi/canvas-live.js +159 -0
- package/dist/abi/cart.d.ts +60 -0
- package/dist/abi/cart.js +396 -0
- package/dist/abi/convert.d.ts +360 -0
- package/dist/abi/convert.js +1330 -0
- package/dist/abi/data-api.d.ts +15 -0
- package/dist/abi/data-api.js +213 -0
- package/dist/abi/jcs.d.ts +6 -0
- package/dist/abi/jcs.js +28 -0
- package/dist/abi/labels.d.ts +3 -0
- package/dist/abi/labels.js +34 -0
- package/dist/abi/page-data.d.ts +264 -0
- package/dist/abi/page-data.js +746 -0
- package/dist/abi/page.d.ts +28 -0
- package/dist/abi/page.js +57 -0
- package/dist/abi/referrals.d.ts +23 -0
- package/dist/abi/referrals.js +89 -0
- package/dist/abi/rewards.d.ts +27 -0
- package/dist/abi/rewards.js +82 -0
- package/dist/abi/seo.d.ts +47 -0
- package/dist/abi/seo.js +68 -0
- package/dist/abi/shell.d.ts +23 -0
- package/dist/abi/shell.js +10 -0
- package/dist/abi/state-pack.d.ts +17 -0
- package/dist/abi/state-pack.js +43 -0
- package/dist/abi/wire.d.ts +46 -0
- package/dist/abi/wire.js +114 -0
- package/dist/build.d.ts +121 -0
- package/dist/build.js +401 -0
- package/dist/chunks.d.ts +23 -0
- package/dist/chunks.js +41 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.js +101 -0
- package/dist/contract.d.ts +6 -0
- package/dist/contract.js +6 -0
- package/dist/headless/ai.d.ts +132 -0
- package/dist/headless/ai.js +99 -0
- package/dist/headless/hooks.d.ts +276 -0
- package/dist/headless/hooks.js +544 -0
- package/dist/headless/i18n.d.ts +13 -0
- package/dist/headless/i18n.js +45 -0
- package/dist/headless/index.d.ts +44 -0
- package/dist/headless/index.js +48 -0
- package/dist/headless/lazy-component.d.ts +72 -0
- package/dist/headless/lazy-component.js +225 -0
- package/dist/headless/lazy-section.d.ts +38 -0
- package/dist/headless/lazy-section.js +97 -0
- package/dist/headless/model.d.ts +73 -0
- package/dist/headless/model.js +115 -0
- package/dist/headless/money.d.ts +17 -0
- package/dist/headless/money.js +63 -0
- package/dist/headless/page.d.ts +45 -0
- package/dist/headless/page.js +53 -0
- package/dist/headless/platform.d.ts +55 -0
- package/dist/headless/platform.js +77 -0
- package/dist/headless/primitives/cart.d.ts +90 -0
- package/dist/headless/primitives/cart.js +153 -0
- package/dist/headless/primitives/collection.d.ts +68 -0
- package/dist/headless/primitives/collection.js +80 -0
- package/dist/headless/primitives/product.d.ts +101 -0
- package/dist/headless/primitives/product.js +117 -0
- package/dist/headless/primitives/storefront.d.ts +106 -0
- package/dist/headless/primitives/storefront.js +187 -0
- package/dist/headless/primitives/util.d.ts +19 -0
- package/dist/headless/primitives/util.js +42 -0
- package/dist/headless/strings.d.ts +9 -0
- package/dist/headless/strings.js +198 -0
- package/dist/headless/structured-data.d.ts +31 -0
- package/dist/headless/structured-data.js +57 -0
- package/dist/headless/tanqory-money.generated.d.ts +493 -0
- package/dist/headless/tanqory-money.generated.js +507 -0
- package/dist/headless/theme.d.ts +109 -0
- package/dist/headless/theme.js +62 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +21 -553
- package/dist/runtime/data/StoreProvider.d.ts +84 -0
- package/dist/runtime/data/StoreProvider.js +380 -0
- package/dist/runtime/data/handle.d.ts +14 -0
- package/dist/runtime/data/handle.js +16 -0
- package/dist/runtime/data/routes.d.ts +87 -0
- package/dist/runtime/data/routes.js +158 -0
- package/dist/runtime/data/to-ui.d.ts +286 -0
- package/dist/runtime/data/to-ui.js +1009 -0
- package/dist/runtime/entries/register.d.ts +9 -0
- package/dist/runtime/entries/register.js +9 -0
- package/dist/runtime/entries/sections.d.ts +16 -0
- package/dist/runtime/entries/sections.js +19 -0
- package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
- package/dist/runtime/kit/SectionTree.js +100 -0
- package/dist/runtime/kit/analytics.d.ts +63 -0
- package/dist/runtime/kit/analytics.js +250 -0
- package/dist/runtime/kit/cart.d.ts +222 -0
- package/dist/runtime/kit/cart.js +545 -0
- package/dist/{types → runtime/kit}/composition.d.ts +1 -1
- package/dist/runtime/kit/composition.js +3 -0
- package/dist/{types → runtime/kit}/config.d.ts +2 -2
- package/dist/runtime/kit/config.js +6 -0
- package/dist/runtime/kit/consent.d.ts +29 -0
- package/dist/runtime/kit/consent.js +159 -0
- package/dist/runtime/kit/contract/content.d.ts +213 -0
- package/dist/runtime/kit/contract/content.js +119 -0
- package/dist/runtime/kit/contract/field-types.d.ts +360 -0
- package/dist/runtime/kit/contract/field-types.js +216 -0
- package/dist/runtime/kit/contract/groups.d.ts +230 -0
- package/dist/runtime/kit/contract/groups.js +402 -0
- package/dist/runtime/kit/contract/index.d.ts +33 -0
- package/dist/runtime/kit/contract/index.js +33 -0
- package/dist/runtime/kit/contract/transform.d.ts +82 -0
- package/dist/runtime/kit/contract/transform.js +133 -0
- package/dist/runtime/kit/contract/validate.d.ts +77 -0
- package/dist/runtime/kit/contract/validate.js +520 -0
- package/dist/runtime/kit/data.d.ts +732 -0
- package/dist/runtime/kit/data.js +1131 -0
- package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
- package/dist/runtime/kit/defineSection.js +10 -0
- package/dist/runtime/kit/dynamic-source.d.ts +118 -0
- package/dist/runtime/kit/dynamic-source.js +311 -0
- package/dist/runtime/kit/index.d.ts +24 -0
- package/dist/runtime/kit/index.js +24 -0
- package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
- package/dist/runtime/kit/jsx-to-json.js +28 -0
- package/dist/{types → runtime/kit}/mount.d.ts +25 -4
- package/dist/runtime/kit/mount.js +124 -0
- package/dist/{types → runtime/kit}/registry.d.ts +1 -1
- package/dist/runtime/kit/registry.js +12 -0
- package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
- package/dist/runtime/kit/ssg.js +56 -0
- package/dist/runtime/kit/storefront.d.ts +652 -0
- package/dist/runtime/kit/storefront.js +723 -0
- package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
- package/dist/runtime/kit/theme-context.js +25 -0
- package/dist/runtime/kit/types.d.ts +155 -0
- package/dist/runtime/kit/types.js +1 -0
- package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
- package/dist/runtime/platform/TrackingPixels.js +63 -0
- package/dist/runtime/platform/environment.d.ts +68 -0
- package/dist/runtime/platform/environment.js +85 -0
- package/dist/runtime/platform/locale.d.ts +27 -0
- package/dist/runtime/platform/locale.js +42 -0
- package/dist/runtime/platform/route-analytics.d.ts +15 -0
- package/dist/runtime/platform/route-analytics.js +72 -0
- package/dist/runtime/platform/safe-href.d.ts +25 -0
- package/dist/runtime/platform/safe-href.js +69 -0
- package/dist/runtime/platform/safe-values.d.ts +37 -0
- package/dist/runtime/platform/safe-values.js +140 -0
- package/dist/runtime/render/SectionRenderer.d.ts +4 -0
- package/dist/runtime/render/SectionRenderer.js +199 -0
- package/dist/runtime/render/listing-query.d.ts +52 -0
- package/dist/runtime/render/listing-query.js +122 -0
- package/dist/runtime/render/localized-copy.d.ts +86 -0
- package/dist/runtime/render/localized-copy.js +129 -0
- package/dist/runtime/render/product-listing.d.ts +11 -0
- package/dist/runtime/render/product-listing.js +243 -0
- package/dist/runtime/render/resolved.d.ts +47 -0
- package/dist/runtime/render/resolved.js +80 -0
- package/dist/runtime/render/section-actions.d.ts +67 -0
- package/dist/runtime/render/section-actions.js +205 -0
- package/dist/runtime/render/starter.d.ts +11 -0
- package/dist/runtime/render/starter.js +96 -0
- package/dist/runtime/seo/head.d.ts +115 -0
- package/dist/runtime/seo/head.js +281 -0
- package/dist/runtime/seo/structured-data.d.ts +83 -0
- package/dist/runtime/seo/structured-data.js +252 -0
- package/dist/runtime/shell/PageShell.d.ts +18 -0
- package/dist/runtime/shell/PageShell.js +118 -0
- package/dist/runtime/shell/RuntimeBridge.d.ts +18 -0
- package/dist/runtime/shell/RuntimeBridge.js +124 -0
- package/dist/runtime/shell/overlay-state.d.ts +31 -0
- package/dist/runtime/shell/overlay-state.js +59 -0
- package/dist/runtime/shell/preview-mode.d.ts +2 -0
- package/dist/runtime/shell/preview-mode.js +11 -0
- package/dist/runtime/shell/spa-router.d.ts +14 -0
- package/dist/runtime/shell/spa-router.js +76 -0
- package/dist/runtime/shell/url-redirects.d.ts +6 -0
- package/dist/runtime/shell/url-redirects.js +37 -0
- package/dist/runtime/slots.d.ts +74 -0
- package/dist/runtime/slots.js +16 -0
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.js +40 -0
- package/dist/sdk/app-block.d.ts +29 -0
- package/dist/sdk/app-block.js +22 -0
- package/dist/sdk/font-hooks.d.ts +7 -0
- package/dist/sdk/font-hooks.js +21 -0
- package/dist/sdk/fonts.d.ts +144 -0
- package/dist/sdk/fonts.js +241 -0
- package/dist/sdk/index.d.ts +32 -0
- package/dist/sdk/index.js +36 -0
- package/dist/sdk/motion-hooks.d.ts +23 -0
- package/dist/sdk/motion-hooks.js +46 -0
- package/dist/sdk/motion.d.ts +78 -0
- package/dist/sdk/motion.js +292 -0
- package/dist/sdk/referrals.d.ts +62 -0
- package/dist/sdk/referrals.js +20 -0
- package/dist/sdk/rewards.d.ts +85 -0
- package/dist/sdk/rewards.js +29 -0
- package/dist/sdk/runtime-context.d.ts +230 -0
- package/dist/sdk/runtime-context.js +73 -0
- package/dist/sdk/schema.d.ts +249 -0
- package/dist/sdk/schema.js +168 -0
- package/dist/sdk/server-render.d.ts +8 -0
- package/dist/sdk/server-render.js +12 -0
- package/dist/sdk/store-lookup.d.ts +32 -0
- package/dist/sdk/store-lookup.js +48 -0
- package/dist/sdk/store.d.ts +164 -0
- package/dist/sdk/store.js +5 -0
- package/dist/sdk/sx.d.ts +45 -0
- package/dist/sdk/sx.js +117 -0
- package/dist/sdk/theme.d.ts +212 -0
- package/dist/sdk/theme.js +27 -0
- package/dist/sdk/types.d.ts +789 -0
- package/dist/sdk/types.js +7 -0
- package/dist/server.d.ts +112 -0
- package/dist/server.js +589 -0
- package/dist/vite-chunks.d.ts +10 -0
- package/dist/vite-chunks.js +44 -0
- package/docs/headless-api.md +250 -0
- package/package.json +72 -26
- package/dist/index.js.map +0 -1
- package/dist/ssg-BZ5FYTw7.js +0 -1802
- package/dist/ssg-BZ5FYTw7.js.map +0 -1
- package/dist/ssg.js +0 -8
- package/dist/ssg.js.map +0 -1
- package/dist/types/cart.d.ts +0 -86
- package/dist/types/data.d.ts +0 -357
- package/dist/types/dynamic-source.d.ts +0 -84
- package/dist/types/editor.d.ts +0 -5
- package/dist/types/index.d.ts +0 -20
- package/dist/types/preview-bridge.d.ts +0 -9
- package/dist/types/storefront.d.ts +0 -333
- package/dist/types/types.d.ts +0 -44
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DataApi } from '../runtime/kit/data.js';
|
|
2
|
+
import type { PageData } from './page-data.js';
|
|
3
|
+
import type { AbiRemote } from './wire.js';
|
|
4
|
+
export declare const SEARCH_SORTS: readonly ["relevance", ...string[]];
|
|
5
|
+
export declare function searchOrder(sort: string | null | undefined): {
|
|
6
|
+
sortKey: 'PRICE' | 'TITLE' | 'CREATED_AT';
|
|
7
|
+
reverse: boolean;
|
|
8
|
+
} | null;
|
|
9
|
+
/** The resource-cache key of a search (platform/runtime/data/StoreProvider.tsx keys its loads the same way). */
|
|
10
|
+
export declare const searchKey: (query: string, sort?: string | null) => string;
|
|
11
|
+
type StoreLocations = Awaited<ReturnType<NonNullable<DataApi['locations']>>>;
|
|
12
|
+
/** rev 2.34 `Shop.locations` (converted by `convert.shop`) → `DataApi.locations`; a store without them answers `[]`. */
|
|
13
|
+
export declare function storeLocations(shop: PageData['shop'] | null | undefined): StoreLocations;
|
|
14
|
+
export declare function createDataApi(pd: PageData, remote: AbiRemote | null): DataApi;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import * as convert from './convert.js';
|
|
2
|
+
function decode(handle) {
|
|
3
|
+
if (!handle.includes('%'))
|
|
4
|
+
return handle;
|
|
5
|
+
try {
|
|
6
|
+
return decodeURIComponent(handle);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return handle;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function predictive(r) {
|
|
13
|
+
return {
|
|
14
|
+
queries: [...r.queries],
|
|
15
|
+
products: r.products.map((p) => ({
|
|
16
|
+
handle: p.handle,
|
|
17
|
+
title: p.title,
|
|
18
|
+
price: p.priceRange.minVariantPrice,
|
|
19
|
+
featuredImage: convert.image(p.featuredImage),
|
|
20
|
+
})),
|
|
21
|
+
collections: r.collections.map((c) => ({ handle: c.handle, title: c.title, image: null })),
|
|
22
|
+
pages: [],
|
|
23
|
+
articles: [],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Nova's search sort ids (the `sort` URL param) → the ABI `catalog.search` order. Relevance (absent) is the default. */
|
|
27
|
+
const SEARCH_ORDER = {
|
|
28
|
+
'price-asc': { sortKey: 'PRICE', reverse: false },
|
|
29
|
+
'price-desc': { sortKey: 'PRICE', reverse: true },
|
|
30
|
+
'title-asc': { sortKey: 'TITLE', reverse: false },
|
|
31
|
+
'created-desc': { sortKey: 'CREATED_AT', reverse: true },
|
|
32
|
+
};
|
|
33
|
+
export const SEARCH_SORTS = ['relevance', ...Object.keys(SEARCH_ORDER)];
|
|
34
|
+
export function searchOrder(sort) {
|
|
35
|
+
return sort && Object.prototype.hasOwnProperty.call(SEARCH_ORDER, sort) ? SEARCH_ORDER[sort] : null;
|
|
36
|
+
}
|
|
37
|
+
/** The resource-cache key of a search (platform/runtime/data/StoreProvider.tsx keys its loads the same way). */
|
|
38
|
+
export const searchKey = (query, sort) => (searchOrder(sort) ? `search:${query}|${sort}` : `search:${query}`);
|
|
39
|
+
/** rev 2.34 `Shop.locations` (converted by `convert.shop`) → `DataApi.locations`; a store without them answers `[]`. */
|
|
40
|
+
export function storeLocations(shop) {
|
|
41
|
+
return (shop?.locations ?? []).map((l) => ({
|
|
42
|
+
id: l.id,
|
|
43
|
+
name: l.name,
|
|
44
|
+
code: null,
|
|
45
|
+
address: {
|
|
46
|
+
country: l.address.country ?? l.address.countryCode ?? null,
|
|
47
|
+
address: [l.address.address1, l.address.address2].filter(Boolean).join(', ') || null,
|
|
48
|
+
city: l.address.city ?? null,
|
|
49
|
+
province: l.address.province ?? null,
|
|
50
|
+
postalCode: l.address.zip ?? null,
|
|
51
|
+
phone: l.phone ?? null,
|
|
52
|
+
},
|
|
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 })) } : {}),
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
export function createDataApi(pd, remote) {
|
|
61
|
+
const productBy = (h) => pd.products[h] ?? pd.products[decode(h)] ?? null;
|
|
62
|
+
const collectionBy = (h) => pd.collections[h] ?? pd.collections[decode(h)] ?? null;
|
|
63
|
+
const menuBy = (h) => pd.menus[h] ?? pd.menus[decode(h)] ?? null;
|
|
64
|
+
const allCollections = () => pd.collectionList ?? Object.values(pd.collections);
|
|
65
|
+
// The page's resource cache (platform/runtime/data/StoreProvider.tsx) starts from what the server
|
|
66
|
+
// loaded, keyed the way that cache keys its loads — so the first render (server and hydrating
|
|
67
|
+
// browser alike) shows it, and the browser does not ask the platform again for the same records.
|
|
68
|
+
const preloaded = {};
|
|
69
|
+
for (const [h, p] of Object.entries(pd.products))
|
|
70
|
+
if (p.variants?.length)
|
|
71
|
+
preloaded[`product:${h}`] = p;
|
|
72
|
+
for (const [h, c] of Object.entries(pd.collections))
|
|
73
|
+
preloaded[`collection-products:${h}`] = { products: c.products, filters: c.filters ?? [] };
|
|
74
|
+
for (const [h, b] of Object.entries(pd.blogs))
|
|
75
|
+
preloaded[`blog:${h}`] = b;
|
|
76
|
+
for (const [k, a] of Object.entries(pd.articles))
|
|
77
|
+
preloaded[`article:${k}`] = a;
|
|
78
|
+
if (pd.search)
|
|
79
|
+
preloaded[searchKey(pd.search.query, pd.search.sort)] = pd.search.result;
|
|
80
|
+
// rev 2.34: the shop's pickup locations, in DataApi.locations' shape; the store-locator reads them on first render
|
|
81
|
+
const locations = storeLocations(pd.shop);
|
|
82
|
+
preloaded.locations = locations;
|
|
83
|
+
for (const [h, list] of Object.entries(pd.recommendations)) {
|
|
84
|
+
const id = pd.products[h]?.id;
|
|
85
|
+
if (id)
|
|
86
|
+
preloaded[`recommendations:${id}`] = list;
|
|
87
|
+
}
|
|
88
|
+
const api = {
|
|
89
|
+
preloaded,
|
|
90
|
+
collectionByHandle: collectionBy,
|
|
91
|
+
allCollections,
|
|
92
|
+
productByHandle: productBy,
|
|
93
|
+
pageByHandle: (h) => pd.pages[h] ?? pd.pages[decode(h)] ?? null,
|
|
94
|
+
localization: pd.localization,
|
|
95
|
+
shop: pd.shop,
|
|
96
|
+
menu: menuBy,
|
|
97
|
+
locations: async () => locations,
|
|
98
|
+
...(pd.policyHandle ? { policyHandle: pd.policyHandle } : {}),
|
|
99
|
+
getSnapshot: () => pd,
|
|
100
|
+
blogSync: (h) => pd.blogs[h] ?? pd.blogs[decode(h)] ?? null,
|
|
101
|
+
articleSync: (b, h) => pd.articles[`${b}/${h}`] ?? pd.articles[`${decode(b)}/${decode(h)}`] ?? null,
|
|
102
|
+
searchSync: (q, sort) => (pd.search && pd.search.query.trim().toLowerCase() === q.trim().toLowerCase() && (pd.search.sort ?? '') === (searchOrder(sort) ? (sort ?? '') : '') ? pd.search.result : null),
|
|
103
|
+
recommendationsSync: (h) => pd.recommendations[h] ?? null,
|
|
104
|
+
routeMissing: pd.routeMissing === true,
|
|
105
|
+
...(pd.metaobject !== undefined ? { routeMetaobject: pd.metaobject } : {}),
|
|
106
|
+
...(pd.signedIn !== null ? { signedIn: pd.signedIn } : {}),
|
|
107
|
+
...(pd.accountUrls ? { accountUrl: (path) => pd.accountUrls[path ?? 'profile'] } : {}),
|
|
108
|
+
...(pd.formEndpoint ? { formEndpoint: pd.formEndpoint } : {}),
|
|
109
|
+
...(pd.formResult ? { formResult: pd.formResult } : {}),
|
|
110
|
+
...(pd.routeParams ? { routeParams: pd.routeParams } : {}),
|
|
111
|
+
fetchMenu: async (handle) => {
|
|
112
|
+
const known = menuBy(handle);
|
|
113
|
+
if (known || !remote)
|
|
114
|
+
return known;
|
|
115
|
+
const list = (await remote.data('shop.menus', [[handle]]));
|
|
116
|
+
const m = list.find((x) => x.handle === handle);
|
|
117
|
+
return m ? convert.menu(m) : null;
|
|
118
|
+
},
|
|
119
|
+
// The cookie banner links the privacy policy only when the store has published it; a page other
|
|
120
|
+
// than that policy's own does not load it, so the browser asks once, when the banner shows.
|
|
121
|
+
fetchPolicy: async (handle) => {
|
|
122
|
+
const known = Object.values(pd.shop.policies ?? {}).find((p) => p?.handle === handle) ?? null;
|
|
123
|
+
if (known || !remote)
|
|
124
|
+
return known;
|
|
125
|
+
const p = (await remote.data('content.policy', [handle]));
|
|
126
|
+
return p ? convert.policy(p) : null;
|
|
127
|
+
},
|
|
128
|
+
fetchProduct: async (handle) => {
|
|
129
|
+
const known = productBy(handle);
|
|
130
|
+
// A card copy carries no variants; the product page needs them.
|
|
131
|
+
if ((known && known.variants?.length) || !remote)
|
|
132
|
+
return known;
|
|
133
|
+
// `collections` (ABI opt-in): the product page's breadcrumb names the product's collection. `reviewsFirst`
|
|
134
|
+
// (storefront-query rev 2.38): its newest published reviews; a region from before that option refuses the
|
|
135
|
+
// unknown member, so the same read is sent once more without it.
|
|
136
|
+
let p;
|
|
137
|
+
try {
|
|
138
|
+
p = (await remote.data('catalog.product', [handle, { collections: true, reviewsFirst: convert.REVIEWS_FIRST }]));
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
p = (await remote.data('catalog.product', [handle, { collections: true }]));
|
|
142
|
+
}
|
|
143
|
+
return p ? convert.product(p) : known;
|
|
144
|
+
},
|
|
145
|
+
listingSeed: (handle, filters) => {
|
|
146
|
+
const seed = pd.listingSeed;
|
|
147
|
+
return seed && (seed.handle === handle || seed.handle === decode(handle)) && seed.key === JSON.stringify(filters) ? { products: seed.products, pageInfo: seed.pageInfo } : null;
|
|
148
|
+
},
|
|
149
|
+
collectionProducts: async (handle, opts) => {
|
|
150
|
+
const known = collectionBy(handle);
|
|
151
|
+
if (!remote) {
|
|
152
|
+
return known
|
|
153
|
+
? { products: known.products, filters: [], pageInfo: { hasNextPage: false, hasPreviousPage: false, startCursor: null, endCursor: null } }
|
|
154
|
+
: { products: [], filters: [], pageInfo: { hasNextPage: false, hasPreviousPage: false, startCursor: null, endCursor: null }, missing: true };
|
|
155
|
+
}
|
|
156
|
+
const sortKey = opts?.sortKey === 'COLLECTION_DEFAULT' ? undefined : opts?.sortKey;
|
|
157
|
+
const filters = convert.abiFilters(opts?.filters);
|
|
158
|
+
// The first unfiltered page carries the facets (ABI opt-in); later pages and filtered pages reuse them.
|
|
159
|
+
const facets = !opts?.after && filters.length === 0;
|
|
160
|
+
const c = (await remote.data('catalog.collection', [handle, { productsFirst: opts?.first ?? 24, ...(opts?.after ? { after: opts.after } : {}), ...(sortKey ? { sortKey } : {}), ...(opts?.reverse ? { reverse: true } : {}), ...(filters.length ? { filters } : {}), ...(facets ? { facets: true } : {}) }]));
|
|
161
|
+
if (!c)
|
|
162
|
+
return { products: [], filters: [], pageInfo: { hasNextPage: false, hasPreviousPage: false, startCursor: null, endCursor: null }, missing: true };
|
|
163
|
+
return {
|
|
164
|
+
products: c.products.nodes.map(convert.product),
|
|
165
|
+
filters: convert.filters(c.filters),
|
|
166
|
+
pageInfo: { hasNextPage: c.products.pageInfo.hasNextPage, hasPreviousPage: Boolean(opts?.after), startCursor: opts?.after ?? null, endCursor: c.products.pageInfo.endCursor ?? null },
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
blogByHandle: async (handle) => {
|
|
170
|
+
const known = pd.blogs[handle] ?? pd.blogs[decode(handle)] ?? null;
|
|
171
|
+
if (known || !remote)
|
|
172
|
+
return known;
|
|
173
|
+
const b = (await remote.data('content.blog', [handle]));
|
|
174
|
+
return b ? convert.blog(b) : null;
|
|
175
|
+
},
|
|
176
|
+
articleByHandle: async (blogHandle, handle) => {
|
|
177
|
+
const known = pd.articles[`${blogHandle}/${handle}`] ?? pd.articles[`${decode(blogHandle)}/${decode(handle)}`] ?? null;
|
|
178
|
+
if (known || !remote)
|
|
179
|
+
return known;
|
|
180
|
+
const a = (await remote.data('content.article', [blogHandle, handle]));
|
|
181
|
+
return a ? { ...convert.article(a), blogHandle } : null;
|
|
182
|
+
},
|
|
183
|
+
...(remote
|
|
184
|
+
? {
|
|
185
|
+
consent: {
|
|
186
|
+
get: async () => (await remote.data('consent.get', [])),
|
|
187
|
+
set: async (input) => {
|
|
188
|
+
const env = await remote.action('consent.set', [input]);
|
|
189
|
+
if (!env.ok)
|
|
190
|
+
throw new Error(env.error.code);
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
search: async (query, opts) => {
|
|
194
|
+
const types = (opts?.types ?? ['PRODUCT', 'PAGE', 'ARTICLE']).map((t) => t.toLowerCase());
|
|
195
|
+
const order = searchOrder(opts?.sort);
|
|
196
|
+
const r = (await remote.data('catalog.search', [{ query, ...(opts?.first ? { first: opts.first } : {}), ...(opts?.after ? { after: opts.after } : {}), types, ...(order ? { sortKey: order.sortKey, ...(order.reverse ? { reverse: true } : {}) } : {}) }]));
|
|
197
|
+
return convert.searchResults(r);
|
|
198
|
+
},
|
|
199
|
+
predictiveSearch: async (query, opts) => predictive((await remote.data('catalog.predictive', [query, opts?.limit ?? 4]))),
|
|
200
|
+
productRecommendations: async (productId) => {
|
|
201
|
+
const handle = Object.values(pd.products).find((p) => p.id === productId)?.handle;
|
|
202
|
+
if (!handle)
|
|
203
|
+
return [];
|
|
204
|
+
const list = (await remote.data('catalog.recommendations', [handle, 'related', 4]));
|
|
205
|
+
return list.map(convert.product);
|
|
206
|
+
},
|
|
207
|
+
}
|
|
208
|
+
: pd.search
|
|
209
|
+
? { search: async () => pd.search.result }
|
|
210
|
+
: {}),
|
|
211
|
+
};
|
|
212
|
+
return api;
|
|
213
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 8785 JSON Canonicalization for JSON values (null, boolean, string, finite number, array,
|
|
3
|
+
* plain object). The browser wire encodes `/_tq/data` arguments as JCS so one call has one cache
|
|
4
|
+
* key (theme-abi-v2.md §4). Same algorithm as scripts/abi/jcs.mjs, which writes manifest.json.
|
|
5
|
+
*/
|
|
6
|
+
export declare function canonicalize(value: unknown): string;
|
package/dist/abi/jcs.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 8785 JSON Canonicalization for JSON values (null, boolean, string, finite number, array,
|
|
3
|
+
* plain object). The browser wire encodes `/_tq/data` arguments as JCS so one call has one cache
|
|
4
|
+
* key (theme-abi-v2.md §4). Same algorithm as scripts/abi/jcs.mjs, which writes manifest.json.
|
|
5
|
+
*/
|
|
6
|
+
export function canonicalize(value) {
|
|
7
|
+
if (value === null)
|
|
8
|
+
return 'null';
|
|
9
|
+
switch (typeof value) {
|
|
10
|
+
case 'boolean':
|
|
11
|
+
return value ? 'true' : 'false';
|
|
12
|
+
case 'number':
|
|
13
|
+
if (!Number.isFinite(value))
|
|
14
|
+
throw new TypeError('JCS: non-finite number');
|
|
15
|
+
return JSON.stringify(value);
|
|
16
|
+
case 'string':
|
|
17
|
+
return JSON.stringify(value);
|
|
18
|
+
case 'object': {
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return `[${value.map(canonicalize).join(',')}]`;
|
|
21
|
+
const o = value;
|
|
22
|
+
const keys = Object.keys(o).filter((k) => o[k] !== undefined).sort();
|
|
23
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalize(o[k])}`).join(',')}}`;
|
|
24
|
+
}
|
|
25
|
+
default:
|
|
26
|
+
throw new TypeError(`JCS: unsupported ${typeof value}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** The uuid a market id names (`gid://tanqory/Market/<uuid>`, optionally `:<currency>`), lower case, or null. */
|
|
2
|
+
export declare const marketKeyOf: (market: string | null | undefined) => string | null;
|
|
3
|
+
export declare function labelsOf(strings: Readonly<Record<string, unknown>> | null | undefined, market?: string | null): Record<string, string>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The merchant's words for the theme's own strings (board 35 #41): the `l.<string key>` entries of the page language's
|
|
3
|
+
* `ctx.data.localization.strings` document (the store's translations of the theme's "Default theme content",
|
|
4
|
+
* Settings > Languages > Translate). The platform writes each value as `<12 hex>:<text>` (the hash of the English it was
|
|
5
|
+
* translated from, which the edge checks for theme content); a theme string's English rarely changes meaning, so the
|
|
6
|
+
* text is used as it is. Empty texts are left out: an empty translation never blanks a word.
|
|
7
|
+
*
|
|
8
|
+
* A market's own wording (Translate & Adapt, "Adapt" for one market) comes as `m.<market uuid>.l.<string key>` and wins
|
|
9
|
+
* over the language's for a page in that market (`ctx.locale.market`); a key it lacks keeps the language's word.
|
|
10
|
+
*/
|
|
11
|
+
const PREFIX = 'l.';
|
|
12
|
+
const HASHED = /^[0-9a-f]{12}:/;
|
|
13
|
+
const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
14
|
+
/** The uuid a market id names (`gid://tanqory/Market/<uuid>`, optionally `:<currency>`), lower case, or null. */
|
|
15
|
+
export const marketKeyOf = (market) => (typeof market === 'string' ? (market.match(UUID)?.[0]?.toLowerCase() ?? null) : null);
|
|
16
|
+
export function labelsOf(strings, market) {
|
|
17
|
+
const out = {};
|
|
18
|
+
if (!strings || typeof strings !== 'object')
|
|
19
|
+
return out;
|
|
20
|
+
const take = (prefix) => {
|
|
21
|
+
for (const [k, v] of Object.entries(strings)) {
|
|
22
|
+
if (!k.startsWith(prefix) || typeof v !== 'string')
|
|
23
|
+
continue;
|
|
24
|
+
const text = HASHED.test(v) ? v.slice(13) : v;
|
|
25
|
+
if (text.trim() !== '')
|
|
26
|
+
out[k.slice(prefix.length)] = text;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
take(PREFIX);
|
|
30
|
+
const m = marketKeyOf(market);
|
|
31
|
+
if (m)
|
|
32
|
+
take(`m.${m}.${PREFIX}`);
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything one page render reads, as ONE serialisable record.
|
|
3
|
+
*
|
|
4
|
+
* The server fills it from `ctx.data` (theme-abi-v2.md §3) and embeds it in the page; the browser
|
|
5
|
+
* rebuilds the identical `DataApi` from the embedded copy, so the hydrated tree starts from the
|
|
6
|
+
* bytes the server rendered. Nothing here is cached across renders: a `PageData` is created inside
|
|
7
|
+
* `render()` and dropped with it (§1 multi-tenant isolates, suite 9).
|
|
8
|
+
*
|
|
9
|
+
* Data plan (§3 counting, §8 limits — 4 calls / 8 sub-requests / 2 rounds hard; budget 3 / 3 / 1, DECISIONS row 272):
|
|
10
|
+
* round 1 snapshot({ resolve: 'all' }) — shop, menus, the route's resource, and every
|
|
11
|
+
* `resolve: true` setting the platform resolves into `refs`
|
|
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),
|
|
16
|
+
* `catalog.collections()` when a section lists every collection, then one
|
|
17
|
+
* `catalog.collection` / `catalog.product` per unresolved ref — never past the hard
|
|
18
|
+
* call limit. A ref the budget cannot cover renders as "not found", the section's own
|
|
19
|
+
* empty state; it is logged, never retried.
|
|
20
|
+
*/
|
|
21
|
+
import type { RenderContext, Cart as AbiCart, Policy as AbiPolicy } from '@tanqory/theme-abi';
|
|
22
|
+
import type { GiftCardBalance } from '../sdk/types.js';
|
|
23
|
+
import type { ContentNode, SectionDef } from '../runtime/kit/types.js';
|
|
24
|
+
import type { Collection, Localization, MetaobjectPage, Page, Product } from '../runtime/kit/data.js';
|
|
25
|
+
import type { Article, Blog, Menu, SearchResults, Shop } from '../runtime/kit/storefront.js';
|
|
26
|
+
import { type ResourceContextValue } from '../runtime/kit/dynamic-source.js';
|
|
27
|
+
/**
|
|
28
|
+
* The listing state of this request (`?sort=` and `?filter.*=`, platform/runtime/render/listing-query.ts):
|
|
29
|
+
* only on the collection route. `sort` may also arrive as the ABI's query-derived route param.
|
|
30
|
+
* Cache-safe for the same reason as the search query: a request with a query string is neither served
|
|
31
|
+
* from nor stored in the shared cache (§5.1).
|
|
32
|
+
*/
|
|
33
|
+
export declare function listingQueryOfRequest(ctx: Pick<RenderContext, 'route' | 'request'>): string;
|
|
34
|
+
/**
|
|
35
|
+
* The search query of this request: the `q` route param (theme-abi-v2.md §2.1), else — for a
|
|
36
|
+
* gateway that does not forward it yet — the `q` of the request's own query string. Only on the
|
|
37
|
+
* search route. Shopper-typed text: every place that prints it escapes it (React does).
|
|
38
|
+
* Reading the raw query is cache-safe: a request with any query string is neither served from nor
|
|
39
|
+
* stored in the shared cache (§5.1).
|
|
40
|
+
*/
|
|
41
|
+
export declare function searchQueryOf(ctx: Pick<RenderContext, 'route' | 'request'>): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* The search page's sort (`?sort=`, the ABI's query-derived `sort` route param on the search kind):
|
|
44
|
+
* a sort id lib/abi/data-api.ts `searchOrder` knows, else null (relevance). Only on the search route.
|
|
45
|
+
*/
|
|
46
|
+
export declare function searchSortOf(ctx: Pick<RenderContext, 'route' | 'request'>): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* The variant a product URL names (`/products/<handle>?variant=<id>`): a shared link, or checkout's way
|
|
49
|
+
* back to the product. Only on the product route; the section opens on it only when it is a variant
|
|
50
|
+
* of that product (ProductDetails ignores any other id). Read from the request's own query string:
|
|
51
|
+
* a request with a query is never served from or stored in the shared cache (§5.1).
|
|
52
|
+
*/
|
|
53
|
+
export declare function variantOf(ctx: Pick<RenderContext, 'route' | 'request'>): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Why a cart permalink (`/cart/<variant>:<qty>`) landed on the cart page: the router's
|
|
56
|
+
* `?cart_link=` reason (apps/storefront/router/cart-permalink.mjs), else null. Only on the cart
|
|
57
|
+
* route, and only a reason the router sends. The cart route is a private response already (§5).
|
|
58
|
+
*/
|
|
59
|
+
export declare function cartLinkOf(ctx: Pick<RenderContext, 'route' | 'request'>): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* The route params the page renders with: the route's own, plus `q` (`searchQueryOf`), its `sort`
|
|
62
|
+
* (`searchSortOf`) and `cart_link` (`cartLinkOf`) when only the request's query string has them.
|
|
63
|
+
* They travel in the page state, so the hydrating browser builds the same location.
|
|
64
|
+
*/
|
|
65
|
+
export declare function pageParamsOf(ctx: Pick<RenderContext, 'route' | 'request'>, searchQuery: string | null, searchSort?: string | null): Readonly<Record<string, string>>;
|
|
66
|
+
export interface PageData {
|
|
67
|
+
/** `ctx.route.kind` this record was loaded for. */
|
|
68
|
+
route: string;
|
|
69
|
+
shop: Shop;
|
|
70
|
+
menus: Record<string, Menu>;
|
|
71
|
+
products: Record<string, Product>;
|
|
72
|
+
collections: Record<string, Collection>;
|
|
73
|
+
/** Every collection, when a section on this page lists them; null when not loaded. */
|
|
74
|
+
collectionList: Collection[] | null;
|
|
75
|
+
pages: Record<string, Page>;
|
|
76
|
+
blogs: Record<string, Blog>;
|
|
77
|
+
/** key `${blogHandle}/${articleHandle}` */
|
|
78
|
+
articles: Record<string, Article>;
|
|
79
|
+
/** On a metaobject page (route kind `metaobject`): the route's entry, null when the platform has none. */
|
|
80
|
+
metaobject?: MetaobjectPage | null;
|
|
81
|
+
/** `sort`: the non-relevance sort id the result was loaded with (absent = relevance). */
|
|
82
|
+
search: {
|
|
83
|
+
query: string;
|
|
84
|
+
sort?: string;
|
|
85
|
+
result: SearchResults;
|
|
86
|
+
} | null;
|
|
87
|
+
/**
|
|
88
|
+
* The first filtered page of the route's collection, when the request's URL names a filter the
|
|
89
|
+
* server could answer in one request (a shared filtered link). `key` is that request's filter objects
|
|
90
|
+
* as JSON — what the listing asks `listingSeed` for. Null otherwise.
|
|
91
|
+
*/
|
|
92
|
+
listingSeed: {
|
|
93
|
+
handle: string;
|
|
94
|
+
key: string;
|
|
95
|
+
products: Product[];
|
|
96
|
+
pageInfo: {
|
|
97
|
+
hasNextPage: boolean;
|
|
98
|
+
endCursor: string | null;
|
|
99
|
+
};
|
|
100
|
+
} | null;
|
|
101
|
+
/** product handle → recommended products, when the page shows recommendations. */
|
|
102
|
+
recommendations: Record<string, Product[]>;
|
|
103
|
+
policyHandle: string | null;
|
|
104
|
+
/** Account BFF URLs for the account slot (§4), only on the customer route. No customer data. */
|
|
105
|
+
accountUrls: {
|
|
106
|
+
orders: string;
|
|
107
|
+
addresses: string;
|
|
108
|
+
profile: string;
|
|
109
|
+
} | null;
|
|
110
|
+
/** The shopper's cart — only on the cart route (forces a private response). */
|
|
111
|
+
cart: AbiCart | null;
|
|
112
|
+
localization: Localization;
|
|
113
|
+
/** `request.isSignedIn` when the header shows the account menu (varied on), else null. */
|
|
114
|
+
signedIn: boolean | null;
|
|
115
|
+
/** Resource handles the plan wanted but could not load inside the limits. */
|
|
116
|
+
unresolved: string[];
|
|
117
|
+
/**
|
|
118
|
+
* The route addresses a resource by handle and the platform has no such resource (product,
|
|
119
|
+
* collection, page, blog), or no published policy for a policy route. The page answers 404 and the section renders its not-found state
|
|
120
|
+
* from this same flag, so the server and the hydrating browser agree.
|
|
121
|
+
*/
|
|
122
|
+
routeMissing: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* The platform's form endpoint on this host (theme-abi §1 native forms): the route's own path, posted
|
|
125
|
+
* `<form data-tq-form="<id>" method="post">`. Set by `render()`; absent on a page loaded without one.
|
|
126
|
+
*/
|
|
127
|
+
formEndpoint?: string | null;
|
|
128
|
+
/** The outcome of the native form POST this render answers (`render()`), else null. */
|
|
129
|
+
formResult?: NativeFormResult | null;
|
|
130
|
+
/** The route's captured segments (`ctx.route.params`): a manifest custom route's `:id`, the ABI's query-derived params. */
|
|
131
|
+
routeParams?: Readonly<Record<string, string>>;
|
|
132
|
+
}
|
|
133
|
+
/** What a declared form's POST came to: `ctx.actions.form.submit`'s answer, or why it never ran. */
|
|
134
|
+
export type NativeFormStatus = 'ok' | 'invalid' | 'rate_limited' | 'unavailable' | 'expired';
|
|
135
|
+
export interface NativeFormResult {
|
|
136
|
+
formId: string;
|
|
137
|
+
status: NativeFormStatus;
|
|
138
|
+
/** The address the shopper typed, kept on a failure so they need not retype it. */
|
|
139
|
+
email?: string;
|
|
140
|
+
/**
|
|
141
|
+
* NEW-MKT-4: on `ok`, the discount code the platform gave THIS shopper for signing up through a merchant pop-up
|
|
142
|
+
* (form `popup`). Not in the Theme ABI `form.submit` result yet (storefront-edge passes it along); absent otherwise.
|
|
143
|
+
*/
|
|
144
|
+
discountCode?: string;
|
|
145
|
+
/**
|
|
146
|
+
* On `ok`: the merchant has double opt-in on, so the sign-up waits for the shopper to confirm by email; the theme
|
|
147
|
+
* says "check your email" rather than "thanks for subscribing" (storefront-edge passes it along; absent otherwise).
|
|
148
|
+
*/
|
|
149
|
+
pendingConfirmation?: true;
|
|
150
|
+
/**
|
|
151
|
+
* NEW-PROD-12: on `ok` of the `gift-card-balance` form, the card's masked balance view as the platform answered it
|
|
152
|
+
* (storefront-edge `giftCardBalanceAnswer`); absent otherwise. Shape-checked by `giftCardBalanceOf`.
|
|
153
|
+
*/
|
|
154
|
+
giftCard?: GiftCardBalance;
|
|
155
|
+
}
|
|
156
|
+
export type Need = {
|
|
157
|
+
kind: 'collection' | 'product' | 'menu' | 'page' | 'blog';
|
|
158
|
+
handle: string;
|
|
159
|
+
ref: string;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Data-plan requests that do not depend on section types (`loadPageData` `plan`). Each flag only adds a read the
|
|
163
|
+
* section conventions would also make (`pageNeeds`): the market list, the sign-in state, the route product's
|
|
164
|
+
* recommendations, the store's collection list.
|
|
165
|
+
*/
|
|
166
|
+
export interface PagePlanOptions {
|
|
167
|
+
/** Read the shopper's country and list the store's countries (the page then varies on `x-tq-country`). */
|
|
168
|
+
localization?: boolean;
|
|
169
|
+
/** Read `request.isSignedIn` (the page then varies on it). */
|
|
170
|
+
account?: boolean;
|
|
171
|
+
/** On a product page, load the product's recommendations in the server render. */
|
|
172
|
+
recommendations?: boolean;
|
|
173
|
+
/** Load the store's collection list. */
|
|
174
|
+
collections?: boolean;
|
|
175
|
+
/** Data calls the caller makes beside the plan in the same render; the plan stays inside the limit with them. */
|
|
176
|
+
reservedCalls?: number;
|
|
177
|
+
}
|
|
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
|
+
*/
|
|
184
|
+
export declare function pageNeeds(nodes: readonly ContentNode[], defs: (type: string) => SectionDef | undefined): {
|
|
185
|
+
needs: Need[];
|
|
186
|
+
listsCollections: boolean;
|
|
187
|
+
showsLocale: boolean;
|
|
188
|
+
showsAccount: boolean;
|
|
189
|
+
showsRecommendations: boolean;
|
|
190
|
+
headerMenus: string[];
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Picker settings connected to a dynamic source (E1 slice 3): a product, collection or page setting bound to a
|
|
194
|
+
* metafield of the route's resource or the shop (`{ '@source': 'product.metafields.custom.related' }`) names the
|
|
195
|
+
* handle that metafield holds (the projector writes a reference as `{id, handle}`). Those handles are needs like a
|
|
196
|
+
* saved handle, fetched in round 2. A bound value that resolves to nothing is no need: the setting's default renders.
|
|
197
|
+
*/
|
|
198
|
+
export declare function boundResourceNeeds(nodes: readonly ContentNode[], defs: (type: string) => SectionDef | undefined, sources: ResourceContextValue): Need[];
|
|
199
|
+
/**
|
|
200
|
+
* `ctx.locale` → Nova's Localization. `locale.country` is a personalising input (§2): it is read
|
|
201
|
+
* only when the page shows the country switcher, and the caller hints `vary: ['x-tq-country']`
|
|
202
|
+
* for exactly that case. Otherwise the country stays blank and nothing on the page depends on it.
|
|
203
|
+
*/
|
|
204
|
+
export declare function localizationOf(ctx: RenderContext, shipsTo: readonly string[], readCountry: boolean): Localization;
|
|
205
|
+
/** `ctx.locale.displayNames` (theme-abi Locale-2, optional), read defensively: only string names; null when absent. */
|
|
206
|
+
export declare function displayNamesOf(ctx: Pick<RenderContext, 'locale'>): {
|
|
207
|
+
countries: Record<string, string>;
|
|
208
|
+
languages: Record<string, {
|
|
209
|
+
name: string;
|
|
210
|
+
endonymName: string;
|
|
211
|
+
}>;
|
|
212
|
+
} | null;
|
|
213
|
+
/** One active market as the platform names it (`ctx.locale.markets`, an optional ABI field). */
|
|
214
|
+
export interface LocaleMarket {
|
|
215
|
+
id: string;
|
|
216
|
+
currency: string;
|
|
217
|
+
countries: readonly string[];
|
|
218
|
+
languages: readonly string[];
|
|
219
|
+
}
|
|
220
|
+
/** `ctx.locale.markets`, read defensively: only well-formed entries; [] when the platform sends none. */
|
|
221
|
+
export declare function marketsOf(ctx: Pick<RenderContext, 'locale'>): LocaleMarket[];
|
|
222
|
+
/** Load a page's data through `ctx.data`. */
|
|
223
|
+
export declare function loadPageData(ctx: RenderContext, nodes: readonly ContentNode[], defs: (type: string) => SectionDef | undefined,
|
|
224
|
+
/** Menu handles named by GLOBAL settings (header/footer menu pickers), not by a node. */
|
|
225
|
+
settingMenus?: readonly string[],
|
|
226
|
+
/**
|
|
227
|
+
* The search query this page renders (`searchQueryOf`). When the snapshot answered a different
|
|
228
|
+
* query — a gateway that does not forward `q` as a route param answers the empty one — the
|
|
229
|
+
* search is run once in round 2, so the server HTML holds the results the browser would show.
|
|
230
|
+
*/
|
|
231
|
+
searchQuery?: string | null,
|
|
232
|
+
/** The search sort of this request (`searchSortOf`); null = relevance. */
|
|
233
|
+
searchSort?: string | null,
|
|
234
|
+
/** The collection listing's URL state (`listingQueryOfRequest`); '' = none. */
|
|
235
|
+
listingQuery?: string,
|
|
236
|
+
/**
|
|
237
|
+
* What the theme asks the plan for regardless of its section types (`RenderOptions.storefront.plan`), and the
|
|
238
|
+
* data calls the caller makes beside this plan in round 1 (`reservedCalls`). Absent: the plan reads only the
|
|
239
|
+
* section conventions (`pageNeeds`), exactly as before.
|
|
240
|
+
*/
|
|
241
|
+
plan?: PagePlanOptions): Promise<PageData>;
|
|
242
|
+
/**
|
|
243
|
+
* The snapshot's entry of a metaobject page → the record dynamic sources read (`metaobject.<field>`). `routeHandle` is
|
|
244
|
+
* the platform's `route.handle`, `<definition url handle>/<entry handle>`: the definition's half names the page's URL.
|
|
245
|
+
* Exported for tests.
|
|
246
|
+
*/
|
|
247
|
+
export declare function metaobjectPageOf(m: {
|
|
248
|
+
handle?: unknown;
|
|
249
|
+
type?: unknown;
|
|
250
|
+
fields?: unknown;
|
|
251
|
+
seo?: unknown;
|
|
252
|
+
} | null | undefined, routeHandle: string | undefined): MetaobjectPage | null;
|
|
253
|
+
/** An unknown (or not yet published) resource on a resource route is a real 404. Exported for tests. */
|
|
254
|
+
export declare function routeMissingOf(route: RenderContext['route'], found: {
|
|
255
|
+
products: Record<string, unknown>;
|
|
256
|
+
collections: Record<string, unknown>;
|
|
257
|
+
pages: Record<string, unknown>;
|
|
258
|
+
blogs: Record<string, unknown>;
|
|
259
|
+
articles: Record<string, {
|
|
260
|
+
handle?: string;
|
|
261
|
+
}>;
|
|
262
|
+
policies: readonly AbiPolicy[];
|
|
263
|
+
metaobject?: MetaobjectPage | null;
|
|
264
|
+
}): boolean;
|