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
@@ -63,9 +63,10 @@ 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";
66
67
  return Feature2;
67
68
  })(Feature || {});
68
- var ALL_ENABLED = 31;
69
+ var ALL_ENABLED = 47;
69
70
 
70
71
  // src/core/string.ts
71
72
  function serializeChar(str) {
@@ -241,6 +242,19 @@ function resolvePlugins(plugins) {
241
242
  return void 0;
242
243
  }
243
244
 
245
+ // src/core/abort-signal.ts
246
+ function resolveAbortSignalResult(resolve) {
247
+ resolve(this.reason);
248
+ }
249
+ function resolveAbortSignal(resolve) {
250
+ this.addEventListener("abort", resolveAbortSignalResult.bind(this, resolve), {
251
+ once: true
252
+ });
253
+ }
254
+ function abortSignalToPromise(signal) {
255
+ return new Promise(resolveAbortSignal.bind(signal));
256
+ }
257
+
244
258
  // src/core/constants.ts
245
259
  var SYMBOL_STRING = {
246
260
  [0 /* AsyncIterator */]: "Symbol.asyncIterator",
@@ -325,24 +339,43 @@ var ERROR_CONSTRUCTOR = {
325
339
  [5 /* TypeError */]: TypeError,
326
340
  [6 /* URIError */]: URIError
327
341
  };
342
+ var NIL = void 0;
328
343
 
329
- // src/core/literals.ts
330
- function createConstantNode(value) {
344
+ // src/core/node.ts
345
+ function createSerovalNode(t, i, s, l, c, m, p, e, a, f, b, o) {
331
346
  return {
332
- t: 2 /* Constant */,
333
- i: void 0,
334
- s: value,
335
- l: void 0,
336
- c: void 0,
337
- m: void 0,
338
- p: void 0,
339
- e: void 0,
340
- a: void 0,
341
- f: void 0,
342
- b: void 0,
343
- o: void 0
347
+ t,
348
+ i,
349
+ s,
350
+ l,
351
+ c,
352
+ m,
353
+ p,
354
+ e,
355
+ a,
356
+ f,
357
+ b,
358
+ o
344
359
  };
345
360
  }
361
+
362
+ // src/core/literals.ts
363
+ function createConstantNode(value) {
364
+ return createSerovalNode(
365
+ 2 /* Constant */,
366
+ NIL,
367
+ value,
368
+ NIL,
369
+ NIL,
370
+ NIL,
371
+ NIL,
372
+ NIL,
373
+ NIL,
374
+ NIL,
375
+ NIL,
376
+ NIL
377
+ );
378
+ }
346
379
  var TRUE_NODE = /* @__PURE__ */ createConstantNode(
347
380
  2 /* True */
348
381
  );
@@ -446,100 +479,100 @@ function createNumberNode(value) {
446
479
  if (Object.is(value, -0)) {
447
480
  return NEG_ZERO_NODE;
448
481
  }
449
- return {
450
- t: 0 /* Number */,
451
- i: void 0,
452
- s: value,
453
- l: void 0,
454
- c: void 0,
455
- m: void 0,
456
- p: void 0,
457
- e: void 0,
458
- a: void 0,
459
- f: void 0,
460
- b: void 0,
461
- o: void 0
462
- };
482
+ return createSerovalNode(
483
+ 0 /* Number */,
484
+ NIL,
485
+ value,
486
+ NIL,
487
+ NIL,
488
+ NIL,
489
+ NIL,
490
+ NIL,
491
+ NIL,
492
+ NIL,
493
+ NIL,
494
+ NIL
495
+ );
463
496
  }
464
497
  function createStringNode(value) {
465
- return {
466
- t: 1 /* String */,
467
- i: void 0,
468
- s: serializeString(value),
469
- l: void 0,
470
- c: void 0,
471
- m: void 0,
472
- p: void 0,
473
- e: void 0,
474
- a: void 0,
475
- f: void 0,
476
- b: void 0,
477
- o: void 0
478
- };
498
+ return createSerovalNode(
499
+ 1 /* String */,
500
+ NIL,
501
+ serializeString(value),
502
+ NIL,
503
+ NIL,
504
+ NIL,
505
+ NIL,
506
+ NIL,
507
+ NIL,
508
+ NIL,
509
+ NIL,
510
+ NIL
511
+ );
479
512
  }
480
513
  function createBigIntNode(current) {
481
- return {
482
- t: 3 /* BigInt */,
483
- i: void 0,
484
- s: "" + current,
485
- l: void 0,
486
- c: void 0,
487
- m: void 0,
488
- p: void 0,
489
- e: void 0,
490
- a: void 0,
491
- f: void 0,
492
- b: void 0,
493
- o: void 0
494
- };
514
+ return createSerovalNode(
515
+ 3 /* BigInt */,
516
+ NIL,
517
+ "" + current,
518
+ NIL,
519
+ NIL,
520
+ NIL,
521
+ NIL,
522
+ NIL,
523
+ NIL,
524
+ NIL,
525
+ NIL,
526
+ NIL
527
+ );
495
528
  }
496
529
  function createIndexedValueNode(id) {
497
- return {
498
- t: 4 /* IndexedValue */,
499
- i: id,
500
- s: void 0,
501
- l: void 0,
502
- c: void 0,
503
- m: void 0,
504
- p: void 0,
505
- e: void 0,
506
- a: void 0,
507
- f: void 0,
508
- b: void 0,
509
- o: void 0
510
- };
530
+ return createSerovalNode(
531
+ 4 /* IndexedValue */,
532
+ id,
533
+ NIL,
534
+ NIL,
535
+ NIL,
536
+ NIL,
537
+ NIL,
538
+ NIL,
539
+ NIL,
540
+ NIL,
541
+ NIL,
542
+ NIL
543
+ );
511
544
  }
512
545
  function createDateNode(id, current) {
513
- return {
514
- t: 5 /* Date */,
515
- i: id,
516
- s: current.toISOString(),
517
- l: void 0,
518
- c: void 0,
519
- m: void 0,
520
- p: void 0,
521
- e: void 0,
522
- f: void 0,
523
- a: void 0,
524
- b: void 0,
525
- o: void 0
526
- };
546
+ return createSerovalNode(
547
+ 5 /* Date */,
548
+ id,
549
+ current.toISOString(),
550
+ NIL,
551
+ NIL,
552
+ NIL,
553
+ NIL,
554
+ NIL,
555
+ NIL,
556
+ NIL,
557
+ NIL,
558
+ NIL
559
+ );
527
560
  }
528
561
  function createRegExpNode(id, current) {
529
- return {
530
- t: 6 /* RegExp */,
531
- i: id,
532
- s: void 0,
533
- l: void 0,
534
- c: serializeString(current.source),
535
- m: current.flags,
536
- p: void 0,
537
- e: void 0,
538
- a: void 0,
539
- f: void 0,
540
- b: void 0,
541
- o: void 0
542
- };
562
+ return createSerovalNode(
563
+ 6 /* RegExp */,
564
+ id,
565
+ NIL,
566
+ NIL,
567
+ serializeString(current.source),
568
+ current.flags,
569
+ NIL,
570
+ NIL,
571
+ NIL,
572
+ NIL,
573
+ NIL,
574
+ NIL
575
+ );
543
576
  }
544
577
  function createArrayBufferNode(id, current) {
545
578
  const bytes = new Uint8Array(current);
@@ -548,292 +581,292 @@ function createArrayBufferNode(id, current) {
548
581
  for (let i = 0; i < len; i++) {
549
582
  values[i] = bytes[i];
550
583
  }
551
- return {
552
- t: 19 /* ArrayBuffer */,
553
- i: id,
554
- s: values,
555
- l: void 0,
556
- c: void 0,
557
- m: void 0,
558
- p: void 0,
559
- e: void 0,
560
- a: void 0,
561
- f: void 0,
562
- b: void 0,
563
- o: void 0
564
- };
584
+ return createSerovalNode(
585
+ 19 /* ArrayBuffer */,
586
+ id,
587
+ values,
588
+ NIL,
589
+ NIL,
590
+ NIL,
591
+ NIL,
592
+ NIL,
593
+ NIL,
594
+ NIL,
595
+ NIL,
596
+ NIL
597
+ );
565
598
  }
566
599
  function createWKSymbolNode(id, current) {
567
- return {
568
- t: 17 /* WKSymbol */,
569
- i: id,
570
- s: INV_SYMBOL_REF[current],
571
- l: void 0,
572
- c: void 0,
573
- m: void 0,
574
- p: void 0,
575
- e: void 0,
576
- a: void 0,
577
- f: void 0,
578
- b: void 0,
579
- o: void 0
580
- };
600
+ return createSerovalNode(
601
+ 17 /* WKSymbol */,
602
+ id,
603
+ INV_SYMBOL_REF[current],
604
+ NIL,
605
+ NIL,
606
+ NIL,
607
+ NIL,
608
+ NIL,
609
+ NIL,
610
+ NIL,
611
+ NIL,
612
+ NIL
613
+ );
581
614
  }
582
615
  function createReferenceNode(id, ref) {
583
- return {
584
- t: 18 /* Reference */,
585
- i: id,
586
- s: serializeString(getReferenceID(ref)),
587
- l: void 0,
588
- c: void 0,
589
- m: void 0,
590
- p: void 0,
591
- e: void 0,
592
- a: void 0,
593
- f: void 0,
594
- b: void 0,
595
- o: void 0
596
- };
616
+ return createSerovalNode(
617
+ 18 /* Reference */,
618
+ id,
619
+ serializeString(getReferenceID(ref)),
620
+ NIL,
621
+ NIL,
622
+ NIL,
623
+ NIL,
624
+ NIL,
625
+ NIL,
626
+ NIL,
627
+ NIL,
628
+ NIL
629
+ );
597
630
  }
598
631
  function createPluginNode(id, tag, value) {
599
- return {
600
- t: 25 /* Plugin */,
601
- i: id,
602
- s: value,
603
- l: void 0,
604
- c: serializeString(tag),
605
- m: void 0,
606
- p: void 0,
607
- e: void 0,
608
- a: void 0,
609
- f: void 0,
610
- b: void 0,
611
- o: void 0
612
- };
632
+ return createSerovalNode(
633
+ 25 /* Plugin */,
634
+ id,
635
+ value,
636
+ NIL,
637
+ serializeString(tag),
638
+ NIL,
639
+ NIL,
640
+ NIL,
641
+ NIL,
642
+ NIL,
643
+ NIL,
644
+ NIL
645
+ );
613
646
  }
614
647
  function createArrayNode(id, current, parsedItems) {
615
- return {
616
- t: 9 /* Array */,
617
- i: id,
618
- s: void 0,
619
- l: current.length,
620
- c: void 0,
621
- m: void 0,
622
- p: void 0,
623
- e: void 0,
624
- a: parsedItems,
625
- f: void 0,
626
- b: void 0,
627
- o: getObjectFlag(current)
628
- };
648
+ return createSerovalNode(
649
+ 9 /* Array */,
650
+ id,
651
+ NIL,
652
+ current.length,
653
+ NIL,
654
+ NIL,
655
+ NIL,
656
+ NIL,
657
+ parsedItems,
658
+ NIL,
659
+ NIL,
660
+ getObjectFlag(current)
661
+ );
629
662
  }
630
663
  function createBoxedNode(id, boxed) {
631
- return {
632
- t: 21 /* Boxed */,
633
- i: id,
634
- s: void 0,
635
- l: void 0,
636
- c: void 0,
637
- m: void 0,
638
- p: void 0,
639
- e: void 0,
640
- a: void 0,
641
- f: boxed,
642
- b: void 0,
643
- o: void 0
644
- };
664
+ return createSerovalNode(
665
+ 21 /* Boxed */,
666
+ id,
667
+ NIL,
668
+ NIL,
669
+ NIL,
670
+ NIL,
671
+ NIL,
672
+ NIL,
673
+ NIL,
674
+ boxed,
675
+ NIL,
676
+ NIL
677
+ );
645
678
  }
646
679
  function createTypedArrayNode(id, current, buffer) {
647
- return {
648
- t: 15 /* TypedArray */,
649
- i: id,
650
- s: void 0,
651
- l: current.length,
652
- c: current.constructor.name,
653
- m: void 0,
654
- p: void 0,
655
- e: void 0,
656
- a: void 0,
657
- f: buffer,
658
- b: current.byteOffset,
659
- o: void 0
660
- };
680
+ return createSerovalNode(
681
+ 15 /* TypedArray */,
682
+ id,
683
+ NIL,
684
+ current.length,
685
+ current.constructor.name,
686
+ NIL,
687
+ NIL,
688
+ NIL,
689
+ NIL,
690
+ buffer,
691
+ current.byteOffset,
692
+ NIL
693
+ );
661
694
  }
662
695
  function createBigIntTypedArrayNode(id, current, buffer) {
663
- return {
664
- t: 16 /* BigIntTypedArray */,
665
- i: id,
666
- s: void 0,
667
- l: current.length,
668
- c: current.constructor.name,
669
- m: void 0,
670
- p: void 0,
671
- e: void 0,
672
- a: void 0,
673
- f: buffer,
674
- b: current.byteOffset,
675
- o: void 0
676
- };
696
+ return createSerovalNode(
697
+ 16 /* BigIntTypedArray */,
698
+ id,
699
+ NIL,
700
+ current.length,
701
+ current.constructor.name,
702
+ NIL,
703
+ NIL,
704
+ NIL,
705
+ NIL,
706
+ buffer,
707
+ current.byteOffset,
708
+ NIL
709
+ );
677
710
  }
678
711
  function createDataViewNode(id, current, buffer) {
679
- return {
680
- t: 20 /* DataView */,
681
- i: id,
682
- s: void 0,
683
- l: current.byteLength,
684
- c: void 0,
685
- m: void 0,
686
- p: void 0,
687
- e: void 0,
688
- a: void 0,
689
- f: buffer,
690
- b: current.byteOffset,
691
- o: void 0
692
- };
712
+ return createSerovalNode(
713
+ 20 /* DataView */,
714
+ id,
715
+ NIL,
716
+ current.byteLength,
717
+ NIL,
718
+ NIL,
719
+ NIL,
720
+ NIL,
721
+ NIL,
722
+ buffer,
723
+ current.byteOffset,
724
+ NIL
725
+ );
693
726
  }
694
727
  function createErrorNode(id, current, options) {
695
- return {
696
- t: 13 /* Error */,
697
- i: id,
698
- s: getErrorConstructor(current),
699
- l: void 0,
700
- c: void 0,
701
- m: serializeString(current.message),
702
- p: options,
703
- e: void 0,
704
- a: void 0,
705
- f: void 0,
706
- b: void 0,
707
- o: void 0
708
- };
728
+ return createSerovalNode(
729
+ 13 /* Error */,
730
+ id,
731
+ getErrorConstructor(current),
732
+ NIL,
733
+ NIL,
734
+ serializeString(current.message),
735
+ options,
736
+ NIL,
737
+ NIL,
738
+ NIL,
739
+ NIL,
740
+ NIL
741
+ );
709
742
  }
710
743
  function createAggregateErrorNode(id, current, options) {
711
- return {
712
- t: 14 /* AggregateError */,
713
- i: id,
714
- s: getErrorConstructor(current),
715
- l: void 0,
716
- c: void 0,
717
- m: serializeString(current.message),
718
- p: options,
719
- e: void 0,
720
- a: void 0,
721
- f: void 0,
722
- b: void 0,
723
- o: void 0
724
- };
744
+ return createSerovalNode(
745
+ 14 /* AggregateError */,
746
+ id,
747
+ getErrorConstructor(current),
748
+ NIL,
749
+ NIL,
750
+ serializeString(current.message),
751
+ options,
752
+ NIL,
753
+ NIL,
754
+ NIL,
755
+ NIL,
756
+ NIL
757
+ );
725
758
  }
726
759
  function createSetNode(id, size, items) {
727
- return {
728
- t: 7 /* Set */,
729
- i: id,
730
- s: void 0,
731
- l: size,
732
- c: void 0,
733
- m: void 0,
734
- p: void 0,
735
- e: void 0,
736
- a: items,
737
- f: void 0,
738
- b: void 0,
739
- o: void 0
740
- };
760
+ return createSerovalNode(
761
+ 7 /* Set */,
762
+ id,
763
+ NIL,
764
+ size,
765
+ NIL,
766
+ NIL,
767
+ NIL,
768
+ NIL,
769
+ items,
770
+ NIL,
771
+ NIL,
772
+ NIL
773
+ );
741
774
  }
742
775
  function createIteratorFactoryInstanceNode(factory, items) {
743
- return {
744
- t: 28 /* IteratorFactoryInstance */,
745
- i: void 0,
746
- s: void 0,
747
- l: void 0,
748
- c: void 0,
749
- m: void 0,
750
- p: void 0,
751
- e: void 0,
752
- a: [factory, items],
753
- f: void 0,
754
- b: void 0,
755
- o: void 0
756
- };
776
+ return createSerovalNode(
777
+ 28 /* IteratorFactoryInstance */,
778
+ NIL,
779
+ NIL,
780
+ NIL,
781
+ NIL,
782
+ NIL,
783
+ NIL,
784
+ NIL,
785
+ [factory, items],
786
+ NIL,
787
+ NIL,
788
+ NIL
789
+ );
757
790
  }
758
791
  function createAsyncIteratorFactoryInstanceNode(factory, items) {
759
- return {
760
- t: 30 /* AsyncIteratorFactoryInstance */,
761
- i: void 0,
762
- s: void 0,
763
- l: void 0,
764
- c: void 0,
765
- m: void 0,
766
- p: void 0,
767
- e: void 0,
768
- a: [factory, items],
769
- f: void 0,
770
- b: void 0,
771
- o: void 0
772
- };
792
+ return createSerovalNode(
793
+ 30 /* AsyncIteratorFactoryInstance */,
794
+ NIL,
795
+ NIL,
796
+ NIL,
797
+ NIL,
798
+ NIL,
799
+ NIL,
800
+ NIL,
801
+ [factory, items],
802
+ NIL,
803
+ NIL,
804
+ NIL
805
+ );
773
806
  }
774
807
  function createStreamConstructorNode(id, factory, sequence) {
775
- return {
776
- t: 31 /* StreamConstructor */,
777
- i: id,
778
- s: void 0,
779
- l: void 0,
780
- c: void 0,
781
- m: void 0,
782
- p: void 0,
783
- e: void 0,
784
- a: sequence,
785
- f: factory,
786
- b: void 0,
787
- o: void 0
788
- };
808
+ return createSerovalNode(
809
+ 31 /* StreamConstructor */,
810
+ id,
811
+ NIL,
812
+ NIL,
813
+ NIL,
814
+ NIL,
815
+ NIL,
816
+ NIL,
817
+ sequence,
818
+ factory,
819
+ NIL,
820
+ NIL
821
+ );
789
822
  }
790
823
  function createStreamNextNode(id, parsed) {
791
- return {
792
- t: 32 /* StreamNext */,
793
- i: id,
794
- s: void 0,
795
- l: void 0,
796
- c: void 0,
797
- m: void 0,
798
- p: void 0,
799
- e: void 0,
800
- a: void 0,
801
- f: parsed,
802
- b: void 0,
803
- o: void 0
804
- };
824
+ return createSerovalNode(
825
+ 32 /* StreamNext */,
826
+ id,
827
+ NIL,
828
+ NIL,
829
+ NIL,
830
+ NIL,
831
+ NIL,
832
+ NIL,
833
+ NIL,
834
+ parsed,
835
+ NIL,
836
+ NIL
837
+ );
805
838
  }
806
839
  function createStreamThrowNode(id, parsed) {
807
- return {
808
- t: 33 /* StreamThrow */,
809
- i: id,
810
- s: void 0,
811
- l: void 0,
812
- c: void 0,
813
- m: void 0,
814
- p: void 0,
815
- e: void 0,
816
- a: void 0,
817
- f: parsed,
818
- b: void 0,
819
- o: void 0
820
- };
840
+ return createSerovalNode(
841
+ 33 /* StreamThrow */,
842
+ id,
843
+ NIL,
844
+ NIL,
845
+ NIL,
846
+ NIL,
847
+ NIL,
848
+ NIL,
849
+ NIL,
850
+ parsed,
851
+ NIL,
852
+ NIL
853
+ );
821
854
  }
822
855
  function createStreamReturnNode(id, parsed) {
823
- return {
824
- t: 34 /* StreamReturn */,
825
- i: id,
826
- s: void 0,
827
- l: void 0,
828
- c: void 0,
829
- m: void 0,
830
- p: void 0,
831
- e: void 0,
832
- a: void 0,
833
- f: parsed,
834
- b: void 0,
835
- o: void 0
836
- };
856
+ return createSerovalNode(
857
+ 34 /* StreamReturn */,
858
+ id,
859
+ NIL,
860
+ NIL,
861
+ NIL,
862
+ NIL,
863
+ NIL,
864
+ NIL,
865
+ NIL,
866
+ parsed,
867
+ NIL,
868
+ NIL
869
+ );
837
870
  }
838
871
 
839
872
  // src/core/errors.ts
@@ -937,7 +970,9 @@ var SPECIAL_REFS = {
937
970
  [1 /* PromiseConstructor */]: {},
938
971
  [2 /* PromiseResolve */]: {},
939
972
  [3 /* PromiseReject */]: {},
940
- [4 /* StreamConstructor */]: {}
973
+ [4 /* StreamConstructor */]: {},
974
+ [5 /* AbortSignalConstructor */]: {},
975
+ [6 /* AbortSignalAbort */]: {}
941
976
  };
942
977
 
943
978
  // src/core/utils/deferred.ts
@@ -1162,7 +1197,7 @@ function sequenceToIterator(sequence) {
1162
1197
  if (index > sequence.d) {
1163
1198
  return {
1164
1199
  done: true,
1165
- value: void 0
1200
+ value: NIL
1166
1201
  };
1167
1202
  }
1168
1203
  const currentIndex = index++;
@@ -1231,17 +1266,6 @@ var BaseParserContext = class {
1231
1266
  }
1232
1267
  return indexed;
1233
1268
  }
1234
- getStrictReference(current) {
1235
- assert(hasReferenceID(current), new SerovalUnsupportedTypeError(current));
1236
- const result = this.getIndexedValue(current);
1237
- if (result.type === 1 /* Indexed */) {
1238
- return result.value;
1239
- }
1240
- return createReferenceNode(result.value, current);
1241
- }
1242
- parseFunction(current) {
1243
- return this.getStrictReference(current);
1244
- }
1245
1269
  parseWellKnownSymbol(current) {
1246
1270
  const ref = this.getReference(current);
1247
1271
  if (ref.type !== 0 /* Fresh */) {
@@ -1255,111 +1279,127 @@ var BaseParserContext = class {
1255
1279
  if (result.type === 1 /* Indexed */) {
1256
1280
  return result.value;
1257
1281
  }
1258
- return {
1259
- t: 26 /* SpecialReference */,
1260
- i: result.value,
1261
- s: ref,
1262
- l: void 0,
1263
- c: void 0,
1264
- m: void 0,
1265
- p: void 0,
1266
- e: void 0,
1267
- a: void 0,
1268
- f: void 0,
1269
- b: void 0,
1270
- o: void 0
1271
- };
1282
+ return createSerovalNode(
1283
+ 26 /* SpecialReference */,
1284
+ result.value,
1285
+ ref,
1286
+ NIL,
1287
+ NIL,
1288
+ NIL,
1289
+ NIL,
1290
+ NIL,
1291
+ NIL,
1292
+ NIL,
1293
+ NIL,
1294
+ NIL
1295
+ );
1272
1296
  }
1273
1297
  parseIteratorFactory() {
1274
1298
  const result = this.getIndexedValue(ITERATOR);
1275
1299
  if (result.type === 1 /* Indexed */) {
1276
1300
  return result.value;
1277
1301
  }
1278
- return {
1279
- t: 27 /* IteratorFactory */,
1280
- i: result.value,
1281
- s: void 0,
1282
- l: void 0,
1283
- c: void 0,
1284
- m: void 0,
1285
- p: void 0,
1286
- e: void 0,
1287
- a: void 0,
1288
- f: this.parseWellKnownSymbol(Symbol.iterator),
1289
- b: void 0,
1290
- o: void 0
1291
- };
1302
+ return createSerovalNode(
1303
+ 27 /* IteratorFactory */,
1304
+ result.value,
1305
+ NIL,
1306
+ NIL,
1307
+ NIL,
1308
+ NIL,
1309
+ NIL,
1310
+ NIL,
1311
+ NIL,
1312
+ this.parseWellKnownSymbol(Symbol.iterator),
1313
+ NIL,
1314
+ NIL
1315
+ );
1292
1316
  }
1293
1317
  parseAsyncIteratorFactory() {
1294
1318
  const result = this.getIndexedValue(ASYNC_ITERATOR);
1295
1319
  if (result.type === 1 /* Indexed */) {
1296
1320
  return result.value;
1297
1321
  }
1298
- return {
1299
- t: 29 /* AsyncIteratorFactory */,
1300
- i: result.value,
1301
- s: void 0,
1302
- l: void 0,
1303
- c: void 0,
1304
- m: void 0,
1305
- p: void 0,
1306
- e: void 0,
1307
- a: [
1322
+ return createSerovalNode(
1323
+ 29 /* AsyncIteratorFactory */,
1324
+ result.value,
1325
+ NIL,
1326
+ NIL,
1327
+ NIL,
1328
+ NIL,
1329
+ NIL,
1330
+ NIL,
1331
+ [
1308
1332
  this.parseSpecialReference(1 /* PromiseConstructor */),
1309
1333
  this.parseWellKnownSymbol(Symbol.asyncIterator)
1310
1334
  ],
1311
- f: void 0,
1312
- b: void 0,
1313
- o: void 0
1314
- };
1335
+ NIL,
1336
+ NIL,
1337
+ NIL
1338
+ );
1315
1339
  }
1316
1340
  createObjectNode(id, current, empty, record) {
1317
- return {
1318
- t: empty ? 11 /* NullConstructor */ : 10 /* Object */,
1319
- i: id,
1320
- s: void 0,
1321
- l: void 0,
1322
- c: void 0,
1323
- m: void 0,
1324
- p: record,
1325
- e: void 0,
1326
- a: void 0,
1327
- f: void 0,
1328
- b: void 0,
1329
- o: getObjectFlag(current)
1330
- };
1341
+ return createSerovalNode(
1342
+ empty ? 11 /* NullConstructor */ : 10 /* Object */,
1343
+ id,
1344
+ NIL,
1345
+ NIL,
1346
+ NIL,
1347
+ NIL,
1348
+ record,
1349
+ NIL,
1350
+ NIL,
1351
+ NIL,
1352
+ NIL,
1353
+ getObjectFlag(current)
1354
+ );
1331
1355
  }
1332
1356
  createMapNode(id, k, v, s) {
1333
- return {
1334
- t: 8 /* Map */,
1335
- i: id,
1336
- s: void 0,
1337
- l: void 0,
1338
- c: void 0,
1339
- m: void 0,
1340
- p: void 0,
1341
- e: { k, v, s },
1342
- a: void 0,
1343
- f: this.parseSpecialReference(0 /* MapSentinel */),
1344
- b: void 0,
1345
- o: void 0
1346
- };
1357
+ return createSerovalNode(
1358
+ 8 /* Map */,
1359
+ id,
1360
+ NIL,
1361
+ NIL,
1362
+ NIL,
1363
+ NIL,
1364
+ NIL,
1365
+ { k, v, s },
1366
+ NIL,
1367
+ this.parseSpecialReference(0 /* MapSentinel */),
1368
+ NIL,
1369
+ NIL
1370
+ );
1347
1371
  }
1348
1372
  createPromiseConstructorNode(id) {
1349
- return {
1350
- t: 22 /* PromiseConstructor */,
1351
- i: id,
1352
- s: void 0,
1353
- l: void 0,
1354
- c: void 0,
1355
- m: void 0,
1356
- p: void 0,
1357
- e: void 0,
1358
- a: void 0,
1359
- f: this.parseSpecialReference(1 /* PromiseConstructor */),
1360
- b: void 0,
1361
- o: void 0
1362
- };
1373
+ return createSerovalNode(
1374
+ 22 /* PromiseConstructor */,
1375
+ id,
1376
+ NIL,
1377
+ NIL,
1378
+ NIL,
1379
+ NIL,
1380
+ NIL,
1381
+ NIL,
1382
+ NIL,
1383
+ this.parseSpecialReference(1 /* PromiseConstructor */),
1384
+ NIL,
1385
+ NIL
1386
+ );
1387
+ }
1388
+ createAbortSignalConstructorNode(id) {
1389
+ return createSerovalNode(
1390
+ 35 /* AbortSignalConstructor */,
1391
+ id,
1392
+ NIL,
1393
+ NIL,
1394
+ NIL,
1395
+ NIL,
1396
+ NIL,
1397
+ NIL,
1398
+ NIL,
1399
+ this.parseSpecialReference(5 /* AbortSignalConstructor */),
1400
+ NIL,
1401
+ NIL
1402
+ );
1363
1403
  }
1364
1404
  };
1365
1405
 
@@ -1456,7 +1496,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1456
1496
  return createErrorNode(
1457
1497
  id,
1458
1498
  current,
1459
- options ? await this.parseProperties(options) : void 0
1499
+ options ? await this.parseProperties(options) : NIL
1460
1500
  );
1461
1501
  }
1462
1502
  async parseAggregateError(id, current) {
@@ -1464,7 +1504,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1464
1504
  return createAggregateErrorNode(
1465
1505
  id,
1466
1506
  current,
1467
- options ? await this.parseProperties(options) : void 0
1507
+ options ? await this.parseProperties(options) : NIL
1468
1508
  );
1469
1509
  }
1470
1510
  async parseMap(id, current) {
@@ -1485,20 +1525,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1485
1525
  }
1486
1526
  async parsePromise(id, current) {
1487
1527
  const [status, result] = await promiseToResult(current);
1488
- return {
1489
- t: 12 /* Promise */,
1490
- i: id,
1491
- s: status,
1492
- l: void 0,
1493
- c: void 0,
1494
- m: void 0,
1495
- p: void 0,
1496
- e: void 0,
1497
- a: void 0,
1498
- f: await this.parse(result),
1499
- b: void 0,
1500
- o: void 0
1501
- };
1528
+ return createSerovalNode(
1529
+ 12 /* Promise */,
1530
+ id,
1531
+ status,
1532
+ NIL,
1533
+ NIL,
1534
+ NIL,
1535
+ NIL,
1536
+ NIL,
1537
+ NIL,
1538
+ await this.parse(result),
1539
+ NIL,
1540
+ NIL
1541
+ );
1502
1542
  }
1503
1543
  async parsePlugin(id, current) {
1504
1544
  const currentPlugins = this.plugins;
@@ -1516,7 +1556,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1516
1556
  }
1517
1557
  }
1518
1558
  }
1519
- return void 0;
1559
+ return NIL;
1520
1560
  }
1521
1561
  async parseStream(id, current) {
1522
1562
  return createStreamConstructorNode(
@@ -1569,7 +1609,29 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1569
1609
  })
1570
1610
  );
1571
1611
  }
