@tenphi/tasty 0.0.0-snapshot.26b4630 → 0.0.0-snapshot.2705ab9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/README.md +315 -159
  2. package/dist/chunks/cacheKey.js +16 -8
  3. package/dist/chunks/cacheKey.js.map +1 -1
  4. package/dist/chunks/definitions.d.ts +1 -1
  5. package/dist/chunks/definitions.js +2 -3
  6. package/dist/chunks/definitions.js.map +1 -1
  7. package/dist/chunks/renderChunk.js +31 -32
  8. package/dist/chunks/renderChunk.js.map +1 -1
  9. package/dist/config.d.ts +98 -12
  10. package/dist/config.js +134 -33
  11. package/dist/config.js.map +1 -1
  12. package/dist/core/index.d.ts +11 -10
  13. package/dist/core/index.js +8 -7
  14. package/dist/counter-style/index.js +51 -0
  15. package/dist/counter-style/index.js.map +1 -0
  16. package/dist/debug.d.ts +26 -141
  17. package/dist/debug.js +356 -635
  18. package/dist/debug.js.map +1 -1
  19. package/dist/font-face/index.js +63 -0
  20. package/dist/font-face/index.js.map +1 -0
  21. package/dist/hooks/resolve-ssr-collector.js +15 -0
  22. package/dist/hooks/resolve-ssr-collector.js.map +1 -0
  23. package/dist/hooks/useCounterStyle.d.ts +50 -0
  24. package/dist/hooks/useCounterStyle.js +47 -0
  25. package/dist/hooks/useCounterStyle.js.map +1 -0
  26. package/dist/hooks/useFontFace.d.ts +43 -0
  27. package/dist/hooks/useFontFace.js +71 -0
  28. package/dist/hooks/useFontFace.js.map +1 -0
  29. package/dist/hooks/useGlobalStyles.d.ts +3 -0
  30. package/dist/hooks/useGlobalStyles.js +24 -1
  31. package/dist/hooks/useGlobalStyles.js.map +1 -1
  32. package/dist/hooks/useKeyframes.js +14 -3
  33. package/dist/hooks/useKeyframes.js.map +1 -1
  34. package/dist/hooks/useProperty.js +32 -13
  35. package/dist/hooks/useProperty.js.map +1 -1
  36. package/dist/hooks/useRawCSS.js +9 -1
  37. package/dist/hooks/useRawCSS.js.map +1 -1
  38. package/dist/hooks/useStyles.d.ts +5 -0
  39. package/dist/hooks/useStyles.js +115 -46
  40. package/dist/hooks/useStyles.js.map +1 -1
  41. package/dist/index.d.ts +22 -11
  42. package/dist/index.js +10 -7
  43. package/dist/injector/index.d.ts +28 -2
  44. package/dist/injector/index.js +27 -1
  45. package/dist/injector/index.js.map +1 -1
  46. package/dist/injector/injector.d.ts +28 -1
  47. package/dist/injector/injector.js +93 -32
  48. package/dist/injector/injector.js.map +1 -1
  49. package/dist/injector/sheet-manager.d.ts +16 -7
  50. package/dist/injector/sheet-manager.js +31 -11
  51. package/dist/injector/sheet-manager.js.map +1 -1
  52. package/dist/injector/types.d.ts +70 -1
  53. package/dist/parser/classify.js +5 -4
  54. package/dist/parser/classify.js.map +1 -1
  55. package/dist/parser/const.js +17 -1
  56. package/dist/parser/const.js.map +1 -1
  57. package/dist/parser/parser.js +1 -1
  58. package/dist/pipeline/conditions.js +14 -8
  59. package/dist/pipeline/conditions.js.map +1 -1
  60. package/dist/pipeline/index.d.ts +3 -1
  61. package/dist/pipeline/index.js +137 -69
  62. package/dist/pipeline/index.js.map +1 -1
  63. package/dist/pipeline/materialize.js +404 -208
  64. package/dist/pipeline/materialize.js.map +1 -1
  65. package/dist/pipeline/parseStateKey.d.ts +1 -1
  66. package/dist/pipeline/parseStateKey.js +37 -20
  67. package/dist/pipeline/parseStateKey.js.map +1 -1
  68. package/dist/pipeline/simplify.js +111 -152
  69. package/dist/pipeline/simplify.js.map +1 -1
  70. package/dist/pipeline/warnings.js +18 -0
  71. package/dist/pipeline/warnings.js.map +1 -0
  72. package/dist/plugins/okhsl-plugin.js +2 -275
  73. package/dist/plugins/okhsl-plugin.js.map +1 -1
  74. package/dist/plugins/types.d.ts +9 -2
  75. package/dist/properties/index.js +82 -17
  76. package/dist/properties/index.js.map +1 -1
  77. package/dist/properties/property-type-resolver.d.ts +24 -0
  78. package/dist/properties/property-type-resolver.js +91 -0
  79. package/dist/properties/property-type-resolver.js.map +1 -0
  80. package/dist/ssr/astro.d.ts +29 -0
  81. package/dist/ssr/astro.js +65 -0
  82. package/dist/ssr/astro.js.map +1 -0
  83. package/dist/ssr/async-storage.d.ts +17 -0
  84. package/dist/ssr/async-storage.js +35 -0
  85. package/dist/ssr/async-storage.js.map +1 -0
  86. package/dist/ssr/collect-auto-properties.js +40 -0
  87. package/dist/ssr/collect-auto-properties.js.map +1 -0
  88. package/dist/ssr/collector.d.ts +102 -0
  89. package/dist/ssr/collector.js +227 -0
  90. package/dist/ssr/collector.js.map +1 -0
  91. package/dist/ssr/context.d.ts +8 -0
  92. package/dist/ssr/context.js +14 -0
  93. package/dist/ssr/context.js.map +1 -0
  94. package/dist/ssr/format-global-rules.js +22 -0
  95. package/dist/ssr/format-global-rules.js.map +1 -0
  96. package/dist/ssr/format-keyframes.js +70 -0
  97. package/dist/ssr/format-keyframes.js.map +1 -0
  98. package/dist/ssr/format-property.js +50 -0
  99. package/dist/ssr/format-property.js.map +1 -0
  100. package/dist/ssr/format-rules.js +73 -0
  101. package/dist/ssr/format-rules.js.map +1 -0
  102. package/dist/ssr/hydrate.d.ts +22 -0
  103. package/dist/ssr/hydrate.js +50 -0
  104. package/dist/ssr/hydrate.js.map +1 -0
  105. package/dist/ssr/index.d.ts +5 -0
  106. package/dist/ssr/index.js +12 -0
  107. package/dist/ssr/index.js.map +1 -0
  108. package/dist/ssr/next.d.ts +45 -0
  109. package/dist/ssr/next.js +71 -0
  110. package/dist/ssr/next.js.map +1 -0
  111. package/dist/ssr/ssr-collector-ref.js +12 -0
  112. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  113. package/dist/states/index.js +12 -257
  114. package/dist/states/index.js.map +1 -1
  115. package/dist/styles/align.d.ts +1 -1
  116. package/dist/styles/align.js.map +1 -1
  117. package/dist/styles/border.d.ts +1 -1
  118. package/dist/styles/border.js +2 -2
  119. package/dist/styles/border.js.map +1 -1
  120. package/dist/styles/color.d.ts +2 -2
  121. package/dist/styles/color.js +9 -5
  122. package/dist/styles/color.js.map +1 -1
  123. package/dist/styles/createStyle.js +25 -22
  124. package/dist/styles/createStyle.js.map +1 -1
  125. package/dist/styles/fade.d.ts +1 -1
  126. package/dist/styles/fade.js.map +1 -1
  127. package/dist/styles/fill.d.ts +14 -16
  128. package/dist/styles/fill.js +6 -5
  129. package/dist/styles/fill.js.map +1 -1
  130. package/dist/styles/flow.d.ts +3 -3
  131. package/dist/styles/flow.js.map +1 -1
  132. package/dist/styles/index.js +1 -1
  133. package/dist/styles/justify.d.ts +1 -1
  134. package/dist/styles/justify.js.map +1 -1
  135. package/dist/styles/predefined.d.ts +0 -2
  136. package/dist/styles/predefined.js +1 -4
  137. package/dist/styles/predefined.js.map +1 -1
  138. package/dist/styles/preset.d.ts +5 -0
  139. package/dist/styles/preset.js +48 -47
  140. package/dist/styles/preset.js.map +1 -1
  141. package/dist/styles/radius.d.ts +1 -1
  142. package/dist/styles/radius.js.map +1 -1
  143. package/dist/styles/scrollbar.d.ts +9 -5
  144. package/dist/styles/scrollbar.js +25 -82
  145. package/dist/styles/scrollbar.js.map +1 -1
  146. package/dist/styles/shadow.d.ts +2 -2
  147. package/dist/styles/shadow.js.map +1 -1
  148. package/dist/styles/transition.d.ts +1 -1
  149. package/dist/styles/transition.js +1 -1
  150. package/dist/styles/transition.js.map +1 -1
  151. package/dist/styles/types.d.ts +70 -21
  152. package/dist/tasty.d.ts +30 -893
  153. package/dist/tasty.js +60 -19
  154. package/dist/tasty.js.map +1 -1
  155. package/dist/types.d.ts +3 -3
  156. package/dist/utils/cache-wrapper.js +4 -8
  157. package/dist/utils/cache-wrapper.js.map +1 -1
  158. package/dist/utils/color-math.d.ts +46 -0
  159. package/dist/utils/color-math.js +749 -0
  160. package/dist/utils/color-math.js.map +1 -0
  161. package/dist/utils/color-space.d.ts +5 -0
  162. package/dist/utils/color-space.js +229 -0
  163. package/dist/utils/color-space.js.map +1 -0
  164. package/dist/utils/colors.d.ts +1 -1
  165. package/dist/utils/colors.js +3 -1
  166. package/dist/utils/colors.js.map +1 -1
  167. package/dist/utils/css-types.d.ts +1 -1
  168. package/dist/utils/dotize.d.ts +1 -1
  169. package/dist/utils/has-keys.js +13 -0
  170. package/dist/utils/has-keys.js.map +1 -0
  171. package/dist/utils/mod-attrs.js +2 -2
  172. package/dist/utils/mod-attrs.js.map +1 -1
  173. package/dist/utils/process-tokens.d.ts +3 -13
  174. package/dist/utils/process-tokens.js +18 -98
  175. package/dist/utils/process-tokens.js.map +1 -1
  176. package/dist/utils/selector-transform.js +32 -0
  177. package/dist/utils/selector-transform.js.map +1 -0
  178. package/dist/utils/string.js.map +1 -1
  179. package/dist/utils/styles.d.ts +4 -88
  180. package/dist/utils/styles.js +34 -398
  181. package/dist/utils/styles.js.map +1 -1
  182. package/dist/utils/typography.d.ts +24 -13
  183. package/dist/utils/typography.js +14 -16
  184. package/dist/utils/typography.js.map +1 -1
  185. package/dist/zero/babel.d.ts +67 -8
  186. package/dist/zero/babel.js +109 -17
  187. package/dist/zero/babel.js.map +1 -1
  188. package/dist/zero/extractor.js +118 -1
  189. package/dist/zero/extractor.js.map +1 -1
  190. package/dist/zero/next.d.ts +44 -30
  191. package/dist/zero/next.js +102 -38
  192. package/dist/zero/next.js.map +1 -1
  193. package/docs/PIPELINE.md +519 -0
  194. package/docs/README.md +31 -0
  195. package/docs/adoption.md +296 -0
  196. package/docs/comparison.md +420 -0
  197. package/docs/configuration.md +326 -0
  198. package/docs/debug.md +318 -0
  199. package/docs/design-system.md +424 -0
  200. package/docs/dsl.md +673 -0
  201. package/docs/getting-started.md +217 -0
  202. package/docs/injector.md +528 -0
  203. package/docs/methodology.md +567 -0
  204. package/docs/runtime.md +485 -0
  205. package/docs/ssr.md +384 -0
  206. package/docs/styles.md +579 -0
  207. package/docs/tasty-static.md +433 -0
  208. package/package.json +98 -28
  209. package/dist/styles/styledScrollbar.d.ts +0 -47
  210. package/dist/styles/styledScrollbar.js +0 -38
  211. package/dist/styles/styledScrollbar.js.map +0 -1
  212. package/dist/tokens/typography.d.ts +0 -19
  213. package/dist/tokens/typography.js +0 -237
  214. package/dist/tokens/typography.js.map +0 -1
  215. package/dist/utils/hsl-to-rgb.js +0 -38
  216. package/dist/utils/hsl-to-rgb.js.map +0 -1
  217. package/dist/utils/okhsl-to-rgb.js +0 -296
  218. package/dist/utils/okhsl-to-rgb.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,30 +1,34 @@
