less 1.7.0 → 1.7.5

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 (109) hide show
  1. package/.grunt/grunt-contrib-jasmine/es5-shim.js +1360 -0
  2. package/.idea/jsLibraryMappings.xml +0 -1
  3. package/.idea/workspace.xml +182 -183
  4. package/.travis.yml +0 -1
  5. package/CHANGELOG.md +60 -2
  6. package/CONTRIBUTING.md +1 -1
  7. package/Gruntfile.js +12 -24
  8. package/LICENSE +0 -2
  9. package/README.md +5 -3
  10. package/benchmark/less-benchmark.js +1 -2
  11. package/bin/lessc +13 -11
  12. package/bower.json +2 -2
  13. package/build/rhino-modules.js +1 -1
  14. package/dist/less-1.7.0.js +59 -59
  15. package/dist/less-1.7.0.min.js +12 -12
  16. package/dist/less-1.7.1.js +7936 -0
  17. package/dist/less-1.7.1.min.js +16 -0
  18. package/dist/less-1.7.2.js +7938 -0
  19. package/dist/less-1.7.2.min.js +16 -0
  20. package/dist/less-1.7.3.js +7942 -0
  21. package/dist/less-1.7.3.min.js +16 -0
  22. package/dist/less-1.7.4.js +7979 -0
  23. package/dist/less-1.7.4.min.js +16 -0
  24. package/dist/less-1.7.5.js +8008 -0
  25. package/dist/less-1.7.5.min.js +16 -0
  26. package/dist/less-rhino-1.7.0.js +48 -48
  27. package/dist/less-rhino-1.7.1.js +9311 -0
  28. package/dist/less-rhino-1.7.2.js +9313 -0
  29. package/dist/less-rhino-1.7.3.js +9317 -0
  30. package/dist/less-rhino-1.7.4.js +9354 -0
  31. package/dist/less-rhino-1.7.5.js +9383 -0
  32. package/dist/lessc-rhino-1.7.0.js +2 -2
  33. package/dist/lessc-rhino-1.7.1.js +449 -0
  34. package/dist/lessc-rhino-1.7.2.js +449 -0
  35. package/dist/lessc-rhino-1.7.3.js +449 -0
  36. package/dist/lessc-rhino-1.7.4.js +449 -0
  37. package/dist/lessc-rhino-1.7.5.js +449 -0
  38. package/lib/less/browser.js +14 -9
  39. package/lib/less/env.js +2 -0
  40. package/lib/less/fs.js +10 -0
  41. package/lib/less/functions.js +41 -38
  42. package/lib/less/import-visitor.js +9 -7
  43. package/lib/less/index.js +30 -18
  44. package/lib/less/lessc_helper.js +1 -0
  45. package/lib/less/parser/parser.js.orig +1747 -0
  46. package/lib/less/parser.js +81 -40
  47. package/lib/less/rhino.js +3 -3
  48. package/lib/less/source-map-output.js +1 -1
  49. package/lib/less/to-css-visitor.js +3 -0
  50. package/lib/less/tree/anonymous.js +7 -3
  51. package/lib/less/tree/directive.js +6 -0
  52. package/lib/less/tree/element.js +6 -22
  53. package/lib/less/tree/import.js +1 -1
  54. package/lib/less/tree/mixin.js +4 -3
  55. package/lib/less/tree/quoted.js +12 -4
  56. package/lib/less/tree/rule.js +7 -4
  57. package/lib/less/tree/rule.js.orig +164 -0
  58. package/lib/less/tree/ruleset.js +27 -2
  59. package/lib/less/tree/selector.js +1 -1
  60. package/lib/less/tree.js +2 -2
  61. package/package.json +13 -12
  62. package/test/browser/less.js +7317 -6931
  63. package/test/css/comments.css +8 -0
  64. package/test/css/css-3.css +9 -0
  65. package/test/css/functions.css +8 -8
  66. package/test/css/import-inline.css +4 -1
  67. package/test/css/import.css +6 -0
  68. package/test/css/javascript.css +5 -0
  69. package/test/css/mixins-guards.css +14 -3
  70. package/test/css/mixins.css +3 -0
  71. package/test/css/property-name-interp.css +1 -0
  72. package/test/css/urls.css +6 -0
  73. package/test/index.js +1 -1
  74. package/test/less/comments.less +14 -1
  75. package/test/less/css-3.less +12 -1
  76. package/test/less/errors/color-invalid-hex-code.less +3 -0
  77. package/test/less/errors/color-invalid-hex-code.txt +4 -0
  78. package/test/less/errors/color-invalid-hex-code2.less +3 -0
  79. package/test/less/errors/color-invalid-hex-code2.txt +4 -0
  80. package/test/less/errors/import-malformed.less +1 -0
  81. package/test/less/errors/import-malformed.txt +3 -0
  82. package/test/less/errors/import-no-semi.txt +1 -1
  83. package/test/less/errors/javascript-error.less +1 -1
  84. package/test/less/errors/javascript-error.txt +2 -2
  85. package/test/less/import-inline.less +1 -0
  86. package/test/less/import.less +8 -1
  87. package/test/less/javascript.less +9 -0
  88. package/test/less/mixins-guards.less +17 -3
  89. package/test/less/mixins.less +4 -0
  90. package/test/less/property-name-interp.less +4 -1
  91. package/test/less/property-name-interp.less.orig +59 -0
  92. package/test/less/urls.less +12 -0
  93. package/test/less-test.js +7 -8
  94. package/test/modify-vars.js +17 -0
  95. package/test/sourcemaps/basic.json +1 -1
  96. package/tmp/browser/test-runner-main.html +4 -0
  97. package/tmp/less.js +8295 -0
  98. package/build/README.md +0 -51
  99. package/tmp/browser/test-postProcessor.html +0 -59
  100. package/tmp/browser/test-runner-browser.html +0 -59
  101. package/tmp/browser/test-runner-errors.html +0 -267
  102. package/tmp/browser/test-runner-global-vars.html +0 -59
  103. package/tmp/browser/test-runner-legacy.html +0 -59
  104. package/tmp/browser/test-runner-modify-vars.html +0 -59
  105. package/tmp/browser/test-runner-no-js-errors.html +0 -59
  106. package/tmp/browser/test-runner-production.html +0 -55
  107. package/tmp/browser/test-runner-relative-urls.html +0 -59
  108. package/tmp/browser/test-runner-rootpath-relative.html +0 -59
  109. package/tmp/browser/test-runner-rootpath.html +0 -59
