@vef-framework/shared 2.0.10 → 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 (116) 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 -0
  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 -165
  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 -79
  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 +15 -0
  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/index.d.ts +1 -0
  107. package/dist/types/utils/key.d.ts +2 -4
  108. package/dist/types/utils/path.d.ts +7 -70
  109. package/dist/types/utils/pinyin.d.ts +2 -3
  110. package/dist/types/utils/security.d.ts +44 -2
  111. package/dist/types/utils/string.d.ts +8 -0
  112. package/dist/types/utils/table.d.ts +25 -0
  113. package/dist/types/utils/task.d.ts +1 -3
  114. package/dist/types/utils/tree.d.ts +8 -0
  115. package/dist/types/utils/zod.d.ts +1 -0
  116. package/package.json +13 -13
@@ -1,76 +1,13 @@
1
1
  import { default as path } from 'path-browserify';
2
- declare const pathSeparator: string;
3
2
  export type PathObject = path.PathObject;
4
- /**
5
- * Get the base name from a path
6
- *
7
- * @param path The path
8
- * @param keepExt Whether to keep the extension
9
- * @returns The base name
10
- */
11
- export declare function getBaseName(path: string, keepExt?: boolean): string;
12
- /**
13
- * Get the extension name from a path
14
- *
15
- * @param path The path
16
- * @returns The extension name
17
- */
18
- export declare function getExtName(path: string): string;
19
- /**
20
- * Get the dir name from a path
21
- *
22
- * @param path The path
23
- * @returns The dir name
24
- */
25
- export declare function getDirName(path: string): string;
26
- /**
27
- * Joins paths
28
- *
29
- * @param paths The paths
30
- * @returns The joined path
31
- */
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;
32
6
  export declare function joinPaths(...paths: string[]): string;
33
- /**
34
- * Checks if a path is absolute
35
- *
36
- * @param path The path
37
- * @returns Whether the path is absolute
38
- */
39
- export declare function isAbsolutePath(path: string): boolean;
40
- /**
41
- * Normalizes a path
42
- *
43
- * @param path The path
44
- * @returns The normalized path
45
- */
46
- export declare function normalizePath(path: string): string;
47
- /**
48
- * Parse a path
49
- *
50
- * @param path The path
51
- * @returns The parsed path
52
- */
53
- export declare function parsePath(path: string): PathObject;
54
- /**
55
- * Format a path object
56
- *
57
- * @param pathObject The path object
58
- * @returns The formatted path
59
- */
7
+ export declare function isAbsolutePath(filePath: string): boolean;
8
+ export declare function normalizePath(filePath: string): string;
9
+ export declare function parsePath(filePath: string): PathObject;
60
10
  export declare function formatPath(pathObject: PathObject): string;
61
- /**
62
- * Get the relative path from one path to another
63
- *
64
- * @param from The starting path
65
- * @param to The destination path
66
- * @returns The relative path
67
- */
68
11
  export declare function getRelativePath(from: string, to: string): string;
69
- /**
70
- * Resolve a path
71
- *
72
- * @param pathSegments The path segments
73
- * @returns The resolved path
74
- */
75
12
  export declare function resolvePath(...pathSegments: string[]): string;
