rc-lib-ui 1.4.8 → 1.4.9

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,4 +1,4 @@
1
- import { WsApi_Options_P } from './deps/WsApi';
1
+ import { WsApi, WsApi_Options_P } from './deps/WsApi';
2
2
  import { WsApi_Events } from './deps/WsApi/WsApi.types';
3
3
  import { BasePayloadSocket, SocketApi_Options_P, SocketApi_StateProps_P, SocketApiOptionsRequest } from './SocketApi.types';
4
4
  import { NetworkStatusInfoTracker } from 'dev-classes';
@@ -10,18 +10,24 @@ interface SocketApi_Events {
10
10
  timeOffReConnect(info: ConnectInfoProps): void;
11
11
  reConnect(status: boolean): void;
12
12
  network(info: NetworkStatusInfoTracker): void;
13
+ destroy(): void;
13
14
  }
14
15
  type CommonEvents = SocketApi_Events & WsApi_Events;
15
16
  export declare class SocketApi {
17
+ private static sessionId;
16
18
  private static state;
19
+ private static isGotWasFirstConnection;
20
+ private static infoNetwork;
17
21
  private static options;
18
- private static wsApi;
22
+ static wsApi: WsApi;
19
23
  private static delay;
20
24
  private static networkTicker;
21
25
  private static events;
22
26
  private static saveID;
23
27
  private static stateDefault;
24
28
  private static copyState;
29
+ private static setInfoNetwork;
30
+ static getInfoNetwork(): NetworkStatusInfoTracker;
25
31
  private static setState;
26
32
  private static resetState;
27
33
  private static setOptions;
@@ -56,6 +62,7 @@ export declare class SocketApi {
56
62
  static init: (options: WsApi_Options_P & SocketApi_Options_P) => void;
57
63
  static connect(): Promise<void>;
58
64
  static disconnect(): void;
65
+ static destroy(): void;
59
66
  static send<P extends BasePayloadSocket, Data extends BasePayloadSocket>(payload: P, cb?: (data: Data) => void): void;
60
67
  static stopReConnect(status?: boolean): void;
61
68
  static socketReConnect: () => void;
@@ -1,14 +1,11 @@
1
- import { NetworkStatusInfoTracker } from 'dev-classes';
2
1
  import { WsApiE_StatusConnect_OR } from './deps/WsApi';
3
2
  import { WsApi_Response } from './deps/WsApi/WsApi.types';
4
3
  export interface SocketApi_Options_P {
5
4
  isReConnectNetworkOnline?: boolean;
6
5
  listUrlsCheckConnectNetwork?: string[];
7
6
  }
8
- type SocketApi_StateProps_OR = 'isDisconnect' | 'isActiveReConnect' | 'isOfflineSocket' | 'isGotWasFirstConnection' | 'isStartCheckNetwork';
9
- export type SocketApi_StateProps_P = Record<SocketApi_StateProps_OR, boolean> & {
10
- infoNetwork: NetworkStatusInfoTracker;
11
- };
7
+ type SocketApi_StateProps_OR = 'isDisconnect' | 'isActiveReConnect' | 'isOfflineSocket';
8
+ export type SocketApi_StateProps_P = Record<SocketApi_StateProps_OR, boolean>;
12
9
  export type SocketApi_StatusConnect_OR = WsApiE_StatusConnect_OR;
13
10
  export type BasePayloadSocket = {
14
11
  action: string;
@@ -31,11 +31,17 @@ export declare class WsApi {
31
31
  cb: any;
32
32
  }[];
33
33
  getOptions: () => WsApi_Options_P;
34
+ setOptions: (options: Partial<WsApi_Options_P>) => {
35
+ url: string;
36
+ timeReConnect: number;
37
+ numberOfRepit?: number;
38
+ };
34
39
  init: (options: typeof this.options) => void;
35
40
  getIsInitWS: () => boolean;
36
41
  connect(): void;
37
42
  close(): void;
38
43
  disconnect(): void;
44
+ destroy(): void;
39
45
  send(data: any): void;
40
46
  setRequestSave(reqInfo: (typeof this.state.arrSaveReq)[number]): void;
41
47
  private getItemsRequestSaveByAction;
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ interface ButtonActionsProps {
3
+ connect: () => void;
4
+ isDisableConnectSocket: boolean;
5
+ }
6
+ export interface ReConnectButtonProps {
7
+ children: (actions: ButtonActionsProps) => React.ReactNode;
8
+ }
9
+ export declare const Connect: React.NamedExoticComponent<ReConnectButtonProps>;
10
+ export {};
@@ -8,6 +8,7 @@ export declare const Socket: {
8
8
  Buttons: {
9
9
  OfflineActive: React.NamedExoticComponent<import('./Buttons/OfflineButton').OfflineButtonProps>;
10
10
  ReConnect: React.NamedExoticComponent<import('./Buttons/ReConnect').ReConnectButtonProps>;
11
+ Connect: React.NamedExoticComponent<import('./Buttons/Connect').ReConnectButtonProps>;
11
12
  };
12
13
  Initialization: React.NamedExoticComponent<InitializationSocketProps>;
13
14
  };
package/dist/socket.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import './socket.css';var z = Object.defineProperty;
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);
2
+ var F = (n, t, s) => t in n ? z(n, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[t] = s;
3
+ var i = (n, t, s) => F(n, typeof t != "symbol" ? t + "" : t, s);
4
4
  import { jsx as D } from "react/jsx-runtime";
5
- import E, { useState as B, useRef as x, useCallback as A, useEffect as O } from "react";
5
+ import N, { useState as T, useRef as W, useCallback as O, 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 L from "classnames";
9
- import { u as W } from "./browser-DJTk47DY.js";
8
+ import B from "classnames";
9
+ import { u as x } from "./browser-DJTk47DY.js";
10
10
  import { N as $ } from "./index-sxz_mdqa.js";
11
- const T = {
11
+ const L = {
12
12
  statusConnect: "disconnect",
13
13
  isOfflineSocket: !1,
14
14
  //Текущее состояние сокета. Зависит от события timeOffReConnect и если задаёться isDisableConnectSocket: true
@@ -20,22 +20,22 @@ const T = {
20
20
  isSelectOffline: !1
21
21
  //Для того что бы 2й раз окно не показывать
22
22
  }
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")({
23
+ }, K = JSON.parse(JSON.stringify(L)), b = U(() => L), C = {
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((t) => ({ infoNoConnectServer: { ...t.infoNoConnectServer, ...n } })),
30
+ setIsDisableConnectSocket: ({ isDisableConnectSocket: n }) => b.setState({ isDisableConnectSocket: n })
31
+ }, m = {
32
+ getStatusConnectSocket: (n) => n.statusConnect,
33
+ getStatusIsReConnectSocket: (n) => n.isReConnectSocket,
34
+ getStatusReady: (n) => n.isReadySocket,
35
+ getIsOfflineSocket: (n) => n.isOfflineSocket,
36
+ getInfoNoConnectServer: (n) => n.infoNoConnectServer,
37
+ getIsDisableConnectSocket: (n) => n.isDisableConnectSocket
38
+ }, R = (n) => b(n), 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: o, ...e }) => /* @__PURE__ */ D(G, { ...e, unmountOnExit: !0, children: /* @__PURE__ */ D(Q, { children: o }) })
47
- )(({ theme: o }) => ({
46
+ ({ children: n, ...t }) => /* @__PURE__ */ D(G, { ...t, unmountOnExit: !0, children: /* @__PURE__ */ D(Q, { children: n }) })
47
+ )(({ theme: n }) => ({
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: (o) => ![""].includes(o)
70
- })(({ theme: o }) => ({
69
+ shouldForwardProp: (n) => ![""].includes(n)
70
+ })(({ theme: n }) => ({
71
71
  top: "100%",
72
72
  "& .MuiCollapse-wrapper": {
73
73
  height: 10
@@ -75,210 +75,211 @@ const T = {
75
75
  "& span": {
76
76
  height: "100%"
77
77
  }
78
- })), j = ({ text: o = "Происходит подключение к серверу", className: e, ...t }) => {
79
- const n = b(R.getStatusConnectSocket), i = b(R.getStatusIsReConnectSocket);
78
+ })), j = ({ text: n = "Происходит подключение к серверу", className: t, ...s }) => {
79
+ const o = R(m.getStatusConnectSocket), r = R(m.getStatusIsReConnectSocket);
80
80
  return /* @__PURE__ */ D(
81
81
  Z,
82
82
  {
83
- in: n === "pending" || i,
83
+ in: o === "pending" || r,
84
84
  collapsedSize: "1px",
85
- className: L(Y["connect-server-anim"], e),
85
+ className: B(Y["connect-server-anim"], t),
86
86
  unmountOnExit: !0,
87
- ...t,
88
- children: o
87
+ ...s,
88
+ children: n
89
89
  }
90
90
  );
91
- }, _ = E.memo(j);
92
- class ee {
91
+ }, _ = N.memo(j);
92
+ class tt {
93
93
  constructor() {
94
- r(this, "defaultProps", {
94
+ i(this, "defaultProps", {
95
95
  interval: 5e3
96
96
  });
97
- r(this, "startActionEvery", (e, t = this.defaultProps) => {
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));
97
+ i(this, "startActionEvery", (t, s = this.defaultProps) => {
98
+ const o = (f) => {
99
+ s != null && s.watchIdInterval && (s == null || s.watchIdInterval(f));
100
+ }, r = (f) => {
101
+ s != null && s.controlAction && (s == null || s.controlAction(f));
102
102
  };
103
- let a = !0, l, c, f;
104
- const S = (u = !0) => {
103
+ let c = !0, l, a, u;
104
+ const S = (f = !0) => {
105
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)" });
106
+ c = !1, clearInterval(l), o(null), f ? a && a({ status: f, msg: h + ": (true)" }) : u && u({ status: f, msg: h + ": (false)" });
107
107
  };
108
108
  return {
109
- promise: new Promise((u, h) => {
110
- c = u, f = h;
109
+ promise: new Promise((f, h) => {
110
+ a = f, u = h;
111
111
  let y = 0, d = 0;
112
112
  l = setInterval(
113
113
  () => {
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("Время загрузки истекло") });
114
+ if (y += s.interval, d += 1, s != null && s.cutoffTime && y > s.cutoffTime || s != null && s.countAction && (s == null ? void 0 : s.countAction) < d) {
115
+ c = !1, clearInterval(l), o(null), h({ status: !1, msg: Error("Время загрузки истекло") });
116
116
  return;
117
117
  }
118
- e() && (a = !1, clearInterval(l), n(null), u({ status: !0, msg: "cb вернул true" }));
118
+ t() && (c = !1, clearInterval(l), o(null), f({ status: !0, msg: "cb вернул true" }));
119
119
  },
120
- t.interval < 200 ? 200 : t.interval
121
- ), n(l), i({
122
- getIsActiveEvent: () => a,
120
+ s.interval < 200 ? 200 : s.interval
121
+ ), o(l), r({
122
+ getIsActiveEvent: () => c,
123
123
  stop: S
124
124
  });
125
125
  }),
126
126
  stop: S
127
127
  };
128
128
  });
129
- r(this, "oneOf", (e, t, { second: n }) => {
130
- let i = 1;
131
- e().then(() => {
132
- i === 1 && (i = 0);
129
+ i(this, "oneOf", (t, s, { second: o }) => {
130
+ let r = 1;
131
+ t().then(() => {
132
+ r === 1 && (r = 0);
133
133
  });
134
- let a = setInterval(() => {
135
- i === 1 && t(), clearInterval(a);
136
- }, n * 1e3);
134
+ let c = setInterval(() => {
135
+ r === 1 && s(), clearInterval(c);
136
+ }, o * 1e3);
137
137
  });
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));
138
+ i(this, "oneOfPromise", (t, s, { second: o }) => new Promise((r, c) => {
139
+ let l = 1, a = { status: !1, msg: "" };
140
+ t().then((S) => {
141
+ l === 1 && (l = 0, r(S));
142
142
  }).catch((S) => {
143
- l === 1 && (l = 0, c.msg = S, a(S));
143
+ l === 1 && (l = 0, a.msg = S, c(S));
144
144
  });
145
- let f = setInterval(() => {
145
+ let u = setInterval(() => {
146
146
  if (l === 1) {
147
- if (l = 0, typeof t == "function") {
148
- a({ status: !1, msg: "", ...t(c) });
147
+ if (l = 0, typeof s == "function") {
148
+ c({ status: !1, msg: "", ...s(a) });
149
149
  return;
150
150
  }
151
- a({ status: !1, msg: "oneOfPromise reject" });
151
+ c({ status: !1, msg: "oneOfPromise reject" });
152
152
  }
153
- clearInterval(f);
154
- }, n * 1e3);
153
+ clearInterval(u);
154
+ }, o * 1e3);
155
155
  }));
156
156
  }
157
157
  }
158
158
  class H {
159
- constructor(e) {
160
- r(this, "subscribersEvents", {});
161
- r(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
162
- r(this, "getSubscribers", () => this.subscribersEvents);
163
- r(this, "subscribe", (e, t) => {
164
- var n;
165
- (n = this.subscribersEvents[e]) == null || n.push(t);
159
+ constructor(t) {
160
+ i(this, "subscribersEvents", {});
161
+ i(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
162
+ i(this, "getSubscribers", () => this.subscribersEvents);
163
+ i(this, "subscribe", (t, s) => {
164
+ var o;
165
+ (o = this.subscribersEvents[t]) == null || o.push(s);
166
166
  });
167
- r(this, "unsubscribe", (e, t) => {
168
- var n;
169
- this.subscribersEvents[e] && (this.subscribersEvents[e] = (n = this.subscribersEvents[e]) == null ? void 0 : n.filter((i) => i !== t));
167
+ i(this, "unsubscribe", (t, s) => {
168
+ var o;
169
+ this.subscribersEvents[t] && (this.subscribersEvents[t] = (o = this.subscribersEvents[t]) == null ? void 0 : o.filter((r) => r !== s));
170
170
  });
171
- r(this, "publish", (e, t) => {
172
- var n;
173
- this.subscribersEvents[e] && ((n = this.subscribersEvents[e]) == null || n.forEach((i) => {
174
- i(t);
171
+ i(this, "publish", (t, s) => {
172
+ var o;
173
+ this.subscribersEvents[t] && ((o = this.subscribersEvents[t]) == null || o.forEach((r) => {
174
+ r(s);
175
175
  }));
176
176
  });
177
- r(this, "resetSubscribers", () => {
178
- const e = Object.entries(this.subscribersEvents);
179
- for (const [t] of e)
180
- this.subscribersEvents[t] = [];
177
+ i(this, "resetSubscribers", () => {
178
+ const t = Object.entries(this.subscribersEvents);
179
+ for (const [s] of t)
180
+ this.subscribersEvents[s] = [];
181
181
  });
182
- e.forEach((t) => {
183
- this.subscribersEvents[t] = [];
182
+ t.forEach((s) => {
183
+ this.subscribersEvents[s] = [];
184
184
  });
185
185
  }
186
186
  }
187
- class te {
187
+ class et {
188
188
  constructor() {
189
- r(this, "options", {
189
+ i(this, "options", {
190
190
  timeReConnect: 5e3,
191
191
  numberOfRepit: 5,
192
192
  url: ""
193
193
  });
194
- r(this, "state", {
194
+ i(this, "state", {
195
195
  statusConnect: "disconnect",
196
196
  ws: null,
197
197
  arrSaveReq: []
198
198
  });
199
- r(this, "initOptions", !1);
200
- r(this, "events", new H(["status", "msg", "error"]));
201
- r(this, "stateDefault", this.copyState(this.state));
202
- r(this, "eventListener", (e) => {
203
- var n, i;
204
- const t = [
199
+ i(this, "initOptions", !1);
200
+ i(this, "events", new H(["status", "msg", "error"]));
201
+ i(this, "stateDefault", this.copyState(this.state));
202
+ i(this, "eventListener", (t) => {
203
+ var o, r;
204
+ const s = [
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 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);
210
+ for (let c = 0; c < s.length; c++) {
211
+ const [l, a] = s[c];
212
+ t === "add" ? (o = this.state.ws) == null || o.addEventListener(l, a) : (r = this.state.ws) == null || r.removeEventListener(l, a);
213
213
  }
214
214
  });
215
- r(this, "openHandler", () => {
215
+ i(this, "openHandler", () => {
216
216
  this.setStatus("ready");
217
217
  });
218
- r(this, "closeHandler", () => {
218
+ i(this, "closeHandler", () => {
219
219
  this.setStatus("close");
220
220
  });
221
- r(this, "msgHandler", (e) => {
222
- const t = JSON.parse(e.data ? e.data : "{}");
221
+ i(this, "msgHandler", (t) => {
222
+ const s = JSON.parse(t.data ? t.data : "{}");
223
223
  try {
224
- const { action: n } = t, i = this.findDataRequestByAction(n);
225
- if (i) {
226
- const { cb: a, ...l } = i, { payload: c, ...f } = l;
227
- this.events.publish("msg", { ...t, request: { ...f, ...c } });
224
+ const { action: o } = s, r = this.findDataRequestByAction(o);
225
+ if (r) {
226
+ const { cb: c, ...l } = r, { payload: a, ...u } = l;
227
+ this.events.publish("msg", { ...s, request: { ...u, ...a } });
228
228
  } else
229
- this.events.publish("msg", t);
230
- n && this.filterSaveItemsByResponse(t);
229
+ this.events.publish("msg", s);
230
+ o && this.filterSaveItemsByResponse(s);
231
231
  } catch {
232
232
  this.events.publish("msg", {});
233
233
  }
234
234
  });
235
- r(this, "errHandler", (e) => {
236
- var t;
235
+ i(this, "errHandler", (t) => {
236
+ var s;
237
237
  this.events.publish("error", {
238
- readyState: (t = this.state.ws) == null ? void 0 : t.readyState,
238
+ readyState: (s = this.state.ws) == null ? void 0 : s.readyState,
239
239
  arrSaveReq: this.getRequestSave()
240
240
  }), this.setStatus("error");
241
241
  });
242
- r(this, "errorInitSocket", () => {
242
+ i(this, "errorInitSocket", () => {
243
243
  console.error("Вы не установили опции");
244
244
  });
245
- r(this, "setStatus", (e) => {
246
- this.setState({ statusConnect: e }), this.events.publish("status", e);
245
+ i(this, "setStatus", (t) => {
246
+ this.setState({ statusConnect: t }), this.events.publish("status", t);
247
247
  });
248
248
  /*----------------------------------------------------------------------------------------------------------*/
249
- r(this, "getState", () => this.state);
250
- r(this, "getSocket", () => this.state.ws);
251
- r(this, "getStatusSocket", () => this.state.statusConnect);
252
- r(this, "getRequestSave", () => this.state.arrSaveReq);
253
- r(this, "getOptions", () => this.options);
249
+ i(this, "getState", () => this.state);
250
+ i(this, "getSocket", () => this.state.ws);
251
+ i(this, "getStatusSocket", () => this.state.statusConnect);
252
+ i(this, "getRequestSave", () => this.state.arrSaveReq);
253
+ i(this, "getOptions", () => this.options);
254
+ i(this, "setOptions", (t) => this.options = { ...this.options, ...t });
254
255
  // getRegisteredEvents = this.events.getListNameEvents;
255
256
  // on = this.events.subscribe;
256
257
  // off = this.events.unsubscribe;
257
- r(this, "init", (e) => {
258
- this.initOptions = !0, this.options = { ...this.options, ...e };
258
+ i(this, "init", (t) => {
259
+ this.initOptions = !0, this.setOptions(t);
259
260
  });
260
- r(this, "getIsInitWS", () => {
261
- const e = this.initOptions;
262
- return e || this.errorInitSocket(), e;
261
+ i(this, "getIsInitWS", () => {
262
+ const t = this.initOptions;
263
+ return t || this.errorInitSocket(), t;
263
264
  });
264
- r(this, "findDataRequestByAction", (e) => this.getItemsRequestSaveByAction(e).sort((i, a) => a.requestTime - i.requestTime)[0]);
265
+ i(this, "findDataRequestByAction", (t) => this.getItemsRequestSaveByAction(t).sort((r, c) => c.requestTime - r.requestTime)[0]);
265
266
  }
266
267
  resetState() {
267
268
  this.state = this.copyState(this.stateDefault);
268
269
  }
269
- setState(e) {
270
- this.state = { ...this.state, ...e };
270
+ setState(t) {
271
+ this.state = { ...this.state, ...t };
271
272
  }
272
- copyState(e) {
273
- return JSON.parse(JSON.stringify(e));
273
+ copyState(t) {
274
+ return JSON.parse(JSON.stringify(t));
274
275
  }
275
- filterSaveItemsByResponse(e) {
276
- const t = this.getRequestSave(), n = [];
277
- for (let i = 0; i < t.length; i++) {
278
- const a = t[i];
279
- a.payload.action !== e.action ? n.push(a) : a.cb && a.cb(e);
276
+ filterSaveItemsByResponse(t) {
277
+ const s = this.getRequestSave(), o = [];
278
+ for (let r = 0; r < s.length; r++) {
279
+ const c = s[r];
280
+ c.payload.action !== t.action ? o.push(c) : c.cb && c.cb(t);
280
281
  }
281
- this.state.arrSaveReq = n;
282
+ this.state.arrSaveReq = o;
282
283
  }
283
284
  connect() {
284
285
  this.initOptions && (this.close(), this.setState({
@@ -286,206 +287,217 @@ class te {
286
287
  }), this.setStatus("pending"), this.eventListener("add"));
287
288
  }
288
289
  close() {
289
- var e;
290
- (e = this.state.ws) == null || e.close(), this.eventListener("remove"), this.setStatus("close");
290
+ var t;
291
+ (t = this.state.ws) == null || t.close(), this.eventListener("remove"), this.setStatus("close");
291
292
  }
292
293
  disconnect() {
293
- this.close(), this.setStatus("disconnect"), this.resetState(), this.events.resetSubscribers();
294
+ this.close(), this.setStatus("disconnect"), this.resetState();
294
295
  }
295
- send(e) {
296
- var n;
297
- const t = JSON.stringify(e);
298
- (n = this.state.ws) == null || n.send(t);
296
+ destroy() {
297
+ const { statusConnect: t } = this.getState();
298
+ t !== "disconnect" && this.disconnect(), this.events.resetSubscribers();
299
299
  }
300
- setRequestSave(e) {
301
- if ("action" in e.payload) {
302
- const t = this.state.arrSaveReq.findIndex((n) => n.payload.action === e.payload.action);
303
- ~t ? this.state.arrSaveReq[t] = e : this.state.arrSaveReq.push(e);
300
+ send(t) {
301
+ var o;
302
+ const s = JSON.stringify(t);
303
+ (o = this.state.ws) == null || o.send(s);
304
+ }
305
+ setRequestSave(t) {
306
+ if ("action" in t.payload) {
307
+ const s = this.state.arrSaveReq.findIndex((o) => o.payload.action === t.payload.action);
308
+ ~s ? this.state.arrSaveReq[s] = t : this.state.arrSaveReq.push(t);
304
309
  }
305
310
  }
306
311
  //INFO: Запросов может быть несколько. И время запроса разное
307
- getItemsRequestSaveByAction(e) {
308
- return this.getRequestSave().filter((t) => {
309
- var n;
310
- return ((n = t == null ? void 0 : t.payload) == null ? void 0 : n.action) === e;
312
+ getItemsRequestSaveByAction(t) {
313
+ return this.getRequestSave().filter((s) => {
314
+ var o;
315
+ return ((o = s == null ? void 0 : s.payload) == null ? void 0 : o.action) === t;
311
316
  });
312
317
  }
313
318
  }
314
- const s = class s {
315
- static copyState(e) {
316
- return JSON.parse(JSON.stringify(e));
319
+ const e = class e {
320
+ static copyState(t) {
321
+ return JSON.parse(JSON.stringify(t));
322
+ }
323
+ static setInfoNetwork(t) {
324
+ e.infoNetwork = t;
317
325
  }
318
- static setState(e) {
319
- s.state = { ...s.state, ...e };
326
+ static getInfoNetwork() {
327
+ return e.infoNetwork;
328
+ }
329
+ static setState(t) {
330
+ e.state = { ...e.state, ...t };
320
331
  }
321
332
  static resetState() {
322
- s.state = s.copyState(s.stateDefault);
333
+ e.state = e.copyState(e.stateDefault);
323
334
  }
324
- static setOptions(e) {
325
- s.options = { ...s.options, ...e };
335
+ static setOptions(t) {
336
+ e.options = { ...e.options, ...t };
326
337
  }
327
- static setStatusReConnect(e) {
328
- s.setState({ isActiveReConnect: e }), s.events.publish("reConnect", e);
338
+ static setStatusReConnect(t) {
339
+ e.setState({ isActiveReConnect: t }), e.events.publish("reConnect", t);
329
340
  }
330
341
  static async connect() {
331
- s.wsApi.getIsInitWS() && (console.log("CONNECT WS"), s.setState({ isDisconnect: !1 }), s.wsApi.connect());
342
+ e.wsApi.getIsInitWS() && (console.log("CONNECT WS"), e.setState({ isDisconnect: !1 }), e.wsApi.connect());
332
343
  }
333
344
  static disconnect() {
334
- var e;
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());
345
+ const { isDisconnect: t, isActiveReConnect: s } = e.getState();
346
+ s && e.stopReConnect(!1), t || (e.setState({ isDisconnect: !0 }), console.log("DISCONNECT WS"), e.wsApi.disconnect(), e.resetState());
347
+ }
348
+ static destroy() {
349
+ var t;
350
+ e.events.publish("destroy", void 0), e.state.isDisconnect || (e.setState({ isDisconnect: !0 }), console.log("DISCONNECT WS"), e.wsApi.disconnect()), e.wsApi.destroy(), e.resetState(), e.events.resetSubscribers(), (t = this.networkTicker) == null || t.destroy();
336
351
  }
337
- static send(e, t) {
338
- const { action: n, ...i } = e, a = i != null && i.request_id ? i.request_id : W(), l = Date.now();
339
- s.wsApi.setRequestSave({
340
- requestAction: n,
341
- request_id: a,
352
+ static send(t, s) {
353
+ const { action: o, ...r } = t, c = r != null && r.request_id ? r.request_id : x(), l = Date.now();
354
+ e.wsApi.setRequestSave({
355
+ requestAction: o,
356
+ request_id: c,
342
357
  requestTime: l,
343
- payload: { action: n, ...i },
344
- cb: t
358
+ payload: { action: o, ...r },
359
+ cb: s
345
360
  });
346
- const c = s.wsApi.getSocket();
347
- if (!c || c.readyState !== 1) {
361
+ const a = e.wsApi.getSocket();
362
+ if (!a || a.readyState !== 1) {
348
363
  console.log("Нет подключения к сокету. Запрос сохранён в setRequestSave");
349
364
  return;
350
365
  }
351
- s.wsApi.send(e);
366
+ e.wsApi.send(t);
352
367
  }
353
- static stopReConnect(e) {
368
+ static stopReConnect(t) {
354
369
  console.dir("функция stop не присвоена к stopReConnect");
355
370
  }
356
- static async request(e, t = {}) {
357
- return new Promise((n, i) => {
371
+ static async request(t, s = {}) {
372
+ return new Promise((o, r) => {
358
373
  var d, g;
359
- if ((d = t == null ? void 0 : t.signal) != null && d.aborted) {
360
- i(new DOMException("Aborted", "AbortError"));
374
+ if ((d = s == null ? void 0 : s.signal) != null && d.aborted) {
375
+ r(new DOMException("Aborted", "AbortError"));
361
376
  return;
362
377
  }
363
- const a = e.action, l = e.request_id ? e.request_id : W(), c = Date.now();
364
- s.wsApi.setRequestSave({
365
- requestAction: a,
378
+ const c = t.action, l = t.request_id ? t.request_id : x(), a = Date.now();
379
+ e.wsApi.setRequestSave({
380
+ requestAction: c,
366
381
  request_id: l,
367
- requestTime: c,
368
- payload: e,
382
+ requestTime: a,
383
+ payload: t,
369
384
  cb: void 0
370
385
  });
371
- let f;
372
- t != null && t.timeout && (f = setTimeout(() => {
373
- h(), i(new Error("Request timeout"));
374
- }, t.timeout));
386
+ let u;
387
+ s != null && s.timeout && (u = setTimeout(() => {
388
+ h(), r(new Error("Request timeout"));
389
+ }, s.timeout));
375
390
  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"));
391
+ h(), r(v);
392
+ }, k = (v) => {
393
+ var E;
394
+ const A = this.wsApi.findDataRequestByAction(c);
395
+ !A || ((E = v == null ? void 0 : v.request) == null ? void 0 : E.requestAction) !== A.requestAction || (h(), o({ ...v }));
396
+ }, f = () => {
397
+ h(), r(new DOMException("Aborted", "AbortError"));
383
398
  }, h = () => {
384
399
  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);
400
+ e.off("msg", k), e.off("error", S), u && clearTimeout(u), (v = s == null ? void 0 : s.signal) == null || v.removeEventListener("abort", f);
386
401
  };
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();
402
+ e.on("msg", k), e.on("error", S), (g = s == null ? void 0 : s.signal) == null || g.addEventListener("abort", f);
403
+ const y = e.wsApi.getSocket();
389
404
  if (!y || y.readyState !== 1) {
390
405
  const v = "Нет подключения к сокету";
391
- console.error(v), h(), i(new Error(v));
406
+ console.error(v), h(), r(new Error(v));
392
407
  return;
393
408
  }
394
- s.wsApi.send(e);
409
+ e.wsApi.send(t);
395
410
  });
396
411
  }
397
412
  };
398
- r(s, "state", {
413
+ i(e, "sessionId", ""), i(e, "state", {
399
414
  isDisconnect: !0,
400
415
  isActiveReConnect: !1,
401
- isOfflineSocket: !0,
402
- isGotWasFirstConnection: !1,
403
- isStartCheckNetwork: !1,
404
- //не используеться
405
- infoNetwork: {
406
- isNetwork: !1,
407
- typeNetwork: ""
408
- }
409
- }), r(s, "options", {
416
+ isOfflineSocket: !0
417
+ // isStartCheckNetwork: false, //не используеться
418
+ }), i(e, "isGotWasFirstConnection", !1), i(e, "infoNetwork", {
419
+ isNetwork: !1,
420
+ typeNetwork: ""
421
+ }), i(e, "options", {
410
422
  isReConnectNetworkOnline: !1,
411
423
  listUrlsCheckConnectNetwork: []
412
- }), 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", {
424
+ }), i(e, "wsApi", new et()), i(e, "delay", new tt()), i(e, "networkTicker", null), i(e, "events", new H(["timeOffReConnect", "reConnect", "network", "destroy"])), i(e, "saveID", {
413
425
  idReConnect: null,
414
426
  checkConnect: null
415
- }), r(s, "stateDefault", s.copyState(s.state)), r(s, "setInfoConnect", (e) => {
416
- e.status || s.close(), s.events.publish("timeOffReConnect", e), s.setStatusReConnect(!1);
417
- }), r(s, "online", () => {
418
- !s.state.isActiveReConnect && s.options.isReConnectNetworkOnline && /*#################-----------<{ Убрал 21.08.2025 }>------------############# */
419
- s.state.isGotWasFirstConnection && s.socketReConnect();
420
- }), r(s, "offline", () => {
421
- s.state.isActiveReConnect && s.stopReConnect(!1);
422
- }), r(s, "splitOptions", (e) => Object.entries(e).reduce(
423
- (t, [n, i]) => {
424
- const a = s.wsApi.getOptions();
425
- return n in a ? { ...t, WsOptions: { ...t.WsOptions, [n]: i } } : { ...t, SocketApiOptions: { ...t.SocketApiOptions, [n]: i } };
427
+ }), i(e, "stateDefault", e.copyState(e.state)), i(e, "setInfoConnect", (t) => {
428
+ t.status || e.close(), e.events.publish("timeOffReConnect", t), e.setStatusReConnect(!1);
429
+ }), i(e, "online", () => {
430
+ !e.state.isActiveReConnect && e.options.isReConnectNetworkOnline && /*#################-----------<{ Убрал 21.08.2025 }>------------############# */
431
+ e.isGotWasFirstConnection && e.socketReConnect();
432
+ }), i(e, "offline", () => {
433
+ e.state.isActiveReConnect && e.stopReConnect(!1);
434
+ }), i(e, "splitOptions", (t) => Object.entries(t).reduce(
435
+ (s, [o, r]) => {
436
+ const c = e.wsApi.getOptions();
437
+ return o in c ? { ...s, WsOptions: { ...s.WsOptions, [o]: r } } : { ...s, SocketApiOptions: { ...s.SocketApiOptions, [o]: r } };
426
438
  },
427
439
  { WsOptions: {}, SocketApiOptions: {} }
428
440
  )), /*---------------------------------------------------------------------------------------------------------------------------*/
429
- r(s, "getState", () => s.state), r(s, "getOptions", () => ({ ...s.options, ...s.wsApi.getOptions() })), r(s, "on", (e, t) => {
430
- s.wsApi.events.getListNameEvents().includes(e) ? s.wsApi.events.subscribe(e, t) : s.events.subscribe(e, t);
431
- }), r(s, "off", (e, t) => {
432
- s.wsApi.events.getListNameEvents().includes(e) ? s.wsApi.events.unsubscribe(e, t) : s.events.unsubscribe(e, t);
433
- }), r(s, "getRequestSave", s.wsApi.getRequestSave), r(s, "getStatusSocket", s.wsApi.getStatusSocket), r(s, "close", () => {
434
- s.state.isActiveReConnect ? s.stopReConnect(!1) : s.wsApi.close();
441
+ i(e, "getState", () => e.state), i(e, "getOptions", () => ({ ...e.options, ...e.wsApi.getOptions() })), i(e, "on", (t, s) => {
442
+ e.wsApi.events.getListNameEvents().includes(t) ? e.wsApi.events.subscribe(t, s) : e.events.subscribe(t, s);
443
+ }), i(e, "off", (t, s) => {
444
+ e.wsApi.events.getListNameEvents().includes(t) ? e.wsApi.events.unsubscribe(t, s) : e.events.unsubscribe(t, s);
445
+ }), i(e, "getRequestSave", e.wsApi.getRequestSave), i(e, "getStatusSocket", e.wsApi.getStatusSocket), i(e, "close", () => {
446
+ e.state.isActiveReConnect ? e.stopReConnect(!1) : e.wsApi.close();
435
447
  }), //INFO: Проверить как часто вызываеться
436
- r(s, "setNetworkStatus", (e) => {
437
- s.events.publish("network", e), e.isNetwork ? s.online() : s.offline();
438
- }), r(s, "init", (e) => {
439
- const { WsOptions: t, SocketApiOptions: n } = s.splitOptions(e);
440
- s.networkTicker = new $(n.listUrlsCheckConnectNetwork ?? []), s.networkTicker.startEvents((i) => {
441
- s.getState(), s.setNetworkStatus(i), s.setState({ infoNetwork: i });
442
- }), s.setOptions(n), s.wsApi.init(t), s.wsApi.events.subscribe("status", (i) => {
443
- s.setState({ isOfflineSocket: i !== "ready" });
448
+ i(e, "setNetworkStatus", (t) => {
449
+ e.events.publish("network", t), e.setInfoNetwork(t), t.isNetwork ? e.online() : e.offline();
450
+ }), i(e, "init", (t) => {
451
+ const { WsOptions: s, SocketApiOptions: o } = e.splitOptions(t);
452
+ e.networkTicker = new $(o.listUrlsCheckConnectNetwork ?? []), e.networkTicker.startEvents((r) => {
453
+ e.getState(), e.setNetworkStatus(r);
454
+ }), e.setOptions(o), e.sessionId = x(), e.wsApi.init(s), e.wsApi.events.subscribe("status", (r) => {
455
+ e.setState({ isOfflineSocket: r !== "ready" });
444
456
  });
445
457
  }), /*------------------------------------------------------------------------------------------------------*/
446
- r(s, "socketReConnect", () => {
447
- if (s.wsApi.getIsInitWS())
448
- if (s.saveID.idReConnect)
449
- console.groupCollapsed("Процесс socketReConnect уже запущен"), console.log("SocketApi.saveID: ", s.saveID), console.groupEnd();
458
+ i(e, "socketReConnect", () => {
459
+ if (e.wsApi.getIsInitWS())
460
+ if (e.saveID.idReConnect)
461
+ console.groupCollapsed("Процесс socketReConnect уже запущен"), console.log("SocketApi.saveID: ", e.saveID), console.groupEnd();
450
462
  else {
451
- s.setStatusReConnect(!0), s.connect();
452
- const { timeReConnect: e, numberOfRepit: t } = s.wsApi.getOptions(), i = t && t > 1 ? t - 1 : 3;
453
- s.delay.startActionEvery(
454
- () => (console.log("reconnect:>>delay"), s.wsApi.getStatusSocket() === "ready" ? (console.dir("Подключение установлено"), !0) : (s.connect(), !1)),
463
+ e.setStatusReConnect(!0), e.connect();
464
+ const { timeReConnect: t, numberOfRepit: s } = e.wsApi.getOptions(), r = s && s > 1 ? s - 1 : 3;
465
+ e.delay.startActionEvery(
466
+ () => (console.log("reconnect:>>delay"), e.wsApi.getStatusSocket() === "ready" ? (console.dir("Подключение установлено"), !0) : (e.connect(), !1)),
455
467
  {
456
- interval: e,
457
- countAction: i,
468
+ interval: t,
469
+ countAction: r,
458
470
  watchIdInterval: (l) => {
459
- s.saveID.idReConnect = l;
471
+ e.saveID.idReConnect = l;
460
472
  },
461
- controlAction: ({ stop: l, getIsActiveEvent: c }) => {
462
- s.stopReConnect = l;
473
+ controlAction: ({ stop: l, getIsActiveEvent: a }) => {
474
+ e.stopReConnect = l;
463
475
  }
464
476
  }
465
477
  ).promise.then((l) => {
466
- s.setInfoConnect(l);
478
+ e.setInfoConnect(l);
467
479
  }).catch((l) => {
468
- if (s.wsApi.getStatusSocket() === "ready") {
469
- console.log("Сокет успел подключиться, игнорируем ошибку таймаута"), s.setInfoConnect({ status: !0, msg: "Подключено (восстановлено)" });
480
+ if (e.wsApi.getStatusSocket() === "ready") {
481
+ console.log("Сокет успел подключиться, игнорируем ошибку таймаута"), e.setInfoConnect({ status: !0, msg: "Подключено (восстановлено)" });
470
482
  return;
471
483
  }
472
- s.setInfoConnect(l);
484
+ e.setInfoConnect(l);
473
485
  });
474
486
  }
475
487
  });
476
- let p = s;
477
- const se = (o, e = {}) => {
478
- const t = o.action, { skip: n = !1, timeout: i = 5e3 } = e, [a, l] = B({
488
+ let p = e;
489
+ const st = (n, t = {}) => {
490
+ const s = n.action, { skip: o = !1, timeout: r = 5e3 } = t, [c, l] = T({
479
491
  data: null,
480
492
  error: "",
481
493
  isLoading: !1,
482
494
  isError: !1,
483
495
  isSuccess: !1
484
- }), c = b(R.getStatusReady), f = b(R.getStatusConnectSocket), S = x(null), C = x(e);
485
- C.current = e;
486
- const u = A(async () => {
487
- var g, v, I, N;
488
- if (n) return;
496
+ }), a = R(m.getStatusReady), u = R(m.getStatusConnectSocket), S = W(null), k = W(t);
497
+ k.current = t;
498
+ const f = O(async () => {
499
+ var g, v, A, E;
500
+ if (o) return;
489
501
  l((w) => ({
490
502
  ...w,
491
503
  isLoading: !0,
@@ -496,14 +508,14 @@ const se = (o, e = {}) => {
496
508
  })), S.current = new AbortController();
497
509
  const d = S.current.signal;
498
510
  try {
499
- const w = await p.request(o, { timeout: i, signal: d });
511
+ const w = await p.request(n, { timeout: r, signal: d });
500
512
  if (d.aborted) return;
501
513
  l((q) => ({
502
514
  ...q,
503
515
  data: w,
504
516
  isSuccess: !0,
505
517
  isLoading: !1
506
- })), (v = (g = C.current).onSuccess) == null || v.call(g, w);
518
+ })), (v = (g = k.current).onSuccess) == null || v.call(g, w);
507
519
  } catch (w) {
508
520
  if (d.aborted) return;
509
521
  const q = w instanceof Error ? w.message : String(w);
@@ -512,110 +524,121 @@ const se = (o, e = {}) => {
512
524
  error: q,
513
525
  isError: !0,
514
526
  isLoading: !1
515
- })), (N = (I = C.current).onError) == null || N.call(I, q);
527
+ })), (E = (A = k.current).onError) == null || E.call(A, q);
516
528
  }
517
- }, [n, t, o, i]);
518
- O(() => (!n && c && u(), () => {
529
+ }, [o, s, n, r]);
530
+ I(() => (!o && a && f(), () => {
519
531
  var d;
520
532
  (d = S.current) == null || d.abort();
521
- }), [u, n, c]), O(() => {
522
- !c && f === "pending" && l((d) => ({
533
+ }), [f, o, a]), I(() => {
534
+ !a && u === "pending" && l((d) => ({
523
535
  ...d,
524
536
  isError: !1,
525
537
  isSuccess: !1,
526
538
  error: "Потеряно соединение с сервером"
527
539
  }));
528
- }, [c, f]);
529
- const h = A(() => {
540
+ }, [a, u]);
541
+ const h = O(() => {
530
542
  var d;
531
- return (d = S.current) == null || d.abort(), u();
532
- }, [u]), y = A(() => {
543
+ return (d = S.current) == null || d.abort(), f();
544
+ }, [f]), y = O(() => {
533
545
  var d;
534
546
  (d = S.current) == null || d.abort(), l((g) => ({ ...g, isLoading: !1 }));
535
547
  }, []);
536
548
  return {
537
- ...a,
549
+ ...c,
538
550
  refetch: h,
539
551
  abort: y
540
552
  };
541
- }, Re = (o, e) => se(o, e), ne = (o) => {
542
- const { isModal: e } = b(R.getInfoNoConnectServer), t = b(R.getStatusIsReConnectSocket), n = b(R.getIsDisableConnectSocket), i = b(R.getStatusConnectSocket), [a, l] = B({
553
+ }, gt = (n, t) => st(n, t), nt = (n) => {
554
+ const { isModal: t } = R(m.getInfoNoConnectServer), s = R(m.getStatusIsReConnectSocket), o = R(m.getIsDisableConnectSocket), r = R(m.getStatusConnectSocket), [c, l] = T({
543
555
  isNetwork: !1,
544
556
  typeNetwork: ""
545
557
  });
546
- return O(() => (p.on("network", (c) => {
547
- console.log("network: ", c), l((f) => ({ ...f, isNetwork: c.isNetwork, typeNetwork: c.typeNetwork }));
548
- }), p.init(o.init), typeof o.onMount == "function" && o.onMount(), p.on("status", (c) => {
549
- const f = m.getState(), { isReadySocket: S, infoNoConnectServer: { isModal: C }, isOfflineSocket: u } = f;
550
- 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 });
551
- }), p.on("error", (c) => {
552
- console.log("error: ", c);
553
- }), p.on("reConnect", (c) => {
554
- console.log('on"reConnect" (status): ', c);
555
- const f = m.getState(), { isReConnectSocket: S, infoNoConnectServer: { isModal: C } } = f;
556
- S !== c && k.setStatusIsReConnectSocket({ isReConnectSocket: c }), C && c && k.setInfoNoConnectServer({ isModal: !1 });
557
- }), p.on("timeOffReConnect", (c) => {
558
- if (console.log("timeOffReConnect: ", c), k.setIsOfflineSocket({ isOfflineSocket: !c.status }), !c.status) {
559
- const f = m.getState(), { infoNoConnectServer: { isModal: S, isSelectOffline: C } } = f;
560
- let u = !1;
561
- !S && !C && (u = !0), u && k.setInfoNoConnectServer({ isModal: u });
558
+ return I(() => (p.on("network", (a) => {
559
+ console.log("network: ", a), l((u) => ({ ...u, isNetwork: a.isNetwork, typeNetwork: a.typeNetwork }));
560
+ }), p.init(n.init), typeof n.onMount == "function" && n.onMount(), p.on("status", (a) => {
561
+ const u = b.getState();
562
+ a !== "ready" && u.isReadySocket && C.setStatusReady({ isReadySocket: !1 });
563
+ const S = p.getState();
564
+ C.setIsOfflineSocket({ isOfflineSocket: S.isOfflineSocket }), !u.isReadySocket && a === "ready" && (C.setStatusReady({ isReadySocket: !0 }), u.isDisableConnectSocket && C.setIsDisableConnectSocket({ isDisableConnectSocket: !1 }), C.setInfoNoConnectServer({
565
+ isModal: !1,
566
+ isSelectOffline: !1
567
+ })), C.setStatusConnectSocket({ statusConnect: a });
568
+ }), p.on("error", (a) => {
569
+ console.log("error: ", a);
570
+ }), p.on("reConnect", (a) => {
571
+ console.log('on"reConnect" (status): ', a);
572
+ const u = b.getState(), { isReConnectSocket: S, infoNoConnectServer: { isModal: k } } = u;
573
+ S !== a && C.setStatusIsReConnectSocket({ isReConnectSocket: a }), k && a && C.setInfoNoConnectServer({ isModal: !1 });
574
+ }), p.on("timeOffReConnect", (a) => {
575
+ if (console.log("timeOffReConnect: ", a), C.setIsOfflineSocket({ isOfflineSocket: !a.status }), !a.status) {
576
+ const u = b.getState(), { infoNoConnectServer: { isModal: S, isSelectOffline: k } } = u;
577
+ let f = !1;
578
+ !S && !k && (f = !0), f && C.setInfoNoConnectServer({ isModal: f });
562
579
  }
563
580
  }), p.connect(), () => {
564
- typeof o.onUnmount == "function" && o.onUnmount(), console.dir("disconnect"), p.disconnect();
565
- }), []), O(() => {
566
- a.isNetwork && !n && !e && !t && ["close"].includes(i) && a.typeNetwork !== "none" && (console.log("Запущен socketReConnect"), p.socketReConnect());
567
- }, [n, e, t, i, a.typeNetwork, a.isNetwork]), O(() => {
568
- t && (!a.isNetwork || i === "ready") && (console.log("Запущен stopReConnect"), p.stopReConnect());
569
- }, [t, a.isNetwork, i]), O(() => {
570
- n && (console.log("isDisableConnectSocket: ", n), k.setIsOfflineSocket({ isOfflineSocket: !0 }), p.close());
571
- }, [n]), null;
572
- }, oe = E.memo(ne), ie = M(P, {
573
- shouldForwardProp: (o) => ![""].includes(o)
574
- })(({ theme: o }) => ({
581
+ typeof n.onUnmount == "function" && n.onUnmount(), console.dir("disconnect"), p.disconnect(), p.destroy();
582
+ }), []), I(() => {
583
+ c.isNetwork && !o && !t && !s && ["close"].includes(r) && c.typeNetwork !== "none" && (console.log("Запущен socketReConnect"), p.socketReConnect());
584
+ }, [o, t, s, r, c.typeNetwork, c.isNetwork]), I(() => {
585
+ s && (!c.isNetwork || r === "ready") && (console.log("Запущен stopReConnect"), p.stopReConnect());
586
+ }, [s, c.isNetwork, r]), I(() => {
587
+ o && (console.log("isDisableConnectSocket: ", o), C.setIsOfflineSocket({ isOfflineSocket: !0 }), p.close());
588
+ }, [o]), null;
589
+ }, ot = N.memo(nt), it = M(P, {
590
+ shouldForwardProp: (n) => ![""].includes(n)
591
+ })(({ theme: n }) => ({
575
592
  bottom: "100%",
576
- backgroundColor: o.palette.error.light,
593
+ backgroundColor: n.palette.error.light,
577
594
  backgroundImage: "linear-gradient(180deg, rgba(255, 255, 255, .15), rgba(255, 255, 255, 0))",
578
595
  "& .MuiCollapse-wrapper": {},
579
596
  "& span": {
580
597
  padding: "1px 10px"
581
598
  }
582
- })), re = ({ children: o, className: e, isNetwork: t, ...n }) => {
583
- const i = b(R.getIsOfflineSocket), a = b(R.getIsDisableConnectSocket), l = i || !t, c = "Оффлайн";
599
+ })), rt = ({ children: n, className: t, isNetwork: s, ...o }) => {
600
+ const r = R(m.getIsOfflineSocket), c = R(m.getIsDisableConnectSocket), l = r || !s || c, a = "Оффлайн";
584
601
  return /* @__PURE__ */ D(
585
- ie,
602
+ it,
586
603
  {
587
604
  in: l,
588
- className: L("socket-offline", e),
589
- ...n,
590
- children: typeof o == "function" ? o({ isDisableConnectSocket: a }) : a ? `Режим ${c}` : c
605
+ className: B("socket-offline", t),
606
+ ...o,
607
+ children: typeof n == "function" ? n({ isDisableConnectSocket: c }) : c ? `Режим ${a}` : a
591
608
  }
592
609
  );
593
- }, ce = E.memo(re), ae = ({ children: o }) => {
594
- const e = A(() => {
595
- k.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !1 });
610
+ }, ct = N.memo(rt), at = ({ children: n }) => {
611
+ const t = O(() => {
612
+ C.setIsDisableConnectSocket({ isDisableConnectSocket: !1 }), C.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !1 });
596
613
  }, []);
597
- return o({ reConnect: e });
598
- }, le = E.memo(ae), ue = ({ children: o }) => {
599
- const e = A(() => {
600
- k.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !0 }), k.setIsDisableConnectSocket({ isDisableConnectSocket: !0 });
614
+ return n({ reConnect: t });
615
+ }, lt = N.memo(at), ut = ({ children: n }) => {
616
+ const t = O(() => {
617
+ C.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !0 }), C.setIsDisableConnectSocket({ isDisableConnectSocket: !0 });
601
618
  }, []);
602
- return o({ offlineActive: e });
603
- }, Se = E.memo(ue), be = {
619
+ return n({ offlineActive: t });
620
+ }, St = N.memo(ut), ft = ({ children: n }) => {
621
+ const t = R(m.getIsDisableConnectSocket), s = O(() => {
622
+ t || p.connect();
623
+ }, [t]);
624
+ return n({ connect: s, isDisableConnectSocket: t });
625
+ }, dt = N.memo(ft), wt = {
604
626
  ConnectDetection: _,
605
- OfflineDetection: ce,
627
+ OfflineDetection: ct,
606
628
  Buttons: {
607
- OfflineActive: Se,
608
- ReConnect: le
629
+ OfflineActive: St,
630
+ ReConnect: lt,
631
+ Connect: dt
609
632
  },
610
- Initialization: oe
633
+ Initialization: ot
611
634
  };
612
635
  export {
613
- be as Socket,
636
+ wt as Socket,
614
637
  p as SocketApi,
615
- Re as createRequestSocketApi,
616
- k as socketActions,
617
- R as socketSelectors,
618
- m as socketStore,
619
- se as useRequestSocketApi,
620
- b as useSocketSelector
638
+ gt as createRequestSocketApi,
639
+ C as socketActions,
640
+ m as socketSelectors,
641
+ b as socketStore,
642
+ st as useRequestSocketApi,
643
+ R as useSocketSelector
621
644
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rc-lib-ui",
3
3
  "private": false,
4
- "version": "1.4.8",
4
+ "version": "1.4.9",
5
5
  "author": "SinGlEBW",
6
6
  "license": "MIT",
7
7
  "type": "module",