@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,230 @@
|
|
|
1
|
+
import type { Cart, Link, Shop, Product, GiftCardBalance, CartLineAttribute } from './types.js';
|
|
2
|
+
export type ThemeMode = 'storefront' | 'editor';
|
|
3
|
+
export type OverlayName = 'cart' | 'search' | 'account';
|
|
4
|
+
export interface ThemeToast {
|
|
5
|
+
id: string;
|
|
6
|
+
message: string;
|
|
7
|
+
tone: 'info' | 'error';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Why the store refused a line's last quantity change, when it said: `cart_limit_exceeded` is the
|
|
11
|
+
* merchant's "Maximum quantity per product"; `maxQuantity` is that limit when known. `quantity_rule`
|
|
12
|
+
* (theme-abi Cart-3): the cart is bought for a company location and the quantity breaks its rule for the
|
|
13
|
+
* variant — `rule` names the part (`minimum`, `maximum`, `increment`); the numbers are the theme's to name.
|
|
14
|
+
*/
|
|
15
|
+
export type CartLineRefusal = {
|
|
16
|
+
code: 'cart_limit_exceeded';
|
|
17
|
+
maxQuantity?: number;
|
|
18
|
+
} | {
|
|
19
|
+
code: 'quantity_rule';
|
|
20
|
+
rule: 'minimum' | 'maximum' | 'increment';
|
|
21
|
+
};
|
|
22
|
+
export interface ThemeContextValue {
|
|
23
|
+
/** `editor` inside the Studio canvas: empty sections draw their setup frame. */
|
|
24
|
+
mode: ThemeMode;
|
|
25
|
+
/** BCP 47 language of the page. */
|
|
26
|
+
locale: string;
|
|
27
|
+
/** The store's theme settings, including the editor's unsaved live values. */
|
|
28
|
+
settings: Readonly<Record<string, unknown>>;
|
|
29
|
+
/** The shopper's cart (null until known). */
|
|
30
|
+
cart: Cart | null;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the shopper's cart is known yet, as StoreContext.cartStatus (board 35 #85): `loading` until the first
|
|
33
|
+
* `cart.get` answers, `failed` when that first load failed and is not retried, else `ready`. Until `ready` an empty
|
|
34
|
+
* `cart` is not an empty cart: the cart drawer shows its loading state, not "Your cart is empty". Absent: `ready`.
|
|
35
|
+
*/
|
|
36
|
+
cartStatus?: 'loading' | 'ready' | 'failed';
|
|
37
|
+
/** Where Checkout goes. */
|
|
38
|
+
checkoutUrl: string;
|
|
39
|
+
/** Which page-level overlay is open. */
|
|
40
|
+
overlay: OverlayName | null;
|
|
41
|
+
/** The cart drawer was opened by an add, not by the shopper. */
|
|
42
|
+
justAddedToCart: boolean;
|
|
43
|
+
/** Lines with a request in flight / whose last request failed. */
|
|
44
|
+
busyLines: readonly string[];
|
|
45
|
+
failedLines: readonly string[];
|
|
46
|
+
/** Failed lines the store said why for (a subset of `failedLines`), by line id. */
|
|
47
|
+
refusedLines: Readonly<Record<string, CartLineRefusal>>;
|
|
48
|
+
toasts: readonly ThemeToast[];
|
|
49
|
+
/** The cookie banner should be shown (the platform decided consent is needed and the shopper has not answered). */
|
|
50
|
+
consentRequired: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Board 35 #42 (2026-11-24): the shopper asked for their choices (the footer's "Cookie preferences", a `#privacy-choices`
|
|
53
|
+
* link): show the preferences dialog itself, not the banner. Absent = false.
|
|
54
|
+
*/
|
|
55
|
+
consentManage?: boolean;
|
|
56
|
+
/** The shopper's current choice, when they made one (the preferences dialog starts from it). */
|
|
57
|
+
consentChoice?: ConsentDecision;
|
|
58
|
+
/**
|
|
59
|
+
* Board 35 #42: the platform's data sharing opt-out page, when a sale-of-data opt-out applies where the shopper is
|
|
60
|
+
* (`consent.get` `regionRequiresOptOut`: the store's own rules and, while the page is automated, the US states whose law
|
|
61
|
+
* asks for one). A theme links it ("Your privacy choices"). Absent = no link.
|
|
62
|
+
*/
|
|
63
|
+
privacyChoicesUrl?: string;
|
|
64
|
+
/** The store's privacy policy page, when it is published; null otherwise (or not known yet). */
|
|
65
|
+
privacyPolicyUrl: string | null;
|
|
66
|
+
/** The shop as sections see it (name, cookie banner, taxes, free-shipping threshold); absent outside a store. */
|
|
67
|
+
shop?: Shop;
|
|
68
|
+
/**
|
|
69
|
+
* Where a platform form posts on this page (`<form data-tq-form method="post">`, Theme ABI §1) — for page-level
|
|
70
|
+
* forms outside a section (a pop-up's sign-up). Absent where the platform takes no form posts.
|
|
71
|
+
*/
|
|
72
|
+
formEndpoint?: string;
|
|
73
|
+
/** The outcome of the platform form POST this page answers, when it answers one (any form id). */
|
|
74
|
+
formResult?: {
|
|
75
|
+
formId: string;
|
|
76
|
+
status: 'ok' | 'invalid' | 'rate_limited' | 'unavailable' | 'expired';
|
|
77
|
+
email?: string;
|
|
78
|
+
discountCode?: string;
|
|
79
|
+
giftCard?: GiftCardBalance;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* How applying a discount code went (`ThemeActions.cart.applyDiscountCode`). Kept equal to the runtime's
|
|
84
|
+
* `DiscountCodeResult` (runtime/kit/cart.tsx).
|
|
85
|
+
*/
|
|
86
|
+
export type DiscountCodeResult = 'applied' | 'not_applicable' | 'failed';
|
|
87
|
+
/**
|
|
88
|
+
* Why the last code `applyDiscountCode` answered `not_applicable` for does not apply (`ThemeActions.cart.lastDiscountRefusal`),
|
|
89
|
+
* when the platform said why (board 35 #14). Kept equal to the runtime's `DiscountCodeRefusal` (runtime/kit/cart.tsx).
|
|
90
|
+
*/
|
|
91
|
+
export type DiscountCodeRefusal = 'not_found' | 'inactive' | 'usage_limit' | 'already_used' | 'sign_in' | 'not_eligible' | 'no_items' | 'minimum_quantity' | 'minimum_subtotal' | 'delivery' | 'not_combinable';
|
|
92
|
+
/**
|
|
93
|
+
* What stock let the last `add` put in the cart, when the platform cut it (theme-abi Cart-2, the store's
|
|
94
|
+
* MERCHANDISE_OUT_OF_STOCK / MERCHANDISE_NOT_ENOUGH_STOCK cart warnings): `out_of_stock` — none could be added, the
|
|
95
|
+
* variant is sold out; `not_enough_stock` — `added` (0 or more) were added, all that is in stock. Kept equal to the
|
|
96
|
+
* runtime's `CartAddStock` (runtime/kit/cart.tsx).
|
|
97
|
+
*/
|
|
98
|
+
export type CartAddStock = {
|
|
99
|
+
code: 'out_of_stock';
|
|
100
|
+
} | {
|
|
101
|
+
code: 'not_enough_stock';
|
|
102
|
+
added: number;
|
|
103
|
+
};
|
|
104
|
+
export interface ConsentDecision {
|
|
105
|
+
analytics: boolean;
|
|
106
|
+
marketing: boolean;
|
|
107
|
+
/** The preferences purpose (the platform's `functional`); absent = not given (stored as off). */
|
|
108
|
+
preferences?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/** What an add may carry beside the variant and quantity. */
|
|
111
|
+
export interface AddToCartOptions {
|
|
112
|
+
/** The selling plan the shopper picked (`Product.sellingPlanGroups[].plans[].id`): the line is a subscription. */
|
|
113
|
+
sellingPlanId?: string;
|
|
114
|
+
/**
|
|
115
|
+
* The line's custom attributes (NEW-PROD-12) — a gift card's recipient. Entries whose key or value is not a string
|
|
116
|
+
* are dropped. Carried by kits that set `ThemeActions.cart.lineAttributes`.
|
|
117
|
+
*/
|
|
118
|
+
attributes?: readonly CartLineAttribute[];
|
|
119
|
+
/**
|
|
120
|
+
* The theme shows a stock cut itself (it reads `ThemeActions.cart.lastAddStock()` where the button is): the kit then
|
|
121
|
+
* does not show its own toast for it. Without it the kit says it in a toast. Either way such an add never opens the
|
|
122
|
+
* cart.
|
|
123
|
+
*/
|
|
124
|
+
showsStock?: true;
|
|
125
|
+
}
|
|
126
|
+
export interface ThemeActions {
|
|
127
|
+
cart: {
|
|
128
|
+
/**
|
|
129
|
+
* Resolves true when the line is in the cart; never rejects. Opens the cart on success, unless stock cut the add
|
|
130
|
+
* (`lastAddStock`). `options.attributes`
|
|
131
|
+
* (NEW-PROD-12) are the line's custom attributes — a gift card's recipient (`Recipient email`, `Recipient name`,
|
|
132
|
+
* `Message`, `Send on`); the platform stores them on the line and the order reads them. Malformed entries are dropped.
|
|
133
|
+
*/
|
|
134
|
+
add(variantId: string, quantity: number, options?: AddToCartOptions): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* What stock let the last `add` put in the cart when the platform cut it (Cart-2), else null. A getter: read it right
|
|
137
|
+
* after `add` resolves. `add` resolved false for `out_of_stock` and for `not_enough_stock` with nothing added; the
|
|
138
|
+
* cart was not opened in either case, nor for a partial add. Absent on kits without it.
|
|
139
|
+
*/
|
|
140
|
+
lastAddStock?(): CartAddStock | null;
|
|
141
|
+
/**
|
|
142
|
+
* `true` on a kit whose `add` carries `options.attributes` to the line (NEW-PROD-12); absent on older kits, which
|
|
143
|
+
* drop them. A theme checks it before offering a form whose answers must reach the line (a gift card's recipient).
|
|
144
|
+
*/
|
|
145
|
+
lineAttributes?: true;
|
|
146
|
+
setQuantity(lineId: string, quantity: number): Promise<void>;
|
|
147
|
+
remove(lineId: string): Promise<void>;
|
|
148
|
+
setNote(note: string): Promise<void>;
|
|
149
|
+
open(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Put a discount code on the cart, beside the codes already there; resolves how it went, never rejects.
|
|
152
|
+
* `applied`: the store applies it (the cart's totals already show it); an earlier code it does not combine with
|
|
153
|
+
* was taken off (`lastDiscountReplaced`). `not_applicable`: the store does not apply it to this cart (unknown,
|
|
154
|
+
* expired, a minimum not met, does not combine) — it was taken off again and the other codes stay; `failed`: the
|
|
155
|
+
* request did not go through.
|
|
156
|
+
* Optional: absent on hosts without cart discount codes — a theme must check before offering a code field.
|
|
157
|
+
*/
|
|
158
|
+
applyDiscountCode?(code: string): Promise<DiscountCodeResult>;
|
|
159
|
+
/** Why the code the last `applyDiscountCode` refused does not apply, when the platform said why; else null. A getter: read it right after `applyDiscountCode` resolves. */
|
|
160
|
+
lastDiscountRefusal?(): DiscountCodeRefusal | null;
|
|
161
|
+
/** The earlier codes the last `applyDiscountCode` took off because the new code does not combine with them ([] when none). A getter. */
|
|
162
|
+
lastDiscountReplaced?(): readonly string[];
|
|
163
|
+
/** Take a discount code off the cart. Resolves true once it is gone; never rejects. Present with `applyDiscountCode`. */
|
|
164
|
+
removeDiscountCode?(code: string): Promise<boolean>;
|
|
165
|
+
};
|
|
166
|
+
search: {
|
|
167
|
+
open(): void;
|
|
168
|
+
/** Go to the results page for a query. */
|
|
169
|
+
go(query: string): void;
|
|
170
|
+
/** Product suggestions for a query (predictive search). */
|
|
171
|
+
suggest(query: string): Promise<SearchSuggestions>;
|
|
172
|
+
};
|
|
173
|
+
localization: {
|
|
174
|
+
/** Switch market (prices and currency follow). */
|
|
175
|
+
changeCountry(countryCode: string): void;
|
|
176
|
+
/**
|
|
177
|
+
* Apply a Region & language choice: `?country=` when the country changed, `?locale=` when the
|
|
178
|
+
* language changed (`current` is what the page shows now). Optional for older hosts.
|
|
179
|
+
*/
|
|
180
|
+
changeLocale?(next: {
|
|
181
|
+
countryCode?: string;
|
|
182
|
+
languageCode?: string;
|
|
183
|
+
}, current?: {
|
|
184
|
+
countryCode?: string;
|
|
185
|
+
languageCode?: string;
|
|
186
|
+
}): void;
|
|
187
|
+
};
|
|
188
|
+
consent: {
|
|
189
|
+
decide(choice: ConsentDecision): void;
|
|
190
|
+
/** Show the shopper's choices again (the preferences dialog), so they can change an earlier choice. */
|
|
191
|
+
open(): void;
|
|
192
|
+
/** Close the reopened choices without a new decision. Optional for older hosts. */
|
|
193
|
+
close?(): void;
|
|
194
|
+
};
|
|
195
|
+
overlays: {
|
|
196
|
+
close(): void;
|
|
197
|
+
};
|
|
198
|
+
toasts: {
|
|
199
|
+
show(message: string, tone?: ThemeToast['tone']): void;
|
|
200
|
+
dismiss(id: string): void;
|
|
201
|
+
};
|
|
202
|
+
/** Go to a storefront URL (soft navigation when on). */
|
|
203
|
+
navigate(href: string): void;
|
|
204
|
+
}
|
|
205
|
+
export interface SearchSuggestions {
|
|
206
|
+
products: Product[];
|
|
207
|
+
collections: Link[];
|
|
208
|
+
articles: Link[];
|
|
209
|
+
/** All matches (the results page count). */
|
|
210
|
+
total: number;
|
|
211
|
+
}
|
|
212
|
+
export interface ThemeRuntimeValue {
|
|
213
|
+
context: ThemeContextValue;
|
|
214
|
+
actions: ThemeActions;
|
|
215
|
+
}
|
|
216
|
+
/** Provided by the theme runtime. Themes never render it. */
|
|
217
|
+
export declare const ThemeRuntimeContext: import("react").Context<ThemeRuntimeValue>;
|
|
218
|
+
/** Page state the theme can render from (cart, open overlay, mode, locale, settings). */
|
|
219
|
+
export declare function useThemeContext(): ThemeContextValue;
|
|
220
|
+
/** The platform actions a theme can trigger (cart, search, localization, consent, toasts). */
|
|
221
|
+
export declare function useThemeActions(): ThemeActions;
|
|
222
|
+
/**
|
|
223
|
+
* Predictive search for a query, debounced. Results are tagged with the query
|
|
224
|
+
* they answered: a slow answer for "shirt" never renders under "hat", and
|
|
225
|
+
* `loading` stays true until the CURRENT query has one.
|
|
226
|
+
*/
|
|
227
|
+
export declare function useSearchSuggestions(query: string, debounceMs?: number): {
|
|
228
|
+
results: SearchSuggestions | null;
|
|
229
|
+
loading: boolean;
|
|
230
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a theme can read from and ask of the platform while it renders.
|
|
3
|
+
*
|
|
4
|
+
* The theme runtime provides these; a theme only calls the hooks. Nothing here
|
|
5
|
+
* exposes how it is done — no API clients, no cart engine, no session.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
8
|
+
const NOOP_ACTIONS = {
|
|
9
|
+
cart: { add: async () => false, setQuantity: async () => { }, remove: async () => { }, setNote: async () => { }, open: () => { } },
|
|
10
|
+
search: { open: () => { }, go: () => { }, suggest: async () => ({ products: [], collections: [], articles: [], total: 0 }) },
|
|
11
|
+
localization: { changeCountry: () => { } },
|
|
12
|
+
consent: { decide: () => { }, open: () => { } },
|
|
13
|
+
overlays: { close: () => { } },
|
|
14
|
+
toasts: { show: () => { }, dismiss: () => { } },
|
|
15
|
+
navigate: () => { },
|
|
16
|
+
};
|
|
17
|
+
const DETACHED = {
|
|
18
|
+
context: {
|
|
19
|
+
mode: 'storefront',
|
|
20
|
+
locale: 'en',
|
|
21
|
+
settings: {},
|
|
22
|
+
cart: null,
|
|
23
|
+
checkoutUrl: '/checkout',
|
|
24
|
+
overlay: null,
|
|
25
|
+
justAddedToCart: false,
|
|
26
|
+
busyLines: [],
|
|
27
|
+
failedLines: [],
|
|
28
|
+
refusedLines: {},
|
|
29
|
+
toasts: [],
|
|
30
|
+
consentRequired: false,
|
|
31
|
+
privacyPolicyUrl: null,
|
|
32
|
+
},
|
|
33
|
+
actions: NOOP_ACTIONS,
|
|
34
|
+
};
|
|
35
|
+
/** Provided by the theme runtime. Themes never render it. */
|
|
36
|
+
export const ThemeRuntimeContext = createContext(DETACHED);
|
|
37
|
+
/** Page state the theme can render from (cart, open overlay, mode, locale, settings). */
|
|
38
|
+
export function useThemeContext() {
|
|
39
|
+
return useContext(ThemeRuntimeContext).context;
|
|
40
|
+
}
|
|
41
|
+
/** The platform actions a theme can trigger (cart, search, localization, consent, toasts). */
|
|
42
|
+
export function useThemeActions() {
|
|
43
|
+
return useContext(ThemeRuntimeContext).actions;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Predictive search for a query, debounced. Results are tagged with the query
|
|
47
|
+
* they answered: a slow answer for "shirt" never renders under "hat", and
|
|
48
|
+
* `loading` stays true until the CURRENT query has one.
|
|
49
|
+
*/
|
|
50
|
+
export function useSearchSuggestions(query, debounceMs = 250) {
|
|
51
|
+
const { search } = useThemeActions();
|
|
52
|
+
const [answer, setAnswer] = useState(null);
|
|
53
|
+
const timer = useRef(null);
|
|
54
|
+
const term = query.trim();
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (timer.current)
|
|
57
|
+
clearTimeout(timer.current);
|
|
58
|
+
if (!term)
|
|
59
|
+
return;
|
|
60
|
+
timer.current = setTimeout(() => {
|
|
61
|
+
search
|
|
62
|
+
.suggest(term)
|
|
63
|
+
.then((results) => setAnswer({ term, results }))
|
|
64
|
+
.catch(() => setAnswer({ term, results: { products: [], collections: [], articles: [], total: 0 } }));
|
|
65
|
+
}, debounceMs);
|
|
66
|
+
return () => {
|
|
67
|
+
if (timer.current)
|
|
68
|
+
clearTimeout(timer.current);
|
|
69
|
+
};
|
|
70
|
+
}, [term, search, debounceMs]);
|
|
71
|
+
const fresh = answer && answer.term === term ? answer.results : null;
|
|
72
|
+
return { results: term ? fresh : null, loading: Boolean(term) && !fresh };
|
|
73
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settings schema DSL — the ONE place a Nova section or block declares its
|
|
3
|
+
* persisted settings in code. Everything else is derived from it:
|
|
4
|
+
*
|
|
5
|
+
* schema ──► TypeScript prop types (SettingsOf<typeof schema>)
|
|
6
|
+
* ──► the adapter (resolveSettings: defaults, legacy, coercion)
|
|
7
|
+
* ──► Storybook controls (stories/argTypes.ts)
|
|
8
|
+
* ──► contract drift validation (validate.ts, against generated/*.json)
|
|
9
|
+
*
|
|
10
|
+
* Option IDs here are the PERSISTED IDs (what a store's saved JSON holds), never
|
|
11
|
+
* display labels. Labels come from the approved contract at display time.
|
|
12
|
+
*/
|
|
13
|
+
import { type FontEditorHints, type FontOptionsInput } from './fonts.js';
|
|
14
|
+
/** The editor control vocabulary used by the approved contracts. */
|
|
15
|
+
export type Control = 'select' | 'boolean' | 'text' | 'textarea' | 'richtext' | 'url' | 'range' | 'number' | 'color' | 'image' | 'video' | 'model' | 'menu' | 'collection' | 'product' | 'page' | 'blog' | 'article' | 'list';
|
|
16
|
+
/**
|
|
17
|
+
* How a persisted setting reaches the component:
|
|
18
|
+
* prop — passed through as the typed component prop of the same name
|
|
19
|
+
* adapter — resolved by the adapter layer into data (a menu handle becomes a
|
|
20
|
+
* Menu object, an image id an Image). The component takes the data.
|
|
21
|
+
*/
|
|
22
|
+
export type Binding = 'prop' | 'adapter';
|
|
23
|
+
interface FieldBase<C extends Control, V, B extends Binding = 'prop'> {
|
|
24
|
+
readonly control: C;
|
|
25
|
+
readonly default: V;
|
|
26
|
+
readonly binding: B;
|
|
27
|
+
/** LEGACY-HIDDEN: saved values keep rendering; not a control for new stores. */
|
|
28
|
+
readonly legacyHidden?: boolean;
|
|
29
|
+
/** The semantic this setting controls — two visible fields must never share one. */
|
|
30
|
+
readonly semantic?: string;
|
|
31
|
+
/** Why a field that is not in the approved contract exists. Absent = it must be in the contract. */
|
|
32
|
+
readonly extension?: string;
|
|
33
|
+
/** The editor's label for the control (a theme's manifest build reads it; the key, humanised, when absent). */
|
|
34
|
+
readonly label?: string;
|
|
35
|
+
/** Helper text under the control. */
|
|
36
|
+
readonly info?: string;
|
|
37
|
+
/** Placeholder text in the control. */
|
|
38
|
+
readonly placeholder?: string;
|
|
39
|
+
/** The editor panel group the control is filed under. */
|
|
40
|
+
readonly group?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Shown in the editor only while this holds: a Liquid-style condition over `section.settings.*`, `block.settings.*`
|
|
43
|
+
* and `settings.*` (the manifest's `visible_if`). A hidden setting keeps its value and still renders.
|
|
44
|
+
*/
|
|
45
|
+
readonly visibleIf?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface SelectField<O extends string = string> extends FieldBase<'select', O> {
|
|
48
|
+
readonly options: readonly O[];
|
|
49
|
+
/** The editor's label for each option id (the id itself when absent). */
|
|
50
|
+
readonly optionLabels?: Readonly<Partial<Record<O, string>>>;
|
|
51
|
+
/** Saved values that are no longer options → the option they render as. */
|
|
52
|
+
readonly legacy?: Readonly<Record<string, O>>;
|
|
53
|
+
/** How the editor draws it beyond a plain select (`field.font`: the font picker). Editor-only (`x-tanqory-editor`). */
|
|
54
|
+
readonly editor?: FontEditorHints;
|
|
55
|
+
}
|
|
56
|
+
export interface BooleanField extends FieldBase<'boolean', boolean> {
|
|
57
|
+
}
|
|
58
|
+
export interface TextField<C extends 'text' | 'textarea' | 'richtext' | 'url' | 'color' = 'text'> extends FieldBase<C, string> {
|
|
59
|
+
}
|
|
60
|
+
export interface RangeField extends FieldBase<'range' | 'number', number> {
|
|
61
|
+
readonly min: number;
|
|
62
|
+
readonly max: number;
|
|
63
|
+
readonly step: number;
|
|
64
|
+
/** Values the design snaps to (e.g. spacer 8·12·16·24…). */
|
|
65
|
+
readonly snap?: readonly number[];
|
|
66
|
+
/** The unit the editor shows beside a range ("px", "%"). */
|
|
67
|
+
readonly unit?: string;
|
|
68
|
+
}
|
|
69
|
+
export type ResourceControl = 'image' | 'video' | 'menu' | 'collection' | 'product' | 'page' | 'blog' | 'article';
|
|
70
|
+
export interface ResourceField<C extends ResourceControl = ResourceControl> extends FieldBase<C, string, 'adapter'> {
|
|
71
|
+
}
|
|
72
|
+
/** What a resource list holds a handle of (theme-abi registry `list` with `items: { type: <kind> }`). */
|
|
73
|
+
export type ListItemKind = 'product' | 'collection' | 'page' | 'blog' | 'article';
|
|
74
|
+
/**
|
|
75
|
+
* The most handles a resource list holds: 50, the editor's and studio-api's cap (the reference platform's list
|
|
76
|
+
* settings take 50; the Theme ABI allows 64). A theme may set a lower `max`, never a higher one.
|
|
77
|
+
*/
|
|
78
|
+
export declare const RESOURCE_LIST_MAX = 50;
|
|
79
|
+
/**
|
|
80
|
+
* A hand-picked list (the editor's multi picker): the persisted value is the handles in the merchant's order; the
|
|
81
|
+
* adapter resolves them (`productsFor`). The manifest field is `{ type: 'list', items: { type: <kind>, resolve }, max }`.
|
|
82
|
+
*/
|
|
83
|
+
export interface ResourceListField<I extends ListItemKind = ListItemKind> extends FieldBase<'list', readonly string[], 'adapter'> {
|
|
84
|
+
/** What each entry is a handle of. */
|
|
85
|
+
readonly items: I;
|
|
86
|
+
/** The most entries, 1 to RESOURCE_LIST_MAX. */
|
|
87
|
+
readonly max: number;
|
|
88
|
+
}
|
|
89
|
+
/** A 3D model of the store's files (theme-abi registry 4 `model`): the value is the file's https URL, passed through. */
|
|
90
|
+
export interface ModelField extends FieldBase<'model', string, 'prop'> {
|
|
91
|
+
}
|
|
92
|
+
export type Field = ModelField | SelectField | BooleanField | TextField<'text' | 'textarea' | 'richtext' | 'url' | 'color'> | RangeField | ResourceField | ResourceListField;
|
|
93
|
+
type Opts = {
|
|
94
|
+
legacyHidden?: boolean;
|
|
95
|
+
semantic?: string;
|
|
96
|
+
extension?: string;
|
|
97
|
+
label?: string;
|
|
98
|
+
info?: string;
|
|
99
|
+
placeholder?: string;
|
|
100
|
+
group?: string;
|
|
101
|
+
visibleIf?: string;
|
|
102
|
+
};
|
|
103
|
+
declare function select<const O extends string>(options: readonly O[], def: NoInfer<O>): SelectField<O>;
|
|
104
|
+
declare function select<const O extends string, const X extends Opts & {
|
|
105
|
+
legacy?: Record<string, NoInfer<O>>;
|
|
106
|
+
optionLabels?: Readonly<Partial<Record<NoInfer<O>, string>>>;
|
|
107
|
+
}>(options: readonly O[], def: NoInfer<O>, opts: X): SelectField<O> & X;
|
|
108
|
+
declare function resource<const C extends ResourceControl>(control: C, def?: string): ResourceField<C>;
|
|
109
|
+
declare function resource<const C extends ResourceControl, const X extends Opts>(control: C, def: string, opts: X): ResourceField<C> & X;
|
|
110
|
+
/** A hand-picked list of resources: handles in the merchant's order, at most `max` (default and cap 50). Starts empty. */
|
|
111
|
+
declare function resourceList<const I extends ListItemKind>(items: I, opts?: Opts & {
|
|
112
|
+
max?: number;
|
|
113
|
+
}): ResourceListField<I>;
|
|
114
|
+
export declare const field: {
|
|
115
|
+
select: typeof select;
|
|
116
|
+
boolean: {
|
|
117
|
+
(def?: boolean | undefined): BooleanField;
|
|
118
|
+
<const X extends Opts>(def: boolean, opts: X): BooleanField & X;
|
|
119
|
+
};
|
|
120
|
+
text: {
|
|
121
|
+
(def?: string | undefined): TextField<"text">;
|
|
122
|
+
<const X extends Opts>(def: string, opts: X): TextField<"text"> & X;
|
|
123
|
+
};
|
|
124
|
+
textarea: {
|
|
125
|
+
(def?: string | undefined): TextField<"textarea">;
|
|
126
|
+
<const X extends Opts>(def: string, opts: X): TextField<"textarea"> & X;
|
|
127
|
+
};
|
|
128
|
+
richtext: {
|
|
129
|
+
(def?: string | undefined): TextField<"richtext">;
|
|
130
|
+
<const X extends Opts>(def: string, opts: X): TextField<"richtext"> & X;
|
|
131
|
+
};
|
|
132
|
+
url: {
|
|
133
|
+
(def?: string | undefined): TextField<"url">;
|
|
134
|
+
<const X extends Opts>(def: string, opts: X): TextField<"url"> & X;
|
|
135
|
+
};
|
|
136
|
+
color: {
|
|
137
|
+
(def?: string | undefined): TextField<"color">;
|
|
138
|
+
<const X extends Opts>(def: string, opts: X): TextField<"color"> & X;
|
|
139
|
+
};
|
|
140
|
+
range(def: number, min: number, max: number, step: number, opts?: Opts & {
|
|
141
|
+
snap?: readonly number[];
|
|
142
|
+
unit?: string;
|
|
143
|
+
}): RangeField;
|
|
144
|
+
/** A number input (contract control "number") — same resolution as range. */
|
|
145
|
+
number(def: number, min: number, max: number, step: number, opts?: Opts): RangeField;
|
|
146
|
+
/**
|
|
147
|
+
* A font (fonts.ts): the platform catalogue first, then the theme's own fonts (`themeFonts`), then the device's
|
|
148
|
+
* faces; the editor draws it as its font picker. Render it with `useFont(settings.key, themeFonts)`.
|
|
149
|
+
*/
|
|
150
|
+
font(def: string, opts?: Opts & FontOptionsInput & {
|
|
151
|
+
weightSetting?: string;
|
|
152
|
+
}): SelectField;
|
|
153
|
+
/** A data picker: the persisted value is a handle/id; the adapter resolves it. */
|
|
154
|
+
resource: typeof resource;
|
|
155
|
+
/** A multi picker: the persisted value is a list of handles; the adapter resolves them. */
|
|
156
|
+
resourceList: typeof resourceList;
|
|
157
|
+
/**
|
|
158
|
+
* A 3D model setting (field-type registry 4, theme-abi §2.6): the editor lists the store's MODEL_3D files; the value is
|
|
159
|
+
* the .glb file's https URL. Show it with `<ModelViewer media={{ src: value }} />`. The manifest declares field-type registry 4 for it (set by
|
|
160
|
+
* `buildManifest` when the theme names none).
|
|
161
|
+
*/
|
|
162
|
+
model(opts?: Opts): ModelField;
|
|
163
|
+
};
|
|
164
|
+
export type Fields = Readonly<Record<string, Field>>;
|
|
165
|
+
/** Where a schema came from: section or block, and which design family owns it. */
|
|
166
|
+
export interface SchemaMeta {
|
|
167
|
+
/** global = a theme setting group (Nova 13 popup), not placed on a page. */
|
|
168
|
+
readonly kind: 'section' | 'block' | 'global';
|
|
169
|
+
readonly name: string;
|
|
170
|
+
/** Design family, e.g. '12A'. The validator reads the contract from here. */
|
|
171
|
+
readonly family: string;
|
|
172
|
+
/**
|
|
173
|
+
* Blocks a section (or a nested block) accepts. The reserved entry `'@app'` (`APP_BLOCKS`) accepts the blocks of the
|
|
174
|
+
* apps installed on the store (theme-abi §7.2); render those with `<AppBlock>`. Never on a header or footer section.
|
|
175
|
+
*/
|
|
176
|
+
readonly blocks?: readonly string[];
|
|
177
|
+
/** Blocks still accepted for saved stores but hidden from the picker. */
|
|
178
|
+
readonly legacyBlocks?: readonly string[];
|
|
179
|
+
/** Sections a block may be placed in (blocks only). */
|
|
180
|
+
readonly parents?: readonly string[];
|
|
181
|
+
/**
|
|
182
|
+
* Earlier persisted names of this block (blocks only). Saved content may still
|
|
183
|
+
* hold a node of that type: the section keeps accepting it (`legacyBlocks`),
|
|
184
|
+
* the theme renders it as this block, and the contract validator reads this
|
|
185
|
+
* block's contract under the old name. New content is written with `name`.
|
|
186
|
+
*/
|
|
187
|
+
readonly legacyNames?: readonly string[];
|
|
188
|
+
/** How the editor names the block in "Add block" (blocks). */
|
|
189
|
+
readonly title?: string;
|
|
190
|
+
/** One line for the editor's picker. */
|
|
191
|
+
readonly description?: string;
|
|
192
|
+
readonly icon?: string;
|
|
193
|
+
/** Route context the block needs (`product`, `collection`, …): it is offered only where the page has it. */
|
|
194
|
+
readonly requiresContext?: readonly string[];
|
|
195
|
+
}
|
|
196
|
+
export interface Schema<F extends Fields = Fields> extends SchemaMeta {
|
|
197
|
+
readonly fields: F;
|
|
198
|
+
}
|
|
199
|
+
export declare function defineSchema<const F extends Fields>(meta: SchemaMeta, fields: F): Schema<F>;
|
|
200
|
+
type ValueOf<F> = F extends SelectField<infer O> ? O : F extends BooleanField ? boolean : F extends RangeField ? number : string;
|
|
201
|
+
/**
|
|
202
|
+
* The resolved settings of a schema: every visible field required (the adapter
|
|
203
|
+
* fills defaults), every LEGACY-HIDDEN field optional.
|
|
204
|
+
*/
|
|
205
|
+
export type SettingsOf<S extends Schema> = {
|
|
206
|
+
-readonly [K in keyof S['fields'] as S['fields'][K] extends {
|
|
207
|
+
binding: 'adapter';
|
|
208
|
+
} ? never : S['fields'][K] extends {
|
|
209
|
+
legacyHidden: true;
|
|
210
|
+
} ? never : K]: ValueOf<S['fields'][K]>;
|
|
211
|
+
} & {
|
|
212
|
+
-readonly [K in keyof S['fields'] as S['fields'][K] extends {
|
|
213
|
+
binding: 'adapter';
|
|
214
|
+
} ? never : S['fields'][K] extends {
|
|
215
|
+
legacyHidden: true;
|
|
216
|
+
} ? K : never]?: ValueOf<S['fields'][K]>;
|
|
217
|
+
};
|
|
218
|
+
/** The raw adapter-bound (handle) values of a schema: a handle, or the handles of a resource list. */
|
|
219
|
+
export type HandlesOf<S extends Schema> = {
|
|
220
|
+
-readonly [K in keyof S['fields'] as S['fields'][K] extends {
|
|
221
|
+
binding: 'adapter';
|
|
222
|
+
} ? K : never]: S['fields'][K] extends ResourceListField ? string[] : string;
|
|
223
|
+
};
|
|
224
|
+
export interface SettingIssue {
|
|
225
|
+
readonly key: string;
|
|
226
|
+
readonly code: 'unknown-option' | 'legacy-value' | 'coerced' | 'unknown-setting' | 'out-of-range';
|
|
227
|
+
readonly value: unknown;
|
|
228
|
+
readonly resolved?: unknown;
|
|
229
|
+
}
|
|
230
|
+
export interface Resolved<S extends Schema> {
|
|
231
|
+
readonly settings: SettingsOf<S>;
|
|
232
|
+
readonly handles: HandlesOf<S>;
|
|
233
|
+
/** Everything the adapter had to correct — surfaced in dev and asserted in tests. */
|
|
234
|
+
readonly issues: readonly SettingIssue[];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The adapter core: saved JSON settings → typed, complete settings.
|
|
238
|
+
*
|
|
239
|
+
* - missing → the field default
|
|
240
|
+
* - a legacy option → the option it renders as (issue: legacy-value)
|
|
241
|
+
* - an unknown option → the default (issue: unknown-option), never a crash
|
|
242
|
+
* - "true"/"false"/"32" strings → boolean / number (issue: coerced)
|
|
243
|
+
* - LEGACY-HIDDEN fields keep their saved value (that is the point of them)
|
|
244
|
+
* - a resource list → its non-empty handles, trimmed, in order; anything but a list → [] (issue: coerced)
|
|
245
|
+
*/
|
|
246
|
+
export declare function resolveSettings<S extends Schema>(schema: S, raw: Readonly<Record<string, unknown>> | undefined): Resolved<S>;
|
|
247
|
+
/** Defaults of a schema — what a brand-new section renders with. */
|
|
248
|
+
export declare function defaultsOf<S extends Schema>(schema: S): SettingsOf<S>;
|
|
249
|
+
export {};
|