@tenphi/tasty 0.1.0

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 (359) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +236 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +7 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +70 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/cacheKey.mjs +70 -0
  8. package/dist/chunks/cacheKey.mjs.map +1 -0
  9. package/dist/chunks/definitions.d.ts +37 -0
  10. package/dist/chunks/definitions.js +260 -0
  11. package/dist/chunks/definitions.js.map +1 -0
  12. package/dist/chunks/definitions.mjs +260 -0
  13. package/dist/chunks/definitions.mjs.map +1 -0
  14. package/dist/chunks/index.d.ts +3 -0
  15. package/dist/chunks/renderChunk.d.ts +2 -0
  16. package/dist/chunks/renderChunk.js +61 -0
  17. package/dist/chunks/renderChunk.js.map +1 -0
  18. package/dist/chunks/renderChunk.mjs +61 -0
  19. package/dist/chunks/renderChunk.mjs.map +1 -0
  20. package/dist/config.d.ts +279 -0
  21. package/dist/config.js +400 -0
  22. package/dist/config.js.map +1 -0
  23. package/dist/config.mjs +231 -0
  24. package/dist/config.mjs.map +1 -0
  25. package/dist/css-writer.d.mts +45 -0
  26. package/dist/css-writer.mjs +74 -0
  27. package/dist/css-writer.mjs.map +1 -0
  28. package/dist/debug.d.ts +204 -0
  29. package/dist/debug.js +733 -0
  30. package/dist/debug.js.map +1 -0
  31. package/dist/extractor.d.mts +24 -0
  32. package/dist/extractor.mjs +150 -0
  33. package/dist/extractor.mjs.map +1 -0
  34. package/dist/hooks/index.d.ts +5 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +27 -0
  36. package/dist/hooks/useGlobalStyles.js +56 -0
  37. package/dist/hooks/useGlobalStyles.js.map +1 -0
  38. package/dist/hooks/useKeyframes.d.ts +56 -0
  39. package/dist/hooks/useKeyframes.js +54 -0
  40. package/dist/hooks/useKeyframes.js.map +1 -0
  41. package/dist/hooks/useProperty.d.ts +79 -0
  42. package/dist/hooks/useProperty.js +91 -0
  43. package/dist/hooks/useProperty.js.map +1 -0
  44. package/dist/hooks/useRawCSS.d.ts +53 -0
  45. package/dist/hooks/useRawCSS.js +28 -0
  46. package/dist/hooks/useRawCSS.js.map +1 -0
  47. package/dist/hooks/useStyles.d.ts +40 -0
  48. package/dist/hooks/useStyles.js +169 -0
  49. package/dist/hooks/useStyles.js.map +1 -0
  50. package/dist/index.d.ts +38 -0
  51. package/dist/index.js +30 -0
  52. package/dist/injector/index.d.ts +157 -0
  53. package/dist/injector/index.js +154 -0
  54. package/dist/injector/index.js.map +1 -0
  55. package/dist/injector/injector.d.ts +139 -0
  56. package/dist/injector/injector.js +404 -0
  57. package/dist/injector/injector.js.map +1 -0
  58. package/dist/injector/injector.mjs +404 -0
  59. package/dist/injector/injector.mjs.map +1 -0
  60. package/dist/injector/sheet-manager.d.ts +127 -0
  61. package/dist/injector/sheet-manager.js +714 -0
  62. package/dist/injector/sheet-manager.js.map +1 -0
  63. package/dist/injector/sheet-manager.mjs +714 -0
  64. package/dist/injector/sheet-manager.mjs.map +1 -0
  65. package/dist/injector/types.d.mts +18 -0
  66. package/dist/injector/types.d.ts +135 -0
  67. package/dist/keyframes/index.js +206 -0
  68. package/dist/keyframes/index.js.map +1 -0
  69. package/dist/keyframes/index.mjs +156 -0
  70. package/dist/keyframes/index.mjs.map +1 -0
  71. package/dist/parser/classify.js +319 -0
  72. package/dist/parser/classify.js.map +1 -0
  73. package/dist/parser/classify.mjs +319 -0
  74. package/dist/parser/classify.mjs.map +1 -0
  75. package/dist/parser/const.js +33 -0
  76. package/dist/parser/const.js.map +1 -0
  77. package/dist/parser/const.mjs +33 -0
  78. package/dist/parser/const.mjs.map +1 -0
  79. package/dist/parser/lru.js +109 -0
  80. package/dist/parser/lru.js.map +1 -0
  81. package/dist/parser/lru.mjs +109 -0
  82. package/dist/parser/lru.mjs.map +1 -0
  83. package/dist/parser/parser.d.ts +25 -0
  84. package/dist/parser/parser.js +116 -0
  85. package/dist/parser/parser.js.map +1 -0
  86. package/dist/parser/parser.mjs +116 -0
  87. package/dist/parser/parser.mjs.map +1 -0
  88. package/dist/parser/tokenizer.js +69 -0
  89. package/dist/parser/tokenizer.js.map +1 -0
  90. package/dist/parser/tokenizer.mjs +69 -0
  91. package/dist/parser/tokenizer.mjs.map +1 -0
  92. package/dist/parser/types.d.mts +37 -0
  93. package/dist/parser/types.d.ts +46 -0
  94. package/dist/parser/types.js +46 -0
  95. package/dist/parser/types.js.map +1 -0
  96. package/dist/parser/types.mjs +46 -0
  97. package/dist/parser/types.mjs.map +1 -0
  98. package/dist/pipeline/conditions.js +377 -0
  99. package/dist/pipeline/conditions.js.map +1 -0
  100. package/dist/pipeline/conditions.mjs +377 -0
  101. package/dist/pipeline/conditions.mjs.map +1 -0
  102. package/dist/pipeline/exclusive.d.ts +1 -0
  103. package/dist/pipeline/exclusive.js +231 -0
  104. package/dist/pipeline/exclusive.js.map +1 -0
  105. package/dist/pipeline/exclusive.mjs +231 -0
  106. package/dist/pipeline/exclusive.mjs.map +1 -0
  107. package/dist/pipeline/index.d.ts +53 -0
  108. package/dist/pipeline/index.js +641 -0
  109. package/dist/pipeline/index.js.map +1 -0
  110. package/dist/pipeline/index.mjs +635 -0
  111. package/dist/pipeline/index.mjs.map +1 -0
  112. package/dist/pipeline/materialize.js +821 -0
  113. package/dist/pipeline/materialize.js.map +1 -0
  114. package/dist/pipeline/materialize.mjs +821 -0
  115. package/dist/pipeline/materialize.mjs.map +1 -0
  116. package/dist/pipeline/parseStateKey.d.ts +1 -0
  117. package/dist/pipeline/parseStateKey.js +418 -0
  118. package/dist/pipeline/parseStateKey.js.map +1 -0
  119. package/dist/pipeline/parseStateKey.mjs +418 -0
  120. package/dist/pipeline/parseStateKey.mjs.map +1 -0
  121. package/dist/pipeline/simplify.js +557 -0
  122. package/dist/pipeline/simplify.js.map +1 -0
  123. package/dist/pipeline/simplify.mjs +557 -0
  124. package/dist/pipeline/simplify.mjs.map +1 -0
  125. package/dist/plugins/index.d.ts +2 -0
  126. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  127. package/dist/plugins/okhsl-plugin.js +371 -0
  128. package/dist/plugins/okhsl-plugin.js.map +1 -0
  129. package/dist/plugins/okhsl-plugin.mjs +345 -0
  130. package/dist/plugins/okhsl-plugin.mjs.map +1 -0
  131. package/dist/plugins/types.d.mts +49 -0
  132. package/dist/plugins/types.d.ts +69 -0
  133. package/dist/properties/index.js +158 -0
  134. package/dist/properties/index.js.map +1 -0
  135. package/dist/properties/index.mjs +141 -0
  136. package/dist/properties/index.mjs.map +1 -0
  137. package/dist/states/index.d.ts +45 -0
  138. package/dist/states/index.js +389 -0
  139. package/dist/states/index.js.map +1 -0
  140. package/dist/states/index.mjs +161 -0
  141. package/dist/states/index.mjs.map +1 -0
  142. package/dist/static/index.d.ts +5 -0
  143. package/dist/static/index.js +5 -0
  144. package/dist/static/tastyStatic.d.ts +46 -0
  145. package/dist/static/tastyStatic.js +31 -0
  146. package/dist/static/tastyStatic.js.map +1 -0
  147. package/dist/static/types.d.ts +49 -0
  148. package/dist/static/types.js +24 -0
  149. package/dist/static/types.js.map +1 -0
  150. package/dist/styles/align.d.ts +15 -0
  151. package/dist/styles/align.js +14 -0
  152. package/dist/styles/align.js.map +1 -0
  153. package/dist/styles/align.mjs +14 -0
  154. package/dist/styles/align.mjs.map +1 -0
  155. package/dist/styles/border.d.ts +25 -0
  156. package/dist/styles/border.js +114 -0
  157. package/dist/styles/border.js.map +1 -0
  158. package/dist/styles/border.mjs +114 -0
  159. package/dist/styles/border.mjs.map +1 -0
  160. package/dist/styles/color.d.ts +14 -0
  161. package/dist/styles/color.js +23 -0
  162. package/dist/styles/color.js.map +1 -0
  163. package/dist/styles/color.mjs +23 -0
  164. package/dist/styles/color.mjs.map +1 -0
  165. package/dist/styles/createStyle.js +77 -0
  166. package/dist/styles/createStyle.js.map +1 -0
  167. package/dist/styles/createStyle.mjs +77 -0
  168. package/dist/styles/createStyle.mjs.map +1 -0
  169. package/dist/styles/dimension.js +97 -0
  170. package/dist/styles/dimension.js.map +1 -0
  171. package/dist/styles/dimension.mjs +97 -0
  172. package/dist/styles/dimension.mjs.map +1 -0
  173. package/dist/styles/display.d.ts +37 -0
  174. package/dist/styles/display.js +67 -0
  175. package/dist/styles/display.js.map +1 -0
  176. package/dist/styles/display.mjs +67 -0
  177. package/dist/styles/display.mjs.map +1 -0
  178. package/dist/styles/fade.d.ts +15 -0
  179. package/dist/styles/fade.js +58 -0
  180. package/dist/styles/fade.js.map +1 -0
  181. package/dist/styles/fade.mjs +58 -0
  182. package/dist/styles/fade.mjs.map +1 -0
  183. package/dist/styles/fill.d.ts +44 -0
  184. package/dist/styles/fill.js +51 -0
  185. package/dist/styles/fill.js.map +1 -0
  186. package/dist/styles/fill.mjs +51 -0
  187. package/dist/styles/fill.mjs.map +1 -0
  188. package/dist/styles/flow.d.ts +16 -0
  189. package/dist/styles/flow.js +12 -0
  190. package/dist/styles/flow.js.map +1 -0
  191. package/dist/styles/flow.mjs +12 -0
  192. package/dist/styles/flow.mjs.map +1 -0
  193. package/dist/styles/gap.d.ts +31 -0
  194. package/dist/styles/gap.js +37 -0
  195. package/dist/styles/gap.js.map +1 -0
  196. package/dist/styles/gap.mjs +37 -0
  197. package/dist/styles/gap.mjs.map +1 -0
  198. package/dist/styles/height.d.ts +17 -0
  199. package/dist/styles/height.js +20 -0
  200. package/dist/styles/height.js.map +1 -0
  201. package/dist/styles/height.mjs +20 -0
  202. package/dist/styles/height.mjs.map +1 -0
  203. package/dist/styles/index.d.ts +2 -0
  204. package/dist/styles/index.js +9 -0
  205. package/dist/styles/index.js.map +1 -0
  206. package/dist/styles/index.mjs +9 -0
  207. package/dist/styles/index.mjs.map +1 -0
  208. package/dist/styles/inset.d.ts +50 -0
  209. package/dist/styles/inset.js +142 -0
  210. package/dist/styles/inset.js.map +1 -0
  211. package/dist/styles/inset.mjs +142 -0
  212. package/dist/styles/inset.mjs.map +1 -0
  213. package/dist/styles/justify.d.ts +15 -0
  214. package/dist/styles/justify.js +14 -0
  215. package/dist/styles/justify.js.map +1 -0
  216. package/dist/styles/justify.mjs +14 -0
  217. package/dist/styles/justify.mjs.map +1 -0
  218. package/dist/styles/list.d.ts +16 -0
  219. package/dist/styles/list.js +98 -0
  220. package/dist/styles/list.js.map +1 -0
  221. package/dist/styles/margin.d.ts +28 -0
  222. package/dist/styles/margin.js +96 -0
  223. package/dist/styles/margin.js.map +1 -0
  224. package/dist/styles/margin.mjs +96 -0
  225. package/dist/styles/margin.mjs.map +1 -0
  226. package/dist/styles/outline.d.ts +29 -0
  227. package/dist/styles/outline.js +65 -0
  228. package/dist/styles/outline.js.map +1 -0
  229. package/dist/styles/outline.mjs +65 -0
  230. package/dist/styles/outline.mjs.map +1 -0
  231. package/dist/styles/padding.d.ts +28 -0
  232. package/dist/styles/padding.js +96 -0
  233. package/dist/styles/padding.js.map +1 -0
  234. package/dist/styles/padding.mjs +96 -0
  235. package/dist/styles/padding.mjs.map +1 -0
  236. package/dist/styles/predefined.d.ts +74 -0
  237. package/dist/styles/predefined.js +241 -0
  238. package/dist/styles/predefined.js.map +1 -0
  239. package/dist/styles/predefined.mjs +232 -0
  240. package/dist/styles/predefined.mjs.map +1 -0
  241. package/dist/styles/preset.d.ts +47 -0
  242. package/dist/styles/preset.js +126 -0
  243. package/dist/styles/preset.js.map +1 -0
  244. package/dist/styles/preset.mjs +126 -0
  245. package/dist/styles/preset.mjs.map +1 -0
  246. package/dist/styles/radius.d.ts +14 -0
  247. package/dist/styles/radius.js +51 -0
  248. package/dist/styles/radius.js.map +1 -0
  249. package/dist/styles/radius.mjs +51 -0
  250. package/dist/styles/radius.mjs.map +1 -0
  251. package/dist/styles/scrollbar.d.ts +21 -0
  252. package/dist/styles/scrollbar.js +105 -0
  253. package/dist/styles/scrollbar.js.map +1 -0
  254. package/dist/styles/scrollbar.mjs +105 -0
  255. package/dist/styles/scrollbar.mjs.map +1 -0
  256. package/dist/styles/shadow.d.ts +14 -0
  257. package/dist/styles/shadow.js +24 -0
  258. package/dist/styles/shadow.js.map +1 -0
  259. package/dist/styles/shadow.mjs +24 -0
  260. package/dist/styles/shadow.mjs.map +1 -0
  261. package/dist/styles/styledScrollbar.d.ts +47 -0
  262. package/dist/styles/styledScrollbar.js +38 -0
  263. package/dist/styles/styledScrollbar.js.map +1 -0
  264. package/dist/styles/styledScrollbar.mjs +38 -0
  265. package/dist/styles/styledScrollbar.mjs.map +1 -0
  266. package/dist/styles/transition.d.ts +14 -0
  267. package/dist/styles/transition.js +138 -0
  268. package/dist/styles/transition.js.map +1 -0
  269. package/dist/styles/transition.mjs +138 -0
  270. package/dist/styles/transition.mjs.map +1 -0
  271. package/dist/styles/types.d.mts +492 -0
  272. package/dist/styles/types.d.ts +496 -0
  273. package/dist/styles/width.d.ts +17 -0
  274. package/dist/styles/width.js +20 -0
  275. package/dist/styles/width.js.map +1 -0
  276. package/dist/styles/width.mjs +20 -0
  277. package/dist/styles/width.mjs.map +1 -0
  278. package/dist/tasty.d.ts +983 -0
  279. package/dist/tasty.js +191 -0
  280. package/dist/tasty.js.map +1 -0
  281. package/dist/tokens/typography.d.ts +19 -0
  282. package/dist/tokens/typography.js +237 -0
  283. package/dist/tokens/typography.js.map +1 -0
  284. package/dist/types.d.ts +182 -0
  285. package/dist/utils/cache-wrapper.js +26 -0
  286. package/dist/utils/cache-wrapper.js.map +1 -0
  287. package/dist/utils/cache-wrapper.mjs +26 -0
  288. package/dist/utils/cache-wrapper.mjs.map +1 -0
  289. package/dist/utils/case-converter.js +8 -0
  290. package/dist/utils/case-converter.js.map +1 -0
  291. package/dist/utils/case-converter.mjs +8 -0
  292. package/dist/utils/case-converter.mjs.map +1 -0
  293. package/dist/utils/colors.d.ts +5 -0
  294. package/dist/utils/colors.js +9 -0
  295. package/dist/utils/colors.js.map +1 -0
  296. package/dist/utils/dotize.d.ts +26 -0
  297. package/dist/utils/dotize.js +122 -0
  298. package/dist/utils/dotize.js.map +1 -0
  299. package/dist/utils/filter-base-props.d.ts +15 -0
  300. package/dist/utils/filter-base-props.js +45 -0
  301. package/dist/utils/filter-base-props.js.map +1 -0
  302. package/dist/utils/get-display-name.d.ts +7 -0
  303. package/dist/utils/get-display-name.js +10 -0
  304. package/dist/utils/get-display-name.js.map +1 -0
  305. package/dist/utils/hsl-to-rgb.js +38 -0
  306. package/dist/utils/hsl-to-rgb.js.map +1 -0
  307. package/dist/utils/hsl-to-rgb.mjs +38 -0
  308. package/dist/utils/hsl-to-rgb.mjs.map +1 -0
  309. package/dist/utils/is-dev-env.js +19 -0
  310. package/dist/utils/is-dev-env.js.map +1 -0
  311. package/dist/utils/is-dev-env.mjs +19 -0
  312. package/dist/utils/is-dev-env.mjs.map +1 -0
  313. package/dist/utils/merge-styles.d.ts +7 -0
  314. package/dist/utils/merge-styles.js +146 -0
  315. package/dist/utils/merge-styles.js.map +1 -0
  316. package/dist/utils/merge-styles.mjs +146 -0
  317. package/dist/utils/merge-styles.mjs.map +1 -0
  318. package/dist/utils/mod-attrs.d.ts +8 -0
  319. package/dist/utils/mod-attrs.js +21 -0
  320. package/dist/utils/mod-attrs.js.map +1 -0
  321. package/dist/utils/okhsl-to-rgb.js +296 -0
  322. package/dist/utils/okhsl-to-rgb.js.map +1 -0
  323. package/dist/utils/okhsl-to-rgb.mjs +296 -0
  324. package/dist/utils/okhsl-to-rgb.mjs.map +1 -0
  325. package/dist/utils/process-tokens.d.ts +31 -0
  326. package/dist/utils/process-tokens.js +171 -0
  327. package/dist/utils/process-tokens.js.map +1 -0
  328. package/dist/utils/process-tokens.mjs +28 -0
  329. package/dist/utils/process-tokens.mjs.map +1 -0
  330. package/dist/utils/resolve-recipes.d.ts +17 -0
  331. package/dist/utils/resolve-recipes.js +143 -0
  332. package/dist/utils/resolve-recipes.js.map +1 -0
  333. package/dist/utils/resolve-recipes.mjs +143 -0
  334. package/dist/utils/resolve-recipes.mjs.map +1 -0
  335. package/dist/utils/string.js +8 -0
  336. package/dist/utils/string.js.map +1 -0
  337. package/dist/utils/string.mjs +8 -0
  338. package/dist/utils/string.mjs.map +1 -0
  339. package/dist/utils/styles.d.mts +18 -0
  340. package/dist/utils/styles.d.ts +183 -0
  341. package/dist/utils/styles.js +585 -0
  342. package/dist/utils/styles.js.map +1 -0
  343. package/dist/utils/styles.mjs +346 -0
  344. package/dist/utils/styles.mjs.map +1 -0
  345. package/dist/utils/typography.d.ts +36 -0
  346. package/dist/utils/typography.js +53 -0
  347. package/dist/utils/typography.js.map +1 -0
  348. package/dist/utils/warnings.d.ts +16 -0
  349. package/dist/utils/warnings.js +16 -0
  350. package/dist/utils/warnings.js.map +1 -0
  351. package/dist/zero/babel.d.mts +108 -0
  352. package/dist/zero/babel.mjs +282 -0
  353. package/dist/zero/babel.mjs.map +1 -0
  354. package/dist/zero/index.d.mts +3 -0
  355. package/dist/zero/index.mjs +4 -0
  356. package/dist/zero/next.d.mts +60 -0
  357. package/dist/zero/next.mjs +78 -0
  358. package/dist/zero/next.mjs.map +1 -0
  359. package/package.json +127 -0
