@mingto/tools 1.0.675

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 (105) hide show
  1. package/README.md +1615 -0
  2. package/dist/array/chunk-array.d.ts +11 -0
  3. package/dist/array/index.d.ts +2 -0
  4. package/dist/browser/copy-text.d.ts +8 -0
  5. package/dist/browser/create-audio-permission.d.ts +186 -0
  6. package/dist/browser/get-absolute-url.d.ts +7 -0
  7. package/dist/browser/get-browser-fingerprint.d.ts +10 -0
  8. package/dist/browser/index.d.ts +9 -0
  9. package/dist/browser/is-android.d.ts +8 -0
  10. package/dist/browser/is-ios.d.ts +8 -0
  11. package/dist/browser/is-mobile.d.ts +8 -0
  12. package/dist/browser/is-pc.d.ts +8 -0
  13. package/dist/constant/image.d.ts +2 -0
  14. package/dist/constant/index.d.ts +1 -0
  15. package/dist/core/__test__/can-be-parsed-as-number.test.d.ts +1 -0
  16. package/dist/core/be-parsed-as-number.d.ts +8 -0
  17. package/dist/core/can-be-parsed-as-number.d.ts +8 -0
  18. package/dist/core/check-array-empty.d.ts +8 -0
  19. package/dist/core/check-empty-not-zero.d.ts +8 -0
  20. package/dist/core/check-empty.d.ts +8 -0
  21. package/dist/core/check-object-empty.d.ts +8 -0
  22. package/dist/core/index.d.ts +15 -0
  23. package/dist/core/is-array.d.ts +8 -0
  24. package/dist/core/is-boolean.d.ts +8 -0
  25. package/dist/core/is-function.d.ts +8 -0
  26. package/dist/core/is-null-or-undefined.d.ts +7 -0
  27. package/dist/core/is-number.d.ts +8 -0
  28. package/dist/core/is-object.d.ts +9 -0
  29. package/dist/core/is-string.d.ts +8 -0
  30. package/dist/core/is-undefined.d.ts +8 -0
  31. package/dist/file/__test__/get-file-suffix.test.d.ts +1 -0
  32. package/dist/file/__test__/is-file-path.test.d.ts +1 -0
  33. package/dist/file/batch-download-file.d.ts +12 -0
  34. package/dist/file/extends/enum.d.ts +81 -0
  35. package/dist/file/extends/regex.d.ts +2 -0
  36. package/dist/file/get-file-icon.d.ts +8 -0
  37. package/dist/file/get-file-name.d.ts +8 -0
  38. package/dist/file/get-file-path-not-query.d.ts +8 -0
  39. package/dist/file/get-file-query.d.ts +8 -0
  40. package/dist/file/get-file-suffix-icon.d.ts +9 -0
  41. package/dist/file/get-file-suffix.d.ts +9 -0
  42. package/dist/file/get-file-title.d.ts +8 -0
  43. package/dist/file/index.d.ts +22 -0
  44. package/dist/file/is-compress-file-path.d.ts +8 -0
  45. package/dist/file/is-document-file-path.d.ts +8 -0
  46. package/dist/file/is-file-path.d.ts +8 -0
  47. package/dist/file/is-image-file-path.d.ts +8 -0
  48. package/dist/file/is-music-file-path.d.ts +8 -0
  49. package/dist/file/is-ppt-file-path.d.ts +8 -0
  50. package/dist/file/is-video-file-path.d.ts +8 -0
  51. package/dist/file/single-download-file-base64.d.ts +8 -0
  52. package/dist/file/single-download-file.d.ts +12 -0
  53. package/dist/file/types/index.d.ts +9 -0
  54. package/dist/file/update-file-path-query.d.ts +8 -0
  55. package/dist/function/debounce.d.ts +23 -0
  56. package/dist/function/index.d.ts +3 -0
  57. package/dist/function/throttle.d.ts +23 -0
  58. package/dist/i18n/index.d.ts +32 -0
  59. package/dist/i18n/locales/ar.d.ts +18 -0
  60. package/dist/i18n/locales/en.d.ts +18 -0
  61. package/dist/i18n/locales/ms.d.ts +18 -0
  62. package/dist/i18n/locales/th.d.ts +18 -0
  63. package/dist/i18n/locales/vi.d.ts +13 -0
  64. package/dist/i18n/locales/zh-cn.d.ts +18 -0
  65. package/dist/i18n/locales/zh-tw.d.ts +18 -0
  66. package/dist/i18n/setup.d.ts +4 -0
  67. package/dist/index.d.ts +28 -0
  68. package/dist/index.js +16971 -0
  69. package/dist/math/__test__/add.test.d.ts +1 -0
  70. package/dist/math/__test__/divide.test.d.ts +1 -0
  71. package/dist/math/__test__/get-decimal-places.test.d.ts +1 -0
  72. package/dist/math/__test__/multiply.test.d.ts +1 -0
  73. package/dist/math/__test__/subtract.test.d.ts +1 -0
  74. package/dist/math/add.d.ts +9 -0
  75. package/dist/math/calc-aspect-ratio.d.ts +9 -0
  76. package/dist/math/divide.d.ts +9 -0
  77. package/dist/math/get-decimal-places.d.ts +8 -0
  78. package/dist/math/index.d.ts +7 -0
  79. package/dist/math/multiply.d.ts +9 -0
  80. package/dist/math/subtract.d.ts +9 -0
  81. package/dist/object/deep-freeze.d.ts +9 -0
  82. package/dist/object/index.d.ts +3 -0
  83. package/dist/object/pick-object.d.ts +9 -0
  84. package/dist/string/__test__/chunk-string.test.d.ts +1 -0
  85. package/dist/string/chunk-string.d.ts +10 -0
  86. package/dist/string/index.d.ts +4 -0
  87. package/dist/string/object-to-query-string.d.ts +10 -0
  88. package/dist/string/query-string-to-object.d.ts +8 -0
  89. package/dist/supply/get-uuid.d.ts +7 -0
  90. package/dist/supply/index.d.ts +3 -0
  91. package/dist/supply/time-delay.d.ts +7 -0
  92. package/dist/supply/type-writer.d.ts +18 -0
  93. package/dist/theme/index.d.ts +1 -0
  94. package/dist/theme/use-theme.d.ts +23 -0
  95. package/dist/validator/index.d.ts +3 -0
  96. package/dist/validator/is-valid-base64.d.ts +6 -0
  97. package/dist/validator/is-valid-url.d.ts +7 -0
  98. package/dist/validator/test/is-valid-url.test.d.ts +1 -0
  99. package/dist/web-socket/create-web-socket.d.ts +9 -0
  100. package/dist/web-socket/index.d.ts +3 -0
  101. package/dist/web-socket/is-web-socket-supported.d.ts +9 -0
  102. package/dist/wrker/close-worker.d.ts +9 -0
  103. package/dist/wrker/create-worker.d.ts +11 -0
  104. package/dist/wrker/index.d.ts +3 -0
  105. package/package.json +31 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 将一个数组分割成多个指定大小的块。这个函数接受一个数组和一个指定的块大小,然后返回一个二维数组。
