@vef-framework/shared 2.0.11 → 2.1.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.
Files changed (115) hide show
  1. package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
  2. package/dist/cjs/color/color-ops.cjs +1 -1
  3. package/dist/cjs/color/index.cjs +1 -1
  4. package/dist/cjs/color/name.cjs +1 -1
  5. package/dist/cjs/color/palette.cjs +1 -1
  6. package/dist/cjs/constants/color-names.cjs +1 -1
  7. package/dist/cjs/constants/color-palettes.cjs +1 -1
  8. package/dist/cjs/constants/index.cjs +1 -1
  9. package/dist/cjs/index.cjs +1 -1
  10. package/dist/cjs/types/color.cjs +0 -1
  11. package/dist/cjs/types/common.cjs +0 -1
  12. package/dist/cjs/types/deep-keys.cjs +0 -1
  13. package/dist/cjs/types/index.cjs +0 -1
  14. package/dist/cjs/utils/chrono.cjs +1 -1
  15. package/dist/cjs/utils/equal.cjs +1 -1
  16. package/dist/cjs/utils/error.cjs +2 -3
  17. package/dist/cjs/utils/event.cjs +1 -1
  18. package/dist/cjs/utils/format.cjs +1 -1
  19. package/dist/cjs/utils/function.cjs +1 -1
  20. package/dist/cjs/utils/id.cjs +1 -1
  21. package/dist/cjs/utils/index.cjs +1 -1
  22. package/dist/cjs/utils/key.cjs +1 -1
  23. package/dist/cjs/utils/lib.cjs +1 -1
  24. package/dist/cjs/utils/object.cjs +1 -1
  25. package/dist/cjs/utils/path.cjs +1 -1
  26. package/dist/cjs/utils/pinyin.cjs +1 -1
  27. package/dist/cjs/utils/security.cjs +1 -1
  28. package/dist/cjs/utils/string.cjs +1 -1
  29. package/dist/cjs/utils/table.cjs +1 -1
  30. package/dist/cjs/utils/task.cjs +1 -1
  31. package/dist/cjs/utils/tree.cjs +1 -1
  32. package/dist/cjs/utils/zod.cjs +1 -1
  33. package/dist/es/color/color-ops.js +55 -68
  34. package/dist/es/color/index.js +4 -18
  35. package/dist/es/color/name.js +25 -27
  36. package/dist/es/color/palette.js +70 -82
  37. package/dist/es/constants/color-names.js +1572 -1572
  38. package/dist/es/constants/color-palettes.js +1085 -360
  39. package/dist/es/constants/index.js +3 -8
  40. package/dist/es/index.js +25 -167
  41. package/dist/es/types/color.js +1 -1
  42. package/dist/es/types/common.js +1 -1
  43. package/dist/es/types/deep-keys.js +1 -1
  44. package/dist/es/types/index.js +1 -3
  45. package/dist/es/utils/chrono.js +77 -92
  46. package/dist/es/utils/equal.js +83 -118
  47. package/dist/es/utils/error.js +27 -29
  48. package/dist/es/utils/event.js +27 -51
  49. package/dist/es/utils/format.js +27 -18
  50. package/dist/es/utils/function.js +26 -36
  51. package/dist/es/utils/id.js +21 -21
  52. package/dist/es/utils/index.js +18 -81
  53. package/dist/es/utils/key.js +17 -23
  54. package/dist/es/utils/lib.js +8 -64
  55. package/dist/es/utils/object.js +12 -12
  56. package/dist/es/utils/path.js +37 -58
  57. package/dist/es/utils/pinyin.js +41 -43
  58. package/dist/es/utils/security.js +73 -31
  59. package/dist/es/utils/string.js +19 -7
  60. package/dist/es/utils/table.js +13 -13
  61. package/dist/es/utils/task.js +6 -7
  62. package/dist/es/utils/tree.js +159 -181
  63. package/dist/es/utils/zod.js +7 -7
  64. package/dist/types/constants/color-names.d.ts +2 -2
  65. package/dist/types/constants/color-palettes.d.ts +2 -2
  66. package/dist/types/src/color/color-ops.d.ts +84 -0
  67. package/dist/types/src/color/index.d.ts +3 -0
  68. package/dist/types/src/color/name.d.ts +7 -0
  69. package/dist/types/src/color/palette.d.ts +8 -0
  70. package/dist/types/src/constants/color-names.d.ts +11 -0
  71. package/dist/types/src/constants/color-palettes.d.ts +823 -0
  72. package/dist/types/src/constants/index.d.ts +2 -0
  73. package/dist/types/src/index.d.ts +4 -0
  74. package/dist/types/src/types/color.d.ts +25 -0
  75. package/dist/types/src/types/common.d.ts +29 -0
  76. package/dist/types/src/types/deep-keys.d.ts +37 -0
  77. package/dist/types/src/types/index.d.ts +3 -0
  78. package/dist/types/src/utils/chrono.d.ts +152 -0
  79. package/dist/types/src/utils/equal.d.ts +16 -0
  80. package/dist/types/src/utils/error.d.ts +22 -0
  81. package/dist/types/src/utils/event.d.ts +46 -0
  82. package/dist/types/src/utils/format.d.ts +31 -0
  83. package/dist/types/src/utils/function.d.ts +27 -0
  84. package/dist/types/src/utils/id.d.ts +6 -0
  85. package/dist/types/src/utils/index.d.ts +18 -0
  86. package/dist/types/src/utils/key.d.ts +5 -0
  87. package/dist/types/src/utils/lib.d.ts +5 -0
  88. package/dist/types/src/utils/object.d.ts +9 -0
  89. package/dist/types/src/utils/path.d.ts +13 -0
  90. package/dist/types/src/utils/pinyin.d.ts +40 -0
  91. package/dist/types/src/utils/security.d.ts +60 -0
  92. package/dist/types/src/utils/string.d.ts +15 -0
  93. package/dist/types/src/utils/table.d.ts +25 -0
  94. package/dist/types/src/utils/task.d.ts +4 -0
  95. package/dist/types/src/utils/tree.d.ts +216 -0
  96. package/dist/types/src/utils/zod.d.ts +2 -0
  97. package/dist/types/types/color.d.ts +1 -49
  98. package/dist/types/types/common.d.ts +7 -3
  99. package/dist/types/types/deep-keys.d.ts +28 -0
  100. package/dist/types/utils/chrono.d.ts +3 -13
  101. package/dist/types/utils/error.d.ts +5 -21
  102. package/dist/types/utils/event.d.ts +9 -31
  103. package/dist/types/utils/format.d.ts +0 -2
  104. package/dist/types/utils/function.d.ts +4 -36
  105. package/dist/types/utils/id.d.ts +2 -2
  106. package/dist/types/utils/key.d.ts +2 -4
  107. package/dist/types/utils/path.d.ts +7 -70
  108. package/dist/types/utils/pinyin.d.ts +2 -3
  109. package/dist/types/utils/security.d.ts +44 -2
  110. package/dist/types/utils/string.d.ts +8 -0
  111. package/dist/types/utils/table.d.ts +1 -0
  112. package/dist/types/utils/task.d.ts +1 -3
  113. package/dist/types/utils/tree.d.ts +8 -0
  114. package/dist/types/utils/zod.d.ts +1 -0
  115. package/package.json +13 -13
