@tenphi/tasty 0.0.0-snapshot.2705ab9 → 0.0.0-snapshot.272039a

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 (372) hide show
  1. package/README.md +441 -362
  2. package/dist/babel-types-Dc5zghyE.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-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/chunks/collector-Cb8ah2JF.js +210 -0
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
  10. package/dist/chunks/config-engine-CMYFZYQh.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-B4aWBkH3.js +910 -0
  14. package/dist/chunks/css-definitions-B4aWBkH3.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/{debug.js → chunks/debug-D2Pu7Xhy.js} +197 -149
  18. package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.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-DHiopXCu.js +691 -0
  24. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  25. package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
  26. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  27. package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
  28. package/dist/chunks/runtime-state-lZjMbvwV.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-DnkV_4Jg.js +5602 -0
  32. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  33. package/dist/chunks/zero-engine-DcwaCvFs.js +310 -0
  34. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  35. package/dist/collector-D2OT6I2G.d.ts +164 -0
  36. package/dist/config-C4ftFxgI.d.ts +1367 -0
  37. package/dist/core/index.d.ts +5 -34
  38. package/dist/core/index.js +9 -27
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DxQNRj50.d.ts +1964 -0
  41. package/dist/index.d.ts +5 -51
  42. package/dist/index.js +11 -36
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-D39qBtox.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 +110 -12
  60. package/dist/ssr/astro.js +206 -50
  61. package/dist/ssr/astro.js.map +1 -1
  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 -5
  65. package/dist/ssr/index.js +7 -9
  66. package/dist/ssr/index.js.map +1 -1
  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 +13 -12
  71. package/dist/ssr/next.js +40 -51
  72. package/dist/ssr/next.js.map +1 -1
  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-CYQIhUg1.d.ts +1569 -0
  80. package/dist/zero/babel.d.ts +27 -121
  81. package/dist/zero/babel.js +192 -151
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +136 -3
  84. package/dist/zero/index.js +24 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +16 -5
  87. package/dist/zero/next.js +8 -42
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +23 -12
  90. package/docs/adoption.md +72 -37
  91. package/docs/ai-agents.md +259 -0
  92. package/docs/comparison.md +83 -54
  93. package/docs/configuration.md +712 -81
  94. package/docs/debug.md +39 -24
  95. package/docs/design-system.md +174 -41
  96. package/docs/dsl.md +733 -195
  97. package/docs/getting-started.md +132 -52
  98. package/docs/injector.md +197 -90
  99. package/docs/methodology.md +154 -48
  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 +746 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +403 -151
  106. package/docs/styles.md +251 -49
  107. package/docs/tasty-static.md +368 -101
  108. package/package.json +157 -40
  109. package/tasty.config.ts +7 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -78
  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 -259
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -60
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -366
  119. package/dist/config.js +0 -504
  120. package/dist/config.js.map +0 -1
  121. package/dist/counter-style/index.js +0 -51
  122. package/dist/counter-style/index.js.map +0 -1
  123. package/dist/debug.d.ts +0 -89
  124. package/dist/debug.js.map +0 -1
  125. package/dist/font-face/index.js +0 -63
  126. package/dist/font-face/index.js.map +0 -1
  127. package/dist/hooks/resolve-ssr-collector.js +0 -15
  128. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  129. package/dist/hooks/useCounterStyle.d.ts +0 -50
  130. package/dist/hooks/useCounterStyle.js +0 -47
  131. package/dist/hooks/useCounterStyle.js.map +0 -1
  132. package/dist/hooks/useFontFace.d.ts +0 -43
  133. package/dist/hooks/useFontFace.js +0 -71
  134. package/dist/hooks/useFontFace.js.map +0 -1
  135. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  136. package/dist/hooks/useGlobalStyles.js +0 -79
  137. package/dist/hooks/useGlobalStyles.js.map +0 -1
  138. package/dist/hooks/useKeyframes.d.ts +0 -56
  139. package/dist/hooks/useKeyframes.js +0 -65
  140. package/dist/hooks/useKeyframes.js.map +0 -1
  141. package/dist/hooks/useProperty.d.ts +0 -79
  142. package/dist/hooks/useProperty.js +0 -110
  143. package/dist/hooks/useProperty.js.map +0 -1
  144. package/dist/hooks/useRawCSS.d.ts +0 -53
  145. package/dist/hooks/useRawCSS.js +0 -36
  146. package/dist/hooks/useRawCSS.js.map +0 -1
  147. package/dist/hooks/useStyles.d.ts +0 -45
  148. package/dist/hooks/useStyles.js +0 -238
  149. package/dist/hooks/useStyles.js.map +0 -1
  150. package/dist/injector/index.d.ts +0 -183
  151. package/dist/injector/index.js +0 -180
  152. package/dist/injector/index.js.map +0 -1
  153. package/dist/injector/injector.d.ts +0 -166
  154. package/dist/injector/injector.js +0 -465
  155. package/dist/injector/injector.js.map +0 -1
  156. package/dist/injector/sheet-manager.d.ts +0 -136
  157. package/dist/injector/sheet-manager.js +0 -734
  158. package/dist/injector/sheet-manager.js.map +0 -1
  159. package/dist/injector/types.d.ts +0 -204
  160. package/dist/keyframes/index.js +0 -206
  161. package/dist/keyframes/index.js.map +0 -1
  162. package/dist/parser/classify.js +0 -320
  163. package/dist/parser/classify.js.map +0 -1
  164. package/dist/parser/const.js +0 -49
  165. package/dist/parser/const.js.map +0 -1
  166. package/dist/parser/lru.js +0 -109
  167. package/dist/parser/lru.js.map +0 -1
  168. package/dist/parser/parser.d.ts +0 -25
  169. package/dist/parser/parser.js +0 -116
  170. package/dist/parser/parser.js.map +0 -1
  171. package/dist/parser/tokenizer.js +0 -69
  172. package/dist/parser/tokenizer.js.map +0 -1
  173. package/dist/parser/types.d.ts +0 -51
  174. package/dist/parser/types.js +0 -46
  175. package/dist/parser/types.js.map +0 -1
  176. package/dist/pipeline/conditions.d.ts +0 -134
  177. package/dist/pipeline/conditions.js +0 -406
  178. package/dist/pipeline/conditions.js.map +0 -1
  179. package/dist/pipeline/exclusive.js +0 -231
  180. package/dist/pipeline/exclusive.js.map +0 -1
  181. package/dist/pipeline/index.d.ts +0 -55
  182. package/dist/pipeline/index.js +0 -709
  183. package/dist/pipeline/index.js.map +0 -1
  184. package/dist/pipeline/materialize.js +0 -1104
  185. package/dist/pipeline/materialize.js.map +0 -1
  186. package/dist/pipeline/parseStateKey.d.ts +0 -15
  187. package/dist/pipeline/parseStateKey.js +0 -447
  188. package/dist/pipeline/parseStateKey.js.map +0 -1
  189. package/dist/pipeline/simplify.js +0 -516
  190. package/dist/pipeline/simplify.js.map +0 -1
  191. package/dist/pipeline/warnings.js +0 -18
  192. package/dist/pipeline/warnings.js.map +0 -1
  193. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  194. package/dist/plugins/okhsl-plugin.js +0 -98
  195. package/dist/plugins/okhsl-plugin.js.map +0 -1
  196. package/dist/plugins/types.d.ts +0 -76
  197. package/dist/properties/index.js +0 -223
  198. package/dist/properties/index.js.map +0 -1
  199. package/dist/properties/property-type-resolver.d.ts +0 -24
  200. package/dist/properties/property-type-resolver.js +0 -91
  201. package/dist/properties/property-type-resolver.js.map +0 -1
  202. package/dist/ssr/async-storage.d.ts +0 -17
  203. package/dist/ssr/async-storage.js +0 -35
  204. package/dist/ssr/async-storage.js.map +0 -1
  205. package/dist/ssr/collect-auto-properties.js +0 -40
  206. package/dist/ssr/collect-auto-properties.js.map +0 -1
  207. package/dist/ssr/collector.d.ts +0 -102
  208. package/dist/ssr/collector.js +0 -227
  209. package/dist/ssr/collector.js.map +0 -1
  210. package/dist/ssr/context.d.ts +0 -8
  211. package/dist/ssr/context.js +0 -14
  212. package/dist/ssr/context.js.map +0 -1
  213. package/dist/ssr/format-global-rules.js +0 -22
  214. package/dist/ssr/format-global-rules.js.map +0 -1
  215. package/dist/ssr/format-keyframes.js +0 -70
  216. package/dist/ssr/format-keyframes.js.map +0 -1
  217. package/dist/ssr/format-property.js +0 -50
  218. package/dist/ssr/format-property.js.map +0 -1
  219. package/dist/ssr/format-rules.js +0 -73
  220. package/dist/ssr/format-rules.js.map +0 -1
  221. package/dist/ssr/hydrate.d.ts +0 -22
  222. package/dist/ssr/hydrate.js +0 -50
  223. package/dist/ssr/hydrate.js.map +0 -1
  224. package/dist/ssr/ssr-collector-ref.js +0 -12
  225. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  226. package/dist/states/index.d.ts +0 -49
  227. package/dist/states/index.js +0 -171
  228. package/dist/states/index.js.map +0 -1
  229. package/dist/static/tastyStatic.d.ts +0 -46
  230. package/dist/static/tastyStatic.js +0 -31
  231. package/dist/static/tastyStatic.js.map +0 -1
  232. package/dist/static/types.d.ts +0 -49
  233. package/dist/static/types.js +0 -24
  234. package/dist/static/types.js.map +0 -1
  235. package/dist/styles/align.d.ts +0 -15
  236. package/dist/styles/align.js +0 -14
  237. package/dist/styles/align.js.map +0 -1
  238. package/dist/styles/border.d.ts +0 -25
  239. package/dist/styles/border.js +0 -114
  240. package/dist/styles/border.js.map +0 -1
  241. package/dist/styles/color.d.ts +0 -14
  242. package/dist/styles/color.js +0 -27
  243. package/dist/styles/color.js.map +0 -1
  244. package/dist/styles/createStyle.js +0 -80
  245. package/dist/styles/createStyle.js.map +0 -1
  246. package/dist/styles/dimension.js +0 -97
  247. package/dist/styles/dimension.js.map +0 -1
  248. package/dist/styles/display.d.ts +0 -37
  249. package/dist/styles/display.js +0 -67
  250. package/dist/styles/display.js.map +0 -1
  251. package/dist/styles/fade.d.ts +0 -15
  252. package/dist/styles/fade.js +0 -58
  253. package/dist/styles/fade.js.map +0 -1
  254. package/dist/styles/fill.d.ts +0 -42
  255. package/dist/styles/fill.js +0 -52
  256. package/dist/styles/fill.js.map +0 -1
  257. package/dist/styles/flow.d.ts +0 -16
  258. package/dist/styles/flow.js +0 -12
  259. package/dist/styles/flow.js.map +0 -1
  260. package/dist/styles/gap.d.ts +0 -31
  261. package/dist/styles/gap.js +0 -37
  262. package/dist/styles/gap.js.map +0 -1
  263. package/dist/styles/height.d.ts +0 -17
  264. package/dist/styles/height.js +0 -20
  265. package/dist/styles/height.js.map +0 -1
  266. package/dist/styles/index.d.ts +0 -2
  267. package/dist/styles/index.js +0 -9
  268. package/dist/styles/index.js.map +0 -1
  269. package/dist/styles/inset.d.ts +0 -52
  270. package/dist/styles/inset.js +0 -150
  271. package/dist/styles/inset.js.map +0 -1
  272. package/dist/styles/justify.d.ts +0 -15
  273. package/dist/styles/justify.js +0 -14
  274. package/dist/styles/justify.js.map +0 -1
  275. package/dist/styles/list.d.ts +0 -16
  276. package/dist/styles/list.js +0 -98
  277. package/dist/styles/list.js.map +0 -1
  278. package/dist/styles/margin.d.ts +0 -24
  279. package/dist/styles/margin.js +0 -104
  280. package/dist/styles/margin.js.map +0 -1
  281. package/dist/styles/outline.d.ts +0 -29
  282. package/dist/styles/outline.js +0 -65
  283. package/dist/styles/outline.js.map +0 -1
  284. package/dist/styles/padding.d.ts +0 -24
  285. package/dist/styles/padding.js +0 -104
  286. package/dist/styles/padding.js.map +0 -1
  287. package/dist/styles/predefined.d.ts +0 -71
  288. package/dist/styles/predefined.js +0 -238
  289. package/dist/styles/predefined.js.map +0 -1
  290. package/dist/styles/preset.d.ts +0 -52
  291. package/dist/styles/preset.js +0 -127
  292. package/dist/styles/preset.js.map +0 -1
  293. package/dist/styles/radius.d.ts +0 -14
  294. package/dist/styles/radius.js +0 -51
  295. package/dist/styles/radius.js.map +0 -1
  296. package/dist/styles/scrollbar.d.ts +0 -25
  297. package/dist/styles/scrollbar.js +0 -48
  298. package/dist/styles/scrollbar.js.map +0 -1
  299. package/dist/styles/shadow.d.ts +0 -14
  300. package/dist/styles/shadow.js +0 -24
  301. package/dist/styles/shadow.js.map +0 -1
  302. package/dist/styles/transition.d.ts +0 -14
  303. package/dist/styles/transition.js +0 -158
  304. package/dist/styles/transition.js.map +0 -1
  305. package/dist/styles/types.d.ts +0 -547
  306. package/dist/styles/width.d.ts +0 -17
  307. package/dist/styles/width.js +0 -20
  308. package/dist/styles/width.js.map +0 -1
  309. package/dist/tasty.d.ts +0 -119
  310. package/dist/tasty.js +0 -232
  311. package/dist/tasty.js.map +0 -1
  312. package/dist/types.d.ts +0 -184
  313. package/dist/utils/cache-wrapper.js +0 -22
  314. package/dist/utils/cache-wrapper.js.map +0 -1
  315. package/dist/utils/case-converter.js +0 -8
  316. package/dist/utils/case-converter.js.map +0 -1
  317. package/dist/utils/color-math.d.ts +0 -46
  318. package/dist/utils/color-math.js +0 -749
  319. package/dist/utils/color-math.js.map +0 -1
  320. package/dist/utils/color-space.d.ts +0 -5
  321. package/dist/utils/color-space.js +0 -229
  322. package/dist/utils/color-space.js.map +0 -1
  323. package/dist/utils/colors.d.ts +0 -5
  324. package/dist/utils/colors.js +0 -11
  325. package/dist/utils/colors.js.map +0 -1
  326. package/dist/utils/css-types.d.ts +0 -7
  327. package/dist/utils/dotize.d.ts +0 -26
  328. package/dist/utils/dotize.js +0 -122
  329. package/dist/utils/dotize.js.map +0 -1
  330. package/dist/utils/filter-base-props.d.ts +0 -15
  331. package/dist/utils/filter-base-props.js +0 -45
  332. package/dist/utils/filter-base-props.js.map +0 -1
  333. package/dist/utils/get-display-name.d.ts +0 -7
  334. package/dist/utils/get-display-name.js +0 -10
  335. package/dist/utils/get-display-name.js.map +0 -1
  336. package/dist/utils/has-keys.js +0 -13
  337. package/dist/utils/has-keys.js.map +0 -1
  338. package/dist/utils/is-dev-env.js +0 -19
  339. package/dist/utils/is-dev-env.js.map +0 -1
  340. package/dist/utils/is-valid-element-type.js +0 -15
  341. package/dist/utils/is-valid-element-type.js.map +0 -1
  342. package/dist/utils/merge-styles.js.map +0 -1
  343. package/dist/utils/mod-attrs.d.ts +0 -8
  344. package/dist/utils/mod-attrs.js +0 -21
  345. package/dist/utils/mod-attrs.js.map +0 -1
  346. package/dist/utils/process-tokens.d.ts +0 -21
  347. package/dist/utils/process-tokens.js +0 -91
  348. package/dist/utils/process-tokens.js.map +0 -1
  349. package/dist/utils/resolve-recipes.d.ts +0 -17
  350. package/dist/utils/resolve-recipes.js +0 -147
  351. package/dist/utils/resolve-recipes.js.map +0 -1
  352. package/dist/utils/selector-transform.js +0 -32
  353. package/dist/utils/selector-transform.js.map +0 -1
  354. package/dist/utils/string.js +0 -8
  355. package/dist/utils/string.js.map +0 -1
  356. package/dist/utils/styles.d.ts +0 -99
  357. package/dist/utils/styles.js +0 -221
  358. package/dist/utils/styles.js.map +0 -1
  359. package/dist/utils/typography.d.ts +0 -47
  360. package/dist/utils/typography.js +0 -51
  361. package/dist/utils/typography.js.map +0 -1
  362. package/dist/utils/warnings.d.ts +0 -16
  363. package/dist/utils/warnings.js +0 -16
  364. package/dist/utils/warnings.js.map +0 -1
  365. package/dist/zero/css-writer.d.ts +0 -45
  366. package/dist/zero/css-writer.js +0 -74
  367. package/dist/zero/css-writer.js.map +0 -1
  368. package/dist/zero/extractor.d.ts +0 -24
  369. package/dist/zero/extractor.js +0 -267
  370. package/dist/zero/extractor.js.map +0 -1
  371. package/docs/PIPELINE.md +0 -519
  372. package/docs/runtime.md +0 -485
