seroval 1.1.1 → 1.2.1

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 (55) hide show
  1. package/dist/cjs/development/index.cjs +728 -523
  2. package/dist/cjs/development/index.cjs.map +3 -3
  3. package/dist/cjs/production/index.cjs +7 -7
  4. package/dist/esm/development/index.mjs +728 -523
  5. package/dist/esm/development/index.mjs.map +3 -3
  6. package/dist/esm/production/index.mjs +7 -7
  7. package/dist/types/core/abort-signal.d.ts +2 -0
  8. package/dist/types/core/abort-signal.d.ts.map +1 -0
  9. package/dist/types/core/base-primitives.d.ts +2 -1
  10. package/dist/types/core/base-primitives.d.ts.map +1 -1
  11. package/dist/types/core/compat.d.ts +3 -2
  12. package/dist/types/core/compat.d.ts.map +1 -1
  13. package/dist/types/core/constants.d.ts +5 -1
  14. package/dist/types/core/constants.d.ts.map +1 -1
  15. package/dist/types/core/context/deserializer.d.ts +3 -0
  16. package/dist/types/core/context/deserializer.d.ts.map +1 -1
  17. package/dist/types/core/context/parser/async.d.ts +3 -0
  18. package/dist/types/core/context/parser/async.d.ts.map +1 -1
  19. package/dist/types/core/context/parser/stream.d.ts +3 -1
  20. package/dist/types/core/context/parser/stream.d.ts.map +1 -1
  21. package/dist/types/core/context/parser/sync.d.ts +4 -1
  22. package/dist/types/core/context/parser/sync.d.ts.map +1 -1
  23. package/dist/types/core/context/parser.d.ts +9 -10
  24. package/dist/types/core/context/parser.d.ts.map +1 -1
  25. package/dist/types/core/context/serializer.d.ts +4 -1
  26. package/dist/types/core/context/serializer.d.ts.map +1 -1
  27. package/dist/types/core/cross/index.d.ts.map +1 -1
  28. package/dist/types/core/literals.d.ts.map +1 -1
  29. package/dist/types/core/node.d.ts +8 -0
  30. package/dist/types/core/node.d.ts.map +1 -0
  31. package/dist/types/core/special-reference.d.ts +6 -1
  32. package/dist/types/core/special-reference.d.ts.map +1 -1
  33. package/dist/types/core/tree/serializer.d.ts +2 -1
  34. package/dist/types/core/tree/serializer.d.ts.map +1 -1
  35. package/dist/types/core/types.d.ts +20 -2
  36. package/dist/types/core/types.d.ts.map +1 -1
  37. package/dist/types/core/utils/iterator-to-sequence.d.ts.map +1 -1
  38. package/package.json +8 -8
  39. package/src/core/abort-signal.ts +19 -0
  40. package/src/core/base-primitives.ts +359 -337
  41. package/src/core/compat.ts +2 -1
  42. package/src/core/constants.ts +5 -0
  43. package/src/core/context/deserializer.ts +34 -1
  44. package/src/core/context/parser/async.ts +75 -22
  45. package/src/core/context/parser/stream.ts +91 -37
  46. package/src/core/context/parser/sync.ts +61 -7
  47. package/src/core/context/parser.ts +121 -117
  48. package/src/core/context/serializer.ts +55 -9
  49. package/src/core/cross/index.ts +2 -6
  50. package/src/core/literals.ts +16 -15
  51. package/src/core/node.ts +40 -0
  52. package/src/core/special-reference.ts +7 -0
  53. package/src/core/tree/serializer.ts +7 -0
  54. package/src/core/types.ts +32 -2
  55. package/src/core/utils/iterator-to-sequence.ts +3 -1
@@ -5,9 +5,10 @@ var Feature = /* @__PURE__ */ ((Feature2) => {
5
5
  Feature2[Feature2["ErrorPrototypeStack"] = 4] = "ErrorPrototypeStack";
6
6
  Feature2[Feature2["ObjectAssign"] = 8] = "ObjectAssign";
7
7
  Feature2[Feature2["BigIntTypedArray"] = 16] = "BigIntTypedArray";
8
+ Feature2[Feature2["AbortSignal"] = 32] = "AbortSignal";
8
9
  return Feature2;
9
10
  })(Feature || {});
10
- var ALL_ENABLED = 31;
11
+ var ALL_ENABLED = 47;
11
12
 
12
13
  // src/core/string.ts
