@fangzhongya/utils 0.0.62 → 0.0.65
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/index.cjs +5 -5
- package/dist/basic/index.js +4 -4
- package/dist/basic/string/index.cjs +3 -3
- package/dist/basic/string/index.js +2 -2
- package/dist/basic/string/toJsons.cjs +2 -2
- package/dist/basic/string/toJsons.d.cts +2 -1
- package/dist/basic/string/toJsons.d.ts +2 -1
- package/dist/basic/string/toJsons.js +1 -1
- package/dist/{chunk-BUMAKEB5.js → chunk-CGDNKEYI.js} +1 -1
- package/dist/{chunk-L6NTBIT6.js → chunk-F4E66MPZ.js} +1 -1
- package/dist/{chunk-ENKAUJ2M.cjs → chunk-TKE7IK2M.cjs} +103 -12
- package/dist/{chunk-V6CQKJQI.cjs → chunk-TV763MO4.cjs} +2 -2
- package/dist/{chunk-G7IWN7T3.cjs → chunk-XLYPGPDB.cjs} +5 -5
- package/dist/{chunk-ZVSPZZHD.js → chunk-ZADO6V3Z.js} +103 -12
- package/dist/index.cjs +13 -13
- package/dist/index.js +12 -12
- package/package.json +1 -1
package/dist/basic/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-TV763MO4.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkXLYPGPDBcjs = require('../chunk-XLYPGPDB.cjs');
|
|
5
5
|
require('../chunk-ZZKR5C3Y.cjs');
|
|
6
6
|
require('../chunk-K2XKKEE7.cjs');
|
|
7
|
-
require('../chunk-
|
|
7
|
+
require('../chunk-TKE7IK2M.cjs');
|
|
8
8
|
require('../chunk-HLKHFBMF.cjs');
|
|
9
9
|
require('../chunk-HWHYHL6J.cjs');
|
|
10
10
|
require('../chunk-J7S3KBHL.cjs');
|
|
@@ -40,9 +40,9 @@ require('../chunk-ILJLXJ5O.cjs');
|
|
|
40
40
|
require('../chunk-OJBZ7UUC.cjs');
|
|
41
41
|
require('../chunk-JR6ZN6QD.cjs');
|
|
42
42
|
require('../chunk-PW7RP73J.cjs');
|
|
43
|
+
require('../chunk-XW3XIK3D.cjs');
|
|
43
44
|
require('../chunk-UEVMS6QD.cjs');
|
|
44
45
|
require('../chunk-OQL4GIEJ.cjs');
|
|
45
|
-
require('../chunk-XW3XIK3D.cjs');
|
|
46
46
|
require('../chunk-WWAPPA4E.cjs');
|
|
47
47
|
require('../chunk-A5LHXE5X.cjs');
|
|
48
48
|
require('../chunk-MIC3W2VY.cjs');
|
|
@@ -52,4 +52,4 @@ require('../chunk-75ZPJI57.cjs');
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
exports.array = _chunk65O7KWP4cjs.array_exports; exports.object = _chunkKZCLX66Dcjs.object_exports; exports.string =
|
|
55
|
+
exports.array = _chunk65O7KWP4cjs.array_exports; exports.object = _chunkKZCLX66Dcjs.object_exports; exports.string = _chunkXLYPGPDBcjs.string_exports;
|
package/dist/basic/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-F4E66MPZ.js";
|
|
2
2
|
import {
|
|
3
3
|
string_exports
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-CGDNKEYI.js";
|
|
5
5
|
import "../chunk-SE2X5XKO.js";
|
|
6
6
|
import "../chunk-TIZFQBWC.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-ZADO6V3Z.js";
|
|
8
8
|
import "../chunk-ADPTUJSF.js";
|
|
9
9
|
import "../chunk-N5Y3XGHX.js";
|
|
10
10
|
import "../chunk-7DTHADVK.js";
|
|
@@ -40,9 +40,9 @@ import "../chunk-P7AWHISY.js";
|
|
|
40
40
|
import "../chunk-LPMR5W6M.js";
|
|
41
41
|
import "../chunk-DMZP4RPN.js";
|
|
42
42
|
import "../chunk-A276ZDLP.js";
|
|
43
|
+
import "../chunk-O34QAOO7.js";
|
|
43
44
|
import "../chunk-4OBNLDTJ.js";
|
|
44
45
|
import "../chunk-EWJJKQIO.js";
|
|
45
|
-
import "../chunk-O34QAOO7.js";
|
|
46
46
|
import "../chunk-BEKTNBRJ.js";
|
|
47
47
|
import "../chunk-GYE23WAN.js";
|
|
48
48
|
import "../chunk-MXY4W3K5.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-XLYPGPDB.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ var _chunkK2XKKEE7cjs = require('../../chunk-K2XKKEE7.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkTKE7IK2Mcjs = require('../../chunk-TKE7IK2M.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunkHLKHFBMFcjs = require('../../chunk-HLKHFBMF.cjs');
|
|
@@ -88,4 +88,4 @@ require('../../chunk-75ZPJI57.cjs');
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
exports.appearNum = _chunkOJBZ7UUCcjs.appearNum; exports.appearNumSeat = _chunkJR6ZN6QDcjs.appearNumSeat; exports.deComment = _chunkXWCRGY54cjs.deComment; exports.extractParams = _chunkJJ37YIPJcjs.extractParams; exports.firstLower = _chunkUEVMS6QDcjs.firstLower; exports.firstUpper = _chunkOQL4GIEJcjs.firstUpper; exports.getContent = _chunk4PUYFFPOcjs.getContent; exports.getContents = _chunk4PUYFFPOcjs.getContents; exports.getFunctionFormat = _chunkJJ37YIPJcjs.getFunctionFormat; exports.getImports = _chunkHWHYHL6Jcjs.getImports; exports.getImportss = _chunkHWHYHL6Jcjs.getImportss; exports.getStartSame = _chunkJ7S3KBHLcjs.getStartSame; exports.getStartSames = _chunkPW7RP73Jcjs.getStartSames; exports.getStrNunPosit = _chunk2H3KVSFAcjs.getStrNunPosit; exports.serializeCodeBlock =
|
|
91
|
+
exports.appearNum = _chunkOJBZ7UUCcjs.appearNum; exports.appearNumSeat = _chunkJR6ZN6QDcjs.appearNumSeat; exports.deComment = _chunkXWCRGY54cjs.deComment; exports.extractParams = _chunkJJ37YIPJcjs.extractParams; exports.firstLower = _chunkUEVMS6QDcjs.firstLower; exports.firstUpper = _chunkOQL4GIEJcjs.firstUpper; exports.getContent = _chunk4PUYFFPOcjs.getContent; exports.getContents = _chunk4PUYFFPOcjs.getContents; exports.getFunctionFormat = _chunkJJ37YIPJcjs.getFunctionFormat; exports.getImports = _chunkHWHYHL6Jcjs.getImports; exports.getImportss = _chunkHWHYHL6Jcjs.getImportss; exports.getStartSame = _chunkJ7S3KBHLcjs.getStartSame; exports.getStartSames = _chunkPW7RP73Jcjs.getStartSames; exports.getStrNunPosit = _chunk2H3KVSFAcjs.getStrNunPosit; exports.serializeCodeBlock = _chunkTKE7IK2Mcjs.serializeCodeBlock; exports.serializeFunctionRef = _chunkTKE7IK2Mcjs.serializeFunctionRef; exports.splitUpper = _chunkL7FSHU27cjs.splitUpper; exports.startsNum = _chunkILJLXJ5Ocjs.startsNum; exports.toFunction = _chunkJJ37YIPJcjs.toFunction; exports.toFunctionParam = _chunkZZKR5C3Ycjs.toFunctionParam; exports.toFunctionParamOptions = _chunkZZKR5C3Ycjs.toFunctionParamOptions; exports.toJSONParse = _chunkK2XKKEE7cjs.toJSONParse; exports.toJSONSParse = _chunkTKE7IK2Mcjs.toJSONSParse; exports.toJSONSStringify = _chunkTKE7IK2Mcjs.toJSONSStringify; exports.toJSONStringify = _chunkK2XKKEE7cjs.toJSONStringify; exports.toStringParse = _chunkHLKHFBMFcjs.toStringParse;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../chunk-
|
|
1
|
+
import "../../chunk-CGDNKEYI.js";
|
|
2
2
|
import {
|
|
3
3
|
toFunctionParam,
|
|
4
4
|
toFunctionParamOptions
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
serializeFunctionRef,
|
|
13
13
|
toJSONSParse,
|
|
14
14
|
toJSONSStringify
|
|
15
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-ZADO6V3Z.js";
|
|
16
16
|
import {
|
|
17
17
|
toStringParse
|
|
18
18
|
} from "../../chunk-ADPTUJSF.js";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkTKE7IK2Mcjs = require('../../chunk-TKE7IK2M.cjs');
|
|
7
7
|
require('../../chunk-JJ37YIPJ.cjs');
|
|
8
8
|
require('../../chunk-A5UJF6LP.cjs');
|
|
9
9
|
require('../../chunk-75ZPJI57.cjs');
|
|
@@ -12,4 +12,4 @@ require('../../chunk-75ZPJI57.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.serializeCodeBlock =
|
|
15
|
+
exports.serializeCodeBlock = _chunkTKE7IK2Mcjs.serializeCodeBlock; exports.serializeFunctionRef = _chunkTKE7IK2Mcjs.serializeFunctionRef; exports.toJSONSParse = _chunkTKE7IK2Mcjs.toJSONSParse; exports.toJSONSStringify = _chunkTKE7IK2Mcjs.toJSONSStringify;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type ObjAny<T = any> = Record<string | number | symbol, T>;
|
|
2
2
|
declare const TYPE_MARKERS: {
|
|
3
|
+
CIRCULAR_REF: string;
|
|
3
4
|
FUNCTION_REF: string;
|
|
4
5
|
CODE_BLOCK: string;
|
|
5
6
|
/**内置对象*/
|
|
@@ -34,7 +35,7 @@ declare const TYPE_MARKERS: {
|
|
|
34
35
|
/**
|
|
35
36
|
* 安全序列化函数(支持更多内置对象)
|
|
36
37
|
*/
|
|
37
|
-
declare function toJSONSStringify(obj: any, space?: number | string): string;
|
|
38
|
+
declare function toJSONSStringify(obj: any, space?: number | string, filtrat?: string): string;
|
|
38
39
|
/**
|
|
39
40
|
* 安全反序列化函数(完整支持更多内置对象)
|
|
40
41
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type ObjAny<T = any> = Record<string | number | symbol, T>;
|
|
2
2
|
declare const TYPE_MARKERS: {
|
|
3
|
+
CIRCULAR_REF: string;
|
|
3
4
|
FUNCTION_REF: string;
|
|
4
5
|
CODE_BLOCK: string;
|
|
5
6
|
/**内置对象*/
|
|
@@ -34,7 +35,7 @@ declare const TYPE_MARKERS: {
|
|
|
34
35
|
/**
|
|
35
36
|
* 安全序列化函数(支持更多内置对象)
|
|
36
37
|
*/
|
|
37
|
-
declare function toJSONSStringify(obj: any, space?: number | string): string;
|
|
38
|
+
declare function toJSONSStringify(obj: any, space?: number | string, filtrat?: string): string;
|
|
38
39
|
/**
|
|
39
40
|
* 安全反序列化函数(完整支持更多内置对象)
|
|
40
41
|
*/
|
|
@@ -7,6 +7,9 @@ var _chunkA5UJF6LPcjs = require('./chunk-A5UJF6LP.cjs');
|
|
|
7
7
|
|
|
8
8
|
// packages/basic/string/toJsons.ts
|
|
9
9
|
var TYPE_MARKERS = {
|
|
10
|
+
// 对象引用
|
|
11
|
+
CIRCULAR_REF: "_CR_",
|
|
12
|
+
// 新增:循环引用标记
|
|
10
13
|
FUNCTION_REF: "_FR_",
|
|
11
14
|
CODE_BLOCK: "_CB_",
|
|
12
15
|
/**内置对象*/
|
|
@@ -93,17 +96,102 @@ var arrayBufferUtils = {
|
|
|
93
96
|
return buffer;
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
|
-
function
|
|
97
|
-
|
|
99
|
+
function getObjectPath(obj, key, seen) {
|
|
100
|
+
if (obj === null || obj === void 0) {
|
|
101
|
+
return String(key);
|
|
102
|
+
}
|
|
103
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
104
|
+
return String(key);
|
|
105
|
+
}
|
|
106
|
+
const objPath = seen.get(obj);
|
|
107
|
+
if (objPath) {
|
|
108
|
+
return Array.isArray(obj) ? `${objPath}[${key}]` : `${objPath}.${key}`;
|
|
109
|
+
}
|
|
110
|
+
const path = `root${key}`;
|
|
111
|
+
if (typeof obj === "object" && obj !== null && !seen.has(obj)) {
|
|
112
|
+
seen.set(obj, path);
|
|
113
|
+
}
|
|
114
|
+
return path;
|
|
115
|
+
}
|
|
116
|
+
function getObjectPathValue(obj, key) {
|
|
117
|
+
if (key === "root") {
|
|
118
|
+
return obj;
|
|
119
|
+
}
|
|
120
|
+
let path = key;
|
|
121
|
+
if (path.startsWith("root")) {
|
|
122
|
+
path = path.slice(4);
|
|
123
|
+
}
|
|
124
|
+
if (!path) {
|
|
125
|
+
return obj;
|
|
126
|
+
}
|
|
127
|
+
const parts = [];
|
|
128
|
+
let current = "";
|
|
129
|
+
let inArray = false;
|
|
130
|
+
let bracketDepth = 0;
|
|
131
|
+
for (let i = 0; i < path.length; i++) {
|
|
132
|
+
const char = path[i];
|
|
133
|
+
if (char === "[") {
|
|
134
|
+
if (current) {
|
|
135
|
+
parts.push(current);
|
|
136
|
+
current = "";
|
|
137
|
+
}
|
|
138
|
+
inArray = true;
|
|
139
|
+
current += char;
|
|
140
|
+
bracketDepth++;
|
|
141
|
+
} else if (char === "]") {
|
|
142
|
+
current += char;
|
|
143
|
+
bracketDepth--;
|
|
144
|
+
if (bracketDepth === 0) {
|
|
145
|
+
const arrayIndex = current.slice(1, -1);
|
|
146
|
+
parts.push(arrayIndex);
|
|
147
|
+
current = "";
|
|
148
|
+
inArray = false;
|
|
149
|
+
}
|
|
150
|
+
} else if (char === "." && !inArray) {
|
|
151
|
+
if (current) {
|
|
152
|
+
parts.push(current);
|
|
153
|
+
current = "";
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
current += char;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (current) {
|
|
160
|
+
parts.push(current);
|
|
161
|
+
}
|
|
162
|
+
let result = obj;
|
|
163
|
+
for (const part of parts) {
|
|
164
|
+
if (result === null || result === void 0) {
|
|
165
|
+
return void 0;
|
|
166
|
+
}
|
|
167
|
+
const num = Number(part);
|
|
168
|
+
const index = !isNaN(num) && part.trim() !== "" ? num : part;
|
|
169
|
+
result = result[index];
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
function toJSONSStringify(obj, space, filtrat = "__") {
|
|
174
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
98
175
|
return JSON.stringify(
|
|
99
176
|
obj,
|
|
100
177
|
function(key, value) {
|
|
178
|
+
const fullPath = this === null || this === void 0 ? key : getObjectPath(this, key, seen);
|
|
179
|
+
if (filtrat && key.startsWith(filtrat)) {
|
|
180
|
+
return void 0;
|
|
181
|
+
}
|
|
101
182
|
if (value === null) {
|
|
102
183
|
return null;
|
|
103
184
|
}
|
|
104
|
-
if (typeof value === "object") {
|
|
105
|
-
|
|
106
|
-
|
|
185
|
+
if (typeof value === "object" && value !== null) {
|
|
186
|
+
const existingPath = seen.get(value);
|
|
187
|
+
if (existingPath && existingPath !== fullPath) {
|
|
188
|
+
return {
|
|
189
|
+
[TYPE_MARKERS.CIRCULAR_REF]: existingPath
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
if (!seen.has(value)) {
|
|
193
|
+
seen.set(value, fullPath);
|
|
194
|
+
}
|
|
107
195
|
}
|
|
108
196
|
if (this[key] instanceof Date) {
|
|
109
197
|
return {
|
|
@@ -277,7 +365,7 @@ function toJSONSParse(str, context) {
|
|
|
277
365
|
}
|
|
278
366
|
return value;
|
|
279
367
|
});
|
|
280
|
-
return restoreSpecialValues(parsed);
|
|
368
|
+
return restoreSpecialValues(parsed, parsed);
|
|
281
369
|
} catch (error) {
|
|
282
370
|
console.error("JSON parse error:", {
|
|
283
371
|
str: str.slice(0, 200) + "...",
|
|
@@ -286,36 +374,36 @@ function toJSONSParse(str, context) {
|
|
|
286
374
|
return {};
|
|
287
375
|
}
|
|
288
376
|
}
|
|
289
|
-
function restoreSpecialValues(obj, depth = 0) {
|
|
377
|
+
function restoreSpecialValues(original, obj, depth = 0) {
|
|
290
378
|
if (depth > 100) throw new Error("Recursion limit exceeded");
|
|
291
379
|
if (obj === null || typeof obj !== "object") {
|
|
292
380
|
return obj;
|
|
293
381
|
}
|
|
294
382
|
if (Array.isArray(obj)) {
|
|
295
383
|
return obj.map((item) => {
|
|
296
|
-
const converted = convertSpecialValue(item);
|
|
384
|
+
const converted = convertSpecialValue(original, item);
|
|
297
385
|
if (converted !== item) {
|
|
298
386
|
return converted;
|
|
299
387
|
}
|
|
300
|
-
return restoreSpecialValues(item, depth + 1);
|
|
388
|
+
return restoreSpecialValues(original, item, depth + 1);
|
|
301
389
|
});
|
|
302
390
|
}
|
|
303
391
|
const result = {};
|
|
304
392
|
for (const key in obj) {
|
|
305
393
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
306
394
|
let value = obj[key];
|
|
307
|
-
const converted = convertSpecialValue(value);
|
|
395
|
+
const converted = convertSpecialValue(original, value);
|
|
308
396
|
if (converted !== value) {
|
|
309
397
|
value = converted;
|
|
310
398
|
} else {
|
|
311
|
-
value = restoreSpecialValues(value, depth + 1);
|
|
399
|
+
value = restoreSpecialValues(original, value, depth + 1);
|
|
312
400
|
}
|
|
313
401
|
result[key] = value;
|
|
314
402
|
}
|
|
315
403
|
}
|
|
316
404
|
return result;
|
|
317
405
|
}
|
|
318
|
-
function convertSpecialValue(value) {
|
|
406
|
+
function convertSpecialValue(original, value) {
|
|
319
407
|
if (value && typeof value === "object") {
|
|
320
408
|
const keys = Object.keys(value);
|
|
321
409
|
if (keys.length === 1) {
|
|
@@ -394,6 +482,9 @@ function convertSpecialValue(value) {
|
|
|
394
482
|
const buffer = arrayBufferUtils.decode(markerValue.b);
|
|
395
483
|
return new DataView(buffer, markerValue.o, markerValue.l);
|
|
396
484
|
}
|
|
485
|
+
case TYPE_MARKERS.CIRCULAR_REF: {
|
|
486
|
+
return getObjectPathValue(original, markerValue);
|
|
487
|
+
}
|
|
397
488
|
}
|
|
398
489
|
}
|
|
399
490
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkXLYPGPDBcjs = require('./chunk-XLYPGPDB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkKZCLX66Dcjs = require('./chunk-KZCLX66D.cjs');
|
|
@@ -16,7 +16,7 @@ var basic_exports = {};
|
|
|
16
16
|
_chunk75ZPJI57cjs.__export.call(void 0, basic_exports, {
|
|
17
17
|
array: () => _chunk65O7KWP4cjs.array_exports,
|
|
18
18
|
object: () => _chunkKZCLX66Dcjs.object_exports,
|
|
19
|
-
string: () =>
|
|
19
|
+
string: () => _chunkXLYPGPDBcjs.string_exports
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
|
|
@@ -11,7 +11,7 @@ var _chunkK2XKKEE7cjs = require('./chunk-K2XKKEE7.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkTKE7IK2Mcjs = require('./chunk-TKE7IK2M.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
var _chunkHLKHFBMFcjs = require('./chunk-HLKHFBMF.cjs');
|
|
@@ -79,16 +79,16 @@ _chunk75ZPJI57cjs.__export.call(void 0, string_exports, {
|
|
|
79
79
|
getStartSame: () => _chunkJ7S3KBHLcjs.getStartSame,
|
|
80
80
|
getStartSames: () => _chunkPW7RP73Jcjs.getStartSames,
|
|
81
81
|
getStrNunPosit: () => _chunk2H3KVSFAcjs.getStrNunPosit,
|
|
82
|
-
serializeCodeBlock: () =>
|
|
83
|
-
serializeFunctionRef: () =>
|
|
82
|
+
serializeCodeBlock: () => _chunkTKE7IK2Mcjs.serializeCodeBlock,
|
|
83
|
+
serializeFunctionRef: () => _chunkTKE7IK2Mcjs.serializeFunctionRef,
|
|
84
84
|
splitUpper: () => _chunkL7FSHU27cjs.splitUpper,
|
|
85
85
|
startsNum: () => _chunkILJLXJ5Ocjs.startsNum,
|
|
86
86
|
toFunction: () => _chunkJJ37YIPJcjs.toFunction,
|
|
87
87
|
toFunctionParam: () => _chunkZZKR5C3Ycjs.toFunctionParam,
|
|
88
88
|
toFunctionParamOptions: () => _chunkZZKR5C3Ycjs.toFunctionParamOptions,
|
|
89
89
|
toJSONParse: () => _chunkK2XKKEE7cjs.toJSONParse,
|
|
90
|
-
toJSONSParse: () =>
|
|
91
|
-
toJSONSStringify: () =>
|
|
90
|
+
toJSONSParse: () => _chunkTKE7IK2Mcjs.toJSONSParse,
|
|
91
|
+
toJSONSStringify: () => _chunkTKE7IK2Mcjs.toJSONSStringify,
|
|
92
92
|
toJSONStringify: () => _chunkK2XKKEE7cjs.toJSONStringify,
|
|
93
93
|
toStringParse: () => _chunkHLKHFBMFcjs.toStringParse
|
|
94
94
|
});
|
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
|
|
8
8
|
// packages/basic/string/toJsons.ts
|
|
9
9
|
var TYPE_MARKERS = {
|
|
10
|
+
// 对象引用
|
|
11
|
+
CIRCULAR_REF: "_CR_",
|
|
12
|
+
// 新增:循环引用标记
|
|
10
13
|
FUNCTION_REF: "_FR_",
|
|
11
14
|
CODE_BLOCK: "_CB_",
|
|
12
15
|
/**内置对象*/
|
|
@@ -93,17 +96,102 @@ var arrayBufferUtils = {
|
|
|
93
96
|
return buffer;
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
|
-
function
|
|
97
|
-
|
|
99
|
+
function getObjectPath(obj, key, seen) {
|
|
100
|
+
if (obj === null || obj === void 0) {
|
|
101
|
+
return String(key);
|
|
102
|
+
}
|
|
103
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
104
|
+
return String(key);
|
|
105
|
+
}
|
|
106
|
+
const objPath = seen.get(obj);
|
|
107
|
+
if (objPath) {
|
|
108
|
+
return Array.isArray(obj) ? `${objPath}[${key}]` : `${objPath}.${key}`;
|
|
109
|
+
}
|
|
110
|
+
const path = `root${key}`;
|
|
111
|
+
if (typeof obj === "object" && obj !== null && !seen.has(obj)) {
|
|
112
|
+
seen.set(obj, path);
|
|
113
|
+
}
|
|
114
|
+
return path;
|
|
115
|
+
}
|
|
116
|
+
function getObjectPathValue(obj, key) {
|
|
117
|
+
if (key === "root") {
|
|
118
|
+
return obj;
|
|
119
|
+
}
|
|
120
|
+
let path = key;
|
|
121
|
+
if (path.startsWith("root")) {
|
|
122
|
+
path = path.slice(4);
|
|
123
|
+
}
|
|
124
|
+
if (!path) {
|
|
125
|
+
return obj;
|
|
126
|
+
}
|
|
127
|
+
const parts = [];
|
|
128
|
+
let current = "";
|
|
129
|
+
let inArray = false;
|
|
130
|
+
let bracketDepth = 0;
|
|
131
|
+
for (let i = 0; i < path.length; i++) {
|
|
132
|
+
const char = path[i];
|
|
133
|
+
if (char === "[") {
|
|
134
|
+
if (current) {
|
|
135
|
+
parts.push(current);
|
|
136
|
+
current = "";
|
|
137
|
+
}
|
|
138
|
+
inArray = true;
|
|
139
|
+
current += char;
|
|
140
|
+
bracketDepth++;
|
|
141
|
+
} else if (char === "]") {
|
|
142
|
+
current += char;
|
|
143
|
+
bracketDepth--;
|
|
144
|
+
if (bracketDepth === 0) {
|
|
145
|
+
const arrayIndex = current.slice(1, -1);
|
|
146
|
+
parts.push(arrayIndex);
|
|
147
|
+
current = "";
|
|
148
|
+
inArray = false;
|
|
149
|
+
}
|
|
150
|
+
} else if (char === "." && !inArray) {
|
|
151
|
+
if (current) {
|
|
152
|
+
parts.push(current);
|
|
153
|
+
current = "";
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
current += char;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (current) {
|
|
160
|
+
parts.push(current);
|
|
161
|
+
}
|
|
162
|
+
let result = obj;
|
|
163
|
+
for (const part of parts) {
|
|
164
|
+
if (result === null || result === void 0) {
|
|
165
|
+
return void 0;
|
|
166
|
+
}
|
|
167
|
+
const num = Number(part);
|
|
168
|
+
const index = !isNaN(num) && part.trim() !== "" ? num : part;
|
|
169
|
+
result = result[index];
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
function toJSONSStringify(obj, space, filtrat = "__") {
|
|
174
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
98
175
|
return JSON.stringify(
|
|
99
176
|
obj,
|
|
100
177
|
function(key, value) {
|
|
178
|
+
const fullPath = this === null || this === void 0 ? key : getObjectPath(this, key, seen);
|
|
179
|
+
if (filtrat && key.startsWith(filtrat)) {
|
|
180
|
+
return void 0;
|
|
181
|
+
}
|
|
101
182
|
if (value === null) {
|
|
102
183
|
return null;
|
|
103
184
|
}
|
|
104
|
-
if (typeof value === "object") {
|
|
105
|
-
|
|
106
|
-
|
|
185
|
+
if (typeof value === "object" && value !== null) {
|
|
186
|
+
const existingPath = seen.get(value);
|
|
187
|
+
if (existingPath && existingPath !== fullPath) {
|
|
188
|
+
return {
|
|
189
|
+
[TYPE_MARKERS.CIRCULAR_REF]: existingPath
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
if (!seen.has(value)) {
|
|
193
|
+
seen.set(value, fullPath);
|
|
194
|
+
}
|
|
107
195
|
}
|
|
108
196
|
if (this[key] instanceof Date) {
|
|
109
197
|
return {
|
|
@@ -277,7 +365,7 @@ function toJSONSParse(str, context) {
|
|
|
277
365
|
}
|
|
278
366
|
return value;
|
|
279
367
|
});
|
|
280
|
-
return restoreSpecialValues(parsed);
|
|
368
|
+
return restoreSpecialValues(parsed, parsed);
|
|
281
369
|
} catch (error) {
|
|
282
370
|
console.error("JSON parse error:", {
|
|
283
371
|
str: str.slice(0, 200) + "...",
|
|
@@ -286,36 +374,36 @@ function toJSONSParse(str, context) {
|
|
|
286
374
|
return {};
|
|
287
375
|
}
|
|
288
376
|
}
|
|
289
|
-
function restoreSpecialValues(obj, depth = 0) {
|
|
377
|
+
function restoreSpecialValues(original, obj, depth = 0) {
|
|
290
378
|
if (depth > 100) throw new Error("Recursion limit exceeded");
|
|
291
379
|
if (obj === null || typeof obj !== "object") {
|
|
292
380
|
return obj;
|
|
293
381
|
}
|
|
294
382
|
if (Array.isArray(obj)) {
|
|
295
383
|
return obj.map((item) => {
|
|
296
|
-
const converted = convertSpecialValue(item);
|
|
384
|
+
const converted = convertSpecialValue(original, item);
|
|
297
385
|
if (converted !== item) {
|
|
298
386
|
return converted;
|
|
299
387
|
}
|
|
300
|
-
return restoreSpecialValues(item, depth + 1);
|
|
388
|
+
return restoreSpecialValues(original, item, depth + 1);
|
|
301
389
|
});
|
|
302
390
|
}
|
|
303
391
|
const result = {};
|
|
304
392
|
for (const key in obj) {
|
|
305
393
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
306
394
|
let value = obj[key];
|
|
307
|
-
const converted = convertSpecialValue(value);
|
|
395
|
+
const converted = convertSpecialValue(original, value);
|
|
308
396
|
if (converted !== value) {
|
|
309
397
|
value = converted;
|
|
310
398
|
} else {
|
|
311
|
-
value = restoreSpecialValues(value, depth + 1);
|
|
399
|
+
value = restoreSpecialValues(original, value, depth + 1);
|
|
312
400
|
}
|
|
313
401
|
result[key] = value;
|
|
314
402
|
}
|
|
315
403
|
}
|
|
316
404
|
return result;
|
|
317
405
|
}
|
|
318
|
-
function convertSpecialValue(value) {
|
|
406
|
+
function convertSpecialValue(original, value) {
|
|
319
407
|
if (value && typeof value === "object") {
|
|
320
408
|
const keys = Object.keys(value);
|
|
321
409
|
if (keys.length === 1) {
|
|
@@ -394,6 +482,9 @@ function convertSpecialValue(value) {
|
|
|
394
482
|
const buffer = arrayBufferUtils.decode(markerValue.b);
|
|
395
483
|
return new DataView(buffer, markerValue.o, markerValue.l);
|
|
396
484
|
}
|
|
485
|
+
case TYPE_MARKERS.CIRCULAR_REF: {
|
|
486
|
+
return getObjectPathValue(original, markerValue);
|
|
487
|
+
}
|
|
397
488
|
}
|
|
398
489
|
}
|
|
399
490
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -22,10 +22,10 @@ require('./chunk-HMAAC5QA.cjs');
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
var _chunkBG2YS767cjs = require('./chunk-BG2YS767.cjs');
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
require('./chunk-
|
|
28
|
-
require('./chunk-
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunkV6PYRA4Acjs = require('./chunk-V6PYRA4A.cjs');
|
|
28
|
+
require('./chunk-FGQXKLTH.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
var _chunkAPRM3ELYcjs = require('./chunk-APRM3ELY.cjs');
|
|
@@ -40,10 +40,10 @@ require('./chunk-FP5ETUFZ.cjs');
|
|
|
40
40
|
|
|
41
41
|
var _chunkHUKQYAV6cjs = require('./chunk-HUKQYAV6.cjs');
|
|
42
42
|
require('./chunk-5VQ4EAJZ.cjs');
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
require('./chunk-
|
|
43
|
+
require('./chunk-KRBTSMT2.cjs');
|
|
44
|
+
require('./chunk-O6P3QI3B.cjs');
|
|
45
|
+
require('./chunk-XHR36FJK.cjs');
|
|
46
|
+
require('./chunk-WI55O3IV.cjs');
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
var _chunkFLGYKRQ6cjs = require('./chunk-FLGYKRQ6.cjs');
|
|
@@ -84,11 +84,11 @@ require('./chunk-7TGGIID4.cjs');
|
|
|
84
84
|
require('./chunk-75UYCE4X.cjs');
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
var
|
|
88
|
-
require('./chunk-
|
|
87
|
+
var _chunkTV763MO4cjs = require('./chunk-TV763MO4.cjs');
|
|
88
|
+
require('./chunk-XLYPGPDB.cjs');
|
|
89
89
|
require('./chunk-ZZKR5C3Y.cjs');
|
|
90
90
|
require('./chunk-K2XKKEE7.cjs');
|
|
91
|
-
require('./chunk-
|
|
91
|
+
require('./chunk-TKE7IK2M.cjs');
|
|
92
92
|
require('./chunk-HLKHFBMF.cjs');
|
|
93
93
|
require('./chunk-HWHYHL6J.cjs');
|
|
94
94
|
require('./chunk-J7S3KBHL.cjs');
|
|
@@ -120,9 +120,9 @@ require('./chunk-ILJLXJ5O.cjs');
|
|
|
120
120
|
require('./chunk-OJBZ7UUC.cjs');
|
|
121
121
|
require('./chunk-JR6ZN6QD.cjs');
|
|
122
122
|
require('./chunk-PW7RP73J.cjs');
|
|
123
|
+
require('./chunk-XW3XIK3D.cjs');
|
|
123
124
|
require('./chunk-UEVMS6QD.cjs');
|
|
124
125
|
require('./chunk-OQL4GIEJ.cjs');
|
|
125
|
-
require('./chunk-XW3XIK3D.cjs');
|
|
126
126
|
require('./chunk-WWAPPA4E.cjs');
|
|
127
127
|
require('./chunk-A5LHXE5X.cjs');
|
|
128
128
|
require('./chunk-MIC3W2VY.cjs');
|
|
@@ -149,4 +149,4 @@ require('./chunk-75ZPJI57.cjs');
|
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
|
|
152
|
-
exports.basic =
|
|
152
|
+
exports.basic = _chunkTV763MO4cjs.basic_exports; exports.css = _chunkXDTLZL44cjs.css_exports; exports.date = _chunk5SOPYS7Lcjs.date_exports; exports.dom = _chunkZUIHJQD6cjs.dom_exports; exports.html = _chunkFLGYKRQ6cjs.html_exports; exports.iss = _chunkRYVXUCAScjs.iss_exports; exports.judge = _chunkFL2HPQ66cjs.judge_exports; exports.load = _chunkBD6DK4QKcjs.load_exports; exports.log = _chunkHUKQYAV6cjs.log_exports; exports.name = _chunkBG2YS767cjs.name_exports; exports.node = _chunkV6PYRA4Acjs.node_exports; exports.tree = _chunkAPRM3ELYcjs.tree_exports; exports.urls = _chunk7GCUYESUcjs.urls_exports; exports.window = _chunk72GMBSE6cjs.window_exports;
|
package/dist/index.js
CHANGED
|
@@ -22,10 +22,10 @@ import "./chunk-GHJWTV6H.js";
|
|
|
22
22
|
import {
|
|
23
23
|
name_exports
|
|
24
24
|
} from "./chunk-BFN33JM5.js";
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import "./chunk-
|
|
25
|
+
import {
|
|
26
|
+
node_exports
|
|
27
|
+
} from "./chunk-UZ3LZBJ5.js";
|
|
28
|
+
import "./chunk-HWR2FRME.js";
|
|
29
29
|
import {
|
|
30
30
|
tree_exports
|
|
31
31
|
} from "./chunk-QUIZWAFR.js";
|
|
@@ -40,10 +40,10 @@ import {
|
|
|
40
40
|
log_exports
|
|
41
41
|
} from "./chunk-4FHGONC7.js";
|
|
42
42
|
import "./chunk-HVQG2IGJ.js";
|
|
43
|
-
import
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
import "./chunk-
|
|
43
|
+
import "./chunk-VRRDYCUH.js";
|
|
44
|
+
import "./chunk-EJWFLQF3.js";
|
|
45
|
+
import "./chunk-AM67P3W7.js";
|
|
46
|
+
import "./chunk-XCDKXZFR.js";
|
|
47
47
|
import {
|
|
48
48
|
html_exports
|
|
49
49
|
} from "./chunk-4JXZQBCA.js";
|
|
@@ -84,11 +84,11 @@ import "./chunk-EKY7GXCD.js";
|
|
|
84
84
|
import "./chunk-Q2EFMBMD.js";
|
|
85
85
|
import {
|
|
86
86
|
basic_exports
|
|
87
|
-
} from "./chunk-
|
|
88
|
-
import "./chunk-
|
|
87
|
+
} from "./chunk-F4E66MPZ.js";
|
|
88
|
+
import "./chunk-CGDNKEYI.js";
|
|
89
89
|
import "./chunk-SE2X5XKO.js";
|
|
90
90
|
import "./chunk-TIZFQBWC.js";
|
|
91
|
-
import "./chunk-
|
|
91
|
+
import "./chunk-ZADO6V3Z.js";
|
|
92
92
|
import "./chunk-ADPTUJSF.js";
|
|
93
93
|
import "./chunk-N5Y3XGHX.js";
|
|
94
94
|
import "./chunk-7DTHADVK.js";
|
|
@@ -120,9 +120,9 @@ import "./chunk-P7AWHISY.js";
|
|
|
120
120
|
import "./chunk-LPMR5W6M.js";
|
|
121
121
|
import "./chunk-DMZP4RPN.js";
|
|
122
122
|
import "./chunk-A276ZDLP.js";
|
|
123
|
+
import "./chunk-O34QAOO7.js";
|
|
123
124
|
import "./chunk-4OBNLDTJ.js";
|
|
124
125
|
import "./chunk-EWJJKQIO.js";
|
|
125
|
-
import "./chunk-O34QAOO7.js";
|
|
126
126
|
import "./chunk-BEKTNBRJ.js";
|
|
127
127
|
import "./chunk-GYE23WAN.js";
|
|
128
128
|
import "./chunk-MXY4W3K5.js";
|