less 4.5.1 → 4.6.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 (340) hide show
  1. package/README.md +70 -5
  2. package/bin/lessc +37 -23
  3. package/dist/less.js +14501 -11745
  4. package/dist/less.min.js +4 -4
  5. package/dist/less.min.js.map +1 -1
  6. package/index.cjs +41 -0
  7. package/lib/less/constants.js +5 -7
  8. package/lib/less/contexts.js +71 -55
  9. package/lib/less/data/colors.js +150 -153
  10. package/lib/less/data/index.js +4 -7
  11. package/lib/less/data/unit-conversions.js +2 -5
  12. package/lib/less/default-options.js +36 -26
  13. package/lib/less/deprecation.js +67 -0
  14. package/lib/less/environment/abstract-file-manager.js +62 -50
  15. package/lib/less/environment/abstract-plugin-loader.js +69 -46
  16. package/lib/less/environment/environment-api.ts +21 -0
  17. package/lib/less/environment/environment.js +34 -30
  18. package/lib/less/environment/file-manager-api.ts +77 -0
  19. package/lib/less/functions/boolean.js +13 -13
  20. package/lib/less/functions/color-blending.js +39 -31
  21. package/lib/less/functions/color.js +153 -137
  22. package/lib/less/functions/data-uri.js +73 -64
  23. package/lib/less/functions/default.js +9 -11
  24. package/lib/less/functions/function-caller.js +35 -34
  25. package/lib/less/functions/function-registry.js +16 -17
  26. package/lib/less/functions/index.js +33 -33
  27. package/lib/less/functions/list.js +88 -75
  28. package/lib/less/functions/math-helper.js +8 -11
  29. package/lib/less/functions/math.js +21 -21
  30. package/lib/less/functions/number.js +42 -53
  31. package/lib/less/functions/string.js +18 -22
  32. package/lib/less/functions/style.js +21 -20
  33. package/lib/less/functions/svg.js +83 -82
  34. package/lib/less/functions/types.js +28 -32
  35. package/lib/less/import-manager.js +73 -64
  36. package/lib/less/index.js +65 -65
  37. package/lib/less/less-error.js +63 -45
  38. package/lib/less/logger.js +11 -14
  39. package/lib/less/parse-tree.js +52 -53
  40. package/lib/less/parse.js +44 -44
  41. package/lib/less/parser/parser-input.js +151 -113
  42. package/lib/less/parser/parser.js +864 -658
  43. package/lib/less/plugin-manager.js +57 -46
  44. package/lib/less/render.js +17 -23
  45. package/lib/less/source-map-builder.js +52 -43
  46. package/lib/less/source-map-output.js +56 -43
  47. package/lib/less/transform-tree.js +40 -30
  48. package/lib/less/tree/anonymous.js +52 -28
  49. package/lib/less/tree/assignment.js +44 -27
  50. package/lib/less/tree/atrule-syntax.js +4 -6
  51. package/lib/less/tree/atrule.js +247 -140
  52. package/lib/less/tree/attribute.js +55 -24
  53. package/lib/less/tree/call.js +70 -42
  54. package/lib/less/tree/color.js +194 -145
  55. package/lib/less/tree/combinator.js +31 -21
  56. package/lib/less/tree/comment.js +44 -23
  57. package/lib/less/tree/condition.js +61 -36
  58. package/lib/less/tree/container.js +90 -34
  59. package/lib/less/tree/debug-info.js +28 -15
  60. package/lib/less/tree/declaration.js +97 -52
  61. package/lib/less/tree/detached-ruleset.js +42 -24
  62. package/lib/less/tree/dimension.js +127 -71
  63. package/lib/less/tree/element.js +82 -52
  64. package/lib/less/tree/expression.js +75 -50
  65. package/lib/less/tree/extend.js +71 -42
  66. package/lib/less/tree/import.js +184 -110
  67. package/lib/less/tree/index.js +52 -81
  68. package/lib/less/tree/javascript.js +43 -32
  69. package/lib/less/tree/js-eval-node.js +46 -32
  70. package/lib/less/tree/keyword.js +25 -17
  71. package/lib/less/tree/media.js +77 -35
  72. package/lib/less/tree/merge-rules.js +47 -0
  73. package/lib/less/tree/mixin-call.js +181 -98
  74. package/lib/less/tree/mixin-definition.js +211 -117
  75. package/lib/less/tree/namespace-value.js +63 -44
  76. package/lib/less/tree/negative.js +34 -21
  77. package/lib/less/tree/nested-at-rule.js +149 -66
  78. package/lib/less/tree/node.js +225 -90
  79. package/lib/less/tree/operation.js +59 -34
  80. package/lib/less/tree/paren.js +34 -17
  81. package/lib/less/tree/property.js +66 -35
  82. package/lib/less/tree/query-in-parens.js +52 -60
  83. package/lib/less/tree/quoted.js +93 -44
  84. package/lib/less/tree/ruleset.js +632 -318
  85. package/lib/less/tree/selector.js +151 -77
  86. package/lib/less/tree/unicode-descriptor.js +14 -12
  87. package/lib/less/tree/unit.js +111 -63
  88. package/lib/less/tree/url.js +62 -38
  89. package/lib/less/tree/value.js +50 -34
  90. package/lib/less/tree/variable-call.js +47 -30
  91. package/lib/less/tree/variable.js +53 -31
  92. package/lib/less/utils.js +44 -47
  93. package/lib/less/visitors/extend-visitor.js +233 -172
  94. package/lib/less/visitors/import-sequencer.js +24 -24
  95. package/lib/less/visitors/import-visitor.js +62 -52
  96. package/lib/less/visitors/index.js +14 -17
  97. package/lib/less/visitors/join-selector-visitor.js +40 -37
  98. package/lib/less/visitors/set-tree-visibility-visitor.js +32 -18
  99. package/lib/less/visitors/to-css-visitor.js +135 -128
  100. package/lib/less/visitors/visitor.js +60 -45
  101. package/lib/less-browser/add-default-options.js +23 -13
  102. package/lib/less-browser/bootstrap.js +23 -17
  103. package/lib/less-browser/browser.js +24 -21
  104. package/lib/less-browser/cache.js +17 -19
  105. package/lib/less-browser/error-reporting.js +52 -44
  106. package/lib/less-browser/file-manager.js +52 -42
  107. package/lib/less-browser/image-size.js +12 -12
  108. package/lib/less-browser/index.js +131 -105
  109. package/lib/less-browser/log-listener.js +30 -31
  110. package/lib/less-browser/plugin-loader.js +10 -10
  111. package/lib/less-browser/utils.js +19 -21
  112. package/lib/less-node/environment.js +32 -8
  113. package/lib/less-node/file-manager.js +62 -45
  114. package/lib/less-node/fs.js +11 -8
  115. package/lib/less-node/image-size.js +40 -31
  116. package/lib/less-node/index.js +28 -19
  117. package/lib/less-node/lessc-helper.js +20 -21
  118. package/lib/less-node/plugin-loader.js +35 -27
  119. package/lib/less-node/url-file-manager.js +33 -31
  120. package/package.json +29 -18
  121. package/.eslintignore +0 -6
  122. package/.eslintrc.js +0 -63
  123. package/Gruntfile.js +0 -403
  124. package/bower.json +0 -22
  125. package/lib/less/constants.js.map +0 -1
  126. package/lib/less/contexts.js.map +0 -1
  127. package/lib/less/data/colors.js.map +0 -1
  128. package/lib/less/data/index.js.map +0 -1
  129. package/lib/less/data/unit-conversions.js.map +0 -1
  130. package/lib/less/default-options.js.map +0 -1
  131. package/lib/less/environment/abstract-file-manager.js.map +0 -1
  132. package/lib/less/environment/abstract-plugin-loader.js.map +0 -1
  133. package/lib/less/environment/environment-api.js +0 -3
  134. package/lib/less/environment/environment-api.js.map +0 -1
  135. package/lib/less/environment/environment.js.map +0 -1
  136. package/lib/less/environment/file-manager-api.js +0 -3
  137. package/lib/less/environment/file-manager-api.js.map +0 -1
  138. package/lib/less/functions/boolean.js.map +0 -1
  139. package/lib/less/functions/color-blending.js.map +0 -1
  140. package/lib/less/functions/color.js.map +0 -1
  141. package/lib/less/functions/data-uri.js.map +0 -1
  142. package/lib/less/functions/default.js.map +0 -1
  143. package/lib/less/functions/function-caller.js.map +0 -1
  144. package/lib/less/functions/function-registry.js.map +0 -1
  145. package/lib/less/functions/index.js.map +0 -1
  146. package/lib/less/functions/list.js.map +0 -1
  147. package/lib/less/functions/math-helper.js.map +0 -1
  148. package/lib/less/functions/math.js.map +0 -1
  149. package/lib/less/functions/number.js.map +0 -1
  150. package/lib/less/functions/string.js.map +0 -1
  151. package/lib/less/functions/style.js.map +0 -1
  152. package/lib/less/functions/svg.js.map +0 -1
  153. package/lib/less/functions/types.js.map +0 -1
  154. package/lib/less/import-manager.js.map +0 -1
  155. package/lib/less/index.js.map +0 -1
  156. package/lib/less/less-error.js.map +0 -1
  157. package/lib/less/logger.js.map +0 -1
  158. package/lib/less/parse-tree.js.map +0 -1
  159. package/lib/less/parse.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/scripts/coverage-lines.js +0 -207
  239. package/scripts/coverage-report.js +0 -158
  240. package/scripts/postinstall.js +0 -61
  241. package/test/.eslintrc.json +0 -9
  242. package/test/README.md +0 -3
  243. package/test/browser/common.js +0 -251
  244. package/test/browser/css/global-vars/simple.css +0 -3
  245. package/test/browser/css/modify-vars/simple.css +0 -8
  246. package/test/browser/css/plugin/plugin.css +0 -3
  247. package/test/browser/css/postProcessor/postProcessor.css +0 -4
  248. package/test/browser/css/relative-urls/urls.css +0 -36
  249. package/test/browser/css/rewrite-urls/urls.css +0 -36
  250. package/test/browser/css/rootpath/urls.css +0 -35
  251. package/test/browser/css/rootpath-relative/urls.css +0 -35
  252. package/test/browser/css/rootpath-rewrite-urls/urls.css +0 -35
  253. package/test/browser/css/urls.css +0 -54
  254. package/test/browser/generator/benchmark.config.js +0 -50
  255. package/test/browser/generator/generate.js +0 -78
  256. package/test/browser/generator/runner.config.js +0 -184
  257. package/test/browser/generator/runner.js +0 -2
  258. package/test/browser/generator/template.js +0 -104
  259. package/test/browser/generator/utils.js +0 -14
  260. package/test/browser/less/console-errors/test-error.less +0 -3
  261. package/test/browser/less/console-errors/test-error.txt +0 -2
  262. package/test/browser/less/errors/image-height-error.less +0 -3
  263. package/test/browser/less/errors/image-height-error.txt +0 -4
  264. package/test/browser/less/errors/image-size-error.less +0 -3
  265. package/test/browser/less/errors/image-size-error.txt +0 -4
  266. package/test/browser/less/errors/image-width-error.less +0 -3
  267. package/test/browser/less/errors/image-width-error.txt +0 -4
  268. package/test/browser/less/global-vars/simple.less +0 -3
  269. package/test/browser/less/imports/urls.less +0 -4
  270. package/test/browser/less/imports/urls2.less +0 -4
  271. package/test/browser/less/modify-vars/imports/simple2.less +0 -4
  272. package/test/browser/less/modify-vars/simple.less +0 -8
  273. package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
  274. package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
  275. package/test/browser/less/plugin/plugin.js +0 -4
  276. package/test/browser/less/plugin/plugin.less +0 -4
  277. package/test/browser/less/postProcessor/postProcessor.less +0 -4
  278. package/test/browser/less/relative-urls/urls.less +0 -34
  279. package/test/browser/less/rewrite-urls/urls.less +0 -34
  280. package/test/browser/less/rootpath/urls.less +0 -33
  281. package/test/browser/less/rootpath-relative/urls.less +0 -33
  282. package/test/browser/less/rootpath-rewrite-urls/urls.less +0 -33
  283. package/test/browser/less/urls.less +0 -62
  284. package/test/browser/runner-VisitorPlugin-options.js +0 -3
  285. package/test/browser/runner-VisitorPlugin.js +0 -3
  286. package/test/browser/runner-browser-options.js +0 -51
  287. package/test/browser/runner-browser-spec.js +0 -12
  288. package/test/browser/runner-console-errors.js +0 -5
  289. package/test/browser/runner-errors-options.js +0 -6
  290. package/test/browser/runner-errors-spec.js +0 -3
  291. package/test/browser/runner-filemanagerPlugin-options.js +0 -5
  292. package/test/browser/runner-filemanagerPlugin.js +0 -3
  293. package/test/browser/runner-global-vars-options.js +0 -7
  294. package/test/browser/runner-global-vars-spec.js +0 -3
  295. package/test/browser/runner-main-options.js +0 -17
  296. package/test/browser/runner-main-spec.js +0 -7
  297. package/test/browser/runner-modify-vars-options.js +0 -5
  298. package/test/browser/runner-modify-vars-spec.js +0 -33
  299. package/test/browser/runner-no-js-errors-options.js +0 -4
  300. package/test/browser/runner-no-js-errors-spec.js +0 -3
  301. package/test/browser/runner-postProcessorPlugin-options.js +0 -3
  302. package/test/browser/runner-postProcessorPlugin.js +0 -3
  303. package/test/browser/runner-preProcessorPlugin-options.js +0 -3
  304. package/test/browser/runner-preProcessorPlugin.js +0 -3
  305. package/test/browser/runner-production-options.js +0 -3
  306. package/test/browser/runner-production-spec.js +0 -5
  307. package/test/browser/runner-relative-urls-options.js +0 -3
  308. package/test/browser/runner-relative-urls-spec.js +0 -3
  309. package/test/browser/runner-rewrite-urls-options.js +0 -3
  310. package/test/browser/runner-rewrite-urls-spec.js +0 -3
  311. package/test/browser/runner-rootpath-options.js +0 -3
  312. package/test/browser/runner-rootpath-relative-options.js +0 -4
  313. package/test/browser/runner-rootpath-relative-spec.js +0 -3
  314. package/test/browser/runner-rootpath-rewrite-urls-options.js +0 -4
  315. package/test/browser/runner-rootpath-rewrite-urls-spec.js +0 -3
  316. package/test/browser/runner-rootpath-spec.js +0 -3
  317. package/test/browser/runner-strict-units-options.js +0 -5
  318. package/test/browser/runner-strict-units-spec.js +0 -3
  319. package/test/index.js +0 -307
  320. package/test/less-test.js +0 -984
  321. package/test/mocha-playwright/runner.js +0 -210
  322. package/test/modify-vars.js +0 -28
  323. package/test/plugins/filemanager/index.js +0 -19
  324. package/test/plugins/postprocess/index.js +0 -14
  325. package/test/plugins/preprocess/index.js +0 -19
  326. package/test/plugins/visitor/index.js +0 -24
  327. package/test/sourcemaps/basic.json +0 -1
  328. package/test/sourcemaps/comprehensive.json +0 -1
  329. package/test/sourcemaps/custom-props.json +0 -1
  330. package/test/sourcemaps/index.html +0 -17
  331. package/test/sourcemaps/sourcemaps-basepath.json +0 -1
  332. package/test/sourcemaps/sourcemaps-include-source.json +0 -1
  333. package/test/sourcemaps/sourcemaps-rootpath.json +0 -1
  334. package/test/sourcemaps/sourcemaps-url.json +0 -1
  335. package/test/sourcemaps-disable-annotation/basic.json +0 -1
  336. package/test/sourcemaps-variable-selector/basic.json +0 -1
  337. package/test/test-es6.ts +0 -17
  338. package/test.less +0 -1
  339. package/tsconfig.build.json +0 -7
  340. package/tsconfig.json +0 -21