1572
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
1612
+ async parseAbortSignalSync(id, current) {
1613
+ return createSerovalNode(
1614
+ 37 /* AbortSignalSync */,
1615
+ id,
1616
+ NIL,
1617
+ NIL,
1618
+ NIL,
1619
+ NIL,
1620
+ NIL,
1621
+ NIL,
1622
+ NIL,
1623
+ await this.parse(current.reason),
1624
+ NIL,
1625
+ NIL
1626
+ );
1627
+ }
1628
+ async parseAbortSignal(id, current) {
1629
+ if (!current.aborted) {
1630
+ await abortSignalToPromise(current);
1631
+ }
1632
+ return this.parseAbortSignalSync(id, current);
1633
+ }
1634
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
1573
1635
  async parseObject(id, current) {
1574
1636
  if (Array.isArray(current)) {
1575
1637
  return this.parseArray(id, current);
@@ -1594,7 +1656,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1594
1656
  current,
1595
1657
  false
1596
1658
  );
1597
- case void 0:
1659
+ case NIL:
1598
1660
  return this.parsePlainObject(
1599
1661
  id,
1600
1662
  current,
@@ -1642,6 +1704,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1642
1704
  return this.parsePromise(id, current);
1643
1705
  }
1644
1706
  const currentFeatures = this.features;
1707
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
1708
+ return this.parseAbortSignal(id, current);
1709
+ }
1645
1710
  if (currentFeatures & 16 /* BigIntTypedArray */) {
1646
1711
  switch (currentClass) {
1647
1712
  case BigInt64Array:
@@ -1665,6 +1730,17 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1665
1730
  }
1666
1731
  throw new SerovalUnsupportedTypeError(current);
1667
1732
  }
