rc-lib-ui 1.2.2 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NetworkAndSocket/Network/components/Render/Render.d.ts +2 -1
- package/dist/NetworkAndSocket/Network/components/index.d.ts +0 -1
- package/dist/NetworkAndSocket/Network/hooks/useNetworkDetection.d.ts +6 -0
- package/dist/network.css +1 -0
- package/dist/network.js +75 -0
- package/dist/react-BHpOq0xO.js +27 -0
- package/dist/socket.js +135 -156
- package/package.json +5 -1
- package/dist/NetworkAndSocket/Network/components/Detection/CustomDetection.d.ts +0 -1
- package/dist/NetworkAndSocket/Network/components/Detection/Detection.d.ts +0 -8
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SxProps } from '@mui/material';
|
|
3
|
-
|
|
3
|
+
import { UseNetworkDetectionProps } from '../../hooks/useNetworkDetection';
|
|
4
|
+
export interface NetworkWatcherRenderProps extends UseNetworkDetectionProps {
|
|
4
5
|
isTitle?: boolean;
|
|
5
6
|
className?: string;
|
|
6
7
|
sxTitle?: SxProps;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InitialStatePropsNetwork } from '../store/network.types';
|
|
2
|
+
export interface UseNetworkDetectionProps {
|
|
3
|
+
isNetwork: boolean;
|
|
4
|
+
getStatus?: (payload: InitialStatePropsNetwork["infoNetwork"]) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const useNetworkDetection: (props: UseNetworkDetectionProps) => void;
|
package/dist/network.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._watcher_1mwhz_1{pointer-events:none;overflow:hidden;position:absolute;left:0;right:0;top:0;bottom:0}._watcherItem_1mwhz_23{transition:all .3s ease;position:absolute;margin:0;left:0;right:0;top:0;bottom:0;font-size:10px;font-weight:700;text-align:center;transform:translateY(-101%);display:flex;justify-content:center;align-items:flex-end;z-index:-1}._active_1mwhz_55{transform:translateY(0)!important}._watcherItemTitle_1mwhz_63{color:#f8f8f8;text-shadow:.05em .05em .2em rgba(10,10,10,.9);letter-spacing:.4px}._watcherItemTitleSpan_1mwhz_75{background-color:#0000004d;height:100%;color:#fff;display:flex;align-items:center;padding:3px 10px;border-radius:5px;line-height:normal}
|
package/dist/network.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsxs as I, jsx as r, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import u from "classnames";
|
|
3
|
+
import _, { useRef as T, useEffect as y, useCallback as N } from "react";
|
|
4
|
+
import { c as O } from "./react-BHpOq0xO.js";
|
|
5
|
+
import { Box as a } from "@mui/system";
|
|
6
|
+
import './network.css';const p = {
|
|
7
|
+
isNetwork: null,
|
|
8
|
+
typeNetwork: "",
|
|
9
|
+
infoNetwork: {
|
|
10
|
+
online: "",
|
|
11
|
+
offline: "",
|
|
12
|
+
action: "",
|
|
13
|
+
status: null,
|
|
14
|
+
titleOnline: "",
|
|
15
|
+
titleOffline: ""
|
|
16
|
+
}
|
|
17
|
+
}, x = JSON.parse(JSON.stringify(p)), c = O(() => p), v = {
|
|
18
|
+
resetState: () => c.setState(x),
|
|
19
|
+
setTypeNetwork: ({ typeNetwork: t }) => c.setState({ typeNetwork: t }),
|
|
20
|
+
setNetworkStatus: ({ isNetwork: t }) => c.setState({ isNetwork: t }),
|
|
21
|
+
setInfoNetworkStatus: ({ infoNetwork: t }) => c.setState({ infoNetwork: t })
|
|
22
|
+
}, R = {
|
|
23
|
+
getNetworkStatus: (t) => t.isNetwork,
|
|
24
|
+
getTypeNetwork: (t) => t.typeNetwork,
|
|
25
|
+
getInfoNetworkStatus: (t) => t.infoNetwork
|
|
26
|
+
}, b = (t) => c(t), z = "_watcher_1mwhz_1", F = "_watcherItem_1mwhz_23", D = "_active_1mwhz_55", j = "_watcherItemTitle_1mwhz_63", A = "_watcherItemTitleSpan_1mwhz_75", i = {
|
|
27
|
+
watcher: z,
|
|
28
|
+
watcherItem: F,
|
|
29
|
+
active: D,
|
|
30
|
+
watcherItemTitle: j,
|
|
31
|
+
watcherItemTitleSpan: A
|
|
32
|
+
}, B = (t) => {
|
|
33
|
+
const { isNetwork: e, getStatus: n } = t, l = T({ excludeFirstInit: !1 });
|
|
34
|
+
y(() => {
|
|
35
|
+
if (!e && e !== null) {
|
|
36
|
+
f("offline", { online: "", offline: "active", status: e, action: "offline", titleOffline: "Нет доступа к сети" }), l.current.excludeFirstInit = !0;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (l.current.excludeFirstInit && e !== null) {
|
|
40
|
+
f("online", { online: "active", offline: "", status: e, action: "online", titleOnline: "В сети" });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}, [e]);
|
|
44
|
+
const s = N(
|
|
45
|
+
(o) => {
|
|
46
|
+
v.setInfoNetworkStatus({ infoNetwork: o }), typeof n == "function" && n(o);
|
|
47
|
+
},
|
|
48
|
+
[n]
|
|
49
|
+
), f = N(
|
|
50
|
+
(o, w) => {
|
|
51
|
+
if (console.log("payload network: ", w), s(w), !e && o === "offline")
|
|
52
|
+
return;
|
|
53
|
+
const m = setTimeout(() => {
|
|
54
|
+
console.dir("setTimeout OfflineDetection"), s({ offline: "", online: "", status: e, action: "", titleOnline: "", titleOffline: "" }), clearTimeout(m);
|
|
55
|
+
}, 3e3);
|
|
56
|
+
},
|
|
57
|
+
[e, s]
|
|
58
|
+
);
|
|
59
|
+
}, C = ({ className: t = "", isTitle: e = !0, sxTitle: n, sx: l, sxItem: s, isNetwork: f, getStatus: o, ...w }) => {
|
|
60
|
+
B({ isNetwork: f, getStatus: o });
|
|
61
|
+
const { online: m, offline: h, action: W, titleOnline: d = "В сети", titleOffline: S = "Нет сети" } = b(R.getInfoNetworkStatus);
|
|
62
|
+
return /* @__PURE__ */ I(a, { className: u(i.watcher, t), sx: l, children: [
|
|
63
|
+
/* @__PURE__ */ r(a, { className: u(i.watcherItem, "bg-gradient bg-danger text-white", { [`${i.active}`]: h }), sx: s, children: /* @__PURE__ */ r(k, { isTitle: e, title: S, sxTitle: n }) }),
|
|
64
|
+
/* @__PURE__ */ r(a, { className: u(i.watcherItem, "bg-gradient bg-success text-white", { [`${i.active}`]: m }), sx: s, children: /* @__PURE__ */ r(k, { isTitle: e, title: d, sxTitle: n }) })
|
|
65
|
+
] });
|
|
66
|
+
}, J = _.memo(C), k = ({ isTitle: t, title: e, sxTitle: n }) => /* @__PURE__ */ r(g, { children: t && /* @__PURE__ */ r(a, { style: { marginBottom: 1 }, className: i.watcherItemTitle, sx: n, children: /* @__PURE__ */ r(a, { component: "span", className: i.watcherItemTitleSpan, children: e }) }) }), H = {
|
|
67
|
+
Render: J
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
H as Network,
|
|
71
|
+
v as networkActions,
|
|
72
|
+
R as networkSelectors,
|
|
73
|
+
c as storeNetwork,
|
|
74
|
+
b as useNetworkSelector
|
|
75
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import u from "react";
|
|
2
|
+
const S = (t) => {
|
|
3
|
+
let e;
|
|
4
|
+
const n = /* @__PURE__ */ new Set(), o = (s, r) => {
|
|
5
|
+
const c = typeof s == "function" ? s(e) : s;
|
|
6
|
+
if (!Object.is(c, e)) {
|
|
7
|
+
const g = e;
|
|
8
|
+
e = r ?? (typeof c != "object" || c === null) ? c : Object.assign({}, e, c), n.forEach((f) => f(e, g));
|
|
9
|
+
}
|
|
10
|
+
}, a = () => e, i = { setState: o, getState: a, getInitialState: () => l, subscribe: (s) => (n.add(s), () => n.delete(s)) }, l = e = t(o, a, i);
|
|
11
|
+
return i;
|
|
12
|
+
}, d = (t) => t ? S(t) : S, I = (t) => t;
|
|
13
|
+
function j(t, e = I) {
|
|
14
|
+
const n = u.useSyncExternalStore(
|
|
15
|
+
t.subscribe,
|
|
16
|
+
u.useCallback(() => e(t.getState()), [t, e]),
|
|
17
|
+
u.useCallback(() => e(t.getInitialState()), [t, e])
|
|
18
|
+
);
|
|
19
|
+
return u.useDebugValue(n), n;
|
|
20
|
+
}
|
|
21
|
+
const b = (t) => {
|
|
22
|
+
const e = d(t), n = (o) => j(e, o);
|
|
23
|
+
return Object.assign(n, e), n;
|
|
24
|
+
}, O = (t) => t ? b(t) : b;
|
|
25
|
+
export {
|
|
26
|
+
O as c
|
|
27
|
+
};
|
package/dist/socket.js
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
|
-
import './socket.css';var
|
|
2
|
-
var U = (t, e, n) => e in t ?
|
|
1
|
+
import './socket.css';var j = Object.defineProperty;
|
|
2
|
+
var U = (t, e, n) => e in t ? j(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
3
|
var R = (t, e, n) => U(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import React, { useState, useRef, useCallback, useEffect } from "react";
|
|
6
|
+
import { c as create } from "./react-BHpOq0xO.js";
|
|
6
7
|
import { styled, Collapse } from "@mui/material";
|
|
7
8
|
import cn from "classnames";
|
|
8
|
-
const
|
|
9
|
-
let e;
|
|
10
|
-
const n = /* @__PURE__ */ new Set(), o = (u, f) => {
|
|
11
|
-
const m = typeof u == "function" ? u(e) : u;
|
|
12
|
-
if (!Object.is(m, e)) {
|
|
13
|
-
const w = e;
|
|
14
|
-
e = f ?? (typeof m != "object" || m === null) ? m : Object.assign({}, e, m), n.forEach((b) => b(e, w));
|
|
15
|
-
}
|
|
16
|
-
}, r = () => e, l = { setState: o, getState: r, getInitialState: () => d, subscribe: (u) => (n.add(u), () => n.delete(u)) }, d = e = t(o, r, l);
|
|
17
|
-
return l;
|
|
18
|
-
}, createStore = (t) => t ? createStoreImpl(t) : createStoreImpl, identity = (t) => t;
|
|
19
|
-
function useStore(t, e = identity) {
|
|
20
|
-
const n = React.useSyncExternalStore(
|
|
21
|
-
t.subscribe,
|
|
22
|
-
React.useCallback(() => e(t.getState()), [t, e]),
|
|
23
|
-
React.useCallback(() => e(t.getInitialState()), [t, e])
|
|
24
|
-
);
|
|
25
|
-
return React.useDebugValue(n), n;
|
|
26
|
-
}
|
|
27
|
-
const createImpl = (t) => {
|
|
28
|
-
const e = createStore(t), n = (o) => useStore(e, o);
|
|
29
|
-
return Object.assign(n, e), n;
|
|
30
|
-
}, create = (t) => t ? createImpl(t) : createImpl, initialState = {
|
|
9
|
+
const initialState = {
|
|
31
10
|
statusConnect: "disconnect",
|
|
32
11
|
isOfflineSocket: !1,
|
|
33
12
|
//Текущее состояние сокета. Зависит от события timeOffReConnect и если задаёться isDisableConnectSocket: true
|
|
@@ -418,8 +397,8 @@ c(h, "hslaToRgba", (t, e, n, o) => {
|
|
|
418
397
|
if (e === 0)
|
|
419
398
|
r = i = a = n;
|
|
420
399
|
else {
|
|
421
|
-
const l = function(
|
|
422
|
-
return w < 0 && (w += 1), w > 1 && (w -= 1), w < 0.16666666666666666 ?
|
|
400
|
+
const l = function(p, m, w) {
|
|
401
|
+
return w < 0 && (w += 1), w > 1 && (w -= 1), w < 0.16666666666666666 ? p + (m - p) * 6 * w : w < 0.5 ? m : w < 0.6666666666666666 ? p + (m - p) * (0.6666666666666666 - w) * 6 : p;
|
|
423
402
|
}, d = n < 0.5 ? n * (1 + e) : n + e - n * e, u = 2 * n - d;
|
|
424
403
|
r = l(u, d, t + 1 / 3), i = l(u, d, t), a = l(u, d, t - 1 / 3);
|
|
425
404
|
}
|
|
@@ -1045,16 +1024,16 @@ function toFormData(t, e, n) {
|
|
|
1045
1024
|
}
|
|
1046
1025
|
return isVisitable(b) ? !0 : (e.append(renderKey(S, g, i), d(b)), !1);
|
|
1047
1026
|
}
|
|
1048
|
-
const
|
|
1027
|
+
const p = [], m = Object.assign(predicates, {
|
|
1049
1028
|
defaultVisitor: u,
|
|
1050
1029
|
convertValue: d,
|
|
1051
1030
|
isVisitable
|
|
1052
1031
|
});
|
|
1053
1032
|
function w(b, g) {
|
|
1054
1033
|
if (!utils$1.isUndefined(b)) {
|
|
1055
|
-
if (
|
|
1034
|
+
if (p.indexOf(b) !== -1)
|
|
1056
1035
|
throw Error("Circular reference detected in " + g.join("."));
|
|
1057
|
-
|
|
1036
|
+
p.push(b), utils$1.forEach(b, function(S, C) {
|
|
1058
1037
|
(!(utils$1.isUndefined(S) || S === null) && r.call(
|
|
1059
1038
|
e,
|
|
1060
1039
|
S,
|
|
@@ -1062,7 +1041,7 @@ function toFormData(t, e, n) {
|
|
|
1062
1041
|
g,
|
|
1063
1042
|
m
|
|
1064
1043
|
)) === !0 && w(S, g ? g.concat(C) : [C]);
|
|
1065
|
-
}),
|
|
1044
|
+
}), p.pop();
|
|
1066
1045
|
}
|
|
1067
1046
|
}
|
|
1068
1047
|
if (!utils$1.isObject(t))
|
|
@@ -1375,13 +1354,13 @@ class AxiosHeaders {
|
|
|
1375
1354
|
set(e, n, o) {
|
|
1376
1355
|
const r = this;
|
|
1377
1356
|
function i(l, d, u) {
|
|
1378
|
-
const
|
|
1379
|
-
if (!
|
|
1357
|
+
const p = normalizeHeader(d);
|
|
1358
|
+
if (!p)
|
|
1380
1359
|
throw new Error("header name must be a non-empty string");
|
|
1381
|
-
const m = utils$1.findKey(r,
|
|
1360
|
+
const m = utils$1.findKey(r, p);
|
|
1382
1361
|
(!m || r[m] === void 0 || u === !0 || u === void 0 && r[m] !== !1) && (r[m || d] = normalizeValue(l));
|
|
1383
1362
|
}
|
|
1384
|
-
const a = (l, d) => utils$1.forEach(l, (u,
|
|
1363
|
+
const a = (l, d) => utils$1.forEach(l, (u, p) => i(u, p, d));
|
|
1385
1364
|
if (utils$1.isPlainObject(e) || e instanceof this.constructor)
|
|
1386
1365
|
a(e, n);
|
|
1387
1366
|
else if (utils$1.isString(e) && (e = e.trim()) && !isValidHeaderName(e))
|
|
@@ -1535,9 +1514,9 @@ function speedometer(t, e) {
|
|
|
1535
1514
|
return e = e !== void 0 ? e : 1e3, function(l) {
|
|
1536
1515
|
const d = Date.now(), u = o[i];
|
|
1537
1516
|
a || (a = d), n[r] = l, o[r] = d;
|
|
1538
|
-
let
|
|
1539
|
-
for (;
|
|
1540
|
-
m += n[
|
|
1517
|
+
let p = i, m = 0;
|
|
1518
|
+
for (; p !== r; )
|
|
1519
|
+
m += n[p++], p = p % t;
|
|
1541
1520
|
if (r = (r + 1) % t, r === i && (i = (i + 1) % t), d - a < e)
|
|
1542
1521
|
return;
|
|
1543
1522
|
const w = u && d - u;
|
|
@@ -1560,7 +1539,7 @@ const progressEventReducer = (t, e, n = 3) => {
|
|
|
1560
1539
|
let o = 0;
|
|
1561
1540
|
const r = speedometer(50, 250);
|
|
1562
1541
|
return throttle((i) => {
|
|
1563
|
-
const a = i.loaded, l = i.lengthComputable ? i.total : void 0, d = a - o, u = r(d),
|
|
1542
|
+
const a = i.loaded, l = i.lengthComputable ? i.total : void 0, d = a - o, u = r(d), p = a <= l;
|
|
1564
1543
|
o = a;
|
|
1565
1544
|
const m = {
|
|
1566
1545
|
loaded: a,
|
|
@@ -1568,7 +1547,7 @@ const progressEventReducer = (t, e, n = 3) => {
|
|
|
1568
1547
|
progress: l ? a / l : void 0,
|
|
1569
1548
|
bytes: d,
|
|
1570
1549
|
rate: u || void 0,
|
|
1571
|
-
estimated: u && l &&
|
|
1550
|
+
estimated: u && l && p ? (l - a) / u : void 0,
|
|
1572
1551
|
event: i,
|
|
1573
1552
|
lengthComputable: l != null,
|
|
1574
1553
|
[e ? "download" : "upload"]: !0
|
|
@@ -1653,30 +1632,30 @@ const headersToObject = (t) => t instanceof AxiosHeaders$1 ? { ...t } : t;
|
|
|
1653
1632
|
function mergeConfig(t, e) {
|
|
1654
1633
|
e = e || {};
|
|
1655
1634
|
const n = {};
|
|
1656
|
-
function o(u,
|
|
1657
|
-
return utils$1.isPlainObject(u) && utils$1.isPlainObject(
|
|
1635
|
+
function o(u, p, m) {
|
|
1636
|
+
return utils$1.isPlainObject(u) && utils$1.isPlainObject(p) ? utils$1.merge.call({ caseless: m }, u, p) : utils$1.isPlainObject(p) ? utils$1.merge({}, p) : utils$1.isArray(p) ? p.slice() : p;
|
|
1658
1637
|
}
|
|
1659
|
-
function r(u,
|
|
1660
|
-
if (utils$1.isUndefined(
|
|
1638
|
+
function r(u, p, m) {
|
|
1639
|
+
if (utils$1.isUndefined(p)) {
|
|
1661
1640
|
if (!utils$1.isUndefined(u))
|
|
1662
1641
|
return o(void 0, u, m);
|
|
1663
1642
|
} else
|
|
1664
|
-
return o(u,
|
|
1643
|
+
return o(u, p, m);
|
|
1665
1644
|
}
|
|
1666
|
-
function i(u,
|
|
1667
|
-
if (!utils$1.isUndefined(
|
|
1668
|
-
return o(void 0,
|
|
1645
|
+
function i(u, p) {
|
|
1646
|
+
if (!utils$1.isUndefined(p))
|
|
1647
|
+
return o(void 0, p);
|
|
1669
1648
|
}
|
|
1670
|
-
function a(u,
|
|
1671
|
-
if (utils$1.isUndefined(
|
|
1649
|
+
function a(u, p) {
|
|
1650
|
+
if (utils$1.isUndefined(p)) {
|
|
1672
1651
|
if (!utils$1.isUndefined(u))
|
|
1673
1652
|
return o(void 0, u);
|
|
1674
1653
|
} else
|
|
1675
|
-
return o(void 0,
|
|
1654
|
+
return o(void 0, p);
|
|
1676
1655
|
}
|
|
1677
|
-
function l(u,
|
|
1656
|
+
function l(u, p, m) {
|
|
1678
1657
|
if (m in e)
|
|
1679
|
-
return o(u,
|
|
1658
|
+
return o(u, p);
|
|
1680
1659
|
if (m in t)
|
|
1681
1660
|
return o(void 0, u);
|
|
1682
1661
|
}
|
|
@@ -1709,11 +1688,11 @@ function mergeConfig(t, e) {
|
|
|
1709
1688
|
socketPath: a,
|
|
1710
1689
|
responseEncoding: a,
|
|
1711
1690
|
validateStatus: l,
|
|
1712
|
-
headers: (u,
|
|
1691
|
+
headers: (u, p) => r(headersToObject(u), headersToObject(p), !0)
|
|
1713
1692
|
};
|
|
1714
1693
|
return utils$1.forEach(Object.keys(Object.assign({}, t, e)), function(u) {
|
|
1715
|
-
const
|
|
1716
|
-
utils$1.isUndefined(m) &&
|
|
1694
|
+
const p = d[u] || r, m = p(t[u], e[u], u);
|
|
1695
|
+
utils$1.isUndefined(m) && p !== l || (n[u] = m);
|
|
1717
1696
|
}), n;
|
|
1718
1697
|
}
|
|
1719
1698
|
const resolveConfig = (t) => {
|
|
@@ -1728,8 +1707,8 @@ const resolveConfig = (t) => {
|
|
|
1728
1707
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv)
|
|
1729
1708
|
a.setContentType(void 0);
|
|
1730
1709
|
else if ((d = a.getContentType()) !== !1) {
|
|
1731
|
-
const [u, ...
|
|
1732
|
-
a.setContentType([u || "multipart/form-data", ...
|
|
1710
|
+
const [u, ...p] = d ? d.split(";").map((m) => m.trim()).filter(Boolean) : [];
|
|
1711
|
+
a.setContentType([u || "multipart/form-data", ...p].join("; "));
|
|
1733
1712
|
}
|
|
1734
1713
|
}
|
|
1735
1714
|
if (platform.hasStandardBrowserEnv && (o && utils$1.isFunction(o) && (o = o(e)), o || o !== !1 && isURLSameOrigin(e.url))) {
|
|
@@ -1742,7 +1721,7 @@ const resolveConfig = (t) => {
|
|
|
1742
1721
|
const o = resolveConfig(t);
|
|
1743
1722
|
let r = o.data;
|
|
1744
1723
|
const i = AxiosHeaders$1.from(o.headers).normalize();
|
|
1745
|
-
let { responseType: a, onUploadProgress: l, onDownloadProgress: d } = o, u,
|
|
1724
|
+
let { responseType: a, onUploadProgress: l, onDownloadProgress: d } = o, u, p, m, w, b;
|
|
1746
1725
|
function g() {
|
|
1747
1726
|
w && w(), b && b(), o.cancelToken && o.cancelToken.unsubscribe(u), o.signal && o.signal.removeEventListener("abort", u);
|
|
1748
1727
|
}
|
|
@@ -1784,7 +1763,7 @@ const resolveConfig = (t) => {
|
|
|
1784
1763
|
)), S = null;
|
|
1785
1764
|
}, r === void 0 && i.setContentType(null), "setRequestHeader" in S && utils$1.forEach(i.toJSON(), function(A, k) {
|
|
1786
1765
|
S.setRequestHeader(k, A);
|
|
1787
|
-
}), utils$1.isUndefined(o.withCredentials) || (S.withCredentials = !!o.withCredentials), a && a !== "json" && (S.responseType = o.responseType), d && ([m, b] = progressEventReducer(d, !0), S.addEventListener("progress", m)), l && S.upload && ([
|
|
1766
|
+
}), utils$1.isUndefined(o.withCredentials) || (S.withCredentials = !!o.withCredentials), a && a !== "json" && (S.responseType = o.responseType), d && ([m, b] = progressEventReducer(d, !0), S.addEventListener("progress", m)), l && S.upload && ([p, w] = progressEventReducer(l), S.upload.addEventListener("progress", p), S.upload.addEventListener("loadend", w)), (o.cancelToken || o.signal) && (u = (A) => {
|
|
1788
1767
|
S && (n(!A || A.type ? new CanceledError(null, t, S) : A), S.abort(), S = null);
|
|
1789
1768
|
}, o.cancelToken && o.cancelToken.subscribe(u), o.signal && (o.signal.aborted ? u() : o.signal.addEventListener("abort", u)));
|
|
1790
1769
|
const D = parseProtocol(o.url);
|
|
@@ -1801,8 +1780,8 @@ const resolveConfig = (t) => {
|
|
|
1801
1780
|
const i = function(u) {
|
|
1802
1781
|
if (!r) {
|
|
1803
1782
|
r = !0, l();
|
|
1804
|
-
const
|
|
1805
|
-
o.abort(
|
|
1783
|
+
const p = u instanceof Error ? u : this.reason;
|
|
1784
|
+
o.abort(p instanceof AxiosError ? p : new CanceledError(p instanceof Error ? p.message : p));
|
|
1806
1785
|
}
|
|
1807
1786
|
};
|
|
1808
1787
|
let a = e && setTimeout(() => {
|
|
@@ -1853,17 +1832,17 @@ const resolveConfig = (t) => {
|
|
|
1853
1832
|
return new ReadableStream({
|
|
1854
1833
|
async pull(d) {
|
|
1855
1834
|
try {
|
|
1856
|
-
const { done: u, value:
|
|
1835
|
+
const { done: u, value: p } = await r.next();
|
|
1857
1836
|
if (u) {
|
|
1858
1837
|
l(), d.close();
|
|
1859
1838
|
return;
|
|
1860
1839
|
}
|
|
1861
|
-
let m =
|
|
1840
|
+
let m = p.byteLength;
|
|
1862
1841
|
if (n) {
|
|
1863
1842
|
let w = i += m;
|
|
1864
1843
|
n(w);
|
|
1865
1844
|
}
|
|
1866
|
-
d.enqueue(new Uint8Array(
|
|
1845
|
+
d.enqueue(new Uint8Array(p));
|
|
1867
1846
|
} catch (u) {
|
|
1868
1847
|
throw l(u), u;
|
|
1869
1848
|
}
|
|
@@ -1925,7 +1904,7 @@ const getBodyLength = async (t) => {
|
|
|
1925
1904
|
onDownloadProgress: l,
|
|
1926
1905
|
onUploadProgress: d,
|
|
1927
1906
|
responseType: u,
|
|
1928
|
-
headers:
|
|
1907
|
+
headers: p,
|
|
1929
1908
|
withCredentials: m = "same-origin",
|
|
1930
1909
|
fetchOptions: w
|
|
1931
1910
|
} = resolveConfig(t);
|
|
@@ -1936,13 +1915,13 @@ const getBodyLength = async (t) => {
|
|
|
1936
1915
|
});
|
|
1937
1916
|
let C;
|
|
1938
1917
|
try {
|
|
1939
|
-
if (d && supportsRequestStream && n !== "get" && n !== "head" && (C = await resolveBodyLength(
|
|
1918
|
+
if (d && supportsRequestStream && n !== "get" && n !== "head" && (C = await resolveBodyLength(p, o)) !== 0) {
|
|
1940
1919
|
let O = new Request(e, {
|
|
1941
1920
|
method: "POST",
|
|
1942
1921
|
body: o,
|
|
1943
1922
|
duplex: "half"
|
|
1944
1923
|
}), I;
|
|
1945
|
-
if (utils$1.isFormData(o) && (I = O.headers.get("content-type")) &&
|
|
1924
|
+
if (utils$1.isFormData(o) && (I = O.headers.get("content-type")) && p.setContentType(I), O.body) {
|
|
1946
1925
|
const [P, L] = progressEventDecorator(
|
|
1947
1926
|
C,
|
|
1948
1927
|
progressEventReducer(asyncDecorator(d))
|
|
@@ -1956,7 +1935,7 @@ const getBodyLength = async (t) => {
|
|
|
1956
1935
|
...w,
|
|
1957
1936
|
signal: b,
|
|
1958
1937
|
method: n.toUpperCase(),
|
|
1959
|
-
headers:
|
|
1938
|
+
headers: p.normalize().toJSON(),
|
|
1960
1939
|
body: o,
|
|
1961
1940
|
duplex: "half",
|
|
1962
1941
|
credentials: D ? m : void 0
|
|
@@ -2176,12 +2155,12 @@ class Axios {
|
|
|
2176
2155
|
this.interceptors.response.forEach(function(g) {
|
|
2177
2156
|
u.push(g.fulfilled, g.rejected);
|
|
2178
2157
|
});
|
|
2179
|
-
let
|
|
2158
|
+
let p, m = 0, w;
|
|
2180
2159
|
if (!d) {
|
|
2181
2160
|
const g = [dispatchRequest.bind(this), void 0];
|
|
2182
|
-
for (g.unshift.apply(g, l), g.push.apply(g, u), w = g.length,
|
|
2183
|
-
|
|
2184
|
-
return
|
|
2161
|
+
for (g.unshift.apply(g, l), g.push.apply(g, u), w = g.length, p = Promise.resolve(n); m < w; )
|
|
2162
|
+
p = p.then(g[m++], g[m++]);
|
|
2163
|
+
return p;
|
|
2185
2164
|
}
|
|
2186
2165
|
w = l.length;
|
|
2187
2166
|
let b = n;
|
|
@@ -2195,13 +2174,13 @@ class Axios {
|
|
|
2195
2174
|
}
|
|
2196
2175
|
}
|
|
2197
2176
|
try {
|
|
2198
|
-
|
|
2177
|
+
p = dispatchRequest.call(this, b);
|
|
2199
2178
|
} catch (g) {
|
|
2200
2179
|
return Promise.reject(g);
|
|
2201
2180
|
}
|
|
2202
2181
|
for (m = 0, w = u.length; m < w; )
|
|
2203
|
-
|
|
2204
|
-
return
|
|
2182
|
+
p = p.then(u[m++], u[m++]);
|
|
2183
|
+
return p;
|
|
2205
2184
|
}
|
|
2206
2185
|
getUri(e) {
|
|
2207
2186
|
e = mergeConfig(this.defaults, e);
|
|
@@ -2447,8 +2426,8 @@ function init(t, e) {
|
|
|
2447
2426
|
for (var i = document.cookie ? document.cookie.split("; ") : [], a = {}, l = 0; l < i.length; l++) {
|
|
2448
2427
|
var d = i[l].split("="), u = d.slice(1).join("=");
|
|
2449
2428
|
try {
|
|
2450
|
-
var
|
|
2451
|
-
if (a[
|
|
2429
|
+
var p = decodeURIComponent(d[0]);
|
|
2430
|
+
if (a[p] = t.read(u, p), r === p)
|
|
2452
2431
|
break;
|
|
2453
2432
|
} catch {
|
|
2454
2433
|
}
|
|
@@ -2580,7 +2559,7 @@ c(x, "events", (t, e, n, o = "") => new Promise((r, i) => {
|
|
|
2580
2559
|
return [...o, ...r];
|
|
2581
2560
|
});
|
|
2582
2561
|
let Utils = x;
|
|
2583
|
-
const E = class
|
|
2562
|
+
const E = class q {
|
|
2584
2563
|
constructor() {
|
|
2585
2564
|
c(this, "getDecodingError", () => ({
|
|
2586
2565
|
ERR_BAD_OPTION_VALUE: "Неправильное значение опции",
|
|
@@ -2593,7 +2572,7 @@ const E = class j {
|
|
|
2593
2572
|
}));
|
|
2594
2573
|
}
|
|
2595
2574
|
static setErrorsHandler(e) {
|
|
2596
|
-
|
|
2575
|
+
q.errorsHandler = e;
|
|
2597
2576
|
}
|
|
2598
2577
|
};
|
|
2599
2578
|
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", (t) => {
|
|
@@ -2607,7 +2586,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2607
2586
|
cookie: E.getAuthCookies()
|
|
2608
2587
|
},
|
|
2609
2588
|
timeout: 6e4
|
|
2610
|
-
}, l = Utils.deepMerge(a, e), d = 520, u = "",
|
|
2589
|
+
}, l = Utils.deepMerge(a, e), d = 520, u = "", p = {
|
|
2611
2590
|
url: t,
|
|
2612
2591
|
statusCode: d,
|
|
2613
2592
|
msg: u,
|
|
@@ -2636,7 +2615,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2636
2615
|
O.message = P, O.data = I, g.msg = E.errorsHandler.gerErrorByStatusCordovaHttp(C, S);
|
|
2637
2616
|
} else
|
|
2638
2617
|
typeof A == "string" && (O.message = A);
|
|
2639
|
-
o({ ...
|
|
2618
|
+
o({ ...p, ...g, errExt: O });
|
|
2640
2619
|
}
|
|
2641
2620
|
);
|
|
2642
2621
|
} else
|
|
@@ -2655,7 +2634,7 @@ c(E, "keyCookie", "AuthCookie"), c(E, "cookieOptions", {}), c(E, "registerReques
|
|
|
2655
2634
|
data: A == null ? void 0 : A.data,
|
|
2656
2635
|
stack: k
|
|
2657
2636
|
};
|
|
2658
|
-
o({ ...
|
|
2637
|
+
o({ ...p, ...b, errExt: T });
|
|
2659
2638
|
});
|
|
2660
2639
|
})), c(E, "getAuthCookies", () => {
|
|
2661
2640
|
var t;
|
|
@@ -2807,7 +2786,7 @@ const y = class N {
|
|
|
2807
2786
|
};
|
|
2808
2787
|
if (N.events.publish("fetch", d), l) {
|
|
2809
2788
|
apiRequest.requestInServer(o, r).then((u) => {
|
|
2810
|
-
const
|
|
2789
|
+
const p = {
|
|
2811
2790
|
isReq: !1,
|
|
2812
2791
|
isReload: !0,
|
|
2813
2792
|
isErr: !1,
|
|
@@ -2815,16 +2794,16 @@ const y = class N {
|
|
|
2815
2794
|
msg: "",
|
|
2816
2795
|
...u
|
|
2817
2796
|
};
|
|
2818
|
-
N.events.publish("fetch",
|
|
2797
|
+
N.events.publish("fetch", p), i(p);
|
|
2819
2798
|
}).catch((u) => {
|
|
2820
|
-
const
|
|
2799
|
+
const p = {
|
|
2821
2800
|
//TODO: Проверить. dataErr не верно возвращает
|
|
2822
2801
|
isReq: !1,
|
|
2823
2802
|
isReload: !1,
|
|
2824
2803
|
keyAction: e,
|
|
2825
2804
|
...u
|
|
2826
2805
|
};
|
|
2827
|
-
N.events.publish("fetch",
|
|
2806
|
+
N.events.publish("fetch", p), a(p);
|
|
2828
2807
|
});
|
|
2829
2808
|
return;
|
|
2830
2809
|
}
|
|
@@ -2920,8 +2899,8 @@ class NetworkStatusTracker {
|
|
|
2920
2899
|
change: new AbortController()
|
|
2921
2900
|
};
|
|
2922
2901
|
this.setControllersEvents(l);
|
|
2923
|
-
const d = this.getConnection(), u = this.getTypeNetwork(d, window.navigator.onLine),
|
|
2924
|
-
this.updateState(
|
|
2902
|
+
const d = this.getConnection(), u = this.getTypeNetwork(d, window.navigator.onLine), p = this.getIsNetwork(u);
|
|
2903
|
+
this.updateState(p, e), window.addEventListener("online", () => {
|
|
2925
2904
|
this.updateState(!0, e);
|
|
2926
2905
|
}, { signal: (n = l.online) == null ? void 0 : n.signal }), window.addEventListener("offline", () => {
|
|
2927
2906
|
this.updateState(!1, e);
|
|
@@ -2998,43 +2977,43 @@ class NetworkStatusTracker {
|
|
|
2998
2977
|
return this.networkInfo;
|
|
2999
2978
|
}
|
|
3000
2979
|
}
|
|
3001
|
-
const
|
|
2980
|
+
const f = class f {
|
|
3002
2981
|
static copyState(e) {
|
|
3003
2982
|
return JSON.parse(JSON.stringify(e));
|
|
3004
2983
|
}
|
|
3005
2984
|
static setState(e) {
|
|
3006
|
-
|
|
2985
|
+
f.state = { ...f.state, ...e };
|
|
3007
2986
|
}
|
|
3008
2987
|
static resetState() {
|
|
3009
|
-
|
|
2988
|
+
f.state = f.copyState(f.stateDefault);
|
|
3010
2989
|
}
|
|
3011
2990
|
static setOptions(e) {
|
|
3012
|
-
|
|
2991
|
+
f.options = { ...f.options, ...e };
|
|
3013
2992
|
}
|
|
3014
2993
|
static setStatusReConnect(e) {
|
|
3015
|
-
|
|
2994
|
+
f.setState({ isActiveReConnect: e }), f.events.publish("reConnect", e);
|
|
3016
2995
|
}
|
|
3017
2996
|
static async connect() {
|
|
3018
|
-
|
|
2997
|
+
f.wsApi.getIsInitWS() && (console.log("CONNECT WS"), f.setState({ isDisconnect: !1 }), f.wsApi.connect());
|
|
3019
2998
|
}
|
|
3020
2999
|
static disconnect() {
|
|
3021
|
-
|
|
3000
|
+
f.state.isDisconnect || (f.setState({ isDisconnect: !0 }), console.log("DISCONNECT WS"), f.wsApi.disconnect(), f.resetState(), f.events.resetSubscribers());
|
|
3022
3001
|
}
|
|
3023
3002
|
static send(e, n) {
|
|
3024
3003
|
const { action: o, ...r } = e, i = r != null && r.request_id ? r.request_id : uuid4(), a = Date.now();
|
|
3025
|
-
|
|
3004
|
+
f.wsApi.setRequestSave({
|
|
3026
3005
|
requestAction: o,
|
|
3027
3006
|
request_id: i,
|
|
3028
3007
|
requestTime: a,
|
|
3029
3008
|
payload: { action: o, ...r },
|
|
3030
3009
|
cb: n
|
|
3031
3010
|
});
|
|
3032
|
-
const l =
|
|
3011
|
+
const l = f.wsApi.getSocket();
|
|
3033
3012
|
if (!l || l.readyState !== 1) {
|
|
3034
3013
|
console.log("Нет подключения к сокету. Запрос сохранён в setRequestSave");
|
|
3035
3014
|
return;
|
|
3036
3015
|
}
|
|
3037
|
-
|
|
3016
|
+
f.wsApi.send(e);
|
|
3038
3017
|
}
|
|
3039
3018
|
static stopReConnect(e) {
|
|
3040
3019
|
console.dir("функция stop не присвоена к stopReConnect");
|
|
@@ -3047,7 +3026,7 @@ const p = class p {
|
|
|
3047
3026
|
return;
|
|
3048
3027
|
}
|
|
3049
3028
|
const i = e.action, a = e.request_id ? e.request_id : uuid4(), l = Date.now();
|
|
3050
|
-
|
|
3029
|
+
f.wsApi.setRequestSave({
|
|
3051
3030
|
requestAction: i,
|
|
3052
3031
|
request_id: a,
|
|
3053
3032
|
requestTime: l,
|
|
@@ -3060,7 +3039,7 @@ const p = class p {
|
|
|
3060
3039
|
}, n.timeout));
|
|
3061
3040
|
const u = (C) => {
|
|
3062
3041
|
w(), r(C);
|
|
3063
|
-
},
|
|
3042
|
+
}, p = (C) => {
|
|
3064
3043
|
var A;
|
|
3065
3044
|
const D = this.wsApi.findDataRequestByAction(i);
|
|
3066
3045
|
!D || ((A = C == null ? void 0 : C.request) == null ? void 0 : A.requestAction) !== D.requestAction || (w(), o({ ...C }));
|
|
@@ -3068,94 +3047,94 @@ const p = class p {
|
|
|
3068
3047
|
w(), r(new DOMException("Aborted", "AbortError"));
|
|
3069
3048
|
}, w = () => {
|
|
3070
3049
|
var C;
|
|
3071
|
-
|
|
3050
|
+
f.off("msg", p), f.off("error", u), d && clearTimeout(d), (C = n == null ? void 0 : n.signal) == null || C.removeEventListener("abort", m);
|
|
3072
3051
|
};
|
|
3073
|
-
|
|
3074
|
-
const b =
|
|
3052
|
+
f.on("msg", p), f.on("error", u), (S = n == null ? void 0 : n.signal) == null || S.addEventListener("abort", m);
|
|
3053
|
+
const b = f.wsApi.getSocket();
|
|
3075
3054
|
if (!b || b.readyState !== 1) {
|
|
3076
3055
|
const C = "Нет подключения к сокету";
|
|
3077
3056
|
console.error(C), w(), r(new Error(C));
|
|
3078
3057
|
return;
|
|
3079
3058
|
}
|
|
3080
|
-
|
|
3059
|
+
f.wsApi.send(e);
|
|
3081
3060
|
});
|
|
3082
3061
|
}
|
|
3083
3062
|
};
|
|
3084
|
-
R(
|
|
3063
|
+
R(f, "state", {
|
|
3085
3064
|
isDisconnect: !0,
|
|
3086
3065
|
isActiveReConnect: !1,
|
|
3087
3066
|
isOfflineSocket: !0,
|
|
3088
3067
|
isGotWasFirstConnection: !1,
|
|
3089
3068
|
isStartCheckNetwork: !1
|
|
3090
3069
|
//не используеться
|
|
3091
|
-
}), R(
|
|
3070
|
+
}), R(f, "options", {
|
|
3092
3071
|
isReConnectNetworkOnline: !1,
|
|
3093
3072
|
listUrlsCheckConnectNetwork: ["https://jsonplaceholder.typicode.com/posts/1"]
|
|
3094
|
-
}), R(
|
|
3073
|
+
}), R(f, "wsApi", new WsApi()), R(f, "delay", new DelaysPromise()), R(f, "networkTicker", null), R(f, "events", new EventSubscribers$1(["timeOffReConnect", "reConnect", "network"])), R(f, "saveID", {
|
|
3095
3074
|
idReConnect: null,
|
|
3096
3075
|
checkConnect: null
|
|
3097
|
-
}), R(
|
|
3098
|
-
e.status ||
|
|
3099
|
-
}), R(
|
|
3100
|
-
!
|
|
3101
|
-
|
|
3102
|
-
}), R(
|
|
3103
|
-
|
|
3104
|
-
}), R(
|
|
3076
|
+
}), R(f, "stateDefault", f.copyState(f.state)), R(f, "setInfoConnect", (e) => {
|
|
3077
|
+
e.status || f.close(), f.events.publish("timeOffReConnect", e), f.setStatusReConnect(!1);
|
|
3078
|
+
}), R(f, "online", () => {
|
|
3079
|
+
!f.state.isActiveReConnect && f.options.isReConnectNetworkOnline && /*#################-----------<{ Убрал 21.08.2025 }>------------############# */
|
|
3080
|
+
f.state.isGotWasFirstConnection && f.socketReConnect();
|
|
3081
|
+
}), R(f, "offline", () => {
|
|
3082
|
+
f.state.isActiveReConnect && f.stopReConnect(!1);
|
|
3083
|
+
}), R(f, "splitOptions", (e) => Object.entries(e).reduce(
|
|
3105
3084
|
(n, [o, r]) => {
|
|
3106
|
-
const i =
|
|
3085
|
+
const i = f.wsApi.getOptions();
|
|
3107
3086
|
return o in i ? { ...n, WsOptions: { ...n.WsOptions, [o]: r } } : { ...n, SocketApiOptions: { ...n.SocketApiOptions, [o]: r } };
|
|
3108
3087
|
},
|
|
3109
3088
|
{ WsOptions: {}, SocketApiOptions: {} }
|
|
3110
3089
|
)), /*---------------------------------------------------------------------------------------------------------------------------*/
|
|
3111
|
-
R(
|
|
3112
|
-
|
|
3113
|
-
}), R(
|
|
3114
|
-
|
|
3115
|
-
}), R(
|
|
3116
|
-
|
|
3090
|
+
R(f, "getState", () => f.state), R(f, "getOptions", () => ({ ...f.options, ...f.wsApi.getOptions() })), R(f, "on", (e, n) => {
|
|
3091
|
+
f.wsApi.events.getListNameEvents().includes(e) ? f.wsApi.events.subscribe(e, n) : f.events.subscribe(e, n);
|
|
3092
|
+
}), R(f, "off", (e, n) => {
|
|
3093
|
+
f.wsApi.events.getListNameEvents().includes(e) ? f.wsApi.events.unsubscribe(e, n) : f.events.unsubscribe(e, n);
|
|
3094
|
+
}), R(f, "getRequestSave", f.wsApi.getRequestSave), R(f, "getStatusSocket", f.wsApi.getStatusSocket), R(f, "close", () => {
|
|
3095
|
+
f.state.isActiveReConnect ? f.stopReConnect(!1) : f.wsApi.close();
|
|
3117
3096
|
}), //INFO: Проверить как часто вызываеться
|
|
3118
|
-
R(
|
|
3119
|
-
|
|
3120
|
-
}), R(
|
|
3121
|
-
const { WsOptions: n, SocketApiOptions: o } =
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
}),
|
|
3125
|
-
|
|
3097
|
+
R(f, "setNetworkStatus", (e) => {
|
|
3098
|
+
f.events.publish("network", e), e.isNetwork ? f.online() : f.offline();
|
|
3099
|
+
}), R(f, "init", (e) => {
|
|
3100
|
+
const { WsOptions: n, SocketApiOptions: o } = f.splitOptions(e);
|
|
3101
|
+
f.networkTicker = new NetworkStatusTracker(o.listUrlsCheckConnectNetwork ?? []), f.networkTicker.startEvents((r) => {
|
|
3102
|
+
f.setNetworkStatus(r);
|
|
3103
|
+
}), f.setOptions(o), f.wsApi.init(n), f.wsApi.events.subscribe("status", (r) => {
|
|
3104
|
+
f.setState({ isOfflineSocket: r !== "ready" });
|
|
3126
3105
|
});
|
|
3127
3106
|
}), /*------------------------------------------------------------------------------------------------------*/
|
|
3128
|
-
R(
|
|
3129
|
-
if (
|
|
3130
|
-
if (console.log("reConnect"),
|
|
3131
|
-
console.groupCollapsed("Процесс socketReConnect уже запущен"), console.log("SocketApi.saveID: ",
|
|
3107
|
+
R(f, "socketReConnect", () => {
|
|
3108
|
+
if (f.wsApi.getIsInitWS())
|
|
3109
|
+
if (console.log("reConnect"), f.saveID.idReConnect)
|
|
3110
|
+
console.groupCollapsed("Процесс socketReConnect уже запущен"), console.log("SocketApi.saveID: ", f.saveID), console.groupEnd();
|
|
3132
3111
|
else {
|
|
3133
|
-
|
|
3134
|
-
const { timeReConnect: e, numberOfRepit: n } =
|
|
3135
|
-
|
|
3136
|
-
() => (console.log("reconnect:>>delay"),
|
|
3112
|
+
f.setStatusReConnect(!0), f.connect();
|
|
3113
|
+
const { timeReConnect: e, numberOfRepit: n } = f.wsApi.getOptions(), r = n && n > 1 ? n - 1 : 3;
|
|
3114
|
+
f.delay.startActionEvery(
|
|
3115
|
+
() => (console.log("reconnect:>>delay"), f.wsApi.getStatusSocket() === "ready" ? (console.dir("Подключение установлено"), !0) : (f.connect(), !1)),
|
|
3137
3116
|
{
|
|
3138
3117
|
interval: e,
|
|
3139
3118
|
countAction: r,
|
|
3140
3119
|
watchIdInterval: (a) => {
|
|
3141
|
-
|
|
3120
|
+
f.saveID.idReConnect = a;
|
|
3142
3121
|
},
|
|
3143
3122
|
controlAction: ({ stop: a, getIsActiveEvent: l }) => {
|
|
3144
|
-
|
|
3123
|
+
f.stopReConnect = a;
|
|
3145
3124
|
}
|
|
3146
3125
|
}
|
|
3147
3126
|
).promise.then((a) => {
|
|
3148
|
-
|
|
3127
|
+
f.setInfoConnect(a);
|
|
3149
3128
|
}).catch((a) => {
|
|
3150
|
-
if (
|
|
3151
|
-
console.log("Сокет успел подключиться, игнорируем ошибку таймаута"),
|
|
3129
|
+
if (f.wsApi.getStatusSocket() === "ready") {
|
|
3130
|
+
console.log("Сокет успел подключиться, игнорируем ошибку таймаута"), f.setInfoConnect({ status: !0, msg: "Подключено (восстановлено)" });
|
|
3152
3131
|
return;
|
|
3153
3132
|
}
|
|
3154
|
-
|
|
3133
|
+
f.setInfoConnect(a);
|
|
3155
3134
|
});
|
|
3156
3135
|
}
|
|
3157
3136
|
});
|
|
3158
|
-
let SocketApi =
|
|
3137
|
+
let SocketApi = f;
|
|
3159
3138
|
const useRequestSocketApi = (t, e = {}) => {
|
|
3160
3139
|
const n = t.action, { skip: o = !1, timeout: r = 5e3 } = e, [i, a] = useState({
|
|
3161
3140
|
data: null,
|
|
@@ -3163,8 +3142,8 @@ const useRequestSocketApi = (t, e = {}) => {
|
|
|
3163
3142
|
isLoading: !1,
|
|
3164
3143
|
isError: !1,
|
|
3165
3144
|
isSuccess: !1
|
|
3166
|
-
}), l = useSocketSelector(socketSelectors.getStatusReady), d = useSocketSelector(socketSelectors.getStatusConnectSocket), u = useRef(null),
|
|
3167
|
-
|
|
3145
|
+
}), l = useSocketSelector(socketSelectors.getStatusReady), d = useSocketSelector(socketSelectors.getStatusConnectSocket), u = useRef(null), p = useRef(e);
|
|
3146
|
+
p.current = e;
|
|
3168
3147
|
const m = useCallback(async () => {
|
|
3169
3148
|
var S, C, D, A;
|
|
3170
3149
|
if (o) return;
|
|
@@ -3185,7 +3164,7 @@ const useRequestSocketApi = (t, e = {}) => {
|
|
|
3185
3164
|
data: k,
|
|
3186
3165
|
isSuccess: !0,
|
|
3187
3166
|
isLoading: !1
|
|
3188
|
-
})), (C = (S =
|
|
3167
|
+
})), (C = (S = p.current).onSuccess) == null || C.call(S, k);
|
|
3189
3168
|
} catch (k) {
|
|
3190
3169
|
if (g.aborted) return;
|
|
3191
3170
|
const T = k instanceof Error ? k.message : String(k);
|
|
@@ -3194,7 +3173,7 @@ const useRequestSocketApi = (t, e = {}) => {
|
|
|
3194
3173
|
error: T,
|
|
3195
3174
|
isError: !0,
|
|
3196
3175
|
isLoading: !1
|
|
3197
|
-
})), (A = (D =
|
|
3176
|
+
})), (A = (D = p.current).onError) == null || A.call(D, T);
|
|
3198
3177
|
}
|
|
3199
3178
|
}, [o, n, t, r]);
|
|
3200
3179
|
useEffect(() => (!o && l && m(), () => {
|
|
@@ -3223,19 +3202,19 @@ const useRequestSocketApi = (t, e = {}) => {
|
|
|
3223
3202
|
}, createRequestSocketApi = (t, e) => useRequestSocketApi(t, e), InitializationMemo = (t) => {
|
|
3224
3203
|
const { isNetwork: e, typeNetwork: n } = t, { isModal: o } = useSocketSelector(socketSelectors.getInfoNoConnectServer), r = useSocketSelector(socketSelectors.getStatusIsReConnectSocket), i = useSocketSelector(socketSelectors.getIsDisableConnectSocket), a = useSocketSelector(socketSelectors.getStatusConnectSocket);
|
|
3225
3204
|
return useEffect(() => (SocketApi.init(t.init), typeof t.onMount == "function" && t.onMount(), SocketApi.on("status", (l) => {
|
|
3226
|
-
const d = socketStore.getState(), { isReadySocket: u, infoNoConnectServer: { isModal:
|
|
3227
|
-
l !== "ready" && u && socketActions.setStatusReady({ isReadySocket: !1 }), !u && l === "ready" && (socketActions.setStatusReady({ isReadySocket: !0 }),
|
|
3205
|
+
const d = socketStore.getState(), { isReadySocket: u, infoNoConnectServer: { isModal: p }, isOfflineSocket: m } = d;
|
|
3206
|
+
l !== "ready" && u && socketActions.setStatusReady({ isReadySocket: !1 }), !u && l === "ready" && (socketActions.setStatusReady({ isReadySocket: !0 }), p && m && (console.log("Вырубаем модалку т.к. сокет законектился после окончания timeOffReConnect"), socketActions.setInfoNoConnectServer({ isModal: !1 }), socketActions.setIsOfflineSocket({ isOfflineSocket: !1 }))), socketActions.setStatusConnectSocket({ statusConnect: l });
|
|
3228
3207
|
}), SocketApi.on("error", (l) => {
|
|
3229
3208
|
console.log("error: ", l);
|
|
3230
3209
|
}), SocketApi.on("reConnect", (l) => {
|
|
3231
3210
|
console.log('on"reConnect" (status): ', l);
|
|
3232
|
-
const d = socketStore.getState(), { isReConnectSocket: u, infoNoConnectServer: { isModal:
|
|
3233
|
-
u !== l && socketActions.setStatusIsReConnectSocket({ isReConnectSocket: l }),
|
|
3211
|
+
const d = socketStore.getState(), { isReConnectSocket: u, infoNoConnectServer: { isModal: p } } = d;
|
|
3212
|
+
u !== l && socketActions.setStatusIsReConnectSocket({ isReConnectSocket: l }), p && l && socketActions.setInfoNoConnectServer({ isModal: !1 });
|
|
3234
3213
|
}), SocketApi.on("timeOffReConnect", (l) => {
|
|
3235
3214
|
if (console.log("timeOffReConnect: ", l), socketActions.setIsOfflineSocket({ isOfflineSocket: !l.status }), !l.status) {
|
|
3236
|
-
const d = socketStore.getState(), { infoNoConnectServer: { isModal: u, isSelectOffline:
|
|
3215
|
+
const d = socketStore.getState(), { infoNoConnectServer: { isModal: u, isSelectOffline: p } } = d;
|
|
3237
3216
|
let m = !1;
|
|
3238
|
-
!u && !
|
|
3217
|
+
!u && !p && (m = !0), m && socketActions.setInfoNoConnectServer({ isModal: m });
|
|
3239
3218
|
}
|
|
3240
3219
|
}), SocketApi.connect(), () => {
|
|
3241
3220
|
typeof t.onUnmount == "function" && t.onUnmount(), console.dir("disconnect"), SocketApi.disconnect();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rc-lib-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.10",
|
|
5
5
|
"author": "SinGlEBW",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"import": "./dist/socket.js",
|
|
18
18
|
"types": "./dist/NetworkAndSocket/Socket/index.d.ts"
|
|
19
19
|
},
|
|
20
|
+
"./network": {
|
|
21
|
+
"import": "./dist/network.js",
|
|
22
|
+
"types": "./dist/NetworkAndSocket/Network/index.d.ts"
|
|
23
|
+
},
|
|
20
24
|
"./preloaders": {
|
|
21
25
|
"import": "./dist/preloaders.js",
|
|
22
26
|
"types": "./dist/Preloaders/index.d.ts"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const CustomDetection: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { InitialStatePropsNetwork } from '../../store/network.types';
|
|
3
|
-
export interface DetectionProps extends Pick<React.HTMLAttributes<HTMLDivElement>, 'className'> {
|
|
4
|
-
profile?: 'min-bottom';
|
|
5
|
-
getStatus?: (props: InitialStatePropsNetwork['infoNetwork']) => void;
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const Detection: React.NamedExoticComponent<DetectionProps>;
|