76
- export { pathSeparator };
13
+ export declare const pathSeparator: string;
@@ -1,5 +1,5 @@
1
- import { AnyObject, If, IsOptionalKeyOf, IsRequiredKeyOf, IsString, Prettify } from '../types';
2
- export type WithPinyin<T extends AnyObject, K extends keyof T & string> = Prettify<WithPinyinInternal<T, K>>;
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
3
  type WithPinyinInternal<T extends AnyObject, K extends keyof T & string> = T & {
4
4
  [Key in K as If<IsRequiredKeyOf<T, Key>, If<IsString<T[Key]>, `${Key}Pinyin`, never>, never>]: string;
5
5
  } & {
@@ -29,7 +29,6 @@ export declare function getPinyinInitials(text: string): string[];
29
29
  * @param obj - The source object
30
30
  * @param keys - The keys to add pinyin fields for
31
31
  * @returns A new object with additional pinyin and pinyin initials fields
32
- *
33
32
  * @example
34
33
  * ```ts
35
34
  * const user = { name: "张三", age: 25 };
@@ -1,10 +1,52 @@
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;
1
43
  /**
2
44
  * Encrypts a given value using RSA encryption with the given public key.
3
45
  *
4
46
  * @param value The value to encrypt
5
47
  * @param publicKey The public key to use for encryption
6
48
  * @returns The encrypted value
7
- * @throws If the encryption fails
49
+ * @throws If the encryption fails or inputs are invalid
8
50
  */
9
51
  export declare function encryptUsingRSA(value: string, publicKey: string): string;
10
52
  /**
@@ -13,6 +55,6 @@ export declare function encryptUsingRSA(value: string, publicKey: string): strin
13
55
  * @param value The value to decrypt
14
56
  * @param privateKey The private key to use for decryption
15
57
  * @returns The decrypted value
16
- * @throws If the decryption fails
58
+ * @throws If the decryption fails or inputs are invalid
17
59
  */
18
60
  export declare function decryptUsingRSA(value: string, privateKey: string): string;
@@ -5,3 +5,11 @@
5
5
  * @returns - The constant case string
6
6
  */
7
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;
@@ -1,6 +1,4 @@
1
1
  /**
2
- * Schedule a microtask.
3
- *
4
- * @param task - The task to schedule.
2
+ * Schedule a microtask with fallback for older environments.
5
3
  */
6
4
  export declare function scheduleMicrotask(task: () => void): void;
@@ -5,16 +5,19 @@ import { AnyObject, Except, MaybeUndefined, SetRequired } from '../types';
5
5
  export interface FlattenTreeOptions<TNode extends AnyObject = AnyObject, TTransformedNode = FlattenedNode<TNode>> {
6
6
  /**
7
7
  * The key name for children property
8
+ *
8
9
  * @default 'children'
9
10
  */
10
11
  childrenKey?: keyof TNode;
11
12
  /**
12
13
  * Whether to include parent node reference
14
+ *
13
15
  * @default false
14
16
  */
15
17
  includeParent?: boolean;
16
18
  /**
17
19
  * Whether to include level information
20
+ *
18
21
  * @default false
19
22
  */
20
23
  includeLevel?: boolean;
@@ -77,17 +80,20 @@ export interface BuildTreeOptions<TNode extends AnyObject = AnyObject, TTransfor
77
80
  /**
78
81
  * Accessor for node id
79
82
  * Can be a property name or a getter function
83
+ *
80
84
  * @default 'id'
81
85
  */
82
86
  idKey?: KeyAccessor<TNode>;
83
87
  /**
84
88
  * Accessor for parent id
85
89
  * Can be a property name or a getter function
90
+ *
86
91
  * @default 'parentId'
87
92
  */
88
93
  parentIdKey?: KeyAccessor<TNode>;
89
94
  /**
90
95
  * The key name for children property
96
+ *
91
97
  * @default 'children'
92
98
  */
93
99
  childrenKey?: TChildrenKey;
@@ -138,11 +144,13 @@ export interface TraverseTreeOptions<TNode extends AnyObject> {
138
144
  * Traversal strategy
139
145
  * - 'dfs': Depth-First Search - visit nodes depth-wise (parent -> children -> siblings)
140
146
  * - 'bfs': Breadth-First Search - visit nodes level-wise (all nodes at level N before level N+1)
147
+ *
141
148
  * @default 'dfs'
142
149
  */
143
150
  strategy?: "dfs" | "bfs";
144
151
  /**
145
152
  * The key name for children property
153
+ *
146
154
  * @default 'children'
147
155
  */
148
156
  childrenKey?: keyof TNode;
@@ -1 +1,2 @@
1
1
  export { z } from 'zod';
2
+ export type { ZodError, ZodIssue, ZodSchema, ZodType } from 'zod';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vef-framework/shared",
3
3
  "type": "module",
4
- "version": "2.0.10",
4
+ "version": "2.1.0",
5
5
  "private": false,
6
6
  "description": "Shared utilities for VEF framework",
7
7
  "author": {
@@ -20,7 +20,7 @@
20
20
  "sideEffects": false,
21
21
  "exports": {
22
22
  ".": {
23
- "source": "./src/index.ts",
23
+ "vef": "./src/index.ts",
24
24
  "import": {
25
25
  "types": "./dist/types/index.d.ts",
26
26
  "default": "./dist/es/index.js"
@@ -45,26 +45,26 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@fingerprintjs/fingerprintjs": "^5.0.1",
49
- "@paralleldrive/cuid2": "^3.1.0",
50
- "@pinyin-pro/data": "^1.2.0",
48
+ "@fingerprintjs/fingerprintjs": "^5.1.0",
49
+ "@paralleldrive/cuid2": "^3.3.0",
50
+ "@pinyin-pro/data": "^1.3.1",
51
51
  "colord": "^2.9.3",
52
- "dayjs": "^1.11.19",
52
+ "dayjs": "^1.11.20",
53
53
  "jsencrypt": "^3.5.4",
54
54
  "klona": "^2.0.6",
55
55
  "mitt": "^3.0.1",
56
56
  "path-browserify": "^1.0.1",
57
- "pinyin-pro": "^3.27.0",
58
- "qs": "^6.14.0",
59
- "radashi": "^12.7.1",
57
+ "pinyin-pro": "^3.28.0",
58
+ "qs": "^6.15.0",
59
+ "radashi": "^12.7.2",
60
60
  "stacktrace-js": "^2.0.2",
61
- "tiny-lru": "^11.4.5",
62
- "type-fest": "^5.2.0",
63
- "zod": "^4.1.13"
61
+ "tiny-lru": "^11.4.7",
62
+ "type-fest": "^5.5.0",
63
+ "zod": "^4.3.6"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/path-browserify": "^1.0.3",
67
- "@types/qs": "^6.14.0"
67
+ "@types/qs": "^6.15.0"
68
68
  },
69
69
  "scripts": {
70
70
  "clean": "rimraf dist",