@tenphi/tasty 0.0.0-snapshot.fafcbfe → 0.0.0-snapshot.fc19da9

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 (330) hide show
  1. package/README.md +497 -266
  2. package/dist/babel-types-DpUCD2L_.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-BDLYGmKn.js +60 -0
  6. package/dist/chunks/build-config-BDLYGmKn.js.map +1 -0
  7. package/dist/chunks/collector-DqcB0UUT.js +210 -0
  8. package/dist/chunks/collector-DqcB0UUT.js.map +1 -0
  9. package/dist/chunks/config-engine-CGIMO2PV.js +272 -0
  10. package/dist/chunks/config-engine-CGIMO2PV.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-BibU6ZnP.js +904 -0
  14. package/dist/chunks/css-definitions-BibU6ZnP.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-BzYPQ0H2.js +502 -0
  18. package/dist/chunks/debug-BzYPQ0H2.js.map +1 -0
  19. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  20. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-B2e-Wha-.js +689 -0
  24. package/dist/chunks/react-runtime-B2e-Wha-.js.map +1 -0
  25. package/dist/chunks/runtime-engine-yeyCAx2e.js +2431 -0
  26. package/dist/chunks/runtime-engine-yeyCAx2e.js.map +1 -0
  27. package/dist/chunks/runtime-state-C0u1jp-Q.js +141 -0
  28. package/dist/chunks/runtime-state-C0u1jp-Q.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D35rvcdB.js +5420 -0
  32. package/dist/chunks/style-engine-D35rvcdB.js.map +1 -0
  33. package/dist/chunks/zero-engine-DpkieEPZ.js +310 -0
  34. package/dist/chunks/zero-engine-DpkieEPZ.js.map +1 -0
  35. package/dist/collector-D4POJ53X.d.ts +164 -0
  36. package/dist/config-DvPUj4cw.d.ts +1364 -0
  37. package/dist/core/index.d.ts +5 -33
  38. package/dist/core/index.js +9 -26
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DC4q-xDq.d.ts +1946 -0
  41. package/dist/index.d.ts +5 -40
  42. package/dist/index.js +11 -33
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-Jb5iZ-Jf.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -0
  45. package/dist/ssr/astro-client.js +6 -0
  46. package/dist/ssr/astro-client.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +18 -0
  57. package/dist/ssr/astro-middleware.js +7 -0
  58. package/dist/ssr/astro-middleware.js.map +1 -0
  59. package/dist/ssr/astro.d.ts +127 -0
  60. package/dist/ssr/astro.js +221 -0
  61. package/dist/ssr/astro.js.map +1 -0
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -0
  65. package/dist/ssr/index.js +10 -0
  66. package/dist/ssr/index.js.map +1 -0
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +46 -0
  71. package/dist/ssr/next.js +60 -0
  72. package/dist/ssr/next.js.map +1 -0
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -4
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +4 -0
  77. package/dist/static/inject.js +17 -0
  78. package/dist/static/inject.js.map +1 -0
  79. package/dist/types-ZbF2_6LV.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +49 -90
  81. package/dist/zero/babel.js +252 -119
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +117 -3
  84. package/dist/zero/index.js +23 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +58 -33
  87. package/dist/zero/next.js +89 -59
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +42 -0
  90. package/docs/adoption.md +331 -0
  91. package/docs/ai-agents.md +252 -0
  92. package/docs/comparison.md +449 -0
  93. package/docs/configuration.md +943 -0
  94. package/docs/debug.md +333 -0
  95. package/docs/design-system.md +557 -0
  96. package/docs/dsl.md +1093 -0
  97. package/docs/getting-started.md +297 -0
  98. package/docs/injector.md +633 -0
  99. package/docs/methodology.md +673 -0
  100. package/docs/migration-v3.md +285 -0
  101. package/docs/pipeline.md +768 -0
  102. package/docs/plugins.md +333 -0
  103. package/docs/react-api.md +703 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +630 -0
  106. package/docs/styles.md +725 -0
  107. package/docs/tasty-static.md +659 -0
  108. package/package.json +238 -50
  109. package/tasty.config.ts +6 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -70
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -260
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -61
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -280
  119. package/dist/config.js +0 -403
  120. package/dist/config.js.map +0 -1
  121. package/dist/debug.d.ts +0 -204
  122. package/dist/debug.js +0 -733
  123. package/dist/debug.js.map +0 -1
  124. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  125. package/dist/hooks/useGlobalStyles.js +0 -56
  126. package/dist/hooks/useGlobalStyles.js.map +0 -1
  127. package/dist/hooks/useKeyframes.d.ts +0 -56
  128. package/dist/hooks/useKeyframes.js +0 -54
  129. package/dist/hooks/useKeyframes.js.map +0 -1
  130. package/dist/hooks/useProperty.d.ts +0 -79
  131. package/dist/hooks/useProperty.js +0 -91
  132. package/dist/hooks/useProperty.js.map +0 -1
  133. package/dist/hooks/useRawCSS.d.ts +0 -53
  134. package/dist/hooks/useRawCSS.js +0 -28
  135. package/dist/hooks/useRawCSS.js.map +0 -1
  136. package/dist/hooks/useStyles.d.ts +0 -40
  137. package/dist/hooks/useStyles.js +0 -169
  138. package/dist/hooks/useStyles.js.map +0 -1
  139. package/dist/injector/index.d.ts +0 -157
  140. package/dist/injector/index.js +0 -154
  141. package/dist/injector/index.js.map +0 -1
  142. package/dist/injector/injector.d.ts +0 -139
  143. package/dist/injector/injector.js +0 -404
  144. package/dist/injector/injector.js.map +0 -1
  145. package/dist/injector/sheet-manager.d.ts +0 -127
  146. package/dist/injector/sheet-manager.js +0 -714
  147. package/dist/injector/sheet-manager.js.map +0 -1
  148. package/dist/injector/types.d.ts +0 -135
  149. package/dist/keyframes/index.js +0 -206
  150. package/dist/keyframes/index.js.map +0 -1
  151. package/dist/parser/classify.js +0 -319
  152. package/dist/parser/classify.js.map +0 -1
  153. package/dist/parser/const.js +0 -33
  154. package/dist/parser/const.js.map +0 -1
  155. package/dist/parser/lru.js +0 -109
  156. package/dist/parser/lru.js.map +0 -1
  157. package/dist/parser/parser.d.ts +0 -25
  158. package/dist/parser/parser.js +0 -116
  159. package/dist/parser/parser.js.map +0 -1
  160. package/dist/parser/tokenizer.js +0 -69
  161. package/dist/parser/tokenizer.js.map +0 -1
  162. package/dist/parser/types.d.ts +0 -51
  163. package/dist/parser/types.js +0 -46
  164. package/dist/parser/types.js.map +0 -1
  165. package/dist/pipeline/conditions.d.ts +0 -134
  166. package/dist/pipeline/conditions.js +0 -400
  167. package/dist/pipeline/conditions.js.map +0 -1
  168. package/dist/pipeline/exclusive.js +0 -231
  169. package/dist/pipeline/exclusive.js.map +0 -1
  170. package/dist/pipeline/index.d.ts +0 -53
  171. package/dist/pipeline/index.js +0 -641
  172. package/dist/pipeline/index.js.map +0 -1
  173. package/dist/pipeline/materialize.js +0 -908
  174. package/dist/pipeline/materialize.js.map +0 -1
  175. package/dist/pipeline/parseStateKey.d.ts +0 -15
  176. package/dist/pipeline/parseStateKey.js +0 -430
  177. package/dist/pipeline/parseStateKey.js.map +0 -1
  178. package/dist/pipeline/simplify.js +0 -557
  179. package/dist/pipeline/simplify.js.map +0 -1
  180. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  181. package/dist/plugins/okhsl-plugin.js +0 -371
  182. package/dist/plugins/okhsl-plugin.js.map +0 -1
  183. package/dist/plugins/types.d.ts +0 -69
  184. package/dist/properties/index.js +0 -158
  185. package/dist/properties/index.js.map +0 -1
  186. package/dist/states/index.d.ts +0 -49
  187. package/dist/states/index.js +0 -416
  188. package/dist/states/index.js.map +0 -1
  189. package/dist/static/tastyStatic.d.ts +0 -46
  190. package/dist/static/tastyStatic.js +0 -31
  191. package/dist/static/tastyStatic.js.map +0 -1
  192. package/dist/static/types.d.ts +0 -49
  193. package/dist/static/types.js +0 -24
  194. package/dist/static/types.js.map +0 -1
  195. package/dist/styles/align.d.ts +0 -15
  196. package/dist/styles/align.js +0 -14
  197. package/dist/styles/align.js.map +0 -1
  198. package/dist/styles/border.d.ts +0 -25
  199. package/dist/styles/border.js +0 -114
  200. package/dist/styles/border.js.map +0 -1
  201. package/dist/styles/color.d.ts +0 -14
  202. package/dist/styles/color.js +0 -23
  203. package/dist/styles/color.js.map +0 -1
  204. package/dist/styles/createStyle.js +0 -77
  205. package/dist/styles/createStyle.js.map +0 -1
  206. package/dist/styles/dimension.js +0 -97
  207. package/dist/styles/dimension.js.map +0 -1
  208. package/dist/styles/display.d.ts +0 -37
  209. package/dist/styles/display.js +0 -67
  210. package/dist/styles/display.js.map +0 -1
  211. package/dist/styles/fade.d.ts +0 -15
  212. package/dist/styles/fade.js +0 -58
  213. package/dist/styles/fade.js.map +0 -1
  214. package/dist/styles/fill.d.ts +0 -44
  215. package/dist/styles/fill.js +0 -51
  216. package/dist/styles/fill.js.map +0 -1
  217. package/dist/styles/flow.d.ts +0 -16
  218. package/dist/styles/flow.js +0 -12
  219. package/dist/styles/flow.js.map +0 -1
  220. package/dist/styles/gap.d.ts +0 -31
  221. package/dist/styles/gap.js +0 -37
  222. package/dist/styles/gap.js.map +0 -1
  223. package/dist/styles/height.d.ts +0 -17
  224. package/dist/styles/height.js +0 -20
  225. package/dist/styles/height.js.map +0 -1
  226. package/dist/styles/index.d.ts +0 -2
  227. package/dist/styles/index.js +0 -9
  228. package/dist/styles/index.js.map +0 -1
  229. package/dist/styles/inset.d.ts +0 -52
  230. package/dist/styles/inset.js +0 -150
  231. package/dist/styles/inset.js.map +0 -1
  232. package/dist/styles/justify.d.ts +0 -15
  233. package/dist/styles/justify.js +0 -14
  234. package/dist/styles/justify.js.map +0 -1
  235. package/dist/styles/list.d.ts +0 -16
  236. package/dist/styles/list.js +0 -98
  237. package/dist/styles/list.js.map +0 -1
  238. package/dist/styles/margin.d.ts +0 -24
  239. package/dist/styles/margin.js +0 -104
  240. package/dist/styles/margin.js.map +0 -1
  241. package/dist/styles/outline.d.ts +0 -29
  242. package/dist/styles/outline.js +0 -65
  243. package/dist/styles/outline.js.map +0 -1
  244. package/dist/styles/padding.d.ts +0 -24
  245. package/dist/styles/padding.js +0 -104
  246. package/dist/styles/padding.js.map +0 -1
  247. package/dist/styles/predefined.d.ts +0 -73
  248. package/dist/styles/predefined.js +0 -241
  249. package/dist/styles/predefined.js.map +0 -1
  250. package/dist/styles/preset.d.ts +0 -47
  251. package/dist/styles/preset.js +0 -126
  252. package/dist/styles/preset.js.map +0 -1
  253. package/dist/styles/radius.d.ts +0 -14
  254. package/dist/styles/radius.js +0 -51
  255. package/dist/styles/radius.js.map +0 -1
  256. package/dist/styles/scrollbar.d.ts +0 -21
  257. package/dist/styles/scrollbar.js +0 -105
  258. package/dist/styles/scrollbar.js.map +0 -1
  259. package/dist/styles/shadow.d.ts +0 -14
  260. package/dist/styles/shadow.js +0 -24
  261. package/dist/styles/shadow.js.map +0 -1
  262. package/dist/styles/styledScrollbar.d.ts +0 -47
  263. package/dist/styles/styledScrollbar.js +0 -38
  264. package/dist/styles/styledScrollbar.js.map +0 -1
  265. package/dist/styles/transition.d.ts +0 -14
  266. package/dist/styles/transition.js +0 -158
  267. package/dist/styles/transition.js.map +0 -1
  268. package/dist/styles/types.d.ts +0 -498
  269. package/dist/styles/width.d.ts +0 -17
  270. package/dist/styles/width.js +0 -20
  271. package/dist/styles/width.js.map +0 -1
  272. package/dist/tasty.d.ts +0 -982
  273. package/dist/tasty.js +0 -191
  274. package/dist/tasty.js.map +0 -1
  275. package/dist/tokens/typography.d.ts +0 -19
  276. package/dist/tokens/typography.js +0 -237
  277. package/dist/tokens/typography.js.map +0 -1
  278. package/dist/types.d.ts +0 -184
  279. package/dist/utils/cache-wrapper.js +0 -26
  280. package/dist/utils/cache-wrapper.js.map +0 -1
  281. package/dist/utils/case-converter.js +0 -8
  282. package/dist/utils/case-converter.js.map +0 -1
  283. package/dist/utils/colors.d.ts +0 -5
  284. package/dist/utils/colors.js +0 -9
  285. package/dist/utils/colors.js.map +0 -1
  286. package/dist/utils/css-types.d.ts +0 -7
  287. package/dist/utils/dotize.d.ts +0 -26
  288. package/dist/utils/dotize.js +0 -122
  289. package/dist/utils/dotize.js.map +0 -1
  290. package/dist/utils/filter-base-props.d.ts +0 -15
  291. package/dist/utils/filter-base-props.js +0 -45
  292. package/dist/utils/filter-base-props.js.map +0 -1
  293. package/dist/utils/get-display-name.d.ts +0 -7
  294. package/dist/utils/get-display-name.js +0 -10
  295. package/dist/utils/get-display-name.js.map +0 -1
  296. package/dist/utils/hsl-to-rgb.js +0 -38
  297. package/dist/utils/hsl-to-rgb.js.map +0 -1
  298. package/dist/utils/is-dev-env.js +0 -19
  299. package/dist/utils/is-dev-env.js.map +0 -1
  300. package/dist/utils/is-valid-element-type.js +0 -15
  301. package/dist/utils/is-valid-element-type.js.map +0 -1
  302. package/dist/utils/merge-styles.js.map +0 -1
  303. package/dist/utils/mod-attrs.d.ts +0 -8
  304. package/dist/utils/mod-attrs.js +0 -21
  305. package/dist/utils/mod-attrs.js.map +0 -1
  306. package/dist/utils/okhsl-to-rgb.js +0 -296
  307. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  308. package/dist/utils/process-tokens.d.ts +0 -31
  309. package/dist/utils/process-tokens.js +0 -171
  310. package/dist/utils/process-tokens.js.map +0 -1
  311. package/dist/utils/resolve-recipes.d.ts +0 -17
  312. package/dist/utils/resolve-recipes.js +0 -147
  313. package/dist/utils/resolve-recipes.js.map +0 -1
  314. package/dist/utils/string.js +0 -8
  315. package/dist/utils/string.js.map +0 -1
  316. package/dist/utils/styles.d.ts +0 -183
  317. package/dist/utils/styles.js +0 -585
  318. package/dist/utils/styles.js.map +0 -1
  319. package/dist/utils/typography.d.ts +0 -36
  320. package/dist/utils/typography.js +0 -53
  321. package/dist/utils/typography.js.map +0 -1
  322. package/dist/utils/warnings.d.ts +0 -16
  323. package/dist/utils/warnings.js +0 -16
  324. package/dist/utils/warnings.js.map +0 -1
  325. package/dist/zero/css-writer.d.ts +0 -45
  326. package/dist/zero/css-writer.js +0 -74
  327. package/dist/zero/css-writer.js.map +0 -1
  328. package/dist/zero/extractor.d.ts +0 -24
  329. package/dist/zero/extractor.js +0 -150
  330. package/dist/zero/extractor.js.map +0 -1
