less 4.4.2 → 4.6.0

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 (333) hide show
  1. package/bin/lessc +67 -58
  2. package/dist/less.js +14496 -11811
  3. package/dist/less.min.js +4 -4
  4. package/dist/less.min.js.map +1 -1
  5. package/lib/less/constants.js +5 -7
  6. package/lib/less/contexts.js +71 -56
  7. package/lib/less/data/colors.js +150 -153
  8. package/lib/less/data/index.js +4 -7
  9. package/lib/less/data/unit-conversions.js +2 -5
  10. package/lib/less/default-options.js +52 -23
  11. package/lib/less/deprecation.js +67 -0
  12. package/lib/less/environment/abstract-file-manager.js +62 -50
  13. package/lib/less/environment/abstract-plugin-loader.js +69 -46
  14. package/lib/less/environment/environment-api.ts +21 -0
  15. package/lib/less/environment/environment.js +34 -30
  16. package/lib/less/environment/file-manager-api.ts +77 -0
  17. package/lib/less/functions/boolean.js +13 -13
  18. package/lib/less/functions/color-blending.js +39 -31
  19. package/lib/less/functions/color.js +153 -137
  20. package/lib/less/functions/data-uri.js +73 -64
  21. package/lib/less/functions/default.js +9 -11
  22. package/lib/less/functions/function-caller.js +35 -34
  23. package/lib/less/functions/function-registry.js +16 -17
  24. package/lib/less/functions/index.js +33 -33
  25. package/lib/less/functions/list.js +88 -75
  26. package/lib/less/functions/math-helper.js +8 -11
  27. package/lib/less/functions/math.js +21 -21
  28. package/lib/less/functions/number.js +42 -53
  29. package/lib/less/functions/string.js +18 -22
  30. package/lib/less/functions/style.js +21 -20
  31. package/lib/less/functions/svg.js +83 -82
  32. package/lib/less/functions/types.js +28 -32
  33. package/lib/less/import-manager.js +73 -64
  34. package/lib/less/index.js +65 -65
  35. package/lib/less/less-error.js +65 -46
  36. package/lib/less/logger.js +11 -14
  37. package/lib/less/parse-tree.js +94 -38
  38. package/lib/less/parse.js +44 -44
  39. package/lib/less/parser/parser-input.js +152 -131
  40. package/lib/less/parser/parser.js +866 -672
  41. package/lib/less/plugin-manager.js +57 -46
  42. package/lib/less/render.js +17 -23
  43. package/lib/less/source-map-builder.js +52 -43
  44. package/lib/less/source-map-output.js +57 -44
  45. package/lib/less/transform-tree.js +40 -30
  46. package/lib/less/tree/anonymous.js +52 -28
  47. package/lib/less/tree/assignment.js +44 -27
  48. package/lib/less/tree/atrule-syntax.js +4 -6
  49. package/lib/less/tree/atrule.js +247 -140
  50. package/lib/less/tree/attribute.js +55 -24
  51. package/lib/less/tree/call.js +70 -42
  52. package/lib/less/tree/color.js +194 -145
  53. package/lib/less/tree/combinator.js +31 -21
  54. package/lib/less/tree/comment.js +44 -23
  55. package/lib/less/tree/condition.js +61 -36
  56. package/lib/less/tree/container.js +90 -34
  57. package/lib/less/tree/debug-info.js +53 -11
  58. package/lib/less/tree/declaration.js +97 -52
  59. package/lib/less/tree/detached-ruleset.js +42 -24
  60. package/lib/less/tree/dimension.js +127 -71
  61. package/lib/less/tree/element.js +82 -52
  62. package/lib/less/tree/expression.js +75 -50
  63. package/lib/less/tree/extend.js +71 -42
  64. package/lib/less/tree/import.js +184 -110
  65. package/lib/less/tree/index.js +52 -81
  66. package/lib/less/tree/javascript.js +43 -32
  67. package/lib/less/tree/js-eval-node.js +46 -32
  68. package/lib/less/tree/keyword.js +25 -17
  69. package/lib/less/tree/media.js +77 -35
  70. package/lib/less/tree/merge-rules.js +47 -0
  71. package/lib/less/tree/mixin-call.js +181 -98
  72. package/lib/less/tree/mixin-definition.js +211 -117
  73. package/lib/less/tree/namespace-value.js +63 -44
  74. package/lib/less/tree/negative.js +34 -21
  75. package/lib/less/tree/nested-at-rule.js +149 -66
  76. package/lib/less/tree/node.js +225 -90
  77. package/lib/less/tree/operation.js +59 -34
  78. package/lib/less/tree/paren.js +34 -17
  79. package/lib/less/tree/property.js +66 -35
  80. package/lib/less/tree/query-in-parens.js +52 -60
  81. package/lib/less/tree/quoted.js +93 -44
  82. package/lib/less/tree/ruleset.js +632 -318
  83. package/lib/less/tree/selector.js +151 -77
  84. package/lib/less/tree/unicode-descriptor.js +14 -12
  85. package/lib/less/tree/unit.js +111 -63
  86. package/lib/less/tree/url.js +62 -38
  87. package/lib/less/tree/value.js +50 -34
  88. package/lib/less/tree/variable-call.js +47 -30
  89. package/lib/less/tree/variable.js +53 -31
  90. package/lib/less/utils.js +44 -47
  91. package/lib/less/visitors/extend-visitor.js +233 -172
  92. package/lib/less/visitors/import-sequencer.js +24 -24
  93. package/lib/less/visitors/import-visitor.js +62 -52
  94. package/lib/less/visitors/index.js +14 -17
  95. package/lib/less/visitors/join-selector-visitor.js +40 -37
  96. package/lib/less/visitors/set-tree-visibility-visitor.js +32 -18
  97. package/lib/less/visitors/to-css-visitor.js +135 -128
  98. package/lib/less/visitors/visitor.js +60 -45
  99. package/lib/less-browser/add-default-options.js +23 -13
  100. package/lib/less-browser/bootstrap.js +23 -17
  101. package/lib/less-browser/browser.js +24 -21
  102. package/lib/less-browser/cache.js +17 -19
  103. package/lib/less-browser/error-reporting.js +52 -44
  104. package/lib/less-browser/file-manager.js +52 -42
  105. package/lib/less-browser/image-size.js +12 -12
  106. package/lib/less-browser/index.js +131 -105
  107. package/lib/less-browser/log-listener.js +30 -31
  108. package/lib/less-browser/plugin-loader.js +10 -10
  109. package/lib/less-browser/utils.js +19 -21
  110. package/lib/less-node/environment.js +32 -8
  111. package/lib/less-node/file-manager.js +62 -45
  112. package/lib/less-node/fs.js +11 -8
  113. package/lib/less-node/image-size.js +40 -31
  114. package/lib/less-node/index.js +28 -19
  115. package/lib/less-node/lessc-helper.js +28 -28
  116. package/lib/less-node/plugin-loader.js +35 -27
  117. package/lib/less-node/url-file-manager.js +33 -31
  118. package/package.json +31 -19
  119. package/.eslintignore +0 -6
  120. package/.eslintrc.js +0 -63
  121. package/Gruntfile.js +0 -404
  122. package/bower.json +0 -22
  123. package/lib/less/constants.js.map +0 -1
  124. package/lib/less/contexts.js.map +0 -1
  125. package/lib/less/data/colors.js.map +0 -1
  126. package/lib/less/data/index.js.map +0 -1
  127. package/lib/less/data/unit-conversions.js.map +0 -1
  128. package/lib/less/default-options.js.map +0 -1
  129. package/lib/less/environment/abstract-file-manager.js.map +0 -1
  130. package/lib/less/environment/abstract-plugin-loader.js.map +0 -1
  131. package/lib/less/environment/environment-api.js +0 -3
  132. package/lib/less/environment/environment-api.js.map +0 -1
  133. package/lib/less/environment/environment.js.map +0 -1
  134. package/lib/less/environment/file-manager-api.js +0 -3
  135. package/lib/less/environment/file-manager-api.js.map +0 -1
  136. package/lib/less/functions/boolean.js.map +0 -1
  137. package/lib/less/functions/color-blending.js.map +0 -1
  138. package/lib/less/functions/color.js.map +0 -1
  139. package/lib/less/functions/data-uri.js.map +0 -1
  140. package/lib/less/functions/default.js.map +0 -1
  141. package/lib/less/functions/function-caller.js.map +0 -1
  142. package/lib/less/functions/function-registry.js.map +0 -1
  143. package/lib/less/functions/index.js.map +0 -1
  144. package/lib/less/functions/list.js.map +0 -1
  145. package/lib/less/functions/math-helper.js.map +0 -1
  146. package/lib/less/functions/math.js.map +0 -1
  147. package/lib/less/functions/number.js.map +0 -1
  148. package/lib/less/functions/string.js.map +0 -1
  149. package/lib/less/functions/style.js.map +0 -1
  150. package/lib/less/functions/svg.js.map +0 -1
  151. package/lib/less/functions/types.js.map +0 -1
  152. package/lib/less/import-manager.js.map +0 -1
  153. package/lib/less/index.js.map +0 -1
  154. package/lib/less/less-error.js.map +0 -1
  155. package/lib/less/logger.js.map +0 -1
  156. package/lib/less/parse-tree.js.map +0 -1
  157. package/lib/less/parse.js.map +0 -1
  158. package/lib/less/parser/chunker.js +0 -148
  159. package/lib/less/parser/chunker.js.map +0 -1
  160. package/lib/less/parser/parser-input.js.map +0 -1
  161. package/lib/less/parser/parser.js.map +0 -1
  162. package/lib/less/plugin-manager.js.map +0 -1
  163. package/lib/less/render.js.map +0 -1
  164. package/lib/less/source-map-builder.js.map +0 -1
  165. package/lib/less/source-map-output.js.map +0 -1
  166. package/lib/less/transform-tree.js.map +0 -1
  167. package/lib/less/tree/anonymous.js.map +0 -1
  168. package/lib/less/tree/assignment.js.map +0 -1
  169. package/lib/less/tree/atrule-syntax.js.map +0 -1
  170. package/lib/less/tree/atrule.js.map +0 -1
  171. package/lib/less/tree/attribute.js.map +0 -1
  172. package/lib/less/tree/call.js.map +0 -1
  173. package/lib/less/tree/color.js.map +0 -1
  174. package/lib/less/tree/combinator.js.map +0 -1
  175. package/lib/less/tree/comment.js.map +0 -1
  176. package/lib/less/tree/condition.js.map +0 -1
  177. package/lib/less/tree/container.js.map +0 -1
  178. package/lib/less/tree/debug-info.js.map +0 -1
  179. package/lib/less/tree/declaration.js.map +0 -1
  180. package/lib/less/tree/detached-ruleset.js.map +0 -1
  181. package/lib/less/tree/dimension.js.map +0 -1
  182. package/lib/less/tree/element.js.map +0 -1
  183. package/lib/less/tree/expression.js.map +0 -1
  184. package/lib/less/tree/extend.js.map +0 -1
  185. package/lib/less/tree/import.js.map +0 -1
  186. package/lib/less/tree/index.js.map +0 -1
  187. package/lib/less/tree/javascript.js.map +0 -1
  188. package/lib/less/tree/js-eval-node.js.map +0 -1
  189. package/lib/less/tree/keyword.js.map +0 -1
  190. package/lib/less/tree/media.js.map +0 -1
  191. package/lib/less/tree/mixin-call.js.map +0 -1
  192. package/lib/less/tree/mixin-definition.js.map +0 -1
  193. package/lib/less/tree/namespace-value.js.map +0 -1
  194. package/lib/less/tree/negative.js.map +0 -1
  195. package/lib/less/tree/nested-at-rule.js.map +0 -1
  196. package/lib/less/tree/node.js.map +0 -1
  197. package/lib/less/tree/operation.js.map +0 -1
  198. package/lib/less/tree/paren.js.map +0 -1
  199. package/lib/less/tree/property.js.map +0 -1
  200. package/lib/less/tree/query-in-parens.js.map +0 -1
  201. package/lib/less/tree/quoted.js.map +0 -1
  202. package/lib/less/tree/ruleset.js.map +0 -1
  203. package/lib/less/tree/selector.js.map +0 -1
  204. package/lib/less/tree/unicode-descriptor.js.map +0 -1
  205. package/lib/less/tree/unit.js.map +0 -1
  206. package/lib/less/tree/url.js.map +0 -1
  207. package/lib/less/tree/value.js.map +0 -1
  208. package/lib/less/tree/variable-call.js.map +0 -1
  209. package/lib/less/tree/variable.js.map +0 -1
  210. package/lib/less/utils.js.map +0 -1
  211. package/lib/less/visitors/extend-visitor.js.map +0 -1
  212. package/lib/less/visitors/import-sequencer.js.map +0 -1
  213. package/lib/less/visitors/import-visitor.js.map +0 -1
  214. package/lib/less/visitors/index.js.map +0 -1
  215. package/lib/less/visitors/join-selector-visitor.js.map +0 -1
  216. package/lib/less/visitors/set-tree-visibility-visitor.js.map +0 -1
  217. package/lib/less/visitors/to-css-visitor.js.map +0 -1
  218. package/lib/less/visitors/visitor.js.map +0 -1
  219. package/lib/less-browser/add-default-options.js.map +0 -1
  220. package/lib/less-browser/bootstrap.js.map +0 -1
  221. package/lib/less-browser/browser.js.map +0 -1
  222. package/lib/less-browser/cache.js.map +0 -1
  223. package/lib/less-browser/error-reporting.js.map +0 -1
  224. package/lib/less-browser/file-manager.js.map +0 -1
  225. package/lib/less-browser/image-size.js.map +0 -1
  226. package/lib/less-browser/index.js.map +0 -1
  227. package/lib/less-browser/log-listener.js.map +0 -1
  228. package/lib/less-browser/plugin-loader.js.map +0 -1
  229. package/lib/less-browser/utils.js.map +0 -1
  230. package/lib/less-node/environment.js.map +0 -1
  231. package/lib/less-node/file-manager.js.map +0 -1
  232. package/lib/less-node/fs.js.map +0 -1
  233. package/lib/less-node/image-size.js.map +0 -1
  234. package/lib/less-node/index.js.map +0 -1
  235. package/lib/less-node/lessc-helper.js.map +0 -1
  236. package/lib/less-node/plugin-loader.js.map +0 -1
  237. package/lib/less-node/url-file-manager.js.map +0 -1
  238. package/test/.eslintrc.json +0 -9
  239. package/test/README.md +0 -3
  240. package/test/browser/common.js +0 -230
  241. package/test/browser/css/global-vars/simple.css +0 -3
  242. package/test/browser/css/modify-vars/simple.css +0 -8
  243. package/test/browser/css/plugin/plugin.css +0 -3
  244. package/test/browser/css/postProcessor/postProcessor.css +0 -4
  245. package/test/browser/css/relative-urls/urls.css +0 -36
  246. package/test/browser/css/rewrite-urls/urls.css +0 -36
  247. package/test/browser/css/rootpath/urls.css +0 -35
  248. package/test/browser/css/rootpath-relative/urls.css +0 -35
  249. package/test/browser/css/rootpath-rewrite-urls/urls.css +0 -35
  250. package/test/browser/css/urls.css +0 -54
  251. package/test/browser/generator/benchmark.config.js +0 -50
  252. package/test/browser/generator/generate.js +0 -78
  253. package/test/browser/generator/runner.config.js +0 -188
  254. package/test/browser/generator/runner.js +0 -2
  255. package/test/browser/generator/template.js +0 -93
  256. package/test/browser/generator/utils.js +0 -14
  257. package/test/browser/less/console-errors/test-error.less +0 -3
  258. package/test/browser/less/console-errors/test-error.txt +0 -2
  259. package/test/browser/less/errors/image-height-error.less +0 -3
  260. package/test/browser/less/errors/image-height-error.txt +0 -4
  261. package/test/browser/less/errors/image-size-error.less +0 -3
  262. package/test/browser/less/errors/image-size-error.txt +0 -4
  263. package/test/browser/less/errors/image-width-error.less +0 -3
  264. package/test/browser/less/errors/image-width-error.txt +0 -4
  265. package/test/browser/less/global-vars/simple.less +0 -3
  266. package/test/browser/less/imports/urls.less +0 -4
  267. package/test/browser/less/imports/urls2.less +0 -4
  268. package/test/browser/less/modify-vars/imports/simple2.less +0 -4
  269. package/test/browser/less/modify-vars/simple.less +0 -8
  270. package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
  271. package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
  272. package/test/browser/less/plugin/plugin.js +0 -4
  273. package/test/browser/less/plugin/plugin.less +0 -4
  274. package/test/browser/less/postProcessor/postProcessor.less +0 -4
  275. package/test/browser/less/relative-urls/urls.less +0 -34
  276. package/test/browser/less/rewrite-urls/urls.less +0 -34
  277. package/test/browser/less/rootpath/urls.less +0 -33
  278. package/test/browser/less/rootpath-relative/urls.less +0 -33
  279. package/test/browser/less/rootpath-rewrite-urls/urls.less +0 -33
  280. package/test/browser/less/urls.less +0 -62
  281. package/test/browser/runner-VisitorPlugin-options.js +0 -3
  282. package/test/browser/runner-VisitorPlugin.js +0 -3
  283. package/test/browser/runner-browser-options.js +0 -51
  284. package/test/browser/runner-browser-spec.js +0 -12
  285. package/test/browser/runner-console-errors.js +0 -5
  286. package/test/browser/runner-errors-options.js +0 -6
  287. package/test/browser/runner-errors-spec.js +0 -3
  288. package/test/browser/runner-filemanagerPlugin-options.js +0 -5
  289. package/test/browser/runner-filemanagerPlugin.js +0 -3
  290. package/test/browser/runner-global-vars-options.js +0 -7
  291. package/test/browser/runner-global-vars-spec.js +0 -3
  292. package/test/browser/runner-legacy-options.js +0 -6
  293. package/test/browser/runner-legacy-spec.js +0 -3
  294. package/test/browser/runner-main-options.js +0 -17
  295. package/test/browser/runner-main-spec.js +0 -7
  296. package/test/browser/runner-modify-vars-options.js +0 -5
  297. package/test/browser/runner-modify-vars-spec.js +0 -33
  298. package/test/browser/runner-no-js-errors-options.js +0 -4
  299. package/test/browser/runner-no-js-errors-spec.js +0 -3
  300. package/test/browser/runner-postProcessorPlugin-options.js +0 -3
  301. package/test/browser/runner-postProcessorPlugin.js +0 -3
  302. package/test/browser/runner-preProcessorPlugin-options.js +0 -3
  303. package/test/browser/runner-preProcessorPlugin.js +0 -3
  304. package/test/browser/runner-production-options.js +0 -3
  305. package/test/browser/runner-production-spec.js +0 -5
  306. package/test/browser/runner-relative-urls-options.js +0 -3
  307. package/test/browser/runner-relative-urls-spec.js +0 -3
  308. package/test/browser/runner-rewrite-urls-options.js +0 -3
  309. package/test/browser/runner-rewrite-urls-spec.js +0 -3
  310. package/test/browser/runner-rootpath-options.js +0 -3
  311. package/test/browser/runner-rootpath-relative-options.js +0 -4
  312. package/test/browser/runner-rootpath-relative-spec.js +0 -3
  313. package/test/browser/runner-rootpath-rewrite-urls-options.js +0 -4
  314. package/test/browser/runner-rootpath-rewrite-urls-spec.js +0 -3
  315. package/test/browser/runner-rootpath-spec.js +0 -3
  316. package/test/browser/runner-strict-units-options.js +0 -5
  317. package/test/browser/runner-strict-units-spec.js +0 -3
  318. package/test/index.js +0 -112
  319. package/test/less-test.js +0 -625
  320. package/test/mocha-playwright/runner.js +0 -210
  321. package/test/modify-vars.js +0 -28
  322. package/test/plugins/filemanager/index.js +0 -19
  323. package/test/plugins/postprocess/index.js +0 -14
  324. package/test/plugins/preprocess/index.js +0 -19
  325. package/test/plugins/visitor/index.js +0 -24
  326. package/test/sourcemaps/basic.json +0 -1
  327. package/test/sourcemaps/custom-props.json +0 -1
  328. package/test/sourcemaps/index.html +0 -17
  329. package/test/sourcemaps-disable-annotation/basic.json +0 -1
  330. package/test/sourcemaps-variable-selector/basic.json +0 -1
  331. package/test/test-es6.ts +0 -17
  332. package/tsconfig.build.json +0 -7
  333. package/tsconfig.json +0 -21
