ly-utils-lib 1.0.11 → 2.4.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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +889 -686
  3. package/dist/array.cjs +237 -0
  4. package/dist/array.cjs.map +1 -0
  5. package/dist/array.d.cts +2 -0
  6. package/dist/array.d.ts +2 -0
  7. package/dist/array.js +150 -0
  8. package/dist/array.js.map +1 -0
  9. package/dist/crypto.cjs +193 -0
  10. package/dist/crypto.cjs.map +1 -0
  11. package/dist/crypto.d.cts +3 -0
  12. package/dist/crypto.d.ts +3 -0
  13. package/dist/crypto.js +144 -0
  14. package/dist/crypto.js.map +1 -0
  15. package/dist/date.cjs +563 -0
  16. package/dist/date.cjs.map +1 -0
  17. package/dist/date.d.cts +2 -0
  18. package/dist/date.d.ts +2 -0
  19. package/dist/date.js +451 -0
  20. package/dist/date.js.map +1 -0
  21. package/dist/excel.cjs +227 -0
  22. package/dist/excel.cjs.map +1 -0
  23. package/dist/excel.d.cts +2 -0
  24. package/dist/excel.d.ts +2 -0
  25. package/dist/excel.js +196 -0
  26. package/dist/excel.js.map +1 -0
  27. package/dist/index-B80SEVzM.d.cts +382 -0
  28. package/dist/index-B80SEVzM.d.ts +382 -0
  29. package/dist/index-Ba1rjTzj.d.cts +299 -0
  30. package/dist/index-Ba1rjTzj.d.ts +299 -0
  31. package/dist/index-Bg1ise7y.d.cts +253 -0
  32. package/dist/index-Bg1ise7y.d.ts +253 -0
  33. package/dist/index-BoqNpwNa.d.cts +203 -0
  34. package/dist/index-BoqNpwNa.d.ts +203 -0
  35. package/dist/index-C0qUnb9Y.d.cts +533 -0
  36. package/dist/index-C0qUnb9Y.d.ts +533 -0
  37. package/dist/index-Cy-mb5v_.d.cts +262 -0
  38. package/dist/index-Cy-mb5v_.d.ts +262 -0
  39. package/dist/index-D1f9Sym2.d.cts +148 -0
  40. package/dist/index-D1f9Sym2.d.ts +148 -0
  41. package/dist/index-Dan5oF-5.d.cts +213 -0
  42. package/dist/index-Dan5oF-5.d.ts +213 -0
  43. package/dist/index-XABfrs7z.d.cts +596 -0
  44. package/dist/index-XABfrs7z.d.ts +596 -0
  45. package/dist/index-YXWfKCK7.d.cts +109 -0
  46. package/dist/index-YXWfKCK7.d.ts +109 -0
  47. package/dist/index.cjs +3355 -0
  48. package/dist/index.cjs.map +1 -0
  49. package/dist/index.d.cts +21 -0
  50. package/dist/index.d.ts +21 -0
  51. package/dist/index.js +3294 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/map.cjs +839 -0
  54. package/dist/map.cjs.map +1 -0
  55. package/dist/map.d.cts +6 -0
  56. package/dist/map.d.ts +6 -0
  57. package/dist/map.js +811 -0
  58. package/dist/map.js.map +1 -0
  59. package/dist/object.cjs +316 -0
  60. package/dist/object.cjs.map +1 -0
  61. package/dist/object.d.cts +2 -0
  62. package/dist/object.d.ts +2 -0
  63. package/dist/object.js +247 -0
  64. package/dist/object.js.map +1 -0
  65. package/dist/pdf.cjs +197 -0
  66. package/dist/pdf.cjs.map +1 -0
  67. package/dist/pdf.d.cts +3 -0
  68. package/dist/pdf.d.ts +3 -0
  69. package/dist/pdf.js +173 -0
  70. package/dist/pdf.js.map +1 -0
  71. package/dist/storage.cjs +255 -0
  72. package/dist/storage.cjs.map +1 -0
  73. package/dist/storage.d.cts +1 -0
  74. package/dist/storage.d.ts +1 -0
  75. package/dist/storage.js +226 -0
  76. package/dist/storage.js.map +1 -0
  77. package/dist/string.cjs +232 -0
  78. package/dist/string.cjs.map +1 -0
  79. package/dist/string.d.cts +2 -0
  80. package/dist/string.d.ts +2 -0
  81. package/dist/string.js +170 -0
  82. package/dist/string.js.map +1 -0
  83. package/dist/utils.cjs +429 -0
  84. package/dist/utils.cjs.map +1 -0
  85. package/dist/utils.d.cts +2 -0
  86. package/dist/utils.d.ts +2 -0
  87. package/dist/utils.js +371 -0
  88. package/dist/utils.js.map +1 -0
  89. package/package.json +159 -33
  90. package/dist/ly-utils-lib.cjs.js +0 -52929
  91. package/dist/ly-utils-lib.cjs.js.map +0 -1
  92. package/dist/ly-utils-lib.es.js +0 -69623
  93. package/dist/ly-utils-lib.es.js.map +0 -1
  94. package/dist/ly-utils-lib.umd.js +0 -53314
  95. package/dist/ly-utils-lib.umd.js.map +0 -1
  96. package/dist/types/index.d.ts +0 -15
  97. package/dist/types/utils/esToolkit.d.ts +0 -12
  98. package/dist/types/utils/ol.d.ts +0 -181
  99. package/dist/types/utils/router.d.ts +0 -15
  100. package/dist/types/utils/storage.d.ts +0 -42
  101. package/dist/types/utils/time.d.ts +0 -76
  102. package/dist/types/utils/tool.d.ts +0 -86
  103. package/dist/vite.svg +0 -1