@@ -1,108 +1,67 @@
1
- import { KeyframesSteps } from "../injector/types.js";
2
- import { StyleDetails, UnitHandler } from "../parser/types.js";
3
- import { StyleHandlerDefinition } from "../utils/styles.js";
4
- import { RecipeStyles } from "../styles/types.js";
5
- import { TastyPlugin } from "../plugins/types.js";
6
- import * as _babel_core0 from "@babel/core";
1
+ import { t as TastyZeroConfig } from "../babel-types-DpUCD2L_.js";
7
2
  import { PluginPass } from "@babel/core";
8
-
9
3
  //#region src/zero/babel.d.ts
10
4
  /**
11
- * Build-time configuration for zero-runtime mode.
12
- * Subset of TastyConfig that applies at build time.
5
+ * Options for the `@tenphi/tasty/babel-plugin` Babel plugin.
13
6
  */
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>;
7
+ export interface TastyZeroBabelOptions {
8
+ /** Output path for generated CSS (default: 'tasty.css') */
9
+ output?: string;
36
10
  /**
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(' ') }
11
+ * Tasty configuration for build-time processing.
12
+ * Can be a static object or a factory function that returns fresh config.
13
+ * A factory is called on each plugin invocation, enabling hot reload
14
+ * of config values that depend on external files (e.g. theme tokens).
40
15
  */
41
- funcs?: Record<string, (groups: StyleDetails[]) => string>;
16
+ config?: TastyZeroConfig | (() => TastyZeroConfig);
42
17
  /**
43
- * Plugins that extend tasty with custom functions, units, states, handlers, or tokens.
44
- * Plugins are processed in order, with later plugins overriding earlier ones.
45
- * @example
46
- * ```ts
47
- * import { okhslPlugin } from '@tenphi/tasty';
18
+ * Absolute path to a TypeScript/JavaScript module that default-exports
19
+ * a `TastyZeroConfig` object. The module is loaded via jiti on each
20
+ * plugin invocation, enabling hot reload when the file changes.
48
21
  *
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 } } }
22
+ * This option is JSON-serializable and is the primary way Turbopack
23
+ * passes config to the Babel plugin (since Turbopack loader options
24
+ * must be plain primitives/objects/arrays).
25
+ *
26
+ * When both `config` and `configFile` are set, `config` takes precedence.
27
+ *
28
+ * @example '/absolute/path/to/tasty-zero.config.ts'
64
29
  */
65
- keyframes?: Record<string, KeyframesSteps>;
30
+ configFile?: string;
66
31
  /**
67
- * Custom style handlers that transform style properties into CSS declarations.
68
- * Handlers replace built-in handlers for the same style name.
69
- * @example
70
- * ```ts
71
- * handlers: {
72
- * fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,
73
- * elevation: ({ elevation }) => ({
74
- * 'box-shadow': `0 ${elevation}px ${elevation * 2}px rgba(0,0,0,0.1)`,
75
- * }),
76
- * }
77
- * ```
32
+ * Absolute file paths whose content affects the generated CSS.
33
+ * When any of these files change, babel-loader invalidates its cache
34
+ * and re-runs the plugin with fresh config values.
35
+ *
36
+ * Typically includes theme files that define Glaze palettes or token values.
37
+ * Paths must be absolute (resolved by the Next.js wrapper).
78
38
  */
79
- handlers?: Record<string, StyleHandlerDefinition>;
39
+ configDeps?: string[];
80
40
  /**
81
- * Predefined tokens that are replaced during style parsing.
82
- * Use `$name` for custom properties and `#name` for color tokens.
83
- * @example { $spacing: '2x', '#accent': '#purple' }
41
+ * Automatically replace `@tenphi/tasty/static` imports with an import
42
+ * of the generated CSS file. This eliminates the need for users to
43
+ * manually import the CSS in their app entry point.
44
+ *
45
+ * @default true
84
46
  */
85
- tokens?: Record<`$${string}` | `#${string}`, string | number>;
47
+ injectImport?: boolean;
86
48
  /**
87
- * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
88
- * Recipe values are flat tasty styles (no sub-element keys).
89
- * @example
90
- * ```ts
91
- * recipes: {
92
- * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
93
- * elevated: { shadow: '2x 2x 4x #shadow' },
94
- * }
95
- * ```
49
+ * Output mode for extracted CSS.
50
+ *
51
+ * - `'file'` (default): CSS is written to a single output file and
52
+ * the `@tenphi/tasty/static` import is rewritten to import that file.
53
+ * - `'inject'`: CSS is embedded inline in the JS output and injected
54
+ * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
55
+ * No CSS file is written. Each `tastyStatic` call becomes
56
+ * self-contained. Best for reusable components and extensions.
57
+ *
58
+ * When `mode` is `'inject'`, `output` and `injectImport` are ignored.
59
+ *
60
+ * @default 'file'
96
61
  */
97
- recipes?: Record<string, RecipeStyles>;
98
- }
99
- interface TastyZeroBabelOptions {
100
- /** Output path for generated CSS (default: 'tasty.css') */
101
- output?: string;
102
- /** Tasty configuration for build-time processing */
103
- config?: TastyZeroConfig;
62
+ mode?: 'file' | 'inject';
104
63
  }