@@ -0,0 +1,108 @@
1
+ import { StyleDetails, UnitHandler } from "../parser/types.mjs";
2
+ import { StyleHandlerDefinition } from "../utils/styles.mjs";
3
+ import { KeyframesSteps } from "../injector/types.mjs";
4
+ import { RecipeStyles } from "../styles/types.mjs";
5
+ import { TastyPlugin } from "../plugins/types.mjs";
6
+ import * as _babel_core0 from "@babel/core";
7
+ import { PluginPass } from "@babel/core";
8
+
9
+ //#region src/zero/babel.d.ts
10
+ /**
11
+ * Build-time configuration for zero-runtime mode.
12
+ * Subset of TastyConfig that applies at build time.
13
+ */
14
+ interface TastyZeroConfig {
15
+ /**
16
+ * Global predefined states for advanced state mapping.
17
+ * Example: { '@mobile': '@media(w < 768px)', '@dark': '@root(theme=dark)' }
18
+ */
19
+ states?: Record<string, string>;
20
+ /**
21
+ * Enable development mode features: source comments in generated CSS.
22
+ * Default: false
23
+ */
24
+ devMode?: boolean;
25
+ /**
26
+ * Parser LRU cache size (default: 1000).
27
+ * Larger values improve performance for builds with many unique style values.
28
+ */
29
+ parserCacheSize?: number;
30
+ /**
31
+ * Custom units for the style parser (merged with built-in units).
32
+ * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
33
+ * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
34
+ */
35
+ units?: Record<string, string | UnitHandler>;
36
+ /**
37
+ * Custom functions for the style parser (merged with existing).
38
+ * Functions process parsed style groups and return CSS values.
39
+ * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
40
+ */
41
+ funcs?: Record<string, (groups: StyleDetails[]) => string>;
42
+ /**
43
+ * Plugins that extend tasty with custom functions, units, states, handlers, or tokens.
44
+ * Plugins are processed in order, with later plugins overriding earlier ones.
45
+ * @example
46
+ * ```ts
47
+ * import { okhslPlugin } from '@tenphi/tasty';
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
+ * Predefined tokens that are replaced during style parsing.
82
+ * Use `$name` for custom properties and `#name` for color tokens.
83
+ * @example { $spacing: '2x', '#accent': '#purple' }
84
+ */
85
+ tokens?: Record<`$${string}` | `#${string}`, string | number>;
86
+ /**
87
+ * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
88
+ * Recipe values are flat tasty styles (no sub-element keys).
89
+ * @example
90
+ * ```ts
91
+ * recipes: {
92
+ * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
93
+ * elevated: { shadow: '2x 2x 4x #shadow' },
94
+ * }
95
+ * ```
96
+ */
97
+ recipes?: Record<string, RecipeStyles>;
98
+ }
99
+ interface TastyZeroBabelOptions {
100
+ /** Output path for generated CSS (default: 'tasty.css') */
101
+ output?: string;
102
+ /** Tasty configuration for build-time processing */
103
+ config?: TastyZeroConfig;
104
+ }
105
+ declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _babel_core0.PluginObj<PluginPass>;
106
+ //#endregion
107
+ export { TastyZeroBabelOptions, TastyZeroConfig, _default as default };
108
+ //# sourceMappingURL=babel.d.mts.map
@@ -0,0 +1,282 @@
1
+ import { configure } from "../config.mjs";
2
+ import { extractKeyframesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "../extractor.mjs";
3
+ import { CSSWriter } from "../css-writer.mjs";
4
+ import { mergeStyles } from "../utils/merge-styles.mjs";
5
+ import { resolveRecipes } from "../utils/resolve-recipes.mjs";
6
+ import { declare } from "@babel/helper-plugin-utils";
7
+ import * as t from "@babel/types";
8
+
9
+ //#region src/zero/babel.ts
10
+ /**
11
+ * Babel plugin for zero-runtime tasty static site generation.
12
+ *
13
+ * Transforms:
14
+ * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }
15
+ * - `tastyStatic(base, styles)` → StaticStyle object with merged styles
16
+ * - `tastyStatic(selector, styles)` → removed entirely
17
+ *
18
+ * Usage:
19
+ * ```javascript
20
+ * // babel.config.js
21
+ * module.exports = {
22
+ * plugins: [
23
+ * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]
24
+ * ]
25
+ * };
26
+ * ```
27
+ */
28
+ var babel_default = declare((api, options) => {
29
+ api.assertVersion(7);
30
+ const outputPath = options.output || "tasty.css";
31
+ const config = options.config || {};
32
+ const devMode = config.devMode ?? false;
33
+ configure(config);
34
+ const cssWriter = new CSSWriter(outputPath, { devMode });
35
+ const globalRegistry = {};
36
+ return {
37
+ name: "tasty-zero",
38
+ pre() {
39
+ this.staticStyleRegistry = {};
40
+ if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
41
+ },
42
+ visitor: {
43
+ ImportDeclaration(path) {
44
+ const source = path.node.source.value;
45
+ if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) path.remove();
46
+ },
47
+ CallExpression(path, state) {
48
+ const callee = path.node.callee;
49
+ if (!t.isIdentifier(callee, { name: "tastyStatic" })) return;
50
+ const args = path.node.arguments;
51
+ if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
52
+ const firstArg = args[0];
53
+ if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, state.sourceFile, config.keyframes);
54
+ else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, config.keyframes);
55
+ else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, config.keyframes);
56
+ else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
57
+ },
58
+ VariableDeclarator(path, state) {
59
+ const init = path.node.init;
60
+ const id = path.node.id;
61
+ if (t.isIdentifier(id) && t.isObjectExpression(init) && isStaticStyleObject(init)) {
62
+ const variableName = id.name;
63
+ const styles = extractStylesFromStaticStyleObject(init, path);
64
+ const className = extractClassNameFromStaticStyleObject(init);
65
+ if (styles && className) {
66
+ state.staticStyleRegistry[variableName] = {
67
+ styles,
68
+ className
69
+ };
70
+ globalRegistry[variableName] = {
71
+ styles,
72
+ className
73
+ };
74
+ }
75
+ }
76
+ }
77
+ },
78
+ post() {
79
+ if (cssWriter.size > 0) cssWriter.write();
80
+ }
81
+ };
82
+ });
83
+ /**
84
+ * Check if an object expression looks like a StaticStyle object
85
+ */
86
+ function isStaticStyleObject(node) {
87
+ const hasClassName = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "className" }));
88
+ const hasStyles = node.properties.some((p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: "styles" }));
89
+ return hasClassName && hasStyles;
90
+ }
91
+ /**
92
+ * Extract styles object from a StaticStyle object expression
93
+ */
94
+ function extractStylesFromStaticStyleObject(node, path) {
95
+ for (const prop of node.properties) if (t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "styles" }) && t.isObjectExpression(prop.value)) return evaluateObjectExpression(prop.value, path);
96
+ return null;
97
+ }
98
+ /**
99
+ * Extract className from a StaticStyle object expression
100
+ */
101
+ function extractClassNameFromStaticStyleObject(node) {
102
+ for (const prop of node.properties) if (t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: "className" }) && t.isStringLiteral(prop.value)) return prop.value.value;
103
+ return null;
104
+ }
105
+ /**
106
+ * Handle tastyStatic(styles) - returns StaticStyle object
107
+ */
108
+ function handleStylesMode(path, args, cssWriter, state, globalRegistry, globalKeyframes) {
109
+ const stylesArg = args[0];
110
+ if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
111
+ const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
112
+ const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
113
+ for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
114
+ const chunks = extractStylesWithChunks(styles);
115
+ for (const chunk of chunks) {
116
+ const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
117
+ cssWriter.add(chunk.className, css, state.sourceFile);
118
+ }
119
+ const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
120
+ const staticStyleObject = createStaticStyleAST(className, styles);
121
+ path.replaceWith(staticStyleObject);
122
+ registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
123
+ }
124
+ /**
125
+ * Handle tastyStatic(base, styles) - extends base with additional styles
126
+ */
127
+ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globalKeyframes) {
128
+ if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
129
+ const baseArg = args[0];
130
+ const stylesArg = args[1];
131
+ if (!t.isIdentifier(baseArg)) throw path.buildCodeFrameError("tastyStatic(base, styles) first argument must be an identifier");
132
+ if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(base, styles) second argument must be a static object literal");
133
+ const baseName = baseArg.name;
134
+ const baseEntry = state.staticStyleRegistry[baseName] || globalRegistry[baseName];
135
+ if (!baseEntry) throw path.buildCodeFrameError(`Cannot find base StaticStyle '${baseName}'. Make sure it is defined before being extended.`);
136
+ const overrideStyles = evaluateObjectExpression(stylesArg, path);
137
+ const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
138
+ const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
139
+ for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
140
+ const chunks = extractStylesWithChunks(mergedStyles);
141
+ for (const chunk of chunks) {
142
+ const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
143
+ cssWriter.add(chunk.className, css, state.sourceFile);
144
+ }
145
+ const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
146
+ const staticStyleObject = createStaticStyleAST(className, mergedStyles);
147
+ path.replaceWith(staticStyleObject);
148
+ registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
149
+ }
150
+ /**
151
+ * Handle tastyStatic(selector, styles) - removes the call entirely
152
+ */
153
+ function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes) {
154
+ if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
155
+ const selectorArg = args[0];
156
+ const stylesArg = args[1];
157
+ if (!t.isStringLiteral(selectorArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) first argument must be a string literal");
158
+ if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(selector, styles) second argument must be a static object literal");
159
+ const selector = selectorArg.value;
160
+ const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
161
+ const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
162
+ for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
163
+ const result = extractStylesForSelector(selector, styles);
164
+ const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
165
+ cssWriter.add(selector, css, sourceFile);
166
+ const parent = path.parentPath;
167
+ if (parent && t.isExpressionStatement(parent.node)) parent.remove();
168
+ else path.replaceWith(t.identifier("undefined"));
169
+ }
170
+ /**
171
+ * Create a StaticStyle object AST node
172
+ */
173
+ function createStaticStyleAST(className, styles) {
174
+ return t.objectExpression([
175
+ t.objectProperty(t.identifier("className"), t.stringLiteral(className)),
176
+ t.objectProperty(t.identifier("styles"), valueToAST(styles)),
177
+ t.objectMethod("method", t.identifier("toString"), [], t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.identifier("className")))]))
178
+ ]);
179
+ }
180
+ /**
181
+ * Register a StaticStyle in the registry if it's being assigned to a variable
182
+ */
183
+ function registerIfVariableDeclaration(path, className, styles, state, globalRegistry) {
184
+ const parent = path.parentPath;
185
+ if (parent && t.isVariableDeclarator(parent.node)) {
186
+ const id = parent.node.id;
187
+ if (t.isIdentifier(id)) {
188
+ const variableName = id.name;
189
+ state.staticStyleRegistry[variableName] = {
190
+ styles,
191
+ className
192
+ };
193
+ globalRegistry[variableName] = {
194
+ styles,
195
+ className
196
+ };
197
+ }
198
+ }
199
+ }
200
+ /**
201
+ * Convert a JavaScript value to an AST node
202
+ */
203
+ function valueToAST(value) {
204
+ if (value === null) return t.nullLiteral();
205
+ if (value === void 0) return t.identifier("undefined");
206
+ if (typeof value === "string") return t.stringLiteral(value);
207
+ if (typeof value === "number") return t.numericLiteral(value);
208
+ if (typeof value === "boolean") return t.booleanLiteral(value);
209
+ if (Array.isArray(value)) return t.arrayExpression(value.map(valueToAST));
210
+ if (typeof value === "object") {
211
+ const properties = Object.entries(value).map(([key, val]) => t.objectProperty(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? t.identifier(key) : t.stringLiteral(key), valueToAST(val)));
212
+ return t.objectExpression(properties);
213
+ }
214
+ return t.identifier("undefined");
215
+ }
216
+ /**
217
+ * Evaluate an ObjectExpression to a plain JavaScript object.
218
+ * Only supports static values that can be determined at build time.
219
+ */
220
+ function evaluateObjectExpression(node, path) {
221
+ const result = {};
222
+ for (const prop of node.properties) {
223
+ if (t.isSpreadElement(prop)) throw path.buildCodeFrameError("Spread elements are not supported in tastyStatic() - styles must be fully static");
224
+ if (!t.isObjectProperty(prop)) throw path.buildCodeFrameError("Only object properties are supported in tastyStatic()");
225
+ let key;
226
+ if (t.isIdentifier(prop.key)) key = prop.key.name;
227
+ else if (t.isStringLiteral(prop.key)) key = prop.key.value;
228
+ else throw path.buildCodeFrameError("Dynamic property keys are not supported in tastyStatic()");
229
+ result[key] = evaluateExpression(prop.value, path);
230
+ }
231
+ return result;
232
+ }
233
+ /**
234
+ * Evaluate an expression to a JavaScript value.
235
+ */
236
+ function evaluateExpression(node, path) {
237
+ if (t.isStringLiteral(node)) return node.value;
238
+ if (t.isNumericLiteral(node)) return node.value;
239
+ if (t.isBooleanLiteral(node)) return node.value;
240
+ if (t.isNullLiteral(node)) return null;
241
+ if (t.isIdentifier(node, { name: "undefined" })) return;
242
+ if (t.isArrayExpression(node)) return node.elements.map((el) => {
243
+ if (el === null) return null;
244
+ if (t.isSpreadElement(el)) throw path.buildCodeFrameError("Spread elements are not supported in tastyStatic()");
245
+ return evaluateExpression(el, path);
246
+ });
247
+ if (t.isObjectExpression(node)) return evaluateObjectExpression(node, path);
248
+ if (t.isTemplateLiteral(node)) {
249
+ if (node.expressions.length > 0) throw path.buildCodeFrameError("Template literals with expressions are not supported in tastyStatic()");
250
+ return node.quasis.map((q) => q.value.cooked).join("");
251
+ }
252
+ if (t.isUnaryExpression(node, { operator: "-" })) {
253
+ const arg = evaluateExpression(node.argument, path);
254
+ if (typeof arg === "number") return -arg;
255
+ }
256
+ throw path.buildCodeFrameError(`Dynamic expressions are not supported in tastyStatic() - got ${node.type}. All values must be static literals.`);
257
+ }
258
+ /**
259
+ * Replace animation names in CSS string.
260
+ * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.
261
+ */
262
+ function replaceAnimationNamesInCSS(css, nameMap) {
263
+ if (nameMap.size === 0) return css;
264
+ return css.replace(/(animation(?:-name)?)\s*:\s*([^;}]+)/gi, (match, prop, value) => {
265
+ let newValue = value;
266
+ for (const [original, replacement] of nameMap) {
267
+ const pattern = new RegExp(`\\b${escapeRegex(original)}\\b`, "g");
268
+ newValue = newValue.replace(pattern, replacement);
269
+ }
270
+ return `${prop}: ${newValue}`;
271
+ });
272
+ }
273
+ /**
274
+ * Escape special regex characters.
275
+ */
276
+ function escapeRegex(str) {
277
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
278
+ }
279
+
280
+ //#endregion
281
+ export { babel_default as default };
282
+ //# sourceMappingURL=babel.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel.mjs","names":[],"sources":["../../src/zero/babel.ts"],"sourcesContent":["/**\n * Babel plugin for zero-runtime tasty static site generation.\n *\n * Transforms:\n * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }\n * - `tastyStatic(base, styles)` → StaticStyle object with merged styles\n * - `tastyStatic(selector, styles)` → removed entirely\n *\n * Usage:\n * ```javascript\n * // babel.config.js\n * module.exports = {\n * plugins: [\n * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]\n * ]\n * };\n * ```\n */\n\nimport { declare } from '@babel/helper-plugin-utils';\nimport * as t from '@babel/types';\n\nimport { configure } from '../config';\nimport type { RecipeStyles, Styles } from '../styles/types';\nimport { mergeStyles } from '../utils/merge-styles';\nimport { resolveRecipes } from '../utils/resolve-recipes';\nimport type { StyleHandlerDefinition } from '../utils/styles';\n\nimport { CSSWriter } from './css-writer';\nimport {\n extractKeyframesFromStyles,\n extractStylesForSelector,\n extractStylesWithChunks,\n} from './extractor';\n\nimport type { NodePath, PluginPass } from '@babel/core';\nimport type { KeyframesSteps } from '../injector/types';\nimport type { StyleDetails, UnitHandler } from '../parser/types';\nimport type { TastyPlugin } from '../plugins/types';\n\n/**\n * Build-time configuration for zero-runtime mode.\n * Subset of TastyConfig that applies at build time.\n */\nexport interface TastyZeroConfig {\n /**\n * Global predefined states for advanced state mapping.\n * Example: { '@mobile': '@media(w < 768px)', '@dark': '@root(theme=dark)' }\n */\n states?: Record<string, string>;\n /**\n * Enable development mode features: source comments in generated CSS.\n * Default: false\n */\n devMode?: boolean;\n /**\n * Parser LRU cache size (default: 1000).\n * Larger values improve performance for builds with many unique style values.\n */\n parserCacheSize?: number;\n /**\n * Custom units for the style parser (merged with built-in units).\n * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.\n * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }\n */\n units?: Record<string, string | UnitHandler>;\n /**\n * Custom functions for the style parser (merged with existing).\n * Functions process parsed style groups and return CSS values.\n * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }\n */\n funcs?: Record<string, (groups: StyleDetails[]) => string>;\n /**\n * Plugins that extend tasty with custom functions, units, states, handlers, or tokens.\n * Plugins are processed in order, with later plugins overriding earlier ones.\n * @example\n * ```ts\n * import { okhslPlugin } from '@tenphi/tasty';\n *\n * // babel.config.js\n * module.exports = {\n * plugins: [\n * ['@tenphi/tasty/babel-plugin', {\n * config: { plugins: [okhslPlugin()] }\n * }]\n * ]\n * };\n * ```\n */\n plugins?: TastyPlugin[];\n /**\n * Global keyframes definitions for static extraction.\n * Keys are animation names, values are keyframes step definitions.\n * @example { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }\n */\n keyframes?: Record<string, KeyframesSteps>;\n /**\n * Custom style handlers that transform style properties into CSS declarations.\n * Handlers replace built-in handlers for the same style name.\n * @example\n * ```ts\n * handlers: {\n * fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,\n * elevation: ({ elevation }) => ({\n * 'box-shadow': `0 ${elevation}px ${elevation * 2}px rgba(0,0,0,0.1)`,\n * }),\n * }\n * ```\n */\n handlers?: Record<string, StyleHandlerDefinition>;\n /**\n * Predefined tokens that are replaced during style parsing.\n * Use `$name` for custom properties and `#name` for color tokens.\n * @example { $spacing: '2x', '#accent': '#purple' }\n */\n tokens?: Record<`$${string}` | `#${string}`, string | number>;\n /**\n * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.\n * Recipe values are flat tasty styles (no sub-element keys).\n * @example\n * ```ts\n * recipes: {\n * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },\n * elevated: { shadow: '2x 2x 4x #shadow' },\n * }\n * ```\n */\n recipes?: Record<string, RecipeStyles>;\n}\n\nexport interface TastyZeroBabelOptions {\n /** Output path for generated CSS (default: 'tasty.css') */\n output?: string;\n /** Tasty configuration for build-time processing */\n config?: TastyZeroConfig;\n}\n\n/**\n * Registry to track StaticStyle objects by their variable names.\n * Used to resolve base styles when extending.\n */\ntype StaticStyleRegistry = Record<string, {\n styles: Styles;\n className: string;\n }>;\n\ninterface PluginState extends PluginPass {\n staticStyleRegistry: StaticStyleRegistry;\n /** Current source file path (for devMode source comments) */\n sourceFile?: string;\n}\n\n// @ts-expect-error PluginState vs PluginPass type mismatch in @babel/helper-plugin-utils\nexport default declare<TastyZeroBabelOptions>((api, options) => {\n api.assertVersion(7);\n\n const outputPath = options.output || 'tasty.css';\n const config = options.config || {};\n const devMode = config.devMode ?? false;\n\n // Apply configuration using the shared configure() function\n // This handles plugin merging, states, units, funcs, handlers, tokens, etc.\n configure(config);\n\n const cssWriter = new CSSWriter(outputPath, { devMode });\n\n // Global registry for cross-file references (same build)\n const globalRegistry: StaticStyleRegistry = {};\n\n return {\n name: 'tasty-zero',\n\n pre(this: PluginState) {\n // Initialize per-file registry\n this.staticStyleRegistry = {};\n // Extract source filename for devMode comments\n if (devMode && this.filename) {\n // Get relative path or just filename\n this.sourceFile = this.filename.split('/').pop() || this.filename;\n }\n },\n\n visitor: {\n // Remove import statements for tasty/static\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\n const source = path.node.source.value;\n\n if (\n source === '@tenphi/tasty/static' ||\n source.endsWith('/tasty/static')\n ) {\n path.remove();\n }\n },\n\n // Transform tastyStatic() calls\n CallExpression(path: NodePath<t.CallExpression>, state: PluginState) {\n const callee = path.node.callee;\n\n // Match tastyStatic(...) calls\n if (!t.isIdentifier(callee, { name: 'tastyStatic' })) {\n return;\n }\n\n const args = path.node.arguments;\n\n if (args.length === 0) {\n throw path.buildCodeFrameError(\n 'tastyStatic() requires at least one argument',\n );\n }\n\n const firstArg = args[0];\n\n if (t.isStringLiteral(firstArg)) {\n // Selector mode: tastyStatic(selector, styles)\n handleSelectorMode(\n path,\n args,\n cssWriter,\n state.sourceFile,\n config.keyframes,\n );\n } else if (t.isObjectExpression(firstArg)) {\n // Styles mode: tastyStatic(styles)\n handleStylesMode(\n path,\n args,\n cssWriter,\n state,\n globalRegistry,\n config.keyframes,\n );\n } else if (t.isIdentifier(firstArg)) {\n // Extension mode: tastyStatic(base, styles)\n handleExtensionMode(\n path,\n args,\n cssWriter,\n state,\n globalRegistry,\n config.keyframes,\n );\n } else {\n throw path.buildCodeFrameError(\n 'tastyStatic() first argument must be an object (styles), ' +\n 'identifier (base StaticStyle), or string (selector)',\n );\n }\n },\n\n // Track variable declarations to register StaticStyle objects\n VariableDeclarator(\n path: NodePath<t.VariableDeclarator>,\n state: PluginState,\n ) {\n const init = path.node.init;\n const id = path.node.id;\n\n // Check if this is a StaticStyle object (has className and styles properties)\n if (\n t.isIdentifier(id) &&\n t.isObjectExpression(init) &&\n isStaticStyleObject(init)\n ) {\n const variableName = id.name;\n const styles = extractStylesFromStaticStyleObject(init, path);\n const className = extractClassNameFromStaticStyleObject(init);\n\n if (styles && className) {\n state.staticStyleRegistry[variableName] = { styles, className };\n globalRegistry[variableName] = { styles, className };\n }\n }\n },\n },\n\n post() {\n // Write all collected CSS at the end of the build\n if (cssWriter.size > 0) {\n cssWriter.write();\n }\n },\n };\n});\n\n/**\n * Check if an object expression looks like a StaticStyle object\n */\nfunction isStaticStyleObject(node: t.ObjectExpression): boolean {\n const hasClassName = node.properties.some(\n (p) =>\n t.isObjectProperty(p) && t.isIdentifier(p.key, { name: 'className' }),\n );\n const hasStyles = node.properties.some(\n (p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: 'styles' }),\n );\n return hasClassName && hasStyles;\n}\n\n/**\n * Extract styles object from a StaticStyle object expression\n */\nfunction extractStylesFromStaticStyleObject(\n node: t.ObjectExpression,\n path: NodePath,\n): Styles | null {\n for (const prop of node.properties) {\n if (\n t.isObjectProperty(prop) &&\n t.isIdentifier(prop.key, { name: 'styles' }) &&\n t.isObjectExpression(prop.value)\n ) {\n return evaluateObjectExpression(prop.value, path) as Styles;\n }\n }\n return null;\n}\n\n/**\n * Extract className from a StaticStyle object expression\n */\nfunction extractClassNameFromStaticStyleObject(\n node: t.ObjectExpression,\n): string | null {\n for (const prop of node.properties) {\n if (\n t.isObjectProperty(prop) &&\n t.isIdentifier(prop.key, { name: 'className' }) &&\n t.isStringLiteral(prop.value)\n ) {\n return prop.value.value;\n }\n }\n return null;\n}\n\n/**\n * Handle tastyStatic(styles) - returns StaticStyle object\n */\nfunction handleStylesMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n globalKeyframes?: Record<string, KeyframesSteps>,\n): void {\n const stylesArg = args[0];\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(styles) argument must be a static object literal',\n );\n }\n\n // Evaluate styles object at build time\n const rawStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Resolve recipes before extraction\n const styles = resolveRecipes(rawStyles);\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n styles,\n globalKeyframes,\n );\n\n // Add keyframes CSS\n for (const kf of keyframes) {\n cssWriter.add(kf.css, kf.css, state.sourceFile);\n }\n\n // Extract styles with chunking\n const chunks = extractStylesWithChunks(styles);\n\n // Add CSS to writer, replacing animation names if needed\n for (const chunk of chunks) {\n const css =\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(chunk.css, nameMap)\n : chunk.css;\n cssWriter.add(chunk.className, css, state.sourceFile);\n }\n\n // Generate className\n const className =\n chunks.length > 0 ? chunks.map((c) => c.className).join(' ') : '';\n\n // Replace call with StaticStyle object\n const staticStyleObject = createStaticStyleAST(className, styles);\n path.replaceWith(staticStyleObject);\n\n // Register if this is being assigned to a variable\n registerIfVariableDeclaration(path, className, styles, state, globalRegistry);\n}\n\n/**\n * Handle tastyStatic(base, styles) - extends base with additional styles\n */\nfunction handleExtensionMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n globalKeyframes?: Record<string, KeyframesSteps>,\n): void {\n if (args.length < 2) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) requires two arguments',\n );\n }\n\n const baseArg = args[0];\n const stylesArg = args[1];\n\n if (!t.isIdentifier(baseArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) first argument must be an identifier',\n );\n }\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) second argument must be a static object literal',\n );\n }\n\n const baseName = baseArg.name;\n\n // Look up base styles in registry\n const baseEntry =\n state.staticStyleRegistry[baseName] || globalRegistry[baseName];\n\n if (!baseEntry) {\n throw path.buildCodeFrameError(\n `Cannot find base StaticStyle '${baseName}'. ` +\n 'Make sure it is defined before being extended.',\n );\n }\n\n // Evaluate override styles\n const overrideStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Merge styles using mergeStyles, then resolve recipes\n const mergedStyles = resolveRecipes(\n mergeStyles(baseEntry.styles, overrideStyles),\n );\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n mergedStyles,\n globalKeyframes,\n );\n\n // Add keyframes CSS\n for (const kf of keyframes) {\n cssWriter.add(kf.css, kf.css, state.sourceFile);\n }\n\n // Extract styles with chunking\n const chunks = extractStylesWithChunks(mergedStyles);\n\n // Add CSS to writer, replacing animation names if needed\n for (const chunk of chunks) {\n const css =\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(chunk.css, nameMap)\n : chunk.css;\n cssWriter.add(chunk.className, css, state.sourceFile);\n }\n\n // Generate className\n const className =\n chunks.length > 0 ? chunks.map((c) => c.className).join(' ') : '';\n\n // Replace call with StaticStyle object\n const staticStyleObject = createStaticStyleAST(className, mergedStyles);\n path.replaceWith(staticStyleObject);\n\n // Register if this is being assigned to a variable\n registerIfVariableDeclaration(\n path,\n className,\n mergedStyles,\n state,\n globalRegistry,\n );\n}\n\n/**\n * Handle tastyStatic(selector, styles) - removes the call entirely\n */\nfunction handleSelectorMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n sourceFile?: string,\n globalKeyframes?: Record<string, KeyframesSteps>,\n): void {\n if (args.length < 2) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) requires two arguments',\n );\n }\n\n const selectorArg = args[0];\n const stylesArg = args[1];\n\n if (!t.isStringLiteral(selectorArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) first argument must be a string literal',\n );\n }\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) second argument must be a static object literal',\n );\n }\n\n const selector = selectorArg.value;\n const rawStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Resolve recipes before extraction\n const styles = resolveRecipes(rawStyles);\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n styles,\n globalKeyframes,\n );\n\n // Add keyframes CSS\n for (const kf of keyframes) {\n cssWriter.add(kf.css, kf.css, sourceFile);\n }\n\n // Extract styles for selector\n const result = extractStylesForSelector(selector, styles);\n\n // Replace animation names if needed and add CSS\n const css =\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(result.css, nameMap)\n : result.css;\n cssWriter.add(selector, css, sourceFile);\n\n // Remove the entire statement\n const parent = path.parentPath;\n if (parent && t.isExpressionStatement(parent.node)) {\n parent.remove();\n } else {\n // If used in an expression context (which would be incorrect usage),\n // replace with undefined\n path.replaceWith(t.identifier('undefined'));\n }\n}\n\n/**\n * Create a StaticStyle object AST node\n */\nfunction createStaticStyleAST(\n className: string,\n styles: Styles,\n): t.ObjectExpression {\n return t.objectExpression([\n t.objectProperty(t.identifier('className'), t.stringLiteral(className)),\n t.objectProperty(t.identifier('styles'), valueToAST(styles)),\n t.objectMethod(\n 'method',\n t.identifier('toString'),\n [],\n t.blockStatement([\n t.returnStatement(\n t.memberExpression(t.thisExpression(), t.identifier('className')),\n ),\n ]),\n ),\n ]);\n}\n\n/**\n * Register a StaticStyle in the registry if it's being assigned to a variable\n */\nfunction registerIfVariableDeclaration(\n path: NodePath,\n className: string,\n styles: Styles,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n): void {\n const parent = path.parentPath;\n if (parent && t.isVariableDeclarator(parent.node)) {\n const id = parent.node.id;\n if (t.isIdentifier(id)) {\n const variableName = id.name;\n state.staticStyleRegistry[variableName] = { styles, className };\n globalRegistry[variableName] = { styles, className };\n }\n }\n}\n\n/**\n * Convert a JavaScript value to an AST node\n */\nfunction valueToAST(value: unknown): t.Expression {\n if (value === null) {\n return t.nullLiteral();\n }\n if (value === undefined) {\n return t.identifier('undefined');\n }\n if (typeof value === 'string') {\n return t.stringLiteral(value);\n }\n if (typeof value === 'number') {\n return t.numericLiteral(value);\n }\n if (typeof value === 'boolean') {\n return t.booleanLiteral(value);\n }\n if (Array.isArray(value)) {\n return t.arrayExpression(value.map(valueToAST));\n }\n if (typeof value === 'object') {\n const properties = Object.entries(value).map(([key, val]) =>\n t.objectProperty(\n /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)\n ? t.identifier(key)\n : t.stringLiteral(key),\n valueToAST(val),\n ),\n );\n return t.objectExpression(properties);\n }\n // Fallback for unsupported types\n return t.identifier('undefined');\n}\n\n/**\n * Evaluate an ObjectExpression to a plain JavaScript object.\n * Only supports static values that can be determined at build time.\n */\nfunction evaluateObjectExpression(\n node: t.ObjectExpression,\n path: NodePath,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const prop of node.properties) {\n if (t.isSpreadElement(prop)) {\n throw path.buildCodeFrameError(\n 'Spread elements are not supported in tastyStatic() - styles must be fully static',\n );\n }\n\n if (!t.isObjectProperty(prop)) {\n throw path.buildCodeFrameError(\n 'Only object properties are supported in tastyStatic()',\n );\n }\n\n // Get key\n let key: string;\n if (t.isIdentifier(prop.key)) {\n key = prop.key.name;\n } else if (t.isStringLiteral(prop.key)) {\n key = prop.key.value;\n } else {\n throw path.buildCodeFrameError(\n 'Dynamic property keys are not supported in tastyStatic()',\n );\n }\n\n // Get value\n const value = evaluateExpression(prop.value, path);\n result[key] = value;\n }\n\n return result;\n}\n\n/**\n * Evaluate an expression to a JavaScript value.\n */\nfunction evaluateExpression(node: t.Node, path: NodePath): unknown {\n if (t.isStringLiteral(node)) {\n return node.value;\n }\n\n if (t.isNumericLiteral(node)) {\n return node.value;\n }\n\n if (t.isBooleanLiteral(node)) {\n return node.value;\n }\n\n if (t.isNullLiteral(node)) {\n return null;\n }\n\n if (t.isIdentifier(node, { name: 'undefined' })) {\n return undefined;\n }\n\n if (t.isArrayExpression(node)) {\n return node.elements.map((el) => {\n if (el === null) return null;\n if (t.isSpreadElement(el)) {\n throw path.buildCodeFrameError(\n 'Spread elements are not supported in tastyStatic()',\n );\n }\n return evaluateExpression(el, path);\n });\n }\n\n if (t.isObjectExpression(node)) {\n return evaluateObjectExpression(node, path);\n }\n\n if (t.isTemplateLiteral(node)) {\n // Only support template literals without expressions\n if (node.expressions.length > 0) {\n throw path.buildCodeFrameError(\n 'Template literals with expressions are not supported in tastyStatic()',\n );\n }\n return node.quasis.map((q) => q.value.cooked).join('');\n }\n\n if (t.isUnaryExpression(node, { operator: '-' })) {\n const arg = evaluateExpression(node.argument, path);\n if (typeof arg === 'number') {\n return -arg;\n }\n }\n\n throw path.buildCodeFrameError(\n `Dynamic expressions are not supported in tastyStatic() - got ${node.type}. ` +\n 'All values must be static literals.',\n );\n}\n\n/**\n * Replace animation names in CSS string.\n * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.\n */\nfunction replaceAnimationNamesInCSS(\n css: string,\n nameMap: Map<string, string>,\n): string {\n if (nameMap.size === 0) return css;\n\n // The CSS contains full rules like \".class { animation: name 1s; }\"\n // We need to replace animation names within declaration blocks\n return css.replace(\n /(animation(?:-name)?)\\s*:\\s*([^;}]+)/gi,\n (match, prop, value) => {\n let newValue = value;\n for (const [original, replacement] of nameMap) {\n // Word boundary replacement\n const pattern = new RegExp(`\\\\b${escapeRegex(original)}\\\\b`, 'g');\n newValue = newValue.replace(pattern, replacement);\n }\n return `${prop}: ${newValue}`;\n },\n );\n}\n\n/**\n * Escape special regex characters.\n */\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyJA,oBAAe,SAAgC,KAAK,YAAY;AAC9D,KA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jB,QAAO,CAAC;;AAIZ,OAAM,KAAK,oBACT,gEAAgE,KAAK,KAAK,uCAE3E;;;;;;AAOH,SAAS,2BACP,KACA,SACQ;AACR,KAAI,QAAQ,SAAS,EAAG,QAAO;AAI/B,QAAO,IAAI,QACT,2CACC,OAAO,MAAM,UAAU;EACtB,IAAI,WAAW;AACf,OAAK,MAAM,CAAC,UAAU,gBAAgB,SAAS;GAE7C,MAAM,UAAU,IAAI,OAAO,MAAM,YAAY,SAAS,CAAC,MAAM,IAAI;AACjE,cAAW,SAAS,QAAQ,SAAS,YAAY;;AAEnD,SAAO,GAAG,KAAK,IAAI;GAEtB;;;;;AAMH,SAAS,YAAY,KAAqB;AACxC,QAAO,IAAI,QAAQ,uBAAuB,OAAO"}
@@ -0,0 +1,3 @@
1
+ import { ExtractedChunk, ExtractedSelector, extractStylesForSelector, extractStylesWithChunks } from "../extractor.mjs";
2
+ import { CSSWriter } from "../css-writer.mjs";
3
+ export { CSSWriter, type ExtractedChunk, type ExtractedSelector, extractStylesForSelector, extractStylesWithChunks };
@@ -0,0 +1,4 @@
1
+ import { extractStylesForSelector, extractStylesWithChunks } from "../extractor.mjs";
2
+ import { CSSWriter } from "../css-writer.mjs";
3
+
4
+ export { CSSWriter, extractStylesForSelector, extractStylesWithChunks };
@@ -0,0 +1,60 @@
1
+ //#region src/zero/next.d.ts
2
+ /**
3
+ * Next.js configuration wrapper for tasty-zero.
4
+ *
5
+ * Provides a convenient way to configure the Babel plugin for Next.js projects.
6
+ *
7
+ * @example
8
+ * ```javascript
9
+ * // next.config.js
10
+ * const { withTastyZero } = require('@tenphi/tasty/next');
11
+ *
12
+ * module.exports = withTastyZero({
13
+ * output: 'public/tasty.css',
14
+ * })({
15
+ * // your Next.js config
16
+ * });
17
+ * ```
18
+ */
19
+ interface WebpackConfigContext {
20
+ isServer: boolean;
21
+ dev: boolean;
22
+ buildId: string;
23
+ dir: string;
24
+ }
25
+ interface NextConfig {
26
+ webpack?: (config: any, context: WebpackConfigContext) => any;
27
+ [key: string]: unknown;
28
+ }
29
+ interface TastyZeroNextOptions {
30
+ /**
31
+ * Output path for CSS relative to project root.
32
+ * @default 'public/tasty.css'
33
+ */
34
+ output?: string;
35
+ /**
36
+ * Whether to enable the plugin.
37
+ * @default true
38
+ */
39
+ enabled?: boolean;
40
+ }
41
+ /**
42
+ * Next.js configuration wrapper for tasty-zero.
43
+ *
44
+ * @param options - Configuration options
45
+ * @returns A function that wraps the Next.js config
46
+ *
47
+ * @example
48
+ * ```javascript
49
+ * // next.config.js
50
+ * const { withTastyZero } = require('@tenphi/tasty/next');
51
+ *
52
+ * module.exports = withTastyZero()({
53
+ * reactStrictMode: true,
54
+ * });
55
+ * ```
56
+ */
57
+ declare function withTastyZero(options?: TastyZeroNextOptions): (nextConfig?: NextConfig) => NextConfig;
58
+ //#endregion
59
+ export { TastyZeroNextOptions, withTastyZero };
60
+ //# sourceMappingURL=next.d.mts.map
@@ -0,0 +1,78 @@
1
+ import { __require } from "../_virtual/_rolldown/runtime.mjs";
2
+ import * as path from "path";
3
+
4
+ //#region src/zero/next.ts
5
+ /**
6
+ * Next.js configuration wrapper for tasty-zero.
7
+ *
8
+ * Provides a convenient way to configure the Babel plugin for Next.js projects.
9
+ *
10
+ * @example
11
+ * ```javascript
12
+ * // next.config.js
13
+ * const { withTastyZero } = require('@tenphi/tasty/next');
14
+ *
15
+ * module.exports = withTastyZero({
16
+ * output: 'public/tasty.css',
17
+ * })({
18
+ * // your Next.js config
19
+ * });
20
+ * ```
21
+ */
22
+ /**
23
+ * Next.js configuration wrapper for tasty-zero.
24
+ *
25
+ * @param options - Configuration options
26
+ * @returns A function that wraps the Next.js config
27
+ *
28
+ * @example
29
+ * ```javascript
30
+ * // next.config.js
31
+ * const { withTastyZero } = require('@tenphi/tasty/next');
32
+ *
33
+ * module.exports = withTastyZero()({
34
+ * reactStrictMode: true,
35
+ * });
36
+ * ```
37
+ */
38
+ function withTastyZero(options = {}) {
39
+ const { output = "public/tasty.css", enabled = true } = options;
40
+ return (nextConfig = {}) => {
41
+ if (!enabled) return nextConfig;
42
+ return {
43
+ ...nextConfig,
44
+ webpack(config, context) {
45
+ const { isServer, dir } = context;
46
+ if (!isServer) {
47
+ const absoluteOutput = path.resolve(dir || process.cwd(), output);
48
+ const babelPluginConfig = [__require.resolve("./babel"), { output: absoluteOutput }];
49
+ const existingRule = config.module?.rules?.find((rule) => rule.use?.loader === "babel-loader" || rule.use?.some?.((u) => u.loader === "babel-loader"));
50
+ if (existingRule) {
51
+ const babelUse = Array.isArray(existingRule.use) ? existingRule.use.find((u) => u.loader === "babel-loader") : existingRule.use;
52
+ if (babelUse?.options) {
53
+ babelUse.options.plugins = babelUse.options.plugins || [];
54
+ babelUse.options.plugins.push(babelPluginConfig);
55
+ }
56
+ } else {
57
+ config.module = config.module || {};
58
+ config.module.rules = config.module.rules || [];
59
+ config.module.rules.push({
60
+ test: /\.(tsx?|jsx?)$/,
61
+ exclude: /node_modules/,
62
+ use: [{
63
+ loader: __require.resolve("babel-loader"),
64
+ options: { plugins: [babelPluginConfig] }
65
+ }]
66
+ });
67
+ }
68
+ }
69
+ if (typeof nextConfig.webpack === "function") return nextConfig.webpack(config, context);
70
+ return config;
71
+ }
72
+ };
73
+ };
74
+ }
75
+
76
+ //#endregion
77
+ export { withTastyZero };
78
+ //# sourceMappingURL=next.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.mjs","names":[],"sources":["../../src/zero/next.ts"],"sourcesContent":["/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * Provides a convenient way to configure the Babel plugin for Next.js projects.\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/next');\n *\n * module.exports = withTastyZero({\n * output: 'public/tasty.css',\n * })({\n * // your Next.js config\n * });\n * ```\n */\n\nimport * as path from 'path';\n\n// Next.js types (inline to avoid requiring next as a dependency)\ninterface WebpackConfigContext {\n isServer: boolean;\n dev: boolean;\n buildId: string;\n dir: string;\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- webpack config types are complex */\ninterface NextConfig {\n webpack?: (config: any, context: WebpackConfigContext) => any;\n [key: string]: unknown;\n}\n\nexport interface TastyZeroNextOptions {\n /**\n * Output path for CSS relative to project root.\n * @default 'public/tasty.css'\n */\n output?: string;\n\n /**\n * Whether to enable the plugin.\n * @default true\n */\n enabled?: boolean;\n}\n\n/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * @param options - Configuration options\n * @returns A function that wraps the Next.js config\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/next');\n *\n * module.exports = withTastyZero()({\n * reactStrictMode: true,\n * });\n * ```\n */\nexport function withTastyZero(options: TastyZeroNextOptions = {}) {\n const { output = 'public/tasty.css', enabled = true } = options;\n\n return (nextConfig: NextConfig = {}): NextConfig => {\n if (!enabled) {\n return nextConfig;\n }\n\n return {\n ...nextConfig,\n\n webpack(config: any, context: WebpackConfigContext) {\n const { isServer, dir } = context;\n\n // Only process on client build to avoid duplicate CSS generation\n if (!isServer) {\n // Get absolute output path\n const absoluteOutput = path.resolve(dir || process.cwd(), output);\n\n // Find existing babel-loader rule or add new one\n const babelPluginConfig = [\n require.resolve('./babel'),\n { output: absoluteOutput },\n ];\n\n // Add our plugin to the existing babel config or create new rule\n const existingRule = config.module?.rules?.find(\n (rule: any) =>\n rule.use?.loader === 'babel-loader' ||\n rule.use?.some?.((u: any) => u.loader === 'babel-loader'),\n );\n\n if (existingRule) {\n // Add to existing babel-loader\n const babelUse = Array.isArray(existingRule.use)\n ? existingRule.use.find((u: any) => u.loader === 'babel-loader')\n : existingRule.use;\n\n if (babelUse?.options) {\n babelUse.options.plugins = babelUse.options.plugins || [];\n babelUse.options.plugins.push(babelPluginConfig);\n }\n } else {\n // Add new rule for our plugin\n config.module = config.module || {};\n config.module.rules = config.module.rules || [];\n config.module.rules.push({\n test: /\\.(tsx?|jsx?)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: require.resolve('babel-loader'),\n options: {\n plugins: [babelPluginConfig],\n },\n },\n ],\n });\n }\n }\n\n // Chain with existing webpack config\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(config, context);\n }\n\n return config;\n },\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,cAAc,UAAgC,EAAE,EAAE;CAChE,MAAM,EAAE,SAAS,oBAAoB,UAAU,SAAS;AAExD,SAAQ,aAAyB,EAAE,KAAiB;AAClD,MAAI,CAAC,QACH,QAAO;AAGT,SAAO;GACL,GAAG;GAEH,QAAQ,QAAa,SAA+B;IAClD,MAAM,EAAE,UAAU,QAAQ;AAG1B,QAAI,CAAC,UAAU;KAEb,MAAM,iBAAiB,KAAK,QAAQ,OAAO,QAAQ,KAAK,EAAE,OAAO;KAGjE,MAAM,oBAAoB,WAChB,QAAQ,UAAU,EAC1B,EAAE,QAAQ,gBAAgB,CAC3B;KAGD,MAAM,eAAe,OAAO,QAAQ,OAAO,MACxC,SACC,KAAK,KAAK,WAAW,kBACrB,KAAK,KAAK,QAAQ,MAAW,EAAE,WAAW,eAAe,CAC5D;AAED,SAAI,cAAc;MAEhB,MAAM,WAAW,MAAM,QAAQ,aAAa,IAAI,GAC5C,aAAa,IAAI,MAAM,MAAW,EAAE,WAAW,eAAe,GAC9D,aAAa;AAEjB,UAAI,UAAU,SAAS;AACrB,gBAAS,QAAQ,UAAU,SAAS,QAAQ,WAAW,EAAE;AACzD,gBAAS,QAAQ,QAAQ,KAAK,kBAAkB;;YAE7C;AAEL,aAAO,SAAS,OAAO,UAAU,EAAE;AACnC,aAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,EAAE;AAC/C,aAAO,OAAO,MAAM,KAAK;OACvB,MAAM;OACN,SAAS;OACT,KAAK,CACH;QACE,kBAAgB,QAAQ,eAAe;QACvC,SAAS,EACP,SAAS,CAAC,kBAAkB,EAC7B;QACF,CACF;OACF,CAAC;;;AAK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