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
@@ -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,21 @@ function resolvePlugins(plugins) {
183
184
  return void 0;
184
185
  }
185
186
 
187
+ // src/core/abort-signal.ts
188
+ function abortSignalToPromise(signal) {
189
+ return new Promise((resolve) => {
190
+ signal.addEventListener(
191
+ "abort",
192
+ () => {
193
+ resolve(signal.reason);
194
+ },
195
+ {
196
+ once: true
197
+ }
198
+ );
199
+ });
200
+ }
201
+
186
202
  // src/core/constants.ts
187
203
  var SYMBOL_STRING = {
188
204
  [0 /* AsyncIterator */]: "Symbol.asyncIterator",
@@ -267,24 +283,43 @@ var ERROR_CONSTRUCTOR = {
267
283
  [5 /* TypeError */]: TypeError,
268
284
  [6 /* URIError */]: URIError
269
285
  };
286
+ var NIL = void 0;
270
287
 
271
- // src/core/literals.ts
272
- function createConstantNode(value) {
288
+ // src/core/node.ts
289
+ function createSerovalNode(t, i, s, l, c, m, p, e, a, f, b, o) {
273
290
  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
291
+ t,
292
+ i,
293
+ s,
294
+ l,
295
+ c,
296
+ m,
297
+ p,
298
+ e,
299
+ a,
300
+ f,
301
+ b,
302
+ o
286
303
  };
287
304
  }
305
+
306
+ // src/core/literals.ts
307
+ function createConstantNode(value) {
308
+ return createSerovalNode(
309
+ 2 /* Constant */,
310
+ NIL,
311
+ value,
312
+ NIL,
313
+ NIL,
314
+ NIL,
315
+ NIL,
316
+ NIL,
317
+ NIL,
318
+ NIL,
319
+ NIL,
320
+ NIL
321
+ );
322
+ }
288
323
  var TRUE_NODE = /* @__PURE__ */ createConstantNode(
289
324
  2 /* True */
290
325
  );
@@ -388,100 +423,100 @@ function createNumberNode(value) {
388
423
  if (Object.is(value, -0)) {
389
424
  return NEG_ZERO_NODE;
390
425
  }
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
- };
426
+ return createSerovalNode(
427
+ 0 /* Number */,
428
+ NIL,
429
+ value,
430
+ NIL,
431
+ NIL,
432
+ NIL,
433
+ NIL,
434
+ NIL,
435
+ NIL,
436
+ NIL,
437
+ NIL,
438
+ NIL
439
+ );
405
440
  }
406
441
  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
- };
442
+ return createSerovalNode(
443
+ 1 /* String */,
444
+ NIL,
445
+ serializeString(value),
446
+ NIL,
447
+ NIL,
448
+ NIL,
449
+ NIL,
450
+ NIL,
451
+ NIL,
452
+ NIL,
453
+ NIL,
454
+ NIL
455
+ );
421
456
  }
422
457
  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
- };
458
+ return createSerovalNode(
459
+ 3 /* BigInt */,
460
+ NIL,
461
+ "" + current,
462
+ NIL,
463
+ NIL,
464
+ NIL,
465
+ NIL,
466
+ NIL,
467
+ NIL,
468
+ NIL,
469
+ NIL,
470
+ NIL
471
+ );
437
472
  }
438
473
  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
- };
474
+ return createSerovalNode(
475
+ 4 /* IndexedValue */,
476
+ id,
477
+ NIL,
478
+ NIL,
479
+ NIL,
480
+ NIL,
481
+ NIL,
482
+ NIL,
483
+ NIL,
484
+ NIL,
485
+ NIL,
486
+ NIL
487
+ );
453
488
  }
454
489
  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
- };
490
+ return createSerovalNode(
491
+ 5 /* Date */,
492
+ id,
493
+ current.toISOString(),
494
+ NIL,
495
+ NIL,
496
+ NIL,
497
+ NIL,
498
+ NIL,
499
+ NIL,
500
+ NIL,
501
+ NIL,
502
+ NIL
503
+ );
469
504
  }
470
505
  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
- };
506
+ return createSerovalNode(
507
+ 6 /* RegExp */,
508
+ id,
509
+ NIL,
510
+ NIL,
511
+ serializeString(current.source),
512
+ current.flags,
513
+ NIL,
514
+ NIL,
515
+ NIL,
516
+ NIL,
517
+ NIL,
518
+ NIL
519
+ );
485
520
  }
