@tenphi/tasty 2.0.2 → 2.0.4

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 (321) hide show
  1. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
  2. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  3. package/dist/{ssr/collector.d.ts → collector-CkZ517g4.d.ts} +3 -3
  4. package/dist/{ssr/collector.js → collector-DXqvGOb1.js} +5 -10
  5. package/dist/collector-DXqvGOb1.js.map +1 -0
  6. package/dist/config-5jzS6k6B.js +10005 -0
  7. package/dist/config-5jzS6k6B.js.map +1 -0
  8. package/dist/config-DknGsfMo.d.ts +857 -0
  9. package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
  10. package/dist/context-CkSg-kDT.js.map +1 -0
  11. package/dist/core/index.d.ts +5 -34
  12. package/dist/core/index.js +5 -26
  13. package/dist/core-CtU6-9OC.js +1507 -0
  14. package/dist/core-CtU6-9OC.js.map +1 -0
  15. package/dist/{zero/extractor.js → css-writer-DHkX0JuE.js} +74 -11
  16. package/dist/css-writer-DHkX0JuE.js.map +1 -0
  17. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
  18. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  19. package/dist/format-rules-DH13ewDu.js +143 -0
  20. package/dist/format-rules-DH13ewDu.js.map +1 -0
  21. package/dist/{ssr/hydrate.js → hydrate-C1Gv-DoS.js} +3 -3
  22. package/dist/hydrate-C1Gv-DoS.js.map +1 -0
  23. package/dist/{styles/types.d.ts → index-PzENbpAq.d.ts} +701 -5
  24. package/dist/index-o7zV2yCr.d.ts +1561 -0
  25. package/dist/index.d.ts +5 -51
  26. package/dist/index.js +728 -35
  27. package/dist/index.js.map +1 -0
  28. package/dist/keyframes-b7X3UxDV.js +587 -0
  29. package/dist/keyframes-b7X3UxDV.js.map +1 -0
  30. package/dist/{utils/merge-styles.d.ts → merge-styles-C7KTy7MY.d.ts} +3 -3
  31. package/dist/{utils/merge-styles.js → merge-styles-Tgo3BbL2.js} +3 -4
  32. package/dist/merge-styles-Tgo3BbL2.js.map +1 -0
  33. package/dist/{utils/resolve-recipes.js → resolve-recipes-Ca2-5CxM.js} +4 -6
  34. package/dist/resolve-recipes-Ca2-5CxM.js.map +1 -0
  35. package/dist/ssr/astro-client.js +1 -1
  36. package/dist/ssr/astro.js +4 -4
  37. package/dist/ssr/index.d.ts +44 -4
  38. package/dist/ssr/index.js +4 -4
  39. package/dist/ssr/next.d.ts +1 -1
  40. package/dist/ssr/next.js +6 -6
  41. package/dist/ssr/next.js.map +1 -1
  42. package/dist/static/index.d.ts +91 -5
  43. package/dist/static/index.js +49 -3
  44. package/dist/static/index.js.map +1 -0
  45. package/dist/zero/babel.d.ts +1 -1
  46. package/dist/zero/babel.js +10 -6
  47. package/dist/zero/babel.js.map +1 -1
  48. package/dist/zero/index.d.ts +67 -3
  49. package/dist/zero/index.js +1 -2
  50. package/docs/pipeline.md +204 -50
  51. package/package.json +3 -3
  52. package/dist/_virtual/_rolldown/runtime.js +0 -7
  53. package/dist/chunks/cacheKey.d.ts +0 -1
  54. package/dist/chunks/cacheKey.js +0 -77
  55. package/dist/chunks/cacheKey.js.map +0 -1
  56. package/dist/chunks/definitions.d.ts +0 -37
  57. package/dist/chunks/definitions.js +0 -258
  58. package/dist/chunks/definitions.js.map +0 -1
  59. package/dist/chunks/index.d.ts +0 -1
  60. package/dist/chunks/renderChunk.d.ts +0 -1
  61. package/dist/chunks/renderChunk.js +0 -59
  62. package/dist/chunks/renderChunk.js.map +0 -1
  63. package/dist/compute-styles.d.ts +0 -31
  64. package/dist/compute-styles.js +0 -322
  65. package/dist/compute-styles.js.map +0 -1
  66. package/dist/config.d.ts +0 -407
  67. package/dist/config.js +0 -591
  68. package/dist/config.js.map +0 -1
  69. package/dist/counter-style/index.js +0 -51
  70. package/dist/counter-style/index.js.map +0 -1
  71. package/dist/debug.d.ts +0 -89
  72. package/dist/debug.js +0 -453
  73. package/dist/debug.js.map +0 -1
  74. package/dist/font-face/index.js +0 -63
  75. package/dist/font-face/index.js.map +0 -1
  76. package/dist/hooks/index.d.ts +0 -7
  77. package/dist/hooks/useCounterStyle.d.ts +0 -36
  78. package/dist/hooks/useCounterStyle.js +0 -65
  79. package/dist/hooks/useCounterStyle.js.map +0 -1
  80. package/dist/hooks/useFontFace.d.ts +0 -45
  81. package/dist/hooks/useFontFace.js +0 -66
  82. package/dist/hooks/useFontFace.js.map +0 -1
  83. package/dist/hooks/useGlobalStyles.d.ts +0 -46
  84. package/dist/hooks/useGlobalStyles.js +0 -88
  85. package/dist/hooks/useGlobalStyles.js.map +0 -1
  86. package/dist/hooks/useKeyframes.d.ts +0 -58
  87. package/dist/hooks/useKeyframes.js +0 -55
  88. package/dist/hooks/useKeyframes.js.map +0 -1
  89. package/dist/hooks/useProperty.d.ts +0 -81
  90. package/dist/hooks/useProperty.js +0 -96
  91. package/dist/hooks/useProperty.js.map +0 -1
  92. package/dist/hooks/useRawCSS.d.ts +0 -22
  93. package/dist/hooks/useRawCSS.js +0 -103
  94. package/dist/hooks/useRawCSS.js.map +0 -1
  95. package/dist/hooks/useStyles.d.ts +0 -40
  96. package/dist/hooks/useStyles.js +0 -31
  97. package/dist/hooks/useStyles.js.map +0 -1
  98. package/dist/injector/index.d.ts +0 -182
  99. package/dist/injector/index.js +0 -185
  100. package/dist/injector/index.js.map +0 -1
  101. package/dist/injector/injector.d.ts +0 -198
  102. package/dist/injector/injector.js +0 -651
  103. package/dist/injector/injector.js.map +0 -1
  104. package/dist/injector/sheet-manager.d.ts +0 -132
  105. package/dist/injector/sheet-manager.js +0 -699
  106. package/dist/injector/sheet-manager.js.map +0 -1
  107. package/dist/injector/types.d.ts +0 -235
  108. package/dist/keyframes/index.js +0 -206
  109. package/dist/keyframes/index.js.map +0 -1
  110. package/dist/parser/classify.js +0 -319
  111. package/dist/parser/classify.js.map +0 -1
  112. package/dist/parser/const.js +0 -60
  113. package/dist/parser/const.js.map +0 -1
  114. package/dist/parser/lru.js +0 -109
  115. package/dist/parser/lru.js.map +0 -1
  116. package/dist/parser/parser.d.ts +0 -25
  117. package/dist/parser/parser.js +0 -115
  118. package/dist/parser/parser.js.map +0 -1
  119. package/dist/parser/tokenizer.js +0 -69
  120. package/dist/parser/tokenizer.js.map +0 -1
  121. package/dist/parser/types.d.ts +0 -51
  122. package/dist/parser/types.js +0 -46
  123. package/dist/parser/types.js.map +0 -1
  124. package/dist/pipeline/conditions.d.ts +0 -134
  125. package/dist/pipeline/conditions.js +0 -406
  126. package/dist/pipeline/conditions.js.map +0 -1
  127. package/dist/pipeline/exclusive.js +0 -382
  128. package/dist/pipeline/exclusive.js.map +0 -1
  129. package/dist/pipeline/index.d.ts +0 -55
  130. package/dist/pipeline/index.js +0 -708
  131. package/dist/pipeline/index.js.map +0 -1
  132. package/dist/pipeline/materialize.js +0 -1157
  133. package/dist/pipeline/materialize.js.map +0 -1
  134. package/dist/pipeline/parseStateKey.d.ts +0 -15
  135. package/dist/pipeline/parseStateKey.js +0 -446
  136. package/dist/pipeline/parseStateKey.js.map +0 -1
  137. package/dist/pipeline/simplify.js +0 -690
  138. package/dist/pipeline/simplify.js.map +0 -1
  139. package/dist/pipeline/warnings.js +0 -18
  140. package/dist/pipeline/warnings.js.map +0 -1
  141. package/dist/plugins/index.d.ts +0 -2
  142. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  143. package/dist/plugins/okhsl-plugin.js +0 -97
  144. package/dist/plugins/okhsl-plugin.js.map +0 -1
  145. package/dist/plugins/types.d.ts +0 -87
  146. package/dist/properties/index.js +0 -222
  147. package/dist/properties/index.js.map +0 -1
  148. package/dist/properties/property-type-resolver.d.ts +0 -24
  149. package/dist/properties/property-type-resolver.js +0 -90
  150. package/dist/properties/property-type-resolver.js.map +0 -1
  151. package/dist/rsc-cache.js +0 -79
  152. package/dist/rsc-cache.js.map +0 -1
  153. package/dist/ssr/async-storage.d.ts +0 -17
  154. package/dist/ssr/async-storage.js.map +0 -1
  155. package/dist/ssr/collect-auto-properties.js +0 -58
  156. package/dist/ssr/collect-auto-properties.js.map +0 -1
  157. package/dist/ssr/collector.js.map +0 -1
  158. package/dist/ssr/context.js.map +0 -1
  159. package/dist/ssr/format-global-rules.js.map +0 -1
  160. package/dist/ssr/format-keyframes.js +0 -69
  161. package/dist/ssr/format-keyframes.js.map +0 -1
  162. package/dist/ssr/format-property.js +0 -49
  163. package/dist/ssr/format-property.js.map +0 -1
  164. package/dist/ssr/format-rules.js +0 -73
  165. package/dist/ssr/format-rules.js.map +0 -1
  166. package/dist/ssr/hydrate.d.ts +0 -29
  167. package/dist/ssr/hydrate.js.map +0 -1
  168. package/dist/ssr/ssr-collector-ref.js +0 -29
  169. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  170. package/dist/states/index.d.ts +0 -49
  171. package/dist/states/index.js +0 -170
  172. package/dist/states/index.js.map +0 -1
  173. package/dist/static/tastyStatic.d.ts +0 -46
  174. package/dist/static/tastyStatic.js +0 -30
  175. package/dist/static/tastyStatic.js.map +0 -1
  176. package/dist/static/types.d.ts +0 -49
  177. package/dist/static/types.js +0 -24
  178. package/dist/static/types.js.map +0 -1
  179. package/dist/styles/border.d.ts +0 -25
  180. package/dist/styles/border.js +0 -120
  181. package/dist/styles/border.js.map +0 -1
  182. package/dist/styles/color.d.ts +0 -14
  183. package/dist/styles/color.js +0 -26
  184. package/dist/styles/color.js.map +0 -1
  185. package/dist/styles/const.js +0 -17
  186. package/dist/styles/const.js.map +0 -1
  187. package/dist/styles/createStyle.js +0 -79
  188. package/dist/styles/createStyle.js.map +0 -1
  189. package/dist/styles/dimension.js +0 -109
  190. package/dist/styles/dimension.js.map +0 -1
  191. package/dist/styles/directional.js +0 -133
  192. package/dist/styles/directional.js.map +0 -1
  193. package/dist/styles/display.d.ts +0 -30
  194. package/dist/styles/display.js +0 -73
  195. package/dist/styles/display.js.map +0 -1
  196. package/dist/styles/fade.d.ts +0 -15
  197. package/dist/styles/fade.js +0 -62
  198. package/dist/styles/fade.js.map +0 -1
  199. package/dist/styles/fill.d.ts +0 -42
  200. package/dist/styles/fill.js +0 -51
  201. package/dist/styles/fill.js.map +0 -1
  202. package/dist/styles/flow.d.ts +0 -16
  203. package/dist/styles/flow.js +0 -12
  204. package/dist/styles/flow.js.map +0 -1
  205. package/dist/styles/gap.d.ts +0 -31
  206. package/dist/styles/gap.js +0 -38
  207. package/dist/styles/gap.js.map +0 -1
  208. package/dist/styles/height.d.ts +0 -17
  209. package/dist/styles/height.js +0 -19
  210. package/dist/styles/height.js.map +0 -1
  211. package/dist/styles/index.d.ts +0 -1
  212. package/dist/styles/index.js +0 -8
  213. package/dist/styles/index.js.map +0 -1
  214. package/dist/styles/inset.d.ts +0 -24
  215. package/dist/styles/inset.js +0 -34
  216. package/dist/styles/inset.js.map +0 -1
  217. package/dist/styles/list.d.ts +0 -16
  218. package/dist/styles/list.js +0 -100
  219. package/dist/styles/list.js.map +0 -1
  220. package/dist/styles/margin.d.ts +0 -24
  221. package/dist/styles/margin.js +0 -32
  222. package/dist/styles/margin.js.map +0 -1
  223. package/dist/styles/outline.d.ts +0 -29
  224. package/dist/styles/outline.js +0 -55
  225. package/dist/styles/outline.js.map +0 -1
  226. package/dist/styles/padding.d.ts +0 -24
  227. package/dist/styles/padding.js +0 -32
  228. package/dist/styles/padding.js.map +0 -1
  229. package/dist/styles/placement.d.ts +0 -37
  230. package/dist/styles/placement.js +0 -74
  231. package/dist/styles/placement.js.map +0 -1
  232. package/dist/styles/predefined.d.ts +0 -71
  233. package/dist/styles/predefined.js +0 -237
  234. package/dist/styles/predefined.js.map +0 -1
  235. package/dist/styles/preset.d.ts +0 -52
  236. package/dist/styles/preset.js +0 -127
  237. package/dist/styles/preset.js.map +0 -1
  238. package/dist/styles/radius.d.ts +0 -12
  239. package/dist/styles/radius.js +0 -83
  240. package/dist/styles/radius.js.map +0 -1
  241. package/dist/styles/scrollMargin.d.ts +0 -24
  242. package/dist/styles/scrollMargin.js +0 -32
  243. package/dist/styles/scrollMargin.js.map +0 -1
  244. package/dist/styles/scrollbar.d.ts +0 -25
  245. package/dist/styles/scrollbar.js +0 -51
  246. package/dist/styles/scrollbar.js.map +0 -1
  247. package/dist/styles/shadow.d.ts +0 -14
  248. package/dist/styles/shadow.js +0 -25
  249. package/dist/styles/shadow.js.map +0 -1
  250. package/dist/styles/shared.js +0 -17
  251. package/dist/styles/shared.js.map +0 -1
  252. package/dist/styles/transition.d.ts +0 -14
  253. package/dist/styles/transition.js +0 -159
  254. package/dist/styles/transition.js.map +0 -1
  255. package/dist/styles/width.d.ts +0 -17
  256. package/dist/styles/width.js +0 -19
  257. package/dist/styles/width.js.map +0 -1
  258. package/dist/tasty.d.ts +0 -134
  259. package/dist/tasty.js +0 -248
  260. package/dist/tasty.js.map +0 -1
  261. package/dist/types.d.ts +0 -184
  262. package/dist/utils/cache-wrapper.js +0 -21
  263. package/dist/utils/cache-wrapper.js.map +0 -1
  264. package/dist/utils/case-converter.js +0 -8
  265. package/dist/utils/case-converter.js.map +0 -1
  266. package/dist/utils/color-math.d.ts +0 -46
  267. package/dist/utils/color-math.js +0 -749
  268. package/dist/utils/color-math.js.map +0 -1
  269. package/dist/utils/color-space.d.ts +0 -5
  270. package/dist/utils/color-space.js +0 -228
  271. package/dist/utils/color-space.js.map +0 -1
  272. package/dist/utils/colors.d.ts +0 -5
  273. package/dist/utils/colors.js +0 -10
  274. package/dist/utils/colors.js.map +0 -1
  275. package/dist/utils/css-types.d.ts +0 -7
  276. package/dist/utils/deps-equal.js +0 -15
  277. package/dist/utils/deps-equal.js.map +0 -1
  278. package/dist/utils/dotize.d.ts +0 -26
  279. package/dist/utils/dotize.js +0 -122
  280. package/dist/utils/dotize.js.map +0 -1
  281. package/dist/utils/filter-base-props.d.ts +0 -15
  282. package/dist/utils/filter-base-props.js +0 -45
  283. package/dist/utils/filter-base-props.js.map +0 -1
  284. package/dist/utils/get-display-name.d.ts +0 -7
  285. package/dist/utils/get-display-name.js +0 -10
  286. package/dist/utils/get-display-name.js.map +0 -1
  287. package/dist/utils/has-keys.js +0 -13
  288. package/dist/utils/has-keys.js.map +0 -1
  289. package/dist/utils/hash.js +0 -14
  290. package/dist/utils/hash.js.map +0 -1
  291. package/dist/utils/is-dev-env.js +0 -19
  292. package/dist/utils/is-dev-env.js.map +0 -1
  293. package/dist/utils/is-valid-element-type.js +0 -15
  294. package/dist/utils/is-valid-element-type.js.map +0 -1
  295. package/dist/utils/merge-styles.js.map +0 -1
  296. package/dist/utils/mod-attrs.d.ts +0 -6
  297. package/dist/utils/mod-attrs.js +0 -20
  298. package/dist/utils/mod-attrs.js.map +0 -1
  299. package/dist/utils/process-tokens.d.ts +0 -17
  300. package/dist/utils/process-tokens.js +0 -83
  301. package/dist/utils/process-tokens.js.map +0 -1
  302. package/dist/utils/resolve-recipes.d.ts +0 -17
  303. package/dist/utils/resolve-recipes.js.map +0 -1
  304. package/dist/utils/selector-transform.js +0 -32
  305. package/dist/utils/selector-transform.js.map +0 -1
  306. package/dist/utils/string.js +0 -8
  307. package/dist/utils/string.js.map +0 -1
  308. package/dist/utils/styles.d.ts +0 -99
  309. package/dist/utils/styles.js +0 -220
  310. package/dist/utils/styles.js.map +0 -1
  311. package/dist/utils/typography.d.ts +0 -58
  312. package/dist/utils/typography.js +0 -51
  313. package/dist/utils/typography.js.map +0 -1
  314. package/dist/utils/warnings.d.ts +0 -16
  315. package/dist/utils/warnings.js +0 -16
  316. package/dist/utils/warnings.js.map +0 -1
  317. package/dist/zero/css-writer.d.ts +0 -45
  318. package/dist/zero/css-writer.js +0 -73
  319. package/dist/zero/css-writer.js.map +0 -1
  320. package/dist/zero/extractor.d.ts +0 -24
  321. package/dist/zero/extractor.js.map +0 -1
