@endge/utils 0.24.6 → 0.24.8

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/index.d.ts CHANGED
@@ -113,6 +113,12 @@ export declare type CollectionOptions<T extends IndexCollectionEntity<ID>, ID =
113
113
 
114
114
  export declare function compareNumber(a: any, b: any): number;
115
115
 
116
+ /** Returns Error metadata as text without forwarding the Error object to Console. */
117
+ export declare function consoleErrorSummary(error: unknown): string;
118
+
119
+ /** Returns a bounded string without traversing or retaining the supplied value. */
120
+ export declare function consoleValueSummary(value: unknown): string;
121
+
116
122
  /**
117
123
  * Тип конструктора для класса.
118
124
  * Используется, например, в DI-контейнерах или фабриках.
package/dist/utils.js CHANGED
@@ -1,36 +1,36 @@
1
- var L = Object.defineProperty;
2
- var k = (r, t, e) => t in r ? L(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var o = (r, t, e) => k(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { ref as y, watch as O, triggerRef as A, onScopeDispose as P, reactive as z } from "vue";
5
- import { parse as R, serialize as I } from "cookie-es";
6
- import { destr as H } from "destr";
7
- import { plainToInstance as b, instanceToPlain as S, Transform as u, TransformationType as d, Expose as U } from "class-transformer";
8
- import { IsOptional as j } from "class-validator";
1
+ var z = Object.defineProperty;
2
+ var P = (r, t, e) => t in r ? z(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var o = (r, t, e) => P(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ref as g, watch as C, triggerRef as $, onScopeDispose as R, reactive as H } from "vue";
5
+ import { parse as U, serialize as E } from "cookie-es";
6
+ import { destr as j } from "destr";
7
+ import { plainToInstance as S, instanceToPlain as _, Transform as f, TransformationType as d, Expose as B } from "class-transformer";
8
+ import { IsOptional as J } from "class-validator";
9
9
  import "reflect-metadata";
10
- import B from "lodash/debounce.js";
11
- import { v4 as J } from "uuid";
12
- import { DateTime as v } from "ts-luxon";
13
- import { differenceInSeconds as C, format as T, differenceInCalendarDays as K, isAfter as x, isEqual as Z, isBefore as F, startOfDay as p, endOfDay as V } from "date-fns";
14
- import { utcToZonedTime as G, getTimezoneOffset as _ } from "date-fns-tz";
15
- import { fetchEventSource as W, EventStreamContentType as Y } from "@microsoft/fetch-event-source";
16
- import { defineStore as q } from "pinia";
17
- const Q = {
10
+ import K from "lodash/debounce.js";
11
+ import { v4 as V } from "uuid";
12
+ import { DateTime as Z } from "ts-luxon";
13
+ import { differenceInSeconds as M, format as T, differenceInCalendarDays as G, isAfter as D, isEqual as W, isBefore as F, startOfDay as p, endOfDay as Y } from "date-fns";
14
+ import { utcToZonedTime as q, getTimezoneOffset as x } from "date-fns-tz";
15
+ import { fetchEventSource as Q, EventStreamContentType as X } from "@microsoft/fetch-event-source";
16
+ import { defineStore as v } from "pinia";
17
+ const tt = {
18
18
  path: "/",
19
19
  watch: !0,
20
- decode: (r) => H(decodeURIComponent(r)),
20
+ decode: (r) => j(decodeURIComponent(r)),
21
21
  encode: (r) => encodeURIComponent(typeof r == "string" ? r : JSON.stringify(r))
22
- }, wt = (r, t) => {
22
+ }, It = (r, t) => {
23
23
  var s;
24
- const e = { ...Q, ...t || {} }, n = R(document.cookie, e), i = y(n[r] ?? ((s = e.default) == null ? void 0 : s.call(e)));
25
- return O(i, () => {
26
- document.cookie = X(r, i.value, e);
24
+ const e = { ...tt, ...t || {} }, n = U(document.cookie, e), i = g(n[r] ?? ((s = e.default) == null ? void 0 : s.call(e)));
25
+ return C(i, () => {
26
+ document.cookie = et(r, i.value, e);
27
27
  }), i;
28
28
  };
29
- function X(r, t, e = {}) {
30
- return t == null ? I(r, t, { ...e, maxAge: -1 }) : I(r, t, e);
29
+ function et(r, t, e = {}) {
30
+ return t == null ? E(r, t, { ...e, maxAge: -1 }) : E(r, t, e);
31
31
  }
32
32
  var m = /* @__PURE__ */ ((r) => (r.Add = "add", r.Remove = "remove", r.Update = "update", r.IndexCreate = "indexCreate", r))(m || {});
