@endge/utils 0.24.12 → 0.24.14
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/RingBuffer.d.ts +12 -0
- package/dist/collection/collection.d.ts +51 -0
- package/dist/collection/collection.types.d.ts +35 -0
- package/dist/collection/indexed-collection.d.ts +140 -0
- package/dist/composable/useCookie.d.ts +1 -0
- package/dist/database/PayloadHttpClient.d.ts +13 -0
- package/dist/events/EventBus.d.ts +117 -0
- package/dist/events/Subscribable.d.ts +31 -0
- package/dist/execute/NamedExecutor.d.ts +39 -0
- package/dist/execute/delay-executor.d.ts +31 -0
- package/dist/index.d.ts +42 -1320
- package/dist/serialize/Serialize.d.ts +14 -0
- package/dist/serialize/decorators/json.d.ts +10 -0
- package/dist/serialize/decorators/jsonString.d.ts +1 -0
- package/dist/serialize/decorators/onDeserialized.d.ts +2 -0
- package/dist/serialize/decorators/script.d.ts +10 -0
- package/dist/serialize/decorators/typeMap.d.ts +55 -0
- package/dist/serialize/decorators/typeRecord.d.ts +59 -0
- package/dist/serialize/useStorageDebounced.d.ts +2 -0
- package/dist/shared/serialize/decorator.d.ts +15 -0
- package/dist/shared/serialize/parse.d.ts +3 -0
- package/dist/shared/types/getter-fn.d.ts +3 -0
- package/dist/shared/types/maybe.d.ts +2 -0
- package/dist/shared/utils/compare.d.ts +1 -0
- package/dist/shared/utils/generate.d.ts +2 -0
- package/dist/shared/utils/keyboard.d.ts +9 -0
- package/dist/shared/utils/text.d.ts +1 -0
- package/dist/shared/utils/time.d.ts +41 -0
- package/dist/tools/compare.d.ts +1 -0
- package/dist/tools/console.d.ts +4 -0
- package/dist/tools/debug.d.ts +2 -0
- package/dist/tools/generate.d.ts +1 -0
- package/dist/tools/geometry.d.ts +15 -0
- package/dist/tools/hotkeys.d.ts +56 -0
- package/dist/tools/keyboard.d.ts +21 -0
- package/dist/tools/logs.d.ts +176 -0
- package/dist/tools/reflect.d.ts +12 -0
- package/dist/tools/state.d.ts +1 -0
- package/dist/tools/system-clock.d.ts +14 -0
- package/dist/tools/text.d.ts +1 -0
- package/dist/tools/time.d.ts +1 -0
- package/dist/tools/tools.types.d.ts +101 -0
- package/dist/tooltip/TooltipRegistrator.d.ts +15 -0
- package/dist/tooltip/store.d.ts +29 -0
- package/dist/tooltip/tooltip.types.d.ts +10 -0
- package/dist/ui/tree.types.d.ts +7 -0
- package/dist/updates/SSEManager.d.ts +26 -0
- package/dist/updates/UPSMeter_Service.d.ts +8 -0
- package/package.json +6 -5
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClassConstructor } from 'class-transformer';
|
|
2
|
+
/**
|
|
3
|
+
* Описывает ответственность Serialize в архитектуре проекта.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Serialize {
|
|
6
|
+
/**
|
|
7
|
+
* Выполняет действие toPlain в рамках ответственности Serialize.
|
|
8
|
+
*/
|
|
9
|
+
static toPlain<T>(instance: T): any;
|
|
10
|
+
/**
|
|
11
|
+
* Выполняет действие fromJSON в рамках ответственности Serialize.
|
|
12
|
+
*/
|
|
13
|
+
static fromJSON<T>(cls: ClassConstructor<T>, json: any): T;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function JsonString(): PropertyDecorator;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ClassConstructor } from 'class-transformer';
|
|
2
|
+
/**
|
|
3
|
+
* Декоратор @TypeMap для автоматической сериализации и десериализации `Map<K, V>`.
|
|
4
|
+
* Поддерживает два формата JSON:
|
|
5
|
+
* 1. **Объект - `Map<K, V>`** (если `keyField` не указан)
|
|
6
|
+
* 2. **Массив - `Map<K, V>`** (если указан `keyField`)
|
|
7
|
+
*
|
|
8
|
+
* @param valueType - Класс значений в `Map<K, V>`.
|
|
9
|
+
* @param keyField - (необязательно) Поле, используемое как ключ (`name`, `id`, и т. д.).
|
|
10
|
+
*
|
|
11
|
+
* ## Пример использования (объект - `Map`)
|
|
12
|
+
* ```typescript
|
|
13
|
+
* export class ReflectDomain {
|
|
14
|
+
* @TypeMap(RType) // JSON-объект { key: value } - Map<string, RType>
|
|
15
|
+
* private types: Map<string, RType> = new Map()
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
* **JSON**
|
|
19
|
+
* ```json
|
|
20
|
+
* {
|
|
21
|
+
* "types": {
|
|
22
|
+
* "User": { "name": "User", "fields": {} },
|
|
23
|
+
* "Company": { "name": "Company", "fields": {} }
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
* **Результат**
|
|
28
|
+
* ```typescript
|
|
29
|
+
* ReflectDomain.types // Map<string, RType>
|
|
30
|
+
* ReflectDomain.getType('User') // RType('User')
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ## Пример использования (массив - `Map`)
|
|
34
|
+
* ```typescript
|
|
35
|
+
* export class ReflectDomain {
|
|
36
|
+
* @TypeMap(RType, 'name') // JSON-массив [{ name: value }, ...] - Map<string, RType>
|
|
37
|
+
* private types: Map<string, RType> = new Map()
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
* **JSON**
|
|
41
|
+
* ```json
|
|
42
|
+
* {
|
|
43
|
+
* "types": [
|
|
44
|
+
* { "name": "User", "fields": {} },
|
|
45
|
+
* { "name": "Company", "fields": {} }
|
|
46
|
+
* ]
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
* **Результат**
|
|
50
|
+
* ```typescript
|
|
51
|
+
* ReflectDomain.types // Map<string, RType>
|
|
52
|
+
* ReflectDomain.getType('User') // RType('User')
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function TypeMap<V>(valueType: ClassConstructor<V>, keyField?: keyof V): PropertyDecorator;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ClassConstructor } from 'class-transformer';
|
|
2
|
+
/**
|
|
3
|
+
* Декоратор `@TypeRecord` для автоматической (де)сериализации полей типа `Record<string, V>`.
|
|
4
|
+
* Работает аналогично `@Type(() => V)`, но для структур, где ключами являются строки (как у обычного объекта),
|
|
5
|
+
* а значениями — экземпляры определённого класса.
|
|
6
|
+
*
|
|
7
|
+
* Используется с библиотекой `class-transformer`.
|
|
8
|
+
*
|
|
9
|
+
* @param valueType - Класс значений, содержащихся в `Record<string, V>`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { Expose } from 'class-transformer'
|
|
14
|
+
*
|
|
15
|
+
* class RField {
|
|
16
|
+
* @Expose()
|
|
17
|
+
* name!: string
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* class Component {
|
|
21
|
+
* @Expose()
|
|
22
|
+
* @TypeRecord(RField)
|
|
23
|
+
* inputFields!: Record<string, RField>
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ## Пример JSON:
|
|
28
|
+
* ```json
|
|
29
|
+
* {
|
|
30
|
+
* "inputFields": {
|
|
31
|
+
* "user": { "name": "user" },
|
|
32
|
+
* "email": { "name": "email" }
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
* После `plainToInstance(Component, json)`:
|
|
37
|
+
* ```ts
|
|
38
|
+
* component.inputFields // Record<string, RField>
|
|
39
|
+
* component.inputFields.user instanceof RField // true
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* ## Пример сериализации:
|
|
43
|
+
* ```ts
|
|
44
|
+
* const component = new Component()
|
|
45
|
+
* component.inputFields = {
|
|
46
|
+
* user: new RField("user"),
|
|
47
|
+
* email: new RField("email"),
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* const json = instanceToPlain(component)
|
|
51
|
+
* // json = {
|
|
52
|
+
* // inputFields: {
|
|
53
|
+
* // user: { name: "user" },
|
|
54
|
+
* // email: { name: "email" }
|
|
55
|
+
* // }
|
|
56
|
+
* // }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function TypeRecord<V>(valueType: ClassConstructor<V>): PropertyDecorator;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExposeOptions } from 'class-transformer';
|
|
2
|
+
import { ValidationOptions } from 'class-validator';
|
|
3
|
+
export declare function GenericExpose(options: ExposeOptions): (target: object, propertyKey: string | symbol) => void;
|
|
4
|
+
export declare function BeforeSerialize(): (target: any, propertyKey: string, _descriptor: PropertyDescriptor) => void;
|
|
5
|
+
export declare function AfterDeserialize(target: any, propertyKey: string, _descriptor: PropertyDescriptor): void;
|
|
6
|
+
export declare function IsOptionalTransformed(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
|
|
7
|
+
export interface ISerializable {
|
|
8
|
+
toPlain(): any;
|
|
9
|
+
toJson(): string;
|
|
10
|
+
}
|
|
11
|
+
export declare function DeserializeId(): PropertyDecorator;
|
|
12
|
+
export declare function DeserializeArrayField(field: string): PropertyDecorator;
|
|
13
|
+
export declare function SerializeId(): PropertyDecorator;
|
|
14
|
+
export declare function SerializeIds(): PropertyDecorator;
|
|
15
|
+
export declare function IgnoreToPlain(): PropertyDecorator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compareNumber(a: any, b: any): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface KeyCombo {
|
|
2
|
+
ctrl?: boolean;
|
|
3
|
+
alt?: boolean;
|
|
4
|
+
shift?: boolean;
|
|
5
|
+
meta?: boolean;
|
|
6
|
+
key: string;
|
|
7
|
+
}
|
|
8
|
+
export type KeyComboArray = Array<KeyCombo>;
|
|
9
|
+
export declare function isAnyKeyComboActive(combos: KeyComboArray, event: KeyboardEvent): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function capitalize(val: unknown): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface DateRange {
|
|
2
|
+
start: Date;
|
|
3
|
+
end: Date;
|
|
4
|
+
}
|
|
5
|
+
export declare function isAfterOrEqual(dateA: Date, dateB: Date): boolean;
|
|
6
|
+
export declare function isDateRangeOverlap(s1: Date, s2: Date, validFrom: Date, validTo: Date): boolean;
|
|
7
|
+
export declare function isDateInRange(date: Date, validFrom: Date, validTo: Date): boolean;
|
|
8
|
+
export declare const parseDate: (isoString: string) => "" | Date;
|
|
9
|
+
export declare function formatDatetime(date: Date, formatString?: string, options?: {}): string;
|
|
10
|
+
export declare function formatDatetimeTZ(date: Date | string | object, formatString?: string, options?: {}, isLocalTime?: boolean): string;
|
|
11
|
+
export declare function getDayOfWeek(date: any): string;
|
|
12
|
+
export declare function formatDateToMSK(date: any): string;
|
|
13
|
+
export declare function extractTime(date: Date | string | object, isLocalTime?: boolean): string;
|
|
14
|
+
export declare function findMinMaxDates(dates: Set<Date>): {
|
|
15
|
+
minDate: Date;
|
|
16
|
+
maxDate: Date;
|
|
17
|
+
};
|
|
18
|
+
export declare function diffDuration(d1: Date, d2: Date): string;
|
|
19
|
+
export declare function diffDurationTable(d1: Date, d2: Date): string;
|
|
20
|
+
export declare function removeTime(date?: Date): Date;
|
|
21
|
+
export declare function getDateOnlyDiffFactor(d1: Date, d2: Date): {
|
|
22
|
+
variant: 'red' | 'blue';
|
|
23
|
+
value: string;
|
|
24
|
+
} | null;
|
|
25
|
+
export declare function toIsoZDate(value: string): string | null;
|
|
26
|
+
export declare function toIsoZDateTime(value: string): string | null;
|
|
27
|
+
export declare function isoToDateInput(value: unknown): string;
|
|
28
|
+
export declare function isoToDateTimeLocalInput(value: unknown): string;
|
|
29
|
+
/** Formats a DateTime as `HH:mm` in the configured IANA timezone or browser-local timezone. */
|
|
30
|
+
export declare function isoDateTimeToTimeInput(value: unknown, timezone?: unknown): string;
|
|
31
|
+
/** Replaces only hours and minutes while preserving the DateTime calendar date in the selected timezone. */
|
|
32
|
+
export declare function mergeTimeIntoDateTime(value: unknown, time: unknown, timezone?: unknown): string | null;
|
|
33
|
+
export declare function timeToTimeInput(value: unknown): string;
|
|
34
|
+
export declare function toTimeHHMMSS(value: unknown): string | null;
|
|
35
|
+
export declare function parseDuration(duration: string): string;
|
|
36
|
+
export declare function formatDatetimeTZSpecial(date?: Date | string | object | null, formatString?: string, options?: {}): string;
|
|
37
|
+
/**
|
|
38
|
+
* Возвращает первую найденную IANA-таймзону с данным смещением (например, "+03:00").
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseOffsetToTimezone(offsetStr: string): string | null;
|
|
41
|
+
export declare function getTimezoneOffsetMs(timezone: string): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compareNumber } from '../shared/utils/compare';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Returns a bounded string without traversing or retaining the supplied value. */
|
|
2
|
+
export declare function consoleValueSummary(value: unknown): string;
|
|
3
|
+
/** Returns Error metadata as text without forwarding the Error object to Console. */
|
|
4
|
+
export declare function consoleErrorSummary(error: unknown): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateUUID, randomString } from '../shared/utils/generate';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface DataRect {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface DataSize {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface DataPoint {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}
|
|
15
|
+
export type Side = 'left' | 'right' | 'top' | 'bottom';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
type HotkeyHandler = (event: KeyboardEvent) => void;
|
|
2
|
+
interface HotkeyManagerOptions {
|
|
3
|
+
ignoreInput?: boolean;
|
|
4
|
+
target?: EventTarget;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Управляет ресурсами и состоянием HotkeyManager.
|
|
8
|
+
*/
|
|
9
|
+
export declare class HotkeyManager {
|
|
10
|
+
private bindings;
|
|
11
|
+
private enabled;
|
|
12
|
+
private readonly target;
|
|
13
|
+
private readonly ignoreInput;
|
|
14
|
+
private readonly handleBound;
|
|
15
|
+
/**
|
|
16
|
+
* Создает экземпляр HotkeyManager и подготавливает базовое состояние.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options?: HotkeyManagerOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Выполняет внутренний шаг isIgnoredTarget для HotkeyManager.
|
|
21
|
+
*/
|
|
22
|
+
private isIgnoredTarget;
|
|
23
|
+
/**
|
|
24
|
+
* Нормализует входные данные HotkeyManager.
|
|
25
|
+
*/
|
|
26
|
+
private normalizeKey;
|
|
27
|
+
/**
|
|
28
|
+
* Обрабатывает runtime-событие HotkeyManager.
|
|
29
|
+
*/
|
|
30
|
+
private handle;
|
|
31
|
+
/**
|
|
32
|
+
* Обрабатывает входящее событие HotkeyManager.
|
|
33
|
+
*/
|
|
34
|
+
on(keys: string | Array<string>, handler: HotkeyHandler): void;
|
|
35
|
+
/**
|
|
36
|
+
* Выполняет действие off в рамках ответственности HotkeyManager.
|
|
37
|
+
*/
|
|
38
|
+
off(keys: string | Array<string>, handler: HotkeyHandler): void;
|
|
39
|
+
/**
|
|
40
|
+
* Очищает накопленное состояние HotkeyManager.
|
|
41
|
+
*/
|
|
42
|
+
clear(key?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Выполняет действие enable в рамках ответственности HotkeyManager.
|
|
45
|
+
*/
|
|
46
|
+
enable(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Выполняет действие disable в рамках ответственности HotkeyManager.
|
|
49
|
+
*/
|
|
50
|
+
disable(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Освобождает runtime-ресурсы и подписки HotkeyManager.
|
|
53
|
+
*/
|
|
54
|
+
destroy(): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { isAnyKeyComboActive, type KeyCombo, type KeyComboArray } from '../shared/utils/keyboard';
|
|
2
|
+
export type KeyboardStatePlatform = 'macos' | 'windows' | 'linux' | 'unknown';
|
|
3
|
+
export interface KeyboardStateSnapshot {
|
|
4
|
+
platform: KeyboardStatePlatform;
|
|
5
|
+
modifiers: {
|
|
6
|
+
ctrl: boolean;
|
|
7
|
+
shift: boolean;
|
|
8
|
+
alt: boolean;
|
|
9
|
+
meta: boolean;
|
|
10
|
+
mod: boolean;
|
|
11
|
+
altGraph: boolean;
|
|
12
|
+
};
|
|
13
|
+
held: {
|
|
14
|
+
key: string[];
|
|
15
|
+
code: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Returns the shared document-scoped keyboard snapshot, installing one tracker lazily. */
|
|
19
|
+
export declare function getKeyboardStateSnapshot(target: Document): KeyboardStateSnapshot;
|
|
20
|
+
/** Subscribes to the shared document-scoped keyboard state and immediately emits its snapshot. */
|
|
21
|
+
export declare function subscribeKeyboardState(target: Document, listener: (snapshot: KeyboardStateSnapshot) => void): () => void;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Subscribable } from '../events/Subscribable';
|
|
2
|
+
/**
|
|
3
|
+
* Структурированная запись лога.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* {
|
|
7
|
+
* timestamp: 1692826342203,
|
|
8
|
+
* level: 'info',
|
|
9
|
+
* message: 'Компонент успешно собран',
|
|
10
|
+
* context: ['components', 'DriverCard'],
|
|
11
|
+
* actions: [
|
|
12
|
+
* {
|
|
13
|
+
* icon: 'ti ti-eye',
|
|
14
|
+
* tooltip: 'Посмотреть компонент',
|
|
15
|
+
* handler: () => alert('Открываю DriverCard'),
|
|
16
|
+
* },
|
|
17
|
+
* ],
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
export interface StructuredLogEntry {
|
|
21
|
+
/** Время создания лога (timestamp в ms) */
|
|
22
|
+
timestamp: number;
|
|
23
|
+
/** Уровень лога: _debug, info, warn или error */
|
|
24
|
+
level: 'debug' | 'info' | 'warn' | 'error' | 'success';
|
|
25
|
+
/** Сообщение лога */
|
|
26
|
+
message: string;
|
|
27
|
+
/** Контекст (иерархия вложенности) */
|
|
28
|
+
context: Array<string>;
|
|
29
|
+
/** Дополнительные действия (например, кнопки для лога) */
|
|
30
|
+
actions?: Array<{
|
|
31
|
+
icon: string;
|
|
32
|
+
tooltip?: string;
|
|
33
|
+
handler: () => void;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Логгер с поддержкой:
|
|
38
|
+
* - Иерархического контекста (`context`, `start`, `end`).
|
|
39
|
+
* - Разных уровней (`_debug`, `info`, `warn`, `error`).
|
|
40
|
+
* - Action-кнопок для каждого лога.
|
|
41
|
+
* - Подписки на обновления (через `Subscribable`).
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const logger = new StructuredLogger()
|
|
45
|
+
*
|
|
46
|
+
* // Устанавливаем контекст
|
|
47
|
+
* logger.context('components', 'DriverCard')
|
|
48
|
+
*
|
|
49
|
+
* // Логируем сообщение
|
|
50
|
+
* logger.info('Компонент успешно собран')
|
|
51
|
+
*
|
|
52
|
+
* // Добавляем действие
|
|
53
|
+
* logger.warn('Предупреждение', [
|
|
54
|
+
* { icon: 'ti ti-alert', tooltip: 'Подробнее', handler: () => alert('Подробнее!') },
|
|
55
|
+
* ])
|
|
56
|
+
*
|
|
57
|
+
* // Используем вложенные уровни
|
|
58
|
+
* logger.start('attributes').info('Загрузка атрибутов')
|
|
59
|
+
* logger.end()
|
|
60
|
+
*
|
|
61
|
+
* // Получаем все логи
|
|
62
|
+
* const logs = logger.getLogs()
|
|
63
|
+
*/
|
|
64
|
+
export declare class StructuredLogger extends Subscribable {
|
|
65
|
+
/** Массив всех логов */
|
|
66
|
+
private logs;
|
|
67
|
+
/** Текущий контекст (иерархия) */
|
|
68
|
+
private currentContext;
|
|
69
|
+
private currentActions;
|
|
70
|
+
/**
|
|
71
|
+
* Устанавливает текущий контекст.
|
|
72
|
+
* Сбрасывает предыдущий контекст.
|
|
73
|
+
*
|
|
74
|
+
* @param context Массив строк или несколько строк с уровнями контекста.
|
|
75
|
+
* @returns _surface (для цепочки вызовов)
|
|
76
|
+
* @example
|
|
77
|
+
* logger.context('components', 'DriverCard')
|
|
78
|
+
*/
|
|
79
|
+
context(...context: Array<string>): this;
|
|
80
|
+
/**
|
|
81
|
+
* Добавляет дополнительный уровень контекста.
|
|
82
|
+
*
|
|
83
|
+
* @param context Новый уровень (например, 'attributes').
|
|
84
|
+
* @returns _surface (для цепочки вызовов)
|
|
85
|
+
* @example
|
|
86
|
+
* logger.start('attributes')
|
|
87
|
+
*/
|
|
88
|
+
start(context: string): this;
|
|
89
|
+
/**
|
|
90
|
+
* Убирает последний уровень контекста.
|
|
91
|
+
* При этом может сразу добавить финальный лог, связанный с этим контекстом.
|
|
92
|
+
*
|
|
93
|
+
* @param level Уровень лога (по умолчанию 'info')
|
|
94
|
+
* @param message Сообщение лога (опционально)
|
|
95
|
+
* @param actions Дополнительные действия (опционально)
|
|
96
|
+
* @example
|
|
97
|
+
* logger.end('info', 'Компиляция завершена', [...])
|
|
98
|
+
*/
|
|
99
|
+
end(level?: 'debug' | 'info' | 'warn' | 'error' | 'success', message?: string, actions?: StructuredLogEntry['actions']): this;
|
|
100
|
+
/**
|
|
101
|
+
* Добавляет экшены в текущий контекст (для следующего `end`)
|
|
102
|
+
* @param icon Иконка (например, "ti ti-check text-xl")
|
|
103
|
+
* @param tooltip Подсказка (опционально)
|
|
104
|
+
* @param handler Функция при клике (опционально)
|
|
105
|
+
* @example
|
|
106
|
+
* logger.action('ti ti-check', 'Все успешно', () => console.logFrame('Успешно!'))
|
|
107
|
+
*/
|
|
108
|
+
action(icon: string, tooltip?: string, handler?: () => void): this;
|
|
109
|
+
/**
|
|
110
|
+
* Внутренний метод для создания лога.
|
|
111
|
+
*
|
|
112
|
+
* @param level Уровень (_debug, info, warn, error)
|
|
113
|
+
* @param message Сообщение
|
|
114
|
+
* @param actions Дополнительные действия (иконки с обработчиками)
|
|
115
|
+
*/
|
|
116
|
+
private log;
|
|
117
|
+
/**
|
|
118
|
+
* Лог уровня _debug.
|
|
119
|
+
*
|
|
120
|
+
* @param message Сообщение
|
|
121
|
+
* @param actions Дополнительные действия (опционально)
|
|
122
|
+
* @example
|
|
123
|
+
* logger._debug('Загрузка данных')
|
|
124
|
+
*/
|
|
125
|
+
debug(message: string, actions?: StructuredLogEntry['actions']): void;
|
|
126
|
+
/**
|
|
127
|
+
* Лог уровня info.
|
|
128
|
+
*
|
|
129
|
+
* @param message Сообщение
|
|
130
|
+
* @param actions Дополнительные действия (опционально)
|
|
131
|
+
* @example
|
|
132
|
+
* logger.info('Загрузка завершена')
|
|
133
|
+
*/
|
|
134
|
+
info(message: string, actions?: StructuredLogEntry['actions']): void;
|
|
135
|
+
/**
|
|
136
|
+
* Лог уровня warn.
|
|
137
|
+
*
|
|
138
|
+
* @param message Сообщение
|
|
139
|
+
* @param actions Дополнительные действия (опционально)
|
|
140
|
+
* @example
|
|
141
|
+
* logger.warn('Низкий заряд батареи')
|
|
142
|
+
*/
|
|
143
|
+
warn(message: string, actions?: StructuredLogEntry['actions']): void;
|
|
144
|
+
/**
|
|
145
|
+
* Лог уровня error.
|
|
146
|
+
*
|
|
147
|
+
* @param message Сообщение
|
|
148
|
+
* @param actions Дополнительные действия (опционально)
|
|
149
|
+
* @example
|
|
150
|
+
* logger.error('Ошибка загрузки', [
|
|
151
|
+
* { icon: 'ti ti-refresh', tooltip: 'Повторить', handler: () => retry() },
|
|
152
|
+
* ])
|
|
153
|
+
*/
|
|
154
|
+
error(message: string, actions?: StructuredLogEntry['actions']): void;
|
|
155
|
+
/**
|
|
156
|
+
* Лог уровня success.
|
|
157
|
+
*
|
|
158
|
+
* @param message Сообщение
|
|
159
|
+
* @param actions Дополнительные действия (опционально)
|
|
160
|
+
* @example
|
|
161
|
+
* logger.success('Успешно', [
|
|
162
|
+
* { icon: 'ti ti-refresh', tooltip: 'Повторить', handler: () => retry() },
|
|
163
|
+
* ])
|
|
164
|
+
*/
|
|
165
|
+
success(message: string, actions?: StructuredLogEntry['actions']): void;
|
|
166
|
+
/**
|
|
167
|
+
* Получить все логи.
|
|
168
|
+
*
|
|
169
|
+
* @returns Массив логов
|
|
170
|
+
*/
|
|
171
|
+
getLogs(): Array<StructuredLogEntry>;
|
|
172
|
+
/**
|
|
173
|
+
* Очистить все логи (полностью).
|
|
174
|
+
*/
|
|
175
|
+
clear(): void;
|
|
176
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Проверяет, является ли переданная функция конструктором.
|
|
3
|
+
*/
|
|
4
|
+
export declare function isConstructor<T extends new (...args: Array<any>) => any>(fn: any): fn is T;
|
|
5
|
+
/**
|
|
6
|
+
* Утилитарный тип: или конструктор, или фабрика.
|
|
7
|
+
*/
|
|
8
|
+
export type ConstructorOrFactory<T, Args extends Array<any> = Array<any>> = (new (...args: Args) => T) | ((...args: Args) => T);
|
|
9
|
+
/**
|
|
10
|
+
* Универсальный вызов: конструктор или фабрика.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createInstance<T, Args extends Array<any>>(source: ConstructorOrFactory<T, Args>, ...args: Args): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function globalState<T>(factory: () => T): () => T;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DateTime } from 'ts-luxon';
|
|
2
|
+
export declare const SystemClock: {
|
|
3
|
+
DateTime: typeof DateTime;
|
|
4
|
+
toDateTime(jsDate: Date): DateTime;
|
|
5
|
+
fromFormat(text: string, format: string, opts: any): DateTime;
|
|
6
|
+
fromISO(text: string, opts?: any): DateTime | null;
|
|
7
|
+
getNow(): DateTime;
|
|
8
|
+
getNowUTC(): DateTime;
|
|
9
|
+
getToday(): DateTime;
|
|
10
|
+
getTime(format?: string): string;
|
|
11
|
+
getUTCTime(format?: string): string;
|
|
12
|
+
getZone(): import('ts-luxon').Zone;
|
|
13
|
+
};
|
|
14
|
+
export declare const dt: (date: Date) => DateTime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { capitalize } from '../shared/utils/text';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../shared/utils/time';
|