module-develop-kit 1.2.1 → 1.2.3

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.
@@ -1,7 +1,4 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
- import { __require as e } from "../vendor/debug/src/browser.js";
3
- var o = e();
4
- const i = /* @__PURE__ */ r(o);
1
+ var r = { exports: {} };
5
2
  export {
6
- i as default
3
+ r as __module
7
4
  };
@@ -1,4 +1,7 @@
1
- var r = { exports: {} };
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as e } from "../vendor/debug/src/browser.js";
3
+ var o = e();
4
+ const i = /* @__PURE__ */ r(o);
2
5
  export {
3
- r as __module
6
+ i as default
4
7
  };
package/dist/main.d.ts CHANGED
@@ -2,6 +2,12 @@ import { Ref } from 'vue';
2
2
  import { supportedExtensions } from 'file-type';
3
3
  import { supportedMimeTypes } from 'file-type';
4
4
 
5
+ /**
6
+ * 支持的文件 MIME 类型配置
7
+ * 从 file-type 库导出,可用于UI展示或额外验证
8
+ */
9
+ export declare const ALLOWED_FILE_MIMES: string[];
10
+
5
11
  /**
6
12
  * 支持的文件类型配置
7
13
  * 基于 file-type 库的 supportedMimeTypes 动态生成
@@ -51,9 +57,8 @@ export declare function detectFileByExtension(file: File, _allowedExtensions: TM
51
57
 
52
58
  /**
53
59
  * 检测文件真实类型并验证 MIME 类型
54
- *
55
60
  * @param file 要检测的文件
56
- * @param _allowedMimes 允许的MIME类型列表 支持单个或者数组。单个支持使用,分割
61
+ * @param _allowedMimes 允许的MIME类型列表 支持单个或者数组。单个支持使用,分割,支持通配符
57
62
  * @param options 检测选项
58
63
  * @returns 检测结果
59
64
  */
@@ -334,8 +339,15 @@ export declare function isUrlSafe(url: unknown, options?: IUrlSanitizeOptions):
334
339
  */
335
340
  export declare function isValidDocument(file: File, maxSize?: number): Promise<IFileDetectionResult>;
336
341
 
342
+ /**
343
+ * 便捷方法: 检测是否为常规支持的文件类型(基于 MIME 类型)
344
+ */
345
+ export declare function isValidFile(file: File, maxSize?: number): Promise<IFileDetectionResult>;
346
+
337
347
  /**
338
348
  * 便捷方法: 检测是否为图片文件(基于 MIME 类型)
349
+ * @file 要检测的文件
350
+ * @maxSize 文件最大尺寸
339
351
  */
340
352
  export declare function isValidImage(file: File, maxSize?: number): Promise<IFileDetectionResult>;
341
353
 
@@ -365,7 +377,7 @@ export declare interface IUrlSanitizeOptions {
365
377
  */
366
378
  fallbackUrl?: string;
367
379
  /**
368
- * 是否严格模式,严格模式下只允许 http/https,默认 false
380
+ * 是否严格模式,严格模式下只允许 http/https,默认 true
369
381
  */
370
382
  strictMode?: boolean;
371
383
  }
package/dist/main.js CHANGED
@@ -1,37 +1,39 @@
1
1
  import { useCall as o } from "./src/outside-call/index.js";
