rc-lib-ui 1.2.15 → 1.2.16-beta.0
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/socket.js +151 -146
- package/package.json +3 -2
package/dist/socket.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import './socket.css';var
|
|
2
|
-
var
|
|
3
|
-
var r = (n, e, t) =>
|
|
1
|
+
import './socket.css';var z = Object.defineProperty;
|
|
2
|
+
var F = (n, e, t) => e in n ? z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
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
|
|
5
|
+
import N, { useState as B, useRef as x, useCallback as E, useEffect as I } 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
|
-
import
|
|
8
|
+
import L from "classnames";
|
|
9
9
|
import { u as W } from "./browser-DJTk47DY.js";
|
|
10
10
|
import { N as $ } from "./index-80JSxasr.js";
|
|
11
|
-
const
|
|
11
|
+
const T = {
|
|
12
12
|
statusConnect: "disconnect",
|
|
13
13
|
isOfflineSocket: !1,
|
|
14
14
|
//Текущее состояние сокета. Зависит от события timeOffReConnect и если задаёться isDisableConnectSocket: true
|
|
@@ -20,29 +20,29 @@ const L = {
|
|
|
20
20
|
isSelectOffline: !1
|
|
21
21
|
//Для того что бы 2й раз окно не показывать
|
|
22
22
|
}
|
|
23
|
-
}, j = JSON.parse(JSON.stringify(
|
|
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 }) =>
|
|
31
|
-
},
|
|
23
|
+
}, j = JSON.parse(JSON.stringify(T)), b = U(() => T), R = {
|
|
24
|
+
resetState: () => b.setState(j),
|
|
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
|
+
}, g = {
|
|
32
32
|
getStatusConnectSocket: (n) => n.statusConnect,
|
|
33
33
|
getStatusIsReConnectSocket: (n) => n.isReConnectSocket,
|
|
34
34
|
getStatusReady: (n) => n.isReadySocket,
|
|
35
35
|
getIsOfflineSocket: (n) => n.isOfflineSocket,
|
|
36
36
|
getInfoNoConnectServer: (n) => n.infoNoConnectServer,
|
|
37
37
|
getIsDisableConnectSocket: (n) => n.isDisableConnectSocket
|
|
38
|
-
},
|
|
38
|
+
}, k = (n) => b(n), K = M("span")({
|
|
39
39
|
backgroundColor: "rgba(0,0,0,0.3)",
|
|
40
40
|
color: "#fff",
|
|
41
41
|
display: "flex",
|
|
42
42
|
alignItems: "center",
|
|
43
43
|
padding: "1px 10px",
|
|
44
44
|
borderRadius: "3px 3px 3px 3px"
|
|
45
|
-
}),
|
|
45
|
+
}), P = M(
|
|
46
46
|
({ children: n, ...e }) => /* @__PURE__ */ D(G, { ...e, unmountOnExit: !0, children: /* @__PURE__ */ D(K, { children: n }) })
|
|
47
47
|
)(({ theme: n }) => ({
|
|
48
48
|
fontSize: 10,
|
|
@@ -65,7 +65,7 @@ const L = {
|
|
|
65
65
|
connectServerAnim: Q,
|
|
66
66
|
"loading-stripes": "_loading-stripes_1lp7f_1",
|
|
67
67
|
loadingStripes: V
|
|
68
|
-
}, Y = M(
|
|
68
|
+
}, Y = M(P, {
|
|
69
69
|
shouldForwardProp: (n) => ![""].includes(n)
|
|
70
70
|
})(({ theme: n }) => ({
|
|
71
71
|
top: "100%",
|
|
@@ -76,54 +76,54 @@ const L = {
|
|
|
76
76
|
height: "100%"
|
|
77
77
|
}
|
|
78
78
|
})), Z = ({ text: n = "Происходит подключение к серверу", className: e, ...t }) => {
|
|
79
|
-
const o = g
|
|
79
|
+
const o = k(g.getStatusConnectSocket), i = k(g.getStatusIsReConnectSocket);
|
|
80
80
|
return /* @__PURE__ */ D(
|
|
81
81
|
Y,
|
|
82
82
|
{
|
|
83
83
|
in: o === "pending" || i,
|
|
84
84
|
collapsedSize: "1px",
|
|
85
|
-
className:
|
|
85
|
+
className: L(X["connect-server-anim"], e),
|
|
86
86
|
unmountOnExit: !0,
|
|
87
87
|
...t,
|
|
88
88
|
children: n
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
}, _ =
|
|
91
|
+
}, _ = N.memo(Z);
|
|
92
92
|
class ee {
|
|
93
93
|
constructor() {
|
|
94
94
|
r(this, "defaultProps", {
|
|
95
95
|
interval: 5e3
|
|
96
96
|
});
|
|
97
97
|
r(this, "startActionEvery", (e, t = this.defaultProps) => {
|
|
98
|
-
const o = (
|
|
99
|
-
t != null && t.watchIdInterval && (t == null || t.watchIdInterval(
|
|
100
|
-
}, i = (
|
|
101
|
-
t != null && t.controlAction && (t == null || t.controlAction(
|
|
98
|
+
const o = (S) => {
|
|
99
|
+
t != null && t.watchIdInterval && (t == null || t.watchIdInterval(S));
|
|
100
|
+
}, i = (S) => {
|
|
101
|
+
t != null && t.controlAction && (t == null || t.controlAction(S));
|
|
102
102
|
};
|
|
103
|
-
let c = !0, a,
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
c = !1, clearInterval(a), o(null),
|
|
103
|
+
let c = !0, a, u, p;
|
|
104
|
+
const l = (S = !0) => {
|
|
105
|
+
const d = "Ручное завершение startActionEvery";
|
|
106
|
+
c = !1, clearInterval(a), o(null), S ? u && u({ status: S, msg: d + ": (true)" }) : p && p({ status: S, msg: d + ": (false)" });
|
|
107
107
|
};
|
|
108
108
|
return {
|
|
109
|
-
promise: new Promise((
|
|
110
|
-
|
|
111
|
-
let
|
|
109
|
+
promise: new Promise((S, d) => {
|
|
110
|
+
u = S, p = d;
|
|
111
|
+
let m = 0, f = 0;
|
|
112
112
|
a = setInterval(
|
|
113
113
|
() => {
|
|
114
|
-
if (
|
|
115
|
-
c = !1, clearInterval(a), o(null),
|
|
114
|
+
if (m += t.interval, f += 1, t != null && t.cutoffTime && m > t.cutoffTime || t != null && t.countAction && (t == null ? void 0 : t.countAction) < f) {
|
|
115
|
+
c = !1, clearInterval(a), o(null), d({ status: !1, msg: Error("Время загрузки истекло") });
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
e() && (c = !1, clearInterval(a), o(null),
|
|
118
|
+
e() && (c = !1, clearInterval(a), o(null), S({ status: !0, msg: "cb вернул true" }));
|
|
119
119
|
},
|
|
120
120
|
t.interval < 200 ? 200 : t.interval
|
|
121
121
|
), o(a), i({
|
|
122
122
|
getIsActiveEvent: () => c,
|
|
123
|
-
stop:
|
|
123
|
+
stop: l
|
|
124
124
|
});
|
|
125
125
|
}),
|
|
126
|
-
stop:
|
|
126
|
+
stop: l
|
|
127
127
|
};
|
|
128
128
|
});
|
|
129
129
|
r(this, "oneOf", (e, t, { second: o }) => {
|
|
@@ -136,26 +136,26 @@ class ee {
|
|
|
136
136
|
}, o * 1e3);
|
|
137
137
|
});
|
|
138
138
|
r(this, "oneOfPromise", (e, t, { second: o }) => new Promise((i, c) => {
|
|
139
|
-
let a = 1,
|
|
140
|
-
e().then((
|
|
141
|
-
a === 1 && (a = 0, i(
|
|
142
|
-
}).catch((
|
|
143
|
-
a === 1 && (a = 0,
|
|
139
|
+
let a = 1, u = { status: !1, msg: "" };
|
|
140
|
+
e().then((l) => {
|
|
141
|
+
a === 1 && (a = 0, i(l));
|
|
142
|
+
}).catch((l) => {
|
|
143
|
+
a === 1 && (a = 0, u.msg = l, c(l));
|
|
144
144
|
});
|
|
145
|
-
let
|
|
145
|
+
let p = setInterval(() => {
|
|
146
146
|
if (a === 1) {
|
|
147
147
|
if (a = 0, typeof t == "function") {
|
|
148
|
-
c({ status: !1, msg: "", ...t(
|
|
148
|
+
c({ status: !1, msg: "", ...t(u) });
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
c({ status: !1, msg: "oneOfPromise reject" });
|
|
152
152
|
}
|
|
153
|
-
clearInterval(
|
|
153
|
+
clearInterval(p);
|
|
154
154
|
}, o * 1e3);
|
|
155
155
|
}));
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
class
|
|
158
|
+
class H {
|
|
159
159
|
constructor(e) {
|
|
160
160
|
r(this, "subscribersEvents", {});
|
|
161
161
|
r(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
|
|
@@ -197,7 +197,7 @@ class te {
|
|
|
197
197
|
arrSaveReq: []
|
|
198
198
|
});
|
|
199
199
|
r(this, "initOptions", !1);
|
|
200
|
-
r(this, "events", new
|
|
200
|
+
r(this, "events", new H(["status", "msg", "error"]));
|
|
201
201
|
r(this, "stateDefault", this.copyState(this.state));
|
|
202
202
|
r(this, "eventListener", (e) => {
|
|
203
203
|
var o, i;
|
|
@@ -208,8 +208,8 @@ class te {
|
|
|
208
208
|
["error", this.errHandler]
|
|
209
209
|
];
|
|
210
210
|
for (let c = 0; c < t.length; c++) {
|
|
211
|
-
const [a,
|
|
212
|
-
e === "add" ? (o = this.state.ws) == null || o.addEventListener(a,
|
|
211
|
+
const [a, u] = t[c];
|
|
212
|
+
e === "add" ? (o = this.state.ws) == null || o.addEventListener(a, u) : (i = this.state.ws) == null || i.removeEventListener(a, u);
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
r(this, "openHandler", () => {
|
|
@@ -223,8 +223,8 @@ class te {
|
|
|
223
223
|
try {
|
|
224
224
|
const { action: o } = t, i = this.findDataRequestByAction(o);
|
|
225
225
|
if (i) {
|
|
226
|
-
const { cb: c, ...a } = i, { payload:
|
|
227
|
-
this.events.publish("msg", { ...t, request: { ...
|
|
226
|
+
const { cb: c, ...a } = i, { payload: u, ...p } = a;
|
|
227
|
+
this.events.publish("msg", { ...t, request: { ...p, ...u } });
|
|
228
228
|
} else
|
|
229
229
|
this.events.publish("msg", t);
|
|
230
230
|
o && this.filterSaveItemsByResponse(t);
|
|
@@ -342,8 +342,8 @@ const s = class s {
|
|
|
342
342
|
payload: { action: o, ...i },
|
|
343
343
|
cb: t
|
|
344
344
|
});
|
|
345
|
-
const
|
|
346
|
-
if (!
|
|
345
|
+
const u = s.wsApi.getSocket();
|
|
346
|
+
if (!u || u.readyState !== 1) {
|
|
347
347
|
console.log("Нет подключения к сокету. Запрос сохранён в setRequestSave");
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
@@ -354,40 +354,40 @@ const s = class s {
|
|
|
354
354
|
}
|
|
355
355
|
static async request(e, t = {}) {
|
|
356
356
|
return new Promise((o, i) => {
|
|
357
|
-
var
|
|
358
|
-
if ((
|
|
357
|
+
var f, w;
|
|
358
|
+
if ((f = t == null ? void 0 : t.signal) != null && f.aborted) {
|
|
359
359
|
i(new DOMException("Aborted", "AbortError"));
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
362
|
-
const c = e.action, a = e.request_id ? e.request_id : W(),
|
|
362
|
+
const c = e.action, a = e.request_id ? e.request_id : W(), u = Date.now();
|
|
363
363
|
s.wsApi.setRequestSave({
|
|
364
364
|
requestAction: c,
|
|
365
365
|
request_id: a,
|
|
366
|
-
requestTime:
|
|
366
|
+
requestTime: u,
|
|
367
367
|
payload: e,
|
|
368
368
|
cb: void 0
|
|
369
369
|
});
|
|
370
|
-
let
|
|
371
|
-
t != null && t.timeout && (
|
|
372
|
-
|
|
370
|
+
let p;
|
|
371
|
+
t != null && t.timeout && (p = setTimeout(() => {
|
|
372
|
+
d(), i(new Error("Request timeout"));
|
|
373
373
|
}, t.timeout));
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
},
|
|
374
|
+
const l = (v) => {
|
|
375
|
+
d(), i(v);
|
|
376
|
+
}, h = (v) => {
|
|
377
377
|
var A;
|
|
378
|
-
const
|
|
379
|
-
!
|
|
380
|
-
},
|
|
381
|
-
|
|
382
|
-
},
|
|
378
|
+
const O = this.wsApi.findDataRequestByAction(c);
|
|
379
|
+
!O || ((A = v == null ? void 0 : v.request) == null ? void 0 : A.requestAction) !== O.requestAction || (d(), o({ ...v }));
|
|
380
|
+
}, S = () => {
|
|
381
|
+
d(), i(new DOMException("Aborted", "AbortError"));
|
|
382
|
+
}, d = () => {
|
|
383
383
|
var v;
|
|
384
|
-
s.off("msg",
|
|
384
|
+
s.off("msg", h), s.off("error", l), p && clearTimeout(p), (v = t == null ? void 0 : t.signal) == null || v.removeEventListener("abort", S);
|
|
385
385
|
};
|
|
386
|
-
s.on("msg",
|
|
387
|
-
const
|
|
388
|
-
if (!
|
|
386
|
+
s.on("msg", h), s.on("error", l), (w = t == null ? void 0 : t.signal) == null || w.addEventListener("abort", S);
|
|
387
|
+
const m = s.wsApi.getSocket();
|
|
388
|
+
if (!m || m.readyState !== 1) {
|
|
389
389
|
const v = "Нет подключения к сокету";
|
|
390
|
-
console.error(v),
|
|
390
|
+
console.error(v), d(), i(new Error(v));
|
|
391
391
|
return;
|
|
392
392
|
}
|
|
393
393
|
s.wsApi.send(e);
|
|
@@ -404,7 +404,7 @@ r(s, "state", {
|
|
|
404
404
|
}), r(s, "options", {
|
|
405
405
|
isReConnectNetworkOnline: !1,
|
|
406
406
|
listUrlsCheckConnectNetwork: ["https://jsonplaceholder.typicode.com/posts/1"]
|
|
407
|
-
}), r(s, "wsApi", new te()), r(s, "delay", new ee()), r(s, "networkTicker", null), r(s, "events", new
|
|
407
|
+
}), 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", {
|
|
408
408
|
idReConnect: null,
|
|
409
409
|
checkConnect: null
|
|
410
410
|
}), r(s, "stateDefault", s.copyState(s.state)), r(s, "setInfoConnect", (e) => {
|
|
@@ -453,7 +453,7 @@ r(s, "socketReConnect", () => {
|
|
|
453
453
|
watchIdInterval: (a) => {
|
|
454
454
|
s.saveID.idReConnect = a;
|
|
455
455
|
},
|
|
456
|
-
controlAction: ({ stop: a, getIsActiveEvent:
|
|
456
|
+
controlAction: ({ stop: a, getIsActiveEvent: u }) => {
|
|
457
457
|
s.stopReConnect = a;
|
|
458
458
|
}
|
|
459
459
|
}
|
|
@@ -468,98 +468,103 @@ r(s, "socketReConnect", () => {
|
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
});
|
|
471
|
-
let
|
|
471
|
+
let C = s;
|
|
472
472
|
const se = (n, e = {}) => {
|
|
473
|
-
const t = n.action, { skip: o = !1, timeout: i = 5e3 } = e, [c, a] =
|
|
473
|
+
const t = n.action, { skip: o = !1, timeout: i = 5e3 } = e, [c, a] = B({
|
|
474
474
|
data: null,
|
|
475
475
|
error: "",
|
|
476
476
|
isLoading: !1,
|
|
477
477
|
isError: !1,
|
|
478
478
|
isSuccess: !1
|
|
479
|
-
}),
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
var
|
|
479
|
+
}), u = k(g.getStatusReady), p = k(g.getStatusConnectSocket), l = x(null), h = x(e);
|
|
480
|
+
h.current = e;
|
|
481
|
+
const S = E(async () => {
|
|
482
|
+
var w, v, O, A;
|
|
483
483
|
if (o) return;
|
|
484
|
-
a((
|
|
485
|
-
...
|
|
484
|
+
a((y) => ({
|
|
485
|
+
...y,
|
|
486
486
|
isLoading: !0,
|
|
487
487
|
isError: !1,
|
|
488
488
|
isSuccess: !1,
|
|
489
489
|
error: "",
|
|
490
490
|
data: null
|
|
491
|
-
})),
|
|
492
|
-
const
|
|
491
|
+
})), l.current = new AbortController();
|
|
492
|
+
const f = l.current.signal;
|
|
493
493
|
try {
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
a((
|
|
497
|
-
...
|
|
498
|
-
data:
|
|
494
|
+
const y = await C.request(n, { timeout: i, signal: f });
|
|
495
|
+
if (f.aborted) return;
|
|
496
|
+
a((q) => ({
|
|
497
|
+
...q,
|
|
498
|
+
data: y,
|
|
499
499
|
isSuccess: !0,
|
|
500
500
|
isLoading: !1
|
|
501
|
-
})), (v = (
|
|
502
|
-
} catch (
|
|
503
|
-
if (
|
|
504
|
-
const
|
|
505
|
-
a((
|
|
506
|
-
...
|
|
507
|
-
error:
|
|
501
|
+
})), (v = (w = h.current).onSuccess) == null || v.call(w, y);
|
|
502
|
+
} catch (y) {
|
|
503
|
+
if (f.aborted) return;
|
|
504
|
+
const q = y instanceof Error ? y.message : String(y);
|
|
505
|
+
a((J) => ({
|
|
506
|
+
...J,
|
|
507
|
+
error: q,
|
|
508
508
|
isError: !0,
|
|
509
509
|
isLoading: !1
|
|
510
|
-
})), (A = (
|
|
510
|
+
})), (A = (O = h.current).onError) == null || A.call(O, q);
|
|
511
511
|
}
|
|
512
512
|
}, [o, t, n, i]);
|
|
513
|
-
I(() => (!o &&
|
|
514
|
-
var
|
|
515
|
-
(
|
|
516
|
-
}), [
|
|
517
|
-
!
|
|
518
|
-
...
|
|
513
|
+
I(() => (!o && u && S(), () => {
|
|
514
|
+
var f;
|
|
515
|
+
(f = l.current) == null || f.abort();
|
|
516
|
+
}), [S, o, u]), I(() => {
|
|
517
|
+
!u && p === "pending" && a((f) => ({
|
|
518
|
+
...f,
|
|
519
519
|
isError: !1,
|
|
520
520
|
isSuccess: !1,
|
|
521
521
|
error: "Потеряно соединение с сервером"
|
|
522
522
|
}));
|
|
523
|
-
}, [
|
|
524
|
-
const
|
|
525
|
-
var
|
|
526
|
-
return (
|
|
527
|
-
}, [
|
|
528
|
-
var
|
|
529
|
-
(
|
|
523
|
+
}, [u, p]);
|
|
524
|
+
const d = E(() => {
|
|
525
|
+
var f;
|
|
526
|
+
return (f = l.current) == null || f.abort(), S();
|
|
527
|
+
}, [S]), m = E(() => {
|
|
528
|
+
var f;
|
|
529
|
+
(f = l.current) == null || f.abort(), a((w) => ({ ...w, isLoading: !1 }));
|
|
530
530
|
}, []);
|
|
531
531
|
return {
|
|
532
532
|
...c,
|
|
533
|
-
refetch:
|
|
534
|
-
abort:
|
|
533
|
+
refetch: d,
|
|
534
|
+
abort: m
|
|
535
535
|
};
|
|
536
536
|
}, be = (n, e) => se(n, e), ne = (n) => {
|
|
537
|
-
const { isNetwork: e, typeNetwork: t } = n, { isModal: o } = g
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
537
|
+
const { isNetwork: e, typeNetwork: t } = n, { isModal: o } = k(g.getInfoNoConnectServer), i = k(g.getStatusIsReConnectSocket), c = k(g.getIsDisableConnectSocket), a = k(g.getStatusConnectSocket), [u, p] = B({
|
|
538
|
+
isNetwork: !1,
|
|
539
|
+
typeNetwork: ""
|
|
540
|
+
});
|
|
541
|
+
return console.group("InitializationSocket (Проверка внутреннего и внешнего статуса network)"), console.log("props:>>", n), console.log("networkState:>>", u), console.groupEnd(), I(() => (C.init(n.init), typeof n.onMount == "function" && n.onMount(), C.on("network", (l) => {
|
|
542
|
+
console.log("network: ", l), p({ isNetwork: l.isNetwork, typeNetwork: l.typeNetwork });
|
|
543
|
+
}), C.on("status", (l) => {
|
|
544
|
+
const h = b.getState(), { isReadySocket: S, infoNoConnectServer: { isModal: d }, isOfflineSocket: m } = h;
|
|
545
|
+
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 });
|
|
546
|
+
}), C.on("error", (l) => {
|
|
542
547
|
console.log("error: ", l);
|
|
543
|
-
}),
|
|
548
|
+
}), C.on("reConnect", (l) => {
|
|
544
549
|
console.log('on"reConnect" (status): ', l);
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
}),
|
|
548
|
-
if (console.log("timeOffReConnect: ", l),
|
|
549
|
-
const
|
|
550
|
-
let
|
|
551
|
-
!
|
|
550
|
+
const h = b.getState(), { isReConnectSocket: S, infoNoConnectServer: { isModal: d } } = h;
|
|
551
|
+
S !== l && R.setStatusIsReConnectSocket({ isReConnectSocket: l }), d && l && R.setInfoNoConnectServer({ isModal: !1 });
|
|
552
|
+
}), C.on("timeOffReConnect", (l) => {
|
|
553
|
+
if (console.log("timeOffReConnect: ", l), R.setIsOfflineSocket({ isOfflineSocket: !l.status }), !l.status) {
|
|
554
|
+
const h = b.getState(), { infoNoConnectServer: { isModal: S, isSelectOffline: d } } = h;
|
|
555
|
+
let m = !1;
|
|
556
|
+
!S && !d && (m = !0), m && R.setInfoNoConnectServer({ isModal: m });
|
|
552
557
|
}
|
|
553
|
-
}),
|
|
554
|
-
typeof n.onUnmount == "function" && n.onUnmount(), console.dir("disconnect"),
|
|
558
|
+
}), C.connect(), () => {
|
|
559
|
+
typeof n.onUnmount == "function" && n.onUnmount(), console.dir("disconnect"), C.disconnect();
|
|
555
560
|
}), []), I(() => {
|
|
556
|
-
e && !c && !o && !i && ["close"].includes(a) && t !== "none" && (console.log("Запущен socketReConnect"),
|
|
561
|
+
e && !c && !o && !i && ["close"].includes(a) && t !== "none" && (console.log("Запущен socketReConnect"), C.socketReConnect());
|
|
557
562
|
}, [c, o, i, a, t, e]), I(() => {
|
|
558
|
-
i && (!e || a === "ready") && (console.log("Запущен stopReConnect"),
|
|
563
|
+
i && (!e || a === "ready") && (console.log("Запущен stopReConnect"), C.stopReConnect());
|
|
559
564
|
}, [i, e, a]), I(() => {
|
|
560
|
-
c && (console.log("isDisableConnectSocket: ", c),
|
|
565
|
+
c && (console.log("isDisableConnectSocket: ", c), R.setIsOfflineSocket({ isOfflineSocket: !0 }), C.close());
|
|
561
566
|
}, [c]), null;
|
|
562
|
-
}, oe =
|
|
567
|
+
}, oe = N.memo(ne), ie = M(P, {
|
|
563
568
|
shouldForwardProp: (n) => ![""].includes(n)
|
|
564
569
|
})(({ theme: n }) => ({
|
|
565
570
|
bottom: "100%",
|
|
@@ -570,42 +575,42 @@ const se = (n, e = {}) => {
|
|
|
570
575
|
padding: "1px 10px"
|
|
571
576
|
}
|
|
572
577
|
})), re = ({ children: n, className: e, isNetwork: t, ...o }) => {
|
|
573
|
-
const i = g
|
|
578
|
+
const i = k(g.getIsOfflineSocket), c = k(g.getIsDisableConnectSocket), a = i || !t, u = "Оффлайн";
|
|
574
579
|
return /* @__PURE__ */ D(
|
|
575
580
|
ie,
|
|
576
581
|
{
|
|
577
582
|
in: a,
|
|
578
|
-
className:
|
|
583
|
+
className: L("socket-offline", e),
|
|
579
584
|
...o,
|
|
580
|
-
children: typeof n == "function" ? n({ isDisableConnectSocket: c }) : c ? `Режим ${
|
|
585
|
+
children: typeof n == "function" ? n({ isDisableConnectSocket: c }) : c ? `Режим ${u}` : u
|
|
581
586
|
}
|
|
582
587
|
);
|
|
583
|
-
}, ce =
|
|
588
|
+
}, ce = N.memo(re), ae = ({ children: n }) => {
|
|
584
589
|
const e = E(() => {
|
|
585
|
-
|
|
590
|
+
R.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !1 });
|
|
586
591
|
}, []);
|
|
587
592
|
return n({ reConnect: e });
|
|
588
|
-
}, le =
|
|
593
|
+
}, le = N.memo(ae), ue = ({ children: n }) => {
|
|
589
594
|
const e = E(() => {
|
|
590
|
-
|
|
595
|
+
R.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !0 }), R.setIsDisableConnectSocket({ isDisableConnectSocket: !0 });
|
|
591
596
|
}, []);
|
|
592
597
|
return n({ offlineActive: e });
|
|
593
|
-
},
|
|
598
|
+
}, Se = N.memo(ue), ge = {
|
|
594
599
|
ConnectDetection: _,
|
|
595
600
|
OfflineDetection: ce,
|
|
596
601
|
Buttons: {
|
|
597
|
-
OfflineActive:
|
|
602
|
+
OfflineActive: Se,
|
|
598
603
|
ReConnect: le
|
|
599
604
|
},
|
|
600
605
|
Initialization: oe
|
|
601
606
|
};
|
|
602
607
|
export {
|
|
603
608
|
ge as Socket,
|
|
604
|
-
|
|
609
|
+
C as SocketApi,
|
|
605
610
|
be as createRequestSocketApi,
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
611
|
+
R as socketActions,
|
|
612
|
+
g as socketSelectors,
|
|
613
|
+
b as socketStore,
|
|
609
614
|
se as useRequestSocketApi,
|
|
610
|
-
|
|
615
|
+
k as useSocketSelector
|
|
611
616
|
};
|
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.16-beta.0",
|
|
5
5
|
"author": "SinGlEBW",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"build": "tsc --project tsconfig.prod.json && vite build",
|
|
56
56
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
57
57
|
"preview": "vite preview",
|
|
58
|
-
"send": "node publishVersion.js"
|
|
58
|
+
"send": "node publishVersion.js",
|
|
59
|
+
"build:dev": "node buildEditVersion.js"
|
|
59
60
|
},
|
|
60
61
|
"dependencies": {
|
|
61
62
|
"dev-classes": "^1.5.2",
|