dev-classes 1.4.33 → 1.4.34
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 +7 -1
- package/dist/classes/Color/Color.d.ts +3 -6
- package/dist/classes/Color/Color.types.d.ts +7 -1
- package/dist/index.js +113 -146
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,13 @@ interface ColorProps{
|
|
|
72
72
|
rgb: () => number[];
|
|
73
73
|
hex: () => string;
|
|
74
74
|
hexMultiple: () => string[];
|
|
75
|
-
pastelColor: (
|
|
75
|
+
pastelColor: (config: {
|
|
76
|
+
baseColor?: string;
|
|
77
|
+
saturation?: number;
|
|
78
|
+
lightness?: number;
|
|
79
|
+
hueShift?: number;
|
|
80
|
+
randomize?: boolean;
|
|
81
|
+
}) => string;
|
|
76
82
|
neonColor: () => string;
|
|
77
83
|
brightColor: (factor?: number) => string;
|
|
78
84
|
};
|
|
@@ -3,13 +3,11 @@ export declare class Color {
|
|
|
3
3
|
private static componentToHex;
|
|
4
4
|
static rgbToHex: ColorProps["rgbToHex"];
|
|
5
5
|
/**
|
|
6
|
-
* https://stackoverflow.com/a/54070620/6758968
|
|
7
6
|
* r, g, b in [0, 255]
|
|
8
7
|
* @returns h in [0,360) and s, v in [0,1]
|
|
9
8
|
*/
|
|
10
9
|
static rgbToHsv: ColorProps["rgbToHsv"];
|
|
11
10
|
/**
|
|
12
|
-
* https://stackoverflow.com/a/54024653/6758968
|
|
13
11
|
* @param h [0, 360]
|
|
14
12
|
* @param s [0, 1]
|
|
15
13
|
* @param v [0, 1]
|
|
@@ -20,7 +18,6 @@ export declare class Color {
|
|
|
20
18
|
* @returns h [0, 360], s [0, 100], l [0, 100], a [0, 1]
|
|
21
19
|
*/
|
|
22
20
|
static rgbaToHsla: ColorProps["rgbaToHsla"];
|
|
23
|
-
private static rgbToHsl;
|
|
24
21
|
/**
|
|
25
22
|
* Converts an HSL color value to RGB. Conversion formula
|
|
26
23
|
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
@@ -53,7 +50,6 @@ export declare class Color {
|
|
|
53
50
|
static rgbaToRgb: ColorProps["rgbaToRgb"];
|
|
54
51
|
static calculateBrightness: ColorProps["calculateBrightness"];
|
|
55
52
|
static getTextColor: ColorProps["getTextColor"];
|
|
56
|
-
private static readonly MIN_BRIGHTNESS;
|
|
57
53
|
private static readonly MIN_SATURATION;
|
|
58
54
|
private static readonly MIN_LIGHTNESS;
|
|
59
55
|
static isBrightAndVivid(color: string): boolean;
|
|
@@ -63,15 +59,16 @@ export declare class Color {
|
|
|
63
59
|
static isHex: (color: string) => boolean;
|
|
64
60
|
private static generateHex;
|
|
65
61
|
private static generateHexMultiple;
|
|
66
|
-
private static generatePastel;
|
|
67
62
|
private static generateNeon;
|
|
68
63
|
private static generateRGB;
|
|
69
64
|
private static brightColor;
|
|
65
|
+
static hslToHex(hue: number, saturation: number, lightness: number): string;
|
|
66
|
+
private static generatePleasantColor;
|
|
70
67
|
static generate: {
|
|
71
68
|
rgb: typeof Color.generateRGB;
|
|
72
69
|
hex: () => string;
|
|
73
70
|
hexMultiple: (count: number) => string[];
|
|
74
|
-
pastelColor: typeof Color.
|
|
71
|
+
pastelColor: typeof Color.generatePleasantColor;
|
|
75
72
|
neonColor: typeof Color.generateNeon;
|
|
76
73
|
brightColor: typeof Color.brightColor;
|
|
77
74
|
};
|
|
@@ -39,7 +39,13 @@ export interface ColorProps {
|
|
|
39
39
|
rgb: () => number[];
|
|
40
40
|
hex: () => string;
|
|
41
41
|
hexMultiple: () => string[];
|
|
42
|
-
pastelColor: (
|
|
42
|
+
pastelColor: (config: {
|
|
43
|
+
baseColor?: string;
|
|
44
|
+
saturation?: number;
|
|
45
|
+
lightness?: number;
|
|
46
|
+
hueShift?: number;
|
|
47
|
+
randomize?: boolean;
|
|
48
|
+
}) => string;
|
|
43
49
|
neonColor: () => string;
|
|
44
50
|
brightColor: (factor?: number) => string;
|
|
45
51
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var P = (r, e, t) => e in r ?
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var P = (r, e, t) => e in r ? k(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var c = (r, e, t) => (P(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
const m = class m {
|
|
5
|
-
static rgbToHsl(e, t, s) {
|
|
6
|
-
e /= 255, t /= 255, s /= 255;
|
|
7
|
-
const n = Math.max(e, t, s), o = Math.min(e, t, s);
|
|
8
|
-
let i = 0, a = 0;
|
|
9
|
-
const u = (n + o) / 2;
|
|
10
|
-
if (n !== o) {
|
|
11
|
-
const l = n - o;
|
|
12
|
-
switch (a = u > 0.5 ? l / (2 - n - o) : l / (n + o), n) {
|
|
13
|
-
case e:
|
|
14
|
-
i = (t - s) / l + (t < s ? 6 : 0);
|
|
15
|
-
break;
|
|
16
|
-
case t:
|
|
17
|
-
i = (s - e) / l + 2;
|
|
18
|
-
break;
|
|
19
|
-
case s:
|
|
20
|
-
i = (e - t) / l + 4;
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
i /= 6;
|
|
24
|
-
}
|
|
25
|
-
return { h: i, s: a, l: u };
|
|
26
|
-
}
|
|
27
5
|
static isBrightAndVivid(e) {
|
|
28
|
-
const [t, s, n] = this.hexToRgb(e), o = this.
|
|
6
|
+
const [t, s, n] = this.hexToRgb(e), o = this.rgbaToHsla(t, s, n, 1);
|
|
29
7
|
return o.l >= this.MIN_LIGHTNESS && o.s >= this.MIN_SATURATION;
|
|
30
8
|
}
|
|
31
|
-
static generatePastel() {
|
|
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
|
-
return `#${n.toString(16).padStart(2, "0")}${o.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`;
|
|
34
|
-
}
|
|
35
9
|
static generateNeon() {
|
|
36
10
|
const e = [
|
|
37
11
|
Math.floor(Math.random() * 128 + 128),
|
|
@@ -59,20 +33,28 @@ const m = class m {
|
|
|
59
33
|
} while (!m.isBrightAndVivid(s));
|
|
60
34
|
return s;
|
|
61
35
|
}
|
|
36
|
+
static hslToHex(e, t, s) {
|
|
37
|
+
const n = m.hslaToRgba(e, t, s, 1), [o, i, a] = n.slice(0, 3);
|
|
38
|
+
return m.rgbToHex(o, i, a);
|
|
39
|
+
}
|
|
40
|
+
static generatePleasantColor(e = {}) {
|
|
41
|
+
const { baseColor: t, saturation: s = 50, lightness: n = 50, hueShift: o = 0, randomize: i = !1 } = e;
|
|
42
|
+
let a, u, l;
|
|
43
|
+
return t ? (a = (m.hexaToHsla(t).h + o) % 360, i ? (u = Math.max(30, Math.min(90, s + (Math.random() * 40 - 20))), l = Math.max(40, Math.min(80, n + (Math.random() * 30 - 15)))) : (u = s, l = n)) : (a = Math.floor(Math.random() * 360), u = s + Math.random() * 20, l = n + Math.random() * 20), (a >= 20 && a <= 50 || a >= 60 && a <= 140) && (a = (a + 100) % 360), n < 100 && (u = Math.max(u, 15), l > 95 && (l = 95 - Math.random() * 10), u < 20 && l > 90 && (a = (a + 180) % 360, u = Math.max(25, u))), m.hslToHex(a, u, l);
|
|
44
|
+
}
|
|
62
45
|
};
|
|
63
46
|
/*Проверить свои методы и возможно исключить т.к. функционал возможно повторяется */
|
|
64
47
|
c(m, "componentToHex", (e) => {
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
}), // static
|
|
68
|
-
// const
|
|
69
|
-
//
|
|
70
|
-
// return
|
|
71
|
-
// }
|
|
72
|
-
// return
|
|
73
|
-
// }
|
|
74
|
-
|
|
75
|
-
* https://stackoverflow.com/a/54070620/6758968
|
|
48
|
+
const s = Math.max(0, Math.min(255, Math.round(e))).toString(16);
|
|
49
|
+
return s.length == 1 ? "0" + s : s;
|
|
50
|
+
}), c(m, "rgbToHex", (e, t, s) => "#" + m.componentToHex(e) + m.componentToHex(t) + m.componentToHex(s)), // static rgbToHex: ColorProps["rgbToHex"] = (r: number, g: number, b: number) => {
|
|
51
|
+
// const toHex = (n: number): string => {
|
|
52
|
+
// const hex = Math.round(n).toString(16);
|
|
53
|
+
// return hex.length === 1 ? "0" + hex : hex;
|
|
54
|
+
// };
|
|
55
|
+
// return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
56
|
+
// }
|
|
57
|
+
/**
|
|
76
58
|
* r, g, b in [0, 255]
|
|
77
59
|
* @returns h in [0,360) and s, v in [0,1]
|
|
78
60
|
*/
|
|
@@ -81,7 +63,6 @@ c(m, "rgbToHsv", (e, t, s) => {
|
|
|
81
63
|
const n = Math.max(e, t, s), o = n - Math.min(e, t, s), i = o && (n === e ? (t - s) / o : n == t ? 2 + (s - e) / o : 4 + (e - t) / o);
|
|
82
64
|
return [60 * (i < 0 ? i + 6 : i), n && o / n, n];
|
|
83
65
|
}), /**
|
|
84
|
-
* https://stackoverflow.com/a/54024653/6758968
|
|
85
66
|
* @param h [0, 360]
|
|
86
67
|
* @param s [0, 1]
|
|
87
68
|
* @param v [0, 1]
|
|
@@ -121,8 +102,7 @@ c(m, "rgbaToHsla", (e, t, s, n = 1) => {
|
|
|
121
102
|
l: l * 100,
|
|
122
103
|
a: n
|
|
123
104
|
};
|
|
124
|
-
}),
|
|
125
|
-
/**
|
|
105
|
+
}), /**
|
|
126
106
|
* Converts an HSL color value to RGB. Conversion formula
|
|
127
107
|
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
128
108
|
*
|
|
@@ -137,8 +117,8 @@ c(m, "hslaToRgba", (e, t, s, n) => {
|
|
|
137
117
|
if (t === 0)
|
|
138
118
|
o = i = a = s;
|
|
139
119
|
else {
|
|
140
|
-
const u = function(
|
|
141
|
-
return d < 0 && (d += 1), d > 1 && (d -= 1), d < 0.16666666666666666 ?
|
|
120
|
+
const u = function(w, b, d) {
|
|
121
|
+
return d < 0 && (d += 1), d > 1 && (d -= 1), d < 0.16666666666666666 ? w + (b - w) * 6 * d : d < 0.5 ? b : d < 0.6666666666666666 ? w + (b - w) * (0.6666666666666666 - d) * 6 : w;
|
|
142
122
|
}, l = s < 0.5 ? s * (1 + t) : s + t - s * t, f = 2 * s - l;
|
|
143
123
|
o = u(f, l, e + 1 / 3), i = u(f, l, e), a = u(f, l, e - 1 / 3);
|
|
144
124
|
}
|
|
@@ -191,8 +171,8 @@ c(m, "mixColors", (e, t, s) => {
|
|
|
191
171
|
let u = m.hsvToRgb(...o);
|
|
192
172
|
const l = m.calculateBrightness(s), f = m.calculateBrightness(u);
|
|
193
173
|
if (n ? l > f : l < f) {
|
|
194
|
-
const
|
|
195
|
-
u = m.changeBrightness(u,
|
|
174
|
+
const b = 0.4 * l / f + 0.6;
|
|
175
|
+
u = m.changeBrightness(u, b);
|
|
196
176
|
}
|
|
197
177
|
return u;
|
|
198
178
|
}), c(m, "changeBrightness", (e, t) => e.map((s) => m.clamp(Math.round(s * t), 0, 255))), c(m, "hexBrightness", (e, t) => {
|
|
@@ -201,26 +181,13 @@ c(m, "mixColors", (e, t, s) => {
|
|
|
201
181
|
}), c(m, "getHexColorFromTelegramColor", (e) => {
|
|
202
182
|
const t = (e < 0 ? 16777215 + e : e).toString(16);
|
|
203
183
|
return "#" + (t.length >= 6 ? t : "0".repeat(6 - t.length) + t);
|
|
204
|
-
}), c(m, "getRgbColorFromTelegramColor", (e) => m.hexToRgb(m.getHexColorFromTelegramColor(e))),
|
|
205
|
-
// return wallPaper.settings
|
|
206
|
-
// ? [
|
|
207
|
-
// wallPaper.settings.background_color,
|
|
208
|
-
// wallPaper.settings.second_background_color,
|
|
209
|
-
// wallPaper.settings.third_background_color,
|
|
210
|
-
// wallPaper.settings.fourth_background_color,
|
|
211
|
-
// ]
|
|
212
|
-
// .filter(Boolean)
|
|
213
|
-
// .map(Color.getHexColorFromTelegramColor)
|
|
214
|
-
// .join(",")
|
|
215
|
-
// : "";
|
|
216
|
-
// }
|
|
217
|
-
c(m, "rgbaToRgb", (e, t) => {
|
|
184
|
+
}), c(m, "getRgbColorFromTelegramColor", (e) => m.hexToRgb(m.getHexColorFromTelegramColor(e))), c(m, "rgbaToRgb", (e, t) => {
|
|
218
185
|
const s = e[3];
|
|
219
186
|
return e.slice(0, 3).map((n, o) => m.clamp(Math.round((s * (n / 255) + s * (t[o] / 255)) * 255), 0, 255));
|
|
220
187
|
}), c(m, "calculateBrightness", (e, t = "BT709") => {
|
|
221
188
|
const [s, n, o] = e, i = m.getRgbByTypeBrightness(t);
|
|
222
189
|
return i[0] * s / 255 + i[1] * n / 255 + i[2] * o / 255;
|
|
223
|
-
}), c(m, "getTextColor", (e) => e > 0.5 ? [0, 0, 0] : [255, 255, 255]), c(m, "
|
|
190
|
+
}), c(m, "getTextColor", (e) => e > 0.5 ? [0, 0, 0] : [255, 255, 255]), c(m, "MIN_SATURATION", 50), c(m, "MIN_LIGHTNESS", 44), c(m, "calculateOpacity", (e, t) => {
|
|
224
191
|
const s = e > 0.5 ? 0 : 1, n = (e - s + t) / t;
|
|
225
192
|
return +Math.max(0.5, Math.min(0.64, n)).toFixed(2);
|
|
226
193
|
}), c(m, "increaseSaturation", (e, t = 1.3) => {
|
|
@@ -240,7 +207,7 @@ c(m, "rgbaToRgb", (e, t) => {
|
|
|
240
207
|
rgb: m.generateRGB,
|
|
241
208
|
hex: m.generateHex,
|
|
242
209
|
hexMultiple: m.generateHexMultiple,
|
|
243
|
-
pastelColor: m.
|
|
210
|
+
pastelColor: m.generatePleasantColor,
|
|
244
211
|
neonColor: m.generateNeon,
|
|
245
212
|
brightColor: m.brightColor
|
|
246
213
|
});
|
|
@@ -386,17 +353,17 @@ class DelaysPromise {
|
|
|
386
353
|
};
|
|
387
354
|
let o = !0, i, a, u;
|
|
388
355
|
const l = (h = !0) => {
|
|
389
|
-
const
|
|
390
|
-
o = !1, clearInterval(i), s(null), h ? a && a({ status: h, msg:
|
|
356
|
+
const w = "Ручное завершение startActionEvery";
|
|
357
|
+
o = !1, clearInterval(i), s(null), h ? a && a({ status: h, msg: w + ": (true)" }) : u && u({ status: h, msg: w + ": (false)" });
|
|
391
358
|
};
|
|
392
359
|
return {
|
|
393
|
-
promise: new Promise((h,
|
|
394
|
-
a = h, u =
|
|
395
|
-
let
|
|
360
|
+
promise: new Promise((h, w) => {
|
|
361
|
+
a = h, u = w;
|
|
362
|
+
let b = 0, d = 0;
|
|
396
363
|
i = setInterval(
|
|
397
364
|
() => {
|
|
398
|
-
if (
|
|
399
|
-
o = !1, clearInterval(i), s(null),
|
|
365
|
+
if (b += t.interval, d += 1, t != null && t.cutoffTime && b > t.cutoffTime || t != null && t.countAction && (t == null ? void 0 : t.countAction) < d) {
|
|
366
|
+
o = !1, clearInterval(i), s(null), w({ status: !1, msg: Error("Время загрузки истекло") });
|
|
400
367
|
return;
|
|
401
368
|
}
|
|
402
369
|
e() && (o = !1, clearInterval(i), s(null), h({ status: !0, msg: "cb вернул true" }));
|
|
@@ -818,12 +785,12 @@ function toFormData(r, e, t) {
|
|
|
818
785
|
}
|
|
819
786
|
return isVisitable(d) ? !0 : (e.append(renderKey(p, g, o), l(d)), !1);
|
|
820
787
|
}
|
|
821
|
-
const h = [],
|
|
788
|
+
const h = [], w = Object.assign(predicates, {
|
|
822
789
|
defaultVisitor: f,
|
|
823
790
|
convertValue: l,
|
|
824
791
|
isVisitable
|
|
825
792
|
});
|
|
826
|
-
function
|
|
793
|
+
function b(d, g) {
|
|
827
794
|
if (!utils$1.isUndefined(d)) {
|
|
828
795
|
if (h.indexOf(d) !== -1)
|
|
829
796
|
throw Error("Circular reference detected in " + g.join("."));
|
|
@@ -833,14 +800,14 @@ function toFormData(r, e, t) {
|
|
|
833
800
|
D,
|
|
834
801
|
utils$1.isString(A) ? A.trim() : A,
|
|
835
802
|
g,
|
|
836
|
-
|
|
837
|
-
)) === !0 &&
|
|
803
|
+
w
|
|
804
|
+
)) === !0 && b(D, g ? g.concat(A) : [A]);
|
|
838
805
|
}), h.pop();
|
|
839
806
|
}
|
|
840
807
|
}
|
|
841
808
|
if (!utils$1.isObject(r))
|
|
842
809
|
throw new TypeError("data must be an object");
|
|
843
|
-
return
|
|
810
|
+
return b(r), e;
|
|
844
811
|
}
|
|
845
812
|
function encode$1(r) {
|
|
846
813
|
const e = {
|
|
@@ -1308,13 +1275,13 @@ function speedometer(r, e) {
|
|
|
1308
1275
|
return e = e !== void 0 ? e : 1e3, function(u) {
|
|
1309
1276
|
const l = Date.now(), f = s[o];
|
|
1310
1277
|
i || (i = l), t[n] = u, s[n] = l;
|
|
1311
|
-
let h = o,
|
|
1278
|
+
let h = o, w = 0;
|
|
1312
1279
|
for (; h !== n; )
|
|
1313
|
-
|
|
1280
|
+
w += t[h++], h = h % r;
|
|
1314
1281
|
if (n = (n + 1) % r, n === o && (o = (o + 1) % r), l - i < e)
|
|
1315
1282
|
return;
|
|
1316
|
-
const
|
|
1317
|
-
return
|
|
1283
|
+
const b = f && l - f;
|
|
1284
|
+
return b ? Math.round(w * 1e3 / b) : void 0;
|
|
1318
1285
|
};
|
|
1319
1286
|
}
|
|
1320
1287
|
function throttle(r, e) {
|
|
@@ -1485,8 +1452,8 @@ function mergeConfig(r, e) {
|
|
|
1485
1452
|
headers: (l, f) => n(headersToObject(l), headersToObject(f), !0)
|
|
1486
1453
|
};
|
|
1487
1454
|
return utils$1.forEach(Object.keys(Object.assign({}, r, e)), function(f) {
|
|
1488
|
-
const h = u[f] || n,
|
|
1489
|
-
utils$1.isUndefined(
|
|
1455
|
+
const h = u[f] || n, w = h(r[f], e[f], f);
|
|
1456
|
+
utils$1.isUndefined(w) && h !== a || (t[f] = w);
|
|
1490
1457
|
}), t;
|
|
1491
1458
|
}
|
|
1492
1459
|
const resolveConfig = (r) => {
|
|
@@ -1515,9 +1482,9 @@ const resolveConfig = (r) => {
|
|
|
1515
1482
|
const n = resolveConfig(r);
|
|
1516
1483
|
let o = n.data;
|
|
1517
1484
|
const i = AxiosHeaders$1.from(n.headers).normalize();
|
|
1518
|
-
let { responseType: a, onUploadProgress: u, onDownloadProgress: l } = n, f, h,
|
|
1485
|
+
let { responseType: a, onUploadProgress: u, onDownloadProgress: l } = n, f, h, w, b, d;
|
|
1519
1486
|
function g() {
|
|
1520
|
-
|
|
1487
|
+
b && b(), d && d(), n.cancelToken && n.cancelToken.unsubscribe(f), n.signal && n.signal.removeEventListener("abort", f);
|
|
1521
1488
|
}
|
|
1522
1489
|
let p = new XMLHttpRequest();
|
|
1523
1490
|
p.open(n.method.toUpperCase(), n.url, !0), p.timeout = n.timeout;
|
|
@@ -1526,7 +1493,7 @@ const resolveConfig = (r) => {
|
|
|
1526
1493
|
return;
|
|
1527
1494
|
const S = AxiosHeaders$1.from(
|
|
1528
1495
|
"getAllResponseHeaders" in p && p.getAllResponseHeaders()
|
|
1529
|
-
),
|
|
1496
|
+
), R = {
|
|
1530
1497
|
data: !a || a === "text" || a === "json" ? p.responseText : p.response,
|
|
1531
1498
|
status: p.status,
|
|
1532
1499
|
statusText: p.statusText,
|
|
@@ -1538,7 +1505,7 @@ const resolveConfig = (r) => {
|
|
|
1538
1505
|
t(C), g();
|
|
1539
1506
|
}, function(C) {
|
|
1540
1507
|
s(C), g();
|
|
1541
|
-
},
|
|
1508
|
+
}, R), p = null;
|
|
1542
1509
|
}
|
|
1543
1510
|
"onloadend" in p ? p.onloadend = D : p.onreadystatechange = function() {
|
|
1544
1511
|
!p || p.readyState !== 4 || p.status === 0 && !(p.responseURL && p.responseURL.indexOf("file:") === 0) || setTimeout(D);
|
|
@@ -1548,16 +1515,16 @@ const resolveConfig = (r) => {
|
|
|
1548
1515
|
s(new AxiosError("Network Error", AxiosError.ERR_NETWORK, r, p)), p = null;
|
|
1549
1516
|
}, p.ontimeout = function() {
|
|
1550
1517
|
let O = n.timeout ? "timeout of " + n.timeout + "ms exceeded" : "timeout exceeded";
|
|
1551
|
-
const
|
|
1518
|
+
const R = n.transitional || transitionalDefaults;
|
|
1552
1519
|
n.timeoutErrorMessage && (O = n.timeoutErrorMessage), s(new AxiosError(
|
|
1553
1520
|
O,
|
|
1554
|
-
|
|
1521
|
+
R.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
1555
1522
|
r,
|
|
1556
1523
|
p
|
|
1557
1524
|
)), p = null;
|
|
1558
|
-
}, o === void 0 && i.setContentType(null), "setRequestHeader" in p && utils$1.forEach(i.toJSON(), function(O,
|
|
1559
|
-
p.setRequestHeader(
|
|
1560
|
-
}), utils$1.isUndefined(n.withCredentials) || (p.withCredentials = !!n.withCredentials), a && a !== "json" && (p.responseType = n.responseType), l && ([
|
|
1525
|
+
}, o === void 0 && i.setContentType(null), "setRequestHeader" in p && utils$1.forEach(i.toJSON(), function(O, R) {
|
|
1526
|
+
p.setRequestHeader(R, O);
|
|
1527
|
+
}), utils$1.isUndefined(n.withCredentials) || (p.withCredentials = !!n.withCredentials), a && a !== "json" && (p.responseType = n.responseType), l && ([w, d] = progressEventReducer(l, !0), p.addEventListener("progress", w)), u && p.upload && ([h, b] = progressEventReducer(u), p.upload.addEventListener("progress", h), p.upload.addEventListener("loadend", b)), (n.cancelToken || n.signal) && (f = (S) => {
|
|
1561
1528
|
p && (s(!S || S.type ? new CanceledError(null, r, p) : S), p.abort(), p = null);
|
|
1562
1529
|
}, n.cancelToken && n.cancelToken.subscribe(f), n.signal && (n.signal.aborted ? f() : n.signal.addEventListener("abort", f)));
|
|
1563
1530
|
const A = parseProtocol(n.url);
|
|
@@ -1633,8 +1600,8 @@ const resolveConfig = (r) => {
|
|
|
1633
1600
|
}
|
|
1634
1601
|
let h = f.byteLength;
|
|
1635
1602
|
if (t) {
|
|
1636
|
-
let
|
|
1637
|
-
t(
|
|
1603
|
+
let w = o += h;
|
|
1604
|
+
t(w);
|
|
1638
1605
|
}
|
|
1639
1606
|
u.enqueue(new Uint8Array(f));
|
|
1640
1607
|
} catch (l) {
|
|
@@ -1703,34 +1670,34 @@ const getBodyLength = async (r) => {
|
|
|
1703
1670
|
responseType: l,
|
|
1704
1671
|
headers: f,
|
|
1705
1672
|
withCredentials: h = "same-origin",
|
|
1706
|
-
fetchOptions:
|
|
1673
|
+
fetchOptions: w
|
|
1707
1674
|
} = resolveConfig(r);
|
|
1708
1675
|
l = l ? (l + "").toLowerCase() : "text";
|
|
1709
|
-
let
|
|
1710
|
-
const g =
|
|
1711
|
-
|
|
1676
|
+
let b = composeSignals$1([n, o && o.toAbortSignal()], i), d;
|
|
1677
|
+
const g = b && b.unsubscribe && (() => {
|
|
1678
|
+
b.unsubscribe();
|
|
1712
1679
|
});
|
|
1713
1680
|
let p;
|
|
1714
1681
|
try {
|
|
1715
1682
|
if (u && supportsRequestStream && t !== "get" && t !== "head" && (p = await resolveBodyLength(f, s)) !== 0) {
|
|
1716
|
-
let
|
|
1683
|
+
let R = new Request(e, {
|
|
1717
1684
|
method: "POST",
|
|
1718
1685
|
body: s,
|
|
1719
1686
|
duplex: "half"
|
|
1720
1687
|
}), T;
|
|
1721
|
-
if (utils$1.isFormData(s) && (T =
|
|
1688
|
+
if (utils$1.isFormData(s) && (T = R.headers.get("content-type")) && f.setContentType(T), R.body) {
|
|
1722
1689
|
const [C, N] = progressEventDecorator(
|
|
1723
1690
|
p,
|
|
1724
1691
|
progressEventReducer(asyncDecorator(u))
|
|
1725
1692
|
);
|
|
1726
|
-
s = trackStream(
|
|
1693
|
+
s = trackStream(R.body, DEFAULT_CHUNK_SIZE, C, N);
|
|
1727
1694
|
}
|
|
1728
1695
|
}
|
|
1729
1696
|
utils$1.isString(h) || (h = h ? "include" : "omit");
|
|
1730
1697
|
const D = "credentials" in Request.prototype;
|
|
1731
1698
|
d = new Request(e, {
|
|
1732
|
-
...
|
|
1733
|
-
signal:
|
|
1699
|
+
...w,
|
|
1700
|
+
signal: b,
|
|
1734
1701
|
method: t.toUpperCase(),
|
|
1735
1702
|
headers: f.normalize().toJSON(),
|
|
1736
1703
|
body: s,
|
|
@@ -1740,9 +1707,9 @@ const getBodyLength = async (r) => {
|
|
|
1740
1707
|
let A = await fetch(d);
|
|
1741
1708
|
const S = supportsResponseStream && (l === "stream" || l === "response");
|
|
1742
1709
|
if (supportsResponseStream && (a || S && g)) {
|
|
1743
|
-
const
|
|
1744
|
-
["status", "statusText", "headers"].forEach((
|
|
1745
|
-
|
|
1710
|
+
const R = {};
|
|
1711
|
+
["status", "statusText", "headers"].forEach((v) => {
|
|
1712
|
+
R[v] = A[v];
|
|
1746
1713
|
});
|
|
1747
1714
|
const T = utils$1.toFiniteNumber(A.headers.get("content-length")), [C, N] = a && progressEventDecorator(
|
|
1748
1715
|
T,
|
|
@@ -1752,13 +1719,13 @@ const getBodyLength = async (r) => {
|
|
|
1752
1719
|
trackStream(A.body, DEFAULT_CHUNK_SIZE, C, () => {
|
|
1753
1720
|
N && N(), g && g();
|
|
1754
1721
|
}),
|
|
1755
|
-
|
|
1722
|
+
R
|
|
1756
1723
|
);
|
|
1757
1724
|
}
|
|
1758
1725
|
l = l || "text";
|
|
1759
1726
|
let O = await resolvers[utils$1.findKey(resolvers, l) || "text"](A, r);
|
|
1760
|
-
return !S && g && g(), await new Promise((
|
|
1761
|
-
settle(
|
|
1727
|
+
return !S && g && g(), await new Promise((R, T) => {
|
|
1728
|
+
settle(R, T, {
|
|
1762
1729
|
data: O,
|
|
1763
1730
|
headers: AxiosHeaders$1.from(A.headers),
|
|
1764
1731
|
status: A.status,
|
|
@@ -1952,30 +1919,30 @@ class Axios {
|
|
|
1952
1919
|
this.interceptors.response.forEach(function(g) {
|
|
1953
1920
|
l.push(g.fulfilled, g.rejected);
|
|
1954
1921
|
});
|
|
1955
|
-
let f, h = 0,
|
|
1922
|
+
let f, h = 0, w;
|
|
1956
1923
|
if (!u) {
|
|
1957
1924
|
const d = [dispatchRequest.bind(this), void 0];
|
|
1958
|
-
for (d.unshift.apply(d, a), d.push.apply(d, l),
|
|
1925
|
+
for (d.unshift.apply(d, a), d.push.apply(d, l), w = d.length, f = Promise.resolve(t); h < w; )
|
|
1959
1926
|
f = f.then(d[h++], d[h++]);
|
|
1960
1927
|
return f;
|
|
1961
1928
|
}
|
|
1962
|
-
|
|
1963
|
-
let
|
|
1964
|
-
for (h = 0; h <
|
|
1929
|
+
w = a.length;
|
|
1930
|
+
let b = t;
|
|
1931
|
+
for (h = 0; h < w; ) {
|
|
1965
1932
|
const d = a[h++], g = a[h++];
|
|
1966
1933
|
try {
|
|
1967
|
-
|
|
1934
|
+
b = d(b);
|
|
1968
1935
|
} catch (p) {
|
|
1969
1936
|
g.call(this, p);
|
|
1970
1937
|
break;
|
|
1971
1938
|
}
|
|
1972
1939
|
}
|
|
1973
1940
|
try {
|
|
1974
|
-
f = dispatchRequest.call(this,
|
|
1941
|
+
f = dispatchRequest.call(this, b);
|
|
1975
1942
|
} catch (d) {
|
|
1976
1943
|
return Promise.reject(d);
|
|
1977
1944
|
}
|
|
1978
|
-
for (h = 0,
|
|
1945
|
+
for (h = 0, w = l.length; h < w; )
|
|
1979
1946
|
f = f.then(l[h++], l[h++]);
|
|
1980
1947
|
return f;
|
|
1981
1948
|
}
|
|
@@ -2302,29 +2269,29 @@ class SaveRequest {
|
|
|
2302
2269
|
return t.some((s) => s.url === e);
|
|
2303
2270
|
}
|
|
2304
2271
|
}
|
|
2305
|
-
const
|
|
2272
|
+
const x = class x {
|
|
2306
2273
|
};
|
|
2307
|
-
c(
|
|
2274
|
+
c(x, "events", (e, t, s, n = "") => new Promise((o, i) => {
|
|
2308
2275
|
let a = 0;
|
|
2309
2276
|
for (let [u, l] of s)
|
|
2310
2277
|
a++, e === "add" ? t.addEventListener(u, l) : t.removeEventListener(u, l), a === s.length && o("");
|
|
2311
|
-
})), c(
|
|
2312
|
-
e.sort((s, n) =>
|
|
2313
|
-
}), c(
|
|
2314
|
-
}), c(
|
|
2315
|
-
let [t, s] =
|
|
2278
|
+
})), c(x, "sortDataByAlphabet", (e, t) => e.sort((s, n) => n[t].trim() < s[t].trim() ? 1 : -1)), c(x, "sortDataByDate", (e, t) => {
|
|
2279
|
+
e.sort((s, n) => x.hasDateLessPeriod(n[t], s[t]) ? 1 : -1);
|
|
2280
|
+
}), c(x, "sortDataByDateAndTime", (e, t) => {
|
|
2281
|
+
}), c(x, "splitDateFromTime", (e) => e.split(" ")), c(x, "reverseDate", (e) => {
|
|
2282
|
+
let [t, s] = x.splitDateFromTime(e);
|
|
2316
2283
|
return t.split(".").reverse().join("-");
|
|
2317
|
-
}), c(
|
|
2284
|
+
}), c(x, "correctionDataISO8601", (e) => {
|
|
2318
2285
|
let t = "";
|
|
2319
2286
|
if (/^\d{2}\.\d{2}\.\d{4}$/.test(e) || /^\d{2}\.\d{2}\.\d{4}\s\d{2}:\d{2}$/.test(e))
|
|
2320
|
-
t =
|
|
2287
|
+
t = x.reverseDate(e);
|
|
2321
2288
|
else if (/^\d{4}-\d{2}-\d{2}$/.test(e))
|
|
2322
2289
|
t = e;
|
|
2323
2290
|
else
|
|
2324
2291
|
throw new Error(`функция correctionDataISO8601 >> date не корректна: ${e}. Требуется один из форматов: дд.мм.гггг | дд.мм.гггг мм:чч | гггг-мм-дд `);
|
|
2325
2292
|
return t;
|
|
2326
|
-
}), c(
|
|
2327
|
-
if (e =
|
|
2293
|
+
}), c(x, "hasDateLessPeriod", (e, t, s) => {
|
|
2294
|
+
if (e = x.correctionDataISO8601(e), t = x.correctionDataISO8601(t), !s || s && !s.dateMinMax || (s == null ? void 0 : s.dateMinMax) === "<=")
|
|
2328
2295
|
return Math.floor(Number(new Date(e))) <= Math.floor(Number(new Date(t)));
|
|
2329
2296
|
if (s && (s == null ? void 0 : s.dateMinMax) === ">=")
|
|
2330
2297
|
return Math.floor(Number(new Date(e))) >= Math.floor(Number(new Date(t)));
|
|
@@ -2332,31 +2299,31 @@ c(R, "events", (e, t, s, n = "") => new Promise((o, i) => {
|
|
|
2332
2299
|
return Math.floor(Number(new Date(e))) < Math.floor(Number(new Date(t)));
|
|
2333
2300
|
if (s && (s == null ? void 0 : s.dateMinMax) === ">")
|
|
2334
2301
|
return Math.floor(Number(new Date(e))) > Math.floor(Number(new Date(t)));
|
|
2335
|
-
}), c(
|
|
2302
|
+
}), c(x, "getEndsWithArr", (e, t) => e.slice(-t)), c(x, "deepMerge", (...e) => {
|
|
2336
2303
|
const t = {}, s = (n) => {
|
|
2337
2304
|
for (const o in n)
|
|
2338
|
-
Object.prototype.hasOwnProperty.call(n, o) && (Object.prototype.toString.call(n[o]) === "[object Object]" ? t[o] =
|
|
2305
|
+
Object.prototype.hasOwnProperty.call(n, o) && (Object.prototype.toString.call(n[o]) === "[object Object]" ? t[o] = x.deepMerge(t[o], n[o]) : t[o] = n[o]);
|
|
2339
2306
|
};
|
|
2340
2307
|
for (let n = 0; n < e.length; n++)
|
|
2341
2308
|
s(e[n]);
|
|
2342
2309
|
return t;
|
|
2343
|
-
}), c(
|
|
2310
|
+
}), c(x, "isJSON", (e) => {
|
|
2344
2311
|
try {
|
|
2345
2312
|
JSON.parse(e);
|
|
2346
2313
|
} catch {
|
|
2347
2314
|
return !1;
|
|
2348
2315
|
}
|
|
2349
2316
|
return !0;
|
|
2350
|
-
}), c(
|
|
2317
|
+
}), c(x, "filterItems", (e, t) => e.filter((s) => s.name.toLowerCase().includes(t.toLowerCase()))), c(x, "sortByOnline", (e) => {
|
|
2351
2318
|
const t = [], s = [];
|
|
2352
2319
|
for (let i = 0; e.length > i; i++) {
|
|
2353
2320
|
const a = e[i];
|
|
2354
2321
|
a.online ? t.push(a) : s.push(a);
|
|
2355
2322
|
}
|
|
2356
|
-
const n =
|
|
2323
|
+
const n = x.sortDataByAlphabet(t, "name"), o = x.sortDataByAlphabet(s, "name");
|
|
2357
2324
|
return [...n, ...o];
|
|
2358
2325
|
});
|
|
2359
|
-
let Utils =
|
|
2326
|
+
let Utils = x;
|
|
2360
2327
|
const E = class E {
|
|
2361
2328
|
constructor() {
|
|
2362
2329
|
c(this, "getDecodingError", () => ({
|
|
@@ -2376,7 +2343,7 @@ const E = class E {
|
|
|
2376
2343
|
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) => {
|
|
2377
2344
|
E.requestUploadToken = e;
|
|
2378
2345
|
}), c(E, "requestInServer", (e, t = {}) => new Promise((s, n) => {
|
|
2379
|
-
var
|
|
2346
|
+
var w;
|
|
2380
2347
|
let o = { url: e, statusCode: 0, data: {}, res: {} };
|
|
2381
2348
|
const i = {
|
|
2382
2349
|
method: "get",
|
|
@@ -2392,9 +2359,9 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2392
2359
|
request: a,
|
|
2393
2360
|
errExt: { message: l, status: u }
|
|
2394
2361
|
}, { cordova: h } = window;
|
|
2395
|
-
if (h != null && h.cordova && ((
|
|
2396
|
-
const { http:
|
|
2397
|
-
"Content-Type" in (a == null ? void 0 : a.headers) && ((a == null ? void 0 : a.headers["Content-Type"]) === "multipart/form-data" &&
|
|
2362
|
+
if (h != null && h.cordova && ((w = h == null ? void 0 : h.plugin) != null && w.http)) {
|
|
2363
|
+
const { http: b } = h == null ? void 0 : h.plugin;
|
|
2364
|
+
"Content-Type" in (a == null ? void 0 : a.headers) && ((a == null ? void 0 : a.headers["Content-Type"]) === "multipart/form-data" && b.setDataSerializer("urlencoded"), (a == null ? void 0 : a.headers["Content-Type"]) === "application/json" && b.setDataSerializer("json")), b.setRequestTimeout(Number(a.timeout) / 1e3), E.registerRequest.setList({ url: e, options: a }), b.sendRequest(
|
|
2398
2365
|
e,
|
|
2399
2366
|
a,
|
|
2400
2367
|
(d) => {
|
|
@@ -2403,12 +2370,12 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2403
2370
|
o = { ...o, statusCode: p, data: D, res: d }, p === 200 && g && (E.saveToken(g), o.data = { ...o.data, token: g }), s(o);
|
|
2404
2371
|
},
|
|
2405
2372
|
(d) => {
|
|
2406
|
-
const g = E.errorsHandler.handleError(d), { url: p, status: D, headers: A, error: S, ...O } = d,
|
|
2373
|
+
const g = E.errorsHandler.handleError(d), { url: p, status: D, headers: A, error: S, ...O } = d, R = typeof S == "string" ? Utils.isJSON(S.trim()) : !1, T = {
|
|
2407
2374
|
headers: A,
|
|
2408
2375
|
status: D,
|
|
2409
2376
|
message: ""
|
|
2410
2377
|
};
|
|
2411
|
-
if (
|
|
2378
|
+
if (R) {
|
|
2412
2379
|
const C = JSON.parse(S.trim()), N = E.errorsHandler.getErrorMessageFromData(D, C);
|
|
2413
2380
|
T.message = N, T.data = C, g.msg = E.errorsHandler.gerErrorByStatusCordovaHttp(D, p);
|
|
2414
2381
|
} else
|
|
@@ -2417,12 +2384,12 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2417
2384
|
}
|
|
2418
2385
|
);
|
|
2419
2386
|
} else
|
|
2420
|
-
E.registerRequest.setList({ url: e, options: a }), axios({ url: e, ...a }).then((
|
|
2387
|
+
E.registerRequest.setList({ url: e, options: a }), axios({ url: e, ...a }).then((b) => {
|
|
2421
2388
|
E.registerRequest.removeItem(e);
|
|
2422
|
-
const d =
|
|
2423
|
-
o = { ...o, statusCode: d, data: g, res:
|
|
2424
|
-
}).catch((
|
|
2425
|
-
const d = E.errorsHandler.handleError(
|
|
2389
|
+
const d = b.status, g = b == null ? void 0 : b.data;
|
|
2390
|
+
o = { ...o, statusCode: d, data: g, res: b }, s(o);
|
|
2391
|
+
}).catch((b) => {
|
|
2392
|
+
const d = E.errorsHandler.handleError(b), { code: g, config: p, status: D, message: A, response: S, stack: O } = b, R = {
|
|
2426
2393
|
code: g,
|
|
2427
2394
|
config: p,
|
|
2428
2395
|
status: D || u,
|
|
@@ -2432,7 +2399,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2432
2399
|
data: S == null ? void 0 : S.data,
|
|
2433
2400
|
stack: O
|
|
2434
2401
|
};
|
|
2435
|
-
n({ ...f, ...d, errExt:
|
|
2402
|
+
n({ ...f, ...d, errExt: R });
|
|
2436
2403
|
});
|
|
2437
2404
|
})), c(E, "getAuthCookies", () => {
|
|
2438
2405
|
var s;
|
|
@@ -2735,8 +2702,8 @@ class NetworkStatusTracker {
|
|
|
2735
2702
|
}, { signal: (a = s.online) == null ? void 0 : a.signal }), window.addEventListener("offline", () => {
|
|
2736
2703
|
this.updateState(!1, e);
|
|
2737
2704
|
}, { signal: (u = s.offline) == null ? void 0 : u.signal }), (l = this.getConnection()) != null && l.addEventListener && this.getConnection().addEventListener("change", () => {
|
|
2738
|
-
const h = this.getConnection(),
|
|
2739
|
-
this.updateState(
|
|
2705
|
+
const h = this.getConnection(), w = this.getTypeNetwork(h, null), b = this.getIsNetwork(w);
|
|
2706
|
+
this.updateState(b, e);
|
|
2740
2707
|
}, { signal: (f = s.change) == null ? void 0 : f.signal });
|
|
2741
2708
|
}
|
|
2742
2709
|
stopEvents() {
|