@@ -1,27 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var node_1 = tslib_1.__importDefault(require("./node"));
5
- var debug_info_1 = tslib_1.__importDefault(require("./debug-info"));
6
- var Comment = function (value, isLineComment, index, currentFileInfo) {
7
- this.value = value;
8
- this.isLineComment = isLineComment;
9
- this._index = index;
10
- this._fileInfo = currentFileInfo;
11
- this.allowRoot = true;
12
- };
13
- Comment.prototype = Object.assign(new node_1.default(), {
14
- type: 'Comment',
15
- genCSS: function (context, output) {
1
+ // @ts-check
2
+ /** @import { EvalContext, CSSOutput, FileInfo } from './node.js' */
3
+ /** @import { DebugInfoContext } from './debug-info.js' */
4
+ import Node from './node.js';
5
+ import getDebugInfo from './debug-info.js';
6
+
7
+ class Comment extends Node {
8
+ get type() { return 'Comment'; }
9
+
10
+ /**
11
+ * @param {string} value
12
+ * @param {boolean} isLineComment
13
+ * @param {number} index
14
+ * @param {FileInfo} currentFileInfo
15
+ */
16
+ constructor(value, isLineComment, index, currentFileInfo) {
17
+ super();
18
+ this.value = value;
19
+ this.isLineComment = isLineComment;
20
+ this._index = index;
21
+ this._fileInfo = currentFileInfo;
22
+ this.allowRoot = true;
23
+ /** @type {{ lineNumber: number, fileName: string } | undefined} */
24
+ this.debugInfo = undefined;
25
+ }
26
+
27
+ /**
28
+ * @param {EvalContext} context
29
+ * @param {CSSOutput} output
30
+ */
31
+ genCSS(context, output) {
16
32
  if (this.debugInfo) {
17
- output.add((0, debug_info_1.default)(context, this), this.fileInfo(), this.getIndex());
33
+ output.add(getDebugInfo(context, /** @type {DebugInfoContext} */ (this)), this.fileInfo(), this.getIndex());
18
34
  }
19
- output.add(this.value);
20
- },
21
- isSilent: function (context) {
22
- var isCompressed = context.compress && this.value[2] !== '!';
35
+ output.add(/** @type {string} */ (this.value));
36
+ }
37
+
38
+ /**
39
+ * @param {EvalContext} context
40
+ * @returns {boolean}
41
+ */
42
+ isSilent(context) {
43
+ const isCompressed = context.compress && /** @type {string} */ (this.value)[2] !== '!';
23
44
  return this.isLineComment || isCompressed;
24
45
  }
25
- });
26
- exports.default = Comment;
27
- //# sourceMappingURL=comment.js.map
46
+ }
47
+
48
+ export default Comment;
@@ -1,40 +1,65 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var node_1 = tslib_1.__importDefault(require("./node"));
5
- var Condition = function (op, l, r, i, negate) {
6
- this.op = op.trim();
7
- this.lvalue = l;
8
- this.rvalue = r;
9
- this._index = i;
10
- this.negate = negate;
11
- };
12
- Condition.prototype = Object.assign(new node_1.default(), {
13
- type: 'Condition',
14
- accept: function (visitor) {
1
+ // @ts-check
2
+ /** @import { EvalContext, TreeVisitor } from './node.js' */
3
+ import Node from './node.js';
4
+
5
+ class Condition extends Node {
6
+ get type() { return 'Condition'; }
7
+
8
+ /**
9
+ * @param {string} op
10
+ * @param {Node} l
11
+ * @param {Node} r
12
+ * @param {number} i
13
+ * @param {boolean} negate
14
+ */
15
+ constructor(op, l, r, i, negate) {
16
+ super();
17
+ this.op = op.trim();
18
+ this.lvalue = l;
19
+ this.rvalue = r;
20
+ this._index = i;
21
+ this.negate = negate;
22
+ }
23
+
24
+ /** @param {TreeVisitor} visitor */
25
+ accept(visitor) {
15
26
  this.lvalue = visitor.visit(this.lvalue);
16
27
  this.rvalue = visitor.visit(this.rvalue);
17
- },
18
- eval: function (context) {
19
- var result = (function (op, a, b) {
20
- switch (op) {
21
- case 'and': return a && b;
22
- case 'or': return a || b;
23
- default:
24
- switch (node_1.default.compare(a, b)) {
25
- case -1:
26
- return op === '<' || op === '=<' || op === '<=';
27
- case 0:
28
- return op === '=' || op === '>=' || op === '=<' || op === '<=';
29
- case 1:
30
- return op === '>' || op === '>=';
31
- default:
32
- return false;
33
- }
34
- }
35
- })(this.op, this.lvalue.eval(context), this.rvalue.eval(context));
28
+ }
29
+
30
+ /**
31
+ * @param {EvalContext} context
32
+ * @returns {boolean}
33
+ * @suppress {checkTypes}
34
+ */
35
+ // @ts-ignore - Condition.eval returns boolean, not Node (used as guard condition)
36
+ eval(context) {
37
+ const a = this.lvalue.eval(context);
38
+ const b = this.rvalue.eval(context);
39
+ /** @type {boolean} */
40
+ let result;
41
+
42
+ switch (this.op) {
43
+ case 'and': result = Boolean(a && b); break;
44
+ case 'or': result = Boolean(a || b); break;
45
+ default:
46
+ switch (Node.compare(a, b)) {
47
+ case -1:
48
+ result = this.op === '<' || this.op === '=<' || this.op === '<=';
49
+ break;
50
+ case 0:
51
+ result = this.op === '=' || this.op === '>=' || this.op === '=<' || this.op === '<=';
52
+ break;
53
+ case 1:
54
+ result = this.op === '>' || this.op === '>=';
55
+ break;
56
+ default:
57
+ result = false;
58
+ }
59
+ }
60
+
36
61
  return this.negate ? !result : result;
37
62
  }
38
- });
39
- exports.default = Condition;
40
- //# sourceMappingURL=condition.js.map
63
+ }
64
+
65
+ export default Condition;
@@ -1,48 +1,104 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var ruleset_1 = tslib_1.__importDefault(require("./ruleset"));
5
- var value_1 = tslib_1.__importDefault(require("./value"));
6
- var selector_1 = tslib_1.__importDefault(require("./selector"));
7
- var atrule_1 = tslib_1.__importDefault(require("./atrule"));
8
- var nested_at_rule_1 = tslib_1.__importDefault(require("./nested-at-rule"));
9
- var Container = function (value, features, index, currentFileInfo, visibilityInfo) {
10
- this._index = index;
11
- this._fileInfo = currentFileInfo;
12
- var selectors = (new selector_1.default([], null, null, this._index, this._fileInfo)).createEmptySelectors();
13
- this.features = new value_1.default(features);
14
- this.rules = [new ruleset_1.default(selectors, value)];
15
- this.rules[0].allowImports = true;
16
- this.copyVisibilityInfo(visibilityInfo);
17
- this.allowRoot = true;
18
- this.setParent(selectors, this);
19
- this.setParent(this.features, this);
20
- this.setParent(this.rules, this);
21
- };
22
- Container.prototype = Object.assign(new atrule_1.default(), tslib_1.__assign(tslib_1.__assign({ type: 'Container' }, nested_at_rule_1.default), { genCSS: function (context, output) {
1
+ // @ts-check
2
+ /** @import { EvalContext, CSSOutput, FileInfo, VisibilityInfo } from './node.js' */
3
+ /** @import { FunctionRegistry, NestableAtRuleThis } from './nested-at-rule.js' */
4
+ import Node from './node.js';
5
+ import Ruleset from './ruleset.js';
6
+ import Value from './value.js';
7
+ import Selector from './selector.js';
8
+ import AtRule from './atrule.js';
9
+ import NestableAtRulePrototype from './nested-at-rule.js';
10
+
11
+ /**
12
+ * @typedef {Ruleset & {
13
+ * allowImports?: boolean,
14
+ * debugInfo?: { lineNumber: number, fileName: string },
15
+ * functionRegistry?: FunctionRegistry
16
+ * }} RulesetWithExtras
17
+ */
18
+
19
+ class Container extends AtRule {
20
+ get type() { return 'Container'; }
21
+
22
+ /**
23
+ * @param {Node[] | null} value
24
+ * @param {Node[]} features
25
+ * @param {number} index
26
+ * @param {FileInfo} currentFileInfo
27
+ * @param {VisibilityInfo} visibilityInfo
28
+ */
29
+ constructor(value, features, index, currentFileInfo, visibilityInfo) {
30
+ super();
31
+ this._index = index;
32
+ this._fileInfo = currentFileInfo;
33
+
34
+ const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();
35
+
36
+ /** @type {Value} */
37
+ this.features = new Value(features);
38
+ /** @type {RulesetWithExtras[]} */
39
+ this.rules = [new Ruleset(selectors, value)];
40
+ this.rules[0].allowImports = true;
41
+ this.copyVisibilityInfo(visibilityInfo);
42
+ this.allowRoot = true;
43
+ this.setParent(selectors, /** @type {Node} */ (/** @type {unknown} */ (this)));
44
+ this.setParent(this.features, /** @type {Node} */ (/** @type {unknown} */ (this)));
45
+ this.setParent(this.rules, /** @type {Node} */ (/** @type {unknown} */ (this)));
46
+
47
+ /** @type {boolean | undefined} */
48
+ this._evaluated = undefined;
49
+ }
50
+
51
+ /**
52
+ * @param {EvalContext} context
53
+ * @param {CSSOutput} output
54
+ */
55
+ genCSS(context, output) {
23
56
  output.add('@container ', this._fileInfo, this._index);
24
57
  this.features.genCSS(context, output);
25
58
  this.outputRuleset(context, output, this.rules);
26
- }, eval: function (context) {
59
+ }
60
+
61
+ /**
62
+ * @param {EvalContext} context
63
+ * @returns {Node}
64
+ */
65
+ eval(context) {
66
+ if (this._evaluated) {
67
+ return /** @type {Node} */ (/** @type {unknown} */ (this));
68
+ }
27
69
  if (!context.mediaBlocks) {
28
70
  context.mediaBlocks = [];
29
71
  context.mediaPath = [];
30
72
  }
31
- var media = new Container(null, [], this._index, this._fileInfo, this.visibilityInfo());
73
+
74
+ const media = new Container(null, [], this._index, this._fileInfo, this.visibilityInfo());
75
+ media._evaluated = true;
32
76
  if (this.debugInfo) {
33
77
  this.rules[0].debugInfo = this.debugInfo;
34
78
  media.debugInfo = this.debugInfo;
35
79
  }
36
- media.features = this.features.eval(context);
37
- context.mediaPath.push(media);
38
- context.mediaBlocks.push(media);
39
- this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit();
80
+
81
+ media.features = /** @type {Value} */ (this.features.eval(context));
82
+
83
+ context.mediaPath.push(/** @type {Node} */ (/** @type {unknown} */ (media)));
84
+ context.mediaBlocks.push(/** @type {Node} */ (/** @type {unknown} */ (media)));
85
+
86
+ const fr = /** @type {RulesetWithExtras} */ (context.frames[0]).functionRegistry;
87
+ if (fr) {
88
+ this.rules[0].functionRegistry = fr.inherit();
89
+ }
40
90
  context.frames.unshift(this.rules[0]);
41
- media.rules = [this.rules[0].eval(context)];
91
+ media.rules = [/** @type {RulesetWithExtras} */ (this.rules[0].eval(context))];
42
92
  context.frames.shift();
93
+
43
94
  context.mediaPath.pop();
44
- return context.mediaPath.length === 0 ? media.evalTop(context) :
45
- media.evalNested(context);
46
- } }));
47
- exports.default = Container;
48
- //# sourceMappingURL=container.js.map
95
+
96
+ return context.mediaPath.length === 0 ? /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalTop(context) :
97
+ /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalNested(context);
98
+ }
99
+ }
100
+
101
+ // Apply NestableAtRulePrototype methods (accept, isRulesetLike override AtRule's versions)
102
+ Object.assign(Container.prototype, NestableAtRulePrototype);
103
+
104
+ export default Container;
@@ -1,22 +1,64 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ // @ts-check
2
+
3
+ /**
4
+ * @typedef {object} DebugInfoData
5
+ * @property {number} lineNumber
6
+ * @property {string} fileName
7
+ */
8
+
9
+ /**
10
+ * @typedef {object} DebugInfoContext
11
+ * @property {DebugInfoData} debugInfo
12
+ */
13
+
14
+ /**
15
+ * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.
16
+ * This will be removed in a future version.
17
+ *
18
+ * @param {DebugInfoContext} ctx - Context object with debugInfo
19
+ * @returns {string} Debug info as CSS comment
20
+ */
3
21
  function asComment(ctx) {
4
- return "/* line ".concat(ctx.debugInfo.lineNumber, ", ").concat(ctx.debugInfo.fileName, " */\n");
22
+ return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\n`;
5
23
  }
24
+
25
+ /**
26
+ * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.
27
+ * This function generates Sass-compatible debug info using @media -sass-debug-info syntax.
28
+ * This format had short-lived usage and is no longer recommended.
29
+ * This will be removed in a future version.
30
+ *
31
+ * @param {DebugInfoContext} ctx - Context object with debugInfo
32
+ * @returns {string} Sass-compatible debug info as @media query
33
+ */
6
34
  function asMediaQuery(ctx) {
7
- var filenameWithProtocol = ctx.debugInfo.fileName;
35
+ let filenameWithProtocol = ctx.debugInfo.fileName;
8
36
  if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) {
9
- filenameWithProtocol = "file://".concat(filenameWithProtocol);
37
+ filenameWithProtocol = `file://${filenameWithProtocol}`;
10
38
  }
11
- return "@media -sass-debug-info{filename{font-family:".concat(filenameWithProtocol.replace(/([.:/\\])/g, function (a) {
39
+ return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:/\\])/g, function (a) {
12
40
  if (a == '\\') {
13
41
  a = '/';
14
42
  }
15
- return "\\".concat(a);
16
- }), "}line{font-family:\\00003").concat(ctx.debugInfo.lineNumber, "}}\n");
43
+ return `\\${a}`;
44
+ })}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`;
17
45
  }
46
+
47
+ /**
48
+ * Generates debug information (line numbers) for CSS output.
49
+ *
50
+ * @param {{ dumpLineNumbers?: string, compress?: boolean }} context - Context object with dumpLineNumbers option
51
+ * @param {DebugInfoContext} ctx - Context object with debugInfo
52
+ * @param {string} [lineSeparator] - Separator between comment and media query (for 'all' mode)
53
+ * @returns {string} Debug info string
54
+ *
55
+ * @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead.
56
+ * All modes ('comments', 'mediaquery', 'all') are deprecated and will be removed in a future version.
57
+ * The 'mediaquery' and 'all' modes generate Sass-compatible @media -sass-debug-info output
58
+ * which had short-lived usage and is no longer recommended.
59
+ */
18
60
  function debugInfo(context, ctx, lineSeparator) {
19
- var result = '';
61
+ let result = '';
20
62
  if (context.dumpLineNumbers && !context.compress) {
21
63
  switch (context.dumpLineNumbers) {
22
64
  case 'comments':
@@ -32,5 +74,5 @@ function debugInfo(context, ctx, lineSeparator) {
32
74
  }
33
75
  return result;
34
76
  }
35
- exports.default = debugInfo;
36
- //# sourceMappingURL=debug-info.js.map
77
+
78
+ export default debugInfo;
@@ -1,58 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var node_1 = tslib_1.__importDefault(require("./node"));
5
- var value_1 = tslib_1.__importDefault(require("./value"));
6
- var keyword_1 = tslib_1.__importDefault(require("./keyword"));
7
- var anonymous_1 = tslib_1.__importDefault(require("./anonymous"));
8
- var Constants = tslib_1.__importStar(require("../constants"));
9
- var MATH = Constants.Math;
1
+ // @ts-check
2
+ /** @import { EvalContext, CSSOutput, FileInfo } from './node.js' */
3
+ import Node from './node.js';
4
+ import Value from './value.js';
5
+ import Keyword from './keyword.js';
6
+ import Anonymous from './anonymous.js';
7
+ import * as Constants from '../constants.js';
8
+ const MATH = Constants.Math;
9
+
10
+ /**
11
+ * @param {EvalContext} context
12
+ * @param {Node[]} name
13
+ * @returns {string}
14
+ */
10
15
  function evalName(context, name) {
11
- var value = '';
12
- var i;
13
- var n = name.length;
14
- var output = { add: function (s) { value += s; } };
16
+ let value = '';
17
+ let i;
18
+ const n = name.length;
19
+ /** @type {CSSOutput} */
20
+ const output = {add: function (s) {value += s;}, isEmpty: function() { return value === ''; }};
15
21
  for (i = 0; i < n; i++) {
16
22
  name[i].eval(context).genCSS(context, output);
17
23
  }
18
24
  return value;
19
25
  }
20
- var Declaration = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
21
- this.name = name;
22
- this.value = (value instanceof node_1.default) ? value : new value_1.default([value ? new anonymous_1.default(value) : null]);
23
- this.important = important ? " ".concat(important.trim()) : '';
24
- this.merge = merge;
25
- this._index = index;
26
- this._fileInfo = currentFileInfo;
27
- this.inline = inline || false;
28
- this.variable = (variable !== undefined) ? variable
29
- : (name.charAt && (name.charAt(0) === '@'));
30
- this.allowRoot = true;
31
- this.setParent(this.value, this);
32
- };
33
- Declaration.prototype = Object.assign(new node_1.default(), {
34
- type: 'Declaration',
35
- genCSS: function (context, output) {
36
- output.add(this.name + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex());
26
+
27
+ class Declaration extends Node {
28
+ get type() { return 'Declaration'; }
29
+
30
+ /**
31
+ * @param {string | Node[]} name
32
+ * @param {Node | string | null} value
33
+ * @param {string} [important]
34
+ * @param {string} [merge]
35
+ * @param {number} [index]
36
+ * @param {FileInfo} [currentFileInfo]
37
+ * @param {boolean} [inline]
38
+ * @param {boolean} [variable]
39
+ */
40
+ constructor(name, value, important, merge, index, currentFileInfo, inline, variable) {
41
+ super();
42
+ this.name = name;
43
+ this.value = (value instanceof Node) ? value : new Value([value ? new Anonymous(value) : null]);
44
+ this.important = important ? ` ${important.trim()}` : '';
45
+ /** @type {string | undefined} */
46
+ this.merge = merge;
47
+ this._index = index;
48
+ this._fileInfo = currentFileInfo;
49
+ /** @type {boolean} */
50
+ this.inline = inline || false;
51
+ /** @type {boolean} */
52
+ this.variable = (variable !== undefined) ? variable
53
+ : (typeof name === 'string' && name.charAt(0) === '@');
54
+ /** @type {boolean} */
55
+ this.allowRoot = true;
56
+ this.setParent(this.value, this);
57
+ }
58
+
59
+ /**
60
+ * @param {EvalContext} context
61
+ * @param {CSSOutput} output
62
+ */
63
+ genCSS(context, output) {
64
+ output.add(/** @type {string} */ (this.name) + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex());
37
65
  try {
38
- this.value.genCSS(context, output);
66
+ /** @type {Node} */ (this.value).genCSS(context, output);
39
67
  }
40
68
  catch (e) {
41
- e.index = this._index;
42
- e.filename = this._fileInfo.filename;
69
+ const err = /** @type {{ index?: number, filename?: string }} */ (e);
70
+ err.index = this._index;
71
+ err.filename = this._fileInfo && this._fileInfo.filename;
43
72
  throw e;
44
73
  }
45
74
  output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? '' : ';'), this._fileInfo, this._index);
46
- },
47
- eval: function (context) {
48
- var mathBypass = false, prevMath, name = this.name, evaldValue, variable = this.variable;
75
+ }
76
+
77
+ /** @param {EvalContext} context */
78
+ eval(context) {
79
+ let mathBypass = false, prevMath, name = this.name, evaldValue, variable = this.variable;
49
80
  if (typeof name !== 'string') {
50
81
  // expand 'primitive' name directly to get
51
82
  // things faster (~10% for benchmark.less):
52
- name = (name.length === 1) && (name[0] instanceof keyword_1.default) ?
53
- name[0].value : evalName(context, name);
83
+ name = (/** @type {Node[]} */ (name).length === 1) && (/** @type {Node[]} */ (name)[0] instanceof Keyword) ?
84
+ /** @type {string} */ (/** @type {Node[]} */ (name)[0].value) : evalName(context, /** @type {Node[]} */ (name));
54
85
  variable = false; // never treat expanded interpolation as new variable name
55
86
  }
87
+
56
88
  // @todo remove when parens-division is default
57
89
  if (name === 'font' && context.math === MATH.ALWAYS) {
58
90
  mathBypass = true;
@@ -61,22 +93,30 @@ Declaration.prototype = Object.assign(new node_1.default(), {
61
93
  }
62
94
  try {
63
95
  context.importantScope.push({});
64
- evaldValue = this.value.eval(context);
96
+ evaldValue = /** @type {Node} */ (this.value).eval(context);
97
+
65
98
  if (!this.variable && evaldValue.type === 'DetachedRuleset') {
66
99
  throw { message: 'Rulesets cannot be evaluated on a property.',
67
100
  index: this.getIndex(), filename: this.fileInfo().filename };
68
101
  }
69
- var important = this.important;
70
- var importantResult = context.importantScope.pop();
71
- if (!important && importantResult.important) {
102
+ let important = this.important;
103
+ const importantResult = context.importantScope.pop();
104
+ if (!important && importantResult && importantResult.important) {
72
105
  important = importantResult.important;
73
106
  }
74
- return new Declaration(name, evaldValue, important, this.merge, this.getIndex(), this.fileInfo(), this.inline, variable);
107
+
108
+ return new Declaration(/** @type {string} */ (name),
109
+ evaldValue,
110
+ important,
111
+ this.merge,
112
+ this.getIndex(), this.fileInfo(), this.inline,
113
+ variable);
75
114
  }
76
115
  catch (e) {
77
- if (typeof e.index !== 'number') {
78
- e.index = this.getIndex();
79
- e.filename = this.fileInfo().filename;
116
+ const err = /** @type {{ index?: number, filename?: string }} */ (e);
117
+ if (typeof err.index !== 'number') {
118
+ err.index = this.getIndex();
119
+ err.filename = this.fileInfo().filename;
80
120
  }
81
121
  throw e;
82
122
  }
@@ -85,10 +125,15 @@ Declaration.prototype = Object.assign(new node_1.default(), {
85
125
  context.math = prevMath;
86
126
  }
87
127
  }
88
- },
89
- makeImportant: function () {
90
- return new Declaration(this.name, this.value, '!important', this.merge, this.getIndex(), this.fileInfo(), this.inline);
91
128
  }
92
- });
93
- exports.default = Declaration;
94
- //# sourceMappingURL=declaration.js.map
129
+
130
+ makeImportant() {
131
+ return new Declaration(this.name,
132
+ /** @type {Node} */ (this.value),
133
+ '!important',
134
+ this.merge,
135
+ this.getIndex(), this.fileInfo(), this.inline);
136
+ }
137
+ }
138
+
139
+ export default Declaration;