@endge/utils 0.25.6 → 0.26.0
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/collection/collection.d.ts +2 -2
- package/dist/events/Subscribable.d.ts +12 -0
- package/dist/index.d.ts +3 -2
- package/dist/shared/types/getter-fn.d.ts +1 -1
- package/dist/shared/utils/compare.d.ts +1 -1
- package/dist/shared/utils/time.d.ts +4 -4
- package/dist/tools/console.d.ts +2 -2
- package/dist/tools/keyboard.d.ts +2 -2
- package/dist/tools/logs.d.ts +3 -3
- package/dist/tools/tools.types.d.ts +2 -2
- package/dist/utils.js +78 -77
- package/package.json +3 -2
- package/dist/events/ChangeNotifier.d.ts +0 -8
- /package/dist/shared/types/{maybe.d.ts → Maybe.d.ts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CollectionEntity, CollectionEvents } from './collection.types';
|
|
2
|
-
import {
|
|
2
|
+
import { Subscribable } from '../events/Subscribable';
|
|
3
3
|
/**
|
|
4
4
|
* Описывает ответственность Collection в архитектуре проекта.
|
|
5
5
|
*/
|
|
6
|
-
export declare class Collection<T extends CollectionEntity> extends
|
|
6
|
+
export declare class Collection<T extends CollectionEntity> extends Subscribable {
|
|
7
7
|
private _items;
|
|
8
8
|
private _indices;
|
|
9
9
|
private _rootIds;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Минимальный framework-independent contract объекта с подпиской на изменения. */
|
|
2
|
+
export interface SubscribableLike {
|
|
3
|
+
subscribe: (listener: () => void) => () => void;
|
|
4
|
+
}
|
|
5
|
+
/** Публикует изменения владельца состояния без зависимости от UI framework. */
|
|
6
|
+
export declare class Subscribable implements SubscribableLike {
|
|
7
|
+
private readonly _subscribers;
|
|
8
|
+
/** Подписывает listener и возвращает идемпотентную функцию отписки. */
|
|
9
|
+
subscribe(listener: () => void): () => void;
|
|
10
|
+
/** Уведомляет текущих подписчиков об изменении владельца состояния. */
|
|
11
|
+
notify(): void;
|
|
12
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './collection/indexed-collection';
|
|
|
4
4
|
export * from './collection/RingBuffer';
|
|
5
5
|
export * from './database/PayloadHttpClient';
|
|
6
6
|
export * from './events/EventBus';
|
|
7
|
+
export * from './events/Subscribable';
|
|
7
8
|
export * from './execute/delay-executor';
|
|
8
9
|
export * from './execute/NamedExecutor';
|
|
9
10
|
export * from './serialize/decorators/json';
|
|
@@ -15,8 +16,8 @@ export * from './serialize/decorators/typeRecord';
|
|
|
15
16
|
export * from './serialize/Serialize';
|
|
16
17
|
export * from './shared/serialize/decorator';
|
|
17
18
|
export { toInstance, toPlain } from './shared/serialize/parse';
|
|
18
|
-
export { isNullOrUndefined } from './shared/types/
|
|
19
|
-
export type { Maybe as SharedMaybe } from './shared/types/
|
|
19
|
+
export { isNullOrUndefined } from './shared/types/Maybe';
|
|
20
|
+
export type { Maybe as SharedMaybe } from './shared/types/Maybe';
|
|
20
21
|
export * from './tools/compare';
|
|
21
22
|
export * from './tools/console';
|
|
22
23
|
export * from './tools/debug';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function compareNumber(a:
|
|
1
|
+
export declare function compareNumber(a: number, b: number): number;
|
|
@@ -8,8 +8,8 @@ export declare function isDateInRange(date: Date, validFrom: Date, validTo: Date
|
|
|
8
8
|
export declare const parseDate: (isoString: string) => "" | Date;
|
|
9
9
|
export declare function formatDatetime(date: Date, formatString?: string, options?: {}): string;
|
|
10
10
|
export declare function formatDatetimeTZ(date: Date | string | object, formatString?: string, options?: {}, isLocalTime?: boolean): string;
|
|
11
|
-
export declare function getDayOfWeek(date:
|
|
12
|
-
export declare function formatDateToMSK(date:
|
|
11
|
+
export declare function getDayOfWeek(date: Date | number): string;
|
|
12
|
+
export declare function formatDateToMSK(date: Date | string | number): string;
|
|
13
13
|
export declare function extractTime(date: Date | string | object, isLocalTime?: boolean): string;
|
|
14
14
|
export declare function findMinMaxDates(dates: Set<Date>): {
|
|
15
15
|
minDate: Date;
|
|
@@ -26,9 +26,9 @@ export declare function toIsoZDate(value: string): string | null;
|
|
|
26
26
|
export declare function toIsoZDateTime(value: string): string | null;
|
|
27
27
|
export declare function isoToDateInput(value: unknown): string;
|
|
28
28
|
export declare function isoToDateTimeLocalInput(value: unknown): string;
|
|
29
|
-
/**
|
|
29
|
+
/** Форматирует DateTime как `HH:mm` в настроенном часовом поясе IANA или локальном поясе браузера. */
|
|
30
30
|
export declare function isoDateTimeToTimeInput(value: unknown, timezone?: unknown): string;
|
|
31
|
-
/**
|
|
31
|
+
/** Заменяет только часы и минуты, сохраняя календарную дату DateTime в выбранном часовом поясе. */
|
|
32
32
|
export declare function mergeTimeIntoDateTime(value: unknown, time: unknown, timezone?: unknown): string | null;
|
|
33
33
|
export declare function timeToTimeInput(value: unknown): string;
|
|
34
34
|
export declare function toTimeHHMMSS(value: unknown): string | null;
|
package/dist/tools/console.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Возвращает строку ограниченной длины без обхода или удержания переданного значения. */
|
|
2
2
|
export declare function consoleValueSummary(value: unknown): string;
|
|
3
|
-
/**
|
|
3
|
+
/** Возвращает метаданные Error как текст, не передавая объект Error в Console. */
|
|
4
4
|
export declare function consoleErrorSummary(error: unknown): string;
|
package/dist/tools/keyboard.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface KeyboardStateSnapshot {
|
|
|
15
15
|
code: string[];
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/** Возвращает общий snapshot клавиатуры уровня document, лениво устанавливая один tracker. */
|
|
19
19
|
export declare function getKeyboardStateSnapshot(target: Document): KeyboardStateSnapshot;
|
|
20
|
-
/**
|
|
20
|
+
/** Подписывается на общее состояние клавиатуры уровня document и сразу публикует его snapshot. */
|
|
21
21
|
export declare function subscribeKeyboardState(target: Document, listener: (snapshot: KeyboardStateSnapshot) => void): () => void;
|
package/dist/tools/logs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Subscribable } from '../events/Subscribable';
|
|
2
2
|
/**
|
|
3
3
|
* Структурированная запись лога.
|
|
4
4
|
*
|
|
@@ -30,7 +30,7 @@ export interface StructuredLogEntry {
|
|
|
30
30
|
actions?: Array<{
|
|
31
31
|
icon: string;
|
|
32
32
|
tooltip?: string;
|
|
33
|
-
handler
|
|
33
|
+
handler?: () => void;
|
|
34
34
|
}>;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -61,7 +61,7 @@ export interface StructuredLogEntry {
|
|
|
61
61
|
* // Получаем все логи
|
|
62
62
|
* const logs = logger.getLogs()
|
|
63
63
|
*/
|
|
64
|
-
export declare class StructuredLogger extends
|
|
64
|
+
export declare class StructuredLogger extends Subscribable {
|
|
65
65
|
/** Массив всех логов */
|
|
66
66
|
private _logs;
|
|
67
67
|
/** Текущий контекст (иерархия) */
|
|
@@ -45,7 +45,7 @@ export type Awaitable<T> = T | Promise<T>;
|
|
|
45
45
|
*/
|
|
46
46
|
export type VoidFn = () => void;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Alias для обратной совместимости, используемый legacy-пакетами.
|
|
49
49
|
*/
|
|
50
50
|
export type VoidFunction = VoidFn;
|
|
51
51
|
/**
|
|
@@ -53,7 +53,7 @@ export type VoidFunction = VoidFn;
|
|
|
53
53
|
*/
|
|
54
54
|
export type Dictionary<T = any> = Record<string, T>;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Нестрогая запись объекта для обратной совместимости.
|
|
57
57
|
*/
|
|
58
58
|
export type AnyRecord = Record<string, any>;
|
|
59
59
|
/**
|
package/dist/utils.js
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var G = (r, t, e) => t in r ? V(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var o = (r, t, e) => G(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { Transform as f, TransformationType as _, plainToInstance as
|
|
4
|
+
import { Transform as f, TransformationType as _, plainToInstance as b, instanceToPlain as T, Expose as J } from "class-transformer";
|
|
5
5
|
import { IsOptional as Z } from "class-validator";
|
|
6
6
|
import "reflect-metadata";
|
|
7
7
|
import { v4 as W } from "uuid";
|
|
8
8
|
import { DateTime as Y } from "ts-luxon";
|
|
9
9
|
import { differenceInSeconds as N, format as g, differenceInCalendarDays as q, isAfter as D, isEqual as Q, isBefore as z, startOfDay as p, endOfDay as X } from "date-fns";
|
|
10
|
-
import { utcToZonedTime as I, getTimezoneOffset as
|
|
10
|
+
import { utcToZonedTime as I, getTimezoneOffset as x, zonedTimeToUtc as v } from "date-fns-tz";
|
|
11
11
|
import { fetchEventSource as tt, EventStreamContentType as et } from "@microsoft/fetch-event-source";
|
|
12
12
|
var m = /* @__PURE__ */ ((r) => (r.Add = "add", r.Remove = "remove", r.Update = "update", r.IndexCreate = "indexCreate", r))(m || {});
|
|
13
13
|
class P {
|
|
14
|
-
constructor() {
|
|
15
|
-
o(this, "_listeners", /* @__PURE__ */ new Set());
|
|
16
|
-
}
|
|
17
|
-
/** Подписывает listener на изменения utility owner. */
|
|
18
|
-
subscribe(t) {
|
|
19
|
-
return this._listeners.add(t), () => {
|
|
20
|
-
this._listeners.delete(t);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/** Уведомляет текущих listeners об изменении. */
|
|
24
|
-
notify() {
|
|
25
|
-
for (const t of this._listeners)
|
|
26
|
-
t();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
class H {
|
|
30
14
|
/**
|
|
31
15
|
* Создает экземпляр EventBus и подготавливает базовое состояние.
|
|
32
16
|
*/
|
|
@@ -152,8 +136,24 @@ class H {
|
|
|
152
136
|
t ? (e = this._listeners.get(t)) == null || e.clear() : this._listeners.clear();
|
|
153
137
|
}
|
|
154
138
|
}
|
|
155
|
-
const
|
|
156
|
-
class
|
|
139
|
+
const xt = new P(Object.keys({}));
|
|
140
|
+
class H {
|
|
141
|
+
constructor() {
|
|
142
|
+
o(this, "_subscribers", /* @__PURE__ */ new Set());
|
|
143
|
+
}
|
|
144
|
+
/** Подписывает listener и возвращает идемпотентную функцию отписки. */
|
|
145
|
+
subscribe(t) {
|
|
146
|
+
return this._subscribers.add(t), () => {
|
|
147
|
+
this._subscribers.delete(t);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Уведомляет текущих подписчиков об изменении владельца состояния. */
|
|
151
|
+
notify() {
|
|
152
|
+
for (const t of this._subscribers)
|
|
153
|
+
t();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
class wt extends H {
|
|
157
157
|
/**
|
|
158
158
|
* Создает экземпляр Collection и подготавливает базовое состояние.
|
|
159
159
|
*/
|
|
@@ -163,7 +163,7 @@ class xt extends P {
|
|
|
163
163
|
o(this, "_indices", /* @__PURE__ */ new Map());
|
|
164
164
|
o(this, "_rootIds", /* @__PURE__ */ new Set());
|
|
165
165
|
o(this, "_bus");
|
|
166
|
-
this._bus = new
|
|
166
|
+
this._bus = new P(Object.values(m)), e.length && this.add(e), this._createIndex("id");
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* Выполняет действие add в рамках ответственности Collection.
|
|
@@ -631,12 +631,12 @@ class At {
|
|
|
631
631
|
this._delayTimer && clearTimeout(this._delayTimer), this._maxTimer && clearTimeout(this._maxTimer), this._delayTimer = null, this._maxTimer = null;
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function w(r) {
|
|
635
635
|
var t;
|
|
636
636
|
return r == null ? String(r) : typeof r == "string" ? `string(${r.length})` : typeof r != "object" ? `${typeof r}(${String(r)})` : Array.isArray(r) ? `Array(${r.length})` : r instanceof Map ? `Map(${r.size})` : r instanceof Set ? `Set(${r.size})` : ((t = r.constructor) == null ? void 0 : t.name) || "Object";
|
|
637
637
|
}
|
|
638
638
|
function U(r) {
|
|
639
|
-
return r instanceof Error ? `${r.name}: ${r.message}` :
|
|
639
|
+
return r instanceof Error ? `${r.name}: ${r.message}` : w(r);
|
|
640
640
|
}
|
|
641
641
|
class Ot {
|
|
642
642
|
/**
|
|
@@ -755,15 +755,15 @@ function Mt() {
|
|
|
755
755
|
)(r, t);
|
|
756
756
|
};
|
|
757
757
|
}
|
|
758
|
-
const
|
|
758
|
+
const K = Symbol("onDeserialized");
|
|
759
759
|
function $t() {
|
|
760
760
|
return function(r, t) {
|
|
761
|
-
Reflect.defineMetadata(
|
|
761
|
+
Reflect.defineMetadata(K, t, r);
|
|
762
762
|
};
|
|
763
763
|
}
|
|
764
764
|
function rt(r) {
|
|
765
765
|
const t = Reflect.getMetadata(
|
|
766
|
-
|
|
766
|
+
K,
|
|
767
767
|
r
|
|
768
768
|
);
|
|
769
769
|
return t ? r[t].bind(r) : null;
|
|
@@ -779,7 +779,7 @@ function Ft() {
|
|
|
779
779
|
)(r, t);
|
|
780
780
|
};
|
|
781
781
|
}
|
|
782
|
-
function
|
|
782
|
+
function Lt(r, t) {
|
|
783
783
|
return f(({ value: e, type: n }) => {
|
|
784
784
|
if (!e)
|
|
785
785
|
return /* @__PURE__ */ new Map();
|
|
@@ -787,7 +787,7 @@ function kt(r, t) {
|
|
|
787
787
|
if (Array.isArray(e))
|
|
788
788
|
return t ? new Map(
|
|
789
789
|
e.map((i) => {
|
|
790
|
-
const s =
|
|
790
|
+
const s = b(r, i);
|
|
791
791
|
return [s[t], s];
|
|
792
792
|
})
|
|
793
793
|
) : (console.warn(
|
|
@@ -802,25 +802,25 @@ function kt(r, t) {
|
|
|
802
802
|
})
|
|
803
803
|
);
|
|
804
804
|
}
|
|
805
|
-
return console.warn(`[TypeMap] Expected object or array, got ${
|
|
805
|
+
return console.warn(`[TypeMap] Expected object or array, got ${w(e)}`), /* @__PURE__ */ new Map();
|
|
806
806
|
}
|
|
807
|
-
return n === _.CLASS_TO_PLAIN ? e instanceof Map ? Array.from(e.values()).map((i) =>
|
|
807
|
+
return n === _.CLASS_TO_PLAIN ? e instanceof Map ? Array.from(e.values()).map((i) => T(i)) : (console.warn(`[TypeMap] Expected Map, got ${w(e)}`), t ? [] : {}) : (console.warn(`[TypeMap] Unexpected transformation type: ${String(n)}`), e);
|
|
808
808
|
});
|
|
809
809
|
}
|
|
810
|
-
function
|
|
810
|
+
function kt(r) {
|
|
811
811
|
return f(({ value: t, type: e }) => {
|
|
812
812
|
if (!t || typeof t != "object")
|
|
813
813
|
return {};
|
|
814
814
|
if (e === _.PLAIN_TO_CLASS) {
|
|
815
815
|
const n = {};
|
|
816
816
|
for (const i of Object.keys(t))
|
|
817
|
-
n[i] =
|
|
817
|
+
n[i] = b(r, t[i]);
|
|
818
818
|
return n;
|
|
819
819
|
}
|
|
820
820
|
if (e === _.CLASS_TO_PLAIN) {
|
|
821
821
|
const n = {};
|
|
822
822
|
for (const i of Object.keys(t))
|
|
823
|
-
n[i] =
|
|
823
|
+
n[i] = T(t[i]);
|
|
824
824
|
return n;
|
|
825
825
|
}
|
|
826
826
|
return t;
|
|
@@ -831,7 +831,7 @@ class Nt {
|
|
|
831
831
|
* Выполняет действие toPlain в рамках ответственности Serialize.
|
|
832
832
|
*/
|
|
833
833
|
static toPlain(t) {
|
|
834
|
-
return
|
|
834
|
+
return T(t, {
|
|
835
835
|
exposeDefaultValues: !0,
|
|
836
836
|
excludeExtraneousValues: !0
|
|
837
837
|
});
|
|
@@ -840,7 +840,7 @@ class Nt {
|
|
|
840
840
|
* Выполняет действие fromJSON в рамках ответственности Serialize.
|
|
841
841
|
*/
|
|
842
842
|
static fromJSON(t, e) {
|
|
843
|
-
const n =
|
|
843
|
+
const n = b(t, e, {
|
|
844
844
|
exposeDefaultValues: !0,
|
|
845
845
|
excludeExtraneousValues: !0
|
|
846
846
|
}), i = rt(n);
|
|
@@ -866,10 +866,10 @@ function Ut(r) {
|
|
|
866
866
|
f(({ value: n }) => n === null ? void 0 : n, { toPlainOnly: !0 })(t, e), Z(r)(t, e);
|
|
867
867
|
};
|
|
868
868
|
}
|
|
869
|
-
function
|
|
869
|
+
function Kt() {
|
|
870
870
|
return f(({ value: r, type: t }) => t === _.PLAIN_TO_CLASS ? r == null ? void 0 : r.id : r);
|
|
871
871
|
}
|
|
872
|
-
function
|
|
872
|
+
function Rt(r) {
|
|
873
873
|
return f(({ value: t, type: e }) => e === _.PLAIN_TO_CLASS ? t == null ? void 0 : t.map((n) => n == null ? void 0 : n[r]) : t);
|
|
874
874
|
}
|
|
875
875
|
function jt() {
|
|
@@ -879,16 +879,16 @@ function Bt() {
|
|
|
879
879
|
return f(({ value: r, type: t }) => t === _.CLASS_TO_PLAIN ? r.map((e) => e.id) : r);
|
|
880
880
|
}
|
|
881
881
|
function Vt() {
|
|
882
|
-
return f(({ value: r, type: t }) => t ===
|
|
882
|
+
return f(({ value: r, type: t }) => t === _.CLASS_TO_PLAIN ? void 0 : r, { toPlainOnly: !0 });
|
|
883
883
|
}
|
|
884
884
|
function Gt(r, t) {
|
|
885
|
-
return
|
|
885
|
+
return b(r, t, {
|
|
886
886
|
exposeDefaultValues: !0,
|
|
887
887
|
excludeExtraneousValues: !0
|
|
888
888
|
});
|
|
889
889
|
}
|
|
890
890
|
function Jt(r) {
|
|
891
|
-
return
|
|
891
|
+
return T(r, {
|
|
892
892
|
exposeUnsetFields: !1
|
|
893
893
|
});
|
|
894
894
|
}
|
|
@@ -938,7 +938,7 @@ class vt {
|
|
|
938
938
|
* Обрабатывает runtime-событие HotkeyManager.
|
|
939
939
|
*/
|
|
940
940
|
_handle(t) {
|
|
941
|
-
if (!this._enabled || this._isIgnoredTarget(t.target))
|
|
941
|
+
if (!(t instanceof KeyboardEvent) || !this._enabled || this._isIgnoredTarget(t.target))
|
|
942
942
|
return;
|
|
943
943
|
const e = this._normalizeKey(t), n = this._bindings.get(e);
|
|
944
944
|
if (n)
|
|
@@ -1016,13 +1016,13 @@ const $ = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new Set([
|
|
|
1016
1016
|
"SymbolLock"
|
|
1017
1017
|
]);
|
|
1018
1018
|
function ee(r) {
|
|
1019
|
-
return E(
|
|
1019
|
+
return E(R(r).snapshot);
|
|
1020
1020
|
}
|
|
1021
1021
|
function re(r, t) {
|
|
1022
|
-
const e =
|
|
1022
|
+
const e = R(r);
|
|
1023
1023
|
return e.subscribers.add(t), t(E(e.snapshot)), () => e.subscribers.delete(t);
|
|
1024
1024
|
}
|
|
1025
|
-
function
|
|
1025
|
+
function R(r) {
|
|
1026
1026
|
var a, l, u;
|
|
1027
1027
|
const t = $.get(r);
|
|
1028
1028
|
if (t)
|
|
@@ -1040,7 +1040,7 @@ function K(r) {
|
|
|
1040
1040
|
meta: c.metaKey,
|
|
1041
1041
|
mod: e === "macos" ? c.metaKey : e === "windows" || e === "linux" ? c.ctrlKey : c.ctrlKey || c.metaKey,
|
|
1042
1042
|
altGraph: ((C = c.getModifierState) == null ? void 0 : C.call(c, "AltGraph")) === !0
|
|
1043
|
-
} : F(e).modifiers, O = [...n.entries.values()],
|
|
1043
|
+
} : F(e).modifiers, O = [...n.entries.values()], S = {
|
|
1044
1044
|
platform: e,
|
|
1045
1045
|
modifiers: h,
|
|
1046
1046
|
held: {
|
|
@@ -1048,10 +1048,10 @@ function K(r) {
|
|
|
1048
1048
|
code: [...new Set(O.map((y) => y.code).filter(Boolean))].sort()
|
|
1049
1049
|
}
|
|
1050
1050
|
};
|
|
1051
|
-
if (!ot(n.snapshot,
|
|
1052
|
-
n.snapshot =
|
|
1051
|
+
if (!ot(n.snapshot, S)) {
|
|
1052
|
+
n.snapshot = S;
|
|
1053
1053
|
for (const y of n.subscribers)
|
|
1054
|
-
y(E(
|
|
1054
|
+
y(E(S));
|
|
1055
1055
|
}
|
|
1056
1056
|
}, s = () => {
|
|
1057
1057
|
n.entries.clear(), i();
|
|
@@ -1089,9 +1089,9 @@ function st(r) {
|
|
|
1089
1089
|
return e.includes("mac") || e.includes("darwin") || e.includes("iphone") || e.includes("ipad") ? "macos" : e.includes("win") ? "windows" : e.includes("linux") || e.includes("x11") || e.includes("cros") ? "linux" : "unknown";
|
|
1090
1090
|
}
|
|
1091
1091
|
function ot(r, t) {
|
|
1092
|
-
return r.platform === t.platform && r.modifiers.ctrl === t.modifiers.ctrl && r.modifiers.shift === t.modifiers.shift && r.modifiers.alt === t.modifiers.alt && r.modifiers.meta === t.modifiers.meta && r.modifiers.mod === t.modifiers.mod && r.modifiers.altGraph === t.modifiers.altGraph &&
|
|
1092
|
+
return r.platform === t.platform && r.modifiers.ctrl === t.modifiers.ctrl && r.modifiers.shift === t.modifiers.shift && r.modifiers.alt === t.modifiers.alt && r.modifiers.meta === t.modifiers.meta && r.modifiers.mod === t.modifiers.mod && r.modifiers.altGraph === t.modifiers.altGraph && L(r.held.key, t.held.key) && L(r.held.code, t.held.code);
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1094
|
+
function L(r, t) {
|
|
1095
1095
|
return r.length === t.length && r.every((e, n) => e === t[n]);
|
|
1096
1096
|
}
|
|
1097
1097
|
function E(r) {
|
|
@@ -1101,7 +1101,7 @@ function E(r) {
|
|
|
1101
1101
|
held: { key: [...r.held.key], code: [...r.held.code] }
|
|
1102
1102
|
};
|
|
1103
1103
|
}
|
|
1104
|
-
class ne extends
|
|
1104
|
+
class ne extends H {
|
|
1105
1105
|
constructor() {
|
|
1106
1106
|
super(...arguments);
|
|
1107
1107
|
/** Массив всех логов */
|
|
@@ -1145,7 +1145,7 @@ class ne extends P {
|
|
|
1145
1145
|
*/
|
|
1146
1146
|
end(e, n, i) {
|
|
1147
1147
|
if (n) {
|
|
1148
|
-
const s = i
|
|
1148
|
+
const s = i != null && i.length ? i : this._currentActions.length > 0 ? this._currentActions : void 0;
|
|
1149
1149
|
this._log(e ?? "info", n, s);
|
|
1150
1150
|
}
|
|
1151
1151
|
return this._currentContext.pop(), this._currentActions = [], this;
|
|
@@ -1356,11 +1356,11 @@ function ge(r, t) {
|
|
|
1356
1356
|
const e = N(r, t), { hours: n, minutes: i } = A(e);
|
|
1357
1357
|
return n || i ? `${e > 0 ? "-" : ""}${d(n)}:${d(i)}` : "";
|
|
1358
1358
|
}
|
|
1359
|
-
function
|
|
1359
|
+
function k(r = /* @__PURE__ */ new Date()) {
|
|
1360
1360
|
return new Date(r.getFullYear(), r.getMonth(), r.getDate());
|
|
1361
1361
|
}
|
|
1362
|
-
function
|
|
1363
|
-
const e = q(
|
|
1362
|
+
function be(r, t) {
|
|
1363
|
+
const e = q(k(r), k(t));
|
|
1364
1364
|
return e ? e > 7 ? {
|
|
1365
1365
|
variant: "red",
|
|
1366
1366
|
value: ">7"
|
|
@@ -1375,14 +1375,14 @@ function Te(r, t) {
|
|
|
1375
1375
|
value: `${e}`
|
|
1376
1376
|
} : null;
|
|
1377
1377
|
}
|
|
1378
|
-
function
|
|
1378
|
+
function Te(r) {
|
|
1379
1379
|
const e = String(r ?? "").trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
1380
1380
|
if (!e)
|
|
1381
1381
|
return null;
|
|
1382
1382
|
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));
|
|
1383
1383
|
return Number.isNaN(a.getTime()) ? null : a.toISOString();
|
|
1384
1384
|
}
|
|
1385
|
-
function
|
|
1385
|
+
function Se(r) {
|
|
1386
1386
|
const t = String(r ?? "").trim();
|
|
1387
1387
|
if (!t)
|
|
1388
1388
|
return null;
|
|
@@ -1394,11 +1394,11 @@ function be(r) {
|
|
|
1394
1394
|
const n = new Date(t);
|
|
1395
1395
|
return Number.isNaN(n.getTime()) ? null : n.toISOString();
|
|
1396
1396
|
}
|
|
1397
|
-
function
|
|
1397
|
+
function xe(r) {
|
|
1398
1398
|
const t = String(r ?? "").trim();
|
|
1399
1399
|
return t ? t.slice(0, 10) : "";
|
|
1400
1400
|
}
|
|
1401
|
-
function
|
|
1401
|
+
function we(r) {
|
|
1402
1402
|
const t = String(r ?? "").trim();
|
|
1403
1403
|
if (!t)
|
|
1404
1404
|
return "";
|
|
@@ -1512,9 +1512,9 @@ function d(r) {
|
|
|
1512
1512
|
function Ce(r) {
|
|
1513
1513
|
const t = /* @__PURE__ */ new Date();
|
|
1514
1514
|
try {
|
|
1515
|
-
const e =
|
|
1515
|
+
const e = x(r, t), n = Intl.supportedValuesOf("timeZone");
|
|
1516
1516
|
for (const i of n)
|
|
1517
|
-
if (
|
|
1517
|
+
if (x(i, t) === e)
|
|
1518
1518
|
return i;
|
|
1519
1519
|
} catch {
|
|
1520
1520
|
return null;
|
|
@@ -1522,7 +1522,7 @@ function Ce(r) {
|
|
|
1522
1522
|
return null;
|
|
1523
1523
|
}
|
|
1524
1524
|
function Me(r) {
|
|
1525
|
-
return
|
|
1525
|
+
return x(r, /* @__PURE__ */ new Date());
|
|
1526
1526
|
}
|
|
1527
1527
|
class $e {
|
|
1528
1528
|
constructor(t) {
|
|
@@ -1560,7 +1560,7 @@ class $e {
|
|
|
1560
1560
|
headers: await this._buildHeaders(),
|
|
1561
1561
|
signal: (t = this._abortController) == null ? void 0 : t.signal,
|
|
1562
1562
|
openWhenHidden: !0,
|
|
1563
|
-
onopen: (i) => {
|
|
1563
|
+
onopen: async (i) => {
|
|
1564
1564
|
var a, l;
|
|
1565
1565
|
if (i.ok && i.headers.get("content-type") === et) {
|
|
1566
1566
|
this._isConnected = !0, (l = (a = this._options).onOpen) == null || l.call(a);
|
|
@@ -1612,13 +1612,13 @@ class Fe {
|
|
|
1612
1612
|
}
|
|
1613
1613
|
export {
|
|
1614
1614
|
Ht as AfterDeserialize,
|
|
1615
|
-
|
|
1615
|
+
xt as AppBus,
|
|
1616
1616
|
Pt as BeforeSerialize,
|
|
1617
|
-
|
|
1617
|
+
wt as Collection,
|
|
1618
1618
|
At as DelayedExecutor,
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1619
|
+
Rt as DeserializeArrayField,
|
|
1620
|
+
Kt as DeserializeId,
|
|
1621
|
+
P as EventBus,
|
|
1622
1622
|
m as Events,
|
|
1623
1623
|
zt as GenericExpose,
|
|
1624
1624
|
vt as HotkeyManager,
|
|
@@ -1637,14 +1637,15 @@ export {
|
|
|
1637
1637
|
jt as SerializeId,
|
|
1638
1638
|
Bt as SerializeIds,
|
|
1639
1639
|
ne as StructuredLogger,
|
|
1640
|
+
H as Subscribable,
|
|
1640
1641
|
lt as SystemClock,
|
|
1641
|
-
|
|
1642
|
-
|
|
1642
|
+
Lt as TypeMap,
|
|
1643
|
+
kt as TypeRecord,
|
|
1643
1644
|
Fe as UPSMeter_Service,
|
|
1644
1645
|
ae as capitalize,
|
|
1645
1646
|
Wt as compareNumber,
|
|
1646
1647
|
U as consoleErrorSummary,
|
|
1647
|
-
|
|
1648
|
+
w as consoleValueSummary,
|
|
1648
1649
|
ie as createInstance,
|
|
1649
1650
|
pe as diffDuration,
|
|
1650
1651
|
ge as diffDurationTable,
|
|
@@ -1656,7 +1657,7 @@ export {
|
|
|
1656
1657
|
ut as formatDatetimeTZ,
|
|
1657
1658
|
Oe as formatDatetimeTZSpecial,
|
|
1658
1659
|
Qt as generateUUID,
|
|
1659
|
-
|
|
1660
|
+
be as getDateOnlyDiffFactor,
|
|
1660
1661
|
he as getDayOfWeek,
|
|
1661
1662
|
ee as getKeyboardStateSnapshot,
|
|
1662
1663
|
rt as getOnDeserializedMethod,
|
|
@@ -1669,8 +1670,8 @@ export {
|
|
|
1669
1670
|
le as isDateRangeOverlap,
|
|
1670
1671
|
Zt as isNullOrUndefined,
|
|
1671
1672
|
De as isoDateTimeToTimeInput,
|
|
1672
|
-
|
|
1673
|
-
|
|
1673
|
+
xe as isoToDateInput,
|
|
1674
|
+
we as isoToDateTimeLocalInput,
|
|
1674
1675
|
Ie as mergeTimeIntoDateTime,
|
|
1675
1676
|
$t as onDeserialized,
|
|
1676
1677
|
fe as parseDate,
|
|
@@ -1678,12 +1679,12 @@ export {
|
|
|
1678
1679
|
Ce as parseOffsetToTimezone,
|
|
1679
1680
|
qt as profile,
|
|
1680
1681
|
Xt as randomString,
|
|
1681
|
-
|
|
1682
|
+
k as removeTime,
|
|
1682
1683
|
re as subscribeKeyboardState,
|
|
1683
1684
|
j as timeToTimeInput,
|
|
1684
1685
|
Gt as toInstance,
|
|
1685
|
-
|
|
1686
|
-
|
|
1686
|
+
Te as toIsoZDate,
|
|
1687
|
+
Se as toIsoZDateTime,
|
|
1687
1688
|
Jt as toPlain,
|
|
1688
1689
|
Ee as toTimeHHMMSS
|
|
1689
1690
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endge/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
20
20
|
"dev": "vite build --watch",
|
|
21
|
-
"build": "vite build",
|
|
21
|
+
"build": "pnpm typecheck && vite build",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.app.json --noEmit",
|
|
22
23
|
"test": "vitest",
|
|
23
24
|
"lint-check": "eslint . --cache",
|
|
24
25
|
"lint-fix": "eslint . --fix --cache"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Внутренний механизм уведомления generic utilities об изменениях. */
|
|
2
|
-
export declare class ChangeNotifier {
|
|
3
|
-
private readonly _listeners;
|
|
4
|
-
/** Подписывает listener на изменения utility owner. */
|
|
5
|
-
subscribe(listener: () => void): () => void;
|
|
6
|
-
/** Уведомляет текущих listeners об изменении. */
|
|
7
|
-
notify(): void;
|
|
8
|
-
}
|
|
File without changes
|