@@ -1,123 +1,9 @@
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
-
1
+ import { t as TastyZeroConfig } from "../babel-types-Dc5zghyE.js";
9
2
  //#region src/zero/babel.d.ts
10
3
  /**
11
- * Build-time configuration for zero-runtime mode.
12
- * Subset of TastyConfig that applies at build time.
4
+ * Options for the `@tenphi/tasty/babel-plugin` Babel plugin.
13
5
  */
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 {
6
+ export interface TastyZeroBabelOptions {
121
7
  /** Output path for generated CSS (default: 'tasty.css') */
122
8
  output?: string;
123
9
  /**
@@ -158,10 +44,30 @@ interface TastyZeroBabelOptions {
158
44
  * @default true
159
45
  */
160
46
  injectImport?: boolean;
47
+ /**
48
+ * Output mode for extracted CSS.
49
+ *
50
+ * - `'file'` (default): CSS is written to a single output file and
51
+ * the `@tenphi/tasty/static` import is rewritten to import that file.
52
+ * - `'inject'`: CSS is embedded inline in the JS output and injected
53
+ * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
54
+ * No CSS file is written. Each `tastyStatic` call becomes
55
+ * self-contained. Best for reusable components and extensions.
56
+ *
57
+ * When `mode` is `'inject'`, `output` and `injectImport` are ignored.
58
+ *
59
+ * @default 'file'
60
+ */
61
+ mode?: 'file' | 'inject';
161
62
  }
162
- /** Clear the shared CSSWriter cache. Exposed for testing. */
163
- declare function clearWriterCache(): void;
164
- declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _babel_core0.PluginObj<PluginPass>;
63
+ /**
64
+ * The plugin's call signature, written out rather than inferred from
65
+ * `declare()` so the published declaration names no Babel types: Babel 7's
66
+ * come from `@types/babel__core`, Babel 8 ships its own, and the two name the
67
+ * plugin object differently.
68
+ */
69
+ type TastyZeroBabelPlugin = (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => object;
70
+ declare const _default: TastyZeroBabelPlugin;
165
71
  //#endregion
166
- export { TastyZeroBabelOptions, TastyZeroConfig, clearWriterCache, _default as default };
72
+ export { type TastyZeroConfig, _default as default };
167
73
  //# sourceMappingURL=babel.d.ts.map
@@ -1,34 +1,23 @@
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";
1
+ import { t as mergeStyles } from "../chunks/shared-utils-y-HjvPN4.js";
2
+ import "../chunks/css-definitions-B4aWBkH3.js";
3
+ import { t as resolveRecipesWith } from "../chunks/config-engine-CMYFZYQh.js";
4
+ import { a as resetZeroConfig, i as reapplyZeroConfig, n as functionsForExtraction, t as configureZero } from "../chunks/build-config-D9Iq8QQm.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-DcwaCvFs.js";
6
+ import { t as loadConfigFile } from "../chunks/config-file-DlZXJMj8.js";
7
7
  import * as fs from "fs";
8
8
  import * as path from "path";
9
9
  import { declare } from "@babel/helper-plugin-utils";
10
10
  import * as t from "@babel/types";
11
- import { createJiti } from "jiti";
12
-
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
13
20
  //#region src/zero/babel.ts
14
- /**
15
- * Babel plugin for zero-runtime tasty static site generation.
16
- *
17
- * Transforms:
18
- * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }
19
- * - `tastyStatic(base, styles)` → StaticStyle object with merged styles
20
- * - `tastyStatic(selector, styles)` → removed entirely
21
- *
22
- * Usage:
23
- * ```javascript
24
- * // babel.config.js
25
- * module.exports = {
26
- * plugins: [
27
- * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]
28
- * ]
29
- * };
30
- * ```
31
- */
32
21
  function mtime(filePath) {
33
22
  try {
34
23
  return fs.statSync(filePath).mtimeMs;
@@ -51,17 +40,13 @@ function clearRequireCacheTree(filePath) {
51
40
  }
52
41
  delete __require.cache[resolved];
53
42
  }
54
- const writerCache = /* @__PURE__ */ new Map();
55
- /** Clear the shared CSSWriter cache. Exposed for testing. */
56
- function clearWriterCache() {
57
- writerCache.clear();
58
- }
59
- var babel_default = declare((api, options) => {
60
- api.assertVersion(7);
43
+ const plugin = declare((api, options) => {
44
+ api.assertVersion("^7.0.0-0 || ^8.0.0-0");
45
+ const mode = options.mode ?? "file";
61
46
  const outputPath = options.output || "tasty.css";
62
47
  const resolvedOutputPath = path.resolve(outputPath);
63
48
  const injectImport = options.injectImport ?? true;
64
- if (injectImport) {
49
+ if (mode === "file" && injectImport) {
65
50
  const dir = path.dirname(resolvedOutputPath);
66
51
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
67
52
  if (!fs.existsSync(resolvedOutputPath)) fs.writeFileSync(resolvedOutputPath, "/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\n");
@@ -80,32 +65,64 @@ var babel_default = declare((api, options) => {
80
65
  const configOption = options.config;
81
66
  let resolvedConfig;
82
67
  if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
83
- else if (options.configFile) resolvedConfig = createJiti(path.dirname(options.configFile), { moduleCache: false })(options.configFile);
68
+ else if (options.configFile) resolvedConfig = loadConfigFile(options.configFile);
84
69
  else resolvedConfig = {};
85
70
  const devMode = resolvedConfig.devMode ?? false;
86
- if (cached) resetConfig();
87
- configure(resolvedConfig);
71
+ resetZeroConfig();
72
+ const finalConfig = {
73
+ namePrefix: "ts",
74
+ ...resolvedConfig
75
+ };
76
+ const config = configureZero(finalConfig);
77
+ setExtractorNamePrefix(finalConfig.namePrefix ?? "ts");
88
78
  const newWriter = new CSSWriter(outputPath, { devMode });
89
- const tokenStyles = getGlobalConfigTokens();
90
- if (tokenStyles && Object.keys(tokenStyles).length > 0) {
91
- const result = extractStylesForSelector(":root", tokenStyles);
92
- if (result.css) newWriter.add(":root:tokens", result.css);
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);
93
84
  }
94
85
  writerCache.set(resolvedOutputPath, {
95
86
  writer: newWriter,
96
87
  configKey,
97
88
  registry: {},
98
- config: resolvedConfig
89
+ config
99
90
  });
100
91
  }
101
92
  const entry = writerCache.get(resolvedOutputPath);
93
+ entry.config = reapplyZeroConfig(entry.config);
102
94
  const cssWriter = entry.writer;
103
95
  const globalRegistry = entry.registry;
104
96
  const config = entry.config;
105
- const devMode = config.devMode ?? false;
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
+ }
106
121
  return {
107
122
  name: "tasty-zero",
108
123
  pre() {
124
+ entry.config = reapplyZeroConfig(entry.config);
125
+ setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
109
126
  this.staticStyleRegistry = {};
110
127
  this._fileAddedCSS = false;
111
128
  if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
@@ -113,15 +130,18 @@ var babel_default = declare((api, options) => {
113
130
  visitor: {
114
131
  ImportDeclaration(nodePath, state) {
115
132
  const source = nodePath.node.source.value;
116
- if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) if (injectImport) {
117
- let importPath = resolvedOutputPath;
118
- if (state.filename) {
119
- const sourceDir = path.dirname(state.filename);
120
- importPath = path.relative(sourceDir, resolvedOutputPath);
121
- if (!importPath.startsWith(".")) importPath = "./" + importPath;
122
- }
123
- nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
124
- } else nodePath.remove();
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
+ }
125
145
  },
126
146
  CallExpression(path, state) {
127
147
  const callee = path.node.callee;
@@ -130,9 +150,9 @@ var babel_default = declare((api, options) => {
130
150
  const args = path.node.arguments;
131
151
  if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
132
152
  const firstArg = args[0];
133
- if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, state.sourceFile, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
134
- else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
135
- else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
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);
136
156
  else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
137
157
  },
138
158
  VariableDeclarator(path, state) {
@@ -156,59 +176,69 @@ var babel_default = declare((api, options) => {
156
176
  }
157
177
  },
158
178
  post() {
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
+ }
159
202
  if (this._fileAddedCSS && cssWriter.size > 0) cssWriter.write();
160
203
  }
161
204
  };
162
205
  });
163
- /**
164
- * Check if an object expression looks like a StaticStyle object
165
- */
166
206
  function isStaticStyleObject(node) {
167
207
  const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
168
208
  const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
169
209
  return hasClassName && hasStyles;
170
210
  }
171
- /**
172
- * Extract styles object from a StaticStyle object expression
173
- */
174
211
  function extractStylesFromStaticStyleObject(node, path) {
175
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);
176
213
  return null;
177
214
  }
178
- /**
179
- * Extract className from a StaticStyle object expression
180
- */
181
215
  function extractClassNameFromStaticStyleObject(node) {
182
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;
183
217
  return null;
184
218
  }
185
- /**
186
- * Handle tastyStatic(styles) - returns StaticStyle object
187
- */
188
- function handleStylesMode(path, args, cssWriter, state, globalRegistry, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
219
+ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
189
220
  const stylesArg = args[0];
190
221
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
191
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
222
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
223
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
192
224
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
193
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
194
- const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
195
- for (const prop of properties) cssWriter.add(prop.css, prop.css, state.sourceFile);
196
- for (const ff of extractFontFaceFromStyles(styles, globalFontFace)) cssWriter.add(ff.css, ff.css, state.sourceFile);
197
- for (const cs of extractCounterStyleFromStyles(styles, globalCounterStyle)) cssWriter.add(cs.css, cs.css, state.sourceFile);
198
- const chunks = extractStylesWithChunks(styles);
199
- for (const chunk of chunks) {
200
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
201
- cssWriter.add(chunk.className, css, state.sourceFile);
202
- }
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);
203
230
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
204
231
  const staticStyleObject = createStaticStyleAST(className, styles);
205
- 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
+ }
206
239
  registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
207
240
  }
208
- /**
209
- * Handle tastyStatic(base, styles) - extends base with additional styles
210
- */
211
- function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
241
+ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
212
242
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
213
243
  const baseArg = args[0];
214
244
  const stylesArg = args[1];
@@ -218,50 +248,94 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globa
218
248
  const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
219
249
  if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
220
250
  const overrideStyles = evaluateObjectExpression(stylesArg, path);
221
- const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
251
+ const mergedStyles = resolveRecipesWith(mergeStyles(baseEntry.styles, overrideStyles), globalRecipes ?? null);
222
252
  const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
223
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
224
- const properties = extractPropertiesFromStyles(mergedStyles, { autoPropertyTypes });
225
- for (const prop of properties) cssWriter.add(prop.css, prop.css, state.sourceFile);
226
- for (const ff of extractFontFaceFromStyles(mergedStyles, globalFontFace)) cssWriter.add(ff.css, ff.css, state.sourceFile);
227
- for (const cs of extractCounterStyleFromStyles(mergedStyles, globalCounterStyle)) cssWriter.add(cs.css, cs.css, state.sourceFile);
228
- const chunks = extractStylesWithChunks(mergedStyles);
229
- for (const chunk of chunks) {
230
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
231
- cssWriter.add(chunk.className, css, state.sourceFile);
232
- }
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);
233
258
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
234
259
  const staticStyleObject = createStaticStyleAST(className, mergedStyles);
235
- 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
+ }
236
267
  registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
237
268
  }
238
- /**
239
- * Handle tastyStatic(selector, styles) - removes the call entirely
240
- */
241
- function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
269
+ function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
242
270
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
243
271
  const selectorArg = args[0];
244
272
  const stylesArg = args[1];
245
273
  if (!t.isStringLiteral(selectorArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) first argument must be a string literal");
246
274
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) second argument must be a static object literal");
247
275
  const selector = selectorArg.value;
248
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
276
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
277
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
249
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) {
250
316
  for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
251
- const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
252
317
  for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
253
- for (const ff of extractFontFaceFromStyles(styles, globalFontFace)) cssWriter.add(ff.css, ff.css, sourceFile);
254
- for (const cs of extractCounterStyleFromStyles(styles, globalCounterStyle)) cssWriter.add(cs.css, cs.css, sourceFile);
255
- const result = extractStylesForSelector(selector, styles);
256
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
257
- cssWriter.add(selector, css, sourceFile);
258
- const parent = path.parentPath;
259
- if (parent && t.isExpressionStatement(parent.node)) parent.remove();
260
- else path.replaceWith(t.identifier("undefined"));
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)]);
261
338
  }
