tiny-essentials 1.18.1 → 1.19.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 (74) hide show
  1. package/README.md +17 -3
  2. package/dist/node_modules/firebase-functions/lib/common/trace.cjs +0 -1
  3. package/dist/node_modules/firebase-functions/lib/logger/index.cjs +1 -0
  4. package/dist/v1/ColorSafeStringify.min.js +1 -1
  5. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  6. package/dist/v1/TinyBasicsEs.js +13 -6
  7. package/dist/v1/TinyBasicsEs.min.js +1 -1
  8. package/dist/v1/TinyClipboard.min.js +1 -1
  9. package/dist/v1/TinyColorConverter.js +617 -0
  10. package/dist/v1/TinyColorConverter.min.js +1 -0
  11. package/dist/v1/TinyDomReadyManager.min.js +1 -1
  12. package/dist/v1/TinyDragger.min.js +1 -1
  13. package/dist/v1/TinyEssentials.js +2635 -482
  14. package/dist/v1/TinyEssentials.min.js +1 -1
  15. package/dist/v1/TinyEvents.js +402 -0
  16. package/dist/v1/TinyEvents.min.js +1 -0
  17. package/dist/v1/TinyHtml.min.js +1 -1
  18. package/dist/v1/TinyLocalStorage.js +1292 -0
  19. package/dist/v1/TinyLocalStorage.min.js +1 -0
  20. package/dist/v1/TinyNotifications.min.js +1 -1
  21. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  22. package/dist/v1/TinyPromiseQueue.min.js +1 -1
  23. package/dist/v1/TinyRateLimiter.js +2 -1
  24. package/dist/v1/TinyRateLimiter.min.js +1 -1
  25. package/dist/v1/TinySmartScroller.js +570 -52
  26. package/dist/v1/TinySmartScroller.min.js +1 -1
  27. package/dist/v1/TinyTextRangeEditor.min.js +1 -1
  28. package/dist/v1/TinyTimeout.js +233 -0
  29. package/dist/v1/TinyTimeout.min.js +1 -0
  30. package/dist/v1/TinyToastNotify.min.js +1 -1
  31. package/dist/v1/TinyUploadClicker.js +1457 -106
  32. package/dist/v1/TinyUploadClicker.min.js +1 -1
  33. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  34. package/dist/v1/basics/html.cjs +13 -6
  35. package/dist/v1/basics/html.d.mts +12 -4
  36. package/dist/v1/basics/html.mjs +13 -6
  37. package/dist/v1/build/TinyColorConverter.cjs +7 -0
  38. package/dist/v1/build/TinyColorConverter.d.mts +3 -0
  39. package/dist/v1/build/TinyColorConverter.mjs +2 -0
  40. package/dist/v1/build/TinyEvents.cjs +7 -0
  41. package/dist/v1/build/TinyEvents.d.mts +3 -0
  42. package/dist/v1/build/TinyEvents.mjs +2 -0
  43. package/dist/v1/build/TinyLocalStorage.cjs +7 -0
  44. package/dist/v1/build/TinyLocalStorage.d.mts +3 -0
  45. package/dist/v1/build/TinyLocalStorage.mjs +2 -0
  46. package/dist/v1/build/TinyTimeout.cjs +7 -0
  47. package/dist/v1/build/TinyTimeout.d.mts +3 -0
  48. package/dist/v1/build/TinyTimeout.mjs +2 -0
  49. package/dist/v1/index.cjs +8 -0
  50. package/dist/v1/index.d.mts +5 -1
  51. package/dist/v1/index.mjs +5 -1
  52. package/dist/v1/libs/TinyColorConverter.cjs +578 -0
  53. package/dist/v1/libs/TinyColorConverter.d.mts +396 -0
  54. package/dist/v1/libs/TinyColorConverter.mjs +520 -0
  55. package/dist/v1/libs/TinyEvents.cjs +363 -0
  56. package/dist/v1/libs/TinyEvents.d.mts +160 -0
  57. package/dist/v1/libs/TinyEvents.mjs +328 -0
  58. package/dist/v1/libs/TinyLocalStorage.cjs +847 -0
  59. package/dist/v1/libs/TinyLocalStorage.d.mts +407 -0
  60. package/dist/v1/libs/TinyLocalStorage.mjs +740 -0
  61. package/dist/v1/libs/TinySmartScroller.cjs +207 -52
  62. package/dist/v1/libs/TinySmartScroller.d.mts +164 -16
  63. package/dist/v1/libs/TinySmartScroller.mjs +181 -52
  64. package/dist/v1/libs/TinyTimeout.cjs +194 -0
  65. package/dist/v1/libs/TinyTimeout.d.mts +89 -0
  66. package/dist/v1/libs/TinyTimeout.mjs +179 -0
  67. package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
  68. package/docs/v1/README.md +4 -0
  69. package/docs/v1/libs/TinyColorConverter.md +220 -0
  70. package/docs/v1/libs/TinyEvents.md +199 -0
  71. package/docs/v1/libs/TinyLocalStorage.md +350 -0
  72. package/docs/v1/libs/TinyRateLimiter.md +0 -3
  73. package/docs/v1/libs/TinyTimeout.md +190 -0
  74. package/package.json +28 -5
