custom-electron-titlebar 4.2.0 → 4.2.1

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 (65) hide show
  1. package/dist/base/browser/browser.d.ts +26 -0
  2. package/dist/base/browser/browser.js +317 -0
  3. package/dist/base/browser/event.d.ts +12 -0
  4. package/dist/base/browser/event.js +215 -0
  5. package/dist/base/browser/keyboardEvent.d.ts +38 -0
  6. package/dist/base/browser/keyboardEvent.js +466 -0
  7. package/dist/base/browser/mouseEvent.d.ts +61 -0
  8. package/dist/base/browser/mouseEvent.js +327 -0
  9. package/dist/base/browser/touch.d.ts +39 -0
  10. package/dist/base/browser/touch.js +454 -0
  11. package/dist/base/common/arrays.d.ts +10 -0
  12. package/dist/base/common/arrays.js +210 -0
  13. package/dist/base/common/async.d.ts +35 -0
  14. package/dist/base/common/async.js +280 -0
  15. package/dist/base/common/charCode.d.ts +405 -0
  16. package/dist/base/common/charCode.js +9 -0
  17. package/dist/base/common/color.d.ts +159 -0
  18. package/dist/base/common/color.js +709 -0
  19. package/dist/base/common/decorators.d.ts +6 -0
  20. package/dist/base/common/decorators.js +300 -0
  21. package/dist/base/common/dom.d.ts +221 -0
  22. package/dist/base/common/dom.js +1478 -0
  23. package/dist/base/common/event.d.ts +213 -0
  24. package/dist/base/common/event.js +804 -0
  25. package/dist/base/common/iterator.d.ts +69 -0
  26. package/dist/base/common/iterator.js +381 -0
  27. package/dist/base/common/keyCodes.d.ts +478 -0
  28. package/dist/base/common/keyCodes.js +479 -0
  29. package/dist/base/common/lifecycle.d.ts +17 -0
  30. package/dist/base/common/lifecycle.js +258 -0
  31. package/dist/base/common/linkedList.d.ts +17 -0
  32. package/dist/base/common/linkedList.js +319 -0
  33. package/dist/base/common/platform.d.ts +33 -0
  34. package/dist/base/common/platform.js +302 -0
  35. package/dist/base/common/strings.d.ts +23 -0
  36. package/dist/base/common/strings.js +273 -0
  37. package/dist/consts.d.ts +49 -0
  38. package/dist/consts.js +303 -0
  39. package/dist/index.d.ts +3 -0
  40. package/dist/index.js +211 -0
  41. package/dist/main/attach-titlebar-to-window.d.ts +3 -0
  42. package/dist/main/attach-titlebar-to-window.js +207 -0
  43. package/dist/main/index.d.ts +3 -0
  44. package/dist/main/index.js +202 -0
  45. package/dist/main/setup-titlebar.d.ts +2 -0
  46. package/dist/main/setup-titlebar.js +242 -0
  47. package/dist/menubar/index.d.ts +86 -0
  48. package/dist/menubar/index.js +1118 -0
  49. package/dist/menubar/menu/index.d.ts +46 -0
  50. package/dist/menubar/menu/index.js +556 -0
  51. package/dist/menubar/menu/item.d.ts +67 -0
  52. package/dist/menubar/menu/item.js +575 -0
  53. package/dist/menubar/menu/separator.d.ts +11 -0
  54. package/dist/menubar/menu/separator.js +213 -0
  55. package/dist/menubar/menu/submenu.d.ts +32 -0
  56. package/dist/menubar/menu/submenu.js +372 -0
  57. package/dist/menubar/menubar-options.d.ts +55 -0
  58. package/dist/menubar/menubar-options.js +9 -0
  59. package/dist/titlebar/index.d.ts +99 -0
  60. package/dist/titlebar/index.js +663 -0
  61. package/dist/titlebar/options.d.ts +84 -0
  62. package/dist/titlebar/options.js +9 -0
  63. package/dist/titlebar/themebar.d.ts +20 -0
  64. package/dist/titlebar/themebar.js +267 -0
  65. package/package.json +1 -1
