@tenphi/tasty 0.0.0-snapshot.e4aff73 → 0.0.0-snapshot.e4e4347

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 (360) hide show
  1. package/README.md +441 -362
  2. package/dist/babel-types-BKDTT4--.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-5d8WlQbq.js +60 -0
  6. package/dist/chunks/build-config-5d8WlQbq.js.map +1 -0
  7. package/dist/chunks/collector-CjCak4iE.js +210 -0
  8. package/dist/chunks/collector-CjCak4iE.js.map +1 -0
  9. package/dist/chunks/config-engine-uOFYZidB.js +272 -0
  10. package/dist/chunks/config-engine-uOFYZidB.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-ubrHP97m.js +910 -0
  14. package/dist/chunks/css-definitions-ubrHP97m.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-CJ31U_WE.js} +197 -149
  18. package/dist/chunks/debug-CJ31U_WE.js.map +1 -0
  19. package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
  20. package/dist/chunks/dsl-DYSJc1-T.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-CyyCI02N.js +689 -0
  24. package/dist/chunks/react-runtime-CyyCI02N.js.map +1 -0
  25. package/dist/chunks/runtime-engine-BQmOu5-W.js +2432 -0
  26. package/dist/chunks/runtime-engine-BQmOu5-W.js.map +1 -0
  27. package/dist/chunks/runtime-state-DEsyUMU-.js +152 -0
  28. package/dist/chunks/runtime-state-DEsyUMU-.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-BX2LshDZ.js +5466 -0
  32. package/dist/chunks/style-engine-BX2LshDZ.js.map +1 -0
  33. package/dist/chunks/zero-engine-Dw0P4yGM.js +310 -0
  34. package/dist/chunks/zero-engine-Dw0P4yGM.js.map +1 -0
  35. package/dist/collector-CTU-nl0g.d.ts +164 -0
  36. package/dist/config-CcxqSZI2.d.ts +1368 -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-xtey-KDu.d.ts +1950 -0
  41. package/dist/index.d.ts +5 -49
  42. package/dist/index.js +11 -34
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-DSkVc6CD.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-DJEM_BOJ.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +20 -108
  81. package/dist/zero/babel.js +211 -142
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +135 -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 +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 +255 -0
  92. package/docs/comparison.md +83 -54
  93. package/docs/configuration.md +764 -74
  94. package/docs/debug.md +39 -24
  95. package/docs/design-system.md +187 -37
  96. package/docs/dsl.md +711 -164
  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 +742 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +403 -149
  106. package/docs/styles.md +200 -45
  107. package/docs/tasty-static.md +354 -99
  108. package/package.json +153 -35
  109. package/tasty.config.ts +6 -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 -323
  119. package/dist/config.js +0 -465
  120. package/dist/config.js.map +0 -1
  121. package/dist/debug.d.ts +0 -89
  122. package/dist/debug.js.map +0 -1
  123. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  124. package/dist/hooks/useGlobalStyles.js +0 -83
  125. package/dist/hooks/useGlobalStyles.js.map +0 -1
  126. package/dist/hooks/useKeyframes.d.ts +0 -56
  127. package/dist/hooks/useKeyframes.js +0 -69
  128. package/dist/hooks/useKeyframes.js.map +0 -1
  129. package/dist/hooks/useProperty.d.ts +0 -79
  130. package/dist/hooks/useProperty.js +0 -114
  131. package/dist/hooks/useProperty.js.map +0 -1
  132. package/dist/hooks/useRawCSS.d.ts +0 -53
  133. package/dist/hooks/useRawCSS.js +0 -40
  134. package/dist/hooks/useRawCSS.js.map +0 -1
  135. package/dist/hooks/useStyles.d.ts +0 -45
  136. package/dist/hooks/useStyles.js +0 -249
  137. package/dist/hooks/useStyles.js.map +0 -1
  138. package/dist/injector/index.d.ts +0 -165
  139. package/dist/injector/index.js +0 -162
  140. package/dist/injector/index.js.map +0 -1
  141. package/dist/injector/injector.d.ts +0 -148
  142. package/dist/injector/injector.js +0 -430
  143. package/dist/injector/injector.js.map +0 -1
  144. package/dist/injector/sheet-manager.d.ts +0 -136
  145. package/dist/injector/sheet-manager.js +0 -729
  146. package/dist/injector/sheet-manager.js.map +0 -1
  147. package/dist/injector/types.d.ts +0 -144
  148. package/dist/keyframes/index.js +0 -206
  149. package/dist/keyframes/index.js.map +0 -1
  150. package/dist/parser/classify.js +0 -320
  151. package/dist/parser/classify.js.map +0 -1
  152. package/dist/parser/const.js +0 -33
  153. package/dist/parser/const.js.map +0 -1
  154. package/dist/parser/lru.js +0 -109
  155. package/dist/parser/lru.js.map +0 -1
  156. package/dist/parser/parser.d.ts +0 -25
  157. package/dist/parser/parser.js +0 -116
  158. package/dist/parser/parser.js.map +0 -1
  159. package/dist/parser/tokenizer.js +0 -69
  160. package/dist/parser/tokenizer.js.map +0 -1
  161. package/dist/parser/types.d.ts +0 -51
  162. package/dist/parser/types.js +0 -46
  163. package/dist/parser/types.js.map +0 -1
  164. package/dist/pipeline/conditions.d.ts +0 -134
  165. package/dist/pipeline/conditions.js +0 -406
  166. package/dist/pipeline/conditions.js.map +0 -1
  167. package/dist/pipeline/exclusive.js +0 -231
  168. package/dist/pipeline/exclusive.js.map +0 -1
  169. package/dist/pipeline/index.d.ts +0 -53
  170. package/dist/pipeline/index.js +0 -681
  171. package/dist/pipeline/index.js.map +0 -1
  172. package/dist/pipeline/materialize.js +0 -1105
  173. package/dist/pipeline/materialize.js.map +0 -1
  174. package/dist/pipeline/parseStateKey.d.ts +0 -15
  175. package/dist/pipeline/parseStateKey.js +0 -447
  176. package/dist/pipeline/parseStateKey.js.map +0 -1
  177. package/dist/pipeline/simplify.js +0 -516
  178. package/dist/pipeline/simplify.js.map +0 -1
  179. package/dist/pipeline/warnings.js +0 -18
  180. package/dist/pipeline/warnings.js.map +0 -1
  181. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  182. package/dist/plugins/okhsl-plugin.js +0 -98
  183. package/dist/plugins/okhsl-plugin.js.map +0 -1
  184. package/dist/plugins/types.d.ts +0 -76
  185. package/dist/properties/index.js +0 -223
  186. package/dist/properties/index.js.map +0 -1
  187. package/dist/properties/property-type-resolver.d.ts +0 -24
  188. package/dist/properties/property-type-resolver.js +0 -91
  189. package/dist/properties/property-type-resolver.js.map +0 -1
  190. package/dist/ssr/async-storage.d.ts +0 -17
  191. package/dist/ssr/async-storage.js +0 -35
  192. package/dist/ssr/async-storage.js.map +0 -1
  193. package/dist/ssr/collect-auto-properties.js +0 -40
  194. package/dist/ssr/collect-auto-properties.js.map +0 -1
  195. package/dist/ssr/collector.d.ts +0 -85
  196. package/dist/ssr/collector.js +0 -183
  197. package/dist/ssr/collector.js.map +0 -1
  198. package/dist/ssr/context.d.ts +0 -8
  199. package/dist/ssr/context.js +0 -14
  200. package/dist/ssr/context.js.map +0 -1
  201. package/dist/ssr/format-global-rules.js +0 -22
  202. package/dist/ssr/format-global-rules.js.map +0 -1
  203. package/dist/ssr/format-keyframes.js +0 -70
  204. package/dist/ssr/format-keyframes.js.map +0 -1
  205. package/dist/ssr/format-property.js +0 -50
  206. package/dist/ssr/format-property.js.map +0 -1
  207. package/dist/ssr/format-rules.js +0 -70
  208. package/dist/ssr/format-rules.js.map +0 -1
  209. package/dist/ssr/hydrate.d.ts +0 -22
  210. package/dist/ssr/hydrate.js +0 -50
  211. package/dist/ssr/hydrate.js.map +0 -1
  212. package/dist/ssr/ssr-collector-ref.js +0 -12
  213. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  214. package/dist/states/index.d.ts +0 -49
  215. package/dist/states/index.js +0 -169
  216. package/dist/states/index.js.map +0 -1
  217. package/dist/static/tastyStatic.d.ts +0 -46
  218. package/dist/static/tastyStatic.js +0 -31
  219. package/dist/static/tastyStatic.js.map +0 -1
  220. package/dist/static/types.d.ts +0 -49
  221. package/dist/static/types.js +0 -24
  222. package/dist/static/types.js.map +0 -1
  223. package/dist/styles/align.d.ts +0 -15
  224. package/dist/styles/align.js +0 -14
  225. package/dist/styles/align.js.map +0 -1
  226. package/dist/styles/border.d.ts +0 -25
  227. package/dist/styles/border.js +0 -114
  228. package/dist/styles/border.js.map +0 -1
  229. package/dist/styles/color.d.ts +0 -14
  230. package/dist/styles/color.js +0 -27
  231. package/dist/styles/color.js.map +0 -1
  232. package/dist/styles/createStyle.js +0 -80
  233. package/dist/styles/createStyle.js.map +0 -1
  234. package/dist/styles/dimension.js +0 -97
  235. package/dist/styles/dimension.js.map +0 -1
  236. package/dist/styles/display.d.ts +0 -37
  237. package/dist/styles/display.js +0 -67
  238. package/dist/styles/display.js.map +0 -1
  239. package/dist/styles/fade.d.ts +0 -15
  240. package/dist/styles/fade.js +0 -58
  241. package/dist/styles/fade.js.map +0 -1
  242. package/dist/styles/fill.d.ts +0 -42
  243. package/dist/styles/fill.js +0 -52
  244. package/dist/styles/fill.js.map +0 -1
  245. package/dist/styles/flow.d.ts +0 -16
  246. package/dist/styles/flow.js +0 -12
  247. package/dist/styles/flow.js.map +0 -1
  248. package/dist/styles/gap.d.ts +0 -31
  249. package/dist/styles/gap.js +0 -37
  250. package/dist/styles/gap.js.map +0 -1
  251. package/dist/styles/height.d.ts +0 -17
  252. package/dist/styles/height.js +0 -20
  253. package/dist/styles/height.js.map +0 -1
  254. package/dist/styles/index.d.ts +0 -2
  255. package/dist/styles/index.js +0 -9
  256. package/dist/styles/index.js.map +0 -1
  257. package/dist/styles/inset.d.ts +0 -52
  258. package/dist/styles/inset.js +0 -150
  259. package/dist/styles/inset.js.map +0 -1
  260. package/dist/styles/justify.d.ts +0 -15
  261. package/dist/styles/justify.js +0 -14
  262. package/dist/styles/justify.js.map +0 -1
  263. package/dist/styles/list.d.ts +0 -16
  264. package/dist/styles/list.js +0 -98
  265. package/dist/styles/list.js.map +0 -1
  266. package/dist/styles/margin.d.ts +0 -24
  267. package/dist/styles/margin.js +0 -104
  268. package/dist/styles/margin.js.map +0 -1
  269. package/dist/styles/outline.d.ts +0 -29
  270. package/dist/styles/outline.js +0 -65
  271. package/dist/styles/outline.js.map +0 -1
  272. package/dist/styles/padding.d.ts +0 -24
  273. package/dist/styles/padding.js +0 -104
  274. package/dist/styles/padding.js.map +0 -1
  275. package/dist/styles/predefined.d.ts +0 -71
  276. package/dist/styles/predefined.js +0 -238
  277. package/dist/styles/predefined.js.map +0 -1
  278. package/dist/styles/preset.d.ts +0 -47
  279. package/dist/styles/preset.js +0 -126
  280. package/dist/styles/preset.js.map +0 -1
  281. package/dist/styles/radius.d.ts +0 -14
  282. package/dist/styles/radius.js +0 -51
  283. package/dist/styles/radius.js.map +0 -1
  284. package/dist/styles/scrollbar.d.ts +0 -25
  285. package/dist/styles/scrollbar.js +0 -48
  286. package/dist/styles/scrollbar.js.map +0 -1
  287. package/dist/styles/shadow.d.ts +0 -14
  288. package/dist/styles/shadow.js +0 -24
  289. package/dist/styles/shadow.js.map +0 -1
  290. package/dist/styles/transition.d.ts +0 -14
  291. package/dist/styles/transition.js +0 -158
  292. package/dist/styles/transition.js.map +0 -1
  293. package/dist/styles/types.d.ts +0 -523
  294. package/dist/styles/width.d.ts +0 -17
  295. package/dist/styles/width.js +0 -20
  296. package/dist/styles/width.js.map +0 -1
  297. package/dist/tasty.d.ts +0 -114
  298. package/dist/tasty.js +0 -232
  299. package/dist/tasty.js.map +0 -1
  300. package/dist/types.d.ts +0 -184
  301. package/dist/utils/cache-wrapper.js +0 -22
  302. package/dist/utils/cache-wrapper.js.map +0 -1
  303. package/dist/utils/case-converter.js +0 -8
  304. package/dist/utils/case-converter.js.map +0 -1
  305. package/dist/utils/color-math.d.ts +0 -46
  306. package/dist/utils/color-math.js +0 -749
  307. package/dist/utils/color-math.js.map +0 -1
  308. package/dist/utils/color-space.d.ts +0 -5
  309. package/dist/utils/color-space.js +0 -229
  310. package/dist/utils/color-space.js.map +0 -1
  311. package/dist/utils/colors.d.ts +0 -5
  312. package/dist/utils/colors.js +0 -11
  313. package/dist/utils/colors.js.map +0 -1
  314. package/dist/utils/css-types.d.ts +0 -7
  315. package/dist/utils/dotize.d.ts +0 -26
  316. package/dist/utils/dotize.js +0 -122
  317. package/dist/utils/dotize.js.map +0 -1
  318. package/dist/utils/filter-base-props.d.ts +0 -15
  319. package/dist/utils/filter-base-props.js +0 -45
  320. package/dist/utils/filter-base-props.js.map +0 -1
  321. package/dist/utils/get-display-name.d.ts +0 -7
  322. package/dist/utils/get-display-name.js +0 -10
  323. package/dist/utils/get-display-name.js.map +0 -1
  324. package/dist/utils/has-keys.js +0 -13
  325. package/dist/utils/has-keys.js.map +0 -1
  326. package/dist/utils/is-dev-env.js +0 -19
  327. package/dist/utils/is-dev-env.js.map +0 -1
  328. package/dist/utils/is-valid-element-type.js +0 -15
  329. package/dist/utils/is-valid-element-type.js.map +0 -1
  330. package/dist/utils/merge-styles.js.map +0 -1
  331. package/dist/utils/mod-attrs.d.ts +0 -8
  332. package/dist/utils/mod-attrs.js +0 -21
  333. package/dist/utils/mod-attrs.js.map +0 -1
  334. package/dist/utils/process-tokens.d.ts +0 -21
  335. package/dist/utils/process-tokens.js +0 -91
  336. package/dist/utils/process-tokens.js.map +0 -1
  337. package/dist/utils/resolve-recipes.d.ts +0 -17
  338. package/dist/utils/resolve-recipes.js +0 -147
  339. package/dist/utils/resolve-recipes.js.map +0 -1
  340. package/dist/utils/selector-transform.js +0 -32
  341. package/dist/utils/selector-transform.js.map +0 -1
  342. package/dist/utils/string.js +0 -8
  343. package/dist/utils/string.js.map +0 -1
  344. package/dist/utils/styles.d.ts +0 -101
  345. package/dist/utils/styles.js +0 -223
  346. package/dist/utils/styles.js.map +0 -1
  347. package/dist/utils/typography.d.ts +0 -47
  348. package/dist/utils/typography.js +0 -43
  349. package/dist/utils/typography.js.map +0 -1
  350. package/dist/utils/warnings.d.ts +0 -16
  351. package/dist/utils/warnings.js +0 -16
  352. package/dist/utils/warnings.js.map +0 -1
  353. package/dist/zero/css-writer.d.ts +0 -45
  354. package/dist/zero/css-writer.js +0 -74
  355. package/dist/zero/css-writer.js.map +0 -1
  356. package/dist/zero/extractor.d.ts +0 -24
  357. package/dist/zero/extractor.js +0 -215
  358. package/dist/zero/extractor.js.map +0 -1
  359. package/docs/PIPELINE.md +0 -519
  360. package/docs/runtime.md +0 -397