105
- declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _babel_core0.PluginObj<PluginPass>;
64
+ declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => import("@babel/core").PluginObj<PluginPass>;
106
65
  //#endregion
107
- export { TastyZeroBabelOptions, TastyZeroConfig, _default as default };
66
+ export { type TastyZeroConfig, _default as default };
108
67
  //# sourceMappingURL=babel.d.ts.map
@@ -1,58 +1,158 @@
1
- import { configure } from "../config.js";
2
- import { mergeStyles } from "../utils/merge-styles.js";
3
- import { resolveRecipes } from "../utils/resolve-recipes.js";
4
- import { extractKeyframesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "./extractor.js";
5
- import { CSSWriter } from "./css-writer.js";
1
+ import { t as mergeStyles } from "../chunks/shared-utils-y-HjvPN4.js";
2
+ import "../chunks/css-definitions-BibU6ZnP.js";
3
+ import { t as resolveRecipesWith } from "../chunks/config-engine-CGIMO2PV.js";
4
+ import { a as resetZeroConfig, i as reapplyZeroConfig, n as functionsForExtraction, t as configureZero } from "../chunks/build-config-BDLYGmKn.js";
5
+ import { a as extractCounterStyleFromStyles, c as extractKeyframesFromStyles, h as setExtractorNamePrefix, i as extractConfigProperties, l as extractPropertiesFromStyles, m as replaceAnimationNamesInCSS, o as extractFontFaceFromStyles, p as renderSelectorCSS, r as extractChunks, s as extractFunctionsFromStyles, t as CSSWriter, u as extractSelectorCSS } from "../chunks/zero-engine-DpkieEPZ.js";
6
+ import { t as loadConfigFile } from "../chunks/config-file-DlZXJMj8.js";
7
+ import * as fs from "fs";
8
+ import * as path from "path";
6
9
  import { declare } from "@babel/helper-plugin-utils";
7
10
  import * as t from "@babel/types";
8
-
11
+ //#region \0rolldown/runtime.js
12
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
13
+ if (typeof require !== "undefined") return require.apply(this, arguments);
14
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
15
+ });
16
+ //#endregion
17
+ //#region src/zero/writer-cache.ts
18
+ const writerCache = /* @__PURE__ */ new Map();
19
+ //#endregion
9
20
  //#region src/zero/babel.ts
