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