@tenphi/tasty 3.4.0 → 3.6.0
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 +147 -129
- package/dist/astro-CzY4LCpr.js +437 -0
- package/dist/astro-CzY4LCpr.js.map +1 -0
- package/dist/{babel-BUQGeOXA.d.ts → babel-DWCsafYw.d.ts} +2 -2
- package/dist/{collector-DUaHCcTS.d.ts → collector-BTVXj2hS.d.ts} +21 -3
- package/dist/{collector-DTahQUiV.js → collector-C6TtL8HJ.js} +36 -13
- package/dist/collector-C6TtL8HJ.js.map +1 -0
- package/dist/{config-B5kHzuNz.js → config-B3gPdCqd.js} +305 -153
- package/dist/config-B3gPdCqd.js.map +1 -0
- package/dist/{config-YsxGv4tq.d.ts → config-LfIDmVHx.d.ts} +132 -32
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-Dr4u1NVD.js → core-Bq7w2kti.js} +215 -95
- package/dist/core-Bq7w2kti.js.map +1 -0
- package/dist/{css-writer-B-J87ncv.js → css-writer-Bgowobbx.js} +3 -3
- package/dist/{css-writer-B-J87ncv.js.map → css-writer-Bgowobbx.js.map} +1 -1
- package/dist/{format-rules-DKOA-6qu.js → format-rules-rCZ37rqY.js} +2 -2
- package/dist/format-rules-rCZ37rqY.js.map +1 -0
- package/dist/{hydrate-OeMX99We.js → hydrate-CNOmZprz.js} +3 -3
- package/dist/{hydrate-OeMX99We.js.map → hydrate-CNOmZprz.js.map} +1 -1
- package/dist/{index-PqN-DIpn.d.ts → index-Bm9ltvdH.d.ts} +38 -16
- package/dist/{index-Cd45t5NM.d.ts → index-BmogEzTo.d.ts} +69 -15
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-CV8azJf3.js → keyframes-DE-OE76F.js} +45 -3
- package/dist/keyframes-DE-OE76F.js.map +1 -0
- package/dist/{merge-styles-CU7JbEwg.d.ts → merge-styles-BcLl1u_d.d.ts} +2 -2
- package/dist/{merge-styles-oklji0KB.js → merge-styles-DuoZEsm9.js} +2 -2
- package/dist/{merge-styles-oklji0KB.js.map → merge-styles-DuoZEsm9.js.map} +1 -1
- package/dist/{resolve-recipes-DTG81rzl.js → resolve-recipes-H9NqOQuP.js} +3 -3
- package/dist/{resolve-recipes-DTG81rzl.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.d.ts +1 -1
- package/dist/ssr/next.js +4 -4
- 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/README.md +13 -8
- package/docs/adoption.md +56 -31
- package/docs/ai-agents.md +78 -77
- package/docs/comparison.md +69 -40
- package/docs/configuration.md +97 -87
- package/docs/debug.md +4 -2
- package/docs/design-system.md +41 -22
- package/docs/dsl.md +225 -195
- package/docs/getting-started.md +60 -39
- package/docs/injector.md +63 -26
- package/docs/methodology.md +42 -36
- package/docs/migration-v3.md +49 -49
- package/docs/plugins.md +37 -33
- package/docs/react-api.md +65 -44
- package/docs/runtime-benchmarks.md +178 -0
- package/docs/ssr.md +124 -61
- package/docs/styles.md +1 -1
- package/docs/tasty-static.md +137 -104
- package/package.json +26 -8
- package/dist/collector-DTahQUiV.js.map +0 -1
- package/dist/config-B5kHzuNz.js.map +0 -1
- package/dist/core-Dr4u1NVD.js.map +0 -1
- package/dist/format-rules-DKOA-6qu.js.map +0 -1
- package/dist/keyframes-CV8azJf3.js.map +0 -1
- package/dist/ssr/astro.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["modAttrs","getClientState"],"sources":["../src/utils/get-display-name.ts","../src/utils/is-valid-element-type.ts","../src/tasty.tsx","../src/hooks/useStyles.ts","../src/utils/client-state.ts","../src/hooks/useGlobalStyles.ts","../src/utils/deps-equal.ts","../src/hooks/useRawCSS.ts","../src/hooks/useKeyframes.ts","../src/hooks/useProperty.ts","../src/hooks/useFontFace.ts","../src/hooks/useCounterStyle.ts","../src/hooks/useFunction.ts","../src/batch-provider.tsx"],"sourcesContent":["import type { ElementType } from 'react';\n\nconst DEFAULT_NAME = 'Anonymous';\n\nexport function getDisplayName<T>(\n Component: ElementType<T>,\n fallbackName = DEFAULT_NAME,\n): string {\n if (typeof Component === 'function') {\n return Component.displayName ?? Component.name ?? fallbackName;\n }\n\n return fallbackName;\n}\n","/**\n * Lightweight replacement for `react-is`'s isValidElementType.\n * Detects string tags, function/class components, and React exotic types\n * (forwardRef, memo, lazy, etc.) via their internal $$typeof symbol.\n */\nexport function isValidElementType(value: unknown): boolean {\n if (typeof value === 'string' || typeof value === 'function') {\n return true;\n }\n\n if (typeof value === 'object' && value !== null) {\n return typeof (value as { $$typeof?: unknown }).$$typeof === 'symbol';\n }\n\n return false;\n}\n","import type {\n AllHTMLAttributes,\n ComponentType,\n ElementType,\n ForwardRefExoticComponent,\n JSX,\n PropsWithoutRef,\n RefAttributes,\n} from 'react';\nimport { createElement, forwardRef, Fragment } from 'react';\nimport type {\n ComputeStylesOptions,\n ComputeStylesResult,\n} from './compute-styles';\nimport { computeStyles } from './compute-styles';\nimport type { PropHandlerProps } from './prop-handlers';\nimport { propHandlerRegistry } from './prop-handlers';\nimport { baseStylePropsRegistry } from './styles/base-props';\nimport { BASE_STYLES } from './styles/list';\nimport type { Styles, StylesInterface } from './styles/types';\nimport type {\n AllBaseProps,\n BaseProps,\n BaseStyleProps,\n ExtraBaseStyleProps,\n ModValue,\n Mods,\n TastyCustomProps,\n TokenValue,\n Tokens,\n} from './types';\nimport { getDisplayName } from './utils/get-display-name';\nimport { isValidElementType } from './utils/is-valid-element-type';\nimport { mergeStyles } from './utils/merge-styles';\nimport { isSelector } from './pipeline';\nimport { hasKeys } from './utils/has-keys';\nimport { modAttrs } from './utils/mod-attrs';\nimport { processTokens } from './utils/process-tokens';\nimport { getConfig } from './config';\nimport { touch } from './injector';\n\nimport type { StyleValue, StyleValueStateMap } from './utils/styles';\n\n/**\n * Mapping of is* properties to their corresponding HTML attributes\n */\nconst IS_PROPERTIES_MAP = {\n isDisabled: 'disabled',\n isHidden: 'hidden',\n isChecked: 'checked',\n} as const;\n\n/**\n * Precalculated entries for performance optimization\n */\nconst IS_PROPERTIES_ENTRIES = Object.entries(IS_PROPERTIES_MAP);\n\n/**\n * Helper function to handle is* properties consistently\n * Transforms is* props to HTML attributes and adds corresponding data-* attributes\n */\nfunction handleIsProperties(props: Record<string, unknown>) {\n for (const [isProperty, targetAttribute] of IS_PROPERTIES_ENTRIES) {\n if (isProperty in props) {\n props[targetAttribute] = props[isProperty];\n delete props[isProperty];\n }\n\n // Add data-* attribute if target attribute is truthy and doesn't already exist\n const dataAttribute = `data-${targetAttribute}`;\n if (!(dataAttribute in props) && props[targetAttribute]) {\n props[dataAttribute] = '';\n }\n }\n}\n\n/**\n * Creates a sub-element component for compound component patterns.\n * Sub-elements are lightweight components with data-element attribute for CSS targeting.\n */\nfunction createSubElement<Tag extends keyof JSX.IntrinsicElements>(\n elementName: string,\n definition: SubElementDefinition<Tag>,\n): ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<Tag>> & RefAttributes<unknown>\n> {\n // Normalize definition to object form\n const config =\n typeof definition === 'string'\n ? { as: definition as Tag }\n : (definition as { as?: Tag; qa?: string; qaVal?: string | number });\n\n const tag = config.as ?? ('div' as Tag);\n const defaultQa = config.qa;\n const defaultQaVal = config.qaVal;\n\n const SubElement = forwardRef<unknown, SubElementProps<Tag>>((props, ref) => {\n const {\n qa,\n qaVal,\n mods,\n tokens,\n isDisabled,\n isHidden,\n isChecked,\n className,\n style,\n ...htmlProps\n } = props as SubElementProps<Tag> & {\n className?: string;\n style?: Record<string, unknown>;\n };\n\n // Build mod attributes\n let modDataAttrs: Record<string, unknown> | undefined;\n if (mods) {\n modDataAttrs = modAttrs(mods as Mods) as Record<string, unknown>;\n }\n\n // Process tokens into inline style properties\n const tokenStyle = tokens\n ? (processTokens(tokens) as Record<string, unknown>)\n : undefined;\n\n // Merge token styles with explicit style prop (style has priority)\n let mergedStyle: Record<string, unknown> | undefined;\n if (tokenStyle || style) {\n mergedStyle =\n tokenStyle && style\n ? { ...tokenStyle, ...style }\n : ((tokenStyle ?? style) as Record<string, unknown>);\n }\n\n const elementProps = {\n 'data-element': elementName,\n 'data-qa': qa ?? defaultQa,\n 'data-qaval': qaVal ?? defaultQaVal,\n ...(modDataAttrs || {}),\n ...htmlProps,\n className,\n style: mergedStyle,\n isDisabled,\n isHidden,\n isChecked,\n ref,\n } as Record<string, unknown>;\n\n // Handle is* properties (isDisabled -> disabled + data-disabled, etc.)\n handleIsProperties(elementProps);\n\n // Clean up undefined data attributes\n if (elementProps['data-qa'] === undefined) delete elementProps['data-qa'];\n if (elementProps['data-qaval'] === undefined)\n delete elementProps['data-qaval'];\n\n return createElement(tag, elementProps);\n });\n\n SubElement.displayName = `SubElement(${elementName})`;\n\n return SubElement as ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<Tag>> & RefAttributes<unknown>\n >;\n}\n\ntype StyleList = readonly (keyof {\n [key in keyof StylesInterface]: StylesInterface[key];\n})[];\n\n// ============================================================================\n// Mod props types — expose modifier keys as top-level component props\n// ============================================================================\n\n/** Type descriptor for a single mod prop: a JS constructor or an enum array. */\nexport type ModPropDef =\n | BooleanConstructor\n | StringConstructor\n | NumberConstructor\n | readonly string[];\n\n/** Array form: list of mod key names (types default to ModValue). */\ntype ModPropsList = readonly string[];\n\n/** Object form: map of mod key names to type descriptors. */\ntype ModPropsMap = Readonly<Record<string, ModPropDef>>;\n\n/** Either array or object form accepted by `modProps` option. */\nexport type ModPropsInput = ModPropsList | ModPropsMap;\n\n/** Resolve a single ModPropDef to its TypeScript type. */\nexport type ResolveModPropDef<T> = T extends BooleanConstructor\n ? boolean\n : T extends StringConstructor\n ? string\n : T extends NumberConstructor\n ? number\n : T extends readonly (infer U)[]\n ? U\n : ModValue;\n\n/** Resolve an entire `modProps` definition to the component prop types it adds. */\nexport type ResolveModProps<M extends ModPropsInput> =\n M extends readonly (infer K)[]\n ? Partial<Record<K & string, ModValue>>\n : M extends Record<string, ModPropDef>\n ? { [key in keyof M & string]?: ResolveModPropDef<M[key]> }\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\n// ============================================================================\n// Token props types — expose token keys as top-level component props\n// ============================================================================\n\n/** A token key with `$` or `#` prefix. */\ntype TokenPropKey = `$${string}` | `#${string}`;\n\n/** Array form: list of prop names. Names ending in `Color` map to `#` color tokens. */\ntype TokenPropsList = readonly string[];\n\n/** Object form: prop name -> token key with explicit `$`/`#` prefix. */\ntype TokenPropsMap = Readonly<Record<string, TokenPropKey>>;\n\n/** Either array or object form accepted by `tokenProps` option. */\nexport type TokenPropsInput = TokenPropsList | TokenPropsMap;\n\n/** Resolve a `tokenProps` definition to the component prop types it adds. */\nexport type ResolveTokenProps<TP extends TokenPropsInput> =\n TP extends readonly (infer K)[]\n ? Partial<Record<K & string, TokenValue>>\n : TP extends Record<string, TokenPropKey>\n ? Partial<Record<keyof TP & string, TokenValue>>\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\n/**\n * Pre-compute the mapping from prop name to token key at component-creation time.\n * Array form: `'progress'` -> `'$progress'`, `'accentColor'` -> `'#accent'`.\n * Object form: entries used as-is.\n */\nfunction buildTokenPropsMapping(\n def: TokenPropsInput,\n): [propName: string, tokenKey: string][] {\n if (Array.isArray(def)) {\n return (def as string[]).map((propName) => {\n if (propName.endsWith('Color') && propName.length > 5) {\n return [propName, `#${propName.slice(0, -5)}`];\n }\n return [propName, `$${propName}`];\n });\n }\n return Object.entries(def);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyProps = Record<string, any>;\n\ntype PropsWithStyles = {\n styles?: Styles;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Omit<Record<string, any>, 'styles'>;\n\nexport type VariantMap = Record<string, Styles>;\n\nexport interface WithVariant<V extends VariantMap> {\n variant?: keyof V;\n}\n\n// ============================================================================\n// Sub-element types for compound components\n// ============================================================================\n\n/**\n * Definition for a sub-element. Can be either:\n * - A tag name string (e.g., 'div', 'span')\n * - An object with configuration options\n */\nexport type SubElementDefinition<\n Tag extends keyof JSX.IntrinsicElements = 'div',\n> =\n | Tag\n | {\n as?: Tag;\n qa?: string;\n qaVal?: string | number;\n };\n\n/**\n * Map of sub-element definitions.\n * Keys become the sub-component names (e.g., { Icon: 'span' } -> Component.Icon)\n */\nexport type ElementsDefinition = Record<\n string,\n SubElementDefinition<keyof JSX.IntrinsicElements>\n>;\n\n/**\n * Resolves the tag from a SubElementDefinition\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ResolveElementTag<T extends SubElementDefinition<any>> = T extends string\n ? T\n : T extends { as?: infer Tag }\n ? Tag extends keyof JSX.IntrinsicElements\n ? Tag\n : 'div'\n : 'div';\n\n/**\n * Props for sub-element components.\n * Combines HTML attributes with tasty-specific props (qa, qaVal, mods, tokens, isDisabled, etc.)\n */\nexport type SubElementProps<Tag extends keyof JSX.IntrinsicElements = 'div'> =\n Omit<\n JSX.IntrinsicElements[Tag],\n 'ref' | 'color' | 'content' | 'translate'\n > & {\n qa?: string;\n qaVal?: string | number;\n mods?: Mods;\n tokens?: Tokens;\n isDisabled?: boolean;\n isHidden?: boolean;\n isChecked?: boolean;\n };\n\n/**\n * Generates the sub-element component types from an ElementsDefinition\n */\ntype SubElementComponents<E extends ElementsDefinition> = {\n [K in keyof E]: ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<ResolveElementTag<E[K]>>> &\n RefAttributes<\n ResolveElementTag<E[K]> extends keyof HTMLElementTagNameMap\n ? HTMLElementTagNameMap[ResolveElementTag<E[K]>]\n : Element\n >\n >;\n};\n\n/**\n * Base type containing common properties shared between TastyProps and TastyElementOptions.\n * Separated to avoid code duplication while allowing different type constraints.\n */\ntype TastyBaseProps<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = {\n /** Default styles of the element. */\n styles?: Styles;\n /** The list of styles that can be provided by props */\n styleProps?: K;\n /** Modifier keys exposed as top-level component props (array or typed object form). */\n modProps?: M;\n /** Token keys exposed as top-level component props (array or typed object form). */\n tokenProps?: TP;\n element?: BaseProps['element'];\n variants?: V;\n /** Default tokens for inline CSS custom properties */\n tokens?: Tokens;\n /** Sub-element definitions for compound components */\n elements?: E;\n} & Pick<BaseProps, 'qa' | 'qaVal'> &\n WithVariant<V>;\n\nexport type TastyProps<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n DefaultProps = AnyProps,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = TastyBaseProps<K, V, E, M, TP> & {\n /** The tag name of the element or a React component. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n as?: string | ComponentType<any>;\n} & Partial<\n Omit<\n DefaultProps,\n 'as' | 'styles' | 'styleProps' | 'modProps' | 'tokenProps' | 'tokens'\n >\n >;\n\n/**\n * Resolves the props of a polymorphic `as` value (intrinsic tag or component).\n * - For intrinsic tags (`'div'`, `'button'`, ...): returns `JSX.IntrinsicElements[Tag]`.\n * - For React component types: returns the component's own props.\n * - Falls back to an empty record for anything else.\n */\nexport type ResolveAsProps<AsType extends ElementType> =\n AsType extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[AsType]\n : AsType extends ComponentType<infer P>\n ? P\n : Record<string, never>;\n\n/**\n * TastyElementOptions is used for the element-creation overload of tasty().\n * It includes an `AsType` generic that allows TypeScript to infer the correct\n * element type from the `as` prop — both for intrinsic tags and for React\n * components (so the wrapped component's prop API is preserved).\n *\n * Note: Uses a separate index signature with `unknown` instead of an `any`\n * record to ensure strict type checking for styles.\n */\nexport type TastyElementOptions<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = TastyBaseProps<K, V, E, M, TP> & {\n /** The tag name of the element or a React component. */\n as?: AsType;\n} & Record<string, unknown>;\n\nexport type AllBasePropsWithMods<\n K extends StyleList,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = AllBaseProps & {\n [key in K[number]]?:\n | StyleValue<StylesInterface[key]>\n | StyleValueStateMap<StylesInterface[key]>;\n} & BaseStyleProps &\n ExtraBaseStyleProps &\n Partial<TastyCustomProps> &\n ResolveModProps<M> &\n ResolveTokenProps<TP>;\n\n/**\n * Keys from BasePropsWithoutChildren that should be omitted from HTML attributes.\n * This excludes event handlers so they can be properly typed from JSX.IntrinsicElements.\n */\ntype TastySpecificKeys =\n | 'as'\n | 'qa'\n | 'qaVal'\n | 'element'\n | 'styles'\n | 'mods'\n | 'isHidden'\n | 'isDisabled'\n | 'isChecked'\n | 'style'\n | 'theme'\n | 'tokens'\n | 'ref'\n | 'color';\n\n/** Extract prop key names from a ModPropsInput (array elements or object keys). */\ntype ModPropsKeys<M extends ModPropsInput> = M extends readonly (infer K)[]\n ? K & string\n : keyof M & string;\n\n/** Extract prop key names from a TokenPropsInput (array elements or object keys). */\ntype TokenPropsKeys<TP extends TokenPropsInput> =\n TP extends readonly (infer K)[] ? K & string : keyof TP & string;\n\n/**\n * Props type for tasty elements that combines:\n * - AllBasePropsWithMods for style props with strict tokens type\n * - HTML attributes for flexibility (properly typed based on `as`)\n * - Variant support\n *\n * AllBasePropsWithMods carries generic AllHTMLAttributes which can conflict\n * with element-specific types (e.g. `src` is `string` in AllHTMLAttributes but\n * `string | Blob` in ImgHTMLAttributes, or the custom props on a third-party\n * component like Next.js `Link`). To avoid intersection-narrowing, we Omit\n * element-specific keys from AllBasePropsWithMods (keeping TastySpecificKeys,\n * style props, mod props, and token props) and let the resolved `as` props\n * supply the authoritative attribute types. The `AllHTMLAttributes<HTMLElement>`\n * baseline is preserved so generic HTML attributes still work even when `as`\n * is a component type with a narrower prop API.\n */\nexport type TastyElementProps<\n K extends StyleList,\n V extends VariantMap,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = Omit<\n AllBasePropsWithMods<K, M, TP>,\n Exclude<\n keyof ResolveAsProps<AsType>,\n | TastySpecificKeys\n | keyof TastyCustomProps\n | keyof ExtraBaseStyleProps\n | K[number]\n | ModPropsKeys<M>\n | TokenPropsKeys<TP>\n >\n> &\n WithVariant<V> &\n Omit<\n Omit<AllHTMLAttributes<HTMLElement>, keyof ResolveAsProps<AsType>> &\n ResolveAsProps<AsType>,\n | TastySpecificKeys\n | keyof TastyCustomProps\n | keyof ExtraBaseStyleProps\n | K[number]\n | ModPropsKeys<M>\n | TokenPropsKeys<TP>\n >;\n\nexport type TastyComponentPropsWithDefaults<\n Props extends PropsWithStyles,\n DefaultProps extends Partial<Props>,\n> = keyof DefaultProps extends never\n ? Props\n : {\n [key in Extract<keyof Props, keyof DefaultProps>]?: Props[key];\n } & {\n [key in keyof Omit<Props, keyof DefaultProps>]: Props[key];\n };\n\n/**\n * The component type returned by the `tasty(options)` element-factory overload.\n *\n * It's a regular React forward-ref component whose props are typed from the\n * factory-time `as` value. Polymorphism is at factory time: each call to\n * `tasty({ as: X })` produces a component whose prop API includes `X`'s own\n * props (so `tasty({ as: NextLink })` exposes `href`, `replace`, `prefetch`,\n * etc.) alongside the Tasty-specific props (`mods`, `tokens`, `styleProps`,\n * `modProps`, `tokenProps`).\n *\n * Note: a render-time `<X as={SomeComponent} />` does not re-infer props from\n * `SomeComponent`; create another `tasty({ as: SomeComponent })` for that.\n */\nexport type TastyPolymorphicComponent<\n DefaultAs extends ElementType,\n K extends StyleList,\n V extends VariantMap,\n M extends ModPropsInput,\n TP extends TokenPropsInput,\n> = ForwardRefExoticComponent<\n PropsWithoutRef<TastyElementProps<K, V, DefaultAs, M, TP>> &\n RefAttributes<unknown>\n>;\n\nexport function tasty<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n options: TastyElementOptions<K, V, E, AsType, M, TP>,\n secondArg?: never,\n): TastyPolymorphicComponent<AsType, K, V, M, TP> & SubElementComponents<E>;\nexport function tasty<\n Props extends PropsWithStyles,\n DefaultProps extends Partial<Props> = Partial<Props>,\n K extends StyleList = readonly never[],\n V extends VariantMap = VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n Component: ComponentType<Props>,\n options?: TastyProps<K, V, E, Props, M, TP>,\n): ComponentType<TastyComponentPropsWithDefaults<Props, DefaultProps>>;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// Implementation\nexport function tasty<\n K extends StyleList,\n V extends VariantMap,\n _C = Record<string, unknown>,\n>(Component: any, options?: any) {\n if (isValidElementType(Component)) {\n return tastyWrap(Component as ComponentType<any>, options);\n }\n\n return tastyElement(Component as TastyProps<K, V>);\n}\n\nfunction tastyWrap<\n P extends PropsWithStyles,\n DefaultProps extends Partial<P> = Partial<P>,\n K extends StyleList = readonly never[],\n V extends VariantMap = VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n Component: ComponentType<P>,\n options?: TastyProps<K, V, E, P, M, TP>,\n): ComponentType<TastyComponentPropsWithDefaults<P, DefaultProps>> {\n // The wrap path forwards default props + merges `styles`/`*Styles` props.\n // Factory-only options (`styleProps`, `modProps`, `tokenProps`, `variants`,\n // `elements`) are stripped here, not forwarded to the wrapped component.\n const {\n as: extendTag,\n element: extendElement,\n styleProps: _styleProps,\n modProps: _modProps,\n tokenProps: _tokenProps,\n variants: _variants,\n elements: _elements,\n ...defaultProps\n } = (options ?? {}) as TastyProps<K, V, E, P, M, TP>;\n\n const propsWithStyles = ['styles'].concat(\n Object.keys(defaultProps).filter((prop) => prop.endsWith('Styles')),\n );\n\n const _WrappedComponent = forwardRef<any, any>((props, ref) => {\n const { as, element, ...restProps } = props as Record<string, unknown>;\n\n const mergedStylesMap = propsWithStyles.reduce(\n (map, prop) => {\n const restValue = (restProps as any)[prop];\n const defaultValue = (defaultProps as any)[prop];\n\n if (restValue != null && defaultValue != null) {\n (map as any)[prop] = mergeStyles(defaultValue, restValue);\n } else {\n (map as any)[prop] = restValue ?? defaultValue;\n }\n\n return map;\n },\n {} as Record<string, unknown>,\n );\n\n const elementProps = {\n ...(defaultProps as unknown as Record<string, unknown>),\n ...(restProps as unknown as Record<string, unknown>),\n ...mergedStylesMap,\n as: (as as string | undefined) ?? extendTag,\n element: (element as string | undefined) || extendElement,\n ref,\n } as unknown as P;\n\n return createElement(Component as ComponentType<P>, elementProps);\n });\n\n _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(\n Component,\n (defaultProps as any).qa ?? (extendTag as any) ?? 'Anonymous',\n )})`;\n\n return _WrappedComponent as unknown as ComponentType<\n TastyComponentPropsWithDefaults<P, DefaultProps>\n >;\n}\n\nfunction tastyElement<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition,\n>(tastyOptions: TastyProps<K, V, E>) {\n const {\n as: originalAs = 'div',\n element: defaultElement,\n styles: defaultStyles,\n styleProps,\n modProps: modPropsDef,\n tokenProps: tokenPropsDef,\n variants,\n tokens: defaultTokens,\n elements,\n ...defaultProps\n } = tastyOptions;\n\n // Pre-compute merged styles for each variant (if variants are defined)\n // This avoids creating separate component instances per variant\n let variantStylesMap: Record<string, Styles | undefined> | undefined;\n if (variants) {\n // Split defaultStyles: extend-mode state maps (no '' key, non-selector)\n // are pulled out and applied AFTER variant merge so they survive\n // replace-mode maps in variants.\n let baseStyles = defaultStyles;\n let extensionStyles: Styles | undefined;\n\n if (defaultStyles) {\n for (const key of Object.keys(defaultStyles)) {\n if (isSelector(key)) continue;\n\n const value = (defaultStyles as Record<string, unknown>)[key];\n\n if (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !('' in value)\n ) {\n if (!extensionStyles) {\n baseStyles = { ...defaultStyles } as Styles;\n extensionStyles = {} as Styles;\n }\n (extensionStyles as Record<string, unknown>)[key] = value;\n delete (baseStyles as Record<string, unknown>)[key];\n }\n }\n }\n\n const variantEntries = Object.entries(variants) as [string, Styles][];\n variantStylesMap = variantEntries.reduce(\n (map, [variant, variantStyles]) => {\n map[variant] = extensionStyles\n ? mergeStyles(baseStyles, variantStyles, extensionStyles)\n : mergeStyles(baseStyles, variantStyles);\n return map;\n },\n {} as Record<string, Styles | undefined>,\n );\n // Ensure 'default' variant always exists\n if (!variantStylesMap['default']) {\n variantStylesMap['default'] = defaultStyles;\n }\n }\n\n const {\n qa: defaultQa,\n qaVal: defaultQaVal,\n ...otherDefaultProps\n } = defaultProps ?? {};\n\n // Fixed at factory-creation time — no dependency on global config.\n const ownPropsToCheck: readonly string[] = styleProps\n ? (styleProps as StyleList).concat(BASE_STYLES)\n : BASE_STYLES;\n\n // Resolved lazily and refreshed on registry version change. `configure()` can\n // run *after* this factory was created (module eval order — see `Element` at\n // the bottom of this file), and `resetConfig()` reopens configuration, so a\n // one-shot lazy init would go stale. Starts at -1 to force first resolution.\n let propsToCheck: readonly string[] = ownPropsToCheck;\n let propsToCheckVersion = -1;\n\n const modPropsKeys: string[] | undefined = modPropsDef\n ? ((Array.isArray(modPropsDef)\n ? modPropsDef\n : Object.keys(modPropsDef)) as string[])\n : undefined;\n\n const tokenPropsMapping: [string, string][] | undefined = tokenPropsDef\n ? buildTokenPropsMapping(tokenPropsDef as TokenPropsInput)\n : undefined;\n\n // Factory-level cache: maps stable style references to computed classNames.\n // For the common case (no instance overrides), this avoids recomputation.\n const classNameCache = new Map<Styles | undefined, string>();\n\n // Passed when the styles object handed to computeStyles() is the factory's\n // own AND computeStyles() will see it again — which is only true where\n // classNameCache is unavailable, i.e. the server. On the client that cache\n // answers every render after the first, so memoizing chunk keys during that\n // first render would write entries nothing ever reads back. Hoisted so the\n // hot path does not allocate it.\n const STABLE_STYLES: ComputeStylesOptions = { stableStyles: true };\n\n const _TastyComponent = forwardRef<\n unknown,\n AllBasePropsWithMods<K> & WithVariant<V>\n >((incomingProps, ref) => {\n // Global props middleware (`configure({ propHandlers })`). Runs before any\n // destructuring so a handler can rewrite every tasty prop — `styles`, `mods`,\n // `tokens`, `variant`, `as`, `element`, `qa` — and strip its own custom props\n // so they never reach the DOM. `ref` is out of reach: forwardRef separates it.\n // Fast path while nothing is registered: one property load and one branch.\n const applyPropHandlers = propHandlerRegistry.apply;\n const allProps = applyPropHandlers\n ? (applyPropHandlers(\n incomingProps as unknown as PropHandlerProps,\n ) as unknown as typeof incomingProps)\n : incomingProps;\n\n const {\n as,\n styles: rawStyles,\n variant,\n mods,\n element,\n qa,\n qaVal,\n className: userClassName,\n tokens,\n style,\n theme,\n ...otherProps\n } = allProps as Record<string, unknown> as AllBasePropsWithMods<K> &\n WithVariant<V> & {\n className?: string;\n tokens?: Tokens;\n style?: Record<string, unknown>;\n theme?: string;\n };\n\n let styles = rawStyles;\n\n let propStyles: Styles | null = null;\n\n if (propsToCheckVersion !== baseStylePropsRegistry.version) {\n const promoted = baseStylePropsRegistry.list;\n\n propsToCheck =\n promoted.length === 0\n ? ownPropsToCheck\n : ownPropsToCheck.concat(promoted);\n propsToCheckVersion = baseStylePropsRegistry.version;\n }\n\n for (const prop of propsToCheck) {\n const key = prop as unknown as string;\n\n if (key in otherProps) {\n if (!propStyles) propStyles = {};\n const value = (otherProps as any)[key];\n (propStyles as any)[key] = value;\n delete (otherProps as any)[key];\n }\n }\n\n if (!styles || (styles && !hasKeys(styles as Record<string, unknown>))) {\n styles = undefined as unknown as Styles;\n }\n\n let propMods: Record<string, ModValue> | undefined;\n if (modPropsKeys) {\n for (const key of modPropsKeys) {\n if (key in otherProps) {\n if (!propMods) propMods = {};\n propMods[key] = (otherProps as Record<string, unknown>)[\n key\n ] as ModValue;\n delete (otherProps as Record<string, unknown>)[key];\n }\n }\n }\n\n let propTokens: Tokens | undefined;\n if (tokenPropsMapping) {\n for (const [propName, tokenKey] of tokenPropsMapping) {\n if (propName in otherProps) {\n if (!propTokens) propTokens = {} as Tokens;\n (propTokens as Record<string, TokenValue>)[tokenKey] = (\n otherProps as Record<string, unknown>\n )[propName] as TokenValue;\n delete (otherProps as Record<string, unknown>)[propName];\n }\n }\n }\n\n const baseStyles = variantStylesMap\n ? (variantStylesMap[(variant as string) || 'default'] ??\n variantStylesMap['default'])\n : defaultStyles;\n\n const hasInstanceStyles =\n styles && hasKeys(styles as Record<string, unknown>);\n const hasPropStyles = propStyles && hasKeys(propStyles);\n\n const allStyles =\n hasInstanceStyles || hasPropStyles\n ? mergeStyles(baseStyles, styles as Styles, propStyles as Styles)\n : baseStyles;\n\n // Use factory-level cache for stable style references (client only).\n // On the server the cache must be skipped: both the SSR collector and\n // the RSC inline-style paths are per-request, so every request must\n // call computeStyles() to ensure CSS is actually collected/emitted.\n const useFactoryCache = typeof document !== 'undefined';\n let stylesResult: ComputeStylesResult;\n if (\n useFactoryCache &&\n allStyles === baseStyles &&\n classNameCache.has(allStyles)\n ) {\n stylesResult = { className: classNameCache.get(allStyles)! };\n touch(stylesResult.className);\n } else {\n stylesResult = computeStyles(\n allStyles,\n !useFactoryCache && allStyles === baseStyles\n ? STABLE_STYLES\n : undefined,\n );\n if (useFactoryCache && allStyles === baseStyles) {\n classNameCache.set(allStyles, stylesResult.className);\n }\n }\n\n // Merge tokens: default -> instance -> tokenProps\n let mergedTokens: Tokens | undefined;\n if (defaultTokens || tokens || propTokens) {\n if (!defaultTokens && !propTokens) {\n mergedTokens = tokens as Tokens;\n } else if (!tokens && !propTokens) {\n mergedTokens = defaultTokens;\n } else {\n mergedTokens = {\n ...defaultTokens,\n ...(tokens as Tokens),\n ...propTokens,\n } as Tokens;\n }\n }\n\n const processedTokenStyle = processTokens(mergedTokens);\n\n let mergedStyle: Record<string, unknown> | undefined;\n if (processedTokenStyle || style) {\n if (!processedTokenStyle) {\n mergedStyle = style;\n } else if (!style) {\n mergedStyle = processedTokenStyle as Record<string, unknown>;\n } else {\n mergedStyle = {\n ...(processedTokenStyle as Record<string, unknown>),\n ...style,\n };\n }\n }\n\n const mergedMods = propMods\n ? { ...(mods as Record<string, ModValue>), ...propMods }\n : (mods as Record<string, ModValue> | undefined);\n\n let modDataAttrs: Record<string, unknown> | undefined;\n if (mergedMods) {\n modDataAttrs = modAttrs(mergedMods as unknown as Mods) as Record<\n string,\n unknown\n >;\n }\n\n const finalClassName = [\n (userClassName as string) || '',\n stylesResult.className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const elementProps = {\n 'data-element': (element as string | undefined) || defaultElement,\n 'data-qa': (qa as string | undefined) || defaultQa,\n 'data-qaval': (qaVal as string | undefined) || defaultQaVal,\n 'data-theme': theme,\n ...(otherDefaultProps as unknown as Record<string, unknown>),\n ...(modDataAttrs || {}),\n ...(otherProps as unknown as Record<string, unknown>),\n className: finalClassName,\n style: mergedStyle,\n ref,\n } as Record<string, unknown>;\n\n handleIsProperties(elementProps);\n\n if (elementProps['data-theme'] === undefined) {\n delete elementProps['data-theme'];\n }\n\n const el = createElement(\n (as as string | 'div') ?? originalAs,\n elementProps,\n );\n\n // RSC mode: wrap element with inline <style> tag.\n // Class names are extracted from these tags on the client via\n // the doubled-specificity pattern (.tXXX.tXXX), so no <script> is needed.\n if (stylesResult.css) {\n const nonce = getConfig().nonce;\n\n return createElement(\n Fragment,\n null,\n createElement('style', {\n 'data-tasty-rsc': '',\n nonce,\n dangerouslySetInnerHTML: { __html: stylesResult.css },\n }),\n el,\n );\n }\n\n return el;\n });\n\n _TastyComponent.displayName = `TastyComponent(${\n (defaultProps as any).qa || originalAs\n })`;\n\n // Attach sub-element components if elements are defined\n if (elements) {\n const subElements = Object.entries(elements).reduce(\n (acc, [name, definition]) => {\n acc[name] = createSubElement(\n name,\n definition as SubElementDefinition<keyof JSX.IntrinsicElements>,\n );\n return acc;\n },\n {} as Record<string, ForwardRefExoticComponent<any>>,\n );\n\n return Object.assign(_TastyComponent, subElements);\n }\n\n return _TastyComponent;\n}\n\nexport const Element = tasty({});\n","import { useContext } from 'react';\n\nimport { computeStyles } from '../compute-styles';\nimport { getTastySSRContext } from '../ssr/context';\nimport type { Styles } from '../styles/types';\n\nexport interface UseStylesResult {\n /**\n * Generated className(s) to apply to the element.\n * Can be empty string if no styles are provided.\n * With chunking enabled, may contain multiple space-separated class names.\n */\n className: string;\n}\n\n/**\n * Hook to generate CSS classes from Tasty styles.\n * Thin wrapper around `computeStyles()` that adds React context-based\n * SSR collector discovery for backward compatibility with TastyRegistry.\n *\n * For hook-free usage (e.g. in server components), use `computeStyles()` directly.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { className } = useStyles({\n * padding: '2x',\n * fill: '#purple',\n * radius: '1r',\n * });\n *\n * return <div className={className}>Styled content</div>;\n * }\n * ```\n */\nexport function useStyles(\n styles: Styles | undefined,\n options?: { root?: Document | ShadowRoot },\n): UseStylesResult {\n return computeStyles(styles, {\n ssrCollector: useContext(getTastySSRContext()),\n root: options?.root,\n });\n}\n","import { getGlobalInjector } from '../config';\n\n/**\n * Build a per-(injector, root) client state cache for the standalone style\n * functions (`useGlobalStyles`, `useRawCSS`, `useKeyframes`, `useCounterStyle`).\n *\n * Two levels, both weak:\n *\n * - **injector** — `configure()` replaces the global injector, and every dispose\n * handle and generated name we cache belongs to the one that produced it.\n * Keying by injector makes stale state fall away with it, instead of letting\n * change-detection keys suppress re-injection into the new sheets.\n * - **root** — the same selector or slot name can be used in several shadow\n * roots, and each holds its own injection.\n */\nexport function createClientState<T extends object>(\n create: () => T,\n): (root: Document | ShadowRoot) => T {\n const byInjector = new WeakMap<object, WeakMap<Document | ShadowRoot, T>>();\n\n return (root: Document | ShadowRoot): T => {\n const injector = getGlobalInjector() as unknown as object;\n\n let byRoot = byInjector.get(injector);\n if (!byRoot) {\n byRoot = new WeakMap();\n byInjector.set(injector, byRoot);\n }\n\n let state = byRoot.get(root);\n if (!state) {\n state = create();\n byRoot.set(root, state);\n }\n\n return state;\n };\n}\n","import { getConfig } from '../config';\nimport { injectGlobal } from '../injector';\nimport type { StyleResult } from '../pipeline';\nimport { renderStyles } from '../pipeline';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport {\n collectAutoInferredProperties,\n collectAutoInferredPropertiesRSC,\n} from '../ssr/collect-auto-properties';\nimport { formatGlobalRules } from '../ssr/format-global-rules';\nimport type { Styles } from '../styles/types';\nimport { createClientState } from '../utils/client-state';\nimport { hashString } from '../utils/hash';\nimport { resolveRecipes } from '../utils/resolve-recipes';\n\ninterface UseGlobalStylesOptions {\n /**\n * Stable identifier for update tracking (client-only). When provided,\n * changing the styles will dispose the previous injection and inject the\n * new one. Without an id, the selector is used as the slot key.\n * In RSC mode, renders are single-pass so update tracking does not apply.\n */\n id?: string;\n /** Shadow root or document to inject into (client only). */\n root?: Document | ShadowRoot;\n}\n\ninterface ClientGlobalEntry {\n stylesKey: string;\n dispose: () => void;\n}\n\nconst getClientGlobalSlots = createClientState(\n () => new Map<string, ClientGlobalEntry>(),\n);\n\nconst noop = () => {\n /* nothing to dispose */\n};\n\n/**\n * Inject global styles for a given selector.\n * Useful for styling elements by selector without generating classNames.\n *\n * SSR-aware: when a ServerStyleCollector is available, CSS is collected\n * during the render phase instead of being injected into the DOM.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Injected styles are permanent — they are not cleaned up on component unmount.\n * Use the `id` option for update tracking when styles change over the\n * component lifecycle.\n *\n * Update tracking is per-slot and per-root: a slot (`id`, or the selector when\n * no `id` is given) holds exactly one injection per `root`. Changing the styles\n * replaces it; rendering styles that produce no CSS clears it.\n *\n * @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')\n * @param styles - Tasty styles object\n * @param options - Optional settings including `id` for update tracking\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * useGlobalStyles('.card', {\n * padding: '2x',\n * radius: '1r',\n * fill: '#white',\n * });\n *\n * return <div className=\"card\">Content</div>;\n * }\n * ```\n */\nexport function useGlobalStyles(\n selector: string,\n styles?: Styles,\n options?: UseGlobalStylesOptions,\n): void {\n if (!styles) return;\n\n if (!selector) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n '[Tasty] useGlobalStyles: selector is required and cannot be empty. ' +\n 'Styles will not be injected.',\n );\n }\n return;\n }\n\n const target = getStyleTarget();\n\n // Resolve the client slot once — both the fast path below and the injection\n // at the end need it.\n const slots =\n target.mode === 'client'\n ? getClientGlobalSlots(options?.root ?? document)\n : null;\n const slotKey = options?.id ?? selector;\n const stylesKey = slots ? JSON.stringify(styles) : '';\n const existing = slots?.get(slotKey);\n\n // Client fast path: skip resolveRecipes/renderStyles if styles haven't changed\n if (existing && existing.stylesKey === stylesKey) return;\n\n const resolvedStyles = resolveRecipes(styles);\n\n const styleResults = renderStyles(resolvedStyles, selector) as StyleResult[];\n\n if (styleResults.length === 0) {\n // An update that renders no CSS must still clear the slot's previous\n // injection, otherwise the stale rules keep applying to the selector.\n if (slots) {\n existing?.dispose();\n slots.set(slotKey, { stylesKey, dispose: noop });\n }\n return;\n }\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatGlobalRules(styleResults);\n if (css) {\n // A slot key (explicit `id`) replaces, matching client update tracking;\n // content-hashed keys only dedup.\n const key = options?.id\n ? `global:${options.id}`\n : `global:${selector}:${hashString(css)}`;\n target.collector.collectGlobalStyles(key, css, options?.id != null);\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n collectAutoInferredProperties(\n styleResults,\n target.collector,\n resolvedStyles,\n );\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatGlobalRules(styleResults);\n if (css) {\n const key = options?.id\n ? `__global:${options.id}`\n : `__global:${selector}:${hashString(css)}`;\n pushRSCCSS(target.cache, key, css, options?.id != null);\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n collectAutoInferredPropertiesRSC(\n styleResults,\n target.cache,\n resolvedStyles,\n );\n }\n return;\n }\n\n // Client path\n if (slots) {\n existing?.dispose();\n\n const { dispose } = injectGlobal(styleResults, { root: options?.root });\n slots.set(slotKey, { stylesKey, dispose });\n }\n}\n","/**\n * Shallow comparison of two dependency arrays using Object.is semantics.\n * Returns true when both arrays have the same length and every element\n * at the same index is identical.\n */\nexport function depsEqual(\n a: readonly unknown[],\n b: readonly unknown[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) return false;\n }\n return true;\n}\n","import { injectRawCSS } from '../injector';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { createClientState } from '../utils/client-state';\nimport { depsEqual } from '../utils/deps-equal';\nimport { hashString } from '../utils/hash';\n\ninterface UseRawCSSOptions {\n /**\n * Shadow root or document to inject into. Update tracking is per-root: the\n * same id in two roots holds a separate injection in each.\n */\n root?: Document | ShadowRoot;\n /**\n * Stable identifier for update tracking (client-only). When provided,\n * changing the CSS content will dispose the previous injection and inject\n * the new one. Without an id, deduplication is purely content-based (same\n * CSS is injected only once). In RSC mode, renders are single-pass so\n * update tracking does not apply.\n */\n id?: string;\n}\n\ninterface ClientEntry {\n contentKey: string;\n dispose: () => void;\n}\n\ninterface ClientRawCSSState {\n /** id -> the single injection that slot currently owns */\n entries: Map<string, ClientEntry>;\n /** content hashes injected without an id (permanent, deduped) */\n contentDedup: Set<string>;\n /** id -> last factory deps, to skip re-evaluating the factory */\n factoryDeps: Map<string, readonly unknown[]>;\n}\n\nconst getClientState = createClientState(\n (): ClientRawCSSState => ({\n entries: new Map(),\n contentDedup: new Set(),\n factoryDeps: new Map(),\n }),\n);\n\n// Overload 1: Static CSS string\nexport function useRawCSS(css: string, options?: UseRawCSSOptions): void;\n\n// Overload 2: Factory function with dependencies\nexport function useRawCSS(\n factory: () => string,\n deps: readonly unknown[],\n options?: UseRawCSSOptions,\n): void;\n\n/**\n * Inject raw CSS text directly without parsing.\n * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.\n *\n * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts\n * with tasty's chunked style sheets.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Injected styles are permanent — they are not cleaned up on component unmount.\n * Use the `id` option for update tracking when styles change over the\n * component lifecycle.\n *\n * @example Static CSS string\n * ```tsx\n * function GlobalStyles() {\n * useRawCSS(`\n * body {\n * margin: 0;\n * padding: 0;\n * font-family: sans-serif;\n * }\n * `);\n *\n * return null;\n * }\n * ```\n *\n * @example Factory function with dependencies\n * ```tsx\n * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {\n * useRawCSS(() => `\n * :root {\n * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};\n * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};\n * }\n * `, [theme], { id: 'theme-vars' });\n *\n * return null;\n * }\n * ```\n *\n * @example With options\n * ```tsx\n * function ShadowStyles({ shadowRoot }) {\n * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });\n * return null;\n * }\n * ```\n */\nexport function useRawCSS(\n cssOrFactory: string | (() => string),\n depsOrOptions?: readonly unknown[] | UseRawCSSOptions,\n options?: UseRawCSSOptions,\n): void {\n const isFactory = typeof cssOrFactory === 'function';\n\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseRawCSSOptions | undefined);\n\n const target = getStyleTarget();\n\n const state =\n target.mode === 'client' ? getClientState(opts?.root ?? document) : null;\n\n // Client deps cache: skip factory re-evaluation when deps haven't changed\n if (isFactory && deps && opts?.id && state) {\n const cachedDeps = state.factoryDeps.get(opts.id);\n if (cachedDeps && depsEqual(cachedDeps, deps)) {\n return;\n }\n }\n\n const css = isFactory\n ? (cssOrFactory as () => string)()\n : (cssOrFactory as string);\n\n if (!css.trim()) return;\n\n if (target.mode === 'ssr') {\n // A slot key (explicit `id`) replaces, matching client update tracking;\n // content-hashed keys only dedup.\n const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;\n target.collector.collectRawCSS(key, css, opts?.id != null);\n return;\n }\n\n if (target.mode === 'rsc') {\n const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;\n pushRSCCSS(target.cache, key, css, opts?.id != null);\n return;\n }\n\n // Client path\n if (!state) return;\n\n const id = opts?.id;\n\n if (id) {\n const existing = state.entries.get(id);\n if (existing) {\n if (existing.contentKey === css) return;\n existing.dispose();\n }\n\n const { dispose } = injectRawCSS(css, opts);\n state.entries.set(id, { contentKey: css, dispose });\n if (deps) state.factoryDeps.set(id, deps);\n } else {\n const contentKey = hashString(css);\n if (state.contentDedup.has(contentKey)) return;\n state.contentDedup.add(contentKey);\n injectRawCSS(css, opts);\n }\n}\n","import { getNamePrefix } from '../config';\nimport { keyframes } from '../injector';\nimport type { KeyframesSteps } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { formatKeyframesCSS } from '../ssr/format-keyframes';\nimport { createClientState } from '../utils/client-state';\nimport { depsEqual } from '../utils/deps-equal';\nimport { hashString } from '../utils/hash';\nimport { makeKeyframeName } from '../utils/name-prefix';\n\ninterface UseKeyframesOptions {\n name?: string;\n root?: Document | ShadowRoot;\n}\n\ninterface FactoryDepsEntry {\n deps: readonly unknown[];\n name: string;\n}\n\ninterface NamedSlotEntry {\n cacheKey: string;\n dispose: () => void;\n}\n\ninterface ClientKeyframesState {\n /** cacheKey (name + serialized steps) -> generated animation name */\n contentToName: Map<string, string>;\n /** provided name -> the single injection that slot currently owns */\n namedSlots: Map<string, NamedSlotEntry>;\n /** provided name -> last factory deps, to skip re-evaluating the factory */\n factoryDeps: Map<string, FactoryDepsEntry>;\n}\n\nconst getClientState = createClientState(\n (): ClientKeyframesState => ({\n contentToName: new Map(),\n namedSlots: new Map(),\n factoryDeps: new Map(),\n }),\n);\n\n/**\n * Inject CSS @keyframes and return the generated animation name.\n * Deduplicates by content — identical steps always return the same name.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Passing `name` claims a slot owned by that one call site (like `useRawCSS`'s\n * `id`): when its steps change, the previous injection is disposed and the name\n * is reused, so the rules don't accumulate. Anonymous keyframes are permanent\n * and shared by content.\n *\n * @example Basic usage - steps object is the dependency\n * ```tsx\n * function MyComponent() {\n * const bounce = useKeyframes({\n * '0%': { transform: 'scale(1)' },\n * '50%': { transform: 'scale(1.1)' },\n * '100%': { transform: 'scale(1)' },\n * });\n *\n * return <div style={{ animation: `${bounce} 1s infinite` }}>Bouncing</div>;\n * }\n * ```\n *\n * @example With custom name\n * ```tsx\n * function MyComponent() {\n * const fadeIn = useKeyframes(\n * { from: { opacity: 0 }, to: { opacity: 1 } },\n * { name: 'fadeIn' }\n * );\n *\n * return <div style={{ animation: `${fadeIn} 0.3s ease-out` }}>Fading in</div>;\n * }\n * ```\n *\n * @example Factory function with dependencies\n * ```tsx\n * function MyComponent({ scale }: { scale: number }) {\n * const pulse = useKeyframes(\n * () => ({\n * '0%': { transform: 'scale(1)' },\n * '100%': { transform: `scale(${scale})` },\n * }),\n * [scale]\n * );\n *\n * return <div style={{ animation: `${pulse} 1s infinite` }}>Pulsing</div>;\n * }\n * ```\n */\n\n// Overload 1: Static steps object\nexport function useKeyframes(\n steps: KeyframesSteps,\n options?: UseKeyframesOptions,\n): string;\n\n// Overload 2: Factory function with dependencies\nexport function useKeyframes(\n factory: () => KeyframesSteps,\n deps: readonly unknown[],\n options?: UseKeyframesOptions,\n): string;\n\n// Implementation\nexport function useKeyframes(\n stepsOrFactory: KeyframesSteps | (() => KeyframesSteps),\n depsOrOptions?: readonly unknown[] | UseKeyframesOptions,\n options?: UseKeyframesOptions,\n): string {\n const isFactory = typeof stepsOrFactory === 'function';\n\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseKeyframesOptions | undefined);\n\n const target = getStyleTarget();\n\n const clientState =\n target.mode === 'client' ? getClientState(opts?.root ?? document) : null;\n\n // Client deps cache: skip factory re-evaluation when deps haven't changed\n if (isFactory && deps && opts?.name && clientState) {\n const cached = clientState.factoryDeps.get(opts.name);\n if (cached && depsEqual(cached.deps, deps)) {\n return cached.name;\n }\n }\n\n const steps = isFactory\n ? (stepsOrFactory as () => KeyframesSteps)()\n : (stepsOrFactory as KeyframesSteps);\n\n if (!steps || Object.keys(steps).length === 0) {\n return '';\n }\n\n if (target.mode === 'ssr') {\n const actualName = target.collector.allocateKeyframeName(opts?.name);\n const css = formatKeyframesCSS(actualName, steps);\n target.collector.collectKeyframes(actualName, css);\n return actualName;\n }\n\n if (target.mode === 'rsc') {\n const serializedContent = JSON.stringify(steps);\n const key = `__kf:${opts?.name ?? ''}:${serializedContent}`;\n\n const existingName = target.cache.generatedNames.get(key);\n if (existingName) return existingName;\n\n const actualName =\n opts?.name ??\n makeKeyframeName(getNamePrefix(), hashString(serializedContent));\n const css = formatKeyframesCSS(actualName, steps);\n pushRSCCSS(target.cache, key, css);\n target.cache.generatedNames.set(key, actualName);\n return actualName;\n }\n\n // Client path: stable name via content-based dedup\n const state = clientState ?? getClientState(opts?.root ?? document);\n const serializedContent = JSON.stringify(steps);\n const cacheKey = `${opts?.name ?? ''}:${serializedContent}`;\n\n const cachedName = state.contentToName.get(cacheKey);\n if (cachedName) {\n return cachedName;\n }\n\n const providedName = opts?.name;\n\n // A named slot owns exactly one injection. When its content changes, drop the\n // previous one first: disposing frees the name so the new steps can reclaim\n // it, and it keeps old @keyframes rules from piling up in the sheet.\n if (providedName) {\n const slot = state.namedSlots.get(providedName);\n\n if (slot && slot.cacheKey !== cacheKey) {\n slot.dispose();\n // Forget the stale content too, so any other call site still passing the\n // old steps re-injects instead of pointing at a removed rule.\n state.contentToName.delete(slot.cacheKey);\n state.namedSlots.delete(providedName);\n }\n }\n\n const result = keyframes(steps, {\n name: providedName,\n root: opts?.root,\n });\n\n const name = result.toString();\n state.contentToName.set(cacheKey, name);\n\n if (providedName) {\n state.namedSlots.set(providedName, { cacheKey, dispose: result.dispose });\n\n if (deps) {\n state.factoryDeps.set(providedName, { deps, name });\n }\n }\n\n return name;\n}\n","import { getGlobalInjector } from '../config';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { formatPropertyCSS } from '../ssr/format-property';\nimport type { PropertyOptions } from '../injector/types';\n\n/**\n * Options for {@link useProperty}. Extends the shared {@link PropertyOptions}\n * (which is `PropertyDefinition` plus an optional injection `root`).\n */\nexport type UsePropertyOptions = PropertyOptions;\n\n/**\n * Register a CSS @property custom property.\n * This enables advanced features like animating custom properties.\n *\n * Note: @property rules are global and persistent once defined.\n * The function ensures the property is only registered once per root.\n *\n * Accepts tasty token syntax for the property name:\n * - `$name` → defines `--name`\n * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')\n * - `--name` → defines `--name` (legacy format)\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param name - The property token ($name, #name) or CSS property name (--name)\n * @param options - Property configuration\n *\n * @example Basic property with token syntax\n * ```tsx\n * function Spinner() {\n * useProperty('$rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n *\n * return <div className=\"spinner\" />;\n * }\n * ```\n *\n * @example Color property with token syntax (auto-sets syntax)\n * ```tsx\n * function MyComponent() {\n * useProperty('#theme', {\n * initialValue: 'red', // syntax: '<color>' is auto-set\n * });\n *\n * // Now --theme-color can be animated with CSS transitions\n * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;\n * }\n * ```\n *\n * @example Legacy format (still supported)\n * ```tsx\n * function ResizableBox() {\n * useProperty('--box-size', {\n * syntax: '<length>',\n * initialValue: '100px',\n * });\n *\n * return <div style={{ width: 'var(--box-size)' }} />;\n * }\n * ```\n */\nexport function useProperty(name: string, options?: UsePropertyOptions): void {\n if (!name) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Tasty] useProperty: property name is required`);\n }\n return;\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatPropertyCSS(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n });\n if (css) {\n target.collector.collectProperty(name, css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatPropertyCSS(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n });\n if (css) {\n pushRSCCSS(target.cache, `__prop:${name}`, css);\n }\n return;\n }\n\n const injector = getGlobalInjector();\n\n if (injector.isPropertyDefined(name, { root: options?.root })) {\n return;\n }\n\n injector.property(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n root: options?.root,\n });\n}\n","import { getGlobalInjector } from '../config';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport type { FontFaceDescriptors, FontFaceInput } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\n\ninterface UseFontFaceOptions {\n root?: Document | ShadowRoot;\n}\n\n/**\n * Inject CSS @font-face rules.\n * Permanent — no cleanup on unmount. Deduplicates by content hash.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param family - The font-family name\n * @param input - Single descriptor object or array of descriptors (for multiple weights/styles)\n * @param options - Optional settings (e.g. Shadow DOM root)\n *\n * @example Single weight\n * ```tsx\n * function App() {\n * useFontFace('Brand Sans', {\n * src: 'url(\"/fonts/brand-sans.woff2\") format(\"woff2\")',\n * fontWeight: '400 700',\n * fontDisplay: 'swap',\n * });\n *\n * return <div style={{ fontFamily: '\"Brand Sans\", sans-serif' }}>Hello</div>;\n * }\n * ```\n *\n * @example Multiple weights\n * ```tsx\n * function App() {\n * useFontFace('Brand Sans', [\n * { src: 'url(\"/fonts/brand-regular.woff2\") format(\"woff2\")', fontWeight: 400, fontDisplay: 'swap' },\n * { src: 'url(\"/fonts/brand-bold.woff2\") format(\"woff2\")', fontWeight: 700, fontDisplay: 'swap' },\n * ]);\n *\n * return <div style={{ fontFamily: '\"Brand Sans\", sans-serif' }}>Hello</div>;\n * }\n * ```\n */\nexport function useFontFace(\n family: string,\n input: FontFaceInput,\n options?: UseFontFaceOptions,\n): void {\n if (!family) return;\n\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n target.collector.collectFontFace(hash, css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n pushRSCCSS(target.cache, `__ff:${hash}`, css);\n }\n return;\n }\n\n const injector = getGlobalInjector();\n for (const desc of descriptors) {\n injector.fontFace(family, desc, { root: options?.root });\n }\n}\n","import { getGlobalInjector, getNamePrefix } from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport type { CounterStyleDescriptors } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { createClientState } from '../utils/client-state';\nimport { hashString } from '../utils/hash';\nimport { makeCounterStyleName } from '../utils/name-prefix';\n\ninterface UseCounterStyleOptions {\n name?: string;\n root?: Document | ShadowRoot;\n}\n\nlet clientCounterStyleCounter = 0;\n\nconst getClientContentToName = createClientState(\n () => new Map<string, string>(),\n);\n\n/**\n * Inject a CSS @counter-style rule and return the generated name.\n * Permanent — no cleanup on unmount. Deduplicates by name.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @example Basic usage\n * ```tsx\n * function EmojiList() {\n * const styleName = useCounterStyle({\n * system: 'cyclic',\n * symbols: '\"👍\"',\n * suffix: '\" \"',\n * }, { name: 'thumbs' });\n *\n * return (\n * <ol style={{ listStyleType: styleName }}>\n * <li>First</li>\n * <li>Second</li>\n * </ol>\n * );\n * }\n * ```\n *\n */\nexport function useCounterStyle(\n descriptors: CounterStyleDescriptors,\n options?: UseCounterStyleOptions,\n): string {\n if (!descriptors || !descriptors.system) {\n return '';\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n const actualName = target.collector.allocateCounterStyleName(options?.name);\n const css = formatCounterStyleRule(actualName, descriptors);\n target.collector.collectCounterStyle(actualName, css);\n return actualName;\n }\n\n if (target.mode === 'rsc') {\n const serializedContent = JSON.stringify(descriptors);\n const key = `__cs:${options?.name ?? ''}:${serializedContent}`;\n\n const existingName = target.cache.generatedNames.get(key);\n if (existingName) return existingName;\n\n const actualName =\n options?.name ??\n makeCounterStyleName(getNamePrefix(), hashString(serializedContent));\n const css = formatCounterStyleRule(actualName, descriptors);\n pushRSCCSS(target.cache, key, css);\n target.cache.generatedNames.set(key, actualName);\n return actualName;\n }\n\n // Client path: stable name via content-based dedup\n const contentToName = getClientContentToName(options?.root ?? document);\n const serializedContent = JSON.stringify(descriptors);\n const cacheKey = `${options?.name ?? ''}:${serializedContent}`;\n\n const existingName = contentToName.get(cacheKey);\n if (existingName) {\n return existingName;\n }\n\n const name =\n options?.name ??\n makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));\n contentToName.set(cacheKey, name);\n\n const injector = getGlobalInjector();\n injector.counterStyle(name, descriptors, { root: options?.root });\n\n return name;\n}\n","import { getGlobalInjector, isFunctionsPolyfillEnabled } from '../config';\nimport {\n formatFunctionRule,\n parseFunctionName,\n registerFunctionPolyfill,\n} from '../functions';\nimport type { FunctionDefinition } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\n\nexport interface UseFunctionOptions {\n /** Shadow root or document to inject into. */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Register a CSS @function (custom function).\n *\n * @function rules are global and persistent once defined. The hook ensures the\n * function is only registered once per root (deduplicated by function name).\n *\n * Accepts tasty token syntax for the function name:\n * - `$$name` → defines `--name` (matches the call site `$$name(...)`)\n * - `$name` / `--name` → also accepted\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param name - The function name token (`$$name`, `$name`, or `--name`)\n * @param definition - Function definition (args, returns, result, local vars)\n *\n * Call the function through the Tasty DSL, not a raw `style` prop: an inline\n * `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never\n * expanded and `polyfills.functions` cannot rewrite it either.\n *\n * @example\n * ```tsx\n * const Box = tasty({ styles: { marginTop: '$$negative(10px)' } });\n *\n * function Layout() {\n * useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });\n * return <Box />;\n * }\n * ```\n */\nexport function useFunction(\n name: string,\n definition: FunctionDefinition,\n options?: UseFunctionOptions,\n): void {\n if (!name) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Tasty] useFunction: function name is required`);\n }\n return;\n }\n\n // @function polyfill: register an inline closure so call sites are expanded\n // into plain CSS by the parser. No native @function rule is emitted.\n if (isFunctionsPolyfillEnabled()) {\n registerFunctionPolyfill(name, definition);\n return;\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatFunctionRule(name, definition);\n if (css) {\n target.collector.collectFunction(parseFunctionName(name), css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatFunctionRule(name, definition);\n if (css) {\n pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);\n }\n return;\n }\n\n getGlobalInjector().func(name, definition, { root: options?.root });\n}\n","import { useInsertionEffect } from 'react';\nimport type { ReactNode } from 'react';\n\nimport { closeBatchWindow, openBatchWindow } from './injector/batch';\n\nexport interface TastyBatchProviderProps {\n children?: ReactNode;\n}\n\n/**\n * Opens a *batch window* for the commit it renders in, so `batchInjection`\n * can defer stylesheet writes without ever letting a layout effect measure an\n * unstyled element.\n *\n * Every `insertRule()` on a live sheet invalidates style for that sheet's\n * scope. When components inject during React's render phase while others read\n * layout in the same pass, the two interleave and the browser recalculates\n * style between every injection. Batching collapses that into one invalidation\n * per flush — but only if the flush happens before anything can measure.\n *\n * ```\n * provider renders -> window OPEN\n * children render -> injections queued\n * provider insertionEffect -> FLUSH, window CLOSED\n * layout effects run -> rules are in the sheet\n * ```\n *\n * `useInsertionEffect` runs in React's mutation phase, after every render in\n * the commit and before any `useLayoutEffect` — which is exactly why React\n * added it for CSS-in-JS libraries. Effects fire child-first, so this\n * provider's runs after every descendant's and still before all layout\n * effects.\n *\n * A commit that does not re-render this provider gets no window, and those\n * injections are written synchronously instead. That is the point: turning\n * `batchInjection: true` on can only ever make injection cheaper, never make a\n * measurement wrong. It also means batching applies to commits this provider\n * takes part in, so mount it as high in the tree as you can.\n *\n * Requires `configure({ batchInjection: true })`; without it this component\n * only renders its children. `batchInjection: 'always'` does not need the\n * provider at all — see that option's docs for the trade-off it accepts.\n *\n * @example\n * ```tsx\n * configure({ batchInjection: true });\n *\n * createRoot(el).render(\n * <TastyBatchProvider>\n * <App />\n * </TastyBatchProvider>,\n * );\n * ```\n */\nexport function TastyBatchProvider({ children }: TastyBatchProviderProps) {\n // Opened during render on purpose: the window has to be open before children\n // render, and this is the only phase that precedes them. It is idempotent and\n // has no other side effect, so StrictMode's double render costs nothing. A\n // render that is thrown away (aborted or suspended) leaves the window open,\n // which the microtask backstop closes — and such a render mounts nothing, so\n // nothing can measure what it queued.\n openBatchWindow();\n\n // Fires in the mutation phase, before any layout effect. No dependency array:\n // it must run on every commit this provider is part of.\n useInsertionEffect(() => {\n closeBatchWindow();\n });\n\n return children;\n}\n"],"mappings":";;;;;;;;;;AAEA,MAAM,eAAe;AAErB,SAAgB,eACd,WACA,eAAe,cACP;CACR,IAAI,OAAO,cAAc,YACvB,OAAO,UAAU,eAAe,UAAU,QAAQ;CAGpD,OAAO;AACT;;;;;;;;ACRA,SAAgB,mBAAmB,OAAyB;CAC1D,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAChD,OAAO;CAGT,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,OAAQ,MAAiC,aAAa;CAG/D,OAAO;AACT;;;;;;ACwCA,MAAM,wBAAwB,OAAO,QAAQ;CAR3C,YAAY;CACZ,UAAU;CACV,WAAW;AAMgD,CAAC;;;;;AAM9D,SAAS,mBAAmB,OAAgC;CAC1D,KAAK,MAAM,CAAC,YAAY,oBAAoB,uBAAuB;EACjE,IAAI,cAAc,OAAO;GACvB,MAAM,mBAAmB,MAAM;GAC/B,OAAO,MAAM;EACf;EAGA,MAAM,gBAAgB,QAAQ;EAC9B,IAAI,EAAE,iBAAiB,UAAU,MAAM,kBACrC,MAAM,iBAAiB;CAE3B;AACF;;;;;AAMA,SAAS,iBACP,aACA,YAGA;CAEA,MAAM,SACJ,OAAO,eAAe,WAClB,EAAE,IAAI,WAAkB,IACvB;CAEP,MAAM,MAAM,OAAO,MAAO;CAC1B,MAAM,YAAY,OAAO;CACzB,MAAM,eAAe,OAAO;CAE5B,MAAM,aAAa,Y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kB,IAAI,KAAK,GAAG;EAEnE;CACF;CAEA,kBAAkB,CAAC,CAAC,KAAK,MAAM,YAAY,EAAE,MAAM,SAAS,KAAK,CAAC;AACpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC7BA,SAAgB,mBAAmB,EAAE,YAAqC;CAOxE,gBAAgB;CAIhB,yBAAyB;EACvB,iBAAiB;CACnB,CAAC;CAED,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["modAttrs","getClientState"],"sources":["../src/utils/get-display-name.ts","../src/utils/is-valid-element-type.ts","../src/tasty.tsx","../src/hooks/useStyles.ts","../src/utils/client-state.ts","../src/hooks/useGlobalStyles.ts","../src/utils/deps-equal.ts","../src/hooks/useRawCSS.ts","../src/hooks/useKeyframes.ts","../src/hooks/useProperty.ts","../src/hooks/useFontFace.ts","../src/hooks/useCounterStyle.ts","../src/hooks/useFunction.ts","../src/batch-provider.tsx"],"sourcesContent":["import type { ElementType } from 'react';\n\nconst DEFAULT_NAME = 'Anonymous';\n\nexport function getDisplayName<T>(\n Component: ElementType<T>,\n fallbackName = DEFAULT_NAME,\n): string {\n if (typeof Component === 'function') {\n return Component.displayName ?? Component.name ?? fallbackName;\n }\n\n return fallbackName;\n}\n","/**\n * Lightweight replacement for `react-is`'s isValidElementType.\n * Detects string tags, function/class components, and React exotic types\n * (forwardRef, memo, lazy, etc.) via their internal $$typeof symbol.\n */\nexport function isValidElementType(value: unknown): boolean {\n if (typeof value === 'string' || typeof value === 'function') {\n return true;\n }\n\n if (typeof value === 'object' && value !== null) {\n return typeof (value as { $$typeof?: unknown }).$$typeof === 'symbol';\n }\n\n return false;\n}\n","import type {\n AllHTMLAttributes,\n ComponentType,\n ElementType,\n ForwardRefExoticComponent,\n JSX,\n PropsWithoutRef,\n RefAttributes,\n} from 'react';\nimport { createElement, forwardRef, Fragment } from 'react';\nimport type {\n ComputeStylesOptions,\n ComputeStylesResult,\n} from './compute-styles';\nimport { computeStyles } from './compute-styles';\nimport type { PropHandlerProps } from './prop-handlers';\nimport { propHandlerRegistry } from './prop-handlers';\nimport { baseStylePropsRegistry } from './styles/base-props';\nimport { BASE_STYLES } from './styles/list';\nimport type { Styles, StylesInterface } from './styles/types';\nimport type {\n AllBaseProps,\n BaseProps,\n BaseStyleProps,\n ExtraBaseStyleProps,\n ModValue,\n Mods,\n TastyCustomProps,\n TokenValue,\n Tokens,\n} from './types';\nimport { getDisplayName } from './utils/get-display-name';\nimport { isValidElementType } from './utils/is-valid-element-type';\nimport { mergeStyles } from './utils/merge-styles';\nimport { isSelector } from './pipeline';\nimport { hasKeys } from './utils/has-keys';\nimport { modAttrs } from './utils/mod-attrs';\nimport { processTokens } from './utils/process-tokens';\nimport { getConfig } from './config';\nimport { touch } from './injector';\n\nimport type { StyleValue, StyleValueStateMap } from './utils/styles';\n\n/**\n * Mapping of is* properties to their corresponding HTML attributes\n */\nconst IS_PROPERTIES_MAP = {\n isDisabled: 'disabled',\n isHidden: 'hidden',\n isChecked: 'checked',\n} as const;\n\n/**\n * Precalculated entries for performance optimization\n */\nconst IS_PROPERTIES_ENTRIES = Object.entries(IS_PROPERTIES_MAP);\n\n/**\n * Helper function to handle is* properties consistently\n * Transforms is* props to HTML attributes and adds corresponding data-* attributes\n */\nfunction handleIsProperties(props: Record<string, unknown>) {\n for (const [isProperty, targetAttribute] of IS_PROPERTIES_ENTRIES) {\n if (isProperty in props) {\n props[targetAttribute] = props[isProperty];\n delete props[isProperty];\n }\n\n // Add data-* attribute if target attribute is truthy and doesn't already exist\n const dataAttribute = `data-${targetAttribute}`;\n if (!(dataAttribute in props) && props[targetAttribute]) {\n props[dataAttribute] = '';\n }\n }\n}\n\n/**\n * Creates a sub-element component for compound component patterns.\n * Sub-elements are lightweight components with data-element attribute for CSS targeting.\n */\nfunction createSubElement<Tag extends keyof JSX.IntrinsicElements>(\n elementName: string,\n definition: SubElementDefinition<Tag>,\n): ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<Tag>> & RefAttributes<unknown>\n> {\n // Normalize definition to object form\n const config =\n typeof definition === 'string'\n ? { as: definition as Tag }\n : (definition as { as?: Tag; qa?: string; qaVal?: string | number });\n\n const tag = config.as ?? ('div' as Tag);\n const defaultQa = config.qa;\n const defaultQaVal = config.qaVal;\n\n const SubElement = forwardRef<unknown, SubElementProps<Tag>>((props, ref) => {\n const {\n qa,\n qaVal,\n mods,\n tokens,\n isDisabled,\n isHidden,\n isChecked,\n className,\n style,\n ...htmlProps\n } = props as SubElementProps<Tag> & {\n className?: string;\n style?: Record<string, unknown>;\n };\n\n // Build mod attributes\n let modDataAttrs: Record<string, unknown> | undefined;\n if (mods) {\n modDataAttrs = modAttrs(mods as Mods) as Record<string, unknown>;\n }\n\n // Process tokens into inline style properties\n const tokenStyle = tokens\n ? (processTokens(tokens) as Record<string, unknown>)\n : undefined;\n\n // Merge token styles with explicit style prop (style has priority)\n let mergedStyle: Record<string, unknown> | undefined;\n if (tokenStyle || style) {\n mergedStyle =\n tokenStyle && style\n ? { ...tokenStyle, ...style }\n : ((tokenStyle ?? style) as Record<string, unknown>);\n }\n\n const elementProps = {\n 'data-element': elementName,\n 'data-qa': qa ?? defaultQa,\n 'data-qaval': qaVal ?? defaultQaVal,\n ...(modDataAttrs || {}),\n ...htmlProps,\n className,\n style: mergedStyle,\n isDisabled,\n isHidden,\n isChecked,\n ref,\n } as Record<string, unknown>;\n\n // Handle is* properties (isDisabled -> disabled + data-disabled, etc.)\n handleIsProperties(elementProps);\n\n // Clean up undefined data attributes\n if (elementProps['data-qa'] === undefined) delete elementProps['data-qa'];\n if (elementProps['data-qaval'] === undefined)\n delete elementProps['data-qaval'];\n\n return createElement(tag, elementProps);\n });\n\n SubElement.displayName = `SubElement(${elementName})`;\n\n return SubElement as ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<Tag>> & RefAttributes<unknown>\n >;\n}\n\ntype StyleList = readonly (keyof {\n [key in keyof StylesInterface]: StylesInterface[key];\n})[];\n\n// ============================================================================\n// Mod props types — expose modifier keys as top-level component props\n// ============================================================================\n\n/** Type descriptor for a single mod prop: a JS constructor or an enum array. */\nexport type ModPropDef =\n | BooleanConstructor\n | StringConstructor\n | NumberConstructor\n | readonly string[];\n\n/** Array form: list of mod key names (types default to ModValue). */\ntype ModPropsList = readonly string[];\n\n/** Object form: map of mod key names to type descriptors. */\ntype ModPropsMap = Readonly<Record<string, ModPropDef>>;\n\n/** Either array or object form accepted by `modProps` option. */\nexport type ModPropsInput = ModPropsList | ModPropsMap;\n\n/** Resolve a single ModPropDef to its TypeScript type. */\nexport type ResolveModPropDef<T> = T extends BooleanConstructor\n ? boolean\n : T extends StringConstructor\n ? string\n : T extends NumberConstructor\n ? number\n : T extends readonly (infer U)[]\n ? U\n : ModValue;\n\n/** Resolve an entire `modProps` definition to the component prop types it adds. */\nexport type ResolveModProps<M extends ModPropsInput> =\n M extends readonly (infer K)[]\n ? Partial<Record<K & string, ModValue>>\n : M extends Record<string, ModPropDef>\n ? { [key in keyof M & string]?: ResolveModPropDef<M[key]> }\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\n// ============================================================================\n// Token props types — expose token keys as top-level component props\n// ============================================================================\n\n/** A token key with `$` or `#` prefix. */\ntype TokenPropKey = `$${string}` | `#${string}`;\n\n/** Array form: list of prop names. Names ending in `Color` map to `#` color tokens. */\ntype TokenPropsList = readonly string[];\n\n/** Object form: prop name -> token key with explicit `$`/`#` prefix. */\ntype TokenPropsMap = Readonly<Record<string, TokenPropKey>>;\n\n/** Either array or object form accepted by `tokenProps` option. */\nexport type TokenPropsInput = TokenPropsList | TokenPropsMap;\n\n/** Resolve a `tokenProps` definition to the component prop types it adds. */\nexport type ResolveTokenProps<TP extends TokenPropsInput> =\n TP extends readonly (infer K)[]\n ? Partial<Record<K & string, TokenValue>>\n : TP extends Record<string, TokenPropKey>\n ? Partial<Record<keyof TP & string, TokenValue>>\n : // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n {};\n\n/**\n * Pre-compute the mapping from prop name to token key at component-creation time.\n * Array form: `'progress'` -> `'$progress'`, `'accentColor'` -> `'#accent'`.\n * Object form: entries used as-is.\n */\nfunction buildTokenPropsMapping(\n def: TokenPropsInput,\n): [propName: string, tokenKey: string][] {\n if (Array.isArray(def)) {\n return (def as string[]).map((propName) => {\n if (propName.endsWith('Color') && propName.length > 5) {\n return [propName, `#${propName.slice(0, -5)}`];\n }\n return [propName, `$${propName}`];\n });\n }\n return Object.entries(def);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyProps = Record<string, any>;\n\ntype PropsWithStyles = {\n styles?: Styles;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Omit<Record<string, any>, 'styles'>;\n\nexport type VariantMap = Record<string, Styles>;\n\nexport interface WithVariant<V extends VariantMap> {\n variant?: keyof V;\n}\n\n// ============================================================================\n// Sub-element types for compound components\n// ============================================================================\n\n/**\n * Definition for a sub-element. Can be either:\n * - A tag name string (e.g., 'div', 'span')\n * - An object with configuration options\n */\nexport type SubElementDefinition<\n Tag extends keyof JSX.IntrinsicElements = 'div',\n> =\n | Tag\n | {\n as?: Tag;\n qa?: string;\n qaVal?: string | number;\n };\n\n/**\n * Map of sub-element definitions.\n * Keys become the sub-component names (e.g., { Icon: 'span' } -> Component.Icon)\n */\nexport type ElementsDefinition = Record<\n string,\n SubElementDefinition<keyof JSX.IntrinsicElements>\n>;\n\n/**\n * Resolves the tag from a SubElementDefinition\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ResolveElementTag<T extends SubElementDefinition<any>> = T extends string\n ? T\n : T extends { as?: infer Tag }\n ? Tag extends keyof JSX.IntrinsicElements\n ? Tag\n : 'div'\n : 'div';\n\n/**\n * Props for sub-element components.\n * Combines HTML attributes with tasty-specific props (qa, qaVal, mods, tokens, isDisabled, etc.)\n */\nexport type SubElementProps<Tag extends keyof JSX.IntrinsicElements = 'div'> =\n Omit<\n JSX.IntrinsicElements[Tag],\n 'ref' | 'color' | 'content' | 'translate'\n > & {\n qa?: string;\n qaVal?: string | number;\n mods?: Mods;\n tokens?: Tokens;\n isDisabled?: boolean;\n isHidden?: boolean;\n isChecked?: boolean;\n };\n\n/**\n * Generates the sub-element component types from an ElementsDefinition\n */\ntype SubElementComponents<E extends ElementsDefinition> = {\n [K in keyof E]: ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<ResolveElementTag<E[K]>>> &\n RefAttributes<\n ResolveElementTag<E[K]> extends keyof HTMLElementTagNameMap\n ? HTMLElementTagNameMap[ResolveElementTag<E[K]>]\n : Element\n >\n >;\n};\n\n/**\n * Base type containing common properties shared between TastyProps and TastyElementOptions.\n * Separated to avoid code duplication while allowing different type constraints.\n */\ntype TastyBaseProps<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = {\n /** Default styles of the element. */\n styles?: Styles;\n /** The list of styles that can be provided by props */\n styleProps?: K;\n /** Modifier keys exposed as top-level component props (array or typed object form). */\n modProps?: M;\n /** Token keys exposed as top-level component props (array or typed object form). */\n tokenProps?: TP;\n element?: BaseProps['element'];\n variants?: V;\n /** Default tokens for inline CSS custom properties */\n tokens?: Tokens;\n /** Sub-element definitions for compound components */\n elements?: E;\n} & Pick<BaseProps, 'qa' | 'qaVal'> &\n WithVariant<V>;\n\nexport type TastyProps<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n DefaultProps = AnyProps,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = TastyBaseProps<K, V, E, M, TP> & {\n /** The tag name of the element or a React component. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n as?: string | ComponentType<any>;\n} & Partial<\n Omit<\n DefaultProps,\n 'as' | 'styles' | 'styleProps' | 'modProps' | 'tokenProps' | 'tokens'\n >\n >;\n\n/**\n * Resolves the props of a polymorphic `as` value (intrinsic tag or component).\n * - For intrinsic tags (`'div'`, `'button'`, ...): returns `JSX.IntrinsicElements[Tag]`.\n * - For React component types: returns the component's own props.\n * - Falls back to an empty record for anything else.\n */\nexport type ResolveAsProps<AsType extends ElementType> =\n AsType extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[AsType]\n : AsType extends ComponentType<infer P>\n ? P\n : Record<string, never>;\n\n/**\n * TastyElementOptions is used for the element-creation overload of tasty().\n * It includes an `AsType` generic that allows TypeScript to infer the correct\n * element type from the `as` prop — both for intrinsic tags and for React\n * components (so the wrapped component's prop API is preserved).\n *\n * Note: Uses a separate index signature with `unknown` instead of an `any`\n * record to ensure strict type checking for styles.\n */\nexport type TastyElementOptions<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = TastyBaseProps<K, V, E, M, TP> & {\n /** The tag name of the element or a React component. */\n as?: AsType;\n} & Record<string, unknown>;\n\nexport type AllBasePropsWithMods<\n K extends StyleList,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = AllBaseProps & {\n [key in K[number]]?:\n StyleValue<StylesInterface[key]> | StyleValueStateMap<StylesInterface[key]>;\n} & BaseStyleProps &\n ExtraBaseStyleProps &\n Partial<TastyCustomProps> &\n ResolveModProps<M> &\n ResolveTokenProps<TP>;\n\n/**\n * Keys from BasePropsWithoutChildren that should be omitted from HTML attributes.\n * This excludes event handlers so they can be properly typed from JSX.IntrinsicElements.\n */\ntype TastySpecificKeys =\n | 'as'\n | 'qa'\n | 'qaVal'\n | 'element'\n | 'styles'\n | 'mods'\n | 'isHidden'\n | 'isDisabled'\n | 'isChecked'\n | 'style'\n | 'theme'\n | 'tokens'\n | 'ref'\n | 'color';\n\n/** Extract prop key names from a ModPropsInput (array elements or object keys). */\ntype ModPropsKeys<M extends ModPropsInput> = M extends readonly (infer K)[]\n ? K & string\n : keyof M & string;\n\n/** Extract prop key names from a TokenPropsInput (array elements or object keys). */\ntype TokenPropsKeys<TP extends TokenPropsInput> =\n TP extends readonly (infer K)[] ? K & string : keyof TP & string;\n\n/**\n * Props type for tasty elements that combines:\n * - AllBasePropsWithMods for style props with strict tokens type\n * - HTML attributes for flexibility (properly typed based on `as`)\n * - Variant support\n *\n * AllBasePropsWithMods carries generic AllHTMLAttributes which can conflict\n * with element-specific types (e.g. `src` is `string` in AllHTMLAttributes but\n * `string | Blob` in ImgHTMLAttributes, or the custom props on a third-party\n * component like Next.js `Link`). To avoid intersection-narrowing, we Omit\n * element-specific keys from AllBasePropsWithMods (keeping TastySpecificKeys,\n * style props, mod props, and token props) and let the resolved `as` props\n * supply the authoritative attribute types. The `AllHTMLAttributes<HTMLElement>`\n * baseline is preserved so generic HTML attributes still work even when `as`\n * is a component type with a narrower prop API.\n */\nexport type TastyElementProps<\n K extends StyleList,\n V extends VariantMap,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n> = Omit<\n AllBasePropsWithMods<K, M, TP>,\n Exclude<\n keyof ResolveAsProps<AsType>,\n | TastySpecificKeys\n | keyof TastyCustomProps\n | keyof ExtraBaseStyleProps\n | K[number]\n | ModPropsKeys<M>\n | TokenPropsKeys<TP>\n >\n> &\n WithVariant<V> &\n Omit<\n Omit<AllHTMLAttributes<HTMLElement>, keyof ResolveAsProps<AsType>> &\n ResolveAsProps<AsType>,\n | TastySpecificKeys\n | keyof TastyCustomProps\n | keyof ExtraBaseStyleProps\n | K[number]\n | ModPropsKeys<M>\n | TokenPropsKeys<TP>\n >;\n\nexport type TastyComponentPropsWithDefaults<\n Props extends PropsWithStyles,\n DefaultProps extends Partial<Props>,\n> = keyof DefaultProps extends never\n ? Props\n : {\n [key in Extract<keyof Props, keyof DefaultProps>]?: Props[key];\n } & {\n [key in keyof Omit<Props, keyof DefaultProps>]: Props[key];\n };\n\n/**\n * The component type returned by the `tasty(options)` element-factory overload.\n *\n * It's a regular React forward-ref component whose props are typed from the\n * factory-time `as` value. Polymorphism is at factory time: each call to\n * `tasty({ as: X })` produces a component whose prop API includes `X`'s own\n * props (so `tasty({ as: NextLink })` exposes `href`, `replace`, `prefetch`,\n * etc.) alongside the Tasty-specific props (`mods`, `tokens`, `styleProps`,\n * `modProps`, `tokenProps`).\n *\n * Note: a render-time `<X as={SomeComponent} />` does not re-infer props from\n * `SomeComponent`; create another `tasty({ as: SomeComponent })` for that.\n */\nexport type TastyPolymorphicComponent<\n DefaultAs extends ElementType,\n K extends StyleList,\n V extends VariantMap,\n M extends ModPropsInput,\n TP extends TokenPropsInput,\n> = ForwardRefExoticComponent<\n PropsWithoutRef<TastyElementProps<K, V, DefaultAs, M, TP>> &\n RefAttributes<unknown>\n>;\n\nexport function tasty<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n AsType extends ElementType = 'div',\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n options: TastyElementOptions<K, V, E, AsType, M, TP>,\n secondArg?: never,\n): TastyPolymorphicComponent<AsType, K, V, M, TP> & SubElementComponents<E>;\nexport function tasty<\n Props extends PropsWithStyles,\n DefaultProps extends Partial<Props> = Partial<Props>,\n K extends StyleList = readonly never[],\n V extends VariantMap = VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n Component: ComponentType<Props>,\n options?: TastyProps<K, V, E, Props, M, TP>,\n): ComponentType<TastyComponentPropsWithDefaults<Props, DefaultProps>>;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// Implementation\nexport function tasty<\n K extends StyleList,\n V extends VariantMap,\n _C = Record<string, unknown>,\n>(Component: any, options?: any) {\n if (isValidElementType(Component)) {\n return tastyWrap(Component as ComponentType<any>, options);\n }\n\n return tastyElement(Component as TastyProps<K, V>);\n}\n\nfunction tastyWrap<\n P extends PropsWithStyles,\n DefaultProps extends Partial<P> = Partial<P>,\n K extends StyleList = readonly never[],\n V extends VariantMap = VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n Component: ComponentType<P>,\n options?: TastyProps<K, V, E, P, M, TP>,\n): ComponentType<TastyComponentPropsWithDefaults<P, DefaultProps>> {\n // The wrap path forwards default props + merges `styles`/`*Styles` props.\n // Factory-only options (`styleProps`, `modProps`, `tokenProps`, `variants`,\n // `elements`) are stripped here, not forwarded to the wrapped component.\n const {\n as: extendTag,\n element: extendElement,\n styleProps: _styleProps,\n modProps: _modProps,\n tokenProps: _tokenProps,\n variants: _variants,\n elements: _elements,\n ...defaultProps\n } = (options ?? {}) as TastyProps<K, V, E, P, M, TP>;\n\n const propsWithStyles = ['styles'].concat(\n Object.keys(defaultProps).filter((prop) => prop.endsWith('Styles')),\n );\n\n const _WrappedComponent = forwardRef<any, any>((props, ref) => {\n const { as, element, ...restProps } = props as Record<string, unknown>;\n\n const mergedStylesMap = propsWithStyles.reduce(\n (map, prop) => {\n const restValue = (restProps as any)[prop];\n const defaultValue = (defaultProps as any)[prop];\n\n if (restValue != null && defaultValue != null) {\n (map as any)[prop] = mergeStyles(defaultValue, restValue);\n } else {\n (map as any)[prop] = restValue ?? defaultValue;\n }\n\n return map;\n },\n {} as Record<string, unknown>,\n );\n\n const elementProps = {\n ...(defaultProps as unknown as Record<string, unknown>),\n ...(restProps as unknown as Record<string, unknown>),\n ...mergedStylesMap,\n as: (as as string | undefined) ?? extendTag,\n element: (element as string | undefined) || extendElement,\n ref,\n } as unknown as P;\n\n return createElement(Component as ComponentType<P>, elementProps);\n });\n\n _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(\n Component,\n (defaultProps as any).qa ?? (extendTag as any) ?? 'Anonymous',\n )})`;\n\n return _WrappedComponent as unknown as ComponentType<\n TastyComponentPropsWithDefaults<P, DefaultProps>\n >;\n}\n\nfunction tastyElement<\n K extends StyleList,\n V extends VariantMap,\n E extends ElementsDefinition,\n>(tastyOptions: TastyProps<K, V, E>) {\n const {\n as: originalAs = 'div',\n element: defaultElement,\n styles: defaultStyles,\n styleProps,\n modProps: modPropsDef,\n tokenProps: tokenPropsDef,\n variants,\n tokens: defaultTokens,\n elements,\n ...defaultProps\n } = tastyOptions;\n\n // Pre-compute merged styles for each variant (if variants are defined)\n // This avoids creating separate component instances per variant\n let variantStylesMap: Record<string, Styles | undefined> | undefined;\n if (variants) {\n // Split defaultStyles: extend-mode state maps (no '' key, non-selector)\n // are pulled out and applied AFTER variant merge so they survive\n // replace-mode maps in variants.\n let baseStyles = defaultStyles;\n let extensionStyles: Styles | undefined;\n\n if (defaultStyles) {\n for (const key of Object.keys(defaultStyles)) {\n if (isSelector(key)) continue;\n\n const value = (defaultStyles as Record<string, unknown>)[key];\n\n if (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n !('' in value)\n ) {\n if (!extensionStyles) {\n baseStyles = { ...defaultStyles } as Styles;\n extensionStyles = {} as Styles;\n }\n (extensionStyles as Record<string, unknown>)[key] = value;\n delete (baseStyles as Record<string, unknown>)[key];\n }\n }\n }\n\n const variantEntries = Object.entries(variants) as [string, Styles][];\n variantStylesMap = variantEntries.reduce(\n (map, [variant, variantStyles]) => {\n map[variant] = extensionStyles\n ? mergeStyles(baseStyles, variantStyles, extensionStyles)\n : mergeStyles(baseStyles, variantStyles);\n return map;\n },\n {} as Record<string, Styles | undefined>,\n );\n // Ensure 'default' variant always exists\n if (!variantStylesMap['default']) {\n variantStylesMap['default'] = defaultStyles;\n }\n }\n\n const {\n qa: defaultQa,\n qaVal: defaultQaVal,\n ...otherDefaultProps\n } = defaultProps ?? {};\n\n // Fixed at factory-creation time — no dependency on global config.\n const ownPropsToCheck: readonly string[] = styleProps\n ? (styleProps as StyleList).concat(BASE_STYLES)\n : BASE_STYLES;\n\n // Resolved lazily and refreshed on registry version change. `configure()` can\n // run *after* this factory was created (module eval order — see `Element` at\n // the bottom of this file), and `resetConfig()` reopens configuration, so a\n // one-shot lazy init would go stale. Starts at -1 to force first resolution.\n let propsToCheck: readonly string[] = ownPropsToCheck;\n let propsToCheckVersion = -1;\n\n const modPropsKeys: string[] | undefined = modPropsDef\n ? ((Array.isArray(modPropsDef)\n ? modPropsDef\n : Object.keys(modPropsDef)) as string[])\n : undefined;\n\n const tokenPropsMapping: [string, string][] | undefined = tokenPropsDef\n ? buildTokenPropsMapping(tokenPropsDef as TokenPropsInput)\n : undefined;\n\n // Factory-level cache: maps stable style references to computed classNames.\n // For the common case (no instance overrides), this avoids recomputation.\n const classNameCache = new Map<Styles | undefined, string>();\n\n // Passed when the styles object handed to computeStyles() is the factory's\n // own AND computeStyles() will see it again — which is only true where\n // classNameCache is unavailable, i.e. the server. On the client that cache\n // answers every render after the first, so memoizing chunk keys during that\n // first render would write entries nothing ever reads back. Hoisted so the\n // hot path does not allocate it.\n const STABLE_STYLES: ComputeStylesOptions = { stableStyles: true };\n\n const _TastyComponent = forwardRef<\n unknown,\n AllBasePropsWithMods<K> & WithVariant<V>\n >((incomingProps, ref) => {\n // Global props middleware (`configure({ propHandlers })`). Runs before any\n // destructuring so a handler can rewrite every tasty prop — `styles`, `mods`,\n // `tokens`, `variant`, `as`, `element`, `qa` — and strip its own custom props\n // so they never reach the DOM. `ref` is out of reach: forwardRef separates it.\n // Fast path while nothing is registered: one property load and one branch.\n const applyPropHandlers = propHandlerRegistry.apply;\n const allProps = applyPropHandlers\n ? (applyPropHandlers(\n incomingProps as unknown as PropHandlerProps,\n ) as unknown as typeof incomingProps)\n : incomingProps;\n\n const {\n as,\n styles: rawStyles,\n variant,\n mods,\n element,\n qa,\n qaVal,\n className: userClassName,\n tokens,\n style,\n theme,\n ...otherProps\n } = allProps as Record<string, unknown> as AllBasePropsWithMods<K> &\n WithVariant<V> & {\n className?: string;\n tokens?: Tokens;\n style?: Record<string, unknown>;\n theme?: string;\n };\n\n let styles = rawStyles;\n\n let propStyles: Styles | null = null;\n\n if (propsToCheckVersion !== baseStylePropsRegistry.version) {\n const promoted = baseStylePropsRegistry.list;\n\n propsToCheck =\n promoted.length === 0\n ? ownPropsToCheck\n : ownPropsToCheck.concat(promoted);\n propsToCheckVersion = baseStylePropsRegistry.version;\n }\n\n for (const prop of propsToCheck) {\n const key = prop as unknown as string;\n\n if (key in otherProps) {\n if (!propStyles) propStyles = {};\n const value = (otherProps as any)[key];\n (propStyles as any)[key] = value;\n delete (otherProps as any)[key];\n }\n }\n\n if (!styles || (styles && !hasKeys(styles as Record<string, unknown>))) {\n styles = undefined as unknown as Styles;\n }\n\n let propMods: Record<string, ModValue> | undefined;\n if (modPropsKeys) {\n for (const key of modPropsKeys) {\n if (key in otherProps) {\n if (!propMods) propMods = {};\n propMods[key] = (otherProps as Record<string, unknown>)[\n key\n ] as ModValue;\n delete (otherProps as Record<string, unknown>)[key];\n }\n }\n }\n\n let propTokens: Tokens | undefined;\n if (tokenPropsMapping) {\n for (const [propName, tokenKey] of tokenPropsMapping) {\n if (propName in otherProps) {\n if (!propTokens) propTokens = {} as Tokens;\n (propTokens as Record<string, TokenValue>)[tokenKey] = (\n otherProps as Record<string, unknown>\n )[propName] as TokenValue;\n delete (otherProps as Record<string, unknown>)[propName];\n }\n }\n }\n\n const baseStyles = variantStylesMap\n ? (variantStylesMap[(variant as string) || 'default'] ??\n variantStylesMap['default'])\n : defaultStyles;\n\n const hasInstanceStyles =\n styles && hasKeys(styles as Record<string, unknown>);\n const hasPropStyles = propStyles && hasKeys(propStyles);\n\n const allStyles =\n hasInstanceStyles || hasPropStyles\n ? mergeStyles(baseStyles, styles as Styles, propStyles as Styles)\n : baseStyles;\n\n // Use factory-level cache for stable style references (client only).\n // On the server the cache must be skipped: both the SSR collector and\n // the RSC inline-style paths are per-request, so every request must\n // call computeStyles() to ensure CSS is actually collected/emitted.\n const useFactoryCache = typeof document !== 'undefined';\n let stylesResult: ComputeStylesResult;\n if (\n useFactoryCache &&\n allStyles === baseStyles &&\n classNameCache.has(allStyles)\n ) {\n stylesResult = { className: classNameCache.get(allStyles)! };\n touch(stylesResult.className);\n } else {\n stylesResult = computeStyles(\n allStyles,\n !useFactoryCache && allStyles === baseStyles\n ? STABLE_STYLES\n : undefined,\n );\n if (useFactoryCache && allStyles === baseStyles) {\n classNameCache.set(allStyles, stylesResult.className);\n }\n }\n\n // Merge tokens: default -> instance -> tokenProps\n let mergedTokens: Tokens | undefined;\n if (defaultTokens || tokens || propTokens) {\n if (!defaultTokens && !propTokens) {\n mergedTokens = tokens as Tokens;\n } else if (!tokens && !propTokens) {\n mergedTokens = defaultTokens;\n } else {\n mergedTokens = {\n ...defaultTokens,\n ...(tokens as Tokens),\n ...propTokens,\n } as Tokens;\n }\n }\n\n const processedTokenStyle = processTokens(mergedTokens);\n\n let mergedStyle: Record<string, unknown> | undefined;\n if (processedTokenStyle || style) {\n if (!processedTokenStyle) {\n mergedStyle = style;\n } else if (!style) {\n mergedStyle = processedTokenStyle as Record<string, unknown>;\n } else {\n mergedStyle = {\n ...(processedTokenStyle as Record<string, unknown>),\n ...style,\n };\n }\n }\n\n const mergedMods = propMods\n ? { ...(mods as Record<string, ModValue>), ...propMods }\n : (mods as Record<string, ModValue> | undefined);\n\n let modDataAttrs: Record<string, unknown> | undefined;\n if (mergedMods) {\n modDataAttrs = modAttrs(mergedMods as unknown as Mods) as Record<\n string,\n unknown\n >;\n }\n\n const finalClassName = [\n (userClassName as string) || '',\n stylesResult.className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const elementProps = {\n 'data-element': (element as string | undefined) || defaultElement,\n 'data-qa': (qa as string | undefined) || defaultQa,\n 'data-qaval': (qaVal as string | undefined) || defaultQaVal,\n 'data-theme': theme,\n ...(otherDefaultProps as unknown as Record<string, unknown>),\n ...(modDataAttrs || {}),\n ...(otherProps as unknown as Record<string, unknown>),\n className: finalClassName,\n style: mergedStyle,\n ref,\n } as Record<string, unknown>;\n\n handleIsProperties(elementProps);\n\n if (elementProps['data-theme'] === undefined) {\n delete elementProps['data-theme'];\n }\n\n const el = createElement(\n (as as string | 'div') ?? originalAs,\n elementProps,\n );\n\n // RSC mode: wrap element with inline <style> tag.\n // Class names are extracted from these tags on the client via\n // the doubled-specificity pattern (.tXXX.tXXX), so no <script> is needed.\n if (stylesResult.css) {\n const nonce = getConfig().nonce;\n\n return createElement(\n Fragment,\n null,\n createElement('style', {\n 'data-tasty-rsc': '',\n nonce,\n dangerouslySetInnerHTML: { __html: stylesResult.css },\n }),\n el,\n );\n }\n\n return el;\n });\n\n _TastyComponent.displayName = `TastyComponent(${\n (defaultProps as any).qa || originalAs\n })`;\n\n // Attach sub-element components if elements are defined\n if (elements) {\n const subElements = Object.entries(elements).reduce(\n (acc, [name, definition]) => {\n acc[name] = createSubElement(\n name,\n definition as SubElementDefinition<keyof JSX.IntrinsicElements>,\n );\n return acc;\n },\n {} as Record<string, ForwardRefExoticComponent<any>>,\n );\n\n return Object.assign(_TastyComponent, subElements);\n }\n\n return _TastyComponent;\n}\n\nexport const Element = tasty({});\n","import { useContext } from 'react';\n\nimport { computeStyles } from '../compute-styles';\nimport { getTastySSRContext } from '../ssr/context';\nimport type { Styles } from '../styles/types';\n\nexport interface UseStylesResult {\n /**\n * Generated className(s) to apply to the element.\n * Can be empty string if no styles are provided.\n * With chunking enabled, may contain multiple space-separated class names.\n */\n className: string;\n}\n\n/**\n * Hook to generate CSS classes from Tasty styles.\n * Thin wrapper around `computeStyles()` that adds React context-based\n * SSR collector discovery for backward compatibility with TastyRegistry.\n *\n * For hook-free usage (e.g. in server components), use `computeStyles()` directly.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { className } = useStyles({\n * padding: '2x',\n * fill: '#purple',\n * radius: '1r',\n * });\n *\n * return <div className={className}>Styled content</div>;\n * }\n * ```\n */\nexport function useStyles(\n styles: Styles | undefined,\n options?: { root?: Document | ShadowRoot },\n): UseStylesResult {\n return computeStyles(styles, {\n ssrCollector: useContext(getTastySSRContext()),\n root: options?.root,\n });\n}\n","import { getGlobalInjector } from '../config';\n\n/**\n * Build a per-(injector, root) client state cache for the standalone style\n * functions (`useGlobalStyles`, `useRawCSS`, `useKeyframes`, `useCounterStyle`).\n *\n * Two levels, both weak:\n *\n * - **injector** — `configure()` replaces the global injector, and every dispose\n * handle and generated name we cache belongs to the one that produced it.\n * Keying by injector makes stale state fall away with it, instead of letting\n * change-detection keys suppress re-injection into the new sheets.\n * - **root** — the same selector or slot name can be used in several shadow\n * roots, and each holds its own injection.\n */\nexport function createClientState<T extends object>(\n create: () => T,\n): (root: Document | ShadowRoot) => T {\n const byInjector = new WeakMap<object, WeakMap<Document | ShadowRoot, T>>();\n\n return (root: Document | ShadowRoot): T => {\n const injector = getGlobalInjector() as unknown as object;\n\n let byRoot = byInjector.get(injector);\n if (!byRoot) {\n byRoot = new WeakMap();\n byInjector.set(injector, byRoot);\n }\n\n let state = byRoot.get(root);\n if (!state) {\n state = create();\n byRoot.set(root, state);\n }\n\n return state;\n };\n}\n","import { getConfig } from '../config';\nimport { injectGlobal } from '../injector';\nimport type { StyleResult } from '../pipeline';\nimport { renderStyles } from '../pipeline';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport {\n collectAutoInferredProperties,\n collectAutoInferredPropertiesRSC,\n} from '../ssr/collect-auto-properties';\nimport { formatGlobalRules } from '../ssr/format-global-rules';\nimport type { Styles } from '../styles/types';\nimport { createClientState } from '../utils/client-state';\nimport { hashString } from '../utils/hash';\nimport { resolveRecipes } from '../utils/resolve-recipes';\n\ninterface UseGlobalStylesOptions {\n /**\n * Stable identifier for update tracking (client-only). When provided,\n * changing the styles will dispose the previous injection and inject the\n * new one. Without an id, the selector is used as the slot key.\n * In RSC mode, renders are single-pass so update tracking does not apply.\n */\n id?: string;\n /** Shadow root or document to inject into (client only). */\n root?: Document | ShadowRoot;\n}\n\ninterface ClientGlobalEntry {\n stylesKey: string;\n dispose: () => void;\n}\n\nconst getClientGlobalSlots = createClientState(\n () => new Map<string, ClientGlobalEntry>(),\n);\n\nconst noop = () => {\n /* nothing to dispose */\n};\n\n/**\n * Inject global styles for a given selector.\n * Useful for styling elements by selector without generating classNames.\n *\n * SSR-aware: when a ServerStyleCollector is available, CSS is collected\n * during the render phase instead of being injected into the DOM.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Injected styles are permanent — they are not cleaned up on component unmount.\n * Use the `id` option for update tracking when styles change over the\n * component lifecycle.\n *\n * Update tracking is per-slot and per-root: a slot (`id`, or the selector when\n * no `id` is given) holds exactly one injection per `root`. Changing the styles\n * replaces it; rendering styles that produce no CSS clears it.\n *\n * @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')\n * @param styles - Tasty styles object\n * @param options - Optional settings including `id` for update tracking\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * useGlobalStyles('.card', {\n * padding: '2x',\n * radius: '1r',\n * fill: '#white',\n * });\n *\n * return <div className=\"card\">Content</div>;\n * }\n * ```\n */\nexport function useGlobalStyles(\n selector: string,\n styles?: Styles,\n options?: UseGlobalStylesOptions,\n): void {\n if (!styles) return;\n\n if (!selector) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n '[Tasty] useGlobalStyles: selector is required and cannot be empty. ' +\n 'Styles will not be injected.',\n );\n }\n return;\n }\n\n const target = getStyleTarget();\n\n // Resolve the client slot once — both the fast path below and the injection\n // at the end need it.\n const slots =\n target.mode === 'client'\n ? getClientGlobalSlots(options?.root ?? document)\n : null;\n const slotKey = options?.id ?? selector;\n const stylesKey = slots ? JSON.stringify(styles) : '';\n const existing = slots?.get(slotKey);\n\n // Client fast path: skip resolveRecipes/renderStyles if styles haven't changed\n if (existing && existing.stylesKey === stylesKey) return;\n\n const resolvedStyles = resolveRecipes(styles);\n\n const styleResults = renderStyles(resolvedStyles, selector) as StyleResult[];\n\n if (styleResults.length === 0) {\n // An update that renders no CSS must still clear the slot's previous\n // injection, otherwise the stale rules keep applying to the selector.\n if (slots) {\n existing?.dispose();\n slots.set(slotKey, { stylesKey, dispose: noop });\n }\n return;\n }\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatGlobalRules(styleResults);\n if (css) {\n // A slot key (explicit `id`) replaces, matching client update tracking;\n // content-hashed keys only dedup.\n const key = options?.id\n ? `global:${options.id}`\n : `global:${selector}:${hashString(css)}`;\n target.collector.collectGlobalStyles(key, css, options?.id != null);\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n collectAutoInferredProperties(\n styleResults,\n target.collector,\n resolvedStyles,\n );\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatGlobalRules(styleResults);\n if (css) {\n const key = options?.id\n ? `__global:${options.id}`\n : `__global:${selector}:${hashString(css)}`;\n pushRSCCSS(target.cache, key, css, options?.id != null);\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n collectAutoInferredPropertiesRSC(\n styleResults,\n target.cache,\n resolvedStyles,\n );\n }\n return;\n }\n\n // Client path\n if (slots) {\n existing?.dispose();\n\n const { dispose } = injectGlobal(styleResults, { root: options?.root });\n slots.set(slotKey, { stylesKey, dispose });\n }\n}\n","/**\n * Shallow comparison of two dependency arrays using Object.is semantics.\n * Returns true when both arrays have the same length and every element\n * at the same index is identical.\n */\nexport function depsEqual(\n a: readonly unknown[],\n b: readonly unknown[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) return false;\n }\n return true;\n}\n","import { injectRawCSS } from '../injector';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { createClientState } from '../utils/client-state';\nimport { depsEqual } from '../utils/deps-equal';\nimport { hashString } from '../utils/hash';\n\ninterface UseRawCSSOptions {\n /**\n * Shadow root or document to inject into. Update tracking is per-root: the\n * same id in two roots holds a separate injection in each.\n */\n root?: Document | ShadowRoot;\n /**\n * Stable identifier for update tracking (client-only). When provided,\n * changing the CSS content will dispose the previous injection and inject\n * the new one. Without an id, deduplication is purely content-based (same\n * CSS is injected only once). In RSC mode, renders are single-pass so\n * update tracking does not apply.\n */\n id?: string;\n}\n\ninterface ClientEntry {\n contentKey: string;\n dispose: () => void;\n}\n\ninterface ClientRawCSSState {\n /** id -> the single injection that slot currently owns */\n entries: Map<string, ClientEntry>;\n /** content hashes injected without an id (permanent, deduped) */\n contentDedup: Set<string>;\n /** id -> last factory deps, to skip re-evaluating the factory */\n factoryDeps: Map<string, readonly unknown[]>;\n}\n\nconst getClientState = createClientState((): ClientRawCSSState => ({\n entries: new Map(),\n contentDedup: new Set(),\n factoryDeps: new Map(),\n}));\n\n// Overload 1: Static CSS string\nexport function useRawCSS(css: string, options?: UseRawCSSOptions): void;\n\n// Overload 2: Factory function with dependencies\nexport function useRawCSS(\n factory: () => string,\n deps: readonly unknown[],\n options?: UseRawCSSOptions,\n): void;\n\n/**\n * Inject raw CSS text directly without parsing.\n * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.\n *\n * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts\n * with tasty's chunked style sheets.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Injected styles are permanent — they are not cleaned up on component unmount.\n * Use the `id` option for update tracking when styles change over the\n * component lifecycle.\n *\n * @example Static CSS string\n * ```tsx\n * function GlobalStyles() {\n * useRawCSS(`\n * body {\n * margin: 0;\n * padding: 0;\n * font-family: sans-serif;\n * }\n * `);\n *\n * return null;\n * }\n * ```\n *\n * @example Factory function with dependencies\n * ```tsx\n * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {\n * useRawCSS(() => `\n * :root {\n * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};\n * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};\n * }\n * `, [theme], { id: 'theme-vars' });\n *\n * return null;\n * }\n * ```\n *\n * @example With options\n * ```tsx\n * function ShadowStyles({ shadowRoot }) {\n * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });\n * return null;\n * }\n * ```\n */\nexport function useRawCSS(\n cssOrFactory: string | (() => string),\n depsOrOptions?: readonly unknown[] | UseRawCSSOptions,\n options?: UseRawCSSOptions,\n): void {\n const isFactory = typeof cssOrFactory === 'function';\n\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseRawCSSOptions | undefined);\n\n const target = getStyleTarget();\n\n const state =\n target.mode === 'client' ? getClientState(opts?.root ?? document) : null;\n\n // Client deps cache: skip factory re-evaluation when deps haven't changed\n if (isFactory && deps && opts?.id && state) {\n const cachedDeps = state.factoryDeps.get(opts.id);\n if (cachedDeps && depsEqual(cachedDeps, deps)) {\n return;\n }\n }\n\n const css = isFactory\n ? (cssOrFactory as () => string)()\n : (cssOrFactory as string);\n\n if (!css.trim()) return;\n\n if (target.mode === 'ssr') {\n // A slot key (explicit `id`) replaces, matching client update tracking;\n // content-hashed keys only dedup.\n const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;\n target.collector.collectRawCSS(key, css, opts?.id != null);\n return;\n }\n\n if (target.mode === 'rsc') {\n const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;\n pushRSCCSS(target.cache, key, css, opts?.id != null);\n return;\n }\n\n // Client path\n if (!state) return;\n\n const id = opts?.id;\n\n if (id) {\n const existing = state.entries.get(id);\n if (existing) {\n if (existing.contentKey === css) return;\n existing.dispose();\n }\n\n const { dispose } = injectRawCSS(css, opts);\n state.entries.set(id, { contentKey: css, dispose });\n if (deps) state.factoryDeps.set(id, deps);\n } else {\n const contentKey = hashString(css);\n if (state.contentDedup.has(contentKey)) return;\n state.contentDedup.add(contentKey);\n injectRawCSS(css, opts);\n }\n}\n","import { getNamePrefix } from '../config';\nimport { keyframes } from '../injector';\nimport type { KeyframesSteps } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { formatKeyframesCSS } from '../ssr/format-keyframes';\nimport { createClientState } from '../utils/client-state';\nimport { depsEqual } from '../utils/deps-equal';\nimport { hashString } from '../utils/hash';\nimport { makeKeyframeName } from '../utils/name-prefix';\n\ninterface UseKeyframesOptions {\n name?: string;\n root?: Document | ShadowRoot;\n}\n\ninterface FactoryDepsEntry {\n deps: readonly unknown[];\n name: string;\n}\n\ninterface NamedSlotEntry {\n cacheKey: string;\n dispose: () => void;\n}\n\ninterface ClientKeyframesState {\n /** cacheKey (name + serialized steps) -> generated animation name */\n contentToName: Map<string, string>;\n /** provided name -> the single injection that slot currently owns */\n namedSlots: Map<string, NamedSlotEntry>;\n /** provided name -> last factory deps, to skip re-evaluating the factory */\n factoryDeps: Map<string, FactoryDepsEntry>;\n}\n\nconst getClientState = createClientState((): ClientKeyframesState => ({\n contentToName: new Map(),\n namedSlots: new Map(),\n factoryDeps: new Map(),\n}));\n\n/**\n * Inject CSS @keyframes and return the generated animation name.\n * Deduplicates by content — identical steps always return the same name.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Passing `name` claims a slot owned by that one call site (like `useRawCSS`'s\n * `id`): when its steps change, the previous injection is disposed and the name\n * is reused, so the rules don't accumulate. Anonymous keyframes are permanent\n * and shared by content.\n *\n * @example Basic usage - steps object is the dependency\n * ```tsx\n * function MyComponent() {\n * const bounce = useKeyframes({\n * '0%': { transform: 'scale(1)' },\n * '50%': { transform: 'scale(1.1)' },\n * '100%': { transform: 'scale(1)' },\n * });\n *\n * return <div style={{ animation: `${bounce} 1s infinite` }}>Bouncing</div>;\n * }\n * ```\n *\n * @example With custom name\n * ```tsx\n * function MyComponent() {\n * const fadeIn = useKeyframes(\n * { from: { opacity: 0 }, to: { opacity: 1 } },\n * { name: 'fadeIn' }\n * );\n *\n * return <div style={{ animation: `${fadeIn} 0.3s ease-out` }}>Fading in</div>;\n * }\n * ```\n *\n * @example Factory function with dependencies\n * ```tsx\n * function MyComponent({ scale }: { scale: number }) {\n * const pulse = useKeyframes(\n * () => ({\n * '0%': { transform: 'scale(1)' },\n * '100%': { transform: `scale(${scale})` },\n * }),\n * [scale]\n * );\n *\n * return <div style={{ animation: `${pulse} 1s infinite` }}>Pulsing</div>;\n * }\n * ```\n */\n\n// Overload 1: Static steps object\nexport function useKeyframes(\n steps: KeyframesSteps,\n options?: UseKeyframesOptions,\n): string;\n\n// Overload 2: Factory function with dependencies\nexport function useKeyframes(\n factory: () => KeyframesSteps,\n deps: readonly unknown[],\n options?: UseKeyframesOptions,\n): string;\n\n// Implementation\nexport function useKeyframes(\n stepsOrFactory: KeyframesSteps | (() => KeyframesSteps),\n depsOrOptions?: readonly unknown[] | UseKeyframesOptions,\n options?: UseKeyframesOptions,\n): string {\n const isFactory = typeof stepsOrFactory === 'function';\n\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseKeyframesOptions | undefined);\n\n const target = getStyleTarget();\n\n const clientState =\n target.mode === 'client' ? getClientState(opts?.root ?? document) : null;\n\n // Client deps cache: skip factory re-evaluation when deps haven't changed\n if (isFactory && deps && opts?.name && clientState) {\n const cached = clientState.factoryDeps.get(opts.name);\n if (cached && depsEqual(cached.deps, deps)) {\n return cached.name;\n }\n }\n\n const steps = isFactory\n ? (stepsOrFactory as () => KeyframesSteps)()\n : (stepsOrFactory as KeyframesSteps);\n\n if (!steps || Object.keys(steps).length === 0) {\n return '';\n }\n\n if (target.mode === 'ssr') {\n const actualName = target.collector.allocateKeyframeName(opts?.name);\n const css = formatKeyframesCSS(actualName, steps);\n target.collector.collectKeyframes(actualName, css);\n return actualName;\n }\n\n if (target.mode === 'rsc') {\n const serializedContent = JSON.stringify(steps);\n const key = `__kf:${opts?.name ?? ''}:${serializedContent}`;\n\n const existingName = target.cache.generatedNames.get(key);\n if (existingName) return existingName;\n\n const actualName =\n opts?.name ??\n makeKeyframeName(getNamePrefix(), hashString(serializedContent));\n const css = formatKeyframesCSS(actualName, steps);\n pushRSCCSS(target.cache, key, css);\n target.cache.generatedNames.set(key, actualName);\n return actualName;\n }\n\n // Client path: stable name via content-based dedup\n const state = clientState ?? getClientState(opts?.root ?? document);\n const serializedContent = JSON.stringify(steps);\n const cacheKey = `${opts?.name ?? ''}:${serializedContent}`;\n\n const cachedName = state.contentToName.get(cacheKey);\n if (cachedName) {\n return cachedName;\n }\n\n const providedName = opts?.name;\n\n // A named slot owns exactly one injection. When its content changes, drop the\n // previous one first: disposing frees the name so the new steps can reclaim\n // it, and it keeps old @keyframes rules from piling up in the sheet.\n if (providedName) {\n const slot = state.namedSlots.get(providedName);\n\n if (slot && slot.cacheKey !== cacheKey) {\n slot.dispose();\n // Forget the stale content too, so any other call site still passing the\n // old steps re-injects instead of pointing at a removed rule.\n state.contentToName.delete(slot.cacheKey);\n state.namedSlots.delete(providedName);\n }\n }\n\n const result = keyframes(steps, {\n name: providedName,\n root: opts?.root,\n });\n\n const name = result.toString();\n state.contentToName.set(cacheKey, name);\n\n if (providedName) {\n state.namedSlots.set(providedName, { cacheKey, dispose: result.dispose });\n\n if (deps) {\n state.factoryDeps.set(providedName, { deps, name });\n }\n }\n\n return name;\n}\n","import { getGlobalInjector } from '../config';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { formatPropertyCSS } from '../ssr/format-property';\nimport type { PropertyOptions } from '../injector/types';\n\n/**\n * Options for {@link useProperty}. Extends the shared {@link PropertyOptions}\n * (which is `PropertyDefinition` plus an optional injection `root`).\n */\nexport type UsePropertyOptions = PropertyOptions;\n\n/**\n * Register a CSS @property custom property.\n * This enables advanced features like animating custom properties.\n *\n * Note: @property rules are global and persistent once defined.\n * The function ensures the property is only registered once per root.\n *\n * Accepts tasty token syntax for the property name:\n * - `$name` → defines `--name`\n * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')\n * - `--name` → defines `--name` (legacy format)\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param name - The property token ($name, #name) or CSS property name (--name)\n * @param options - Property configuration\n *\n * @example Basic property with token syntax\n * ```tsx\n * function Spinner() {\n * useProperty('$rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n *\n * return <div className=\"spinner\" />;\n * }\n * ```\n *\n * @example Color property with token syntax (auto-sets syntax)\n * ```tsx\n * function MyComponent() {\n * useProperty('#theme', {\n * initialValue: 'red', // syntax: '<color>' is auto-set\n * });\n *\n * // Now --theme-color can be animated with CSS transitions\n * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;\n * }\n * ```\n *\n * @example Legacy format (still supported)\n * ```tsx\n * function ResizableBox() {\n * useProperty('--box-size', {\n * syntax: '<length>',\n * initialValue: '100px',\n * });\n *\n * return <div style={{ width: 'var(--box-size)' }} />;\n * }\n * ```\n */\nexport function useProperty(name: string, options?: UsePropertyOptions): void {\n if (!name) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Tasty] useProperty: property name is required`);\n }\n return;\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatPropertyCSS(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n });\n if (css) {\n target.collector.collectProperty(name, css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatPropertyCSS(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n });\n if (css) {\n pushRSCCSS(target.cache, `__prop:${name}`, css);\n }\n return;\n }\n\n const injector = getGlobalInjector();\n\n if (injector.isPropertyDefined(name, { root: options?.root })) {\n return;\n }\n\n injector.property(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n root: options?.root,\n });\n}\n","import { getGlobalInjector } from '../config';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport type { FontFaceDescriptors, FontFaceInput } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\n\ninterface UseFontFaceOptions {\n root?: Document | ShadowRoot;\n}\n\n/**\n * Inject CSS @font-face rules.\n * Permanent — no cleanup on unmount. Deduplicates by content hash.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param family - The font-family name\n * @param input - Single descriptor object or array of descriptors (for multiple weights/styles)\n * @param options - Optional settings (e.g. Shadow DOM root)\n *\n * @example Single weight\n * ```tsx\n * function App() {\n * useFontFace('Brand Sans', {\n * src: 'url(\"/fonts/brand-sans.woff2\") format(\"woff2\")',\n * fontWeight: '400 700',\n * fontDisplay: 'swap',\n * });\n *\n * return <div style={{ fontFamily: '\"Brand Sans\", sans-serif' }}>Hello</div>;\n * }\n * ```\n *\n * @example Multiple weights\n * ```tsx\n * function App() {\n * useFontFace('Brand Sans', [\n * { src: 'url(\"/fonts/brand-regular.woff2\") format(\"woff2\")', fontWeight: 400, fontDisplay: 'swap' },\n * { src: 'url(\"/fonts/brand-bold.woff2\") format(\"woff2\")', fontWeight: 700, fontDisplay: 'swap' },\n * ]);\n *\n * return <div style={{ fontFamily: '\"Brand Sans\", sans-serif' }}>Hello</div>;\n * }\n * ```\n */\nexport function useFontFace(\n family: string,\n input: FontFaceInput,\n options?: UseFontFaceOptions,\n): void {\n if (!family) return;\n\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n target.collector.collectFontFace(hash, css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n pushRSCCSS(target.cache, `__ff:${hash}`, css);\n }\n return;\n }\n\n const injector = getGlobalInjector();\n for (const desc of descriptors) {\n injector.fontFace(family, desc, { root: options?.root });\n }\n}\n","import { getGlobalInjector, getNamePrefix } from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport type { CounterStyleDescriptors } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { createClientState } from '../utils/client-state';\nimport { hashString } from '../utils/hash';\nimport { makeCounterStyleName } from '../utils/name-prefix';\n\ninterface UseCounterStyleOptions {\n name?: string;\n root?: Document | ShadowRoot;\n}\n\nlet clientCounterStyleCounter = 0;\n\nconst getClientContentToName = createClientState(\n () => new Map<string, string>(),\n);\n\n/**\n * Inject a CSS @counter-style rule and return the generated name.\n * Permanent — no cleanup on unmount. Deduplicates by name.\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @example Basic usage\n * ```tsx\n * function EmojiList() {\n * const styleName = useCounterStyle({\n * system: 'cyclic',\n * symbols: '\"👍\"',\n * suffix: '\" \"',\n * }, { name: 'thumbs' });\n *\n * return (\n * <ol style={{ listStyleType: styleName }}>\n * <li>First</li>\n * <li>Second</li>\n * </ol>\n * );\n * }\n * ```\n *\n */\nexport function useCounterStyle(\n descriptors: CounterStyleDescriptors,\n options?: UseCounterStyleOptions,\n): string {\n if (!descriptors || !descriptors.system) {\n return '';\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n const actualName = target.collector.allocateCounterStyleName(options?.name);\n const css = formatCounterStyleRule(actualName, descriptors);\n target.collector.collectCounterStyle(actualName, css);\n return actualName;\n }\n\n if (target.mode === 'rsc') {\n const serializedContent = JSON.stringify(descriptors);\n const key = `__cs:${options?.name ?? ''}:${serializedContent}`;\n\n const existingName = target.cache.generatedNames.get(key);\n if (existingName) return existingName;\n\n const actualName =\n options?.name ??\n makeCounterStyleName(getNamePrefix(), hashString(serializedContent));\n const css = formatCounterStyleRule(actualName, descriptors);\n pushRSCCSS(target.cache, key, css);\n target.cache.generatedNames.set(key, actualName);\n return actualName;\n }\n\n // Client path: stable name via content-based dedup\n const contentToName = getClientContentToName(options?.root ?? document);\n const serializedContent = JSON.stringify(descriptors);\n const cacheKey = `${options?.name ?? ''}:${serializedContent}`;\n\n const existingName = contentToName.get(cacheKey);\n if (existingName) {\n return existingName;\n }\n\n const name =\n options?.name ??\n makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));\n contentToName.set(cacheKey, name);\n\n const injector = getGlobalInjector();\n injector.counterStyle(name, descriptors, { root: options?.root });\n\n return name;\n}\n","import { getGlobalInjector, isFunctionsPolyfillEnabled } from '../config';\nimport {\n formatFunctionRule,\n parseFunctionName,\n registerFunctionPolyfill,\n} from '../functions';\nimport type { FunctionDefinition } from '../injector/types';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\n\nexport interface UseFunctionOptions {\n /** Shadow root or document to inject into. */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Register a CSS @function (custom function).\n *\n * @function rules are global and persistent once defined. The hook ensures the\n * function is only registered once per root (deduplicated by function name).\n *\n * Accepts tasty token syntax for the function name:\n * - `$$name` → defines `--name` (matches the call site `$$name(...)`)\n * - `$name` / `--name` → also accepted\n *\n * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * @param name - The function name token (`$$name`, `$name`, or `--name`)\n * @param definition - Function definition (args, returns, result, local vars)\n *\n * Call the function through the Tasty DSL, not a raw `style` prop: an inline\n * `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never\n * expanded and `polyfills.functions` cannot rewrite it either.\n *\n * @example\n * ```tsx\n * const Box = tasty({ styles: { marginTop: '$$negative(10px)' } });\n *\n * function Layout() {\n * useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });\n * return <Box />;\n * }\n * ```\n */\nexport function useFunction(\n name: string,\n definition: FunctionDefinition,\n options?: UseFunctionOptions,\n): void {\n if (!name) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Tasty] useFunction: function name is required`);\n }\n return;\n }\n\n // @function polyfill: register an inline closure so call sites are expanded\n // into plain CSS by the parser. No native @function rule is emitted.\n if (isFunctionsPolyfillEnabled()) {\n registerFunctionPolyfill(name, definition);\n return;\n }\n\n const target = getStyleTarget();\n\n if (target.mode === 'ssr') {\n target.collector.collectInternals();\n\n const css = formatFunctionRule(name, definition);\n if (css) {\n target.collector.collectFunction(parseFunctionName(name), css);\n }\n return;\n }\n\n if (target.mode === 'rsc') {\n const css = formatFunctionRule(name, definition);\n if (css) {\n pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);\n }\n return;\n }\n\n getGlobalInjector().func(name, definition, { root: options?.root });\n}\n","import { useInsertionEffect } from 'react';\nimport type { ReactNode } from 'react';\n\nimport { closeBatchWindow, openBatchWindow } from './injector/batch';\n\nexport interface TastyBatchProviderProps {\n children?: ReactNode;\n}\n\n/**\n * Opens a *batch window* for the commit it renders in, so `batchInjection`\n * can defer stylesheet writes without ever letting a layout effect measure an\n * unstyled element.\n *\n * Every `insertRule()` on a live sheet invalidates style for that sheet's\n * scope. When components inject during React's render phase while others read\n * layout in the same pass, the two interleave and the browser recalculates\n * style between every injection. Batching collapses that into one invalidation\n * per flush — but only if the flush happens before anything can measure.\n *\n * ```\n * provider renders -> window OPEN\n * children render -> injections queued\n * provider insertionEffect -> FLUSH, window CLOSED\n * layout effects run -> rules are in the sheet\n * ```\n *\n * `useInsertionEffect` runs in React's mutation phase, after every render in\n * the commit and before any `useLayoutEffect` — which is exactly why React\n * added it for CSS-in-JS libraries. Effects fire child-first, so this\n * provider's runs after every descendant's and still before all layout\n * effects.\n *\n * A commit that does not re-render this provider gets no window, and those\n * injections are written synchronously instead. That is the point: turning\n * `batchInjection: true` on can only ever make injection cheaper, never make a\n * measurement wrong. It also means batching applies to commits this provider\n * takes part in, so mount it as high in the tree as you can.\n *\n * Requires `configure({ batchInjection: true })`; without it this component\n * only renders its children. `batchInjection: 'always'` does not need the\n * provider at all — see that option's docs for the trade-off it accepts.\n *\n * @example\n * ```tsx\n * configure({ batchInjection: true });\n *\n * createRoot(el).render(\n * <TastyBatchProvider>\n * <App />\n * </TastyBatchProvider>,\n * );\n * ```\n */\nexport function TastyBatchProvider({ children }: TastyBatchProviderProps) {\n // Opened during render on purpose: the window has to be open before children\n // render, and this is the only phase that precedes them. It is idempotent and\n // has no other side effect, so StrictMode's double render costs nothing. A\n // render that is thrown away (aborted or suspended) leaves the window open,\n // which the microtask backstop closes — and such a render mounts nothing, so\n // nothing can measure what it queued.\n openBatchWindow();\n\n // Fires in the mutation phase, before any layout effect. No dependency array:\n // it must run on every commit this provider is part of.\n useInsertionEffect(() => {\n closeBatchWindow();\n });\n\n return children;\n}\n"],"mappings":";;;;;;;;;;AAEA,MAAM,eAAe;AAErB,SAAgB,eACd,WACA,eAAe,cACP;CACR,IAAI,OAAO,cAAc,YACvB,OAAO,UAAU,eAAe,UAAU,QAAQ;CAGpD,OAAO;AACT;;;;;;;;ACRA,SAAgB,mBAAmB,OAAyB;CAC1D,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAChD,OAAO;CAGT,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,OAAQ,MAAiC,aAAa;CAG/D,OAAO;AACT;;;;;;ACwCA,MAAM,wBAAwB,OAAO,QAAQ;CAR3C,YAAY;CACZ,UAAU;CACV,WAAW;AAMgD,CAAC;;;;;AAM9D,SAAS,mBAAmB,OAAgC;CAC1D,KAAK,MAAM,CAAC,YAAY,oBAAoB,uBAAuB;EACjE,IAAI,cAAc,OAAO;GACvB,MAAM,mBAAmB,MAAM;GAC/B,OAAO,MAAM;EACf;EAGA,MAAM,gBAAgB,QAAQ;EAC9B,IAAI,EAAE,iBAAiB,UAAU,MAAM,kBACrC,MAAM,iBAAiB;CAE3B;AACF;;;;;AAMA,SAAS,iBACP,aACA,YAGA;CAEA,MAAM,SACJ,OAAO,eAAe,WAClB,EAAE,IAAI,WAAkB,IACvB;CAEP,MAAM,MAAM,OAAO,MAAO;CAC1B,MAAM,YAAY,OAAO;CACzB,MAAM,eAAe,OAAO;CAE5B,MAAM,aAAa,YAA2C,OAAO,QAAQ;EAC3E,MAAM,EACJ,IACA,OACA,MACA,QACA,YACA,UACA,WACA,WACA,OACA,GAAG,cACD;EAMJ,IAAI;EACJ,IAAI,MACF,eAAe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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC7BA,SAAgB,mBAAmB,EAAE,YAAqC;CAOxE,gBAAgB;CAIhB,yBAAyB;EACvB,iBAAiB;CACnB,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as STYLE_TO_CHUNK, F as hasPipelineCacheEntry, H as extractPredefinedStateRefs, I as isSelector, L as renderStyles, V as extractLocalPredefinedStates, wt as CHUNK_NAMES } from "./config-
|
|
1
|
+
import { At as STYLE_TO_CHUNK, F as hasPipelineCacheEntry, H as extractPredefinedStateRefs, I as isSelector, L as renderStyles, V as extractLocalPredefinedStates, _t as hashString, wt as CHUNK_NAMES } from "./config-B3gPdCqd.js";
|
|
2
2
|
//#region src/chunks/definitions.ts
|
|
3
3
|
/**
|
|
4
4
|
* Style chunk definitions for CSS chunking optimization.
|
|
@@ -431,6 +431,48 @@ function extractAnimationNamesFromStyles(styles) {
|
|
|
431
431
|
* @param nameMap Map from original name to injected name (only contains names that differ)
|
|
432
432
|
* @returns Updated declarations string
|
|
433
433
|
*/
|
|
434
|
+
/**
|
|
435
|
+
* The name a local `@keyframes` block is emitted under.
|
|
436
|
+
*
|
|
437
|
+
* Content-addressed, and a pure function of what was authored: the same steps
|
|
438
|
+
* always produce the same name, and different steps under the same authored
|
|
439
|
+
* name cannot collide. That is what lets the server and the client agree —
|
|
440
|
+
* a name handed out by whichever injector happened to see the definition first
|
|
441
|
+
* depends on run order, so the two would disagree on both the animation name
|
|
442
|
+
* and the class that references it.
|
|
443
|
+
*/
|
|
444
|
+
function resolveKeyframesName(authored, steps) {
|
|
445
|
+
return `${authored}-${hashString(JSON.stringify(steps))}`;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* The emitted name for every local `@keyframes` in `styles`, by authored name.
|
|
449
|
+
* Pure — the server, the RSC pass and the client all reach the same answer.
|
|
450
|
+
*/
|
|
451
|
+
function resolveKeyframesNames(used) {
|
|
452
|
+
const names = /* @__PURE__ */ new Map();
|
|
453
|
+
for (const [authored, steps] of Object.entries(used)) names.set(authored, resolveKeyframesName(authored, steps));
|
|
454
|
+
return names;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Whether `declarations` names `animation` as an animation to run.
|
|
458
|
+
*
|
|
459
|
+
* Only `animation` and `animation-name` values count, and only whole tokens
|
|
460
|
+
* within them: an animation called `crossfade` does not use keyframes called
|
|
461
|
+
* `fade`. Same parsing as `replaceAnimationNames`, so the two agree on what
|
|
462
|
+
* counts as a reference.
|
|
463
|
+
*/
|
|
464
|
+
function referencesAnimation(declarations, animation) {
|
|
465
|
+
if (!declarations.includes("animation")) return false;
|
|
466
|
+
for (const part of declarations.split(";")) {
|
|
467
|
+
const colonIdx = part.indexOf(":");
|
|
468
|
+
if (colonIdx === -1) continue;
|
|
469
|
+
const prop = part.slice(0, colonIdx).trim().toLowerCase();
|
|
470
|
+
if (prop !== "animation" && prop !== "animation-name") continue;
|
|
471
|
+
const value = part.slice(colonIdx + 1);
|
|
472
|
+
if (replaceWord(value, animation, "\0") !== value) return true;
|
|
473
|
+
}
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
434
476
|
function replaceAnimationNames(declarations, nameMap) {
|
|
435
477
|
if (!declarations.includes("animation")) return declarations;
|
|
436
478
|
const parts = declarations.split(";");
|
|
@@ -488,6 +530,6 @@ function filterUsedKeyframes(keyframes, usedNames) {
|
|
|
488
530
|
return hasAny ? used : null;
|
|
489
531
|
}
|
|
490
532
|
//#endregion
|
|
491
|
-
export { mergeKeyframes as a,
|
|
533
|
+
export { mergeKeyframes as a, resolveKeyframesNames as c, categorizeStyleKeys as d, hasLocalKeyframes as i, renderStylesForChunk as l, extractLocalKeyframes as n, referencesAnimation as o, filterUsedKeyframes as r, replaceAnimationNames as s, extractAnimationNamesFromStyles as t, generateChunkCacheKey as u };
|
|
492
534
|
|
|
493
|
-
//# sourceMappingURL=keyframes-
|
|
535
|
+
//# sourceMappingURL=keyframes-DE-OE76F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyframes-DE-OE76F.js","names":[],"sources":["../src/chunks/definitions.ts","../src/chunks/cacheKey.ts","../src/chunks/renderChunk.ts","../src/keyframes/index.ts"],"sourcesContent":["/**\n * Style chunk definitions for CSS chunking optimization.\n *\n * Styles are grouped into chunks based on:\n * 1. Handler dependencies - styles that share a handler MUST be in the same chunk\n * 2. Logical grouping - related styles grouped for better cache reuse\n *\n * See STYLE_CHUNKING_SPEC.md for detailed rationale.\n *\n * ============================================================================\n * ⚠️ CRITICAL ARCHITECTURAL CONSTRAINT: NO CROSS-CHUNK HANDLER DEPENDENCIES\n * ============================================================================\n *\n * Style handlers declare their dependencies via `__lookupStyles` array.\n * This creates a dependency graph where handlers read multiple style props.\n *\n * **ALL styles in a handler's `__lookupStyles` MUST be in the SAME chunk.**\n *\n * Why this matters:\n * 1. Each chunk computes a cache key from ONLY its own style values\n * 2. If a handler reads a style from another chunk, that value isn't in the cache key\n * 3. Changing the cross-chunk style won't invalidate this chunk's cache\n * 4. Result: stale CSS output or incorrect cache hits\n *\n * Example of a violation:\n * ```\n * // flowStyle.__lookupStyles = ['display', 'flow']\n * // If 'display' is in DISPLAY chunk and 'flow' is in LAYOUT chunk:\n * // - User sets { display: 'grid', flow: 'column' }\n * // - LAYOUT chunk caches CSS with flow=column, display=grid\n * // - User changes to { display: 'flex', flow: 'column' }\n * // - LAYOUT chunk cache key unchanged (only has 'flow')\n * // - Returns stale CSS computed with display=grid!\n * ```\n *\n * Before adding/moving styles, verify:\n * 1. Find all handlers that use this style (grep for the style name in __lookupStyles)\n * 2. Ensure ALL styles from each handler's __lookupStyles are in the same chunk\n *\n * For **custom** handlers registered through `configure({ handlers })` this is no\n * longer only a convention: `alignHandlerChunks()` in `styles/predefined.ts` pulls\n * any style name the lists below don't know into its handler's existing chunk, and\n * warns when a handler bridges two chunks defined here. The lists below are still\n * hand-maintained, so the constraint must be checked by hand when editing them.\n * ============================================================================\n */\n\nimport { isSelector } from '../pipeline';\n\nimport { CHUNK_NAMES, STYLE_TO_CHUNK } from './style-chunk-map';\nimport type { ChunkName } from './style-chunk-map';\n\n// ============================================================================\n// Chunk Style Lists\n// ============================================================================\n\n// The chunk style lists and the style→chunk map live in `style-chunk-map.ts` so\n// that the map is populated by importing *that* module, independent of whether\n// this one has been loaded. Re-exported here for the original import paths.\nexport {\n APPEARANCE_CHUNK_STYLES,\n DIMENSION_CHUNK_STYLES,\n DISPLAY_CHUNK_STYLES,\n FONT_CHUNK_STYLES,\n LAYOUT_CHUNK_STYLES,\n POSITION_CHUNK_STYLES,\n} from './style-chunk-map';\nexport { CHUNK_NAMES, STYLE_TO_CHUNK } from './style-chunk-map';\nexport type { ChunkName } from './style-chunk-map';\n\n// ============================================================================\n// Chunk Priority Order\n// ============================================================================\n\n/**\n * Chunk processing order. This ensures deterministic className allocation\n * regardless of style key order in the input.\n */\nconst CHUNK_ORDER: readonly string[] = [\n CHUNK_NAMES.APPEARANCE,\n CHUNK_NAMES.FONT,\n CHUNK_NAMES.DIMENSION,\n CHUNK_NAMES.DISPLAY,\n CHUNK_NAMES.LAYOUT,\n CHUNK_NAMES.POSITION,\n CHUNK_NAMES.MISC,\n CHUNK_NAMES.SUBCOMPONENTS,\n] as const;\n\n/**\n * Map from chunk name to its priority index for sorting.\n */\nconst _CHUNK_PRIORITY = new Map<string, number>(\n CHUNK_ORDER.map((name, index) => [name, index]),\n);\n\n// ============================================================================\n// Chunk Info Interface\n// ============================================================================\n\nexport interface ChunkInfo {\n /** Name of the chunk */\n name: ChunkName | string;\n /** Style keys belonging to this chunk */\n styleKeys: string[];\n}\n\n// ============================================================================\n// Style Categorization\n// ============================================================================\n\n/**\n * Categorize style keys into chunks.\n *\n * Returns chunks in a deterministic order (by CHUNK_ORDER) regardless\n * of the order of keys in the input styles object.\n *\n * @param styles - The styles object to categorize\n * @returns Map of chunk name to array of style keys in that chunk (in priority order)\n */\nexport function categorizeStyleKeys(\n styles: Record<string, unknown>,\n): Map<string, string[]> {\n // First pass: collect keys into chunks (unordered)\n const chunkData: Record<string, string[]> = {};\n const keys = Object.keys(styles);\n\n for (const key of keys) {\n // Skip the $ helper key (used for selector combinators)\n // Skip @keyframes and @property (processed separately in useStyles)\n // Skip recipe (resolved before pipeline by resolveRecipes)\n if (\n key === '$' ||\n key === '@keyframes' ||\n key === '@property' ||\n key === '@font-face' ||\n key === '@counter-style' ||\n key === '@function' ||\n key === 'recipe'\n ) {\n continue;\n }\n\n if (isSelector(key)) {\n // All selectors go into the subcomponents chunk\n if (!chunkData[CHUNK_NAMES.SUBCOMPONENTS]) {\n chunkData[CHUNK_NAMES.SUBCOMPONENTS] = [];\n }\n chunkData[CHUNK_NAMES.SUBCOMPONENTS].push(key);\n } else {\n // Look up the chunk for this style, default to misc\n const chunkName = STYLE_TO_CHUNK.get(key) ?? CHUNK_NAMES.MISC;\n if (!chunkData[chunkName]) {\n chunkData[chunkName] = [];\n }\n chunkData[chunkName].push(key);\n }\n }\n\n // Second pass: build ordered Map based on CHUNK_ORDER\n const orderedChunks = new Map<string, string[]>();\n\n // Add chunks in priority order\n for (const chunkName of CHUNK_ORDER) {\n if (chunkData[chunkName] && chunkData[chunkName].length > 0) {\n // Sort keys within chunk for consistent cache key generation\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n // Handle any unknown chunks (shouldn't happen, but be defensive)\n for (const chunkName of Object.keys(chunkData)) {\n if (!orderedChunks.has(chunkName)) {\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n return orderedChunks;\n}\n","/**\n * Chunk-specific cache key generation.\n *\n * Generates cache keys that only include styles relevant to a specific chunk,\n * enabling more granular caching and reuse.\n *\n * Enhanced to support predefined states:\n * - Global predefined states don't affect cache keys (constant across app)\n * - Local predefined states only affect cache keys if referenced in the chunk\n */\n\nimport {\n extractLocalPredefinedStates,\n extractPredefinedStateRefs,\n} from '../states';\nimport type { Styles } from '../styles/types';\n\nconst _stableStringifyCache = new WeakMap<object, string>();\n\ninterface ChunkKeyEntry {\n /**\n * Flat `[key0, value0, key1, value1, …]` record of exactly what the key was\n * built from. Interleaving keeps an entry to one allocation.\n */\n snapshot: unknown[];\n key: string;\n}\n\n/**\n * Per-styles-object memo of generated keys, keyed by chunk name.\n *\n * Reading from this is free, so every call checks it. Writing to it is not:\n * the `WeakMap.set` plus the snapshot allocation measured ~35% of the cost of\n * generating a key from scratch, and it is pure waste for a styles object that\n * is never seen again. Callers therefore have to opt in via `reusable`, and\n * only for an object they know outlives the render that produced it.\n *\n * `Styles` is a plain mutable object, and nothing in the public\n * `computeStyles` / `useStyles` contract asks callers to freeze it, so a hit is\n * only returned after re-reading every value the key was built from and\n * confirming none of them changed. That check is deliberately shallow: it\n * compares the same references `stableStringify` would have looked up in\n * `_stableStringifyCache`, so a memoized key is stale in exactly the cases the\n * un-memoized function was already stale in — an object-valued style mutated\n * in place — and in no others.\n */\nconst _chunkKeyCache = new WeakMap<object, Map<string, ChunkKeyEntry>>();\n\n/**\n * Is `entry` still a valid key for this chunk of `styles`?\n *\n * True only when the chunk asks for the same style keys, in the same order,\n * and every one of them still reads back the value the key was built from.\n */\nfunction isEntryFresh(\n styles: Styles,\n entry: ChunkKeyEntry,\n styleKeys: string[],\n): boolean {\n const snapshot = entry.snapshot;\n const length = styleKeys.length;\n\n if (snapshot.length !== length * 2) return false;\n\n for (let i = 0, at = 0; i < length; i++, at += 2) {\n const key = styleKeys[i];\n if (snapshot[at] !== key) return false;\n if (styles[key] !== snapshot[at + 1]) return false;\n }\n\n return true;\n}\n\n/**\n * Recursively serialize a value with sorted keys for stable output.\n * This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.\n * Uses a WeakMap cache for object values to avoid re-serializing the same references.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value !== 'object') {\n return JSON.stringify(value);\n }\n\n const cached = _stableStringifyCache.get(value as object);\n if (cached !== undefined) return cached;\n\n let result: string;\n if (Array.isArray(value)) {\n result = '[' + value.map(stableStringify).join(',') + ']';\n } else {\n const obj = value as Record<string, unknown>;\n const sortedKeys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const key of sortedKeys) {\n if (obj[key] !== undefined) {\n parts.push(`${JSON.stringify(key)}:${stableStringify(obj[key])}`);\n }\n }\n result = '{' + parts.join(',') + '}';\n }\n\n _stableStringifyCache.set(value as object, result);\n return result;\n}\n\nfunction computeChunkCacheKey(\n styles: Styles,\n chunkName: string,\n snapshot: unknown[],\n): string {\n // Start with chunk name for namespace separation\n const parts: string[] = [chunkName];\n\n // styleKeys are already sorted by categorizeStyleKeys\n let chunkStylesStr = '';\n\n // Reading from the snapshot rather than from `styles` guarantees the key and\n // the values a memo entry validates against are the same values.\n for (let at = 0; at < snapshot.length; at += 2) {\n const value = snapshot[at + 1];\n if (value !== undefined) {\n // Use stable stringify for consistent serialization regardless of key order\n const serialized = stableStringify(value);\n parts.push(`${snapshot[at] as string}:${serialized}`);\n chunkStylesStr += serialized;\n }\n }\n\n // Extract local predefined states from the full styles object\n const localStates = extractLocalPredefinedStates(styles);\n\n // Only include local predefined states that are actually referenced in this chunk\n if (Object.keys(localStates).length > 0) {\n const referencedStates = extractPredefinedStateRefs(chunkStylesStr);\n const relevantLocalStates: string[] = [];\n\n for (const stateName of referencedStates) {\n if (localStates[stateName]) {\n relevantLocalStates.push(`${stateName}=${localStates[stateName]}`);\n }\n }\n\n // Add relevant local states to the cache key (sorted for stability)\n if (relevantLocalStates.length > 0) {\n relevantLocalStates.sort();\n parts.unshift(`[states:${relevantLocalStates.join('|')}]`);\n }\n }\n\n // Use null character as separator (safe, not in JSON output)\n return parts.join('\\0');\n}\n\n/**\n * Generate a cache key for a specific chunk.\n *\n * Only includes the styles that belong to this chunk, allowing\n * chunks to be cached independently.\n *\n * Also includes relevant local predefined states that are referenced\n * by this chunk's styles.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk\n * @param styleKeys - Keys of styles belonging to this chunk\n * @param reusable - Pass `true` only when `styles` outlives this render and\n * will be keyed again — a `tasty()` factory's own styles object, for\n * instance. It stores the result so the next render can skip serializing\n * every value again, which is worth doing only if there is a next render for\n * this exact object. Freshly merged per-render objects must leave it `false`:\n * storing them costs more than the key they would never reuse. Reading an\n * existing entry does not require it.\n * @returns A stable cache key string\n */\nexport function generateChunkCacheKey(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n reusable = false,\n): string {\n let perStyles = _chunkKeyCache.get(styles as object);\n\n if (perStyles !== undefined) {\n const entry = perStyles.get(chunkName);\n if (entry !== undefined && isEntryFresh(styles, entry, styleKeys)) {\n return entry.key;\n }\n }\n\n const length = styleKeys.length;\n const snapshot: unknown[] = new Array(length * 2);\n\n for (let i = 0, at = 0; i < length; i++, at += 2) {\n const styleKey = styleKeys[i];\n snapshot[at] = styleKey;\n snapshot[at + 1] = styles[styleKey];\n }\n\n const key = computeChunkCacheKey(styles, chunkName, snapshot);\n\n if (reusable) {\n if (perStyles === undefined) {\n perStyles = new Map();\n _chunkKeyCache.set(styles as object, perStyles);\n }\n perStyles.set(chunkName, { snapshot, key });\n }\n\n return key;\n}\n","/**\n * Chunk-specific style rendering.\n *\n * Renders styles for a specific chunk by filtering the styles object\n * to only include relevant keys before passing to renderStyles.\n */\n\nimport type { RenderResult } from '../pipeline';\nimport { hasPipelineCacheEntry, renderStyles } from '../pipeline';\nimport { extractLocalPredefinedStates } from '../states';\nimport type { Styles } from '../styles/types';\n\nimport { CHUNK_NAMES } from './definitions';\n\n/**\n * Build a filtered styles object for a regular chunk.\n */\nfunction buildFilteredStyles(styles: Styles, styleKeys: string[]): Styles {\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n const filteredStyles: Styles = {};\n\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n return filteredStyles;\n}\n\n/**\n * Build a filtered styles object for the subcomponents chunk.\n */\nfunction buildSubcomponentFilteredStyles(\n styles: Styles,\n selectorKeys: string[],\n): Styles {\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n const filteredStyles: Styles = {};\n\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n for (const key of selectorKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n if (styles.$ !== undefined) {\n filteredStyles.$ = styles.$;\n }\n\n return filteredStyles;\n}\n\n/**\n * Render styles for a specific chunk.\n *\n * On pipeline cache hit, avoids building the filtered styles object entirely.\n * Only constructs it on cache miss when the pipeline actually needs the styles.\n *\n * IMPORTANT: Local predefined states (e.g., '@mobile': '@media(w < 600px)')\n * are always included in the filtered styles, regardless of which chunk is\n * being rendered. This ensures that state references like '@mobile' in any\n * chunk can be properly resolved by the pipeline.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk being rendered\n * @param styleKeys - Keys of styles belonging to this chunk\n * @returns RenderResult with rules for this chunk\n */\nexport function renderStylesForChunk(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n pipelineCacheKey?: string,\n): RenderResult {\n if (styleKeys.length === 0) {\n return { rules: [], className: '' };\n }\n\n // Fast path: skip building filteredStyles when pipeline has a cached result\n if (pipelineCacheKey && hasPipelineCacheEntry(pipelineCacheKey)) {\n return renderStyles(undefined, undefined, undefined, pipelineCacheKey);\n }\n\n // Cache miss: build filtered styles and run pipeline\n const filteredStyles =\n chunkName === CHUNK_NAMES.SUBCOMPONENTS\n ? buildSubcomponentFilteredStyles(styles, styleKeys)\n : buildFilteredStyles(styles, styleKeys);\n\n return renderStyles(filteredStyles, undefined, undefined, pipelineCacheKey);\n}\n","/**\n * Keyframes Utilities\n *\n * Optimized utilities for extracting and processing keyframes in styles.\n * Designed for zero overhead when no keyframes are used.\n */\n\nimport type { KeyframesSteps } from '../injector/types';\nimport type { Styles } from '../styles/types';\nimport { hashString } from '../utils/hash';\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst KEYFRAMES_KEY = '@keyframes';\n\n/**\n * Pattern to extract animation names from CSS animation property values.\n * Animation name is typically the first identifier in the shorthand.\n * Handles: \"fadeIn 300ms ease-in\", \"pulse 1s infinite\", etc.\n *\n * CSS animation shorthand order (all optional except name):\n * animation: name | duration | timing | delay | iteration | direction | fill-mode | play-state\n *\n * Animation names must:\n * - Start with a letter, underscore, or hyphen (but not a digit or CSS keyword)\n * - Not be CSS keywords: none, initial, inherit, unset, revert\n */\nconst CSS_KEYWORDS = new Set([\n 'none',\n 'initial',\n 'inherit',\n 'unset',\n 'revert',\n 'auto',\n 'normal',\n 'running',\n 'paused',\n]);\n\n/**\n * Pattern to match animation name at the start of an animation value.\n * Must start with letter, underscore, or hyphen (not digit).\n */\nconst ANIMATION_NAME_PATTERN = /^([a-zA-Z_-][a-zA-Z0-9_-]*)/;\n\n// ============================================================================\n// Extraction Functions\n// ============================================================================\n\n/**\n * Check if styles object has local @keyframes definition.\n * Fast path: single property lookup.\n */\nexport function hasLocalKeyframes(styles: Styles): boolean {\n return KEYFRAMES_KEY in styles;\n}\n\n/**\n * Extract local @keyframes from styles object.\n * Returns null if no local keyframes (fast path).\n */\nexport function extractLocalKeyframes(\n styles: Styles,\n): Record<string, KeyframesSteps> | null {\n const keyframes = styles[KEYFRAMES_KEY];\n if (!keyframes || typeof keyframes !== 'object') {\n return null;\n }\n return keyframes as Record<string, KeyframesSteps>;\n}\n\n/**\n * Merge local and global keyframes.\n * Local keyframes take priority over global.\n * Returns null if no keyframes exist (fast path).\n */\nexport function mergeKeyframes(\n local: Record<string, KeyframesSteps> | null,\n global: Record<string, KeyframesSteps> | null,\n): Record<string, KeyframesSteps> | null {\n if (!local && !global) return null;\n if (!local) return global;\n if (!global) return local;\n // Local overrides global\n return { ...global, ...local };\n}\n\n// ============================================================================\n// Animation Name Extraction\n// ============================================================================\n\n/**\n * Extract animation name from a single animation value.\n * Returns null if no valid name found.\n *\n * Examples:\n * - \"fadeIn 300ms ease-in\" → \"fadeIn\"\n * - \"1s pulse infinite\" → \"pulse\" (name can be anywhere)\n * - \"none\" → null (CSS keyword)\n * - \"300ms ease-in\" → null (no name, just duration/timing)\n */\nfunction extractAnimationNameFromValue(value: string): string | null {\n const trimmed = value.trim();\n if (!trimmed) return null;\n\n // Split by whitespace and find the first valid animation name\n const parts = trimmed.split(/\\s+/);\n\n for (const part of parts) {\n // Skip CSS keywords\n if (CSS_KEYWORDS.has(part.toLowerCase())) continue;\n\n // Skip time values (e.g., 300ms, 1s, 0.5s)\n if (/^-?[\\d.]+m?s$/i.test(part)) continue;\n\n // Skip iteration counts (e.g., infinite, 3)\n if (part === 'infinite' || /^\\d+$/.test(part)) continue;\n\n // Skip direction values\n if (\n ['normal', 'reverse', 'alternate', 'alternate-reverse'].includes(\n part.toLowerCase(),\n )\n )\n continue;\n\n // Skip fill-mode values\n if (['forwards', 'backwards', 'both'].includes(part.toLowerCase()))\n continue;\n\n // Skip play-state values\n if (['running', 'paused'].includes(part.toLowerCase())) continue;\n\n // Skip timing functions (ease, linear, ease-in, etc., or cubic-bezier/steps)\n if (\n /^(ease|linear|ease-in|ease-out|ease-in-out|step-start|step-end)$/i.test(\n part,\n )\n )\n continue;\n if (/^(cubic-bezier|steps)\\(/i.test(part)) continue;\n\n // Check if it looks like a valid animation name\n const match = ANIMATION_NAME_PATTERN.exec(part);\n if (match) {\n return match[1];\n }\n }\n\n return null;\n}\n\n/**\n * Extract all animation names from an animation property value.\n * Handles multiple animations separated by commas.\n *\n * Example: \"fadeIn 300ms, slideIn 500ms ease-out\" → [\"fadeIn\", \"slideIn\"]\n */\nfunction extractAnimationNamesFromAnimationValue(value: string): string[] {\n const names: string[] = [];\n\n // Split by comma for multiple animations\n const animations = value.split(',');\n\n for (const animation of animations) {\n const name = extractAnimationNameFromValue(animation);\n if (name && !names.includes(name)) {\n names.push(name);\n }\n }\n\n return names;\n}\n\n/**\n * Extract animation names from a style value (handles mappings and arrays).\n */\nfunction extractAnimationNamesFromStyleValue(\n value: unknown,\n names: Set<string>,\n): void {\n if (typeof value === 'string') {\n for (const name of extractAnimationNamesFromAnimationValue(value)) {\n names.add(name);\n }\n } else if (Array.isArray(value)) {\n // Responsive array\n for (const v of value) {\n extractAnimationNamesFromStyleValue(v, names);\n }\n } else if (value && typeof value === 'object') {\n // State mapping\n for (const v of Object.values(value)) {\n extractAnimationNamesFromStyleValue(v, names);\n }\n }\n}\n\n/**\n * Extract all animation names referenced in styles.\n * Scans 'animation' and 'animationName' properties including in state mappings.\n * Returns empty set if no animation properties found (fast path).\n */\nexport function extractAnimationNamesFromStyles(styles: Styles): Set<string> {\n const names = new Set<string>();\n\n // Check animation property\n if ('animation' in styles) {\n extractAnimationNamesFromStyleValue(styles.animation, names);\n }\n\n // Check animationName property\n if ('animationName' in styles) {\n extractAnimationNamesFromStyleValue(styles.animationName, names);\n }\n\n // Check nested selectors (sub-elements)\n for (const [key, value] of Object.entries(styles)) {\n // Skip non-selector keys and special keys\n if (key === '$' || key === KEYFRAMES_KEY) continue;\n\n // Check if it's a selector (starts with &, ., or uppercase)\n if (\n (key.startsWith('&') || key.startsWith('.') || /^[A-Z]/.test(key)) &&\n value &&\n typeof value === 'object'\n ) {\n // Recursively extract from nested styles\n const nestedNames = extractAnimationNamesFromStyles(value as Styles);\n for (const name of nestedNames) {\n names.add(name);\n }\n }\n }\n\n return names;\n}\n\n// ============================================================================\n// Name Replacement\n// ============================================================================\n\n/**\n * Replace animation names in CSS declarations with injected names.\n * Optimized to avoid regex creation - uses simple string replacement.\n *\n * @param declarations CSS declarations string\n * @param nameMap Map from original name to injected name (only contains names that differ)\n * @returns Updated declarations string\n */\n/**\n * The name a local `@keyframes` block is emitted under.\n *\n * Content-addressed, and a pure function of what was authored: the same steps\n * always produce the same name, and different steps under the same authored\n * name cannot collide. That is what lets the server and the client agree —\n * a name handed out by whichever injector happened to see the definition first\n * depends on run order, so the two would disagree on both the animation name\n * and the class that references it.\n */\nexport function resolveKeyframesName(\n authored: string,\n steps: KeyframesSteps,\n): string {\n return `${authored}-${hashString(JSON.stringify(steps))}`;\n}\n\n/**\n * The emitted name for every local `@keyframes` in `styles`, by authored name.\n * Pure — the server, the RSC pass and the client all reach the same answer.\n */\nexport function resolveKeyframesNames(\n used: Record<string, KeyframesSteps>,\n): Map<string, string> {\n const names = new Map<string, string>();\n\n for (const [authored, steps] of Object.entries(used)) {\n names.set(authored, resolveKeyframesName(authored, steps));\n }\n\n return names;\n}\n\n/**\n * Whether `declarations` names `animation` as an animation to run.\n *\n * Only `animation` and `animation-name` values count, and only whole tokens\n * within them: an animation called `crossfade` does not use keyframes called\n * `fade`. Same parsing as `replaceAnimationNames`, so the two agree on what\n * counts as a reference.\n */\nexport function referencesAnimation(\n declarations: string,\n animation: string,\n): boolean {\n if (!declarations.includes('animation')) return false;\n\n for (const part of declarations.split(';')) {\n const colonIdx = part.indexOf(':');\n if (colonIdx === -1) continue;\n\n const prop = part.slice(0, colonIdx).trim().toLowerCase();\n if (prop !== 'animation' && prop !== 'animation-name') continue;\n\n const value = part.slice(colonIdx + 1);\n if (replaceWord(value, animation, '\\u0000') !== value) return true;\n }\n\n return false;\n}\n\nexport function replaceAnimationNames(\n declarations: string,\n nameMap: Map<string, string>,\n): string {\n // Fast path: no animation properties\n if (!declarations.includes('animation')) return declarations;\n\n // Parse and replace\n const parts = declarations.split(';');\n let modified = false;\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n const colonIdx = part.indexOf(':');\n if (colonIdx === -1) continue;\n\n const prop = part.slice(0, colonIdx).trim().toLowerCase();\n\n if (prop === 'animation' || prop === 'animation-name') {\n const prefix = part.slice(0, colonIdx + 1);\n let value = part.slice(colonIdx + 1);\n\n // Replace each animation name using simple word replacement\n for (const [original, injected] of nameMap) {\n // Simple word boundary replacement without regex\n const newValue = replaceWord(value, original, injected);\n if (newValue !== value) {\n value = newValue;\n modified = true;\n }\n }\n\n parts[i] = prefix + value;\n }\n }\n\n return modified ? parts.join(';') : declarations;\n}\n\n/**\n * Replace a word in a string (word boundary aware, no regex).\n */\nfunction replaceWord(str: string, word: string, replacement: string): string {\n let result = str;\n let idx = 0;\n\n while ((idx = result.indexOf(word, idx)) !== -1) {\n // Check word boundaries\n const before = idx === 0 ? ' ' : result[idx - 1];\n const after =\n idx + word.length >= result.length ? ' ' : result[idx + word.length];\n\n const isWordBoundaryBefore = !/[a-zA-Z0-9_-]/.test(before);\n const isWordBoundaryAfter = !/[a-zA-Z0-9_-]/.test(after);\n\n if (isWordBoundaryBefore && isWordBoundaryAfter) {\n result =\n result.slice(0, idx) + replacement + result.slice(idx + word.length);\n idx += replacement.length;\n } else {\n idx += word.length;\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Filter Functions\n// ============================================================================\n\n/**\n * Filter keyframes to only those that are actually used.\n * Returns null if no keyframes are used (fast path).\n */\nexport function filterUsedKeyframes(\n keyframes: Record<string, KeyframesSteps> | null,\n usedNames: Set<string>,\n): Record<string, KeyframesSteps> | null {\n if (!keyframes || usedNames.size === 0) return null;\n\n const used: Record<string, KeyframesSteps> = {};\n let hasAny = false;\n\n for (const name of usedNames) {\n if (keyframes[name]) {\n used[name] = keyframes[name];\n hasAny = true;\n }\n }\n\n return hasAny ? used : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,MAAM,cAAiC;CACrC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;AACd;AAKwB,IAAI,IAC1B,YAAY,KAAK,MAAM,UAAU,CAAC,MAAM,KAAK,CAAC,CAChD;;;;;;;;;;AA0BA,SAAgB,oBACd,QACuB;CAEvB,MAAM,YAAsC,CAAC;CAC7C,MAAM,OAAO,OAAO,KAAK,MAAM;CAE/B,KAA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C,IAAI,CAAC,aAAa,UAAU,SAAS,GAAG,OAAO;CAE/C,MAAM,OAAuC,CAAC;CAC9C,IAAI,SAAS;CAEb,KAAK,MAAM,QAAQ,WACjB,IAAI,UAAU,OAAO;EACnB,KAAK,QAAQ,UAAU;EACvB,SAAS;CACX;CAGF,OAAO,SAAS,OAAO;AACzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as Styles } from "./index-
|
|
1
|
+
import { b as Styles } from "./index-BmogEzTo.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/merge-styles.d.ts
|
|
4
4
|
declare function mergeStyles(...objects: (Styles | undefined | null)[]): Styles;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { mergeStyles as t };
|
|
7
|
-
//# sourceMappingURL=merge-styles-
|
|
7
|
+
//# sourceMappingURL=merge-styles-BcLl1u_d.d.ts.map
|