package/dist/config.js DELETED
@@ -1,591 +0,0 @@
1
- import { resetColorSpace, setColorSpace } from "./utils/color-space.js";
2
- import { isDevEnv } from "./utils/is-dev-env.js";
3
- import { CUSTOM_UNITS, getGlobalFuncs, getGlobalParser, normalizeColorTokenValue, resetGlobalPredefinedTokens, setGlobalPredefinedTokens } from "./utils/styles.js";
4
- import { normalizeHandlerDefinition, registerHandler, resetHandlers } from "./styles/predefined.js";
5
- import { StyleInjector } from "./injector/injector.js";
6
- import { setGlobalPredefinedStates } from "./states/index.js";
7
- import { clearPipelineCache, isSelector, renderStyles } from "./pipeline/index.js";
8
- import { generateTypographyTokens } from "./utils/typography.js";
9
- //#region src/config.ts
10
- /**
11
- * Tasty Configuration Module
12
- *
13
- * Centralizes all tasty configuration, including:
14
- * - Style injector settings (nonce, cleanup thresholds, etc.)
15
- * - Global predefined states for advanced state mapping
16
- * - stylesGenerated flag that locks configuration after first style generation
17
- *
18
- * Configuration must be done BEFORE any styles are generated.
19
- * After the first `inject()` call, configuration is locked and attempts to
20
- * reconfigure will emit a warning and be ignored.
21
- */
22
- const emittedWarnings = /* @__PURE__ */ new Set();
23
- const devMode = isDevEnv();
24
- /**
25
- * Emit a warning only once
26
- */
27
- function warnOnce(key, message) {
28
- if (devMode && !emittedWarnings.has(key)) {
29
- emittedWarnings.add(key);
30
- console.warn(message);
31
- }
32
- }
33
- let stylesGenerated = false;
34
- let currentConfig = null;
35
- let globalKeyframes = null;
36
- let globalFontFace = null;
37
- let globalCounterStyle = null;
38
- let globalProperties = null;
39
- let globalRecipes = null;
40
- let globalConfigTokens = null;
41
- let globalStyles = null;
42
- const GTKEY_TOKENS = "__tasty_cfg_tokens__";
43
- const GTKEY_FONT_FACE = "__tasty_cfg_font_face__";
44
- const GTKEY_COUNTER_STYLE = "__tasty_cfg_counter_style__";
45
- const GTKEY_PROPERTIES = "__tasty_cfg_properties__";
46
- const GTKEY_GLOBAL_STYLES = "__tasty_cfg_global_styles__";
47
- function setOnGlobalThis(key, value) {
48
- globalThis[key] = value;
49
- }
50
- function getFromGlobalThis(key) {
51
- return globalThis[key];
52
- }
53
- function clearGlobalThisConfig() {
54
- const g = globalThis;
55
- delete g[GTKEY_TOKENS];
56
- delete g[GTKEY_FONT_FACE];
57
- delete g[GTKEY_COUNTER_STYLE];
58
- delete g[GTKEY_PROPERTIES];
59
- delete g[GTKEY_GLOBAL_STYLES];
60
- }
61
- /**
62
- * Default properties shipped with tasty.
63
- * These are always included unless explicitly overridden via `configure({ properties })`.
64
- * Keys use tasty token syntax (#name for colors, $name for other properties).
65
- *
66
- * For properties with CSS @property-compatible types (length, time, number, color),
67
- * an `initialValue` is provided so the property works even without a project-level token.
68
- */
69
- const DEFAULT_PROPERTIES = {
70
- "#tasty-second-fill": {
71
- inherits: false,
72
- initialValue: "transparent"
73
- },
74
- "#current": {
75
- inherits: true,
76
- initialValue: "transparent"
77
- },
78
- "#white": {
79
- inherits: true,
80
- initialValue: "rgb(255 255 255)"
81
- },
82
- "#black": {
83
- inherits: true,
84
- initialValue: "rgb(0 0 0)"
85
- },
86
- "#clear": {
87
- inherits: true,
88
- initialValue: "transparent"
89
- },
90
- "#border": {
91
- inherits: true,
92
- initialValue: "rgb(0 0 0)"
93
- },
94
- $gap: {
95
- syntax: "<length>",
96
- inherits: true,
97
- initialValue: "4px"
98
- },
99
- $radius: {
100
- syntax: "<length>",
101
- inherits: true,
102
- initialValue: "6px"
103
- },
104
- "$border-width": {
105
- syntax: "<length>",
106
- inherits: true,
107
- initialValue: "1px"
108
- },
109
- "$outline-width": {
110
- syntax: "<length>",
111
- inherits: true,
112
- initialValue: "3px"
113
- },
114
- $transition: {
115
- syntax: "<time>",
116
- inherits: true,
117
- initialValue: "80ms"
118
- },
119
- "$sharp-radius": {
120
- syntax: "<length>",
121
- inherits: true,
122
- initialValue: "0px"
123
- },
124
- "$bold-font-weight": {
125
- syntax: "<number>",
126
- inherits: true,
127
- initialValue: "700"
128
- },
129
- "$font-sans-fallback": {
130
- syntax: "*",
131
- inherits: true,
132
- initialValue: "system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, \"Apple Color Emoji\", \"Segoe UI Emoji\", sans-serif"
133
- },
134
- "$font-mono-fallback": {
135
- syntax: "*",
136
- inherits: true,
137
- initialValue: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace"
138
- }
139
- };
140
- const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
141
- /**
142
- * Detect if we're running in a test environment
143
- */
144
- function isTestEnvironment() {
145
- if (typeof global !== "undefined") {
146
- const g = global;
147
- if (g.vi || g.jest || g.expect || g.describe || g.it) return true;
148
- }
149
- if (typeof window !== "undefined" && window.navigator?.userAgent?.includes("jsdom")) return true;
150
- if (typeof globalThis !== "undefined") {
151
- const gt = globalThis;
152
- if (gt.vitest || gt.mocha) return true;
153
- }
154
- return false;
155
- }
156
- /**
157
- * Create default configuration with optional test environment detection
158
- */
159
- function createDefaultConfig(isTest) {
160
- return {
161
- maxRulesPerSheet: 8192,
162
- forceTextInjection: isTest ?? false,
163
- devMode: isDevEnv()
164
- };
165
- }
166
- /**
167
- * Mark that styles have been generated (called by injector on first inject)
168
- * This locks the configuration - no further changes allowed.
169
- * Also injects internal and global properties.
170
- */
171
- function markStylesGenerated() {
172
- if (stylesGenerated) return;
173
- stylesGenerated = true;
174
- if (typeof document !== "undefined" && document.querySelector("style[data-tasty-ssr]")) {
175
- warnOnce("ssr-globals-skip", "[Tasty] SSR styles detected — skipping client-side global CSS injection to avoid duplicates.");
176
- return;
177
- }
178
- const injector = getGlobalInjector();
179
- for (const [token, definition] of Object.entries(getEffectiveProperties())) injector.property(token, definition);
180
- if (globalFontFace && Object.keys(globalFontFace).length > 0) for (const [family, input] of Object.entries(globalFontFace)) {
181
- const descriptors = Array.isArray(input) ? input : [input];
182
- for (const desc of descriptors) injector.fontFace(family, desc);
183
- }
184
- if (globalCounterStyle && Object.keys(globalCounterStyle).length > 0) for (const [name, descriptors] of Object.entries(globalCounterStyle)) injector.counterStyle(name, descriptors);
185
- if (globalConfigTokens && Object.keys(globalConfigTokens).length > 0) {
186
- const tokenRules = renderStyles(globalConfigTokens, ":root");
187
- if (tokenRules.length > 0) injector.injectGlobal(tokenRules);
188
- }
189
- if (globalStyles) {
190
- for (const [selector, styles] of Object.entries(globalStyles)) if (Object.keys(styles).length > 0) {
191
- const rules = renderStyles(styles, selector);
192
- if (rules.length > 0) injector.injectGlobal(rules);
193
- }
194
- }
195
- }
196
- /**
197
- * Check if styles have been generated (configuration is locked)
198
- */
199
- function hasStylesGenerated() {
200
- return stylesGenerated;
201
- }
202
- let _hasGlobalKeyframes = false;
203
- /**
204
- * Check if any global keyframes are configured.
205
- * Uses a pre-computed flag to avoid Object.keys() allocation on every call.
206
- */
207
- function hasGlobalKeyframes() {
208
- return _hasGlobalKeyframes;
209
- }
210
- /**
211
- * Get global keyframes configuration.
212
- * Returns null if no keyframes configured (fast path for zero-overhead).
213
- */
214
- function getGlobalKeyframes() {
215
- return globalKeyframes;
216
- }
217
- /**
218
- * Set global keyframes (called from configure).
219
- * Internal use only.
220
- */
221
- function setGlobalKeyframes(keyframes) {
222
- if (stylesGenerated) {
223
- warnOnce("keyframes-after-styles", "[Tasty] Cannot update keyframes after styles have been generated.\nThe new keyframes will be ignored.");
224
- return;
225
- }
226
- globalKeyframes = keyframes;
227
- _hasGlobalKeyframes = Object.keys(keyframes).length > 0;
228
- }
229
- /**
230
- * Set global properties (called from configure).
231
- * Internal use only.
232
- */
233
- function setGlobalProperties(properties) {
234
- if (stylesGenerated) {
235
- warnOnce("properties-after-styles", "[Tasty] Cannot update properties after styles have been generated.\nThe new properties will be ignored.");
236
- return;
237
- }
238
- globalProperties = properties;
239
- setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);
240
- }
241
- /**
242
- * Get the effective properties: DEFAULT_PROPERTIES merged with user-configured
243
- * properties. User properties override defaults with matching keys.
244
- * Reads from globalThis first for cross-module SSR support.
245
- */
246
- function getEffectiveProperties() {
247
- const props = globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES);
248
- if (!props) return DEFAULT_PROPERTIES;
249
- return {
250
- ...DEFAULT_PROPERTIES,
251
- ...props
252
- };
253
- }
254
- /**
255
- * Get global font-face configuration.
256
- * Returns null if no font faces configured.
257
- * Reads from globalThis first for cross-module SSR support.
258
- */
259
- function getGlobalFontFace() {
260
- return globalFontFace ?? getFromGlobalThis(GTKEY_FONT_FACE) ?? null;
261
- }
262
- /**
263
- * Set global font faces (called from configure).
264
- * Internal use only.
265
- */
266
- function setGlobalFontFace(fontFace) {
267
- if (stylesGenerated) {
268
- warnOnce("fontface-after-styles", "[Tasty] Cannot update fontFace after styles have been generated.\nThe new font faces will be ignored.");
269
- return;
270
- }
271
- globalFontFace = fontFace;
272
- setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);
273
- }
274
- /**
275
- * Get global counter-style configuration.
276
- * Returns null if no counter styles configured.
277
- * Reads from globalThis first for cross-module SSR support.
278
- */
279
- function getGlobalCounterStyle() {
280
- return globalCounterStyle ?? getFromGlobalThis(GTKEY_COUNTER_STYLE) ?? null;
281
- }
282
- /**
283
- * Set global counter styles (called from configure).
284
- * Internal use only.
285
- */
286
- function setGlobalCounterStyle(counterStyle) {
287
- if (stylesGenerated) {
288
- warnOnce("counterstyle-after-styles", "[Tasty] Cannot update counterStyle after styles have been generated.\nThe new counter styles will be ignored.");
289
- return;
290
- }
291
- globalCounterStyle = counterStyle;
292
- setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);
293
- }
294
- /**
295
- * Check if any global recipes are configured.
296
- * Fast path: returns false if no recipes were ever set.
297
- */
298
- function hasGlobalRecipes() {
299
- return globalRecipes !== null && Object.keys(globalRecipes).length > 0;
300
- }
301
- /**
302
- * Get global recipes configuration.
303
- * Returns null if no recipes configured (fast path for zero-overhead).
304
- */
305
- function getGlobalRecipes() {
306
- return globalRecipes;
307
- }
308
- /**
309
- * Set global recipes (called from configure).
310
- * Internal use only.
311
- */
312
- function setGlobalRecipes(recipes) {
313
- if (stylesGenerated) {
314
- warnOnce("recipes-after-styles", "[Tasty] Cannot update recipes after styles have been generated.\nThe new recipes will be ignored.");
315
- return;
316
- }
317
- if (devMode) for (const [name, recipeStyles] of Object.entries(recipes)) {
318
- if (name === "none") warnOnce("recipe-reserved-none", "[Tasty] Recipe name \"none\" is reserved. It is used as a keyword meaning \"no base recipes\" (e.g. recipe: 'none / post-recipe'). Choose a different name for your recipe.");
319
- for (const key of Object.keys(recipeStyles)) {
320
- if (isSelector(key)) warnOnce(`recipe-selector-${name}-${key}`, `[Tasty] Recipe "${name}" contains sub-element key "${key}". Recipes must be flat styles without sub-element keys. Remove the sub-element key from the recipe definition.`);
321
- if (key === "recipe") warnOnce(`recipe-recursive-${name}`, `[Tasty] Recipe "${name}" contains a "recipe" key. Recipes cannot reference other recipes. Use space-separated names for composition: recipe: 'base elevated'.`);
322
- }
323
- }
324
- globalRecipes = recipes;
325
- }
326
- /**
327
- * Get global token styles for :root injection.
328
- * Returns null if no tokens configured.
329
- * Reads from globalThis first for cross-module SSR support.
330
- */
331
- function getGlobalConfigTokens() {
332
- return globalConfigTokens ?? getFromGlobalThis(GTKEY_TOKENS) ?? null;
333
- }
334
- /**
335
- * Set global token styles (called from configure).
336
- * Internal use only.
337
- */
338
- function setGlobalConfigTokens(styles) {
339
- if (stylesGenerated) {
340
- warnOnce("tokens-after-styles", "[Tasty] Cannot update tokens after styles have been generated.\nThe new tokens will be ignored.");
341
- return;
342
- }
343
- globalConfigTokens = globalConfigTokens ? {
344
- ...globalConfigTokens,
345
- ...styles
346
- } : styles;
347
- setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);
348
- }
349
- /**
350
- * Get configured global styles for injection.
351
- * Returns null if no global styles configured.
352
- * Reads from globalThis first for cross-module SSR support.
353
- */
354
- function getGlobalStyles() {
355
- return globalStyles ?? getFromGlobalThis(GTKEY_GLOBAL_STYLES) ?? null;
356
- }
357
- /**
358
- * Set configured global styles (called from configure).
359
- * Internal use only.
360
- */
361
- function setGlobalStyles(styles) {
362
- if (stylesGenerated) {
363
- warnOnce("globalStyles-after-styles", "[Tasty] Cannot update globalStyles after styles have been generated.\nThe new global styles will be ignored.");
364
- return;
365
- }
366
- if (globalStyles) for (const [selector, selectorStyles] of Object.entries(styles)) globalStyles[selector] = globalStyles[selector] ? {
367
- ...globalStyles[selector],
368
- ...selectorStyles
369
- } : selectorStyles;
370
- else globalStyles = { ...styles };
371
- setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);
372
- }
373
- /**
374
- * Check if configuration is locked (styles have been generated)
375
- */
376
- function isConfigLocked() {
377
- return stylesGenerated;
378
- }
379
- /**
380
- * Configure the Tasty style system.
381
- *
382
- * Must be called BEFORE any styles are generated (before first render that uses tasty).
383
- * After styles are generated, configuration is locked and calls to configure() will
384
- * emit a warning and be ignored.
385
- *
386
- * @example
387
- * ```ts
388
- * import { configure } from '@tenphi/tasty';
389
- *
390
- * // Configure before app renders
391
- * configure({
392
- * nonce: 'abc123',
393
- * states: {
394
- * '@mobile': '@media(w < 768px)',
395
- * '@dark': '@root(theme=dark)',
396
- * },
397
- * });
398
- * ```
399
- */
400
- function configure(config = {}) {
401
- if (stylesGenerated) {
402
- warnOnce("configure-after-styles", "[Tasty] Cannot call configure() after styles have been generated.\nConfiguration must be done before the first render. The configuration will be ignored.");
403
- return;
404
- }
405
- let mergedStates = {};
406
- let mergedUnits = {};
407
- let mergedFuncs = {};
408
- let mergedHandlers = {};
409
- let mergedReplaceTokens = {};
410
- let mergedConfigTokens = {};
411
- let mergedRecipes = {};
412
- let mergedPresets = {};
413
- const mergedGlobalStyles = {};
414
- if (config.plugins) for (const plugin of config.plugins) {
415
- if (plugin.states) mergedStates = {
416
- ...mergedStates,
417
- ...plugin.states
418
- };
419
- if (plugin.units) mergedUnits = {
420
- ...mergedUnits,
421
- ...plugin.units
422
- };
423
- if (plugin.funcs) mergedFuncs = {
424
- ...mergedFuncs,
425
- ...plugin.funcs
426
- };
427
- if (plugin.handlers) mergedHandlers = {
428
- ...mergedHandlers,
429
- ...plugin.handlers
430
- };
431
- if (plugin.replaceTokens) mergedReplaceTokens = {
432
- ...mergedReplaceTokens,
433
- ...plugin.replaceTokens
434
- };
435
- if (plugin.tokens) mergedConfigTokens = {
436
- ...mergedConfigTokens,
437
- ...plugin.tokens
438
- };
439
- if (plugin.recipes) mergedRecipes = {
440
- ...mergedRecipes,
441
- ...plugin.recipes
442
- };
443
- if (plugin.presets) mergedPresets = {
444
- ...mergedPresets,
445
- ...plugin.presets
446
- };
447
- if (plugin.globalStyles) for (const [sel, styles] of Object.entries(plugin.globalStyles)) mergedGlobalStyles[sel] = mergedGlobalStyles[sel] ? {
448
- ...mergedGlobalStyles[sel],
449
- ...styles
450
- } : styles;
451
- }
452
- if (config.states) mergedStates = {
453
- ...mergedStates,
454
- ...config.states
455
- };
456
- if (config.units) mergedUnits = {
457
- ...mergedUnits,
458
- ...config.units
459
- };
460
- if (config.funcs) mergedFuncs = {
461
- ...mergedFuncs,
462
- ...config.funcs
463
- };
464
- if (config.handlers) mergedHandlers = {
465
- ...mergedHandlers,
466
- ...config.handlers
467
- };
468
- if (config.replaceTokens) mergedReplaceTokens = {
469
- ...mergedReplaceTokens,
470
- ...config.replaceTokens
471
- };
472
- if (config.presets) mergedPresets = {
473
- ...mergedPresets,
474
- ...config.presets
475
- };
476
- if (Object.keys(mergedPresets).length > 0) mergedConfigTokens = {
477
- ...generateTypographyTokens(mergedPresets),
478
- ...mergedConfigTokens
479
- };
480
- if (config.tokens) mergedConfigTokens = {
481
- ...mergedConfigTokens,
482
- ...config.tokens
483
- };
484
- if (config.recipes) mergedRecipes = {
485
- ...mergedRecipes,
486
- ...config.recipes
487
- };
488
- if (config.globalStyles) for (const [sel, styles] of Object.entries(config.globalStyles)) mergedGlobalStyles[sel] = mergedGlobalStyles[sel] ? {
489
- ...mergedGlobalStyles[sel],
490
- ...styles
491
- } : styles;
492
- if (devMode) {
493
- const tokenKeys = new Set(Object.keys(mergedConfigTokens));
494
- for (const key of Object.keys(mergedReplaceTokens)) if (tokenKeys.has(key)) warnOnce(`token-conflict-${key}`, `[Tasty] Token "${key}" is defined in both \`tokens\` and \`replaceTokens\`. \`replaceTokens\` performs parse-time substitution, so the \`tokens\` CSS custom property will be injected but never used by Tasty styles. Remove it from one of the two.`);
495
- }
496
- if (config.colorSpace) {
497
- setColorSpace(config.colorSpace);
498
- getGlobalParser().clearCache();
499
- }
500
- if (Object.keys(mergedStates).length > 0) setGlobalPredefinedStates(mergedStates);
501
- const parser = getGlobalParser();
502
- if (config.parserCacheSize !== void 0) parser.updateOptions({ cacheSize: config.parserCacheSize });
503
- if (Object.keys(mergedUnits).length > 0) {
504
- const currentUnits = parser.getUnits() ?? CUSTOM_UNITS;
505
- parser.setUnits({
506
- ...currentUnits,
507
- ...mergedUnits
508
- });
509
- }
510
- if (Object.keys(mergedFuncs).length > 0) {
511
- const currentFuncs = getGlobalFuncs();
512
- const finalFuncs = {
513
- ...currentFuncs,
514
- ...mergedFuncs
515
- };
516
- parser.setFuncs(finalFuncs);
517
- Object.assign(currentFuncs, mergedFuncs);
518
- }
519
- if (config.keyframes) setGlobalKeyframes(config.keyframes);
520
- if (config.properties) setGlobalProperties(config.properties);
521
- if (config.fontFace) setGlobalFontFace(config.fontFace);
522
- if (config.counterStyle) setGlobalCounterStyle(config.counterStyle);
523
- if (Object.keys(mergedHandlers).length > 0) for (const [name, definition] of Object.entries(mergedHandlers)) registerHandler(normalizeHandlerDefinition(name, definition));
524
- if (Object.keys(mergedReplaceTokens).length > 0) {
525
- const processedTokens = {};
526
- for (const [key, value] of Object.entries(mergedReplaceTokens)) if (key.startsWith("#")) {
527
- const normalized = normalizeColorTokenValue(value);
528
- if (normalized === null) continue;
529
- processedTokens[key] = String(normalized);
530
- } else if (value === false) continue;
531
- else processedTokens[key] = String(value);
532
- setGlobalPredefinedTokens(processedTokens);
533
- }
534
- if (Object.keys(mergedConfigTokens).length > 0) setGlobalConfigTokens(mergedConfigTokens);
535
- if (Object.keys(mergedRecipes).length > 0) setGlobalRecipes(mergedRecipes);
536
- if (Object.keys(mergedGlobalStyles).length > 0) setGlobalStyles(mergedGlobalStyles);
537
- const { states: _states, parserCacheSize: _parserCacheSize, units: _units, funcs: _funcs, plugins: _plugins, keyframes: _keyframes, properties: _properties, fontFace: _fontFace, counterStyle: _counterStyle, handlers: _handlers, tokens: _tokens, replaceTokens: _replaceTokens, recipes: _recipes, colorSpace: _colorSpace, presets: _presets, globalStyles: _globalStyles, ...injectorConfig } = config;
538
- const fullConfig = {
539
- ...createDefaultConfig(),
540
- ...currentConfig,
541
- ...injectorConfig
542
- };
543
- currentConfig = fullConfig;
544
- const storage = typeof window !== "undefined" ? window : globalThis;
545
- storage[GLOBAL_INJECTOR_KEY] = new StyleInjector(fullConfig);
546
- }
547
- /**
548
- * Get the current configuration.
549
- * If not configured, returns default configuration.
550
- */
551
- function getConfig() {
552
- if (!currentConfig) currentConfig = createDefaultConfig(isTestEnvironment());
553
- return currentConfig;
554
- }
555
- /**
556
- * Get the global injector instance.
557
- * Auto-configures with defaults if not already configured.
558
- */
559
- function getGlobalInjector() {
560
- const storage = typeof window !== "undefined" ? window : globalThis;
561
- if (!storage[GLOBAL_INJECTOR_KEY]) configure();
562
- return storage[GLOBAL_INJECTOR_KEY];
563
- }
564
- /**
565
- * Reset configuration (for testing only).
566
- * Clears the global injector and allows reconfiguration.
567
- */
568
- function resetConfig() {
569
- stylesGenerated = false;
570
- currentConfig = null;
571
- globalKeyframes = null;
572
- _hasGlobalKeyframes = false;
573
- globalProperties = null;
574
- globalFontFace = null;
575
- globalCounterStyle = null;
576
- globalRecipes = null;
577
- globalConfigTokens = null;
578
- globalStyles = null;
579
- clearGlobalThisConfig();
580
- resetGlobalPredefinedTokens();
581
- resetHandlers();
582
- resetColorSpace();
583
- clearPipelineCache();
584
- emittedWarnings.clear();
585
- const storage = typeof window !== "undefined" ? window : globalThis;
586
- delete storage[GLOBAL_INJECTOR_KEY];
587
- }
588
- //#endregion
589
- export { configure, getConfig, getEffectiveProperties, getGlobalConfigTokens, getGlobalCounterStyle, getGlobalFontFace, getGlobalInjector, getGlobalKeyframes, getGlobalRecipes, getGlobalStyles, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, markStylesGenerated, resetConfig };
590
-
591
- //# sourceMappingURL=config.js.map