dev-classes 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/Color.d.ts +26 -22
- package/dist/classes/Color.js +6 -6
- package/dist/classes/Delay.d.ts +7 -6
- package/package.json +1 -1
package/dist/classes/Color.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type ColorRgb = [number, number, number];
|
|
2
|
+
export interface ColorProps {
|
|
3
|
+
ColorRgb: ColorRgb;
|
|
4
|
+
ColorRgba: [...ColorRgb, number];
|
|
5
|
+
ColorHsla: Record<"h" | "s" | "l" | "a", number>;
|
|
6
|
+
TypeBrightness_OR: "BT601" | "BT709" | "BT2020";
|
|
7
|
+
}
|
|
5
8
|
export declare class Color {
|
|
6
9
|
private static componentToHex;
|
|
7
10
|
static getNumberRGB: (getComputedStyleRGB: string) => number[] | RegExpMatchArray;
|
|
@@ -19,11 +22,11 @@ export declare class Color {
|
|
|
19
22
|
* @param v [0, 1]
|
|
20
23
|
* @returns r, g, b in [0, 255]
|
|
21
24
|
*/
|
|
22
|
-
static hsvToRgb(h: number, s: number, v: number): ColorRgb;
|
|
25
|
+
static hsvToRgb(h: number, s: number, v: number): ColorProps['ColorRgb'];
|
|
23
26
|
/**
|
|
24
27
|
* @returns h [0, 360], s [0, 100], l [0, 100], a [0, 1]
|
|
25
28
|
*/
|
|
26
|
-
static rgbaToHsla(r: number, g: number, b: number, a?: number): ColorHsla;
|
|
29
|
+
static rgbaToHsla(r: number, g: number, b: number, a?: number): ColorProps['ColorHsla'];
|
|
27
30
|
/**
|
|
28
31
|
* Converts an HSL color value to RGB. Conversion formula
|
|
29
32
|
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
@@ -33,31 +36,32 @@ export declare class Color {
|
|
|
33
36
|
* @param {number} l The lightness [0, 1]
|
|
34
37
|
* @return {Array} The RGB representation [0, 255]
|
|
35
38
|
*/
|
|
36
|
-
static hslaToRgba(h: number, s: number, l: number, a: number): ColorRgba;
|
|
37
|
-
static hslaStringToRgba(hsla: string):
|
|
38
|
-
static hexaToRgba(hexa: string):
|
|
39
|
+
static hslaToRgba(h: number, s: number, l: number, a: number): ColorProps['ColorRgba'];
|
|
40
|
+
static hslaStringToRgba(hsla: string): [number, number, number, number];
|
|
41
|
+
static hexaToRgba(hexa: string): [number, number, number, number];
|
|
39
42
|
static hexToRgb(hex: string): ColorRgb;
|
|
40
|
-
static hexaToHsla(hexa: string):
|
|
41
|
-
static rgbaToHexa(rgba: ColorRgba | ColorRgb): string;
|
|
43
|
+
static hexaToHsla(hexa: string): Record<"h" | "s" | "l" | "a", number>;
|
|
44
|
+
static rgbaToHexa(rgba: ColorProps['ColorRgba'] | ColorProps['ColorRgb']): string;
|
|
42
45
|
static hslaStringToHexa(hsla: string): string;
|
|
43
46
|
static hslaStringToHex(hsla: string): string;
|
|
44
47
|
/**
|
|
45
48
|
* @param weight [0, 1]
|
|
46
49
|
*/
|
|
47
|
-
static mixColors(color1: ColorRgb, color2: ColorRgb, weight: number): ColorRgb;
|
|
48
|
-
static getRgbByTypeBrightness(type: TypeBrightness_OR): number[];
|
|
49
|
-
static computePerceivedBrightness(color: ColorRgb, type?: TypeBrightness_OR): number;
|
|
50
|
-
static getAverageColor(color1: ColorRgb, color2: ColorRgb): ColorRgb;
|
|
51
|
-
static getAccentColor(baseHsv: number[], baseColor: ColorRgb, elementColor: ColorRgb): ColorRgb;
|
|
52
|
-
static changeColorAccent(baseHsv: number[], accentHsv: number[], color: ColorRgb, isDarkTheme: boolean): ColorRgb;
|
|
53
|
-
static changeBrightness(color: ColorRgb, amount: number): ColorRgb;
|
|
54
|
-
static hexBrightness(hex: string, amount: number
|
|
50
|
+
static mixColors(color1: ColorProps['ColorRgb'], color2: ColorProps['ColorRgb'], weight: number): ColorRgb;
|
|
51
|
+
static getRgbByTypeBrightness(type: ColorProps['TypeBrightness_OR']): number[];
|
|
52
|
+
static computePerceivedBrightness(color: ColorProps['ColorRgb'], type?: ColorProps['TypeBrightness_OR']): number;
|
|
53
|
+
static getAverageColor(color1: ColorProps['ColorRgb'], color2: ColorProps['ColorRgb']): ColorProps['ColorRgb'];
|
|
54
|
+
static getAccentColor(baseHsv: number[], baseColor: ColorProps['ColorRgb'], elementColor: ColorProps['ColorRgb']): ColorProps['ColorRgb'];
|
|
55
|
+
static changeColorAccent(baseHsv: number[], accentHsv: number[], color: ColorProps['ColorRgb'], isDarkTheme: boolean): ColorRgb;
|
|
56
|
+
static changeBrightness(color: ColorProps['ColorRgb'], amount: number): ColorRgb;
|
|
57
|
+
static hexBrightness(hex: string, amount: number): string;
|
|
55
58
|
static getHexColorFromTelegramColor(color: number): string;
|
|
56
59
|
static getRgbColorFromTelegramColor(color: number): ColorRgb;
|
|
57
60
|
static getColorsFromWallPaper(wallPaper: any): string;
|
|
58
|
-
static rgbaToRgb(rgba: ColorRgba, bg: ColorRgb): ColorRgb;
|
|
59
|
-
static calculateLuminance(rgb: ColorRgb, type?: TypeBrightness_OR): number;
|
|
60
|
-
static getTextColor(luminance: number): ColorRgb;
|
|
61
|
+
static rgbaToRgb(rgba: ColorProps['ColorRgba'], bg: ColorProps['ColorRgb']): ColorProps['ColorRgb'];
|
|
62
|
+
static calculateLuminance(rgb: ColorProps['ColorRgb'], type?: ColorProps['TypeBrightness_OR']): number;
|
|
63
|
+
static getTextColor(luminance: number): ColorProps['ColorRgb'];
|
|
61
64
|
static calculateOpacity(luminance: number, targetContrast: number): number;
|
|
62
65
|
static clamp(v: number, min: number, max: number): number;
|
|
63
66
|
}
|
|
67
|
+
export {};
|
package/dist/classes/Color.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (l, t, n) => (
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var b = (l, t, n) => t in l ? M(l, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : l[t] = n;
|
|
3
|
+
var p = (l, t, n) => (b(l, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
4
|
const o = class o {
|
|
5
5
|
/**
|
|
6
6
|
* https://stackoverflow.com/a/54070620/6758968
|
|
@@ -159,9 +159,9 @@ const o = class o {
|
|
|
159
159
|
static changeBrightness(t, n) {
|
|
160
160
|
return t.map((e) => o.clamp(Math.round(e * n), 0, 255));
|
|
161
161
|
}
|
|
162
|
-
static hexBrightness(t, n
|
|
163
|
-
const
|
|
164
|
-
return o.rgbToHex(
|
|
162
|
+
static hexBrightness(t, n) {
|
|
163
|
+
const e = o.hexToRgb(t), r = o.changeBrightness(e, n), [s, a, i] = r;
|
|
164
|
+
return o.rgbToHex(s, a, i);
|
|
165
165
|
}
|
|
166
166
|
static getHexColorFromTelegramColor(t) {
|
|
167
167
|
const n = (t < 0 ? 16777215 + t : t).toString(16);
|
package/dist/classes/Delay.d.ts
CHANGED
|
@@ -8,13 +8,14 @@ interface StartActionEveryConfigI {
|
|
|
8
8
|
getIsActiveEvent(): boolean;
|
|
9
9
|
}): void;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}>;
|
|
11
|
+
export interface DelaysPromiseProps {
|
|
12
|
+
startActionEvery: (cb: () => boolean, config: StartActionEveryConfigI) => Promise<{
|
|
13
|
+
status: boolean;
|
|
14
|
+
msg: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
16
17
|
export declare class DelaysPromise {
|
|
17
|
-
startActionEvery:
|
|
18
|
+
startActionEvery: DelaysPromiseProps['startActionEvery'];
|
|
18
19
|
oneOf: (promiseWatch: any, potentialCaseCB: any, { second }: {
|
|
19
20
|
second: any;
|
|
20
21
|
}) => void;
|