486
521
  function createArrayBufferNode(id, current) {
487
522
  const bytes = new Uint8Array(current);
@@ -490,292 +525,292 @@ function createArrayBufferNode(id, current) {
490
525
  for (let i = 0; i < len; i++) {
491
526
  values[i] = bytes[i];
492
527
  }
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
- };
528
+ return createSerovalNode(
529
+ 19 /* ArrayBuffer */,
530
+ id,
531
+ values,
532
+ NIL,
533
+ NIL,
534
+ NIL,
535
+ NIL,
536
+ NIL,
537
+ NIL,
538
+ NIL,
539
+ NIL,
540
+ NIL
541
+ );
507
542
  }
508
543
  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
- };
544
+ return createSerovalNode(
545
+ 17 /* WKSymbol */,
546
+ id,
547
+ INV_SYMBOL_REF[current],
548
+ NIL,
549
+ NIL,
550
+ NIL,
551
+ NIL,
552
+ NIL,
553
+ NIL,
554
+ NIL,
555
+ NIL,
556
+ NIL
557
+ );
523
558
  }
524
559
  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
- };
560
+ return createSerovalNode(
561
+ 18 /* Reference */,
562
+ id,
563
+ serializeString(getReferenceID(ref)),
564
+ NIL,
565
+ NIL,
566
+ NIL,
567
+ NIL,
568
+ NIL,
569
+ NIL,
570
+ NIL,
571
+ NIL,
572
+ NIL
573
+ );
539
574
  }
540
575
  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
- };
576
+ return createSerovalNode(
577
+ 25 /* Plugin */,
578
+ id,
579
+ value,
580
+ NIL,
581
+ serializeString(tag),
582
+ NIL,
583
+ NIL,
584
+ NIL,
585
+ NIL,
586
+ NIL,
587
+ NIL,
588
+ NIL
589
+ );
555
590
  }
556
591
  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
- };
592
+ return createSerovalNode(
593
+ 9 /* Array */,
594
+ id,
595
+ NIL,
596
+ current.length,
597
+ NIL,
598
+ NIL,
599
+ NIL,
600
+ NIL,
601
+ parsedItems,
602
+ NIL,
603
+ NIL,
604
+ getObjectFlag(current)
605
+ );
571
606
  }
572
607
  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
- };
608
+ return createSerovalNode(
609
+ 21 /* Boxed */,
610
+ id,
611
+ NIL,
612
+ NIL,
613
+ NIL,
614
+ NIL,
615
+ NIL,
616
+ NIL,
617
+ NIL,
618
+ boxed,
619
+ NIL,
620
+ NIL
621
+ );
587
622
  }
588
623
  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
- };
624
+ return createSerovalNode(
625
+ 15 /* TypedArray */,
626
+ id,
627
+ NIL,
628
+ current.length,
629
+ current.constructor.name,
630
+ NIL,
631
+ NIL,
632
+ NIL,
633
+ NIL,
634
+ buffer,
635
+ current.byteOffset,
636
+ NIL
637
+ );
603
638
  }
604
639
  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
- };
640
+ return createSerovalNode(
641
+ 16 /* BigIntTypedArray */,
642
+ id,
643
+ NIL,
644
+ current.length,
645
+ current.constructor.name,
646
+ NIL,
647
+ NIL,
648
+ NIL,
649
+ NIL,
650
+ buffer,
651
+ current.byteOffset,
652
+ NIL
653
+ );
619
654
  }
620
655
  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
- };
656
+ return createSerovalNode(
657
+ 20 /* DataView */,
658
+ id,
659
+ NIL,
660
+ current.byteLength,
661
+ NIL,
662
+ NIL,
663
+ NIL,
664
+ NIL,
665
+ NIL,
666
+ buffer,
667
+ current.byteOffset,
668
+ NIL
669
+ );
635
670
  }
636
671
  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
- };
672
+ return createSerovalNode(
673
+ 13 /* Error */,
674
+ id,
675
+ getErrorConstructor(current),
676
+ NIL,
677
+ NIL,
678
+ serializeString(current.message),
679
+ options,
680
+ NIL,
681
+ NIL,
682
+ NIL,
683
+ NIL,
684
+ NIL
685
+ );
651
686
  }
652
687
  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
- };
688
+ return createSerovalNode(
689
+ 14 /* AggregateError */,
690
+ id,
691
+ getErrorConstructor(current),
692
+ NIL,
693
+ NIL,
694
+ serializeString(current.message),
695
+ options,
696
+ NIL,
697
+ NIL,
698
+ NIL,
699
+ NIL,
700
+ NIL
701
+ );
667
702
  }
668
703
  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
- };
704
+ return createSerovalNode(
705
+ 7 /* Set */,
706
+ id,
707
+ NIL,
708
+ size,
709
+ NIL,
710
+ NIL,
711
+ NIL,
712
+ NIL,
713
+ items,
714
+ NIL,
715
+ NIL,
716
+ NIL
717
+ );
683
718
  }
