@tenphi/tasty 0.0.0-snapshot.407dbfc → 0.0.0-snapshot.41a8fde

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 (342) hide show
  1. package/README.md +33 -23
  2. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +16 -6
  3. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  4. package/dist/{ssr/collector.js → collector-CBddDz-s.js} +50 -26
  5. package/dist/collector-CBddDz-s.js.map +1 -0
  6. package/dist/{ssr/collector.d.ts → collector-osfWTeRd.d.ts} +21 -15
  7. package/dist/config-BoZDUHW5.d.ts +945 -0
  8. package/dist/config-dkNtxY1j.js +10462 -0
  9. package/dist/config-dkNtxY1j.js.map +1 -0
  10. package/dist/context-CkSg-kDT.js +24 -0
  11. package/dist/context-CkSg-kDT.js.map +1 -0
  12. package/dist/core/index.d.ts +5 -34
  13. package/dist/core/index.js +6 -27
  14. package/dist/core-CWJ4JX5P.js +1598 -0
  15. package/dist/core-CWJ4JX5P.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-DPR4cAyK.js} +98 -13
  17. package/dist/css-writer-DPR4cAyK.js.map +1 -0
  18. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
  19. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  20. package/dist/format-rules-BnfFVBQE.js +143 -0
  21. package/dist/format-rules-BnfFVBQE.js.map +1 -0
  22. package/dist/hydrate-Chagc_CN.js +45 -0
  23. package/dist/hydrate-Chagc_CN.js.map +1 -0
  24. package/dist/index-B_k47mc_.d.ts +1655 -0
  25. package/dist/index-tcHuMPFt.d.ts +1286 -0
  26. package/dist/index.d.ts +5 -51
  27. package/dist/index.js +732 -36
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-Dbe0HQAg.js +588 -0
  30. package/dist/keyframes-Dbe0HQAg.js.map +1 -0
  31. package/dist/{utils/merge-styles.d.ts → merge-styles-BMWcH6MF.d.ts} +3 -3
  32. package/dist/{utils/merge-styles.js → merge-styles-CWRl0mKF.js} +3 -4
  33. package/dist/merge-styles-CWRl0mKF.js.map +1 -0
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-DZBMeDib.js} +4 -6
  35. package/dist/resolve-recipes-DZBMeDib.js.map +1 -0
  36. package/dist/ssr/astro-client.js +5 -10
  37. package/dist/ssr/astro-client.js.map +1 -1
  38. package/dist/ssr/astro.d.ts +5 -14
  39. package/dist/ssr/astro.js +43 -48
  40. package/dist/ssr/astro.js.map +1 -1
  41. package/dist/ssr/index.d.ts +44 -4
  42. package/dist/ssr/index.js +6 -6
  43. package/dist/ssr/index.js.map +1 -1
  44. package/dist/ssr/next.d.ts +7 -4
  45. package/dist/ssr/next.js +10 -9
  46. package/dist/ssr/next.js.map +1 -1
  47. package/dist/static/index.d.ts +91 -5
  48. package/dist/static/index.js +49 -3
  49. package/dist/static/index.js.map +1 -0
  50. package/dist/zero/babel.d.ts +7 -108
  51. package/dist/zero/babel.js +57 -21
  52. package/dist/zero/babel.js.map +1 -1
  53. package/dist/zero/index.d.ts +67 -3
  54. package/dist/zero/index.js +1 -2
  55. package/docs/README.md +4 -4
  56. package/docs/adoption.md +5 -3
  57. package/docs/comparison.md +24 -25
  58. package/docs/configuration.md +113 -1
  59. package/docs/debug.md +11 -9
  60. package/docs/design-system.md +22 -10
  61. package/docs/dsl.md +17 -15
  62. package/docs/getting-started.md +10 -10
  63. package/docs/injector.md +4 -4
  64. package/docs/methodology.md +28 -2
  65. package/docs/{PIPELINE.md → pipeline.md} +230 -50
  66. package/docs/{runtime.md → react-api.md} +30 -1
  67. package/docs/ssr.md +18 -9
  68. package/docs/styles.md +9 -7
  69. package/docs/tasty-static.md +29 -2
  70. package/package.json +11 -10
  71. package/tasty.config.ts +1 -0
  72. package/dist/_virtual/_rolldown/runtime.js +0 -7
  73. package/dist/chunks/cacheKey.d.ts +0 -1
  74. package/dist/chunks/cacheKey.js +0 -77
  75. package/dist/chunks/cacheKey.js.map +0 -1
  76. package/dist/chunks/definitions.d.ts +0 -37
  77. package/dist/chunks/definitions.js +0 -258
  78. package/dist/chunks/definitions.js.map +0 -1
  79. package/dist/chunks/index.d.ts +0 -1
  80. package/dist/chunks/renderChunk.d.ts +0 -1
  81. package/dist/chunks/renderChunk.js +0 -59
  82. package/dist/chunks/renderChunk.js.map +0 -1
  83. package/dist/compute-styles.d.ts +0 -31
  84. package/dist/compute-styles.js +0 -335
  85. package/dist/compute-styles.js.map +0 -1
  86. package/dist/config.d.ts +0 -367
  87. package/dist/config.js +0 -502
  88. package/dist/config.js.map +0 -1
  89. package/dist/counter-style/index.js +0 -51
  90. package/dist/counter-style/index.js.map +0 -1
  91. package/dist/debug.d.ts +0 -89
  92. package/dist/debug.js +0 -453
  93. package/dist/debug.js.map +0 -1
  94. package/dist/font-face/index.js +0 -63
  95. package/dist/font-face/index.js.map +0 -1
  96. package/dist/hooks/index.d.ts +0 -7
  97. package/dist/hooks/useCounterStyle.d.ts +0 -36
  98. package/dist/hooks/useCounterStyle.js +0 -64
  99. package/dist/hooks/useCounterStyle.js.map +0 -1
  100. package/dist/hooks/useFontFace.d.ts +0 -45
  101. package/dist/hooks/useFontFace.js +0 -66
  102. package/dist/hooks/useFontFace.js.map +0 -1
  103. package/dist/hooks/useGlobalStyles.d.ts +0 -46
  104. package/dist/hooks/useGlobalStyles.js +0 -87
  105. package/dist/hooks/useGlobalStyles.js.map +0 -1
  106. package/dist/hooks/useKeyframes.d.ts +0 -58
  107. package/dist/hooks/useKeyframes.js +0 -54
  108. package/dist/hooks/useKeyframes.js.map +0 -1
  109. package/dist/hooks/useProperty.d.ts +0 -81
  110. package/dist/hooks/useProperty.js +0 -96
  111. package/dist/hooks/useProperty.js.map +0 -1
  112. package/dist/hooks/useRawCSS.d.ts +0 -22
  113. package/dist/hooks/useRawCSS.js +0 -103
  114. package/dist/hooks/useRawCSS.js.map +0 -1
  115. package/dist/hooks/useStyles.d.ts +0 -40
  116. package/dist/hooks/useStyles.js +0 -29
  117. package/dist/hooks/useStyles.js.map +0 -1
  118. package/dist/injector/index.d.ts +0 -182
  119. package/dist/injector/index.js +0 -185
  120. package/dist/injector/index.js.map +0 -1
  121. package/dist/injector/injector.d.ts +0 -193
  122. package/dist/injector/injector.js +0 -564
  123. package/dist/injector/injector.js.map +0 -1
  124. package/dist/injector/sheet-manager.d.ts +0 -132
  125. package/dist/injector/sheet-manager.js +0 -698
  126. package/dist/injector/sheet-manager.js.map +0 -1
  127. package/dist/injector/types.d.ts +0 -228
  128. package/dist/keyframes/index.js +0 -206
  129. package/dist/keyframes/index.js.map +0 -1
  130. package/dist/parser/classify.js +0 -319
  131. package/dist/parser/classify.js.map +0 -1
  132. package/dist/parser/const.js +0 -60
  133. package/dist/parser/const.js.map +0 -1
  134. package/dist/parser/lru.js +0 -109
  135. package/dist/parser/lru.js.map +0 -1
  136. package/dist/parser/parser.d.ts +0 -25
  137. package/dist/parser/parser.js +0 -115
  138. package/dist/parser/parser.js.map +0 -1
  139. package/dist/parser/tokenizer.js +0 -69
  140. package/dist/parser/tokenizer.js.map +0 -1
  141. package/dist/parser/types.d.ts +0 -51
  142. package/dist/parser/types.js +0 -46
  143. package/dist/parser/types.js.map +0 -1
  144. package/dist/pipeline/conditions.d.ts +0 -134
  145. package/dist/pipeline/conditions.js +0 -406
  146. package/dist/pipeline/conditions.js.map +0 -1
  147. package/dist/pipeline/exclusive.js +0 -230
  148. package/dist/pipeline/exclusive.js.map +0 -1
  149. package/dist/pipeline/index.d.ts +0 -55
  150. package/dist/pipeline/index.js +0 -708
  151. package/dist/pipeline/index.js.map +0 -1
  152. package/dist/pipeline/materialize.js +0 -1103
  153. package/dist/pipeline/materialize.js.map +0 -1
  154. package/dist/pipeline/parseStateKey.d.ts +0 -15
  155. package/dist/pipeline/parseStateKey.js +0 -446
  156. package/dist/pipeline/parseStateKey.js.map +0 -1
  157. package/dist/pipeline/simplify.js +0 -515
  158. package/dist/pipeline/simplify.js.map +0 -1
  159. package/dist/pipeline/warnings.js +0 -18
  160. package/dist/pipeline/warnings.js.map +0 -1
  161. package/dist/plugins/index.d.ts +0 -2
  162. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  163. package/dist/plugins/okhsl-plugin.js +0 -97
  164. package/dist/plugins/okhsl-plugin.js.map +0 -1
  165. package/dist/plugins/types.d.ts +0 -76
  166. package/dist/properties/index.js +0 -222
  167. package/dist/properties/index.js.map +0 -1
  168. package/dist/properties/property-type-resolver.d.ts +0 -24
  169. package/dist/properties/property-type-resolver.js +0 -90
  170. package/dist/properties/property-type-resolver.js.map +0 -1
  171. package/dist/rsc-cache.js +0 -81
  172. package/dist/rsc-cache.js.map +0 -1
  173. package/dist/ssr/async-storage.d.ts +0 -17
  174. package/dist/ssr/async-storage.js.map +0 -1
  175. package/dist/ssr/collect-auto-properties.js +0 -58
  176. package/dist/ssr/collect-auto-properties.js.map +0 -1
  177. package/dist/ssr/collector.js.map +0 -1
  178. package/dist/ssr/format-global-rules.js.map +0 -1
  179. package/dist/ssr/format-keyframes.js +0 -69
  180. package/dist/ssr/format-keyframes.js.map +0 -1
  181. package/dist/ssr/format-property.js +0 -49
  182. package/dist/ssr/format-property.js.map +0 -1
  183. package/dist/ssr/format-rules.js +0 -73
  184. package/dist/ssr/format-rules.js.map +0 -1
  185. package/dist/ssr/hydrate.d.ts +0 -22
  186. package/dist/ssr/hydrate.js +0 -49
  187. package/dist/ssr/hydrate.js.map +0 -1
  188. package/dist/ssr/ssr-collector-ref.js +0 -12
  189. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  190. package/dist/states/index.d.ts +0 -49
  191. package/dist/states/index.js +0 -170
  192. package/dist/states/index.js.map +0 -1
  193. package/dist/static/tastyStatic.d.ts +0 -46
  194. package/dist/static/tastyStatic.js +0 -30
  195. package/dist/static/tastyStatic.js.map +0 -1
  196. package/dist/static/types.d.ts +0 -49
  197. package/dist/static/types.js +0 -24
  198. package/dist/static/types.js.map +0 -1
  199. package/dist/styles/border.d.ts +0 -25
  200. package/dist/styles/border.js +0 -120
  201. package/dist/styles/border.js.map +0 -1
  202. package/dist/styles/color.d.ts +0 -14
  203. package/dist/styles/color.js +0 -26
  204. package/dist/styles/color.js.map +0 -1
  205. package/dist/styles/const.js +0 -17
  206. package/dist/styles/const.js.map +0 -1
  207. package/dist/styles/createStyle.js +0 -79
  208. package/dist/styles/createStyle.js.map +0 -1
  209. package/dist/styles/dimension.js +0 -109
  210. package/dist/styles/dimension.js.map +0 -1
  211. package/dist/styles/directional.js +0 -133
  212. package/dist/styles/directional.js.map +0 -1
  213. package/dist/styles/display.d.ts +0 -30
  214. package/dist/styles/display.js +0 -73
  215. package/dist/styles/display.js.map +0 -1
  216. package/dist/styles/fade.d.ts +0 -15
  217. package/dist/styles/fade.js +0 -62
  218. package/dist/styles/fade.js.map +0 -1
  219. package/dist/styles/fill.d.ts +0 -42
  220. package/dist/styles/fill.js +0 -51
  221. package/dist/styles/fill.js.map +0 -1
  222. package/dist/styles/flow.d.ts +0 -16
  223. package/dist/styles/flow.js +0 -12
  224. package/dist/styles/flow.js.map +0 -1
  225. package/dist/styles/gap.d.ts +0 -31
  226. package/dist/styles/gap.js +0 -38
  227. package/dist/styles/gap.js.map +0 -1
  228. package/dist/styles/height.d.ts +0 -17
  229. package/dist/styles/height.js +0 -19
  230. package/dist/styles/height.js.map +0 -1
  231. package/dist/styles/index.d.ts +0 -1
  232. package/dist/styles/index.js +0 -8
  233. package/dist/styles/index.js.map +0 -1
  234. package/dist/styles/inset.d.ts +0 -24
  235. package/dist/styles/inset.js +0 -34
  236. package/dist/styles/inset.js.map +0 -1
  237. package/dist/styles/list.d.ts +0 -16
  238. package/dist/styles/list.js +0 -100
  239. package/dist/styles/list.js.map +0 -1
  240. package/dist/styles/margin.d.ts +0 -24
  241. package/dist/styles/margin.js +0 -32
  242. package/dist/styles/margin.js.map +0 -1
  243. package/dist/styles/outline.d.ts +0 -29
  244. package/dist/styles/outline.js +0 -55
  245. package/dist/styles/outline.js.map +0 -1
  246. package/dist/styles/padding.d.ts +0 -24
  247. package/dist/styles/padding.js +0 -32
  248. package/dist/styles/padding.js.map +0 -1
  249. package/dist/styles/placement.d.ts +0 -37
  250. package/dist/styles/placement.js +0 -74
  251. package/dist/styles/placement.js.map +0 -1
  252. package/dist/styles/predefined.d.ts +0 -71
  253. package/dist/styles/predefined.js +0 -237
  254. package/dist/styles/predefined.js.map +0 -1
  255. package/dist/styles/preset.d.ts +0 -52
  256. package/dist/styles/preset.js +0 -127
  257. package/dist/styles/preset.js.map +0 -1
  258. package/dist/styles/radius.d.ts +0 -12
  259. package/dist/styles/radius.js +0 -83
  260. package/dist/styles/radius.js.map +0 -1
  261. package/dist/styles/scrollMargin.d.ts +0 -24
  262. package/dist/styles/scrollMargin.js +0 -32
  263. package/dist/styles/scrollMargin.js.map +0 -1
  264. package/dist/styles/scrollbar.d.ts +0 -25
  265. package/dist/styles/scrollbar.js +0 -51
  266. package/dist/styles/scrollbar.js.map +0 -1
  267. package/dist/styles/shadow.d.ts +0 -14
  268. package/dist/styles/shadow.js +0 -25
  269. package/dist/styles/shadow.js.map +0 -1
  270. package/dist/styles/shared.js +0 -17
  271. package/dist/styles/shared.js.map +0 -1
  272. package/dist/styles/transition.d.ts +0 -14
  273. package/dist/styles/transition.js +0 -159
  274. package/dist/styles/transition.js.map +0 -1
  275. package/dist/styles/types.d.ts +0 -564
  276. package/dist/styles/width.d.ts +0 -17
  277. package/dist/styles/width.js +0 -19
  278. package/dist/styles/width.js.map +0 -1
  279. package/dist/tasty.d.ts +0 -134
  280. package/dist/tasty.js +0 -243
  281. package/dist/tasty.js.map +0 -1
  282. package/dist/types.d.ts +0 -184
  283. package/dist/utils/cache-wrapper.js +0 -21
  284. package/dist/utils/cache-wrapper.js.map +0 -1
  285. package/dist/utils/case-converter.js +0 -8
  286. package/dist/utils/case-converter.js.map +0 -1
  287. package/dist/utils/color-math.d.ts +0 -46
  288. package/dist/utils/color-math.js +0 -749
  289. package/dist/utils/color-math.js.map +0 -1
  290. package/dist/utils/color-space.d.ts +0 -5
  291. package/dist/utils/color-space.js +0 -228
  292. package/dist/utils/color-space.js.map +0 -1
  293. package/dist/utils/colors.d.ts +0 -5
  294. package/dist/utils/colors.js +0 -10
  295. package/dist/utils/colors.js.map +0 -1
  296. package/dist/utils/css-types.d.ts +0 -7
  297. package/dist/utils/deps-equal.js +0 -15
  298. package/dist/utils/deps-equal.js.map +0 -1
  299. package/dist/utils/dotize.d.ts +0 -26
  300. package/dist/utils/dotize.js +0 -122
  301. package/dist/utils/dotize.js.map +0 -1
  302. package/dist/utils/filter-base-props.d.ts +0 -15
  303. package/dist/utils/filter-base-props.js +0 -45
  304. package/dist/utils/filter-base-props.js.map +0 -1
  305. package/dist/utils/get-display-name.d.ts +0 -7
  306. package/dist/utils/get-display-name.js +0 -10
  307. package/dist/utils/get-display-name.js.map +0 -1
  308. package/dist/utils/has-keys.js +0 -13
  309. package/dist/utils/has-keys.js.map +0 -1
  310. package/dist/utils/hash.js +0 -14
  311. package/dist/utils/hash.js.map +0 -1
  312. package/dist/utils/is-dev-env.js +0 -19
  313. package/dist/utils/is-dev-env.js.map +0 -1
  314. package/dist/utils/is-valid-element-type.js +0 -15
  315. package/dist/utils/is-valid-element-type.js.map +0 -1
  316. package/dist/utils/merge-styles.js.map +0 -1
  317. package/dist/utils/mod-attrs.d.ts +0 -6
  318. package/dist/utils/mod-attrs.js +0 -20
  319. package/dist/utils/mod-attrs.js.map +0 -1
  320. package/dist/utils/process-tokens.d.ts +0 -17
  321. package/dist/utils/process-tokens.js +0 -83
  322. package/dist/utils/process-tokens.js.map +0 -1
  323. package/dist/utils/resolve-recipes.d.ts +0 -17
  324. package/dist/utils/resolve-recipes.js.map +0 -1
  325. package/dist/utils/selector-transform.js +0 -32
  326. package/dist/utils/selector-transform.js.map +0 -1
  327. package/dist/utils/string.js +0 -8
  328. package/dist/utils/string.js.map +0 -1
  329. package/dist/utils/styles.d.ts +0 -99
  330. package/dist/utils/styles.js +0 -220
  331. package/dist/utils/styles.js.map +0 -1
  332. package/dist/utils/typography.d.ts +0 -47
  333. package/dist/utils/typography.js +0 -51
  334. package/dist/utils/typography.js.map +0 -1
  335. package/dist/utils/warnings.d.ts +0 -16
  336. package/dist/utils/warnings.js +0 -16
  337. package/dist/utils/warnings.js.map +0 -1
  338. package/dist/zero/css-writer.d.ts +0 -45
  339. package/dist/zero/css-writer.js +0 -73
  340. package/dist/zero/css-writer.js.map +0 -1
  341. package/dist/zero/extractor.d.ts +0 -24
  342. package/dist/zero/extractor.js.map +0 -1
