less 3.10.0-beta.2 → 3.10.3

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 (124) hide show
  1. package/.DS_Store +0 -0
  2. package/bin/lessc +6652 -5505
  3. package/dist/less.cjs.js +6593 -5448
  4. package/dist/less.js +10 -6
  5. package/dist/less.min.js +2 -2
  6. package/dist/less.min.js.map +1 -1
  7. package/lib/less/constants.js +13 -0
  8. package/lib/less/contexts.js +164 -0
  9. package/lib/less/data/colors.js +150 -0
  10. package/lib/less/data/index.js +4 -0
  11. package/lib/less/data/unit-conversions.js +21 -0
  12. package/lib/less/default-options.js +68 -0
  13. package/lib/less/environment/abstract-file-manager.js +127 -0
  14. package/lib/less/environment/abstract-plugin-loader.js +187 -0
  15. package/lib/less/environment/environment-api.js +25 -0
  16. package/lib/less/environment/environment.js +59 -0
  17. package/lib/less/environment/file-manager-api.js +103 -0
  18. package/lib/less/functions/boolean.js +13 -0
  19. package/lib/less/functions/color-blending.js +84 -0
  20. package/lib/less/functions/color.js +417 -0
  21. package/lib/less/functions/data-uri.js +74 -0
  22. package/lib/less/functions/default.js +25 -0
  23. package/lib/less/functions/function-caller.js +49 -0
  24. package/lib/less/functions/function-registry.js +35 -0
  25. package/lib/less/functions/index.js +33 -0
  26. package/lib/less/functions/list.js +143 -0
  27. package/lib/less/functions/math-helper.js +15 -0
  28. package/lib/less/functions/math.js +28 -0
  29. package/lib/less/functions/number.js +89 -0
  30. package/lib/less/functions/string.js +36 -0
  31. package/lib/less/functions/svg.js +87 -0
  32. package/lib/less/functions/types.js +70 -0
  33. package/lib/less/import-manager.js +169 -0
  34. package/lib/less/index.js +92 -0
  35. package/lib/less/less-error.js +140 -0
  36. package/lib/less/logger.js +34 -0
  37. package/lib/less/parse-tree.js +66 -0
  38. package/lib/less/parse.js +89 -0
  39. package/lib/less/parser/chunker.js +122 -0
  40. package/lib/less/parser/parser-input.js +390 -0
  41. package/lib/less/parser/parser.js +2418 -0
  42. package/lib/less/plugin-manager.js +168 -0
  43. package/lib/less/render.js +42 -0
  44. package/lib/less/source-map-builder.js +77 -0
  45. package/lib/less/source-map-output.js +149 -0
  46. package/lib/less/transform-tree.js +96 -0
  47. package/lib/less/tree/anonymous.js +37 -0
  48. package/lib/less/tree/assignment.js +33 -0
  49. package/lib/less/tree/atrule.js +165 -0
  50. package/lib/less/tree/attribute.js +34 -0
  51. package/lib/less/tree/call.js +105 -0
  52. package/lib/less/tree/color.js +246 -0
  53. package/lib/less/tree/combinator.js +29 -0
  54. package/lib/less/tree/comment.js +29 -0
  55. package/lib/less/tree/condition.js +43 -0
  56. package/lib/less/tree/debug-info.js +34 -0
  57. package/lib/less/tree/declaration.js +115 -0
  58. package/lib/less/tree/detached-ruleset.js +30 -0
  59. package/lib/less/tree/dimension.js +179 -0
  60. package/lib/less/tree/element.js +73 -0
  61. package/lib/less/tree/expression.js +74 -0
  62. package/lib/less/tree/extend.js +66 -0
  63. package/lib/less/tree/import.js +184 -0
  64. package/lib/less/tree/index.js +54 -0
  65. package/lib/less/tree/javascript.js +33 -0
  66. package/lib/less/tree/js-eval-node.js +58 -0
  67. package/lib/less/tree/keyword.js +21 -0
  68. package/lib/less/tree/media.js +154 -0
  69. package/lib/less/tree/mixin-call.js +215 -0
  70. package/lib/less/tree/mixin-definition.js +229 -0
  71. package/lib/less/tree/namespace-value.js +87 -0
  72. package/lib/less/tree/negative.js +26 -0
  73. package/lib/less/tree/node.js +178 -0
  74. package/lib/less/tree/operation.js +62 -0
  75. package/lib/less/tree/paren.js +22 -0
  76. package/lib/less/tree/property.js +77 -0
  77. package/lib/less/tree/quoted.js +70 -0
  78. package/lib/less/tree/ruleset.js +867 -0
  79. package/lib/less/tree/selector.js +146 -0
  80. package/lib/less/tree/unicode-descriptor.js +13 -0
  81. package/lib/less/tree/unit.js +141 -0
  82. package/lib/less/tree/url.js +65 -0
  83. package/lib/less/tree/value.js +44 -0
  84. package/lib/less/tree/variable-call.js +46 -0
  85. package/lib/less/tree/variable.js +67 -0
  86. package/lib/less/utils.js +122 -0
  87. package/lib/less/visitors/extend-visitor.js +505 -0
  88. package/lib/less/visitors/import-sequencer.js +58 -0
  89. package/lib/less/visitors/import-visitor.js +189 -0
  90. package/lib/less/visitors/index.js +15 -0
  91. package/lib/less/visitors/join-selector-visitor.js +57 -0
  92. package/lib/less/visitors/set-tree-visibility-visitor.js +45 -0
  93. package/lib/less/visitors/to-css-visitor.js +363 -0
  94. package/lib/less/visitors/visitor.js +163 -0
  95. package/lib/less-browser/add-default-options.js +49 -0
  96. package/lib/less-browser/bootstrap.js +69 -0
  97. package/lib/less-browser/browser.js +65 -0
  98. package/lib/less-browser/cache.js +43 -0
  99. package/lib/less-browser/error-reporting.js +170 -0
  100. package/lib/less-browser/file-manager.js +113 -0
  101. package/lib/less-browser/image-size.js +28 -0
  102. package/lib/less-browser/index.js +285 -0
  103. package/lib/less-browser/log-listener.js +42 -0
  104. package/lib/less-browser/plugin-loader.js +26 -0
  105. package/lib/less-browser/utils.js +24 -0
  106. package/lib/less-node/environment.js +16 -0
  107. package/lib/less-node/file-manager.js +177 -0
  108. package/lib/less-node/fs.js +10 -0
  109. package/lib/less-node/image-size.js +58 -0
  110. package/lib/less-node/index.js +27 -0
  111. package/lib/less-node/lessc-helper.js +89 -0
  112. package/lib/less-node/plugin-loader.js +53 -0
  113. package/lib/less-node/url-file-manager.js +49 -0
  114. package/lib/lessc.js +557 -0
  115. package/lib/source-map/source-map-0.1.31.js +1933 -0
  116. package/lib/source-map/source-map-footer.js +4 -0
  117. package/lib/source-map/source-map-header.js +3 -0
  118. package/package.json +1 -1
  119. package/test/.DS_Store +0 -0
  120. package/test/browser/less.min.js +11 -0
  121. package/test/browser/less.min.js.map +1 -0
  122. package/test/css/css-escapes.css +1 -0
  123. package/test/less/css-escapes.less +3 -1
  124. package/.git/index +0 -0