10
- /**
11
- * Babel plugin for zero-runtime tasty static site generation.
12
- *
13
- * Transforms:
14
- * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }
15
- * - `tastyStatic(base, styles)` → StaticStyle object with merged styles
16
- * - `tastyStatic(selector, styles)` → removed entirely
17
- *
18
- * Usage:
19
- * ```javascript
20
- * // babel.config.js
21
- * module.exports = {
22
- * plugins: [
23
- * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]
24
- * ]
25
- * };
26
- * ```
27
- */
21
+ function mtime(filePath) {
22
+ try {
23
+ return fs.statSync(filePath).mtimeMs;
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+ function clearRequireCacheTree(filePath) {
29
+ let resolved;
30
+ try {
31
+ resolved = __require.resolve(filePath);
32
+ } catch {
33
+ return;
34
+ }
35
+ const mod = __require.cache[resolved];
36
+ if (!mod) return;
37
+ const dir = resolved.substring(0, resolved.lastIndexOf("/"));
38
+ if (mod.children) {
39
+ for (const child of mod.children) if (child.id.startsWith(dir) && !child.id.includes("node_modules")) clearRequireCacheTree(child.id);
40
+ }
41
+ delete __require.cache[resolved];
42
+ }
28
43
  var babel_default = declare((api, options) => {
29
44
  api.assertVersion(7);
45
+ const mode = options.mode ?? "file";
30
46
  const outputPath = options.output || "tasty.css";
31
- const config = options.config || {};
32
- const devMode = config.devMode ?? false;
33
- configure(config);
34
- const cssWriter = new CSSWriter(outputPath, { devMode });
35
- const globalRegistry = {};
47
+ const resolvedOutputPath = path.resolve(outputPath);
48
+ const injectImport = options.injectImport ?? true;
49
+ if (mode === "file" && injectImport) {
50
+ const dir = path.dirname(resolvedOutputPath);
51
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
52
+ if (!fs.existsSync(resolvedOutputPath)) fs.writeFileSync(resolvedOutputPath, "/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\n");
53
+ }
54
+ const configDeps = [...options.configFile ? [options.configFile] : [], ...options.configDeps || []];
55
+ const configKey = configDeps.length > 0 ? configDeps.map(mtime).join(",") : "";
56
+ if (configDeps.length > 0) {
57
+ api.cache.using(() => configKey);
58
+ for (const dep of configDeps) try {
59
+ api.addExternalDependency(dep);
60
+ } catch {}
61
+ } else api.cache.forever();
62
+ if (configDeps.length > 0) for (const dep of configDeps) clearRequireCacheTree(dep);
63
+ const cached = writerCache.get(resolvedOutputPath);
64
+ if (!cached || cached.configKey !== configKey) {
65
+ const configOption = options.config;
66
+ let resolvedConfig;
67
+ if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
68
+ else if (options.configFile) resolvedConfig = loadConfigFile(options.configFile);
69
+ else resolvedConfig = {};
70
+ const devMode = resolvedConfig.devMode ?? false;
71
+ resetZeroConfig();
72
+ const finalConfig = {
73
+ namePrefix: "ts",
74
+ ...resolvedConfig
75
+ };
76
+ const config = configureZero(finalConfig);
77
+ setExtractorNamePrefix(finalConfig.namePrefix ?? "ts");
78
+ const newWriter = new CSSWriter(outputPath, { devMode });
79
+ if (mode !== "inject") {
80
+ for (const prop of extractConfigProperties(config.normalized.properties)) newWriter.add(`@property:${prop.name}`, prop.css);
81
+ const tokenCSS = extractCSSFromStyles(":root", config.normalized.tokens);
82
+ if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
83
+ for (const [selector, styles] of Object.entries(config.normalized.globalStyles)) writeGlobalStyles(newWriter, selector, styles, config.normalized.keyframes);
84
+ }
85
+ writerCache.set(resolvedOutputPath, {
86
+ writer: newWriter,
87
+ configKey,
88
+ registry: {},
89
+ config
90
+ });
91
+ }
92
+ const entry = writerCache.get(resolvedOutputPath);
93
+ entry.config = reapplyZeroConfig(entry.config);
94
+ const cssWriter = entry.writer;
95
+ const globalRegistry = entry.registry;
96
+ const config = entry.config;
97
+ const sourceConfig = config.source;
98
+ const devMode = sourceConfig.devMode ?? false;
99
+ setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
100
+ const configProperties = extractConfigProperties(config.normalized.properties);
101
+ const propertyOptions = {
102
+ autoPropertyTypes: sourceConfig.autoPropertyTypes,
103
+ defined: new Set(configProperties.map((prop) => prop.name))
104
+ };
105
+ let propertyCSS;
106
+ let tokenCSS;
107
+ let globalStylesCSS;
108
+ if (mode === "inject") {
109
+ propertyCSS = configProperties.map((prop) => prop.css).join("\n") || void 0;
110
+ tokenCSS = extractCSSFromStyles(":root", config.normalized.tokens);
111
+ const gs = config.normalized.globalStyles;
112
+ if (Object.keys(gs).length > 0) {
113
+ globalStylesCSS = /* @__PURE__ */ new Map();
114
+ for (const [selector, styles] of Object.entries(gs)) {
115
+ const css = extractCSSFromStyles(selector, styles, config.normalized.keyframes);
116
+ if (css) globalStylesCSS.set(selector, css);
117
+ }
118
+ if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
119
+ }
120
+ }
36
121
  return {
37
122
  name: "tasty-zero",
38
123
  pre() {
124
+ entry.config = reapplyZeroConfig(entry.config);
125
+ setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
39
126
  this.staticStyleRegistry = {};
127
+ this._fileAddedCSS = false;
40
128
  if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
41
129
  },
42
130
  visitor: {
43
- ImportDeclaration(path) {
44
- const source = path.node.source.value;
45
- if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) path.remove();
131
+ ImportDeclaration(nodePath, state) {
132
+ const source = nodePath.node.source.value;
133
+ if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) {
134
+ if (mode === "inject") nodePath.replaceWith(t.importDeclaration([t.importSpecifier(t.identifier("_$i"), t.identifier("injectCSS"))], t.stringLiteral("@tenphi/tasty/static/inject")));
135
+ else if (injectImport) {
136
+ let importPath = resolvedOutputPath;
137
+ if (state.filename) {
138
+ const sourceDir = path.dirname(state.filename);
139
+ importPath = path.relative(sourceDir, resolvedOutputPath);
140
+ if (!importPath.startsWith(".")) importPath = "./" + importPath;
141
+ }
142
+ nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
143
+ } else nodePath.remove();
144
+ }
46
145
  },
47
146
  CallExpression(path, state) {
48
147
  const callee = path.node.callee;
49
148
  if (!t.isIdentifier(callee, { name: "tastyStatic" })) return;
149
+ state._fileAddedCSS = true;
50
150
  const args = path.node.arguments;
51
151
  if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
52
152
  const firstArg = args[0];
53
- if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, state.sourceFile, config.keyframes);
54
- else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, config.keyframes);
55
- else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, config.keyframes);
153
+ if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.normalized.keyframes, propertyOptions, config.normalized.fontFaces, config.normalized.counterStyles, functionsForExtraction(config), config.normalized.recipes);
154
+ else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.normalized.keyframes, propertyOptions, config.normalized.fontFaces, config.normalized.counterStyles, functionsForExtraction(config), config.normalized.recipes);
155
+ else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.normalized.keyframes, propertyOptions, config.normalized.fontFaces, config.normalized.counterStyles, functionsForExtraction(config), config.normalized.recipes);
56
156
  else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
