less 4.0.1-alpha.2 → 4.1.0
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/Gruntfile.js +2 -12
- package/dist/less.js +178 -48
- package/dist/less.min.js +3 -3
- package/dist/less.min.js.map +1 -1
- package/lib/less/constants.js +2 -1
- package/lib/less/constants.js.map +1 -1
- package/lib/less/functions/boolean.js +11 -1
- package/lib/less/functions/boolean.js.map +1 -1
- package/lib/less/import-manager.js.map +1 -1
- package/lib/less/index.js +4 -1
- package/lib/less/index.js.map +1 -1
- package/lib/less/parser/parser.js +3 -3
- package/lib/less/parser/parser.js.map +1 -1
- package/lib/less/source-map-output.js +5 -1
- package/lib/less/source-map-output.js.map +1 -1
- package/lib/less/transform-tree.js.map +1 -1
- package/lib/less/tree/assignment.js.map +1 -1
- package/lib/less/tree/atrule.js.map +1 -1
- package/lib/less/tree/attribute.js.map +1 -1
- package/lib/less/tree/color.js.map +1 -1
- package/lib/less/tree/debug-info.js.map +1 -1
- package/lib/less/tree/dimension.js +2 -1
- package/lib/less/tree/dimension.js.map +1 -1
- package/lib/less/tree/mixin-call.js.map +1 -1
- package/lib/less/tree/node.js +6 -0
- package/lib/less/tree/node.js.map +1 -1
- package/lib/less/tree/ruleset.js.map +1 -1
- package/lib/less/utils.js +3 -2
- package/lib/less/utils.js.map +1 -1
- package/lib/less/visitors/import-sequencer.js.map +1 -1
- package/lib/less/visitors/import-visitor.js.map +1 -1
- package/lib/less-node/url-file-manager.js +12 -8
- package/lib/less-node/url-file-manager.js.map +1 -1
- package/package.json +13 -11
- package/test/index.js +20 -2
- package/test/less-test.js +36 -16
- package/LICENSE +0 -177
package/Gruntfile.js
CHANGED
|
@@ -243,9 +243,6 @@ module.exports = function(grunt) {
|
|
|
243
243
|
benchmark: {
|
|
244
244
|
command: "node benchmark/index.js"
|
|
245
245
|
},
|
|
246
|
-
benchmarkbrowser: {
|
|
247
|
-
command: "node test/browser/generator/runner.js benchmark"
|
|
248
|
-
},
|
|
249
246
|
opts: {
|
|
250
247
|
// test running with all current options (using `opts` since `options` means something already)
|
|
251
248
|
command: [
|
|
@@ -286,7 +283,7 @@ module.exports = function(grunt) {
|
|
|
286
283
|
eslint: {
|
|
287
284
|
target: [
|
|
288
285
|
"test/**/*.js",
|
|
289
|
-
"
|
|
286
|
+
"src/less*/**/*.js",
|
|
290
287
|
"!test/less/errors/plugin/plugin-error.js"
|
|
291
288
|
],
|
|
292
289
|
options: {
|
|
@@ -416,15 +413,8 @@ module.exports = function(grunt) {
|
|
|
416
413
|
]);
|
|
417
414
|
|
|
418
415
|
// Run benchmark
|
|
419
|
-
grunt.registerTask("benchmark
|
|
416
|
+
grunt.registerTask("benchmark", [
|
|
420
417
|
"shell:testcjs",
|
|
421
418
|
"shell:benchmark"
|
|
422
419
|
]);
|
|
423
|
-
|
|
424
|
-
// Run all browser tests
|
|
425
|
-
grunt.registerTask("benchmark", [
|
|
426
|
-
"browsertest-lessjs",
|
|
427
|
-
"connect",
|
|
428
|
-
"shell:benchmarkbrowser"
|
|
429
|
-
]);
|
|
430
420
|
};
|
package/dist/less.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Less - Leaner CSS v4.
|
|
2
|
+
* Less - Leaner CSS v4.1.0
|
|
3
3
|
* http://lesscss.org
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2009-
|
|
5
|
+
* Copyright (c) 2009-2021, Alexis Sellier <self@cloudhead.net>
|
|
6
6
|
* Licensed under the Apache-2.0 License.
|
|
7
7
|
*
|
|
8
8
|
* @license Apache-2.0
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
(function (global, factory) {
|
|
12
12
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
13
13
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
14
|
-
(global = global || self, global.less = factory());
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.less = factory());
|
|
15
15
|
}(this, (function () { 'use strict';
|
|
16
16
|
|
|
17
17
|
// Export a new default each time
|
|
@@ -451,6 +451,12 @@
|
|
|
451
451
|
|
|
452
452
|
var data = { colors: colors, unitConversions: unitConversions };
|
|
453
453
|
|
|
454
|
+
/**
|
|
455
|
+
* The reason why Node is a class and other nodes simply do not extend
|
|
456
|
+
* from Node (since we're transpiling) is due to this issue:
|
|
457
|
+
*
|
|
458
|
+
* https://github.com/less/less.js/issues/3434
|
|
459
|
+
*/
|
|
454
460
|
var Node = /** @class */ (function () {
|
|
455
461
|
function Node() {
|
|
456
462
|
this.parent = null;
|
|
@@ -930,52 +936,116 @@
|
|
|
930
936
|
}
|
|
931
937
|
});
|
|
932
938
|
|
|
933
|
-
|
|
934
|
-
|
|
939
|
+
var Math$1 = {
|
|
940
|
+
ALWAYS: 0,
|
|
941
|
+
PARENS_DIVISION: 1,
|
|
942
|
+
PARENS: 2
|
|
943
|
+
// removed - STRICT_LEGACY: 3
|
|
944
|
+
};
|
|
945
|
+
var RewriteUrls = {
|
|
946
|
+
OFF: 0,
|
|
947
|
+
LOCAL: 1,
|
|
948
|
+
ALL: 2
|
|
949
|
+
};
|
|
935
950
|
|
|
936
|
-
|
|
937
|
-
|
|
951
|
+
/**
|
|
952
|
+
* Returns the object type of the given payload
|
|
953
|
+
*
|
|
954
|
+
* @param {*} payload
|
|
955
|
+
* @returns {string}
|
|
956
|
+
*/
|
|
957
|
+
function getType(payload) {
|
|
958
|
+
return Object.prototype.toString.call(payload).slice(8, -1);
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
|
962
|
+
*
|
|
963
|
+
* @param {*} payload
|
|
964
|
+
* @returns {payload is Record<string, any>}
|
|
965
|
+
*/
|
|
966
|
+
function isPlainObject(payload) {
|
|
967
|
+
if (getType(payload) !== 'Object')
|
|
968
|
+
return false;
|
|
969
|
+
return payload.constructor === Object && Object.getPrototypeOf(payload) === Object.prototype;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Returns whether the payload is an array
|
|
973
|
+
*
|
|
974
|
+
* @param {any} payload
|
|
975
|
+
* @returns {payload is any[]}
|
|
976
|
+
*/
|
|
977
|
+
function isArray(payload) {
|
|
978
|
+
return getType(payload) === 'Array';
|
|
979
|
+
}
|
|
938
980
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
981
|
+
/*! *****************************************************************************
|
|
982
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
983
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
984
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
985
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
986
|
+
|
|
987
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
988
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
989
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
990
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
991
|
+
|
|
992
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
993
|
+
and limitations under the License.
|
|
946
994
|
***************************************************************************** */
|
|
947
|
-
|
|
948
|
-
__assign = Object.assign || function __assign(t) {
|
|
949
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
950
|
-
s = arguments[i];
|
|
951
|
-
for (var p in s)
|
|
952
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
953
|
-
t[p] = s[p];
|
|
954
|
-
}
|
|
955
|
-
return t;
|
|
956
|
-
};
|
|
957
|
-
return __assign.apply(this, arguments);
|
|
958
|
-
};
|
|
995
|
+
|
|
959
996
|
function __spreadArrays() {
|
|
960
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
961
|
-
s += arguments[i].length;
|
|
997
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
962
998
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
963
999
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
964
1000
|
r[k] = a[j];
|
|
965
1001
|
return r;
|
|
966
1002
|
}
|
|
967
1003
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1004
|
+
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
|
1005
|
+
var propType = {}.propertyIsEnumerable.call(originalObject, key)
|
|
1006
|
+
? 'enumerable'
|
|
1007
|
+
: 'nonenumerable';
|
|
1008
|
+
if (propType === 'enumerable')
|
|
1009
|
+
carry[key] = newVal;
|
|
1010
|
+
if (includeNonenumerable && propType === 'nonenumerable') {
|
|
1011
|
+
Object.defineProperty(carry, key, {
|
|
1012
|
+
value: newVal,
|
|
1013
|
+
enumerable: false,
|
|
1014
|
+
writable: true,
|
|
1015
|
+
configurable: true,
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked.
|
|
1021
|
+
*
|
|
1022
|
+
* @export
|
|
1023
|
+
* @template T
|
|
1024
|
+
* @param {T} target Target can be anything
|
|
1025
|
+
* @param {Options} [options={}] Options can be `props` or `nonenumerable`
|
|
1026
|
+
* @returns {T} the target with replaced values
|
|
1027
|
+
* @export
|
|
1028
|
+
*/
|
|
1029
|
+
function copy(target, options) {
|
|
1030
|
+
if (options === void 0) { options = {}; }
|
|
1031
|
+
if (isArray(target))
|
|
1032
|
+
return target.map(function (i) { return copy(i, options); });
|
|
1033
|
+
if (!isPlainObject(target))
|
|
1034
|
+
return target;
|
|
1035
|
+
var props = Object.getOwnPropertyNames(target);
|
|
1036
|
+
var symbols = Object.getOwnPropertySymbols(target);
|
|
1037
|
+
return __spreadArrays(props, symbols).reduce(function (carry, key) {
|
|
1038
|
+
if (isArray(options.props) && !options.props.includes(key)) {
|
|
1039
|
+
return carry;
|
|
1040
|
+
}
|
|
1041
|
+
var val = target[key];
|
|
1042
|
+
var newVal = copy(val, options);
|
|
1043
|
+
assignProp(carry, key, newVal, target, options.nonenumerable);
|
|
1044
|
+
return carry;
|
|
1045
|
+
}, {});
|
|
1046
|
+
}
|
|
978
1047
|
|
|
1048
|
+
/* jshint proto: true */
|
|
979
1049
|
function getLocation(index, inputStream) {
|
|
980
1050
|
var n = index + 1;
|
|
981
1051
|
var line = null;
|
|
@@ -1013,9 +1083,9 @@
|
|
|
1013
1083
|
var newObj = obj2 || {};
|
|
1014
1084
|
if (!obj2._defaults) {
|
|
1015
1085
|
newObj = {};
|
|
1016
|
-
var defaults_1 =
|
|
1086
|
+
var defaults_1 = copy(obj1);
|
|
1017
1087
|
newObj._defaults = defaults_1;
|
|
1018
|
-
var cloned = obj2 ?
|
|
1088
|
+
var cloned = obj2 ? copy(obj2) : {};
|
|
1019
1089
|
Object.assign(newObj, defaults_1, cloned);
|
|
1020
1090
|
}
|
|
1021
1091
|
return newObj;
|
|
@@ -2832,7 +2902,8 @@
|
|
|
2832
2902
|
else {
|
|
2833
2903
|
other = other.convertTo(this.unit.usedUnits());
|
|
2834
2904
|
if (context.strictUnits && other.unit.toString() !== unit.toString()) {
|
|
2835
|
-
throw new Error("Incompatible units. Change the units or use the unit function.
|
|
2905
|
+
throw new Error("Incompatible units. Change the units or use the unit function. "
|
|
2906
|
+
+ ("Bad units: '" + unit.toString() + "' and '" + other.unit.toString() + "'."));
|
|
2836
2907
|
}
|
|
2837
2908
|
value = this._operate(context, op, this.value, other.value);
|
|
2838
2909
|
}
|
|
@@ -2960,6 +3031,29 @@
|
|
|
2960
3031
|
}
|
|
2961
3032
|
});
|
|
2962
3033
|
|
|
3034
|
+
/*! *****************************************************************************
|
|
3035
|
+
Copyright (c) Microsoft Corporation.
|
|
3036
|
+
|
|
3037
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
3038
|
+
purpose with or without fee is hereby granted.
|
|
3039
|
+
|
|
3040
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
3041
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
3042
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
3043
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
3044
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3045
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3046
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
3047
|
+
***************************************************************************** */
|
|
3048
|
+
|
|
3049
|
+
function __spreadArrays$1() {
|
|
3050
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
3051
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
3052
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
3053
|
+
r[k] = a[j];
|
|
3054
|
+
return r;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
2963
3057
|
var Expression = function (value, noSpacing) {
|
|
2964
3058
|
this.value = value;
|
|
2965
3059
|
this.noSpacing = noSpacing;
|
|
@@ -3059,7 +3153,7 @@
|
|
|
3059
3153
|
return item;
|
|
3060
3154
|
});
|
|
3061
3155
|
if (evalArgs === false) {
|
|
3062
|
-
return this.func.apply(this, __spreadArrays([this.context], args));
|
|
3156
|
+
return this.func.apply(this, __spreadArrays$1([this.context], args));
|
|
3063
3157
|
}
|
|
3064
3158
|
return this.func.apply(this, args);
|
|
3065
3159
|
};
|
|
@@ -7172,9 +7266,9 @@
|
|
|
7172
7266
|
parserInput.restore();
|
|
7173
7267
|
return;
|
|
7174
7268
|
}
|
|
7175
|
-
if (!lookups && !hasParens) {
|
|
7176
|
-
// This isn't a valid mixin call
|
|
7177
|
-
parserInput.restore(
|
|
7269
|
+
if (inValue && !lookups && !hasParens) {
|
|
7270
|
+
// This isn't a valid in-value mixin call
|
|
7271
|
+
parserInput.restore();
|
|
7178
7272
|
return;
|
|
7179
7273
|
}
|
|
7180
7274
|
if (!inValue && parsers.important()) {
|
|
@@ -8605,7 +8699,17 @@
|
|
|
8605
8699
|
: (falseValue ? falseValue.eval(context) : new Anonymous);
|
|
8606
8700
|
}
|
|
8607
8701
|
If.evalArgs = false;
|
|
8608
|
-
|
|
8702
|
+
function isdefined(context, variable) {
|
|
8703
|
+
try {
|
|
8704
|
+
variable.eval(context);
|
|
8705
|
+
return Keyword.True;
|
|
8706
|
+
}
|
|
8707
|
+
catch (e) {
|
|
8708
|
+
return Keyword.False;
|
|
8709
|
+
}
|
|
8710
|
+
}
|
|
8711
|
+
isdefined.evalArgs = false;
|
|
8712
|
+
var boolean$1 = { isdefined: isdefined, boolean: boolean, 'if': If };
|
|
8609
8713
|
|
|
8610
8714
|
var colorFunctions;
|
|
8611
8715
|
function clamp$1(val) {
|
|
@@ -9917,8 +10021,12 @@
|
|
|
9917
10021
|
// adjust the source
|
|
9918
10022
|
inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);
|
|
9919
10023
|
}
|
|
9920
|
-
|
|
10024
|
+
/**
|
|
10025
|
+
* ignore empty content, or failsafe
|
|
10026
|
+
* if contents map is incorrect
|
|
10027
|
+
*/
|
|
9921
10028
|
if (inputSource === undefined) {
|
|
10029
|
+
this._css.push(chunk);
|
|
9922
10030
|
return;
|
|
9923
10031
|
}
|
|
9924
10032
|
inputSource = inputSource.substring(0, index);
|
|
@@ -10402,6 +10510,27 @@
|
|
|
10402
10510
|
return render;
|
|
10403
10511
|
}
|
|
10404
10512
|
|
|
10513
|
+
var version = "4.1.0";
|
|
10514
|
+
|
|
10515
|
+
function parseNodeVersion(version) {
|
|
10516
|
+
var match = version.match(/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\+([0-9A-Za-z-.]+))?$/); // eslint-disable-line max-len
|
|
10517
|
+
if (!match) {
|
|
10518
|
+
throw new Error('Unable to parse: ' + version);
|
|
10519
|
+
}
|
|
10520
|
+
|
|
10521
|
+
var res = {
|
|
10522
|
+
major: parseInt(match[1], 10),
|
|
10523
|
+
minor: parseInt(match[2], 10),
|
|
10524
|
+
patch: parseInt(match[3], 10),
|
|
10525
|
+
pre: match[4] || '',
|
|
10526
|
+
build: match[5] || '',
|
|
10527
|
+
};
|
|
10528
|
+
|
|
10529
|
+
return res;
|
|
10530
|
+
}
|
|
10531
|
+
|
|
10532
|
+
var parseNodeVersion_1 = parseNodeVersion;
|
|
10533
|
+
|
|
10405
10534
|
function lessRoot (environment, fileManagers) {
|
|
10406
10535
|
var sourceMapOutput, sourceMapBuilder, parseTree, importManager;
|
|
10407
10536
|
environment = new Environment(environment, fileManagers);
|
|
@@ -10411,8 +10540,9 @@
|
|
|
10411
10540
|
importManager = ImportManager(environment);
|
|
10412
10541
|
var render = Render(environment, parseTree);
|
|
10413
10542
|
var parse = Parse(environment, parseTree, importManager);
|
|
10543
|
+
var v = parseNodeVersion_1("v" + version);
|
|
10414
10544
|
var initial = {
|
|
10415
|
-
version: [
|
|
10545
|
+
version: [v.major, v.minor, v.patch],
|
|
10416
10546
|
data: data,
|
|
10417
10547
|
tree: tree,
|
|
10418
10548
|
Environment: Environment,
|