seroval 1.3.0 → 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.
@@ -1461,7 +1461,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1461
1461
  const nodes = [];
1462
1462
  for (let i = 0, len = current.length; i < len; i++) {
1463
1463
  if (i in current) {
1464
- nodes[i] = await this.parseTop(current[i]);
1464
+ nodes[i] = await this.parse(current[i]);
1465
1465
  }
1466
1466
  }
1467
1467
  return nodes;
@@ -1475,7 +1475,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1475
1475
  const valueNodes = [];
1476
1476
  for (let i = 0, len = entries.length; i < len; i++) {
1477
1477
  keyNodes.push(serializeString(entries[i][0]));
1478
- valueNodes.push(await this.parseTop(entries[i][1]));
1478
+ valueNodes.push(await this.parse(entries[i][1]));
1479
1479
  }
1480
1480
  let symbol = Symbol.iterator;
1481
1481
  if (symbol in properties) {
@@ -1483,7 +1483,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1483
1483
  valueNodes.push(
1484
1484
  createIteratorFactoryInstanceNode(
1485
1485
  this.parseIteratorFactory(),
1486
- await this.parseTop(
1486
+ await this.parse(
1487
1487
  iteratorToSequence(properties)
1488
1488
  )
1489
1489
  )
@@ -1495,7 +1495,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1495
1495
  valueNodes.push(
1496
1496
  createAsyncIteratorFactoryInstanceNode(
1497
1497
  this.parseAsyncIteratorFactory(),
1498
- await this.parseTop(
1498
+ await this.parse(
1499
1499
  createStreamFromAsyncIterable(
1500
1500
  properties
1501
1501
  )
@@ -1528,24 +1528,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1528
1528
  );
1529
1529
  }
1530
1530
  async parseBoxed(id, current) {
1531
- return createBoxedNode(id, await this.parseTop(current.valueOf()));
1531
+ return createBoxedNode(id, await this.parse(current.valueOf()));
1532
1532
  }
1533
1533
  async parseTypedArray(id, current) {
1534
- return createTypedArrayNode(
1535
- id,
1536
- current,
1537
- await this.parseTop(current.buffer)
1538
- );
1534
+ return createTypedArrayNode(id, current, await this.parse(current.buffer));
1539
1535
  }
1540
1536
  async parseBigIntTypedArray(id, current) {
1541
1537
  return createBigIntTypedArrayNode(
1542
1538
  id,
1543
1539
  current,
1544
- await this.parseTop(current.buffer)
1540
+ await this.parse(current.buffer)
1545
1541
  );
1546
1542
  }
1547
1543
  async parseDataView(id, current) {
1548
- return createDataViewNode(id, current, await this.parseTop(current.buffer));
1544
+ return createDataViewNode(id, current, await this.parse(current.buffer));
1549
1545
  }
1550
1546
  async parseError(id, current) {
1551
1547
  const options = getErrorOptions(current, this.features);
@@ -1567,15 +1563,15 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1567
1563
  const keyNodes = [];
1568
1564
  const valueNodes = [];
1569
1565
  for (const [key, value] of current.entries()) {
1570
- keyNodes.push(await this.parseTop(key));
1571
- valueNodes.push(await this.parseTop(value));
1566
+ keyNodes.push(await this.parse(key));
1567
+ valueNodes.push(await this.parse(value));
1572
1568
  }
1573
1569
  return this.createMapNode(id, keyNodes, valueNodes, current.size);
1574
1570
  }
1575
1571
  async parseSet(id, current) {
1576
1572
  const items = [];
1577
1573
  for (const item of current.keys()) {
1578
- items.push(await this.parseTop(item));
1574
+ items.push(await this.parse(item));
1579
1575
  }
1580
1576
  return createSetNode(id, current.size, items);
1581
1577
  }
@@ -1591,7 +1587,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1591
1587
  NIL,
1592
1588
  NIL,
1593
1589
  NIL,
1594
- await this.parseTop(result),
1590
+ await this.parse(result),
1595
1591
  NIL,
1596
1592
  NIL
1597
1593
  );
@@ -1623,7 +1619,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1623
1619
  const cleanup = current.on({
1624
1620
  next: (value) => {
1625
1621
  this.markRef(id);
1626
- this.parseTop(value).then(
1622
+ this.parse(value).then(
1627
1623
  (data) => {
1628
1624
  sequence.push(createStreamNextNode(id, data));
1629
1625
  },
@@ -1635,7 +1631,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1635
1631
  },
1636
1632
  throw: (value) => {
1637
1633
  this.markRef(id);
1638
- this.parseTop(value).then(
1634
+ this.parse(value).then(
1639
1635
  (data) => {
1640
1636
  sequence.push(createStreamThrowNode(id, data));
1641
1637
  resolve(sequence);
@@ -1649,7 +1645,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1649
1645
  },
1650
1646
  return: (value) => {
1651
1647
  this.markRef(id);
1652
- this.parseTop(value).then(
1648
+ this.parse(value).then(
1653
1649
  (data) => {
1654
1650
  sequence.push(createStreamReturnNode(id, data));
1655
1651
  resolve(sequence);
@@ -1675,7 +1671,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1675
1671
  }
1676
1672
  const currentClass = current.constructor;
1677
1673
  if (currentClass === OpaqueReference) {
1678
- return this.parseTop(
1674
+ return this.parse(
1679
1675
  current.replacement
1680
1676
  );
1681
1677
  }
@@ -1772,7 +1768,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1772
1768
  }
1773
1769
  throw new SerovalUnsupportedTypeError(current);
1774
1770
  }
1775
- async parseTop(current) {
1771
+ async parse(current) {
1776
1772
  switch (typeof current) {
1777
1773
  case "boolean":
1778
1774
  return current ? TRUE_NODE : FALSE_NODE;
@@ -1799,9 +1795,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1799
1795
  throw new SerovalUnsupportedTypeError(current);
1800
1796
  }
1801
1797
  }
1802
- async parse(current) {
1798
+ async parseTop(current) {
1803
1799
  try {
1804
- return await this.parseTop(current);
1800
+ return await this.parse(current);
1805
1801
  } catch (error) {
1806
1802
  throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
1807
1803
  }
@@ -2014,7 +2010,10 @@ var BaseDeserializerContext = class {
2014
2010
  throw new SerovalMissingPluginError(node.c);
2015
2011
  }
2016
2012
  deserializePromiseConstructor(node) {
2017
- return this.assignIndexedValue(node.i, createDeferred()).promise;
2013
+ return this.assignIndexedValue(
2014
+ node.i,
2015
+ this.assignIndexedValue(node.s, createDeferred()).promise
2016
+ );
2018
2017
  }
2019
2018
  deserializePromiseResolve(node) {
2020
2019
  const deferred = this.refs.get(node.i);
@@ -2074,83 +2073,86 @@ var BaseDeserializerContext = class {
2074
2073
  this.deserialize(node.a[1]);
2075
2074
  return void 0;
2076
2075
  }
2077
- deserialize(node) {
2076
+ deserializeTop(node) {
2078
2077
  try {
2079
- switch (node.t) {
2080
- case 2 /* Constant */:
2081
- return CONSTANT_VAL[node.s];
2082
- case 0 /* Number */:
2083
- return node.s;
2084
- case 1 /* String */:
2085
- return deserializeString(node.s);
2086
- case 3 /* BigInt */:
2087
- return BigInt(node.s);
2088
- case 4 /* IndexedValue */:
2089
- return this.refs.get(node.i);
2090
- case 18 /* Reference */:
2091
- return this.deserializeReference(node);
2092
- case 9 /* Array */:
2093
- return this.deserializeArray(node);
2094
- case 10 /* Object */:
2095
- case 11 /* NullConstructor */:
2096
- return this.deserializeObject(node);
2097
- case 5 /* Date */:
2098
- return this.deserializeDate(node);
2099
- case 6 /* RegExp */:
2100
- return this.deserializeRegExp(node);
2101
- case 7 /* Set */:
2102
- return this.deserializeSet(node);
2103
- case 8 /* Map */:
2104
- return this.deserializeMap(node);
2105
- case 19 /* ArrayBuffer */:
2106
- return this.deserializeArrayBuffer(node);
2107
- case 16 /* BigIntTypedArray */:
2108
- case 15 /* TypedArray */:
2109
- return this.deserializeTypedArray(node);
2110
- case 20 /* DataView */:
2111
- return this.deserializeDataView(node);
2112
- case 14 /* AggregateError */:
2113
- return this.deserializeAggregateError(node);
2114
- case 13 /* Error */:
2115
- return this.deserializeError(node);
2116
- case 12 /* Promise */:
2117
- return this.deserializePromise(node);
2118
- case 17 /* WKSymbol */:
2119
- return SYMBOL_REF[node.s];
2120
- case 21 /* Boxed */:
2121
- return this.deserializeBoxed(node);
2122
- case 25 /* Plugin */:
2123
- return this.deserializePlugin(node);
2124
- case 22 /* PromiseConstructor */:
2125
- return this.deserializePromiseConstructor(node);
2126
- case 23 /* PromiseSuccess */:
2127
- return this.deserializePromiseResolve(node);
2128
- case 24 /* PromiseFailure */:
2129
- return this.deserializePromiseReject(node);
2130
- case 28 /* IteratorFactoryInstance */:
2131
- return this.deserializeIteratorFactoryInstance(node);
2132
- case 30 /* AsyncIteratorFactoryInstance */:
2133
- return this.deserializeAsyncIteratorFactoryInstance(node);
2134
- case 31 /* StreamConstructor */:
2135
- return this.deserializeStreamConstructor(node);
2136
- case 32 /* StreamNext */:
2137
- return this.deserializeStreamNext(node);
2138
- case 33 /* StreamThrow */:
2139
- return this.deserializeStreamThrow(node);
2140
- case 34 /* StreamReturn */:
2141
- return this.deserializeStreamReturn(node);
2142
- case 27 /* IteratorFactory */:
2143
- return this.deserializeIteratorFactory(node);
2144
- case 29 /* AsyncIteratorFactory */:
2145
- return this.deserializeAsyncIteratorFactory(node);
2146
- // case SerovalNodeType.SpecialReference:
2147
- default:
2148
- throw new SerovalUnsupportedNodeError(node);
2149
- }
2078
+ return this.deserialize(node);
2150
2079
  } catch (error) {
2151
2080
  throw new SerovalDeserializationError(error);
2152
2081
  }
2153
2082
  }
2083
+ deserialize(node) {
2084
+ switch (node.t) {
2085
+ case 2 /* Constant */:
2086
+ return CONSTANT_VAL[node.s];
2087
+ case 0 /* Number */:
2088
+ return node.s;
2089
+ case 1 /* String */:
2090
+ return deserializeString(node.s);
2091
+ case 3 /* BigInt */:
2092
+ return BigInt(node.s);
2093
+ case 4 /* IndexedValue */:
2094
+ return this.refs.get(node.i);
2095
+ case 18 /* Reference */:
2096
+ return this.deserializeReference(node);
2097
+ case 9 /* Array */:
2098
+ return this.deserializeArray(node);
2099
+ case 10 /* Object */:
2100
+ case 11 /* NullConstructor */:
2101
+ return this.deserializeObject(node);
2102
+ case 5 /* Date */:
2103
+ return this.deserializeDate(node);
2104
+ case 6 /* RegExp */:
2105
+ return this.deserializeRegExp(node);
2106
+ case 7 /* Set */:
2107
+ return this.deserializeSet(node);
2108
+ case 8 /* Map */:
2109
+ return this.deserializeMap(node);
2110
+ case 19 /* ArrayBuffer */:
2111
+ return this.deserializeArrayBuffer(node);
2112
+ case 16 /* BigIntTypedArray */:
2113
+ case 15 /* TypedArray */:
2114
+ return this.deserializeTypedArray(node);
2115
+ case 20 /* DataView */:
2116
+ return this.deserializeDataView(node);
2117
+ case 14 /* AggregateError */:
2118
+ return this.deserializeAggregateError(node);
2119
+ case 13 /* Error */:
2120
+ return this.deserializeError(node);
2121
+ case 12 /* Promise */:
2122
+ return this.deserializePromise(node);
2123
+ case 17 /* WKSymbol */:
2124
+ return SYMBOL_REF[node.s];
2125
+ case 21 /* Boxed */:
2126
+ return this.deserializeBoxed(node);
2127
+ case 25 /* Plugin */:
2128
+ return this.deserializePlugin(node);
2129
+ case 22 /* PromiseConstructor */:
2130
+ return this.deserializePromiseConstructor(node);
2131
+ case 23 /* PromiseSuccess */:
2132
+ return this.deserializePromiseResolve(node);
2133
+ case 24 /* PromiseFailure */:
2134
+ return this.deserializePromiseReject(node);
2135
+ case 28 /* IteratorFactoryInstance */:
2136
+ return this.deserializeIteratorFactoryInstance(node);
2137
+ case 30 /* AsyncIteratorFactoryInstance */:
2138
+ return this.deserializeAsyncIteratorFactoryInstance(node);
2139
+ case 31 /* StreamConstructor */:
2140
+ return this.deserializeStreamConstructor(node);
2141
+ case 32 /* StreamNext */:
2142
+ return this.deserializeStreamNext(node);
2143
+ case 33 /* StreamThrow */:
2144
+ return this.deserializeStreamThrow(node);
2145
+ case 34 /* StreamReturn */:
2146
+ return this.deserializeStreamReturn(node);
2147
+ case 27 /* IteratorFactory */:
2148
+ return this.deserializeIteratorFactory(node);
2149
+ case 29 /* AsyncIteratorFactory */:
2150
+ return this.deserializeAsyncIteratorFactory(node);
2151
+ // case SerovalNodeType.SpecialReference:
2152
+ default:
2153
+ throw new SerovalUnsupportedNodeError(node);
2154
+ }
2155
+ }
2154
2156
  };
2155
2157
 
2156
2158
  // src/core/cross/deserializer.ts
@@ -2813,6 +2815,15 @@ var BaseSerializerContext = class {
2813
2815
  ["s"],
2814
2816
  this.createFunction(
2815
2817
  ["b", "c", "p", "d", "e", "t", "f"],
2818
+ /**
2819
+ * b = resolved values
2820
+ * c = b size
2821
+ * p = pending promises
2822
+ * d = index where the resolved value stops
2823
+ * e = if the last value is a throw
2824
+ * t = placeholder variable
2825
+ * f = finalize
2826
+ */
2816
2827
  "(b=[],c=0,p=[],d=-1,e=!1,f=" + this.createEffectfulFunction(
2817
2828
  ["i", "l"],
2818
2829
  "for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})"
@@ -2825,9 +2836,9 @@ var BaseSerializerContext = class {
2825
2836
  ) + ",return:" + this.createEffectfulFunction(
2826
2837
  ["v", "t"],
2827
2838
  "if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)"
2828
- ) + "}),t={[" + this.getRefParam(symbol.i) + "]:" + this.createFunction([], "t") + ",next:" + this.createEffectfulFunction(
2839
+ ) + "}),t={[" + this.getRefParam(symbol.i) + "]:" + this.createFunction([], "t.p") + ",next:" + this.createEffectfulFunction(
2829
2840
  ["i", "t", "v"],
2830
- "if(d===-1){return((i=c++)>=b.length)?(p.push(t=" + this.getRefParam(promise.i) + "()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}"
2841
+ "if(d===-1){return((i=c++)>=b.length)?(" + this.getRefParam(promise.i) + "(t={p:0,s:0,f:0}),p.push(t),t.p):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}"
2831
2842
  ) + "})"
2832
2843
  )
2833
2844
  )
@@ -2985,7 +2996,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2985
2996
  const nodes = [];
2986
2997
  for (let i = 0, len = current.length; i < len; i++) {
2987
2998
  if (i in current) {
2988
- nodes[i] = this.parseTop(current[i]);
2999
+ nodes[i] = this.parse(current[i]);
2989
3000
  }
2990
3001
  }
2991
3002
  return nodes;
@@ -2999,7 +3010,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2999
3010
  const valueNodes = [];
3000
3011
  for (let i = 0, len = entries.length; i < len; i++) {
3001
3012
  keyNodes.push(serializeString(entries[i][0]));
3002
- valueNodes.push(this.parseTop(entries[i][1]));
3013
+ valueNodes.push(this.parse(entries[i][1]));
3003
3014
  }
3004
3015
  let symbol = Symbol.iterator;
3005
3016
  if (symbol in properties) {
@@ -3007,7 +3018,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3007
3018
  valueNodes.push(
3008
3019
  createIteratorFactoryInstanceNode(
3009
3020
  this.parseIteratorFactory(),
3010
- this.parseTop(
3021
+ this.parse(
3011
3022
  iteratorToSequence(properties)
3012
3023
  )
3013
3024
  )
@@ -3019,7 +3030,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3019
3030
  valueNodes.push(
3020
3031
  createAsyncIteratorFactoryInstanceNode(
3021
3032
  this.parseAsyncIteratorFactory(),
3022
- this.parseTop(createStream())
3033
+ this.parse(createStream())
3023
3034
  )
3024
3035
  );
3025
3036
  }
@@ -3048,20 +3059,16 @@ var BaseSyncParserContext = class extends BaseParserContext {
3048
3059
  );
3049
3060
  }
3050
3061
  parseBoxed(id, current) {
3051
- return createBoxedNode(id, this.parseTop(current.valueOf()));
3062
+ return createBoxedNode(id, this.parse(current.valueOf()));
3052
3063
  }
3053
3064
  parseTypedArray(id, current) {
3054
- return createTypedArrayNode(id, current, this.parseTop(current.buffer));
3065
+ return createTypedArrayNode(id, current, this.parse(current.buffer));
3055
3066
  }
3056
3067
  parseBigIntTypedArray(id, current) {
3057
- return createBigIntTypedArrayNode(
3058
- id,
3059
- current,
3060
- this.parseTop(current.buffer)
3061
- );
3068
+ return createBigIntTypedArrayNode(id, current, this.parse(current.buffer));
3062
3069
  }
3063
3070
  parseDataView(id, current) {
3064
- return createDataViewNode(id, current, this.parseTop(current.buffer));
3071
+ return createDataViewNode(id, current, this.parse(current.buffer));
3065
3072
  }
3066
3073
  parseError(id, current) {
3067
3074
  const options = getErrorOptions(current, this.features);
@@ -3083,15 +3090,15 @@ var BaseSyncParserContext = class extends BaseParserContext {
3083
3090
  const keyNodes = [];
3084
3091
  const valueNodes = [];
3085
3092
  for (const [key, value] of current.entries()) {
3086
- keyNodes.push(this.parseTop(key));
3087
- valueNodes.push(this.parseTop(value));
3093
+ keyNodes.push(this.parse(key));
3094
+ valueNodes.push(this.parse(value));
3088
3095
  }
3089
3096
  return this.createMapNode(id, keyNodes, valueNodes, current.size);
3090
3097
  }
3091
3098
  parseSet(id, current) {
3092
3099
  const items = [];
3093
3100
  for (const item of current.keys()) {
3094
- items.push(this.parseTop(item));
3101
+ items.push(this.parse(item));
3095
3102
  }
3096
3103
  return createSetNode(id, current.size, items);
3097
3104
  }
@@ -3133,7 +3140,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3133
3140
  }
3134
3141
  const currentClass = current.constructor;
3135
3142
  if (currentClass === OpaqueReference) {
3136
- return this.parseTop(
3143
+ return this.parse(
3137
3144
  current.replacement
3138
3145
  );
3139
3146
  }
@@ -3230,7 +3237,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3230
3237
  }
3231
3238
  throw new SerovalUnsupportedTypeError(current);
3232
3239
  }
3233
- parseTop(current) {
3240
+ parse(current) {
3234
3241
  switch (typeof current) {
3235
3242
  case "boolean":
3236
3243
  return current ? TRUE_NODE : FALSE_NODE;
@@ -3258,9 +3265,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
3258
3265
  throw new SerovalUnsupportedTypeError(current);
3259
3266
  }
3260
3267
  }
3261
- parse(current) {
3268
+ parseTop(current) {
3262
3269
  try {
3263
- return this.parseTop(current);
3270
+ return this.parse(current);
3264
3271
  } catch (error) {
3265
3272
  throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
3266
3273
  }
@@ -3326,7 +3333,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3326
3333
  const valueNodes = [];
3327
3334
  for (let i = 0, len = entries.length; i < len; i++) {
3328
3335
  keyNodes.push(serializeString(entries[i][0]));
3329
- valueNodes.push(this.parseTop(entries[i][1]));
3336
+ valueNodes.push(this.parse(entries[i][1]));
3330
3337
  }
3331
3338
  let symbol = Symbol.iterator;
3332
3339
  if (symbol in properties) {
@@ -3334,7 +3341,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3334
3341
  valueNodes.push(
3335
3342
  createIteratorFactoryInstanceNode(
3336
3343
  this.parseIteratorFactory(),
3337
- this.parseTop(
3344
+ this.parse(
3338
3345
  iteratorToSequence(properties)
3339
3346
  )
3340
3347
  )
@@ -3346,7 +3353,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3346
3353
  valueNodes.push(
3347
3354
  createAsyncIteratorFactoryInstanceNode(
3348
3355
  this.parseAsyncIteratorFactory(),
3349
- this.parseTop(
3356
+ this.parse(
3350
3357
  createStreamFromAsyncIterable(
3351
3358
  properties
3352
3359
  )
@@ -3485,7 +3492,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3485
3492
  }
3486
3493
  parseWithError(current) {
3487
3494
  try {
3488
- return this.parseTop(current);
3495
+ return this.parse(current);
3489
3496
  } catch (err) {
3490
3497
  this.onError(err);
3491
3498
  return NIL;
@@ -3543,7 +3550,7 @@ function crossSerialize(source, options = {}) {
3543
3550
  disabledFeatures: options.disabledFeatures,
3544
3551
  refs: options.refs
3545
3552
  });
3546
- const tree = ctx.parse(source);
3553
+ const tree = ctx.parseTop(source);
3547
3554
  const serial = new CrossSerializerContext({
3548
3555
  plugins,
3549
3556
  features: ctx.features,
@@ -3559,7 +3566,7 @@ async function crossSerializeAsync(source, options = {}) {
3559
3566
  disabledFeatures: options.disabledFeatures,
3560
3567
  refs: options.refs
3561
3568
  });
3562
- const tree = await ctx.parse(source);
3569
+ const tree = await ctx.parseTop(source);
3563
3570
  const serial = new CrossSerializerContext({
3564
3571
  plugins,
3565
3572
  features: ctx.features,
@@ -3575,7 +3582,7 @@ function toCrossJSON(source, options = {}) {
3575
3582
  disabledFeatures: options.disabledFeatures,
3576
3583
  refs: options.refs
3577
3584
  });
3578
- return ctx.parse(source);
3585
+ return ctx.parseTop(source);
3579
3586
  }
3580
3587
  async function toCrossJSONAsync(source, options = {}) {
3581
3588
  const plugins = resolvePlugins(options.plugins);
@@ -3584,7 +3591,7 @@ async function toCrossJSONAsync(source, options = {}) {
3584
3591
  disabledFeatures: options.disabledFeatures,
3585
3592
  refs: options.refs
3586
3593
  });
3587
- return await ctx.parse(source);
3594
+ return await ctx.parseTop(source);
3588
3595
  }
3589
3596
  function crossSerializeStream(source, options) {
3590
3597
  const plugins = resolvePlugins(options.plugins);
@@ -3635,7 +3642,7 @@ function fromCrossJSON(source, options) {
3635
3642
  plugins,
3636
3643
  refs: options.refs
3637
3644
  });
3638
- return ctx.deserialize(source);
3645
+ return ctx.deserializeTop(source);
3639
3646
  }
3640
3647
 
3641
3648
  // src/core/tree/async.ts
@@ -3763,7 +3770,7 @@ function serialize(source, options = {}) {
3763
3770
  plugins,
3764
3771
  disabledFeatures: options.disabledFeatures
3765
3772
  });
3766
- const tree = ctx.parse(source);
3773
+ const tree = ctx.parseTop(source);
3767
3774
  const serial = new VanillaSerializerContext({
3768
3775
  plugins,
3769
3776
  features: ctx.features,
@@ -3777,7 +3784,7 @@ async function serializeAsync(source, options = {}) {
3777
3784
  plugins,
3778
3785
  disabledFeatures: options.disabledFeatures
3779
3786
  });
3780
- const tree = await ctx.parse(source);
3787
+ const tree = await ctx.parseTop(source);
3781
3788
  const serial = new VanillaSerializerContext({
3782
3789
  plugins,
3783
3790
  features: ctx.features,
@@ -3795,7 +3802,7 @@ function toJSON(source, options = {}) {
3795
3802
  disabledFeatures: options.disabledFeatures
3796
3803
  });
3797
3804
  return {
3798
- t: ctx.parse(source),
3805
+ t: ctx.parseTop(source),
3799
3806
  f: ctx.features,
3800
3807
  m: Array.from(ctx.marked)
3801
3808
  };
@@ -3807,7 +3814,7 @@ async function toJSONAsync(source, options = {}) {
3807
3814
  disabledFeatures: options.disabledFeatures
3808
3815
  });
3809
3816
  return {
3810
- t: await ctx.parse(source),
3817
+ t: await ctx.parseTop(source),
3811
3818
  f: ctx.features,
3812
3819
  m: Array.from(ctx.marked)
3813
3820
  };
@@ -3827,7 +3834,7 @@ function fromJSON(source, options = {}) {
3827
3834
  plugins,
3828
3835
  markedRefs: source.m
3829
3836
  });
3830
- return ctx.deserialize(source.t);
3837
+ return ctx.deserializeTop(source.t);
3831
3838
  }
3832
3839
 
3833
3840
  // src/core/Serializer.ts