@tenphi/tasty 0.0.0-snapshot.c8bdaeb → 0.0.0-snapshot.c8c7b2a

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 (318) hide show
  1. package/README.md +309 -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 +322 -0
  15. package/dist/compute-styles.js.map +1 -0
  16. package/dist/config.d.ts +157 -30
  17. package/dist/config.js +233 -45
  18. package/dist/config.js.map +1 -1
  19. package/dist/core/index.d.ts +12 -11
  20. package/dist/core/index.js +12 -11
  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 +359 -639
  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 +36 -0
  30. package/dist/hooks/useCounterStyle.js +65 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +45 -0
  33. package/dist/hooks/useFontFace.js +66 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +21 -2
  36. package/dist/hooks/useGlobalStyles.js +60 -28
  37. package/dist/hooks/useGlobalStyles.js.map +1 -1
  38. package/dist/hooks/useKeyframes.d.ts +4 -2
  39. package/dist/hooks/useKeyframes.js +44 -43
  40. package/dist/hooks/useKeyframes.js.map +1 -1
  41. package/dist/hooks/useProperty.d.ts +4 -2
  42. package/dist/hooks/useProperty.js +36 -31
  43. package/dist/hooks/useProperty.js.map +1 -1
  44. package/dist/hooks/useRawCSS.d.ts +13 -44
  45. package/dist/hooks/useRawCSS.js +91 -16
  46. package/dist/hooks/useRawCSS.js.map +1 -1
  47. package/dist/hooks/useStyles.d.ts +3 -3
  48. package/dist/hooks/useStyles.js +8 -146
  49. package/dist/hooks/useStyles.js.map +1 -1
  50. package/dist/index.d.ts +15 -12
  51. package/dist/index.js +15 -12
  52. package/dist/injector/index.d.ts +36 -11
  53. package/dist/injector/index.js +43 -12
  54. package/dist/injector/index.js.map +1 -1
  55. package/dist/injector/injector.d.ts +62 -3
  56. package/dist/injector/injector.js +293 -46
  57. package/dist/injector/injector.js.map +1 -1
  58. package/dist/injector/sheet-manager.d.ts +22 -17
  59. package/dist/injector/sheet-manager.js +64 -79
  60. package/dist/injector/sheet-manager.js.map +1 -1
  61. package/dist/injector/types.d.ts +121 -21
  62. package/dist/keyframes/index.js +1 -1
  63. package/dist/parser/classify.js +6 -6
  64. package/dist/parser/classify.js.map +1 -1
  65. package/dist/parser/const.js +30 -3
  66. package/dist/parser/const.js.map +1 -1
  67. package/dist/parser/lru.js +1 -1
  68. package/dist/parser/lru.js.map +1 -1
  69. package/dist/parser/parser.js +2 -3
  70. package/dist/parser/parser.js.map +1 -1
  71. package/dist/parser/tokenizer.js +1 -1
  72. package/dist/parser/tokenizer.js.map +1 -1
  73. package/dist/parser/types.js +1 -1
  74. package/dist/parser/types.js.map +1 -1
  75. package/dist/pipeline/conditions.js +1 -1
  76. package/dist/pipeline/conditions.js.map +1 -1
  77. package/dist/pipeline/exclusive.js +58 -4
  78. package/dist/pipeline/exclusive.js.map +1 -1
  79. package/dist/pipeline/index.d.ts +3 -1
  80. package/dist/pipeline/index.js +82 -34
  81. package/dist/pipeline/index.js.map +1 -1
  82. package/dist/pipeline/materialize.js +436 -123
  83. package/dist/pipeline/materialize.js.map +1 -1
  84. package/dist/pipeline/parseStateKey.d.ts +1 -1
  85. package/dist/pipeline/parseStateKey.js +21 -13
  86. package/dist/pipeline/parseStateKey.js.map +1 -1
  87. package/dist/pipeline/simplify.js +181 -7
  88. package/dist/pipeline/simplify.js.map +1 -1
  89. package/dist/pipeline/warnings.js +1 -1
  90. package/dist/plugins/index.d.ts +2 -0
  91. package/dist/plugins/okhsl-plugin.js +3 -277
  92. package/dist/plugins/okhsl-plugin.js.map +1 -1
  93. package/dist/plugins/types.d.ts +20 -2
  94. package/dist/properties/index.js +83 -19
  95. package/dist/properties/index.js.map +1 -1
  96. package/dist/properties/property-type-resolver.d.ts +24 -0
  97. package/dist/properties/property-type-resolver.js +90 -0
  98. package/dist/properties/property-type-resolver.js.map +1 -0
  99. package/dist/rsc-cache.js +79 -0
  100. package/dist/rsc-cache.js.map +1 -0
  101. package/dist/ssr/astro-client.d.ts +1 -0
  102. package/dist/ssr/astro-client.js +19 -0
  103. package/dist/ssr/astro-client.js.map +1 -0
  104. package/dist/ssr/astro-middleware.d.ts +15 -0
  105. package/dist/ssr/astro-middleware.js +19 -0
  106. package/dist/ssr/astro-middleware.js.map +1 -0
  107. package/dist/ssr/astro.d.ts +108 -0
  108. package/dist/ssr/astro.js +149 -0
  109. package/dist/ssr/astro.js.map +1 -0
  110. package/dist/ssr/async-storage.d.ts +17 -0
  111. package/dist/ssr/async-storage.js +44 -0
  112. package/dist/ssr/async-storage.js.map +1 -0
  113. package/dist/ssr/collect-auto-properties.js +58 -0
  114. package/dist/ssr/collect-auto-properties.js.map +1 -0
  115. package/dist/ssr/collector.d.ts +98 -0
  116. package/dist/ssr/collector.js +235 -0
  117. package/dist/ssr/collector.js.map +1 -0
  118. package/dist/ssr/context.js +16 -0
  119. package/dist/ssr/context.js.map +1 -0
  120. package/dist/ssr/format-global-rules.js +22 -0
  121. package/dist/ssr/format-global-rules.js.map +1 -0
  122. package/dist/ssr/format-keyframes.js +69 -0
  123. package/dist/ssr/format-keyframes.js.map +1 -0
  124. package/dist/ssr/format-property.js +49 -0
  125. package/dist/ssr/format-property.js.map +1 -0
  126. package/dist/ssr/format-rules.js +73 -0
  127. package/dist/ssr/format-rules.js.map +1 -0
  128. package/dist/ssr/hydrate.d.ts +29 -0
  129. package/dist/ssr/hydrate.js +45 -0
  130. package/dist/ssr/hydrate.js.map +1 -0
  131. package/dist/ssr/index.d.ts +4 -0
  132. package/dist/ssr/index.js +10 -0
  133. package/dist/ssr/index.js.map +1 -0
  134. package/dist/ssr/next.d.ts +46 -0
  135. package/dist/ssr/next.js +75 -0
  136. package/dist/ssr/next.js.map +1 -0
  137. package/dist/ssr/ssr-collector-ref.js +29 -0
  138. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  139. package/dist/states/index.js +13 -259
  140. package/dist/states/index.js.map +1 -1
  141. package/dist/static/index.js +1 -2
  142. package/dist/static/inject.d.ts +5 -0
  143. package/dist/static/inject.js +17 -0
  144. package/dist/static/inject.js.map +1 -0
  145. package/dist/static/tastyStatic.js +1 -2
  146. package/dist/static/tastyStatic.js.map +1 -1
  147. package/dist/static/types.js +1 -1
  148. package/dist/styles/border.d.ts +1 -1
  149. package/dist/styles/border.js +30 -24
  150. package/dist/styles/border.js.map +1 -1
  151. package/dist/styles/color.d.ts +1 -1
  152. package/dist/styles/color.js +11 -8
  153. package/dist/styles/color.js.map +1 -1
  154. package/dist/styles/const.js +17 -0
  155. package/dist/styles/const.js.map +1 -0
  156. package/dist/styles/createStyle.js +28 -26
  157. package/dist/styles/createStyle.js.map +1 -1
  158. package/dist/styles/dimension.js +15 -3
  159. package/dist/styles/dimension.js.map +1 -1
  160. package/dist/styles/directional.js +133 -0
  161. package/dist/styles/directional.js.map +1 -0
  162. package/dist/styles/display.d.ts +3 -10
  163. package/dist/styles/display.js +45 -39
  164. package/dist/styles/display.js.map +1 -1
  165. package/dist/styles/fade.d.ts +1 -1
  166. package/dist/styles/fade.js +9 -5
  167. package/dist/styles/fade.js.map +1 -1
  168. package/dist/styles/fill.d.ts +2 -2
  169. package/dist/styles/fill.js +9 -9
  170. package/dist/styles/fill.js.map +1 -1
  171. package/dist/styles/flow.js +1 -1
  172. package/dist/styles/gap.d.ts +1 -1
  173. package/dist/styles/gap.js +4 -3
  174. package/dist/styles/gap.js.map +1 -1
  175. package/dist/styles/height.d.ts +1 -1
  176. package/dist/styles/height.js +1 -2
  177. package/dist/styles/height.js.map +1 -1
  178. package/dist/styles/index.d.ts +0 -1
  179. package/dist/styles/index.js +3 -4
  180. package/dist/styles/index.js.map +1 -1
  181. package/dist/styles/inset.d.ts +1 -29
  182. package/dist/styles/inset.js +19 -135
  183. package/dist/styles/inset.js.map +1 -1
  184. package/dist/styles/list.d.ts +5 -5
  185. package/dist/styles/list.js +4 -2
  186. package/dist/styles/list.js.map +1 -1
  187. package/dist/styles/margin.d.ts +1 -1
  188. package/dist/styles/margin.js +17 -89
  189. package/dist/styles/margin.js.map +1 -1
  190. package/dist/styles/outline.d.ts +1 -1
  191. package/dist/styles/outline.js +6 -16
  192. package/dist/styles/outline.js.map +1 -1
  193. package/dist/styles/padding.d.ts +1 -1
  194. package/dist/styles/padding.js +17 -89
  195. package/dist/styles/padding.js.map +1 -1
  196. package/dist/styles/placement.d.ts +37 -0
  197. package/dist/styles/placement.js +74 -0
  198. package/dist/styles/placement.js.map +1 -0
  199. package/dist/styles/predefined.d.ts +4 -6
  200. package/dist/styles/predefined.js +9 -13
  201. package/dist/styles/predefined.js.map +1 -1
  202. package/dist/styles/preset.d.ts +6 -1
  203. package/dist/styles/preset.js +54 -53
  204. package/dist/styles/preset.js.map +1 -1
  205. package/dist/styles/radius.d.ts +1 -3
  206. package/dist/styles/radius.js +38 -6
  207. package/dist/styles/radius.js.map +1 -1
  208. package/dist/styles/scrollMargin.d.ts +24 -0
  209. package/dist/styles/scrollMargin.js +32 -0
  210. package/dist/styles/scrollMargin.js.map +1 -0
  211. package/dist/styles/scrollbar.d.ts +9 -5
  212. package/dist/styles/scrollbar.js +31 -92
  213. package/dist/styles/scrollbar.js.map +1 -1
  214. package/dist/styles/shadow.d.ts +1 -1
  215. package/dist/styles/shadow.js +4 -3
  216. package/dist/styles/shadow.js.map +1 -1
  217. package/dist/styles/shared.js +17 -0
  218. package/dist/styles/shared.js.map +1 -0
  219. package/dist/styles/transition.d.ts +1 -1
  220. package/dist/styles/transition.js +6 -5
  221. package/dist/styles/transition.js.map +1 -1
  222. package/dist/styles/types.d.ts +94 -28
  223. package/dist/styles/width.d.ts +1 -1
  224. package/dist/styles/width.js +1 -2
  225. package/dist/styles/width.js.map +1 -1
  226. package/dist/tasty.d.ts +46 -894
  227. package/dist/tasty.js +101 -59
  228. package/dist/tasty.js.map +1 -1
  229. package/dist/types.d.ts +1 -1
  230. package/dist/utils/cache-wrapper.js +4 -9
  231. package/dist/utils/cache-wrapper.js.map +1 -1
  232. package/dist/utils/case-converter.js +1 -1
  233. package/dist/utils/color-math.d.ts +46 -0
  234. package/dist/utils/color-math.js +749 -0
  235. package/dist/utils/color-math.js.map +1 -0
  236. package/dist/utils/color-space.d.ts +5 -0
  237. package/dist/utils/color-space.js +228 -0
  238. package/dist/utils/color-space.js.map +1 -0
  239. package/dist/utils/colors.js +3 -2
  240. package/dist/utils/colors.js.map +1 -1
  241. package/dist/utils/deps-equal.js +15 -0
  242. package/dist/utils/deps-equal.js.map +1 -0
  243. package/dist/utils/dotize.js +1 -1
  244. package/dist/utils/dotize.js.map +1 -1
  245. package/dist/utils/filter-base-props.d.ts +1 -1
  246. package/dist/utils/filter-base-props.js +1 -1
  247. package/dist/utils/filter-base-props.js.map +1 -1
  248. package/dist/utils/get-display-name.js +1 -1
  249. package/dist/utils/has-keys.js +13 -0
  250. package/dist/utils/has-keys.js.map +1 -0
  251. package/dist/utils/hash.js +14 -0
  252. package/dist/utils/hash.js.map +1 -0
  253. package/dist/utils/is-dev-env.js +1 -1
  254. package/dist/utils/is-dev-env.js.map +1 -1
  255. package/dist/utils/is-valid-element-type.js +1 -1
  256. package/dist/utils/merge-styles.js +1 -2
  257. package/dist/utils/merge-styles.js.map +1 -1
  258. package/dist/utils/mod-attrs.d.ts +0 -2
  259. package/dist/utils/mod-attrs.js +3 -4
  260. package/dist/utils/mod-attrs.js.map +1 -1
  261. package/dist/utils/process-tokens.d.ts +3 -17
  262. package/dist/utils/process-tokens.js +19 -107
  263. package/dist/utils/process-tokens.js.map +1 -1
  264. package/dist/utils/resolve-recipes.js +1 -2
  265. package/dist/utils/resolve-recipes.js.map +1 -1
  266. package/dist/utils/selector-transform.js +32 -0
  267. package/dist/utils/selector-transform.js.map +1 -0
  268. package/dist/utils/string.js +1 -1
  269. package/dist/utils/styles.d.ts +3 -82
  270. package/dist/utils/styles.js +29 -399
  271. package/dist/utils/styles.js.map +1 -1
  272. package/dist/utils/typography.d.ts +35 -13
  273. package/dist/utils/typography.js +16 -18
  274. package/dist/utils/typography.js.map +1 -1
  275. package/dist/utils/warnings.js +1 -1
  276. package/dist/zero/babel.d.ts +57 -84
  277. package/dist/zero/babel.js +217 -37
  278. package/dist/zero/babel.js.map +1 -1
  279. package/dist/zero/css-writer.js +1 -2
  280. package/dist/zero/css-writer.js.map +1 -1
  281. package/dist/zero/extractor.js +119 -3
  282. package/dist/zero/extractor.js.map +1 -1
  283. package/dist/zero/index.js +1 -2
  284. package/dist/zero/next.d.ts +56 -30
  285. package/dist/zero/next.js +105 -40
  286. package/dist/zero/next.js.map +1 -1
  287. package/docs/README.md +31 -0
  288. package/docs/adoption.md +298 -0
  289. package/docs/comparison.md +419 -0
  290. package/docs/configuration.md +394 -0
  291. package/docs/debug.md +320 -0
  292. package/docs/design-system.md +436 -0
  293. package/docs/dsl.md +688 -0
  294. package/docs/getting-started.md +217 -0
  295. package/docs/injector.md +544 -0
  296. package/docs/methodology.md +616 -0
  297. package/docs/pipeline.md +519 -0
  298. package/docs/react-api.md +557 -0
  299. package/docs/ssr.md +442 -0
  300. package/docs/styles.md +596 -0
  301. package/docs/tasty-static.md +532 -0
  302. package/package.json +68 -36
  303. package/dist/styles/align.d.ts +0 -15
  304. package/dist/styles/align.js +0 -14
  305. package/dist/styles/align.js.map +0 -1
  306. package/dist/styles/justify.d.ts +0 -15
  307. package/dist/styles/justify.js +0 -14
  308. package/dist/styles/justify.js.map +0 -1
  309. package/dist/styles/styledScrollbar.d.ts +0 -47
  310. package/dist/styles/styledScrollbar.js +0 -38
  311. package/dist/styles/styledScrollbar.js.map +0 -1
  312. package/dist/tokens/typography.d.ts +0 -19
  313. package/dist/tokens/typography.js +0 -237
  314. package/dist/tokens/typography.js.map +0 -1
  315. package/dist/utils/hsl-to-rgb.js +0 -38
  316. package/dist/utils/hsl-to-rgb.js.map +0 -1
  317. package/dist/utils/okhsl-to-rgb.js +0 -296
  318. package/dist/utils/okhsl-to-rgb.js.map +0 -1
