less 4.9.1 → 5.0.0-alpha.10

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 (134) hide show
  1. package/README.md +23 -5
  2. package/V5-STATUS.md +71 -0
  3. package/bin/lessc +302 -626
  4. package/dist/less-browser-dev.js +2550 -0
  5. package/dist/less-node.cjs +480 -14561
  6. package/index.cjs +5 -2
  7. package/lib/browser-dev.js +86 -0
  8. package/lib/index.js +164 -0
  9. package/lib/lessc-helper.js +64 -0
  10. package/lib/logger.js +76 -0
  11. package/lib/options.d.ts +82 -0
  12. package/lib/options.js +227 -0
  13. package/lib/types.js +20 -0
  14. package/lib/version.js +19 -0
  15. package/package.json +36 -40
  16. package/dist/less.cjs +0 -15218
  17. package/dist/less.js +0 -15218
  18. package/dist/less.min.js +0 -11
  19. package/dist/less.min.js.map +0 -1
  20. package/lib/less/constants.js +0 -13
  21. package/lib/less/contexts.js +0 -165
  22. package/lib/less/data/colors.js +0 -150
  23. package/lib/less/data/index.js +0 -4
  24. package/lib/less/data/unit-conversions.js +0 -21
  25. package/lib/less/default-options.js +0 -89
  26. package/lib/less/deprecation.js +0 -82
  27. package/lib/less/environment/abstract-file-manager.js +0 -140
  28. package/lib/less/environment/abstract-plugin-loader.js +0 -185
  29. package/lib/less/environment/environment-api.ts +0 -21
  30. package/lib/less/environment/environment.js +0 -59
  31. package/lib/less/environment/file-manager-api.ts +0 -77
  32. package/lib/less/functions/boolean.js +0 -29
  33. package/lib/less/functions/color-blending.js +0 -85
  34. package/lib/less/functions/color.js +0 -452
  35. package/lib/less/functions/data-uri.js +0 -74
  36. package/lib/less/functions/default.js +0 -26
  37. package/lib/less/functions/function-caller.js +0 -55
  38. package/lib/less/functions/function-registry.js +0 -36
  39. package/lib/less/functions/index.js +0 -35
  40. package/lib/less/functions/list.js +0 -158
  41. package/lib/less/functions/math-helper.js +0 -22
  42. package/lib/less/functions/math.js +0 -30
  43. package/lib/less/functions/number.js +0 -95
  44. package/lib/less/functions/string.js +0 -39
  45. package/lib/less/functions/style.js +0 -29
  46. package/lib/less/functions/svg.js +0 -87
  47. package/lib/less/functions/types.js +0 -70
  48. package/lib/less/import-manager.js +0 -183
  49. package/lib/less/index.js +0 -95
  50. package/lib/less/less-error.js +0 -166
  51. package/lib/less/logger.js +0 -34
  52. package/lib/less/parse-tree.js +0 -124
  53. package/lib/less/parse.js +0 -87
  54. package/lib/less/parser/lookup-pattern.js +0 -26
  55. package/lib/less/parser/parser-input.js +0 -400
  56. package/lib/less/parser/parser.js +0 -2998
  57. package/lib/less/plugin-manager.js +0 -168
  58. package/lib/less/render.js +0 -41
  59. package/lib/less/source-map-builder.js +0 -82
  60. package/lib/less/source-map-output.js +0 -151
  61. package/lib/less/transform-tree.js +0 -102
  62. package/lib/less/tree/anonymous.js +0 -61
  63. package/lib/less/tree/assignment.js +0 -48
  64. package/lib/less/tree/atrule-syntax.js +0 -8
  65. package/lib/less/tree/atrule.js +0 -340
  66. package/lib/less/tree/attribute.js +0 -63
  67. package/lib/less/tree/call.js +0 -132
  68. package/lib/less/tree/color.js +0 -285
  69. package/lib/less/tree/combinator.js +0 -38
  70. package/lib/less/tree/comment.js +0 -48
  71. package/lib/less/tree/condition.js +0 -65
  72. package/lib/less/tree/container.js +0 -104
  73. package/lib/less/tree/debug-info.js +0 -80
  74. package/lib/less/tree/declaration.js +0 -142
  75. package/lib/less/tree/detached-ruleset.js +0 -45
  76. package/lib/less/tree/dimension.js +0 -215
  77. package/lib/less/tree/element.js +0 -93
  78. package/lib/less/tree/expression.js +0 -100
  79. package/lib/less/tree/extend.js +0 -88
  80. package/lib/less/tree/import.js +0 -299
  81. package/lib/less/tree/index.js +0 -56
  82. package/lib/less/tree/interpolated-variable.js +0 -106
  83. package/lib/less/tree/javascript.js +0 -45
  84. package/lib/less/tree/js-eval-node.js +0 -80
  85. package/lib/less/tree/keyword.js +0 -28
  86. package/lib/less/tree/media.js +0 -90
  87. package/lib/less/tree/merge-rules.js +0 -47
  88. package/lib/less/tree/mixin-call.js +0 -283
  89. package/lib/less/tree/mixin-definition.js +0 -319
  90. package/lib/less/tree/namespace-value.js +0 -95
  91. package/lib/less/tree/negative.js +0 -37
  92. package/lib/less/tree/nested-at-rule.js +0 -239
  93. package/lib/less/tree/node.js +0 -310
  94. package/lib/less/tree/operation.js +0 -81
  95. package/lib/less/tree/paren.js +0 -41
  96. package/lib/less/tree/property.js +0 -96
  97. package/lib/less/tree/query-in-parens.js +0 -64
  98. package/lib/less/tree/quoted.js +0 -131
  99. package/lib/less/tree/ruleset.js +0 -1068
  100. package/lib/less/tree/selector.js +0 -201
  101. package/lib/less/tree/unicode-descriptor.js +0 -14
  102. package/lib/less/tree/unit.js +0 -170
  103. package/lib/less/tree/url.js +0 -83
  104. package/lib/less/tree/value.js +0 -60
  105. package/lib/less/tree/variable-call.js +0 -60
  106. package/lib/less/tree/variable.js +0 -85
  107. package/lib/less/utils.js +0 -126
  108. package/lib/less/visitors/extend-visitor.js +0 -505
  109. package/lib/less/visitors/import-sequencer.js +0 -56
  110. package/lib/less/visitors/import-visitor.js +0 -203
  111. package/lib/less/visitors/index.js +0 -15
  112. package/lib/less/visitors/join-selector-visitor.js +0 -65
  113. package/lib/less/visitors/set-tree-visibility-visitor.js +0 -57
  114. package/lib/less/visitors/to-css-visitor.js +0 -332
  115. package/lib/less/visitors/visitor.js +0 -165
  116. package/lib/less-browser/add-default-options.js +0 -53
  117. package/lib/less-browser/bootstrap.js +0 -67
  118. package/lib/less-browser/browser.js +0 -65
  119. package/lib/less-browser/cache.js +0 -43
  120. package/lib/less-browser/error-reporting.js +0 -170
  121. package/lib/less-browser/file-manager.js +0 -112
  122. package/lib/less-browser/image-size.js +0 -28
  123. package/lib/less-browser/index.js +0 -284
  124. package/lib/less-browser/log-listener.js +0 -42
  125. package/lib/less-browser/plugin-loader.js +0 -24
  126. package/lib/less-browser/utils.js +0 -30
  127. package/lib/less-node/environment.js +0 -43
  128. package/lib/less-node/file-manager.js +0 -156
  129. package/lib/less-node/fs.js +0 -14
  130. package/lib/less-node/image-size.js +0 -78
  131. package/lib/less-node/index.js +0 -31
  132. package/lib/less-node/lessc-helper.js +0 -95
  133. package/lib/less-node/plugin-loader.js +0 -62
  134. package/lib/less-node/url-file-manager.js +0 -60