@@ -0,0 +1,709 @@
1
+ "use strict";
2
+
3
+ /* ---------------------------------------------------------------------------------------------
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ * Licensed under the MIT License. See License.txt in the project root for license information.
6
+ *-------------------------------------------------------------------------------------------- */
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.Color = exports.HSVA = exports.HSLA = exports.RGBA = void 0;
11
+ function roundFloat(number, decimalPoints) {
12
+ const decimal = Math.pow(10, decimalPoints);
13
+ return Math.round(number * decimal) / decimal;
14
+ }
15
+ class RGBA {
16
+ constructor(r, g, b, a = 1) {
17
+ this.r = Math.min(255, Math.max(0, r)) | 0;
18
+ this.g = Math.min(255, Math.max(0, g)) | 0;
19
+ this.b = Math.min(255, Math.max(0, b)) | 0;
20
+ this.a = _get__("roundFloat")(Math.max(Math.min(1, a), 0), 3);
21
+ }
22
+ static equals(a, b) {
23
+ return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a;
24
+ }
25
+ }
26
+ exports.RGBA = _get__("RGBA");
27
+ class HSLA {
28
+ constructor(h, s, l, a) {
29
+ this.h = Math.max(Math.min(360, h), 0) | 0;
30
+ this.s = _get__("roundFloat")(Math.max(Math.min(1, s), 0), 3);
31
+ this.l = _get__("roundFloat")(Math.max(Math.min(1, l), 0), 3);
32
+ this.a = _get__("roundFloat")(Math.max(Math.min(1, a), 0), 3);
33
+ }
34
+ static equals(a, b) {
35
+ return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;
36
+ }
37
+ /**
38
+ * Converts an RGB color value to HSL. Conversion formula
39
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
40
+ * Assumes r, g, and b are contained in the set [0, 255] and
41
+ * returns h in the set [0, 360], s, and l in the set [0, 1].
42
+ */
43
+ static fromRGBA(rgba) {
44
+ const r = rgba.r / 255;
45
+ const g = rgba.g / 255;
46
+ const b = rgba.b / 255;
47
+ const a = rgba.a;
48
+ const max = Math.max(r, g, b);
49
+ const min = Math.min(r, g, b);
50
+ let h = 0;
51
+ let s = 0;
52
+ const l = (min + max) / 2;
53
+ const chroma = max - min;
54
+ if (chroma > 0) {
55
+ s = Math.min(l <= 0.5 ? chroma / (2 * l) : chroma / (2 - 2 * l), 1);
56
+ switch (max) {
57
+ case r:
58
+ h = (g - b) / chroma + (g < b ? 6 : 0);
59
+ break;
60
+ case g:
61
+ h = (b - r) / chroma + 2;
62
+ break;
63
+ case b:
64
+ h = (r - g) / chroma + 4;
65
+ break;
66
+ }
67
+ h *= 60;
68
+ h = Math.round(h);
69
+ }
70
+ return new (_get__("HSLA"))(h, s, l, a);
71
+ }
72
+ static _hue2rgb(p, q, t) {
73
+ if (t < 0) {
74
+ t += 1;
75
+ }
76
+ if (t > 1) {
77
+ t -= 1;
78
+ }
79
+ if (t < 1 / 6) {
80
+ return p + (q - p) * 6 * t;
81
+ }
82
+ if (t < 1 / 2) {
83
+ return q;
84
+ }
85
+ if (t < 2 / 3) {
86
+ return p + (q - p) * (2 / 3 - t) * 6;
87
+ }
88
+ return p;
89
+ }
90
+ /**
91
+ * Converts an HSL color value to RGB. Conversion formula
92
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
93
+ * Assumes h in the set [0, 360] s, and l are contained in the set [0, 1] and
94
+ * returns r, g, and b in the set [0, 255].
95
+ */
96
+ static toRGBA(hsla) {
97
+ const h = hsla.h / 360;
98
+ const {
99
+ s,
100
+ l,
101
+ a
102
+ } = hsla;
103
+ let r, g, b;
104
+ if (s === 0) {
105
+ r = g = b = l; // achromatic
106
+ } else {
107
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
108
+ const p = 2 * l - q;
109
+ r = _get__("HSLA")._hue2rgb(p, q, h + 1 / 3);
110
+ g = _get__("HSLA")._hue2rgb(p, q, h);
111
+ b = _get__("HSLA")._hue2rgb(p, q, h - 1 / 3);
112
+ }
113
+ return new (_get__("RGBA"))(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), a);
114
+ }
115
+ }
116
+ exports.HSLA = _get__("HSLA");
117
+ class HSVA {
118
+ constructor(h, s, v, a) {
119
+ this.h = Math.max(Math.min(360, h), 0) | 0;
120
+ this.s = _get__("roundFloat")(Math.max(Math.min(1, s), 0), 3);
121
+ this.v = _get__("roundFloat")(Math.max(Math.min(1, v), 0), 3);
122
+ this.a = _get__("roundFloat")(Math.max(Math.min(1, a), 0), 3);
123
+ }
124
+ static equals(a, b) {
125
+ return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
126
+ }
127
+ // from http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
128
+ static fromRGBA(rgba) {
129
+ const r = rgba.r / 255;
130
+ const g = rgba.g / 255;
131
+ const b = rgba.b / 255;
132
+ const cmax = Math.max(r, g, b);
133
+ const cmin = Math.min(r, g, b);
134
+ const delta = cmax - cmin;
135
+ const s = cmax === 0 ? 0 : delta / cmax;
136
+ let m;
137
+ if (delta === 0) {
138
+ m = 0;
139
+ } else if (cmax === r) {
140
+ m = ((g - b) / delta % 6 + 6) % 6;
141
+ } else if (cmax === g) {
142
+ m = (b - r) / delta + 2;
143
+ } else {
144
+ m = (r - g) / delta + 4;
145
+ }
146
+ return new (_get__("HSVA"))(Math.round(m * 60), s, cmax, rgba.a);
147
+ }
148
+ // from http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
149
+ static toRGBA(hsva) {
150
+ const {
151
+ h,
152
+ s,
153
+ v,
154
+ a
155
+ } = hsva;
156
+ const c = v * s;
157
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
158
+ const m = v - c;
159
+ let [r, g, b] = [0, 0, 0];
160
+ if (h < 60) {
161
+ r = c;
162
+ g = x;
163
+ } else if (h < 120) {
164
+ r = x;
165
+ g = c;
166
+ } else if (h < 180) {
167
+ g = c;
168
+ b = x;
169
+ } else if (h < 240) {
170
+ g = x;
171
+ b = c;
172
+ } else if (h < 300) {
173
+ r = x;
174
+ b = c;
175
+ } else if (h < 360) {
176
+ r = c;
177
+ b = x;
178
+ }
179
+ r = Math.round((r + m) * 255);
180
+ g = Math.round((g + m) * 255);
181
+ b = Math.round((b + m) * 255);
182
+ return new (_get__("RGBA"))(r, g, b, a);
183
+ }
184
+ }
185
+ exports.HSVA = _get__("HSVA");
186
+ class Color {
187
+ static fromHex(hex) {
188
+ return _get__("Color").Format.CSS.parseHex(hex) || _get__("Color").RED;
189
+ }
190
+ get hsla() {
191
+ if (this._hsla) {
192
+ return this._hsla;
193
+ } else {
194
+ return _get__("HSLA").fromRGBA(this.rgba);
195
+ }
196
+ }
197
+ get hsva() {
198
+ if (this._hsva) {
199
+ return this._hsva;
200
+ }
201
+ return _get__("HSVA").fromRGBA(this.rgba);
202
+ }
203
+ constructor(arg) {
204
+ if (!arg) {
205
+ throw new Error('Color needs a value');
206
+ } else if (arg instanceof _get__("RGBA")) {
207
+ this.rgba = arg;
208
+ } else if (arg instanceof _get__("HSLA")) {
209
+ this._hsla = arg;
210
+ this.rgba = _get__("HSLA").toRGBA(arg);
211
+ } else if (arg instanceof _get__("HSVA")) {
212
+ this._hsva = arg;
213
+ this.rgba = _get__("HSVA").toRGBA(arg);
214
+ } else {
215
+ throw new Error('Invalid color ctor argument');
216
+ }
217
+ }
218
+ equals(other) {
219
+ return !!other && _get__("RGBA").equals(this.rgba, other.rgba) && _get__("HSLA").equals(this.hsla, other.hsla) && _get__("HSVA").equals(this.hsva, other.hsva);
220
+ }
221
+ /**
222
+ * http://www.w3.org/TR/WCAG20/#relativeluminancedef
223
+ * Returns the number in the set [0, 1]. O => Darkest Black. 1 => Lightest white.
224
+ */
225
+ getRelativeLuminance() {
226
+ const R = _get__("Color")._relativeLuminanceForComponent(this.rgba.r);
227
+ const G = _get__("Color")._relativeLuminanceForComponent(this.rgba.g);
228
+ const B = _get__("Color")._relativeLuminanceForComponent(this.rgba.b);
229
+ const luminance = 0.2126 * R + 0.7152 * G + 0.0722 * B;
230
+ return _get__("roundFloat")(luminance, 4);
231
+ }
232
+ static _relativeLuminanceForComponent(color) {
233
+ const c = color / 255;
234
+ return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
235
+ }
236
+ /**
237
+ * http://www.w3.org/TR/WCAG20/#contrast-ratiodef
238
+ * Returns the contrast ration number in the set [1, 21].
239
+ */
240
+ getContrastRatio(another) {
241
+ const lum1 = this.getRelativeLuminance();
242
+ const lum2 = another.getRelativeLuminance();
243
+ return lum1 > lum2 ? (lum1 + 0.05) / (lum2 + 0.05) : (lum2 + 0.05) / (lum1 + 0.05);
244
+ }
245
+ /**
246
+ * http://24ways.org/2010/calculating-color-contrast
247
+ * Return 'true' if darker color otherwise 'false'
248
+ */
249
+ isDarker() {
250
+ const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
251
+ return yiq < 128;
252
+ }
253
+ /**
254
+ * http://24ways.org/2010/calculating-color-contrast
255
+ * Return 'true' if lighter color otherwise 'false'
256
+ */
257
+ isLighter() {
258
+ const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
259
+ return yiq >= 128;
260
+ }
261
+ isLighterThan(another) {
262
+ const lum1 = this.getRelativeLuminance();
263
+ const lum2 = another.getRelativeLuminance();
264
+ return lum1 > lum2;
265
+ }
266
+ isDarkerThan(another) {
267
+ const lum1 = this.getRelativeLuminance();
268
+ const lum2 = another.getRelativeLuminance();
269
+ return lum1 < lum2;
270
+ }
271
+ lighten(factor) {
272
+ return new (_get__("Color"))(new (_get__("HSLA"))(this.hsla.h, this.hsla.s, this.hsla.l + this.hsla.l * factor, this.hsla.a));
273
+ }
274
+ darken(factor) {
275
+ return new (_get__("Color"))(new (_get__("HSLA"))(this.hsla.h, this.hsla.s, this.hsla.l - this.hsla.l * factor, this.hsla.a));
276
+ }
277
+ transparent(factor) {
278
+ const {
279
+ r,
280
+ g,
281
+ b,
282
+ a
283
+ } = this.rgba;
284
+ return new (_get__("Color"))(new (_get__("RGBA"))(r, g, b, a * factor));
285
+ }
286
+ isTransparent() {
287
+ return this.rgba.a === 0;
288
+ }
289
+ isOpaque() {
290
+ return this.rgba.a === 1;
291
+ }
292
+ opposite() {
293
+ return new (_get__("Color"))(new (_get__("RGBA"))(255 - this.rgba.r, 255 - this.rgba.g, 255 - this.rgba.b, this.rgba.a));
294
+ }
295
+ blend(c) {
296
+ const rgba = c.rgba;
297
+ // Convert to 0..1 opacity
298
+ const thisA = this.rgba.a;
299
+ const colorA = rgba.a;
300
+ const a = thisA + colorA * (1 - thisA);
301
+ if (a < 1e-6) {
302
+ return _get__("Color").TRANSPARENT;
303
+ }
304
+ const r = this.rgba.r * thisA / a + rgba.r * colorA * (1 - thisA) / a;
305
+ const g = this.rgba.g * thisA / a + rgba.g * colorA * (1 - thisA) / a;
306
+ const b = this.rgba.b * thisA / a + rgba.b * colorA * (1 - thisA) / a;
307
+ return new (_get__("Color"))(new (_get__("RGBA"))(r, g, b, a));
308
+ }
309
+ flatten(...backgrounds) {
310
+ const background = backgrounds.reduceRight((accumulator, color) => {
311
+ return _get__("Color")._flatten(color, accumulator);
312
+ });
313
+ return _get__("Color")._flatten(this, background);
314
+ }
315
+ static _flatten(foreground, background) {
316
+ const backgroundAlpha = 1 - foreground.rgba.a;
317
+ return new (_get__("Color"))(new (_get__("RGBA"))(backgroundAlpha * background.rgba.r + foreground.rgba.a * foreground.rgba.r, backgroundAlpha * background.rgba.g + foreground.rgba.a * foreground.rgba.g, backgroundAlpha * background.rgba.b + foreground.rgba.a * foreground.rgba.b));
318
+ }
319
+ toString() {
320
+ return '' + _get__("Color").Format.CSS.format(this);
321
+ }
322
+ static getLighterColor(of, relative, factor) {
323
+ if (of.isLighterThan(relative)) {
324
+ return of;
325
+ }
326
+ factor = factor || 0.5;
327
+ const lum1 = of.getRelativeLuminance();
328
+ const lum2 = relative.getRelativeLuminance();
329
+ factor = factor * (lum2 - lum1) / lum2;
330
+ return of.lighten(factor);
331
+ }
332
+ static getDarkerColor(of, relative, factor) {
333
+ if (of.isDarkerThan(relative)) {
334
+ return of;
335
+ }
336
+ factor = factor || 0.5;
337
+ const lum1 = of.getRelativeLuminance();
338
+ const lum2 = relative.getRelativeLuminance();
339
+ factor = factor * (lum1 - lum2) / lum1;
340
+ return of.darken(factor);
341
+ }
342
+ }
343
+ _get__("Color").WHITE = new (_get__("Color"))(new (_get__("RGBA"))(255, 255, 255, 1));
344
+ _get__("Color").BLACK = new (_get__("Color"))(new (_get__("RGBA"))(0, 0, 0, 1));
345
+ _get__("Color").RED = new (_get__("Color"))(new (_get__("RGBA"))(255, 0, 0, 1));
346
+ _get__("Color").BLUE = new (_get__("Color"))(new (_get__("RGBA"))(0, 0, 255, 1));
347
+ _get__("Color").GREEN = new (_get__("Color"))(new (_get__("RGBA"))(0, 255, 0, 1));
348
+ _get__("Color").CYAN = new (_get__("Color"))(new (_get__("RGBA"))(0, 255, 255, 1));
349
+ _get__("Color").LIGHTGREY = new (_get__("Color"))(new (_get__("RGBA"))(211, 211, 211, 1));
350
+ _get__("Color").TRANSPARENT = new (_get__("Color"))(new (_get__("RGBA"))(0, 0, 0, 0));
351
+ exports.Color = _get__("Color");
352
+ (function (Color) {
353
+ let Format;
354
+ (function (Format) {
355
+ let CSS;
356
+ (function (CSS) {
357
+ function formatRGB(color) {
358
+ if (color.rgba.a === 1) {
359
+ return `rgb(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b})`;
360
+ }
361
+ return Color.Format.CSS.formatRGBA(color);
362
+ }
363
+ CSS.formatRGB = formatRGB;
364
+ function formatRGBA(color) {
365
+ return `rgba(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b}, ${+color.rgba.a.toFixed(2)})`;
366
+ }
367
+ CSS.formatRGBA = formatRGBA;
368
+ function formatHSL(color) {
369
+ if (color.hsla.a === 1) {
370
+ return `hsl(${color.hsla.h}, ${(color.hsla.s * 100).toFixed(2)}%, ${(color.hsla.l * 100).toFixed(2)}%)`;
371
+ }
372
+ return Color.Format.CSS.formatHSLA(color);
373
+ }
374
+ CSS.formatHSL = formatHSL;
375
+ function formatHSLA(color) {
376
+ return `hsla(${color.hsla.h}, ${(color.hsla.s * 100).toFixed(2)}%, ${(color.hsla.l * 100).toFixed(2)}%, ${color.hsla.a.toFixed(2)})`;
377
+ }
378
+ CSS.formatHSLA = formatHSLA;
379
+ function _toTwoDigitHex(n) {
380
+ const r = n.toString(16);
381
+ return r.length !== 2 ? '0' + r : r;
382
+ }
383
+ /**
384
+ * Formats the color as #RRGGBB
385
+ */
386
+ function formatHex(color) {
387
+ return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}`;
388
+ }
389
+ CSS.formatHex = formatHex;
390
+ /**
391
+ * Formats the color as #RRGGBBAA
392
+ * If 'compact' is set, colors without transparancy will be printed as #RRGGBB
393
+ */
394
+ function formatHexA(color, compact = false) {
395
+ if (compact && color.rgba.a === 1) {
396
+ return Color.Format.CSS.formatHex(color);
397
+ }
398
+ return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}${_toTwoDigitHex(Math.round(color.rgba.a * 255))}`;
399
+ }
400
+ CSS.formatHexA = formatHexA;
401
+ /**
402
+ * The default format will use HEX if opaque and RGBA otherwise.
403
+ */
404
+ function format(color) {
405
+ if (!color) {
406
+ return null;
407
+ }
408
+ if (color.isOpaque()) {
409
+ return Color.Format.CSS.formatHex(color);
410
+ }
411
+ return Color.Format.CSS.formatRGBA(color);
412
+ }
413
+ CSS.format = format;
414
+ /**
415
+ * Converts an Hex color value to a Color.
416
+ * returns r, g, and b are contained in the set [0, 255]
417
+ * @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA).
418
+ */
419
+ function parseHex(hex) {
420
+ if (!hex) {
421
+ // Invalid color
422
+ return null;
423
+ }
424
+ const length = hex.length;
425
+ if (length === 0) {
426
+ // Invalid color
427
+ return null;
428
+ }
429
+ if (hex.charCodeAt(0) !== 35 /* CharCode.Hash */) {
430
+ // Does not begin with a #
431
+ return null;
432
+ }
433
+ if (length === 7) {
434
+ // #RRGGBB format
435
+ const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
436
+ const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
437
+ const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
438
+ return new Color(new (_get__("RGBA"))(r, g, b, 1));
439
+ }
440
+ if (length === 9) {
441
+ // #RRGGBBAA format
442
+ const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
443
+ const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
444
+ const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
445
+ const a = 16 * _parseHexDigit(hex.charCodeAt(7)) + _parseHexDigit(hex.charCodeAt(8));
446
+ return new Color(new (_get__("RGBA"))(r, g, b, a / 255));
447
+ }
448
+ if (length === 4) {
449
+ // #RGB format
450
+ const r = _parseHexDigit(hex.charCodeAt(1));
451
+ const g = _parseHexDigit(hex.charCodeAt(2));
452
+ const b = _parseHexDigit(hex.charCodeAt(3));
453
+ return new Color(new (_get__("RGBA"))(16 * r + r, 16 * g + g, 16 * b + b));
454
+ }
455
+ if (length === 5) {
456
+ // #RGBA format
457
+ const r = _parseHexDigit(hex.charCodeAt(1));
458
+ const g = _parseHexDigit(hex.charCodeAt(2));
459
+ const b = _parseHexDigit(hex.charCodeAt(3));
460
+ const a = _parseHexDigit(hex.charCodeAt(4));
461
+ return new Color(new (_get__("RGBA"))(16 * r + r, 16 * g + g, 16 * b + b, (16 * a + a) / 255));
462
+ }
463
+ // Invalid color
464
+ return null;
465
+ }
466
+ CSS.parseHex = parseHex;
467
+ function _parseHexDigit(charCode) {
468
+ switch (charCode) {
469
+ case 48 /* CharCode.Digit0 */:
470
+ return 0;
471
+ case 49 /* CharCode.Digit1 */:
472
+ return 1;
473
+ case 50 /* CharCode.Digit2 */:
474
+ return 2;
475
+ case 51 /* CharCode.Digit3 */:
476
+ return 3;
477
+ case 52 /* CharCode.Digit4 */:
478
+ return 4;
479
+ case 53 /* CharCode.Digit5 */:
480
+ return 5;
481
+ case 54 /* CharCode.Digit6 */:
482
+ return 6;
483
+ case 55 /* CharCode.Digit7 */:
484
+ return 7;
485
+ case 56 /* CharCode.Digit8 */:
486
+ return 8;
487
+ case 57 /* CharCode.Digit9 */:
488
+ return 9;
489
+ case 97 /* CharCode.a */:
490
+ return 10;
491
+ case 65 /* CharCode.A */:
492
+ return 10;
493
+ case 98 /* CharCode.b */:
494
+ return 11;
495
+ case 66 /* CharCode.B */:
496
+ return 11;
497
+ case 99 /* CharCode.c */:
498
+ return 12;
499
+ case 67 /* CharCode.C */:
500
+ return 12;
501
+ case 100 /* CharCode.d */:
502
+ return 13;
503
+ case 68 /* CharCode.D */:
504
+ return 13;
505
+ case 101 /* CharCode.e */:
506
+ return 14;
507
+ case 69 /* CharCode.E */:
508
+ return 14;
509
+ case 102 /* CharCode.f */:
510
+ return 15;
511
+ case 70 /* CharCode.F */:
512
+ return 15;
513
+ }
514
+ return 0;
515
+ }
516
+ })(CSS = Format.CSS || (Format.CSS = {}));
517
+ })(Format = Color.Format || (Color.Format = {}));
518
+ })(_assign__("Color", exports.Color || (exports.Color = {})));
519
+ exports.Color = _get__("Color");
520
+ function _getGlobalObject() {
521
+ try {
522
+ if (!!global) {
523
+ return global;
524
+ }
525
+ } catch (e) {
526
+ try {
527
+ if (!!window) {
528
+ return window;
529
+ }
530
+ } catch (e) {
531
+ return this;
532
+ }
533
+ }
534
+ }
535
+ ;
536
+ var _RewireModuleId__ = null;
537
+ function _getRewireModuleId__() {
538
+ if (_RewireModuleId__ === null) {
539
+ let globalVariable = _getGlobalObject();
540
+ if (!globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__) {
541
+ globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__ = 0;
542
+ }
543
+ _RewireModuleId__ = __$$GLOBAL_REWIRE_NEXT_MODULE_ID__++;
544
+ }
545
+ return _RewireModuleId__;
546
+ }
547
+ function _getRewireRegistry__() {
548
+ let theGlobalVariable = _getGlobalObject();
549
+ if (!theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__) {
550
+ theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);
551
+ }
552
+ return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__;
553
+ }
554
+ function _getRewiredData__() {
555
+ let moduleId = _getRewireModuleId__();
556
+ let registry = _getRewireRegistry__();
557
+ let rewireData = registry[moduleId];
558
+ if (!rewireData) {
559
+ registry[moduleId] = Object.create(null);
560
+ rewireData = registry[moduleId];
561
+ }
562
+ return rewireData;
563
+ }
564
+ (function registerResetAll() {
565
+ let theGlobalVariable = _getGlobalObject();
566
+ if (!theGlobalVariable['__rewire_reset_all__']) {
567
+ theGlobalVariable['__rewire_reset_all__'] = function () {
568
+ theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);
569
+ };
570
+ }
571
+ })();
572
+ var INTENTIONAL_UNDEFINED = '__INTENTIONAL_UNDEFINED__';
573
+ let _RewireAPI__ = {};
574
+ (function () {
575
+ function addPropertyToAPIObject(name, value) {
576
+ Object.defineProperty(_RewireAPI__, name, {
577
+ value: value,
578
+ enumerable: false,
579
+ configurable: true
580
+ });
581
+ }
582
+ addPropertyToAPIObject('__get__', _get__);
583
+ addPropertyToAPIObject('__GetDependency__', _get__);
584
+ addPropertyToAPIObject('__Rewire__', _set__);
585
+ addPropertyToAPIObject('__set__', _set__);
586
+ addPropertyToAPIObject('__reset__', _reset__);
587
+ addPropertyToAPIObject('__ResetDependency__', _reset__);
588
+ addPropertyToAPIObject('__with__', _with__);
589
+ })();
590
+ function _get__(variableName) {
591
+ let rewireData = _getRewiredData__();
592
+ if (rewireData[variableName] === undefined) {
593
+ return _get_original__(variableName);
594
+ } else {
595
+ var value = rewireData[variableName];
596
+ if (value === INTENTIONAL_UNDEFINED) {
597
+ return undefined;
598
+ } else {
599
+ return value;
600
+ }
601
+ }
602
+ }
603
+ function _get_original__(variableName) {
604
+ switch (variableName) {
605
+ case "roundFloat":
606
+ return roundFloat;
607
+ case "RGBA":
608
+ return RGBA;
609
+ case "HSLA":
610
+ return HSLA;
611
+ case "HSVA":
612
+ return HSVA;
613
+ case "Color":
614
+ return Color;
615
+ }
616
+ return undefined;
617
+ }
618
+ function _assign__(variableName, value) {
619
+ let rewireData = _getRewiredData__();
620
+ if (rewireData[variableName] === undefined) {
621
+ return _set_original__(variableName, value);
622
+ } else {
623
+ return rewireData[variableName] = value;
624
+ }
625
+ }
626
+ function _set_original__(variableName, _value) {
627
+ switch (variableName) {
628
+ case "Color":
629
+ return Color = _value;
630
+ }
631
+ return undefined;
632
+ }
633
+ function _update_operation__(operation, variableName, prefix) {
634
+ var oldValue = _get__(variableName);
635
+ var newValue = operation === '++' ? oldValue + 1 : oldValue - 1;
636
+ _assign__(variableName, newValue);
637
+ return prefix ? newValue : oldValue;
638
+ }
639
+ function _set__(variableName, value) {
640
+ let rewireData = _getRewiredData__();
641
+ if (typeof variableName === 'object') {
642
+ Object.keys(variableName).forEach(function (name) {
643
+ rewireData[name] = variableName[name];
644
+ });
645
+ return function () {
646
+ Object.keys(variableName).forEach(function (name) {
647
+ _reset__(variableName);
648
+ });
649
+ };
650
+ } else {
651
+ if (value === undefined) {
652
+ rewireData[variableName] = INTENTIONAL_UNDEFINED;
653
+ } else {
654
+ rewireData[variableName] = value;
655
+ }
656
+ return function () {
657
+ _reset__(variableName);
658
+ };
659
+ }
660
+ }
661
+ function _reset__(variableName) {
662
+ let rewireData = _getRewiredData__();
663
+ delete rewireData[variableName];
664
+ if (Object.keys(rewireData).length == 0) {
665
+ delete _getRewireRegistry__()[_getRewireModuleId__];
666
+ }
667
+ ;
668
+ }
669
+ function _with__(object) {
670
+ let rewireData = _getRewiredData__();
671
+ var rewiredVariableNames = Object.keys(object);
672
+ var previousValues = {};
673
+ function reset() {
674
+ rewiredVariableNames.forEach(function (variableName) {
675
+ rewireData[variableName] = previousValues[variableName];
676
+ });
677
+ }
678
+ return function (callback) {
679
+ rewiredVariableNames.forEach(function (variableName) {
680
+ previousValues[variableName] = rewireData[variableName];
681
+ rewireData[variableName] = object[variableName];
682
+ });
683
+ let result = callback();
684
+ if (!!result && typeof result.then == 'function') {
685
+ result.then(reset).catch(reset);
686
+ } else {
687
+ reset();
688
+ }
689
+ return result;
690
+ };
691
+ }
692
+ let _typeOfOriginalExport = typeof module.exports;
693
+ function addNonEnumerableProperty(name, value) {
694
+ Object.defineProperty(module.exports, name, {
695
+ value: value,
696
+ enumerable: false,
697
+ configurable: true
698
+ });
699
+ }
700
+ if ((_typeOfOriginalExport === 'object' || _typeOfOriginalExport === 'function') && Object.isExtensible(module.exports)) {
701
+ addNonEnumerableProperty('__get__', _get__);
702
+ addNonEnumerableProperty('__GetDependency__', _get__);
703
+ addNonEnumerableProperty('__Rewire__', _set__);
704
+ addNonEnumerableProperty('__set__', _set__);
705
+ addNonEnumerableProperty('__reset__', _reset__);
706
+ addNonEnumerableProperty('__ResetDependency__', _reset__);
707
+ addNonEnumerableProperty('__with__', _with__);
708
+ addNonEnumerableProperty('__RewireAPI__', _RewireAPI__);
709
+ }
@@ -0,0 +1,6 @@
1
+ export declare function memoize(_target: any, key: string, descriptor: any): void;
2
+ export interface IDebounceReducer<T> {
3
+ (previousValue: T, ...args: any[]): T;
4
+ }
5
+ export declare function debounce<T>(delay: number, reducer?: IDebounceReducer<T>, initialValueProvider?: () => T): Function;
6
+ export declare function throttle<T>(delay: number, reducer?: IDebounceReducer<T>, initialValueProvider?: () => T): Function;