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,39 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js"));
|
|
7
|
-
var minMax = function (isMin, args) {
|
|
8
|
-
var _this = this;
|
|
1
|
+
import Dimension from '../tree/dimension.js';
|
|
2
|
+
import Anonymous from '../tree/anonymous.js';
|
|
3
|
+
import mathHelper from './math-helper.js';
|
|
4
|
+
|
|
5
|
+
const minMax = function (isMin, args) {
|
|
9
6
|
args = Array.prototype.slice.call(args);
|
|
10
7
|
switch (args.length) {
|
|
11
8
|
case 0: throw { type: 'Argument', message: 'one or more arguments required' };
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
let i; // key is the unit.toString() for unified Dimension values,
|
|
11
|
+
let j;
|
|
12
|
+
let current;
|
|
13
|
+
let currentUnified;
|
|
14
|
+
let referenceUnified;
|
|
15
|
+
let unit;
|
|
16
|
+
let unitStatic;
|
|
17
|
+
let unitClone;
|
|
18
|
+
|
|
19
|
+
const // elems only contains original argument values.
|
|
20
|
+
order = [];
|
|
21
|
+
|
|
22
|
+
const values = {};
|
|
24
23
|
// value is the index into the order array.
|
|
25
24
|
for (i = 0; i < args.length; i++) {
|
|
26
25
|
current = args[i];
|
|
27
|
-
if (!(current instanceof
|
|
26
|
+
if (!(current instanceof Dimension)) {
|
|
28
27
|
if (Array.isArray(args[i].value)) {
|
|
29
28
|
Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
|
|
30
29
|
continue;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
30
|
+
} else {
|
|
33
31
|
throw { type: 'Argument', message: 'incompatible types' };
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new
|
|
34
|
+
currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();
|
|
37
35
|
unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
|
|
38
36
|
unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;
|
|
39
37
|
unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;
|
|
@@ -46,8 +44,8 @@ var minMax = function (isMin, args) {
|
|
|
46
44
|
order.push(current);
|
|
47
45
|
continue;
|
|
48
46
|
}
|
|
49
|
-
referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new
|
|
50
|
-
if (isMin && currentUnified.value < referenceUnified.value ||
|
|
47
|
+
referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();
|
|
48
|
+
if ( isMin && currentUnified.value < referenceUnified.value ||
|
|
51
49
|
!isMin && currentUnified.value > referenceUnified.value) {
|
|
52
50
|
order[j] = current;
|
|
53
51
|
}
|
|
@@ -55,52 +53,43 @@ var minMax = function (isMin, args) {
|
|
|
55
53
|
if (order.length == 1) {
|
|
56
54
|
return order[0];
|
|
57
55
|
}
|
|
58
|
-
args = order.map(
|
|
59
|
-
return new
|
|
56
|
+
args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
|
|
57
|
+
return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
|
|
60
58
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
65
|
-
args[_i] = arguments[_i];
|
|
66
|
-
}
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
min: function(...args) {
|
|
67
62
|
try {
|
|
68
63
|
return minMax.call(this, true, args);
|
|
69
|
-
}
|
|
70
|
-
catch (e) { }
|
|
64
|
+
} catch (e) {}
|
|
71
65
|
},
|
|
72
|
-
max: function
|
|
73
|
-
var args = [];
|
|
74
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
75
|
-
args[_i] = arguments[_i];
|
|
76
|
-
}
|
|
66
|
+
max: function(...args) {
|
|
77
67
|
try {
|
|
78
68
|
return minMax.call(this, false, args);
|
|
79
|
-
}
|
|
80
|
-
catch (e) { }
|
|
69
|
+
} catch (e) {}
|
|
81
70
|
},
|
|
82
71
|
convert: function (val, unit) {
|
|
83
72
|
return val.convertTo(unit.value);
|
|
84
73
|
},
|
|
85
74
|
pi: function () {
|
|
86
|
-
return new
|
|
75
|
+
return new Dimension(Math.PI);
|
|
87
76
|
},
|
|
88
|
-
mod: function
|
|
89
|
-
return new
|
|
77
|
+
mod: function(a, b) {
|
|
78
|
+
return new Dimension(a.value % b.value, a.unit);
|
|
90
79
|
},
|
|
91
|
-
pow: function
|
|
80
|
+
pow: function(x, y) {
|
|
92
81
|
if (typeof x === 'number' && typeof y === 'number') {
|
|
93
|
-
x = new
|
|
94
|
-
y = new
|
|
95
|
-
}
|
|
96
|
-
else if (!(x instanceof dimension_1.default) || !(y instanceof dimension_1.default)) {
|
|
82
|
+
x = new Dimension(x);
|
|
83
|
+
y = new Dimension(y);
|
|
84
|
+
} else if (!(x instanceof Dimension) || !(y instanceof Dimension)) {
|
|
97
85
|
throw { type: 'Argument', message: 'arguments must be numbers' };
|
|
98
86
|
}
|
|
99
|
-
|
|
87
|
+
|
|
88
|
+
return new Dimension(Math.pow(x.value, y.value), x.unit);
|
|
100
89
|
},
|
|
101
90
|
percentage: function (n) {
|
|
102
|
-
|
|
91
|
+
const result = mathHelper(num => num * 100, '%', n);
|
|
92
|
+
|
|
103
93
|
return result;
|
|
104
94
|
}
|
|
105
95
|
};
|
|
106
|
-
//# sourceMappingURL=number.js.map
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var javascript_1 = tslib_1.__importDefault(require("../tree/javascript"));
|
|
7
|
-
exports.default = {
|
|
1
|
+
import Quoted from '../tree/quoted.js';
|
|
2
|
+
import Anonymous from '../tree/anonymous.js';
|
|
3
|
+
import JavaScript from '../tree/javascript.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
8
6
|
e: function (str) {
|
|
9
|
-
return new
|
|
7
|
+
return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true);
|
|
10
8
|
},
|
|
11
9
|
escape: function (str) {
|
|
12
|
-
return new
|
|
13
|
-
.replace(
|
|
10
|
+
return new Anonymous(
|
|
11
|
+
encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')
|
|
12
|
+
.replace(/\(/g, '%28').replace(/\)/g, '%29'));
|
|
14
13
|
},
|
|
15
14
|
replace: function (string, pattern, replacement, flags) {
|
|
16
|
-
|
|
15
|
+
let result = string.value;
|
|
17
16
|
replacement = (replacement.type === 'Quoted') ?
|
|
18
17
|
replacement.value : replacement.toCSS();
|
|
19
18
|
result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);
|
|
20
|
-
return new
|
|
19
|
+
return new Quoted(string.quote || '', result, string.escaped);
|
|
21
20
|
},
|
|
22
21
|
'%': function (string /* arg, arg, ... */) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
|
23
|
+
let result = string.value;
|
|
24
|
+
|
|
25
|
+
for (let i = 0; i < args.length; i++) {
|
|
26
26
|
/* jshint loopfunc:true */
|
|
27
|
-
result = result.replace(/%[sda]/i,
|
|
28
|
-
|
|
27
|
+
result = result.replace(/%[sda]/i, token => {
|
|
28
|
+
const value = ((args[i].type === 'Quoted') &&
|
|
29
29
|
token.match(/s/i)) ? args[i].value : args[i].toCSS();
|
|
30
30
|
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
|
|
31
31
|
});
|
|
32
|
-
};
|
|
33
|
-
for (var i = 0; i < args.length; i++) {
|
|
34
|
-
_loop_1(i);
|
|
35
32
|
}
|
|
36
33
|
result = result.replace(/%%/g, '%');
|
|
37
|
-
return new
|
|
34
|
+
return new Quoted(string.quote || '', result, string.escaped);
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
|
-
//# sourceMappingURL=string.js.map
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var styleExpression = function (args) {
|
|
7
|
-
var _this = this;
|
|
1
|
+
import Variable from '../tree/variable.js';
|
|
2
|
+
import Anonymous from '../tree/anonymous.js';
|
|
3
|
+
|
|
4
|
+
/** @param {*[]} args */
|
|
5
|
+
const styleExpression = function (args) {
|
|
8
6
|
args = Array.prototype.slice.call(args);
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
if (args.length === 0) {
|
|
8
|
+
throw { type: 'Argument', message: 'one or more arguments required' };
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
|
|
11
|
+
const entityList = [new Variable(args[0].value, this.index, this.currentFileInfo).eval(this.context)];
|
|
12
|
+
|
|
13
|
+
const result = entityList.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
|
|
14
|
+
|
|
15
|
+
return new Anonymous(`style(${result})`);
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
args[_i] = arguments[_i];
|
|
21
|
-
}
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
/** @param {...*} args */
|
|
20
|
+
style: function(...args) {
|
|
22
21
|
try {
|
|
23
22
|
return styleExpression.call(this, args);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
// When style() is used as a CSS function (e.g. @container style(--responsive: true)),
|
|
25
|
+
// arguments won't be valid Less variables. Return undefined to let the
|
|
26
|
+
// parser fall through and treat it as plain CSS.
|
|
24
27
|
}
|
|
25
|
-
catch (e) { }
|
|
26
28
|
},
|
|
27
29
|
};
|
|
28
|
-
//# sourceMappingURL=style.js.map
|
|
@@ -1,86 +1,87 @@
|
|
|
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
|
-
throwArgumentDescriptor();
|
|
31
|
-
}
|
|
32
|
-
stops = arguments[1].value;
|
|
33
|
-
}
|
|
34
|
-
else if (arguments.length < 3) {
|
|
1
|
+
import Dimension from '../tree/dimension.js';
|
|
2
|
+
import Color from '../tree/color.js';
|
|
3
|
+
import Expression from '../tree/expression.js';
|
|
4
|
+
import Quoted from '../tree/quoted.js';
|
|
5
|
+
import URL from '../tree/url.js';
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
return { 'svg-gradient': function(direction) {
|
|
9
|
+
let stops;
|
|
10
|
+
let gradientDirectionSvg;
|
|
11
|
+
let gradientType = 'linear';
|
|
12
|
+
let rectangleDimension = 'x="0" y="0" width="1" height="1"';
|
|
13
|
+
const renderEnv = {compress: false};
|
|
14
|
+
let returner;
|
|
15
|
+
const directionValue = direction.toCSS(renderEnv);
|
|
16
|
+
let i;
|
|
17
|
+
let color;
|
|
18
|
+
let position;
|
|
19
|
+
let positionValue;
|
|
20
|
+
let alpha;
|
|
21
|
+
|
|
22
|
+
function throwArgumentDescriptor() {
|
|
23
|
+
throw { type: 'Argument',
|
|
24
|
+
message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +
|
|
25
|
+
' end_color [end_position] or direction, color list' };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (arguments.length == 2) {
|
|
29
|
+
if (arguments[1].value.length < 2) {
|
|
35
30
|
throwArgumentDescriptor();
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
stops = arguments[1].value;
|
|
33
|
+
} else if (arguments.length < 3) {
|
|
34
|
+
throwArgumentDescriptor();
|
|
35
|
+
} else {
|
|
36
|
+
stops = Array.prototype.slice.call(arguments, 1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
switch (directionValue) {
|
|
40
|
+
case 'to bottom':
|
|
41
|
+
gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
|
|
42
|
+
break;
|
|
43
|
+
case 'to right':
|
|
44
|
+
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
|
|
45
|
+
break;
|
|
46
|
+
case 'to bottom right':
|
|
47
|
+
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
|
|
48
|
+
break;
|
|
49
|
+
case 'to top right':
|
|
50
|
+
gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
|
|
51
|
+
break;
|
|
52
|
+
case 'ellipse':
|
|
53
|
+
case 'ellipse at center':
|
|
54
|
+
gradientType = 'radial';
|
|
55
|
+
gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
|
|
56
|
+
rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
|
|
60
|
+
' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
|
|
61
|
+
}
|
|
62
|
+
returner = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><${gradientType}Gradient id="g" ${gradientDirectionSvg}>`;
|
|
63
|
+
|
|
64
|
+
for (i = 0; i < stops.length; i += 1) {
|
|
65
|
+
if (stops[i] instanceof Expression) {
|
|
66
|
+
color = stops[i].value[0];
|
|
67
|
+
position = stops[i].value[1];
|
|
68
|
+
} else {
|
|
69
|
+
color = stops[i];
|
|
70
|
+
position = undefined;
|
|
39
71
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
break;
|
|
44
|
-
case 'to right':
|
|
45
|
-
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
|
|
46
|
-
break;
|
|
47
|
-
case 'to bottom right':
|
|
48
|
-
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
|
|
49
|
-
break;
|
|
50
|
-
case 'to top right':
|
|
51
|
-
gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
|
|
52
|
-
break;
|
|
53
|
-
case 'ellipse':
|
|
54
|
-
case 'ellipse at center':
|
|
55
|
-
gradientType = 'radial';
|
|
56
|
-
gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
|
|
57
|
-
rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
|
|
61
|
-
' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
|
|
62
|
-
}
|
|
63
|
-
returner = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1 1\"><".concat(gradientType, "Gradient id=\"g\" ").concat(gradientDirectionSvg, ">");
|
|
64
|
-
for (i = 0; i < stops.length; i += 1) {
|
|
65
|
-
if (stops[i] instanceof expression_1.default) {
|
|
66
|
-
color = stops[i].value[0];
|
|
67
|
-
position = stops[i].value[1];
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
color = stops[i];
|
|
71
|
-
position = undefined;
|
|
72
|
-
}
|
|
73
|
-
if (!(color instanceof color_1.default) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof dimension_1.default))) {
|
|
74
|
-
throwArgumentDescriptor();
|
|
75
|
-
}
|
|
76
|
-
positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
|
|
77
|
-
alpha = color.alpha;
|
|
78
|
-
returner += "<stop offset=\"".concat(positionValue, "\" stop-color=\"").concat(color.toRGB(), "\"").concat(alpha < 1 ? " stop-opacity=\"".concat(alpha, "\"") : '', "/>");
|
|
72
|
+
|
|
73
|
+
if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) {
|
|
74
|
+
throwArgumentDescriptor();
|
|
79
75
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
returner = "
|
|
83
|
-
|
|
84
|
-
} }
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
|
|
77
|
+
alpha = color.alpha;
|
|
78
|
+
returner += `<stop offset="${positionValue}" stop-color="${color.toRGB()}"${alpha < 1 ? ` stop-opacity="${alpha}"` : ''}/>`;
|
|
79
|
+
}
|
|
80
|
+
returner += `</${gradientType}Gradient><rect ${rectangleDimension} fill="url(#g)" /></svg>`;
|
|
81
|
+
|
|
82
|
+
returner = encodeURIComponent(returner);
|
|
83
|
+
|
|
84
|
+
returner = `data:image/svg+xml,${returner}`;
|
|
85
|
+
return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
|
86
|
+
}};
|
|
87
|
+
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var isa = function (n, Type) { return (n instanceof Type) ? keyword_1.default.True : keyword_1.default.False; };
|
|
13
|
-
var isunit = function (n, unit) {
|
|
1
|
+
import Keyword from '../tree/keyword.js';
|
|
2
|
+
import DetachedRuleset from '../tree/detached-ruleset.js';
|
|
3
|
+
import Dimension from '../tree/dimension.js';
|
|
4
|
+
import Color from '../tree/color.js';
|
|
5
|
+
import Quoted from '../tree/quoted.js';
|
|
6
|
+
import Anonymous from '../tree/anonymous.js';
|
|
7
|
+
import URL from '../tree/url.js';
|
|
8
|
+
import Operation from '../tree/operation.js';
|
|
9
|
+
|
|
10
|
+
const isa = (n, Type) => (n instanceof Type) ? Keyword.True : Keyword.False;
|
|
11
|
+
const isunit = (n, unit) => {
|
|
14
12
|
if (unit === undefined) {
|
|
15
13
|
throw { type: 'Argument', message: 'missing the required second argument to isunit.' };
|
|
16
14
|
}
|
|
@@ -18,26 +16,27 @@ var isunit = function (n, unit) {
|
|
|
18
16
|
if (typeof unit !== 'string') {
|
|
19
17
|
throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };
|
|
20
18
|
}
|
|
21
|
-
return (n instanceof
|
|
19
|
+
return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;
|
|
22
20
|
};
|
|
23
|
-
|
|
21
|
+
|
|
22
|
+
export default {
|
|
24
23
|
isruleset: function (n) {
|
|
25
|
-
return isa(n,
|
|
24
|
+
return isa(n, DetachedRuleset);
|
|
26
25
|
},
|
|
27
26
|
iscolor: function (n) {
|
|
28
|
-
return isa(n,
|
|
27
|
+
return isa(n, Color);
|
|
29
28
|
},
|
|
30
29
|
isnumber: function (n) {
|
|
31
|
-
return isa(n,
|
|
30
|
+
return isa(n, Dimension);
|
|
32
31
|
},
|
|
33
32
|
isstring: function (n) {
|
|
34
|
-
return isa(n,
|
|
33
|
+
return isa(n, Quoted);
|
|
35
34
|
},
|
|
36
35
|
iskeyword: function (n) {
|
|
37
|
-
return isa(n,
|
|
36
|
+
return isa(n, Keyword);
|
|
38
37
|
},
|
|
39
38
|
isurl: function (n) {
|
|
40
|
-
return isa(n,
|
|
39
|
+
return isa(n, URL);
|
|
41
40
|
},
|
|
42
41
|
ispixel: function (n) {
|
|
43
42
|
return isunit(n, 'px');
|
|
@@ -48,27 +47,24 @@ exports.default = {
|
|
|
48
47
|
isem: function (n) {
|
|
49
48
|
return isunit(n, 'em');
|
|
50
49
|
},
|
|
51
|
-
isunit
|
|
50
|
+
isunit,
|
|
52
51
|
unit: function (val, unit) {
|
|
53
|
-
if (!(val instanceof
|
|
52
|
+
if (!(val instanceof Dimension)) {
|
|
54
53
|
throw { type: 'Argument',
|
|
55
|
-
message:
|
|
54
|
+
message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` };
|
|
56
55
|
}
|
|
57
56
|
if (unit) {
|
|
58
|
-
if (unit instanceof
|
|
57
|
+
if (unit instanceof Keyword) {
|
|
59
58
|
unit = unit.value;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
59
|
+
} else {
|
|
62
60
|
unit = unit.toCSS();
|
|
63
61
|
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
62
|
+
} else {
|
|
66
63
|
unit = '';
|
|
67
64
|
}
|
|
68
|
-
return new
|
|
65
|
+
return new Dimension(val.value, unit);
|
|
69
66
|
},
|
|
70
67
|
'get-unit': function (n) {
|
|
71
|
-
return new
|
|
68
|
+
return new Anonymous(n.unit);
|
|
72
69
|
}
|
|
73
70
|
};
|
|
74
|
-
//# sourceMappingURL=types.js.map
|