@@ -1,113 +1,10 @@
1
- import { 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";
1
+ import { t as TastyZeroConfig } from "../babel-types-BKDTT4--.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>;
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
- * 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
- * ```
78
- */
79
- handlers?: Record<string, StyleHandlerDefinition>;
80
- /**
81
- * Design tokens injected as CSS custom properties on `:root`.
82
- * Values are parsed through the Tasty DSL. Supports state maps.
83
- * @example { '$gap': '4px', '#primary': { '': '#purple', '@dark': '#light-purple' } }
84
- */
85
- tokens?: ConfigTokens;
86
- /**
87
- * Predefined tokens replaced during style parsing (parse-time substitution).
88
- * Use `$name` for custom properties and `#name` for color tokens.
89
- * @example { $spacing: '2x', '#accent': '#purple' }
90
- */
91
- replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
92
- /**
93
- * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
94
- * Recipe values are flat tasty styles (no sub-element keys).
95
- * @example
96
- * ```ts
97
- * recipes: {
98
- * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
99
- * elevated: { shadow: '2x 2x 4x #shadow' },
100
- * }
101
- * ```
102
- */
103
- recipes?: Record<string, RecipeStyles>;
104
- /**
105
- * Automatically infer and register CSS @property declarations from values.
106
- * @default true
107
- */
108
- autoPropertyTypes?: boolean;
109
- }
110
- interface TastyZeroBabelOptions {
7
+ export interface TastyZeroBabelOptions {
111
8
  /** Output path for generated CSS (default: 'tasty.css') */
112
9
  output?: string;
113
10
  /**
@@ -148,8 +45,23 @@ interface TastyZeroBabelOptions {
148
45
  * @default true
149
46
  */
150
47
  injectImport?: boolean;
48
+ /**
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'
61
+ */
62
+ mode?: 'file' | 'inject';
151
63
  }
152
- 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>;
153
65
  //#endregion
154
- export { TastyZeroBabelOptions, TastyZeroConfig, _default as default };
66
+ export { type TastyZeroConfig, _default as default };
155
67
  //# sourceMappingURL=babel.d.ts.map
@@ -1,34 +1,23 @@
1
- import { __require } from "../_virtual/_rolldown/runtime.js";
2
- import { configure, getGlobalConfigTokens } from "../config.js";
3
- import { mergeStyles } from "../utils/merge-styles.js";
4
- import { resolveRecipes } from "../utils/resolve-recipes.js";
5
- import { 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-ubrHP97m.js";
3
+ import { t as resolveRecipesWith } from "../chunks/config-engine-uOFYZidB.js";
4
+ import { a as resetZeroConfig, i as reapplyZeroConfig, n as functionsForExtraction, t as configureZero } from "../chunks/build-config-5d8WlQbq.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-Dw0P4yGM.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;
@@ -53,64 +42,117 @@ function clearRequireCacheTree(filePath) {
53
42
  }
54
43
  var babel_default = declare((api, options) => {
55
44
  api.assertVersion(7);
45
+ const mode = options.mode ?? "file";
56
46
  const outputPath = options.output || "tasty.css";
57
47
  const resolvedOutputPath = path.resolve(outputPath);
58
48
  const injectImport = options.injectImport ?? true;
59
- if (injectImport) {
49
+ if (mode === "file" && injectImport) {
60
50
  const dir = path.dirname(resolvedOutputPath);
61
51
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
62
52
  if (!fs.existsSync(resolvedOutputPath)) fs.writeFileSync(resolvedOutputPath, "/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\n");
63
53
  }
64
54
  const configDeps = [...options.configFile ? [options.configFile] : [], ...options.configDeps || []];
55
+ const configKey = configDeps.length > 0 ? configDeps.map(mtime).join(",") : "";
65
56
  if (configDeps.length > 0) {
66
- api.cache.using(() => configDeps.map(mtime).join(","));
57
+ api.cache.using(() => configKey);
67
58
  for (const dep of configDeps) try {
68
59
  api.addExternalDependency(dep);
69
60
  } catch {}
70
61
  } else api.cache.forever();
71
62
  if (configDeps.length > 0) for (const dep of configDeps) clearRequireCacheTree(dep);
72
- const configOption = options.config;
73
- let config;
74
- if (configOption) config = typeof configOption === "function" ? configOption() : configOption;
75
- else if (options.configFile) config = createJiti(path.dirname(options.configFile), { moduleCache: false })(options.configFile);
76
- else config = {};
77
- const devMode = config.devMode ?? false;
78
- configure(config);
79
- const cssWriter = new CSSWriter(outputPath, { devMode });
80
- const tokenStyles = getGlobalConfigTokens();
81
- if (tokenStyles && Object.keys(tokenStyles).length > 0) {
82
- const result = extractStylesForSelector(":root", tokenStyles);
83
- if (result.css) cssWriter.add(":root:tokens", result.css);
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
+ }
84
120
  }
85
- const globalRegistry = {};
86
121
  return {
87
122
  name: "tasty-zero",
88
123
  pre() {
124
+ entry.config = reapplyZeroConfig(entry.config);
125
+ setExtractorNamePrefix(sourceConfig.namePrefix ?? "ts");
89
126
  this.staticStyleRegistry = {};
127
+ this._fileAddedCSS = false;
90
128
  if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
91
129
  },
92
130
  visitor: {
93
131
  ImportDeclaration(nodePath, state) {
94
132
  const source = nodePath.node.source.value;
95
- if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) if (injectImport) {
96
- let importPath = resolvedOutputPath;
97
- if (state.filename) {
98
- const sourceDir = path.dirname(state.filename);
99
- importPath = path.relative(sourceDir, resolvedOutputPath);
100
- if (!importPath.startsWith(".")) importPath = "./" + importPath;
101
- }
102
- nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
103
- } 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
+ }
104
145
  },
105
146
  CallExpression(path, state) {
106
147
  const callee = path.node.callee;
107
148
  if (!t.isIdentifier(callee, { name: "tastyStatic" })) return;
149
+ state._fileAddedCSS = true;
108
150
  const args = path.node.arguments;
109
151
  if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
110
152
  const firstArg = args[0];
111
- if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, state.sourceFile, config.keyframes, config.autoPropertyTypes);
112
- else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, config.keyframes, config.autoPropertyTypes);
113
- else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, config.keyframes, config.autoPropertyTypes);
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);
114
156
  else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
115
157
  },
