less 4.5.1 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -5
- package/bin/lessc +37 -23
- package/dist/less.js +14501 -11745
- package/dist/less.min.js +4 -4
- package/dist/less.min.js.map +1 -1
- package/index.cjs +41 -0
- package/lib/less/constants.js +5 -7
- package/lib/less/contexts.js +71 -55
- 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 +36 -26
- 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 +63 -45
- package/lib/less/logger.js +11 -14
- package/lib/less/parse-tree.js +52 -53
- package/lib/less/parse.js +44 -44
- package/lib/less/parser/parser-input.js +151 -113
- package/lib/less/parser/parser.js +864 -658
- 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 +56 -43
- 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 +28 -15
- 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 +20 -21
- package/lib/less-node/plugin-loader.js +35 -27
- package/lib/less-node/url-file-manager.js +33 -31
- package/package.json +29 -18
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -63
- package/Gruntfile.js +0 -403
- 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/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/scripts/coverage-lines.js +0 -207
- package/scripts/coverage-report.js +0 -158
- package/scripts/postinstall.js +0 -61
- package/test/.eslintrc.json +0 -9
- package/test/README.md +0 -3
- package/test/browser/common.js +0 -251
- 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 -184
- package/test/browser/generator/runner.js +0 -2
- package/test/browser/generator/template.js +0 -104
- 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-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 -307
- package/test/less-test.js +0 -984
- 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/comprehensive.json +0 -1
- package/test/sourcemaps/custom-props.json +0 -1
- package/test/sourcemaps/index.html +0 -17
- package/test/sourcemaps/sourcemaps-basepath.json +0 -1
- package/test/sourcemaps/sourcemaps-include-source.json +0 -1
- package/test/sourcemaps/sourcemaps-rootpath.json +0 -1
- package/test/sourcemaps/sourcemaps-url.json +0 -1
- 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/test.less +0 -1
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -21
package/lib/less/tree/index.js
CHANGED
|
@@ -1,85 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var namespace_value_1 = tslib_1.__importDefault(require("./namespace-value"));
|
|
1
|
+
// @ts-check
|
|
2
|
+
import Node from './node.js';
|
|
3
|
+
import Color from './color.js';
|
|
4
|
+
import AtRule from './atrule.js';
|
|
5
|
+
import DetachedRuleset from './detached-ruleset.js';
|
|
6
|
+
import Operation from './operation.js';
|
|
7
|
+
import Dimension from './dimension.js';
|
|
8
|
+
import Unit from './unit.js';
|
|
9
|
+
import Keyword from './keyword.js';
|
|
10
|
+
import Variable from './variable.js';
|
|
11
|
+
import Property from './property.js';
|
|
12
|
+
import Ruleset from './ruleset.js';
|
|
13
|
+
import Element from './element.js';
|
|
14
|
+
import Attribute from './attribute.js';
|
|
15
|
+
import Combinator from './combinator.js';
|
|
16
|
+
import Selector from './selector.js';
|
|
17
|
+
import Quoted from './quoted.js';
|
|
18
|
+
import Expression from './expression.js';
|
|
19
|
+
import Declaration from './declaration.js';
|
|
20
|
+
import Call from './call.js';
|
|
21
|
+
import URL from './url.js';
|
|
22
|
+
import Import from './import.js';
|
|
23
|
+
import Comment from './comment.js';
|
|
24
|
+
import Anonymous from './anonymous.js';
|
|
25
|
+
import Value from './value.js';
|
|
26
|
+
import JavaScript from './javascript.js';
|
|
27
|
+
import Assignment from './assignment.js';
|
|
28
|
+
import Condition from './condition.js';
|
|
29
|
+
import QueryInParens from './query-in-parens.js';
|
|
30
|
+
import Paren from './paren.js';
|
|
31
|
+
import Media from './media.js';
|
|
32
|
+
import Container from './container.js';
|
|
33
|
+
import UnicodeDescriptor from './unicode-descriptor.js';
|
|
34
|
+
import Negative from './negative.js';
|
|
35
|
+
import Extend from './extend.js';
|
|
36
|
+
import VariableCall from './variable-call.js';
|
|
37
|
+
import NamespaceValue from './namespace-value.js';
|
|
38
|
+
|
|
40
39
|
// mixins
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Color
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Property: property_1.default,
|
|
54
|
-
Ruleset: ruleset_1.default,
|
|
55
|
-
Element: element_1.default,
|
|
56
|
-
Attribute: attribute_1.default,
|
|
57
|
-
Combinator: combinator_1.default,
|
|
58
|
-
Selector: selector_1.default,
|
|
59
|
-
Quoted: quoted_1.default,
|
|
60
|
-
Expression: expression_1.default,
|
|
61
|
-
Declaration: declaration_1.default,
|
|
62
|
-
Call: call_1.default,
|
|
63
|
-
URL: url_1.default,
|
|
64
|
-
Import: import_1.default,
|
|
65
|
-
Comment: comment_1.default,
|
|
66
|
-
Anonymous: anonymous_1.default,
|
|
67
|
-
Value: value_1.default,
|
|
68
|
-
JavaScript: javascript_1.default,
|
|
69
|
-
Assignment: assignment_1.default,
|
|
70
|
-
Condition: condition_1.default,
|
|
71
|
-
Paren: paren_1.default,
|
|
72
|
-
Media: media_1.default,
|
|
73
|
-
Container: container_1.default,
|
|
74
|
-
QueryInParens: query_in_parens_1.default,
|
|
75
|
-
UnicodeDescriptor: unicode_descriptor_1.default,
|
|
76
|
-
Negative: negative_1.default,
|
|
77
|
-
Extend: extend_1.default,
|
|
78
|
-
VariableCall: variable_call_1.default,
|
|
79
|
-
NamespaceValue: namespace_value_1.default,
|
|
40
|
+
import MixinCall from './mixin-call.js';
|
|
41
|
+
import MixinDefinition from './mixin-definition.js';
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
Node, Color, AtRule, DetachedRuleset, Operation,
|
|
45
|
+
Dimension, Unit, Keyword, Variable, Property,
|
|
46
|
+
Ruleset, Element, Attribute, Combinator, Selector,
|
|
47
|
+
Quoted, Expression, Declaration, Call, URL, Import,
|
|
48
|
+
Comment, Anonymous, Value, JavaScript, Assignment,
|
|
49
|
+
Condition, Paren, Media, Container, QueryInParens,
|
|
50
|
+
UnicodeDescriptor, Negative, Extend, VariableCall,
|
|
51
|
+
NamespaceValue,
|
|
80
52
|
mixin: {
|
|
81
|
-
Call:
|
|
82
|
-
Definition:
|
|
53
|
+
Call: MixinCall,
|
|
54
|
+
Definition: MixinDefinition
|
|
83
55
|
}
|
|
84
56
|
};
|
|
85
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,34 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
/** @import { EvalContext, FileInfo } from './node.js' */
|
|
3
|
+
import JsEvalNode from './js-eval-node.js';
|
|
4
|
+
import Dimension from './dimension.js';
|
|
5
|
+
import Quoted from './quoted.js';
|
|
6
|
+
import Anonymous from './anonymous.js';
|
|
7
|
+
|
|
8
|
+
class JavaScript extends JsEvalNode {
|
|
9
|
+
get type() { return 'JavaScript'; }
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} string
|
|
13
|
+
* @param {boolean} escaped
|
|
14
|
+
* @param {number} index
|
|
15
|
+
* @param {FileInfo} currentFileInfo
|
|
16
|
+
*/
|
|
17
|
+
constructor(string, escaped, index, currentFileInfo) {
|
|
18
|
+
super();
|
|
19
|
+
this.escaped = escaped;
|
|
20
|
+
this.expression = string;
|
|
21
|
+
this._index = index;
|
|
22
|
+
this._fileInfo = currentFileInfo;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {EvalContext} context
|
|
27
|
+
* @returns {Dimension | Quoted | Anonymous}
|
|
28
|
+
*/
|
|
29
|
+
eval(context) {
|
|
30
|
+
const result = this.evaluateJavaScript(this.expression, context);
|
|
31
|
+
const type = typeof result;
|
|
32
|
+
|
|
33
|
+
if (type === 'number' && !isNaN(/** @type {number} */ (result))) {
|
|
34
|
+
return new Dimension(/** @type {number} */ (result));
|
|
35
|
+
} else if (type === 'string') {
|
|
36
|
+
return new Quoted(`"${result}"`, /** @type {string} */ (result), this.escaped, this._index);
|
|
37
|
+
} else if (Array.isArray(result)) {
|
|
38
|
+
return new Anonymous(/** @type {string[]} */ (result).join(', '));
|
|
39
|
+
} else {
|
|
40
|
+
return new Anonymous(/** @type {string} */ (result));
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default JavaScript;
|
|
@@ -1,60 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
/** @import { EvalContext } from './node.js' */
|
|
3
|
+
import Node from './node.js';
|
|
4
|
+
import Variable from './variable.js';
|
|
5
|
+
|
|
6
|
+
class JsEvalNode extends Node {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} expression
|
|
9
|
+
* @param {EvalContext} context
|
|
10
|
+
* @returns {string | number | boolean}
|
|
11
|
+
*/
|
|
12
|
+
evaluateJavaScript(expression, context) {
|
|
13
|
+
let result;
|
|
14
|
+
const that = this;
|
|
15
|
+
/** @type {Record<string, { value: Node, toJS: () => string }>} */
|
|
16
|
+
const evalContext = {};
|
|
17
|
+
|
|
12
18
|
if (!context.javascriptEnabled) {
|
|
13
19
|
throw { message: 'Inline JavaScript is not enabled. Is it set in your options?',
|
|
14
20
|
filename: this.fileInfo().filename,
|
|
15
21
|
index: this.getIndex() };
|
|
16
22
|
}
|
|
23
|
+
|
|
17
24
|
expression = expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
|
|
18
|
-
return that.jsify(new
|
|
25
|
+
return that.jsify(new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context));
|
|
19
26
|
});
|
|
27
|
+
|
|
28
|
+
/** @type {Function} */
|
|
29
|
+
let expressionFunc;
|
|
20
30
|
try {
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
throw { message: "JavaScript evaluation error: ".concat(e.message, " from `").concat(expression, "`"),
|
|
31
|
+
expressionFunc = new Function(`return (${expression})`);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
throw { message: `JavaScript evaluation error: ${/** @type {Error} */ (e).message} from \`${expression}\`` ,
|
|
25
34
|
filename: this.fileInfo().filename,
|
|
26
35
|
index: this.getIndex() };
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
|
|
38
|
+
const variables = /** @type {Node & { variables: () => Record<string, { value: Node }> }} */ (context.frames[0]).variables();
|
|
39
|
+
for (const k in variables) {
|
|
30
40
|
// eslint-disable-next-line no-prototype-builtins
|
|
31
41
|
if (variables.hasOwnProperty(k)) {
|
|
32
42
|
evalContext[k.slice(1)] = {
|
|
33
43
|
value: variables[k].value,
|
|
34
44
|
toJS: function () {
|
|
35
|
-
return this.value.eval(context).toCSS();
|
|
45
|
+
return this.value.eval(context).toCSS(context);
|
|
36
46
|
}
|
|
37
47
|
};
|
|
38
48
|
}
|
|
39
49
|
}
|
|
50
|
+
|
|
40
51
|
try {
|
|
41
|
-
result =
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
throw { message: "JavaScript evaluation error: '".concat(e.name, ": ").concat(e.message.replace(/["]/g, '\''), "'"),
|
|
52
|
+
result = expressionFunc.call(evalContext);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
throw { message: `JavaScript evaluation error: '${/** @type {Error} */ (e).name}: ${/** @type {Error} */ (e).message.replace(/["]/g, '\'')}'` ,
|
|
45
55
|
filename: this.fileInfo().filename,
|
|
46
56
|
index: this.getIndex() };
|
|
47
57
|
}
|
|
48
58
|
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {Node} obj
|
|
63
|
+
* @returns {string}
|
|
64
|
+
*/
|
|
65
|
+
jsify(obj) {
|
|
51
66
|
if (Array.isArray(obj.value) && (obj.value.length > 1)) {
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return obj.toCSS();
|
|
67
|
+
return `[${obj.value.map(function (v) { return v.toCSS(/** @type {EvalContext} */ (undefined)); }).join(', ')}]`;
|
|
68
|
+
} else {
|
|
69
|
+
return obj.toCSS(/** @type {EvalContext} */ (undefined));
|
|
56
70
|
}
|
|
57
71
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default JsEvalNode;
|
package/lib/less/tree/keyword.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
output.add(this.value);
|
|
1
|
+
// @ts-check
|
|
2
|
+
import Node from './node.js';
|
|
3
|
+
|
|
4
|
+
/** @import { EvalContext, CSSOutput } from './node.js' */
|
|
5
|
+
|
|
6
|
+
class Keyword extends Node {
|
|
7
|
+
get type() { return 'Keyword'; }
|
|
8
|
+
|
|
9
|
+
/** @param {string} value */
|
|
10
|
+
constructor(value) {
|
|
11
|
+
super();
|
|
12
|
+
this.value = value;
|
|
15
13
|
}
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {EvalContext} context
|
|
17
|
+
* @param {CSSOutput} output
|
|
18
|
+
*/
|
|
19
|
+
genCSS(context, output) {
|
|
20
|
+
if (this.value === '%') { throw { type: 'Syntax', message: 'Invalid % without number' }; }
|
|
21
|
+
output.add(/** @type {string} */ (this.value));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
Keyword.True = new Keyword('true');
|
|
18
26
|
Keyword.False = new Keyword('false');
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
|
|
28
|
+
export default Keyword;
|
package/lib/less/tree/media.js
CHANGED
|
@@ -1,48 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
/** @import { EvalContext, CSSOutput, FileInfo, VisibilityInfo } from './node.js' */
|
|
3
|
+
/** @import { NestableAtRuleThis } from './nested-at-rule.js' */
|
|
4
|
+
/** @import { RulesetLikeNode } from './atrule.js' */
|
|
5
|
+
import Node from './node.js';
|
|
6
|
+
import Ruleset from './ruleset.js';
|
|
7
|
+
import Value from './value.js';
|
|
8
|
+
import Selector from './selector.js';
|
|
9
|
+
import AtRule from './atrule.js';
|
|
10
|
+
import NestableAtRulePrototype from './nested-at-rule.js';
|
|
11
|
+
|
|
12
|
+
class Media extends AtRule {
|
|
13
|
+
get type() { return 'Media'; }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {Node[] | null} value
|
|
17
|
+
* @param {Node[]} features
|
|
18
|
+
* @param {number} [index]
|
|
19
|
+
* @param {FileInfo} [currentFileInfo]
|
|
20
|
+
* @param {VisibilityInfo} [visibilityInfo]
|
|
21
|
+
*/
|
|
22
|
+
constructor(value, features, index, currentFileInfo, visibilityInfo) {
|
|
23
|
+
super();
|
|
24
|
+
this._index = index;
|
|
25
|
+
this._fileInfo = currentFileInfo;
|
|
26
|
+
|
|
27
|
+
const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();
|
|
28
|
+
|
|
29
|
+
/** @type {Value} */
|
|
30
|
+
this.features = new Value(features);
|
|
31
|
+
/** @type {RulesetLikeNode[]} */
|
|
32
|
+
this.rules = [new Ruleset(selectors, value)];
|
|
33
|
+
/** @type {RulesetLikeNode} */ (this.rules[0]).allowImports = true;
|
|
34
|
+
this.copyVisibilityInfo(visibilityInfo);
|
|
35
|
+
this.allowRoot = true;
|
|
36
|
+
this.setParent(selectors, /** @type {Node} */ (/** @type {unknown} */ (this)));
|
|
37
|
+
this.setParent(this.features, /** @type {Node} */ (/** @type {unknown} */ (this)));
|
|
38
|
+
this.setParent(this.rules, /** @type {Node} */ (/** @type {unknown} */ (this)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {EvalContext} context
|
|
43
|
+
* @param {CSSOutput} output
|
|
44
|
+
*/
|
|
45
|
+
genCSS(context, output) {
|
|
23
46
|
output.add('@media ', this._fileInfo, this._index);
|
|
24
47
|
this.features.genCSS(context, output);
|
|
25
48
|
this.outputRuleset(context, output, this.rules);
|
|
26
|
-
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {EvalContext} context
|
|
53
|
+
* @returns {Node}
|
|
54
|
+
*/
|
|
55
|
+
eval(context) {
|
|
27
56
|
if (!context.mediaBlocks) {
|
|
28
57
|
context.mediaBlocks = [];
|
|
29
58
|
context.mediaPath = [];
|
|
30
59
|
}
|
|
31
|
-
|
|
60
|
+
|
|
61
|
+
const media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo());
|
|
32
62
|
if (this.debugInfo) {
|
|
33
|
-
this.rules[0].debugInfo = this.debugInfo;
|
|
63
|
+
/** @type {RulesetLikeNode} */ (this.rules[0]).debugInfo = this.debugInfo;
|
|
34
64
|
media.debugInfo = this.debugInfo;
|
|
35
65
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
|
|
67
|
+
media.features = /** @type {Value} */ (this.features.eval(context));
|
|
68
|
+
|
|
69
|
+
context.mediaPath.push(/** @type {Node} */ (/** @type {unknown} */ (media)));
|
|
70
|
+
context.mediaBlocks.push(/** @type {Node} */ (/** @type {unknown} */ (media)));
|
|
71
|
+
|
|
72
|
+
const fr = /** @type {RulesetLikeNode} */ (context.frames[0]).functionRegistry;
|
|
73
|
+
if (fr) {
|
|
74
|
+
/** @type {RulesetLikeNode} */ (this.rules[0]).functionRegistry = fr.inherit();
|
|
75
|
+
}
|
|
40
76
|
context.frames.unshift(this.rules[0]);
|
|
41
|
-
media.rules = [this.rules[0].eval(context)];
|
|
77
|
+
media.rules = [/** @type {RulesetLikeNode} */ (this.rules[0].eval(context))];
|
|
42
78
|
context.frames.shift();
|
|
79
|
+
|
|
43
80
|
context.mediaPath.pop();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
81
|
+
|
|
82
|
+
return context.mediaPath.length === 0 ? /** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalTop(context) :
|
|
83
|
+
/** @type {NestableAtRuleThis} */ (/** @type {unknown} */ (media)).evalNested(context);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Apply NestableAtRulePrototype methods (accept, isRulesetLike override AtRule's versions)
|
|
88
|
+
Object.assign(Media.prototype, NestableAtRulePrototype);
|
|
89
|
+
|
|
90
|
+
export default Media;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import Expression from './expression.js';
|
|
3
|
+
import Value from './value.js';
|
|
4
|
+
import Node from './node.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Merges declarations with merge flags (+ or ,) into combined values.
|
|
8
|
+
* Used by both the ToCSSVisitor and AtRule eval.
|
|
9
|
+
* @param {Node[]} rules
|
|
10
|
+
*/
|
|
11
|
+
export default function mergeRules(rules) {
|
|
12
|
+
if (!rules) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @type {Record<string, Array<Node & { merge: string, name: string, value: Node, important: string }>>} */
|
|
17
|
+
const groups = {};
|
|
18
|
+
/** @type {Array<Array<Node & { merge: string, name: string, value: Node, important: string }>>} */
|
|
19
|
+
const groupsArr = [];
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < rules.length; i++) {
|
|
22
|
+
const rule = /** @type {Node & { merge: string, name: string }} */ (rules[i]);
|
|
23
|
+
if (rule.merge) {
|
|
24
|
+
const key = rule.name;
|
|
25
|
+
groups[key] ? rules.splice(i--, 1) :
|
|
26
|
+
groupsArr.push(groups[key] = []);
|
|
27
|
+
groups[key].push(/** @type {Node & { merge: string, name: string, value: Node, important: string }} */ (rule));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
groupsArr.forEach(group => {
|
|
32
|
+
if (group.length > 0) {
|
|
33
|
+
const result = group[0];
|
|
34
|
+
/** @type {Node[]} */
|
|
35
|
+
let space = [];
|
|
36
|
+
const comma = [new Expression(space)];
|
|
37
|
+
group.forEach(rule => {
|
|
38
|
+
if ((rule.merge === '+') && (space.length > 0)) {
|
|
39
|
+
comma.push(new Expression(space = []));
|
|
40
|
+
}
|
|
41
|
+
space.push(rule.value);
|
|
42
|
+
result.important = result.important || rule.important;
|
|
43
|
+
});
|
|
44
|
+
result.value = new Value(comma);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|