seroval 1.1.0 → 1.2.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 (55) hide show
  1. package/dist/cjs/development/index.cjs +710 -508
  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 +710 -508
  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 +2 -0
  18. package/dist/types/core/context/parser/async.d.ts.map +1 -1
  19. package/dist/types/core/context/parser/stream.d.ts +2 -1
  20. package/dist/types/core/context/parser/stream.d.ts.map +1 -1
  21. package/dist/types/core/context/parser/sync.d.ts +3 -1
  22. package/dist/types/core/context/parser/sync.d.ts.map +1 -1
  23. package/dist/types/core/context/parser.d.ts +2 -1
  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/serializer.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 +13 -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 +61 -20
  45. package/src/core/context/parser/stream.ts +89 -37
  46. package/src/core/context/parser/sync.ts +44 -3
  47. package/src/core/context/parser.ts +106 -85
  48. package/src/core/context/serializer.ts +56 -10
  49. package/src/core/cross/serializer.ts +6 -2
  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 +9 -1
  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,21 @@ function resolvePlugins(plugins) {
241
242
  return void 0;
242
243
  }
243
244
 
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
+
244
260
  // src/core/constants.ts
245
261
  var SYMBOL_STRING = {
246
262
  [0 /* AsyncIterator */]: "Symbol.asyncIterator",
@@ -325,24 +341,43 @@ var ERROR_CONSTRUCTOR = {
325
341
  [5 /* TypeError */]: TypeError,
326
342
  [6 /* URIError */]: URIError
327
343
  };
344
+ var NIL = void 0;
328
345
 
329
- // src/core/literals.ts
330
- function createConstantNode(value) {
346
+ // src/core/node.ts
347
+ function createSerovalNode(t, i, s, l, c, m, p, e, a, f, b, o) {
331
348
  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
349
+ t,
350
+ i,
351
+ s,
352
+ l,
353
+ c,
354
+ m,
355
+ p,
356
+ e,
357
+ a,
358
+ f,
359
+ b,
360
+ o
344
361
  };
345
362
  }
363
+
364
+ // src/core/literals.ts
365
+ function createConstantNode(value) {
366
+ return createSerovalNode(
367
+ 2 /* Constant */,
368
+ NIL,
369
+ value,
370
+ NIL,
371
+ NIL,
372
+ NIL,
373
+ NIL,
374
+ NIL,
375
+ NIL,
376
+ NIL,
377
+ NIL,
378
+ NIL
379
+ );
380
+ }
346
381
  var TRUE_NODE = /* @__PURE__ */ createConstantNode(
347
382
  2 /* True */
348
383
  );
@@ -446,100 +481,100 @@ function createNumberNode(value) {
446
481
  if (Object.is(value, -0)) {
447
482
  return NEG_ZERO_NODE;
448
483
  }
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
- };
484
+ return createSerovalNode(
485
+ 0 /* Number */,
486
+ NIL,
487
+ value,
488
+ NIL,
489
+ NIL,
490
+ NIL,
491
+ NIL,
492
+ NIL,
493
+ NIL,
494
+ NIL,
495
+ NIL,
496
+ NIL
497
+ );
463
498
  }
464
499
  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
- };
500
+ return createSerovalNode(
501
+ 1 /* String */,
502
+ NIL,
503
+ serializeString(value),
504
+ NIL,
505
+ NIL,
506
+ NIL,
507
+ NIL,
508
+ NIL,
509
+ NIL,
510
+ NIL,
511
+ NIL,
512
+ NIL
513
+ );
479
514
  }
480
515
  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
- };
516
+ return createSerovalNode(
517
+ 3 /* BigInt */,
518
+ NIL,
519
+ "" + current,
520
+ NIL,
521
+ NIL,
522
+ NIL,
523
+ NIL,
524
+ NIL,
525
+ NIL,
526
+ NIL,
527
+ NIL,
528
+ NIL
529
+ );
495
530
  }
