dev-classes 1.4.34 → 1.4.35
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/Color.d.ts +11 -5
- package/dist/index.js +128 -134
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorProps } from './Color.types';
|
|
1
|
+
import { ColorProps, ColorRgb } from './Color.types';
|
|
2
2
|
export declare class Color {
|
|
3
3
|
private static componentToHex;
|
|
4
4
|
static rgbToHex: ColorProps["rgbToHex"];
|
|
@@ -62,14 +62,20 @@ export declare class Color {
|
|
|
62
62
|
private static generateNeon;
|
|
63
63
|
private static generateRGB;
|
|
64
64
|
private static brightColor;
|
|
65
|
-
static hslToHex(hue: number, saturation: number, lightness: number)
|
|
65
|
+
static hslToHex: (hue: number, saturation: number, lightness: number) => string;
|
|
66
66
|
private static generatePleasantColor;
|
|
67
67
|
static generate: {
|
|
68
|
-
rgb:
|
|
68
|
+
rgb: () => ColorRgb;
|
|
69
69
|
hex: () => string;
|
|
70
70
|
hexMultiple: (count: number) => string[];
|
|
71
|
-
pastelColor:
|
|
72
|
-
|
|
71
|
+
pastelColor: (config: {
|
|
72
|
+
baseColor?: string;
|
|
73
|
+
saturation?: number;
|
|
74
|
+
lightness?: number;
|
|
75
|
+
hueShift?: number;
|
|
76
|
+
randomize?: boolean;
|
|
77
|
+
}) => string;
|
|
78
|
+
neonColor: () => string;
|
|
73
79
|
brightColor: typeof Color.brightColor;
|
|
74
80
|
};
|
|
75
81
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,53 +1,26 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
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
|
-
const
|
|
4
|
+
const h = class h {
|
|
5
5
|
static isBrightAndVivid(e) {
|
|
6
6
|
const [t, s, n] = this.hexToRgb(e), o = this.rgbaToHsla(t, s, n, 1);
|
|
7
7
|
return o.l >= this.MIN_LIGHTNESS && o.s >= this.MIN_SATURATION;
|
|
8
8
|
}
|
|
9
|
-
static generateNeon() {
|
|
10
|
-
const e = [
|
|
11
|
-
Math.floor(Math.random() * 128 + 128),
|
|
12
|
-
// Яркий канал
|
|
13
|
-
Math.floor(Math.random() * 64),
|
|
14
|
-
// Темный канал
|
|
15
|
-
Math.floor(Math.random() * 64)
|
|
16
|
-
// Темный канал
|
|
17
|
-
];
|
|
18
|
-
for (let t = e.length - 1; t > 0; t--) {
|
|
19
|
-
const s = Math.floor(Math.random() * (t + 1));
|
|
20
|
-
[e[t], e[s]] = [e[s], e[t]];
|
|
21
|
-
}
|
|
22
|
-
return `#${e[0].toString(16).padStart(2, "0")}${e[1].toString(16).padStart(2, "0")}${e[2].toString(16).padStart(2, "0")}`;
|
|
23
|
-
}
|
|
24
|
-
static generateRGB() {
|
|
25
|
-
return Array.from({ length: 3 }, () => Math.floor(Math.random() * 128 + 128));
|
|
26
|
-
}
|
|
27
9
|
static brightColor(e = 1.3) {
|
|
28
10
|
let t = 0, s;
|
|
29
11
|
do {
|
|
30
|
-
const [n, o, i] =
|
|
31
|
-
if (s = `#${n.toString(16).padStart(2, "0")}${o.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`, s =
|
|
12
|
+
const [n, o, i] = h.generateRGB();
|
|
13
|
+
if (s = `#${n.toString(16).padStart(2, "0")}${o.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`, s = h.increaseSaturation(s, e), t++, t > 100)
|
|
32
14
|
break;
|
|
33
|
-
} while (!
|
|
15
|
+
} while (!h.isBrightAndVivid(s));
|
|
34
16
|
return s;
|
|
35
17
|
}
|
|
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
|
-
}
|
|
45
18
|
};
|
|
46
19
|
/*Проверить свои методы и возможно исключить т.к. функционал возможно повторяется */
|
|
47
|
-
c(
|
|
20
|
+
c(h, "componentToHex", (e) => {
|
|
48
21
|
const s = Math.max(0, Math.min(255, Math.round(e))).toString(16);
|
|
49
22
|
return s.length == 1 ? "0" + s : s;
|
|
50
|
-
}), c(
|
|
23
|
+
}), c(h, "rgbToHex", (e, t, s) => "#" + h.componentToHex(e) + h.componentToHex(t) + h.componentToHex(s)), // static rgbToHex: ColorProps["rgbToHex"] = (r: number, g: number, b: number) => {
|
|
51
24
|
// const toHex = (n: number): string => {
|
|
52
25
|
// const hex = Math.round(n).toString(16);
|
|
53
26
|
// return hex.length === 1 ? "0" + hex : hex;
|
|
@@ -58,7 +31,7 @@ c(m, "componentToHex", (e) => {
|
|
|
58
31
|
* r, g, b in [0, 255]
|
|
59
32
|
* @returns h in [0,360) and s, v in [0,1]
|
|
60
33
|
*/
|
|
61
|
-
c(
|
|
34
|
+
c(h, "rgbToHsv", (e, t, s) => {
|
|
62
35
|
e /= 255, t /= 255, s /= 255;
|
|
63
36
|
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);
|
|
64
37
|
return [60 * (i < 0 ? i + 6 : i), n && o / n, n];
|
|
@@ -68,13 +41,13 @@ c(m, "rgbToHsv", (e, t, s) => {
|
|
|
68
41
|
* @param v [0, 1]
|
|
69
42
|
* @returns r, g, b in [0, 255]
|
|
70
43
|
*/
|
|
71
|
-
c(
|
|
44
|
+
c(h, "hsvToRgb", (e, t, s) => {
|
|
72
45
|
const n = (o, i = (o + e / 60) % 6) => Math.round((s - s * t * Math.max(Math.min(i, 4 - i, 1), 0)) * 255);
|
|
73
46
|
return [n(5), n(3), n(1)];
|
|
74
47
|
}), /**
|
|
75
48
|
* @returns h [0, 360], s [0, 100], l [0, 100], a [0, 1]
|
|
76
49
|
*/
|
|
77
|
-
c(
|
|
50
|
+
c(h, "rgbaToHsla", (e, t, s, n = 1) => {
|
|
78
51
|
e /= 255, t /= 255, s /= 255;
|
|
79
52
|
const o = Math.max(e, t, s), i = Math.min(e, t, s);
|
|
80
53
|
let a = 0, u;
|
|
@@ -111,7 +84,7 @@ c(m, "rgbaToHsla", (e, t, s, n = 1) => {
|
|
|
111
84
|
* @param {number} l The lightness [0, 1]
|
|
112
85
|
* @return {Array} The RGB representation [0, 255]
|
|
113
86
|
*/
|
|
114
|
-
c(
|
|
87
|
+
c(h, "hslaToRgba", (e, t, s, n) => {
|
|
115
88
|
e /= 360, t /= 100, s /= 100;
|
|
116
89
|
let o, i, a;
|
|
117
90
|
if (t === 0)
|
|
@@ -123,10 +96,10 @@ c(m, "hslaToRgba", (e, t, s, n) => {
|
|
|
123
96
|
o = u(f, l, e + 1 / 3), i = u(f, l, e), a = u(f, l, e - 1 / 3);
|
|
124
97
|
}
|
|
125
98
|
return [o, i, a, n].map((u) => Math.round(u * 255));
|
|
126
|
-
}), c(
|
|
99
|
+
}), c(h, "hslaStringToRgba", (e) => {
|
|
127
100
|
const t = e.slice(5, -1).split(", "), s = Number(t.pop()), n = t.map((o) => o.endsWith("%") ? +o.slice(0, -1) : +o);
|
|
128
|
-
return
|
|
129
|
-
}), c(
|
|
101
|
+
return h.hslaToRgba(n[0], n[1], n[2], s);
|
|
102
|
+
}), c(h, "hexaToRgba", (e, t) => {
|
|
130
103
|
const s = [], n = e[0] === "#" ? 1 : 0;
|
|
131
104
|
if (e.length === 5 + n && (e = (n ? "#" : "") + "0" + e.slice(n)), e.length === 3 + n)
|
|
132
105
|
for (let o = n; o < e.length; ++o)
|
|
@@ -139,79 +112,100 @@ c(m, "hslaToRgba", (e, t, s, n) => {
|
|
|
139
112
|
for (let o = n; o < e.length; o += 2)
|
|
140
113
|
s.push(parseInt(e.slice(o, o + 2), 16));
|
|
141
114
|
return t && s.length === 4 && (s[3] = Math.round(s[3] / 255 * 100) / 100), s;
|
|
142
|
-
}), c(
|
|
143
|
-
const t =
|
|
144
|
-
return
|
|
145
|
-
}), c(
|
|
115
|
+
}), c(h, "hexaToHsla", (e) => {
|
|
116
|
+
const t = h.hexaToRgba(e);
|
|
117
|
+
return h.rgbaToHsla(t[0], t[1], t[2], t[3]);
|
|
118
|
+
}), c(h, "hexToRgb", (e) => h.hexaToRgba(e.slice(0, 7))), c(h, "rgbaToHexa", (e) => {
|
|
146
119
|
const t = [...e], s = t.pop(), n = Math.round(Math.min(Math.max(s ?? 1, 0), 1) * 255);
|
|
147
120
|
return "#" + t.map((o) => ("0" + o.toString(16)).slice(-2)).join("") + n.toString(16);
|
|
148
|
-
}), c(
|
|
121
|
+
}), c(h, "hslaStringToHexa", (e) => h.rgbaToHexa(h.hslaStringToRgba(e))), c(h, "hslaStringToHex", (e) => h.hslaStringToHexa(e).slice(0, -2)), /**
|
|
149
122
|
* @param weight [0, 1]
|
|
150
123
|
*/
|
|
151
|
-
c(
|
|
124
|
+
c(h, "mixColors", (e, t, s) => {
|
|
152
125
|
const n = new Array(3);
|
|
153
126
|
for (let o = 0; o < 3; ++o) {
|
|
154
127
|
const i = e[o], a = t[o];
|
|
155
128
|
n[o] = Math.floor(a + (i - a) * s);
|
|
156
129
|
}
|
|
157
130
|
return n;
|
|
158
|
-
}), c(
|
|
131
|
+
}), c(h, "getRgbByTypeBrightness", (e) => ({
|
|
159
132
|
BT601: [0.299, 0.587, 0.114],
|
|
160
133
|
BT709: [0.2126, 0.7152, 0.0722],
|
|
161
134
|
BT2020: [0.2627, 0.678, 0.0593]
|
|
162
|
-
})[e]), c(
|
|
163
|
-
const n =
|
|
164
|
-
return n[0] = Math.min(360, o[0] - n[0] + e[0]), n[1] = Math.min(1, o[1] * e[1] / n[1]), n[2] = Math.min(1, (o[2] / n[2] + i - 1) * e[2] / i), n[2] < 0.3 ? s :
|
|
165
|
-
}), c(
|
|
166
|
-
const o =
|
|
135
|
+
})[e]), c(h, "getAverageColor", (e, t) => e.map((s, n) => Math.round((s + t[n]) / 2))), c(h, "getAccentColor", (e, t, s) => {
|
|
136
|
+
const n = h.rgbToHsv(...t), o = h.rgbToHsv(...s), i = Math.min(1.5 * n[1] / e[1], 1);
|
|
137
|
+
return n[0] = Math.min(360, o[0] - n[0] + e[0]), n[1] = Math.min(1, o[1] * e[1] / n[1]), n[2] = Math.min(1, (o[2] / n[2] + i - 1) * e[2] / i), n[2] < 0.3 ? s : h.hsvToRgb(...n);
|
|
138
|
+
}), c(h, "changeColorAccent", (e, t, s, n) => {
|
|
139
|
+
const o = h.rgbToHsv(...s);
|
|
167
140
|
if (Math.min(Math.abs(o[0] - e[0]), Math.abs(o[0] - e[0] - 360)) > 30)
|
|
168
141
|
return s;
|
|
169
142
|
const a = e[1] ? Math.min(1.5 * o[1] / e[1], 1) : 0;
|
|
170
143
|
o[0] = Math.min(360, o[0] + t[0] - e[0]), o[1] = e[1] ? Math.min(1, o[1] * t[1] / e[1]) : 0, o[2] = e[2] ? Math.min(1, o[2] * (1 - a + a * t[2] / e[2])) : 0;
|
|
171
|
-
let u =
|
|
172
|
-
const l =
|
|
144
|
+
let u = h.hsvToRgb(...o);
|
|
145
|
+
const l = h.calculateBrightness(s), f = h.calculateBrightness(u);
|
|
173
146
|
if (n ? l > f : l < f) {
|
|
174
147
|
const b = 0.4 * l / f + 0.6;
|
|
175
|
-
u =
|
|
148
|
+
u = h.changeBrightness(u, b);
|
|
176
149
|
}
|
|
177
150
|
return u;
|
|
178
|
-
}), c(
|
|
179
|
-
const s =
|
|
180
|
-
return
|
|
181
|
-
}), c(
|
|
151
|
+
}), c(h, "changeBrightness", (e, t) => e.map((s) => h.clamp(Math.round(s * t), 0, 255))), c(h, "hexBrightness", (e, t) => {
|
|
152
|
+
const s = h.hexToRgb(e), n = h.changeBrightness(s, t), [o, i, a] = n;
|
|
153
|
+
return h.rgbToHex(o, i, a);
|
|
154
|
+
}), c(h, "getHexColorFromTelegramColor", (e) => {
|
|
182
155
|
const t = (e < 0 ? 16777215 + e : e).toString(16);
|
|
183
156
|
return "#" + (t.length >= 6 ? t : "0".repeat(6 - t.length) + t);
|
|
184
|
-
}), c(
|
|
157
|
+
}), c(h, "getRgbColorFromTelegramColor", (e) => h.hexToRgb(h.getHexColorFromTelegramColor(e))), c(h, "rgbaToRgb", (e, t) => {
|
|
185
158
|
const s = e[3];
|
|
186
|
-
return e.slice(0, 3).map((n, o) =>
|
|
187
|
-
}), c(
|
|
188
|
-
const [s, n, o] = e, i =
|
|
159
|
+
return e.slice(0, 3).map((n, o) => h.clamp(Math.round((s * (n / 255) + s * (t[o] / 255)) * 255), 0, 255));
|
|
160
|
+
}), c(h, "calculateBrightness", (e, t = "BT709") => {
|
|
161
|
+
const [s, n, o] = e, i = h.getRgbByTypeBrightness(t);
|
|
189
162
|
return i[0] * s / 255 + i[1] * n / 255 + i[2] * o / 255;
|
|
190
|
-
}), c(
|
|
163
|
+
}), c(h, "getTextColor", (e) => e > 0.5 ? [0, 0, 0] : [255, 255, 255]), c(h, "MIN_SATURATION", 50), c(h, "MIN_LIGHTNESS", 44), c(h, "calculateOpacity", (e, t) => {
|
|
191
164
|
const s = e > 0.5 ? 0 : 1, n = (e - s + t) / t;
|
|
192
165
|
return +Math.max(0.5, Math.min(0.64, n)).toFixed(2);
|
|
193
|
-
}), c(
|
|
166
|
+
}), c(h, "increaseSaturation", (e, t = 1.3) => {
|
|
194
167
|
if (typeof e == "string") {
|
|
195
|
-
const s =
|
|
196
|
-
return
|
|
168
|
+
const s = h.hexToRgb(e), [n, o, i] = h.rgbToHsv(...s), a = Math.min(1, o * t), u = h.hsvToRgb(n, a, i);
|
|
169
|
+
return h.rgbToHex(...u);
|
|
197
170
|
} else {
|
|
198
|
-
const [s, n, o] =
|
|
199
|
-
return
|
|
171
|
+
const [s, n, o] = h.rgbToHsv(e[0], e[1], e[2]), i = Math.min(1, n * t);
|
|
172
|
+
return h.hsvToRgb(s, i, o);
|
|
200
173
|
}
|
|
201
|
-
}), c(
|
|
174
|
+
}), c(h, "clamp", (e, t, s) => Math.min(s, Math.max(t, e))), c(h, "isHex", (e) => {
|
|
202
175
|
if (typeof e != "string")
|
|
203
176
|
return !1;
|
|
204
177
|
const t = e.replace(/^#/, "");
|
|
205
178
|
return /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(t);
|
|
206
|
-
}), c(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
179
|
+
}), c(h, "generateHex", () => `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`), c(h, "generateHexMultiple", (e) => Array.from({ length: e }, () => h.generateHex())), c(h, "generateNeon", () => {
|
|
180
|
+
const e = [
|
|
181
|
+
Math.floor(Math.random() * 128 + 128),
|
|
182
|
+
// Яркий канал
|
|
183
|
+
Math.floor(Math.random() * 64),
|
|
184
|
+
// Темный канал
|
|
185
|
+
Math.floor(Math.random() * 64)
|
|
186
|
+
// Темный канал
|
|
187
|
+
];
|
|
188
|
+
for (let t = e.length - 1; t > 0; t--) {
|
|
189
|
+
const s = Math.floor(Math.random() * (t + 1));
|
|
190
|
+
[e[t], e[s]] = [e[s], e[t]];
|
|
191
|
+
}
|
|
192
|
+
return `#${e[0].toString(16).padStart(2, "0")}${e[1].toString(16).padStart(2, "0")}${e[2].toString(16).padStart(2, "0")}`;
|
|
193
|
+
}), c(h, "generateRGB", () => Array.from({ length: 3 }, () => Math.floor(Math.random() * 128 + 128))), c(h, "hslToHex", (e, t, s) => {
|
|
194
|
+
const n = h.hslaToRgba(e, t, s, 1), [o, i, a] = n.slice(0, 3);
|
|
195
|
+
return h.rgbToHex(o, i, a);
|
|
196
|
+
}), c(h, "generatePleasantColor", (e = {}) => {
|
|
197
|
+
const { baseColor: t, saturation: s = 50, lightness: n = 50, hueShift: o = 0, randomize: i = !1 } = e;
|
|
198
|
+
let a, u, l;
|
|
199
|
+
return t ? (a = (h.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))), h.hslToHex(a, u, l);
|
|
200
|
+
}), c(h, "generate", {
|
|
201
|
+
rgb: h.generateRGB,
|
|
202
|
+
hex: h.generateHex,
|
|
203
|
+
hexMultiple: h.generateHexMultiple,
|
|
204
|
+
pastelColor: h.generatePleasantColor,
|
|
205
|
+
neonColor: h.generateNeon,
|
|
206
|
+
brightColor: h.brightColor
|
|
213
207
|
});
|
|
214
|
-
let Color =
|
|
208
|
+
let Color = h;
|
|
215
209
|
const itemsMonths = ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"], itemsWeek = ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"], _DateProcessing = class _DateProcessing {
|
|
216
210
|
};
|
|
217
211
|
c(_DateProcessing, "getActiveColorClassInDiffDate", (r, e, t) => {
|
|
@@ -346,19 +340,19 @@ class DelaysPromise {
|
|
|
346
340
|
interval: 5e3
|
|
347
341
|
});
|
|
348
342
|
c(this, "startActionEvery", (e, t = this.defaultProps) => {
|
|
349
|
-
const s = (
|
|
350
|
-
t != null && t.watchIdInterval && (t == null || t.watchIdInterval(
|
|
351
|
-
}, n = (
|
|
352
|
-
t != null && t.controlAction && (t == null || t.controlAction(
|
|
343
|
+
const s = (m) => {
|
|
344
|
+
t != null && t.watchIdInterval && (t == null || t.watchIdInterval(m));
|
|
345
|
+
}, n = (m) => {
|
|
346
|
+
t != null && t.controlAction && (t == null || t.controlAction(m));
|
|
353
347
|
};
|
|
354
348
|
let o = !0, i, a, u;
|
|
355
|
-
const l = (
|
|
349
|
+
const l = (m = !0) => {
|
|
356
350
|
const w = "Ручное завершение startActionEvery";
|
|
357
|
-
o = !1, clearInterval(i), s(null),
|
|
351
|
+
o = !1, clearInterval(i), s(null), m ? a && a({ status: m, msg: w + ": (true)" }) : u && u({ status: m, msg: w + ": (false)" });
|
|
358
352
|
};
|
|
359
353
|
return {
|
|
360
|
-
promise: new Promise((
|
|
361
|
-
a =
|
|
354
|
+
promise: new Promise((m, w) => {
|
|
355
|
+
a = m, u = w;
|
|
362
356
|
let b = 0, d = 0;
|
|
363
357
|
i = setInterval(
|
|
364
358
|
() => {
|
|
@@ -366,7 +360,7 @@ class DelaysPromise {
|
|
|
366
360
|
o = !1, clearInterval(i), s(null), w({ status: !1, msg: Error("Время загрузки истекло") });
|
|
367
361
|
return;
|
|
368
362
|
}
|
|
369
|
-
e() && (o = !1, clearInterval(i), s(null),
|
|
363
|
+
e() && (o = !1, clearInterval(i), s(null), m({ status: !0, msg: "cb вернул true" }));
|
|
370
364
|
},
|
|
371
365
|
t.interval < 200 ? 200 : t.interval
|
|
372
366
|
), s(i), n({
|
|
@@ -785,16 +779,16 @@ function toFormData(r, e, t) {
|
|
|
785
779
|
}
|
|
786
780
|
return isVisitable(d) ? !0 : (e.append(renderKey(p, g, o), l(d)), !1);
|
|
787
781
|
}
|
|
788
|
-
const
|
|
782
|
+
const m = [], w = Object.assign(predicates, {
|
|
789
783
|
defaultVisitor: f,
|
|
790
784
|
convertValue: l,
|
|
791
785
|
isVisitable
|
|
792
786
|
});
|
|
793
787
|
function b(d, g) {
|
|
794
788
|
if (!utils$1.isUndefined(d)) {
|
|
795
|
-
if (
|
|
789
|
+
if (m.indexOf(d) !== -1)
|
|
796
790
|
throw Error("Circular reference detected in " + g.join("."));
|
|
797
|
-
|
|
791
|
+
m.push(d), utils$1.forEach(d, function(D, A) {
|
|
798
792
|
(!(utils$1.isUndefined(D) || D === null) && n.call(
|
|
799
793
|
e,
|
|
800
794
|
D,
|
|
@@ -802,7 +796,7 @@ function toFormData(r, e, t) {
|
|
|
802
796
|
g,
|
|
803
797
|
w
|
|
804
798
|
)) === !0 && b(D, g ? g.concat(A) : [A]);
|
|
805
|
-
}),
|
|
799
|
+
}), m.pop();
|
|
806
800
|
}
|
|
807
801
|
}
|
|
808
802
|
if (!utils$1.isObject(r))
|
|
@@ -1118,8 +1112,8 @@ class AxiosHeaders {
|
|
|
1118
1112
|
const f = normalizeHeader(u);
|
|
1119
1113
|
if (!f)
|
|
1120
1114
|
throw new Error("header name must be a non-empty string");
|
|
1121
|
-
const
|
|
1122
|
-
(!
|
|
1115
|
+
const m = utils$1.findKey(n, f);
|
|
1116
|
+
(!m || n[m] === void 0 || l === !0 || l === void 0 && n[m] !== !1) && (n[m || u] = normalizeValue(a));
|
|
1123
1117
|
}
|
|
1124
1118
|
const i = (a, u) => utils$1.forEach(a, (l, f) => o(l, f, u));
|
|
1125
1119
|
if (utils$1.isPlainObject(e) || e instanceof this.constructor)
|
|
@@ -1275,9 +1269,9 @@ function speedometer(r, e) {
|
|
|
1275
1269
|
return e = e !== void 0 ? e : 1e3, function(u) {
|
|
1276
1270
|
const l = Date.now(), f = s[o];
|
|
1277
1271
|
i || (i = l), t[n] = u, s[n] = l;
|
|
1278
|
-
let
|
|
1279
|
-
for (;
|
|
1280
|
-
w += t[
|
|
1272
|
+
let m = o, w = 0;
|
|
1273
|
+
for (; m !== n; )
|
|
1274
|
+
w += t[m++], m = m % r;
|
|
1281
1275
|
if (n = (n + 1) % r, n === o && (o = (o + 1) % r), l - i < e)
|
|
1282
1276
|
return;
|
|
1283
1277
|
const b = f && l - f;
|
|
@@ -1290,10 +1284,10 @@ function throttle(r, e) {
|
|
|
1290
1284
|
t = f, n = null, o && (clearTimeout(o), o = null), r.apply(null, l);
|
|
1291
1285
|
};
|
|
1292
1286
|
return [(...l) => {
|
|
1293
|
-
const f = Date.now(),
|
|
1294
|
-
|
|
1287
|
+
const f = Date.now(), m = f - t;
|
|
1288
|
+
m >= s ? i(l, f) : (n = l, o || (o = setTimeout(() => {
|
|
1295
1289
|
o = null, i(n);
|
|
1296
|
-
}, s -
|
|
1290
|
+
}, s - m)));
|
|
1297
1291
|
}, () => n && i(n)];
|
|
1298
1292
|
}
|
|
1299
1293
|
const progressEventReducer = (r, e, t = 3) => {
|
|
@@ -1302,7 +1296,7 @@ const progressEventReducer = (r, e, t = 3) => {
|
|
|
1302
1296
|
return throttle((o) => {
|
|
1303
1297
|
const i = o.loaded, a = o.lengthComputable ? o.total : void 0, u = i - s, l = n(u), f = i <= a;
|
|
1304
1298
|
s = i;
|
|
1305
|
-
const
|
|
1299
|
+
const m = {
|
|
1306
1300
|
loaded: i,
|
|
1307
1301
|
total: a,
|
|
1308
1302
|
progress: a ? i / a : void 0,
|
|
@@ -1313,7 +1307,7 @@ const progressEventReducer = (r, e, t = 3) => {
|
|
|
1313
1307
|
lengthComputable: a != null,
|
|
1314
1308
|
[e ? "download" : "upload"]: !0
|
|
1315
1309
|
};
|
|
1316
|
-
r(
|
|
1310
|
+
r(m);
|
|
1317
1311
|
}, t);
|
|
1318
1312
|
}, progressEventDecorator = (r, e) => {
|
|
1319
1313
|
const t = r != null;
|
|
@@ -1393,15 +1387,15 @@ const headersToObject = (r) => r instanceof AxiosHeaders$1 ? { ...r } : r;
|
|
|
1393
1387
|
function mergeConfig(r, e) {
|
|
1394
1388
|
e = e || {};
|
|
1395
1389
|
const t = {};
|
|
1396
|
-
function s(l, f,
|
|
1397
|
-
return utils$1.isPlainObject(l) && utils$1.isPlainObject(f) ? utils$1.merge.call({ caseless:
|
|
1390
|
+
function s(l, f, m) {
|
|
1391
|
+
return utils$1.isPlainObject(l) && utils$1.isPlainObject(f) ? utils$1.merge.call({ caseless: m }, l, f) : utils$1.isPlainObject(f) ? utils$1.merge({}, f) : utils$1.isArray(f) ? f.slice() : f;
|
|
1398
1392
|
}
|
|
1399
|
-
function n(l, f,
|
|
1393
|
+
function n(l, f, m) {
|
|
1400
1394
|
if (utils$1.isUndefined(f)) {
|
|
1401
1395
|
if (!utils$1.isUndefined(l))
|
|
1402
|
-
return s(void 0, l,
|
|
1396
|
+
return s(void 0, l, m);
|
|
1403
1397
|
} else
|
|
1404
|
-
return s(l, f,
|
|
1398
|
+
return s(l, f, m);
|
|
1405
1399
|
}
|
|
1406
1400
|
function o(l, f) {
|
|
1407
1401
|
if (!utils$1.isUndefined(f))
|
|
@@ -1414,10 +1408,10 @@ function mergeConfig(r, e) {
|
|
|
1414
1408
|
} else
|
|
1415
1409
|
return s(void 0, f);
|
|
1416
1410
|
}
|
|
1417
|
-
function a(l, f,
|
|
1418
|
-
if (
|
|
1411
|
+
function a(l, f, m) {
|
|
1412
|
+
if (m in e)
|
|
1419
1413
|
return s(l, f);
|
|
1420
|
-
if (
|
|
1414
|
+
if (m in r)
|
|
1421
1415
|
return s(void 0, l);
|
|
1422
1416
|
}
|
|
1423
1417
|
const u = {
|
|
@@ -1452,8 +1446,8 @@ function mergeConfig(r, e) {
|
|
|
1452
1446
|
headers: (l, f) => n(headersToObject(l), headersToObject(f), !0)
|
|
1453
1447
|
};
|
|
1454
1448
|
return utils$1.forEach(Object.keys(Object.assign({}, r, e)), function(f) {
|
|
1455
|
-
const
|
|
1456
|
-
utils$1.isUndefined(w) &&
|
|
1449
|
+
const m = u[f] || n, w = m(r[f], e[f], f);
|
|
1450
|
+
utils$1.isUndefined(w) && m !== a || (t[f] = w);
|
|
1457
1451
|
}), t;
|
|
1458
1452
|
}
|
|
1459
1453
|
const resolveConfig = (r) => {
|
|
@@ -1468,7 +1462,7 @@ const resolveConfig = (r) => {
|
|
|
1468
1462
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv)
|
|
1469
1463
|
i.setContentType(void 0);
|
|
1470
1464
|
else if ((u = i.getContentType()) !== !1) {
|
|
1471
|
-
const [l, ...f] = u ? u.split(";").map((
|
|
1465
|
+
const [l, ...f] = u ? u.split(";").map((m) => m.trim()).filter(Boolean) : [];
|
|
1472
1466
|
i.setContentType([l || "multipart/form-data", ...f].join("; "));
|
|
1473
1467
|
}
|
|
1474
1468
|
}
|
|
@@ -1482,7 +1476,7 @@ const resolveConfig = (r) => {
|
|
|
1482
1476
|
const n = resolveConfig(r);
|
|
1483
1477
|
let o = n.data;
|
|
1484
1478
|
const i = AxiosHeaders$1.from(n.headers).normalize();
|
|
1485
|
-
let { responseType: a, onUploadProgress: u, onDownloadProgress: l } = n, f,
|
|
1479
|
+
let { responseType: a, onUploadProgress: u, onDownloadProgress: l } = n, f, m, w, b, d;
|
|
1486
1480
|
function g() {
|
|
1487
1481
|
b && b(), d && d(), n.cancelToken && n.cancelToken.unsubscribe(f), n.signal && n.signal.removeEventListener("abort", f);
|
|
1488
1482
|
}
|
|
@@ -1524,7 +1518,7 @@ const resolveConfig = (r) => {
|
|
|
1524
1518
|
)), p = null;
|
|
1525
1519
|
}, o === void 0 && i.setContentType(null), "setRequestHeader" in p && utils$1.forEach(i.toJSON(), function(O, R) {
|
|
1526
1520
|
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 && ([
|
|
1521
|
+
}), 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 && ([m, b] = progressEventReducer(u), p.upload.addEventListener("progress", m), p.upload.addEventListener("loadend", b)), (n.cancelToken || n.signal) && (f = (S) => {
|
|
1528
1522
|
p && (s(!S || S.type ? new CanceledError(null, r, p) : S), p.abort(), p = null);
|
|
1529
1523
|
}, n.cancelToken && n.cancelToken.subscribe(f), n.signal && (n.signal.aborted ? f() : n.signal.addEventListener("abort", f)));
|
|
1530
1524
|
const A = parseProtocol(n.url);
|
|
@@ -1598,9 +1592,9 @@ const resolveConfig = (r) => {
|
|
|
1598
1592
|
a(), u.close();
|
|
1599
1593
|
return;
|
|
1600
1594
|
}
|
|
1601
|
-
let
|
|
1595
|
+
let m = f.byteLength;
|
|
1602
1596
|
if (t) {
|
|
1603
|
-
let w = o +=
|
|
1597
|
+
let w = o += m;
|
|
1604
1598
|
t(w);
|
|
1605
1599
|
}
|
|
1606
1600
|
u.enqueue(new Uint8Array(f));
|
|
@@ -1669,7 +1663,7 @@ const getBodyLength = async (r) => {
|
|
|
1669
1663
|
onUploadProgress: u,
|
|
1670
1664
|
responseType: l,
|
|
1671
1665
|
headers: f,
|
|
1672
|
-
withCredentials:
|
|
1666
|
+
withCredentials: m = "same-origin",
|
|
1673
1667
|
fetchOptions: w
|
|
1674
1668
|
} = resolveConfig(r);
|
|
1675
1669
|
l = l ? (l + "").toLowerCase() : "text";
|
|
@@ -1693,7 +1687,7 @@ const getBodyLength = async (r) => {
|
|
|
1693
1687
|
s = trackStream(R.body, DEFAULT_CHUNK_SIZE, C, N);
|
|
1694
1688
|
}
|
|
1695
1689
|
}
|
|
1696
|
-
utils$1.isString(
|
|
1690
|
+
utils$1.isString(m) || (m = m ? "include" : "omit");
|
|
1697
1691
|
const D = "credentials" in Request.prototype;
|
|
1698
1692
|
d = new Request(e, {
|
|
1699
1693
|
...w,
|
|
@@ -1702,7 +1696,7 @@ const getBodyLength = async (r) => {
|
|
|
1702
1696
|
headers: f.normalize().toJSON(),
|
|
1703
1697
|
body: s,
|
|
1704
1698
|
duplex: "half",
|
|
1705
|
-
credentials: D ?
|
|
1699
|
+
credentials: D ? m : void 0
|
|
1706
1700
|
});
|
|
1707
1701
|
let A = await fetch(d);
|
|
1708
1702
|
const S = supportsResponseStream && (l === "stream" || l === "response");
|
|
@@ -1919,17 +1913,17 @@ class Axios {
|
|
|
1919
1913
|
this.interceptors.response.forEach(function(g) {
|
|
1920
1914
|
l.push(g.fulfilled, g.rejected);
|
|
1921
1915
|
});
|
|
1922
|
-
let f,
|
|
1916
|
+
let f, m = 0, w;
|
|
1923
1917
|
if (!u) {
|
|
1924
1918
|
const d = [dispatchRequest.bind(this), void 0];
|
|
1925
|
-
for (d.unshift.apply(d, a), d.push.apply(d, l), w = d.length, f = Promise.resolve(t);
|
|
1926
|
-
f = f.then(d[
|
|
1919
|
+
for (d.unshift.apply(d, a), d.push.apply(d, l), w = d.length, f = Promise.resolve(t); m < w; )
|
|
1920
|
+
f = f.then(d[m++], d[m++]);
|
|
1927
1921
|
return f;
|
|
1928
1922
|
}
|
|
1929
1923
|
w = a.length;
|
|
1930
1924
|
let b = t;
|
|
1931
|
-
for (
|
|
1932
|
-
const d = a[
|
|
1925
|
+
for (m = 0; m < w; ) {
|
|
1926
|
+
const d = a[m++], g = a[m++];
|
|
1933
1927
|
try {
|
|
1934
1928
|
b = d(b);
|
|
1935
1929
|
} catch (p) {
|
|
@@ -1942,8 +1936,8 @@ class Axios {
|
|
|
1942
1936
|
} catch (d) {
|
|
1943
1937
|
return Promise.reject(d);
|
|
1944
1938
|
}
|
|
1945
|
-
for (
|
|
1946
|
-
f = f.then(l[
|
|
1939
|
+
for (m = 0, w = l.length; m < w; )
|
|
1940
|
+
f = f.then(l[m++], l[m++]);
|
|
1947
1941
|
return f;
|
|
1948
1942
|
}
|
|
1949
1943
|
getUri(e) {
|
|
@@ -2358,9 +2352,9 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2358
2352
|
isErr: !0,
|
|
2359
2353
|
request: a,
|
|
2360
2354
|
errExt: { message: l, status: u }
|
|
2361
|
-
}, { cordova:
|
|
2362
|
-
if (
|
|
2363
|
-
const { http: b } =
|
|
2355
|
+
}, { cordova: m } = window;
|
|
2356
|
+
if (m != null && m.cordova && ((w = m == null ? void 0 : m.plugin) != null && w.http)) {
|
|
2357
|
+
const { http: b } = m == null ? void 0 : m.plugin;
|
|
2364
2358
|
"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(
|
|
2365
2359
|
e,
|
|
2366
2360
|
a,
|
|
@@ -2564,7 +2558,7 @@ const y = class y {
|
|
|
2564
2558
|
};
|
|
2565
2559
|
if (y.events.publish("fetch", l), u) {
|
|
2566
2560
|
apiRequest.requestInServer(s, n).then((f) => {
|
|
2567
|
-
const
|
|
2561
|
+
const m = {
|
|
2568
2562
|
isReq: !1,
|
|
2569
2563
|
isReload: !0,
|
|
2570
2564
|
isErr: !1,
|
|
@@ -2572,16 +2566,16 @@ const y = class y {
|
|
|
2572
2566
|
msg: "",
|
|
2573
2567
|
...f
|
|
2574
2568
|
};
|
|
2575
|
-
y.events.publish("fetch",
|
|
2569
|
+
y.events.publish("fetch", m), o(m);
|
|
2576
2570
|
}).catch((f) => {
|
|
2577
|
-
const
|
|
2571
|
+
const m = {
|
|
2578
2572
|
//TODO: Проверить. dataErr не верно возвращает
|
|
2579
2573
|
isReq: !1,
|
|
2580
2574
|
isReload: !1,
|
|
2581
2575
|
keyAction: e,
|
|
2582
2576
|
...f
|
|
2583
2577
|
};
|
|
2584
|
-
y.events.publish("fetch",
|
|
2578
|
+
y.events.publish("fetch", m), i(m);
|
|
2585
2579
|
});
|
|
2586
2580
|
return;
|
|
2587
2581
|
}
|
|
@@ -2702,7 +2696,7 @@ class NetworkStatusTracker {
|
|
|
2702
2696
|
}, { signal: (a = s.online) == null ? void 0 : a.signal }), window.addEventListener("offline", () => {
|
|
2703
2697
|
this.updateState(!1, e);
|
|
2704
2698
|
}, { signal: (u = s.offline) == null ? void 0 : u.signal }), (l = this.getConnection()) != null && l.addEventListener && this.getConnection().addEventListener("change", () => {
|
|
2705
|
-
const
|
|
2699
|
+
const m = this.getConnection(), w = this.getTypeNetwork(m, null), b = this.getIsNetwork(w);
|
|
2706
2700
|
this.updateState(b, e);
|
|
2707
2701
|
}, { signal: (f = s.change) == null ? void 0 : f.signal });
|
|
2708
2702
|
}
|