@gx-design-vue/pro-utils 0.2.0-alpha.2 → 0.2.0-alpha.4

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 (97) hide show
  1. package/dist/array/index.d.ts +2 -2
  2. package/dist/array/index.js +2 -3
  3. package/dist/array/slice.js +1 -4
  4. package/dist/array/sort.js +5 -8
  5. package/dist/array/tree.d.ts +6 -6
  6. package/dist/array/tree.js +15 -15
  7. package/dist/array/unique.d.ts +24 -2
  8. package/dist/array/unique.js +34 -3
  9. package/dist/class/index.js +1 -2
  10. package/dist/class/prefix.d.ts +2 -2
  11. package/dist/class/prefix.js +3 -4
  12. package/dist/clone/cloneDeep.js +1 -3
  13. package/dist/clone/cloneDeepWith.js +4 -7
  14. package/dist/clone/getTag.js +1 -2
  15. package/dist/clone/index.js +1 -2
  16. package/dist/clone/tags.js +1 -2
  17. package/dist/dom/event.js +1 -2
  18. package/dist/dom/index.d.ts +3 -2
  19. package/dist/dom/index.js +3 -3
  20. package/dist/dom/measure.js +9 -6
  21. package/dist/{file → dom}/media.d.ts +1 -1
  22. package/dist/{file → dom}/media.js +37 -20
  23. package/dist/dom/raf.d.ts +1 -1
  24. package/dist/dom/raf.js +1 -2
  25. package/dist/dom/scroll.js +5 -7
  26. package/dist/{base64/index.d.ts → encoding/base64.d.ts} +2 -2
  27. package/dist/{base64/index.js → encoding/base64.js} +29 -33
  28. package/dist/encoding/index.d.ts +2 -0
  29. package/dist/encoding/index.js +2 -0
  30. package/dist/file/config.js +6 -2
  31. package/dist/file/convert.d.ts +6 -2
  32. package/dist/file/convert.js +7 -3
  33. package/dist/file/index.d.ts +2 -3
  34. package/dist/file/index.js +2 -4
  35. package/dist/file/type.js +7 -10
  36. package/dist/function/copy.d.ts +7 -0
  37. package/dist/function/copy.js +8 -2
  38. package/dist/function/getValue.d.ts +2 -2
  39. package/dist/function/getValue.js +4 -5
  40. package/dist/function/index.js +1 -2
  41. package/dist/function/object.js +1 -2
  42. package/dist/function/run.js +1 -2
  43. package/dist/index.d.ts +11 -17
  44. package/dist/index.js +13 -22
  45. package/dist/is/base64.d.ts +7 -4
  46. package/dist/is/base64.js +9 -6
  47. package/dist/is/browser.js +2 -3
  48. package/dist/is/deepEqual.d.ts +10 -4
  49. package/dist/is/deepEqual.js +14 -9
  50. package/dist/is/device.js +4 -2
  51. package/dist/is/equal.js +1 -2
  52. package/dist/is/img.js +1 -2
  53. package/dist/is/index.d.ts +3 -3
  54. package/dist/is/index.js +3 -4
  55. package/dist/is/nil.js +1 -2
  56. package/dist/is/plainObject.js +2 -4
  57. package/dist/is/primitive.js +1 -2
  58. package/dist/is/server.js +1 -2
  59. package/dist/is/type.js +1 -2
  60. package/dist/is/typedArray.js +1 -2
  61. package/dist/is/unsafeProperty.js +1 -2
  62. package/dist/is/url.js +2 -4
  63. package/dist/is/valid.js +1 -2
  64. package/dist/merge/{useDeepMege.d.ts → deepCloneMerge.d.ts} +3 -1
  65. package/dist/merge/{useDeepMege.js → deepCloneMerge.js} +6 -6
  66. package/dist/merge/index.d.ts +1 -1
  67. package/dist/merge/index.js +26 -10
  68. package/dist/merge/mergeWith.js +1 -4
  69. package/dist/number/chinese.js +1 -4
  70. package/dist/number/format.js +7 -6
  71. package/dist/number/index.js +1 -2
  72. package/dist/object/classNames.js +1 -5
  73. package/dist/object/index.js +2 -3
  74. package/dist/object/omitBoolean.js +1 -2
  75. package/dist/object/omitUndefined.js +1 -2
  76. package/dist/object/omitUndefinedAndEmptyArr.js +1 -2
  77. package/dist/pro-utils.esm.js +625 -402
  78. package/dist/pro-utils.js +2 -1
  79. package/dist/{vue/slots.d.ts → slots/index.d.ts} +3 -3
  80. package/dist/{vue/slots.js → slots/index.js} +34 -20
  81. package/dist/string/duration.js +1 -2
  82. package/dist/string/empty.js +1 -2
  83. package/dist/string/index.d.ts +2 -2
  84. package/dist/string/index.js +2 -3
  85. package/dist/string/nanoid.js +1 -2
  86. package/dist/string/uuid.d.ts +10 -8
  87. package/dist/string/uuid.js +41 -30
  88. package/dist/table/column.js +6 -10
  89. package/dist/table/index.js +1 -2
  90. package/dist/table/page.js +1 -4
  91. package/dist/typing.d.ts +2 -2
  92. package/dist/typing.js +1 -1
  93. package/package.json +2 -1
  94. package/dist/clone/symbols.d.ts +0 -10
  95. package/dist/clone/symbols.js +0 -13
  96. package/dist/vue/index.d.ts +0 -2
  97. package/dist/vue/index.js +0 -3
