@endge/utils 0.24.14 → 0.25.6
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 +7 -7
- package/dist/collection/collection.types.d.ts +10 -10
- package/dist/collection/indexed-collection.d.ts +17 -17
- package/dist/database/PayloadHttpClient.d.ts +3 -3
- package/dist/events/ChangeNotifier.d.ts +8 -0
- package/dist/events/EventBus.d.ts +3 -3
- package/dist/execute/NamedExecutor.d.ts +9 -9
- package/dist/execute/delay-executor.d.ts +8 -8
- package/dist/index.d.ts +8 -14
- package/dist/shared/serialize/decorator.d.ts +2 -2
- package/dist/tools/hotkeys.d.ts +8 -8
- package/dist/tools/logs.d.ts +7 -7
- package/dist/tools/tools.types.d.ts +2 -2
- package/dist/utils.js +545 -634
- package/package.json +11 -17
- package/dist/composable/useCookie.d.ts +0 -1
- package/dist/events/Subscribable.d.ts +0 -31
- package/dist/serialize/useStorageDebounced.d.ts +0 -2
- package/dist/tooltip/TooltipRegistrator.d.ts +0 -15
- package/dist/tooltip/store.d.ts +0 -29
- package/dist/tooltip/tooltip.types.d.ts +0 -10
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CollectionEntity, CollectionEvents } from './collection.types';
|
|
2
|
-
import {
|
|
2
|
+
import { ChangeNotifier } from '../events/ChangeNotifier';
|
|
3
3
|
/**
|
|
4
4
|
* Описывает ответственность Collection в архитектуре проекта.
|
|
5
5
|
*/
|
|
6
|
-
export declare class Collection<T extends CollectionEntity> extends
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private
|
|
6
|
+
export declare class Collection<T extends CollectionEntity> extends ChangeNotifier {
|
|
7
|
+
private _items;
|
|
8
|
+
private _indices;
|
|
9
|
+
private _rootIds;
|
|
10
|
+
private _bus;
|
|
11
11
|
/**
|
|
12
12
|
* Создает экземпляр Collection и подготавливает базовое состояние.
|
|
13
13
|
*/
|
|
@@ -31,7 +31,7 @@ export declare class Collection<T extends CollectionEntity> extends Subscribable
|
|
|
31
31
|
/**
|
|
32
32
|
* Создает runtime-сущность Collection.
|
|
33
33
|
*/
|
|
34
|
-
private
|
|
34
|
+
private _createIndex;
|
|
35
35
|
/**
|
|
36
36
|
* Возвращает реактивный массив всех элементов.
|
|
37
37
|
*/
|
|
@@ -8,28 +8,28 @@ export declare enum Events {
|
|
|
8
8
|
Update = "update",
|
|
9
9
|
IndexCreate = "indexCreate"
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export interface CollectionEvents<T extends CollectionEntity> {
|
|
12
12
|
[Events.Add]: Array<T>;
|
|
13
13
|
[Events.Remove]: Array<T>;
|
|
14
14
|
[Events.Update]: Array<T>;
|
|
15
15
|
[Events.IndexCreate]: keyof T;
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
export interface IndexCollectionEntity<ID = string | null> {
|
|
18
18
|
id: ID;
|
|
19
19
|
index: number;
|
|
20
20
|
filteredIndex: number;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export interface CollectionOptions<T extends IndexCollectionEntity<ID>, ID = string | null> {
|
|
23
23
|
sortFn: (a: T, b: T) => number;
|
|
24
24
|
filterFn: (item: T) => boolean;
|
|
25
25
|
indexEnabled: boolean;
|
|
26
26
|
filterIndexEnabled: boolean;
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
export interface ReadonlyIndexCollection<T extends IndexCollectionEntity<ID>, ID = string | null> {
|
|
29
|
-
get(id: ID)
|
|
30
|
-
all()
|
|
31
|
-
size()
|
|
32
|
-
unfiltered()
|
|
33
|
-
has(id: ID)
|
|
34
|
-
forEach(callback: (item: T) => void)
|
|
29
|
+
get: (id: ID) => T | undefined;
|
|
30
|
+
all: () => ReadonlyArray<T>;
|
|
31
|
+
size: () => number;
|
|
32
|
+
unfiltered: () => ReadonlyArray<T>;
|
|
33
|
+
has: (id: ID) => boolean;
|
|
34
|
+
forEach: (callback: (item: T) => void) => void;
|
|
35
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OneOrMany } from '../tools/tools.types';
|
|
2
1
|
import { CollectionOptions, IndexCollectionEntity } from './collection.types';
|
|
2
|
+
import { OneOrMany } from '../tools/tools.types';
|
|
3
3
|
/**
|
|
4
4
|
* Высокопроизводительная IndexedCollection
|
|
5
5
|
*
|
|
@@ -14,16 +14,16 @@ import { CollectionOptions, IndexCollectionEntity } from './collection.types';
|
|
|
14
14
|
* - При изменении filterFn можно пересобрать filteredList без пересортировки list.
|
|
15
15
|
*/
|
|
16
16
|
export declare class IndexedCollection<T extends IndexCollectionEntity<ID>, ID = string | null> {
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
17
|
+
private _list;
|
|
18
|
+
private _filteredList;
|
|
19
|
+
private _map;
|
|
20
|
+
private _indexById;
|
|
21
|
+
private _dirtySort;
|
|
22
|
+
private _dirtyFilter;
|
|
23
|
+
private _sortFn?;
|
|
24
|
+
private _filterFn?;
|
|
25
|
+
private _indexEnabled;
|
|
26
|
+
private _filterIndexEnabled;
|
|
27
27
|
/**
|
|
28
28
|
* Создает экземпляр IndexedCollection и подготавливает базовое состояние.
|
|
29
29
|
*/
|
|
@@ -116,25 +116,25 @@ export declare class IndexedCollection<T extends IndexCollectionEntity<ID>, ID =
|
|
|
116
116
|
/**
|
|
117
117
|
* Выполняет внутренний шаг rebuildFilteredFromScratch для IndexedCollection.
|
|
118
118
|
*/
|
|
119
|
-
private
|
|
119
|
+
private _rebuildFilteredFromScratch;
|
|
120
120
|
/**
|
|
121
121
|
* Выполняет внутренний шаг addToFilteredIfPasses для IndexedCollection.
|
|
122
122
|
*/
|
|
123
|
-
private
|
|
123
|
+
private _addToFilteredIfPasses;
|
|
124
124
|
/**
|
|
125
125
|
* Добавляет сущность в runtime-коллекцию IndexedCollection.
|
|
126
126
|
*/
|
|
127
|
-
private
|
|
127
|
+
private _appendToFiltered;
|
|
128
128
|
/**
|
|
129
129
|
* Выполняет внутренний шаг refilterOneO1 для IndexedCollection.
|
|
130
130
|
*/
|
|
131
|
-
private
|
|
131
|
+
private _refilterOneO1;
|
|
132
132
|
/**
|
|
133
133
|
* Удаляет сущность из runtime-коллекции IndexedCollection.
|
|
134
134
|
*/
|
|
135
|
-
private
|
|
135
|
+
private _removeFromFilteredO1;
|
|
136
136
|
/**
|
|
137
137
|
* Удаляет сущность из runtime-коллекции IndexedCollection.
|
|
138
138
|
*/
|
|
139
|
-
private
|
|
139
|
+
private _removeFromListO1;
|
|
140
140
|
}
|
|
@@ -2,10 +2,10 @@ export interface PayloadClientOptions {
|
|
|
2
2
|
baseUrl: string;
|
|
3
3
|
}
|
|
4
4
|
export declare class PayloadHttpClient {
|
|
5
|
-
private readonly
|
|
5
|
+
private readonly _baseUrl;
|
|
6
6
|
constructor(opts: PayloadClientOptions);
|
|
7
|
-
private
|
|
8
|
-
private
|
|
7
|
+
private _buildUrl;
|
|
8
|
+
private _buildHeaders;
|
|
9
9
|
get<T>(path: string, query?: Record<string, unknown>, extraHeaders?: HeadersInit): Promise<T>;
|
|
10
10
|
post<T>(path: string, body?: unknown, extraHeaders?: HeadersInit): Promise<T>;
|
|
11
11
|
patch<T>(path: string, body?: unknown, extraHeaders?: HeadersInit): Promise<T>;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -36,7 +36,7 @@ export type EventList = Record<string, any>;
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare class EventBus<StaticEvents extends Record<string, any>, CustomEventMap extends Record<string, any> = Record<string, any>> {
|
|
39
|
-
private
|
|
39
|
+
private _listeners;
|
|
40
40
|
/**
|
|
41
41
|
* Создает экземпляр EventBus и подготавливает базовое состояние.
|
|
42
42
|
*/
|
|
@@ -106,12 +106,12 @@ export declare class EventBus<StaticEvents extends Record<string, any>, CustomEv
|
|
|
106
106
|
*/
|
|
107
107
|
clear(event?: string): void;
|
|
108
108
|
}
|
|
109
|
-
export
|
|
109
|
+
export interface GlobalEvents {
|
|
110
110
|
notify: {
|
|
111
111
|
severity: 'success' | 'error' | 'info' | 'warn';
|
|
112
112
|
summary: string;
|
|
113
113
|
detail?: string;
|
|
114
114
|
life?: number;
|
|
115
115
|
};
|
|
116
|
-
}
|
|
116
|
+
}
|
|
117
117
|
export declare const AppBus: EventBus<GlobalEvents, Record<string, any>>;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
interface NamedExecutorConfig {
|
|
2
2
|
delayMs: number;
|
|
3
3
|
maxMs: number;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
/**
|
|
6
6
|
* Описывает ответственность NamedExecutor в архитектуре проекта.
|
|
7
7
|
*/
|
|
8
8
|
export declare class NamedExecutor {
|
|
9
|
-
private readonly
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
9
|
+
private readonly _config;
|
|
10
|
+
private _delayTimers;
|
|
11
|
+
private _maxTimers;
|
|
12
|
+
private _callbacks;
|
|
13
|
+
private _firstCallTime;
|
|
14
14
|
/**
|
|
15
15
|
* Создает экземпляр NamedExecutor и подготавливает базовое состояние.
|
|
16
16
|
*/
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(_config: NamedExecutorConfig);
|
|
18
18
|
/**
|
|
19
19
|
* Выполняет действие run в рамках ответственности NamedExecutor.
|
|
20
20
|
*/
|
|
@@ -34,6 +34,6 @@ export declare class NamedExecutor {
|
|
|
34
34
|
/**
|
|
35
35
|
* Очищает накопленное состояние NamedExecutor.
|
|
36
36
|
*/
|
|
37
|
-
private
|
|
37
|
+
private _clear;
|
|
38
38
|
}
|
|
39
39
|
export {};
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Описывает ответственность DelayedExecutor в архитектуре проекта.
|
|
3
3
|
*/
|
|
4
4
|
export declare class DelayedExecutor<T extends Array<any> = []> {
|
|
5
|
-
private readonly
|
|
6
|
-
private readonly
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private
|
|
5
|
+
private readonly _fn;
|
|
6
|
+
private readonly _firstExecuteImmediately;
|
|
7
|
+
private _delayTimer;
|
|
8
|
+
private _maxTimer;
|
|
9
|
+
private _hasExecutedOnce;
|
|
10
|
+
private _lastArgs;
|
|
11
11
|
/**
|
|
12
12
|
* Создает экземпляр DelayedExecutor и подготавливает базовое состояние.
|
|
13
13
|
*/
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(_fn: (...args: T) => void, _firstExecuteImmediately?: boolean);
|
|
15
15
|
/**
|
|
16
16
|
* Выполняет действие run в рамках ответственности DelayedExecutor.
|
|
17
17
|
*/
|
|
@@ -27,5 +27,5 @@ export declare class DelayedExecutor<T extends Array<any> = []> {
|
|
|
27
27
|
/**
|
|
28
28
|
* Очищает накопленное состояние DelayedExecutor.
|
|
29
29
|
*/
|
|
30
|
-
private
|
|
30
|
+
private _clear;
|
|
31
31
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
export { useCookie } from './composable/useCookie';
|
|
2
1
|
export * from './collection/collection';
|
|
3
|
-
export * from './collection/indexed-collection';
|
|
4
2
|
export * from './collection/collection.types';
|
|
3
|
+
export * from './collection/indexed-collection';
|
|
5
4
|
export * from './collection/RingBuffer';
|
|
6
|
-
export * from './events/EventBus';
|
|
7
|
-
export * from './events/Subscribable';
|
|
8
5
|
export * from './database/PayloadHttpClient';
|
|
6
|
+
export * from './events/EventBus';
|
|
9
7
|
export * from './execute/delay-executor';
|
|
10
8
|
export * from './execute/NamedExecutor';
|
|
11
|
-
export { toInstance, toPlain } from './shared/serialize/parse';
|
|
12
|
-
export * from './shared/serialize/decorator';
|
|
13
|
-
export { isNullOrUndefined } from './shared/types/maybe';
|
|
14
|
-
export type { Maybe as SharedMaybe } from './shared/types/maybe';
|
|
15
|
-
export * from './serialize/Serialize';
|
|
16
9
|
export * from './serialize/decorators/json';
|
|
17
10
|
export * from './serialize/decorators/jsonString';
|
|
18
11
|
export * from './serialize/decorators/onDeserialized';
|
|
19
12
|
export * from './serialize/decorators/script';
|
|
20
13
|
export * from './serialize/decorators/typeMap';
|
|
21
14
|
export * from './serialize/decorators/typeRecord';
|
|
22
|
-
export * from './serialize/
|
|
15
|
+
export * from './serialize/Serialize';
|
|
16
|
+
export * from './shared/serialize/decorator';
|
|
17
|
+
export { toInstance, toPlain } from './shared/serialize/parse';
|
|
18
|
+
export { isNullOrUndefined } from './shared/types/maybe';
|
|
19
|
+
export type { Maybe as SharedMaybe } from './shared/types/maybe';
|
|
23
20
|
export * from './tools/compare';
|
|
24
21
|
export * from './tools/console';
|
|
25
22
|
export * from './tools/debug';
|
|
@@ -34,9 +31,6 @@ export * from './tools/system-clock';
|
|
|
34
31
|
export * from './tools/text';
|
|
35
32
|
export * from './tools/time';
|
|
36
33
|
export * from './tools/tools.types';
|
|
34
|
+
export * from './ui/tree.types';
|
|
37
35
|
export * from './updates/SSEManager';
|
|
38
36
|
export * from './updates/UPSMeter_Service';
|
|
39
|
-
export * from './tooltip/store';
|
|
40
|
-
export * from './tooltip/TooltipRegistrator';
|
|
41
|
-
export * from './tooltip/tooltip.types';
|
|
42
|
-
export * from './ui/tree.types';
|
|
@@ -5,8 +5,8 @@ export declare function BeforeSerialize(): (target: any, propertyKey: string, _d
|
|
|
5
5
|
export declare function AfterDeserialize(target: any, propertyKey: string, _descriptor: PropertyDescriptor): void;
|
|
6
6
|
export declare function IsOptionalTransformed(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
|
|
7
7
|
export interface ISerializable {
|
|
8
|
-
toPlain()
|
|
9
|
-
toJson()
|
|
8
|
+
toPlain: () => any;
|
|
9
|
+
toJson: () => string;
|
|
10
10
|
}
|
|
11
11
|
export declare function DeserializeId(): PropertyDecorator;
|
|
12
12
|
export declare function DeserializeArrayField(field: string): PropertyDecorator;
|
package/dist/tools/hotkeys.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ interface HotkeyManagerOptions {
|
|
|
7
7
|
* Управляет ресурсами и состоянием HotkeyManager.
|
|
8
8
|
*/
|
|
9
9
|
export declare class HotkeyManager {
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private readonly
|
|
13
|
-
private readonly
|
|
14
|
-
private readonly
|
|
10
|
+
private _bindings;
|
|
11
|
+
private _enabled;
|
|
12
|
+
private readonly _target;
|
|
13
|
+
private readonly _ignoreInput;
|
|
14
|
+
private readonly _handleBound;
|
|
15
15
|
/**
|
|
16
16
|
* Создает экземпляр HotkeyManager и подготавливает базовое состояние.
|
|
17
17
|
*/
|
|
@@ -19,15 +19,15 @@ export declare class HotkeyManager {
|
|
|
19
19
|
/**
|
|
20
20
|
* Выполняет внутренний шаг isIgnoredTarget для HotkeyManager.
|
|
21
21
|
*/
|
|
22
|
-
private
|
|
22
|
+
private _isIgnoredTarget;
|
|
23
23
|
/**
|
|
24
24
|
* Нормализует входные данные HotkeyManager.
|
|
25
25
|
*/
|
|
26
|
-
private
|
|
26
|
+
private _normalizeKey;
|
|
27
27
|
/**
|
|
28
28
|
* Обрабатывает runtime-событие HotkeyManager.
|
|
29
29
|
*/
|
|
30
|
-
private
|
|
30
|
+
private _handle;
|
|
31
31
|
/**
|
|
32
32
|
* Обрабатывает входящее событие HotkeyManager.
|
|
33
33
|
*/
|
package/dist/tools/logs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChangeNotifier } from '../events/ChangeNotifier';
|
|
2
2
|
/**
|
|
3
3
|
* Структурированная запись лога.
|
|
4
4
|
*
|
|
@@ -38,7 +38,7 @@ export interface StructuredLogEntry {
|
|
|
38
38
|
* - Иерархического контекста (`context`, `start`, `end`).
|
|
39
39
|
* - Разных уровней (`_debug`, `info`, `warn`, `error`).
|
|
40
40
|
* - Action-кнопок для каждого лога.
|
|
41
|
-
* - Подписки на
|
|
41
|
+
* - Подписки на обновления.
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* const logger = new StructuredLogger()
|
|
@@ -61,12 +61,12 @@ 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 ChangeNotifier {
|
|
65
65
|
/** Массив всех логов */
|
|
66
|
-
private
|
|
66
|
+
private _logs;
|
|
67
67
|
/** Текущий контекст (иерархия) */
|
|
68
|
-
private
|
|
69
|
-
private
|
|
68
|
+
private _currentContext;
|
|
69
|
+
private _currentActions;
|
|
70
70
|
/**
|
|
71
71
|
* Устанавливает текущий контекст.
|
|
72
72
|
* Сбрасывает предыдущий контекст.
|
|
@@ -113,7 +113,7 @@ export declare class StructuredLogger extends Subscribable {
|
|
|
113
113
|
* @param message Сообщение
|
|
114
114
|
* @param actions Дополнительные действия (иконки с обработчиками)
|
|
115
115
|
*/
|
|
116
|
-
private
|
|
116
|
+
private _log;
|
|
117
117
|
/**
|
|
118
118
|
* Лог уровня _debug.
|
|
119
119
|
*
|
|
@@ -89,10 +89,10 @@ export type OneOrMany<T> = T | Array<T>;
|
|
|
89
89
|
/**
|
|
90
90
|
* Тип для активного состояния с вычисляемым значением.
|
|
91
91
|
*/
|
|
92
|
-
export
|
|
92
|
+
export interface ActiveState<T> {
|
|
93
93
|
value: T;
|
|
94
94
|
computed: T;
|
|
95
|
-
}
|
|
95
|
+
}
|
|
96
96
|
/**
|
|
97
97
|
* Тип для глубокой частичной рекурсии.
|
|
98
98
|
*/
|