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.
- package/dist/cjs/development/index.cjs +710 -508
- package/dist/cjs/development/index.cjs.map +3 -3
- package/dist/cjs/production/index.cjs +7 -7
- package/dist/esm/development/index.mjs +710 -508
- package/dist/esm/development/index.mjs.map +3 -3
- package/dist/esm/production/index.mjs +7 -7
- package/dist/types/core/abort-signal.d.ts +2 -0
- package/dist/types/core/abort-signal.d.ts.map +1 -0
- package/dist/types/core/base-primitives.d.ts +2 -1
- package/dist/types/core/base-primitives.d.ts.map +1 -1
- package/dist/types/core/compat.d.ts +3 -2
- package/dist/types/core/compat.d.ts.map +1 -1
- package/dist/types/core/constants.d.ts +5 -1
- package/dist/types/core/constants.d.ts.map +1 -1
- package/dist/types/core/context/deserializer.d.ts +3 -0
- package/dist/types/core/context/deserializer.d.ts.map +1 -1
- package/dist/types/core/context/parser/async.d.ts +2 -0
- package/dist/types/core/context/parser/async.d.ts.map +1 -1
- package/dist/types/core/context/parser/stream.d.ts +2 -1
- package/dist/types/core/context/parser/stream.d.ts.map +1 -1
- package/dist/types/core/context/parser/sync.d.ts +3 -1
- package/dist/types/core/context/parser/sync.d.ts.map +1 -1
- package/dist/types/core/context/parser.d.ts +2 -1
- package/dist/types/core/context/parser.d.ts.map +1 -1
- package/dist/types/core/context/serializer.d.ts +4 -1
- package/dist/types/core/context/serializer.d.ts.map +1 -1
- package/dist/types/core/cross/serializer.d.ts.map +1 -1
- package/dist/types/core/literals.d.ts.map +1 -1
- package/dist/types/core/node.d.ts +8 -0
- package/dist/types/core/node.d.ts.map +1 -0
- package/dist/types/core/special-reference.d.ts +6 -1
- package/dist/types/core/special-reference.d.ts.map +1 -1
- package/dist/types/core/tree/serializer.d.ts +2 -1
- package/dist/types/core/tree/serializer.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +20 -2
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/core/utils/iterator-to-sequence.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/core/abort-signal.ts +13 -0
- package/src/core/base-primitives.ts +359 -337
- package/src/core/compat.ts +2 -1
- package/src/core/constants.ts +5 -0
- package/src/core/context/deserializer.ts +34 -1
- package/src/core/context/parser/async.ts +61 -20
- package/src/core/context/parser/stream.ts +89 -37
- package/src/core/context/parser/sync.ts +44 -3
- package/src/core/context/parser.ts +106 -85
- package/src/core/context/serializer.ts +56 -10
- package/src/core/cross/serializer.ts +6 -2
- package/src/core/literals.ts +16 -15
- package/src/core/node.ts +40 -0
- package/src/core/special-reference.ts +7 -0
- package/src/core/tree/serializer.ts +9 -1
- package/src/core/types.ts +32 -2
- 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 =
|
|
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/
|
|
330
|
-
function
|
|
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
|
|
333
|
-
i
|
|
334
|
-
s
|
|
335
|
-
l
|
|
336
|
-
c
|
|
337
|
-
m
|
|
338
|
-
p
|
|
339
|
-
e
|
|
340
|
-
a
|
|
341
|
-
f
|
|
342
|
-
b
|
|
343
|
-
o
|
|
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
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
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
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
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
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
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
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
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
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
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
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
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
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
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
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
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
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
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
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
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
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
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
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
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
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
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:
|
|
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
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
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
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
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
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
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
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1348
|
+
NIL,
|
|
1349
|
+
NIL,
|
|
1350
|
+
NIL
|
|
1351
|
+
);
|
|
1315
1352
|
}
|
|
1316
1353
|
createObjectNode(id, current, empty, record) {
|
|
1317
|
-
return
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
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
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
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
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
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) :
|
|
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) :
|
|
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
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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 */]:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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
|
-
|
|
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) :
|
|
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) :
|
|
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
|
-
|
|
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
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
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
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
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
|
|
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
|
|
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,
|
|
3857
|
+
return "(" + this.createFunction(this.vars, body) + ")()";
|
|
3656
3858
|
}
|
|
3657
3859
|
if (tree.t === 10 /* Object */) {
|
|
3658
3860
|
return "(" + result + ")";
|