@endge/utils 0.24.2 → 0.24.3

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
@@ -781,36 +781,6 @@ export declare class RingBuffer<T> {
781
781
  */
782
782
  export declare function Script(): PropertyDecorator;
783
783
 
784
- /**
785
- * Описывает ответственность ScriptRunner в архитектуре проекта.
786
- */
787
- export declare class ScriptRunner {
788
- private script;
789
- /**
790
- * Создает экземпляр ScriptRunner и подготавливает базовое состояние.
791
- */
792
- constructor(script: string);
793
- /**
794
- * Запускает скрипт с некоторым контекстом и автоматически
795
- * добавляют экспортируемые имена которые парсятся из JSX
796
- */
797
- runAsync(context: Record<string, any>, exportNames?: Set<string>): Promise<void>;
798
- /**
799
- * Синхронно вычисляет выражение в контексте.
800
- * Используется для интерполяций, :bind, v-if и т.п.
801
- */
802
- runSync(context: Record<string, any>, exportNames?: Set<string>): void;
803
- /**
804
- * Синхронно вычисляет выражение в контексте.
805
- * Используется для интерполяций, :bind, v-if и т.п.
806
- */
807
- evaluate(context: Record<string, any>): any;
808
- /**
809
- * Выполняет внутренний шаг wrapIfAsync для ScriptRunner.
810
- */
811
- private wrapIfAsync;
812
- }
813
-
814
784
  /**
815
785
  * Описывает ответственность Serialize в архитектуре проекта.
816
786
  */
package/dist/utils.js CHANGED
@@ -1,17 +1,17 @@
1
1
  var L = Object.defineProperty;
2
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 a = (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 R } from "vue";
5
- import { parse as z, serialize as I } from "cookie-es";
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
6
  import { destr as H } from "destr";
7
7
  import { plainToInstance as b, instanceToPlain as S, Transform as u, TransformationType as d, Expose as U } from "class-transformer";
8
8
  import { IsOptional as j } from "class-validator";
9
9
  import "reflect-metadata";
10
- import v from "lodash/debounce.js";
11
- import { v4 as B } from "uuid";
12
- import { DateTime as J } from "ts-luxon";
13
- import { differenceInSeconds as C, format as T, differenceInCalendarDays as K, isAfter as _, isEqual as V, isBefore as F, startOfDay as p, endOfDay as Z } from "date-fns";
14
- import { utcToZonedTime as G, getTimezoneOffset as w } from "date-fns-tz";
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
15
  import { fetchEventSource as W, EventStreamContentType as Y } from "@microsoft/fetch-event-source";
16
16
  import { defineStore as q } from "pinia";
17
17
  const Q = {
@@ -19,9 +19,9 @@ const Q = {
19
19
  watch: !0,
20
20
  decode: (r) => H(decodeURIComponent(r)),
21
21
  encode: (r) => encodeURIComponent(typeof r == "string" ? r : JSON.stringify(r))
22
- }, xt = (r, t) => {
22
+ }, wt = (r, t) => {
23
23
  var s;
24
- const e = { ...Q, ...t || {} }, n = z(document.cookie, e), i = y(n[r] ?? ((s = e.default) == null ? void 0 : s.call(e)));
24
+ const e = { ...Q, ...t || {} }, n = R(document.cookie, e), i = y(n[r] ?? ((s = e.default) == null ? void 0 : s.call(e)));
25
25
  return O(i, () => {
26
26
  document.cookie = X(r, i.value, e);
27
27
  }), i;
@@ -35,7 +35,7 @@ class M {
35
35
  * Создает экземпляр EventBus и подготавливает базовое состояние.
36
36
  */
37
37
  constructor(t = []) {
38
- a(this, "listeners", /* @__PURE__ */ new Map());
38
+ o(this, "listeners", /* @__PURE__ */ new Map());
39
39
  t.forEach((e) => {
40
40
  this.listeners.set(e, /* @__PURE__ */ new Set());
41
41
  });
@@ -111,8 +111,8 @@ class M {
111
111
  */
112
112
  _once(t, e) {
113
113
  const n = Array.isArray(t) ? t : [t], i = (s) => {
114
- for (const o of n)
115
- this.off(o, i);
114
+ for (const a of n)
115
+ this.off(a, i);
116
116
  e(s);
117
117
  };
118
118
  this._on(n, i);
@@ -157,9 +157,9 @@ class M {
157
157
  }
158
158
  }
159
159
  const It = new M(Object.keys({}));
160
- class $ {
160
+ class N {
161
161
  constructor() {
162
- a(this, "subscribers", /* @__PURE__ */ new Set());
162
+ o(this, "subscribers", /* @__PURE__ */ new Set());
163
163
  }
164
164
  /**
165
165
  * Подписывается на обновления.
@@ -189,16 +189,16 @@ const Dt = (r) => {
189
189
  e();
190
190
  }), t;
191
191
  };
192
- class Ot extends $ {
192
+ class Ot extends N {
193
193
  /**
194
194
  * Создает экземпляр Collection и подготавливает базовое состояние.
195
195
  */
196
196
  constructor(e = []) {
197
197
  super();
198
- a(this, "items", []);
199
- a(this, "indices", /* @__PURE__ */ new Map());
200
- a(this, "rootIds", /* @__PURE__ */ new Set());
201
- a(this, "bus");
198
+ o(this, "items", []);
199
+ o(this, "indices", /* @__PURE__ */ new Map());
200
+ o(this, "rootIds", /* @__PURE__ */ new Set());
201
+ o(this, "bus");
202
202
  this.bus = new M(Object.values(m)), e.length && this.add(e), this.createIndex("id");
203
203
  }
204
204
  /**
@@ -207,8 +207,8 @@ class Ot extends $ {
207
207
  add(e) {
208
208
  const n = Array.isArray(e) ? e : [e];
209
209
  n.forEach((i) => {
210
- this.items.push(i), this.indices.forEach((s, o) => {
211
- s.set(i[o], i);
210
+ this.items.push(i), this.indices.forEach((s, a) => {
211
+ s.set(i[a], i);
212
212
  }), i.parentId || this.rootIds.add(i.id);
213
213
  }), n != null && n.length && (this.bus.emit(m.Add, n), this.notify());
214
214
  }
@@ -218,7 +218,7 @@ class Ot extends $ {
218
218
  remove(e) {
219
219
  const n = Array.isArray(e) ? e : [e], i = [];
220
220
  n.forEach((s) => {
221
- const o = typeof s == "string" ? s : s.id, l = this.items.findIndex((c) => c.id === o);
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
224
  this.indices.forEach((f, g) => {
@@ -234,8 +234,8 @@ class Ot extends $ {
234
234
  const n = Array.isArray(e) ? e : [e];
235
235
  n.forEach((i) => {
236
236
  const s = this.get(i.id);
237
- s && (Object.assign(s, i), this.indices.forEach((o, l) => {
238
- o.set(i[l], s);
237
+ s && (Object.assign(s, i), this.indices.forEach((a, l) => {
238
+ a.set(i[l], s);
239
239
  }));
240
240
  }), n != null && n.length && (this.bus.emit(m.Update, n), this.notify());
241
241
  }
@@ -291,16 +291,16 @@ class At {
291
291
  * Создает экземпляр IndexedCollection и подготавливает базовое состояние.
292
292
  */
293
293
  constructor(t = null) {
294
- a(this, "list", []);
295
- a(this, "filteredList", []);
296
- a(this, "map", /* @__PURE__ */ new Map());
297
- a(this, "indexById", /* @__PURE__ */ new Map());
298
- a(this, "dirtySort", !1);
299
- a(this, "dirtyFilter", !1);
300
- a(this, "sortFn");
301
- a(this, "filterFn");
302
- a(this, "indexEnabled", !1);
303
- a(this, "filterIndexEnabled", !1);
294
+ o(this, "list", []);
295
+ o(this, "filteredList", []);
296
+ o(this, "map", /* @__PURE__ */ new Map());
297
+ o(this, "indexById", /* @__PURE__ */ new Map());
298
+ o(this, "dirtySort", !1);
299
+ o(this, "dirtyFilter", !1);
300
+ o(this, "sortFn");
301
+ o(this, "filterFn");
302
+ o(this, "indexEnabled", !1);
303
+ o(this, "filterIndexEnabled", !1);
304
304
  t && this.options(t);
305
305
  }
306
306
  /**
@@ -518,10 +518,10 @@ class At {
518
518
  }
519
519
  class Ct {
520
520
  constructor(t) {
521
- a(this, "_cap");
522
- a(this, "_buf");
523
- a(this, "_head", 0);
524
- a(this, "_len", 0);
521
+ o(this, "_cap");
522
+ o(this, "_buf");
523
+ o(this, "_head", 0);
524
+ o(this, "_len", 0);
525
525
  this._cap = Math.max(0, t | 0), this._buf = new Array(this._cap);
526
526
  }
527
527
  get capacity() {
@@ -549,7 +549,7 @@ class Ct {
549
549
  }
550
550
  class Ft {
551
551
  constructor(t) {
552
- a(this, "baseUrl");
552
+ o(this, "baseUrl");
553
553
  this.baseUrl = t.baseUrl.replace(/\/+$/, "");
554
554
  }
555
555
  buildUrl(t, e) {
@@ -624,10 +624,10 @@ class Mt {
624
624
  * Создает экземпляр DelayedExecutor и подготавливает базовое состояние.
625
625
  */
626
626
  constructor(t, e = !1) {
627
- a(this, "delayTimer", null);
628
- a(this, "maxTimer", null);
629
- a(this, "hasExecutedOnce", !1);
630
- a(this, "lastArgs", null);
627
+ o(this, "delayTimer", null);
628
+ o(this, "maxTimer", null);
629
+ o(this, "hasExecutedOnce", !1);
630
+ o(this, "lastArgs", null);
631
631
  this.fn = t, this.firstExecuteImmediately = e;
632
632
  }
633
633
  /**
@@ -659,15 +659,15 @@ 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 $t {
662
+ class Nt {
663
663
  /**
664
664
  * Создает экземпляр NamedExecutor и подготавливает базовое состояние.
665
665
  */
666
666
  constructor(t) {
667
- a(this, "delayTimers", /* @__PURE__ */ new Map());
668
- a(this, "maxTimers", /* @__PURE__ */ new Map());
669
- a(this, "callbacks", /* @__PURE__ */ new Map());
670
- a(this, "firstCallTime", /* @__PURE__ */ new Map());
667
+ o(this, "delayTimers", /* @__PURE__ */ new Map());
668
+ o(this, "maxTimers", /* @__PURE__ */ new Map());
669
+ o(this, "callbacks", /* @__PURE__ */ new Map());
670
+ o(this, "firstCallTime", /* @__PURE__ */ new Map());
671
671
  this.config = t;
672
672
  }
673
673
  /**
@@ -720,7 +720,7 @@ class $t {
720
720
  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
721
  }
722
722
  }
723
- function Nt(r, t) {
723
+ function $t(r, t) {
724
724
  return b(r, t, {
725
725
  exposeDefaultValues: !0,
726
726
  excludeExtraneousValues: !0
@@ -742,10 +742,10 @@ function Pt() {
742
742
  Reflect.defineMetadata(tt, t, r);
743
743
  };
744
744
  }
745
- function Rt(r, t, e) {
745
+ function zt(r, t, e) {
746
746
  r.__afterDeserializeMethods__ || (r.__afterDeserializeMethods__ = []), r.__afterDeserializeMethods__.push(t);
747
747
  }
748
- function zt(r) {
748
+ function Rt(r) {
749
749
  return function(t, e) {
750
750
  u(({ value: n }) => n === null ? void 0 : n, { toPlainOnly: !0 })(t, e), j(r)(t, e);
751
751
  };
@@ -759,29 +759,29 @@ function Ut(r) {
759
759
  function jt() {
760
760
  return u(({ value: r, type: t }) => t === d.CLASS_TO_PLAIN && (r == null ? void 0 : r.id) || r);
761
761
  }
762
- function vt() {
762
+ function Bt() {
763
763
  return u(({ value: r, type: t }) => t === d.CLASS_TO_PLAIN ? r.map((e) => e.id) : r);
764
764
  }
765
- function Bt() {
765
+ function Jt() {
766
766
  return u(({ value: r, type: t }) => t === "classToPlain" ? void 0 : r, { toPlainOnly: !0 });
767
767
  }
768
- function Jt(r) {
768
+ function vt(r) {
769
769
  return r == null;
770
770
  }
771
- const N = Symbol("onDeserialized");
771
+ const $ = Symbol("onDeserialized");
772
772
  function Kt() {
773
773
  return function(r, t) {
774
- Reflect.defineMetadata(N, t, r);
774
+ Reflect.defineMetadata($, t, r);
775
775
  };
776
776
  }
777
777
  function et(r) {
778
778
  const t = Reflect.getMetadata(
779
- N,
779
+ $,
780
780
  r
781
781
  );
782
782
  return t ? r[t].bind(r) : null;
783
783
  }
784
- class Vt {
784
+ class Zt {
785
785
  /**
786
786
  * Выполняет действие toPlain в рамках ответственности Serialize.
787
787
  */
@@ -802,7 +802,7 @@ class Vt {
802
802
  return i && i(), n;
803
803
  }
804
804
  }
805
- function Zt() {
805
+ function Vt() {
806
806
  return function(r, t) {
807
807
  u(
808
808
  ({ value: e }) => {
@@ -879,8 +879,8 @@ function Yt(r, t) {
879
879
  "[TypeMap] Key field is required for array transformation!"
880
880
  ), /* @__PURE__ */ new Map()) : typeof e == "object" ? new Map(
881
881
  Object.entries(e).map(([i, s]) => {
882
- const o = new r();
883
- return Object.assign(o, s), [i, o];
882
+ const a = new r();
883
+ return Object.assign(a, s), [i, a];
884
884
  })
885
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());
886
886
  }
@@ -904,15 +904,15 @@ function qt(r) {
904
904
  }
905
905
  function Qt(r, t, e = (s) => s, n = (s) => s, i = 300) {
906
906
  let s = t;
907
- const o = localStorage.getItem(r);
908
- if (o)
907
+ const a = localStorage.getItem(r);
908
+ if (a)
909
909
  try {
910
- const f = JSON.parse(o);
910
+ const f = JSON.parse(a);
911
911
  s = e(f);
912
912
  } catch {
913
- console.error("Failed to parse from localStorage", r, o);
913
+ console.error("Failed to parse from localStorage", r, a);
914
914
  }
915
- const l = y(s), c = v(() => {
915
+ const l = y(s), c = B(() => {
916
916
  try {
917
917
  const f = JSON.stringify(n(l.value));
918
918
  localStorage.setItem(r, f);
@@ -938,7 +938,7 @@ function te(r, t) {
938
938
  const e = performance.now(), n = t(), i = performance.now();
939
939
  return console.log(`${r}: ${Math.round(i - e)} ms`), console.groupEnd(), n;
940
940
  }
941
- const ee = () => B(), D = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
941
+ const ee = () => J(), D = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
942
942
  function re(r) {
943
943
  let t = "";
944
944
  for (let e = 0; e < r; ++e)
@@ -950,11 +950,11 @@ class ne {
950
950
  * Создает экземпляр HotkeyManager и подготавливает базовое состояние.
951
951
  */
952
952
  constructor(t = {}) {
953
- a(this, "bindings", /* @__PURE__ */ new Map());
954
- a(this, "enabled", !0);
955
- a(this, "target");
956
- a(this, "ignoreInput");
957
- a(this, "handleBound");
953
+ o(this, "bindings", /* @__PURE__ */ new Map());
954
+ o(this, "enabled", !0);
955
+ o(this, "target");
956
+ o(this, "ignoreInput");
957
+ o(this, "handleBound");
958
958
  this.target = t.target || window, this.ignoreInput = t.ignoreInput ?? !1, this.handleBound = this.handle.bind(this), this.target.addEventListener("keydown", this.handleBound);
959
959
  }
960
960
  /**
@@ -997,8 +997,8 @@ class ne {
997
997
  var i;
998
998
  const n = Array.isArray(t) ? t : [t];
999
999
  for (const s of n) {
1000
- const o = s.toLowerCase();
1001
- (i = this.bindings.get(o)) == null || i.delete(e);
1000
+ const a = s.toLowerCase();
1001
+ (i = this.bindings.get(a)) == null || i.delete(e);
1002
1002
  }
1003
1003
  }
1004
1004
  /**
@@ -1029,18 +1029,18 @@ class ne {
1029
1029
  function ie(r, t) {
1030
1030
  return t != null && t.key ? r.some((e) => {
1031
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, o = 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());
1033
- return n && i && s && o && l;
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());
1033
+ return n && i && s && a && l;
1034
1034
  }) : !1;
1035
1035
  }
1036
- class se extends $ {
1036
+ class se extends N {
1037
1037
  constructor() {
1038
1038
  super(...arguments);
1039
1039
  /** Массив всех логов */
1040
- a(this, "logs", []);
1040
+ o(this, "logs", []);
1041
1041
  /** Текущий контекст (иерархия) */
1042
- a(this, "currentContext", []);
1043
- a(this, "currentActions", []);
1042
+ o(this, "currentContext", []);
1043
+ o(this, "currentActions", []);
1044
1044
  }
1045
1045
  /**
1046
1046
  * Устанавливает текущий контекст.
@@ -1198,100 +1198,13 @@ function oe(r, ...t) {
1198
1198
  } else
1199
1199
  return r(...t);
1200
1200
  }
1201
- class ae {
1202
- /**
1203
- * Создает экземпляр ScriptRunner и подготавливает базовое состояние.
1204
- */
1205
- constructor(t) {
1206
- this.script = t;
1207
- }
1208
- /**
1209
- * Запускает скрипт с некоторым контекстом и автоматически
1210
- * добавляют экспортируемые имена которые парсятся из JSX
1211
- */
1212
- async runAsync(t, e = /* @__PURE__ */ new Set()) {
1213
- const n = Object.keys(t), i = Object.fromEntries(
1214
- n.map((c) => [c, this.wrapIfAsync(t[c])])
1215
- ), s = Array.from(e), o = s.length > 0 ? `
1216
-
1217
- expose({ ${s.join(", ")} });
1218
- ` : "", l = `${this.script}${o}`;
1219
- try {
1220
- return await new Function(
1221
- ...n,
1222
- `"use strict"; return (async () => { ${l} })();`
1223
- )(...Object.values(i));
1224
- } catch (c) {
1225
- console.warn(
1226
- "(ScriptRunner.runAsync): Ошибка в скрипте:",
1227
- l,
1228
- c
1229
- );
1230
- }
1231
- }
1232
- /**
1233
- * Синхронно вычисляет выражение в контексте.
1234
- * Используется для интерполяций, :bind, v-if и т.п.
1235
- */
1236
- runSync(t, e = /* @__PURE__ */ new Set()) {
1237
- const n = Object.keys(t), i = Object.values(t), s = Array.from(e), o = s.length > 0 ? `
1238
-
1239
- expose({ ${s.join(", ")} });
1240
- ` : "";
1241
- try {
1242
- new Function(
1243
- ...n,
1244
- `"use strict"; ${this.script}${o};`
1245
- )(...i);
1246
- } catch (l) {
1247
- console.warn(
1248
- "(ScriptRunner.runSync): Ошибка в скрипте:",
1249
- this.script,
1250
- l
1251
- );
1252
- }
1253
- }
1254
- /**
1255
- * Синхронно вычисляет выражение в контексте.
1256
- * Используется для интерполяций, :bind, v-if и т.п.
1257
- */
1258
- evaluate(t) {
1259
- const e = Object.keys(t), n = Object.values(t);
1260
- try {
1261
- return new Function(
1262
- ...e,
1263
- `"use strict"; return (${this.script});`
1264
- )(...n);
1265
- } catch (i) {
1266
- console.warn(
1267
- "(ScriptRunner.evaluate): Ошибка в выражении:",
1268
- this.script,
1269
- i
1270
- );
1271
- return;
1272
- }
1273
- }
1274
- /**
1275
- * Выполняет внутренний шаг wrapIfAsync для ScriptRunner.
1276
- */
1277
- wrapIfAsync(t) {
1278
- if (typeof t != "object" || t === null) return t;
1279
- const e = {};
1280
- for (const [n, i] of Object.entries(t))
1281
- typeof i == "function" ? e[n] = (...s) => {
1282
- const o = i(...s);
1283
- return o instanceof Promise, o;
1284
- } : e[n] = i;
1285
- return e;
1286
- }
1287
- }
1288
1201
  const it = /* @__PURE__ */ new WeakMap();
1289
- function ce(r) {
1202
+ function ae(r) {
1290
1203
  let t;
1291
1204
  return () => (t || (t = r(), it.set(r, t)), t);
1292
1205
  }
1293
1206
  const st = {
1294
- DateTime: J,
1207
+ DateTime: v,
1295
1208
  toDateTime(r) {
1296
1209
  return this.DateTime.fromJSDate(r);
1297
1210
  },
@@ -1319,22 +1232,22 @@ const st = {
1319
1232
  getZone() {
1320
1233
  return this.DateTime.now().zone;
1321
1234
  }
1322
- }, le = (r) => st.toDateTime(r);
1323
- function ue(r) {
1235
+ }, ce = (r) => st.toDateTime(r);
1236
+ function le(r) {
1324
1237
  return String(r).charAt(0).toUpperCase() + String(r).slice(1);
1325
1238
  }
1326
- function fe(r, t) {
1327
- return _(r, t) || V(r, t);
1239
+ function ue(r, t) {
1240
+ return x(r, t) || Z(r, t);
1328
1241
  }
1329
- function he(r, t, e, n) {
1330
- const i = p(r), s = p(t), o = p(e), l = p(n);
1331
- return !F(s, o) && !_(i, l);
1242
+ function fe(r, t, e, n) {
1243
+ const i = p(r), s = p(t), a = p(e), l = p(n);
1244
+ return !F(s, a) && !x(i, l);
1332
1245
  }
1333
- function de(r, t, e) {
1334
- return !F(r, p(t)) && !_(r, Z(e));
1246
+ function he(r, t, e) {
1247
+ return !F(r, p(t)) && !x(r, V(e));
1335
1248
  }
1336
- const me = (r) => r && new Date(r);
1337
- function pe(r, t = "HH:mm dd.MM.yyyy", e = {}) {
1249
+ const de = (r) => r && new Date(r);
1250
+ function me(r, t = "HH:mm dd.MM.yyyy", e = {}) {
1338
1251
  return r && T(r, t, e);
1339
1252
  }
1340
1253
  function ot(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
@@ -1349,30 +1262,30 @@ function ot(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
1349
1262
  r = new Date(r.toString());
1350
1263
  return n ? T(r, t, e) : T(G(r, "utc"), t, e);
1351
1264
  }
1352
- function ye(r) {
1265
+ function pe(r) {
1353
1266
  const t = { weekday: "short" }, e = new Intl.DateTimeFormat("ru-RU", t).format(r);
1354
1267
  return e.charAt(0).toUpperCase() + e.slice(1);
1355
1268
  }
1356
- function ge(r) {
1357
- 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"), o = n.getFullYear();
1358
- return `${i}.${s}.${o}`;
1269
+ function ye(r) {
1270
+ 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
+ return `${i}.${s}.${a}`;
1359
1272
  }
1360
- function Te(r, t = !0) {
1273
+ function ge(r, t = !0) {
1361
1274
  return ot(r, "HH:mm", {}, t);
1362
1275
  }
1363
- function be(r) {
1276
+ function Te(r) {
1364
1277
  const t = Array.from(r), e = Math.min(...t.map((i) => i.getTime())), n = Math.max(...t.map((i) => i.getTime()));
1365
1278
  return {
1366
1279
  minDate: new Date(e),
1367
1280
  maxDate: new Date(n)
1368
1281
  };
1369
1282
  }
1370
- function Se(r, t) {
1371
- const e = C(r, t), { hours: n, minutes: i } = x(e);
1283
+ function be(r, t) {
1284
+ const e = C(r, t), { hours: n, minutes: i } = w(e);
1372
1285
  return n || i ? `${e > 0 ? "-" : "+"}${h(n)}:${h(i)}` : "";
1373
1286
  }
1374
- function we(r, t) {
1375
- const e = C(r, t), { hours: n, minutes: i } = x(e);
1287
+ function Se(r, t) {
1288
+ const e = C(r, t), { hours: n, minutes: i } = w(e);
1376
1289
  return n || i ? `${e > 0 ? "-" : ""}${h(n)}:${h(i)}` : "";
1377
1290
  }
1378
1291
  function E(r = /* @__PURE__ */ new Date()) {
@@ -1398,36 +1311,36 @@ function xe(r) {
1398
1311
  const e = String(r ?? "").trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);
1399
1312
  if (!e)
1400
1313
  return null;
1401
- const n = Number(e[1]), i = Number(e[2]) - 1, s = Number(e[3]), o = new Date(Date.UTC(n, i, s, 0, 0, 0, 0));
1402
- return Number.isNaN(o.getTime()) ? null : o.toISOString();
1314
+ 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
+ return Number.isNaN(a.getTime()) ? null : a.toISOString();
1403
1316
  }
1404
- function Ie(r) {
1317
+ function we(r) {
1405
1318
  const t = String(r ?? "").trim();
1406
1319
  if (!t)
1407
1320
  return null;
1408
1321
  const e = t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/);
1409
1322
  if (e) {
1410
- const i = Number(e[1]), s = Number(e[2]) - 1, o = Number(e[3]), l = Number(e[4]), c = Number(e[5]), f = e[6] != null ? Number(e[6]) : 0, g = new Date(i, s, o, l, c, f, 0);
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);
1411
1324
  return Number.isNaN(g.getTime()) ? null : g.toISOString();
1412
1325
  }
1413
1326
  const n = new Date(t);
1414
1327
  return Number.isNaN(n.getTime()) ? null : n.toISOString();
1415
1328
  }
1416
- function De(r) {
1329
+ function Ie(r) {
1417
1330
  const t = String(r ?? "").trim();
1418
1331
  return t ? t.slice(0, 10) : "";
1419
1332
  }
1420
- function Ee(r) {
1333
+ function De(r) {
1421
1334
  const t = String(r ?? "").trim();
1422
1335
  if (!t)
1423
1336
  return "";
1424
1337
  const e = new Date(t);
1425
1338
  if (Number.isNaN(e.getTime()))
1426
1339
  return t.slice(0, 16);
1427
- const n = e.getFullYear(), i = h(e.getMonth() + 1), s = h(e.getDate()), o = h(e.getHours()), l = h(e.getMinutes());
1428
- return `${n}-${i}-${s}T${o}:${l}`;
1340
+ const n = e.getFullYear(), i = h(e.getMonth() + 1), s = h(e.getDate()), a = h(e.getHours()), l = h(e.getMinutes());
1341
+ return `${n}-${i}-${s}T${a}:${l}`;
1429
1342
  }
1430
- function Oe(r) {
1343
+ function Ee(r) {
1431
1344
  if (r == null)
1432
1345
  return "";
1433
1346
  const t = String(r).trim();
@@ -1439,7 +1352,7 @@ function Oe(r) {
1439
1352
  const n = t.match(/^(\d{2}):(\d{2})$/);
1440
1353
  return n ? `${n[1]}:${n[2]}` : "";
1441
1354
  }
1442
- function Ae(r) {
1355
+ function Oe(r) {
1443
1356
  if (r == null)
1444
1357
  return null;
1445
1358
  const t = String(r).trim();
@@ -1451,11 +1364,11 @@ function Ae(r) {
1451
1364
  const n = t.match(/^(\d{2}):(\d{2})$/);
1452
1365
  return n ? `${n[1]}:${n[2]}:00` : null;
1453
1366
  }
1454
- function Ce(r) {
1455
- const t = ct(r), e = Math.sign(t) >= 0 ? "" : "-", { hours: n, minutes: i } = x(t);
1367
+ function Ae(r) {
1368
+ const t = ct(r), e = Math.sign(t) >= 0 ? "" : "-", { hours: n, minutes: i } = w(t);
1456
1369
  return `${e}${h(n)}:${h(i)}`;
1457
1370
  }
1458
- function Fe(r = null, t = "dd", e = {}) {
1371
+ function Ce(r = null, t = "dd", e = {}) {
1459
1372
  const n = at(r);
1460
1373
  if (!n)
1461
1374
  return "";
@@ -1468,7 +1381,7 @@ function at(r) {
1468
1381
  const t = typeof r == "string" ? new Date(r) : r instanceof Date ? r : new Date(r.toString());
1469
1382
  return Number.isNaN(t.getTime()) ? null : t;
1470
1383
  }
1471
- function x(r) {
1384
+ function w(r) {
1472
1385
  const t = Math.abs(r);
1473
1386
  return {
1474
1387
  hours: Math.floor(t / 3600) % 24,
@@ -1484,37 +1397,37 @@ function ct(r) {
1484
1397
  return (e[1] ? -1 : 1) * (Number(e[2]) * 3600 + Number(e[3]) * 60 + Number(e[4] ?? 0));
1485
1398
  const n = t.match(/^(-)?P(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/i);
1486
1399
  if (n) {
1487
- const i = n[1] ? -1 : 1, s = Number(n[2] ?? 0), o = Number(n[3] ?? 0), l = Number(n[4] ?? 0), c = Number(n[5] ?? 0);
1488
- return i * (s * 86400 + o * 3600 + l * 60 + c);
1400
+ const i = n[1] ? -1 : 1, s = Number(n[2] ?? 0), a = Number(n[3] ?? 0), l = Number(n[4] ?? 0), c = Number(n[5] ?? 0);
1401
+ return i * (s * 86400 + a * 3600 + l * 60 + c);
1489
1402
  }
1490
1403
  return 0;
1491
1404
  }
1492
1405
  function h(r) {
1493
1406
  return String(r).padStart(2, "0");
1494
1407
  }
1495
- function Me(r) {
1408
+ function Fe(r) {
1496
1409
  const t = /* @__PURE__ */ new Date();
1497
1410
  try {
1498
- const e = w(r, t), n = Intl.supportedValuesOf("timeZone");
1411
+ const e = _(r, t), n = Intl.supportedValuesOf("timeZone");
1499
1412
  for (const i of n)
1500
- if (w(i, t) === e)
1413
+ if (_(i, t) === e)
1501
1414
  return i;
1502
1415
  } catch {
1503
1416
  return null;
1504
1417
  }
1505
1418
  return null;
1506
1419
  }
1507
- function $e(r) {
1508
- return w(r, /* @__PURE__ */ new Date());
1420
+ function Me(r) {
1421
+ return _(r, /* @__PURE__ */ new Date());
1509
1422
  }
1510
1423
  class Ne {
1511
1424
  constructor(t) {
1512
- a(this, "_url");
1513
- a(this, "_retryInterval");
1514
- a(this, "_abortController", null);
1515
- a(this, "_isConnected", !1);
1516
- a(this, "_reconnectTimeout", null);
1517
- a(this, "_options");
1425
+ o(this, "_url");
1426
+ o(this, "_retryInterval");
1427
+ o(this, "_abortController", null);
1428
+ o(this, "_isConnected", !1);
1429
+ o(this, "_reconnectTimeout", null);
1430
+ o(this, "_options");
1518
1431
  this._url = t.url, this._retryInterval = t.retryInterval ?? 3e3, this._options = t;
1519
1432
  }
1520
1433
  start() {
@@ -1544,9 +1457,9 @@ class Ne {
1544
1457
  signal: (t = this._abortController) == null ? void 0 : t.signal,
1545
1458
  openWhenHidden: !0,
1546
1459
  onopen: (i) => {
1547
- var o, l;
1460
+ var a, l;
1548
1461
  if (i.ok && i.headers.get("content-type") === Y) {
1549
- this._isConnected = !0, (l = (o = this._options).onOpen) == null || l.call(o);
1462
+ this._isConnected = !0, (l = (a = this._options).onOpen) == null || l.call(a);
1550
1463
  return;
1551
1464
  }
1552
1465
  throw new Error(`Unexpected response: ${i.status}`);
@@ -1563,8 +1476,8 @@ class Ne {
1563
1476
  this._isConnected = !1, (s = (i = this._options).onClose) == null || s.call(i), this._scheduleReconnect();
1564
1477
  },
1565
1478
  onerror: (i) => {
1566
- var s, o;
1567
- this._isConnected = !1, (o = (s = this._options).onError) == null || o.call(s, i instanceof Error ? i : new Error(String(i))), this._scheduleReconnect();
1479
+ var s, a;
1480
+ this._isConnected = !1, (a = (s = this._options).onError) == null || a.call(s, i instanceof Error ? i : new Error(String(i))), this._scheduleReconnect();
1568
1481
  }
1569
1482
  });
1570
1483
  } catch (i) {
@@ -1575,11 +1488,11 @@ class Ne {
1575
1488
  return this._isConnected;
1576
1489
  }
1577
1490
  }
1578
- class Le {
1491
+ class $e {
1579
1492
  constructor() {
1580
- a(this, "_currentCount", 0);
1581
- a(this, "_lastResetTime", Date.now());
1582
- a(this, "_lastEventsPerSecond", 0);
1493
+ o(this, "_currentCount", 0);
1494
+ o(this, "_lastResetTime", Date.now());
1495
+ o(this, "_lastEventsPerSecond", 0);
1583
1496
  }
1584
1497
  count() {
1585
1498
  const t = Date.now();
@@ -1592,8 +1505,8 @@ class Le {
1592
1505
  this._currentCount = 0, this._lastEventsPerSecond = 0, this._lastResetTime = Date.now();
1593
1506
  }
1594
1507
  }
1595
- const ke = q("tooltip", () => {
1596
- const r = R({}), t = y(null);
1508
+ const Le = q("tooltip", () => {
1509
+ const r = z({}), t = y(null);
1597
1510
  function e(c) {
1598
1511
  r[c.id] = {
1599
1512
  ...c,
@@ -1609,7 +1522,7 @@ const ke = q("tooltip", () => {
1609
1522
  function s(c) {
1610
1523
  r[c] && (r[c].active = !1, t.value === c && (t.value = null));
1611
1524
  }
1612
- function o(c) {
1525
+ function a(c) {
1613
1526
  i(c);
1614
1527
  }
1615
1528
  function l() {
@@ -1622,17 +1535,17 @@ const ke = q("tooltip", () => {
1622
1535
  unregisterTooltip: n,
1623
1536
  showTooltip: i,
1624
1537
  hideTooltip: s,
1625
- setActiveTooltipId: o,
1538
+ setActiveTooltipId: a,
1626
1539
  clearActiveTooltipId: l
1627
1540
  };
1628
1541
  });
1629
- function Pe(r, t) {
1542
+ function ke(r, t) {
1630
1543
  var e;
1631
1544
  return r("div", {}, (e = t.slots) != null && e.default ? t.slots.default() : []);
1632
1545
  }
1633
- const Re = "x-collection-tooltip-id";
1546
+ const Pe = "x-collection-tooltip-id";
1634
1547
  export {
1635
- Rt as AfterDeserialize,
1548
+ zt as AfterDeserialize,
1636
1549
  It as AppBus,
1637
1550
  Pt as BeforeSerialize,
1638
1551
  Ot as Collection,
@@ -1644,70 +1557,69 @@ export {
1644
1557
  kt as GenericExpose,
1645
1558
  ne as HotkeyManager,
1646
1559
  rt as IS_DEBUG,
1647
- Bt as IgnoreToPlain,
1560
+ Jt as IgnoreToPlain,
1648
1561
  At as IndexedCollection,
1649
- zt as IsOptionalTransformed,
1650
- Zt as Json,
1562
+ Rt as IsOptionalTransformed,
1563
+ Vt as Json,
1651
1564
  Gt as JsonString,
1652
- $t as NamedExecutor,
1565
+ Nt as NamedExecutor,
1653
1566
  Ft as PayloadHttpClient,
1654
1567
  Ct as RingBuffer,
1655
1568
  Ne as SSEManager,
1656
1569
  Wt as Script,
1657
- ae as ScriptRunner,
1658
- Vt as Serialize,
1570
+ Zt as Serialize,
1659
1571
  jt as SerializeId,
1660
- vt as SerializeIds,
1572
+ Bt as SerializeIds,
1661
1573
  se as StructuredLogger,
1662
- $ as Subscribable,
1574
+ N as Subscribable,
1663
1575
  st as SystemClock,
1664
- Re as TooltipAttribute,
1665
- Pe as TooltipRegistrator,
1576
+ Pe as TooltipAttribute,
1577
+ ke as TooltipRegistrator,
1666
1578
  Yt as TypeMap,
1667
1579
  qt as TypeRecord,
1668
- Le as UPSMeter_Service,
1669
- ue as capitalize,
1580
+ $e as UPSMeter_Service,
1581
+ le as capitalize,
1670
1582
  Xt as compareNumber,
1671
1583
  oe as createInstance,
1672
- Se as diffDuration,
1673
- we as diffDurationTable,
1674
- le as dt,
1675
- Te as extractTime,
1676
- be as findMinMaxDates,
1677
- ge as formatDateToMSK,
1678
- pe as formatDatetime,
1584
+ be as diffDuration,
1585
+ Se as diffDurationTable,
1586
+ ce as dt,
1587
+ ge as extractTime,
1588
+ Te as findMinMaxDates,
1589
+ ye as formatDateToMSK,
1590
+ me as formatDatetime,
1679
1591
  ot as formatDatetimeTZ,
1680
- Fe as formatDatetimeTZSpecial,
1592
+ Ce as formatDatetimeTZSpecial,
1681
1593
  ee as generateUUID,
1682
1594
  _e as getDateOnlyDiffFactor,
1683
- ye as getDayOfWeek,
1595
+ pe as getDayOfWeek,
1684
1596
  et as getOnDeserializedMethod,
1685
- $e as getTimezoneOffsetMs,
1686
- ce as globalState,
1687
- fe as isAfterOrEqual,
1597
+ Me as getTimezoneOffsetMs,
1598
+ ae as globalState,
1599
+ ue as isAfterOrEqual,
1688
1600
  ie as isAnyKeyComboActive,
1689
1601
  nt as isConstructor,
1690
- de as isDateInRange,
1691
- he as isDateRangeOverlap,
1692
- Jt as isNullOrUndefined,
1693
- De as isoToDateInput,
1694
- Ee as isoToDateTimeLocalInput,
1602
+ he as isDateInRange,
1603
+ fe as isDateRangeOverlap,
1604
+ vt as isNullOrUndefined,
1605
+ Ie as isoToDateInput,
1606
+ De as isoToDateTimeLocalInput,
1695
1607
  Kt as onDeserialized,
1696
- me as parseDate,
1697
- Ce as parseDuration,
1698
- Me as parseOffsetToTimezone,
1608
+ de as parseDate,
1609
+ Ae as parseDuration,
1610
+ Fe as parseOffsetToTimezone,
1699
1611
  te as profile,
1700
1612
  re as randomString,
1701
1613
  E as removeTime,
1702
- Oe as timeToTimeInput,
1703
- Nt as toInstance,
1614
+ Ee as timeToTimeInput,
1615
+ $t as toInstance,
1704
1616
  xe as toIsoZDate,
1705
- Ie as toIsoZDateTime,
1617
+ we as toIsoZDateTime,
1706
1618
  Lt as toPlain,
1707
- Ae as toTimeHHMMSS,
1708
- xt as useCookie,
1619
+ Oe as toTimeHHMMSS,
1620
+ wt as useCookie,
1709
1621
  Qt as useStorageDebounced,
1710
1622
  Dt as useSubscribableRef,
1711
1623
  Et as useSubscribableRefAuto,
1712
- ke as useTooltipStore
1624
+ Le as useTooltipStore
1713
1625
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@endge/utils",
3
3
  "private": false,
4
- "version": "0.24.2",
4
+ "version": "0.24.3",
5
5
  "type": "module",
6
6
  "module": "./dist/utils.js",
7
7
  "types": "./dist/index.d.ts",
@@ -15,13 +15,6 @@
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
- "scripts": {
19
- "clean": "rimraf dist tsconfig.tsbuildinfo",
20
- "dev": "vite build --watch",
21
- "dev:watch": "vite build --watch",
22
- "build": "vite build",
23
- "test": "vitest"
24
- },
25
18
  "dependencies": {
26
19
  "@microsoft/fetch-event-source": "^2.0.1",
27
20
  "class-transformer": "^0.5.1",
@@ -48,5 +41,12 @@
48
41
  "vite-plugin-dts": "^4.5.0",
49
42
  "vitest": "^3.2.4",
50
43
  "vue-tsc": "^2.2.0"
44
+ },
45
+ "scripts": {
46
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
47
+ "dev": "vite build --watch",
48
+ "dev:watch": "vite build --watch",
49
+ "build": "vite build",
50
+ "test": "vitest"
51
51
  }
52
- }
52
+ }