dev-classes 1.0.11 → 1.0.13
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/_types/index.d.js +1 -0
- package/dist/classes/DateProcessing/DateProcessing.d.ts +2 -0
- package/dist/classes/DateProcessing/DateProcessing.js +2 -2
- package/dist/classes/SocketApi/SocketApi.d.ts +3 -3
- package/dist/classes/SocketApi/SocketApi.js +19 -21
- package/dist/classes/SocketApi/deps/ConfigInfoConnect/ConfigInfoConnect.js +3 -3
- package/dist/classes/SocketApi/deps/WsApi/WsApi.d.ts +4 -4
- package/dist/classes/SocketApi/deps/WsApi/WsApi.types.d.ts +19 -6
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -45,6 +45,7 @@ export interface DateProcessingI {
|
|
|
45
45
|
}): 'Сегодня' | 'Вчера' | 'Позавчера' | string;
|
|
46
46
|
getCurrentDate(): string;
|
|
47
47
|
getDaysInMonth(a: number, b: number): number;
|
|
48
|
+
getCurrentYear(): number;
|
|
48
49
|
}
|
|
49
50
|
export declare class DateProcessing {
|
|
50
51
|
static getActiveColorClassInDiffDate: DateProcessingI['getActiveColorClassInDiffDate'];
|
|
@@ -73,6 +74,7 @@ export declare class DateProcessing {
|
|
|
73
74
|
static cropSecond: DateProcessingI['cropSecond'];
|
|
74
75
|
static getRenderDate: DateProcessingI['getRenderDate'];
|
|
75
76
|
static getCurrentDate: DateProcessingI['getCurrentDate'];
|
|
77
|
+
static getCurrentYear: DateProcessingI['getCurrentYear'];
|
|
76
78
|
static getDaysInMonth: DateProcessingI['getDaysInMonth'];
|
|
77
79
|
}
|
|
78
80
|
export {};
|
|
@@ -99,9 +99,9 @@ a(_DateProcessing, "getActiveColorClassInDiffDate", (e, t, r) => {
|
|
|
99
99
|
return _DateProcessing.correctionDate(e, { shortYear: !0, withOutCurrentYear: r });
|
|
100
100
|
}
|
|
101
101
|
}), a(_DateProcessing, "getCurrentDate", () => {
|
|
102
|
-
const e = /* @__PURE__ */ new Date(), t =
|
|
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, "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
105
|
let DateProcessing = _DateProcessing;
|
|
106
106
|
export {
|
|
107
107
|
DateProcessing
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectOptions_P,
|
|
1
|
+
import { ConnectOptions_P, EventNames_OR, GetCbByKeyNameEvent } from './deps/WsApi';
|
|
2
2
|
|
|
3
3
|
interface WatchI {
|
|
4
4
|
watchTimeOffReConnect(info: {
|
|
@@ -17,8 +17,8 @@ export declare class SocketApi {
|
|
|
17
17
|
};
|
|
18
18
|
private static saveID;
|
|
19
19
|
private static stateDefault;
|
|
20
|
-
static on<
|
|
21
|
-
static off<
|
|
20
|
+
static on<K extends EventNames_OR>(eventName: K, cb: GetCbByKeyNameEvent<K>): () => void;
|
|
21
|
+
static off<K extends EventNames_OR>(eventName: K, cb: GetCbByKeyNameEvent<K>): void;
|
|
22
22
|
static setOptions: (option?: ConnectOptions_P) => void;
|
|
23
23
|
static close(): void;
|
|
24
24
|
static disconnect(): void;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var p = Object.defineProperty;
|
|
2
2
|
var u = (n, e, s) => e in n ? p(n, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[e] = s;
|
|
3
|
-
var
|
|
3
|
+
var c = (n, e, s) => (u(n, typeof e != "symbol" ? e + "" : e, s), s);
|
|
4
4
|
import { WsApi as C } from "./deps/WsApi/WsApi.js";
|
|
5
5
|
const R = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
6
6
|
function A(n) {
|
|
7
7
|
return R.test(n);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
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
|
-
|
|
14
|
-
class
|
|
13
|
+
i.valid = A;
|
|
14
|
+
class v {
|
|
15
15
|
watchTimeOffReConnect(e) {
|
|
16
16
|
}
|
|
17
17
|
watchReConnect(e) {
|
|
@@ -28,19 +28,18 @@ const t = class t {
|
|
|
28
28
|
t.resetSocket(), t.wsApi.setStatus("close");
|
|
29
29
|
}
|
|
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
33
|
static send(e) {
|
|
34
34
|
return new Promise((s, r) => {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
let { action: w, ...v } = e;
|
|
35
|
+
var a;
|
|
36
|
+
let { action: w, ...d } = e;
|
|
38
37
|
if (!t.wsApi.state.ws || t.wsApi.state.ws.readyState !== 1) {
|
|
39
|
-
t.wsApi.state.arrSaveReq.some((f) => f.action === e.action) ||
|
|
38
|
+
t.wsApi.state.arrSaveReq.some((f) => f.action === e.action) || t.wsApi.state.arrSaveReq.push(e);
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
|
-
const l =
|
|
43
|
-
t.wsApi.totalInfoReqPromise.push({ action: w, reqId: l, resolve: s, reject: r }), (
|
|
41
|
+
const l = i();
|
|
42
|
+
t.wsApi.totalInfoReqPromise.push({ action: w, reqId: l, resolve: s, reject: r }), (a = t.wsApi.state.ws) == null || a.send(JSON.stringify(e)), t.wsApi.state.arrSaveReq.length && !t.wsApi.state.isRequestArrSaveReq && (t.wsApi.state.isRequestArrSaveReq = !0);
|
|
44
43
|
});
|
|
45
44
|
}
|
|
46
45
|
static connect() {
|
|
@@ -70,19 +69,19 @@ const t = class t {
|
|
|
70
69
|
(e = t.wsApi.state.ws) == null || e.close(), t.wsApi.removeEvents();
|
|
71
70
|
}
|
|
72
71
|
static createConnect() {
|
|
73
|
-
console.
|
|
72
|
+
console.log("CONNECT WS"), t.resetSocket(), t.state.isDisconnect = !1, t.wsApi.state.ws = new WebSocket(t.wsApi.state.url), t.wsApi.setStatus("pending"), t.wsApi.addEvents();
|
|
74
73
|
}
|
|
75
74
|
};
|
|
76
|
-
|
|
75
|
+
c(t, "wsApi", new C()), c(t, "watch", new v()), c(t, "state", {
|
|
77
76
|
isDisconnect: !0,
|
|
78
77
|
initConnect: !1,
|
|
79
78
|
isReConnect: !1
|
|
80
|
-
}),
|
|
79
|
+
}), c(t, "saveID", {
|
|
81
80
|
idConnect: null,
|
|
82
81
|
checkConnect: null
|
|
83
|
-
}),
|
|
82
|
+
}), c(t, "stateDefault", t.copyState(t.state)), c(t, "setOptions", (e = t.wsApi.configWs) => {
|
|
84
83
|
t.state.initConnect || (t.wsApi.configWs = e, t.wsApi.internet.addWatcherInternet());
|
|
85
|
-
}),
|
|
84
|
+
}), c(t, "getEndReq", () => t.wsApi.state.arrSaveReq), c(t, "socketReConnect", () => {
|
|
86
85
|
t.saveID.idConnect ? (console.groupCollapsed("Процесс idConnect уже запущен"), console.log("SocketApi.saveID: ", t.saveID), console.groupEnd()) : (t.state.isReConnect = !0, t.watch.watchReConnect(!0), t.createConnect(), t.wsApi.startActionEvery(
|
|
87
86
|
() => t.wsApi.state.statusConnect === "ready" ? !0 : (t.createConnect(), !1),
|
|
88
87
|
{
|
|
@@ -92,17 +91,16 @@ a(t, "wsApi", new C()), a(t, "watch", new d()), a(t, "state", {
|
|
|
92
91
|
t.saveID.idConnect = e;
|
|
93
92
|
},
|
|
94
93
|
controlAction: ({ stop: e, getIsActiveEvent: s }) => {
|
|
95
|
-
console.
|
|
94
|
+
console.group("Вызван controlAction"), console.log("getIsActiveEvent не используется"), console.groupEnd(), t.stopReConnect = () => {
|
|
96
95
|
e();
|
|
97
96
|
};
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
).then(t.setInfoConnect).catch(t.setInfoConnect));
|
|
101
|
-
}),
|
|
100
|
+
}), c(t, "setInfoConnect", (e) => {
|
|
102
101
|
e.status || t.close(), t.watch.watchTimeOffReConnect(e), t.watch.watchReConnect(!1), t.state.isReConnect = !1;
|
|
103
102
|
});
|
|
104
|
-
let
|
|
105
|
-
window.SocketApi = c;
|
|
103
|
+
let o = t;
|
|
106
104
|
export {
|
|
107
|
-
|
|
105
|
+
o as SocketApi
|
|
108
106
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var i = Object.defineProperty;
|
|
2
2
|
var e = (n, o, t) => o in n ? i(n, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[o] = t;
|
|
3
3
|
var s = (n, o, t) => (e(n, typeof o != "symbol" ? o + "" : o, t), t);
|
|
4
|
-
class
|
|
4
|
+
class C {
|
|
5
5
|
constructor() {
|
|
6
6
|
s(this, "options", {
|
|
7
7
|
stop: !1
|
|
8
8
|
});
|
|
9
9
|
s(this, "setConditionReConnect", (o) => {
|
|
10
|
-
|
|
10
|
+
this.options = { ...this.options, ...o };
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
C as ConfigInfoConnect
|
|
16
16
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectOptions_P,
|
|
1
|
+
import { ConnectOptions_P, EventNames_OR, StatusConnect_OR, WsApiStateDefaultI, WsApiStateSaveDefaultI, GetCbByKeyNameEvent } from './WsApi.types';
|
|
2
2
|
import { InternetWatcher } from '../InternetWatcher/InternetWatcher';
|
|
3
3
|
import { DelaysPromise } from '../../../Delay/Delay';
|
|
4
4
|
|
|
@@ -13,13 +13,13 @@ export declare class WsApi extends DelaysPromise {
|
|
|
13
13
|
reject: any;
|
|
14
14
|
}[];
|
|
15
15
|
private stateDefault;
|
|
16
|
-
setStatus: (status:
|
|
16
|
+
setStatus: (status: StatusConnect_OR) => void;
|
|
17
17
|
removeEvents: () => void;
|
|
18
18
|
addEvents: () => void;
|
|
19
19
|
openHandler: () => void;
|
|
20
20
|
closeHandler: () => void;
|
|
21
|
-
on<
|
|
22
|
-
off<
|
|
21
|
+
on<K extends EventNames_OR>(eventName: K, cb: GetCbByKeyNameEvent<K>): () => void;
|
|
22
|
+
off<K extends EventNames_OR>(eventName: K, cb: GetCbByKeyNameEvent<K>): void;
|
|
23
23
|
msgHandler: (e: any) => void;
|
|
24
24
|
errHandler: (err: any) => void;
|
|
25
25
|
private copyState;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
export interface ConnectOptions_P {
|
|
2
2
|
timeReConnect: number;
|
|
3
3
|
}
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export type EventNames_OR = "msg" | "status";
|
|
5
|
+
export type StatusConnect_OR = "pending" | "ready" | "error" | "close" | "disconnect";
|
|
6
|
+
interface EventByStatus {
|
|
7
|
+
event: 'status';
|
|
8
|
+
cb(status: StatusConnect_OR): void;
|
|
9
|
+
}
|
|
10
|
+
interface EventByMSG {
|
|
11
|
+
event: 'msg';
|
|
12
|
+
cb(payload: any): void;
|
|
13
|
+
}
|
|
14
|
+
interface EventsInfoByName_P {
|
|
15
|
+
status: EventByStatus;
|
|
16
|
+
msg: EventByMSG;
|
|
17
|
+
}
|
|
18
|
+
export type GetCbByKeyNameEvent<K extends EventNames_OR> = EventsInfoByName_P[K]['cb'];
|
|
19
|
+
export type SubscribersEvents_P = Record<EventNames_OR, any[]>;
|
|
8
20
|
export interface WsApiStateDefaultI {
|
|
9
|
-
statusConnect:
|
|
21
|
+
statusConnect: StatusConnect_OR;
|
|
10
22
|
ws: null | WebSocket;
|
|
11
23
|
url: string;
|
|
12
24
|
}
|
|
13
25
|
export interface WsApiStateSaveDefaultI {
|
|
14
26
|
isRequestArrSaveReq: boolean;
|
|
15
27
|
arrSaveReq: any[];
|
|
16
|
-
subscribersEvents:
|
|
28
|
+
subscribersEvents: SubscribersEvents_P;
|
|
17
29
|
}
|
|
30
|
+
export {};
|