13
14
  function serializeChar(str) {
@@ -183,6 +184,19 @@ function resolvePlugins(plugins) {
183
184
  return void 0;
184
185
  }
185
186
 
187
+ // src/core/abort-signal.ts
188
+ function resolveAbortSignalResult(resolve) {
189
+ resolve(this.reason);
190
+ }
191
+ function resolveAbortSignal(resolve) {
192
+ this.addEventListener("abort", resolveAbortSignalResult.bind(this, resolve), {
193
+ once: true
194
+ });
195
+ }
196
+ function abortSignalToPromise(signal) {
197
+ return new Promise(resolveAbortSignal.bind(signal));
198
+ }
199
+
186
200
  // src/core/constants.ts
187
201
  var SYMBOL_STRING = {
188
202
  [0 /* AsyncIterator */]: "Symbol.asyncIterator",
@@ -267,24 +281,43 @@ var ERROR_CONSTRUCTOR = {
267
281
  [5 /* TypeError */]: TypeError,
268
282
  [6 /* URIError */]: URIError
269
283
  };
284
+ var NIL = void 0;
270
285
 
271
- // src/core/literals.ts
272
- function createConstantNode(value) {
286
+ // src/core/node.ts
287
+ function createSerovalNode(t, i, s, l, c, m, p, e, a, f, b, o) {
273
288
  return {
274
- t: 2 /* Constant */,
275
- i: void 0,
276
- s: value,
277
- l: void 0,
278
- c: void 0,
279
- m: void 0,
280
- p: void 0,
281
- e: void 0,
282
- a: void 0,
283
- f: void 0,
284
- b: void 0,
285
- o: void 0
289
+ t,
290
+ i,
291
+ s,
292
+ l,
293
+ c,
294
+ m,
295
+ p,
296
+ e,
297
+ a,
298
+ f,
299
+ b,
300
+ o
286
301
  };
287
302
  }
303
+
304
+ // src/core/literals.ts
305
+ function createConstantNode(value) {
306
+ return createSerovalNode(
307
+ 2 /* Constant */,
308
+ NIL,
309
+ value,
310
+ NIL,
311
+ NIL,
312
+ NIL,
313
+ NIL,
314
+ NIL,
315
+ NIL,
316
+ NIL,
317
+ NIL,
318
+ NIL
319
+ );
320
+ }
288
321
  var TRUE_NODE = /* @__PURE__ */ createConstantNode(
289
322
  2 /* True */
290
323
  );
@@ -388,100 +421,100 @@ function createNumberNode(value) {
388
421
  if (Object.is(value, -0)) {
389
422
  return NEG_ZERO_NODE;
390
423
  }
391
- return {
392
- t: 0 /* Number */,
393
- i: void 0,
394
- s: value,
395
- l: void 0,
396
- c: void 0,
397
- m: void 0,
398
- p: void 0,
399
- e: void 0,
400
- a: void 0,
401
- f: void 0,
402
- b: void 0,
403
- o: void 0
404
- };
424
+ return createSerovalNode(
425
+ 0 /* Number */,
426
+ NIL,
427
+ value,
428
+ NIL,
429
+ NIL,
430
+ NIL,
431
+ NIL,
432
+ NIL,
433
+ NIL,
434
+ NIL,
435
+ NIL,
436
+ NIL
437
+ );
405
438
  }
406
439
  function createStringNode(value) {
407
- return {
408
- t: 1 /* String */,
409
- i: void 0,
410
- s: serializeString(value),
411
- l: void 0,
412
- c: void 0,
413
- m: void 0,
414
- p: void 0,
415
- e: void 0,
416
- a: void 0,
417
- f: void 0,
418
- b: void 0,
419
- o: void 0
420
- };
440
+ return createSerovalNode(
441
+ 1 /* String */,
442
+ NIL,
443
+ serializeString(value),
444
+ NIL,
445
+ NIL,
446
+ NIL,
447
+ NIL,
448
+ NIL,
449
+ NIL,
450
+ NIL,
451
+ NIL,
452
+ NIL
453
+ );
421
454
  }
422
455
  function createBigIntNode(current) {
423
- return {
424
- t: 3 /* BigInt */,
425
- i: void 0,
426
- s: "" + current,
427
- l: void 0,
428
- c: void 0,
429
- m: void 0,
430
- p: void 0,
431
- e: void 0,
432
- a: void 0,
433
- f: void 0,
434
- b: void 0,
435
- o: void 0
436
- };
456
+ return createSerovalNode(
457
+ 3 /* BigInt */,
458
+ NIL,
459
+ "" + current,
460
+ NIL,
461
+ NIL,
462
+ NIL,
463
+ NIL,
464
+ NIL,
465
+ NIL,
466
+ NIL,
467
+ NIL,
468
+ NIL
469
+ );
437
470
  }
438
471
  function createIndexedValueNode(id) {
439
- return {
440
- t: 4 /* IndexedValue */,
441
- i: id,
442
- s: void 0,
443
- l: void 0,
444
- c: void 0,
445
- m: void 0,
446
- p: void 0,
447
- e: void 0,
448
- a: void 0,
449
- f: void 0,
450
- b: void 0,
451
- o: void 0
452
- };
472
+ return createSerovalNode(
473
+ 4 /* IndexedValue */,
474
+ id,
475
+ NIL,
476
+ NIL,
477
+ NIL,
478
+ NIL,
479
+ NIL,
480
+ NIL,
481
+ NIL,
482
+ NIL,
483
+ NIL,
484
+ NIL
485
+ );
453
486
  }
454
487
  function createDateNode(id, current) {
455
- return {
456
- t: 5 /* Date */,
457
- i: id,
458
- s: current.toISOString(),
459
- l: void 0,
460
- c: void 0,
461
- m: void 0,
462
- p: void 0,
463
- e: void 0,
464
- f: void 0,
465
- a: void 0,
466
- b: void 0,
467
- o: void 0
468
- };
488
+ return createSerovalNode(
489
+ 5 /* Date */,
490
+ id,
491
+ current.toISOString(),
492
+ NIL,
493
+ NIL,
494
+ NIL,
495
+ NIL,
496
+ NIL,
497
+ NIL,
498
+ NIL,
499
+ NIL,
500
+ NIL
501
+ );
469
502
  }
470
503
  function createRegExpNode(id, current) {
471
- return {
472
- t: 6 /* RegExp */,
473
- i: id,
474
- s: void 0,
475
- l: void 0,
476
- c: serializeString(current.source),
477
- m: current.flags,
478
- p: void 0,
479
- e: void 0,
480
- a: void 0,
481
- f: void 0,
482
- b: void 0,
483
- o: void 0
484
- };
504
+ return createSerovalNode(
505
+ 6 /* RegExp */,
506
+ id,
507
+ NIL,
508
+ NIL,
509
+ serializeString(current.source),
510
+ current.flags,
511
+ NIL,
512
+ NIL,
513
+ NIL,
514
+ NIL,
515
+ NIL,
516
+ NIL
517
+ );
485
518
  }
486
519
  function createArrayBufferNode(id, current) {
487
520
  const bytes = new Uint8Array(current);
@@ -490,292 +523,292 @@ function createArrayBufferNode(id, current) {
490
523
  for (let i = 0; i < len; i++) {
491
524
  values[i] = bytes[i];
492
525
  }
493
- return {
494
- t: 19 /* ArrayBuffer */,
495
- i: id,
496
- s: values,
497
- l: void 0,
498
- c: void 0,
499
- m: void 0,
500
- p: void 0,
501
- e: void 0,
502
- a: void 0,
503
- f: void 0,
504
- b: void 0,
505
- o: void 0
506
- };
526
+ return createSerovalNode(
527
+ 19 /* ArrayBuffer */,
528
+ id,
529
+ values,
530
+ NIL,
531
+ NIL,
532
+ NIL,
533
+ NIL,
534
+ NIL,
535
+ NIL,
536
+ NIL,
537
+ NIL,
538
+ NIL
539
+ );
507
540
  }
508
541
  function createWKSymbolNode(id, current) {
509
- return {
510
- t: 17 /* WKSymbol */,
511
- i: id,
512
- s: INV_SYMBOL_REF[current],
513
- l: void 0,
514
- c: void 0,
515
- m: void 0,
516
- p: void 0,
517
- e: void 0,
518
- a: void 0,
519
- f: void 0,
520
- b: void 0,
521
- o: void 0
522
- };
542
+ return createSerovalNode(
543
+ 17 /* WKSymbol */,
544
+ id,
545
+ INV_SYMBOL_REF[current],
546
+ NIL,
547
+ NIL,
548
+ NIL,
549
+ NIL,
550
+ NIL,
551
+ NIL,
552
+ NIL,
553
+ NIL,
554
+ NIL
555
+ );
523
556
  }
524
557
  function createReferenceNode(id, ref) {
525
- return {
526
- t: 18 /* Reference */,
527
- i: id,
528
- s: serializeString(getReferenceID(ref)),
529
- l: void 0,
530
- c: void 0,
531
- m: void 0,
532
- p: void 0,
533
- e: void 0,
534
- a: void 0,
535
- f: void 0,
536
- b: void 0,
537
- o: void 0
538
- };
558
+ return createSerovalNode(
559
+ 18 /* Reference */,
560
+ id,
561
+ serializeString(getReferenceID(ref)),
562
+ NIL,
563
+ NIL,
564
+ NIL,
565
+ NIL,
566
+ NIL,
567
+ NIL,
568
+ NIL,
569
+ NIL,
570
+ NIL
571
+ );
539
572
  }
540
573
  function createPluginNode(id, tag, value) {
541
- return {
542
- t: 25 /* Plugin */,
543
- i: id,
544
- s: value,
545
- l: void 0,
546
- c: serializeString(tag),
547
- m: void 0,
548
- p: void 0,
549
- e: void 0,
550
- a: void 0,
551
- f: void 0,
552
- b: void 0,
553
- o: void 0
554
- };
574
+ return createSerovalNode(
575
+ 25 /* Plugin */,
576
+ id,
577
+ value,
578
+ NIL,
579
+ serializeString(tag),
580
+ NIL,
581
+ NIL,
582
+ NIL,
583
+ NIL,
584
+ NIL,
585
+ NIL,
586
+ NIL
587
+ );
555
588
  }
556
589
  function createArrayNode(id, current, parsedItems) {
557
- return {
558
- t: 9 /* Array */,
559
- i: id,
560
- s: void 0,
561
- l: current.length,
562
- c: void 0,
563
- m: void 0,
564
- p: void 0,
565
- e: void 0,
566
- a: parsedItems,
567
- f: void 0,
568
- b: void 0,
569
- o: getObjectFlag(current)
570
- };
590
+ return createSerovalNode(
591
+ 9 /* Array */,
592
+ id,
593
+ NIL,
594
+ current.length,
595
+ NIL,
596
+ NIL,
597
+ NIL,
598
+ NIL,
599
+ parsedItems,
600
+ NIL,
601
+ NIL,
602
+ getObjectFlag(current)
603
+ );
571
604
  }
572
605
  function createBoxedNode(id, boxed) {
573
- return {
574
- t: 21 /* Boxed */,
575
- i: id,
576
- s: void 0,
577
- l: void 0,
578
- c: void 0,
579
- m: void 0,
580
- p: void 0,
581
- e: void 0,
582
- a: void 0,
583
- f: boxed,
584
- b: void 0,
585
- o: void 0
586
- };
606
+ return createSerovalNode(
607
+ 21 /* Boxed */,
608
+ id,
609
+ NIL,
610
+ NIL,
611
+ NIL,
612
+ NIL,
613
+ NIL,
614
+ NIL,
615
+ NIL,
616
+ boxed,
617
+ NIL,
618
+ NIL
619
+ );
587
620
  }
588
621
  function createTypedArrayNode(id, current, buffer) {
589
- return {
590
- t: 15 /* TypedArray */,
591
- i: id,
592
- s: void 0,
593
- l: current.length,
594
- c: current.constructor.name,
595
- m: void 0,
596
- p: void 0,
597
- e: void 0,
598
- a: void 0,
599
- f: buffer,
600
- b: current.byteOffset,
601
- o: void 0
602
- };
622
+ return createSerovalNode(
623
+ 15 /* TypedArray */,
624
+ id,
625
+ NIL,
626
+ current.length,
627
+ current.constructor.name,
628
+ NIL,
629
+ NIL,
630
+ NIL,
631
+ NIL,
632
+ buffer,
633
+ current.byteOffset,
634
+ NIL
635
+ );
603
636
  }
604
637
  function createBigIntTypedArrayNode(id, current, buffer) {
605
- return {
606
- t: 16 /* BigIntTypedArray */,
607
- i: id,
608
- s: void 0,
609
- l: current.length,
610
- c: current.constructor.name,
611
- m: void 0,
612
- p: void 0,
613
- e: void 0,
614
- a: void 0,
615
- f: buffer,
616
- b: current.byteOffset,
617
- o: void 0
618
- };
638
+ return createSerovalNode(
639
+ 16 /* BigIntTypedArray */,
640
+ id,
641
+ NIL,
642
+ current.length,
643
+ current.constructor.name,
644
+ NIL,
645
+ NIL,
646
+ NIL,
647
+ NIL,
648
+ buffer,
649
+ current.byteOffset,
650
+ NIL
651
+ );
619
652
  }
620
653
  function createDataViewNode(id, current, buffer) {
621
- return {
622
- t: 20 /* DataView */,
623
- i: id,
624
- s: void 0,
625
- l: current.byteLength,
626
- c: void 0,
627
- m: void 0,
628
- p: void 0,
629
- e: void 0,
630
- a: void 0,
631
- f: buffer,
632
- b: current.byteOffset,
633
- o: void 0
634
- };
654
+ return createSerovalNode(
655
+ 20 /* DataView */,
656
+ id,
657
+ NIL,
658
+ current.byteLength,
659
+ NIL,
660
+ NIL,
661
+ NIL,
662
+ NIL,
663
+ NIL,
664
+ buffer,
665
+ current.byteOffset,
666
+ NIL
667
+ );
635
668
  }
636
669
  function createErrorNode(id, current, options) {
637
- return {
638
- t: 13 /* Error */,
639
- i: id,
640
- s: getErrorConstructor(current),
641
- l: void 0,
642
- c: void 0,
643
- m: serializeString(current.message),
644
- p: options,
645
- e: void 0,
646
- a: void 0,
647
- f: void 0,
648
- b: void 0,
649
- o: void 0
650
- };
670
+ return createSerovalNode(
671
+ 13 /* Error */,
672
+ id,
673
+ getErrorConstructor(current),
674
+ NIL,
675
+ NIL,
676
+ serializeString(current.message),
677
+ options,
678
+ NIL,
679
+ NIL,
680
+ NIL,
681
+ NIL,
682
+ NIL
683
+ );
651
684
  }
652
685
  function createAggregateErrorNode(id, current, options) {
653
- return {
654
- t: 14 /* AggregateError */,
655
- i: id,
656
- s: getErrorConstructor(current),
657
- l: void 0,
658
- c: void 0,
659
- m: serializeString(current.message),
660
- p: options,
661
- e: void 0,
662
- a: void 0,
663
- f: void 0,
664
- b: void 0,
665
- o: void 0
666
- };
686
+ return createSerovalNode(
687
+ 14 /* AggregateError */,
688
+ id,
689
+ getErrorConstructor(current),
690
+ NIL,
691
+ NIL,
692
+ serializeString(current.message),
693
+ options,
694
+ NIL,
695
+ NIL,
696
+ NIL,
697
+ NIL,
698
+ NIL
699
+ );
667
700
  }
668
701
  function createSetNode(id, size, items) {
669
- return {
670
- t: 7 /* Set */,
671
- i: id,
672
- s: void 0,
673
- l: size,
674
- c: void 0,
675
- m: void 0,
676
- p: void 0,
677
- e: void 0,
678
- a: items,
679
- f: void 0,
680
- b: void 0,
681
- o: void 0
682
- };
702
+ return createSerovalNode(
703
+ 7 /* Set */,
704
+ id,
705
+ NIL,
706
+ size,
707
+ NIL,
708
+ NIL,
709
+ NIL,
710
+ NIL,
711
+ items,
712
+ NIL,
713
+ NIL,
714
+ NIL
715
+ );
683
716
  }
684
717
  function createIteratorFactoryInstanceNode(factory, items) {
685
- return {
686
- t: 28 /* IteratorFactoryInstance */,
687
- i: void 0,
688
- s: void 0,
689
- l: void 0,
690
- c: void 0,
691
- m: void 0,
692
- p: void 0,
693
- e: void 0,
694
- a: [factory, items],
695
- f: void 0,
696
- b: void 0,
697
- o: void 0
698
- };
718
+ return createSerovalNode(
719
+ 28 /* IteratorFactoryInstance */,
720
+ NIL,
721
+ NIL,
722
+ NIL,
723
+ NIL,
724
+ NIL,
725
+ NIL,
726
+ NIL,
727
+ [factory, items],
728
+ NIL,
729
+ NIL,
730
+ NIL
731
+ );
699
732
  }
700
733
  function createAsyncIteratorFactoryInstanceNode(factory, items) {
701
- return {
702
- t: 30 /* AsyncIteratorFactoryInstance */,
703
- i: void 0,
704
- s: void 0,
705
- l: void 0,
706
- c: void 0,
707
- m: void 0,
708
- p: void 0,
709
- e: void 0,
710
- a: [factory, items],
711
- f: void 0,
712
- b: void 0,
713
- o: void 0
714
- };
734
+ return createSerovalNode(
735
+ 30 /* AsyncIteratorFactoryInstance */,
736
+ NIL,
737
+ NIL,
738
+ NIL,
739
+ NIL,
740
+ NIL,
741
+ NIL,
742
+ NIL,
743
+ [factory, items],
744
+ NIL,
745
+ NIL,
746
+ NIL
747
+ );
715
748
  }
716
749
  function createStreamConstructorNode(id, factory, sequence) {
717
- return {
718
- t: 31 /* StreamConstructor */,
719
- i: id,
720
- s: void 0,
721
- l: void 0,
722
- c: void 0,
723
- m: void 0,
724
- p: void 0,
725
- e: void 0,
726
- a: sequence,
727
- f: factory,
728
- b: void 0,
729
- o: void 0
730
- };
750
+ return createSerovalNode(
751
+ 31 /* StreamConstructor */,
752
+ id,
753
+ NIL,
754
+ NIL,
755
+ NIL,
756
+ NIL,
757
+ NIL,
758
+ NIL,
759
+ sequence,
760
+ factory,
761
+ NIL,
762
+ NIL
763
+ );
731
764
  }
732
765
  function createStreamNextNode(id, parsed) {
733
- return {
734
- t: 32 /* StreamNext */,
735
- i: id,
736
- s: void 0,
737
- l: void 0,
738
- c: void 0,
739
- m: void 0,
740
- p: void 0,
741
- e: void 0,
742
- a: void 0,
743
- f: parsed,
744
- b: void 0,
745
- o: void 0
746
- };
766
+ return createSerovalNode(
767
+ 32 /* StreamNext */,
768
+ id,
769
+ NIL,
770
+ NIL,
771
+ NIL,
772
+ NIL,
773
+ NIL,
774
+ NIL,
775
+ NIL,
776
+ parsed,
777
+ NIL,
778
+ NIL
779
+ );
747
780
  }
748
781
  function createStreamThrowNode(id, parsed) {
749
- return {
750
- t: 33 /* StreamThrow */,
751
- i: id,
752
- s: void 0,
753
- l: void 0,
754
- c: void 0,
755
- m: void 0,
756
- p: void 0,
757
- e: void 0,
758
- a: void 0,
759
- f: parsed,
760
- b: void 0,
761
- o: void 0
762
- };
782
+ return createSerovalNode(
783
+ 33 /* StreamThrow */,
784
+ id,
785
+ NIL,
786
+ NIL,
787
+ NIL,
788
+ NIL,
789
+ NIL,
790
+ NIL,
791
+ NIL,
792
+ parsed,
793
+ NIL,
794
+ NIL
795
+ );
763
796
  }
764
797
  function createStreamReturnNode(id, parsed) {
765
- return {
766
- t: 34 /* StreamReturn */,
767
- i: id,
768
- s: void 0,
769
- l: void 0,
770
- c: void 0,
771
- m: void 0,
772
- p: void 0,
773
- e: void 0,
774
- a: void 0,
775
- f: parsed,
776
- b: void 0,
777
- o: void 0
778
- };
798
+ return createSerovalNode(
799
+ 34 /* StreamReturn */,
800
+ id,
801
+ NIL,
802
+ NIL,
803
+ NIL,
804
+ NIL,
805
+ NIL,
806
+ NIL,
807
+ NIL,
808
+ parsed,
809
+ NIL,
810
+ NIL
811
+ );
779
812
  }
780
813
 
781
814
  // src/core/errors.ts
@@ -879,7 +912,9 @@ var SPECIAL_REFS = {
879
912
  [1 /* PromiseConstructor */]: {},
880
913
  [2 /* PromiseResolve */]: {},
881
914
  [3 /* PromiseReject */]: {},
882
- [4 /* StreamConstructor */]: {}
915
+ [4 /* StreamConstructor */]: {},
916
+ [5 /* AbortSignalConstructor */]: {},
917
+ [6 /* AbortSignalAbort */]: {}
883
918
  };
884
919
 
885
920
  // src/core/utils/deferred.ts
@@ -1104,7 +1139,7 @@ function sequenceToIterator(sequence) {
1104
1139
  if (index > sequence.d) {
1105
1140
  return {
1106
1141
  done: true,
1107
- value: void 0
1142
+ value: NIL
1108
1143
  };
1109
1144
  }
1110
1145
  const currentIndex = index++;
@@ -1173,17 +1208,6 @@ var BaseParserContext = class {
1173
1208
  }
1174
1209
  return indexed;
1175
1210
  }
1176
- getStrictReference(current) {
1177
- assert(hasReferenceID(current), new SerovalUnsupportedTypeError(current));
1178
- const result = this.getIndexedValue(current);
1179
- if (result.type === 1 /* Indexed */) {
1180
- return result.value;
1181
- }
1182
- return createReferenceNode(result.value, current);
1183
- }
1184
- parseFunction(current) {
1185
- return this.getStrictReference(current);
1186
- }
1187
1211
  parseWellKnownSymbol(current) {
1188
1212
  const ref = this.getReference(current);
1189
1213
  if (ref.type !== 0 /* Fresh */) {
@@ -1197,111 +1221,127 @@ var BaseParserContext = class {
1197
1221
  if (result.type === 1 /* Indexed */) {
1198
1222
  return result.value;
1199
1223
  }
1200
- return {
1201
- t: 26 /* SpecialReference */,
1202
- i: result.value,
1203
- s: ref,
1204
- l: void 0,
1205
- c: void 0,
1206
- m: void 0,
1207
- p: void 0,
1208
- e: void 0,
1209
- a: void 0,
1210
- f: void 0,
1211
- b: void 0,
1212
- o: void 0
1213
- };
1224
+ return createSerovalNode(
1225
+ 26 /* SpecialReference */,
1226
+ result.value,
1227
+ ref,
1228
+ NIL,
1229
+ NIL,
1230
+ NIL,
1231
+ NIL,
1232
+ NIL,
1233
+ NIL,
1234
+ NIL,
1235
+ NIL,
1236
+ NIL
1237
+ );
1214
1238
  }
1215
1239
  parseIteratorFactory() {
1216
1240
  const result = this.getIndexedValue(ITERATOR);
1217
1241
  if (result.type === 1 /* Indexed */) {
1218
1242
  return result.value;
1219
1243
  }
1220
- return {
1221
- t: 27 /* IteratorFactory */,
1222
- i: result.value,
1223
- s: void 0,
1224
- l: void 0,
1225
- c: void 0,
1226
- m: void 0,
1227
- p: void 0,
1228
- e: void 0,
1229
- a: void 0,
1230
- f: this.parseWellKnownSymbol(Symbol.iterator),
1231
- b: void 0,
1232
- o: void 0
1233
- };
1244
+ return createSerovalNode(
1245
+ 27 /* IteratorFactory */,
1246
+ result.value,
1247
+ NIL,
1248
+ NIL,
1249
+ NIL,
1250
+ NIL,
1251
+ NIL,
1252
+ NIL,
1253
+ NIL,
1254
+ this.parseWellKnownSymbol(Symbol.iterator),
1255
+ NIL,
1256
+ NIL
1257
+ );
1234
1258
  }
1235
1259
  parseAsyncIteratorFactory() {
1236
1260
  const result = this.getIndexedValue(ASYNC_ITERATOR);
1237
1261
  if (result.type === 1 /* Indexed */) {
1238
1262
  return result.value;
1239
1263
  }
1240
- return {
1241
- t: 29 /* AsyncIteratorFactory */,
1242
- i: result.value,
1243
- s: void 0,
1244
- l: void 0,
1245
- c: void 0,
1246
- m: void 0,
1247
- p: void 0,
1248
- e: void 0,
1249
- a: [
1264
+ return createSerovalNode(
1265
+ 29 /* AsyncIteratorFactory */,
1266
+ result.value,
1267
+ NIL,
1268
+ NIL,
1269
+ NIL,
1270
+ NIL,
1271
+ NIL,
1272
+ NIL,
1273
+ [
1250
1274
  this.parseSpecialReference(1 /* PromiseConstructor */),
1251
1275
  this.parseWellKnownSymbol(Symbol.asyncIterator)
1252
1276
  ],
1253
- f: void 0,
1254
- b: void 0,
1255
- o: void 0
1256
- };
1277
+ NIL,
1278
+ NIL,
1279
+ NIL
1280
+ );
1257
1281
  }
1258
1282
  createObjectNode(id, current, empty, record) {
1259
- return {
1260
- t: empty ? 11 /* NullConstructor */ : 10 /* Object */,
1261
- i: id,
1262
- s: void 0,
1263
- l: void 0,
1264
- c: void 0,
1265
- m: void 0,
1266
- p: record,
1267
- e: void 0,
1268
- a: void 0,
1269
- f: void 0,
1270
- b: void 0,
1271
- o: getObjectFlag(current)
1272
- };
1283
+ return createSerovalNode(
1284
+ empty ? 11 /* NullConstructor */ : 10 /* Object */,
1285
+ id,
1286
+ NIL,
1287
+ NIL,
1288
+ NIL,
1289
+ NIL,
1290
+ record,
1291
+ NIL,
1292
+ NIL,
1293
+ NIL,
1294
+ NIL,
1295
+ getObjectFlag(current)
1296
+ );
1273
1297
  }
1274
1298
  createMapNode(id, k, v, s) {
1275
- return {
1276
- t: 8 /* Map */,
1277
- i: id,
1278
- s: void 0,
1279
- l: void 0,
1280
- c: void 0,
1281
- m: void 0,
1282
- p: void 0,
1283
- e: { k, v, s },
1284
- a: void 0,
1285
- f: this.parseSpecialReference(0 /* MapSentinel */),
1286
- b: void 0,
1287
- o: void 0
1288
- };
1299
+ return createSerovalNode(
1300
+ 8 /* Map */,
1301
+ id,
1302
+ NIL,
1303
+ NIL,
1304
+ NIL,
1305
+ NIL,
1306
+ NIL,
1307
+ { k, v, s },
1308
+ NIL,
1309
+ this.parseSpecialReference(0 /* MapSentinel */),
1310
+ NIL,
1311
+ NIL
1312
+ );
1289
1313
  }
1290
1314
  createPromiseConstructorNode(id) {
1291
- return {
1292
- t: 22 /* PromiseConstructor */,
1293
- i: id,
1294
- s: void 0,
1295
- l: void 0,
1296
- c: void 0,
1297
- m: void 0,
1298
- p: void 0,
1299
- e: void 0,
1300
- a: void 0,
1301
- f: this.parseSpecialReference(1 /* PromiseConstructor */),
1302
- b: void 0,
1303
- o: void 0
1304
- };
1315
+ return createSerovalNode(
1316
+ 22 /* PromiseConstructor */,
1317
+ id,
1318
+ NIL,
1319
+ NIL,
1320
+ NIL,
1321
+ NIL,
1322
+ NIL,
1323
+ NIL,
1324
+ NIL,
1325
+ this.parseSpecialReference(1 /* PromiseConstructor */),
1326
+ NIL,
1327
+ NIL
1328
+ );
1329
+ }
1330
+ createAbortSignalConstructorNode(id) {
1331
+ return createSerovalNode(
1332
+ 35 /* AbortSignalConstructor */,
1333
+ id,
1334
+ NIL,
1335
+ NIL,
1336
+ NIL,
1337
+ NIL,
1338
+ NIL,
1339
+ NIL,
1340
+ NIL,
1341
+ this.parseSpecialReference(5 /* AbortSignalConstructor */),
1342
+ NIL,
1343
+ NIL
1344
+ );
1305
1345
  }
1306
1346
  };
1307
1347
 
@@ -1398,7 +1438,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1398
1438
  return createErrorNode(
1399
1439
  id,
1400
1440
  current,
1401
- options ? await this.parseProperties(options) : void 0
1441
+ options ? await this.parseProperties(options) : NIL
1402
1442
  );
1403
1443
  }
1404
1444
  async parseAggregateError(id, current) {
@@ -1406,7 +1446,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1406
1446
  return createAggregateErrorNode(
1407
1447
  id,
1408
1448
  current,
1409
- options ? await this.parseProperties(options) : void 0
1449
+ options ? await this.parseProperties(options) : NIL
1410
1450
  );
1411
1451
  }
1412
1452
  async parseMap(id, current) {
@@ -1427,20 +1467,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1427
1467
  }
1428
1468
  async parsePromise(id, current) {
1429
1469
  const [status, result] = await promiseToResult(current);
1430
- return {
1431
- t: 12 /* Promise */,
1432
- i: id,
1433
- s: status,
1434
- l: void 0,
1435
- c: void 0,
1436
- m: void 0,
1437
- p: void 0,
1438
- e: void 0,
1439
- a: void 0,
1440
- f: await this.parse(result),
1441
- b: void 0,
1442
- o: void 0
1443
- };
1470
+ return createSerovalNode(
1471
+ 12 /* Promise */,
1472
+ id,
1473
+ status,
1474
+ NIL,
1475
+ NIL,
1476
+ NIL,
1477
+ NIL,
1478
+ NIL,
1479
+ NIL,
1480
+ await this.parse(result),
1481
+ NIL,
1482
+ NIL
1483
+ );
1444
1484
  }
1445
1485
  async parsePlugin(id, current) {
1446
1486
  const currentPlugins = this.plugins;
@@ -1458,7 +1498,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1458
1498
  }
1459
1499
  }
1460
1500
  }
1461
- return void 0;
1501
+ return NIL;
1462
1502
  }
1463
1503
  async parseStream(id, current) {
1464
1504
  return createStreamConstructorNode(
@@ -1511,7 +1551,29 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1511
1551
  })
1512
1552
  );
1513
1553
  }
