seroval 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/development/index.cjs +283 -398
  3. package/dist/cjs/development/index.cjs.map +3 -3
  4. package/dist/cjs/production/index.cjs +5 -5
  5. package/dist/esm/development/index.mjs +283 -398
  6. package/dist/esm/development/index.mjs.map +3 -3
  7. package/dist/esm/production/index.mjs +5 -5
  8. package/dist/types/core/base-primitives.d.ts +1 -2
  9. package/dist/types/core/base-primitives.d.ts.map +1 -1
  10. package/dist/types/core/compat.d.ts +2 -3
  11. package/dist/types/core/compat.d.ts.map +1 -1
  12. package/dist/types/core/constants.d.ts +3 -6
  13. package/dist/types/core/constants.d.ts.map +1 -1
  14. package/dist/types/core/context/deserializer.d.ts +0 -3
  15. package/dist/types/core/context/deserializer.d.ts.map +1 -1
  16. package/dist/types/core/context/parser/async.d.ts +2 -2
  17. package/dist/types/core/context/parser/async.d.ts.map +1 -1
  18. package/dist/types/core/context/parser/stream.d.ts +8 -7
  19. package/dist/types/core/context/parser/stream.d.ts.map +1 -1
  20. package/dist/types/core/context/parser/sync.d.ts +3 -3
  21. package/dist/types/core/context/parser/sync.d.ts.map +1 -1
  22. package/dist/types/core/context/parser.d.ts +10 -12
  23. package/dist/types/core/context/parser.d.ts.map +1 -1
  24. package/dist/types/core/context/serializer.d.ts +1 -5
  25. package/dist/types/core/context/serializer.d.ts.map +1 -1
  26. package/dist/types/core/cross/index.d.ts.map +1 -1
  27. package/dist/types/core/function-string.d.ts +3 -0
  28. package/dist/types/core/function-string.d.ts.map +1 -0
  29. package/dist/types/core/special-reference.d.ts +4 -5
  30. package/dist/types/core/special-reference.d.ts.map +1 -1
  31. package/dist/types/core/tree/serializer.d.ts +1 -2
  32. package/dist/types/core/tree/serializer.d.ts.map +1 -1
  33. package/dist/types/core/types.d.ts +5 -19
  34. package/dist/types/core/types.d.ts.map +1 -1
  35. package/package.json +9 -9
  36. package/src/core/base-primitives.ts +2 -22
  37. package/src/core/compat.ts +6 -2
  38. package/src/core/constants.ts +2 -5
  39. package/src/core/context/deserializer.ts +2 -35
  40. package/src/core/context/parser/async.ts +67 -84
  41. package/src/core/context/parser/stream.ts +64 -109
  42. package/src/core/context/parser/sync.ts +66 -83
  43. package/src/core/context/parser.ts +24 -56
  44. package/src/core/context/serializer.ts +12 -128
  45. package/src/core/cross/index.ts +2 -6
  46. package/src/core/function-string.ts +31 -0
  47. package/src/core/special-reference.ts +96 -8
  48. package/src/core/tree/serializer.ts +0 -7
  49. package/src/core/types.ts +5 -27
  50. package/dist/types/core/abort-signal.d.ts +0 -2
  51. package/dist/types/core/abort-signal.d.ts.map +0 -1
  52. package/src/core/abort-signal.ts +0 -13
@@ -63,10 +63,9 @@ var Feature = /* @__PURE__ */ ((Feature2) => {
63
63
  Feature2[Feature2["ErrorPrototypeStack"] = 4] = "ErrorPrototypeStack";
64
64
  Feature2[Feature2["ObjectAssign"] = 8] = "ObjectAssign";
65
65
  Feature2[Feature2["BigIntTypedArray"] = 16] = "BigIntTypedArray";
66
- Feature2[Feature2["AbortSignal"] = 32] = "AbortSignal";
67
66
  return Feature2;
68
67
  })(Feature || {});
69
- var ALL_ENABLED = 47;
68
+ var ALL_ENABLED = 1 /* AggregateError */ | 2 /* ArrowFunction */ | 4 /* ErrorPrototypeStack */ | 8 /* ObjectAssign */ | 16 /* BigIntTypedArray */;
70
69
 
71
70
  // src/core/string.ts
