less 3.11.0 → 3.11.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.
package/bin/lessc CHANGED
@@ -187,15 +187,8 @@ var AbstractFileManager = /** @class */ (function () {
187
187
  }
188
188
  return filename.slice(0, j + 1);
189
189
  };
190
- AbstractFileManager.prototype.isPathWithExtension = function (path, ext) {
191
- var extPos = path.lastIndexOf(ext);
192
- return extPos !== -1 && extPos === path.length - ext.length;
193
- };
194
190
  AbstractFileManager.prototype.tryAppendExtension = function (path, ext) {
195
- if (this.isPathWithExtension(path, ext)) {
196
- return path;
197
- }
198
- return path + ext;
191
+ return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext;
199
192
  };
200
193
  AbstractFileManager.prototype.tryAppendLessExtension = function (path) {
201
194
  return this.tryAppendExtension(path, '.less');
@@ -295,26 +288,19 @@ var AbstractFileManager = /** @class */ (function () {
295
288
  var FileManager = /** @class */ (function (_super) {
296
289
  tslib.__extends(FileManager, _super);
297
290
  function FileManager() {
298
- var _this = _super.call(this) || this;
299
- _this.contents = {};
300
- return _this;
291
+ return _super !== null && _super.apply(this, arguments) || this;
301
292
  }
302
- FileManager.prototype.supports = function (filename, currentDirectory, options, environment) {
293
+ FileManager.prototype.supports = function () {
303
294
  return true;
304
295
  };
305
- FileManager.prototype.supportsSync = function (filename, currentDirectory, options, environment) {
296
+ FileManager.prototype.supportsSync = function () {
306
297
  return true;
307
298
  };
308
- FileManager.prototype.getPossibleFileExtensions = function (path, ext) {
309
- if (this.isPathWithExtension(path, ext)) {
310
- return [''];
311
- }
312
- return ['', ext];
313
- };
314
299
  FileManager.prototype.loadFile = function (filename, currentDirectory, options, environment, callback) {
315
300
  var fullFilename;
316
301
  var isAbsoluteFilename = this.isPathAbsolute(filename);
317
302
  var filenamesTried = [];
303
+ var self = this;
318
304
  var prefix = filename.slice(0, 1);
319
305
  var explicit = prefix === '.' || prefix === '/';
320
306
  var result = null;
@@ -329,7 +315,6 @@ var FileManager = /** @class */ (function (_super) {
329
315
  paths.push('.');
330
316
  }
331
317
  var prefixes = options.prefixes || [''];
332
- var extensions = this.getPossibleFileExtensions(filename, options.ext);
333
318
  var fileParts = this.extractUrlParts(filename);
334
319
  if (options.syncImport) {
335
320
  getFileData(returnData, returnData);
@@ -359,51 +344,64 @@ var FileManager = /** @class */ (function (_super) {
359
344
  if (i < paths.length) {
360
345
  (function tryPrefix(j) {
361
346
  if (j < prefixes.length) {
362
- (function tryExtension(k) {
363
- if (k < extensions.length) {
364
- isNodeModule = false;
365
- fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename + extensions[k];
366
- if (paths[i]) {
367
- fullFilename = path.join(paths[i], fullFilename);
368
- }
369
- if (!explicit && paths[i] === '.') {
370
- try {
371
- fullFilename = require.resolve(fullFilename);
372
- isNodeModule = true;
373
- }
374
- catch (e) {
375
- filenamesTried.push(npmPrefix + fullFilename);
376
- }
377
- }
378
- var readFileArgs = [fullFilename];
379
- if (!options.rawBuffer) {
380
- readFileArgs.push('utf-8');
381
- }
382
- if (options.syncImport) {
383
- try {
384
- var data = fs$1.readFileSync.apply(this, readFileArgs);
385
- fulfill({ contents: data, filename: fullFilename });
386
- }
387
- catch (e) {
388
- filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
389
- return tryExtension(k + 1);
390
- }
347
+ isNodeModule = false;
348
+ fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename;
349
+ if (paths[i]) {
350
+ fullFilename = path.join(paths[i], fullFilename);
351
+ }
352
+ if (!explicit && paths[i] === '.') {
353
+ try {
354
+ fullFilename = require.resolve(fullFilename);
355
+ isNodeModule = true;
356
+ }
357
+ catch (e) {
358
+ filenamesTried.push(npmPrefix + fullFilename);
359
+ tryWithExtension();
360
+ }
361
+ }
362
+ else {
363
+ tryWithExtension();
364
+ }
365
+ function tryWithExtension() {
366
+ var extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
367
+ if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
368
+ try {
369
+ fullFilename = require.resolve(extFilename);
370
+ isNodeModule = true;
391
371
  }
392
- else {
393
- readFileArgs.push(function (e, data) {
394
- if (e) {
395
- filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
396
- return tryExtension(k + 1);
397
- }
398
- fulfill({ contents: data, filename: fullFilename });
399
- });
400
- fs$1.readFile.apply(this, readFileArgs);
372
+ catch (e) {
373
+ filenamesTried.push(npmPrefix + extFilename);
374
+ fullFilename = extFilename;
401
375
  }
402
376
  }
403
377
  else {
404
- tryPrefix(j + 1);
378
+ fullFilename = extFilename;
405
379
  }
406
- })(0);
380
+ }
381
+ var readFileArgs = [fullFilename];
382
+ if (!options.rawBuffer) {
383
+ readFileArgs.push('utf-8');
384
+ }
385
+ if (options.syncImport) {
386
+ try {
387
+ var data = fs$1.readFileSync.apply(this, readFileArgs);
388
+ fulfill({ contents: data, filename: fullFilename });
389
+ }
390
+ catch (e) {
391
+ filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
392
+ return tryPrefix(j + 1);
393
+ }
394
+ }
395
+ else {
396
+ readFileArgs.push(function (e, data) {
397
+ if (e) {
398
+ filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
399
+ return tryPrefix(j + 1);
400
+ }
401
+ fulfill({ contents: data, filename: fullFilename });
402
+ });
403
+ fs$1.readFile.apply(this, readFileArgs);
404
+ }
407
405
  }
408
406
  else {
409
407
  tryPathIndex(i + 1);
@@ -10564,7 +10562,7 @@ var createFromEnvironment = (function (environment, fileManagers) {
10564
10562
  * It's not clear what should / must be public and why.
10565
10563
  */
10566
10564
  var initial = {
10567
- version: [3, 11, 0],
10565
+ version: [3, 11, 1],
10568
10566
  data: data,
10569
10567
  tree: tree,
10570
10568
  Environment: environment$1,
package/dist/less.cjs.js CHANGED
@@ -48,15 +48,8 @@ var AbstractFileManager = /** @class */ (function () {
48
48
  }
49
49
  return filename.slice(0, j + 1);
50
50
  };
51
- AbstractFileManager.prototype.isPathWithExtension = function (path, ext) {
52
- var extPos = path.lastIndexOf(ext);
53
- return extPos !== -1 && extPos === path.length - ext.length;
54
- };
55
51
  AbstractFileManager.prototype.tryAppendExtension = function (path, ext) {
56
- if (this.isPathWithExtension(path, ext)) {
57
- return path;
58
- }
59
- return path + ext;
52
+ return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext;
60
53
  };
61
54
  AbstractFileManager.prototype.tryAppendLessExtension = function (path) {
62
55
  return this.tryAppendExtension(path, '.less');
@@ -156,26 +149,19 @@ var AbstractFileManager = /** @class */ (function () {
156
149
  var FileManager = /** @class */ (function (_super) {
157
150
  tslib.__extends(FileManager, _super);
158
151
  function FileManager() {
159
- var _this = _super.call(this) || this;
160
- _this.contents = {};
161
- return _this;
152
+ return _super !== null && _super.apply(this, arguments) || this;
162
153
  }
163
- FileManager.prototype.supports = function (filename, currentDirectory, options, environment) {
154
+ FileManager.prototype.supports = function () {
164
155
  return true;
165
156
  };
166
- FileManager.prototype.supportsSync = function (filename, currentDirectory, options, environment) {
157
+ FileManager.prototype.supportsSync = function () {
167
158
  return true;
168
159
  };
169
- FileManager.prototype.getPossibleFileExtensions = function (path, ext) {
170
- if (this.isPathWithExtension(path, ext)) {
171
- return [''];
172
- }
173
- return ['', ext];
174
- };
175
160
  FileManager.prototype.loadFile = function (filename, currentDirectory, options, environment, callback) {
176
161
  var fullFilename;
177
162
  var isAbsoluteFilename = this.isPathAbsolute(filename);
178
163
  var filenamesTried = [];
164
+ var self = this;
179
165
  var prefix = filename.slice(0, 1);
180
166
  var explicit = prefix === '.' || prefix === '/';
181
167
  var result = null;
@@ -190,7 +176,6 @@ var FileManager = /** @class */ (function (_super) {
190
176
  paths.push('.');
191
177
  }
192
178
  var prefixes = options.prefixes || [''];
193
- var extensions = this.getPossibleFileExtensions(filename, options.ext);
194
179
  var fileParts = this.extractUrlParts(filename);
195
180
  if (options.syncImport) {
196
181
  getFileData(returnData, returnData);
@@ -220,51 +205,64 @@ var FileManager = /** @class */ (function (_super) {
220
205
  if (i < paths.length) {
221
206
  (function tryPrefix(j) {
222
207
  if (j < prefixes.length) {
223
- (function tryExtension(k) {
224
- if (k < extensions.length) {
225
- isNodeModule = false;
226
- fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename + extensions[k];
227
- if (paths[i]) {
228
- fullFilename = path.join(paths[i], fullFilename);
229
- }
230
- if (!explicit && paths[i] === '.') {
231
- try {
232
- fullFilename = require.resolve(fullFilename);
233
- isNodeModule = true;
234
- }
235
- catch (e) {
236
- filenamesTried.push(npmPrefix + fullFilename);
237
- }
238
- }
239
- var readFileArgs = [fullFilename];
240
- if (!options.rawBuffer) {
241
- readFileArgs.push('utf-8');
242
- }
243
- if (options.syncImport) {
244
- try {
245
- var data = fs$1.readFileSync.apply(this, readFileArgs);
246
- fulfill({ contents: data, filename: fullFilename });
247
- }
248
- catch (e) {
249
- filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
250
- return tryExtension(k + 1);
251
- }
208
+ isNodeModule = false;
209
+ fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename;
210
+ if (paths[i]) {
211
+ fullFilename = path.join(paths[i], fullFilename);
212
+ }
213
+ if (!explicit && paths[i] === '.') {
214
+ try {
215
+ fullFilename = require.resolve(fullFilename);
216
+ isNodeModule = true;
217
+ }
218
+ catch (e) {
219
+ filenamesTried.push(npmPrefix + fullFilename);
220
+ tryWithExtension();
221
+ }
222
+ }
223
+ else {
224
+ tryWithExtension();
225
+ }
226
+ function tryWithExtension() {
227
+ var extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
228
+ if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
229
+ try {
230
+ fullFilename = require.resolve(extFilename);
231
+ isNodeModule = true;
252
232
  }
253
- else {
254
- readFileArgs.push(function (e, data) {
255
- if (e) {
256
- filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
257
- return tryExtension(k + 1);
258
- }
259
- fulfill({ contents: data, filename: fullFilename });
260
- });
261
- fs$1.readFile.apply(this, readFileArgs);
233
+ catch (e) {
234
+ filenamesTried.push(npmPrefix + extFilename);
235
+ fullFilename = extFilename;
262
236
  }
263
237
  }
264
238
  else {
265
- tryPrefix(j + 1);
239
+ fullFilename = extFilename;
266
240
  }
267
- })(0);
241
+ }
242
+ var readFileArgs = [fullFilename];
243
+ if (!options.rawBuffer) {
244
+ readFileArgs.push('utf-8');
245
+ }
246
+ if (options.syncImport) {
247
+ try {
248
+ var data = fs$1.readFileSync.apply(this, readFileArgs);
249
+ fulfill({ contents: data, filename: fullFilename });
250
+ }
251
+ catch (e) {
252
+ filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
253
+ return tryPrefix(j + 1);
254
+ }
255
+ }
256
+ else {
257
+ readFileArgs.push(function (e, data) {
258
+ if (e) {
259
+ filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
260
+ return tryPrefix(j + 1);
261
+ }
262
+ fulfill({ contents: data, filename: fullFilename });
263
+ });
264
+ fs$1.readFile.apply(this, readFileArgs);
265
+ }
268
266
  }
269
267
  else {
270
268
  tryPathIndex(i + 1);
@@ -10560,7 +10558,7 @@ var createFromEnvironment = (function (environment, fileManagers) {
10560
10558
  * It's not clear what should / must be public and why.
10561
10559
  */
10562
10560
  var initial = {
10563
- version: [3, 11, 0],
10561
+ version: [3, 11, 1],
10564
10562
  data: data,
10565
10563
  tree: tree,
10566
10564
  Environment: environment$1,
package/dist/less.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Less - Leaner CSS v3.11.0
2
+ * Less - Leaner CSS v3.11.1
3
3
  * http://lesscss.org
4
4
  *
5
5
  * Copyright (c) 2009-2020, Alexis Sellier <self@cloudhead.net>
@@ -4858,15 +4858,8 @@
4858
4858
  }
4859
4859
  return filename.slice(0, j + 1);
4860
4860
  };
4861
- AbstractFileManager.prototype.isPathWithExtension = function (path, ext) {
4862
- var extPos = path.lastIndexOf(ext);
4863
- return extPos !== -1 && extPos === path.length - ext.length;
4864
- };
4865
4861
  AbstractFileManager.prototype.tryAppendExtension = function (path, ext) {
4866
- if (this.isPathWithExtension(path, ext)) {
4867
- return path;
4868
- }
4869
- return path + ext;
4862
+ return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext;
4870
4863
  };
4871
4864
  AbstractFileManager.prototype.tryAppendLessExtension = function (path) {
4872
4865
  return this.tryAppendExtension(path, '.less');
@@ -10823,7 +10816,7 @@
10823
10816
  * It's not clear what should / must be public and why.
10824
10817
  */
10825
10818
  var initial = {
10826
- version: [3, 11, 0],
10819
+ version: [3, 11, 1],
10827
10820
  data: data,
10828
10821
  tree: tree,
10829
10822
  Environment: environment,
@@ -10886,17 +10879,6 @@
10886
10879
  FileManager.prototype.alwaysMakePathsAbsolute = function () {
10887
10880
  return true;
10888
10881
  };
10889
- FileManager.prototype.getPossibleFileExtensions = function (path, ext) {
10890
- if (this.isPathWithExtension(path, ext)) {
10891
- return [''];
10892
- }
10893
- // if file doesn't have dot in name it require extention
10894
- if (path.indexOf(".") === -1) {
10895
- return [ext];
10896
- }
10897
- // path has dots in name it might be with or without extention (like .css)
10898
- return [ext, ''];
10899
- };
10900
10882
  FileManager.prototype.join = function (basePath, laterPath) {
10901
10883
  if (!basePath) {
10902
10884
  return laterPath;
@@ -10940,8 +10922,25 @@
10940
10922
  handleResponse(xhr, callback, errback);
10941
10923
  }
10942
10924
  };
10943
- FileManager.prototype.tryToLoad = function (href) {
10944
- var _this = this;
10925
+ FileManager.prototype.supports = function () {
10926
+ return true;
10927
+ };
10928
+ FileManager.prototype.clearFileCache = function () {
10929
+ fileCache = {};
10930
+ };
10931
+ FileManager.prototype.loadFile = function (filename, currentDirectory, options, environment) {
10932
+ // TODO: Add prefix support like less-node?
10933
+ // What about multiple paths?
10934
+ if (currentDirectory && !this.isPathAbsolute(filename)) {
10935
+ filename = currentDirectory + filename;
10936
+ }
10937
+ filename = options.ext ? this.tryAppendExtension(filename, options.ext) : filename;
10938
+ options = options || {};
10939
+ // sheet may be set to the stylesheet for the initial load or a collection of properties including
10940
+ // some context variables for imports
10941
+ var hrefParts = this.extractUrlParts(filename, window.location.href);
10942
+ var href = hrefParts.url;
10943
+ var self = this;
10945
10944
  return new Promise(function (resolve, reject) {
10946
10945
  if (options.useFileCache && fileCache[href]) {
10947
10946
  try {
@@ -10952,7 +10951,7 @@
10952
10951
  return reject({ filename: href, message: "Error loading file " + href + " error was " + e.message });
10953
10952
  }
10954
10953
  }
10955
- _this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
10954
+ self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
10956
10955
  // per file cache
10957
10956
  fileCache[href] = data;
10958
10957
  // Use remote copy (re-parse)
@@ -10962,28 +10961,6 @@
10962
10961
  });
10963
10962
  });
10964
10963
  };
10965
- FileManager.prototype.supports = function () {
10966
- return true;
10967
- };
10968
- FileManager.prototype.clearFileCache = function () {
10969
- fileCache = {};
10970
- };
10971
- FileManager.prototype.loadFile = function (filename, currentDirectory, options, environment) {
10972
- // TODO: Add prefix support like less-node?
10973
- // What about multiple paths?
10974
- var _this = this;
10975
- if (currentDirectory && !this.isPathAbsolute(filename)) {
10976
- filename = currentDirectory + filename;
10977
- }
10978
- var extensions = this.getPossibleFileExtensions(filename, options.ext || '');
10979
- options = options || {};
10980
- // sheet may be set to the stylesheet for the initial load or a collection of properties including
10981
- // some context variables for imports
10982
- var hrefParts = this.extractUrlParts(filename, window.location.href);
10983
- var href = hrefParts.url;
10984
- var hrefs = extensions.map(function (ext) { return _this.tryAppendExtension(href, ext); });
10985
- return hrefs.reduce(function (prev, href) { return prev.catch(function () { return _this.tryToLoad(href); }); }, this.tryToLoad(hrefs.shift()));
10986
- };
10987
10964
  return FileManager;
10988
10965
  }(AbstractFileManager));
10989
10966
  var FM = (function (opts, log) {