rc-lib-ui 1.2.16-beta.5 → 1.2.17
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.
|
@@ -2,8 +2,6 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { SocketApi } from '../../api';
|
|
3
3
|
export interface InitializationSocketProps {
|
|
4
4
|
init: Parameters<typeof SocketApi.init>[0];
|
|
5
|
-
isNetwork: boolean;
|
|
6
|
-
typeNetwork: string;
|
|
7
5
|
onMount?: () => void;
|
|
8
6
|
onUnmount?: () => void;
|
|
9
7
|
}
|
package/dist/dashboard.js
CHANGED
package/dist/socket.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import './socket.css';var z = Object.defineProperty;
|
|
2
|
-
var F = (
|
|
3
|
-
var r = (
|
|
2
|
+
var F = (o, e, t) => e in o ? z(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var r = (o, e, t) => F(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { jsx as D } from "react/jsx-runtime";
|
|
5
|
-
import
|
|
5
|
+
import E, { useState as B, useRef as x, useCallback as A, 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,22 +20,22 @@ const T = {
|
|
|
20
20
|
isSelectOffline: !1
|
|
21
21
|
//Для того что бы 2й раз окно не показывать
|
|
22
22
|
}
|
|
23
|
-
}, K = JSON.parse(JSON.stringify(T)),
|
|
24
|
-
resetState: () =>
|
|
25
|
-
setStatusConnectSocket: ({ statusConnect:
|
|
26
|
-
setStatusIsReConnectSocket: ({ isReConnectSocket:
|
|
27
|
-
setStatusReady: ({ isReadySocket:
|
|
28
|
-
setIsOfflineSocket: ({ isOfflineSocket:
|
|
29
|
-
setInfoNoConnectServer: (
|
|
30
|
-
setIsDisableConnectSocket: ({ isDisableConnectSocket:
|
|
31
|
-
},
|
|
32
|
-
getStatusConnectSocket: (
|
|
33
|
-
getStatusIsReConnectSocket: (
|
|
34
|
-
getStatusReady: (
|
|
35
|
-
getIsOfflineSocket: (
|
|
36
|
-
getInfoNoConnectServer: (
|
|
37
|
-
getIsDisableConnectSocket: (
|
|
38
|
-
},
|
|
23
|
+
}, K = JSON.parse(JSON.stringify(T)), m = U(() => T), k = {
|
|
24
|
+
resetState: () => m.setState(K),
|
|
25
|
+
setStatusConnectSocket: ({ statusConnect: o }) => m.setState({ statusConnect: o }),
|
|
26
|
+
setStatusIsReConnectSocket: ({ isReConnectSocket: o }) => m.setState({ isReConnectSocket: o }),
|
|
27
|
+
setStatusReady: ({ isReadySocket: o }) => m.setState({ isReadySocket: o }),
|
|
28
|
+
setIsOfflineSocket: ({ isOfflineSocket: o }) => m.setState({ isOfflineSocket: o }),
|
|
29
|
+
setInfoNoConnectServer: (o) => m.setState((e) => ({ infoNoConnectServer: { ...e.infoNoConnectServer, ...o } })),
|
|
30
|
+
setIsDisableConnectSocket: ({ isDisableConnectSocket: o }) => m.setState({ isDisableConnectSocket: o })
|
|
31
|
+
}, R = {
|
|
32
|
+
getStatusConnectSocket: (o) => o.statusConnect,
|
|
33
|
+
getStatusIsReConnectSocket: (o) => o.isReConnectSocket,
|
|
34
|
+
getStatusReady: (o) => o.isReadySocket,
|
|
35
|
+
getIsOfflineSocket: (o) => o.isOfflineSocket,
|
|
36
|
+
getInfoNoConnectServer: (o) => o.infoNoConnectServer,
|
|
37
|
+
getIsDisableConnectSocket: (o) => o.isDisableConnectSocket
|
|
38
|
+
}, b = (o) => m(o), Q = M("span")({
|
|
39
39
|
backgroundColor: "rgba(0,0,0,0.3)",
|
|
40
40
|
color: "#fff",
|
|
41
41
|
display: "flex",
|
|
@@ -43,8 +43,8 @@ const T = {
|
|
|
43
43
|
padding: "1px 10px",
|
|
44
44
|
borderRadius: "3px 3px 3px 3px"
|
|
45
45
|
}), P = M(
|
|
46
|
-
({ children:
|
|
47
|
-
)(({ theme:
|
|
46
|
+
({ children: o, ...e }) => /* @__PURE__ */ D(G, { ...e, unmountOnExit: !0, children: /* @__PURE__ */ D(Q, { children: o }) })
|
|
47
|
+
)(({ theme: o }) => ({
|
|
48
48
|
fontSize: 10,
|
|
49
49
|
position: "absolute",
|
|
50
50
|
left: 0,
|
|
@@ -66,8 +66,8 @@ const T = {
|
|
|
66
66
|
"loading-stripes": "_loading-stripes_1lp7f_1",
|
|
67
67
|
loadingStripes: X
|
|
68
68
|
}, Z = M(P, {
|
|
69
|
-
shouldForwardProp: (
|
|
70
|
-
})(({ theme:
|
|
69
|
+
shouldForwardProp: (o) => ![""].includes(o)
|
|
70
|
+
})(({ theme: o }) => ({
|
|
71
71
|
top: "100%",
|
|
72
72
|
"& .MuiCollapse-wrapper": {
|
|
73
73
|
height: 10
|
|
@@ -75,83 +75,83 @@ const T = {
|
|
|
75
75
|
"& span": {
|
|
76
76
|
height: "100%"
|
|
77
77
|
}
|
|
78
|
-
})), j = ({ text:
|
|
79
|
-
const
|
|
78
|
+
})), j = ({ text: o = "Происходит подключение к серверу", className: e, ...t }) => {
|
|
79
|
+
const n = b(R.getStatusConnectSocket), i = b(R.getStatusIsReConnectSocket);
|
|
80
80
|
return /* @__PURE__ */ D(
|
|
81
81
|
Z,
|
|
82
82
|
{
|
|
83
|
-
in:
|
|
83
|
+
in: n === "pending" || i,
|
|
84
84
|
collapsedSize: "1px",
|
|
85
85
|
className: L(Y["connect-server-anim"], e),
|
|
86
86
|
unmountOnExit: !0,
|
|
87
87
|
...t,
|
|
88
|
-
children:
|
|
88
|
+
children: o
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
}, _ =
|
|
91
|
+
}, _ = E.memo(j);
|
|
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
|
|
99
|
-
t != null && t.watchIdInterval && (t == null || t.watchIdInterval(
|
|
100
|
-
}, i = (
|
|
101
|
-
t != null && t.controlAction && (t == null || t.controlAction(
|
|
98
|
+
const n = (u) => {
|
|
99
|
+
t != null && t.watchIdInterval && (t == null || t.watchIdInterval(u));
|
|
100
|
+
}, i = (u) => {
|
|
101
|
+
t != null && t.controlAction && (t == null || t.controlAction(u));
|
|
102
102
|
};
|
|
103
|
-
let
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
103
|
+
let a = !0, l, c, f;
|
|
104
|
+
const S = (u = !0) => {
|
|
105
|
+
const h = "Ручное завершение startActionEvery";
|
|
106
|
+
a = !1, clearInterval(l), n(null), u ? c && c({ status: u, msg: h + ": (true)" }) : f && f({ status: u, msg: h + ": (false)" });
|
|
107
107
|
};
|
|
108
108
|
return {
|
|
109
|
-
promise: new Promise((
|
|
110
|
-
|
|
111
|
-
let
|
|
112
|
-
|
|
109
|
+
promise: new Promise((u, h) => {
|
|
110
|
+
c = u, f = h;
|
|
111
|
+
let y = 0, d = 0;
|
|
112
|
+
l = setInterval(
|
|
113
113
|
() => {
|
|
114
|
-
if (
|
|
115
|
-
|
|
114
|
+
if (y += t.interval, d += 1, t != null && t.cutoffTime && y > t.cutoffTime || t != null && t.countAction && (t == null ? void 0 : t.countAction) < d) {
|
|
115
|
+
a = !1, clearInterval(l), n(null), h({ status: !1, msg: Error("Время загрузки истекло") });
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
e() && (
|
|
118
|
+
e() && (a = !1, clearInterval(l), n(null), u({ status: !0, msg: "cb вернул true" }));
|
|
119
119
|
},
|
|
120
120
|
t.interval < 200 ? 200 : t.interval
|
|
121
|
-
),
|
|
122
|
-
getIsActiveEvent: () =>
|
|
123
|
-
stop:
|
|
121
|
+
), n(l), i({
|
|
122
|
+
getIsActiveEvent: () => a,
|
|
123
|
+
stop: S
|
|
124
124
|
});
|
|
125
125
|
}),
|
|
126
|
-
stop:
|
|
126
|
+
stop: S
|
|
127
127
|
};
|
|
128
128
|
});
|
|
129
|
-
r(this, "oneOf", (e, t, { second:
|
|
129
|
+
r(this, "oneOf", (e, t, { second: n }) => {
|
|
130
130
|
let i = 1;
|
|
131
131
|
e().then(() => {
|
|
132
132
|
i === 1 && (i = 0);
|
|
133
133
|
});
|
|
134
|
-
let
|
|
135
|
-
i === 1 && t(), clearInterval(
|
|
136
|
-
},
|
|
134
|
+
let a = setInterval(() => {
|
|
135
|
+
i === 1 && t(), clearInterval(a);
|
|
136
|
+
}, n * 1e3);
|
|
137
137
|
});
|
|
138
|
-
r(this, "oneOfPromise", (e, t, { second:
|
|
139
|
-
let
|
|
140
|
-
e().then((
|
|
141
|
-
|
|
142
|
-
}).catch((
|
|
143
|
-
|
|
138
|
+
r(this, "oneOfPromise", (e, t, { second: n }) => new Promise((i, a) => {
|
|
139
|
+
let l = 1, c = { status: !1, msg: "" };
|
|
140
|
+
e().then((S) => {
|
|
141
|
+
l === 1 && (l = 0, i(S));
|
|
142
|
+
}).catch((S) => {
|
|
143
|
+
l === 1 && (l = 0, c.msg = S, a(S));
|
|
144
144
|
});
|
|
145
|
-
let
|
|
146
|
-
if (
|
|
147
|
-
if (
|
|
148
|
-
|
|
145
|
+
let f = setInterval(() => {
|
|
146
|
+
if (l === 1) {
|
|
147
|
+
if (l = 0, typeof t == "function") {
|
|
148
|
+
a({ status: !1, msg: "", ...t(c) });
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
a({ status: !1, msg: "oneOfPromise reject" });
|
|
152
152
|
}
|
|
153
|
-
clearInterval(
|
|
154
|
-
},
|
|
153
|
+
clearInterval(f);
|
|
154
|
+
}, n * 1e3);
|
|
155
155
|
}));
|
|
156
156
|
}
|
|
157
157
|
}
|
|
@@ -161,16 +161,16 @@ class H {
|
|
|
161
161
|
r(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
|
|
162
162
|
r(this, "getSubscribers", () => this.subscribersEvents);
|
|
163
163
|
r(this, "subscribe", (e, t) => {
|
|
164
|
-
var
|
|
165
|
-
(
|
|
164
|
+
var n;
|
|
165
|
+
(n = this.subscribersEvents[e]) == null || n.push(t);
|
|
166
166
|
});
|
|
167
167
|
r(this, "unsubscribe", (e, t) => {
|
|
168
|
-
var
|
|
169
|
-
this.subscribersEvents[e] && (this.subscribersEvents[e] = (
|
|
168
|
+
var n;
|
|
169
|
+
this.subscribersEvents[e] && (this.subscribersEvents[e] = (n = this.subscribersEvents[e]) == null ? void 0 : n.filter((i) => i !== t));
|
|
170
170
|
});
|
|
171
171
|
r(this, "publish", (e, t) => {
|
|
172
|
-
var
|
|
173
|
-
this.subscribersEvents[e] && ((
|
|
172
|
+
var n;
|
|
173
|
+
this.subscribersEvents[e] && ((n = this.subscribersEvents[e]) == null || n.forEach((i) => {
|
|
174
174
|
i(t);
|
|
175
175
|
}));
|
|
176
176
|
});
|
|
@@ -200,16 +200,16 @@ class te {
|
|
|
200
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
|
-
var
|
|
203
|
+
var n, i;
|
|
204
204
|
const t = [
|
|
205
205
|
["open", this.openHandler],
|
|
206
206
|
["close", this.closeHandler],
|
|
207
207
|
["message", this.msgHandler],
|
|
208
208
|
["error", this.errHandler]
|
|
209
209
|
];
|
|
210
|
-
for (let
|
|
211
|
-
const [
|
|
212
|
-
e === "add" ? (
|
|
210
|
+
for (let a = 0; a < t.length; a++) {
|
|
211
|
+
const [l, c] = t[a];
|
|
212
|
+
e === "add" ? (n = this.state.ws) == null || n.addEventListener(l, c) : (i = this.state.ws) == null || i.removeEventListener(l, c);
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
r(this, "openHandler", () => {
|
|
@@ -221,13 +221,13 @@ class te {
|
|
|
221
221
|
r(this, "msgHandler", (e) => {
|
|
222
222
|
const t = JSON.parse(e.data ? e.data : "{}");
|
|
223
223
|
try {
|
|
224
|
-
const { action:
|
|
224
|
+
const { action: n } = t, i = this.findDataRequestByAction(n);
|
|
225
225
|
if (i) {
|
|
226
|
-
const { cb:
|
|
227
|
-
this.events.publish("msg", { ...t, request: { ...
|
|
226
|
+
const { cb: a, ...l } = i, { payload: c, ...f } = l;
|
|
227
|
+
this.events.publish("msg", { ...t, request: { ...f, ...c } });
|
|
228
228
|
} else
|
|
229
229
|
this.events.publish("msg", t);
|
|
230
|
-
|
|
230
|
+
n && this.filterSaveItemsByResponse(t);
|
|
231
231
|
} catch {
|
|
232
232
|
this.events.publish("msg", {});
|
|
233
233
|
}
|
|
@@ -261,7 +261,7 @@ class te {
|
|
|
261
261
|
const e = this.initOptions;
|
|
262
262
|
return e || this.errorInitSocket(), e;
|
|
263
263
|
});
|
|
264
|
-
r(this, "findDataRequestByAction", (e) => this.getItemsRequestSaveByAction(e).sort((i,
|
|
264
|
+
r(this, "findDataRequestByAction", (e) => this.getItemsRequestSaveByAction(e).sort((i, a) => a.requestTime - i.requestTime)[0]);
|
|
265
265
|
}
|
|
266
266
|
resetState() {
|
|
267
267
|
this.state = this.copyState(this.stateDefault);
|
|
@@ -273,12 +273,12 @@ class te {
|
|
|
273
273
|
return JSON.parse(JSON.stringify(e));
|
|
274
274
|
}
|
|
275
275
|
filterSaveItemsByResponse(e) {
|
|
276
|
-
const t = this.getRequestSave(),
|
|
276
|
+
const t = this.getRequestSave(), n = [];
|
|
277
277
|
for (let i = 0; i < t.length; i++) {
|
|
278
|
-
const
|
|
279
|
-
|
|
278
|
+
const a = t[i];
|
|
279
|
+
a.payload.action !== e.action ? n.push(a) : a.cb && a.cb(e);
|
|
280
280
|
}
|
|
281
|
-
this.state.arrSaveReq =
|
|
281
|
+
this.state.arrSaveReq = n;
|
|
282
282
|
}
|
|
283
283
|
connect() {
|
|
284
284
|
this.initOptions && (this.close(), this.setState({
|
|
@@ -293,21 +293,21 @@ class te {
|
|
|
293
293
|
this.close(), this.setStatus("disconnect"), this.resetState(), this.events.resetSubscribers();
|
|
294
294
|
}
|
|
295
295
|
send(e) {
|
|
296
|
-
var
|
|
296
|
+
var n;
|
|
297
297
|
const t = JSON.stringify(e);
|
|
298
|
-
(
|
|
298
|
+
(n = this.state.ws) == null || n.send(t);
|
|
299
299
|
}
|
|
300
300
|
setRequestSave(e) {
|
|
301
301
|
if ("action" in e.payload) {
|
|
302
|
-
const t = this.state.arrSaveReq.findIndex((
|
|
302
|
+
const t = this.state.arrSaveReq.findIndex((n) => n.payload.action === e.payload.action);
|
|
303
303
|
~t ? this.state.arrSaveReq[t] = e : this.state.arrSaveReq.push(e);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
//INFO: Запросов может быть несколько. И время запроса разное
|
|
307
307
|
getItemsRequestSaveByAction(e) {
|
|
308
308
|
return this.getRequestSave().filter((t) => {
|
|
309
|
-
var
|
|
310
|
-
return ((
|
|
309
|
+
var n;
|
|
310
|
+
return ((n = t == null ? void 0 : t.payload) == null ? void 0 : n.action) === e;
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
}
|
|
@@ -335,16 +335,16 @@ const s = class s {
|
|
|
335
335
|
s.state.isDisconnect || (s.setState({ isDisconnect: !0 }), console.log("DISCONNECT WS"), s.wsApi.disconnect(), s.resetState(), s.events.resetSubscribers(), (e = this.networkTicker) == null || e.destroy());
|
|
336
336
|
}
|
|
337
337
|
static send(e, t) {
|
|
338
|
-
const { action:
|
|
338
|
+
const { action: n, ...i } = e, a = i != null && i.request_id ? i.request_id : W(), l = Date.now();
|
|
339
339
|
s.wsApi.setRequestSave({
|
|
340
|
-
requestAction:
|
|
341
|
-
request_id:
|
|
342
|
-
requestTime:
|
|
343
|
-
payload: { action:
|
|
340
|
+
requestAction: n,
|
|
341
|
+
request_id: a,
|
|
342
|
+
requestTime: l,
|
|
343
|
+
payload: { action: n, ...i },
|
|
344
344
|
cb: t
|
|
345
345
|
});
|
|
346
|
-
const
|
|
347
|
-
if (!
|
|
346
|
+
const c = s.wsApi.getSocket();
|
|
347
|
+
if (!c || c.readyState !== 1) {
|
|
348
348
|
console.log("Нет подключения к сокету. Запрос сохранён в setRequestSave");
|
|
349
349
|
return;
|
|
350
350
|
}
|
|
@@ -354,41 +354,41 @@ const s = class s {
|
|
|
354
354
|
console.dir("функция stop не присвоена к stopReConnect");
|
|
355
355
|
}
|
|
356
356
|
static async request(e, t = {}) {
|
|
357
|
-
return new Promise((
|
|
358
|
-
var
|
|
359
|
-
if ((
|
|
357
|
+
return new Promise((n, i) => {
|
|
358
|
+
var d, g;
|
|
359
|
+
if ((d = t == null ? void 0 : t.signal) != null && d.aborted) {
|
|
360
360
|
i(new DOMException("Aborted", "AbortError"));
|
|
361
361
|
return;
|
|
362
362
|
}
|
|
363
|
-
const
|
|
363
|
+
const a = e.action, l = e.request_id ? e.request_id : W(), c = Date.now();
|
|
364
364
|
s.wsApi.setRequestSave({
|
|
365
|
-
requestAction:
|
|
366
|
-
request_id:
|
|
367
|
-
requestTime:
|
|
365
|
+
requestAction: a,
|
|
366
|
+
request_id: l,
|
|
367
|
+
requestTime: c,
|
|
368
368
|
payload: e,
|
|
369
369
|
cb: void 0
|
|
370
370
|
});
|
|
371
|
-
let
|
|
372
|
-
t != null && t.timeout && (
|
|
373
|
-
|
|
371
|
+
let f;
|
|
372
|
+
t != null && t.timeout && (f = setTimeout(() => {
|
|
373
|
+
h(), i(new Error("Request timeout"));
|
|
374
374
|
}, t.timeout));
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
},
|
|
378
|
-
var
|
|
379
|
-
const I = this.wsApi.findDataRequestByAction(
|
|
380
|
-
!I || ((
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
var
|
|
385
|
-
s.off("msg",
|
|
375
|
+
const S = (v) => {
|
|
376
|
+
h(), i(v);
|
|
377
|
+
}, C = (v) => {
|
|
378
|
+
var N;
|
|
379
|
+
const I = this.wsApi.findDataRequestByAction(a);
|
|
380
|
+
!I || ((N = v == null ? void 0 : v.request) == null ? void 0 : N.requestAction) !== I.requestAction || (h(), n({ ...v }));
|
|
381
|
+
}, u = () => {
|
|
382
|
+
h(), i(new DOMException("Aborted", "AbortError"));
|
|
383
|
+
}, h = () => {
|
|
384
|
+
var v;
|
|
385
|
+
s.off("msg", C), s.off("error", S), f && clearTimeout(f), (v = t == null ? void 0 : t.signal) == null || v.removeEventListener("abort", u);
|
|
386
386
|
};
|
|
387
|
-
s.on("msg",
|
|
388
|
-
const
|
|
389
|
-
if (!
|
|
390
|
-
const
|
|
391
|
-
console.error(
|
|
387
|
+
s.on("msg", C), s.on("error", S), (g = t == null ? void 0 : t.signal) == null || g.addEventListener("abort", u);
|
|
388
|
+
const y = s.wsApi.getSocket();
|
|
389
|
+
if (!y || y.readyState !== 1) {
|
|
390
|
+
const v = "Нет подключения к сокету";
|
|
391
|
+
console.error(v), h(), i(new Error(v));
|
|
392
392
|
return;
|
|
393
393
|
}
|
|
394
394
|
s.wsApi.send(e);
|
|
@@ -416,9 +416,9 @@ r(s, "state", {
|
|
|
416
416
|
}), r(s, "offline", () => {
|
|
417
417
|
s.state.isActiveReConnect && s.stopReConnect(!1);
|
|
418
418
|
}), r(s, "splitOptions", (e) => Object.entries(e).reduce(
|
|
419
|
-
(t, [
|
|
420
|
-
const
|
|
421
|
-
return
|
|
419
|
+
(t, [n, i]) => {
|
|
420
|
+
const a = s.wsApi.getOptions();
|
|
421
|
+
return n in a ? { ...t, WsOptions: { ...t.WsOptions, [n]: i } } : { ...t, SocketApiOptions: { ...t.SocketApiOptions, [n]: i } };
|
|
422
422
|
},
|
|
423
423
|
{ WsOptions: {}, SocketApiOptions: {} }
|
|
424
424
|
)), /*---------------------------------------------------------------------------------------------------------------------------*/
|
|
@@ -432,16 +432,16 @@ r(s, "getState", () => s.state), r(s, "getOptions", () => ({ ...s.options, ...s.
|
|
|
432
432
|
r(s, "setNetworkStatus", (e) => {
|
|
433
433
|
s.events.publish("network", e), e.isNetwork ? s.online() : s.offline();
|
|
434
434
|
}), r(s, "init", (e) => {
|
|
435
|
-
const { WsOptions: t, SocketApiOptions:
|
|
436
|
-
s.networkTicker = new $(
|
|
435
|
+
const { WsOptions: t, SocketApiOptions: n } = s.splitOptions(e);
|
|
436
|
+
s.networkTicker = new $(n.listUrlsCheckConnectNetwork ?? []), s.networkTicker.startEvents((i) => {
|
|
437
437
|
s.setNetworkStatus(i);
|
|
438
|
-
}), s.setOptions(
|
|
438
|
+
}), s.setOptions(n), s.wsApi.init(t), s.wsApi.events.subscribe("status", (i) => {
|
|
439
439
|
s.setState({ isOfflineSocket: i !== "ready" });
|
|
440
440
|
});
|
|
441
441
|
}), /*------------------------------------------------------------------------------------------------------*/
|
|
442
442
|
r(s, "socketReConnect", () => {
|
|
443
443
|
if (s.wsApi.getIsInitWS())
|
|
444
|
-
if (
|
|
444
|
+
if (s.saveID.idReConnect)
|
|
445
445
|
console.groupCollapsed("Процесс socketReConnect уже запущен"), console.log("SocketApi.saveID: ", s.saveID), console.groupEnd();
|
|
446
446
|
else {
|
|
447
447
|
s.setStatusReConnect(!0), s.connect();
|
|
@@ -451,152 +451,152 @@ r(s, "socketReConnect", () => {
|
|
|
451
451
|
{
|
|
452
452
|
interval: e,
|
|
453
453
|
countAction: i,
|
|
454
|
-
watchIdInterval: (
|
|
455
|
-
s.saveID.idReConnect =
|
|
454
|
+
watchIdInterval: (l) => {
|
|
455
|
+
s.saveID.idReConnect = l;
|
|
456
456
|
},
|
|
457
|
-
controlAction: ({ stop:
|
|
458
|
-
s.stopReConnect =
|
|
457
|
+
controlAction: ({ stop: l, getIsActiveEvent: c }) => {
|
|
458
|
+
s.stopReConnect = l;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
).promise.then((
|
|
462
|
-
s.setInfoConnect(
|
|
463
|
-
}).catch((
|
|
461
|
+
).promise.then((l) => {
|
|
462
|
+
s.setInfoConnect(l);
|
|
463
|
+
}).catch((l) => {
|
|
464
464
|
if (s.wsApi.getStatusSocket() === "ready") {
|
|
465
465
|
console.log("Сокет успел подключиться, игнорируем ошибку таймаута"), s.setInfoConnect({ status: !0, msg: "Подключено (восстановлено)" });
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
|
-
s.setInfoConnect(
|
|
468
|
+
s.setInfoConnect(l);
|
|
469
469
|
});
|
|
470
470
|
}
|
|
471
471
|
});
|
|
472
|
-
let
|
|
473
|
-
const se = (
|
|
474
|
-
const t =
|
|
472
|
+
let p = s;
|
|
473
|
+
const se = (o, e = {}) => {
|
|
474
|
+
const t = o.action, { skip: n = !1, timeout: i = 5e3 } = e, [a, l] = B({
|
|
475
475
|
data: null,
|
|
476
476
|
error: "",
|
|
477
477
|
isLoading: !1,
|
|
478
478
|
isError: !1,
|
|
479
479
|
isSuccess: !1
|
|
480
|
-
}),
|
|
481
|
-
|
|
482
|
-
const
|
|
483
|
-
var
|
|
484
|
-
if (
|
|
485
|
-
|
|
486
|
-
...
|
|
480
|
+
}), c = b(R.getStatusReady), f = b(R.getStatusConnectSocket), S = x(null), C = x(e);
|
|
481
|
+
C.current = e;
|
|
482
|
+
const u = A(async () => {
|
|
483
|
+
var g, v, I, N;
|
|
484
|
+
if (n) return;
|
|
485
|
+
l((w) => ({
|
|
486
|
+
...w,
|
|
487
487
|
isLoading: !0,
|
|
488
488
|
isError: !1,
|
|
489
489
|
isSuccess: !1,
|
|
490
490
|
error: "",
|
|
491
491
|
data: null
|
|
492
|
-
})),
|
|
493
|
-
const
|
|
492
|
+
})), S.current = new AbortController();
|
|
493
|
+
const d = S.current.signal;
|
|
494
494
|
try {
|
|
495
|
-
const
|
|
496
|
-
if (
|
|
497
|
-
|
|
495
|
+
const w = await p.request(o, { timeout: i, signal: d });
|
|
496
|
+
if (d.aborted) return;
|
|
497
|
+
l((q) => ({
|
|
498
498
|
...q,
|
|
499
|
-
data:
|
|
499
|
+
data: w,
|
|
500
500
|
isSuccess: !0,
|
|
501
501
|
isLoading: !1
|
|
502
|
-
})), (
|
|
503
|
-
} catch (
|
|
504
|
-
if (
|
|
505
|
-
const q =
|
|
506
|
-
|
|
502
|
+
})), (v = (g = C.current).onSuccess) == null || v.call(g, w);
|
|
503
|
+
} catch (w) {
|
|
504
|
+
if (d.aborted) return;
|
|
505
|
+
const q = w instanceof Error ? w.message : String(w);
|
|
506
|
+
l((J) => ({
|
|
507
507
|
...J,
|
|
508
508
|
error: q,
|
|
509
509
|
isError: !0,
|
|
510
510
|
isLoading: !1
|
|
511
|
-
})), (
|
|
511
|
+
})), (N = (I = C.current).onError) == null || N.call(I, q);
|
|
512
512
|
}
|
|
513
|
-
}, [
|
|
514
|
-
O(() => (!
|
|
515
|
-
var
|
|
516
|
-
(
|
|
517
|
-
}), [
|
|
518
|
-
!
|
|
519
|
-
...
|
|
513
|
+
}, [n, t, o, i]);
|
|
514
|
+
O(() => (!n && c && u(), () => {
|
|
515
|
+
var d;
|
|
516
|
+
(d = S.current) == null || d.abort();
|
|
517
|
+
}), [u, n, c]), O(() => {
|
|
518
|
+
!c && f === "pending" && l((d) => ({
|
|
519
|
+
...d,
|
|
520
520
|
isError: !1,
|
|
521
521
|
isSuccess: !1,
|
|
522
522
|
error: "Потеряно соединение с сервером"
|
|
523
523
|
}));
|
|
524
|
-
}, [
|
|
525
|
-
const
|
|
526
|
-
var
|
|
527
|
-
return (
|
|
528
|
-
}, [
|
|
529
|
-
var
|
|
530
|
-
(
|
|
524
|
+
}, [c, f]);
|
|
525
|
+
const h = A(() => {
|
|
526
|
+
var d;
|
|
527
|
+
return (d = S.current) == null || d.abort(), u();
|
|
528
|
+
}, [u]), y = A(() => {
|
|
529
|
+
var d;
|
|
530
|
+
(d = S.current) == null || d.abort(), l((g) => ({ ...g, isLoading: !1 }));
|
|
531
531
|
}, []);
|
|
532
532
|
return {
|
|
533
|
-
...
|
|
534
|
-
refetch:
|
|
535
|
-
abort:
|
|
533
|
+
...a,
|
|
534
|
+
refetch: h,
|
|
535
|
+
abort: y
|
|
536
536
|
};
|
|
537
|
-
},
|
|
538
|
-
const {
|
|
537
|
+
}, Re = (o, e) => se(o, e), ne = (o) => {
|
|
538
|
+
const { isModal: e } = b(R.getInfoNoConnectServer), t = b(R.getStatusIsReConnectSocket), n = b(R.getIsDisableConnectSocket), i = b(R.getStatusConnectSocket), [a, l] = B({
|
|
539
539
|
isNetwork: !1,
|
|
540
540
|
typeNetwork: ""
|
|
541
541
|
});
|
|
542
|
-
return O(() => (
|
|
543
|
-
console.log("network: ",
|
|
544
|
-
}),
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
}),
|
|
548
|
-
console.log("error: ",
|
|
549
|
-
}),
|
|
550
|
-
console.log('on"reConnect" (status): ',
|
|
551
|
-
const
|
|
552
|
-
S !==
|
|
553
|
-
}),
|
|
554
|
-
if (console.log("timeOffReConnect: ",
|
|
555
|
-
const
|
|
556
|
-
let
|
|
557
|
-
!S && !
|
|
542
|
+
return O(() => (p.on("network", (c) => {
|
|
543
|
+
console.log("network: ", c), l((f) => ({ ...f, isNetwork: c.isNetwork, typeNetwork: c.typeNetwork }));
|
|
544
|
+
}), p.init(o.init), typeof o.onMount == "function" && o.onMount(), p.on("status", (c) => {
|
|
545
|
+
const f = m.getState(), { isReadySocket: S, infoNoConnectServer: { isModal: C }, isOfflineSocket: u } = f;
|
|
546
|
+
c !== "ready" && S && k.setStatusReady({ isReadySocket: !1 }), !S && c === "ready" && (k.setStatusReady({ isReadySocket: !0 }), C && u && (console.log("Вырубаем модалку т.к. сокет законектился после окончания timeOffReConnect"), k.setInfoNoConnectServer({ isModal: !1 }), k.setIsOfflineSocket({ isOfflineSocket: !1 }))), k.setStatusConnectSocket({ statusConnect: c });
|
|
547
|
+
}), p.on("error", (c) => {
|
|
548
|
+
console.log("error: ", c);
|
|
549
|
+
}), p.on("reConnect", (c) => {
|
|
550
|
+
console.log('on"reConnect" (status): ', c);
|
|
551
|
+
const f = m.getState(), { isReConnectSocket: S, infoNoConnectServer: { isModal: C } } = f;
|
|
552
|
+
S !== c && k.setStatusIsReConnectSocket({ isReConnectSocket: c }), C && c && k.setInfoNoConnectServer({ isModal: !1 });
|
|
553
|
+
}), p.on("timeOffReConnect", (c) => {
|
|
554
|
+
if (console.log("timeOffReConnect: ", c), k.setIsOfflineSocket({ isOfflineSocket: !c.status }), !c.status) {
|
|
555
|
+
const f = m.getState(), { infoNoConnectServer: { isModal: S, isSelectOffline: C } } = f;
|
|
556
|
+
let u = !1;
|
|
557
|
+
!S && !C && (u = !0), u && k.setInfoNoConnectServer({ isModal: u });
|
|
558
558
|
}
|
|
559
|
-
}),
|
|
560
|
-
typeof
|
|
559
|
+
}), p.connect(), () => {
|
|
560
|
+
typeof o.onUnmount == "function" && o.onUnmount(), console.dir("disconnect"), p.disconnect();
|
|
561
561
|
}), []), O(() => {
|
|
562
|
-
|
|
563
|
-
}, [
|
|
564
|
-
|
|
565
|
-
}, [
|
|
566
|
-
|
|
567
|
-
}, [
|
|
568
|
-
}, oe =
|
|
569
|
-
shouldForwardProp: (
|
|
570
|
-
})(({ theme:
|
|
562
|
+
a.isNetwork && !n && !e && !t && ["close"].includes(i) && a.typeNetwork !== "none" && (console.log("Запущен socketReConnect"), p.socketReConnect());
|
|
563
|
+
}, [n, e, t, i, a.typeNetwork, a.isNetwork]), O(() => {
|
|
564
|
+
t && (!a.isNetwork || i === "ready") && (console.log("Запущен stopReConnect"), p.stopReConnect());
|
|
565
|
+
}, [t, a.isNetwork, i]), O(() => {
|
|
566
|
+
n && (console.log("isDisableConnectSocket: ", n), k.setIsOfflineSocket({ isOfflineSocket: !0 }), p.close());
|
|
567
|
+
}, [n]), null;
|
|
568
|
+
}, oe = E.memo(ne), ie = M(P, {
|
|
569
|
+
shouldForwardProp: (o) => ![""].includes(o)
|
|
570
|
+
})(({ theme: o }) => ({
|
|
571
571
|
bottom: "100%",
|
|
572
|
-
backgroundColor:
|
|
572
|
+
backgroundColor: o.palette.error.light,
|
|
573
573
|
backgroundImage: "linear-gradient(180deg, rgba(255, 255, 255, .15), rgba(255, 255, 255, 0))",
|
|
574
574
|
"& .MuiCollapse-wrapper": {},
|
|
575
575
|
"& span": {
|
|
576
576
|
padding: "1px 10px"
|
|
577
577
|
}
|
|
578
|
-
})), re = ({ children:
|
|
579
|
-
const i =
|
|
578
|
+
})), re = ({ children: o, className: e, isNetwork: t, ...n }) => {
|
|
579
|
+
const i = b(R.getIsOfflineSocket), a = b(R.getIsDisableConnectSocket), l = i || !t, c = "Оффлайн";
|
|
580
580
|
return /* @__PURE__ */ D(
|
|
581
581
|
ie,
|
|
582
582
|
{
|
|
583
|
-
in:
|
|
583
|
+
in: l,
|
|
584
584
|
className: L("socket-offline", e),
|
|
585
|
-
...
|
|
586
|
-
children: typeof
|
|
585
|
+
...n,
|
|
586
|
+
children: typeof o == "function" ? o({ isDisableConnectSocket: a }) : a ? `Режим ${c}` : c
|
|
587
587
|
}
|
|
588
588
|
);
|
|
589
|
-
}, ce =
|
|
590
|
-
const e =
|
|
591
|
-
|
|
589
|
+
}, ce = E.memo(re), ae = ({ children: o }) => {
|
|
590
|
+
const e = A(() => {
|
|
591
|
+
k.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !1 });
|
|
592
592
|
}, []);
|
|
593
|
-
return
|
|
594
|
-
}, le =
|
|
595
|
-
const e =
|
|
596
|
-
|
|
593
|
+
return o({ reConnect: e });
|
|
594
|
+
}, le = E.memo(ae), ue = ({ children: o }) => {
|
|
595
|
+
const e = A(() => {
|
|
596
|
+
k.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !0 }), k.setIsDisableConnectSocket({ isDisableConnectSocket: !0 });
|
|
597
597
|
}, []);
|
|
598
|
-
return
|
|
599
|
-
}, Se =
|
|
598
|
+
return o({ offlineActive: e });
|
|
599
|
+
}, Se = E.memo(ue), be = {
|
|
600
600
|
ConnectDetection: _,
|
|
601
601
|
OfflineDetection: ce,
|
|
602
602
|
Buttons: {
|
|
@@ -606,12 +606,12 @@ const se = (n, e = {}) => {
|
|
|
606
606
|
Initialization: oe
|
|
607
607
|
};
|
|
608
608
|
export {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
609
|
+
be as Socket,
|
|
610
|
+
p as SocketApi,
|
|
611
|
+
Re as createRequestSocketApi,
|
|
612
|
+
k as socketActions,
|
|
613
|
+
R as socketSelectors,
|
|
614
|
+
m as socketStore,
|
|
615
615
|
se as useRequestSocketApi,
|
|
616
|
-
|
|
616
|
+
b as useSocketSelector
|
|
617
617
|
};
|
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.17",
|
|
5
5
|
"author": "SinGlEBW",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"build:dev": "node buildEditVersion.js"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"dev-classes": "^1.5.
|
|
62
|
+
"dev-classes": "^1.5.5",
|
|
63
63
|
"notistack": "^3.0.2",
|
|
64
64
|
"react-transition-group": "^4.4.5",
|
|
65
65
|
"uuid4": "^2.0.3",
|