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
|
@@ -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 =
|
|
11
|
+
var ALL_ENABLED = 47;
|
|
11
12
|
|
|
12
13
|
// src/core/string.ts
|
|
13
14
|
function serializeChar(str) {
|
|
@@ -183,6 +184,19 @@ function resolvePlugins(plugins) {
|
|
|
183
184
|
return void 0;
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
// src/core/abort-signal.ts
|
|
188
|
+
function resolveAbortSignalResult(resolve) {
|
|
189
|
+
resolve(this.reason);
|
|
190
|
+
}
|
|
191
|
+
function resolveAbortSignal(resolve) {
|
|
192
|
+
this.addEventListener("abort", resolveAbortSignalResult.bind(this, resolve), {
|
|
193
|
+
once: true
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function abortSignalToPromise(signal) {
|
|
197
|
+
return new Promise(resolveAbortSignal.bind(signal));
|
|
198
|
+
}
|
|
199
|
+
|
|
186
200
|
// src/core/constants.ts
|
|
187
201
|
var SYMBOL_STRING = {
|
|
188
202
|
[0 /* AsyncIterator */]: "Symbol.asyncIterator",
|
|
@@ -267,24 +281,43 @@ var ERROR_CONSTRUCTOR = {
|
|
|
267
281
|
[5 /* TypeError */]: TypeError,
|
|
268
282
|
[6 /* URIError */]: URIError
|
|
269
283
|
};
|
|
284
|
+
var NIL = void 0;
|
|
270
285
|
|
|
271
|
-
// src/core/
|
|
272
|
-
function
|
|
286
|
+
// src/core/node.ts
|
|
287
|
+
function createSerovalNode(t, i, s, l, c, m, p, e, a, f, b, o) {
|
|
273
288
|
return {
|
|
274
|
-
t
|
|
275
|
-
i
|
|
276
|
-
s
|
|
277
|
-
l
|
|
278
|
-
c
|
|
279
|
-
m
|
|
280
|
-
p
|
|
281
|
-
e
|
|
282
|
-
a
|
|
283
|
-
f
|
|
284
|
-
b
|
|
285
|
-
o
|
|
289
|
+
t,
|
|
290
|
+
i,
|
|
291
|
+
s,
|
|
292
|
+
l,
|
|
293
|
+
c,
|
|
294
|
+
m,
|
|
295
|
+
p,
|
|
296
|
+
e,
|
|
297
|
+
a,
|
|
298
|
+
f,
|
|
299
|
+
b,
|
|
300
|
+
o
|
|
286
301
|
};
|
|
287
302
|
}
|
|
303
|
+
|
|
304
|
+
// src/core/literals.ts
|
|
305
|
+
function createConstantNode(value) {
|
|
306
|
+
return createSerovalNode(
|
|
307
|
+
2 /* Constant */,
|
|
308
|
+
NIL,
|
|
309
|
+
value,
|
|
310
|
+
NIL,
|
|
311
|
+
NIL,
|
|
312
|
+
NIL,
|
|
313
|
+
NIL,
|
|
314
|
+
NIL,
|
|
315
|
+
NIL,
|
|
316
|
+
NIL,
|
|
317
|
+
NIL,
|
|
318
|
+
NIL
|
|
319
|
+
);
|
|
320
|
+
}
|
|
288
321
|
var TRUE_NODE = /* @__PURE__ */ createConstantNode(
|
|
289
322
|
2 /* True */
|
|
290
323
|
);
|
|
@@ -388,100 +421,100 @@ function createNumberNode(value) {
|
|
|
388
421
|
if (Object.is(value, -0)) {
|
|
389
422
|
return NEG_ZERO_NODE;
|
|
390
423
|
}
|
|
391
|
-
return
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
424
|
+
return createSerovalNode(
|
|
425
|
+
0 /* Number */,
|
|
426
|
+
NIL,
|
|
427
|
+
value,
|
|
428
|
+
NIL,
|
|
429
|
+
NIL,
|
|
430
|
+
NIL,
|
|
431
|
+
NIL,
|
|
432
|
+
NIL,
|
|
433
|
+
NIL,
|
|
434
|
+
NIL,
|
|
435
|
+
NIL,
|
|
436
|
+
NIL
|
|
437
|
+
);
|
|
405
438
|
}
|
|
406
439
|
function createStringNode(value) {
|
|
407
|
-
return
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
440
|
+
return createSerovalNode(
|
|
441
|
+
1 /* String */,
|
|
442
|
+
NIL,
|
|
443
|
+
serializeString(value),
|
|
444
|
+
NIL,
|
|
445
|
+
NIL,
|
|
446
|
+
NIL,
|
|
447
|
+
NIL,
|
|
448
|
+
NIL,
|
|
449
|
+
NIL,
|
|
450
|
+
NIL,
|
|
451
|
+
NIL,
|
|
452
|
+
NIL
|
|
453
|
+
);
|
|
421
454
|
}
|
|
422
455
|
function createBigIntNode(current) {
|
|
423
|
-
return
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
456
|
+
return createSerovalNode(
|
|
457
|
+
3 /* BigInt */,
|
|
458
|
+
NIL,
|
|
459
|
+
"" + current,
|
|
460
|
+
NIL,
|
|
461
|
+
NIL,
|
|
462
|
+
NIL,
|
|
463
|
+
NIL,
|
|
464
|
+
NIL,
|
|
465
|
+
NIL,
|
|
466
|
+
NIL,
|
|
467
|
+
NIL,
|
|
468
|
+
NIL
|
|
469
|
+
);
|
|
437
470
|
}
|
|
438
471
|
function createIndexedValueNode(id) {
|
|
439
|
-
return
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
472
|
+
return createSerovalNode(
|
|
473
|
+
4 /* IndexedValue */,
|
|
474
|
+
id,
|
|
475
|
+
NIL,
|
|
476
|
+
NIL,
|
|
477
|
+
NIL,
|
|
478
|
+
NIL,
|
|
479
|
+
NIL,
|
|
480
|
+
NIL,
|
|
481
|
+
NIL,
|
|
482
|
+
NIL,
|
|
483
|
+
NIL,
|
|
484
|
+
NIL
|
|
485
|
+
);
|
|
453
486
|
}
|
|
454
487
|
function createDateNode(id, current) {
|
|
455
|
-
return
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
488
|
+
return createSerovalNode(
|
|
489
|
+
5 /* Date */,
|
|
490
|
+
id,
|
|
491
|
+
current.toISOString(),
|
|
492
|
+
NIL,
|
|
493
|
+
NIL,
|
|
494
|
+
NIL,
|
|
495
|
+
NIL,
|
|
496
|
+
NIL,
|
|
497
|
+
NIL,
|
|
498
|
+
NIL,
|
|
499
|
+
NIL,
|
|
500
|
+
NIL
|
|
501
|
+
);
|
|
469
502
|
}
|
|
470
503
|
function createRegExpNode(id, current) {
|
|
471
|
-
return
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
504
|
+
return createSerovalNode(
|
|
505
|
+
6 /* RegExp */,
|
|
506
|
+
id,
|
|
507
|
+
NIL,
|
|
508
|
+
NIL,
|
|
509
|
+
serializeString(current.source),
|
|
510
|
+
current.flags,
|
|
511
|
+
NIL,
|
|
512
|
+
NIL,
|
|
513
|
+
NIL,
|
|
514
|
+
NIL,
|
|
515
|
+
NIL,
|
|
516
|
+
NIL
|
|
517
|
+
);
|
|
485
518
|
}
|
|
486
519
|
function createArrayBufferNode(id, current) {
|
|
487
520
|
const bytes = new Uint8Array(current);
|
|
@@ -490,292 +523,292 @@ function createArrayBufferNode(id, current) {
|
|
|
490
523
|
for (let i = 0; i < len; i++) {
|
|
491
524
|
values[i] = bytes[i];
|
|
492
525
|
}
|
|
493
|
-
return
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
526
|
+
return createSerovalNode(
|
|
527
|
+
19 /* ArrayBuffer */,
|
|
528
|
+
id,
|
|
529
|
+
values,
|
|
530
|
+
NIL,
|
|
531
|
+
NIL,
|
|
532
|
+
NIL,
|
|
533
|
+
NIL,
|
|
534
|
+
NIL,
|
|
535
|
+
NIL,
|
|
536
|
+
NIL,
|
|
537
|
+
NIL,
|
|
538
|
+
NIL
|
|
539
|
+
);
|
|
507
540
|
}
|
|
508
541
|
function createWKSymbolNode(id, current) {
|
|
509
|
-
return
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
542
|
+
return createSerovalNode(
|
|
543
|
+
17 /* WKSymbol */,
|
|
544
|
+
id,
|
|
545
|
+
INV_SYMBOL_REF[current],
|
|
546
|
+
NIL,
|
|
547
|
+
NIL,
|
|
548
|
+
NIL,
|
|
549
|
+
NIL,
|
|
550
|
+
NIL,
|
|
551
|
+
NIL,
|
|
552
|
+
NIL,
|
|
553
|
+
NIL,
|
|
554
|
+
NIL
|
|
555
|
+
);
|
|
523
556
|
}
|
|
524
557
|
function createReferenceNode(id, ref) {
|
|
525
|
-
return
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
558
|
+
return createSerovalNode(
|
|
559
|
+
18 /* Reference */,
|
|
560
|
+
id,
|
|
561
|
+
serializeString(getReferenceID(ref)),
|
|
562
|
+
NIL,
|
|
563
|
+
NIL,
|
|
564
|
+
NIL,
|
|
565
|
+
NIL,
|
|
566
|
+
NIL,
|
|
567
|
+
NIL,
|
|
568
|
+
NIL,
|
|
569
|
+
NIL,
|
|
570
|
+
NIL
|
|
571
|
+
);
|
|
539
572
|
}
|
|
540
573
|
function createPluginNode(id, tag, value) {
|
|
541
|
-
return
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
574
|
+
return createSerovalNode(
|
|
575
|
+
25 /* Plugin */,
|
|
576
|
+
id,
|
|
577
|
+
value,
|
|
578
|
+
NIL,
|
|
579
|
+
serializeString(tag),
|
|
580
|
+
NIL,
|
|
581
|
+
NIL,
|
|
582
|
+
NIL,
|
|
583
|
+
NIL,
|
|
584
|
+
NIL,
|
|
585
|
+
NIL,
|
|
586
|
+
NIL
|
|
587
|
+
);
|
|
555
588
|
}
|
|
556
589
|
function createArrayNode(id, current, parsedItems) {
|
|
557
|
-
return
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
590
|
+
return createSerovalNode(
|
|
591
|
+
9 /* Array */,
|
|
592
|
+
id,
|
|
593
|
+
NIL,
|
|
594
|
+
current.length,
|
|
595
|
+
NIL,
|
|
596
|
+
NIL,
|
|
597
|
+
NIL,
|
|
598
|
+
NIL,
|
|
599
|
+
parsedItems,
|
|
600
|
+
NIL,
|
|
601
|
+
NIL,
|
|
602
|
+
getObjectFlag(current)
|
|
603
|
+
);
|
|
571
604
|
}
|
|
572
605
|
function createBoxedNode(id, boxed) {
|
|
573
|
-
return
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
606
|
+
return createSerovalNode(
|
|
607
|
+
21 /* Boxed */,
|
|
608
|
+
id,
|
|
609
|
+
NIL,
|
|
610
|
+
NIL,
|
|
611
|
+
NIL,
|
|
612
|
+
NIL,
|
|
613
|
+
NIL,
|
|
614
|
+
NIL,
|
|
615
|
+
NIL,
|
|
616
|
+
boxed,
|
|
617
|
+
NIL,
|
|
618
|
+
NIL
|
|
619
|
+
);
|
|
587
620
|
}
|
|
588
621
|
function createTypedArrayNode(id, current, buffer) {
|
|
589
|
-
return
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
622
|
+
return createSerovalNode(
|
|
623
|
+
15 /* TypedArray */,
|
|
624
|
+
id,
|
|
625
|
+
NIL,
|
|
626
|
+
current.length,
|
|
627
|
+
current.constructor.name,
|
|
628
|
+
NIL,
|
|
629
|
+
NIL,
|
|
630
|
+
NIL,
|
|
631
|
+
NIL,
|
|
632
|
+
buffer,
|
|
633
|
+
current.byteOffset,
|
|
634
|
+
NIL
|
|
635
|
+
);
|
|
603
636
|
}
|
|
604
637
|
function createBigIntTypedArrayNode(id, current, buffer) {
|
|
605
|
-
return
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
638
|
+
return createSerovalNode(
|
|
639
|
+
16 /* BigIntTypedArray */,
|
|
640
|
+
id,
|
|
641
|
+
NIL,
|
|
642
|
+
current.length,
|
|
643
|
+
current.constructor.name,
|
|
644
|
+
NIL,
|
|
645
|
+
NIL,
|
|
646
|
+
NIL,
|
|
647
|
+
NIL,
|
|
648
|
+
buffer,
|
|
649
|
+
current.byteOffset,
|
|
650
|
+
NIL
|
|
651
|
+
);
|
|
619
652
|
}
|
|
620
653
|
function createDataViewNode(id, current, buffer) {
|
|
621
|
-
return
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
654
|
+
return createSerovalNode(
|
|
655
|
+
20 /* DataView */,
|
|
656
|
+
id,
|
|
657
|
+
NIL,
|
|
658
|
+
current.byteLength,
|
|
659
|
+
NIL,
|
|
660
|
+
NIL,
|
|
661
|
+
NIL,
|
|
662
|
+
NIL,
|
|
663
|
+
NIL,
|
|
664
|
+
buffer,
|
|
665
|
+
current.byteOffset,
|
|
666
|
+
NIL
|
|
667
|
+
);
|
|
635
668
|
}
|
|
636
669
|
function createErrorNode(id, current, options) {
|
|
637
|
-
return
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
670
|
+
return createSerovalNode(
|
|
671
|
+
13 /* Error */,
|
|
672
|
+
id,
|
|
673
|
+
getErrorConstructor(current),
|
|
674
|
+
NIL,
|
|
675
|
+
NIL,
|
|
676
|
+
serializeString(current.message),
|
|
677
|
+
options,
|
|
678
|
+
NIL,
|
|
679
|
+
NIL,
|
|
680
|
+
NIL,
|
|
681
|
+
NIL,
|
|
682
|
+
NIL
|
|
683
|
+
);
|
|
651
684
|
}
|
|
652
685
|
function createAggregateErrorNode(id, current, options) {
|
|
653
|
-
return
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
686
|
+
return createSerovalNode(
|
|
687
|
+
14 /* AggregateError */,
|
|
688
|
+
id,
|
|
689
|
+
getErrorConstructor(current),
|
|
690
|
+
NIL,
|
|
691
|
+
NIL,
|
|
692
|
+
serializeString(current.message),
|
|
693
|
+
options,
|
|
694
|
+
NIL,
|
|
695
|
+
NIL,
|
|
696
|
+
NIL,
|
|
697
|
+
NIL,
|
|
698
|
+
NIL
|
|
699
|
+
);
|
|
667
700
|
}
|
|
668
701
|
function createSetNode(id, size, items) {
|
|
669
|
-
return
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
702
|
+
return createSerovalNode(
|
|
703
|
+
7 /* Set */,
|
|
704
|
+
id,
|
|
705
|
+
NIL,
|
|
706
|
+
size,
|
|
707
|
+
NIL,
|
|
708
|
+
NIL,
|
|
709
|
+
NIL,
|
|
710
|
+
NIL,
|
|
711
|
+
items,
|
|
712
|
+
NIL,
|
|
713
|
+
NIL,
|
|
714
|
+
NIL
|
|
715
|
+
);
|
|
683
716
|
}
|
|
684
717
|
function createIteratorFactoryInstanceNode(factory, items) {
|
|
685
|
-
return
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
718
|
+
return createSerovalNode(
|
|
719
|
+
28 /* IteratorFactoryInstance */,
|
|
720
|
+
NIL,
|
|
721
|
+
NIL,
|
|
722
|
+
NIL,
|
|
723
|
+
NIL,
|
|
724
|
+
NIL,
|
|
725
|
+
NIL,
|
|
726
|
+
NIL,
|
|
727
|
+
[factory, items],
|
|
728
|
+
NIL,
|
|
729
|
+
NIL,
|
|
730
|
+
NIL
|
|
731
|
+
);
|
|
699
732
|
}
|
|
700
733
|
function createAsyncIteratorFactoryInstanceNode(factory, items) {
|
|
701
|
-
return
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
734
|
+
return createSerovalNode(
|
|
735
|
+
30 /* AsyncIteratorFactoryInstance */,
|
|
736
|
+
NIL,
|
|
737
|
+
NIL,
|
|
738
|
+
NIL,
|
|
739
|
+
NIL,
|
|
740
|
+
NIL,
|
|
741
|
+
NIL,
|
|
742
|
+
NIL,
|
|
743
|
+
[factory, items],
|
|
744
|
+
NIL,
|
|
745
|
+
NIL,
|
|
746
|
+
NIL
|
|
747
|
+
);
|
|
715
748
|
}
|
|
716
749
|
function createStreamConstructorNode(id, factory, sequence) {
|
|
717
|
-
return
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
750
|
+
return createSerovalNode(
|
|
751
|
+
31 /* StreamConstructor */,
|
|
752
|
+
id,
|
|
753
|
+
NIL,
|
|
754
|
+
NIL,
|
|
755
|
+
NIL,
|
|
756
|
+
NIL,
|
|
757
|
+
NIL,
|
|
758
|
+
NIL,
|
|
759
|
+
sequence,
|
|
760
|
+
factory,
|
|
761
|
+
NIL,
|
|
762
|
+
NIL
|
|
763
|
+
);
|
|
731
764
|
}
|
|
732
765
|
function createStreamNextNode(id, parsed) {
|
|
733
|
-
return
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
766
|
+
return createSerovalNode(
|
|
767
|
+
32 /* StreamNext */,
|
|
768
|
+
id,
|
|
769
|
+
NIL,
|
|
770
|
+
NIL,
|
|
771
|
+
NIL,
|
|
772
|
+
NIL,
|
|
773
|
+
NIL,
|
|
774
|
+
NIL,
|
|
775
|
+
NIL,
|
|
776
|
+
parsed,
|
|
777
|
+
NIL,
|
|
778
|
+
NIL
|
|
779
|
+
);
|
|
747
780
|
}
|
|
748
781
|
function createStreamThrowNode(id, parsed) {
|
|
749
|
-
return
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
782
|
+
return createSerovalNode(
|
|
783
|
+
33 /* StreamThrow */,
|
|
784
|
+
id,
|
|
785
|
+
NIL,
|
|
786
|
+
NIL,
|
|
787
|
+
NIL,
|
|
788
|
+
NIL,
|
|
789
|
+
NIL,
|
|
790
|
+
NIL,
|
|
791
|
+
NIL,
|
|
792
|
+
parsed,
|
|
793
|
+
NIL,
|
|
794
|
+
NIL
|
|
795
|
+
);
|
|
763
796
|
}
|
|
764
797
|
function createStreamReturnNode(id, parsed) {
|
|
765
|
-
return
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
798
|
+
return createSerovalNode(
|
|
799
|
+
34 /* StreamReturn */,
|
|
800
|
+
id,
|
|
801
|
+
NIL,
|
|
802
|
+
NIL,
|
|
803
|
+
NIL,
|
|
804
|
+
NIL,
|
|
805
|
+
NIL,
|
|
806
|
+
NIL,
|
|
807
|
+
NIL,
|
|
808
|
+
parsed,
|
|
809
|
+
NIL,
|
|
810
|
+
NIL
|
|
811
|
+
);
|
|
779
812
|
}
|
|
780
813
|
|
|
781
814
|
// src/core/errors.ts
|
|
@@ -879,7 +912,9 @@ var SPECIAL_REFS = {
|
|
|
879
912
|
[1 /* PromiseConstructor */]: {},
|
|
880
913
|
[2 /* PromiseResolve */]: {},
|
|
881
914
|
[3 /* PromiseReject */]: {},
|
|
882
|
-
[4 /* StreamConstructor */]: {}
|
|
915
|
+
[4 /* StreamConstructor */]: {},
|
|
916
|
+
[5 /* AbortSignalConstructor */]: {},
|
|
917
|
+
[6 /* AbortSignalAbort */]: {}
|
|
883
918
|
};
|
|
884
919
|
|
|
885
920
|
// src/core/utils/deferred.ts
|
|
@@ -1104,7 +1139,7 @@ function sequenceToIterator(sequence) {
|
|
|
1104
1139
|
if (index > sequence.d) {
|
|
1105
1140
|
return {
|
|
1106
1141
|
done: true,
|
|
1107
|
-
value:
|
|
1142
|
+
value: NIL
|
|
1108
1143
|
};
|
|
1109
1144
|
}
|
|
1110
1145
|
const currentIndex = index++;
|
|
@@ -1173,17 +1208,6 @@ var BaseParserContext = class {
|
|
|
1173
1208
|
}
|
|
1174
1209
|
return indexed;
|
|
1175
1210
|
}
|
|
1176
|
-
getStrictReference(current) {
|
|
1177
|
-
assert(hasReferenceID(current), new SerovalUnsupportedTypeError(current));
|
|
1178
|
-
const result = this.getIndexedValue(current);
|
|
1179
|
-
if (result.type === 1 /* Indexed */) {
|
|
1180
|
-
return result.value;
|
|
1181
|
-
}
|
|
1182
|
-
return createReferenceNode(result.value, current);
|
|
1183
|
-
}
|
|
1184
|
-
parseFunction(current) {
|
|
1185
|
-
return this.getStrictReference(current);
|
|
1186
|
-
}
|
|
1187
1211
|
parseWellKnownSymbol(current) {
|
|
1188
1212
|
const ref = this.getReference(current);
|
|
1189
1213
|
if (ref.type !== 0 /* Fresh */) {
|
|
@@ -1197,111 +1221,127 @@ var BaseParserContext = class {
|
|
|
1197
1221
|
if (result.type === 1 /* Indexed */) {
|
|
1198
1222
|
return result.value;
|
|
1199
1223
|
}
|
|
1200
|
-
return
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1224
|
+
return createSerovalNode(
|
|
1225
|
+
26 /* SpecialReference */,
|
|
1226
|
+
result.value,
|
|
1227
|
+
ref,
|
|
1228
|
+
NIL,
|
|
1229
|
+
NIL,
|
|
1230
|
+
NIL,
|
|
1231
|
+
NIL,
|
|
1232
|
+
NIL,
|
|
1233
|
+
NIL,
|
|
1234
|
+
NIL,
|
|
1235
|
+
NIL,
|
|
1236
|
+
NIL
|
|
1237
|
+
);
|
|
1214
1238
|
}
|
|
1215
1239
|
parseIteratorFactory() {
|
|
1216
1240
|
const result = this.getIndexedValue(ITERATOR);
|
|
1217
1241
|
if (result.type === 1 /* Indexed */) {
|
|
1218
1242
|
return result.value;
|
|
1219
1243
|
}
|
|
1220
|
-
return
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1244
|
+
return createSerovalNode(
|
|
1245
|
+
27 /* IteratorFactory */,
|
|
1246
|
+
result.value,
|
|
1247
|
+
NIL,
|
|
1248
|
+
NIL,
|
|
1249
|
+
NIL,
|
|
1250
|
+
NIL,
|
|
1251
|
+
NIL,
|
|
1252
|
+
NIL,
|
|
1253
|
+
NIL,
|
|
1254
|
+
this.parseWellKnownSymbol(Symbol.iterator),
|
|
1255
|
+
NIL,
|
|
1256
|
+
NIL
|
|
1257
|
+
);
|
|
1234
1258
|
}
|
|
1235
1259
|
parseAsyncIteratorFactory() {
|
|
1236
1260
|
const result = this.getIndexedValue(ASYNC_ITERATOR);
|
|
1237
1261
|
if (result.type === 1 /* Indexed */) {
|
|
1238
1262
|
return result.value;
|
|
1239
1263
|
}
|
|
1240
|
-
return
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1264
|
+
return createSerovalNode(
|
|
1265
|
+
29 /* AsyncIteratorFactory */,
|
|
1266
|
+
result.value,
|
|
1267
|
+
NIL,
|
|
1268
|
+
NIL,
|
|
1269
|
+
NIL,
|
|
1270
|
+
NIL,
|
|
1271
|
+
NIL,
|
|
1272
|
+
NIL,
|
|
1273
|
+
[
|
|
1250
1274
|
this.parseSpecialReference(1 /* PromiseConstructor */),
|
|
1251
1275
|
this.parseWellKnownSymbol(Symbol.asyncIterator)
|
|
1252
1276
|
],
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1277
|
+
NIL,
|
|
1278
|
+
NIL,
|
|
1279
|
+
NIL
|
|
1280
|
+
);
|
|
1257
1281
|
}
|
|
1258
1282
|
createObjectNode(id, current, empty, record) {
|
|
1259
|
-
return
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1283
|
+
return createSerovalNode(
|
|
1284
|
+
empty ? 11 /* NullConstructor */ : 10 /* Object */,
|
|
1285
|
+
id,
|
|
1286
|
+
NIL,
|
|
1287
|
+
NIL,
|
|
1288
|
+
NIL,
|
|
1289
|
+
NIL,
|
|
1290
|
+
record,
|
|
1291
|
+
NIL,
|
|
1292
|
+
NIL,
|
|
1293
|
+
NIL,
|
|
1294
|
+
NIL,
|
|
1295
|
+
getObjectFlag(current)
|
|
1296
|
+
);
|
|
1273
1297
|
}
|
|
1274
1298
|
createMapNode(id, k, v, s) {
|
|
1275
|
-
return
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1299
|
+
return createSerovalNode(
|
|
1300
|
+
8 /* Map */,
|
|
1301
|
+
id,
|
|
1302
|
+
NIL,
|
|
1303
|
+
NIL,
|
|
1304
|
+
NIL,
|
|
1305
|
+
NIL,
|
|
1306
|
+
NIL,
|
|
1307
|
+
{ k, v, s },
|
|
1308
|
+
NIL,
|
|
1309
|
+
this.parseSpecialReference(0 /* MapSentinel */),
|
|
1310
|
+
NIL,
|
|
1311
|
+
NIL
|
|
1312
|
+
);
|
|
1289
1313
|
}
|
|
1290
1314
|
createPromiseConstructorNode(id) {
|
|
1291
|
-
return
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1315
|
+
return createSerovalNode(
|
|
1316
|
+
22 /* PromiseConstructor */,
|
|
1317
|
+
id,
|
|
1318
|
+
NIL,
|
|
1319
|
+
NIL,
|
|
1320
|
+
NIL,
|
|
1321
|
+
NIL,
|
|
1322
|
+
NIL,
|
|
1323
|
+
NIL,
|
|
1324
|
+
NIL,
|
|
1325
|
+
this.parseSpecialReference(1 /* PromiseConstructor */),
|
|
1326
|
+
NIL,
|
|
1327
|
+
NIL
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
createAbortSignalConstructorNode(id) {
|
|
1331
|
+
return createSerovalNode(
|
|
1332
|
+
35 /* AbortSignalConstructor */,
|
|
1333
|
+
id,
|
|
1334
|
+
NIL,
|
|
1335
|
+
NIL,
|
|
1336
|
+
NIL,
|
|
1337
|
+
NIL,
|
|
1338
|
+
NIL,
|
|
1339
|
+
NIL,
|
|
1340
|
+
NIL,
|
|
1341
|
+
this.parseSpecialReference(5 /* AbortSignalConstructor */),
|
|
1342
|
+
NIL,
|
|
1343
|
+
NIL
|
|
1344
|
+
);
|
|
1305
1345
|
}
|
|
1306
1346
|
};
|
|
1307
1347
|
|
|
@@ -1398,7 +1438,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1398
1438
|
return createErrorNode(
|
|
1399
1439
|
id,
|
|
1400
1440
|
current,
|
|
1401
|
-
options ? await this.parseProperties(options) :
|
|
1441
|
+
options ? await this.parseProperties(options) : NIL
|
|
1402
1442
|
);
|
|
1403
1443
|
}
|
|
1404
1444
|
async parseAggregateError(id, current) {
|
|
@@ -1406,7 +1446,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1406
1446
|
return createAggregateErrorNode(
|
|
1407
1447
|
id,
|
|
1408
1448
|
current,
|
|
1409
|
-
options ? await this.parseProperties(options) :
|
|
1449
|
+
options ? await this.parseProperties(options) : NIL
|
|
1410
1450
|
);
|
|
1411
1451
|
}
|
|
1412
1452
|
async parseMap(id, current) {
|
|
@@ -1427,20 +1467,20 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1427
1467
|
}
|
|
1428
1468
|
async parsePromise(id, current) {
|
|
1429
1469
|
const [status, result] = await promiseToResult(current);
|
|
1430
|
-
return
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1470
|
+
return createSerovalNode(
|
|
1471
|
+
12 /* Promise */,
|
|
1472
|
+
id,
|
|
1473
|
+
status,
|
|
1474
|
+
NIL,
|
|
1475
|
+
NIL,
|
|
1476
|
+
NIL,
|
|
1477
|
+
NIL,
|
|
1478
|
+
NIL,
|
|
1479
|
+
NIL,
|
|
1480
|
+
await this.parse(result),
|
|
1481
|
+
NIL,
|
|
1482
|
+
NIL
|
|
1483
|
+
);
|
|
1444
1484
|
}
|
|
1445
1485
|
async parsePlugin(id, current) {
|
|
1446
1486
|
const currentPlugins = this.plugins;
|
|
@@ -1458,7 +1498,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1458
1498
|
}
|
|
1459
1499
|
}
|
|
1460
1500
|
}
|
|
1461
|
-
return
|
|
1501
|
+
return NIL;
|
|
1462
1502
|
}
|
|
1463
1503
|
async parseStream(id, current) {
|
|
1464
1504
|
return createStreamConstructorNode(
|
|
@@ -1511,7 +1551,29 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1511
1551
|
})
|
|
1512
1552
|
);
|
|
1513
1553
|
}
|
|
1514
|
-
|
|
1554
|
+
async parseAbortSignalSync(id, current) {
|
|
1555
|
+
return createSerovalNode(
|
|
1556
|
+
37 /* AbortSignalSync */,
|
|
1557
|
+
id,
|
|
1558
|
+
NIL,
|
|
1559
|
+
NIL,
|
|
1560
|
+
NIL,
|
|
1561
|
+
NIL,
|
|
1562
|
+
NIL,
|
|
1563
|
+
NIL,
|
|
1564
|
+
NIL,
|
|
1565
|
+
await this.parse(current.reason),
|
|
1566
|
+
NIL,
|
|
1567
|
+
NIL
|
|
1568
|
+
);
|
|
1569
|
+
}
|
|
1570
|
+
async parseAbortSignal(id, current) {
|
|
1571
|
+
if (!current.aborted) {
|
|
1572
|
+
await abortSignalToPromise(current);
|
|
1573
|
+
}
|
|
1574
|
+
return this.parseAbortSignalSync(id, current);
|
|
1575
|
+
}
|
|
1576
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
|
|
1515
1577
|
async parseObject(id, current) {
|
|
1516
1578
|
if (Array.isArray(current)) {
|
|
1517
1579
|
return this.parseArray(id, current);
|
|
@@ -1536,7 +1598,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1536
1598
|
current,
|
|
1537
1599
|
false
|
|
1538
1600
|
);
|
|
1539
|
-
case
|
|
1601
|
+
case NIL:
|
|
1540
1602
|
return this.parsePlainObject(
|
|
1541
1603
|
id,
|
|
1542
1604
|
current,
|
|
@@ -1584,6 +1646,9 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1584
1646
|
return this.parsePromise(id, current);
|
|
1585
1647
|
}
|
|
1586
1648
|
const currentFeatures = this.features;
|
|
1649
|
+
if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
|
|
1650
|
+
return this.parseAbortSignal(id, current);
|
|
1651
|
+
}
|
|
1587
1652
|
if (currentFeatures & 16 /* BigIntTypedArray */) {
|
|
1588
1653
|
switch (currentClass) {
|
|
1589
1654
|
case BigInt64Array:
|
|
@@ -1607,6 +1672,17 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1607
1672
|
}
|
|
1608
1673
|
throw new SerovalUnsupportedTypeError(current);
|
|
1609
1674
|
}
|
|
1675
|
+
async parseFunction(current) {
|
|
1676
|
+
const ref = this.getReference(current);
|
|
1677
|
+
if (ref.type !== 0 /* Fresh */) {
|
|
1678
|
+
return ref.value;
|
|
1679
|
+
}
|
|
1680
|
+
const plugin = await this.parsePlugin(ref.value, current);
|
|
1681
|
+
if (plugin) {
|
|
1682
|
+
return plugin;
|
|
1683
|
+
}
|
|
1684
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
1685
|
+
}
|
|
1610
1686
|
async parse(current) {
|
|
1611
1687
|
try {
|
|
1612
1688
|
switch (typeof current) {
|
|
@@ -1906,6 +1982,21 @@ var BaseDeserializerContext = class {
|
|
|
1906
1982
|
this.deserialize(node.a[1]);
|
|
1907
1983
|
return void 0;
|
|
1908
1984
|
}
|
|
1985
|
+
deserializeAbortSignalConstructor(node) {
|
|
1986
|
+
return this.assignIndexedValue(node.i, new AbortController()).signal;
|
|
1987
|
+
}
|
|
1988
|
+
deserializeAbortSignalAbort(node) {
|
|
1989
|
+
const controller = this.refs.get(node.i);
|
|
1990
|
+
assert(controller, new SerovalMissingInstanceError("AbortSignal"));
|
|
1991
|
+
controller.abort(this.deserialize(node.a[1]));
|
|
1992
|
+
return void 0;
|
|
1993
|
+
}
|
|
1994
|
+
deserializeAbortSignalSync(node) {
|
|
1995
|
+
return this.assignIndexedValue(
|
|
1996
|
+
node.i,
|
|
1997
|
+
AbortSignal.abort(this.deserialize(node.f))
|
|
1998
|
+
);
|
|
1999
|
+
}
|
|
1909
2000
|
deserialize(node) {
|
|
1910
2001
|
try {
|
|
1911
2002
|
switch (node.t) {
|
|
@@ -1975,6 +2066,13 @@ var BaseDeserializerContext = class {
|
|
|
1975
2066
|
return this.deserializeIteratorFactory(node);
|
|
1976
2067
|
case 29 /* AsyncIteratorFactory */:
|
|
1977
2068
|
return this.deserializeAsyncIteratorFactory(node);
|
|
2069
|
+
case 36 /* AbortSignalAbort */:
|
|
2070
|
+
return this.deserializeAbortSignalAbort(node);
|
|
2071
|
+
case 35 /* AbortSignalConstructor */:
|
|
2072
|
+
return this.deserializeAbortSignalConstructor(node);
|
|
2073
|
+
case 37 /* AbortSignalSync */:
|
|
2074
|
+
return this.deserializeAbortSignalSync(node);
|
|
2075
|
+
// case SerovalNodeType.SpecialReference:
|
|
1978
2076
|
default:
|
|
1979
2077
|
throw new SerovalUnsupportedNodeError(node);
|
|
1980
2078
|
}
|
|
@@ -2027,7 +2125,7 @@ function mergeAssignments(assignments) {
|
|
|
2027
2125
|
current = {
|
|
2028
2126
|
t: 0 /* Index */,
|
|
2029
2127
|
s: item.s,
|
|
2030
|
-
k:
|
|
2128
|
+
k: NIL,
|
|
2031
2129
|
v: getAssignmentExpression(current)
|
|
2032
2130
|
};
|
|
2033
2131
|
} else if (item.t === 2 /* Set */ && item.s === prev.s) {
|
|
@@ -2041,7 +2139,7 @@ function mergeAssignments(assignments) {
|
|
|
2041
2139
|
current = {
|
|
2042
2140
|
t: 1 /* Add */,
|
|
2043
2141
|
s: getAssignmentExpression(current),
|
|
2044
|
-
k:
|
|
2142
|
+
k: NIL,
|
|
2045
2143
|
v: item.v
|
|
2046
2144
|
};
|
|
2047
2145
|
} else if (item.t === 3 /* Delete */ && item.s === prev.s) {
|
|
@@ -2049,7 +2147,7 @@ function mergeAssignments(assignments) {
|
|
|
2049
2147
|
t: 3 /* Delete */,
|
|
2050
2148
|
s: getAssignmentExpression(current),
|
|
2051
2149
|
k: item.k,
|
|
2052
|
-
v:
|
|
2150
|
+
v: NIL
|
|
2053
2151
|
};
|
|
2054
2152
|
} else {
|
|
2055
2153
|
newAssignments.push(current);
|
|
@@ -2069,7 +2167,7 @@ function resolveAssignments(assignments) {
|
|
|
2069
2167
|
}
|
|
2070
2168
|
return result;
|
|
2071
2169
|
}
|
|
2072
|
-
return
|
|
2170
|
+
return NIL;
|
|
2073
2171
|
}
|
|
2074
2172
|
var NULL_CONSTRUCTOR = "Object.create(null)";
|
|
2075
2173
|
var SET_CONSTRUCTOR = "new Set";
|
|
@@ -2080,7 +2178,7 @@ var OBJECT_FLAG_CONSTRUCTOR = {
|
|
|
2080
2178
|
[3 /* Frozen */]: "Object.freeze",
|
|
2081
2179
|
[2 /* Sealed */]: "Object.seal",
|
|
2082
2180
|
[1 /* NonExtensible */]: "Object.preventExtensions",
|
|
2083
|
-
[0 /* None */]:
|
|
2181
|
+
[0 /* None */]: NIL
|
|
2084
2182
|
};
|
|
2085
2183
|
var BaseSerializerContext = class {
|
|
2086
2184
|
constructor(options) {
|
|
@@ -2166,7 +2264,7 @@ var BaseSerializerContext = class {
|
|
|
2166
2264
|
this.assignments.push({
|
|
2167
2265
|
t: 0 /* Index */,
|
|
2168
2266
|
s: source,
|
|
2169
|
-
k:
|
|
2267
|
+
k: NIL,
|
|
2170
2268
|
v: value
|
|
2171
2269
|
});
|
|
2172
2270
|
}
|
|
@@ -2174,7 +2272,7 @@ var BaseSerializerContext = class {
|
|
|
2174
2272
|
this.assignments.push({
|
|
2175
2273
|
t: 1 /* Add */,
|
|
2176
2274
|
s: this.getRefParam(ref),
|
|
2177
|
-
k:
|
|
2275
|
+
k: NIL,
|
|
2178
2276
|
v: value
|
|
2179
2277
|
});
|
|
2180
2278
|
}
|
|
@@ -2191,7 +2289,7 @@ var BaseSerializerContext = class {
|
|
|
2191
2289
|
t: 3 /* Delete */,
|
|
2192
2290
|
s: this.getRefParam(ref),
|
|
2193
2291
|
k: key,
|
|
2194
|
-
v:
|
|
2292
|
+
v: NIL
|
|
2195
2293
|
});
|
|
2196
2294
|
}
|
|
2197
2295
|
createArrayAssign(ref, index, value) {
|
|
@@ -2376,7 +2474,7 @@ var BaseSerializerContext = class {
|
|
|
2376
2474
|
this.stack.pop();
|
|
2377
2475
|
return resolveAssignments(mainAssignments);
|
|
2378
2476
|
}
|
|
2379
|
-
return
|
|
2477
|
+
return NIL;
|
|
2380
2478
|
}
|
|
2381
2479
|
serializeDictionary(node, init) {
|
|
2382
2480
|
if (node.p) {
|
|
@@ -2631,6 +2729,16 @@ var BaseSerializerContext = class {
|
|
|
2631
2729
|
'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
|
|
2632
2730
|
) + "})"
|
|
2633
2731
|
);
|
|
2732
|
+
case 5 /* AbortSignalConstructor */:
|
|
2733
|
+
return this.createFunction(
|
|
2734
|
+
["a", "s"],
|
|
2735
|
+
"((s=(a=new AbortController).signal).a=a,s)"
|
|
2736
|
+
);
|
|
2737
|
+
case 6 /* AbortSignalAbort */:
|
|
2738
|
+
return this.createEffectfulFunction(
|
|
2739
|
+
["s", "r"],
|
|
2740
|
+
"s.a.abort(r);delete s.a"
|
|
2741
|
+
);
|
|
2634
2742
|
default:
|
|
2635
2743
|
return "";
|
|
2636
2744
|
}
|
|
@@ -2742,6 +2850,18 @@ var BaseSerializerContext = class {
|
|
|
2742
2850
|
serializeStreamReturn(node) {
|
|
2743
2851
|
return this.getRefParam(node.i) + ".return(" + this.serialize(node.f) + ")";
|
|
2744
2852
|
}
|
|
2853
|
+
serializeAbortSignalSync(node) {
|
|
2854
|
+
return this.assignIndexedValue(
|
|
2855
|
+
node.i,
|
|
2856
|
+
"AbortSignal.abort(" + this.serialize(node.f) + ")"
|
|
2857
|
+
);
|
|
2858
|
+
}
|
|
2859
|
+
serializeAbortSignalConstructor(node) {
|
|
2860
|
+
return this.assignIndexedValue(node.i, this.getConstructor(node.f) + "()");
|
|
2861
|
+
}
|
|
2862
|
+
serializeAbortSignalAbort(node) {
|
|
2863
|
+
return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
|
|
2864
|
+
}
|
|
2745
2865
|
serialize(node) {
|
|
2746
2866
|
try {
|
|
2747
2867
|
switch (node.t) {
|
|
@@ -2814,6 +2934,12 @@ var BaseSerializerContext = class {
|
|
|
2814
2934
|
return this.serializeStreamThrow(node);
|
|
2815
2935
|
case 34 /* StreamReturn */:
|
|
2816
2936
|
return this.serializeStreamReturn(node);
|
|
2937
|
+
case 36 /* AbortSignalAbort */:
|
|
2938
|
+
return this.serializeAbortSignalAbort(node);
|
|
2939
|
+
case 35 /* AbortSignalConstructor */:
|
|
2940
|
+
return this.serializeAbortSignalConstructor(node);
|
|
2941
|
+
case 37 /* AbortSignalSync */:
|
|
2942
|
+
return this.serializeAbortSignalSync(node);
|
|
2817
2943
|
default:
|
|
2818
2944
|
throw new SerovalUnsupportedNodeError(node);
|
|
2819
2945
|
}
|
|
@@ -2942,7 +3068,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
2942
3068
|
return createErrorNode(
|
|
2943
3069
|
id,
|
|
2944
3070
|
current,
|
|
2945
|
-
options ? this.parseProperties(options) :
|
|
3071
|
+
options ? this.parseProperties(options) : NIL
|
|
2946
3072
|
);
|
|
2947
3073
|
}
|
|
2948
3074
|
parseAggregateError(id, current) {
|
|
@@ -2950,7 +3076,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
2950
3076
|
return createAggregateErrorNode(
|
|
2951
3077
|
id,
|
|
2952
3078
|
current,
|
|
2953
|
-
options ? this.parseProperties(options) :
|
|
3079
|
+
options ? this.parseProperties(options) : NIL
|
|
2954
3080
|
);
|
|
2955
3081
|
}
|
|
2956
3082
|
parseMap(id, current) {
|
|
@@ -2997,7 +3123,29 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
2997
3123
|
parsePromise(id, _current) {
|
|
2998
3124
|
return this.createPromiseConstructorNode(id);
|
|
2999
3125
|
}
|
|
3000
|
-
|
|
3126
|
+
parseAbortSignalSync(id, current) {
|
|
3127
|
+
return createSerovalNode(
|
|
3128
|
+
37 /* AbortSignalSync */,
|
|
3129
|
+
id,
|
|
3130
|
+
NIL,
|
|
3131
|
+
NIL,
|
|
3132
|
+
NIL,
|
|
3133
|
+
NIL,
|
|
3134
|
+
NIL,
|
|
3135
|
+
NIL,
|
|
3136
|
+
NIL,
|
|
3137
|
+
this.parse(current.reason),
|
|
3138
|
+
NIL,
|
|
3139
|
+
NIL
|
|
3140
|
+
);
|
|
3141
|
+
}
|
|
3142
|
+
parseAbortSignal(id, current) {
|
|
3143
|
+
if (current.aborted) {
|
|
3144
|
+
return this.parseAbortSignalSync(id, current);
|
|
3145
|
+
}
|
|
3146
|
+
return this.createAbortSignalConstructorNode(id);
|
|
3147
|
+
}
|
|
3148
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ehh
|
|
3001
3149
|
parseObject(id, current) {
|
|
3002
3150
|
if (Array.isArray(current)) {
|
|
3003
3151
|
return this.parseArray(id, current);
|
|
@@ -3070,6 +3218,9 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3070
3218
|
return this.parsePromise(id, current);
|
|
3071
3219
|
}
|
|
3072
3220
|
const currentFeatures = this.features;
|
|
3221
|
+
if (currentFeatures & 32 /* AbortSignal */ && typeof AbortSignal !== "undefined" && currentClass === AbortSignal) {
|
|
3222
|
+
return this.parseAbortSignal(id, current);
|
|
3223
|
+
}
|
|
3073
3224
|
if (currentFeatures & 16 /* BigIntTypedArray */) {
|
|
3074
3225
|
switch (currentClass) {
|
|
3075
3226
|
case BigInt64Array:
|
|
@@ -3093,6 +3244,17 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3093
3244
|
}
|
|
3094
3245
|
throw new SerovalUnsupportedTypeError(current);
|
|
3095
3246
|
}
|
|
3247
|
+
parseFunction(current) {
|
|
3248
|
+
const ref = this.getReference(current);
|
|
3249
|
+
if (ref.type !== 0 /* Fresh */) {
|
|
3250
|
+
return ref.value;
|
|
3251
|
+
}
|
|
3252
|
+
const plugin = this.parsePlugin(ref.value, current);
|
|
3253
|
+
if (plugin) {
|
|
3254
|
+
return plugin;
|
|
3255
|
+
}
|
|
3256
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
3257
|
+
}
|
|
3096
3258
|
parse(current) {
|
|
3097
3259
|
try {
|
|
3098
3260
|
switch (typeof current) {
|
|
@@ -3109,14 +3271,15 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3109
3271
|
case "object": {
|
|
3110
3272
|
if (current) {
|
|
3111
3273
|
const ref = this.getReference(current);
|
|
3112
|
-
return ref.type === 0 ? this.parseObject(ref.value, current) : ref.value;
|
|
3274
|
+
return ref.type === 0 /* Fresh */ ? this.parseObject(ref.value, current) : ref.value;
|
|
3113
3275
|
}
|
|
3114
3276
|
return NULL_NODE;
|
|
3115
3277
|
}
|
|
3116
3278
|
case "symbol":
|
|
3117
3279
|
return this.parseWellKnownSymbol(current);
|
|
3118
|
-
case "function":
|
|
3280
|
+
case "function": {
|
|
3119
3281
|
return this.parseFunction(current);
|
|
3282
|
+
}
|
|
3120
3283
|
default:
|
|
3121
3284
|
throw new SerovalUnsupportedTypeError(current);
|
|
3122
3285
|
}
|
|
@@ -3234,23 +3397,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3234
3397
|
(data) => {
|
|
3235
3398
|
const parsed = this.parseWithError(data);
|
|
3236
3399
|
if (parsed) {
|
|
3237
|
-
this.onParse(
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3400
|
+
this.onParse(
|
|
3401
|
+
createSerovalNode(
|
|
3402
|
+
23 /* PromiseResolve */,
|
|
3403
|
+
id,
|
|
3404
|
+
NIL,
|
|
3405
|
+
NIL,
|
|
3406
|
+
NIL,
|
|
3407
|
+
NIL,
|
|
3408
|
+
NIL,
|
|
3409
|
+
NIL,
|
|
3410
|
+
[
|
|
3411
|
+
this.parseSpecialReference(2 /* PromiseResolve */),
|
|
3412
|
+
parsed
|
|
3413
|
+
],
|
|
3414
|
+
NIL,
|
|
3415
|
+
NIL,
|
|
3416
|
+
NIL
|
|
3417
|
+
)
|
|
3418
|
+
);
|
|
3254
3419
|
}
|
|
3255
3420
|
this.popPendingState();
|
|
3256
3421
|
},
|
|
@@ -3258,23 +3423,25 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3258
3423
|
if (this.alive) {
|
|
3259
3424
|
const parsed = this.parseWithError(data);
|
|
3260
3425
|
if (parsed) {
|
|
3261
|
-
this.onParse(
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3426
|
+
this.onParse(
|
|
3427
|
+
createSerovalNode(
|
|
3428
|
+
24 /* PromiseReject */,
|
|
3429
|
+
id,
|
|
3430
|
+
NIL,
|
|
3431
|
+
NIL,
|
|
3432
|
+
NIL,
|
|
3433
|
+
NIL,
|
|
3434
|
+
NIL,
|
|
3435
|
+
NIL,
|
|
3436
|
+
[
|
|
3437
|
+
this.parseSpecialReference(3 /* PromiseReject */),
|
|
3438
|
+
parsed
|
|
3439
|
+
],
|
|
3440
|
+
NIL,
|
|
3441
|
+
NIL,
|
|
3442
|
+
NIL
|
|
3443
|
+
)
|
|
3444
|
+
);
|
|
3278
3445
|
}
|
|
3279
3446
|
}
|
|
3280
3447
|
this.popPendingState();
|
|
@@ -3299,7 +3466,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3299
3466
|
}
|
|
3300
3467
|
}
|
|
3301
3468
|
}
|
|
3302
|
-
return
|
|
3469
|
+
return NIL;
|
|
3303
3470
|
}
|
|
3304
3471
|
parseStream(id, current) {
|
|
3305
3472
|
const result = createStreamConstructorNode(
|
|
@@ -3338,12 +3505,51 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3338
3505
|
});
|
|
3339
3506
|
return result;
|
|
3340
3507
|
}
|
|
3508
|
+
handleAbortSignal(id, current) {
|
|
3509
|
+
if (this.alive) {
|
|
3510
|
+
const parsed = this.parseWithError(current.reason);
|
|
3511
|
+
if (parsed) {
|
|
3512
|
+
this.onParse(
|
|
3513
|
+
createSerovalNode(
|
|
3514
|
+
36 /* AbortSignalAbort */,
|
|
3515
|
+
id,
|
|
3516
|
+
NIL,
|
|
3517
|
+
NIL,
|
|
3518
|
+
NIL,
|
|
3519
|
+
NIL,
|
|
3520
|
+
NIL,
|
|
3521
|
+
NIL,
|
|
3522
|
+
[
|
|
3523
|
+
this.parseSpecialReference(6 /* AbortSignalAbort */),
|
|
3524
|
+
parsed
|
|
3525
|
+
],
|
|
3526
|
+
NIL,
|
|
3527
|
+
NIL,
|
|
3528
|
+
NIL
|
|
3529
|
+
)
|
|
3530
|
+
);
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
this.popPendingState();
|
|
3534
|
+
}
|
|
3535
|
+
parseAbortSignal(id, current) {
|
|
3536
|
+
if (current.aborted) {
|
|
3537
|
+
return this.parseAbortSignalSync(id, current);
|
|
3538
|
+
}
|
|
3539
|
+
this.pushPendingState();
|
|
3540
|
+
current.addEventListener(
|
|
3541
|
+
"abort",
|
|
3542
|
+
this.handleAbortSignal.bind(this, id, current),
|
|
3543
|
+
{ once: true }
|
|
3544
|
+
);
|
|
3545
|
+
return this.createAbortSignalConstructorNode(id);
|
|
3546
|
+
}
|
|
3341
3547
|
parseWithError(current) {
|
|
3342
3548
|
try {
|
|
3343
3549
|
return this.parse(current);
|
|
3344
3550
|
} catch (err) {
|
|
3345
3551
|
this.onError(err);
|
|
3346
|
-
return
|
|
3552
|
+
return NIL;
|
|
3347
3553
|
}
|
|
3348
3554
|
}
|
|
3349
3555
|
/**
|
|
@@ -3469,9 +3675,7 @@ function crossSerializeStream(source, options) {
|
|
|
3469
3675
|
onDone: options.onDone
|
|
3470
3676
|
});
|
|
3471
3677
|
ctx.start(source);
|
|
3472
|
-
return ()
|
|
3473
|
-
ctx.destroy();
|
|
3474
|
-
};
|
|
3678
|
+
return ctx.destroy.bind(ctx);
|
|
3475
3679
|
}
|
|
3476
3680
|
function toCrossJSONStream(source, options) {
|
|
3477
3681
|
const plugins = resolvePlugins(options.plugins);
|
|
@@ -3484,9 +3688,7 @@ function toCrossJSONStream(source, options) {
|
|
|
3484
3688
|
onDone: options.onDone
|
|
3485
3689
|
});
|
|
3486
3690
|
ctx.start(source);
|
|
3487
|
-
return ()
|
|
3488
|
-
ctx.destroy();
|
|
3489
|
-
};
|
|
3691
|
+
return ctx.destroy.bind(ctx);
|
|
3490
3692
|
}
|
|
3491
3693
|
function fromCrossJSON(source, options) {
|
|
3492
3694
|
const plugins = resolvePlugins(options.plugins);
|
|
@@ -3585,6 +3787,9 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
|
|
|
3585
3787
|
serializePromiseReject(node) {
|
|
3586
3788
|
throw new SerovalUnsupportedNodeError(node);
|
|
3587
3789
|
}
|
|
3790
|
+
serializeAbortSignalAbort(node) {
|
|
3791
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
3792
|
+
}
|
|
3588
3793
|
serializeTop(tree) {
|
|
3589
3794
|
const result = this.serialize(tree);
|
|
3590
3795
|
if (tree.i != null && this.vars.length) {
|