@tanqory/theme-kit 2.0.0-alpha.17 → 2.0.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/abi/canvas-live.d.ts +7 -2
- package/dist/abi/canvas-live.js +8 -3
- package/dist/abi/cart.d.ts +5 -4
- package/dist/abi/cart.js +14 -5
- package/dist/abi/convert.d.ts +18 -2
- package/dist/abi/convert.js +56 -4
- package/dist/abi/data-api.js +4 -0
- package/dist/abi/page-data.d.ts +11 -3
- package/dist/abi/page-data.js +71 -3
- package/dist/abi/wire.d.ts +8 -0
- package/dist/abi/wire.js +32 -2
- package/dist/build.d.ts +7 -2
- package/dist/build.js +96 -5
- package/dist/chunks.d.ts +23 -0
- package/dist/chunks.js +41 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +16 -2
- package/dist/headless/hooks.js +5 -1
- package/dist/headless/index.d.ts +8 -1
- package/dist/headless/index.js +11 -1
- 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 +1 -9
- package/dist/headless/money.js +24 -22
- package/dist/headless/page.d.ts +2 -0
- package/dist/headless/primitives/storefront.js +2 -1
- package/dist/headless/strings.js +8 -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 +13 -3
- package/dist/headless/theme.js +12 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/runtime/data/StoreProvider.js +10 -3
- package/dist/runtime/data/to-ui.d.ts +12 -7
- package/dist/runtime/data/to-ui.js +48 -16
- package/dist/runtime/kit/cart.d.ts +10 -3
- package/dist/runtime/kit/contract/content.d.ts +14 -0
- package/dist/runtime/kit/contract/content.js +13 -0
- package/dist/runtime/kit/contract/field-types.d.ts +26 -3
- package/dist/runtime/kit/contract/field-types.js +11 -1
- package/dist/runtime/kit/contract/validate.d.ts +2 -0
- package/dist/runtime/kit/contract/validate.js +49 -9
- package/dist/runtime/kit/data.d.ts +12 -0
- package/dist/runtime/kit/data.js +36 -22
- package/dist/runtime/kit/dynamic-source.d.ts +12 -0
- package/dist/runtime/kit/dynamic-source.js +17 -0
- package/dist/runtime/kit/storefront.d.ts +14 -1
- package/dist/runtime/kit/types.d.ts +8 -0
- package/dist/runtime/render/SectionRenderer.js +44 -11
- 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 +2 -1
- package/dist/runtime/render/section-actions.js +4 -1
- package/dist/runtime/render/starter.js +19 -4
- package/dist/runtime/seo/head.d.ts +1 -1
- package/dist/runtime/shell/PageShell.js +6 -1
- package/dist/runtime/shell/RuntimeBridge.d.ts +4 -0
- package/dist/runtime/shell/RuntimeBridge.js +37 -6
- package/dist/runtime/slots.d.ts +1 -1
- 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 +7 -1
- package/dist/sdk/index.js +11 -1
- 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/runtime-context.d.ts +32 -4
- package/dist/sdk/schema.d.ts +47 -4
- package/dist/sdk/schema.js +47 -0
- package/dist/sdk/store-lookup.d.ts +5 -0
- package/dist/sdk/store-lookup.js +19 -0
- package/dist/sdk/store.d.ts +15 -0
- package/dist/sdk/sx.d.ts +5 -0
- package/dist/sdk/sx.js +7 -2
- package/dist/sdk/theme.d.ts +21 -0
- package/dist/sdk/theme.js +17 -0
- package/dist/sdk/types.d.ts +36 -4
- package/dist/server.d.ts +5 -4
- package/dist/server.js +76 -20
- package/dist/vite-chunks.d.ts +10 -0
- package/dist/vite-chunks.js +44 -0
- package/docs/headless-api.md +33 -3
- package/package.json +10 -18
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Continuous values and motion for themes, under the platform CSP (theme-abi §5: `style-src-attr 'none'`, no
|
|
3
|
+
* 'unsafe-inline', script CSP unchanged).
|
|
4
|
+
*
|
|
5
|
+
* CSS VARIABLES. A value that changes with every scroll or drag frame cannot be a class (`sx()` makes one class per
|
|
6
|
+
* value). `setCssVars(el, { '--progress': 0.42 })` writes custom properties through the CSSOM
|
|
7
|
+
* (`CSSStyleDeclaration.setProperty`). CSP governs style *attributes* the parser reads from markup and `<style>`
|
|
8
|
+
* elements; it does not govern the CSSOM: CSP Level 2 §7.16 and CSP Level 3 §6.1.15 (`style-src-attr` "governs the
|
|
9
|
+
* behaviour of style attributes") restrict a style attribute the user agent would apply from the document, and the only
|
|
10
|
+
* CSSOM gating either spec names is `cssText` setters and `insertRule` under `'unsafe-eval'` (CSP3 §6.1.13 item 4,
|
|
11
|
+
* CSP2 §7.16; an editor's note there, which browsers do not apply). `setProperty` is neither, and this module never
|
|
12
|
+
* uses `cssText`, `insertRule` or `setAttribute('style')`.
|
|
13
|
+
* Checked in Chromium 148 and WebKit 26.4 under the storefront's own policy (2026-11-19): `setProperty('--w', '42px')`
|
|
14
|
+
* applies; a `style` attribute in markup or set with `setAttribute` is refused. A variable is never in the server HTML
|
|
15
|
+
* (where it would be a refused attribute): only browser code calls this, and only names that start with `--`.
|
|
16
|
+
*
|
|
17
|
+
* MOTION. `reveal()` (an element entering the screen) and `exit()` (leaving, before it is removed) run on the Web
|
|
18
|
+
* Animations API (`Element.animate`), which writes no attribute at all; `scrollProgress()` reports how far an element
|
|
19
|
+
* has travelled through the screen, for scroll-linked effects, and can write it to a variable. Everything honours
|
|
20
|
+
* `prefers-reduced-motion: reduce` (Media Queries Level 5 §11.6): no movement, only the end state (a reveal shows at
|
|
21
|
+
* once, an exit removes at once), and scroll-linked values still report (the theme decides what they do) unless the
|
|
22
|
+
* caller asks for `staticWhenReduced`. Every function is a no-op on the server.
|
|
23
|
+
*/
|
|
24
|
+
/** A custom property name: two hyphens, then letters, digits, `-` and `_` (CSS Variables Level 1 §2 `<custom-property-name>`). */
|
|
25
|
+
const VAR_NAME = /^--[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
|
|
26
|
+
/**
|
|
27
|
+
* The values a variable may hold: numbers with an optional unit, percentages, hex colours, keywords, other custom
|
|
28
|
+
* property names, operators (`+ - * / ,`) and the functions rgb()/rgba()/hsl()/hsla()/calc()/min()/max()/clamp()/var()
|
|
29
|
+
* over those, nested two levels at most. Nothing that could load a resource (`url(`, `image-set(`, `src(`), close a
|
|
30
|
+
* declaration or a rule, or hide in an escape. Read by a single left-to-right scan (linear in the length, never a
|
|
31
|
+
* backtracking pattern: a regex over runs of atoms backtracked exponentially on `aaaa…!`, security review 2026-11-19).
|
|
32
|
+
*/
|
|
33
|
+
const FUNCS = new Set(['rgb', 'rgba', 'hsl', 'hsla', 'calc', 'min', 'max', 'clamp', 'var']);
|
|
34
|
+
const UNITS = new Set(['', '%', 'px', 'em', 'rem', 'ch', 'ex', 'vh', 'vw', 'vmin', 'vmax', 'svh', 'lvh', 'dvh', 'svw', 'lvw', 'dvw', 'cqw', 'cqh', 'deg', 'rad', 'turn', 's', 'ms', 'fr', 'x']);
|
|
35
|
+
const VALUE_MAX = 200;
|
|
36
|
+
const isDigit = (c) => c >= '0' && c <= '9';
|
|
37
|
+
const isAlpha = (c) => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
|
38
|
+
const isHex = (c) => isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
|
|
39
|
+
/** One scan of `v`: true when every character belongs to an allowed token and the brackets close. */
|
|
40
|
+
function valueScan(v) {
|
|
41
|
+
let i = 0;
|
|
42
|
+
let depth = 0;
|
|
43
|
+
let tokens = 0;
|
|
44
|
+
while (i < v.length) {
|
|
45
|
+
const c = v[i];
|
|
46
|
+
if (c === ' ' || c === '\t') {
|
|
47
|
+
i++;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (c === ')') {
|
|
51
|
+
if (depth === 0)
|
|
52
|
+
return false;
|
|
53
|
+
depth--;
|
|
54
|
+
i++;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (c === '+' || c === '*' || c === '/' || c === ',') {
|
|
58
|
+
i++;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (c === '-' && !(isDigit(v[i + 1] ?? '') || v[i + 1] === '.' || v[i + 1] === '-' || isAlpha(v[i + 1] ?? ''))) {
|
|
62
|
+
i++;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (c === '#') {
|
|
66
|
+
let j = i + 1;
|
|
67
|
+
while (j < v.length && isHex(v[j]))
|
|
68
|
+
j++;
|
|
69
|
+
if (j - i - 1 < 3 || j - i - 1 > 8)
|
|
70
|
+
return false;
|
|
71
|
+
i = j;
|
|
72
|
+
tokens++;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (isDigit(c) || c === '.' || (c === '-' && (isDigit(v[i + 1] ?? '') || v[i + 1] === '.'))) {
|
|
76
|
+
let j = c === '-' ? i + 1 : i;
|
|
77
|
+
let digits = 0;
|
|
78
|
+
while (j < v.length && isDigit(v[j])) {
|
|
79
|
+
j++;
|
|
80
|
+
digits++;
|
|
81
|
+
}
|
|
82
|
+
if (v[j] === '.') {
|
|
83
|
+
j++;
|
|
84
|
+
while (j < v.length && isDigit(v[j])) {
|
|
85
|
+
j++;
|
|
86
|
+
digits++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (digits === 0)
|
|
90
|
+
return false;
|
|
91
|
+
if ((v[j] === 'e' || v[j] === 'E') && (isDigit(v[j + 1] ?? '') || (v[j + 1] === '-' && isDigit(v[j + 2] ?? '')))) {
|
|
92
|
+
j += v[j + 1] === '-' ? 2 : 1;
|
|
93
|
+
while (j < v.length && isDigit(v[j]))
|
|
94
|
+
j++;
|
|
95
|
+
}
|
|
96
|
+
let u = j;
|
|
97
|
+
while (u < v.length && (isAlpha(v[u]) || v[u] === '%'))
|
|
98
|
+
u++;
|
|
99
|
+
if (!UNITS.has(v.slice(j, u).toLowerCase()))
|
|
100
|
+
return false;
|
|
101
|
+
i = u;
|
|
102
|
+
tokens++;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (isAlpha(c) || c === '-') {
|
|
106
|
+
// a keyword, a custom property name (`--a`), or a function name followed by `(`
|
|
107
|
+
let j = i;
|
|
108
|
+
while (j < v.length && (isAlpha(v[j]) || isDigit(v[j]) || v[j] === '-' || v[j] === '_'))
|
|
109
|
+
j++;
|
|
110
|
+
const word = v.slice(i, j);
|
|
111
|
+
// a keyword is at most 32 characters, a custom property name 2 + 64 (VAR_NAME)
|
|
112
|
+
if (word.length > (word.startsWith('--') ? 66 : 32))
|
|
113
|
+
return false;
|
|
114
|
+
if (v[j] === '(') {
|
|
115
|
+
if (!FUNCS.has(word.toLowerCase()) || depth >= 2)
|
|
116
|
+
return false;
|
|
117
|
+
depth++;
|
|
118
|
+
i = j + 1;
|
|
119
|
+
tokens++;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (word.startsWith('-') && !word.startsWith('--'))
|
|
123
|
+
return false;
|
|
124
|
+
i = j;
|
|
125
|
+
tokens++;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return depth === 0 && tokens > 0;
|
|
131
|
+
}
|
|
132
|
+
/** The string a variable is set to, or null when the value is refused (valueScan). */
|
|
133
|
+
export function cssVarValue(value) {
|
|
134
|
+
if (typeof value === 'number')
|
|
135
|
+
return Number.isFinite(value) ? String(Math.round(value * 1e4) / 1e4) : null;
|
|
136
|
+
if (typeof value !== 'string')
|
|
137
|
+
return null;
|
|
138
|
+
const v = value.trim();
|
|
139
|
+
if (!v || v.length > VALUE_MAX || /[;{}<>\\"'`]|url\(|image-set\(|src\(|\/\*/i.test(v))
|
|
140
|
+
return null;
|
|
141
|
+
return valueScan(v) ? v : null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Set (or, with null / undefined, remove) custom properties on an element, in one frame. A name that is not a custom
|
|
145
|
+
* property or a value the grammar refuses is skipped, never escaped into place. Answers the names written.
|
|
146
|
+
*/
|
|
147
|
+
export function setCssVars(el, vars) {
|
|
148
|
+
const style = el?.style;
|
|
149
|
+
if (!style || typeof style.setProperty !== 'function')
|
|
150
|
+
return [];
|
|
151
|
+
const done = [];
|
|
152
|
+
for (const [name, raw] of Object.entries(vars)) {
|
|
153
|
+
if (!VAR_NAME.test(name))
|
|
154
|
+
continue;
|
|
155
|
+
if (raw === null || raw === undefined) {
|
|
156
|
+
style.removeProperty(name);
|
|
157
|
+
done.push(name);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const v = cssVarValue(raw);
|
|
161
|
+
if (v === null)
|
|
162
|
+
continue;
|
|
163
|
+
if (style.getPropertyValue(name) !== v)
|
|
164
|
+
style.setProperty(name, v);
|
|
165
|
+
done.push(name);
|
|
166
|
+
}
|
|
167
|
+
return done;
|
|
168
|
+
}
|
|
169
|
+
// ── reduced motion ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
170
|
+
const REDUCE = '(prefers-reduced-motion: reduce)';
|
|
171
|
+
const hasWindow = () => typeof window !== 'undefined' && typeof window.matchMedia === 'function';
|
|
172
|
+
/** The shopper asked for less motion (their system setting). false on the server. */
|
|
173
|
+
export function prefersReducedMotion() {
|
|
174
|
+
return hasWindow() ? window.matchMedia(REDUCE).matches : false;
|
|
175
|
+
}
|
|
176
|
+
/** Calls `cb` when the setting changes; answers the function that stops it. */
|
|
177
|
+
export function onReducedMotionChange(cb) {
|
|
178
|
+
if (!hasWindow())
|
|
179
|
+
return () => { };
|
|
180
|
+
const mq = window.matchMedia(REDUCE);
|
|
181
|
+
const h = (e) => cb(e.matches);
|
|
182
|
+
mq.addEventListener?.('change', h);
|
|
183
|
+
return () => mq.removeEventListener?.('change', h);
|
|
184
|
+
}
|
|
185
|
+
const clamp = (n, lo, hi, d) => (typeof n === 'number' && Number.isFinite(n) ? Math.min(hi, Math.max(lo, n)) : d);
|
|
186
|
+
const EASING = /^(?:linear|ease(?:-in|-out|-in-out)?|cubic-bezier\((?:\s*-?\d*\.?\d+\s*,){3}\s*-?\d*\.?\d+\s*\)|steps\(\s*\d{1,3}\s*(?:,\s*(?:start|end|jump-(?:start|end|none|both))\s*)?\))$/;
|
|
187
|
+
/** The keyframes of a preset, from hidden to shown. */
|
|
188
|
+
export function presetFrames(preset = 'fade-up', distance = 24) {
|
|
189
|
+
const d = `${clamp(distance, 0, 200, 24)}px`;
|
|
190
|
+
const from = preset === 'fade' ? { opacity: 0 }
|
|
191
|
+
: preset === 'fade-down' ? { opacity: 0, transform: `translateY(-${d})` }
|
|
192
|
+
: preset === 'slide-left' ? { opacity: 0, transform: `translateX(${d})` }
|
|
193
|
+
: preset === 'slide-right' ? { opacity: 0, transform: `translateX(-${d})` }
|
|
194
|
+
: preset === 'scale' ? { opacity: 0, transform: 'scale(0.96)' }
|
|
195
|
+
: { opacity: 0, transform: `translateY(${d})` };
|
|
196
|
+
return [from, { opacity: 1, transform: 'none' }];
|
|
197
|
+
}
|
|
198
|
+
function timing(o, defDuration) {
|
|
199
|
+
return {
|
|
200
|
+
duration: clamp(o.duration, 0, 2000, defDuration),
|
|
201
|
+
delay: clamp(o.delay, 0, 2000, 0),
|
|
202
|
+
easing: typeof o.easing === 'string' && o.easing.length <= 64 && EASING.test(o.easing.trim()) ? o.easing.trim() : 'cubic-bezier(.2,.7,.2,1)',
|
|
203
|
+
fill: 'both',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
const canAnimate = (el) => !!el && typeof el.animate === 'function';
|
|
207
|
+
/**
|
|
208
|
+
* Fades or slides an element in when it comes on screen (IntersectionObserver), with the Web Animations API. Reduced
|
|
209
|
+
* motion: it is shown at once. Answers the function that stops watching. An element that is never on screen stays as
|
|
210
|
+
* the theme's CSS draws it (the animation's first frame is applied only when it runs), so no content is hidden for good.
|
|
211
|
+
*/
|
|
212
|
+
export function reveal(el, o = {}) {
|
|
213
|
+
if (!canAnimate(el) || typeof IntersectionObserver === 'undefined')
|
|
214
|
+
return () => { };
|
|
215
|
+
const once = o.once !== false;
|
|
216
|
+
let running = null;
|
|
217
|
+
const io = new IntersectionObserver((entries) => {
|
|
218
|
+
for (const e of entries) {
|
|
219
|
+
if (!e.isIntersecting)
|
|
220
|
+
continue;
|
|
221
|
+
if (!prefersReducedMotion()) {
|
|
222
|
+
running?.cancel();
|
|
223
|
+
running = el.animate(presetFrames(o.preset, o.distance), timing(o, 500));
|
|
224
|
+
}
|
|
225
|
+
if (once)
|
|
226
|
+
io.disconnect();
|
|
227
|
+
}
|
|
228
|
+
}, { threshold: clamp(o.threshold, 0, 1, 0.15) });
|
|
229
|
+
io.observe(el);
|
|
230
|
+
return () => {
|
|
231
|
+
io.disconnect();
|
|
232
|
+
running?.cancel();
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Plays an element's exit (the preset backwards) and resolves when it is done, so the caller can remove it then (a
|
|
237
|
+
* drawer, a toast, a dismissed card). Reduced motion or no Web Animations: resolves at once.
|
|
238
|
+
*/
|
|
239
|
+
export function exit(el, o = {}) {
|
|
240
|
+
if (!canAnimate(el) || prefersReducedMotion())
|
|
241
|
+
return Promise.resolve();
|
|
242
|
+
const a = el.animate([...presetFrames(o.preset ?? 'fade', o.distance)].reverse(), timing(o, 250));
|
|
243
|
+
return a.finished.then(() => undefined, () => undefined);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* How far an element has travelled through the screen: 0 when its top meets the bottom of the screen, 1 when its bottom
|
|
247
|
+
* leaves the top (the same range as CSS `view()` timelines, Scroll-driven Animations §3.2). Computed at most once a
|
|
248
|
+
* frame, only while the element is near the screen. Answers the function that stops it.
|
|
249
|
+
*/
|
|
250
|
+
export function scrollProgress(el, cb, o = {}) {
|
|
251
|
+
if (!el || typeof window === 'undefined' || typeof el.getBoundingClientRect !== 'function')
|
|
252
|
+
return () => { };
|
|
253
|
+
const name = o.cssVar && VAR_NAME.test(o.cssVar) ? o.cssVar : null;
|
|
254
|
+
const report = (p) => {
|
|
255
|
+
if (name)
|
|
256
|
+
setCssVars(el, { [name]: p });
|
|
257
|
+
cb?.(p);
|
|
258
|
+
};
|
|
259
|
+
if (o.staticWhenReduced && prefersReducedMotion()) {
|
|
260
|
+
report(1);
|
|
261
|
+
return () => { };
|
|
262
|
+
}
|
|
263
|
+
let frame = 0;
|
|
264
|
+
let pending = false;
|
|
265
|
+
let near = true;
|
|
266
|
+
const measure = () => {
|
|
267
|
+
pending = false;
|
|
268
|
+
const r = el.getBoundingClientRect();
|
|
269
|
+
const vh = window.innerHeight || 1;
|
|
270
|
+
const p = Math.min(1, Math.max(0, (vh - r.top) / (vh + r.height || 1)));
|
|
271
|
+
report(Math.round(p * 1e4) / 1e4);
|
|
272
|
+
};
|
|
273
|
+
const onScroll = () => {
|
|
274
|
+
if (!near || pending)
|
|
275
|
+
return;
|
|
276
|
+
pending = true;
|
|
277
|
+
frame = requestAnimationFrame(measure);
|
|
278
|
+
};
|
|
279
|
+
const io = typeof IntersectionObserver === 'undefined' ? null : new IntersectionObserver((es) => { near = es.some((e) => e.isIntersecting); if (near)
|
|
280
|
+
onScroll(); }, { rootMargin: '25% 0px' });
|
|
281
|
+
io?.observe(el);
|
|
282
|
+
window.addEventListener('scroll', onScroll, { passive: true });
|
|
283
|
+
window.addEventListener('resize', onScroll, { passive: true });
|
|
284
|
+
onScroll();
|
|
285
|
+
return () => {
|
|
286
|
+
io?.disconnect();
|
|
287
|
+
window.removeEventListener('scroll', onScroll);
|
|
288
|
+
window.removeEventListener('resize', onScroll);
|
|
289
|
+
if (pending)
|
|
290
|
+
cancelAnimationFrame(frame);
|
|
291
|
+
};
|
|
292
|
+
}
|
|
@@ -8,12 +8,17 @@ export interface ThemeToast {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
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.
|
|
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.
|
|
12
14
|
*/
|
|
13
|
-
export
|
|
15
|
+
export type CartLineRefusal = {
|
|
14
16
|
code: 'cart_limit_exceeded';
|
|
15
17
|
maxQuantity?: number;
|
|
16
|
-
}
|
|
18
|
+
} | {
|
|
19
|
+
code: 'quantity_rule';
|
|
20
|
+
rule: 'minimum' | 'maximum' | 'increment';
|
|
21
|
+
};
|
|
17
22
|
export interface ThemeContextValue {
|
|
18
23
|
/** `editor` inside the Studio canvas: empty sections draw their setup frame. */
|
|
19
24
|
mode: ThemeMode;
|
|
@@ -23,6 +28,12 @@ export interface ThemeContextValue {
|
|
|
23
28
|
settings: Readonly<Record<string, unknown>>;
|
|
24
29
|
/** The shopper's cart (null until known). */
|
|
25
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';
|
|
26
37
|
/** Where Checkout goes. */
|
|
27
38
|
checkoutUrl: string;
|
|
28
39
|
/** Which page-level overlay is open. */
|
|
@@ -37,6 +48,19 @@ export interface ThemeContextValue {
|
|
|
37
48
|
toasts: readonly ThemeToast[];
|
|
38
49
|
/** The cookie banner should be shown (the platform decided consent is needed and the shopper has not answered). */
|
|
39
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;
|
|
40
64
|
/** The store's privacy policy page, when it is published; null otherwise (or not known yet). */
|
|
41
65
|
privacyPolicyUrl: string | null;
|
|
42
66
|
/** The shop as sections see it (name, cookie banner, taxes, free-shipping threshold); absent outside a store. */
|
|
@@ -80,6 +104,8 @@ export type CartAddStock = {
|
|
|
80
104
|
export interface ConsentDecision {
|
|
81
105
|
analytics: boolean;
|
|
82
106
|
marketing: boolean;
|
|
107
|
+
/** The preferences purpose (the platform's `functional`); absent = not given (stored as off). */
|
|
108
|
+
preferences?: boolean;
|
|
83
109
|
}
|
|
84
110
|
/** What an add may carry beside the variant and quantity. */
|
|
85
111
|
export interface AddToCartOptions {
|
|
@@ -161,8 +187,10 @@ export interface ThemeActions {
|
|
|
161
187
|
};
|
|
162
188
|
consent: {
|
|
163
189
|
decide(choice: ConsentDecision): void;
|
|
164
|
-
/** Show the
|
|
190
|
+
/** Show the shopper's choices again (the preferences dialog), so they can change an earlier choice. */
|
|
165
191
|
open(): void;
|
|
192
|
+
/** Close the reopened choices without a new decision. Optional for older hosts. */
|
|
193
|
+
close?(): void;
|
|
166
194
|
};
|
|
167
195
|
overlays: {
|
|
168
196
|
close(): void;
|
package/dist/sdk/schema.d.ts
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* Option IDs here are the PERSISTED IDs (what a store's saved JSON holds), never
|
|
11
11
|
* display labels. Labels come from the approved contract at display time.
|
|
12
12
|
*/
|
|
13
|
+
import { type FontEditorHints, type FontOptionsInput } from './fonts.js';
|
|
13
14
|
/** The editor control vocabulary used by the approved contracts. */
|
|
14
|
-
export type Control = 'select' | 'boolean' | 'text' | 'textarea' | 'richtext' | 'url' | 'range' | 'number' | 'color' | 'image' | 'video' | 'menu' | 'collection' | 'product' | 'page' | 'blog' | 'article';
|
|
15
|
+
export type Control = 'select' | 'boolean' | 'text' | 'textarea' | 'richtext' | 'url' | 'range' | 'number' | 'color' | 'image' | 'video' | 'model' | 'menu' | 'collection' | 'product' | 'page' | 'blog' | 'article' | 'list';
|
|
15
16
|
/**
|
|
16
17
|
* How a persisted setting reaches the component:
|
|
17
18
|
* prop — passed through as the typed component prop of the same name
|
|
@@ -49,6 +50,8 @@ export interface SelectField<O extends string = string> extends FieldBase<'selec
|
|
|
49
50
|
readonly optionLabels?: Readonly<Partial<Record<O, string>>>;
|
|
50
51
|
/** Saved values that are no longer options → the option they render as. */
|
|
51
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;
|
|
52
55
|
}
|
|
53
56
|
export interface BooleanField extends FieldBase<'boolean', boolean> {
|
|
54
57
|
}
|
|
@@ -66,7 +69,27 @@ export interface RangeField extends FieldBase<'range' | 'number', number> {
|
|
|
66
69
|
export type ResourceControl = 'image' | 'video' | 'menu' | 'collection' | 'product' | 'page' | 'blog' | 'article';
|
|
67
70
|
export interface ResourceField<C extends ResourceControl = ResourceControl> extends FieldBase<C, string, 'adapter'> {
|
|
68
71
|
}
|
|
69
|
-
|
|
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;
|
|
70
93
|
type Opts = {
|
|
71
94
|
legacyHidden?: boolean;
|
|
72
95
|
semantic?: string;
|
|
@@ -84,6 +107,10 @@ declare function select<const O extends string, const X extends Opts & {
|
|
|
84
107
|
}>(options: readonly O[], def: NoInfer<O>, opts: X): SelectField<O> & X;
|
|
85
108
|
declare function resource<const C extends ResourceControl>(control: C, def?: string): ResourceField<C>;
|
|
86
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>;
|
|
87
114
|
export declare const field: {
|
|
88
115
|
select: typeof select;
|
|
89
116
|
boolean: {
|
|
@@ -116,8 +143,23 @@ export declare const field: {
|
|
|
116
143
|
}): RangeField;
|
|
117
144
|
/** A number input (contract control "number") — same resolution as range. */
|
|
118
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;
|
|
119
153
|
/** A data picker: the persisted value is a handle/id; the adapter resolves it. */
|
|
120
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;
|
|
121
163
|
};
|
|
122
164
|
export type Fields = Readonly<Record<string, Field>>;
|
|
123
165
|
/** Where a schema came from: section or block, and which design family owns it. */
|
|
@@ -173,11 +215,11 @@ export type SettingsOf<S extends Schema> = {
|
|
|
173
215
|
legacyHidden: true;
|
|
174
216
|
} ? K : never]?: ValueOf<S['fields'][K]>;
|
|
175
217
|
};
|
|
176
|
-
/** The raw adapter-bound (handle) values of a schema. */
|
|
218
|
+
/** The raw adapter-bound (handle) values of a schema: a handle, or the handles of a resource list. */
|
|
177
219
|
export type HandlesOf<S extends Schema> = {
|
|
178
220
|
-readonly [K in keyof S['fields'] as S['fields'][K] extends {
|
|
179
221
|
binding: 'adapter';
|
|
180
|
-
} ? K : never]: string;
|
|
222
|
+
} ? K : never]: S['fields'][K] extends ResourceListField ? string[] : string;
|
|
181
223
|
};
|
|
182
224
|
export interface SettingIssue {
|
|
183
225
|
readonly key: string;
|
|
@@ -199,6 +241,7 @@ export interface Resolved<S extends Schema> {
|
|
|
199
241
|
* - an unknown option → the default (issue: unknown-option), never a crash
|
|
200
242
|
* - "true"/"false"/"32" strings → boolean / number (issue: coerced)
|
|
201
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)
|
|
202
245
|
*/
|
|
203
246
|
export declare function resolveSettings<S extends Schema>(schema: S, raw: Readonly<Record<string, unknown>> | undefined): Resolved<S>;
|
|
204
247
|
/** Defaults of a schema — what a brand-new section renders with. */
|
package/dist/sdk/schema.js
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
* Option IDs here are the PERSISTED IDs (what a store's saved JSON holds), never
|
|
11
11
|
* display labels. Labels come from the approved contract at display time.
|
|
12
12
|
*/
|
|
13
|
+
import { fontEditorHints, fontOptions } from './fonts.js';
|
|
14
|
+
/**
|
|
15
|
+
* The most handles a resource list holds: 50, the editor's and studio-api's cap (the reference platform's list
|
|
16
|
+
* settings take 50; the Theme ABI allows 64). A theme may set a lower `max`, never a higher one.
|
|
17
|
+
*/
|
|
18
|
+
export const RESOURCE_LIST_MAX = 50;
|
|
13
19
|
function select(options, def, opts) {
|
|
14
20
|
return { control: 'select', options, default: def, binding: 'prop', ...opts };
|
|
15
21
|
}
|
|
@@ -22,6 +28,12 @@ function simple(control) {
|
|
|
22
28
|
function resource(control, def = '', opts) {
|
|
23
29
|
return { control, default: def, binding: 'adapter', ...opts };
|
|
24
30
|
}
|
|
31
|
+
/** A hand-picked list of resources: handles in the merchant's order, at most `max` (default and cap 50). Starts empty. */
|
|
32
|
+
function resourceList(items, opts = {}) {
|
|
33
|
+
const { max, ...rest } = opts;
|
|
34
|
+
const cap = typeof max === 'number' && Number.isInteger(max) && max > 0 ? Math.min(max, RESOURCE_LIST_MAX) : RESOURCE_LIST_MAX;
|
|
35
|
+
return { control: 'list', items, max: cap, default: [], binding: 'adapter', ...rest };
|
|
36
|
+
}
|
|
25
37
|
export const field = {
|
|
26
38
|
select,
|
|
27
39
|
boolean: simple('boolean'),
|
|
@@ -37,8 +49,37 @@ export const field = {
|
|
|
37
49
|
number(def, min, max, step, opts = {}) {
|
|
38
50
|
return { control: 'number', default: def, min, max, step, binding: 'prop', ...opts };
|
|
39
51
|
},
|
|
52
|
+
/**
|
|
53
|
+
* A font (fonts.ts): the platform catalogue first, then the theme's own fonts (`themeFonts`), then the device's
|
|
54
|
+
* faces; the editor draws it as its font picker. Render it with `useFont(settings.key, themeFonts)`.
|
|
55
|
+
*/
|
|
56
|
+
font(def, opts = {}) {
|
|
57
|
+
const { themeFonts, catalogue, system, unset, weightSetting, ...rest } = opts;
|
|
58
|
+
const options = fontOptions({ themeFonts, catalogue, system, unset });
|
|
59
|
+
if (!options.some((o) => o.value === def))
|
|
60
|
+
throw new Error(`field.font: the default "${def}" is not one of its options`);
|
|
61
|
+
return {
|
|
62
|
+
control: 'select',
|
|
63
|
+
options: options.map((o) => o.value),
|
|
64
|
+
optionLabels: Object.fromEntries(options.map((o) => [o.value, o.label])),
|
|
65
|
+
default: def,
|
|
66
|
+
binding: 'prop',
|
|
67
|
+
editor: fontEditorHints(options, weightSetting),
|
|
68
|
+
...rest,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
40
71
|
/** A data picker: the persisted value is a handle/id; the adapter resolves it. */
|
|
41
72
|
resource,
|
|
73
|
+
/** A multi picker: the persisted value is a list of handles; the adapter resolves them. */
|
|
74
|
+
resourceList,
|
|
75
|
+
/**
|
|
76
|
+
* A 3D model setting (field-type registry 4, theme-abi §2.6): the editor lists the store's MODEL_3D files; the value is
|
|
77
|
+
* the .glb file's https URL. Show it with `<ModelViewer media={{ src: value }} />`. The manifest declares field-type registry 4 for it (set by
|
|
78
|
+
* `buildManifest` when the theme names none).
|
|
79
|
+
*/
|
|
80
|
+
model(opts = {}) {
|
|
81
|
+
return { control: 'model', default: '', binding: 'prop', ...opts };
|
|
82
|
+
},
|
|
42
83
|
};
|
|
43
84
|
export function defineSchema(meta, fields) {
|
|
44
85
|
return { ...meta, fields };
|
|
@@ -54,6 +95,7 @@ function snapTo(value, snap) {
|
|
|
54
95
|
* - an unknown option → the default (issue: unknown-option), never a crash
|
|
55
96
|
* - "true"/"false"/"32" strings → boolean / number (issue: coerced)
|
|
56
97
|
* - LEGACY-HIDDEN fields keep their saved value (that is the point of them)
|
|
98
|
+
* - a resource list → its non-empty handles, trimmed, in order; anything but a list → [] (issue: coerced)
|
|
57
99
|
*/
|
|
58
100
|
export function resolveSettings(schema, raw) {
|
|
59
101
|
const input = raw ?? {};
|
|
@@ -99,6 +141,11 @@ export function resolveSettings(schema, raw) {
|
|
|
99
141
|
issues.push({ key, code: 'out-of-range', value: n, resolved: clamped });
|
|
100
142
|
value = f.snap ? snapTo(clamped, f.snap) : clamped;
|
|
101
143
|
}
|
|
144
|
+
else if (f.control === 'list') {
|
|
145
|
+
if (!Array.isArray(value))
|
|
146
|
+
issues.push({ key, code: 'coerced', value, resolved: [] });
|
|
147
|
+
value = Array.isArray(value) ? value.flatMap((h) => (typeof h === 'string' && h.trim() ? [h.trim()] : [])) : [];
|
|
148
|
+
}
|
|
102
149
|
else {
|
|
103
150
|
value = typeof value === 'string' ? value : String(value ?? '');
|
|
104
151
|
}
|
|
@@ -23,5 +23,10 @@ export declare function productFor(store: StoreContext, handle: string | undefin
|
|
|
23
23
|
product: Product | null;
|
|
24
24
|
unavailable: boolean;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* The handles of a resource list (`field.resourceList('product')`) → the products, in the merchant's order. A handle
|
|
28
|
+
* the store has no product for, an unpublished or deleted one, and a repeat are left out; nothing is invented.
|
|
29
|
+
*/
|
|
30
|
+
export declare function productsFor(store: StoreContext, handles: readonly string[] | undefined): Product[];
|
|
26
31
|
/** Comma-separated collection handles (a multi-picker fallback) → links; typos and unavailable handles drop out. */
|
|
27
32
|
export declare function collectionLinksFor(store: StoreContext, handles: string): Link[];
|
package/dist/sdk/store-lookup.js
CHANGED
|
@@ -16,6 +16,25 @@ export function productFor(store, handle, fallback) {
|
|
|
16
16
|
return { product: null, unavailable: true };
|
|
17
17
|
return { product: (handle ? store.products?.[handle] : undefined) ?? fallback ?? null, unavailable: false };
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The handles of a resource list (`field.resourceList('product')`) → the products, in the merchant's order. A handle
|
|
21
|
+
* the store has no product for, an unpublished or deleted one, and a repeat are left out; nothing is invented.
|
|
22
|
+
*/
|
|
23
|
+
export function productsFor(store, handles) {
|
|
24
|
+
const out = [];
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
for (const raw of handles ?? []) {
|
|
27
|
+
const handle = typeof raw === 'string' ? raw.trim() : '';
|
|
28
|
+
if (!handle || seen.has(handle) || store.unavailableProducts?.includes(handle))
|
|
29
|
+
continue;
|
|
30
|
+
const product = store.products?.[handle];
|
|
31
|
+
if (!product)
|
|
32
|
+
continue;
|
|
33
|
+
seen.add(handle);
|
|
34
|
+
out.push(product);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
19
38
|
/** Comma-separated collection handles (a multi-picker fallback) → links; typos and unavailable handles drop out. */
|
|
20
39
|
export function collectionLinksFor(store, handles) {
|
|
21
40
|
return handles
|
package/dist/sdk/store.d.ts
CHANGED
|
@@ -67,6 +67,14 @@ export interface StoreContext {
|
|
|
67
67
|
clock?: () => number;
|
|
68
68
|
/** The shopper has not answered the cookie banner yet (the phone sticky bar waits). */
|
|
69
69
|
consentAnswered?: boolean;
|
|
70
|
+
/** The shopper's stored choice, when they made one (consent.get `known`). */
|
|
71
|
+
consentChoice?: {
|
|
72
|
+
analytics: boolean;
|
|
73
|
+
marketing: boolean;
|
|
74
|
+
preferences: boolean;
|
|
75
|
+
};
|
|
76
|
+
/** A sale-of-data opt-out applies where the shopper is (consent.get `regionRequiresOptOut`, board 35 #42). */
|
|
77
|
+
consentOptOut?: boolean;
|
|
70
78
|
/** Products by handle (product pickers). */
|
|
71
79
|
products?: Record<string, Product>;
|
|
72
80
|
/** The route's product on product templates. */
|
|
@@ -109,6 +117,13 @@ export interface StoreContext {
|
|
|
109
117
|
ugcFeed?: UgcPost[] | null;
|
|
110
118
|
/** 12G · the full cart for the cart page (the header only needs the summary above). */
|
|
111
119
|
currentCart?: Cart | null;
|
|
120
|
+
/**
|
|
121
|
+
* Whether the shopper's cart is known yet (board 35 #85): `loading` until the first `cart.get` answers (and in the
|
|
122
|
+
* server render, unless the platform resolved the cart), `failed` when that first load failed and is not retried,
|
|
123
|
+
* else `ready`. A cart not yet read is not an empty cart: a cart surface shows its loading state, never "Your cart
|
|
124
|
+
* is empty", until this is `ready`. Absent (fixtures, a host without a cart): treat as `ready`.
|
|
125
|
+
*/
|
|
126
|
+
cartStatus?: 'loading' | 'ready' | 'failed';
|
|
112
127
|
/** The checkout app — the only place Checkout goes. */
|
|
113
128
|
checkoutUrl?: string;
|
|
114
129
|
/** Why a cart permalink the store could not open sent the shopper to the cart page (`unavailable`, `failed`), else null. */
|
package/dist/sdk/sx.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ import type { CSSProperties } from 'react';
|
|
|
23
23
|
export declare const STYLE_RULES_ID = "tq-style-rules";
|
|
24
24
|
export interface StyleSink {
|
|
25
25
|
add(className: string, declarations: string): void;
|
|
26
|
+
/** A catalogue font family the render uses (fonts.ts useFont): the server imports it once. */
|
|
27
|
+
font?(family: string): void;
|
|
26
28
|
}
|
|
27
29
|
/** Declarations text of a style object (`prop:value;…`), unsafe values dropped. */
|
|
28
30
|
export declare function declarations(style: CSSProperties | Record<string, unknown>): string;
|
|
@@ -33,8 +35,11 @@ export declare function declarations(style: CSSProperties | Record<string, unkno
|
|
|
33
35
|
export declare function collectStyles<T>(render: () => T): {
|
|
34
36
|
result: T;
|
|
35
37
|
css: string;
|
|
38
|
+
fonts: string[];
|
|
36
39
|
};
|
|
37
40
|
/** `sx(style)` → a class name carrying those declarations (undefined for an empty style). */
|
|
38
41
|
export declare function sx(style: CSSProperties | Record<string, unknown> | null | undefined | false): string | undefined;
|
|
42
|
+
/** During a server render: note a catalogue font family the page uses (fonts.ts). No-op in the browser. */
|
|
43
|
+
export declare function registerFontFamily(family: string): void;
|
|
39
44
|
/** Join class names, skipping empty ones. */
|
|
40
45
|
export declare function cx(...names: Array<string | false | null | undefined>): string | undefined;
|