less 4.8.1 → 5.0.0-alpha.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/README.md +19 -5
- package/bin/lessc +190 -630
- package/dist/less-node.cjs +398 -14282
- package/index.cjs +5 -2
- package/lib/index.js +164 -0
- package/lib/lessc-helper.js +52 -0
- package/lib/logger.js +76 -0
- package/lib/options.d.ts +46 -0
- package/lib/options.js +145 -0
- package/lib/types.js +20 -0
- package/lib/version.js +19 -0
- package/package.json +33 -40
- package/dist/less.cjs +0 -14929
- package/dist/less.js +0 -14929
- package/dist/less.min.js +0 -11
- package/dist/less.min.js.map +0 -1
- package/lib/less/constants.js +0 -13
- package/lib/less/contexts.js +0 -165
- package/lib/less/data/colors.js +0 -150
- package/lib/less/data/index.js +0 -4
- package/lib/less/data/unit-conversions.js +0 -21
- package/lib/less/default-options.js +0 -89
- package/lib/less/deprecation.js +0 -82
- package/lib/less/environment/abstract-file-manager.js +0 -140
- package/lib/less/environment/abstract-plugin-loader.js +0 -185
- package/lib/less/environment/environment-api.ts +0 -21
- package/lib/less/environment/environment.js +0 -59
- package/lib/less/environment/file-manager-api.ts +0 -77
- package/lib/less/functions/boolean.js +0 -29
- package/lib/less/functions/color-blending.js +0 -85
- package/lib/less/functions/color.js +0 -452
- package/lib/less/functions/data-uri.js +0 -74
- package/lib/less/functions/default.js +0 -26
- package/lib/less/functions/function-caller.js +0 -55
- package/lib/less/functions/function-registry.js +0 -36
- package/lib/less/functions/index.js +0 -35
- package/lib/less/functions/list.js +0 -158
- package/lib/less/functions/math-helper.js +0 -22
- package/lib/less/functions/math.js +0 -30
- package/lib/less/functions/number.js +0 -95
- package/lib/less/functions/string.js +0 -36
- package/lib/less/functions/style.js +0 -29
- package/lib/less/functions/svg.js +0 -87
- package/lib/less/functions/types.js +0 -70
- package/lib/less/import-manager.js +0 -183
- package/lib/less/index.js +0 -95
- package/lib/less/less-error.js +0 -166
- package/lib/less/logger.js +0 -34
- package/lib/less/parse-tree.js +0 -124
- package/lib/less/parse.js +0 -87
- package/lib/less/parser/parser-input.js +0 -400
- package/lib/less/parser/parser.js +0 -2894
- package/lib/less/plugin-manager.js +0 -168
- package/lib/less/render.js +0 -41
- package/lib/less/source-map-builder.js +0 -82
- package/lib/less/source-map-output.js +0 -151
- package/lib/less/transform-tree.js +0 -102
- package/lib/less/tree/anonymous.js +0 -57
- package/lib/less/tree/assignment.js +0 -48
- package/lib/less/tree/atrule-syntax.js +0 -8
- package/lib/less/tree/atrule.js +0 -340
- package/lib/less/tree/attribute.js +0 -63
- package/lib/less/tree/call.js +0 -132
- package/lib/less/tree/color.js +0 -285
- package/lib/less/tree/combinator.js +0 -38
- package/lib/less/tree/comment.js +0 -48
- package/lib/less/tree/condition.js +0 -65
- package/lib/less/tree/container.js +0 -104
- package/lib/less/tree/debug-info.js +0 -80
- package/lib/less/tree/declaration.js +0 -139
- package/lib/less/tree/detached-ruleset.js +0 -45
- package/lib/less/tree/dimension.js +0 -215
- package/lib/less/tree/element.js +0 -93
- package/lib/less/tree/expression.js +0 -100
- package/lib/less/tree/extend.js +0 -88
- package/lib/less/tree/import.js +0 -299
- package/lib/less/tree/index.js +0 -56
- package/lib/less/tree/javascript.js +0 -45
- package/lib/less/tree/js-eval-node.js +0 -74
- package/lib/less/tree/keyword.js +0 -28
- package/lib/less/tree/media.js +0 -90
- package/lib/less/tree/merge-rules.js +0 -47
- package/lib/less/tree/mixin-call.js +0 -283
- package/lib/less/tree/mixin-definition.js +0 -319
- package/lib/less/tree/namespace-value.js +0 -95
- package/lib/less/tree/negative.js +0 -37
- package/lib/less/tree/nested-at-rule.js +0 -198
- package/lib/less/tree/node.js +0 -310
- package/lib/less/tree/operation.js +0 -81
- package/lib/less/tree/paren.js +0 -41
- package/lib/less/tree/property.js +0 -96
- package/lib/less/tree/query-in-parens.js +0 -64
- package/lib/less/tree/quoted.js +0 -114
- package/lib/less/tree/ruleset.js +0 -1066
- package/lib/less/tree/selector.js +0 -201
- package/lib/less/tree/unicode-descriptor.js +0 -14
- package/lib/less/tree/unit.js +0 -170
- package/lib/less/tree/url.js +0 -83
- package/lib/less/tree/value.js +0 -60
- package/lib/less/tree/variable-call.js +0 -60
- package/lib/less/tree/variable.js +0 -85
- package/lib/less/utils.js +0 -126
- package/lib/less/visitors/extend-visitor.js +0 -505
- package/lib/less/visitors/import-sequencer.js +0 -56
- package/lib/less/visitors/import-visitor.js +0 -203
- package/lib/less/visitors/index.js +0 -15
- package/lib/less/visitors/join-selector-visitor.js +0 -65
- package/lib/less/visitors/set-tree-visibility-visitor.js +0 -57
- package/lib/less/visitors/to-css-visitor.js +0 -332
- package/lib/less/visitors/visitor.js +0 -165
- package/lib/less-browser/add-default-options.js +0 -53
- package/lib/less-browser/bootstrap.js +0 -67
- package/lib/less-browser/browser.js +0 -65
- package/lib/less-browser/cache.js +0 -43
- package/lib/less-browser/error-reporting.js +0 -170
- package/lib/less-browser/file-manager.js +0 -112
- package/lib/less-browser/image-size.js +0 -28
- package/lib/less-browser/index.js +0 -284
- package/lib/less-browser/log-listener.js +0 -42
- package/lib/less-browser/plugin-loader.js +0 -24
- package/lib/less-browser/utils.js +0 -30
- package/lib/less-node/environment.js +0 -43
- package/lib/less-node/file-manager.js +0 -156
- package/lib/less-node/fs.js +0 -14
- package/lib/less-node/image-size.js +0 -78
- package/lib/less-node/index.js +0 -31
- package/lib/less-node/lessc-helper.js +0 -95
- package/lib/less-node/plugin-loader.js +0 -62
- package/lib/less-node/url-file-manager.js +0 -60
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
/** @import { EvalContext, FileInfo } from './node.js' */
|
|
3
|
-
import Node from './node.js';
|
|
4
|
-
import Declaration from './declaration.js';
|
|
5
|
-
import Ruleset from './ruleset.js';
|
|
6
|
-
|
|
7
|
-
class Property extends Node {
|
|
8
|
-
get type() { return 'Property'; }
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} name
|
|
12
|
-
* @param {number} index
|
|
13
|
-
* @param {FileInfo} currentFileInfo
|
|
14
|
-
*/
|
|
15
|
-
constructor(name, index, currentFileInfo) {
|
|
16
|
-
super();
|
|
17
|
-
this.name = name;
|
|
18
|
-
this._index = index;
|
|
19
|
-
this._fileInfo = currentFileInfo;
|
|
20
|
-
/** @type {boolean | undefined} */
|
|
21
|
-
this.evaluating = undefined;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {EvalContext} context
|
|
26
|
-
* @returns {Node}
|
|
27
|
-
*/
|
|
28
|
-
eval(context) {
|
|
29
|
-
let property;
|
|
30
|
-
const name = this.name;
|
|
31
|
-
// TODO: shorten this reference
|
|
32
|
-
const mergeRules = /** @type {{ less: { visitors: { ToCSSVisitor: { prototype: { _mergeRules: (rules: Declaration[]) => void } } } } }} */ (context.pluginManager).less.visitors.ToCSSVisitor.prototype._mergeRules;
|
|
33
|
-
|
|
34
|
-
if (this.evaluating) {
|
|
35
|
-
throw { type: 'Name',
|
|
36
|
-
message: `Recursive property reference for ${name}`,
|
|
37
|
-
filename: this.fileInfo().filename,
|
|
38
|
-
index: this.getIndex() };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this.evaluating = true;
|
|
42
|
-
|
|
43
|
-
property = this.find(context.frames, function (/** @type {Node} */ frame) {
|
|
44
|
-
let v;
|
|
45
|
-
const vArr = /** @type {Ruleset} */ (frame).property(name);
|
|
46
|
-
if (vArr) {
|
|
47
|
-
for (let i = 0; i < vArr.length; i++) {
|
|
48
|
-
v = vArr[i];
|
|
49
|
-
|
|
50
|
-
vArr[i] = new Declaration(v.name,
|
|
51
|
-
v.value,
|
|
52
|
-
v.important,
|
|
53
|
-
v.merge,
|
|
54
|
-
v.index,
|
|
55
|
-
v.currentFileInfo,
|
|
56
|
-
v.inline,
|
|
57
|
-
v.variable
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
mergeRules(vArr);
|
|
61
|
-
|
|
62
|
-
v = vArr[vArr.length - 1];
|
|
63
|
-
if (v.important) {
|
|
64
|
-
const importantScope = context.importantScope[context.importantScope.length - 1];
|
|
65
|
-
importantScope.important = v.important;
|
|
66
|
-
}
|
|
67
|
-
v = v.value.eval(context);
|
|
68
|
-
return v;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
if (property) {
|
|
72
|
-
this.evaluating = false;
|
|
73
|
-
return property;
|
|
74
|
-
} else {
|
|
75
|
-
throw { type: 'Name',
|
|
76
|
-
message: `Property '${name}' is undefined`,
|
|
77
|
-
filename: this.currentFileInfo.filename,
|
|
78
|
-
index: this.index };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @param {Node[]} obj
|
|
84
|
-
* @param {(frame: Node) => Node | undefined} fun
|
|
85
|
-
* @returns {Node | null}
|
|
86
|
-
*/
|
|
87
|
-
find(obj, fun) {
|
|
88
|
-
for (let i = 0, r; i < obj.length; i++) {
|
|
89
|
-
r = fun.call(obj, obj[i]);
|
|
90
|
-
if (r) { return r; }
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export default Property;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
/** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */
|
|
3
|
-
import Node from './node.js';
|
|
4
|
-
|
|
5
|
-
class QueryInParens extends Node {
|
|
6
|
-
get type() { return 'QueryInParens'; }
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {string} op
|
|
10
|
-
* @param {Node} l
|
|
11
|
-
* @param {Node} m
|
|
12
|
-
* @param {string | null} op2
|
|
13
|
-
* @param {Node | null} r
|
|
14
|
-
* @param {number} i
|
|
15
|
-
*/
|
|
16
|
-
constructor(op, l, m, op2, r, i) {
|
|
17
|
-
super();
|
|
18
|
-
this.op = op.trim();
|
|
19
|
-
this.lvalue = l;
|
|
20
|
-
this.mvalue = m;
|
|
21
|
-
this.op2 = op2 ? op2.trim() : null;
|
|
22
|
-
/** @type {Node | null} */
|
|
23
|
-
this.rvalue = r;
|
|
24
|
-
this._index = i;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** @param {TreeVisitor} visitor */
|
|
28
|
-
accept(visitor) {
|
|
29
|
-
this.lvalue = visitor.visit(this.lvalue);
|
|
30
|
-
this.mvalue = visitor.visit(this.mvalue);
|
|
31
|
-
if (this.rvalue) {
|
|
32
|
-
this.rvalue = visitor.visit(this.rvalue);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @param {EvalContext} context */
|
|
37
|
-
eval(context) {
|
|
38
|
-
const node = new QueryInParens(
|
|
39
|
-
this.op,
|
|
40
|
-
this.lvalue.eval(context),
|
|
41
|
-
this.mvalue.eval(context),
|
|
42
|
-
this.op2,
|
|
43
|
-
this.rvalue ? this.rvalue.eval(context) : null,
|
|
44
|
-
this._index || 0
|
|
45
|
-
);
|
|
46
|
-
return node;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @param {EvalContext} context
|
|
51
|
-
* @param {CSSOutput} output
|
|
52
|
-
*/
|
|
53
|
-
genCSS(context, output) {
|
|
54
|
-
this.lvalue.genCSS(context, output);
|
|
55
|
-
output.add(' ' + this.op + ' ');
|
|
56
|
-
this.mvalue.genCSS(context, output);
|
|
57
|
-
if (this.rvalue) {
|
|
58
|
-
output.add(' ' + this.op2 + ' ');
|
|
59
|
-
this.rvalue.genCSS(context, output);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default QueryInParens;
|
package/lib/less/tree/quoted.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
/** @import { EvalContext, CSSOutput, FileInfo } from './node.js' */
|
|
3
|
-
import Node from './node.js';
|
|
4
|
-
import Variable from './variable.js';
|
|
5
|
-
import Property from './property.js';
|
|
6
|
-
|
|
7
|
-
class Quoted extends Node {
|
|
8
|
-
get type() { return 'Quoted'; }
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} str
|
|
12
|
-
* @param {string} [content]
|
|
13
|
-
* @param {boolean} [escaped]
|
|
14
|
-
* @param {number} [index]
|
|
15
|
-
* @param {FileInfo} [currentFileInfo]
|
|
16
|
-
*/
|
|
17
|
-
constructor(str, content, escaped, index, currentFileInfo) {
|
|
18
|
-
super();
|
|
19
|
-
/** @type {boolean} */
|
|
20
|
-
this.escaped = (escaped === undefined) ? true : escaped;
|
|
21
|
-
/** @type {string} */
|
|
22
|
-
this.value = content || '';
|
|
23
|
-
/** @type {string} */
|
|
24
|
-
this.quote = str.charAt(0);
|
|
25
|
-
this._index = index;
|
|
26
|
-
this._fileInfo = currentFileInfo;
|
|
27
|
-
/** @type {RegExp} */
|
|
28
|
-
this.variableRegex = /@\{([\w-]+)\}/g;
|
|
29
|
-
/** @type {RegExp} */
|
|
30
|
-
this.propRegex = /\$\{([\w-]+)\}/g;
|
|
31
|
-
/** @type {boolean | undefined} */
|
|
32
|
-
this.allowRoot = escaped;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param {EvalContext} context
|
|
37
|
-
* @param {CSSOutput} output
|
|
38
|
-
*/
|
|
39
|
-
genCSS(context, output) {
|
|
40
|
-
if (!this.escaped) {
|
|
41
|
-
output.add(this.quote, this.fileInfo(), this.getIndex());
|
|
42
|
-
}
|
|
43
|
-
output.add(/** @type {string} */ (this.value));
|
|
44
|
-
if (!this.escaped) {
|
|
45
|
-
output.add(this.quote);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** @returns {RegExpMatchArray | null} */
|
|
50
|
-
containsVariables() {
|
|
51
|
-
return /** @type {string} */ (this.value).match(this.variableRegex);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @param {EvalContext} context */
|
|
55
|
-
eval(context) {
|
|
56
|
-
const that = this;
|
|
57
|
-
let value = /** @type {string} */ (this.value);
|
|
58
|
-
/**
|
|
59
|
-
* @param {string} _
|
|
60
|
-
* @param {string} name1
|
|
61
|
-
* @param {string} name2
|
|
62
|
-
* @returns {string}
|
|
63
|
-
*/
|
|
64
|
-
const variableReplacement = function (_, name1, name2) {
|
|
65
|
-
const v = new Variable(`@${name1 ?? name2}`, that.getIndex(), that.fileInfo()).eval(context);
|
|
66
|
-
return (v instanceof Quoted) ? /** @type {string} */ (v.value) : v.toCSS(context);
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* @param {string} _
|
|
70
|
-
* @param {string} name1
|
|
71
|
-
* @param {string} name2
|
|
72
|
-
* @returns {string}
|
|
73
|
-
*/
|
|
74
|
-
const propertyReplacement = function (_, name1, name2) {
|
|
75
|
-
const v = new Property(`$${name1 ?? name2}`, that.getIndex(), that.fileInfo()).eval(context);
|
|
76
|
-
return (v instanceof Quoted) ? /** @type {string} */ (v.value) : v.toCSS(context);
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* @param {string} value
|
|
80
|
-
* @param {RegExp} regexp
|
|
81
|
-
* @param {(substring: string, ...args: string[]) => string} replacementFnc
|
|
82
|
-
* @returns {string}
|
|
83
|
-
*/
|
|
84
|
-
function iterativeReplace(value, regexp, replacementFnc) {
|
|
85
|
-
let evaluatedValue = value;
|
|
86
|
-
do {
|
|
87
|
-
value = evaluatedValue.toString();
|
|
88
|
-
evaluatedValue = value.replace(regexp, replacementFnc);
|
|
89
|
-
} while (value !== evaluatedValue);
|
|
90
|
-
return evaluatedValue;
|
|
91
|
-
}
|
|
92
|
-
value = iterativeReplace(value, this.variableRegex, variableReplacement);
|
|
93
|
-
value = iterativeReplace(value, this.propRegex, propertyReplacement);
|
|
94
|
-
return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @param {Node} other
|
|
99
|
-
* @returns {number | undefined}
|
|
100
|
-
*/
|
|
101
|
-
compare(other) {
|
|
102
|
-
// when comparing quoted strings allow the quote to differ
|
|
103
|
-
if (other.type === 'Quoted' && !this.escaped && !/** @type {Quoted} */ (other).escaped) {
|
|
104
|
-
return Node.numericCompare(
|
|
105
|
-
/** @type {string} */ (this.value),
|
|
106
|
-
/** @type {string} */ (other.value)
|
|
107
|
-
);
|
|
108
|
-
} else {
|
|
109
|
-
return other.toCSS && this.toCSS(/** @type {EvalContext} */ ({})) === other.toCSS(/** @type {EvalContext} */ ({})) ? 0 : undefined;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default Quoted;
|