dev-classes 1.4.1 → 1.4.10

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
@@ -234,4 +234,14 @@ MyClass.on('myEvent', (status) => {
234
234
  })
235
235
  MyClass.runTime(2);
236
236
 
237
+ ```
238
+
239
+ <h3 align="center">NetworkStatusTracker</h3>
240
+
241
+ ```ts
242
+ // Будущая замена NetworkInformation
243
+ const networkTicker = new NetworkStatusTracker([]);
244
+ networkTicker.startEvents((info) => {
245
+ SocketApi.setNetworkStatus(info);
246
+ });
237
247
  ```
@@ -0,0 +1,35 @@
1
+ var c = Object.defineProperty;
2
+ var u = (b, s, e) => s in b ? c(b, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : b[s] = e;
3
+ var t = (b, s, e) => (u(b, typeof s != "symbol" ? s + "" : s, e), e);
4
+ class E {
5
+ constructor(s) {
6
+ t(this, "subscribersEvents", {});
7
+ t(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
8
+ t(this, "getSubscribers", () => this.subscribersEvents);
9
+ t(this, "subscribe", (s, e) => {
10
+ var r;
11
+ (r = this.subscribersEvents[s]) == null || r.push(e);
12
+ });
13
+ t(this, "unsubscribe", (s, e) => {
14
+ var r;
15
+ this.subscribersEvents[s] && (this.subscribersEvents[s] = (r = this.subscribersEvents[s]) == null ? void 0 : r.filter((i) => i !== e));
16
+ });
17
+ t(this, "publish", (s, e) => {
18
+ var r;
19
+ this.subscribersEvents[s] && ((r = this.subscribersEvents[s]) == null || r.forEach((i) => {
20
+ i(e);
21
+ }));
22
+ });
23
+ t(this, "resetSubscribers", () => {
24
+ const s = Object.entries(this.subscribersEvents);
25
+ for (const [e, r] of s)
26
+ this.subscribersEvents[e] = [];
27
+ });
28
+ s.forEach((e) => {
29
+ this.subscribersEvents[e] = [];
30
+ });
31
+ }
32
+ }
33
+ export {
34
+ E as EventSubscribers
35
+ };
@@ -5,7 +5,7 @@ import { NetworkInformation as k } from "../Utils/NetworkInformation/NetworkInfo
5
5
  import { apiRequest as u } from "./deps/apiRequest/apiRequest.js";
6
6
  import { NetworkInformationCordova as g } from "../Utils/NetworkInformation/classes/NetworkInformationCordova.js";
7
7
  import { NetworkInformationPC as b } from "../Utils/NetworkInformation/classes/NetworkInformationPC.js";
8
- import { EventSubscribers as N } from "../Utils/EventSubscribers/EventSubscribers.js";
8
+ import { EventSubscribers as N } from "../EventSubscribers/EventSubscribers.js";
9
9
  const t = class t {
10
10
  static setState(e) {
11
11
  t.state = { ...t.state, ...e };
@@ -42,6 +42,7 @@ const t = class t {
42
42
  t.events.publish("fetch", n), I(n);
43
43
  }).catch((c) => {
44
44
  const n = {
45
+ //TODO: Проверить. dataErr не верно возвращает
45
46
  isReq: !1,
46
47
  isReload: !1,
47
48
  keyAction: e,
@@ -4,7 +4,7 @@ var x = (e, t, n) => (lt(e, typeof t != "symbol" ? t + "" : t, n), n);
4
4
  import { ErrorsHandler as ft } from "./ErrorsHandler/ErrorsHandler.js";
5
5
  import { SaveRequest as Oe } from "./SaveRequest/SaveRequest.js";
6
6
  import { Utils as ne } from "../../../Utils/Utils.js";
7
- function Ie(e, t) {
7
+ function He(e, t) {
8
8
  return function() {
9
9
  return e.apply(t, arguments);
10
10
  };
@@ -12,25 +12,25 @@ function Ie(e, t) {
12
12
  const { toString: dt } = Object.prototype, { getPrototypeOf: ye } = Object, X = /* @__PURE__ */ ((e) => (t) => {
13
13
  const n = dt.call(t);
14
14
  return e[n] || (e[n] = n.slice(8, -1).toLowerCase());
15
- })(/* @__PURE__ */ Object.create(null)), U = (e) => (e = e.toLowerCase(), (t) => X(t) === e), Q = (e) => (t) => typeof t === e, { isArray: _ } = Array, v = Q("undefined");
15
+ })(/* @__PURE__ */ Object.create(null)), D = (e) => (e = e.toLowerCase(), (t) => X(t) === e), Q = (e) => (t) => typeof t === e, { isArray: _ } = Array, v = Q("undefined");
16
16
  function pt(e) {
17
17
  return e !== null && !v(e) && e.constructor !== null && !v(e.constructor) && N(e.constructor.isBuffer) && e.constructor.isBuffer(e);
18
18
  }
19
- const He = U("ArrayBuffer");
19
+ const qe = D("ArrayBuffer");
20
20
  function ht(e) {
21
21
  let t;
22
- return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && He(e.buffer), t;
22
+ return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && qe(e.buffer), t;
23
23
  }
24
24
  const mt = Q("string"), N = Q("function"), ve = Q("number"), Z = (e) => e !== null && typeof e == "object", yt = (e) => e === !0 || e === !1, J = (e) => {
25
25
  if (X(e) !== "object")
26
26
  return !1;
27
27
  const t = ye(e);
28
28
  return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(Symbol.toStringTag in e) && !(Symbol.iterator in e);
29
- }, wt = U("Date"), gt = U("File"), bt = U("Blob"), Et = U("FileList"), St = (e) => Z(e) && N(e.pipe), Rt = (e) => {
29
+ }, wt = D("Date"), gt = D("File"), bt = D("Blob"), Et = D("FileList"), St = (e) => Z(e) && N(e.pipe), Rt = (e) => {
30
30
  let t;
31
31
  return e && (typeof FormData == "function" && e instanceof FormData || N(e.append) && ((t = X(e)) === "formdata" || // detect form-data instance
32
32
  t === "object" && N(e.toString) && e.toString() === "[object FormData]"));
33
- }, Ot = U("URLSearchParams"), [Tt, At, Ct, xt] = ["ReadableStream", "Request", "Response", "Headers"].map(U), Nt = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
33
+ }, Ot = D("URLSearchParams"), [Tt, At, Ct, xt] = ["ReadableStream", "Request", "Response", "Headers"].map(D), Nt = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
34
34
  function M(e, t, { allOwnKeys: n = !1 } = {}) {
35
35
  if (e === null || typeof e > "u")
36
36
  return;
@@ -65,12 +65,12 @@ function ce() {
65
65
  return t;
66
66
  }
67
67
  const Pt = (e, t, n, { allOwnKeys: r } = {}) => (M(t, (s, o) => {
68
- n && N(s) ? e[o] = Ie(s, n) : e[o] = s;
68
+ n && N(s) ? e[o] = He(s, n) : e[o] = s;
69
69
  }, { allOwnKeys: r }), e), kt = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), Ft = (e, t, n, r) => {
70
70
  e.prototype = Object.create(t.prototype, r), e.prototype.constructor = e, Object.defineProperty(e, "super", {
71
71
  value: t.prototype
72
72
  }), n && Object.assign(e.prototype, n);
73
- }, Ut = (e, t, n, r) => {
73
+ }, Dt = (e, t, n, r) => {
74
74
  let s, o, i;
75
75
  const c = {};
76
76
  if (t = t || {}, e == null)
@@ -81,7 +81,7 @@ const Pt = (e, t, n, { allOwnKeys: r } = {}) => (M(t, (s, o) => {
81
81
  e = n !== !1 && ye(e);
82
82
  } while (e && (!n || n(e, t)) && e !== Object.prototype);
83
83
  return t;
84
- }, Dt = (e, t, n) => {
84
+ }, Ut = (e, t, n) => {
85
85
  e = String(e), (n === void 0 || n > e.length) && (n = e.length), n -= t.length;
86
86
  const r = e.indexOf(t, n);
87
87
  return r !== -1 && r === n;
@@ -110,12 +110,12 @@ const Pt = (e, t, n, { allOwnKeys: r } = {}) => (M(t, (s, o) => {
110
110
  for (; (n = e.exec(t)) !== null; )
111
111
  r.push(n);
112
112
  return r;
113
- }, qt = U("HTMLFormElement"), It = (e) => e.toLowerCase().replace(
113
+ }, It = D("HTMLFormElement"), Ht = (e) => e.toLowerCase().replace(
114
114
  /[-_\s]([a-z\d])(\w*)/g,
115
115
  function(n, r, s) {
116
116
  return r.toUpperCase() + s;
117
117
  }
118
- ), Te = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), Ht = U("RegExp"), Je = (e, t) => {
118
+ ), Te = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), qt = D("RegExp"), Je = (e, t) => {
119
119
  const n = Object.getOwnPropertyDescriptors(e), r = {};
120
120
  M(n, (s, o) => {
121
121
  let i;
@@ -175,7 +175,7 @@ const Wt = (e) => {
175
175
  return r;
176
176
  };
177
177
  return n(e, 0);
178
- }, Kt = U("AsyncFunction"), Gt = (e) => e && (Z(e) || N(e)) && N(e.then) && N(e.catch), Ve = ((e, t) => e ? setImmediate : t ? ((n, r) => (B.addEventListener("message", ({ source: s, data: o }) => {
178
+ }, Kt = D("AsyncFunction"), Gt = (e) => e && (Z(e) || N(e)) && N(e.then) && N(e.catch), Ve = ((e, t) => e ? setImmediate : t ? ((n, r) => (B.addEventListener("message", ({ source: s, data: o }) => {
179
179
  s === B && o === n && r.length && r.shift()();
180
180
  }, !1), (s) => {
181
181
  r.push(s), B.postMessage(n, "*");
@@ -184,7 +184,7 @@ const Wt = (e) => {
184
184
  N(B.postMessage)
185
185
  ), Xt = typeof queueMicrotask < "u" ? queueMicrotask.bind(B) : typeof process < "u" && process.nextTick || Ve, a = {
186
186
  isArray: _,
187
- isArrayBuffer: He,
187
+ isArrayBuffer: qe,
188
188
  isBuffer: pt,
189
189
  isFormData: Rt,
190
190
  isArrayBufferView: ht,
@@ -201,7 +201,7 @@ const Wt = (e) => {
201
201
  isDate: wt,
202
202
  isFile: gt,
203
203
  isBlob: bt,
204
- isRegExp: Ht,
204
+ isRegExp: qt,
205
205
  isFunction: N,
206
206
  isStream: St,
207
207
  isURLSearchParams: Ot,
@@ -213,21 +213,21 @@ const Wt = (e) => {
213
213
  trim: Nt,
214
214
  stripBOM: kt,
215
215
  inherits: Ft,
216
- toFlatObject: Ut,
216
+ toFlatObject: Dt,
217
217
  kindOf: X,
218
- kindOfTest: U,
219
- endsWith: Dt,
218
+ kindOfTest: D,
219
+ endsWith: Ut,
220
220
  toArray: Lt,
221
221
  forEachEntry: jt,
222
222
  matchAll: _t,
223
- isHTMLForm: qt,
223
+ isHTMLForm: It,
224
224
  hasOwnProperty: Te,
225
225
  hasOwnProp: Te,
226
226
  // an alias to avoid ESLint no-prototype-builtins detection
227
227
  reduceDescriptors: Je,
228
228
  freezeMethods: vt,
229
229
  toObjectSet: Mt,
230
- toCamelCase: It,
230
+ toCamelCase: Ht,
231
231
  noop: zt,
232
232
  toFiniteNumber: Jt,
233
233
  findKey: Me,
@@ -633,7 +633,7 @@ const Ee = be, hn = a.toObjectSet([
633
633
  s = i.indexOf(":"), n = i.substring(0, s).trim().toLowerCase(), r = i.substring(s + 1).trim(), !(!n || t[n] && hn[n]) && (n === "set-cookie" ? t[n] ? t[n].push(r) : t[n] = [r] : t[n] = t[n] ? t[n] + ", " + r : r);
634
634
  }), t;
635
635
  }, Pe = Symbol("internals");
636
- function H(e) {
636
+ function q(e) {
637
637
  return e && String(e).trim().toLowerCase();
638
638
  }
639
639
  function $(e) {
@@ -678,7 +678,7 @@ class ee {
678
678
  set(t, n, r) {
679
679
  const s = this;
680
680
  function o(c, f, u) {
681
- const l = H(f);
681
+ const l = q(f);
682
682
  if (!l)
683
683
  throw new Error("header name must be a non-empty string");
684
684
  const m = a.findKey(s, l);
@@ -697,7 +697,7 @@ class ee {
697
697
  return this;
698
698
  }
699
699
  get(t, n) {
700
- if (t = H(t), t) {
700
+ if (t = q(t), t) {
701
701
  const r = a.findKey(this, t);
702
702
  if (r) {
703
703
  const s = this[r];
@@ -714,7 +714,7 @@ class ee {
714
714
  }
715
715
  }
716
716
  has(t, n) {
717
- if (t = H(t), t) {
717
+ if (t = q(t), t) {
718
718
  const r = a.findKey(this, t);
719
719
  return !!(r && this[r] !== void 0 && (!n || se(this, this[r], r, n)));
720
720
  }
@@ -724,7 +724,7 @@ class ee {
724
724
  const r = this;
725
725
  let s = !1;
726
726
  function o(i) {
727
- if (i = H(i), i) {
727
+ if (i = q(i), i) {
728
728
  const c = a.findKey(r, i);
729
729
  c && (!n || se(r, r[c], c, n)) && (delete r[c], s = !0);
730
730
  }
@@ -783,7 +783,7 @@ class ee {
783
783
  accessors: {}
784
784
  }).accessors, s = this.prototype;
785
785
  function o(i) {
786
- const c = H(i);
786
+ const c = q(i);
787
787
  r[c] || (bn(s, i), r[c] = !0);
788
788
  }
789
789
  return a.isArray(t) ? t.forEach(o) : o(t), this;
@@ -811,10 +811,10 @@ function oe(e, t) {
811
811
  function et(e) {
812
812
  return !!(e && e.__CANCEL__);
813
813
  }
814
- function q(e, t, n) {
814
+ function I(e, t, n) {
815
815
  y.call(this, e ?? "canceled", y.ERR_CANCELED, t, n), this.name = "CanceledError";
816
816
  }
817
- a.inherits(q, y, {
817
+ a.inherits(I, y, {
818
818
  __CANCEL__: !0
819
819
  });
820
820
  function tt(e, t, n) {
@@ -952,7 +952,7 @@ function Cn(e, t) {
952
952
  function nt(e, t) {
953
953
  return e && !An(t) ? Cn(e, t) : t;
954
954
  }
955
- const Ue = (e) => e instanceof F ? { ...e } : e;
955
+ const De = (e) => e instanceof F ? { ...e } : e;
956
956
  function j(e, t) {
957
957
  t = t || {};
958
958
  const n = {};
@@ -1012,7 +1012,7 @@ function j(e, t) {
1012
1012
  socketPath: i,
1013
1013
  responseEncoding: i,
1014
1014
  validateStatus: c,
1015
- headers: (u, l) => s(Ue(u), Ue(l), !0)
1015
+ headers: (u, l) => s(De(u), De(l), !0)
1016
1016
  };
1017
1017
  return a.forEach(Object.keys(Object.assign({}, e, t)), function(l) {
1018
1018
  const m = f[l] || s, S = m(e[l], t[l], l);
@@ -1088,7 +1088,7 @@ const rt = (e) => {
1088
1088
  }, o === void 0 && i.setContentType(null), "setRequestHeader" in p && a.forEach(i.toJSON(), function(E, A) {
1089
1089
  p.setRequestHeader(A, E);
1090
1090
  }), a.isUndefined(s.withCredentials) || (p.withCredentials = !!s.withCredentials), c && c !== "json" && (p.responseType = s.responseType), u && ([S, d] = W(u, !0), p.addEventListener("progress", S)), f && p.upload && ([m, R] = W(f), p.upload.addEventListener("progress", m), p.upload.addEventListener("loadend", R)), (s.cancelToken || s.signal) && (l = (O) => {
1091
- p && (r(!O || O.type ? new q(null, e, p) : O), p.abort(), p = null);
1091
+ p && (r(!O || O.type ? new I(null, e, p) : O), p.abort(), p = null);
1092
1092
  }, s.cancelToken && s.cancelToken.subscribe(l), s.signal && (s.signal.aborted ? l() : s.signal.addEventListener("abort", l)));
1093
1093
  const b = En(s.url);
1094
1094
  if (b && C.protocols.indexOf(b) === -1) {
@@ -1105,7 +1105,7 @@ const rt = (e) => {
1105
1105
  if (!s) {
1106
1106
  s = !0, c();
1107
1107
  const l = u instanceof Error ? u : this.reason;
1108
- r.abort(l instanceof y ? l : new q(l instanceof Error ? l.message : l));
1108
+ r.abort(l instanceof y ? l : new I(l instanceof Error ? l.message : l));
1109
1109
  }
1110
1110
  };
1111
1111
  let i = t && setTimeout(() => {
@@ -1129,10 +1129,10 @@ const rt = (e) => {
1129
1129
  let r = 0, s;
1130
1130
  for (; r < n; )
1131
1131
  s = r + t, yield e.slice(r, s), r = s;
1132
- }, Un = async function* (e, t) {
1133
- for await (const n of Dn(e))
1132
+ }, Dn = async function* (e, t) {
1133
+ for await (const n of Un(e))
1134
1134
  yield* Fn(n, t);
1135
- }, Dn = async function* (e) {
1135
+ }, Un = async function* (e) {
1136
1136
  if (e[Symbol.asyncIterator]) {
1137
1137
  yield* e;
1138
1138
  return;
@@ -1148,8 +1148,8 @@ const rt = (e) => {
1148
1148
  } finally {
1149
1149
  await t.cancel();
1150
1150
  }
1151
- }, De = (e, t, n, r) => {
1152
- const s = Un(e, t);
1151
+ }, Ue = (e, t, n, r) => {
1152
+ const s = Dn(e, t);
1153
1153
  let o = 0, i, c = (f) => {
1154
1154
  i || (i = !0, r && r(f));
1155
1155
  };
@@ -1220,7 +1220,7 @@ const jn = async (e) => {
1220
1220
  }, _n = async (e, t) => {
1221
1221
  const n = a.toFiniteNumber(e.getContentLength());
1222
1222
  return n ?? jn(t);
1223
- }, qn = te && (async (e) => {
1223
+ }, In = te && (async (e) => {
1224
1224
  let {
1225
1225
  url: t,
1226
1226
  method: n,
@@ -1253,7 +1253,7 @@ const jn = async (e) => {
1253
1253
  p,
1254
1254
  W(Fe(f))
1255
1255
  );
1256
- r = De(A.body, Le, k, L);
1256
+ r = Ue(A.body, Le, k, L);
1257
1257
  }
1258
1258
  }
1259
1259
  a.isString(m) || (m = m ? "include" : "omit");
@@ -1271,15 +1271,15 @@ const jn = async (e) => {
1271
1271
  const O = fe && (u === "stream" || u === "response");
1272
1272
  if (fe && (c || O && h)) {
1273
1273
  const A = {};
1274
- ["status", "statusText", "headers"].forEach((I) => {
1275
- A[I] = b[I];
1274
+ ["status", "statusText", "headers"].forEach((H) => {
1275
+ A[H] = b[H];
1276
1276
  });
1277
1277
  const P = a.toFiniteNumber(b.headers.get("content-length")), [k, L] = c && ke(
1278
1278
  P,
1279
1279
  W(Fe(c), !0)
1280
1280
  ) || [];
1281
1281
  b = new Response(
1282
- De(b.body, Le, k, () => {
1282
+ Ue(b.body, Le, k, () => {
1283
1283
  L && L(), h && h();
1284
1284
  }),
1285
1285
  A
@@ -1308,7 +1308,7 @@ const jn = async (e) => {
1308
1308
  }), de = {
1309
1309
  http: Qt,
1310
1310
  xhr: Nn,
1311
- fetch: qn
1311
+ fetch: In
1312
1312
  };
1313
1313
  a.forEach(de, (e, t) => {
1314
1314
  if (e) {
@@ -1319,7 +1319,7 @@ a.forEach(de, (e, t) => {
1319
1319
  Object.defineProperty(e, "adapterName", { value: t });
1320
1320
  }
1321
1321
  });
1322
- const Be = (e) => `- ${e}`, In = (e) => a.isFunction(e) || e === null || e === !1, it = {
1322
+ const Be = (e) => `- ${e}`, Hn = (e) => a.isFunction(e) || e === null || e === !1, it = {
1323
1323
  getAdapter: (e) => {
1324
1324
  e = a.isArray(e) ? e : [e];
1325
1325
  const { length: t } = e;
@@ -1328,7 +1328,7 @@ const Be = (e) => `- ${e}`, In = (e) => a.isFunction(e) || e === null || e === !
1328
1328
  for (let o = 0; o < t; o++) {
1329
1329
  n = e[o];
1330
1330
  let i;
1331
- if (r = n, !In(n) && (r = de[(i = String(n)).toLowerCase()], r === void 0))
1331
+ if (r = n, !Hn(n) && (r = de[(i = String(n)).toLowerCase()], r === void 0))
1332
1332
  throw new y(`Unknown adapter '${i}'`);
1333
1333
  if (r)
1334
1334
  break;
@@ -1352,7 +1352,7 @@ const Be = (e) => `- ${e}`, In = (e) => a.isFunction(e) || e === null || e === !
1352
1352
  };
1353
1353
  function ie(e) {
1354
1354
  if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
1355
- throw new q(null, e);
1355
+ throw new I(null, e);
1356
1356
  }
1357
1357
  function je(e) {
1358
1358
  return ie(e), e.headers = F.from(e.headers), e.data = oe.call(
@@ -1397,7 +1397,7 @@ Se.transitional = function(t, n, r) {
1397
1397
  )), t ? t(o, i, c) : !0;
1398
1398
  };
1399
1399
  };
1400
- function Hn(e, t, n) {
1400
+ function qn(e, t, n) {
1401
1401
  if (typeof e != "object")
1402
1402
  throw new y("options must be an object", y.ERR_BAD_OPTION_VALUE);
1403
1403
  const r = Object.keys(e);
@@ -1415,9 +1415,9 @@ function Hn(e, t, n) {
1415
1415
  }
1416
1416
  }
1417
1417
  const pe = {
1418
- assertOptions: Hn,
1418
+ assertOptions: qn,
1419
1419
  validators: Se
1420
- }, D = pe.validators;
1420
+ }, U = pe.validators;
1421
1421
  class G {
1422
1422
  constructor(t) {
1423
1423
  this.defaults = t, this.interceptors = {
@@ -1454,14 +1454,14 @@ class G {
1454
1454
  typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = j(this.defaults, n);
1455
1455
  const { transitional: r, paramsSerializer: s, headers: o } = n;
1456
1456
  r !== void 0 && pe.assertOptions(r, {
1457
- silentJSONParsing: D.transitional(D.boolean),
1458
- forcedJSONParsing: D.transitional(D.boolean),
1459
- clarifyTimeoutError: D.transitional(D.boolean)
1457
+ silentJSONParsing: U.transitional(U.boolean),
1458
+ forcedJSONParsing: U.transitional(U.boolean),
1459
+ clarifyTimeoutError: U.transitional(U.boolean)
1460
1460
  }, !1), s != null && (a.isFunction(s) ? n.paramsSerializer = {
1461
1461
  serialize: s
1462
1462
  } : pe.assertOptions(s, {
1463
- encode: D.function,
1464
- serialize: D.function
1463
+ encode: U.function,
1464
+ serialize: U.function
1465
1465
  }, !0)), n.method = (n.method || this.defaults.method || "get").toLowerCase();
1466
1466
  let i = o && a.merge(
1467
1467
  o.common,
@@ -1565,7 +1565,7 @@ class Re {
1565
1565
  r.unsubscribe(o);
1566
1566
  }, i;
1567
1567
  }, t(function(o, i, c) {
1568
- r.reason || (r.reason = new q(o, i, c), n(r.reason));
1568
+ r.reason || (r.reason = new I(o, i, c), n(r.reason));
1569
1569
  });
1570
1570
  }
1571
1571
  /**
@@ -1693,14 +1693,14 @@ Object.entries(he).forEach(([e, t]) => {
1693
1693
  });
1694
1694
  const Jn = he;
1695
1695
  function ct(e) {
1696
- const t = new V(e), n = Ie(V.prototype.request, t);
1696
+ const t = new V(e), n = He(V.prototype.request, t);
1697
1697
  return a.extend(n, V.prototype, t, { allOwnKeys: !0 }), a.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(s) {
1698
1698
  return ct(j(e, s));
1699
1699
  }, n;
1700
1700
  }
1701
1701
  const T = ct(Ee);
1702
1702
  T.Axios = V;
1703
- T.CanceledError = q;
1703
+ T.CanceledError = I;
1704
1704
  T.CancelToken = vn;
1705
1705
  T.isCancel = et;
1706
1706
  T.VERSION = at;
@@ -1815,7 +1815,7 @@ x(w, "keyCookie", "AuthCookie"), x(w, "cookieOptions", {}), x(w, "registerReques
1815
1815
  };
1816
1816
  if (window != null && window.cordova && ((S = (m = window == null ? void 0 : window.cordova) == null ? void 0 : m.plugin) != null && S.http)) {
1817
1817
  const { http: d } = (R = window == null ? void 0 : window.cordova) == null ? void 0 : R.plugin;
1818
- d.setDataSerializer("json"), d.setRequestTimeout(Number(c.timeout) / 1e3), w.registerRequest.setList({ url: t, options: c }), d.sendRequest(
1818
+ "Content-Type" in (c == null ? void 0 : c.headers) && ((c == null ? void 0 : c.headers["Content-Type"]) === "multipart/form-data" && d.setDataSerializer("urlencoded"), (c == null ? void 0 : c.headers["Content-Type"]) === "application/json" && d.setDataSerializer("json")), d.setRequestTimeout(Number(c.timeout) / 1e3), w.registerRequest.setList({ url: t, options: c }), d.sendRequest(
1819
1819
  t,
1820
1820
  c,
1821
1821
  (h) => {
@@ -1830,8 +1830,8 @@ x(w, "keyCookie", "AuthCookie"), x(w, "cookieOptions", {}), x(w, "registerReques
1830
1830
  message: ""
1831
1831
  };
1832
1832
  if (P) {
1833
- const L = JSON.parse(E.trim()), I = w.errorsHandler.getErrorMessageFromData(L);
1834
- k.message = I, k.data = L, p.msg = I;
1833
+ const L = JSON.parse(E.trim()), H = w.errorsHandler.getErrorMessageFromData(L);
1834
+ k.message = H, k.data = L, p.msg = H;
1835
1835
  } else
1836
1836
  typeof E == "string" && (k.message = E);
1837
1837
  s({ ...l, ...p, errExt: k });
@@ -1886,7 +1886,7 @@ x(w, "keyCookie", "AuthCookie"), x(w, "cookieOptions", {}), x(w, "registerReques
1886
1886
  }), x(w, "setCookieOptions", (t) => {
1887
1887
  w.cookieOptions = t;
1888
1888
  });
1889
- let qe = w;
1889
+ let Ie = w;
1890
1890
  export {
1891
- qe as apiRequest
1891
+ Ie as apiRequest
1892
1892
  };
@@ -0,0 +1,30 @@
1
+ import { NetworkStatusInfoTracker, OnStatusChange, NetworkConstructorConfig } from './NetworkStatusTracker.types';
2
+
3
+ export declare class NetworkStatusTracker {
4
+ private networkInfo;
5
+ private listUrls;
6
+ private state;
7
+ private setState;
8
+ private getState;
9
+ constructor(listUrls: string[]);
10
+ private getFetchOptions;
11
+ private getConnection;
12
+ private getIsNetwork;
13
+ private getTypeNetwork;
14
+ private updateState;
15
+ private controllersEvents;
16
+ private getControllersEvents;
17
+ private setControllersEvents;
18
+ startEvents(onStatusChange: OnStatusChange): void;
19
+ stopEvents(): void;
20
+ private requestByUrls;
21
+ private checkConnection;
22
+ private controllersFetching;
23
+ private getControllersMonitoring;
24
+ private setControllersMonitoring;
25
+ private startFetching;
26
+ private stopFetching;
27
+ checkStatus(onStatusChange?: OnStatusChange, config?: NetworkConstructorConfig): Promise<NetworkStatusInfoTracker>;
28
+ private fetchingNetwork;
29
+ getCurrentState(): NetworkStatusInfoTracker;
30
+ }
@@ -0,0 +1,158 @@
1
+ var v = Object.defineProperty;
2
+ var d = (r, t, e) => t in r ? v(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var s = (r, t, e) => (d(r, typeof t != "symbol" ? t + "" : t, e), e);
4
+ class p {
5
+ constructor(t) {
6
+ s(this, "networkInfo");
7
+ s(this, "listUrls", []);
8
+ s(this, "state", {
9
+ isActiveEvents: !1,
10
+ isMonitoring: !1,
11
+ checkIntervalId: null
12
+ });
13
+ s(this, "getFetchOptions", (t) => ({
14
+ method: "HEAD",
15
+ cache: "no-store",
16
+ signal: t.signal,
17
+ headers: {
18
+ "Cache-Control": "no-cache, no-store, must-revalidate",
19
+ Pragma: "no-cache",
20
+ Expires: "0"
21
+ }
22
+ }));
23
+ s(this, "getIsNetwork", (t) => !["unknown", "none"].includes(t));
24
+ s(this, "getTypeNetwork", ({ effectiveType: t, type: e }, n) => (n || n === null) && (t || e) || "none");
25
+ /*-----------------------------------------------------------------------------*/
26
+ s(this, "controllersEvents", {
27
+ online: null,
28
+ offline: null,
29
+ change: null
30
+ });
31
+ s(this, "controllersFetching", {
32
+ online: null,
33
+ offline: null,
34
+ change: null
35
+ });
36
+ this.listUrls = t;
37
+ const e = typeof navigator < "u" ? navigator.onLine : !1;
38
+ this.networkInfo = {
39
+ isNetwork: e,
40
+ typeNetwork: this.getTypeNetwork(this.getConnection(), e)
41
+ };
42
+ }
43
+ setState(t) {
44
+ this.state = { ...this.state, ...t };
45
+ }
46
+ getState() {
47
+ return this.state;
48
+ }
49
+ getConnection() {
50
+ var t;
51
+ return (t = window == null ? void 0 : window.navigator) == null ? void 0 : t.connection;
52
+ }
53
+ updateState(t, e) {
54
+ const n = {
55
+ isNetwork: t,
56
+ typeNetwork: this.getTypeNetwork(this.getConnection(), t)
57
+ };
58
+ this.networkInfo = n, typeof e == "function" && e(n);
59
+ }
60
+ getControllersEvents() {
61
+ return this.controllersEvents;
62
+ }
63
+ setControllersEvents(t) {
64
+ this.controllersEvents = { ...this.controllersEvents, ...t };
65
+ }
66
+ startEvents(t) {
67
+ var l, c, a, h;
68
+ const { isActiveEvents: e } = this.getState();
69
+ if (e)
70
+ return;
71
+ this.setState({ isActiveEvents: !0 });
72
+ const n = {
73
+ online: new AbortController(),
74
+ offline: new AbortController(),
75
+ change: new AbortController()
76
+ };
77
+ this.setControllersEvents(n);
78
+ const o = this.getConnection(), i = this.getTypeNetwork(o, window.navigator.onLine), g = this.getIsNetwork(i);
79
+ this.updateState(g, t), window.addEventListener("online", () => {
80
+ this.updateState(!0, t);
81
+ }, { signal: (l = n.online) == null ? void 0 : l.signal }), window.addEventListener("offline", () => {
82
+ this.updateState(!1, t);
83
+ }, { signal: (c = n.offline) == null ? void 0 : c.signal }), (a = this.getConnection()) != null && a.addEventListener && this.getConnection().addEventListener("change", () => {
84
+ const u = this.getConnection(), w = this.getTypeNetwork(u, null), f = this.getIsNetwork(w);
85
+ this.updateState(f, t);
86
+ }, { signal: (h = n.change) == null ? void 0 : h.signal });
87
+ }
88
+ stopEvents() {
89
+ const { isActiveEvents: t } = this.getState();
90
+ if (t) {
91
+ this.setState({ isActiveEvents: !1 });
92
+ const e = this.getControllersEvents();
93
+ for (const n of Object.values(e))
94
+ n == null || n.abort();
95
+ }
96
+ }
97
+ /*-----------------------------------------------------------------------------*/
98
+ async requestByUrls(t, e) {
99
+ const n = await this.checkConnection(e);
100
+ this.updateState(n, t);
101
+ }
102
+ async checkConnection(t = {}) {
103
+ for (const e of this.listUrls)
104
+ try {
105
+ const n = new AbortController(), o = setTimeout(() => n.abort(), (t == null ? void 0 : t.timeout) || 5e3), i = await window.fetch(e);
106
+ if (clearTimeout(o), i.status >= 200 && i.status < 400)
107
+ return !0;
108
+ } catch {
109
+ continue;
110
+ }
111
+ return !1;
112
+ }
113
+ getControllersMonitoring() {
114
+ return this.controllersFetching;
115
+ }
116
+ setControllersMonitoring(t) {
117
+ this.controllersFetching = { ...this.controllersFetching, ...t };
118
+ }
119
+ startFetching(t, { interval: e = 5e3 }) {
120
+ const { isMonitoring: n } = this.getState();
121
+ if (n)
122
+ return;
123
+ this.setState({ isMonitoring: !0 });
124
+ const o = {
125
+ online: new AbortController(),
126
+ offline: new AbortController(),
127
+ change: new AbortController()
128
+ };
129
+ this.setControllersMonitoring(o), this.requestByUrls(t, { timeout: 2e3 });
130
+ const i = window.setInterval(() => this.requestByUrls(t), e);
131
+ this.setState({ checkIntervalId: i });
132
+ }
133
+ stopFetching() {
134
+ const { isMonitoring: t, checkIntervalId: e } = this.getState();
135
+ if (!t)
136
+ return;
137
+ const n = this.getControllersMonitoring();
138
+ for (const o of Object.values(n))
139
+ o == null || o.abort();
140
+ e && clearInterval(e), this.setState({ isMonitoring: !1, checkIntervalId: null });
141
+ }
142
+ /*--------------------------------------------------------------------------------------------------*/
143
+ /*--------------------------------------------------------------------------------------------------*/
144
+ async checkStatus(t, e) {
145
+ return await this.requestByUrls(t), this.getCurrentState();
146
+ }
147
+ fetchingNetwork(t, e) {
148
+ return this.startFetching(t, e), {
149
+ stop: () => this.stopFetching()
150
+ };
151
+ }
152
+ getCurrentState() {
153
+ return this.networkInfo;
154
+ }
155
+ }
156
+ export {
157
+ p as NetworkStatusTracker
158
+ };
@@ -0,0 +1,22 @@
1
+ export interface NetworkInfoConnection {
2
+ downlink?: number;
3
+ effectiveType?: string;
4
+ rtt?: number;
5
+ saveData?: boolean;
6
+ type?: string;
7
+ }
8
+ export interface NetworkStatusInfoTracker {
9
+ isNetwork: boolean;
10
+ typeNetwork: string;
11
+ }
12
+ export interface NetworkStatusConfig {
13
+ interval?: number;
14
+ }
15
+ export interface NetworkConstructorConfig {
16
+ timeout?: number;
17
+ }
18
+ export type OnStatusChange = (info: NetworkStatusInfoTracker) => void;
19
+ export interface NetworkItemListTracker {
20
+ keyNameSystem: string;
21
+ getInfo: () => NetworkStatusInfoTracker;
22
+ }
package/dist/index.d.ts CHANGED
@@ -5,5 +5,6 @@ export * from './classes/File';
5
5
  export * from './classes/HTTPSApi';
6
6
  export * from './classes/Numbers';
7
7
  export * from './classes/Utils/Utils';
8
- export * from './classes/Utils/EventSubscribers';
8
+ export * from './classes/EventSubscribers';
9
+ export * from './classes/NetworkStatusTracker/NetworkStatusTracker';
9
10
  export * from './classes/Utils/NetworkInformation';
package/dist/index.js CHANGED
@@ -1,26 +1,28 @@
1
1
  import { Color as t } from "./classes/Color/Color.js";
2
2
  import { DateProcessing as m } from "./classes/DateProcessing/DateProcessing.js";
3
3
  import { DelaysPromise as p } from "./classes/DelaysPromise/DelaysPromise.js";
4
- import { File as i } from "./classes/File/File.js";
5
- import { HTTPSApi as s } from "./classes/HTTPSApi/HTTPSApi.js";
6
- import { Numbers as N } from "./classes/Numbers/Numbers.js";
7
- import { Utils as k } from "./classes/Utils/Utils.js";
8
- import { EventSubscribers as w } from "./classes/Utils/EventSubscribers/EventSubscribers.js";
9
- import { NetworkInformation as P } from "./classes/Utils/NetworkInformation/NetworkInformation.js";
10
- import { NetworkInformationPC as C } from "./classes/Utils/NetworkInformation/classes/NetworkInformationPC.js";
4
+ import { File as a } from "./classes/File/File.js";
5
+ import { HTTPSApi as n } from "./classes/HTTPSApi/HTTPSApi.js";
6
+ import { Numbers as k } from "./classes/Numbers/Numbers.js";
7
+ import { Utils as w } from "./classes/Utils/Utils.js";
8
+ import { EventSubscribers as c } from "./classes/EventSubscribers/EventSubscribers.js";
9
+ import { NetworkStatusTracker as I } from "./classes/NetworkStatusTracker/NetworkStatusTracker.js";
10
+ import { NetworkInformation as u } from "./classes/Utils/NetworkInformation/NetworkInformation.js";
11
+ import { NetworkInformationPC as S } from "./classes/Utils/NetworkInformation/classes/NetworkInformationPC.js";
11
12
  import { NetworkInformationAbstract as v } from "./classes/Utils/NetworkInformation/classes/types/types.abscruct.js";
12
13
  import { NetworkInformationCordova as D } from "./classes/Utils/NetworkInformation/classes/NetworkInformationCordova.js";
13
14
  export {
14
15
  t as Color,
15
16
  m as DateProcessing,
16
17
  p as DelaysPromise,
17
- w as EventSubscribers,
18
- i as File,
19
- s as HTTPSApi,
20
- P as NetworkInformation,
18
+ c as EventSubscribers,
19
+ a as File,
20
+ n as HTTPSApi,
21
+ u as NetworkInformation,
21
22
  v as NetworkInformationAbstract,
22
23
  D as NetworkInformationCordova,
23
- C as NetworkInformationPC,
24
- N as Numbers,
25
- k as Utils
24
+ S as NetworkInformationPC,
25
+ I as NetworkStatusTracker,
26
+ k as Numbers,
27
+ w as Utils
26
28
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "git+https://github.com/SinGlEBW/dev-classes.git"
12
12
  },
13
13
  "license": "MIT",
14
- "version": "1.4.1",
14
+ "version": "1.4.10",
15
15
  "type": "module",
16
16
  "module": "./dist/index.js",
17
17
  "main": "./dist/index.js",
@@ -1,33 +0,0 @@
1
- var c = Object.defineProperty;
2
- var u = (t, s, r) => s in t ? c(t, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[s] = r;
3
- var b = (t, s, r) => (u(t, typeof s != "symbol" ? s + "" : s, r), r);
4
- class h {
5
- constructor(s) {
6
- b(this, "subscribersEvents", {});
7
- b(this, "getListNameEvents", () => Object.keys(this.subscribersEvents));
8
- b(this, "getSubscribers", () => this.subscribersEvents);
9
- b(this, "subscribe", (s, r) => {
10
- var e;
11
- (e = this.subscribersEvents[s]) == null || e.push(r);
12
- });
13
- b(this, "unsubscribe", (s, r) => {
14
- var e;
15
- this.subscribersEvents[s] && (this.subscribersEvents[s] = (e = this.subscribersEvents[s]) == null ? void 0 : e.filter((i) => i !== r));
16
- });
17
- b(this, "publish", (s, r) => {
18
- var e;
19
- this.subscribersEvents[s] && ((e = this.subscribersEvents[s]) == null || e.forEach((i) => {
20
- i(r);
21
- }));
22
- });
23
- b(this, "resetSubscribers", () => {
24
- this.subscribersEvents = {};
25
- });
26
- s.forEach((r) => {
27
- this.subscribersEvents[r] = [];
28
- });
29
- }
30
- }
31
- export {
32
- h as EventSubscribers
33
- };