57
157
  },
58
158
  VariableDeclarator(path, state) {
@@ -76,55 +176,69 @@ var babel_default = declare((api, options) => {
76
176
  }
77
177
  },
78
178
  post() {
79
- if (cssWriter.size > 0) cssWriter.write();
179
+ if (mode === "inject") {
180
+ if (this._fileAddedCSS && (propertyCSS || tokenCSS || globalStylesCSS)) {
181
+ const program = this.file.ast.program;
182
+ let insertIndex = 0;
183
+ for (let i = 0; i < program.body.length; i++) if (t.isImportDeclaration(program.body[i])) insertIndex = i + 1;
184
+ if (propertyCSS) {
185
+ const injectCall = createInjectCallAST("@property", propertyCSS);
186
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
187
+ insertIndex++;
188
+ }
189
+ if (tokenCSS) {
190
+ const injectCall = createInjectCallAST(":root", tokenCSS);
191
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
192
+ insertIndex++;
193
+ }
194
+ if (globalStylesCSS) for (const [selector, css] of globalStylesCSS) {
195
+ const injectCall = createInjectCallAST(selector, css);
196
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
197
+ insertIndex++;
198
+ }
199
+ }
200
+ return;
201
+ }
202
+ if (this._fileAddedCSS && cssWriter.size > 0) cssWriter.write();
80
203
  }
81
204
  };
