dev-classes 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/DateProcessing/DateProcessing.d.ts +7 -0
- package/dist/classes/DateProcessing/DateProcessing.js +10 -1
- package/dist/classes/SocketApi/SocketApi.d.ts +2 -3
- package/dist/classes/SocketApi/SocketApi.js +19 -20
- package/dist/classes/SocketApi/deps/WsApi/WsApi.d.ts +2 -2
- package/dist/classes/SocketApi/deps/WsApi/WsApi.js +8 -13
- package/dist/classes/SocketApi/deps/WsApi/WsApi.types.d.ts +1 -3
- package/package.json +1 -1
|
@@ -76,5 +76,12 @@ export declare class DateProcessing {
|
|
|
76
76
|
static getCurrentDate: DateProcessingI['getCurrentDate'];
|
|
77
77
|
static getCurrentYear: DateProcessingI['getCurrentYear'];
|
|
78
78
|
static getDaysInMonth: DateProcessingI['getDaysInMonth'];
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param date example: '2022-01-01'
|
|
82
|
+
* @param config example: {day: 1, month: 1, year: 1}
|
|
83
|
+
* @returns example: '2023-02-02'
|
|
84
|
+
*/
|
|
85
|
+
static getDateDeviation: (date: string, config: Partial<Record<"day" | "month" | "year", number>>) => string;
|
|
79
86
|
}
|
|
80
87
|
export {};
|
|
@@ -101,7 +101,16 @@ a(_DateProcessing, "getActiveColorClassInDiffDate", (e, t, r) => {
|
|
|
101
101
|
}), a(_DateProcessing, "getCurrentDate", () => {
|
|
102
102
|
const e = /* @__PURE__ */ new Date(), t = _DateProcessing.getCurrentYear(), r = e.toJSON().split("T")[0].slice(5);
|
|
103
103
|
return `${t}-${r}`;
|
|
104
|
-
}), a(_DateProcessing, "getCurrentYear", () => (/* @__PURE__ */ new Date()).getFullYear()), a(_DateProcessing, "getDaysInMonth", (e, t) => new Date(t, e, 0).getDate())
|
|
104
|
+
}), a(_DateProcessing, "getCurrentYear", () => (/* @__PURE__ */ new Date()).getFullYear()), a(_DateProcessing, "getDaysInMonth", (e, t) => new Date(t, e, 0).getDate()), /**
|
|
105
|
+
*
|
|
106
|
+
* @param date example: '2022-01-01'
|
|
107
|
+
* @param config example: {day: 1, month: 1, year: 1}
|
|
108
|
+
* @returns example: '2023-02-02'
|
|
109
|
+
*/
|
|
110
|
+
a(_DateProcessing, "getDateDeviation", (e, t) => {
|
|
111
|
+
const r = _DateProcessing.correctionDataISO8601(e), s = new Date(r), { day: n, month: c, year: i } = t;
|
|
112
|
+
return i && s.setFullYear(s.getFullYear() + i), c && s.setMonth(s.getMonth() + c), n && s.setDate(s.getDate() + n), s.toISOString().slice(0, 10);
|
|
113
|
+
});
|
|
105
114
|
let DateProcessing = _DateProcessing;
|
|
106
115
|
export {
|
|
107
116
|
DateProcessing
|
|
@@ -22,7 +22,7 @@ export declare class SocketApi {
|
|
|
22
22
|
static setOptions: (option?: ConnectOptions_P) => void;
|
|
23
23
|
static close(): void;
|
|
24
24
|
static disconnect(): void;
|
|
25
|
-
static send<ResType>(data: object,
|
|
25
|
+
static send<ResType>(data: object, cb?: (data: ResType) => void): void;
|
|
26
26
|
static connect(): void;
|
|
27
27
|
static stopReConnect(): void;
|
|
28
28
|
static resetState(): void;
|
|
@@ -33,8 +33,7 @@ export declare class SocketApi {
|
|
|
33
33
|
action: string;
|
|
34
34
|
};
|
|
35
35
|
reqId: string;
|
|
36
|
-
|
|
37
|
-
reject: any;
|
|
36
|
+
cb: any;
|
|
38
37
|
}[];
|
|
39
38
|
static watchReConnect(cb: WatchI["watchReConnect"]): void;
|
|
40
39
|
static watchTimeOffReConnect(cb: WatchI["watchTimeOffReConnect"]): void;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var u = (n, e, s) => e in n ?
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var u = (n, e, s) => e in n ? f(n, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[e] = s;
|
|
3
3
|
var c = (n, e, s) => (u(n, typeof e != "symbol" ? e + "" : e, s), s);
|
|
4
|
-
import { WsApi as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
return
|
|
4
|
+
import { WsApi as p } from "./deps/WsApi/WsApi.js";
|
|
5
|
+
const C = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
6
|
+
function d(n) {
|
|
7
|
+
return C.test(n);
|
|
8
8
|
}
|
|
9
9
|
function i() {
|
|
10
10
|
var n = URL.createObjectURL(new Blob()), e = n.toString();
|
|
11
11
|
return URL.revokeObjectURL(n), e.split(/[:\/]/g).pop().toLowerCase();
|
|
12
12
|
}
|
|
13
|
-
i.valid =
|
|
14
|
-
class
|
|
13
|
+
i.valid = d;
|
|
14
|
+
class R {
|
|
15
15
|
watchTimeOffReConnect(e) {
|
|
16
16
|
}
|
|
17
17
|
watchReConnect(e) {
|
|
@@ -30,19 +30,18 @@ const t = class t {
|
|
|
30
30
|
static disconnect() {
|
|
31
31
|
t.state.isDisconnect || (t.state.isDisconnect = !0, console.log("DISCONNECT WS"), t.wsApi.internet.removeWatcherInternet(), t.wsApi.setStatus("disconnect"), t.resetSocket(), t.resetState(), t.wsApi.resetState());
|
|
32
32
|
}
|
|
33
|
-
static send(e, s
|
|
34
|
-
var
|
|
35
|
-
const { action:
|
|
33
|
+
static send(e, s) {
|
|
34
|
+
var o;
|
|
35
|
+
const { action: r, ...w } = e, l = i();
|
|
36
36
|
if (t.wsApi.setRequestSave({
|
|
37
|
-
reqId:
|
|
38
|
-
payload: { action:
|
|
39
|
-
|
|
40
|
-
reject: r
|
|
37
|
+
reqId: l,
|
|
38
|
+
payload: { action: r, ...w },
|
|
39
|
+
cb: s
|
|
41
40
|
}), !t.wsApi.state.ws || t.wsApi.state.ws.readyState !== 1) {
|
|
42
|
-
console.log("Нет подключения к
|
|
41
|
+
console.log("Нет подключения к сокету");
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
|
-
(
|
|
44
|
+
(o = t.wsApi.state.ws) == null || o.send(JSON.stringify(e));
|
|
46
45
|
}
|
|
47
46
|
static connect() {
|
|
48
47
|
t.createConnect();
|
|
@@ -74,7 +73,7 @@ const t = class t {
|
|
|
74
73
|
console.log("CONNECT WS"), t.resetSocket(), t.state.isDisconnect = !1, t.wsApi.state.ws = new WebSocket(t.wsApi.configWs.url), t.wsApi.setStatus("pending"), t.wsApi.addEvents();
|
|
75
74
|
}
|
|
76
75
|
};
|
|
77
|
-
c(t, "wsApi", new
|
|
76
|
+
c(t, "wsApi", new p()), c(t, "watch", new R()), c(t, "state", {
|
|
78
77
|
isDisconnect: !0,
|
|
79
78
|
initConnect: !1,
|
|
80
79
|
isReConnect: !1
|
|
@@ -102,7 +101,7 @@ c(t, "wsApi", new C()), c(t, "watch", new v()), c(t, "state", {
|
|
|
102
101
|
}), c(t, "setInfoConnect", (e) => {
|
|
103
102
|
e.status || t.close(), t.watch.watchTimeOffReConnect(e), t.watch.watchReConnect(!1), t.state.isReConnect = !1;
|
|
104
103
|
});
|
|
105
|
-
let
|
|
104
|
+
let a = t;
|
|
106
105
|
export {
|
|
107
|
-
|
|
106
|
+
a as SocketApi
|
|
108
107
|
};
|
|
@@ -20,14 +20,14 @@ export declare class WsApi extends DelaysPromise {
|
|
|
20
20
|
resetState(): void;
|
|
21
21
|
private sendInformationToTheEvent;
|
|
22
22
|
setRequestSave(reqInfo: typeof this.state.arrSaveReq[number]): void;
|
|
23
|
+
removeRequestItemSave(action: string): void;
|
|
23
24
|
getRequestSave(): {
|
|
24
25
|
payload: {
|
|
25
26
|
[key: string]: any;
|
|
26
27
|
action: string;
|
|
27
28
|
};
|
|
28
29
|
reqId: string;
|
|
29
|
-
|
|
30
|
-
reject: any;
|
|
30
|
+
cb: any;
|
|
31
31
|
}[];
|
|
32
32
|
setResponceInReqSave(responce: {
|
|
33
33
|
action: string;
|
|
@@ -15,7 +15,6 @@ class p extends c {
|
|
|
15
15
|
r(this, "state", {
|
|
16
16
|
statusConnect: "disconnect",
|
|
17
17
|
ws: null,
|
|
18
|
-
isRequestArrSaveReq: !1,
|
|
19
18
|
arrSaveReq: [],
|
|
20
19
|
subscribersEvents: {
|
|
21
20
|
msg: [],
|
|
@@ -35,14 +34,7 @@ class p extends c {
|
|
|
35
34
|
(e = this.state.ws) == null || e.addEventListener("open", this.openHandler), (t = this.state.ws) == null || t.addEventListener("close", this.closeHandler), (s = this.state.ws) == null || s.addEventListener("message", this.msgHandler), (a = this.state.ws) == null || a.addEventListener("error", this.errHandler);
|
|
36
35
|
});
|
|
37
36
|
r(this, "openHandler", () => {
|
|
38
|
-
var t;
|
|
39
37
|
console.log("this >> open"), this.setStatus("ready");
|
|
40
|
-
const e = this.getRequestSave();
|
|
41
|
-
if (e.length)
|
|
42
|
-
for (let s = 0; s < e.length; s++) {
|
|
43
|
-
const a = e[s];
|
|
44
|
-
(t = this.state.ws) == null || t.send(JSON.stringify(a.payload));
|
|
45
|
-
}
|
|
46
38
|
});
|
|
47
39
|
r(this, "closeHandler", () => {
|
|
48
40
|
console.log("this >> close"), this.setStatus("close");
|
|
@@ -84,10 +76,13 @@ class p extends c {
|
|
|
84
76
|
~t ? this.state.arrSaveReq[t] = e : this.state.arrSaveReq.push(e);
|
|
85
77
|
}
|
|
86
78
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
removeRequestItemSave(e) {
|
|
80
|
+
const t = this.state.arrSaveReq.filter((s) => {
|
|
81
|
+
var a;
|
|
82
|
+
return ((a = s.payload) == null ? void 0 : a.action) !== e;
|
|
83
|
+
});
|
|
84
|
+
this.state.arrSaveReq = t;
|
|
85
|
+
}
|
|
91
86
|
getRequestSave() {
|
|
92
87
|
return this.state.arrSaveReq;
|
|
93
88
|
}
|
|
@@ -95,7 +90,7 @@ class p extends c {
|
|
|
95
90
|
const t = this.getRequestSave(), s = [];
|
|
96
91
|
for (let a = 0; a < t.length; a++) {
|
|
97
92
|
const o = t[a];
|
|
98
|
-
o.payload.action !== e.action ? s.push(o) : o.
|
|
93
|
+
o.payload.action !== e.action ? s.push(o) : o.cb && o.cb(e);
|
|
99
94
|
}
|
|
100
95
|
this.state.arrSaveReq = s, console.log("filterArrSaveReq", s);
|
|
101
96
|
}
|
|
@@ -24,15 +24,13 @@ export interface WsApiStateDefaultI {
|
|
|
24
24
|
ws: null | WebSocket;
|
|
25
25
|
}
|
|
26
26
|
export interface WsApiStateSaveDefaultI {
|
|
27
|
-
isRequestArrSaveReq: boolean;
|
|
28
27
|
arrSaveReq: {
|
|
29
28
|
payload: {
|
|
30
29
|
action: string;
|
|
31
30
|
[key: string]: any;
|
|
32
31
|
};
|
|
33
32
|
reqId: string;
|
|
34
|
-
|
|
35
|
-
reject: any;
|
|
33
|
+
cb: any;
|
|
36
34
|
}[];
|
|
37
35
|
subscribersEvents: SubscribersEvents_P;
|
|
38
36
|
}
|