@fangzhongya/utils 0.0.11 → 0.0.15
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.
- package/dist/basic/array/index.cjs +10 -6
- package/dist/basic/array/index.d.cts +1 -0
- package/dist/basic/array/index.d.ts +1 -0
- package/dist/basic/array/index.js +10 -6
- package/dist/basic/array/sortObj.cjs +7 -0
- package/dist/basic/array/sortObj.d.cts +10 -0
- package/dist/basic/array/sortObj.d.ts +10 -0
- package/dist/basic/array/sortObj.js +7 -0
- package/dist/basic/index.cjs +18 -15
- package/dist/basic/index.d.cts +6 -3
- package/dist/basic/index.d.ts +6 -3
- package/dist/basic/index.js +17 -14
- package/dist/basic/object/index.cjs +14 -8
- package/dist/basic/object/index.d.cts +1 -0
- package/dist/basic/object/index.d.ts +1 -0
- package/dist/basic/object/index.js +13 -7
- package/dist/basic/object/objValue.cjs +9 -0
- package/dist/basic/object/objValue.d.cts +7 -0
- package/dist/basic/object/objValue.d.ts +7 -0
- package/dist/basic/object/objValue.js +9 -0
- package/dist/basic/string/index.cjs +15 -4
- package/dist/basic/string/index.d.cts +1 -0
- package/dist/basic/string/index.d.ts +1 -0
- package/dist/basic/string/index.js +14 -3
- package/dist/basic/string/toFunction.cjs +2 -2
- package/dist/basic/string/toFunction.d.cts +15 -7
- package/dist/basic/string/toFunction.d.ts +15 -7
- package/dist/basic/string/toFunction.js +1 -1
- package/dist/basic/string/toJson.cjs +3 -3
- package/dist/basic/string/toJson.d.cts +2 -5
- package/dist/basic/string/toJson.d.ts +2 -5
- package/dist/basic/string/toJson.js +2 -2
- package/dist/basic/string/toJsons.cjs +15 -0
- package/dist/basic/string/toJsons.d.cts +60 -0
- package/dist/basic/string/toJsons.d.ts +60 -0
- package/dist/basic/string/toJsons.js +15 -0
- package/dist/{chunk-45M6CPWK.cjs → chunk-4VLLDFBC.cjs} +16 -6
- package/dist/chunk-5HC662VK.js +432 -0
- package/dist/{chunk-VQKOHGV5.cjs → chunk-5WOFUMZG.cjs} +8 -4
- package/dist/chunk-754Z5VW6.js +29 -0
- package/dist/chunk-7O4MJOHM.js +142 -0
- package/dist/chunk-E4WBX6J5.cjs +29 -0
- package/dist/chunk-ETMYYVQJ.cjs +432 -0
- package/dist/{chunk-QJVB3JIZ.js → chunk-HWR2FRME.js} +1 -1
- package/dist/{chunk-JJLYV6GY.js → chunk-IEQHKLEL.js} +12 -6
- package/dist/chunk-JHV27P2Q.cjs +54 -0
- package/dist/{chunk-R5TH6GQE.js → chunk-KE6Z4OCB.js} +5 -5
- package/dist/{chunk-GIJMEVTJ.js → chunk-N46TJUMT.js} +12 -2
- package/dist/chunk-O34QAOO7.js +16 -0
- package/dist/{chunk-YHLI3SF7.js → chunk-OVHYLUAS.js} +8 -0
- package/dist/chunk-PLNZCEDI.js +442 -0
- package/dist/{chunk-V5HVA7TW.cjs → chunk-PV2N6PF2.cjs} +8 -0
- package/dist/chunk-QXK4IUBI.cjs +142 -0
- package/dist/chunk-RYBJGHXK.cjs +153 -0
- package/dist/chunk-U3PZBQ6G.js +54 -0
- package/dist/{chunk-SLRWY5FH.cjs → chunk-UGT4QBTM.cjs} +12 -6
- package/dist/chunk-UHKL2RG3.cjs +80 -0
- package/dist/{chunk-2KT66KQH.js → chunk-UN6NW2BW.js} +9 -5
- package/dist/chunk-UV6KZOFD.cjs +24 -0
- package/dist/{chunk-FCCQIHFD.js → chunk-UZ3LZBJ5.js} +1 -1
- package/dist/chunk-V2DXOH6B.cjs +442 -0
- package/dist/chunk-XQOH3NGZ.js +153 -0
- package/dist/chunk-XW3XIK3D.cjs +16 -0
- package/dist/chunk-YKNGDK4I.js +80 -0
- package/dist/index-6KUSPX5S.d.cts +9 -0
- package/dist/index-B7gdHwF9.d.cts +40 -0
- package/dist/{index-EY4Ag8_f.d.cts → index-BU0xla6v.d.cts} +4 -1
- package/dist/{index-DBBlm0PZ.d.cts → index-BzNlzEhU.d.cts} +7 -1
- package/dist/{index-D92-6As_.d.ts → index-C29DFVeC.d.ts} +3 -1
- package/dist/index-CPO1AFVg.d.ts +14 -0
- package/dist/index-C_7JHW0u.d.ts +9 -0
- package/dist/{index-CsP95PJy.d.ts → index-DOq59RNr.d.ts} +4 -1
- package/dist/index-DPrdy8Ms.d.ts +40 -0
- package/dist/index-cuR7l2XV.d.cts +14 -0
- package/dist/{index-BrxHOuw0.d.cts → index-qUiGxoy_.d.cts} +3 -1
- package/dist/{index-DjtNMmhM.d.ts → index-rVnsK7Ft.d.ts} +7 -1
- package/dist/index.cjs +33 -28
- package/dist/index.d.cts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +35 -30
- package/dist/judge/index.cjs +57 -5
- package/dist/judge/index.d.cts +1 -0
- package/dist/judge/index.d.ts +1 -0
- package/dist/judge/index.js +57 -5
- package/dist/judge/judge.cjs +55 -0
- package/dist/judge/judge.d.cts +155 -0
- package/dist/judge/judge.d.ts +155 -0
- package/dist/judge/judge.js +55 -0
- package/dist/judge/matchs.cjs +3 -3
- package/dist/judge/matchs.js +2 -2
- package/dist/name/index.cjs +3 -3
- package/dist/name/index.js +4 -4
- package/dist/node/getPort.js +1 -1
- package/dist/node/index.js +2 -2
- package/dist/tree/index.cjs +11 -2
- package/dist/tree/index.d.cts +1 -0
- package/dist/tree/index.d.ts +1 -0
- package/dist/tree/index.js +10 -1
- package/dist/tree/splitGroup.cjs +12 -0
- package/dist/tree/splitGroup.d.cts +15 -0
- package/dist/tree/splitGroup.d.ts +15 -0
- package/dist/tree/splitGroup.js +12 -0
- package/dist/urls/index.cjs +10 -10
- package/dist/urls/index.js +13 -13
- package/package.json +31 -6
- package/dist/chunk-6YI3CDEW.js +0 -35
- package/dist/chunk-AFKJQ4QP.js +0 -35
- package/dist/chunk-JYPJ5QJ5.cjs +0 -35
- package/dist/chunk-T7XQBASK.js +0 -28
- package/dist/chunk-U5TCBGC3.cjs +0 -28
- package/dist/chunk-WMZ6P3AK.cjs +0 -24
- package/dist/chunk-ZJIRJ4YJ.cjs +0 -35
- package/dist/index-BWAB-b69.d.ts +0 -10
- package/dist/index-CIOxFVHu.d.ts +0 -9
- package/dist/index-CVNtXK0N.d.ts +0 -14
- package/dist/index-D-5HNg2W.d.cts +0 -14
- package/dist/index-DTk8hXm8.d.cts +0 -10
- package/dist/index-DfmnOk56.d.cts +0 -9
- package/dist/{chunk-LZ7JIJ4I.cjs → chunk-222T3EXB.cjs} +9 -9
- package/dist/{chunk-IVDRKJ33.js → chunk-BFN33JM5.js} +3 -3
- package/dist/{chunk-ZXWKQRGH.cjs → chunk-BG2YS767.cjs} +2 -2
- package/dist/{chunk-X4WTO4NR.js → chunk-JM55S2OL.js} +12 -12
- package/dist/{chunk-NGQKVTCR.cjs → chunk-T22I7TJQ.cjs} +3 -3
- package/dist/{chunk-FRGDQOX4.js → chunk-T2QKEABG.js} +3 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkETMYYVQJcjs = require('../../chunk-ETMYYVQJ.cjs');
|
|
7
|
+
require('../../chunk-QXK4IUBI.cjs');
|
|
8
|
+
require('../../chunk-E4WBX6J5.cjs');
|
|
9
|
+
require('../../chunk-75ZPJI57.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.serializeCodeBlock = _chunkETMYYVQJcjs.serializeCodeBlock; exports.serializeFunctionRef = _chunkETMYYVQJcjs.serializeFunctionRef; exports.toJSONSParse = _chunkETMYYVQJcjs.toJSONSParse; exports.toJSONSStringify = _chunkETMYYVQJcjs.toJSONSStringify;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
type ObjAny<T = any> = Record<string | number | symbol, T>;
|
|
2
|
+
declare const TYPE_MARKERS: {
|
|
3
|
+
FUNCTION_REF: string;
|
|
4
|
+
CODE_BLOCK: string;
|
|
5
|
+
/**内置对象*/
|
|
6
|
+
SYMBOL: string;
|
|
7
|
+
FUNCTION: string;
|
|
8
|
+
UNDEFINED: string;
|
|
9
|
+
DATE: string;
|
|
10
|
+
REGEXP: string;
|
|
11
|
+
NAN: string;
|
|
12
|
+
BIGINT: string;
|
|
13
|
+
MAP: string;
|
|
14
|
+
SET: string;
|
|
15
|
+
ARRAY_BUFFER: string;
|
|
16
|
+
TYPED_ARRAY: string;
|
|
17
|
+
DATA_VIEW: string;
|
|
18
|
+
ERROR: string;
|
|
19
|
+
URL: string;
|
|
20
|
+
INFINITY: string;
|
|
21
|
+
NEGATIVE_INFINITY: string;
|
|
22
|
+
INT8_ARRAY: string;
|
|
23
|
+
UINT8_ARRAY: string;
|
|
24
|
+
UINT8_CLAMPED_ARRAY: string;
|
|
25
|
+
INT16_ARRAY: string;
|
|
26
|
+
UINT16_ARRAY: string;
|
|
27
|
+
INT32_ARRAY: string;
|
|
28
|
+
UINT32_ARRAY: string;
|
|
29
|
+
FLOAT32_ARRAY: string;
|
|
30
|
+
FLOAT64_ARRAY: string;
|
|
31
|
+
BIGINT64_ARRAY: string;
|
|
32
|
+
BIGUINT64_ARRAY: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 安全序列化函数(支持更多内置对象)
|
|
36
|
+
*/
|
|
37
|
+
declare function toJSONSStringify(obj: any, space?: number | string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 安全反序列化函数(完整支持更多内置对象)
|
|
40
|
+
*/
|
|
41
|
+
declare function toJSONSParse<T = any>(str: string, context?: ObjAny): T;
|
|
42
|
+
type CodeBlock = {
|
|
43
|
+
params: string[];
|
|
44
|
+
body: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* 序列化函数引用
|
|
49
|
+
*/
|
|
50
|
+
declare function serializeFunctionRef(key: string): {
|
|
51
|
+
[TYPE_MARKERS.FUNCTION_REF]: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 序列化代码块
|
|
55
|
+
*/
|
|
56
|
+
declare function serializeCodeBlock(value: CodeBlock): {
|
|
57
|
+
[TYPE_MARKERS.CODE_BLOCK]: CodeBlock;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { type CodeBlock, serializeCodeBlock, serializeFunctionRef, toJSONSParse, toJSONSStringify };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
type ObjAny<T = any> = Record<string | number | symbol, T>;
|
|
2
|
+
declare const TYPE_MARKERS: {
|
|
3
|
+
FUNCTION_REF: string;
|
|
4
|
+
CODE_BLOCK: string;
|
|
5
|
+
/**内置对象*/
|
|
6
|
+
SYMBOL: string;
|
|
7
|
+
FUNCTION: string;
|
|
8
|
+
UNDEFINED: string;
|
|
9
|
+
DATE: string;
|
|
10
|
+
REGEXP: string;
|
|
11
|
+
NAN: string;
|
|
12
|
+
BIGINT: string;
|
|
13
|
+
MAP: string;
|
|
14
|
+
SET: string;
|
|
15
|
+
ARRAY_BUFFER: string;
|
|
16
|
+
TYPED_ARRAY: string;
|
|
17
|
+
DATA_VIEW: string;
|
|
18
|
+
ERROR: string;
|
|
19
|
+
URL: string;
|
|
20
|
+
INFINITY: string;
|
|
21
|
+
NEGATIVE_INFINITY: string;
|
|
22
|
+
INT8_ARRAY: string;
|
|
23
|
+
UINT8_ARRAY: string;
|
|
24
|
+
UINT8_CLAMPED_ARRAY: string;
|
|
25
|
+
INT16_ARRAY: string;
|
|
26
|
+
UINT16_ARRAY: string;
|
|
27
|
+
INT32_ARRAY: string;
|
|
28
|
+
UINT32_ARRAY: string;
|
|
29
|
+
FLOAT32_ARRAY: string;
|
|
30
|
+
FLOAT64_ARRAY: string;
|
|
31
|
+
BIGINT64_ARRAY: string;
|
|
32
|
+
BIGUINT64_ARRAY: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 安全序列化函数(支持更多内置对象)
|
|
36
|
+
*/
|
|
37
|
+
declare function toJSONSStringify(obj: any, space?: number | string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 安全反序列化函数(完整支持更多内置对象)
|
|
40
|
+
*/
|
|
41
|
+
declare function toJSONSParse<T = any>(str: string, context?: ObjAny): T;
|
|
42
|
+
type CodeBlock = {
|
|
43
|
+
params: string[];
|
|
44
|
+
body: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* 序列化函数引用
|
|
49
|
+
*/
|
|
50
|
+
declare function serializeFunctionRef(key: string): {
|
|
51
|
+
[TYPE_MARKERS.FUNCTION_REF]: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 序列化代码块
|
|
55
|
+
*/
|
|
56
|
+
declare function serializeCodeBlock(value: CodeBlock): {
|
|
57
|
+
[TYPE_MARKERS.CODE_BLOCK]: CodeBlock;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { type CodeBlock, serializeCodeBlock, serializeFunctionRef, toJSONSParse, toJSONSStringify };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
serializeCodeBlock,
|
|
3
|
+
serializeFunctionRef,
|
|
4
|
+
toJSONSParse,
|
|
5
|
+
toJSONSStringify
|
|
6
|
+
} from "../../chunk-5HC662VK.js";
|
|
7
|
+
import "../../chunk-7O4MJOHM.js";
|
|
8
|
+
import "../../chunk-754Z5VW6.js";
|
|
9
|
+
import "../../chunk-MLKGABMK.js";
|
|
10
|
+
export {
|
|
11
|
+
serializeCodeBlock,
|
|
12
|
+
serializeFunctionRef,
|
|
13
|
+
toJSONSParse,
|
|
14
|
+
toJSONSStringify
|
|
15
|
+
};
|
|
@@ -7,11 +7,17 @@ var _chunkL7FSHU27cjs = require('./chunk-L7FSHU27.cjs');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkJHV27P2Qcjs = require('./chunk-JHV27P2Q.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkETMYYVQJcjs = require('./chunk-ETMYYVQJ.cjs');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkQXK4IUBIcjs = require('./chunk-QXK4IUBI.cjs');
|
|
15
21
|
|
|
16
22
|
|
|
17
23
|
var _chunk3HXQ7TGVcjs = require('./chunk-3HXQ7TGV.cjs');
|
|
@@ -38,13 +44,17 @@ _chunk75ZPJI57cjs.__export.call(void 0, string_exports, {
|
|
|
38
44
|
appearNumSeat: () => _chunkJR6ZN6QDcjs.appearNumSeat,
|
|
39
45
|
firstLower: () => _chunkUEVMS6QDcjs.firstLower,
|
|
40
46
|
firstUpper: () => _chunkOQL4GIEJcjs.firstUpper,
|
|
41
|
-
getFunctionFormat: () =>
|
|
47
|
+
getFunctionFormat: () => _chunkQXK4IUBIcjs.getFunctionFormat,
|
|
42
48
|
getStartSame: () => _chunkJ7S3KBHLcjs.getStartSame,
|
|
43
49
|
getStartSames: () => _chunkPW7RP73Jcjs.getStartSames,
|
|
50
|
+
serializeCodeBlock: () => _chunkETMYYVQJcjs.serializeCodeBlock,
|
|
51
|
+
serializeFunctionRef: () => _chunkETMYYVQJcjs.serializeFunctionRef,
|
|
44
52
|
splitUpper: () => _chunkL7FSHU27cjs.splitUpper,
|
|
45
|
-
toFunction: () =>
|
|
46
|
-
toJSONParse: () =>
|
|
47
|
-
|
|
53
|
+
toFunction: () => _chunkQXK4IUBIcjs.toFunction,
|
|
54
|
+
toJSONParse: () => _chunkJHV27P2Qcjs.toJSONParse,
|
|
55
|
+
toJSONSParse: () => _chunkETMYYVQJcjs.toJSONSParse,
|
|
56
|
+
toJSONSStringify: () => _chunkETMYYVQJcjs.toJSONSStringify,
|
|
57
|
+
toJSONStringify: () => _chunkJHV27P2Qcjs.toJSONStringify
|
|
48
58
|
});
|
|
49
59
|
|
|
50
60
|
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toFunction
|
|
3
|
+
} from "./chunk-7O4MJOHM.js";
|
|
4
|
+
import {
|
|
5
|
+
getObjValue
|
|
6
|
+
} from "./chunk-754Z5VW6.js";
|
|
7
|
+
|
|
8
|
+
// packages/basic/string/toJsons.ts
|
|
9
|
+
var TYPE_MARKERS = {
|
|
10
|
+
FUNCTION_REF: "_FR_",
|
|
11
|
+
CODE_BLOCK: "_CB_",
|
|
12
|
+
/**内置对象*/
|
|
13
|
+
SYMBOL: "_Sy_",
|
|
14
|
+
FUNCTION: "_F_",
|
|
15
|
+
UNDEFINED: "_UN_",
|
|
16
|
+
DATE: "_D_",
|
|
17
|
+
REGEXP: "_R_",
|
|
18
|
+
NAN: "_N_",
|
|
19
|
+
BIGINT: "_BI_",
|
|
20
|
+
MAP: "_M_",
|
|
21
|
+
SET: "_S_",
|
|
22
|
+
ARRAY_BUFFER: "_AB_",
|
|
23
|
+
TYPED_ARRAY: "_TA_",
|
|
24
|
+
DATA_VIEW: "_DV_",
|
|
25
|
+
ERROR: "_E_",
|
|
26
|
+
URL: "_U_",
|
|
27
|
+
INFINITY: "_I_",
|
|
28
|
+
NEGATIVE_INFINITY: "_NI_",
|
|
29
|
+
INT8_ARRAY: "_I8_",
|
|
30
|
+
UINT8_ARRAY: "_U8_",
|
|
31
|
+
UINT8_CLAMPED_ARRAY: "_U8C_",
|
|
32
|
+
INT16_ARRAY: "_I1_",
|
|
33
|
+
UINT16_ARRAY: "_U1_",
|
|
34
|
+
INT32_ARRAY: "_I3_",
|
|
35
|
+
UINT32_ARRAY: "_U3_",
|
|
36
|
+
FLOAT32_ARRAY: "_F3_",
|
|
37
|
+
FLOAT64_ARRAY: "_F6_",
|
|
38
|
+
BIGINT64_ARRAY: "_BI6_",
|
|
39
|
+
BIGUINT64_ARRAY: "_BU6_"
|
|
40
|
+
};
|
|
41
|
+
var arrayBufferUtils = {
|
|
42
|
+
// 将ArrayBuffer编码为Base64字符串
|
|
43
|
+
encode: (buffer) => {
|
|
44
|
+
if (typeof Buffer !== "undefined") {
|
|
45
|
+
const bytes = new Uint8Array(buffer);
|
|
46
|
+
let binary = "";
|
|
47
|
+
bytes.forEach((byte) => binary += String.fromCharCode(byte));
|
|
48
|
+
return btoa(binary);
|
|
49
|
+
}
|
|
50
|
+
if (typeof btoa === "function") {
|
|
51
|
+
const bytes = new Uint8Array(buffer);
|
|
52
|
+
let binary = "";
|
|
53
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
54
|
+
binary += String.fromCharCode(bytes[i]);
|
|
55
|
+
}
|
|
56
|
+
return btoa(binary);
|
|
57
|
+
}
|
|
58
|
+
throw new Error(
|
|
59
|
+
"ArrayBuffer encoding not supported in this environment"
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
// 将Base64字符串解码为ArrayBuffer
|
|
63
|
+
decode: (base64Str) => {
|
|
64
|
+
if (typeof Buffer !== "undefined") {
|
|
65
|
+
const binaryString = atob(base64Str);
|
|
66
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
67
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
68
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
69
|
+
}
|
|
70
|
+
return bytes.buffer;
|
|
71
|
+
}
|
|
72
|
+
if (typeof atob === "function") {
|
|
73
|
+
const binaryString = atob(base64Str);
|
|
74
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
75
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
76
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
77
|
+
}
|
|
78
|
+
return bytes.buffer;
|
|
79
|
+
}
|
|
80
|
+
throw new Error(
|
|
81
|
+
"ArrayBuffer decoding not supported in this environment"
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
// 获取ArrayBuffer的字节数组表示
|
|
85
|
+
toByteArray: (buffer) => {
|
|
86
|
+
return Array.from(new Uint8Array(buffer));
|
|
87
|
+
},
|
|
88
|
+
// 从字节数组创建ArrayBuffer
|
|
89
|
+
fromByteArray: (array) => {
|
|
90
|
+
const buffer = new ArrayBuffer(array.length);
|
|
91
|
+
const view = new Uint8Array(buffer);
|
|
92
|
+
array.forEach((value, index) => view[index] = value);
|
|
93
|
+
return buffer;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
function toJSONSStringify(obj, space) {
|
|
97
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
98
|
+
return JSON.stringify(
|
|
99
|
+
obj,
|
|
100
|
+
function(key, value) {
|
|
101
|
+
if (value === null) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
if (typeof value === "object") {
|
|
105
|
+
if (seen.has(value)) return "[Circular]";
|
|
106
|
+
seen.add(value);
|
|
107
|
+
}
|
|
108
|
+
if (this[key] instanceof Date) {
|
|
109
|
+
return {
|
|
110
|
+
[TYPE_MARKERS.DATE]: this[key].getTime()
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (this[key] instanceof URL) {
|
|
114
|
+
return {
|
|
115
|
+
[TYPE_MARKERS.URL]: this[key].href
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (value === Infinity) {
|
|
119
|
+
return { [TYPE_MARKERS.INFINITY]: 1 };
|
|
120
|
+
}
|
|
121
|
+
if (value === -Infinity) {
|
|
122
|
+
return { [TYPE_MARKERS.NEGATIVE_INFINITY]: 1 };
|
|
123
|
+
}
|
|
124
|
+
if (value === void 0) {
|
|
125
|
+
return { [TYPE_MARKERS.UNDEFINED]: 1 };
|
|
126
|
+
}
|
|
127
|
+
if (Object.is(value, NaN)) {
|
|
128
|
+
return { [TYPE_MARKERS.NAN]: 1 };
|
|
129
|
+
}
|
|
130
|
+
switch (typeof value) {
|
|
131
|
+
case "bigint":
|
|
132
|
+
return { [TYPE_MARKERS.BIGINT]: value.toString() };
|
|
133
|
+
case "symbol":
|
|
134
|
+
return {
|
|
135
|
+
[TYPE_MARKERS.SYMBOL]: {
|
|
136
|
+
k: Symbol.keyFor(value) ?? 0,
|
|
137
|
+
d: value.description || ""
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
case "function":
|
|
141
|
+
return {
|
|
142
|
+
[TYPE_MARKERS.FUNCTION]: value.toString()
|
|
143
|
+
};
|
|
144
|
+
case "object":
|
|
145
|
+
if (value instanceof RegExp) {
|
|
146
|
+
return {
|
|
147
|
+
[TYPE_MARKERS.REGEXP]: {
|
|
148
|
+
s: value.source,
|
|
149
|
+
f: value.flags
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (value instanceof Map) {
|
|
154
|
+
return {
|
|
155
|
+
[TYPE_MARKERS.MAP]: Array.from(value.entries())
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (value instanceof Set) {
|
|
159
|
+
return {
|
|
160
|
+
[TYPE_MARKERS.SET]: Array.from(value.values())
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (value instanceof ArrayBuffer) {
|
|
164
|
+
return {
|
|
165
|
+
[TYPE_MARKERS.ARRAY_BUFFER]: arrayBufferUtils.encode(value)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (value instanceof Int8Array) {
|
|
169
|
+
return {
|
|
170
|
+
[TYPE_MARKERS.INT8_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (value instanceof Uint8Array) {
|
|
174
|
+
return {
|
|
175
|
+
[TYPE_MARKERS.UINT8_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (value instanceof Uint8ClampedArray) {
|
|
179
|
+
return {
|
|
180
|
+
[TYPE_MARKERS.UINT8_CLAMPED_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (value instanceof Int16Array) {
|
|
184
|
+
return {
|
|
185
|
+
[TYPE_MARKERS.INT16_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (value instanceof Uint16Array) {
|
|
189
|
+
return {
|
|
190
|
+
[TYPE_MARKERS.UINT16_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (value instanceof Int32Array) {
|
|
194
|
+
return {
|
|
195
|
+
[TYPE_MARKERS.INT32_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (value instanceof Uint32Array) {
|
|
199
|
+
return {
|
|
200
|
+
[TYPE_MARKERS.UINT32_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (value instanceof Float32Array) {
|
|
204
|
+
return {
|
|
205
|
+
[TYPE_MARKERS.FLOAT32_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (value instanceof Float64Array) {
|
|
209
|
+
return {
|
|
210
|
+
[TYPE_MARKERS.FLOAT64_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (value instanceof BigInt64Array) {
|
|
214
|
+
return {
|
|
215
|
+
[TYPE_MARKERS.BIGINT64_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
if (value instanceof BigUint64Array) {
|
|
219
|
+
return {
|
|
220
|
+
[TYPE_MARKERS.BIGUINT64_ARRAY]: arrayBufferUtils.toByteArray(value.buffer)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (value instanceof DataView) {
|
|
224
|
+
return {
|
|
225
|
+
[TYPE_MARKERS.DATA_VIEW]: {
|
|
226
|
+
b: arrayBufferUtils.encode(
|
|
227
|
+
value.buffer
|
|
228
|
+
),
|
|
229
|
+
o: value.byteOffset,
|
|
230
|
+
l: value.byteLength
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
if (value instanceof Error) {
|
|
235
|
+
return {
|
|
236
|
+
[TYPE_MARKERS.ERROR]: {
|
|
237
|
+
n: value.name,
|
|
238
|
+
m: value.message,
|
|
239
|
+
s: value.stack
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return value;
|
|
245
|
+
},
|
|
246
|
+
space
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
function toJSONSParse(str, context) {
|
|
250
|
+
try {
|
|
251
|
+
const parsed = JSON.parse(str, (key, value) => {
|
|
252
|
+
if (value && typeof value === "object") {
|
|
253
|
+
const markers = Object.keys(value);
|
|
254
|
+
if (markers.length === 1) {
|
|
255
|
+
const marker = markers[0];
|
|
256
|
+
const markerValue = value[marker];
|
|
257
|
+
switch (marker) {
|
|
258
|
+
case TYPE_MARKERS.BIGINT:
|
|
259
|
+
return BigInt(markerValue);
|
|
260
|
+
case TYPE_MARKERS.SYMBOL:
|
|
261
|
+
return markerValue.k ? Symbol.for(markerValue.k) : Symbol(markerValue.d);
|
|
262
|
+
case TYPE_MARKERS.FUNCTION:
|
|
263
|
+
return toFunction(markerValue, key) || function() {
|
|
264
|
+
};
|
|
265
|
+
case TYPE_MARKERS.NAN:
|
|
266
|
+
return NaN;
|
|
267
|
+
case TYPE_MARKERS.INFINITY:
|
|
268
|
+
return Infinity;
|
|
269
|
+
case TYPE_MARKERS.NEGATIVE_INFINITY:
|
|
270
|
+
return -Infinity;
|
|
271
|
+
case TYPE_MARKERS.FUNCTION_REF:
|
|
272
|
+
return context ? getObjValue(markerValue, context) : void 0;
|
|
273
|
+
case TYPE_MARKERS.CODE_BLOCK:
|
|
274
|
+
return getCodeBlock(markerValue, key);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return value;
|
|
279
|
+
});
|
|
280
|
+
return restoreSpecialValues(parsed);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.error("JSON parse error:", {
|
|
283
|
+
str: str.slice(0, 200) + "...",
|
|
284
|
+
error
|
|
285
|
+
});
|
|
286
|
+
return {};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function restoreSpecialValues(obj, depth = 0) {
|
|
290
|
+
if (depth > 100) throw new Error("Recursion limit exceeded");
|
|
291
|
+
if (obj === null || typeof obj !== "object") {
|
|
292
|
+
return obj;
|
|
293
|
+
}
|
|
294
|
+
if (Array.isArray(obj)) {
|
|
295
|
+
return obj.map((item) => {
|
|
296
|
+
const converted = convertSpecialValue(item);
|
|
297
|
+
if (converted !== item) {
|
|
298
|
+
return converted;
|
|
299
|
+
}
|
|
300
|
+
return restoreSpecialValues(item, depth + 1);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
const result = {};
|
|
304
|
+
for (const key in obj) {
|
|
305
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
306
|
+
let value = obj[key];
|
|
307
|
+
const converted = convertSpecialValue(value);
|
|
308
|
+
if (converted !== value) {
|
|
309
|
+
value = converted;
|
|
310
|
+
} else {
|
|
311
|
+
value = restoreSpecialValues(value, depth + 1);
|
|
312
|
+
}
|
|
313
|
+
result[key] = value;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
function convertSpecialValue(value) {
|
|
319
|
+
if (value && typeof value === "object") {
|
|
320
|
+
const keys = Object.keys(value);
|
|
321
|
+
if (keys.length === 1) {
|
|
322
|
+
const [marker] = keys;
|
|
323
|
+
const markerValue = value[marker];
|
|
324
|
+
switch (marker) {
|
|
325
|
+
case TYPE_MARKERS.UNDEFINED:
|
|
326
|
+
return void 0;
|
|
327
|
+
case TYPE_MARKERS.DATE:
|
|
328
|
+
return new Date(markerValue);
|
|
329
|
+
// 从时间戳恢复Date
|
|
330
|
+
case TYPE_MARKERS.REGEXP: {
|
|
331
|
+
return new RegExp(markerValue.s, markerValue.f);
|
|
332
|
+
}
|
|
333
|
+
case TYPE_MARKERS.MAP:
|
|
334
|
+
return new Map(markerValue);
|
|
335
|
+
case TYPE_MARKERS.SET:
|
|
336
|
+
return new Set(markerValue);
|
|
337
|
+
case TYPE_MARKERS.ARRAY_BUFFER:
|
|
338
|
+
return arrayBufferUtils.decode(markerValue);
|
|
339
|
+
case TYPE_MARKERS.ERROR: {
|
|
340
|
+
const { n, m, s } = markerValue;
|
|
341
|
+
const error = new Error(m);
|
|
342
|
+
error.name = n;
|
|
343
|
+
error.stack = s;
|
|
344
|
+
return error;
|
|
345
|
+
}
|
|
346
|
+
case TYPE_MARKERS.URL:
|
|
347
|
+
return new URL(markerValue);
|
|
348
|
+
// 处理所有TypedArray类型
|
|
349
|
+
case TYPE_MARKERS.INT8_ARRAY:
|
|
350
|
+
return new Int8Array(
|
|
351
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
352
|
+
);
|
|
353
|
+
case TYPE_MARKERS.UINT8_ARRAY:
|
|
354
|
+
return new Uint8Array(
|
|
355
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
356
|
+
);
|
|
357
|
+
case TYPE_MARKERS.UINT8_CLAMPED_ARRAY:
|
|
358
|
+
return new Uint8ClampedArray(
|
|
359
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
360
|
+
);
|
|
361
|
+
case TYPE_MARKERS.INT16_ARRAY:
|
|
362
|
+
return new Int16Array(
|
|
363
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
364
|
+
);
|
|
365
|
+
case TYPE_MARKERS.UINT16_ARRAY:
|
|
366
|
+
return new Uint16Array(
|
|
367
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
368
|
+
);
|
|
369
|
+
case TYPE_MARKERS.INT32_ARRAY:
|
|
370
|
+
return new Int32Array(
|
|
371
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
372
|
+
);
|
|
373
|
+
case TYPE_MARKERS.UINT32_ARRAY:
|
|
374
|
+
return new Uint32Array(
|
|
375
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
376
|
+
);
|
|
377
|
+
case TYPE_MARKERS.FLOAT32_ARRAY:
|
|
378
|
+
return new Float32Array(
|
|
379
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
380
|
+
);
|
|
381
|
+
case TYPE_MARKERS.FLOAT64_ARRAY:
|
|
382
|
+
return new Float64Array(
|
|
383
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
384
|
+
);
|
|
385
|
+
case TYPE_MARKERS.BIGINT64_ARRAY:
|
|
386
|
+
return new BigInt64Array(
|
|
387
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
388
|
+
);
|
|
389
|
+
case TYPE_MARKERS.BIGUINT64_ARRAY:
|
|
390
|
+
return new BigUint64Array(
|
|
391
|
+
arrayBufferUtils.fromByteArray(markerValue)
|
|
392
|
+
);
|
|
393
|
+
case TYPE_MARKERS.DATA_VIEW: {
|
|
394
|
+
const buffer = arrayBufferUtils.decode(markerValue.b);
|
|
395
|
+
return new DataView(buffer, markerValue.o, markerValue.l);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return value;
|
|
401
|
+
}
|
|
402
|
+
function getCodeBlock(value, key) {
|
|
403
|
+
try {
|
|
404
|
+
try {
|
|
405
|
+
const fullFunction = `function ${value.name ?? key ?? ""}(${value.params.join(",")}) { ${value.body} }`;
|
|
406
|
+
return new Function(`"use strict";
|
|
407
|
+
return (${fullFunction})`)();
|
|
408
|
+
} catch (error) {
|
|
409
|
+
return new Function(
|
|
410
|
+
...value.params,
|
|
411
|
+
`"use strict";
|
|
412
|
+
${value.body}`
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
} catch (error) {
|
|
416
|
+
console.error("Code block execution failed", error);
|
|
417
|
+
return value;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function serializeFunctionRef(key) {
|
|
421
|
+
return { [TYPE_MARKERS.FUNCTION_REF]: key };
|
|
422
|
+
}
|
|
423
|
+
function serializeCodeBlock(value) {
|
|
424
|
+
return { [TYPE_MARKERS.CODE_BLOCK]: value };
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export {
|
|
428
|
+
toJSONSStringify,
|
|
429
|
+
toJSONSParse,
|
|
430
|
+
serializeFunctionRef,
|
|
431
|
+
serializeCodeBlock
|
|
432
|
+
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunkTCMJPIRMcjs = require('./chunk-TCMJPIRM.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkXSQOJWXLcjs = require('./chunk-XSQOJWXL.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
var _chunkGD3OA7GUcjs = require('./chunk-GD3OA7GU.cjs');
|
|
4
10
|
|
|
5
11
|
|
|
@@ -9,10 +15,7 @@ var _chunkMHHMXDHDcjs = require('./chunk-MHHMXDHD.cjs');
|
|
|
9
15
|
var _chunkSOAKYJIGcjs = require('./chunk-SOAKYJIG.cjs');
|
|
10
16
|
|
|
11
17
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkXSQOJWXLcjs = require('./chunk-XSQOJWXL.cjs');
|
|
18
|
+
var _chunkXW3XIK3Dcjs = require('./chunk-XW3XIK3D.cjs');
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
var _chunkISHLY7WMcjs = require('./chunk-ISHLY7WM.cjs');
|
|
@@ -28,6 +31,7 @@ _chunk75ZPJI57cjs.__export.call(void 0, array_exports, {
|
|
|
28
31
|
duplicateRemoval: () => _chunkGD3OA7GUcjs.duplicateRemoval,
|
|
29
32
|
isArray: () => _chunkISHLY7WMcjs.isArray,
|
|
30
33
|
replaceAfter: () => _chunkMHHMXDHDcjs.replaceAfter,
|
|
34
|
+
sortObj: () => _chunkXW3XIK3Dcjs.sortObj,
|
|
31
35
|
toggleArray: () => _chunkSOAKYJIGcjs.toggleArray
|
|
32
36
|
});
|
|
33
37
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// packages/basic/object/objValue.ts
|
|
2
|
+
function getObjValue(key, locale) {
|
|
3
|
+
if (!key) return locale;
|
|
4
|
+
const path = key.split(".");
|
|
5
|
+
let result = locale;
|
|
6
|
+
for (const prop of path) {
|
|
7
|
+
if (result == null || typeof result !== "object") return void 0;
|
|
8
|
+
result = result[prop];
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
function setObjValue(locale, key, value) {
|
|
13
|
+
if (!key) return Object.assign(locale, value);
|
|
14
|
+
const path = key.split(".");
|
|
15
|
+
const lastKey = path.pop();
|
|
16
|
+
let current = locale;
|
|
17
|
+
for (const prop of path) {
|
|
18
|
+
if (!current[prop] || typeof current[prop] !== "object") {
|
|
19
|
+
current[prop] = {};
|
|
20
|
+
}
|
|
21
|
+
current = current[prop];
|
|
22
|
+
}
|
|
23
|
+
current[lastKey] = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
getObjValue,
|
|
28
|
+
setObjValue
|
|
29
|
+
};
|