module-develop-kit 1.1.0 → 1.2.1

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 (45) hide show
  1. package/dist/commonjs-virtual-dir/browser.js +5 -2
  2. package/dist/commonjs-virtual-dir/browser2.js +4 -0
  3. package/dist/commonjs-virtual-dir/index2.js +5 -3
  4. package/dist/commonjs-virtual-dir/index3.js +3 -5
  5. package/dist/commonjs-virtual-dir/index4.js +2 -4
  6. package/dist/commonjs-virtual-dir/index5.js +2 -2
  7. package/dist/commonjs-virtual-dir/index6.js +2 -2
  8. package/dist/commonjs-virtual-dir/index7.js +4 -0
  9. package/dist/commonjs-virtual-dir/index8.js +4 -0
  10. package/dist/main.d.ts +140 -29
  11. package/dist/main.js +34 -22
  12. package/dist/src/outside-call/utils.js +1 -1
  13. package/dist/src/shield/crypto/sm4.js +1 -1
  14. package/dist/src/shield/file-detection.js +143 -0
  15. package/dist/vendor/@borewit/text-codec/lib/index.js +181 -0
  16. package/dist/vendor/@tokenizer/inflate/lib/GzipHandler.js +21 -0
  17. package/dist/vendor/@tokenizer/inflate/lib/ZipHandler.js +156 -0
  18. package/dist/vendor/@tokenizer/inflate/lib/ZipToken.js +71 -0
  19. package/dist/vendor/base64-js/index.js +1 -1
  20. package/dist/vendor/debug/src/browser.js +1 -1
  21. package/dist/vendor/file-type/source/detectors/asf.js +74 -0
  22. package/dist/vendor/file-type/source/detectors/ebml.js +61 -0
  23. package/dist/vendor/file-type/source/detectors/png.js +64 -0
  24. package/dist/vendor/file-type/source/detectors/zip.js +344 -0
  25. package/dist/vendor/file-type/source/index.js +1135 -0
  26. package/dist/vendor/file-type/source/parser.js +49 -0
  27. package/dist/vendor/file-type/source/supported.js +372 -0
  28. package/dist/vendor/file-type/source/tokens.js +40 -0
  29. package/dist/vendor/ieee754/index.js +30 -0
  30. package/dist/vendor/jsbn/index.js +1 -1
  31. package/dist/vendor/sdp-transform/lib/index.js +1 -1
  32. package/dist/vendor/strtok3/lib/AbstractTokenizer.js +92 -0
  33. package/dist/vendor/strtok3/lib/BlobTokenizer.js +48 -0
  34. package/dist/vendor/strtok3/lib/BufferTokenizer.js +47 -0
  35. package/dist/vendor/strtok3/lib/ReadStreamTokenizer.js +91 -0
  36. package/dist/vendor/strtok3/lib/core.js +22 -0
  37. package/dist/vendor/strtok3/lib/stream/AbstractStreamReader.js +51 -0
  38. package/dist/vendor/strtok3/lib/stream/Errors.js +16 -0
  39. package/dist/vendor/strtok3/lib/stream/WebStreamByobReader.js +18 -0
  40. package/dist/vendor/strtok3/lib/stream/WebStreamDefaultReader.js +45 -0
  41. package/dist/vendor/strtok3/lib/stream/WebStreamReader.js +15 -0
  42. package/dist/vendor/strtok3/lib/stream/WebStreamReaderFactory.js +15 -0
  43. package/dist/vendor/token-types/lib/index.js +81 -0
  44. package/dist/vendor/uint8array-extras/index.js +45 -0
  45. package/package.json +2 -1