1
- import { CacheMetrics, DisposeFunction, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./injector/types.js";
1
+ import { CacheMetrics, CounterStyleDescriptors, DisposeFunction, FontFaceDescriptors, FontFaceInput, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./injector/types.js";
2
2
  import { CSSProperties } from "./utils/css-types.js";
3
3
  import { Bucket, ParserOptions, ProcessedStyle, StyleDetails, StyleDetailsPart, UnitHandler } from "./parser/types.js";
4
4
  import { StyleParser } from "./parser/parser.js";
5
- import { AtRuleContext, ParsedAdvancedState, StateParserContext, createStateParserContext, getGlobalPredefinedStates, setGlobalPredefinedStates } from "./states/index.js";
6
- import { COMPUTE_FUNC_MAP, CSSMap, CUSTOM_UNITS, ComputeModel, DIRECTIONS, ParsedColor, RawStyleHandler, STATE_OPERATORS, STATE_OPERATOR_LIST, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleMap, StylePropValue, StyleStateData, StyleStateDataList, StyleStateDataListMap, StyleStateMap, StyleValue, StyleValueStateMap, buildAtRuleContext, computeState, customFunc, extendStyles, extractStyles, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, getModSelector, getRgbValuesFromRgbaString, hexToRgb, isAdvancedStateToken, normalizeColorTokenValue, parseColor, parseStateNotation, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleStateMapToStyleStateDataList } from "./utils/styles.js";
7
- import { NoType, NotSelector, RecipeStyles, Selector, Styles, StylesInterface, StylesWithoutSelectors, SuffixForSelector, TastyNamedColors, TastyPresetNames } from "./styles/types.js";
5
+ import { getNamedColorHex, getRgbValuesFromRgbaString, hexToRgb, hslToRgbValues, strToRgb } from "./utils/color-math.js";
6
+ import { CSSMap, CUSTOM_UNITS, DIRECTIONS, ParsedColor, RawStyleHandler, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleMap, StylePropValue, StyleValue, StyleValueStateMap, customFunc, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, normalizeColorTokenValue, parseColor, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, stringifyStyles } from "./utils/styles.js";
7
+ import { ConfigTokenValue, ConfigTokens, NoType, NotSelector, RecipeStyles, Selector, Styles, StylesInterface, StylesWithoutSelectors, SuffixForSelector, TastyNamedColors, TastyPresetNames } from "./styles/types.js";
8
8
  import { ConditionNode } from "./pipeline/conditions.js";
9
+ import { AtRuleContext, ParsedAdvancedState, StateParserContext, createStateParserContext, getGlobalPredefinedStates, setGlobalPredefinedStates } from "./states/index.js";
9
10
  import { ParseStateKeyOptions, parseStateKey } from "./pipeline/parseStateKey.js";
10
11
  import { RenderResult, StyleResult, isSelector, renderStyles } from "./pipeline/index.js";
11
12
  import { SheetManager } from "./injector/sheet-manager.js";
12
13
  import { StyleInjector } from "./injector/injector.js";
14
+ import { ColorSpace } from "./utils/color-space.js";
13
15
  import { TastyPlugin, TastyPluginFactory } from "./plugins/types.js";
14
- import { TastyConfig, configure, getConfig, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig } from "./config.js";
16
+ import { TastyConfig, configure, getConfig, getGlobalCounterStyle, getGlobalFontFace, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig } from "./config.js";
15
17
  import { okhslFunc, okhslPlugin } from "./plugins/okhsl-plugin.js";
16
18
  import { CHUNK_NAMES, ChunkInfo, ChunkName, STYLE_TO_CHUNK, categorizeStyleKeys } from "./chunks/definitions.js";
17
- import { PropertyOptions, allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property } from "./injector/index.js";
18
19
  import { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, COLOR_STYLES, CONTAINER_STYLES, DIMENSION_STYLES, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, TEXT_STYLES } from "./styles/list.js";
19
20
  import { AllBaseProps, BaseProps, BasePropsWithoutChildren, BaseStyleProps, BlockInnerStyleProps, BlockOuterStyleProps, BlockStyleProps, ColorStyleProps, ContainerStyleProps, DimensionStyleProps, FlowStyleProps, GlobalStyledProps, InnerStyleProps, ModValue, Mods, OuterStyleProps, PositionStyleProps, Props, ShortGridStyles, TagName, TastyExtensionConfig, TastyThemeNames, TextStyleProps, TokenValue, Tokens } from "./types.js";
20
- import { AllBasePropsWithMods, Element, ElementsDefinition, SubElementDefinition, SubElementProps, TastyElementOptions, TastyElementProps, TastyProps, VariantMap, WithVariant, tasty } from "./tasty.js";
21
+ import { AllBasePropsWithMods, Element, ElementsDefinition, ModPropDef, ModPropsInput, ResolveModPropDef, ResolveModProps, SubElementDefinition, SubElementProps, TastyElementOptions, TastyElementProps, TastyProps, VariantMap, WithVariant, tasty } from "./tasty.js";
21
22
  import { UseStylesOptions, UseStylesResult, useStyles } from "./hooks/useStyles.js";
22
23
  import { useGlobalStyles } from "./hooks/useGlobalStyles.js";
23
24
  import { useRawCSS } from "./hooks/useRawCSS.js";
24
25
  import { useKeyframes } from "./hooks/useKeyframes.js";
25
26
  import { UsePropertyOptions, useProperty } from "./hooks/useProperty.js";
27
+ import { useFontFace } from "./hooks/useFontFace.js";
28
+ import { useCounterStyle } from "./hooks/useCounterStyle.js";
26
29
  import { getDisplayName } from "./utils/get-display-name.js";
27
30
  import { styleHandlers } from "./styles/predefined.js";
31
+ import { PropertyOptions, allocateClassName, cleanup, counterStyle, createInjector, destroy, fontFace, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, trackRef } from "./injector/index.js";
28
32
  import { filterBaseProps } from "./utils/filter-base-props.js";
29
33
  import { color } from "./utils/colors.js";
30
34
  import { _modAttrs } from "./utils/mod-attrs.js";
@@ -32,9 +36,16 @@ import { dotize } from "./utils/dotize.js";
32
36
  import { mergeStyles } from "./utils/merge-styles.js";
33
37
  import { resolveRecipes } from "./utils/resolve-recipes.js";
34
38
  import { deprecationWarning, warn } from "./utils/warnings.js";
35
- import { hslToRgbValues, processTokens, stringifyTokens } from "./utils/process-tokens.js";
36
- import { TypographyPreset } from "./tokens/typography.js";
37
- import { generateTypographyTokens } from "./utils/typography.js";
39
+ import { processTokens, stringifyTokens } from "./utils/process-tokens.js";
40
+ import { TypographyPreset, generateTypographyTokens } from "./utils/typography.js";
38
41
  import { tastyDebug } from "./debug.js";
39
42
  import "./core/index.js";
40
- export { type AllBaseProps, type AllBasePropsWithMods, AtRuleContext, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, type BaseProps, type BasePropsWithoutChildren, BaseStyleProps, BlockInnerStyleProps, BlockOuterStyleProps, BlockStyleProps, Bucket, CHUNK_NAMES, COLOR_STYLES, COMPUTE_FUNC_MAP, CONTAINER_STYLES, CSSMap, CSSProperties, CUSTOM_UNITS, CacheMetrics, ChunkInfo, ChunkName, ColorStyleProps, ComputeModel, ConditionNode, ContainerStyleProps, DIMENSION_STYLES, DIRECTIONS, DimensionStyleProps, DisposeFunction, Element, type ElementsDefinition, FLOW_STYLES, FlowStyleProps, GlobalStyledProps, INNER_STYLES, InjectResult, InnerStyleProps, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, ModValue, Mods, NoType, NotSelector, OUTER_STYLES, OuterStyleProps, POSITION_STYLES, ParseStateKeyOptions, ParsedAdvancedState, ParsedColor, ParserOptions, PositionStyleProps, ProcessedStyle, PropertyDefinition, PropertyOptions, Props, RawCSSResult, RawStyleHandler, RecipeStyles, RenderResult, RootRegistry, RuleInfo, STATE_OPERATORS, STATE_OPERATOR_LIST, STYLE_TO_CHUNK, Selector, SheetInfo, SheetManager, ShortGridStyles, StateParserContext, StyleDetails, StyleDetailsPart, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleInjector, StyleInjectorConfig, StyleMap, StyleParser, StylePropValue, StyleResult, StyleRule, StyleStateData, StyleStateDataList, StyleStateDataListMap, StyleStateMap, StyleValue, StyleValueStateMap, Styles, StylesInterface, StylesWithoutSelectors, type SubElementDefinition, type SubElementProps, SuffixForSelector, TEXT_STYLES, TagName, TastyConfig, type TastyElementOptions, type TastyElementProps, TastyExtensionConfig, TastyNamedColors, TastyPlugin, TastyPluginFactory, TastyPresetNames, type TastyProps, TastyThemeNames, TextStyleProps, TokenValue, Tokens, TypographyPreset, UnitHandler, type UsePropertyOptions, type UseStylesOptions, type UseStylesResult, type VariantMap, type WithVariant, allocateClassName, buildAtRuleContext, categorizeStyleKeys, cleanup, color, computeState, configure, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, extendStyles, extractStyles, filterBaseProps, filterMods, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getModSelector, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isAdvancedStateToken, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStateNotation, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, stringifyTokens, styleHandlers, styleStateMapToStyleStateDataList, tasty, tastyDebug, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
43
+ import { CSSProperties as CSSProperties$1 } from "react";
44
+
45
+ //#region src/index.d.ts
46
+ declare module './utils/css-types' {
47
+ interface CSSProperties extends CSSProperties$1 {}
48
+ }
49
+ //#endregion
50
+ export { type AllBaseProps, type AllBasePropsWithMods, AtRuleContext, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, type BaseProps, type BasePropsWithoutChildren, BaseStyleProps, BlockInnerStyleProps, BlockOuterStyleProps, BlockStyleProps, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CSSMap, CSSProperties, CUSTOM_UNITS, CacheMetrics, ChunkInfo, ChunkName, ColorSpace, ColorStyleProps, ConditionNode, ConfigTokenValue, ConfigTokens, ContainerStyleProps, CounterStyleDescriptors, DIMENSION_STYLES, DIRECTIONS, DimensionStyleProps, DisposeFunction, Element, type ElementsDefinition, FLOW_STYLES, FlowStyleProps, FontFaceDescriptors, FontFaceInput, GlobalStyledProps, INNER_STYLES, InjectResult, InnerStyleProps, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, type ModPropDef, type ModPropsInput, ModValue, Mods, NoType, NotSelector, OUTER_STYLES, OuterStyleProps, POSITION_STYLES, ParseStateKeyOptions, ParsedAdvancedState, ParsedColor, ParserOptions, PositionStyleProps, ProcessedStyle, PropertyDefinition, PropertyOptions, Props, RawCSSResult, RawStyleHandler, RecipeStyles, RenderResult, type ResolveModPropDef, type ResolveModProps, RootRegistry, RuleInfo, STYLE_TO_CHUNK, Selector, SheetInfo, SheetManager, ShortGridStyles, StateParserContext, StyleDetails, StyleDetailsPart, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleInjector, StyleInjectorConfig, StyleMap, StyleParser, StylePropValue, StyleResult, StyleRule, StyleValue, StyleValueStateMap, Styles, StylesInterface, StylesWithoutSelectors, type SubElementDefinition, type SubElementProps, SuffixForSelector, TEXT_STYLES, TagName, TastyConfig, type TastyElementOptions, type TastyElementProps, TastyExtensionConfig, TastyNamedColors, TastyPlugin, TastyPluginFactory, TastyPresetNames, type TastyProps, TastyThemeNames, TextStyleProps, TokenValue, Tokens, TypographyPreset, UnitHandler, type UsePropertyOptions, type UseStylesOptions, type UseStylesResult, type VariantMap, type WithVariant, allocateClassName, categorizeStyleKeys, cleanup, color, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, stringifyTokens, styleHandlers, tasty, tastyDebug, trackRef, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
51
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,25 +1,26 @@
1
+ import { getNamedColorHex, getRgbValuesFromRgbaString, hexToRgb, hslToRgbValues, strToRgb } from "./utils/color-math.js";
1
2
  import { Bucket } from "./parser/types.js";
2
3
  import { StyleParser } from "./parser/parser.js";
3
4
  import { okhslFunc, okhslPlugin } from "./plugins/okhsl-plugin.js";
4
- import { createStateParserContext, getGlobalPredefinedStates, setGlobalPredefinedStates } from "./states/index.js";
5
- import { hslToRgbValues, processTokens, stringifyTokens } from "./utils/process-tokens.js";
6
- import { COMPUTE_FUNC_MAP, CUSTOM_UNITS, DIRECTIONS, STATE_OPERATORS, STATE_OPERATOR_LIST, buildAtRuleContext, computeState, customFunc, extendStyles, extractStyles, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, getModSelector, getRgbValuesFromRgbaString, hexToRgb, isAdvancedStateToken, normalizeColorTokenValue, parseColor, parseStateNotation, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleStateMapToStyleStateDataList } from "./utils/styles.js";
5
+ import { CUSTOM_UNITS, DIRECTIONS, customFunc, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, normalizeColorTokenValue, parseColor, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, stringifyStyles } from "./utils/styles.js";
6
+ import { deprecationWarning, warn } from "./utils/warnings.js";
7
7
  import { styleHandlers } from "./styles/predefined.js";
8
8
  import { SheetManager } from "./injector/sheet-manager.js";
9
9
  import { StyleInjector } from "./injector/injector.js";
10
+ import { createStateParserContext, getGlobalPredefinedStates, setGlobalPredefinedStates } from "./states/index.js";
10
11
  import { parseStateKey } from "./pipeline/parseStateKey.js";
11
12
  import { isSelector, renderStyles } from "./pipeline/index.js";
12
- import { configure, getConfig, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig } from "./config.js";
13
+ import { configure, getConfig, getGlobalCounterStyle, getGlobalFontFace, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig } from "./config.js";
13
14
  import { CHUNK_NAMES, STYLE_TO_CHUNK, categorizeStyleKeys } from "./chunks/definitions.js";
14
15
  import { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, COLOR_STYLES, CONTAINER_STYLES, DIMENSION_STYLES, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, TEXT_STYLES } from "./styles/list.js";
15
- import { allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property } from "./injector/index.js";
16
+ import { allocateClassName, cleanup, counterStyle, createInjector, destroy, fontFace, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, trackRef } from "./injector/index.js";
16
17
  import { filterBaseProps } from "./utils/filter-base-props.js";
17
18
  import { color } from "./utils/colors.js";
18
19
  import { _modAttrs } from "./utils/mod-attrs.js";
19
20
  import { dotize } from "./utils/dotize.js";
20
21
  import { mergeStyles } from "./utils/merge-styles.js";
21
22
  import { resolveRecipes } from "./utils/resolve-recipes.js";
22
- import { deprecationWarning, warn } from "./utils/warnings.js";
23
+ import { processTokens, stringifyTokens } from "./utils/process-tokens.js";
23
24
  import { generateTypographyTokens } from "./utils/typography.js";
24
25
  import { tastyDebug } from "./debug.js";
25
26
  import { useStyles } from "./hooks/useStyles.js";
@@ -29,5 +30,7 @@ import { useGlobalStyles } from "./hooks/useGlobalStyles.js";
29
30
  import { useRawCSS } from "./hooks/useRawCSS.js";
30
31
  import { useKeyframes } from "./hooks/useKeyframes.js";
31
32
  import { useProperty } from "./hooks/useProperty.js";
33
+ import { useFontFace } from "./hooks/useFontFace.js";
34
+ import { useCounterStyle } from "./hooks/useCounterStyle.js";
32
35
 
33
- export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, Bucket, CHUNK_NAMES, COLOR_STYLES, COMPUTE_FUNC_MAP, CONTAINER_STYLES, CUSTOM_UNITS, DIMENSION_STYLES, DIRECTIONS, Element, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, STATE_OPERATORS, STATE_OPERATOR_LIST, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, allocateClassName, buildAtRuleContext, categorizeStyleKeys, cleanup, color, computeState, configure, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, extendStyles, extractStyles, filterBaseProps, filterMods, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getModSelector, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isAdvancedStateToken, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStateNotation, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, stringifyTokens, styleHandlers, styleStateMapToStyleStateDataList, tasty, tastyDebug, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
36
+ export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CUSTOM_UNITS, DIMENSION_STYLES, DIRECTIONS, Element, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, allocateClassName, categorizeStyleKeys, cleanup, color, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, stringifyTokens, styleHandlers, tasty, tastyDebug, trackRef, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
@@ -1,4 +1,4 @@
1
- import { CacheMetrics, DisposeFunction, GlobalInjectResult, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./types.js";
1
+ import { CacheMetrics, CounterStyleDescriptors, DisposeFunction, FontFaceDescriptors, FontFaceInput, GlobalInjectResult, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./types.js";
2
2
  import { StyleResult } from "../pipeline/index.js";
3
3
  import { SheetManager } from "./sheet-manager.js";
4
4
  import { StyleInjector } from "./injector.js";
@@ -13,6 +13,14 @@ declare function allocateClassName(cacheKey: string, options?: {
13
13
  className: string;
14
14
  isNewAllocation: boolean;
15
15
  };
16
+ /**
17
+ * Track a reference to an already-injected cacheKey (refCount + dispose).
18
+ * Used on cache hits (SSR hydration or runtime reuse) where the pipeline
19
+ * was skipped. Returns null if the cacheKey is not in the cache.
20
+ */
21
+ declare function trackRef(cacheKey: string, options?: {
22
+ root?: Document | ShadowRoot;
23
+ }): InjectResult | null;
16
24
  /**
17
25
  * Inject styles and return className with dispose function
18
26
  */
@@ -117,6 +125,24 @@ declare function property(name: string, options?: PropertyOptions): void;
117
125
  declare function isPropertyDefined(name: string, options?: {
118
126
  root?: Document | ShadowRoot;
119
127
  }): boolean;
128
+ /**
129
+ * Inject a CSS @font-face rule.
130
+ *
131
+ * Permanent and global — no dispose or ref-counting.
132
+ * Deduplicates by content hash (family + descriptors).
133
+ */
134
+ declare function fontFace(family: string, descriptors: FontFaceDescriptors, options?: {
135
+ root?: Document | ShadowRoot;
136
+ }): void;
137
+ /**
138
+ * Inject a CSS @counter-style rule.
139
+ *
140
+ * Permanent and global — no dispose or ref-counting.
141
+ * Deduplicates by name (first definition wins).
142
+ */
143
+ declare function counterStyle(name: string, descriptors: CounterStyleDescriptors, options?: {
144
+ root?: Document | ShadowRoot;
145
+ }): void;
120
146
  /**
121
147
  * Get CSS text from all sheets (for SSR)
122
148
  */
@@ -153,5 +179,5 @@ declare function destroy(root?: Document | ShadowRoot): void;
153
179
  */
154
180
  declare function createInjector(config?: Partial<StyleInjectorConfig>): StyleInjector;
155
181
  //#endregion
156
- export { PropertyOptions, allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property };
182
+ export { PropertyOptions, allocateClassName, cleanup, counterStyle, createInjector, destroy, fontFace, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, trackRef };
157
183
  //# sourceMappingURL=index.d.ts.map
@@ -10,6 +10,14 @@ function allocateClassName(cacheKey, options) {
10
10
  return getGlobalInjector().allocateClassName(cacheKey, options);
11
11
  }
12
12
  /**
13
+ * Track a reference to an already-injected cacheKey (refCount + dispose).
14
+ * Used on cache hits (SSR hydration or runtime reuse) where the pipeline
15
+ * was skipped. Returns null if the cacheKey is not in the cache.
16
+ */
17
+ function trackRef(cacheKey, options) {
18
+ return getGlobalInjector().trackRef(cacheKey, options);
19
+ }
20
+ /**
13
21
  * Inject styles and return className with dispose function
14
22
  */
15
23
  function inject(rules, options) {
@@ -93,6 +101,24 @@ function isPropertyDefined(name, options) {
93
101
  return getGlobalInjector().isPropertyDefined(name, options);
94
102
  }
95
103
  /**
104
+ * Inject a CSS @font-face rule.
105
+ *
106
+ * Permanent and global — no dispose or ref-counting.
107
+ * Deduplicates by content hash (family + descriptors).
108
+ */
109
+ function fontFace(family, descriptors, options) {
110
+ return getGlobalInjector().fontFace(family, descriptors, options);
111
+ }
112
+ /**
113
+ * Inject a CSS @counter-style rule.
114
+ *
115
+ * Permanent and global — no dispose or ref-counting.
116
+ * Deduplicates by name (first definition wins).
117
+ */
118
+ function counterStyle(name, descriptors, options) {
119
+ return getGlobalInjector().counterStyle(name, descriptors, options);
120
+ }
121
+ /**
96
122
  * Get CSS text from all sheets (for SSR)
97
123
  */
98
124
  function getCssText(options) {
@@ -150,5 +176,5 @@ function createInjector(config = {}) {
150
176
  }
151
177
 
152
178
  //#endregion
153
- export { allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property };
179
+ export { allocateClassName, cleanup, counterStyle, createInjector, destroy, fontFace, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, trackRef };
154
180
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/injector/index.ts"],"sourcesContent":["import {\n getConfig,\n getGlobalInjector,\n isTestEnvironment,\n markStylesGenerated,\n} from '../config';\nimport type { StyleResult } from '../pipeline';\n\nimport { StyleInjector } from './injector';\nimport type {\n GlobalInjectResult,\n InjectResult,\n KeyframesResult,\n KeyframesSteps,\n StyleInjectorConfig,\n} from './types';\n\n/**\n * Allocate a className for a cacheKey without injecting styles yet\n */\nexport function allocateClassName(\n cacheKey: string,\n options?: { root?: Document | ShadowRoot },\n): { className: string; isNewAllocation: boolean } {\n return getGlobalInjector().allocateClassName(cacheKey, options);\n}\n\n/**\n * Inject styles and return className with dispose function\n */\nexport function inject(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot; cacheKey?: string },\n): InjectResult {\n // Mark that styles have been generated (prevents configuration changes)\n markStylesGenerated();\n\n return getGlobalInjector().inject(rules, options);\n}\n\n/**\n * Inject global rules that should not reserve tasty class names\n */\nexport function injectGlobal(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot },\n): GlobalInjectResult {\n return getGlobalInjector().injectGlobal(rules, options);\n}\n\n/**\n * Inject raw CSS text directly without parsing\n * This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.\n * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.\n *\n * @example\n * ```tsx\n * // Inject raw CSS\n * const { dispose } = injectRawCSS(`\n * body { margin: 0; padding: 0; }\n * .my-class { color: red; }\n * `);\n *\n * // Later, remove the injected CSS\n * dispose();\n * ```\n */\nexport function injectRawCSS(\n css: string,\n options?: { root?: Document | ShadowRoot },\n): { dispose: () => void } {\n return getGlobalInjector().injectRawCSS(css, options);\n}\n\n/**\n * Get raw CSS text for SSR\n */\nexport function getRawCSSText(options?: {\n root?: Document | ShadowRoot;\n}): string {\n return getGlobalInjector().getRawCSSText(options);\n}\n\n/**\n * Inject keyframes and return object with toString() and dispose()\n */\nexport function keyframes(\n steps: KeyframesSteps,\n nameOrOptions?: string | { root?: Document | ShadowRoot; name?: string },\n): KeyframesResult {\n return getGlobalInjector().keyframes(steps, nameOrOptions);\n}\n\nexport interface PropertyOptions {\n /**\n * CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>')\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax\n */\n syntax?: string;\n /**\n * Whether the property inherits from parent elements\n * @default true\n */\n inherits?: boolean;\n /**\n * Initial value for the property\n */\n initialValue?: string | number;\n /**\n * Shadow root or document to inject into\n */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Define 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 * Re-registering the same property name is a no-op.\n *\n * @param name - The custom property name (must start with --)\n * @param options - Property configuration\n *\n * @example\n * ```ts\n * // Define a color property that can be animated\n * property('--my-color', {\n * syntax: '<color>',\n * initialValue: 'red',\n * });\n *\n * // Define an angle property\n * property('--rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n * ```\n */\nexport function property(name: string, options?: PropertyOptions): void {\n return getGlobalInjector().property(name, options);\n}\n\n/**\n * Check if a CSS @property has already been defined\n *\n * @param name - The custom property name to check\n * @param options - Options including root\n */\nexport function isPropertyDefined(\n name: string,\n options?: { root?: Document | ShadowRoot },\n): boolean {\n return getGlobalInjector().isPropertyDefined(name, options);\n}\n\n/**\n * Get CSS text from all sheets (for SSR)\n */\nexport function getCssText(options?: { root?: Document | ShadowRoot }): string {\n return getGlobalInjector().getCssText(options);\n}\n\n/**\n * Collect only CSS used by a rendered subtree (like jest-styled-components).\n * Pass the container returned by render(...).\n */\nexport function getCssTextForNode(\n node: ParentNode | Element | DocumentFragment,\n options?: { root?: Document | ShadowRoot },\n): string {\n // Collect tasty-generated class names (t<number>) from the subtree\n const classSet = new Set<string>();\n\n const readClasses = (el: Element) => {\n const cls = el.getAttribute('class');\n if (!cls) return;\n for (const token of cls.split(/\\s+/)) {\n if (/^t\\d+$/.test(token)) classSet.add(token);\n }\n };\n\n // Include node itself if it's an Element\n if ((node as Element).getAttribute) {\n readClasses(node as Element);\n }\n // Walk descendants\n const elements = (node as ParentNode).querySelectorAll\n ? (node as ParentNode).querySelectorAll('[class]')\n : ([] as unknown as NodeListOf<Element>);\n if (elements) elements.forEach(readClasses);\n\n return getGlobalInjector().getCssTextForClasses(classSet, options);\n}\n\n/**\n * Force cleanup of unused rules\n */\nexport function cleanup(root?: Document | ShadowRoot): void {\n return getGlobalInjector().cleanup(root);\n}\n\n/**\n * Check if we're currently running in a test environment\n */\nexport function getIsTestEnvironment(): boolean {\n return isTestEnvironment();\n}\n\n/**\n * Get the global injector instance for debugging\n */\nexport const injector = {\n get instance() {\n return getGlobalInjector();\n },\n};\n\n/**\n * Destroy all resources and clean up\n */\nexport function destroy(root?: Document | ShadowRoot): void {\n return getGlobalInjector().destroy(root);\n}\n\n/**\n * Create a new isolated injector instance\n */\nexport function createInjector(\n config: Partial<StyleInjectorConfig> = {},\n): StyleInjector {\n const defaultConfig = getConfig();\n\n const fullConfig: StyleInjectorConfig = {\n ...defaultConfig,\n // Auto-enable forceTextInjection in test environments\n forceTextInjection: config.forceTextInjection ?? isTestEnvironment(),\n ...config,\n };\n\n return new StyleInjector(fullConfig);\n}\n\n// Re-export types\nexport type {\n StyleInjectorConfig,\n InjectResult,\n DisposeFunction,\n RuleInfo,\n SheetInfo,\n RootRegistry,\n StyleRule,\n KeyframesInfo,\n KeyframesResult,\n KeyframesSteps,\n KeyframesCacheEntry,\n CacheMetrics,\n RawCSSResult,\n PropertyDefinition,\n} from './types';\n\nexport { StyleInjector } from './injector';\nexport { SheetManager } from './sheet-manager';\n"],"mappings":";;;;;;;;AAoBA,SAAgB,kBACd,UACA,SACiD;AACjD,QAAO,mBAAmB,CAAC,kBAAkB,UAAU,QAAQ;;;;;AAMjE,SAAgB,OACd,OACA,SACc;AAEd,sBAAqB;AAErB,QAAO,mBAAmB,CAAC,OAAO,OAAO,QAAQ;;;;;AAMnD,SAAgB,aACd,OACA,SACoB;AACpB,QAAO,mBAAmB,CAAC,aAAa,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;AAoBzD,SAAgB,aACd,KACA,SACyB;AACzB,QAAO,mBAAmB,CAAC,aAAa,KAAK,QAAQ;;;;;AAMvD,SAAgB,cAAc,SAEnB;AACT,QAAO,mBAAmB,CAAC,cAAc,QAAQ;;;;;AAMnD,SAAgB,UACd,OACA,eACiB;AACjB,QAAO,mBAAmB,CAAC,UAAU,OAAO,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkD5D,SAAgB,SAAS,MAAc,SAAiC;AACtE,QAAO,mBAAmB,CAAC,SAAS,MAAM,QAAQ;;;;;;;;AASpD,SAAgB,kBACd,MACA,SACS;AACT,QAAO,mBAAmB,CAAC,kBAAkB,MAAM,QAAQ;;;;;AAM7D,SAAgB,WAAW,SAAoD;AAC7E,QAAO,mBAAmB,CAAC,WAAW,QAAQ;;;;;;AAOhD,SAAgB,kBACd,MACA,SACQ;CAER,MAAM,2BAAW,IAAI,KAAa;CAElC,MAAM,eAAe,OAAgB;EACnC,MAAM,MAAM,GAAG,aAAa,QAAQ;AACpC,MAAI,CAAC,IAAK;AACV,OAAK,MAAM,SAAS,IAAI,MAAM,MAAM,CAClC,KAAI,SAAS,KAAK,MAAM,CAAE,UAAS,IAAI,MAAM;;AAKjD,KAAK,KAAiB,aACpB,aAAY,KAAgB;CAG9B,MAAM,WAAY,KAAoB,mBACjC,KAAoB,iBAAiB,UAAU,GAC/C,EAAE;AACP,KAAI,SAAU,UAAS,QAAQ,YAAY;AAE3C,QAAO,mBAAmB,CAAC,qBAAqB,UAAU,QAAQ;;;;;AAMpE,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,uBAAgC;AAC9C,QAAO,mBAAmB;;;;;AAM5B,MAAa,WAAW,EACtB,IAAI,WAAW;AACb,QAAO,mBAAmB;GAE7B;;;;AAKD,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,eACd,SAAuC,EAAE,EAC1B;AAUf,QAAO,IAAI,cAP6B;EACtC,GAHoB,WAAW;EAK/B,oBAAoB,OAAO,sBAAsB,mBAAmB;EACpE,GAAG;EACJ,CAEmC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/injector/index.ts"],"sourcesContent":["import {\n getConfig,\n getGlobalInjector,\n isTestEnvironment,\n markStylesGenerated,\n} from '../config';\nimport type { StyleResult } from '../pipeline';\n\nimport { StyleInjector } from './injector';\nimport type {\n CounterStyleDescriptors,\n FontFaceDescriptors,\n GlobalInjectResult,\n InjectResult,\n KeyframesResult,\n KeyframesSteps,\n StyleInjectorConfig,\n} from './types';\n\n/**\n * Allocate a className for a cacheKey without injecting styles yet\n */\nexport function allocateClassName(\n cacheKey: string,\n options?: { root?: Document | ShadowRoot },\n): { className: string; isNewAllocation: boolean } {\n return getGlobalInjector().allocateClassName(cacheKey, options);\n}\n\n/**\n * Track a reference to an already-injected cacheKey (refCount + dispose).\n * Used on cache hits (SSR hydration or runtime reuse) where the pipeline\n * was skipped. Returns null if the cacheKey is not in the cache.\n */\nexport function trackRef(\n cacheKey: string,\n options?: { root?: Document | ShadowRoot },\n): InjectResult | null {\n return getGlobalInjector().trackRef(cacheKey, options);\n}\n\n/**\n * Inject styles and return className with dispose function\n */\nexport function inject(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot; cacheKey?: string },\n): InjectResult {\n // Mark that styles have been generated (prevents configuration changes)\n markStylesGenerated();\n\n return getGlobalInjector().inject(rules, options);\n}\n\n/**\n * Inject global rules that should not reserve tasty class names\n */\nexport function injectGlobal(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot },\n): GlobalInjectResult {\n return getGlobalInjector().injectGlobal(rules, options);\n}\n\n/**\n * Inject raw CSS text directly without parsing\n * This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.\n * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.\n *\n * @example\n * ```tsx\n * // Inject raw CSS\n * const { dispose } = injectRawCSS(`\n * body { margin: 0; padding: 0; }\n * .my-class { color: red; }\n * `);\n *\n * // Later, remove the injected CSS\n * dispose();\n * ```\n */\nexport function injectRawCSS(\n css: string,\n options?: { root?: Document | ShadowRoot },\n): { dispose: () => void } {\n return getGlobalInjector().injectRawCSS(css, options);\n}\n\n/**\n * Get raw CSS text for SSR\n */\nexport function getRawCSSText(options?: {\n root?: Document | ShadowRoot;\n}): string {\n return getGlobalInjector().getRawCSSText(options);\n}\n\n/**\n * Inject keyframes and return object with toString() and dispose()\n */\nexport function keyframes(\n steps: KeyframesSteps,\n nameOrOptions?: string | { root?: Document | ShadowRoot; name?: string },\n): KeyframesResult {\n return getGlobalInjector().keyframes(steps, nameOrOptions);\n}\n\nexport interface PropertyOptions {\n /**\n * CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>')\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax\n */\n syntax?: string;\n /**\n * Whether the property inherits from parent elements\n * @default true\n */\n inherits?: boolean;\n /**\n * Initial value for the property\n */\n initialValue?: string | number;\n /**\n * Shadow root or document to inject into\n */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Define 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 * Re-registering the same property name is a no-op.\n *\n * @param name - The custom property name (must start with --)\n * @param options - Property configuration\n *\n * @example\n * ```ts\n * // Define a color property that can be animated\n * property('--my-color', {\n * syntax: '<color>',\n * initialValue: 'red',\n * });\n *\n * // Define an angle property\n * property('--rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n * ```\n */\nexport function property(name: string, options?: PropertyOptions): void {\n return getGlobalInjector().property(name, options);\n}\n\n/**\n * Check if a CSS @property has already been defined\n *\n * @param name - The custom property name to check\n * @param options - Options including root\n */\nexport function isPropertyDefined(\n name: string,\n options?: { root?: Document | ShadowRoot },\n): boolean {\n return getGlobalInjector().isPropertyDefined(name, options);\n}\n\n/**\n * Inject a CSS @font-face rule.\n *\n * Permanent and global — no dispose or ref-counting.\n * Deduplicates by content hash (family + descriptors).\n */\nexport function fontFace(\n family: string,\n descriptors: FontFaceDescriptors,\n options?: { root?: Document | ShadowRoot },\n): void {\n return getGlobalInjector().fontFace(family, descriptors, options);\n}\n\n/**\n * Inject a CSS @counter-style rule.\n *\n * Permanent and global — no dispose or ref-counting.\n * Deduplicates by name (first definition wins).\n */\nexport function counterStyle(\n name: string,\n descriptors: CounterStyleDescriptors,\n options?: { root?: Document | ShadowRoot },\n): void {\n return getGlobalInjector().counterStyle(name, descriptors, options);\n}\n\n/**\n * Get CSS text from all sheets (for SSR)\n */\nexport function getCssText(options?: { root?: Document | ShadowRoot }): string {\n return getGlobalInjector().getCssText(options);\n}\n\n/**\n * Collect only CSS used by a rendered subtree (like jest-styled-components).\n * Pass the container returned by render(...).\n */\nexport function getCssTextForNode(\n node: ParentNode | Element | DocumentFragment,\n options?: { root?: Document | ShadowRoot },\n): string {\n // Collect tasty-generated class names (t<number>) from the subtree\n const classSet = new Set<string>();\n\n const readClasses = (el: Element) => {\n const cls = el.getAttribute('class');\n if (!cls) return;\n for (const token of cls.split(/\\s+/)) {\n if (/^t\\d+$/.test(token)) classSet.add(token);\n }\n };\n\n // Include node itself if it's an Element\n if ((node as Element).getAttribute) {\n readClasses(node as Element);\n }\n // Walk descendants\n const elements = (node as ParentNode).querySelectorAll\n ? (node as ParentNode).querySelectorAll('[class]')\n : ([] as unknown as NodeListOf<Element>);\n if (elements) elements.forEach(readClasses);\n\n return getGlobalInjector().getCssTextForClasses(classSet, options);\n}\n\n/**\n * Force cleanup of unused rules\n */\nexport function cleanup(root?: Document | ShadowRoot): void {\n return getGlobalInjector().cleanup(root);\n}\n\n/**\n * Check if we're currently running in a test environment\n */\nexport function getIsTestEnvironment(): boolean {\n return isTestEnvironment();\n}\n\n/**\n * Get the global injector instance for debugging\n */\nexport const injector = {\n get instance() {\n return getGlobalInjector();\n },\n};\n\n/**\n * Destroy all resources and clean up\n */\nexport function destroy(root?: Document | ShadowRoot): void {\n return getGlobalInjector().destroy(root);\n}\n\n/**\n * Create a new isolated injector instance\n */\nexport function createInjector(\n config: Partial<StyleInjectorConfig> = {},\n): StyleInjector {\n const defaultConfig = getConfig();\n\n const fullConfig: StyleInjectorConfig = {\n ...defaultConfig,\n // Auto-enable forceTextInjection in test environments\n forceTextInjection: config.forceTextInjection ?? isTestEnvironment(),\n ...config,\n };\n\n return new StyleInjector(fullConfig);\n}\n\n// Re-export types\nexport type {\n StyleInjectorConfig,\n InjectResult,\n DisposeFunction,\n RuleInfo,\n SheetInfo,\n RootRegistry,\n StyleRule,\n KeyframesInfo,\n KeyframesResult,\n KeyframesSteps,\n KeyframesCacheEntry,\n CacheMetrics,\n RawCSSResult,\n PropertyDefinition,\n FontFaceDescriptors,\n FontFaceInput,\n CounterStyleDescriptors,\n} from './types';\n\nexport { StyleInjector } from './injector';\nexport { SheetManager } from './sheet-manager';\n"],"mappings":";;;;;;;;AAsBA,SAAgB,kBACd,UACA,SACiD;AACjD,QAAO,mBAAmB,CAAC,kBAAkB,UAAU,QAAQ;;;;;;;AAQjE,SAAgB,SACd,UACA,SACqB;AACrB,QAAO,mBAAmB,CAAC,SAAS,UAAU,QAAQ;;;;;AAMxD,SAAgB,OACd,OACA,SACc;AAEd,sBAAqB;AAErB,QAAO,mBAAmB,CAAC,OAAO,OAAO,QAAQ;;;;;AAMnD,SAAgB,aACd,OACA,SACoB;AACpB,QAAO,mBAAmB,CAAC,aAAa,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;AAoBzD,SAAgB,aACd,KACA,SACyB;AACzB,QAAO,mBAAmB,CAAC,aAAa,KAAK,QAAQ;;;;;AAMvD,SAAgB,cAAc,SAEnB;AACT,QAAO,mBAAmB,CAAC,cAAc,QAAQ;;;;;AAMnD,SAAgB,UACd,OACA,eACiB;AACjB,QAAO,mBAAmB,CAAC,UAAU,OAAO,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkD5D,SAAgB,SAAS,MAAc,SAAiC;AACtE,QAAO,mBAAmB,CAAC,SAAS,MAAM,QAAQ;;;;;;;;AASpD,SAAgB,kBACd,MACA,SACS;AACT,QAAO,mBAAmB,CAAC,kBAAkB,MAAM,QAAQ;;;;;;;;AAS7D,SAAgB,SACd,QACA,aACA,SACM;AACN,QAAO,mBAAmB,CAAC,SAAS,QAAQ,aAAa,QAAQ;;;;;;;;AASnE,SAAgB,aACd,MACA,aACA,SACM;AACN,QAAO,mBAAmB,CAAC,aAAa,MAAM,aAAa,QAAQ;;;;;AAMrE,SAAgB,WAAW,SAAoD;AAC7E,QAAO,mBAAmB,CAAC,WAAW,QAAQ;;;;;;AAOhD,SAAgB,kBACd,MACA,SACQ;CAER,MAAM,2BAAW,IAAI,KAAa;CAElC,MAAM,eAAe,OAAgB;EACnC,MAAM,MAAM,GAAG,aAAa,QAAQ;AACpC,MAAI,CAAC,IAAK;AACV,OAAK,MAAM,SAAS,IAAI,MAAM,MAAM,CAClC,KAAI,SAAS,KAAK,MAAM,CAAE,UAAS,IAAI,MAAM;;AAKjD,KAAK,KAAiB,aACpB,aAAY,KAAgB;CAG9B,MAAM,WAAY,KAAoB,mBACjC,KAAoB,iBAAiB,UAAU,GAC/C,EAAE;AACP,KAAI,SAAU,UAAS,QAAQ,YAAY;AAE3C,QAAO,mBAAmB,CAAC,qBAAqB,UAAU,QAAQ;;;;;AAMpE,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,uBAAgC;AAC9C,QAAO,mBAAmB;;;;;AAM5B,MAAa,WAAW,EACtB,IAAI,WAAW;AACb,QAAO,mBAAmB;GAE7B;;;;AAKD,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,eACd,SAAuC,EAAE,EAC1B;AAUf,QAAO,IAAI,cAP6B;EACtC,GAHoB,WAAW;EAK/B,oBAAoB,OAAO,sBAAsB,mBAAmB;EACpE,GAAG;EACJ,CAEmC"}
@@ -1,4 +1,4 @@
1
- import { CacheMetrics, GlobalInjectResult, InjectResult, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, StyleInjectorConfig } from "./types.js";
1
+ import { CacheMetrics, CounterStyleDescriptors, FontFaceDescriptors, GlobalInjectResult, InjectResult, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, StyleInjectorConfig } from "./types.js";
2
2
  import { StyleResult } from "../pipeline/index.js";
3
3
  import { SheetManager } from "./sheet-manager.js";
4
4
 
@@ -50,6 +50,15 @@ declare class StyleInjector {
50
50
  getRawCSSText(options?: {
51
51
  root?: Document | ShadowRoot;
52
52
  }): string;
53
+ /**
54
+ * Increment refCount for an already-injected cacheKey and return a dispose.
55
+ * Used by useStyles on cache hits (hydration or runtime reuse) where
56
+ * the pipeline was skipped but refCount tracking is still needed.
57
+ * Returns null if the cacheKey is not found.
58
+ */
59
+ trackRef(cacheKey: string, options?: {
60
+ root?: Document | ShadowRoot;
61
+ }): InjectResult | null;
53
62
  /**
54
63
  * Dispose of a className
55
64
  */
@@ -112,6 +121,24 @@ declare class StyleInjector {
112
121
  isPropertyDefined(name: string, options?: {
113
122
  root?: Document | ShadowRoot;
114
123
  }): boolean;
124
+ /**
125
+ * Inject a CSS @font-face rule.
126
+ *
127
+ * Permanent and global — no dispose or ref-counting.
128
+ * Deduplicates by content hash (family + descriptors).
129
+ */
130
+ fontFace(family: string, descriptors: FontFaceDescriptors, options?: {
131
+ root?: Document | ShadowRoot;
132
+ }): void;
133
+ /**
134
+ * Inject a CSS @counter-style rule.
135
+ *
136
+ * Permanent and global — no dispose or ref-counting.
137
+ * Deduplicates by name (first definition wins).
138
+ */
139
+ counterStyle(name: string, descriptors: CounterStyleDescriptors, options?: {
140
+ root?: Document | ShadowRoot;
141
+ }): void;
115
142
  /**
116
143
  * Inject keyframes and return object with toString() and dispose()
117
144
  *
@@ -1,7 +1,9 @@
1
+ import { getEffectiveDefinition, normalizePropertyDefinition } from "../properties/index.js";
1
2
  import { isDevEnv } from "../utils/is-dev-env.js";
2
3
  import { parseStyle } from "../utils/styles.js";
3
- import { colorInitialValueToRgb, getEffectiveDefinition, normalizePropertyDefinition } from "../properties/index.js";
4
4
  import { SheetManager } from "./sheet-manager.js";
5
+ import { fontFaceContentHash, formatFontFaceDeclarations } from "../font-face/index.js";
6
+ import { formatCounterStyleDeclarations } from "../counter-style/index.js";
5
7
 
6
8
  //#region src/injector/injector.ts
7
9
  /**
@@ -92,21 +94,19 @@ var StyleInjector = class {
92
94
  rootPrefix: void 0
93
95
  };
94
96
  });
95
- const colorPropRegex = /^\s*(--[a-z0-9-]+-color)\s*:/i;
96
- for (const rule of rulesToInsert) {
97
- if (!rule.declarations) continue;
98
- const parts = rule.declarations.split(/;+\s*/);
99
- for (const part of parts) {
100
- if (!part) continue;
101
- const match = colorPropRegex.exec(part);
102
- if (match) {
103
- const propName = match[1];
104
- if (!this.isPropertyDefined(propName, { root })) this.property(propName, {
105
- syntax: "<color>",
106
- initialValue: "transparent",
97
+ if (this.config.autoPropertyTypes !== false) {
98
+ const resolver = registry.propertyTypeResolver;
99
+ const defined = registry.injectedProperties;
100
+ for (const rule of rulesToInsert) {
101
+ if (!rule.declarations) continue;
102
+ resolver.scanDeclarations(rule.declarations, (name) => defined.has(name), (name, syntax, initialValue) => {
103
+ this.property(name, {
104
+ syntax,
105
+ inherits: true,
106
+ initialValue,
107
107
  root
108
108
  });
109
- }
109
+ });
110
110
  }
111
111
  }
112
112
  const ruleInfo = this.sheetManager.insertRule(registry, rulesToInsert, className, root);
@@ -141,6 +141,21 @@ var StyleInjector = class {
141
141
  const root = options?.root || document;
142
142
  const registry = this.sheetManager.getRegistry(root);
143
143
  if (!rules || rules.length === 0) return { dispose: () => {} };
144
+ if (this.config.autoPropertyTypes !== false) {
145
+ const resolver = registry.propertyTypeResolver;
146
+ const defined = registry.injectedProperties;
147
+ for (const rule of rules) {
148
+ if (!rule.declarations) continue;
149
+ resolver.scanDeclarations(rule.declarations, (name) => defined.has(name), (name, syntax, initialValue) => {
150
+ this.property(name, {
151
+ syntax,
152
+ inherits: true,
153
+ initialValue,
154
+ root
155
+ });
156
+ });
157
+ }
158
+ }
144
159
  const key = `global:${this.globalRuleCounter++}`;
145
160
  const info = this.sheetManager.insertGlobalRule(registry, rules, key, root);
146
161
  if (registry.metrics) registry.metrics.totalInsertions++;
@@ -165,6 +180,25 @@ var StyleInjector = class {
165
180
  return this.sheetManager.getRawCSSText(root);
166
181
  }
167
182
  /**
183
+ * Increment refCount for an already-injected cacheKey and return a dispose.
184
+ * Used by useStyles on cache hits (hydration or runtime reuse) where
185
+ * the pipeline was skipped but refCount tracking is still needed.
186
+ * Returns null if the cacheKey is not found.
187
+ */
188
+ trackRef(cacheKey, options) {
189
+ const root = options?.root || document;
190
+ const registry = this.sheetManager.getRegistry(root);
191
+ if (!registry.cacheKeyToClassName.has(cacheKey)) return null;
192
+ const className = registry.cacheKeyToClassName.get(cacheKey);
193
+ const currentRefCount = registry.refCounts.get(className) || 0;
194
+ registry.refCounts.set(className, currentRefCount + 1);
195
+ if (registry.metrics) registry.metrics.hits++;
196
+ return {
197
+ className,
198
+ dispose: () => this.dispose(className, registry)
199
+ };
200
+ }
201
+ /**
168
202
  * Dispose of a className
169
203
  */
170
204
  dispose(className, registry) {
@@ -262,13 +296,7 @@ var StyleInjector = class {
262
296
  const cssName = effectiveResult.cssName;
263
297
  const definition = effectiveResult.definition;
264
298
  const normalizedDef = normalizePropertyDefinition(definition);
265
- const existingDef = registry.injectedProperties.get(cssName);
266
- if (existingDef !== void 0) {
267
- if (existingDef !== normalizedDef) {
268
- if (isDevEnv()) console.warn(`[Tasty] @property ${cssName} was already defined with a different declaration. The new declaration will be ignored. Original: ${existingDef}, New: ${normalizedDef}`);
269
- }
270
- return;
271
- }
299
+ if (registry.injectedProperties.get(cssName) !== void 0) return;
272
300
  const parts = [];
273
301
  if (definition.syntax != null) {
274
302
  let syntax = String(definition.syntax).trim();
@@ -290,15 +318,6 @@ var StyleInjector = class {
290
318
  };
291
319
  if (!this.sheetManager.insertGlobalRule(registry, [rule], `property:${name}`, root)) return;
292
320
  registry.injectedProperties.set(cssName, normalizedDef);
293
- if (effectiveResult.isColor) {
294
- const rgbCssName = `${cssName}-rgb`;
295
- if (!this.isPropertyDefined(rgbCssName, { root })) this.property(rgbCssName, {
296
- syntax: "<number>+",
297
- inherits: definition.inherits,
298
- initialValue: colorInitialValueToRgb(definition.initialValue),
299
- root
300
- });
301
- }
302
321
  }
303
322
  /**
304
323
  * Check whether a given @property name was already injected by this injector.
@@ -316,6 +335,39 @@ var StyleInjector = class {
316
335
  return registry.injectedProperties.has(effectiveResult.cssName);
317
336
  }
318
337
  /**
338
+ * Inject a CSS @font-face rule.
339
+ *
340
+ * Permanent and global — no dispose or ref-counting.
341
+ * Deduplicates by content hash (family + descriptors).
342
+ */
343
+ fontFace(family, descriptors, options) {
344
+ const root = options?.root || document;
345
+ const registry = this.sheetManager.getRegistry(root);
346
+ const hash = fontFaceContentHash(family, descriptors);
347
+ if (registry.injectedFontFaces.has(hash)) return;
348
+ const rule = {
349
+ selector: "@font-face",
350
+ declarations: formatFontFaceDeclarations(family, descriptors)
351
+ };
352
+ if (this.sheetManager.insertGlobalRule(registry, [rule], `fontface:${hash}`, root)) registry.injectedFontFaces.add(hash);
353
+ }
354
+ /**
355
+ * Inject a CSS @counter-style rule.
356
+ *
357
+ * Permanent and global — no dispose or ref-counting.
358
+ * Deduplicates by name (first definition wins).
359
+ */
360
+ counterStyle(name, descriptors, options) {
361
+ const root = options?.root || document;
362
+ const registry = this.sheetManager.getRegistry(root);
363
+ if (registry.injectedCounterStyles.has(name)) return;
364
+ const rule = {
365
+ selector: `@counter-style ${name}`,
366
+ declarations: formatCounterStyleDeclarations(descriptors)
367
+ };
368
+ if (this.sheetManager.insertGlobalRule(registry, [rule], `counterstyle:${name}`, root)) registry.injectedCounterStyles.add(name);
369
+ }
370
+ /**
319
371
  * Inject keyframes and return object with toString() and dispose()
320
372
  *
321
373
  * Keyframes are cached by content (steps). If the same content is injected
@@ -351,11 +403,20 @@ var StyleInjector = class {
351
403
  registry.keyframesNameToContent.set(providedName, contentHash);
352
404
  }
353
405
  } else actualName = `k${registry.keyframesCounter++}`;
354
- const info = this.sheetManager.insertKeyframes(registry, steps, actualName, root);
355
- if (!info) return {
406
+ const result = this.sheetManager.insertKeyframes(registry, steps, actualName, root);
407
+ if (!result) return {
356
408
  toString: () => "",
357
409
  dispose: () => {}
358
410
  };
411
+ const { info, declarations } = result;
412
+ if (this.config.autoPropertyTypes !== false && declarations) registry.propertyTypeResolver.scanDeclarations(declarations, (name) => registry.injectedProperties.has(name), (name, syntax, initialValue) => {
413
+ this.property(name, {
414
+ syntax,
415
+ inherits: true,
416
+ initialValue,
417
+ root
418
+ });
419
+ });
359
420
  registry.keyframesCache.set(contentHash, {
360
421
  name: actualName,
361
422
  refCount: 1,