116
158
  VariableDeclarator(path, state) {
@@ -134,57 +176,69 @@ var babel_default = declare((api, options) => {
134
176
  }
135
177
  },
136
178
  post() {
137
- 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();
138
203
  }
139
204
  };
140
205
  });
141
- /**
142
- * Check if an object expression looks like a StaticStyle object
143
- */
144
206
  function isStaticStyleObject(node) {
145
207
  const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
146
208
  const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
147
209
  return hasClassName && hasStyles;
148
210
  }
149
- /**
150
- * Extract styles object from a StaticStyle object expression
151
- */
152
211
  function extractStylesFromStaticStyleObject(node, path) {
153
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);
154
213
  return null;
155
214
  }
156
- /**
157
- * Extract className from a StaticStyle object expression
158
- */
159
215
  function extractClassNameFromStaticStyleObject(node) {
160
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;
161
217
  return null;
162
218
  }
163
- /**
164
- * Handle tastyStatic(styles) - returns StaticStyle object
165
- */
166
- function handleStylesMode(path, args, cssWriter, state, globalRegistry, globalKeyframes, autoPropertyTypes) {
219
+ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
167
220
  const stylesArg = args[0];
168
221
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
169
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
222
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
223
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
170
224
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
171
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
172
- const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
173
- for (const prop of properties) cssWriter.add(prop.css, prop.css, state.sourceFile);
174
- const chunks = extractStylesWithChunks(styles);
175
- for (const chunk of chunks) {
176
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
177
- cssWriter.add(chunk.className, css, state.sourceFile);
178
- }
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);
179
230
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
180
231
  const staticStyleObject = createStaticStyleAST(className, styles);
