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.
Files changed (129) hide show
  1. package/README.md +19 -5
  2. package/bin/lessc +190 -630
  3. package/dist/less-node.cjs +398 -14282
  4. package/index.cjs +5 -2
  5. package/lib/index.js +164 -0
  6. package/lib/lessc-helper.js +52 -0
  7. package/lib/logger.js +76 -0
  8. package/lib/options.d.ts +46 -0
  9. package/lib/options.js +145 -0
  10. package/lib/types.js +20 -0
  11. package/lib/version.js +19 -0
  12. package/package.json +33 -40
  13. package/dist/less.cjs +0 -14929
  14. package/dist/less.js +0 -14929
  15. package/dist/less.min.js +0 -11
  16. package/dist/less.min.js.map +0 -1
  17. package/lib/less/constants.js +0 -13
  18. package/lib/less/contexts.js +0 -165
  19. package/lib/less/data/colors.js +0 -150
  20. package/lib/less/data/index.js +0 -4
  21. package/lib/less/data/unit-conversions.js +0 -21
  22. package/lib/less/default-options.js +0 -89
  23. package/lib/less/deprecation.js +0 -82
  24. package/lib/less/environment/abstract-file-manager.js +0 -140
  25. package/lib/less/environment/abstract-plugin-loader.js +0 -185
  26. package/lib/less/environment/environment-api.ts +0 -21
  27. package/lib/less/environment/environment.js +0 -59
  28. package/lib/less/environment/file-manager-api.ts +0 -77
  29. package/lib/less/functions/boolean.js +0 -29
  30. package/lib/less/functions/color-blending.js +0 -85
  31. package/lib/less/functions/color.js +0 -452
  32. package/lib/less/functions/data-uri.js +0 -74
  33. package/lib/less/functions/default.js +0 -26
  34. package/lib/less/functions/function-caller.js +0 -55
  35. package/lib/less/functions/function-registry.js +0 -36
  36. package/lib/less/functions/index.js +0 -35
  37. package/lib/less/functions/list.js +0 -158
  38. package/lib/less/functions/math-helper.js +0 -22
  39. package/lib/less/functions/math.js +0 -30
  40. package/lib/less/functions/number.js +0 -95
  41. package/lib/less/functions/string.js +0 -36
  42. package/lib/less/functions/style.js +0 -29
  43. package/lib/less/functions/svg.js +0 -87
  44. package/lib/less/functions/types.js +0 -70
  45. package/lib/less/import-manager.js +0 -183
  46. package/lib/less/index.js +0 -95
  47. package/lib/less/less-error.js +0 -166
  48. package/lib/less/logger.js +0 -34
  49. package/lib/less/parse-tree.js +0 -124
  50. package/lib/less/parse.js +0 -87
  51. package/lib/less/parser/parser-input.js +0 -400
  52. package/lib/less/parser/parser.js +0 -2894
  53. package/lib/less/plugin-manager.js +0 -168
  54. package/lib/less/render.js +0 -41
  55. package/lib/less/source-map-builder.js +0 -82
  56. package/lib/less/source-map-output.js +0 -151
  57. package/lib/less/transform-tree.js +0 -102
  58. package/lib/less/tree/anonymous.js +0 -57
  59. package/lib/less/tree/assignment.js +0 -48
  60. package/lib/less/tree/atrule-syntax.js +0 -8
  61. package/lib/less/tree/atrule.js +0 -340
  62. package/lib/less/tree/attribute.js +0 -63
  63. package/lib/less/tree/call.js +0 -132
  64. package/lib/less/tree/color.js +0 -285
  65. package/lib/less/tree/combinator.js +0 -38
  66. package/lib/less/tree/comment.js +0 -48
  67. package/lib/less/tree/condition.js +0 -65
  68. package/lib/less/tree/container.js +0 -104
  69. package/lib/less/tree/debug-info.js +0 -80
  70. package/lib/less/tree/declaration.js +0 -139
  71. package/lib/less/tree/detached-ruleset.js +0 -45
  72. package/lib/less/tree/dimension.js +0 -215
  73. package/lib/less/tree/element.js +0 -93
  74. package/lib/less/tree/expression.js +0 -100
  75. package/lib/less/tree/extend.js +0 -88
  76. package/lib/less/tree/import.js +0 -299
  77. package/lib/less/tree/index.js +0 -56
  78. package/lib/less/tree/javascript.js +0 -45
  79. package/lib/less/tree/js-eval-node.js +0 -74
  80. package/lib/less/tree/keyword.js +0 -28
  81. package/lib/less/tree/media.js +0 -90
  82. package/lib/less/tree/merge-rules.js +0 -47
  83. package/lib/less/tree/mixin-call.js +0 -283
  84. package/lib/less/tree/mixin-definition.js +0 -319
  85. package/lib/less/tree/namespace-value.js +0 -95
  86. package/lib/less/tree/negative.js +0 -37
  87. package/lib/less/tree/nested-at-rule.js +0 -198
  88. package/lib/less/tree/node.js +0 -310
  89. package/lib/less/tree/operation.js +0 -81
  90. package/lib/less/tree/paren.js +0 -41
  91. package/lib/less/tree/property.js +0 -96
  92. package/lib/less/tree/query-in-parens.js +0 -64
  93. package/lib/less/tree/quoted.js +0 -114
  94. package/lib/less/tree/ruleset.js +0 -1066
  95. package/lib/less/tree/selector.js +0 -201
  96. package/lib/less/tree/unicode-descriptor.js +0 -14
  97. package/lib/less/tree/unit.js +0 -170
  98. package/lib/less/tree/url.js +0 -83
  99. package/lib/less/tree/value.js +0 -60
  100. package/lib/less/tree/variable-call.js +0 -60
  101. package/lib/less/tree/variable.js +0 -85
  102. package/lib/less/utils.js +0 -126
  103. package/lib/less/visitors/extend-visitor.js +0 -505
  104. package/lib/less/visitors/import-sequencer.js +0 -56
  105. package/lib/less/visitors/import-visitor.js +0 -203
  106. package/lib/less/visitors/index.js +0 -15
  107. package/lib/less/visitors/join-selector-visitor.js +0 -65
  108. package/lib/less/visitors/set-tree-visibility-visitor.js +0 -57
  109. package/lib/less/visitors/to-css-visitor.js +0 -332
  110. package/lib/less/visitors/visitor.js +0 -165
  111. package/lib/less-browser/add-default-options.js +0 -53
  112. package/lib/less-browser/bootstrap.js +0 -67
  113. package/lib/less-browser/browser.js +0 -65
  114. package/lib/less-browser/cache.js +0 -43
  115. package/lib/less-browser/error-reporting.js +0 -170
  116. package/lib/less-browser/file-manager.js +0 -112
  117. package/lib/less-browser/image-size.js +0 -28
  118. package/lib/less-browser/index.js +0 -284
  119. package/lib/less-browser/log-listener.js +0 -42
  120. package/lib/less-browser/plugin-loader.js +0 -24
  121. package/lib/less-browser/utils.js +0 -30
  122. package/lib/less-node/environment.js +0 -43
  123. package/lib/less-node/file-manager.js +0 -156
  124. package/lib/less-node/fs.js +0 -14
  125. package/lib/less-node/image-size.js +0 -78
  126. package/lib/less-node/index.js +0 -31
  127. package/lib/less-node/lessc-helper.js +0 -95
  128. package/lib/less-node/plugin-loader.js +0 -62
  129. package/lib/less-node/url-file-manager.js +0 -60
