dev-classes 1.3.27 → 1.3.29

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/README.md CHANGED
@@ -146,7 +146,10 @@ interface OneOfPromiseReject{
146
146
 
147
147
 
148
148
  interface DelaysPromiseProps{
149
- startActionEvery: (cb: () => boolean, config: StartActionEveryConfigI) => Promise<{status: boolean, msg: string}>
149
+ startActionEvery: (cb: () => boolean, config: StartActionEveryConfigI) => {
150
+ stop: ControlAction['stop'],
151
+ promise: Promise<{status: boolean, msg: string}>
152
+ }
150
153
  oneOf: (watchPromise: () => Promise<any>, potentialCaseCB: () => void, config: {second: number}) => void
151
154
  oneOfPromise:(watchPromise: () => Promise<any>, cbPotentialReject: (p:OneOfPromiseReject) => OneOfPromiseReject, config: {second: number}) => Promise<any>
152
155
  }
@@ -1,69 +1,72 @@
1
- var i = Object.defineProperty;
2
- var o = (u, e, t) => e in u ? i(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
3
- var I = (u, e, t) => (o(u, typeof e != "symbol" ? e + "" : e, t), t);
4
- class h {
1
+ var P = Object.defineProperty;
2
+ var h = (m, e, t) => e in m ? P(m, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[e] = t;
3
+ var A = (m, e, t) => (h(m, typeof e != "symbol" ? e + "" : e, t), t);
4
+ class O {
5
5
  constructor() {
6
- I(this, "defaultProps", {
6
+ A(this, "defaultProps", {
7
7
  interval: 5e3
8
8
  });
9
- I(this, "startActionEvery", (e, t = this.defaultProps) => {
10
- const a = (s) => {
11
- t != null && t.watchIdInterval && (t == null || t.watchIdInterval(s));
12
- }, v = (s) => {
13
- t != null && t.controlAction && (t == null || t.controlAction(s));
9
+ A(this, "startActionEvery", (e, t = this.defaultProps) => {
10
+ const a = (r) => {
11
+ t != null && t.watchIdInterval && (t == null || t.watchIdInterval(r));
12
+ }, u = (r) => {
13
+ t != null && t.controlAction && (t == null || t.controlAction(r));
14
+ };
15
+ let l = !0, s, n, I;
16
+ const v = (r = !0) => {
17
+ const p = "Ручное завершение startActionEvery";
18
+ l = !1, clearInterval(s), a(null), r ? n && n({ status: r, msg: p + ": (true)" }) : I && I({ status: r, msg: p + ": (false)" });
19
+ };
20
+ return {
21
+ promise: new Promise((r, p) => {
22
+ n = r, I = p;
23
+ let d = 0, o = 0;
24
+ s = setInterval(
25
+ () => {
26
+ if (d += t.interval, o += 1, t != null && t.cutoffTime && d > t.cutoffTime || t != null && t.countAction && (t == null ? void 0 : t.countAction) < o) {
27
+ l = !1, clearInterval(s), a(null), p({ status: !1, msg: Error("Время загрузки истекло") });
28
+ return;
29
+ }
30
+ e() && (l = !1, clearInterval(s), a(null), r({ status: !0, msg: "cb вернул true" }));
31
+ },
32
+ t.interval < 200 ? 200 : t.interval
33
+ ), a(s), u({
34
+ getIsActiveEvent: () => l,
35
+ stop: v
36
+ });
37
+ }),
38
+ stop: v
14
39
  };
15
- return new Promise((s, l) => {
16
- let n = 0, m = 0;
17
- const r = {
18
- isActive: !0
19
- }, A = setInterval(
20
- () => {
21
- if (n += t.interval, m += 1, t != null && t.cutoffTime && n > t.cutoffTime || t != null && t.countAction && (t == null ? void 0 : t.countAction) < m) {
22
- r.isActive = !1, clearInterval(A), a(null), l({ status: !1, msg: Error("Время загрузки истекло") });
23
- return;
24
- }
25
- e() && (r.isActive = !1, clearInterval(A), a(null), s({ status: !0, msg: "cb вернул true" }));
26
- },
27
- t.interval < 200 ? 200 : t.interval
28
- );
29
- a(A), v({
30
- getIsActiveEvent: () => r.isActive,
31
- stop: (p) => {
32
- const d = "Ручное завершение startActionEvery";
33
- r.isActive = !1, clearInterval(A), a(null), p ? s({ status: p, msg: d + ": (true)" }) : l({ status: p, msg: d + ": (false)" });
34
- }
35
- });
36
- });
37
40
  });
38
- I(this, "oneOf", (e, t, { second: a }) => {
39
- let v = 1;
41
+ A(this, "oneOf", (e, t, { second: a }) => {
42
+ let u = 1;
40
43
  e().then(() => {
41
- v === 1 && (v = 0);
44
+ u === 1 && (u = 0);
42
45
  });
43
- let s = setInterval(() => {
44
- v === 1 && t(), clearInterval(s);
46
+ let l = setInterval(() => {
47
+ u === 1 && t(), clearInterval(l);
45
48
  }, a * 1e3);
46
49
  });
47
- I(this, "oneOfPromise", (e, t, { second: a }) => new Promise((v, s) => {
48
- let l = 1, n = { status: !1, msg: "" };
49
- e().then((r) => {
50
- l === 1 && (l = 0, v(r));
51
- }).catch((r) => {
52
- l === 1 && (l = 0, n.msg = r, s(r));
50
+ A(this, "oneOfPromise", (e, t, { second: a }) => new Promise((u, l) => {
51
+ let s = 1, n = { status: !1, msg: "" };
52
+ e().then((v) => {
53
+ s === 1 && (s = 0, u(v));
54
+ }).catch((v) => {
55
+ s === 1 && (s = 0, n.msg = v, l(v));
53
56
  });
54
- let m = setInterval(() => {
55
- if (l === 1) {
56
- if (l = 0, typeof t == "function") {
57
- s({ status: !1, msg: "", ...t(n) });
57
+ let I = setInterval(() => {
58
+ if (s === 1) {
59
+ if (s = 0, typeof t == "function") {
60
+ l({ status: !1, msg: "", ...t(n) });
58
61
  return;
59
62
  }
60
- s({ status: !1, msg: "oneOfPromise reject" });
63
+ l({ status: !1, msg: "oneOfPromise reject" });
61
64
  }
62
- clearInterval(m);
65
+ clearInterval(I);
63
66
  }, a * 1e3);
64
67
  }));
65
68
  }
66
69
  }
67
70
  export {
68
- h as DelaysPromise
71
+ O as DelaysPromise
69
72
  };
@@ -14,10 +14,13 @@ interface OneOfPromiseReject {
14
14
  msg: string;
15
15
  }
16
16
  export interface DelaysPromiseProps {
17
- startActionEvery: (cb: () => boolean, config: StartActionEveryConfigI) => Promise<{
18
- status: boolean;
19
- msg: string;
20
- }>;
17
+ startActionEvery: (cb: () => boolean, config: StartActionEveryConfigI) => {
18
+ stop: ControlAction['stop'];
19
+ promise: Promise<{
20
+ status: boolean;
21
+ msg: string;
22
+ }>;
23
+ };
21
24
  oneOf: (watchPromise: () => Promise<any>, potentialCaseCB: () => void, config: {
22
25
  second: number;
23
26
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { WsApi_Options_P } from './deps/WsApi';
2
- import { SocketApi_Options_P, SocketApi_State_P } from './SocketApi.types';
2
+ import { SocketApi_Options_P, SocketApi_StateProps_P } from './SocketApi.types';
3
3
 
4
4
  export declare class SocketApi {
5
5
  #private;
@@ -20,9 +20,17 @@ export declare class SocketApi {
20
20
  private static online;
21
21
  private static offline;
22
22
  private static splitOptions;
23
- static getState: () => SocketApi_State_P;
23
+ static getState: () => SocketApi_StateProps_P;
24
24
  static on: typeof SocketApi.wsApi.on & typeof SocketApi.events.subscribe;
25
25
  static off: typeof SocketApi.wsApi.on & typeof SocketApi.events.subscribe;
26
+ static getRequestSave: () => {
27
+ payload: {
28
+ [key: string]: any;
29
+ action: string;
30
+ };
31
+ reqId: string;
32
+ cb: any;
33
+ }[];
26
34
  static getStatusSocket: () => import('./deps/WsApi').WsApiE_StatusConnect_OR;
27
35
  static close: () => void;
28
36
  static init: (options: WsApi_Options_P & SocketApi_Options_P) => void;
@@ -1,24 +1,24 @@
1
1
  var w = Object.defineProperty;
2
- var C = (i, e, s) => e in i ? w(i, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[e] = s;
3
- var n = (i, e, s) => (C(i, typeof e != "symbol" ? e + "" : e, s), s);
4
- var f = (i, e, s) => {
5
- if (e.has(i))
2
+ var C = (o, e, s) => e in o ? w(o, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[e] = s;
3
+ var n = (o, e, s) => (C(o, typeof e != "symbol" ? e + "" : e, s), s);
4
+ var f = (o, e, s) => {
5
+ if (e.has(o))
6
6
  throw TypeError("Cannot add the same private member more than once");
7
- e instanceof WeakSet ? e.add(i) : e.set(i, s);
7
+ e instanceof WeakSet ? e.add(o) : e.set(o, s);
8
8
  };
9
9
  import { DelaysPromise as R } from "../DelaysPromise/DelaysPromise.js";
10
- import { NetworkInformationCordova as d } from "../Utils/NetworkInformation/classes/NetworkInformationCordova.js";
11
- import { NetworkInformationPC as v } from "../Utils/NetworkInformation/classes/NetworkInformationPC.js";
10
+ import { NetworkInformationCordova as v } from "../Utils/NetworkInformation/classes/NetworkInformationCordova.js";
11
+ import { NetworkInformationPC as d } from "../Utils/NetworkInformation/classes/NetworkInformationPC.js";
12
12
  import { EventSubscribers as g } from "../Utils/EventSubscribers/EventSubscribers.js";
13
13
  import { NetworkInformation as O } from "../Utils/NetworkInformation/NetworkInformation.js";
14
14
  import { WsApi as S } from "./deps/WsApi/WsApi.js";
15
15
  const I = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
16
- function m(i) {
17
- return I.test(i);
16
+ function m(o) {
17
+ return I.test(o);
18
18
  }
19
19
  function u() {
20
- var i = URL.createObjectURL(new Blob()), e = i.toString();
21
- return URL.revokeObjectURL(i), e.split(/[:\/]/g).pop().toLowerCase();
20
+ var o = URL.createObjectURL(new Blob()), e = o.toString();
21
+ return URL.revokeObjectURL(o), e.split(/[:\/]/g).pop().toLowerCase();
22
22
  }
23
23
  u.valid = m;
24
24
  var r, A;
@@ -45,10 +45,10 @@ const t = class t {
45
45
  t.state.isDisconnect || (t.setState({ isDisconnect: !0 }), console.log("DISCONNECT WS"), t.wsApi.disconnect(), t.resetState());
46
46
  }
47
47
  static send(e, s) {
48
- const { action: o, ...c } = e, a = u();
48
+ const { action: i, ...c } = e, a = u();
49
49
  t.wsApi.setRequestSave({
50
50
  reqId: a,
51
- payload: { action: o, ...c },
51
+ payload: { action: i, ...c },
52
52
  cb: s
53
53
  });
54
54
  const l = t.wsApi.getSocket();
@@ -71,7 +71,7 @@ r = new WeakSet(), A = function() {
71
71
  isNetworkStatus: navigator.onLine
72
72
  }), n(t, "options", {
73
73
  isReConnectNetworkOnline: !1
74
- }), n(t, "wsApi", new S()), n(t, "delay", new R()), n(t, "internet", new O([new v(), new d()])), n(t, "events", new g(["timeOffReConnect", "reConnect"])), n(t, "saveID", {
74
+ }), n(t, "wsApi", new S()), n(t, "delay", new R()), n(t, "internet", new O([new d(), new v()])), n(t, "events", new g(["timeOffReConnect", "reConnect"])), n(t, "saveID", {
75
75
  idReConnect: null,
76
76
  checkConnect: null
77
77
  }), n(t, "stateDefault", t.copyState(t.state)), n(t, "setInfoConnect", (e) => {
@@ -81,9 +81,9 @@ r = new WeakSet(), A = function() {
81
81
  }), n(t, "offline", () => {
82
82
  t.setState({ isNetworkStatus: !1 }), t.state.isActiveReConnect && t.stopReConnect(!1);
83
83
  }), n(t, "splitOptions", (e) => Object.entries(e).reduce(
84
- (s, [o, c]) => {
84
+ (s, [i, c]) => {
85
85
  const a = t.wsApi.getOptions();
86
- return o in a ? { ...s, WsOptions: { ...s.WsOptions, [o]: c } } : { ...s, SocketApiOptions: { ...s.SocketApiOptions, [o]: c } };
86
+ return i in a ? { ...s, WsOptions: { ...s.WsOptions, [i]: c } } : { ...s, SocketApiOptions: { ...s.SocketApiOptions, [i]: c } };
87
87
  },
88
88
  { WsOptions: {}, SocketApiOptions: {} }
89
89
  )), /*---------------------------------------------------------------------------------------------------------------------------*/
@@ -91,20 +91,14 @@ n(t, "getState", () => t.state), n(t, "on", (e, s) => {
91
91
  t.wsApi.getRegisteredEvents().includes(e) ? t.wsApi.on(e, s) : t.events.subscribe(e, s);
92
92
  }), n(t, "off", (e, s) => {
93
93
  t.wsApi.getRegisteredEvents().includes(e) ? t.wsApi.off(e, s) : t.events.unsubscribe(e, s);
94
- }), // static getRequestSave = SocketApi.wsApi.getRequestSave;
95
- n(t, "getStatusSocket", t.wsApi.getStatusSocket), n(t, "close", () => {
94
+ }), n(t, "getRequestSave", t.wsApi.getRequestSave), n(t, "getStatusSocket", t.wsApi.getStatusSocket), n(t, "close", () => {
96
95
  t.state.isActiveReConnect ? t.stopReConnect(!1) : t.wsApi.close();
97
96
  }), n(t, "init", (e) => {
98
- const { WsOptions: s, SocketApiOptions: o } = t.splitOptions(e);
97
+ const { WsOptions: s, SocketApiOptions: i } = t.splitOptions(e);
99
98
  t.internet.run((c) => {
100
99
  c ? t.online() : t.offline();
101
- }), t.setOptions(o), t.wsApi.init(s);
100
+ }), t.setOptions(i), t.wsApi.init(s);
102
101
  }), /*------------------------------------------------------------------------------------------------------*/
103
- // useEffect(() => {
104
- // if((isReConnectSocket && (!isNetworkStatus || statusWS === 'ready'))){
105
- // SocketApi.stopReConnect();
106
- // }
107
- // },[isReConnectSocket, isNetworkStatus, statusWS]);
108
102
  n(t, "socketReConnect", () => {
109
103
  if (t.wsApi.getIsInitWS())
110
104
  if (console.log("reconnect"), t.saveID.idReConnect)
@@ -117,14 +111,14 @@ n(t, "socketReConnect", () => {
117
111
  {
118
112
  interval: e,
119
113
  countAction: s,
120
- watchIdInterval: (o) => {
121
- t.saveID.idReConnect = o;
114
+ watchIdInterval: (c) => {
115
+ t.saveID.idReConnect = c;
122
116
  },
123
- controlAction: ({ stop: o, getIsActiveEvent: c }) => {
124
- t.stopReConnect = o;
117
+ controlAction: ({ stop: c, getIsActiveEvent: a }) => {
118
+ t.stopReConnect = c;
125
119
  }
126
120
  }
127
- ).then(t.setInfoConnect).catch(t.setInfoConnect);
121
+ ).promise.then(t.setInfoConnect).catch(t.setInfoConnect);
128
122
  }
129
123
  });
130
124
  let p = t;
@@ -1,6 +1,9 @@
1
+ import { WsApiE_StatusConnect_OR } from './deps/WsApi';
2
+
1
3
  export interface SocketApi_Options_P {
2
4
  isReConnectNetworkOnline?: boolean;
3
5
  }
4
- type SocketApi_State_OR = 'isDisconnect' | 'isActiveReConnect' | 'isOfflineSocket' | 'isReady' | 'isNetworkStatus';
5
- export type SocketApi_State_P = Record<SocketApi_State_OR, boolean>;
6
+ type SocketApi_StateProps_OR = 'isDisconnect' | 'isActiveReConnect' | 'isOfflineSocket' | 'isReady' | 'isNetworkStatus';
7
+ export type SocketApi_StateProps_P = Record<SocketApi_StateProps_OR, boolean>;
8
+ export type SocketApi_StatusConnect_OR = WsApiE_StatusConnect_OR;
6
9
  export {};
@@ -1,2 +1,2 @@
1
1
  export * from './SocketApi';
2
- export { type SocketApi_State_P } from './SocketApi.types';
2
+ export { type SocketApi_StateProps_P, type SocketApi_StatusConnect_OR } from './SocketApi.types';
package/package.json CHANGED
@@ -2,16 +2,16 @@
2
2
  "name": "dev-classes",
3
3
  "private": false,
4
4
  "author": "SinGlEBW",
5
+ "homepage": "https://github.com/SinGlEBW/dev-classes#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/SinGlEBW/dev-classes/issues"
8
+ },
5
9
  "repository": {
6
10
  "type": "git",
7
11
  "url": "git+https://github.com/SinGlEBW/dev-classes.git"
8
12
  },
9
- "bugs": {
10
- "url": "https://github.com/SinGlEBW/dev-classes/issues"
11
- },
12
- "homepage": "https://github.com/SinGlEBW/dev-classes#readme",
13
13
  "license": "MIT",
14
- "version": "1.3.27",
14
+ "version": "1.3.29",
15
15
  "type": "module",
16
16
  "module": "./dist/index.js",
17
17
  "main": "./dist/index.js",
@@ -38,7 +38,8 @@
38
38
  "scripts": {
39
39
  "start": "vite",
40
40
  "build": "tsc && vite build",
41
- "preview": "vite preview"
41
+ "preview": "vite preview",
42
+ "publish": "node publishVersion.js"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@types/js-cookie": "^3.0.6",