seroval 1.6.4 → 1.6.6
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/dev/index.cjs +102 -30
- package/dist/dev/index.d.cts +10 -2
- package/dist/dev/index.d.ts +10 -2
- package/dist/dev/index.js +102 -31
- package/dist/index.cjs +102 -30
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +102 -31
- package/package.json +1 -1
package/dist/dev/index.js
CHANGED
|
@@ -147,6 +147,8 @@ const NEG_INFINITY_NODE = /* @__PURE__ */ createConstantNode(6);
|
|
|
147
147
|
const NAN_NODE = /* @__PURE__ */ createConstantNode(7);
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/core/string.ts
|
|
150
|
+
const MIN_JSON_STRINGIFY_LENGTH = 64;
|
|
151
|
+
const JSON_ESCAPE_DIFFERENCES = /[\x00-\x07\x0b\x0e-\x1f<\u2028\u2029\ud800-\udfff]/;
|
|
150
152
|
function serializeChar(str) {
|
|
151
153
|
switch (str) {
|
|
152
154
|
case "\"": return "\\\"";
|
|
@@ -163,6 +165,7 @@ function serializeChar(str) {
|
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
function serializeString(str) {
|
|
168
|
+
if (str.length >= MIN_JSON_STRINGIFY_LENGTH && !JSON_ESCAPE_DIFFERENCES.test(str)) return JSON.stringify(str).slice(1, -1);
|
|
166
169
|
let result = "";
|
|
167
170
|
let lastPos = 0;
|
|
168
171
|
let replacement;
|
|
@@ -523,7 +526,10 @@ const STREAM_CONSTRUCTOR = () => {
|
|
|
523
526
|
let count = 0;
|
|
524
527
|
const internal = {
|
|
525
528
|
flush(value, mode, x) {
|
|
526
|
-
for (x = 0; x < count; x++)
|
|
529
|
+
for (x = 0; x < count; x++) {
|
|
530
|
+
const listener = listeners[x];
|
|
531
|
+
if (listener) listener[mode](value);
|
|
532
|
+
}
|
|
527
533
|
},
|
|
528
534
|
up(listener, x, z, current) {
|
|
529
535
|
for (x = 0, z = buffer.length; x < z; x++) {
|
|
@@ -532,16 +538,20 @@ const STREAM_CONSTRUCTOR = () => {
|
|
|
532
538
|
else listener.next(current);
|
|
533
539
|
}
|
|
534
540
|
},
|
|
535
|
-
on(listener, temp) {
|
|
541
|
+
on(listener, temp = 0) {
|
|
542
|
+
let subscribed = alive;
|
|
536
543
|
if (alive) {
|
|
537
|
-
temp = count
|
|
544
|
+
for (temp = 0; temp < count; temp++) if (!listeners[temp]) break;
|
|
545
|
+
if (temp === count) count++;
|
|
538
546
|
listeners[temp] = listener;
|
|
539
547
|
}
|
|
540
548
|
internal.up(listener);
|
|
541
549
|
return () => {
|
|
542
|
-
if (alive) {
|
|
543
|
-
|
|
544
|
-
listeners[
|
|
550
|
+
if (alive && subscribed) {
|
|
551
|
+
subscribed = false;
|
|
552
|
+
listeners[temp] = void 0;
|
|
553
|
+
while (count > 0 && !listeners[count - 1]) count--;
|
|
554
|
+
listeners.length = count;
|
|
545
555
|
}
|
|
546
556
|
};
|
|
547
557
|
}
|
|
@@ -752,19 +762,35 @@ function isStream(value) {
|
|
|
752
762
|
function createStream() {
|
|
753
763
|
return STREAM_CONSTRUCTOR();
|
|
754
764
|
}
|
|
755
|
-
function createStreamFromAsyncIterable(iterable) {
|
|
765
|
+
function createStreamFromAsyncIterable(iterable, cleanups) {
|
|
756
766
|
const stream = createStream();
|
|
757
767
|
const iterator = iterable[SYM_ASYNC_ITERATOR]();
|
|
768
|
+
let cancelled = false;
|
|
769
|
+
let done = false;
|
|
770
|
+
cleanups === null || cleanups === void 0 || cleanups.push(() => {
|
|
771
|
+
if (!(done || cancelled)) {
|
|
772
|
+
cancelled = true;
|
|
773
|
+
Promise.resolve().then(() => {
|
|
774
|
+
var _iterator$return;
|
|
775
|
+
return (_iterator$return = iterator.return) === null || _iterator$return === void 0 ? void 0 : _iterator$return.call(iterator);
|
|
776
|
+
}).catch(() => {});
|
|
777
|
+
}
|
|
778
|
+
});
|
|
758
779
|
async function push() {
|
|
759
780
|
try {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
781
|
+
while (!cancelled) {
|
|
782
|
+
const value = await iterator.next();
|
|
783
|
+
if (cancelled) return;
|
|
784
|
+
if (value.done) {
|
|
785
|
+
done = true;
|
|
786
|
+
stream.return(value.value);
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
763
789
|
stream.next(value.value);
|
|
764
|
-
await push();
|
|
765
790
|
}
|
|
766
791
|
} catch (error) {
|
|
767
|
-
|
|
792
|
+
done = true;
|
|
793
|
+
if (!cancelled) stream.throw(error);
|
|
768
794
|
}
|
|
769
795
|
}
|
|
770
796
|
push().catch(() => {});
|
|
@@ -786,13 +812,15 @@ async function promiseToResult(current) {
|
|
|
786
812
|
//#endregion
|
|
787
813
|
//#region src/core/context/parser.ts
|
|
788
814
|
function createBaseParserContext(mode, options) {
|
|
815
|
+
var _options$compactArray;
|
|
789
816
|
return {
|
|
790
817
|
plugins: options.plugins,
|
|
791
818
|
mode,
|
|
792
819
|
marked: /* @__PURE__ */ new Set(),
|
|
793
820
|
features: 127 ^ (options.disabledFeatures || 0),
|
|
794
821
|
refs: options.refs || /* @__PURE__ */ new Map(),
|
|
795
|
-
depthLimit: options.depthLimit || 1e3
|
|
822
|
+
depthLimit: options.depthLimit || 1e3,
|
|
823
|
+
compactArrayBufferViews: (_options$compactArray = options.compactArrayBufferViews) !== null && _options$compactArray !== void 0 ? _options$compactArray : false
|
|
796
824
|
};
|
|
797
825
|
}
|
|
798
826
|
/**
|
|
@@ -872,11 +900,22 @@ function createMapNode(ctx, id, k, v) {
|
|
|
872
900
|
function createPromiseConstructorNode(ctx, id, resolver) {
|
|
873
901
|
return createSerovalNode(22, id, resolver, void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 1), void 0, void 0, void 0);
|
|
874
902
|
}
|
|
875
|
-
function
|
|
903
|
+
function getArrayBufferView(ctx, current) {
|
|
904
|
+
if (!ctx.compactArrayBufferViews) return current;
|
|
905
|
+
const buffer = new Uint8Array(current.buffer, current.byteOffset, current.byteLength).slice().buffer;
|
|
906
|
+
const Constructor = current.constructor;
|
|
907
|
+
return new Constructor(buffer);
|
|
908
|
+
}
|
|
909
|
+
function encodeArrayBuffer(current) {
|
|
910
|
+
if (typeof Buffer !== "undefined") return Buffer.from(current).toString("base64");
|
|
876
911
|
const bytes = new Uint8Array(current);
|
|
912
|
+
if (typeof bytes.toBase64 === "function") return bytes.toBase64();
|
|
877
913
|
let result = "";
|
|
878
914
|
for (let i = 0, len = bytes.length; i < len; i++) result += String.fromCharCode(bytes[i]);
|
|
879
|
-
return
|
|
915
|
+
return btoa(result);
|
|
916
|
+
}
|
|
917
|
+
function createArrayBufferNode(ctx, id, current) {
|
|
918
|
+
return createSerovalNode(19, id, encodeArrayBuffer(current), void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 5), void 0, void 0, void 0);
|
|
880
919
|
}
|
|
881
920
|
//#endregion
|
|
882
921
|
//#region src/core/context/async-parser.ts
|
|
@@ -940,12 +979,15 @@ async function parseBoxed$1(ctx, depth, id, current) {
|
|
|
940
979
|
return createBoxedNode(id, await parseAsync(ctx, depth, current.valueOf()));
|
|
941
980
|
}
|
|
942
981
|
async function parseTypedArray$1(ctx, depth, id, current) {
|
|
982
|
+
current = getArrayBufferView(ctx.base, current);
|
|
943
983
|
return createTypedArrayNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
944
984
|
}
|
|
945
985
|
async function parseBigIntTypedArray$1(ctx, depth, id, current) {
|
|
986
|
+
current = getArrayBufferView(ctx.base, current);
|
|
946
987
|
return createBigIntTypedArrayNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
947
988
|
}
|
|
948
989
|
async function parseDataView$1(ctx, depth, id, current) {
|
|
990
|
+
current = getArrayBufferView(ctx.base, current);
|
|
949
991
|
return createDataViewNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
950
992
|
}
|
|
951
993
|
async function parseError$1(ctx, depth, id, current) {
|
|
@@ -1190,7 +1232,7 @@ function isValidSymbol(symbol) {
|
|
|
1190
1232
|
}
|
|
1191
1233
|
//#endregion
|
|
1192
1234
|
//#region src/core/context/deserializer.ts
|
|
1193
|
-
const
|
|
1235
|
+
const DEFAULT_MAX_BASE64_LENGTH = 1e6;
|
|
1194
1236
|
const MAX_BIGINT_LENGTH = 1e4;
|
|
1195
1237
|
const MAX_REGEXP_SOURCE_LENGTH = 2e4;
|
|
1196
1238
|
function applyObjectFlag(obj, flag) {
|
|
@@ -1203,7 +1245,9 @@ function applyObjectFlag(obj, flag) {
|
|
|
1203
1245
|
}
|
|
1204
1246
|
const DEFAULT_DEPTH_LIMIT = 1e3;
|
|
1205
1247
|
function createBaseDeserializerContext(mode, options) {
|
|
1206
|
-
var _options$features;
|
|
1248
|
+
var _options$maxBase64Len, _options$features;
|
|
1249
|
+
const maxBase64Length = (_options$maxBase64Len = options.maxBase64Length) !== null && _options$maxBase64Len !== void 0 ? _options$maxBase64Len : DEFAULT_MAX_BASE64_LENGTH;
|
|
1250
|
+
if (!Number.isSafeInteger(maxBase64Length) || maxBase64Length < 0) throw new RangeError("maxBase64Length must be a non-negative safe integer");
|
|
1207
1251
|
const refs = options.refs || /* @__PURE__ */ new Map();
|
|
1208
1252
|
if (!("types" in refs)) Object.assign(refs, { types: /* @__PURE__ */ new Map() });
|
|
1209
1253
|
return {
|
|
@@ -1211,7 +1255,8 @@ function createBaseDeserializerContext(mode, options) {
|
|
|
1211
1255
|
plugins: options.plugins,
|
|
1212
1256
|
refs,
|
|
1213
1257
|
features: (_options$features = options.features) !== null && _options$features !== void 0 ? _options$features : 127 ^ (options.disabledFeatures || 0),
|
|
1214
|
-
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT
|
|
1258
|
+
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT,
|
|
1259
|
+
maxBase64Length
|
|
1215
1260
|
};
|
|
1216
1261
|
}
|
|
1217
1262
|
function createVanillaDeserializerContext(options) {
|
|
@@ -1374,7 +1419,8 @@ function deserializeMap(ctx, depth, node) {
|
|
|
1374
1419
|
return result;
|
|
1375
1420
|
}
|
|
1376
1421
|
function deserializeArrayBuffer(ctx, node) {
|
|
1377
|
-
if (node.s
|
|
1422
|
+
if (typeof node.s !== "string") throw new SerovalMalformedNodeError(node);
|
|
1423
|
+
if (node.s.length > ctx.base.maxBase64Length) throw new RangeError("ArrayBuffer exceeds maxBase64Length (" + ctx.base.maxBase64Length + ")");
|
|
1378
1424
|
return assignIndexedValue$1(ctx, node.i, ARRAY_BUFFER_CONSTRUCTOR(deserializeString(node.s)));
|
|
1379
1425
|
}
|
|
1380
1426
|
function deserializeTypedArray(ctx, depth, node) {
|
|
@@ -1383,7 +1429,7 @@ function deserializeTypedArray(ctx, depth, node) {
|
|
|
1383
1429
|
const source = deserialize$1(ctx, depth, node.f);
|
|
1384
1430
|
if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
|
|
1385
1431
|
const offset = (_node$b = node.b) !== null && _node$b !== void 0 ? _node$b : 0;
|
|
1386
|
-
if (offset < 0 || offset > source.byteLength || node.l >
|
|
1432
|
+
if (offset < 0 || offset > source.byteLength || node.l > ctx.base.maxBase64Length) throw new SerovalMalformedNodeError(node);
|
|
1387
1433
|
return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
|
|
1388
1434
|
}
|
|
1389
1435
|
function deserializeDataView(ctx, depth, node) {
|
|
@@ -1391,7 +1437,7 @@ function deserializeDataView(ctx, depth, node) {
|
|
|
1391
1437
|
const source = deserialize$1(ctx, depth, node.f);
|
|
1392
1438
|
if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
|
|
1393
1439
|
const offset = (_node$b2 = node.b) !== null && _node$b2 !== void 0 ? _node$b2 : 0;
|
|
1394
|
-
if (offset < 0 || offset > source.byteLength || node.l >
|
|
1440
|
+
if (offset < 0 || offset > source.byteLength || node.l > ctx.base.maxBase64Length) throw new SerovalMalformedNodeError(node);
|
|
1395
1441
|
return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
|
|
1396
1442
|
}
|
|
1397
1443
|
function deserializeDictionary(ctx, depth, node, result) {
|
|
@@ -1451,13 +1497,15 @@ function deserializePromiseFulfill(ctx, depth, node) {
|
|
|
1451
1497
|
function deserializeIteratorFactoryInstance(ctx, depth, node) {
|
|
1452
1498
|
deserialize$1(ctx, depth, node.a[0]);
|
|
1453
1499
|
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
1454
|
-
|
|
1500
|
+
validateNodeType(ctx, node, node.a[1].i, 35);
|
|
1501
|
+
if (!source) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1455
1502
|
return sequenceToIterator(source);
|
|
1456
1503
|
}
|
|
1457
1504
|
function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
|
|
1458
1505
|
deserialize$1(ctx, depth, node.a[0]);
|
|
1459
1506
|
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
1460
|
-
|
|
1507
|
+
validateNodeType(ctx, node, node.a[1].i, 31);
|
|
1508
|
+
if (!source) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1461
1509
|
return streamToAsyncIterable(source);
|
|
1462
1510
|
}
|
|
1463
1511
|
function deserializeStreamConstructor(ctx, depth, node) {
|
|
@@ -1503,6 +1551,7 @@ function deserializeAsyncIteratorFactory(ctx, depth, node) {
|
|
|
1503
1551
|
}
|
|
1504
1552
|
function deserializeSequence(ctx, depth, node) {
|
|
1505
1553
|
const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
|
|
1554
|
+
assignNodeType(ctx, node.i, 35);
|
|
1506
1555
|
for (let i = 0, len = node.a.length; i < len; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
|
|
1507
1556
|
return result;
|
|
1508
1557
|
}
|
|
@@ -2408,7 +2457,7 @@ function parseProperties(ctx, depth, properties) {
|
|
|
2408
2457
|
}
|
|
2409
2458
|
if (SYM_ASYNC_ITERATOR in properties) {
|
|
2410
2459
|
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ASYNC_ITERATOR));
|
|
2411
|
-
valueNodes.push(createAsyncIteratorFactoryInstanceNode(parseAsyncIteratorFactory(ctx.base), parseSOS(ctx, depth, ctx.type === 1 ? createStream() : createStreamFromAsyncIterable(properties))));
|
|
2460
|
+
valueNodes.push(createAsyncIteratorFactoryInstanceNode(parseAsyncIteratorFactory(ctx.base), parseSOS(ctx, depth, ctx.type === 1 ? createStream() : createStreamFromAsyncIterable(properties, ctx.state.cleanups))));
|
|
2412
2461
|
}
|
|
2413
2462
|
if (SYM_TO_STRING_TAG in properties) {
|
|
2414
2463
|
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_TO_STRING_TAG));
|
|
@@ -2430,12 +2479,15 @@ function parseBoxed(ctx, depth, id, current) {
|
|
|
2430
2479
|
return createBoxedNode(id, parseSOS(ctx, depth, current.valueOf()));
|
|
2431
2480
|
}
|
|
2432
2481
|
function parseTypedArray(ctx, depth, id, current) {
|
|
2482
|
+
current = getArrayBufferView(ctx.base, current);
|
|
2433
2483
|
return createTypedArrayNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
2434
2484
|
}
|
|
2435
2485
|
function parseBigIntTypedArray(ctx, depth, id, current) {
|
|
2486
|
+
current = getArrayBufferView(ctx.base, current);
|
|
2436
2487
|
return createBigIntTypedArrayNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
2437
2488
|
}
|
|
2438
2489
|
function parseDataView(ctx, depth, id, current) {
|
|
2490
|
+
current = getArrayBufferView(ctx.base, current);
|
|
2439
2491
|
return createDataViewNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
2440
2492
|
}
|
|
2441
2493
|
function parseError(ctx, depth, id, current) {
|
|
@@ -2686,6 +2738,7 @@ function destroyStreamParse(ctx) {
|
|
|
2686
2738
|
function crossSerialize(source, options = {}) {
|
|
2687
2739
|
const plugins = resolvePlugins(options.plugins);
|
|
2688
2740
|
const ctx = createSyncParserContext(2, {
|
|
2741
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2689
2742
|
plugins,
|
|
2690
2743
|
disabledFeatures: options.disabledFeatures,
|
|
2691
2744
|
refs: options.refs
|
|
@@ -2701,6 +2754,7 @@ function crossSerialize(source, options = {}) {
|
|
|
2701
2754
|
async function crossSerializeAsync(source, options = {}) {
|
|
2702
2755
|
const plugins = resolvePlugins(options.plugins);
|
|
2703
2756
|
const ctx = createAsyncParserContext(2, {
|
|
2757
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2704
2758
|
plugins,
|
|
2705
2759
|
disabledFeatures: options.disabledFeatures,
|
|
2706
2760
|
refs: options.refs
|
|
@@ -2714,15 +2768,19 @@ async function crossSerializeAsync(source, options = {}) {
|
|
|
2714
2768
|
}), tree);
|
|
2715
2769
|
}
|
|
2716
2770
|
function toCrossJSON(source, options = {}) {
|
|
2771
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2717
2772
|
return parseTop(createSyncParserContext(2, {
|
|
2718
|
-
|
|
2773
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2774
|
+
plugins,
|
|
2719
2775
|
disabledFeatures: options.disabledFeatures,
|
|
2720
2776
|
refs: options.refs
|
|
2721
2777
|
}), source);
|
|
2722
2778
|
}
|
|
2723
2779
|
async function toCrossJSONAsync(source, options = {}) {
|
|
2780
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2724
2781
|
return await parseTopAsync(createAsyncParserContext(2, {
|
|
2725
|
-
|
|
2782
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2783
|
+
plugins,
|
|
2726
2784
|
disabledFeatures: options.disabledFeatures,
|
|
2727
2785
|
refs: options.refs
|
|
2728
2786
|
}), source);
|
|
@@ -2730,6 +2788,7 @@ async function toCrossJSONAsync(source, options = {}) {
|
|
|
2730
2788
|
function crossSerializeStream(source, options) {
|
|
2731
2789
|
const plugins = resolvePlugins(options.plugins);
|
|
2732
2790
|
const ctx = createStreamParserContext({
|
|
2791
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2733
2792
|
plugins,
|
|
2734
2793
|
refs: options.refs,
|
|
2735
2794
|
disabledFeatures: options.disabledFeatures,
|
|
@@ -2756,8 +2815,10 @@ function crossSerializeStream(source, options) {
|
|
|
2756
2815
|
return destroyStreamParse.bind(null, ctx);
|
|
2757
2816
|
}
|
|
2758
2817
|
function toCrossJSONStream(source, options) {
|
|
2818
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2759
2819
|
const ctx = createStreamParserContext({
|
|
2760
|
-
|
|
2820
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2821
|
+
plugins,
|
|
2761
2822
|
refs: options.refs,
|
|
2762
2823
|
disabledFeatures: options.disabledFeatures,
|
|
2763
2824
|
depthLimit: options.depthLimit,
|
|
@@ -2769,8 +2830,10 @@ function toCrossJSONStream(source, options) {
|
|
|
2769
2830
|
return destroyStreamParse.bind(null, ctx);
|
|
2770
2831
|
}
|
|
2771
2832
|
function fromCrossJSON(source, options) {
|
|
2833
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2772
2834
|
return deserializeTop(createCrossDeserializerContext({
|
|
2773
|
-
|
|
2835
|
+
maxBase64Length: options.maxBase64Length,
|
|
2836
|
+
plugins,
|
|
2774
2837
|
refs: options.refs,
|
|
2775
2838
|
features: options.features,
|
|
2776
2839
|
disabledFeatures: options.disabledFeatures,
|
|
@@ -2801,6 +2864,7 @@ var Serializer = class {
|
|
|
2801
2864
|
scopeId: this.options.scopeId,
|
|
2802
2865
|
refs: this.refs,
|
|
2803
2866
|
disabledFeatures: this.options.disabledFeatures,
|
|
2867
|
+
compactArrayBufferViews: this.options.compactArrayBufferViews,
|
|
2804
2868
|
onError: this.options.onError,
|
|
2805
2869
|
onSerialize: (data, initial) => {
|
|
2806
2870
|
if (this.alive) this.options.onData(initial ? this.options.globalIdentifier + "[\"" + serializeString(key) + "\"]=" + data : data);
|
|
@@ -2851,6 +2915,7 @@ var Serializer = class {
|
|
|
2851
2915
|
function serialize(source, options = {}) {
|
|
2852
2916
|
const plugins = resolvePlugins(options.plugins);
|
|
2853
2917
|
const ctx = createSyncParserContext(1, {
|
|
2918
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2854
2919
|
plugins,
|
|
2855
2920
|
disabledFeatures: options.disabledFeatures
|
|
2856
2921
|
});
|
|
@@ -2864,6 +2929,7 @@ function serialize(source, options = {}) {
|
|
|
2864
2929
|
async function serializeAsync(source, options = {}) {
|
|
2865
2930
|
const plugins = resolvePlugins(options.plugins);
|
|
2866
2931
|
const ctx = createAsyncParserContext(1, {
|
|
2932
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2867
2933
|
plugins,
|
|
2868
2934
|
disabledFeatures: options.disabledFeatures
|
|
2869
2935
|
});
|
|
@@ -2878,8 +2944,10 @@ function deserialize(source) {
|
|
|
2878
2944
|
return (0, eval)(source);
|
|
2879
2945
|
}
|
|
2880
2946
|
function toJSON(source, options = {}) {
|
|
2947
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2881
2948
|
const ctx = createSyncParserContext(1, {
|
|
2882
|
-
|
|
2949
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2950
|
+
plugins,
|
|
2883
2951
|
disabledFeatures: options.disabledFeatures
|
|
2884
2952
|
});
|
|
2885
2953
|
return {
|
|
@@ -2889,8 +2957,10 @@ function toJSON(source, options = {}) {
|
|
|
2889
2957
|
};
|
|
2890
2958
|
}
|
|
2891
2959
|
async function toJSONAsync(source, options = {}) {
|
|
2960
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2892
2961
|
const ctx = createAsyncParserContext(1, {
|
|
2893
|
-
|
|
2962
|
+
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
2963
|
+
plugins,
|
|
2894
2964
|
disabledFeatures: options.disabledFeatures
|
|
2895
2965
|
});
|
|
2896
2966
|
return {
|
|
@@ -2912,6 +2982,7 @@ function fromJSON(source, options = {}) {
|
|
|
2912
2982
|
const disabledFeatures = options.disabledFeatures || 0;
|
|
2913
2983
|
const sourceFeatures = (_source$f = source.f) !== null && _source$f !== void 0 ? _source$f : 127;
|
|
2914
2984
|
return deserializeTop(createVanillaDeserializerContext({
|
|
2985
|
+
maxBase64Length: options.maxBase64Length,
|
|
2915
2986
|
plugins,
|
|
2916
2987
|
markedRefs: source.m,
|
|
2917
2988
|
features: sourceFeatures & ~disabledFeatures,
|
|
@@ -2919,4 +2990,4 @@ function fromJSON(source, options = {}) {
|
|
|
2919
2990
|
}), source.t);
|
|
2920
2991
|
}
|
|
2921
2992
|
//#endregion
|
|
2922
|
-
export { Feature, OpaqueReference, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
|
|
2993
|
+
export { Feature, OpaqueReference, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, isStream, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
|