@@ -1,7 +1,34 @@
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
+ * A typography token value: plain value or a state map for responsive/theme-aware presets.
6
+ *
7
+ * @example
8
+ * // Plain value
9
+ * fontWeight: '400'
10
+ * // State map
11
+ * fontWeight: { '': '400', '@dark': '300' }
12
+ */
13
+ type TypographyTokenValue = string | number | Record<string, string | number | undefined | null | '@inherit'>;
14
+ /**
15
+ * Typography preset configuration.
16
+ * Each preset defines font properties that get expanded into CSS custom properties.
17
+ * All fields accept plain values or state maps for responsive/theme-aware tokens.
18
+ *
19
+ * Use with `generateTypographyTokens()` to create typography tokens for your design system.
20
+ */
21
+ interface TypographyPreset {
22
+ fontSize: TypographyTokenValue;
23
+ lineHeight: TypographyTokenValue;
24
+ letterSpacing?: TypographyTokenValue;
25
+ fontWeight: TypographyTokenValue;
26
+ boldFontWeight?: TypographyTokenValue;
27
+ iconSize?: TypographyTokenValue;
28
+ textTransform?: TypographyTokenValue;
29
+ fontFamily?: TypographyTokenValue;
30
+ fontStyle?: TypographyTokenValue;
31
+ }
5
32
  /**
6
33
  * Generate typography tokens with $ prefix for CSS custom properties.
7
34
  *
@@ -16,21 +43,16 @@ import { TypographyPreset } from "../tokens/typography.js";
16
43
  * - `${name}-font-family` (if defined)
17
44
  * - `${name}-font-style` (if defined)
18
45
  *
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'
46
+ * @param presets - Typography presets object
47
+ * @returns ConfigTokens object with $ prefixed keys
26
48
  *
27
49
  * @example
28
- * // Using custom presets
29
50
  * const customTokens = generateTypographyTokens({
30
- * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' }
51
+ * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },
52
+ * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },
31
53
  * });
32
54
  */
