@endge/utils 0.26.0 → 0.26.1
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/updates/SSEManager.d.ts +1 -0
- package/dist/utils.js +150 -127
- package/package.json +1 -1
package/dist/utils.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var G = (r, t, e) => t in r ? V(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var o = (r, t, e) => G(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { Transform as
|
|
4
|
+
import { Transform as d, TransformationType as _, plainToInstance as b, instanceToPlain as T, Expose as J } from "class-transformer";
|
|
5
5
|
import { IsOptional as Z } from "class-validator";
|
|
6
6
|
import "reflect-metadata";
|
|
7
7
|
import { v4 as W } from "uuid";
|
|
8
8
|
import { DateTime as Y } from "ts-luxon";
|
|
9
|
-
import { differenceInSeconds as
|
|
10
|
-
import { utcToZonedTime as
|
|
9
|
+
import { differenceInSeconds as z, format as g, differenceInCalendarDays as q, isAfter as I, isEqual as Q, isBefore as P, startOfDay as p, endOfDay as X } from "date-fns";
|
|
10
|
+
import { utcToZonedTime as E, getTimezoneOffset as w, zonedTimeToUtc as v } from "date-fns-tz";
|
|
11
11
|
import { fetchEventSource as tt, EventStreamContentType as et } from "@microsoft/fetch-event-source";
|
|
12
12
|
var m = /* @__PURE__ */ ((r) => (r.Add = "add", r.Remove = "remove", r.Update = "update", r.IndexCreate = "indexCreate", r))(m || {});
|
|
13
|
-
class
|
|
13
|
+
class H {
|
|
14
14
|
/**
|
|
15
15
|
* Создает экземпляр EventBus и подготавливает базовое состояние.
|
|
16
16
|
*/
|
|
@@ -136,8 +136,8 @@ class P {
|
|
|
136
136
|
t ? (e = this._listeners.get(t)) == null || e.clear() : this._listeners.clear();
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
class
|
|
139
|
+
const wt = new H(Object.keys({}));
|
|
140
|
+
class U {
|
|
141
141
|
constructor() {
|
|
142
142
|
o(this, "_subscribers", /* @__PURE__ */ new Set());
|
|
143
143
|
}
|
|
@@ -153,7 +153,7 @@ class H {
|
|
|
153
153
|
t();
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
class
|
|
156
|
+
class xt extends U {
|
|
157
157
|
/**
|
|
158
158
|
* Создает экземпляр Collection и подготавливает базовое состояние.
|
|
159
159
|
*/
|
|
@@ -163,7 +163,7 @@ class wt extends H {
|
|
|
163
163
|
o(this, "_indices", /* @__PURE__ */ new Map());
|
|
164
164
|
o(this, "_rootIds", /* @__PURE__ */ new Set());
|
|
165
165
|
o(this, "_bus");
|
|
166
|
-
this._bus = new
|
|
166
|
+
this._bus = new H(Object.values(m)), e.length && this.add(e), this._createIndex("id");
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* Выполняет действие add в рамках ответственности Collection.
|
|
@@ -185,8 +185,8 @@ class wt extends H {
|
|
|
185
185
|
const a = typeof s == "string" ? s : s.id, l = this._items.findIndex((u) => u.id === a);
|
|
186
186
|
if (l !== -1) {
|
|
187
187
|
const [u] = this._items.splice(l, 1);
|
|
188
|
-
this._indices.forEach((c,
|
|
189
|
-
c.delete(u[
|
|
188
|
+
this._indices.forEach((c, f) => {
|
|
189
|
+
c.delete(u[f]);
|
|
190
190
|
}), u.parentId || this._rootIds.delete(u.id), i.push(u);
|
|
191
191
|
}
|
|
192
192
|
}), i.length && (this._bus.emit(m.Remove, i), this.notify());
|
|
@@ -591,7 +591,7 @@ class Et {
|
|
|
591
591
|
return await n.json().catch(() => ({}));
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
|
-
class
|
|
594
|
+
class Ct {
|
|
595
595
|
/**
|
|
596
596
|
* Создает экземпляр DelayedExecutor и подготавливает базовое состояние.
|
|
597
597
|
*/
|
|
@@ -631,14 +631,14 @@ class At {
|
|
|
631
631
|
this._delayTimer && clearTimeout(this._delayTimer), this._maxTimer && clearTimeout(this._maxTimer), this._delayTimer = null, this._maxTimer = null;
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function x(r) {
|
|
635
635
|
var t;
|
|
636
636
|
return r == null ? String(r) : typeof r == "string" ? `string(${r.length})` : typeof r != "object" ? `${typeof r}(${String(r)})` : Array.isArray(r) ? `Array(${r.length})` : r instanceof Map ? `Map(${r.size})` : r instanceof Set ? `Set(${r.size})` : ((t = r.constructor) == null ? void 0 : t.name) || "Object";
|
|
637
637
|
}
|
|
638
|
-
function
|
|
639
|
-
return r instanceof Error ? `${r.name}: ${r.message}` :
|
|
638
|
+
function D(r) {
|
|
639
|
+
return r instanceof Error ? `${r.name}: ${r.message}` : x(r);
|
|
640
640
|
}
|
|
641
|
-
class
|
|
641
|
+
class At {
|
|
642
642
|
/**
|
|
643
643
|
* Создает экземпляр NamedExecutor и подготавливает базовое состояние.
|
|
644
644
|
*/
|
|
@@ -675,7 +675,7 @@ class Ot {
|
|
|
675
675
|
const e = this._callbacks.get(t);
|
|
676
676
|
e && e();
|
|
677
677
|
} catch (e) {
|
|
678
|
-
console.error(`[NamedExecutor] flush error: ${
|
|
678
|
+
console.error(`[NamedExecutor] flush error: ${D(e)}`);
|
|
679
679
|
}
|
|
680
680
|
this._clear(t);
|
|
681
681
|
}
|
|
@@ -699,9 +699,9 @@ class Ot {
|
|
|
699
699
|
clearTimeout(this._delayTimers.get(t)), clearTimeout(this._maxTimers.get(t)), this._delayTimers.delete(t), this._maxTimers.delete(t), this._callbacks.delete(t), this._firstCallTime.delete(t);
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function Ot() {
|
|
703
703
|
return function(r, t) {
|
|
704
|
-
|
|
704
|
+
d(
|
|
705
705
|
({ value: e }) => {
|
|
706
706
|
if (typeof e == "string")
|
|
707
707
|
try {
|
|
@@ -712,7 +712,7 @@ function Ct() {
|
|
|
712
712
|
return e;
|
|
713
713
|
},
|
|
714
714
|
{ toClassOnly: !0 }
|
|
715
|
-
)(r, t),
|
|
715
|
+
)(r, t), d(
|
|
716
716
|
({ value: e }) => {
|
|
717
717
|
try {
|
|
718
718
|
return JSON.stringify(e);
|
|
@@ -726,7 +726,7 @@ function Ct() {
|
|
|
726
726
|
}
|
|
727
727
|
function Mt() {
|
|
728
728
|
return function(r, t) {
|
|
729
|
-
|
|
729
|
+
d(
|
|
730
730
|
({ value: e }) => {
|
|
731
731
|
if (e == null)
|
|
732
732
|
return "{}";
|
|
@@ -739,7 +739,7 @@ function Mt() {
|
|
|
739
739
|
return e;
|
|
740
740
|
},
|
|
741
741
|
{ toClassOnly: !0 }
|
|
742
|
-
)(r, t),
|
|
742
|
+
)(r, t), d(
|
|
743
743
|
({ value: e }) => {
|
|
744
744
|
if (!e)
|
|
745
745
|
return {};
|
|
@@ -768,19 +768,19 @@ function rt(r) {
|
|
|
768
768
|
);
|
|
769
769
|
return t ? r[t].bind(r) : null;
|
|
770
770
|
}
|
|
771
|
-
function
|
|
771
|
+
function kt() {
|
|
772
772
|
return function(r, t) {
|
|
773
|
-
|
|
773
|
+
d(
|
|
774
774
|
({ value: e }) => typeof e == "string" ? e.trim() : String(e ?? ""),
|
|
775
775
|
{ toClassOnly: !0 }
|
|
776
|
-
)(r, t),
|
|
776
|
+
)(r, t), d(
|
|
777
777
|
({ value: e }) => typeof e == "string" ? e : String(e ?? ""),
|
|
778
778
|
{ toPlainOnly: !0 }
|
|
779
779
|
)(r, t);
|
|
780
780
|
};
|
|
781
781
|
}
|
|
782
|
-
function
|
|
783
|
-
return
|
|
782
|
+
function Ft(r, t) {
|
|
783
|
+
return d(({ value: e, type: n }) => {
|
|
784
784
|
if (!e)
|
|
785
785
|
return /* @__PURE__ */ new Map();
|
|
786
786
|
if (n === _.PLAIN_TO_CLASS) {
|
|
@@ -802,13 +802,13 @@ function Lt(r, t) {
|
|
|
802
802
|
})
|
|
803
803
|
);
|
|
804
804
|
}
|
|
805
|
-
return console.warn(`[TypeMap] Expected object or array, got ${
|
|
805
|
+
return console.warn(`[TypeMap] Expected object or array, got ${x(e)}`), /* @__PURE__ */ new Map();
|
|
806
806
|
}
|
|
807
|
-
return n === _.CLASS_TO_PLAIN ? e instanceof Map ? Array.from(e.values()).map((i) => T(i)) : (console.warn(`[TypeMap] Expected Map, got ${
|
|
807
|
+
return n === _.CLASS_TO_PLAIN ? e instanceof Map ? Array.from(e.values()).map((i) => T(i)) : (console.warn(`[TypeMap] Expected Map, got ${x(e)}`), t ? [] : {}) : (console.warn(`[TypeMap] Unexpected transformation type: ${String(n)}`), e);
|
|
808
808
|
});
|
|
809
809
|
}
|
|
810
|
-
function
|
|
811
|
-
return
|
|
810
|
+
function Lt(r) {
|
|
811
|
+
return d(({ value: t, type: e }) => {
|
|
812
812
|
if (!t || typeof t != "object")
|
|
813
813
|
return {};
|
|
814
814
|
if (e === _.PLAIN_TO_CLASS) {
|
|
@@ -863,23 +863,23 @@ function Ht(r, t, e) {
|
|
|
863
863
|
}
|
|
864
864
|
function Ut(r) {
|
|
865
865
|
return function(t, e) {
|
|
866
|
-
|
|
866
|
+
d(({ value: n }) => n === null ? void 0 : n, { toPlainOnly: !0 })(t, e), Z(r)(t, e);
|
|
867
867
|
};
|
|
868
868
|
}
|
|
869
869
|
function Kt() {
|
|
870
|
-
return
|
|
870
|
+
return d(({ value: r, type: t }) => t === _.PLAIN_TO_CLASS ? r == null ? void 0 : r.id : r);
|
|
871
871
|
}
|
|
872
872
|
function Rt(r) {
|
|
873
|
-
return
|
|
873
|
+
return d(({ value: t, type: e }) => e === _.PLAIN_TO_CLASS ? t == null ? void 0 : t.map((n) => n == null ? void 0 : n[r]) : t);
|
|
874
874
|
}
|
|
875
875
|
function jt() {
|
|
876
|
-
return
|
|
876
|
+
return d(({ value: r, type: t }) => t === _.CLASS_TO_PLAIN && (r == null ? void 0 : r.id) || r);
|
|
877
877
|
}
|
|
878
878
|
function Bt() {
|
|
879
|
-
return
|
|
879
|
+
return d(({ value: r, type: t }) => t === _.CLASS_TO_PLAIN ? r.map((e) => e.id) : r);
|
|
880
880
|
}
|
|
881
881
|
function Vt() {
|
|
882
|
-
return
|
|
882
|
+
return d(({ value: r, type: t }) => t === _.CLASS_TO_PLAIN ? void 0 : r, { toPlainOnly: !0 });
|
|
883
883
|
}
|
|
884
884
|
function Gt(r, t) {
|
|
885
885
|
return b(r, t, {
|
|
@@ -902,11 +902,11 @@ const Yt = !1;
|
|
|
902
902
|
function qt(r, t) {
|
|
903
903
|
return t();
|
|
904
904
|
}
|
|
905
|
-
const Qt = () => W(),
|
|
905
|
+
const Qt = () => W(), $ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
906
906
|
function Xt(r) {
|
|
907
907
|
let t = "";
|
|
908
908
|
for (let e = 0; e < r; ++e)
|
|
909
|
-
t +=
|
|
909
|
+
t += $[Math.floor($.length * Math.random())];
|
|
910
910
|
return t;
|
|
911
911
|
}
|
|
912
912
|
class vt {
|
|
@@ -998,7 +998,7 @@ function te(r, t) {
|
|
|
998
998
|
return n && i && s && a && l;
|
|
999
999
|
}) : !1;
|
|
1000
1000
|
}
|
|
1001
|
-
const
|
|
1001
|
+
const k = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new Set([
|
|
1002
1002
|
"Alt",
|
|
1003
1003
|
"AltGraph",
|
|
1004
1004
|
"CapsLock",
|
|
@@ -1016,15 +1016,15 @@ const $ = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new Set([
|
|
|
1016
1016
|
"SymbolLock"
|
|
1017
1017
|
]);
|
|
1018
1018
|
function ee(r) {
|
|
1019
|
-
return
|
|
1019
|
+
return C(R(r).snapshot);
|
|
1020
1020
|
}
|
|
1021
1021
|
function re(r, t) {
|
|
1022
1022
|
const e = R(r);
|
|
1023
|
-
return e.subscribers.add(t), t(
|
|
1023
|
+
return e.subscribers.add(t), t(C(e.snapshot)), () => e.subscribers.delete(t);
|
|
1024
1024
|
}
|
|
1025
1025
|
function R(r) {
|
|
1026
1026
|
var a, l, u;
|
|
1027
|
-
const t =
|
|
1027
|
+
const t = k.get(r);
|
|
1028
1028
|
if (t)
|
|
1029
1029
|
return t;
|
|
1030
1030
|
const e = st((a = r.defaultView) == null ? void 0 : a.navigator), n = {
|
|
@@ -1032,17 +1032,17 @@ function R(r) {
|
|
|
1032
1032
|
entries: /* @__PURE__ */ new Map(),
|
|
1033
1033
|
subscribers: /* @__PURE__ */ new Set()
|
|
1034
1034
|
}, i = (c) => {
|
|
1035
|
-
var
|
|
1036
|
-
const
|
|
1035
|
+
var M;
|
|
1036
|
+
const f = c ? {
|
|
1037
1037
|
ctrl: c.ctrlKey,
|
|
1038
1038
|
shift: c.shiftKey,
|
|
1039
1039
|
alt: c.altKey,
|
|
1040
1040
|
meta: c.metaKey,
|
|
1041
1041
|
mod: e === "macos" ? c.metaKey : e === "windows" || e === "linux" ? c.ctrlKey : c.ctrlKey || c.metaKey,
|
|
1042
|
-
altGraph: ((
|
|
1042
|
+
altGraph: ((M = c.getModifierState) == null ? void 0 : M.call(c, "AltGraph")) === !0
|
|
1043
1043
|
} : F(e).modifiers, O = [...n.entries.values()], S = {
|
|
1044
1044
|
platform: e,
|
|
1045
|
-
modifiers:
|
|
1045
|
+
modifiers: f,
|
|
1046
1046
|
held: {
|
|
1047
1047
|
key: [...new Set(O.map((y) => y.key))].sort(),
|
|
1048
1048
|
code: [...new Set(O.map((y) => y.code).filter(Boolean))].sort()
|
|
@@ -1051,23 +1051,23 @@ function R(r) {
|
|
|
1051
1051
|
if (!ot(n.snapshot, S)) {
|
|
1052
1052
|
n.snapshot = S;
|
|
1053
1053
|
for (const y of n.subscribers)
|
|
1054
|
-
y(
|
|
1054
|
+
y(C(S));
|
|
1055
1055
|
}
|
|
1056
1056
|
}, s = () => {
|
|
1057
1057
|
n.entries.clear(), i();
|
|
1058
1058
|
};
|
|
1059
1059
|
return r.addEventListener("keydown", (c) => {
|
|
1060
1060
|
if (!it.has(c.key)) {
|
|
1061
|
-
const
|
|
1062
|
-
n.entries.set(c.code || `key:${
|
|
1061
|
+
const f = c.key.toLowerCase();
|
|
1062
|
+
n.entries.set(c.code || `key:${f}`, { key: f, code: c.code });
|
|
1063
1063
|
}
|
|
1064
1064
|
i(c);
|
|
1065
1065
|
}, !0), r.addEventListener("keyup", (c) => {
|
|
1066
|
-
const
|
|
1067
|
-
n.entries.delete(c.code || `key:${
|
|
1066
|
+
const f = c.key.toLowerCase();
|
|
1067
|
+
n.entries.delete(c.code || `key:${f}`), i(c);
|
|
1068
1068
|
}, !0), r.addEventListener("visibilitychange", () => {
|
|
1069
1069
|
r.visibilityState === "hidden" && s();
|
|
1070
|
-
}), (l = r.defaultView) == null || l.addEventListener("blur", s), (u = r.defaultView) == null || u.addEventListener("pagehide", s),
|
|
1070
|
+
}), (l = r.defaultView) == null || l.addEventListener("blur", s), (u = r.defaultView) == null || u.addEventListener("pagehide", s), k.set(r, n), n;
|
|
1071
1071
|
}
|
|
1072
1072
|
function F(r) {
|
|
1073
1073
|
return {
|
|
@@ -1094,14 +1094,14 @@ function ot(r, t) {
|
|
|
1094
1094
|
function L(r, t) {
|
|
1095
1095
|
return r.length === t.length && r.every((e, n) => e === t[n]);
|
|
1096
1096
|
}
|
|
1097
|
-
function
|
|
1097
|
+
function C(r) {
|
|
1098
1098
|
return {
|
|
1099
1099
|
platform: r.platform,
|
|
1100
1100
|
modifiers: { ...r.modifiers },
|
|
1101
1101
|
held: { key: [...r.held.key], code: [...r.held.code] }
|
|
1102
1102
|
};
|
|
1103
1103
|
}
|
|
1104
|
-
class ne extends
|
|
1104
|
+
class ne extends U {
|
|
1105
1105
|
constructor() {
|
|
1106
1106
|
super(...arguments);
|
|
1107
1107
|
/** Массив всех логов */
|
|
@@ -1305,14 +1305,14 @@ function ae(r) {
|
|
|
1305
1305
|
return String(r).charAt(0).toUpperCase() + String(r).slice(1);
|
|
1306
1306
|
}
|
|
1307
1307
|
function ce(r, t) {
|
|
1308
|
-
return
|
|
1308
|
+
return I(r, t) || Q(r, t);
|
|
1309
1309
|
}
|
|
1310
1310
|
function le(r, t, e, n) {
|
|
1311
1311
|
const i = p(r), s = p(t), a = p(e), l = p(n);
|
|
1312
|
-
return !
|
|
1312
|
+
return !P(s, a) && !I(i, l);
|
|
1313
1313
|
}
|
|
1314
1314
|
function ue(r, t, e) {
|
|
1315
|
-
return !
|
|
1315
|
+
return !P(r, p(t)) && !I(r, X(e));
|
|
1316
1316
|
}
|
|
1317
1317
|
const fe = (r) => r && new Date(r);
|
|
1318
1318
|
function de(r, t = "HH:mm dd.MM.yyyy", e = {}) {
|
|
@@ -1328,7 +1328,7 @@ function ut(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
|
|
|
1328
1328
|
return "";
|
|
1329
1329
|
} else
|
|
1330
1330
|
r = new Date(r.toString());
|
|
1331
|
-
return n ? g(r, t, e) : g(
|
|
1331
|
+
return n ? g(r, t, e) : g(E(r, "utc"), t, e);
|
|
1332
1332
|
}
|
|
1333
1333
|
function he(r) {
|
|
1334
1334
|
const t = { weekday: "short" }, e = new Intl.DateTimeFormat("ru-RU", t).format(r);
|
|
@@ -1349,18 +1349,18 @@ function ye(r) {
|
|
|
1349
1349
|
};
|
|
1350
1350
|
}
|
|
1351
1351
|
function pe(r, t) {
|
|
1352
|
-
const e =
|
|
1353
|
-
return n || i ? `${e > 0 ? "-" : "+"}${
|
|
1352
|
+
const e = z(r, t), { hours: n, minutes: i } = A(e);
|
|
1353
|
+
return n || i ? `${e > 0 ? "-" : "+"}${h(n)}:${h(i)}` : "";
|
|
1354
1354
|
}
|
|
1355
1355
|
function ge(r, t) {
|
|
1356
|
-
const e =
|
|
1357
|
-
return n || i ? `${e > 0 ? "-" : ""}${
|
|
1356
|
+
const e = z(r, t), { hours: n, minutes: i } = A(e);
|
|
1357
|
+
return n || i ? `${e > 0 ? "-" : ""}${h(n)}:${h(i)}` : "";
|
|
1358
1358
|
}
|
|
1359
|
-
function
|
|
1359
|
+
function N(r = /* @__PURE__ */ new Date()) {
|
|
1360
1360
|
return new Date(r.getFullYear(), r.getMonth(), r.getDate());
|
|
1361
1361
|
}
|
|
1362
1362
|
function be(r, t) {
|
|
1363
|
-
const e = q(
|
|
1363
|
+
const e = q(N(r), N(t));
|
|
1364
1364
|
return e ? e > 7 ? {
|
|
1365
1365
|
variant: "red",
|
|
1366
1366
|
value: ">7"
|
|
@@ -1388,24 +1388,24 @@ function Se(r) {
|
|
|
1388
1388
|
return null;
|
|
1389
1389
|
const e = t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/);
|
|
1390
1390
|
if (e) {
|
|
1391
|
-
const i = Number(e[1]), s = Number(e[2]) - 1, a = Number(e[3]), l = Number(e[4]), u = Number(e[5]), c = e[6] != null ? Number(e[6]) : 0,
|
|
1392
|
-
return Number.isNaN(
|
|
1391
|
+
const i = Number(e[1]), s = Number(e[2]) - 1, a = Number(e[3]), l = Number(e[4]), u = Number(e[5]), c = e[6] != null ? Number(e[6]) : 0, f = new Date(i, s, a, l, u, c, 0);
|
|
1392
|
+
return Number.isNaN(f.getTime()) ? null : f.toISOString();
|
|
1393
1393
|
}
|
|
1394
1394
|
const n = new Date(t);
|
|
1395
1395
|
return Number.isNaN(n.getTime()) ? null : n.toISOString();
|
|
1396
1396
|
}
|
|
1397
|
-
function
|
|
1397
|
+
function we(r) {
|
|
1398
1398
|
const t = String(r ?? "").trim();
|
|
1399
1399
|
return t ? t.slice(0, 10) : "";
|
|
1400
1400
|
}
|
|
1401
|
-
function
|
|
1401
|
+
function xe(r) {
|
|
1402
1402
|
const t = String(r ?? "").trim();
|
|
1403
1403
|
if (!t)
|
|
1404
1404
|
return "";
|
|
1405
1405
|
const e = new Date(t);
|
|
1406
1406
|
if (Number.isNaN(e.getTime()))
|
|
1407
1407
|
return t.slice(0, 16);
|
|
1408
|
-
const n = e.getFullYear(), i =
|
|
1408
|
+
const n = e.getFullYear(), i = h(e.getMonth() + 1), s = h(e.getDate()), a = h(e.getHours()), l = h(e.getMinutes());
|
|
1409
1409
|
return `${n}-${i}-${s}T${a}:${l}`;
|
|
1410
1410
|
}
|
|
1411
1411
|
function De(r, t) {
|
|
@@ -1415,8 +1415,8 @@ function De(r, t) {
|
|
|
1415
1415
|
const n = new Date(String(r ?? "").trim());
|
|
1416
1416
|
if (Number.isNaN(n.getTime()))
|
|
1417
1417
|
return "";
|
|
1418
|
-
const i = B(t), s = i ?
|
|
1419
|
-
return `${
|
|
1418
|
+
const i = B(t), s = i ? E(n, i) : n;
|
|
1419
|
+
return `${h(s.getHours())}:${h(s.getMinutes())}`;
|
|
1420
1420
|
}
|
|
1421
1421
|
function Ie(r, t, e) {
|
|
1422
1422
|
const n = j(t).match(/^(\d{2}):(\d{2})$/);
|
|
@@ -1431,7 +1431,7 @@ function Ie(r, t, e) {
|
|
|
1431
1431
|
const l = B(e);
|
|
1432
1432
|
if (!l)
|
|
1433
1433
|
return i.setHours(s, a, 0, 0), i.toISOString();
|
|
1434
|
-
const u =
|
|
1434
|
+
const u = E(i, l);
|
|
1435
1435
|
return u.setHours(s, a, 0, 0), v(u, l).toISOString();
|
|
1436
1436
|
}
|
|
1437
1437
|
function j(r) {
|
|
@@ -1468,11 +1468,11 @@ function Ee(r) {
|
|
|
1468
1468
|
const n = t.match(/^(\d{2}):(\d{2})$/);
|
|
1469
1469
|
return n ? `${n[1]}:${n[2]}:00` : null;
|
|
1470
1470
|
}
|
|
1471
|
-
function
|
|
1471
|
+
function Ce(r) {
|
|
1472
1472
|
const t = dt(r), e = Math.sign(t) >= 0 ? "" : "-", { hours: n, minutes: i } = A(t);
|
|
1473
|
-
return `${e}${
|
|
1473
|
+
return `${e}${h(n)}:${h(i)}`;
|
|
1474
1474
|
}
|
|
1475
|
-
function
|
|
1475
|
+
function Ae(r = null, t = "dd", e = {}) {
|
|
1476
1476
|
const n = ft(r);
|
|
1477
1477
|
if (!n)
|
|
1478
1478
|
return "";
|
|
@@ -1506,15 +1506,15 @@ function dt(r) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
return 0;
|
|
1508
1508
|
}
|
|
1509
|
-
function
|
|
1509
|
+
function h(r) {
|
|
1510
1510
|
return String(r).padStart(2, "0");
|
|
1511
1511
|
}
|
|
1512
|
-
function
|
|
1512
|
+
function Oe(r) {
|
|
1513
1513
|
const t = /* @__PURE__ */ new Date();
|
|
1514
1514
|
try {
|
|
1515
|
-
const e =
|
|
1515
|
+
const e = w(r, t), n = Intl.supportedValuesOf("timeZone");
|
|
1516
1516
|
for (const i of n)
|
|
1517
|
-
if (
|
|
1517
|
+
if (w(i, t) === e)
|
|
1518
1518
|
return i;
|
|
1519
1519
|
} catch {
|
|
1520
1520
|
return null;
|
|
@@ -1522,7 +1522,7 @@ function Ce(r) {
|
|
|
1522
1522
|
return null;
|
|
1523
1523
|
}
|
|
1524
1524
|
function Me(r) {
|
|
1525
|
-
return
|
|
1525
|
+
return w(r, /* @__PURE__ */ new Date());
|
|
1526
1526
|
}
|
|
1527
1527
|
class $e {
|
|
1528
1528
|
constructor(t) {
|
|
@@ -1535,14 +1535,23 @@ class $e {
|
|
|
1535
1535
|
this._url = t.url, this._retryInterval = t.retryInterval ?? 3e3, this._options = t;
|
|
1536
1536
|
}
|
|
1537
1537
|
start() {
|
|
1538
|
-
|
|
1538
|
+
if (this._abortController)
|
|
1539
|
+
return;
|
|
1540
|
+
const t = new AbortController();
|
|
1541
|
+
this._abortController = t, this._connect(t);
|
|
1539
1542
|
}
|
|
1540
1543
|
stop() {
|
|
1541
|
-
|
|
1542
|
-
|
|
1544
|
+
this._clearReconnect(), this._isConnected = !1;
|
|
1545
|
+
const t = this._abortController;
|
|
1546
|
+
this._abortController = null, t == null || t.abort();
|
|
1547
|
+
}
|
|
1548
|
+
_isCurrent(t) {
|
|
1549
|
+
return this._abortController === t && !t.signal.aborted;
|
|
1543
1550
|
}
|
|
1544
|
-
_scheduleReconnect() {
|
|
1545
|
-
this._clearReconnect(), this._reconnectTimeout = setTimeout(() =>
|
|
1551
|
+
_scheduleReconnect(t) {
|
|
1552
|
+
this._isCurrent(t) && (this._clearReconnect(), this._reconnectTimeout = setTimeout(() => {
|
|
1553
|
+
this._isCurrent(t) && (this.stop(), this.start());
|
|
1554
|
+
}, this._retryInterval));
|
|
1546
1555
|
}
|
|
1547
1556
|
_clearReconnect() {
|
|
1548
1557
|
this._reconnectTimeout && (clearTimeout(this._reconnectTimeout), this._reconnectTimeout = null);
|
|
@@ -1552,48 +1561,62 @@ class $e {
|
|
|
1552
1561
|
const t = { ...this._options.headers }, e = await ((i = (n = this._options).getToken) == null ? void 0 : i.call(n));
|
|
1553
1562
|
return e && (t.Authorization = `Bearer ${e}`), t;
|
|
1554
1563
|
}
|
|
1555
|
-
async _connect() {
|
|
1556
|
-
var
|
|
1564
|
+
async _connect(t) {
|
|
1565
|
+
var e, n;
|
|
1557
1566
|
try {
|
|
1567
|
+
const i = await this._buildHeaders();
|
|
1568
|
+
if (!this._isCurrent(t))
|
|
1569
|
+
return;
|
|
1558
1570
|
await tt(this._url, {
|
|
1559
1571
|
method: "GET",
|
|
1560
|
-
headers:
|
|
1561
|
-
signal:
|
|
1572
|
+
headers: i,
|
|
1573
|
+
signal: t.signal,
|
|
1562
1574
|
openWhenHidden: !0,
|
|
1563
|
-
onopen: async (
|
|
1564
|
-
var
|
|
1565
|
-
if (
|
|
1566
|
-
|
|
1575
|
+
onopen: async (s) => {
|
|
1576
|
+
var l, u, c, f;
|
|
1577
|
+
if (!this._isCurrent(t))
|
|
1578
|
+
throw new Error("[SSEManager] Connection was stopped.");
|
|
1579
|
+
if (s.ok && ((u = (l = s.headers.get("content-type")) == null ? void 0 : l.split(";")[0]) == null ? void 0 : u.trim()) === et) {
|
|
1580
|
+
this._isConnected = !0, (f = (c = this._options).onOpen) == null || f.call(c);
|
|
1567
1581
|
return;
|
|
1568
1582
|
}
|
|
1569
|
-
throw new Error(`Unexpected response: ${
|
|
1583
|
+
throw new Error(`Unexpected response: ${s.status}`);
|
|
1570
1584
|
},
|
|
1571
|
-
onmessage: (
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1585
|
+
onmessage: (s) => {
|
|
1586
|
+
if (this._isCurrent(t))
|
|
1587
|
+
try {
|
|
1588
|
+
this._options.onEvent(JSON.parse(s.data));
|
|
1589
|
+
} catch (a) {
|
|
1590
|
+
console.warn(`[SSEManager] Failed to parse message: ${D(a)}`);
|
|
1591
|
+
}
|
|
1577
1592
|
},
|
|
1578
1593
|
onclose: () => {
|
|
1579
|
-
var i, s;
|
|
1580
|
-
this._isConnected = !1, (s = (i = this._options).onClose) == null || s.call(i), this._scheduleReconnect();
|
|
1581
|
-
},
|
|
1582
|
-
onerror: (i) => {
|
|
1583
1594
|
var s, a;
|
|
1584
|
-
this._isConnected = !1, (a = (s = this._options).
|
|
1595
|
+
this._isCurrent(t) && (this._isConnected = !1, (a = (s = this._options).onClose) == null || a.call(s));
|
|
1596
|
+
},
|
|
1597
|
+
// Retry belongs to this manager. Throwing disables the library's retry loop.
|
|
1598
|
+
onerror: (s) => {
|
|
1599
|
+
throw s;
|
|
1585
1600
|
}
|
|
1586
1601
|
});
|
|
1587
1602
|
} catch (i) {
|
|
1588
|
-
|
|
1589
|
-
|
|
1603
|
+
if (this._isCurrent(t)) {
|
|
1604
|
+
this._isConnected = !1;
|
|
1605
|
+
try {
|
|
1606
|
+
(n = (e = this._options).onError) == null || n.call(e, i instanceof Error ? i : new Error(String(i)));
|
|
1607
|
+
} catch (s) {
|
|
1608
|
+
console.warn(`[SSEManager] Error callback failed: ${D(s)}`);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
} finally {
|
|
1612
|
+
this._isCurrent(t) && (this._isConnected = !1, this._scheduleReconnect(t));
|
|
1590
1613
|
}
|
|
1591
1614
|
}
|
|
1592
1615
|
get isConnected() {
|
|
1593
1616
|
return this._isConnected;
|
|
1594
1617
|
}
|
|
1595
1618
|
}
|
|
1596
|
-
class
|
|
1619
|
+
class ke {
|
|
1597
1620
|
constructor() {
|
|
1598
1621
|
o(this, "_currentCount", 0);
|
|
1599
1622
|
o(this, "_lastResetTime", Date.now());
|
|
@@ -1612,13 +1635,13 @@ class Fe {
|
|
|
1612
1635
|
}
|
|
1613
1636
|
export {
|
|
1614
1637
|
Ht as AfterDeserialize,
|
|
1615
|
-
|
|
1638
|
+
wt as AppBus,
|
|
1616
1639
|
Pt as BeforeSerialize,
|
|
1617
|
-
|
|
1618
|
-
|
|
1640
|
+
xt as Collection,
|
|
1641
|
+
Ct as DelayedExecutor,
|
|
1619
1642
|
Rt as DeserializeArrayField,
|
|
1620
1643
|
Kt as DeserializeId,
|
|
1621
|
-
|
|
1644
|
+
H as EventBus,
|
|
1622
1645
|
m as Events,
|
|
1623
1646
|
zt as GenericExpose,
|
|
1624
1647
|
vt as HotkeyManager,
|
|
@@ -1626,26 +1649,26 @@ export {
|
|
|
1626
1649
|
Vt as IgnoreToPlain,
|
|
1627
1650
|
Dt as IndexedCollection,
|
|
1628
1651
|
Ut as IsOptionalTransformed,
|
|
1629
|
-
|
|
1652
|
+
Ot as Json,
|
|
1630
1653
|
Mt as JsonString,
|
|
1631
|
-
|
|
1654
|
+
At as NamedExecutor,
|
|
1632
1655
|
Et as PayloadHttpClient,
|
|
1633
1656
|
It as RingBuffer,
|
|
1634
1657
|
$e as SSEManager,
|
|
1635
|
-
|
|
1658
|
+
kt as Script,
|
|
1636
1659
|
Nt as Serialize,
|
|
1637
1660
|
jt as SerializeId,
|
|
1638
1661
|
Bt as SerializeIds,
|
|
1639
1662
|
ne as StructuredLogger,
|
|
1640
|
-
|
|
1663
|
+
U as Subscribable,
|
|
1641
1664
|
lt as SystemClock,
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1665
|
+
Ft as TypeMap,
|
|
1666
|
+
Lt as TypeRecord,
|
|
1667
|
+
ke as UPSMeter_Service,
|
|
1645
1668
|
ae as capitalize,
|
|
1646
1669
|
Wt as compareNumber,
|
|
1647
|
-
|
|
1648
|
-
|
|
1670
|
+
D as consoleErrorSummary,
|
|
1671
|
+
x as consoleValueSummary,
|
|
1649
1672
|
ie as createInstance,
|
|
1650
1673
|
pe as diffDuration,
|
|
1651
1674
|
ge as diffDurationTable,
|
|
@@ -1655,7 +1678,7 @@ export {
|
|
|
1655
1678
|
_e as formatDateToMSK,
|
|
1656
1679
|
de as formatDatetime,
|
|
1657
1680
|
ut as formatDatetimeTZ,
|
|
1658
|
-
|
|
1681
|
+
Ae as formatDatetimeTZSpecial,
|
|
1659
1682
|
Qt as generateUUID,
|
|
1660
1683
|
be as getDateOnlyDiffFactor,
|
|
1661
1684
|
he as getDayOfWeek,
|
|
@@ -1670,16 +1693,16 @@ export {
|
|
|
1670
1693
|
le as isDateRangeOverlap,
|
|
1671
1694
|
Zt as isNullOrUndefined,
|
|
1672
1695
|
De as isoDateTimeToTimeInput,
|
|
1673
|
-
|
|
1674
|
-
|
|
1696
|
+
we as isoToDateInput,
|
|
1697
|
+
xe as isoToDateTimeLocalInput,
|
|
1675
1698
|
Ie as mergeTimeIntoDateTime,
|
|
1676
1699
|
$t as onDeserialized,
|
|
1677
1700
|
fe as parseDate,
|
|
1678
|
-
|
|
1679
|
-
|
|
1701
|
+
Ce as parseDuration,
|
|
1702
|
+
Oe as parseOffsetToTimezone,
|
|
1680
1703
|
qt as profile,
|
|
1681
1704
|
Xt as randomString,
|
|
1682
|
-
|
|
1705
|
+
N as removeTime,
|
|
1683
1706
|
re as subscribeKeyboardState,
|
|
1684
1707
|
j as timeToTimeInput,
|
|
1685
1708
|
Gt as toInstance,
|