@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
package/dist/types/data.d.ts
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type StorefrontExtensions } from './storefront';
|
|
3
|
-
export interface Money {
|
|
4
|
-
amount: string;
|
|
5
|
-
currencyCode: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ProductOption {
|
|
8
|
-
name: string;
|
|
9
|
-
values: string[];
|
|
10
|
-
}
|
|
11
|
-
export interface ImageRef {
|
|
12
|
-
url: string;
|
|
13
|
-
altText?: string;
|
|
14
|
-
}
|
|
15
|
-
/** SEO snapshot (Product/Page/Article). */
|
|
16
|
-
export interface Seo {
|
|
17
|
-
title?: string | null;
|
|
18
|
-
description?: string | null;
|
|
19
|
-
}
|
|
20
|
-
/** Per-variant cart quantity bounds (wholesale / case-of-N). Storefront cart enforces these. */
|
|
21
|
-
export interface QuantityRule {
|
|
22
|
-
minimum: number;
|
|
23
|
-
maximum: number | null;
|
|
24
|
-
increment: number;
|
|
25
|
-
}
|
|
26
|
-
/** Per-unit pricing ("$2.50 / 100ml"). */
|
|
27
|
-
export interface UnitPriceMeasurement {
|
|
28
|
-
measuredType: string;
|
|
29
|
-
quantityValue: number;
|
|
30
|
-
quantityUnit: string;
|
|
31
|
-
referenceValue: number;
|
|
32
|
-
referenceUnit: string;
|
|
33
|
-
}
|
|
34
|
-
/** Pickup / in-store stock for one location. */
|
|
35
|
-
export interface StoreAvailability {
|
|
36
|
-
available: boolean;
|
|
37
|
-
quantityAvailable: number;
|
|
38
|
-
pickUpTime?: string | null;
|
|
39
|
-
location: {
|
|
40
|
-
id: string;
|
|
41
|
-
name: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export interface SellingPlanOption {
|
|
45
|
-
name: string;
|
|
46
|
-
value: string;
|
|
47
|
-
}
|
|
48
|
-
export interface SellingPlan {
|
|
49
|
-
id: string;
|
|
50
|
-
name: string;
|
|
51
|
-
description?: string | null;
|
|
52
|
-
recurringDeliveries: boolean;
|
|
53
|
-
options: SellingPlanOption[];
|
|
54
|
-
}
|
|
55
|
-
export interface SellingPlanGroup {
|
|
56
|
-
name: string;
|
|
57
|
-
appName?: string | null;
|
|
58
|
-
options: Array<{
|
|
59
|
-
name: string;
|
|
60
|
-
values: string[];
|
|
61
|
-
}>;
|
|
62
|
-
sellingPlans: SellingPlan[];
|
|
63
|
-
}
|
|
64
|
-
export interface ProductVariant {
|
|
65
|
-
id: string;
|
|
66
|
-
title: string;
|
|
67
|
-
price: Money;
|
|
68
|
-
/** "Was" price — present when the variant is on sale (compareAtPrice > price). */
|
|
69
|
-
compareAtPrice?: Money | null;
|
|
70
|
-
availableForSale: boolean;
|
|
71
|
-
selectedOptions?: {
|
|
72
|
-
name: string;
|
|
73
|
-
value: string;
|
|
74
|
-
}[];
|
|
75
|
-
image?: ImageRef | null;
|
|
76
|
-
/** Stock-keeping unit. Only after `fetchProduct()`. */
|
|
77
|
-
sku?: string | null;
|
|
78
|
-
/** Cart quantity bounds (min/max/increment). */
|
|
79
|
-
quantityRule?: QuantityRule;
|
|
80
|
-
/** Per-unit price ("$2.50 / 100ml") for measured products. */
|
|
81
|
-
unitPrice?: Money | null;
|
|
82
|
-
unitPriceMeasurement?: UnitPriceMeasurement | null;
|
|
83
|
-
/** Pickup availability per location (only after `fetchProduct()`). */
|
|
84
|
-
storeAvailability?: StoreAvailability[];
|
|
85
|
-
}
|
|
86
|
-
export interface Product {
|
|
87
|
-
/** Storefront GraphQL node id (present for live data). */
|
|
88
|
-
id?: string;
|
|
89
|
-
handle: string;
|
|
90
|
-
title: string;
|
|
91
|
-
price: Money;
|
|
92
|
-
/** Range "was" price (max compareAtPrice across variants) — sale badge on cards. */
|
|
93
|
-
compareAtPrice?: Money | null;
|
|
94
|
-
featuredImage?: ImageRef | null;
|
|
95
|
-
/** Default purchasable variant id (`firstAvailableVariant`) — enough to add
|
|
96
|
-
* to cart from a grid/card without loading the full variant list. */
|
|
97
|
-
variantId?: string;
|
|
98
|
-
availableForSale?: boolean;
|
|
99
|
-
/** Catalog facets (card badges / filtering). Present from boot. */
|
|
100
|
-
vendor?: string | null;
|
|
101
|
-
productType?: string | null;
|
|
102
|
-
tags?: string[];
|
|
103
|
-
/** Long description — only populated by `fetchProduct()` (PDP). */
|
|
104
|
-
description?: string;
|
|
105
|
-
/** Image gallery — only after `fetchProduct()` (PDP). */
|
|
106
|
-
images?: ImageRef[];
|
|
107
|
-
/** Option definitions (Size, Color…) — only after `fetchProduct()`. */
|
|
108
|
-
options?: ProductOption[];
|
|
109
|
-
/** Full variant list — only after `fetchProduct()` (PDP). */
|
|
110
|
-
variants?: ProductVariant[];
|
|
111
|
-
/** Subscription / selling-plan groups — only after `fetchProduct()`. */
|
|
112
|
-
sellingPlanGroups?: SellingPlanGroup[];
|
|
113
|
-
/** Requested custom metafields ("namespace.key" → value) — pass identifiers to fetchProduct(). */
|
|
114
|
-
metafields?: Record<string, string | null>;
|
|
115
|
-
/** SEO override — only after `fetchProduct()`. */
|
|
116
|
-
seo?: Seo | null;
|
|
117
|
-
}
|
|
118
|
-
export interface Collection {
|
|
119
|
-
handle: string;
|
|
120
|
-
title: string;
|
|
121
|
-
/** Optional hero image; falls back to first product's featuredImage. */
|
|
122
|
-
image?: {
|
|
123
|
-
url?: string;
|
|
124
|
-
altText?: string;
|
|
125
|
-
} | null;
|
|
126
|
-
products: Product[];
|
|
127
|
-
/** Custom metafields ("namespace.key" → value) for dynamic sources. */
|
|
128
|
-
metafields?: Record<string, string | null>;
|
|
129
|
-
}
|
|
130
|
-
export interface Page {
|
|
131
|
-
handle: string;
|
|
132
|
-
title: string;
|
|
133
|
-
/** HTML body — rendered via dangerouslySetInnerHTML by the PageBody section. */
|
|
134
|
-
body: string;
|
|
135
|
-
bodySummary?: string;
|
|
136
|
-
author?: string | null;
|
|
137
|
-
publishedAt?: string;
|
|
138
|
-
updatedAt?: string;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* The data interface every block consumes. Themes provide an implementation.
|
|
142
|
-
*
|
|
143
|
-
* Core read methods (collections/products/pages/localization) are always
|
|
144
|
-
* present. The Shopify-compatible extensions (shop, menus, search, blog,
|
|
145
|
-
* recommendations, metaobjects, customer account) come from `StorefrontExtensions`
|
|
146
|
-
* and are LIVE-ONLY — undefined under mock data, so themes feature-detect them
|
|
147
|
-
* (`data.search?.(...)`, `data.customer?.login(...)`).
|
|
148
|
-
*/
|
|
149
|
-
export interface DataApi extends StorefrontExtensions {
|
|
150
|
-
collectionByHandle: (handle: string) => Collection | null;
|
|
151
|
-
/** All known collections (used by CollectionList). */
|
|
152
|
-
allCollections: () => Collection[];
|
|
153
|
-
/**
|
|
154
|
-
* List every navigation menu the store has (Dashboard → Navigation), for the
|
|
155
|
-
* editor's `link_list` picker. Identity only (handle/title/count) — fetch a
|
|
156
|
-
* menu's items with `fetchMenu(handle)`. Optional: older payloads may omit it.
|
|
157
|
-
*/
|
|
158
|
-
listMenus?: () => Promise<Array<{
|
|
159
|
-
handle: string;
|
|
160
|
-
title: string;
|
|
161
|
-
itemsCount: number;
|
|
162
|
-
}>>;
|
|
163
|
-
/** Connected tracking pixels (Settings → Customer events) to inject on the
|
|
164
|
-
* storefront. Optional — older payloads / mock mode return []. */
|
|
165
|
-
pixels?: () => Promise<Array<{
|
|
166
|
-
id: string;
|
|
167
|
-
name: string;
|
|
168
|
-
provider: string | null;
|
|
169
|
-
providerPixelId: string | null;
|
|
170
|
-
code: string | null;
|
|
171
|
-
}>>;
|
|
172
|
-
/** Physical store locations (Settings → Locations) for a store-locator. */
|
|
173
|
-
locations?: () => Promise<Array<{
|
|
174
|
-
id: string;
|
|
175
|
-
name: string;
|
|
176
|
-
code: string | null;
|
|
177
|
-
address: {
|
|
178
|
-
country: string | null;
|
|
179
|
-
address: string | null;
|
|
180
|
-
city: string | null;
|
|
181
|
-
province: string | null;
|
|
182
|
-
postalCode: string | null;
|
|
183
|
-
phone: string | null;
|
|
184
|
-
} | null;
|
|
185
|
-
}>>;
|
|
186
|
-
/**
|
|
187
|
-
* Look up a single product by its handle. Returns null when the handle
|
|
188
|
-
* isn't found. Required by FeaturedProduct / ProductDetails sections
|
|
189
|
-
* (ported from the canonical examples/react theme in PR #2).
|
|
190
|
-
*/
|
|
191
|
-
productByHandle: (handle: string) => Product | null;
|
|
192
|
-
/**
|
|
193
|
-
* Look up a Page by handle (the storefront's `/pages/<handle>` content).
|
|
194
|
-
* Returns null if the handle wasn't prefetched at boot or the merchant
|
|
195
|
-
* hasn't published a page with that handle. Live data prefetches only the
|
|
196
|
-
* page matching the current URL, so other handles return null even when
|
|
197
|
-
* they exist in the backend — themes should only call this for the page
|
|
198
|
-
* the user is on.
|
|
199
|
-
*/
|
|
200
|
-
pageByHandle: (handle: string) => Page | null;
|
|
201
|
-
/** Localization snapshot — what markets/countries the store has live.
|
|
202
|
-
* null = mock data; the country switcher should hide itself. */
|
|
203
|
-
localization: Localization | null;
|
|
204
|
-
/**
|
|
205
|
-
* Raw GraphQL escape hatch against the same storefront endpoint the live
|
|
206
|
-
* data source was booted with. Present ONLY for live data — undefined for
|
|
207
|
-
* mock data. Powers post-boot interactions (the cart's mutations live here).
|
|
208
|
-
*/
|
|
209
|
-
graphql?: <T = unknown>(query: string, variables?: Record<string, unknown>) => Promise<T>;
|
|
210
|
-
/**
|
|
211
|
-
* Fetch a single product WITH its full options + variants on demand (for the
|
|
212
|
-
* product page's variant picker). Live data hits the backend; mock data
|
|
213
|
-
* resolves synchronously from the prefetched cache. Returns null if missing.
|
|
214
|
-
*/
|
|
215
|
-
fetchProduct?: (handle: string, opts?: {
|
|
216
|
-
metafields?: Array<{
|
|
217
|
-
namespace: string;
|
|
218
|
-
key: string;
|
|
219
|
-
}>;
|
|
220
|
-
}) => Promise<Product | null>;
|
|
221
|
-
/**
|
|
222
|
-
* Fetch the shop's custom metafields by identifier (for dynamic sources).
|
|
223
|
-
* Live data queries `shop { metafields(identifiers) }`; mock data returns {}
|
|
224
|
-
* (no metafields offline). Result keys are "namespace.key".
|
|
225
|
-
*/
|
|
226
|
-
fetchShopMetafields?: (identifiers: Array<{
|
|
227
|
-
namespace: string;
|
|
228
|
-
key: string;
|
|
229
|
-
}>) => Promise<Record<string, string | null>>;
|
|
230
|
-
/**
|
|
231
|
-
* Fetch a collection's custom metafields by identifier (for dynamic sources).
|
|
232
|
-
* Result keys are "namespace.key".
|
|
233
|
-
*/
|
|
234
|
-
fetchCollectionMetafields?: (handle: string, identifiers: Array<{
|
|
235
|
-
namespace: string;
|
|
236
|
-
key: string;
|
|
237
|
-
}>) => Promise<Record<string, string | null>>;
|
|
238
|
-
/**
|
|
239
|
-
* The raw serializable bootstrap payload this live DataApi was built from
|
|
240
|
-
* (null for mock data). The SSG step embeds it into the page as
|
|
241
|
-
* `window.__TQ_STATE__` so the client can rebuild the identical DataApi
|
|
242
|
-
* synchronously at hydration via createLiveDataFromSnapshot — SSR markup and
|
|
243
|
-
* the client's first render match by construction.
|
|
244
|
-
*/
|
|
245
|
-
getSnapshot?: () => unknown;
|
|
246
|
-
}
|
|
247
|
-
/** Country/market shape mirrored from storefront GraphQL `Localization`. */
|
|
248
|
-
export interface LocalizedCurrency {
|
|
249
|
-
isoCode: string;
|
|
250
|
-
name?: string;
|
|
251
|
-
symbol?: string;
|
|
252
|
-
}
|
|
253
|
-
export interface LocalizedMarket {
|
|
254
|
-
id: string;
|
|
255
|
-
handle: string;
|
|
256
|
-
name: string;
|
|
257
|
-
}
|
|
258
|
-
export interface LocalizedCountry {
|
|
259
|
-
isoCode: string;
|
|
260
|
-
name: string;
|
|
261
|
-
currency: LocalizedCurrency;
|
|
262
|
-
market: LocalizedMarket | null;
|
|
263
|
-
}
|
|
264
|
-
/** A language the store has published (dashboard → Markets / Languages). */
|
|
265
|
-
export interface LocalizedLanguage {
|
|
266
|
-
isoCode: string;
|
|
267
|
-
name: string;
|
|
268
|
-
}
|
|
269
|
-
export interface Localization {
|
|
270
|
-
/** Currently-active country (resolved from the request's X-Tanqory-Country). */
|
|
271
|
-
country: LocalizedCountry;
|
|
272
|
-
/** Every country the store has an active Market for — what the picker shows. */
|
|
273
|
-
availableCountries: LocalizedCountry[];
|
|
274
|
-
/**
|
|
275
|
-
* Currently-active language + every language the store has PUBLISHED. These
|
|
276
|
-
* are STORE/dashboard data (the merchant's published locales), not a theme
|
|
277
|
-
* config list — the theme only ships the translations. Optional so older live
|
|
278
|
-
* payloads (countries only) still satisfy the type; the picker falls back to a
|
|
279
|
-
* single default when absent.
|
|
280
|
-
*/
|
|
281
|
-
language?: LocalizedLanguage;
|
|
282
|
-
availableLanguages?: LocalizedLanguage[];
|
|
283
|
-
}
|
|
284
|
-
/** Wraps the app with a theme-provided data source (mock or live). */
|
|
285
|
-
export declare function DataProvider({ value, children }: {
|
|
286
|
-
value: DataApi;
|
|
287
|
-
children: ReactNode;
|
|
288
|
-
}): JSX.Element;
|
|
289
|
-
export declare function useData(): DataApi;
|
|
290
|
-
/** Build an offline data source from fixture collections (theme passes its JSON). */
|
|
291
|
-
export declare function createMockData(collections: Collection[]): DataApi;
|
|
292
|
-
/**
|
|
293
|
-
* Live data source backed by the Tanqory Storefront GraphQL API.
|
|
294
|
-
*
|
|
295
|
-
* const data = await createLiveData({
|
|
296
|
-
* endpoint: 'https://api-do-sgp1.tanqory.com',
|
|
297
|
-
* storeId: '<store-uuid>',
|
|
298
|
-
* token: '<publishable-storefront-token>',
|
|
299
|
-
* prefetch: { collectionLimit: 20, productLimitPerCollection: 24 },
|
|
300
|
-
* })
|
|
301
|
-
*
|
|
302
|
-
* Returns the same `DataApi` shape as `createMockData` (sync read methods)
|
|
303
|
-
* by pre-fetching collections + their products at boot and serving every
|
|
304
|
-
* subsequent lookup from an in-memory cache. The trade-off: a single GraphQL
|
|
305
|
-
* round-trip at boot, then zero network on render — exactly what the SSG
|
|
306
|
-
* step + first hydration need.
|
|
307
|
-
*
|
|
308
|
-
* Per-handle pages (e.g. /products/<handle>) that miss the prefetch can
|
|
309
|
-
* still be fetched lazily via `dataApi.refresh()` (TODO) — for now, raise
|
|
310
|
-
* `prefetch.productLimitPerCollection` to cover the catalogue size.
|
|
311
|
-
*/
|
|
312
|
-
export interface LiveDataOptions {
|
|
313
|
-
/** Base URL of the store-api (e.g. https://api-do-sgp1.tanqory.com). */
|
|
314
|
-
endpoint: string;
|
|
315
|
-
/** Store UUID (the `:storeId` path param). */
|
|
316
|
-
storeId: string;
|
|
317
|
-
/** Publishable storefront token — passed as `x-publishable-key`. */
|
|
318
|
-
token?: string;
|
|
319
|
-
/**
|
|
320
|
-
* ISO 3166 alpha-2 (e.g. "TH", "SG", "US"). When set, the backend resolves
|
|
321
|
-
* the matching Market for this country, applies its currency + exchange
|
|
322
|
-
* rate, and returns Money fields in that currency. Falls back to store
|
|
323
|
-
* base currency if no Market matches the country.
|
|
324
|
-
*/
|
|
325
|
-
country?: string;
|
|
326
|
-
/** Optional fetch override (testing / SSR). */
|
|
327
|
-
fetcher?: typeof fetch;
|
|
328
|
-
/**
|
|
329
|
-
* Page handle (from `/pages/<handle>`) to fetch alongside the homepage
|
|
330
|
-
* bootstrap. The theme entry resolves the current URL once at boot and
|
|
331
|
-
* passes the matching handle here so the PageBody section can read
|
|
332
|
-
* `dataApi.pageByHandle(handle)` synchronously during hydration.
|
|
333
|
-
*/
|
|
334
|
-
pageHandle?: string;
|
|
335
|
-
/** Tune how much to load at boot. */
|
|
336
|
-
prefetch?: {
|
|
337
|
-
/** Max collections to fetch (default 20). */
|
|
338
|
-
collectionLimit?: number;
|
|
339
|
-
/** Max products to inline under each collection (default 24). */
|
|
340
|
-
productLimitPerCollection?: number;
|
|
341
|
-
/** Max products to fetch at the top level (default 24) — these power the
|
|
342
|
-
* synthesized `featured` / `all` virtual collections when the store has
|
|
343
|
-
* no real collections yet. */
|
|
344
|
-
topProductLimit?: number;
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
export declare function createLiveData(opts: LiveDataOptions): Promise<DataApi>;
|
|
348
|
-
/**
|
|
349
|
-
* Build a live DataApi SYNCHRONOUSLY from a previously-fetched bootstrap
|
|
350
|
-
* payload (`data.getSnapshot()`, serialized into the SSG HTML as
|
|
351
|
-
* `window.__TQ_STATE__` by the prerender step). This is what makes hydration
|
|
352
|
-
* deterministic: the client's first render uses the EXACT data the server
|
|
353
|
-
* rendered with — no network round-trip, no drift, no mock fallback — and
|
|
354
|
-
* mount()'s `revalidate` swaps in fresh data after hydration (SWR).
|
|
355
|
-
*/
|
|
356
|
-
export declare function createLiveDataFromSnapshot(snapshot: unknown, opts: LiveDataOptions): DataApi;
|
|
357
|
-
export declare function formatMoney(money: Money): string;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dynamic sources — bind a section/block setting to a live metafield, resource
|
|
3
|
-
* property, or metaobject field (Shopify "Insert dynamic source", the ⛁ icon).
|
|
4
|
-
*
|
|
5
|
-
* A setting value is normally a primitive. When the merchant connects a dynamic
|
|
6
|
-
* source the editor stores a `{ '@source': '<path>' }` object instead, and the
|
|
7
|
-
* theme resolves it at render against the CURRENT page resource:
|
|
8
|
-
*
|
|
9
|
-
* product.metafields.custom.subtitle → the page product's metafield
|
|
10
|
-
* collection.metafields.custom.tagline → the page collection's metafield
|
|
11
|
-
* shop.metafields.custom.announcement → the store's metafield (any page)
|
|
12
|
-
* product.title / shop.name → a plain resource property
|
|
13
|
-
* metaobject:size:medium.label → a metaobject field (type:handle.key)
|
|
14
|
-
*
|
|
15
|
-
* The path grammar mirrors Shopify so themes/docs are portable. Resolution is
|
|
16
|
-
* synchronous against already-loaded resources — the provider is responsible
|
|
17
|
-
* for loading the bound metafields (see `collectBoundIdentifiers`).
|
|
18
|
-
*/
|
|
19
|
-
import { type ReactNode } from 'react';
|
|
20
|
-
import type { Product, Collection } from './data';
|
|
21
|
-
import type { Shop, Metaobject } from './storefront';
|
|
22
|
-
/** A setting bound to a dynamic source instead of a literal value. */
|
|
23
|
-
export interface BoundSource {
|
|
24
|
-
'@source': string;
|
|
25
|
-
}
|
|
26
|
-
export type Bound<T> = T | BoundSource;
|
|
27
|
-
export declare function isBoundSource(v: unknown): v is BoundSource;
|
|
28
|
-
/** Resources a dynamic source can read from on the current page. */
|
|
29
|
-
export interface ResourceContextValue {
|
|
30
|
-
shop?: (Shop & {
|
|
31
|
-
metafields?: Record<string, string | null>;
|
|
32
|
-
}) | null;
|
|
33
|
-
product?: (Product & {
|
|
34
|
-
metafields?: Record<string, string | null>;
|
|
35
|
-
}) | null;
|
|
36
|
-
collection?: (Collection & {
|
|
37
|
-
metafields?: Record<string, string | null>;
|
|
38
|
-
}) | null;
|
|
39
|
-
/** Synchronous metaobject lookup (type, handle) → entry, from a warmed cache. */
|
|
40
|
-
metaobject?: (type: string, handle: string) => Metaobject | null;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Provide the current page's resources to dynamic sources. Wrap the page once
|
|
44
|
-
* (the layout does this). `shop` falls back to the data source so shop-level
|
|
45
|
-
* bindings work on every page without extra wiring.
|
|
46
|
-
*/
|
|
47
|
-
export declare function DynamicSourceProvider({ value, children, }: {
|
|
48
|
-
value: ResourceContextValue;
|
|
49
|
-
children: ReactNode;
|
|
50
|
-
}): JSX.Element;
|
|
51
|
-
export declare function useResourceContext(): ResourceContextValue;
|
|
52
|
-
/** Resolve a `@source` path against a resource context. Returns null if unbound. */
|
|
53
|
-
export declare function resolveBoundSource(source: string, ctx: ResourceContextValue): string | null;
|
|
54
|
-
/**
|
|
55
|
-
* Resolve a possibly-bound setting value for the current page.
|
|
56
|
-
* const heading = useBound(attributes.heading) // string | the literal | null
|
|
57
|
-
* A plain value passes through unchanged; a `{ '@source' }` object resolves to
|
|
58
|
-
* the live value (or null when the source has no value on this resource).
|
|
59
|
-
*/
|
|
60
|
-
export declare function useBound(value: unknown): unknown;
|
|
61
|
-
/** Convenience: resolve to a string (empty when null/unbound-empty). */
|
|
62
|
-
export declare function useBoundText(value: unknown, fallback?: string): string;
|
|
63
|
-
/**
|
|
64
|
-
* Walk a content tree's section/block settings and collect every bound metafield
|
|
65
|
-
* identifier, grouped by resource. The provider uses this to request exactly the
|
|
66
|
-
* metafields the page binds (the live product/collection query takes identifiers).
|
|
67
|
-
*/
|
|
68
|
-
export declare function collectBoundIdentifiers(nodes: Array<{
|
|
69
|
-
settings?: Record<string, unknown>;
|
|
70
|
-
blocks?: unknown[];
|
|
71
|
-
}> | undefined): {
|
|
72
|
-
product: Array<{
|
|
73
|
-
namespace: string;
|
|
74
|
-
key: string;
|
|
75
|
-
}>;
|
|
76
|
-
collection: Array<{
|
|
77
|
-
namespace: string;
|
|
78
|
-
key: string;
|
|
79
|
-
}>;
|
|
80
|
-
shop: Array<{
|
|
81
|
-
namespace: string;
|
|
82
|
-
key: string;
|
|
83
|
-
}>;
|
|
84
|
-
};
|
package/dist/types/editor.d.ts
DELETED
package/dist/types/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { defineSection } from './defineSection';
|
|
2
|
-
export { defineTheme, defineSettings, type ThemeConfig, type SettingsSchema } from './config';
|
|
3
|
-
export { ThemeProvider, useSettings, useT } from './theme-context';
|
|
4
|
-
export { mount, type MountOptions } from './mount';
|
|
5
|
-
export { renderStorefrontHTML, renderSectionPreviewHTML } from './ssg';
|
|
6
|
-
export { SectionTree } from './SectionTree';
|
|
7
|
-
export { Editor } from './editor';
|
|
8
|
-
export { registerSections, getSection, allSections } from './registry';
|
|
9
|
-
export { DataProvider, useData, createMockData, createLiveData, createLiveDataFromSnapshot, formatMoney, } from './data';
|
|
10
|
-
export { CartProvider, useCart } from './cart';
|
|
11
|
-
export { DynamicSourceProvider, useResourceContext, useBound, useBoundText, isBoundSource, resolveBoundSource, collectBoundIdentifiers, } from './dynamic-source';
|
|
12
|
-
export type { Bound, BoundSource, ResourceContextValue } from './dynamic-source';
|
|
13
|
-
export type { CartApi, CartLine, CartState, AddToCartInput, AppliedDiscountCode, AppliedGiftCard, } from './cart';
|
|
14
|
-
export type { LiveDataOptions, Localization, LocalizedCountry, LocalizedMarket, LocalizedCurrency, ProductOption, ProductVariant, ImageRef, QuantityRule, UnitPriceMeasurement, StoreAvailability, SellingPlan, SellingPlanOption, SellingPlanGroup, } from './data';
|
|
15
|
-
export { jsxToJSON } from './jsx-to-json';
|
|
16
|
-
export { tag, type Tag } from './composition';
|
|
17
|
-
export type { Money, Product, Collection, DataApi } from './data';
|
|
18
|
-
export type { SectionDef, SectionProps, ContentNode, PageDoc, AttrSpec } from './types';
|
|
19
|
-
export { customerTokenStore } from './storefront';
|
|
20
|
-
export type { StorefrontExtensions, Menu, MenuItem, MenuItemType, Blog, Article, SearchResults, CollectionProductsPage, PredictiveSearchResults, PageInfo, Filter, Metaobject, MetaobjectField, Shop, ShopPolicy, Image as StorefrontImage, Seo, CustomerApi, Customer, CustomerAddress, CustomerAddressInput, Order, OrderLineItem, AuthResult, MutationResult, } from './storefront';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type FC, type ReactNode } from 'react';
|
|
2
|
-
import type { ContentNode } from './types';
|
|
3
|
-
export declare function PreviewBridge({ pages, initialPage, Shell, }: {
|
|
4
|
-
pages: Record<string, ContentNode[]>;
|
|
5
|
-
initialPage: string;
|
|
6
|
-
Shell: FC<{
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}>;
|
|
9
|
-
}): JSX.Element;
|