@@ -0,0 +1,262 @@
1
+ import { cloneDeep, groupBy, invert, isEmptyObject, isEqual, merge, omit, pick } from 'es-toolkit';
2
+
3
+ /**
4
+ * 对象工具模块
5
+ * 基于 es-toolkit 封装,提供常用的对象处理功能
6
+ */
7
+
8
+ /**
9
+ * 获取对象的所有键
10
+ * @param obj 对象
11
+ */
12
+ declare const keys: <T extends Record<string, any>>(obj: T) => (keyof T)[];
13
+ /**
14
+ * 获取对象的所有值
15
+ * @param obj 对象
16
+ */
17
+ declare const values: <T extends Record<string, any>>(obj: T) => T[keyof T][];
18
+ /**
19
+ * 获取对象的所有键值对
20
+ * @param obj 对象
21
+ */
22
+ declare const entries: <T extends Record<string, any>>(obj: T) => [keyof T, T[keyof T]][];
23
+ /**
24
+ * 从键值对数组创建对象
25
+ * @param pairs 键值对数组
26
+ */
27
+ declare const fromPairs: <K extends string | number | symbol, V>(pairs: [K, V][]) => Record<K, V>;
28
+ /**
29
+ * 获取对象的嵌套属性值
30
+ * @param obj 对象
31
+ * @param path 路径
32
+ * @param defaultValue 默认值
33
+ */
34
+ declare const get: <T>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
35
+ /**
36
+ * 设置对象的嵌套属性值
37
+ * @param obj 对象
38
+ * @param path 路径
39
+ * @param value 值
40
+ */
41
+ declare const set: (obj: Record<string, any>, path: string, value: any) => void;
42
+ /**
43
+ * 判断对象是否有某个路径
44
+ * @param obj 对象
45
+ * @param path 路径
46
+ */
47
+ declare const has: (obj: Record<string, any>, path: string) => boolean;
48
+ /**
49
+ * 判断对象是否为空
50
+ * @param obj 对象
51
+ */
52
+ declare const isEmpty: (obj: any) => boolean;
53
+ /**
54
+ * 深度合并对象
55
+ * @param target 目标对象
56
+ * @param sources 源对象
57
+ */
58
+ declare const deepMerge: <T extends Record<string, any>>(target: T, ...sources: Partial<T>[]) => T;
59
+ /**
60
+ * 判断是否是对象
61
+ * @param obj 值
62
+ */
63
+ declare const isObject: (obj: any) => obj is Record<string, any>;
64
+ /**
65
+ * 判断是否是数组
66
+ * @param obj 值
67
+ */
68
+ declare const isArray: (obj: any) => obj is any[];
69
+ /**
70
+ * 判断是否是函数
71
+ * @param obj 值
72
+ */
73
+ declare const isFunction: (obj: any) => obj is (...args: unknown[]) => unknown;
74
+ /**
75
+ * 判断是否是数字
76
+ * @param obj 值
77
+ */
78
+ declare const isNumber: (obj: any) => obj is number;
79
+ /**
80
+ * 判断是否是字符串
81
+ * @param obj 值
82
+ */
83
+ declare const isString: (obj: any) => obj is string;
84
+ /**
85
+ * 判断是否是布尔值
86
+ * @param obj 值
87
+ */
88
+ declare const isBoolean: (obj: any) => obj is boolean;
89
+ /**
90
+ * 判断是否是 null 或 undefined
91
+ * @param obj 值
92
+ */
93
+ declare const isNil: (obj: any) => boolean;
94
+ /**
95
+ * 判断是否是 null
96
+ * @param obj 值
97
+ */
98
+ declare const isNull: (obj: any) => obj is null;
99
+ /**
100
+ * 判断是否是 undefined
101
+ * @param obj 值
102
+ */
103
+ declare const isUndefined: (obj: any) => obj is undefined;
104
+ /**
105
+ * 获取对象的键值对数量
106
+ * @param obj 对象
107
+ */
108
+ declare const size: (obj: Record<string, any>) => number;
109
+ /**
110
+ * 清空对象
111
+ * @param obj 对象
112
+ */
113
+ declare const clear: <T extends Record<string, any>>(obj: T) => T;
114
+ /**
115
+ * 转换为查询字符串
116
+ * @param obj 对象
117
+ */
118
+ declare const toQueryString: (obj: Record<string, any>) => string;
119
+ /**
120
+ * 查询字符串转对象
121
+ * @param queryString 查询字符串
122
+ */
123
+ declare const fromQueryString: (queryString: string) => Record<string, string>;
124
+ /**
125
+ * 对象排序
126
+ * @param obj 对象
127
+ * @param compareFn 比较函数
128
+ */
129
+ declare const sortKeys: <T extends Record<string, any>>(obj: T, compareFn?: (a: string, b: string) => number) => T;
130
+ /**
131
+ * 重命名对象的键
132
+ * @param obj 对象
133
+ * @param renameMap 重命名映射
134
+ */
135
+ declare const renameKeys: <T extends Record<string, any>>(obj: T, renameMap: Record<string, string>) => T;
136
+ /**
137
+ * 过滤对象的键值对
138
+ * @param obj 对象
139
+ * @param predicate 过滤函数
140
+ */
141
+ declare const filter: <T extends Record<string, any>>(obj: T, predicate: (value: any, key: string) => boolean) => Partial<T>;
142
+ /**
143
+ * 映射对象的值
144
+ * @param obj 对象
145
+ * @param mapper 映射函数
146
+ */
147
+ declare const mapValues: <T extends Record<string, any>, R>(obj: T, mapper: (value: any, key: string) => R) => Record<string, R>;
148
+ /**
149
+ * 映射对象的键
150
+ * @param obj 对象
151
+ * @param mapper 映射函数
152
+ */
153
+ declare const mapKeys: <T extends Record<string, any>, R extends string>(obj: T, mapper: (key: string, value: any) => R) => Record<R, any>;
154
+ /**
155
+ * 获取嵌套路径的值
156
+ * @param obj 对象
157
+ * @param path 路径
158
+ * @param defaultValue 默认值
159
+ */
160
+ declare const getDeep: <T>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
161
+ /**
162
+ * 设置嵌套路径的值
163
+ * @param obj 对象
164
+ * @param path 路径
165
+ * @param value 值
166
+ */
167
+ declare const setDeep: (obj: Record<string, any>, path: string, value: any) => void;
168
+ /**
169
+ * 判断对象是否有某个路径
170
+ * @param obj 对象
171
+ * @param path 路径
172
+ */
173
+ declare const hasDeep: (obj: Record<string, any>, path: string) => boolean;
174
+ /**
175
+ * 删除嵌套路径的值
176
+ * @param obj 对象
177
+ * @param path 路径
178
+ */
179
+ declare const deleteDeep: (obj: Record<string, any>, path: string) => boolean;
180
+ /**
181
+ * 转换为 FormData
182
+ * @param obj 对象
183
+ */
184
+ declare const toFormData: (obj: Record<string, any>) => FormData;
185
+ /**
186
+ * 对象差值(返回在 obj 中但不在 base 中的键值对)
187
+ * @param obj 对象
188
+ * @param base 基础对象
189
+ */
190
+ declare const diff: <T extends Record<string, any>>(obj: T, base: T) => Partial<T>;
191
+ /**
192
+ * 深度冻结对象
193
+ * @param obj 对象
194
+ */
195
+ declare const deepFreeze: <T>(obj: T) => T;
196
+ /**
197
+ * 获取对象的第一个值
198
+ * @param obj 对象
199
+ */
200
+ declare const first: <T>(obj: Record<string, T>) => T | undefined;
201
+ /**
202
+ * 获取对象的最后一个值
203
+ * @param obj 对象
204
+ */
205
+ declare const last: <T>(obj: Record<string, T>) => T | undefined;
206
+ /**
207
+ * 按路径分组对象数组
208
+ * @param arr 对象数组
209
+ * @param keyPath 键路径
210
+ */
211
+ declare const groupByPath: <T extends Record<string, any>>(arr: T[], keyPath: string) => Record<string, T[]>;
212
+
213
+ declare const index_clear: typeof clear;
214
+ declare const index_cloneDeep: typeof cloneDeep;
215
+ declare const index_deepFreeze: typeof deepFreeze;
216
+ declare const index_deepMerge: typeof deepMerge;
217
+ declare const index_deleteDeep: typeof deleteDeep;
218
+ declare const index_diff: typeof diff;
219
+ declare const index_entries: typeof entries;
220
+ declare const index_filter: typeof filter;
221
+ declare const index_first: typeof first;
222
+ declare const index_fromPairs: typeof fromPairs;
223
+ declare const index_fromQueryString: typeof fromQueryString;
224
+ declare const index_get: typeof get;
225
+ declare const index_getDeep: typeof getDeep;
226
+ declare const index_groupBy: typeof groupBy;
227
+ declare const index_groupByPath: typeof groupByPath;
228
+ declare const index_has: typeof has;
229
+ declare const index_hasDeep: typeof hasDeep;
230
+ declare const index_invert: typeof invert;
231
+ declare const index_isArray: typeof isArray;
232
+ declare const index_isBoolean: typeof isBoolean;
233
+ declare const index_isEmpty: typeof isEmpty;
234
+ declare const index_isEmptyObject: typeof isEmptyObject;
235
+ declare const index_isEqual: typeof isEqual;
236
+ declare const index_isFunction: typeof isFunction;
237
+ declare const index_isNil: typeof isNil;
238
+ declare const index_isNull: typeof isNull;
239
+ declare const index_isNumber: typeof isNumber;
240
+ declare const index_isObject: typeof isObject;
241
+ declare const index_isString: typeof isString;
242
+ declare const index_isUndefined: typeof isUndefined;
243
+ declare const index_keys: typeof keys;
244
+ declare const index_last: typeof last;
245
+ declare const index_mapKeys: typeof mapKeys;
246
+ declare const index_mapValues: typeof mapValues;
247
+ declare const index_merge: typeof merge;
248
+ declare const index_omit: typeof omit;
249
+ declare const index_pick: typeof pick;
250
+ declare const index_renameKeys: typeof renameKeys;
251
+ declare const index_set: typeof set;
252
+ declare const index_setDeep: typeof setDeep;
253
+ declare const index_size: typeof size;
254
+ declare const index_sortKeys: typeof sortKeys;
255
+ declare const index_toFormData: typeof toFormData;
256
+ declare const index_toQueryString: typeof toQueryString;
257
+ declare const index_values: typeof values;
258
+ declare namespace index {
259
+ export { index_clear as clear, index_cloneDeep as cloneDeep, index_deepFreeze as deepFreeze, index_deepMerge as deepMerge, index_deleteDeep as deleteDeep, index_diff as diff, index_entries as entries, index_filter as filter, index_first as first, index_fromPairs as fromPairs, index_fromQueryString as fromQueryString, index_get as get, index_getDeep as getDeep, index_groupBy as groupBy, index_groupByPath as groupByPath, index_has as has, index_hasDeep as hasDeep, index_invert as invert, index_isArray as isArray, index_isBoolean as isBoolean, index_isEmpty as isEmpty, index_isEmptyObject as isEmptyObject, index_isEqual as isEqual, index_isFunction as isFunction, index_isNil as isNil, index_isNull as isNull, index_isNumber as isNumber, index_isObject as isObject, index_isString as isString, index_isUndefined as isUndefined, index_keys as keys, index_last as last, index_mapKeys as mapKeys, index_mapValues as mapValues, index_merge as merge, index_omit as omit, index_pick as pick, index_renameKeys as renameKeys, index_set as set, index_setDeep as setDeep, index_size as size, index_sortKeys as sortKeys, index_toFormData as toFormData, index_toQueryString as toQueryString, index_values as values };
260
+ }
261
+
262
+ export { keys as A, last as B, mapKeys as C, mapValues as D, renameKeys as E, set as F, setDeep as G, size as H, sortKeys as I, toFormData as J, toQueryString as K, values as L, deepMerge as a, deleteDeep as b, clear as c, deepFreeze as d, diff as e, entries as f, filter as g, first as h, index as i, fromPairs as j, fromQueryString as k, get as l, getDeep as m, groupByPath as n, has as o, hasDeep as p, isArray as q, isBoolean as r, isEmpty as s, isFunction as t, isNil as u, isNull as v, isNumber as w, isObject as x, isString as y, isUndefined as z };
@@ -0,0 +1,262 @@
1
+ import { cloneDeep, groupBy, invert, isEmptyObject, isEqual, merge, omit, pick } from 'es-toolkit';
2
+
3
+ /**
4
+ * 对象工具模块
5
+ * 基于 es-toolkit 封装,提供常用的对象处理功能
6
+ */
7
+
8
+ /**
9
+ * 获取对象的所有键
10
+ * @param obj 对象
11
+ */
12
+ declare const keys: <T extends Record<string, any>>(obj: T) => (keyof T)[];
13
+ /**
14
+ * 获取对象的所有值
15
+ * @param obj 对象
16
+ */
17
+ declare const values: <T extends Record<string, any>>(obj: T) => T[keyof T][];
18
+ /**
19
+ * 获取对象的所有键值对
20
+ * @param obj 对象
21
+ */
22
+ declare const entries: <T extends Record<string, any>>(obj: T) => [keyof T, T[keyof T]][];
23
+ /**
24
+ * 从键值对数组创建对象
25
+ * @param pairs 键值对数组
26
+ */
27
+ declare const fromPairs: <K extends string | number | symbol, V>(pairs: [K, V][]) => Record<K, V>;
28
+ /**
29
+ * 获取对象的嵌套属性值
30
+ * @param obj 对象
31
+ * @param path 路径
32
+ * @param defaultValue 默认值
33
+ */
34
+ declare const get: <T>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
35
+ /**
36
+ * 设置对象的嵌套属性值
37
+ * @param obj 对象
38
+ * @param path 路径
39
+ * @param value 值
40
+ */
41
+ declare const set: (obj: Record<string, any>, path: string, value: any) => void;
42
+ /**
43
+ * 判断对象是否有某个路径
44
+ * @param obj 对象
45
+ * @param path 路径
46
+ */
47
+ declare const has: (obj: Record<string, any>, path: string) => boolean;
48
+ /**
49
+ * 判断对象是否为空
50
+ * @param obj 对象
51
+ */
52
+ declare const isEmpty: (obj: any) => boolean;
53
+ /**
54
+ * 深度合并对象
55
+ * @param target 目标对象
56
+ * @param sources 源对象
57
+ */
58
+ declare const deepMerge: <T extends Record<string, any>>(target: T, ...sources: Partial<T>[]) => T;
59
+ /**
60
+ * 判断是否是对象
61
+ * @param obj 值
62
+ */
63
+ declare const isObject: (obj: any) => obj is Record<string, any>;
64
+ /**
65
+ * 判断是否是数组
66
+ * @param obj 值
67
+ */
68
+ declare const isArray: (obj: any) => obj is any[];
69
+ /**
70
+ * 判断是否是函数
71
+ * @param obj 值
72
+ */
73
+ declare const isFunction: (obj: any) => obj is (...args: unknown[]) => unknown;
74
+ /**
75
+ * 判断是否是数字
76
+ * @param obj 值
77
+ */
78
+ declare const isNumber: (obj: any) => obj is number;
79
+ /**
80
+ * 判断是否是字符串
81
+ * @param obj 值
82
+ */
83
+ declare const isString: (obj: any) => obj is string;
84
+ /**
85
+ * 判断是否是布尔值
86
+ * @param obj 值
87
+ */
88
+ declare const isBoolean: (obj: any) => obj is boolean;
89
+ /**
90
+ * 判断是否是 null 或 undefined
91
+ * @param obj 值
92
+ */
93
+ declare const isNil: (obj: any) => boolean;
94
+ /**
95
+ * 判断是否是 null
96
+ * @param obj 值
97
+ */
98
+ declare const isNull: (obj: any) => obj is null;
99
+ /**
100
+ * 判断是否是 undefined
101
+ * @param obj 值
102
+ */
103
+ declare const isUndefined: (obj: any) => obj is undefined;
104
+ /**
105
+ * 获取对象的键值对数量
106
+ * @param obj 对象
107
+ */
108
+ declare const size: (obj: Record<string, any>) => number;
109
+ /**
110
+ * 清空对象
111
+ * @param obj 对象
112
+ */
113
+ declare const clear: <T extends Record<string, any>>(obj: T) => T;
114
+ /**
115
+ * 转换为查询字符串
116
+ * @param obj 对象
117
+ */
118
+ declare const toQueryString: (obj: Record<string, any>) => string;
119
+ /**
120
+ * 查询字符串转对象
121
+ * @param queryString 查询字符串
122
+ */
123
+ declare const fromQueryString: (queryString: string) => Record<string, string>;
124
+ /**
125
+ * 对象排序
126
+ * @param obj 对象
127
+ * @param compareFn 比较函数
128
+ */
129
+ declare const sortKeys: <T extends Record<string, any>>(obj: T, compareFn?: (a: string, b: string) => number) => T;
130
+ /**
131
+ * 重命名对象的键
132
+ * @param obj 对象
133
+ * @param renameMap 重命名映射
134
+ */
135
+ declare const renameKeys: <T extends Record<string, any>>(obj: T, renameMap: Record<string, string>) => T;
136
+ /**
137
+ * 过滤对象的键值对
138
+ * @param obj 对象
139
+ * @param predicate 过滤函数
140
+ */
141
+ declare const filter: <T extends Record<string, any>>(obj: T, predicate: (value: any, key: string) => boolean) => Partial<T>;
142
+ /**
143
+ * 映射对象的值
144
+ * @param obj 对象
145
+ * @param mapper 映射函数
146
+ */
147
+ declare const mapValues: <T extends Record<string, any>, R>(obj: T, mapper: (value: any, key: string) => R) => Record<string, R>;
148
+ /**
149
+ * 映射对象的键
150
+ * @param obj 对象
151
+ * @param mapper 映射函数
152
+ */
153
+ declare const mapKeys: <T extends Record<string, any>, R extends string>(obj: T, mapper: (key: string, value: any) => R) => Record<R, any>;
154
+ /**
155
+ * 获取嵌套路径的值
156
+ * @param obj 对象
157
+ * @param path 路径
158
+ * @param defaultValue 默认值
159
+ */
160
+ declare const getDeep: <T>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
161
+ /**
162
+ * 设置嵌套路径的值
163
+ * @param obj 对象
164
+ * @param path 路径
165
+ * @param value 值
166
+ */
167
+ declare const setDeep: (obj: Record<string, any>, path: string, value: any) => void;
168
+ /**
169
+ * 判断对象是否有某个路径
170
+ * @param obj 对象
171
+ * @param path 路径
172
+ */
173
+ declare const hasDeep: (obj: Record<string, any>, path: string) => boolean;
174
+ /**
175
+ * 删除嵌套路径的值
176
+ * @param obj 对象
177
+ * @param path 路径
178
+ */
179
+ declare const deleteDeep: (obj: Record<string, any>, path: string) => boolean;
180
+ /**
181
+ * 转换为 FormData
182
+ * @param obj 对象
183
+ */
184
+ declare const toFormData: (obj: Record<string, any>) => FormData;
185
+ /**
186
+ * 对象差值(返回在 obj 中但不在 base 中的键值对)
187
+ * @param obj 对象
188
+ * @param base 基础对象
189
+ */
190
+ declare const diff: <T extends Record<string, any>>(obj: T, base: T) => Partial<T>;
191
+ /**
192
+ * 深度冻结对象
193
+ * @param obj 对象
194
+ */
195
+ declare const deepFreeze: <T>(obj: T) => T;
196
+ /**
197
+ * 获取对象的第一个值
198
+ * @param obj 对象
199
+ */
200
+ declare const first: <T>(obj: Record<string, T>) => T | undefined;
201
+ /**
202
+ * 获取对象的最后一个值
203
+ * @param obj 对象
204
+ */
205
+ declare const last: <T>(obj: Record<string, T>) => T | undefined;
206
+ /**
207
+ * 按路径分组对象数组
208
+ * @param arr 对象数组
209
+ * @param keyPath 键路径
210
+ */
211
+ declare const groupByPath: <T extends Record<string, any>>(arr: T[], keyPath: string) => Record<string, T[]>;
212
+
213
+ declare const index_clear: typeof clear;
214
+ declare const index_cloneDeep: typeof cloneDeep;
215
+ declare const index_deepFreeze: typeof deepFreeze;
216
+ declare const index_deepMerge: typeof deepMerge;
217
+ declare const index_deleteDeep: typeof deleteDeep;
218
+ declare const index_diff: typeof diff;
219
+ declare const index_entries: typeof entries;
220
+ declare const index_filter: typeof filter;
221
+ declare const index_first: typeof first;
222
+ declare const index_fromPairs: typeof fromPairs;
223
+ declare const index_fromQueryString: typeof fromQueryString;
224
+ declare const index_get: typeof get;
225
+ declare const index_getDeep: typeof getDeep;
226
+ declare const index_groupBy: typeof groupBy;
227
+ declare const index_groupByPath: typeof groupByPath;
228
+ declare const index_has: typeof has;
229
+ declare const index_hasDeep: typeof hasDeep;
230
+ declare const index_invert: typeof invert;
231
+ declare const index_isArray: typeof isArray;
232
+ declare const index_isBoolean: typeof isBoolean;
233
+ declare const index_isEmpty: typeof isEmpty;
234
+ declare const index_isEmptyObject: typeof isEmptyObject;
235
+ declare const index_isEqual: typeof isEqual;
236
+ declare const index_isFunction: typeof isFunction;
237
+ declare const index_isNil: typeof isNil;
238
+ declare const index_isNull: typeof isNull;
239
+ declare const index_isNumber: typeof isNumber;
240
+ declare const index_isObject: typeof isObject;
241
+ declare const index_isString: typeof isString;
242
+ declare const index_isUndefined: typeof isUndefined;
243
+ declare const index_keys: typeof keys;
244
+ declare const index_last: typeof last;
245
+ declare const index_mapKeys: typeof mapKeys;
246
+ declare const index_mapValues: typeof mapValues;
247
+ declare const index_merge: typeof merge;
248
+ declare const index_omit: typeof omit;
249
+ declare const index_pick: typeof pick;
250
+ declare const index_renameKeys: typeof renameKeys;
251
+ declare const index_set: typeof set;
252
+ declare const index_setDeep: typeof setDeep;
253
+ declare const index_size: typeof size;
254
+ declare const index_sortKeys: typeof sortKeys;
255
+ declare const index_toFormData: typeof toFormData;
256
+ declare const index_toQueryString: typeof toQueryString;
257
+ declare const index_values: typeof values;
258
+ declare namespace index {
259
+ export { index_clear as clear, index_cloneDeep as cloneDeep, index_deepFreeze as deepFreeze, index_deepMerge as deepMerge, index_deleteDeep as deleteDeep, index_diff as diff, index_entries as entries, index_filter as filter, index_first as first, index_fromPairs as fromPairs, index_fromQueryString as fromQueryString, index_get as get, index_getDeep as getDeep, index_groupBy as groupBy, index_groupByPath as groupByPath, index_has as has, index_hasDeep as hasDeep, index_invert as invert, index_isArray as isArray, index_isBoolean as isBoolean, index_isEmpty as isEmpty, index_isEmptyObject as isEmptyObject, index_isEqual as isEqual, index_isFunction as isFunction, index_isNil as isNil, index_isNull as isNull, index_isNumber as isNumber, index_isObject as isObject, index_isString as isString, index_isUndefined as isUndefined, index_keys as keys, index_last as last, index_mapKeys as mapKeys, index_mapValues as mapValues, index_merge as merge, index_omit as omit, index_pick as pick, index_renameKeys as renameKeys, index_set as set, index_setDeep as setDeep, index_size as size, index_sortKeys as sortKeys, index_toFormData as toFormData, index_toQueryString as toQueryString, index_values as values };
260
+ }
261
+
262
+ export { keys as A, last as B, mapKeys as C, mapValues as D, renameKeys as E, set as F, setDeep as G, size as H, sortKeys as I, toFormData as J, toQueryString as K, values as L, deepMerge as a, deleteDeep as b, clear as c, deepFreeze as d, diff as e, entries as f, filter as g, first as h, index as i, fromPairs as j, fromQueryString as k, get as l, getDeep as m, groupByPath as n, has as o, hasDeep as p, isArray as q, isBoolean as r, isEmpty as s, isFunction as t, isNil as u, isNull as v, isNumber as w, isObject as x, isString as y, isUndefined as z };
@@ -0,0 +1,148 @@
1
+ import html2canvas, { Options } from 'html2canvas';
2
+ import { jsPDF } from 'jspdf';
3
+
4
+ /**
5
+ * PDF 工具模块
6
+ * 基于 html2canvas 和 jspdf 封装,提供常用的 PDF 处理功能
7
+ */
8
+
9
+ interface CaptureToPDFOptions {
10
+ filename?: string;
11
+ scale?: number;
12
+ useCORS?: boolean;
13
+ backgroundColor?: string;
14
+ logging?: boolean;
15
+ pagebreak?: {
16
+ mode?: string;
17
+ before?: string;
18
+ after?: string;
19
+ };
20
+ margin?: number;
21
+ }
22
+ interface PDFOptions {
23
+ orientation?: 'p' | 'portrait' | 'l' | 'landscape';
24
+ unit?: 'pt' | 'mm' | 'cm' | 'in';
25
+ format?: 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'legal' | 'letter' | [number, number];
26
+ }
27
+ /**
28
+ * 将 DOM 元素转换为 PDF
29
+ * @param element DOM 元素
30
+ * @param options 选项
31
+ */
32
+ declare const captureToPDF: (element: HTMLElement, options?: CaptureToPDFOptions) => Promise<void>;
33
+ /**
34
+ * 将 DOM 元素转换为 PDF(分页)
35
+ * @param element DOM 元素
36
+ * @param options 选项
37
+ */
38
+ declare const captureToPDFWithPagination: (element: HTMLElement, options?: CaptureToPDFOptions) => Promise<void>;
39
+ /**
40
+ * 截取 DOM 元素为图片
41
+ * @param element DOM 元素
42
+ * @param options html2canvas 选项
43
+ */
44
+ declare const captureToImage: (element: HTMLElement, options?: Partial<Options>) => Promise<string>;
45
+ /**
46
+ * 截取 DOM 元素并下载为图片
47
+ * @param element DOM 元素
48
+ * @param filename 文件名
49
+ * @param options html2canvas 选项
50
+ */
51
+ declare const captureToImageDownload: (element: HTMLElement, filename?: string, options?: Partial<Options>) => Promise<void>;
52
+ /**
53
+ * 创建空白 PDF
54
+ * @param options PDF 选项
55
+ */
56
+ declare const createPDF: (options?: PDFOptions) => jsPDF;
57
+ /**
58
+ * 添加文本到 PDF
59
+ * @param pdf PDF 实例
60
+ * @param text 文本
61
+ * @param x X 坐标
62
+ * @param y Y 坐标
63
+ * @param options 选项
64
+ */
65
+ declare const addTextToPDF: (pdf: jsPDF, text: string, x: number, y: number, options?: {
66
+ maxWidth?: number;
67
+ align?: "left" | "center" | "right";
68
+ fontSize?: number;
69
+ fontStyle?: "normal" | "bold" | "italic" | "bolditalic";
70
+ }) => void;
71
+ /**
72
+ * 添加图片到 PDF
73
+ * @param pdf PDF 实例
74
+ * @param imageData 图片数据(DataURL 或 URL)
75
+ * @param x X 坐标
76
+ * @param y Y 坐标
77
+ * @param width 宽度
78
+ * @param height 高度
79
+ */
80
+ declare const addImageToPDF: (pdf: jsPDF, imageData: string, x: number, y: number, width: number, height: number) => void;
81
+ /**
82
+ * 添加表格到 PDF
83
+ * @param pdf PDF 实例
84
+ * @param headers 表头
85
+ * @param data 数据
86
+ * @param options 选项
87
+ */
88
+ declare const addTableToPDF: (pdf: jsPDF, headers: string[], data: string[][], options?: {
89
+ x?: number;
90
+ y?: number;
91
+ cellWidth?: number;
92
+ cellHeight?: number;
93
+ headerBackgroundColor?: string;
94
+ headerTextColor?: string;
95
+ textColor?: string;
96
+ fontSize?: number;
97
+ lineWidth?: number;
98
+ lineColor?: number[];
99
+ }) => void;
100
+ /**
101
+ * 添加新页面
102
+ * @param pdf PDF 实例
103
+ */
104
+ declare const addPage: (pdf: jsPDF) => void;
105
+ /**
106
+ * 保存 PDF
107
+ * @param pdf PDF 实例
108
+ * @param filename 文件名
109
+ */
110
+ declare const savePDF: (pdf: jsPDF, filename?: string) => void;
111
+ /**
112
+ * PDF 转 DataURL
113
+ * @param pdf PDF 实例
114
+ */
115
+ declare const pdfToDataURL: (pdf: jsPDF) => string;
116
+ /**
117
+ * PDF 转 Blob
118
+ * @param pdf PDF 实例
119
+ */
120
+ declare const pdfToBlob: (pdf: jsPDF) => Blob;
121
+ /**
122
+ * 合并多个 PDF(需要使用 pdf-lib 库实现)
123
+ * @param _pdfs PDF 实例数组
124
+ */
125
+ declare const mergePDFs: (_pdfs: jsPDF[]) => Promise<jsPDF>;
126
+
127
+ type index_CaptureToPDFOptions = CaptureToPDFOptions;
128
+ type index_PDFOptions = PDFOptions;
129
+ declare const index_addImageToPDF: typeof addImageToPDF;
130
+ declare const index_addPage: typeof addPage;
131
+ declare const index_addTableToPDF: typeof addTableToPDF;
132
+ declare const index_addTextToPDF: typeof addTextToPDF;
133
+ declare const index_captureToImage: typeof captureToImage;
134
+ declare const index_captureToImageDownload: typeof captureToImageDownload;
135
+ declare const index_captureToPDF: typeof captureToPDF;
136
+ declare const index_captureToPDFWithPagination: typeof captureToPDFWithPagination;
137
+ declare const index_createPDF: typeof createPDF;
138
+ declare const index_html2canvas: typeof html2canvas;
139
+ declare const index_jsPDF: typeof jsPDF;
140
+ declare const index_mergePDFs: typeof mergePDFs;
141
+ declare const index_pdfToBlob: typeof pdfToBlob;
142
+ declare const index_pdfToDataURL: typeof pdfToDataURL;
143
+ declare const index_savePDF: typeof savePDF;
144
+ declare namespace index {
145
+ export { type index_CaptureToPDFOptions as CaptureToPDFOptions, type index_PDFOptions as PDFOptions, index_addImageToPDF as addImageToPDF, index_addPage as addPage, index_addTableToPDF as addTableToPDF, index_addTextToPDF as addTextToPDF, index_captureToImage as captureToImage, index_captureToImageDownload as captureToImageDownload, index_captureToPDF as captureToPDF, index_captureToPDFWithPagination as captureToPDFWithPagination, index_createPDF as createPDF, index_html2canvas as html2canvas, index_jsPDF as jsPDF, index_mergePDFs as mergePDFs, index_pdfToBlob as pdfToBlob, index_pdfToDataURL as pdfToDataURL, index_savePDF as savePDF };
146
+ }
147
+
148
+ export { type CaptureToPDFOptions as C, type PDFOptions as P, addImageToPDF as a, addPage as b, addTableToPDF as c, addTextToPDF as d, captureToImage as e, captureToImageDownload as f, captureToPDF as g, captureToPDFWithPagination as h, index as i, createPDF as j, pdfToDataURL as k, mergePDFs as m, pdfToBlob as p, savePDF as s };