@@ -1,115 +0,0 @@
1
- import { Lru } from "./lru.js";
2
- import { Bucket, finalizeGroup, finalizePart, makeEmptyDetails, makeEmptyPart } from "./types.js";
3
- import { classify } from "./classify.js";
4
- import { scan } from "./tokenizer.js";
5
- //#region src/parser/parser.ts
6
- var StyleParser = class {
7
- cache;
8
- constructor(opts = {}) {
9
- this.opts = opts;
10
- this.cache = new Lru(this.opts.cacheSize ?? 1e3);
11
- }
12
- process(src) {
13
- const key = String(src);
14
- const hit = this.cache.get(key);
15
- if (hit) return hit;
16
- const stripped = src.replace(/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g, "").toLowerCase();
17
- const groups = [];
18
- let currentGroup = makeEmptyDetails();
19
- let currentPart = makeEmptyPart();
20
- let parts = [];
21
- const pushToken = (bucket, processed) => {
22
- if (!processed) return;
23
- const mergeIntoPrevUrl = () => {
24
- const lastIdx = currentPart.values.length - 1;
25
- currentPart.values[lastIdx] += ` ${processed}`;
26
- const lastAllIdx = currentPart.all.length - 1;
27
- currentPart.all[lastAllIdx] += ` ${processed}`;
28
- };
29
- if (currentPart.values.length > 0 && currentPart.values[currentPart.values.length - 1].startsWith("url(")) {
30
- mergeIntoPrevUrl();
31
- return;
32
- }
33
- switch (bucket) {
34
- case Bucket.Color:
35
- currentPart.colors.push(processed);
36
- break;
37
- case Bucket.Value:
38
- currentPart.values.push(processed);
39
- break;
40
- case Bucket.Mod:
41
- currentPart.mods.push(processed);
42
- break;
43
- }
44
- currentPart.all.push(processed);
45
- };
46
- const endPart = () => {
47
- if (currentPart.all.length > 0) {
48
- finalizePart(currentPart);
49
- parts.push(currentPart);
50
- }
51
- currentPart = makeEmptyPart();
52
- };
53
- const endGroup = () => {
54
- endPart();
55
- if (parts.length === 0) {
56
- parts.push(makeEmptyPart());
57
- finalizePart(parts[0]);
58
- }
59
- finalizeGroup(currentGroup, parts);
60
- groups.push(currentGroup);
61
- currentGroup = makeEmptyDetails();
62
- parts = [];
63
- currentPart = makeEmptyPart();
64
- };
65
- scan(stripped, (tok, isComma, isSlash, _prevChar) => {
66
- if (tok) {
67
- if (currentGroup.input) currentGroup.input += ` ${tok}`;
68
- else currentGroup.input = tok;
69
- const { bucket, processed } = classify(tok, this.opts, (sub) => this.process(sub));
70
- pushToken(bucket, processed);
71
- }
72
- if (isSlash) endPart();
73
- if (isComma) endGroup();
74
- });
75
- if (currentPart.all.length || parts.length || !groups.length) endGroup();
76
- const result = {
77
- output: groups.map((g) => g.output).join(", "),
78
- groups
79
- };
80
- Object.freeze(result);
81
- this.cache.set(key, result);
82
- return result;
83
- }
84
- setFuncs(funcs) {
85
- this.opts.funcs = funcs;
86
- this.cache.clear();
87
- }
88
- setUnits(units) {
89
- this.opts.units = units;
90
- this.cache.clear();
91
- }
92
- updateOptions(patch) {
93
- Object.assign(this.opts, patch);
94
- if (patch.cacheSize) this.cache = new Lru(patch.cacheSize);
95
- else this.cache.clear();
96
- }
97
- /**
98
- * Clear the parser cache.
99
- * Call this when external state that affects parsing results has changed
100
- * (e.g., predefined tokens).
101
- */
102
- clearCache() {
103
- this.cache.clear();
104
- }
105
- /**
106
- * Get the current units configuration.
107
- */
108
- getUnits() {
109
- return this.opts.units;
110
- }
111
- };
112
- //#endregion
113
- export { StyleParser };
114
-
115
- //# sourceMappingURL=parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.js","names":[],"sources":["../../src/parser/parser.ts"],"sourcesContent":["import { classify } from './classify';\nimport { Lru } from './lru';\nimport { scan } from './tokenizer';\nimport type {\n ParserOptions,\n ProcessedStyle,\n StyleDetails,\n StyleDetailsPart,\n} from './types';\nimport {\n Bucket,\n finalizeGroup,\n finalizePart,\n makeEmptyDetails,\n makeEmptyPart,\n} from './types';\n\nexport class StyleParser {\n private cache: Lru<string, ProcessedStyle>;\n constructor(private opts: ParserOptions = {}) {\n this.cache = new Lru<string, ProcessedStyle>(this.opts.cacheSize ?? 1000);\n }\n\n /* ---------------- Public API ---------------- */\n process(src: string): ProcessedStyle {\n const key = String(src);\n const hit = this.cache.get(key);\n if (hit) return hit;\n\n // strip comments & lower-case once\n const stripped = src\n .replace(/\\/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*\\//g, '')\n .toLowerCase();\n\n const groups: StyleDetails[] = [];\n let currentGroup = makeEmptyDetails();\n let currentPart = makeEmptyPart();\n let parts: StyleDetailsPart[] = [];\n\n const pushToken = (bucket: Bucket, processed: string) => {\n if (!processed) return;\n\n // If the previous token was a url(...) value, merge this token into it so that\n // background layer segments like \"url(img) no-repeat center/cover\" are kept\n // as a single value entry.\n const mergeIntoPrevUrl = () => {\n const lastIdx = currentPart.values.length - 1;\n currentPart.values[lastIdx] += ` ${processed}`;\n const lastAllIdx = currentPart.all.length - 1;\n currentPart.all[lastAllIdx] += ` ${processed}`;\n };\n\n const prevIsUrlValue =\n currentPart.values.length > 0 &&\n currentPart.values[currentPart.values.length - 1].startsWith('url(');\n\n if (prevIsUrlValue) {\n // Extend the existing url(...) value regardless of current bucket.\n mergeIntoPrevUrl();\n // Additionally, for non-value buckets we need to remove their own storage.\n // So early return.\n return;\n }\n\n switch (bucket) {\n case Bucket.Color:\n currentPart.colors.push(processed);\n break;\n case Bucket.Value:\n currentPart.values.push(processed);\n break;\n case Bucket.Mod:\n currentPart.mods.push(processed);\n break;\n }\n currentPart.all.push(processed);\n };\n\n const endPart = () => {\n // Only add non-empty parts\n if (currentPart.all.length > 0) {\n finalizePart(currentPart);\n parts.push(currentPart);\n }\n currentPart = makeEmptyPart();\n };\n\n const endGroup = () => {\n endPart(); // finalize last part\n\n // Ensure at least one part exists (even if empty) for backward compat\n if (parts.length === 0) {\n parts.push(makeEmptyPart());\n finalizePart(parts[0]);\n }\n\n finalizeGroup(currentGroup, parts);\n groups.push(currentGroup);\n\n // Reset for next group\n currentGroup = makeEmptyDetails();\n parts = [];\n currentPart = makeEmptyPart();\n };\n\n scan(stripped, (tok, isComma, isSlash, _prevChar) => {\n if (tok) {\n // Accumulate raw token into currentGroup.input\n if (currentGroup.input) {\n currentGroup.input += ` ${tok}`;\n } else {\n currentGroup.input = tok;\n }\n\n const { bucket, processed } = classify(tok, this.opts, (sub) =>\n this.process(sub),\n );\n pushToken(bucket, processed);\n }\n if (isSlash) endPart();\n if (isComma) endGroup();\n });\n\n // push final group if not already\n if (currentPart.all.length || parts.length || !groups.length) endGroup();\n\n const output = groups.map((g) => g.output).join(', ');\n const result: ProcessedStyle = { output, groups };\n Object.freeze(result);\n this.cache.set(key, result);\n return result;\n }\n\n setFuncs(funcs: Required<ParserOptions>['funcs']): void {\n this.opts.funcs = funcs;\n this.cache.clear();\n }\n\n setUnits(units: Required<ParserOptions>['units']): void {\n this.opts.units = units;\n this.cache.clear();\n }\n\n updateOptions(patch: Partial<ParserOptions>): void {\n Object.assign(this.opts, patch);\n if (patch.cacheSize)\n this.cache = new Lru<string, ProcessedStyle>(patch.cacheSize);\n else this.cache.clear();\n }\n\n /**\n * Clear the parser cache.\n * Call this when external state that affects parsing results has changed\n * (e.g., predefined tokens).\n */\n clearCache(): void {\n this.cache.clear();\n }\n\n /**\n * Get the current units configuration.\n */\n getUnits(): ParserOptions['units'] {\n return this.opts.units;\n }\n}\n\n// Re-export\nexport type { StyleDetails, ProcessedStyle } from './types';\n"],"mappings":";;;;;AAiBA,IAAa,cAAb,MAAyB;CACvB;CACA,YAAY,OAA8B,EAAE,EAAE;AAA1B,OAAA,OAAA;AAClB,OAAK,QAAQ,IAAI,IAA4B,KAAK,KAAK,aAAa,IAAK;;CAI3E,QAAQ,KAA6B;EACnC,MAAM,MAAM,OAAO,IAAI;EACvB,MAAM,MAAM,KAAK,MAAM,IAAI,IAAI;AAC/B,MAAI,IAAK,QAAO;EAGhB,MAAM,WAAW,IACd,QAAQ,qCAAqC,GAAG,CAChD,aAAa;EAEhB,MAAM,SAAyB,EAAE;EACjC,IAAI,eAAe,kBAAkB;EACrC,IAAI,cAAc,eAAe;EACjC,IAAI,QAA4B,EAAE;EAElC,MAAM,aAAa,QAAgB,cAAsB;AACvD,OAAI,CAAC,UAAW;GAKhB,MAAM,yBAAyB;IAC7B,MAAM,UAAU,YAAY,OAAO,SAAS;AAC5C,gBAAY,OAAO,YAAY,IAAI;IACnC,MAAM,aAAa,YAAY,IAAI,SAAS;AAC5C,gBAAY,IAAI,eAAe,IAAI;;AAOrC,OAHE,YAAY,OAAO,SAAS,KAC5B,YAAY,OAAO,YAAY,OAAO,SAAS,GAAG,WAAW,OAAO,EAElD;AAElB,sBAAkB;AAGlB;;AAGF,WAAQ,QAAR;IACE,KAAK,OAAO;AACV,iBAAY,OAAO,KAAK,UAAU;AAClC;IACF,KAAK,OAAO;AACV,iBAAY,OAAO,KAAK,UAAU;AAClC;IACF,KAAK,OAAO;AACV,iBAAY,KAAK,KAAK,UAAU;AAChC;;AAEJ,eAAY,IAAI,KAAK,UAAU;;EAGjC,MAAM,gBAAgB;AAEpB,OAAI,YAAY,IAAI,SAAS,GAAG;AAC9B,iBAAa,YAAY;AACzB,UAAM,KAAK,YAAY;;AAEzB,iBAAc,eAAe;;EAG/B,MAAM,iBAAiB;AACrB,YAAS;AAGT,OAAI,MAAM,WAAW,GAAG;AACtB,UAAM,KAAK,eAAe,CAAC;AAC3B,iBAAa,MAAM,GAAG;;AAGxB,iBAAc,cAAc,MAAM;AAClC,UAAO,KAAK,aAAa;AAGzB,kBAAe,kBAAkB;AACjC,WAAQ,EAAE;AACV,iBAAc,eAAe;;AAG/B,OAAK,WAAW,KAAK,SAAS,SAAS,cAAc;AACnD,OAAI,KAAK;AAEP,QAAI,aAAa,MACf,cAAa,SAAS,IAAI;QAE1B,cAAa,QAAQ;IAGvB,MAAM,EAAE,QAAQ,cAAc,SAAS,KAAK,KAAK,OAAO,QACtD,KAAK,QAAQ,IAAI,CAClB;AACD,cAAU,QAAQ,UAAU;;AAE9B,OAAI,QAAS,UAAS;AACtB,OAAI,QAAS,WAAU;IACvB;AAGF,MAAI,YAAY,IAAI,UAAU,MAAM,UAAU,CAAC,OAAO,OAAQ,WAAU;EAGxE,MAAM,SAAyB;GAAE,QADlB,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,KAAK,KAAK;GACZ;GAAQ;AACjD,SAAO,OAAO,OAAO;AACrB,OAAK,MAAM,IAAI,KAAK,OAAO;AAC3B,SAAO;;CAGT,SAAS,OAA+C;AACtD,OAAK,KAAK,QAAQ;AAClB,OAAK,MAAM,OAAO;;CAGpB,SAAS,OAA+C;AACtD,OAAK,KAAK,QAAQ;AAClB,OAAK,MAAM,OAAO;;CAGpB,cAAc,OAAqC;AACjD,SAAO,OAAO,KAAK,MAAM,MAAM;AAC/B,MAAI,MAAM,UACR,MAAK,QAAQ,IAAI,IAA4B,MAAM,UAAU;MAC1D,MAAK,MAAM,OAAO;;;;;;;CAQzB,aAAmB;AACjB,OAAK,MAAM,OAAO;;;;;CAMpB,WAAmC;AACjC,SAAO,KAAK,KAAK"}
@@ -1,69 +0,0 @@
1
- //#region src/parser/tokenizer.ts
2
- const isWhitespace = (ch) => ch === " " || ch === "\n" || ch === " " || ch === "\r" || ch === "\f";
3
- function scan(src, cb) {
4
- let depth = 0;
5
- let inUrl = false;
6
- let inQuote = 0;
7
- let start = 0;
8
- let i = 0;
9
- let pendingSlash = false;
10
- const flush = (isComma, isSlash) => {
11
- const actualSlash = isSlash || pendingSlash;
12
- pendingSlash = false;
13
- if (start < i) {
14
- const prevChar = start > 0 ? src[start - 1] : null;
15
- cb(src.slice(start, i), isComma, actualSlash, prevChar);
16
- } else if (isComma) cb("", true, false, null);
17
- else if (actualSlash) cb("", false, true, null);
18
- start = i + 1;
19
- };
20
- for (; i < src.length; i++) {
21
- const ch = src[i];
22
- if (inQuote) {
23
- if (ch === inQuote && src[i - 1] !== "\\") inQuote = 0;
24
- continue;
25
- }
26
- if (ch === "\"" || ch === "'") {
27
- inQuote = ch;
28
- continue;
29
- }
30
- if (ch === "(") {
31
- if (!depth) {
32
- if (src.slice(Math.max(0, i - 3), i + 1) === "url(") inUrl = true;
33
- }
34
- depth++;
35
- continue;
36
- }
37
- if (ch === ")") {
38
- depth = Math.max(0, depth - 1);
39
- if (inUrl && depth === 0) inUrl = false;
40
- continue;
41
- }
42
- if (inUrl) continue;
43
- if (!depth) {
44
- if (ch === ",") {
45
- flush(true, false);
46
- continue;
47
- }
48
- if (ch === "/") {
49
- const prevIsWhitespace = isWhitespace(src[i - 1]);
50
- const nextIsWhitespace = isWhitespace(src[i + 1]);
51
- if (prevIsWhitespace && nextIsWhitespace) {
52
- pendingSlash = true;
53
- start = i + 1;
54
- continue;
55
- }
56
- continue;
57
- }
58
- if (isWhitespace(ch)) {
59
- flush(false, false);
60
- continue;
61
- }
62
- }
63
- }
64
- flush(false, false);
65
- }
66
- //#endregion
67
- export { scan };
68
-
69
- //# sourceMappingURL=tokenizer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokenizer.js","names":[],"sources":["../../src/parser/tokenizer.ts"],"sourcesContent":["export type TokenCallback = (\n token: string,\n isComma: boolean,\n isSlash: boolean,\n precedingChar: string | null,\n) => void;\n\nconst isWhitespace = (ch: string | undefined): boolean =>\n ch === ' ' || ch === '\\n' || ch === '\\t' || ch === '\\r' || ch === '\\f';\n\nexport function scan(src: string, cb: TokenCallback) {\n let depth = 0;\n let inUrl = false;\n let inQuote: string | 0 = 0;\n let start = 0;\n let i = 0;\n // Track if we just saw a standalone slash separator (whitespace before, whitespace after)\n let pendingSlash = false;\n\n const flush = (isComma: boolean, isSlash: boolean) => {\n // If we have a pending slash, emit the part break\n const actualSlash = isSlash || pendingSlash;\n pendingSlash = false;\n\n if (start < i) {\n const prevChar = start > 0 ? src[start - 1] : null;\n cb(src.slice(start, i), isComma, actualSlash, prevChar);\n } else if (isComma) {\n cb('', true, false, null); // empty token followed by comma => group break.\n } else if (actualSlash) {\n cb('', false, true, null); // empty token followed by slash => part break.\n }\n start = i + 1;\n };\n\n for (; i < src.length; i++) {\n const ch = src[i];\n\n // quote mode\n if (inQuote) {\n if (ch === inQuote && src[i - 1] !== '\\\\') inQuote = 0;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n inQuote = ch;\n continue;\n }\n\n // paren & url tracking (not inside quotes)\n if (ch === '(') {\n // detect url(\n if (!depth) {\n const maybe = src.slice(Math.max(0, i - 3), i + 1);\n if (maybe === 'url(') inUrl = true;\n }\n depth++;\n continue;\n }\n if (ch === ')') {\n depth = Math.max(0, depth - 1);\n if (inUrl && depth === 0) inUrl = false;\n continue;\n }\n\n if (inUrl) continue; // inside url(...) treat everything as part of token\n\n if (!depth) {\n if (ch === ',') {\n flush(true, false);\n continue;\n }\n // Slash is only a separator when surrounded by whitespace (e.g., \"a / b\")\n // This preserves CSS patterns like \"center/cover\" as single tokens\n if (ch === '/') {\n const prevIsWhitespace = isWhitespace(src[i - 1]);\n const nextIsWhitespace = isWhitespace(src[i + 1]);\n if (prevIsWhitespace && nextIsWhitespace) {\n // Already flushed by whitespace before, mark pending slash\n pendingSlash = true;\n start = i + 1; // skip the slash character\n continue;\n }\n // Not surrounded by whitespace - treat as part of token\n continue;\n }\n if (isWhitespace(ch)) {\n flush(false, false);\n continue;\n }\n }\n }\n flush(false, false); // tail\n}\n"],"mappings":";AAOA,MAAM,gBAAgB,OACpB,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAQ,OAAO,QAAQ,OAAO;AAEpE,SAAgB,KAAK,KAAa,IAAmB;CACnD,IAAI,QAAQ;CACZ,IAAI,QAAQ;CACZ,IAAI,UAAsB;CAC1B,IAAI,QAAQ;CACZ,IAAI,IAAI;CAER,IAAI,eAAe;CAEnB,MAAM,SAAS,SAAkB,YAAqB;EAEpD,MAAM,cAAc,WAAW;AAC/B,iBAAe;AAEf,MAAI,QAAQ,GAAG;GACb,MAAM,WAAW,QAAQ,IAAI,IAAI,QAAQ,KAAK;AAC9C,MAAG,IAAI,MAAM,OAAO,EAAE,EAAE,SAAS,aAAa,SAAS;aAC9C,QACT,IAAG,IAAI,MAAM,OAAO,KAAK;WAChB,YACT,IAAG,IAAI,OAAO,MAAM,KAAK;AAE3B,UAAQ,IAAI;;AAGd,QAAO,IAAI,IAAI,QAAQ,KAAK;EAC1B,MAAM,KAAK,IAAI;AAGf,MAAI,SAAS;AACX,OAAI,OAAO,WAAW,IAAI,IAAI,OAAO,KAAM,WAAU;AACrD;;AAEF,MAAI,OAAO,QAAO,OAAO,KAAK;AAC5B,aAAU;AACV;;AAIF,MAAI,OAAO,KAAK;AAEd,OAAI,CAAC;QACW,IAAI,MAAM,KAAK,IAAI,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KACpC,OAAQ,SAAQ;;AAEhC;AACA;;AAEF,MAAI,OAAO,KAAK;AACd,WAAQ,KAAK,IAAI,GAAG,QAAQ,EAAE;AAC9B,OAAI,SAAS,UAAU,EAAG,SAAQ;AAClC;;AAGF,MAAI,MAAO;AAEX,MAAI,CAAC,OAAO;AACV,OAAI,OAAO,KAAK;AACd,UAAM,MAAM,MAAM;AAClB;;AAIF,OAAI,OAAO,KAAK;IACd,MAAM,mBAAmB,aAAa,IAAI,IAAI,GAAG;IACjD,MAAM,mBAAmB,aAAa,IAAI,IAAI,GAAG;AACjD,QAAI,oBAAoB,kBAAkB;AAExC,oBAAe;AACf,aAAQ,IAAI;AACZ;;AAGF;;AAEF,OAAI,aAAa,GAAG,EAAE;AACpB,UAAM,OAAO,MAAM;AACnB;;;;AAIN,OAAM,OAAO,MAAM"}
@@ -1,51 +0,0 @@
1
- //#region src/parser/types.d.ts
2
- declare enum Bucket {
3
- Color = 0,
4
- Value = 1,
5
- Mod = 2
6
- }
7
- /**
8
- * A part within a group, representing a slash-separated segment.
9
- * For example, in `'2px solid #red / 4px'`, there are two parts:
10
- * - Part 0: `2px solid #red`
11
- * - Part 1: `4px`
12
- */
13
- interface StyleDetailsPart {
14
- mods: string[];
15
- values: string[];
16
- colors: string[];
17
- all: string[];
18
- output: string;
19
- }
20
- /**
21
- * A group of style details, representing a comma-separated segment.
22
- * Contains aggregated values from all parts for backward compatibility,
23
- * plus the structured `parts` array for handlers that need slash separation.
24
- */
25
- interface StyleDetails {
26
- input: string;
27
- output: string;
28
- /** Aggregated mods from all parts (backward compatible) */
29
- mods: string[];
30
- /** Aggregated values from all parts (backward compatible) */
31
- values: string[];
32
- /** Aggregated colors from all parts (backward compatible) */
33
- colors: string[];
34
- /** Aggregated all tokens from all parts (backward compatible) */
35
- all: string[];
36
- /** Slash-separated parts within this group */
37
- parts: StyleDetailsPart[];
38
- }
39
- interface ProcessedStyle {
40
- output: string;
41
- groups: StyleDetails[];
42
- }
43
- type UnitHandler = (scalar: number) => string;
44
- interface ParserOptions {
45
- funcs?: Record<string, (parsed: StyleDetails[]) => string>;
46
- units?: Record<string, string | UnitHandler>;
47
- cacheSize?: number;
48
- }
49
- //#endregion
50
- export { Bucket, ParserOptions, ProcessedStyle, StyleDetails, StyleDetailsPart, UnitHandler };
51
- //# sourceMappingURL=types.d.ts.map
@@ -1,46 +0,0 @@
1
- //#region src/parser/types.ts
2
- let Bucket = /* @__PURE__ */ function(Bucket) {
3
- Bucket[Bucket["Color"] = 0] = "Color";
4
- Bucket[Bucket["Value"] = 1] = "Value";
5
- Bucket[Bucket["Mod"] = 2] = "Mod";
6
- return Bucket;
7
- }({});
8
- const makeEmptyPart = () => ({
9
- mods: [],
10
- values: [],
11
- colors: [],
12
- all: [],
13
- output: ""
14
- });
15
- const makeEmptyDetails = () => ({
16
- input: "",
17
- output: "",
18
- mods: [],
19
- values: [],
20
- colors: [],
21
- all: [],
22
- parts: []
23
- });
24
- const finalizePart = (p) => {
25
- p.output = p.all.join(" ");
26
- return p;
27
- };
28
- /**
29
- * Aggregate parts into a StyleDetails group.
30
- * Combines all parts' arrays into group-level arrays for backward compatibility.
31
- */
32
- const finalizeGroup = (d, parts) => {
33
- d.parts = parts;
34
- for (const part of parts) {
35
- d.mods.push(...part.mods);
36
- d.values.push(...part.values);
37
- d.colors.push(...part.colors);
38
- d.all.push(...part.all);
39
- }
40
- d.output = parts.map((p) => p.output).join(" / ");
41
- return d;
42
- };
43
- //#endregion
44
- export { Bucket, finalizeGroup, finalizePart, makeEmptyDetails, makeEmptyPart };
45
-
46
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/parser/types.ts"],"sourcesContent":["export enum Bucket {\n Color,\n Value,\n Mod,\n}\n\n/**\n * A part within a group, representing a slash-separated segment.\n * For example, in `'2px solid #red / 4px'`, there are two parts:\n * - Part 0: `2px solid #red`\n * - Part 1: `4px`\n */\nexport interface StyleDetailsPart {\n mods: string[];\n values: string[];\n colors: string[];\n all: string[];\n output: string;\n}\n\n/**\n * A group of style details, representing a comma-separated segment.\n * Contains aggregated values from all parts for backward compatibility,\n * plus the structured `parts` array for handlers that need slash separation.\n */\nexport interface StyleDetails {\n input: string;\n output: string;\n /** Aggregated mods from all parts (backward compatible) */\n mods: string[];\n /** Aggregated values from all parts (backward compatible) */\n values: string[];\n /** Aggregated colors from all parts (backward compatible) */\n colors: string[];\n /** Aggregated all tokens from all parts (backward compatible) */\n all: string[];\n /** Slash-separated parts within this group */\n parts: StyleDetailsPart[];\n}\n\nexport interface ProcessedStyle {\n output: string;\n groups: StyleDetails[];\n}\n\nexport type UnitHandler = (scalar: number) => string;\n\nexport interface ParserOptions {\n funcs?: Record<string, (parsed: StyleDetails[]) => string>;\n units?: Record<string, string | UnitHandler>;\n cacheSize?: number;\n}\n\nexport const makeEmptyPart = (): StyleDetailsPart => ({\n mods: [],\n values: [],\n colors: [],\n all: [],\n output: '',\n});\n\nexport const makeEmptyDetails = (): StyleDetails => ({\n input: '',\n output: '',\n mods: [],\n values: [],\n colors: [],\n all: [],\n parts: [],\n});\n\nexport const finalizePart = (p: StyleDetailsPart): StyleDetailsPart => {\n p.output = p.all.join(' ');\n return p;\n};\n\n/**\n * Aggregate parts into a StyleDetails group.\n * Combines all parts' arrays into group-level arrays for backward compatibility.\n */\nexport const finalizeGroup = (\n d: StyleDetails,\n parts: StyleDetailsPart[],\n): StyleDetails => {\n // Store parts\n d.parts = parts;\n\n // Aggregate all parts into group-level arrays\n for (const part of parts) {\n d.mods.push(...part.mods);\n d.values.push(...part.values);\n d.colors.push(...part.colors);\n d.all.push(...part.all);\n }\n\n // Join parts' outputs with ' / ' for the group output\n d.output = parts.map((p) => p.output).join(' / ');\n\n return d;\n};\n"],"mappings":";AAAA,IAAY,SAAL,yBAAA,QAAA;AACL,QAAA,OAAA,WAAA,KAAA;AACA,QAAA,OAAA,WAAA,KAAA;AACA,QAAA,OAAA,SAAA,KAAA;;KACD;AAiDD,MAAa,uBAAyC;CACpD,MAAM,EAAE;CACR,QAAQ,EAAE;CACV,QAAQ,EAAE;CACV,KAAK,EAAE;CACP,QAAQ;CACT;AAED,MAAa,0BAAwC;CACnD,OAAO;CACP,QAAQ;CACR,MAAM,EAAE;CACR,QAAQ,EAAE;CACV,QAAQ,EAAE;CACV,KAAK,EAAE;CACP,OAAO,EAAE;CACV;AAED,MAAa,gBAAgB,MAA0C;AACrE,GAAE,SAAS,EAAE,IAAI,KAAK,IAAI;AAC1B,QAAO;;;;;;AAOT,MAAa,iBACX,GACA,UACiB;AAEjB,GAAE,QAAQ;AAGV,MAAK,MAAM,QAAQ,OAAO;AACxB,IAAE,KAAK,KAAK,GAAG,KAAK,KAAK;AACzB,IAAE,OAAO,KAAK,GAAG,KAAK,OAAO;AAC7B,IAAE,OAAO,KAAK,GAAG,KAAK,OAAO;AAC7B,IAAE,IAAI,KAAK,GAAG,KAAK,IAAI;;AAIzB,GAAE,SAAS,MAAM,KAAK,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM;AAEjD,QAAO"}
@@ -1,134 +0,0 @@
1
- //#region src/pipeline/conditions.d.ts
2
- /**
3
- * ConditionNode Types and Helpers
4
- *
5
- * Core data structures for representing style conditions as an abstract syntax tree.
6
- * Used throughout the pipeline for parsing, simplification, and CSS generation.
7
- */
8
- /**
9
- * Base interface for all state conditions (leaf nodes)
10
- */
11
- interface BaseStateCondition {
12
- kind: 'state';
13
- negated: boolean;
14
- raw: string;
15
- uniqueId: string;
16
- }
17
- /**
18
- * Modifier condition: [data-attr] or [data-attr="value"]
19
- */
20
- interface ModifierCondition extends BaseStateCondition {
21
- type: 'modifier';
22
- attribute: string;
23
- value?: string;
24
- operator?: '=' | '^=' | '$=' | '*=';
25
- }
26
- /**
27
- * Pseudo-class condition: :hover, :focus-visible
28
- */
29
- interface PseudoCondition extends BaseStateCondition {
30
- type: 'pseudo';
31
- pseudo: string;
32
- }
33
- /**
34
- * Numeric bound for dimension queries
35
- */
36
- interface NumericBound {
37
- value: string;
38
- valueNumeric: number | null;
39
- inclusive: boolean;
40
- }
41
- /**
42
- * Media query condition
43
- */
44
- interface MediaCondition extends BaseStateCondition {
45
- type: 'media';
46
- subtype: 'dimension' | 'feature' | 'type';
47
- dimension?: 'width' | 'height' | 'inline-size' | 'block-size';
48
- lowerBound?: NumericBound;
49
- upperBound?: NumericBound;
50
- feature?: string;
51
- featureValue?: string;
52
- mediaType?: 'print' | 'screen' | 'all' | 'speech';
53
- }
54
- /**
55
- * Container query condition
56
- */
57
- interface ContainerCondition extends BaseStateCondition {
58
- type: 'container';
59
- subtype: 'dimension' | 'style' | 'raw';
60
- containerName?: string;
61
- dimension?: 'width' | 'height' | 'inline-size' | 'block-size';
62
- lowerBound?: NumericBound;
63
- upperBound?: NumericBound;
64
- property?: string;
65
- propertyValue?: string;
66
- rawCondition?: string;
67
- }
68
- /**
69
- * Root state condition: @root(theme=dark)
70
- */
71
- interface RootCondition extends BaseStateCondition {
72
- type: 'root';
73
- innerCondition: ConditionNode;
74
- }
75
- /**
76
- * Parent state condition: @parent(hovered), @parent(theme=dark, >)
77
- */
78
- interface ParentCondition extends BaseStateCondition {
79
- type: 'parent';
80
- innerCondition: ConditionNode;
81
- direct: boolean;
82
- }
83
- /**
84
- * Own state condition: @own(hovered)
85
- */
86
- interface OwnCondition extends BaseStateCondition {
87
- type: 'own';
88
- innerCondition: ConditionNode;
89
- }
90
- /**
91
- * Starting style condition: @starting
92
- */
93
- interface StartingCondition extends BaseStateCondition {
94
- type: 'starting';
95
- }
96
- /**
97
- * Supports query condition: @supports(display: grid), @supports($, :has(*))
98
- */
99
- interface SupportsCondition extends BaseStateCondition {
100
- type: 'supports';
101
- subtype: 'feature' | 'selector';
102
- condition: string;
103
- }
104
- /**
105
- * Union of all state condition types
106
- */
107
- type StateCondition = ModifierCondition | PseudoCondition | MediaCondition | ContainerCondition | RootCondition | ParentCondition | OwnCondition | StartingCondition | SupportsCondition;
108
- /**
109
- * Compound node: combines conditions with AND/OR
110
- */
111
- interface CompoundCondition {
112
- kind: 'compound';
113
- operator: 'AND' | 'OR';
114
- children: ConditionNode[];
115
- }
116
- /**
117
- * True condition (matches everything)
118
- */
119
- interface TrueCondition {
120
- kind: 'true';
121
- }
122
- /**
123
- * False condition (matches nothing - skip this rule)
124
- */
125
- interface FalseCondition {
126
- kind: 'false';
127
- }
128
- /**
129
- * Union of all condition node types
130
- */
131
- type ConditionNode = StateCondition | CompoundCondition | TrueCondition | FalseCondition;
132
- //#endregion
133
- export { ConditionNode };
134
- //# sourceMappingURL=conditions.d.ts.map