496
531
  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
- };
532
+ return createSerovalNode(
533
+ 4 /* IndexedValue */,
534
+ id,
535
+ NIL,
536
+ NIL,
537
+ NIL,
538
+ NIL,
539
+ NIL,
540
+ NIL,
541
+ NIL,
542
+ NIL,
543
+ NIL,
544
+ NIL
545
+ );
511
546
  }
512
547
  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
- };
548
+ return createSerovalNode(
549
+ 5 /* Date */,
550
+ id,
551
+ current.toISOString(),
552
+ NIL,
553
+ NIL,
554
+ NIL,
555
+ NIL,
556
+ NIL,
557
+ NIL,
558
+ NIL,
559
+ NIL,
560
+ NIL
561
+ );
527
562
  }
528
563
  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
- };
564
+ return createSerovalNode(
565
+ 6 /* RegExp */,
566
+ id,
567
+ NIL,
568
+ NIL,
569
+ serializeString(current.source),
570
+ current.flags,
571
+ NIL,
572
+ NIL,
573
+ NIL,
574
+ NIL,
575
+ NIL,
576
+ NIL
577
+ );
543
578
  }
544
579
  function createArrayBufferNode(id, current) {
545
580
  const bytes = new Uint8Array(current);
@@ -548,292 +583,292 @@ function createArrayBufferNode(id, current) {
548
583
  for (let i = 0; i < len; i++) {
549
584
  values[i] = bytes[i];
550
585
  }
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
- };
586
+ return createSerovalNode(
587
+ 19 /* ArrayBuffer */,
588
+ id,
589
+ values,
590
+ NIL,
591
+ NIL,
592
+ NIL,
593
+ NIL,
594
+ NIL,
595
+ NIL,
596
+ NIL,
597
+ NIL,
598
+ NIL
599
+ );
565
600
  }
566
601
  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
- };
602
+ return createSerovalNode(
603
+ 17 /* WKSymbol */,
604
+ id,
605
+ INV_SYMBOL_REF[current],
606
+ NIL,
607
+ NIL,
608
+ NIL,
609
+ NIL,
610
+ NIL,
611
+ NIL,
612
+ NIL,
613
+ NIL,
614
+ NIL
615
+ );
581
616
  }
582
617
  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
- };
618
+ return createSerovalNode(
619
+ 18 /* Reference */,
620
+ id,
621
+ serializeString(getReferenceID(ref)),
622
+ NIL,
623
+ NIL,
624
+ NIL,
625
+ NIL,
626
+ NIL,
627
+ NIL,
628
+ NIL,
629
+ NIL,
630
+ NIL
631
+ );
597
632
  }
598
633
  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
- };
634
+ return createSerovalNode(
635
+ 25 /* Plugin */,
636
+ id,
637
+ value,
638
+ NIL,
639
+ serializeString(tag),
640
+ NIL,
641
+ NIL,
642
+ NIL,
643
+ NIL,
644
+ NIL,
645
+ NIL,
646
+ NIL
647
+ );
613
648
  }
614
649
  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
- };
650
+ return createSerovalNode(
651
+ 9 /* Array */,
652
+ id,
653
+ NIL,
654
+ current.length,
655
+ NIL,
656
+ NIL,
657
+ NIL,
658
+ NIL,
659
+ parsedItems,
660
+ NIL,
661
+ NIL,
662
+ getObjectFlag(current)
663
+ );
629
664
  }
630
665
  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
- };
666
+ return createSerovalNode(
667
+ 21 /* Boxed */,
668
+ id,
669
+ NIL,
670
+ NIL,
671
+ NIL,
672
+ NIL,
673
+ NIL,
674
+ NIL,
675
+ NIL,
676
+ boxed,
677
+ NIL,
678
+ NIL
679
+ );
645
680
  }
646
681
  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
