less 3.0.0-pre.2 → 3.0.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 (205) hide show
  1. package/.eslintrc.json +88 -0
  2. package/.github/stale.yml +17 -0
  3. package/.project +17 -0
  4. package/.settings/org.eclipse.buildship.core.prefs +2 -0
  5. package/.travis.yml +22 -3
  6. package/.vscode/launch.json +14 -0
  7. package/CHANGELOG.md +27 -0
  8. package/Gruntfile.js +191 -86
  9. package/README.md +5 -7
  10. package/appveyor.yml +9 -10
  11. package/bin/lessc +37 -50
  12. package/dist/less.js +1357 -1269
  13. package/dist/less.min.js +7 -7
  14. package/lib/less/contexts.js +20 -16
  15. package/lib/less/default-options.js +65 -0
  16. package/lib/less/environment/abstract-file-manager.js +13 -14
  17. package/lib/less/environment/abstract-plugin-loader.js +45 -36
  18. package/lib/less/environment/environment.js +5 -0
  19. package/lib/less/functions/boolean.js +15 -0
  20. package/lib/less/functions/color.js +54 -24
  21. package/lib/less/functions/data-uri.js +5 -2
  22. package/lib/less/functions/function-registry.js +1 -1
  23. package/lib/less/functions/index.js +2 -1
  24. package/lib/less/functions/number.js +2 -2
  25. package/lib/less/functions/string.js +2 -2
  26. package/lib/less/functions/svg.js +4 -4
  27. package/lib/less/import-manager.js +41 -29
  28. package/lib/less/index.js +28 -3
  29. package/lib/less/less-error.js +112 -13
  30. package/lib/less/parse.js +18 -15
  31. package/lib/less/parser/parser-input.js +4 -4
  32. package/lib/less/parser/parser.js +208 -114
  33. package/lib/less/plugin-manager.js +8 -33
  34. package/lib/less/render.js +6 -2
  35. package/lib/less/source-map-builder.js +3 -0
  36. package/lib/less/source-map-output.js +13 -8
  37. package/lib/less/transform-tree.js +2 -2
  38. package/lib/less/tree/anonymous.js +4 -1
  39. package/lib/less/tree/atrule.js +7 -6
  40. package/lib/less/tree/call.js +25 -3
  41. package/lib/less/tree/color.js +2 -2
  42. package/lib/less/tree/debug-info.js +1 -1
  43. package/lib/less/tree/declaration.js +6 -5
  44. package/lib/less/tree/dimension.js +4 -1
  45. package/lib/less/tree/extend.js +2 -2
  46. package/lib/less/tree/import.js +17 -9
  47. package/lib/less/tree/index.js +3 -7
  48. package/lib/less/tree/js-eval-node.js +1 -1
  49. package/lib/less/tree/media.js +3 -14
  50. package/lib/less/tree/mixin-definition.js +3 -3
  51. package/lib/less/tree/node.js +9 -6
  52. package/lib/less/tree/operation.js +1 -1
  53. package/lib/less/tree/property.js +70 -0
  54. package/lib/less/tree/quoted.js +11 -10
  55. package/lib/less/tree/ruleset.js +115 -71
  56. package/lib/less/tree/selector.js +38 -23
  57. package/lib/less/tree/unit.js +1 -1
  58. package/lib/less/tree/value.js +6 -1
  59. package/lib/less/tree/{ruleset-call.js → variable-call.js} +5 -5
  60. package/lib/less/tree/variable.js +6 -6
  61. package/lib/less/utils.js +40 -0
  62. package/lib/less/visitors/extend-visitor.js +14 -14
  63. package/lib/less/visitors/import-visitor.js +2 -2
  64. package/lib/less/visitors/join-selector-visitor.js +1 -1
  65. package/lib/less/visitors/to-css-visitor.js +51 -84
  66. package/lib/less/visitors/visitor.js +15 -15
  67. package/lib/less-browser/bootstrap.js +21 -5
  68. package/lib/less-browser/cache.js +2 -2
  69. package/lib/less-browser/error-reporting.js +5 -5
  70. package/lib/less-browser/file-manager.js +27 -35
  71. package/lib/less-browser/index.js +12 -17
  72. package/lib/less-browser/plugin-loader.js +8 -45
  73. package/lib/less-browser/utils.js +1 -1
  74. package/lib/less-node/file-manager.js +99 -69
  75. package/lib/less-node/fs.js +1 -1
  76. package/lib/less-node/image-size.js +2 -2
  77. package/lib/less-node/index.js +7 -57
  78. package/lib/less-node/lessc-helper.js +38 -38
  79. package/lib/less-node/plugin-loader.js +18 -79
  80. package/lib/less-node/url-file-manager.js +1 -1
  81. package/lib/less-rhino/index.js +29 -44
  82. package/package.json +16 -9
  83. package/test/browser/common.js +54 -18
  84. package/test/browser/css/plugin/plugin.css +3 -0
  85. package/test/browser/jasmine-jsreporter.js +4 -4
  86. package/test/browser/less/plugin/plugin.js +7 -0
  87. package/test/browser/less/plugin/plugin.less +4 -0
  88. package/test/browser/less.js +11685 -13
  89. package/test/browser/runner-browser-options.js +6 -1
  90. package/test/browser/runner-filemanagerPlugin-options.js +3 -2
  91. package/test/browser/runner-legacy-options.js +2 -1
  92. package/test/browser/runner-main-options.js +0 -1
  93. package/test/browser/runner-modify-vars-spec.js +2 -2
  94. package/test/browser/test-runner-template.tmpl +38 -14
  95. package/test/copy-bom.js +1 -1
  96. package/test/css/calc.css +5 -0
  97. package/test/css/comments2.css +1 -1
  98. package/test/css/compression/compression.css +1 -1
  99. package/test/css/css-grid.css +11 -0
  100. package/test/css/debug/linenumbers-all.css +0 -1
  101. package/test/css/debug/linenumbers-comments.css +0 -1
  102. package/test/css/debug/linenumbers-mediaquery.css +0 -1
  103. package/test/css/functions.css +16 -3
  104. package/test/css/import-module.css +9 -0
  105. package/test/css/import.css +0 -1
  106. package/test/css/legacy/legacy.css +1 -1
  107. package/test/css/merge.css +5 -4
  108. package/test/css/plugin-module.css +1 -0
  109. package/test/css/plugin.css +20 -0
  110. package/test/css/property-accessors.css +49 -0
  111. package/test/css/{css.css → strict-math/css.css} +0 -0
  112. package/test/css/{mixins-args.css → strict-math/mixins-args.css} +0 -0
  113. package/test/css/{parens.css → strict-math/parens.css} +0 -0
  114. package/test/import-module/one/1.less +3 -0
  115. package/test/import-module/one/two/2.less +3 -0
  116. package/test/import-module/one/two/three/3.less +3 -0
  117. package/test/import-module/package.json +11 -0
  118. package/test/index.js +55 -49
  119. package/test/less/calc.less +7 -0
  120. package/test/less/css-grid.less +15 -0
  121. package/test/less/detached-rulesets.less +2 -2
  122. package/test/less/errors/color-invalid-hex-code.less +1 -0
  123. package/test/less/errors/color-invalid-hex-code.txt +1 -1
  124. package/test/less/errors/color-invalid-hex-code2.less +1 -0
  125. package/test/less/errors/color-invalid-hex-code2.txt +1 -1
  126. package/test/less/errors/import-missing.txt +1 -1
  127. package/test/less/errors/plugin/plugin-error-2.js +5 -0
  128. package/test/less/errors/plugin/plugin-error-3.js +5 -0
  129. package/test/less/errors/plugin/plugin-error.js +1 -0
  130. package/test/less/errors/plugin-1.less +1 -0
  131. package/test/less/errors/plugin-1.txt +2 -0
  132. package/test/less/errors/plugin-2.less +1 -0
  133. package/test/less/errors/plugin-2.txt +5 -0
  134. package/test/less/errors/plugin-3.less +1 -0
  135. package/test/less/errors/plugin-3.txt +5 -0
  136. package/test/less/functions.less +18 -0
  137. package/test/less/import-module.less +3 -0
  138. package/test/less/import.less +0 -2
  139. package/test/less/legacy/legacy.less +1 -1
  140. package/test/less/media.less +2 -2
  141. package/test/less/merge.less +6 -3
  142. package/test/less/plugin/plugin-collection.js +9 -0
  143. package/test/less/plugin/plugin-local.js +2 -2
  144. package/test/less/plugin/plugin-scope1.js +3 -0
  145. package/test/less/plugin/plugin-scope2.js +3 -0
  146. package/test/less/plugin/plugin-simple.js +7 -0
  147. package/test/less/plugin/plugin-tree-nodes.js +33 -31
  148. package/test/less/plugin-module.less +7 -0
  149. package/test/less/plugin.less +33 -3
  150. package/test/less/property-accessors.less +67 -0
  151. package/test/less/root-registry/file.less +1 -0
  152. package/test/less/root-registry/root.less +3 -0
  153. package/test/less/{css.less → strict-math/css.less} +0 -0
  154. package/test/less/{mixins-args.less → strict-math/mixins-args.less} +0 -0
  155. package/test/less/{parens.less → strict-math/parens.less} +0 -0
  156. package/test/less-bom/calc.less +7 -0
  157. package/test/less-bom/css-grid.less +15 -0
  158. package/test/less-bom/detached-rulesets.less +2 -2
  159. package/test/less-bom/errors/color-invalid-hex-code.less +1 -0
  160. package/test/less-bom/errors/color-invalid-hex-code.txt +1 -1
  161. package/test/less-bom/errors/color-invalid-hex-code2.less +1 -0
  162. package/test/less-bom/errors/color-invalid-hex-code2.txt +1 -1
  163. package/test/less-bom/errors/import-missing.txt +1 -1
  164. package/test/less-bom/errors/plugin/plugin-error-2.js +5 -0
  165. package/test/less-bom/errors/plugin/plugin-error-3.js +5 -0
  166. package/test/less-bom/errors/plugin/plugin-error.js +1 -0
  167. package/test/less-bom/errors/plugin-1.less +1 -0
  168. package/test/less-bom/errors/plugin-1.txt +2 -0
  169. package/test/less-bom/errors/plugin-2.less +1 -0
  170. package/test/less-bom/errors/plugin-2.txt +5 -0
  171. package/test/less-bom/errors/plugin-3.less +1 -0
  172. package/test/less-bom/errors/plugin-3.txt +5 -0
  173. package/test/less-bom/functions.less +18 -0
  174. package/test/less-bom/import-module.less +3 -0
  175. package/test/less-bom/import.less +0 -2
  176. package/test/less-bom/legacy/legacy.less +1 -1
  177. package/test/less-bom/media.less +2 -2
  178. package/test/less-bom/merge.less +6 -3
  179. package/test/less-bom/plugin/plugin-collection.js +9 -0
  180. package/test/less-bom/plugin/plugin-local.js +2 -2
  181. package/test/less-bom/plugin/plugin-scope1.js +3 -0
  182. package/test/less-bom/plugin/plugin-scope2.js +3 -0
  183. package/test/less-bom/plugin/plugin-simple.js +7 -0
  184. package/test/less-bom/plugin/plugin-tree-nodes.js +33 -31
  185. package/test/less-bom/plugin-module.less +7 -0
  186. package/test/less-bom/plugin.less +33 -3
  187. package/test/less-bom/property-accessors.less +67 -0
  188. package/test/less-bom/root-registry/file.less +1 -0
  189. package/test/less-bom/root-registry/root.less +3 -0
  190. package/test/less-bom/{css.less → strict-math/css.less} +0 -0
  191. package/test/less-bom/{mixins-args.less → strict-math/mixins-args.less} +0 -0
  192. package/test/less-bom/{parens.less → strict-math/parens.less} +0 -0
  193. package/test/less-test.js +75 -17
  194. package/test/modify-vars.js +1 -1
  195. package/test/plugins/visitor/index.js +1 -1
  196. package/.jscsrc +0 -73
  197. package/.jshintrc +0 -11
  198. package/lib/less/tree/alpha.js +0 -28
  199. package/lib/less/tree/directive.js +0 -12
  200. package/lib/less/tree/rule.js +0 -12
  201. package/test/less/errors/functions-2-alpha.less +0 -2
  202. package/test/less/errors/functions-2-alpha.txt +0 -3
  203. package/test/less-bom/errors/functions-2-alpha.less +0 -2
  204. package/test/less-bom/errors/functions-2-alpha.txt +0 -3
  205. package/test/sourcemaps/maps/import-map.map +0 -1
