dev-classes 1.2.1 → 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.
@@ -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, cb?: (data: ResType) => void, cbError?: (err: Error) => void): void;
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;
@@ -1,7 +1,7 @@
1
1
  var f = Object.defineProperty;
2
- var p = (n, e, s) => e in n ? f(n, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[e] = s;
3
- var c = (n, e, s) => (p(n, typeof e != "symbol" ? e + "" : e, s), s);
4
- import { WsApi as u } from "./deps/WsApi/WsApi.js";
2
+ var u = (n, e, s) => e in n ? f(n, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[e] = s;
3
+ var c = (n, e, s) => (u(n, typeof e != "symbol" ? e + "" : e, s), s);
4
+ import { WsApi as p } from "./deps/WsApi/WsApi.js";
5
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
6
  function d(n) {
7
7
  return C.test(n);
@@ -30,18 +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, g) {
34
- var a;
33
+ static send(e, s) {
34
+ var o;
35
35
  const { action: r, ...w } = e, l = i();
36
36
  if (t.wsApi.setRequestSave({
37
37
  reqId: l,
38
38
  payload: { action: r, ...w },
39
39
  cb: s
40
40
  }), !t.wsApi.state.ws || t.wsApi.state.ws.readyState !== 1) {
41
- console.log("Нет подключения к сокету. Данные запроса сохранены", t.wsApi.state.arrSaveReq);
41
+ console.log("Нет подключения к сокету");
42
42
  return;
43
43
  }
44
- (a = t.wsApi.state.ws) == null || a.send(JSON.stringify(e));
44
+ (o = t.wsApi.state.ws) == null || o.send(JSON.stringify(e));
45
45
  }
46
46
  static connect() {
47
47
  t.createConnect();
@@ -73,7 +73,7 @@ const t = class t {
73
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();
74
74
  }
75
75
  };
76
- c(t, "wsApi", new u()), c(t, "watch", new R()), c(t, "state", {
76
+ c(t, "wsApi", new p()), c(t, "watch", new R()), c(t, "state", {
77
77
  isDisconnect: !0,
78
78
  initConnect: !1,
79
79
  isReConnect: !1
@@ -101,7 +101,7 @@ c(t, "wsApi", new u()), c(t, "watch", new R()), c(t, "state", {
101
101
  }), c(t, "setInfoConnect", (e) => {
102
102
  e.status || t.close(), t.watch.watchTimeOffReConnect(e), t.watch.watchReConnect(!1), t.state.isReConnect = !1;
103
103
  });
104
- let o = t;
104
+ let a = t;
105
105
  export {
106
- o as SocketApi
106
+ a as SocketApi
107
107
  };
@@ -20,6 +20,7 @@ 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;
@@ -2,7 +2,7 @@ var h = Object.defineProperty;
2
2
  var l = (i, n, e) => n in i ? h(i, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[n] = e;
3
3
  var r = (i, n, e) => (l(i, typeof n != "symbol" ? n + "" : n, e), e);
4
4
  import { DelaysPromise as c } from "../../../Delay/Delay.js";
5
- import { InternetWatcher as d } from "../InternetWatcher/InternetWatcher.js";
5
+ import { InternetWatcher as v } from "../InternetWatcher/InternetWatcher.js";
6
6
  class p extends c {
7
7
  constructor() {
8
8
  super(...arguments);
@@ -11,11 +11,10 @@ class p extends c {
11
11
  numberOfRepit: 5,
12
12
  url: ""
13
13
  });
14
- r(this, "internet", new d());
14
+ r(this, "internet", new v());
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
- // removeItemRequestSave(action: string) {
88
- // const newTotalRequestSave = this.state.arrSaveReq.filter((item) => item.payload?.action !== action);
89
- // this.state.arrSaveReq = newTotalRequestSave
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
  }
@@ -24,7 +24,6 @@ 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;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/SinGlEBW/dev-classes.git"
8
8
  },
9
9
  "license": "MIT",
10
- "version": "1.2.1",
10
+ "version": "1.2.2",
11
11
  "type": "module",
12
12
  "module": "./dist/index.js",
13
13
  "main": "./dist/index.js",