@endge/utils 0.24.1 → 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,16 +1,16 @@
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);
3
+ var o = (r, t, e) => k(r, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { ref as y, watch as O, triggerRef as A, onScopeDispose as P, reactive as z } from "vue";
5
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 w, isEqual as V, isBefore as F, startOfDay as p, endOfDay as Z } from "date-fns";
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
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";
@@ -19,7 +19,7 @@ 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
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, () => {
@@ -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
@@ -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,93 +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((f) => [f, this.wrapIfAsync(t[f])])
1215
- ), s = Array.from(e), o = s.length > 0 ? `
1216
-
1217
- expose({ ${s.join(", ")} });
1218
- ` : "", l = `${this.script}${o}`;
1219
- return await new Function(
1220
- ...n,
1221
- `"use strict"; return (async () => { ${l} })();`
1222
- )(...Object.values(i));
1223
- }
1224
- /**
1225
- * Синхронно вычисляет выражение в контексте.
1226
- * Используется для интерполяций, :bind, v-if и т.п.
1227
- */
1228
- runSync(t, e = /* @__PURE__ */ new Set()) {
1229
- const n = Object.keys(t), i = Object.values(t), s = Array.from(e), o = s.length > 0 ? `
1230
-
1231
- expose({ ${s.join(", ")} });
1232
- ` : "";
1233
- try {
1234
- new Function(
1235
- ...n,
1236
- `"use strict"; ${this.script}${o};`
1237
- )(...i);
1238
- } catch (l) {
1239
- console.warn(
1240
- "(ScriptRunner.runSync): Ошибка в выражении:",
1241
- this.script,
1242
- l
1243
- );
1244
- }
1245
- }
1246
- /**
1247
- * Синхронно вычисляет выражение в контексте.
1248
- * Используется для интерполяций, :bind, v-if и т.п.
1249
- */
1250
- evaluate(t) {
1251
- const e = Object.keys(t), n = Object.values(t);
1252
- console.log(t);
1253
- try {
1254
- return new Function(
1255
- ...e,
1256
- `"use strict"; return (${this.script});`
1257
- )(...n);
1258
- } catch (i) {
1259
- console.warn(
1260
- "(ScriptRunner.runSync): Ошибка в выражении:",
1261
- this.script,
1262
- i
1263
- );
1264
- return;
1265
- }
1266
- }
1267
- /**
1268
- * Выполняет внутренний шаг wrapIfAsync для ScriptRunner.
1269
- */
1270
- wrapIfAsync(t) {
1271
- if (typeof t != "object" || t === null) return t;
1272
- const e = {};
1273
- for (const [n, i] of Object.entries(t))
1274
- typeof i == "function" ? e[n] = (...s) => {
1275
- const o = i(...s);
1276
- return o instanceof Promise, o;
1277
- } : e[n] = i;
1278
- return e;
1279
- }
1280
- }
1281
1201
  const it = /* @__PURE__ */ new WeakMap();