@@ -1,310 +0,0 @@
1
- // @ts-check
2
- /**
3
- * @typedef {object} FileInfo
4
- * @property {string} [filename]
5
- * @property {string} [rootpath]
6
- * @property {string} [currentDirectory]
7
- * @property {string} [rootFilename]
8
- * @property {string} [entryPath]
9
- * @property {boolean} [reference]
10
- */
11
-
12
- /**
13
- * @typedef {object} VisibilityInfo
14
- * @property {number} [visibilityBlocks]
15
- * @property {boolean} [nodeVisible]
16
- */
17
-
18
- /**
19
- * @typedef {object} CSSOutput
20
- * @property {(chunk: string, fileInfo?: FileInfo, index?: number, mapLines?: boolean) => void} add
21
- * @property {() => boolean} isEmpty
22
- */
23
-
24
- /**
25
- * @typedef {object} EvalContext
26
- * @property {number} [numPrecision]
27
- * @property {(op?: string) => boolean} [isMathOn]
28
- * @property {number} [math]
29
- * @property {Node[]} [frames]
30
- * @property {Array<{important?: string}>} [importantScope]
31
- * @property {string[]} [paths]
32
- * @property {boolean} [compress]
33
- * @property {boolean} [strictUnits]
34
- * @property {boolean} [sourceMap]
35
- * @property {boolean} [importMultiple]
36
- * @property {string} [urlArgs]
37
- * @property {boolean} [javascriptEnabled]
38
- * @property {object} [pluginManager]
39
- * @property {number} [rewriteUrls]
40
- * @property {boolean} [inCalc]
41
- * @property {boolean} [mathOn]
42
- * @property {boolean[]} [calcStack]
43
- * @property {boolean[]} [parensStack]
44
- * @property {Node[]} [mediaBlocks]
45
- * @property {Node[]} [mediaPath]
46
- * @property {() => void} [inParenthesis]
47
- * @property {() => void} [outOfParenthesis]
48
- * @property {() => void} [enterCalc]
49
- * @property {() => void} [exitCalc]
50
- * @property {(path: string) => boolean} [pathRequiresRewrite]
51
- * @property {(path: string, rootpath?: string) => string} [rewritePath]
52
- * @property {(path: string) => string} [normalizePath]
53
- * @property {number} [tabLevel]
54
- * @property {boolean} [lastRule]
55
- */
56
-
57
- /**
58
- * @typedef {object} TreeVisitor
59
- * @property {(node: Node) => Node} visit
60
- * @property {(nodes: Node[], nonReplacing?: boolean) => Node[]} visitArray
61
- */
62
-
63
- /**
64
- * The reason why Node is a class and other nodes simply do not extend
65
- * from Node (since we're transpiling) is due to this issue:
66
- *
67
- * @see https://github.com/less/less.js/issues/3434
68
- */
69
- class Node {
70
- get type() { return ''; }
71
-
72
- constructor() {
73
- /** @type {Node | null} */
74
- this.parent = null;
75
- /** @type {number | undefined} */
76
- this.visibilityBlocks = undefined;
77
- /** @type {boolean | undefined} */
78
- this.nodeVisible = undefined;
79
- /** @type {Node | null} */
80
- this.rootNode = null;
81
- /** @type {Node | null} */
82
- this.parsed = null;
83
-
84
- /** @type {Node | Node[] | string | number | undefined} */
85
- this.value = undefined;
86
- /** @type {number | undefined} */
87
- this._index = undefined;
88
- /** @type {FileInfo | undefined} */
89
- this._fileInfo = undefined;
90
- }
91
-
92
- get currentFileInfo() {
93
- return this.fileInfo();
94
- }
95
-
96
- get index() {
97
- return this.getIndex();
98
- }
99
-
100
- /**
101
- * @param {Node | Node[]} nodes
102
- * @param {Node} parent
103
- */
104
- setParent(nodes, parent) {
105
- /** @param {Node} node */
106
- function set(node) {
107
- if (node && node instanceof Node) {
108
- node.parent = parent;
109
- }
110
- }
111
- if (Array.isArray(nodes)) {
112
- nodes.forEach(set);
113
- }
114
- else {
115
- set(nodes);
116
- }
117
- }
118
-
119
- /** @returns {number} */
120
- getIndex() {
121
- return this._index || (this.parent && this.parent.getIndex()) || 0;
122
- }
123
-
124
- /** @returns {FileInfo} */
125
- fileInfo() {
126
- return this._fileInfo || (this.parent && this.parent.fileInfo()) || {};
127
- }
128
-
129
- /** @returns {boolean} */
130
- isRulesetLike() { return false; }
131
-
132
- /**
133
- * @param {EvalContext} context
134
- * @returns {string}
135
- */
136
- toCSS(context) {
137
- /** @type {string[]} */
138
- const strs = [];
139
- this.genCSS(context, {
140
- add: function(chunk, fileInfo, index) {
141
- strs.push(chunk);
142
- },
143
- isEmpty: function () {
144
- return strs.length === 0;
145
- }
146
- });
147
- return strs.join('');
148
- }
149
-
150
- /**
151
- * @param {EvalContext} context
152
- * @param {CSSOutput} output
153
- */
154
- genCSS(context, output) {
155
- output.add(/** @type {string} */ (this.value));
156
- }
157
-
158
- /**
159
- * @param {TreeVisitor} visitor
160
- */
161
- accept(visitor) {
162
- this.value = visitor.visit(/** @type {Node} */ (this.value));
163
- }
164
-
165
- /**
166
- * @param {EvalContext} [context]
167
- * @returns {Node}
168
- */
169
- eval(context) { return this; }
170
-
171
- /**
172
- * @param {EvalContext} context
173
- * @param {string} op
174
- * @param {number} a
175
- * @param {number} b
176
- * @returns {number | undefined}
177
- */
178
- _operate(context, op, a, b) {
179
- switch (op) {
180
- case '+': return a + b;
181
- case '-': return a - b;
182
- case '*': return a * b;
183
- case '/': return a / b;
184
- }
185
- }
186
-
187
- /**
188
- * @param {EvalContext} context
189
- * @param {number} value
190
- * @returns {number}
191
- */
192
- fround(context, value) {
193
- const precision = context && context.numPrecision;
194
- // add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded:
195
- return (precision) ? Number((value + 2e-16).toFixed(precision)) : value;
196
- }
197
-
198
- /**
199
- * @param {Node & { compare?: (other: Node) => number | undefined }} a
200
- * @param {Node & { compare?: (other: Node) => number | undefined }} b
201
- * @returns {number | undefined}
202
- */
203
- static compare(a, b) {
204
- /* returns:
205
- -1: a < b
206
- 0: a = b
207
- 1: a > b
208
- and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */
209
-
210
- if ((a.compare) &&
211
- // for "symmetric results" force toCSS-based comparison
212
- // of Quoted or Anonymous if either value is one of those
213
- !(b.type === 'Quoted' || b.type === 'Anonymous')) {
214
- return a.compare(b);
215
- } else if (b.compare) {
216
- return -b.compare(a);
217
- } else if (a.type !== b.type) {
218
- return undefined;
219
- }
220
-
221
- let aVal = a.value;
222
- let bVal = b.value;
223
- if (!Array.isArray(aVal)) {
224
- return aVal === bVal ? 0 : undefined;
225
- }
226
- if (!Array.isArray(bVal)) {
227
- return undefined;
228
- }
229
- if (aVal.length !== bVal.length) {
230
- return undefined;
231
- }
232
- for (let i = 0; i < aVal.length; i++) {
233
- if (Node.compare(aVal[i], bVal[i]) !== 0) {
234
- return undefined;
235
- }
236
- }
237
- return 0;
238
- }
239
-
240
- /**
241
- * @param {number | string} a
242
- * @param {number | string} b
243
- * @returns {number | undefined}
244
- */
245
- static numericCompare(a, b) {
246
- return a < b ? -1
247
- : a === b ? 0
248
- : a > b ? 1 : undefined;
249
- }
250
-
251
- /** @returns {boolean} */
252
- blocksVisibility() {
253
- if (this.visibilityBlocks === undefined) {
254
- this.visibilityBlocks = 0;
255
- }
256
- return this.visibilityBlocks !== 0;
257
- }
258
-
259
- addVisibilityBlock() {
260
- if (this.visibilityBlocks === undefined) {
261
- this.visibilityBlocks = 0;
262
- }
263
- this.visibilityBlocks = this.visibilityBlocks + 1;
264
- }
265
-
266
- removeVisibilityBlock() {
267
- if (this.visibilityBlocks === undefined) {
268
- this.visibilityBlocks = 0;
269
- }
270
- this.visibilityBlocks = this.visibilityBlocks - 1;
271
- }
272
-
273
- ensureVisibility() {
274
- this.nodeVisible = true;
275
- }
276
-
277
- ensureInvisibility() {
278
- this.nodeVisible = false;
279
- }
280
-
281
- /** @returns {boolean | undefined} */
282
- isVisible() {
283
- return this.nodeVisible;
284
- }
285
-
286
- /** @returns {VisibilityInfo} */
287
- visibilityInfo() {
288
- return {
289
- visibilityBlocks: this.visibilityBlocks,
290
- nodeVisible: this.nodeVisible
291
- };
292
- }
293
-
294
- /** @param {VisibilityInfo} info */
295
- copyVisibilityInfo(info) {
296
- if (!info) {
297
- return;
298
- }
299
- this.visibilityBlocks = info.visibilityBlocks;
300
- this.nodeVisible = info.nodeVisible;
301
- }
302
- }
303
-
304
- /**
305
- * Set by the parser at runtime on Node.prototype.
306
- * @type {{ context: EvalContext, importManager: object, imports: object } | undefined}
307
- */
308
- Node.prototype.parse = undefined;
309
-
310
- export default Node;
@@ -1,81 +0,0 @@
1
- // @ts-check
2
- /** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */
3
- import Node from './node.js';
4
- import Color from './color.js';
5
- import Dimension from './dimension.js';
6
- import * as Constants from '../constants.js';
7
- const MATH = Constants.Math;
8
-
9
- class Operation extends Node {
10
- get type() { return 'Operation'; }
11
-
12
- /**
13
- * @param {string} op
14
- * @param {Node[]} operands
15
- * @param {boolean} isSpaced
16
- */
17
- constructor(op, operands, isSpaced) {
18
- super();
19
- this.op = op.trim();
20
- this.operands = operands;
21
- this.isSpaced = isSpaced;
22
- }
23
-
24
- /** @param {TreeVisitor} visitor */
25
- accept(visitor) {
26
- this.operands = visitor.visitArray(this.operands);
27
- }
28
-
29
- /**
30
- * @param {EvalContext} context
31
- * @returns {Node}
32
- */
33
- eval(context) {
34
- let a = this.operands[0].eval(context), b = this.operands[1].eval(context), op;
35
-
36
- if (context.isMathOn(this.op)) {
37
- op = this.op === './' ? '/' : this.op;
38
- if (a instanceof Dimension && b instanceof Color) {
39
- a = /** @type {Dimension} */ (a).toColor();
40
- }
41
- if (b instanceof Dimension && a instanceof Color) {
42
- b = /** @type {Dimension} */ (b).toColor();
43
- }
44
- if (!/** @type {Dimension | Color} */ (a).operate || !/** @type {Dimension | Color} */ (b).operate) {
45
- if (
46
- (a instanceof Operation || b instanceof Operation)
47
- && /** @type {Operation} */ (a).op === '/' && context.math === MATH.PARENS_DIVISION
48
- ) {
49
- return new Operation(this.op, [a, b], this.isSpaced);
50
- }
51
- throw { type: 'Operation',
52
- message: 'Operation on an invalid type' };
53
- }
54
-
55
- if (a instanceof Dimension) {
56
- return a.operate(context, op, /** @type {Dimension} */ (b));
57
- }
58
- return /** @type {Color} */ (a).operate(context, op, /** @type {Color} */ (b));
59
- } else {
60
- return new Operation(this.op, [a, b], this.isSpaced);
61
- }
62
- }
63
-
64
- /**
65
- * @param {EvalContext} context
66
- * @param {CSSOutput} output
67
- */
68
- genCSS(context, output) {
69
- this.operands[0].genCSS(context, output);
70
- if (this.isSpaced) {
71
- output.add(' ');
72
- }
73
- output.add(this.op);
74
- if (this.isSpaced) {
75
- output.add(' ');
76
- }
77
- this.operands[1].genCSS(context, output);
78
- }
79
- }
80
-
81
- export default Operation;
@@ -1,41 +0,0 @@
1
- // @ts-check
2
- /** @import { EvalContext, CSSOutput } from './node.js' */
3
- import Node from './node.js';
4
-
5
- class Paren extends Node {
6
- get type() { return 'Paren'; }
7
-
8
- /** @param {Node} node */
9
- constructor(node) {
10
- super();
11
- this.value = node;
12
- /** @type {boolean | undefined} */
13
- this.noSpacing = undefined;
14
- }
15
-
16
- /**
17
- * @param {EvalContext} context
18
- * @param {CSSOutput} output
19
- */
20
- genCSS(context, output) {
21
- output.add('(');
22
- /** @type {Node} */ (this.value).genCSS(context, output);
23
- output.add(')');
24
- }
25
-
26
- /**
27
- * @param {EvalContext} context
28
- * @returns {Paren}
29
- */
30
- eval(context) {
31
- const paren = new Paren(/** @type {Node} */ (this.value).eval(context));
32
-
33
- if (this.noSpacing) {
34
- paren.noSpacing = true;
35
- }
36
-
37
- return paren;
38
- }
39
- }
40
-
41
- export default Paren;
@@ -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;