dev-classes 1.4.31 → 1.4.33
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 +89 -81
- 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
|
@@ -29,7 +29,7 @@ const m = class m {
|
|
|
29
29
|
return o.l >= this.MIN_LIGHTNESS && o.s >= this.MIN_SATURATION;
|
|
30
30
|
}
|
|
31
31
|
static generatePastel() {
|
|
32
|
-
const [e, t, s] =
|
|
32
|
+
const [e, t, s] = m.generateRGB(), n = Math.floor((e + 255) / 2), o = Math.floor((t + 255) / 2), i = Math.floor((s + 255) / 2);
|
|
33
33
|
return `#${n.toString(16).padStart(2, "0")}${o.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`;
|
|
34
34
|
}
|
|
35
35
|
static generateNeon() {
|
|
@@ -50,14 +50,14 @@ const m = class m {
|
|
|
50
50
|
static generateRGB() {
|
|
51
51
|
return Array.from({ length: 3 }, () => Math.floor(Math.random() * 128 + 128));
|
|
52
52
|
}
|
|
53
|
-
static brightColor() {
|
|
54
|
-
let
|
|
53
|
+
static brightColor(e = 1.3) {
|
|
54
|
+
let t = 0, s;
|
|
55
55
|
do {
|
|
56
|
-
const [
|
|
57
|
-
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)
|
|
58
58
|
break;
|
|
59
|
-
} while (!m.isBrightAndVivid(
|
|
60
|
-
return
|
|
59
|
+
} while (!m.isBrightAndVivid(s));
|
|
60
|
+
return s;
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
/*Проверить свои методы и возможно исключить т.к. функционал возможно повторяется */
|
|
@@ -137,8 +137,8 @@ c(m, "hslaToRgba", (e, t, s, n) => {
|
|
|
137
137
|
if (t === 0)
|
|
138
138
|
o = i = a = s;
|
|
139
139
|
else {
|
|
140
|
-
const u = function(
|
|
141
|
-
return d < 0 && (d += 1), d > 1 && (d -= 1), d < 0.16666666666666666 ?
|
|
140
|
+
const u = function(b, w, d) {
|
|
141
|
+
return d < 0 && (d += 1), d > 1 && (d -= 1), d < 0.16666666666666666 ? b + (w - b) * 6 * d : d < 0.5 ? w : d < 0.6666666666666666 ? b + (w - b) * (0.6666666666666666 - d) * 6 : b;
|
|
142
142
|
}, l = s < 0.5 ? s * (1 + t) : s + t - s * t, f = 2 * s - l;
|
|
143
143
|
o = u(f, l, e + 1 / 3), i = u(f, l, e), a = u(f, l, e - 1 / 3);
|
|
144
144
|
}
|
|
@@ -223,6 +223,14 @@ c(m, "rgbaToRgb", (e, t) => {
|
|
|
223
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) => {
|
|
224
224
|
const s = e > 0.5 ? 0 : 1, n = (e - s + t) / t;
|
|
225
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
|
+
}
|
|
226
234
|
}), c(m, "clamp", (e, t, s) => Math.min(s, Math.max(t, e))), c(m, "isHex", (e) => {
|
|
227
235
|
if (typeof e != "string")
|
|
228
236
|
return !1;
|
|
@@ -378,17 +386,17 @@ class DelaysPromise {
|
|
|
378
386
|
};
|
|
379
387
|
let o = !0, i, a, u;
|
|
380
388
|
const l = (h = !0) => {
|
|
381
|
-
const
|
|
382
|
-
o = !1, clearInterval(i), s(null), h ? a && a({ status: h, msg:
|
|
389
|
+
const b = "Ручное завершение startActionEvery";
|
|
390
|
+
o = !1, clearInterval(i), s(null), h ? a && a({ status: h, msg: b + ": (true)" }) : u && u({ status: h, msg: b + ": (false)" });
|
|
383
391
|
};
|
|
384
392
|
return {
|
|
385
|
-
promise: new Promise((h,
|
|
386
|
-
a = h, u =
|
|
393
|
+
promise: new Promise((h, b) => {
|
|
394
|
+
a = h, u = b;
|
|
387
395
|
let w = 0, d = 0;
|
|
388
396
|
i = setInterval(
|
|
389
397
|
() => {
|
|
390
398
|
if (w += t.interval, d += 1, t != null && t.cutoffTime && w > t.cutoffTime || t != null && t.countAction && (t == null ? void 0 : t.countAction) < d) {
|
|
391
|
-
o = !1, clearInterval(i), s(null),
|
|
399
|
+
o = !1, clearInterval(i), s(null), b({ status: !1, msg: Error("Время загрузки истекло") });
|
|
392
400
|
return;
|
|
393
401
|
}
|
|
394
402
|
e() && (o = !1, clearInterval(i), s(null), h({ status: !0, msg: "cb вернул true" }));
|
|
@@ -800,17 +808,17 @@ function toFormData(r, e, t) {
|
|
|
800
808
|
if (utils$1.endsWith(g, "{}"))
|
|
801
809
|
g = s ? g : g.slice(0, -2), d = JSON.stringify(d);
|
|
802
810
|
else if (utils$1.isArray(d) && isFlatArray(d) || (utils$1.isFileList(d) || utils$1.endsWith(g, "[]")) && (D = utils$1.toArray(d)))
|
|
803
|
-
return g = removeBrackets(g), D.forEach(function(S,
|
|
811
|
+
return g = removeBrackets(g), D.forEach(function(S, O) {
|
|
804
812
|
!(utils$1.isUndefined(S) || S === null) && e.append(
|
|
805
813
|
// eslint-disable-next-line no-nested-ternary
|
|
806
|
-
i === !0 ? renderKey([g],
|
|
814
|
+
i === !0 ? renderKey([g], O, o) : i === null ? g : g + "[]",
|
|
807
815
|
l(S)
|
|
808
816
|
);
|
|
809
817
|
}), !1;
|
|
810
818
|
}
|
|
811
819
|
return isVisitable(d) ? !0 : (e.append(renderKey(p, g, o), l(d)), !1);
|
|
812
820
|
}
|
|
813
|
-
const h = [],
|
|
821
|
+
const h = [], b = Object.assign(predicates, {
|
|
814
822
|
defaultVisitor: f,
|
|
815
823
|
convertValue: l,
|
|
816
824
|
isVisitable
|
|
@@ -825,7 +833,7 @@ function toFormData(r, e, t) {
|
|
|
825
833
|
D,
|
|
826
834
|
utils$1.isString(A) ? A.trim() : A,
|
|
827
835
|
g,
|
|
828
|
-
|
|
836
|
+
b
|
|
829
837
|
)) === !0 && w(D, g ? g.concat(A) : [A]);
|
|
830
838
|
}), h.pop();
|
|
831
839
|
}
|
|
@@ -1300,13 +1308,13 @@ function speedometer(r, e) {
|
|
|
1300
1308
|
return e = e !== void 0 ? e : 1e3, function(u) {
|
|
1301
1309
|
const l = Date.now(), f = s[o];
|
|
1302
1310
|
i || (i = l), t[n] = u, s[n] = l;
|
|
1303
|
-
let h = o,
|
|
1311
|
+
let h = o, b = 0;
|
|
1304
1312
|
for (; h !== n; )
|
|
1305
|
-
|
|
1313
|
+
b += t[h++], h = h % r;
|
|
1306
1314
|
if (n = (n + 1) % r, n === o && (o = (o + 1) % r), l - i < e)
|
|
1307
1315
|
return;
|
|
1308
1316
|
const w = f && l - f;
|
|
1309
|
-
return w ? Math.round(
|
|
1317
|
+
return w ? Math.round(b * 1e3 / w) : void 0;
|
|
1310
1318
|
};
|
|
1311
1319
|
}
|
|
1312
1320
|
function throttle(r, e) {
|
|
@@ -1477,8 +1485,8 @@ function mergeConfig(r, e) {
|
|
|
1477
1485
|
headers: (l, f) => n(headersToObject(l), headersToObject(f), !0)
|
|
1478
1486
|
};
|
|
1479
1487
|
return utils$1.forEach(Object.keys(Object.assign({}, r, e)), function(f) {
|
|
1480
|
-
const h = u[f] || n,
|
|
1481
|
-
utils$1.isUndefined(
|
|
1488
|
+
const h = u[f] || n, b = h(r[f], e[f], f);
|
|
1489
|
+
utils$1.isUndefined(b) && h !== a || (t[f] = b);
|
|
1482
1490
|
}), t;
|
|
1483
1491
|
}
|
|
1484
1492
|
const resolveConfig = (r) => {
|
|
@@ -1507,7 +1515,7 @@ const resolveConfig = (r) => {
|
|
|
1507
1515
|
const n = resolveConfig(r);
|
|
1508
1516
|
let o = n.data;
|
|
1509
1517
|
const i = AxiosHeaders$1.from(n.headers).normalize();
|
|
1510
|
-
let { responseType: a, onUploadProgress: u, onDownloadProgress: l } = n, f, h,
|
|
1518
|
+
let { responseType: a, onUploadProgress: u, onDownloadProgress: l } = n, f, h, b, w, d;
|
|
1511
1519
|
function g() {
|
|
1512
1520
|
w && w(), d && d(), n.cancelToken && n.cancelToken.unsubscribe(f), n.signal && n.signal.removeEventListener("abort", f);
|
|
1513
1521
|
}
|
|
@@ -1539,17 +1547,17 @@ const resolveConfig = (r) => {
|
|
|
1539
1547
|
}, p.onerror = function() {
|
|
1540
1548
|
s(new AxiosError("Network Error", AxiosError.ERR_NETWORK, r, p)), p = null;
|
|
1541
1549
|
}, p.ontimeout = function() {
|
|
1542
|
-
let
|
|
1550
|
+
let O = n.timeout ? "timeout of " + n.timeout + "ms exceeded" : "timeout exceeded";
|
|
1543
1551
|
const x = n.transitional || transitionalDefaults;
|
|
1544
|
-
n.timeoutErrorMessage && (
|
|
1545
|
-
|
|
1552
|
+
n.timeoutErrorMessage && (O = n.timeoutErrorMessage), s(new AxiosError(
|
|
1553
|
+
O,
|
|
1546
1554
|
x.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
1547
1555
|
r,
|
|
1548
1556
|
p
|
|
1549
1557
|
)), p = null;
|
|
1550
|
-
}, o === void 0 && i.setContentType(null), "setRequestHeader" in p && utils$1.forEach(i.toJSON(), function(
|
|
1551
|
-
p.setRequestHeader(x,
|
|
1552
|
-
}), utils$1.isUndefined(n.withCredentials) || (p.withCredentials = !!n.withCredentials), a && a !== "json" && (p.responseType = n.responseType), l && ([
|
|
1558
|
+
}, o === void 0 && i.setContentType(null), "setRequestHeader" in p && utils$1.forEach(i.toJSON(), function(O, x) {
|
|
1559
|
+
p.setRequestHeader(x, O);
|
|
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) => {
|
|
1553
1561
|
p && (s(!S || S.type ? new CanceledError(null, r, p) : S), p.abort(), p = null);
|
|
1554
1562
|
}, n.cancelToken && n.cancelToken.subscribe(f), n.signal && (n.signal.aborted ? f() : n.signal.addEventListener("abort", f)));
|
|
1555
1563
|
const A = parseProtocol(n.url);
|
|
@@ -1625,8 +1633,8 @@ const resolveConfig = (r) => {
|
|
|
1625
1633
|
}
|
|
1626
1634
|
let h = f.byteLength;
|
|
1627
1635
|
if (t) {
|
|
1628
|
-
let
|
|
1629
|
-
t(
|
|
1636
|
+
let b = o += h;
|
|
1637
|
+
t(b);
|
|
1630
1638
|
}
|
|
1631
1639
|
u.enqueue(new Uint8Array(f));
|
|
1632
1640
|
} catch (l) {
|
|
@@ -1695,7 +1703,7 @@ const getBodyLength = async (r) => {
|
|
|
1695
1703
|
responseType: l,
|
|
1696
1704
|
headers: f,
|
|
1697
1705
|
withCredentials: h = "same-origin",
|
|
1698
|
-
fetchOptions:
|
|
1706
|
+
fetchOptions: b
|
|
1699
1707
|
} = resolveConfig(r);
|
|
1700
1708
|
l = l ? (l + "").toLowerCase() : "text";
|
|
1701
1709
|
let w = composeSignals$1([n, o && o.toAbortSignal()], i), d;
|
|
@@ -1709,8 +1717,8 @@ const getBodyLength = async (r) => {
|
|
|
1709
1717
|
method: "POST",
|
|
1710
1718
|
body: s,
|
|
1711
1719
|
duplex: "half"
|
|
1712
|
-
}),
|
|
1713
|
-
if (utils$1.isFormData(s) && (
|
|
1720
|
+
}), T;
|
|
1721
|
+
if (utils$1.isFormData(s) && (T = x.headers.get("content-type")) && f.setContentType(T), x.body) {
|
|
1714
1722
|
const [C, N] = progressEventDecorator(
|
|
1715
1723
|
p,
|
|
1716
1724
|
progressEventReducer(asyncDecorator(u))
|
|
@@ -1721,7 +1729,7 @@ const getBodyLength = async (r) => {
|
|
|
1721
1729
|
utils$1.isString(h) || (h = h ? "include" : "omit");
|
|
1722
1730
|
const D = "credentials" in Request.prototype;
|
|
1723
1731
|
d = new Request(e, {
|
|
1724
|
-
...
|
|
1732
|
+
...b,
|
|
1725
1733
|
signal: w,
|
|
1726
1734
|
method: t.toUpperCase(),
|
|
1727
1735
|
headers: f.normalize().toJSON(),
|
|
@@ -1736,8 +1744,8 @@ const getBodyLength = async (r) => {
|
|
|
1736
1744
|
["status", "statusText", "headers"].forEach((k) => {
|
|
1737
1745
|
x[k] = A[k];
|
|
1738
1746
|
});
|
|
1739
|
-
const
|
|
1740
|
-
|
|
1747
|
+
const T = utils$1.toFiniteNumber(A.headers.get("content-length")), [C, N] = a && progressEventDecorator(
|
|
1748
|
+
T,
|
|
1741
1749
|
progressEventReducer(asyncDecorator(a), !0)
|
|
1742
1750
|
) || [];
|
|
1743
1751
|
A = new Response(
|
|
@@ -1748,10 +1756,10 @@ const getBodyLength = async (r) => {
|
|
|
1748
1756
|
);
|
|
1749
1757
|
}
|
|
1750
1758
|
l = l || "text";
|
|
1751
|
-
let
|
|
1752
|
-
return !S && g && g(), await new Promise((x,
|
|
1753
|
-
settle(x,
|
|
1754
|
-
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,
|
|
1755
1763
|
headers: AxiosHeaders$1.from(A.headers),
|
|
1756
1764
|
status: A.status,
|
|
1757
1765
|
statusText: A.statusText,
|
|
@@ -1944,16 +1952,16 @@ class Axios {
|
|
|
1944
1952
|
this.interceptors.response.forEach(function(g) {
|
|
1945
1953
|
l.push(g.fulfilled, g.rejected);
|
|
1946
1954
|
});
|
|
1947
|
-
let f, h = 0,
|
|
1955
|
+
let f, h = 0, b;
|
|
1948
1956
|
if (!u) {
|
|
1949
1957
|
const d = [dispatchRequest.bind(this), void 0];
|
|
1950
|
-
for (d.unshift.apply(d, a), d.push.apply(d, l),
|
|
1958
|
+
for (d.unshift.apply(d, a), d.push.apply(d, l), b = d.length, f = Promise.resolve(t); h < b; )
|
|
1951
1959
|
f = f.then(d[h++], d[h++]);
|
|
1952
1960
|
return f;
|
|
1953
1961
|
}
|
|
1954
|
-
|
|
1962
|
+
b = a.length;
|
|
1955
1963
|
let w = t;
|
|
1956
|
-
for (h = 0; h <
|
|
1964
|
+
for (h = 0; h < b; ) {
|
|
1957
1965
|
const d = a[h++], g = a[h++];
|
|
1958
1966
|
try {
|
|
1959
1967
|
w = d(w);
|
|
@@ -1967,7 +1975,7 @@ class Axios {
|
|
|
1967
1975
|
} catch (d) {
|
|
1968
1976
|
return Promise.reject(d);
|
|
1969
1977
|
}
|
|
1970
|
-
for (h = 0,
|
|
1978
|
+
for (h = 0, b = l.length; h < b; )
|
|
1971
1979
|
f = f.then(l[h++], l[h++]);
|
|
1972
1980
|
return f;
|
|
1973
1981
|
}
|
|
@@ -2368,7 +2376,7 @@ const E = class E {
|
|
|
2368
2376
|
c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerRequest", new SaveRequest()), c(E, "registerFailedRequests", new SaveRequest()), c(E, "requestUploadToken", null), c(E, "errorsHandler", new ErrorsHandler()), c(E, "setMethodUploadToken", (e) => {
|
|
2369
2377
|
E.requestUploadToken = e;
|
|
2370
2378
|
}), c(E, "requestInServer", (e, t = {}) => new Promise((s, n) => {
|
|
2371
|
-
var
|
|
2379
|
+
var b;
|
|
2372
2380
|
let o = { url: e, statusCode: 0, data: {}, res: {} };
|
|
2373
2381
|
const i = {
|
|
2374
2382
|
method: "get",
|
|
@@ -2384,7 +2392,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2384
2392
|
request: a,
|
|
2385
2393
|
errExt: { message: l, status: u }
|
|
2386
2394
|
}, { cordova: h } = window;
|
|
2387
|
-
if (h != null && h.cordova && ((
|
|
2395
|
+
if (h != null && h.cordova && ((b = h == null ? void 0 : h.plugin) != null && b.http)) {
|
|
2388
2396
|
const { http: w } = h == null ? void 0 : h.plugin;
|
|
2389
2397
|
"Content-Type" in (a == null ? void 0 : a.headers) && ((a == null ? void 0 : a.headers["Content-Type"]) === "multipart/form-data" && w.setDataSerializer("urlencoded"), (a == null ? void 0 : a.headers["Content-Type"]) === "application/json" && w.setDataSerializer("json")), w.setRequestTimeout(Number(a.timeout) / 1e3), E.registerRequest.setList({ url: e, options: a }), w.sendRequest(
|
|
2390
2398
|
e,
|
|
@@ -2395,17 +2403,17 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2395
2403
|
o = { ...o, statusCode: p, data: D, res: d }, p === 200 && g && (E.saveToken(g), o.data = { ...o.data, token: g }), s(o);
|
|
2396
2404
|
},
|
|
2397
2405
|
(d) => {
|
|
2398
|
-
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 = {
|
|
2399
2407
|
headers: A,
|
|
2400
2408
|
status: D,
|
|
2401
2409
|
message: ""
|
|
2402
2410
|
};
|
|
2403
2411
|
if (x) {
|
|
2404
2412
|
const C = JSON.parse(S.trim()), N = E.errorsHandler.getErrorMessageFromData(D, C);
|
|
2405
|
-
|
|
2413
|
+
T.message = N, T.data = C, g.msg = E.errorsHandler.gerErrorByStatusCordovaHttp(D, p);
|
|
2406
2414
|
} else
|
|
2407
|
-
typeof S == "string" && (
|
|
2408
|
-
n({ ...f, ...g, errExt:
|
|
2415
|
+
typeof S == "string" && (T.message = S);
|
|
2416
|
+
n({ ...f, ...g, errExt: T });
|
|
2409
2417
|
}
|
|
2410
2418
|
);
|
|
2411
2419
|
} else
|
|
@@ -2414,7 +2422,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2414
2422
|
const d = w.status, g = w == null ? void 0 : w.data;
|
|
2415
2423
|
o = { ...o, statusCode: d, data: g, res: w }, s(o);
|
|
2416
2424
|
}).catch((w) => {
|
|
2417
|
-
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 = {
|
|
2418
2426
|
code: g,
|
|
2419
2427
|
config: p,
|
|
2420
2428
|
status: D || u,
|
|
@@ -2422,7 +2430,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2422
2430
|
headers: S == null ? void 0 : S.headers,
|
|
2423
2431
|
statusText: S == null ? void 0 : S.statusText,
|
|
2424
2432
|
data: S == null ? void 0 : S.data,
|
|
2425
|
-
stack:
|
|
2433
|
+
stack: O
|
|
2426
2434
|
};
|
|
2427
2435
|
n({ ...f, ...d, errExt: x });
|
|
2428
2436
|
});
|
|
@@ -2564,21 +2572,21 @@ class EventSubscribers {
|
|
|
2564
2572
|
});
|
|
2565
2573
|
}
|
|
2566
2574
|
}
|
|
2567
|
-
const
|
|
2575
|
+
const y = class y {
|
|
2568
2576
|
static setState(e) {
|
|
2569
|
-
|
|
2577
|
+
y.state = { ...y.state, ...e };
|
|
2570
2578
|
}
|
|
2571
2579
|
static getState() {
|
|
2572
|
-
return
|
|
2580
|
+
return y.state;
|
|
2573
2581
|
}
|
|
2574
2582
|
static getIsNetwork() {
|
|
2575
|
-
return
|
|
2583
|
+
return y.state.isNetworkStatus;
|
|
2576
2584
|
}
|
|
2577
2585
|
static request({ keyAction: e, request: t }) {
|
|
2578
2586
|
const { url: s, ...n } = t;
|
|
2579
2587
|
return new Promise((o, i) => {
|
|
2580
|
-
|
|
2581
|
-
const u =
|
|
2588
|
+
y.getIsInit() || y.init();
|
|
2589
|
+
const u = y.getIsNetwork(), l = {
|
|
2582
2590
|
url: s,
|
|
2583
2591
|
keyAction: e,
|
|
2584
2592
|
isErr: !u,
|
|
@@ -2587,7 +2595,7 @@ const b = class b {
|
|
|
2587
2595
|
statusCode: u ? 0 : 520,
|
|
2588
2596
|
isReload: !1
|
|
2589
2597
|
};
|
|
2590
|
-
if (
|
|
2598
|
+
if (y.events.publish("fetch", l), u) {
|
|
2591
2599
|
apiRequest.requestInServer(s, n).then((f) => {
|
|
2592
2600
|
const h = {
|
|
2593
2601
|
isReq: !1,
|
|
@@ -2597,7 +2605,7 @@ const b = class b {
|
|
|
2597
2605
|
msg: "",
|
|
2598
2606
|
...f
|
|
2599
2607
|
};
|
|
2600
|
-
|
|
2608
|
+
y.events.publish("fetch", h), o(h);
|
|
2601
2609
|
}).catch((f) => {
|
|
2602
2610
|
const h = {
|
|
2603
2611
|
//TODO: Проверить. dataErr не верно возвращает
|
|
@@ -2606,32 +2614,32 @@ const b = class b {
|
|
|
2606
2614
|
keyAction: e,
|
|
2607
2615
|
...f
|
|
2608
2616
|
};
|
|
2609
|
-
|
|
2617
|
+
y.events.publish("fetch", h), i(h);
|
|
2610
2618
|
});
|
|
2611
2619
|
return;
|
|
2612
2620
|
}
|
|
2613
|
-
|
|
2621
|
+
y.events.publish("fetch", l), i(l);
|
|
2614
2622
|
});
|
|
2615
2623
|
}
|
|
2616
2624
|
};
|
|
2617
|
-
c(
|
|
2625
|
+
c(y, "state", {
|
|
2618
2626
|
isInit: !1,
|
|
2619
2627
|
isNetworkStatus: navigator.onLine
|
|
2620
|
-
}), c(
|
|
2621
|
-
|
|
2622
|
-
}), c(
|
|
2623
|
-
|
|
2624
|
-
}), c(
|
|
2628
|
+
}), c(y, "internet", new NetworkInformation([new NetworkInformationPC(), new NetworkInformationCordova()])), c(y, "events", new EventSubscribers(["fetch"])), c(y, "online", () => {
|
|
2629
|
+
y.setState({ isNetworkStatus: !0 });
|
|
2630
|
+
}), c(y, "offline", () => {
|
|
2631
|
+
y.setState({ isNetworkStatus: !1 });
|
|
2632
|
+
}), c(y, "errorInit", () => {
|
|
2625
2633
|
console.error("Не вызван HTTPSApi.init()");
|
|
2626
|
-
}), c(
|
|
2627
|
-
const { isInit: e } =
|
|
2628
|
-
return e ||
|
|
2629
|
-
}), c(
|
|
2630
|
-
|
|
2631
|
-
e ?
|
|
2632
|
-
}),
|
|
2633
|
-
}), c(
|
|
2634
|
-
let HTTPSApi =
|
|
2634
|
+
}), c(y, "getIsInit", () => {
|
|
2635
|
+
const { isInit: e } = y.getState();
|
|
2636
|
+
return e || y.errorInit(), e;
|
|
2637
|
+
}), c(y, "init", () => {
|
|
2638
|
+
y.internet.run((e) => {
|
|
2639
|
+
e ? y.online() : y.offline();
|
|
2640
|
+
}), y.setState({ isInit: !0 });
|
|
2641
|
+
}), c(y, "on", y.events.subscribe), c(y, "off", y.events.unsubscribe), c(y, "removeAuthCookie", apiRequest.removeAuthCookie), c(y, "getAuthCookies", apiRequest.getAuthCookies);
|
|
2642
|
+
let HTTPSApi = y;
|
|
2635
2643
|
class Numbers {
|
|
2636
2644
|
}
|
|
2637
2645
|
c(Numbers, "getOnlyTheStringNumbers", (e) => e.split("").filter((t) => !Number.isNaN(Number.parseInt(t))).join("")), c(Numbers, "isNumber", (e) => {
|
|
@@ -2727,7 +2735,7 @@ class NetworkStatusTracker {
|
|
|
2727
2735
|
}, { signal: (a = s.online) == null ? void 0 : a.signal }), window.addEventListener("offline", () => {
|
|
2728
2736
|
this.updateState(!1, e);
|
|
2729
2737
|
}, { signal: (u = s.offline) == null ? void 0 : u.signal }), (l = this.getConnection()) != null && l.addEventListener && this.getConnection().addEventListener("change", () => {
|
|
2730
|
-
const h = this.getConnection(),
|
|
2738
|
+
const h = this.getConnection(), b = this.getTypeNetwork(h, null), w = this.getIsNetwork(b);
|
|
2731
2739
|
this.updateState(w, e);
|
|
2732
2740
|
}, { signal: (f = s.change) == null ? void 0 : f.signal });
|
|
2733
2741
|
}
|