684
719
  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
- };
720
+ return createSerovalNode(
721
+ 28 /* IteratorFactoryInstance */,
722
+ NIL,
723
+ NIL,
724
+ NIL,
725
+ NIL,
726
+ NIL,
727
+ NIL,
728
+ NIL,
729
+ [factory, items],
730
+ NIL,
731
+ NIL,
732
+ NIL
733
+ );
699
734
  }
700
735
  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
- };
736
+ return createSerovalNode(
737
+ 30 /* AsyncIteratorFactoryInstance */,
738
+ NIL,
739
+ NIL,
740
+ NIL,
741
+ NIL,
742
+ NIL,
743
+ NIL,
744
+ NIL,
745
+ [factory, items],
746
+ NIL,
747
+ NIL,
748
+ NIL
749
+ );
715
750
  }
716
751
  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
- };
752
+ return createSerovalNode(
753
+ 31 /* StreamConstructor */,
754
+ id,
755
+ NIL,
756
+ NIL,
757
+ NIL,
758
+ NIL,
759
+ NIL,
760
+ NIL,
761
+ sequence,
762
+ factory,
763
+ NIL,
764
+ NIL
765
+ );
731
766
  }
732
767
  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
- };
768
+ return createSerovalNode(
769
+ 32 /* StreamNext */,
770
+ id,
771
+ NIL,
772
+ NIL,
773
+ NIL,
774
+ NIL,
775
+ NIL,
776
+ NIL,
777
+ NIL,
778
+ parsed,
779
+ NIL,
780
+ NIL
781
+ );
747
782
  }
748
783
  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
- };
784
+ return createSerovalNode(
785
+ 33 /* StreamThrow */,
786
+ id,
787
+ NIL,
788
+ NIL,
789
+ NIL,
790
+ NIL,
791
+ NIL,
792
+ NIL,
793
+ NIL,
794
+ parsed,
795
+ NIL,
796
+ NIL
797
+ );
763
798
  }
764
799
  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
- };
800
+ return createSerovalNode(
801
+ 34 /* StreamReturn */,
802
+ id,
803
+ NIL,
804
+ NIL,
805
+ NIL,
806
+ NIL,
807
+ NIL,
808
+ NIL,
809
+ NIL,
810
+ parsed,
811
+ NIL,
812
+ NIL
813
+ );
779
814
  }
780
815
 
781
816
  // src/core/errors.ts
@@ -879,7 +914,9 @@ var SPECIAL_REFS = {
879
914
  [1 /* PromiseConstructor */]: {},
880
915
  [2 /* PromiseResolve */]: {},
881
916
  [3 /* PromiseReject */]: {},
882
- [4 /* StreamConstructor */]: {}
917
+ [4 /* StreamConstructor */]: {},
918
+ [5 /* AbortSignalConstructor */]: {},
919
+ [6 /* AbortSignalAbort */]: {}
883
920
  };
884
921
 
885
922
  // src/core/utils/deferred.ts
@@ -1104,7 +1141,7 @@ function sequenceToIterator(sequence) {
1104
1141
  if (index > sequence.d) {
1105
1142
  return {
1106
1143
  done: true,
1107
- value: void 0
1144
+ value: NIL
1108
1145
  };
1109
1146
  }
1110
1147
  const currentIndex = index++;
@@ -1197,111 +1234,127 @@ var BaseParserContext = class {
1197
1234
  if (result.type === 1 /* Indexed */) {
1198
1235
  return result.value;
1199
1236
  }
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
- };
1237
+ return createSerovalNode(
1238
+ 26 /* SpecialReference */,
1239
+ result.value,
1240
+ ref,
1241
+ NIL,
1242
+ NIL,
1243
+ NIL,
1244
+ NIL,
1245
+ NIL,
1246
+ NIL,
1247
+ NIL,
1248
+ NIL,
1249
+ NIL
1250
+ );
1214
1251
  }
1215
1252
  parseIteratorFactory() {
1216
1253
  const result = this.getIndexedValue(ITERATOR);
1217
1254
  if (result.type === 1 /* Indexed */) {
1218
1255
  return result.value;
1219
1256
  }
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
- };
1257
+ return createSerovalNode(
1258
+ 27 /* IteratorFactory */,
1259
+ result.value,
1260
+ NIL,
1261
+ NIL,
1262
+ NIL,
1263
+ NIL,
1264
+ NIL,
1265
+ NIL,
1266
+ NIL,
1267
+ this.parseWellKnownSymbol(Symbol.iterator),
1268
+ NIL,
1269
+ NIL
1270
+ );
1234
1271
  }
