seroval 1.3.1 → 1.3.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.
@@ -1403,7 +1403,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1403
1403
  const nodes = [];
1404
1404
  for (let i = 0, len = current.length; i < len; i++) {
1405
1405
  if (i in current) {
1406
- nodes[i] = await this.parseTop(current[i]);
1406
+ nodes[i] = await this.parse(current[i]);
1407
1407
  }
1408
1408
  }
1409
1409
  return nodes;
@@ -1417,7 +1417,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1417
1417
  const valueNodes = [];
1418
1418
  for (let i = 0, len = entries.length; i < len; i++) {
1419
1419
  keyNodes.push(serializeString(entries[i][0]));
1420
- valueNodes.push(await this.parseTop(entries[i][1]));
1420
+ valueNodes.push(await this.parse(entries[i][1]));
1421
1421
  }
1422
1422
  let symbol = Symbol.iterator;
1423
1423
  if (symbol in properties) {
@@ -1425,7 +1425,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1425
1425
  valueNodes.push(
1426
1426
  createIteratorFactoryInstanceNode(
1427
1427
  this.parseIteratorFactory(),
1428
- await this.parseTop(
1428
+ await this.parse(
1429
1429
  iteratorToSequence(properties)
1430
1430
  )
1431
1431
  )
@@ -1437,7 +1437,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1437
1437
  valueNodes.push(
1438
1438
  createAsyncIteratorFactoryInstanceNode(
1439
1439
  this.parseAsyncIteratorFactory(),
1440
- await this.parseTop(
1440
+ await this.parse(
1441
1441
  createStreamFromAsyncIterable(
1442
1442
  properties
1443
1443
  )
@@ -1470,24 +1470,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1470
1470
  );
1471
1471
  }
1472
1472
  async parseBoxed(id, current) {
1473
- return createBoxedNode(id, await this.parseTop(current.valueOf()));
1473
+ return createBoxedNode(id, await this.parse(current.valueOf()));
1474
1474
  }
1475
1475
  async parseTypedArray(id, current) {
1476
- return createTypedArrayNode(
1477
- id,
1478
- current,
1479
- await this.parseTop(current.buffer)
1480
- );
1476
+ return createTypedArrayNode(id, current, await this.parse(current.buffer));
1481
1477
  }
1482
1478
  async parseBigIntTypedArray(id, current) {
1483
1479
  return createBigIntTypedArrayNode(
1484
1480
  id,
1485
1481
  current,
1486
- await this.parseTop(current.buffer)
1482
+ await this.parse(current.buffer)
1487
1483
  );
1488
1484
  }
1489
1485
  async parseDataView(id, current) {
1490
- return createDataViewNode(id, current, await this.parseTop(current.buffer));
1486
+ return createDataViewNode(id, current, await this.parse(current.buffer));
1491
1487
  }
1492
1488
  async parseError(id, current) {
1493
1489
  const options = getErrorOptions(current, this.features);
@@ -1509,15 +1505,15 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1509
1505
  const keyNodes = [];
1510
1506
  const valueNodes = [];
1511
1507
  for (const [key, value] of current.entries()) {
1512
- keyNodes.push(await this.parseTop(key));
1513
- valueNodes.push(await this.parseTop(value));
1508
+ keyNodes.push(await this.parse(key));
1509
+ valueNodes.push(await this.parse(value));
1514
1510
  }
1515
1511
  return this.createMapNode(id, keyNodes, valueNodes, current.size);
1516
1512
  }
1517
1513
  async parseSet(id, current) {
1518
1514
  const items = [];
1519
1515
  for (const item of current.keys()) {
1520
- items.push(await this.parseTop(item));
1516
+ items.push(await this.parse(item));
1521
1517
  }
1522
1518
  return createSetNode(id, current.size, items);
1523
1519
  }
@@ -1533,7 +1529,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1533
1529
  NIL,
1534
1530
  NIL,
1535
1531
  NIL,
1536
- await this.parseTop(result),
1532
+ await this.parse(result),
1537
1533
  NIL,
1538
1534
  NIL
1539
1535
  );
@@ -1565,7 +1561,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1565
1561
  const cleanup = current.on({
1566
1562
  next: (value) => {
1567
1563
  this.markRef(id);
1568
- this.parseTop(value).then(
1564
+ this.parse(value).then(
1569
1565
  (data) => {
1570
1566
  sequence.push(createStreamNextNode(id, data));
1571
1567
  },
@@ -1577,7 +1573,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1577
1573
  },
1578
1574
  throw: (value) => {
1579
1575
  this.markRef(id);
1580
- this.parseTop(value).then(
1576
+ this.parse(value).then(
1581
1577
  (data) => {
1582
1578
  sequence.push(createStreamThrowNode(id, data));
1583
1579
  resolve(sequence);
@@ -1591,7 +1587,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1591
1587
  },
1592
1588
  return: (value) => {
1593
1589
  this.markRef(id);
1594
- this.parseTop(value).then(
1590
+ this.parse(value).then(
1595
1591
  (data) => {
1596
1592
  sequence.push(createStreamReturnNode(id, data));
1597
1593
  resolve(sequence);
@@ -1617,7 +1613,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1617
1613
  }
1618
1614
  const currentClass = current.constructor;
1619
1615
  if (currentClass === OpaqueReference) {
1620
- return this.parseTop(
1616
+ return this.parse(
1621
1617
  current.replacement
1622
1618
  );
1623
1619
  }
@@ -1714,7 +1710,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1714
1710
  }
1715
1711
  throw new SerovalUnsupportedTypeError(current);
1716
1712
  }
1717
- async parseTop(current) {
1713
+ async parse(current) {
1718
1714
  switch (typeof current) {
1719
1715
  case "boolean":
1720
1716
  return current ? TRUE_NODE : FALSE_NODE;
@@ -1741,9 +1737,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1741
1737
  throw new SerovalUnsupportedTypeError(current);
1742
1738
  }
1743
1739
  }
1744
- async parse(current) {
1740
+ async parseTop(current) {
1745
1741
  try {
1746
- return await this.parseTop(current);
1742
+ return await this.parse(current);
1747
1743
  } catch (error) {
1748
1744
  throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
1749
1745
  }
@@ -1956,7 +1952,10 @@ var BaseDeserializerContext = class {
1956
1952
  throw new SerovalMissingPluginError(node.c);
1957
1953
  }
1958
1954
  deserializePromiseConstructor(node) {
1959
- return this.assignIndexedValue(node.i, createDeferred()).promise;
1955
+ return this.assignIndexedValue(
1956
+ node.i,
1957
+ this.assignIndexedValue(node.s, createDeferred()).promise
1958
+ );
1960
1959
  }
1961
1960
  deserializePromiseResolve(node) {
1962
1961
  const deferred = this.refs.get(node.i);
@@ -2016,83 +2015,86 @@ var BaseDeserializerContext = class {
2016
2015
  this.deserialize(node.a[1]);
2017
2016
  return void 0;
2018
2017
  }
2019
- deserialize(node) {
2018
+ deserializeTop(node) {
2020
2019
  try {
2021
- switch (node.t) {
2022
- case 2 /* Constant */:
2023
- return CONSTANT_VAL[node.s];
2024
- case 0 /* Number */:
2025
- return node.s;
2026
- case 1 /* String */:
2027
- return deserializeString(node.s);
2028
- case 3 /* BigInt */:
2029
- return BigInt(node.s);
2030
- case 4 /* IndexedValue */:
2031
- return this.refs.get(node.i);
2032
- case 18 /* Reference */:
2033
- return this.deserializeReference(node);
2034
- case 9 /* Array */:
2035
- return this.deserializeArray(node);
2036
- case 10 /* Object */:
2037
- case 11 /* NullConstructor */:
2038
- return this.deserializeObject(node);
2039
- case 5 /* Date */:
2040
- return this.deserializeDate(node);
2041
- case 6 /* RegExp */:
2042
- return this.deserializeRegExp(node);
2043
- case 7 /* Set */:
2044
- return this.deserializeSet(node);
2045
- case 8 /* Map */:
2046
- return this.deserializeMap(node);
2047
- case 19 /* ArrayBuffer */:
2048
- return this.deserializeArrayBuffer(node);
2049
- case 16 /* BigIntTypedArray */:
2050
- case 15 /* TypedArray */:
2051
- return this.deserializeTypedArray(node);
2052
- case 20 /* DataView */:
2053
- return this.deserializeDataView(node);
2054
- case 14 /* AggregateError */:
2055
- return this.deserializeAggregateError(node);
2056
- case 13 /* Error */:
2057
- return this.deserializeError(node);
2058
- case 12 /* Promise */:
2059
- return this.deserializePromise(node);
2060
- case 17 /* WKSymbol */:
2061
- return SYMBOL_REF[node.s];
2062
- case 21 /* Boxed */:
2063
- return this.deserializeBoxed(node);
2064
- case 25 /* Plugin */:
2065
- return this.deserializePlugin(node);
2066
- case 22 /* PromiseConstructor */:
2067
- return this.deserializePromiseConstructor(node);
2068
- case 23 /* PromiseSuccess */:
2069
- return this.deserializePromiseResolve(node);
2070
- case 24 /* PromiseFailure */:
2071
- return this.deserializePromiseReject(node);
2072
- case 28 /* IteratorFactoryInstance */:
2073
- return this.deserializeIteratorFactoryInstance(node);
2074
- case 30 /* AsyncIteratorFactoryInstance */:
2075
- return this.deserializeAsyncIteratorFactoryInstance(node);
2076
- case 31 /* StreamConstructor */:
2077
- return this.deserializeStreamConstructor(node);
2078
- case 32 /* StreamNext */:
2079
- return this.deserializeStreamNext(node);
2080
- case 33 /* StreamThrow */:
2081
- return this.deserializeStreamThrow(node);
2082
- case 34 /* StreamReturn */:
2083
- return this.deserializeStreamReturn(node);
2084
- case 27 /* IteratorFactory */:
2085
- return this.deserializeIteratorFactory(node);
2086
- case 29 /* AsyncIteratorFactory */:
2087
- return this.deserializeAsyncIteratorFactory(node);
2088
- // case SerovalNodeType.SpecialReference:
2089
- default:
2090
- throw new SerovalUnsupportedNodeError(node);
2091
- }
2020
+ return this.deserialize(node);
2092
2021
  } catch (error) {
2093
2022
  throw new SerovalDeserializationError(error);
2094
2023
  }
2095
2024
  }
2025
+ deserialize(node) {
2026
+ switch (node.t) {
2027
+ case 2 /* Constant */:
2028
+ return CONSTANT_VAL[node.s];
2029
+ case 0 /* Number */:
2030
+ return node.s;
2031
+ case 1 /* String */:
2032
+ return deserializeString(node.s);
2033
+ case 3 /* BigInt */:
2034
+ return BigInt(node.s);
2035
+ case 4 /* IndexedValue */:
2036
+ return this.refs.get(node.i);
2037
+ case 18 /* Reference */:
2038
+ return this.deserializeReference(node);
2039
+ case 9 /* Array */:
2040
+ return this.deserializeArray(node);
2041
+ case 10 /* Object */:
2042
+ case 11 /* NullConstructor */:
2043
+ return this.deserializeObject(node);
2044
+ case 5 /* Date */:
2045
+ return this.deserializeDate(node);
2046
+ case 6 /* RegExp */:
2047
+ return this.deserializeRegExp(node);
2048
+ case 7 /* Set */:
2049
+ return this.deserializeSet(node);
2050
+ case 8 /* Map */:
2051
+ return this.deserializeMap(node);
2052
+ case 19 /* ArrayBuffer */:
2053
+ return this.deserializeArrayBuffer(node);
2054
+ case 16 /* BigIntTypedArray */:
2055
+ case 15 /* TypedArray */:
2056
+ return this.deserializeTypedArray(node);
2057
+ case 20 /* DataView */:
2058
+ return this.deserializeDataView(node);
2059
+ case 14 /* AggregateError */:
2060
+ return this.deserializeAggregateError(node);
2061
+ case 13 /* Error */:
2062
+ return this.deserializeError(node);
2063
+ case 12 /* Promise */:
2064
+ return this.deserializePromise(node);
2065
+ case 17 /* WKSymbol */:
2066
+ return SYMBOL_REF[node.s];
2067
+ case 21 /* Boxed */:
2068
+ return this.deserializeBoxed(node);
2069
+ case 25 /* Plugin */:
2070
+ return this.deserializePlugin(node);
2071
+ case 22 /* PromiseConstructor */:
2072
+ return this.deserializePromiseConstructor(node);
2073
+ case 23 /* PromiseSuccess */:
2074
+ return this.deserializePromiseResolve(node);
2075
+ case 24 /* PromiseFailure */:
2076
+ return this.deserializePromiseReject(node);
2077
+ case 28 /* IteratorFactoryInstance */:
2078
+ return this.deserializeIteratorFactoryInstance(node);
2079
+ case 30 /* AsyncIteratorFactoryInstance */:
2080
+ return this.deserializeAsyncIteratorFactoryInstance(node);
2081
+ case 31 /* StreamConstructor */:
2082
+ return this.deserializeStreamConstructor(node);
2083
+ case 32 /* StreamNext */:
2084
+ return this.deserializeStreamNext(node);
2085
+ case 33 /* StreamThrow */:
2086
+ return this.deserializeStreamThrow(node);
2087
+ case 34 /* StreamReturn */:
2088
+ return this.deserializeStreamReturn(node);
2089
+ case 27 /* IteratorFactory */:
2090
+ return this.deserializeIteratorFactory(node);
2091
+ case 29 /* AsyncIteratorFactory */:
2092
+ return this.deserializeAsyncIteratorFactory(node);
2093
+ // case SerovalNodeType.SpecialReference:
2094
+ default:
2095
+ throw new SerovalUnsupportedNodeError(node);
2096
+ }
2097
+ }
2096
2098
  };
2097
2099
 
2098
2100
  // src/core/cross/deserializer.ts
@@ -2936,7 +2938,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2936
2938
  const nodes = [];
2937
2939
  for (let i = 0, len = current.length; i < len; i++) {
2938
2940
  if (i in current) {
2939
- nodes[i] = this.parseTop(current[i]);
2941
+ nodes[i] = this.parse(current[i]);
2940
2942
  }
2941
2943
  }
2942
2944
  return nodes;
@@ -2950,7 +2952,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2950
2952
  const valueNodes = [];
2951
2953
  for (let i = 0, len = entries.length; i < len; i++) {
2952
2954
  keyNodes.push(serializeString(entries[i][0]));
2953
- valueNodes.push(this.parseTop(entries[i][1]));
2955
+ valueNodes.push(this.parse(entries[i][1]));
2954
2956
  }
2955
2957
  let symbol = Symbol.iterator;
2956
2958
  if (symbol in properties) {
@@ -2958,7 +2960,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2958
2960
  valueNodes.push(
2959
2961
  createIteratorFactoryInstanceNode(
2960
2962
  this.parseIteratorFactory(),
2961
- this.parseTop(
2963
+ this.parse(
2962
2964
  iteratorToSequence(properties)
2963
2965
  )
2964
2966
  )
@@ -2970,7 +2972,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2970
2972
  valueNodes.push(
2971
2973
  createAsyncIteratorFactoryInstanceNode(
2972
2974
  this.parseAsyncIteratorFactory(),
2973
- this.parseTop(createStream())
2975
+ this.parse(createStream())
2974
2976
  )
2975
2977
  );
2976
2978
  }
@@ -2999,20 +3001,16 @@ var BaseSyncParserContext = class extends BaseParserContext {
2999
3001
  );
3000
3002
  }
3001
3003
  parseBoxed(id, current) {
3002
- return createBoxedNode(id, this.parseTop(current.valueOf()));
3004
+ return createBoxedNode(id, this.parse(current.valueOf()));
3003
3005
  }
3004
3006
  parseTypedArray(id, current) {
3005
- return createTypedArrayNode(id, current, this.parseTop(current.buffer));
3007
+ return createTypedArrayNode(id, current, this.parse(current.buffer));
3006
3008
  }
3007
3009
  parseBigIntTypedArray(id, current) {
3008
- return createBigIntTypedArrayNode(
3009
- id,
3010
- current,
3011
- this.parseTop(current.buffer)
3012
- );
3010
+ return createBigIntTypedArrayNode(id, current, this.parse(current.buffer));
3013
3011
  }
3014
3012
  parseDataView(id, current) {
3015
- return createDataViewNode(id, current, this.parseTop(current.buffer));
3013
+ return createDataViewNode(id, current, this.parse(current.buffer));
3016
3014
  }
3017
3015
  parseError(id, current) {
3018
3016
  const options = getErrorOptions(current, this.features);
@@ -3034,15 +3032,15 @@ var BaseSyncParserContext = class extends BaseParserContext {
3034
3032
  const keyNodes = [];
3035
3033
  const valueNodes = [];
3036
3034
  for (const [key, value] of current.entries()) {
3037
- keyNodes.push(this.parseTop(key));
3038
- valueNodes.push(this.parseTop(value));
3035
+ keyNodes.push(this.parse(key));
3036
+ valueNodes.push(this.parse(value));
3039
3037
  }
3040
3038
  return this.createMapNode(id, keyNodes, valueNodes, current.size);
3041
3039
  }
3042
3040
  parseSet(id, current) {
3043
3041
  const items = [];
3044
3042
  for (const item of current.keys()) {
3045
- items.push(this.parseTop(item));
3043
+ items.push(this.parse(item));
3046
3044
  }
3047
3045
  return createSetNode(id, current.size, items);
3048
3046
  }
@@ -3084,7 +3082,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3084
3082
  }
3085
3083
  const currentClass = current.constructor;
3086
3084
  if (currentClass === OpaqueReference) {
3087
- return this.parseTop(
3085
+ return this.parse(
3088
3086
  current.replacement
3089
3087
  );
3090
3088
  }
@@ -3181,7 +3179,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3181
3179
  }
3182
3180
  throw new SerovalUnsupportedTypeError(current);
3183
3181
  }
3184
- parseTop(current) {
3182
+ parse(current) {
3185
3183
  switch (typeof current) {
3186
3184
  case "boolean":
3187
3185
  return current ? TRUE_NODE : FALSE_NODE;
@@ -3209,9 +3207,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
3209
3207
  throw new SerovalUnsupportedTypeError(current);
3210
3208
  }
3211
3209
  }
3212
- parse(current) {
3210
+ parseTop(current) {
3213
3211
  try {
3214
- return this.parseTop(current);
3212
+ return this.parse(current);
3215
3213
  } catch (error) {
3216
3214
  throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
3217
3215
  }
@@ -3277,7 +3275,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3277
3275
  const valueNodes = [];
3278
3276
  for (let i = 0, len = entries.length; i < len; i++) {
3279
3277
  keyNodes.push(serializeString(entries[i][0]));
3280
- valueNodes.push(this.parseTop(entries[i][1]));
3278
+ valueNodes.push(this.parse(entries[i][1]));
3281
3279
  }
3282
3280
  let symbol = Symbol.iterator;
3283
3281
  if (symbol in properties) {
@@ -3285,7 +3283,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3285
3283
  valueNodes.push(
3286
3284
  createIteratorFactoryInstanceNode(
3287
3285
  this.parseIteratorFactory(),
3288
- this.parseTop(
3286
+ this.parse(
3289
3287
  iteratorToSequence(properties)
3290
3288
  )
3291
3289
  )
@@ -3297,7 +3295,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3297
3295
  valueNodes.push(
3298
3296
  createAsyncIteratorFactoryInstanceNode(
3299
3297
  this.parseAsyncIteratorFactory(),
3300
- this.parseTop(
3298
+ this.parse(
3301
3299
  createStreamFromAsyncIterable(
3302
3300
  properties
3303
3301
  )
@@ -3436,7 +3434,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3436
3434
  }
3437
3435
  parseWithError(current) {
3438
3436
  try {
3439
- return this.parseTop(current);
3437
+ return this.parse(current);
3440
3438
  } catch (err) {
3441
3439
  this.onError(err);
3442
3440
  return NIL;
@@ -3494,7 +3492,7 @@ function crossSerialize(source, options = {}) {
3494
3492
  disabledFeatures: options.disabledFeatures,
3495
3493
  refs: options.refs
3496
3494
  });
3497
- const tree = ctx.parse(source);
3495
+ const tree = ctx.parseTop(source);
3498
3496
  const serial = new CrossSerializerContext({
3499
3497
  plugins,
3500
3498
  features: ctx.features,
@@ -3510,7 +3508,7 @@ async function crossSerializeAsync(source, options = {}) {
3510
3508
  disabledFeatures: options.disabledFeatures,
3511
3509
  refs: options.refs
3512
3510
  });
3513
- const tree = await ctx.parse(source);
3511
+ const tree = await ctx.parseTop(source);
3514
3512
  const serial = new CrossSerializerContext({
3515
3513
  plugins,
3516
3514
  features: ctx.features,
@@ -3526,7 +3524,7 @@ function toCrossJSON(source, options = {}) {
3526
3524
  disabledFeatures: options.disabledFeatures,
3527
3525
  refs: options.refs
3528
3526
  });
3529
- return ctx.parse(source);
3527
+ return ctx.parseTop(source);
3530
3528
  }
3531
3529
  async function toCrossJSONAsync(source, options = {}) {
3532
3530
  const plugins = resolvePlugins(options.plugins);
@@ -3535,7 +3533,7 @@ async function toCrossJSONAsync(source, options = {}) {
3535
3533
  disabledFeatures: options.disabledFeatures,
3536
3534
  refs: options.refs
3537
3535
  });
3538
- return await ctx.parse(source);
3536
+ return await ctx.parseTop(source);
3539
3537
  }
3540
3538
  function crossSerializeStream(source, options) {
3541
3539
  const plugins = resolvePlugins(options.plugins);
@@ -3586,7 +3584,7 @@ function fromCrossJSON(source, options) {
3586
3584
  plugins,
3587
3585
  refs: options.refs
3588
3586
  });
3589
- return ctx.deserialize(source);
3587
+ return ctx.deserializeTop(source);
3590
3588
  }
3591
3589
 
3592
3590
  // src/core/tree/async.ts
@@ -3714,7 +3712,7 @@ function serialize(source, options = {}) {
3714
3712
  plugins,
3715
3713
  disabledFeatures: options.disabledFeatures
3716
3714
  });
3717
- const tree = ctx.parse(source);
3715
+ const tree = ctx.parseTop(source);
3718
3716
  const serial = new VanillaSerializerContext({
3719
3717
  plugins,
3720
3718
  features: ctx.features,
@@ -3728,7 +3726,7 @@ async function serializeAsync(source, options = {}) {
3728
3726
  plugins,
3729
3727
  disabledFeatures: options.disabledFeatures
3730
3728
  });
3731
- const tree = await ctx.parse(source);
3729
+ const tree = await ctx.parseTop(source);
3732
3730
  const serial = new VanillaSerializerContext({
3733
3731
  plugins,
3734
3732
  features: ctx.features,
@@ -3746,7 +3744,7 @@ function toJSON(source, options = {}) {
3746
3744
  disabledFeatures: options.disabledFeatures
3747
3745
  });
3748
3746
  return {
3749
- t: ctx.parse(source),
3747
+ t: ctx.parseTop(source),
3750
3748
  f: ctx.features,
3751
3749
  m: Array.from(ctx.marked)
3752
3750
  };
@@ -3758,7 +3756,7 @@ async function toJSONAsync(source, options = {}) {
3758
3756
  disabledFeatures: options.disabledFeatures
3759
3757
  });
3760
3758
  return {
3761
- t: await ctx.parse(source),
3759
+ t: await ctx.parseTop(source),
3762
3760
  f: ctx.features,
3763
3761
  m: Array.from(ctx.marked)
3764
3762
  };
@@ -3778,7 +3776,7 @@ function fromJSON(source, options = {}) {
3778
3776
  plugins,
3779
3777
  markedRefs: source.m
3780
3778
  });
3781
- return ctx.deserialize(source.t);
3779
+ return ctx.deserializeTop(source.t);
3782
3780
  }
3783
3781
 
3784
3782
  // src/core/Serializer.ts