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.
Files changed (200) hide show
  1. package/Gruntfile.js +1 -1
  2. package/bin/lessc +14 -3
  3. package/dist/less.js +11156 -11157
  4. package/dist/less.min.js +3 -3
  5. package/dist/less.min.js.map +1 -1
  6. package/lib/less/constants.js +2 -2
  7. package/lib/less/constants.js.map +1 -1
  8. package/lib/less/contexts.js +88 -110
  9. package/lib/less/contexts.js.map +1 -1
  10. package/lib/less/data/index.js +3 -5
  11. package/lib/less/data/index.js.map +1 -1
  12. package/lib/less/default-options.js +57 -53
  13. package/lib/less/default-options.js.map +1 -1
  14. package/lib/less/environment/abstract-file-manager.js +6 -6
  15. package/lib/less/environment/abstract-file-manager.js.map +1 -1
  16. package/lib/less/environment/abstract-plugin-loader.js +7 -13
  17. package/lib/less/environment/abstract-plugin-loader.js.map +1 -1
  18. package/lib/less/environment/environment.js +9 -11
  19. package/lib/less/environment/environment.js.map +1 -1
  20. package/lib/less/functions/boolean.js +14 -6
  21. package/lib/less/functions/boolean.js.map +1 -1
  22. package/lib/less/functions/color-blending.js +2 -4
  23. package/lib/less/functions/color-blending.js.map +1 -1
  24. package/lib/less/functions/color.js +41 -9
  25. package/lib/less/functions/color.js.map +1 -1
  26. package/lib/less/functions/data-uri.js +5 -26
  27. package/lib/less/functions/data-uri.js.map +1 -1
  28. package/lib/less/functions/default.js +2 -4
  29. package/lib/less/functions/default.js.map +1 -1
  30. package/lib/less/functions/function-caller.js +19 -35
  31. package/lib/less/functions/function-caller.js.map +1 -1
  32. package/lib/less/functions/index.js +14 -16
  33. package/lib/less/functions/index.js.map +1 -1
  34. package/lib/less/functions/list.js +21 -12
  35. package/lib/less/functions/list.js.map +1 -1
  36. package/lib/less/functions/math-helper.js +2 -4
  37. package/lib/less/functions/math-helper.js.map +1 -1
  38. package/lib/less/functions/math.js +2 -4
  39. package/lib/less/functions/math.js.map +1 -1
  40. package/lib/less/functions/number.js +12 -8
  41. package/lib/less/functions/number.js.map +1 -1
  42. package/lib/less/functions/string.js +4 -6
  43. package/lib/less/functions/string.js.map +1 -1
  44. package/lib/less/functions/svg.js +6 -8
  45. package/lib/less/functions/svg.js.map +1 -1
  46. package/lib/less/functions/types.js +9 -11
  47. package/lib/less/functions/types.js.map +1 -1
  48. package/lib/less/import-manager.js +6 -27
  49. package/lib/less/import-manager.js.map +1 -1
  50. package/lib/less/index.js +48 -82
  51. package/lib/less/index.js.map +1 -1
  52. package/lib/less/less-error.js +6 -24
  53. package/lib/less/less-error.js.map +1 -1
  54. package/lib/less/parse-tree.js +8 -8
  55. package/lib/less/parse-tree.js.map +1 -1
  56. package/lib/less/parse.js +11 -31
  57. package/lib/less/parse.js.map +1 -1
  58. package/lib/less/parser/chunker.js +4 -2
  59. package/lib/less/parser/chunker.js.map +1 -1
  60. package/lib/less/parser/parser-input.js +2 -4
  61. package/lib/less/parser/parser-input.js.map +1 -1
  62. package/lib/less/parser/parser.js +8 -29
  63. package/lib/less/parser/parser.js.map +1 -1
  64. package/lib/less/plugin-manager.js +2 -3
  65. package/lib/less/plugin-manager.js.map +1 -1
  66. package/lib/less/render.js +6 -22
  67. package/lib/less/render.js.map +1 -1
  68. package/lib/less/source-map-builder.js +4 -2
  69. package/lib/less/source-map-builder.js.map +1 -1
  70. package/lib/less/source-map-output.js +5 -7
  71. package/lib/less/source-map-output.js.map +1 -1
  72. package/lib/less/transform-tree.js +9 -9
  73. package/lib/less/transform-tree.js.map +1 -1
  74. package/lib/less/tree/anonymous.js +19 -20
  75. package/lib/less/tree/anonymous.js.map +1 -1
  76. package/lib/less/tree/assignment.js +22 -23
  77. package/lib/less/tree/assignment.js.map +1 -1
  78. package/lib/less/tree/atrule.js +105 -116
  79. package/lib/less/tree/atrule.js.map +1 -1
  80. package/lib/less/tree/attribute.js +18 -19
  81. package/lib/less/tree/attribute.js.map +1 -1
  82. package/lib/less/tree/call.js +68 -69
  83. package/lib/less/tree/call.js.map +1 -1
  84. package/lib/less/tree/color.js +163 -172
  85. package/lib/less/tree/color.js.map +1 -1
  86. package/lib/less/tree/combinator.js +9 -10
  87. package/lib/less/tree/combinator.js.map +1 -1
  88. package/lib/less/tree/comment.js +15 -16
  89. package/lib/less/tree/comment.js.map +1 -1
  90. package/lib/less/tree/condition.js +29 -30
  91. package/lib/less/tree/condition.js.map +1 -1
  92. package/lib/less/tree/debug-info.js +32 -30
  93. package/lib/less/tree/debug-info.js.map +1 -1
  94. package/lib/less/tree/declaration.js +71 -95
  95. package/lib/less/tree/declaration.js.map +1 -1
  96. package/lib/less/tree/detached-ruleset.js +18 -38
  97. package/lib/less/tree/detached-ruleset.js.map +1 -1
  98. package/lib/less/tree/dimension.js +126 -129
  99. package/lib/less/tree/dimension.js.map +1 -1
  100. package/lib/less/tree/element.js +40 -41
  101. package/lib/less/tree/element.js.map +1 -1
  102. package/lib/less/tree/expression.js +55 -74
  103. package/lib/less/tree/expression.js.map +1 -1
  104. package/lib/less/tree/extend.js +28 -34
  105. package/lib/less/tree/extend.js.map +1 -1
  106. package/lib/less/tree/import.js +120 -140
  107. package/lib/less/tree/import.js.map +1 -1
  108. package/lib/less/tree/index.js +37 -39
  109. package/lib/less/tree/index.js.map +1 -1
  110. package/lib/less/tree/javascript.js +23 -24
  111. package/lib/less/tree/javascript.js.map +1 -1
  112. package/lib/less/tree/js-eval-node.js +51 -50
  113. package/lib/less/tree/js-eval-node.js.map +1 -1
  114. package/lib/less/tree/keyword.js +10 -11
  115. package/lib/less/tree/keyword.js.map +1 -1
  116. package/lib/less/tree/media.js +111 -131
  117. package/lib/less/tree/media.js.map +1 -1
  118. package/lib/less/tree/mixin-call.js +156 -160
  119. package/lib/less/tree/mixin-call.js.map +1 -1
  120. package/lib/less/tree/mixin-definition.js +164 -184
  121. package/lib/less/tree/mixin-definition.js.map +1 -1
  122. package/lib/less/tree/namespace-value.js +53 -57
  123. package/lib/less/tree/namespace-value.js.map +1 -1
  124. package/lib/less/tree/negative.js +16 -17
  125. package/lib/less/tree/negative.js.map +1 -1
  126. package/lib/less/tree/node.js +39 -39
  127. package/lib/less/tree/node.js.map +1 -1
  128. package/lib/less/tree/operation.js +41 -63
  129. package/lib/less/tree/operation.js.map +1 -1
  130. package/lib/less/tree/paren.js +13 -14
  131. package/lib/less/tree/paren.js.map +1 -1
  132. package/lib/less/tree/property.js +48 -49
  133. package/lib/less/tree/property.js.map +1 -1
  134. package/lib/less/tree/quoted.js +50 -51
  135. package/lib/less/tree/quoted.js.map +1 -1
  136. package/lib/less/tree/ruleset.js +665 -702
  137. package/lib/less/tree/ruleset.js.map +1 -1
  138. package/lib/less/tree/selector.js +105 -106
  139. package/lib/less/tree/selector.js.map +1 -1
  140. package/lib/less/tree/unicode-descriptor.js +5 -6
  141. package/lib/less/tree/unicode-descriptor.js.map +1 -1
  142. package/lib/less/tree/unit.js +99 -120
  143. package/lib/less/tree/unit.js.map +1 -1
  144. package/lib/less/tree/url.js +44 -45
  145. package/lib/less/tree/url.js.map +1 -1
  146. package/lib/less/tree/value.js +27 -26
  147. package/lib/less/tree/value.js.map +1 -1
  148. package/lib/less/tree/variable-call.js +30 -31
  149. package/lib/less/tree/variable-call.js.map +1 -1
  150. package/lib/less/tree/variable.js +46 -48
  151. package/lib/less/tree/variable.js.map +1 -1
  152. package/lib/less/utils.js +5 -23
  153. package/lib/less/utils.js.map +1 -1
  154. package/lib/less/visitors/extend-visitor.js +14 -41
  155. package/lib/less/visitors/extend-visitor.js.map +1 -1
  156. package/lib/less/visitors/import-sequencer.js +2 -7
  157. package/lib/less/visitors/import-sequencer.js.map +1 -1
  158. package/lib/less/visitors/import-visitor.js +7 -33
  159. package/lib/less/visitors/import-visitor.js.map +1 -1
  160. package/lib/less/visitors/index.js +7 -9
  161. package/lib/less/visitors/index.js.map +1 -1
  162. package/lib/less/visitors/join-selector-visitor.js +2 -4
  163. package/lib/less/visitors/join-selector-visitor.js.map +1 -1
  164. package/lib/less/visitors/to-css-visitor.js +4 -6
  165. package/lib/less/visitors/to-css-visitor.js.map +1 -1
  166. package/lib/less/visitors/visitor.js +4 -12
  167. package/lib/less/visitors/visitor.js.map +1 -1
  168. package/lib/less-browser/add-default-options.js +2 -4
  169. package/lib/less-browser/add-default-options.js.map +1 -1
  170. package/lib/less-browser/bootstrap.js +4 -6
  171. package/lib/less-browser/bootstrap.js.map +1 -1
  172. package/lib/less-browser/browser.js +2 -20
  173. package/lib/less-browser/browser.js.map +1 -1
  174. package/lib/less-browser/error-reporting.js +3 -24
  175. package/lib/less-browser/error-reporting.js.map +1 -1
  176. package/lib/less-browser/file-manager.js +17 -36
  177. package/lib/less-browser/file-manager.js.map +1 -1
  178. package/lib/less-browser/image-size.js +2 -4
  179. package/lib/less-browser/image-size.js.map +1 -1
  180. package/lib/less-browser/index.js +9 -11
  181. package/lib/less-browser/index.js.map +1 -1
  182. package/lib/less-browser/plugin-loader.js +10 -29
  183. package/lib/less-browser/plugin-loader.js.map +1 -1
  184. package/lib/less-node/file-manager.js +15 -34
  185. package/lib/less-node/file-manager.js.map +1 -1
  186. package/lib/less-node/image-size.js +4 -6
  187. package/lib/less-node/image-size.js.map +1 -1
  188. package/lib/less-node/index.js +10 -16
  189. package/lib/less-node/index.js.map +1 -1
  190. package/lib/less-node/plugin-loader.js +23 -42
  191. package/lib/less-node/plugin-loader.js.map +1 -1
  192. package/lib/less-node/url-file-manager.js +23 -38
  193. package/lib/less-node/url-file-manager.js.map +1 -1
  194. package/package.json +12 -9
  195. package/test/browser/less/errors/image-height-error.txt +1 -1
  196. package/test/browser/less/errors/image-size-error.txt +1 -1
  197. package/test/browser/less/errors/image-width-error.txt +1 -1
  198. package/test/index.js +28 -9
  199. package/test/less-test.js +36 -16
  200. package/tsconfig.json +1 -0