package/bin/lessc CHANGED
@@ -3,6 +3,7 @@
3
3
  var path = require('path'),
4
4
  fs = require('../lib/less-node/fs'),
5
5
  os = require("os"),
6
+ utils = require('../lib/less/utils'),
6
7
  errno,
7
8
  mkdirp;
8
9
 
@@ -13,43 +14,17 @@ try {
13
14
  }
14
15
 
15
16
  var less = require('../lib/less-node'),
16
- pluginLoader = new less.PluginLoader(less),
17
+ pluginManager = new less.PluginManager(less),
18
+ fileManager = new less.FileManager(),
17
19
  plugins = [],
18
20
  queuePlugins = [],
19
21
  args = process.argv.slice(1),
20
22
  silent = false,
21
23
  verbose = false,
22
- options = {
23
- depends: false,
24
- compress: false,
25
- max_line_len: -1,
26
- lint: false,
27
- paths: [],
28
- color: true,
29
- strictImports: false,
30
- insecure: false,
31
- rootpath: '',
32
- relativeUrls: false,
33
- ieCompat: true,
34
- strictMath: false,
35
- strictUnits: false,
36
- globalVars: null,
37
- modifyVars: null,
38
- urlArgs: '',
39
- plugins: plugins
40
- };
41
-
42
- if (less.options) {
43
- for (var i = 0, keys = Object.keys(options); i < keys.length; i++) {
44
- if (!less.options[keys[i]]) {
45
- less.options[keys[i]] = options[keys[i]];
46
- }
47
- }
48
24
  options = less.options;
49
- }
50
- else {
51
- less.options = options;
52
- }
25
+
26
+ options.plugins = plugins;
27
+ options.reUsePluginManager = true;
53
28
 
