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,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var utils = tslib_1.__importStar(require("../utils"));
|
|
6
|
-
var defaultFunc = {
|
|
1
|
+
import Keyword from '../tree/keyword.js';
|
|
2
|
+
import * as utils from '../utils.js';
|
|
3
|
+
|
|
4
|
+
const defaultFunc = {
|
|
7
5
|
eval: function () {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const v = this.value_;
|
|
7
|
+
const e = this.error_;
|
|
10
8
|
if (e) {
|
|
11
9
|
throw e;
|
|
12
10
|
}
|
|
13
11
|
if (!utils.isNullOrUndefined(v)) {
|
|
14
|
-
return v ?
|
|
12
|
+
return v ? Keyword.True : Keyword.False;
|
|
15
13
|
}
|
|
16
14
|
},
|
|
17
15
|
value: function (v) {
|
|
@@ -24,5 +22,5 @@ var defaultFunc = {
|
|
|
24
22
|
this.value_ = this.error_ = null;
|
|
25
23
|
}
|
|
26
24
|
};
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
|
|
26
|
+
export default defaultFunc;
|
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var functionCaller = /** @class */ (function () {
|
|
6
|
-
function functionCaller(name, context, index, currentFileInfo) {
|
|
1
|
+
import Expression from '../tree/expression.js';
|
|
2
|
+
|
|
3
|
+
class functionCaller {
|
|
4
|
+
constructor(name, context, index, currentFileInfo) {
|
|
7
5
|
this.name = name.toLowerCase();
|
|
8
6
|
this.index = index;
|
|
9
7
|
this.context = context;
|
|
10
8
|
this.currentFileInfo = currentFileInfo;
|
|
9
|
+
|
|
11
10
|
this.func = context.frames[0].functionRegistry.get(this.name);
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
isValid() {
|
|
14
14
|
return Boolean(this.func);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
call(args) {
|
|
18
18
|
if (!(Array.isArray(args))) {
|
|
19
19
|
args = [args];
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
const evalArgs = this.func.evalArgs;
|
|
22
22
|
if (evalArgs !== false) {
|
|
23
|
-
args = args.map(
|
|
23
|
+
args = args.map(a => a.eval(this.context));
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const commentFilter = item => !(item.type === 'Comment');
|
|
26
|
+
|
|
26
27
|
// This code is terrible and should be replaced as per this issue...
|
|
27
28
|
// https://github.com/less/less.js/issues/2477
|
|
28
29
|
args = args
|
|
29
30
|
.filter(commentFilter)
|
|
30
|
-
.map(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
.map(item => {
|
|
32
|
+
if (item.type === 'Expression') {
|
|
33
|
+
const subNodes = item.value.filter(commentFilter);
|
|
34
|
+
if (subNodes.length === 1) {
|
|
35
|
+
// https://github.com/less/less.js/issues/3616
|
|
36
|
+
if (item.parens && subNodes[0].op === '/') {
|
|
37
|
+
return item;
|
|
38
|
+
}
|
|
39
|
+
return subNodes[0];
|
|
40
|
+
} else {
|
|
41
|
+
return new Expression(subNodes);
|
|
37
42
|
}
|
|
38
|
-
return subNodes[0];
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return new expression_1.default(subNodes);
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
return item;
|
|
45
|
+
});
|
|
46
|
+
|
|
46
47
|
if (evalArgs === false) {
|
|
47
|
-
return this.func
|
|
48
|
+
return this.func(this.context, ...args);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
|
|
51
|
+
return this.func(...args);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default functionCaller;
|
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function makeRegistry(base) {
|
|
1
|
+
function makeRegistry( base ) {
|
|
4
2
|
return {
|
|
5
3
|
_data: {},
|
|
6
|
-
add: function
|
|
4
|
+
add: function(name, func) {
|
|
7
5
|
// precautionary case conversion, as later querying of
|
|
8
6
|
// the registry by function-caller uses lower case as well.
|
|
9
7
|
name = name.toLowerCase();
|
|
8
|
+
|
|
10
9
|
// eslint-disable-next-line no-prototype-builtins
|
|
11
10
|
if (this._data.hasOwnProperty(name)) {
|
|
12
11
|
// TODO warn
|
|
13
12
|
}
|
|
14
13
|
this._data[name] = func;
|
|
15
14
|
},
|
|
16
|
-
addMultiple: function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
addMultiple: function(functions) {
|
|
16
|
+
Object.keys(functions).forEach(
|
|
17
|
+
name => {
|
|
18
|
+
this.add(name, functions[name]);
|
|
19
|
+
});
|
|
21
20
|
},
|
|
22
|
-
get: function
|
|
23
|
-
return this._data[name] || (base && base.get(name));
|
|
21
|
+
get: function(name) {
|
|
22
|
+
return this._data[name] || ( base && base.get( name ));
|
|
24
23
|
},
|
|
25
|
-
getLocalFunctions: function
|
|
24
|
+
getLocalFunctions: function() {
|
|
26
25
|
return this._data;
|
|
27
26
|
},
|
|
28
|
-
inherit: function
|
|
29
|
-
return makeRegistry(this);
|
|
27
|
+
inherit: function() {
|
|
28
|
+
return makeRegistry( this );
|
|
30
29
|
},
|
|
31
|
-
create: function
|
|
30
|
+
create: function(base) {
|
|
32
31
|
return makeRegistry(base);
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
|
|
36
|
+
export default makeRegistry( null );
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import functionRegistry from './function-registry.js';
|
|
2
|
+
import functionCaller from './function-caller.js';
|
|
3
|
+
|
|
4
|
+
import boolean from './boolean.js';
|
|
5
|
+
import defaultFunc from './default.js';
|
|
6
|
+
import color from './color.js';
|
|
7
|
+
import colorBlending from './color-blending.js';
|
|
8
|
+
import dataUri from './data-uri.js';
|
|
9
|
+
import list from './list.js';
|
|
10
|
+
import math from './math.js';
|
|
11
|
+
import number from './number.js';
|
|
12
|
+
import string from './string.js';
|
|
13
|
+
import svg from './svg.js';
|
|
14
|
+
import types from './types.js';
|
|
15
|
+
import style from './style.js';
|
|
16
|
+
|
|
17
|
+
export default environment => {
|
|
18
|
+
const functions = { functionRegistry, functionCaller };
|
|
19
|
+
|
|
20
20
|
// register functions
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
functionRegistry.addMultiple(boolean);
|
|
22
|
+
functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));
|
|
23
|
+
functionRegistry.addMultiple(color);
|
|
24
|
+
functionRegistry.addMultiple(colorBlending);
|
|
25
|
+
functionRegistry.addMultiple(dataUri(environment));
|
|
26
|
+
functionRegistry.addMultiple(list);
|
|
27
|
+
functionRegistry.addMultiple(math);
|
|
28
|
+
functionRegistry.addMultiple(number);
|
|
29
|
+
functionRegistry.addMultiple(string);
|
|
30
|
+
functionRegistry.addMultiple(svg(environment));
|
|
31
|
+
functionRegistry.addMultiple(types);
|
|
32
|
+
functionRegistry.addMultiple(style);
|
|
33
|
+
|
|
33
34
|
return functions;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
|
35
|
+
};
|
|
@@ -1,58 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var value_1 = tslib_1.__importDefault(require("../tree/value"));
|
|
14
|
-
var getItemsFromNode = function (node) {
|
|
1
|
+
import Comment from '../tree/comment.js';
|
|
2
|
+
import Node from '../tree/node.js';
|
|
3
|
+
import Dimension from '../tree/dimension.js';
|
|
4
|
+
import Declaration from '../tree/declaration.js';
|
|
5
|
+
import Expression from '../tree/expression.js';
|
|
6
|
+
import Ruleset from '../tree/ruleset.js';
|
|
7
|
+
import Selector from '../tree/selector.js';
|
|
8
|
+
import Element from '../tree/element.js';
|
|
9
|
+
import Quote from '../tree/quoted.js';
|
|
10
|
+
import Value from '../tree/value.js';
|
|
11
|
+
|
|
12
|
+
const getItemsFromNode = node => {
|
|
15
13
|
// handle non-array values as an array of length 1
|
|
16
14
|
// return 'undefined' if index is invalid
|
|
17
|
-
|
|
15
|
+
const items = Array.isArray(node.value) ?
|
|
18
16
|
node.value : Array(node);
|
|
17
|
+
|
|
19
18
|
return items;
|
|
20
19
|
};
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
_SELF: function(n) {
|
|
23
23
|
return n;
|
|
24
24
|
},
|
|
25
|
-
'~': function
|
|
26
|
-
var expr = [];
|
|
27
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
28
|
-
expr[_i] = arguments[_i];
|
|
29
|
-
}
|
|
25
|
+
'~': function(...expr) {
|
|
30
26
|
if (expr.length === 1) {
|
|
31
27
|
return expr[0];
|
|
32
28
|
}
|
|
33
|
-
return new
|
|
29
|
+
return new Value(expr);
|
|
34
30
|
},
|
|
35
|
-
extract: function
|
|
31
|
+
extract: function(values, index) {
|
|
36
32
|
// (1-based index)
|
|
37
33
|
index = index.value - 1;
|
|
34
|
+
|
|
38
35
|
return getItemsFromNode(values)[index];
|
|
39
36
|
},
|
|
40
|
-
length: function
|
|
41
|
-
return new
|
|
37
|
+
length: function(values) {
|
|
38
|
+
return new Dimension(getItemsFromNode(values).length);
|
|
42
39
|
},
|
|
43
40
|
/**
|
|
44
41
|
* Creates a Less list of incremental values.
|
|
45
42
|
* Modeled after Lodash's range function, also exists natively in PHP
|
|
46
|
-
*
|
|
43
|
+
*
|
|
47
44
|
* @param {Dimension} [start=1]
|
|
48
45
|
* @param {Dimension} end - e.g. 10 or 10px - unit is added to output
|
|
49
|
-
* @param {Dimension} [step=1]
|
|
46
|
+
* @param {Dimension} [step=1]
|
|
50
47
|
*/
|
|
51
|
-
range: function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
range: function(start, end, step) {
|
|
49
|
+
let from;
|
|
50
|
+
let to;
|
|
51
|
+
let stepValue = 1;
|
|
52
|
+
const list = [];
|
|
56
53
|
if (end) {
|
|
57
54
|
to = end;
|
|
58
55
|
from = start.value;
|
|
@@ -64,82 +61,98 @@ exports.default = {
|
|
|
64
61
|
from = 1;
|
|
65
62
|
to = start;
|
|
66
63
|
}
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
|
|
65
|
+
for (let i = from; i <= to.value; i += stepValue) {
|
|
66
|
+
list.push(new Dimension(i, to.unit));
|
|
69
67
|
}
|
|
70
|
-
|
|
68
|
+
|
|
69
|
+
return new Expression(list);
|
|
71
70
|
},
|
|
72
|
-
each: function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (val instanceof
|
|
79
|
-
return val.eval(
|
|
71
|
+
each: function(list, rs) {
|
|
72
|
+
const rules = [];
|
|
73
|
+
let newRules;
|
|
74
|
+
let iterator;
|
|
75
|
+
|
|
76
|
+
const tryEval = val => {
|
|
77
|
+
if (val instanceof Node) {
|
|
78
|
+
return val.eval(this.context);
|
|
80
79
|
}
|
|
81
80
|
return val;
|
|
82
81
|
};
|
|
83
|
-
|
|
82
|
+
|
|
83
|
+
if (list.value && !(list instanceof Quote)) {
|
|
84
84
|
if (Array.isArray(list.value)) {
|
|
85
85
|
iterator = list.value.map(tryEval);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
86
|
+
} else {
|
|
88
87
|
iterator = [tryEval(list.value)];
|
|
89
88
|
}
|
|
90
|
-
}
|
|
91
|
-
else if (list.ruleset) {
|
|
89
|
+
} else if (list.ruleset) {
|
|
92
90
|
iterator = tryEval(list.ruleset).rules;
|
|
93
|
-
}
|
|
94
|
-
else if (list.rules) {
|
|
91
|
+
} else if (list.rules) {
|
|
95
92
|
iterator = list.rules.map(tryEval);
|
|
96
|
-
}
|
|
97
|
-
else if (Array.isArray(list)) {
|
|
93
|
+
} else if (Array.isArray(list)) {
|
|
98
94
|
iterator = list.map(tryEval);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
95
|
+
} else {
|
|
101
96
|
iterator = [tryEval(list)];
|
|
102
97
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
|
|
99
|
+
let valueName = '@value';
|
|
100
|
+
let keyName = '@key';
|
|
101
|
+
let indexName = '@index';
|
|
102
|
+
|
|
106
103
|
if (rs.params) {
|
|
107
104
|
valueName = rs.params[0] && rs.params[0].name;
|
|
108
105
|
keyName = rs.params[1] && rs.params[1].name;
|
|
109
106
|
indexName = rs.params[2] && rs.params[2].name;
|
|
110
107
|
rs = rs.rules;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
108
|
+
} else {
|
|
113
109
|
rs = rs.ruleset;
|
|
114
110
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
|
|
112
|
+
for (let i = 0; i < iterator.length; i++) {
|
|
113
|
+
let key;
|
|
114
|
+
let value;
|
|
115
|
+
const item = iterator[i];
|
|
116
|
+
if (item instanceof Declaration) {
|
|
120
117
|
key = typeof item.name === 'string' ? item.name : item.name[0].value;
|
|
121
118
|
value = item.value;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
key = new dimension_1.default(i + 1);
|
|
119
|
+
} else {
|
|
120
|
+
key = new Dimension(i + 1);
|
|
125
121
|
value = item;
|
|
126
122
|
}
|
|
127
|
-
|
|
123
|
+
|
|
124
|
+
if (item instanceof Comment) {
|
|
128
125
|
continue;
|
|
129
126
|
}
|
|
127
|
+
|
|
130
128
|
newRules = rs.rules.slice(0);
|
|
131
129
|
if (valueName) {
|
|
132
|
-
newRules.push(new
|
|
130
|
+
newRules.push(new Declaration(valueName,
|
|
131
|
+
value,
|
|
132
|
+
false, false, this.index, this.currentFileInfo));
|
|
133
133
|
}
|
|
134
134
|
if (indexName) {
|
|
135
|
-
newRules.push(new
|
|
135
|
+
newRules.push(new Declaration(indexName,
|
|
136
|
+
new Dimension(i + 1),
|
|
137
|
+
false, false, this.index, this.currentFileInfo));
|
|
136
138
|
}
|
|
137
139
|
if (keyName) {
|
|
138
|
-
newRules.push(new
|
|
140
|
+
newRules.push(new Declaration(keyName,
|
|
141
|
+
key,
|
|
142
|
+
false, false, this.index, this.currentFileInfo));
|
|
139
143
|
}
|
|
140
|
-
|
|
144
|
+
|
|
145
|
+
rules.push(new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
|
|
146
|
+
newRules,
|
|
147
|
+
rs.strictImports,
|
|
148
|
+
rs.visibilityInfo()
|
|
149
|
+
));
|
|
141
150
|
}
|
|
142
|
-
|
|
151
|
+
|
|
152
|
+
return new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
|
|
153
|
+
rules,
|
|
154
|
+
rs.strictImports,
|
|
155
|
+
rs.visibilityInfo()
|
|
156
|
+
).eval(this.context);
|
|
143
157
|
}
|
|
144
158
|
};
|
|
145
|
-
//# sourceMappingURL=list.js.map
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var MathHelper = function (fn, unit, n) {
|
|
6
|
-
if (!(n instanceof dimension_1.default)) {
|
|
1
|
+
import Dimension from '../tree/dimension.js';
|
|
2
|
+
|
|
3
|
+
const MathHelper = (fn, unit, n) => {
|
|
4
|
+
if (!(n instanceof Dimension)) {
|
|
7
5
|
throw { type: 'Argument', message: 'argument must be a number' };
|
|
8
6
|
}
|
|
9
7
|
if (unit === null) {
|
|
10
8
|
unit = n.unit;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
9
|
+
} else {
|
|
13
10
|
n = n.unify();
|
|
14
11
|
}
|
|
15
|
-
return new
|
|
12
|
+
return new Dimension(fn(parseFloat(n.value)), unit);
|
|
16
13
|
};
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
|
|
15
|
+
export default MathHelper;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js"));
|
|
5
|
-
var mathFunctions = {
|
|
1
|
+
import mathHelper from './math-helper.js';
|
|
2
|
+
|
|
3
|
+
const mathFunctions = {
|
|
6
4
|
// name, unit
|
|
7
|
-
ceil:
|
|
5
|
+
ceil: null,
|
|
8
6
|
floor: null,
|
|
9
|
-
sqrt:
|
|
10
|
-
abs:
|
|
11
|
-
tan:
|
|
12
|
-
sin:
|
|
13
|
-
cos:
|
|
14
|
-
atan:
|
|
15
|
-
asin:
|
|
16
|
-
acos:
|
|
7
|
+
sqrt: null,
|
|
8
|
+
abs: null,
|
|
9
|
+
tan: '',
|
|
10
|
+
sin: '',
|
|
11
|
+
cos: '',
|
|
12
|
+
atan: 'rad',
|
|
13
|
+
asin: 'rad',
|
|
14
|
+
acos: 'rad'
|
|
17
15
|
};
|
|
18
|
-
|
|
16
|
+
|
|
17
|
+
for (const f in mathFunctions) {
|
|
19
18
|
// eslint-disable-next-line no-prototype-builtins
|
|
20
19
|
if (mathFunctions.hasOwnProperty(f)) {
|
|
21
|
-
mathFunctions[f] =
|
|
20
|
+
mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
|
|
24
|
+
mathFunctions.round = (n, f) => {
|
|
25
|
+
const fraction = typeof f === 'undefined' ? 0 : f.value;
|
|
26
|
+
return mathHelper(num => num.toFixed(fraction), null, n);
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
export default mathFunctions;
|