@@ -1,5 +1,5 @@
1
- /* LESS.js v1.7.0 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */
2
-
1
+ /* LESS.js v1.7.0 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */
2
+
3
3
  /*global name:true, less, loadStyleSheet, os */
4
4
 
5
5
  function formatError(ctx, options) {
@@ -0,0 +1,449 @@
1
+ /* Less.js v1.7.1 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */
2
+
3
+ /*global name:true, less, loadStyleSheet, os */
4
+
5
+ function formatError(ctx, options) {
6
+ options = options || {};
7
+
8
+ var message = "";
9
+ var extract = ctx.extract;
10
+ var error = [];
11
+
12
+ // var stylize = options.color ? require('./lessc_helper').stylize : function (str) { return str; };
13
+ var stylize = function (str) { return str; };
14
+
15
+ // only output a stack if it isn't a less error
16
+ if (ctx.stack && !ctx.type) { return stylize(ctx.stack, 'red'); }
17
+
18
+ if (!ctx.hasOwnProperty('index') || !extract) {
19
+ return ctx.stack || ctx.message;
20
+ }
21
+
22
+ if (typeof(extract[0]) === 'string') {
23
+ error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));
24
+ }
25
+
26
+ if (typeof(extract[1]) === 'string') {
27
+ var errorTxt = ctx.line + ' ';
28
+ if (extract[1]) {
29
+ errorTxt += extract[1].slice(0, ctx.column) +
30
+ stylize(stylize(stylize(extract[1][ctx.column], 'bold') +
31
+ extract[1].slice(ctx.column + 1), 'red'), 'inverse');
32
+ }
33
+ error.push(errorTxt);
34
+ }
35
+
36
+ if (typeof(extract[2]) === 'string') {
37
+ error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));
38
+ }
39
+ error = error.join('\n') + stylize('', 'reset') + '\n';
40
+
41
+ message += stylize(ctx.type + 'Error: ' + ctx.message, 'red');
42
+ if (ctx.filename) {
43
+ message += stylize(' in ', 'red') + ctx.filename +
44
+ stylize(' on line ' + ctx.line + ', column ' + (ctx.column + 1) + ':', 'grey');
45
+ }
46
+
47
+ message += '\n' + error;
48
+
49
+ if (ctx.callLine) {
50
+ message += stylize('from ', 'red') + (ctx.filename || '') + '/n';
51
+ message += stylize(ctx.callLine, 'grey') + ' ' + ctx.callExtract + '/n';
52
+ }
53
+
54
+ return message;
55
+ }
56
+
57
+ function writeError(ctx, options) {
58
+ options = options || {};
59
+ if (options.silent) { return; }
60
+ var message = formatError(ctx, options);
61
+ throw new Error(message);
62
+ }
63
+
64
+ function loadStyleSheet(sheet, callback, reload, remaining) {
65
+ var endOfPath = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')),
66
+ sheetName = name.slice(0, endOfPath + 1) + sheet.href,
67
+ contents = sheet.contents || {},
68
+ input = readFile(sheetName);
69
+
70
+ input = input.replace(/^\xEF\xBB\xBF/, '');
71
+
72
+ contents[sheetName] = input;
73
+
74
+ var parser = new less.Parser({
75
+ paths: [sheet.href.replace(/[\w\.-]+$/, '')],
76
+ contents: contents
77
+ });
78
+ parser.parse(input, function (e, root) {
79
+ if (e) {
80
+ return writeError(e);
81
+ }
82
+ try {
83
+ callback(e, root, input, sheet, { local: false, lastModified: 0, remaining: remaining }, sheetName);
84
+ } catch(e) {
85
+ writeError(e);
86
+ }
87
+ });
88
+ }
89
+
90
+ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
91
+
92
+ var href = file;
93
+ if (currentFileInfo && currentFileInfo.currentDirectory && !/^\//.test(file)) {
94
+ href = less.modules.path.join(currentFileInfo.currentDirectory, file);
95
+ }
96
+
97
+ var path = less.modules.path.dirname(href);
98
+
99
+ var newFileInfo = {
100
+ currentDirectory: path + '/',
101
+ filename: href
102
+ };
103
+
104
+ if (currentFileInfo) {
105
+ newFileInfo.entryPath = currentFileInfo.entryPath;
106
+ newFileInfo.rootpath = currentFileInfo.rootpath;
107
+ newFileInfo.rootFilename = currentFileInfo.rootFilename;
108
+ newFileInfo.relativeUrls = currentFileInfo.relativeUrls;
109
+ } else {
110
+ newFileInfo.entryPath = path;
111
+ newFileInfo.rootpath = less.rootpath || path;
112
+ newFileInfo.rootFilename = href;
113
+ newFileInfo.relativeUrls = env.relativeUrls;
114
+ }
115
+
116
+ var j = file.lastIndexOf('/');
117
+ if(newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {
118
+ var relativeSubDirectory = file.slice(0, j+1);
119
+ newFileInfo.rootpath = newFileInfo.rootpath + relativeSubDirectory; // append (sub|sup) directory path of imported file
120
+ }
121
+ newFileInfo.currentDirectory = path;
122
+ newFileInfo.filename = href;
123
+
124
+ var data = null;
125
+ try {
126
+ data = readFile(href);
127
+ } catch (e) {
128
+ callback({ type: 'File', message: "'" + less.modules.path.basename(href) + "' wasn't found" });
129
+ return;
130
+ }
131
+
132
+ try {
133
+ callback(null, data, href, newFileInfo, { lastModified: 0 });
134
+ } catch (e) {
135
+ callback(e, null, href);
136
+ }
137
+ };
138
+
139
+
140
+ function writeFile(filename, content) {
141
+ var fstream = new java.io.FileWriter(filename);
142
+ var out = new java.io.BufferedWriter(fstream);
143
+ out.write(content);
144
+ out.close();
145
+ }
146
+
147
+ // Command line integration via Rhino
148
+ (function (args) {
149
+
150
+ var options = {
151
+ depends: false,
152
+ compress: false,
153
+ cleancss: false,
154
+ max_line_len: -1,
155
+ optimization: 1,
156
+ silent: false,
157
+ verbose: false,
158
+ lint: false,
159
+ paths: [],
160
+ color: true,
161
+ strictImports: false,
162
+ rootpath: '',
163
+ relativeUrls: false,
164
+ ieCompat: true,
165
+ strictMath: false,
166
+ strictUnits: false
167
+ };
168
+ var continueProcessing = true,
169
+ currentErrorcode;
170
+
171
+ var checkArgFunc = function(arg, option) {
172
+ if (!option) {
173
+ print(arg + " option requires a parameter");
174
+ continueProcessing = false;
175
+ return false;
176
+ }
177
+ return true;
178
+ };
179
+
180
+ var checkBooleanArg = function(arg) {
181
+ var onOff = /^((on|t|true|y|yes)|(off|f|false|n|no))$/i.exec(arg);
182
+ if (!onOff) {
183
+ print(" unable to parse "+arg+" as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");
184
+ continueProcessing = false;
185
+ return false;
186
+ }
187
+ return Boolean(onOff[2]);
188
+ };
189
+
190
+ var warningMessages = "";
191
+ var sourceMapFileInline = false;
192
+
193
+ args = args.filter(function (arg) {
194
+ var match = arg.match(/^-I(.+)$/);
195
+
196
+ if (match) {
197
+ options.paths.push(match[1]);
198
+ return false;
199
+ }
200
+
201
+ match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);
202
+ if (match) { arg = match[1]; } // was (?:=([^\s]*)), check!
203
+ else { return arg; }
204
+
205
+ switch (arg) {
206
+ case 'v':
207
+ case 'version':
208
+ console.log("lessc " + less.version.join('.') + " (Less Compiler) [JavaScript]");
209
+ continueProcessing = false;
210
+ break;
211
+ case 'verbose':
212
+ options.verbose = true;
213
+ break;
214
+ case 's':
215
+ case 'silent':
216
+ options.silent = true;
217
+ break;
218
+ case 'l':
219
+ case 'lint':
220
+ options.lint = true;
221
+ break;
222
+ case 'strict-imports':
223
+ options.strictImports = true;
224
+ break;
225
+ case 'h':
226
+ case 'help':
227
+ //TODO
228
+ // require('../lib/less/lessc_helper').printUsage();
229
+ continueProcessing = false;
230
+ break;
231
+ case 'x':
232
+ case 'compress':
233
+ options.compress = true;
234
+ break;
235
+ case 'M':
236
+ case 'depends':
237
+ options.depends = true;
238
+ break;
239
+ case 'yui-compress':
240
+ warningMessages += "yui-compress option has been removed. assuming clean-css.";
241
+ options.cleancss = true;
242
+ break;
243
+ case 'clean-css':
244
+ options.cleancss = true;
245
+ break;
246
+ case 'max-line-len':
247
+ if (checkArgFunc(arg, match[2])) {
248
+ options.maxLineLen = parseInt(match[2], 10);
249
+ if (options.maxLineLen <= 0) {
250
+ options.maxLineLen = -1;
251
+ }
252
+ }
253
+ break;
254
+ case 'no-color':
255
+ options.color = false;
256
+ break;
257
+ case 'no-ie-compat':
258
+ options.ieCompat = false;
259
+ break;
260
+ case 'no-js':
261
+ options.javascriptEnabled = false;
262
+ break;
263
+ case 'include-path':
264
+ if (checkArgFunc(arg, match[2])) {
265
+ options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
266
+ .map(function(p) {
267
+ if (p) {
268
+ // return path.resolve(process.cwd(), p);
269
+ return p;
270
+ }
271
+ });
272
+ }
273
+ break;
274
+ case 'O0': options.optimization = 0; break;
275
+ case 'O1': options.optimization = 1; break;
276
+ case 'O2': options.optimization = 2; break;
277
+ case 'line-numbers':
278
+ if (checkArgFunc(arg, match[2])) {
279
+ options.dumpLineNumbers = match[2];
280
+ }
281
+ break;
282
+ case 'source-map':
283
+ if (!match[2]) {
284
+ options.sourceMap = true;
285
+ } else {
286
+ options.sourceMap = match[2];
287
+ }
288
+ break;
289
+ case 'source-map-rootpath':
290
+ if (checkArgFunc(arg, match[2])) {
291
+ options.sourceMapRootpath = match[2];
292
+ }
293
+ break;
294
+ case 'source-map-basepath':
295
+ if (checkArgFunc(arg, match[2])) {
296
+ options.sourceMapBasepath = match[2];
297
+ }
298
+ break;
299
+ case 'source-map-map-inline':
300
+ sourceMapFileInline = true;
301
+ options.sourceMap = true;
302
+ break;
303
+ case 'source-map-less-inline':
304
+ options.outputSourceFiles = true;
305
+ break;
306
+ case 'source-map-url':
307
+ if (checkArgFunc(arg, match[2])) {
308
+ options.sourceMapURL = match[2];
309
+ }
310
+ break;
311
+ case 'source-map-output-map-file':
312
+ if (checkArgFunc(arg, match[2])) {
313
+ options.writeSourceMap = function(sourceMapContent) {
314
+ writeFile(match[2], sourceMapContent);
315
+ };
316
+ }
317
+ break;
318
+ case 'rp':
319
+ case 'rootpath':
320
+ if (checkArgFunc(arg, match[2])) {
321
+ options.rootpath = match[2].replace(/\\/g, '/');
322
+ }
323
+ break;
324
+ case "ru":
325
+ case "relative-urls":
326
+ options.relativeUrls = true;
327
+ break;
328
+ case "sm":
329
+ case "strict-math":
330
+ if (checkArgFunc(arg, match[2])) {
331
+ options.strictMath = checkBooleanArg(match[2]);
332
+ }
333
+ break;
334
+ case "su":
335
+ case "strict-units":
336
+ if (checkArgFunc(arg, match[2])) {
337
+ options.strictUnits = checkBooleanArg(match[2]);
338
+ }
339
+ break;
340
+ default:
341
+ console.log('invalid option ' + arg);
342
+ continueProcessing = false;
343
+ }
344
+ });
345
+
346
+ if (!continueProcessing) {
347
+ return;
348
+ }
349
+
350
+ var name = args[0];
351
+ if (name && name != '-') {
352
+ // name = path.resolve(process.cwd(), name);
353
+ }
354
+ var output = args[1];
355
+ var outputbase = args[1];
356
+ if (output) {
357
+ options.sourceMapOutputFilename = output;
358
+ // output = path.resolve(process.cwd(), output);
359
+ if (warningMessages) {
360
+ console.log(warningMessages);
361
+ }
362
+ }
363
+
364
+ // options.sourceMapBasepath = process.cwd();
365
+ // options.sourceMapBasepath = '';
366
+
367
+ if (options.sourceMap === true) {
368
+ console.log("output: " + output);
369
+ if (!output && !sourceMapFileInline) {
370
+ console.log("the sourcemap option only has an optional filename if the css filename is given");
371
+ return;
372
+ }
373
+ options.sourceMapFullFilename = options.sourceMapOutputFilename + ".map";
374
+ options.sourceMap = less.modules.path.basename(options.sourceMapFullFilename);
375
+ } else if (options.sourceMap) {
376
+ options.sourceMapOutputFilename = options.sourceMap;
377
+ }
378
+
379
+
380
+ if (!name) {
381
+ console.log("lessc: no inout files");
382
+ console.log("");
383
+ // TODO
384
+ // require('../lib/less/lessc_helper').printUsage();
385
+ currentErrorcode = 1;
386
+ return;
387
+ }
388
+
389
+ // var ensureDirectory = function (filepath) {
390
+ // var dir = path.dirname(filepath),
391
+ // cmd,
392
+ // existsSync = fs.existsSync || path.existsSync;
393
+ // if (!existsSync(dir)) {
394
+ // if (mkdirp === undefined) {
395
+ // try {mkdirp = require('mkdirp');}
396
+ // catch(e) { mkdirp = null; }
397
+ // }
398
+ // cmd = mkdirp && mkdirp.sync || fs.mkdirSync;
399
+ // cmd(dir);
400
+ // }
401
+ // };
402
+
403
+ if (options.depends) {
404
+ if (!outputbase) {
405
+ console.log("option --depends requires an output path to be specified");
406
+ return;
407
+ }
408
+ console.log(outputbase + ": ");
409
+ }
410
+
411
+ if (!name) {
412
+ console.log('No files present in the fileset');
413
+ quit(1);
414
+ }
415
+
416
+ var input = null;
417
+ try {
418
+ input = readFile(name, 'utf-8');
419
+
420
+ } catch (e) {
421
+ console.log('lesscss: couldn\'t open file ' + name);
422
+ quit(1);
423
+ }
424
+
425
+ options.filename = name;
426
+ var result;
427
+ try {
428
+ var parser = new less.Parser(options);
429
+ parser.parse(input, function (e, root) {
430
+ if (e) {
431
+ writeError(e, options);
432
+ quit(1);
433
+ } else {
434
+ result = root.toCSS(options);
435
+ if (output) {
436
+ writeFile(output, result);
437
+ console.log("Written to " + output);
438
+ } else {
439
+ print(result);
440
+ }
441
+ quit(0);
442
+ }
443
+ });
444
+ }
445
+ catch(e) {
446
+ writeError(e, options);
447
+ quit(1);
448
+ }
449
+ }(arguments));