54
29
  var sourceMapOptions = {};
55
30
  var continueProcessing = true;
@@ -103,7 +78,7 @@ var sourceMapFileInline = false;
103
78
 
104
79
  function printUsage() {
105
80
  less.lesscHelper.printUsage();
106
- pluginLoader.printUsage(plugins);
81
+ pluginManager.Loader.printUsage(plugins);
107
82
  continueProcessing = false;
108
83
  }
109
84
  function render() {
@@ -133,10 +108,14 @@ function render() {
133
108
  return;
134
109
  }
135
110
  // its in the same directory, so always just the basename
136
- sourceMapOptions.sourceMapOutputFilename = path.basename(output);
137
- sourceMapOptions.sourceMapFullFilename = output + ".map";
111
+ if (output) {
112
+ sourceMapOptions.sourceMapOutputFilename = path.basename(output);
113
+ sourceMapOptions.sourceMapFullFilename = output + ".map";
114
+ }
138
115
  // its in the same directory, so always just the basename
139
- sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
116
+ if ('sourceMapFullFilename' in sourceMapOptions) {
117
+ sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
118
+ }
140
119
  } else if (options.sourceMap && !sourceMapFileInline) {
141
120
  var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename),
142
121
  mapDir = path.dirname(mapFilename),
@@ -156,12 +135,13 @@ function render() {
156
135
  }