82
205
  });
83
- /**
84
- * Check if an object expression looks like a StaticStyle object
85
- */
86
206
  function isStaticStyleObject(node) {
87
207
  const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
88
208
  const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
89
209
  return hasClassName && hasStyles;
90
210
  }
91
- /**
92
- * Extract styles object from a StaticStyle object expression
93
- */
94
211
  function extractStylesFromStaticStyleObject(node, path) {
95
212
  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);
96
213
  return null;
97
214
  }
98
- /**
99
- * Extract className from a StaticStyle object expression
100
- */
101
215
  function extractClassNameFromStaticStyleObject(node) {
102
216
  for (const prop of node.properties) if (t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "className" }) && t.isStringLiteral(prop.value)) return prop.value.value;
103
217
  return null;
104
218
  }
105
- /**
106
- * Handle tastyStatic(styles) - returns StaticStyle object
107
- */
108
- function handleStylesMode(path, args, cssWriter, state, globalRegistry, globalKeyframes) {
219
+ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
109
220
  const stylesArg = args[0];
110
221
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
111
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
222
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
223
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
112
224
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
113
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
114
- const chunks = extractStylesWithChunks(styles);
115
- for (const chunk of chunks) {
116
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
117
- cssWriter.add(chunk.className, css, state.sourceFile);
118
- }
225
+ const properties = extractPropertiesFromStyles(styles, propertyOptions);
226
+ const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
227
+ const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
228
+ const functions = extractFunctionsFromStyles(styles, globalFunction);
229
+ const chunks = extractChunks(styles);
119
230
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
120
231
  const staticStyleObject = createStaticStyleAST(className, styles);
121
- path.replaceWith(staticStyleObject);
232
+ if (mode === "inject") {
233
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
234
+ path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
235
+ } else {
236
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
237
+ path.replaceWith(staticStyleObject);
238
+ }
122
239
  registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
123
240
  }
