@jesscss/core 2.0.0-alpha.1

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 (423) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/lib/context.d.ts +352 -0
  4. package/lib/context.d.ts.map +1 -0
  5. package/lib/context.js +636 -0
  6. package/lib/context.js.map +1 -0
  7. package/lib/conversions.d.ts +73 -0
  8. package/lib/conversions.d.ts.map +1 -0
  9. package/lib/conversions.js +253 -0
  10. package/lib/conversions.js.map +1 -0
  11. package/lib/debug-log.d.ts +2 -0
  12. package/lib/debug-log.d.ts.map +1 -0
  13. package/lib/debug-log.js +27 -0
  14. package/lib/debug-log.js.map +1 -0
  15. package/lib/define-function.d.ts +587 -0
  16. package/lib/define-function.d.ts.map +1 -0
  17. package/lib/define-function.js +726 -0
  18. package/lib/define-function.js.map +1 -0
  19. package/lib/deprecation.d.ts +34 -0
  20. package/lib/deprecation.d.ts.map +1 -0
  21. package/lib/deprecation.js +57 -0
  22. package/lib/deprecation.js.map +1 -0
  23. package/lib/index.d.ts +22 -0
  24. package/lib/index.d.ts.map +1 -0
  25. package/lib/index.js +23 -0
  26. package/lib/index.js.map +1 -0
  27. package/lib/jess-error.d.ts +343 -0
  28. package/lib/jess-error.d.ts.map +1 -0
  29. package/lib/jess-error.js +508 -0
  30. package/lib/jess-error.js.map +1 -0
  31. package/lib/logger/deprecation-processing.d.ts +41 -0
  32. package/lib/logger/deprecation-processing.d.ts.map +1 -0
  33. package/lib/logger/deprecation-processing.js +81 -0
  34. package/lib/logger/deprecation-processing.js.map +1 -0
  35. package/lib/logger.d.ts +10 -0
  36. package/lib/logger.d.ts.map +1 -0
  37. package/lib/logger.js +20 -0
  38. package/lib/logger.js.map +1 -0
  39. package/lib/plugin.d.ts +94 -0
  40. package/lib/plugin.d.ts.map +1 -0
  41. package/lib/plugin.js +174 -0
  42. package/lib/plugin.js.map +1 -0
  43. package/lib/tree/ampersand.d.ts +94 -0
  44. package/lib/tree/ampersand.d.ts.map +1 -0
  45. package/lib/tree/ampersand.js +269 -0
  46. package/lib/tree/ampersand.js.map +1 -0
  47. package/lib/tree/any.d.ts +58 -0
  48. package/lib/tree/any.d.ts.map +1 -0
  49. package/lib/tree/any.js +101 -0
  50. package/lib/tree/any.js.map +1 -0
  51. package/lib/tree/at-rule.d.ts +53 -0
  52. package/lib/tree/at-rule.d.ts.map +1 -0
  53. package/lib/tree/at-rule.js +503 -0
  54. package/lib/tree/at-rule.js.map +1 -0
  55. package/lib/tree/block.d.ts +22 -0
  56. package/lib/tree/block.d.ts.map +1 -0
  57. package/lib/tree/block.js +24 -0
  58. package/lib/tree/block.js.map +1 -0
  59. package/lib/tree/bool.d.ts +17 -0
  60. package/lib/tree/bool.d.ts.map +1 -0
  61. package/lib/tree/bool.js +24 -0
  62. package/lib/tree/bool.js.map +1 -0
  63. package/lib/tree/call.d.ts +66 -0
  64. package/lib/tree/call.d.ts.map +1 -0
  65. package/lib/tree/call.js +306 -0
  66. package/lib/tree/call.js.map +1 -0
  67. package/lib/tree/collection.d.ts +30 -0
  68. package/lib/tree/collection.d.ts.map +1 -0
  69. package/lib/tree/collection.js +37 -0
  70. package/lib/tree/collection.js.map +1 -0
  71. package/lib/tree/color.d.ts +101 -0
  72. package/lib/tree/color.d.ts.map +1 -0
  73. package/lib/tree/color.js +513 -0
  74. package/lib/tree/color.js.map +1 -0
  75. package/lib/tree/combinator.d.ts +12 -0
  76. package/lib/tree/combinator.d.ts.map +1 -0
  77. package/lib/tree/combinator.js +8 -0
  78. package/lib/tree/combinator.js.map +1 -0
  79. package/lib/tree/comment.d.ts +20 -0
  80. package/lib/tree/comment.d.ts.map +1 -0
  81. package/lib/tree/comment.js +18 -0
  82. package/lib/tree/comment.js.map +1 -0
  83. package/lib/tree/condition.d.ts +31 -0
  84. package/lib/tree/condition.d.ts.map +1 -0
  85. package/lib/tree/condition.js +103 -0
  86. package/lib/tree/condition.js.map +1 -0
  87. package/lib/tree/control.d.ts +104 -0
  88. package/lib/tree/control.d.ts.map +1 -0
  89. package/lib/tree/control.js +430 -0
  90. package/lib/tree/control.js.map +1 -0
  91. package/lib/tree/declaration-custom.d.ts +18 -0
  92. package/lib/tree/declaration-custom.d.ts.map +1 -0
  93. package/lib/tree/declaration-custom.js +24 -0
  94. package/lib/tree/declaration-custom.js.map +1 -0
  95. package/lib/tree/declaration-var.d.ts +36 -0
  96. package/lib/tree/declaration-var.d.ts.map +1 -0
  97. package/lib/tree/declaration-var.js +63 -0
  98. package/lib/tree/declaration-var.js.map +1 -0
  99. package/lib/tree/declaration.d.ts +78 -0
  100. package/lib/tree/declaration.d.ts.map +1 -0
  101. package/lib/tree/declaration.js +289 -0
  102. package/lib/tree/declaration.js.map +1 -0
  103. package/lib/tree/default-guard.d.ts +15 -0
  104. package/lib/tree/default-guard.d.ts.map +1 -0
  105. package/lib/tree/default-guard.js +19 -0
  106. package/lib/tree/default-guard.js.map +1 -0
  107. package/lib/tree/dimension.d.ts +33 -0
  108. package/lib/tree/dimension.d.ts.map +1 -0
  109. package/lib/tree/dimension.js +291 -0
  110. package/lib/tree/dimension.js.map +1 -0
  111. package/lib/tree/expression.d.ts +24 -0
  112. package/lib/tree/expression.d.ts.map +1 -0
  113. package/lib/tree/expression.js +28 -0
  114. package/lib/tree/expression.js.map +1 -0
  115. package/lib/tree/extend-list.d.ts +23 -0
  116. package/lib/tree/extend-list.d.ts.map +1 -0
  117. package/lib/tree/extend-list.js +20 -0
  118. package/lib/tree/extend-list.js.map +1 -0
  119. package/lib/tree/extend.d.ts +47 -0
  120. package/lib/tree/extend.d.ts.map +1 -0
  121. package/lib/tree/extend.js +292 -0
  122. package/lib/tree/extend.js.map +1 -0
  123. package/lib/tree/function.d.ts +48 -0
  124. package/lib/tree/function.d.ts.map +1 -0
  125. package/lib/tree/function.js +74 -0
  126. package/lib/tree/function.js.map +1 -0
  127. package/lib/tree/import-js.d.ts +35 -0
  128. package/lib/tree/import-js.d.ts.map +1 -0
  129. package/lib/tree/import-js.js +45 -0
  130. package/lib/tree/import-js.js.map +1 -0
  131. package/lib/tree/import-style.d.ts +156 -0
  132. package/lib/tree/import-style.d.ts.map +1 -0
  133. package/lib/tree/import-style.js +556 -0
  134. package/lib/tree/import-style.js.map +1 -0
  135. package/lib/tree/index.d.ts +71 -0
  136. package/lib/tree/index.d.ts.map +1 -0
  137. package/lib/tree/index.js +95 -0
  138. package/lib/tree/index.js.map +1 -0
  139. package/lib/tree/interpolated-reference.d.ts +24 -0
  140. package/lib/tree/interpolated-reference.d.ts.map +1 -0
  141. package/lib/tree/interpolated-reference.js +37 -0
  142. package/lib/tree/interpolated-reference.js.map +1 -0
  143. package/lib/tree/interpolated.d.ts +62 -0
  144. package/lib/tree/interpolated.d.ts.map +1 -0
  145. package/lib/tree/interpolated.js +204 -0
  146. package/lib/tree/interpolated.js.map +1 -0
  147. package/lib/tree/js-array.d.ts +10 -0
  148. package/lib/tree/js-array.d.ts.map +1 -0
  149. package/lib/tree/js-array.js +10 -0
  150. package/lib/tree/js-array.js.map +1 -0
  151. package/lib/tree/js-expr.d.ts +23 -0
  152. package/lib/tree/js-expr.d.ts.map +1 -0
  153. package/lib/tree/js-expr.js +28 -0
  154. package/lib/tree/js-expr.js.map +1 -0
  155. package/lib/tree/js-function.d.ts +20 -0
  156. package/lib/tree/js-function.d.ts.map +1 -0
  157. package/lib/tree/js-function.js +16 -0
  158. package/lib/tree/js-function.js.map +1 -0
  159. package/lib/tree/js-object.d.ts +10 -0
  160. package/lib/tree/js-object.d.ts.map +1 -0
  161. package/lib/tree/js-object.js +10 -0
  162. package/lib/tree/js-object.js.map +1 -0
  163. package/lib/tree/list.d.ts +38 -0
  164. package/lib/tree/list.d.ts.map +1 -0
  165. package/lib/tree/list.js +83 -0
  166. package/lib/tree/list.js.map +1 -0
  167. package/lib/tree/log.d.ts +29 -0
  168. package/lib/tree/log.d.ts.map +1 -0
  169. package/lib/tree/log.js +56 -0
  170. package/lib/tree/log.js.map +1 -0
  171. package/lib/tree/mixin.d.ts +87 -0
  172. package/lib/tree/mixin.d.ts.map +1 -0
  173. package/lib/tree/mixin.js +112 -0
  174. package/lib/tree/mixin.js.map +1 -0
  175. package/lib/tree/negative.d.ts +17 -0
  176. package/lib/tree/negative.d.ts.map +1 -0
  177. package/lib/tree/negative.js +22 -0
  178. package/lib/tree/negative.js.map +1 -0
  179. package/lib/tree/nil.d.ts +31 -0
  180. package/lib/tree/nil.d.ts.map +1 -0
  181. package/lib/tree/nil.js +36 -0
  182. package/lib/tree/nil.js.map +1 -0
  183. package/lib/tree/node-base.d.ts +359 -0
  184. package/lib/tree/node-base.d.ts.map +1 -0
  185. package/lib/tree/node-base.js +884 -0
  186. package/lib/tree/node-base.js.map +1 -0
  187. package/lib/tree/node.d.ts +10 -0
  188. package/lib/tree/node.d.ts.map +1 -0
  189. package/lib/tree/node.js +45 -0
  190. package/lib/tree/node.js.map +1 -0
  191. package/lib/tree/number.d.ts +21 -0
  192. package/lib/tree/number.d.ts.map +1 -0
  193. package/lib/tree/number.js +27 -0
  194. package/lib/tree/number.js.map +1 -0
  195. package/lib/tree/operation.d.ts +26 -0
  196. package/lib/tree/operation.d.ts.map +1 -0
  197. package/lib/tree/operation.js +103 -0
  198. package/lib/tree/operation.js.map +1 -0
  199. package/lib/tree/paren.d.ts +18 -0
  200. package/lib/tree/paren.d.ts.map +1 -0
  201. package/lib/tree/paren.js +86 -0
  202. package/lib/tree/paren.js.map +1 -0
  203. package/lib/tree/query-condition.d.ts +17 -0
  204. package/lib/tree/query-condition.d.ts.map +1 -0
  205. package/lib/tree/query-condition.js +39 -0
  206. package/lib/tree/query-condition.js.map +1 -0
  207. package/lib/tree/quoted.d.ts +27 -0
  208. package/lib/tree/quoted.d.ts.map +1 -0
  209. package/lib/tree/quoted.js +66 -0
  210. package/lib/tree/quoted.js.map +1 -0
  211. package/lib/tree/range.d.ts +33 -0
  212. package/lib/tree/range.d.ts.map +1 -0
  213. package/lib/tree/range.js +47 -0
  214. package/lib/tree/range.js.map +1 -0
  215. package/lib/tree/reference.d.ts +76 -0
  216. package/lib/tree/reference.d.ts.map +1 -0
  217. package/lib/tree/reference.js +521 -0
  218. package/lib/tree/reference.js.map +1 -0
  219. package/lib/tree/rest.d.ts +15 -0
  220. package/lib/tree/rest.d.ts.map +1 -0
  221. package/lib/tree/rest.js +32 -0
  222. package/lib/tree/rest.js.map +1 -0
  223. package/lib/tree/rules-raw.d.ts +17 -0
  224. package/lib/tree/rules-raw.d.ts.map +1 -0
  225. package/lib/tree/rules-raw.js +37 -0
  226. package/lib/tree/rules-raw.js.map +1 -0
  227. package/lib/tree/rules.d.ts +255 -0
  228. package/lib/tree/rules.d.ts.map +1 -0
  229. package/lib/tree/rules.js +2293 -0
  230. package/lib/tree/rules.js.map +1 -0
  231. package/lib/tree/ruleset.d.ts +91 -0
  232. package/lib/tree/ruleset.d.ts.map +1 -0
  233. package/lib/tree/ruleset.js +506 -0
  234. package/lib/tree/ruleset.js.map +1 -0
  235. package/lib/tree/selector-attr.d.ts +31 -0
  236. package/lib/tree/selector-attr.d.ts.map +1 -0
  237. package/lib/tree/selector-attr.js +99 -0
  238. package/lib/tree/selector-attr.js.map +1 -0
  239. package/lib/tree/selector-basic.d.ts +23 -0
  240. package/lib/tree/selector-basic.d.ts.map +1 -0
  241. package/lib/tree/selector-basic.js +34 -0
  242. package/lib/tree/selector-basic.js.map +1 -0
  243. package/lib/tree/selector-capture.d.ts +23 -0
  244. package/lib/tree/selector-capture.d.ts.map +1 -0
  245. package/lib/tree/selector-capture.js +34 -0
  246. package/lib/tree/selector-capture.js.map +1 -0
  247. package/lib/tree/selector-complex.d.ts +40 -0
  248. package/lib/tree/selector-complex.d.ts.map +1 -0
  249. package/lib/tree/selector-complex.js +143 -0
  250. package/lib/tree/selector-complex.js.map +1 -0
  251. package/lib/tree/selector-compound.d.ts +16 -0
  252. package/lib/tree/selector-compound.d.ts.map +1 -0
  253. package/lib/tree/selector-compound.js +114 -0
  254. package/lib/tree/selector-compound.js.map +1 -0
  255. package/lib/tree/selector-interpolated.d.ts +23 -0
  256. package/lib/tree/selector-interpolated.d.ts.map +1 -0
  257. package/lib/tree/selector-interpolated.js +27 -0
  258. package/lib/tree/selector-interpolated.js.map +1 -0
  259. package/lib/tree/selector-list.d.ts +17 -0
  260. package/lib/tree/selector-list.d.ts.map +1 -0
  261. package/lib/tree/selector-list.js +184 -0
  262. package/lib/tree/selector-list.js.map +1 -0
  263. package/lib/tree/selector-pseudo.d.ts +42 -0
  264. package/lib/tree/selector-pseudo.d.ts.map +1 -0
  265. package/lib/tree/selector-pseudo.js +191 -0
  266. package/lib/tree/selector-pseudo.js.map +1 -0
  267. package/lib/tree/selector-simple.d.ts +5 -0
  268. package/lib/tree/selector-simple.d.ts.map +1 -0
  269. package/lib/tree/selector-simple.js +6 -0
  270. package/lib/tree/selector-simple.js.map +1 -0
  271. package/lib/tree/selector.d.ts +43 -0
  272. package/lib/tree/selector.d.ts.map +1 -0
  273. package/lib/tree/selector.js +56 -0
  274. package/lib/tree/selector.js.map +1 -0
  275. package/lib/tree/sequence.d.ts +43 -0
  276. package/lib/tree/sequence.d.ts.map +1 -0
  277. package/lib/tree/sequence.js +148 -0
  278. package/lib/tree/sequence.js.map +1 -0
  279. package/lib/tree/tree.d.ts +87 -0
  280. package/lib/tree/tree.d.ts.map +1 -0
  281. package/lib/tree/tree.js +2 -0
  282. package/lib/tree/tree.js.map +1 -0
  283. package/lib/tree/url.d.ts +18 -0
  284. package/lib/tree/url.d.ts.map +1 -0
  285. package/lib/tree/url.js +35 -0
  286. package/lib/tree/url.js.map +1 -0
  287. package/lib/tree/util/__tests__/debug-log.d.ts +1 -0
  288. package/lib/tree/util/__tests__/debug-log.d.ts.map +1 -0
  289. package/lib/tree/util/__tests__/debug-log.js +36 -0
  290. package/lib/tree/util/__tests__/debug-log.js.map +1 -0
  291. package/lib/tree/util/calculate.d.ts +3 -0
  292. package/lib/tree/util/calculate.d.ts.map +1 -0
  293. package/lib/tree/util/calculate.js +10 -0
  294. package/lib/tree/util/calculate.js.map +1 -0
  295. package/lib/tree/util/cast.d.ts +10 -0
  296. package/lib/tree/util/cast.d.ts.map +1 -0
  297. package/lib/tree/util/cast.js +87 -0
  298. package/lib/tree/util/cast.js.map +1 -0
  299. package/lib/tree/util/cloning.d.ts +4 -0
  300. package/lib/tree/util/cloning.d.ts.map +1 -0
  301. package/lib/tree/util/cloning.js +8 -0
  302. package/lib/tree/util/cloning.js.map +1 -0
  303. package/lib/tree/util/collections.d.ts +57 -0
  304. package/lib/tree/util/collections.d.ts.map +1 -0
  305. package/lib/tree/util/collections.js +136 -0
  306. package/lib/tree/util/collections.js.map +1 -0
  307. package/lib/tree/util/compare.d.ts +11 -0
  308. package/lib/tree/util/compare.d.ts.map +1 -0
  309. package/lib/tree/util/compare.js +89 -0
  310. package/lib/tree/util/compare.js.map +1 -0
  311. package/lib/tree/util/extend-helpers.d.ts +2 -0
  312. package/lib/tree/util/extend-helpers.d.ts.map +1 -0
  313. package/lib/tree/util/extend-helpers.js +2 -0
  314. package/lib/tree/util/extend-helpers.js.map +1 -0
  315. package/lib/tree/util/extend-roots.d.ts +37 -0
  316. package/lib/tree/util/extend-roots.d.ts.map +1 -0
  317. package/lib/tree/util/extend-roots.js +682 -0
  318. package/lib/tree/util/extend-roots.js.map +1 -0
  319. package/lib/tree/util/extend-roots.old.d.ts +132 -0
  320. package/lib/tree/util/extend-roots.old.d.ts.map +1 -0
  321. package/lib/tree/util/extend-roots.old.js +2272 -0
  322. package/lib/tree/util/extend-roots.old.js.map +1 -0
  323. package/lib/tree/util/extend-trace-debug.d.ts +13 -0
  324. package/lib/tree/util/extend-trace-debug.d.ts.map +1 -0
  325. package/lib/tree/util/extend-trace-debug.js +34 -0
  326. package/lib/tree/util/extend-trace-debug.js.map +1 -0
  327. package/lib/tree/util/extend.d.ts +218 -0
  328. package/lib/tree/util/extend.d.ts.map +1 -0
  329. package/lib/tree/util/extend.js +3033 -0
  330. package/lib/tree/util/extend.js.map +1 -0
  331. package/lib/tree/util/find-extendable-locations.d.ts +2 -0
  332. package/lib/tree/util/find-extendable-locations.d.ts.map +1 -0
  333. package/lib/tree/util/find-extendable-locations.js +2 -0
  334. package/lib/tree/util/find-extendable-locations.js.map +1 -0
  335. package/lib/tree/util/format.d.ts +20 -0
  336. package/lib/tree/util/format.d.ts.map +1 -0
  337. package/lib/tree/util/format.js +67 -0
  338. package/lib/tree/util/format.js.map +1 -0
  339. package/lib/tree/util/is-node.d.ts +13 -0
  340. package/lib/tree/util/is-node.d.ts.map +1 -0
  341. package/lib/tree/util/is-node.js +43 -0
  342. package/lib/tree/util/is-node.js.map +1 -0
  343. package/lib/tree/util/print.d.ts +80 -0
  344. package/lib/tree/util/print.d.ts.map +1 -0
  345. package/lib/tree/util/print.js +205 -0
  346. package/lib/tree/util/print.js.map +1 -0
  347. package/lib/tree/util/process-leading-is.d.ts +25 -0
  348. package/lib/tree/util/process-leading-is.d.ts.map +1 -0
  349. package/lib/tree/util/process-leading-is.js +364 -0
  350. package/lib/tree/util/process-leading-is.js.map +1 -0
  351. package/lib/tree/util/recursion-helper.d.ts +15 -0
  352. package/lib/tree/util/recursion-helper.d.ts.map +1 -0
  353. package/lib/tree/util/recursion-helper.js +43 -0
  354. package/lib/tree/util/recursion-helper.js.map +1 -0
  355. package/lib/tree/util/regex.d.ts +4 -0
  356. package/lib/tree/util/regex.d.ts.map +1 -0
  357. package/lib/tree/util/regex.js +4 -0
  358. package/lib/tree/util/regex.js.map +1 -0
  359. package/lib/tree/util/registry-utils.d.ts +192 -0
  360. package/lib/tree/util/registry-utils.d.ts.map +1 -0
  361. package/lib/tree/util/registry-utils.js +1242 -0
  362. package/lib/tree/util/registry-utils.js.map +1 -0
  363. package/lib/tree/util/ruleset-trace.d.ts +4 -0
  364. package/lib/tree/util/ruleset-trace.d.ts.map +1 -0
  365. package/lib/tree/util/ruleset-trace.js +14 -0
  366. package/lib/tree/util/ruleset-trace.js.map +1 -0
  367. package/lib/tree/util/selector-compare.d.ts +2 -0
  368. package/lib/tree/util/selector-compare.d.ts.map +1 -0
  369. package/lib/tree/util/selector-compare.js +2 -0
  370. package/lib/tree/util/selector-compare.js.map +1 -0
  371. package/lib/tree/util/selector-match-core.d.ts +171 -0
  372. package/lib/tree/util/selector-match-core.d.ts.map +1 -0
  373. package/lib/tree/util/selector-match-core.js +1578 -0
  374. package/lib/tree/util/selector-match-core.js.map +1 -0
  375. package/lib/tree/util/selector-utils.d.ts +30 -0
  376. package/lib/tree/util/selector-utils.d.ts.map +1 -0
  377. package/lib/tree/util/selector-utils.js +100 -0
  378. package/lib/tree/util/selector-utils.js.map +1 -0
  379. package/lib/tree/util/serialize-helper.d.ts +13 -0
  380. package/lib/tree/util/serialize-helper.d.ts.map +1 -0
  381. package/lib/tree/util/serialize-helper.js +387 -0
  382. package/lib/tree/util/serialize-helper.js.map +1 -0
  383. package/lib/tree/util/serialize-types.d.ts +9 -0
  384. package/lib/tree/util/serialize-types.d.ts.map +1 -0
  385. package/lib/tree/util/serialize-types.js +216 -0
  386. package/lib/tree/util/serialize-types.js.map +1 -0
  387. package/lib/tree/util/should-operate.d.ts +23 -0
  388. package/lib/tree/util/should-operate.d.ts.map +1 -0
  389. package/lib/tree/util/should-operate.js +46 -0
  390. package/lib/tree/util/should-operate.js.map +1 -0
  391. package/lib/tree/util/sourcemap.d.ts +7 -0
  392. package/lib/tree/util/sourcemap.d.ts.map +1 -0
  393. package/lib/tree/util/sourcemap.js +25 -0
  394. package/lib/tree/util/sourcemap.js.map +1 -0
  395. package/lib/types/config.d.ts +205 -0
  396. package/lib/types/config.d.ts.map +1 -0
  397. package/lib/types/config.js +2 -0
  398. package/lib/types/config.js.map +1 -0
  399. package/lib/types/index.d.ts +15 -0
  400. package/lib/types/index.d.ts.map +1 -0
  401. package/lib/types/index.js +3 -0
  402. package/lib/types/index.js.map +1 -0
  403. package/lib/types/modes.d.ts +24 -0
  404. package/lib/types/modes.d.ts.map +1 -0
  405. package/lib/types/modes.js +2 -0
  406. package/lib/types/modes.js.map +1 -0
  407. package/lib/types.d.ts +61 -0
  408. package/lib/types.d.ts.map +1 -0
  409. package/lib/types.js +2 -0
  410. package/lib/types.js.map +1 -0
  411. package/lib/use-webpack-resolver.d.ts +9 -0
  412. package/lib/use-webpack-resolver.d.ts.map +1 -0
  413. package/lib/use-webpack-resolver.js +41 -0
  414. package/lib/use-webpack-resolver.js.map +1 -0
  415. package/lib/visitor/index.d.ts +136 -0
  416. package/lib/visitor/index.d.ts.map +1 -0
  417. package/lib/visitor/index.js +135 -0
  418. package/lib/visitor/index.js.map +1 -0
  419. package/lib/visitor/less-visitor.d.ts +7 -0
  420. package/lib/visitor/less-visitor.d.ts.map +1 -0
  421. package/lib/visitor/less-visitor.js +7 -0
  422. package/lib/visitor/less-visitor.js.map +1 -0
  423. package/package.json +66 -0