33
- class M {
33
+ class N {
34
34
  /**
35
35
  * Создает экземпляр EventBus и подготавливает базовое состояние.
36
36
  */
@@ -156,8 +156,8 @@ class M {
156
156
  t ? (e = this.listeners.get(t)) == null || e.clear() : this.listeners.clear();
157
157
  }
158
158
  }
159
- const It = new M(Object.keys({}));
160
- class N {
159
+ const Et = new N(Object.keys({}));
160
+ class L {
161
161
  constructor() {
162
162
  o(this, "subscribers", /* @__PURE__ */ new Set());
163
163
  }
@@ -178,18 +178,18 @@ class N {
178
178
  this.subscribers.forEach((t) => t());
179
179
  }
180
180
  }
181
- const Dt = (r) => {
182
- const t = y(r), e = r.subscribe(() => {
183
- A(t);
181
+ const At = (r) => {
182
+ const t = g(r), e = r.subscribe(() => {
183
+ $(t);
184
184
  });
185
185
  return { refObj: t, unsubscribe: e };
186
- }, Et = (r) => {
187
- const t = y(r), e = r.subscribe(() => A(t));
188
- return P(() => {
186
+ }, Ot = (r) => {
187
+ const t = g(r), e = r.subscribe(() => $(t));
188
+ return R(() => {
189
189
  e();
190
190
  }), t;
191
191
  };
192
- class Ot extends N {
192
+ class Ct extends L {
193
193
  /**
194
194
  * Создает экземпляр Collection и подготавливает базовое состояние.
195
195
  */
@@ -199,7 +199,7 @@ class Ot extends N {
199
199
  o(this, "indices", /* @__PURE__ */ new Map());
200
200
  o(this, "rootIds", /* @__PURE__ */ new Set());
201
201
  o(this, "bus");
202
- this.bus = new M(Object.values(m)), e.length && this.add(e), this.createIndex("id");
202
+ this.bus = new N(Object.values(m)), e.length && this.add(e), this.createIndex("id");
203
203
  }
204
204
  /**
205
205
  * Выполняет действие add в рамках ответственности Collection.
@@ -221,8 +221,8 @@ class Ot extends N {
221
221
  const a = typeof s == "string" ? s : s.id, l = this.items.findIndex((c) => c.id === a);
222
222
  if (l !== -1) {
223
223
  const [c] = this.items.splice(l, 1);
224
- this.indices.forEach((f, g) => {
225
- f.delete(c[g]);
224
+ this.indices.forEach((u, y) => {
225
+ u.delete(c[y]);
226
226
  }), c.parentId || this.rootIds.delete(c.id), i.push(c);
227
227
  }
228
228
  }), i.length && (this.bus.emit(m.Remove, i), this.notify());
@@ -286,7 +286,7 @@ class Ot extends N {
286
286
  this.bus.off(e, n);
287
287
  }
288
288
  }
289
- class At {
289
+ class $t {
290
290
  /**
291
291
  * Создает экземпляр IndexedCollection и подготавливает базовое состояние.
292
292
  */
@@ -516,7 +516,7 @@ class At {
516
516
  this.list.pop(), this.indexById.delete(t);
517
517
  }
518
518
  }
519
- class Ct {
519
+ class Mt {
520
520
  constructor(t) {
521
521
  o(this, "_cap");
522
522
  o(this, "_buf");
@@ -619,7 +619,7 @@ class Ft {
619
619
  return await n.json().catch(() => ({}));
620
620
  }
621
621
  }
622
- class Mt {
622
+ class Nt {
623
623
  /**
624
624
  * Создает экземпляр DelayedExecutor и подготавливает базовое состояние.
625
625
  */
@@ -659,7 +659,14 @@ class Mt {
659
659
  this.delayTimer && clearTimeout(this.delayTimer), this.maxTimer && clearTimeout(this.maxTimer), this.delayTimer = null, this.maxTimer = null;
660
660
  }
661
661
  }
662
- class Nt {
662
+ function w(r) {
663
+ var t;
664
+ 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";
665
+ }
666
+ function b(r) {
667
+ return r instanceof Error ? `${r.name}: ${r.message}` : w(r);
668
+ }
669
+ class Lt {
663
670
  /**
664
671
  * Создает экземпляр NamedExecutor и подготавливает базовое состояние.
665
672
  */
@@ -696,7 +703,7 @@ class Nt {
696
703
  const e = this.callbacks.get(t);
697
704
  e && e();
698
705
  } catch (e) {
699
- console.error("[NamedExecutor] flush error:", e);
706
+ console.error(`[NamedExecutor] flush error: ${b(e)}`);
700
707
  }
701
708
  this.clear(t);
702
709
  }
@@ -720,73 +727,73 @@ class Nt {
720
727
  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);
721
728
  }
722
729
  }
723
- function $t(r, t) {
724
- return b(r, t, {
730
+ function kt(r, t) {
731
+ return S(r, t, {
725
732
  exposeDefaultValues: !0,
726
733
  excludeExtraneousValues: !0
727
734
  });
728
735
  }
729
- function Lt(r) {
730
- return S(r, {
736
+ function zt(r) {
737
+ return _(r, {
731
738
  exposeUnsetFields: !1
732
739
  });
733
740
  }
734
- function kt(r) {
741
+ function Pt(r) {
735
742
  return function(t, e) {
736
- U(r)(t, e), Reflect.defineMetadata("genericExpose", r.name, t, e);
743
+ B(r)(t, e), Reflect.defineMetadata("genericExpose", r.name, t, e);
737
744
  };
738
745
  }
739
- const tt = Symbol("beforeSerialize");
740
- function Pt() {
746
+ const rt = Symbol("beforeSerialize");
747
+ function Rt() {
741
748
  return function(r, t, e) {
742
- Reflect.defineMetadata(tt, t, r);
749
+ Reflect.defineMetadata(rt, t, r);
743
750
  };
744
751
  }
745
- function zt(r, t, e) {
752
+ function Ht(r, t, e) {
746
753
  r.__afterDeserializeMethods__ || (r.__afterDeserializeMethods__ = []), r.__afterDeserializeMethods__.push(t);
747
754
  }
748
- function Rt(r) {
755
+ function Ut(r) {
749
756
  return function(t, e) {
750
- u(({ value: n }) => n === null ? void 0 : n, { toPlainOnly: !0 })(t, e), j(r)(t, e);
757
+ f(({ value: n }) => n === null ? void 0 : n, { toPlainOnly: !0 })(t, e), J(r)(t, e);
751
758
  };
752
759
  }
753
- function Ht() {
754
- return u(({ value: r, type: t }) => t === d.PLAIN_TO_CLASS ? r == null ? void 0 : r.id : r);
755
- }
756
- function Ut(r) {
757
- return u(({ value: t, type: e }) => e === d.PLAIN_TO_CLASS ? t == null ? void 0 : t.map((n) => n == null ? void 0 : n[r]) : t);
758
- }
759
760
  function jt() {
760
- return u(({ value: r, type: t }) => t === d.CLASS_TO_PLAIN && (r == null ? void 0 : r.id) || r);
761
+ return f(({ value: r, type: t }) => t === d.PLAIN_TO_CLASS ? r == null ? void 0 : r.id : r);
761
762
  }
762
- function Bt() {
763
- return u(({ value: r, type: t }) => t === d.CLASS_TO_PLAIN ? r.map((e) => e.id) : r);
763
+ function Bt(r) {
764
+ return f(({ value: t, type: e }) => e === d.PLAIN_TO_CLASS ? t == null ? void 0 : t.map((n) => n == null ? void 0 : n[r]) : t);
764
765
  }
765
766
  function Jt() {
766
- return u(({ value: r, type: t }) => t === "classToPlain" ? void 0 : r, { toPlainOnly: !0 });
767
+ return f(({ value: r, type: t }) => t === d.CLASS_TO_PLAIN && (r == null ? void 0 : r.id) || r);
767
768
  }
768
- function vt(r) {
769
+ function Kt() {
770
+ return f(({ value: r, type: t }) => t === d.CLASS_TO_PLAIN ? r.map((e) => e.id) : r);
771
+ }
772
+ function Vt() {
773
+ return f(({ value: r, type: t }) => t === "classToPlain" ? void 0 : r, { toPlainOnly: !0 });
774
+ }
775
+ function Zt(r) {
769
776
  return r == null;
770
777
  }
771
- const $ = Symbol("onDeserialized");
772
- function Kt() {
778
+ const k = Symbol("onDeserialized");
779
+ function Gt() {
773
780
  return function(r, t) {
774
- Reflect.defineMetadata($, t, r);
781
+ Reflect.defineMetadata(k, t, r);
775
782
  };
776
783
  }
777
- function et(r) {
784
+ function nt(r) {
778
785
  const t = Reflect.getMetadata(
779
- $,
786
+ k,
780
787
  r
781
788
  );
782
789
  return t ? r[t].bind(r) : null;
783
790
  }
784
- class Zt {
791
+ class Wt {
785
792
  /**
786
793
  * Выполняет действие toPlain в рамках ответственности Serialize.
787
794
  */
788
795
  static toPlain(t) {
789
- return S(t, {
796
+ return _(t, {
790
797
  exposeDefaultValues: !0,
791
798
  excludeExtraneousValues: !0
792
799
  });
@@ -795,16 +802,16 @@ class Zt {
795
802
  * Выполняет действие fromJSON в рамках ответственности Serialize.
796
803
  */
797
804
  static fromJSON(t, e) {
798
- const n = b(t, e, {
805
+ const n = S(t, e, {
799
806
  exposeDefaultValues: !0,
800
807
  excludeExtraneousValues: !0
801
- }), i = et(n);
808
+ }), i = nt(n);
802
809
  return i && i(), n;
803
810
  }
804
811
  }
805
- function Vt() {
812
+ function Yt() {
806
813
  return function(r, t) {
807
- u(
814
+ f(
808
815
  ({ value: e }) => {
809
816
  if (typeof e == "string")
810
817
  try {
@@ -815,7 +822,7 @@ function Vt() {
815
822
  return e;
816
823
  },
817
824
  { toClassOnly: !0 }
818
- )(r, t), u(
825
+ )(r, t), f(
819
826
  ({ value: e }) => {
820
827
  try {
821
828
  return JSON.stringify(e);
@@ -827,9 +834,9 @@ function Vt() {
827
834
  )(r, t);
828
835
  };
829
836
  }
830
- function Gt() {
837
+ function qt() {
831
838
  return function(r, t) {
832
- u(
839
+ f(
833
840
  ({ value: e }) => {
834
841
  if (e == null)
835
842
  return "{}";
@@ -842,7 +849,7 @@ function Gt() {
842
849
  return e;
843
850
  },
844
851
  { toClassOnly: !0 }
845
- )(r, t), u(
852
+ )(r, t), f(
846
853
  ({ value: e }) => {
847
854
  if (!e)
848
855
  return {};
@@ -858,21 +865,21 @@ function Gt() {
858
865
  )(r, t);
859
866
  };
860
867
  }
861
- function Wt() {
868
+ function Qt() {
862
869
  return function(r, t) {
863
- u(
870
+ f(
864
871
  ({ value: e }) => typeof e == "string" ? e.trim() : String(e ?? ""),
865
872
  { toClassOnly: !0 }
866
- )(r, t), u(
873
+ )(r, t), f(
867
874
  ({ value: e }) => typeof e == "string" ? e : String(e ?? ""),
868
875
  { toPlainOnly: !0 }
869
876
  )(r, t);
870
877
  };
871
878
  }
872
- function Yt(r, t) {
873
- return u(({ value: e, type: n }) => e ? n === d.PLAIN_TO_CLASS ? Array.isArray(e) ? t ? new Map(
879
+ function Xt(r, t) {
880
+ return f(({ value: e, type: n }) => e ? n === d.PLAIN_TO_CLASS ? Array.isArray(e) ? t ? new Map(
874
881
  e.map((i) => {
875
- const s = b(r, i);
882
+ const s = S(r, i);
876
883
  return [s[t], s];
877
884
  })
878
885
  ) : (console.warn(
@@ -882,45 +889,45 @@ function Yt(r, t) {
882
889
  const a = new r();
883
890
  return Object.assign(a, s), [i, a];
884
891
  })
885
- ) : (console.warn("[TypeMap] Expected object or array, got:", e), /* @__PURE__ */ new Map()) : n === d.CLASS_TO_PLAIN ? e instanceof Map ? Array.from(e.values()).map((i) => S(i)) : (console.warn("[TypeMap] Expected Map, got:", e), t ? [] : {}) : (console.warn("[TypeMap] Unexpected transformation type:", n), e) : /* @__PURE__ */ new Map());
892
+ ) : (console.warn(`[TypeMap] Expected object or array, got ${w(e)}`), /* @__PURE__ */ new Map()) : n === d.CLASS_TO_PLAIN ? e instanceof Map ? Array.from(e.values()).map((i) => _(i)) : (console.warn(`[TypeMap] Expected Map, got ${w(e)}`), t ? [] : {}) : (console.warn(`[TypeMap] Unexpected transformation type: ${String(n)}`), e) : /* @__PURE__ */ new Map());
886
893
  }
887
- function qt(r) {
888
- return u(({ value: t, type: e }) => {
894
+ function vt(r) {
895
+ return f(({ value: t, type: e }) => {
889
896
  if (!t || typeof t != "object") return {};
890
897
  if (e === d.PLAIN_TO_CLASS) {
891
898
  const n = {};
892
899
  for (const i of Object.keys(t))
893
- n[i] = b(r, t[i]);
900
+ n[i] = S(r, t[i]);
894
901
  return n;
895
902
  }
896
903
  if (e === d.CLASS_TO_PLAIN) {
897
904
  const n = {};
898
905
  for (const i of Object.keys(t))
899
- n[i] = S(t[i]);
906
+ n[i] = _(t[i]);
900
907
  return n;
901
908
  }
902
909
  return t;
903
910
  });
904
911
  }
905
- function Qt(r, t, e = (s) => s, n = (s) => s, i = 300) {
912
+ function te(r, t, e = (s) => s, n = (s) => s, i = 300) {
906
913
  let s = t;
907
914
  const a = localStorage.getItem(r);
908
915
  if (a)
909
916
  try {
910
- const f = JSON.parse(a);
911
- s = e(f);
912
- } catch {
913
- console.error("Failed to parse from localStorage", r, a);
917
+ const u = JSON.parse(a);
918
+ s = e(u);
919
+ } catch (u) {
920
+ console.error(`[useStorageDebounced] Failed to parse "${r}" (${a.length} chars): ${b(u)}`);
914
921
  }
915
- const l = y(s), c = B(() => {
922
+ const l = g(s), c = K(() => {
916
923
  try {
917
- const f = JSON.stringify(n(l.value));
918
- localStorage.setItem(r, f);
919
- } catch {
920
- console.error("Failed to save to localStorage", r, l.value);
924
+ const u = JSON.stringify(n(l.value));
925
+ localStorage.setItem(r, u);
926
+ } catch (u) {
927
+ console.error(`[useStorageDebounced] Failed to save "${r}": ${b(u)}`);
921
928
  }
922
929
  }, i);
923
- return O(
930
+ return C(
924
931
  () => l.value,
925
932
  () => {
926
933
  c();
@@ -928,24 +935,24 @@ function Qt(r, t, e = (s) => s, n = (s) => s, i = 300) {
928
935
  { deep: !0 }
929
936
  ), l;
930
937
  }
931
- function Xt(r, t) {
938
+ function ee(r, t) {
932
939
  return r < t ? -1 : r > t ? 1 : 0;
933
940
  }
934
- const rt = process.env.NODE_ENV !== "production";
935
- function te(r, t) {
936
- if (!rt) return t();
941
+ const it = process.env.NODE_ENV !== "production";
942
+ function re(r, t) {
943
+ if (!it) return t();
937
944
  console.groupCollapsed(`⏳ ${r}`);
938
945
  const e = performance.now(), n = t(), i = performance.now();
939
946
  return console.log(`${r}: ${Math.round(i - e)} ms`), console.groupEnd(), n;
940
947
  }
941
- const ee = () => J(), D = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
942
- function re(r) {
948
+ const ne = () => V(), A = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
949
+ function ie(r) {
943
950
  let t = "";
944
951
  for (let e = 0; e < r; ++e)
945
- t += D[Math.floor(D.length * Math.random())];
952
+ t += A[Math.floor(A.length * Math.random())];
946
953
  return t;
947
954
  }
948
- class ne {
955
+ class se {
949
956
  /**
950
957
  * Создает экземпляр HotkeyManager и подготавливает базовое состояние.
951
958
  */
@@ -1026,14 +1033,14 @@ class ne {
1026
1033
  this.clear(), this.target.removeEventListener("keydown", this.handleBound);
1027
1034
  }
1028
1035
  }
1029
- function ie(r, t) {
1036
+ function oe(r, t) {
1030
1037
  return t != null && t.key ? r.some((e) => {
1031
- var c, f;
1032
- const n = e.ctrl === void 0 || t.ctrlKey === e.ctrl, i = e.alt === void 0 || t.altKey === e.alt, s = e.shift === void 0 || t.shiftKey === e.shift, a = e.meta === void 0 || t.metaKey === e.meta, l = t.key && e.key && ((c = t.key) == null ? void 0 : c.toLowerCase()) === ((f = e.key) == null ? void 0 : f.toLowerCase());
1038
+ var c, u;
1039
+ const n = e.ctrl === void 0 || t.ctrlKey === e.ctrl, i = e.alt === void 0 || t.altKey === e.alt, s = e.shift === void 0 || t.shiftKey === e.shift, a = e.meta === void 0 || t.metaKey === e.meta, l = t.key && e.key && ((c = t.key) == null ? void 0 : c.toLowerCase()) === ((u = e.key) == null ? void 0 : u.toLowerCase());
1033
1040
  return n && i && s && a && l;
1034
1041
  }) : !1;
1035
1042
  }
1036
- class se extends N {
1043
+ class ae extends L {
1037
1044
  constructor() {
1038
1045
  super(...arguments);
1039
1046
  /** Массив всех логов */
@@ -1184,27 +1191,27 @@ class se extends N {
1184
1191
  this.logs = [], this.notify();
1185
1192
  }
1186
1193
  }
1187
- function nt(r) {
1194
+ function st(r) {
1188
1195
  try {
1189
1196
  return new new Proxy(r, { construct: () => ({}) })(), !0;
1190
1197
  } catch {
1191
1198
  return !1;
1192
1199
  }
1193
1200
  }
1194
- function oe(r, ...t) {
1195
- if (nt(r)) {
1201
+ function ce(r, ...t) {
1202
+ if (st(r)) {
1196
1203
  const e = r;
1197
1204
  return new e(...t);
1198
1205
  } else
1199
1206
  return r(...t);
1200
1207
  }
1201
- const it = /* @__PURE__ */ new WeakMap();
1202
- function ae(r) {
1208
+ const ot = /* @__PURE__ */ new WeakMap();
1209
+ function le(r) {
1203
1210
  let t;
1204
- return () => (t || (t = r(), it.set(r, t)), t);
1211
+ return () => (t || (t = r(), ot.set(r, t)), t);
1205
1212
  }
1206
- const st = {
1207
- DateTime: v,
1213
+ const at = {
1214
+ DateTime: Z,
1208
1215
  toDateTime(r) {
1209
1216
  return this.DateTime.fromJSDate(r);
1210
1217
  },
@@ -1232,25 +1239,25 @@ const st = {
1232
1239
  getZone() {
1233
1240
  return this.DateTime.now().zone;
1234
1241
  }
1235
- }, ce = (r) => st.toDateTime(r);
1236
- function le(r) {
1242
+ }, ue = (r) => at.toDateTime(r);
1243
+ function fe(r) {
1237
1244
  return String(r).charAt(0).toUpperCase() + String(r).slice(1);
1238
1245
  }
1239
- function ue(r, t) {
1240
- return x(r, t) || Z(r, t);
1246
+ function he(r, t) {
1247
+ return D(r, t) || W(r, t);
1241
1248
  }
1242
- function fe(r, t, e, n) {
1249
+ function de(r, t, e, n) {
1243
1250
  const i = p(r), s = p(t), a = p(e), l = p(n);
1244
- return !F(s, a) && !x(i, l);
1251
+ return !F(s, a) && !D(i, l);
1245
1252
  }
1246
- function he(r, t, e) {
1247
- return !F(r, p(t)) && !x(r, V(e));
1253
+ function me(r, t, e) {
1254
+ return !F(r, p(t)) && !D(r, Y(e));
1248
1255
  }
1249
- const de = (r) => r && new Date(r);
1250
- function me(r, t = "HH:mm dd.MM.yyyy", e = {}) {
1256
+ const pe = (r) => r && new Date(r);
1257
+ function ge(r, t = "HH:mm dd.MM.yyyy", e = {}) {
1251
1258
  return r && T(r, t, e);
1252
1259
  }
1253
- function ot(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
1260
+ function ct(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
1254
1261
  if (!r || !r || r === "")
1255
1262
  return "";
1256
1263
  if (typeof r == "string")
@@ -1260,39 +1267,39 @@ function ot(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
1260
1267
  return "";
1261
1268
  } else
1262
1269
  r = new Date(r.toString());
1263
- return n ? T(r, t, e) : T(G(r, "utc"), t, e);
1270
+ return n ? T(r, t, e) : T(q(r, "utc"), t, e);
1264
1271
  }
1265
- function pe(r) {
1272
+ function ye(r) {
1266
1273
  const t = { weekday: "short" }, e = new Intl.DateTimeFormat("ru-RU", t).format(r);
1267
1274
  return e.charAt(0).toUpperCase() + e.slice(1);
1268
1275
  }
1269
- function ye(r) {
1276
+ function Te(r) {
1270
1277
  const t = new Date(r), e = t.getTime() + t.getTimezoneOffset() * 6e3, n = new Date(e + 180 * 6e3), i = String(n.getDate()).padStart(2, "0"), s = String(n.getMonth() + 1).padStart(2, "0"), a = n.getFullYear();
1271
1278
  return `${i}.${s}.${a}`;
1272
1279
  }
1273
- function ge(r, t = !0) {
1274
- return ot(r, "HH:mm", {}, t);
1280
+ function be(r, t = !0) {
1281
+ return ct(r, "HH:mm", {}, t);
1275
1282
  }
1276
- function Te(r) {
1283
+ function Se(r) {
1277
1284
  const t = Array.from(r), e = Math.min(...t.map((i) => i.getTime())), n = Math.max(...t.map((i) => i.getTime()));
1278
1285
  return {
1279
1286
  minDate: new Date(e),
1280
1287
  maxDate: new Date(n)
1281
1288
  };
1282
1289
  }
1283
- function be(r, t) {
1284
- const e = C(r, t), { hours: n, minutes: i } = w(e);
1290
+ function _e(r, t) {
1291
+ const e = M(r, t), { hours: n, minutes: i } = I(e);
1285
1292
  return n || i ? `${e > 0 ? "-" : "+"}${h(n)}:${h(i)}` : "";
1286
1293
  }
1287
- function Se(r, t) {
1288
- const e = C(r, t), { hours: n, minutes: i } = w(e);
1294
+ function xe(r, t) {
1295
+ const e = M(r, t), { hours: n, minutes: i } = I(e);
1289
1296
  return n || i ? `${e > 0 ? "-" : ""}${h(n)}:${h(i)}` : "";
1290
1297
  }
1291
- function E(r = /* @__PURE__ */ new Date()) {
1298
+ function O(r = /* @__PURE__ */ new Date()) {
1292
1299
  return new Date(r.getFullYear(), r.getMonth(), r.getDate());
1293
1300
  }
1294
- function _e(r, t) {
1295
- const e = K(E(r), E(t));
1301
+ function we(r, t) {
1302
+ const e = G(O(r), O(t));
1296
1303
  return e ? e > 7 ? {
1297
1304
  variant: "red",
1298
1305
  value: ">7"
@@ -1307,30 +1314,30 @@ function _e(r, t) {
1307
1314
  value: `${e}`
1308
1315
  } : null;
1309
1316
  }
1310
- function xe(r) {
1317
+ function De(r) {
1311
1318
  const e = String(r ?? "").trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);
1312
1319
  if (!e)
1313
1320
  return null;
1314
1321
  const n = Number(e[1]), i = Number(e[2]) - 1, s = Number(e[3]), a = new Date(Date.UTC(n, i, s, 0, 0, 0, 0));
1315
1322
  return Number.isNaN(a.getTime()) ? null : a.toISOString();
1316
1323
  }
1317
- function we(r) {
1324
+ function Ie(r) {
1318
1325
  const t = String(r ?? "").trim();
1319
1326
  if (!t)
1320
1327
  return null;
1321
1328
  const e = t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/);
1322
1329
  if (e) {
1323
- const i = Number(e[1]), s = Number(e[2]) - 1, a = Number(e[3]), l = Number(e[4]), c = Number(e[5]), f = e[6] != null ? Number(e[6]) : 0, g = new Date(i, s, a, l, c, f, 0);
1324
- return Number.isNaN(g.getTime()) ? null : g.toISOString();
1330
+ const i = Number(e[1]), s = Number(e[2]) - 1, a = Number(e[3]), l = Number(e[4]), c = Number(e[5]), u = e[6] != null ? Number(e[6]) : 0, y = new Date(i, s, a, l, c, u, 0);
1331
+ return Number.isNaN(y.getTime()) ? null : y.toISOString();
1325
1332
  }
1326
1333
  const n = new Date(t);
1327
1334
  return Number.isNaN(n.getTime()) ? null : n.toISOString();
1328
1335
  }
1329
- function Ie(r) {
1336
+ function Ee(r) {
1330
1337
  const t = String(r ?? "").trim();
1331
1338
  return t ? t.slice(0, 10) : "";
1332
1339
  }
1333
- function De(r) {
1340
+ function Ae(r) {
1334
1341
  const t = String(r ?? "").trim();
1335
1342
  if (!t)
1336
1343
  return "";
@@ -1340,7 +1347,7 @@ function De(r) {
1340
1347
  const n = e.getFullYear(), i = h(e.getMonth() + 1), s = h(e.getDate()), a = h(e.getHours()), l = h(e.getMinutes());
1341
1348
  return `${n}-${i}-${s}T${a}:${l}`;
1342
1349
  }
1343
- function Ee(r) {
1350
+ function Oe(r) {
1344
1351
  if (r == null)
1345
1352
  return "";
1346
1353
  const t = String(r).trim();
@@ -1352,7 +1359,7 @@ function Ee(r) {
1352
1359
  const n = t.match(/^(\d{2}):(\d{2})$/);
1353
1360
  return n ? `${n[1]}:${n[2]}` : "";
1354
1361
  }
1355
- function Oe(r) {
1362
+ function Ce(r) {
1356
1363
  if (r == null)
1357
1364
  return null;
1358
1365
  const t = String(r).trim();
@@ -1364,31 +1371,31 @@ function Oe(r) {
1364
1371
  const n = t.match(/^(\d{2}):(\d{2})$/);
1365
1372
  return n ? `${n[1]}:${n[2]}:00` : null;
1366
1373
  }
1367
- function Ae(r) {
1368
- const t = ct(r), e = Math.sign(t) >= 0 ? "" : "-", { hours: n, minutes: i } = w(t);
1374
+ function $e(r) {
1375
+ const t = ut(r), e = Math.sign(t) >= 0 ? "" : "-", { hours: n, minutes: i } = I(t);
1369
1376
  return `${e}${h(n)}:${h(i)}`;
1370
1377
  }
1371
- function Ce(r = null, t = "dd", e = {}) {
1372
- const n = at(r);
1378
+ function Me(r = null, t = "dd", e = {}) {
1379
+ const n = lt(r);
1373
1380
  if (!n)
1374
1381
  return "";
1375
1382
  const i = /* @__PURE__ */ new Date(), s = new Date(n);
1376
1383
  return i.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0), s.toDateString() === i.toDateString() ? "" : `/${T(n, t, e)}`;
1377
1384
  }
1378
- function at(r) {
1385
+ function lt(r) {
1379
1386
  if (!r || r === "")
1380
1387
  return null;
1381
1388
  const t = typeof r == "string" ? new Date(r) : r instanceof Date ? r : new Date(r.toString());
1382
1389
  return Number.isNaN(t.getTime()) ? null : t;
1383
1390
  }
1384
- function w(r) {
1391
+ function I(r) {
1385
1392
  const t = Math.abs(r);
1386
1393
  return {
1387
1394
  hours: Math.floor(t / 3600) % 24,
1388
1395
  minutes: Math.floor(t / 60) % 60
1389
1396
  };
1390
1397
  }
1391
- function ct(r) {
1398
+ function ut(r) {
1392
1399
  const t = String(r ?? "").trim();
1393
1400
  if (!t)
1394
1401
  return 0;
@@ -1408,19 +1415,19 @@ function h(r) {
1408
1415
  function Fe(r) {
1409
1416
  const t = /* @__PURE__ */ new Date();
1410
1417
  try {
1411
- const e = _(r, t), n = Intl.supportedValuesOf("timeZone");
1418
+ const e = x(r, t), n = Intl.supportedValuesOf("timeZone");
1412
1419
  for (const i of n)
1413
- if (_(i, t) === e)
1420
+ if (x(i, t) === e)
1414
1421
  return i;
1415
1422
  } catch {
1416
1423
  return null;
1417
1424
  }
1418
1425
  return null;
1419
1426
  }
1420
- function Me(r) {
1421
- return _(r, /* @__PURE__ */ new Date());
1427
+ function Ne(r) {
1428
+ return x(r, /* @__PURE__ */ new Date());
1422
1429
  }
1423
- class Ne {
1430
+ class Le {
1424
1431
  constructor(t) {
1425
1432
  o(this, "_url");
1426
1433
  o(this, "_retryInterval");
@@ -1451,14 +1458,14 @@ class Ne {
1451
1458
  async _connect() {
1452
1459
  var t, e, n;
1453
1460
  try {
1454
- await W(this._url, {
1461
+ await Q(this._url, {
1455
1462
  method: "GET",
1456
1463
  headers: await this._buildHeaders(),
1457
1464
  signal: (t = this._abortController) == null ? void 0 : t.signal,
1458
1465
  openWhenHidden: !0,
1459
1466
  onopen: (i) => {
1460
1467
  var a, l;
1461
- if (i.ok && i.headers.get("content-type") === Y) {
1468
+ if (i.ok && i.headers.get("content-type") === X) {
1462
1469
  this._isConnected = !0, (l = (a = this._options).onOpen) == null || l.call(a);
1463
1470
  return;
1464
1471
  }
@@ -1468,7 +1475,7 @@ class Ne {
1468
1475
  try {
1469
1476
  this._options.onEvent(JSON.parse(i.data));
1470
1477
  } catch (s) {
1471
- console.warn("[SSEManager] Failed to parse message", s);
1478
+ console.warn(`[SSEManager] Failed to parse message: ${b(s)}`);
1472
1479
  }
1473
1480
  },
1474
1481
  onclose: () => {
@@ -1489,7 +1496,7 @@ class Ne {
1489
1496
  return this._isConnected;
1490
1497
  }
1491
1498
  }
1492
- class $e {
1499
+ class ke {
1493
1500
  constructor() {
1494
1501
  o(this, "_currentCount", 0);
1495
1502
  o(this, "_lastResetTime", Date.now());
@@ -1506,8 +1513,8 @@ class $e {
1506
1513
  this._currentCount = 0, this._lastEventsPerSecond = 0, this._lastResetTime = Date.now();
1507
1514
  }
1508
1515
  }
1509
- const Le = q("tooltip", () => {
1510
- const r = z({}), t = y(null);
1516
+ const ze = v("tooltip", () => {
1517
+ const r = H({}), t = g(null);
1511
1518
  function e(c) {
1512
1519
  r[c.id] = {
1513
1520
  ...c,
@@ -1540,87 +1547,89 @@ const Le = q("tooltip", () => {
1540
1547
  clearActiveTooltipId: l
1541
1548
  };
1542
1549
  });
1543
- function ke(r, t) {
1550
+ function Pe(r, t) {
1544
1551
  var e;
1545
1552
  return r("div", {}, (e = t.slots) != null && e.default ? t.slots.default() : []);
1546
1553
  }
1547
- const Pe = "x-collection-tooltip-id";
1554
+ const Re = "x-collection-tooltip-id";
1548
1555
  export {
1549
- zt as AfterDeserialize,
1550
- It as AppBus,
1551
- Pt as BeforeSerialize,
1552
- Ot as Collection,
1553
- Mt as DelayedExecutor,
1554
- Ut as DeserializeArrayField,
1555
- Ht as DeserializeId,
1556
- M as EventBus,
1556
+ Ht as AfterDeserialize,
1557
+ Et as AppBus,
1558
+ Rt as BeforeSerialize,
1559
+ Ct as Collection,
1560
+ Nt as DelayedExecutor,
1561
+ Bt as DeserializeArrayField,
1562
+ jt as DeserializeId,
1563
+ N as EventBus,
1557
1564
  m as Events,
1558
- kt as GenericExpose,
1559
- ne as HotkeyManager,
1560
- rt as IS_DEBUG,
1561
- Jt as IgnoreToPlain,
1562
- At as IndexedCollection,
1563
- Rt as IsOptionalTransformed,
1564
- Vt as Json,
1565
- Gt as JsonString,
1566
- Nt as NamedExecutor,
1565
+ Pt as GenericExpose,
1566
+ se as HotkeyManager,
1567
+ it as IS_DEBUG,
1568
+ Vt as IgnoreToPlain,
1569
+ $t as IndexedCollection,
1570
+ Ut as IsOptionalTransformed,
1571
+ Yt as Json,
1572
+ qt as JsonString,
1573
+ Lt as NamedExecutor,
1567
1574
  Ft as PayloadHttpClient,
1568
- Ct as RingBuffer,
1569
- Ne as SSEManager,
1570
- Wt as Script,
1571
- Zt as Serialize,
1572
- jt as SerializeId,
1573
- Bt as SerializeIds,
1574
- se as StructuredLogger,
1575
- N as Subscribable,
1576
- st as SystemClock,
1577
- Pe as TooltipAttribute,
1578
- ke as TooltipRegistrator,
1579
- Yt as TypeMap,
1580
- qt as TypeRecord,
1581
- $e as UPSMeter_Service,
1582
- le as capitalize,
1583
- Xt as compareNumber,
1584
- oe as createInstance,
1585
- be as diffDuration,
1586
- Se as diffDurationTable,
1587
- ce as dt,
1588
- ge as extractTime,
1589
- Te as findMinMaxDates,
1590
- ye as formatDateToMSK,
1591
- me as formatDatetime,
1592
- ot as formatDatetimeTZ,
1593
- Ce as formatDatetimeTZSpecial,
1594
- ee as generateUUID,
1595
- _e as getDateOnlyDiffFactor,
1596
- pe as getDayOfWeek,
1597
- et as getOnDeserializedMethod,
1598
- Me as getTimezoneOffsetMs,
1599
- ae as globalState,
1600
- ue as isAfterOrEqual,
1601
- ie as isAnyKeyComboActive,
1602
- nt as isConstructor,
1603
- he as isDateInRange,
1604
- fe as isDateRangeOverlap,
1605
- vt as isNullOrUndefined,
1606
- Ie as isoToDateInput,
1607
- De as isoToDateTimeLocalInput,
1608
- Kt as onDeserialized,
1609
- de as parseDate,
1610
- Ae as parseDuration,
1575
+ Mt as RingBuffer,
1576
+ Le as SSEManager,
1577
+ Qt as Script,
1578
+ Wt as Serialize,
1579
+ Jt as SerializeId,
1580
+ Kt as SerializeIds,
1581
+ ae as StructuredLogger,
1582
+ L as Subscribable,
1583
+ at as SystemClock,
1584
+ Re as TooltipAttribute,
1585
+ Pe as TooltipRegistrator,
1586
+ Xt as TypeMap,
1587
+ vt as TypeRecord,
1588
+ ke as UPSMeter_Service,
1589
+ fe as capitalize,
1590
+ ee as compareNumber,
1591
+ b as consoleErrorSummary,
1592
+ w as consoleValueSummary,
1593
+ ce as createInstance,
1594
+ _e as diffDuration,
1595
+ xe as diffDurationTable,
1596
+ ue as dt,
1597
+ be as extractTime,
1598
+ Se as findMinMaxDates,
1599
+ Te as formatDateToMSK,
1600
+ ge as formatDatetime,
1601
+ ct as formatDatetimeTZ,
1602
+ Me as formatDatetimeTZSpecial,
1603
+ ne as generateUUID,
1604
+ we as getDateOnlyDiffFactor,
1605
+ ye as getDayOfWeek,
1606
+ nt as getOnDeserializedMethod,
1607
+ Ne as getTimezoneOffsetMs,
1608
+ le as globalState,
1609
+ he as isAfterOrEqual,
1610
+ oe as isAnyKeyComboActive,
1611
+ st as isConstructor,
1612
+ me as isDateInRange,
1613
+ de as isDateRangeOverlap,
1614
+ Zt as isNullOrUndefined,
1615
+ Ee as isoToDateInput,
1616
+ Ae as isoToDateTimeLocalInput,
1617
+ Gt as onDeserialized,
1618
+ pe as parseDate,
1619
+ $e as parseDuration,
1611
1620
  Fe as parseOffsetToTimezone,
1612
- te as profile,
1613
- re as randomString,
1614
- E as removeTime,
1615
- Ee as timeToTimeInput,
1616
- $t as toInstance,
1617
- xe as toIsoZDate,
1618
- we as toIsoZDateTime,
1619
- Lt as toPlain,
1620
- Oe as toTimeHHMMSS,
1621
- wt as useCookie,
1622
- Qt as useStorageDebounced,
1623
- Dt as useSubscribableRef,
1624
- Et as useSubscribableRefAuto,
1625
- Le as useTooltipStore
1621
+ re as profile,
1622
+ ie as randomString,
1623
+ O as removeTime,
1624
+ Oe as timeToTimeInput,
1625
+ kt as toInstance,
1626
+ De as toIsoZDate,
1627
+ Ie as toIsoZDateTime,
1628
+ zt as toPlain,
1629
+ Ce as toTimeHHMMSS,
1630
+ It as useCookie,
1631
+ te as useStorageDebounced,
1632
+ At as useSubscribableRef,
1633
+ Ot as useSubscribableRefAuto,
1634
+ ze as useTooltipStore
1626
1635
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@endge/utils",
3
3
  "private": false,
4
- "version": "0.24.6",
4
+ "version": "0.24.8",
5
5
  "type": "module",
6
6
  "module": "./dist/utils.js",
7
7
  "types": "./dist/index.d.ts",