@tenphi/tasty 0.0.0-snapshot.05c1c22

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 (314) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +629 -0
  3. package/dist/_virtual/_rolldown/runtime.js +7 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +77 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/definitions.d.ts +37 -0
  8. package/dist/chunks/definitions.js +258 -0
  9. package/dist/chunks/definitions.js.map +1 -0
  10. package/dist/chunks/index.d.ts +1 -0
  11. package/dist/chunks/renderChunk.d.ts +1 -0
  12. package/dist/chunks/renderChunk.js +59 -0
  13. package/dist/chunks/renderChunk.js.map +1 -0
  14. package/dist/config.d.ts +366 -0
  15. package/dist/config.js +503 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/core/index.d.ts +33 -0
  18. package/dist/core/index.js +26 -0
  19. package/dist/counter-style/index.js +51 -0
  20. package/dist/counter-style/index.js.map +1 -0
  21. package/dist/debug.d.ts +89 -0
  22. package/dist/debug.js +453 -0
  23. package/dist/debug.js.map +1 -0
  24. package/dist/font-face/index.js +63 -0
  25. package/dist/font-face/index.js.map +1 -0
  26. package/dist/hooks/index.d.ts +7 -0
  27. package/dist/hooks/resolve-ssr-collector.js +14 -0
  28. package/dist/hooks/resolve-ssr-collector.js.map +1 -0
  29. package/dist/hooks/useCounterStyle.d.ts +50 -0
  30. package/dist/hooks/useCounterStyle.js +46 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +43 -0
  33. package/dist/hooks/useFontFace.js +70 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +30 -0
  36. package/dist/hooks/useGlobalStyles.js +78 -0
  37. package/dist/hooks/useGlobalStyles.js.map +1 -0
  38. package/dist/hooks/useKeyframes.d.ts +56 -0
  39. package/dist/hooks/useKeyframes.js +64 -0
  40. package/dist/hooks/useKeyframes.js.map +1 -0
  41. package/dist/hooks/useProperty.d.ts +79 -0
  42. package/dist/hooks/useProperty.js +109 -0
  43. package/dist/hooks/useProperty.js.map +1 -0
  44. package/dist/hooks/useRawCSS.d.ts +53 -0
  45. package/dist/hooks/useRawCSS.js +35 -0
  46. package/dist/hooks/useRawCSS.js.map +1 -0
  47. package/dist/hooks/useStyles.d.ts +45 -0
  48. package/dist/hooks/useStyles.js +237 -0
  49. package/dist/hooks/useStyles.js.map +1 -0
  50. package/dist/index.d.ts +50 -0
  51. package/dist/index.js +35 -0
  52. package/dist/injector/index.d.ts +183 -0
  53. package/dist/injector/index.js +179 -0
  54. package/dist/injector/index.js.map +1 -0
  55. package/dist/injector/injector.d.ts +166 -0
  56. package/dist/injector/injector.js +464 -0
  57. package/dist/injector/injector.js.map +1 -0
  58. package/dist/injector/sheet-manager.d.ts +136 -0
  59. package/dist/injector/sheet-manager.js +733 -0
  60. package/dist/injector/sheet-manager.js.map +1 -0
  61. package/dist/injector/types.d.ts +204 -0
  62. package/dist/keyframes/index.js +206 -0
  63. package/dist/keyframes/index.js.map +1 -0
  64. package/dist/parser/classify.js +319 -0
  65. package/dist/parser/classify.js.map +1 -0
  66. package/dist/parser/const.js +49 -0
  67. package/dist/parser/const.js.map +1 -0
  68. package/dist/parser/lru.js +109 -0
  69. package/dist/parser/lru.js.map +1 -0
  70. package/dist/parser/parser.d.ts +25 -0
  71. package/dist/parser/parser.js +115 -0
  72. package/dist/parser/parser.js.map +1 -0
  73. package/dist/parser/tokenizer.js +69 -0
  74. package/dist/parser/tokenizer.js.map +1 -0
  75. package/dist/parser/types.d.ts +51 -0
  76. package/dist/parser/types.js +46 -0
  77. package/dist/parser/types.js.map +1 -0
  78. package/dist/pipeline/conditions.d.ts +134 -0
  79. package/dist/pipeline/conditions.js +406 -0
  80. package/dist/pipeline/conditions.js.map +1 -0
  81. package/dist/pipeline/exclusive.js +230 -0
  82. package/dist/pipeline/exclusive.js.map +1 -0
  83. package/dist/pipeline/index.d.ts +55 -0
  84. package/dist/pipeline/index.js +708 -0
  85. package/dist/pipeline/index.js.map +1 -0
  86. package/dist/pipeline/materialize.js +1103 -0
  87. package/dist/pipeline/materialize.js.map +1 -0
  88. package/dist/pipeline/parseStateKey.d.ts +15 -0
  89. package/dist/pipeline/parseStateKey.js +446 -0
  90. package/dist/pipeline/parseStateKey.js.map +1 -0
  91. package/dist/pipeline/simplify.js +515 -0
  92. package/dist/pipeline/simplify.js.map +1 -0
  93. package/dist/pipeline/warnings.js +18 -0
  94. package/dist/pipeline/warnings.js.map +1 -0
  95. package/dist/plugins/index.d.ts +2 -0
  96. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  97. package/dist/plugins/okhsl-plugin.js +97 -0
  98. package/dist/plugins/okhsl-plugin.js.map +1 -0
  99. package/dist/plugins/types.d.ts +76 -0
  100. package/dist/properties/index.js +222 -0
  101. package/dist/properties/index.js.map +1 -0
  102. package/dist/properties/property-type-resolver.d.ts +24 -0
  103. package/dist/properties/property-type-resolver.js +90 -0
  104. package/dist/properties/property-type-resolver.js.map +1 -0
  105. package/dist/ssr/astro.d.ts +29 -0
  106. package/dist/ssr/astro.js +64 -0
  107. package/dist/ssr/astro.js.map +1 -0
  108. package/dist/ssr/async-storage.d.ts +17 -0
  109. package/dist/ssr/async-storage.js +34 -0
  110. package/dist/ssr/async-storage.js.map +1 -0
  111. package/dist/ssr/collect-auto-properties.js +39 -0
  112. package/dist/ssr/collect-auto-properties.js.map +1 -0
  113. package/dist/ssr/collector.d.ts +102 -0
  114. package/dist/ssr/collector.js +226 -0
  115. package/dist/ssr/collector.js.map +1 -0
  116. package/dist/ssr/context.d.ts +8 -0
  117. package/dist/ssr/context.js +13 -0
  118. package/dist/ssr/context.js.map +1 -0
  119. package/dist/ssr/format-global-rules.js +22 -0
  120. package/dist/ssr/format-global-rules.js.map +1 -0
  121. package/dist/ssr/format-keyframes.js +69 -0
  122. package/dist/ssr/format-keyframes.js.map +1 -0
  123. package/dist/ssr/format-property.js +49 -0
  124. package/dist/ssr/format-property.js.map +1 -0
  125. package/dist/ssr/format-rules.js +73 -0
  126. package/dist/ssr/format-rules.js.map +1 -0
  127. package/dist/ssr/hydrate.d.ts +22 -0
  128. package/dist/ssr/hydrate.js +49 -0
  129. package/dist/ssr/hydrate.js.map +1 -0
  130. package/dist/ssr/index.d.ts +5 -0
  131. package/dist/ssr/index.js +11 -0
  132. package/dist/ssr/index.js.map +1 -0
  133. package/dist/ssr/next.d.ts +45 -0
  134. package/dist/ssr/next.js +69 -0
  135. package/dist/ssr/next.js.map +1 -0
  136. package/dist/ssr/ssr-collector-ref.js +12 -0
  137. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  138. package/dist/states/index.d.ts +49 -0
  139. package/dist/states/index.js +170 -0
  140. package/dist/states/index.js.map +1 -0
  141. package/dist/static/index.d.ts +5 -0
  142. package/dist/static/index.js +4 -0
  143. package/dist/static/inject.d.ts +5 -0
  144. package/dist/static/inject.js +17 -0
  145. package/dist/static/inject.js.map +1 -0
  146. package/dist/static/tastyStatic.d.ts +46 -0
  147. package/dist/static/tastyStatic.js +30 -0
  148. package/dist/static/tastyStatic.js.map +1 -0
  149. package/dist/static/types.d.ts +49 -0
  150. package/dist/static/types.js +24 -0
  151. package/dist/static/types.js.map +1 -0
  152. package/dist/styles/align.d.ts +15 -0
  153. package/dist/styles/align.js +14 -0
  154. package/dist/styles/align.js.map +1 -0
  155. package/dist/styles/border.d.ts +25 -0
  156. package/dist/styles/border.js +113 -0
  157. package/dist/styles/border.js.map +1 -0
  158. package/dist/styles/color.d.ts +14 -0
  159. package/dist/styles/color.js +26 -0
  160. package/dist/styles/color.js.map +1 -0
  161. package/dist/styles/createStyle.js +79 -0
  162. package/dist/styles/createStyle.js.map +1 -0
  163. package/dist/styles/dimension.js +96 -0
  164. package/dist/styles/dimension.js.map +1 -0
  165. package/dist/styles/display.d.ts +37 -0
  166. package/dist/styles/display.js +66 -0
  167. package/dist/styles/display.js.map +1 -0
  168. package/dist/styles/fade.d.ts +15 -0
  169. package/dist/styles/fade.js +57 -0
  170. package/dist/styles/fade.js.map +1 -0
  171. package/dist/styles/fill.d.ts +42 -0
  172. package/dist/styles/fill.js +51 -0
  173. package/dist/styles/fill.js.map +1 -0
  174. package/dist/styles/flow.d.ts +16 -0
  175. package/dist/styles/flow.js +12 -0
  176. package/dist/styles/flow.js.map +1 -0
  177. package/dist/styles/gap.d.ts +31 -0
  178. package/dist/styles/gap.js +36 -0
  179. package/dist/styles/gap.js.map +1 -0
  180. package/dist/styles/height.d.ts +17 -0
  181. package/dist/styles/height.js +19 -0
  182. package/dist/styles/height.js.map +1 -0
  183. package/dist/styles/index.d.ts +1 -0
  184. package/dist/styles/index.js +8 -0
  185. package/dist/styles/index.js.map +1 -0
  186. package/dist/styles/inset.d.ts +52 -0
  187. package/dist/styles/inset.js +149 -0
  188. package/dist/styles/inset.js.map +1 -0
  189. package/dist/styles/justify.d.ts +15 -0
  190. package/dist/styles/justify.js +14 -0
  191. package/dist/styles/justify.js.map +1 -0
  192. package/dist/styles/list.d.ts +16 -0
  193. package/dist/styles/list.js +98 -0
  194. package/dist/styles/list.js.map +1 -0
  195. package/dist/styles/margin.d.ts +24 -0
  196. package/dist/styles/margin.js +103 -0
  197. package/dist/styles/margin.js.map +1 -0
  198. package/dist/styles/outline.d.ts +29 -0
  199. package/dist/styles/outline.js +64 -0
  200. package/dist/styles/outline.js.map +1 -0
  201. package/dist/styles/padding.d.ts +24 -0
  202. package/dist/styles/padding.js +103 -0
  203. package/dist/styles/padding.js.map +1 -0
  204. package/dist/styles/predefined.d.ts +71 -0
  205. package/dist/styles/predefined.js +237 -0
  206. package/dist/styles/predefined.js.map +1 -0
  207. package/dist/styles/preset.d.ts +52 -0
  208. package/dist/styles/preset.js +126 -0
  209. package/dist/styles/preset.js.map +1 -0
  210. package/dist/styles/radius.d.ts +12 -0
  211. package/dist/styles/radius.js +71 -0
  212. package/dist/styles/radius.js.map +1 -0
  213. package/dist/styles/scrollbar.d.ts +25 -0
  214. package/dist/styles/scrollbar.js +46 -0
  215. package/dist/styles/scrollbar.js.map +1 -0
  216. package/dist/styles/shadow.d.ts +14 -0
  217. package/dist/styles/shadow.js +23 -0
  218. package/dist/styles/shadow.js.map +1 -0
  219. package/dist/styles/transition.d.ts +14 -0
  220. package/dist/styles/transition.js +157 -0
  221. package/dist/styles/transition.js.map +1 -0
  222. package/dist/styles/types.d.ts +549 -0
  223. package/dist/styles/width.d.ts +17 -0
  224. package/dist/styles/width.js +19 -0
  225. package/dist/styles/width.js.map +1 -0
  226. package/dist/tasty.d.ts +119 -0
  227. package/dist/tasty.js +231 -0
  228. package/dist/tasty.js.map +1 -0
  229. package/dist/types.d.ts +184 -0
  230. package/dist/utils/cache-wrapper.js +21 -0
  231. package/dist/utils/cache-wrapper.js.map +1 -0
  232. package/dist/utils/case-converter.js +8 -0
  233. package/dist/utils/case-converter.js.map +1 -0
  234. package/dist/utils/color-math.d.ts +46 -0
  235. package/dist/utils/color-math.js +749 -0
  236. package/dist/utils/color-math.js.map +1 -0
  237. package/dist/utils/color-space.d.ts +5 -0
  238. package/dist/utils/color-space.js +228 -0
  239. package/dist/utils/color-space.js.map +1 -0
  240. package/dist/utils/colors.d.ts +5 -0
  241. package/dist/utils/colors.js +10 -0
  242. package/dist/utils/colors.js.map +1 -0
  243. package/dist/utils/css-types.d.ts +7 -0
  244. package/dist/utils/dotize.d.ts +26 -0
  245. package/dist/utils/dotize.js +122 -0
  246. package/dist/utils/dotize.js.map +1 -0
  247. package/dist/utils/filter-base-props.d.ts +15 -0
  248. package/dist/utils/filter-base-props.js +45 -0
  249. package/dist/utils/filter-base-props.js.map +1 -0
  250. package/dist/utils/get-display-name.d.ts +7 -0
  251. package/dist/utils/get-display-name.js +10 -0
  252. package/dist/utils/get-display-name.js.map +1 -0
  253. package/dist/utils/has-keys.js +13 -0
  254. package/dist/utils/has-keys.js.map +1 -0
  255. package/dist/utils/is-dev-env.js +19 -0
  256. package/dist/utils/is-dev-env.js.map +1 -0
  257. package/dist/utils/is-valid-element-type.js +15 -0
  258. package/dist/utils/is-valid-element-type.js.map +1 -0
  259. package/dist/utils/merge-styles.d.ts +7 -0
  260. package/dist/utils/merge-styles.js +145 -0
  261. package/dist/utils/merge-styles.js.map +1 -0
  262. package/dist/utils/mod-attrs.d.ts +6 -0
  263. package/dist/utils/mod-attrs.js +20 -0
  264. package/dist/utils/mod-attrs.js.map +1 -0
  265. package/dist/utils/process-tokens.d.ts +21 -0
  266. package/dist/utils/process-tokens.js +90 -0
  267. package/dist/utils/process-tokens.js.map +1 -0
  268. package/dist/utils/resolve-recipes.d.ts +17 -0
  269. package/dist/utils/resolve-recipes.js +146 -0
  270. package/dist/utils/resolve-recipes.js.map +1 -0
  271. package/dist/utils/selector-transform.js +32 -0
  272. package/dist/utils/selector-transform.js.map +1 -0
  273. package/dist/utils/string.js +8 -0
  274. package/dist/utils/string.js.map +1 -0
  275. package/dist/utils/styles.d.ts +99 -0
  276. package/dist/utils/styles.js +220 -0
  277. package/dist/utils/styles.js.map +1 -0
  278. package/dist/utils/typography.d.ts +47 -0
  279. package/dist/utils/typography.js +51 -0
  280. package/dist/utils/typography.js.map +1 -0
  281. package/dist/utils/warnings.d.ts +16 -0
  282. package/dist/utils/warnings.js +16 -0
  283. package/dist/utils/warnings.js.map +1 -0
  284. package/dist/zero/babel.d.ts +182 -0
  285. package/dist/zero/babel.js +438 -0
  286. package/dist/zero/babel.js.map +1 -0
  287. package/dist/zero/css-writer.d.ts +45 -0
  288. package/dist/zero/css-writer.js +73 -0
  289. package/dist/zero/css-writer.js.map +1 -0
  290. package/dist/zero/extractor.d.ts +24 -0
  291. package/dist/zero/extractor.js +266 -0
  292. package/dist/zero/extractor.js.map +1 -0
  293. package/dist/zero/index.d.ts +3 -0
  294. package/dist/zero/index.js +3 -0
  295. package/dist/zero/next.d.ts +86 -0
  296. package/dist/zero/next.js +143 -0
  297. package/dist/zero/next.js.map +1 -0
  298. package/docs/PIPELINE.md +519 -0
  299. package/docs/README.md +31 -0
  300. package/docs/adoption.md +296 -0
  301. package/docs/comparison.md +420 -0
  302. package/docs/configuration.md +326 -0
  303. package/docs/debug.md +318 -0
  304. package/docs/design-system.md +424 -0
  305. package/docs/dsl.md +673 -0
  306. package/docs/getting-started.md +217 -0
  307. package/docs/injector.md +528 -0
  308. package/docs/methodology.md +567 -0
  309. package/docs/runtime.md +485 -0
  310. package/docs/ssr.md +384 -0
  311. package/docs/styles.md +582 -0
  312. package/docs/tasty-static.md +520 -0
  313. package/package.json +215 -0
  314. package/tasty.config.ts +14 -0