@@ -0,0 +1,91 @@
1
+ import { AbstractTokenizer as o } from "./AbstractTokenizer.js";
2
+ import { EndOfStreamError as a } from "./stream/Errors.js";
3
+ const f = 256e3;
4
+ class u extends o {
5
+ /**
6
+ * Constructor
7
+ * @param streamReader stream-reader to read from
8
+ * @param options Tokenizer options
9
+ */
10
+ constructor(t, n) {
11
+ super(n), this.streamReader = t, this.fileInfo = n?.fileInfo ?? {};
12
+ }
13
+ /**
14
+ * Read buffer from tokenizer
15
+ * @param uint8Array - Target Uint8Array to fill with data read from the tokenizer-stream
16
+ * @param options - Read behaviour options
17
+ * @returns Promise with number of bytes read
18
+ */
19
+ async readBuffer(t, n) {
20
+ const e = this.normalizeOptions(t, n), r = e.position - this.position;
21
+ if (r > 0)
22
+ return await this.ignore(r), this.readBuffer(t, n);
23
+ if (r < 0)
24
+ throw new Error("`options.position` must be equal or greater than `tokenizer.position`");
25
+ if (e.length === 0)
26
+ return 0;
27
+ const s = await this.streamReader.read(t.subarray(0, e.length), e.mayBeLess);
28
+ if (this.position += s, (!n || !n.mayBeLess) && s < e.length)
29
+ throw new a();
30
+ return s;
31
+ }
32
+ /**
33
+ * Peek (read ahead) buffer from tokenizer
34
+ * @param uint8Array - Uint8Array (or Buffer) to write data to
35
+ * @param options - Read behaviour options
36
+ * @returns Promise with number of bytes peeked
37
+ */
38
+ async peekBuffer(t, n) {
39
+ const e = this.normalizeOptions(t, n);
40
+ let r = 0;
41
+ if (e.position) {
42
+ const s = e.position - this.position;
43
+ if (s > 0) {
44
+ const i = new Uint8Array(e.length + s);
45
+ return r = await this.peekBuffer(i, { mayBeLess: e.mayBeLess }), t.set(i.subarray(s)), r - s;
46
+ }
47
+ if (s < 0)
48
+ throw new Error("Cannot peek from a negative offset in a stream");
49
+ }
50
+ if (e.length > 0) {
51
+ try {
52
+ r = await this.streamReader.peek(t.subarray(0, e.length), e.mayBeLess);
53
+ } catch (s) {
54
+ if (n?.mayBeLess && s instanceof a)
55
+ return 0;
56
+ throw s;
57
+ }
58
+ if (!e.mayBeLess && r < e.length)
59
+ throw new a();
60
+ }
61
+ return r;
62
+ }
63
+ /**
64
+ * @param length Number of bytes to ignore. Must be ≥ 0.
65
+ */
66
+ async ignore(t) {
67
+ if (t < 0)
68
+ throw new RangeError("ignore length must be ≥ 0 bytes");
69
+ const n = Math.min(f, t), e = new Uint8Array(n);
70
+ let r = 0;
71
+ for (; r < t; ) {
72
+ const s = t - r, i = await this.readBuffer(e, { length: Math.min(n, s) });
73
+ if (i < 0)
74
+ return i;
75
+ r += i;
76
+ }
77
+ return r;
78
+ }
79
+ abort() {
80
+ return this.streamReader.abort();
81
+ }
82
+ async close() {
83
+ return this.streamReader.close();
84
+ }
85
+ supportsRandomAccess() {
86
+ return !1;
87
+ }
88
+ }
89
+ export {
90
+ u as ReadStreamTokenizer
91
+ };
@@ -0,0 +1,22 @@
1
+ import { makeWebStreamReader as m } from "./stream/WebStreamReaderFactory.js";
2
+ import { ReadStreamTokenizer as f } from "./ReadStreamTokenizer.js";
3
+ import { BufferTokenizer as i } from "./BufferTokenizer.js";
4
+ import { BlobTokenizer as a } from "./BlobTokenizer.js";
5
+ function p(e, o) {
6
+ const n = m(e), r = o ?? {}, t = r.onClose;
7
+ return r.onClose = async () => {
8
+ if (await n.close(), t)
9
+ return t();
10
+ }, new f(n, r);
11
+ }
12
+ function b(e, o) {
13
+ return new i(e, o);
14
+ }
15
+ function w(e, o) {
16
+ return new a(e, o);
17
+ }
18
+ export {
19
+ w as fromBlob,
20
+ b as fromBuffer,
21
+ p as fromWebStream
22
+ };
@@ -0,0 +1,51 @@
1
+ import { EndOfStreamError as s, AbortError as i } from "./Errors.js";
2
+ class d {
3
+ constructor() {
4
+ this.endOfStream = !1, this.interrupted = !1, this.peekQueue = [];
5
+ }
6
+ async peek(t, r = !1) {
7
+ const e = await this.read(t, r);
8
+ return this.peekQueue.push(t.subarray(0, e)), e;
9
+ }
10
+ async read(t, r = !1) {
11
+ if (t.length === 0)
12
+ return 0;
13
+ let e = this.readFromPeekBuffer(t);
14
+ if (this.endOfStream || (e += await this.readRemainderFromStream(t.subarray(e), r)), e === 0 && !r)
15
+ throw new s();
16
+ return e;
17
+ }
18
+ /**
19
+ * Read chunk from stream
20
+ * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
21
+ * @returns Number of bytes read
22
+ */
23
+ readFromPeekBuffer(t) {
24
+ let r = t.length, e = 0;
25
+ for (; this.peekQueue.length > 0 && r > 0; ) {
26
+ const a = this.peekQueue.pop();
27
+ if (!a)
28
+ throw new Error("peekData should be defined");
29
+ const n = Math.min(a.length, r);
30
+ t.set(a.subarray(0, n), e), e += n, r -= n, n < a.length && this.peekQueue.push(a.subarray(n));
31
+ }
32
+ return e;
33
+ }
34
+ async readRemainderFromStream(t, r) {
35
+ let e = 0;
36
+ for (; e < t.length && !this.endOfStream; ) {
37
+ if (this.interrupted)
38
+ throw new i();
39
+ const a = await this.readFromStream(t.subarray(e), r);
40
+ if (a === 0)
41
+ break;
42
+ e += a;
43
+ }
44
+ if (!r && e < t.length)
45
+ throw new s();
46
+ return e;
47
+ }
48
+ }
49
+ export {
50
+ d as AbstractStreamReader
51
+ };
@@ -0,0 +1,16 @@
1
+ const t = "End-Of-Stream";
2
+ class o extends Error {
3
+ constructor() {
4
+ super(t), this.name = "EndOfStreamError";
5
+ }
6
+ }
7
+ class s extends Error {
8
+ constructor(e = "The operation was aborted") {
9
+ super(e), this.name = "AbortError";
10
+ }
11
+ }
12
+ export {
13
+ s as AbortError,
14
+ o as EndOfStreamError,
15
+ t as defaultMessages
16
+ };
@@ -0,0 +1,18 @@
1
+ import { WebStreamReader as n } from "./WebStreamReader.js";
2
+ class i extends n {
3
+ /**
4
+ * Read from stream
5
+ * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
6
+ * @param mayBeLess - If true, may fill the buffer partially
7
+ * @protected Bytes read
8
+ */
9
+ async readFromStream(t, r) {
10
+ if (t.length === 0)
11
+ return 0;
12
+ const e = await this.reader.read(new Uint8Array(t.length), { min: r ? void 0 : t.length });
13
+ return e.done && (this.endOfStream = e.done), e.value ? (t.set(e.value), e.value.length) : 0;
14
+ }
15
+ }
16
+ export {
17
+ i as WebStreamByobReader
18
+ };
@@ -0,0 +1,45 @@
1
+ import { EndOfStreamError as s } from "./Errors.js";
2
+ import { AbstractStreamReader as i } from "./AbstractStreamReader.js";
3
+ class u extends i {
4
+ constructor(t) {
5
+ super(), this.reader = t, this.buffer = null;
6
+ }
7
+ /**
8
+ * Copy chunk to target, and store the remainder in this.buffer
9
+ */
10
+ writeChunk(t, r) {
11
+ const e = Math.min(r.length, t.length);
12
+ return t.set(r.subarray(0, e)), e < r.length ? this.buffer = r.subarray(e) : this.buffer = null, e;
13
+ }
14
+ /**
15
+ * Read from stream
16
+ * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
17
+ * @param mayBeLess - If true, may fill the buffer partially
18
+ * @protected Bytes read
19
+ */
20
+ async readFromStream(t, r) {
21
+ if (t.length === 0)
22
+ return 0;
23
+ let e = 0;
24
+ for (this.buffer && (e += this.writeChunk(t, this.buffer)); e < t.length && !this.endOfStream; ) {
25
+ const a = await this.reader.read();
26
+ if (a.done) {
27
+ this.endOfStream = !0;
28
+ break;
29
+ }
30
+ a.value && (e += this.writeChunk(t.subarray(e), a.value));
31
+ }
32
+ if (!r && e === 0 && this.endOfStream)
33
+ throw new s();
34
+ return e;
35
+ }
36
+ abort() {
37
+ return this.interrupted = !0, this.reader.cancel();
38
+ }
39
+ async close() {
40
+ await this.abort(), this.reader.releaseLock();
41
+ }
42
+ }
43
+ export {
44
+ u as WebStreamDefaultReader
45
+ };
@@ -0,0 +1,15 @@
1
+ import { AbstractStreamReader as r } from "./AbstractStreamReader.js";
2
+ class a extends r {
3
+ constructor(e) {
4
+ super(), this.reader = e;
5
+ }
6
+ async abort() {
7
+ return this.close();
8
+ }
9
+ async close() {
10
+ this.reader.releaseLock();
11
+ }
12
+ }
13
+ export {
14
+ a as WebStreamReader
15
+ };
@@ -0,0 +1,15 @@
1
+ import { WebStreamByobReader as a } from "./WebStreamByobReader.js";
2
+ import { WebStreamDefaultReader as t } from "./WebStreamDefaultReader.js";
3
+ function d(r) {
4
+ try {
5
+ const e = r.getReader({ mode: "byob" });
6
+ return e instanceof ReadableStreamDefaultReader ? new t(e) : new a(e);
7
+ } catch (e) {
8
+ if (e instanceof TypeError)
9
+ return new t(r.getReader());
10
+ throw e;
11
+ }
12
+ }
13
+ export {
14
+ d as makeWebStreamReader
15
+ };
@@ -0,0 +1,81 @@
1
+ import "../../../commonjs-virtual-dir/index4.js";
2
+ import { textDecode as i } from "../../@borewit/text-codec/lib/index.js";
3
+ function r(e) {
4
+ return new DataView(e.buffer, e.byteOffset);
5
+ }
6
+ const s = {
7
+ len: 1,
8
+ get(e, t) {
9
+ return r(e).getUint8(t);
10
+ },
11
+ put(e, t, n) {
12
+ return r(e).setUint8(t, n), t + 1;
13
+ }
14
+ }, c = {
15
+ len: 2,
16
+ get(e, t) {
17
+ return r(e).getUint16(t, !0);
18
+ },
19
+ put(e, t, n) {
20
+ return r(e).setUint16(t, n, !0), t + 2;
21
+ }
22
+ }, p = {
23
+ len: 2,
24
+ get(e, t) {
25
+ return r(e).getUint16(t);
26
+ },
27
+ put(e, t, n) {
28
+ return r(e).setUint16(t, n), t + 2;
29
+ }
30
+ }, l = {
31
+ len: 4,
32
+ get(e, t) {
33
+ return r(e).getUint32(t, !0);
34
+ },
35
+ put(e, t, n) {
36
+ return r(e).setUint32(t, n, !0), t + 4;
37
+ }
38
+ }, o = {
39
+ len: 4,
40
+ get(e, t) {
41
+ return r(e).getUint32(t);
42
+ },
43
+ put(e, t, n) {
44
+ return r(e).setUint32(t, n), t + 4;
45
+ }
46
+ }, I = {
47
+ len: 4,
48
+ get(e, t) {
49
+ return r(e).getInt32(t);
50
+ },
51
+ put(e, t, n) {
52
+ return r(e).setInt32(t, n), t + 4;
53
+ }
54
+ }, T = {
55
+ len: 8,
56
+ get(e, t) {
57
+ return r(e).getBigUint64(t, !0);
58
+ },
59
+ put(e, t, n) {
60
+ return r(e).setBigUint64(t, n, !0), t + 8;
61
+ }
62
+ };
63
+ class N {
64
+ constructor(t, n) {
65
+ this.len = t, this.encoding = n;
66
+ }
67
+ get(t, n = 0) {
68
+ const u = t.subarray(n, n + this.len);
69
+ return i(u, this.encoding);
70
+ }
71
+ }
72
+ export {
73
+ I as INT32_BE,
74
+ N as StringType,
75
+ p as UINT16_BE,
76
+ c as UINT16_LE,
77
+ o as UINT32_BE,
78
+ l as UINT32_LE,
79
+ T as UINT64_LE,
80
+ s as UINT8
81
+ };
@@ -0,0 +1,45 @@
1
+ const f = Object.prototype.toString, c = "[object Uint8Array]";
2
+ function u(t, r, e) {
3
+ return t ? t.constructor === r ? !0 : f.call(t) === e : !1;
4
+ }
5
+ function g(t) {
6
+ return u(t, Uint8Array, c);
7
+ }
8
+ function U(t) {
9
+ if (!g(t))
10
+ throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof t}\``);
11
+ }
12
+ function s(t, r) {
13
+ if (t.length === 0)
14
+ return new Uint8Array(0);
15
+ r ??= t.reduce((n, o) => n + o.length, 0);
16
+ const e = new Uint8Array(r);
17
+ let i = 0;
18
+ for (const n of t)
19
+ U(n), e.set(n, i), i += n.length;
20
+ return e;
21
+ }
22
+ new globalThis.TextDecoder("utf8");
23
+ new globalThis.TextEncoder();
24
+ Array.from({ length: 256 }, (t, r) => r.toString(16).padStart(2, "0"));
25
+ function y(t) {
26
+ const { byteLength: r } = t;
27
+ if (r === 6)
28
+ return t.getUint16(0) * 2 ** 32 + t.getUint32(2);
29
+ if (r === 5)
30
+ return t.getUint8(0) * 2 ** 32 + t.getUint32(1);
31
+ if (r === 4)
32
+ return t.getUint32(0);
33
+ if (r === 3)
34
+ return t.getUint8(0) * 2 ** 16 + t.getUint16(1);
35
+ if (r === 2)
36
+ return t.getUint16(0);
37
+ if (r === 1)
38
+ return t.getUint8(0);
39
+ }
40
+ export {
41
+ U as assertUint8Array,
42
+ s as concatUint8Arrays,
43
+ y as getUintBE,
44
+ g as isUint8Array
45
+ };
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.1.0",
4
+ "version": "1.2.1",
5
5
  "type": "module",
6
6
  "description": "前端项目通用工具包",
7
7
  "module": "dist/main.js",
@@ -59,6 +59,7 @@
59
59
  "vue-tsc": "^3.0.7"
60
60
  },
61
61
  "dependencies": {
62
+ "file-type": "^22.0.1",
62
63
  "gm-crypt": "^0.0.2",
63
64
  "jssip": "^3.10.1",
64
65
  "sm-crypto": "^0.3.13"