181
- 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
+ }
182
239
  registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
183
240
  }
184
- /**
185
- * Handle tastyStatic(base, styles) - extends base with additional styles
186
- */
187
- function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globalKeyframes, autoPropertyTypes) {
241
+ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
188
242
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
189
243
  const baseArg = args[0];
190
244
  const stylesArg = args[1];
@@ -194,46 +248,94 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globa
194
248
  const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
195
249
  if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
196
250
  const overrideStyles = evaluateObjectExpression(stylesArg, path);
197
- const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
251
+ const mergedStyles = resolveRecipesWith(mergeStyles(baseEntry.styles, overrideStyles), globalRecipes ?? null);
198
252
  const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
199
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
200
- const properties = extractPropertiesFromStyles(mergedStyles, { autoPropertyTypes });
201
- for (const prop of properties) cssWriter.add(prop.css, prop.css, state.sourceFile);
202
- const chunks = extractStylesWithChunks(mergedStyles);
203
- for (const chunk of chunks) {
204
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
205
- cssWriter.add(chunk.className, css, state.sourceFile);
206
- }
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);
207
258
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
208
259
  const staticStyleObject = createStaticStyleAST(className, mergedStyles);
209
- 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
+ }
210
267
  registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
211
268
  }
212
- /**
213
- * Handle tastyStatic(selector, styles) - removes the call entirely
214
- */
215
- function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes, autoPropertyTypes) {
269
+ function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, propertyOptions, globalFontFace, globalCounterStyle, globalFunction, globalRecipes) {
216
270
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
217
271
  const selectorArg = args[0];
218
272
  const stylesArg = args[1];
219
273
  if (!t.isStringLiteral(selectorArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) first argument must be a string literal");
220
274
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) second argument must be a static object literal");
221
275
  const selector = selectorArg.value;
222
- const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
276
+ const rawStyles = evaluateObjectExpression(stylesArg, path);
277
+ const styles = resolveRecipesWith(rawStyles, globalRecipes ?? null);
223
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) {
224
316
  for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
225
- const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
226
317
  for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
227
- const result = extractStylesForSelector(selector, styles);
228
- const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
229
- cssWriter.add(selector, css, sourceFile);
230
- const parent = path.parentPath;
231
- if (parent && t.isExpressionStatement(parent.node)) parent.remove();
232
- 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)]);
233
338
  }
