rc-lib-ui 1.1.50 → 1.1.53
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 +113 -123
- package/package.json +1 -1
package/dist/socket.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import './socket.css';var j = Object.defineProperty;
|
|
2
|
-
var J = (
|
|
3
|
-
var r = (
|
|
2
|
+
var J = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var r = (n, t, e) => J(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { jsx as D } from "react/jsx-runtime";
|
|
5
5
|
import k, { useState as z, useRef as x, useCallback as N, useEffect as O } from "react";
|
|
6
6
|
import { styled as M, Collapse as G } from "@mui/material";
|
|
7
7
|
import W from "classnames";
|
|
8
|
-
const B = (
|
|
8
|
+
const B = (n) => {
|
|
9
9
|
let t;
|
|
10
|
-
const e = /* @__PURE__ */ new Set(),
|
|
10
|
+
const e = /* @__PURE__ */ new Set(), o = (u, h) => {
|
|
11
11
|
const f = typeof u == "function" ? u(t) : u;
|
|
12
12
|
if (!Object.is(f, t)) {
|
|
13
13
|
const v = t;
|
|
14
14
|
t = h ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((b) => b(t, v));
|
|
15
15
|
}
|
|
16
|
-
}, i = () => t, a = { setState:
|
|
16
|
+
}, i = () => t, a = { setState: o, getState: i, getInitialState: () => S, subscribe: (u) => (e.add(u), () => e.delete(u)) }, S = t = n(o, i, a);
|
|
17
17
|
return a;
|
|
18
|
-
}, $ = (
|
|
19
|
-
function K(
|
|
18
|
+
}, $ = (n) => n ? B(n) : B, V = (n) => n;
|
|
19
|
+
function K(n, t = V) {
|
|
20
20
|
const e = k.useSyncExternalStore(
|
|
21
|
-
|
|
22
|
-
k.useCallback(() => t(
|
|
23
|
-
k.useCallback(() => t(
|
|
21
|
+
n.subscribe,
|
|
22
|
+
k.useCallback(() => t(n.getState()), [n, t]),
|
|
23
|
+
k.useCallback(() => t(n.getInitialState()), [n, t])
|
|
24
24
|
);
|
|
25
25
|
return k.useDebugValue(e), e;
|
|
26
26
|
}
|
|
27
|
-
const T = (
|
|
28
|
-
const t = $(
|
|
27
|
+
const T = (n) => {
|
|
28
|
+
const t = $(n), e = (o) => K(t, o);
|
|
29
29
|
return Object.assign(e, t), e;
|
|
30
|
-
}, Q = (
|
|
30
|
+
}, Q = (n) => n ? T(n) : T, U = {
|
|
31
31
|
statusConnect: "disconnect",
|
|
32
32
|
isOfflineSocket: !1,
|
|
33
33
|
//Текущее состояние сокета. Зависит от события timeOffReConnect и если задаёться isDisableConnectSocket: true
|
|
@@ -41,20 +41,20 @@ const T = (o) => {
|
|
|
41
41
|
}
|
|
42
42
|
}, X = JSON.parse(JSON.stringify(U)), w = Q(() => U), p = {
|
|
43
43
|
resetState: () => w.setState(X),
|
|
44
|
-
setStatusConnectSocket: ({ statusConnect:
|
|
45
|
-
setStatusIsReConnectSocket: ({ isReConnectSocket:
|
|
46
|
-
setStatusReady: ({ isReadySocket:
|
|
47
|
-
setIsOfflineSocket: ({ isOfflineSocket:
|
|
48
|
-
setInfoNoConnectServer: (
|
|
49
|
-
setIsDisableConnectSocket: ({ isDisableConnectSocket:
|
|
44
|
+
setStatusConnectSocket: ({ statusConnect: n }) => w.setState({ statusConnect: n }),
|
|
45
|
+
setStatusIsReConnectSocket: ({ isReConnectSocket: n }) => w.setState({ isReConnectSocket: n }),
|
|
46
|
+
setStatusReady: ({ isReadySocket: n }) => w.setState({ isReadySocket: n }),
|
|
47
|
+
setIsOfflineSocket: ({ isOfflineSocket: n }) => w.setState({ isOfflineSocket: n }),
|
|
48
|
+
setInfoNoConnectServer: (n) => w.setState((t) => ({ infoNoConnectServer: { ...t.infoNoConnectServer, ...n } })),
|
|
49
|
+
setIsDisableConnectSocket: ({ isDisableConnectSocket: n }) => w.setState({ isDisableConnectSocket: n })
|
|
50
50
|
}, R = {
|
|
51
|
-
getStatusConnectSocket: (
|
|
52
|
-
getStatusIsReConnectSocket: (
|
|
53
|
-
getStatusReady: (
|
|
54
|
-
getIsOfflineSocket: (
|
|
55
|
-
getInfoNoConnectServer: (
|
|
56
|
-
getIsDisableConnectSocket: (
|
|
57
|
-
}, m = (
|
|
51
|
+
getStatusConnectSocket: (n) => n.statusConnect,
|
|
52
|
+
getStatusIsReConnectSocket: (n) => n.isReConnectSocket,
|
|
53
|
+
getStatusReady: (n) => n.isReadySocket,
|
|
54
|
+
getIsOfflineSocket: (n) => n.isOfflineSocket,
|
|
55
|
+
getInfoNoConnectServer: (n) => n.infoNoConnectServer,
|
|
56
|
+
getIsDisableConnectSocket: (n) => n.isDisableConnectSocket
|
|
57
|
+
}, m = (n) => w(n), Y = M("span")({
|
|
58
58
|
backgroundColor: "rgba(0,0,0,0.3)",
|
|
59
59
|
color: "#fff",
|
|
60
60
|
display: "flex",
|
|
@@ -62,8 +62,8 @@ const T = (o) => {
|
|
|
62
62
|
padding: "1px 10px",
|
|
63
63
|
borderRadius: "3px 3px 3px 3px"
|
|
64
64
|
}), P = M(
|
|
65
|
-
({ children:
|
|
66
|
-
)(({ theme:
|
|
65
|
+
({ children: n, ...t }) => /* @__PURE__ */ D(G, { ...t, unmountOnExit: !0, children: /* @__PURE__ */ D(Y, { children: n }) })
|
|
66
|
+
)(({ theme: n }) => ({
|
|
67
67
|
fontSize: 10,
|
|
68
68
|
position: "absolute",
|
|
69
69
|
left: 0,
|
|
@@ -85,8 +85,8 @@ const T = (o) => {
|
|
|
85
85
|
"loading-stripes": "_loading-stripes_1lp7f_1",
|
|
86
86
|
loadingStripes: _
|
|
87
87
|
}, et = M(P, {
|
|
88
|
-
shouldForwardProp: (
|
|
89
|
-
})(({ theme:
|
|
88
|
+
shouldForwardProp: (n) => ![""].includes(n)
|
|
89
|
+
})(({ theme: n }) => ({
|
|
90
90
|
top: "100%",
|
|
91
91
|
"& .MuiCollapse-wrapper": {
|
|
92
92
|
height: 10
|
|
@@ -94,7 +94,7 @@ const T = (o) => {
|
|
|
94
94
|
"& span": {
|
|
95
95
|
height: "100%"
|
|
96
96
|
}
|
|
97
|
-
})), st = ({ text:
|
|
97
|
+
})), st = ({ text: n = "Происходит подключение к серверу", className: t, ...e }) => {
|
|
98
98
|
const i = m(R.getStatusConnectSocket) === "pending";
|
|
99
99
|
return /* @__PURE__ */ D(
|
|
100
100
|
et,
|
|
@@ -104,16 +104,16 @@ const T = (o) => {
|
|
|
104
104
|
className: W(tt["connect-server-anim"], t),
|
|
105
105
|
unmountOnExit: !0,
|
|
106
106
|
...e,
|
|
107
|
-
children:
|
|
107
|
+
children: n
|
|
108
108
|
}
|
|
109
109
|
);
|
|
110
110
|
}, nt = k.memo(st), ot = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
111
|
-
function it(
|
|
112
|
-
return ot.test(
|
|
111
|
+
function it(n) {
|
|
112
|
+
return ot.test(n);
|
|
113
113
|
}
|
|
114
114
|
function L() {
|
|
115
|
-
var
|
|
116
|
-
return URL.revokeObjectURL(
|
|
115
|
+
var n = URL.createObjectURL(new Blob()), t = n.toString();
|
|
116
|
+
return URL.revokeObjectURL(n), t.split(/[:\/]/g).pop().toLowerCase();
|
|
117
117
|
}
|
|
118
118
|
L.valid = it;
|
|
119
119
|
class rt {
|
|
@@ -122,7 +122,7 @@ class rt {
|
|
|
122
122
|
interval: 5e3
|
|
123
123
|
});
|
|
124
124
|
r(this, "startActionEvery", (t, e = this.defaultProps) => {
|
|
125
|
-
const
|
|
125
|
+
const o = (f) => {
|
|
126
126
|
e != null && e.watchIdInterval && (e == null || e.watchIdInterval(f));
|
|
127
127
|
}, i = (f) => {
|
|
128
128
|
e != null && e.controlAction && (e == null || e.controlAction(f));
|
|
@@ -130,7 +130,7 @@ class rt {
|
|
|
130
130
|
let c = !0, l, a, S;
|
|
131
131
|
const u = (f = !0) => {
|
|
132
132
|
const v = "Ручное завершение startActionEvery";
|
|
133
|
-
c = !1, clearInterval(l),
|
|
133
|
+
c = !1, clearInterval(l), o(null), f ? a && a({ status: f, msg: v + ": (true)" }) : S && S({ status: f, msg: v + ": (false)" });
|
|
134
134
|
};
|
|
135
135
|
return {
|
|
136
136
|
promise: new Promise((f, v) => {
|
|
@@ -139,13 +139,13 @@ class rt {
|
|
|
139
139
|
l = setInterval(
|
|
140
140
|
() => {
|
|
141
141
|
if (b += e.interval, d += 1, e != null && e.cutoffTime && b > e.cutoffTime || e != null && e.countAction && (e == null ? void 0 : e.countAction) < d) {
|
|
142
|
-
c = !1, clearInterval(l),
|
|
142
|
+
c = !1, clearInterval(l), o(null), v({ status: !1, msg: Error("Время загрузки истекло") });
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
t() && (c = !1, clearInterval(l),
|
|
145
|
+
t() && (c = !1, clearInterval(l), o(null), f({ status: !0, msg: "cb вернул true" }));
|
|
146
146
|
},
|
|
147
147
|
e.interval < 200 ? 200 : e.interval
|
|
148
|
-
),
|
|
148
|
+
), o(l), i({
|
|
149
149
|
getIsActiveEvent: () => c,
|
|
150
150
|
stop: u
|
|
151
151
|
});
|
|
@@ -153,16 +153,16 @@ class rt {
|
|
|
153
153
|
stop: u
|
|
154
154
|
};
|
|
155
155
|
});
|
|
156
|
-
r(this, "oneOf", (t, e, { second:
|
|
156
|
+
r(this, "oneOf", (t, e, { second: o }) => {
|
|
157
157
|
let i = 1;
|
|
158
158
|
t().then(() => {
|
|
159
159
|
i === 1 && (i = 0);
|
|
160
160
|
});
|
|
161
161
|
let c = setInterval(() => {
|
|
162
162
|
i === 1 && e(), clearInterval(c);
|
|
163
|
-
},
|
|
163
|
+
}, o * 1e3);
|
|
164
164
|
});
|
|
165
|
-
r(this, "oneOfPromise", (t, e, { second:
|
|
165
|
+
r(this, "oneOfPromise", (t, e, { second: o }) => new Promise((i, c) => {
|
|
166
166
|
let l = 1, a = { status: !1, msg: "" };
|
|
167
167
|
t().then((u) => {
|
|
168
168
|
l === 1 && (l = 0, i(u));
|
|
@@ -178,7 +178,7 @@ class rt {
|
|
|
178
178
|
c({ status: !1, msg: "oneOfPromise reject" });
|
|
179
179
|
}
|
|
180
180
|
clearInterval(S);
|
|
181
|
-
},
|
|
181
|
+
}, o * 1e3);
|
|
182
182
|
}));
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -188,16 +188,16 @@ class F {
|
|
|
188
188
|
r(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
|
|
189
189
|
r(this, "getSubscribers", () => this.subscribersEvents);
|
|
190
190
|
r(this, "subscribe", (t, e) => {
|
|
191
|
-
var
|
|
192
|
-
(
|
|
191
|
+
var o;
|
|
192
|
+
(o = this.subscribersEvents[t]) == null || o.push(e);
|
|
193
193
|
});
|
|
194
194
|
r(this, "unsubscribe", (t, e) => {
|
|
195
|
-
var
|
|
196
|
-
this.subscribersEvents[t] && (this.subscribersEvents[t] = (
|
|
195
|
+
var o;
|
|
196
|
+
this.subscribersEvents[t] && (this.subscribersEvents[t] = (o = this.subscribersEvents[t]) == null ? void 0 : o.filter((i) => i !== e));
|
|
197
197
|
});
|
|
198
198
|
r(this, "publish", (t, e) => {
|
|
199
|
-
var
|
|
200
|
-
this.subscribersEvents[t] && ((
|
|
199
|
+
var o;
|
|
200
|
+
this.subscribersEvents[t] && ((o = this.subscribersEvents[t]) == null || o.forEach((i) => {
|
|
201
201
|
i(e);
|
|
202
202
|
}));
|
|
203
203
|
});
|
|
@@ -221,7 +221,7 @@ class ct {
|
|
|
221
221
|
checkIntervalId: null
|
|
222
222
|
});
|
|
223
223
|
r(this, "getIsNetwork", (t) => !["unknown", "none"].includes(t));
|
|
224
|
-
r(this, "getTypeNetwork", (
|
|
224
|
+
r(this, "getTypeNetwork", (t, e) => e || e === null ? "4g" : "none");
|
|
225
225
|
/*-----------------------------------------------------------------------------*/
|
|
226
226
|
r(this, "controllersEvents", {
|
|
227
227
|
online: null,
|
|
@@ -246,26 +246,16 @@ class ct {
|
|
|
246
246
|
getState() {
|
|
247
247
|
return this.state;
|
|
248
248
|
}
|
|
249
|
-
// private getFetchOptions = (controller: AbortController) => ({
|
|
250
|
-
// method: 'HEAD',
|
|
251
|
-
// cache: 'no-store',
|
|
252
|
-
// signal: controller.signal,
|
|
253
|
-
// headers: {
|
|
254
|
-
// 'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
255
|
-
// 'Pragma': 'no-cache',
|
|
256
|
-
// 'Expires': '0'
|
|
257
|
-
// }
|
|
258
|
-
// } as const);
|
|
259
249
|
getConnection() {
|
|
260
250
|
var t;
|
|
261
251
|
return (t = window == null ? void 0 : window.navigator) == null ? void 0 : t.connection;
|
|
262
252
|
}
|
|
263
253
|
updateState(t, e) {
|
|
264
|
-
const
|
|
254
|
+
const o = {
|
|
265
255
|
isNetwork: t,
|
|
266
256
|
typeNetwork: this.getTypeNetwork(this.getConnection(), t)
|
|
267
257
|
};
|
|
268
|
-
this.networkInfo =
|
|
258
|
+
this.networkInfo = o, typeof e == "function" && e(o);
|
|
269
259
|
}
|
|
270
260
|
getControllersEvents() {
|
|
271
261
|
return this.controllersEvents;
|
|
@@ -279,40 +269,40 @@ class ct {
|
|
|
279
269
|
if (e)
|
|
280
270
|
return;
|
|
281
271
|
this.setState({ isActiveEvents: !0 });
|
|
282
|
-
const
|
|
272
|
+
const o = {
|
|
283
273
|
online: new AbortController(),
|
|
284
274
|
offline: new AbortController(),
|
|
285
275
|
change: new AbortController()
|
|
286
276
|
};
|
|
287
|
-
this.setControllersEvents(
|
|
277
|
+
this.setControllersEvents(o);
|
|
288
278
|
const i = this.getConnection(), c = this.getTypeNetwork(i, window.navigator.onLine), l = this.getIsNetwork(c);
|
|
289
279
|
this.updateState(l, t), window.addEventListener("online", () => {
|
|
290
280
|
this.updateState(!0, t);
|
|
291
|
-
}, { signal: (a =
|
|
281
|
+
}, { signal: (a = o.online) == null ? void 0 : a.signal }), window.addEventListener("offline", () => {
|
|
292
282
|
this.updateState(!1, t);
|
|
293
|
-
}, { signal: (S =
|
|
283
|
+
}, { signal: (S = o.offline) == null ? void 0 : S.signal }), (u = this.getConnection()) != null && u.addEventListener && this.getConnection().addEventListener("change", () => {
|
|
294
284
|
const f = this.getConnection(), v = this.getTypeNetwork(f, null), b = this.getIsNetwork(v);
|
|
295
285
|
this.updateState(b, t);
|
|
296
|
-
}, { signal: (h =
|
|
286
|
+
}, { signal: (h = o.change) == null ? void 0 : h.signal });
|
|
297
287
|
}
|
|
298
288
|
stopEvents() {
|
|
299
289
|
const { isActiveEvents: t } = this.getState();
|
|
300
290
|
if (t) {
|
|
301
291
|
this.setState({ isActiveEvents: !1 });
|
|
302
292
|
const e = this.getControllersEvents();
|
|
303
|
-
for (const
|
|
304
|
-
|
|
293
|
+
for (const o of Object.values(e))
|
|
294
|
+
o == null || o.abort();
|
|
305
295
|
}
|
|
306
296
|
}
|
|
307
297
|
/*-----------------------------------------------------------------------------*/
|
|
308
298
|
async requestByUrls(t, e) {
|
|
309
|
-
const
|
|
310
|
-
this.updateState(
|
|
299
|
+
const o = await this.checkConnection(e);
|
|
300
|
+
this.updateState(o, t);
|
|
311
301
|
}
|
|
312
302
|
async checkConnection(t = {}) {
|
|
313
303
|
for (const e of this.listUrls)
|
|
314
304
|
try {
|
|
315
|
-
const
|
|
305
|
+
const o = new AbortController(), i = setTimeout(() => o.abort(), (t == null ? void 0 : t.timeout) || 5e3), c = await window.fetch(e);
|
|
316
306
|
if (clearTimeout(i), c.status >= 200 && c.status < 400)
|
|
317
307
|
return !0;
|
|
318
308
|
} catch {
|
|
@@ -327,8 +317,8 @@ class ct {
|
|
|
327
317
|
this.controllersFetching = { ...this.controllersFetching, ...t };
|
|
328
318
|
}
|
|
329
319
|
startFetching(t, { interval: e = 5e3 }) {
|
|
330
|
-
const { isMonitoring:
|
|
331
|
-
if (
|
|
320
|
+
const { isMonitoring: o } = this.getState();
|
|
321
|
+
if (o)
|
|
332
322
|
return;
|
|
333
323
|
this.setState({ isMonitoring: !0 });
|
|
334
324
|
const i = {
|
|
@@ -343,8 +333,8 @@ class ct {
|
|
|
343
333
|
stopFetching() {
|
|
344
334
|
const { isMonitoring: t, checkIntervalId: e } = this.getState();
|
|
345
335
|
if (!t) return;
|
|
346
|
-
const
|
|
347
|
-
for (const i of Object.values(
|
|
336
|
+
const o = this.getControllersMonitoring();
|
|
337
|
+
for (const i of Object.values(o))
|
|
348
338
|
i == null || i.abort();
|
|
349
339
|
e && clearInterval(e), this.setState({ isMonitoring: !1, checkIntervalId: null });
|
|
350
340
|
}
|
|
@@ -378,7 +368,7 @@ class at {
|
|
|
378
368
|
r(this, "events", new F(["status", "msg", "error"]));
|
|
379
369
|
r(this, "stateDefault", this.copyState(this.state));
|
|
380
370
|
r(this, "eventListener", (t) => {
|
|
381
|
-
var
|
|
371
|
+
var o, i;
|
|
382
372
|
const e = [
|
|
383
373
|
["open", this.openHandler],
|
|
384
374
|
["close", this.closeHandler],
|
|
@@ -387,7 +377,7 @@ class at {
|
|
|
387
377
|
];
|
|
388
378
|
for (let c = 0; c < e.length; c++) {
|
|
389
379
|
const [l, a] = e[c];
|
|
390
|
-
t === "add" ? (
|
|
380
|
+
t === "add" ? (o = this.state.ws) == null || o.addEventListener(l, a) : (i = this.state.ws) == null || i.removeEventListener(l, a);
|
|
391
381
|
}
|
|
392
382
|
});
|
|
393
383
|
r(this, "openHandler", () => {
|
|
@@ -399,13 +389,13 @@ class at {
|
|
|
399
389
|
r(this, "msgHandler", (t) => {
|
|
400
390
|
const e = JSON.parse(t.data ? t.data : "{}");
|
|
401
391
|
try {
|
|
402
|
-
const { action:
|
|
392
|
+
const { action: o } = e, i = this.findDataRequestByAction(o);
|
|
403
393
|
if (i) {
|
|
404
394
|
const { cb: c, ...l } = i, { payload: a, ...S } = l;
|
|
405
395
|
this.events.publish("msg", { ...e, request: { ...S, ...a } });
|
|
406
396
|
} else
|
|
407
397
|
this.events.publish("msg", e);
|
|
408
|
-
|
|
398
|
+
o && this.filterSaveItemsByResponse(e);
|
|
409
399
|
} catch {
|
|
410
400
|
this.events.publish("msg", {});
|
|
411
401
|
}
|
|
@@ -451,12 +441,12 @@ class at {
|
|
|
451
441
|
return JSON.parse(JSON.stringify(t));
|
|
452
442
|
}
|
|
453
443
|
filterSaveItemsByResponse(t) {
|
|
454
|
-
const e = this.getRequestSave(),
|
|
444
|
+
const e = this.getRequestSave(), o = [];
|
|
455
445
|
for (let i = 0; i < e.length; i++) {
|
|
456
446
|
const c = e[i];
|
|
457
|
-
c.payload.action !== t.action ?
|
|
447
|
+
c.payload.action !== t.action ? o.push(c) : c.cb && c.cb(t);
|
|
458
448
|
}
|
|
459
|
-
this.state.arrSaveReq =
|
|
449
|
+
this.state.arrSaveReq = o;
|
|
460
450
|
}
|
|
461
451
|
connect() {
|
|
462
452
|
this.initOptions && (this.close(), this.setState({
|
|
@@ -471,21 +461,21 @@ class at {
|
|
|
471
461
|
this.close(), this.setStatus("disconnect"), this.resetState(), this.events.resetSubscribers();
|
|
472
462
|
}
|
|
473
463
|
send(t) {
|
|
474
|
-
var
|
|
464
|
+
var o;
|
|
475
465
|
const e = JSON.stringify(t);
|
|
476
|
-
(
|
|
466
|
+
(o = this.state.ws) == null || o.send(e);
|
|
477
467
|
}
|
|
478
468
|
setRequestSave(t) {
|
|
479
469
|
if ("action" in t.payload) {
|
|
480
|
-
const e = this.state.arrSaveReq.findIndex((
|
|
470
|
+
const e = this.state.arrSaveReq.findIndex((o) => o.payload.action === t.payload.action);
|
|
481
471
|
~e ? this.state.arrSaveReq[e] = t : this.state.arrSaveReq.push(t);
|
|
482
472
|
}
|
|
483
473
|
}
|
|
484
474
|
//INFO: Запросов может быть несколько. И время запроса разное
|
|
485
475
|
getItemsRequestSaveByAction(t) {
|
|
486
476
|
return this.getRequestSave().filter((e) => {
|
|
487
|
-
var
|
|
488
|
-
return ((
|
|
477
|
+
var o;
|
|
478
|
+
return ((o = e == null ? void 0 : e.payload) == null ? void 0 : o.action) === t;
|
|
489
479
|
});
|
|
490
480
|
}
|
|
491
481
|
}
|
|
@@ -512,12 +502,12 @@ const s = class s {
|
|
|
512
502
|
s.state.isDisconnect || (s.setState({ isDisconnect: !0 }), console.log("DISCONNECT WS"), s.wsApi.disconnect(), s.resetState(), s.events.resetSubscribers());
|
|
513
503
|
}
|
|
514
504
|
static send(t, e) {
|
|
515
|
-
const { action:
|
|
505
|
+
const { action: o, ...i } = t, c = i != null && i.request_id ? i.request_id : L(), l = Date.now();
|
|
516
506
|
s.wsApi.setRequestSave({
|
|
517
|
-
requestAction:
|
|
507
|
+
requestAction: o,
|
|
518
508
|
request_id: c,
|
|
519
509
|
requestTime: l,
|
|
520
|
-
payload: { action:
|
|
510
|
+
payload: { action: o, ...i },
|
|
521
511
|
cb: e
|
|
522
512
|
});
|
|
523
513
|
const a = s.wsApi.getSocket();
|
|
@@ -531,7 +521,7 @@ const s = class s {
|
|
|
531
521
|
console.dir("функция stop не присвоена к stopReConnect");
|
|
532
522
|
}
|
|
533
523
|
static async request(t, e = {}) {
|
|
534
|
-
return new Promise((
|
|
524
|
+
return new Promise((o, i) => {
|
|
535
525
|
var d, y;
|
|
536
526
|
if ((d = e == null ? void 0 : e.signal) != null && d.aborted) {
|
|
537
527
|
i(new DOMException("Aborted", "AbortError"));
|
|
@@ -554,7 +544,7 @@ const s = class s {
|
|
|
554
544
|
}, h = (g) => {
|
|
555
545
|
var A;
|
|
556
546
|
const E = this.wsApi.findDataRequestByAction(c);
|
|
557
|
-
!E || ((A = g == null ? void 0 : g.request) == null ? void 0 : A.requestAction) !== E.requestAction || (v(),
|
|
547
|
+
!E || ((A = g == null ? void 0 : g.request) == null ? void 0 : A.requestAction) !== E.requestAction || (v(), o({ ...g }));
|
|
558
548
|
}, f = () => {
|
|
559
549
|
v(), i(new DOMException("Aborted", "AbortError"));
|
|
560
550
|
}, v = () => {
|
|
@@ -594,9 +584,9 @@ r(s, "networkTicker", null), r(s, "events", new F(["timeOffReConnect", "reConnec
|
|
|
594
584
|
}), r(s, "offline", () => {
|
|
595
585
|
s.state.isActiveReConnect && s.stopReConnect(!1);
|
|
596
586
|
}), r(s, "splitOptions", (t) => Object.entries(t).reduce(
|
|
597
|
-
(e, [
|
|
587
|
+
(e, [o, i]) => {
|
|
598
588
|
const c = s.wsApi.getOptions();
|
|
599
|
-
return
|
|
589
|
+
return o in c ? { ...e, WsOptions: { ...e.WsOptions, [o]: i } } : { ...e, SocketApiOptions: { ...e.SocketApiOptions, [o]: i } };
|
|
600
590
|
},
|
|
601
591
|
{ WsOptions: {}, SocketApiOptions: {} }
|
|
602
592
|
)), /*---------------------------------------------------------------------------------------------------------------------------*/
|
|
@@ -610,10 +600,10 @@ r(s, "getState", () => s.state), r(s, "getOptions", () => ({ ...s.options, ...s.
|
|
|
610
600
|
r(s, "setNetworkStatus", (t) => {
|
|
611
601
|
s.events.publish("network", t), t.isNetwork ? s.online() : s.offline();
|
|
612
602
|
}), r(s, "init", (t) => {
|
|
613
|
-
const { WsOptions: e, SocketApiOptions:
|
|
614
|
-
s.networkTicker = new ct(
|
|
603
|
+
const { WsOptions: e, SocketApiOptions: o } = s.splitOptions(t);
|
|
604
|
+
s.networkTicker = new ct(o.listUrlsCheckConnectNetwork ?? []), s.networkTicker.startEvents((i) => {
|
|
615
605
|
s.setNetworkStatus(i);
|
|
616
|
-
}), s.setOptions(
|
|
606
|
+
}), s.setOptions(o), s.wsApi.init(e), s.wsApi.events.subscribe("status", (i) => {
|
|
617
607
|
s.setState({ isOfflineSocket: i !== "ready" });
|
|
618
608
|
});
|
|
619
609
|
}), /*------------------------------------------------------------------------------------------------------*/
|
|
@@ -648,8 +638,8 @@ r(s, "socketReConnect", () => {
|
|
|
648
638
|
}
|
|
649
639
|
});
|
|
650
640
|
let C = s;
|
|
651
|
-
const lt = (
|
|
652
|
-
const e =
|
|
641
|
+
const lt = (n, t = {}) => {
|
|
642
|
+
const e = n.action, { skip: o = !1, timeout: i = 5e3 } = t, [c, l] = z({
|
|
653
643
|
data: null,
|
|
654
644
|
error: "",
|
|
655
645
|
isLoading: !1,
|
|
@@ -659,7 +649,7 @@ const lt = (o, t = {}) => {
|
|
|
659
649
|
h.current = t;
|
|
660
650
|
const f = N(async () => {
|
|
661
651
|
var y, g, E, A;
|
|
662
|
-
if (
|
|
652
|
+
if (o) return;
|
|
663
653
|
l((I) => ({
|
|
664
654
|
...I,
|
|
665
655
|
isLoading: !0,
|
|
@@ -670,7 +660,7 @@ const lt = (o, t = {}) => {
|
|
|
670
660
|
})), u.current = new AbortController();
|
|
671
661
|
const d = u.current.signal;
|
|
672
662
|
try {
|
|
673
|
-
const I = await C.request(
|
|
663
|
+
const I = await C.request(n, { timeout: i, signal: d });
|
|
674
664
|
if (d.aborted) return;
|
|
675
665
|
l((q) => ({
|
|
676
666
|
...q,
|
|
@@ -688,11 +678,11 @@ const lt = (o, t = {}) => {
|
|
|
688
678
|
isLoading: !1
|
|
689
679
|
})), (A = (E = h.current).onError) == null || A.call(E, q);
|
|
690
680
|
}
|
|
691
|
-
}, [
|
|
692
|
-
O(() => (!
|
|
681
|
+
}, [o, e, n, i]);
|
|
682
|
+
O(() => (!o && a && f(), () => {
|
|
693
683
|
var d;
|
|
694
684
|
(d = u.current) == null || d.abort();
|
|
695
|
-
}), [f,
|
|
685
|
+
}), [f, o, a]), O(() => {
|
|
696
686
|
!a && S === "pending" && l((d) => ({
|
|
697
687
|
...d,
|
|
698
688
|
isError: !1,
|
|
@@ -712,9 +702,9 @@ const lt = (o, t = {}) => {
|
|
|
712
702
|
refetch: v,
|
|
713
703
|
abort: b
|
|
714
704
|
};
|
|
715
|
-
}, yt = (
|
|
716
|
-
const { isNetwork: t, typeNetwork: e } =
|
|
717
|
-
return O(() => (C.init(
|
|
705
|
+
}, yt = (n, t) => lt(n, t), ut = (n) => {
|
|
706
|
+
const { isNetwork: t, typeNetwork: e } = n, { isModal: o } = m(R.getInfoNoConnectServer), i = m(R.getStatusIsReConnectSocket), c = m(R.getIsDisableConnectSocket), l = m(R.getStatusConnectSocket);
|
|
707
|
+
return O(() => (C.init(n.init), typeof n.onMount == "function" && n.onMount(), C.on("status", (a) => {
|
|
718
708
|
const S = w.getState(), { isReadySocket: u, infoNoConnectServer: { isModal: h }, isOfflineSocket: f } = S;
|
|
719
709
|
a !== "ready" && u && p.setStatusReady({ isReadySocket: !1 }), !u && a === "ready" && (p.setStatusReady({ isReadySocket: !0 }), h && f && (console.log("Вырубаем модалку т.к. сокет законектился после окончания timeOffReConnect"), p.setInfoNoConnectServer({ isModal: !1 }), p.setIsOfflineSocket({ isOfflineSocket: !1 }))), p.setStatusConnectSocket({ statusConnect: a });
|
|
720
710
|
}), C.on("error", (a) => {
|
|
@@ -730,45 +720,45 @@ const lt = (o, t = {}) => {
|
|
|
730
720
|
!u && !h && (f = !0), f && p.setInfoNoConnectServer({ isModal: f });
|
|
731
721
|
}
|
|
732
722
|
}), C.connect(), () => {
|
|
733
|
-
typeof
|
|
723
|
+
typeof n.onUnmount == "function" && n.onUnmount(), console.dir("disconnect"), C.disconnect();
|
|
734
724
|
}), []), O(() => {
|
|
735
|
-
t && !c && !
|
|
736
|
-
}, [c,
|
|
725
|
+
t && !c && !o && !i && ["close"].includes(l) && e !== "none" && (console.log("Запущен socketReConnect"), C.socketReConnect());
|
|
726
|
+
}, [c, o, i, l, e, t]), O(() => {
|
|
737
727
|
i && (!t || l === "ready") && (console.log("Запущен stopReConnect"), C.stopReConnect());
|
|
738
728
|
}, [i, t, l]), O(() => {
|
|
739
729
|
c && (console.log("isDisableConnectSocket: ", c), p.setIsOfflineSocket({ isOfflineSocket: !0 }), C.close());
|
|
740
730
|
}, [c]), null;
|
|
741
731
|
}, ft = k.memo(ut), St = M(P, {
|
|
742
|
-
shouldForwardProp: (
|
|
743
|
-
})(({ theme:
|
|
732
|
+
shouldForwardProp: (n) => ![""].includes(n)
|
|
733
|
+
})(({ theme: n }) => ({
|
|
744
734
|
bottom: "100%",
|
|
745
|
-
backgroundColor:
|
|
735
|
+
backgroundColor: n.palette.error.light,
|
|
746
736
|
backgroundImage: "linear-gradient(180deg, rgba(255, 255, 255, .15), rgba(255, 255, 255, 0))",
|
|
747
737
|
"& .MuiCollapse-wrapper": {},
|
|
748
738
|
"& span": {
|
|
749
739
|
padding: "1px 10px"
|
|
750
740
|
}
|
|
751
|
-
})), dt = ({ children:
|
|
741
|
+
})), dt = ({ children: n, className: t, isNetwork: e, ...o }) => {
|
|
752
742
|
const i = m(R.getIsOfflineSocket), c = m(R.getIsDisableConnectSocket), l = i || !e, a = "Оффлайн";
|
|
753
743
|
return /* @__PURE__ */ D(
|
|
754
744
|
St,
|
|
755
745
|
{
|
|
756
746
|
in: l,
|
|
757
747
|
className: W("socket-offline", t),
|
|
758
|
-
...
|
|
759
|
-
children: typeof
|
|
748
|
+
...o,
|
|
749
|
+
children: typeof n == "function" ? n({ isDisableConnectSocket: c }) : c ? `Режим ${a}` : a
|
|
760
750
|
}
|
|
761
751
|
);
|
|
762
|
-
}, ht = k.memo(dt), vt = ({ children:
|
|
752
|
+
}, ht = k.memo(dt), vt = ({ children: n }) => {
|
|
763
753
|
const t = N(() => {
|
|
764
754
|
p.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !1 });
|
|
765
755
|
}, []);
|
|
766
|
-
return
|
|
767
|
-
}, gt = k.memo(vt), pt = ({ children:
|
|
756
|
+
return n({ reConnect: t });
|
|
757
|
+
}, gt = k.memo(vt), pt = ({ children: n }) => {
|
|
768
758
|
const t = N(() => {
|
|
769
759
|
p.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !0 }), p.setIsDisableConnectSocket({ isDisableConnectSocket: !0 });
|
|
770
760
|
}, []);
|
|
771
|
-
return
|
|
761
|
+
return n({ offlineActive: t });
|
|
772
762
|
}, Ct = k.memo(pt), It = {
|
|
773
763
|
ConnectDetection: nt,
|
|
774
764
|
OfflineDetection: ht,
|