- };
682
+ return createSerovalNode(
683
+ 15 /* TypedArray */,
684
+ id,
685
+ NIL,
686
+ current.length,
687
+ current.constructor.name,
688
+ NIL,
689
+ NIL,
690
+ NIL,
691
+ NIL,
692
+ buffer,
693
+ current.byteOffset,
694
+ NIL
695
+ );
661
696
  }
662
697
  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
- };
698
+ return createSerovalNode(
699
+ 16 /* BigIntTypedArray */,
700
+ id,
701
+ NIL,
702
+ current.length,
703
+ current.constructor.name,
704
+ NIL,
705
+ NIL,
706
+ NIL,
707
+ NIL,
708
+ buffer,
709
+ current.byteOffset,
710
+ NIL
711
+ );
677
712
  }
678
713
  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
- };
714
+ return createSerovalNode(
715
+ 20 /* DataView */,
716
+ id,
717
+ NIL,
718
+ current.byteLength,
719
+ NIL,
720
+ NIL,
721
+ NIL,
722
+ NIL,
723
+ NIL,
724
+ buffer,
725
+ current.byteOffset,
726
+ NIL
727
+ );
693
728
  }
694
729
  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
- };
730
+ return createSerovalNode(
731
+ 13 /* Error */,
732
+ id,
733
+ getErrorConstructor(current),
734
+ NIL,
735
+ NIL,
736
+ serializeString(current.message),
737
+ options,
738
+ NIL,
739
+ NIL,
740
+ NIL,
741
+ NIL,
742
+ NIL
743
+ );
709
744
  }
710
745
  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
- };
746
+ return createSerovalNode(
747
+ 14 /* AggregateError */,
748
+ id,
749
+ getErrorConstructor(current),
750
+ NIL,
751
+ NIL,
752
+ serializeString(current.message),
753
+ options,
754
+ NIL,
755
+ NIL,
756
+ NIL,
757
+ NIL,
758
+ NIL
759
+ );
725
760
  }
726
761
  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
- };
762
+ return createSerovalNode(
763
+ 7 /* Set */,
764
+ id,
765
+ NIL,
766
+ size,
767
+ NIL,
768
+ NIL,
769
+ NIL,
770
+ NIL,
771
+ items,
772
+ NIL,
773
+ NIL,
774
+ NIL
775
+ );
741
776
  }
742
777
  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
- };
778
+ return createSerovalNode(
779
+ 28 /* IteratorFactoryInstance */,
780
+ NIL,
781
+ NIL,
782
+ NIL,
783
+ NIL,
784
+ NIL,
785
+ NIL,
786
+ NIL,
787
+ [factory, items],
788
+ NIL,
789
+ NIL,
790
+ NIL
791
+ );
757
792
  }
758
793
  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
- };
794
+ return createSerovalNode(
795
+ 30 /* AsyncIteratorFactoryInstance */,
796
+ NIL,
797
+ NIL,
798
+ NIL,
799
+ NIL,
800
+ NIL,
801
+ NIL,
802
+ NIL,
803
+ [factory, items],
804
+ NIL,
805
+ NIL,
806
+ NIL
807
+ );
773
808
  }
774
809
  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
- };
810
+ return createSerovalNode(
811
+ 31 /* StreamConstructor */,
812
+ id,
813
+ NIL,
814
+ NIL,
815
+ NIL,
816
+ NIL,
817
+ NIL,
818
+ NIL,
819
+ sequence,
820
+ factory,
821
+ NIL,
822
+ NIL
823
+ );
789
824
  }
790
825
  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
- };
826
+ return createSerovalNode(
827
+ 32 /* StreamNext */,
828
+ id,
829
+ NIL,
830
+ NIL,
831
+ NIL,
832
+ NIL,
833
+ NIL,
834
+ NIL,
835
+ NIL,
836
+ parsed,
837
+ NIL,
838
+ NIL
839
+ );
805
840
  }
806
841
  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
