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,62 +1,70 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = (function () {
4
- var // Less input string
5
- input;
6
- var // current chunk
7
- j;
8
- var // holds state for backtracking
9
- saveStack = [];
10
- var // furthest index the parser has gone to
11
- furthest;
12
- var // if this is furthest we got to, this is the probably cause
13
- furthestPossibleErrorMessage;
14
- var // chunkified input
15
- chunks;
16
- var // current chunk
17
- current;
18
- var // index of current chunk, in `input`
19
- currentPos;
20
- var parserInput = {};
21
- var CHARCODE_SPACE = 32;
22
- var CHARCODE_TAB = 9;
23
- var CHARCODE_LF = 10;
24
- var CHARCODE_CR = 13;
25
- var CHARCODE_PLUS = 43;
26
- var CHARCODE_COMMA = 44;
27
- var CHARCODE_FORWARD_SLASH = 47;
28
- var CHARCODE_9 = 57;
1
+ export default () => {
2
+ let // Less input string
3
+ input;
4
+
5
+ let // current chunk
6
+ j;
7
+
8
+ const // holds state for backtracking
9
+ saveStack = [];
10
+
11
+ let // furthest index the parser has gone to
12
+ furthest;
13
+
14
+ let // if this is furthest we got to, this is the probably cause
15
+ furthestPossibleErrorMessage;
16
+
17
+ let // chunkified input
18
+ chunks;
19
+
20
+ let // current chunk
21
+ current;
22
+
23
+ let // index of current chunk, in `input`
24
+ currentPos;
25
+
26
+ const parserInput = {};
27
+ const CHARCODE_SPACE = 32;
28
+ const CHARCODE_TAB = 9;
29
+ const CHARCODE_LF = 10;
30
+ const CHARCODE_CR = 13;
31
+ const CHARCODE_PLUS = 43;
32
+ const CHARCODE_COMMA = 44;
33
+ const CHARCODE_FORWARD_SLASH = 47;
34
+ const CHARCODE_9 = 57;
35
+
29
36
  function skipWhitespace(length) {
30
- var oldi = parserInput.i;
31
- var oldj = j;
32
- var curr = parserInput.i - currentPos;
33
- var endIndex = parserInput.i + current.length - curr;
34
- var mem = (parserInput.i += length);
35
- var inp = input;
36
- var c;
37
- var nextChar;
38
- var comment;
37
+ const oldi = parserInput.i;
38
+ const oldj = j;
39
+ const curr = parserInput.i - currentPos;
40
+ const endIndex = parserInput.i + current.length - curr;
41
+ const mem = (parserInput.i += length);
42
+ const inp = input;
43
+ let c;
44
+ let nextChar;
45
+ let comment;
46
+
39
47
  for (; parserInput.i < endIndex; parserInput.i++) {
40
48
  c = inp.charCodeAt(parserInput.i);
49
+
41
50
  if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) {
42
51
  nextChar = inp.charAt(parserInput.i + 1);
43
52
  if (nextChar === '/') {
44
- comment = { index: parserInput.i, isLineComment: true };
45
- var nextNewLine = inp.indexOf('\n', parserInput.i + 2);
53
+ comment = {index: parserInput.i, isLineComment: true};
54
+ let nextNewLine = inp.indexOf('\n', parserInput.i + 2);
46
55
  if (nextNewLine < 0) {
47
56
  nextNewLine = endIndex;
48
57
  }
49
58
  parserInput.i = nextNewLine;
50
- comment.text = inp.substr(comment.index, parserInput.i - comment.index);
59
+ comment.text = inp.slice(comment.index, parserInput.i);
51
60
  parserInput.commentStore.push(comment);
52
61
  continue;
53
- }
54
- else if (nextChar === '*') {
55
- var nextStarSlash = inp.indexOf('*/', parserInput.i + 2);
62
+ } else if (nextChar === '*') {
63
+ const nextStarSlash = inp.indexOf('*/', parserInput.i + 2);
56
64
  if (nextStarSlash >= 0) {
57
65
  comment = {
58
66
  index: parserInput.i,
59
- text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i),
67
+ text: inp.slice(parserInput.i, nextStarSlash + 2),
60
68
  isLineComment: false
61
69
  };
62
70
  parserInput.i += comment.text.length - 1;
@@ -66,12 +74,15 @@ exports.default = (function () {
66
74
  }
67
75
  break;
68
76
  }
77
+
69
78
  if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) {
70
79
  break;
71
80
  }
72
81
  }
82
+
73
83
  current = current.slice(length + parserInput.i - mem + curr);
74
84
  currentPos = parserInput.i;
85
+
75
86
  if (!current.length) {
76
87
  if (j < chunks.length - 1) {
77
88
  current = chunks[++j];
@@ -80,80 +91,95 @@ exports.default = (function () {
80
91
  }
81
92
  parserInput.finished = true;
82
93
  }
94
+
83
95
  return oldi !== parserInput.i || oldj !== j;
84
96
  }
85
- parserInput.save = function () {
97
+
98
+ parserInput.save = () => {
86
99
  currentPos = parserInput.i;
87
- saveStack.push({ current: current, i: parserInput.i, j: j });
100
+ saveStack.push( { current, i: parserInput.i, j });
88
101
  };
89
- parserInput.restore = function (possibleErrorMessage) {
102
+ parserInput.restore = possibleErrorMessage => {
103
+
90
104
  if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) {
91
105
  furthest = parserInput.i;
92
106
  furthestPossibleErrorMessage = possibleErrorMessage;
93
107
  }
94
- var state = saveStack.pop();
108
+ const state = saveStack.pop();
95
109
  current = state.current;
96
110
  currentPos = parserInput.i = state.i;
97
111
  j = state.j;
98
112
  };
99
- parserInput.forget = function () {
113
+ parserInput.forget = () => {
100
114
  saveStack.pop();
101
115
  };
102
- parserInput.isWhitespace = function (offset) {
103
- var pos = parserInput.i + (offset || 0);
104
- var code = input.charCodeAt(pos);
116
+ parserInput.isWhitespace = offset => {
117
+ const pos = parserInput.i + (offset || 0);
118
+ const code = input.charCodeAt(pos);
105
119
  return (code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF);
106
120
  };
121
+
107
122
  // Specialization of $(tok)
108
- parserInput.$re = function (tok) {
123
+ parserInput.$re = tok => {
109
124
  if (parserInput.i > currentPos) {
110
125
  current = current.slice(parserInput.i - currentPos);
111
126
  currentPos = parserInput.i;
112
127
  }
113
- var m = tok.exec(current);
128
+
129
+ const m = tok.exec(current);
114
130
  if (!m) {
115
131
  return null;
116
132
  }
133
+
117
134
  skipWhitespace(m[0].length);
118
135
  if (typeof m === 'string') {
119
136
  return m;
120
137
  }
138
+
121
139
  return m.length === 1 ? m[0] : m;
122
140
  };
123
- parserInput.$char = function (tok) {
141
+
142
+ parserInput.$char = tok => {
124
143
  if (input.charAt(parserInput.i) !== tok) {
125
144
  return null;
126
145
  }
127
146
  skipWhitespace(1);
128
147
  return tok;
129
148
  };
130
- parserInput.$peekChar = function (tok) {
149
+
150
+ parserInput.$peekChar = tok => {
131
151
  if (input.charAt(parserInput.i) !== tok) {
132
152
  return null;
133
153
  }
134
154
  return tok;
135
155
  };
136
- parserInput.$str = function (tok) {
137
- var tokLength = tok.length;
156
+
157
+ parserInput.$str = tok => {
158
+ const tokLength = tok.length;
159
+
138
160
  // https://jsperf.com/string-startswith/21
139
- for (var i = 0; i < tokLength; i++) {
161
+ for (let i = 0; i < tokLength; i++) {
140
162
  if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {
141
163
  return null;
142
164
  }
143
165
  }
166
+
144
167
  skipWhitespace(tokLength);
145
168
  return tok;
146
169
  };
147
- parserInput.$quoted = function (loc) {
148
- var pos = loc || parserInput.i;
149
- var startChar = input.charAt(pos);
170
+
171
+ parserInput.$quoted = loc => {
172
+ const pos = loc || parserInput.i;
173
+ const startChar = input.charAt(pos);
174
+
150
175
  if (startChar !== '\'' && startChar !== '"') {
151
176
  return;
152
177
  }
153
- var length = input.length;
154
- var currentPosition = pos;
155
- for (var i = 1; i + currentPosition < length; i++) {
156
- var nextChar = input.charAt(i + currentPosition);
178
+ const length = input.length;
179
+ const currentPosition = pos;
180
+
181
+ for (let i = 1; i + currentPosition < length; i++) {
182
+ const nextChar = input.charAt(i + currentPosition);
157
183
  switch (nextChar) {
158
184
  case '\\':
159
185
  i++;
@@ -162,10 +188,10 @@ exports.default = (function () {
162
188
  case '\n':
163
189
  break;
164
190
  case startChar: {
165
- var str = input.substr(currentPosition, i + 1);
191
+ const str = input.slice(currentPosition, currentPosition + i + 1);
166
192
  if (!loc && loc !== 0) {
167
193
  skipWhitespace(i + 1);
168
- return str;
194
+ return str
169
195
  }
170
196
  return [startChar, str];
171
197
  }
@@ -174,33 +200,35 @@ exports.default = (function () {
174
200
  }
175
201
  return null;
176
202
  };
203
+
177
204
  /**
178
205
  * Permissive parsing. Ignores everything except matching {} [] () and quotes
179
206
  * until matching token (outside of blocks)
180
207
  */
181
- parserInput.$parseUntil = function (tok) {
182
- var quote = '';
183
- var returnVal = null;
184
- var inComment = false;
185
- var blockDepth = 0;
186
- var blockStack = [];
187
- var parseGroups = [];
188
- var length = input.length;
189
- var startPos = parserInput.i;
190
- var lastPos = parserInput.i;
191
- var i = parserInput.i;
192
- var loop = true;
193
- var testChar;
208
+ parserInput.$parseUntil = tok => {
209
+ let quote = '';
210
+ let returnVal = null;
211
+ let inComment = false;
212
+ let blockDepth = 0;
213
+ const blockStack = [];
214
+ const parseGroups = [];
215
+ const length = input.length;
216
+ const startPos = parserInput.i;
217
+ let lastPos = parserInput.i;
218
+ let i = parserInput.i;
219
+ let loop = true;
220
+ let testChar;
221
+
194
222
  if (typeof tok === 'string') {
195
- testChar = function (char) { return char === tok; };
196
- }
197
- else {
198
- testChar = function (char) { return tok.test(char); };
223
+ testChar = char => char === tok
224
+ } else {
225
+ testChar = char => tok.test(char)
199
226
  }
227
+
200
228
  do {
201
- var nextChar = input.charAt(i);
229
+ let nextChar = input.charAt(i);
202
230
  if (blockDepth === 0 && testChar(nextChar)) {
203
- returnVal = input.substr(lastPos, i - lastPos);
231
+ returnVal = input.slice(lastPos, i);
204
232
  if (returnVal) {
205
233
  parseGroups.push(returnVal);
206
234
  }
@@ -209,9 +237,8 @@ exports.default = (function () {
209
237
  }
210
238
  returnVal = parseGroups;
211
239
  skipWhitespace(i - startPos);
212
- loop = false;
213
- }
214
- else {
240
+ loop = false
241
+ } else {
215
242
  if (inComment) {
216
243
  if (nextChar === '*' &&
217
244
  input.charAt(i + 1) === '/') {
@@ -226,7 +253,7 @@ exports.default = (function () {
226
253
  case '\\':
227
254
  i++;
228
255
  nextChar = input.charAt(i);
229
- parseGroups.push(input.substr(lastPos, i - lastPos + 1));
256
+ parseGroups.push(input.slice(lastPos, i + 1));
230
257
  lastPos = i + 1;
231
258
  break;
232
259
  case '/':
@@ -240,7 +267,7 @@ exports.default = (function () {
240
267
  case '"':
241
268
  quote = parserInput.$quoted(i);
242
269
  if (quote) {
243
- parseGroups.push(input.substr(lastPos, i - lastPos), quote);
270
+ parseGroups.push(input.slice(lastPos, i), quote);
244
271
  i += quote[1].length - 1;
245
272
  lastPos = i + 1;
246
273
  }
@@ -265,11 +292,10 @@ exports.default = (function () {
265
292
  case '}':
266
293
  case ')':
267
294
  case ']': {
268
- var expected = blockStack.pop();
295
+ const expected = blockStack.pop();
269
296
  if (nextChar === expected) {
270
297
  blockDepth--;
271
- }
272
- else {
298
+ } else {
273
299
  // move the parser to the error and return expected
274
300
  skipWhitespace(i - startPos);
275
301
  returnVal = expected;
@@ -283,60 +309,72 @@ exports.default = (function () {
283
309
  }
284
310
  }
285
311
  } while (loop);
312
+
286
313
  return returnVal ? returnVal : null;
287
- };
314
+ }
315
+
288
316
  parserInput.autoCommentAbsorb = true;
289
317
  parserInput.commentStore = [];
290
318
  parserInput.finished = false;
319
+
291
320
  // Same as $(), but don't change the state of the parser,
292
321
  // just return the match.
293
- parserInput.peek = function (tok) {
322
+ parserInput.peek = tok => {
294
323
  if (typeof tok === 'string') {
295
324
  // https://jsperf.com/string-startswith/21
296
- for (var i = 0; i < tok.length; i++) {
325
+ for (let i = 0; i < tok.length; i++) {
297
326
  if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {
298
327
  return false;
299
328
  }
300
329
  }
301
330
  return true;
302
- }
303
- else {
331
+ } else {
304
332
  return tok.test(current);
305
333
  }
306
334
  };
335
+
307
336
  // Specialization of peek()
308
337
  // TODO remove or change some currentChar calls to peekChar
309
- parserInput.peekChar = function (tok) { return input.charAt(parserInput.i) === tok; };
310
- parserInput.currentChar = function () { return input.charAt(parserInput.i); };
311
- parserInput.prevChar = function () { return input.charAt(parserInput.i - 1); };
312
- parserInput.getInput = function () { return input; };
313
- parserInput.peekNotNumeric = function () {
314
- var c = input.charCodeAt(parserInput.i);
338
+ parserInput.peekChar = tok => input.charAt(parserInput.i) === tok;
339
+
340
+ parserInput.currentChar = () => input.charAt(parserInput.i);
341
+
342
+ parserInput.prevChar = () => input.charAt(parserInput.i - 1);
343
+
344
+ parserInput.getInput = () => input;
345
+
346
+ parserInput.peekNotNumeric = () => {
347
+ const c = input.charCodeAt(parserInput.i);
315
348
  // Is the first char of the dimension 0-9, '.', '+' or '-'
316
349
  return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA;
317
350
  };
318
- parserInput.start = function (str) {
351
+
352
+ parserInput.start = (str) => {
319
353
  input = str;
320
354
  parserInput.i = j = currentPos = furthest = 0;
355
+
321
356
  chunks = [str];
322
357
  current = chunks[0];
358
+
323
359
  skipWhitespace(0);
324
360
  };
325
- parserInput.end = function () {
326
- var message;
327
- var isFinished = parserInput.i >= input.length;
361
+
362
+ parserInput.end = () => {
363
+ let message;
364
+ const isFinished = parserInput.i >= input.length;
365
+
328
366
  if (parserInput.i < furthest) {
329
367
  message = furthestPossibleErrorMessage;
330
368
  parserInput.i = furthest;
331
369
  }
332
370
  return {
333
- isFinished: isFinished,
371
+ isFinished,
334
372
  furthest: parserInput.i,
335
373
  furthestPossibleErrorMessage: message,
336
374
  furthestReachedEnd: parserInput.i >= input.length - 1,
337
375
  furthestChar: input[parserInput.i]
338
376
  };
339
377
  };
378
+
340
379
  return parserInput;
341
- });
342
- //# sourceMappingURL=parser-input.js.map
380
+ };