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

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 (306) hide show
  1. package/README.md +315 -159
  2. package/dist/_virtual/_rolldown/runtime.js +1 -2
  3. package/dist/chunks/cacheKey.d.ts +1 -0
  4. package/dist/chunks/cacheKey.js +17 -10
  5. package/dist/chunks/cacheKey.js.map +1 -1
  6. package/dist/chunks/definitions.d.ts +1 -1
  7. package/dist/chunks/definitions.js +3 -5
  8. package/dist/chunks/definitions.js.map +1 -1
  9. package/dist/chunks/index.d.ts +1 -0
  10. package/dist/chunks/renderChunk.d.ts +1 -0
  11. package/dist/chunks/renderChunk.js +32 -34
  12. package/dist/chunks/renderChunk.js.map +1 -1
  13. package/dist/compute-styles.d.ts +31 -0
  14. package/dist/compute-styles.js +357 -0
  15. package/dist/compute-styles.js.map +1 -0
  16. package/dist/config.d.ts +116 -30
  17. package/dist/config.js +144 -45
  18. package/dist/config.js.map +1 -1
  19. package/dist/core/index.d.ts +12 -11
  20. package/dist/core/index.js +11 -10
  21. package/dist/counter-style/index.js +51 -0
  22. package/dist/counter-style/index.js.map +1 -0
  23. package/dist/debug.d.ts +26 -141
  24. package/dist/debug.js +357 -637
  25. package/dist/debug.js.map +1 -1
  26. package/dist/font-face/index.js +63 -0
  27. package/dist/font-face/index.js.map +1 -0
  28. package/dist/hooks/index.d.ts +7 -0
  29. package/dist/hooks/useCounterStyle.d.ts +50 -0
  30. package/dist/hooks/useCounterStyle.js +45 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +43 -0
  33. package/dist/hooks/useFontFace.js +69 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +3 -0
  36. package/dist/hooks/useGlobalStyles.js +23 -2
  37. package/dist/hooks/useGlobalStyles.js.map +1 -1
  38. package/dist/hooks/useKeyframes.js +13 -4
  39. package/dist/hooks/useKeyframes.js.map +1 -1
  40. package/dist/hooks/useProperty.js +31 -14
  41. package/dist/hooks/useProperty.js.map +1 -1
  42. package/dist/hooks/useRawCSS.js +8 -2
  43. package/dist/hooks/useRawCSS.js.map +1 -1
  44. package/dist/hooks/useStyles.d.ts +4 -4
  45. package/dist/hooks/useStyles.js +7 -147
  46. package/dist/hooks/useStyles.js.map +1 -1
  47. package/dist/index.d.ts +23 -12
  48. package/dist/index.js +14 -11
  49. package/dist/injector/index.d.ts +41 -11
  50. package/dist/injector/index.js +48 -11
  51. package/dist/injector/index.js.map +1 -1
  52. package/dist/injector/injector.d.ts +58 -3
  53. package/dist/injector/injector.js +204 -41
  54. package/dist/injector/injector.js.map +1 -1
  55. package/dist/injector/sheet-manager.d.ts +18 -17
  56. package/dist/injector/sheet-manager.js +45 -73
  57. package/dist/injector/sheet-manager.js.map +1 -1
  58. package/dist/injector/types.d.ts +119 -19
  59. package/dist/keyframes/index.js +1 -1
  60. package/dist/parser/classify.js +6 -6
  61. package/dist/parser/classify.js.map +1 -1
  62. package/dist/parser/const.js +30 -3
  63. package/dist/parser/const.js.map +1 -1
  64. package/dist/parser/lru.js +1 -1
  65. package/dist/parser/lru.js.map +1 -1
  66. package/dist/parser/parser.js +2 -3
  67. package/dist/parser/parser.js.map +1 -1
  68. package/dist/parser/tokenizer.js +1 -1
  69. package/dist/parser/tokenizer.js.map +1 -1
  70. package/dist/parser/types.js +1 -1
  71. package/dist/parser/types.js.map +1 -1
  72. package/dist/pipeline/conditions.js +15 -9
  73. package/dist/pipeline/conditions.js.map +1 -1
  74. package/dist/pipeline/exclusive.js +1 -2
  75. package/dist/pipeline/exclusive.js.map +1 -1
  76. package/dist/pipeline/index.d.ts +3 -1
  77. package/dist/pipeline/index.js +139 -72
  78. package/dist/pipeline/index.js.map +1 -1
  79. package/dist/pipeline/materialize.js +405 -210
  80. package/dist/pipeline/materialize.js.map +1 -1
  81. package/dist/pipeline/parseStateKey.d.ts +1 -1
  82. package/dist/pipeline/parseStateKey.js +38 -22
  83. package/dist/pipeline/parseStateKey.js.map +1 -1
  84. package/dist/pipeline/simplify.js +112 -154
  85. package/dist/pipeline/simplify.js.map +1 -1
  86. package/dist/pipeline/warnings.js +18 -0
  87. package/dist/pipeline/warnings.js.map +1 -0
  88. package/dist/plugins/index.d.ts +2 -0
  89. package/dist/plugins/okhsl-plugin.js +3 -277
  90. package/dist/plugins/okhsl-plugin.js.map +1 -1
  91. package/dist/plugins/types.d.ts +9 -2
  92. package/dist/properties/index.js +83 -19
  93. package/dist/properties/index.js.map +1 -1
  94. package/dist/properties/property-type-resolver.d.ts +24 -0
  95. package/dist/properties/property-type-resolver.js +90 -0
  96. package/dist/properties/property-type-resolver.js.map +1 -0
  97. package/dist/ssr/astro.d.ts +29 -0
  98. package/dist/ssr/astro.js +64 -0
  99. package/dist/ssr/astro.js.map +1 -0
  100. package/dist/ssr/async-storage.d.ts +17 -0
  101. package/dist/ssr/async-storage.js +34 -0
  102. package/dist/ssr/async-storage.js.map +1 -0
  103. package/dist/ssr/collect-auto-properties.js +39 -0
  104. package/dist/ssr/collect-auto-properties.js.map +1 -0
  105. package/dist/ssr/collector.d.ts +102 -0
  106. package/dist/ssr/collector.js +219 -0
  107. package/dist/ssr/collector.js.map +1 -0
  108. package/dist/ssr/format-global-rules.js +22 -0
  109. package/dist/ssr/format-global-rules.js.map +1 -0
  110. package/dist/ssr/format-keyframes.js +69 -0
  111. package/dist/ssr/format-keyframes.js.map +1 -0
  112. package/dist/ssr/format-property.js +49 -0
  113. package/dist/ssr/format-property.js.map +1 -0
  114. package/dist/ssr/format-rules.js +73 -0
  115. package/dist/ssr/format-rules.js.map +1 -0
  116. package/dist/ssr/hydrate.d.ts +22 -0
  117. package/dist/ssr/hydrate.js +49 -0
  118. package/dist/ssr/hydrate.js.map +1 -0
  119. package/dist/ssr/index.d.ts +4 -0
  120. package/dist/ssr/index.js +10 -0
  121. package/dist/ssr/index.js.map +1 -0
  122. package/dist/ssr/next.d.ts +43 -0
  123. package/dist/ssr/next.js +74 -0
  124. package/dist/ssr/next.js.map +1 -0
  125. package/dist/ssr/ssr-collector-ref.js +12 -0
  126. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  127. package/dist/states/index.js +13 -259
  128. package/dist/states/index.js.map +1 -1
  129. package/dist/static/index.js +1 -2
  130. package/dist/static/inject.d.ts +5 -0
  131. package/dist/static/inject.js +17 -0
  132. package/dist/static/inject.js.map +1 -0
  133. package/dist/static/tastyStatic.js +1 -2
  134. package/dist/static/tastyStatic.js.map +1 -1
  135. package/dist/static/types.js +1 -1
  136. package/dist/styles/border.d.ts +2 -2
  137. package/dist/styles/border.js +30 -24
  138. package/dist/styles/border.js.map +1 -1
  139. package/dist/styles/color.d.ts +3 -3
  140. package/dist/styles/color.js +11 -8
  141. package/dist/styles/color.js.map +1 -1
  142. package/dist/styles/const.js +17 -0
  143. package/dist/styles/const.js.map +1 -0
  144. package/dist/styles/createStyle.js +29 -27
  145. package/dist/styles/createStyle.js.map +1 -1
  146. package/dist/styles/dimension.js +15 -3
  147. package/dist/styles/dimension.js.map +1 -1
  148. package/dist/styles/directional.js +133 -0
  149. package/dist/styles/directional.js.map +1 -0
  150. package/dist/styles/display.d.ts +3 -10
  151. package/dist/styles/display.js +45 -39
  152. package/dist/styles/display.js.map +1 -1
  153. package/dist/styles/fade.d.ts +2 -2
  154. package/dist/styles/fade.js +9 -5
  155. package/dist/styles/fade.js.map +1 -1
  156. package/dist/styles/fill.d.ts +15 -17
  157. package/dist/styles/fill.js +9 -9
  158. package/dist/styles/fill.js.map +1 -1
  159. package/dist/styles/flow.d.ts +3 -3
  160. package/dist/styles/flow.js +1 -1
  161. package/dist/styles/flow.js.map +1 -1
  162. package/dist/styles/gap.d.ts +1 -1
  163. package/dist/styles/gap.js +4 -3
  164. package/dist/styles/gap.js.map +1 -1
  165. package/dist/styles/height.d.ts +1 -1
  166. package/dist/styles/height.js +1 -2
  167. package/dist/styles/height.js.map +1 -1
  168. package/dist/styles/index.d.ts +0 -1
  169. package/dist/styles/index.js +3 -4
  170. package/dist/styles/index.js.map +1 -1
  171. package/dist/styles/inset.d.ts +1 -29
  172. package/dist/styles/inset.js +19 -135
  173. package/dist/styles/inset.js.map +1 -1
  174. package/dist/styles/list.d.ts +5 -5
  175. package/dist/styles/list.js +4 -2
  176. package/dist/styles/list.js.map +1 -1
  177. package/dist/styles/margin.d.ts +1 -1
  178. package/dist/styles/margin.js +17 -89
  179. package/dist/styles/margin.js.map +1 -1
  180. package/dist/styles/outline.d.ts +1 -1
  181. package/dist/styles/outline.js +6 -16
  182. package/dist/styles/outline.js.map +1 -1
  183. package/dist/styles/padding.d.ts +1 -1
  184. package/dist/styles/padding.js +17 -89
  185. package/dist/styles/padding.js.map +1 -1
  186. package/dist/styles/placement.d.ts +37 -0
  187. package/dist/styles/placement.js +74 -0
  188. package/dist/styles/placement.js.map +1 -0
  189. package/dist/styles/predefined.d.ts +4 -6
  190. package/dist/styles/predefined.js +9 -13
  191. package/dist/styles/predefined.js.map +1 -1
  192. package/dist/styles/preset.d.ts +6 -1
  193. package/dist/styles/preset.js +54 -53
  194. package/dist/styles/preset.js.map +1 -1
  195. package/dist/styles/radius.d.ts +2 -4
  196. package/dist/styles/radius.js +38 -6
  197. package/dist/styles/radius.js.map +1 -1
  198. package/dist/styles/scrollMargin.d.ts +24 -0
  199. package/dist/styles/scrollMargin.js +32 -0
  200. package/dist/styles/scrollMargin.js.map +1 -0
  201. package/dist/styles/scrollbar.d.ts +9 -5
  202. package/dist/styles/scrollbar.js +31 -85
  203. package/dist/styles/scrollbar.js.map +1 -1
  204. package/dist/styles/shadow.d.ts +3 -3
  205. package/dist/styles/shadow.js +4 -3
  206. package/dist/styles/shadow.js.map +1 -1
  207. package/dist/styles/shared.js +17 -0
  208. package/dist/styles/shared.js.map +1 -0
  209. package/dist/styles/transition.d.ts +2 -2
  210. package/dist/styles/transition.js +6 -5
  211. package/dist/styles/transition.js.map +1 -1
  212. package/dist/styles/types.d.ts +94 -28
  213. package/dist/styles/width.d.ts +1 -1
  214. package/dist/styles/width.js +1 -2
  215. package/dist/styles/width.js.map +1 -1
  216. package/dist/tasty.d.ts +46 -894
  217. package/dist/tasty.js +112 -60
  218. package/dist/tasty.js.map +1 -1
  219. package/dist/types.d.ts +3 -3
  220. package/dist/utils/cache-wrapper.js +4 -9
  221. package/dist/utils/cache-wrapper.js.map +1 -1
  222. package/dist/utils/case-converter.js +1 -1
  223. package/dist/utils/color-math.d.ts +46 -0
  224. package/dist/utils/color-math.js +749 -0
  225. package/dist/utils/color-math.js.map +1 -0
  226. package/dist/utils/color-space.d.ts +5 -0
  227. package/dist/utils/color-space.js +228 -0
  228. package/dist/utils/color-space.js.map +1 -0
  229. package/dist/utils/colors.d.ts +1 -1
  230. package/dist/utils/colors.js +3 -2
  231. package/dist/utils/colors.js.map +1 -1
  232. package/dist/utils/css-types.d.ts +1 -1
  233. package/dist/utils/dotize.d.ts +1 -1
  234. package/dist/utils/dotize.js +1 -1
  235. package/dist/utils/dotize.js.map +1 -1
  236. package/dist/utils/filter-base-props.js +1 -1
  237. package/dist/utils/get-display-name.js +1 -1
  238. package/dist/utils/has-keys.js +13 -0
  239. package/dist/utils/has-keys.js.map +1 -0
  240. package/dist/utils/is-dev-env.js +1 -1
  241. package/dist/utils/is-dev-env.js.map +1 -1
  242. package/dist/utils/is-valid-element-type.js +1 -1
  243. package/dist/utils/merge-styles.js +1 -2
  244. package/dist/utils/merge-styles.js.map +1 -1
  245. package/dist/utils/mod-attrs.d.ts +0 -2
  246. package/dist/utils/mod-attrs.js +3 -4
  247. package/dist/utils/mod-attrs.js.map +1 -1
  248. package/dist/utils/process-tokens.d.ts +3 -17
  249. package/dist/utils/process-tokens.js +19 -107
  250. package/dist/utils/process-tokens.js.map +1 -1
  251. package/dist/utils/resolve-recipes.js +1 -2
  252. package/dist/utils/resolve-recipes.js.map +1 -1
  253. package/dist/utils/selector-transform.js +32 -0
  254. package/dist/utils/selector-transform.js.map +1 -0
  255. package/dist/utils/string.js +1 -1
  256. package/dist/utils/string.js.map +1 -1
  257. package/dist/utils/styles.d.ts +5 -89
  258. package/dist/utils/styles.js +35 -400
  259. package/dist/utils/styles.js.map +1 -1
  260. package/dist/utils/typography.d.ts +24 -13
  261. package/dist/utils/typography.js +15 -17
  262. package/dist/utils/typography.js.map +1 -1
  263. package/dist/utils/warnings.js +1 -1
  264. package/dist/zero/babel.d.ts +84 -10
  265. package/dist/zero/babel.js +193 -37
  266. package/dist/zero/babel.js.map +1 -1
  267. package/dist/zero/css-writer.js +1 -2
  268. package/dist/zero/css-writer.js.map +1 -1
  269. package/dist/zero/extractor.js +119 -3
  270. package/dist/zero/extractor.js.map +1 -1
  271. package/dist/zero/index.js +1 -2
  272. package/dist/zero/next.d.ts +56 -30
  273. package/dist/zero/next.js +105 -40
  274. package/dist/zero/next.js.map +1 -1
  275. package/docs/PIPELINE.md +519 -0
  276. package/docs/README.md +31 -0
  277. package/docs/adoption.md +296 -0
  278. package/docs/comparison.md +420 -0
  279. package/docs/configuration.md +326 -0
  280. package/docs/debug.md +318 -0
  281. package/docs/design-system.md +424 -0
  282. package/docs/dsl.md +673 -0
  283. package/docs/getting-started.md +217 -0
  284. package/docs/injector.md +543 -0
  285. package/docs/methodology.md +616 -0
  286. package/docs/runtime.md +572 -0
  287. package/docs/ssr.md +354 -0
  288. package/docs/styles.md +596 -0
  289. package/docs/tasty-static.md +520 -0
  290. package/package.json +106 -31
  291. package/dist/styles/align.d.ts +0 -15
  292. package/dist/styles/align.js +0 -14
  293. package/dist/styles/align.js.map +0 -1
  294. package/dist/styles/justify.d.ts +0 -15
  295. package/dist/styles/justify.js +0 -14
  296. package/dist/styles/justify.js.map +0 -1
  297. package/dist/styles/styledScrollbar.d.ts +0 -47
  298. package/dist/styles/styledScrollbar.js +0 -38
  299. package/dist/styles/styledScrollbar.js.map +0 -1
  300. package/dist/tokens/typography.d.ts +0 -19
  301. package/dist/tokens/typography.js +0 -237
  302. package/dist/tokens/typography.js.map +0 -1
  303. package/dist/utils/hsl-to-rgb.js +0 -38
  304. package/dist/utils/hsl-to-rgb.js.map +0 -1
  305. package/dist/utils/okhsl-to-rgb.js +0 -296
  306. package/dist/utils/okhsl-to-rgb.js.map +0 -1