- };
842
+ return createSerovalNode(
843
+ 33 /* StreamThrow */,
844
+ id,
845
+ NIL,
846
+ NIL,
847
+ NIL,
848
+ NIL,
849
+ NIL,
850
+ NIL,
851
+ NIL,
852
+ parsed,
853
+ NIL,
854
+ NIL
855
+ );
821
856
  }
822
857
  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
- };
858
+ return createSerovalNode(
859
+ 34 /* StreamReturn */,
860
+ id,
861
+ NIL,
862
+ NIL,
863
+ NIL,
864
+ NIL,
865
+ NIL,
866
+ NIL,
867
+ NIL,
868
+ parsed,
869
+ NIL,
870
+ NIL
871
+ );
837
872
  }
838
873
 
839
874
  // src/core/errors.ts
@@ -937,7 +972,9 @@ var SPECIAL_REFS = {
937
972
  [1 /* PromiseConstructor */]: {},
938
973
  [2 /* PromiseResolve */]: {},
939
974
  [3 /* PromiseReject */]: {},
940
- [4 /* StreamConstructor */]: {}
975
+ [4 /* StreamConstructor */]: {},
976
+ [5 /* AbortSignalConstructor */]: {},
977
+ [6 /* AbortSignalAbort */]: {}
941
978
  };
942
979
 
943
980
  // src/core/utils/deferred.ts
@@ -1162,7 +1199,7 @@ function sequenceToIterator(sequence) {
1162
1199
  if (index > sequence.d) {
1163
1200
  return {
1164
1201
  done: true,
1165
- value: void 0
1202
+ value: NIL
1166
1203
  };
1167
1204
  }
1168
1205
  const currentIndex = index++;
@@ -1255,111 +1292,127 @@ var BaseParserContext = class {
1255
1292
  if (result.type === 1 /* Indexed */) {
1256
1293
  return result.value;
1257
1294
  }
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
- };
1295
+ return createSerovalNode(
1296
+ 26 /* SpecialReference */,
1297
+ result.value,
1298
+ ref,
1299
+ NIL,
1300
+ NIL,
1301
+ NIL,
1302
+ NIL,
1303
+ NIL,
1304
+ NIL,
1305
+ NIL,
1306
+ NIL,
1307
+ NIL
1308
+ );
1272
1309
  }
1273
1310
  parseIteratorFactory() {
1274
1311
  const result = this.getIndexedValue(ITERATOR);
1275
1312
  if (result.type === 1 /* Indexed */) {
1276
1313
  return result.value;
1277
1314
  }
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
- };
1315
+ return createSerovalNode(
1316
+ 27 /* IteratorFactory */,
1317
+ result.value,
1318
+ NIL,
1319
+ NIL,
1320
+ NIL,
1321
+ NIL,
1322
+ NIL,
1323
+ NIL,
1324
+ NIL,
1325
+ this.parseWellKnownSymbol(Symbol.iterator),
1326
+ NIL,
1327
+ NIL
1328
+ );
1292
1329
  }
1293
1330
  parseAsyncIteratorFactory() {
1294
1331
  const result = this.getIndexedValue(ASYNC_ITERATOR);
1295
1332
  if (result.type === 1 /* Indexed */) {
1296
1333
  return result.value;
1297
1334
  }
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: [
1335
+ return createSerovalNode(
1336
+ 29 /* AsyncIteratorFactory */,
1337
+ result.value,
1338
+ NIL,
1339
+ NIL,
1340
+ NIL,
1341
+ NIL,
1342
+ NIL,
1343
+ NIL,
1344
+ [
1308
1345
  this.parseSpecialReference(1 /* PromiseConstructor */),
1309
1346
  this.parseWellKnownSymbol(Symbol.asyncIterator)
1310
1347
  ],
1311
- f: void 0,
1312
- b: void 0,
1313
- o: void 0
1314
- };
1348
+ NIL,
1349
+ NIL,
1350
+ NIL
1351
+ );
1315
1352
  }