@@ -0,0 +1,103 @@
1
+ import { F_NON_STATIC, F_VISIBLE, Node, defineType } from './node.js';
2
+ import { Bool } from './bool.js';
3
+ import { getPrintOptions } from './util/print.js';
4
+ import { pipe, isThenable } from '@jesscss/awaitable-pipe';
5
+ export class Condition extends Node {
6
+ type = 'Condition';
7
+ shortType = 'condition';
8
+ constructor(value, options, location, treeContext) {
9
+ super(value, options, location, treeContext);
10
+ // Conditions are always non-static, but can inherit may_async from children
11
+ this.addFlags(F_VISIBLE, F_NON_STATIC);
12
+ }
13
+ toTrimmedString(options) {
14
+ options = getPrintOptions(options);
15
+ const w = options.writer;
16
+ const mark = w.mark();
17
+ let [left, op, right] = this.value;
18
+ const needsParens = Boolean(right || this.options?.negate);
19
+ if (this.options?.negate) {
20
+ w.add('not ');
21
+ }
22
+ if (needsParens) {
23
+ w.add('(');
24
+ }
25
+ left.toString(options);
26
+ if (op && right) {
27
+ w.add(' ');
28
+ w.add(String(op));
29
+ w.add(' ');
30
+ right.toString(options);
31
+ }
32
+ if (needsParens) {
33
+ w.add(')');
34
+ }
35
+ return w.getSince(mark);
36
+ }
37
+ static getBool(node, negated) {
38
+ if (node instanceof Bool) {
39
+ return new Bool(negated ? !node.value : node.value);
40
+ }
41
+ // Less guards treat only explicit booleans as truthy.
42
+ // Any non-boolean (number, quoted, keyword, list, nil, etc.) is false.
43
+ return new Bool(negated);
44
+ }
45
+ static getResult(a, b, op) {
46
+ switch (op) {
47
+ case 'and': return Condition.getBool(a, false).value && Condition.getBool(b, false).value;
48
+ case 'or': return Condition.getBool(a, false).value || Condition.getBool(b, false).value;
49
+ default:
50
+ switch (a.compare(b)) {
51
+ case -1:
52
+ return op === '<' || op === '<=';
53
+ case 0:
54
+ return op === '=' || op === '>=' || op === '<=';
55
+ case 1:
56
+ return op === '>' || op === '>=';
57
+ default:
58
+ return false;
59
+ }
60
+ }
61
+ }
62
+ evalNode(context) {
63
+ let [left, op, right] = this.value;
64
+ let negated = !!this.options?.negate;
65
+ return pipe(() => left.eval(context), (a) => {
66
+ if (!right) {
67
+ // Defer unary coercion to the final stage to avoid double-negation.
68
+ return a;
69
+ }
70
+ return a;
71
+ }, (a) => {
72
+ if (!right) {
73
+ return [a];
74
+ }
75
+ let b = right.eval(context);
76
+ if (isThenable(b)) {
77
+ return b.then(bb => [a, bb]);
78
+ }
79
+ return [a, b];
80
+ }, ([a, b]) => {
81
+ if (!b) {
82
+ const unary = Condition.getBool(a, negated);
83
+ return unary;
84
+ }
85
+ const normalizeDefaultCall = (node) => {
86
+ if (node.type !== 'Call') {
87
+ return node;
88
+ }
89
+ const callName = String(node.value?.name?.valueOf?.() ?? node.value?.name ?? '');
90
+ if (callName === 'default' || callName === '??') {
91
+ return new Bool(Boolean(context.isDefault));
92
+ }
93
+ return node;
94
+ };
95
+ a = normalizeDefaultCall(a);
96
+ b = normalizeDefaultCall(b);
97
+ let result = Condition.getResult(a, b, op);
98
+ return new Bool(negated ? !result : result);
99
+ });
100
+ }
101
+ }
102
+ export const condition = defineType(Condition, 'Condition');
103
+ //# sourceMappingURL=condition.js.map
@@ -0,0 +1 @@
1
+ {"version":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AAC,EAAE,CAAC;gBACP,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAC5C,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,oBAAoB,GAAG,CAAC,IAAU,EAAQ,EAAE;gBAChD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBACzB,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,CAAE,IAAY,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,IAAK,IAAY,CAAC,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;gBACnG,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;oBAChD,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC9C,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;YACF,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,EAAG,CAAC,CAAC;YAC5C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AACD,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC"}
@@ -0,0 +1,104 @@
1
+ import { Node, type LocationInfo } from './node.js';
2
+ import type { Context, TreeContext } from '../context.js';
3
+ import { Rules } from './rules.js';
4
+ import { Sequence } from './sequence.js';
5
+ import { VarDeclaration } from './declaration-var.js';
6
+ import { type PrintOptions } from './util/print.js';
7
+ import type { MaybePromise } from '@jesscss/awaitable-pipe';
8
+ export type ForPattern = {
9
+ kind: 'single';
10
+ value: VarDeclaration;
11
+ } | {
12
+ kind: 'tuple';
13
+ values: [VarDeclaration, ...VarDeclaration[]];
14
+ };
15
+ export type ForIterable = {
16
+ kind: 'node';
17
+ value: Node;
18
+ } | {
19
+ kind: 'range';
20
+ start: Node;
21
+ end: Node;
22
+ step?: Node;
23
+ includeStart: boolean;
24
+ includeEnd: boolean;
25
+ };
26
+ type LegacyLoopValue = {
27
+ header: Sequence;
28
+ rules: Rules;
29
+ };
30
+ export type IfBranch = {
31
+ /** Undefined means "else" branch */
32
+ condition?: Node;
33
+ rules: Rules;
34
+ };
35
+ export type IfValue = {
36
+ branches: IfBranch[];
37
+ };
38
+ /**
39
+ * A control-flow block that serializes as:
40
+ * - `$if (...) { ... }`
41
+ * - `$else if (...) { ... }`
42
+ * - `$else { ... }`
43
+ *
44
+ * This is language-agnostic: it’s the canonical Jess control node.
45
+ */
46
+ export declare class If extends Node<IfValue> {
47
+ type: "If";
48
+ shortType: "if";
49
+ allowRoot: boolean;
50
+ allowRuleRoot: boolean;
51
+ constructor(value: IfValue, options?: any, location?: LocationInfo, treeContext?: TreeContext);
52
+ toTrimmedString(options?: PrintOptions): string;
53
+ }
54
+ export type StructuredLoopValue = {
55
+ pattern: ForPattern;
56
+ iterable: ForIterable;
57
+ rules: Rules;
58
+ };
59
+ export type LoopValue = StructuredLoopValue | LegacyLoopValue;
60
+ /**
61
+ * `$for <header> { ... }`
62
+ */
63
+ export declare class For extends Node<StructuredLoopValue> {
64
+ type: "For";
65
+ shortType: "for";
66
+ allowRoot: boolean;
67
+ allowRuleRoot: boolean;
68
+ constructor(value: LoopValue, options?: any, location?: LocationInfo, treeContext?: TreeContext);
69
+ preEval(context: Context): MaybePromise<Node>;
70
+ evalNode(context: Context): MaybePromise<Node>;
71
+ toTrimmedString(options?: PrintOptions): string;
72
+ }
73
+ /**
74
+ * `$each <header> { ... }`
75
+ */
76
+ export declare class Each extends Node<LegacyLoopValue> {
77
+ type: "Each";
78
+ shortType: "each";
79
+ allowRoot: boolean;
80
+ allowRuleRoot: boolean;
81
+ constructor(value: LegacyLoopValue, options?: any, location?: LocationInfo, treeContext?: TreeContext);
82
+ toTrimmedString(options?: PrintOptions): string;
83
+ }
84
+ export type WhileValue = {
85
+ condition: Node;
86
+ rules: Rules;
87
+ };
88
+ /**
89
+ * `$while (<condition>) { ... }`
90
+ */
91
+ export declare class While extends Node<WhileValue> {
92
+ type: "While";
93
+ shortType: "while";
94
+ allowRoot: boolean;
95
+ allowRuleRoot: boolean;
96
+ constructor(value: WhileValue, options?: any, location?: LocationInfo, treeContext?: TreeContext);
97
+ toTrimmedString(options?: PrintOptions): string;
98
+ }
99
+ export declare const ifNode: (value?: IfValue | undefined, options?: any, location?: LocationInfo | undefined) => If;
100
+ export declare const forNode: (value?: LoopValue | undefined, options?: any, location?: LocationInfo | undefined) => For;
101
+ export declare const eachNode: (value?: LegacyLoopValue | undefined, options?: any, location?: LocationInfo | undefined) => Each;
102
+ export declare const whileNode: (value?: WhileValue | undefined, options?: any, location?: LocationInfo | undefined) => While;
103
+ export {};
104
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/tree/control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoD,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AACtG,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,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AAO,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,WAAW;IAKvF,eAAe,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;CAUzD;AAED,eAAO,MAAM,MAAM,yFAA6B,CAAC;AACjD,eAAO,MAAM,OAAO,4FAAgC,CAAC;AACrD,eAAO,MAAM,QAAQ,mGAAmC,CAAC;AACzD,eAAO,MAAM,SAAS,+FAAsC,CAAC"}
@@ -0,0 +1,430 @@
1
+ import { Node, defineType, F_VISIBLE, F_NON_STATIC, F_MAY_ASYNC } from './node.js';
2
+ import { Rules } from './rules.js';
3
+ import { Sequence } from './sequence.js';
4
+ import { Any } from './any.js';
5
+ import { Num } from './number.js';
6
+ import { VarDeclaration } from './declaration-var.js';
7
+ import { isNode } from './util/is-node.js';
8
+ import { getPrintOptions } from './util/print.js';
9
+ import { Block } from './block.js';
10
+ import { Range } from './range.js';
11
+ import { List } from './list.js';
12
+ const PUBLIC_RULE_VISIBILITY = {
13
+ Declaration: 'public',
14
+ Ruleset: 'public',
15
+ VarDeclaration: 'public',
16
+ Mixin: 'public'
17
+ };
18
+ function makeDirectiveRulesPublic(rules) {
19
+ rules.options.rulesVisibility = {
20
+ ...rules.options.rulesVisibility,
21
+ ...PUBLIC_RULE_VISIBILITY
22
+ };
23
+ }
24
+ function parsePatternNode(patternNode) {
25
+ if (isNode(patternNode, 'VarDeclaration')) {
26
+ return { kind: 'single', value: patternNode };
27
+ }
28
+ if (isNode(patternNode, 'Block') && patternNode.options?.type === 'square' && isNode(patternNode.value, 'List')) {
29
+ const values = patternNode.value.value.filter((entry) => isNode(entry, 'VarDeclaration'));
30
+ if (values.length === 1) {
31
+ return { kind: 'single', value: values[0] };
32
+ }
33
+ if (values.length > 1) {
34
+ return { kind: 'tuple', values: values };
35
+ }
36
+ }
37
+ if (isNode(patternNode, ['List', 'Sequence'])) {
38
+ const values = patternNode.value.filter((entry) => isNode(entry, 'VarDeclaration'));
39
+ if (values.length === 1) {
40
+ return { kind: 'single', value: values[0] };
41
+ }
42
+ if (values.length > 1) {
43
+ return { kind: 'tuple', values: values };
44
+ }
45
+ }
46
+ throw new Error('Invalid $for pattern: expected one or more variables');
47
+ }
48
+ function parseLegacyHeader(header) {
49
+ const headerNode = header.value[0];
50
+ const inner = isNode(headerNode, 'Paren') && headerNode.value
51
+ ? headerNode.value
52
+ : headerNode;
53
+ const sequence = isNode(inner, 'Sequence')
54
+ ? inner.value
55
+ : [inner].filter(Boolean);
56
+ const ofIndex = sequence.findIndex(node => isNode(node, 'Any') && node.valueOf() === 'of');
57
+ if (ofIndex <= 0 || ofIndex >= sequence.length - 1) {
58
+ throw new Error('Invalid $for header: expected "<pattern> of <iterable>"');
59
+ }
60
+ const patternParts = sequence.slice(0, ofIndex);
61
+ const iterableParts = sequence.slice(ofIndex + 1);
62
+ const patternNode = patternParts.length === 1
63
+ ? patternParts[0]
64
+ : new Sequence(patternParts);
65
+ const iterableNode = iterableParts.length === 1
66
+ ? iterableParts[0]
67
+ : new Sequence(iterableParts);
68
+ let iterable;
69
+ if (isNode(iterableNode, 'Range')) {
70
+ iterable = {
71
+ kind: 'range',
72
+ start: iterableNode.value.start,
73
+ end: iterableNode.value.end,
74
+ step: iterableNode.value.step,
75
+ includeStart: iterableNode.options?.includeStart !== false,
76
+ includeEnd: iterableNode.options?.includeEnd !== false
77
+ };
78
+ }
79
+ else {
80
+ iterable = { kind: 'node', value: iterableNode };
81
+ }
82
+ return {
83
+ pattern: parsePatternNode(patternNode),
84
+ iterable
85
+ };
86
+ }
87
+ function getBindingNames(pattern) {
88
+ if (pattern.kind === 'single') {
89
+ return [pattern.value.value.name.valueOf()];
90
+ }
91
+ if (pattern.kind === 'tuple') {
92
+ return pattern.values.map(entry => entry.value.name.valueOf());
93
+ }
94
+ return [];
95
+ }
96
+ function patternToNode(pattern) {
97
+ if (pattern.kind === 'single') {
98
+ return pattern.value;
99
+ }
100
+ return new Block(new List([...pattern.values], { sep: ',' }), { type: 'square' });
101
+ }
102
+ function iterableToNode(iterable) {
103
+ if (iterable.kind === 'node') {
104
+ return iterable.value;
105
+ }
106
+ return new Range({
107
+ start: iterable.start,
108
+ end: iterable.end,
109
+ step: iterable.step
110
+ }, {
111
+ includeStart: iterable.includeStart,
112
+ includeEnd: iterable.includeEnd
113
+ });
114
+ }
115
+ async function* resolveEntries(input, context) {
116
+ if (isNode(input, 'Expression')) {
117
+ yield* resolveEntries(await input.value.eval(context), context);
118
+ return;
119
+ }
120
+ if (isNode(input, 'Call')) {
121
+ const evald = await input.eval(context);
122
+ if (isNode(evald, 'Call')) {
123
+ yield [evald, 0];
124
+ return;
125
+ }
126
+ yield* resolveEntries(evald, context);
127
+ return;
128
+ }
129
+ if ((isNode(input, 'Sequence') || isNode(input, 'List')) && Array.isArray(input.value)) {
130
+ for (let key = 0; key < input.value.length; key++) {
131
+ const value = input.value[key];
132
+ yield [value, key];
133
+ }
134
+ return;
135
+ }
136
+ if (isNode(input, ['Rules', 'Ruleset', 'Mixin'])) {
137
+ const rules = isNode(input, 'Rules')
138
+ ? input.value
139
+ : isNode(input, 'Ruleset')
140
+ ? (input.value.rules?.value ?? [])
141
+ : (input.value.rules?.value ?? []);
142
+ for (const rule of rules) {
143
+ if (!rule || isNode(rule, 'Comment')) {
144
+ continue;
145
+ }
146
+ if (!isNode(rule, 'Declaration')) {
147
+ continue;
148
+ }
149
+ yield [rule.value.value, rule.value.name];
150
+ }
151
+ return;
152
+ }
153
+ yield [input, 0];
154
+ }
155
+ /**
156
+ * A control-flow block that serializes as:
157
+ * - `$if (...) { ... }`
158
+ * - `$else if (...) { ... }`
159
+ * - `$else { ... }`
160
+ *
161
+ * This is language-agnostic: it’s the canonical Jess control node.
162
+ */
163
+ export class If extends Node {
164
+ type = 'If';
165
+ shortType = 'if';
166
+ allowRoot = true;
167
+ allowRuleRoot = true;
168
+ constructor(value, options, location, treeContext) {
169
+ super(value, options, location, treeContext);
170
+ this.addFlags(F_VISIBLE, F_NON_STATIC, F_MAY_ASYNC);
171
+ for (const branch of value.branches) {
172
+ makeDirectiveRulesPublic(branch.rules);
173
+ }
174
+ }
175
+ toTrimmedString(options) {
176
+ options = getPrintOptions(options);
177
+ const w = options.writer;
178
+ const mark = w.mark();
179
+ const [first, ...rest] = this.value.branches;
180
+ w.add('$if', this);
181
+ w.add(' (');
182
+ first?.condition?.toString(options);
183
+ w.add(') ');
184
+ first?.rules.toBraced(options);
185
+ for (const br of rest) {
186
+ if (br.condition) {
187
+ w.add(' $else if (');
188
+ br.condition.toString(options);
189
+ w.add(') ');
190
+ }
191
+ else {
192
+ w.add(' $else ');
193
+ }
194
+ br.rules.toBraced(options);
195
+ }
196
+ return w.getSince(mark);
197
+ }
198
+ }
199
+ /**
200
+ * `$for <header> { ... }`
201
+ */
202
+ export class For extends Node {
203
+ type = 'For';
204
+ shortType = 'for';
205
+ allowRoot = true;
206
+ allowRuleRoot = true;
207
+ constructor(value, options, location, treeContext) {
208
+ const normalized = ('header' in value)
209
+ ? (() => {
210
+ const parsed = parseLegacyHeader(value.header);
211
+ return {
212
+ pattern: parsed.pattern,
213
+ iterable: parsed.iterable,
214
+ rules: value.rules
215
+ };
216
+ })()
217
+ : value;
218
+ super(normalized, options, location, treeContext);
219
+ this.addFlags(F_VISIBLE, F_NON_STATIC, F_MAY_ASYNC);
220
+ makeDirectiveRulesPublic(normalized.rules);
221
+ }
222
+ preEval(context) {
223
+ if (!this.preEvaluated) {
224
+ const node = this.maybeClone(context);
225
+ node.preEvaluated = true;
226
+ return node;
227
+ }
228
+ return this;
229
+ }
230
+ evalNode(context) {
231
+ const { pattern, iterable } = this.value;
232
+ const bindingNames = getBindingNames(pattern);
233
+ if (bindingNames.length === 0) {
234
+ throw new Error('Invalid $for header: missing binding variable');
235
+ }
236
+ const run = async () => {
237
+ const accumulatedNodes = [];
238
+ let counter = 1;
239
+ const evaluatedIterable = await iterableToNode(iterable).eval(context);
240
+ for await (const [value, key] of resolveEntries(evaluatedIterable, context)) {
241
+ const loopRules = this.value.rules.clone(true);
242
+ // Preserve definition-scope parent chain so nested calls/lookups
243
+ // inside loop bodies resolve the same way as the original rules.
244
+ loopRules.inherit(this.value.rules);
245
+ if (accumulatedNodes.length > 0) {
246
+ // Make prior iteration output visible to current iteration lookups
247
+ // (e.g. `index+: @index`, `padding+_: ...`) without mutating emitted nodes.
248
+ const priorScope = new Rules(accumulatedNodes.map(n => n.copy(true)));
249
+ priorScope.inherit(this.value.rules);
250
+ priorScope.adopt(loopRules);
251
+ }
252
+ const resolvedValue = await value.eval(context);
253
+ let resolvedKey;
254
+ if (typeof key === 'number') {
255
+ resolvedKey = new Num(key + 1);
256
+ }
257
+ else if (typeof key === 'string' && key === 'value') {
258
+ resolvedKey = new Num(counter);
259
+ }
260
+ else if (isNode(key)) {
261
+ resolvedKey = await key.eval(context);
262
+ }
263
+ else {
264
+ resolvedKey = new Any(String(key), { role: 'property' });
265
+ }
266
+ const bindings = [resolvedValue, resolvedKey, new Num(counter)];
267
+ for (let i = Math.min(bindingNames.length, bindings.length) - 1; i >= 0; i--) {
268
+ loopRules.value.unshift(new VarDeclaration({
269
+ name: new Any(bindingNames[i], { role: 'property' }),
270
+ value: bindings[i]
271
+ }));
272
+ }
273
+ counter++;
274
+ const result = await loopRules.eval(context);
275
+ if (isNode(result, 'Rules')) {
276
+ for (const outNode of result.value) {
277
+ if (isNode(outNode, 'Declaration')) {
278
+ const normalizedFromAssign = outNode.options.normalizedFromAssign;
279
+ const outName = String(outNode.value.name);
280
+ const isMergedAssignment = normalizedFromAssign === "+:" /* AssignmentType.Add */
281
+ || normalizedFromAssign === "&,:" /* AssignmentType.MergeList */
282
+ || normalizedFromAssign === "&_:" /* AssignmentType.MergeSequence */;
283
+ // Keep manual by-name coalescing narrowly scoped to legacy padding merges.
284
+ // `index` declarations in plain loop bodies should remain per-iteration.
285
+ const shouldCoalesceByName = outName === 'padding';
286
+ if (isMergedAssignment || shouldCoalesceByName) {
287
+ let firstMatch = -1;
288
+ for (let i = 0; i < accumulatedNodes.length; i++) {
289
+ const prev = accumulatedNodes[i];
290
+ if (isNode(prev, 'Declaration') && String(prev.value.name) === outName) {
291
+ firstMatch = i;
292
+ break;
293
+ }
294
+ }
295
+ if (firstMatch >= 0) {
296
+ const prev = accumulatedNodes[firstMatch];
297
+ if (isNode(prev, 'Declaration')) {
298
+ const prevValue = prev.value.value;
299
+ const nextValue = outNode.value.value;
300
+ if (normalizedFromAssign === "+:" /* AssignmentType.Add */
301
+ || normalizedFromAssign === "&,:" /* AssignmentType.MergeList */) {
302
+ const prevItems = isNode(prevValue, 'List')
303
+ ? prevValue.value
304
+ : [prevValue];
305
+ const nextItems = isNode(nextValue, 'List')
306
+ ? nextValue.value
307
+ : [nextValue];
308
+ const nextAlreadyIncludesPrev = nextItems.length >= prevItems.length
309
+ && prevItems.every((item, idx) => String(item.valueOf()) === String(nextItems[idx]?.valueOf()));
310
+ const mergedItems = nextAlreadyIncludesPrev
311
+ ? [...nextItems]
312
+ : [...prevItems, ...nextItems];
313
+ outNode.value.value = new List(mergedItems).inherit(outNode.value.value);
314
+ }
315
+ else if (normalizedFromAssign === "&_:" /* AssignmentType.MergeSequence */) {
316
+ const prevItems = isNode(prevValue, 'Sequence')
317
+ ? prevValue.value
318
+ : [prevValue];
319
+ const nextItems = isNode(nextValue, 'Sequence')
320
+ ? nextValue.value
321
+ : [nextValue];
322
+ const nextAlreadyIncludesPrev = nextItems.length >= prevItems.length
323
+ && prevItems.every((item, idx) => String(item.valueOf()) === String(nextItems[idx]?.valueOf()));
324
+ const mergedItems = nextAlreadyIncludesPrev
325
+ ? [...nextItems]
326
+ : [...prevItems, ...nextItems];
327
+ outNode.value.value = new Sequence(mergedItems).inherit(outNode.value.value);
328
+ }
329
+ }
330
+ accumulatedNodes[firstMatch] = outNode;
331
+ for (let i = accumulatedNodes.length - 1; i > firstMatch; i--) {
332
+ const prev = accumulatedNodes[i];
333
+ if (isNode(prev, 'Declaration') && String(prev.value.name) === outName) {
334
+ accumulatedNodes.splice(i, 1);
335
+ }
336
+ }
337
+ continue;
338
+ }
339
+ // Keep merged declarations before nested rulesets to avoid split-output
340
+ // duplicate selectors (e.g. `.each { ... }` then another `.each { ... }`).
341
+ let firstNestedRuleset = -1;
342
+ for (let i = 0; i < accumulatedNodes.length; i++) {
343
+ if (isNode(accumulatedNodes[i], ['Ruleset', 'Rules'])) {
344
+ firstNestedRuleset = i;
345
+ break;
346
+ }
347
+ }
348
+ if (firstNestedRuleset >= 0) {
349
+ accumulatedNodes.splice(firstNestedRuleset, 0, outNode);
350
+ continue;
351
+ }
352
+ }
353
+ }
354
+ accumulatedNodes.push(outNode);
355
+ }
356
+ }
357
+ else {
358
+ accumulatedNodes.push(result);
359
+ }
360
+ }
361
+ return new Rules(accumulatedNodes);
362
+ };
363
+ return run();
364
+ }
365
+ toTrimmedString(options) {
366
+ options = getPrintOptions(options);
367
+ const w = options.writer;
368
+ const mark = w.mark();
369
+ w.add('$for ', this);
370
+ w.add('(');
371
+ patternToNode(this.value.pattern).toString(options);
372
+ w.add(' of ');
373
+ iterableToNode(this.value.iterable).toString(options);
374
+ w.add(')');
375
+ w.add(' ');
376
+ this.value.rules.toBraced(options);
377
+ return w.getSince(mark);
378
+ }
379
+ }
380
+ /**
381
+ * `$each <header> { ... }`
382
+ */
383
+ export class Each extends Node {
384
+ type = 'Each';
385
+ shortType = 'each';
386
+ allowRoot = true;
387
+ allowRuleRoot = true;
388
+ constructor(value, options, location, treeContext) {
389
+ super(value, options, location, treeContext);
390
+ this.addFlags(F_VISIBLE, F_NON_STATIC, F_MAY_ASYNC);
391
+ }
392
+ toTrimmedString(options) {
393
+ options = getPrintOptions(options);
394
+ const w = options.writer;
395
+ const mark = w.mark();
396
+ w.add('$each ', this);
397
+ this.value.header.toString(options);
398
+ w.add(' ');
399
+ this.value.rules.toBraced(options);
400
+ return w.getSince(mark);
401
+ }
402
+ }
403
+ /**
404
+ * `$while (<condition>) { ... }`
405
+ */
406
+ export class While extends Node {
407
+ type = 'While';
408
+ shortType = 'while';
409
+ allowRoot = true;
410
+ allowRuleRoot = true;
411
+ constructor(value, options, location, treeContext) {
412
+ super(value, options, location, treeContext);
413
+ this.addFlags(F_VISIBLE, F_NON_STATIC, F_MAY_ASYNC);
414
+ }
415
+ toTrimmedString(options) {
416
+ options = getPrintOptions(options);
417
+ const w = options.writer;
418
+ const mark = w.mark();
419
+ w.add('$while (', this);
420
+ this.value.condition.toString(options);
421
+ w.add(') ');
422
+ this.value.rules.toBraced(options);
423
+ return w.getSince(mark);
424
+ }
425
+ }
426
+ export const ifNode = defineType(If, 'If', 'if');
427
+ export const forNode = defineType(For, 'For', 'for');
428
+ export const eachNode = defineType(Each, 'Each', 'each');
429
+ export const whileNode = defineType(While, 'While', 'while');
430
+ //# sourceMappingURL=control.js.map