@@ -1,7 +1,23 @@
1
- import { Styles } from "../styles/types.js";
2
- import { TypographyPreset } from "../tokens/typography.js";
1
+ import { ConfigTokens } from "../styles/types.js";
3
2
 
4
3
  //#region src/utils/typography.d.ts
4
+ /**
5
+ * Typography preset configuration.
6
+ * Each preset defines font properties that get expanded into CSS custom properties.
7
+ *
8
+ * Use with `generateTypographyTokens()` to create typography tokens for your design system.
9
+ */
10
+ interface TypographyPreset {
11
+ fontSize: string;
12
+ lineHeight: string;
13
+ letterSpacing?: string;
14
+ fontWeight: string | number;
15
+ boldFontWeight?: string | number;
16
+ iconSize?: string;
17
+ textTransform?: string;
18
+ fontFamily?: string;
19
+ fontStyle?: string;
20
+ }
5
21
  /**
6
22
  * Generate typography tokens with $ prefix for CSS custom properties.
7
23
  *
@@ -16,21 +32,16 @@ import { TypographyPreset } from "../tokens/typography.js";
16
32
  * - `${name}-font-family` (if defined)
17
33
  * - `${name}-font-style` (if defined)
18
34
  *
19
- * @param presets - Typography presets object (defaults to TYPOGRAPHY_PRESETS)
20
- * @returns Styles object with $ prefixed keys
21
- *
22
- * @example
23
- * // Using default presets
24
- * const tokens = generateTypographyTokens();
25
- * // tokens['$h1-font-size'] === '36px'
35
+ * @param presets - Typography presets object
36
+ * @returns ConfigTokens object with $ prefixed keys
26
37
  *
27
38
  * @example
28
- * // Using custom presets
29
39
  * const customTokens = generateTypographyTokens({
30
- * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' }
40
+ * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },
41
+ * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },
31
42
  * });
32
43
  */