157
136
 
158
137
  if (sourceMapOptions.sourceMapRootpath === undefined) {
159
- var pathToMap = path.dirname(sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename || '.'),
138
+ var pathToMap = path.dirname((sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename) || '.'),
160
139
  pathToInput = path.dirname(sourceMapOptions.sourceMapInputFilename || '.');
161
140
  sourceMapOptions.sourceMapRootpath = path.relative(pathToMap, pathToInput);
162
141
  }
163
142
 
164
- if (! input) {
143
+
144
+ if (!input) {
165
145
  console.error("lessc: no input files");
166
146
  console.error("");
167
147
  printUsage();
@@ -176,7 +156,7 @@ function render() {
176
156
  if (!existsSync(dir)) {
177
157
  if (mkdirp === undefined) {
178
158
  try {mkdirp = require('mkdirp');}
179
- catch(e) { mkdirp = null; }
159
+ catch (e) { mkdirp = null; }
180
160
  }
181
161
  cmd = mkdirp && mkdirp.sync || fs.mkdirSync;
182
162
  cmd(dir);
@@ -310,7 +290,11 @@ function render() {
310
290
  }
311
291
  },
312
292
  function(err) {
313
- less.writeError(err, options);
293
+ if (!options.silent) {
294
+ console.error(err.toString({
295
+ stylize: options.color && less.lesscHelper.stylize
296
+ }));
297
+ }
314
298
  process.exitCode = 1;
315
299
  });
316
300
  };
@@ -348,18 +332,18 @@ function processPluginQueue() {
348
332
  }
349
333
  }