33
- declare function generateTypographyTokens(presets?: Record<string, TypographyPreset>): Styles;
55
+ declare function generateTypographyTokens(presets: Record<string, TypographyPreset>): ConfigTokens;
34
56
  //#endregion
35
- export { generateTypographyTokens };
57
+ export { TypographyPreset, TypographyTokenValue, generateTypographyTokens };
36
58
  //# 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
- tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? "0";
38
+ tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? "normal";
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 * A typography token value: plain value or a state map for responsive/theme-aware presets.\n *\n * @example\n * // Plain value\n * fontWeight: '400'\n * // State map\n * fontWeight: { '': '400', '@dark': '300' }\n */\nexport type TypographyTokenValue =\n | string\n | number\n | Record<string, string | number | undefined | null | '@inherit'>;\n\n/**\n * Typography preset configuration.\n * Each preset defines font properties that get expanded into CSS custom properties.\n * All fields accept plain values or state maps for responsive/theme-aware tokens.\n *\n * Use with `generateTypographyTokens()` to create typography tokens for your design system.\n */\nexport interface TypographyPreset {\n fontSize: TypographyTokenValue;\n lineHeight: TypographyTokenValue;\n letterSpacing?: TypographyTokenValue;\n fontWeight: TypographyTokenValue;\n boldFontWeight?: TypographyTokenValue;\n iconSize?: TypographyTokenValue;\n textTransform?: TypographyTokenValue;\n fontFamily?: TypographyTokenValue;\n fontStyle?: TypographyTokenValue;\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: ConfigTokens = {} as ConfigTokens;\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 ?? 'normal';\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;\n}\n"],"mappings":";AAEA,MAAM,wBAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AA0DF,SAAgB,yBACd,SACc;CACd,MAAM,SAAuB,EAAE;AAE/B,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,108 +1,81 @@
1
- import { KeyframesSteps } from "../injector/types.js";
2
- import { StyleDetails, UnitHandler } from "../parser/types.js";
3
- import { StyleHandlerDefinition } from "../utils/styles.js";
4
- import { RecipeStyles } from "../styles/types.js";
5
- import { TastyPlugin } from "../plugins/types.js";
6
- import * as _babel_core0 from "@babel/core";
1
+ import { TastyConfig } from "../config.js";
2
+ import * as _$_babel_core0 from "@babel/core";
7
3
  import { PluginPass } from "@babel/core";
