less 4.4.2 → 4.6.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/bin/lessc +67 -58
- package/dist/less.js +14496 -11811
- package/dist/less.min.js +4 -4
- package/dist/less.min.js.map +1 -1
- package/lib/less/constants.js +5 -7
- package/lib/less/contexts.js +71 -56
- package/lib/less/data/colors.js +150 -153
- package/lib/less/data/index.js +4 -7
- package/lib/less/data/unit-conversions.js +2 -5
- package/lib/less/default-options.js +52 -23
- package/lib/less/deprecation.js +67 -0
- package/lib/less/environment/abstract-file-manager.js +62 -50
- package/lib/less/environment/abstract-plugin-loader.js +69 -46
- package/lib/less/environment/environment-api.ts +21 -0
- package/lib/less/environment/environment.js +34 -30
- package/lib/less/environment/file-manager-api.ts +77 -0
- package/lib/less/functions/boolean.js +13 -13
- package/lib/less/functions/color-blending.js +39 -31
- package/lib/less/functions/color.js +153 -137
- package/lib/less/functions/data-uri.js +73 -64
- package/lib/less/functions/default.js +9 -11
- package/lib/less/functions/function-caller.js +35 -34
- package/lib/less/functions/function-registry.js +16 -17
- package/lib/less/functions/index.js +33 -33
- package/lib/less/functions/list.js +88 -75
- package/lib/less/functions/math-helper.js +8 -11
- package/lib/less/functions/math.js +21 -21
- package/lib/less/functions/number.js +42 -53
- package/lib/less/functions/string.js +18 -22
- package/lib/less/functions/style.js +21 -20
- package/lib/less/functions/svg.js +83 -82
- package/lib/less/functions/types.js +28 -32
- package/lib/less/import-manager.js +73 -64
- package/lib/less/index.js +65 -65
- package/lib/less/less-error.js +65 -46
- package/lib/less/logger.js +11 -14
- package/lib/less/parse-tree.js +94 -38
- package/lib/less/parse.js +44 -44
- package/lib/less/parser/parser-input.js +152 -131
- package/lib/less/parser/parser.js +866 -672
- package/lib/less/plugin-manager.js +57 -46
- package/lib/less/render.js +17 -23
- package/lib/less/source-map-builder.js +52 -43
- package/lib/less/source-map-output.js +57 -44
- package/lib/less/transform-tree.js +40 -30
- package/lib/less/tree/anonymous.js +52 -28
- package/lib/less/tree/assignment.js +44 -27
- package/lib/less/tree/atrule-syntax.js +4 -6
- package/lib/less/tree/atrule.js +247 -140
- package/lib/less/tree/attribute.js +55 -24
- package/lib/less/tree/call.js +70 -42
- package/lib/less/tree/color.js +194 -145
- package/lib/less/tree/combinator.js +31 -21
- package/lib/less/tree/comment.js +44 -23
- package/lib/less/tree/condition.js +61 -36
- package/lib/less/tree/container.js +90 -34
- package/lib/less/tree/debug-info.js +53 -11
- package/lib/less/tree/declaration.js +97 -52
- package/lib/less/tree/detached-ruleset.js +42 -24
- package/lib/less/tree/dimension.js +127 -71
- package/lib/less/tree/element.js +82 -52
- package/lib/less/tree/expression.js +75 -50
- package/lib/less/tree/extend.js +71 -42
- package/lib/less/tree/import.js +184 -110
- package/lib/less/tree/index.js +52 -81
- package/lib/less/tree/javascript.js +43 -32
- package/lib/less/tree/js-eval-node.js +46 -32
- package/lib/less/tree/keyword.js +25 -17
- package/lib/less/tree/media.js +77 -35
- package/lib/less/tree/merge-rules.js +47 -0
- package/lib/less/tree/mixin-call.js +181 -98
- package/lib/less/tree/mixin-definition.js +211 -117
- package/lib/less/tree/namespace-value.js +63 -44
- package/lib/less/tree/negative.js +34 -21
- package/lib/less/tree/nested-at-rule.js +149 -66
- package/lib/less/tree/node.js +225 -90
- package/lib/less/tree/operation.js +59 -34
- package/lib/less/tree/paren.js +34 -17
- package/lib/less/tree/property.js +66 -35
- package/lib/less/tree/query-in-parens.js +52 -60
- package/lib/less/tree/quoted.js +93 -44
- package/lib/less/tree/ruleset.js +632 -318
- package/lib/less/tree/selector.js +151 -77
- package/lib/less/tree/unicode-descriptor.js +14 -12
- package/lib/less/tree/unit.js +111 -63
- package/lib/less/tree/url.js +62 -38
- package/lib/less/tree/value.js +50 -34
- package/lib/less/tree/variable-call.js +47 -30
- package/lib/less/tree/variable.js +53 -31
- package/lib/less/utils.js +44 -47
- package/lib/less/visitors/extend-visitor.js +233 -172
- package/lib/less/visitors/import-sequencer.js +24 -24
- package/lib/less/visitors/import-visitor.js +62 -52
- package/lib/less/visitors/index.js +14 -17
- package/lib/less/visitors/join-selector-visitor.js +40 -37
- package/lib/less/visitors/set-tree-visibility-visitor.js +32 -18
- package/lib/less/visitors/to-css-visitor.js +135 -128
- package/lib/less/visitors/visitor.js +60 -45
- package/lib/less-browser/add-default-options.js +23 -13
- package/lib/less-browser/bootstrap.js +23 -17
- package/lib/less-browser/browser.js +24 -21
- package/lib/less-browser/cache.js +17 -19
- package/lib/less-browser/error-reporting.js +52 -44
- package/lib/less-browser/file-manager.js +52 -42
- package/lib/less-browser/image-size.js +12 -12
- package/lib/less-browser/index.js +131 -105
- package/lib/less-browser/log-listener.js +30 -31
- package/lib/less-browser/plugin-loader.js +10 -10
- package/lib/less-browser/utils.js +19 -21
- package/lib/less-node/environment.js +32 -8
- package/lib/less-node/file-manager.js +62 -45
- package/lib/less-node/fs.js +11 -8
- package/lib/less-node/image-size.js +40 -31
- package/lib/less-node/index.js +28 -19
- package/lib/less-node/lessc-helper.js +28 -28
- package/lib/less-node/plugin-loader.js +35 -27
- package/lib/less-node/url-file-manager.js +33 -31
- package/package.json +31 -19
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -63
- package/Gruntfile.js +0 -404
- package/bower.json +0 -22
- package/lib/less/constants.js.map +0 -1
- package/lib/less/contexts.js.map +0 -1
- package/lib/less/data/colors.js.map +0 -1
- package/lib/less/data/index.js.map +0 -1
- package/lib/less/data/unit-conversions.js.map +0 -1
- package/lib/less/default-options.js.map +0 -1
- package/lib/less/environment/abstract-file-manager.js.map +0 -1
- package/lib/less/environment/abstract-plugin-loader.js.map +0 -1
- package/lib/less/environment/environment-api.js +0 -3
- package/lib/less/environment/environment-api.js.map +0 -1
- package/lib/less/environment/environment.js.map +0 -1
- package/lib/less/environment/file-manager-api.js +0 -3
- package/lib/less/environment/file-manager-api.js.map +0 -1
- package/lib/less/functions/boolean.js.map +0 -1
- package/lib/less/functions/color-blending.js.map +0 -1
- package/lib/less/functions/color.js.map +0 -1
- package/lib/less/functions/data-uri.js.map +0 -1
- package/lib/less/functions/default.js.map +0 -1
- package/lib/less/functions/function-caller.js.map +0 -1
- package/lib/less/functions/function-registry.js.map +0 -1
- package/lib/less/functions/index.js.map +0 -1
- package/lib/less/functions/list.js.map +0 -1
- package/lib/less/functions/math-helper.js.map +0 -1
- package/lib/less/functions/math.js.map +0 -1
- package/lib/less/functions/number.js.map +0 -1
- package/lib/less/functions/string.js.map +0 -1
- package/lib/less/functions/style.js.map +0 -1
- package/lib/less/functions/svg.js.map +0 -1
- package/lib/less/functions/types.js.map +0 -1
- package/lib/less/import-manager.js.map +0 -1
- package/lib/less/index.js.map +0 -1
- package/lib/less/less-error.js.map +0 -1
- package/lib/less/logger.js.map +0 -1
- package/lib/less/parse-tree.js.map +0 -1
- package/lib/less/parse.js.map +0 -1
- package/lib/less/parser/chunker.js +0 -148
- package/lib/less/parser/chunker.js.map +0 -1
- package/lib/less/parser/parser-input.js.map +0 -1
- package/lib/less/parser/parser.js.map +0 -1
- package/lib/less/plugin-manager.js.map +0 -1
- package/lib/less/render.js.map +0 -1
- package/lib/less/source-map-builder.js.map +0 -1
- package/lib/less/source-map-output.js.map +0 -1
- package/lib/less/transform-tree.js.map +0 -1
- package/lib/less/tree/anonymous.js.map +0 -1
- package/lib/less/tree/assignment.js.map +0 -1
- package/lib/less/tree/atrule-syntax.js.map +0 -1
- package/lib/less/tree/atrule.js.map +0 -1
- package/lib/less/tree/attribute.js.map +0 -1
- package/lib/less/tree/call.js.map +0 -1
- package/lib/less/tree/color.js.map +0 -1
- package/lib/less/tree/combinator.js.map +0 -1
- package/lib/less/tree/comment.js.map +0 -1
- package/lib/less/tree/condition.js.map +0 -1
- package/lib/less/tree/container.js.map +0 -1
- package/lib/less/tree/debug-info.js.map +0 -1
- package/lib/less/tree/declaration.js.map +0 -1
- package/lib/less/tree/detached-ruleset.js.map +0 -1
- package/lib/less/tree/dimension.js.map +0 -1
- package/lib/less/tree/element.js.map +0 -1
- package/lib/less/tree/expression.js.map +0 -1
- package/lib/less/tree/extend.js.map +0 -1
- package/lib/less/tree/import.js.map +0 -1
- package/lib/less/tree/index.js.map +0 -1
- package/lib/less/tree/javascript.js.map +0 -1
- package/lib/less/tree/js-eval-node.js.map +0 -1
- package/lib/less/tree/keyword.js.map +0 -1
- package/lib/less/tree/media.js.map +0 -1
- package/lib/less/tree/mixin-call.js.map +0 -1
- package/lib/less/tree/mixin-definition.js.map +0 -1
- package/lib/less/tree/namespace-value.js.map +0 -1
- package/lib/less/tree/negative.js.map +0 -1
- package/lib/less/tree/nested-at-rule.js.map +0 -1
- package/lib/less/tree/node.js.map +0 -1
- package/lib/less/tree/operation.js.map +0 -1
- package/lib/less/tree/paren.js.map +0 -1
- package/lib/less/tree/property.js.map +0 -1
- package/lib/less/tree/query-in-parens.js.map +0 -1
- package/lib/less/tree/quoted.js.map +0 -1
- package/lib/less/tree/ruleset.js.map +0 -1
- package/lib/less/tree/selector.js.map +0 -1
- package/lib/less/tree/unicode-descriptor.js.map +0 -1
- package/lib/less/tree/unit.js.map +0 -1
- package/lib/less/tree/url.js.map +0 -1
- package/lib/less/tree/value.js.map +0 -1
- package/lib/less/tree/variable-call.js.map +0 -1
- package/lib/less/tree/variable.js.map +0 -1
- package/lib/less/utils.js.map +0 -1
- package/lib/less/visitors/extend-visitor.js.map +0 -1
- package/lib/less/visitors/import-sequencer.js.map +0 -1
- package/lib/less/visitors/import-visitor.js.map +0 -1
- package/lib/less/visitors/index.js.map +0 -1
- package/lib/less/visitors/join-selector-visitor.js.map +0 -1
- package/lib/less/visitors/set-tree-visibility-visitor.js.map +0 -1
- package/lib/less/visitors/to-css-visitor.js.map +0 -1
- package/lib/less/visitors/visitor.js.map +0 -1
- package/lib/less-browser/add-default-options.js.map +0 -1
- package/lib/less-browser/bootstrap.js.map +0 -1
- package/lib/less-browser/browser.js.map +0 -1
- package/lib/less-browser/cache.js.map +0 -1
- package/lib/less-browser/error-reporting.js.map +0 -1
- package/lib/less-browser/file-manager.js.map +0 -1
- package/lib/less-browser/image-size.js.map +0 -1
- package/lib/less-browser/index.js.map +0 -1
- package/lib/less-browser/log-listener.js.map +0 -1
- package/lib/less-browser/plugin-loader.js.map +0 -1
- package/lib/less-browser/utils.js.map +0 -1
- package/lib/less-node/environment.js.map +0 -1
- package/lib/less-node/file-manager.js.map +0 -1
- package/lib/less-node/fs.js.map +0 -1
- package/lib/less-node/image-size.js.map +0 -1
- package/lib/less-node/index.js.map +0 -1
- package/lib/less-node/lessc-helper.js.map +0 -1
- package/lib/less-node/plugin-loader.js.map +0 -1
- package/lib/less-node/url-file-manager.js.map +0 -1
- package/test/.eslintrc.json +0 -9
- package/test/README.md +0 -3
- package/test/browser/common.js +0 -230
- package/test/browser/css/global-vars/simple.css +0 -3
- package/test/browser/css/modify-vars/simple.css +0 -8
- package/test/browser/css/plugin/plugin.css +0 -3
- package/test/browser/css/postProcessor/postProcessor.css +0 -4
- package/test/browser/css/relative-urls/urls.css +0 -36
- package/test/browser/css/rewrite-urls/urls.css +0 -36
- package/test/browser/css/rootpath/urls.css +0 -35
- package/test/browser/css/rootpath-relative/urls.css +0 -35
- package/test/browser/css/rootpath-rewrite-urls/urls.css +0 -35
- package/test/browser/css/urls.css +0 -54
- package/test/browser/generator/benchmark.config.js +0 -50
- package/test/browser/generator/generate.js +0 -78
- package/test/browser/generator/runner.config.js +0 -188
- package/test/browser/generator/runner.js +0 -2
- package/test/browser/generator/template.js +0 -93
- package/test/browser/generator/utils.js +0 -14
- package/test/browser/less/console-errors/test-error.less +0 -3
- package/test/browser/less/console-errors/test-error.txt +0 -2
- package/test/browser/less/errors/image-height-error.less +0 -3
- package/test/browser/less/errors/image-height-error.txt +0 -4
- package/test/browser/less/errors/image-size-error.less +0 -3
- package/test/browser/less/errors/image-size-error.txt +0 -4
- package/test/browser/less/errors/image-width-error.less +0 -3
- package/test/browser/less/errors/image-width-error.txt +0 -4
- package/test/browser/less/global-vars/simple.less +0 -3
- package/test/browser/less/imports/urls.less +0 -4
- package/test/browser/less/imports/urls2.less +0 -4
- package/test/browser/less/modify-vars/imports/simple2.less +0 -4
- package/test/browser/less/modify-vars/simple.less +0 -8
- package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
- package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
- package/test/browser/less/plugin/plugin.js +0 -4
- package/test/browser/less/plugin/plugin.less +0 -4
- package/test/browser/less/postProcessor/postProcessor.less +0 -4
- package/test/browser/less/relative-urls/urls.less +0 -34
- package/test/browser/less/rewrite-urls/urls.less +0 -34
- package/test/browser/less/rootpath/urls.less +0 -33
- package/test/browser/less/rootpath-relative/urls.less +0 -33
- package/test/browser/less/rootpath-rewrite-urls/urls.less +0 -33
- package/test/browser/less/urls.less +0 -62
- package/test/browser/runner-VisitorPlugin-options.js +0 -3
- package/test/browser/runner-VisitorPlugin.js +0 -3
- package/test/browser/runner-browser-options.js +0 -51
- package/test/browser/runner-browser-spec.js +0 -12
- package/test/browser/runner-console-errors.js +0 -5
- package/test/browser/runner-errors-options.js +0 -6
- package/test/browser/runner-errors-spec.js +0 -3
- package/test/browser/runner-filemanagerPlugin-options.js +0 -5
- package/test/browser/runner-filemanagerPlugin.js +0 -3
- package/test/browser/runner-global-vars-options.js +0 -7
- package/test/browser/runner-global-vars-spec.js +0 -3
- package/test/browser/runner-legacy-options.js +0 -6
- package/test/browser/runner-legacy-spec.js +0 -3
- package/test/browser/runner-main-options.js +0 -17
- package/test/browser/runner-main-spec.js +0 -7
- package/test/browser/runner-modify-vars-options.js +0 -5
- package/test/browser/runner-modify-vars-spec.js +0 -33
- package/test/browser/runner-no-js-errors-options.js +0 -4
- package/test/browser/runner-no-js-errors-spec.js +0 -3
- package/test/browser/runner-postProcessorPlugin-options.js +0 -3
- package/test/browser/runner-postProcessorPlugin.js +0 -3
- package/test/browser/runner-preProcessorPlugin-options.js +0 -3
- package/test/browser/runner-preProcessorPlugin.js +0 -3
- package/test/browser/runner-production-options.js +0 -3
- package/test/browser/runner-production-spec.js +0 -5
- package/test/browser/runner-relative-urls-options.js +0 -3
- package/test/browser/runner-relative-urls-spec.js +0 -3
- package/test/browser/runner-rewrite-urls-options.js +0 -3
- package/test/browser/runner-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-options.js +0 -3
- package/test/browser/runner-rootpath-relative-options.js +0 -4
- package/test/browser/runner-rootpath-relative-spec.js +0 -3
- package/test/browser/runner-rootpath-rewrite-urls-options.js +0 -4
- package/test/browser/runner-rootpath-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-spec.js +0 -3
- package/test/browser/runner-strict-units-options.js +0 -5
- package/test/browser/runner-strict-units-spec.js +0 -3
- package/test/index.js +0 -112
- package/test/less-test.js +0 -625
- package/test/mocha-playwright/runner.js +0 -210
- package/test/modify-vars.js +0 -28
- package/test/plugins/filemanager/index.js +0 -19
- package/test/plugins/postprocess/index.js +0 -14
- package/test/plugins/preprocess/index.js +0 -19
- package/test/plugins/visitor/index.js +0 -24
- package/test/sourcemaps/basic.json +0 -1
- package/test/sourcemaps/custom-props.json +0 -1
- package/test/sourcemaps/index.html +0 -17
- package/test/sourcemaps-disable-annotation/basic.json +0 -1
- package/test/sourcemaps-variable-selector/basic.json +0 -1
- package/test/test-es6.ts +0 -17
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -21
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* Plugin Manager
|
|
5
3
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
class PluginManager {
|
|
5
|
+
constructor(less) {
|
|
8
6
|
this.less = less;
|
|
9
7
|
this.visitors = [];
|
|
10
8
|
this.preProcessors = [];
|
|
@@ -15,23 +13,25 @@ var PluginManager = /** @class */ (function () {
|
|
|
15
13
|
this.pluginCache = {};
|
|
16
14
|
this.Loader = new less.PluginLoader(less);
|
|
17
15
|
}
|
|
16
|
+
|
|
18
17
|
/**
|
|
19
18
|
* Adds all the plugins in the array
|
|
20
19
|
* @param {Array} plugins
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
addPlugins(plugins) {
|
|
23
22
|
if (plugins) {
|
|
24
|
-
for (
|
|
23
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
25
24
|
this.addPlugin(plugins[i]);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
31
31
|
* @param plugin
|
|
32
32
|
* @param {String} filename
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
addPlugin(plugin, filename, functionRegistry) {
|
|
35
35
|
this.installedPlugins.push(plugin);
|
|
36
36
|
if (filename) {
|
|
37
37
|
this.pluginCache[filename] = plugin;
|
|
@@ -39,119 +39,130 @@ var PluginManager = /** @class */ (function () {
|
|
|
39
39
|
if (plugin.install) {
|
|
40
40
|
plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
|
+
|
|
43
44
|
/**
|
|
44
45
|
*
|
|
45
46
|
* @param filename
|
|
46
47
|
*/
|
|
47
|
-
|
|
48
|
+
get(filename) {
|
|
48
49
|
return this.pluginCache[filename];
|
|
49
|
-
}
|
|
50
|
+
}
|
|
51
|
+
|
|
50
52
|
/**
|
|
51
53
|
* Adds a visitor. The visitor object has options on itself to determine
|
|
52
54
|
* when it should run.
|
|
53
55
|
* @param visitor
|
|
54
56
|
*/
|
|
55
|
-
|
|
57
|
+
addVisitor(visitor) {
|
|
56
58
|
this.visitors.push(visitor);
|
|
57
|
-
}
|
|
59
|
+
}
|
|
60
|
+
|
|
58
61
|
/**
|
|
59
62
|
* Adds a pre processor object
|
|
60
63
|
* @param {object} preProcessor
|
|
61
64
|
* @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import
|
|
62
65
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
addPreProcessor(preProcessor, priority) {
|
|
67
|
+
let indexToInsertAt;
|
|
65
68
|
for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {
|
|
66
69
|
if (this.preProcessors[indexToInsertAt].priority >= priority) {
|
|
67
70
|
break;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
this.preProcessors.splice(indexToInsertAt, 0, {
|
|
71
|
-
}
|
|
73
|
+
this.preProcessors.splice(indexToInsertAt, 0, {preProcessor, priority});
|
|
74
|
+
}
|
|
75
|
+
|
|
72
76
|
/**
|
|
73
77
|
* Adds a post processor object
|
|
74
78
|
* @param {object} postProcessor
|
|
75
79
|
* @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression
|
|
76
80
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
addPostProcessor(postProcessor, priority) {
|
|
82
|
+
let indexToInsertAt;
|
|
79
83
|
for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {
|
|
80
84
|
if (this.postProcessors[indexToInsertAt].priority >= priority) {
|
|
81
85
|
break;
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
|
-
this.postProcessors.splice(indexToInsertAt, 0, {
|
|
85
|
-
}
|
|
88
|
+
this.postProcessors.splice(indexToInsertAt, 0, {postProcessor, priority});
|
|
89
|
+
}
|
|
90
|
+
|
|
86
91
|
/**
|
|
87
92
|
*
|
|
88
93
|
* @param manager
|
|
89
94
|
*/
|
|
90
|
-
|
|
95
|
+
addFileManager(manager) {
|
|
91
96
|
this.fileManagers.push(manager);
|
|
92
|
-
}
|
|
97
|
+
}
|
|
98
|
+
|
|
93
99
|
/**
|
|
94
100
|
*
|
|
95
101
|
* @returns {Array}
|
|
96
102
|
* @private
|
|
97
103
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for (
|
|
104
|
+
getPreProcessors() {
|
|
105
|
+
const preProcessors = [];
|
|
106
|
+
for (let i = 0; i < this.preProcessors.length; i++) {
|
|
101
107
|
preProcessors.push(this.preProcessors[i].preProcessor);
|
|
102
108
|
}
|
|
103
109
|
return preProcessors;
|
|
104
|
-
}
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
/**
|
|
106
113
|
*
|
|
107
114
|
* @returns {Array}
|
|
108
115
|
* @private
|
|
109
116
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
for (
|
|
117
|
+
getPostProcessors() {
|
|
118
|
+
const postProcessors = [];
|
|
119
|
+
for (let i = 0; i < this.postProcessors.length; i++) {
|
|
113
120
|
postProcessors.push(this.postProcessors[i].postProcessor);
|
|
114
121
|
}
|
|
115
122
|
return postProcessors;
|
|
116
|
-
}
|
|
123
|
+
}
|
|
124
|
+
|
|
117
125
|
/**
|
|
118
126
|
*
|
|
119
127
|
* @returns {Array}
|
|
120
128
|
* @private
|
|
121
129
|
*/
|
|
122
|
-
|
|
130
|
+
getVisitors() {
|
|
123
131
|
return this.visitors;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
visitor() {
|
|
135
|
+
const self = this;
|
|
127
136
|
return {
|
|
128
|
-
first: function
|
|
137
|
+
first: function() {
|
|
129
138
|
self.iterator = -1;
|
|
130
139
|
return self.visitors[self.iterator];
|
|
131
140
|
},
|
|
132
|
-
get: function
|
|
141
|
+
get: function() {
|
|
133
142
|
self.iterator += 1;
|
|
134
143
|
return self.visitors[self.iterator];
|
|
135
144
|
}
|
|
136
145
|
};
|
|
137
|
-
}
|
|
146
|
+
}
|
|
147
|
+
|
|
138
148
|
/**
|
|
139
149
|
*
|
|
140
150
|
* @returns {Array}
|
|
141
151
|
* @private
|
|
142
152
|
*/
|
|
143
|
-
|
|
153
|
+
getFileManagers() {
|
|
144
154
|
return this.fileManagers;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let pm;
|
|
159
|
+
|
|
160
|
+
const PluginManagerFactory = function(less, newFactory) {
|
|
150
161
|
if (newFactory || !pm) {
|
|
151
162
|
pm = new PluginManager(less);
|
|
152
163
|
}
|
|
153
164
|
return pm;
|
|
154
165
|
};
|
|
166
|
+
|
|
155
167
|
//
|
|
156
|
-
|
|
157
|
-
//# sourceMappingURL=plugin-manager.js.map
|
|
168
|
+
export default PluginManagerFactory;
|
package/lib/less/render.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function default_1(environment, ParseTree) {
|
|
6
|
-
var render = function (input, options, callback) {
|
|
1
|
+
import * as utils from './utils.js';
|
|
2
|
+
|
|
3
|
+
export default function(environment, ParseTree) {
|
|
4
|
+
const render = function (input, options, callback) {
|
|
7
5
|
if (typeof options === 'function') {
|
|
8
6
|
callback = options;
|
|
9
7
|
options = utils.copyOptions(this.options, {});
|
|
@@ -11,37 +9,33 @@ function default_1(environment, ParseTree) {
|
|
|
11
9
|
else {
|
|
12
10
|
options = utils.copyOptions(this.options, options || {});
|
|
13
11
|
}
|
|
12
|
+
|
|
14
13
|
if (!callback) {
|
|
15
|
-
|
|
14
|
+
const self = this;
|
|
16
15
|
return new Promise(function (resolve, reject) {
|
|
17
|
-
render.call(
|
|
16
|
+
render.call(self, input, options, function(err, output) {
|
|
18
17
|
if (err) {
|
|
19
18
|
reject(err);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
19
|
+
} else {
|
|
22
20
|
resolve(output);
|
|
23
21
|
}
|
|
24
22
|
});
|
|
25
23
|
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
var result;
|
|
24
|
+
} else {
|
|
25
|
+
this.parse(input, options, function(err, root, imports, options) {
|
|
26
|
+
if (err) { return callback(err); }
|
|
27
|
+
|
|
28
|
+
let result;
|
|
33
29
|
try {
|
|
34
|
-
|
|
30
|
+
const parseTree = new ParseTree(root, imports);
|
|
35
31
|
result = parseTree.toCSS(options);
|
|
36
32
|
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
|
|
39
|
-
}
|
|
33
|
+
catch (err) { return callback(err); }
|
|
34
|
+
|
|
40
35
|
callback(null, result);
|
|
41
36
|
});
|
|
42
37
|
}
|
|
43
38
|
};
|
|
39
|
+
|
|
44
40
|
return render;
|
|
45
41
|
}
|
|
46
|
-
exports.default = default_1;
|
|
47
|
-
//# sourceMappingURL=render.js.map
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var SourceMapBuilder = /** @class */ (function () {
|
|
5
|
-
function SourceMapBuilder(options) {
|
|
1
|
+
export default function (SourceMapOutput, environment) {
|
|
2
|
+
class SourceMapBuilder {
|
|
3
|
+
constructor(options) {
|
|
6
4
|
this.options = options;
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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);
|
|
24
25
|
this.sourceMap = sourceMapOutput.sourceMap;
|
|
25
26
|
this.sourceMapURL = sourceMapOutput.sourceMapURL;
|
|
26
27
|
if (this.options.sourceMapInputFilename) {
|
|
@@ -30,44 +31,52 @@ function default_1(SourceMapOutput, environment) {
|
|
|
30
31
|
this.sourceMapURL = sourceMapOutput.removeBasepath(this.sourceMapURL);
|
|
31
32
|
}
|
|
32
33
|
return css + this.getCSSAppendage();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getCSSAppendage() {
|
|
37
|
+
|
|
38
|
+
let sourceMapURL = this.sourceMapURL;
|
|
36
39
|
if (this.options.sourceMapFileInline) {
|
|
37
40
|
if (this.sourceMap === undefined) {
|
|
38
41
|
return '';
|
|
39
42
|
}
|
|
40
|
-
sourceMapURL =
|
|
43
|
+
sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`;
|
|
41
44
|
}
|
|
45
|
+
|
|
42
46
|
if (this.options.disableSourcemapAnnotation) {
|
|
43
47
|
return '';
|
|
44
48
|
}
|
|
49
|
+
|
|
45
50
|
if (sourceMapURL) {
|
|
46
|
-
return
|
|
51
|
+
return `/*# sourceMappingURL=${sourceMapURL} */`;
|
|
47
52
|
}
|
|
48
53
|
return '';
|
|
49
|
-
}
|
|
50
|
-
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getExternalSourceMap() {
|
|
51
57
|
return this.sourceMap;
|
|
52
|
-
}
|
|
53
|
-
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setExternalSourceMap(sourceMap) {
|
|
54
61
|
this.sourceMap = sourceMap;
|
|
55
|
-
}
|
|
56
|
-
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
isInline() {
|
|
57
65
|
return this.options.sourceMapFileInline;
|
|
58
|
-
}
|
|
59
|
-
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getSourceMapURL() {
|
|
60
69
|
return this.sourceMapURL;
|
|
61
|
-
}
|
|
62
|
-
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getOutputFilename() {
|
|
63
73
|
return this.options.sourceMapOutputFilename;
|
|
64
|
-
}
|
|
65
|
-
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getInputFilename() {
|
|
66
77
|
return this.sourceMapInputFilename;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
70
81
|
return SourceMapBuilder;
|
|
71
82
|
}
|
|
72
|
-
exports.default = default_1;
|
|
73
|
-
//# sourceMappingURL=source-map-builder.js.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var SourceMapOutput = /** @class */ (function () {
|
|
5
|
-
function SourceMapOutput(options) {
|
|
1
|
+
export default function (environment) {
|
|
2
|
+
class SourceMapOutput {
|
|
3
|
+
constructor(options) {
|
|
6
4
|
this._css = [];
|
|
7
5
|
this._rootNode = options.rootNode;
|
|
8
6
|
this._contentsMap = options.contentsMap;
|
|
@@ -10,7 +8,7 @@ function default_1(environment) {
|
|
|
10
8
|
if (options.sourceMapFilename) {
|
|
11
9
|
this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/');
|
|
12
10
|
}
|
|
13
|
-
this._outputFilename = options.outputFilename;
|
|
11
|
+
this._outputFilename = options.outputFilename ? options.outputFilename.replace(/\\/g, '/') : options.outputFilename;
|
|
14
12
|
this.sourceMapURL = options.sourceMapURL;
|
|
15
13
|
if (options.sourceMapBasepath) {
|
|
16
14
|
this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/');
|
|
@@ -20,48 +18,55 @@ function default_1(environment) {
|
|
|
20
18
|
if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') {
|
|
21
19
|
this._sourceMapRootpath += '/';
|
|
22
20
|
}
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
21
|
+
} else {
|
|
25
22
|
this._sourceMapRootpath = '';
|
|
26
23
|
}
|
|
27
24
|
this._outputSourceFiles = options.outputSourceFiles;
|
|
28
25
|
this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();
|
|
26
|
+
|
|
29
27
|
this._lineNumber = 0;
|
|
30
28
|
this._column = 0;
|
|
31
29
|
}
|
|
32
|
-
|
|
30
|
+
|
|
31
|
+
removeBasepath(path) {
|
|
33
32
|
if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) {
|
|
34
33
|
path = path.substring(this._sourceMapBasepath.length);
|
|
35
34
|
if (path.charAt(0) === '\\' || path.charAt(0) === '/') {
|
|
36
35
|
path = path.substring(1);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
38
|
+
|
|
39
39
|
return path;
|
|
40
|
-
}
|
|
41
|
-
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
normalizeFilename(filename) {
|
|
42
43
|
filename = filename.replace(/\\/g, '/');
|
|
43
44
|
filename = this.removeBasepath(filename);
|
|
44
45
|
return (this._sourceMapRootpath || '') + filename;
|
|
45
|
-
}
|
|
46
|
-
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
add(chunk, fileInfo, index, mapLines) {
|
|
49
|
+
|
|
47
50
|
// ignore adding empty strings
|
|
48
51
|
if (!chunk) {
|
|
49
52
|
return;
|
|
50
53
|
}
|
|
51
|
-
|
|
54
|
+
|
|
55
|
+
let lines, sourceLines, columns, sourceColumns, i;
|
|
56
|
+
|
|
52
57
|
if (fileInfo && fileInfo.filename) {
|
|
53
|
-
|
|
58
|
+
let inputSource = this._contentsMap[fileInfo.filename];
|
|
59
|
+
|
|
54
60
|
// remove vars/banner added to the top of the file
|
|
55
61
|
if (this._contentsIgnoredCharsMap[fileInfo.filename]) {
|
|
56
62
|
// adjust the index
|
|
57
63
|
index -= this._contentsIgnoredCharsMap[fileInfo.filename];
|
|
58
|
-
if (index < 0) {
|
|
59
|
-
index = 0;
|
|
60
|
-
}
|
|
64
|
+
if (index < 0) { index = 0; }
|
|
61
65
|
// adjust the source
|
|
62
66
|
inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);
|
|
63
67
|
}
|
|
64
|
-
|
|
68
|
+
|
|
69
|
+
/**
|
|
65
70
|
* ignore empty content, or failsafe
|
|
66
71
|
* if contents map is incorrect
|
|
67
72
|
*/
|
|
@@ -69,45 +74,51 @@ function default_1(environment) {
|
|
|
69
74
|
this._css.push(chunk);
|
|
70
75
|
return;
|
|
71
76
|
}
|
|
77
|
+
|
|
72
78
|
inputSource = inputSource.substring(0, index);
|
|
73
79
|
sourceLines = inputSource.split('\n');
|
|
74
80
|
sourceColumns = sourceLines[sourceLines.length - 1];
|
|
75
81
|
}
|
|
82
|
+
|
|
76
83
|
lines = chunk.split('\n');
|
|
77
84
|
columns = lines[lines.length - 1];
|
|
85
|
+
|
|
78
86
|
if (fileInfo && fileInfo.filename) {
|
|
79
87
|
if (!mapLines) {
|
|
80
|
-
this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column
|
|
81
|
-
original: { line: sourceLines.length, column: sourceColumns.length
|
|
82
|
-
source: this.normalizeFilename(fileInfo.filename)
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
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 {
|
|
85
92
|
for (i = 0; i < lines.length; i++) {
|
|
86
|
-
this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0
|
|
87
|
-
original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0
|
|
88
|
-
source: this.normalizeFilename(fileInfo.filename)
|
|
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)});
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
}
|
|
99
|
+
|
|
92
100
|
if (lines.length === 1) {
|
|
93
101
|
this._column += columns.length;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
102
|
+
} else {
|
|
96
103
|
this._lineNumber += lines.length - 1;
|
|
97
104
|
this._column = columns.length;
|
|
98
105
|
}
|
|
106
|
+
|
|
99
107
|
this._css.push(chunk);
|
|
100
|
-
}
|
|
101
|
-
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
isEmpty() {
|
|
102
111
|
return this._css.length === 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
toCSS(context) {
|
|
105
115
|
this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });
|
|
116
|
+
|
|
106
117
|
if (this._outputSourceFiles) {
|
|
107
|
-
for (
|
|
118
|
+
for (const filename in this._contentsMap) {
|
|
108
119
|
// eslint-disable-next-line no-prototype-builtins
|
|
109
120
|
if (this._contentsMap.hasOwnProperty(filename)) {
|
|
110
|
-
|
|
121
|
+
let source = this._contentsMap[filename];
|
|
111
122
|
if (this._contentsIgnoredCharsMap[filename]) {
|
|
112
123
|
source = source.slice(this._contentsIgnoredCharsMap[filename]);
|
|
113
124
|
}
|
|
@@ -115,24 +126,26 @@ function default_1(environment) {
|
|
|
115
126
|
}
|
|
116
127
|
}
|
|
117
128
|
}
|
|
129
|
+
|
|
118
130
|
this._rootNode.genCSS(context, this);
|
|
131
|
+
|
|
119
132
|
if (this._css.length > 0) {
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
let sourceMapURL;
|
|
134
|
+
const sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());
|
|
135
|
+
|
|
122
136
|
if (this.sourceMapURL) {
|
|
123
137
|
sourceMapURL = this.sourceMapURL;
|
|
124
|
-
}
|
|
125
|
-
else if (this._sourceMapFilename) {
|
|
138
|
+
} else if (this._sourceMapFilename) {
|
|
126
139
|
sourceMapURL = this._sourceMapFilename;
|
|
127
140
|
}
|
|
128
141
|
this.sourceMapURL = sourceMapURL;
|
|
142
|
+
|
|
129
143
|
this.sourceMap = sourceMapContent;
|
|
130
144
|
}
|
|
145
|
+
|
|
131
146
|
return this._css.join('');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
return SourceMapOutput;
|
|
136
151
|
}
|
|
137
|
-
exports.default = default_1;
|
|
138
|
-
//# sourceMappingURL=source-map-output.js.map
|