less 1.7.4 → 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 (47) hide show
  1. package/.idea/jsLibraryMappings.xml +0 -1
  2. package/.idea/workspace.xml +160 -202
  3. package/CHANGELOG.md +13 -0
  4. package/Gruntfile.js +0 -12
  5. package/README.md +53 -53
  6. package/bin/lessc +4 -1
  7. package/bower.json +2 -2
  8. package/dist/less-1.7.4.js +59 -59
  9. package/dist/less-1.7.4.min.js +12 -12
  10. package/dist/less-1.7.5.js +8008 -0
  11. package/dist/less-1.7.5.min.js +16 -0
  12. package/dist/less-rhino-1.7.4.js +48 -48
  13. package/dist/less-rhino-1.7.5.js +9383 -0
  14. package/dist/lessc-rhino-1.7.4.js +2 -2
  15. package/dist/lessc-rhino-1.7.5.js +449 -0
  16. package/lib/less/functions.js +8 -1
  17. package/lib/less/import-visitor.js +2 -2
  18. package/lib/less/index.js +3 -3
  19. package/lib/less/parser/parser.js.orig +1747 -0
  20. package/lib/less/parser.js +27 -1
  21. package/lib/less/tree/directive.js +4 -1
  22. package/lib/less/tree/element.js +6 -22
  23. package/lib/less/tree/rule.js +7 -4
  24. package/lib/less/tree/rule.js.orig +164 -0
  25. package/lib/less/tree/ruleset.js +8 -1
  26. package/lib/less/tree/selector.js +1 -1
  27. package/package.json +6 -6
  28. package/test/browser/less.js +7275 -6947
  29. package/test/css/comments.css +8 -0
  30. package/test/css/css-3.css +6 -0
  31. package/test/css/import.css +5 -0
  32. package/test/css/mixins.css +3 -0
  33. package/test/css/property-name-interp.css +1 -0
  34. package/test/css/urls.css +1 -0
  35. package/test/less/comments.less +14 -1
  36. package/test/less/css-3.less +7 -0
  37. package/test/less/errors/import-malformed.less +1 -1
  38. package/test/less/errors/import-malformed.txt +3 -3
  39. package/test/less/import.less +8 -2
  40. package/test/less/mixins.less +1 -0
  41. package/test/less/property-name-interp.less +4 -1
  42. package/test/less/property-name-interp.less.orig +59 -0
  43. package/test/less/urls.less +2 -1
  44. package/test/modify-vars.js +17 -0
  45. package/tmp/browser/test-runner-main.html +4 -0
  46. package/tmp/less.js +8295 -0
  47. package/build/README.md +0 -53
@@ -1,5 +1,5 @@
1
- /* Less.js v1.7.4 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */
2
-
1
+ /* Less.js v1.7.4 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.5 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));
@@ -422,6 +422,13 @@ tree.functions = {
422
422
  filePath = mimetype;
423
423
  }
424
424
 
425
+ var fragmentStart = filePath.indexOf('#');
426
+ var fragment = '';
427
+ if (fragmentStart!==-1) {
428
+ fragment = filePath.slice(fragmentStart);
429
+ filePath = filePath.slice(0, fragmentStart);
430
+ }
431
+
425
432
  if (this.env.isPathRelative(filePath)) {
426
433
  if (this.currentFileInfo.relativeUrls) {
427
434
  filePath = path.join(this.currentFileInfo.currentDirectory, filePath);
@@ -470,7 +477,7 @@ tree.functions = {
470
477
  buf = useBase64 ? buf.toString('base64')
471
478
  : encodeURIComponent(buf);
472
479
 
473
- var uri = "\"data:" + mimetype + ',' + buf + "\"";
480
+ var uri = "\"data:" + mimetype + ',' + buf + fragment + "\"";
474
481
  return new(tree.URL)(new(tree.Anonymous)(uri));
475
482
  },
476
483
 
@@ -133,7 +133,7 @@
133
133
  this.env.frames.shift();
134
134
  },
135
135
  visitMedia: function (mediaNode, visitArgs) {
136
- this.env.frames.unshift(mediaNode.ruleset);
136
+ this.env.frames.unshift(mediaNode.rules[0]);
137
137
  return mediaNode;
138
138
  },
139
139
  visitMediaOut: function (mediaNode) {
@@ -141,4 +141,4 @@
141
141
  }
142
142
  };
143
143
 
144
- })(require('./tree'));
144
+ })(require('./tree'));
package/lib/less/index.js CHANGED
@@ -4,7 +4,7 @@ var path = require('path'),
4
4
  fs = require('./fs');
5
5
 
6
6
  var less = {
7
- version: [1, 7, 4],
7
+ version: [1, 7, 5],
8
8
  Parser: require('./parser').Parser,
9
9
  tree: require('./tree'),
10
10
  render: function (input, options, callback) {
@@ -27,7 +27,7 @@ var less = {
27
27
  }
28
28
  catch (err) { callback(err); return; }
29
29
  callback(null, css);
30
- });
30
+ }, options);
31
31
  } else {
32
32
  ee = new (require('events').EventEmitter)();
33
33
 
@@ -36,7 +36,7 @@ var less = {
36
36
  if (e) { return ee.emit('error', e); }
37
37
  try { ee.emit('success', root.toCSS(options)); }
38
38
  catch (err) { ee.emit('error', err); }
39
- });
39
+ }, options);
40
40
  });
41
41
  return ee;
42
42
  }