rc-lib-ui 1.2.16-beta.3 → 1.2.16-beta.5
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SocketApi } from '../../api';
|
|
3
3
|
export interface InitializationSocketProps {
|
|
4
|
-
init:
|
|
4
|
+
init: Parameters<typeof SocketApi.init>[0];
|
|
5
5
|
isNetwork: boolean;
|
|
6
6
|
typeNetwork: string;
|
|
7
7
|
onMount?: () => void;
|
package/dist/socket.js
CHANGED
|
@@ -2,7 +2,7 @@ import './socket.css';var z = Object.defineProperty;
|
|
|
2
2
|
var F = (n, e, t) => e in n ? z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
3
|
var r = (n, e, t) => F(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { jsx as D } from "react/jsx-runtime";
|
|
5
|
-
import N, { useState as B, useRef as x, useCallback as E, useEffect as
|
|
5
|
+
import N, { useState as B, useRef as x, useCallback as E, useEffect as O } from "react";
|
|
6
6
|
import { c as U } from "./react-CLnE01WS.js";
|
|
7
7
|
import { styled as M, Collapse as G } from "@mui/material";
|
|
8
8
|
import L from "classnames";
|
|
@@ -20,14 +20,14 @@ const T = {
|
|
|
20
20
|
isSelectOffline: !1
|
|
21
21
|
//Для того что бы 2й раз окно не показывать
|
|
22
22
|
}
|
|
23
|
-
}, K = JSON.parse(JSON.stringify(T)),
|
|
24
|
-
resetState: () =>
|
|
25
|
-
setStatusConnectSocket: ({ statusConnect: n }) =>
|
|
26
|
-
setStatusIsReConnectSocket: ({ isReConnectSocket: n }) =>
|
|
27
|
-
setStatusReady: ({ isReadySocket: n }) =>
|
|
28
|
-
setIsOfflineSocket: ({ isOfflineSocket: n }) =>
|
|
29
|
-
setInfoNoConnectServer: (n) =>
|
|
30
|
-
setIsDisableConnectSocket: ({ isDisableConnectSocket: n }) =>
|
|
23
|
+
}, K = JSON.parse(JSON.stringify(T)), b = U(() => T), R = {
|
|
24
|
+
resetState: () => b.setState(K),
|
|
25
|
+
setStatusConnectSocket: ({ statusConnect: n }) => b.setState({ statusConnect: n }),
|
|
26
|
+
setStatusIsReConnectSocket: ({ isReConnectSocket: n }) => b.setState({ isReConnectSocket: n }),
|
|
27
|
+
setStatusReady: ({ isReadySocket: n }) => b.setState({ isReadySocket: n }),
|
|
28
|
+
setIsOfflineSocket: ({ isOfflineSocket: n }) => b.setState({ isOfflineSocket: n }),
|
|
29
|
+
setInfoNoConnectServer: (n) => b.setState((e) => ({ infoNoConnectServer: { ...e.infoNoConnectServer, ...n } })),
|
|
30
|
+
setIsDisableConnectSocket: ({ isDisableConnectSocket: n }) => b.setState({ isDisableConnectSocket: n })
|
|
31
31
|
}, k = {
|
|
32
32
|
getStatusConnectSocket: (n) => n.statusConnect,
|
|
33
33
|
getStatusIsReConnectSocket: (n) => n.isReConnectSocket,
|
|
@@ -35,7 +35,7 @@ const T = {
|
|
|
35
35
|
getIsOfflineSocket: (n) => n.isOfflineSocket,
|
|
36
36
|
getInfoNoConnectServer: (n) => n.infoNoConnectServer,
|
|
37
37
|
getIsDisableConnectSocket: (n) => n.isDisableConnectSocket
|
|
38
|
-
},
|
|
38
|
+
}, g = (n) => b(n), Q = M("span")({
|
|
39
39
|
backgroundColor: "rgba(0,0,0,0.3)",
|
|
40
40
|
color: "#fff",
|
|
41
41
|
display: "flex",
|
|
@@ -76,7 +76,7 @@ const T = {
|
|
|
76
76
|
height: "100%"
|
|
77
77
|
}
|
|
78
78
|
})), j = ({ text: n = "Происходит подключение к серверу", className: e, ...t }) => {
|
|
79
|
-
const o =
|
|
79
|
+
const o = g(k.getStatusConnectSocket), i = g(k.getStatusIsReConnectSocket);
|
|
80
80
|
return /* @__PURE__ */ D(
|
|
81
81
|
Z,
|
|
82
82
|
{
|
|
@@ -376,8 +376,8 @@ const s = class s {
|
|
|
376
376
|
d(), i(p);
|
|
377
377
|
}, h = (p) => {
|
|
378
378
|
var A;
|
|
379
|
-
const
|
|
380
|
-
!
|
|
379
|
+
const I = this.wsApi.findDataRequestByAction(c);
|
|
380
|
+
!I || ((A = p == null ? void 0 : p.request) == null ? void 0 : A.requestAction) !== I.requestAction || (d(), o({ ...p }));
|
|
381
381
|
}, S = () => {
|
|
382
382
|
d(), i(new DOMException("Aborted", "AbortError"));
|
|
383
383
|
}, d = () => {
|
|
@@ -404,7 +404,7 @@ r(s, "state", {
|
|
|
404
404
|
//не используеться
|
|
405
405
|
}), r(s, "options", {
|
|
406
406
|
isReConnectNetworkOnline: !1,
|
|
407
|
-
listUrlsCheckConnectNetwork: [
|
|
407
|
+
listUrlsCheckConnectNetwork: []
|
|
408
408
|
}), r(s, "wsApi", new te()), r(s, "delay", new ee()), r(s, "networkTicker", null), r(s, "events", new H(["timeOffReConnect", "reConnect", "network"])), r(s, "saveID", {
|
|
409
409
|
idReConnect: null,
|
|
410
410
|
checkConnect: null
|
|
@@ -477,10 +477,10 @@ const se = (n, e = {}) => {
|
|
|
477
477
|
isLoading: !1,
|
|
478
478
|
isError: !1,
|
|
479
479
|
isSuccess: !1
|
|
480
|
-
}), u =
|
|
480
|
+
}), u = g(k.getStatusReady), v = g(k.getStatusConnectSocket), l = x(null), h = x(e);
|
|
481
481
|
h.current = e;
|
|
482
482
|
const S = E(async () => {
|
|
483
|
-
var w, p,
|
|
483
|
+
var w, p, I, A;
|
|
484
484
|
if (o) return;
|
|
485
485
|
a((y) => ({
|
|
486
486
|
...y,
|
|
@@ -508,13 +508,13 @@ const se = (n, e = {}) => {
|
|
|
508
508
|
error: q,
|
|
509
509
|
isError: !0,
|
|
510
510
|
isLoading: !1
|
|
511
|
-
})), (A = (
|
|
511
|
+
})), (A = (I = h.current).onError) == null || A.call(I, q);
|
|
512
512
|
}
|
|
513
513
|
}, [o, t, n, i]);
|
|
514
|
-
|
|
514
|
+
O(() => (!o && u && S(), () => {
|
|
515
515
|
var f;
|
|
516
516
|
(f = l.current) == null || f.abort();
|
|
517
|
-
}), [S, o, u]),
|
|
517
|
+
}), [S, o, u]), O(() => {
|
|
518
518
|
!u && v === "pending" && a((f) => ({
|
|
519
519
|
...f,
|
|
520
520
|
isError: !1,
|
|
@@ -534,35 +534,35 @@ const se = (n, e = {}) => {
|
|
|
534
534
|
refetch: d,
|
|
535
535
|
abort: m
|
|
536
536
|
};
|
|
537
|
-
},
|
|
538
|
-
const { isNetwork: e, typeNetwork: t } = n, { isModal: o } =
|
|
537
|
+
}, be = (n, e) => se(n, e), ne = (n) => {
|
|
538
|
+
const { isNetwork: e, typeNetwork: t } = n, { isModal: o } = g(k.getInfoNoConnectServer), i = g(k.getStatusIsReConnectSocket), c = g(k.getIsDisableConnectSocket), a = g(k.getStatusConnectSocket), [u, v] = B({
|
|
539
539
|
isNetwork: !1,
|
|
540
540
|
typeNetwork: ""
|
|
541
541
|
});
|
|
542
|
-
return
|
|
542
|
+
return O(() => (C.on("network", (l) => {
|
|
543
543
|
console.log("network: ", l), v({ isNetwork: l.isNetwork, typeNetwork: l.typeNetwork });
|
|
544
544
|
}), C.init(n.init), typeof n.onMount == "function" && n.onMount(), C.on("status", (l) => {
|
|
545
|
-
const h =
|
|
545
|
+
const h = b.getState(), { isReadySocket: S, infoNoConnectServer: { isModal: d }, isOfflineSocket: m } = h;
|
|
546
546
|
l !== "ready" && S && R.setStatusReady({ isReadySocket: !1 }), !S && l === "ready" && (R.setStatusReady({ isReadySocket: !0 }), d && m && (console.log("Вырубаем модалку т.к. сокет законектился после окончания timeOffReConnect"), R.setInfoNoConnectServer({ isModal: !1 }), R.setIsOfflineSocket({ isOfflineSocket: !1 }))), R.setStatusConnectSocket({ statusConnect: l });
|
|
547
547
|
}), C.on("error", (l) => {
|
|
548
548
|
console.log("error: ", l);
|
|
549
549
|
}), C.on("reConnect", (l) => {
|
|
550
550
|
console.log('on"reConnect" (status): ', l);
|
|
551
|
-
const h =
|
|
551
|
+
const h = b.getState(), { isReConnectSocket: S, infoNoConnectServer: { isModal: d } } = h;
|
|
552
552
|
S !== l && R.setStatusIsReConnectSocket({ isReConnectSocket: l }), d && l && R.setInfoNoConnectServer({ isModal: !1 });
|
|
553
553
|
}), C.on("timeOffReConnect", (l) => {
|
|
554
554
|
if (console.log("timeOffReConnect: ", l), R.setIsOfflineSocket({ isOfflineSocket: !l.status }), !l.status) {
|
|
555
|
-
const h =
|
|
555
|
+
const h = b.getState(), { infoNoConnectServer: { isModal: S, isSelectOffline: d } } = h;
|
|
556
556
|
let m = !1;
|
|
557
557
|
!S && !d && (m = !0), m && R.setInfoNoConnectServer({ isModal: m });
|
|
558
558
|
}
|
|
559
559
|
}), C.connect(), () => {
|
|
560
560
|
typeof n.onUnmount == "function" && n.onUnmount(), console.dir("disconnect"), C.disconnect();
|
|
561
|
-
}), []),
|
|
561
|
+
}), []), O(() => {
|
|
562
562
|
e && !c && !o && !i && ["close"].includes(a) && t !== "none" && (console.log("Запущен socketReConnect"), C.socketReConnect());
|
|
563
|
-
}, [c, o, i, a, t, e]),
|
|
563
|
+
}, [c, o, i, a, t, e]), O(() => {
|
|
564
564
|
i && (!e || a === "ready") && (console.log("Запущен stopReConnect"), C.stopReConnect());
|
|
565
|
-
}, [i, e, a]),
|
|
565
|
+
}, [i, e, a]), O(() => {
|
|
566
566
|
c && (console.log("isDisableConnectSocket: ", c), R.setIsOfflineSocket({ isOfflineSocket: !0 }), C.close());
|
|
567
567
|
}, [c]), null;
|
|
568
568
|
}, oe = N.memo(ne), ie = M(P, {
|
|
@@ -576,7 +576,7 @@ const se = (n, e = {}) => {
|
|
|
576
576
|
padding: "1px 10px"
|
|
577
577
|
}
|
|
578
578
|
})), re = ({ children: n, className: e, isNetwork: t, ...o }) => {
|
|
579
|
-
const i =
|
|
579
|
+
const i = g(k.getIsOfflineSocket), c = g(k.getIsDisableConnectSocket), a = i || !t, u = "Оффлайн";
|
|
580
580
|
return /* @__PURE__ */ D(
|
|
581
581
|
ie,
|
|
582
582
|
{
|
|
@@ -608,10 +608,10 @@ const se = (n, e = {}) => {
|
|
|
608
608
|
export {
|
|
609
609
|
ke as Socket,
|
|
610
610
|
C as SocketApi,
|
|
611
|
-
|
|
611
|
+
be as createRequestSocketApi,
|
|
612
612
|
R as socketActions,
|
|
613
613
|
k as socketSelectors,
|
|
614
|
-
|
|
614
|
+
b as socketStore,
|
|
615
615
|
se as useRequestSocketApi,
|
|
616
|
-
|
|
616
|
+
g as useSocketSelector
|
|
617
617
|
};
|