less 3.13.1 → 4.1.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/Gruntfile.js +1 -1
- package/bin/lessc +14 -3
- package/dist/less.js +11156 -11157
- package/dist/less.min.js +3 -3
- package/dist/less.min.js.map +1 -1
- package/lib/less/constants.js +2 -2
- package/lib/less/constants.js.map +1 -1
- package/lib/less/contexts.js +88 -110
- package/lib/less/contexts.js.map +1 -1
- package/lib/less/data/index.js +3 -5
- package/lib/less/data/index.js.map +1 -1
- package/lib/less/default-options.js +57 -53
- package/lib/less/default-options.js.map +1 -1
- package/lib/less/environment/abstract-file-manager.js +6 -6
- package/lib/less/environment/abstract-file-manager.js.map +1 -1
- package/lib/less/environment/abstract-plugin-loader.js +7 -13
- package/lib/less/environment/abstract-plugin-loader.js.map +1 -1
- package/lib/less/environment/environment.js +9 -11
- package/lib/less/environment/environment.js.map +1 -1
- package/lib/less/functions/boolean.js +14 -6
- package/lib/less/functions/boolean.js.map +1 -1
- package/lib/less/functions/color-blending.js +2 -4
- package/lib/less/functions/color-blending.js.map +1 -1
- package/lib/less/functions/color.js +41 -9
- package/lib/less/functions/color.js.map +1 -1
- package/lib/less/functions/data-uri.js +5 -26
- package/lib/less/functions/data-uri.js.map +1 -1
- package/lib/less/functions/default.js +2 -4
- package/lib/less/functions/default.js.map +1 -1
- package/lib/less/functions/function-caller.js +19 -35
- package/lib/less/functions/function-caller.js.map +1 -1
- package/lib/less/functions/index.js +14 -16
- package/lib/less/functions/index.js.map +1 -1
- package/lib/less/functions/list.js +21 -12
- package/lib/less/functions/list.js.map +1 -1
- package/lib/less/functions/math-helper.js +2 -4
- package/lib/less/functions/math-helper.js.map +1 -1
- package/lib/less/functions/math.js +2 -4
- package/lib/less/functions/math.js.map +1 -1
- package/lib/less/functions/number.js +12 -8
- package/lib/less/functions/number.js.map +1 -1
- package/lib/less/functions/string.js +4 -6
- package/lib/less/functions/string.js.map +1 -1
- package/lib/less/functions/svg.js +6 -8
- package/lib/less/functions/svg.js.map +1 -1
- package/lib/less/functions/types.js +9 -11
- package/lib/less/functions/types.js.map +1 -1
- package/lib/less/import-manager.js +6 -27
- package/lib/less/import-manager.js.map +1 -1
- package/lib/less/index.js +48 -82
- package/lib/less/index.js.map +1 -1
- package/lib/less/less-error.js +6 -24
- package/lib/less/less-error.js.map +1 -1
- package/lib/less/parse-tree.js +8 -8
- package/lib/less/parse-tree.js.map +1 -1
- package/lib/less/parse.js +11 -31
- package/lib/less/parse.js.map +1 -1
- package/lib/less/parser/chunker.js +4 -2
- package/lib/less/parser/chunker.js.map +1 -1
- package/lib/less/parser/parser-input.js +2 -4
- package/lib/less/parser/parser-input.js.map +1 -1
- package/lib/less/parser/parser.js +8 -29
- package/lib/less/parser/parser.js.map +1 -1
- package/lib/less/plugin-manager.js +2 -3
- package/lib/less/plugin-manager.js.map +1 -1
- package/lib/less/render.js +6 -22
- package/lib/less/render.js.map +1 -1
- package/lib/less/source-map-builder.js +4 -2
- package/lib/less/source-map-builder.js.map +1 -1
- package/lib/less/source-map-output.js +5 -7
- package/lib/less/source-map-output.js.map +1 -1
- package/lib/less/transform-tree.js +9 -9
- package/lib/less/transform-tree.js.map +1 -1
- package/lib/less/tree/anonymous.js +19 -20
- package/lib/less/tree/anonymous.js.map +1 -1
- package/lib/less/tree/assignment.js +22 -23
- package/lib/less/tree/assignment.js.map +1 -1
- package/lib/less/tree/atrule.js +105 -116
- package/lib/less/tree/atrule.js.map +1 -1
- package/lib/less/tree/attribute.js +18 -19
- package/lib/less/tree/attribute.js.map +1 -1
- package/lib/less/tree/call.js +68 -69
- package/lib/less/tree/call.js.map +1 -1
- package/lib/less/tree/color.js +163 -172
- package/lib/less/tree/color.js.map +1 -1
- package/lib/less/tree/combinator.js +9 -10
- package/lib/less/tree/combinator.js.map +1 -1
- package/lib/less/tree/comment.js +15 -16
- package/lib/less/tree/comment.js.map +1 -1
- package/lib/less/tree/condition.js +29 -30
- package/lib/less/tree/condition.js.map +1 -1
- package/lib/less/tree/debug-info.js +32 -30
- package/lib/less/tree/debug-info.js.map +1 -1
- package/lib/less/tree/declaration.js +71 -95
- package/lib/less/tree/declaration.js.map +1 -1
- package/lib/less/tree/detached-ruleset.js +18 -38
- package/lib/less/tree/detached-ruleset.js.map +1 -1
- package/lib/less/tree/dimension.js +126 -129
- package/lib/less/tree/dimension.js.map +1 -1
- package/lib/less/tree/element.js +40 -41
- package/lib/less/tree/element.js.map +1 -1
- package/lib/less/tree/expression.js +55 -74
- package/lib/less/tree/expression.js.map +1 -1
- package/lib/less/tree/extend.js +28 -34
- package/lib/less/tree/extend.js.map +1 -1
- package/lib/less/tree/import.js +120 -140
- package/lib/less/tree/import.js.map +1 -1
- package/lib/less/tree/index.js +37 -39
- package/lib/less/tree/index.js.map +1 -1
- package/lib/less/tree/javascript.js +23 -24
- package/lib/less/tree/javascript.js.map +1 -1
- package/lib/less/tree/js-eval-node.js +51 -50
- package/lib/less/tree/js-eval-node.js.map +1 -1
- package/lib/less/tree/keyword.js +10 -11
- package/lib/less/tree/keyword.js.map +1 -1
- package/lib/less/tree/media.js +111 -131
- package/lib/less/tree/media.js.map +1 -1
- package/lib/less/tree/mixin-call.js +156 -160
- package/lib/less/tree/mixin-call.js.map +1 -1
- package/lib/less/tree/mixin-definition.js +164 -184
- package/lib/less/tree/mixin-definition.js.map +1 -1
- package/lib/less/tree/namespace-value.js +53 -57
- package/lib/less/tree/namespace-value.js.map +1 -1
- package/lib/less/tree/negative.js +16 -17
- package/lib/less/tree/negative.js.map +1 -1
- package/lib/less/tree/node.js +39 -39
- package/lib/less/tree/node.js.map +1 -1
- package/lib/less/tree/operation.js +41 -63
- package/lib/less/tree/operation.js.map +1 -1
- package/lib/less/tree/paren.js +13 -14
- package/lib/less/tree/paren.js.map +1 -1
- package/lib/less/tree/property.js +48 -49
- package/lib/less/tree/property.js.map +1 -1
- package/lib/less/tree/quoted.js +50 -51
- package/lib/less/tree/quoted.js.map +1 -1
- package/lib/less/tree/ruleset.js +665 -702
- package/lib/less/tree/ruleset.js.map +1 -1
- package/lib/less/tree/selector.js +105 -106
- package/lib/less/tree/selector.js.map +1 -1
- package/lib/less/tree/unicode-descriptor.js +5 -6
- package/lib/less/tree/unicode-descriptor.js.map +1 -1
- package/lib/less/tree/unit.js +99 -120
- package/lib/less/tree/unit.js.map +1 -1
- package/lib/less/tree/url.js +44 -45
- package/lib/less/tree/url.js.map +1 -1
- package/lib/less/tree/value.js +27 -26
- package/lib/less/tree/value.js.map +1 -1
- package/lib/less/tree/variable-call.js +30 -31
- package/lib/less/tree/variable-call.js.map +1 -1
- package/lib/less/tree/variable.js +46 -48
- package/lib/less/tree/variable.js.map +1 -1
- package/lib/less/utils.js +5 -23
- package/lib/less/utils.js.map +1 -1
- package/lib/less/visitors/extend-visitor.js +14 -41
- package/lib/less/visitors/extend-visitor.js.map +1 -1
- package/lib/less/visitors/import-sequencer.js +2 -7
- package/lib/less/visitors/import-sequencer.js.map +1 -1
- package/lib/less/visitors/import-visitor.js +7 -33
- package/lib/less/visitors/import-visitor.js.map +1 -1
- package/lib/less/visitors/index.js +7 -9
- package/lib/less/visitors/index.js.map +1 -1
- package/lib/less/visitors/join-selector-visitor.js +2 -4
- package/lib/less/visitors/join-selector-visitor.js.map +1 -1
- package/lib/less/visitors/to-css-visitor.js +4 -6
- package/lib/less/visitors/to-css-visitor.js.map +1 -1
- package/lib/less/visitors/visitor.js +4 -12
- package/lib/less/visitors/visitor.js.map +1 -1
- package/lib/less-browser/add-default-options.js +2 -4
- package/lib/less-browser/add-default-options.js.map +1 -1
- package/lib/less-browser/bootstrap.js +4 -6
- package/lib/less-browser/bootstrap.js.map +1 -1
- package/lib/less-browser/browser.js +2 -20
- package/lib/less-browser/browser.js.map +1 -1
- package/lib/less-browser/error-reporting.js +3 -24
- package/lib/less-browser/error-reporting.js.map +1 -1
- package/lib/less-browser/file-manager.js +17 -36
- package/lib/less-browser/file-manager.js.map +1 -1
- package/lib/less-browser/image-size.js +2 -4
- package/lib/less-browser/image-size.js.map +1 -1
- package/lib/less-browser/index.js +9 -11
- package/lib/less-browser/index.js.map +1 -1
- package/lib/less-browser/plugin-loader.js +10 -29
- package/lib/less-browser/plugin-loader.js.map +1 -1
- package/lib/less-node/file-manager.js +15 -34
- package/lib/less-node/file-manager.js.map +1 -1
- package/lib/less-node/image-size.js +4 -6
- package/lib/less-node/image-size.js.map +1 -1
- package/lib/less-node/index.js +10 -16
- package/lib/less-node/index.js.map +1 -1
- package/lib/less-node/plugin-loader.js +23 -42
- package/lib/less-node/plugin-loader.js.map +1 -1
- package/lib/less-node/url-file-manager.js +23 -38
- package/lib/less-node/url-file-manager.js.map +1 -1
- package/package.json +12 -9
- package/test/browser/less/errors/image-height-error.txt +1 -1
- package/test/browser/less/errors/image-size-error.txt +1 -1
- package/test/browser/less/errors/image-width-error.txt +1 -1
- package/test/index.js +28 -9
- package/test/less-test.js +36 -16
- package/tsconfig.json +1 -0
package/lib/less/tree/color.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
7
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var node_1 = tslib_1.__importDefault(require("./node"));
|
|
5
|
+
var colors_1 = tslib_1.__importDefault(require("../data/colors"));
|
|
8
6
|
//
|
|
9
7
|
// RGB Colors - #ff0014, #eee
|
|
10
8
|
//
|
|
@@ -46,185 +44,169 @@ var Color = function (rgb, a, originalForm) {
|
|
|
46
44
|
this.value = originalForm;
|
|
47
45
|
}
|
|
48
46
|
};
|
|
49
|
-
Color.prototype = new node_1.default()
|
|
50
|
-
Color
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
47
|
+
Color.prototype = Object.assign(new node_1.default(), {
|
|
48
|
+
type: 'Color',
|
|
49
|
+
luma: function () {
|
|
50
|
+
var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255;
|
|
51
|
+
r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);
|
|
52
|
+
g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);
|
|
53
|
+
b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);
|
|
54
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
55
|
+
},
|
|
56
|
+
genCSS: function (context, output) {
|
|
57
|
+
output.add(this.toCSS(context));
|
|
58
|
+
},
|
|
59
|
+
toCSS: function (context, doNotCompress) {
|
|
60
|
+
var compress = context && context.compress && !doNotCompress;
|
|
61
|
+
var color;
|
|
62
|
+
var alpha;
|
|
63
|
+
var colorFunction;
|
|
64
|
+
var args = [];
|
|
65
|
+
// `value` is set if this color was originally
|
|
66
|
+
// converted from a named color string so we need
|
|
67
|
+
// to respect this and try to output named color too.
|
|
68
|
+
alpha = this.fround(context, this.alpha);
|
|
69
|
+
if (this.value) {
|
|
70
|
+
if (this.value.indexOf('rgb') === 0) {
|
|
71
|
+
if (alpha < 1) {
|
|
72
|
+
colorFunction = 'rgba';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (this.value.indexOf('hsl') === 0) {
|
|
76
|
+
if (alpha < 1) {
|
|
77
|
+
colorFunction = 'hsla';
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
colorFunction = 'hsl';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return this.value;
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
|
-
else
|
|
87
|
+
else {
|
|
79
88
|
if (alpha < 1) {
|
|
80
|
-
colorFunction = '
|
|
89
|
+
colorFunction = 'rgba';
|
|
81
90
|
}
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
}
|
|
92
|
+
switch (colorFunction) {
|
|
93
|
+
case 'rgba':
|
|
94
|
+
args = this.rgb.map(function (c) {
|
|
95
|
+
return clamp(Math.round(c), 255);
|
|
96
|
+
}).concat(clamp(alpha, 1));
|
|
97
|
+
break;
|
|
98
|
+
case 'hsla':
|
|
99
|
+
args.push(clamp(alpha, 1));
|
|
100
|
+
case 'hsl':
|
|
101
|
+
color = this.toHSL();
|
|
102
|
+
args = [
|
|
103
|
+
this.fround(context, color.h),
|
|
104
|
+
this.fround(context, color.s * 100) + "%",
|
|
105
|
+
this.fround(context, color.l * 100) + "%"
|
|
106
|
+
].concat(args);
|
|
107
|
+
}
|
|
108
|
+
if (colorFunction) {
|
|
109
|
+
// Values are capped between `0` and `255`, rounded and zero-padded.
|
|
110
|
+
return colorFunction + "(" + args.join("," + (compress ? '' : ' ')) + ")";
|
|
111
|
+
}
|
|
112
|
+
color = this.toRGB();
|
|
113
|
+
if (compress) {
|
|
114
|
+
var splitcolor = color.split('');
|
|
115
|
+
// Convert color to short format
|
|
116
|
+
if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {
|
|
117
|
+
color = "#" + splitcolor[1] + splitcolor[3] + splitcolor[5];
|
|
84
118
|
}
|
|
85
119
|
}
|
|
120
|
+
return color;
|
|
121
|
+
},
|
|
122
|
+
//
|
|
123
|
+
// Operations have to be done per-channel, if not,
|
|
124
|
+
// channels will spill onto each other. Once we have
|
|
125
|
+
// our result, in the form of an integer triplet,
|
|
126
|
+
// we create a new Color node to hold the result.
|
|
127
|
+
//
|
|
128
|
+
operate: function (context, op, other) {
|
|
129
|
+
var rgb = new Array(3);
|
|
130
|
+
var alpha = this.alpha * (1 - other.alpha) + other.alpha;
|
|
131
|
+
for (var c = 0; c < 3; c++) {
|
|
132
|
+
rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);
|
|
133
|
+
}
|
|
134
|
+
return new Color(rgb, alpha);
|
|
135
|
+
},
|
|
136
|
+
toRGB: function () {
|
|
137
|
+
return toHex(this.rgb);
|
|
138
|
+
},
|
|
139
|
+
toHSL: function () {
|
|
140
|
+
var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;
|
|
141
|
+
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
142
|
+
var h;
|
|
143
|
+
var s;
|
|
144
|
+
var l = (max + min) / 2;
|
|
145
|
+
var d = max - min;
|
|
146
|
+
if (max === min) {
|
|
147
|
+
h = s = 0;
|
|
148
|
+
}
|
|
86
149
|
else {
|
|
87
|
-
|
|
150
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
151
|
+
switch (max) {
|
|
152
|
+
case r:
|
|
153
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
154
|
+
break;
|
|
155
|
+
case g:
|
|
156
|
+
h = (b - r) / d + 2;
|
|
157
|
+
break;
|
|
158
|
+
case b:
|
|
159
|
+
h = (r - g) / d + 4;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
h /= 6;
|
|
88
163
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
164
|
+
return { h: h * 360, s: s, l: l, a: a };
|
|
165
|
+
},
|
|
166
|
+
// Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
|
|
167
|
+
toHSV: function () {
|
|
168
|
+
var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;
|
|
169
|
+
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
170
|
+
var h;
|
|
171
|
+
var s;
|
|
172
|
+
var v = max;
|
|
173
|
+
var d = max - min;
|
|
174
|
+
if (max === 0) {
|
|
175
|
+
s = 0;
|
|
93
176
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
case 'rgba':
|
|
97
|
-
args = this.rgb.map(function (c) { return clamp(Math.round(c), 255); }).concat(clamp(alpha, 1));
|
|
98
|
-
break;
|
|
99
|
-
case 'hsla':
|
|
100
|
-
args.push(clamp(alpha, 1));
|
|
101
|
-
case 'hsl':
|
|
102
|
-
color = this.toHSL();
|
|
103
|
-
args = [
|
|
104
|
-
this.fround(context, color.h),
|
|
105
|
-
this.fround(context, color.s * 100) + "%",
|
|
106
|
-
this.fround(context, color.l * 100) + "%"
|
|
107
|
-
].concat(args);
|
|
108
|
-
}
|
|
109
|
-
if (colorFunction) {
|
|
110
|
-
// Values are capped between `0` and `255`, rounded and zero-padded.
|
|
111
|
-
return colorFunction + "(" + args.join("," + (compress ? '' : ' ')) + ")";
|
|
112
|
-
}
|
|
113
|
-
color = this.toRGB();
|
|
114
|
-
if (compress) {
|
|
115
|
-
var splitcolor = color.split('');
|
|
116
|
-
// Convert color to short format
|
|
117
|
-
if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {
|
|
118
|
-
color = "#" + splitcolor[1] + splitcolor[3] + splitcolor[5];
|
|
177
|
+
else {
|
|
178
|
+
s = d / max;
|
|
119
179
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
//
|
|
124
|
-
// Operations have to be done per-channel, if not,
|
|
125
|
-
// channels will spill onto each other. Once we have
|
|
126
|
-
// our result, in the form of an integer triplet,
|
|
127
|
-
// we create a new Color node to hold the result.
|
|
128
|
-
//
|
|
129
|
-
Color.prototype.operate = function (context, op, other) {
|
|
130
|
-
var rgb = new Array(3);
|
|
131
|
-
var alpha = this.alpha * (1 - other.alpha) + other.alpha;
|
|
132
|
-
for (var c = 0; c < 3; c++) {
|
|
133
|
-
rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);
|
|
134
|
-
}
|
|
135
|
-
return new Color(rgb, alpha);
|
|
136
|
-
};
|
|
137
|
-
Color.prototype.toRGB = function () {
|
|
138
|
-
return toHex(this.rgb);
|
|
139
|
-
};
|
|
140
|
-
Color.prototype.toHSL = function () {
|
|
141
|
-
var r = this.rgb[0] / 255;
|
|
142
|
-
var g = this.rgb[1] / 255;
|
|
143
|
-
var b = this.rgb[2] / 255;
|
|
144
|
-
var a = this.alpha;
|
|
145
|
-
var max = Math.max(r, g, b);
|
|
146
|
-
var min = Math.min(r, g, b);
|
|
147
|
-
var h;
|
|
148
|
-
var s;
|
|
149
|
-
var l = (max + min) / 2;
|
|
150
|
-
var d = max - min;
|
|
151
|
-
if (max === min) {
|
|
152
|
-
h = s = 0;
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
156
|
-
switch (max) {
|
|
157
|
-
case r:
|
|
158
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
159
|
-
break;
|
|
160
|
-
case g:
|
|
161
|
-
h = (b - r) / d + 2;
|
|
162
|
-
break;
|
|
163
|
-
case b:
|
|
164
|
-
h = (r - g) / d + 4;
|
|
165
|
-
break;
|
|
180
|
+
if (max === min) {
|
|
181
|
+
h = 0;
|
|
166
182
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var s;
|
|
181
|
-
var v = max;
|
|
182
|
-
var d = max - min;
|
|
183
|
-
if (max === 0) {
|
|
184
|
-
s = 0;
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
s = d / max;
|
|
188
|
-
}
|
|
189
|
-
if (max === min) {
|
|
190
|
-
h = 0;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
switch (max) {
|
|
194
|
-
case r:
|
|
195
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
196
|
-
break;
|
|
197
|
-
case g:
|
|
198
|
-
h = (b - r) / d + 2;
|
|
199
|
-
break;
|
|
200
|
-
case b:
|
|
201
|
-
h = (r - g) / d + 4;
|
|
202
|
-
break;
|
|
183
|
+
else {
|
|
184
|
+
switch (max) {
|
|
185
|
+
case r:
|
|
186
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
187
|
+
break;
|
|
188
|
+
case g:
|
|
189
|
+
h = (b - r) / d + 2;
|
|
190
|
+
break;
|
|
191
|
+
case b:
|
|
192
|
+
h = (r - g) / d + 4;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
h /= 6;
|
|
203
196
|
}
|
|
204
|
-
h
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
};
|
|
218
|
-
Color.prototype.type = 'Color';
|
|
219
|
-
function clamp(v, max) {
|
|
220
|
-
return Math.min(Math.max(v, 0), max);
|
|
221
|
-
}
|
|
222
|
-
function toHex(v) {
|
|
223
|
-
return "#" + v.map(function (c) {
|
|
224
|
-
c = clamp(Math.round(c), 255);
|
|
225
|
-
return (c < 16 ? '0' : '') + c.toString(16);
|
|
226
|
-
}).join('');
|
|
227
|
-
}
|
|
197
|
+
return { h: h * 360, s: s, v: v, a: a };
|
|
198
|
+
},
|
|
199
|
+
toARGB: function () {
|
|
200
|
+
return toHex([this.alpha * 255].concat(this.rgb));
|
|
201
|
+
},
|
|
202
|
+
compare: function (x) {
|
|
203
|
+
return (x.rgb &&
|
|
204
|
+
x.rgb[0] === this.rgb[0] &&
|
|
205
|
+
x.rgb[1] === this.rgb[1] &&
|
|
206
|
+
x.rgb[2] === this.rgb[2] &&
|
|
207
|
+
x.alpha === this.alpha) ? 0 : undefined;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
228
210
|
Color.fromKeyword = function (keyword) {
|
|
229
211
|
var c;
|
|
230
212
|
var key = keyword.toLowerCase();
|
|
@@ -239,5 +221,14 @@ Color.fromKeyword = function (keyword) {
|
|
|
239
221
|
return c;
|
|
240
222
|
}
|
|
241
223
|
};
|
|
224
|
+
function clamp(v, max) {
|
|
225
|
+
return Math.min(Math.max(v, 0), max);
|
|
226
|
+
}
|
|
227
|
+
function toHex(v) {
|
|
228
|
+
return "#" + v.map(function (c) {
|
|
229
|
+
c = clamp(Math.round(c), 255);
|
|
230
|
+
return (c < 16 ? '0' : '') + c.toString(16);
|
|
231
|
+
}).join('');
|
|
232
|
+
}
|
|
242
233
|
exports.default = Color;
|
|
243
234
|
//# sourceMappingURL=color.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/less/tree/color.js"],"names":[],"mappings":";;;;;AAAA,gDAA0B;AAC1B,0DAAoC;AAEpC,EAAE;AACF,6BAA6B;AAC7B,EAAE;AACF,IAAM,KAAK,GAAG,UAAS,GAAG,EAAE,CAAC,EAAE,YAAY;IACvC,IAAM,IAAI,GAAG,IAAI,CAAC;IAClB,EAAE;IACF,+CAA+C;IAC/C,iDAAiD;IACjD,EAAE;IACF,+CAA+C;IAC/C,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;KAClB;SAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE;QACxB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,GAAG,CAAC,KAAK,CAAC,OA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,CAAC,CAAC,CAAC,CAAC,CAAC;KACvC;SACI,IAAI,GAAG,KAAK,aAAa,EAAE;QAC5B,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC/B;IAED,IAAI,CAAC,EAAE;QACH,CAAC,CAAC,KAAK,GAAG,OAAO,CAAC;QAClB,OAAO,CAAC,CAAC;KACZ;AACL,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC","sourcesContent":["import Node from './node';\nimport colors from '../data/colors';\n\n//\n// RGB Colors - #ff0014, #eee\n//\nconst Color = function(rgb, a, originalForm) {\n const self = this;\n //\n // The end goal here, is to parse the arguments\n // into an integer triplet, such as `128, 255, 0`\n //\n // This facilitates operations and conversions.\n //\n if (Array.isArray(rgb)) {\n this.rgb = rgb;\n } else if (rgb.length >= 6) {\n this.rgb = [];\n rgb.match(/.{2}/g).map((c, i) => {\n if (i < 3) {\n self.rgb.push(parseInt(c, 16));\n } else {\n self.alpha = (parseInt(c, 16)) / 255;\n }\n });\n } else {\n this.rgb = [];\n rgb.split('').map((c, i) => {\n if (i < 3) {\n self.rgb.push(parseInt(c + c, 16));\n } else {\n self.alpha = (parseInt(c + c, 16)) / 255;\n }\n });\n }\n this.alpha = this.alpha || (typeof a === 'number' ? a : 1);\n if (typeof originalForm !== 'undefined') {\n this.value = originalForm;\n }\n};\n\nColor.prototype = new Node();\n\nColor.prototype.luma = function() {\n let r = this.rgb[0] / 255;\n let g = this.rgb[1] / 255;\n let b = this.rgb[2] / 255;\n\n r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);\n g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);\n b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nColor.prototype.genCSS = function(context, output) {\n output.add(this.toCSS(context));\n};\n\nColor.prototype.toCSS = function(context, doNotCompress) {\n const compress = context && context.compress && !doNotCompress;\n let color;\n let alpha;\n let colorFunction;\n let args = [];\n\n // `value` is set if this color was originally\n // converted from a named color string so we need\n // to respect this and try to output named color too.\n alpha = this.fround(context, this.alpha);\n\n if (this.value) {\n if (this.value.indexOf('rgb') === 0) {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n } else if (this.value.indexOf('hsl') === 0) {\n if (alpha < 1) {\n colorFunction = 'hsla';\n } else {\n colorFunction = 'hsl';\n }\n } else {\n return this.value;\n }\n } else {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n }\n\n switch (colorFunction) {\n case 'rgba':\n args = this.rgb.map(c => clamp(Math.round(c), 255)).concat(clamp(alpha, 1));\n break;\n case 'hsla':\n args.push(clamp(alpha, 1));\n case 'hsl':\n color = this.toHSL();\n args = [\n this.fround(context, color.h),\n `${this.fround(context, color.s * 100)}%`,\n `${this.fround(context, color.l * 100)}%`\n ].concat(args);\n }\n\n if (colorFunction) {\n // Values are capped between `0` and `255`, rounded and zero-padded.\n return `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`;\n }\n\n color = this.toRGB();\n\n if (compress) {\n const splitcolor = color.split('');\n\n // Convert color to short format\n if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {\n color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`;\n }\n }\n\n return color;\n};\n\n//\n// Operations have to be done per-channel, if not,\n// channels will spill onto each other. Once we have\n// our result, in the form of an integer triplet,\n// we create a new Color node to hold the result.\n//\nColor.prototype.operate = function(context, op, other) {\n const rgb = new Array(3);\n const alpha = this.alpha * (1 - other.alpha) + other.alpha;\n for (let c = 0; c < 3; c++) {\n rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);\n }\n return new Color(rgb, alpha);\n};\n\nColor.prototype.toRGB = function() {\n return toHex(this.rgb);\n};\n\nColor.prototype.toHSL = function() {\n const r = this.rgb[0] / 255;\n const g = this.rgb[1] / 255;\n const b = this.rgb[2] / 255;\n const a = this.alpha;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h;\n let s;\n const l = (max + min) / 2;\n const d = max - min;\n\n if (max === min) {\n h = s = 0;\n } else {\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, l, a };\n};\n\n// Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript\nColor.prototype.toHSV = function() {\n const r = this.rgb[0] / 255;\n const g = this.rgb[1] / 255;\n const b = this.rgb[2] / 255;\n const a = this.alpha;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h;\n let s;\n const v = max;\n\n const d = max - min;\n if (max === 0) {\n s = 0;\n } else {\n s = d / max;\n }\n\n if (max === min) {\n h = 0;\n } else {\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, v, a };\n};\n\nColor.prototype.toARGB = function() {\n return toHex([this.alpha * 255].concat(this.rgb));\n};\n\nColor.prototype.compare = function(x) {\n return (x.rgb &&\n x.rgb[0] === this.rgb[0] &&\n x.rgb[1] === this.rgb[1] &&\n x.rgb[2] === this.rgb[2] &&\n x.alpha === this.alpha) ? 0 : undefined;\n};\n\nColor.prototype.type = 'Color';\n\nfunction clamp(v, max) {\n return Math.min(Math.max(v, 0), max);\n}\n\nfunction toHex(v) {\n return `#${v.map(c => {\n c = clamp(Math.round(c), 255);\n return (c < 16 ? '0' : '') + c.toString(16);\n }).join('')}`;\n}\n\nColor.fromKeyword = keyword => {\n let c;\n const key = keyword.toLowerCase();\n if (colors.hasOwnProperty(key)) {\n c = new Color(colors[key].slice(1));\n }\n else if (key === 'transparent') {\n c = new Color([0, 0, 0], 0);\n }\n\n if (c) {\n c.value = keyword;\n return c;\n }\n};\n\nexport default Color;\n"]}
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/less/tree/color.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,kEAAoC;AAEpC,EAAE;AACF,6BAA6B;AAC7B,EAAE;AACF,IAAM,KAAK,GAAG,UAAS,GAAG,EAAE,CAAC,EAAE,YAAY;IACvC,IAAM,IAAI,GAAG,IAAI,CAAC;IAClB,EAAE;IACF,+CAA+C;IAC/C,iDAAiD;IACjD,EAAE;IACF,+CAA+C;IAC/C,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;KAClB;SAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE;QACxB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,EAAE;gBACP,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;aAClC;iBAAM;gBACH,IAAI,CAAC,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;aACxC;QACL,CAAC,CAAC,CAAC;KACN;SAAM;QACH,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,EAAE;gBACP,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC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Z;AACL,CAAC,CAAC;AAEF,SAAS,KAAK,CAAC,CAAC,EAAE,GAAG;IACjB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,KAAK,CAAC,CAAC;IACZ,OAAO,MAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC;QACxB,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC9B,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAG,CAAC;AAClB,CAAC;AAED,kBAAe,KAAK,CAAC","sourcesContent":["import Node from './node';\nimport colors from '../data/colors';\n\n//\n// RGB Colors - #ff0014, #eee\n//\nconst Color = function(rgb, a, originalForm) {\n const self = this;\n //\n // The end goal here, is to parse the arguments\n // into an integer triplet, such as `128, 255, 0`\n //\n // This facilitates operations and conversions.\n //\n if (Array.isArray(rgb)) {\n this.rgb = rgb;\n } else if (rgb.length >= 6) {\n this.rgb = [];\n rgb.match(/.{2}/g).map(function (c, i) {\n if (i < 3) {\n self.rgb.push(parseInt(c, 16));\n } else {\n self.alpha = (parseInt(c, 16)) / 255;\n }\n });\n } else {\n this.rgb = [];\n rgb.split('').map(function (c, i) {\n if (i < 3) {\n self.rgb.push(parseInt(c + c, 16));\n } else {\n self.alpha = (parseInt(c + c, 16)) / 255;\n }\n });\n }\n this.alpha = this.alpha || (typeof a === 'number' ? a : 1);\n if (typeof originalForm !== 'undefined') {\n this.value = originalForm;\n }\n}\n\nColor.prototype = Object.assign(new Node(), {\n type: 'Color',\n\n luma() {\n let r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255;\n\n r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);\n g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);\n b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n },\n\n toCSS(context, doNotCompress) {\n const compress = context && context.compress && !doNotCompress;\n let color;\n let alpha;\n let colorFunction;\n let args = [];\n\n // `value` is set if this color was originally\n // converted from a named color string so we need\n // to respect this and try to output named color too.\n alpha = this.fround(context, this.alpha);\n\n if (this.value) {\n if (this.value.indexOf('rgb') === 0) {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n } else if (this.value.indexOf('hsl') === 0) {\n if (alpha < 1) {\n colorFunction = 'hsla';\n } else {\n colorFunction = 'hsl';\n }\n } else {\n return this.value;\n }\n } else {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n }\n\n switch (colorFunction) {\n case 'rgba':\n args = this.rgb.map(function (c) {\n return clamp(Math.round(c), 255);\n }).concat(clamp(alpha, 1));\n break;\n case 'hsla':\n args.push(clamp(alpha, 1));\n case 'hsl':\n color = this.toHSL();\n args = [\n this.fround(context, color.h),\n `${this.fround(context, color.s * 100)}%`,\n `${this.fround(context, color.l * 100)}%`\n ].concat(args);\n }\n\n if (colorFunction) {\n // Values are capped between `0` and `255`, rounded and zero-padded.\n return `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`;\n }\n\n color = this.toRGB();\n\n if (compress) {\n const splitcolor = color.split('');\n\n // Convert color to short format\n if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {\n color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`;\n }\n }\n\n return color;\n },\n\n //\n // Operations have to be done per-channel, if not,\n // channels will spill onto each other. Once we have\n // our result, in the form of an integer triplet,\n // we create a new Color node to hold the result.\n //\n operate(context, op, other) {\n const rgb = new Array(3);\n const alpha = this.alpha * (1 - other.alpha) + other.alpha;\n for (let c = 0; c < 3; c++) {\n rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);\n }\n return new Color(rgb, alpha);\n },\n\n toRGB() {\n return toHex(this.rgb);\n },\n\n toHSL() {\n const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;\n\n const max = Math.max(r, g, b), min = Math.min(r, g, b);\n let h;\n let s;\n const l = (max + min) / 2;\n const d = max - min;\n\n if (max === min) {\n h = s = 0;\n } else {\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, l, a };\n },\n\n // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript\n toHSV() {\n const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;\n\n const max = Math.max(r, g, b), min = Math.min(r, g, b);\n let h;\n let s;\n const v = max;\n\n const d = max - min;\n if (max === 0) {\n s = 0;\n } else {\n s = d / max;\n }\n\n if (max === min) {\n h = 0;\n } else {\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, v, a };\n },\n\n toARGB() {\n return toHex([this.alpha * 255].concat(this.rgb));\n },\n\n compare(x) {\n return (x.rgb &&\n x.rgb[0] === this.rgb[0] &&\n x.rgb[1] === this.rgb[1] &&\n x.rgb[2] === this.rgb[2] &&\n x.alpha === this.alpha) ? 0 : undefined;\n }\n});\n\nColor.fromKeyword = function(keyword) {\n let c;\n const key = keyword.toLowerCase();\n if (colors.hasOwnProperty(key)) {\n c = new Color(colors[key].slice(1));\n }\n else if (key === 'transparent') {\n c = new Color([0, 0, 0], 0);\n }\n\n if (c) {\n c.value = keyword;\n return c;\n }\n};\n\nfunction clamp(v, max) {\n return Math.min(Math.max(v, 0), max);\n}\n\nfunction toHex(v) {\n return `#${v.map(function (c) {\n c = clamp(Math.round(c), 255);\n return (c < 16 ? '0' : '') + c.toString(16);\n }).join('')}`;\n}\n\nexport default Color;\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var node_1 = tslib_1.__importDefault(require("./node"));
|
|
7
5
|
var _noSpaceCombinators = {
|
|
8
6
|
'': true,
|
|
9
7
|
' ': true,
|
|
@@ -19,11 +17,12 @@ var Combinator = function (value) {
|
|
|
19
17
|
this.emptyOrWhitespace = this.value === '';
|
|
20
18
|
}
|
|
21
19
|
};
|
|
22
|
-
Combinator.prototype = new node_1.default()
|
|
23
|
-
Combinator
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
Combinator.prototype = Object.assign(new node_1.default(), {
|
|
21
|
+
type: 'Combinator',
|
|
22
|
+
genCSS: function (context, output) {
|
|
23
|
+
var spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';
|
|
24
|
+
output.add(spaceOrEmpty + this.value + spaceOrEmpty);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
28
27
|
exports.default = Combinator;
|
|
29
28
|
//# sourceMappingURL=combinator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../../src/less/tree/combinator.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../../src/less/tree/combinator.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,IAAM,mBAAmB,GAAG;IACxB,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;CACZ,CAAC;AAEF,IAAM,UAAU,GAAG,UAAS,KAAK;IAC7B,IAAI,KAAK,KAAK,GAAG,EAAE;QACf,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;KACjC;SAAM;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;KAC9C;AACL,CAAC,CAAA;AAED,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC7C,IAAI,EAAE,YAAY;IAElB,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,IAAM,YAAY,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACtF,MAAM,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC;IACzD,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,UAAU,CAAC","sourcesContent":["import Node from './node';\nconst _noSpaceCombinators = {\n '': true,\n ' ': true,\n '|': true\n};\n\nconst Combinator = function(value) {\n if (value === ' ') {\n this.value = ' ';\n this.emptyOrWhitespace = true;\n } else {\n this.value = value ? value.trim() : '';\n this.emptyOrWhitespace = this.value === '';\n }\n}\n\nCombinator.prototype = Object.assign(new Node(), {\n type: 'Combinator',\n\n genCSS(context, output) {\n const spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';\n output.add(spaceOrEmpty + this.value + spaceOrEmpty);\n }\n});\n\nexport default Combinator;\n"]}
|
package/lib/less/tree/comment.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
7
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var node_1 = tslib_1.__importDefault(require("./node"));
|
|
5
|
+
var debug_info_1 = tslib_1.__importDefault(require("./debug-info"));
|
|
8
6
|
var Comment = function (value, isLineComment, index, currentFileInfo) {
|
|
9
7
|
this.value = value;
|
|
10
8
|
this.isLineComment = isLineComment;
|
|
@@ -12,17 +10,18 @@ var Comment = function (value, isLineComment, index, currentFileInfo) {
|
|
|
12
10
|
this._fileInfo = currentFileInfo;
|
|
13
11
|
this.allowRoot = true;
|
|
14
12
|
};
|
|
15
|
-
Comment.prototype = new node_1.default()
|
|
16
|
-
Comment
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
Comment.prototype = Object.assign(new node_1.default(), {
|
|
14
|
+
type: 'Comment',
|
|
15
|
+
genCSS: function (context, output) {
|
|
16
|
+
if (this.debugInfo) {
|
|
17
|
+
output.add(debug_info_1.default(context, this), this.fileInfo(), this.getIndex());
|
|
18
|
+
}
|
|
19
|
+
output.add(this.value);
|
|
20
|
+
},
|
|
21
|
+
isSilent: function (context) {
|
|
22
|
+
var isCompressed = context.compress && this.value[2] !== '!';
|
|
23
|
+
return this.isLineComment || isCompressed;
|
|
19
24
|
}
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
Comment.prototype.isSilent = function (context) {
|
|
23
|
-
var isCompressed = context.compress && this.value[2] !== '!';
|
|
24
|
-
return this.isLineComment || isCompressed;
|
|
25
|
-
};
|
|
26
|
-
Comment.prototype.type = 'Comment';
|
|
25
|
+
});
|
|
27
26
|
exports.default = Comment;
|
|
28
27
|
//# sourceMappingURL=comment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../src/less/tree/comment.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../../src/less/tree/comment.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,oEAAwC;AAExC,IAAM,OAAO,GAAG,UAAS,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,eAAe;IACjE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACnC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC;IACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAA;AAED,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC1C,IAAI,EAAE,SAAS;IAEf,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAM,CAAC,GAAG,CAAC,oBAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC7E;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,QAAQ,YAAC,OAAO;QACZ,IAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;QAC/D,OAAO,IAAI,CAAC,aAAa,IAAI,YAAY,CAAC;IAC9C,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,OAAO,CAAC","sourcesContent":["import Node from './node';\nimport getDebugInfo from './debug-info';\n\nconst Comment = function(value, isLineComment, index, currentFileInfo) {\n this.value = value;\n this.isLineComment = isLineComment;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.allowRoot = true;\n}\n\nComment.prototype = Object.assign(new Node(), {\n type: 'Comment',\n\n genCSS(context, output) {\n if (this.debugInfo) {\n output.add(getDebugInfo(context, this), this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n },\n\n isSilent(context) {\n const isCompressed = context.compress && this.value[2] !== '!';\n return this.isLineComment || isCompressed;\n }\n});\n\nexport default Comment;\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var node_1 = tslib_1.__importDefault(require("./node"));
|
|
7
5
|
var Condition = function (op, l, r, i, negate) {
|
|
8
6
|
this.op = op.trim();
|
|
9
7
|
this.lvalue = l;
|
|
@@ -11,31 +9,32 @@ var Condition = function (op, l, r, i, negate) {
|
|
|
11
9
|
this._index = i;
|
|
12
10
|
this.negate = negate;
|
|
13
11
|
};
|
|
14
|
-
Condition.prototype = new node_1.default()
|
|
15
|
-
Condition
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
12
|
+
Condition.prototype = Object.assign(new node_1.default(), {
|
|
13
|
+
type: 'Condition',
|
|
14
|
+
accept: function (visitor) {
|
|
15
|
+
this.lvalue = visitor.visit(this.lvalue);
|
|
16
|
+
this.rvalue = visitor.visit(this.rvalue);
|
|
17
|
+
},
|
|
18
|
+
eval: function (context) {
|
|
19
|
+
var result = (function (op, a, b) {
|
|
20
|
+
switch (op) {
|
|
21
|
+
case 'and': return a && b;
|
|
22
|
+
case 'or': return a || b;
|
|
23
|
+
default:
|
|
24
|
+
switch (node_1.default.compare(a, b)) {
|
|
25
|
+
case -1:
|
|
26
|
+
return op === '<' || op === '=<' || op === '<=';
|
|
27
|
+
case 0:
|
|
28
|
+
return op === '=' || op === '>=' || op === '=<' || op === '<=';
|
|
29
|
+
case 1:
|
|
30
|
+
return op === '>' || op === '>=';
|
|
31
|
+
default:
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})(this.op, this.lvalue.eval(context), this.rvalue.eval(context));
|
|
36
|
+
return this.negate ? !result : result;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
40
39
|
exports.default = Condition;
|
|
41
40
|
//# sourceMappingURL=condition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../src/less/tree/condition.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../src/less/tree/condition.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,SAAS,GAAG,UAAS,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM;IAC1C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI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C;QAElE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1C,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC","sourcesContent":["import Node from './node';\n\nconst Condition = function(op, l, r, i, negate) {\n this.op = op.trim();\n this.lvalue = l;\n this.rvalue = r;\n this._index = i;\n this.negate = negate;\n};\n\nCondition.prototype = Object.assign(new Node(), {\n type: 'Condition',\n\n accept(visitor) {\n this.lvalue = visitor.visit(this.lvalue);\n this.rvalue = visitor.visit(this.rvalue);\n },\n\n eval(context) {\n const result = (function (op, a, b) {\n switch (op) {\n case 'and': return a && b;\n case 'or': return a || b;\n default:\n switch (Node.compare(a, b)) {\n case -1:\n return op === '<' || op === '=<' || op === '<=';\n case 0:\n return op === '=' || op === '>=' || op === '=<' || op === '<=';\n case 1:\n return op === '>' || op === '>=';\n default:\n return false;\n }\n }\n })(this.op, this.lvalue.eval(context), this.rvalue.eval(context));\n\n return this.negate ? !result : result;\n }\n});\n\nexport default Condition;\n"]}
|