3
+ * 每个子数组包含原数组中的一部分元素,大小由 `chunkSize` 参数决定。
4
+ * 如果数组的长度不是 `chunkSize` 的整数倍,最后一个块可能包含的元素少于 `chunkSize`。
5
+ *
6
+ * @param array 要分割的源数组。
7
+ * @param chunkSize 每个块的大小。必须为正整数。默认值为 1。
8
+ * @returns 返回一个二维数组,每个子数组是原数组的一部分元素。
9
+ */
10
+ declare function chunkArray<T>(array: T[], chunkSize?: number): T[][];
11
+ export default chunkArray;
@@ -0,0 +1,2 @@
1
+ import { default as chunkArray } from './chunk-array';
2
+ export { chunkArray };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 复制文本到剪贴板。
3
+ *
4
+ * @param text 需要复制到剪贴板的文本。
5
+ * @returns 返回一个 Promise 对象。成功时返回被复制的文本,失败时返回错误信息。
6
+ */
7
+ declare function copyText(text: string): Promise<string>;
8
+ export default copyText;
@@ -0,0 +1,186 @@
1
+ declare enum AudioPermissionErrorType {
2
+ NO_USER_INTERACTION_ERROR = "NoUserInteractionError",
3
+ AUTOPLAY_BLOCKED = "AutoplayBlocked",
4
+ AUTOPLAY_UNKNOWN_ERROR = "AutoplayUnknownError",
5
+ SECURE_CONTEXT_ERROR = "SecureContextError",
6
+ PERMISSION_DENIED_PERMANENTLY = "PermissionDeniedPermanently",
7
+ NOT_ALLOWED_ERROR = "NotAllowedError",
8
+ MEDIA_DEVICES_API_UNAVAILABLE = "MediaDevicesApiUnavailable",
9
+ NOT_FOUND_ERROR = "NotFoundError",
10
+ NOT_READABLE_ERROR = "NotReadableError",
11
+ OVERCONSTRAINED_ERROR = "OverconstrainedError",
12
+ SECURITY_ERROR = "SecurityError",
13
+ MICROPHONE_UNKNOWN_ERROR = "MicrophoneUnknownError",
14
+ MICROPHONE_TIMEOUT_ERROR = "MicrophoneTimeoutError"
15
+ }
16
+ declare class AudioPermissionError extends Error {
17
+ name: AudioPermissionErrorType;
18
+ private constructor();
19
+ static create(name: AudioPermissionErrorType, message?: string): AudioPermissionError;
20
+ }
21
+ /**
22
+ * 音频播放权限管理类
23
+ *
24
+ * 根据MDN文档,音频播放权限需要满足以下条件之一:
25
+ * 1. 音频被静音或音量为0
26
+ * 2. 用户已与网站产生交互(点击、触摸、按键等)
27
+ * 3. 网站已被加入自动播放白名单
28
+ * 4. 通过Permissions Policy授权
29
+ *
30
+ * 跨平台实现策略:
31
+ * - PC端:预检测AudioContext状态,如果suspended则监听用户交互
32
+ * - iOS Safari:必须在用户交互事件的调用栈中调用resume(),需要50ms延迟确保状态变更
33
+ * - Android:直接在用户交互后检测AudioContext状态
34
+ *
35
+ * 自动播放策略限制:
36
+ * - Chrome 66+:需要用户交互或MEI(Media Engagement Index)足够高
37
+ * - Safari:严格要求用户交互,AudioContext创建时默认为suspended状态
38
+ * - Firefox:相对宽松,但仍会阻止明显的自动播放行为
39
+ *
40
+ *
41
+ *
42
+ * 实现原理:
43
+ * PC:
44
+ * 1.在PC端首先预检测AudioContext状态:
45
+ * 如果状态是 “running” 状态则可以播放音频,
46
+ * 如果状态不是 “running” 状态则需要监听用户交互事件,
47
+ * 2.用户交互事件触发后,再检测AudioContext状态:
48
+ * 如果状态是 “running” 状态则可以播放音频,
49
+ * 如果状态不是 “running” 状态则抛出异常。
50
+ *
51
+ * IOS:
52
+ * 1.用户交互事件触发后,再检测AudioContext状态:
53
+ * 如果状态是 “suspended” 则需要调用 resume 方法,并且需要延迟 50ms,
54
+ * 如果状态不是 “suspended” 状态进行下一步判断,
55
+ * 2.获取AudioContext状态:
56
+ * 如果状态是 “running” 状态则可以播放音频,
57
+ * 如果状态不是 “running” 状态则抛出异常。
58
+ *
59
+ * Android:
60
+ * 1.用户交互事件触发后,再检测AudioContext状态:
61
+ * 如果状态是 “running” 状态则可以播放音频,
62
+ * 如果状态不是 “running” 状态则抛出异常。
63
+ */
64
+ declare class AudioPlaybackPermission {
65
+ private userInteracted;
66
+ private executeContext;
67
+ constructor();
68
+ /**
69
+ * 初始化播放权限检测
70
+ */
71
+ private initPlaybackPermission;
72
+ /**
73
+ * 检测初始AudioContext状态(仅PC平台)
74
+ */
75
+ private checkInitialAudioContextState;
76
+ /**
77
+ * 设置用户交互监听器
78
+ */
79
+ private setupUserInteractionListeners;
80
+ /**
81
+ * 请求播放权限
82
+ * 根据Web Audio API最佳实践实现
83
+ */
84
+ requestPlaybackPermission(): Promise<void>;
85
+ /**
86
+ * 执行上下文设置
87
+ * @param context 执行上下文
88
+ */
89
+ setExecuteContext(context: AudioPermission): void;
90
+ }
91
+ /**
92
+ * 麦克风权限管理类
93
+ *
94
+ * 根据MDN文档,getUserMedia需要满足:
95
+ * 1. 安全上下文(HTTPS)
96
+ * 2. 用户明确授权
97
+ * 3. 顶级文档上下文或通过Permissions Policy授权的iframe
98
+ *
99
+ *
100
+ * 权限状态说明:
101
+ * - granted: 用户已授权,可直接访问麦克风
102
+ * - denied: 用户已拒绝,需要用户手动在浏览器设置中重新开启
103
+ * - prompt: 首次访问,会弹出授权对话框
104
+ *
105
+ *
106
+ * 平台差异:
107
+ * - 桌面端:通过浏览器原生授权对话框处理
108
+ * - iOS Safari:权限被拒绝后,需要用户在系统设置中重新开启
109
+ * - Android Chrome:权限处理与桌面端类似,但某些版本可能有缓存问题
110
+ *
111
+ *
112
+ * 注意事项:
113
+ * 1. 浏览器会永久缓存用户的权限决定
114
+ * 2. 在非HTTPS环境下(除localhost外)会直接失败
115
+ * 3. 某些浏览器在隐私模式下可能有不同行为
116
+ * 4. iframe中使用需要正确配置Permissions Policy
117
+ *
118
+ *
119
+ * 实现原理:
120
+ * - PC平台:
121
+ * 1. 通过授权弹框申请权限:
122
+ * 如果用户拒绝了权限,会抛出异常
123
+ * 如果用户点击了允许,会返回成功
124
+ * 2.第二次申请权限,会根据用户第一次申请权限的结果:
125
+ * 如果用户第一次申请权限失败,会抛出异常
126
+ * 如果用户第一次申请权限成功,会返回成功
127
+ * - 移动端:
128
+ * 1. 通过授权弹框申请权限:
129
+ * 如果用户拒绝了权限,会抛出异常
130
+ * 如果用户点击了允许,会返回成功
131
+ * 2.第二次申请权限,会根据用户第一次申请权限的结果:
132
+ * 如果用户第一次申请权限失败,会抛出异常
133
+ * 如果用户第一次申请权限成功,会返回成功
134
+ *
135
+ * iOS平台:
136
+ * 1. 通过授权弹框申请权限:
137
+ * 如果用户拒绝了权限,会抛出异常
138
+ * 如果用户点击了允许,会返回成功
139
+ * 2.第二次申请权限,会根据用户第一次申请权限的结果:
140
+ * 如果用户第一次申请权限失败,会抛出异常
141
+ * 如果用户第一次申请权限成功,会返回成功
142
+ *
143
+ *
144
+ */
145
+ declare class MicrophonePermission {
146
+ private microphonePermissionGranted;
147
+ private permissionDeniedPermanently;
148
+ /**
149
+ * 检查是否在安全上下文中
150
+ */
151
+ private isSecureContext;
152
+ /**
153
+ * 带超时的getUserMedia调用
154
+ * @param constraints - 媒体约束
155
+ * @param timeoutMs - 超时时间(毫秒)
156
+ * @returns Promise<MediaStream>
157
+ */
158
+ private getUserMediaWithTimeout;
159
+ /**
160
+ * 请求麦克风权限
161
+ * 根据MediaDevices.getUserMedia规范实现
162
+ */
163
+ requestMicrophonePermission(): Promise<void>;
164
+ }
165
+ /**
166
+ * 统一的音频权限管理类
167
+ */
168
+ declare class AudioPermission {
169
+ playbackPermission: AudioPlaybackPermission;
170
+ microphonePermission: MicrophonePermission;
171
+ constructor();
172
+ /**
173
+ * 请求音频播放权限
174
+ */
175
+ requestPlaybackPermission(): Promise<void>;
176
+ /**
177
+ * 请求麦克风权限
178
+ */
179
+ requestMicrophonePermission(): Promise<void>;
180
+ }
181
+ /**
182
+ * 创建或获取音频权限管理实例
183
+ */
184
+ declare function createAudioPermission(): AudioPermission;
185
+ export default createAudioPermission;
186
+ export { AudioPermission, AudioPermissionError, AudioPermissionErrorType, AudioPlaybackPermission, MicrophonePermission };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 规范化 URL 路径为绝对路径
3
+ * @param rawUrl - 待规范化的原始 URL 路径,支持空值、相对路径、绝对路径等格式
4
+ * @returns 规范化后的绝对 URL 字符串,空输入返回空字符串
5
+ */
6
+ declare function getAbsoluteUrl(rawUrl: string): string;
7
+ export default getAbsoluteUrl;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 获取浏览器唯一指纹 ID
3
+ * 通过收集浏览器特征(UserAgent, Screen, Language, Timezone, Canvas 等)生成哈希值
4
+ * 注意:此方法生成的 ID 在浏览器环境变化(如升级、窗口大小改变如果包含了窗口大小)时可能会变化,
5
+ * 但作为匿名用户的临时唯一标识通常足够。
6
+ *
7
+ * @returns 浏览器指纹 ID 字符串
8
+ */
9
+ export declare function getBrowserFingerprint(): string;
10
+ export default getBrowserFingerprint;
@@ -0,0 +1,9 @@
1
+ import { default as copyText } from './copy-text';
2
+ import { default as createAudioPermission } from './create-audio-permission';
3
+ import { default as getAbsoluteUrl } from './get-absolute-url';
4
+ import { default as getBrowserFingerprint } from './get-browser-fingerprint';
5
+ import { default as isAndroid } from './is-android';
6
+ import { default as isIos } from './is-ios';
7
+ import { default as isMobile } from './is-mobile';
8
+ import { default as isPc } from './is-pc';
9
+ export { copyText, createAudioPermission, getAbsoluteUrl, getBrowserFingerprint, isAndroid, isIos, isMobile, isPc, };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断当前环境是否为 Android 设备。
3
+ * 主要检测设备类型为 Android。
4
+ *
5
+ * @returns 如果是Android设备,返回true;否则返回false。
6
+ */
7
+ declare function isAndroid(): boolean;
8
+ export default isAndroid;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断当前环境是否为 iOS 设备。
3
+ * 主要检测的设备类型包括 iPhone、iPad 和 iPod。
4
+ *
5
+ * @returns 如果是iOS设备,返回true;否则返回false。
6
+ */
7
+ declare function isIos(): boolean;
8
+ export default isIos;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断当前环境是否为移动设备。
3
+ * 主要检测设备类型为移动设备。
4
+ *
5
+ * @returns 如果是移动设备,返回true;否则返回false。
6
+ */
7
+ declare function isMobile(): boolean;
8
+ export default isMobile;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断当前环境是否为PC设备。
3
+ * 主要检测设备类型为PC设备。
4
+ *
5
+ * @returns 如果是PC设备,返回true;否则返回false。
6
+ */
7
+ declare function isPc(): boolean;
8
+ export default isPc;
@@ -0,0 +1,2 @@
1
+ declare const DEFAULT_USER_AVATAR = "https://1-future-tuzai.obs.cn-southwest-2.myhuaweicloud.com/web_image/default.png";
2
+ export { DEFAULT_USER_AVATAR };
@@ -0,0 +1 @@
1
+ export { DEFAULT_USER_AVATAR } from './image';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 将输入值转换为数字类型。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 输入值转换后的数字值,如果无法解析则返回 `NaN`。
6
+ */
7
+ declare function beParsedAsNumber(value: number | string): number;
8
+ export default beParsedAsNumber;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查输入值是否可以被解析为有效的数字。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值可以被解析为一个有效的数字,则返回 `true`,否则返回 `false`。
6
+ */
7
+ declare function canBeParsedAsNumber(value: unknown): boolean;
8
+ export default canBeParsedAsNumber;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查输入值是否是空数组。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是一个空数组,则返回 `true`;否则返回 `false`。
6
+ */
7
+ declare function checkArrayEmpty(value: unknown): value is Array<unknown>;
8
+ export default checkArrayEmpty;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查输入值是否为空(''、null、undefined、[]、{}),但是不能为0。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是空(''、null、undefined、[]、{}),但不包括0,则返回 `true`;否则返回 `false`。
6
+ */
7
+ declare function checkEmptyNotZero(value: unknown): value is null | undefined | '' | [] | Record<string, never>;
8
+ export default checkEmptyNotZero;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查输入值是否为空(''、0、null、undefined、[]、{})。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是空的,则返回 true,否则返回 false。
6
+ */
7
+ declare function checkEmpty(value: unknown): value is null | undefined | '' | [] | Record<string, never> | 0;
8
+ export default checkEmpty;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查输入值是否是空对象
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果值是一个空对象,则返回 true,否则返回 false。
6
+ */
7
+ declare function checkObjectEmpty(value: unknown): value is Record<string, never>;
8
+ export default checkObjectEmpty;
@@ -0,0 +1,15 @@
1
+ import { default as beParsedAsNumber } from './be-parsed-as-number';
2
+ import { default as canBeParsedAsNumber } from './can-be-parsed-as-number';
3
+ import { default as checkArrayEmpty } from './check-array-empty';
4
+ import { default as checkEmpty } from './check-empty';
5
+ import { default as checkEmptyNotZero } from './check-empty-not-zero';
6
+ import { default as checkObjectEmpty } from './check-object-empty';
7
+ import { default as isArray } from './is-array';
8
+ import { default as isBoolean } from './is-boolean';
9
+ import { default as isFunction } from './is-function';
10
+ import { default as isNullOrUndefined } from './is-null-or-undefined';
11
+ import { default as isNumber } from './is-number';
12
+ import { default as isObject } from './is-object';
13
+ import { default as isString } from './is-string';
14
+ import { default as isUndefined } from './is-undefined';
15
+ export { beParsedAsNumber, canBeParsedAsNumber, checkArrayEmpty, checkEmpty, checkEmptyNotZero, checkObjectEmpty, isArray, isBoolean, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断输入值是否是一个数组。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是一个数组,则返回 true,否则返回 false。
6
+ */
7
+ declare function isArray(value: unknown): value is Array<unknown>;
8
+ export default isArray;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断输入值是否是一个布尔值。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是一个布尔值,则返回 true,否则返回 false。
6
+ */
7
+ declare function isBoolean(value: unknown): value is boolean;
8
+ export default isBoolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断输入值是否是一个函数。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是一个函数,则返回 true,否则返回 false。
6
+ */
7
+ declare function isFunction<T extends (...args: any[]) => any>(value: unknown): value is T;
8
+ export default isFunction;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 检查输入值是否为 null 或 undefined。
3
+ * @param value 输入值。
4
+ * @returns 如果输入值为 null 或 undefined,则返回 true;否则返回 false。
5
+ */
6
+ declare function isNullOrUndefined(value: unknown): value is null | undefined;
7
+ export default isNullOrUndefined;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断输入值是否是一个数字。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是一个数字,则返回 true,否则返回 false。
6
+ */
7
+ declare function isNumber(value: unknown): value is number;
8
+ export default isNumber;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 判断输入值是否是一个对象。
3
+ * 注意:此函数不将 null 视为对象,因此如果输入值是 null,将返回 false。
4
+ *
5
+ * @param value 输入值。
6
+ * @returns 如果输入值是一个普通对象并且不等于 null ,则返回 true;否则返回 false。
7
+ */
8
+ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>;
9
+ export default isObject;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断输入值是否是一个字符串。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值是一个字符串,则返回 true,否则返回 false。
6
+ */
7
+ declare function isString(value: unknown): value is string;
8
+ export default isString;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 检查输入值是否为 undefined。
3
+ *
4
+ * @param value 输入值。
5
+ * @returns 如果输入值为 undefined,则返回 true;否则返回 false。
6
+ */
7
+ declare function isUndefined(value: unknown): value is undefined;
8
+ export default isUndefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 批量下载文件并打包为 ZIP。该函数接受一个文件列表,每个文件包含文件路径和可选的文件名,最终将所有文件打包为一个 ZIP 文件并触发下载。
3
+ *
4
+ * @param fileList 文件列表,每个文件包含文件路径和可选的文件名。如果未提供文件名,将自动从文件路径中提取。
5
+ * @param zipName 打包后的 ZIP 文件名。如果文件名不以 `.zip` 结尾,将自动添加 `.zip` 后缀。
6
+ * @returns 返回一个 Promise,在文件打包和下载完成后。
7
+ */
8
+ declare function batchDownloadFile(fileList: Array<{
9
+ filePath: string;
10
+ fileName?: string;
11
+ }>, zipName: string): Promise<void>;
12
+ export default batchDownloadFile;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 文件后缀类型枚举
3
+ */
4
+ declare const FileSuffixEnum: {
5
+ readonly DOCX: "docx";
6
+ readonly DOC: "doc";
7
+ readonly PDF: "pdf";
8
+ readonly PPTX: "pptx";
9
+ readonly PPT: "ppt";
10
+ readonly XLSX: "xlsx";
11
+ readonly XLS: "xls";
12
+ readonly JPG: "jpg";
13
+ readonly PNG: "png";
14
+ readonly JPEG: "jpeg";
15
+ readonly WEBP: "webp";
16
+ readonly GIF: "gif";
17
+ readonly MP4: "mp4";
18
+ readonly AVI: "avi";
19
+ readonly FLV: "flv";
20
+ readonly MKV: "mkv";
21
+ readonly MP3: "mp3";
22
+ readonly WAV: "wav";
23
+ readonly TXT: "txt";
24
+ readonly JSON: "json";
25
+ readonly ZIP: "zip";
26
+ readonly RAR: "rar";
27
+ readonly HTML: "html";
28
+ };
29
+ /**
30
+ * 图片后缀类型枚举
31
+ */
32
+ declare const ImageFileSuffixEnum: {
33
+ readonly JPG: "jpg";
34
+ readonly PNG: "png";
35
+ readonly GIF: "gif";
36
+ readonly JPEG: "jpeg";
37
+ readonly WEBP: "webp";
38
+ };
39
+ /**
40
+ * 视频文件后缀类型枚举
41
+ */
42
+ declare const VideoFileSuffixEnum: {
43
+ readonly MP4: "mp4";
44
+ readonly AVI: "avi";
45
+ readonly FLV: "flv";
46
+ readonly MKV: "mkv";
47
+ };
48
+ /**
49
+ * PPT文件后缀类型枚举
50
+ */
51
+ declare const PptFileSuffixEnum: {
52
+ readonly PPT: "ppt";
53
+ readonly PPTX: "pptx";
54
+ };
55
+ /**
56
+ * 文档文件后缀类型枚举
57
+ */
58
+ declare const DocumentFileSuffixEnum: {
59
+ readonly DOC: "doc";
60
+ readonly DOCX: "docx";
61
+ readonly PDF: "pdf";
62
+ readonly TXT: "txt";
63
+ readonly XLS: "xls";
64
+ readonly XLSX: "xlsx";
65
+ readonly JSON: "json";
66
+ };
67
+ /**
68
+ * 音乐文件后缀类型枚举
69
+ */
70
+ declare const MusicFileSuffixEnum: {
71
+ readonly MP3: "mp3";
72
+ readonly WAV: "wav";
73
+ };
74
+ /**
75
+ * 压缩文件后缀类型枚举
76
+ */
77
+ declare const CompressFileSuffixEnum: {
78
+ readonly ZIP: "zip";
79
+ readonly RAR: "rar";
80
+ };
81
+ export { CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, ImageFileSuffixEnum, MusicFileSuffixEnum, PptFileSuffixEnum, VideoFileSuffixEnum, };
@@ -0,0 +1,2 @@
1
+ declare const filePathRegex: RegExp;
2
+ export { filePathRegex };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 根据文件后缀获取对应的图标。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 对应文件类型的图标。
6
+ */
7
+ declare function getFileIcon(filePath: string): string;
8
+ export default getFileIcon;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 从文件路径中提取完整的文件名(包含后缀)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 文件名(包含后缀)。
6
+ */
7
+ declare function getFileName(filePath: string): string;
8
+ export default getFileName;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 获取文件路径(不包含查询参数)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 不包含查询参数的文件路径。
6
+ */
7
+ declare function getFilePathNotQuery(filePath: string): string;
8
+ export default getFilePathNotQuery;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 获取 URL 中的查询参数。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 查询参数对象。
6
+ */
7
+ declare function getFileQuery(filePath: string): Record<string, any>;
8
+ export default getFileQuery;
@@ -0,0 +1,9 @@
1
+ import { FileSuffix } from './types';
2
+ /**
3
+ * 根据文件后缀获取对应的图标。
4
+ *
5
+ * @param fileSuffix 文件后缀。
6
+ * @returns 对应的图标路径,若未匹配则返回默认图标。
7
+ */
8
+ declare function getFileSuffixIcon(fileSuffix: FileSuffix): string;
9
+ export default getFileSuffixIcon;
@@ -0,0 +1,9 @@
1
+ import { FileSuffix } from './types';
2
+ /**
3
+ * 从文件路径中提取文件后缀。
4
+ *
5
+ * @param filePath 文件路径。
6
+ * @returns 文件后缀,以小写形式返回。如果文件没有后缀或路径无效,返回空字符串。
7
+ */
8
+ declare function getFileSuffix(filePath: string): FileSuffix;
9
+ export default getFileSuffix;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 从文件路径中提取文件名(不包含后缀)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 文件名(不包含后缀)。
6
+ */
7
+ declare function getFileTitle(filePath: string): string;
8
+ export default getFileTitle;
@@ -0,0 +1,22 @@
1
+ import { CompressFileSuffix, DocumentFileSuffix, FileSuffix, ImageFileSuffix, MusicFileSuffix, PptFileSuffix, VideoFileSuffix } from './types';
2
+ import { default as batchDownloadFile } from './batch-download-file';
3
+ import { CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, ImageFileSuffixEnum, MusicFileSuffixEnum, PptFileSuffixEnum, VideoFileSuffixEnum } from './extends/enum';
4
+ import { default as getFileIcon } from './get-file-icon';
5
+ import { default as getFileName } from './get-file-name';
6
+ import { default as getFilePathNotQuery } from './get-file-path-not-query';
7
+ import { default as getFileQuery } from './get-file-query';
8
+ import { default as getFileSuffix } from './get-file-suffix';
9
+ import { default as getFileSuffixIcon } from './get-file-suffix-icon';
10
+ import { default as getFileTitle } from './get-file-title';
11
+ import { default as isCompressFilePath } from './is-compress-file-path';
12
+ import { default as isDocumentFilePath } from './is-document-file-path';
13
+ import { default as isFilePath } from './is-file-path';
14
+ import { default as isImageFilePath } from './is-image-file-path';
15
+ import { default as isMusicFilePath } from './is-music-file-path';
16
+ import { default as isPptFilePath } from './is-ppt-file-path';
17
+ import { default as isVideoFilePath } from './is-video-file-path';
18
+ import { default as singleDownloadFile } from './single-download-file';
19
+ import { default as singleDownloadFileBase64 } from './single-download-file-base64';
20
+ import { default as updateFilePathQuery } from './update-file-path-query';
21
+ export type { CompressFileSuffix, DocumentFileSuffix, FileSuffix, ImageFileSuffix, MusicFileSuffix, PptFileSuffix, VideoFileSuffix, };
22
+ export { batchDownloadFile, CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, getFileIcon, getFileName, getFilePathNotQuery, getFileQuery, getFileSuffix, getFileSuffixIcon, getFileTitle, ImageFileSuffixEnum, isCompressFilePath, isDocumentFilePath, isFilePath, isImageFilePath, isMusicFilePath, isPptFilePath, isVideoFilePath, MusicFileSuffixEnum, PptFileSuffixEnum, singleDownloadFile, singleDownloadFileBase64, updateFilePathQuery, VideoFileSuffixEnum, };