1282
- function ce(r) {
1202
+ function ae(r) {
1283
1203
  let t;
1284
1204
  return () => (t || (t = r(), it.set(r, t)), t);
1285
1205
  }
1286
1206
  const st = {
1287
- DateTime: J,
1207
+ DateTime: v,
1288
1208
  toDateTime(r) {
1289
1209
  return this.DateTime.fromJSDate(r);
1290
1210
  },
@@ -1312,22 +1232,22 @@ const st = {
1312
1232
  getZone() {
1313
1233
  return this.DateTime.now().zone;
1314
1234
  }
1315
- }, le = (r) => st.toDateTime(r);
1316
- function ue(r) {
1235
+ }, ce = (r) => st.toDateTime(r);
1236
+ function le(r) {
1317
1237
  return String(r).charAt(0).toUpperCase() + String(r).slice(1);
1318
1238
  }
1319
- function fe(r, t) {
1320
- return w(r, t) || V(r, t);
1239
+ function ue(r, t) {
1240
+ return x(r, t) || Z(r, t);
1321
1241
  }
1322
- function he(r, t, e, n) {
1323
- const i = p(r), s = p(t), o = p(e), l = p(n);
1324
- return !F(s, o) && !w(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);
1325
1245
  }
1326
- function de(r, t, e) {
1327
- return !F(r, p(t)) && !w(r, Z(e));
1246
+ function he(r, t, e) {
1247
+ return !F(r, p(t)) && !x(r, V(e));
1328
1248
  }
1329
- const me = (r) => r && new Date(r);
1330
- 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 = {}) {
1331
1251
  return r && T(r, t, e);
1332
1252
  }
1333
1253
  function ot(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
@@ -1342,36 +1262,36 @@ function ot(r, t = "HH:mm dd.MM.yyyy", e = {}, n = !0) {
1342
1262
  r = new Date(r.toString());
1343
1263
  return n ? T(r, t, e) : T(G(r, "utc"), t, e);
1344
1264
  }
1345
- function ye(r) {
1265
+ function pe(r) {
1346
1266
  const t = { weekday: "short" }, e = new Intl.DateTimeFormat("ru-RU", t).format(r);
1347
1267
  return e.charAt(0).toUpperCase() + e.slice(1);
1348
1268
  }
1349
- function ge(r) {
1350
- 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();
1351
- 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}`;
1352
1272
  }
1353
- function Te(r, t = !0) {
1273
+ function ge(r, t = !0) {
1354
1274
  return ot(r, "HH:mm", {}, t);
1355
1275
  }
1356
- function be(r) {
1276
+ function Te(r) {
1357
1277
  const t = Array.from(r), e = Math.min(...t.map((i) => i.getTime())), n = Math.max(...t.map((i) => i.getTime()));
1358
1278
  return {
1359
1279
  minDate: new Date(e),
1360
1280
  maxDate: new Date(n)
1361
1281
  };
1362
1282
  }
1363
- function Se(r, t) {
1364
- 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);
1365
1285
  return n || i ? `${e > 0 ? "-" : "+"}${h(n)}:${h(i)}` : "";
1366
1286
  }
1367
- function _e(r, t) {
1368
- 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);
1369
1289
  return n || i ? `${e > 0 ? "-" : ""}${h(n)}:${h(i)}` : "";
1370
1290
  }
1371
1291
  function E(r = /* @__PURE__ */ new Date()) {
1372
1292
  return new Date(r.getFullYear(), r.getMonth(), r.getDate());
1373
1293
  }
1374
- function we(r, t) {
1294
+ function _e(r, t) {
1375
1295
  const e = K(E(r), E(t));
1376
1296
  return e ? e > 7 ? {
1377
1297
  variant: "red",
@@ -1391,36 +1311,36 @@ function xe(r) {
1391
1311
  const e = String(r ?? "").trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);
1392
1312
  if (!e)
1393
1313
  return null;
1394
- 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));
1395
- 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();
1396
1316
  }
1397
- function Ie(r) {
1317
+ function we(r) {
1398
1318
  const t = String(r ?? "").trim();
1399
1319
  if (!t)
1400
1320
  return null;
1401
1321
  const e = t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/);
1402
1322
  if (e) {
1403
- 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);
1404
1324
  return Number.isNaN(g.getTime()) ? null : g.toISOString();
1405
1325
  }
1406
1326
  const n = new Date(t);
1407
1327
  return Number.isNaN(n.getTime()) ? null : n.toISOString();
1408
1328
  }
1409
- function De(r) {
1329
+ function Ie(r) {
1410
1330
  const t = String(r ?? "").trim();
1411
1331
  return t ? t.slice(0, 10) : "";
1412
1332
  }
1413
- function Ee(r) {
1333
+ function De(r) {
1414
1334
  const t = String(r ?? "").trim();
1415
1335
  if (!t)
1416
1336
  return "";
1417
1337
  const e = new Date(t);
1418
1338
  if (Number.isNaN(e.getTime()))
1419
1339
  return t.slice(0, 16);
1420
- const n = e.getFullYear(), i = h(e.getMonth() + 1), s = h(e.getDate()), o = h(e.getHours()), l = h(e.getMinutes());
1421
- 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}`;
1422
1342
  }
1423
- function Oe(r) {
1343
+ function Ee(r) {
1424
1344
  if (r == null)
1425
1345
  return "";
1426
1346
  const t = String(r).trim();
@@ -1432,7 +1352,7 @@ function Oe(r) {
1432
1352
  const n = t.match(/^(\d{2}):(\d{2})$/);
1433
1353
  return n ? `${n[1]}:${n[2]}` : "";
1434
1354
  }
1435
- function Ae(r) {
1355
+ function Oe(r) {
1436
1356
  if (r == null)
1437
1357
  return null;
1438
1358
  const t = String(r).trim();
@@ -1444,11 +1364,11 @@ function Ae(r) {
1444
1364
  const n = t.match(/^(\d{2}):(\d{2})$/);
1445
1365
  return n ? `${n[1]}:${n[2]}:00` : null;
1446
1366
  }
1447
- function Ce(r) {
1448
- 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);
1449
1369
  return `${e}${h(n)}:${h(i)}`;
1450
1370
  }
1451
- function Fe(r = null, t = "dd", e = {}) {
1371
+ function Ce(r = null, t = "dd", e = {}) {
1452
1372
  const n = at(r);
1453
1373
  if (!n)
1454
1374
  return "";
@@ -1461,7 +1381,7 @@ function at(r) {
1461
1381
  const t = typeof r == "string" ? new Date(r) : r instanceof Date ? r : new Date(r.toString());
1462
1382
  return Number.isNaN(t.getTime()) ? null : t;
1463
1383
  }
1464
- function x(r) {
1384
+ function w(r) {
1465
1385
  const t = Math.abs(r);
1466
1386
  return {
1467
1387
  hours: Math.floor(t / 3600) % 24,
@@ -1477,15 +1397,15 @@ function ct(r) {
1477
1397
  return (e[1] ? -1 : 1) * (Number(e[2]) * 3600 + Number(e[3]) * 60 + Number(e[4] ?? 0));
1478
1398
  const n = t.match(/^(-)?P(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/i);
1479
1399
  if (n) {
1480
- 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);
1481
- 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);
1482
1402
  }
1483
1403
  return 0;
1484
1404
  }
1485
1405
  function h(r) {
1486
1406
  return String(r).padStart(2, "0");
1487
1407
  }
1488
- function Me(r) {
1408
+ function Fe(r) {
1489
1409
  const t = /* @__PURE__ */ new Date();
1490
1410
  try {
1491
1411
  const e = _(r, t), n = Intl.supportedValuesOf("timeZone");
@@ -1497,17 +1417,17 @@ function Me(r) {
1497
1417
  }
1498
1418
  return null;
1499
1419
  }
1500
- function $e(r) {
1420
+ function Me(r) {
1501
1421
  return _(r, /* @__PURE__ */ new Date());
1502
1422
  }
1503
1423
  class Ne {
1504
1424
  constructor(t) {
1505
- a(this, "_url");
1506
- a(this, "_retryInterval");
1507
- a(this, "_abortController", null);
1508
- a(this, "_isConnected", !1);
1509
- a(this, "_reconnectTimeout", null);
1510
- 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");
1511
1431
  this._url = t.url, this._retryInterval = t.retryInterval ?? 3e3, this._options = t;
1512
1432
  }
1513
1433
  start() {
@@ -1537,9 +1457,9 @@ class Ne {
1537
1457
  signal: (t = this._abortController) == null ? void 0 : t.signal,
1538
1458
  openWhenHidden: !0,
1539
1459
  onopen: (i) => {
1540
- var o, l;
1460
+ var a, l;
1541
1461
  if (i.ok && i.headers.get("content-type") === Y) {
1542
- 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);
1543
1463
  return;
1544
1464
  }
1545
1465
  throw new Error(`Unexpected response: ${i.status}`);
@@ -1556,8 +1476,8 @@ class Ne {
1556
1476
  this._isConnected = !1, (s = (i = this._options).onClose) == null || s.call(i), this._scheduleReconnect();
1557
1477
  },
1558
1478
  onerror: (i) => {
1559
- var s, o;
1560
- 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();
1561
1481
  }
1562
1482
  });
1563
1483
  } catch (i) {
@@ -1568,11 +1488,11 @@ class Ne {
1568
1488
  return this._isConnected;
1569
1489
  }
1570
1490
  }
1571
- class Le {
1491
+ class $e {
1572
1492
  constructor() {
1573
- a(this, "_currentCount", 0);
1574
- a(this, "_lastResetTime", Date.now());
1575
- a(this, "_lastEventsPerSecond", 0);
1493
+ o(this, "_currentCount", 0);
1494
+ o(this, "_lastResetTime", Date.now());
1495
+ o(this, "_lastEventsPerSecond", 0);
1576
1496
  }
1577
1497
  count() {
1578
1498
  const t = Date.now();
@@ -1585,7 +1505,7 @@ class Le {
1585
1505
  this._currentCount = 0, this._lastEventsPerSecond = 0, this._lastResetTime = Date.now();
1586
1506
  }
1587
1507
  }
1588
- const ke = q("tooltip", () => {
1508
+ const Le = q("tooltip", () => {
1589
1509
  const r = z({}), t = y(null);
1590
1510
  function e(c) {
1591
1511
  r[c.id] = {
@@ -1602,7 +1522,7 @@ const ke = q("tooltip", () => {
1602
1522
  function s(c) {
1603
1523
  r[c] && (r[c].active = !1, t.value === c && (t.value = null));
1604
1524
  }
1605
- function o(c) {
1525
+ function a(c) {
1606
1526
  i(c);
1607
1527
  }
1608
1528
  function l() {
@@ -1615,15 +1535,15 @@ const ke = q("tooltip", () => {
1615
1535
  unregisterTooltip: n,
1616
1536
  showTooltip: i,
1617
1537
  hideTooltip: s,
1618
- setActiveTooltipId: o,
1538
+ setActiveTooltipId: a,
1619
1539
  clearActiveTooltipId: l
1620
1540
  };
1621
1541
  });
1622
- function Pe(r, t) {
1542
+ function ke(r, t) {
1623
1543
  var e;
1624
1544
  return r("div", {}, (e = t.slots) != null && e.default ? t.slots.default() : []);
1625
1545
  }
1626
- const ze = "x-collection-tooltip-id";
1546
+ const Pe = "x-collection-tooltip-id";
1627
1547
  export {
1628
1548
  zt as AfterDeserialize,
1629
1549
  It as AppBus,
@@ -1637,70 +1557,69 @@ export {
1637
1557
  kt as GenericExpose,
1638
1558
  ne as HotkeyManager,
1639
1559
  rt as IS_DEBUG,
1640
- Bt as IgnoreToPlain,
1560
+ Jt as IgnoreToPlain,
1641
1561
  At as IndexedCollection,
1642
1562
  Rt as IsOptionalTransformed,
1643
- Zt as Json,
1563
+ Vt as Json,
1644
1564
  Gt as JsonString,
1645
- $t as NamedExecutor,
1565
+ Nt as NamedExecutor,
1646
1566
  Ft as PayloadHttpClient,
1647
1567
  Ct as RingBuffer,
1648
1568
  Ne as SSEManager,
1649
1569
  Wt as Script,
1650
- ae as ScriptRunner,
1651
- Vt as Serialize,
1570
+ Zt as Serialize,
1652
1571
  jt as SerializeId,
1653
- vt as SerializeIds,
1572
+ Bt as SerializeIds,
1654
1573
  se as StructuredLogger,
1655
- $ as Subscribable,
1574
+ N as Subscribable,
1656
1575
  st as SystemClock,
1657
- ze as TooltipAttribute,
1658
- Pe as TooltipRegistrator,
1576
+ Pe as TooltipAttribute,
1577
+ ke as TooltipRegistrator,
1659
1578
  Yt as TypeMap,
1660
1579
  qt as TypeRecord,
1661
- Le as UPSMeter_Service,
1662
- ue as capitalize,
1580
+ $e as UPSMeter_Service,
1581
+ le as capitalize,
1663
1582
  Xt as compareNumber,
1664
1583
  oe as createInstance,
1665
- Se as diffDuration,
1666
- _e as diffDurationTable,
1667
- le as dt,
1668
- Te as extractTime,
1669
- be as findMinMaxDates,
1670
- ge as formatDateToMSK,
1671
- 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,
1672
1591
  ot as formatDatetimeTZ,
1673
- Fe as formatDatetimeTZSpecial,
1592
+ Ce as formatDatetimeTZSpecial,
1674
1593
  ee as generateUUID,
1675
- we as getDateOnlyDiffFactor,
1676
- ye as getDayOfWeek,
1594
+ _e as getDateOnlyDiffFactor,
1595
+ pe as getDayOfWeek,
1677
1596
  et as getOnDeserializedMethod,
1678
- $e as getTimezoneOffsetMs,
1679
- ce as globalState,
1680
- fe as isAfterOrEqual,
1597
+ Me as getTimezoneOffsetMs,
1598
+ ae as globalState,
1599
+ ue as isAfterOrEqual,
1681
1600
  ie as isAnyKeyComboActive,
1682
1601
  nt as isConstructor,
1683
- de as isDateInRange,
1684
- he as isDateRangeOverlap,
1685
- Jt as isNullOrUndefined,
1686
- De as isoToDateInput,
1687
- Ee as isoToDateTimeLocalInput,
1602
+ he as isDateInRange,
1603
+ fe as isDateRangeOverlap,
1604
+ vt as isNullOrUndefined,
1605
+ Ie as isoToDateInput,
1606
+ De as isoToDateTimeLocalInput,
1688
1607
  Kt as onDeserialized,
1689
- me as parseDate,
1690
- Ce as parseDuration,
1691
- Me as parseOffsetToTimezone,
1608
+ de as parseDate,
1609
+ Ae as parseDuration,
1610
+ Fe as parseOffsetToTimezone,
1692
1611
  te as profile,
1693
1612
  re as randomString,
1694
1613
  E as removeTime,
1695
- Oe as timeToTimeInput,
1696
- Nt as toInstance,
1614
+ Ee as timeToTimeInput,
1615
+ $t as toInstance,
1697
1616
  xe as toIsoZDate,
1698
- Ie as toIsoZDateTime,
1617
+ we as toIsoZDateTime,
1699
1618
  Lt as toPlain,
1700
- Ae as toTimeHHMMSS,
1701
- xt as useCookie,
1619
+ Oe as toTimeHHMMSS,
1620
+ wt as useCookie,
1702
1621
  Qt as useStorageDebounced,
1703
1622
  Dt as useSubscribableRef,
1704
1623
  Et as useSubscribableRefAuto,
1705
- ke as useTooltipStore
1624
+ Le as useTooltipStore
1706
1625
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@endge/utils",
3
3
  "private": false,
4
- "version": "0.24.1",
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
+ }