rc-lib-ui 1.1.28 → 1.1.45

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.
Files changed (20) hide show
  1. package/dist/NetworkAndSocket/Socket/api/SocketApi.d.ts +6 -7
  2. package/dist/NetworkAndSocket/Socket/api/SocketApi.types.d.ts +5 -3
  3. package/dist/NetworkAndSocket/Socket/api/deps/NetworkStatusTracker/NetworkStatusTracker.d.ts +0 -1
  4. package/dist/NetworkAndSocket/Socket/api/deps/WsApi/WsApi.d.ts +2 -2
  5. package/dist/NetworkAndSocket/Socket/api/deps/WsApi/WsApi.types.d.ts +2 -2
  6. package/dist/NetworkAndSocket/Socket/api/helpers/createRequestSocket/createRequestSocket.d.ts +2 -1
  7. package/dist/NetworkAndSocket/Socket/api/helpers/createRequestSocket/createRequestSocket.types.d.ts +3 -3
  8. package/dist/NetworkAndSocket/Socket/api/hooks/index.d.ts +1 -0
  9. package/dist/NetworkAndSocket/Socket/api/hooks/useRequestSocketApi/generators/generator1.d.ts +1 -0
  10. package/dist/NetworkAndSocket/Socket/api/hooks/useRequestSocketApi/generators/generator2.d.ts +1 -0
  11. package/dist/NetworkAndSocket/Socket/api/hooks/useRequestSocketApi/useRequestSocketApi.d.ts +11 -1
  12. package/dist/NetworkAndSocket/Socket/api/hooks/useRequestSocketApi/useRequestSocketApi.types.d.ts +9 -0
  13. package/dist/NetworkAndSocket/Socket/api/index.d.ts +2 -1
  14. package/dist/NetworkAndSocket/Socket/components/index.d.ts +2 -4
  15. package/dist/NetworkAndSocket/Socket/components/ui/CollapseCustom.d.ts +1 -2
  16. package/dist/NetworkAndSocket/Socket/store/socket.store.d.ts +1 -0
  17. package/dist/NetworkAndSocket/Socket/store/socket.types.d.ts +2 -0
  18. package/dist/socket.js +181 -153
  19. package/package.json +2 -2
  20. package/dist/NetworkAndSocket/index.d.ts +0 -2
@@ -1,18 +1,17 @@
1
- import { NetworkInfo } from './deps/NetworkControls';
2
1
  import { WsApi_Options_P } from './deps/WsApi';
3
2
  import { WsApi_Events } from './deps/WsApi/WsApi.types';
4
- import { SocketApi_Options_P, SocketApi_StateProps_P, SocketApiOptionsRequest } from './SocketApi.types';
3
+ import { BasePayloadSocket, SocketApi_Options_P, SocketApi_StateProps_P, SocketApiOptionsRequest } from './SocketApi.types';
4
+ import { NetworkStatusInfoTracker } from './deps/NetworkStatusTracker/NetworkStatusTracker.types';
5
5
  interface SocketApi_Events {
6
6
  timeOffReConnect(info: {
7
7
  status: boolean;
8
8
  msg: string;
9
9
  }): void;
10
10
  reConnect(status: boolean): void;
11
- network(info: NetworkInfo): void;
11
+ network(info: NetworkStatusInfoTracker): void;
12
12
  }
13
13
  type CommonEvents = SocketApi_Events & WsApi_Events;
14
14
  export declare class SocketApi {
15
- #private;
16
15
  private static state;
17
16
  private static options;
18
17
  private static wsApi;
@@ -47,7 +46,7 @@ export declare class SocketApi {
47
46
  action: string;
48
47
  [key: string]: any;
49
48
  };
50
- reqId: string;
49
+ request_id: string;
51
50
  cb: any;
52
51
  }[];
53
52
  static getStatusSocket: () => import('./deps/WsApi').WsApiE_StatusConnect_OR;
@@ -56,9 +55,9 @@ export declare class SocketApi {
56
55
  static init: (options: WsApi_Options_P & SocketApi_Options_P) => void;
57
56
  static connect(): Promise<void>;
58
57
  static disconnect(): void;
59
- static send<P = any, Data = any>(payload: P, cb?: (data: Data) => void): void;
58
+ static send<P extends BasePayloadSocket, Data extends BasePayloadSocket>(payload: P, cb?: (data: Data) => void): void;
60
59
  static stopReConnect(status?: boolean): void;
61
60
  static socketReConnect: () => void;
62
- static request<P = any, Data = any>(keyRequest: string, payload: P, options?: SocketApiOptionsRequest): Promise<Data>;
61
+ static request<P extends BasePayloadSocket, Data extends BasePayloadSocket>(payload: P, options?: SocketApiOptionsRequest): Promise<Data>;
63
62
  }
64
63
  export {};
@@ -4,13 +4,15 @@ export interface SocketApi_Options_P {
4
4
  isReConnectNetworkOnline?: boolean;
5
5
  listUrlsCheckConnectNetwork?: string[];
6
6
  }
7
- type SocketApi_StateProps_OR = 'isDisconnect' | 'isActiveReConnect' | 'isOfflineSocket' | 'isReady' | 'isGotWasFirstConnection' | 'isStartCheckNetwork';
7
+ type SocketApi_StateProps_OR = 'isDisconnect' | 'isActiveReConnect' | 'isOfflineSocket' | 'isGotWasFirstConnection' | 'isStartCheckNetwork';
8
8
  export type SocketApi_StateProps_P = Record<SocketApi_StateProps_OR, boolean>;
9
9
  export type SocketApi_StatusConnect_OR = WsApiE_StatusConnect_OR;
10
- export interface SocketRequest {
10
+ export type BasePayloadSocket = {
11
11
  action: string;
12
+ request_id?: string;
13
+ } & {
12
14
  [key: string]: any;
13
- }
15
+ };
14
16
  export type SocketResponse<P = any, Data = any> = WsApi_Response<P, Data>;