@@ -0,0 +1,617 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ (() => {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __webpack_require__.d = (exports, definition) => {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ (() => {
21
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
+ /******/ })();
23
+ /******/
24
+ /************************************************************************/
25
+ var __webpack_exports__ = {};
26
+
27
+ // EXPORTS
28
+ __webpack_require__.d(__webpack_exports__, {
29
+ TinyColorConverter: () => (/* reexport */ libs_TinyColorConverter)
30
+ });
31
+
32
+ ;// ./src/v1/libs/TinyColorConverter.mjs
33
+ /**
34
+ * Represents a color in RGBA format.
35
+ * Each element must be a number between 0 and 255.
36
+ * The fourth value represents the alpha (transparency) channel.
37
+ *
38
+ * @typedef {number[]} RgbaColor
39
+ * @property {number} 0 - Red component (0–255)
40
+ * @property {number} 1 - Green component (0–255)
41
+ * @property {number} 2 - Blue component (0–255)
42
+ * @property {number} 3 - Alpha component (0–255)
43
+ */
44
+
45
+ /**
46
+ * Represents a color in RGB format.
47
+ * Each element must be a number between 0 and 255.
48
+ *
49
+ * @typedef {number[]} RgbColor
50
+ * @property {number} 0 - Red component (0–255)
51
+ * @property {number} 1 - Green component (0–255)
52
+ * @property {number} 2 - Blue component (0–255)
53
+ */
54
+
55
+ /**
56
+ * Represents a color in HSLA format.
57
+ * The fourth value represents the alpha (transparency) channel.
58
+ *
59
+ * @typedef {number[]} HslaColor
60
+ * @property {number} 0 - Hue (0–360)
61
+ * @property {number} 1 - Saturation (0–100)
62
+ * @property {number} 2 - Lightness (0–100)
63
+ * @property {number} 3 - Alpha component (0–255)
64
+ */
65
+
66
+ /**
67
+ * Represents a color in HSL format.
68
+ *
69
+ * @typedef {number[]} HslColor
70
+ * @property {number} 0 - Hue (0–360)
71
+ * @property {number} 1 - Saturation (0–100)
72
+ * @property {number} 2 - Lightness (0–100)
73
+ */
74
+
75
+ /**
76
+ * Represents a hex color.
77
+ *
78
+ * @typedef {string} HexColor
79
+ */
80
+
81
+ /**
82
+ * A union type representing various accepted color formats.
83
+ * Can be a hex color string, a numeric value, or an array-based RGB/RGBA representation.
84
+ *
85
+ * @typedef {HexColor | number | RgbColor | RgbaColor} ColorTypes
86
+ */
87
+
88
+ /**
89
+ * @typedef {Object} RgbaResult
90
+ * @property {number} r - Red component (0–255)
91
+ * @property {number} g - Green component (0–255)
92
+ * @property {number} b - Blue component (0–255)
93
+ * @property {number} a - Alpha component (0–255)
94
+ */
95
+
96
+ /**
97
+ * @typedef {Object} RgbResult
98
+ * @property {number} r - Red component (0–255)
99
+ * @property {number} g - Green component (0–255)
100
+ * @property {number} b - Blue component (0–255)
101
+ */
102
+
103
+ /**
104
+ * @typedef {Object} HexResult
105
+ * @property {string} hex - Hex color
106
+ */
107
+
108
+ /**
109
+ * @typedef {Object} HslResult
110
+ * @property {number} h - Hue (0–360)
111
+ * @property {number} s - Saturation (0–100)
112
+ * @property {number} l - Lightness (0–100)
113
+ */
114
+
115
+ /**
116
+ * A class that allows converting colors between all common formats.
117
+ */
118
+ class TinyColorConverter {
119
+ /**
120
+ * Generates a smooth gradient of colors based on sine wave patterns.
121
+ *
122
+ * @see {@link https://www.npmjs.com/package/rainbow-colors-array} Code Reference
123
+ * @param {number} [len=24] - The number of colors to generate.
124
+ * @param {'rgb'|'hex'|'hsl'} [type='rgb'] - The format of the colors returned: `'rgb'`, `'hex'`, or `'hsl'`.
125
+ * @param {boolean} [pastel=false] - If true, generates pastel tones by adjusting the intensity and offset.
126
+ * @returns {Array<RgbResult|HexResult|HslResult>} An array of color values in the selected format:
127
+ */
128
+ static _rca(len, type, pastel) {
129
+ let eq1 = 127;
130
+ let eq2 = 128;
131
+ if (len === undefined) {
132
+ len = 24;
133
+ }
134
+ if (type === undefined) {
135
+ type = 'rgb';
136
+ }
137
+ if (pastel === true) {
138
+ eq1 = 55;
139
+ eq2 = 200;
140
+ }
141
+ const frequency = (Math.PI * 2) / len;
142
+
143
+ const cvparr = [];
144
+ for (let i = 0; i < len; ++i) {
145
+ const red = Math.sin(frequency * i + 2) * eq1 + eq2;
146
+ const green = Math.sin(frequency * i + 0) * eq1 + eq2;
147
+ const blue = Math.sin(frequency * i + 4) * eq1 + eq2;
148
+
149
+ switch (type) {
150
+ case 'hex':
151
+ cvparr.push({ hex: this.rgbToHex(Math.round(red), Math.round(green), Math.round(blue)) });
152
+ break;
153
+ case 'rgb':
154
+ cvparr.push({ r: red, g: green, b: blue });
155
+ break;
156
+ case 'hsl':
157
+ const [h, s, l] = this.rgbaToHsl(Math.round(red), Math.round(green), Math.round(blue));
158
+ cvparr.push({ h, s, l });
159
+ break;
160
+ }
161
+ }
162
+
163
+ return cvparr;
164
+ }
165
+
166
+ /**
167
+ * Generates a smooth gradient of colors based on sine wave patterns.
168
+ *
169
+ * @param {number} [len=24] - The number of colors to generate.
170
+ * @param {boolean} [pastel=false] - If true, generates pastel tones by adjusting the intensity and offset.
171
+ * @returns {RgbResult[]} An array of rgb color values.
172
+ */
173
+ static rcaRgb(len, pastel) {
174
+ return /** @type {RgbResult[]} */ (TinyColorConverter._rca(len, 'rgb', pastel));
175
+ }
176
+
177
+ /**
178
+ * Generates a smooth gradient of colors based on sine wave patterns.
179
+ *
180
+ * @param {number} [len=24] - The number of colors to generate.
181
+ * @param {boolean} [pastel=false] - If true, generates pastel tones by adjusting the intensity and offset.
182
+ * @returns {HslResult[]} An array of hsl color values.
183
+ */
184
+ static rcaHsl(len, pastel) {
185
+ return /** @type {HslResult[]} */ (TinyColorConverter._rca(len, 'hsl', pastel));
186
+ }
187
+
188
+ /**
189
+ * Generates a smooth gradient of colors based on sine wave patterns.
190
+ *
191
+ * @param {number} [len=24] - The number of colors to generate.
192
+ * @param {boolean} [pastel=false] - If true, generates pastel tones by adjusting the intensity and offset.
193
+ * @returns {HexResult[]} An array of hex color values.
194
+ */
195
+ static rcaHex(len, pastel) {
196
+ return /** @type {HexResult[]} */ (TinyColorConverter._rca(len, 'hex', pastel));
197
+ }
198
+
199
+ /**
200
+ * Generates a random color in hexadecimal format.
201
+ *
202
+ * @returns {HexColor} A hex color string (e.g. `#a3e5f2`).
203
+ */
204
+ static randomColor() {
205
+ const hex = Math.floor(Math.random() * 0x1000000).toString(16);
206
+ return `#${hex.padStart(6, '0')}`;
207
+ }
208
+
209
+ /**
210
+ * Parses input into RGBA array.
211
+ * @param {ColorTypes} input
212
+ * @param {boolean} isHsl
213
+ * @returns {RgbaColor}
214
+ */
215
+ static parseInput(input, isHsl) {
216
+ if (typeof input === 'string') {
217
+ input = input.trim().toLowerCase();
218
+ if (input.startsWith('#')) return this.hexToRgba(input);
219
+ if (input.startsWith('rgb')) return this.rgbStringToRgbaArray(input);
220
+ if (input.startsWith('hsl')) return this.hslStringToRgbaArray(input);
221
+ }
222
+ if (typeof input === 'number') return this.intToRgba(input);
223
+ if (
224
+ Array.isArray(input) &&
225
+ (input.length === 3 || input.length === 4) &&
226
+ input.every((item) => typeof item === 'number')
227
+ ) {
228
+ if (isHsl) {
229
+ const [h, s, l, a2] = input;
230
+ if (h <= 360 && s <= 100 && l <= 100) return this.hslToRgba(h, s, l, a2);
231
+ }
232
+ return [...input, 1].slice(0, 4);
233
+ }
234
+
235
+ throw new Error('Unsupported color format.');
236
+ }
237
+
238
+ // HSL Color
239
+
240
+ /**
241
+ * Converts hsl to integer.
242
+ * @param {number} h - Hue (0–360)
243
+ * @param {number} s - Saturation (0–100)
244
+ * @param {number} l - Lightness (0–100)
245
+ * @returns {number}
246
+ */
247
+ static hslToInt(h, s, l) {
248
+ const [r, g, b] = TinyColorConverter.hslToRgba(h, s, l);
249
+ return TinyColorConverter.rgbToInt(r, g, b);
250
+ }
251
+
252
+ /**
253
+ * Converts hsl to hex.
254
+ * @param {number} h - Hue (0–360)
255
+ * @param {number} s - Saturation (0–100)
256
+ * @param {number} l - Lightness (0–100)
257
+ * @returns {HexColor}
258
+ */
259
+ static hslToHex(h, s, l) {
260
+ const [r, g, b] = TinyColorConverter.hslToRgba(h, s, l);
261
+ return TinyColorConverter.rgbToHex(r, g, b);
262
+ }
263
+
264
+ /**
265
+ * Converts hsl(a) string to RGBA array.
266
+ * @param {string} hsl
267
+ * @returns {RgbaColor}
268
+ */
269
+ static hslStringToRgbaArray(hsl) {
270
+ const match = hsl.match(/[\d.]+/g)?.map(Number);
271
+ if (!match || match.length < 3) return [0, 0, 0, 1];
272
+ const [h, s, l, a = 1] = match;
273
+ return this.hslToRgba(h, s, l, a);
274
+ }
275
+
276
+ /**
277
+ * Converts HSL or HSLA to RGBA.
278
+ * @param {number} h - Hue (0–360)
279
+ * @param {number} s - Saturation (0–100)
280
+ * @param {number} l - Lightness (0–100)
281
+ * @param {number} [a=1] - Alpha (0–1)
282
+ * @returns {RgbaColor}
283
+ */
284
+ static hslToRgba(h, s, l, a = 1) {
285
+ s /= 100;
286
+ l /= 100;
287
+ /** @type {(n: number) => number} */
288
+ const k = (n) => (n + h / 30) % 12;
289
+ const a_ = s * Math.min(l, 1 - l);
290
+ /** @type {(n: number) => number} */
291
+ const f = (n) => l - a_ * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
292
+ return [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255), a];
293
+ }
294
+
295
+ /**
296
+ * Converts HSL or HSLA to RGB.
297
+ * @param {number} h - Hue (0–360)
298
+ * @param {number} s - Saturation (0–100)
299
+ * @param {number} l - Lightness (0–100)
300
+ * @param {number} [a=1] - Alpha (0–1)
301
+ * @returns {RgbColor}
302
+ */
303
+ static hslToRgb(h, s, l, a = 1) {
304
+ return TinyColorConverter.hslToRgba(h, s, l, a).slice(0, 3);
305
+ }
306
+
307
+ // Hex Color
308
+
309
+ /**
310
+ * Converts hex to integer.
311
+ * @param {HexColor} hex
312
+ * @returns {number}
313
+ */
314
+ static hexToInt(hex) {
315
+ return parseInt(hex.replace(/^#/, ''), 16);
316
+ }
317
+
318
+ /**
319
+ * Converts hex string to HSL array.
320
+ * @param {HexColor} hex
321
+ * @returns {HslColor}
322
+ */
323
+ static hexToHsl(hex) {
324
+ const [r, g, b, a] = TinyColorConverter.hexToRgba(hex);
325
+ return TinyColorConverter.rgbaToHsl(r, g, b, a);
326
+ }
327
+
328
+ /**
329
+ * Converts hex string to HSL array.
330
+ * @param {HexColor} hex
331
+ * @returns {HslaColor}
332
+ */
333
+ static hexToHsla(hex) {
334
+ const [r, g, b, a] = TinyColorConverter.hexToRgba(hex);
335
+ return TinyColorConverter.rgbaToHsla(r, g, b, a);
336
+ }
337
+
338
+ /**
339
+ * Converts hex string to RGBA array.
340
+ * @param {HexColor} hex
341
+ * @returns {RgbaColor}
342
+ */
343
+ static hexToRgba(hex) {
344
+ hex = hex.replace(/^#/, '');
345
+ if (hex.length === 3)
346
+ hex = hex
347
+ .split('')
348
+ .map((c) => c + c)
349
+ .join('');
350
+ const intVal = parseInt(hex, 16);
351
+ const r = (intVal >> 16) & 255;
352
+ const g = (intVal >> 8) & 255;
353
+ const b = intVal & 255;
354
+ return [r, g, b, 1];
355
+ }
356
+
357
+ /**
358
+ * Converts HEX to RGB.
359
+ * @param {HexColor} hex
360
+ * @returns {RgbColor}
361
+ */
362
+ static hexToRgb(hex) {
363
+ return this.hexToRgba(hex).slice(0, 3);
364
+ }
365
+
366
+ // RGBA Color
367
+
368
+ /**
369
+ * Converts RGB to HEX.
370
+ * @param {number} r
371
+ * @param {number} g
372
+ * @param {number} b
373
+ * @returns {HexColor}
374
+ */
375
+ static rgbToHex(r, g, b) {
376
+ return '#' + [r, g, b].map((v) => v.toString(16).padStart(2, '0')).join('');
377
+ }
378
+
379
+ /**
380
+ * Converts RGB to integer.
381
+ * @param {number} r
382
+ * @param {number} g
383
+ * @param {number} b
384
+ * @returns {number}
385
+ */
386
+ static rgbToInt(r, g, b) {
387
+ return (r << 16) | (g << 8) | b;
388
+ }
389
+
390
+ /**
391
+ * Converts RGBA to HSLA.
392
+ * @param {number} r
393
+ * @param {number} g
394
+ * @param {number} b
395
+ * @param {number} [a=1]
396
+ * @returns {HslaColor}
397
+ */
398
+ static rgbaToHsla(r, g, b, a = 1) {
399
+ r /= 255;
400
+ g /= 255;
401
+ b /= 255;
402
+ const max = Math.max(r, g, b);
403
+ const min = Math.min(r, g, b);
404
+ let h = 0,
405
+ s = 0,
406
+ l = (max + min) / 2;
407
+ const d = max - min;
408
+
409
+ if (d !== 0) {
410
+ s = d / (1 - Math.abs(2 * l - 1));
411
+ switch (max) {
412
+ case r:
413
+ h = (g - b) / d + (g < b ? 6 : 0);
414
+ break;
415
+ case g:
416
+ h = (b - r) / d + 2;
417
+ break;
418
+ case b:
419
+ h = (r - g) / d + 4;
420
+ break;
421
+ }
422
+ h *= 60;
423
+ }
424
+
425
+ return [Math.round(h), Math.round(s * 100), Math.round(l * 100), a];
426
+ }
427
+
428
+ /**
429
+ * Converts RGBA to HSL.
430
+ * @param {number} r
431
+ * @param {number} g
432
+ * @param {number} b
433
+ * @param {number} [a=1]
434
+ * @returns {HslColor}
435
+ */
436
+ static rgbaToHsl(r, g, b, a) {
437
+ return this.rgbaToHsla(r, g, b, a).slice(0, 3);
438
+ }
439
+
440
+ /**
441
+ * Converts rgb(a) string to RGBA array.
442
+ * @param {string} rgb
443
+ * @returns {RgbaColor}
444
+ */
445
+ static rgbStringToRgbaArray(rgb) {
446
+ const match = rgb.match(/[\d.]+/g)?.map(Number);
447
+ if (!match) return [];
448
+ return [...match, 1].slice(0, 4);
449
+ }
450
+
451
+ // Integer Color
452
+
453
+ /**
454
+ * Converts integer color to HSL.
455
+ * @param {number} int
456
+ * @returns {HslColor}
457
+ */
458
+ static intToHsl(int) {
459
+ const [r, g, b, a] = TinyColorConverter.intToRgba(int);
460
+ return TinyColorConverter.rgbaToHsl(r, g, b, a);
461
+ }
462
+
463
+ /**
464
+ * Converts integer color to HSL.
465
+ * @param {number} int
466
+ * @returns {HslaColor}
467
+ */
468
+ static intToHsla(int) {
469
+ const [r, g, b, a] = TinyColorConverter.intToRgba(int);
470
+ return TinyColorConverter.rgbaToHsla(r, g, b, a);
471
+ }
472
+
473
+ /**
474
+ * Converts integer color to hex.
475
+ * @param {number} int
476
+ * @returns {HexColor}
477
+ */
478
+ static intToHex(int) {
479
+ return '#' + int.toString(16).padStart(6, '0');
480
+ }
481
+
482
+ /**
483
+ * Converts an integer (0xRRGGBB) to RGBA.
484
+ * @param {number} value
485
+ * @returns {RgbaColor}
486
+ */
487
+ static intToRgba(value) {
488
+ const r = (value >> 16) & 255;
489
+ const g = (value >> 8) & 255;
490
+ const b = value & 255;
491
+ return [r, g, b, 1];
492
+ }
493
+
494
+ // Class Script
495
+
496
+ /** @type {ColorTypes} */
497
+ #original = '#000000';
498
+ /** @type {RgbaColor} */
499
+ #rgba = [0, 0, 0, 0];
500
+
501
+ #checkIsHsl;
502
+
503
+ /**
504
+ * @param {ColorTypes|null} [input=null] - Any valid color (hex, rgb string, rgba string, hsl(a), css name, array or int).
505
+ * @param {boolean} [checkIsHsl=false]
506
+ */
507
+ constructor(input = null, checkIsHsl = false) {
508
+ this.#checkIsHsl = checkIsHsl;
509
+ if (typeof input !== 'undefined' && input !== null) this.setColor(input);
510
+ }
511
+
512
+ /**
513
+ * @param {ColorTypes} input - Any valid color (hex, rgb string, rgba string, hsl(a), css name, array or int).
514
+ */
515
+ setColor(input) {
516
+ this.#original = input;
517
+ const isHsl =
518
+ this.#checkIsHsl &&
519
+ Array.isArray(input) &&
520
+ input[0] <= 360 &&
521
+ input[1] <= 100 &&
522
+ input[2] <= 100;
523
+ this.#rgba = TinyColorConverter.parseInput(input, isHsl);
524
+ }
525
+
526
+ /**
527
+ * Returns HSLA array.
528
+ * @returns {HslaColor}
529
+ */
530
+ toHslaArray() {
531
+ const [r, g, b, a] = this.#rgba;
532
+ return TinyColorConverter.rgbaToHsla(r, g, b, a);
533
+ }
534
+
535
+ /**
536
+ * Returns RGB string.
537
+ * @returns {string}
538
+ */
539
+ toHslString() {
540
+ const [r, g, b] = this.#rgba;
541
+ const [h, s, l] = TinyColorConverter.rgbaToHsl(r, g, b);
542
+ return `hsl(${h}, ${s}%, ${l}%)`;
543
+ }
544
+
545
+ /**
546
+ * Returns RGBA string.
547
+ * @returns {string}
548
+ */
549
+ toHslaString() {
550
+ const [r, g, b, a] = this.#rgba;
551
+ const [h, s, l, a2] = TinyColorConverter.rgbaToHsla(r, g, b, a);
552
+ return `hsla(${h}, ${s}%, ${l}%, ${a2 ?? 1})`;
553
+ }
554
+
555
+ /**
556
+ * Returns RGBA array.
557
+ * @returns {RgbaColor}
558
+ */
559
+ toRgbaArray() {
560
+ return [...this.#rgba];
561
+ }
562
+
563
+ /**
564
+ * Returns RGB string.
565
+ * @returns {string}
566
+ */
567
+ toRgbString() {
568
+ const [r, g, b] = this.#rgba;
569
+ return `rgb(${r}, ${g}, ${b})`;
570
+ }
571
+
572
+ /**
573
+ * Returns RGBA string.
574
+ * @returns {string}
575
+ */
576
+ toRgbaString() {
577
+ const [r, g, b, a] = this.#rgba;
578
+ return `rgba(${r}, ${g}, ${b}, ${a ?? 1})`;
579
+ }
580
+
581
+ /**
582
+ * Returns hex color.
583
+ * @returns {HexColor}
584
+ */
585
+ toHex() {
586
+ const [r, g, b] = this.#rgba;
587
+ return TinyColorConverter.rgbToHex(r, g, b);
588
+ }
589
+
590
+ /**
591
+ * Returns color as integer.
592
+ * @returns {number}
593
+ */
594
+ toInt() {
595
+ const [r, g, b] = this.#rgba;
596
+ return TinyColorConverter.rgbToInt(r, g, b);
597
+ }
598
+
599
+ /**
600
+ * Returns the original input.
601
+ * @returns {ColorTypes}
602
+ */
603
+ getOriginal() {
604
+ return this.#original;
605
+ }
606
+ }
607
+
608
+ /* harmony default export */ const libs_TinyColorConverter = (TinyColorConverter);
609
+
610
+ ;// ./src/v1/build/TinyColorConverter.mjs
611
+
612
+
613
+
614
+
615
+ window.TinyColorConverter = __webpack_exports__.TinyColorConverter;
616
+ /******/ })()
617
+ ;
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var t={d:(r,a)=>{for(var s in a)t.o(a,s)&&!t.o(r,s)&&Object.defineProperty(r,s,{enumerable:!0,get:a[s]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r)},r={};t.d(r,{TinyColorConverter:()=>s});class a{static _rca(t,r,a){let s=127,o=128;void 0===t&&(t=24),void 0===r&&(r="rgb"),!0===a&&(s=55,o=200);const n=2*Math.PI/t,e=[];for(let a=0;a<t;++a){const t=Math.sin(n*a+2)*s+o,i=Math.sin(n*a+0)*s+o,h=Math.sin(n*a+4)*s+o;switch(r){case"hex":e.push({hex:this.rgbToHex(Math.round(t),Math.round(i),Math.round(h))});break;case"rgb":e.push({r:t,g:i,b:h});break;case"hsl":const[r,a,s]=this.rgbaToHsl(Math.round(t),Math.round(i),Math.round(h));e.push({h:r,s:a,l:s})}}return e}static rcaRgb(t,r){return a._rca(t,"rgb",r)}static rcaHsl(t,r){return a._rca(t,"hsl",r)}static rcaHex(t,r){return a._rca(t,"hex",r)}static randomColor(){return`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`}static parseInput(t,r){if("string"==typeof t){if((t=t.trim().toLowerCase()).startsWith("#"))return this.hexToRgba(t);if(t.startsWith("rgb"))return this.rgbStringToRgbaArray(t);if(t.startsWith("hsl"))return this.hslStringToRgbaArray(t)}if("number"==typeof t)return this.intToRgba(t);if(Array.isArray(t)&&(3===t.length||4===t.length)&&t.every(t=>"number"==typeof t)){if(r){const[r,a,s,o]=t;if(r<=360&&a<=100&&s<=100)return this.hslToRgba(r,a,s,o)}return[...t,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(t,r,s){const[o,n,e]=a.hslToRgba(t,r,s);return a.rgbToInt(o,n,e)}static hslToHex(t,r,s){const[o,n,e]=a.hslToRgba(t,r,s);return a.rgbToHex(o,n,e)}static hslStringToRgbaArray(t){const r=t.match(/[\d.]+/g)?.map(Number);if(!r||r.length<3)return[0,0,0,1];const[a,s,o,n=1]=r;return this.hslToRgba(a,s,o,n)}static hslToRgba(t,r,a,s=1){a/=100;const o=r=>(r+t/30)%12,n=(r/=100)*Math.min(a,1-a),e=t=>a-n*Math.max(-1,Math.min(o(t)-3,Math.min(9-o(t),1)));return[Math.round(255*e(0)),Math.round(255*e(8)),Math.round(255*e(4)),s]}static hslToRgb(t,r,s,o=1){return a.hslToRgba(t,r,s,o).slice(0,3)}static hexToInt(t){return parseInt(t.replace(/^#/,""),16)}static hexToHsl(t){const[r,s,o,n]=a.hexToRgba(t);return a.rgbaToHsl(r,s,o,n)}static hexToHsla(t){const[r,s,o,n]=a.hexToRgba(t);return a.rgbaToHsla(r,s,o,n)}static hexToRgba(t){3===(t=t.replace(/^#/,"")).length&&(t=t.split("").map(t=>t+t).join(""));const r=parseInt(t,16);return[r>>16&255,r>>8&255,255&r,1]}static hexToRgb(t){return this.hexToRgba(t).slice(0,3)}static rgbToHex(t,r,a){return"#"+[t,r,a].map(t=>t.toString(16).padStart(2,"0")).join("")}static rgbToInt(t,r,a){return t<<16|r<<8|a}static rgbaToHsla(t,r,a,s=1){t/=255,r/=255,a/=255;const o=Math.max(t,r,a),n=Math.min(t,r,a);let e=0,i=0,h=(o+n)/2;const c=o-n;if(0!==c){switch(i=c/(1-Math.abs(2*h-1)),o){case t:e=(r-a)/c+(r<a?6:0);break;case r:e=(a-t)/c+2;break;case a:e=(t-r)/c+4}e*=60}return[Math.round(e),Math.round(100*i),Math.round(100*h),s]}static rgbaToHsl(t,r,a,s){return this.rgbaToHsla(t,r,a,s).slice(0,3)}static rgbStringToRgbaArray(t){const r=t.match(/[\d.]+/g)?.map(Number);return r?[...r,1].slice(0,4):[]}static intToHsl(t){const[r,s,o,n]=a.intToRgba(t);return a.rgbaToHsl(r,s,o,n)}static intToHsla(t){const[r,s,o,n]=a.intToRgba(t);return a.rgbaToHsla(r,s,o,n)}static intToHex(t){return"#"+t.toString(16).padStart(6,"0")}static intToRgba(t){return[t>>16&255,t>>8&255,255&t,1]}#t="#000000";#r=[0,0,0,0];#a;constructor(t=null,r=!1){this.#a=r,null!=t&&this.setColor(t)}setColor(t){this.#t=t;const r=this.#a&&Array.isArray(t)&&t[0]<=360&&t[1]<=100&&t[2]<=100;this.#r=a.parseInput(t,r)}toHslaArray(){const[t,r,s,o]=this.#r;return a.rgbaToHsla(t,r,s,o)}toHslString(){const[t,r,s]=this.#r,[o,n,e]=a.rgbaToHsl(t,r,s);return`hsl(${o}, ${n}%, ${e}%)`}toHslaString(){const[t,r,s,o]=this.#r,[n,e,i,h]=a.rgbaToHsla(t,r,s,o);return`hsla(${n}, ${e}%, ${i}%, ${h??1})`}toRgbaArray(){return[...this.#r]}toRgbString(){const[t,r,a]=this.#r;return`rgb(${t}, ${r}, ${a})`}toRgbaString(){const[t,r,a,s]=this.#r;return`rgba(${t}, ${r}, ${a}, ${s??1})`}toHex(){const[t,r,s]=this.#r;return a.rgbToHex(t,r,s)}toInt(){const[t,r,s]=this.#r;return a.rgbToInt(t,r,s)}getOriginal(){return this.#t}}const s=a;window.TinyColorConverter=r.TinyColorConverter})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={d:(r,i)=>{for(var a in i)e.o(i,a)&&!e.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:i[a]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},r={};e.d(r,{TinyDomReadyManager:()=>i});const i=class{#e=[];#r=!1;#i=!1;#a=[];#n(){this.#r&&Promise.all(this.#a).then((()=>{this.#i=!0,this.#o(!1)})).catch((e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)}))}#o(e){this.#e.filter((r=>r.domOnly===e)).sort(((e,r)=>r.priority-e.priority)).forEach((e=>this.#t(e))),this.#e=this.#e.filter((r=>!(r.once&&(!e||r.domOnly))))}#t(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#r=!0,this.#o(!0),this.#n()}init(){if(this.#r)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",(()=>this._markDomReady()))}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#i||(this.#a.push(e),this.#r&&this.#n())}onReady(e,{once:r=!0,priority:i=0,filter:a=null,domOnly:n=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const o={fn:e,once:r,priority:i,filter:a,domOnly:n};if(n&&this.#r)return this.#t(o),void(r||this.#e.push(o));!n&&this.#i?this.#t(o):this.#e.push(o)}isReady(){return this.#i}isDomReady(){return this.#r}};window.TinyDomReadyManager=r.TinyDomReadyManager})();
1
+ (()=>{"use strict";var e={d:(r,i)=>{for(var a in i)e.o(i,a)&&!e.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:i[a]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},r={};e.d(r,{TinyDomReadyManager:()=>i});const i=class{#e=[];#r=!1;#i=!1;#a=[];#n(){this.#r&&Promise.all(this.#a).then(()=>{this.#i=!0,this.#o(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#o(e){this.#e.filter(r=>r.domOnly===e).sort((e,r)=>r.priority-e.priority).forEach(e=>this.#t(e)),this.#e=this.#e.filter(r=>!(r.once&&(!e||r.domOnly)))}#t(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#r=!0,this.#o(!0),this.#n()}init(){if(this.#r)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",()=>this._markDomReady())}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#i||(this.#a.push(e),this.#r&&this.#n())}onReady(e,{once:r=!0,priority:i=0,filter:a=null,domOnly:n=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const o={fn:e,once:r,priority:i,filter:a,domOnly:n};if(n&&this.#r)return this.#t(o),void(r||this.#e.push(o));!n&&this.#i?this.#t(o):this.#e.push(o)}isReady(){return this.#i}isDomReady(){return this.#r}};window.TinyDomReadyManager=r.TinyDomReadyManager})();