33
- declare function generateTypographyTokens(presets?: Record<string, TypographyPreset>): Styles;
44
+ declare function generateTypographyTokens(presets: Record<string, TypographyPreset>): ConfigTokens;
34
45
  //#endregion
35
- export { generateTypographyTokens };
46
+ export { TypographyPreset, generateTypographyTokens };
36
47
  //# sourceMappingURL=typography.d.ts.map
@@ -1,6 +1,11 @@
1
- import { TYPOGRAPHY_PRESETS } from "../tokens/typography.js";
2
-
3
1
  //#region src/utils/typography.ts
2
+ const RESERVED_PRESET_NAMES = new Set([
3
+ "strong",
4
+ "bold",
5
+ "italic",
6
+ "icon",
7
+ "tight"
8
+ ]);
4
9
  /**
5
10
  * Generate typography tokens with $ prefix for CSS custom properties.
6
11
  *
@@ -15,31 +20,24 @@ import { TYPOGRAPHY_PRESETS } from "../tokens/typography.js";
15
20
  * - `${name}-font-family` (if defined)
16
21
  * - `${name}-font-style` (if defined)
17
22
  *
18
- * @param presets - Typography presets object (defaults to TYPOGRAPHY_PRESETS)
19
- * @returns Styles object with $ prefixed keys
20
- *
21
- * @example
22
- * // Using default presets
23
- * const tokens = generateTypographyTokens();
24
- * // tokens['$h1-font-size'] === '36px'
23
+ * @param presets - Typography presets object
24
+ * @returns ConfigTokens object with $ prefixed keys
25
25
  *
26
26
  * @example
27
- * // Using custom presets
28
27
  * const customTokens = generateTypographyTokens({
29
- * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' }
28
+ * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },
29
+ * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },
30
30
  * });
31
31
  */
