dev-classes 1.4.30 → 1.4.32
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/README.md +2 -1
- package/dist/classes/Color/Color.d.ts +27 -26
- package/dist/classes/Color/Color.types.d.ts +2 -1
- package/dist/index.js +35 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,13 +67,14 @@ interface ColorProps{
|
|
|
67
67
|
clamp(v: number, min: number, max: number): number;
|
|
68
68
|
isHex(color:string):boolean;
|
|
69
69
|
isBrightAndVivid: (color: string) => boolean;
|
|
70
|
+
increaseSaturation: (color: string | number[], factor?: number) => string | number[];
|
|
70
71
|
generate: {
|
|
71
72
|
rgb: () => number[];
|
|
72
73
|
hex: () => string;
|
|
73
74
|
hexMultiple: () => string[];
|
|
74
75
|
pastelColor: () => string;
|
|
75
76
|
neonColor: () => string;
|
|
76
|
-
brightColor: () => string;
|
|
77
|
+
brightColor: (factor?: number) => string;
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ColorProps } from './Color.types';
|
|
2
2
|
export declare class Color {
|
|
3
3
|
private static componentToHex;
|
|
4
|
-
static rgbToHex: ColorProps[
|
|
4
|
+
static rgbToHex: ColorProps["rgbToHex"];
|
|
5
5
|
/**
|
|
6
6
|
* https://stackoverflow.com/a/54070620/6758968
|
|
7
7
|
* r, g, b in [0, 255]
|
|
8
8
|
* @returns h in [0,360) and s, v in [0,1]
|
|
9
9
|
*/
|
|
10
|
-
static rgbToHsv: ColorProps[
|
|
10
|
+
static rgbToHsv: ColorProps["rgbToHsv"];
|
|
11
11
|
/**
|
|
12
12
|
* https://stackoverflow.com/a/54024653/6758968
|
|
13
13
|
* @param h [0, 360]
|
|
@@ -15,11 +15,11 @@ export declare class Color {
|
|
|
15
15
|
* @param v [0, 1]
|
|
16
16
|
* @returns r, g, b in [0, 255]
|
|
17
17
|
*/
|
|
18
|
-
static hsvToRgb: ColorProps[
|
|
18
|
+
static hsvToRgb: ColorProps["hsvToRgb"];
|
|
19
19
|
/**
|
|
20
20
|
* @returns h [0, 360], s [0, 100], l [0, 100], a [0, 1]
|
|
21
21
|
*/
|
|
22
|
-
static rgbaToHsla: ColorProps[
|
|
22
|
+
static rgbaToHsla: ColorProps["rgbaToHsla"];
|
|
23
23
|
private static rgbToHsl;
|
|
24
24
|
/**
|
|
25
25
|
* Converts an HSL color value to RGB. Conversion formula
|
|
@@ -30,35 +30,36 @@ export declare class Color {
|
|
|
30
30
|
* @param {number} l The lightness [0, 1]
|
|
31
31
|
* @return {Array} The RGB representation [0, 255]
|
|
32
32
|
*/
|
|
33
|
-
static hslaToRgba: ColorProps[
|
|
34
|
-
static hslaStringToRgba: ColorProps[
|
|
35
|
-
static hexaToRgba: ColorProps[
|
|
36
|
-
static hexaToHsla: ColorProps[
|
|
37
|
-
static hexToRgb: ColorProps[
|
|
38
|
-
static rgbaToHexa: ColorProps[
|
|
39
|
-
static hslaStringToHexa: ColorProps[
|
|
40
|
-
static hslaStringToHex: ColorProps[
|
|
33
|
+
static hslaToRgba: ColorProps["hslaToRgba"];
|
|
34
|
+
static hslaStringToRgba: ColorProps["hslaStringToRgba"];
|
|
35
|
+
static hexaToRgba: ColorProps["hexaToRgba"];
|
|
36
|
+
static hexaToHsla: ColorProps["hexaToHsla"];
|
|
37
|
+
static hexToRgb: ColorProps["hexToRgb"];
|
|
38
|
+
static rgbaToHexa: ColorProps["rgbaToHexa"];
|
|
39
|
+
static hslaStringToHexa: ColorProps["hslaStringToHexa"];
|
|
40
|
+
static hslaStringToHex: ColorProps["hslaStringToHex"];
|
|
41
41
|
/**
|
|
42
42
|
* @param weight [0, 1]
|
|
43
43
|
*/
|
|
44
|
-
static mixColors: ColorProps[
|
|
45
|
-
static getRgbByTypeBrightness: ColorProps[
|
|
46
|
-
static getAverageColor: ColorProps[
|
|
47
|
-
static getAccentColor: ColorProps[
|
|
48
|
-
static changeColorAccent: ColorProps[
|
|
49
|
-
static changeBrightness: ColorProps[
|
|
50
|
-
static hexBrightness: ColorProps[
|
|
51
|
-
static getHexColorFromTelegramColor: ColorProps[
|
|
52
|
-
static getRgbColorFromTelegramColor: ColorProps[
|
|
53
|
-
static rgbaToRgb: ColorProps[
|
|
54
|
-
static calculateBrightness: ColorProps[
|
|
55
|
-
static getTextColor: ColorProps[
|
|
44
|
+
static mixColors: ColorProps["mixColors"];
|
|
45
|
+
static getRgbByTypeBrightness: ColorProps["getRgbByTypeBrightness"];
|
|
46
|
+
static getAverageColor: ColorProps["getAverageColor"];
|
|
47
|
+
static getAccentColor: ColorProps["getAccentColor"];
|
|
48
|
+
static changeColorAccent: ColorProps["changeColorAccent"];
|
|
49
|
+
static changeBrightness: ColorProps["changeBrightness"];
|
|
50
|
+
static hexBrightness: ColorProps["hexBrightness"];
|
|
51
|
+
static getHexColorFromTelegramColor: ColorProps["getHexColorFromTelegramColor"];
|
|
52
|
+
static getRgbColorFromTelegramColor: ColorProps["getRgbColorFromTelegramColor"];
|
|
53
|
+
static rgbaToRgb: ColorProps["rgbaToRgb"];
|
|
54
|
+
static calculateBrightness: ColorProps["calculateBrightness"];
|
|
55
|
+
static getTextColor: ColorProps["getTextColor"];
|
|
56
56
|
private static readonly MIN_BRIGHTNESS;
|
|
57
57
|
private static readonly MIN_SATURATION;
|
|
58
58
|
private static readonly MIN_LIGHTNESS;
|
|
59
59
|
static isBrightAndVivid(color: string): boolean;
|
|
60
|
-
static calculateOpacity: ColorProps[
|
|
61
|
-
static
|
|
60
|
+
static calculateOpacity: ColorProps["calculateOpacity"];
|
|
61
|
+
static increaseSaturation: ColorProps["increaseSaturation"];
|
|
62
|
+
static clamp: ColorProps["clamp"];
|
|
62
63
|
static isHex: (color: string) => boolean;
|
|
63
64
|
private static generateHex;
|
|
64
65
|
private static generateHexMultiple;
|
|
@@ -32,6 +32,7 @@ export interface ColorProps {
|
|
|
32
32
|
calculateBrightness(rgb: Color_P["ColorRgb"], type?: Color_P["TypeBrightness_OR"]): number;
|
|
33
33
|
getTextColor(luminance: number): Color_P["ColorRgb"];
|
|
34
34
|
calculateOpacity(luminance: number, targetContrast: number): number;
|
|
35
|
+
increaseSaturation: (color: string | number[], factor?: number) => string | number[];
|
|
35
36
|
clamp(v: number, min: number, max: number): number;
|
|
36
37
|
isBrightAndVivid: (color: string) => boolean;
|
|
37
38
|
generate: {
|
|
@@ -40,6 +41,6 @@ export interface ColorProps {
|
|
|
40
41
|
hexMultiple: () => string[];
|
|
41
42
|
pastelColor: () => string;
|
|
42
43
|
neonColor: () => string;
|
|
43
|
-
brightColor: () => string;
|
|
44
|
+
brightColor: (factor?: number) => string;
|
|
44
45
|
};
|
|
45
46
|
}
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,6 @@ const m = class m {
|
|
|
25
25
|
return { h: i, s: a, l: u };
|
|
26
26
|
}
|
|
27
27
|
static isBrightAndVivid(e) {
|
|
28
|
-
debugger;
|
|
29
28
|
const [t, s, n] = this.hexToRgb(e), o = this.rgbToHsl(t, s, n);
|
|
30
29
|
return o.l >= this.MIN_LIGHTNESS && o.s >= this.MIN_SATURATION;
|
|
31
30
|
}
|
|
@@ -51,14 +50,14 @@ const m = class m {
|
|
|
51
50
|
static generateRGB() {
|
|
52
51
|
return Array.from({ length: 3 }, () => Math.floor(Math.random() * 128 + 128));
|
|
53
52
|
}
|
|
54
|
-
static brightColor() {
|
|
55
|
-
let
|
|
53
|
+
static brightColor(e = 1.3) {
|
|
54
|
+
let t = 0, s;
|
|
56
55
|
do {
|
|
57
|
-
const [
|
|
58
|
-
if (
|
|
56
|
+
const [n, o, i] = m.generateRGB();
|
|
57
|
+
if (s = `#${n.toString(16).padStart(2, "0")}${o.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`, s = m.increaseSaturation(s, e), t++, t > 100)
|
|
59
58
|
break;
|
|
60
|
-
} while (!m.isBrightAndVivid(
|
|
61
|
-
return
|
|
59
|
+
} while (!m.isBrightAndVivid(s));
|
|
60
|
+
return s;
|
|
62
61
|
}
|
|
63
62
|
};
|
|
64
63
|
/*Проверить свои методы и возможно исключить т.к. функционал возможно повторяется */
|
|
@@ -224,6 +223,14 @@ c(m, "rgbaToRgb", (e, t) => {
|
|
|
224
223
|
}), c(m, "getTextColor", (e) => e > 0.5 ? [0, 0, 0] : [255, 255, 255]), c(m, "MIN_BRIGHTNESS", 0.6), c(m, "MIN_SATURATION", 0.5), c(m, "MIN_LIGHTNESS", 0.4), c(m, "calculateOpacity", (e, t) => {
|
|
225
224
|
const s = e > 0.5 ? 0 : 1, n = (e - s + t) / t;
|
|
226
225
|
return +Math.max(0.5, Math.min(0.64, n)).toFixed(2);
|
|
226
|
+
}), c(m, "increaseSaturation", (e, t = 1.3) => {
|
|
227
|
+
if (typeof e == "string") {
|
|
228
|
+
const s = m.hexToRgb(e), [n, o, i] = m.rgbToHsv(...s), a = Math.min(1, o * t), u = m.hsvToRgb(n, a, i);
|
|
229
|
+
return m.rgbToHex(...u);
|
|
230
|
+
} else {
|
|
231
|
+
const [s, n, o] = m.rgbToHsv(e[0], e[1], e[2]), i = Math.min(1, n * t);
|
|
232
|
+
return m.hsvToRgb(s, i, o);
|
|
233
|
+
}
|
|
227
234
|
}), c(m, "clamp", (e, t, s) => Math.min(s, Math.max(t, e))), c(m, "isHex", (e) => {
|
|
228
235
|
if (typeof e != "string")
|
|
229
236
|
return !1;
|
|
@@ -801,10 +808,10 @@ function toFormData(r, e, t) {
|
|
|
801
808
|
if (utils$1.endsWith(g, "{}"))
|
|
802
809
|
g = s ? g : g.slice(0, -2), d = JSON.stringify(d);
|
|
803
810
|
else if (utils$1.isArray(d) && isFlatArray(d) || (utils$1.isFileList(d) || utils$1.endsWith(g, "[]")) && (D = utils$1.toArray(d)))
|
|
804
|
-
return g = removeBrackets(g), D.forEach(function(S,
|
|
811
|
+
return g = removeBrackets(g), D.forEach(function(S, O) {
|
|
805
812
|
!(utils$1.isUndefined(S) || S === null) && e.append(
|
|
806
813
|
// eslint-disable-next-line no-nested-ternary
|
|
807
|
-
i === !0 ? renderKey([g],
|
|
814
|
+
i === !0 ? renderKey([g], O, o) : i === null ? g : g + "[]",
|
|
808
815
|
l(S)
|
|
809
816
|
);
|
|
810
817
|
}), !1;
|
|
@@ -1540,16 +1547,16 @@ const resolveConfig = (r) => {
|
|
|
1540
1547
|
}, p.onerror = function() {
|
|
1541
1548
|
s(new AxiosError("Network Error", AxiosError.ERR_NETWORK, r, p)), p = null;
|
|
1542
1549
|
}, p.ontimeout = function() {
|
|
1543
|
-
let
|
|
1550
|
+
let O = n.timeout ? "timeout of " + n.timeout + "ms exceeded" : "timeout exceeded";
|
|
1544
1551
|
const x = n.transitional || transitionalDefaults;
|
|
1545
|
-
n.timeoutErrorMessage && (
|
|
1546
|
-
|
|
1552
|
+
n.timeoutErrorMessage && (O = n.timeoutErrorMessage), s(new AxiosError(
|
|
1553
|
+
O,
|
|
1547
1554
|
x.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
1548
1555
|
r,
|
|
1549
1556
|
p
|
|
1550
1557
|
)), p = null;
|
|
1551
|
-
}, o === void 0 && i.setContentType(null), "setRequestHeader" in p && utils$1.forEach(i.toJSON(), function(
|
|
1552
|
-
p.setRequestHeader(x,
|
|
1558
|
+
}, o === void 0 && i.setContentType(null), "setRequestHeader" in p && utils$1.forEach(i.toJSON(), function(O, x) {
|
|
1559
|
+
p.setRequestHeader(x, O);
|
|
1553
1560
|
}), utils$1.isUndefined(n.withCredentials) || (p.withCredentials = !!n.withCredentials), a && a !== "json" && (p.responseType = n.responseType), l && ([b, d] = progressEventReducer(l, !0), p.addEventListener("progress", b)), u && p.upload && ([h, w] = progressEventReducer(u), p.upload.addEventListener("progress", h), p.upload.addEventListener("loadend", w)), (n.cancelToken || n.signal) && (f = (S) => {
|
|
1554
1561
|
p && (s(!S || S.type ? new CanceledError(null, r, p) : S), p.abort(), p = null);
|
|
1555
1562
|
}, n.cancelToken && n.cancelToken.subscribe(f), n.signal && (n.signal.aborted ? f() : n.signal.addEventListener("abort", f)));
|
|
@@ -1710,8 +1717,8 @@ const getBodyLength = async (r) => {
|
|
|
1710
1717
|
method: "POST",
|
|
1711
1718
|
body: s,
|
|
1712
1719
|
duplex: "half"
|
|
1713
|
-
}),
|
|
1714
|
-
if (utils$1.isFormData(s) && (
|
|
1720
|
+
}), T;
|
|
1721
|
+
if (utils$1.isFormData(s) && (T = x.headers.get("content-type")) && f.setContentType(T), x.body) {
|
|
1715
1722
|
const [C, N] = progressEventDecorator(
|
|
1716
1723
|
p,
|
|
1717
1724
|
progressEventReducer(asyncDecorator(u))
|
|
@@ -1737,8 +1744,8 @@ const getBodyLength = async (r) => {
|
|
|
1737
1744
|
["status", "statusText", "headers"].forEach((k) => {
|
|
1738
1745
|
x[k] = A[k];
|
|
1739
1746
|
});
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1747
|
+
const T = utils$1.toFiniteNumber(A.headers.get("content-length")), [C, N] = a && progressEventDecorator(
|
|
1748
|
+
T,
|
|
1742
1749
|
progressEventReducer(asyncDecorator(a), !0)
|
|
1743
1750
|
) || [];
|
|
1744
1751
|
A = new Response(
|
|
@@ -1749,10 +1756,10 @@ const getBodyLength = async (r) => {
|
|
|
1749
1756
|
);
|
|
1750
1757
|
}
|
|
1751
1758
|
l = l || "text";
|
|
1752
|
-
let
|
|
1753
|
-
return !S && g && g(), await new Promise((x,
|
|
1754
|
-
settle(x,
|
|
1755
|
-
data:
|
|
1759
|
+
let O = await resolvers[utils$1.findKey(resolvers, l) || "text"](A, r);
|
|
1760
|
+
return !S && g && g(), await new Promise((x, T) => {
|
|
1761
|
+
settle(x, T, {
|
|
1762
|
+
data: O,
|
|
1756
1763
|
headers: AxiosHeaders$1.from(A.headers),
|
|
1757
1764
|
status: A.status,
|
|
1758
1765
|
statusText: A.statusText,
|
|
@@ -2396,17 +2403,17 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2396
2403
|
o = { ...o, statusCode: p, data: D, res: d }, p === 200 && g && (E.saveToken(g), o.data = { ...o.data, token: g }), s(o);
|
|
2397
2404
|
},
|
|
2398
2405
|
(d) => {
|
|
2399
|
-
const g = E.errorsHandler.handleError(d), { url: p, status: D, headers: A, error: S, ...
|
|
2406
|
+
const g = E.errorsHandler.handleError(d), { url: p, status: D, headers: A, error: S, ...O } = d, x = typeof S == "string" ? Utils.isJSON(S.trim()) : !1, T = {
|
|
2400
2407
|
headers: A,
|
|
2401
2408
|
status: D,
|
|
2402
2409
|
message: ""
|
|
2403
2410
|
};
|
|
2404
2411
|
if (x) {
|
|
2405
2412
|
const C = JSON.parse(S.trim()), N = E.errorsHandler.getErrorMessageFromData(D, C);
|
|
2406
|
-
|
|
2413
|
+
T.message = N, T.data = C, g.msg = E.errorsHandler.gerErrorByStatusCordovaHttp(D, p);
|
|
2407
2414
|
} else
|
|
2408
|
-
typeof S == "string" && (
|
|
2409
|
-
n({ ...f, ...g, errExt:
|
|
2415
|
+
typeof S == "string" && (T.message = S);
|
|
2416
|
+
n({ ...f, ...g, errExt: T });
|
|
2410
2417
|
}
|
|
2411
2418
|
);
|
|
2412
2419
|
} else
|
|
@@ -2415,7 +2422,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2415
2422
|
const d = w.status, g = w == null ? void 0 : w.data;
|
|
2416
2423
|
o = { ...o, statusCode: d, data: g, res: w }, s(o);
|
|
2417
2424
|
}).catch((w) => {
|
|
2418
|
-
const d = E.errorsHandler.handleError(w), { code: g, config: p, status: D, message: A, response: S, stack:
|
|
2425
|
+
const d = E.errorsHandler.handleError(w), { code: g, config: p, status: D, message: A, response: S, stack: O } = w, x = {
|
|
2419
2426
|
code: g,
|
|
2420
2427
|
config: p,
|
|
2421
2428
|
status: D || u,
|
|
@@ -2423,7 +2430,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2423
2430
|
headers: S == null ? void 0 : S.headers,
|
|
2424
2431
|
statusText: S == null ? void 0 : S.statusText,
|
|
2425
2432
|
data: S == null ? void 0 : S.data,
|
|
2426
|
-
stack:
|
|
2433
|
+
stack: O
|
|
2427
2434
|
};
|
|
2428
2435
|
n({ ...f, ...d, errExt: x });
|
|
2429
2436
|
});
|