262
- /**
263
- * Create a StaticStyle object AST node
264
- */
265
339
  function createStaticStyleAST(className, styles) {
266
340
  return t.objectExpression([
267
341
  t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
@@ -269,9 +343,6 @@ function createStaticStyleAST(className, styles) {
269
343
  t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
270
344
  ]);
271
345
  }
272
- /**
273
- * Register a StaticStyle in the registry if it's being assigned to a variable
274
- */
275
346
  function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
276
347
  const parent = path.parentPath;
277
348
  if (parent && t.isVariableDeclarator(parent.node)) {
@@ -289,14 +360,11 @@ function registerIfVariableDeclaration(path, className, styles, state, globalReg
289
360
  }
290
361
  }
291
362
  }
292
- /**
293
- * Convert a JavaScript value to an AST node
294
- */
295
363
  function valueToAST(value) {
296
364
  if (value === null) return t.nullLiteral();
297
365
  if (value === void 0) return t.identifier("undefined");
298
366
  if (typeof value === "string") return t.stringLiteral(value);
299
- if (typeof value === "number") return t.numericLiteral(value);
367
+ if (typeof value === "number") return t.valueToNode(value);
300
368
  if (typeof value === "boolean") return t.booleanLiteral(value);
301
369
  if (Array.isArray(value)) return t.arrayExpression(value.map(valueToAST));
302
370
  if (typeof value === "object") {
@@ -305,10 +373,6 @@ function valueToAST(value) {
305
373
  }
306
374
  return t.identifier("undefined");
307
375
  }
308
- /**
309
- * Evaluate an ObjectExpression to a plain JavaScript object.
310
- * Only supports static values that can be determined at build time.
311
- */
312
376
  function evaluateObjectExpression(node, path) {
313
377
  const result = {};
314
378
  for (const prop of node.properties) {
@@ -318,13 +382,11 @@ function evaluateObjectExpression(node, path) {
318
382
  if (t.isIdentifier(prop.key)) key = prop.key.name;
319
383
  else if (t.isStringLiteral(prop.key)) key = prop.key.value;
320
384
  else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
321
- result[key] = evaluateExpression(prop.value, path);
385
+ const value = evaluateExpression(prop.value, path);
386
+ result[key] = value;
322
387
  }
323
388
  return result;
324
389
  }
325
- /**
326
- * Evaluate an expression to a JavaScript value.
327
- */
328
390
  function evaluateExpression(node, path) {
329
391
  if (t.isStringLiteral(node)) return node.value;
330
392
  if (t.isNumericLiteral(node)) return node.value;
@@ -347,28 +409,7 @@ function evaluateExpression(node, path) {
347
409
  }
348
410
  throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
349
411
  }
350
- /**
351
- * Replace animation names in CSS string.
352
- * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
353
- */
354
- function replaceAnimationNamesInCSS(css, nameMap) {
355
- if (nameMap.size === 0) return css;
356
- return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
357
- let newValue = value;
358
- for (const [original, replacement] of nameMap) {
359
- const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
360
- newValue = newValue.replace(pattern, replacement);
361
- }
362
- return `${prop}: ${newValue}`;
363
- });
364
- }
365
- /**
366
- * Escape special regex characters.
367
- */
368
- function escapeRegex(str) {
369
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
370
- }
371
-
372
412
  //#endregion
373
- export { clearWriterCache, babel_default as default };
413
+ export { plugin as default };
414
+
374
415
  //# sourceMappingURL=babel.js.map