@tenphi/tasty 0.0.0-snapshot.05e04ff → 0.0.0-snapshot.06c8a41
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/dist/astro-CeYENy2x.js +301 -0
- package/dist/astro-CeYENy2x.js.map +1 -0
- package/dist/{babel-B_P8t-f0.d.ts → babel-DWCsafYw.d.ts} +2 -2
- package/dist/{collector-DCI2yzwx.js → collector-B3OsM252.js} +36 -13
- package/dist/collector-B3OsM252.js.map +1 -0
- package/dist/{collector-CQDeU7WS.d.ts → collector-BTVXj2hS.d.ts} +21 -3
- package/dist/{config-B97n_EIv.js → config-B3gPdCqd.js} +202 -393
- package/dist/config-B3gPdCqd.js.map +1 -0
- package/dist/{config-CwRr6-fG.d.ts → config-LfIDmVHx.d.ts} +93 -65
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-DWrUWxog.js → core-DGm0CFHP.js} +271 -184
- package/dist/core-DGm0CFHP.js.map +1 -0
- package/dist/css-resources-Cyl_axbI.js +149 -0
- package/dist/css-resources-Cyl_axbI.js.map +1 -0
- package/dist/{css-writer-Cq0fg5v8.js → css-writer-Bgowobbx.js} +3 -3
- package/dist/{css-writer-Cq0fg5v8.js.map → css-writer-Bgowobbx.js.map} +1 -1
- package/dist/{format-rules-Wb7dJOoL.js → format-rules-XRw9u7d4.js} +3 -29
- package/dist/format-rules-XRw9u7d4.js.map +1 -0
- package/dist/{hydrate-gFTLBDK9.js → hydrate-CNOmZprz.js} +2 -2
- package/dist/{hydrate-gFTLBDK9.js.map → hydrate-CNOmZprz.js.map} +1 -1
- package/dist/{index-C0W21Qcb.d.ts → index-Bm9ltvdH.d.ts} +28 -53
- package/dist/{index-DpykQKO8.d.ts → index-BmogEzTo.d.ts} +60 -38
- package/dist/index.d.ts +5 -5
- package/dist/index.js +41 -117
- package/dist/index.js.map +1 -1
- package/dist/{renderChunk-COXABoQz.js → keyframes-DE-OE76F.js} +248 -3
- package/dist/keyframes-DE-OE76F.js.map +1 -0
- package/dist/{merge-styles-Bpwfy1CS.d.ts → merge-styles-BcLl1u_d.d.ts} +2 -2
- package/dist/{merge-styles-CzVxdtav.js → merge-styles-DuoZEsm9.js} +2 -2
- package/dist/{merge-styles-CzVxdtav.js.map → merge-styles-DuoZEsm9.js.map} +1 -1
- package/dist/{resolve-recipes-BnrUEjWV.js → resolve-recipes-H9NqOQuP.js} +3 -3
- package/dist/{resolve-recipes-BnrUEjWV.js.map → resolve-recipes-H9NqOQuP.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +3 -1
- package/dist/ssr/astro-middleware-static.js +1 -1
- package/dist/ssr/astro-middleware.d.ts +3 -1
- package/dist/ssr/astro-middleware.js +1 -1
- package/dist/ssr/astro.d.ts +45 -3
- package/dist/ssr/astro.js +1 -156
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +66 -0
- package/dist/ssr/next-config.js +115 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -2
- package/dist/ssr/next.js +26 -9
- package/dist/ssr/next.js.map +1 -1
- package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
- package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +1 -1
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +1 -1
- package/dist/zero/index.js +1 -1
- package/dist/zero/next.d.ts +1 -1
- package/docs/debug.md +13 -0
- package/docs/injector.md +21 -7
- package/docs/runtime-benchmarks.md +192 -75
- package/docs/ssr.md +179 -20
- package/package.json +30 -9
- package/dist/collector-DCI2yzwx.js.map +0 -1
- package/dist/config-B97n_EIv.js.map +0 -1
- package/dist/core-DWrUWxog.js.map +0 -1
- package/dist/format-rules-Wb7dJOoL.js.map +0 -1
- package/dist/renderChunk-COXABoQz.js.map +0 -1
- package/dist/ssr/astro.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $t as
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
4
|
-
import { n as formatPropertyCSS } from "./format-rules-
|
|
5
|
-
import { t as mergeStyles } from "./merge-styles-
|
|
6
|
-
import { t as resolveRecipes } from "./resolve-recipes-
|
|
1
|
+
import { $ as SheetManager, $t as StyleParser, A as FLOW_STYLES, At as STYLE_TO_CHUNK, B as createStateParserContext, C as BASE_STYLES, Ct as APPEARANCE_CHUNK_STYLES, D as COLOR_STYLES, Dt as FONT_CHUNK_STYLES, E as BLOCK_STYLES, Et as DISPLAY_CHUNK_STYLES, Ft as registerFunctionPolyfill, G as StyleInjector, Gt as parseStyle, Ht as getGlobalPredefinedTokens, I as isSelector, Jt as okhstPlugin, Kt as stringifyStyles, L as renderStyles, Lt as CUSTOM_UNITS, M as OUTER_STYLES, Mt as formatFunctionRule, N as POSITION_STYLES, O as CONTAINER_STYLES, Ot as LAYOUT_CHUNK_STYLES, P as TEXT_STYLES, Pt as parseFunctionName, R as parseStateKey, Rt as DIRECTIONS, S as baseStylePropsRegistry, St as propHandlerRegistry, T as BLOCK_OUTER_STYLES, Tt as DIMENSION_CHUNK_STYLES, U as getGlobalPredefinedStates, Ut as normalizeColorTokenValue, Vt as getGlobalParser, W as setGlobalPredefinedStates, Wt as parseColor, X as fontFaceContentHash, Xt as okhslPlugin, Yt as okhslFunction, Z as formatFontFaceRule, Zt as createColorFunc, _ as isFunctionsPolyfillEnabled, _t as hashString, a as getGlobalCounterStyles, an as hslToRgbValues, at as closeBatchWindow, b as resetConfig, c as getGlobalInjector, ct as openBatchWindow, dt as DEFAULT_ZERO_NAME_PREFIX, f as getNamePrefix, g as isConfigLocked, h as hasStylesGenerated, in as hexToRgb, j as INNER_STYLES, k as DIMENSION_STYLES, kt as POSITION_CHUNK_STYLES, l as getGlobalKeyframes, lt as resetStyleBatch, m as hasGlobalRecipes, mt as makeKeyframeName, n as getConfig, nn as getNamedColorHex, nt as styleHandlers, o as getGlobalFontFaces, on as strToRgb, ot as flushStyles, p as hasGlobalKeyframes, pt as makeCounterStyleName, q as formatCounterStyleRule, qt as okhstFunction, rn as getRgbValuesFromRgbaString, s as getGlobalFunctions, st as hasPendingStyleWrites, t as configure, tt as defineHandler, u as getGlobalRecipes, ut as DEFAULT_NAME_PREFIX, v as isTestEnvironment, w as BLOCK_INNER_STYLES, wt as CHUNK_NAMES, x as generateTypographyTokens, zt as filterMods } from "./config-B3gPdCqd.js";
|
|
2
|
+
import { A as keyframes, C as getRawCSSText, D as injectRawCSS, E as injectGlobal, F as chunkSheetRegistry, I as resolveFunctionColor, M as property, N as touch, O as injector, P as ChunkSheetRegistry, S as getCSSTextForNode, T as inject, _ as destroy, a as color, b as gc, c as hasKeys, d as collectAutoInferredPropertiesRSC, f as getStyleTarget, g as createInjector, h as counterStyle, i as _modAttrs, j as ownKeyframes, k as isPropertyDefined, l as formatKeyframesCSS, m as cleanup, n as processTokens, o as filterBaseProps, p as pushRSCCSS, r as dotize, s as computeStyles, t as tastyDebug, u as collectAutoInferredProperties, v as fontFace, w as holdKeyframes, x as getCSSText, y as func } from "./core-DGm0CFHP.js";
|
|
3
|
+
import { d as categorizeStyleKeys } from "./keyframes-DE-OE76F.js";
|
|
4
|
+
import { n as formatPropertyCSS } from "./format-rules-XRw9u7d4.js";
|
|
5
|
+
import { t as mergeStyles } from "./merge-styles-DuoZEsm9.js";
|
|
6
|
+
import { t as resolveRecipes } from "./resolve-recipes-H9NqOQuP.js";
|
|
7
7
|
import { t as getTastySSRContext } from "./context-CA8YKeMn.js";
|
|
8
8
|
import { t as formatGlobalRules } from "./format-global-rules-DklyaXv-.js";
|
|
9
9
|
import { Fragment, createElement, forwardRef, useContext, useInsertionEffect } from "react";
|
|
@@ -26,106 +26,8 @@ function isValidElementType(value) {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
29
|
-
//#region src/hooks/useStyles.ts
|
|
30
|
-
/**
|
|
31
|
-
* Hook to generate CSS classes from Tasty styles.
|
|
32
|
-
* Thin wrapper around `computeStyles()` that adds React context-based
|
|
33
|
-
* SSR collector discovery for backward compatibility with TastyRegistry.
|
|
34
|
-
*
|
|
35
|
-
* For hook-free usage (e.g. in server components), use `computeStyles()` directly.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```tsx
|
|
39
|
-
* function MyComponent() {
|
|
40
|
-
* const { className } = useStyles({
|
|
41
|
-
* padding: '2x',
|
|
42
|
-
* fill: '#purple',
|
|
43
|
-
* radius: '1r',
|
|
44
|
-
* });
|
|
45
|
-
*
|
|
46
|
-
* return <div className={className}>Styled content</div>;
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
function useStyles(styles, options) {
|
|
51
|
-
const root = options?.root;
|
|
52
|
-
const managed = commitManaged$1();
|
|
53
|
-
const result = computeStyles(styles, {
|
|
54
|
-
ssrCollector: useContext(getTastySSRContext()),
|
|
55
|
-
root,
|
|
56
|
-
managed
|
|
57
|
-
});
|
|
58
|
-
if (managed) useStyleCommit(result.className, root);
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
const CAN_COMMIT$1 = typeof document !== "undefined";
|
|
62
|
-
let commitManagedMemo$1 = false;
|
|
63
|
-
let commitManagedEpoch$1 = -1;
|
|
64
|
-
/**
|
|
65
|
-
* Whether styles should be held through the commit rather than written during
|
|
66
|
-
* render — see the same gate in `tasty()`. Only applications that configured
|
|
67
|
-
* `gc` take the insertion effect; everything else keeps the synchronous path.
|
|
68
|
-
*/
|
|
69
|
-
function commitManaged$1() {
|
|
70
|
-
const epoch = getStyleEpoch();
|
|
71
|
-
if (commitManagedEpoch$1 !== epoch) {
|
|
72
|
-
commitManagedEpoch$1 = epoch;
|
|
73
|
-
commitManagedMemo$1 = CAN_COMMIT$1 && getConfig().gc != null;
|
|
74
|
-
}
|
|
75
|
-
return commitManagedMemo$1;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Hold the styles this render resolved for as long as the component is mounted.
|
|
79
|
-
*
|
|
80
|
-
* Rendering only names the classes and records what they stand for; this is
|
|
81
|
-
* where they reach the sheet. `useInsertionEffect` is React's insertion phase —
|
|
82
|
-
* it runs after every render in the commit and before any layout effect, so the
|
|
83
|
-
* rules are in place before anything can measure them.
|
|
84
|
-
*
|
|
85
|
-
* The dependency is the class-name string itself, so an unchanged rerender —
|
|
86
|
-
* the overwhelmingly common case — costs one string comparison and nothing
|
|
87
|
-
* else. Because setup re-inserts whatever is missing, a class collected while
|
|
88
|
-
* this render was still pending simply comes back here.
|
|
89
|
-
*/
|
|
90
|
-
function useStyleCommit(className, root) {
|
|
91
|
-
useInsertionEffect(() => {
|
|
92
|
-
if (!className) return;
|
|
93
|
-
acquireStyles(className, { root });
|
|
94
|
-
return () => releaseStyles(className, { root });
|
|
95
|
-
}, [className, root]);
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
29
|
//#region src/tasty.tsx
|
|
99
30
|
/**
|
|
100
|
-
* Whether this environment ever commits. Server renders (SSR and RSC) resolve
|
|
101
|
-
* class names and hand them to a collector; only a browser mounts them.
|
|
102
|
-
*/
|
|
103
|
-
const CAN_COMMIT = typeof document !== "undefined";
|
|
104
|
-
let commitManagedMemo = false;
|
|
105
|
-
let commitManagedEpoch = -1;
|
|
106
|
-
/**
|
|
107
|
-
* Whether styles should be held through the commit rather than written during
|
|
108
|
-
* render.
|
|
109
|
-
*
|
|
110
|
-
* Only applications that asked for collection pay for it. Without `gc`
|
|
111
|
-
* configured there is nothing to collect, so components take the synchronous
|
|
112
|
-
* path and no insertion effect at all — no hook slot, no dependency array, no
|
|
113
|
-
* setup closure per render.
|
|
114
|
-
*
|
|
115
|
-
* Memoized because it decides whether a hook is taken: it must not change
|
|
116
|
-
* between renders of one component. `configure()` locks once the first styles
|
|
117
|
-
* are generated, so this settles on the first render and only a whole new
|
|
118
|
-
* injector — a new style epoch — can move it.
|
|
119
|
-
*/
|
|
120
|
-
function commitManaged() {
|
|
121
|
-
const epoch = getStyleEpoch();
|
|
122
|
-
if (commitManagedEpoch !== epoch) {
|
|
123
|
-
commitManagedEpoch = epoch;
|
|
124
|
-
commitManagedMemo = CAN_COMMIT && getConfig().gc != null;
|
|
125
|
-
}
|
|
126
|
-
return commitManagedMemo;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
31
|
* Precalculated entries for performance optimization
|
|
130
32
|
*/
|
|
131
33
|
const IS_PROPERTIES_ENTRIES = Object.entries({
|
|
@@ -259,11 +161,6 @@ function tastyElement(tastyOptions) {
|
|
|
259
161
|
const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
|
|
260
162
|
const classNameCache = /* @__PURE__ */ new Map();
|
|
261
163
|
const STABLE_STYLES = { stableStyles: true };
|
|
262
|
-
const STABLE_STYLES_MANAGED = {
|
|
263
|
-
stableStyles: true,
|
|
264
|
-
managed: true
|
|
265
|
-
};
|
|
266
|
-
const MANAGED = { managed: true };
|
|
267
164
|
const _TastyComponent = forwardRef((incomingProps, ref) => {
|
|
268
165
|
const applyPropHandlers = propHandlerRegistry.apply;
|
|
269
166
|
const { as, styles: rawStyles, variant, mods, element, qa, qaVal, className: userClassName, tokens, style, theme, ...otherProps } = applyPropHandlers ? applyPropHandlers(incomingProps) : incomingProps;
|
|
@@ -304,16 +201,15 @@ function tastyElement(tastyOptions) {
|
|
|
304
201
|
const hasInstanceStyles = styles && hasKeys(styles);
|
|
305
202
|
const hasPropStyles = propStyles && hasKeys(propStyles);
|
|
306
203
|
const allStyles = hasInstanceStyles || hasPropStyles ? mergeStyles(baseStyles, styles, propStyles) : baseStyles;
|
|
307
|
-
const managed = commitManaged();
|
|
308
204
|
const useFactoryCache = typeof document !== "undefined";
|
|
309
|
-
const cached = useFactoryCache && allStyles === baseStyles ? classNameCache.get(allStyles) : void 0;
|
|
310
205
|
let stylesResult;
|
|
311
|
-
if (
|
|
312
|
-
|
|
313
|
-
stylesResult
|
|
314
|
-
|
|
206
|
+
if (useFactoryCache && allStyles === baseStyles && classNameCache.has(allStyles)) {
|
|
207
|
+
stylesResult = { className: classNameCache.get(allStyles) };
|
|
208
|
+
touch(stylesResult.className);
|
|
209
|
+
} else {
|
|
210
|
+
stylesResult = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES : void 0);
|
|
211
|
+
if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, stylesResult.className);
|
|
315
212
|
}
|
|
316
|
-
if (managed) useStyleCommit(stylesResult.className);
|
|
317
213
|
let mergedTokens;
|
|
318
214
|
if (defaultTokens || tokens || propTokens) if (!defaultTokens && !propTokens) mergedTokens = tokens;
|
|
319
215
|
else if (!tokens && !propTokens) mergedTokens = defaultTokens;
|
|
@@ -374,6 +270,34 @@ function tastyElement(tastyOptions) {
|
|
|
374
270
|
}
|
|
375
271
|
const Element = tasty({});
|
|
376
272
|
//#endregion
|
|
273
|
+
//#region src/hooks/useStyles.ts
|
|
274
|
+
/**
|
|
275
|
+
* Hook to generate CSS classes from Tasty styles.
|
|
276
|
+
* Thin wrapper around `computeStyles()` that adds React context-based
|
|
277
|
+
* SSR collector discovery for backward compatibility with TastyRegistry.
|
|
278
|
+
*
|
|
279
|
+
* For hook-free usage (e.g. in server components), use `computeStyles()` directly.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```tsx
|
|
283
|
+
* function MyComponent() {
|
|
284
|
+
* const { className } = useStyles({
|
|
285
|
+
* padding: '2x',
|
|
286
|
+
* fill: '#purple',
|
|
287
|
+
* radius: '1r',
|
|
288
|
+
* });
|
|
289
|
+
*
|
|
290
|
+
* return <div className={className}>Styled content</div>;
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
function useStyles(styles, options) {
|
|
295
|
+
return computeStyles(styles, {
|
|
296
|
+
ssrCollector: useContext(getTastySSRContext()),
|
|
297
|
+
root: options?.root
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
377
301
|
//#region src/utils/client-state.ts
|
|
378
302
|
/**
|
|
379
303
|
* Build a per-(injector, root) client state cache for the standalone style
|
|
@@ -993,6 +917,6 @@ function TastyBatchProvider({ children }) {
|
|
|
993
917
|
return children;
|
|
994
918
|
}
|
|
995
919
|
//#endregion
|
|
996
|
-
export { APPEARANCE_CHUNK_STYLES, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CUSTOM_UNITS, ChunkSheetRegistry, DEFAULT_NAME_PREFIX, DEFAULT_ZERO_NAME_PREFIX, DIMENSION_CHUNK_STYLES, DIMENSION_STYLES, DIRECTIONS, DISPLAY_CHUNK_STYLES, Element, FLOW_STYLES, FONT_CHUNK_STYLES, INNER_STYLES, LAYOUT_CHUNK_STYLES, OUTER_STYLES, POSITION_CHUNK_STYLES, POSITION_STYLES, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, TastyBatchProvider,
|
|
920
|
+
export { APPEARANCE_CHUNK_STYLES, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CUSTOM_UNITS, ChunkSheetRegistry, DEFAULT_NAME_PREFIX, DEFAULT_ZERO_NAME_PREFIX, DIMENSION_CHUNK_STYLES, DIMENSION_STYLES, DIRECTIONS, DISPLAY_CHUNK_STYLES, Element, FLOW_STYLES, FONT_CHUNK_STYLES, INNER_STYLES, LAYOUT_CHUNK_STYLES, OUTER_STYLES, POSITION_CHUNK_STYLES, POSITION_STYLES, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, TastyBatchProvider, categorizeStyleKeys, chunkSheetRegistry, cleanup, color, computeStyles, configure, counterStyle, createColorFunc, createInjector, createStateParserContext, defineHandler, destroy, dotize, filterBaseProps, filterMods, flushStyles, fontFace, func, gc, generateTypographyTokens, getCSSText, getCSSTextForNode, getConfig, getDisplayName, getGlobalCounterStyles, getGlobalFontFaces, getGlobalFunctions, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getNamePrefix, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasPendingStyleWrites, hasStylesGenerated, hexToRgb, holdKeyframes, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunction, okhslPlugin, okhstFunction, okhstPlugin, ownKeyframes, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetStyleBatch, resolveFunctionColor, resolveRecipes, setGlobalPredefinedStates, strToRgb, stringifyStyles, styleHandlers, tasty, tastyDebug, touch, useCounterStyle, useFontFace, useFunction, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles };
|
|
997
921
|
|
|
998
922
|
//# sourceMappingURL=index.js.map
|