32
- function generateTypographyTokens(presets = TYPOGRAPHY_PRESETS) {
32
+ function generateTypographyTokens(presets) {
33
33
  const tokens = {};
34
34
  for (const [name, preset] of Object.entries(presets)) {
35
+ if (RESERVED_PRESET_NAMES.has(name)) throw new Error(`Invalid typography preset name "${name}". This name is reserved as a preset modifier.`);
35
36
  tokens[`$${name}-font-size`] = preset.fontSize;
36
37
  tokens[`$${name}-line-height`] = preset.lineHeight;
37
38
  tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? "0";
38
39
  tokens[`$${name}-font-weight`] = preset.fontWeight;
39
- if (preset.boldFontWeight !== void 0) {
40
- const boldKey = name === "c1" ? `$${name}-font-bold-weight` : `$${name}-bold-font-weight`;
41
- tokens[boldKey] = preset.boldFontWeight;
42
- }
40
+ if (preset.boldFontWeight !== void 0) tokens[`$${name}-bold-font-weight`] = preset.boldFontWeight;
43
41
  if (preset.iconSize !== void 0) tokens[`$${name}-icon-size`] = preset.iconSize;
44
42
  if (preset.textTransform !== void 0) tokens[`$${name}-text-transform`] = preset.textTransform;
45
43
  if (preset.fontFamily !== void 0) tokens[`$${name}-font-family`] = preset.fontFamily;
@@ -47,7 +45,7 @@ function generateTypographyTokens(presets = TYPOGRAPHY_PRESETS) {
47
45
  }
48
46
  return tokens;
49
47
  }
50
-
51
48
  //#endregion
52
49
  export { generateTypographyTokens };
50
+
53
51
  //# sourceMappingURL=typography.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typography.js","names":[],"sources":["../../src/utils/typography.ts"],"sourcesContent":["import type { TypographyPreset } from '../tokens/typography';\nimport { TYPOGRAPHY_PRESETS } from '../tokens/typography';\n\nimport type { Styles } from '../styles/types';\n\n// Re-export types for convenience\nexport type { TypographyPreset };\n\n/**\n * Generate typography tokens with $ prefix for CSS custom properties.\n *\n * Each preset generates the following CSS custom properties:\n * - `${name}-font-size`\n * - `${name}-line-height`\n * - `${name}-letter-spacing`\n * - `${name}-font-weight`\n * - `${name}-bold-font-weight` (if defined)\n * - `${name}-icon-size` (if defined)\n * - `${name}-text-transform` (if defined)\n * - `${name}-font-family` (if defined)\n * - `${name}-font-style` (if defined)\n *\n * @param presets - Typography presets object (defaults to TYPOGRAPHY_PRESETS)\n * @returns Styles object with $ prefixed keys\n *\n * @example\n * // Using default presets\n * const tokens = generateTypographyTokens();\n * // tokens['$h1-font-size'] === '36px'\n *\n * @example\n * // Using custom presets\n * const customTokens = generateTypographyTokens({\n * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' }\n * });\n */\nexport function generateTypographyTokens(\n presets: Record<string, TypographyPreset> = TYPOGRAPHY_PRESETS,\n): Styles {\n const tokens: Record<string, string | number> = {};\n\n for (const [name, preset] of Object.entries(presets)) {\n tokens[`$${name}-font-size`] = preset.fontSize;\n tokens[`$${name}-line-height`] = preset.lineHeight;\n tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? '0';\n tokens[`$${name}-font-weight`] = preset.fontWeight;\n\n if (preset.boldFontWeight !== undefined) {\n // Handle different property naming for c1 (uses font-bold-weight instead of bold-font-weight)\n const boldKey =\n name === 'c1'\n ? `$${name}-font-bold-weight`\n : `$${name}-bold-font-weight`;\n tokens[boldKey] = preset.boldFontWeight;\n }\n\n if (preset.iconSize !== undefined) {\n tokens[`$${name}-icon-size`] = preset.iconSize;\n }\n\n if (preset.textTransform !== undefined) {\n tokens[`$${name}-text-transform`] = preset.textTransform;\n }\n\n if (preset.fontFamily !== undefined) {\n tokens[`$${name}-font-family`] = preset.fontFamily;\n }\n\n if (preset.fontStyle !== undefined) {\n tokens[`$${name}-font-style`] = preset.fontStyle;\n }\n }\n\n return tokens as Styles;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,yBACd,UAA4C,oBACpC;CACR,MAAM,SAA0C,EAAE;AAElD,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,QAAQ,EAAE;AACpD,SAAO,IAAI,KAAK,eAAe,OAAO;AACtC,SAAO,IAAI,KAAK,iBAAiB,OAAO;AACxC,SAAO,IAAI,KAAK,oBAAoB,OAAO,iBAAiB;AAC5D,SAAO,IAAI,KAAK,iBAAiB,OAAO;AAExC,MAAI,OAAO,mBAAmB,QAAW;GAEvC,MAAM,UACJ,SAAS,OACL,IAAI,KAAK,qBACT,IAAI,KAAK;AACf,UAAO,WAAW,OAAO;;AAG3B,MAAI,OAAO,aAAa,OACtB,QAAO,IAAI,KAAK,eAAe,OAAO;AAGxC,MAAI,OAAO,kBAAkB,OAC3B,QAAO,IAAI,KAAK,oBAAoB,OAAO;AAG7C,MAAI,OAAO,eAAe,OACxB,QAAO,IAAI,KAAK,iBAAiB,OAAO;AAG1C,MAAI,OAAO,cAAc,OACvB,QAAO,IAAI,KAAK,gBAAgB,OAAO;;AAI3C,QAAO"}
1
+ {"version":3,"file":"typography.js","names":[],"sources":["../../src/utils/typography.ts"],"sourcesContent":["import type { ConfigTokens } from '../styles/types';\n\nconst RESERVED_PRESET_NAMES = new Set([\n 'strong',\n 'bold',\n 'italic',\n 'icon',\n 'tight',\n]);\n\n/**\n * Typography preset configuration.\n * Each preset defines font properties that get expanded into CSS custom properties.\n *\n * Use with `generateTypographyTokens()` to create typography tokens for your design system.\n */\nexport interface TypographyPreset {\n fontSize: string;\n lineHeight: string;\n letterSpacing?: string;\n fontWeight: string | number;\n boldFontWeight?: string | number;\n iconSize?: string;\n textTransform?: string;\n fontFamily?: string;\n fontStyle?: string;\n}\n\n/**\n * Generate typography tokens with $ prefix for CSS custom properties.\n *\n * Each preset generates the following CSS custom properties:\n * - `${name}-font-size`\n * - `${name}-line-height`\n * - `${name}-letter-spacing`\n * - `${name}-font-weight`\n * - `${name}-bold-font-weight` (if defined)\n * - `${name}-icon-size` (if defined)\n * - `${name}-text-transform` (if defined)\n * - `${name}-font-family` (if defined)\n * - `${name}-font-style` (if defined)\n *\n * @param presets - Typography presets object\n * @returns ConfigTokens object with $ prefixed keys\n *\n * @example\n * const customTokens = generateTypographyTokens({\n * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },\n * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },\n * });\n */\nexport function generateTypographyTokens(\n presets: Record<string, TypographyPreset>,\n): ConfigTokens {\n const tokens: Record<`$${string}`, string | number> = {};\n\n for (const [name, preset] of Object.entries(presets)) {\n if (RESERVED_PRESET_NAMES.has(name)) {\n throw new Error(\n `Invalid typography preset name \"${name}\". This name is reserved as a preset modifier.`,\n );\n }\n\n tokens[`$${name}-font-size`] = preset.fontSize;\n tokens[`$${name}-line-height`] = preset.lineHeight;\n tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? '0';\n tokens[`$${name}-font-weight`] = preset.fontWeight;\n\n if (preset.boldFontWeight !== undefined) {\n tokens[`$${name}-bold-font-weight`] = preset.boldFontWeight;\n }\n\n if (preset.iconSize !== undefined) {\n tokens[`$${name}-icon-size`] = preset.iconSize;\n }\n\n if (preset.textTransform !== undefined) {\n tokens[`$${name}-text-transform`] = preset.textTransform;\n }\n\n if (preset.fontFamily !== undefined) {\n tokens[`$${name}-font-family`] = preset.fontFamily;\n }\n\n if (preset.fontStyle !== undefined) {\n tokens[`$${name}-font-style`] = preset.fontStyle;\n }\n }\n\n return tokens as ConfigTokens;\n}\n"],"mappings":";AAEA,MAAM,wBAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AA2CF,SAAgB,yBACd,SACc;CACd,MAAM,SAAgD,EAAE;AAExD,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,QAAQ,EAAE;AACpD,MAAI,sBAAsB,IAAI,KAAK,CACjC,OAAM,IAAI,MACR,mCAAmC,KAAK,gDACzC;AAGH,SAAO,IAAI,KAAK,eAAe,OAAO;AACtC,SAAO,IAAI,KAAK,iBAAiB,OAAO;AACxC,SAAO,IAAI,KAAK,oBAAoB,OAAO,iBAAiB;AAC5D,SAAO,IAAI,KAAK,iBAAiB,OAAO;AAExC,MAAI,OAAO,mBAAmB,KAAA,EAC5B,QAAO,IAAI,KAAK,sBAAsB,OAAO;AAG/C,MAAI,OAAO,aAAa,KAAA,EACtB,QAAO,IAAI,KAAK,eAAe,OAAO;AAGxC,MAAI,OAAO,kBAAkB,KAAA,EAC3B,QAAO,IAAI,KAAK,oBAAoB,OAAO;AAG7C,MAAI,OAAO,eAAe,KAAA,EACxB,QAAO,IAAI,KAAK,iBAAiB,OAAO;AAG1C,MAAI,OAAO,cAAc,KAAA,EACvB,QAAO,IAAI,KAAK,gBAAgB,OAAO;;AAI3C,QAAO"}
@@ -10,7 +10,7 @@ function deprecationWarning(condition, { property, name, betterAlternative, reas
10
10
  if (reason) warn(`Reason: ${typeof reason === "function" ? reason() : reason}`);
11
11
  console.groupEnd();
12
12
  }
13
-
14
13
  //#endregion
15
14
  export { deprecationWarning, warn };
15
+
16
16
  //# sourceMappingURL=warnings.js.map
@@ -1,9 +1,9 @@
1
- import { KeyframesSteps } from "../injector/types.js";
1
+ import { CounterStyleDescriptors, FontFaceInput, KeyframesSteps } from "../injector/types.js";
2
2
  import { StyleDetails, UnitHandler } from "../parser/types.js";
3
3
  import { StyleHandlerDefinition } from "../utils/styles.js";
4
- import { RecipeStyles } from "../styles/types.js";
4
+ import { ConfigTokens, RecipeStyles } from "../styles/types.js";
5
5
  import { TastyPlugin } from "../plugins/types.js";
6
- import * as _babel_core0 from "@babel/core";
6
+ import * as _$_babel_core0 from "@babel/core";
7
7
  import { PluginPass } from "@babel/core";
8
8
 
9
9
  //#region src/zero/babel.d.ts
@@ -40,7 +40,7 @@ interface TastyZeroConfig {
40
40
  */
41
41
  funcs?: Record<string, (groups: StyleDetails[]) => string>;
42
42
  /**
43
- * Plugins that extend tasty with custom functions, units, states, handlers, or tokens.
43
+ * Plugins that extend tasty with custom functions, units, states, and handlers.
44
44
  * Plugins are processed in order, with later plugins overriding earlier ones.
45
45
  * @example
46
46
  * ```ts
@@ -63,6 +63,16 @@ interface TastyZeroConfig {
63
63
  * @example { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }
64
64
  */
65
65
  keyframes?: Record<string, KeyframesSteps>;
66
+ /**
67
+ * Global @font-face definitions for static extraction.
68
+ * Keys are font-family names, values are descriptors or arrays of descriptors.
69
+ */
70
+ fontFace?: Record<string, FontFaceInput>;
71
+ /**
72
+ * Global @counter-style definitions for static extraction.
73
+ * Keys are counter-style names, values are descriptor objects.
74
+ */
75
+ counterStyle?: Record<string, CounterStyleDescriptors>;
66
76
  /**
67
77
  * Custom style handlers that transform style properties into CSS declarations.
68
78
  * Handlers replace built-in handlers for the same style name.
@@ -78,11 +88,17 @@ interface TastyZeroConfig {
78
88
  */
79
89
  handlers?: Record<string, StyleHandlerDefinition>;
80
90
  /**
81
- * Predefined tokens that are replaced during style parsing.
91
+ * Design tokens injected as CSS custom properties on `:root`.
92
+ * Values are parsed through the Tasty DSL. Supports state maps.
93
+ * @example { '$gap': '4px', '#primary': { '': '#purple', '@dark': '#light-purple' } }
94
+ */
95
+ tokens?: ConfigTokens;
96
+ /**
97
+ * Predefined tokens replaced during style parsing (parse-time substitution).
82
98
  * Use `$name` for custom properties and `#name` for color tokens.
83
99
  * @example { $spacing: '2x', '#accent': '#purple' }
84
100
  */
85
- tokens?: Record<`$${string}` | `#${string}`, string | number>;
101
+ replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
86
102
  /**
87
103
  * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
88
104
  * Recipe values are flat tasty styles (no sub-element keys).
@@ -95,14 +111,72 @@ interface TastyZeroConfig {
95
111
  * ```
96
112
  */
97
113
  recipes?: Record<string, RecipeStyles>;
114
+ /**
115
+ * Automatically infer and register CSS @property declarations from values.
116
+ * @default true
117
+ */
118
+ autoPropertyTypes?: boolean;
98
119
  }
99
120
  interface TastyZeroBabelOptions {
100
121
  /** Output path for generated CSS (default: 'tasty.css') */
101
122
  output?: string;
102
- /** Tasty configuration for build-time processing */
103
- config?: TastyZeroConfig;
123
+ /**
124
+ * Tasty configuration for build-time processing.
125
+ * Can be a static object or a factory function that returns fresh config.
126
+ * A factory is called on each plugin invocation, enabling hot reload
127
+ * of config values that depend on external files (e.g. theme tokens).
128
+ */
129
+ config?: TastyZeroConfig | (() => TastyZeroConfig);
130
+ /**
131
+ * Absolute path to a TypeScript/JavaScript module that default-exports
132
+ * a `TastyZeroConfig` object. The module is loaded via jiti on each
133
+ * plugin invocation, enabling hot reload when the file changes.
134
+ *
135
+ * This option is JSON-serializable and is the primary way Turbopack
136
+ * passes config to the Babel plugin (since Turbopack loader options
137
+ * must be plain primitives/objects/arrays).
138
+ *
139
+ * When both `config` and `configFile` are set, `config` takes precedence.
140
+ *
141
+ * @example '/absolute/path/to/tasty-zero.config.ts'
142
+ */
143
+ configFile?: string;
144
+ /**
145
+ * Absolute file paths whose content affects the generated CSS.
146
+ * When any of these files change, babel-loader invalidates its cache
147
+ * and re-runs the plugin with fresh config values.
148
+ *
149
+ * Typically includes theme files that define Glaze palettes or token values.
150
+ * Paths must be absolute (resolved by the Next.js wrapper).
151
+ */
152
+ configDeps?: string[];
153
+ /**
154
+ * Automatically replace `@tenphi/tasty/static` imports with an import
155
+ * of the generated CSS file. This eliminates the need for users to
156
+ * manually import the CSS in their app entry point.
157
+ *
158
+ * @default true
159
+ */
160
+ injectImport?: boolean;
161
+ /**
162
+ * Output mode for extracted CSS.
163
+ *
164
+ * - `'file'` (default): CSS is written to a single output file and
165
+ * the `@tenphi/tasty/static` import is rewritten to import that file.
166
+ * - `'inject'`: CSS is embedded inline in the JS output and injected
167
+ * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
168
+ * No CSS file is written. Each `tastyStatic` call becomes
169
+ * self-contained. Best for reusable components and extensions.
170
+ *
171
+ * When `mode` is `'inject'`, `output` and `injectImport` are ignored.
172
+ *
173
+ * @default 'file'
174
+ */
175
+ mode?: 'file' | 'inject';
104
176
  }
105
- declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _babel_core0.PluginObj<PluginPass>;
177
+ /** Clear the shared CSSWriter cache. Exposed for testing. */
178
+ declare function clearWriterCache(): void;
179
+ declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _$_babel_core0.PluginObj<PluginPass>;
106
180
  //#endregion
107
- export { TastyZeroBabelOptions, TastyZeroConfig, _default as default };
181
+ export { TastyZeroBabelOptions, TastyZeroConfig, clearWriterCache, _default as default };
108
182
  //# sourceMappingURL=babel.d.ts.map
@@ -1,11 +1,14 @@
1
- import { configure } from "../config.js";
1
+ import { __require } from "../_virtual/_rolldown/runtime.js";
2
+ import { configure, getGlobalConfigTokens, resetConfig } from "../config.js";
2
3
  import { mergeStyles } from "../utils/merge-styles.js";
3
4
  import { resolveRecipes } from "../utils/resolve-recipes.js";
4
- import { extractKeyframesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "./extractor.js";
5
+ import { extractCounterStyleFromStyles, extractFontFaceFromStyles, extractKeyframesFromStyles, extractPropertiesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "./extractor.js";
5
6
  import { CSSWriter } from "./css-writer.js";
7
+ import * as fs from "fs";
8
+ import * as path from "path";
6
9
  import { declare } from "@babel/helper-plugin-utils";
7
10
  import * as t from "@babel/types";
8
-
11
+ import { createJiti } from "jiti";
9
12
  //#region src/zero/babel.ts
10
13
  /**
11
14
  * Babel plugin for zero-runtime tasty static site generation.
@@ -25,34 +28,122 @@ import * as t from "@babel/types";
25
28
  * };
26
29
  * ```
27
30
  */
31
+ function mtime(filePath) {
32
+ try {
33
+ return fs.statSync(filePath).mtimeMs;
34
+ } catch {
35
+ return null;
36
+ }
37
+ }
38
+ function clearRequireCacheTree(filePath) {
39
+ let resolved;
40
+ try {
41
+ resolved = __require.resolve(filePath);
42
+ } catch {
43
+ return;
44
+ }
45
+ const mod = __require.cache[resolved];
46
+ if (!mod) return;
47
+ const dir = resolved.substring(0, resolved.lastIndexOf("/"));
48
+ if (mod.children) {
49
+ for (const child of mod.children) if (child.id.startsWith(dir) && !child.id.includes("node_modules")) clearRequireCacheTree(child.id);
50
+ }
51
+ delete __require.cache[resolved];
52
+ }
53
+ const writerCache = /* @__PURE__ */ new Map();
54
+ /** Clear the shared CSSWriter cache. Exposed for testing. */
55
+ function clearWriterCache() {
56
+ writerCache.clear();
57
+ }
28
58
  var babel_default = declare((api, options) => {
29
59
  api.assertVersion(7);
60
+ const mode = options.mode ?? "file";
30
61
  const outputPath = options.output || "tasty.css";
31
- const config = options.config || {};
62
+ const resolvedOutputPath = path.resolve(outputPath);
63
+ const injectImport = options.injectImport ?? true;
64
+ if (mode === "file" && injectImport) {
65
+ const dir = path.dirname(resolvedOutputPath);
66
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
67
+ if (!fs.existsSync(resolvedOutputPath)) fs.writeFileSync(resolvedOutputPath, "/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\n");
68
+ }
69
+ const configDeps = [...options.configFile ? [options.configFile] : [], ...options.configDeps || []];
70
+ const configKey = configDeps.length > 0 ? configDeps.map(mtime).join(",") : "";
71
+ if (configDeps.length > 0) {
72
+ api.cache.using(() => configKey);
73
+ for (const dep of configDeps) try {
74
+ api.addExternalDependency(dep);
75
+ } catch {}
76
+ } else api.cache.forever();
77
+ if (configDeps.length > 0) for (const dep of configDeps) clearRequireCacheTree(dep);
78
+ const cached = writerCache.get(resolvedOutputPath);
79
+ if (!cached || cached.configKey !== configKey) {
80
+ const configOption = options.config;
81
+ let resolvedConfig;
82
+ if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
83
+ else if (options.configFile) resolvedConfig = createJiti(path.dirname(options.configFile), { moduleCache: false })(options.configFile);
84
+ else resolvedConfig = {};
85
+ const devMode = resolvedConfig.devMode ?? false;
86
+ if (cached) resetConfig();
87
+ configure(resolvedConfig);
88
+ const newWriter = new CSSWriter(outputPath, { devMode });
89
+ if (mode !== "inject") {
90
+ const tokenStyles = getGlobalConfigTokens();
91
+ if (tokenStyles && Object.keys(tokenStyles).length > 0) {
92
+ const result = extractStylesForSelector(":root", tokenStyles);
93
+ if (result.css) newWriter.add(":root:tokens", result.css);
94
+ }
95
+ }
96
+ writerCache.set(resolvedOutputPath, {
97
+ writer: newWriter,
98
+ configKey,
99
+ registry: {},
100
+ config: resolvedConfig
101
+ });
102
+ }
103
+ const entry = writerCache.get(resolvedOutputPath);
104
+ const cssWriter = entry.writer;
105
+ const globalRegistry = entry.registry;
106
+ const config = entry.config;
32
107
  const devMode = config.devMode ?? false;
33
- configure(config);
34
- const cssWriter = new CSSWriter(outputPath, { devMode });
35
- const globalRegistry = {};
108
+ let tokenCSS;
109
+ if (mode === "inject") {
110
+ const tokenStyles = getGlobalConfigTokens();
111
+ if (tokenStyles && Object.keys(tokenStyles).length > 0) {
112
+ const result = extractStylesForSelector(":root", tokenStyles);
113
+ if (result.css) tokenCSS = result.css;
114
+ }
115
+ }
36
116
  return {
37
117
  name: "tasty-zero",
38
118
  pre() {
39
119
  this.staticStyleRegistry = {};
120
+ this._fileAddedCSS = false;
40
121
  if (devMode && this.filename) this.sourceFile = this.filename.split("/").pop() || this.filename;
41
122
  },
42
123
  visitor: {
43
- ImportDeclaration(path) {
44
- const source = path.node.source.value;
45
- if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) path.remove();
124
+ ImportDeclaration(nodePath, state) {
125
+ const source = nodePath.node.source.value;
126
+ if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) if (mode === "inject") nodePath.replaceWith(t.importDeclaration([t.importSpecifier(t.identifier("_$i"), t.identifier("injectCSS"))], t.stringLiteral("@tenphi/tasty/static/inject")));
127
+ else if (injectImport) {
128
+ let importPath = resolvedOutputPath;
129
+ if (state.filename) {
130
+ const sourceDir = path.dirname(state.filename);
131
+ importPath = path.relative(sourceDir, resolvedOutputPath);
132
+ if (!importPath.startsWith(".")) importPath = "./" + importPath;
133
+ }
134
+ nodePath.replaceWith(t.importDeclaration([], t.stringLiteral(importPath)));
135
+ } else nodePath.remove();
46
136
  },
47
137
  CallExpression(path, state) {
48
138
  const callee = path.node.callee;
49
139
  if (!t.isIdentifier(callee, { name: "tastyStatic" })) return;
140
+ state._fileAddedCSS = true;
50
141
  const args = path.node.arguments;
51
142
  if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
52
143
  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);
144
+ if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
145
+ else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
146
+ else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFace, config.counterStyle);
56
147
  else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
57
148
  },
58
149
  VariableDeclarator(path, state) {
@@ -76,7 +167,17 @@ var babel_default = declare((api, options) => {
76
167
  }
77
168
  },
78
169
  post() {
79
- if (cssWriter.size > 0) cssWriter.write();
170
+ if (mode === "inject") {
171
+ if (this._fileAddedCSS && tokenCSS) {
172
+ const program = this.file.ast.program;
173
+ const injectCall = createInjectCallAST(":root", tokenCSS);
174
+ let insertIndex = 0;
175
+ for (let i = 0; i < program.body.length; i++) if (t.isImportDeclaration(program.body[i])) insertIndex = i + 1;
176
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
177
+ }
178
+ return;
179
+ }
180
+ if (this._fileAddedCSS && cssWriter.size > 0) cssWriter.write();
80
181
  }
81
182
  };
82
183
  });
@@ -105,26 +206,30 @@ function extractClassNameFromStaticStyleObject(node) {
105
206
  /**
106
207
  * Handle tastyStatic(styles) - returns StaticStyle object
107
208
  */
108
- function handleStylesMode(path, args, cssWriter, state, globalRegistry, globalKeyframes) {
209
+ function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
109
210
  const stylesArg = args[0];
110
211
  if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
111
212
  const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
112
213
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
113
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
214
+ const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
215
+ const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
216
+ const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
114
217
  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
218
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
120
219
  const staticStyleObject = createStaticStyleAST(className, styles);
121
- path.replaceWith(staticStyleObject);
220
+ if (mode === "inject") {
221
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
222
+ path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
223
+ } else {
224
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
225
+ path.replaceWith(staticStyleObject);
226
+ }
122
227
  registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
123
228
  }
124
229
  /**
125
230
  * Handle tastyStatic(base, styles) - extends base with additional styles
126
231
  */
127
- function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globalKeyframes) {
232
+ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
128
233
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
129
234
  const baseArg = args[0];
130
235
  const stylesArg = args[1];
@@ -136,21 +241,25 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globa
136
241
  const overrideStyles = evaluateObjectExpression(stylesArg, path);
137
242
  const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
138
243
  const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
139
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
244
+ const properties = extractPropertiesFromStyles(mergedStyles, { autoPropertyTypes });
245
+ const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
246
+ const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
140
247
  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
248
  const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
146
249
  const staticStyleObject = createStaticStyleAST(className, mergedStyles);
147
- path.replaceWith(staticStyleObject);
250
+ if (mode === "inject") {
251
+ const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap));
252
+ path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
253
+ } else {
254
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, state.sourceFile);
255
+ path.replaceWith(staticStyleObject);
256
+ }
148
257
  registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
149
258
  }
150
259
  /**
151
260
  * Handle tastyStatic(selector, styles) - removes the call entirely
152
261
  */
153
- function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes) {
262
+ function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
154
263
  if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
155
264
  const selectorArg = args[0];
156
265
  const stylesArg = args[1];
@@ -159,13 +268,60 @@ function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes)
159
268
  const selector = selectorArg.value;