1733
+ async parseFunction(current) {
1734
+ const ref = this.getReference(current);
1735
+ if (ref.type !== 0 /* Fresh */) {
1736
+ return ref.value;
1737
+ }
1738
+ const plugin = await this.parsePlugin(ref.value, current);
1739
+ if (plugin) {
1740
+ return plugin;
1741
+ }
1742
+ throw new SerovalUnsupportedTypeError(current);
1743
+ }
1668
1744
  async parse(current) {
1669
1745
  try {
1670
1746
  switch (typeof current) {
@@ -1964,6 +2040,21 @@ var BaseDeserializerContext = class {
1964
2040
  this.deserialize(node.a[1]);
1965
2041
  return void 0;
1966
2042
  }
2043
+ deserializeAbortSignalConstructor(node) {
2044
+ return this.assignIndexedValue(node.i, new AbortController()).signal;
2045
+ }
2046
+ deserializeAbortSignalAbort(node) {
2047
+ const controller = this.refs.get(node.i);
2048
+ assert(controller, new SerovalMissingInstanceError("AbortSignal"));
2049
+ controller.abort(this.deserialize(node.a[1]));
2050
+ return void 0;
2051
+ }
2052
+ deserializeAbortSignalSync(node) {
2053
+ return this.assignIndexedValue(
2054
+ node.i,
2055
+ AbortSignal.abort(this.deserialize(node.f))
2056
+ );
2057
+ }
1967
2058
  deserialize(node) {
1968
2059
  try {
1969
2060
  switch (node.t) {
@@ -2033,6 +2124,13 @@ var BaseDeserializerContext = class {
2033
2124
  return this.deserializeIteratorFactory(node);
2034
2125
  case 29 /* AsyncIteratorFactory */:
2035
2126
  return this.deserializeAsyncIteratorFactory(node);
2127
+ case 36 /* AbortSignalAbort */:
2128
+ return this.deserializeAbortSignalAbort(node);
2129
+ case 35 /* AbortSignalConstructor */:
2130
+ return this.deserializeAbortSignalConstructor(node);
2131
+ case 37 /* AbortSignalSync */:
2132
+ return this.deserializeAbortSignalSync(node);
2133
+ // case SerovalNodeType.SpecialReference:
2036
2134
  default:
2037
2135
  throw new SerovalUnsupportedNodeError(node);
2038
2136
  }
@@ -2085,7 +2183,7 @@ function mergeAssignments(assignments) {
2085
2183
  current = {
2086
2184
  t: 0 /* Index */,
2087
2185
  s: item.s,
2088
- k: void 0,
2186
+ k: NIL,
2089
2187
  v: getAssignmentExpression(current)
2090
2188
  };
2091
2189
  } else if (item.t === 2 /* Set */ && item.s === prev.s) {
@@ -2099,7 +2197,7 @@ function mergeAssignments(assignments) {
2099
2197
  current = {
2100
2198
  t: 1 /* Add */,
2101
2199
  s: getAssignmentExpression(current),
2102
- k: void 0,
2200
+ k: NIL,
2103
2201
  v: item.v
2104
2202
  };
2105
2203
  } else if (item.t === 3 /* Delete */ && item.s === prev.s) {
@@ -2107,7 +2205,7 @@ function mergeAssignments(assignments) {
2107
2205
  t: 3 /* Delete */,
2108
2206
  s: getAssignmentExpression(current),
2109
2207
  k: item.k,
2110
- v: void 0
2208
+ v: NIL
2111
2209
  };
2112
2210
  } else {
2113
2211
  newAssignments.push(current);
@@ -2127,7 +2225,7 @@ function resolveAssignments(assignments) {
2127
2225
  }
2128
2226
  return result;
2129
2227
  }
2130
- return void 0;
2228
+ return NIL;
2131
2229
  }
2132
2230
  var NULL_CONSTRUCTOR = "Object.create(null)";
2133
2231
  var SET_CONSTRUCTOR = "new Set";
@@ -2138,7 +2236,7 @@ var OBJECT_FLAG_CONSTRUCTOR = {
2138
2236
  [3 /* Frozen */]: "Object.freeze",
2139
2237
  [2 /* Sealed */]: "Object.seal",
2140
2238
  [1 /* NonExtensible */]: "Object.preventExtensions",
2141
- [0 /* None */]: void 0
2239
+ [0 /* None */]: NIL
2142
2240
  };
2143
2241
  var BaseSerializerContext = class {
2144
2242
  constructor(options) {
@@ -2224,7 +2322,7 @@ var BaseSerializerContext = class {
2224
2322
  this.assignments.push({
2225
2323
  t: 0 /* Index */,
2226
2324
  s: source,
2227
- k: void 0,
2325
+ k: NIL,
2228
2326
  v: value
2229
2327
  });
2230
2328
  }
@@ -2232,7 +2330,7 @@ var BaseSerializerContext = class {
2232
2330
  this.assignments.push({
2233
2331
  t: 1 /* Add */,
2234
2332
  s: this.getRefParam(ref),
2235
- k: void 0,
2333
+ k: NIL,
2236
2334
  v: value
2237
2335
  });
2238
2336
  }
@@ -2249,7 +2347,7 @@ var BaseSerializerContext = class {
2249
2347
  t: 3 /* Delete */,
2250
2348
  s: this.getRefParam(ref),
2251
2349
  k: key,
2252
- v: void 0
2350
+ v: NIL
2253
2351
  });
2254
2352
  }
2255
2353
  createArrayAssign(ref, index, value) {
@@ -2434,7 +2532,7 @@ var BaseSerializerContext = class {
2434
2532
  this.stack.pop();
2435
2533
  return resolveAssignments(mainAssignments);
2436
2534
  }
2437
- return void 0;
2535
+ return NIL;
2438
2536
  }
2439
2537
  serializeDictionary(node, init) {
2440
2538
  if (node.p) {
@@ -2689,6 +2787,16 @@ var BaseSerializerContext = class {
2689
2787
  'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
2690
2788
  ) + "})"
2691
2789
  );
2790
+ case 5 /* AbortSignalConstructor */:
2791
+ return this.createFunction(
2792
+ ["a", "s"],
2793
+ "((s=(a=new AbortController).signal).a=a,s)"
2794
+ );
2795
+ case 6 /* AbortSignalAbort */:
2796
+ return this.createEffectfulFunction(
2797
+ ["s", "r"],
2798
+ "s.a.abort(r);delete s.a"
2799
+ );
2692
2800
  default:
2693
2801
  return "";
2694
2802
  }
@@ -2800,6 +2908,18 @@ var BaseSerializerContext = class {
2800
2908
  serializeStreamReturn(node) {
2801
2909
  return this.getRefParam(node.i) + ".return(" + this.serialize(node.f) + ")";
2802
2910
  }
2911
+ serializeAbortSignalSync(node) {
2912
+ return this.assignIndexedValue(
2913
+ node.i,
2914
+ "AbortSignal.abort(" + this.serialize(node.f) + ")"
2915
+ );
2916
+ }
2917
+ serializeAbortSignalConstructor(node) {
2918
+ return this.assignIndexedValue(node.i, this.getConstructor(node.f) + "()");
2919
+ }
2920
+ serializeAbortSignalAbort(node) {
2921
+ return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
2922
+ }
2803
2923
  serialize(node) {
2804
2924
  try {
2805
2925
  switch (node.t) {
@@ -2872,6 +2992,12 @@ var BaseSerializerContext = class {
2872
2992
  return this.serializeStreamThrow(node);
2873
2993
  case 34 /* StreamReturn */:
2874
2994
  return this.serializeStreamReturn(node);
2995
+ case 36 /* AbortSignalAbort */:
2996
+ return this.serializeAbortSignalAbort(node);
2997
+ case 35 /* AbortSignalConstructor */:
2998
+ return this.serializeAbortSignalConstructor(node);
2999
+ case 37 /* AbortSignalSync */:
3000
+ return this.serializeAbortSignalSync(node);
2875
3001
  default:
2876
3002
  throw new SerovalUnsupportedNodeError(node);
2877
3003
  }
@@ -3000,7 +3126,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3000
3126
  return createErrorNode(
3001
3127
  id,
3002
3128
  current,
3003
- options ? this.parseProperties(options) : void 0
3129
+ options ? this.parseProperties(options) : NIL
3004
3130
  );
3005
3131
  }
3006
3132
  parseAggregateError(id, current) {
@@ -3008,7 +3134,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3008
3134
  return createAggregateErrorNode(
3009
3135
  id,
3010
3136
  current,
3011
- options ? this.parseProperties(options) : void 0
3137
+ options ? this.parseProperties(options) : NIL
3012
3138
  );
3013
3139
  }
3014
3140
  parseMap(id, current) {
@@ -3055,7 +3181,29 @@ var BaseSyncParserContext = class extends BaseParserContext {
3055
3181
  parsePromise(id, _current) {
3056
3182
  return this.createPromiseConstructorNode(id);
3057
3183
  }
3058
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
3184
+ parseAbortSignalSync(id, current) {
3185
+ return createSerovalNode(
3186
+ 37 /* AbortSignalSync */,
3187
+ id,
3188
+ NIL,
3189
+ NIL,
3190
+ NIL,
3191
+ NIL,
3192
+ NIL,
3193
+ NIL,
3194
+ NIL,
3195
+ this.parse(current.reason),
3196
+ NIL,
3197
+ NIL
3198
+ );
3199
+ }
3200
+ parseAbortSignal(id, current) {
3201
+ if (current.aborted) {
3202
+ return this.parseAbortSignalSync(id, current);
3203
+ }
3204
+ return this.createAbortSignalConstructorNode(id);
3205
+ }
3206
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
3059
3207
  parseObject(id, current) {
3060
3208
  if (Array.isArray(current)) {
3061
3209
  return this.parseArray(id, current);
@@ -3128,6 +3276,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
3128
3276
  return this.parsePromise(id, current);
3129
3277
  }
3130
3278
  const currentFeatures = this.features;
3279
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
3280
+ return this.parseAbortSignal(id, current);
3281
+ }
3131
3282
  if (currentFeatures & 16 /* BigIntTypedArray */) {
3132
3283
  switch (currentClass) {
3133
3284
  case BigInt64Array:
@@ -3151,6 +3302,17 @@ var BaseSyncParserContext = class extends BaseParserContext {
3151
3302
  }
3152
3303
  throw new SerovalUnsupportedTypeError(current);
3153
3304
  }
3305
+ parseFunction(current) {
3306
+ const ref = this.getReference(current);
3307
+ if (ref.type !== 0 /* Fresh */) {
3308
+ return ref.value;
3309
+ }
3310
+ const plugin = this.parsePlugin(ref.value, current);
3311
+ if (plugin) {
3312
+ return plugin;
3313
+ }
3314
+ throw new SerovalUnsupportedTypeError(current);
3315
+ }
3154
3316
  parse(current) {
3155
3317
  try {
3156
3318
  switch (typeof current) {
@@ -3167,14 +3329,15 @@ var BaseSyncParserContext = class extends BaseParserContext {
3167
3329
  case "object": {
3168
3330
  if (current) {
3169
3331
  const ref = this.getReference(current);
3170
- return ref.type === 0 ? this.parseObject(ref.value, current) : ref.value;
3332
+ return ref.type === 0 /* Fresh */ ? this.parseObject(ref.value, current) : ref.value;
3171
3333
  }
3172
3334
  return NULL_NODE;
3173
3335
  }
3174
3336
  case "symbol":
3175
3337
  return this.parseWellKnownSymbol(current);
3176
- case "function":
3338
+ case "function": {
3177
3339
  return this.parseFunction(current);
3340
+ }
3178
3341
  default:
3179
3342
  throw new SerovalUnsupportedTypeError(current);
3180
3343
  }
@@ -3292,23 +3455,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3292
3455
  (data) => {
3293
3456
  const parsed = this.parseWithError(data);
3294
3457
  if (parsed) {
3295
- this.onParse({
3296
- t: 23 /* PromiseResolve */,
3297
- i: id,
3298
- s: void 0,
3299
- l: void 0,
3300
- c: void 0,
3301
- m: void 0,
3302
- p: void 0,
3303
- e: void 0,
3304
- a: [
3305
- this.parseSpecialReference(2 /* PromiseResolve */),
3306
- parsed
3307
- ],
3308
- f: void 0,
3309
- b: void 0,
3310
- o: void 0
3311
- });
3458
+ this.onParse(
3459
+ createSerovalNode(
3460
+ 23 /* PromiseResolve */,
3461
+ id,
3462
+ NIL,
3463
+ NIL,
3464
+ NIL,
3465
+ NIL,
3466
+ NIL,
3467
+ NIL,
3468
+ [
3469
+ this.parseSpecialReference(2 /* PromiseResolve */),
3470
+ parsed
3471
+ ],
3472
+ NIL,
3473
+ NIL,
3474
+ NIL
3475
+ )
3476
+ );
3312
3477
  }
3313
3478
  this.popPendingState();
3314
3479
  },
@@ -3316,23 +3481,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3316
3481
  if (this.alive) {
3317
3482
  const parsed = this.parseWithError(data);
3318
3483
  if (parsed) {
3319
- this.onParse({
3320
- t: 24 /* PromiseReject */,
3321
- i: id,
3322
- s: void 0,
3323
- l: void 0,
3324
- c: void 0,
3325
- m: void 0,
3326
- p: void 0,
3327
- e: void 0,
3328
- a: [
3329
- this.parseSpecialReference(3 /* PromiseReject */),
3330
- parsed
3331
- ],
3332
- f: void 0,
3333
- b: void 0,
3334
- o: void 0
3335
- });
3484
+ this.onParse(
3485
+ createSerovalNode(
3486
+ 24 /* PromiseReject */,
3487
+ id,
3488
+ NIL,
3489
+ NIL,
3490
+ NIL,
3491
+ NIL,
3492
+ NIL,
3493
+ NIL,
3494
+ [
3495
+ this.parseSpecialReference(3 /* PromiseReject */),
3496
+ parsed
3497
+ ],
3498
+ NIL,
3499
+ NIL,
3500
+ NIL
3501
+ )
3502
+ );
3336
3503
  }
3337
3504
  }
3338
3505
  this.popPendingState();
@@ -3357,7 +3524,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3357
3524
  }
3358
3525
  }
3359
3526
  }
3360
- return void 0;
3527
+ return NIL;
3361
3528
  }
3362
3529
  parseStream(id, current) {
3363
3530
  const result = createStreamConstructorNode(
@@ -3396,12 +3563,51 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3396
3563
  });
3397
3564
  return result;
3398
3565
  }
3566
+ handleAbortSignal(id, current) {
3567
+ if (this.alive) {
3568
+ const parsed = this.parseWithError(current.reason);
3569
+ if (parsed) {
3570
+ this.onParse(
3571
+ createSerovalNode(
3572
+ 36 /* AbortSignalAbort */,
3573
+ id,
3574
+ NIL,
3575
+ NIL,
3576
+ NIL,
3577
+ NIL,
3578
+ NIL,
3579
+ NIL,
3580
+ [
3581
+ this.parseSpecialReference(6 /* AbortSignalAbort */),
3582
+ parsed
3583
+ ],
3584
+ NIL,
3585
+ NIL,
3586
+ NIL
3587
+ )
3588
+ );
3589
+ }
3590
+ }
3591
+ this.popPendingState();
3592
+ }
3593
+ parseAbortSignal(id, current) {
3594
+ if (current.aborted) {
3595
+ return this.parseAbortSignalSync(id, current);
3596
+ }
3597
+ this.pushPendingState();
3598
+ current.addEventListener(
3599
+ "abort",
3600
+ this.handleAbortSignal.bind(this, id, current),
3601
+ { once: true }
3602
+ );
3603
+ return this.createAbortSignalConstructorNode(id);
3604
+ }
3399
3605
  parseWithError(current) {
3400
3606
  try {
3401
3607
  return this.parse(current);
3402
3608
  } catch (err) {
3403
3609
  this.onError(err);
3404
- return void 0;
3610
+ return NIL;
3405
3611
  }
3406
3612
  }
3407
3613
  /**
@@ -3527,9 +3733,7 @@ function crossSerializeStream(source, options) {
3527
3733
  onDone: options.onDone
3528
3734
  });
3529
3735
  ctx.start(source);
3530
- return () => {
3531
- ctx.destroy();
3532
- };
3736
+ return ctx.destroy.bind(ctx);
3533
3737
  }
3534
3738
  function toCrossJSONStream(source, options) {
3535
3739
  const plugins = resolvePlugins(options.plugins);
@@ -3542,9 +3746,7 @@ function toCrossJSONStream(source, options) {
3542
3746
  onDone: options.onDone
3543
3747
  });
3544
3748
  ctx.start(source);
3545
- return () => {
3546
- ctx.destroy();
3547
- };
3749
+ return ctx.destroy.bind(ctx);
3548
3750
  }
3549
3751
  function fromCrossJSON(source, options) {
3550
3752
  const plugins = resolvePlugins(options.plugins);
@@ -3643,6 +3845,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3643
3845
  serializePromiseReject(node) {
3644
3846
  throw new SerovalUnsupportedNodeError(node);
3645
3847
  }
3848
+ serializeAbortSignalAbort(node) {
3849
+ throw new SerovalUnsupportedNodeError(node);
3850
+ }
3646
3851
  serializeTop(tree) {
3647
3852
  const result = this.serialize(tree);
3648
3853
  if (tree.i != null && this.vars.length) {