124
- /**
125
- * Handle tastyStatic(base, styles) - extends base with additional styles
126
- */
127
- function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globalKeyframes) {
241
+ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
128
242
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
129
243
  const baseArg = args[0];
130
244
  const stylesArg = args[1];
@@ -134,42 +248,94 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globa
134
248
  const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
135
249
  if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
136
250
  const overrideStyles = evaluateObjectExpression(stylesArg, path);
137
- const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
251
+ const mergedStyles = resolveRecipesWith(mergeStyles(baseEntry.styles, overrideStyles), globalRecipes ?? null);
138
252
  const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
139
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
140
- const chunks = extractStylesWithChunks(mergedStyles);
141
- for (const chunk of chunks) {
142
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
143
- cssWriter.add(chunk.className, css, state.sourceFile);
144
- }
253
+ const properties = extractPropertiesFromStyles(mergedStyles, propertyOptions);
254
+ const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
255
+ const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
256
+ const functions = extractFunctionsFromStyles(mergedStyles, globalFunction);
257
+ const chunks = extractChunks(mergedStyles);
145
258
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
146
259
  const staticStyleObject = createStaticStyleAST(className, mergedStyles);
147
- path.replaceWith(staticStyleObject);
260
+ if (mode === "inject") {
261
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
262
+ path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
263
+ } else {
264
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
265
+ path.replaceWith(staticStyleObject);
266
+ }
148
267
  registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
149
268
  }