160
269
  const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
161
270
  const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
162
- for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
271
+ const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
272
+ const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
273
+ const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
163
274
  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"));
275
+ const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
276
+ if (mode === "inject") {
277
+ const cssParts = [];
278
+ for (const kf of keyframes) cssParts.push(kf.css);
279
+ for (const prop of properties) cssParts.push(prop.css);
280
+ for (const ff of fontFaces) cssParts.push(ff.css);
281
+ for (const cs of counterStyles) cssParts.push(cs.css);
282
+ cssParts.push(selectorCSS);
283
+ const injectCall = createInjectCallAST(selector, cssParts.join("\n"));
284
+ const parent = path.parentPath;
285
+ if (parent && t.isExpressionStatement(parent.node)) parent.replaceWith(t.expressionStatement(injectCall));
286
+ else path.replaceWith(injectCall);
287
+ } else {
288
+ writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, [], nameMap, sourceFile);
289
+ cssWriter.add(selector, selectorCSS, sourceFile);
290
+ const parent = path.parentPath;
291
+ if (parent && t.isExpressionStatement(parent.node)) parent.remove();
292
+ else path.replaceWith(t.identifier("undefined"));
293
+ }
294
+ }
295
+ /**
296
+ * Collect all extracted CSS parts into a single string (for inject mode).
297
+ */
298
+ function collectAllCSS(keyframes, properties, fontFaces, counterStyles, chunks, nameMap) {
299
+ const parts = [];
300
+ for (const kf of keyframes) parts.push(kf.css);
301
+ for (const prop of properties) parts.push(prop.css);
302
+ for (const ff of fontFaces) parts.push(ff.css);
303
+ for (const cs of counterStyles) parts.push(cs.css);
304
+ for (const chunk of chunks) parts.push(nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css);
305
+ return parts.join("\n");
306
+ }
307
+ /**
308
+ * Write all extracted CSS parts to a CSSWriter (for file mode).
309
+ */
310
+ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, chunks, nameMap, sourceFile) {
311
+ for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
312
+ for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
313
+ for (const ff of fontFaces) cssWriter.add(ff.css, ff.css, sourceFile);
314
+ for (const cs of counterStyles) cssWriter.add(cs.css, cs.css, sourceFile);
315
+ for (const chunk of chunks) {
316
+ const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
317
+ cssWriter.add(chunk.className, css, sourceFile);
318
+ }
319
+ }
320
+ /**
321
+ * Create an `_$i(id, css)` call expression AST node for inject mode.
322
+ */
323
+ function createInjectCallAST(id, css) {
324
+ return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
169
325
  }
170
326
  /**
171
327
  * Create a StaticStyle object AST node
@@ -276,7 +432,7 @@ function replaceAnimationNamesInCSS(css, nameMap) {
276
432
  function escapeRegex(str) {
277
433
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
278
434
  }
279
-
280
435
  //#endregion
281
- export { babel_default as default };
436
+ export { clearWriterCache, babel_default as default };
437
+
282
438
  //# sourceMappingURL=babel.js.map