@@ -1,52 +1,50 @@
1
- //#region src/base64/index.ts
1
+ //#region src/encoding/base64.ts
2
+ const BASE64_KEY_STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
2
3
  /**
3
4
  * Base64 编解码类
4
5
  */
5
6
  var Base64 = class {
6
7
  _keyStr;
7
8
  constructor() {
8
- this._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
9
+ this._keyStr = BASE64_KEY_STR;
9
10
  }
10
11
  _utf8_encode(string) {
11
12
  string = string.replace(/\r\n/g, "\n");
12
- let utftext = "";
13
+ const utftext = [];
13
14
  for (let n = 0; n < string.length; n++) {
14
15
  const c = string.charCodeAt(n);
15
- if (c < 128) utftext += String.fromCharCode(c);
16
+ if (c < 128) utftext.push(c);
16
17
  else if (c > 127 && c < 2048) {
17
- utftext += String.fromCharCode(c >> 6 | 192);
18
- utftext += String.fromCharCode(c & 63 | 128);
18
+ utftext.push(c >> 6 | 192);
19
+ utftext.push(c & 63 | 128);
19
20
  } else {
20
- utftext += String.fromCharCode(c >> 12 | 224);
21
- utftext += String.fromCharCode(c >> 6 & 63 | 128);
22
- utftext += String.fromCharCode(c & 63 | 128);
21
+ utftext.push(c >> 12 | 224);
22
+ utftext.push(c >> 6 & 63 | 128);
23
+ utftext.push(c & 63 | 128);
23
24
  }
24
25
  }
25
- return utftext;
26
+ return String.fromCharCode(...utftext);
26
27
  }
27
28
  _utf8_decode(utftext) {
28
- let string = "";
29
+ const chars = [];
29
30
  let i = 0;
30
- let c = 0;
31
- let c1 = 0;
32
- let c2 = 0;
33
31
  while (i < utftext.length) {
34
- c = utftext.charCodeAt(i);
32
+ const c = utftext.charCodeAt(i);
35
33
  if (c < 128) {
36
- string += String.fromCharCode(c);
34
+ chars.push(c);
37
35
  i++;
38
36
  } else if (c > 191 && c < 224) {
39
- c1 = utftext.charCodeAt(i + 1);
40
- string += String.fromCharCode((c & 31) << 6 | c1 & 63);
37
+ const c1 = utftext.charCodeAt(i + 1);
38
+ chars.push((c & 31) << 6 | c1 & 63);
41
39
  i += 2;
42
40
  } else {
43
- c1 = utftext.charCodeAt(i + 1);
44
- c2 = utftext.charCodeAt(i + 2);
45
- string += String.fromCharCode((c & 15) << 12 | (c1 & 63) << 6 | c2 & 63);
41
+ const c1 = utftext.charCodeAt(i + 1);
42
+ const c2 = utftext.charCodeAt(i + 2);
43
+ chars.push((c & 15) << 12 | (c1 & 63) << 6 | c2 & 63);
46
44
  i += 3;
47
45
  }
48
46
  }
49
- return string;
47
+ return String.fromCharCode(...chars);
50
48
  }
51
49
  /**
52
50
  * 加密方法
@@ -55,7 +53,7 @@ var Base64 = class {
55
53
  * @returns Base64 编码后的字符串
56
54
  */
57
55
  encode(input) {
58
- let output = "";
56
+ const output = [];
59
57
  let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
60
58
  let i = 0;
61
59
  input = this._utf8_encode(input);
@@ -69,9 +67,9 @@ var Base64 = class {
69
67
  enc4 = chr3 & 63;
70
68
  if (Number.isNaN(chr2)) enc3 = enc4 = 64;
71
69
  else if (Number.isNaN(chr3)) enc4 = 64;
72
- output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
70
+ output.push(this._keyStr.charAt(enc1), this._keyStr.charAt(enc2), this._keyStr.charAt(enc3), this._keyStr.charAt(enc4));
73
71
  }
74
- return output;
72
+ return output.join("");
75
73
  }
76
74
  /**
77
75
  * 解密方法
@@ -80,7 +78,7 @@ var Base64 = class {
80
78
  * @returns 解码后的字符串
81
79
  */
82
80
  decode(input) {
83
- let output = "";
81
+ const output = [];
84
82
  let chr1, chr2, chr3;
85
83
  let enc1, enc2, enc3, enc4;
86
84
  let i = 0;
@@ -93,14 +91,12 @@ var Base64 = class {
93
91
  chr1 = enc1 << 2 | enc2 >> 4;
94
92
  chr2 = (enc2 & 15) << 4 | enc3 >> 2;
95
93
  chr3 = (enc3 & 3) << 6 | enc4;
96
- output = output + String.fromCharCode(chr1);
97
- if (enc3 !== 64) output = output + String.fromCharCode(chr2);
98
- if (enc4 !== 64) output = output + String.fromCharCode(chr3);
94
+ output.push(chr1);
95
+ if (enc3 !== 64) output.push(chr2);
96
+ if (enc4 !== 64) output.push(chr3);
99
97
  }
100
- output = this._utf8_decode(output);
101
- return output;
98
+ return this._utf8_decode(String.fromCharCode(...output));
102
99
  }
103
100
  };
104
-
105
101
  //#endregion
106
- export { Base64 as default };
102
+ export { Base64, Base64 as default };
@@ -0,0 +1,2 @@
1
+ import { Base64 } from "./base64.js";
2
+ export { Base64 };
@@ -0,0 +1,2 @@
1
+ import { Base64 } from "./base64.js";
2
+ export { Base64 };
@@ -3,11 +3,13 @@
3
3
  * 文件类型配置