1316
1353
  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
- };
1354
+ return createSerovalNode(
1355
+ empty ? 11 /* NullConstructor */ : 10 /* Object */,
1356
+ id,
1357
+ NIL,
1358
+ NIL,
1359
+ NIL,
1360
+ NIL,
1361
+ record,
1362
+ NIL,
1363
+ NIL,
1364
+ NIL,
1365
+ NIL,
1366
+ getObjectFlag(current)
1367
+ );
1331
1368
  }
1332
1369
  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
- };
1370
+ return createSerovalNode(
1371
+ 8 /* Map */,
1372
+ id,
1373
+ NIL,
1374
+ NIL,
1375
+ NIL,
1376
+ NIL,
1377
+ NIL,
1378
+ { k, v, s },
1379
+ NIL,
1380
+ this.parseSpecialReference(0 /* MapSentinel */),
1381
+ NIL,
1382
+ NIL
1383
+ );
1347
1384
  }
1348
1385
  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
- };
1386
+ return createSerovalNode(
1387
+ 22 /* PromiseConstructor */,
1388
+ id,
1389
+ NIL,
1390
+ NIL,
1391
+ NIL,
1392
+ NIL,
1393
+ NIL,
1394
+ NIL,
1395
+ NIL,
1396
+ this.parseSpecialReference(1 /* PromiseConstructor */),
1397
+ NIL,
1398
+ NIL
1399
+ );
1400
+ }
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
+ );
1363
1416
  }
1364
1417
  };
1365
1418
 
@@ -1456,7 +1509,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1456
1509
  return createErrorNode(
1457
1510
  id,
1458
1511
  current,
1459
- options ? await this.parseProperties(options) : void 0
1512
+ options ? await this.parseProperties(options) : NIL
1460
1513
  );
1461
1514
  }
1462
1515
  async parseAggregateError(id, current) {
@@ -1464,7 +1517,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1464
1517
  return createAggregateErrorNode(
1465
1518
  id,
1466
1519
  current,
1467
- options ? await this.parseProperties(options) : void 0
1520
+ options ? await this.parseProperties(options) : NIL
1468
1521
  );
1469
1522
  }
1470
1523
  async parseMap(id, current) {
@@ -1485,20 +1538,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1485
1538
  }
1486
1539
  async parsePromise(id, current) {
1487
1540
  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
- };
1541
+ return createSerovalNode(
1542
+ 12 /* Promise */,
1543
+ id,
1544
+ status,
1545
+ NIL,
1546
+ NIL,
1547
+ NIL,
1548
+ NIL,
1549
+ NIL,
1550
+ NIL,
1551
+ await this.parse(result),
1552
+ NIL,
1553
+ NIL
1554
+ );
1502
1555
  }
1503
1556
  async parsePlugin(id, current) {
1504
1557
  const currentPlugins = this.plugins;
@@ -1516,7 +1569,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1516
1569
  }
1517
1570
  }
1518
1571
  }
1519
- return void 0;
1572
+ return NIL;
1520
1573
  }
1521
1574
  async parseStream(id, current) {
1522
1575
  return createStreamConstructorNode(
@@ -1569,7 +1622,29 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1569
1622
  })
1570
1623
  );
1571
1624
  }