350
334
  queuePlugins.forEach(function(queue) {
351
- pluginLoader.tryLoadPlugin(queue.name, function(err, data) {
352
- if (err) {
353
- pluginError(queue.name);
354
- }
355
- else {
335
+ var context = utils.clone(options);
336
+ pluginManager.Loader.loadPlugin(queue.name, process.cwd(), context, less.environment, fileManager)
337
+ .then(function(data) {
356
338
  pluginFinished({
357
339
  fileContent: data.contents,
358
340
  filename: data.filename,
359
341
  options: queue.options
360
342
  });
361
- }
362
- });
343
+ })
344
+ .catch(function() {
345
+ pluginError(queue.name);
346
+ });
363
347
  });
364
348
  }
365
349
 
@@ -427,14 +411,15 @@ function processPluginQueue() {
427
411
  case 'no-color':
428
412
  options.color = false;
429
413
  break;
430
- case 'no-ie-compat':
431
- options.ieCompat = false;
414
+ case 'ie-compat':
415
+ options.ieCompat = true;
432
416
  break;
433
- case 'inline-js':
417
+ case 'js':
434
418
  options.javascriptEnabled = true;
435
419
  break;
436
420
  case 'no-js':
437
- console.error('The "--no-js" argument is deprecated. Use "--inline-js" to enable inline JavaScript.');
421
+ console.error('The "--no-js" argument is deprecated, as inline JavaScript ' +
422
+ 'is disabled by default. Use "--js" to enable inline JavaScript (not recommended).');
438
423
  break;
439
424
  case 'include-path':
440
425
  if (checkArgFunc(arg, match[2])) {
@@ -470,10 +455,12 @@ function processPluginQueue() {
470
455
  sourceMapOptions.sourceMapBasepath = match[2];
471
456
  }
472
457
  break;
458
+ case 'source-map-inline':
473
459
  case 'source-map-map-inline':
474
460
  sourceMapFileInline = true;
475
461
  options.sourceMap = true;
476
462
  break;
463
+ case 'source-map-include-source':
477
464
  case 'source-map-less-inline':
478
465
  sourceMapOptions.outputSourceFiles = true;
479
466
  break;