4
4
  */
5
5
  const fileTypes = {
6
+ /** 允许的视频格式 */
6
7
  videoAllowType: [
7
8
  "mp4",
8
9
  "webm",
9
10
  "ogg"
10
11
  ],
12
+ /** 允许的音频格式 */
11
13
  audioAllowType: [
12
14
  "mp3",
13
15
  "ogg",
@@ -16,6 +18,7 @@ const fileTypes = {
16
18
  "m4a",
17
19
  "webm"
18
20
  ],
21
+ /** 图片格式 */
19
22
  imageType: [
20
23
  "jpeg",
21
24
  "jpg",
@@ -37,6 +40,7 @@ const fileTypes = {
37
40
  "psd",
38
41
  "eps"
39
42
  ],
43
+ /** 视频格式 */
40
44
  videoType: [
41
45
  "mp4",
42
46
  "avi",
@@ -59,6 +63,7 @@ const fileTypes = {
59
63
  "divx",
60
64
  "xvid"
61
65
  ],
66
+ /** 音频格式 */
62
67
  audioType: [
63
68
  "mp3",
64
69
  "wav",
@@ -76,6 +81,5 @@ const fileTypes = {
76
81
  "ape"
77
82
  ]
78
83
  };
79
-
80
84
  //#endregion
81
- export { fileTypes };
85
+ export { fileTypes };
@@ -36,6 +36,10 @@ declare function dataURLtoFile(url: string, filename: string): File;
36
36
  * @param fileType - 文件类型
37
37
  * @returns File 对象
38
38
  */
39
- declare function blobToDataURL(blob: Blob, fileName: string, fileType: string): File;
39
+ declare function blobToFile(blob: Blob, fileName: string, fileType: string): File;
40
+ /**
41
+ * @deprecated 请使用 blobToFile,该函数实际返回 File 对象而非 Data URL
42
+ */
43
+ declare const blobToDataURL: typeof blobToFile;
40
44
  //#endregion
41
- export { blobToDataURL, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl };
45
+ export { blobToDataURL, blobToFile, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl };
@@ -61,9 +61,13 @@ function dataURLtoFile(url, filename) {
61
61
  * @param fileType - 文件类型
62
62
  * @returns File 对象
63
63
  */
64
- function blobToDataURL(blob, fileName, fileType) {
64
+ function blobToFile(blob, fileName, fileType) {
65
+ if (typeof window === "undefined") return null;
65
66
  return new window.File([blob], fileName, { type: fileType });
66
67
  }
67
-
68
+ /**
69
+ * @deprecated 请使用 blobToFile,该函数实际返回 File 对象而非 Data URL
70
+ */
71
+ const blobToDataURL = blobToFile;
68
72
  //#endregion
69
- export { blobToDataURL, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl };
73
+ export { blobToDataURL, blobToFile, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl };
@@ -1,5 +1,4 @@
1
1
  import { fileTypes } from "./config.js";
2
- import { blobToDataURL, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./convert.js";
3
- import { generateVideoPicture, getMediaInfos, getVideoCoverPicture } from "./media.js";
2
+ import { blobToDataURL, blobToFile, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./convert.js";
4
3
  import { checkFileType, getFileSuffix, getVideoFileUrl } from "./type.js";
5
- export { blobToDataURL, checkFileType, dataURLtoBlob, dataURLtoFile, fileTypes, generateVideoPicture, getBase64, getBlobUrl, getFileSuffix, getMediaInfos, getVideoCoverPicture, getVideoFileUrl };
4
+ export { blobToDataURL, blobToFile, checkFileType, dataURLtoBlob, dataURLtoFile, fileTypes, getBase64, getBlobUrl, getFileSuffix, getVideoFileUrl };
@@ -1,6 +1,4 @@
1
1
  import { fileTypes } from "./config.js";
2
- import { blobToDataURL, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./convert.js";
3
2
  import { checkFileType, getFileSuffix, getVideoFileUrl } from "./type.js";
4
- import { generateVideoPicture, getMediaInfos, getVideoCoverPicture } from "./media.js";
5
-
6
- export { blobToDataURL, checkFileType, dataURLtoBlob, dataURLtoFile, fileTypes, generateVideoPicture, getBase64, getBlobUrl, getFileSuffix, getMediaInfos, getVideoCoverPicture, getVideoFileUrl };
3
+ import { blobToDataURL, blobToFile, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./convert.js";
4
+ export { blobToDataURL, blobToFile, checkFileType, dataURLtoBlob, dataURLtoFile, fileTypes, getBase64, getBlobUrl, getFileSuffix, getVideoFileUrl };
package/dist/file/type.js CHANGED
@@ -1,7 +1,5 @@
1
- import { isBase64 } from "../is/base64.js";
2
- import "../is/index.js";
1
+ import { isMediaDataURI } from "../is/base64.js";
3
2
  import { fileTypes } from "./config.js";
4
-
5
3
  //#region src/file/type.ts
6
4
  /**
7
5
  * 获取文件后缀名
@@ -38,21 +36,20 @@ function checkFileType(url, type) {
38
36
  if (!url) return "4";
39
37
  if (url === "data:") return "4";
40
38
  let fileType = "4";
41
- if (isBase64(url)) {
39
+ if (isMediaDataURI(url)) {
42
40
  if (url.includes("data:image/")) fileType = "png";
43
41
  else if (url.includes("data:video/")) fileType = "mp4";
44
42
  else if (url.includes("data:audio/")) fileType = "mp3";
45
43
  } else if (url instanceof Blob) {
46
- url = String(url);
47
- if (url.includes("image")) fileType = "png";
48
- else if (url.includes("video")) fileType = "mp4";
49
- else if (url.includes("audio")) fileType = "mp3";
44
+ const mimeType = url.type || "";
45
+ if (mimeType.startsWith("image/")) fileType = "png";
46
+ else if (mimeType.startsWith("video/")) fileType = "mp4";
47
+ else if (mimeType.startsWith("audio/")) fileType = "mp3";
50
48
  } else fileType = getFileSuffix(url).toLowerCase();
51
49
  if (fileTypes.imageType.includes(fileType)) return "1";
52
50
  if (fileTypes.videoType.includes(fileType)) return "3";
53
51
  if (fileTypes.audioType.includes(fileType)) return "2";
54
52
  return "4";
55
53
  }
56
-
57
54
  //#endregion
58
- export { checkFileType, getFileSuffix, getVideoFileUrl };
55
+ export { checkFileType, getFileSuffix, getVideoFileUrl };
@@ -4,6 +4,13 @@ import { RecordType } from "../typing.js";
4
4
  /**
5
5
  * 简单深拷贝(使用 JSON 序列化)
6
6
  *
7
+ * 注意:基于 `JSON.parse(JSON.stringify())` 实现,存在以下限制:
8
+ * - `undefined`、函数、`Symbol` 会丢失
9
+ * - `Date` 会变为字符串、`RegExp`/`Map`/`Set` 会变为空对象
10
+ * - 含循环引用时会抛错
11
+ *
12
+ * 如需完整深拷贝,请使用 {@link cloneDeep}。
13
+ *
7
14
  * @param data - 要拷贝的数据
8
15
  * @returns 拷贝后的数据
9
16
  */
@@ -2,12 +2,18 @@
2
2
  /**
3
3
  * 简单深拷贝(使用 JSON 序列化)
4
4
  *
5
+ * 注意:基于 `JSON.parse(JSON.stringify())` 实现,存在以下限制:
6
+ * - `undefined`、函数、`Symbol` 会丢失
7
+ * - `Date` 会变为字符串、`RegExp`/`Map`/`Set` 会变为空对象
8
+ * - 含循环引用时会抛错
9
+ *
10
+ * 如需完整深拷贝,请使用 {@link cloneDeep}。
11
+ *
5
12
  * @param data - 要拷贝的数据
6
13
  * @returns 拷贝后的数据
7
14
  */
8
15
  function deepCopy(data) {
9
16
  return JSON.parse(JSON.stringify(data));
10
17
  }
11
-
12
18
  //#endregion
13
- export { deepCopy };
19
+ export { deepCopy };
@@ -1,10 +1,10 @@
1
1
  //#region src/function/getValue.d.ts
2
- type DeepValueOf<T, K> = K extends `${infer First}:${infer Rest}` ? First extends keyof T ? Rest extends '' ? T[First] : DeepValueOf<T[First], Rest> : undefined : K extends keyof T ? T[K] : undefined;
2
+ type DeepValueOf<T, K> = K extends `${infer First}.${infer Rest}` ? First extends keyof T ? Rest extends '' ? T[First] : DeepValueOf<T[First], Rest> : undefined : K extends `${infer First}:${infer Rest}` ? First extends keyof T ? Rest extends '' ? T[First] : DeepValueOf<T[First], Rest> : undefined : K extends keyof T ? T[K] : undefined;
3
3
  /**
4
4
  * 根据 key 从对象中获取值(支持嵌套路径)
5
5
  *
6
6
  * @param object - 目标对象
7
- * @param key - 键路径(支持用冒号分隔的嵌套路径)
7
+ * @param key - 键路径(支持 `.` 或 `:` 分隔的嵌套路径)
8
8
  * @returns 获取的值
9
9
  */
10
10
  declare function getValueFromObjectByKey<T extends object, K extends string | string[] = string>(object: T, key: K): DeepValueOf<T, K extends string ? K : string> | undefined;
@@ -3,17 +3,16 @@
3
3
  * 根据 key 从对象中获取值(支持嵌套路径)
4
4
  *
5
5
  * @param object - 目标对象
6
- * @param key - 键路径(支持用冒号分隔的嵌套路径)
6
+ * @param key - 键路径(支持 `.` 或 `:` 分隔的嵌套路径)
7
7
  * @returns 获取的值
8
8
  */
9
9
  function getValueFromObjectByKey(object, key) {
10
10
  if (typeof key !== "string" && !Array.isArray(key)) return;
11
- const keys = Array.isArray(key) ? key : key.split(":");
11
+ const keys = Array.isArray(key) ? key : key.split(/[.:]/);
12
12
  let currentValue = object;
13
- for (let i = 0; i < keys.length; i++) if (currentValue && Object.prototype.hasOwnProperty.call(currentValue, keys[i])) currentValue = currentValue[keys[i]];
13
+ for (let i = 0; i < keys.length; i++) if (currentValue && Object.hasOwn(currentValue, keys[i])) currentValue = currentValue[keys[i]];
14
14
  else return;
15
15
  return currentValue;
16
16
  }
17
-
18
17
  //#endregion
19
- export { getValueFromObjectByKey };
18
+ export { getValueFromObjectByKey };
@@ -2,5 +2,4 @@ import { forInObject, getSymbols, keysOf } from "./object.js";
2
2
  import { deepCopy } from "./copy.js";
3
3
  import { getValueFromObjectByKey } from "./getValue.js";
4
4
  import { runFunction } from "./run.js";
5
-
6
- export { deepCopy, forInObject, getSymbols, getValueFromObjectByKey, keysOf, runFunction };
5
+ export { deepCopy, forInObject, getSymbols, getValueFromObjectByKey, keysOf, runFunction };
@@ -28,6 +28,5 @@ function forInObject(obj, callback) {
28
28
  function keysOf(obj) {
29
29
  return Object.keys(obj);
30
30
  }
31
-
32
31
  //#endregion
33
- export { forInObject, getSymbols, keysOf };
32
+ export { forInObject, getSymbols, keysOf };
@@ -10,6 +10,5 @@ function runFunction(valueEnum, ...rest) {
10
10
  if (typeof valueEnum === "function") return valueEnum(...rest);
11
11
  return valueEnum;
12
12
  }
13
-
14
13
  //#endregion
15
- export { runFunction };
14
+ export { runFunction };
package/dist/index.d.ts CHANGED
@@ -2,29 +2,26 @@ import { arraySlice } from "./array/slice.js";
2
2
  import { compareArray, compareArraySort, compareArrayTimeSort, compareTime } from "./array/sort.js";
3
3
  import { AlignType, BasicTablePageConfig, Breakpoint, CustomRender, DeepPartial, EmptyEmit, ExtendIfDefined, Fn, LimitDeepPartial, MediaOptions, Nullable, OmitUndefined, RecordType, SemanticClassNames, SemanticStyles, SizeType, VueNode, WithFalse, WithIfDefault, WithRequired } from "./typing.js";
4
4
  import { filterTree, findSourceByTree, findValueAndAncestors, getArrayLast, getLevelData, getMaxFloor, getSortIndex, treeData } from "./array/tree.js";
5
- import { arrayUnique } from "./array/unique.js";
6
- import "./array/index.js";
5
+ import { arrayUnique, arrayUniqueBy } from "./array/unique.js";
7
6
  import { PrefixCls, getPrefixCls } from "./class/prefix.js";
8
7
  import { cloneDeep } from "./clone/cloneDeep.js";
9
8
  import { cloneDeepWith, cloneDeepWithImpl, copyProperties } from "./clone/cloneDeepWith.js";
10
9
  import { off, on } from "./dom/event.js";
11
10
  import { getTextWidth } from "./dom/measure.js";
12
- import wrapperRaf from "./dom/raf.js";
11
+ import { generateVideoPicture, getMediaInfos, getVideoCoverPicture } from "./dom/media.js";
12
+ import { wrapperRaf } from "./dom/raf.js";
13
13
  import { ScrollToOptions, easeInOutCubic, getScroll, getScrollContainer, isInContainer, isScroll, isWindow, scrollTo } from "./dom/scroll.js";
14
- import "./dom/index.js";
14
+ import { Base64 } from "./encoding/base64.js";
15
15
  import { fileTypes } from "./file/config.js";
16
- import { blobToDataURL, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./file/convert.js";
17
- import { generateVideoPicture, getMediaInfos, getVideoCoverPicture } from "./file/media.js";
16
+ import { blobToDataURL, blobToFile, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./file/convert.js";
18
17
  import { checkFileType, getFileSuffix, getVideoFileUrl } from "./file/type.js";
19
- import "./file/index.js";
20
18
  import { deepCopy } from "./function/copy.js";
21
19
  import { getValueFromObjectByKey } from "./function/getValue.js";
22
20
  import { forInObject, getSymbols, keysOf } from "./function/object.js";
23
21
  import { runFunction } from "./function/run.js";
24
- import "./function/index.js";
25
- import { isBase64, isDataURLBase64 } from "./is/base64.js";
22
+ import { isDataURLBase64, isMediaDataURI } from "./is/base64.js";
26
23
  import { isBrowser } from "./is/browser.js";
27
- import { isDeepEqualReact } from "./is/deepEqual.js";
24
+ import { isDeepEqual, isDeepEqualReact } from "./is/deepEqual.js";
28
25
  import { isMobile, isTablet, isWindowsOs } from "./is/device.js";
29
26
  import { isEqual } from "./is/equal.js";
30
27
  import { isImg } from "./is/img.js";
@@ -37,7 +34,7 @@ import { isTypedArray } from "./is/typedArray.js";
37
34
  import { isUnsafeProperty } from "./is/unsafeProperty.js";
38
35
  import { isUrl } from "./is/url.js";
39
36
  import { convertValueBoolean, isValid } from "./is/valid.js";
40
- import { useDeepMerge } from "./merge/useDeepMege.js";
37
+ import { useDeepMerge } from "./merge/deepCloneMerge.js";
41
38
  import { mergeWith } from "./merge/mergeWith.js";
42
39
  import { deepMerge, merge } from "./merge/index.js";
43
40
  import { toChinesNum } from "./number/chinese.js";
@@ -46,14 +43,11 @@ import classNames from "./object/classNames.js";
46
43
  import { omitBoolean } from "./object/omitBoolean.js";
47
44
  import { omitUndefined } from "./object/omitUndefined.js";
48
45
  import { omitUndefinedAndEmptyArr } from "./object/omitUndefinedAndEmptyArr.js";
49
- import "./object/index.js";
46
+ import { RenderResult, SlotsPropsResult, filterEmpty, getKeys, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, isEmptyElement, slotRender } from "./slots/index.js";
50
47
  import { formatDuration } from "./string/duration.js";
51
48
  import { handleEmptyField } from "./string/empty.js";
52
49
  import { nanoid } from "./string/nanoid.js";
53
- import { getRandomNumber } from "./string/uuid.js";
50
+ import { createUUIDFactory } from "./string/uuid.js";
54
51
  import { genColumnKey, handleShowIndex } from "./table/column.js";
55
52
  import { handleCurrentPage } from "./table/page.js";
56
- import "./table/index.js";
57
- import { RenderResult, SlotsPropsResult, filterEmpty, getKeys, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, isEmptyElement, slotRender } from "./vue/slots.js";
58
- import "./vue/index.js";
59
- export { AlignType, BasicTablePageConfig, Breakpoint, CustomRender, DeepPartial, EmptyEmit, ExtendIfDefined, Fn, LimitDeepPartial, MediaOptions, Nullable, OmitUndefined, PrefixCls, RecordType, RenderResult, ScrollToOptions, SemanticClassNames, SemanticStyles, SizeType, SlotsPropsResult, VueNode, WithFalse, WithIfDefault, WithRequired, arraySlice, arrayUnique, blobToDataURL, checkFileType, classNames, cloneDeep, cloneDeepWith, cloneDeepWithImpl, compareArray, compareArraySort, compareArrayTimeSort, compareTime, convertValueBoolean, copyProperties, dataURLtoBlob, dataURLtoFile, deepCopy, deepMerge, easeInOutCubic, fileTypes, filterEmpty, filterTree, findSourceByTree, findValueAndAncestors, forInObject, formatDuration, formatNumber, genColumnKey, generateVideoPicture, getArrayLast, getBase64, getBlobUrl, getFileSuffix, getKeys, getLevelData, getMaxFloor, getMediaInfos, getPrefixCls, getRandomNumber, getScroll, getScrollContainer, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, getSortIndex, getSymbols, getTextWidth, getValueFromObjectByKey, getVideoCoverPicture, getVideoFileUrl, handleCurrentPage, handleEmptyField, handleShowIndex, is, isArray, isBase64, isBoolean, isBrowser, isDataURLBase64, isDeepEqualReact, isEmptyElement, isEqual, isFunction, isImg, isInContainer, isJSONStr, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isScroll, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindow, isWindowsOs, keysOf, merge, mergeWith, nanoid, off, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr, on, wrapperRaf as raf, runFunction, scrollTo, slotRender, toChinesNum, toConvertNumberShow, treeData, useDeepMerge };
53
+ export { AlignType, Base64, BasicTablePageConfig, Breakpoint, CustomRender, DeepPartial, EmptyEmit, ExtendIfDefined, Fn, LimitDeepPartial, MediaOptions, Nullable, OmitUndefined, PrefixCls, RecordType, RenderResult, ScrollToOptions, SemanticClassNames, SemanticStyles, SizeType, SlotsPropsResult, VueNode, WithFalse, WithIfDefault, WithRequired, arraySlice, arrayUnique, arrayUniqueBy, blobToDataURL, blobToFile, checkFileType, classNames, cloneDeep, cloneDeepWith, cloneDeepWithImpl, compareArray, compareArraySort, compareArrayTimeSort, compareTime, convertValueBoolean, copyProperties, createUUIDFactory, dataURLtoBlob, dataURLtoFile, deepCopy, deepMerge, easeInOutCubic, fileTypes, filterEmpty, filterTree, findSourceByTree, findValueAndAncestors, forInObject, formatDuration, formatNumber, genColumnKey, generateVideoPicture, getArrayLast, getBase64, getBlobUrl, getFileSuffix, getKeys, getLevelData, getMaxFloor, getMediaInfos, getPrefixCls, getScroll, getScrollContainer, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, getSortIndex, getSymbols, getTextWidth, getValueFromObjectByKey, getVideoCoverPicture, getVideoFileUrl, handleCurrentPage, handleEmptyField, handleShowIndex, is, isArray, isBoolean, isBrowser, isDataURLBase64, isDeepEqual, isDeepEqualReact, isEmptyElement, isEqual, isFunction, isImg, isInContainer, isJSONStr, isMediaDataURI, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isScroll, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindow, isWindowsOs, keysOf, merge, mergeWith, nanoid, off, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr, on, wrapperRaf as raf, runFunction, scrollTo, slotRender, toChinesNum, toConvertNumberShow, treeData, useDeepMerge };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { isBase64, isDataURLBase64 } from "./is/base64.js";
1
+ import { isDataURLBase64, isMediaDataURI } from "./is/base64.js";
2
2
  import { isBrowser } from "./is/browser.js";
3
- import { isDeepEqualReact } from "./is/deepEqual.js";
3
+ import { isDeepEqual, isDeepEqualReact } from "./is/deepEqual.js";
4
4
  import { isMobile, isTablet, isWindowsOs } from "./is/device.js";
5
5
  import { isEqual } from "./is/equal.js";
6
6
  import { isImg } from "./is/img.js";
@@ -14,48 +14,39 @@ import { isTypedArray } from "./is/typedArray.js";
14
14
  import { isUnsafeProperty } from "./is/unsafeProperty.js";
15
15
  import { isUrl } from "./is/url.js";
16
16
  import { convertValueBoolean, isValid } from "./is/valid.js";
17
- import "./is/index.js";
18
17
  import { arraySlice } from "./array/slice.js";
19
18
  import { compareArray, compareArraySort, compareArrayTimeSort, compareTime } from "./array/sort.js";
20
19
  import { filterTree, findSourceByTree, findValueAndAncestors, getArrayLast, getLevelData, getMaxFloor, getSortIndex, treeData } from "./array/tree.js";
21
- import { arrayUnique } from "./array/unique.js";
22
- import "./array/index.js";
20
+ import { arrayUnique, arrayUniqueBy } from "./array/unique.js";
23
21
  import { getPrefixCls } from "./class/prefix.js";
24
22
  import { cloneDeepWith, cloneDeepWithImpl, copyProperties } from "./clone/cloneDeepWith.js";
25
23
  import { cloneDeep } from "./clone/cloneDeep.js";
26
- import "./clone/index.js";
27
24
  import { off, on } from "./dom/event.js";
28
25
  import { getTextWidth } from "./dom/measure.js";
29
- import wrapperRaf from "./dom/raf.js";
30
- import { easeInOutCubic, getScroll, getScrollContainer, isInContainer, isScroll, isWindow, scrollTo } from "./dom/scroll.js";
31
- import "./dom/index.js";
32
26
  import { fileTypes } from "./file/config.js";
33
- import { blobToDataURL, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./file/convert.js";
34
27
  import { checkFileType, getFileSuffix, getVideoFileUrl } from "./file/type.js";
35
- import { generateVideoPicture, getMediaInfos, getVideoCoverPicture } from "./file/media.js";
36
- import "./file/index.js";
28
+ import { generateVideoPicture, getMediaInfos, getVideoCoverPicture } from "./dom/media.js";
29
+ import { wrapperRaf } from "./dom/raf.js";
30
+ import { easeInOutCubic, getScroll, getScrollContainer, isInContainer, isScroll, isWindow, scrollTo } from "./dom/scroll.js";
31
+ import { Base64 } from "./encoding/base64.js";
32
+ import { blobToDataURL, blobToFile, dataURLtoBlob, dataURLtoFile, getBase64, getBlobUrl } from "./file/convert.js";
37
33
  import { deepCopy } from "./function/copy.js";
38
34
  import { getValueFromObjectByKey } from "./function/getValue.js";
39
35
  import { runFunction } from "./function/run.js";
40
36
  import { mergeWith } from "./merge/mergeWith.js";
41
- import { useDeepMerge } from "./merge/useDeepMege.js";
37
+ import { useDeepMerge } from "./merge/deepCloneMerge.js";
42
38
  import { deepMerge, merge } from "./merge/index.js";
43
39
  import { toChinesNum } from "./number/chinese.js";
44
40
  import { formatNumber, toConvertNumberShow } from "./number/format.js";
45
- import "./number/index.js";
46
- import classNames_default from "./object/classNames.js";
41
+ import classNames from "./object/classNames.js";
47
42
  import { omitBoolean } from "./object/omitBoolean.js";
48
43
  import { omitUndefined } from "./object/omitUndefined.js";
49
44
  import { omitUndefinedAndEmptyArr } from "./object/omitUndefinedAndEmptyArr.js";
50
- import "./object/index.js";
45
+ import { filterEmpty, getKeys, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, isEmptyElement, slotRender } from "./slots/index.js";
51
46
  import { formatDuration } from "./string/duration.js";
52
47
  import { handleEmptyField } from "./string/empty.js";
53
48
  import { nanoid } from "./string/nanoid.js";
54
- import { getRandomNumber } from "./string/uuid.js";
49
+ import { createUUIDFactory } from "./string/uuid.js";
55
50
  import { genColumnKey, handleShowIndex } from "./table/column.js";
56
51
  import { handleCurrentPage } from "./table/page.js";
57
- import "./table/index.js";
58
- import { filterEmpty, getKeys, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, isEmptyElement, slotRender } from "./vue/slots.js";
59
- import "./vue/index.js";
60
-
61
- export { arraySlice, arrayUnique, blobToDataURL, checkFileType, classNames_default as classNames, cloneDeep, cloneDeepWith, cloneDeepWithImpl, compareArray, compareArraySort, compareArrayTimeSort, compareTime, convertValueBoolean, copyProperties, dataURLtoBlob, dataURLtoFile, deepCopy, deepMerge, easeInOutCubic, fileTypes, filterEmpty, filterTree, findSourceByTree, findValueAndAncestors, forInObject, formatDuration, formatNumber, genColumnKey, generateVideoPicture, getArrayLast, getBase64, getBlobUrl, getFileSuffix, getKeys, getLevelData, getMaxFloor, getMediaInfos, getPrefixCls, getRandomNumber, getScroll, getScrollContainer, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, getSortIndex, getSymbols, getTextWidth, getValueFromObjectByKey, getVideoCoverPicture, getVideoFileUrl, handleCurrentPage, handleEmptyField, handleShowIndex, is, isArray, isBase64, isBoolean, isBrowser, isDataURLBase64, isDeepEqualReact, isEmptyElement, isEqual, isFunction, isImg, isInContainer, isJSONStr, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isScroll, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindow, isWindowsOs, keysOf, merge, mergeWith, nanoid, off, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr, on, wrapperRaf as raf, runFunction, scrollTo, slotRender, toChinesNum, toConvertNumberShow, treeData, useDeepMerge };
52
+ export { Base64, arraySlice, arrayUnique, arrayUniqueBy, blobToDataURL, blobToFile, checkFileType, classNames, cloneDeep, cloneDeepWith, cloneDeepWithImpl, compareArray, compareArraySort, compareArrayTimeSort, compareTime, convertValueBoolean, copyProperties, createUUIDFactory, dataURLtoBlob, dataURLtoFile, deepCopy, deepMerge, easeInOutCubic, fileTypes, filterEmpty, filterTree, findSourceByTree, findValueAndAncestors, forInObject, formatDuration, formatNumber, genColumnKey, generateVideoPicture, getArrayLast, getBase64, getBlobUrl, getFileSuffix, getKeys, getLevelData, getMaxFloor, getMediaInfos, getPrefixCls, getScroll, getScrollContainer, getSlot, getSlotVNode, getSlotsChildren, getSlotsProps, getSortIndex, getSymbols, getTextWidth, getValueFromObjectByKey, getVideoCoverPicture, getVideoFileUrl, handleCurrentPage, handleEmptyField, handleShowIndex, is, isArray, isBoolean, isBrowser, isDataURLBase64, isDeepEqual, isDeepEqualReact, isEmptyElement, isEqual, isFunction, isImg, isInContainer, isJSONStr, isMediaDataURI, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isScroll, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindow, isWindowsOs, keysOf, merge, mergeWith, nanoid, off, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr, on, wrapperRaf as raf, runFunction, scrollTo, slotRender, toChinesNum, toConvertNumberShow, treeData, useDeepMerge };
@@ -1,11 +1,14 @@
1
1
  //#region src/is/base64.d.ts
2
2
  /**
3
- * 判断是否为 base64 编码的字符串
3
+ * 判断是否为媒体类型(image/video/audio)的 Data URL(data URI)
4
+ *
5
+ * 仅检测媒体类型 Data URL 的前缀(`data:image/`、`data:video/`、`data:audio/`),
6
+ * 不校验 Base64 编码内容。如需校验完整 Base64 编码,请使用 {@link isDataURLBase64}。
4
7
  *
5
8
  * @param str - 要判断的字符串
6
- * @returns 是否为 base64 编码
9
+ * @returns 是否为媒体类型 Data URL
7
10
  */
8
- declare function isBase64(str?: string): boolean;
11
+ declare function isMediaDataURI(str?: any): boolean;
9
12
  /**
10
13
  * 判断是否为 Data URL 格式的 base64 字符串
11
14
  *
@@ -14,4 +17,4 @@ declare function isBase64(str?: string): boolean;
14
17
  */
15
18
  declare function isDataURLBase64(str: string): boolean;
16
19
  //#endregion
17
- export { isBase64, isDataURLBase64 };
20
+ export { isDataURLBase64, isMediaDataURI };
package/dist/is/base64.js CHANGED
@@ -1,16 +1,20 @@
1
1
  //#region src/is/base64.ts
2
2
  /**
3
- * 判断是否为 base64 编码的字符串
3
+ * 判断是否为媒体类型(image/video/audio)的 Data URL(data URI)
4
+ *
5
+ * 仅检测媒体类型 Data URL 的前缀(`data:image/`、`data:video/`、`data:audio/`),
6
+ * 不校验 Base64 编码内容。如需校验完整 Base64 编码,请使用 {@link isDataURLBase64}。
4
7
  *
5
8
  * @param str - 要判断的字符串
6
- * @returns 是否为 base64 编码
9
+ * @returns 是否为媒体类型 Data URL
7
10
  */
8
- function isBase64(str = "") {
11
+ function isMediaDataURI(str = "") {
12
+ if (typeof str !== "string") return false;
9
13
  if (str && [
10
14
  "data:image/",
11
15
  "data:video/",
12
16
  "data:audio/"
13
- ].find((item) => str.includes(item))) return true;
17
+ ].some((item) => str.includes(item))) return true;
14
18
  return false;
15
19
  }
16
20
  /**
@@ -22,6 +26,5 @@ function isBase64(str = "") {
22
26
  function isDataURLBase64(str) {
23
27
  return typeof str === "string" && /^data:(?:image|video|audio)\/[A-Za-z]+;base64,[A-Za-z0-9+/=]+$/.test(str);
24
28
  }
25
-
26
29
  //#endregion
27
- export { isBase64, isDataURLBase64 };
30
+ export { isDataURLBase64, isMediaDataURI };
@@ -1,5 +1,4 @@
1
1
  //#region src/is/browser.ts
2
- const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
3
2
  /**
4
3
  * 检查是否为浏览器环境
5
4
  *
@@ -7,8 +6,8 @@ const isNode = typeof process !== "undefined" && process.versions != null && pro
7
6
  */
8
7
  function isBrowser() {
9
8
  if (process.env.NODE_ENV === "TEST") return true;
9
+ const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
10
10
  return typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.matchMedia !== "undefined" && !isNode;
11
11
  }
12
-
13
12
  //#endregion
14
- export { isBrowser };
13
+ export { isBrowser };
@@ -1,13 +1,19 @@
1
1
  //#region src/is/deepEqual.d.ts
2
2
  /**
3
- * React 深度比较
3
+ * 深度比较两个值是否相等
4
+ *
5
+ * 支持数组、Map、Set、TypedArray、RegExp 及普通对象的递归比较。
4
6
  *
5
7
  * @param a - 第一个值
6
8
  * @param b - 第二个值
7
9
  * @param ignoreKeys - 忽略的键
8
- * @param debug - 是否调试
10
+ * @param debug - 是否调试(打印首个不相等的键)
9
11
  * @returns 是否相等
10
12
  */
11
- declare function isDeepEqualReact(a: any, b: any, ignoreKeys?: string[], debug?: boolean): boolean;
13
+ declare function isDeepEqual(a: any, b: any, ignoreKeys?: string[], debug?: boolean): boolean;
14
+ /**
15
+ * @deprecated 请使用 isDeepEqual,该名称为历史遗留(早期移植自 React 实现)
16
+ */
17
+ declare const isDeepEqualReact: typeof isDeepEqual;
12
18
  //#endregion
13
- export { isDeepEqualReact };
19
+ export { isDeepEqual, isDeepEqualReact };