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