15
17
  export interface SocketApiOptionsRequest {
16
18
  timeout?: number;
@@ -6,7 +6,6 @@ export declare class NetworkStatusTracker {
6
6
  private setState;
7
7
  private getState;
8
8
  constructor(listUrls: string[]);
9
- private getFetchOptions;
10
9
  private getConnection;
11
10
  private getIsNetwork;
12
11
  private getTypeNetwork;
@@ -27,7 +27,7 @@ export declare class WsApi {
27
27
  action: string;
28
28
  [key: string]: any;
29
29
  };
30
- reqId: string;
30
+ request_id: string;
31
31
  cb: any;
32
32
  }[];
33
33
  getOptions: () => WsApi_Options_P;
@@ -46,7 +46,7 @@ export declare class WsApi {
46
46
  action: string;
47
47
  [key: string]: any;
48
48
  };
49
- reqId: string;
49
+ request_id: string;
50
50
  cb: any;
51
51
  };
52
52
  }
@@ -16,7 +16,7 @@ export interface WsApi_RequestMeta<P> {
16
16
  requestAction: string;
17
17
  requestTime: number;
18
18
  payload: P;
19
- reqId: string;
19
+ request_id: string;
20
20
  }
21
21
  export type WsApi_Response<P, D> = D & {
22
22
  request: WsApi_RequestMeta<P>;
@@ -34,7 +34,7 @@ export interface WsApi_StateProps {
34
34
  action: string;
35
35
  [key: string]: any;
36
36
  };
37
- reqId: string;
37
+ request_id: string;
38
38
  cb: any;
39
39
  }[];
40
40
  }
@@ -1,2 +1,3 @@
1
+ import { BasePayloadSocket } from './../../SocketApi.types';
1
2
  import { CreateRequestSocketProps } from './createRequestSocket.types';