@@ -0,0 +1,2 @@
1
+ export * from './color-names';
2
+ export * from './color-palettes';
@@ -0,0 +1,4 @@
1
+ export * from './color';
2
+ export * from './constants';
3
+ export * from './types';
4
+ export * from './utils';
@@ -0,0 +1,25 @@
1
+ export type ColorEntry = [hex: string, name: string];
2
+ export type ColorNumber = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
3
+ export interface ColorSwatch {
4
+ number: ColorNumber;
5
+ hex: string;
6
+ }
7
+ export interface ColorPalette {
8
+ name: string;
9
+ swatches: ColorSwatch[];
10
+ }
11
+ export interface ColorSwatchWithDelta extends ColorSwatch {
12
+ delta: number;
13
+ }
14
+ export interface NearestColorPalette extends ColorPalette {
15
+ nearestSwatch: ColorSwatchWithDelta;
16
+ nearestLightnessSwatch: ColorSwatchWithDelta;
17
+ }
18
+ export interface MatchedColorPalette extends ColorPalette {
19
+ colorMap: Map<ColorNumber, string>;
20
+ /**
21
+ * The main color swatch with number 500
22
+ */
23
+ main: ColorSwatch;
24
+ matched: ColorSwatch;
25
+ }
@@ -0,0 +1,29 @@
1
+ import { Primitive } from 'type-fest';
2
+ export type Builtin = Primitive | Function | Date | Error | RegExp;
3
+ export type Key = string;
4
+ export type Awaitable<T> = T | Promise<T>;
5
+ export type MaybeArray<T> = T | T[];
6
+ export type MaybeNullish<T> = T | null | undefined;
7
+ export type MaybeUndefined<T> = T | undefined;
8
+ export type MaybeNull<T> = T | null;
9
+ export type IsString<T> = T extends string ? true : false;
10
+ /**
11
+ * Inverts a boolean type.
12
+ *
13
+ * @example Not<true> = false, Not<false> = true
14
+ */
15
+ export type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
16
+ export interface EmptyObject {
17
+ }
18
+ export type AnyObject = Record<keyof any, any>;
19
+ export type RenameKey<T, TOldKey extends keyof T, TNewKey extends string> = {
20
+ [K in keyof T as K extends TOldKey ? TNewKey : K]: T[K];
21
+ };
22
+ export type NonFunctionGuard<T> = T extends Function ? never : T;
23
+ /**
24
+ * Omits all symbol keys from an object type.
25
+ */
26
+ export type OmitSymbol<T> = {
27
+ [K in keyof T as K extends symbol ? never : K]: T[K];
28
+ };
29
+ export type { And, Except, HasOptionalKeys, HasRequiredKeys, If, IsAny, IsBooleanLiteral, IsEqual, IsFloat, IsInteger, IsLiteral, IsNever, IsNull, IsNullable, IsNumericLiteral, IsOptional, IsOptionalKeyOf, IsReadonlyKeyOf, IsRequiredKeyOf, IsStringLiteral, IsSymbolLiteral, IsTuple, IsUndefined, IsUnknown, IsWritableKeyOf, IterableElement, KebabCase, LiteralUnion, NonEmptyObject, NonEmptyString, NonEmptyTuple, OptionalKeysOf, Or, OverrideProperties, PartialDeep, Primitive, RequiredDeep, RequiredKeysOf, SetFieldType, SetOptional, SetParameterType, SetReadonly, SetRequired, SetReturnType, Simplify, SimplifyDeep } from 'type-fest';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Generates a range of numbers from 0 to N-1 as a tuple type.
3
+ * Used to create a union of valid array indices.
4
+ */
5
+ type ComputeRange<N extends number, Result extends unknown[] = []> = Result["length"] extends N ? Result : ComputeRange<N, [...Result, Result["length"]]>;
6
+ /**
7
+ * Union type of numbers from 0 to 39.
8
+ * Limits tuple index depth to prevent excessive type recursion.
9
+ */
10
+ type Index40 = ComputeRange<40>[number];
11
+ /**
12
+ * Checks if a type is a tuple (fixed-length array) with length <= 40.
13
+ * Returns the tuple type if valid, never otherwise.
14
+ */
15
+ type IsTuple<T> = T extends readonly any[] & {
16
+ length: infer Length;
17
+ } ? Length extends Index40 ? T : never : never;
18
+ /**
19
+ * Extracts all valid numeric indices from a tuple type.
20
+ * For [string, number, boolean], returns 0 | 1 | 2.
21
+ */
22
+ type AllowedIndexes<Tuple extends readonly any[], Keys extends number = never> = Tuple extends readonly [] ? Keys : Tuple extends readonly [infer _, ...infer Tail] ? AllowedIndexes<Tail, Keys | Tail["length"]> : Keys;
23
+ /**
24
+ * Creates dot-notation paths for nested properties.
25
+ * Converts TPrefix.NestedKey into string literal types.
26
+ */
27
+ type DeepKeysPrefix<T, TPrefix, TDepth extends any[]> = TPrefix extends keyof T & (number | string) ? `${TPrefix}.${DeepKeys<T[TPrefix], [...TDepth, any]> & string}` : never;
28
+ /**
29
+ * Extracts all possible deep property paths from an object type as dot-notation strings.
30
+ * Supports nested objects, tuples, and arrays up to 5 levels deep.
31
+ *
32
+ * @example
33
+ * type User = { name: string; address: { city: string; zip: number } };
34
+ * type Paths = DeepKeys<User>; // "name" | "address" | "address.city" | "address.zip"
35
+ */
36
+ export type DeepKeys<T, TDepth extends any[] = []> = TDepth["length"] extends 5 ? never : unknown extends T ? string : T extends readonly any[] & IsTuple<T> ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>, TDepth> : T extends any[] ? DeepKeys<T[number], [...TDepth, any]> : T extends Date ? never : T extends object ? (keyof T & string) | DeepKeysPrefix<T, keyof T, TDepth> : never;
37
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './color';
2
+ export * from './common';
3
+ export * from './deep-keys';
@@ -0,0 +1,152 @@
1
+ import { DurationUnitType } from 'dayjs/plugin/duration';
2
+ import { MaybeNull } from '../types';
3
+ import { default as dayjs } from 'dayjs';
4
+ export type Dayjs = dayjs.Dayjs;
5
+ /**
6
+ * Temporal picker mode type.
7
+ * Defines the granularity of date/time selection.
8
+ */
9
+ export type TemporalMode = "minute" | "hour" | "time" | "date" | "datetime" | "week" | "month" | "quarter" | "year";
10
+ export declare const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
11
+ export declare const DEFAULT_TIME_FORMAT = "HH:mm:ss";
12
+ export declare const DEFAULT_DATETIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
13
+ export declare const LOCALIZED_DATETIME_FORMAT = "LLLL";
14
+ export declare const LOCALIZED_DATE_FORMAT = "LLdddd";
15
+ /**
16
+ * Format duration to human readable string.
17
+ *
18
+ * @param value - Duration value
19
+ * @param unit - The unit of the duration (default: "seconds")
20
+ * @returns Formatted duration string
21
+ * @example
22
+ * ```ts
23
+ * formatDuration(60) // "1分钟"
24
+ * formatDuration(3600) // "1小时0分钟"
25
+ * formatDuration(86400) // "1天0小时0分钟"
26
+ * formatDuration(90061) // "1天1小时1分钟"
27
+ * ```
28
+ */
29
+ export declare function formatDuration(value: number, unit?: DurationUnitType): string;
30
+ /**
31
+ * Parses a date string into a dayjs instance with optional format.
32
+ *
33
+ * @param date - The date string or Date object to parse
34
+ * @param format - The format string to use for parsing (optional, ignored for Date objects)
35
+ * @returns A dayjs instance
36
+ * @example
37
+ * ```ts
38
+ * parseDate("2025-11-10") // dayjs instance
39
+ * parseDate("2025-11-10 16:30:45") // dayjs instance
40
+ * parseDate("20251110", "YYYYMMDD") // dayjs instance with custom format
41
+ * parseDate("10/11/2025", "DD/MM/YYYY") // dayjs instance with custom format
42
+ * parseDate(new Date()) // dayjs instance from Date object
43
+ * ```
44
+ */
45
+ export declare function parseDate(date: string | Date, format?: MaybeNull<string>): Dayjs;
46
+ /**
47
+ * Attempts to parse a date string by trying various datetime and date formats.
48
+ * Returns null if parsing fails with all formats.
49
+ *
50
+ * @param date - The date string to parse
51
+ * @returns A dayjs instance if parsing succeeds, null otherwise
52
+ * @example
53
+ * ```ts
54
+ * tryParseDate("2025-11-10 16:30:45") // dayjs instance
55
+ * tryParseDate("2025/11/10") // dayjs instance
56
+ * tryParseDate("20251110") // dayjs instance
57
+ * tryParseDate("invalid date") // null
58
+ * ```
59
+ */
60
+ export declare function tryParseDate(date: string): MaybeNull<Dayjs>;
61
+ /**
62
+ * Formats a dayjs instance with the specified format.
63
+ *
64
+ * @param date - The dayjs instance to format
65
+ * @param format - The format string (defaults to "YYYY-MM-DD HH:mm:ss")
66
+ * @returns The formatted date string
67
+ * @example
68
+ * ```ts
69
+ * formatDate(dayjs()) // "2025-11-10 16:30:45"
70
+ * formatDate(dayjs(), "YYYY-MM-DD") // "2025-11-10"
71
+ * formatDate(dayjs(), "HH:mm:ss") // "16:30:45"
72
+ * ```
73
+ */
74
+ export declare function formatDate(date: Dayjs, format?: string): string;
75
+ /**
76
+ * Gets the current time as a dayjs instance.
77
+ *
78
+ * @returns The current time as a dayjs instance
79
+ * @example
80
+ * ```ts
81
+ * const now = getNow() // dayjs instance
82
+ * now.format("YYYY-MM-DD") // "2025-11-10"
83
+ * ```
84
+ */
85
+ export declare function getNow(): Dayjs;
86
+ /**
87
+ * Gets the current date string in "YYYY-MM-DD" format.
88
+ *
89
+ * @returns The current date string
90
+ * @example
91
+ * ```ts
92
+ * getNowDateString() // "2025-11-10"
93
+ * ```
94
+ */
95
+ export declare function getNowDateString(): string;
96
+ /**
97
+ * Gets the current time string in "HH:mm:ss" format.
98
+ *
99
+ * @returns The current time string
100
+ * @example
101
+ * ```ts
102
+ * getNowTimeString() // "16:30:45"
103
+ * ```
104
+ */
105
+ export declare function getNowTimeString(): string;
106
+ /**
107
+ * Gets the current date time string in "YYYY-MM-DD HH:mm:ss" format.
108
+ *
109
+ * @returns The current date time string
110
+ * @example
111
+ * ```ts
112
+ * getNowDateTimeString() // "2025-11-10 16:30:45"
113
+ * ```
114
+ */
115
+ export declare function getNowDateTimeString(): string;
116
+ /**
117
+ * Gets the current date time in a localized full format.
118
+ *
119
+ * @returns The localized date time string
120
+ * @example
121
+ * ```ts
122
+ * // With zh-cn locale
123
+ * getLocalizedDateTime() // "2025年11月10日星期日下午4点30分45秒"
124
+ * getLocalizedDateTime(false) // "2025年11月10日星期日"
125
+ * ```
126
+ */
127
+ export declare function getLocalizedDateTime(includeTime?: boolean): string;
128
+ declare const FORMAT_MAP: {
129
+ readonly year: readonly ["YYYY"];
130
+ readonly quarter: readonly ["YYYY-Q季度"];
131
+ readonly month: readonly ["YYYY-MM", "YYYY/MM", "YYYY.MM", "YYYYMM"];
132
+ readonly week: readonly ["YYYY-wo"];
133
+ readonly date: readonly ["YYYY-MM-DD", "YYYY/MM/DD", "YYYY.MM.DD", "YYYYMMDD", "YY/MM/DD", "YY.MM.DD", "YYMMDD"];
134
+ readonly time: readonly ["HH:mm:ss", "HH.mm.ss", "HHmmss"];
135
+ readonly hour: readonly ["HH"];
136
+ readonly minute: readonly ["HH:mm", "HH.mm", "HHmm"];
137
+ readonly datetime: readonly ["YYYY-MM-DD HH:mm:ss", "YYYY/MM/DD HH:mm:ss", "YYYY.MM.DD HH.mm.ss", "YYYYMMDDHHmmss", "YY/MM/DD HH:mm:ss", "YY.MM.DD HH:mm:ss", "YY.MM.DD HH.mm.ss", "YYMMDDHHmmss"];
138
+ };
139
+ /**
140
+ * Gets the available format patterns for a temporal picker mode.
141
+ *
142
+ * @param mode - The temporal picker mode
143
+ * @returns An array of format strings for the specified mode
144
+ * @example
145
+ * ```ts
146
+ * getTemporalFormats("date") // ["YYYY-MM-DD", "YYYY/MM/DD", ...]
147
+ * getTemporalFormats("time") // ["HH:mm:ss", "HH.mm.ss", "HHmmss"]
148
+ * getTemporalFormats("datetime") // ["YYYY-MM-DD HH:mm:ss", ...]
149
+ * ```
150
+ */
151
+ export declare function getTemporalFormats<const T extends TemporalMode>(mode: T): typeof FORMAT_MAP[T];
152
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shallowly compares two values.
3
+ *
4
+ * @param value1 - The first value to compare.
5
+ * @param value2 - The second value to compare.
6
+ * @returns `true` if the values are shallowly equal, `false` otherwise.
7
+ */
8
+ export declare function isShallowEqual(value1: unknown, value2: unknown): boolean;
9
+ /**
10
+ * Deeply compares two values, with support for circular references.
11
+ *
12
+ * @param value1 - The first value to compare.
13
+ * @param value2 - The second value to compare.
14
+ * @returns `true` if the values are deeply equal, `false` otherwise.
15
+ */
16
+ export declare function isDeepEqual(value1: unknown, value2: unknown): boolean;
@@ -0,0 +1,22 @@
1
+ import * as stackTrace from "stacktrace-js";
2
+ export type StackFrame = stackTrace.StackFrame;
3
+ /**
4
+ * Parse error stack and optionally filter frames.
5
+ */
6
+ export declare function parseErrorStack(error: Error, filter?: (frame: StackFrame) => boolean): Promise<StackFrame[]>;
7
+ /**
8
+ * Filter to exclude node_modules frames (user code only).
9
+ */
10
+ export declare function filterUserFrame(stackFrame: StackFrame): boolean;
11
+ /**
12
+ * Get sanitized error stack with user frames only.
13
+ */
14
+ export declare function getSanitizedErrorStack(error: Error): Promise<string>;
15
+ /**
16
+ * Get current call stack.
17
+ */
18
+ export declare function getCurrentStack(filter?: (frame: StackFrame) => boolean): Promise<StackFrame[]>;
19
+ /**
20
+ * Get current call stack synchronously.
21
+ */
22
+ export declare function getCurrentStackSync(filter?: (frame: StackFrame) => boolean): StackFrame[];
@@ -0,0 +1,46 @@
1
+ import { EventHandlerMap, EventType, Handler } from 'mitt';
2
+ /**
3
+ * Type-safe event emitter wrapper around mitt library.
4
+ */
5
+ export declare class EventEmitter<TEvents extends Record<EventType, any> = Record<EventType, unknown>> {
6
+ #private;
7
+ /**
8
+ * Subscribe to an event. Returns unsubscribe function.
9
+ */
10
+ on<const TEventType extends keyof TEvents>(eventType: TEventType, eventListener: Handler<TEvents[TEventType]>): () => void;
11
+ /**
12
+ * Emit an event with optional payload.
13
+ */
14
+ emit<const TEventType extends keyof TEvents>(eventType: undefined extends TEvents[TEventType] ? TEventType : never): void;
15
+ emit<const TEventType extends keyof TEvents>(eventType: TEventType, eventPayload: TEvents[TEventType]): void;
16
+ /**
17
+ * Remove listener(s) for an event type.
18
+ */
19
+ off<const TEventType extends keyof TEvents>(eventType: TEventType, eventListener?: Handler<TEvents[TEventType]>): void;
20
+ /**
21
+ * Remove all listeners from all events.
22
+ */
23
+ clear(): void;
24
+ /**
25
+ * Get all registered listeners (for debugging).
26
+ */
27
+ getAllListeners(): EventHandlerMap<TEvents>;
28
+ }
29
+ /**
30
+ * Create a new EventEmitter instance.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * interface AppEvents {
35
+ * 'user:login': { userId: string };
36
+ * 'user:logout': void;
37
+ * }
38
+ *
39
+ * const emitter = createEventEmitter<AppEvents>();
40
+ * const unsubscribe = emitter.on('user:login', ({ userId }) => {
41
+ * console.log(`User ${userId} logged in`);
42
+ * });
43
+ * ```
44
+ */
45
+ export declare function createEventEmitter<TEvents extends Record<EventType, any> = Record<EventType, unknown>>(): EventEmitter<TEvents>;
46
+ export { type Handler as EventHandler, type EventType } from 'mitt';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Format bytes to human readable string
3
+ *
4
+ * @param bytes - Number of bytes
5
+ * @param decimals - Number of decimal places (default: 2)
6
+ * @returns Formatted string with unit (B, KB, MB, GB, TB, PB)
7
+ * @example
8
+ * ```ts
9
+ * formatBytes(1024) // "1 KB"
10
+ * formatBytes(1536, 1) // "1.5 KB"
11
+ * formatBytes(1048576) // "1 MB"
12
+ * formatBytes(0) // "0 B"
13
+ * ```
14
+ */
15
+ export declare function formatBytes(bytes: number, decimals?: number): string;
16
+ /**
17
+ * Format large numbers to human readable string with units (K, M, B, T)
18
+ *
19
+ * @param num - Number to format
20
+ * @param decimals - Number of decimal places (default: 2)
21
+ * @returns Formatted string with unit (K, M, B, T)
22
+ * @example
23
+ * ```ts
24
+ * formatNumber(1000) // "1 K"
25
+ * formatNumber(1500, 1) // "1.5 K"
26
+ * formatNumber(1234567) // "1.23 M"
27
+ * formatNumber(999) // "999"
28
+ * formatNumber(0) // "0"
29
+ * ```
30
+ */
31
+ export declare function formatNumber(num: number, decimals?: number): string;
@@ -0,0 +1,27 @@
1
+ import { Awaitable, MaybeUndefined } from '../types';
2
+ export interface AwaitableFnInvocationOptions<in TResult, in out TContext = unknown> {
3
+ onInvoke?: () => MaybeUndefined<TContext>;
4
+ onSuccess?: (result: TResult, context: MaybeUndefined<TContext>) => void;
5
+ onError?: (error: unknown, context: MaybeUndefined<TContext>) => void;
6
+ onFinally?: (context: MaybeUndefined<TContext>) => void;
7
+ }
8
+ /**
9
+ * Checks if a function is an async function.
10
+ */
11
+ export declare function isAsyncFunction(fn: Function): fn is (...args: any[]) => Promise<any>;
12
+ /**
13
+ * Invokes an awaitable function with lifecycle hooks.
14
+ */
15
+ export declare function invokeAwaitableFn<TArgs extends any[] = any[], TResult = unknown, TContext = unknown>(fn: (...args: TArgs) => Awaitable<TResult>, args: NoInfer<TArgs>, options: AwaitableFnInvocationOptions<NoInfer<TResult>, TContext>): Promise<TResult>;
16
+ /**
17
+ * Returns the value itself (identity function).
18
+ */
19
+ export declare function identity<T>(value: T): T;
20
+ /**
21
+ * Creates a function that throws a not-implemented error.
22
+ */
23
+ export declare function createThrowNotImplementedFn(feature?: string): () => never;
24
+ /**
25
+ * Throws a not-implemented error.
26
+ */
27
+ export declare function throwNotImplemented(feature?: string): never;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates a unique ID based on browser fingerprint.
3
+ *
4
+ * @returns A unique ID string
5
+ */
6
+ export declare function generateId(): string;
@@ -0,0 +1,18 @@
1
+ export * from './chrono';
2
+ export * from './equal';
3
+ export * from './error';
4
+ export * from './event';
5
+ export * from './format';
6
+ export * from './function';
7
+ export * from './id';
8
+ export * from './key';
9
+ export * from './lib';
10
+ export * from './object';
11
+ export * from './path';
12
+ export * from './pinyin';
13
+ export * from './security';
14
+ export * from './string';
15
+ export * from './table';
16
+ export * from './task';
17
+ export * from './tree';
18
+ export * from './zod';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generate a stable hash key from any value by serializing to JSON.
3
+ * Objects are normalized with sorted keys for consistent hashing.
4
+ */
5
+ export declare function hashKey(key: unknown): string;
@@ -0,0 +1,5 @@
1
+ export declare const alwaysTrue: () => boolean;
2
+ export declare const alwaysFalse: () => boolean;
3
+ export { klona as cloneDeep } from 'klona';
4
+ export { parse as decodeQueryString, stringify as encodeQueryString } from 'qs';
5
+ export { always, assign, camel as camelCase, capitalize, cluster, debounce, first, get, isArray, isBigInt, isBoolean, isDate, isEmpty, isError, isFloat, isFunction, isInt, isIntString, isMap, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isUndefined, isWeakMap, isWeakSet, dash as kebabCase, last, max, memo as memoize, min, noop, omit, once, pascal as pascalCase, pick, set, similarity, snake as snakeCase, sum, template, throttle, toFloat, toInt, trim, unique } from 'radashi';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Merges the source object into the target object
3
+ *
4
+ * @param target - The target object
5
+ * @param source - The source object
6
+ * @param overrideExisting - Whether to override existing values
7
+ * @returns The merged object with the source object merged into the target object
8
+ */
9
+ export declare function mergeWith<T extends object>(target: T, source: Partial<T>, overrideExisting?: boolean): T;
@@ -0,0 +1,13 @@
1
+ import { default as path } from 'path-browserify';
2
+ export type PathObject = path.PathObject;
3
+ export declare function getBaseName(filePath: string, keepExt?: boolean): string;
4
+ export declare function getExtName(filePath: string): string;
5
+ export declare function getDirName(filePath: string): string;
6
+ export declare function joinPaths(...paths: string[]): string;
7
+ export declare function isAbsolutePath(filePath: string): boolean;
8
+ export declare function normalizePath(filePath: string): string;
9
+ export declare function parsePath(filePath: string): PathObject;
10
+ export declare function formatPath(pathObject: PathObject): string;
11
+ export declare function getRelativePath(from: string, to: string): string;
12
+ export declare function resolvePath(...pathSegments: string[]): string;
13
+ export declare const pathSeparator: string;
@@ -0,0 +1,40 @@
1
+ import { AnyObject, If, IsOptionalKeyOf, IsRequiredKeyOf, IsString, Simplify } from '../types';
2
+ export type WithPinyin<T extends AnyObject, K extends keyof T & string> = Simplify<WithPinyinInternal<T, K>>;
3
+ type WithPinyinInternal<T extends AnyObject, K extends keyof T & string> = T & {
4
+ [Key in K as If<IsRequiredKeyOf<T, Key>, If<IsString<T[Key]>, `${Key}Pinyin`, never>, never>]: string;
5
+ } & {
6
+ [Key in K as If<IsRequiredKeyOf<T, Key>, If<IsString<T[Key]>, `${Key}PinyinInitials`, never>, never>]: string;
7
+ } & {
8
+ [Key in K as If<IsOptionalKeyOf<T, Key>, If<IsString<T[Key]>, `${Key}Pinyin`, never>, never>]?: string;
9
+ } & {
10
+ [Key in K as If<IsOptionalKeyOf<T, Key>, If<IsString<T[Key]>, `${Key}PinyinInitials`, never>, never>]?: string;
11
+ };
12
+ /**
13
+ * Get the pinyin representation of Chinese text
14
+ *
15
+ * @param text - The Chinese text to convert
16
+ * @returns Array of pinyin strings for each character
17
+ */
18
+ export declare function getPinyin(text: string): string[];
19
+ /**
20
+ * Get the initial letters (first letters) of pinyin for Chinese text
21
+ *
22
+ * @param text - The Chinese text to convert
23
+ * @returns Array of initial letters for each character
24
+ */
25
+ export declare function getPinyinInitials(text: string): string[];
26
+ /**
27
+ * Add pinyin fields to an object for specified string keys
28
+ *
29
+ * @param obj - The source object
30
+ * @param keys - The keys to add pinyin fields for
31
+ * @returns A new object with additional pinyin and pinyin initials fields
32
+ * @example
33
+ * ```ts
34
+ * const user = { name: "张三", age: 25 };
35
+ * const result = withPinyin(user, "name");
36
+ * // result: { name: "张三", age: 25, namePinyin: "zhangsan", namePinyinInitials: "zs" }
37
+ * ```
38
+ */
39
+ export declare function withPinyin<T extends AnyObject, K extends keyof T & string>(obj: T, ...keys: K[]): WithPinyin<T, K>;
40
+ export {};
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Encode a string to XOR-encrypted byte array.
3
+ *
4
+ * @param plainText The plain text string to encode
5
+ * @returns The encrypted byte array
6
+ */
7
+ export declare function obfuscateEncode(plainText: string): Uint8Array;
8
+ /**
9
+ * Decode an XOR-encrypted byte array to string.
10
+ *
11
+ * @param encoded The encrypted byte array
12
+ * @returns The decoded string
13
+ */
14
+ export declare function obfuscateDecode(encoded: Uint8Array | number[]): string;
15
+ /**
16
+ * Encode a string to XOR-encrypted hex string.
17
+ *
18
+ * @param plainText The plain text string to encode
19
+ * @returns The encrypted hex string
20
+ */
21
+ export declare function obfuscateEncodeToHex(plainText: string): string;
22
+ /**
23
+ * Decode an XOR-encrypted hex string to plain text.
24
+ *
25
+ * @param hexString The encrypted hex string
26
+ * @returns The decoded string
27
+ */
28
+ export declare function obfuscateDecodeFromHex(hexString: string): string;
29
+ /**
30
+ * Encode a string to XOR-encrypted base64 string.
31
+ *
32
+ * @param plainText The plain text string to encode
33
+ * @returns The encrypted base64 string
34
+ */
35
+ export declare function obfuscateEncodeToBase64(plainText: string): string;
36
+ /**
37
+ * Decode an XOR-encrypted base64 string to plain text.
38
+ *
39
+ * @param base64String The encrypted base64 string
40
+ * @returns The decoded string
41
+ */
42
+ export declare function obfuscateDecodeFromBase64(base64String: string): string;
43
+ /**
44
+ * Encrypts a given value using RSA encryption with the given public key.
45
+ *
46
+ * @param value The value to encrypt
47
+ * @param publicKey The public key to use for encryption
48
+ * @returns The encrypted value
49
+ * @throws If the encryption fails or inputs are invalid
50
+ */
51
+ export declare function encryptUsingRSA(value: string, publicKey: string): string;
52
+ /**
53
+ * Decrypts a given value using RSA encryption with the given private key.
54
+ *
55
+ * @param value The value to decrypt
56
+ * @param privateKey The private key to use for decryption
57
+ * @returns The decrypted value
58
+ * @throws If the decryption fails or inputs are invalid
59
+ */
60
+ export declare function decryptUsingRSA(value: string, privateKey: string): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Convert a string to constant case
3
+ *
4
+ * @param value - The value
5
+ * @returns - The constant case string
6
+ */
7
+ export declare function constantCase(value: string): string;
8
+ /**
9
+ * Convert an unknown value to string
10
+ *
11
+ * @param value - The value to stringify
12
+ * @param emptyForNullish - Whether to return empty string for null/undefined (default: true)
13
+ * @returns - The string representation
14
+ */
15
+ export declare function stringify(value: unknown): string;
@@ -0,0 +1,25 @@
1
+ import { AnyObject } from '../types';
2
+ /**
3
+ * Comparison mode for reference values
4
+ */
5
+ export type CompareMode = "reference" | "shallow" | "deep";
6
+ /**
7
+ * Options for shouldUpdateByKeys
8
+ */
9
+ export interface ShouldUpdateByKeysOptions {
10
+ /**
11
+ * Comparison mode for reference values
12
+ * - "reference": Use strict equality (===)
13
+ * - "shallow": Use shallow comparison
14
+ * - "deep": Use deep comparison
15
+ *
16
+ * @default "reference"
17
+ */
18
+ compare?: CompareMode;
19
+ }
20
+ /**
21
+ * Creates a function that checks if any specified keys differ between two objects.
22
+ * Useful for Table's shouldCellUpdate prop to optimize re-renders.
23
+ */
24
+ export declare function shouldUpdateByKeys<T = AnyObject, const K extends keyof T = keyof T>(options: ShouldUpdateByKeysOptions, ...keys: K[]): (next: T, prev: T) => boolean;
25
+ export declare function shouldUpdateByKeys<T = AnyObject, const K extends keyof T = keyof T>(...keys: K[]): (next: T, prev: T) => boolean;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Schedule a microtask with fallback for older environments.
3
+ */
4
+ export declare function scheduleMicrotask(task: () => void): void;