@@ -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 node_1 = __importDefault(require("./node"));
7
- var colors_1 = __importDefault(require("../data/colors"));
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.prototype.luma = function () {
51
- var r = this.rgb[0] / 255;
52
- var g = this.rgb[1] / 255;
53
- var b = this.rgb[2] / 255;
54
- r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);
55
- g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);
56
- b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);
57
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
58
- };
59
- Color.prototype.genCSS = function (context, output) {
60
- output.add(this.toCSS(context));
61
- };
62
- Color.prototype.toCSS = function (context, doNotCompress) {
63
- var compress = context && context.compress && !doNotCompress;
64
- var color;
65
- var alpha;
66
- var colorFunction;
67
- var args = [];
68
- // `value` is set if this color was originally
69
- // converted from a named color string so we need
70
- // to respect this and try to output named color too.
71
- alpha = this.fround(context, this.alpha);
72
- if (this.value) {
73
- if (this.value.indexOf('rgb') === 0) {
74
- if (alpha < 1) {
75
- colorFunction = 'rgba';
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 if (this.value.indexOf('hsl') === 0) {
87
+ else {
79
88
  if (alpha < 1) {
80
- colorFunction = 'hsla';
89
+ colorFunction = 'rgba';
81
90
  }
82
- else {
83
- colorFunction = 'hsl';
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
- return this.value;
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
- else {
91
- if (alpha < 1) {
92
- colorFunction = 'rgba';
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
- switch (colorFunction) {
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
- return color;
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
- h /= 6;
168
- }
169
- return { h: h * 360, s: s, l: l, a: a };
170
- };
171
- // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
172
- Color.prototype.toHSV = function () {
173
- var r = this.rgb[0] / 255;
174
- var g = this.rgb[1] / 255;
175
- var b = this.rgb[2] / 255;
176
- var a = this.alpha;
177
- var max = Math.max(r, g, b);
178
- var min = Math.min(r, g, b);
179
- var h;
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 /= 6;
205
- }
206
- return { h: h * 360, s: s, v: v, a: a };
207
- };
208
- Color.prototype.toARGB = function () {
209
- return toHex([this.alpha * 255].concat(this.rgb));
210
- };
211
- Color.prototype.compare = function (x) {
212
- return (x.rgb &&
213
- x.rgb[0] === this.rgb[0] &&
214
- x.rgb[1] === this.rgb[1] &&
215
- x.rgb[2] === this.rgb[2] &&
216
- x.alpha === this.alpha) ? 0 : undefined;
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,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,gBAAM,CAAC,GAAG,CAAC,CAAC,KAAK,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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AC;QAClB,OAAO,CAAC,CAAC;KACZ;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 node_1 = __importDefault(require("./node"));
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.prototype.genCSS = function (context, output) {
24
- var spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';
25
- output.add(spaceOrEmpty + this.value + spaceOrEmpty);
26
- };
27
- Combinator.prototype.type = 'Combinator';
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":";;;;;AAAA,gDAA0B;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,CAAC;AAEF,UAAU,CAAC,SAAS,GAAG,IAAI,cAAI,EAAE,CAAC;AAElC,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,UAAS,OAAO,EAAE,MAAM;IAClD,IAAM,YAAY,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACtF,MAAM,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,IAAI,GAAG,YAAY,CAAC;AAEzC,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 = new Node();\n\nCombinator.prototype.genCSS = function(context, output) {\n const spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';\n output.add(spaceOrEmpty + this.value + spaceOrEmpty);\n};\n\nCombinator.prototype.type = 'Combinator';\n\nexport default Combinator;\n"]}
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"]}
@@ -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 node_1 = __importDefault(require("./node"));
7
- var debug_info_1 = __importDefault(require("./debug-info"));
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.prototype.genCSS = function (context, output) {
17
- if (this.debugInfo) {
18
- output.add(debug_info_1.default(context, this), this.fileInfo(), this.getIndex());
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
- output.add(this.value);
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":";;;;;AAAA,gDAA0B;AAC1B,4DAAwC;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,CAAC;AAEF,OAAO,CAAC,SAAS,GAAG,IAAI,cAAI,EAAE,CAAC;AAE/B,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,UAAS,OAAO,EAAE,MAAM;IAC/C,IAAI,IAAI,CAAC,SAAS,EAAE;QAChB,MAAM,CAAC,GAAG,CAAC,oBAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;KAC7E;IACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,OAAO,CAAC,SAAS,CAAC,QAAQ,GAAG,UAAS,OAAO;IACzC,IAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;IAC/D,OAAO,IAAI,CAAC,aAAa,IAAI,YAAY,CAAC;AAC9C,CAAC,CAAC;AAEF,OAAO,CAAC,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC;AACnC,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 = new Node();\n\nComment.prototype.genCSS = function(context, output) {\n if (this.debugInfo) {\n output.add(getDebugInfo(context, this), this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n};\n\nComment.prototype.isSilent = function(context) {\n const isCompressed = context.compress && this.value[2] !== '!';\n return this.isLineComment || isCompressed;\n};\n\nComment.prototype.type = 'Comment';\nexport default Comment;\n"]}
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 node_1 = __importDefault(require("./node"));
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.prototype.accept = function (visitor) {
16
- this.lvalue = visitor.visit(this.lvalue);
17
- this.rvalue = visitor.visit(this.rvalue);
18
- };
19
- Condition.prototype.eval = function (context) {
20
- var result = (function (op, a, b) {
21
- switch (op) {
22
- case 'and': return a && b;
23
- case 'or': return a || b;
24
- default:
25
- switch (node_1.default.compare(a, b)) {
26
- case -1:
27
- return op === '<' || op === '=<' || op === '<=';
28
- case 0:
29
- return op === '=' || op === '>=' || op === '=<' || op === '<=';
30
- case 1:
31
- return op === '>' || op === '>=';
32
- default:
33
- return false;
34
- }
35
- }
36
- })(this.op, this.lvalue.eval(context), this.rvalue.eval(context));
37
- return this.negate ? !result : result;
38
- };
39
- Condition.prototype.type = 'Condition';
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":";;;;;AAAA,gDAA0B;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,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC,CAAC;AAEF,SAAS,CAAC,SAAS,GAAG,IAAI,cAAI,EAAE,CAAC;AAEjC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,UAAS,OAAO;IACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,I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.op = op.trim();\n this.lvalue = l;\n this.rvalue = r;\n this._index = i;\n this.negate = negate;\n};\n\nCondition.prototype = new Node();\n\nCondition.prototype.accept = function(visitor) {\n this.lvalue = visitor.visit(this.lvalue);\n this.rvalue = visitor.visit(this.rvalue);\n}\n\nCondition.prototype.eval = function(context) {\n const result = ((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\nCondition.prototype.type = 'Condition';\nexport default Condition;\n"]}
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,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC,CAAC;AAEF,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,cAAI,EAAE,EAAE;IAC5C,IAAI,EAAE,WAAW;IAEjB,MAAM,YAAC,OAAO;QACV,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,YAAC,OAAO;QACR,IAAM,MAAM,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;YAC9B,QAAQ,EAAE,EAAE;gBACR,KAAK,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1B,KAAK,IAAI,CAAC,CAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1B;oBACI,QAAQ,cAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;wBACxB,KAAK,CAAC,CAAC;4BACH,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;wBACpD,KAAK,CAAC;4BACF,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;wBACnE,KAAK,CAAC;4BACF,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;wBACrC;4BACI,OAAO,KAAK,CAAC;qBACpB;aACR;QACL,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;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"]}