2
- export declare const createRequestSocket: <ResponseSocket = any>(cb: (data: ResponseSocket) => void, { payload, socketAction, signal }: CreateRequestSocketProps) => void;
3
+ export declare const createRequestSocket: <RequestSocket, ResponseSocket extends BasePayloadSocket & { [key in string]: any; }>(cb: (data: ResponseSocket) => void, { payload, signal }: CreateRequestSocketProps<RequestSocket>) => void;
@@ -1,5 +1,5 @@
1
- export interface CreateRequestSocketProps<D = any> {
2
- payload: D;
3
- socketAction: string;
1
+ import { BasePayloadSocket } from '../../SocketApi.types';
2
+ export interface CreateRequestSocketProps<D> {
3
+ payload: D & BasePayloadSocket;
4
4
  signal?: AbortSignal;
5
5
  }
@@ -0,0 +1 @@
1
+ export * from './useRequestSocketApi';
@@ -1,5 +1,6 @@
1
1
  import { UseRequestSocketOptions } from './useRequestSocketApi.types';
2
- export declare const useRequestSocketApi: <P = any, Data = any>(keyRequest: string, payload: P, options?: UseRequestSocketOptions<Data>) => {
2
+ import { BasePayloadSocket } from '../../SocketApi.types';
3
+ export declare const useRequestSocketApi: <P extends BasePayloadSocket, Data extends BasePayloadSocket>(payload: P, options?: UseRequestSocketOptions<Data>) => {
3
4
  data: Data | null;
4
5
  error: Error | null;
5
6
  isLoading: boolean;
@@ -8,3 +9,12 @@ export declare const useRequestSocketApi: <P = any, Data = any>(keyRequest: stri
8
9
  refetch: () => Promise<void>;
9
10
  abort: () => void;
10
11
  };
12
+ export declare const createRequestSocketApi: <P extends BasePayloadSocket, D extends BasePayloadSocket>(p: P, d?: UseRequestSocketOptions<D>) => {
13
+ data: D | null;
14
+ error: Error | null;
15
+ isLoading: boolean;
16
+ isError: boolean;
17
+ isSuccess: boolean;
18
+ refetch: () => Promise<void>;
19
+ abort: () => void;
20
+ };
@@ -4,3 +4,12 @@ export interface UseRequestSocketOptions<Data = any> {
4
4
  onSuccess?: (data: Data) => void;
5
5
  onError?: (error: Error) => void;
6
6
  }
7
+ export interface ResultUseRequestSocketApi<Data = any> {
8
+ data: Data | null;
9
+ error: Error | null;
10
+ isLoading: boolean;
11
+ isError: boolean;
12
+ isSuccess: boolean;
13
+ refetch: () => Promise<void>;
14
+ abort: () => void;
15
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './SocketApi';
2
- export { type SocketApi_StateProps_P, type SocketApi_StatusConnect_OR } from './SocketApi.types';
2
+ export * from './hooks';
3
+ export { type SocketApi_StateProps_P, type SocketApi_StatusConnect_OR, type BasePayloadSocket } from './SocketApi.types';
@@ -2,14 +2,12 @@ import { default as React } from 'react';
2
2
  import { SocketConnectDetectionProps } from './ConnectDetection/ConnectDetection';
3
3
  import { InitializationSocketProps } from './Initialization/Initialization';
4
4
  import { SocketOfflineDetectionPayloadProps, SocketOfflineDetectionProps } from './OfflineDetection/OfflineDetection';
5
- import { ReConnectButtonProps } from './Buttons/ReConnect';
6
- import { OfflineButtonProps } from './Buttons/OfflineButton';
7
5
  export declare const Socket: {
8
6
  ConnectDetection: React.NamedExoticComponent<SocketConnectDetectionProps>;
9
7
  OfflineDetection: React.NamedExoticComponent<SocketOfflineDetectionProps>;
10
8
  Buttons: {
11
- OfflineActive: React.NamedExoticComponent<OfflineButtonProps>;
12
- ReConnect: React.NamedExoticComponent<ReConnectButtonProps>;
9
+ OfflineActive: React.NamedExoticComponent<import('./Buttons/OfflineButton').OfflineButtonProps>;
10
+ ReConnect: React.NamedExoticComponent<import('./Buttons/ReConnect').ReConnectButtonProps>;
13
11
  };
14
12
  Initialization: React.NamedExoticComponent<InitializationSocketProps>;
15
13
  };
@@ -1,3 +1,2 @@
1
1
  import { CollapseProps } from '@mui/material';
2
- import { Theme } from '@mui/material/styles';
3
- export declare const SocketCollapse: import('@emotion/styled').StyledComponent<CollapseProps & import('@mui/system').MUIStyledCommonProps<Theme>, {}, {}>;
2
+ export declare const SocketCollapse: import('@emotion/styled').StyledComponent<CollapseProps & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
@@ -4,6 +4,7 @@ export declare const socketActions: SocketActions;
4
4
  export declare const socketSelectors: {
5
5
  getStatusConnectSocket: (state: InitialStatePropsSocket) => "ready" | "close" | "error" | "pending" | "disconnect";
6
6
  getStatusIsReConnectSocket: (state: InitialStatePropsSocket) => boolean;
7
+ getStatusReady: (state: InitialStatePropsSocket) => boolean;
7
8
  getIsOfflineSocket: (state: InitialStatePropsSocket) => boolean;
8
9
  getInfoNoConnectServer: (state: InitialStatePropsSocket) => {
9
10
  isModal: boolean;
@@ -4,6 +4,7 @@ export interface InitialStatePropsSocket {
4
4
  isReConnectSocket: boolean;
5
5
  isOfflineSocket: boolean;
6
6
  isDisableConnectSocket: boolean;
7
+ isReadySocket: boolean;
7
8
  infoNoConnectServer: {
8
9
  isModal: boolean;
9
10
  isSelectOffline: boolean;
@@ -13,6 +14,7 @@ export interface SocketActions {
13
14
  resetState: () => void;
14
15
  setStatusConnectSocket: (payload: Pick<InitialStatePropsSocket, 'statusConnect'>) => void;
15
16
  setStatusIsReConnectSocket: (payload: Pick<InitialStatePropsSocket, 'isReConnectSocket'>) => void;
17
+ setStatusReady: (payload: Pick<InitialStatePropsSocket, 'isReadySocket'>) => void;
16
18
  setIsOfflineSocket: (payload: Pick<InitialStatePropsSocket, 'isOfflineSocket'>) => void;
17
19
  setInfoNoConnectServer: (payload: Partial<InitialStatePropsSocket['infoNoConnectServer']>) => void;
18
20
  setIsDisableConnectSocket: (payload: Pick<InitialStatePropsSocket, 'isDisableConnectSocket'>) => void;
package/dist/socket.js CHANGED
@@ -1,69 +1,68 @@
1
- import './socket.css';var U = Object.defineProperty;
2
- var P = (o) => {
3
- throw TypeError(o);
4
- };
5
- var F = (o, t, e) => t in o ? U(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
6
- var r = (o, t, e) => F(o, typeof t != "symbol" ? t + "" : t, e);
7
- var q = (o, t, e) => t.has(o) ? P("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e);
8
- import { jsx as R } from "react/jsx-runtime";
9
- import b, { useEffect as I, useCallback as x } from "react";
10
- import { styled as y, Collapse as H } from "@mui/material";
11
- import T from "classnames";
12
- const D = (o) => {
1
+ import './socket.css';var z = Object.defineProperty;
2
+ var G = (o, t, e) => t in o ? z(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var r = (o, t, e) => G(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { jsx as M } from "react/jsx-runtime";
5
+ import w, { useState as O, useRef as $, useCallback as A, useEffect as E } from "react";
6
+ import { styled as x, Collapse as V } from "@mui/material";
7
+ import U from "classnames";
8
+ const T = (o) => {
13
9
  let t;
14
- const e = /* @__PURE__ */ new Set(), n = (u, h) => {
10
+ const e = /* @__PURE__ */ new Set(), n = (u, d) => {
15
11
  const f = typeof u == "function" ? u(t) : u;
16
12
  if (!Object.is(f, t)) {
17
- const d = t;
18
- t = h ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((p) => p(t, d));
13
+ const h = t;
14
+ t = d ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((g) => g(t, h));
19
15
  }
20
16
  }, i = () => t, a = { setState: n, getState: i, getInitialState: () => S, subscribe: (u) => (e.add(u), () => e.delete(u)) }, S = t = o(n, i, a);
21
17
  return a;
22
- }, j = (o) => o ? D(o) : D, J = (o) => o;
23
- function z(o, t = J) {
24
- const e = b.useSyncExternalStore(
18
+ }, K = (o) => o ? T(o) : T, Q = (o) => o;
19
+ function X(o, t = Q) {
20
+ const e = w.useSyncExternalStore(
25
21
  o.subscribe,
26
- b.useCallback(() => t(o.getState()), [o, t]),
27
- b.useCallback(() => t(o.getInitialState()), [o, t])
22
+ w.useCallback(() => t(o.getState()), [o, t]),
23
+ w.useCallback(() => t(o.getInitialState()), [o, t])
28
24
  );
29
- return b.useDebugValue(e), e;
25
+ return w.useDebugValue(e), e;
30
26
  }
31
- const M = (o) => {
32
- const t = j(o), e = (n) => z(t, n);
27
+ const W = (o) => {
28
+ const t = K(o), e = (n) => X(t, n);
33
29
  return Object.assign(e, t), e;
34
- }, G = (o) => o ? M(o) : M, B = {
30
+ }, Y = (o) => o ? W(o) : W, P = {
35
31
  statusConnect: "disconnect",
36
32
  isOfflineSocket: !1,
37
33
  //Текущее состояние сокета. Зависит от события timeOffReConnect и если задаёться isDisableConnectSocket: true
38
- isDisableConnectSocket: !1,
39
34
  isReConnectSocket: !1,
35
+ isDisableConnectSocket: !1,
36
+ isReadySocket: !1,
40
37
  infoNoConnectServer: {
41
38
  isModal: !1,
42
39
  isSelectOffline: !1
43
40
  //Для того что бы 2й раз окно не показывать
44
41
  }
45
- }, $ = JSON.parse(JSON.stringify(B)), C = G(() => B), w = {
46
- resetState: () => C.setState($),
47
- setStatusConnectSocket: ({ statusConnect: o }) => C.setState({ statusConnect: o }),
48
- setStatusIsReConnectSocket: ({ isReConnectSocket: o }) => C.setState({ isReConnectSocket: o }),
49
- setIsOfflineSocket: ({ isOfflineSocket: o }) => C.setState({ isOfflineSocket: o }),
50
- setInfoNoConnectServer: (o) => C.setState((t) => ({ infoNoConnectServer: { ...t.infoNoConnectServer, ...o } })),
51
- setIsDisableConnectSocket: ({ isDisableConnectSocket: o }) => C.setState({ isDisableConnectSocket: o })
42
+ }, Z = JSON.parse(JSON.stringify(P)), b = Y(() => P), C = {
43
+ resetState: () => b.setState(Z),
44
+ setStatusConnectSocket: ({ statusConnect: o }) => b.setState({ statusConnect: o }),
45
+ setStatusIsReConnectSocket: ({ isReConnectSocket: o }) => b.setState({ isReConnectSocket: o }),
46
+ setStatusReady: ({ isReadySocket: o }) => b.setState({ isReadySocket: o }),
47
+ setIsOfflineSocket: ({ isOfflineSocket: o }) => b.setState({ isOfflineSocket: o }),
48
+ setInfoNoConnectServer: (o) => b.setState((t) => ({ infoNoConnectServer: { ...t.infoNoConnectServer, ...o } })),
49
+ setIsDisableConnectSocket: ({ isDisableConnectSocket: o }) => b.setState({ isDisableConnectSocket: o })
52
50
  }, m = {
53
51
  getStatusConnectSocket: (o) => o.statusConnect,
54
52
  getStatusIsReConnectSocket: (o) => o.isReConnectSocket,
53
+ getStatusReady: (o) => o.isReadySocket,
55
54
  getIsOfflineSocket: (o) => o.isOfflineSocket,
56
55
  getInfoNoConnectServer: (o) => o.infoNoConnectServer,
57
56
  getIsDisableConnectSocket: (o) => o.isDisableConnectSocket
58
- }, k = (o) => C(o), V = y("span")({
57
+ }, R = (o) => b(o), _ = x("span")({
59
58
  backgroundColor: "rgba(0,0,0,0.3)",
60
59
  color: "#fff",
61
60
  display: "flex",
62
61
  alignItems: "center",
63
62
  padding: "1px 10px",
64
63
  borderRadius: "3px 3px 3px 3px"
65
- }), L = y(
66
- ({ children: o, ...t }) => /* @__PURE__ */ R(H, { ...t, unmountOnExit: !0, children: /* @__PURE__ */ R(V, { children: o }) })
64
+ }), F = x(
65
+ ({ children: o, ...t }) => /* @__PURE__ */ M(V, { ...t, unmountOnExit: !0, children: /* @__PURE__ */ M(_, { children: o }) })
67
66
  )(({ theme: o }) => ({
68
67
  fontSize: 10,
69
68
  position: "absolute",
@@ -80,12 +79,12 @@ const M = (o) => {
80
79
  color: "#151616",
81
80
  letterSpacing: 1
82
81
  }
83
- })), K = "_connect-server-anim_1lp7f_1", Q = "_loading-stripes_1lp7f_1", X = {
82
+ })), tt = "_connect-server-anim_1lp7f_1", et = "_loading-stripes_1lp7f_1", st = {
84
83
  "connect-server-anim": "_connect-server-anim_1lp7f_1",
85
- connectServerAnim: K,
84
+ connectServerAnim: tt,
86
85
  "loading-stripes": "_loading-stripes_1lp7f_1",
87
- loadingStripes: Q
88
- }, Y = y(L, {
86
+ loadingStripes: et
87
+ }, nt = x(F, {
89
88
  shouldForwardProp: (o) => ![""].includes(o)
90
89
  })(({ theme: o }) => ({
91
90
  top: "100%",
@@ -95,29 +94,29 @@ const M = (o) => {
95
94
  "& span": {
96
95
  height: "100%"
97
96
  }
98
- })), Z = ({ text: o = "Происходит подключение к серверу", className: t, ...e }) => {
99
- const i = k(m.getStatusConnectSocket) === "pending";
100
- return /* @__PURE__ */ R(
101
- Y,
97
+ })), ot = ({ text: o = "Происходит подключение к серверу", className: t, ...e }) => {
98
+ const i = R(m.getStatusConnectSocket) === "pending";
99
+ return /* @__PURE__ */ M(
100
+ nt,
102
101
  {
103
102
  in: i,
104
103
  collapsedSize: "1px",
105
- className: T(X["connect-server-anim"], t),
104
+ className: U(st["connect-server-anim"], t),
106
105
  unmountOnExit: !0,
107
106
  ...e,
108
107
  children: o
109
108
  }
110
109
  );
111
- }, _ = b.memo(Z), tt = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
112
- function et(o) {
113
- return tt.test(o);
110
+ }, it = w.memo(ot), rt = /^[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 ct(o) {
112
+ return rt.test(o);
114
113
  }
115
- function O() {
114
+ function L() {
116
115
  var o = URL.createObjectURL(new Blob()), t = o.toString();
117
116
  return URL.revokeObjectURL(o), t.split(/[:\/]/g).pop().toLowerCase();
118
117
  }
119
- O.valid = et;
120
- class st {
118
+ L.valid = ct;
119
+ class at {
121
120
  constructor() {
122
121
  r(this, "defaultProps", {
123
122
  interval: 5e3
@@ -130,17 +129,17 @@ class st {
130
129
  };
131
130
  let c = !0, l, a, S;
132
131
  const u = (f = !0) => {
133
- const d = "Ручное завершение startActionEvery";
134
- c = !1, clearInterval(l), n(null), f ? a && a({ status: f, msg: d + ": (true)" }) : S && S({ status: f, msg: d + ": (false)" });
132
+ const h = "Ручное завершение startActionEvery";
133
+ c = !1, clearInterval(l), n(null), f ? a && a({ status: f, msg: h + ": (true)" }) : S && S({ status: f, msg: h + ": (false)" });
135
134
  };
136
135
  return {
137
- promise: new Promise((f, d) => {
138
- a = f, S = d;
139
- let p = 0, g = 0;
136
+ promise: new Promise((f, h) => {
137
+ a = f, S = h;
138
+ let g = 0, v = 0;
140
139
  l = setInterval(
141
140
  () => {
142
- if (p += e.interval, g += 1, e != null && e.cutoffTime && p > e.cutoffTime || e != null && e.countAction && (e == null ? void 0 : e.countAction) < g) {
143
- c = !1, clearInterval(l), n(null), d({ status: !1, msg: Error("Время загрузки истекло") });
141
+ if (g += e.interval, v += 1, e != null && e.cutoffTime && g > e.cutoffTime || e != null && e.countAction && (e == null ? void 0 : e.countAction) < v) {
142
+ c = !1, clearInterval(l), n(null), h({ status: !1, msg: Error("Время загрузки истекло") });
144
143
  return;
145
144
  }
146
145
  t() && (c = !1, clearInterval(l), n(null), f({ status: !0, msg: "cb вернул true" }));
@@ -183,7 +182,7 @@ class st {
183
182
  }));
184
183
  }
185
184
  }
186
- class W {
185
+ class H {
187
186
  constructor(t) {
188
187
  r(this, "subscribersEvents", {});
189
188
  r(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
@@ -204,7 +203,7 @@ class W {
204
203
  });
205
204
  r(this, "resetSubscribers", () => {
206
205
  const t = Object.entries(this.subscribersEvents);
207
- for (const [e, n] of t)
206
+ for (const [e] of t)
208
207
  this.subscribersEvents[e] = [];
209
208
  });
210
209
  t.forEach((e) => {
@@ -212,7 +211,7 @@ class W {
212
211
  });
213
212
  }
214
213
  }
215
- class nt {
214
+ class lt {
216
215
  constructor(t) {
217
216
  r(this, "networkInfo");
218
217
  r(this, "listUrls", []);
@@ -221,16 +220,6 @@ class nt {
221
220
  isMonitoring: !1,
222
221
  checkIntervalId: null
223
222
  });
224
- r(this, "getFetchOptions", (t) => ({
225
- method: "HEAD",
226
- cache: "no-store",
227
- signal: t.signal,
228
- headers: {
229
- "Cache-Control": "no-cache, no-store, must-revalidate",
230
- Pragma: "no-cache",
231
- Expires: "0"
232
- }
233
- }));
234
223
  r(this, "getIsNetwork", (t) => !["unknown", "none"].includes(t));
235
224
  r(this, "getTypeNetwork", ({ effectiveType: t, type: e }, n) => (n || n === null) && (t || e) || "none");
236
225
  /*-----------------------------------------------------------------------------*/
@@ -257,6 +246,16 @@ class nt {
257
246
  getState() {
258
247
  return this.state;
259
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);
260
259
  getConnection() {
261
260
  var t;
262
261
  return (t = window == null ? void 0 : window.navigator) == null ? void 0 : t.connection;
@@ -275,7 +274,7 @@ class nt {
275
274
  this.controllersEvents = { ...this.controllersEvents, ...t };
276
275
  }
277
276
  startEvents(t) {
278
- var a, S, u, h;
277
+ var a, S, u, d;
279
278
  const { isActiveEvents: e } = this.getState();
280
279
  if (e)
281
280
  return;
@@ -292,9 +291,9 @@ class nt {
292
291
  }, { signal: (a = n.online) == null ? void 0 : a.signal }), window.addEventListener("offline", () => {
293
292
  this.updateState(!1, t);
294
293
  }, { signal: (S = n.offline) == null ? void 0 : S.signal }), (u = this.getConnection()) != null && u.addEventListener && this.getConnection().addEventListener("change", () => {
295
- const f = this.getConnection(), d = this.getTypeNetwork(f, null), p = this.getIsNetwork(d);
296
- this.updateState(p, t);
297
- }, { signal: (h = n.change) == null ? void 0 : h.signal });
294
+ const f = this.getConnection(), h = this.getTypeNetwork(f, null), g = this.getIsNetwork(h);
295
+ this.updateState(g, t);
296
+ }, { signal: (d = n.change) == null ? void 0 : d.signal });
298
297
  }
299
298
  stopEvents() {
300
299
  const { isActiveEvents: t } = this.getState();
@@ -363,7 +362,7 @@ class nt {
363
362
  return this.networkInfo;
364
363
  }
365
364
  }
366
- class ot {
365
+ class ut {
367
366
  constructor() {
368
367
  r(this, "options", {
369
368
  timeReConnect: 5e3,
@@ -376,7 +375,7 @@ class ot {
376
375
  arrSaveReq: []
377
376
  });
378
377
  r(this, "initOptions", !1);
379
- r(this, "events", new W(["status", "msg", "error"]));
378
+ r(this, "events", new H(["status", "msg", "error"]));
380
379
  r(this, "stateDefault", this.copyState(this.state));
381
380
  r(this, "eventListener", (t) => {
382
381
  var n, i;
@@ -474,7 +473,7 @@ class ot {
474
473
  send(t) {
475
474
  var n;
476
475
  const e = JSON.stringify(t);
477
- (n = this.state.ws) == null || n.send(e);
476
+ console.log("Смотрим сообщение в строке", e), console.log("роверяем есть ли this.state.ws", this.state.ws), (n = this.state.ws) == null || n.send(e);
478
477
  }
479
478
  setRequestSave(t) {
480
479
  if ("action" in t.payload) {
@@ -490,7 +489,6 @@ class ot {
490
489
  });
491
490
  }
492
491
  }
493
- var E, it;
494
492
  const s = class s {
495
493
  static copyState(t) {
496
494
  return JSON.parse(JSON.stringify(t));
@@ -514,10 +512,10 @@ const s = class s {
514
512
  s.state.isDisconnect || (s.setState({ isDisconnect: !0 }), console.log("DISCONNECT WS"), s.wsApi.disconnect(), s.resetState(), s.events.resetSubscribers());
515
513
  }
516
514
  static send(t, e) {
517
- const { action: n, ...i } = t, c = O(), l = Date.now();
515
+ const { action: n, ...i } = t, c = i != null && i.request_id ? i.request_id : L(), l = Date.now();
518
516
  s.wsApi.setRequestSave({
519
517
  requestAction: n,
520
- reqId: c,
518
+ request_id: c,
521
519
  requestTime: l,
522
520
  payload: { action: n, ...i },
523
521
  cb: e
@@ -527,63 +525,63 @@ const s = class s {
527
525
  console.log("Нет подключения к сокету");
528
526
  return;
529
527
  }
530
- s.wsApi.send(t);
528
+ console.log("Дулаем запроc, SocketApi.wsApi.send(payload)"), s.wsApi.send(t);
531
529
  }
532
530
  static stopReConnect(t) {
533
531
  console.dir("функция stop не присвоена к stopReConnect");
534
532
  }
535
- static async request(t, e, n = {}) {
536
- return new Promise((i, c) => {
537
- var d, p;
538
- if ((d = n == null ? void 0 : n.signal) != null && d.aborted) {
539
- c(new DOMException("Aborted", "AbortError"));
533
+ static async request(t, e = {}) {
534
+ return new Promise((n, i) => {
535
+ var h, g;
536
+ if ((h = e == null ? void 0 : e.signal) != null && h.aborted) {
537
+ i(new DOMException("Aborted", "AbortError"));
540
538
  return;
541
539
  }
542
- const l = O(), a = Date.now();
540
+ const c = t.action, l = t.request_id ? t.request_id : L(), a = Date.now();
543
541
  s.wsApi.setRequestSave({
544
- requestAction: t,
545
- reqId: l,
542
+ requestAction: c,
543
+ request_id: l,
546
544
  requestTime: a,
547
- payload: e,
545
+ payload: t,
548
546
  cb: void 0
549
547
  });
550
548
  let S;
551
- n != null && n.timeout && (S = setTimeout(() => {
552
- s.off("msg", h), s.off("error", u), c(new Error("Request timeout"));
553
- }, n == null ? void 0 : n.timeout));
554
- const u = (g) => {
555
- s.off("msg", h), s.off("error", u), c(g);
556
- }, h = (g) => {
557
- var N;
558
- const A = this.wsApi.findDataRequestByAction(t);
559
- ((N = g == null ? void 0 : g.request) == null ? void 0 : N.requestAction) === A.requestAction && (s.off("msg", h), s.off("error", u), i({ ...g }));
549
+ e != null && e.timeout && (S = setTimeout(() => {
550
+ s.off("msg", d), s.off("error", u), i(new Error("Request timeout"));
551
+ }, e == null ? void 0 : e.timeout));
552
+ const u = (v) => {
553
+ s.off("msg", d), s.off("error", u), i(v);
554
+ }, d = (v) => {
555
+ var y;
556
+ const N = this.wsApi.findDataRequestByAction(c);
557
+ ((y = v == null ? void 0 : v.request) == null ? void 0 : y.requestAction) === N.requestAction && (s.off("msg", d), s.off("error", u), n({ ...v }));
560
558
  };
561
- s.on("msg", h), s.on("error", u), (p = n == null ? void 0 : n.signal) == null || p.addEventListener("abort", () => {
559
+ s.on("msg", d), s.on("error", u), (g = e == null ? void 0 : e.signal) == null || g.addEventListener("abort", () => {
562
560
  debugger;
563
- S && clearTimeout(S), s.off("msg", h), s.off("error", u), c(new DOMException("Aborted", "AbortError"));
561
+ S && clearTimeout(S), s.off("msg", d), s.off("error", u), i(new DOMException("Aborted", "AbortError"));
564
562
  });
565
563
  const f = s.wsApi.getSocket();
566
564
  if (!f || f.readyState !== 1) {
567
- console.log("Нет подключения к сокету");
565
+ const v = "Нет подключения к сокету";
566
+ console.error(v), i(new Error(v));
568
567
  return;
569
568
  }
570
- s.wsApi.send(e);
569
+ s.wsApi.send(t);
571
570
  });
572
571
  }
573
572
  };
574
- E = new WeakSet(), it = function() {
575
- }, q(s, E), r(s, "state", {
573
+ r(s, "state", {
576
574
  isDisconnect: !0,
577
575
  isActiveReConnect: !1,
578
576
  isOfflineSocket: !0,
579
- isReady: !1,
580
577
  isGotWasFirstConnection: !1,
581
578
  isStartCheckNetwork: !1
579
+ //не используеться
582
580
  }), r(s, "options", {
583
581
  isReConnectNetworkOnline: !1,
584
582
  listUrlsCheckConnectNetwork: ["https://jsonplaceholder.typicode.com/posts/1"]
585
- }), r(s, "wsApi", new ot()), r(s, "delay", new st()), // private static internetControl:NetworkControls | null = null
586
- r(s, "networkTicker", null), r(s, "events", new W(["timeOffReConnect", "reConnect", "network"])), r(s, "saveID", {
583
+ }), r(s, "wsApi", new ut()), r(s, "delay", new at()), // private static internetControl:NetworkControls | null = null
584
+ r(s, "networkTicker", null), r(s, "events", new H(["timeOffReConnect", "reConnect", "network"])), r(s, "saveID", {
587
585
  idReConnect: null,
588
586
  checkConnect: null
589
587
  }), r(s, "stateDefault", s.copyState(s.state)), r(s, "setInfoConnect", (t) => {
@@ -610,7 +608,7 @@ r(s, "setNetworkStatus", (t) => {
610
608
  s.events.publish("network", t), t.isNetwork ? s.online() : s.offline();
611
609
  }), r(s, "init", (t) => {
612
610
  const { WsOptions: e, SocketApiOptions: n } = s.splitOptions(t);
613
- s.networkTicker = new nt(n.listUrlsCheckConnectNetwork ?? []), s.networkTicker.startEvents((i) => {
611
+ s.networkTicker = new lt(n.listUrlsCheckConnectNetwork ?? []), s.networkTicker.startEvents((i) => {
614
612
  s.setNetworkStatus(i);
615
613
  }), s.setOptions(n), s.wsApi.init(e);
616
614
  }), /*------------------------------------------------------------------------------------------------------*/
@@ -640,33 +638,61 @@ r(s, "socketReConnect", () => {
640
638
  });
641
639
  }
642
640
  });
643
- let v = s;
644
- const rt = (o) => {
645
- const { isNetwork: t, typeNetwork: e } = o, { isModal: n } = k(m.getInfoNoConnectServer), i = k(m.getStatusIsReConnectSocket), c = k(m.getIsDisableConnectSocket), l = k(m.getStatusConnectSocket);
646
- return I(() => (v.init(o.init), typeof o.onMount == "function" && o.onMount(), v.on("status", (a) => {
647
- console.log("status", a), w.setStatusConnectSocket({ statusConnect: a });
648
- }), v.on("error", (a) => {
641
+ let p = s;
642
+ const ft = (o, t = {}) => {
643
+ const e = o.action, { skip: n = !1, timeout: i = 5e3, onSuccess: c, onError: l } = t, [a, S] = O(null), [u, d] = O(null), [f, h] = O(!1), [g, v] = O(!1), [N, y] = O(!1), k = $(null), q = A(async () => {
644
+ if (n) return;
645
+ h(!0), v(!1), y(!1), d(null), S(null), k.current = new AbortController();
646
+ const D = k.current.signal;
647
+ try {
648
+ const I = await p.request(
649
+ o,
650
+ { timeout: i, signal: D }
651
+ );
652
+ if (D.aborted) return;
653
+ S(I), y(!0), c == null || c(I);
654
+ } catch (I) {
655
+ if (D.aborted) return;
656
+ const B = I instanceof Error ? I : new Error(String(I));
657
+ d(B), v(!0), l == null || l(B);
658
+ } finally {
659
+ D.aborted || h(!1);
660
+ }
661
+ }, [n, e, o, i, c, l]);
662
+ E(() => (n || q(), () => {
663
+ k.current && k.current.abort();
664
+ }), [q, n]);
665
+ const j = A(() => (k.current && k.current.abort(), q()), [q]), J = A(() => {
666
+ k.current && (k.current.abort(), h(!1));
667
+ }, []);
668
+ return { data: a, error: u, isLoading: f, isError: g, isSuccess: N, refetch: j, abort: J };
669
+ }, Ot = (o, t) => ft(o, t), St = (o) => {
670
+ const { isNetwork: t, typeNetwork: e } = o, { isModal: n } = R(m.getInfoNoConnectServer), i = R(m.getStatusIsReConnectSocket), c = R(m.getIsDisableConnectSocket), l = R(m.getStatusConnectSocket);
671
+ return E(() => (p.init(o.init), typeof o.onMount == "function" && o.onMount(), p.on("status", (a) => {
672
+ const S = b.getState(), { isReadySocket: u } = S;
673
+ a !== "ready" && u && C.setStatusReady({ isReadySocket: !1 }), !u && a === "ready" && C.setStatusReady({ isReadySocket: !0 }), C.setStatusConnectSocket({ statusConnect: a });
674
+ }), p.on("error", (a) => {
649
675
  console.log("error: ", a);
650
- }), v.on("reConnect", (a) => {
676
+ }), p.on("reConnect", (a) => {
651
677
  console.log("reConnect", a);
652
- const S = C.getState(), { isReConnectSocket: u, infoNoConnectServer: { isModal: h } } = S;
653
- u !== a && w.setStatusIsReConnectSocket({ isReConnectSocket: a }), h && a && w.setInfoNoConnectServer({ isModal: !1 });
654
- }), v.on("timeOffReConnect", (a) => {
655
- if (console.log("timeOffReConnect: ", a), w.setIsOfflineSocket({ isOfflineSocket: !a.status }), !a.status) {
656
- const S = C.getState(), { infoNoConnectServer: { isModal: u, isSelectOffline: h } } = S;
678
+ const S = b.getState(), { isReConnectSocket: u, infoNoConnectServer: { isModal: d } } = S;
679
+ u !== a && C.setStatusIsReConnectSocket({ isReConnectSocket: a }), d && a && C.setInfoNoConnectServer({ isModal: !1 });
680
+ }), p.on("timeOffReConnect", (a) => {
681
+ if (console.log("timeOffReConnect: ", a), C.setIsOfflineSocket({ isOfflineSocket: !a.status }), !a.status) {
682
+ const S = b.getState(), { infoNoConnectServer: { isModal: u, isSelectOffline: d } } = S;
657
683
  let f = !1;
658
- !u && !h && (f = !0), f && w.setInfoNoConnectServer({ isModal: f });
684
+ !u && !d && (f = !0), f && C.setInfoNoConnectServer({ isModal: f });
659
685
  }
660
- }), v.connect(), () => {
661
- typeof o.onUnmount == "function" && o.onUnmount(), console.dir("disconnect"), v.disconnect();
662
- }), []), I(() => {
663
- t && !c && !n && !i && ["close"].includes(l) && e !== "none" && (console.log("Запущен socketReConnect"), v.socketReConnect());
664
- }, [c, n, i, l, e, t]), I(() => {
665
- i && (!t || l === "ready") && (console.log("Запущен stopReConnect"), v.stopReConnect());
666
- }, [i, t, l]), I(() => {
667
- c && (console.log("isDisableConnectSocket: ", c), w.setIsOfflineSocket({ isOfflineSocket: !0 }), v.close());
686
+ }), p.connect(), () => {
687
+ typeof o.onUnmount == "function" && o.onUnmount(), console.dir("disconnect"), p.disconnect();
688
+ }), []), E(() => {
689
+ t && !c && !n && !i && ["close"].includes(l) && e !== "none" && (console.log("Запущен socketReConnect"), p.socketReConnect());
690
+ }, [c, n, i, l, e, t]), E(() => {
691
+ i && (!t || l === "ready") && (console.log("Запущен stopReConnect"), p.stopReConnect());
692
+ }, [i, t, l]), E(() => {
693
+ c && (console.log("isDisableConnectSocket: ", c), C.setIsOfflineSocket({ isOfflineSocket: !0 }), p.close());
668
694
  }, [c]), null;
669
- }, ct = b.memo(rt), at = y(L, {
695
+ }, dt = w.memo(St), ht = x(F, {
670
696
  shouldForwardProp: (o) => ![""].includes(o)
671
697
  })(({ theme: o }) => ({
672
698
  bottom: "100%",
@@ -676,41 +702,43 @@ const rt = (o) => {
676
702
  "& span": {
677
703
  padding: "1px 10px"
678
704
  }
679
- })), lt = ({ children: o, className: t, isNetwork: e, ...n }) => {
680
- const i = k(m.getIsOfflineSocket), c = k(m.getIsDisableConnectSocket), l = i || !e, a = "Оффлайн";
681
- return /* @__PURE__ */ R(
682
- at,
705
+ })), vt = ({ children: o, className: t, isNetwork: e, ...n }) => {
706
+ const i = R(m.getIsOfflineSocket), c = R(m.getIsDisableConnectSocket), l = i || !e, a = "Оффлайн";
707
+ return /* @__PURE__ */ M(
708
+ ht,
683
709
  {
684
710
  in: l,
685
- className: T("socket-offline", t),
711
+ className: U("socket-offline", t),
686
712
  ...n,
687
713
  children: typeof o == "function" ? o({ isDisableConnectSocket: c }) : c ? `Режим ${a}` : a
688
714
  }
689
715
  );
690
- }, ut = b.memo(lt), ft = ({ children: o }) => {
691
- const t = x(() => {
692
- w.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !1 });
716
+ }, pt = w.memo(vt), gt = ({ children: o }) => {
717
+ const t = A(() => {
718
+ C.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !1 });
693
719
  }, []);
694
720
  return o({ reConnect: t });
695
- }, St = b.memo(ft), ht = ({ children: o }) => {
696
- const t = x(() => {
697
- w.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !0 }), w.setIsDisableConnectSocket({ isDisableConnectSocket: !0 });
721
+ }, Ct = w.memo(gt), bt = ({ children: o }) => {
722
+ const t = A(() => {
723
+ C.setInfoNoConnectServer({ isModal: !1, isSelectOffline: !0 }), C.setIsDisableConnectSocket({ isDisableConnectSocket: !0 });
698
724
  }, []);
699
725
  return o({ offlineActive: t });
700
- }, dt = b.memo(ht), bt = {
701
- ConnectDetection: _,
702
- OfflineDetection: ut,
726
+ }, wt = w.memo(bt), Et = {
727
+ ConnectDetection: it,
728
+ OfflineDetection: pt,
703
729
  Buttons: {
704
- OfflineActive: dt,
705
- ReConnect: St
730
+ OfflineActive: wt,
731
+ ReConnect: Ct
706
732
  },
707
- Initialization: ct
733
+ Initialization: dt
708
734
  };
709
735
  export {
710
- bt as Socket,
711
- v as SocketApi,
712
- w as socketActions,
736
+ Et as Socket,
737
+ p as SocketApi,
738
+ Ot as createRequestSocketApi,
739
+ C as socketActions,
713
740
  m as socketSelectors,
714
- C as socketStore,
715
- k as useSocketSelector
741
+ b as socketStore,
742
+ ft as useRequestSocketApi,
743
+ R as useSocketSelector
716
744
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rc-lib-ui",
3
3
  "private": false,
4
- "version": "1.1.28",
4
+ "version": "1.1.45",
5
5
  "author": "SinGlEBW",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "scripts": {
42
42
  "dev": "vite",
43
- "build": "tsc && vite build",
43
+ "build": "tsc --project tsconfig.prod.json && vite build",
44
44
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
45
45
  "preview": "vite preview",
46
46
  "send": "node publishVersion.js"
@@ -1,2 +0,0 @@
1
- export * from './Network';
2
- export * from './Socket';