@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,8 @@
1
+ /**
2
+ * 判断是否是有效的压缩文件路径(包含 rar、zip )。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 是否是有效的压缩文件路径。
6
+ */
7
+ declare function isCompressFilePath(filePath: string): boolean;
8
+ export default isCompressFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的文档文件路径(包含doc、docx、pdf、txt、xls、xlsx、json)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 是否是有效的文档文件路径。
6
+ */
7
+ declare function isDocumentFilePath(filePath: string): boolean;
8
+ export default isDocumentFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的文件路径(包含doc、docx、pdf、ppt、pptx、xls、xlsx、jpg、jpeg、png、webp、gif、mp4、avi、flv、mkv、mp3、mav、txt、html)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 是否是有效的文件路径(空后缀文件不属于有效文件路径)。
6
+ */
7
+ declare function isFilePath(filePath: string): boolean;
8
+ export default isFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的图片文件路径(包含jpg、jpeg、png、webp、gif)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 是否是有效的图片文件路径。
6
+ */
7
+ declare function isImageFilePath(filePath: string): boolean;
8
+ export default isImageFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的音乐文件路径(包含mp3)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 是否是有效的音乐文件路径。
6
+ */
7
+ declare function isMusicFilePath(filePath: string): boolean;
8
+ export default isMusicFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的ppt文件路径(包含ppt、pptx)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 是否是有效的ppt文件路径。
6
+ */
7
+ declare function isPptFilePath(filePath: string): boolean;
8
+ export default isPptFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否是有效的视频文件路径(包含mp4、avi、flv、mkv)。
3
+ *
4
+ * @param filePath 文件路径。
5
+ * @returns 是否是有效的视频文件路径。
6
+ */
7
+ declare function isVideoFilePath(filePath: string): boolean;
8
+ export default isVideoFilePath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 下载 base64 图片或文件
3
+ * @param base64Data - base64 data URL (如: data:image/png;base64,...)
4
+ * @param fileName - 保存的文件名和扩展名
5
+ * @returns Promise<void>
6
+ */
7
+ declare function downloadBase64File(base64Data: string, fileName: string): Promise<void>;
8
+ export default downloadBase64File;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 单文件下载
3
+ * @param source 下载源,支持 Base64 字符串或 URL
4
+ * @param fileName 下载文件名
5
+ * - 当 source 为 Base64 字符串时,必须提供文件名
6
+ * - 当 source 为 URL 且为文件路径时,若未提供文件名,则默认使用 URL 路径中的文件名
7
+ * - 当 source 为 URL 且不为文件路径时,传入的文件名参数无效,将使用服务器响应头中的文件名
8
+ *
9
+ * @returns Promise<void> 下载完成后解析的 Promise
10
+ */
11
+ declare function singleDownloadFile(source: string, fileName?: string, pathQuery?: Record<string, string>): Promise<void>;
12
+ export default singleDownloadFile;
@@ -0,0 +1,9 @@
1
+ import { CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, ImageFileSuffixEnum, MusicFileSuffixEnum, PptFileSuffixEnum, VideoFileSuffixEnum } from '../extends/enum';
2
+ type FileSuffix = (typeof FileSuffixEnum)[keyof typeof FileSuffixEnum];
3
+ type ImageFileSuffix = (typeof ImageFileSuffixEnum)[keyof typeof ImageFileSuffixEnum];
4
+ type VideoFileSuffix = (typeof VideoFileSuffixEnum)[keyof typeof VideoFileSuffixEnum];
5
+ type PptFileSuffix = (typeof PptFileSuffixEnum)[keyof typeof PptFileSuffixEnum];
6
+ type DocumentFileSuffix = (typeof DocumentFileSuffixEnum)[keyof typeof DocumentFileSuffixEnum];
7
+ type MusicFileSuffix = (typeof MusicFileSuffixEnum)[keyof typeof MusicFileSuffixEnum];
8
+ type CompressFileSuffix = (typeof CompressFileSuffixEnum)[keyof typeof CompressFileSuffixEnum];
9
+ export type { CompressFileSuffix, DocumentFileSuffix, FileSuffix, ImageFileSuffix, MusicFileSuffix, PptFileSuffix, VideoFileSuffix, };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 更新文件路径的查询参数
3
+ * @param filePath 文件路径
4
+ * @param objectQuery 查询参数对象
5
+ * @returns 更新后的文件路径
6
+ */
7
+ declare function updateFilePathQuery(filePath: string, objectQuery: Record<string, string>, isAppend?: boolean): string;
8
+ export default updateFilePathQuery;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 防抖函数的类型定义
3
+ * @template T - 原始函数的类型
4
+ */
5
+ interface DebouncedFunction<T extends (...args: any[]) => any> {
6
+ /**
7
+ * 防抖后的函数,参数类型与原函数一致
8
+ */
9
+ (...args: Parameters<T>): void;
10
+ /**
11
+ * 取消防抖函数的未执行部分
12
+ */
13
+ cancel: () => void;
14
+ }
15
+ /**
16
+ * 创建一个防抖函数。
17
+ * 防抖函数的作用是限制一个函数在短时间内频繁触发的次数,直到指定的延迟时间结束后才执行。
18
+ * @param {T} callback - 需要防抖的函数
19
+ * @param {number} delay - 防抖的延迟时间(毫秒)
20
+ * @returns {DebouncedFunction<T>} 防抖后的函数,包含原函数的参数类型和取消方法
21
+ */
22
+ declare function debounce<T extends (...args: any[]) => any>(callback: T, delay: number): DebouncedFunction<T>;
23
+ export default debounce;
@@ -0,0 +1,3 @@
1
+ import { default as debounce } from './debounce';
2
+ import { default as throttle } from './throttle';
3
+ export { debounce, throttle };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 节流函数的类型定义
3
+ * @template T - 原始函数的类型
4
+ */
5
+ interface ThrottledFunction<T extends (...args: any[]) => any> {
6
+ /**
7
+ * 节流后的函数,参数类型与原函数一致
8
+ */
9
+ (...args: Parameters<T>): void;
10
+ /**
11
+ * 取消节流函数的未执行部分
12
+ */
13
+ cancel: () => void;
14
+ }
15
+ /**
16
+ * 创建一个节流函数。
17
+ * 节流函数的作用是限制一个函数在一定时间内最多执行一次,避免高频触发导致的性能问题。
18
+ * @param {T} callback - 需要节流的函数
19
+ * @param {number} delay - 节流的时间间隔(毫秒)
20
+ * @returns {ThrottledFunction<T>} 节流后的函数,包含原函数的参数类型和取消方法
21
+ */
22
+ declare function throttle<T extends (...args: any[]) => any>(callback: T, delay: number): ThrottledFunction<T>;
23
+ export default throttle;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 国际化管理器
3
+ */
4
+ export declare class I18n {
5
+ private currentLocale;
6
+ private messages;
7
+ /**
8
+ * 设置当前语言
9
+ * @param locale - 语言代码,如 'zh-cn', 'en', 'ms', 'ar', 'zh-tw', 'th', 'vi'
10
+ */
11
+ setLocale(locale: string): void;
12
+ /**
13
+ * 获取当前语言
14
+ * @returns 当前语言代码
15
+ */
16
+ getLocale(): string;
17
+ /**
18
+ * 注册语言包
19
+ * @param locale - 语言代码
20
+ * @param messages - 语言包内容
21
+ */
22
+ registerMessages(locale: string, messages: Record<string, string>): void;
23
+ /**
24
+ * 获取翻译文本
25
+ * @param key - 翻译键
26
+ * @param fallback - 备用文本
27
+ * @returns 翻译后的文本
28
+ */
29
+ t(key: string, fallback?: string): string;
30
+ }
31
+ export declare const i18n: I18n;
32
+ export type Locale = 'zh-cn' | 'zh-tw' | 'en' | 'ms' | 'ar' | 'th' | 'vi';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 阿拉伯语语言包
3
+ */
4
+ export declare const ar: {
5
+ 'audio.permission.no_user_interaction': string;
6
+ 'audio.permission.autoplay_blocked': string;
7
+ 'audio.permission.autoplay_unknown_error': string;
8
+ 'audio.permission.secure_context_error': string;
9
+ 'audio.permission.permission_denied_permanently': string;
10
+ 'audio.permission.media_devices_api_unavailable': string;
11
+ 'audio.permission.not_allowed_error': string;
12
+ 'audio.permission.not_readable_error': string;
13
+ 'audio.permission.not_found_error': string;
14
+ 'audio.permission.security_error': string;
15
+ 'audio.permission.overconstrained_error': string;
16
+ 'audio.permission.microphone_unknown_error': string;
17
+ 'audio.permission.microphone_timeout_error': string;
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 英文语言包
3
+ */
4
+ export declare const en: {
5
+ 'audio.permission.no_user_interaction': string;
6
+ 'audio.permission.autoplay_blocked': string;
7
+ 'audio.permission.autoplay_unknown_error': string;
8
+ 'audio.permission.secure_context_error': string;
9
+ 'audio.permission.permission_denied_permanently': string;
10
+ 'audio.permission.media_devices_api_unavailable': string;
11
+ 'audio.permission.not_allowed_error': string;
12
+ 'audio.permission.not_readable_error': string;
13
+ 'audio.permission.not_found_error': string;
14
+ 'audio.permission.security_error': string;
15
+ 'audio.permission.overconstrained_error': string;
16
+ 'audio.permission.microphone_unknown_error': string;
17
+ 'audio.permission.microphone_timeout_error': string;
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 马来语语言包
3
+ */
4
+ export declare const ms: {
5
+ 'audio.permission.no_user_interaction': string;
6
+ 'audio.permission.autoplay_blocked': string;
7
+ 'audio.permission.autoplay_unknown_error': string;
8
+ 'audio.permission.secure_context_error': string;
9
+ 'audio.permission.permission_denied_permanently': string;
10
+ 'audio.permission.media_devices_api_unavailable': string;
11
+ 'audio.permission.not_allowed_error': string;
12
+ 'audio.permission.not_readable_error': string;
13
+ 'audio.permission.not_found_error': string;
14
+ 'audio.permission.security_error': string;
15
+ 'audio.permission.overconstrained_error': string;
16
+ 'audio.permission.microphone_unknown_error': string;
17
+ 'audio.permission.microphone_timeout_error': string;
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 泰语语言包
3
+ */
4
+ export declare const th: {
5
+ 'audio.permission.no_user_interaction': string;
6
+ 'audio.permission.autoplay_blocked': string;
7
+ 'audio.permission.autoplay_unknown_error': string;
8
+ 'audio.permission.secure_context_error': string;
9
+ 'audio.permission.permission_denied_permanently': string;
10
+ 'audio.permission.media_devices_api_unavailable': string;
11
+ 'audio.permission.not_allowed_error': string;
12
+ 'audio.permission.not_readable_error': string;
13
+ 'audio.permission.not_found_error': string;
14
+ 'audio.permission.security_error': string;
15
+ 'audio.permission.overconstrained_error': string;
16
+ 'audio.permission.microphone_unknown_error': string;
17
+ 'audio.permission.microphone_timeout_error': string;
18
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 越南语语言包
3
+ */
4
+ export declare const vi: {
5
+ 'audio.permission.no_user_interaction': string;
6
+ 'audio.permission.autoplay_blocked': string;
7
+ 'audio.permission.autoplay_unknown_error': string;
8
+ 'audio.permission.secure_context_error': string;
9
+ 'audio.permission.permission_denied_permanently': string;
10
+ 'audio.permission.media_devices_api_unavailable': string;
11
+ 'audio.permission.not_allowed_error': string;
12
+ 'audio.permission.not_readable_error': string;
13
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 简体中文语言包
3
+ */
4
+ export declare const zhCn: {
5
+ 'audio.permission.no_user_interaction': string;
6
+ 'audio.permission.autoplay_blocked': string;
7
+ 'audio.permission.autoplay_unknown_error': string;
8
+ 'audio.permission.secure_context_error': string;
9
+ 'audio.permission.permission_denied_permanently': string;
10
+ 'audio.permission.media_devices_api_unavailable': string;
11
+ 'audio.permission.not_allowed_error': string;
12
+ 'audio.permission.not_readable_error': string;
13
+ 'audio.permission.not_found_error': string;
14
+ 'audio.permission.security_error': string;
15
+ 'audio.permission.overconstrained_error': string;
16
+ 'audio.permission.microphone_unknown_error': string;
17
+ 'audio.permission.microphone_timeout_error': string;
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 繁体中文语言包
3
+ */
4
+ export declare const zhTw: {
5
+ 'audio.permission.no_user_interaction': string;
6
+ 'audio.permission.autoplay_blocked': string;
7
+ 'audio.permission.autoplay_unknown_error': string;
8
+ 'audio.permission.secure_context_error': string;
9
+ 'audio.permission.permission_denied_permanently': string;
10
+ 'audio.permission.media_devices_api_unavailable': string;
11
+ 'audio.permission.not_allowed_error': string;
12
+ 'audio.permission.not_readable_error': string;
13
+ 'audio.permission.not_found_error': string;
14
+ 'audio.permission.security_error': string;
15
+ 'audio.permission.overconstrained_error': string;
16
+ 'audio.permission.microphone_unknown_error': string;
17
+ 'audio.permission.microphone_timeout_error': string;
18
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 初始化国际化配置
3
+ */
4
+ export declare function setupI18n(): void;
@@ -0,0 +1,28 @@
1
+ import { Locale } from './i18n';
2
+ export * from './array';
3
+ export * from './browser';
4
+ export * from './constant';
5
+ export * from './core';
6
+ export * from './file';
7
+ export * from './function';
8
+ export * from './math';
9
+ export * from './object';
10
+ export * from './string';
11
+ export * from './supply';
12
+ export * from './theme';
13
+ export * from './validator';
14
+ export * from './web-socket';
15
+ export * from './wrker';
16
+ declare const _default: {
17
+ /**
18
+ * 设置语言
19
+ * @param locale - 语言代码,支持 'zh-cn', 'zh-tw', 'en', 'ms', 'ar', 'th'、'vi'
20
+ */
21
+ locale(locale: Locale): void;
22
+ /**
23
+ * 获取当前语言
24
+ * @returns 当前语言代码
25
+ */
26
+ getLocale(): Locale;
27
+ };
28
+ export default _default;