@@ -0,0 +1,178 @@
1
+ class Node {
2
+ constructor() {
3
+ this.parent = null;
4
+ this.visibilityBlocks = undefined;
5
+ this.nodeVisible = undefined;
6
+ this.rootNode = null;
7
+ this.parsed = null;
8
+
9
+ const self = this;
10
+ Object.defineProperty(this, 'currentFileInfo', {
11
+ get: function() { return self.fileInfo(); }
12
+ });
13
+ Object.defineProperty(this, 'index', {
14
+ get: function() { return self.getIndex(); }
15
+ });
16
+
17
+ }
18
+
19
+ setParent(nodes, parent) {
20
+ function set(node) {
21
+ if (node && node instanceof Node) {
22
+ node.parent = parent;
23
+ }
24
+ }
25
+ if (Array.isArray(nodes)) {
26
+ nodes.forEach(set);
27
+ }
28
+ else {
29
+ set(nodes);
30
+ }
31
+ }
32
+
33
+ getIndex() {
34
+ return this._index || (this.parent && this.parent.getIndex()) || 0;
35
+ }
36
+
37
+ fileInfo() {
38
+ return this._fileInfo || (this.parent && this.parent.fileInfo()) || {};
39
+ }
40
+
41
+ isRulesetLike() {
42
+ return false;
43
+ }
44
+
45
+ toCSS(context) {
46
+ const strs = [];
47
+ this.genCSS(context, {
48
+ add: function(chunk, fileInfo, index) {
49
+ strs.push(chunk);
50
+ },
51
+ isEmpty: function () {
52
+ return strs.length === 0;
53
+ }
54
+ });
55
+ return strs.join('');
56
+ }
57
+
58
+ genCSS(context, output) {
59
+ output.add(this.value);
60
+ }
61
+
62
+ accept(visitor) {
63
+ this.value = visitor.visit(this.value);
64
+ }
65
+
66
+ eval() { return this; }
67
+
68
+ _operate(context, op, a, b) {
69
+ switch (op) {
70
+ case '+': return a + b;
71
+ case '-': return a - b;
72
+ case '*': return a * b;
73
+ case '/': return a / b;
74
+ }
75
+ }
76
+
77
+ fround(context, value) {
78
+ const precision = context && context.numPrecision;
79
+ // add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded:
80
+ return (precision) ? Number((value + 2e-16).toFixed(precision)) : value;
81
+ }
82
+
83
+ // Returns true if this node represents root of ast imported by reference
84
+ blocksVisibility() {
85
+ if (this.visibilityBlocks == null) {
86
+ this.visibilityBlocks = 0;
87
+ }
88
+ return this.visibilityBlocks !== 0;
89
+ }
90
+
91
+ addVisibilityBlock() {
92
+ if (this.visibilityBlocks == null) {
93
+ this.visibilityBlocks = 0;
94
+ }
95
+ this.visibilityBlocks = this.visibilityBlocks + 1;
96
+ }
97
+
98
+ removeVisibilityBlock() {
99
+ if (this.visibilityBlocks == null) {
100
+ this.visibilityBlocks = 0;
101
+ }
102
+ this.visibilityBlocks = this.visibilityBlocks - 1;
103
+ }
104
+
105
+ // Turns on node visibility - if called node will be shown in output regardless
106
+ // of whether it comes from import by reference or not
107
+ ensureVisibility() {
108
+ this.nodeVisible = true;
109
+ }
110
+
111
+ // Turns off node visibility - if called node will NOT be shown in output regardless
112
+ // of whether it comes from import by reference or not
113
+ ensureInvisibility() {
114
+ this.nodeVisible = false;
115
+ }
116
+
117
+ // return values:
118
+ // false - the node must not be visible
119
+ // true - the node must be visible
120
+ // undefined or null - the node has the same visibility as its parent
121
+ isVisible() {
122
+ return this.nodeVisible;
123
+ }
124
+
125
+ visibilityInfo() {
126
+ return {
127
+ visibilityBlocks: this.visibilityBlocks,
128
+ nodeVisible: this.nodeVisible
129
+ };
130
+ }
131
+
132
+ copyVisibilityInfo(info) {
133
+ if (!info) {
134
+ return;
135
+ }
136
+ this.visibilityBlocks = info.visibilityBlocks;
137
+ this.nodeVisible = info.nodeVisible;
138
+ }
139
+ }
140
+
141
+ Node.compare = (a, b) => {
142
+ /* returns:
143
+ -1: a < b
144
+ 0: a = b
145
+ 1: a > b
146
+ and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */
147
+
148
+ if ((a.compare) &&
149
+ // for "symmetric results" force toCSS-based comparison
150
+ // of Quoted or Anonymous if either value is one of those
151
+ !(b.type === 'Quoted' || b.type === 'Anonymous')) {
152
+ return a.compare(b);
153
+ } else if (b.compare) {
154
+ return -b.compare(a);
155
+ } else if (a.type !== b.type) {
156
+ return undefined;
157
+ }
158
+
159
+ a = a.value;
160
+ b = b.value;
161
+ if (!Array.isArray(a)) {
162
+ return a === b ? 0 : undefined;
163
+ }
164
+ if (a.length !== b.length) {
165
+ return undefined;
166
+ }
167
+ for (let i = 0; i < a.length; i++) {
168
+ if (Node.compare(a[i], b[i]) !== 0) {
169
+ return undefined;
170
+ }
171
+ }
172
+ return 0;
173
+ };
174
+
175
+ Node.numericCompare = (a, b) => a < b ? -1
176
+ : a === b ? 0
177
+ : a > b ? 1 : undefined;
178
+ export default Node;
@@ -0,0 +1,62 @@
1
+ import Node from './node';
2
+ import Color from './color';
3
+ import Dimension from './dimension';
4
+ import * as Constants from '../constants';
5
+ const MATH = Constants.Math;
6
+
7
+
8
+ class Operation extends Node {
9
+ constructor(op, operands, isSpaced) {
10
+ super();
11
+
12
+ this.op = op.trim();
13
+ this.operands = operands;
14
+ this.isSpaced = isSpaced;
15
+ }
16
+
17
+ accept(visitor) {
18
+ this.operands = visitor.visitArray(this.operands);
19
+ }
20
+
21
+ eval(context) {
22
+ let a = this.operands[0].eval(context);
23
+ let b = this.operands[1].eval(context);
24
+ let op;
25
+
26
+ if (context.isMathOn(this.op)) {
27
+ op = this.op === './' ? '/' : this.op;
28
+ if (a instanceof Dimension && b instanceof Color) {
29
+ a = a.toColor();
30
+ }
31
+ if (b instanceof Dimension && a instanceof Color) {
32
+ b = b.toColor();
33
+ }
34
+ if (!a.operate) {
35
+ if (a instanceof Operation && a.op === '/' && context.math === MATH.PARENS_DIVISION) {
36
+ return new Operation(this.op, [a, b], this.isSpaced);
37
+ }
38
+ throw { type: 'Operation',
39
+ message: 'Operation on an invalid type' };
40
+ }
41
+
42
+ return a.operate(context, op, b);
43
+ } else {
44
+ return new Operation(this.op, [a, b], this.isSpaced);
45
+ }
46
+ }
47
+
48
+ genCSS(context, output) {
49
+ this.operands[0].genCSS(context, output);
50
+ if (this.isSpaced) {
51
+ output.add(' ');
52
+ }
53
+ output.add(this.op);
54
+ if (this.isSpaced) {
55
+ output.add(' ');
56
+ }
57
+ this.operands[1].genCSS(context, output);
58
+ }
59
+ }
60
+
61
+ Operation.prototype.type = 'Operation';
62
+ export default Operation;
@@ -0,0 +1,22 @@
1
+ import Node from './node';
2
+
3
+ class Paren extends Node {
4
+ constructor(node) {
5
+ super();
6
+
7
+ this.value = node;
8
+ }
9
+
10
+ genCSS(context, output) {
11
+ output.add('(');
12
+ this.value.genCSS(context, output);
13
+ output.add(')');
14
+ }
15
+
16
+ eval(context) {
17
+ return new Paren(this.value.eval(context));
18
+ }
19
+ }
20
+
21
+ Paren.prototype.type = 'Paren';
22
+ export default Paren;
@@ -0,0 +1,77 @@
1
+ import Node from './node';
2
+ import Declaration from './declaration';
3
+
4
+ class Property extends Node {
5
+ constructor(name, index, currentFileInfo) {
6
+ super();
7
+
8
+ this.name = name;
9
+ this._index = index;
10
+ this._fileInfo = currentFileInfo;
11
+ }
12
+
13
+ eval(context) {
14
+ let property;
15
+ const name = this.name;
16
+ // TODO: shorten this reference
17
+ const mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;
18
+
19
+ if (this.evaluating) {
20
+ throw { type: 'Name',
21
+ message: `Recursive property reference for ${name}`,
22
+ filename: this.fileInfo().filename,
23
+ index: this.getIndex() };
24
+ }
25
+
26
+ this.evaluating = true;
27
+
28
+ property = this.find(context.frames, frame => {
29
+ let v;
30
+ const vArr = frame.property(name);
31
+ if (vArr) {
32
+ for (let i = 0; i < vArr.length; i++) {
33
+ v = vArr[i];
34
+
35
+ vArr[i] = new Declaration(v.name,
36
+ v.value,
37
+ v.important,
38
+ v.merge,
39
+ v.index,
40
+ v.currentFileInfo,
41
+ v.inline,
42
+ v.variable
43
+ );
44
+ }
45
+ mergeRules(vArr);
46
+
47
+ v = vArr[vArr.length - 1];
48
+ if (v.important) {
49
+ const importantScope = context.importantScope[context.importantScope.length - 1];
50
+ importantScope.important = v.important;
51
+ }
52
+ v = v.value.eval(context);
53
+ return v;
54
+ }
55
+ });
56
+ if (property) {
57
+ this.evaluating = false;
58
+ return property;
59
+ } else {
60
+ throw { type: 'Name',
61
+ message: `Property '${name}' is undefined`,
62
+ filename: this.currentFileInfo.filename,
63
+ index: this.index };
64
+ }
65
+ }
66
+
67
+ find(obj, fun) {
68
+ for (let i = 0, r; i < obj.length; i++) {
69
+ r = fun.call(obj, obj[i]);
70
+ if (r) { return r; }
71
+ }
72
+ return null;
73
+ }
74
+ }
75
+
76
+ Property.prototype.type = 'Property';
77
+ export default Property;
@@ -0,0 +1,70 @@
1
+ import Node from './node';
2
+ import Variable from './variable';
3
+ import Property from './property';
4
+
5
+
6
+ class Quoted extends Node {
7
+ constructor(str, content, escaped, index, currentFileInfo) {
8
+ super();
9
+
10
+ this.escaped = (escaped == null) ? true : escaped;
11
+ this.value = content || '';
12
+ this.quote = str.charAt(0);
13
+ this._index = index;
14
+ this._fileInfo = currentFileInfo;
15
+ this.variableRegex = /@\{([\w-]+)\}/g;
16
+ this.propRegex = /\$\{([\w-]+)\}/g;
17
+ this.allowRoot = escaped;
18
+ }
19
+
20
+ genCSS(context, output) {
21
+ if (!this.escaped) {
22
+ output.add(this.quote, this.fileInfo(), this.getIndex());
23
+ }
24
+ output.add(this.value);
25
+ if (!this.escaped) {
26
+ output.add(this.quote);
27
+ }
28
+ }
29
+
30
+ containsVariables() {
31
+ return this.value.match(this.variableRegex);
32
+ }
33
+
34
+ eval(context) {
35
+ const that = this;
36
+ let value = this.value;
37
+ const variableReplacement = (_, name) => {
38
+ const v = new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context, true);
39
+ return (v instanceof Quoted) ? v.value : v.toCSS();
40
+ };
41
+ const propertyReplacement = (_, name) => {
42
+ const v = new Property(`$${name}`, that.getIndex(), that.fileInfo()).eval(context, true);
43
+ return (v instanceof Quoted) ? v.value : v.toCSS();
44
+ };
45
+ function iterativeReplace(value, regexp, replacementFnc) {
46
+ let evaluatedValue = value;
47
+ do {
48
+ value = evaluatedValue.toString();
49
+ evaluatedValue = value.replace(regexp, replacementFnc);
50
+ } while (value !== evaluatedValue);
51
+ return evaluatedValue;
52
+ }
53
+ value = iterativeReplace(value, this.variableRegex, variableReplacement);
54
+ value = iterativeReplace(value, this.propRegex, propertyReplacement);
55
+
56
+ return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());
57
+ }
58
+
59
+ compare(other) {
60
+ // when comparing quoted strings allow the quote to differ
61
+ if (other.type === 'Quoted' && !this.escaped && !other.escaped) {
62
+ return Node.numericCompare(this.value, other.value);
63
+ } else {
64
+ return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;
65
+ }
66
+ }
67
+ }
68
+
69
+ Quoted.prototype.type = 'Quoted';
70
+ export default Quoted;