@tenphi/tasty 0.0.0-snapshot.27699f6 → 0.0.0-snapshot.27b6708
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 +171 -107
- package/dist/{async-storage-B7_o6FKt.js → async-storage-DKK-wTD4.js} +1 -1
- package/dist/{async-storage-B7_o6FKt.js.map → async-storage-DKK-wTD4.js.map} +1 -1
- package/dist/babel-BUQGeOXA.d.ts +83 -0
- package/dist/{collector-QwpPODsy.js → collector-DTahQUiV.js} +97 -23
- package/dist/collector-DTahQUiV.js.map +1 -0
- package/dist/{collector-LuU1vZ68.d.ts → collector-DUaHCcTS.d.ts} +54 -7
- package/dist/{config-rrijM-U2.js → config-B5kHzuNz.js} +5144 -3012
- package/dist/config-B5kHzuNz.js.map +1 -0
- package/dist/{config-vuCRkBWX.d.ts → config-YsxGv4tq.d.ts} +412 -33
- package/dist/{context-CkSg-kDT.js → context-CA8YKeMn.js} +1 -1
- package/dist/{context-CkSg-kDT.js.map → context-CA8YKeMn.js.map} +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-BvTG0J_M.js → core-Dr4u1NVD.js} +162 -188
- package/dist/core-Dr4u1NVD.js.map +1 -0
- package/dist/{css-writer-C7HJGEmN.js → css-writer-B-J87ncv.js} +78 -17
- package/dist/css-writer-B-J87ncv.js.map +1 -0
- package/dist/{format-global-rules-Dbc_1tc3.js → format-global-rules-DklyaXv-.js} +1 -1
- package/dist/{format-global-rules-Dbc_1tc3.js.map → format-global-rules-DklyaXv-.js.map} +1 -1
- package/dist/{format-rules-BvokPr1L.js → format-rules-DKOA-6qu.js} +4 -17
- package/dist/format-rules-DKOA-6qu.js.map +1 -0
- package/dist/{hydrate-Dsv7Pwon.js → hydrate-OeMX99We.js} +3 -11
- package/dist/{hydrate-Dsv7Pwon.js.map → hydrate-OeMX99We.js.map} +1 -1
- package/dist/{index-dUtwpOux.d.ts → index-Cd45t5NM.d.ts} +319 -64
- package/dist/{index-ZRxZWzlj.d.ts → index-PqN-DIpn.d.ts} +498 -189
- package/dist/index.d.ts +5 -5
- package/dist/index.js +253 -63
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-DDqRjwa9.js → keyframes-CV8azJf3.js} +97 -191
- package/dist/keyframes-CV8azJf3.js.map +1 -0
- package/dist/{merge-styles-CtDJMhpJ.d.ts → merge-styles-CU7JbEwg.d.ts} +2 -2
- package/dist/{merge-styles-B8jV6zu3.js → merge-styles-oklji0KB.js} +2 -2
- package/dist/{merge-styles-B8jV6zu3.js.map → merge-styles-oklji0KB.js.map} +1 -1
- package/dist/{resolve-recipes-BnTZz2I_.js → resolve-recipes-DTG81rzl.js} +3 -3
- package/dist/{resolve-recipes-BnTZz2I_.js.map → resolve-recipes-DTG81rzl.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-static.d.ts +16 -0
- package/dist/ssr/astro-middleware-static.js +18 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +8 -6
- package/dist/ssr/astro-middleware.js +10 -10
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +2 -17
- package/dist/ssr/astro.js +29 -21
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -9
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +2 -3
- package/dist/ssr/next.js +6 -7
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +4 -4
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.js.map +1 -1
- package/dist/zero/babel.d.ts +2 -81
- package/dist/zero/babel.js +39 -27
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +16 -2
- package/dist/zero/index.js +2 -2
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +1 -1
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +12 -6
- package/docs/adoption.md +53 -28
- package/docs/ai-agents.md +224 -0
- package/docs/comparison.md +59 -30
- package/docs/configuration.md +498 -69
- package/docs/debug.md +7 -7
- package/docs/design-system.md +43 -24
- package/docs/dsl.md +510 -178
- package/docs/getting-started.md +55 -34
- package/docs/injector.md +58 -5
- package/docs/methodology.md +68 -36
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +93 -25
- package/docs/plugins.md +349 -0
- package/docs/react-api.md +162 -38
- package/docs/ssr.md +45 -35
- package/docs/styles.md +65 -16
- package/docs/tasty-static.md +25 -8
- package/package.json +43 -21
- package/tasty.config.ts +6 -0
- package/dist/collector-QwpPODsy.js.map +0 -1
- package/dist/config-rrijM-U2.js.map +0 -1
- package/dist/core-BvTG0J_M.js.map +0 -1
- package/dist/css-writer-C7HJGEmN.js.map +0 -1
- package/dist/format-rules-BvokPr1L.js.map +0 -1
- package/dist/keyframes-DDqRjwa9.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as
|
|
3
|
-
import { $ as
|
|
4
|
-
import { t as mergeStyles } from "./merge-styles-
|
|
5
|
-
export { AllBaseProps, AllBasePropsWithMods, AtRuleContext, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, BaseProps, BasePropsWithoutChildren, BaseStyleProps, BlockInnerStyleProps, BlockOuterStyleProps, BlockStyleProps,
|
|
1
|
+
import { C as ParseFunction, D as PropHandlerDefinition, E as PropHandler, O as PropHandlerProps, S as FunctionsConfig, T as SheetManager, _ as TastyPluginFactory, a as getGlobalFontFaces, b as generateTypographyTokens, c as getGlobalRecipes, d as hasGlobalRecipes, f as hasStylesGenerated, g as TastyPlugin, h as resetConfig, i as getGlobalCounterStyles, l as getNamePrefix, m as isTestEnvironment, n as configure, o as getGlobalFunctions, p as isConfigLocked, r as getConfig, s as getGlobalKeyframes, t as TastyConfig, u as hasGlobalKeyframes, v as TypographyPreset, w as StyleInjector, x as ColorSpace, y as TypographyTokenValue } from "./config-YsxGv4tq.js";
|
|
2
|
+
import { $ as StyleParser, A as ParsedColor, At as StyleUsage, B as StyleValueStateMap, C as SuffixForSelector, Ct as PropertyOptions, D as CSSMap, Dt as SheetInfo, E as AnyStyleHandler, Et as RuleInfo, F as StyleHandlerProps, G as parseColor, H as getGlobalParser, I as StyleHandlerResult, J as getNamedColorHex, K as parseStyle, L as StyleMap, M as ResolvedStyleValue, Mt as flushStyles, N as StyleHandler, Nt as hasPendingStyleWrites, O as CUSTOM_UNITS, Ot as StyleInjectorConfig, P as StyleHandlerDefinition, Pt as resetStyleBatch, Q as strToRgb, R as StylePropValue, S as StylesWithoutSelectors, St as PropertyDefinition, T as TastyPresetNames, Tt as RootRegistry, U as getGlobalPredefinedTokens, V as filterMods, W as normalizeColorTokenValue, X as hexToRgb, Y as getRgbValuesFromRgbaString, Z as hslToRgbValues, _ as NotSelector, _t as InjectionMode, a as ParseStateKeyOptions, at as CSSProperties, b as Styles, bt as KeyframesResult, c as ParsedAdvancedState, ct as DisposeFunction, d as getGlobalPredefinedStates, dt as FunctionDefinition, et as ParserOptions, f as setGlobalPredefinedStates, ft as FunctionParameter, g as NoType, gt as InjectResult, h as ConfigTokens, i as renderStyles, it as UnitHandler, j as RawStyleHandler, jt as QueuedWrite, k as DIRECTIONS, kt as StyleRule, l as StateParserContext, lt as FontFaceDescriptors, m as ConfigTokenValue, mt as GCOptions, n as StyleResult, nt as StyleDetails, o as parseStateKey, ot as CacheMetrics, p as ConditionNode, pt as GCConfig, q as stringifyStyles, r as isSelector, rt as StyleDetailsPart, s as AtRuleContext, st as CounterStyleDescriptors, t as RenderResult, tt as ProcessedStyle, u as createStateParserContext, ut as FontFaceInput, v as RecipeStyles, vt as KeyframesCacheEntry, w as TastyNamedColors, wt as RawCSSResult, x as StylesInterface, xt as KeyframesSteps, y as Selector, yt as KeyframesInfo, z as StyleValue } from "./index-Cd45t5NM.js";
|
|
3
|
+
import { $ as okhstFunction, $t as PositionStyleProps, A as keyframes, At as TastyElementProps, B as ChunkInfo, Bt as BaseStyleProps, C as getCSSTextForNode, Ct as ResolveModPropDef, D as injectRawCSS, Dt as SubElementProps, E as injectGlobal, Et as SubElementDefinition, F as ComputeStylesOptions, Ft as WithVariant, G as DIMENSION_CHUNK_STYLES, Gt as ContainerStyleProps, H as APPEARANCE_CHUNK_STYLES, Ht as BlockOuterStyleProps, I as ComputeStylesResult, It as tasty, J as LAYOUT_CHUNK_STYLES, Jt as FlowStyleProps, K as DISPLAY_CHUNK_STYLES, Kt as DimensionStyleProps, L as computeStyles, Lt as AllBaseProps, M as touch, Mt as TastyProps, N as ChunkSheetRegistry, Nt as TokenPropsInput, O as injector, Ot as TastyComponentPropsWithDefaults, P as chunkSheetRegistry, Pt as VariantMap, Q as createColorFunc, Qt as OuterStyleProps, R as defineHandler, Rt as BaseProps, S as getCSSText, Sn as DEFAULT_ZERO_NAME_PREFIX, St as ResolveAsProps, T as inject, Tt as ResolveTokenProps, U as CHUNK_NAMES, Ut as BlockStyleProps, V as categorizeStyleKeys, Vt as BlockInnerStyleProps, W as ChunkName, Wt as ColorStyleProps, X as STYLE_TO_CHUNK, Xt as ModValue, Y as POSITION_CHUNK_STYLES, Yt as InnerStyleProps, Z as resolveFunctionColor, Zt as Mods, _ as createInjector, _n as INNER_STYLES, _t as AllBasePropsWithMods, a as DebugOptions, an as TastyThemeNames, at as TastyBatchProviderProps, b as func, bn as TEXT_STYLES, bt as ModPropDef, c as tastyDebug, cn as Tokens, ct as useCounterStyle, d as dotize, dn as BLOCK_OUTER_STYLES, dt as useProperty, en as ShortGridStyles, et as okhstPlugin, f as _modAttrs, fn as BLOCK_STYLES, ft as useKeyframes, g as counterStyle, gn as FLOW_STYLES, gt as useStyles, h as cleanup, hn as DIMENSION_STYLES, ht as UseStylesResult, i as DebugChunkInfo, in as TastyExtensionConfig, it as TastyBatchProvider, j as property, jt as TastyPolymorphicComponent, k as isPropertyDefined, kt as TastyElementOptions, l as processTokens, ln as BASE_STYLES, lt as useFontFace, m as filterBaseProps, mn as CONTAINER_STYLES, mt as useGlobalStyles, n as CacheStatus, nn as TastyBaseStylePropNames, nt as okhslPlugin, o as InspectResult, on as TextStyleProps, ot as UseFunctionOptions, p as color, pn as COLOR_STYLES, pt as useRawCSS, q as FONT_CHUNK_STYLES, qt as ExtraBaseStyleProps, r as ChunkBreakdown, rn as TastyCustomProps, rt as getDisplayName, s as Summary, sn as TokenValue, st as useFunction, t as CSSOptions, tn as TagName, tt as okhslFunction, u as resolveRecipes, un as BLOCK_INNER_STYLES, ut as UsePropertyOptions, v as destroy, vn as OUTER_STYLES, vt as Element, w as getRawCSSText, wt as ResolveModProps, x as gc, xn as DEFAULT_NAME_PREFIX, xt as ModPropsInput, y as fontFace, yn as POSITION_STYLES, yt as ElementsDefinition, z as styleHandlers, zt as BasePropsWithoutChildren } from "./index-PqN-DIpn.js";
|
|
4
|
+
import { t as mergeStyles } from "./merge-styles-CU7JbEwg.js";
|
|
5
|
+
export { APPEARANCE_CHUNK_STYLES, type AllBaseProps, type AllBasePropsWithMods, type AnyStyleHandler, type AtRuleContext, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, type BaseProps, type BasePropsWithoutChildren, type BaseStyleProps, type BlockInnerStyleProps, type BlockOuterStyleProps, type BlockStyleProps, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, type CSSMap, CSSOptions, type CSSProperties, CUSTOM_UNITS, type CacheMetrics, CacheStatus, ChunkBreakdown, type ChunkInfo, type ChunkName, ChunkSheetRegistry, type ColorSpace, type ColorStyleProps, type ComputeStylesOptions, type ComputeStylesResult, type ConditionNode, type ConfigTokenValue, type ConfigTokens, type ContainerStyleProps, type CounterStyleDescriptors, DEFAULT_NAME_PREFIX, DEFAULT_ZERO_NAME_PREFIX, DIMENSION_CHUNK_STYLES, DIMENSION_STYLES, DIRECTIONS, DISPLAY_CHUNK_STYLES, DebugChunkInfo, DebugOptions, type DimensionStyleProps, type DisposeFunction, Element, type ElementsDefinition, type ExtraBaseStyleProps, FLOW_STYLES, FONT_CHUNK_STYLES, type FlowStyleProps, type FontFaceDescriptors, type FontFaceInput, type FunctionDefinition, type FunctionParameter, type FunctionsConfig, type GCConfig, type GCOptions, INNER_STYLES, type InjectResult, type InjectionMode, type InnerStyleProps, InspectResult, type KeyframesCacheEntry, type KeyframesInfo, type KeyframesResult, type KeyframesSteps, LAYOUT_CHUNK_STYLES, type ModPropDef, type ModPropsInput, type ModValue, type Mods, type NoType, type NotSelector, OUTER_STYLES, type OuterStyleProps, POSITION_CHUNK_STYLES, POSITION_STYLES, type ParseFunction, type ParseStateKeyOptions, type ParsedAdvancedState, type ParsedColor, type ParserOptions, type PositionStyleProps, type ProcessedStyle, type PropHandler, type PropHandlerDefinition, type PropHandlerProps, type PropertyDefinition, type PropertyOptions, type QueuedWrite, type RawCSSResult, type RawStyleHandler, type RecipeStyles, type RenderResult, type ResolveAsProps, type ResolveModPropDef, type ResolveModProps, type ResolveTokenProps, type ResolvedStyleValue, type RootRegistry, type RuleInfo, STYLE_TO_CHUNK, type Selector, type SheetInfo, SheetManager, type ShortGridStyles, type StateParserContext, type StyleDetails, type StyleDetailsPart, type StyleHandler, type StyleHandlerDefinition, type StyleHandlerProps, type StyleHandlerResult, StyleInjector, type StyleInjectorConfig, type StyleMap, StyleParser, type StylePropValue, type StyleResult, type StyleRule, type StyleUsage, type StyleValue, type StyleValueStateMap, type Styles, type StylesInterface, type StylesWithoutSelectors, type SubElementDefinition, type SubElementProps, type SuffixForSelector, Summary, TEXT_STYLES, type TagName, type TastyBaseStylePropNames, TastyBatchProvider, type TastyBatchProviderProps, type TastyComponentPropsWithDefaults, type TastyConfig, type TastyCustomProps, type TastyElementOptions, type TastyElementProps, type TastyExtensionConfig, type TastyNamedColors, type TastyPlugin, type TastyPluginFactory, type TastyPolymorphicComponent, type TastyPresetNames, type TastyProps, type TastyThemeNames, type TextStyleProps, type TokenPropsInput, type TokenValue, type Tokens, TypographyPreset, TypographyTokenValue, type UnitHandler, type UseFunctionOptions, type UsePropertyOptions, type UseStylesResult, type VariantMap, type WithVariant, 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, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunction, okhslPlugin, okhstFunction, okhstPlugin, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { d 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-
|
|
7
|
-
import { t as getTastySSRContext } from "./context-
|
|
8
|
-
import { t as formatGlobalRules } from "./format-global-rules-
|
|
9
|
-
import { Fragment, createElement, forwardRef, useContext } from "react";
|
|
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-B5kHzuNz.js";
|
|
2
|
+
import { A as property, C as getRawCSSText, D as injector, E as injectRawCSS, M as ChunkSheetRegistry, N as chunkSheetRegistry, O as isPropertyDefined, P as resolveFunctionColor, S as getCSSTextForNode, T as injectGlobal, _ 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 touch, k as keyframes, 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 inject, x as getCSSText, y as func } from "./core-Dr4u1NVD.js";
|
|
3
|
+
import { l as categorizeStyleKeys } from "./keyframes-CV8azJf3.js";
|
|
4
|
+
import { n as formatPropertyCSS } from "./format-rules-DKOA-6qu.js";
|
|
5
|
+
import { t as mergeStyles } from "./merge-styles-oklji0KB.js";
|
|
6
|
+
import { t as resolveRecipes } from "./resolve-recipes-DTG81rzl.js";
|
|
7
|
+
import { t as getTastySSRContext } from "./context-CA8YKeMn.js";
|
|
8
|
+
import { t as formatGlobalRules } from "./format-global-rules-DklyaXv-.js";
|
|
9
|
+
import { Fragment, createElement, forwardRef, useContext, useInsertionEffect } from "react";
|
|
10
10
|
//#region src/utils/get-display-name.ts
|
|
11
11
|
const DEFAULT_NAME = "Anonymous";
|
|
12
12
|
function getDisplayName(Component, fallbackName = DEFAULT_NAME) {
|
|
@@ -106,7 +106,7 @@ function tasty(Component, options) {
|
|
|
106
106
|
return tastyElement(Component);
|
|
107
107
|
}
|
|
108
108
|
function tastyWrap(Component, options) {
|
|
109
|
-
const { as: extendTag, element: extendElement, ...defaultProps } = options ?? {};
|
|
109
|
+
const { as: extendTag, element: extendElement, styleProps: _styleProps, modProps: _modProps, tokenProps: _tokenProps, variants: _variants, elements: _elements, ...defaultProps } = options ?? {};
|
|
110
110
|
const propsWithStyles = ["styles"].concat(Object.keys(defaultProps).filter((prop) => prop.endsWith("Styles")));
|
|
111
111
|
const _WrappedComponent = forwardRef((props, ref) => {
|
|
112
112
|
const { as, element, ...restProps } = props;
|
|
@@ -154,14 +154,23 @@ function tastyElement(tastyOptions) {
|
|
|
154
154
|
if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
|
|
155
155
|
}
|
|
156
156
|
const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps ?? {};
|
|
157
|
-
const
|
|
157
|
+
const ownPropsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
|
|
158
|
+
let propsToCheck = ownPropsToCheck;
|
|
159
|
+
let propsToCheckVersion = -1;
|
|
158
160
|
const modPropsKeys = modPropsDef ? Array.isArray(modPropsDef) ? modPropsDef : Object.keys(modPropsDef) : void 0;
|
|
159
161
|
const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
|
|
160
162
|
const classNameCache = /* @__PURE__ */ new Map();
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
+
const STABLE_STYLES = { stableStyles: true };
|
|
164
|
+
const _TastyComponent = forwardRef((incomingProps, ref) => {
|
|
165
|
+
const applyPropHandlers = propHandlerRegistry.apply;
|
|
166
|
+
const { as, styles: rawStyles, variant, mods, element, qa, qaVal, className: userClassName, tokens, style, theme, ...otherProps } = applyPropHandlers ? applyPropHandlers(incomingProps) : incomingProps;
|
|
163
167
|
let styles = rawStyles;
|
|
164
168
|
let propStyles = null;
|
|
169
|
+
if (propsToCheckVersion !== baseStylePropsRegistry.version) {
|
|
170
|
+
const promoted = baseStylePropsRegistry.list;
|
|
171
|
+
propsToCheck = promoted.length === 0 ? ownPropsToCheck : ownPropsToCheck.concat(promoted);
|
|
172
|
+
propsToCheckVersion = baseStylePropsRegistry.version;
|
|
173
|
+
}
|
|
165
174
|
for (const prop of propsToCheck) {
|
|
166
175
|
const key = prop;
|
|
167
176
|
if (key in otherProps) {
|
|
@@ -198,7 +207,7 @@ function tastyElement(tastyOptions) {
|
|
|
198
207
|
stylesResult = { className: classNameCache.get(allStyles) };
|
|
199
208
|
touch(stylesResult.className);
|
|
200
209
|
} else {
|
|
201
|
-
stylesResult = computeStyles(allStyles);
|
|
210
|
+
stylesResult = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES : void 0);
|
|
202
211
|
if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, stylesResult.className);
|
|
203
212
|
}
|
|
204
213
|
let mergedTokens;
|
|
@@ -228,6 +237,7 @@ function tastyElement(tastyOptions) {
|
|
|
228
237
|
"data-element": element || defaultElement,
|
|
229
238
|
"data-qa": qa || defaultQa,
|
|
230
239
|
"data-qaval": qaVal || defaultQaVal,
|
|
240
|
+
"data-theme": theme,
|
|
231
241
|
...otherDefaultProps,
|
|
232
242
|
...modDataAttrs || {},
|
|
233
243
|
...otherProps,
|
|
@@ -236,6 +246,7 @@ function tastyElement(tastyOptions) {
|
|
|
236
246
|
ref
|
|
237
247
|
};
|
|
238
248
|
handleIsProperties(elementProps);
|
|
249
|
+
if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
|
|
239
250
|
const el = createElement(as ?? originalAs, elementProps);
|
|
240
251
|
if (stylesResult.css) {
|
|
241
252
|
const nonce = getConfig().nonce;
|
|
@@ -287,8 +298,41 @@ function useStyles(styles, options) {
|
|
|
287
298
|
});
|
|
288
299
|
}
|
|
289
300
|
//#endregion
|
|
301
|
+
//#region src/utils/client-state.ts
|
|
302
|
+
/**
|
|
303
|
+
* Build a per-(injector, root) client state cache for the standalone style
|
|
304
|
+
* functions (`useGlobalStyles`, `useRawCSS`, `useKeyframes`, `useCounterStyle`).
|
|
305
|
+
*
|
|
306
|
+
* Two levels, both weak:
|
|
307
|
+
*
|
|
308
|
+
* - **injector** — `configure()` replaces the global injector, and every dispose
|
|
309
|
+
* handle and generated name we cache belongs to the one that produced it.
|
|
310
|
+
* Keying by injector makes stale state fall away with it, instead of letting
|
|
311
|
+
* change-detection keys suppress re-injection into the new sheets.
|
|
312
|
+
* - **root** — the same selector or slot name can be used in several shadow
|
|
313
|
+
* roots, and each holds its own injection.
|
|
314
|
+
*/
|
|
315
|
+
function createClientState(create) {
|
|
316
|
+
const byInjector = /* @__PURE__ */ new WeakMap();
|
|
317
|
+
return (root) => {
|
|
318
|
+
const injector = getGlobalInjector();
|
|
319
|
+
let byRoot = byInjector.get(injector);
|
|
320
|
+
if (!byRoot) {
|
|
321
|
+
byRoot = /* @__PURE__ */ new WeakMap();
|
|
322
|
+
byInjector.set(injector, byRoot);
|
|
323
|
+
}
|
|
324
|
+
let state = byRoot.get(root);
|
|
325
|
+
if (!state) {
|
|
326
|
+
state = create();
|
|
327
|
+
byRoot.set(root, state);
|
|
328
|
+
}
|
|
329
|
+
return state;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
290
333
|
//#region src/hooks/useGlobalStyles.ts
|
|
291
|
-
const
|
|
334
|
+
const getClientGlobalSlots = createClientState(() => /* @__PURE__ */ new Map());
|
|
335
|
+
const noop = () => {};
|
|
292
336
|
/**
|
|
293
337
|
* Inject global styles for a given selector.
|
|
294
338
|
* Useful for styling elements by selector without generating classNames.
|
|
@@ -302,6 +346,10 @@ const clientGlobalEntries = /* @__PURE__ */ new Map();
|
|
|
302
346
|
* Use the `id` option for update tracking when styles change over the
|
|
303
347
|
* component lifecycle.
|
|
304
348
|
*
|
|
349
|
+
* Update tracking is per-slot and per-root: a slot (`id`, or the selector when
|
|
350
|
+
* no `id` is given) holds exactly one injection per `root`. Changing the styles
|
|
351
|
+
* replaces it; rendering styles that produce no CSS clears it.
|
|
352
|
+
*
|
|
305
353
|
* @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')
|
|
306
354
|
* @param styles - Tasty styles object
|
|
307
355
|
* @param options - Optional settings including `id` for update tracking
|
|
@@ -326,21 +374,29 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
326
374
|
return;
|
|
327
375
|
}
|
|
328
376
|
const target = getStyleTarget();
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
377
|
+
const slots = target.mode === "client" ? getClientGlobalSlots(options?.root ?? document) : null;
|
|
378
|
+
const slotKey = options?.id ?? selector;
|
|
379
|
+
const stylesKey = slots ? JSON.stringify(styles) : "";
|
|
380
|
+
const existing = slots?.get(slotKey);
|
|
381
|
+
if (existing && existing.stylesKey === stylesKey) return;
|
|
335
382
|
const resolvedStyles = resolveRecipes(styles);
|
|
336
383
|
const styleResults = renderStyles(resolvedStyles, selector);
|
|
337
|
-
if (styleResults.length === 0)
|
|
384
|
+
if (styleResults.length === 0) {
|
|
385
|
+
if (slots) {
|
|
386
|
+
existing?.dispose();
|
|
387
|
+
slots.set(slotKey, {
|
|
388
|
+
stylesKey,
|
|
389
|
+
dispose: noop
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
338
394
|
if (target.mode === "ssr") {
|
|
339
395
|
target.collector.collectInternals();
|
|
340
396
|
const css = formatGlobalRules(styleResults);
|
|
341
397
|
if (css) {
|
|
342
398
|
const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
|
|
343
|
-
target.collector.collectGlobalStyles(key, css);
|
|
399
|
+
target.collector.collectGlobalStyles(key, css, options?.id != null);
|
|
344
400
|
}
|
|
345
401
|
if (getConfig().autoPropertyTypes !== false) collectAutoInferredProperties(styleResults, target.collector, resolvedStyles);
|
|
346
402
|
return;
|
|
@@ -349,19 +405,19 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
349
405
|
const css = formatGlobalRules(styleResults);
|
|
350
406
|
if (css) {
|
|
351
407
|
const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
|
|
352
|
-
pushRSCCSS(target.cache, key, css);
|
|
408
|
+
pushRSCCSS(target.cache, key, css, options?.id != null);
|
|
353
409
|
}
|
|
354
410
|
if (getConfig().autoPropertyTypes !== false) collectAutoInferredPropertiesRSC(styleResults, target.cache, resolvedStyles);
|
|
355
411
|
return;
|
|
356
412
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
413
|
+
if (slots) {
|
|
414
|
+
existing?.dispose();
|
|
415
|
+
const { dispose } = injectGlobal(styleResults, { root: options?.root });
|
|
416
|
+
slots.set(slotKey, {
|
|
417
|
+
stylesKey,
|
|
418
|
+
dispose
|
|
419
|
+
});
|
|
420
|
+
}
|
|
365
421
|
}
|
|
366
422
|
//#endregion
|
|
367
423
|
//#region src/utils/deps-equal.ts
|
|
@@ -377,9 +433,11 @@ function depsEqual(a, b) {
|
|
|
377
433
|
}
|
|
378
434
|
//#endregion
|
|
379
435
|
//#region src/hooks/useRawCSS.ts
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
436
|
+
const getClientState$1 = createClientState(() => ({
|
|
437
|
+
entries: /* @__PURE__ */ new Map(),
|
|
438
|
+
contentDedup: /* @__PURE__ */ new Set(),
|
|
439
|
+
factoryDeps: /* @__PURE__ */ new Map()
|
|
440
|
+
}));
|
|
383
441
|
/**
|
|
384
442
|
* Inject raw CSS text directly without parsing.
|
|
385
443
|
* This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
|
|
@@ -435,53 +493,59 @@ function useRawCSS(cssOrFactory, depsOrOptions, options) {
|
|
|
435
493
|
const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
|
|
436
494
|
const opts = isFactory ? options : depsOrOptions;
|
|
437
495
|
const target = getStyleTarget();
|
|
438
|
-
|
|
439
|
-
|
|
496
|
+
const state = target.mode === "client" ? getClientState$1(opts?.root ?? document) : null;
|
|
497
|
+
if (isFactory && deps && opts?.id && state) {
|
|
498
|
+
const cachedDeps = state.factoryDeps.get(opts.id);
|
|
440
499
|
if (cachedDeps && depsEqual(cachedDeps, deps)) return;
|
|
441
500
|
}
|
|
442
501
|
const css = isFactory ? cssOrFactory() : cssOrFactory;
|
|
443
502
|
if (!css.trim()) return;
|
|
444
503
|
if (target.mode === "ssr") {
|
|
445
504
|
const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;
|
|
446
|
-
target.collector.collectRawCSS(key, css);
|
|
505
|
+
target.collector.collectRawCSS(key, css, opts?.id != null);
|
|
447
506
|
return;
|
|
448
507
|
}
|
|
449
508
|
if (target.mode === "rsc") {
|
|
450
509
|
const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;
|
|
451
|
-
pushRSCCSS(target.cache, key, css);
|
|
510
|
+
pushRSCCSS(target.cache, key, css, opts?.id != null);
|
|
452
511
|
return;
|
|
453
512
|
}
|
|
513
|
+
if (!state) return;
|
|
454
514
|
const id = opts?.id;
|
|
455
515
|
if (id) {
|
|
456
|
-
const existing =
|
|
516
|
+
const existing = state.entries.get(id);
|
|
457
517
|
if (existing) {
|
|
458
518
|
if (existing.contentKey === css) return;
|
|
459
519
|
existing.dispose();
|
|
460
520
|
}
|
|
461
521
|
const { dispose } = injectRawCSS(css, opts);
|
|
462
|
-
|
|
522
|
+
state.entries.set(id, {
|
|
463
523
|
contentKey: css,
|
|
464
524
|
dispose
|
|
465
525
|
});
|
|
466
|
-
if (deps)
|
|
526
|
+
if (deps) state.factoryDeps.set(id, deps);
|
|
467
527
|
} else {
|
|
468
528
|
const contentKey = hashString(css);
|
|
469
|
-
if (
|
|
470
|
-
|
|
529
|
+
if (state.contentDedup.has(contentKey)) return;
|
|
530
|
+
state.contentDedup.add(contentKey);
|
|
471
531
|
injectRawCSS(css, opts);
|
|
472
532
|
}
|
|
473
533
|
}
|
|
474
534
|
//#endregion
|
|
475
535
|
//#region src/hooks/useKeyframes.ts
|
|
476
|
-
const
|
|
477
|
-
|
|
536
|
+
const getClientState = createClientState(() => ({
|
|
537
|
+
contentToName: /* @__PURE__ */ new Map(),
|
|
538
|
+
namedSlots: /* @__PURE__ */ new Map(),
|
|
539
|
+
factoryDeps: /* @__PURE__ */ new Map()
|
|
540
|
+
}));
|
|
478
541
|
function useKeyframes(stepsOrFactory, depsOrOptions, options) {
|
|
479
542
|
const isFactory = typeof stepsOrFactory === "function";
|
|
480
543
|
const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
|
|
481
544
|
const opts = isFactory ? options : depsOrOptions;
|
|
482
545
|
const target = getStyleTarget();
|
|
483
|
-
|
|
484
|
-
|
|
546
|
+
const clientState = target.mode === "client" ? getClientState(opts?.root ?? document) : null;
|
|
547
|
+
if (isFactory && deps && opts?.name && clientState) {
|
|
548
|
+
const cached = clientState.factoryDeps.get(opts.name);
|
|
485
549
|
if (cached && depsEqual(cached.deps, deps)) return cached.name;
|
|
486
550
|
}
|
|
487
551
|
const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
|
|
@@ -497,25 +561,42 @@ function useKeyframes(stepsOrFactory, depsOrOptions, options) {
|
|
|
497
561
|
const key = `__kf:${opts?.name ?? ""}:${serializedContent}`;
|
|
498
562
|
const existingName = target.cache.generatedNames.get(key);
|
|
499
563
|
if (existingName) return existingName;
|
|
500
|
-
const actualName = opts?.name ??
|
|
564
|
+
const actualName = opts?.name ?? makeKeyframeName(getNamePrefix(), hashString(serializedContent));
|
|
501
565
|
const css = formatKeyframesCSS(actualName, steps);
|
|
502
566
|
pushRSCCSS(target.cache, key, css);
|
|
503
567
|
target.cache.generatedNames.set(key, actualName);
|
|
504
568
|
return actualName;
|
|
505
569
|
}
|
|
570
|
+
const state = clientState ?? getClientState(opts?.root ?? document);
|
|
506
571
|
const serializedContent = JSON.stringify(steps);
|
|
507
572
|
const cacheKey = `${opts?.name ?? ""}:${serializedContent}`;
|
|
508
|
-
const cachedName =
|
|
573
|
+
const cachedName = state.contentToName.get(cacheKey);
|
|
509
574
|
if (cachedName) return cachedName;
|
|
510
|
-
const
|
|
511
|
-
|
|
575
|
+
const providedName = opts?.name;
|
|
576
|
+
if (providedName) {
|
|
577
|
+
const slot = state.namedSlots.get(providedName);
|
|
578
|
+
if (slot && slot.cacheKey !== cacheKey) {
|
|
579
|
+
slot.dispose();
|
|
580
|
+
state.contentToName.delete(slot.cacheKey);
|
|
581
|
+
state.namedSlots.delete(providedName);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
const result = keyframes(steps, {
|
|
585
|
+
name: providedName,
|
|
512
586
|
root: opts?.root
|
|
513
|
-
}).toString();
|
|
514
|
-
clientContentToName$1.set(cacheKey, name);
|
|
515
|
-
if (deps && opts?.name) factoryDepsCache.set(opts.name, {
|
|
516
|
-
deps,
|
|
517
|
-
name
|
|
518
587
|
});
|
|
588
|
+
const name = result.toString();
|
|
589
|
+
state.contentToName.set(cacheKey, name);
|
|
590
|
+
if (providedName) {
|
|
591
|
+
state.namedSlots.set(providedName, {
|
|
592
|
+
cacheKey,
|
|
593
|
+
dispose: result.dispose
|
|
594
|
+
});
|
|
595
|
+
if (deps) state.factoryDeps.set(providedName, {
|
|
596
|
+
deps,
|
|
597
|
+
name
|
|
598
|
+
});
|
|
599
|
+
}
|
|
519
600
|
return name;
|
|
520
601
|
}
|
|
521
602
|
//#endregion
|
|
@@ -671,7 +752,7 @@ function useFontFace(family, input, options) {
|
|
|
671
752
|
//#endregion
|
|
672
753
|
//#region src/hooks/useCounterStyle.ts
|
|
673
754
|
let clientCounterStyleCounter = 0;
|
|
674
|
-
const
|
|
755
|
+
const getClientContentToName = createClientState(() => /* @__PURE__ */ new Map());
|
|
675
756
|
/**
|
|
676
757
|
* Inject a CSS @counter-style rule and return the generated name.
|
|
677
758
|
* Permanent — no cleanup on unmount. Deduplicates by name.
|
|
@@ -711,22 +792,131 @@ function useCounterStyle(descriptors, options) {
|
|
|
711
792
|
const key = `__cs:${options?.name ?? ""}:${serializedContent}`;
|
|
712
793
|
const existingName = target.cache.generatedNames.get(key);
|
|
713
794
|
if (existingName) return existingName;
|
|
714
|
-
const actualName = options?.name ??
|
|
795
|
+
const actualName = options?.name ?? makeCounterStyleName(getNamePrefix(), hashString(serializedContent));
|
|
715
796
|
const css = formatCounterStyleRule(actualName, descriptors);
|
|
716
797
|
pushRSCCSS(target.cache, key, css);
|
|
717
798
|
target.cache.generatedNames.set(key, actualName);
|
|
718
799
|
return actualName;
|
|
719
800
|
}
|
|
801
|
+
const contentToName = getClientContentToName(options?.root ?? document);
|
|
720
802
|
const serializedContent = JSON.stringify(descriptors);
|
|
721
803
|
const cacheKey = `${options?.name ?? ""}:${serializedContent}`;
|
|
722
|
-
const existingName =
|
|
804
|
+
const existingName = contentToName.get(cacheKey);
|
|
723
805
|
if (existingName) return existingName;
|
|
724
|
-
const name = options?.name ??
|
|
725
|
-
|
|
806
|
+
const name = options?.name ?? makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));
|
|
807
|
+
contentToName.set(cacheKey, name);
|
|
726
808
|
getGlobalInjector().counterStyle(name, descriptors, { root: options?.root });
|
|
727
809
|
return name;
|
|
728
810
|
}
|
|
729
811
|
//#endregion
|
|
730
|
-
|
|
812
|
+
//#region src/hooks/useFunction.ts
|
|
813
|
+
/**
|
|
814
|
+
* Register a CSS @function (custom function).
|
|
815
|
+
*
|
|
816
|
+
* @function rules are global and persistent once defined. The hook ensures the
|
|
817
|
+
* function is only registered once per root (deduplicated by function name).
|
|
818
|
+
*
|
|
819
|
+
* Accepts tasty token syntax for the function name:
|
|
820
|
+
* - `$$name` → defines `--name` (matches the call site `$$name(...)`)
|
|
821
|
+
* - `$name` / `--name` → also accepted
|
|
822
|
+
*
|
|
823
|
+
* Works in all environments: client, SSR with collector, and React Server Components.
|
|
824
|
+
*
|
|
825
|
+
* @param name - The function name token (`$$name`, `$name`, or `--name`)
|
|
826
|
+
* @param definition - Function definition (args, returns, result, local vars)
|
|
827
|
+
*
|
|
828
|
+
* Call the function through the Tasty DSL, not a raw `style` prop: an inline
|
|
829
|
+
* `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never
|
|
830
|
+
* expanded and `polyfills.functions` cannot rewrite it either.
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* ```tsx
|
|
834
|
+
* const Box = tasty({ styles: { marginTop: '$$negative(10px)' } });
|
|
835
|
+
*
|
|
836
|
+
* function Layout() {
|
|
837
|
+
* useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
|
|
838
|
+
* return <Box />;
|
|
839
|
+
* }
|
|
840
|
+
* ```
|
|
841
|
+
*/
|
|
842
|
+
function useFunction(name, definition, options) {
|
|
843
|
+
if (!name) {
|
|
844
|
+
console.warn(`[Tasty] useFunction: function name is required`);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (isFunctionsPolyfillEnabled()) {
|
|
848
|
+
registerFunctionPolyfill(name, definition);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
const target = getStyleTarget();
|
|
852
|
+
if (target.mode === "ssr") {
|
|
853
|
+
target.collector.collectInternals();
|
|
854
|
+
const css = formatFunctionRule(name, definition);
|
|
855
|
+
if (css) target.collector.collectFunction(parseFunctionName(name), css);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if (target.mode === "rsc") {
|
|
859
|
+
const css = formatFunctionRule(name, definition);
|
|
860
|
+
if (css) pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
getGlobalInjector().func(name, definition, { root: options?.root });
|
|
864
|
+
}
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region src/batch-provider.tsx
|
|
867
|
+
/**
|
|
868
|
+
* Opens a *batch window* for the commit it renders in, so `batchInjection`
|
|
869
|
+
* can defer stylesheet writes without ever letting a layout effect measure an
|
|
870
|
+
* unstyled element.
|
|
871
|
+
*
|
|
872
|
+
* Every `insertRule()` on a live sheet invalidates style for that sheet's
|
|
873
|
+
* scope. When components inject during React's render phase while others read
|
|
874
|
+
* layout in the same pass, the two interleave and the browser recalculates
|
|
875
|
+
* style between every injection. Batching collapses that into one invalidation
|
|
876
|
+
* per flush — but only if the flush happens before anything can measure.
|
|
877
|
+
*
|
|
878
|
+
* ```
|
|
879
|
+
* provider renders -> window OPEN
|
|
880
|
+
* children render -> injections queued
|
|
881
|
+
* provider insertionEffect -> FLUSH, window CLOSED
|
|
882
|
+
* layout effects run -> rules are in the sheet
|
|
883
|
+
* ```
|
|
884
|
+
*
|
|
885
|
+
* `useInsertionEffect` runs in React's mutation phase, after every render in
|
|
886
|
+
* the commit and before any `useLayoutEffect` — which is exactly why React
|
|
887
|
+
* added it for CSS-in-JS libraries. Effects fire child-first, so this
|
|
888
|
+
* provider's runs after every descendant's and still before all layout
|
|
889
|
+
* effects.
|
|
890
|
+
*
|
|
891
|
+
* A commit that does not re-render this provider gets no window, and those
|
|
892
|
+
* injections are written synchronously instead. That is the point: turning
|
|
893
|
+
* `batchInjection: true` on can only ever make injection cheaper, never make a
|
|
894
|
+
* measurement wrong. It also means batching applies to commits this provider
|
|
895
|
+
* takes part in, so mount it as high in the tree as you can.
|
|
896
|
+
*
|
|
897
|
+
* Requires `configure({ batchInjection: true })`; without it this component
|
|
898
|
+
* only renders its children. `batchInjection: 'always'` does not need the
|
|
899
|
+
* provider at all — see that option's docs for the trade-off it accepts.
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```tsx
|
|
903
|
+
* configure({ batchInjection: true });
|
|
904
|
+
*
|
|
905
|
+
* createRoot(el).render(
|
|
906
|
+
* <TastyBatchProvider>
|
|
907
|
+
* <App />
|
|
908
|
+
* </TastyBatchProvider>,
|
|
909
|
+
* );
|
|
910
|
+
* ```
|
|
911
|
+
*/
|
|
912
|
+
function TastyBatchProvider({ children }) {
|
|
913
|
+
openBatchWindow();
|
|
914
|
+
useInsertionEffect(() => {
|
|
915
|
+
closeBatchWindow();
|
|
916
|
+
});
|
|
917
|
+
return children;
|
|
918
|
+
}
|
|
919
|
+
//#endregion
|
|
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, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunction, okhslPlugin, okhstFunction, okhstPlugin, 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 };
|
|
731
921
|
|
|
732
922
|
//# sourceMappingURL=index.js.map
|