@tenphi/tasty 0.0.0-snapshot.d656d18 → 0.0.0-snapshot.d7129ca

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +6 -6
  2. package/dist/{babel-_RVkw0iE.d.ts → babel-DD7kdEFT.d.ts} +2 -2
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/{async-storage-DKK-wTD4.js.map → async-storage-CG5HnUT5.js.map} +1 -1
  5. package/dist/chunks/build-config-CUQVwdWF.js +42 -0
  6. package/dist/chunks/build-config-CUQVwdWF.js.map +1 -0
  7. package/dist/chunks/{collector-DBGcmUEq.js → collector-B0LTHw6Z.js} +6 -124
  8. package/dist/chunks/collector-B0LTHw6Z.js.map +1 -0
  9. package/dist/chunks/config-engine-C3pF9EK9.js +267 -0
  10. package/dist/chunks/config-engine-C3pF9EK9.js.map +1 -0
  11. package/dist/chunks/css-definitions-D_it4XZH.js +875 -0
  12. package/dist/chunks/css-definitions-D_it4XZH.js.map +1 -0
  13. package/dist/chunks/{css-resources-Cyl_axbI.js → css-resources-BN8apgxt.js} +1 -8
  14. package/dist/chunks/{css-resources-Cyl_axbI.js.map → css-resources-BN8apgxt.js.map} +1 -1
  15. package/dist/chunks/{debug-BUwqo6vC.js → debug-CiiHDgmR.js} +69 -150
  16. package/dist/chunks/debug-CiiHDgmR.js.map +1 -0
  17. package/dist/chunks/{dsl-CXvoaLnj.js → dsl-C5yuAn41.js} +62 -786
  18. package/dist/chunks/dsl-C5yuAn41.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-sH6r6Ajr.js +557 -0
  22. package/dist/chunks/react-runtime-sH6r6Ajr.js.map +1 -0
  23. package/dist/chunks/runtime-engine-BrRcOZwD.js +2438 -0
  24. package/dist/chunks/runtime-engine-BrRcOZwD.js.map +1 -0
  25. package/dist/chunks/runtime-state-BTDqSYBk.js +127 -0
  26. package/dist/chunks/runtime-state-BTDqSYBk.js.map +1 -0
  27. package/dist/chunks/{shared-utils-OIg0N_dp.js → shared-utils-DWA4LjIa.js} +24 -62
  28. package/dist/chunks/shared-utils-DWA4LjIa.js.map +1 -0
  29. package/dist/chunks/{style-engine-CqSmIlud.js → style-engine-C1ECBZxR.js} +671 -2736
  30. package/dist/chunks/style-engine-C1ECBZxR.js.map +1 -0
  31. package/dist/chunks/{css-writer-PFzrSPeu.js → zero-engine-B6EnYcXY.js} +3 -120
  32. package/dist/chunks/zero-engine-B6EnYcXY.js.map +1 -0
  33. package/dist/{collector-CVdVIy7s.d.ts → collector-YpsMjV7T.d.ts} +6 -4
  34. package/dist/{config-BI0y21JV.d.ts → config-BnZqyYG4.d.ts} +16 -25
  35. package/dist/core/index.d.ts +5 -5
  36. package/dist/core/index.js +9 -7
  37. package/dist/{index-CrT0bsiI.d.ts → index-BLJLo9cl.d.ts} +17 -50
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +10 -7
  40. package/dist/{merge-styles-BFktNP8J.d.ts → merge-styles-CTDLIrO5.d.ts} +2 -2
  41. package/dist/ssr/astro-client.js +1 -14
  42. package/dist/ssr/astro-client.js.map +1 -1
  43. package/dist/ssr/astro-middleware-static.js +0 -11
  44. package/dist/ssr/astro-middleware-static.js.map +1 -1
  45. package/dist/ssr/astro-middleware.js +0 -12
  46. package/dist/ssr/astro-middleware.js.map +1 -1
  47. package/dist/ssr/astro.js +5 -85
  48. package/dist/ssr/astro.js.map +1 -1
  49. package/dist/ssr/index.d.ts +6 -6
  50. package/dist/ssr/index.js +4 -4
  51. package/dist/ssr/next-config.d.ts +1 -1
  52. package/dist/ssr/next-config.js +29 -20
  53. package/dist/ssr/next-config.js.map +1 -1
  54. package/dist/ssr/next.d.ts +1 -1
  55. package/dist/ssr/next.js +5 -36
  56. package/dist/ssr/next.js.map +1 -1
  57. package/dist/static/index.d.ts +2 -2
  58. package/dist/static/index.js +1 -19
  59. package/dist/static/index.js.map +1 -1
  60. package/dist/{index-BzAC3p06.d.ts → types-vfRQhzRd.d.ts} +811 -811
  61. package/dist/zero/babel.d.ts +1 -1
  62. package/dist/zero/babel.js +25 -95
  63. package/dist/zero/babel.js.map +1 -1
  64. package/dist/zero/index.d.ts +1 -1
  65. package/dist/zero/index.js +1 -1
  66. package/dist/zero/next.d.ts +1 -1
  67. package/dist/zero/next.js +0 -31
  68. package/dist/zero/next.js.map +1 -1
  69. package/docs/ai-agents.md +5 -1
  70. package/docs/dsl.md +2 -2
  71. package/docs/getting-started.md +12 -11
  72. package/docs/methodology.md +2 -2
  73. package/docs/pipeline.md +3 -0
  74. package/docs/plugins.md +1 -1
  75. package/docs/runtime-benchmarks.md +105 -68
  76. package/docs/ssr.md +1 -1
  77. package/docs/styles.md +5 -5
  78. package/docs/tasty-static.md +1 -1
  79. package/package.json +29 -10
  80. package/dist/chunks/async-storage-DKK-wTD4.js +0 -44
  81. package/dist/chunks/collector-DBGcmUEq.js.map +0 -1
  82. package/dist/chunks/css-writer-PFzrSPeu.js.map +0 -1
  83. package/dist/chunks/debug-BUwqo6vC.js.map +0 -1
  84. package/dist/chunks/dsl-CXvoaLnj.js.map +0 -1
  85. package/dist/chunks/hydrate-6YoHZP6A.js +0 -37
  86. package/dist/chunks/hydrate-6YoHZP6A.js.map +0 -1
  87. package/dist/chunks/react-runtime-B3CmvDEQ.js +0 -1525
  88. package/dist/chunks/react-runtime-B3CmvDEQ.js.map +0 -1
  89. package/dist/chunks/runtime-engine-Y00VWjrS.js +0 -4719
  90. package/dist/chunks/runtime-engine-Y00VWjrS.js.map +0 -1
  91. package/dist/chunks/shared-utils-OIg0N_dp.js.map +0 -1
  92. package/dist/chunks/style-engine-CqSmIlud.js.map +0 -1
