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