2
- import { antiReplyAttackStrategy as i, requestDataEncryption as s, responseDataEncryption as a } from "./src/shield/crypto/index.js";
3
- import { ALLOWED_FILE_TYPES as p, detectFileByExtension as E, detectFileByMime as l, detectionFilesByExtension as m, detectionFilesByMime as x, isValidDocument as f, isValidImage as S, isValidVideo as d } from "./src/shield/file-detection.js";
4
- import { htmlSanitize as c } from "./src/shield/html-sanitize.js";
5
- import { startNoDebugger as _ } from "./src/shield/no-debugger.js";
6
- import { isUrlSafe as D, sanitizeUrl as M, sanitizeUrls as A } from "./src/shield/url-sanitize.js";
7
- import { EventBus as C } from "./src/utils/eventBus.js";
8
- import { CallLogger as I } from "./src/outside-call/utils.js";
9
- import { ECallStatus as L, EMIT_EVENT_NAME as R, SIP_CODE_MESSAGE as T, SIP_ERROR_CAUSES as U } from "./src/outside-call/constants.js";
10
- import { supportedExtensions as N, supportedMimeTypes as O } from "./vendor/file-type/source/index.js";
2
+ import { antiReplyAttackStrategy as i, requestDataEncryption as s, responseDataEncryption as E } from "./src/shield/crypto/index.js";
3
+ import { ALLOWED_FILE_MIMES as l, ALLOWED_FILE_TYPES as n, detectFileByExtension as p, detectFileByMime as m, detectionFilesByExtension as x, detectionFilesByMime as S, isValidDocument as d, isValidFile as f, isValidImage as _, isValidVideo as y } from "./src/shield/file-detection.js";
4
+ import { htmlSanitize as u } from "./src/shield/html-sanitize.js";
5
+ import { startNoDebugger as D } from "./src/shield/no-debugger.js";
6
+ import { isUrlSafe as I, sanitizeUrl as L, sanitizeUrls as g } from "./src/shield/url-sanitize.js";
7
+ import { EventBus as V } from "./src/utils/eventBus.js";
8
+ import { CallLogger as C } from "./src/outside-call/utils.js";
9
+ import { ECallStatus as R, EMIT_EVENT_NAME as T, SIP_CODE_MESSAGE as U, SIP_ERROR_CAUSES as z } from "./src/outside-call/constants.js";
10
+ import { supportedExtensions as P, supportedMimeTypes as W } from "./vendor/file-type/source/index.js";
11
11
  export {
12
- p as ALLOWED_FILE_TYPES,
13
- I as CallLogger,
14
- L as ECallStatus,
15
- R as EMIT_EVENT_NAME,
16
- C as EventBus,
17
- T as SIP_CODE_MESSAGE,
18
- U as SIP_ERROR_CAUSES,
12
+ l as ALLOWED_FILE_MIMES,
13
+ n as ALLOWED_FILE_TYPES,
14
+ C as CallLogger,
15
+ R as ECallStatus,
16
+ T as EMIT_EVENT_NAME,
17
+ V as EventBus,
18
+ U as SIP_CODE_MESSAGE,
19
+ z as SIP_ERROR_CAUSES,
19
20
  i as antiReplyAttackStrategy,
20
- E as detectFileByExtension,
21
- l as detectFileByMime,
22
- m as detectionFilesByExtension,
23
- x as detectionFilesByMime,
24
- c as htmlSanitize,
25
- D as isUrlSafe,
26
- f as isValidDocument,
27
- S as isValidImage,
28
- d as isValidVideo,
21
+ p as detectFileByExtension,
22
+ m as detectFileByMime,
23
+ x as detectionFilesByExtension,
24
+ S as detectionFilesByMime,
25
+ u as htmlSanitize,
26
+ I as isUrlSafe,
27
+ d as isValidDocument,
28
+ f as isValidFile,
29
+ _ as isValidImage,
30
+ y as isValidVideo,
29
31
  s as requestDataEncryption,
30
- a as responseDataEncryption,
31
- M as sanitizeUrl,
32
- A as sanitizeUrls,
33
- _ as startNoDebugger,
34
- N as supportedExtensions,
35
- O as supportedMimeTypes,
32
+ E as responseDataEncryption,
33
+ L as sanitizeUrl,
34
+ g as sanitizeUrls,
35
+ D as startNoDebugger,
36
+ P as supportedExtensions,
37
+ W as supportedMimeTypes,
36
38
  o as useCall
37
39
  };
@@ -1,19 +1,20 @@
1
- import { supportedMimeTypes as l, fileTypeFromStream as y } from "../../vendor/file-type/source/index.js";
2
- import { supportedExtensions as z } from "../../vendor/file-type/source/index.js";
1
+ import { supportedMimeTypes as f, fileTypeFromStream as y } from "../../vendor/file-type/source/index.js";
2
+ import { supportedExtensions as L } from "../../vendor/file-type/source/index.js";
3
3
  function d(e) {
4
4
  const t = /* @__PURE__ */ new Set();
5
- for (const r of l)
6
- r.startsWith(`${e}/`) && t.add(r);
5
+ for (const i of f)
6
+ i.startsWith(`${e}/`) && t.add(i);
7
7
  return t;
8
8
  }