1514
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
1554
+ async parseAbortSignalSync(id, current) {
1555
+ return createSerovalNode(
1556
+ 37 /* AbortSignalSync */,
1557
+ id,
1558
+ NIL,
1559
+ NIL,
1560
+ NIL,
1561
+ NIL,
1562
+ NIL,
1563
+ NIL,
1564
+ NIL,
1565
+ await this.parse(current.reason),
1566
+ NIL,
1567
+ NIL
1568
+ );
1569
+ }
1570
+ async parseAbortSignal(id, current) {
1571
+ if (!current.aborted) {
1572
+ await abortSignalToPromise(current);
1573
+ }
1574
+ return this.parseAbortSignalSync(id, current);
1575
+ }
1576
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
1515
1577
  async parseObject(id, current) {
1516
1578
  if (Array.isArray(current)) {
1517
1579
  return this.parseArray(id, current);
@@ -1536,7 +1598,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1536
1598
  current,
1537
1599
  false
1538
1600
  );
1539
- case void 0:
1601
+ case NIL:
1540
1602
  return this.parsePlainObject(
1541
1603
  id,
1542
1604
  current,
@@ -1584,6 +1646,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1584
1646
  return this.parsePromise(id, current);
1585
1647
  }
1586
1648
  const currentFeatures = this.features;
1649
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
1650
+ return this.parseAbortSignal(id, current);
1651
+ }
1587
1652
  if (currentFeatures & 16 /* BigIntTypedArray */) {
1588
1653
  switch (currentClass) {
1589
1654
  case BigInt64Array:
@@ -1607,6 +1672,17 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1607
1672
  }
1608
1673
  throw new SerovalUnsupportedTypeError(current);
1609
1674
  }