1235
1272
  parseAsyncIteratorFactory() {
1236
1273
  const result = this.getIndexedValue(ASYNC_ITERATOR);
1237
1274
  if (result.type === 1 /* Indexed */) {
1238
1275
  return result.value;
1239
1276
  }
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: [
1277
+ return createSerovalNode(
1278
+ 29 /* AsyncIteratorFactory */,
1279
+ result.value,
1280
+ NIL,
1281
+ NIL,
1282
+ NIL,
1283
+ NIL,
1284
+ NIL,
1285
+ NIL,
1286
+ [
1250
1287
  this.parseSpecialReference(1 /* PromiseConstructor */),
1251
1288
  this.parseWellKnownSymbol(Symbol.asyncIterator)
1252
1289
  ],
1253
- f: void 0,
1254
- b: void 0,
1255
- o: void 0
1256
- };
1290
+ NIL,
1291
+ NIL,
1292
+ NIL
1293
+ );
1257
1294
  }
1258
1295
  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
- };
1296
+ return createSerovalNode(
1297
+ empty ? 11 /* NullConstructor */ : 10 /* Object */,
1298
+ id,
1299
+ NIL,
1300
+ NIL,
1301
+ NIL,
1302
+ NIL,
1303
+ record,
1304
+ NIL,
1305
+ NIL,
1306
+ NIL,
1307
+ NIL,
1308
+ getObjectFlag(current)
1309
+ );
1273
1310
  }
1274
1311
  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
- };
1312
+ return createSerovalNode(
1313
+ 8 /* Map */,
1314
+ id,
1315
+ NIL,
1316
+ NIL,
1317
+ NIL,
1318
+ NIL,
1319
+ NIL,
1320
+ { k, v, s },
1321
+ NIL,
1322
+ this.parseSpecialReference(0 /* MapSentinel */),
1323
+ NIL,
1324
+ NIL
1325
+ );
1289
1326
  }
1290
1327
  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
- };
1328
+ return createSerovalNode(
1329
+ 22 /* PromiseConstructor */,
1330
+ id,
1331
+ NIL,
1332
+ NIL,
1333
+ NIL,
1334
+ NIL,
1335
+ NIL,
1336
+ NIL,
1337
+ NIL,
1338
+ this.parseSpecialReference(1 /* PromiseConstructor */),
1339
+ NIL,
1340
+ NIL
1341
+ );
1342
+ }
1343
+ createAbortSignalConstructorNode(id) {
1344
+ return createSerovalNode(
1345
+ 35 /* AbortSignalConstructor */,
1346
+ id,
1347
+ NIL,
1348
+ NIL,
1349
+ NIL,
1350
+ NIL,
1351
+ NIL,
1352
+ NIL,
1353
+ NIL,
1354
+ this.parseSpecialReference(5 /* AbortSignalConstructor */),
1355
+ NIL,
1356
+ NIL
1357
+ );
1305
1358
  }
1306
1359
  };
1307
1360
 
@@ -1398,7 +1451,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1398
1451
  return createErrorNode(
1399
1452
  id,
1400
1453
  current,
1401
- options ? await this.parseProperties(options) : void 0
1454
+ options ? await this.parseProperties(options) : NIL
1402
1455
  );
1403
1456
  }
1404
1457
  async parseAggregateError(id, current) {
@@ -1406,7 +1459,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1406
1459
  return createAggregateErrorNode(
1407
1460
  id,
1408
1461
  current,
1409
- options ? await this.parseProperties(options) : void 0
1462
+ options ? await this.parseProperties(options) : NIL
1410
1463
  );
1411
1464
  }
1412
1465
  async parseMap(id, current) {
@@ -1427,20 +1480,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1427
1480
  }
1428
1481
  async parsePromise(id, current) {
1429
1482
  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
- };
1483
+ return createSerovalNode(
1484
+ 12 /* Promise */,
1485
+ id,
1486
+ status,
1487
+ NIL,
1488
+ NIL,
1489
+ NIL,
1490
+ NIL,
1491
+ NIL,
1492
+ NIL,
1493
+ await this.parse(result),
1494
+ NIL,
1495
+ NIL
1496
+ );
1444
1497
  }
1445
1498
  async parsePlugin(id, current) {
1446
1499
  const currentPlugins = this.plugins;
@@ -1458,7 +1511,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1458
1511
  }
1459
1512
  }
1460
1513
  }
1461
- return void 0;
1514
+ return NIL;
1462
1515
  }