@@ -0,0 +1,182 @@
1
+ import { CounterStyleDescriptors, FontFaceInput, KeyframesSteps } from "../injector/types.js";
2
+ import { StyleDetails, UnitHandler } from "../parser/types.js";
3
+ import { StyleHandlerDefinition } from "../utils/styles.js";
4
+ import { ConfigTokens, RecipeStyles } from "../styles/types.js";
5
+ import { TastyPlugin } from "../plugins/types.js";
6
+ import * as _$_babel_core0 from "@babel/core";
7
+ import { PluginPass } from "@babel/core";
8
+
9
+ //#region src/zero/babel.d.ts
10
+ /**
11
+ * Build-time configuration for zero-runtime mode.
12
+ * Subset of TastyConfig that applies at build time.
13
+ */
14
+ interface TastyZeroConfig {
15
+ /**
16
+ * Global predefined states for advanced state mapping.
17
+ * Example: { '@mobile': '@media(w < 768px)', '@dark': '@root(theme=dark)' }
18
+ */
19
+ states?: Record<string, string>;
20
+ /**
21
+ * Enable development mode features: source comments in generated CSS.
22
+ * Default: false
23
+ */
24
+ devMode?: boolean;
25
+ /**
26
+ * Parser LRU cache size (default: 1000).
27
+ * Larger values improve performance for builds with many unique style values.
28
+ */
29
+ parserCacheSize?: number;
30
+ /**
31
+ * Custom units for the style parser (merged with built-in units).
32
+ * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
33
+ * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
34
+ */
35
+ units?: Record<string, string | UnitHandler>;
36
+ /**
37
+ * Custom functions for the style parser (merged with existing).
38
+ * Functions process parsed style groups and return CSS values.
39
+ * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
40
+ */
41
+ funcs?: Record<string, (groups: StyleDetails[]) => string>;
42
+ /**
43
+ * Plugins that extend tasty with custom functions, units, states, and handlers.
44
+ * Plugins are processed in order, with later plugins overriding earlier ones.
45
+ * @example
46
+ * ```ts
47
+ * import { okhslPlugin } from '@tenphi/tasty';
48
+ *
49
+ * // babel.config.js
50
+ * module.exports = {
51
+ * plugins: [
52
+ * ['@tenphi/tasty/babel-plugin', {
53
+ * config: { plugins: [okhslPlugin()] }
54
+ * }]
55
+ * ]
56
+ * };
57
+ * ```
58
+ */
59
+ plugins?: TastyPlugin[];
60
+ /**
61
+ * Global keyframes definitions for static extraction.
62
+ * Keys are animation names, values are keyframes step definitions.
63
+ * @example { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }
64
+ */
65
+ keyframes?: Record<string, KeyframesSteps>;
66
+ /**
67
+ * Global @font-face definitions for static extraction.
68
+ * Keys are font-family names, values are descriptors or arrays of descriptors.
69
+ */
70
+ fontFace?: Record<string, FontFaceInput>;
71
+ /**
72
+ * Global @counter-style definitions for static extraction.
73
+ * Keys are counter-style names, values are descriptor objects.
74
+ */
75
+ counterStyle?: Record<string, CounterStyleDescriptors>;
76
+ /**
77
+ * Custom style handlers that transform style properties into CSS declarations.
78
+ * Handlers replace built-in handlers for the same style name.
79
+ * @example
80
+ * ```ts
81
+ * handlers: {
82
+ * fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,
83
+ * elevation: ({ elevation }) => ({
84
+ * 'box-shadow': `0 ${elevation}px ${elevation * 2}px rgba(0,0,0,0.1)`,
85
+ * }),
86
+ * }
87
+ * ```
88
+ */
89
+ handlers?: Record<string, StyleHandlerDefinition>;
90
+ /**
91
+ * Design tokens injected as CSS custom properties on `:root`.
92
+ * Values are parsed through the Tasty DSL. Supports state maps.
93
+ * @example { '$gap': '4px', '#primary': { '': '#purple', '@dark': '#light-purple' } }
94
+ */
95
+ tokens?: ConfigTokens;
96
+ /**
97
+ * Predefined tokens replaced during style parsing (parse-time substitution).
98
+ * Use `$name` for custom properties and `#name` for color tokens.
99
+ * @example { $spacing: '2x', '#accent': '#purple' }
100
+ */
101
+ replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
102
+ /**
103
+ * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
104
+ * Recipe values are flat tasty styles (no sub-element keys).
105
+ * @example
106
+ * ```ts
107
+ * recipes: {
108
+ * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
109
+ * elevated: { shadow: '2x 2x 4x #shadow' },
110
+ * }
111
+ * ```
112
+ */
113
+ recipes?: Record<string, RecipeStyles>;
114
+ /**
115
+ * Automatically infer and register CSS @property declarations from values.
116
+ * @default true
117
+ */
118
+ autoPropertyTypes?: boolean;
119
+ }
120
+ interface TastyZeroBabelOptions {
121
+ /** Output path for generated CSS (default: 'tasty.css') */
122
+ output?: string;
123
+ /**
124
+ * Tasty configuration for build-time processing.
125
+ * Can be a static object or a factory function that returns fresh config.
126
+ * A factory is called on each plugin invocation, enabling hot reload
127
+ * of config values that depend on external files (e.g. theme tokens).
128
+ */
129
+ config?: TastyZeroConfig | (() => TastyZeroConfig);
130
+ /**
131
+ * Absolute path to a TypeScript/JavaScript module that default-exports
132
+ * a `TastyZeroConfig` object. The module is loaded via jiti on each
133
+ * plugin invocation, enabling hot reload when the file changes.
134
+ *
135
+ * This option is JSON-serializable and is the primary way Turbopack
136
+ * passes config to the Babel plugin (since Turbopack loader options
137
+ * must be plain primitives/objects/arrays).
138
+ *
139
+ * When both `config` and `configFile` are set, `config` takes precedence.
140
+ *
141
+ * @example '/absolute/path/to/tasty-zero.config.ts'
142
+ */
143
+ configFile?: string;
144
+ /**
145
+ * Absolute file paths whose content affects the generated CSS.
146
+ * When any of these files change, babel-loader invalidates its cache
147
+ * and re-runs the plugin with fresh config values.
148
+ *
149
+ * Typically includes theme files that define Glaze palettes or token values.
150
+ * Paths must be absolute (resolved by the Next.js wrapper).
151
+ */
152
+ configDeps?: string[];
153
+ /**
154
+ * Automatically replace `@tenphi/tasty/static` imports with an import
155
+ * of the generated CSS file. This eliminates the need for users to
156
+ * manually import the CSS in their app entry point.
157
+ *
158
+ * @default true
159
+ */
160
+ injectImport?: boolean;
161
+ /**
162
+ * Output mode for extracted CSS.
163
+ *
164
+ * - `'file'` (default): CSS is written to a single output file and
165
+ * the `@tenphi/tasty/static` import is rewritten to import that file.
166
+ * - `'inject'`: CSS is embedded inline in the JS output and injected
167
+ * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
168
+ * No CSS file is written. Each `tastyStatic` call becomes
169
+ * self-contained. Best for reusable components and extensions.
170
+ *
171
+ * When `mode` is `'inject'`, `output` and `injectImport` are ignored.
172
+ *
173
+ * @default 'file'
174
+ */
175
+ mode?: 'file' | 'inject';
176
+ }
177
+ /** Clear the shared CSSWriter cache. Exposed for testing. */
178
+ declare function clearWriterCache(): void;
179
+ declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _$_babel_core0.PluginObj<PluginPass>;
180
+ //#endregion
181
+ export { TastyZeroBabelOptions, TastyZeroConfig, clearWriterCache, _default as default };
182
+ //# sourceMappingURL=babel.d.ts.map
@@ -0,0 +1,438 @@
1
+ import { __require } from "../_virtual/_rolldown/runtime.js";
2
+ import { configure, getGlobalConfigTokens, resetConfig } from "../config.js";
3
+ import { mergeStyles } from "../utils/merge-styles.js";
4
+ import { resolveRecipes } from "../utils/resolve-recipes.js";
5
+ import { extractCounterStyleFromStyles, extractFontFaceFromStyles, extractKeyframesFromStyles, extractPropertiesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "./extractor.js";
6
+ import { CSSWriter } from "./css-writer.js";
7
+ import * as fs from "fs";
8
+ import * as path from "path";
9
+ import { declare } from "@babel/helper-plugin-utils";
10
+ import * as t from "@babel/types";
11
+ import { createJiti } from "jiti";
12
+ //#region src/zero/babel.ts
13
+ /**
14
+ * Babel plugin for zero-runtime tasty static site generation.
15
+ *
16
+ * Transforms:
17
+ * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }
18
+ * - `tastyStatic(base, styles)` → StaticStyle object with merged styles
19
+ * - `tastyStatic(selector, styles)` → removed entirely
20
+ *
21
+ * Usage:
22
+ * ```javascript
23
+ * // babel.config.js
24
+ * module.exports = {
25
+ * plugins: [
26
+ * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]
27
+ * ]
28
+ * };
29
+ * ```
30
+ */
31
+ function mtime(filePath) {
32
+ try {
33
+ return fs.statSync(filePath).mtimeMs;
34
+ } catch {
35
+ return null;
36
+ }
37
+ }
38
+ function clearRequireCacheTree(filePath) {
39
+ let resolved;
40
+ try {
41
+ resolved = __require.resolve(filePath);
42
+ } catch {
43
+ return;
44
+ }
45
+ const mod = __require.cache[resolved];
46
+ if (!mod) return;
47
+ const dir = resolved.substring(0, resolved.lastIndexOf("/"));
48
+ if (mod.children) {
49
+ for (const child of mod.children) if (child.id.startsWith(dir) && !child.id.includes("node_modules")) clearRequireCacheTree(child.id);
50
+ }
51
+ delete __require.cache[resolved];
52
+ }
53
+ const writerCache = /* @__PURE__ */ new Map();
54
+ /** Clear the shared CSSWriter cache. Exposed for testing. */
55
+ function clearWriterCache() {
56
+ writerCache.clear();
57
+ }
58
+ var babel_default = declare((api, options) => {
59
+ api.assertVersion(7);
60
+ const mode = options.mode ?? "file";
61
+ const outputPath = options.output || "tasty.css";
62
+ const resolvedOutputPath = path.resolve(outputPath);
63
+ const injectImport = options.injectImport ?? true;
64
+ if (mode === "file" && injectImport) {
65
+ const dir = path.dirname(resolvedOutputPath);
66
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
67
+ if (!fs.existsSync(resolvedOutputPath)) fs.writeFileSync(resolvedOutputPath, "/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\n");
68
+ }
69
+ const configDeps = [...options.configFile ? [options.configFile] : [], ...options.configDeps || []];
70
+ const configKey = configDeps.length > 0 ? configDeps.map(mtime).join(",") : "";
71
+ if (configDeps.length > 0) {
72
+ api.cache.using(() => configKey);
73
+ for (const dep of configDeps) try {
74
+ api.addExternalDependency(dep);
75
+ } catch {}
76
+ } else api.cache.forever();
77
+ if (configDeps.length > 0) for (const dep of configDeps) clearRequireCacheTree(dep);
78
+ const cached = writerCache.get(resolvedOutputPath);
79
+ if (!cached || cached.configKey !== configKey) {
80
+ const configOption = options.config;
81
+ let resolvedConfig;
82
+ if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
83
+ else if (options.configFile) resolvedConfig = createJiti(path.dirname(options.configFile), { moduleCache: false })(options.configFile);
84
+ else resolvedConfig = {};
85
+ const devMode = resolvedConfig.devMode ?? false;
86
+ if (cached) resetConfig();
87
+ configure(resolvedConfig);
88
+ const newWriter = new CSSWriter(outputPath, { devMode });
89
+ if (mode !== "inject") {
90
+ const tokenStyles = getGlobalConfigTokens();
91
+ if (tokenStyles && Object.keys(tokenStyles).length > 0) {
92
+ const result = extractStylesForSelector(":root", tokenStyles);
93
+ if (result.css) newWriter.add(":root:tokens", result.css);
94
+ }
95
+ }
96
+ writerCache.set(resolvedOutputPath, {
97
+ writer: newWriter,
98
+ configKey,
99
+ registry: {},
100
+ config: resolvedConfig
101
+ });
102
+ }
103
+ const entry = writerCache.get(resolvedOutputPath);
104
+ const cssWriter = entry.writer;
105
+ const globalRegistry = entry.registry;
106
+ const config = entry.config;
107
+ const devMode = config.devMode ?? false;
108
+ let tokenCSS;
109
+ if (mode === "inject") {
110
+ const tokenStyles = getGlobalConfigTokens();
111
+ if (tokenStyles && Object.keys(tokenStyles).length > 0) {
112
+ const result = extractStylesForSelector(":root", tokenStyles);
113
+ if (result.css) tokenCSS = result.css;
114
+ }
115
+ }
116
+ return {
117
+ name: "tasty-zero",
118
+ pre() {
119
+ this.staticStyleRegistry = {};
120
+ this._fileAddedCSS = false;
121
+ if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
122
+ },
123
+ visitor: {
124
+ ImportDeclaration(nodePath, state) {
125
+ const source = nodePath.node.source.value;
126
+ if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) if (mode === "inject") nodePath.replaceWith(t.importDeclaration([t.importSpecifier(t.identifier("_$i"), t.identifier("injectCSS"))], t.stringLiteral("@tenphi/tasty/static/inject")));
127
+ else if (injectImport) {
128
+ let importPath = resolvedOutputPath;
129
+ if (state.filename) {
130
+ const sourceDir = path.dirname(state.filename);
131
+ importPath = path.relative(sourceDir, resolvedOutputPath);
132
+ if (!importPath.startsWith(".")) importPath = "./" + importPath;
133
+ }
134
+ nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
135
+ } else nodePath.remove();
136
+ },
137
+ CallExpression(path, state) {
138
+ const callee = path.node.callee;
139
+ if (!t.isIdentifier(callee, { name: "tastyStatic" })) return;
140
+ state._fileAddedCSS = true;
141
+ const args = path.node.arguments;
142
+ if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
143
+ const firstArg = args[0];
144
+ if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
145
+ else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
146
+ else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
147
+ else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
148
+ },
149
+ VariableDeclarator(path, state) {
150
+ const init = path.node.init;
151
+ const id = path.node.id;
152
+ if (t.isIdentifier(id) && t.isObjectExpression(init) && isStaticStyleObject(init)) {
153
+ const variableName = id.name;
154
+ const styles = extractStylesFromStaticStyleObject(init, path);
155
+ const className = extractClassNameFromStaticStyleObject(init);
156
+ if (styles && className) {
157
+ state.staticStyleRegistry[variableName] = {
158
+ styles,
159
+ className
160
+ };
161
+ globalRegistry[variableName] = {
162
+ styles,
163
+ className
164
+ };
165
+ }
166
+ }
167
+ }
168
+ },
169
+ post() {
170
+ if (mode === "inject") {
171
+ if (this._fileAddedCSS && tokenCSS) {
172
+ const program = this.file.ast.program;
173
+ const injectCall = createInjectCallAST(":root", tokenCSS);
174
+ let insertIndex = 0;
175
+ for (let i = 0; i < program.body.length; i++) if (t.isImportDeclaration(program.body[i])) insertIndex = i + 1;
176
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
177
+ }
178
+ return;
179
+ }
180
+ if (this._fileAddedCSS && cssWriter.size > 0) cssWriter.write();
181
+ }
182
+ };
183
+ });
184
+ /**
185
+ * Check if an object expression looks like a StaticStyle object
186
+ */
187
+ function isStaticStyleObject(node) {
188
+ const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
189
+ const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
190
+ return hasClassName && hasStyles;
191
+ }
192
+ /**
193
+ * Extract styles object from a StaticStyle object expression
194
+ */
195
+ function extractStylesFromStaticStyleObject(node, path) {
196
+ for (const prop of node.properties) if (t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "styles" }) && t.isObjectExpression(prop.value)) return evaluateObjectExpression(prop.value, path);
197
+ return null;
198
+ }
199
+ /**
200
+ * Extract className from a StaticStyle object expression
201
+ */
202
+ function extractClassNameFromStaticStyleObject(node) {
203
+ for (const prop of node.properties) if (t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "className" }) && t.isStringLiteral(prop.value)) return prop.value.value;
204
+ return null;
205
+ }
206
+ /**
207
+ * Handle tastyStatic(styles) - returns StaticStyle object
208
+ */
209
+ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
210
+ const stylesArg = args[0];
211
+ if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
212
+ const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
213
+ const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
214
+ const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
215
+ const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
216
+ const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
217
+ const chunks = extractStylesWithChunks(styles);
218
+ const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
219
+ const staticStyleObject = createStaticStyleAST(className, styles);
220
+ if (mode === "inject") {
221
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
222
+ path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
223
+ } else {
224
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
225
+ path.replaceWith(staticStyleObject);
226
+ }
227
+ registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
228
+ }
229
+ /**
230
+ * Handle tastyStatic(base, styles) - extends base with additional styles
231
+ */
232
+ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
233
+ if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
234
+ const baseArg = args[0];
235
+ const stylesArg = args[1];
236
+ if (!t.isIdentifier(baseArg)) throw path.buildCodeFrameError("tastyStatic(base, styles) first argument must be an identifier");
237
+ if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(base, styles) second argument must be a static object literal");
238
+ const baseName = baseArg.name;
239
+ const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
240
+ if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
241
+ const overrideStyles = evaluateObjectExpression(stylesArg, path);
242
+ const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
243
+ const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
244
+ const properties = extractPropertiesFromStyles(mergedStyles, { autoPropertyTypes });
245
+ const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
246
+ const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
247
+ const chunks = extractStylesWithChunks(mergedStyles);
248
+ const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
249
+ const staticStyleObject = createStaticStyleAST(className, mergedStyles);
250
+ if (mode === "inject") {
251
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
252
+ path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
253
+ } else {
254
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
255
+ path.replaceWith(staticStyleObject);
256
+ }
257
+ registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
258
+ }
259
+ /**
260
+ * Handle tastyStatic(selector, styles) - removes the call entirely
261
+ */
262
+ function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
263
+ if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
264
+ const selectorArg = args[0];
265
+ const stylesArg = args[1];
266
+ if (!t.isStringLiteral(selectorArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) first argument must be a string literal");
267
+ if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) second argument must be a static object literal");
268
+ const selector = selectorArg.value;
269
+ const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
270
+ const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
271
+ const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
272
+ const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
273
+ const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
274
+ const result = extractStylesForSelector(selector, styles);
275
+ const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
276
+ if (mode === "inject") {
277
+ const cssParts = [];
278
+ for (const kf of keyframes) cssParts.push(kf.css);
279
+ for (const prop of properties) cssParts.push(prop.css);
280
+ for (const ff of fontFaces) cssParts.push(ff.css);
281
+ for (const cs of counterStyles) cssParts.push(cs.css);
282
+ cssParts.push(selectorCSS);
283
+ const injectCall = createInjectCallAST(selector, cssParts.join("\n"));
284
+ const parent = path.parentPath;
285
+ if (parent && t.isExpressionStatement(parent.node)) parent.replaceWith(t.expressionStatement(injectCall));
286
+ else path.replaceWith(injectCall);
287
+ } else {
288
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, [], nameMap, sourceFile);
289
+ cssWriter.add(selector, selectorCSS, sourceFile);
290
+ const parent = path.parentPath;
291
+ if (parent && t.isExpressionStatement(parent.node)) parent.remove();
292
+ else path.replaceWith(t.identifier("undefined"));
293
+ }
294
+ }
295
+ /**
296
+ * Collect all extracted CSS parts into a single string (for inject mode).
297
+ */
298
+ function collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap) {
299
+ const parts = [];
300
+ for (const kf of keyframes) parts.push(kf.css);
301
+ for (const prop of properties) parts.push(prop.css);
302
+ for (const ff of fontFaces) parts.push(ff.css);
303
+ for (const cs of counterStyles) parts.push(cs.css);
304
+ for (const chunk of chunks) parts.push(nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css);
305
+ return parts.join("\n");
306
+ }
307
+ /**
308
+ * Write all extracted CSS parts to a CSSWriter (for file mode).
309
+ */
310
+ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, sourceFile) {
311
+ for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
312
+ for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
313
+ for (const ff of fontFaces) cssWriter.add(ff.css, ff.css, sourceFile);
314
+ for (const cs of counterStyles) cssWriter.add(cs.css, cs.css, sourceFile);
315
+ for (const chunk of chunks) {
316
+ const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
317
+ cssWriter.add(chunk.className, css, sourceFile);
318
+ }
319
+ }
320
+ /**
321
+ * Create an `_$i(id, css)` call expression AST node for inject mode.
322
+ */
323
+ function createInjectCallAST(id, css) {
324
+ return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
325
+ }
326
+ /**
327
+ * Create a StaticStyle object AST node
328
+ */
329
+ function createStaticStyleAST(className, styles) {
330
+ return t.objectExpression([
331
+ t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
332
+ t.objectProperty(t.identifier("styles"), valueToAST(styles)),
333
+ t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
334
+ ]);
335
+ }
336
+ /**
337
+ * Register a StaticStyle in the registry if it's being assigned to a variable
338
+ */
339
+ function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
340
+ const parent = path.parentPath;
341
+ if (parent && t.isVariableDeclarator(parent.node)) {
342
+ const id = parent.node.id;
343
+ if (t.isIdentifier(id)) {
344
+ const variableName = id.name;
345
+ state.staticStyleRegistry[variableName] = {
346
+ styles,
347
+ className
348
+ };
349
+ globalRegistry[variableName] = {
350
+ styles,
351
+ className
352
+ };
353
+ }
354
+ }
355
+ }
356
+ /**
357
+ * Convert a JavaScript value to an AST node
358
+ */
359
+ function valueToAST(value) {
360
+ if (value === null) return t.nullLiteral();
361
+ if (value === void 0) return t.identifier("undefined");
362
+ if (typeof value === "string") return t.stringLiteral(value);
363
+ if (typeof value === "number") return t.numericLiteral(value);
364
+ if (typeof value === "boolean") return t.booleanLiteral(value);
365
+ if (Array.isArray(value)) return t.arrayExpression(value.map(valueToAST));
366
+ if (typeof value === "object") {
367
+ const properties = Object.entries(value).map(([key, val]) => t.objectProperty(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? t.identifier(key) : t.stringLiteral(key), valueToAST(val)));
368
+ return t.objectExpression(properties);
369
+ }
370
+ return t.identifier("undefined");
371
+ }
372
+ /**
373
+ * Evaluate an ObjectExpression to a plain JavaScript object.
374
+ * Only supports static values that can be determined at build time.
375
+ */
376
+ function evaluateObjectExpression(node, path) {
377
+ const result = {};
378
+ for (const prop of node.properties) {
379
+ if (t.isSpreadElement(prop)) throw path.buildCodeFrameError("Spread elements are not supported in tastyStatic() - styles must be fully static");
380
+ if (!t.isObjectProperty(prop)) throw path.buildCodeFrameError("Only object properties are supported in tastyStatic()");
381
+ let key;
382
+ if (t.isIdentifier(prop.key)) key = prop.key.name;
383
+ else if (t.isStringLiteral(prop.key)) key = prop.key.value;
384
+ else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
385
+ result[key] = evaluateExpression(prop.value, path);
386
+ }
387
+ return result;
388
+ }
389
+ /**
390
+ * Evaluate an expression to a JavaScript value.
391
+ */
392
+ function evaluateExpression(node, path) {
393
+ if (t.isStringLiteral(node)) return node.value;
394
+ if (t.isNumericLiteral(node)) return node.value;
395
+ if (t.isBooleanLiteral(node)) return node.value;
396
+ if (t.isNullLiteral(node)) return null;
397
+ if (t.isIdentifier(node, { name: "undefined" })) return;
398
+ if (t.isArrayExpression(node)) return node.elements.map((el) => {
399
+ if (el === null) return null;
400
+ if (t.isSpreadElement(el)) throw path.buildCodeFrameError("Spread elements are not supported in tastyStatic()");
401
+ return evaluateExpression(el, path);
402
+ });
403
+ if (t.isObjectExpression(node)) return evaluateObjectExpression(node, path);
404
+ if (t.isTemplateLiteral(node)) {
405
+ if (node.expressions.length > 0) throw path.buildCodeFrameError("Template literals with expressions are not supported in tastyStatic()");
406
+ return node.quasis.map((q) => q.value.cooked).join("");
407
+ }
408
+ if (t.isUnaryExpression(node, { operator: "-" })) {
409
+ const arg = evaluateExpression(node.argument, path);
410
+ if (typeof arg === "number") return -arg;
411
+ }
412
+ throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
413
+ }
414
+ /**
415
+ * Replace animation names in CSS string.
416
+ * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
417
+ */
418
+ function replaceAnimationNamesInCSS(css, nameMap) {
419
+ if (nameMap.size === 0) return css;
420
+ return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
421
+ let newValue = value;
422
+ for (const [original, replacement] of nameMap) {
423
+ const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
424
+ newValue = newValue.replace(pattern, replacement);
425
+ }
426
+ return `${prop}: ${newValue}`;
427
+ });
428
+ }
429
+ /**
430
+ * Escape special regex characters.
431
+ */
432
+ function escapeRegex(str) {
433
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
434
+ }
435
+ //#endregion
436
+ export { clearWriterCache, babel_default as default };
437
+
438
+ //# sourceMappingURL=babel.js.map