@@ -1,39 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
5
- var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
6
- var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js"));
7
- var minMax = function (isMin, args) {
8
- var _this = this;
1
+ import Dimension from '../tree/dimension.js';
2
+ import Anonymous from '../tree/anonymous.js';
3
+ import mathHelper from './math-helper.js';
4
+
5
+ const minMax = function (isMin, args) {
9
6
  args = Array.prototype.slice.call(args);
10
7
  switch (args.length) {
11
8
  case 0: throw { type: 'Argument', message: 'one or more arguments required' };
12
9
  }
13
- var i; // key is the unit.toString() for unified Dimension values,
14
- var j;
15
- var current;
16
- var currentUnified;
17
- var referenceUnified;
18
- var unit;
19
- var unitStatic;
20
- var unitClone;
21
- var // elems only contains original argument values.
22
- order = [];
23
- var values = {};
10
+ let i; // key is the unit.toString() for unified Dimension values,
11
+ let j;
12
+ let current;
13
+ let currentUnified;
14
+ let referenceUnified;
15
+ let unit;
16
+ let unitStatic;
17
+ let unitClone;
18
+
19
+ const // elems only contains original argument values.
20
+ order = [];
21
+
22
+ const values = {};
24
23
  // value is the index into the order array.
25
24
  for (i = 0; i < args.length; i++) {
26
25
  current = args[i];
27
- if (!(current instanceof dimension_1.default)) {
26
+ if (!(current instanceof Dimension)) {
28
27
  if (Array.isArray(args[i].value)) {
29
28
  Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
30
29
  continue;
31
- }
32
- else {
30
+ } else {
33
31
  throw { type: 'Argument', message: 'incompatible types' };
34
32
  }
35
33
  }
36
- currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new dimension_1.default(current.value, unitClone).unify() : current.unify();
34
+ currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();
37
35
  unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
38
36
  unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;
39
37
  unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;
@@ -46,8 +44,8 @@ var minMax = function (isMin, args) {
46
44
  order.push(current);
47
45
  continue;
48
46
  }
49
- referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new dimension_1.default(order[j].value, unitClone).unify() : order[j].unify();
50
- if (isMin && currentUnified.value < referenceUnified.value ||
47
+ referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();
48
+ if ( isMin && currentUnified.value < referenceUnified.value ||
51
49
  !isMin && currentUnified.value > referenceUnified.value) {
52
50
  order[j] = current;
53
51
  }
@@ -55,52 +53,43 @@ var minMax = function (isMin, args) {
55
53
  if (order.length == 1) {
56
54
  return order[0];
57
55
  }
58
- args = order.map(function (a) { return a.toCSS(_this.context); }).join(this.context.compress ? ',' : ', ');
59
- return new anonymous_1.default("".concat(isMin ? 'min' : 'max', "(").concat(args, ")"));
56
+ args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
57
+ return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
60
58
  };
61
- exports.default = {
62
- min: function () {
63
- var args = [];
64
- for (var _i = 0; _i < arguments.length; _i++) {
65
- args[_i] = arguments[_i];
66
- }
59
+
60
+ export default {
61
+ min: function(...args) {
67
62
  try {
68
63
  return minMax.call(this, true, args);
69
- }
70
- catch (e) { }
64
+ } catch (e) {}
71
65
  },
72
- max: function () {
73
- var args = [];
74
- for (var _i = 0; _i < arguments.length; _i++) {
75
- args[_i] = arguments[_i];
76
- }
66
+ max: function(...args) {
77
67
  try {
78
68
  return minMax.call(this, false, args);
79
- }
80
- catch (e) { }
69
+ } catch (e) {}
81
70
  },
82
71
  convert: function (val, unit) {
83
72
  return val.convertTo(unit.value);
84
73
  },
85
74
  pi: function () {
86
- return new dimension_1.default(Math.PI);
75
+ return new Dimension(Math.PI);
87
76
  },
88
- mod: function (a, b) {
89
- return new dimension_1.default(a.value % b.value, a.unit);
77
+ mod: function(a, b) {
78
+ return new Dimension(a.value % b.value, a.unit);
90
79
  },
91
- pow: function (x, y) {
80
+ pow: function(x, y) {
92
81
  if (typeof x === 'number' && typeof y === 'number') {
93
- x = new dimension_1.default(x);
94
- y = new dimension_1.default(y);
95
- }
96
- else if (!(x instanceof dimension_1.default) || !(y instanceof dimension_1.default)) {
82
+ x = new Dimension(x);
83
+ y = new Dimension(y);
84
+ } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) {
97
85
  throw { type: 'Argument', message: 'arguments must be numbers' };
98
86
  }
99
- return new dimension_1.default(Math.pow(x.value, y.value), x.unit);
87
+
88
+ return new Dimension(Math.pow(x.value, y.value), x.unit);
100
89
  },
101
90
  percentage: function (n) {
102
- var result = (0, math_helper_js_1.default)(function (num) { return num * 100; }, '%', n);
91
+ const result = mathHelper(num => num * 100, '%', n);
92
+
103
93
  return result;
104
94
  }
105
95
  };
106
- //# sourceMappingURL=number.js.map
@@ -1,40 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
5
- var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
6
- var javascript_1 = tslib_1.__importDefault(require("../tree/javascript"));
7
- exports.default = {
1
+ import Quoted from '../tree/quoted.js';
2
+ import Anonymous from '../tree/anonymous.js';
3
+ import JavaScript from '../tree/javascript.js';
4
+
5
+ export default {
8
6
  e: function (str) {
9
- return new quoted_1.default('"', str instanceof javascript_1.default ? str.evaluated : str.value, true);
7
+ return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true);
10
8
  },
11
9
  escape: function (str) {
12
- return new anonymous_1.default(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')
13
- .replace(/\(/g, '%28').replace(/\)/g, '%29'));
10
+ return new Anonymous(
11
+ encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')
12
+ .replace(/\(/g, '%28').replace(/\)/g, '%29'));
14
13
  },
15
14
  replace: function (string, pattern, replacement, flags) {
16
- var result = string.value;
15
+ let result = string.value;
17
16
  replacement = (replacement.type === 'Quoted') ?
18
17
  replacement.value : replacement.toCSS();
19
18
  result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);
20
- return new quoted_1.default(string.quote || '', result, string.escaped);
19
+ return new Quoted(string.quote || '', result, string.escaped);
21
20
  },
22
21
  '%': function (string /* arg, arg, ... */) {
23
- var args = Array.prototype.slice.call(arguments, 1);
24
- var result = string.value;
25
- var _loop_1 = function (i) {
22
+ const args = Array.prototype.slice.call(arguments, 1);
23
+ let result = string.value;
24
+
25
+ for (let i = 0; i < args.length; i++) {
26
26
  /* jshint loopfunc:true */
27
- result = result.replace(/%[sda]/i, function (token) {
28
- var value = ((args[i].type === 'Quoted') &&
27
+ result = result.replace(/%[sda]/i, token => {
28
+ const value = ((args[i].type === 'Quoted') &&
29
29
  token.match(/s/i)) ? args[i].value : args[i].toCSS();
30
30
  return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
31
31
  });
32
- };
33
- for (var i = 0; i < args.length; i++) {
34
- _loop_1(i);
35
32
  }
36
33
  result = result.replace(/%%/g, '%');
37
- return new quoted_1.default(string.quote || '', result, string.escaped);
34
+ return new Quoted(string.quote || '', result, string.escaped);
38
35
  }
39
36
  };
40
- //# sourceMappingURL=string.js.map
@@ -1,28 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var variable_1 = tslib_1.__importDefault(require("../tree/variable"));
5
- var variable_2 = tslib_1.__importDefault(require("../tree/variable"));
6
- var styleExpression = function (args) {
7
- var _this = this;
1
+ import Variable from '../tree/variable.js';
2
+ import Anonymous from '../tree/anonymous.js';
3
+
4
+ /** @param {*[]} args */
5
+ const styleExpression = function (args) {
8
6
  args = Array.prototype.slice.call(args);
9
- switch (args.length) {
10
- case 0: throw { type: 'Argument', message: 'one or more arguments required' };
7
+ if (args.length === 0) {
8
+ throw { type: 'Argument', message: 'one or more arguments required' };
11
9
  }
12
- var entityList = [new variable_1.default(args[0].value, this.index, this.currentFileInfo).eval(this.context)];
13
- args = entityList.map(function (a) { return a.toCSS(_this.context); }).join(this.context.compress ? ',' : ', ');
14
- return new variable_2.default("style(".concat(args, ")"));
10
+
11
+ const entityList = [new Variable(args[0].value, this.index, this.currentFileInfo).eval(this.context)];
12
+
13
+ const result = entityList.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
14
+
15
+ return new Anonymous(`style(${result})`);
15
16
  };
16
- exports.default = {
17
- style: function () {
18
- var args = [];
19
- for (var _i = 0; _i < arguments.length; _i++) {
20
- args[_i] = arguments[_i];
21
- }
17
+
18
+ export default {
19
+ /** @param {...*} args */
20
+ style: function(...args) {
22
21
  try {
23
22
  return styleExpression.call(this, args);
23
+ } catch (e) {
24
+ // When style() is used as a CSS function (e.g. @container style(--responsive: true)),
25
+ // arguments won't be valid Less variables. Return undefined to let the
26
+ // parser fall through and treat it as plain CSS.
24
27
  }
25
- catch (e) { }
26
28
  },
27
29
  };
28
- //# sourceMappingURL=style.js.map
@@ -1,86 +1,87 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
5
- var color_1 = tslib_1.__importDefault(require("../tree/color"));
6
- var expression_1 = tslib_1.__importDefault(require("../tree/expression"));
7
- var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
8
- var url_1 = tslib_1.__importDefault(require("../tree/url"));
9
- exports.default = (function () {
10
- return { 'svg-gradient': function (direction) {
11
- var stops;
12
- var gradientDirectionSvg;
13
- var gradientType = 'linear';
14
- var rectangleDimension = 'x="0" y="0" width="1" height="1"';
15
- var renderEnv = { compress: false };
16
- var returner;
17
- var directionValue = direction.toCSS(renderEnv);
18
- var i;
19
- var color;
20
- var position;
21
- var positionValue;
22
- var alpha;
23
- function throwArgumentDescriptor() {
24
- throw { type: 'Argument',
25
- message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +
26
- ' end_color [end_position] or direction, color list' };
27
- }
28
- if (arguments.length == 2) {
29
- if (arguments[1].value.length < 2) {
30
- throwArgumentDescriptor();
31
- }
32
- stops = arguments[1].value;
33
- }
34
- else if (arguments.length < 3) {
1
+ import Dimension from '../tree/dimension.js';
2
+ import Color from '../tree/color.js';
3
+ import Expression from '../tree/expression.js';
4
+ import Quoted from '../tree/quoted.js';
5
+ import URL from '../tree/url.js';
6
+
7
+ export default () => {
8
+ return { 'svg-gradient': function(direction) {
9
+ let stops;
10
+ let gradientDirectionSvg;
11
+ let gradientType = 'linear';
12
+ let rectangleDimension = 'x="0" y="0" width="1" height="1"';
13
+ const renderEnv = {compress: false};
14
+ let returner;
15
+ const directionValue = direction.toCSS(renderEnv);
16
+ let i;
17
+ let color;
18
+ let position;
19
+ let positionValue;
20
+ let alpha;
21
+
22
+ function throwArgumentDescriptor() {
23
+ throw { type: 'Argument',
24
+ message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +
25
+ ' end_color [end_position] or direction, color list' };
26
+ }
27
+
28
+ if (arguments.length == 2) {
29
+ if (arguments[1].value.length < 2) {
35
30
  throwArgumentDescriptor();
36
31
  }
37
- else {
38
- stops = Array.prototype.slice.call(arguments, 1);
32
+ stops = arguments[1].value;
33
+ } else if (arguments.length < 3) {
34
+ throwArgumentDescriptor();
35
+ } else {
36
+ stops = Array.prototype.slice.call(arguments, 1);
37
+ }
38
+
39
+ switch (directionValue) {
40
+ case 'to bottom':
41
+ gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
42
+ break;
43
+ case 'to right':
44
+ gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
45
+ break;
46
+ case 'to bottom right':
47
+ gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
48
+ break;
49
+ case 'to top right':
50
+ gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
51
+ break;
52
+ case 'ellipse':
53
+ case 'ellipse at center':
54
+ gradientType = 'radial';
55
+ gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
56
+ rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
57
+ break;
58
+ default:
59
+ throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
60
+ ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
61
+ }
62
+ returner = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><${gradientType}Gradient id="g" ${gradientDirectionSvg}>`;
63
+
64
+ for (i = 0; i < stops.length; i += 1) {
65
+ if (stops[i] instanceof Expression) {
66
+ color = stops[i].value[0];
67
+ position = stops[i].value[1];
68
+ } else {
69
+ color = stops[i];
70
+ position = undefined;
39
71
  }
40
- switch (directionValue) {
41
- case 'to bottom':
42
- gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
43
- break;
44
- case 'to right':
45
- gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
46
- break;
47
- case 'to bottom right':
48
- gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
49
- break;
50
- case 'to top right':
51
- gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
52
- break;
53
- case 'ellipse':
54
- case 'ellipse at center':
55
- gradientType = 'radial';
56
- gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
57
- rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
58
- break;
59
- default:
60
- throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
61
- ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
62
- }
63
- returner = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1 1\"><".concat(gradientType, "Gradient id=\"g\" ").concat(gradientDirectionSvg, ">");
64
- for (i = 0; i < stops.length; i += 1) {
65
- if (stops[i] instanceof expression_1.default) {
66
- color = stops[i].value[0];
67
- position = stops[i].value[1];
68
- }
69
- else {
70
- color = stops[i];
71
- position = undefined;
72
- }
73
- if (!(color instanceof color_1.default) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof dimension_1.default))) {
74
- throwArgumentDescriptor();
75
- }
76
- positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
77
- alpha = color.alpha;
78
- returner += "<stop offset=\"".concat(positionValue, "\" stop-color=\"").concat(color.toRGB(), "\"").concat(alpha < 1 ? " stop-opacity=\"".concat(alpha, "\"") : '', "/>");
72
+
73
+ if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) {
74
+ throwArgumentDescriptor();
79
75
  }
80
- returner += "</".concat(gradientType, "Gradient><rect ").concat(rectangleDimension, " fill=\"url(#g)\" /></svg>");
81
- returner = encodeURIComponent(returner);
82
- returner = "data:image/svg+xml,".concat(returner);
83
- return new url_1.default(new quoted_1.default("'".concat(returner, "'"), returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
84
- } };
85
- });
86
- //# sourceMappingURL=svg.js.map
76
+ positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
77
+ alpha = color.alpha;
78
+ returner += `<stop offset="${positionValue}" stop-color="${color.toRGB()}"${alpha < 1 ? ` stop-opacity="${alpha}"` : ''}/>`;
79
+ }
80
+ returner += `</${gradientType}Gradient><rect ${rectangleDimension} fill="url(#g)" /></svg>`;
81
+
82
+ returner = encodeURIComponent(returner);
83
+
84
+ returner = `data:image/svg+xml,${returner}`;
85
+ return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
86
+ }};
87
+ };
@@ -1,16 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var keyword_1 = tslib_1.__importDefault(require("../tree/keyword"));
5
- var detached_ruleset_1 = tslib_1.__importDefault(require("../tree/detached-ruleset"));
6
- var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
7
- var color_1 = tslib_1.__importDefault(require("../tree/color"));
8
- var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
9
- var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
10
- var url_1 = tslib_1.__importDefault(require("../tree/url"));
11
- var operation_1 = tslib_1.__importDefault(require("../tree/operation"));
12
- var isa = function (n, Type) { return (n instanceof Type) ? keyword_1.default.True : keyword_1.default.False; };
13
- var isunit = function (n, unit) {
1
+ import Keyword from '../tree/keyword.js';
2
+ import DetachedRuleset from '../tree/detached-ruleset.js';
3
+ import Dimension from '../tree/dimension.js';
4
+ import Color from '../tree/color.js';
5
+ import Quoted from '../tree/quoted.js';
6
+ import Anonymous from '../tree/anonymous.js';
7
+ import URL from '../tree/url.js';
8
+ import Operation from '../tree/operation.js';
9
+
10
+ const isa = (n, Type) => (n instanceof Type) ? Keyword.True : Keyword.False;
11
+ const isunit = (n, unit) => {
14
12
  if (unit === undefined) {
15
13
  throw { type: 'Argument', message: 'missing the required second argument to isunit.' };
16
14
  }
@@ -18,26 +16,27 @@ var isunit = function (n, unit) {
18
16
  if (typeof unit !== 'string') {
19
17
  throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };
20
18
  }
21
- return (n instanceof dimension_1.default) && n.unit.is(unit) ? keyword_1.default.True : keyword_1.default.False;
19
+ return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;
22
20
  };
23
- exports.default = {
21
+
22
+ export default {
24
23
  isruleset: function (n) {
25
- return isa(n, detached_ruleset_1.default);
24
+ return isa(n, DetachedRuleset);
26
25
  },
27
26
  iscolor: function (n) {
28
- return isa(n, color_1.default);
27
+ return isa(n, Color);
29
28
  },
30
29
  isnumber: function (n) {
31
- return isa(n, dimension_1.default);
30
+ return isa(n, Dimension);
32
31
  },
33
32
  isstring: function (n) {
34
- return isa(n, quoted_1.default);
33
+ return isa(n, Quoted);
35
34
  },
36
35
  iskeyword: function (n) {
37
- return isa(n, keyword_1.default);
36
+ return isa(n, Keyword);
38
37
  },
39
38
  isurl: function (n) {
40
- return isa(n, url_1.default);
39
+ return isa(n, URL);
41
40
  },
42
41
  ispixel: function (n) {
43
42
  return isunit(n, 'px');
@@ -48,27 +47,24 @@ exports.default = {
48
47
  isem: function (n) {
49
48
  return isunit(n, 'em');
50
49
  },
51
- isunit: isunit,
50
+ isunit,
52
51
  unit: function (val, unit) {
53
- if (!(val instanceof dimension_1.default)) {
52
+ if (!(val instanceof Dimension)) {
54
53
  throw { type: 'Argument',
55
- message: "the first argument to unit must be a number".concat(val instanceof operation_1.default ? '. Have you forgotten parenthesis?' : '') };
54
+ message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` };
56
55
  }
57
56
  if (unit) {
58
- if (unit instanceof keyword_1.default) {
57
+ if (unit instanceof Keyword) {
59
58
  unit = unit.value;
60
- }
61
- else {
59
+ } else {
62
60
  unit = unit.toCSS();
63
61
  }
64
- }
65
- else {
62
+ } else {
66
63
  unit = '';
67
64
  }
68
- return new dimension_1.default(val.value, unit);
65
+ return new Dimension(val.value, unit);
69
66
  },
70
67
  'get-unit': function (n) {
71
- return new anonymous_1.default(n.unit);
68
+ return new Anonymous(n.unit);
72
69
  }
73
70
  };
74
- //# sourceMappingURL=types.js.map