seroval 1.4.0 → 1.4.2
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 +553 -350
- package/dist/cjs/development/index.cjs.map +3 -3
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +553 -350
- package/dist/esm/development/index.mjs.map +3 -3
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/base-primitives.d.ts +2 -2
- package/dist/types/core/base-primitives.d.ts.map +1 -1
- package/dist/types/core/compat.d.ts +2 -1
- package/dist/types/core/compat.d.ts.map +1 -1
- package/dist/types/core/constants.d.ts +2 -2
- package/dist/types/core/constants.d.ts.map +1 -1
- package/dist/types/core/constructors.d.ts +1 -1
- package/dist/types/core/constructors.d.ts.map +1 -1
- package/dist/types/core/context/async-parser.d.ts +5 -4
- package/dist/types/core/context/async-parser.d.ts.map +1 -1
- package/dist/types/core/context/deserializer.d.ts +7 -2
- package/dist/types/core/context/deserializer.d.ts.map +1 -1
- package/dist/types/core/context/parser.d.ts +3 -1
- package/dist/types/core/context/parser.d.ts.map +1 -1
- package/dist/types/core/context/serializer.d.ts.map +1 -1
- package/dist/types/core/context/sync-parser.d.ts +5 -5
- package/dist/types/core/context/sync-parser.d.ts.map +1 -1
- package/dist/types/core/cross/index.d.ts.map +1 -1
- package/dist/types/core/errors.d.ts +9 -0
- package/dist/types/core/errors.d.ts.map +1 -1
- package/dist/types/core/node.d.ts +1 -1
- package/dist/types/core/string.d.ts.map +1 -1
- package/dist/types/core/tree/index.d.ts +4 -1
- package/dist/types/core/tree/index.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +6 -11
- package/dist/types/core/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/base-primitives.ts +17 -18
- package/src/core/compat.ts +3 -1
- package/src/core/constants.ts +18 -4
- package/src/core/constructors.ts +2 -1
- package/src/core/context/async-parser.ts +102 -50
- package/src/core/context/deserializer.ts +269 -105
- package/src/core/context/parser.ts +12 -10
- package/src/core/context/serializer.ts +31 -36
- package/src/core/context/sync-parser.ts +149 -75
- package/src/core/cross/index.ts +2 -0
- package/src/core/errors.ts +33 -0
- package/src/core/node.ts +2 -2
- package/src/core/string.ts +3 -1
- package/src/core/tree/index.ts +10 -1
- package/src/core/types.ts +10 -19
|
@@ -23,8 +23,11 @@ __export(src_exports, {
|
|
|
23
23
|
Feature: () => Feature,
|
|
24
24
|
OpaqueReference: () => OpaqueReference,
|
|
25
25
|
Serializer: () => Serializer,
|
|
26
|
+
SerovalConflictedNodeIdError: () => SerovalConflictedNodeIdError,
|
|
27
|
+
SerovalDepthLimitError: () => SerovalDepthLimitError,
|
|
26
28
|
SerovalDeserializationError: () => SerovalDeserializationError,
|
|
27
29
|
SerovalError: () => SerovalError,
|
|
30
|
+
SerovalMalformedNodeError: () => SerovalMalformedNodeError,
|
|
28
31
|
SerovalMissingInstanceError: () => SerovalMissingInstanceError,
|
|
29
32
|
SerovalMissingPluginError: () => SerovalMissingPluginError,
|
|
30
33
|
SerovalMissingReferenceError: () => SerovalMissingReferenceError,
|
|
@@ -64,9 +67,10 @@ var Feature = /* @__PURE__ */ ((Feature2) => {
|
|
|
64
67
|
Feature2[Feature2["ErrorPrototypeStack"] = 4] = "ErrorPrototypeStack";
|
|
65
68
|
Feature2[Feature2["ObjectAssign"] = 8] = "ObjectAssign";
|
|
66
69
|
Feature2[Feature2["BigIntTypedArray"] = 16] = "BigIntTypedArray";
|
|
70
|
+
Feature2[Feature2["RegExp"] = 32] = "RegExp";
|
|
67
71
|
return Feature2;
|
|
68
72
|
})(Feature || {});
|
|
69
|
-
var ALL_ENABLED = 1 /* AggregateError */ | 2 /* ArrowFunction */ | 4 /* ErrorPrototypeStack */ | 8 /* ObjectAssign */ | 16 /* BigIntTypedArray */;
|
|
73
|
+
var ALL_ENABLED = 1 /* AggregateError */ | 2 /* ArrowFunction */ | 4 /* ErrorPrototypeStack */ | 8 /* ObjectAssign */ | 16 /* BigIntTypedArray */ | 32 /* RegExp */;
|
|
70
74
|
|
|
71
75
|
// src/core/symbols.ts
|
|
72
76
|
var SYM_ASYNC_ITERATOR = Symbol.asyncIterator;
|
|
@@ -139,10 +143,11 @@ var CONSTANT_STRING = {
|
|
|
139
143
|
[6 /* NegInf */]: "-1/0",
|
|
140
144
|
[7 /* Nan */]: "0/0"
|
|
141
145
|
};
|
|
146
|
+
var NIL = void 0;
|
|
142
147
|
var CONSTANT_VAL = {
|
|
143
148
|
[2 /* True */]: true,
|
|
144
149
|
[3 /* False */]: false,
|
|
145
|
-
[1 /* Undefined */]:
|
|
150
|
+
[1 /* Undefined */]: NIL,
|
|
146
151
|
[0 /* Null */]: null,
|
|
147
152
|
[4 /* NegZero */]: -0,
|
|
148
153
|
[5 /* Inf */]: Number.POSITIVE_INFINITY,
|
|
@@ -167,15 +172,13 @@ var ERROR_CONSTRUCTOR = {
|
|
|
167
172
|
[5 /* TypeError */]: TypeError,
|
|
168
173
|
[6 /* URIError */]: URIError
|
|
169
174
|
};
|
|
170
|
-
var NIL = void 0;
|
|
171
175
|
|
|
172
176
|
// src/core/node.ts
|
|
173
|
-
function createSerovalNode(t, i, s,
|
|
177
|
+
function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o, l) {
|
|
174
178
|
return {
|
|
175
179
|
t,
|
|
176
180
|
i,
|
|
177
181
|
s,
|
|
178
|
-
l,
|
|
179
182
|
c,
|
|
180
183
|
m,
|
|
181
184
|
p,
|
|
@@ -183,7 +186,8 @@ function createSerovalNode(t, i, s, l, c, m, p, e, a, f, b, o) {
|
|
|
183
186
|
a,
|
|
184
187
|
f,
|
|
185
188
|
b,
|
|
186
|
-
o
|
|
189
|
+
o,
|
|
190
|
+
l
|
|
187
191
|
};
|
|
188
192
|
}
|
|
189
193
|
|
|
@@ -251,7 +255,7 @@ function serializeChar(str) {
|
|
|
251
255
|
case "\u2029":
|
|
252
256
|
return "\\u2029";
|
|
253
257
|
default:
|
|
254
|
-
return
|
|
258
|
+
return NIL;
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
261
|
function serializeString(str) {
|
|
@@ -539,7 +543,6 @@ function createRegExpNode(id, current) {
|
|
|
539
543
|
6 /* RegExp */,
|
|
540
544
|
id,
|
|
541
545
|
NIL,
|
|
542
|
-
NIL,
|
|
543
546
|
serializeString(current.source),
|
|
544
547
|
current.flags,
|
|
545
548
|
NIL,
|
|
@@ -547,6 +550,7 @@ function createRegExpNode(id, current) {
|
|
|
547
550
|
NIL,
|
|
548
551
|
NIL,
|
|
549
552
|
NIL,
|
|
553
|
+
NIL,
|
|
550
554
|
NIL
|
|
551
555
|
);
|
|
552
556
|
}
|
|
@@ -587,7 +591,6 @@ function createPluginNode(id, tag, value) {
|
|
|
587
591
|
25 /* Plugin */,
|
|
588
592
|
id,
|
|
589
593
|
value,
|
|
590
|
-
NIL,
|
|
591
594
|
serializeString(tag),
|
|
592
595
|
NIL,
|
|
593
596
|
NIL,
|
|
@@ -595,6 +598,7 @@ function createPluginNode(id, tag, value) {
|
|
|
595
598
|
NIL,
|
|
596
599
|
NIL,
|
|
597
600
|
NIL,
|
|
601
|
+
NIL,
|
|
598
602
|
NIL
|
|
599
603
|
);
|
|
600
604
|
}
|
|
@@ -603,7 +607,6 @@ function createArrayNode(id, current, parsedItems) {
|
|
|
603
607
|
9 /* Array */,
|
|
604
608
|
id,
|
|
605
609
|
NIL,
|
|
606
|
-
current.length,
|
|
607
610
|
NIL,
|
|
608
611
|
NIL,
|
|
609
612
|
NIL,
|
|
@@ -611,7 +614,8 @@ function createArrayNode(id, current, parsedItems) {
|
|
|
611
614
|
parsedItems,
|
|
612
615
|
NIL,
|
|
613
616
|
NIL,
|
|
614
|
-
getObjectFlag(current)
|
|
617
|
+
getObjectFlag(current),
|
|
618
|
+
NIL
|
|
615
619
|
);
|
|
616
620
|
}
|
|
617
621
|
function createBoxedNode(id, boxed) {
|
|
@@ -624,9 +628,9 @@ function createBoxedNode(id, boxed) {
|
|
|
624
628
|
NIL,
|
|
625
629
|
NIL,
|
|
626
630
|
NIL,
|
|
627
|
-
NIL,
|
|
628
631
|
boxed,
|
|
629
632
|
NIL,
|
|
633
|
+
NIL,
|
|
630
634
|
NIL
|
|
631
635
|
);
|
|
632
636
|
}
|
|
@@ -635,7 +639,6 @@ function createTypedArrayNode(id, current, buffer) {
|
|
|
635
639
|
15 /* TypedArray */,
|
|
636
640
|
id,
|
|
637
641
|
NIL,
|
|
638
|
-
current.length,
|
|
639
642
|
current.constructor.name,
|
|
640
643
|
NIL,
|
|
641
644
|
NIL,
|
|
@@ -643,7 +646,8 @@ function createTypedArrayNode(id, current, buffer) {
|
|
|
643
646
|
NIL,
|
|
644
647
|
buffer,
|
|
645
648
|
current.byteOffset,
|
|
646
|
-
NIL
|
|
649
|
+
NIL,
|
|
650
|
+
current.length
|
|
647
651
|
);
|
|
648
652
|
}
|
|
649
653
|
function createBigIntTypedArrayNode(id, current, buffer) {
|
|
@@ -651,7 +655,6 @@ function createBigIntTypedArrayNode(id, current, buffer) {
|
|
|
651
655
|
16 /* BigIntTypedArray */,
|
|
652
656
|
id,
|
|
653
657
|
NIL,
|
|
654
|
-
current.length,
|
|
655
658
|
current.constructor.name,
|
|
656
659
|
NIL,
|
|
657
660
|
NIL,
|
|
@@ -659,7 +662,8 @@ function createBigIntTypedArrayNode(id, current, buffer) {
|
|
|
659
662
|
NIL,
|
|
660
663
|
buffer,
|
|
661
664
|
current.byteOffset,
|
|
662
|
-
NIL
|
|
665
|
+
NIL,
|
|
666
|
+
current.byteLength
|
|
663
667
|
);
|
|
664
668
|
}
|
|
665
669
|
function createDataViewNode(id, current, buffer) {
|
|
@@ -667,7 +671,6 @@ function createDataViewNode(id, current, buffer) {
|
|
|
667
671
|
20 /* DataView */,
|
|
668
672
|
id,
|
|
669
673
|
NIL,
|
|
670
|
-
current.byteLength,
|
|
671
674
|
NIL,
|
|
672
675
|
NIL,
|
|
673
676
|
NIL,
|
|
@@ -675,7 +678,8 @@ function createDataViewNode(id, current, buffer) {
|
|
|
675
678
|
NIL,
|
|
676
679
|
buffer,
|
|
677
680
|
current.byteOffset,
|
|
678
|
-
NIL
|
|
681
|
+
NIL,
|
|
682
|
+
current.byteLength
|
|
679
683
|
);
|
|
680
684
|
}
|
|
681
685
|
function createErrorNode(id, current, options) {
|
|
@@ -684,13 +688,13 @@ function createErrorNode(id, current, options) {
|
|
|
684
688
|
id,
|
|
685
689
|
getErrorConstructor(current),
|
|
686
690
|
NIL,
|
|
687
|
-
NIL,
|
|
688
691
|
serializeString(current.message),
|
|
689
692
|
options,
|
|
690
693
|
NIL,
|
|
691
694
|
NIL,
|
|
692
695
|
NIL,
|
|
693
696
|
NIL,
|
|
697
|
+
NIL,
|
|
694
698
|
NIL
|
|
695
699
|
);
|
|
696
700
|
}
|
|
@@ -700,22 +704,21 @@ function createAggregateErrorNode(id, current, options) {
|
|
|
700
704
|
id,
|
|
701
705
|
getErrorConstructor(current),
|
|
702
706
|
NIL,
|
|
703
|
-
NIL,
|
|
704
707
|
serializeString(current.message),
|
|
705
708
|
options,
|
|
706
709
|
NIL,
|
|
707
710
|
NIL,
|
|
708
711
|
NIL,
|
|
709
712
|
NIL,
|
|
713
|
+
NIL,
|
|
710
714
|
NIL
|
|
711
715
|
);
|
|
712
716
|
}
|
|
713
|
-
function createSetNode(id,
|
|
717
|
+
function createSetNode(id, items) {
|
|
714
718
|
return createSerovalNode(
|
|
715
719
|
7 /* Set */,
|
|
716
720
|
id,
|
|
717
721
|
NIL,
|
|
718
|
-
size,
|
|
719
722
|
NIL,
|
|
720
723
|
NIL,
|
|
721
724
|
NIL,
|
|
@@ -723,6 +726,7 @@ function createSetNode(id, size, items) {
|
|
|
723
726
|
items,
|
|
724
727
|
NIL,
|
|
725
728
|
NIL,
|
|
729
|
+
NIL,
|
|
726
730
|
NIL
|
|
727
731
|
);
|
|
728
732
|
}
|
|
@@ -735,10 +739,10 @@ function createIteratorFactoryInstanceNode(factory, items) {
|
|
|
735
739
|
NIL,
|
|
736
740
|
NIL,
|
|
737
741
|
NIL,
|
|
738
|
-
NIL,
|
|
739
742
|
[factory, items],
|
|
740
743
|
NIL,
|
|
741
744
|
NIL,
|
|
745
|
+
NIL,
|
|
742
746
|
NIL
|
|
743
747
|
);
|
|
744
748
|
}
|
|
@@ -751,10 +755,10 @@ function createAsyncIteratorFactoryInstanceNode(factory, items) {
|
|
|
751
755
|
NIL,
|
|
752
756
|
NIL,
|
|
753
757
|
NIL,
|
|
754
|
-
NIL,
|
|
755
758
|
[factory, items],
|
|
756
759
|
NIL,
|
|
757
760
|
NIL,
|
|
761
|
+
NIL,
|
|
758
762
|
NIL
|
|
759
763
|
);
|
|
760
764
|
}
|
|
@@ -767,10 +771,10 @@ function createStreamConstructorNode(id, factory, sequence) {
|
|
|
767
771
|
NIL,
|
|
768
772
|
NIL,
|
|
769
773
|
NIL,
|
|
770
|
-
NIL,
|
|
771
774
|
sequence,
|
|
772
775
|
factory,
|
|
773
776
|
NIL,
|
|
777
|
+
NIL,
|
|
774
778
|
NIL
|
|
775
779
|
);
|
|
776
780
|
}
|
|
@@ -784,9 +788,9 @@ function createStreamNextNode(id, parsed) {
|
|
|
784
788
|
NIL,
|
|
785
789
|
NIL,
|
|
786
790
|
NIL,
|
|
787
|
-
NIL,
|
|
788
791
|
parsed,
|
|
789
792
|
NIL,
|
|
793
|
+
NIL,
|
|
790
794
|
NIL
|
|
791
795
|
);
|
|
792
796
|
}
|
|
@@ -800,9 +804,9 @@ function createStreamThrowNode(id, parsed) {
|
|
|
800
804
|
NIL,
|
|
801
805
|
NIL,
|
|
802
806
|
NIL,
|
|
803
|
-
NIL,
|
|
804
807
|
parsed,
|
|
805
808
|
NIL,
|
|
809
|
+
NIL,
|
|
806
810
|
NIL
|
|
807
811
|
);
|
|
808
812
|
}
|
|
@@ -816,9 +820,9 @@ function createStreamReturnNode(id, parsed) {
|
|
|
816
820
|
NIL,
|
|
817
821
|
NIL,
|
|
818
822
|
NIL,
|
|
819
|
-
NIL,
|
|
820
823
|
parsed,
|
|
821
824
|
NIL,
|
|
825
|
+
NIL,
|
|
822
826
|
NIL
|
|
823
827
|
);
|
|
824
828
|
}
|
|
@@ -918,6 +922,27 @@ var SerovalUnknownTypedArrayError = class extends Error {
|
|
|
918
922
|
);
|
|
919
923
|
}
|
|
920
924
|
};
|
|
925
|
+
var SerovalMalformedNodeError = class extends Error {
|
|
926
|
+
constructor(node) {
|
|
927
|
+
super(
|
|
928
|
+
false ? getSpecificErrorMessage(8 /* MalformedNode */) : 'Malformed node type "' + node.t + '".'
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
var SerovalConflictedNodeIdError = class extends Error {
|
|
933
|
+
constructor(node) {
|
|
934
|
+
super(
|
|
935
|
+
false ? getSpecificErrorMessage(9 /* ConflictedNodeId */) : 'Conflicted node id "' + node.i + '".'
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
var SerovalDepthLimitError = class extends Error {
|
|
940
|
+
constructor(limit) {
|
|
941
|
+
super(
|
|
942
|
+
false ? getSpecificErrorMessage(9 /* ConflictedNodeId */) : "Depth limit of " + limit + " reached"
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
};
|
|
921
946
|
|
|
922
947
|
// src/core/opaque-reference.ts
|
|
923
948
|
var OpaqueReference = class {
|
|
@@ -1127,8 +1152,9 @@ var ASYNC_ITERATOR_CONSTRUCTOR = (symbol, createPromise) => (stream) => () => {
|
|
|
1127
1152
|
return instance;
|
|
1128
1153
|
};
|
|
1129
1154
|
var SERIALIZED_ASYNC_ITERATOR_CONSTRUCTOR = /* @__PURE__ */ ASYNC_ITERATOR_CONSTRUCTOR.toString();
|
|
1130
|
-
var ARRAY_BUFFER_CONSTRUCTOR = (
|
|
1155
|
+
var ARRAY_BUFFER_CONSTRUCTOR = (b64) => {
|
|
1131
1156
|
const decoded = atob(b64);
|
|
1157
|
+
const length = decoded.length;
|
|
1132
1158
|
const arr = new Uint8Array(length);
|
|
1133
1159
|
for (let i = 0; i < length; i++) {
|
|
1134
1160
|
arr[i] = decoded.charCodeAt(i);
|
|
@@ -1240,7 +1266,8 @@ function createBaseParserContext(mode, options) {
|
|
|
1240
1266
|
mode,
|
|
1241
1267
|
marked: /* @__PURE__ */ new Set(),
|
|
1242
1268
|
features: ALL_ENABLED ^ (options.disabledFeatures || 0),
|
|
1243
|
-
refs: options.refs || /* @__PURE__ */ new Map()
|
|
1269
|
+
refs: options.refs || /* @__PURE__ */ new Map(),
|
|
1270
|
+
depthLimit: options.depthLimit || 1e3
|
|
1244
1271
|
};
|
|
1245
1272
|
}
|
|
1246
1273
|
function markParserRef(ctx, id) {
|
|
@@ -1322,9 +1349,9 @@ function parseIteratorFactory(ctx) {
|
|
|
1322
1349
|
NIL,
|
|
1323
1350
|
NIL,
|
|
1324
1351
|
NIL,
|
|
1325
|
-
NIL,
|
|
1326
1352
|
parseWellKnownSymbol(ctx, SYM_ITERATOR),
|
|
1327
1353
|
NIL,
|
|
1354
|
+
NIL,
|
|
1328
1355
|
NIL
|
|
1329
1356
|
);
|
|
1330
1357
|
}
|
|
@@ -1341,13 +1368,13 @@ function parseAsyncIteratorFactory(ctx) {
|
|
|
1341
1368
|
NIL,
|
|
1342
1369
|
NIL,
|
|
1343
1370
|
NIL,
|
|
1344
|
-
NIL,
|
|
1345
1371
|
[
|
|
1346
1372
|
parseSpecialReference(ctx, 1 /* PromiseConstructor */),
|
|
1347
1373
|
parseWellKnownSymbol(ctx, SYM_ASYNC_ITERATOR)
|
|
1348
1374
|
],
|
|
1349
1375
|
NIL,
|
|
1350
1376
|
NIL,
|
|
1377
|
+
NIL,
|
|
1351
1378
|
NIL
|
|
1352
1379
|
);
|
|
1353
1380
|
}
|
|
@@ -1358,16 +1385,16 @@ function createObjectNode(id, current, empty, record) {
|
|
|
1358
1385
|
NIL,
|
|
1359
1386
|
NIL,
|
|
1360
1387
|
NIL,
|
|
1361
|
-
NIL,
|
|
1362
1388
|
record,
|
|
1363
1389
|
NIL,
|
|
1364
1390
|
NIL,
|
|
1365
1391
|
NIL,
|
|
1366
1392
|
NIL,
|
|
1367
|
-
getObjectFlag(current)
|
|
1393
|
+
getObjectFlag(current),
|
|
1394
|
+
NIL
|
|
1368
1395
|
);
|
|
1369
1396
|
}
|
|
1370
|
-
function createMapNode(ctx, id, k, v
|
|
1397
|
+
function createMapNode(ctx, id, k, v) {
|
|
1371
1398
|
return createSerovalNode(
|
|
1372
1399
|
8 /* Map */,
|
|
1373
1400
|
id,
|
|
@@ -1375,11 +1402,11 @@ function createMapNode(ctx, id, k, v, s) {
|
|
|
1375
1402
|
NIL,
|
|
1376
1403
|
NIL,
|
|
1377
1404
|
NIL,
|
|
1378
|
-
|
|
1379
|
-
{ k, v, s },
|
|
1405
|
+
{ k, v },
|
|
1380
1406
|
NIL,
|
|
1381
1407
|
parseSpecialReference(ctx, 0 /* MapSentinel */),
|
|
1382
1408
|
NIL,
|
|
1409
|
+
NIL,
|
|
1383
1410
|
NIL
|
|
1384
1411
|
);
|
|
1385
1412
|
}
|
|
@@ -1393,24 +1420,22 @@ function createPromiseConstructorNode(ctx, id, resolver) {
|
|
|
1393
1420
|
NIL,
|
|
1394
1421
|
NIL,
|
|
1395
1422
|
NIL,
|
|
1396
|
-
NIL,
|
|
1397
1423
|
parseSpecialReference(ctx, 1 /* PromiseConstructor */),
|
|
1398
1424
|
NIL,
|
|
1425
|
+
NIL,
|
|
1399
1426
|
NIL
|
|
1400
1427
|
);
|
|
1401
1428
|
}
|
|
1402
1429
|
function createArrayBufferNode(ctx, id, current) {
|
|
1403
1430
|
const bytes = new Uint8Array(current);
|
|
1404
|
-
const len = bytes.length;
|
|
1405
1431
|
let result = "";
|
|
1406
|
-
for (let i = 0; i < len; i++) {
|
|
1432
|
+
for (let i = 0, len = bytes.length; i < len; i++) {
|
|
1407
1433
|
result += String.fromCharCode(bytes[i]);
|
|
1408
1434
|
}
|
|
1409
1435
|
return createSerovalNode(
|
|
1410
1436
|
19 /* ArrayBuffer */,
|
|
1411
1437
|
id,
|
|
1412
1438
|
serializeString(btoa(result)),
|
|
1413
|
-
len,
|
|
1414
1439
|
NIL,
|
|
1415
1440
|
NIL,
|
|
1416
1441
|
NIL,
|
|
@@ -1418,6 +1443,7 @@ function createArrayBufferNode(ctx, id, current) {
|
|
|
1418
1443
|
NIL,
|
|
1419
1444
|
parseSpecialReference(ctx, 5 /* ArrayBufferConstructor */),
|
|
1420
1445
|
NIL,
|
|
1446
|
+
NIL,
|
|
1421
1447
|
NIL
|
|
1422
1448
|
);
|
|
1423
1449
|
}
|
|
@@ -1430,32 +1456,35 @@ function createAsyncParserContext(mode, options) {
|
|
|
1430
1456
|
};
|
|
1431
1457
|
}
|
|
1432
1458
|
var AsyncParsePluginContext = class {
|
|
1433
|
-
constructor(_p) {
|
|
1459
|
+
constructor(_p, depth) {
|
|
1434
1460
|
this._p = _p;
|
|
1461
|
+
this.depth = depth;
|
|
1435
1462
|
}
|
|
1436
1463
|
parse(current) {
|
|
1437
|
-
return parseAsync(this._p, current);
|
|
1464
|
+
return parseAsync(this._p, this.depth, current);
|
|
1438
1465
|
}
|
|
1439
1466
|
};
|
|
1440
|
-
async function parseItems(ctx, current) {
|
|
1467
|
+
async function parseItems(ctx, depth, current) {
|
|
1441
1468
|
const nodes = [];
|
|
1442
1469
|
for (let i = 0, len = current.length; i < len; i++) {
|
|
1443
1470
|
if (i in current) {
|
|
1444
|
-
nodes[i] = await parseAsync(ctx, current[i]);
|
|
1471
|
+
nodes[i] = await parseAsync(ctx, depth, current[i]);
|
|
1472
|
+
} else {
|
|
1473
|
+
nodes[i] = 0;
|
|
1445
1474
|
}
|
|
1446
1475
|
}
|
|
1447
1476
|
return nodes;
|
|
1448
1477
|
}
|
|
1449
|
-
async function parseArray(ctx, id, current) {
|
|
1450
|
-
return createArrayNode(id, current, await parseItems(ctx, current));
|
|
1478
|
+
async function parseArray(ctx, depth, id, current) {
|
|
1479
|
+
return createArrayNode(id, current, await parseItems(ctx, depth, current));
|
|
1451
1480
|
}
|
|
1452
|
-
async function parseProperties(ctx, properties) {
|
|
1481
|
+
async function parseProperties(ctx, depth, properties) {
|
|
1453
1482
|
const entries = Object.entries(properties);
|
|
1454
1483
|
const keyNodes = [];
|
|
1455
1484
|
const valueNodes = [];
|
|
1456
1485
|
for (let i = 0, len = entries.length; i < len; i++) {
|
|
1457
1486
|
keyNodes.push(serializeString(entries[i][0]));
|
|
1458
|
-
valueNodes.push(await parseAsync(ctx, entries[i][1]));
|
|
1487
|
+
valueNodes.push(await parseAsync(ctx, depth, entries[i][1]));
|
|
1459
1488
|
}
|
|
1460
1489
|
if (SYM_ITERATOR in properties) {
|
|
1461
1490
|
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ITERATOR));
|
|
@@ -1464,6 +1493,7 @@ async function parseProperties(ctx, properties) {
|
|
|
1464
1493
|
parseIteratorFactory(ctx.base),
|
|
1465
1494
|
await parseAsync(
|
|
1466
1495
|
ctx,
|
|
1496
|
+
depth,
|
|
1467
1497
|
iteratorToSequence(properties)
|
|
1468
1498
|
)
|
|
1469
1499
|
)
|
|
@@ -1476,6 +1506,7 @@ async function parseProperties(ctx, properties) {
|
|
|
1476
1506
|
parseAsyncIteratorFactory(ctx.base),
|
|
1477
1507
|
await parseAsync(
|
|
1478
1508
|
ctx,
|
|
1509
|
+
depth,
|
|
1479
1510
|
createStreamFromAsyncIterable(
|
|
1480
1511
|
properties
|
|
1481
1512
|
)
|
|
@@ -1495,92 +1526,96 @@ async function parseProperties(ctx, properties) {
|
|
|
1495
1526
|
}
|
|
1496
1527
|
return {
|
|
1497
1528
|
k: keyNodes,
|
|
1498
|
-
v: valueNodes
|
|
1499
|
-
s: keyNodes.length
|
|
1529
|
+
v: valueNodes
|
|
1500
1530
|
};
|
|
1501
1531
|
}
|
|
1502
|
-
async function parsePlainObject(ctx, id, current, empty) {
|
|
1532
|
+
async function parsePlainObject(ctx, depth, id, current, empty) {
|
|
1503
1533
|
return createObjectNode(
|
|
1504
1534
|
id,
|
|
1505
1535
|
current,
|
|
1506
1536
|
empty,
|
|
1507
|
-
await parseProperties(ctx, current)
|
|
1537
|
+
await parseProperties(ctx, depth, current)
|
|
1508
1538
|
);
|
|
1509
1539
|
}
|
|
1510
|
-
async function parseBoxed(ctx, id, current) {
|
|
1511
|
-
return createBoxedNode(id, await parseAsync(ctx, current.valueOf()));
|
|
1540
|
+
async function parseBoxed(ctx, depth, id, current) {
|
|
1541
|
+
return createBoxedNode(id, await parseAsync(ctx, depth, current.valueOf()));
|
|
1512
1542
|
}
|
|
1513
|
-
async function parseTypedArray(ctx, id, current) {
|
|
1543
|
+
async function parseTypedArray(ctx, depth, id, current) {
|
|
1514
1544
|
return createTypedArrayNode(
|
|
1515
1545
|
id,
|
|
1516
1546
|
current,
|
|
1517
|
-
await parseAsync(ctx, current.buffer)
|
|
1547
|
+
await parseAsync(ctx, depth, current.buffer)
|
|
1518
1548
|
);
|
|
1519
1549
|
}
|
|
1520
|
-
async function parseBigIntTypedArray(ctx, id, current) {
|
|
1550
|
+
async function parseBigIntTypedArray(ctx, depth, id, current) {
|
|
1521
1551
|
return createBigIntTypedArrayNode(
|
|
1522
1552
|
id,
|
|
1523
1553
|
current,
|
|
1524
|
-
await parseAsync(ctx, current.buffer)
|
|
1554
|
+
await parseAsync(ctx, depth, current.buffer)
|
|
1525
1555
|
);
|
|
1526
1556
|
}
|
|
1527
|
-
async function parseDataView(ctx, id, current) {
|
|
1528
|
-
return createDataViewNode(
|
|
1557
|
+
async function parseDataView(ctx, depth, id, current) {
|
|
1558
|
+
return createDataViewNode(
|
|
1559
|
+
id,
|
|
1560
|
+
current,
|
|
1561
|
+
await parseAsync(ctx, depth, current.buffer)
|
|
1562
|
+
);
|
|
1529
1563
|
}
|
|
1530
|
-
async function parseError(ctx, id, current) {
|
|
1564
|
+
async function parseError(ctx, depth, id, current) {
|
|
1531
1565
|
const options = getErrorOptions(current, ctx.base.features);
|
|
1532
1566
|
return createErrorNode(
|
|
1533
1567
|
id,
|
|
1534
1568
|
current,
|
|
1535
|
-
options ? await parseProperties(ctx, options) : NIL
|
|
1569
|
+
options ? await parseProperties(ctx, depth, options) : NIL
|
|
1536
1570
|
);
|
|
1537
1571
|
}
|
|
1538
|
-
async function parseAggregateError(ctx, id, current) {
|
|
1572
|
+
async function parseAggregateError(ctx, depth, id, current) {
|
|
1539
1573
|
const options = getErrorOptions(current, ctx.base.features);
|
|
1540
1574
|
return createAggregateErrorNode(
|
|
1541
1575
|
id,
|
|
1542
1576
|
current,
|
|
1543
|
-
options ? await parseProperties(ctx, options) : NIL
|
|
1577
|
+
options ? await parseProperties(ctx, depth, options) : NIL
|
|
1544
1578
|
);
|
|
1545
1579
|
}
|
|
1546
|
-
async function parseMap(ctx, id, current) {
|
|
1580
|
+
async function parseMap(ctx, depth, id, current) {
|
|
1547
1581
|
const keyNodes = [];
|
|
1548
1582
|
const valueNodes = [];
|
|
1549
1583
|
for (const [key, value] of current.entries()) {
|
|
1550
|
-
keyNodes.push(await parseAsync(ctx, key));
|
|
1551
|
-
valueNodes.push(await parseAsync(ctx, value));
|
|
1584
|
+
keyNodes.push(await parseAsync(ctx, depth, key));
|
|
1585
|
+
valueNodes.push(await parseAsync(ctx, depth, value));
|
|
1552
1586
|
}
|
|
1553
|
-
return createMapNode(ctx.base, id, keyNodes, valueNodes
|
|
1587
|
+
return createMapNode(ctx.base, id, keyNodes, valueNodes);
|
|
1554
1588
|
}
|
|
1555
|
-
async function parseSet(ctx, id, current) {
|
|
1589
|
+
async function parseSet(ctx, depth, id, current) {
|
|
1556
1590
|
const items = [];
|
|
1557
1591
|
for (const item of current.keys()) {
|
|
1558
|
-
items.push(await parseAsync(ctx, item));
|
|
1592
|
+
items.push(await parseAsync(ctx, depth, item));
|
|
1559
1593
|
}
|
|
1560
|
-
return createSetNode(id,
|
|
1594
|
+
return createSetNode(id, items);
|
|
1561
1595
|
}
|
|
1562
|
-
async function parsePlugin(ctx, id, current) {
|
|
1596
|
+
async function parsePlugin(ctx, depth, id, current) {
|
|
1563
1597
|
const currentPlugins = ctx.base.plugins;
|
|
1564
1598
|
if (currentPlugins) {
|
|
1565
1599
|
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
1566
1600
|
const plugin = currentPlugins[i];
|
|
1567
1601
|
if (plugin.parse.async && plugin.test(current)) {
|
|
1568
|
-
if (ctx.child == null) {
|
|
1569
|
-
ctx.child = new AsyncParsePluginContext(ctx);
|
|
1570
|
-
}
|
|
1571
1602
|
return createPluginNode(
|
|
1572
1603
|
id,
|
|
1573
1604
|
plugin.tag,
|
|
1574
|
-
await plugin.parse.async(
|
|
1575
|
-
|
|
1576
|
-
|
|
1605
|
+
await plugin.parse.async(
|
|
1606
|
+
current,
|
|
1607
|
+
new AsyncParsePluginContext(ctx, depth),
|
|
1608
|
+
{
|
|
1609
|
+
id
|
|
1610
|
+
}
|
|
1611
|
+
)
|
|
1577
1612
|
);
|
|
1578
1613
|
}
|
|
1579
1614
|
}
|
|
1580
1615
|
}
|
|
1581
1616
|
return NIL;
|
|
1582
1617
|
}
|
|
1583
|
-
async function parsePromise(ctx, id, current) {
|
|
1618
|
+
async function parsePromise(ctx, depth, id, current) {
|
|
1584
1619
|
const [status, result] = await promiseToResult(current);
|
|
1585
1620
|
return createSerovalNode(
|
|
1586
1621
|
12 /* Promise */,
|
|
@@ -1591,18 +1626,18 @@ async function parsePromise(ctx, id, current) {
|
|
|
1591
1626
|
NIL,
|
|
1592
1627
|
NIL,
|
|
1593
1628
|
NIL,
|
|
1629
|
+
await parseAsync(ctx, depth, result),
|
|
1594
1630
|
NIL,
|
|
1595
|
-
await parseAsync(ctx, result),
|
|
1596
1631
|
NIL,
|
|
1597
1632
|
NIL
|
|
1598
1633
|
);
|
|
1599
1634
|
}
|
|
1600
|
-
function parseStreamHandle(id, current, resolve, reject) {
|
|
1635
|
+
function parseStreamHandle(depth, id, current, resolve, reject) {
|
|
1601
1636
|
const sequence = [];
|
|
1602
1637
|
const cleanup = current.on({
|
|
1603
1638
|
next: (value) => {
|
|
1604
1639
|
markParserRef(this.base, id);
|
|
1605
|
-
parseAsync(this, value).then(
|
|
1640
|
+
parseAsync(this, depth, value).then(
|
|
1606
1641
|
(data) => {
|
|
1607
1642
|
sequence.push(createStreamNextNode(id, data));
|
|
1608
1643
|
},
|
|
@@ -1614,7 +1649,7 @@ function parseStreamHandle(id, current, resolve, reject) {
|
|
|
1614
1649
|
},
|
|
1615
1650
|
throw: (value) => {
|
|
1616
1651
|
markParserRef(this.base, id);
|
|
1617
|
-
parseAsync(this, value).then(
|
|
1652
|
+
parseAsync(this, depth, value).then(
|
|
1618
1653
|
(data) => {
|
|
1619
1654
|
sequence.push(createStreamThrowNode(id, data));
|
|
1620
1655
|
resolve(sequence);
|
|
@@ -1628,7 +1663,7 @@ function parseStreamHandle(id, current, resolve, reject) {
|
|
|
1628
1663
|
},
|
|
1629
1664
|
return: (value) => {
|
|
1630
1665
|
markParserRef(this.base, id);
|
|
1631
|
-
parseAsync(this, value).then(
|
|
1666
|
+
parseAsync(this, depth, value).then(
|
|
1632
1667
|
(data) => {
|
|
1633
1668
|
sequence.push(createStreamReturnNode(id, data));
|
|
1634
1669
|
resolve(sequence);
|
|
@@ -1642,28 +1677,31 @@ function parseStreamHandle(id, current, resolve, reject) {
|
|
|
1642
1677
|
}
|
|
1643
1678
|
});
|
|
1644
1679
|
}
|
|
1645
|
-
async function parseStream(ctx, id, current) {
|
|
1680
|
+
async function parseStream(ctx, depth, id, current) {
|
|
1646
1681
|
return createStreamConstructorNode(
|
|
1647
1682
|
id,
|
|
1648
1683
|
parseSpecialReference(ctx.base, 4 /* StreamConstructor */),
|
|
1649
|
-
await new Promise(
|
|
1684
|
+
await new Promise(
|
|
1685
|
+
parseStreamHandle.bind(ctx, depth, id, current)
|
|
1686
|
+
)
|
|
1650
1687
|
);
|
|
1651
1688
|
}
|
|
1652
|
-
async function parseObjectAsync(ctx, id, current) {
|
|
1689
|
+
async function parseObjectAsync(ctx, depth, id, current) {
|
|
1653
1690
|
if (Array.isArray(current)) {
|
|
1654
|
-
return parseArray(ctx, id, current);
|
|
1691
|
+
return parseArray(ctx, depth, id, current);
|
|
1655
1692
|
}
|
|
1656
1693
|
if (isStream(current)) {
|
|
1657
|
-
return parseStream(ctx, id, current);
|
|
1694
|
+
return parseStream(ctx, depth, id, current);
|
|
1658
1695
|
}
|
|
1659
1696
|
const currentClass = current.constructor;
|
|
1660
1697
|
if (currentClass === OpaqueReference) {
|
|
1661
1698
|
return parseAsync(
|
|
1662
1699
|
ctx,
|
|
1700
|
+
depth,
|
|
1663
1701
|
current.replacement
|
|
1664
1702
|
);
|
|
1665
1703
|
}
|
|
1666
|
-
const parsed = await parsePlugin(ctx, id, current);
|
|
1704
|
+
const parsed = await parsePlugin(ctx, depth, id, current);
|
|
1667
1705
|
if (parsed) {
|
|
1668
1706
|
return parsed;
|
|
1669
1707
|
}
|
|
@@ -1671,6 +1709,7 @@ async function parseObjectAsync(ctx, id, current) {
|
|
|
1671
1709
|
case Object:
|
|
1672
1710
|
return parsePlainObject(
|
|
1673
1711
|
ctx,
|
|
1712
|
+
depth,
|
|
1674
1713
|
id,
|
|
1675
1714
|
current,
|
|
1676
1715
|
false
|
|
@@ -1678,14 +1717,13 @@ async function parseObjectAsync(ctx, id, current) {
|
|
|
1678
1717
|
case NIL:
|
|
1679
1718
|
return parsePlainObject(
|
|
1680
1719
|
ctx,
|
|
1720
|
+
depth,
|
|
1681
1721
|
id,
|
|
1682
1722
|
current,
|
|
1683
1723
|
true
|
|
1684
1724
|
);
|
|
1685
1725
|
case Date:
|
|
1686
1726
|
return createDateNode(id, current);
|
|
1687
|
-
case RegExp:
|
|
1688
|
-
return createRegExpNode(id, current);
|
|
1689
1727
|
case Error:
|
|
1690
1728
|
case EvalError:
|
|
1691
1729
|
case RangeError:
|
|
@@ -1693,12 +1731,12 @@ async function parseObjectAsync(ctx, id, current) {
|
|
|
1693
1731
|
case SyntaxError:
|
|
1694
1732
|
case TypeError:
|
|
1695
1733
|
case URIError:
|
|
1696
|
-
return parseError(ctx, id, current);
|
|
1734
|
+
return parseError(ctx, depth, id, current);
|
|
1697
1735
|
case Number:
|
|
1698
1736
|
case Boolean:
|
|
1699
1737
|
case String:
|
|
1700
1738
|
case BigInt:
|
|
1701
|
-
return parseBoxed(ctx, id, current);
|
|
1739
|
+
return parseBoxed(ctx, depth, id, current);
|
|
1702
1740
|
case ArrayBuffer:
|
|
1703
1741
|
return createArrayBufferNode(
|
|
1704
1742
|
ctx.base,
|
|
@@ -1714,26 +1752,40 @@ async function parseObjectAsync(ctx, id, current) {
|
|
|
1714
1752
|
case Uint8ClampedArray:
|
|
1715
1753
|
case Float32Array:
|
|
1716
1754
|
case Float64Array:
|
|
1717
|
-
return parseTypedArray(
|
|
1755
|
+
return parseTypedArray(
|
|
1756
|
+
ctx,
|
|
1757
|
+
depth,
|
|
1758
|
+
id,
|
|
1759
|
+
current
|
|
1760
|
+
);
|
|
1718
1761
|
case DataView:
|
|
1719
|
-
return parseDataView(ctx, id, current);
|
|
1762
|
+
return parseDataView(ctx, depth, id, current);
|
|
1720
1763
|
case Map:
|
|
1721
|
-
return parseMap(
|
|
1764
|
+
return parseMap(
|
|
1765
|
+
ctx,
|
|
1766
|
+
depth,
|
|
1767
|
+
id,
|
|
1768
|
+
current
|
|
1769
|
+
);
|
|
1722
1770
|
case Set:
|
|
1723
|
-
return parseSet(ctx, id, current);
|
|
1771
|
+
return parseSet(ctx, depth, id, current);
|
|
1724
1772
|
default:
|
|
1725
1773
|
break;
|
|
1726
1774
|
}
|
|
1727
1775
|
if (currentClass === Promise || current instanceof Promise) {
|
|
1728
|
-
return parsePromise(ctx, id, current);
|
|
1776
|
+
return parsePromise(ctx, depth, id, current);
|
|
1729
1777
|
}
|
|
1730
1778
|
const currentFeatures = ctx.base.features;
|
|
1779
|
+
if (currentFeatures & 32 /* RegExp */ && currentClass === RegExp) {
|
|
1780
|
+
return createRegExpNode(id, current);
|
|
1781
|
+
}
|
|
1731
1782
|
if (currentFeatures & 16 /* BigIntTypedArray */) {
|
|
1732
1783
|
switch (currentClass) {
|
|
1733
1784
|
case BigInt64Array:
|
|
1734
1785
|
case BigUint64Array:
|
|
1735
1786
|
return parseBigIntTypedArray(
|
|
1736
1787
|
ctx,
|
|
1788
|
+
depth,
|
|
1737
1789
|
id,
|
|
1738
1790
|
current
|
|
1739
1791
|
);
|
|
@@ -1742,28 +1794,33 @@ async function parseObjectAsync(ctx, id, current) {
|
|
|
1742
1794
|
}
|
|
1743
1795
|
}
|
|
1744
1796
|
if (currentFeatures & 1 /* AggregateError */ && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
1745
|
-
return parseAggregateError(
|
|
1797
|
+
return parseAggregateError(
|
|
1798
|
+
ctx,
|
|
1799
|
+
depth,
|
|
1800
|
+
id,
|
|
1801
|
+
current
|
|
1802
|
+
);
|
|
1746
1803
|
}
|
|
1747
1804
|
if (current instanceof Error) {
|
|
1748
|
-
return parseError(ctx, id, current);
|
|
1805
|
+
return parseError(ctx, depth, id, current);
|
|
1749
1806
|
}
|
|
1750
1807
|
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) {
|
|
1751
|
-
return parsePlainObject(ctx, id, current, !!currentClass);
|
|
1808
|
+
return parsePlainObject(ctx, depth, id, current, !!currentClass);
|
|
1752
1809
|
}
|
|
1753
1810
|
throw new SerovalUnsupportedTypeError(current);
|
|
1754
1811
|
}
|
|
1755
|
-
async function parseFunctionAsync(ctx, current) {
|
|
1812
|
+
async function parseFunctionAsync(ctx, depth, current) {
|
|
1756
1813
|
const ref = getReferenceNode(ctx.base, current);
|
|
1757
1814
|
if (ref.type !== 0 /* Fresh */) {
|
|
1758
1815
|
return ref.value;
|
|
1759
1816
|
}
|
|
1760
|
-
const plugin = await parsePlugin(ctx, ref.value, current);
|
|
1817
|
+
const plugin = await parsePlugin(ctx, depth, ref.value, current);
|
|
1761
1818
|
if (plugin) {
|
|
1762
1819
|
return plugin;
|
|
1763
1820
|
}
|
|
1764
1821
|
throw new SerovalUnsupportedTypeError(current);
|
|
1765
1822
|
}
|
|
1766
|
-
async function parseAsync(ctx, current) {
|
|
1823
|
+
async function parseAsync(ctx, depth, current) {
|
|
1767
1824
|
switch (typeof current) {
|
|
1768
1825
|
case "boolean":
|
|
1769
1826
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
@@ -1778,21 +1835,21 @@ async function parseAsync(ctx, current) {
|
|
|
1778
1835
|
case "object": {
|
|
1779
1836
|
if (current) {
|
|
1780
1837
|
const ref = getReferenceNode(ctx.base, current);
|
|
1781
|
-
return ref.type === 0 ? await parseObjectAsync(ctx, ref.value, current) : ref.value;
|
|
1838
|
+
return ref.type === 0 ? await parseObjectAsync(ctx, depth + 1, ref.value, current) : ref.value;
|
|
1782
1839
|
}
|
|
1783
1840
|
return NULL_NODE;
|
|
1784
1841
|
}
|
|
1785
1842
|
case "symbol":
|
|
1786
1843
|
return parseWellKnownSymbol(ctx.base, current);
|
|
1787
1844
|
case "function":
|
|
1788
|
-
return parseFunctionAsync(ctx, current);
|
|
1845
|
+
return parseFunctionAsync(ctx, depth, current);
|
|
1789
1846
|
default:
|
|
1790
1847
|
throw new SerovalUnsupportedTypeError(current);
|
|
1791
1848
|
}
|
|
1792
1849
|
}
|
|
1793
1850
|
async function parseTopAsync(ctx, current) {
|
|
1794
1851
|
try {
|
|
1795
|
-
return await parseAsync(ctx, current);
|
|
1852
|
+
return await parseAsync(ctx, 0, current);
|
|
1796
1853
|
} catch (error) {
|
|
1797
1854
|
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
1798
1855
|
}
|
|
@@ -1858,6 +1915,9 @@ function getTypedArrayConstructor(name) {
|
|
|
1858
1915
|
}
|
|
1859
1916
|
|
|
1860
1917
|
// src/core/context/deserializer.ts
|
|
1918
|
+
var MAX_BASE64_LENGTH = 1e6;
|
|
1919
|
+
var MAX_BIGINT_LENGTH = 1e4;
|
|
1920
|
+
var MAX_REGEXP_SOURCE_LENGTH = 2e4;
|
|
1861
1921
|
function applyObjectFlag(obj, flag) {
|
|
1862
1922
|
switch (flag) {
|
|
1863
1923
|
case 3 /* Frozen */:
|
|
@@ -1870,18 +1930,22 @@ function applyObjectFlag(obj, flag) {
|
|
|
1870
1930
|
return obj;
|
|
1871
1931
|
}
|
|
1872
1932
|
}
|
|
1933
|
+
var DEFAULT_DEPTH_LIMIT = 1e3;
|
|
1873
1934
|
function createBaseDeserializerContext(mode, options) {
|
|
1935
|
+
var _a;
|
|
1874
1936
|
return {
|
|
1875
1937
|
mode,
|
|
1876
1938
|
plugins: options.plugins,
|
|
1877
|
-
refs: options.refs || /* @__PURE__ */ new Map()
|
|
1939
|
+
refs: options.refs || /* @__PURE__ */ new Map(),
|
|
1940
|
+
features: (_a = options.features) != null ? _a : ALL_ENABLED ^ (options.disabledFeatures || 0),
|
|
1941
|
+
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT
|
|
1878
1942
|
};
|
|
1879
1943
|
}
|
|
1880
1944
|
function createVanillaDeserializerContext(options) {
|
|
1881
1945
|
return {
|
|
1882
1946
|
mode: 1 /* Vanilla */,
|
|
1883
1947
|
base: createBaseDeserializerContext(1 /* Vanilla */, options),
|
|
1884
|
-
child:
|
|
1948
|
+
child: NIL,
|
|
1885
1949
|
state: {
|
|
1886
1950
|
marked: new Set(options.markedRefs)
|
|
1887
1951
|
}
|
|
@@ -1891,32 +1955,50 @@ function createCrossDeserializerContext(options) {
|
|
|
1891
1955
|
return {
|
|
1892
1956
|
mode: 2 /* Cross */,
|
|
1893
1957
|
base: createBaseDeserializerContext(2 /* Cross */, options),
|
|
1894
|
-
child:
|
|
1958
|
+
child: NIL
|
|
1895
1959
|
};
|
|
1896
1960
|
}
|
|
1897
1961
|
var DeserializePluginContext = class {
|
|
1898
|
-
constructor(_p) {
|
|
1962
|
+
constructor(_p, depth) {
|
|
1899
1963
|
this._p = _p;
|
|
1964
|
+
this.depth = depth;
|
|
1900
1965
|
}
|
|
1901
1966
|
deserialize(node) {
|
|
1902
|
-
return deserialize(this._p, node);
|
|
1967
|
+
return deserialize(this._p, this.depth, node);
|
|
1903
1968
|
}
|
|
1904
1969
|
};
|
|
1970
|
+
function guardIndexedValue(ctx, id) {
|
|
1971
|
+
if (id < 0 || !Number.isFinite(id) || !Number.isInteger(id)) {
|
|
1972
|
+
throw new SerovalMalformedNodeError({
|
|
1973
|
+
t: 4 /* IndexedValue */,
|
|
1974
|
+
i: id
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
if (ctx.refs.has(id)) {
|
|
1978
|
+
throw new Error("Conflicted ref id: " + id);
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1905
1981
|
function assignIndexedValueVanilla(ctx, id, value) {
|
|
1982
|
+
guardIndexedValue(ctx.base, id);
|
|
1906
1983
|
if (ctx.state.marked.has(id)) {
|
|
1907
1984
|
ctx.base.refs.set(id, value);
|
|
1908
1985
|
}
|
|
1909
1986
|
return value;
|
|
1910
1987
|
}
|
|
1911
1988
|
function assignIndexedValueCross(ctx, id, value) {
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1989
|
+
guardIndexedValue(ctx.base, id);
|
|
1990
|
+
ctx.base.refs.set(id, value);
|
|
1915
1991
|
return value;
|
|
1916
1992
|
}
|
|
1917
1993
|
function assignIndexedValue(ctx, id, value) {
|
|
1918
1994
|
return ctx.mode === 1 /* Vanilla */ ? assignIndexedValueVanilla(ctx, id, value) : assignIndexedValueCross(ctx, id, value);
|
|
1919
1995
|
}
|
|
1996
|
+
function deserializeKnownValue(node, record, key) {
|
|
1997
|
+
if (Object.hasOwn(record, key)) {
|
|
1998
|
+
return record[key];
|
|
1999
|
+
}
|
|
2000
|
+
throw new SerovalMalformedNodeError(node);
|
|
2001
|
+
}
|
|
1920
2002
|
function deserializeReference(ctx, node) {
|
|
1921
2003
|
return assignIndexedValue(
|
|
1922
2004
|
ctx,
|
|
@@ -1924,46 +2006,96 @@ function deserializeReference(ctx, node) {
|
|
|
1924
2006
|
getReference(deserializeString(node.s))
|
|
1925
2007
|
);
|
|
1926
2008
|
}
|
|
1927
|
-
function deserializeArray(ctx, node) {
|
|
1928
|
-
const
|
|
2009
|
+
function deserializeArray(ctx, depth, node) {
|
|
2010
|
+
const items = node.a;
|
|
2011
|
+
const len = items.length;
|
|
1929
2012
|
const result = assignIndexedValue(
|
|
1930
2013
|
ctx,
|
|
1931
2014
|
node.i,
|
|
1932
2015
|
new Array(len)
|
|
1933
2016
|
);
|
|
1934
|
-
let item;
|
|
1935
|
-
|
|
1936
|
-
item = node.a[i];
|
|
2017
|
+
for (let i = 0, item; i < len; i++) {
|
|
2018
|
+
item = items[i];
|
|
1937
2019
|
if (item) {
|
|
1938
|
-
result[i] = deserialize(ctx, item);
|
|
2020
|
+
result[i] = deserialize(ctx, depth, item);
|
|
1939
2021
|
}
|
|
1940
2022
|
}
|
|
1941
2023
|
applyObjectFlag(result, node.o);
|
|
1942
2024
|
return result;
|
|
1943
2025
|
}
|
|
1944
|
-
function
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2026
|
+
function isValidKey(key) {
|
|
2027
|
+
switch (key) {
|
|
2028
|
+
case "constructor":
|
|
2029
|
+
case "__proto__":
|
|
2030
|
+
case "prototype":
|
|
2031
|
+
case "__defineGetter__":
|
|
2032
|
+
case "__defineSetter__":
|
|
2033
|
+
case "__lookupGetter__":
|
|
2034
|
+
case "__lookupSetter__":
|
|
2035
|
+
return false;
|
|
2036
|
+
default:
|
|
2037
|
+
return true;
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
function isValidSymbol(symbol) {
|
|
2041
|
+
switch (symbol) {
|
|
2042
|
+
case SYM_ASYNC_ITERATOR:
|
|
2043
|
+
case SYM_IS_CONCAT_SPREADABLE:
|
|
2044
|
+
case SYM_TO_STRING_TAG:
|
|
2045
|
+
case SYM_ITERATOR:
|
|
2046
|
+
return true;
|
|
2047
|
+
default:
|
|
2048
|
+
return false;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
function assignStringProperty(object, key, value) {
|
|
2052
|
+
if (isValidKey(key)) {
|
|
2053
|
+
object[key] = value;
|
|
2054
|
+
} else {
|
|
2055
|
+
Object.defineProperty(object, key, {
|
|
2056
|
+
value,
|
|
2057
|
+
configurable: true,
|
|
2058
|
+
enumerable: true,
|
|
2059
|
+
writable: true
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
function assignProperty(ctx, depth, object, key, value) {
|
|
2064
|
+
if (typeof key === "string") {
|
|
2065
|
+
assignStringProperty(object, key, deserialize(ctx, depth, value));
|
|
2066
|
+
} else {
|
|
2067
|
+
const actual = deserialize(ctx, depth, key);
|
|
2068
|
+
switch (typeof actual) {
|
|
2069
|
+
case "string":
|
|
2070
|
+
assignStringProperty(object, actual, deserialize(ctx, depth, value));
|
|
2071
|
+
break;
|
|
2072
|
+
case "symbol":
|
|
2073
|
+
if (isValidSymbol(actual)) {
|
|
2074
|
+
object[actual] = deserialize(ctx, depth, value);
|
|
2075
|
+
}
|
|
2076
|
+
break;
|
|
2077
|
+
default:
|
|
2078
|
+
throw new SerovalMalformedNodeError(key);
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
function deserializeProperties(ctx, depth, node, result) {
|
|
2083
|
+
const keys = node.k;
|
|
2084
|
+
const len = keys.length;
|
|
2085
|
+
if (len > 0) {
|
|
2086
|
+
for (let i = 0, vals = node.v, len2 = keys.length; i < len2; i++) {
|
|
2087
|
+
assignProperty(ctx, depth, result, keys[i], vals[i]);
|
|
1956
2088
|
}
|
|
1957
2089
|
}
|
|
1958
2090
|
return result;
|
|
1959
2091
|
}
|
|
1960
|
-
function deserializeObject(ctx, node) {
|
|
2092
|
+
function deserializeObject(ctx, depth, node) {
|
|
1961
2093
|
const result = assignIndexedValue(
|
|
1962
2094
|
ctx,
|
|
1963
2095
|
node.i,
|
|
1964
2096
|
node.t === 10 /* Object */ ? {} : /* @__PURE__ */ Object.create(null)
|
|
1965
2097
|
);
|
|
1966
|
-
deserializeProperties(ctx, node.p, result);
|
|
2098
|
+
deserializeProperties(ctx, depth, node.p, result);
|
|
1967
2099
|
applyObjectFlag(result, node.o);
|
|
1968
2100
|
return result;
|
|
1969
2101
|
}
|
|
@@ -1971,84 +2103,100 @@ function deserializeDate(ctx, node) {
|
|
|
1971
2103
|
return assignIndexedValue(ctx, node.i, new Date(node.s));
|
|
1972
2104
|
}
|
|
1973
2105
|
function deserializeRegExp(ctx, node) {
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2106
|
+
if (ctx.base.features & 32 /* RegExp */) {
|
|
2107
|
+
const source = deserializeString(node.c);
|
|
2108
|
+
if (source.length > MAX_REGEXP_SOURCE_LENGTH) {
|
|
2109
|
+
throw new SerovalMalformedNodeError(node);
|
|
2110
|
+
}
|
|
2111
|
+
return assignIndexedValue(ctx, node.i, new RegExp(source, node.m));
|
|
2112
|
+
}
|
|
2113
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
1979
2114
|
}
|
|
1980
|
-
function deserializeSet(ctx, node) {
|
|
2115
|
+
function deserializeSet(ctx, depth, node) {
|
|
1981
2116
|
const result = assignIndexedValue(ctx, node.i, /* @__PURE__ */ new Set());
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
result.add(deserialize(ctx, items[i]));
|
|
2117
|
+
for (let i = 0, items = node.a, len = items.length; i < len; i++) {
|
|
2118
|
+
result.add(deserialize(ctx, depth, items[i]));
|
|
1985
2119
|
}
|
|
1986
2120
|
return result;
|
|
1987
2121
|
}
|
|
1988
|
-
function deserializeMap(ctx, node) {
|
|
2122
|
+
function deserializeMap(ctx, depth, node) {
|
|
1989
2123
|
const result = assignIndexedValue(ctx, node.i, /* @__PURE__ */ new Map());
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2124
|
+
for (let i = 0, keys = node.e.k, vals = node.e.v, len = keys.length; i < len; i++) {
|
|
2125
|
+
result.set(
|
|
2126
|
+
deserialize(ctx, depth, keys[i]),
|
|
2127
|
+
deserialize(ctx, depth, vals[i])
|
|
2128
|
+
);
|
|
1994
2129
|
}
|
|
1995
2130
|
return result;
|
|
1996
2131
|
}
|
|
1997
2132
|
function deserializeArrayBuffer(ctx, node) {
|
|
2133
|
+
if (node.s.length > MAX_BASE64_LENGTH) {
|
|
2134
|
+
throw new SerovalMalformedNodeError(node);
|
|
2135
|
+
}
|
|
1998
2136
|
const result = assignIndexedValue(
|
|
1999
2137
|
ctx,
|
|
2000
2138
|
node.i,
|
|
2001
|
-
ARRAY_BUFFER_CONSTRUCTOR(
|
|
2139
|
+
ARRAY_BUFFER_CONSTRUCTOR(deserializeString(node.s))
|
|
2002
2140
|
);
|
|
2003
2141
|
return result;
|
|
2004
2142
|
}
|
|
2005
|
-
function deserializeTypedArray(ctx, node) {
|
|
2143
|
+
function deserializeTypedArray(ctx, depth, node) {
|
|
2144
|
+
var _a;
|
|
2006
2145
|
const construct = getTypedArrayConstructor(node.c);
|
|
2007
|
-
const source = deserialize(ctx, node.f);
|
|
2146
|
+
const source = deserialize(ctx, depth, node.f);
|
|
2147
|
+
const offset = (_a = node.b) != null ? _a : 0;
|
|
2148
|
+
if (offset < 0 || offset > source.byteLength) {
|
|
2149
|
+
throw new SerovalMalformedNodeError(node);
|
|
2150
|
+
}
|
|
2008
2151
|
const result = assignIndexedValue(
|
|
2009
2152
|
ctx,
|
|
2010
2153
|
node.i,
|
|
2011
|
-
new construct(source,
|
|
2154
|
+
new construct(source, offset, node.l)
|
|
2012
2155
|
);
|
|
2013
2156
|
return result;
|
|
2014
2157
|
}
|
|
2015
|
-
function deserializeDataView(ctx, node) {
|
|
2016
|
-
|
|
2158
|
+
function deserializeDataView(ctx, depth, node) {
|
|
2159
|
+
var _a;
|
|
2160
|
+
const source = deserialize(ctx, depth, node.f);
|
|
2161
|
+
const offset = (_a = node.b) != null ? _a : 0;
|
|
2162
|
+
if (offset < 0 || offset > source.byteLength) {
|
|
2163
|
+
throw new SerovalMalformedNodeError(node);
|
|
2164
|
+
}
|
|
2017
2165
|
const result = assignIndexedValue(
|
|
2018
2166
|
ctx,
|
|
2019
2167
|
node.i,
|
|
2020
|
-
new DataView(source,
|
|
2168
|
+
new DataView(source, offset, node.l)
|
|
2021
2169
|
);
|
|
2022
2170
|
return result;
|
|
2023
2171
|
}
|
|
2024
|
-
function deserializeDictionary(ctx, node, result) {
|
|
2172
|
+
function deserializeDictionary(ctx, depth, node, result) {
|
|
2025
2173
|
if (node.p) {
|
|
2026
|
-
const fields = deserializeProperties(ctx, node.p, {});
|
|
2027
|
-
Object.
|
|
2174
|
+
const fields = deserializeProperties(ctx, depth, node.p, {});
|
|
2175
|
+
Object.defineProperties(result, Object.getOwnPropertyDescriptors(fields));
|
|
2028
2176
|
}
|
|
2029
2177
|
return result;
|
|
2030
2178
|
}
|
|
2031
|
-
function deserializeAggregateError(ctx, node) {
|
|
2179
|
+
function deserializeAggregateError(ctx, depth, node) {
|
|
2032
2180
|
const result = assignIndexedValue(
|
|
2033
2181
|
ctx,
|
|
2034
2182
|
node.i,
|
|
2035
2183
|
new AggregateError([], deserializeString(node.m))
|
|
2036
2184
|
);
|
|
2037
|
-
return deserializeDictionary(ctx, node, result);
|
|
2185
|
+
return deserializeDictionary(ctx, depth, node, result);
|
|
2038
2186
|
}
|
|
2039
|
-
function deserializeError(ctx, node) {
|
|
2040
|
-
const construct = ERROR_CONSTRUCTOR
|
|
2187
|
+
function deserializeError(ctx, depth, node) {
|
|
2188
|
+
const construct = deserializeKnownValue(node, ERROR_CONSTRUCTOR, node.s);
|
|
2041
2189
|
const result = assignIndexedValue(
|
|
2042
2190
|
ctx,
|
|
2043
2191
|
node.i,
|
|
2044
2192
|
new construct(deserializeString(node.m))
|
|
2045
2193
|
);
|
|
2046
|
-
return deserializeDictionary(ctx, node, result);
|
|
2194
|
+
return deserializeDictionary(ctx, depth, node, result);
|
|
2047
2195
|
}
|
|
2048
|
-
function deserializePromise(ctx, node) {
|
|
2196
|
+
function deserializePromise(ctx, depth, node) {
|
|
2049
2197
|
const deferred = PROMISE_CONSTRUCTOR();
|
|
2050
2198
|
const result = assignIndexedValue(ctx, node.i, deferred.p);
|
|
2051
|
-
const deserialized = deserialize(ctx, node.f);
|
|
2199
|
+
const deserialized = deserialize(ctx, depth, node.f);
|
|
2052
2200
|
if (node.s) {
|
|
2053
2201
|
deferred.s(deserialized);
|
|
2054
2202
|
} else {
|
|
@@ -2056,23 +2204,25 @@ function deserializePromise(ctx, node) {
|
|
|
2056
2204
|
}
|
|
2057
2205
|
return result;
|
|
2058
2206
|
}
|
|
2059
|
-
function deserializeBoxed(ctx, node) {
|
|
2060
|
-
return assignIndexedValue(
|
|
2207
|
+
function deserializeBoxed(ctx, depth, node) {
|
|
2208
|
+
return assignIndexedValue(
|
|
2209
|
+
ctx,
|
|
2210
|
+
node.i,
|
|
2211
|
+
// biome-ignore lint/style/useConsistentBuiltinInstantiation: intended
|
|
2212
|
+
Object(deserialize(ctx, depth, node.f))
|
|
2213
|
+
);
|
|
2061
2214
|
}
|
|
2062
|
-
function deserializePlugin(ctx, node) {
|
|
2215
|
+
function deserializePlugin(ctx, depth, node) {
|
|
2063
2216
|
const currentPlugins = ctx.base.plugins;
|
|
2064
2217
|
if (currentPlugins) {
|
|
2065
2218
|
const tag = deserializeString(node.c);
|
|
2066
2219
|
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
2067
2220
|
const plugin = currentPlugins[i];
|
|
2068
2221
|
if (plugin.tag === tag) {
|
|
2069
|
-
if (ctx.child == null) {
|
|
2070
|
-
ctx.child = new DeserializePluginContext(ctx);
|
|
2071
|
-
}
|
|
2072
2222
|
return assignIndexedValue(
|
|
2073
2223
|
ctx,
|
|
2074
2224
|
node.i,
|
|
2075
|
-
plugin.deserialize(node.s, ctx
|
|
2225
|
+
plugin.deserialize(node.s, new DeserializePluginContext(ctx, depth), {
|
|
2076
2226
|
id: node.i
|
|
2077
2227
|
})
|
|
2078
2228
|
);
|
|
@@ -2088,142 +2238,150 @@ function deserializePromiseConstructor(ctx, node) {
|
|
|
2088
2238
|
assignIndexedValue(ctx, node.s, PROMISE_CONSTRUCTOR()).p
|
|
2089
2239
|
);
|
|
2090
2240
|
}
|
|
2091
|
-
function deserializePromiseResolve(ctx, node) {
|
|
2241
|
+
function deserializePromiseResolve(ctx, depth, node) {
|
|
2092
2242
|
const deferred = ctx.base.refs.get(node.i);
|
|
2093
2243
|
if (deferred) {
|
|
2094
|
-
deferred.s(deserialize(ctx, node.a[1]));
|
|
2095
|
-
return
|
|
2244
|
+
deferred.s(deserialize(ctx, depth, node.a[1]));
|
|
2245
|
+
return NIL;
|
|
2096
2246
|
}
|
|
2097
2247
|
throw new SerovalMissingInstanceError("Promise");
|
|
2098
2248
|
}
|
|
2099
|
-
function deserializePromiseReject(ctx, node) {
|
|
2249
|
+
function deserializePromiseReject(ctx, depth, node) {
|
|
2100
2250
|
const deferred = ctx.base.refs.get(node.i);
|
|
2101
2251
|
if (deferred) {
|
|
2102
|
-
deferred.f(deserialize(ctx, node.a[1]));
|
|
2103
|
-
return
|
|
2252
|
+
deferred.f(deserialize(ctx, depth, node.a[1]));
|
|
2253
|
+
return NIL;
|
|
2104
2254
|
}
|
|
2105
2255
|
throw new SerovalMissingInstanceError("Promise");
|
|
2106
2256
|
}
|
|
2107
|
-
function deserializeIteratorFactoryInstance(ctx, node) {
|
|
2108
|
-
deserialize(ctx, node.a[0]);
|
|
2109
|
-
const source = deserialize(ctx, node.a[1]);
|
|
2257
|
+
function deserializeIteratorFactoryInstance(ctx, depth, node) {
|
|
2258
|
+
deserialize(ctx, depth, node.a[0]);
|
|
2259
|
+
const source = deserialize(ctx, depth, node.a[1]);
|
|
2110
2260
|
return sequenceToIterator(source);
|
|
2111
2261
|
}
|
|
2112
|
-
function deserializeAsyncIteratorFactoryInstance(ctx, node) {
|
|
2113
|
-
deserialize(ctx, node.a[0]);
|
|
2114
|
-
const source = deserialize(ctx, node.a[1]);
|
|
2262
|
+
function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
|
|
2263
|
+
deserialize(ctx, depth, node.a[0]);
|
|
2264
|
+
const source = deserialize(ctx, depth, node.a[1]);
|
|
2115
2265
|
return streamToAsyncIterable(source);
|
|
2116
2266
|
}
|
|
2117
|
-
function deserializeStreamConstructor(ctx, node) {
|
|
2267
|
+
function deserializeStreamConstructor(ctx, depth, node) {
|
|
2118
2268
|
const result = assignIndexedValue(ctx, node.i, createStream());
|
|
2119
|
-
const
|
|
2269
|
+
const items = node.a;
|
|
2270
|
+
const len = items.length;
|
|
2120
2271
|
if (len) {
|
|
2121
2272
|
for (let i = 0; i < len; i++) {
|
|
2122
|
-
deserialize(ctx,
|
|
2273
|
+
deserialize(ctx, depth, items[i]);
|
|
2123
2274
|
}
|
|
2124
2275
|
}
|
|
2125
2276
|
return result;
|
|
2126
2277
|
}
|
|
2127
|
-
function deserializeStreamNext(ctx, node) {
|
|
2278
|
+
function deserializeStreamNext(ctx, depth, node) {
|
|
2128
2279
|
const deferred = ctx.base.refs.get(node.i);
|
|
2129
|
-
if (deferred) {
|
|
2130
|
-
deferred.next(deserialize(ctx, node.f));
|
|
2131
|
-
return
|
|
2280
|
+
if (deferred && isStream(deferred)) {
|
|
2281
|
+
deferred.next(deserialize(ctx, depth, node.f));
|
|
2282
|
+
return NIL;
|
|
2132
2283
|
}
|
|
2133
2284
|
throw new SerovalMissingInstanceError("Stream");
|
|
2134
2285
|
}
|
|
2135
|
-
function deserializeStreamThrow(ctx, node) {
|
|
2286
|
+
function deserializeStreamThrow(ctx, depth, node) {
|
|
2136
2287
|
const deferred = ctx.base.refs.get(node.i);
|
|
2137
|
-
if (deferred) {
|
|
2138
|
-
deferred.throw(deserialize(ctx, node.f));
|
|
2139
|
-
return
|
|
2288
|
+
if (deferred && isStream(deferred)) {
|
|
2289
|
+
deferred.throw(deserialize(ctx, depth, node.f));
|
|
2290
|
+
return NIL;
|
|
2140
2291
|
}
|
|
2141
2292
|
throw new SerovalMissingInstanceError("Stream");
|
|
2142
2293
|
}
|
|
2143
|
-
function deserializeStreamReturn(ctx, node) {
|
|
2294
|
+
function deserializeStreamReturn(ctx, depth, node) {
|
|
2144
2295
|
const deferred = ctx.base.refs.get(node.i);
|
|
2145
|
-
if (deferred) {
|
|
2146
|
-
deferred.return(deserialize(ctx, node.f));
|
|
2147
|
-
return
|
|
2296
|
+
if (deferred && isStream(deferred)) {
|
|
2297
|
+
deferred.return(deserialize(ctx, depth, node.f));
|
|
2298
|
+
return NIL;
|
|
2148
2299
|
}
|
|
2149
2300
|
throw new SerovalMissingInstanceError("Stream");
|
|
2150
2301
|
}
|
|
2151
|
-
function deserializeIteratorFactory(ctx, node) {
|
|
2152
|
-
deserialize(ctx, node.f);
|
|
2153
|
-
return
|
|
2302
|
+
function deserializeIteratorFactory(ctx, depth, node) {
|
|
2303
|
+
deserialize(ctx, depth, node.f);
|
|
2304
|
+
return NIL;
|
|
2154
2305
|
}
|
|
2155
|
-
function deserializeAsyncIteratorFactory(ctx, node) {
|
|
2156
|
-
deserialize(ctx, node.a[1]);
|
|
2157
|
-
return
|
|
2306
|
+
function deserializeAsyncIteratorFactory(ctx, depth, node) {
|
|
2307
|
+
deserialize(ctx, depth, node.a[1]);
|
|
2308
|
+
return NIL;
|
|
2158
2309
|
}
|
|
2159
|
-
function deserialize(ctx, node) {
|
|
2310
|
+
function deserialize(ctx, depth, node) {
|
|
2311
|
+
if (depth > ctx.base.depthLimit) {
|
|
2312
|
+
throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
2313
|
+
}
|
|
2314
|
+
depth += 1;
|
|
2160
2315
|
switch (node.t) {
|
|
2161
2316
|
case 2 /* Constant */:
|
|
2162
|
-
return CONSTANT_VAL
|
|
2317
|
+
return deserializeKnownValue(node, CONSTANT_VAL, node.s);
|
|
2163
2318
|
case 0 /* Number */:
|
|
2164
|
-
return node.s;
|
|
2319
|
+
return Number(node.s);
|
|
2165
2320
|
case 1 /* String */:
|
|
2166
|
-
return deserializeString(node.s);
|
|
2321
|
+
return deserializeString(String(node.s));
|
|
2167
2322
|
case 3 /* BigInt */:
|
|
2323
|
+
if (String(node.s).length > MAX_BIGINT_LENGTH) {
|
|
2324
|
+
throw new SerovalMalformedNodeError(node);
|
|
2325
|
+
}
|
|
2168
2326
|
return BigInt(node.s);
|
|
2169
2327
|
case 4 /* IndexedValue */:
|
|
2170
2328
|
return ctx.base.refs.get(node.i);
|
|
2171
2329
|
case 18 /* Reference */:
|
|
2172
2330
|
return deserializeReference(ctx, node);
|
|
2173
2331
|
case 9 /* Array */:
|
|
2174
|
-
return deserializeArray(ctx, node);
|
|
2332
|
+
return deserializeArray(ctx, depth, node);
|
|
2175
2333
|
case 10 /* Object */:
|
|
2176
2334
|
case 11 /* NullConstructor */:
|
|
2177
|
-
return deserializeObject(ctx, node);
|
|
2335
|
+
return deserializeObject(ctx, depth, node);
|
|
2178
2336
|
case 5 /* Date */:
|
|
2179
2337
|
return deserializeDate(ctx, node);
|
|
2180
2338
|
case 6 /* RegExp */:
|
|
2181
2339
|
return deserializeRegExp(ctx, node);
|
|
2182
2340
|
case 7 /* Set */:
|
|
2183
|
-
return deserializeSet(ctx, node);
|
|
2341
|
+
return deserializeSet(ctx, depth, node);
|
|
2184
2342
|
case 8 /* Map */:
|
|
2185
|
-
return deserializeMap(ctx, node);
|
|
2343
|
+
return deserializeMap(ctx, depth, node);
|
|
2186
2344
|
case 19 /* ArrayBuffer */:
|
|
2187
2345
|
return deserializeArrayBuffer(ctx, node);
|
|
2188
2346
|
case 16 /* BigIntTypedArray */:
|
|
2189
2347
|
case 15 /* TypedArray */:
|
|
2190
|
-
return deserializeTypedArray(ctx, node);
|
|
2348
|
+
return deserializeTypedArray(ctx, depth, node);
|
|
2191
2349
|
case 20 /* DataView */:
|
|
2192
|
-
return deserializeDataView(ctx, node);
|
|
2350
|
+
return deserializeDataView(ctx, depth, node);
|
|
2193
2351
|
case 14 /* AggregateError */:
|
|
2194
|
-
return deserializeAggregateError(ctx, node);
|
|
2352
|
+
return deserializeAggregateError(ctx, depth, node);
|
|
2195
2353
|
case 13 /* Error */:
|
|
2196
|
-
return deserializeError(ctx, node);
|
|
2354
|
+
return deserializeError(ctx, depth, node);
|
|
2197
2355
|
case 12 /* Promise */:
|
|
2198
|
-
return deserializePromise(ctx, node);
|
|
2356
|
+
return deserializePromise(ctx, depth, node);
|
|
2199
2357
|
case 17 /* WKSymbol */:
|
|
2200
|
-
return SYMBOL_REF
|
|
2358
|
+
return deserializeKnownValue(node, SYMBOL_REF, node.s);
|
|
2201
2359
|
case 21 /* Boxed */:
|
|
2202
|
-
return deserializeBoxed(ctx, node);
|
|
2360
|
+
return deserializeBoxed(ctx, depth, node);
|
|
2203
2361
|
case 25 /* Plugin */:
|
|
2204
|
-
return deserializePlugin(ctx, node);
|
|
2362
|
+
return deserializePlugin(ctx, depth, node);
|
|
2205
2363
|
case 22 /* PromiseConstructor */:
|
|
2206
2364
|
return deserializePromiseConstructor(ctx, node);
|
|
2207
2365
|
case 23 /* PromiseSuccess */:
|
|
2208
|
-
return deserializePromiseResolve(ctx, node);
|
|
2366
|
+
return deserializePromiseResolve(ctx, depth, node);
|
|
2209
2367
|
case 24 /* PromiseFailure */:
|
|
2210
|
-
return deserializePromiseReject(ctx, node);
|
|
2368
|
+
return deserializePromiseReject(ctx, depth, node);
|
|
2211
2369
|
case 28 /* IteratorFactoryInstance */:
|
|
2212
|
-
return deserializeIteratorFactoryInstance(ctx, node);
|
|
2370
|
+
return deserializeIteratorFactoryInstance(ctx, depth, node);
|
|
2213
2371
|
case 30 /* AsyncIteratorFactoryInstance */:
|
|
2214
|
-
return deserializeAsyncIteratorFactoryInstance(ctx, node);
|
|
2372
|
+
return deserializeAsyncIteratorFactoryInstance(ctx, depth, node);
|
|
2215
2373
|
case 31 /* StreamConstructor */:
|
|
2216
|
-
return deserializeStreamConstructor(ctx, node);
|
|
2374
|
+
return deserializeStreamConstructor(ctx, depth, node);
|
|
2217
2375
|
case 32 /* StreamNext */:
|
|
2218
|
-
return deserializeStreamNext(ctx, node);
|
|
2376
|
+
return deserializeStreamNext(ctx, depth, node);
|
|
2219
2377
|
case 33 /* StreamThrow */:
|
|
2220
|
-
return deserializeStreamThrow(ctx, node);
|
|
2378
|
+
return deserializeStreamThrow(ctx, depth, node);
|
|
2221
2379
|
case 34 /* StreamReturn */:
|
|
2222
|
-
return deserializeStreamReturn(ctx, node);
|
|
2380
|
+
return deserializeStreamReturn(ctx, depth, node);
|
|
2223
2381
|
case 27 /* IteratorFactory */:
|
|
2224
|
-
return deserializeIteratorFactory(ctx, node);
|
|
2382
|
+
return deserializeIteratorFactory(ctx, depth, node);
|
|
2225
2383
|
case 29 /* AsyncIteratorFactory */:
|
|
2226
|
-
return deserializeAsyncIteratorFactory(ctx, node);
|
|
2384
|
+
return deserializeAsyncIteratorFactory(ctx, depth, node);
|
|
2227
2385
|
// case SerovalNodeType.SpecialReference:
|
|
2228
2386
|
default:
|
|
2229
2387
|
throw new SerovalUnsupportedNodeError(node);
|
|
@@ -2231,7 +2389,7 @@ function deserialize(ctx, node) {
|
|
|
2231
2389
|
}
|
|
2232
2390
|
function deserializeTop(ctx, node) {
|
|
2233
2391
|
try {
|
|
2234
|
-
return deserialize(ctx, node);
|
|
2392
|
+
return deserialize(ctx, 0, node);
|
|
2235
2393
|
} catch (error) {
|
|
2236
2394
|
throw new SerovalDeserializationError(error);
|
|
2237
2395
|
}
|
|
@@ -2379,7 +2537,7 @@ function createVanillaSerializerContext(options) {
|
|
|
2379
2537
|
mode: 1 /* Vanilla */,
|
|
2380
2538
|
base: createBaseSerializerContext(1 /* Vanilla */, options),
|
|
2381
2539
|
state: createVanillaSerializerState(),
|
|
2382
|
-
child:
|
|
2540
|
+
child: NIL
|
|
2383
2541
|
};
|
|
2384
2542
|
}
|
|
2385
2543
|
function createCrossSerializerContext(options) {
|
|
@@ -2387,7 +2545,7 @@ function createCrossSerializerContext(options) {
|
|
|
2387
2545
|
mode: 2 /* Cross */,
|
|
2388
2546
|
base: createBaseSerializerContext(2 /* Cross */, options),
|
|
2389
2547
|
state: options,
|
|
2390
|
-
child:
|
|
2548
|
+
child: NIL
|
|
2391
2549
|
};
|
|
2392
2550
|
}
|
|
2393
2551
|
var SerializePluginContext = class {
|
|
@@ -2519,12 +2677,13 @@ function serializeArrayItem(ctx, id, item, index) {
|
|
|
2519
2677
|
}
|
|
2520
2678
|
function serializeArray(ctx, node) {
|
|
2521
2679
|
const id = node.i;
|
|
2522
|
-
|
|
2680
|
+
const list = node.a;
|
|
2681
|
+
const len = list.length;
|
|
2682
|
+
if (len > 0) {
|
|
2523
2683
|
ctx.base.stack.push(id);
|
|
2524
|
-
const list = node.a;
|
|
2525
2684
|
let values = serializeArrayItem(ctx, id, list[0], 0);
|
|
2526
2685
|
let isHoley = values === "";
|
|
2527
|
-
for (let i = 1,
|
|
2686
|
+
for (let i = 1, item; i < len; i++) {
|
|
2528
2687
|
item = serializeArrayItem(ctx, id, list[i], i);
|
|
2529
2688
|
values += "," + item;
|
|
2530
2689
|
isHoley = item === "";
|
|
@@ -2570,9 +2729,9 @@ function serializeProperty(ctx, source, key, val) {
|
|
|
2570
2729
|
return "[" + serialize(ctx, key) + "]:" + serialize(ctx, val);
|
|
2571
2730
|
}
|
|
2572
2731
|
function serializeProperties(ctx, source, record) {
|
|
2573
|
-
const
|
|
2574
|
-
|
|
2575
|
-
|
|
2732
|
+
const keys = record.k;
|
|
2733
|
+
const len = keys.length;
|
|
2734
|
+
if (len > 0) {
|
|
2576
2735
|
const values = record.v;
|
|
2577
2736
|
ctx.base.stack.push(source.i);
|
|
2578
2737
|
let result = serializeProperty(ctx, source, keys[0], values[0]);
|
|
@@ -2655,10 +2814,10 @@ function serializeAssignment(ctx, source, mainAssignments, key, value) {
|
|
|
2655
2814
|
}
|
|
2656
2815
|
}
|
|
2657
2816
|
function serializeAssignments(ctx, source, node) {
|
|
2658
|
-
const
|
|
2659
|
-
|
|
2817
|
+
const keys = node.k;
|
|
2818
|
+
const len = keys.length;
|
|
2819
|
+
if (len > 0) {
|
|
2660
2820
|
const mainAssignments = [];
|
|
2661
|
-
const keys = node.k;
|
|
2662
2821
|
const values = node.v;
|
|
2663
2822
|
ctx.base.stack.push(source.i);
|
|
2664
2823
|
for (let i = 0; i < len; i++) {
|
|
@@ -2691,8 +2850,11 @@ function serializeNullConstructor(ctx, node) {
|
|
|
2691
2850
|
function serializeDate(node) {
|
|
2692
2851
|
return 'new Date("' + node.s + '")';
|
|
2693
2852
|
}
|
|
2694
|
-
function serializeRegExp(node) {
|
|
2695
|
-
|
|
2853
|
+
function serializeRegExp(ctx, node) {
|
|
2854
|
+
if (ctx.base.features & 32 /* RegExp */) {
|
|
2855
|
+
return "/" + node.c + "/" + node.m;
|
|
2856
|
+
}
|
|
2857
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
2696
2858
|
}
|
|
2697
2859
|
function serializeSetItem(ctx, id, item) {
|
|
2698
2860
|
const base = ctx.base;
|
|
@@ -2709,10 +2871,10 @@ function serializeSetItem(ctx, id, item) {
|
|
|
2709
2871
|
}
|
|
2710
2872
|
function serializeSet(ctx, node) {
|
|
2711
2873
|
let serialized = SET_CONSTRUCTOR;
|
|
2712
|
-
const
|
|
2874
|
+
const items = node.a;
|
|
2875
|
+
const size = items.length;
|
|
2713
2876
|
const id = node.i;
|
|
2714
|
-
if (size) {
|
|
2715
|
-
const items = node.a;
|
|
2877
|
+
if (size > 0) {
|
|
2716
2878
|
ctx.base.stack.push(id);
|
|
2717
2879
|
let result = serializeSetItem(ctx, id, items[0]);
|
|
2718
2880
|
for (let i = 1, item = result; i < size; i++) {
|
|
@@ -2767,13 +2929,13 @@ function serializeMapEntry(ctx, id, key, val, sentinel) {
|
|
|
2767
2929
|
}
|
|
2768
2930
|
function serializeMap(ctx, node) {
|
|
2769
2931
|
let serialized = MAP_CONSTRUCTOR;
|
|
2770
|
-
const
|
|
2932
|
+
const keys = node.e.k;
|
|
2933
|
+
const size = keys.length;
|
|
2771
2934
|
const id = node.i;
|
|
2772
2935
|
const sentinel = node.f;
|
|
2773
2936
|
const sentinelId = getRefParam(ctx, sentinel.i);
|
|
2774
2937
|
const base = ctx.base;
|
|
2775
|
-
if (size) {
|
|
2776
|
-
const keys = node.e.k;
|
|
2938
|
+
if (size > 0) {
|
|
2777
2939
|
const vals = node.e.v;
|
|
2778
2940
|
base.stack.push(id);
|
|
2779
2941
|
let result = serializeMapEntry(ctx, id, keys[0], vals[0], sentinelId);
|
|
@@ -2793,7 +2955,7 @@ function serializeMap(ctx, node) {
|
|
|
2793
2955
|
return serialized;
|
|
2794
2956
|
}
|
|
2795
2957
|
function serializeArrayBuffer(ctx, node) {
|
|
2796
|
-
return getConstructor(ctx, node.f) +
|
|
2958
|
+
return getConstructor(ctx, node.f) + '("' + node.s + '")';
|
|
2797
2959
|
}
|
|
2798
2960
|
function serializeTypedArray(ctx, node) {
|
|
2799
2961
|
return "new " + node.c + "(" + serialize(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
@@ -2973,7 +3135,7 @@ function serializeAssignable(ctx, node) {
|
|
|
2973
3135
|
case 5 /* Date */:
|
|
2974
3136
|
return serializeDate(node);
|
|
2975
3137
|
case 6 /* RegExp */:
|
|
2976
|
-
return serializeRegExp(node);
|
|
3138
|
+
return serializeRegExp(ctx, node);
|
|
2977
3139
|
case 7 /* Set */:
|
|
2978
3140
|
return serializeSet(ctx, node);
|
|
2979
3141
|
case 8 /* Map */:
|
|
@@ -3085,26 +3247,28 @@ function createSyncParserContext(mode, options) {
|
|
|
3085
3247
|
return {
|
|
3086
3248
|
type: 1 /* Sync */,
|
|
3087
3249
|
base: createBaseParserContext(mode, options),
|
|
3088
|
-
child:
|
|
3250
|
+
child: NIL
|
|
3089
3251
|
};
|
|
3090
3252
|
}
|
|
3091
3253
|
var SyncParsePluginContext = class {
|
|
3092
|
-
constructor(_p) {
|
|
3254
|
+
constructor(_p, depth) {
|
|
3093
3255
|
this._p = _p;
|
|
3256
|
+
this.depth = depth;
|
|
3094
3257
|
}
|
|
3095
3258
|
parse(current) {
|
|
3096
|
-
return parseSOS(this._p, current);
|
|
3259
|
+
return parseSOS(this._p, this.depth, current);
|
|
3097
3260
|
}
|
|
3098
3261
|
};
|
|
3099
3262
|
var StreamParsePluginContext = class {
|
|
3100
|
-
constructor(_p) {
|
|
3263
|
+
constructor(_p, depth) {
|
|
3101
3264
|
this._p = _p;
|
|
3265
|
+
this.depth = depth;
|
|
3102
3266
|
}
|
|
3103
3267
|
parse(current) {
|
|
3104
|
-
return parseSOS(this._p, current);
|
|
3268
|
+
return parseSOS(this._p, this.depth, current);
|
|
3105
3269
|
}
|
|
3106
3270
|
parseWithError(current) {
|
|
3107
|
-
return parseWithError(this._p, current);
|
|
3271
|
+
return parseWithError(this._p, this.depth, current);
|
|
3108
3272
|
}
|
|
3109
3273
|
isAlive() {
|
|
3110
3274
|
return this._p.state.alive;
|
|
@@ -3137,29 +3301,30 @@ function createStreamParserContext(options) {
|
|
|
3137
3301
|
return {
|
|
3138
3302
|
type: 2 /* Stream */,
|
|
3139
3303
|
base: createBaseParserContext(2 /* Cross */, options),
|
|
3140
|
-
child: void 0,
|
|
3141
3304
|
state: createStreamParserState(options)
|
|
3142
3305
|
};
|
|
3143
3306
|
}
|
|
3144
|
-
function parseItems2(ctx, current) {
|
|
3307
|
+
function parseItems2(ctx, depth, current) {
|
|
3145
3308
|
const nodes = [];
|
|
3146
3309
|
for (let i = 0, len = current.length; i < len; i++) {
|
|
3147
3310
|
if (i in current) {
|
|
3148
|
-
nodes[i] = parseSOS(ctx, current[i]);
|
|
3311
|
+
nodes[i] = parseSOS(ctx, depth, current[i]);
|
|
3312
|
+
} else {
|
|
3313
|
+
nodes[i] = 0;
|
|
3149
3314
|
}
|
|
3150
3315
|
}
|
|
3151
3316
|
return nodes;
|
|
3152
3317
|
}
|
|
3153
|
-
function parseArray2(ctx, id, current) {
|
|
3154
|
-
return createArrayNode(id, current, parseItems2(ctx, current));
|
|
3318
|
+
function parseArray2(ctx, depth, id, current) {
|
|
3319
|
+
return createArrayNode(id, current, parseItems2(ctx, depth, current));
|
|
3155
3320
|
}
|
|
3156
|
-
function parseProperties2(ctx, properties) {
|
|
3321
|
+
function parseProperties2(ctx, depth, properties) {
|
|
3157
3322
|
const entries = Object.entries(properties);
|
|
3158
3323
|
const keyNodes = [];
|
|
3159
3324
|
const valueNodes = [];
|
|
3160
3325
|
for (let i = 0, len = entries.length; i < len; i++) {
|
|
3161
3326
|
keyNodes.push(serializeString(entries[i][0]));
|
|
3162
|
-
valueNodes.push(parseSOS(ctx, entries[i][1]));
|
|
3327
|
+
valueNodes.push(parseSOS(ctx, depth, entries[i][1]));
|
|
3163
3328
|
}
|
|
3164
3329
|
if (SYM_ITERATOR in properties) {
|
|
3165
3330
|
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ITERATOR));
|
|
@@ -3168,6 +3333,7 @@ function parseProperties2(ctx, properties) {
|
|
|
3168
3333
|
parseIteratorFactory(ctx.base),
|
|
3169
3334
|
parseSOS(
|
|
3170
3335
|
ctx,
|
|
3336
|
+
depth,
|
|
3171
3337
|
iteratorToSequence(properties)
|
|
3172
3338
|
)
|
|
3173
3339
|
)
|
|
@@ -3180,6 +3346,7 @@ function parseProperties2(ctx, properties) {
|
|
|
3180
3346
|
parseAsyncIteratorFactory(ctx.base),
|
|
3181
3347
|
parseSOS(
|
|
3182
3348
|
ctx,
|
|
3349
|
+
depth,
|
|
3183
3350
|
ctx.type === 1 /* Sync */ ? createStream() : createStreamFromAsyncIterable(
|
|
3184
3351
|
properties
|
|
3185
3352
|
)
|
|
@@ -3199,58 +3366,70 @@ function parseProperties2(ctx, properties) {
|
|
|
3199
3366
|
}
|
|
3200
3367
|
return {
|
|
3201
3368
|
k: keyNodes,
|
|
3202
|
-
v: valueNodes
|
|
3203
|
-
s: keyNodes.length
|
|
3369
|
+
v: valueNodes
|
|
3204
3370
|
};
|
|
3205
3371
|
}
|
|
3206
|
-
function parsePlainObject2(ctx, id, current, empty) {
|
|
3207
|
-
return createObjectNode(
|
|
3372
|
+
function parsePlainObject2(ctx, depth, id, current, empty) {
|
|
3373
|
+
return createObjectNode(
|
|
3374
|
+
id,
|
|
3375
|
+
current,
|
|
3376
|
+
empty,
|
|
3377
|
+
parseProperties2(ctx, depth, current)
|
|
3378
|
+
);
|
|
3208
3379
|
}
|
|
3209
|
-
function parseBoxed2(ctx, id, current) {
|
|
3210
|
-
return createBoxedNode(id, parseSOS(ctx, current.valueOf()));
|
|
3380
|
+
function parseBoxed2(ctx, depth, id, current) {
|
|
3381
|
+
return createBoxedNode(id, parseSOS(ctx, depth, current.valueOf()));
|
|
3211
3382
|
}
|
|
3212
|
-
function parseTypedArray2(ctx, id, current) {
|
|
3213
|
-
return createTypedArrayNode(
|
|
3383
|
+
function parseTypedArray2(ctx, depth, id, current) {
|
|
3384
|
+
return createTypedArrayNode(
|
|
3385
|
+
id,
|
|
3386
|
+
current,
|
|
3387
|
+
parseSOS(ctx, depth, current.buffer)
|
|
3388
|
+
);
|
|
3214
3389
|
}
|
|
3215
|
-
function parseBigIntTypedArray2(ctx, id, current) {
|
|
3216
|
-
return createBigIntTypedArrayNode(
|
|
3390
|
+
function parseBigIntTypedArray2(ctx, depth, id, current) {
|
|
3391
|
+
return createBigIntTypedArrayNode(
|
|
3392
|
+
id,
|
|
3393
|
+
current,
|
|
3394
|
+
parseSOS(ctx, depth, current.buffer)
|
|
3395
|
+
);
|
|
3217
3396
|
}
|
|
3218
|
-
function parseDataView2(ctx, id, current) {
|
|
3219
|
-
return createDataViewNode(id, current, parseSOS(ctx, current.buffer));
|
|
3397
|
+
function parseDataView2(ctx, depth, id, current) {
|
|
3398
|
+
return createDataViewNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
3220
3399
|
}
|
|
3221
|
-
function parseError2(ctx, id, current) {
|
|
3400
|
+
function parseError2(ctx, depth, id, current) {
|
|
3222
3401
|
const options = getErrorOptions(current, ctx.base.features);
|
|
3223
3402
|
return createErrorNode(
|
|
3224
3403
|
id,
|
|
3225
3404
|
current,
|
|
3226
|
-
options ? parseProperties2(ctx, options) : NIL
|
|
3405
|
+
options ? parseProperties2(ctx, depth, options) : NIL
|
|
3227
3406
|
);
|
|
3228
3407
|
}
|
|
3229
|
-
function parseAggregateError2(ctx, id, current) {
|
|
3408
|
+
function parseAggregateError2(ctx, depth, id, current) {
|
|
3230
3409
|
const options = getErrorOptions(current, ctx.base.features);
|
|
3231
3410
|
return createAggregateErrorNode(
|
|
3232
3411
|
id,
|
|
3233
3412
|
current,
|
|
3234
|
-
options ? parseProperties2(ctx, options) : NIL
|
|
3413
|
+
options ? parseProperties2(ctx, depth, options) : NIL
|
|
3235
3414
|
);
|
|
3236
3415
|
}
|
|
3237
|
-
function parseMap2(ctx, id, current) {
|
|
3416
|
+
function parseMap2(ctx, depth, id, current) {
|
|
3238
3417
|
const keyNodes = [];
|
|
3239
3418
|
const valueNodes = [];
|
|
3240
3419
|
for (const [key, value] of current.entries()) {
|
|
3241
|
-
keyNodes.push(parseSOS(ctx, key));
|
|
3242
|
-
valueNodes.push(parseSOS(ctx, value));
|
|
3420
|
+
keyNodes.push(parseSOS(ctx, depth, key));
|
|
3421
|
+
valueNodes.push(parseSOS(ctx, depth, value));
|
|
3243
3422
|
}
|
|
3244
|
-
return createMapNode(ctx.base, id, keyNodes, valueNodes
|
|
3423
|
+
return createMapNode(ctx.base, id, keyNodes, valueNodes);
|
|
3245
3424
|
}
|
|
3246
|
-
function parseSet2(ctx, id, current) {
|
|
3425
|
+
function parseSet2(ctx, depth, id, current) {
|
|
3247
3426
|
const items = [];
|
|
3248
3427
|
for (const item of current.keys()) {
|
|
3249
|
-
items.push(parseSOS(ctx, item));
|
|
3428
|
+
items.push(parseSOS(ctx, depth, item));
|
|
3250
3429
|
}
|
|
3251
|
-
return createSetNode(id,
|
|
3430
|
+
return createSetNode(id, items);
|
|
3252
3431
|
}
|
|
3253
|
-
function parseStream2(ctx, id, current) {
|
|
3432
|
+
function parseStream2(ctx, depth, id, current) {
|
|
3254
3433
|
const result = createStreamConstructorNode(
|
|
3255
3434
|
id,
|
|
3256
3435
|
parseSpecialReference(ctx.base, 4 /* StreamConstructor */),
|
|
@@ -3263,7 +3442,7 @@ function parseStream2(ctx, id, current) {
|
|
|
3263
3442
|
current.on({
|
|
3264
3443
|
next: (value) => {
|
|
3265
3444
|
if (ctx.state.alive) {
|
|
3266
|
-
const parsed = parseWithError(ctx, value);
|
|
3445
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
3267
3446
|
if (parsed) {
|
|
3268
3447
|
onParse(ctx, createStreamNextNode(id, parsed));
|
|
3269
3448
|
}
|
|
@@ -3271,7 +3450,7 @@ function parseStream2(ctx, id, current) {
|
|
|
3271
3450
|
},
|
|
3272
3451
|
throw: (value) => {
|
|
3273
3452
|
if (ctx.state.alive) {
|
|
3274
|
-
const parsed = parseWithError(ctx, value);
|
|
3453
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
3275
3454
|
if (parsed) {
|
|
3276
3455
|
onParse(ctx, createStreamThrowNode(id, parsed));
|
|
3277
3456
|
}
|
|
@@ -3280,7 +3459,7 @@ function parseStream2(ctx, id, current) {
|
|
|
3280
3459
|
},
|
|
3281
3460
|
return: (value) => {
|
|
3282
3461
|
if (ctx.state.alive) {
|
|
3283
|
-
const parsed = parseWithError(ctx, value);
|
|
3462
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
3284
3463
|
if (parsed) {
|
|
3285
3464
|
onParse(ctx, createStreamReturnNode(id, parsed));
|
|
3286
3465
|
}
|
|
@@ -3290,9 +3469,9 @@ function parseStream2(ctx, id, current) {
|
|
|
3290
3469
|
});
|
|
3291
3470
|
return result;
|
|
3292
3471
|
}
|
|
3293
|
-
function handlePromiseSuccess(id, data) {
|
|
3472
|
+
function handlePromiseSuccess(id, depth, data) {
|
|
3294
3473
|
if (this.state.alive) {
|
|
3295
|
-
const parsed = parseWithError(this, data);
|
|
3474
|
+
const parsed = parseWithError(this, depth, data);
|
|
3296
3475
|
if (parsed) {
|
|
3297
3476
|
onParse(
|
|
3298
3477
|
this,
|
|
@@ -3304,13 +3483,13 @@ function handlePromiseSuccess(id, data) {
|
|
|
3304
3483
|
NIL,
|
|
3305
3484
|
NIL,
|
|
3306
3485
|
NIL,
|
|
3307
|
-
NIL,
|
|
3308
3486
|
[
|
|
3309
3487
|
parseSpecialReference(this.base, 2 /* PromiseSuccess */),
|
|
3310
3488
|
parsed
|
|
3311
3489
|
],
|
|
3312
3490
|
NIL,
|
|
3313
3491
|
NIL,
|
|
3492
|
+
NIL,
|
|
3314
3493
|
NIL
|
|
3315
3494
|
)
|
|
3316
3495
|
);
|
|
@@ -3318,9 +3497,9 @@ function handlePromiseSuccess(id, data) {
|
|
|
3318
3497
|
popPendingState(this);
|
|
3319
3498
|
}
|
|
3320
3499
|
}
|
|
3321
|
-
function handlePromiseFailure(id, data) {
|
|
3500
|
+
function handlePromiseFailure(id, depth, data) {
|
|
3322
3501
|
if (this.state.alive) {
|
|
3323
|
-
const parsed = parseWithError(this, data);
|
|
3502
|
+
const parsed = parseWithError(this, depth, data);
|
|
3324
3503
|
if (parsed) {
|
|
3325
3504
|
onParse(
|
|
3326
3505
|
this,
|
|
@@ -3332,13 +3511,13 @@ function handlePromiseFailure(id, data) {
|
|
|
3332
3511
|
NIL,
|
|
3333
3512
|
NIL,
|
|
3334
3513
|
NIL,
|
|
3335
|
-
NIL,
|
|
3336
3514
|
[
|
|
3337
3515
|
parseSpecialReference(this.base, 3 /* PromiseFailure */),
|
|
3338
3516
|
parsed
|
|
3339
3517
|
],
|
|
3340
3518
|
NIL,
|
|
3341
3519
|
NIL,
|
|
3520
|
+
NIL,
|
|
3342
3521
|
NIL
|
|
3343
3522
|
)
|
|
3344
3523
|
);
|
|
@@ -3346,80 +3525,74 @@ function handlePromiseFailure(id, data) {
|
|
|
3346
3525
|
}
|
|
3347
3526
|
popPendingState(this);
|
|
3348
3527
|
}
|
|
3349
|
-
function parsePromise2(ctx, id, current) {
|
|
3528
|
+
function parsePromise2(ctx, depth, id, current) {
|
|
3350
3529
|
const resolver = createIndexForValue(ctx.base, {});
|
|
3351
3530
|
if (ctx.type === 2 /* Stream */) {
|
|
3352
3531
|
pushPendingState(ctx);
|
|
3353
3532
|
current.then(
|
|
3354
|
-
handlePromiseSuccess.bind(ctx, resolver),
|
|
3355
|
-
handlePromiseFailure.bind(ctx, resolver)
|
|
3533
|
+
handlePromiseSuccess.bind(ctx, resolver, depth),
|
|
3534
|
+
handlePromiseFailure.bind(ctx, resolver, depth)
|
|
3356
3535
|
);
|
|
3357
3536
|
}
|
|
3358
3537
|
return createPromiseConstructorNode(ctx.base, id, resolver);
|
|
3359
3538
|
}
|
|
3360
|
-
function parsePluginSync(ctx, id, current, currentPlugins) {
|
|
3539
|
+
function parsePluginSync(ctx, depth, id, current, currentPlugins) {
|
|
3361
3540
|
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
3362
3541
|
const plugin = currentPlugins[i];
|
|
3363
3542
|
if (plugin.parse.sync && plugin.test(current)) {
|
|
3364
|
-
if (ctx.child == null) {
|
|
3365
|
-
ctx.child = new SyncParsePluginContext(ctx);
|
|
3366
|
-
}
|
|
3367
3543
|
return createPluginNode(
|
|
3368
3544
|
id,
|
|
3369
3545
|
plugin.tag,
|
|
3370
|
-
plugin.parse.sync(current, ctx
|
|
3546
|
+
plugin.parse.sync(current, new SyncParsePluginContext(ctx, depth), {
|
|
3371
3547
|
id
|
|
3372
3548
|
})
|
|
3373
3549
|
);
|
|
3374
3550
|
}
|
|
3375
3551
|
}
|
|
3376
|
-
return
|
|
3552
|
+
return NIL;
|
|
3377
3553
|
}
|
|
3378
|
-
function parsePluginStream(ctx, id, current, currentPlugins) {
|
|
3554
|
+
function parsePluginStream(ctx, depth, id, current, currentPlugins) {
|
|
3379
3555
|
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
3380
3556
|
const plugin = currentPlugins[i];
|
|
3381
3557
|
if (plugin.parse.stream && plugin.test(current)) {
|
|
3382
|
-
if (ctx.child == null) {
|
|
3383
|
-
ctx.child = new StreamParsePluginContext(ctx);
|
|
3384
|
-
}
|
|
3385
3558
|
return createPluginNode(
|
|
3386
3559
|
id,
|
|
3387
3560
|
plugin.tag,
|
|
3388
|
-
plugin.parse.stream(current, ctx
|
|
3561
|
+
plugin.parse.stream(current, new StreamParsePluginContext(ctx, depth), {
|
|
3389
3562
|
id
|
|
3390
3563
|
})
|
|
3391
3564
|
);
|
|
3392
3565
|
}
|
|
3393
3566
|
}
|
|
3394
|
-
return
|
|
3567
|
+
return NIL;
|
|
3395
3568
|
}
|
|
3396
|
-
function parsePlugin2(ctx, id, current) {
|
|
3569
|
+
function parsePlugin2(ctx, depth, id, current) {
|
|
3397
3570
|
const currentPlugins = ctx.base.plugins;
|
|
3398
3571
|
if (currentPlugins) {
|
|
3399
|
-
return ctx.type === 1 /* Sync */ ? parsePluginSync(ctx, id, current, currentPlugins) : parsePluginStream(ctx, id, current, currentPlugins);
|
|
3572
|
+
return ctx.type === 1 /* Sync */ ? parsePluginSync(ctx, depth, id, current, currentPlugins) : parsePluginStream(ctx, depth, id, current, currentPlugins);
|
|
3400
3573
|
}
|
|
3401
|
-
return
|
|
3574
|
+
return NIL;
|
|
3402
3575
|
}
|
|
3403
|
-
function parseObjectPhase2(ctx, id, current, currentClass) {
|
|
3576
|
+
function parseObjectPhase2(ctx, depth, id, current, currentClass) {
|
|
3404
3577
|
switch (currentClass) {
|
|
3405
3578
|
case Object:
|
|
3406
3579
|
return parsePlainObject2(
|
|
3407
3580
|
ctx,
|
|
3581
|
+
depth,
|
|
3408
3582
|
id,
|
|
3409
3583
|
current,
|
|
3410
3584
|
false
|
|
3411
3585
|
);
|
|
3412
|
-
case
|
|
3586
|
+
case NIL:
|
|
3413
3587
|
return parsePlainObject2(
|
|
3414
3588
|
ctx,
|
|
3589
|
+
depth,
|
|
3415
3590
|
id,
|
|
3416
3591
|
current,
|
|
3417
3592
|
true
|
|
3418
3593
|
);
|
|
3419
3594
|
case Date:
|
|
3420
3595
|
return createDateNode(id, current);
|
|
3421
|
-
case RegExp:
|
|
3422
|
-
return createRegExpNode(id, current);
|
|
3423
3596
|
case Error:
|
|
3424
3597
|
case EvalError:
|
|
3425
3598
|
case RangeError:
|
|
@@ -3427,12 +3600,12 @@ function parseObjectPhase2(ctx, id, current, currentClass) {
|
|
|
3427
3600
|
case SyntaxError:
|
|
3428
3601
|
case TypeError:
|
|
3429
3602
|
case URIError:
|
|
3430
|
-
return parseError2(ctx, id, current);
|
|
3603
|
+
return parseError2(ctx, depth, id, current);
|
|
3431
3604
|
case Number:
|
|
3432
3605
|
case Boolean:
|
|
3433
3606
|
case String:
|
|
3434
3607
|
case BigInt:
|
|
3435
|
-
return parseBoxed2(ctx, id, current);
|
|
3608
|
+
return parseBoxed2(ctx, depth, id, current);
|
|
3436
3609
|
case ArrayBuffer:
|
|
3437
3610
|
return createArrayBufferNode(
|
|
3438
3611
|
ctx.base,
|
|
@@ -3448,26 +3621,40 @@ function parseObjectPhase2(ctx, id, current, currentClass) {
|
|
|
3448
3621
|
case Uint8ClampedArray:
|
|
3449
3622
|
case Float32Array:
|
|
3450
3623
|
case Float64Array:
|
|
3451
|
-
return parseTypedArray2(
|
|
3624
|
+
return parseTypedArray2(
|
|
3625
|
+
ctx,
|
|
3626
|
+
depth,
|
|
3627
|
+
id,
|
|
3628
|
+
current
|
|
3629
|
+
);
|
|
3452
3630
|
case DataView:
|
|
3453
|
-
return parseDataView2(ctx, id, current);
|
|
3631
|
+
return parseDataView2(ctx, depth, id, current);
|
|
3454
3632
|
case Map:
|
|
3455
|
-
return parseMap2(
|
|
3633
|
+
return parseMap2(
|
|
3634
|
+
ctx,
|
|
3635
|
+
depth,
|
|
3636
|
+
id,
|
|
3637
|
+
current
|
|
3638
|
+
);
|
|
3456
3639
|
case Set:
|
|
3457
|
-
return parseSet2(ctx, id, current);
|
|
3640
|
+
return parseSet2(ctx, depth, id, current);
|
|
3458
3641
|
default:
|
|
3459
3642
|
break;
|
|
3460
3643
|
}
|
|
3461
3644
|
if (currentClass === Promise || current instanceof Promise) {
|
|
3462
|
-
return parsePromise2(ctx, id, current);
|
|
3645
|
+
return parsePromise2(ctx, depth, id, current);
|
|
3463
3646
|
}
|
|
3464
3647
|
const currentFeatures = ctx.base.features;
|
|
3648
|
+
if (currentFeatures & 32 /* RegExp */ && currentClass === RegExp) {
|
|
3649
|
+
return createRegExpNode(id, current);
|
|
3650
|
+
}
|
|
3465
3651
|
if (currentFeatures & 16 /* BigIntTypedArray */) {
|
|
3466
3652
|
switch (currentClass) {
|
|
3467
3653
|
case BigInt64Array:
|
|
3468
3654
|
case BigUint64Array:
|
|
3469
3655
|
return parseBigIntTypedArray2(
|
|
3470
3656
|
ctx,
|
|
3657
|
+
depth,
|
|
3471
3658
|
id,
|
|
3472
3659
|
current
|
|
3473
3660
|
);
|
|
@@ -3476,48 +3663,57 @@ function parseObjectPhase2(ctx, id, current, currentClass) {
|
|
|
3476
3663
|
}
|
|
3477
3664
|
}
|
|
3478
3665
|
if (currentFeatures & 1 /* AggregateError */ && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
3479
|
-
return parseAggregateError2(
|
|
3666
|
+
return parseAggregateError2(
|
|
3667
|
+
ctx,
|
|
3668
|
+
depth,
|
|
3669
|
+
id,
|
|
3670
|
+
current
|
|
3671
|
+
);
|
|
3480
3672
|
}
|
|
3481
3673
|
if (current instanceof Error) {
|
|
3482
|
-
return parseError2(ctx, id, current);
|
|
3674
|
+
return parseError2(ctx, depth, id, current);
|
|
3483
3675
|
}
|
|
3484
3676
|
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) {
|
|
3485
|
-
return parsePlainObject2(ctx, id, current, !!currentClass);
|
|
3677
|
+
return parsePlainObject2(ctx, depth, id, current, !!currentClass);
|
|
3486
3678
|
}
|
|
3487
3679
|
throw new SerovalUnsupportedTypeError(current);
|
|
3488
3680
|
}
|
|
3489
|
-
function parseObject(ctx, id, current) {
|
|
3681
|
+
function parseObject(ctx, depth, id, current) {
|
|
3490
3682
|
if (Array.isArray(current)) {
|
|
3491
|
-
return parseArray2(ctx, id, current);
|
|
3683
|
+
return parseArray2(ctx, depth, id, current);
|
|
3492
3684
|
}
|
|
3493
3685
|
if (isStream(current)) {
|
|
3494
|
-
return parseStream2(ctx, id, current);
|
|
3686
|
+
return parseStream2(ctx, depth, id, current);
|
|
3495
3687
|
}
|
|
3496
3688
|
const currentClass = current.constructor;
|
|
3497
3689
|
if (currentClass === OpaqueReference) {
|
|
3498
3690
|
return parseSOS(
|
|
3499
3691
|
ctx,
|
|
3692
|
+
depth,
|
|
3500
3693
|
current.replacement
|
|
3501
3694
|
);
|
|
3502
3695
|
}
|
|
3503
|
-
const parsed = parsePlugin2(ctx, id, current);
|
|
3696
|
+
const parsed = parsePlugin2(ctx, depth, id, current);
|
|
3504
3697
|
if (parsed) {
|
|
3505
3698
|
return parsed;
|
|
3506
3699
|
}
|
|
3507
|
-
return parseObjectPhase2(ctx, id, current, currentClass);
|
|
3700
|
+
return parseObjectPhase2(ctx, depth, id, current, currentClass);
|
|
3508
3701
|
}
|
|
3509
|
-
function parseFunction(ctx, current) {
|
|
3702
|
+
function parseFunction(ctx, depth, current) {
|
|
3510
3703
|
const ref = getReferenceNode(ctx.base, current);
|
|
3511
3704
|
if (ref.type !== 0 /* Fresh */) {
|
|
3512
3705
|
return ref.value;
|
|
3513
3706
|
}
|
|
3514
|
-
const plugin = parsePlugin2(ctx, ref.value, current);
|
|
3707
|
+
const plugin = parsePlugin2(ctx, depth, ref.value, current);
|
|
3515
3708
|
if (plugin) {
|
|
3516
3709
|
return plugin;
|
|
3517
3710
|
}
|
|
3518
3711
|
throw new SerovalUnsupportedTypeError(current);
|
|
3519
3712
|
}
|
|
3520
|
-
function parseSOS(ctx, current) {
|
|
3713
|
+
function parseSOS(ctx, depth, current) {
|
|
3714
|
+
if (depth >= ctx.base.depthLimit) {
|
|
3715
|
+
throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
3716
|
+
}
|
|
3521
3717
|
switch (typeof current) {
|
|
3522
3718
|
case "boolean":
|
|
3523
3719
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
@@ -3532,14 +3728,14 @@ function parseSOS(ctx, current) {
|
|
|
3532
3728
|
case "object": {
|
|
3533
3729
|
if (current) {
|
|
3534
3730
|
const ref = getReferenceNode(ctx.base, current);
|
|
3535
|
-
return ref.type === 0 /* Fresh */ ? parseObject(ctx, ref.value, current) : ref.value;
|
|
3731
|
+
return ref.type === 0 /* Fresh */ ? parseObject(ctx, depth + 1, ref.value, current) : ref.value;
|
|
3536
3732
|
}
|
|
3537
3733
|
return NULL_NODE;
|
|
3538
3734
|
}
|
|
3539
3735
|
case "symbol":
|
|
3540
3736
|
return parseWellKnownSymbol(ctx.base, current);
|
|
3541
3737
|
case "function": {
|
|
3542
|
-
return parseFunction(ctx, current);
|
|
3738
|
+
return parseFunction(ctx, depth, current);
|
|
3543
3739
|
}
|
|
3544
3740
|
default:
|
|
3545
3741
|
throw new SerovalUnsupportedTypeError(current);
|
|
@@ -3547,7 +3743,7 @@ function parseSOS(ctx, current) {
|
|
|
3547
3743
|
}
|
|
3548
3744
|
function parseTop(ctx, current) {
|
|
3549
3745
|
try {
|
|
3550
|
-
return parseSOS(ctx, current);
|
|
3746
|
+
return parseSOS(ctx, 0, current);
|
|
3551
3747
|
} catch (error) {
|
|
3552
3748
|
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
3553
3749
|
}
|
|
@@ -3586,16 +3782,16 @@ function popPendingState(ctx) {
|
|
|
3586
3782
|
onDone(ctx);
|
|
3587
3783
|
}
|
|
3588
3784
|
}
|
|
3589
|
-
function parseWithError(ctx, current) {
|
|
3785
|
+
function parseWithError(ctx, depth, current) {
|
|
3590
3786
|
try {
|
|
3591
|
-
return parseSOS(ctx, current);
|
|
3787
|
+
return parseSOS(ctx, depth, current);
|
|
3592
3788
|
} catch (err) {
|
|
3593
3789
|
onError(ctx, err);
|
|
3594
3790
|
return NIL;
|
|
3595
3791
|
}
|
|
3596
3792
|
}
|
|
3597
3793
|
function startStreamParse(ctx, current) {
|
|
3598
|
-
const parsed = parseWithError(ctx, current);
|
|
3794
|
+
const parsed = parseWithError(ctx, 0, current);
|
|
3599
3795
|
if (parsed) {
|
|
3600
3796
|
onParseInternal(ctx, parsed, true);
|
|
3601
3797
|
ctx.state.initial = false;
|
|
@@ -3715,7 +3911,9 @@ function fromCrossJSON(source, options) {
|
|
|
3715
3911
|
const plugins = resolvePlugins(options.plugins);
|
|
3716
3912
|
const ctx = createCrossDeserializerContext({
|
|
3717
3913
|
plugins,
|
|
3718
|
-
refs: options.refs
|
|
3914
|
+
refs: options.refs,
|
|
3915
|
+
features: options.features,
|
|
3916
|
+
disabledFeatures: options.disabledFeatures
|
|
3719
3917
|
});
|
|
3720
3918
|
return deserializeTop(ctx, source);
|
|
3721
3919
|
}
|
|
@@ -3865,10 +4063,15 @@ function compileJSON(source, options = {}) {
|
|
|
3865
4063
|
return serializeTopVanilla(ctx, source.t);
|
|
3866
4064
|
}
|
|
3867
4065
|
function fromJSON(source, options = {}) {
|
|
4066
|
+
var _a;
|
|
3868
4067
|
const plugins = resolvePlugins(options.plugins);
|
|
4068
|
+
const disabledFeatures = options.disabledFeatures || 0;
|
|
4069
|
+
const sourceFeatures = (_a = source.f) != null ? _a : ALL_ENABLED;
|
|
3869
4070
|
const ctx = createVanillaDeserializerContext({
|
|
3870
4071
|
plugins,
|
|
3871
|
-
markedRefs: source.m
|
|
4072
|
+
markedRefs: source.m,
|
|
4073
|
+
features: sourceFeatures & ~disabledFeatures,
|
|
4074
|
+
disabledFeatures
|
|
3872
4075
|
});
|
|
3873
4076
|
return deserializeTop(ctx, source.t);
|
|
3874
4077
|
}
|