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,17 +1,15 @@
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 utils = tslib_1.__importStar(require("../utils"));
6
- var defaultFunc = {
1
+ import Keyword from '../tree/keyword.js';
2
+ import * as utils from '../utils.js';
3
+
4
+ const defaultFunc = {
7
5
  eval: function () {
8
- var v = this.value_;
9
- var e = this.error_;
6
+ const v = this.value_;
7
+ const e = this.error_;
10
8
  if (e) {
11
9
  throw e;
12
10
  }
13
11
  if (!utils.isNullOrUndefined(v)) {
14
- return v ? keyword_1.default.True : keyword_1.default.False;
12
+ return v ? Keyword.True : Keyword.False;
15
13
  }
16
14
  },
17
15
  value: function (v) {
@@ -24,5 +22,5 @@ var defaultFunc = {
24
22
  this.value_ = this.error_ = null;
25
23
  }
26
24
  };
27
- exports.default = defaultFunc;
28
- //# sourceMappingURL=default.js.map
25
+
26
+ export default defaultFunc;
@@ -1,54 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var expression_1 = tslib_1.__importDefault(require("../tree/expression"));
5
- var functionCaller = /** @class */ (function () {
6
- function functionCaller(name, context, index, currentFileInfo) {
1
+ import Expression from '../tree/expression.js';
2
+
3
+ class functionCaller {
4
+ constructor(name, context, index, currentFileInfo) {
7
5
  this.name = name.toLowerCase();
8
6
  this.index = index;
9
7
  this.context = context;
10
8
  this.currentFileInfo = currentFileInfo;
9
+
11
10
  this.func = context.frames[0].functionRegistry.get(this.name);
12
11
  }
13
- functionCaller.prototype.isValid = function () {
12
+
13
+ isValid() {
14
14
  return Boolean(this.func);
15
- };
16
- functionCaller.prototype.call = function (args) {
17
- var _this = this;
15
+ }
16
+
17
+ call(args) {
18
18
  if (!(Array.isArray(args))) {
19
19
  args = [args];
20
20
  }
21
- var evalArgs = this.func.evalArgs;
21
+ const evalArgs = this.func.evalArgs;
22
22
  if (evalArgs !== false) {
23
- args = args.map(function (a) { return a.eval(_this.context); });
23
+ args = args.map(a => a.eval(this.context));
24
24
  }
25
- var commentFilter = function (item) { return !(item.type === 'Comment'); };
25
+ const commentFilter = item => !(item.type === 'Comment');
26
+
26
27
  // This code is terrible and should be replaced as per this issue...
27
28
  // https://github.com/less/less.js/issues/2477
28
29
  args = args
29
30
  .filter(commentFilter)
30
- .map(function (item) {
31
- if (item.type === 'Expression') {
32
- var subNodes = item.value.filter(commentFilter);
33
- if (subNodes.length === 1) {
34
- // https://github.com/less/less.js/issues/3616
35
- if (item.parens && subNodes[0].op === '/') {
36
- return item;
31
+ .map(item => {
32
+ if (item.type === 'Expression') {
33
+ const subNodes = item.value.filter(commentFilter);
34
+ if (subNodes.length === 1) {
35
+ // https://github.com/less/less.js/issues/3616
36
+ if (item.parens && subNodes[0].op === '/') {
37
+ return item;
38
+ }
39
+ return subNodes[0];
40
+ } else {
41
+ return new Expression(subNodes);
37
42
  }
38
- return subNodes[0];
39
- }
40
- else {
41
- return new expression_1.default(subNodes);
42
43
  }
43
- }
44
- return item;
45
- });
44
+ return item;
45
+ });
46
+
46
47
  if (evalArgs === false) {
47
- return this.func.apply(this, tslib_1.__spreadArray([this.context], args, false));
48
+ return this.func(this.context, ...args);
48
49
  }
49
- return this.func.apply(this, args);
50
- };
51
- return functionCaller;
52
- }());
53
- exports.default = functionCaller;
54
- //# sourceMappingURL=function-caller.js.map
50
+
51
+ return this.func(...args);
52
+ }
53
+ }
54
+
55
+ export default functionCaller;
@@ -1,37 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function makeRegistry(base) {
1
+ function makeRegistry( base ) {
4
2
  return {
5
3
  _data: {},
6
- add: function (name, func) {
4
+ add: function(name, func) {
7
5
  // precautionary case conversion, as later querying of
8
6
  // the registry by function-caller uses lower case as well.
9
7
  name = name.toLowerCase();
8
+
10
9
  // eslint-disable-next-line no-prototype-builtins
11
10
  if (this._data.hasOwnProperty(name)) {
12
11
  // TODO warn
13
12
  }
14
13
  this._data[name] = func;
15
14
  },
16
- addMultiple: function (functions) {
17
- var _this = this;
18
- Object.keys(functions).forEach(function (name) {
19
- _this.add(name, functions[name]);
20
- });
15
+ addMultiple: function(functions) {
16
+ Object.keys(functions).forEach(
17
+ name => {
18
+ this.add(name, functions[name]);
19
+ });
21
20
  },
22
- get: function (name) {
23
- return this._data[name] || (base && base.get(name));
21
+ get: function(name) {
22
+ return this._data[name] || ( base && base.get( name ));
24
23
  },
25
- getLocalFunctions: function () {
24
+ getLocalFunctions: function() {
26
25
  return this._data;
27
26
  },
28
- inherit: function () {
29
- return makeRegistry(this);
27
+ inherit: function() {
28
+ return makeRegistry( this );
30
29
  },
31
- create: function (base) {
30
+ create: function(base) {
32
31
  return makeRegistry(base);
33
32
  }
34
33
  };
35
34
  }
36
- exports.default = makeRegistry(null);
37
- //# sourceMappingURL=function-registry.js.map
35
+
36
+ export default makeRegistry( null );
@@ -1,35 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var function_registry_1 = tslib_1.__importDefault(require("./function-registry"));
5
- var function_caller_1 = tslib_1.__importDefault(require("./function-caller"));
6
- var boolean_1 = tslib_1.__importDefault(require("./boolean"));
7
- var default_1 = tslib_1.__importDefault(require("./default"));
8
- var color_1 = tslib_1.__importDefault(require("./color"));
9
- var color_blending_1 = tslib_1.__importDefault(require("./color-blending"));
10
- var data_uri_1 = tslib_1.__importDefault(require("./data-uri"));
11
- var list_1 = tslib_1.__importDefault(require("./list"));
12
- var math_1 = tslib_1.__importDefault(require("./math"));
13
- var number_1 = tslib_1.__importDefault(require("./number"));
14
- var string_1 = tslib_1.__importDefault(require("./string"));
15
- var svg_1 = tslib_1.__importDefault(require("./svg"));
16
- var types_1 = tslib_1.__importDefault(require("./types"));
17
- var style_1 = tslib_1.__importDefault(require("./style"));
18
- exports.default = (function (environment) {
19
- var functions = { functionRegistry: function_registry_1.default, functionCaller: function_caller_1.default };
1
+ import functionRegistry from './function-registry.js';
2
+ import functionCaller from './function-caller.js';
3
+
4
+ import boolean from './boolean.js';
5
+ import defaultFunc from './default.js';
6
+ import color from './color.js';
7
+ import colorBlending from './color-blending.js';
8
+ import dataUri from './data-uri.js';
9
+ import list from './list.js';
10
+ import math from './math.js';
11
+ import number from './number.js';
12
+ import string from './string.js';
13
+ import svg from './svg.js';
14
+ import types from './types.js';
15
+ import style from './style.js';
16
+
17
+ export default environment => {
18
+ const functions = { functionRegistry, functionCaller };
19
+
20
20
  // register functions
21
- function_registry_1.default.addMultiple(boolean_1.default);
22
- function_registry_1.default.add('default', default_1.default.eval.bind(default_1.default));
23
- function_registry_1.default.addMultiple(color_1.default);
24
- function_registry_1.default.addMultiple(color_blending_1.default);
25
- function_registry_1.default.addMultiple((0, data_uri_1.default)(environment));
26
- function_registry_1.default.addMultiple(list_1.default);
27
- function_registry_1.default.addMultiple(math_1.default);
28
- function_registry_1.default.addMultiple(number_1.default);
29
- function_registry_1.default.addMultiple(string_1.default);
30
- function_registry_1.default.addMultiple((0, svg_1.default)(environment));
31
- function_registry_1.default.addMultiple(types_1.default);
32
- function_registry_1.default.addMultiple(style_1.default);
21
+ functionRegistry.addMultiple(boolean);
22
+ functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));
23
+ functionRegistry.addMultiple(color);
24
+ functionRegistry.addMultiple(colorBlending);
25
+ functionRegistry.addMultiple(dataUri(environment));
26
+ functionRegistry.addMultiple(list);
27
+ functionRegistry.addMultiple(math);
28
+ functionRegistry.addMultiple(number);
29
+ functionRegistry.addMultiple(string);
30
+ functionRegistry.addMultiple(svg(environment));
31
+ functionRegistry.addMultiple(types);
32
+ functionRegistry.addMultiple(style);
33
+
33
34
  return functions;
34
- });
35
- //# sourceMappingURL=index.js.map
35
+ };
@@ -1,58 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var comment_1 = tslib_1.__importDefault(require("../tree/comment"));
5
- var node_1 = tslib_1.__importDefault(require("../tree/node"));
6
- var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
7
- var declaration_1 = tslib_1.__importDefault(require("../tree/declaration"));
8
- var expression_1 = tslib_1.__importDefault(require("../tree/expression"));
9
- var ruleset_1 = tslib_1.__importDefault(require("../tree/ruleset"));
10
- var selector_1 = tslib_1.__importDefault(require("../tree/selector"));
11
- var element_1 = tslib_1.__importDefault(require("../tree/element"));
12
- var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
13
- var value_1 = tslib_1.__importDefault(require("../tree/value"));
14
- var getItemsFromNode = function (node) {
1
+ import Comment from '../tree/comment.js';
2
+ import Node from '../tree/node.js';
3
+ import Dimension from '../tree/dimension.js';
4
+ import Declaration from '../tree/declaration.js';
5
+ import Expression from '../tree/expression.js';
6
+ import Ruleset from '../tree/ruleset.js';
7
+ import Selector from '../tree/selector.js';
8
+ import Element from '../tree/element.js';
9
+ import Quote from '../tree/quoted.js';
10
+ import Value from '../tree/value.js';
11
+
12
+ const getItemsFromNode = node => {
15
13
  // handle non-array values as an array of length 1
16
14
  // return 'undefined' if index is invalid
17
- var items = Array.isArray(node.value) ?
15
+ const items = Array.isArray(node.value) ?
18
16
  node.value : Array(node);
17
+
19
18
  return items;
20
19
  };
21
- exports.default = {
22
- _SELF: function (n) {
20
+
21
+ export default {
22
+ _SELF: function(n) {
23
23
  return n;
24
24
  },
25
- '~': function () {
26
- var expr = [];
27
- for (var _i = 0; _i < arguments.length; _i++) {
28
- expr[_i] = arguments[_i];
29
- }
25
+ '~': function(...expr) {
30
26
  if (expr.length === 1) {
31
27
  return expr[0];
32
28
  }
33
- return new value_1.default(expr);
29
+ return new Value(expr);
34
30
  },
35
- extract: function (values, index) {
31
+ extract: function(values, index) {
36
32
  // (1-based index)
37
33
  index = index.value - 1;
34
+
38
35
  return getItemsFromNode(values)[index];
39
36
  },
40
- length: function (values) {
41
- return new dimension_1.default(getItemsFromNode(values).length);
37
+ length: function(values) {
38
+ return new Dimension(getItemsFromNode(values).length);
42
39
  },
43
40
  /**
44
41
  * Creates a Less list of incremental values.
45
42
  * Modeled after Lodash's range function, also exists natively in PHP
46
- *
43
+ *
47
44
  * @param {Dimension} [start=1]
48
45
  * @param {Dimension} end - e.g. 10 or 10px - unit is added to output
49
- * @param {Dimension} [step=1]
46
+ * @param {Dimension} [step=1]
50
47
  */
51
- range: function (start, end, step) {
52
- var from;
53
- var to;
54
- var stepValue = 1;
55
- var list = [];
48
+ range: function(start, end, step) {
49
+ let from;
50
+ let to;
51
+ let stepValue = 1;
52
+ const list = [];
56
53
  if (end) {
57
54
  to = end;
58
55
  from = start.value;
@@ -64,82 +61,98 @@ exports.default = {
64
61
  from = 1;
65
62
  to = start;
66
63
  }
67
- for (var i = from; i <= to.value; i += stepValue) {
68
- list.push(new dimension_1.default(i, to.unit));
64
+
65
+ for (let i = from; i <= to.value; i += stepValue) {
66
+ list.push(new Dimension(i, to.unit));
69
67
  }
70
- return new expression_1.default(list);
68
+
69
+ return new Expression(list);
71
70
  },
72
- each: function (list, rs) {
73
- var _this = this;
74
- var rules = [];
75
- var newRules;
76
- var iterator;
77
- var tryEval = function (val) {
78
- if (val instanceof node_1.default) {
79
- return val.eval(_this.context);
71
+ each: function(list, rs) {
72
+ const rules = [];
73
+ let newRules;
74
+ let iterator;
75
+
76
+ const tryEval = val => {
77
+ if (val instanceof Node) {
78
+ return val.eval(this.context);
80
79
  }
81
80
  return val;
82
81
  };
83
- if (list.value && !(list instanceof quoted_1.default)) {
82
+
83
+ if (list.value && !(list instanceof Quote)) {
84
84
  if (Array.isArray(list.value)) {
85
85
  iterator = list.value.map(tryEval);
86
- }
87
- else {
86
+ } else {
88
87
  iterator = [tryEval(list.value)];
89
88
  }
90
- }
91
- else if (list.ruleset) {
89
+ } else if (list.ruleset) {
92
90
  iterator = tryEval(list.ruleset).rules;
93
- }
94
- else if (list.rules) {
91
+ } else if (list.rules) {
95
92
  iterator = list.rules.map(tryEval);
96
- }
97
- else if (Array.isArray(list)) {
93
+ } else if (Array.isArray(list)) {
98
94
  iterator = list.map(tryEval);
99
- }
100
- else {
95
+ } else {
101
96
  iterator = [tryEval(list)];
102
97
  }
103
- var valueName = '@value';
104
- var keyName = '@key';
105
- var indexName = '@index';
98
+
99
+ let valueName = '@value';
100
+ let keyName = '@key';
101
+ let indexName = '@index';
102
+
106
103
  if (rs.params) {
107
104
  valueName = rs.params[0] && rs.params[0].name;
108
105
  keyName = rs.params[1] && rs.params[1].name;
109
106
  indexName = rs.params[2] && rs.params[2].name;
110
107
  rs = rs.rules;
111
- }
112
- else {
108
+ } else {
113
109
  rs = rs.ruleset;
114
110
  }
115
- for (var i = 0; i < iterator.length; i++) {
116
- var key = void 0;
117
- var value = void 0;
118
- var item = iterator[i];
119
- if (item instanceof declaration_1.default) {
111
+
112
+ for (let i = 0; i < iterator.length; i++) {
113
+ let key;
114
+ let value;
115
+ const item = iterator[i];
116
+ if (item instanceof Declaration) {
120
117
  key = typeof item.name === 'string' ? item.name : item.name[0].value;
121
118
  value = item.value;
122
- }
123
- else {
124
- key = new dimension_1.default(i + 1);
119
+ } else {
120
+ key = new Dimension(i + 1);
125
121
  value = item;
126
122
  }
127
- if (item instanceof comment_1.default) {
123
+
124
+ if (item instanceof Comment) {
128
125
  continue;
129
126
  }
127
+
130
128
  newRules = rs.rules.slice(0);
131
129
  if (valueName) {
132
- newRules.push(new declaration_1.default(valueName, value, false, false, this.index, this.currentFileInfo));
130
+ newRules.push(new Declaration(valueName,
131
+ value,
132
+ false, false, this.index, this.currentFileInfo));
133
133
  }
134
134
  if (indexName) {
135
- newRules.push(new declaration_1.default(indexName, new dimension_1.default(i + 1), false, false, this.index, this.currentFileInfo));
135
+ newRules.push(new Declaration(indexName,
136
+ new Dimension(i + 1),
137
+ false, false, this.index, this.currentFileInfo));
136
138
  }
137
139
  if (keyName) {
138
- newRules.push(new declaration_1.default(keyName, key, false, false, this.index, this.currentFileInfo));
140
+ newRules.push(new Declaration(keyName,
141
+ key,
142
+ false, false, this.index, this.currentFileInfo));
139
143
  }
140
- rules.push(new ruleset_1.default([new (selector_1.default)([new element_1.default('', '&')])], newRules, rs.strictImports, rs.visibilityInfo()));
144
+
145
+ rules.push(new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
146
+ newRules,
147
+ rs.strictImports,
148
+ rs.visibilityInfo()
149
+ ));
141
150
  }
142
- return new ruleset_1.default([new (selector_1.default)([new element_1.default('', '&')])], rules, rs.strictImports, rs.visibilityInfo()).eval(this.context);
151
+
152
+ return new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
153
+ rules,
154
+ rs.strictImports,
155
+ rs.visibilityInfo()
156
+ ).eval(this.context);
143
157
  }
144
158
  };
145
- //# sourceMappingURL=list.js.map
@@ -1,18 +1,15 @@
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 MathHelper = function (fn, unit, n) {
6
- if (!(n instanceof dimension_1.default)) {
1
+ import Dimension from '../tree/dimension.js';
2
+
3
+ const MathHelper = (fn, unit, n) => {
4
+ if (!(n instanceof Dimension)) {
7
5
  throw { type: 'Argument', message: 'argument must be a number' };
8
6
  }
9
7
  if (unit === null) {
10
8
  unit = n.unit;
11
- }
12
- else {
9
+ } else {
13
10
  n = n.unify();
14
11
  }
15
- return new dimension_1.default(fn(parseFloat(n.value)), unit);
12
+ return new Dimension(fn(parseFloat(n.value)), unit);
16
13
  };
17
- exports.default = MathHelper;
18
- //# sourceMappingURL=math-helper.js.map
14
+
15
+ export default MathHelper;
@@ -1,29 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js"));
5
- var mathFunctions = {
1
+ import mathHelper from './math-helper.js';
2
+
3
+ const mathFunctions = {
6
4
  // name, unit
7
- ceil: null,
5
+ ceil: null,
8
6
  floor: null,
9
- sqrt: null,
10
- abs: null,
11
- tan: '',
12
- sin: '',
13
- cos: '',
14
- atan: 'rad',
15
- asin: 'rad',
16
- acos: 'rad'
7
+ sqrt: null,
8
+ abs: null,
9
+ tan: '',
10
+ sin: '',
11
+ cos: '',
12
+ atan: 'rad',
13
+ asin: 'rad',
14
+ acos: 'rad'
17
15
  };
18
- for (var f in mathFunctions) {
16
+
17
+ for (const f in mathFunctions) {
19
18
  // eslint-disable-next-line no-prototype-builtins
20
19
  if (mathFunctions.hasOwnProperty(f)) {
21
- mathFunctions[f] = math_helper_js_1.default.bind(null, Math[f], mathFunctions[f]);
20
+ mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);
22
21
  }
23
22
  }
24
- mathFunctions.round = function (n, f) {
25
- var fraction = typeof f === 'undefined' ? 0 : f.value;
26
- return (0, math_helper_js_1.default)(function (num) { return num.toFixed(fraction); }, null, n);
23
+
24
+ mathFunctions.round = (n, f) => {
25
+ const fraction = typeof f === 'undefined' ? 0 : f.value;
26
+ return mathHelper(num => num.toFixed(fraction), null, n);
27
27
  };
28
- exports.default = mathFunctions;
29
- //# sourceMappingURL=math.js.map
28
+
29
+ export default mathFunctions;