less 4.0.1-alpha.0 → 4.1.2
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/.eslintignore +2 -1
- package/.eslintrc.json +70 -2
- package/Gruntfile.js +8 -23
- package/dist/less.js +1161 -1132
- package/dist/less.min.js +3 -3
- package/dist/less.min.js.map +1 -1
- package/lib/less/constants.js +2 -1
- package/lib/less/constants.js.map +1 -1
- package/lib/less/contexts.js +2 -20
- 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/environment/abstract-plugin-loader.js +3 -5
- package/lib/less/environment/abstract-plugin-loader.js.map +1 -1
- package/lib/less/environment/environment.js +2 -4
- 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 +7 -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 +7 -12
- 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 +11 -13
- 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 +4 -6
- 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 +11 -12
- 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 +25 -43
- package/lib/less/index.js.map +1 -1
- package/lib/less/less-error.js +2 -20
- package/lib/less/less-error.js.map +1 -1
- package/lib/less/parse-tree.js +4 -6
- package/lib/less/parse-tree.js.map +1 -1
- package/lib/less/parse.js +6 -27
- package/lib/less/parse.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 +10 -31
- package/lib/less/parser/parser.js.map +1 -1
- package/lib/less/render.js +2 -20
- package/lib/less/render.js.map +1 -1
- package/lib/less/source-map-output.js +5 -1
- package/lib/less/source-map-output.js.map +1 -1
- package/lib/less/transform-tree.js +4 -6
- package/lib/less/transform-tree.js.map +1 -1
- package/lib/less/tree/anonymous.js +22 -41
- package/lib/less/tree/anonymous.js.map +1 -1
- package/lib/less/tree/assignment.js +15 -34
- package/lib/less/tree/assignment.js.map +1 -1
- package/lib/less/tree/atrule.js +49 -68
- package/lib/less/tree/atrule.js.map +1 -1
- package/lib/less/tree/attribute.js +16 -35
- package/lib/less/tree/attribute.js.map +1 -1
- package/lib/less/tree/call.js +20 -39
- package/lib/less/tree/call.js.map +1 -1
- package/lib/less/tree/color.js +75 -94
- package/lib/less/tree/color.js.map +1 -1
- package/lib/less/tree/combinator.js +16 -35
- package/lib/less/tree/combinator.js.map +1 -1
- package/lib/less/tree/comment.js +17 -36
- package/lib/less/tree/comment.js.map +1 -1
- package/lib/less/tree/condition.js +16 -35
- package/lib/less/tree/condition.js.map +1 -1
- package/lib/less/tree/debug-info.js.map +1 -1
- package/lib/less/tree/declaration.js +36 -74
- package/lib/less/tree/declaration.js.map +1 -1
- package/lib/less/tree/detached-ruleset.js +19 -57
- package/lib/less/tree/detached-ruleset.js.map +1 -1
- package/lib/less/tree/dimension.js +36 -53
- package/lib/less/tree/dimension.js.map +1 -1
- package/lib/less/tree/element.js +34 -53
- package/lib/less/tree/element.js.map +1 -1
- package/lib/less/tree/expression.js +23 -61
- package/lib/less/tree/expression.js.map +1 -1
- package/lib/less/tree/extend.js +34 -53
- package/lib/less/tree/extend.js.map +1 -1
- package/lib/less/tree/import.js +46 -84
- package/lib/less/tree/import.js.map +1 -1
- package/lib/less/tree/index.js +71 -46
- package/lib/less/tree/index.js.map +1 -1
- package/lib/less/tree/javascript.js +16 -35
- package/lib/less/tree/javascript.js.map +1 -1
- package/lib/less/tree/js-eval-node.js +14 -31
- package/lib/less/tree/js-eval-node.js.map +1 -1
- package/lib/less/tree/keyword.js +10 -29
- package/lib/less/tree/keyword.js.map +1 -1
- package/lib/less/tree/media.js +40 -78
- package/lib/less/tree/media.js.map +1 -1
- package/lib/less/tree/mixin-call.js +34 -47
- package/lib/less/tree/mixin-call.js.map +1 -1
- package/lib/less/tree/mixin-definition.js +51 -89
- package/lib/less/tree/mixin-definition.js.map +1 -1
- package/lib/less/tree/namespace-value.js +22 -37
- package/lib/less/tree/namespace-value.js.map +1 -1
- package/lib/less/tree/negative.js +14 -33
- package/lib/less/tree/negative.js.map +1 -1
- package/lib/less/tree/node.js +20 -7
- package/lib/less/tree/node.js.map +1 -1
- package/lib/less/tree/operation.js +22 -59
- package/lib/less/tree/operation.js.map +1 -1
- package/lib/less/tree/paren.js +12 -31
- package/lib/less/tree/paren.js.map +1 -1
- package/lib/less/tree/property.js +21 -36
- package/lib/less/tree/property.js.map +1 -1
- package/lib/less/tree/quoted.js +25 -44
- package/lib/less/tree/quoted.js.map +1 -1
- package/lib/less/tree/ruleset.js +69 -107
- package/lib/less/tree/ruleset.js.map +1 -1
- package/lib/less/tree/selector.js +38 -57
- package/lib/less/tree/selector.js.map +1 -1
- package/lib/less/tree/unicode-descriptor.js +8 -27
- package/lib/less/tree/unicode-descriptor.js.map +1 -1
- package/lib/less/tree/unit.js +38 -76
- package/lib/less/tree/unit.js.map +1 -1
- package/lib/less/tree/url.js +20 -39
- package/lib/less/tree/url.js.map +1 -1
- package/lib/less/tree/value.js +21 -40
- package/lib/less/tree/value.js.map +1 -1
- package/lib/less/tree/variable-call.js +17 -36
- package/lib/less/tree/variable-call.js.map +1 -1
- package/lib/less/tree/variable.js +21 -36
- package/lib/less/tree/variable.js.map +1 -1
- package/lib/less/utils.js +5 -33
- package/lib/less/utils.js.map +1 -1
- package/lib/less/visitors/extend-visitor.js +5 -26
- package/lib/less/visitors/extend-visitor.js.map +1 -1
- package/lib/less/visitors/import-sequencer.js.map +1 -1
- package/lib/less/visitors/import-visitor.js +5 -26
- 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 +7 -7
- package/lib/less/visitors/to-css-visitor.js.map +1 -1
- package/lib/less/visitors/visitor.js +2 -4
- 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 +6 -8
- 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 +24 -39
- package/lib/less-node/url-file-manager.js.map +1 -1
- package/package.json +20 -17
- package/test/index.js +20 -2
- package/test/less-test.js +36 -16
- package/tsconfig.json +6 -0
- package/LICENSE +0 -177
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../../src/less/tree/attribute.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../../src/less/tree/attribute.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAE1B,IAAM,SAAS,GAAG,UAAS,GAAG,EAAE,EAAE,EAAE,KAAK;IACrC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACvB,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC5C,IAAI,EAAE,WAAW;IAEjB,IAAI,YAAC,OAAO;QACR,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAClE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,YAAC,OAAO;QACT,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAEhE,IAAI,IAAI,CAAC,EAAE,EAAE;YACT,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACxE;QAED,OAAO,MAAI,KAAK,MAAG,CAAC;IACxB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC","sourcesContent":["import Node from './node';\n\nconst Attribute = function(key, op, value) {\n this.key = key;\n this.op = op;\n this.value = value;\n}\n\nAttribute.prototype = Object.assign(new Node(), {\n type: 'Attribute',\n\n eval(context) {\n return new Attribute(this.key.eval ? this.key.eval(context) : this.key,\n this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value);\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n },\n\n toCSS(context) {\n let value = this.key.toCSS ? this.key.toCSS(context) : this.key;\n\n if (this.op) {\n value += this.op;\n value += (this.value.toCSS ? this.value.toCSS(context) : this.value);\n }\n\n return `[${value}]`;\n }\n});\n\nexport default Attribute;\n"]}
|
package/lib/less/tree/call.js
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var node_1 = tslib_1.__importDefault(require("./node"));
|
|
5
|
+
var anonymous_1 = tslib_1.__importDefault(require("./anonymous"));
|
|
6
|
+
var function_caller_1 = tslib_1.__importDefault(require("../functions/function-caller"));
|
|
22
7
|
//
|
|
23
8
|
// A function call node.
|
|
24
9
|
//
|
|
25
|
-
var Call =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
Call.prototype.accept = function (visitor) {
|
|
10
|
+
var Call = function (name, args, index, currentFileInfo) {
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.args = args;
|
|
13
|
+
this.calc = name === 'calc';
|
|
14
|
+
this._index = index;
|
|
15
|
+
this._fileInfo = currentFileInfo;
|
|
16
|
+
};
|
|
17
|
+
Call.prototype = Object.assign(new node_1.default(), {
|
|
18
|
+
type: 'Call',
|
|
19
|
+
accept: function (visitor) {
|
|
37
20
|
if (this.args) {
|
|
38
21
|
this.args = visitor.visitArray(this.args);
|
|
39
22
|
}
|
|
40
|
-
}
|
|
23
|
+
},
|
|
41
24
|
//
|
|
42
25
|
// When evaluating a function call,
|
|
43
26
|
// we either find the function in the functionRegistry,
|
|
@@ -49,7 +32,7 @@ var Call = /** @class */ (function (_super) {
|
|
|
49
32
|
// we try to pass a variable to a function, like: `saturate(@color)`.
|
|
50
33
|
// The function should receive the value, not the variable.
|
|
51
34
|
//
|
|
52
|
-
|
|
35
|
+
eval: function (context) {
|
|
53
36
|
var _this = this;
|
|
54
37
|
/**
|
|
55
38
|
* Turn off math for calc(), and switch back on for evaluating nested functions
|
|
@@ -104,8 +87,8 @@ var Call = /** @class */ (function (_super) {
|
|
|
104
87
|
var args = this.args.map(function (a) { return a.eval(context); });
|
|
105
88
|
exitCalc();
|
|
106
89
|
return new Call(this.name, args, this.getIndex(), this.fileInfo());
|
|
107
|
-
}
|
|
108
|
-
|
|
90
|
+
},
|
|
91
|
+
genCSS: function (context, output) {
|
|
109
92
|
output.add(this.name + "(", this.fileInfo(), this.getIndex());
|
|
110
93
|
for (var i = 0; i < this.args.length; i++) {
|
|
111
94
|
this.args[i].genCSS(context, output);
|
|
@@ -114,9 +97,7 @@ var Call = /** @class */ (function (_super) {
|
|
|
114
97
|
}
|
|
115
98
|
}
|
|
116
99
|
output.add(')');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}(node_1.default));
|
|
120
|
-
Call.prototype.type = 'Call';
|
|
100
|
+
}
|
|
101
|
+
});
|
|
121
102
|
exports.default = Call;
|
|
122
103
|
//# sourceMappingURL=call.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../src/less/tree/call.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../src/less/tree/call.js"],"names":[],"mappings":";;;AAAA,wDAA0B;AAC1B,kEAAoC;AACpC,yFAA0D;AAE1D,EAAE;AACF,wBAAwB;AACxB,EAAE;AACF,IAAM,IAAI,GAAG,UAAS,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe;IACpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI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GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAf,CAAe,CAAC,CAAC;QACjD,QAAQ,EAAE,CAAC;QAEX,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,YAAC,OAAO,EAAE,MAAM;QAClB,MAAM,CAAC,GAAG,CAAI,IAAI,CAAC,IAAI,MAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACrC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC1B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACpB;SACJ;QAED,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,IAAI,CAAC","sourcesContent":["import Node from './node';\nimport Anonymous from './anonymous';\nimport FunctionCaller from '../functions/function-caller';\n\n//\n// A function call node.\n//\nconst Call = function(name, args, index, currentFileInfo) {\n this.name = name;\n this.args = args;\n this.calc = name === 'calc';\n this._index = index;\n this._fileInfo = currentFileInfo;\n}\n\nCall.prototype = Object.assign(new Node(), {\n type: 'Call',\n\n accept(visitor) {\n if (this.args) {\n this.args = visitor.visitArray(this.args);\n }\n },\n\n //\n // When evaluating a function call,\n // we either find the function in the functionRegistry,\n // in which case we call it, passing the evaluated arguments,\n // if this returns null or we cannot find the function, we\n // simply print it out as it appeared originally [2].\n //\n // The reason why we evaluate the arguments, is in the case where\n // we try to pass a variable to a function, like: `saturate(@color)`.\n // The function should receive the value, not the variable.\n //\n eval(context) {\n /**\n * Turn off math for calc(), and switch back on for evaluating nested functions\n */\n const currentMathContext = context.mathOn;\n context.mathOn = !this.calc;\n if (this.calc || context.inCalc) {\n context.enterCalc();\n }\n\n const exitCalc = () => {\n if (this.calc || context.inCalc) {\n context.exitCalc();\n }\n context.mathOn = currentMathContext;\n };\n\n let result;\n const funcCaller = new FunctionCaller(this.name, context, this.getIndex(), this.fileInfo());\n\n if (funcCaller.isValid()) {\n try {\n result = funcCaller.call(this.args);\n exitCalc();\n } catch (e) {\n if (e.hasOwnProperty('line') && e.hasOwnProperty('column')) {\n throw e;\n }\n throw { \n type: e.type || 'Runtime',\n message: `Error evaluating function \\`${this.name}\\`${e.message ? `: ${e.message}` : ''}`,\n index: this.getIndex(), \n filename: this.fileInfo().filename,\n line: e.lineNumber,\n column: e.columnNumber\n };\n }\n }\n\n if (result !== null && result !== undefined) {\n // Results that that are not nodes are cast as Anonymous nodes\n // Falsy values or booleans are returned as empty nodes\n if (!(result instanceof Node)) {\n if (!result || result === true) {\n result = new Anonymous(null); \n }\n else {\n result = new Anonymous(result.toString()); \n }\n \n }\n result._index = this._index;\n result._fileInfo = this._fileInfo;\n return result;\n }\n\n const args = this.args.map(a => a.eval(context));\n exitCalc();\n\n return new Call(this.name, args, this.getIndex(), this.fileInfo());\n },\n\n genCSS(context, output) {\n output.add(`${this.name}(`, this.fileInfo(), this.getIndex());\n\n for (let i = 0; i < this.args.length; i++) {\n this.args[i].genCSS(context, output);\n if (i + 1 < this.args.length) {\n output.add(', ');\n }\n }\n\n output.add(')');\n }\n});\n\nexport default Call;\n"]}
|
package/lib/less/tree/color.js
CHANGED
|
@@ -1,79 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
var
|
|
20
|
-
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"));
|
|
21
6
|
//
|
|
22
7
|
// RGB Colors - #ff0014, #eee
|
|
23
8
|
//
|
|
24
|
-
var Color =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
if (Array.isArray(rgb)) {
|
|
36
|
-
_this.rgb = rgb;
|
|
37
|
-
}
|
|
38
|
-
else if (rgb.length >= 6) {
|
|
39
|
-
_this.rgb = [];
|
|
40
|
-
rgb.match(/.{2}/g).map(function (c, i) {
|
|
41
|
-
if (i < 3) {
|
|
42
|
-
self.rgb.push(parseInt(c, 16));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
self.alpha = (parseInt(c, 16)) / 255;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
_this.rgb = [];
|
|
51
|
-
rgb.split('').map(function (c, i) {
|
|
52
|
-
if (i < 3) {
|
|
53
|
-
self.rgb.push(parseInt(c + c, 16));
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
self.alpha = (parseInt(c + c, 16)) / 255;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
_this.alpha = _this.alpha || (typeof a === 'number' ? a : 1);
|
|
61
|
-
if (typeof originalForm !== 'undefined') {
|
|
62
|
-
_this.value = originalForm;
|
|
63
|
-
}
|
|
64
|
-
return _this;
|
|
9
|
+
var Color = function (rgb, a, originalForm) {
|
|
10
|
+
var self = this;
|
|
11
|
+
//
|
|
12
|
+
// The end goal here, is to parse the arguments
|
|
13
|
+
// into an integer triplet, such as `128, 255, 0`
|
|
14
|
+
//
|
|
15
|
+
// This facilitates operations and conversions.
|
|
16
|
+
//
|
|
17
|
+
if (Array.isArray(rgb)) {
|
|
18
|
+
this.rgb = rgb;
|
|
65
19
|
}
|
|
66
|
-
|
|
20
|
+
else if (rgb.length >= 6) {
|
|
21
|
+
this.rgb = [];
|
|
22
|
+
rgb.match(/.{2}/g).map(function (c, i) {
|
|
23
|
+
if (i < 3) {
|
|
24
|
+
self.rgb.push(parseInt(c, 16));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
self.alpha = (parseInt(c, 16)) / 255;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.rgb = [];
|
|
33
|
+
rgb.split('').map(function (c, i) {
|
|
34
|
+
if (i < 3) {
|
|
35
|
+
self.rgb.push(parseInt(c + c, 16));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
self.alpha = (parseInt(c + c, 16)) / 255;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
this.alpha = this.alpha || (typeof a === 'number' ? a : 1);
|
|
43
|
+
if (typeof originalForm !== 'undefined') {
|
|
44
|
+
this.value = originalForm;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Color.prototype = Object.assign(new node_1.default(), {
|
|
48
|
+
type: 'Color',
|
|
49
|
+
luma: function () {
|
|
67
50
|
var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255;
|
|
68
51
|
r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);
|
|
69
52
|
g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);
|
|
70
53
|
b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);
|
|
71
54
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
72
|
-
}
|
|
73
|
-
|
|
55
|
+
},
|
|
56
|
+
genCSS: function (context, output) {
|
|
74
57
|
output.add(this.toCSS(context));
|
|
75
|
-
}
|
|
76
|
-
|
|
58
|
+
},
|
|
59
|
+
toCSS: function (context, doNotCompress) {
|
|
77
60
|
var compress = context && context.compress && !doNotCompress;
|
|
78
61
|
var color;
|
|
79
62
|
var alpha;
|
|
@@ -135,25 +118,25 @@ var Color = /** @class */ (function (_super) {
|
|
|
135
118
|
}
|
|
136
119
|
}
|
|
137
120
|
return color;
|
|
138
|
-
}
|
|
121
|
+
},
|
|
139
122
|
//
|
|
140
123
|
// Operations have to be done per-channel, if not,
|
|
141
124
|
// channels will spill onto each other. Once we have
|
|
142
125
|
// our result, in the form of an integer triplet,
|
|
143
126
|
// we create a new Color node to hold the result.
|
|
144
127
|
//
|
|
145
|
-
|
|
128
|
+
operate: function (context, op, other) {
|
|
146
129
|
var rgb = new Array(3);
|
|
147
130
|
var alpha = this.alpha * (1 - other.alpha) + other.alpha;
|
|
148
131
|
for (var c = 0; c < 3; c++) {
|
|
149
132
|
rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);
|
|
150
133
|
}
|
|
151
134
|
return new Color(rgb, alpha);
|
|
152
|
-
}
|
|
153
|
-
|
|
135
|
+
},
|
|
136
|
+
toRGB: function () {
|
|
154
137
|
return toHex(this.rgb);
|
|
155
|
-
}
|
|
156
|
-
|
|
138
|
+
},
|
|
139
|
+
toHSL: function () {
|
|
157
140
|
var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;
|
|
158
141
|
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
159
142
|
var h;
|
|
@@ -179,9 +162,9 @@ var Color = /** @class */ (function (_super) {
|
|
|
179
162
|
h /= 6;
|
|
180
163
|
}
|
|
181
164
|
return { h: h * 360, s: s, l: l, a: a };
|
|
182
|
-
}
|
|
165
|
+
},
|
|
183
166
|
// Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
|
|
184
|
-
|
|
167
|
+
toHSV: function () {
|
|
185
168
|
var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;
|
|
186
169
|
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
187
170
|
var h;
|
|
@@ -212,34 +195,32 @@ var Color = /** @class */ (function (_super) {
|
|
|
212
195
|
h /= 6;
|
|
213
196
|
}
|
|
214
197
|
return { h: h * 360, s: s, v: v, a: a };
|
|
215
|
-
}
|
|
216
|
-
|
|
198
|
+
},
|
|
199
|
+
toARGB: function () {
|
|
217
200
|
return toHex([this.alpha * 255].concat(this.rgb));
|
|
218
|
-
}
|
|
219
|
-
|
|
201
|
+
},
|
|
202
|
+
compare: function (x) {
|
|
220
203
|
return (x.rgb &&
|
|
221
204
|
x.rgb[0] === this.rgb[0] &&
|
|
222
205
|
x.rgb[1] === this.rgb[1] &&
|
|
223
206
|
x.rgb[2] === this.rgb[2] &&
|
|
224
207
|
x.alpha === this.alpha) ? 0 : undefined;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
}(node_1.default));
|
|
242
|
-
Color.prototype.type = 'Color';
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
Color.fromKeyword = function (keyword) {
|
|
211
|
+
var c;
|
|
212
|
+
var key = keyword.toLowerCase();
|
|
213
|
+
if (colors_1.default.hasOwnProperty(key)) {
|
|
214
|
+
c = new Color(colors_1.default[key].slice(1));
|
|
215
|
+
}
|
|
216
|
+
else if (key === 'transparent') {
|
|
217
|
+
c = new Color([0, 0, 0], 0);
|
|
218
|
+
}
|
|
219
|
+
if (c) {
|
|
220
|
+
c.value = keyword;
|
|
221
|
+
return c;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
243
224
|
function clamp(v, max) {
|
|
244
225
|
return Math.min(Math.max(v, 0), max);
|
|
245
226
|
}
|
|
@@ -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;IAAoB,yBAAI;IACpB,eAAY,GAAG,EAAE,CAAC,EAAE,YAAY;QAAhC,YACI,iBAAO,SAkCV;QAhCG,IAAM,IAAI,GAAG,KAAI,CAAC;QAClB,EAAE;QACF,+CAA+C;QAC/C,iDAAiD;QACjD,EAAE;QACF,+CAA+C;QAC/C,EAAE;QACF,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACpB,KAAI,CAAC,GAAG,GAAG,GAAG,CAAC;SAClB;aAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE;YACxB,KAAI,CAAC,GAAG,GAAG,EAAE,CAAC;YACd,GAAG,CAAC,K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014, #eee\n//\nclass Color extends Node {\n constructor(rgb, a, originalForm) {\n super();\n\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\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 static 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}\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(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
|
+
{"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,K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,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,47 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
var
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var node_1 = tslib_1.__importDefault(require("./node"));
|
|
20
5
|
var _noSpaceCombinators = {
|
|
21
6
|
'': true,
|
|
22
7
|
' ': true,
|
|
23
8
|
'|': true
|
|
24
9
|
};
|
|
25
|
-
var Combinator =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else {
|
|
34
|
-
_this.value = value ? value.trim() : '';
|
|
35
|
-
_this.emptyOrWhitespace = _this.value === '';
|
|
36
|
-
}
|
|
37
|
-
return _this;
|
|
10
|
+
var Combinator = function (value) {
|
|
11
|
+
if (value === ' ') {
|
|
12
|
+
this.value = ' ';
|
|
13
|
+
this.emptyOrWhitespace = true;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
this.value = value ? value.trim() : '';
|
|
17
|
+
this.emptyOrWhitespace = this.value === '';
|
|
38
18
|
}
|
|
39
|
-
|
|
19
|
+
};
|
|
20
|
+
Combinator.prototype = Object.assign(new node_1.default(), {
|
|
21
|
+
type: 'Combinator',
|
|
22
|
+
genCSS: function (context, output) {
|
|
40
23
|
var spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';
|
|
41
24
|
output.add(spaceOrEmpty + this.value + spaceOrEmpty);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}(node_1.default));
|
|
45
|
-
Combinator.prototype.type = 'Combinator';
|
|
25
|
+
}
|
|
26
|
+
});
|
|
46
27
|
exports.default = Combinator;
|
|
47
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,46 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Comment.prototype.genCSS = function (context, output) {
|
|
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"));
|
|
6
|
+
var Comment = function (value, isLineComment, index, currentFileInfo) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
this.isLineComment = isLineComment;
|
|
9
|
+
this._index = index;
|
|
10
|
+
this._fileInfo = currentFileInfo;
|
|
11
|
+
this.allowRoot = true;
|
|
12
|
+
};
|
|
13
|
+
Comment.prototype = Object.assign(new node_1.default(), {
|
|
14
|
+
type: 'Comment',
|
|
15
|
+
genCSS: function (context, output) {
|
|
33
16
|
if (this.debugInfo) {
|
|
34
17
|
output.add(debug_info_1.default(context, this), this.fileInfo(), this.getIndex());
|
|
35
18
|
}
|
|
36
19
|
output.add(this.value);
|
|
37
|
-
}
|
|
38
|
-
|
|
20
|
+
},
|
|
21
|
+
isSilent: function (context) {
|
|
39
22
|
var isCompressed = context.compress && this.value[2] !== '!';
|
|
40
23
|
return this.isLineComment || isCompressed;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}(node_1.default));
|
|
44
|
-
Comment.prototype.type = 'Comment';
|
|
24
|
+
}
|
|
25
|
+
});
|
|
45
26
|
exports.default = Comment;
|
|
46
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"]}
|