1675
+ async parseFunction(current) {
1676
+ const ref = this.getReference(current);
1677
+ if (ref.type !== 0 /* Fresh */) {
1678
+ return ref.value;
1679
+ }
1680
+ const plugin = await this.parsePlugin(ref.value, current);
1681
+ if (plugin) {
1682
+ return plugin;
1683
+ }
1684
+ throw new SerovalUnsupportedTypeError(current);
1685
+ }
1610
1686
  async parse(current) {
1611
1687
  try {
1612
1688
  switch (typeof current) {
@@ -1906,6 +1982,21 @@ var BaseDeserializerContext = class {
1906
1982
  this.deserialize(node.a[1]);
1907
1983
  return void 0;
1908
1984
  }
1985
+ deserializeAbortSignalConstructor(node) {
1986
+ return this.assignIndexedValue(node.i, new AbortController()).signal;
1987
+ }
1988
+ deserializeAbortSignalAbort(node) {
1989
+ const controller = this.refs.get(node.i);
1990
+ assert(controller, new SerovalMissingInstanceError("AbortSignal"));
1991
+ controller.abort(this.deserialize(node.a[1]));
1992
+ return void 0;
1993
+ }
1994
+ deserializeAbortSignalSync(node) {
1995
+ return this.assignIndexedValue(
1996
+ node.i,
1997
+ AbortSignal.abort(this.deserialize(node.f))
1998
+ );
1999
+ }
1909
2000
  deserialize(node) {
1910
2001
  try {
1911
2002
  switch (node.t) {
@@ -1975,6 +2066,13 @@ var BaseDeserializerContext = class {
1975
2066
  return this.deserializeIteratorFactory(node);
1976
2067
  case 29 /* AsyncIteratorFactory */:
1977
2068
  return this.deserializeAsyncIteratorFactory(node);
2069
+ case 36 /* AbortSignalAbort */:
2070
+ return this.deserializeAbortSignalAbort(node);
2071
+ case 35 /* AbortSignalConstructor */:
2072
+ return this.deserializeAbortSignalConstructor(node);
2073
+ case 37 /* AbortSignalSync */:
2074
+ return this.deserializeAbortSignalSync(node);
2075
+ // case SerovalNodeType.SpecialReference:
1978
2076
  default:
1979
2077
  throw new SerovalUnsupportedNodeError(node);
1980
2078
  }
@@ -2027,7 +2125,7 @@ function mergeAssignments(assignments) {
2027
2125
  current = {
2028
2126
  t: 0 /* Index */,
2029
2127
  s: item.s,
2030
- k: void 0,
2128
+ k: NIL,
2031
2129
  v: getAssignmentExpression(current)
2032
2130
  };
2033
2131
  } else if (item.t === 2 /* Set */ && item.s === prev.s) {
@@ -2041,7 +2139,7 @@ function mergeAssignments(assignments) {
2041
2139
  current = {
2042
2140
  t: 1 /* Add */,
2043
2141
  s: getAssignmentExpression(current),
2044
- k: void 0,
2142
+ k: NIL,
2045
2143
  v: item.v
2046
2144
  };
2047
2145
  } else if (item.t === 3 /* Delete */ && item.s === prev.s) {
@@ -2049,7 +2147,7 @@ function mergeAssignments(assignments) {
2049
2147
  t: 3 /* Delete */,
2050
2148
  s: getAssignmentExpression(current),
2051
2149
  k: item.k,
2052
- v: void 0
2150
+ v: NIL
2053
2151
  };
2054
2152
  } else {
2055
2153
  newAssignments.push(current);
@@ -2069,7 +2167,7 @@ function resolveAssignments(assignments) {
2069
2167
  }
2070
2168
  return result;
2071
2169
  }
2072
- return void 0;
2170
+ return NIL;
2073
2171
  }
2074
2172
  var NULL_CONSTRUCTOR = "Object.create(null)";
2075
2173
  var SET_CONSTRUCTOR = "new Set";
@@ -2080,7 +2178,7 @@ var OBJECT_FLAG_CONSTRUCTOR = {
2080
2178
  [3 /* Frozen */]: "Object.freeze",
2081
2179
  [2 /* Sealed */]: "Object.seal",
2082
2180
  [1 /* NonExtensible */]: "Object.preventExtensions",
2083
- [0 /* None */]: void 0
2181
+ [0 /* None */]: NIL
2084
2182
  };
2085
2183
  var BaseSerializerContext = class {
2086
2184
  constructor(options) {
@@ -2166,7 +2264,7 @@ var BaseSerializerContext = class {
2166
2264
  this.assignments.push({
2167
2265
  t: 0 /* Index */,
2168
2266
  s: source,
2169
- k: void 0,
2267
+ k: NIL,
2170
2268
  v: value
2171
2269
  });
2172
2270
  }
@@ -2174,7 +2272,7 @@ var BaseSerializerContext = class {
2174
2272
  this.assignments.push({
2175
2273
  t: 1 /* Add */,
2176
2274
  s: this.getRefParam(ref),
2177
- k: void 0,
2275
+ k: NIL,
2178
2276
  v: value
2179
2277
  });
2180
2278
  }
@@ -2191,7 +2289,7 @@ var BaseSerializerContext = class {
2191
2289
  t: 3 /* Delete */,
2192
2290
  s: this.getRefParam(ref),
2193
2291
  k: key,
2194
- v: void 0
2292
+ v: NIL
2195
2293
  });
2196
2294
  }
2197
2295
  createArrayAssign(ref, index, value) {
@@ -2376,7 +2474,7 @@ var BaseSerializerContext = class {
2376
2474
  this.stack.pop();
2377
2475
  return resolveAssignments(mainAssignments);
2378
2476
  }
2379
- return void 0;
2477
+ return NIL;
2380
2478
  }
2381
2479
  serializeDictionary(node, init) {
2382
2480
  if (node.p) {
@@ -2631,6 +2729,16 @@ var BaseSerializerContext = class {
2631
2729
  'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
2632
2730
  ) + "})"
2633
2731
  );
2732
+ case 5 /* AbortSignalConstructor */:
2733
+ return this.createFunction(
2734
+ ["a", "s"],
2735
+ "((s=(a=new AbortController).signal).a=a,s)"
2736
+ );
2737
+ case 6 /* AbortSignalAbort */:
2738
+ return this.createEffectfulFunction(
2739
+ ["s", "r"],
2740
+ "s.a.abort(r);delete s.a"
2741
+ );
2634
2742
  default:
2635
2743
  return "";
2636
2744
  }
@@ -2742,6 +2850,18 @@ var BaseSerializerContext = class {
2742
2850
  serializeStreamReturn(node) {
2743
2851
  return this.getRefParam(node.i) + ".return(" + this.serialize(node.f) + ")";
2744
2852
  }
2853
+ serializeAbortSignalSync(node) {
2854
+ return this.assignIndexedValue(
2855
+ node.i,
2856
+ "AbortSignal.abort(" + this.serialize(node.f) + ")"
2857
+ );
2858
+ }
2859
+ serializeAbortSignalConstructor(node) {
2860
+ return this.assignIndexedValue(node.i, this.getConstructor(node.f) + "()");
2861
+ }
2862
+ serializeAbortSignalAbort(node) {
2863
+ return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
2864
+ }
2745
2865
  serialize(node) {
2746
2866
  try {
2747
2867
  switch (node.t) {
@@ -2814,6 +2934,12 @@ var BaseSerializerContext = class {
2814
2934
  return this.serializeStreamThrow(node);
2815
2935
  case 34 /* StreamReturn */:
2816
2936
  return this.serializeStreamReturn(node);
2937
+ case 36 /* AbortSignalAbort */:
2938
+ return this.serializeAbortSignalAbort(node);
2939
+ case 35 /* AbortSignalConstructor */:
2940
+ return this.serializeAbortSignalConstructor(node);
2941
+ case 37 /* AbortSignalSync */:
2942
+ return this.serializeAbortSignalSync(node);
2817
2943
  default:
2818
2944
  throw new SerovalUnsupportedNodeError(node);
2819
2945
  }
@@ -2942,7 +3068,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2942
3068
  return createErrorNode(
2943
3069
  id,
2944
3070
  current,
2945
- options ? this.parseProperties(options) : void 0
3071
+ options ? this.parseProperties(options) : NIL
2946
3072
  );
2947
3073
  }
2948
3074
  parseAggregateError(id, current) {
@@ -2950,7 +3076,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2950
3076
  return createAggregateErrorNode(
2951
3077
  id,
2952
3078
  current,
2953
- options ? this.parseProperties(options) : void 0
3079
+ options ? this.parseProperties(options) : NIL
2954
3080
  );
2955
3081
  }
2956
3082
  parseMap(id, current) {
@@ -2997,7 +3123,29 @@ var BaseSyncParserContext = class extends BaseParserContext {
2997
3123
  parsePromise(id, _current) {
2998
3124
  return this.createPromiseConstructorNode(id);
2999
3125
  }
3000
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
3126
+ parseAbortSignalSync(id, current) {
3127
+ return createSerovalNode(
3128
+ 37 /* AbortSignalSync */,
3129
+ id,
3130
+ NIL,
3131
+ NIL,
3132
+ NIL,
3133
+ NIL,
3134
+ NIL,
3135
+ NIL,
3136
+ NIL,
3137
+ this.parse(current.reason),
3138
+ NIL,
3139
+ NIL
3140
+ );
3141
+ }
3142
+ parseAbortSignal(id, current) {
3143
+ if (current.aborted) {
3144
+ return this.parseAbortSignalSync(id, current);
3145
+ }
3146
+ return this.createAbortSignalConstructorNode(id);
3147
+ }
3148
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
3001
3149
  parseObject(id, current) {
3002
3150
  if (Array.isArray(current)) {
3003
3151
  return this.parseArray(id, current);
@@ -3070,6 +3218,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
3070
3218
  return this.parsePromise(id, current);
3071
3219
  }
3072
3220
  const currentFeatures = this.features;
3221
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
3222
+ return this.parseAbortSignal(id, current);
3223
+ }
3073
3224
  if (currentFeatures & 16 /* BigIntTypedArray */) {
3074
3225
  switch (currentClass) {
3075
3226
  case BigInt64Array:
@@ -3093,6 +3244,17 @@ var BaseSyncParserContext = class extends BaseParserContext {
3093
3244
  }
3094
3245
  throw new SerovalUnsupportedTypeError(current);
3095
3246
  }
3247
+ parseFunction(current) {
3248
+ const ref = this.getReference(current);
3249
+ if (ref.type !== 0 /* Fresh */) {
3250
+ return ref.value;
3251
+ }
3252
+ const plugin = this.parsePlugin(ref.value, current);
3253
+ if (plugin) {
3254
+ return plugin;
3255
+ }
3256
+ throw new SerovalUnsupportedTypeError(current);
3257
+ }
3096
3258
  parse(current) {
3097
3259
  try {
3098
3260
  switch (typeof current) {
@@ -3109,14 +3271,15 @@ var BaseSyncParserContext = class extends BaseParserContext {
3109
3271
  case "object": {
3110
3272
  if (current) {
3111
3273
  const ref = this.getReference(current);
3112
- return ref.type === 0 ? this.parseObject(ref.value, current) : ref.value;
3274
+ return ref.type === 0 /* Fresh */ ? this.parseObject(ref.value, current) : ref.value;
3113
3275
  }
3114
3276
  return NULL_NODE;
3115
3277
  }
3116
3278
  case "symbol":
3117
3279
  return this.parseWellKnownSymbol(current);
3118
- case "function":
3280
+ case "function": {
3119
3281
  return this.parseFunction(current);
3282
+ }
3120
3283
  default:
3121
3284
  throw new SerovalUnsupportedTypeError(current);
3122
3285
  }
@@ -3234,23 +3397,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3234
3397
  (data) => {
3235
3398
  const parsed = this.parseWithError(data);
3236
3399
  if (parsed) {
3237
- this.onParse({
3238
- t: 23 /* PromiseResolve */,
3239
- i: id,
3240
- s: void 0,
3241
- l: void 0,
3242
- c: void 0,
3243
- m: void 0,
3244
- p: void 0,
3245
- e: void 0,
3246
- a: [
3247
- this.parseSpecialReference(2 /* PromiseResolve */),
3248
- parsed
3249
- ],
3250
- f: void 0,
3251
- b: void 0,
3252
- o: void 0
3253
- });
3400
+ this.onParse(
3401
+ createSerovalNode(
3402
+ 23 /* PromiseResolve */,
3403
+ id,
3404
+ NIL,
3405
+ NIL,
3406
+ NIL,
3407
+ NIL,
3408
+ NIL,
3409
+ NIL,
3410
+ [
3411
+ this.parseSpecialReference(2 /* PromiseResolve */),
3412
+ parsed
3413
+ ],
3414
+ NIL,
3415
+ NIL,
3416
+ NIL
3417
+ )
3418
+ );
3254
3419
  }
3255
3420
  this.popPendingState();
3256
3421
  },
@@ -3258,23 +3423,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3258
3423
  if (this.alive) {
3259
3424
  const parsed = this.parseWithError(data);
3260
3425
  if (parsed) {
3261
- this.onParse({
3262
- t: 24 /* PromiseReject */,
3263
- i: id,
3264
- s: void 0,
3265
- l: void 0,
3266
- c: void 0,
3267
- m: void 0,
3268
- p: void 0,
3269
- e: void 0,
3270
- a: [
3271
- this.parseSpecialReference(3 /* PromiseReject */),
3272
- parsed
3273
- ],
3274
- f: void 0,
3275
- b: void 0,
3276
- o: void 0
3277
- });
3426
+ this.onParse(
3427
+ createSerovalNode(
3428
+ 24 /* PromiseReject */,
3429
+ id,
3430
+ NIL,
3431
+ NIL,
3432
+ NIL,
3433
+ NIL,
3434
+ NIL,
3435
+ NIL,
3436
+ [
3437
+ this.parseSpecialReference(3 /* PromiseReject */),
3438
+ parsed
3439
+ ],
3440
+ NIL,
3441
+ NIL,
3442
+ NIL
3443
+ )
3444
+ );
3278
3445
  }
3279
3446
  }
3280
3447
  this.popPendingState();
@@ -3299,7 +3466,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3299
3466
  }
3300
3467
  }
3301
3468
  }
3302
- return void 0;
3469
+ return NIL;
3303
3470
  }
3304
3471
  parseStream(id, current) {
3305
3472
  const result = createStreamConstructorNode(
@@ -3338,12 +3505,51 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3338
3505
  });
3339
3506
  return result;
3340
3507
  }
3508
+ handleAbortSignal(id, current) {
3509
+ if (this.alive) {
3510
+ const parsed = this.parseWithError(current.reason);
3511
+ if (parsed) {
3512
+ this.onParse(
3513
+ createSerovalNode(
3514
+ 36 /* AbortSignalAbort */,
3515
+ id,
3516
+ NIL,
3517
+ NIL,
3518
+ NIL,
3519
+ NIL,
3520
+ NIL,
3521
+ NIL,
3522
+ [
3523
+ this.parseSpecialReference(6 /* AbortSignalAbort */),
3524
+ parsed
3525
+ ],
3526
+ NIL,
3527
+ NIL,
3528
+ NIL
3529
+ )
3530
+ );
3531
+ }
3532
+ }
3533
+ this.popPendingState();
3534
+ }
3535
+ parseAbortSignal(id, current) {
3536
+ if (current.aborted) {
3537
+ return this.parseAbortSignalSync(id, current);
3538
+ }
3539
+ this.pushPendingState();
3540
+ current.addEventListener(
3541
+ "abort",
3542
+ this.handleAbortSignal.bind(this, id, current),
3543
+ { once: true }
3544
+ );
3545
+ return this.createAbortSignalConstructorNode(id);
3546
+ }
3341
3547
  parseWithError(current) {
3342
3548
  try {
3343
3549
  return this.parse(current);
3344
3550
  } catch (err) {
3345
3551
  this.onError(err);
3346
- return void 0;
3552
+ return NIL;
3347
3553
  }
3348
3554
  }
3349
3555
  /**
@@ -3469,9 +3675,7 @@ function crossSerializeStream(source, options) {
3469
3675
  onDone: options.onDone
3470
3676
  });
3471
3677
  ctx.start(source);
3472
- return () => {
3473
- ctx.destroy();
3474
- };
3678
+ return ctx.destroy.bind(ctx);
3475
3679
  }
3476
3680
  function toCrossJSONStream(source, options) {
3477
3681
  const plugins = resolvePlugins(options.plugins);
@@ -3484,9 +3688,7 @@ function toCrossJSONStream(source, options) {
3484
3688
  onDone: options.onDone
3485
3689
  });
3486
3690
  ctx.start(source);
3487
- return () => {
3488
- ctx.destroy();
3489
- };
3691
+ return ctx.destroy.bind(ctx);
3490
3692
  }
3491
3693
  function fromCrossJSON(source, options) {
3492
3694
  const plugins = resolvePlugins(options.plugins);
@@ -3585,6 +3787,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3585
3787
  serializePromiseReject(node) {
3586
3788
  throw new SerovalUnsupportedNodeError(node);
3587
3789
  }
3790
+ serializeAbortSignalAbort(node) {
3791
+ throw new SerovalUnsupportedNodeError(node);
3792
+ }
3588
3793
  serializeTop(tree) {
3589
3794
  const result = this.serialize(tree);
3590
3795
  if (tree.i != null && this.vars.length) {