@@ -1,1525 +0,0 @@
1
- import { M as normalizeDslName, d as normalizeColorTokenValue, p as parseStyle } from "./dsl-CXvoaLnj.js";
2
- import { n as isSelector, t as mergeStyles } from "./shared-utils-OIg0N_dp.js";
3
- import { $ as getNamePrefix, A as holdKeyframes, At as extractLocalProperties, Et as makeKeyframeName, Ft as formatFunctionRule, I as keyframes, It as hasLocalFunctions, L as ownKeyframes, Lt as parseFunctionName, M as injectGlobal, Mt as parsePropertyToken, N as injectRawCSS, Nt as propHandlerRegistry, Pt as extractLocalFunctions, R as property, Rt as registerFunctionPolyfill, T as func, Tt as makeCounterStyleName, U as getConfig, X as getGlobalKeyframes, Y as getGlobalInjector, _ as referencesAnimation, _t as closeBatchWindow, a as resolveRecipes, bt as openBatchWindow, c as formatPropertyCSS, ct as extractLocalCounterStyle, dt as extractLocalFontFace, et as hasGlobalKeyframes, f as extractAnimationNamesFromStyles, ft as fontFaceContentHash, g as mergeKeyframes, gt as PropertyTypeResolver, h as hasLocalKeyframes, i as cacheWrapper, j as inject, jt as hasLocalProperties, kt as hashString, l as getRegisteredSSRCollector, lt as formatCounterStyleRule, m as filterUsedKeyframes, mt as hasLocalFontFace, n as createClientState, o as formatRules, p as extractLocalKeyframes, pt as formatFontFaceRule, r as formatGlobalRules, rt as isFunctionsPolyfillEnabled, s as formatKeyframesCSS, t as depsEqual, ut as hasLocalCounterStyle, v as replaceAnimationNames, w as fontFace, wt as makeClassName, x as counterStyle, y as resolveKeyframesNames, z as touch, zt as registerLocalFunctionPolyfills } from "./runtime-engine-Y00VWjrS.js";
4
- import { S as camelToKebab, b as renderStyles, i as baseStylePropsRegistry, n as generateChunkCacheKey, r as categorizeStyleKeys, s as BASE_STYLES, t as renderStylesForChunk } from "./style-engine-CqSmIlud.js";
5
- import { Fragment, cache, createContext, createElement, forwardRef, useContext, useInsertionEffect } from "react";
6
- //#region src/rsc-cache.ts
7
- /**
8
- * Shared RSC (React Server Components) inline style cache.
9
- *
10
- * Uses React.cache for per-request memoization in Server Components.
11
- * Both computeStyles() and standalone style functions (useGlobalStyles,
12
- * useRawCSS, useKeyframes, useProperty, useFontFace, useCounterStyle)
13
- * share this cache so that CSS accumulated by standalone functions is
14
- * flushed into inline <style> tags by the next tasty() component.
15
- */
16
- /**
17
- * Per-request RSC style cache using React.cache.
18
- * React.cache provides per-request memoization in Server Components,
19
- * so each request gets its own isolated cache.
20
- */
21
- const getRSCCache = cache(() => ({
22
- cacheKeyToClassName: /* @__PURE__ */ new Map(),
23
- emittedKeys: /* @__PURE__ */ new Set(),
24
- internalsEmitted: false,
25
- pendingCSS: [],
26
- keyToIndex: /* @__PURE__ */ new Map(),
27
- generatedNames: /* @__PURE__ */ new Map()
28
- }));
29
- function rscAllocateClassName(rscCache, cacheKey) {
30
- const existing = rscCache.cacheKeyToClassName.get(cacheKey);
31
- if (existing) return {
32
- className: existing,
33
- isNew: false
34
- };
35
- const className = makeClassName(getNamePrefix(), hashString(cacheKey));
36
- rscCache.cacheKeyToClassName.set(cacheKey, className);
37
- return {
38
- className,
39
- isNew: true
40
- };
41
- }
42
- /**
43
- * Flush any pending CSS accumulated by standalone functions.
44
- * Returns the CSS string and clears the buffer.
45
- */
46
- function flushPendingCSS(rscCache) {
47
- if (rscCache.pendingCSS.length === 0) return "";
48
- const css = rscCache.pendingCSS.join("\n");
49
- rscCache.pendingCSS.length = 0;
50
- rscCache.keyToIndex.clear();
51
- return css;
52
- }
53
- /**
54
- * Push CSS into the RSC pending buffer with dedup via emittedKeys.
55
- * Returns true if the CSS was added, false if it was already emitted.
56
- *
57
- * Pass `replace` for slot-keyed entries (an explicit `id`), where the last write
58
- * must win to match the client's update-tracking behavior. If the slot has
59
- * already been flushed into a `<style>` tag the new CSS is appended instead,
60
- * which still wins by cascade order.
61
- */
62
- function pushRSCCSS(rscCache, key, css, replace) {
63
- if (replace) {
64
- const pendingIndex = rscCache.keyToIndex.get(key);
65
- if (pendingIndex !== void 0) {
66
- rscCache.pendingCSS[pendingIndex] = css;
67
- return true;
68
- }
69
- } else if (rscCache.emittedKeys.has(key)) return false;
70
- rscCache.emittedKeys.add(key);
71
- rscCache.keyToIndex.set(key, rscCache.pendingCSS.length);
72
- rscCache.pendingCSS.push(css);
73
- return true;
74
- }
75
- /**
76
- * Determine the current style injection target.
77
- * Centralizes the three-way detection (SSR collector / RSC cache / client DOM)
78
- * used by all style functions.
79
- */
80
- function getStyleTarget() {
81
- const collector = getRegisteredSSRCollector();
82
- if (collector) return {
83
- mode: "ssr",
84
- collector
85
- };
86
- if (typeof document === "undefined") return {
87
- mode: "rsc",
88
- cache: getRSCCache()
89
- };
90
- return { mode: "client" };
91
- }
92
- //#endregion
93
- //#region src/ssr/collect-auto-properties.ts
94
- /**
95
- * Scan rendered rules for auto-inferable custom properties and emit
96
- * @property CSS via the provided callback.
97
- */
98
- function scanAndEmitAutoProperties(rules, styles, emit) {
99
- const registered = /* @__PURE__ */ new Set();
100
- if (styles) {
101
- const localProps = styles["@property"];
102
- if (localProps && typeof localProps === "object") for (const token of Object.keys(localProps)) {
103
- const parsed = parsePropertyToken(token);
104
- if (parsed.isValid) registered.add(parsed.cssName);
105
- }
106
- }
107
- const resolver = new PropertyTypeResolver();
108
- for (const rule of rules) {
109
- if (!rule.declarations) continue;
110
- resolver.scanDeclarations(rule.declarations, (name) => registered.has(name), (name, syntax, initialValue) => {
111
- registered.add(name);
112
- const css = formatPropertyCSS(name, {
113
- syntax,
114
- inherits: true,
115
- initialValue
116
- });
117
- if (css) emit(name, css);
118
- });
119
- }
120
- }
121
- /**
122
- * Scan rendered rules for custom property declarations and collect
123
- * auto-inferred @property rules via the SSR collector.
124
- *
125
- * @param rules - Rendered style rules containing CSS declarations
126
- * @param collector - SSR collector to emit @property CSS into
127
- * @param styles - Original styles object (used to skip explicit @property)
128
- */
129
- function collectAutoInferredProperties(rules, collector, styles) {
130
- scanAndEmitAutoProperties(rules, styles, (name, css) => {
131
- collector.collectProperty(`__auto:${name}`, css);
132
- });
133
- }
134
- /**
135
- * RSC variant: scan rendered rules and push auto-inferred @property CSS
136
- * into the RSC pending buffer.
137
- */
138
- function collectAutoInferredPropertiesRSC(rules, rscCache, styles) {
139
- scanAndEmitAutoProperties(rules, styles, (name, css) => {
140
- pushRSCCSS(rscCache, `__auto:${name}`, css);
141
- });
142
- }
143
- //#endregion
144
- //#region src/utils/has-keys.ts
145
- /**
146
- * Check if an object has any own enumerable keys.
147
- * Avoids the array allocation of Object.keys(obj).length > 0.
148
- */
149
- function hasKeys(obj) {
150
- for (const _ in obj) return true;
151
- return false;
152
- }
153
- //#endregion
154
- //#region src/compute-styles.ts
155
- /**
156
- * Hook-free, synchronous style computation.
157
- *
158
- * Extracts the core logic from useStyles() into a plain function that can
159
- * be called during React render without any hooks. Three code paths:
160
- *
161
- * 1. SSR collector — styles collected via ServerStyleCollector
162
- * 2. Client inject — styles injected synchronously into the DOM
163
- * 3. RSC inline — styles returned as CSS strings for inline <style> emission
164
- *
165
- * This enables tasty() components to work as React Server Components.
166
- */
167
- const EMPTY_RESULT = { className: "" };
168
- /**
169
- * Mark internals as emitted for this RSC request.
170
- *
171
- * Internals (tokens, @property, @font-face, @counter-style) are emitted
172
- * exclusively by the SSR collector via ServerStyleCollector.collectInternals().
173
- * The SSR path is reliable because TastyRegistry is always present as a
174
- * client component in the root layout, guaranteeing SSR runs for every page.
175
- *
176
- * Previously this function also emitted internals and coordinated with SSR
177
- * via a globalThis flag, but that flag leaked across requests in the same
178
- * Node.js process, causing pages without RSC-rendered tasty components
179
- * (e.g. the playground route) to lose all token CSS.
180
- */
181
- function collectInternalsRSC(rscCache) {
182
- if (rscCache.internalsEmitted) return "";
183
- rscCache.internalsEmitted = true;
184
- return "";
185
- }
186
- /**
187
- * Collect per-component ancillary CSS (keyframes, @property, font-face,
188
- * counter-style) for RSC mode.
189
- */
190
- function collectAncillaryRSC(rscCache, styles) {
191
- const parts = [];
192
- const usedKf = getUsedKeyframes(styles);
193
- const rscKeyframeNames = usedKf ? resolveKeyframesNames(usedKf) : null;
194
- if (usedKf && rscKeyframeNames) for (const [authored, steps] of Object.entries(usedKf)) {
195
- const name = rscKeyframeNames.get(authored);
196
- const key = `__kf:${name}`;
197
- if (!rscCache.emittedKeys.has(key)) {
198
- rscCache.emittedKeys.add(key);
199
- parts.push(formatKeyframesCSS(name, steps));
200
- }
201
- }
202
- if (hasLocalProperties(styles)) {
203
- const localProperties = extractLocalProperties(styles);
204
- if (localProperties) for (const [token, definition] of Object.entries(localProperties)) {
205
- const key = `__prop:${token}`;
206
- if (!rscCache.emittedKeys.has(key)) {
207
- rscCache.emittedKeys.add(key);
208
- const css = formatPropertyCSS(token, definition);
209
- if (css) parts.push(css);
210
- }
211
- }
212
- }
213
- if (hasLocalFontFace(styles)) {
214
- const localFontFace = extractLocalFontFace(styles);
215
- if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
216
- const descriptors = Array.isArray(input) ? input : [input];
217
- for (const desc of descriptors) {
218
- const key = `__ff:${fontFaceContentHash(family, desc)}`;
219
- if (!rscCache.emittedKeys.has(key)) {
220
- rscCache.emittedKeys.add(key);
221
- parts.push(formatFontFaceRule(family, desc));
222
- }
223
- }
224
- }
225
- }
226
- if (hasLocalCounterStyle(styles)) {
227
- const localCounterStyle = extractLocalCounterStyle(styles);
228
- if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) {
229
- const key = `__cs:${name}:${JSON.stringify(descriptors)}`;
230
- if (!rscCache.emittedKeys.has(key)) {
231
- rscCache.emittedKeys.add(key);
232
- parts.push(formatCounterStyleRule(name, descriptors));
233
- }
234
- }
235
- }
236
- if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
237
- const localFunctions = extractLocalFunctions(styles);
238
- if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) {
239
- const key = `__func:${parseFunctionName(name)}`;
240
- if (!rscCache.emittedKeys.has(key)) {
241
- rscCache.emittedKeys.add(key);
242
- parts.push(formatFunctionRule(name, definition));
243
- }
244
- }
245
- }
246
- return parts.join("\n");
247
- }
248
- /**
249
- * Process all chunks in RSC mode: render CSS to strings, allocate classNames,
250
- * and return combined { className, css }.
251
- */
252
- function computeStylesRSC(styles, chunkMap, stableStyles) {
253
- const rscCache = getRSCCache();
254
- const cssParts = [];
255
- const classNames = [];
256
- const rscUsedKf = getUsedKeyframes(styles);
257
- const rscKeyframeNames = rscUsedKf ? resolveKeyframesNames(rscUsedKf) : null;
258
- const pendingCSS = flushPendingCSS(rscCache);
259
- if (pendingCSS) cssParts.push(pendingCSS);
260
- const internalsCSS = collectInternalsRSC(rscCache);
261
- if (internalsCSS) cssParts.push(internalsCSS);
262
- for (const [chunkName, chunkStyleKeys] of chunkMap) {
263
- if (chunkStyleKeys.length === 0) continue;
264
- const baseKey = generateChunkCacheKey(styles, chunkName, chunkStyleKeys, stableStyles);
265
- const renderResult = renderStylesForChunk(styles, chunkName, chunkStyleKeys);
266
- if (renderResult.rules.length === 0) continue;
267
- const { rules, cacheKey } = applyKeyframeNames(renderResult.rules, baseKey, rscKeyframeNames);
268
- const { className, isNew } = rscAllocateClassName(rscCache, cacheKey);
269
- classNames.push(className);
270
- if (isNew) {
271
- const css = formatRules(rules, className);
272
- if (css) cssParts.push(css);
273
- }
274
- }
275
- const ancillaryCSS = collectAncillaryRSC(rscCache, styles);
276
- if (ancillaryCSS) cssParts.push(ancillaryCSS);
277
- if (classNames.length === 0) return EMPTY_RESULT;
278
- const css = cssParts.join("\n");
279
- return {
280
- className: classNames.join(" "),
281
- css: css || void 0
282
- };
283
- }
284
- /**
285
- * Get keyframes that are actually used in styles.
286
- * Returns null if no keyframes are used (fast path for zero overhead).
287
- */
288
- function getUsedKeyframes(styles) {
289
- const hasLocal = hasLocalKeyframes(styles);
290
- const hasGlobal = hasGlobalKeyframes();
291
- if (!hasLocal && !hasGlobal) return null;
292
- const usedNames = extractAnimationNamesFromStyles(styles);
293
- if (usedNames.size === 0) return null;
294
- return filterUsedKeyframes(mergeKeyframes(hasLocal ? extractLocalKeyframes(styles) : null, hasGlobal ? getGlobalKeyframes() : null), usedNames);
295
- }
296
- /**
297
- * Process a chunk on the SSR path: allocate via collector, render, collect CSS.
298
- */
299
- function processChunkSSR(collector, styles, chunkName, styleKeys, stableStyles, keyframeNames) {
300
- if (styleKeys.length === 0) return null;
301
- const baseKey = generateChunkCacheKey(styles, chunkName, styleKeys, stableStyles);
302
- const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);
303
- if (renderResult.rules.length === 0) return null;
304
- const { animations, rules, cacheKey } = applyKeyframeNames(renderResult.rules, baseKey, keyframeNames);
305
- const { className, isNewAllocation } = collector.allocateClassName(cacheKey);
306
- if (isNewAllocation) {
307
- collector.collectChunk(cacheKey, className, rules);
308
- return {
309
- name: chunkName,
310
- styleKeys,
311
- cacheKey,
312
- renderResult: {
313
- ...renderResult,
314
- rules
315
- },
316
- className,
317
- animations
318
- };
319
- }
320
- return {
321
- name: chunkName,
322
- styleKeys,
323
- cacheKey,
324
- renderResult: { rules: [] },
325
- className
326
- };
327
- }
328
- /**
329
- * Point a chunk's rules at the resolved keyframe names, and fold those names
330
- * into its cache key.
331
- *
332
- * Both halves matter, and both have to happen before the rules are written
333
- * anywhere: the declarations have to name the animation that will exist, and
334
- * the key has to distinguish two components that authored the same shorthand
335
- * over different definitions. Shared by the client and the server so they
336
- * cannot disagree about either.
337
- */
338
- function applyKeyframeNames(ruleset, baseKey, keyframeNames) {
339
- if (!keyframeNames || keyframeNames.size === 0) return {
340
- animations: [],
341
- rules: ruleset,
342
- cacheKey: baseKey
343
- };
344
- const animations = [...keyframeNames.keys()].filter((authored) => ruleset.some((rule) => referencesAnimation(rule.declarations, authored)));
345
- if (animations.length === 0) return {
346
- animations,
347
- rules: ruleset,
348
- cacheKey: baseKey
349
- };
350
- return {
351
- animations,
352
- rules: ruleset.map((rule) => ({
353
- ...rule,
354
- declarations: replaceAnimationNames(rule.declarations, keyframeNames)
355
- })),
356
- cacheKey: `${baseKey}\u0000kf:${animations.map((authored) => `${authored}=${keyframeNames.get(authored)}`).sort().join(",")}`
357
- };
358
- }
359
- /**
360
- * Process a chunk on the client: render, allocate className, and inject
361
- * CSS synchronously. The injector's cache makes this idempotent.
362
- */
363
- function processChunkSync(styles, chunkName, styleKeys, stableStyles, root, keyframeNames) {
364
- if (styleKeys.length === 0) return null;
365
- const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys, stableStyles);
366
- const renderResult = renderStylesForChunk(styles, chunkName, styleKeys, cacheKey);
367
- if (renderResult.rules.length === 0) return null;
368
- const { animations, rules, cacheKey: injectKey } = applyKeyframeNames(renderResult.rules, cacheKey, keyframeNames);
369
- const { className } = inject(rules, {
370
- cacheKey: injectKey,
371
- root,
372
- pin: false
373
- });
374
- return {
375
- name: chunkName,
376
- styleKeys,
377
- cacheKey: injectKey,
378
- renderResult: {
379
- ...renderResult,
380
- rules
381
- },
382
- className,
383
- animations
384
- };
385
- }
386
- /**
387
- * Inject all ancillary rules (properties, font-faces, counter-styles) synchronously.
388
- */
389
- function injectAncillarySync(styles, root) {
390
- if (hasLocalProperties(styles)) {
391
- const localProperties = extractLocalProperties(styles);
392
- if (localProperties) for (const [token, definition] of Object.entries(localProperties)) property(token, {
393
- ...definition,
394
- root
395
- });
396
- }
397
- if (hasLocalFontFace(styles)) {
398
- const localFontFace = extractLocalFontFace(styles);
399
- if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
400
- const descriptors = Array.isArray(input) ? input : [input];
401
- for (const desc of descriptors) fontFace(family, desc, { root });
402
- }
403
- }
404
- if (hasLocalCounterStyle(styles)) {
405
- const localCounterStyle = extractLocalCounterStyle(styles);
406
- if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) counterStyle(name, descriptors, { root });
407
- }
408
- if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
409
- const localFunctions = extractLocalFunctions(styles);
410
- if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) func(name, definition, { root });
411
- }
412
- }
413
- /**
414
- * Collect all ancillary rules into the SSR collector.
415
- */
416
- function collectAncillarySSR(collector, styles, chunks) {
417
- const usedKf = getUsedKeyframes(styles);
418
- if (usedKf) {
419
- const names = resolveKeyframesNames(usedKf);
420
- for (const [authored, steps] of Object.entries(usedKf)) {
421
- const name = names.get(authored);
422
- collector.collectKeyframes(name, formatKeyframesCSS(name, steps));
423
- }
424
- }
425
- if (hasLocalProperties(styles)) {
426
- const localProperties = extractLocalProperties(styles);
427
- if (localProperties) for (const [token, definition] of Object.entries(localProperties)) {
428
- const css = formatPropertyCSS(token, definition);
429
- if (css) collector.collectProperty(token, css);
430
- }
431
- }
432
- if (hasLocalFontFace(styles)) {
433
- const localFontFace = extractLocalFontFace(styles);
434
- if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
435
- const descriptors = Array.isArray(input) ? input : [input];
436
- for (const desc of descriptors) {
437
- const hash = fontFaceContentHash(family, desc);
438
- const css = formatFontFaceRule(family, desc);
439
- collector.collectFontFace(hash, css);
440
- }
441
- }
442
- }
443
- if (hasLocalCounterStyle(styles)) {
444
- const localCounterStyle = extractLocalCounterStyle(styles);
445
- if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) {
446
- const css = formatCounterStyleRule(name, descriptors);
447
- collector.collectCounterStyle(name, css);
448
- }
449
- }
450
- if (!isFunctionsPolyfillEnabled() && hasLocalFunctions(styles)) {
451
- const localFunctions = extractLocalFunctions(styles);
452
- if (localFunctions) for (const [name, definition] of Object.entries(localFunctions)) {
453
- const css = formatFunctionRule(name, definition);
454
- collector.collectFunction(parseFunctionName(name), css);
455
- }
456
- }
457
- if (getConfig().autoPropertyTypes !== false) {
458
- const allRules = chunks.flatMap((c) => c.renderResult.rules);
459
- if (allRules.length > 0) collectAutoInferredProperties(allRules, collector, styles);
460
- }
461
- }
462
- /**
463
- * Synchronous, hook-free style computation.
464
- *
465
- * Resolves recipes, categorizes style keys into chunks, renders CSS rules,
466
- * allocates class names, and injects / collects / returns the CSS.
467
- *
468
- * Three code paths:
469
- * 1. SSR collector — discovered via ALS or passed explicitly; CSS collected
470
- * 2. RSC inline — no collector and no `document`; CSS returned as `result.css`
471
- * for the caller to emit as an inline `<style>` tag
472
- * 3. Client inject — CSS injected synchronously into the DOM (idempotent)
473
- *
474
- * @param styles - Tasty styles object (or undefined for no styles)
475
- * @param options - Optional SSR collector override
476
- */
477
- function computeStyles(styles, options) {
478
- if (!styles || !hasKeys(styles)) return EMPTY_RESULT;
479
- const resolved = resolveRecipes(styles);
480
- const stableStyles = options?.stableStyles === true && resolved === styles;
481
- if (isFunctionsPolyfillEnabled() && hasLocalFunctions(resolved)) registerLocalFunctionPolyfills(resolved);
482
- const chunkMap = categorizeStyleKeys(resolved);
483
- const collector = options?.ssrCollector !== void 0 ? options.ssrCollector : getRegisteredSSRCollector();
484
- const chunks = [];
485
- if (collector) {
486
- collector.collectInternals();
487
- const ssrKf = getUsedKeyframes(resolved);
488
- const ssrKeyframeNames = ssrKf ? resolveKeyframesNames(ssrKf) : null;
489
- for (const [chunkName, chunkStyleKeys] of chunkMap) {
490
- const chunk = processChunkSSR(collector, resolved, chunkName, chunkStyleKeys, stableStyles, ssrKeyframeNames);
491
- if (chunk) chunks.push(chunk);
492
- }
493
- collectAncillarySSR(collector, resolved, chunks);
494
- } else if (typeof document === "undefined") return computeStylesRSC(resolved, chunkMap, stableStyles);
495
- else {
496
- const root = options?.root;
497
- injectAncillarySync(resolved, root);
498
- const usedKf = getUsedKeyframes(resolved);
499
- const keyframeNames = usedKf ? resolveKeyframesNames(usedKf) : null;
500
- const keyframeKeys = usedKf && keyframeNames ? holdKeyframes(usedKf, keyframeNames, { root }) : null;
501
- for (const [chunkName, chunkStyleKeys] of chunkMap) {
502
- const chunk = processChunkSync(resolved, chunkName, chunkStyleKeys, stableStyles, root, keyframeNames);
503
- if (chunk) chunks.push(chunk);
504
- }
505
- if (keyframeKeys) for (const chunk of chunks) for (const authored of chunk.animations ?? []) {
506
- const key = keyframeKeys.get(authored);
507
- if (key) ownKeyframes(key, chunk.className, { root });
508
- }
509
- for (const chunk of chunks) touch(chunk.className, { root });
510
- }
511
- if (chunks.length === 0) return EMPTY_RESULT;
512
- if (chunks.length === 1) return { className: chunks[0].className };
513
- return { className: chunks.map((c) => c.className).join(" ") };
514
- }
515
- //#endregion
516
- //#region src/utils/filter-base-props.ts
517
- const DOMPropNames = new Set(["id"]);
518
- const BasePropNames = new Set([
519
- "role",
520
- "as",
521
- "element",
522
- "css",
523
- "qa",
524
- "mods",
525
- "qaVal",
526
- "hidden",
527
- "isHidden",
528
- "disabled",
529
- "isDisabled",
530
- "children",
531
- "style",
532
- "className",
533
- "href",
534
- "target",
535
- "tabIndex"
536
- ]);
537
- const ignoreEventPropsNames = new Set([
538
- "onPress",
539
- "onHoverStart",
540
- "onHoverEnd",
541
- "onPressStart",
542
- "onPressEnd"
543
- ]);
544
- const propRe = /^((data-).*)$/;
545
- const eventRe = /^on[A-Z].+$/;
546
- /**
547
- * Filters out all props that aren't valid DOM props or defined via override prop obj.
548
- * @param props - The component props to be filtered.
549
- * @param opts - Props to override.
550
- */
551
- function filterBaseProps(props, opts = {}) {
552
- const { propNames, eventProps } = opts;
553
- const filteredProps = {};
554
- for (const prop in props) if (Object.prototype.hasOwnProperty.call(props, prop) && (DOMPropNames.has(prop) || BasePropNames.has(prop) || prop.startsWith("aria-") || eventProps && eventRe.test(prop) && !ignoreEventPropsNames.has(prop) || propNames?.has(prop) || propRe.test(prop))) filteredProps[prop] = props[prop];
555
- return filteredProps;
556
- }
557
- //#endregion
558
- //#region src/utils/mod-attrs.ts
559
- function modAttrs(map) {
560
- return map ? Object.keys(map).reduce((attrs, key) => {
561
- const value = map[key];
562
- if (value == null || value === false) return attrs;
563
- const attrName = `data-${camelToKebab(key)}`;
564
- if (value === true) attrs[attrName] = "";
565
- else if (typeof value === "string") attrs[attrName] = value;
566
- else if (typeof value === "number") attrs[attrName] = String(value);
567
- else console.warn(`[Tasty] Invalid mod value for "${key}". Expected boolean, string, or number, got ${typeof value}`);
568
- return attrs;
569
- }, {}) : null;
570
- }
571
- const _modAttrs = cacheWrapper(modAttrs);
572
- //#endregion
573
- //#region src/utils/process-tokens.ts
574
- /**
575
- * Check if a value is a valid token value (string, number, or boolean - not object).
576
- * Returns false for `false` values (they mean "skip this token").
577
- */
578
- function isValidTokenValue(value) {
579
- if (value === void 0 || value === null || value === false) return false;
580
- if (typeof value === "object") {
581
- console.warn("[Tasty] Object values are not allowed in tokens prop. Tokens do not support state-based styling. Use a primitive value instead.");
582
- return false;
583
- }
584
- return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
585
- }
586
- /**
587
- * Process a single token value through the tasty parser.
588
- * Numbers are converted to strings; 0 stays as "0".
589
- */
590
- function processTokenValue(value) {
591
- if (typeof value === "number") {
592
- if (value === 0) return "0";
593
- return parseStyle(String(value)).output;
594
- }
595
- return parseStyle(value).output;
596
- }
597
- /**
598
- * Resolve one `$name` / `#name` entry to the custom property it declares and
599
- * the value to declare, or `null` when the entry declares nothing.
600
- *
601
- * The two sigils differ only in the property name they build and in how `true`
602
- * is read: for a custom property it is the empty value, for a color it is
603
- * `transparent`.
604
- */
605
- function resolveTokenEntry(key, value) {
606
- const name = `--${normalizeDslName(key.slice(1))}`;
607
- if (key[0] === "$") return [name, processTokenValue(value === true ? "" : value)];
608
- const colorValue = normalizeColorTokenValue(value);
609
- if (colorValue === null) return null;
610
- return [`${name}-color`, processTokenValue(colorValue)];
611
- }
612
- /**
613
- * Process tokens object into inline style properties.
614
- * - `$name` -> `--name` with the parsed value
615
- * - `#name` -> `--name-color` with the parsed value
616
- *
617
- * @param tokens - The tokens object to process
618
- * @returns CSSProperties object or undefined if no tokens to process
619
- */
620
- function processTokens(tokens) {
621
- if (!tokens) return;
622
- const keys = Object.keys(tokens);
623
- if (keys.length === 0) return;
624
- let result;
625
- for (const key of keys) {
626
- const value = tokens[key];
627
- if (!isValidTokenValue(value)) continue;
628
- if (key[0] !== "$" && key[0] !== "#") continue;
629
- const entry = resolveTokenEntry(key, value);
630
- if (!entry) continue;
631
- if (!result) result = {};
632
- result[entry[0]] = entry[1];
633
- }
634
- return result;
635
- }
636
- //#endregion
637
- //#region src/utils/get-display-name.ts
638
- const DEFAULT_NAME = "Anonymous";
639
- function getDisplayName(Component, fallbackName = DEFAULT_NAME) {
640
- if (typeof Component === "function") return Component.displayName ?? Component.name ?? fallbackName;
641
- return fallbackName;
642
- }
643
- //#endregion
644
- //#region src/utils/is-valid-element-type.ts
645
- /**
646
- * Lightweight replacement for `react-is`'s isValidElementType.
647
- * Detects string tags, function/class components, and React exotic types
648
- * (forwardRef, memo, lazy, etc.) via their internal $$typeof symbol.
649
- */
650
- function isValidElementType(value) {
651
- if (typeof value === "string" || typeof value === "function") return true;
652
- if (typeof value === "object" && value !== null) return typeof value.$$typeof === "symbol";
653
- return false;
654
- }
655
- //#endregion
656
- //#region src/tasty.tsx
657
- /**
658
- * Precalculated entries for performance optimization
659
- */
660
- const IS_PROPERTIES_ENTRIES = Object.entries({
661
- isDisabled: "disabled",
662
- isHidden: "hidden",
663
- isChecked: "checked"
664
- });
665
- /**
666
- * Helper function to handle is* properties consistently
667
- * Transforms is* props to HTML attributes and adds corresponding data-* attributes
668
- */
669
- function handleIsProperties(props) {
670
- for (const [isProperty, targetAttribute] of IS_PROPERTIES_ENTRIES) {
671
- if (isProperty in props) {
672
- props[targetAttribute] = props[isProperty];
673
- delete props[isProperty];
674
- }
675
- const dataAttribute = `data-${targetAttribute}`;
676
- if (!(dataAttribute in props) && props[targetAttribute]) props[dataAttribute] = "";
677
- }
678
- }
679
- /**
680
- * Creates a sub-element component for compound component patterns.
681
- * Sub-elements are lightweight components with data-element attribute for CSS targeting.
682
- */
683
- function createSubElement(elementName, definition) {
684
- const config = typeof definition === "string" ? { as: definition } : definition;
685
- const tag = config.as ?? "div";
686
- const defaultQa = config.qa;
687
- const defaultQaVal = config.qaVal;
688
- const SubElement = forwardRef((props, ref) => {
689
- const { qa, qaVal, mods, tokens, isDisabled, isHidden, isChecked, className, style, ...htmlProps } = props;
690
- let modDataAttrs;
691
- if (mods) modDataAttrs = _modAttrs(mods);
692
- const tokenStyle = tokens ? processTokens(tokens) : void 0;
693
- let mergedStyle;
694
- if (tokenStyle || style) mergedStyle = tokenStyle && style ? {
695
- ...tokenStyle,
696
- ...style
697
- } : tokenStyle ?? style;
698
- const elementProps = {
699
- "data-element": elementName,
700
- "data-qa": qa ?? defaultQa,
701
- "data-qaval": qaVal ?? defaultQaVal,
702
- ...modDataAttrs || {},
703
- ...htmlProps,
704
- className,
705
- style: mergedStyle,
706
- isDisabled,
707
- isHidden,
708
- isChecked,
709
- ref
710
- };
711
- handleIsProperties(elementProps);
712
- if (elementProps["data-qa"] === void 0) delete elementProps["data-qa"];
713
- if (elementProps["data-qaval"] === void 0) delete elementProps["data-qaval"];
714
- return createElement(tag, elementProps);
715
- });
716
- SubElement.displayName = `SubElement(${elementName})`;
717
- return SubElement;
718
- }
719
- /**
720
- * Pre-compute the mapping from prop name to token key at component-creation time.
721
- * Array form: `'progress'` -> `'$progress'`, `'accentColor'` -> `'#accent'`.
722
- * Object form: entries used as-is.
723
- */
724
- function buildTokenPropsMapping(def) {
725
- if (Array.isArray(def)) return def.map((propName) => {
726
- if (propName.endsWith("Color") && propName.length > 5) return [propName, `#${propName.slice(0, -5)}`];
727
- return [propName, `$${propName}`];
728
- });
729
- return Object.entries(def);
730
- }
731
- function tasty(Component, options) {
732
- if (isValidElementType(Component)) return tastyWrap(Component, options);
733
- return tastyElement(Component);
734
- }
735
- function tastyWrap(Component, options) {
736
- const { as: extendTag, element: extendElement, styleProps: _styleProps, modProps: _modProps, tokenProps: _tokenProps, variants: _variants, elements: _elements, ...defaultProps } = options ?? {};
737
- const propsWithStyles = ["styles"].concat(Object.keys(defaultProps).filter((prop) => prop.endsWith("Styles")));
738
- const _WrappedComponent = forwardRef((props, ref) => {
739
- const { as, element, ...restProps } = props;
740
- const mergedStylesMap = propsWithStyles.reduce((map, prop) => {
741
- const restValue = restProps[prop];
742
- const defaultValue = defaultProps[prop];
743
- if (restValue != null && defaultValue != null) map[prop] = mergeStyles(defaultValue, restValue);
744
- else map[prop] = restValue ?? defaultValue;
745
- return map;
746
- }, {});
747
- return createElement(Component, {
748
- ...defaultProps,
749
- ...restProps,
750
- ...mergedStylesMap,
751
- as: as ?? extendTag,
752
- element: element || extendElement,
753
- ref
754
- });
755
- });
756
- _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(Component, defaultProps.qa ?? extendTag ?? "Anonymous")})`;
757
- return _WrappedComponent;
758
- }
759
- function tastyElement(tastyOptions) {
760
- const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
761
- let variantStylesMap;
762
- if (variants) {
763
- let baseStyles = defaultStyles;
764
- let extensionStyles;
765
- if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
766
- if (isSelector(key)) continue;
767
- const value = defaultStyles[key];
768
- if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
769
- if (!extensionStyles) {
770
- baseStyles = { ...defaultStyles };
771
- extensionStyles = {};
772
- }
773
- extensionStyles[key] = value;
774
- delete baseStyles[key];
775
- }
776
- }
777
- variantStylesMap = Object.entries(variants).reduce((map, [variant, variantStyles]) => {
778
- map[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
779
- return map;
780
- }, {});
781
- if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
782
- }
783
- const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps ?? {};
784
- const ownPropsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
785
- let propsToCheck = ownPropsToCheck;
786
- let propsToCheckVersion = -1;
787
- const modPropsKeys = modPropsDef ? Array.isArray(modPropsDef) ? modPropsDef : Object.keys(modPropsDef) : void 0;
788
- const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
789
- const classNameCache = /* @__PURE__ */ new Map();
790
- const STABLE_STYLES = { stableStyles: true };
791
- const _TastyComponent = forwardRef((incomingProps, ref) => {
792
- const applyPropHandlers = propHandlerRegistry.apply;
793
- const { as, styles: rawStyles, variant, mods, element, qa, qaVal, className: userClassName, tokens, style, theme, ...otherProps } = applyPropHandlers ? applyPropHandlers(incomingProps) : incomingProps;
794
- let styles = rawStyles;
795
- let propStyles = null;
796
- if (propsToCheckVersion !== baseStylePropsRegistry.version) {
797
- const promoted = baseStylePropsRegistry.list;
798
- propsToCheck = promoted.length === 0 ? ownPropsToCheck : ownPropsToCheck.concat(promoted);
799
- propsToCheckVersion = baseStylePropsRegistry.version;
800
- }
801
- for (const prop of propsToCheck) {
802
- const key = prop;
803
- if (key in otherProps) {
804
- if (!propStyles) propStyles = {};
805
- const value = otherProps[key];
806
- propStyles[key] = value;
807
- delete otherProps[key];
808
- }
809
- }
810
- if (!styles || styles && !hasKeys(styles)) styles = void 0;
811
- let propMods;
812
- if (modPropsKeys) {
813
- for (const key of modPropsKeys) if (key in otherProps) {
814
- if (!propMods) propMods = {};
815
- propMods[key] = otherProps[key];
816
- delete otherProps[key];
817
- }
818
- }
819
- let propTokens;
820
- if (tokenPropsMapping) {
821
- for (const [propName, tokenKey] of tokenPropsMapping) if (propName in otherProps) {
822
- if (!propTokens) propTokens = {};
823
- propTokens[tokenKey] = otherProps[propName];
824
- delete otherProps[propName];
825
- }
826
- }
827
- const baseStyles = variantStylesMap ? variantStylesMap[variant || "default"] ?? variantStylesMap["default"] : defaultStyles;
828
- const hasInstanceStyles = styles && hasKeys(styles);
829
- const hasPropStyles = propStyles && hasKeys(propStyles);
830
- const allStyles = hasInstanceStyles || hasPropStyles ? mergeStyles(baseStyles, styles, propStyles) : baseStyles;
831
- const useFactoryCache = typeof document !== "undefined";
832
- let stylesResult;
833
- if (useFactoryCache && allStyles === baseStyles && classNameCache.has(allStyles)) {
834
- stylesResult = { className: classNameCache.get(allStyles) };
835
- touch(stylesResult.className);
836
- } else {
837
- stylesResult = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES : void 0);
838
- if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, stylesResult.className);
839
- }
840
- let mergedTokens;
841
- if (defaultTokens || tokens || propTokens) if (!defaultTokens && !propTokens) mergedTokens = tokens;
842
- else if (!tokens && !propTokens) mergedTokens = defaultTokens;
843
- else mergedTokens = {
844
- ...defaultTokens,
845
- ...tokens,
846
- ...propTokens
847
- };
848
- const processedTokenStyle = processTokens(mergedTokens);
849
- let mergedStyle;
850
- if (processedTokenStyle || style) if (!processedTokenStyle) mergedStyle = style;
851
- else if (!style) mergedStyle = processedTokenStyle;
852
- else mergedStyle = {
853
- ...processedTokenStyle,
854
- ...style
855
- };
856
- const mergedMods = propMods ? {
857
- ...mods,
858
- ...propMods
859
- } : mods;
860
- let modDataAttrs;
861
- if (mergedMods) modDataAttrs = _modAttrs(mergedMods);
862
- const finalClassName = [userClassName || "", stylesResult.className].filter(Boolean).join(" ");
863
- const elementProps = {
864
- "data-element": element || defaultElement,
865
- "data-qa": qa || defaultQa,
866
- "data-qaval": qaVal || defaultQaVal,
867
- "data-theme": theme,
868
- ...otherDefaultProps,
869
- ...modDataAttrs || {},
870
- ...otherProps,
871
- className: finalClassName,
872
- style: mergedStyle,
873
- ref
874
- };
875
- handleIsProperties(elementProps);
876
- if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
877
- const el = createElement(as ?? originalAs, elementProps);
878
- if (stylesResult.css) {
879
- const nonce = getConfig().nonce;
880
- return createElement(Fragment, null, createElement("style", {
881
- "data-tasty-rsc": "",
882
- nonce,
883
- dangerouslySetInnerHTML: { __html: stylesResult.css }
884
- }), el);
885
- }
886
- return el;
887
- });
888
- _TastyComponent.displayName = `TastyComponent(${defaultProps.qa || originalAs})`;
889
- if (elements) {
890
- const subElements = Object.entries(elements).reduce((acc, [name, definition]) => {
891
- acc[name] = createSubElement(name, definition);
892
- return acc;
893
- }, {});
894
- return Object.assign(_TastyComponent, subElements);
895
- }
896
- return _TastyComponent;
897
- }
898
- const Element = /* @__PURE__ */ tasty({});
899
- //#endregion
900
- //#region src/ssr/context.ts
901
- /**
902
- * React context for SSR collector discovery.
903
- *
904
- * Used by Next.js TastyRegistry to provide the ServerStyleCollector
905
- * to useStyles() via React context (the streaming-compatible path).
906
- *
907
- * This avoids relying on globalThis for cross-layer communication,
908
- * which leaks between RSC and SSR module graphs in Next.js App Router.
909
- *
910
- * The context is created lazily to avoid calling createContext() at
911
- * module evaluation time, which would break Server Components that
912
- * import from `@tenphi/tasty` without using any React hooks.
913
- */
914
- let _ctx;
915
- function getTastySSRContext() {
916
- if (!_ctx) _ctx = createContext(null);
917
- return _ctx;
918
- }
919
- //#endregion
920
- //#region src/hooks/useStyles.ts
921
- /**
922
- * Hook to generate CSS classes from Tasty styles.
923
- * Thin wrapper around `computeStyles()` that adds React context-based
924
- * SSR collector discovery for backward compatibility with TastyRegistry.
925
- *
926
- * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
927
- *
928
- * @example
929
- * ```tsx
930
- * function MyComponent() {
931
- * const { className } = useStyles({
932
- * padding: '2x',
933
- * fill: '#purple',
934
- * radius: '1r',
935
- * });
936
- *
937
- * return <div className={className}>Styled content</div>;
938
- * }
939
- * ```
940
- */
941
- function useStyles(styles, options) {
942
- return computeStyles(styles, {
943
- ssrCollector: useContext(getTastySSRContext()),
944
- root: options?.root
945
- });
946
- }
947
- //#endregion
948
- //#region src/hooks/useGlobalStyles.ts
949
- const getClientGlobalSlots = /* @__PURE__ */ createClientState(() => /* @__PURE__ */ new Map());
950
- const noop = () => {};
951
- /**
952
- * Inject global styles for a given selector.
953
- * Useful for styling elements by selector without generating classNames.
954
- *
955
- * SSR-aware: when a ServerStyleCollector is available, CSS is collected
956
- * during the render phase instead of being injected into the DOM.
957
- *
958
- * Works in all environments: client, SSR with collector, and React Server Components.
959
- *
960
- * Injected styles are permanent — they are not cleaned up on component unmount.
961
- * Use the `id` option for update tracking when styles change over the
962
- * component lifecycle.
963
- *
964
- * Update tracking is per-slot and per-root: a slot (`id`, or the selector when
965
- * no `id` is given) holds exactly one injection per `root`. Changing the styles
966
- * replaces it; rendering styles that produce no CSS clears it.
967
- *
968
- * @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')
969
- * @param styles - Tasty styles object
970
- * @param options - Optional settings including `id` for update tracking
971
- *
972
- * @example
973
- * ```tsx
974
- * function MyComponent() {
975
- * useGlobalStyles('.card', {
976
- * padding: '2x',
977
- * radius: '1r',
978
- * fill: '#white',
979
- * });
980
- *
981
- * return <div className="card">Content</div>;
982
- * }
983
- * ```
984
- */
985
- function useGlobalStyles(selector, styles, options) {
986
- if (!styles) return;
987
- if (!selector) {
988
- console.warn("[Tasty] useGlobalStyles: selector is required and cannot be empty. Styles will not be injected.");
989
- return;
990
- }
991
- const target = getStyleTarget();
992
- const slots = target.mode === "client" ? getClientGlobalSlots(options?.root ?? document) : null;
993
- const slotKey = options?.id ?? selector;
994
- const stylesKey = slots ? JSON.stringify(styles) : "";
995
- const existing = slots?.get(slotKey);
996
- if (existing && existing.stylesKey === stylesKey) return;
997
- const resolvedStyles = resolveRecipes(styles);
998
- const styleResults = renderStyles(resolvedStyles, selector);
999
- if (styleResults.length === 0) {
1000
- if (slots) {
1001
- existing?.dispose();
1002
- slots.set(slotKey, {
1003
- stylesKey,
1004
- dispose: noop
1005
- });
1006
- }
1007
- return;
1008
- }
1009
- if (target.mode === "ssr") {
1010
- target.collector.collectInternals();
1011
- const css = formatGlobalRules(styleResults);
1012
- if (css) {
1013
- const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
1014
- target.collector.collectGlobalStyles(key, css, options?.id != null);
1015
- }
1016
- if (getConfig().autoPropertyTypes !== false) collectAutoInferredProperties(styleResults, target.collector, resolvedStyles);
1017
- return;
1018
- }
1019
- if (target.mode === "rsc") {
1020
- const css = formatGlobalRules(styleResults);
1021
- if (css) {
1022
- const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
1023
- pushRSCCSS(target.cache, key, css, options?.id != null);
1024
- }
1025
- if (getConfig().autoPropertyTypes !== false) collectAutoInferredPropertiesRSC(styleResults, target.cache, resolvedStyles);
1026
- return;
1027
- }
1028
- if (slots) {
1029
- existing?.dispose();
1030
- const { dispose } = injectGlobal(styleResults, { root: options?.root });
1031
- slots.set(slotKey, {
1032
- stylesKey,
1033
- dispose
1034
- });
1035
- }
1036
- }
1037
- //#endregion
1038
- //#region src/hooks/useRawCSS.ts
1039
- const getClientState$1 = /* @__PURE__ */ createClientState(() => ({
1040
- entries: /* @__PURE__ */ new Map(),
1041
- contentDedup: /* @__PURE__ */ new Set(),
1042
- factoryDeps: /* @__PURE__ */ new Map()
1043
- }));
1044
- /**
1045
- * Inject raw CSS text directly without parsing.
1046
- * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
1047
- *
1048
- * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts
1049
- * with tasty's chunked style sheets.
1050
- *
1051
- * Works in all environments: client, SSR with collector, and React Server Components.
1052
- *
1053
- * Injected styles are permanent — they are not cleaned up on component unmount.
1054
- * Use the `id` option for update tracking when styles change over the
1055
- * component lifecycle.
1056
- *
1057
- * @example Static CSS string
1058
- * ```tsx
1059
- * function GlobalStyles() {
1060
- * useRawCSS(`
1061
- * body {
1062
- * margin: 0;
1063
- * padding: 0;
1064
- * font-family: sans-serif;
1065
- * }
1066
- * `);
1067
- *
1068
- * return null;
1069
- * }
1070
- * ```
1071
- *
1072
- * @example Factory function with dependencies
1073
- * ```tsx
1074
- * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {
1075
- * useRawCSS(() => `
1076
- * :root {
1077
- * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};
1078
- * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};
1079
- * }
1080
- * `, [theme], { id: 'theme-vars' });
1081
- *
1082
- * return null;
1083
- * }
1084
- * ```
1085
- *
1086
- * @example With options
1087
- * ```tsx
1088
- * function ShadowStyles({ shadowRoot }) {
1089
- * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });
1090
- * return null;
1091
- * }
1092
- * ```
1093
- */
1094
- function useRawCSS(cssOrFactory, depsOrOptions, options) {
1095
- const isFactory = typeof cssOrFactory === "function";
1096
- const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
1097
- const opts = isFactory ? options : depsOrOptions;
1098
- const target = getStyleTarget();
1099
- const state = target.mode === "client" ? getClientState$1(opts?.root ?? document) : null;
1100
- if (isFactory && deps && opts?.id && state) {
1101
- const cachedDeps = state.factoryDeps.get(opts.id);
1102
- if (cachedDeps && depsEqual(cachedDeps, deps)) return;
1103
- }
1104
- const css = isFactory ? cssOrFactory() : cssOrFactory;
1105
- if (!css.trim()) return;
1106
- if (target.mode === "ssr") {
1107
- const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;
1108
- target.collector.collectRawCSS(key, css, opts?.id != null);
1109
- return;
1110
- }
1111
- if (target.mode === "rsc") {
1112
- const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;
1113
- pushRSCCSS(target.cache, key, css, opts?.id != null);
1114
- return;
1115
- }
1116
- if (!state) return;
1117
- const id = opts?.id;
1118
- if (id) {
1119
- const existing = state.entries.get(id);
1120
- if (existing) {
1121
- if (existing.contentKey === css) return;
1122
- existing.dispose();
1123
- }
1124
- const { dispose } = injectRawCSS(css, opts);
1125
- state.entries.set(id, {
1126
- contentKey: css,
1127
- dispose
1128
- });
1129
- if (deps) state.factoryDeps.set(id, deps);
1130
- } else {
1131
- const contentKey = hashString(css);
1132
- if (state.contentDedup.has(contentKey)) return;
1133
- state.contentDedup.add(contentKey);
1134
- injectRawCSS(css, opts);
1135
- }
1136
- }
1137
- //#endregion
1138
- //#region src/hooks/useKeyframes.ts
1139
- const getClientState = /* @__PURE__ */ createClientState(() => ({
1140
- contentToName: /* @__PURE__ */ new Map(),
1141
- namedSlots: /* @__PURE__ */ new Map(),
1142
- factoryDeps: /* @__PURE__ */ new Map()
1143
- }));
1144
- function useKeyframes(stepsOrFactory, depsOrOptions, options) {
1145
- const isFactory = typeof stepsOrFactory === "function";
1146
- const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
1147
- const opts = isFactory ? options : depsOrOptions;
1148
- const target = getStyleTarget();
1149
- const clientState = target.mode === "client" ? getClientState(opts?.root ?? document) : null;
1150
- if (isFactory && deps && opts?.name && clientState) {
1151
- const cached = clientState.factoryDeps.get(opts.name);
1152
- if (cached && depsEqual(cached.deps, deps)) return cached.name;
1153
- }
1154
- const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
1155
- if (!steps || Object.keys(steps).length === 0) return "";
1156
- if (target.mode === "ssr") {
1157
- const actualName = target.collector.allocateKeyframeName(opts?.name);
1158
- const css = formatKeyframesCSS(actualName, steps);
1159
- target.collector.collectKeyframes(actualName, css);
1160
- return actualName;
1161
- }
1162
- if (target.mode === "rsc") {
1163
- const serializedContent = JSON.stringify(steps);
1164
- const key = `__kf:${opts?.name ?? ""}:${serializedContent}`;
1165
- const existingName = target.cache.generatedNames.get(key);
1166
- if (existingName) return existingName;
1167
- const actualName = opts?.name ?? makeKeyframeName(getNamePrefix(), hashString(serializedContent));
1168
- const css = formatKeyframesCSS(actualName, steps);
1169
- pushRSCCSS(target.cache, key, css);
1170
- target.cache.generatedNames.set(key, actualName);
1171
- return actualName;
1172
- }
1173
- const state = clientState ?? getClientState(opts?.root ?? document);
1174
- const serializedContent = JSON.stringify(steps);
1175
- const cacheKey = `${opts?.name ?? ""}:${serializedContent}`;
1176
- const cachedName = state.contentToName.get(cacheKey);
1177
- if (cachedName) return cachedName;
1178
- const providedName = opts?.name;
1179
- if (providedName) {
1180
- const slot = state.namedSlots.get(providedName);
1181
- if (slot && slot.cacheKey !== cacheKey) {
1182
- slot.dispose();
1183
- state.contentToName.delete(slot.cacheKey);
1184
- state.namedSlots.delete(providedName);
1185
- }
1186
- }
1187
- const result = keyframes(steps, {
1188
- name: providedName,
1189
- root: opts?.root
1190
- });
1191
- const name = result.toString();
1192
- state.contentToName.set(cacheKey, name);
1193
- if (providedName) {
1194
- state.namedSlots.set(providedName, {
1195
- cacheKey,
1196
- dispose: result.dispose
1197
- });
1198
- if (deps) state.factoryDeps.set(providedName, {
1199
- deps,
1200
- name
1201
- });
1202
- }
1203
- return name;
1204
- }
1205
- //#endregion
1206
- //#region src/hooks/useProperty.ts
1207
- /**
1208
- * Register a CSS @property custom property.
1209
- * This enables advanced features like animating custom properties.
1210
- *
1211
- * Note: @property rules are global and persistent once defined.
1212
- * The function ensures the property is only registered once per root.
1213
- *
1214
- * Accepts tasty token syntax for the property name:
1215
- * - `$name` → defines `--name`
1216
- * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
1217
- * - `--name` → defines `--name` (legacy format)
1218
- *
1219
- * Works in all environments: client, SSR with collector, and React Server Components.
1220
- *
1221
- * @param name - The property token ($name, #name) or CSS property name (--name)
1222
- * @param options - Property configuration
1223
- *
1224
- * @example Basic property with token syntax
1225
- * ```tsx
1226
- * function Spinner() {
1227
- * useProperty('$rotation', {
1228
- * syntax: '<angle>',
1229
- * inherits: false,
1230
- * initialValue: '0deg',
1231
- * });
1232
- *
1233
- * return <div className="spinner" />;
1234
- * }
1235
- * ```
1236
- *
1237
- * @example Color property with token syntax (auto-sets syntax)
1238
- * ```tsx
1239
- * function MyComponent() {
1240
- * useProperty('#theme', {
1241
- * initialValue: 'red', // syntax: '<color>' is auto-set
1242
- * });
1243
- *
1244
- * // Now --theme-color can be animated with CSS transitions
1245
- * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;
1246
- * }
1247
- * ```
1248
- *
1249
- * @example Legacy format (still supported)
1250
- * ```tsx
1251
- * function ResizableBox() {
1252
- * useProperty('--box-size', {
1253
- * syntax: '<length>',
1254
- * initialValue: '100px',
1255
- * });
1256
- *
1257
- * return <div style={{ width: 'var(--box-size)' }} />;
1258
- * }
1259
- * ```
1260
- */
1261
- function useProperty(name, options) {
1262
- if (!name) {
1263
- console.warn(`[Tasty] useProperty: property name is required`);
1264
- return;
1265
- }
1266
- const target = getStyleTarget();
1267
- if (target.mode === "ssr") {
1268
- target.collector.collectInternals();
1269
- const css = formatPropertyCSS(name, {
1270
- syntax: options?.syntax,
1271
- inherits: options?.inherits,
1272
- initialValue: options?.initialValue
1273
- });
1274
- if (css) target.collector.collectProperty(name, css);
1275
- return;
1276
- }
1277
- if (target.mode === "rsc") {
1278
- const css = formatPropertyCSS(name, {
1279
- syntax: options?.syntax,
1280
- inherits: options?.inherits,
1281
- initialValue: options?.initialValue
1282
- });
1283
- if (css) pushRSCCSS(target.cache, `__prop:${name}`, css);
1284
- return;
1285
- }
1286
- const injector = getGlobalInjector();
1287
- if (injector.isPropertyDefined(name, { root: options?.root })) return;
1288
- injector.property(name, {
1289
- syntax: options?.syntax,
1290
- inherits: options?.inherits,
1291
- initialValue: options?.initialValue,
1292
- root: options?.root
1293
- });
1294
- }
1295
- //#endregion
1296
- //#region src/hooks/useFontFace.ts
1297
- /**
1298
- * Inject CSS @font-face rules.
1299
- * Permanent — no cleanup on unmount. Deduplicates by content hash.
1300
- *
1301
- * Works in all environments: client, SSR with collector, and React Server Components.
1302
- *
1303
- * @param family - The font-family name
1304
- * @param input - Single descriptor object or array of descriptors (for multiple weights/styles)
1305
- * @param options - Optional settings (e.g. Shadow DOM root)
1306
- *
1307
- * @example Single weight
1308
- * ```tsx
1309
- * function App() {
1310
- * useFontFace('Brand Sans', {
1311
- * src: 'url("/fonts/brand-sans.woff2") format("woff2")',
1312
- * fontWeight: '400 700',
1313
- * fontDisplay: 'swap',
1314
- * });
1315
- *
1316
- * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
1317
- * }
1318
- * ```
1319
- *
1320
- * @example Multiple weights
1321
- * ```tsx
1322
- * function App() {
1323
- * useFontFace('Brand Sans', [
1324
- * { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
1325
- * { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
1326
- * ]);
1327
- *
1328
- * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
1329
- * }
1330
- * ```
1331
- */
1332
- function useFontFace(family, input, options) {
1333
- if (!family) return;
1334
- const descriptors = Array.isArray(input) ? input : [input];
1335
- const target = getStyleTarget();
1336
- if (target.mode === "ssr") {
1337
- for (const desc of descriptors) {
1338
- const hash = fontFaceContentHash(family, desc);
1339
- const css = formatFontFaceRule(family, desc);
1340
- target.collector.collectFontFace(hash, css);
1341
- }
1342
- return;
1343
- }
1344
- if (target.mode === "rsc") {
1345
- for (const desc of descriptors) {
1346
- const hash = fontFaceContentHash(family, desc);
1347
- const css = formatFontFaceRule(family, desc);
1348
- pushRSCCSS(target.cache, `__ff:${hash}`, css);
1349
- }
1350
- return;
1351
- }
1352
- const injector = getGlobalInjector();
1353
- for (const desc of descriptors) injector.fontFace(family, desc, { root: options?.root });
1354
- }
1355
- //#endregion
1356
- //#region src/hooks/useCounterStyle.ts
1357
- let clientCounterStyleCounter = 0;
1358
- const getClientContentToName = /* @__PURE__ */ createClientState(() => /* @__PURE__ */ new Map());
1359
- /**
1360
- * Inject a CSS @counter-style rule and return the generated name.
1361
- * Permanent — no cleanup on unmount. Deduplicates by name.
1362
- *
1363
- * Works in all environments: client, SSR with collector, and React Server Components.
1364
- *
1365
- * @example Basic usage
1366
- * ```tsx
1367
- * function EmojiList() {
1368
- * const styleName = useCounterStyle({
1369
- * system: 'cyclic',
1370
- * symbols: '"👍"',
1371
- * suffix: '" "',
1372
- * }, { name: 'thumbs' });
1373
- *
1374
- * return (
1375
- * <ol style={{ listStyleType: styleName }}>
1376
- * <li>First</li>
1377
- * <li>Second</li>
1378
- * </ol>
1379
- * );
1380
- * }
1381
- * ```
1382
- *
1383
- */
1384
- function useCounterStyle(descriptors, options) {
1385
- if (!descriptors || !descriptors.system) return "";
1386
- const target = getStyleTarget();
1387
- if (target.mode === "ssr") {
1388
- const actualName = target.collector.allocateCounterStyleName(options?.name);
1389
- const css = formatCounterStyleRule(actualName, descriptors);
1390
- target.collector.collectCounterStyle(actualName, css);
1391
- return actualName;
1392
- }
1393
- if (target.mode === "rsc") {
1394
- const serializedContent = JSON.stringify(descriptors);
1395
- const key = `__cs:${options?.name ?? ""}:${serializedContent}`;
1396
- const existingName = target.cache.generatedNames.get(key);
1397
- if (existingName) return existingName;
1398
- const actualName = options?.name ?? makeCounterStyleName(getNamePrefix(), hashString(serializedContent));
1399
- const css = formatCounterStyleRule(actualName, descriptors);
1400
- pushRSCCSS(target.cache, key, css);
1401
- target.cache.generatedNames.set(key, actualName);
1402
- return actualName;
1403
- }
1404
- const contentToName = getClientContentToName(options?.root ?? document);
1405
- const serializedContent = JSON.stringify(descriptors);
1406
- const cacheKey = `${options?.name ?? ""}:${serializedContent}`;
1407
- const existingName = contentToName.get(cacheKey);
1408
- if (existingName) return existingName;
1409
- const name = options?.name ?? makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));
1410
- contentToName.set(cacheKey, name);
1411
- getGlobalInjector().counterStyle(name, descriptors, { root: options?.root });
1412
- return name;
1413
- }
1414
- //#endregion
1415
- //#region src/hooks/useFunction.ts
1416
- /**
1417
- * Register a CSS @function (custom function).
1418
- *
1419
- * @function rules are global and persistent once defined. The hook ensures the
1420
- * function is only registered once per root (deduplicated by function name).
1421
- *
1422
- * Accepts tasty token syntax for the function name:
1423
- * - `$$name` → defines `--name` (matches the call site `$$name(...)`)
1424
- * - `$name` / `--name` → also accepted
1425
- *
1426
- * Works in all environments: client, SSR with collector, and React Server Components.
1427
- *
1428
- * @param name - The function name token (`$$name`, `$name`, or `--name`)
1429
- * @param definition - Function definition (args, returns, result, local vars)
1430
- *
1431
- * Call the function through the Tasty DSL, not a raw `style` prop: an inline
1432
- * `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never
1433
- * expanded and `polyfills.functions` cannot rewrite it either.
1434
- *
1435
- * @example
1436
- * ```tsx
1437
- * const Box = tasty({ styles: { marginTop: '$$negative(10px)' } });
1438
- *
1439
- * function Layout() {
1440
- * useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
1441
- * return <Box />;
1442
- * }
1443
- * ```
1444
- */
1445
- function useFunction(name, definition, options) {
1446
- if (!name) {
1447
- console.warn(`[Tasty] useFunction: function name is required`);
1448
- return;
1449
- }
1450
- if (isFunctionsPolyfillEnabled()) {
1451
- registerFunctionPolyfill(name, definition);
1452
- return;
1453
- }
1454
- const target = getStyleTarget();
1455
- if (target.mode === "ssr") {
1456
- target.collector.collectInternals();
1457
- const css = formatFunctionRule(name, definition);
1458
- if (css) target.collector.collectFunction(parseFunctionName(name), css);
1459
- return;
1460
- }
1461
- if (target.mode === "rsc") {
1462
- const css = formatFunctionRule(name, definition);
1463
- if (css) pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);
1464
- return;
1465
- }
1466
- getGlobalInjector().func(name, definition, { root: options?.root });
1467
- }
1468
- //#endregion
1469
- //#region src/batch-provider.tsx
1470
- /**
1471
- * Opens a *batch window* for the commit it renders in, so `batchInjection`
1472
- * can defer stylesheet writes without ever letting a layout effect measure an
1473
- * unstyled element.
1474
- *
1475
- * Every `insertRule()` on a live sheet invalidates style for that sheet's
1476
- * scope. When components inject during React's render phase while others read
1477
- * layout in the same pass, the two interleave and the browser recalculates
1478
- * style between every injection. Batching collapses that into one invalidation
1479
- * per flush — but only if the flush happens before anything can measure.
1480
- *
1481
- * ```
1482
- * provider renders -> window OPEN
1483
- * children render -> injections queued
1484
- * provider insertionEffect -> FLUSH, window CLOSED
1485
- * layout effects run -> rules are in the sheet
1486
- * ```
1487
- *
1488
- * `useInsertionEffect` runs in React's mutation phase, after every render in
1489
- * the commit and before any `useLayoutEffect` — which is exactly why React
1490
- * added it for CSS-in-JS libraries. Effects fire child-first, so this
1491
- * provider's runs after every descendant's and still before all layout
1492
- * effects.
1493
- *
1494
- * A commit that does not re-render this provider gets no window, and those
1495
- * injections are written synchronously instead. That is the point: turning
1496
- * `batchInjection: true` on can only ever make injection cheaper, never make a
1497
- * measurement wrong. It also means batching applies to commits this provider
1498
- * takes part in, so mount it as high in the tree as you can.
1499
- *
1500
- * Requires `configure({ batchInjection: true })`; without it this component
1501
- * only renders its children. `batchInjection: 'always'` does not need the
1502
- * provider at all — see that option's docs for the trade-off it accepts.
1503
- *
1504
- * @example
1505
- * ```tsx
1506
- * configure({ batchInjection: true });
1507
- *
1508
- * createRoot(el).render(
1509
- * <TastyBatchProvider>
1510
- * <App />
1511
- * </TastyBatchProvider>,
1512
- * );
1513
- * ```
1514
- */
1515
- function TastyBatchProvider({ children }) {
1516
- openBatchWindow();
1517
- useInsertionEffect(() => {
1518
- closeBatchWindow();
1519
- });
1520
- return children;
1521
- }
1522
- //#endregion
1523
- export { computeStyles as _, useProperty as a, useGlobalStyles as c, Element as d, tasty as f, filterBaseProps as g, _modAttrs as h, useFontFace as i, useStyles as l, processTokens as m, useFunction as n, useKeyframes as o, getDisplayName as p, useCounterStyle as r, useRawCSS as s, TastyBatchProvider as t, getTastySSRContext as u };
1524
-
1525
- //# sourceMappingURL=react-runtime-B3CmvDEQ.js.map