8
4
 
9
5
  //#region src/zero/babel.d.ts
10
6
  /**
11
7
  * Build-time configuration for zero-runtime mode.
12
- * Subset of TastyConfig that applies at build time.
8
+ * Subset of TastyConfig excluding runtime-only DOM options
9
+ * (`nonce`, `maxRulesPerSheet`, `forceTextInjection`, `gc`)
10
+ * and overriding `devMode` default to `false`.
13
11
  */
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>;
12
+ type TastyZeroConfig = Omit<TastyConfig, 'nonce' | 'maxRulesPerSheet' | 'forceTextInjection' | 'gc' | 'devMode'> & {
20
13
  /**
21
14
  * Enable development mode features: source comments in generated CSS.
22
- * Default: false
15
+ * @default false
23
16
  */
24
17
  devMode?: boolean;
18
+ };
19
+ interface TastyZeroBabelOptions {
20
+ /** Output path for generated CSS (default: 'tasty.css') */
21
+ output?: string;
25
22
  /**
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(' ') }
23
+ * Tasty configuration for build-time processing.
24
+ * Can be a static object or a factory function that returns fresh config.
25
+ * A factory is called on each plugin invocation, enabling hot reload
26
+ * of config values that depend on external files (e.g. theme tokens).
40
27
  */
41
- funcs?: Record<string, (groups: StyleDetails[]) => string>;
28
+ config?: TastyZeroConfig | (() => TastyZeroConfig);
42
29
  /**
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';
30
+ * Absolute path to a TypeScript/JavaScript module that default-exports
31
+ * a `TastyZeroConfig` object. The module is loaded via jiti on each
32
+ * plugin invocation, enabling hot reload when the file changes.
48
33
  *
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 } } }
34
+ * This option is JSON-serializable and is the primary way Turbopack
35
+ * passes config to the Babel plugin (since Turbopack loader options
36
+ * must be plain primitives/objects/arrays).
37
+ *
38
+ * When both `config` and `configFile` are set, `config` takes precedence.
39
+ *
40
+ * @example '/absolute/path/to/tasty-zero.config.ts'
64
41
  */
65
- keyframes?: Record<string, KeyframesSteps>;
42
+ configFile?: string;
66
43
  /**
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
- * ```
44
+ * Absolute file paths whose content affects the generated CSS.
45
+ * When any of these files change, babel-loader invalidates its cache
46
+ * and re-runs the plugin with fresh config values.
47
+ *
48
+ * Typically includes theme files that define Glaze palettes or token values.
49
+ * Paths must be absolute (resolved by the Next.js wrapper).
78
50
  */
79
- handlers?: Record<string, StyleHandlerDefinition>;
51
+ configDeps?: string[];
80
52
  /**
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' }
53
+ * Automatically replace `@tenphi/tasty/static` imports with an import
54
+ * of the generated CSS file. This eliminates the need for users to
55
+ * manually import the CSS in their app entry point.
56
+ *
57
+ * @default true
84
58
  */
85
- tokens?: Record<`$${string}` | `#${string}`, string | number>;
59
+ injectImport?: boolean;
86
60
  /**
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
- * ```
61
+ * Output mode for extracted CSS.
62
+ *
63
+ * - `'file'` (default): CSS is written to a single output file and
64
+ * the `@tenphi/tasty/static` import is rewritten to import that file.
65
+ * - `'inject'`: CSS is embedded inline in the JS output and injected
66
+ * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.
67
+ * No CSS file is written. Each `tastyStatic` call becomes
68
+ * self-contained. Best for reusable components and extensions.
69
+ *
70
+ * When `mode` is `'inject'`, `output` and `injectImport` are ignored.
71
+ *
72
+ * @default 'file'
96
73
  */
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;
74
+ mode?: 'file' | 'inject';
104
75
  }
105
- declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _babel_core0.PluginObj<PluginPass>;
76
+ /** Clear the shared CSSWriter cache. Exposed for testing. */
77
+ declare function clearWriterCache(): void;
78
+ declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _$_babel_core0.PluginObj<PluginPass>;
106
79
  //#endregion
107
- export { TastyZeroBabelOptions, TastyZeroConfig, _default as default };
80
+ export { TastyZeroBabelOptions, TastyZeroConfig, clearWriterCache, _default as default };
108
81
  //# sourceMappingURL=babel.d.ts.map