1463
1516
  async parseStream(id, current) {
1464
1517
  return createStreamConstructorNode(
@@ -1511,7 +1564,29 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1511
1564
  })
1512
1565
  );
1513
1566
  }
1514
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
1567
+ async parseAbortSignalSync(id, current) {
1568
+ return createSerovalNode(
1569
+ 37 /* AbortSignalSync */,
1570
+ id,
1571
+ NIL,
1572
+ NIL,
1573
+ NIL,
1574
+ NIL,
1575
+ NIL,
1576
+ NIL,
1577
+ NIL,
1578
+ await this.parse(current.reason),
1579
+ NIL,
1580
+ NIL
1581
+ );
1582
+ }
1583
+ async parseAbortSignal(id, current) {
1584
+ if (!current.aborted) {
1585
+ await abortSignalToPromise(current);
1586
+ }
1587
+ return this.parseAbortSignalSync(id, current);
1588
+ }
1589
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
1515
1590
  async parseObject(id, current) {
1516
1591
  if (Array.isArray(current)) {
1517
1592
  return this.parseArray(id, current);
@@ -1536,7 +1611,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1536
1611
  current,
1537
1612
  false
1538
1613
  );
1539
- case void 0:
1614
+ case NIL:
1540
1615
  return this.parsePlainObject(
1541
1616
  id,
1542
1617
  current,
@@ -1584,6 +1659,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
1584
1659
  return this.parsePromise(id, current);
1585
1660
  }
1586
1661
  const currentFeatures = this.features;
1662
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
1663
+ return this.parseAbortSignal(id, current);
1664
+ }
1587
1665
  if (currentFeatures & 16 /* BigIntTypedArray */) {
1588
1666
  switch (currentClass) {
1589
1667
  case BigInt64Array:
@@ -1906,6 +1984,21 @@ var BaseDeserializerContext = class {
1906
1984
  this.deserialize(node.a[1]);
1907
1985
  return void 0;
1908
1986
  }
1987
+ deserializeAbortSignalConstructor(node) {
1988
+ return this.assignIndexedValue(node.i, new AbortController()).signal;
1989
+ }
1990
+ deserializeAbortSignalAbort(node) {
1991
+ const controller = this.refs.get(node.i);
1992
+ assert(controller, new SerovalMissingInstanceError("AbortSignal"));
1993
+ controller.abort(this.deserialize(node.a[1]));
1994
+ return void 0;
1995
+ }
1996
+ deserializeAbortSignalSync(node) {
1997
+ return this.assignIndexedValue(
1998
+ node.i,
1999
+ AbortSignal.abort(this.deserialize(node.f))
2000
+ );
2001
+ }
1909
2002
  deserialize(node) {
1910
2003
  try {
1911
2004
  switch (node.t) {
@@ -1975,6 +2068,13 @@ var BaseDeserializerContext = class {
1975
2068
  return this.deserializeIteratorFactory(node);
1976
2069
  case 29 /* AsyncIteratorFactory */:
1977
2070
  return this.deserializeAsyncIteratorFactory(node);
2071
+ case 36 /* AbortSignalAbort */:
2072
+ return this.deserializeAbortSignalAbort(node);
2073
+ case 35 /* AbortSignalConstructor */:
2074
+ return this.deserializeAbortSignalConstructor(node);
2075
+ case 37 /* AbortSignalSync */:
2076
+ return this.deserializeAbortSignalSync(node);
2077
+ // case SerovalNodeType.SpecialReference:
1978
2078
  default:
1979
2079
  throw new SerovalUnsupportedNodeError(node);
1980
2080
  }
@@ -2027,7 +2127,7 @@ function mergeAssignments(assignments) {
2027
2127
  current = {
2028
2128
  t: 0 /* Index */,
2029
2129
  s: item.s,
2030
- k: void 0,
2130
+ k: NIL,
2031
2131
  v: getAssignmentExpression(current)
2032
2132
  };
2033
2133
  } else if (item.t === 2 /* Set */ && item.s === prev.s) {
@@ -2041,7 +2141,7 @@ function mergeAssignments(assignments) {
2041
2141
  current = {
2042
2142
  t: 1 /* Add */,
2043
2143
  s: getAssignmentExpression(current),
2044
- k: void 0,
2144
+ k: NIL,
2045
2145
  v: item.v
2046
2146
  };
2047
2147
  } else if (item.t === 3 /* Delete */ && item.s === prev.s) {
@@ -2049,7 +2149,7 @@ function mergeAssignments(assignments) {
2049
2149
  t: 3 /* Delete */,
2050
2150
  s: getAssignmentExpression(current),
2051
2151
  k: item.k,
2052
- v: void 0
2152
+ v: NIL
2053
2153
  };
2054
2154
  } else {
2055
2155
  newAssignments.push(current);
@@ -2069,7 +2169,7 @@ function resolveAssignments(assignments) {
2069
2169
  }
2070
2170
  return result;
2071
2171
  }
2072
- return void 0;
2172
+ return NIL;
2073
2173
  }
2074
2174
  var NULL_CONSTRUCTOR = "Object.create(null)";
2075
2175
  var SET_CONSTRUCTOR = "new Set";
@@ -2080,7 +2180,7 @@ var OBJECT_FLAG_CONSTRUCTOR = {
2080
2180
  [3 /* Frozen */]: "Object.freeze",
2081
2181
  [2 /* Sealed */]: "Object.seal",
2082
2182
  [1 /* NonExtensible */]: "Object.preventExtensions",
2083
- [0 /* None */]: void 0
2183
+ [0 /* None */]: NIL
2084
2184
  };
2085
2185
  var BaseSerializerContext = class {
2086
2186
  constructor(options) {
@@ -2106,7 +2206,7 @@ var BaseSerializerContext = class {
2106
2206
  createFunction(parameters, body) {
2107
2207
  if (this.features & 2 /* ArrowFunction */) {
2108
2208
  const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
2109
- return joined + "=>" + body;
2209
+ return joined + "=>" + (body.startsWith("{") ? "(" + body + ")" : body);
2110
2210
  }
2111
2211
  return "function(" + parameters.join(",") + "){return " + body + "}";
2112
2212
  }
@@ -2166,7 +2266,7 @@ var BaseSerializerContext = class {
2166
2266
  this.assignments.push({
2167
2267
  t: 0 /* Index */,
2168
2268
  s: source,
2169
- k: void 0,
2269
+ k: NIL,
2170
2270
  v: value
2171
2271
  });
2172
2272
  }
@@ -2174,7 +2274,7 @@ var BaseSerializerContext = class {
2174
2274
  this.assignments.push({
2175
2275
  t: 1 /* Add */,
2176
2276
  s: this.getRefParam(ref),
2177
- k: void 0,
2277
+ k: NIL,
2178
2278
  v: value
2179
2279
  });
2180
2280
  }
@@ -2191,7 +2291,7 @@ var BaseSerializerContext = class {
2191
2291
  t: 3 /* Delete */,
2192
2292
  s: this.getRefParam(ref),
2193
2293
  k: key,
2194
- v: void 0
2294
+ v: NIL
2195
2295
  });
2196
2296
  }
2197
2297
  createArrayAssign(ref, index, value) {
@@ -2376,7 +2476,7 @@ var BaseSerializerContext = class {
2376
2476
  this.stack.pop();
2377
2477
  return resolveAssignments(mainAssignments);
2378
2478
  }
2379
- return void 0;
2479
+ return NIL;
2380
2480
  }
2381
2481
  serializeDictionary(node, init) {
2382
2482
  if (node.p) {
@@ -2631,6 +2731,16 @@ var BaseSerializerContext = class {
2631
2731
  'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
2632
2732
  ) + "})"
2633
2733
  );
2734
+ case 5 /* AbortSignalConstructor */:
2735
+ return this.createFunction(
2736
+ ["a", "s"],
2737
+ "((s=(a=new AbortController).signal).a=a,s)"
2738
+ );
2739
+ case 6 /* AbortSignalAbort */:
2740
+ return this.createEffectfulFunction(
2741
+ ["s", "r"],
2742
+ "s.a.abort(r);delete s.a"
2743
+ );
2634
2744
  default:
2635
2745
  return "";
2636
2746
  }
@@ -2742,6 +2852,18 @@ var BaseSerializerContext = class {
2742
2852
  serializeStreamReturn(node) {
2743
2853
  return this.getRefParam(node.i) + ".return(" + this.serialize(node.f) + ")";
2744
2854
  }
2855
+ serializeAbortSignalSync(node) {
2856
+ return this.assignIndexedValue(
2857
+ node.i,
2858
+ "AbortSignal.abort(" + this.serialize(node.f) + ")"
2859
+ );
2860
+ }
2861
+ serializeAbortSignalConstructor(node) {
2862
+ return this.assignIndexedValue(node.i, this.getConstructor(node.f) + "()");
2863
+ }
2864
+ serializeAbortSignalAbort(node) {
2865
+ return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
2866
+ }
2745
2867
  serialize(node) {
2746
2868
  try {
2747
2869
  switch (node.t) {
@@ -2814,6 +2936,12 @@ var BaseSerializerContext = class {
2814
2936
  return this.serializeStreamThrow(node);
2815
2937
  case 34 /* StreamReturn */:
2816
2938
  return this.serializeStreamReturn(node);
2939
+ case 36 /* AbortSignalAbort */:
2940
+ return this.serializeAbortSignalAbort(node);
2941
+ case 35 /* AbortSignalConstructor */:
2942
+ return this.serializeAbortSignalConstructor(node);
2943
+ case 37 /* AbortSignalSync */:
2944
+ return this.serializeAbortSignalSync(node);
2817
2945
  default:
2818
2946
  throw new SerovalUnsupportedNodeError(node);
2819
2947
  }
@@ -2845,9 +2973,12 @@ var CrossSerializerContext = class extends BaseSerializerContext {
2845
2973
  const patches = this.resolvePatches();
2846
2974
  const ref = this.getRefParam(id);
2847
2975
  const params = this.scopeId == null ? "" : GLOBAL_CONTEXT_REFERENCES;
2848
- const body = patches ? result + "," + patches + ref : result;
2976
+ const body = patches ? "(" + result + "," + patches + ref + ")" : result;
2849
2977
  if (params === "") {
2850
- return patches ? "(" + body + ")" : body;
2978
+ if (tree.t === 10 /* Object */ && !patches) {
2979
+ return "(" + body + ")";
2980
+ }
2981
+ return body;
2851
2982
  }
2852
2983
  const args = this.scopeId == null ? "()" : "(" + GLOBAL_CONTEXT_REFERENCES + '["' + serializeString(this.scopeId) + '"])';
2853
2984
  return "(" + this.createFunction([params], body) + ")" + args;
@@ -2939,7 +3070,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2939
3070
  return createErrorNode(
2940
3071
  id,
2941
3072
  current,
2942
- options ? this.parseProperties(options) : void 0
3073
+ options ? this.parseProperties(options) : NIL
2943
3074
  );
2944
3075
  }
2945
3076
  parseAggregateError(id, current) {
@@ -2947,7 +3078,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
2947
3078
  return createAggregateErrorNode(
2948
3079
  id,
2949
3080
  current,
2950
- options ? this.parseProperties(options) : void 0
3081
+ options ? this.parseProperties(options) : NIL
2951
3082
  );
2952
3083
  }
2953
3084
  parseMap(id, current) {
@@ -2994,7 +3125,29 @@ var BaseSyncParserContext = class extends BaseParserContext {
2994
3125
  parsePromise(id, _current) {
2995
3126
  return this.createPromiseConstructorNode(id);
2996
3127
  }
2997
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
3128
+ parseAbortSignalSync(id, current) {
3129
+ return createSerovalNode(
3130
+ 37 /* AbortSignalSync */,
3131
+ id,
3132
+ NIL,
3133
+ NIL,
3134
+ NIL,
3135
+ NIL,
3136
+ NIL,
3137
+ NIL,
3138
+ NIL,
3139
+ this.parse(current.reason),
3140
+ NIL,
3141
+ NIL
3142
+ );
3143
+ }
3144
+ parseAbortSignal(id, current) {
3145
+ if (current.aborted) {
3146
+ return this.parseAbortSignalSync(id, current);
3147
+ }
3148
+ return this.createAbortSignalConstructorNode(id);
3149
+ }
3150
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
2998
3151
  parseObject(id, current) {
2999
3152
  if (Array.isArray(current)) {
3000
3153
  return this.parseArray(id, current);
@@ -3067,6 +3220,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
3067
3220
  return this.parsePromise(id, current);
3068
3221
  }
3069
3222
  const currentFeatures = this.features;
3223
+ if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
3224
+ return this.parseAbortSignal(id, current);
3225
+ }
3070
3226
  if (currentFeatures & 16 /* BigIntTypedArray */) {
3071
3227
  switch (currentClass) {
3072
3228
  case BigInt64Array:
@@ -3231,23 +3387,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3231
3387
  (data) => {
3232
3388
  const parsed = this.parseWithError(data);
3233
3389
  if (parsed) {
3234
- this.onParse({
3235
- t: 23 /* PromiseResolve */,
3236
- i: id,
3237
- s: void 0,
3238
- l: void 0,
3239
- c: void 0,
3240
- m: void 0,
3241
- p: void 0,
3242
- e: void 0,
3243
- a: [
3244
- this.parseSpecialReference(2 /* PromiseResolve */),
3245
- parsed
3246
- ],
3247
- f: void 0,
3248
- b: void 0,
3249
- o: void 0
3250
- });
3390
+ this.onParse(
3391
+ createSerovalNode(
3392
+ 23 /* PromiseResolve */,
3393
+ id,
3394
+ NIL,
3395
+ NIL,
3396
+ NIL,
3397
+ NIL,
3398
+ NIL,
3399
+ NIL,
3400
+ [
3401
+ this.parseSpecialReference(2 /* PromiseResolve */),
3402
+ parsed
3403
+ ],
3404
+ NIL,
3405
+ NIL,
3406
+ NIL
3407
+ )
3408
+ );
3251
3409
  }
3252
3410
  this.popPendingState();
3253
3411
  },
@@ -3255,23 +3413,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3255
3413
  if (this.alive) {
3256
3414
  const parsed = this.parseWithError(data);
3257
3415
  if (parsed) {
3258
- this.onParse({
3259
- t: 24 /* PromiseReject */,
3260
- i: id,
3261
- s: void 0,
3262
- l: void 0,
3263
- c: void 0,
3264
- m: void 0,
3265
- p: void 0,
3266
- e: void 0,
3267
- a: [
3268
- this.parseSpecialReference(3 /* PromiseReject */),
3269
- parsed
3270
- ],
3271
- f: void 0,
3272
- b: void 0,
3273
- o: void 0
3274
- });
3416
+ this.onParse(
3417
+ createSerovalNode(
3418
+ 24 /* PromiseReject */,
3419
+ id,
3420
+ NIL,
3421
+ NIL,
3422
+ NIL,
3423
+ NIL,
3424
+ NIL,
3425
+ NIL,
3426
+ [
3427
+ this.parseSpecialReference(3 /* PromiseReject */),
3428
+ parsed
3429
+ ],
3430
+ NIL,
3431
+ NIL,
3432
+ NIL
3433
+ )
3434
+ );
3275
3435
  }
3276
3436
  }
3277
3437
  this.popPendingState();
@@ -3296,7 +3456,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3296
3456
  }
3297
3457
  }
3298
3458
  }
3299
- return void 0;
3459
+ return NIL;
3300
3460
  }
3301
3461
  parseStream(id, current) {
3302
3462
  const result = createStreamConstructorNode(
@@ -3335,12 +3495,50 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
3335
3495
  });
3336
3496
  return result;
3337
3497
  }
3498
+ parseAbortSignal(id, current) {
3499
+ if (current.aborted) {
3500
+ return this.parseAbortSignalSync(id, current);
3501
+ }
3502
+ this.pushPendingState();
3503
+ current.addEventListener(
3504
+ "abort",
3505
+ () => {
3506
+ if (this.alive) {
3507
+ const parsed = this.parseWithError(current.reason);
3508
+ if (parsed) {
3509
+ this.onParse(
3510
+ createSerovalNode(
3511
+ 36 /* AbortSignalAbort */,
3512
+ id,
3513
+ NIL,
3514
+ NIL,
3515
+ NIL,
3516
+ NIL,
3517
+ NIL,
3518
+ NIL,
3519
+ [
3520
+ this.parseSpecialReference(6 /* AbortSignalAbort */),
3521
+ parsed
3522
+ ],
3523
+ NIL,
3524
+ NIL,
3525
+ NIL
3526
+ )
3527
+ );
3528
+ }
3529
+ }
3530
+ this.popPendingState();
3531
+ },
3532
+ { once: true }
3533
+ );
3534
+ return this.createAbortSignalConstructorNode(id);
3535
+ }
3338
3536
  parseWithError(current) {
3339
3537
  try {
3340
3538
  return this.parse(current);
3341
3539
  } catch (err) {
3342
3540
  this.onError(err);
3343
- return void 0;
3541
+ return NIL;
3344
3542
  }
3345
3543
  }
3346
3544
  /**
@@ -3582,6 +3780,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3582
3780
  serializePromiseReject(node) {
3583
3781
  throw new SerovalUnsupportedNodeError(node);
3584
3782
  }
3783
+ serializeAbortSignalAbort(node) {
3784
+ throw new SerovalUnsupportedNodeError(node);
3785
+ }
3585
3786
  serializeTop(tree) {
3586
3787
  const result = this.serialize(tree);
3587
3788
  if (tree.i != null && this.vars.length) {
@@ -3593,8 +3794,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
3593
3794
  if (!result.startsWith(index + "=")) {
3594
3795
  body = index + "=" + body;
3595
3796
  }
3797
+ body = "(" + body + ")";
3596
3798
  }
3597
- return "(" + this.createFunction(this.vars, "(" + body + ")") + ")()";
3799
+ return "(" + this.createFunction(this.vars, body) + ")()";
3598
3800
  }
3599
3801
  if (tree.t === 10 /* Object */) {
3600
3802
  return "(" + result + ")";