234
- /**
235
- * Create a StaticStyle object AST node
236
- */
237
339
  function createStaticStyleAST(className, styles) {
238
340
  return t.objectExpression([
239
341
  t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
@@ -241,9 +343,6 @@ function createStaticStyleAST(className, styles) {
241
343
  t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
242
344
  ]);
243
345
  }
244
- /**
245
- * Register a StaticStyle in the registry if it's being assigned to a variable
246
- */
247
346
  function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
248
347
  const parent = path.parentPath;
249
348
  if (parent && t.isVariableDeclarator(parent.node)) {
@@ -261,9 +360,6 @@ function registerIfVariableDeclaration(path, className, styles, state, globalReg
261
360
  }
262
361
  }
263
362
  }
264
- /**
265
- * Convert a JavaScript value to an AST node
266
- */
267
363
  function valueToAST(value) {
268
364
  if (value === null) return t.nullLiteral();
269
365
  if (value === void 0) return t.identifier("undefined");
@@ -277,10 +373,6 @@ function valueToAST(value) {
277
373
  }
278
374
  return t.identifier("undefined");
279
375
  }
280
- /**
281
- * Evaluate an ObjectExpression to a plain JavaScript object.
282
- * Only supports static values that can be determined at build time.
283
- */
284
376
  function evaluateObjectExpression(node, path) {
285
377
  const result = {};
286
378
  for (const prop of node.properties) {
@@ -290,13 +382,11 @@ function evaluateObjectExpression(node, path) {
290
382
  if (t.isIdentifier(prop.key)) key = prop.key.name;
291
383
  else if (t.isStringLiteral(prop.key)) key = prop.key.value;
292
384
  else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
293
- result[key] = evaluateExpression(prop.value, path);
385
+ const value = evaluateExpression(prop.value, path);
386
+ result[key] = value;
294
387
  }
295
388
  return result;
296
389
  }
297
- /**
298
- * Evaluate an expression to a JavaScript value.
299
- */
300
390
  function evaluateExpression(node, path) {
301
391
  if (t.isStringLiteral(node)) return node.value;
302
392
  if (t.isNumericLiteral(node)) return node.value;
@@ -319,28 +409,7 @@ function evaluateExpression(node, path) {
319
409
  }
320
410
  throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
321
411
  }
322
- /**
323
- * Replace animation names in CSS string.
324
- * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
325
- */
326
- function replaceAnimationNamesInCSS(css, nameMap) {
327
- if (nameMap.size === 0) return css;
328
- return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
329
- let newValue = value;
330
- for (const [original, replacement] of nameMap) {
331
- const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
332
- newValue = newValue.replace(pattern, replacement);
333
- }
334
- return `${prop}: ${newValue}`;
335
- });
336
- }
337
- /**
338
- * Escape special regex characters.
339
- */
340
- function escapeRegex(str) {
341
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
342
- }
343
-
344
412
  //#endregion
345
413
  export { babel_default as default };
414
+
346
415
  //# sourceMappingURL=babel.js.map