seroval 0.8.0 → 0.9.0
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/cjs/development/index.cjs +152 -44
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +152 -44
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/context.d.ts +6 -0
- package/dist/types/tree/shared.d.ts +2 -0
- package/dist/types/tree/types.d.ts +10 -0
- package/package.json +7 -7
- package/src/context.ts +10 -0
- package/src/tree/async.ts +11 -0
- package/src/tree/constants.ts +1 -0
- package/src/tree/deserialize.ts +16 -0
- package/src/tree/primitives.ts +12 -0
- package/src/tree/reference.ts +0 -1
- package/src/tree/serialize.ts +61 -9
- package/src/tree/shared.ts +14 -0
- package/src/tree/sync.ts +10 -0
- package/src/tree/types.ts +13 -1
- package/src/tree/web-api.ts +4 -0
- package/src/tree/iterator.ts +0 -14
|
@@ -91,7 +91,8 @@ function createSerializationContext(options) {
|
|
|
91
91
|
refSize: 0,
|
|
92
92
|
features: options.features,
|
|
93
93
|
markedRefs: new Set(options.markedRefs),
|
|
94
|
-
valueMap: /* @__PURE__ */ new Map()
|
|
94
|
+
valueMap: /* @__PURE__ */ new Map(),
|
|
95
|
+
flags: []
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
function markRef(ctx, current) {
|
|
@@ -204,7 +205,8 @@ function createConstantNode(value) {
|
|
|
204
205
|
d: void 0,
|
|
205
206
|
a: void 0,
|
|
206
207
|
f: void 0,
|
|
207
|
-
b: void 0
|
|
208
|
+
b: void 0,
|
|
209
|
+
o: void 0
|
|
208
210
|
};
|
|
209
211
|
}
|
|
210
212
|
var TRUE_NODE = createConstantNode(2 /* True */);
|
|
@@ -384,7 +386,8 @@ function createNumberNode(value) {
|
|
|
384
386
|
d: void 0,
|
|
385
387
|
a: void 0,
|
|
386
388
|
f: void 0,
|
|
387
|
-
b: void 0
|
|
389
|
+
b: void 0,
|
|
390
|
+
o: void 0
|
|
388
391
|
};
|
|
389
392
|
}
|
|
390
393
|
}
|
|
@@ -399,7 +402,8 @@ function createStringNode(value) {
|
|
|
399
402
|
d: void 0,
|
|
400
403
|
a: void 0,
|
|
401
404
|
f: void 0,
|
|
402
|
-
b: void 0
|
|
405
|
+
b: void 0,
|
|
406
|
+
o: void 0
|
|
403
407
|
};
|
|
404
408
|
}
|
|
405
409
|
function createBigIntNode(ctx, current) {
|
|
@@ -414,7 +418,8 @@ function createBigIntNode(ctx, current) {
|
|
|
414
418
|
d: void 0,
|
|
415
419
|
a: void 0,
|
|
416
420
|
f: void 0,
|
|
417
|
-
b: void 0
|
|
421
|
+
b: void 0,
|
|
422
|
+
o: void 0
|
|
418
423
|
};
|
|
419
424
|
}
|
|
420
425
|
function createIndexedValueNode(id) {
|
|
@@ -428,7 +433,8 @@ function createIndexedValueNode(id) {
|
|
|
428
433
|
d: void 0,
|
|
429
434
|
a: void 0,
|
|
430
435
|
f: void 0,
|
|
431
|
-
b: void 0
|
|
436
|
+
b: void 0,
|
|
437
|
+
o: void 0
|
|
432
438
|
};
|
|
433
439
|
}
|
|
434
440
|
function createDateNode(id, current) {
|
|
@@ -442,7 +448,8 @@ function createDateNode(id, current) {
|
|
|
442
448
|
d: void 0,
|
|
443
449
|
f: void 0,
|
|
444
450
|
a: void 0,
|
|
445
|
-
b: void 0
|
|
451
|
+
b: void 0,
|
|
452
|
+
o: void 0
|
|
446
453
|
};
|
|
447
454
|
}
|
|
448
455
|
function createRegExpNode(id, current) {
|
|
@@ -456,7 +463,8 @@ function createRegExpNode(id, current) {
|
|
|
456
463
|
d: void 0,
|
|
457
464
|
a: void 0,
|
|
458
465
|
f: void 0,
|
|
459
|
-
b: void 0
|
|
466
|
+
b: void 0,
|
|
467
|
+
o: void 0
|
|
460
468
|
};
|
|
461
469
|
}
|
|
462
470
|
function createArrayBufferNode(id, current) {
|
|
@@ -476,7 +484,8 @@ function createArrayBufferNode(id, current) {
|
|
|
476
484
|
d: void 0,
|
|
477
485
|
a: void 0,
|
|
478
486
|
f: void 0,
|
|
479
|
-
b: void 0
|
|
487
|
+
b: void 0,
|
|
488
|
+
o: void 0
|
|
480
489
|
};
|
|
481
490
|
}
|
|
482
491
|
function serializeArrayBuffer(ctx, current) {
|
|
@@ -498,7 +507,8 @@ function createTypedArrayNode(ctx, id, current) {
|
|
|
498
507
|
d: void 0,
|
|
499
508
|
a: void 0,
|
|
500
509
|
f: serializeArrayBuffer(ctx, current.buffer),
|
|
501
|
-
b: current.byteOffset
|
|
510
|
+
b: current.byteOffset,
|
|
511
|
+
o: void 0
|
|
502
512
|
};
|
|
503
513
|
}
|
|
504
514
|
var BIGINT_FLAG = 4096 /* BigIntTypedArray */ | 8 /* BigInt */;
|
|
@@ -517,7 +527,8 @@ function createBigIntTypedArrayNode(ctx, id, current) {
|
|
|
517
527
|
d: void 0,
|
|
518
528
|
a: void 0,
|
|
519
529
|
f: serializeArrayBuffer(ctx, current.buffer),
|
|
520
|
-
b: current.byteOffset
|
|
530
|
+
b: current.byteOffset,
|
|
531
|
+
o: void 0
|
|
521
532
|
};
|
|
522
533
|
}
|
|
523
534
|
function createWKSymbolNode(ctx, id, current) {
|
|
@@ -533,7 +544,8 @@ function createWKSymbolNode(ctx, id, current) {
|
|
|
533
544
|
d: void 0,
|
|
534
545
|
a: void 0,
|
|
535
546
|
f: void 0,
|
|
536
|
-
b: void 0
|
|
547
|
+
b: void 0,
|
|
548
|
+
o: void 0
|
|
537
549
|
};
|
|
538
550
|
}
|
|
539
551
|
function createReferenceNode(id, ref) {
|
|
@@ -547,7 +559,8 @@ function createReferenceNode(id, ref) {
|
|
|
547
559
|
d: void 0,
|
|
548
560
|
a: void 0,
|
|
549
561
|
f: void 0,
|
|
550
|
-
b: void 0
|
|
562
|
+
b: void 0,
|
|
563
|
+
o: void 0
|
|
551
564
|
};
|
|
552
565
|
}
|
|
553
566
|
function createDataViewNode(ctx, id, current) {
|
|
@@ -561,7 +574,8 @@ function createDataViewNode(ctx, id, current) {
|
|
|
561
574
|
d: void 0,
|
|
562
575
|
a: void 0,
|
|
563
576
|
f: serializeArrayBuffer(ctx, current.buffer),
|
|
564
|
-
b: current.byteOffset
|
|
577
|
+
b: current.byteOffset,
|
|
578
|
+
o: void 0
|
|
565
579
|
};
|
|
566
580
|
}
|
|
567
581
|
function createSymbolNode(ctx, current) {
|
|
@@ -709,6 +723,18 @@ function isValidIdentifier(name) {
|
|
|
709
723
|
const char = name[0];
|
|
710
724
|
return (char === "$" || char === "_" || char >= "A" && char <= "Z" || char >= "a" && char <= "z") && IDENTIFIER_CHECK.test(name);
|
|
711
725
|
}
|
|
726
|
+
function getObjectFlag(obj) {
|
|
727
|
+
if (Object.isFrozen(obj)) {
|
|
728
|
+
return 3 /* Frozen */;
|
|
729
|
+
}
|
|
730
|
+
if (Object.isSealed(obj)) {
|
|
731
|
+
return 2 /* Sealed */;
|
|
732
|
+
}
|
|
733
|
+
if (Object.isExtensible(obj)) {
|
|
734
|
+
return 0 /* None */;
|
|
735
|
+
}
|
|
736
|
+
return 1 /* NonExtensible */;
|
|
737
|
+
}
|
|
712
738
|
|
|
713
739
|
// src/tree/web-api.ts
|
|
714
740
|
function createURLNode(ctx, id, current) {
|
|
@@ -723,7 +749,8 @@ function createURLNode(ctx, id, current) {
|
|
|
723
749
|
d: void 0,
|
|
724
750
|
f: void 0,
|
|
725
751
|
a: void 0,
|
|
726
|
-
b: void 0
|
|
752
|
+
b: void 0,
|
|
753
|
+
o: void 0
|
|
727
754
|
};
|
|
728
755
|
}
|
|
729
756
|
function createURLSearchParamsNode(ctx, id, current) {
|
|
@@ -738,7 +765,8 @@ function createURLSearchParamsNode(ctx, id, current) {
|
|
|
738
765
|
d: void 0,
|
|
739
766
|
f: void 0,
|
|
740
767
|
a: void 0,
|
|
741
|
-
b: void 0
|
|
768
|
+
b: void 0,
|
|
769
|
+
o: void 0
|
|
742
770
|
};
|
|
743
771
|
}
|
|
744
772
|
async function createBlobNode(ctx, id, current) {
|
|
@@ -753,7 +781,8 @@ async function createBlobNode(ctx, id, current) {
|
|
|
753
781
|
d: void 0,
|
|
754
782
|
f: serializeArrayBuffer(ctx, await current.arrayBuffer()),
|
|
755
783
|
a: void 0,
|
|
756
|
-
b: void 0
|
|
784
|
+
b: void 0,
|
|
785
|
+
o: void 0
|
|
757
786
|
};
|
|
758
787
|
}
|
|
759
788
|
async function createFileNode(ctx, id, current) {
|
|
@@ -768,7 +797,8 @@ async function createFileNode(ctx, id, current) {
|
|
|
768
797
|
d: void 0,
|
|
769
798
|
f: serializeArrayBuffer(ctx, await current.arrayBuffer()),
|
|
770
799
|
a: void 0,
|
|
771
|
-
b: current.lastModified
|
|
800
|
+
b: current.lastModified,
|
|
801
|
+
o: void 0
|
|
772
802
|
};
|
|
773
803
|
}
|
|
774
804
|
|
|
@@ -806,7 +836,8 @@ function generateArrayNode(ctx, id, current) {
|
|
|
806
836
|
d: void 0,
|
|
807
837
|
a: generateNodeList(ctx, current),
|
|
808
838
|
f: void 0,
|
|
809
|
-
b: void 0
|
|
839
|
+
b: void 0,
|
|
840
|
+
o: getObjectFlag(current)
|
|
810
841
|
};
|
|
811
842
|
}
|
|
812
843
|
function generateMapNode(ctx, id, current) {
|
|
@@ -843,7 +874,8 @@ function generateMapNode(ctx, id, current) {
|
|
|
843
874
|
d: { k: keyNodes, v: valueNodes, s: len },
|
|
844
875
|
a: void 0,
|
|
845
876
|
f: void 0,
|
|
846
|
-
b: void 0
|
|
877
|
+
b: void 0,
|
|
878
|
+
o: void 0
|
|
847
879
|
};
|
|
848
880
|
}
|
|
849
881
|
function generateSetNode(ctx, id, current) {
|
|
@@ -873,7 +905,8 @@ function generateSetNode(ctx, id, current) {
|
|
|
873
905
|
d: void 0,
|
|
874
906
|
a: nodes,
|
|
875
907
|
f: void 0,
|
|
876
|
-
b: void 0
|
|
908
|
+
b: void 0,
|
|
909
|
+
o: void 0
|
|
877
910
|
};
|
|
878
911
|
}
|
|
879
912
|
function generateProperties(ctx, properties) {
|
|
@@ -964,7 +997,8 @@ function generateObjectNode(ctx, id, current, empty) {
|
|
|
964
997
|
d: generateProperties(ctx, current),
|
|
965
998
|
a: void 0,
|
|
966
999
|
f: void 0,
|
|
967
|
-
b: void 0
|
|
1000
|
+
b: void 0,
|
|
1001
|
+
o: getObjectFlag(current)
|
|
968
1002
|
};
|
|
969
1003
|
}
|
|
970
1004
|
function generateAggregateErrorNode(ctx, id, current) {
|
|
@@ -980,7 +1014,8 @@ function generateAggregateErrorNode(ctx, id, current) {
|
|
|
980
1014
|
d: optionsNode,
|
|
981
1015
|
a: void 0,
|
|
982
1016
|
f: void 0,
|
|
983
|
-
b: void 0
|
|
1017
|
+
b: void 0,
|
|
1018
|
+
o: void 0
|
|
984
1019
|
};
|
|
985
1020
|
}
|
|
986
1021
|
function generateErrorNode(ctx, id, current) {
|
|
@@ -996,7 +1031,8 @@ function generateErrorNode(ctx, id, current) {
|
|
|
996
1031
|
d: optionsNode,
|
|
997
1032
|
a: void 0,
|
|
998
1033
|
f: void 0,
|
|
999
|
-
b: void 0
|
|
1034
|
+
b: void 0,
|
|
1035
|
+
o: void 0
|
|
1000
1036
|
};
|
|
1001
1037
|
}
|
|
1002
1038
|
function generateHeadersNode(ctx, id, current) {
|
|
@@ -1015,7 +1051,8 @@ function generateHeadersNode(ctx, id, current) {
|
|
|
1015
1051
|
d: generatePlainProperties(ctx, items),
|
|
1016
1052
|
a: void 0,
|
|
1017
1053
|
f: void 0,
|
|
1018
|
-
b: void 0
|
|
1054
|
+
b: void 0,
|
|
1055
|
+
o: void 0
|
|
1019
1056
|
};
|
|
1020
1057
|
}
|
|
1021
1058
|
function generateFormDataNode(ctx, id, current) {
|
|
@@ -1034,7 +1071,8 @@ function generateFormDataNode(ctx, id, current) {
|
|
|
1034
1071
|
d: generatePlainProperties(ctx, items),
|
|
1035
1072
|
a: void 0,
|
|
1036
1073
|
f: void 0,
|
|
1037
|
-
b: void 0
|
|
1074
|
+
b: void 0,
|
|
1075
|
+
o: void 0
|
|
1038
1076
|
};
|
|
1039
1077
|
}
|
|
1040
1078
|
function generateBoxedNode(ctx, id, current) {
|
|
@@ -1048,7 +1086,8 @@ function generateBoxedNode(ctx, id, current) {
|
|
|
1048
1086
|
d: void 0,
|
|
1049
1087
|
a: void 0,
|
|
1050
1088
|
f: parseSync(ctx, current.valueOf()),
|
|
1051
|
-
b: void 0
|
|
1089
|
+
b: void 0,
|
|
1090
|
+
o: void 0
|
|
1052
1091
|
};
|
|
1053
1092
|
}
|
|
1054
1093
|
function parseObject(ctx, current) {
|
|
@@ -1207,7 +1246,8 @@ async function generateArrayNode2(ctx, id, current) {
|
|
|
1207
1246
|
d: void 0,
|
|
1208
1247
|
a: await generateNodeList2(ctx, current),
|
|
1209
1248
|
f: void 0,
|
|
1210
|
-
b: void 0
|
|
1249
|
+
b: void 0,
|
|
1250
|
+
o: getObjectFlag(current)
|
|
1211
1251
|
};
|
|
1212
1252
|
}
|
|
1213
1253
|
async function generateMapNode2(ctx, id, current) {
|
|
@@ -1244,7 +1284,8 @@ async function generateMapNode2(ctx, id, current) {
|
|
|
1244
1284
|
d: { k: keyNodes, v: valueNodes, s: len },
|
|
1245
1285
|
a: void 0,
|
|
1246
1286
|
f: void 0,
|
|
1247
|
-
b: void 0
|
|
1287
|
+
b: void 0,
|
|
1288
|
+
o: void 0
|
|
1248
1289
|
};
|
|
1249
1290
|
}
|
|
1250
1291
|
async function generateSetNode2(ctx, id, current) {
|
|
@@ -1274,7 +1315,8 @@ async function generateSetNode2(ctx, id, current) {
|
|
|
1274
1315
|
d: void 0,
|
|
1275
1316
|
a: nodes,
|
|
1276
1317
|
f: void 0,
|
|
1277
|
-
b: void 0
|
|
1318
|
+
b: void 0,
|
|
1319
|
+
o: void 0
|
|
1278
1320
|
};
|
|
1279
1321
|
}
|
|
1280
1322
|
async function generateProperties2(ctx, properties) {
|
|
@@ -1370,7 +1412,8 @@ async function generatePromiseNode(ctx, id, current) {
|
|
|
1370
1412
|
d: void 0,
|
|
1371
1413
|
a: void 0,
|
|
1372
1414
|
f: await parseAsync(ctx, await current),
|
|
1373
|
-
b: void 0
|
|
1415
|
+
b: void 0,
|
|
1416
|
+
o: void 0
|
|
1374
1417
|
};
|
|
1375
1418
|
}
|
|
1376
1419
|
async function generateObjectNode2(ctx, id, current, empty) {
|
|
@@ -1384,7 +1427,8 @@ async function generateObjectNode2(ctx, id, current, empty) {
|
|
|
1384
1427
|
d: await generateProperties2(ctx, current),
|
|
1385
1428
|
a: void 0,
|
|
1386
1429
|
f: void 0,
|
|
1387
|
-
b: void 0
|
|
1430
|
+
b: void 0,
|
|
1431
|
+
o: getObjectFlag(current)
|
|
1388
1432
|
};
|
|
1389
1433
|
}
|
|
1390
1434
|
async function generateAggregateErrorNode2(ctx, id, current) {
|
|
@@ -1400,7 +1444,8 @@ async function generateAggregateErrorNode2(ctx, id, current) {
|
|
|
1400
1444
|
d: optionsNode,
|
|
1401
1445
|
a: void 0,
|
|
1402
1446
|
f: void 0,
|
|
1403
|
-
b: void 0
|
|
1447
|
+
b: void 0,
|
|
1448
|
+
o: void 0
|
|
1404
1449
|
};
|
|
1405
1450
|
}
|
|
1406
1451
|
async function generateErrorNode2(ctx, id, current) {
|
|
@@ -1416,7 +1461,8 @@ async function generateErrorNode2(ctx, id, current) {
|
|
|
1416
1461
|
d: optionsNode,
|
|
1417
1462
|
a: void 0,
|
|
1418
1463
|
f: void 0,
|
|
1419
|
-
b: void 0
|
|
1464
|
+
b: void 0,
|
|
1465
|
+
o: void 0
|
|
1420
1466
|
};
|
|
1421
1467
|
}
|
|
1422
1468
|
async function generateHeadersNode2(ctx, id, current) {
|
|
@@ -1435,7 +1481,8 @@ async function generateHeadersNode2(ctx, id, current) {
|
|
|
1435
1481
|
d: await generatePlainProperties2(ctx, items),
|
|
1436
1482
|
a: void 0,
|
|
1437
1483
|
f: void 0,
|
|
1438
|
-
b: void 0
|
|
1484
|
+
b: void 0,
|
|
1485
|
+
o: void 0
|
|
1439
1486
|
};
|
|
1440
1487
|
}
|
|
1441
1488
|
async function generateFormDataNode2(ctx, id, current) {
|
|
@@ -1454,7 +1501,8 @@ async function generateFormDataNode2(ctx, id, current) {
|
|
|
1454
1501
|
d: await generatePlainProperties2(ctx, items),
|
|
1455
1502
|
a: void 0,
|
|
1456
1503
|
f: void 0,
|
|
1457
|
-
b: void 0
|
|
1504
|
+
b: void 0,
|
|
1505
|
+
o: void 0
|
|
1458
1506
|
};
|
|
1459
1507
|
}
|
|
1460
1508
|
async function generateBoxedNode2(ctx, id, current) {
|
|
@@ -1468,7 +1516,8 @@ async function generateBoxedNode2(ctx, id, current) {
|
|
|
1468
1516
|
d: void 0,
|
|
1469
1517
|
a: void 0,
|
|
1470
1518
|
f: await parseAsync(ctx, current.valueOf()),
|
|
1471
|
-
b: void 0
|
|
1519
|
+
b: void 0,
|
|
1520
|
+
o: void 0
|
|
1472
1521
|
};
|
|
1473
1522
|
}
|
|
1474
1523
|
async function parseObject2(ctx, current) {
|
|
@@ -1611,6 +1660,18 @@ async function parseAsync(ctx, current) {
|
|
|
1611
1660
|
}
|
|
1612
1661
|
|
|
1613
1662
|
// src/tree/deserialize.ts
|
|
1663
|
+
function applyObjectFlag(obj, flag) {
|
|
1664
|
+
switch (flag) {
|
|
1665
|
+
case 3 /* Frozen */:
|
|
1666
|
+
return Object.freeze(obj);
|
|
1667
|
+
case 1 /* NonExtensible */:
|
|
1668
|
+
return Object.preventExtensions(obj);
|
|
1669
|
+
case 2 /* Sealed */:
|
|
1670
|
+
return Object.seal(obj);
|
|
1671
|
+
default:
|
|
1672
|
+
return obj;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1614
1675
|
function assignIndexedValue(ctx, index, value) {
|
|
1615
1676
|
if (ctx.markedRefs.has(index)) {
|
|
1616
1677
|
ctx.valueMap.set(index, value);
|
|
@@ -1631,6 +1692,7 @@ function deserializeArray(ctx, node) {
|
|
|
1631
1692
|
result[i] = deserializeTree(ctx, item);
|
|
1632
1693
|
}
|
|
1633
1694
|
}
|
|
1695
|
+
applyObjectFlag(result, node.o);
|
|
1634
1696
|
return result;
|
|
1635
1697
|
}
|
|
1636
1698
|
function deserializeProperties(ctx, node, result) {
|
|
@@ -1665,6 +1727,7 @@ function deserializeObject(ctx, node) {
|
|
|
1665
1727
|
node.t === 10 /* Object */ ? {} : /* @__PURE__ */ Object.create(null)
|
|
1666
1728
|
);
|
|
1667
1729
|
deserializeProperties(ctx, node.d, result);
|
|
1730
|
+
applyObjectFlag(result, node.o);
|
|
1668
1731
|
return result;
|
|
1669
1732
|
}
|
|
1670
1733
|
function deserializeSet(ctx, node) {
|
|
@@ -1891,6 +1954,12 @@ function getAssignmentExpression(assignment) {
|
|
|
1891
1954
|
return "";
|
|
1892
1955
|
}
|
|
1893
1956
|
}
|
|
1957
|
+
var OBJECT_FLAG_CONSTRUCTOR = {
|
|
1958
|
+
[3 /* Frozen */]: "Object.freeze",
|
|
1959
|
+
[2 /* Sealed */]: "Object.seal",
|
|
1960
|
+
[1 /* NonExtensible */]: "Object.preventExtensions",
|
|
1961
|
+
[0 /* None */]: void 0
|
|
1962
|
+
};
|
|
1894
1963
|
function mergeAssignments(assignments) {
|
|
1895
1964
|
const newAssignments = [];
|
|
1896
1965
|
let current = assignments[0];
|
|
@@ -1966,8 +2035,33 @@ function resolveAssignments(assignments) {
|
|
|
1966
2035
|
}
|
|
1967
2036
|
return void 0;
|
|
1968
2037
|
}
|
|
2038
|
+
function pushObjectFlag(ctx, flag, id) {
|
|
2039
|
+
if (flag !== 0 /* None */) {
|
|
2040
|
+
markRef(ctx, id);
|
|
2041
|
+
ctx.flags.push({
|
|
2042
|
+
type: flag,
|
|
2043
|
+
value: getRefParam(ctx, id)
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
function resolveFlags(ctx) {
|
|
2048
|
+
let result = "";
|
|
2049
|
+
for (let i = 0, len = ctx.flags.length; i < len; i++) {
|
|
2050
|
+
const flag = ctx.flags[i];
|
|
2051
|
+
result += OBJECT_FLAG_CONSTRUCTOR[flag.type] + "(" + flag.value + "),";
|
|
2052
|
+
}
|
|
2053
|
+
return result;
|
|
2054
|
+
}
|
|
1969
2055
|
function resolvePatches(ctx) {
|
|
1970
|
-
|
|
2056
|
+
const assignments = resolveAssignments(ctx.assignments);
|
|
2057
|
+
const flags = resolveFlags(ctx);
|
|
2058
|
+
if (assignments) {
|
|
2059
|
+
if (flags) {
|
|
2060
|
+
return assignments + flags;
|
|
2061
|
+
}
|
|
2062
|
+
return assignments;
|
|
2063
|
+
}
|
|
2064
|
+
return flags;
|
|
1971
2065
|
}
|
|
1972
2066
|
function createAssignment(ctx, source, value) {
|
|
1973
2067
|
ctx.assignments.push({
|
|
@@ -2043,6 +2137,7 @@ function serializeArray(ctx, node) {
|
|
|
2043
2137
|
}
|
|
2044
2138
|
}
|
|
2045
2139
|
ctx.stack.pop();
|
|
2140
|
+
pushObjectFlag(ctx, node.o, node.i);
|
|
2046
2141
|
return assignIndexedValue2(ctx, id, "[" + values + (isHoley ? ",]" : "]"));
|
|
2047
2142
|
}
|
|
2048
2143
|
function getIterableAccess(ctx) {
|
|
@@ -2124,8 +2219,6 @@ function serializeAssignments(ctx, sourceID, node) {
|
|
|
2124
2219
|
for (let i = 0, len = node.s; i < len; i++) {
|
|
2125
2220
|
key = keys[i];
|
|
2126
2221
|
value = values[i];
|
|
2127
|
-
parentAssignment = ctx.assignments;
|
|
2128
|
-
ctx.assignments = mainAssignments;
|
|
2129
2222
|
switch (key) {
|
|
2130
2223
|
case 0 /* SymbolIterator */:
|
|
2131
2224
|
{
|
|
@@ -2133,26 +2226,39 @@ function serializeAssignments(ctx, sourceID, node) {
|
|
|
2133
2226
|
ctx.stack = [];
|
|
2134
2227
|
const serialized = serializeTree(ctx, value) + getIterableAccess(ctx);
|
|
2135
2228
|
ctx.stack = parent;
|
|
2229
|
+
parentAssignment = ctx.assignments;
|
|
2230
|
+
ctx.assignments = mainAssignments;
|
|
2136
2231
|
createArrayAssign(
|
|
2137
2232
|
ctx,
|
|
2138
2233
|
sourceID,
|
|
2139
2234
|
"Symbol.iterator",
|
|
2140
2235
|
ctx.features & 4 /* ArrowFunction */ ? "()=>" + serialized : "function(){return " + serialized + "}"
|
|
2141
2236
|
);
|
|
2237
|
+
ctx.assignments = parentAssignment;
|
|
2142
2238
|
}
|
|
2143
2239
|
break;
|
|
2144
2240
|
default: {
|
|
2145
2241
|
const serialized = serializeTree(ctx, value);
|
|
2146
2242
|
const check = Number(key);
|
|
2147
2243
|
const isIdentifier = check >= 0 || isValidIdentifier(key);
|
|
2148
|
-
if (
|
|
2149
|
-
|
|
2244
|
+
if (isIndexedValueInStack(ctx, value)) {
|
|
2245
|
+
if (isIdentifier && Number.isNaN(check)) {
|
|
2246
|
+
createObjectAssign(ctx, sourceID, key, serialized);
|
|
2247
|
+
} else {
|
|
2248
|
+
createArrayAssign(ctx, sourceID, isIdentifier ? key : '"' + key + '"', serialized);
|
|
2249
|
+
}
|
|
2150
2250
|
} else {
|
|
2151
|
-
|
|
2251
|
+
parentAssignment = ctx.assignments;
|
|
2252
|
+
ctx.assignments = mainAssignments;
|
|
2253
|
+
if (isIdentifier && Number.isNaN(check)) {
|
|
2254
|
+
createObjectAssign(ctx, sourceID, key, serialized);
|
|
2255
|
+
} else {
|
|
2256
|
+
createArrayAssign(ctx, sourceID, isIdentifier ? key : '"' + key + '"', serialized);
|
|
2257
|
+
}
|
|
2258
|
+
ctx.assignments = parentAssignment;
|
|
2152
2259
|
}
|
|
2153
2260
|
}
|
|
2154
2261
|
}
|
|
2155
|
-
ctx.assignments = parentAssignment;
|
|
2156
2262
|
}
|
|
2157
2263
|
ctx.stack.pop();
|
|
2158
2264
|
return resolveAssignments(mainAssignments);
|
|
@@ -2173,9 +2279,11 @@ function serializeDictionary(ctx, i, d, init) {
|
|
|
2173
2279
|
}
|
|
2174
2280
|
var NULL_CONSTRUCTOR = "Object.create(null)";
|
|
2175
2281
|
function serializeNullConstructor(ctx, node) {
|
|
2282
|
+
pushObjectFlag(ctx, node.o, node.i);
|
|
2176
2283
|
return serializeDictionary(ctx, node.i, node.d, NULL_CONSTRUCTOR);
|
|
2177
2284
|
}
|
|
2178
2285
|
function serializeObject(ctx, node) {
|
|
2286
|
+
pushObjectFlag(ctx, node.o, node.i);
|
|
2179
2287
|
return assignIndexedValue2(ctx, node.i, serializeProperties(ctx, node.i, node.d));
|
|
2180
2288
|
}
|
|
2181
2289
|
function serializeSet(ctx, node) {
|