9
- const f = {
9
+ const l = {
10
10
  // 图片类型 - 从 supportedMimeTypes 中过滤 image/*
11
11
  image: d("image"),
12
12
  // 文档类型 - 包含常见办公文档
13
13
  document: /* @__PURE__ */ new Set([
14
- ...Array.from(l).filter(
15
- (e) => e.includes("pdf") || e.includes("msword") || e.includes("officedocument") || e.includes("ms-excel") || e.includes("ms-powerpoint") || e.includes("opendocument") || e === "text/plain"
16
- )
14
+ ...Array.from(f).filter((e) => {
15
+ const t = e.includes("pdf") || e.includes("msword") || e.includes("officedocument") || e.includes("ms-excel") || e.includes("ms-powerpoint") || e.includes("opendocument") || e === "text/plain", i = e.includes("macroenabled");
16
+ return t && !i;
17
+ })
17
18
  ]),
18
19
  // 视频类型 - 从 supportedMimeTypes 中过滤 video/*
19
20
  video: d("video"),
@@ -21,7 +22,7 @@ const f = {
21
22
  audio: d("audio"),
22
23
  // 压缩文件
23
24
  archive: /* @__PURE__ */ new Set([
24
- ...Array.from(l).filter(
25
+ ...Array.from(f).filter(
25
26
  (e) => e.includes("zip") || e.includes("rar") || e.includes("7z") || e.includes("tar") || e.includes("gzip") || e.includes("compress")
26
27
  )
27
28
  ]),
@@ -29,37 +30,37 @@ const f = {
29
30
  font: d("font"),
30
31
  // 模型文件
31
32
  model: d("model")
32
- };
33
- function M(e, t) {
34
- return t.some((r) => {
35
- const i = r.trim();
36
- if (!i)
33
+ }, M = Object.values(l).reduce((e, t) => (e.push(...Array.from(t)), e), []);
34
+ function v(e, t) {
35
+ return t.some((i) => {
36
+ const r = i.trim();
37
+ if (!r)
37
38
  return !1;
38
- if (i === e)
39
+ if (r === e)
39
40
  return !0;
40
- if (i.endsWith("/*")) {
41
- const n = i.slice(0, i.indexOf("/"));
41
+ if (r.endsWith("/*")) {
42
+ const n = r.slice(0, r.indexOf("/"));
42
43
  return e.startsWith(`${n}/`);
43
44
  }
44
45
  return !1;
45
46
  });
46
47
  }
47
48
  async function p(e, t) {
48
- const { maxSize: r } = t;
49
- if (r && e.size > r)
49
+ const { maxSize: i } = t;
50
+ if (i && e.size > i)
50
51
  return {
51
52
  valid: !1,
52
- error: `上传文件大小不能超过 ${(r / 1024 / 1024).toFixed(2)}MB`,
53
+ error: `上传文件大小不能超过 ${(i / 1024 / 1024).toFixed(2)}MB`,
53
54
  claimedMime: e.type
54
55
  };
55
- const i = await y(e.stream());
56
- if (!i)
56
+ const r = await y(e.stream());
57
+ if (!r)
57
58
  return {
58
59
  valid: !1,
59
60
  error: "无法检测文件类型,可能是不支持的格式或文件已损坏",
60
61
  claimedMime: e.type
61
62
  };
62
- const n = i.mime, o = i.ext, c = e.type, s = n === c;
63
+ const n = r.mime, o = r.ext, c = e.type, s = n === c;
63
64
  return !s && c && console.warn("文件MIME类型不匹配", {
64
65
  claimed: c,
65
66
  detected: n,
@@ -71,12 +72,12 @@ async function p(e, t) {
71
72
  mimeMatches: s
72
73
  };
73
74
  }
74
- async function u(e, t, r = {}) {
75
- const i = await p(e, r);
76
- if ("valid" in i && !i.valid)
77
- return i;
78
- const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = i, m = Array.isArray(t) ? t : t.split(",");
79
- return !n || !M(n, m) ? {
75
+ async function a(e, t, i = {}) {
76
+ const r = await p(e, i);
77
+ if ("valid" in r && !r.valid)
78
+ return r;
79
+ const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = r, m = Array.isArray(t) ? t : t.split(",");
80
+ return !n || !v(n, m) ? {
80
81
  valid: !1,
81
82
  error: `不支持的文件类型: ${n || "未知"}`,
82
83
  detectedMime: n,
@@ -91,12 +92,12 @@ async function u(e, t, r = {}) {
91
92
  mimeMatches: s
92
93
  };
93
94
  }
94
- async function v(e, t, r = {}) {
95
- const i = await p(e, r);
96
- if ("valid" in i && !i.valid)
97
- return i;
98
- const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = i, m = Array.isArray(t) ? t : t.split(",").map((a) => a.trim());
99
- return !o || !m.some((a) => o === a || `.${o}` === a) ? {
95
+ async function A(e, t, i = {}) {
96
+ const r = await p(e, i);
97
+ if ("valid" in r && !r.valid)
98
+ return r;
99
+ const { detectedMime: n, detectedExt: o, claimedMime: c, mimeMatches: s } = r, m = Array.isArray(t) ? t : t.split(",").map((u) => u.trim());
100
+ return !o || !m.some((u) => o === u || `.${o}` === u) ? {
100
101
  valid: !1,
101
102
  error: `不支持的文件扩展名: .${o || "未知"}`,
102
103
  detectedMime: n,
@@ -111,33 +112,38 @@ async function v(e, t, r = {}) {
111
112
  mimeMatches: s
112
113
  };
113
114
  }
114
- function A(e, t, r = {}) {
115
- return Promise.all(e.map((i) => u(i, t, r)));
115
+ function x(e, t, i = {}) {
116
+ return Promise.all(e.map((r) => a(r, t, i)));
116
117
  }
117
- function g(e, t, r = {}) {
118
- return Promise.all(e.map((i) => v(i, t, r)));
118
+ function F(e, t, i = {}) {
119
+ return Promise.all(e.map((r) => A(r, t, i)));
119
120
  }
120
- function E(e, t) {
121
- const r = Array.from(f.image);
122
- return u(e, r, { maxSize: t });
121
+ function g(e, t) {
122
+ const i = Array.from(l.image);
123
+ return a(e, i, { maxSize: t });
123
124
  }
124
125
  function w(e, t) {
125
- const r = Array.from(f.document);
126
- return u(e, r, { maxSize: t });
126
+ const i = Array.from(l.document);
127
+ return a(e, i, { maxSize: t });
128
+ }
129
+ function h(e, t) {
130
+ const i = Array.from(l.video);
131
+ return a(e, i, { maxSize: t });
127
132
  }
128
- function F(e, t) {
129
- const r = Array.from(f.video);
130
- return u(e, r, { maxSize: t });
133
+ function S(e, t) {
134
+ return a(e, M, { maxSize: t });
131
135
  }
132
136
  export {
133
- f as ALLOWED_FILE_TYPES,
134
- v as detectFileByExtension,
135
- u as detectFileByMime,
136
- g as detectionFilesByExtension,
137
- A as detectionFilesByMime,
137
+ M as ALLOWED_FILE_MIMES,
138
+ l as ALLOWED_FILE_TYPES,
139
+ A as detectFileByExtension,
140
+ a as detectFileByMime,
141
+ F as detectionFilesByExtension,
142
+ x as detectionFilesByMime,
138
143
  w as isValidDocument,
139
- E as isValidImage,
140
- F as isValidVideo,
141
- z as supportedExtensions,
142
- l as supportedMimeTypes
144
+ S as isValidFile,
145
+ g as isValidImage,
146
+ h as isValidVideo,
147
+ L as supportedExtensions,
148
+ f as supportedMimeTypes
143
149
  };
@@ -1,4 +1,4 @@
1
- const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], o = [
1
+ const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], n = [
2
2
  // eslint-disable-next-line no-script-url
3
3
  "javascript:",
4
4
  "data:",
@@ -7,11 +7,11 @@ const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], o = [
7
7
  "about:",
8
8
  "blob:"
9
9
  ];
10
- function l(t) {
10
+ function c(t) {
11
11
  return t.replace(/[​-‍]/g, "").replace(/\s+/g, "").trim();
12
12
  }
13
- function n(t) {
14
- const e = t.toLowerCase();
13
+ function a(t) {
14
+ const r = t.toLowerCase();
15
15
  return [
16
16
  /javascript:/i,
17
17
  /data:text\/html/i,
@@ -25,35 +25,35 @@ function n(t) {
25
25
  // URL 编码的 javascript
26
26
  /\\u006a\\u0061\\u0076\\u0061/i
27
27
  // Unicode 编码
28
- ].some((s) => s.test(e) || s.test(t));
28
+ ].some((s) => s.test(r) || s.test(t));
29
29
  }
30
- function c(t, e = {}) {
30
+ function l(t, r = {}) {
31
31
  if (!t || typeof t != "string")
32
32
  return !1;
33
- const r = t.trim();
34
- if (!r)
33
+ const e = t.trim();
34
+ if (!e)
35
35
  return !1;
36
- if (r.startsWith("/") || r.startsWith("./") || r.startsWith("../"))
37
- return e.allowRelative === !1 ? !1 : !n(r);
38
- const s = l(r);
39
- if (n(s))
36
+ if (e.startsWith("/") || e.startsWith("./") || e.startsWith("../"))
37
+ return r.allowRelative === !1 ? !1 : !a(e);
38
+ const s = c(e);
39
+ if (a(s))
40
40
  return !1;
41
41
  try {
42
- const a = new URL(s, "http://example.com").protocol.toLowerCase();
43
- return e.strictMode ? a === "http:" || a === "https:" : o.includes(a) ? !1 : [...i, ...e.extraSafeProtocols || []].includes(a);
42
+ const o = new URL(s, "http://example.com").protocol.toLowerCase();
43
+ return r.strictMode ?? !0 ? ["http:", "https:", ...r.extraSafeProtocols || []].includes(o) : n.includes(o) ? !1 : [...i, ...r.extraSafeProtocols || []].includes(o);
44
44
  } catch {
45
45
  return !1;
46
46
  }
47
47
  }
48
- function f(t, e = {}) {
49
- const r = e.fallbackUrl || "#";
50
- return c(t, e) ? t.trim() : r;
48
+ function f(t, r = {}) {
49
+ const e = r.fallbackUrl || "#";
50
+ return l(t, r) ? t.trim() : e;
51
51
  }
52
- function m(t, e = {}) {
53
- return t.map((r) => f(r, e));
52
+ function P(t, r = {}) {
53
+ return t.map((e) => f(e, r));
54
54
  }
55
55
  export {
56
- c as isUrlSafe,
56
+ l as isUrlSafe,
57
57
  f as sanitizeUrl,
58
- m as sanitizeUrls
58
+ P as sanitizeUrls
59
59
  };
@@ -1,5 +1,5 @@
1
1
  import { UINT32_LE as h, StringType as k } from "../../../token-types/lib/index.js";
2
- import D from "../../../../commonjs-virtual-dir/browser.js";
2
+ import D from "../../../../commonjs-virtual-dir/browser2.js";
3
3
  import { Signature as c, EndOfCentralDirectoryRecordToken as L, FileHeader as E, DataDescriptor as y, LocalFileHeaderToken as S } from "./ZipToken.js";
4
4
  function m(s) {
5
5
  const t = new Uint8Array(h.len);
@@ -1,4 +1,4 @@
1
- import { __module as C } from "../../../commonjs-virtual-dir/browser2.js";
1
+ import { __module as C } from "../../../commonjs-virtual-dir/browser.js";
2
2
  import { __require as g } from "./common.js";
3
3
  var F;
4
4
  function p() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "module-develop-kit",
3
3
  "author": "Front-End team",
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "type": "module",
6
6
  "description": "前端项目通用工具包",
7
7
  "module": "dist/main.js",