72
71
  function serializeChar(str) {
@@ -242,21 +241,6 @@ function resolvePlugins(plugins) {
242
241
  return void 0;
243
242
  }
244
243
 
245
- // src/core/abort-signal.ts
246
- function abortSignalToPromise(signal) {
247
- return new Promise((resolve) => {
248
- signal.addEventListener(
249
- "abort",
250
- () => {
251
- resolve(signal.reason);
252
- },
253
- {
254
- once: true
255
- }
256
- );
257
- });
258
- }
259
-
260
244
  // src/core/constants.ts
261
245
  var SYMBOL_STRING = {
262
246
  [0 /* AsyncIterator */]: "Symbol.asyncIterator",
@@ -545,10 +529,11 @@ function createIndexedValueNode(id) {
545
529
  );
546
530
  }
547
531
  function createDateNode(id, current) {
532
+ const timestamp = current.valueOf();
548
533
  return createSerovalNode(
549
534
  5 /* Date */,
550
535
  id,
551
- current.toISOString(),
536
+ timestamp !== timestamp ? "" : current.toISOString(),
552
537
  NIL,
553
538
  NIL,
554
539
  NIL,
@@ -964,18 +949,96 @@ var OpaqueReference = class {
964
949
  }
965
950
  };
966
951
 
952
+ // src/core/function-string.ts
953
+ function createFunction(features, parameters, body) {
954
+ if (features & 2 /* ArrowFunction */) {
955
+ const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
956
+ return joined + "=>" + (body.startsWith("{") ? "(" + body + ")" : body);
957
+ }
958
+ return "function(" + parameters.join(",") + "){return " + body + "}";
959
+ }
960
+ function createEffectfulFunction(features, parameters, body) {
961
+ if (features & 2 /* ArrowFunction */) {
962
+ const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
963
+ return joined + "=>{" + body + "}";
964
+ }
965
+ return "function(" + parameters.join(",") + "){" + body + "}";
966
+ }
967
+
967
968
  // src/core/special-reference.ts
968
969
  var ITERATOR = {};
969
970
  var ASYNC_ITERATOR = {};
970
971
  var SPECIAL_REFS = {
971
972
  [0 /* MapSentinel */]: {},
972
973
  [1 /* PromiseConstructor */]: {},
973
- [2 /* PromiseResolve */]: {},
974
- [3 /* PromiseReject */]: {},
975
- [4 /* StreamConstructor */]: {},
976
- [5 /* AbortSignalConstructor */]: {},
977
- [6 /* AbortSignalAbort */]: {}
974
+ [2 /* PromiseSuccess */]: {},
975
+ [3 /* PromiseFailure */]: {},
976
+ [4 /* StreamConstructor */]: {}
978
977
  };
978
+ function serializePromiseConstructor(features) {
979
+ return createFunction(
980
+ features,
981
+ ["r"],
982
+ "(r.p=new Promise(" + createEffectfulFunction(features, ["s", "f"], "r.s=s,r.f=f") + "))"
983
+ );
984
+ }
985
+ function serializePromiseSuccess(features) {
986
+ return createEffectfulFunction(
987
+ features,
988
+ ["r", "d"],
989
+ "r.s(d),r.p.s=1,r.p.v=d"
990
+ );
991
+ }
992
+ function serializePromiseFailure(features) {
993
+ return createEffectfulFunction(
994
+ features,
995
+ ["r", "d"],
996
+ "r.f(d),r.p.s=2,r.p.v=d"
997
+ );
998
+ }
999
+ function serializeStreamConstructor(features) {
1000
+ return createFunction(
1001
+ features,
1002
+ ["b", "a", "s", "l", "p", "f", "e", "n"],
1003
+ "(b=[],a=!0,s=!1,l=[],p=0,f=" + createEffectfulFunction(
1004
+ features,
1005
+ ["v", "m", "x"],
1006
+ "for(x=0;x<p;x++)l[x]&&l[x][m](v)"
1007
+ ) + ",n=" + createEffectfulFunction(
1008
+ features,
1009
+ ["o", "x", "z", "c"],
1010
+ 'for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))'
1011
+ ) + ",e=" + createFunction(
1012
+ features,
1013
+ ["o", "t"],
1014
+ "(a&&(l[t=p++]=o),n(o)," + createEffectfulFunction(features, [], "a&&(l[t]=void 0)") + ")"
1015
+ ) + ",{__SEROVAL_STREAM__:!0,on:" + createFunction(features, ["o"], "e(o)") + ",next:" + createEffectfulFunction(features, ["v"], 'a&&(b.push(v),f(v,"next"))') + ",throw:" + createEffectfulFunction(
1016
+ features,
1017
+ ["v"],
1018
+ 'a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)'
1019
+ ) + ",return:" + createEffectfulFunction(
1020
+ features,
1021
+ ["v"],
1022
+ 'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
1023
+ ) + "})"
1024
+ );
1025
+ }
1026
+ function serializeSpecialReferenceValue(features, ref) {
1027
+ switch (ref) {
1028
+ case 0 /* MapSentinel */:
1029
+ return "[]";
1030
+ case 1 /* PromiseConstructor */:
1031
+ return serializePromiseConstructor(features);
1032
+ case 2 /* PromiseSuccess */:
1033
+ return serializePromiseSuccess(features);
1034
+ case 3 /* PromiseFailure */:
1035
+ return serializePromiseFailure(features);
1036
+ case 4 /* StreamConstructor */:
1037
+ return serializeStreamConstructor(features);
1038
+ default:
1039
+ return "";
1040
+ }
1041
+ }
979
1042
 
980
1043
  // src/core/utils/deferred.ts
981
1044
  function createDeferred() {
@@ -1239,6 +1302,11 @@ var BaseParserContext = class {
1239
1302
  isMarked(id) {
1240
1303
  return this.marked.has(id);
1241
1304
  }
1305
+ createIndex(current) {
1306
+ const id = this.refs.size;
1307
+ this.refs.set(current, id);
1308
+ return id;
1309
+ }
1242
1310
  getIndexedValue(current) {
1243
1311
  const registeredId = this.refs.get(current);
1244
1312
  if (registeredId != null) {
@@ -1248,11 +1316,9 @@ var BaseParserContext = class {
1248
1316
  value: createIndexedValueNode(registeredId)
1249
1317
  };
1250
1318
  }
1251
- const id = this.refs.size;
1252
- this.refs.set(current, id);
1253
1319
  return {
1254
1320
  type: 0 /* Fresh */,
1255
- value: id
1321
+ value: this.createIndex(current)
1256
1322
  };
1257
1323
  }
1258
1324
  getReference(current) {
@@ -1268,17 +1334,6 @@ var BaseParserContext = class {
1268
1334
  }
1269
1335
  return indexed;
1270
1336
  }
1271
- getStrictReference(current) {
1272
- assert(hasReferenceID(current), new SerovalUnsupportedTypeError(current));
1273
- const result = this.getIndexedValue(current);
1274
- if (result.type === 1 /* Indexed */) {
1275
- return result.value;
1276
- }
1277
- return createReferenceNode(result.value, current);
1278
- }
1279
- parseFunction(current) {
1280
- return this.getStrictReference(current);
1281
- }
1282
1337
  parseWellKnownSymbol(current) {
1283
1338
  const ref = this.getReference(current);
1284
1339
  if (ref.type !== 0 /* Fresh */) {
@@ -1382,11 +1437,11 @@ var BaseParserContext = class {
1382
1437
  NIL
1383
1438
  );
1384
1439
  }
1385
- createPromiseConstructorNode(id) {
1440
+ createPromiseConstructorNode(id, resolver) {
1386
1441
  return createSerovalNode(
1387
1442
  22 /* PromiseConstructor */,
1388
1443
  id,
1389
- NIL,
1444
+ resolver,
1390
1445
  NIL,
1391
1446
  NIL,
1392
1447
  NIL,
@@ -1398,22 +1453,6 @@ var BaseParserContext = class {
1398
1453
  NIL
1399
1454
  );
1400
1455
  }
1401
- createAbortSignalConstructorNode(id) {
1402
- return createSerovalNode(
1403
- 35 /* AbortSignalConstructor */,
1404
- id,
1405
- NIL,
1406
- NIL,
1407
- NIL,
1408
- NIL,
1409
- NIL,
1410
- NIL,
1411
- NIL,
1412
- this.parseSpecialReference(5 /* AbortSignalConstructor */),
1413
- NIL,
1414
- NIL
1415
- );
1416
- }
1417
1456
  };
1418
1457
 
1419
1458
  // src/core/context/parser/async.ts
@@ -1422,7 +1461,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1422
1461
  const nodes = [];
1423
1462
  for (let i = 0, len = current.length; i < len; i++) {
1424
1463
  if (i in current) {
1425
- nodes[i] = await this.parse(current[i]);
1464
+ nodes[i] = await this.parseTop(current[i]);
1426
1465
  }
1427
1466
  }
1428
1467
  return nodes;
@@ -1436,7 +1475,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1436
1475
  const valueNodes = [];
1437
1476
  for (let i = 0, len = entries.length; i < len; i++) {
1438
1477
  keyNodes.push(serializeString(entries[i][0]));
1439
- valueNodes.push(await this.parse(entries[i][1]));
1478
+ valueNodes.push(await this.parseTop(entries[i][1]));
1440
1479
  }
1441
1480
  let symbol = Symbol.iterator;
1442
1481
  if (symbol in properties) {
@@ -1444,7 +1483,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1444
1483
  valueNodes.push(
1445
1484
  createIteratorFactoryInstanceNode(
1446
1485
  this.parseIteratorFactory(),
1447
- await this.parse(
1486
+ await this.parseTop(
1448
1487
  iteratorToSequence(properties)
1449
1488
  )
1450
1489
  )
@@ -1456,7 +1495,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1456
1495
  valueNodes.push(
1457
1496
  createAsyncIteratorFactoryInstanceNode(
1458
1497
  this.parseAsyncIteratorFactory(),
1459
- await this.parse(
1498
+ await this.parseTop(
1460
1499
  createStreamFromAsyncIterable(
1461
1500
  properties
1462
1501
  )
@@ -1489,20 +1528,24 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1489
1528
  );
1490
1529
  }
1491
1530
  async parseBoxed(id, current) {
1492
- return createBoxedNode(id, await this.parse(current.valueOf()));
1531
+ return createBoxedNode(id, await this.parseTop(current.valueOf()));
1493
1532
  }
1494
1533
  async parseTypedArray(id, current) {
1495
- return createTypedArrayNode(id, current, await this.parse(current.buffer));
1534
+ return createTypedArrayNode(
1535
+ id,
1536
+ current,
1537
+ await this.parseTop(current.buffer)
1538
+ );
1496
1539
  }
1497
1540
  async parseBigIntTypedArray(id, current) {
1498
1541
  return createBigIntTypedArrayNode(
1499
1542
  id,
1500
1543
  current,
1501
- await this.parse(current.buffer)
1544
+ await this.parseTop(current.buffer)
1502
1545
  );
1503
1546
  }
1504
1547
  async parseDataView(id, current) {
1505
- return createDataViewNode(id, current, await this.parse(current.buffer));
1548
+ return createDataViewNode(id, current, await this.parseTop(current.buffer));
1506
1549
  }
1507
1550
  async parseError(id, current) {
1508
1551
  const options = getErrorOptions(current, this.features);
@@ -1524,15 +1567,15 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1524
1567
  const keyNodes = [];
1525
1568
  const valueNodes = [];
1526
1569
  for (const [key, value] of current.entries()) {
1527
- keyNodes.push(await this.parse(key));
1528
- valueNodes.push(await this.parse(value));
1570
+ keyNodes.push(await this.parseTop(key));
1571
+ valueNodes.push(await this.parseTop(value));
1529
1572
  }
1530
1573
  return this.createMapNode(id, keyNodes, valueNodes, current.size);
1531
1574
  }
1532
1575
  async parseSet(id, current) {
1533
1576
  const items = [];
1534
1577
  for (const item of current.keys()) {
1535
- items.push(await this.parse(item));
1578
+ items.push(await this.parseTop(item));
1536
1579
  }
1537
1580
  return createSetNode(id, current.size, items);
1538
1581
  }
@@ -1548,7 +1591,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1548
1591
  NIL,
1549
1592
  NIL,
1550
1593
  NIL,
1551
- await this.parse(result),
1594
+ await this.parseTop(result),
1552
1595
  NIL,
1553
1596
  NIL
1554
1597
  );
@@ -1580,7 +1623,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1580
1623
  const cleanup = current.on({
1581
1624
  next: (value) => {
1582
1625
  this.markRef(id);
1583
- this.parse(value).then(
1626
+ this.parseTop(value).then(
1584
1627
  (data) => {
1585
1628
  sequence.push(createStreamNextNode(id, data));
1586
1629
  },
@@ -1592,7 +1635,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1592
1635
  },
1593
1636
  throw: (value) => {
1594
1637
  this.markRef(id);
1595
- this.parse(value).then(
1638
+ this.parseTop(value).then(
1596
1639
  (data) => {
1597
1640
  sequence.push(createStreamThrowNode(id, data));
1598
1641
  resolve(sequence);
@@ -1606,7 +1649,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1606
1649
  },
1607
1650
  return: (value) => {
1608
1651
  this.markRef(id);
1609
- this.parse(value).then(
1652
+ this.parseTop(value).then(
1610
1653
  (data) => {
1611
1654
  sequence.push(createStreamReturnNode(id, data));
1612
1655
  resolve(sequence);
@@ -1622,28 +1665,6 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1622
1665
  })
1623
1666
  );
1624
1667
  }
1625
- async parseAbortSignalSync(id, current) {
1626
- return createSerovalNode(
1627
- 37 /* AbortSignalSync */,
1628
- id,
1629
- NIL,
1630
- NIL,
1631
- NIL,
1632
- NIL,
1633
- NIL,
1634
- NIL,
1635
- NIL,
1636
- await this.parse(current.reason),
1637
- NIL,
1638
- NIL
1639
- );
1640
- }
1641
- async parseAbortSignal(id, current) {
1642
- if (!current.aborted) {
1643
- await abortSignalToPromise(current);
1644
- }
1645
- return this.parseAbortSignalSync(id, current);
1646
- }
1647
1668
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
1648
1669
  async parseObject(id, current) {
1649
1670
  if (Array.isArray(current)) {
@@ -1654,7 +1675,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1654
1675
  }
1655
1676
  const currentClass = current.constructor;
1656
1677
  if (currentClass === OpaqueReference) {
1657
- return this.parse(
1678
+ return this.parseTop(
1658
1679
  current.replacement
1659
1680
  );
1660
1681
  }
@@ -1717,9 +1738,6 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1717
1738
  return this.parsePromise(id, current);
1718
1739
  }
1719
1740
  const currentFeatures = this.features;
1720
- if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
1721
- return this.parseAbortSignal(id, current);
1722
- }
1723
1741
  if (currentFeatures & 16 /* BigIntTypedArray */) {
1724
1742
  switch (currentClass) {
1725
1743
  case BigInt64Array:
@@ -1743,35 +1761,49 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1743
1761
  }
1744
1762
  throw new SerovalUnsupportedTypeError(current);
1745
1763
  }
1746
- async parse(current) {
1747
- try {
1748
- switch (typeof current) {
1749
- case "boolean":
1750
- return current ? TRUE_NODE : FALSE_NODE;
1751
- case "undefined":
1752
- return UNDEFINED_NODE;
1753
- case "string":
1754
- return createStringNode(current);
1755
- case "number":
1756
- return createNumberNode(current);
1757
- case "bigint":
1758
- return createBigIntNode(current);
1759
- case "object": {
1760
- if (current) {
1761
- const ref = this.getReference(current);
1762
- return ref.type === 0 ? await this.parseObject(ref.value, current) : ref.value;
1763
- }
1764
- return NULL_NODE;
1764
+ async parseFunction(current) {
1765
+ const ref = this.getReference(current);
1766
+ if (ref.type !== 0 /* Fresh */) {
1767
+ return ref.value;
1768
+ }
1769
+ const plugin = await this.parsePlugin(ref.value, current);
1770
+ if (plugin) {
1771
+ return plugin;
1772
+ }
1773
+ throw new SerovalUnsupportedTypeError(current);
1774
+ }
1775
+ async parseTop(current) {
1776
+ switch (typeof current) {
1777
+ case "boolean":
1778
+ return current ? TRUE_NODE : FALSE_NODE;
1779
+ case "undefined":
1780
+ return UNDEFINED_NODE;
1781
+ case "string":
1782
+ return createStringNode(current);
1783
+ case "number":
1784
+ return createNumberNode(current);
1785
+ case "bigint":
1786
+ return createBigIntNode(current);
1787
+ case "object": {
1788
+ if (current) {
1789
+ const ref = this.getReference(current);
1790
+ return ref.type === 0 ? await this.parseObject(ref.value, current) : ref.value;
1765
1791
  }
1766
- case "symbol":
1767
- return this.parseWellKnownSymbol(current);
1768
- case "function":
1769
- return this.parseFunction(current);
1770
- default:
1771
- throw new SerovalUnsupportedTypeError(current);
1792
+ return NULL_NODE;
1772
1793
  }
1794
+ case "symbol":
1795
+ return this.parseWellKnownSymbol(current);
1796
+ case "function":
1797
+ return this.parseFunction(current);
1798
+ default:
1799
+ throw new SerovalUnsupportedTypeError(current);
1800
+ }
1801
+ }
1802
+ async parse(current) {
1803
+ try {
1804
+ return await this.parseTop(current);
1773
1805
  } catch (error) {
1774
- throw new SerovalParserError(error);
1806
+ throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
1775
1807
  }
1776
1808
  }
1777
1809
  };
@@ -2042,21 +2074,6 @@ var BaseDeserializerContext = class {
2042
2074
  this.deserialize(node.a[1]);
2043
2075
  return void 0;
2044
2076
  }
2045
- deserializeAbortSignalConstructor(node) {
2046
- return this.assignIndexedValue(node.i, new AbortController()).signal;
2047
- }
2048
- deserializeAbortSignalAbort(node) {
2049
- const controller = this.refs.get(node.i);
2050
- assert(controller, new SerovalMissingInstanceError("AbortSignal"));
2051
- controller.abort(this.deserialize(node.a[1]));
2052
- return void 0;
2053
- }
2054
- deserializeAbortSignalSync(node) {
2055
- return this.assignIndexedValue(
2056
- node.i,
2057
- AbortSignal.abort(this.deserialize(node.f))
2058
- );
2059
- }
2060
2077
  deserialize(node) {
2061
2078
  try {
2062
2079
  switch (node.t) {
@@ -2106,9 +2123,9 @@ var BaseDeserializerContext = class {
2106
2123
  return this.deserializePlugin(node);
2107
2124
  case 22 /* PromiseConstructor */:
2108
2125
  return this.deserializePromiseConstructor(node);
2109
- case 23 /* PromiseResolve */:
2126
+ case 23 /* PromiseSuccess */:
2110
2127
  return this.deserializePromiseResolve(node);
2111
- case 24 /* PromiseReject */:
2128
+ case 24 /* PromiseFailure */:
2112
2129
  return this.deserializePromiseReject(node);
2113
2130
  case 28 /* IteratorFactoryInstance */:
2114
2131
  return this.deserializeIteratorFactoryInstance(node);
@@ -2126,12 +2143,6 @@ var BaseDeserializerContext = class {
2126
2143
  return this.deserializeIteratorFactory(node);
2127
2144
  case 29 /* AsyncIteratorFactory */:
2128
2145
  return this.deserializeAsyncIteratorFactory(node);
2129
- case 36 /* AbortSignalAbort */:
2130
- return this.deserializeAbortSignalAbort(node);
2131
- case 35 /* AbortSignalConstructor */:
2132
- return this.deserializeAbortSignalConstructor(node);
2133
- case 37 /* AbortSignalSync */:
2134
- return this.deserializeAbortSignalSync(node);
2135
2146
  // case SerovalNodeType.SpecialReference:
2136
2147
  default:
2137
2148
  throw new SerovalUnsupportedNodeError(node);
@@ -2262,18 +2273,10 @@ var BaseSerializerContext = class {
2262
2273
  this.marked = new Set(options.markedRefs);
2263
2274
  }
2264
2275
  createFunction(parameters, body) {
2265
- if (this.features & 2 /* ArrowFunction */) {
2266
- const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
2267
- return joined + "=>" + (body.startsWith("{") ? "(" + body + ")" : body);
2268
- }
2269
- return "function(" + parameters.join(",") + "){return " + body + "}";
2276
+ return createFunction(this.features, parameters, body);
2270
2277
  }
2271
2278
  createEffectfulFunction(parameters, body) {
2272
- if (this.features & 2 /* ArrowFunction */) {
2273
- const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
2274
- return joined + "=>{" + body + "}";
2275
- }
2276
- return "function(" + parameters.join(",") + "){" + body + "}";
2279
+ return createEffectfulFunction(this.features, parameters, body);
2277
2280
  }
2278
2281
  /**
2279
2282
  * A tiny function that tells if a reference
@@ -2742,7 +2745,11 @@ var BaseSerializerContext = class {
2742
2745
  return current === this.getRefParam(node.i) ? current : "(" + current + ")";
2743
2746
  }
2744
2747
  serializePromiseConstructor(node) {
2745
- return this.assignIndexedValue(node.i, this.getConstructor(node.f) + "()");
2748
+ const resolver = this.assignIndexedValue(node.s, "{p:0,s:0,f:0}");
2749
+ return this.assignIndexedValue(
2750
+ node.i,
2751
+ this.getConstructor(node.f) + "(" + resolver + ")"
2752
+ );
2746
2753
  }
2747
2754
  serializePromiseResolve(node) {
2748
2755
  return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
@@ -2750,63 +2757,10 @@ var BaseSerializerContext = class {
2750
2757
  serializePromiseReject(node) {
2751
2758
  return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
2752
2759
  }
2753
- serializeSpecialReferenceValue(ref) {
2754
- switch (ref) {
2755
- case 0 /* MapSentinel */:
2756
- return "[]";
2757
- case 1 /* PromiseConstructor */:
2758
- return this.createFunction(
2759
- ["s", "f", "p"],
2760
- "((p=new Promise(" + this.createEffectfulFunction(["a", "b"], "s=a,f=b") + ")).s=s,p.f=f,p)"
2761
- );
2762
- case 2 /* PromiseResolve */:
2763
- return this.createEffectfulFunction(
2764
- ["p", "d"],
2765
- 'p.s(d),p.status="success",p.value=d;delete p.s;delete p.f'
2766
- );
2767
- case 3 /* PromiseReject */:
2768
- return this.createEffectfulFunction(
2769
- ["p", "d"],
2770
- 'p.f(d),p.status="failure",p.value=d;delete p.s;delete p.f'
2771
- );
2772
- case 4 /* StreamConstructor */:
2773
- return this.createFunction(
2774
- ["b", "a", "s", "l", "p", "f", "e", "n"],
2775
- "(b=[],a=!0,s=!1,l=[],p=0,f=" + this.createEffectfulFunction(
2776
- ["v", "m", "x"],
2777
- "for(x=0;x<p;x++)l[x]&&l[x][m](v)"
2778
- ) + ",n=" + this.createEffectfulFunction(
2779
- ["o", "x", "z", "c"],
2780
- 'for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))'
2781
- ) + ",e=" + this.createFunction(
2782
- ["o", "t"],
2783
- "(a&&(l[t=p++]=o),n(o)," + this.createEffectfulFunction([], "a&&(l[t]=void 0)") + ")"
2784
- ) + ",{__SEROVAL_STREAM__:!0,on:" + this.createFunction(["o"], "e(o)") + ",next:" + this.createEffectfulFunction(["v"], 'a&&(b.push(v),f(v,"next"))') + ",throw:" + this.createEffectfulFunction(
2785
- ["v"],
2786
- 'a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)'
2787
- ) + ",return:" + this.createEffectfulFunction(
2788
- ["v"],
2789
- 'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
2790
- ) + "})"
2791
- );
2792
- case 5 /* AbortSignalConstructor */:
2793
- return this.createFunction(
2794
- ["a", "s"],
2795
- "((s=(a=new AbortController).signal).a=a,s)"
2796
- );
2797
- case 6 /* AbortSignalAbort */:
2798
- return this.createEffectfulFunction(
2799
- ["s", "r"],
2800
- "s.a.abort(r);delete s.a"
2801
- );
2802
- default:
2803
- return "";
2804
- }
2805
- }
2806
2760
  serializeSpecialReference(node) {
2807
2761
  return this.assignIndexedValue(
2808
2762
  node.i,
2809
- this.serializeSpecialReferenceValue(node.s)
2763
+ serializeSpecialReferenceValue(this.features, node.s)
2810
2764
  );
2811
2765
  }
2812
2766
  serializeIteratorFactory(node) {
@@ -2910,18 +2864,6 @@ var BaseSerializerContext = class {
2910
2864
  serializeStreamReturn(node) {
2911
2865
  return this.getRefParam(node.i) + ".return(" + this.serialize(node.f) + ")";
2912
2866
  }
2913
- serializeAbortSignalSync(node) {
2914
- return this.assignIndexedValue(
2915
- node.i,
2916
- "AbortSignal.abort(" + this.serialize(node.f) + ")"
2917
- );
2918
- }
2919
- serializeAbortSignalConstructor(node) {
2920
- return this.assignIndexedValue(node.i, this.getConstructor(node.f) + "()");
2921
- }
2922
- serializeAbortSignalAbort(node) {
2923
- return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
2924
- }
2925
2867
  serialize(node) {
2926
2868
  try {
2927
2869
  switch (node.t) {
@@ -2970,9 +2912,9 @@ var BaseSerializerContext = class {
2970
2912
  return this.serializeBoxed(node);
2971
2913
  case 22 /* PromiseConstructor */:
2972
2914
  return this.serializePromiseConstructor(node);
2973
- case 23 /* PromiseResolve */:
2915
+ case 23 /* PromiseSuccess */:
2974
2916
  return this.serializePromiseResolve(node);
2975
- case 24 /* PromiseReject */:
2917
+ case 24 /* PromiseFailure */:
2976
2918
  return this.serializePromiseReject(node);
2977
2919
  case 25 /* Plugin */:
2978
2920
  return this.serializePlugin(node);
@@ -2994,12 +2936,6 @@ var BaseSerializerContext = class {
2994
2936
  return this.serializeStreamThrow(node);
2995
2937
  case 34 /* StreamReturn */:
2996
2938
  return this.serializeStreamReturn(node);
2997
- case 36 /* AbortSignalAbort */:
2998
- return this.serializeAbortSignalAbort(node);
2999
- case 35 /* AbortSignalConstructor */:
3000
- return this.serializeAbortSignalConstructor(node);
3001
- case 37 /* AbortSignalSync */:
3002
- return this.serializeAbortSignalSync(node);
3003
2939
  default:
3004
2940
  throw new SerovalUnsupportedNodeError(node);
3005
2941
  }
@@ -3049,7 +2985,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3049
2985
  const nodes = [];
3050
2986
  for (let i = 0, len = current.length; i < len; i++) {
3051
2987
  if (i in current) {
3052
- nodes[i] = this.parse(current[i]);
2988
+ nodes[i] = this.parseTop(current[i]);
3053
2989
  }
3054
2990
  }
3055
2991
  return nodes;
@@ -3063,7 +2999,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3063
2999
  const valueNodes = [];
3064
3000
  for (let i = 0, len = entries.length; i < len; i++) {
3065
3001
  keyNodes.push(serializeString(entries[i][0]));
3066
- valueNodes.push(this.parse(entries[i][1]));
3002
+ valueNodes.push(this.parseTop(entries[i][1]));
3067
3003
  }
3068
3004
  let symbol = Symbol.iterator;
3069
3005
  if (symbol in properties) {
@@ -3071,7 +3007,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3071
3007
  valueNodes.push(
3072
3008
  createIteratorFactoryInstanceNode(
3073
3009
  this.parseIteratorFactory(),
3074
- this.parse(
3010
+ this.parseTop(
3075
3011
  iteratorToSequence(properties)
3076
3012
  )
3077
3013
  )
@@ -3083,7 +3019,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3083
3019
  valueNodes.push(
3084
3020
  createAsyncIteratorFactoryInstanceNode(
3085
3021
  this.parseAsyncIteratorFactory(),
3086
- this.parse(createStream())
3022
+ this.parseTop(createStream())
3087
3023
  )
3088
3024
  );
3089
3025
  }
@@ -3112,16 +3048,20 @@ var BaseSyncParserContext = class extends BaseParserContext {
3112
3048
  );
3113
3049
  }
3114
3050
  parseBoxed(id, current) {
3115
- return createBoxedNode(id, this.parse(current.valueOf()));
3051
+ return createBoxedNode(id, this.parseTop(current.valueOf()));
3116
3052
  }
3117
3053
  parseTypedArray(id, current) {
3118
- return createTypedArrayNode(id, current, this.parse(current.buffer));
3054
+ return createTypedArrayNode(id, current, this.parseTop(current.buffer));
3119
3055
  }
3120
3056
  parseBigIntTypedArray(id, current) {
3121
- return createBigIntTypedArrayNode(id, current, this.parse(current.buffer));
3057
+ return createBigIntTypedArrayNode(
3058
+ id,
3059
+ current,
3060
+ this.parseTop(current.buffer)
3061
+ );
3122
3062
  }
3123
3063
  parseDataView(id, current) {
3124
- return createDataViewNode(id, current, this.parse(current.buffer));
3064
+ return createDataViewNode(id, current, this.parseTop(current.buffer));
3125
3065
  }
3126
3066
  parseError(id, current) {
3127
3067
  const options = getErrorOptions(current, this.features);
@@ -3143,15 +3083,15 @@ var BaseSyncParserContext = class extends BaseParserContext {
3143
3083
  const keyNodes = [];
3144
3084
  const valueNodes = [];
3145
3085
  for (const [key, value] of current.entries()) {
3146
- keyNodes.push(this.parse(key));
3147
- valueNodes.push(this.parse(value));
3086
+ keyNodes.push(this.parseTop(key));
3087
+ valueNodes.push(this.parseTop(value));
3148
3088
  }
3149
3089
  return this.createMapNode(id, keyNodes, valueNodes, current.size);
3150
3090
  }
3151
3091
  parseSet(id, current) {
3152
3092
  const items = [];
3153
3093
  for (const item of current.keys()) {
3154
- items.push(this.parse(item));
3094
+ items.push(this.parseTop(item));
3155
3095
  }
3156
3096
  return createSetNode(id, current.size, items);
3157
3097
  }
@@ -3181,29 +3121,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3181
3121
  );
3182
3122
  }
3183
3123
  parsePromise(id, _current) {
3184
- return this.createPromiseConstructorNode(id);
3185
- }
3186
- parseAbortSignalSync(id, current) {
3187
- return createSerovalNode(
3188
- 37 /* AbortSignalSync */,
3189
- id,
3190
- NIL,
3191
- NIL,
3192
- NIL,
3193
- NIL,
3194
- NIL,
3195
- NIL,
3196
- NIL,
3197
- this.parse(current.reason),
3198
- NIL,
3199
- NIL
3200
- );
3201
- }
3202
- parseAbortSignal(id, current) {
3203
- if (current.aborted) {
3204
- return this.parseAbortSignalSync(id, current);
3205
- }
3206
- return this.createAbortSignalConstructorNode(id);
3124
+ return this.createPromiseConstructorNode(id, this.createIndex({}));
3207
3125
  }
3208
3126
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
3209
3127
  parseObject(id, current) {
@@ -3215,7 +3133,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3215
3133
  }
3216
3134
  const currentClass = current.constructor;
3217
3135
  if (currentClass === OpaqueReference) {
3218
- return this.parse(
3136
+ return this.parseTop(
3219
3137
  current.replacement
3220
3138
  );
3221
3139
  }
@@ -3278,9 +3196,6 @@ var BaseSyncParserContext = class extends BaseParserContext {
3278
3196
  return this.parsePromise(id, current);
3279
3197
  }
3280
3198
  const currentFeatures = this.features;
3281
- if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
3282
- return this.parseAbortSignal(id, current);
3283
- }
3284
3199
  if (currentFeatures & 16 /* BigIntTypedArray */) {
3285
3200
  switch (currentClass) {
3286
3201
  case BigInt64Array:
@@ -3304,35 +3219,50 @@ var BaseSyncParserContext = class extends BaseParserContext {
3304
3219
  }
3305
3220
  throw new SerovalUnsupportedTypeError(current);
3306
3221
  }
3307
- parse(current) {
3308
- try {
3309
- switch (typeof current) {
3310
- case "boolean":
3311
- return current ? TRUE_NODE : FALSE_NODE;
3312
- case "undefined":
3313
- return UNDEFINED_NODE;
3314
- case "string":
3315
- return createStringNode(current);
3316
- case "number":
3317
- return createNumberNode(current);
3318
- case "bigint":
3319
- return createBigIntNode(current);
3320
- case "object": {
3321
- if (current) {
3322
- const ref = this.getReference(current);
3323
- return ref.type === 0 ? this.parseObject(ref.value, current) : ref.value;
3324
- }
3325
- return NULL_NODE;
3222
+ parseFunction(current) {
3223
+ const ref = this.getReference(current);
3224
+ if (ref.type !== 0 /* Fresh */) {
3225
+ return ref.value;
3226
+ }
3227
+ const plugin = this.parsePlugin(ref.value, current);
3228
+ if (plugin) {
3229
+ return plugin;
3230
+ }
3231
+ throw new SerovalUnsupportedTypeError(current);
3232
+ }
3233
+ parseTop(current) {
3234
+ switch (typeof current) {
3235
+ case "boolean":
3236
+ return current ? TRUE_NODE : FALSE_NODE;
3237
+ case "undefined":
3238
+ return UNDEFINED_NODE;
3239
+ case "string":
3240
+ return createStringNode(current);
3241
+ case "number":
3242
+ return createNumberNode(current);
3243
+ case "bigint":
3244
+ return createBigIntNode(current);
3245
+ case "object": {
3246
+ if (current) {
3247
+ const ref = this.getReference(current);
3248
+ return ref.type === 0 /* Fresh */ ? this.parseObject(ref.value, current) : ref.value;
3326
3249
  }
3327
- case "symbol":
3328
- return this.parseWellKnownSymbol(current);
3329
- case "function":
3330
- return this.parseFunction(current);
3331
- default:
3332
- throw new SerovalUnsupportedTypeError(current);
3250
+ return NULL_NODE;
3251
+ }
3252
+ case "symbol":
3253
+ return this.parseWellKnownSymbol(current);
3254
+ case "function": {
3255
+ return this.parseFunction(current);
3333
3256
  }
3257
+ default:
3258
+ throw new SerovalUnsupportedTypeError(current);
3259
+ }
3260
+ }
3261
+ parse(current) {
3262
+ try {
3263
+ return this.parseTop(current);
3334
3264
  } catch (error) {
3335
- throw new SerovalParserError(error);
3265
+ throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
3336
3266
  }
3337
3267
  }
3338
3268
  };
@@ -3396,7 +3326,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3396
3326
  const valueNodes = [];
3397
3327
  for (let i = 0, len = entries.length; i < len; i++) {
3398
3328
  keyNodes.push(serializeString(entries[i][0]));
3399
- valueNodes.push(this.parse(entries[i][1]));
3329
+ valueNodes.push(this.parseTop(entries[i][1]));
3400
3330
  }
3401
3331
  let symbol = Symbol.iterator;
3402
3332
  if (symbol in properties) {
@@ -3404,7 +3334,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3404
3334
  valueNodes.push(
3405
3335
  createIteratorFactoryInstanceNode(
3406
3336
  this.parseIteratorFactory(),
3407
- this.parse(
3337
+ this.parseTop(
3408
3338
  iteratorToSequence(properties)
3409
3339
  )
3410
3340
  )
@@ -3416,7 +3346,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3416
3346
  valueNodes.push(
3417
3347
  createAsyncIteratorFactoryInstanceNode(
3418
3348
  this.parseAsyncIteratorFactory(),
3419
- this.parse(
3349
+ this.parseTop(
3420
3350
  createStreamFromAsyncIterable(
3421
3351
  properties
3422
3352
  )
@@ -3440,63 +3370,63 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3440
3370
  s: keyNodes.length
3441
3371
  };
3442
3372
  }
3373
+ handlePromiseSuccess(id, data) {
3374
+ const parsed = this.parseWithError(data);
3375
+ if (parsed) {
3376
+ this.onParse(
3377
+ createSerovalNode(
3378
+ 23 /* PromiseSuccess */,
3379
+ id,
3380
+ NIL,
3381
+ NIL,
3382
+ NIL,
3383
+ NIL,
3384
+ NIL,
3385
+ NIL,
3386
+ [this.parseSpecialReference(2 /* PromiseSuccess */), parsed],
3387
+ NIL,
3388
+ NIL,
3389
+ NIL
3390
+ )
3391
+ );
3392
+ }
3393
+ this.popPendingState();
3394
+ }
3395
+ handlePromiseFailure(id, data) {
3396
+ if (this.alive) {
3397
+ const parsed = this.parseWithError(data);
3398
+ if (parsed) {
3399
+ this.onParse(
3400
+ createSerovalNode(
3401
+ 24 /* PromiseFailure */,
3402
+ id,
3403
+ NIL,
3404
+ NIL,
3405
+ NIL,
3406
+ NIL,
3407
+ NIL,
3408
+ NIL,
3409
+ [
3410
+ this.parseSpecialReference(3 /* PromiseFailure */),
3411
+ parsed
3412
+ ],
3413
+ NIL,
3414
+ NIL,
3415
+ NIL
3416
+ )
3417
+ );
3418
+ }
3419
+ }
3420
+ this.popPendingState();
3421
+ }
3443
3422
  parsePromise(id, current) {
3423
+ const resolver = this.createIndex({});
3444
3424
  current.then(
3445
- (data) => {
3446
- const parsed = this.parseWithError(data);
3447
- if (parsed) {
3448
- this.onParse(
3449
- createSerovalNode(
3450
- 23 /* PromiseResolve */,
3451
- id,
3452
- NIL,
3453
- NIL,
3454
- NIL,
3455
- NIL,
3456
- NIL,
3457
- NIL,
3458
- [
3459
- this.parseSpecialReference(2 /* PromiseResolve */),
3460
- parsed
3461
- ],
3462
- NIL,
3463
- NIL,
3464
- NIL
3465
- )
3466
- );
3467
- }
3468
- this.popPendingState();
3469
- },
3470
- (data) => {
3471
- if (this.alive) {
3472
- const parsed = this.parseWithError(data);
3473
- if (parsed) {
3474
- this.onParse(
3475
- createSerovalNode(
3476
- 24 /* PromiseReject */,
3477
- id,
3478
- NIL,
3479
- NIL,
3480
- NIL,
3481
- NIL,
3482
- NIL,
3483
- NIL,
3484
- [
3485
- this.parseSpecialReference(3 /* PromiseReject */),
3486
- parsed
3487
- ],
3488
- NIL,
3489
- NIL,
3490
- NIL
3491
- )
3492
- );
3493
- }
3494
- }
3495
- this.popPendingState();
3496
- }
3425
+ this.handlePromiseSuccess.bind(this, resolver),
3426
+ this.handlePromiseFailure.bind(this, resolver)
3497
3427
  );
3498
3428
  this.pushPendingState();
3499
- return this.createPromiseConstructorNode(id);
3429
+ return this.createPromiseConstructorNode(id, resolver);
3500
3430
  }
3501
3431
  parsePlugin(id, current) {
3502
3432
  const currentPlugins = this.plugins;
@@ -3553,47 +3483,9 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3553
3483
  });
3554
3484
  return result;
3555
3485
  }
3556
- parseAbortSignal(id, current) {
3557
- if (current.aborted) {
3558
- return this.parseAbortSignalSync(id, current);
3559
- }
3560
- this.pushPendingState();
3561
- current.addEventListener(
3562
- "abort",
3563
- () => {
3564
- if (this.alive) {
3565
- const parsed = this.parseWithError(current.reason);
3566
- if (parsed) {
3567
- this.onParse(
3568
- createSerovalNode(
3569
- 36 /* AbortSignalAbort */,
3570
- id,
3571
- NIL,
3572
- NIL,
3573
- NIL,
3574
- NIL,
3575
- NIL,
3576
- NIL,
3577
- [
3578
- this.parseSpecialReference(6 /* AbortSignalAbort */),
3579
- parsed
3580
- ],
3581
- NIL,
3582
- NIL,
3583
- NIL
3584
- )
3585
- );
3586
- }
3587
- }
3588
- this.popPendingState();
3589
- },
3590
- { once: true }
3591
- );
3592
- return this.createAbortSignalConstructorNode(id);
3593
- }
3594
3486
  parseWithError(current) {
3595
3487
  try {
3596
- return this.parse(current);
3488
+ return this.parseTop(current);
3597
3489
  } catch (err) {
3598
3490
  this.onError(err);
3599
3491
  return NIL;
@@ -3722,9 +3614,7 @@ function crossSerializeStream(source, options) {
3722
3614
  onDone: options.onDone
3723
3615
  });
3724
3616
  ctx.start(source);
3725
- return () => {
3726
- ctx.destroy();
3727
- };
3617
+ return ctx.destroy.bind(ctx);
3728
3618
  }
3729
3619
  function toCrossJSONStream(source, options) {
3730
3620
  const plugins = resolvePlugins(options.plugins);
@@ -3737,9 +3627,7 @@ function toCrossJSONStream(source, options) {
3737
3627
  onDone: options.onDone
3738
3628
  });
3739
3629
  ctx.start(source);
3740
- return () => {
3741
- ctx.destroy();
3742
- };
3630
+ return ctx.destroy.bind(ctx);
3743
3631
  }
3744
3632
  function fromCrossJSON(source, options) {
3745
3633
  const plugins = resolvePlugins(options.plugins);
@@ -3838,9 +3726,6 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3838
3726
  serializePromiseReject(node) {
3839
3727
  throw new SerovalUnsupportedNodeError(node);
3840
3728
  }
3841
- serializeAbortSignalAbort(node) {
3842
- throw new SerovalUnsupportedNodeError(node);
3843
- }
3844
3729
  serializeTop(tree) {
3845
3730
  const result = this.serialize(tree);
3846
3731
  if (tree.i != null && this.vars.length) {