150
- /**
151
- * Handle tastyStatic(selector, styles) - removes the call entirely
152
- */
153
- function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes) {
269
+ function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
154
270
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
155
271
  const selectorArg = args[0];
156
272
  const stylesArg = args[1];
157
273
  if (!t.isStringLiteral(selectorArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) first argument must be a string literal");
158
274
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) second argument must be a static object literal");
159
275
  const selector = selectorArg.value;
160
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
276
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
277
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
161
278
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
279
+ const properties = extractPropertiesFromStyles(styles, propertyOptions);
280
+ const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
281
+ const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
282
+ const functions = extractFunctionsFromStyles(styles, globalFunction);
283
+ const css = renderSelectorCSS(selector, styles);
284
+ const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(css, nameMap) : css;
285
+ if (mode === "inject") {
286
+ const cssParts = [];
287
+ for (const kf of keyframes) cssParts.push(kf.css);
288
+ for (const prop of properties) cssParts.push(prop.css);
289
+ for (const ff of fontFaces) cssParts.push(ff.css);
290
+ for (const cs of counterStyles) cssParts.push(cs.css);
291
+ for (const fn of functions) cssParts.push(fn.css);
292
+ cssParts.push(selectorCSS);
293
+ const injectCall = createInjectCallAST(selector, cssParts.join("\n"));
294
+ const parent = path.parentPath;
295
+ if (parent && t.isExpressionStatement(parent.node)) parent.replaceWith(t.expressionStatement(injectCall));
296
+ else path.replaceWith(injectCall);
297
+ } else {
298
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, [], nameMap, sourceFile);
299
+ cssWriter.add(selector, selectorCSS, sourceFile);
300
+ const parent = path.parentPath;
301
+ if (parent && t.isExpressionStatement(parent.node)) parent.remove();
302
+ else path.replaceWith(t.identifier("undefined"));
303
+ }
304
+ }
305
+ function collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap) {
306
+ const parts = [];
307
+ for (const kf of keyframes) parts.push(kf.css);
308
+ for (const prop of properties) parts.push(prop.css);
309
+ for (const ff of fontFaces) parts.push(ff.css);
310
+ for (const cs of counterStyles) parts.push(cs.css);
311
+ for (const fn of functions) parts.push(fn.css);
312
+ for (const chunk of chunks) parts.push(nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css);
313
+ return parts.join("\n");
314
+ }
315
+ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, sourceFile) {
162
316
  for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
163
- const result = extractStylesForSelector(selector, styles);
164
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
165
- cssWriter.add(selector, css, sourceFile);
166
- const parent = path.parentPath;
167
- if (parent && t.isExpressionStatement(parent.node)) parent.remove();
168
- else path.replaceWith(t.identifier("undefined"));
317
+ for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
318
+ for (const ff of fontFaces) cssWriter.add(ff.css, ff.css, sourceFile);
319
+ for (const cs of counterStyles) cssWriter.add(cs.css, cs.css, sourceFile);
320
+ for (const fn of functions) cssWriter.add(fn.css, fn.css, sourceFile);
321
+ for (const chunk of chunks) {
322
+ const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
323
+ cssWriter.add(chunk.className, css, sourceFile);
324
+ }
325
+ }
326
+ function extractCSSFromStyles(selector, styles, globalKeyframes) {
327
+ if (!styles || Object.keys(styles).length === 0) return void 0;
328
+ return extractSelectorCSS(selector, styles, globalKeyframes) || void 0;
329
+ }
330
+ function writeGlobalStyles(cssWriter, selector, styles, globalKeyframes) {
331
+ const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
332
+ for (const kf of keyframes) cssWriter.add(kf.css, kf.css);
333
+ const css = replaceAnimationNamesInCSS(renderSelectorCSS(selector, styles), nameMap);
334
+ if (css) cssWriter.add(`global:${selector}`, css);
335
+ }
336
+ function createInjectCallAST(id, css) {
337
+ return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
169
338
  }
170
- /**
171
- * Create a StaticStyle object AST node
172
- */
173
339
  function createStaticStyleAST(className, styles) {
174
340
  return t.objectExpression([
175
341
  t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
@@ -177,9 +343,6 @@ function createStaticStyleAST(className, styles) {
177
343
  t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
178
344
  ]);
179
345
  }
180
- /**
181
- * Register a StaticStyle in the registry if it's being assigned to a variable
182
- */
183
346
  function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
184
347
  const parent = path.parentPath;
185
348
  if (parent && t.isVariableDeclarator(parent.node)) {
@@ -197,9 +360,6 @@ function registerIfVariableDeclaration(path, className, styles, state, globalReg
197
360
  }
198
361
  }
199
362
  }
200
- /**
201
- * Convert a JavaScript value to an AST node
202
- */
203
363
  function valueToAST(value) {
204
364
  if (value === null) return t.nullLiteral();
205
365
  if (value === void 0) return t.identifier("undefined");
@@ -213,10 +373,6 @@ function valueToAST(value) {
213
373
  }
214
374
  return t.identifier("undefined");
215
375
  }
216
- /**
217
- * Evaluate an ObjectExpression to a plain JavaScript object.
218
- * Only supports static values that can be determined at build time.
219
- */
220
376
  function evaluateObjectExpression(node, path) {
221
377
  const result = {};
222
378
  for (const prop of node.properties) {
@@ -226,13 +382,11 @@ function evaluateObjectExpression(node, path) {
226
382
  if (t.isIdentifier(prop.key)) key = prop.key.name;
227
383
  else if (t.isStringLiteral(prop.key)) key = prop.key.value;
228
384
  else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
229
- result[key] = evaluateExpression(prop.value, path);
385
+ const value = evaluateExpression(prop.value, path);
386
+ result[key] = value;
230
387
  }
231
388
  return result;
232
389
  }
233
- /**
234
- * Evaluate an expression to a JavaScript value.
235
- */
236
390
  function evaluateExpression(node, path) {
237
391
  if (t.isStringLiteral(node)) return node.value;
238
392
  if (t.isNumericLiteral(node)) return node.value;
@@ -255,28 +409,7 @@ function evaluateExpression(node, path) {
255
409
  }
256
410
  throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
257
411
  }
258
- /**
259
- * Replace animation names in CSS string.
260
- * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
261
- */
262
- function replaceAnimationNamesInCSS(css, nameMap) {
263
- if (nameMap.size === 0) return css;
264
- return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
265
- let newValue = value;
266
- for (const [original, replacement] of nameMap) {
267
- const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
268
- newValue = newValue.replace(pattern, replacement);
269
- }
270
- return `${prop}: ${newValue}`;
271
- });
272
- }
273
- /**
274
- * Escape special regex characters.
275
- */
276
- function escapeRegex(str) {
277
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
278
- }
279
-
280
412
  //#endregion
281
413
  export { babel_default as default };
414
+
282
415
  //# sourceMappingURL=babel.js.map