@@ -1,168 +0,0 @@
1
- /**
2
- * Plugin Manager
3
- */
4
- class PluginManager {
5
- constructor(less) {
6
- this.less = less;
7
- this.visitors = [];
8
- this.preProcessors = [];
9
- this.postProcessors = [];
10
- this.installedPlugins = [];
11
- this.fileManagers = [];
12
- this.iterator = -1;
13
- this.pluginCache = {};
14
- this.Loader = new less.PluginLoader(less);
15
- }
16
-
17
- /**
18
- * Adds all the plugins in the array
19
- * @param {Array} plugins
20
- */
21
- addPlugins(plugins) {
22
- if (plugins) {
23
- for (let i = 0; i < plugins.length; i++) {
24
- this.addPlugin(plugins[i]);
25
- }
26
- }
27
- }
28
-
29
- /**
30
- *
31
- * @param plugin
32
- * @param {String} filename
33
- */
34
- addPlugin(plugin, filename, functionRegistry) {
35
- this.installedPlugins.push(plugin);
36
- if (filename) {
37
- this.pluginCache[filename] = plugin;
38
- }
39
- if (plugin.install) {
40
- plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);
41
- }
42
- }
43
-
44
- /**
45
- *
46
- * @param filename
47
- */
48
- get(filename) {
49
- return this.pluginCache[filename];
50
- }
51
-
52
- /**
53
- * Adds a visitor. The visitor object has options on itself to determine
54
- * when it should run.
55
- * @param visitor
56
- */
57
- addVisitor(visitor) {
58
- this.visitors.push(visitor);
59
- }
60
-
61
- /**
62
- * Adds a pre processor object
63
- * @param {object} preProcessor
64
- * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import
65
- */
66
- addPreProcessor(preProcessor, priority) {
67
- let indexToInsertAt;
68
- for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {
69
- if (this.preProcessors[indexToInsertAt].priority >= priority) {
70
- break;
71
- }
72
- }
73
- this.preProcessors.splice(indexToInsertAt, 0, {preProcessor, priority});
74
- }
75
-
76
- /**
77
- * Adds a post processor object
78
- * @param {object} postProcessor
79
- * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression
80
- */
81
- addPostProcessor(postProcessor, priority) {
82
- let indexToInsertAt;
83
- for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {
84
- if (this.postProcessors[indexToInsertAt].priority >= priority) {
85
- break;
86
- }
87
- }
88
- this.postProcessors.splice(indexToInsertAt, 0, {postProcessor, priority});
89
- }
90
-
91
- /**
92
- *
93
- * @param manager
94
- */
95
- addFileManager(manager) {
96
- this.fileManagers.push(manager);
97
- }
98
-
99
- /**
100
- *
101
- * @returns {Array}
102
- * @private
103
- */
104
- getPreProcessors() {
105
- const preProcessors = [];
106
- for (let i = 0; i < this.preProcessors.length; i++) {
107
- preProcessors.push(this.preProcessors[i].preProcessor);
108
- }
109
- return preProcessors;
110
- }
111
-
112
- /**
113
- *
114
- * @returns {Array}
115
- * @private
116
- */
117
- getPostProcessors() {
118
- const postProcessors = [];
119
- for (let i = 0; i < this.postProcessors.length; i++) {
120
- postProcessors.push(this.postProcessors[i].postProcessor);
121
- }
122
- return postProcessors;
123
- }
124
-
125
- /**
126
- *
127
- * @returns {Array}
128
- * @private
129
- */
130
- getVisitors() {
131
- return this.visitors;
132
- }
133
-
134
- visitor() {
135
- const self = this;
136
- return {
137
- first: function() {
138
- self.iterator = -1;
139
- return self.visitors[self.iterator];
140
- },
141
- get: function() {
142
- self.iterator += 1;
143
- return self.visitors[self.iterator];
144
- }
145
- };
146
- }
147
-
148
- /**
149
- *
150
- * @returns {Array}
151
- * @private
152
- */
153
- getFileManagers() {
154
- return this.fileManagers;
155
- }
156
- }
157
-
158
- let pm;
159
-
160
- const PluginManagerFactory = function(less, newFactory) {
161
- if (newFactory || !pm) {
162
- pm = new PluginManager(less);
163
- }
164
- return pm;
165
- };
166
-
167
- //
168
- export default PluginManagerFactory;
@@ -1,41 +0,0 @@
1
- import * as utils from './utils.js';
2
-
3
- export default function(environment, ParseTree) {
4
- const render = function (input, options, callback) {
5
- if (typeof options === 'function') {
6
- callback = options;
7
- options = utils.copyOptions(this.options, {});
8
- }
9
- else {
10
- options = utils.copyOptions(this.options, options || {});
11
- }
12
-
13
- if (!callback) {
14
- const self = this;
15
- return new Promise(function (resolve, reject) {
16
- render.call(self, input, options, function(err, output) {
17
- if (err) {
18
- reject(err);
19
- } else {
20
- resolve(output);
21
- }
22
- });
23
- });
24
- } else {
25
- this.parse(input, options, function(err, root, imports, options) {
26
- if (err) { return callback(err); }
27
-
28
- let result;
29
- try {
30
- const parseTree = new ParseTree(root, imports);
31
- result = parseTree.toCSS(options);
32
- }
33
- catch (err) { return callback(err); }
34
-
35
- callback(null, result);
36
- });
37
- }
38
- };
39
-
40
- return render;
41
- }
@@ -1,82 +0,0 @@
1
- export default function (SourceMapOutput, environment) {
2
- class SourceMapBuilder {
3
- constructor(options) {
4
- this.options = options;
5
- }
6
-
7
- toCSS(rootNode, options, imports) {
8
- const sourceMapOutput = new SourceMapOutput(
9
- {
10
- contentsIgnoredCharsMap: imports.contentsIgnoredChars,
11
- rootNode,
12
- contentsMap: imports.contents,
13
- sourceMapFilename: this.options.sourceMapFilename,
14
- sourceMapURL: this.options.sourceMapURL,
15
- outputFilename: this.options.sourceMapOutputFilename,
16
- sourceMapBasepath: this.options.sourceMapBasepath,
17
- sourceMapRootpath: this.options.sourceMapRootpath,
18
- outputSourceFiles: this.options.outputSourceFiles,
19
- sourceMapGenerator: this.options.sourceMapGenerator,
20
- sourceMapFileInline: this.options.sourceMapFileInline,
21
- disableSourcemapAnnotation: this.options.disableSourcemapAnnotation
22
- });
23
-
24
- const css = sourceMapOutput.toCSS(options);
25
- this.sourceMap = sourceMapOutput.sourceMap;
26
- this.sourceMapURL = sourceMapOutput.sourceMapURL;
27
- if (this.options.sourceMapInputFilename) {
28
- this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename);
29
- }
30
- if (this.options.sourceMapBasepath !== undefined && this.sourceMapURL !== undefined) {
31
- this.sourceMapURL = sourceMapOutput.removeBasepath(this.sourceMapURL);
32
- }
33
- return css + this.getCSSAppendage();
34
- }
35
-
36
- getCSSAppendage() {
37
-
38
- let sourceMapURL = this.sourceMapURL;
39
- if (this.options.sourceMapFileInline) {
40
- if (this.sourceMap === undefined) {
41
- return '';
42
- }
43
- sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`;
44
- }
45
-
46
- if (this.options.disableSourcemapAnnotation) {
47
- return '';
48
- }
49
-
50
- if (sourceMapURL) {
51
- return `/*# sourceMappingURL=${sourceMapURL} */`;
52
- }
53
- return '';
54
- }
55
-
56
- getExternalSourceMap() {
57
- return this.sourceMap;
58
- }
59
-
60
- setExternalSourceMap(sourceMap) {
61
- this.sourceMap = sourceMap;
62
- }
63
-
64
- isInline() {
65
- return this.options.sourceMapFileInline;
66
- }
67
-
68
- getSourceMapURL() {
69
- return this.sourceMapURL;
70
- }
71
-
72
- getOutputFilename() {
73
- return this.options.sourceMapOutputFilename;
74
- }
75
-
76
- getInputFilename() {
77
- return this.sourceMapInputFilename;
78
- }
79
- }
80
-
81
- return SourceMapBuilder;
82
- }
@@ -1,151 +0,0 @@
1
- export default function (environment) {
2
- class SourceMapOutput {
3
- constructor(options) {
4
- this._css = [];
5
- this._rootNode = options.rootNode;
6
- this._contentsMap = options.contentsMap;
7
- this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap;
8
- if (options.sourceMapFilename) {
9
- this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/');
10
- }
11
- this._outputFilename = options.outputFilename ? options.outputFilename.replace(/\\/g, '/') : options.outputFilename;
12
- this.sourceMapURL = options.sourceMapURL;
13
- if (options.sourceMapBasepath) {
14
- this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/');
15
- }
16
- if (options.sourceMapRootpath) {
17
- this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\/g, '/');
18
- if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') {
19
- this._sourceMapRootpath += '/';
20
- }
21
- } else {
22
- this._sourceMapRootpath = '';
23
- }
24
- this._outputSourceFiles = options.outputSourceFiles;
25
- this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();
26
-
27
- this._lineNumber = 0;
28
- this._column = 0;
29
- }
30
-
31
- removeBasepath(path) {
32
- if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) {
33
- path = path.substring(this._sourceMapBasepath.length);
34
- if (path.charAt(0) === '\\' || path.charAt(0) === '/') {
35
- path = path.substring(1);
36
- }
37
- }
38
-
39
- return path;
40
- }
41
-
42
- normalizeFilename(filename) {
43
- filename = filename.replace(/\\/g, '/');
44
- filename = this.removeBasepath(filename);
45
- return (this._sourceMapRootpath || '') + filename;
46
- }
47
-
48
- add(chunk, fileInfo, index, mapLines) {
49
-
50
- // ignore adding empty strings
51
- if (!chunk) {
52
- return;
53
- }
54
-
55
- let lines, sourceLines, columns, sourceColumns, i;
56
-
57
- if (fileInfo && fileInfo.filename) {
58
- let inputSource = this._contentsMap[fileInfo.filename];
59
-
60
- // remove vars/banner added to the top of the file
61
- if (this._contentsIgnoredCharsMap[fileInfo.filename]) {
62
- // adjust the index
63
- index -= this._contentsIgnoredCharsMap[fileInfo.filename];
64
- if (index < 0) { index = 0; }
65
- // adjust the source
66
- inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);
67
- }
68
-
69
- /**
70
- * ignore empty content, or failsafe
71
- * if contents map is incorrect
72
- */
73
- if (inputSource === undefined) {
74
- this._css.push(chunk);
75
- return;
76
- }
77
-
78
- inputSource = inputSource.substring(0, index);
79
- sourceLines = inputSource.split('\n');
80
- sourceColumns = sourceLines[sourceLines.length - 1];
81
- }
82
-
83
- lines = chunk.split('\n');
84
- columns = lines[lines.length - 1];
85
-
86
- if (fileInfo && fileInfo.filename) {
87
- if (!mapLines) {
88
- this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},
89
- original: { line: sourceLines.length, column: sourceColumns.length},
90
- source: this.normalizeFilename(fileInfo.filename)});
91
- } else {
92
- for (i = 0; i < lines.length; i++) {
93
- this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0},
94
- original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0},
95
- source: this.normalizeFilename(fileInfo.filename)});
96
- }
97
- }
98
- }
99
-
100
- if (lines.length === 1) {
101
- this._column += columns.length;
102
- } else {
103
- this._lineNumber += lines.length - 1;
104
- this._column = columns.length;
105
- }
106
-
107
- this._css.push(chunk);
108
- }
109
-
110
- isEmpty() {
111
- return this._css.length === 0;
112
- }
113
-
114
- toCSS(context) {
115
- this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });
116
-
117
- if (this._outputSourceFiles) {
118
- for (const filename in this._contentsMap) {
119
- // eslint-disable-next-line no-prototype-builtins
120
- if (this._contentsMap.hasOwnProperty(filename)) {
121
- let source = this._contentsMap[filename];
122
- if (this._contentsIgnoredCharsMap[filename]) {
123
- source = source.slice(this._contentsIgnoredCharsMap[filename]);
124
- }
125
- this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);
126
- }
127
- }
128
- }
129
-
130
- this._rootNode.genCSS(context, this);
131
-
132
- if (this._css.length > 0) {
133
- let sourceMapURL;
134
- const sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());
135
-
136
- if (this.sourceMapURL) {
137
- sourceMapURL = this.sourceMapURL;
138
- } else if (this._sourceMapFilename) {
139
- sourceMapURL = this._sourceMapFilename;
140
- }
141
- this.sourceMapURL = sourceMapURL;
142
-
143
- this.sourceMap = sourceMapContent;
144
- }
145
-
146
- return this._css.join('');
147
- }
148
- }
149
-
150
- return SourceMapOutput;
151
- }
@@ -1,102 +0,0 @@
1
- import contexts from './contexts.js';
2
- import visitor from './visitors/index.js';
3
- import tree from './tree/index.js';
4
-
5
- /**
6
- * @param {import('./tree/node.js').default} root
7
- * @param {{ variables?: Record<string, *>, compress?: boolean, pluginManager?: *, frames?: *[] }} options
8
- * @returns {import('./tree/node.js').default}
9
- */
10
- export default function(root, options) {
11
- options = options || {};
12
- let evaldRoot;
13
- let variables = options.variables;
14
- const evalEnv = new contexts.Eval(options);
15
-
16
- //
17
- // Allows setting variables with a hash, so:
18
- //
19
- // `{ color: new tree.Color('#f01') }` will become:
20
- //
21
- // new tree.Declaration('@color',
22
- // new tree.Value([
23
- // new tree.Expression([
24
- // new tree.Color('#f01')
25
- // ])
26
- // ])
27
- // )
28
- //
29
- if (typeof variables === 'object' && !Array.isArray(variables)) {
30
- variables = Object.keys(variables).map(function (k) {
31
- let value = variables[k];
32
-
33
- if (!(value instanceof tree.Value)) {
34
- if (!(value instanceof tree.Expression)) {
35
- value = new tree.Expression([value]);
36
- }
37
- value = new tree.Value([value]);
38
- }
39
- return new tree.Declaration(`@${k}`, value, false, null, 0);
40
- });
41
- evalEnv.frames = [new tree.Ruleset(null, variables)];
42
- }
43
-
44
- const visitors = [
45
- new visitor.JoinSelectorVisitor(),
46
- new visitor.MarkVisibleSelectorsVisitor(true),
47
- new visitor.ExtendVisitor(),
48
- new visitor.ToCSSVisitor({compress: Boolean(options.compress)})
49
- ];
50
-
51
- const preEvalVisitors = [];
52
- let v;
53
- let visitorIterator;
54
-
55
- /**
56
- * first() / get() allows visitors to be added while visiting
57
- *
58
- * @todo Add scoping for visitors just like functions for @plugin; right now they're global
59
- */
60
- if (options.pluginManager) {
61
- visitorIterator = options.pluginManager.visitor();
62
- for (let i = 0; i < 2; i++) {
63
- visitorIterator.first();
64
- while ((v = visitorIterator.get())) {
65
- if (v.isPreEvalVisitor) {
66
- if (i === 0 || preEvalVisitors.indexOf(v) === -1) {
67
- preEvalVisitors.push(v);
68
- v.run(root);
69
- }
70
- }
71
- else {
72
- if (i === 0 || visitors.indexOf(v) === -1) {
73
- if (v.isPreVisitor) {
74
- visitors.unshift(v);
75
- }
76
- else {
77
- visitors.push(v);
78
- }
79
- }
80
- }
81
- }
82
- }
83
- }
84
-
85
- evaldRoot = root.eval(evalEnv);
86
-
87
- for (let i = 0; i < visitors.length; i++) {
88
- visitors[i].run(evaldRoot);
89
- }
90
-
91
- // Run any remaining visitors added after eval pass
92
- if (options.pluginManager) {
93
- visitorIterator.first();
94
- while ((v = visitorIterator.get())) {
95
- if (visitors.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) {
96
- v.run(evaldRoot);
97
- }
98
- }
99
- }
100
-
101
- return evaldRoot;
102
- }
@@ -1,57 +0,0 @@
1
- // @ts-check
2
- /** @import { EvalContext, CSSOutput, FileInfo, VisibilityInfo } from './node.js' */
3
- import Node from './node.js';
4
-
5
- class Anonymous extends Node {
6
- get type() { return 'Anonymous'; }
7
-
8
- /**
9
- * @param {string | null} value
10
- * @param {number} [index]
11
- * @param {FileInfo} [currentFileInfo]
12
- * @param {boolean} [mapLines]
13
- * @param {boolean} [rulesetLike]
14
- * @param {VisibilityInfo} [visibilityInfo]
15
- */
16
- constructor(value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {
17
- super();
18
- this.value = value;
19
- this._index = index;
20
- this._fileInfo = currentFileInfo;
21
- this.mapLines = mapLines;
22
- this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;
23
- this.allowRoot = true;
24
- this.copyVisibilityInfo(visibilityInfo);
25
- }
26
-
27
- /** @returns {Anonymous} */
28
- eval() {
29
- return new Anonymous(/** @type {string | null} */ (this.value), this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());
30
- }
31
-
32
- /**
33
- * @param {Node} other
34
- * @returns {number | undefined}
35
- */
36
- compare(other) {
37
- return other.toCSS && this.toCSS(/** @type {EvalContext} */ ({})) === other.toCSS(/** @type {EvalContext} */ ({})) ? 0 : undefined;
38
- }
39
-
40
- /** @returns {boolean} */
41
- isRulesetLike() {
42
- return this.rulesetLike;
43
- }
44
-
45
- /**
46
- * @param {EvalContext} context
47
- * @param {CSSOutput} output
48
- */
49
- genCSS(context, output) {
50
- this.nodeVisible = Boolean(this.value);
51
- if (this.nodeVisible) {
52
- output.add(/** @type {string} */ (this.value), this._fileInfo, this._index, this.mapLines);
53
- }
54
- }
55
- }
56
-
57
- export default Anonymous;
@@ -1,48 +0,0 @@
1
- // @ts-check
2
- /** @import { EvalContext, CSSOutput, TreeVisitor } from './node.js' */
3
- import Node from './node.js';
4
-
5
- class Assignment extends Node {
6
- get type() { return 'Assignment'; }
7
-
8
- /**
9
- * @param {string} key
10
- * @param {Node} val
11
- */
12
- constructor(key, val) {
13
- super();
14
- this.key = key;
15
- this.value = val;
16
- }
17
-
18
- /** @param {TreeVisitor} visitor */
19
- accept(visitor) {
20
- this.value = visitor.visit(/** @type {Node} */ (this.value));
21
- }
22
-
23
- /**
24
- * @param {EvalContext} context
25
- * @returns {Assignment}
26
- */
27
- eval(context) {
28
- if (/** @type {Node} */ (this.value).eval) {
29
- return new Assignment(this.key, /** @type {Node} */ (this.value).eval(context));
30
- }
31
- return this;
32
- }
33
-
34
- /**
35
- * @param {EvalContext} context
36
- * @param {CSSOutput} output
37
- */
38
- genCSS(context, output) {
39
- output.add(`${this.key}=`);
40
- if (/** @type {Node} */ (this.value).genCSS) {
41
- /** @type {Node} */ (this.value).genCSS(context, output);
42
- } else {
43
- output.add(/** @type {string} */ (/** @type {unknown} */ (this.value)));
44
- }
45
- }
46
- }
47
-
48
- export default Assignment;
@@ -1,8 +0,0 @@
1
- // @ts-check
2
- export const MediaSyntaxOptions = {
3
- queryInParens: true
4
- };
5
-
6
- export const ContainerSyntaxOptions = {
7
- queryInParens: true
8
- };