1572
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
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
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
1573
1648
  async parseObject(id, current) {
1574
1649
  if (Array.isArray(current)) {
1575
1650
  return this.parseArray(id, current);
@@ -1594,7 +1669,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1594
1669
  current,
1595
1670
  false
1596
1671
  );
1597
- case void 0:
1672
+ case NIL:
1598
1673
  return this.parsePlainObject(
1599
1674
  id,
1600
1675
  current,
@@ -1642,6 +1717,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1642
1717
  return this.parsePromise(id, current);
1643
1718
  }
1644
1719
  const currentFeatures = this.features;
1720
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
1721
+ return this.parseAbortSignal(id, current);
1722
+ }
1645
1723
  if (currentFeatures & 16 /* BigIntTypedArray */) {
1646
1724
  switch (currentClass) {
1647
1725
  case BigInt64Array:
@@ -1964,6 +2042,21 @@ var BaseDeserializerContext = class {
1964
2042
  this.deserialize(node.a[1]);
1965
2043
  return void 0;
1966
2044
  }
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
+ }
1967
2060
  deserialize(node) {
1968
2061
  try {
1969
2062
  switch (node.t) {
@@ -2033,6 +2126,13 @@ var BaseDeserializerContext = class {
2033
2126
  return this.deserializeIteratorFactory(node);
2034
2127
  case 29 /* AsyncIteratorFactory */:
2035
2128
  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
+ // case SerovalNodeType.SpecialReference:
2036
2136
  default:
2037
2137
  throw new SerovalUnsupportedNodeError(node);
2038
2138
  }
@@ -2085,7 +2185,7 @@ function mergeAssignments(assignments) {
2085
2185
  current = {
2086
2186
  t: 0 /* Index */,
2087
2187
  s: item.s,
2088
- k: void 0,
2188
+ k: NIL,
2089
2189
  v: getAssignmentExpression(current)
2090
2190
  };
2091
2191
  } else if (item.t === 2 /* Set */ && item.s === prev.s) {
@@ -2099,7 +2199,7 @@ function mergeAssignments(assignments) {
2099
2199
  current = {
2100
2200
  t: 1 /* Add */,
2101
2201
  s: getAssignmentExpression(current),
2102
- k: void 0,
2202
+ k: NIL,
2103
2203
  v: item.v
2104
2204
  };
2105
2205
  } else if (item.t === 3 /* Delete */ && item.s === prev.s) {
@@ -2107,7 +2207,7 @@ function mergeAssignments(assignments) {
2107
2207
  t: 3 /* Delete */,
2108
2208
  s: getAssignmentExpression(current),
2109
2209
  k: item.k,
2110
- v: void 0
2210
+ v: NIL
2111
2211
  };
2112
2212
  } else {
2113
2213
  newAssignments.push(current);
@@ -2127,7 +2227,7 @@ function resolveAssignments(assignments) {
2127
2227
  }
2128
2228
  return result;
2129
2229
  }
2130
- return void 0;
2230
+ return NIL;
2131
2231
  }
2132
2232
  var NULL_CONSTRUCTOR = "Object.create(null)";
2133
2233
  var SET_CONSTRUCTOR = "new Set";
@@ -2138,7 +2238,7 @@ var OBJECT_FLAG_CONSTRUCTOR = {
2138
2238
  [3 /* Frozen */]: "Object.freeze",
2139
2239
  [2 /* Sealed */]: "Object.seal",
2140
2240
  [1 /* NonExtensible */]: "Object.preventExtensions",
2141
- [0 /* None */]: void 0
2241
+ [0 /* None */]: NIL
2142
2242
  };
2143
2243
  var BaseSerializerContext = class {
2144
2244
  constructor(options) {
@@ -2164,7 +2264,7 @@ var BaseSerializerContext = class {
2164
2264
  createFunction(parameters, body) {
2165
2265
  if (this.features & 2 /* ArrowFunction */) {
2166
2266
  const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
2167
- return joined + "=>" + body;
2267
+ return joined + "=>" + (body.startsWith("{") ? "(" + body + ")" : body);
2168
2268
  }
2169
2269
  return "function(" + parameters.join(",") + "){return " + body + "}";
2170
2270
  }
@@ -2224,7 +2324,7 @@ var BaseSerializerContext = class {
2224
2324
  this.assignments.push({
2225
2325
  t: 0 /* Index */,
2226
2326
  s: source,
2227
- k: void 0,
2327
+ k: NIL,
2228
2328
  v: value
2229
2329
  });
2230
2330
  }
@@ -2232,7 +2332,7 @@ var BaseSerializerContext = class {
2232
2332
  this.assignments.push({
2233
2333
  t: 1 /* Add */,
2234
2334
  s: this.getRefParam(ref),
2235
- k: void 0,
2335
+ k: NIL,
2236
2336
  v: value
2237
2337
  });
2238
2338
  }
@@ -2249,7 +2349,7 @@ var BaseSerializerContext = class {
2249
2349
  t: 3 /* Delete */,
2250
2350
  s: this.getRefParam(ref),
2251
2351
  k: key,
2252
- v: void 0
2352
+ v: NIL
2253
2353
  });
2254
2354
  }
2255
2355
  createArrayAssign(ref, index, value) {
@@ -2434,7 +2534,7 @@ var BaseSerializerContext = class {
2434
2534
  this.stack.pop();
2435
2535
  return resolveAssignments(mainAssignments);
2436
2536
  }
2437
- return void 0;
2537
+ return NIL;
2438
2538
  }
2439
2539
  serializeDictionary(node, init) {
2440
2540
  if (node.p) {
@@ -2689,6 +2789,16 @@ var BaseSerializerContext = class {
2689
2789
  'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
2690
2790
  ) + "})"
2691
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
+ );
2692
2802
  default:
2693
2803
  return "";
2694
2804
  }
@@ -2800,6 +2910,18 @@ var BaseSerializerContext = class {
2800
2910
  serializeStreamReturn(node) {
2801
2911
  return this.getRefParam(node.i) + ".return(" + this.serialize(node.f) + ")";
2802
2912
  }
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
+ }
2803
2925
  serialize(node) {
2804
2926
  try {
2805
2927
  switch (node.t) {
@@ -2872,6 +2994,12 @@ var BaseSerializerContext = class {
2872
2994
  return this.serializeStreamThrow(node);
2873
2995
  case 34 /* StreamReturn */:
2874
2996
  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);
2875
3003
  default:
2876
3004
  throw new SerovalUnsupportedNodeError(node);
2877
3005
  }
@@ -2903,9 +3031,12 @@ var CrossSerializerContext = class extends BaseSerializerContext {
2903
3031
  const patches = this.resolvePatches();
2904
3032
  const ref = this.getRefParam(id);
2905
3033
  const params = this.scopeId == null ? "" : GLOBAL_CONTEXT_REFERENCES;
2906
- const body = patches ? result + "," + patches + ref : result;
3034
+ const body = patches ? "(" + result + "," + patches + ref + ")" : result;
2907
3035
  if (params === "") {
2908
- return patches ? "(" + body + ")" : body;
3036
+ if (tree.t === 10 /* Object */ && !patches) {
3037
+ return "(" + body + ")";
3038
+ }
3039
+ return body;
2909
3040
  }
2910
3041
  const args = this.scopeId == null ? "()" : "(" + GLOBAL_CONTEXT_REFERENCES + '["' + serializeString(this.scopeId) + '"])';
2911
3042
  return "(" + this.createFunction([params], body) + ")" + args;
@@ -2997,7 +3128,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2997
3128
  return createErrorNode(
2998
3129
  id,
2999
3130
  current,
3000
- options ? this.parseProperties(options) : void 0
3131
+ options ? this.parseProperties(options) : NIL
3001
3132
  );
3002
3133
  }
3003
3134
  parseAggregateError(id, current) {
@@ -3005,7 +3136,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
3005
3136
  return createAggregateErrorNode(
3006
3137
  id,
3007
3138
  current,
3008
- options ? this.parseProperties(options) : void 0
3139
+ options ? this.parseProperties(options) : NIL
3009
3140
  );
3010
3141
  }
3011
3142
  parseMap(id, current) {
@@ -3052,7 +3183,29 @@ var BaseSyncParserContext = class extends BaseParserContext {
3052
3183
  parsePromise(id, _current) {
3053
3184
  return this.createPromiseConstructorNode(id);
3054
3185
  }
3055
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
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);
3207
+ }
3208
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
3056
3209
  parseObject(id, current) {
3057
3210
  if (Array.isArray(current)) {
3058
3211
  return this.parseArray(id, current);
@@ -3125,6 +3278,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
3125
3278
  return this.parsePromise(id, current);
3126
3279
  }
3127
3280
  const currentFeatures = this.features;
3281
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
3282
+ return this.parseAbortSignal(id, current);
3283
+ }
3128
3284
  if (currentFeatures & 16 /* BigIntTypedArray */) {
3129
3285
  switch (currentClass) {
3130
3286
  case BigInt64Array:
@@ -3289,23 +3445,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3289
3445
  (data) => {
3290
3446
  const parsed = this.parseWithError(data);
3291
3447
  if (parsed) {
3292
- this.onParse({
3293
- t: 23 /* PromiseResolve */,
3294
- i: id,
3295
- s: void 0,
3296
- l: void 0,
3297
- c: void 0,
3298
- m: void 0,
3299
- p: void 0,
3300
- e: void 0,
3301
- a: [
3302
- this.parseSpecialReference(2 /* PromiseResolve */),
3303
- parsed
3304
- ],
3305
- f: void 0,
3306
- b: void 0,
3307
- o: void 0
3308
- });
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
+ );
3309
3467
  }
3310
3468
  this.popPendingState();
3311
3469
  },
@@ -3313,23 +3471,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3313
3471
  if (this.alive) {
3314
3472
  const parsed = this.parseWithError(data);
3315
3473
  if (parsed) {
3316
- this.onParse({
3317
- t: 24 /* PromiseReject */,
3318
- i: id,
3319
- s: void 0,
3320
- l: void 0,
3321
- c: void 0,
3322
- m: void 0,
3323
- p: void 0,
3324
- e: void 0,
3325
- a: [
3326
- this.parseSpecialReference(3 /* PromiseReject */),
3327
- parsed
3328
- ],
3329
- f: void 0,
3330
- b: void 0,
3331
- o: void 0
3332
- });
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
+ );
3333
3493
  }
3334
3494
  }
3335
3495
  this.popPendingState();
@@ -3354,7 +3514,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3354
3514
  }
3355
3515
  }
3356
3516
  }
3357
- return void 0;
3517
+ return NIL;
3358
3518
  }
3359
3519
  parseStream(id, current) {
3360
3520
  const result = createStreamConstructorNode(
@@ -3393,12 +3553,50 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3393
3553
  });
3394
3554
  return result;
3395
3555
  }
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
+ }
3396
3594
  parseWithError(current) {
3397
3595
  try {
3398
3596
  return this.parse(current);
3399
3597
  } catch (err) {
3400
3598
  this.onError(err);
3401
- return void 0;
3599
+ return NIL;
3402
3600
  }
3403
3601
  }
3404
3602
  /**
@@ -3640,6 +3838,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3640
3838
  serializePromiseReject(node) {
3641
3839
  throw new SerovalUnsupportedNodeError(node);
3642
3840
  }
3841
+ serializeAbortSignalAbort(node) {
3842
+ throw new SerovalUnsupportedNodeError(node);
3843
+ }
3643
3844
  serializeTop(tree) {
3644
3845
  const result = this.serialize(tree);
3645
3846
  if (tree.i != null && this.vars.length) {
@@ -3651,8 +3852,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3651
3852
  if (!result.startsWith(index + "=")) {
3652
3853
  body = index + "=" + body;
3653
3854
  }
3855
+ body = "(" + body + ")";
3654
3856
  }
3655
- return "(" + this.createFunction(this.vars, "(" + body + ")") + ")()";
3857
+ return "(" + this.createFunction(this.vars, body) + ")()";
3656
3858
  }
3657
3859
  if (tree.t === 10 /* Object */) {
3658
3860
  return "(" + result + ")";