@qredence/fleet 0.10.1 → 0.10.3
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/CHANGELOG.md +21 -0
- package/dist/runtime-manifest.json +14 -14
- package/dist/web/client/assets/{artifacts-panel-6JEdy6jU.js → artifacts-panel-CfWH5cQn.js} +1 -1
- package/dist/web/client/assets/{chat-command-palette-Bxr5EkO6.js → chat-command-palette-CKGrP-Ke.js} +1 -1
- package/dist/web/client/assets/{ease-DYVhTl2n.js → ease-nNJMFgD_.js} +1 -1
- package/dist/web/client/assets/globals-C6h6fq-s.css +2 -0
- package/dist/web/client/assets/index-DJDQWCGd.js +12 -0
- package/dist/web/client/assets/{model-selector-list-CbDAT0Rw.js → model-selector-list-CIJArf3L.js} +1 -1
- package/dist/web/client/assets/{prompt-input-CoV1gTUQ.js → prompt-input-0kaw0ekd.js} +1 -1
- package/dist/web/client/assets/{right-panel-registry-BAJ6TuEY.js → right-panel-registry-BkBAryPm.js} +2 -2
- package/dist/web/client/assets/routes-C6C0y-oH.js +14 -0
- package/dist/web/client/assets/{session-activity-panel-DwaXiSrS.js → session-activity-panel-BloVPsLJ.js} +1 -1
- package/dist/web/client/assets/{session-tool-renderer-DEABxZG3.js → session-tool-renderer-CGMatufW.js} +1 -1
- package/dist/web/client/assets/{subagent-chat-panel-R2RoX1Yt.js → subagent-chat-panel-xm-zBsFL.js} +1 -1
- package/dist/web/client/assets/{subagent-transcript-DVZhMo7a.js → subagent-transcript-BzToBVWk.js} +1 -1
- package/dist/web/client/assets/{subagents-panel-CMMRUP8F.js → subagents-panel-B5ooG4sS.js} +1 -1
- package/dist/web/client/assets/{tool-part-normalizer-CF6bmJ0s.js → tool-part-normalizer-CJ2sY87r.js} +1 -1
- package/dist/web/client/assets/{tool-result-7qREIVv_.js → tool-result-C_RIixge.js} +4 -4
- package/dist/web/client/assets/{tool-timeline-CGhwMeNl.js → tool-timeline-BVY5VQ3a.js} +2 -2
- package/dist/web/client/assets/{use-reduced-motion-CFEp5oKr.js → use-reduced-motion-69Ji0Qlf.js} +1 -1
- package/dist/web/client/assets/workspace-panel-DsZZnfkm.js +1 -0
- package/dist/web/client/bundle-budget.json +5 -5
- package/dist/web/server/{_tanstack-start-manifest_v-BiMhF9NX-QUZEGAB6.js → _tanstack-start-manifest_v-Cs4JeecK-7Q7PABV3.js} +9 -9
- package/dist/web/server/{agents-DOgCHixY-KUZP2VDO.js → agents-DOgCHixY-TU7YLWS2.js} +1 -1
- package/dist/web/server/{agents-page-BdiR9H8w-M6X6SXMF.js → agents-page-BdiR9H8w-UXB7T3LH.js} +2 -2
- package/dist/web/server/{artifacts-panel-BNiaRF83-HDC6VQ66.js → artifacts-panel-DjaLT-MS-DAPJTA2V.js} +6 -6
- package/dist/web/server/{chat-command-palette-CT9aJAWG-LV26BDEW.js → chat-command-palette-CGCsCr9E-U5PCLXNE.js} +4 -4
- package/dist/web/server/{chunk-5XRESJQR.js → chunk-2Y2543CV.js} +3 -3
- package/dist/web/server/{chunk-4YQ7RBB7.js → chunk-3LAD2C43.js} +3 -3
- package/dist/web/server/{chunk-RX2ZJARF.js → chunk-4OLRCVML.js} +2 -21
- package/dist/web/server/{chunk-35RIM6VP.js → chunk-CPB76YQU.js} +1251 -740
- package/dist/web/server/{chunk-2ETDIMNM.js → chunk-ETVLY2KE.js} +1 -1
- package/dist/web/server/{chunk-4TKPOOIG.js → chunk-MEAWBN4N.js} +4 -4
- package/dist/web/server/{chunk-KBMRRJQN.js → chunk-PBNUO4IN.js} +2 -2
- package/dist/web/server/{chunk-LEZMRXSP.js → chunk-QWJE6ES6.js} +37 -24
- package/dist/web/server/{chunk-3CU2ITG7.js → chunk-UULUKSQD.js} +170 -529
- package/dist/web/server/{chunk-3R7XCOWI.js → chunk-UZ2KHDSW.js} +5 -5
- package/dist/web/server/{chunk-27J2LPAW.js → chunk-VBCFQNR3.js} +2 -2
- package/dist/web/server/{connectors-Dv_uPdv0-2X5VWQXK.js → connectors-Dv_uPdv0-2TCNQ3TU.js} +1 -1
- package/dist/web/server/{connectors-page-DW75T-uH-EKRHUZ6K.js → connectors-page-DW75T-uH-BR36R6FT.js} +2 -2
- package/dist/web/server/{create-project-dialog-EwieT1Vw-X5MYQSZM.js → create-project-dialog-aCD1v__i-37Y2AYF7.js} +4 -4
- package/dist/web/server/{model-selector-list-By_G7_Hr-GXT27BZO.js → model-selector-list-q8bMnmhy-SPFJGUBT.js} +2 -2
- package/dist/web/server/{openui-renderer-DCkg_JoD-4QCKSVY5.js → openui-renderer-DNl7TU3v-LAP3OM5H.js} +3 -3
- package/dist/web/server/{resources-panel-s0mgyvgQ-FVMBBLJJ.js → resources-panel-Dtm8nlrt-PMS7NWKW.js} +5 -5
- package/dist/web/server/{router-DXxChQOI-B7VVEX3H.js → router-CFtn3QOM-3WK4R4UB.js} +2 -2
- package/dist/web/server/{routes-D-g2ILNg-LDYCQ4NU.js → routes-CpT-KFt7-F6WEPWF6.js} +3 -3
- package/dist/web/server/server.js +1415 -1004
- package/dist/web/server/{session-activity-panel-wC0jAJvs-QAHJXPAM.js → session-activity-panel-Dr9Q0Wmd-2F7ZYCAY.js} +5 -5
- package/dist/web/server/{session-reasoning-panel-B_K8YgF5-AQPMFM3Y.js → session-reasoning-panel-BFyfdmnZ-AQBC4WAL.js} +4 -4
- package/dist/web/server/{session-tool-renderer-D96BACVh-CH5CV3TS.js → session-tool-renderer-DHu5tv0A-YFP7I2UC.js} +5 -5
- package/dist/web/server/{session-tree-panel-CZGXNZIP-FBB3XGMN.js → session-tree-panel-BkMTm2QF-K56UQR2K.js} +4 -4
- package/dist/web/server/{settings-dialog-BrjqiTVe-H7WOTB4I.js → settings-dialog-1Zr_EiEd-GDE4IXK2.js} +5 -5
- package/dist/web/server/{subagent-chat-panel-Dz62jo_m-X4ZRN5KI.js → subagent-chat-panel-BCm1x_mR-HY6QEHEF.js} +8 -8
- package/dist/web/server/{subagents-panel-CwpbzJJz-N3ISHODM.js → subagents-panel-3gfZLsTx-7D53UO7K.js} +8 -8
- package/dist/web/server/{workspace-panel-C7akv5b9-XUKEHPOP.js → workspace-panel-BeSOuvp7-7N3CAG2K.js} +5 -5
- package/package.json +1 -1
- package/dist/web/client/assets/globals-DDDleTbS.css +0 -2
- package/dist/web/client/assets/index-CEZTSuLf.js +0 -13
- package/dist/web/client/assets/routes-EKRITFZz.js +0 -14
- package/dist/web/client/assets/workspace-panel-Da5I4p_t.js +0 -1
|
@@ -4334,7 +4334,7 @@ function createSerializationAdapter(opts) {
|
|
|
4334
4334
|
return opts;
|
|
4335
4335
|
}
|
|
4336
4336
|
|
|
4337
|
-
// node_modules/.pnpm/seroval@1.
|
|
4337
|
+
// node_modules/.pnpm/seroval@1.7.1/node_modules/seroval/dist/index.js
|
|
4338
4338
|
var SYM_ASYNC_ITERATOR = Symbol.asyncIterator;
|
|
4339
4339
|
var SYM_HAS_INSTANCE = Symbol.hasInstance;
|
|
4340
4340
|
var SYM_IS_CONCAT_SPREADABLE = Symbol.isConcatSpreadable;
|
|
@@ -4348,36 +4348,43 @@ var SYM_SPLIT = Symbol.split;
|
|
|
4348
4348
|
var SYM_TO_PRIMITIVE = Symbol.toPrimitive;
|
|
4349
4349
|
var SYM_TO_STRING_TAG = Symbol.toStringTag;
|
|
4350
4350
|
var SYM_UNSCOPABLES = Symbol.unscopables;
|
|
4351
|
-
var
|
|
4352
|
-
[0]: "
|
|
4353
|
-
[1]: "
|
|
4354
|
-
[2]: "
|
|
4355
|
-
[3]: "
|
|
4356
|
-
[4]: "
|
|
4357
|
-
[5]: "
|
|
4358
|
-
[6]: "
|
|
4359
|
-
[7]: "
|
|
4360
|
-
[8]: "Symbol.species",
|
|
4361
|
-
[9]: "Symbol.split",
|
|
4362
|
-
[10]: "Symbol.toPrimitive",
|
|
4363
|
-
[11]: "Symbol.toStringTag",
|
|
4364
|
-
[12]: "Symbol.unscopables"
|
|
4351
|
+
var TEMPORAL_TYPE_NAME = {
|
|
4352
|
+
[0]: "Instant",
|
|
4353
|
+
[1]: "Duration",
|
|
4354
|
+
[2]: "PlainDate",
|
|
4355
|
+
[3]: "PlainDateTime",
|
|
4356
|
+
[4]: "PlainMonthDay",
|
|
4357
|
+
[5]: "PlainTime",
|
|
4358
|
+
[6]: "PlainYearMonth",
|
|
4359
|
+
[7]: "ZonedDateTime"
|
|
4365
4360
|
};
|
|
4366
|
-
var
|
|
4367
|
-
[
|
|
4368
|
-
[
|
|
4369
|
-
[
|
|
4370
|
-
[
|
|
4371
|
-
[
|
|
4372
|
-
[
|
|
4373
|
-
[
|
|
4374
|
-
[
|
|
4375
|
-
[
|
|
4376
|
-
[
|
|
4377
|
-
[
|
|
4378
|
-
[
|
|
4379
|
-
[
|
|
4361
|
+
var SYMBOL_REF = {
|
|
4362
|
+
[0]: SYM_ASYNC_ITERATOR,
|
|
4363
|
+
[1]: SYM_HAS_INSTANCE,
|
|
4364
|
+
[2]: SYM_IS_CONCAT_SPREADABLE,
|
|
4365
|
+
[3]: SYM_ITERATOR,
|
|
4366
|
+
[4]: SYM_MATCH,
|
|
4367
|
+
[5]: SYM_MATCH_ALL,
|
|
4368
|
+
[6]: SYM_REPLACE,
|
|
4369
|
+
[7]: SYM_SEARCH,
|
|
4370
|
+
[8]: SYM_SPECIES,
|
|
4371
|
+
[9]: SYM_SPLIT,
|
|
4372
|
+
[10]: SYM_TO_PRIMITIVE,
|
|
4373
|
+
[11]: SYM_TO_STRING_TAG,
|
|
4374
|
+
[12]: SYM_UNSCOPABLES
|
|
4380
4375
|
};
|
|
4376
|
+
function createSymbolStringTable() {
|
|
4377
|
+
const result = {};
|
|
4378
|
+
for (let i = 0; i <= 12; i++) result[i] = SYMBOL_REF[i].description;
|
|
4379
|
+
return result;
|
|
4380
|
+
}
|
|
4381
|
+
var SYMBOL_STRING = /* @__PURE__ */ createSymbolStringTable();
|
|
4382
|
+
function createInverseSymbolTable() {
|
|
4383
|
+
const result = {};
|
|
4384
|
+
for (let i = 0; i <= 12; i++) result[SYMBOL_REF[i]] = i;
|
|
4385
|
+
return result;
|
|
4386
|
+
}
|
|
4387
|
+
var INV_SYMBOL_REF = /* @__PURE__ */ createInverseSymbolTable();
|
|
4381
4388
|
var CONSTANT_STRING = {
|
|
4382
4389
|
[2]: "!0",
|
|
4383
4390
|
[3]: "!1",
|
|
@@ -4388,26 +4395,27 @@ var CONSTANT_STRING = {
|
|
|
4388
4395
|
[6]: "-1/0",
|
|
4389
4396
|
[7]: "0/0"
|
|
4390
4397
|
};
|
|
4391
|
-
var
|
|
4392
|
-
[
|
|
4393
|
-
[
|
|
4394
|
-
[
|
|
4395
|
-
[
|
|
4396
|
-
[4]:
|
|
4397
|
-
[5]:
|
|
4398
|
-
[6]:
|
|
4399
|
-
[7]: NaN
|
|
4400
|
-
};
|
|
4401
|
-
var ERROR_CONSTRUCTOR_STRING = {
|
|
4402
|
-
[0]: "Error",
|
|
4403
|
-
[1]: "EvalError",
|
|
4404
|
-
[2]: "RangeError",
|
|
4405
|
-
[3]: "ReferenceError",
|
|
4406
|
-
[4]: "SyntaxError",
|
|
4407
|
-
[5]: "TypeError",
|
|
4408
|
-
[6]: "URIError"
|
|
4398
|
+
var ERROR_CONSTRUCTOR = {
|
|
4399
|
+
[0]: Error,
|
|
4400
|
+
[1]: EvalError,
|
|
4401
|
+
[2]: RangeError,
|
|
4402
|
+
[3]: ReferenceError,
|
|
4403
|
+
[4]: SyntaxError,
|
|
4404
|
+
[5]: TypeError,
|
|
4405
|
+
[6]: URIError
|
|
4409
4406
|
};
|
|
4407
|
+
function createErrorConstructorStringTable() {
|
|
4408
|
+
const result = {};
|
|
4409
|
+
for (let i = 0; i <= 6; i++) result[i] = ERROR_CONSTRUCTOR[i].name;
|
|
4410
|
+
return result;
|
|
4411
|
+
}
|
|
4412
|
+
var ERROR_CONSTRUCTOR_STRING = /* @__PURE__ */ createErrorConstructorStringTable();
|
|
4410
4413
|
function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o, l) {
|
|
4414
|
+
if (c === void 0 && m === void 0 && p === void 0 && e === void 0 && a === void 0 && f === void 0 && b === void 0 && o === void 0 && l === void 0) return {
|
|
4415
|
+
t,
|
|
4416
|
+
i,
|
|
4417
|
+
s
|
|
4418
|
+
};
|
|
4411
4419
|
return {
|
|
4412
4420
|
t,
|
|
4413
4421
|
i,
|
|
@@ -4424,7 +4432,7 @@ function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o, l) {
|
|
|
4424
4432
|
};
|
|
4425
4433
|
}
|
|
4426
4434
|
function createConstantNode(value) {
|
|
4427
|
-
return createSerovalNode(2, void 0, value
|
|
4435
|
+
return createSerovalNode(2, void 0, value);
|
|
4428
4436
|
}
|
|
4429
4437
|
var TRUE_NODE = /* @__PURE__ */ createConstantNode(2);
|
|
4430
4438
|
var FALSE_NODE = /* @__PURE__ */ createConstantNode(3);
|
|
@@ -4435,80 +4443,116 @@ var INFINITY_NODE = /* @__PURE__ */ createConstantNode(5);
|
|
|
4435
4443
|
var NEG_INFINITY_NODE = /* @__PURE__ */ createConstantNode(6);
|
|
4436
4444
|
var NAN_NODE = /* @__PURE__ */ createConstantNode(7);
|
|
4437
4445
|
var MIN_JSON_STRINGIFY_LENGTH = 64;
|
|
4438
|
-
var
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4446
|
+
var NEEDS_ESCAPE = /["\\\n\r\b\t\f<\u2028\u2029]/;
|
|
4447
|
+
var JSON_ESCAPE_DIFFERENCES = /[\x00-\x07\x0b\x0e-\x1f\ud800-\udfff]/;
|
|
4448
|
+
var LESS_THAN = /</g;
|
|
4449
|
+
var LINE_SEPARATOR = /\u2028/g;
|
|
4450
|
+
var PARAGRAPH_SEPARATOR = /\u2029/g;
|
|
4451
|
+
function escapeCharCode(code) {
|
|
4452
|
+
switch (code) {
|
|
4453
|
+
case 34:
|
|
4442
4454
|
return '\\"';
|
|
4443
|
-
case
|
|
4455
|
+
case 92:
|
|
4444
4456
|
return "\\\\";
|
|
4445
|
-
case
|
|
4457
|
+
case 10:
|
|
4446
4458
|
return "\\n";
|
|
4447
|
-
case
|
|
4459
|
+
case 13:
|
|
4448
4460
|
return "\\r";
|
|
4449
|
-
case
|
|
4461
|
+
case 8:
|
|
4450
4462
|
return "\\b";
|
|
4451
|
-
case
|
|
4463
|
+
case 9:
|
|
4452
4464
|
return "\\t";
|
|
4453
|
-
case
|
|
4465
|
+
case 12:
|
|
4454
4466
|
return "\\f";
|
|
4455
|
-
case
|
|
4467
|
+
case 60:
|
|
4456
4468
|
return "\\x3C";
|
|
4457
|
-
case
|
|
4469
|
+
case 8232:
|
|
4458
4470
|
return "\\u2028";
|
|
4459
|
-
case
|
|
4471
|
+
case 8233:
|
|
4460
4472
|
return "\\u2029";
|
|
4461
4473
|
default:
|
|
4462
4474
|
return;
|
|
4463
4475
|
}
|
|
4464
4476
|
}
|
|
4465
4477
|
function serializeString(str) {
|
|
4466
|
-
if (
|
|
4478
|
+
if (!NEEDS_ESCAPE.test(str)) return str;
|
|
4479
|
+
if (str.length >= MIN_JSON_STRINGIFY_LENGTH && !JSON_ESCAPE_DIFFERENCES.test(str)) {
|
|
4480
|
+
let result2 = JSON.stringify(str).slice(1, -1);
|
|
4481
|
+
if (result2.includes("<")) result2 = result2.replace(LESS_THAN, "\\x3C");
|
|
4482
|
+
if (result2.includes("\u2028")) result2 = result2.replace(LINE_SEPARATOR, "\\u2028");
|
|
4483
|
+
if (result2.includes("\u2029")) result2 = result2.replace(PARAGRAPH_SEPARATOR, "\\u2029");
|
|
4484
|
+
return result2;
|
|
4485
|
+
}
|
|
4467
4486
|
let result = "";
|
|
4468
4487
|
let lastPos = 0;
|
|
4469
4488
|
let replacement;
|
|
4470
4489
|
for (let i = 0, len = str.length; i < len; i++) {
|
|
4471
|
-
replacement =
|
|
4490
|
+
replacement = escapeCharCode(str.charCodeAt(i));
|
|
4472
4491
|
if (replacement) {
|
|
4473
4492
|
result += str.slice(lastPos, i) + replacement;
|
|
4474
4493
|
lastPos = i + 1;
|
|
4475
4494
|
}
|
|
4476
4495
|
}
|
|
4477
|
-
|
|
4478
|
-
else result += str.slice(lastPos);
|
|
4479
|
-
return result;
|
|
4480
|
-
}
|
|
4481
|
-
function deserializeReplacer(str) {
|
|
4482
|
-
switch (str) {
|
|
4483
|
-
case "\\\\":
|
|
4484
|
-
return "\\";
|
|
4485
|
-
case '\\"':
|
|
4486
|
-
return '"';
|
|
4487
|
-
case "\\n":
|
|
4488
|
-
return "\n";
|
|
4489
|
-
case "\\r":
|
|
4490
|
-
return "\r";
|
|
4491
|
-
case "\\b":
|
|
4492
|
-
return "\b";
|
|
4493
|
-
case "\\t":
|
|
4494
|
-
return " ";
|
|
4495
|
-
case "\\f":
|
|
4496
|
-
return "\f";
|
|
4497
|
-
case "\\x3C":
|
|
4498
|
-
return "<";
|
|
4499
|
-
case "\\u2028":
|
|
4500
|
-
return "\u2028";
|
|
4501
|
-
case "\\u2029":
|
|
4502
|
-
return "\u2029";
|
|
4503
|
-
default:
|
|
4504
|
-
return str;
|
|
4505
|
-
}
|
|
4496
|
+
return result + str.slice(lastPos);
|
|
4506
4497
|
}
|
|
4498
|
+
var JSON_COMPATIBLE = /^(?:[^"\\\x00-\x1f]|\\["\\nrbtf])*$/;
|
|
4499
|
+
var ESCAPE_SEQUENCE = /(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g;
|
|
4507
4500
|
function deserializeString(str) {
|
|
4508
|
-
if (typeof str
|
|
4509
|
-
|
|
4501
|
+
if (typeof str !== "string") return str.replace(ESCAPE_SEQUENCE, deserializeString);
|
|
4502
|
+
let index = str.indexOf("\\");
|
|
4503
|
+
if (index === -1) return str;
|
|
4504
|
+
if (JSON_COMPATIBLE.test(str)) return JSON.parse('"' + str + '"');
|
|
4505
|
+
let result = "";
|
|
4506
|
+
let lastPos = 0;
|
|
4507
|
+
const last2 = str.length - 1;
|
|
4508
|
+
while (index !== -1 && index < last2) {
|
|
4509
|
+
let replacement;
|
|
4510
|
+
let length = 2;
|
|
4511
|
+
switch (str.charCodeAt(index + 1)) {
|
|
4512
|
+
case 92:
|
|
4513
|
+
replacement = "\\";
|
|
4514
|
+
break;
|
|
4515
|
+
case 34:
|
|
4516
|
+
replacement = '"';
|
|
4517
|
+
break;
|
|
4518
|
+
case 110:
|
|
4519
|
+
replacement = "\n";
|
|
4520
|
+
break;
|
|
4521
|
+
case 114:
|
|
4522
|
+
replacement = "\r";
|
|
4523
|
+
break;
|
|
4524
|
+
case 98:
|
|
4525
|
+
replacement = "\b";
|
|
4526
|
+
break;
|
|
4527
|
+
case 116:
|
|
4528
|
+
replacement = " ";
|
|
4529
|
+
break;
|
|
4530
|
+
case 102:
|
|
4531
|
+
replacement = "\f";
|
|
4532
|
+
break;
|
|
4533
|
+
case 120:
|
|
4534
|
+
if (str.startsWith("3C", index + 2)) {
|
|
4535
|
+
replacement = "<";
|
|
4536
|
+
length = 4;
|
|
4537
|
+
}
|
|
4538
|
+
break;
|
|
4539
|
+
case 117:
|
|
4540
|
+
if (str.startsWith("2028", index + 2)) {
|
|
4541
|
+
replacement = "\u2028";
|
|
4542
|
+
length = 6;
|
|
4543
|
+
} else if (str.startsWith("2029", index + 2)) {
|
|
4544
|
+
replacement = "\u2029";
|
|
4545
|
+
length = 6;
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4548
|
+
if (replacement) {
|
|
4549
|
+
result += str.slice(lastPos, index) + replacement;
|
|
4550
|
+
lastPos = index + length;
|
|
4551
|
+
index = str.indexOf("\\", lastPos);
|
|
4552
|
+
} else index = str.indexOf("\\", index + 1);
|
|
4553
|
+
}
|
|
4554
|
+
return result + str.slice(lastPos);
|
|
4510
4555
|
}
|
|
4511
|
-
var { toString: objectToString } = Object.prototype;
|
|
4512
4556
|
var STEP_ERROR_CODES = {
|
|
4513
4557
|
parsing: 1,
|
|
4514
4558
|
serialization: 2,
|
|
@@ -4517,10 +4561,9 @@ var STEP_ERROR_CODES = {
|
|
|
4517
4561
|
function getErrorMessageProd(type) {
|
|
4518
4562
|
return `Seroval Error (step: ${STEP_ERROR_CODES[type]})`;
|
|
4519
4563
|
}
|
|
4520
|
-
var getErrorMessage = (type, cause) => getErrorMessageProd(type);
|
|
4521
4564
|
var SerovalError = class extends Error {
|
|
4522
4565
|
constructor(type, cause) {
|
|
4523
|
-
super(
|
|
4566
|
+
super(getErrorMessageProd(type));
|
|
4524
4567
|
this.cause = cause;
|
|
4525
4568
|
}
|
|
4526
4569
|
};
|
|
@@ -4529,6 +4572,11 @@ var SerovalParserError = class extends SerovalError {
|
|
|
4529
4572
|
super("parsing", cause);
|
|
4530
4573
|
}
|
|
4531
4574
|
};
|
|
4575
|
+
var SerovalSerializationError = class extends SerovalError {
|
|
4576
|
+
constructor(cause) {
|
|
4577
|
+
super("serialization", cause);
|
|
4578
|
+
}
|
|
4579
|
+
};
|
|
4532
4580
|
function getSpecificErrorMessage(code) {
|
|
4533
4581
|
return `Seroval Error (specific: ${code})`;
|
|
4534
4582
|
}
|
|
@@ -4548,96 +4596,73 @@ var SerovalMissingPluginError = class extends Error {
|
|
|
4548
4596
|
super(getSpecificErrorMessage(3));
|
|
4549
4597
|
}
|
|
4550
4598
|
};
|
|
4551
|
-
var
|
|
4552
|
-
constructor(
|
|
4553
|
-
super(getSpecificErrorMessage(
|
|
4554
|
-
this.value = value;
|
|
4599
|
+
var SerovalUnknownTypedArrayError = class extends Error {
|
|
4600
|
+
constructor(name) {
|
|
4601
|
+
super(getSpecificErrorMessage(7));
|
|
4555
4602
|
}
|
|
4556
4603
|
};
|
|
4557
4604
|
var SerovalDepthLimitError = class extends Error {
|
|
4558
4605
|
constructor(limit) {
|
|
4559
|
-
super(getSpecificErrorMessage(
|
|
4606
|
+
super(getSpecificErrorMessage(10));
|
|
4607
|
+
}
|
|
4608
|
+
};
|
|
4609
|
+
var SerovalLiveStreamError = class extends Error {
|
|
4610
|
+
constructor(reason) {
|
|
4611
|
+
super(getSpecificErrorMessage(12));
|
|
4612
|
+
this.reason = reason;
|
|
4560
4613
|
}
|
|
4561
4614
|
};
|
|
4562
|
-
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
4563
|
-
var GLOBAL_CONTEXT_R = `self.$R`;
|
|
4564
|
-
function getCrossReferenceHeader(id) {
|
|
4565
|
-
if (id == null) return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[]`;
|
|
4566
|
-
return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(id)}"]=[]`;
|
|
4567
|
-
}
|
|
4568
|
-
var REFERENCE = /* @__PURE__ */ new Map();
|
|
4569
|
-
var INV_REFERENCE = /* @__PURE__ */ new Map();
|
|
4570
|
-
function hasReferenceID(value) {
|
|
4571
|
-
return REFERENCE.has(value);
|
|
4572
|
-
}
|
|
4573
|
-
function getReferenceID(value) {
|
|
4574
|
-
if (hasReferenceID(value)) return REFERENCE.get(value);
|
|
4575
|
-
throw new SerovalMissingReferenceError(value);
|
|
4576
|
-
}
|
|
4577
|
-
if (typeof globalThis !== "undefined") Object.defineProperty(globalThis, REFERENCES_KEY, {
|
|
4578
|
-
value: INV_REFERENCE,
|
|
4579
|
-
configurable: true,
|
|
4580
|
-
writable: false,
|
|
4581
|
-
enumerable: false
|
|
4582
|
-
});
|
|
4583
|
-
else if (typeof window !== "undefined") Object.defineProperty(window, REFERENCES_KEY, {
|
|
4584
|
-
value: INV_REFERENCE,
|
|
4585
|
-
configurable: true,
|
|
4586
|
-
writable: false,
|
|
4587
|
-
enumerable: false
|
|
4588
|
-
});
|
|
4589
|
-
else if (typeof self !== "undefined") Object.defineProperty(self, REFERENCES_KEY, {
|
|
4590
|
-
value: INV_REFERENCE,
|
|
4591
|
-
configurable: true,
|
|
4592
|
-
writable: false,
|
|
4593
|
-
enumerable: false
|
|
4594
|
-
});
|
|
4595
|
-
else if (typeof global !== "undefined") Object.defineProperty(global, REFERENCES_KEY, {
|
|
4596
|
-
value: INV_REFERENCE,
|
|
4597
|
-
configurable: true,
|
|
4598
|
-
writable: false,
|
|
4599
|
-
enumerable: false
|
|
4600
|
-
});
|
|
4601
4615
|
function getErrorConstructor(error) {
|
|
4602
|
-
if (error instanceof
|
|
4603
|
-
if (error instanceof RangeError) return 2;
|
|
4604
|
-
if (error instanceof ReferenceError) return 3;
|
|
4605
|
-
if (error instanceof SyntaxError) return 4;
|
|
4606
|
-
if (error instanceof TypeError) return 5;
|
|
4607
|
-
if (error instanceof URIError) return 6;
|
|
4616
|
+
for (let i = 1; i <= 6; i++) if (error instanceof ERROR_CONSTRUCTOR[i]) return i;
|
|
4608
4617
|
return 0;
|
|
4609
4618
|
}
|
|
4610
|
-
function getInitialErrorOptions(error) {
|
|
4611
|
-
const construct = ERROR_CONSTRUCTOR_STRING[getErrorConstructor(error)];
|
|
4612
|
-
if (error.name !== construct) return { name: error.name };
|
|
4613
|
-
if (error.constructor.name !== construct) return { name: error.constructor.name };
|
|
4614
|
-
return {};
|
|
4615
|
-
}
|
|
4616
4619
|
function getErrorOptions(error, features) {
|
|
4617
|
-
|
|
4618
|
-
const
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
if (name === "stack") {
|
|
4623
|
-
if (features & 4) {
|
|
4624
|
-
options = options || {};
|
|
4625
|
-
options[name] = error[name];
|
|
4626
|
-
}
|
|
4627
|
-
} else {
|
|
4628
|
-
options = options || {};
|
|
4629
|
-
options[name] = error[name];
|
|
4630
|
-
}
|
|
4631
|
-
}
|
|
4632
|
-
}
|
|
4620
|
+
const options = /* @__PURE__ */ Object.create(null);
|
|
4621
|
+
const construct = ERROR_CONSTRUCTOR_STRING[getErrorConstructor(error)];
|
|
4622
|
+
if (error.name !== construct) options.name = error.name;
|
|
4623
|
+
else if (error.constructor.name !== construct) options.name = error.constructor.name;
|
|
4624
|
+
for (const name of Object.getOwnPropertyNames(error)) if (name !== "name" && name !== "message" && (name !== "stack" || features & 4)) options[name] = error[name];
|
|
4633
4625
|
return options;
|
|
4634
4626
|
}
|
|
4635
4627
|
function getObjectFlag(obj) {
|
|
4628
|
+
if (Object.isExtensible(obj)) return 0;
|
|
4636
4629
|
if (Object.isFrozen(obj)) return 3;
|
|
4637
4630
|
if (Object.isSealed(obj)) return 2;
|
|
4638
|
-
if (Object.isExtensible(obj)) return 0;
|
|
4639
4631
|
return 1;
|
|
4640
4632
|
}
|
|
4633
|
+
function getTypedArrayConstructor(name) {
|
|
4634
|
+
switch (name) {
|
|
4635
|
+
case "Int8Array":
|
|
4636
|
+
return Int8Array;
|
|
4637
|
+
case "Int16Array":
|
|
4638
|
+
return Int16Array;
|
|
4639
|
+
case "Int32Array":
|
|
4640
|
+
return Int32Array;
|
|
4641
|
+
case "Uint8Array":
|
|
4642
|
+
return Uint8Array;
|
|
4643
|
+
case "Uint16Array":
|
|
4644
|
+
return Uint16Array;
|
|
4645
|
+
case "Uint32Array":
|
|
4646
|
+
return Uint32Array;
|
|
4647
|
+
case "Uint8ClampedArray":
|
|
4648
|
+
return Uint8ClampedArray;
|
|
4649
|
+
case "Float32Array":
|
|
4650
|
+
return Float32Array;
|
|
4651
|
+
case "Float64Array":
|
|
4652
|
+
return Float64Array;
|
|
4653
|
+
case "BigInt64Array":
|
|
4654
|
+
return BigInt64Array;
|
|
4655
|
+
case "BigUint64Array":
|
|
4656
|
+
return BigUint64Array;
|
|
4657
|
+
default:
|
|
4658
|
+
throw new SerovalUnknownTypedArrayError(name);
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
var typedArrayNameGetter;
|
|
4662
|
+
function getTypedArrayName(value) {
|
|
4663
|
+
if (!typedArrayNameGetter) typedArrayNameGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), Symbol.toStringTag).get;
|
|
4664
|
+
return typedArrayNameGetter.call(value);
|
|
4665
|
+
}
|
|
4641
4666
|
function createNumberNode(value) {
|
|
4642
4667
|
switch (value) {
|
|
4643
4668
|
case Number.POSITIVE_INFINITY:
|
|
@@ -4647,85 +4672,224 @@ function createNumberNode(value) {
|
|
|
4647
4672
|
}
|
|
4648
4673
|
if (value !== value) return NAN_NODE;
|
|
4649
4674
|
if (Object.is(value, -0)) return NEG_ZERO_NODE;
|
|
4650
|
-
return createSerovalNode(0, void 0, value
|
|
4675
|
+
return createSerovalNode(0, void 0, value);
|
|
4651
4676
|
}
|
|
4652
4677
|
function createStringNode(value) {
|
|
4653
|
-
return createSerovalNode(1, void 0, serializeString(value)
|
|
4678
|
+
return createSerovalNode(1, void 0, serializeString(value));
|
|
4654
4679
|
}
|
|
4655
4680
|
function createBigIntNode(current) {
|
|
4656
|
-
return createSerovalNode(3, void 0, "" + current
|
|
4681
|
+
return createSerovalNode(3, void 0, "" + current);
|
|
4657
4682
|
}
|
|
4658
4683
|
function createIndexedValueNode(id) {
|
|
4659
|
-
return createSerovalNode(4, id
|
|
4684
|
+
return createSerovalNode(4, id);
|
|
4660
4685
|
}
|
|
4661
4686
|
function createDateNode(id, current) {
|
|
4662
4687
|
const timestamp = current.valueOf();
|
|
4663
|
-
return createSerovalNode(5, id, timestamp
|
|
4688
|
+
return createSerovalNode(5, id, timestamp === timestamp ? current.toISOString() : "");
|
|
4664
4689
|
}
|
|
4665
4690
|
function createTemporalNode(id, type, current) {
|
|
4666
|
-
return createSerovalNode(36, id, current.toString(), type
|
|
4691
|
+
return createSerovalNode(36, id, current.toString(), type);
|
|
4667
4692
|
}
|
|
4668
4693
|
function createRegExpNode(id, current) {
|
|
4669
|
-
return createSerovalNode(6, id, void 0, serializeString(current.source), current.flags
|
|
4694
|
+
return createSerovalNode(6, id, void 0, serializeString(current.source), current.flags);
|
|
4670
4695
|
}
|
|
4671
4696
|
function createWKSymbolNode(id, current) {
|
|
4672
|
-
return createSerovalNode(17, id, INV_SYMBOL_REF[current]
|
|
4697
|
+
return createSerovalNode(17, id, INV_SYMBOL_REF[current]);
|
|
4673
4698
|
}
|
|
4674
|
-
function createReferenceNode(id,
|
|
4675
|
-
return createSerovalNode(18, id, serializeString(
|
|
4699
|
+
function createReferenceNode(id, referenceId) {
|
|
4700
|
+
return createSerovalNode(18, id, serializeString(referenceId));
|
|
4676
4701
|
}
|
|
4677
4702
|
function createPluginNode(id, tag, value) {
|
|
4678
|
-
return createSerovalNode(25, id, value, serializeString(tag)
|
|
4703
|
+
return createSerovalNode(25, id, value, serializeString(tag));
|
|
4679
4704
|
}
|
|
4680
4705
|
function createArrayNode(id, current, parsedItems) {
|
|
4681
|
-
return createSerovalNode(9, id, void 0, void 0, void 0, void 0, void 0, parsedItems, void 0, void 0, getObjectFlag(current)
|
|
4706
|
+
return createSerovalNode(9, id, void 0, void 0, void 0, void 0, void 0, parsedItems, void 0, void 0, getObjectFlag(current));
|
|
4682
4707
|
}
|
|
4683
4708
|
function createBoxedNode(id, boxed) {
|
|
4684
|
-
return createSerovalNode(21, id, void 0, void 0, void 0, void 0, void 0, void 0, boxed
|
|
4709
|
+
return createSerovalNode(21, id, void 0, void 0, void 0, void 0, void 0, void 0, boxed);
|
|
4685
4710
|
}
|
|
4686
4711
|
var MAX_TYPED_ARRAY_LENGTH = 1e6;
|
|
4687
|
-
function
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
if (current.length > MAX_TYPED_ARRAY_LENGTH) throw new SerovalUnsupportedTypeError(current);
|
|
4693
|
-
return createSerovalNode(16, id, void 0, current.constructor.name, void 0, void 0, void 0, void 0, buffer, current.byteOffset, void 0, current.length);
|
|
4694
|
-
}
|
|
4695
|
-
function createDataViewNode(id, current, buffer) {
|
|
4696
|
-
if (current.byteLength > MAX_TYPED_ARRAY_LENGTH) throw new SerovalUnsupportedTypeError(current);
|
|
4697
|
-
return createSerovalNode(20, id, void 0, void 0, void 0, void 0, void 0, void 0, buffer, current.byteOffset, void 0, current.byteLength);
|
|
4712
|
+
function createViewNode(type, id, current, buffer) {
|
|
4713
|
+
const isDataView = type === 20;
|
|
4714
|
+
const size = isDataView ? current.byteLength : current.length;
|
|
4715
|
+
if (size > MAX_TYPED_ARRAY_LENGTH) throw new SerovalUnsupportedTypeError(current);
|
|
4716
|
+
return createSerovalNode(type, id, void 0, isDataView ? void 0 : getTypedArrayName(current), void 0, void 0, void 0, void 0, buffer, current.byteOffset, void 0, size);
|
|
4698
4717
|
}
|
|
4699
|
-
function createErrorNode(id, current, options) {
|
|
4700
|
-
return createSerovalNode(
|
|
4701
|
-
}
|
|
4702
|
-
function createAggregateErrorNode(id, current, options) {
|
|
4703
|
-
return createSerovalNode(14, id, getErrorConstructor(current), void 0, serializeString(current.message), options, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
4718
|
+
function createErrorNode(type, id, current, options) {
|
|
4719
|
+
return createSerovalNode(type, id, getErrorConstructor(current), void 0, serializeString(current.message), options);
|
|
4704
4720
|
}
|
|
4705
4721
|
function createSetNode(id, items) {
|
|
4706
|
-
return createSerovalNode(7, id, void 0, void 0, void 0, void 0, void 0, items
|
|
4707
|
-
}
|
|
4708
|
-
function createIteratorFactoryInstanceNode(factory, items) {
|
|
4709
|
-
return createSerovalNode(28, void 0, void 0, void 0, void 0, void 0, void 0, [factory, items], void 0, void 0, void 0, void 0);
|
|
4722
|
+
return createSerovalNode(7, id, void 0, void 0, void 0, void 0, void 0, items);
|
|
4710
4723
|
}
|
|
4711
|
-
function
|
|
4712
|
-
return createSerovalNode(
|
|
4724
|
+
function createIteratorFactoryInstanceNode(type, factory, items) {
|
|
4725
|
+
return createSerovalNode(type, void 0, void 0, void 0, void 0, void 0, void 0, [factory, items]);
|
|
4713
4726
|
}
|
|
4714
|
-
function createStreamConstructorNode(id, factory, sequence) {
|
|
4715
|
-
return createSerovalNode(31, id, void 0, void 0, void 0, void 0, void 0, sequence, factory, void 0, void 0,
|
|
4727
|
+
function createStreamConstructorNode(id, factory, sequence, live) {
|
|
4728
|
+
return createSerovalNode(31, id, void 0, void 0, void 0, void 0, void 0, sequence, factory, void 0, void 0, live);
|
|
4716
4729
|
}
|
|
4717
|
-
function
|
|
4718
|
-
return createSerovalNode(
|
|
4719
|
-
}
|
|
4720
|
-
function createStreamThrowNode(id, parsed) {
|
|
4721
|
-
return createSerovalNode(33, id, void 0, void 0, void 0, void 0, void 0, void 0, parsed, void 0, void 0, void 0);
|
|
4722
|
-
}
|
|
4723
|
-
function createStreamReturnNode(id, parsed) {
|
|
4724
|
-
return createSerovalNode(34, id, void 0, void 0, void 0, void 0, void 0, void 0, parsed, void 0, void 0, void 0);
|
|
4730
|
+
function createStreamEventNode(type, id, parsed) {
|
|
4731
|
+
return createSerovalNode(type, id, void 0, void 0, void 0, void 0, void 0, void 0, parsed);
|
|
4725
4732
|
}
|
|
4726
4733
|
function createSequenceNode(id, sequence, throwAt, doneAt) {
|
|
4727
4734
|
return createSerovalNode(35, id, throwAt, void 0, void 0, void 0, void 0, sequence, void 0, void 0, void 0, doneAt);
|
|
4728
4735
|
}
|
|
4736
|
+
function isLiveStream(value) {
|
|
4737
|
+
return value instanceof LiveStream;
|
|
4738
|
+
}
|
|
4739
|
+
var LiveStream = class {
|
|
4740
|
+
constructor(options) {
|
|
4741
|
+
this.consumed = false;
|
|
4742
|
+
this.closed = false;
|
|
4743
|
+
this.cancelled = false;
|
|
4744
|
+
this.options = options;
|
|
4745
|
+
}
|
|
4746
|
+
deliver(reader, record) {
|
|
4747
|
+
record.delivered = true;
|
|
4748
|
+
reader.resolve({
|
|
4749
|
+
event: record.event,
|
|
4750
|
+
accept: () => {
|
|
4751
|
+
if (this.pending === record && record.delivered) {
|
|
4752
|
+
const terminal = record.event.type !== "next";
|
|
4753
|
+
record.event = void 0;
|
|
4754
|
+
this.pending = void 0;
|
|
4755
|
+
const resolve = record.resolve;
|
|
4756
|
+
record.resolve = void 0;
|
|
4757
|
+
record.reject = void 0;
|
|
4758
|
+
if (terminal) {
|
|
4759
|
+
this.closed = true;
|
|
4760
|
+
this.options = void 0;
|
|
4761
|
+
const waiter = this.waiting;
|
|
4762
|
+
this.waiting = void 0;
|
|
4763
|
+
waiter?.reject(new SerovalLiveStreamError("closed"));
|
|
4764
|
+
}
|
|
4765
|
+
resolve?.();
|
|
4766
|
+
}
|
|
4767
|
+
}
|
|
4768
|
+
});
|
|
4769
|
+
}
|
|
4770
|
+
/** @internal */
|
|
4771
|
+
push(event) {
|
|
4772
|
+
if (this.cancelled) return Promise.reject(this.cancelReason);
|
|
4773
|
+
if (this.closed) return Promise.reject(new SerovalLiveStreamError("closed"));
|
|
4774
|
+
if (this.pending) return Promise.reject(new SerovalLiveStreamError("pending"));
|
|
4775
|
+
return new Promise((resolve, reject) => {
|
|
4776
|
+
const record = {
|
|
4777
|
+
event,
|
|
4778
|
+
delivered: false,
|
|
4779
|
+
resolve,
|
|
4780
|
+
reject
|
|
4781
|
+
};
|
|
4782
|
+
this.pending = record;
|
|
4783
|
+
if (this.waiting) {
|
|
4784
|
+
const waiter = this.waiting;
|
|
4785
|
+
this.waiting = void 0;
|
|
4786
|
+
this.deliver(waiter, record);
|
|
4787
|
+
}
|
|
4788
|
+
});
|
|
4789
|
+
}
|
|
4790
|
+
cancel(reason) {
|
|
4791
|
+
if (this.cancelled || this.closed) return;
|
|
4792
|
+
this.cancelled = true;
|
|
4793
|
+
this.cancelReason = reason;
|
|
4794
|
+
const record = this.pending;
|
|
4795
|
+
const waiter = this.waiting;
|
|
4796
|
+
this.pending = void 0;
|
|
4797
|
+
this.waiting = void 0;
|
|
4798
|
+
const callbackOwner = this.options;
|
|
4799
|
+
this.options = void 0;
|
|
4800
|
+
if (record) {
|
|
4801
|
+
record.event = void 0;
|
|
4802
|
+
const reject = record.reject;
|
|
4803
|
+
record.resolve = void 0;
|
|
4804
|
+
record.reject = void 0;
|
|
4805
|
+
reject?.(reason);
|
|
4806
|
+
}
|
|
4807
|
+
if (waiter) waiter.reject(reason);
|
|
4808
|
+
callbackOwner?.onCancel?.(reason);
|
|
4809
|
+
}
|
|
4810
|
+
read() {
|
|
4811
|
+
if (this.cancelled) return Promise.reject(this.cancelReason);
|
|
4812
|
+
if (this.closed) return Promise.reject(new SerovalLiveStreamError("closed"));
|
|
4813
|
+
if (this.waiting) return Promise.reject(new SerovalLiveStreamError("reading"));
|
|
4814
|
+
return new Promise((resolve, reject) => {
|
|
4815
|
+
const next = {
|
|
4816
|
+
resolve,
|
|
4817
|
+
reject
|
|
4818
|
+
};
|
|
4819
|
+
if (this.pending && !this.pending.delivered) this.deliver(next, this.pending);
|
|
4820
|
+
else this.waiting = next;
|
|
4821
|
+
});
|
|
4822
|
+
}
|
|
4823
|
+
consume() {
|
|
4824
|
+
if (this.consumed) throw new SerovalLiveStreamError("consumed");
|
|
4825
|
+
this.consumed = true;
|
|
4826
|
+
return {
|
|
4827
|
+
read: () => this.read(),
|
|
4828
|
+
cancel: (reason) => this.cancel(reason)
|
|
4829
|
+
};
|
|
4830
|
+
}
|
|
4831
|
+
/**
|
|
4832
|
+
* Consumes the stream through a replay-style listener, accepting each
|
|
4833
|
+
* event as soon as it has been delivered. Use `consume` or `pump` when
|
|
4834
|
+
* acceptance must wait for processing.
|
|
4835
|
+
*/
|
|
4836
|
+
on(listener) {
|
|
4837
|
+
const wrap = (key) => (value, accept) => {
|
|
4838
|
+
listener[key](value);
|
|
4839
|
+
accept();
|
|
4840
|
+
};
|
|
4841
|
+
return this.pump({
|
|
4842
|
+
next: wrap("next"),
|
|
4843
|
+
throw: wrap("throw"),
|
|
4844
|
+
return: wrap("return")
|
|
4845
|
+
});
|
|
4846
|
+
}
|
|
4847
|
+
/**
|
|
4848
|
+
* Consumes the stream into a sink that controls acceptance. Returns the
|
|
4849
|
+
* cancel function.
|
|
4850
|
+
* @internal
|
|
4851
|
+
*/
|
|
4852
|
+
pump(sink) {
|
|
4853
|
+
const consumer = this.consume();
|
|
4854
|
+
let current = sink;
|
|
4855
|
+
function next() {
|
|
4856
|
+
consumer.read().then((delivery) => {
|
|
4857
|
+
const target = current;
|
|
4858
|
+
if (!target) return;
|
|
4859
|
+
const event = delivery.event;
|
|
4860
|
+
let failure;
|
|
4861
|
+
let failed = false;
|
|
4862
|
+
try {
|
|
4863
|
+
failure = target[event.type](event.type === "throw" ? event.error : event.value, delivery.accept);
|
|
4864
|
+
} catch (error) {
|
|
4865
|
+
failed = true;
|
|
4866
|
+
failure = error;
|
|
4867
|
+
}
|
|
4868
|
+
if (failed || failure !== void 0) {
|
|
4869
|
+
current = void 0;
|
|
4870
|
+
try {
|
|
4871
|
+
consumer.cancel(failure);
|
|
4872
|
+
} finally {
|
|
4873
|
+
target.done?.();
|
|
4874
|
+
}
|
|
4875
|
+
return;
|
|
4876
|
+
}
|
|
4877
|
+
if (event.type === "next") {
|
|
4878
|
+
next();
|
|
4879
|
+
return;
|
|
4880
|
+
}
|
|
4881
|
+
current = void 0;
|
|
4882
|
+
target.done?.();
|
|
4883
|
+
}, (reason) => {
|
|
4884
|
+
const target = current;
|
|
4885
|
+
current = void 0;
|
|
4886
|
+
target?.error?.(reason);
|
|
4887
|
+
});
|
|
4888
|
+
}
|
|
4889
|
+
next();
|
|
4890
|
+
return consumer.cancel;
|
|
4891
|
+
}
|
|
4892
|
+
};
|
|
4729
4893
|
var OpaqueReference = class {
|
|
4730
4894
|
constructor(value, replacement) {
|
|
4731
4895
|
this.value = value;
|
|
@@ -4757,7 +4921,7 @@ var PROMISE_FAILURE = (resolver, data) => {
|
|
|
4757
4921
|
var SERIALIZED_PROMISE_CONSTRUCTOR = /* @__PURE__ */ PROMISE_CONSTRUCTOR.toString();
|
|
4758
4922
|
var SERIALIZED_PROMISE_SUCCESS = /* @__PURE__ */ PROMISE_SUCCESS.toString();
|
|
4759
4923
|
var SERIALIZED_PROMISE_FAILURE = /* @__PURE__ */ PROMISE_FAILURE.toString();
|
|
4760
|
-
var STREAM_CONSTRUCTOR = () => {
|
|
4924
|
+
var STREAM_CONSTRUCTOR = (live) => {
|
|
4761
4925
|
const buffer = [];
|
|
4762
4926
|
const listeners = [];
|
|
4763
4927
|
let alive = true;
|
|
@@ -4765,6 +4929,7 @@ var STREAM_CONSTRUCTOR = () => {
|
|
|
4765
4929
|
let count = 0;
|
|
4766
4930
|
const internal = {
|
|
4767
4931
|
flush(value, mode, x) {
|
|
4932
|
+
live > 1 || buffer.push(value);
|
|
4768
4933
|
for (x = 0; x < count; x++) {
|
|
4769
4934
|
const listener = listeners[x];
|
|
4770
4935
|
if (listener) listener[mode](value);
|
|
@@ -4778,6 +4943,7 @@ var STREAM_CONSTRUCTOR = () => {
|
|
|
4778
4943
|
}
|
|
4779
4944
|
},
|
|
4780
4945
|
on(listener, temp = 0) {
|
|
4946
|
+
if (live > 1) throw new Error("Stream consumed");
|
|
4781
4947
|
let subscribed = alive;
|
|
4782
4948
|
if (alive) {
|
|
4783
4949
|
for (temp = 0; temp < count; temp++) if (!listeners[temp]) break;
|
|
@@ -4785,6 +4951,10 @@ var STREAM_CONSTRUCTOR = () => {
|
|
|
4785
4951
|
listeners[temp] = listener;
|
|
4786
4952
|
}
|
|
4787
4953
|
internal.up(listener);
|
|
4954
|
+
if (live) {
|
|
4955
|
+
live = 2;
|
|
4956
|
+
buffer.length = 0;
|
|
4957
|
+
}
|
|
4788
4958
|
return () => {
|
|
4789
4959
|
if (alive && subscribed) {
|
|
4790
4960
|
subscribed = false;
|
|
@@ -4801,14 +4971,10 @@ var STREAM_CONSTRUCTOR = () => {
|
|
|
4801
4971
|
return internal.on(listener);
|
|
4802
4972
|
},
|
|
4803
4973
|
next(value) {
|
|
4804
|
-
if (alive)
|
|
4805
|
-
buffer.push(value);
|
|
4806
|
-
internal.flush(value, "next");
|
|
4807
|
-
}
|
|
4974
|
+
if (alive) internal.flush(value, "next");
|
|
4808
4975
|
},
|
|
4809
4976
|
throw(value) {
|
|
4810
4977
|
if (alive) {
|
|
4811
|
-
buffer.push(value);
|
|
4812
4978
|
internal.flush(value, "throw");
|
|
4813
4979
|
alive = false;
|
|
4814
4980
|
success = false;
|
|
@@ -4817,7 +4983,6 @@ var STREAM_CONSTRUCTOR = () => {
|
|
|
4817
4983
|
},
|
|
4818
4984
|
return(value) {
|
|
4819
4985
|
if (alive) {
|
|
4820
|
-
buffer.push(value);
|
|
4821
4986
|
internal.flush(value, "return");
|
|
4822
4987
|
alive = false;
|
|
4823
4988
|
success = true;
|
|
@@ -4935,23 +5100,25 @@ var ARRAY_BUFFER_CONSTRUCTOR = (b64) => {
|
|
|
4935
5100
|
return arr.buffer;
|
|
4936
5101
|
};
|
|
4937
5102
|
var SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR = /* @__PURE__ */ ARRAY_BUFFER_CONSTRUCTOR.toString();
|
|
5103
|
+
var Sequence = class {
|
|
5104
|
+
constructor(values, throwAt, doneAt) {
|
|
5105
|
+
this.v = values;
|
|
5106
|
+
this.t = throwAt;
|
|
5107
|
+
this.d = doneAt;
|
|
5108
|
+
}
|
|
5109
|
+
};
|
|
4938
5110
|
function isSequence(value) {
|
|
4939
|
-
return
|
|
5111
|
+
return value instanceof Sequence;
|
|
4940
5112
|
}
|
|
4941
5113
|
function createSequence(values, throwAt, doneAt) {
|
|
4942
|
-
return
|
|
4943
|
-
__SEROVAL_SEQUENCE__: true,
|
|
4944
|
-
v: values,
|
|
4945
|
-
t: throwAt,
|
|
4946
|
-
d: doneAt
|
|
4947
|
-
};
|
|
5114
|
+
return new Sequence(values, throwAt, doneAt);
|
|
4948
5115
|
}
|
|
4949
5116
|
function createSequenceFromIterable(source) {
|
|
4950
5117
|
const values = [];
|
|
4951
5118
|
let throwsAt = -1;
|
|
4952
5119
|
let doneAt = -1;
|
|
4953
5120
|
const iterator = source[SYM_ITERATOR]();
|
|
4954
|
-
|
|
5121
|
+
for (; ; ) try {
|
|
4955
5122
|
const value = iterator.next();
|
|
4956
5123
|
values.push(value.value);
|
|
4957
5124
|
if (value.done) {
|
|
@@ -4960,11 +5127,12 @@ function createSequenceFromIterable(source) {
|
|
|
4960
5127
|
}
|
|
4961
5128
|
} catch (error) {
|
|
4962
5129
|
throwsAt = values.length;
|
|
5130
|
+
doneAt = throwsAt;
|
|
4963
5131
|
values.push(error);
|
|
5132
|
+
break;
|
|
4964
5133
|
}
|
|
4965
5134
|
return createSequence(values, throwsAt, doneAt);
|
|
4966
5135
|
}
|
|
4967
|
-
var createIterator = ITERATOR_CONSTRUCTOR(SYM_ITERATOR);
|
|
4968
5136
|
var ITERATOR = {};
|
|
4969
5137
|
var ASYNC_ITERATOR = {};
|
|
4970
5138
|
var SPECIAL_REFS = {
|
|
@@ -4983,61 +5151,173 @@ var SPECIAL_REF_STRING = {
|
|
|
4983
5151
|
[4]: SERIALIZED_STREAM_CONSTRUCTOR,
|
|
4984
5152
|
[5]: SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR
|
|
4985
5153
|
};
|
|
5154
|
+
var Stream = class {
|
|
5155
|
+
constructor(live) {
|
|
5156
|
+
this.buffer = [];
|
|
5157
|
+
this.listeners = [];
|
|
5158
|
+
this.alive = true;
|
|
5159
|
+
this.success = false;
|
|
5160
|
+
this.count = 0;
|
|
5161
|
+
this.live = live;
|
|
5162
|
+
}
|
|
5163
|
+
flush(value, mode) {
|
|
5164
|
+
this.live > 1 || this.buffer.push(value);
|
|
5165
|
+
for (let x = 0; x < this.count; x++) this.listeners[x]?.[mode](value);
|
|
5166
|
+
}
|
|
5167
|
+
replay(listener) {
|
|
5168
|
+
for (let x = 0, z = this.buffer.length; x < z; x++) {
|
|
5169
|
+
const current = this.buffer[x];
|
|
5170
|
+
if (!this.alive && x === z - 1) listener[this.success ? "return" : "throw"](current);
|
|
5171
|
+
else listener.next(current);
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
5174
|
+
on(listener) {
|
|
5175
|
+
if (this.live > 1) throw new Error("Stream consumed");
|
|
5176
|
+
let subscribed = this.alive;
|
|
5177
|
+
let temp = 0;
|
|
5178
|
+
if (subscribed) {
|
|
5179
|
+
for (; temp < this.count; temp++) if (!this.listeners[temp]) break;
|
|
5180
|
+
if (temp === this.count) this.count++;
|
|
5181
|
+
this.listeners[temp] = listener;
|
|
5182
|
+
}
|
|
5183
|
+
this.replay(listener);
|
|
5184
|
+
if (this.live) {
|
|
5185
|
+
this.live = 2;
|
|
5186
|
+
this.buffer.length = 0;
|
|
5187
|
+
}
|
|
5188
|
+
return () => {
|
|
5189
|
+
if (this.alive && subscribed) {
|
|
5190
|
+
subscribed = false;
|
|
5191
|
+
this.listeners[temp] = void 0;
|
|
5192
|
+
while (this.count > 0 && !this.listeners[this.count - 1]) this.count--;
|
|
5193
|
+
this.listeners.length = this.count;
|
|
5194
|
+
}
|
|
5195
|
+
};
|
|
5196
|
+
}
|
|
5197
|
+
/**
|
|
5198
|
+
* Returns the events of a stream that has ended, without subscribing, so a
|
|
5199
|
+
* live receiver is not consumed. The last value is the `return` or `throw`
|
|
5200
|
+
* value. Returns `undefined` while the stream is open, or when a live
|
|
5201
|
+
* receiver was already consumed and has no events left.
|
|
5202
|
+
* @internal
|
|
5203
|
+
*/
|
|
5204
|
+
endedEvents() {
|
|
5205
|
+
if (this.alive || this.live > 1) return void 0;
|
|
5206
|
+
return {
|
|
5207
|
+
values: this.buffer.slice(),
|
|
5208
|
+
success: this.success
|
|
5209
|
+
};
|
|
5210
|
+
}
|
|
5211
|
+
next(value) {
|
|
5212
|
+
if (this.alive) this.flush(value, "next");
|
|
5213
|
+
}
|
|
5214
|
+
throw(value) {
|
|
5215
|
+
if (this.alive) {
|
|
5216
|
+
this.flush(value, "throw");
|
|
5217
|
+
this.alive = false;
|
|
5218
|
+
this.success = false;
|
|
5219
|
+
this.listeners.length = 0;
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5222
|
+
return(value) {
|
|
5223
|
+
if (this.alive) {
|
|
5224
|
+
this.flush(value, "return");
|
|
5225
|
+
this.alive = false;
|
|
5226
|
+
this.success = true;
|
|
5227
|
+
this.listeners.length = 0;
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
};
|
|
4986
5231
|
function isStream(value) {
|
|
4987
|
-
return
|
|
5232
|
+
return value instanceof Stream || isLiveStream(value);
|
|
4988
5233
|
}
|
|
4989
5234
|
function createStream() {
|
|
4990
|
-
return
|
|
4991
|
-
}
|
|
4992
|
-
function
|
|
4993
|
-
const
|
|
4994
|
-
|
|
4995
|
-
let
|
|
4996
|
-
let
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5235
|
+
return new Stream();
|
|
5236
|
+
}
|
|
5237
|
+
function encodeArrayBuffer$1(current) {
|
|
5238
|
+
const bytes = new Uint8Array(current);
|
|
5239
|
+
if (typeof bytes.toBase64 === "function") return bytes.toBase64();
|
|
5240
|
+
let result = "";
|
|
5241
|
+
for (let i = 0, len = bytes.length; i < len; i++) result += String.fromCharCode(bytes[i]);
|
|
5242
|
+
return btoa(result);
|
|
5243
|
+
}
|
|
5244
|
+
function encodeArrayBuffer(current) {
|
|
5245
|
+
if (typeof Buffer !== "undefined") return Buffer.from(current).toString("base64");
|
|
5246
|
+
return encodeArrayBuffer$1(current);
|
|
5247
|
+
}
|
|
5248
|
+
function createPlugin(plugin) {
|
|
5249
|
+
return plugin;
|
|
5250
|
+
}
|
|
5251
|
+
function dedupePlugins(deduped, plugins) {
|
|
5252
|
+
for (let i = 0, len = plugins.length; i < len; i++) {
|
|
5253
|
+
const current = plugins[i];
|
|
5254
|
+
if (!deduped.has(current)) {
|
|
5255
|
+
deduped.add(current);
|
|
5256
|
+
if (current.extends) dedupePlugins(deduped, current.extends);
|
|
5005
5257
|
}
|
|
5006
|
-
}
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
stream.next(value.value);
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
var RESOLVED_PLUGINS = /* @__PURE__ */ new WeakMap();
|
|
5261
|
+
function matchResolved(resolved, plugins, added) {
|
|
5262
|
+
for (let i = 0, len = plugins.length; i < len; i++) {
|
|
5263
|
+
const current = plugins[i];
|
|
5264
|
+
if (current === resolved[added]) {
|
|
5265
|
+
added++;
|
|
5266
|
+
if (current.extends) {
|
|
5267
|
+
added = matchResolved(resolved, current.extends, added);
|
|
5268
|
+
if (added === -1) return -1;
|
|
5018
5269
|
}
|
|
5019
|
-
}
|
|
5020
|
-
|
|
5021
|
-
if (
|
|
5270
|
+
} else {
|
|
5271
|
+
const index = resolved.indexOf(current);
|
|
5272
|
+
if (index === -1 || index >= added) return -1;
|
|
5022
5273
|
}
|
|
5023
5274
|
}
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5275
|
+
return added;
|
|
5276
|
+
}
|
|
5277
|
+
function resolvePlugins(plugins) {
|
|
5278
|
+
if (plugins) {
|
|
5279
|
+
const cached = RESOLVED_PLUGINS.get(plugins);
|
|
5280
|
+
if (cached && matchResolved(cached, plugins, 0) === cached.length) return cached;
|
|
5281
|
+
const deduped = /* @__PURE__ */ new Set();
|
|
5282
|
+
dedupePlugins(deduped, plugins);
|
|
5283
|
+
const resolved = [...deduped];
|
|
5284
|
+
RESOLVED_PLUGINS.set(plugins, resolved);
|
|
5285
|
+
return resolved;
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
function getPlainObjectPlugins(plugins) {
|
|
5289
|
+
if (plugins) {
|
|
5290
|
+
for (let i = 0, len = plugins.length; i < len; i++) if (plugins[i].skipPlainObjects) {
|
|
5291
|
+
const result = plugins.filter((plugin) => !plugin.skipPlainObjects);
|
|
5292
|
+
return result.length ? result : void 0;
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5295
|
+
return plugins;
|
|
5027
5296
|
}
|
|
5028
|
-
var
|
|
5029
|
-
|
|
5030
|
-
|
|
5297
|
+
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
5298
|
+
var GLOBAL_CONTEXT_R = `self.$R`;
|
|
5299
|
+
function getCrossReferenceHeader(id) {
|
|
5300
|
+
if (id == null) return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[]`;
|
|
5301
|
+
return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(id)}"]=[]`;
|
|
5302
|
+
}
|
|
5303
|
+
var REFERENCE = /* @__PURE__ */ new Map();
|
|
5304
|
+
function getReferenceID(value) {
|
|
5305
|
+
return REFERENCE.get(value);
|
|
5306
|
+
}
|
|
5307
|
+
function createBaseParserContext(options) {
|
|
5031
5308
|
return {
|
|
5032
5309
|
plugins: options.plugins,
|
|
5033
|
-
|
|
5310
|
+
plainObjectPlugins: getPlainObjectPlugins(options.plugins),
|
|
5034
5311
|
marked: /* @__PURE__ */ new Set(),
|
|
5035
|
-
features: 127 ^ (options.disabledFeatures
|
|
5036
|
-
refs: options.refs
|
|
5312
|
+
features: 127 ^ (options.disabledFeatures ?? 0),
|
|
5313
|
+
refs: options.refs ?? /* @__PURE__ */ new Map(),
|
|
5037
5314
|
depthLimit: options.depthLimit || 1e3,
|
|
5038
|
-
compactArrayBufferViews:
|
|
5315
|
+
compactArrayBufferViews: options.compactArrayBufferViews ?? false
|
|
5039
5316
|
};
|
|
5040
5317
|
}
|
|
5318
|
+
function getObjectPlugins(ctx, current, currentClass) {
|
|
5319
|
+
return currentClass === Object && Object.getPrototypeOf(current) === Object.prototype ? ctx.plainObjectPlugins : ctx.plugins;
|
|
5320
|
+
}
|
|
5041
5321
|
function markParserRef(ctx, id) {
|
|
5042
5322
|
ctx.marked.add(id);
|
|
5043
5323
|
}
|
|
@@ -5050,111 +5330,141 @@ function getNodeForIndexedValue(ctx, current) {
|
|
|
5050
5330
|
const registeredId = ctx.refs.get(current);
|
|
5051
5331
|
if (registeredId != null) {
|
|
5052
5332
|
markParserRef(ctx, registeredId);
|
|
5053
|
-
return
|
|
5054
|
-
type: 1,
|
|
5055
|
-
value: createIndexedValueNode(registeredId)
|
|
5056
|
-
};
|
|
5333
|
+
return createIndexedValueNode(registeredId);
|
|
5057
5334
|
}
|
|
5058
|
-
return
|
|
5059
|
-
type: 0,
|
|
5060
|
-
value: createIndexForValue(ctx, current)
|
|
5061
|
-
};
|
|
5335
|
+
return createIndexForValue(ctx, current);
|
|
5062
5336
|
}
|
|
5063
5337
|
function getReferenceNode(ctx, current) {
|
|
5064
5338
|
const indexed = getNodeForIndexedValue(ctx, current);
|
|
5065
|
-
if (indexed
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
value: createReferenceNode(indexed.value, current)
|
|
5069
|
-
};
|
|
5070
|
-
return indexed;
|
|
5339
|
+
if (typeof indexed !== "number") return indexed;
|
|
5340
|
+
const referenceId = getReferenceID(current);
|
|
5341
|
+
return referenceId === void 0 ? indexed : createReferenceNode(indexed, referenceId);
|
|
5071
5342
|
}
|
|
5072
5343
|
function parseWellKnownSymbol(ctx, current) {
|
|
5073
5344
|
const ref = getReferenceNode(ctx, current);
|
|
5074
|
-
if (ref
|
|
5075
|
-
if (current in INV_SYMBOL_REF) return createWKSymbolNode(ref
|
|
5345
|
+
if (typeof ref !== "number") return ref;
|
|
5346
|
+
if (current in INV_SYMBOL_REF) return createWKSymbolNode(ref, current);
|
|
5076
5347
|
throw new SerovalUnsupportedTypeError(current);
|
|
5077
5348
|
}
|
|
5078
5349
|
function parseSpecialReference(ctx, ref) {
|
|
5079
5350
|
const result = getNodeForIndexedValue(ctx, SPECIAL_REFS[ref]);
|
|
5080
|
-
if (result
|
|
5081
|
-
return createSerovalNode(26, result
|
|
5351
|
+
if (typeof result !== "number") return result;
|
|
5352
|
+
return createSerovalNode(26, result, ref);
|
|
5082
5353
|
}
|
|
5083
5354
|
function parseIteratorFactory(ctx) {
|
|
5084
5355
|
const result = getNodeForIndexedValue(ctx, ITERATOR);
|
|
5085
|
-
if (result
|
|
5086
|
-
return createSerovalNode(27, result
|
|
5356
|
+
if (typeof result !== "number") return result;
|
|
5357
|
+
return createSerovalNode(27, result, void 0, void 0, void 0, void 0, void 0, void 0, parseWellKnownSymbol(ctx, SYM_ITERATOR));
|
|
5087
5358
|
}
|
|
5088
5359
|
function parseAsyncIteratorFactory(ctx) {
|
|
5089
5360
|
const result = getNodeForIndexedValue(ctx, ASYNC_ITERATOR);
|
|
5090
|
-
if (result
|
|
5091
|
-
return createSerovalNode(29, result
|
|
5361
|
+
if (typeof result !== "number") return result;
|
|
5362
|
+
return createSerovalNode(29, result, void 0, void 0, void 0, void 0, void 0, [parseSpecialReference(ctx, 1), parseWellKnownSymbol(ctx, SYM_ASYNC_ITERATOR)]);
|
|
5363
|
+
}
|
|
5364
|
+
function getTemporalType(currentClass) {
|
|
5365
|
+
switch (currentClass) {
|
|
5366
|
+
case Temporal.Instant:
|
|
5367
|
+
return 0;
|
|
5368
|
+
case Temporal.Duration:
|
|
5369
|
+
return 1;
|
|
5370
|
+
case Temporal.PlainDate:
|
|
5371
|
+
return 2;
|
|
5372
|
+
case Temporal.PlainDateTime:
|
|
5373
|
+
return 3;
|
|
5374
|
+
case Temporal.PlainMonthDay:
|
|
5375
|
+
return 4;
|
|
5376
|
+
case Temporal.PlainTime:
|
|
5377
|
+
return 5;
|
|
5378
|
+
case Temporal.PlainYearMonth:
|
|
5379
|
+
return 6;
|
|
5380
|
+
case Temporal.ZonedDateTime:
|
|
5381
|
+
return 7;
|
|
5382
|
+
default:
|
|
5383
|
+
return;
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
function getObjectClass(current) {
|
|
5387
|
+
const currentClass = current.constructor;
|
|
5388
|
+
if (currentClass !== void 0 && typeof currentClass !== "function") {
|
|
5389
|
+
const proto = Object.getPrototypeOf(current);
|
|
5390
|
+
return proto === null ? void 0 : proto.constructor;
|
|
5391
|
+
}
|
|
5392
|
+
return currentClass;
|
|
5393
|
+
}
|
|
5394
|
+
function getObjectKind(current, currentClass, features) {
|
|
5395
|
+
switch (currentClass) {
|
|
5396
|
+
case Object:
|
|
5397
|
+
return 1;
|
|
5398
|
+
case void 0:
|
|
5399
|
+
return 2;
|
|
5400
|
+
case Date:
|
|
5401
|
+
return 3;
|
|
5402
|
+
case Error:
|
|
5403
|
+
case EvalError:
|
|
5404
|
+
case RangeError:
|
|
5405
|
+
case ReferenceError:
|
|
5406
|
+
case SyntaxError:
|
|
5407
|
+
case TypeError:
|
|
5408
|
+
case URIError:
|
|
5409
|
+
return 4;
|
|
5410
|
+
case Number:
|
|
5411
|
+
case Boolean:
|
|
5412
|
+
case String:
|
|
5413
|
+
case BigInt:
|
|
5414
|
+
return 6;
|
|
5415
|
+
case ArrayBuffer:
|
|
5416
|
+
return 7;
|
|
5417
|
+
case Int8Array:
|
|
5418
|
+
case Int16Array:
|
|
5419
|
+
case Int32Array:
|
|
5420
|
+
case Uint8Array:
|
|
5421
|
+
case Uint16Array:
|
|
5422
|
+
case Uint32Array:
|
|
5423
|
+
case Uint8ClampedArray:
|
|
5424
|
+
case Float32Array:
|
|
5425
|
+
case Float64Array:
|
|
5426
|
+
return 8;
|
|
5427
|
+
case DataView:
|
|
5428
|
+
return 10;
|
|
5429
|
+
case Map:
|
|
5430
|
+
return 11;
|
|
5431
|
+
case Set:
|
|
5432
|
+
return 12;
|
|
5433
|
+
}
|
|
5434
|
+
if (currentClass === Promise || current instanceof Promise) return 13;
|
|
5435
|
+
if (features & 32 && currentClass === RegExp) return 14;
|
|
5436
|
+
if (features & 16 && (currentClass === BigInt64Array || currentClass === BigUint64Array)) return 9;
|
|
5437
|
+
if (features & 1 && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) return 5;
|
|
5438
|
+
if (features & 64 && typeof Temporal !== "undefined" && getTemporalType(currentClass) != null) return 15;
|
|
5439
|
+
if (current instanceof Error) return 4;
|
|
5440
|
+
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) return 16;
|
|
5441
|
+
return 0;
|
|
5092
5442
|
}
|
|
5093
5443
|
function createObjectNode(id, current, empty, record) {
|
|
5094
|
-
return createSerovalNode(empty ? 11 : 10, id, void 0, void 0, void 0, record, void 0, void 0, void 0, void 0, getObjectFlag(current)
|
|
5444
|
+
return createSerovalNode(empty ? 11 : 10, id, void 0, void 0, void 0, record, void 0, void 0, void 0, void 0, getObjectFlag(current));
|
|
5445
|
+
}
|
|
5446
|
+
function parseMapSentinel(ctx) {
|
|
5447
|
+
return parseSpecialReference(ctx, 0);
|
|
5095
5448
|
}
|
|
5096
|
-
function createMapNode(
|
|
5449
|
+
function createMapNode(id, sentinel, k, v) {
|
|
5097
5450
|
return createSerovalNode(8, id, void 0, void 0, void 0, void 0, {
|
|
5098
5451
|
k,
|
|
5099
5452
|
v
|
|
5100
|
-
}, void 0,
|
|
5453
|
+
}, void 0, sentinel);
|
|
5101
5454
|
}
|
|
5102
5455
|
function createPromiseConstructorNode(ctx, id, resolver) {
|
|
5103
|
-
return createSerovalNode(22, id, resolver, void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 1)
|
|
5456
|
+
return createSerovalNode(22, id, resolver, void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 1));
|
|
5104
5457
|
}
|
|
5105
5458
|
function getArrayBufferView(ctx, current) {
|
|
5106
5459
|
if (!ctx.compactArrayBufferViews) return current;
|
|
5107
5460
|
const buffer = new Uint8Array(current.buffer, current.byteOffset, current.byteLength).slice().buffer;
|
|
5108
|
-
|
|
5109
|
-
return new Constructor(buffer);
|
|
5110
|
-
}
|
|
5111
|
-
function encodeArrayBuffer(current) {
|
|
5112
|
-
if (typeof Buffer !== "undefined") return Buffer.from(current).toString("base64");
|
|
5113
|
-
const bytes = new Uint8Array(current);
|
|
5114
|
-
if (typeof bytes.toBase64 === "function") return bytes.toBase64();
|
|
5115
|
-
let result = "";
|
|
5116
|
-
for (let i = 0, len = bytes.length; i < len; i++) result += String.fromCharCode(bytes[i]);
|
|
5117
|
-
return btoa(result);
|
|
5461
|
+
return new (current instanceof DataView ? DataView : getTypedArrayConstructor(getTypedArrayName(current)))(buffer);
|
|
5118
5462
|
}
|
|
5119
5463
|
function createArrayBufferNode(ctx, id, current) {
|
|
5120
|
-
return createSerovalNode(19, id, encodeArrayBuffer(current), void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 5)
|
|
5121
|
-
}
|
|
5122
|
-
function createPlugin(plugin) {
|
|
5123
|
-
return plugin;
|
|
5124
|
-
}
|
|
5125
|
-
function dedupePlugins(deduped, plugins) {
|
|
5126
|
-
for (let i = 0, len = plugins.length; i < len; i++) {
|
|
5127
|
-
const current = plugins[i];
|
|
5128
|
-
if (!deduped.has(current)) {
|
|
5129
|
-
deduped.add(current);
|
|
5130
|
-
if (current.extends) dedupePlugins(deduped, current.extends);
|
|
5131
|
-
}
|
|
5132
|
-
}
|
|
5133
|
-
}
|
|
5134
|
-
function resolvePlugins(plugins) {
|
|
5135
|
-
if (plugins) {
|
|
5136
|
-
const deduped = /* @__PURE__ */ new Set();
|
|
5137
|
-
dedupePlugins(deduped, plugins);
|
|
5138
|
-
return [...deduped];
|
|
5139
|
-
}
|
|
5140
|
-
}
|
|
5141
|
-
function isValidKey(key) {
|
|
5142
|
-
switch (key) {
|
|
5143
|
-
case "constructor":
|
|
5144
|
-
case "__proto__":
|
|
5145
|
-
case "prototype":
|
|
5146
|
-
case "__defineGetter__":
|
|
5147
|
-
case "__defineSetter__":
|
|
5148
|
-
case "__lookupGetter__":
|
|
5149
|
-
case "__lookupSetter__":
|
|
5150
|
-
return false;
|
|
5151
|
-
default:
|
|
5152
|
-
return true;
|
|
5153
|
-
}
|
|
5464
|
+
return createSerovalNode(19, id, encodeArrayBuffer(current), void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 5));
|
|
5154
5465
|
}
|
|
5155
5466
|
var RETURN = () => T;
|
|
5156
|
-
var
|
|
5157
|
-
var IS_MODERN = /* @__PURE__ */ /=>/.test(SERIALIZED_RETURN);
|
|
5467
|
+
var IS_MODERN = /* @__PURE__ */ (/* @__PURE__ */ RETURN.toString()).includes("=>");
|
|
5158
5468
|
function createFunction(parameters, body) {
|
|
5159
5469
|
if (IS_MODERN) return (parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")") + "=>" + (body.startsWith("{") ? "(" + body + ")" : body);
|
|
5160
5470
|
return "function(" + parameters.join(",") + "){return " + body + "}";
|
|
@@ -5178,10 +5488,13 @@ function getIdentifier(index) {
|
|
|
5178
5488
|
}
|
|
5179
5489
|
return ref;
|
|
5180
5490
|
}
|
|
5181
|
-
var IDENTIFIER_CHECK = /^[$A-Z_][0-9A-Z_$]*$/i;
|
|
5182
5491
|
function isValidIdentifier(name) {
|
|
5183
|
-
const
|
|
5184
|
-
|
|
5492
|
+
const len = name.length;
|
|
5493
|
+
for (let i = 0; i < len; i++) {
|
|
5494
|
+
const code = name.charCodeAt(i);
|
|
5495
|
+
if (!(code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 && i > 0 || code === 95 || code === 36)) return false;
|
|
5496
|
+
}
|
|
5497
|
+
return len > 0;
|
|
5185
5498
|
}
|
|
5186
5499
|
function getAssignmentExpression(assignment) {
|
|
5187
5500
|
switch (assignment.t) {
|
|
@@ -5197,51 +5510,32 @@ function getAssignmentExpression(assignment) {
|
|
|
5197
5510
|
return "Object.defineProperty(" + assignment.s + ',"__proto__",{value:' + assignment.k + ",configurable:!0,enumerable:!0,writable:!0})";
|
|
5198
5511
|
}
|
|
5199
5512
|
}
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
else if (item.t === 1 && item.s === prev.s) current = {
|
|
5218
|
-
t: 1,
|
|
5219
|
-
s: getAssignmentExpression(current),
|
|
5220
|
-
k: void 0,
|
|
5221
|
-
v: item.v
|
|
5222
|
-
};
|
|
5223
|
-
else if (item.t === 3 && item.s === prev.s) current = {
|
|
5224
|
-
t: 3,
|
|
5225
|
-
s: getAssignmentExpression(current),
|
|
5226
|
-
k: item.k,
|
|
5227
|
-
v: void 0
|
|
5228
|
-
};
|
|
5513
|
+
var MAX_ASSIGNMENT_CHAIN_LENGTH = 100;
|
|
5514
|
+
function resolveAssignments(assignments) {
|
|
5515
|
+
if (!assignments.length) return void 0;
|
|
5516
|
+
let previous = assignments[0];
|
|
5517
|
+
let expression = getAssignmentExpression(previous);
|
|
5518
|
+
let result = "";
|
|
5519
|
+
let chainLength = 1;
|
|
5520
|
+
for (let index = 1, length = assignments.length; index < length; index++) {
|
|
5521
|
+
const assignment = assignments[index];
|
|
5522
|
+
if (chainLength === MAX_ASSIGNMENT_CHAIN_LENGTH) {
|
|
5523
|
+
result += expression + ",";
|
|
5524
|
+
expression = getAssignmentExpression(assignment);
|
|
5525
|
+
chainLength = 0;
|
|
5526
|
+
} else if (assignment.t === 0 && previous.t === 0 && assignment.v === previous.v) expression = assignment.s + "=" + expression;
|
|
5527
|
+
else if (assignment.t === 2 && previous.t === 2 && assignment.s === previous.s) expression += ".set(" + assignment.k + "," + assignment.v + ")";
|
|
5528
|
+
else if (assignment.t === 1 && previous.t === 1 && assignment.s === previous.s) expression += ".add(" + assignment.v + ")";
|
|
5529
|
+
else if (assignment.t === 3 && previous.t === 2 && assignment.s === previous.s) expression += ".delete(" + assignment.k + ")";
|
|
5229
5530
|
else {
|
|
5230
|
-
|
|
5231
|
-
|
|
5531
|
+
result += expression + ",";
|
|
5532
|
+
expression = getAssignmentExpression(assignment);
|
|
5533
|
+
chainLength = 0;
|
|
5232
5534
|
}
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
newAssignments.push(current);
|
|
5236
|
-
return newAssignments;
|
|
5237
|
-
}
|
|
5238
|
-
function resolveAssignments(assignments) {
|
|
5239
|
-
if (assignments.length) {
|
|
5240
|
-
let result = "";
|
|
5241
|
-
const merged = mergeAssignments(assignments);
|
|
5242
|
-
for (let i = 0, len = merged.length; i < len; i++) result += getAssignmentExpression(merged[i]) + ",";
|
|
5243
|
-
return result;
|
|
5535
|
+
chainLength++;
|
|
5536
|
+
previous = assignment;
|
|
5244
5537
|
}
|
|
5538
|
+
return result + expression + ",";
|
|
5245
5539
|
}
|
|
5246
5540
|
var NULL_CONSTRUCTOR = "Object.create(null)";
|
|
5247
5541
|
var SET_CONSTRUCTOR = "new Set";
|
|
@@ -5259,28 +5553,20 @@ function createBaseSerializerContext(mode, options) {
|
|
|
5259
5553
|
mode,
|
|
5260
5554
|
plugins: options.plugins,
|
|
5261
5555
|
features: options.features,
|
|
5262
|
-
marked: new Set(options.markedRefs),
|
|
5556
|
+
marked: Array.isArray(options.markedRefs) ? new Set(options.markedRefs) : options.markedRefs,
|
|
5263
5557
|
stack: [],
|
|
5264
5558
|
flags: [],
|
|
5265
|
-
assignments: []
|
|
5559
|
+
assignments: [],
|
|
5560
|
+
assignAll: mode === 2 && !options.assignSharedRefsOnly
|
|
5266
5561
|
};
|
|
5267
5562
|
}
|
|
5268
5563
|
function createCrossSerializerContext(options) {
|
|
5269
5564
|
return {
|
|
5270
5565
|
mode: 2,
|
|
5271
5566
|
base: createBaseSerializerContext(2, options),
|
|
5272
|
-
state: options
|
|
5273
|
-
child: void 0
|
|
5567
|
+
state: options
|
|
5274
5568
|
};
|
|
5275
5569
|
}
|
|
5276
|
-
var SerializePluginContext = class {
|
|
5277
|
-
constructor(_p) {
|
|
5278
|
-
this._p = _p;
|
|
5279
|
-
}
|
|
5280
|
-
serialize(node) {
|
|
5281
|
-
return serialize$1(this._p, node);
|
|
5282
|
-
}
|
|
5283
|
-
};
|
|
5284
5570
|
function getVanillaRefParam(state, index) {
|
|
5285
5571
|
let actualIndex = state.valid.get(index);
|
|
5286
5572
|
if (actualIndex == null) {
|
|
@@ -5368,7 +5654,7 @@ function createArrayAssign(ctx, ref, index, value) {
|
|
|
5368
5654
|
createAssignment(ctx.base, getRefParam(ctx, ref) + "[" + index + "]", value);
|
|
5369
5655
|
}
|
|
5370
5656
|
function createObjectAssign(ctx, ref, key, value) {
|
|
5371
|
-
if (
|
|
5657
|
+
if (key === "__proto__") {
|
|
5372
5658
|
ctx.base.assignments.push({
|
|
5373
5659
|
t: 4,
|
|
5374
5660
|
s: getRefParam(ctx, ref),
|
|
@@ -5382,15 +5668,35 @@ function createObjectAssign(ctx, ref, key, value) {
|
|
|
5382
5668
|
function createSequenceAssign(ctx, ref, index, value) {
|
|
5383
5669
|
createAssignment(ctx.base, getRefParam(ctx, ref) + ".v[" + index + "]", value);
|
|
5384
5670
|
}
|
|
5671
|
+
function getKeyKind(key) {
|
|
5672
|
+
const first = key.charCodeAt(0);
|
|
5673
|
+
if (first >= 48 && first <= 57) {
|
|
5674
|
+
const check = Number(key);
|
|
5675
|
+
return check >= 0 && check.toString() === key ? 2 : 0;
|
|
5676
|
+
}
|
|
5677
|
+
if (key === "Infinity") return 2;
|
|
5678
|
+
return isValidIdentifier(key) ? 1 : 0;
|
|
5679
|
+
}
|
|
5385
5680
|
function isIndexedValueInStack(ctx, node) {
|
|
5386
5681
|
return node.t === 4 && ctx.stack.includes(node.i);
|
|
5387
5682
|
}
|
|
5683
|
+
function hasMarkedNode(ctx, node) {
|
|
5684
|
+
if (Array.isArray(node)) {
|
|
5685
|
+
for (let i = 0, len = node.length; i < len; i++) if (hasMarkedNode(ctx, node[i])) return true;
|
|
5686
|
+
return false;
|
|
5687
|
+
}
|
|
5688
|
+
if (node == null || typeof node !== "object") return false;
|
|
5689
|
+
const current = node;
|
|
5690
|
+
if (current.t !== 4 && typeof current.i === "number" && isSerializerRefMarked(ctx, current.i)) return true;
|
|
5691
|
+
for (const key in current) if (hasMarkedNode(ctx, current[key])) return true;
|
|
5692
|
+
return false;
|
|
5693
|
+
}
|
|
5388
5694
|
function assignIndexedValue(ctx, index, value) {
|
|
5389
|
-
if (ctx.
|
|
5695
|
+
if (!ctx.base.assignAll && !isSerializerRefMarked(ctx.base, index)) return value;
|
|
5390
5696
|
return getRefParam(ctx, index) + "=" + value;
|
|
5391
5697
|
}
|
|
5392
5698
|
function serializeReference(node) {
|
|
5393
|
-
return '
|
|
5699
|
+
return REFERENCES_KEY + '.get("' + node.s + '")';
|
|
5394
5700
|
}
|
|
5395
5701
|
function serializeArrayItem(ctx, id, item, index) {
|
|
5396
5702
|
if (item) {
|
|
@@ -5424,16 +5730,15 @@ function serializeArray(ctx, node) {
|
|
|
5424
5730
|
}
|
|
5425
5731
|
function serializeProperty(ctx, source, key, val) {
|
|
5426
5732
|
if (typeof key === "string") {
|
|
5427
|
-
const
|
|
5428
|
-
const isIdentifier = check >= 0 && check.toString() === key || isValidIdentifier(key);
|
|
5733
|
+
const kind = getKeyKind(key);
|
|
5429
5734
|
if (isIndexedValueInStack(ctx.base, val)) {
|
|
5430
5735
|
const refParam = getRefParam(ctx, val.i);
|
|
5431
5736
|
markSerializerRef(ctx.base, source.i);
|
|
5432
|
-
if (
|
|
5433
|
-
else createArrayAssign(ctx, source.i,
|
|
5737
|
+
if (kind === 1) createObjectAssign(ctx, source.i, key, refParam);
|
|
5738
|
+
else createArrayAssign(ctx, source.i, kind === 2 ? key : '"' + key + '"', refParam);
|
|
5434
5739
|
return "";
|
|
5435
5740
|
}
|
|
5436
|
-
if (
|
|
5741
|
+
if (key !== "__proto__") return (kind === 0 ? '"' + key + '"' : key) + ":" + serialize$1(ctx, val);
|
|
5437
5742
|
return '["' + key + '"]:' + serialize$1(ctx, val);
|
|
5438
5743
|
}
|
|
5439
5744
|
return "[" + serialize$1(ctx, key) + "]:" + serialize$1(ctx, val);
|
|
@@ -5445,7 +5750,7 @@ function serializeProperties(ctx, source, record) {
|
|
|
5445
5750
|
const values = record.v;
|
|
5446
5751
|
ctx.base.stack.push(source.i);
|
|
5447
5752
|
let result = serializeProperty(ctx, source, keys[0], values[0]);
|
|
5448
|
-
for (let i = 1, item
|
|
5753
|
+
for (let i = 1, item; i < len; i++) {
|
|
5449
5754
|
item = serializeProperty(ctx, source, keys[i], values[i]);
|
|
5450
5755
|
result += (item && result && ",") + item;
|
|
5451
5756
|
}
|
|
@@ -5466,18 +5771,14 @@ function serializeWithObjectAssign(ctx, source, value, serialized) {
|
|
|
5466
5771
|
function serializeStringKeyAssignment(ctx, source, mainAssignments, key, value) {
|
|
5467
5772
|
const base = ctx.base;
|
|
5468
5773
|
const serialized = serialize$1(ctx, value);
|
|
5469
|
-
const
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
if (isIdentifier && check !== check) createObjectAssign(ctx, source.i, key, serialized);
|
|
5478
|
-
else createArrayAssign(ctx, source.i, isIdentifier ? key : '"' + key + '"', serialized);
|
|
5479
|
-
base.assignments = parentAssignment;
|
|
5480
|
-
}
|
|
5774
|
+
const parentAssignment = base.assignments;
|
|
5775
|
+
if (!isIndexedValueInStack(base, value)) base.assignments = mainAssignments;
|
|
5776
|
+
createKeyAssign(ctx, source.i, getKeyKind(key), key, serialized);
|
|
5777
|
+
base.assignments = parentAssignment;
|
|
5778
|
+
}
|
|
5779
|
+
function createKeyAssign(ctx, ref, kind, key, value) {
|
|
5780
|
+
if (kind === 1) createObjectAssign(ctx, ref, key, value);
|
|
5781
|
+
else createArrayAssign(ctx, ref, kind === 2 ? key : '"' + key + '"', value);
|
|
5481
5782
|
}
|
|
5482
5783
|
function serializeAssignment(ctx, source, mainAssignments, key, value) {
|
|
5483
5784
|
if (typeof key === "string") serializeStringKeyAssignment(ctx, source, mainAssignments, key, value);
|
|
@@ -5508,7 +5809,7 @@ function serializeAssignments(ctx, source, node) {
|
|
|
5508
5809
|
function serializeDictionary(ctx, node, init) {
|
|
5509
5810
|
if (node.p) {
|
|
5510
5811
|
const base = ctx.base;
|
|
5511
|
-
if (base.features & 8) init = serializeWithObjectAssign(ctx, node, node.p, init);
|
|
5812
|
+
if (base.features & 8 && !node.p.k.includes("__proto__")) init = serializeWithObjectAssign(ctx, node, node.p, init);
|
|
5512
5813
|
else {
|
|
5513
5814
|
markSerializerRef(base, node.i);
|
|
5514
5815
|
const assignments = serializeAssignments(ctx, node, node.p);
|
|
@@ -5524,22 +5825,15 @@ function serializeNullConstructor(ctx, node) {
|
|
|
5524
5825
|
function serializeDate(node) {
|
|
5525
5826
|
return 'new Date("' + node.s + '")';
|
|
5526
5827
|
}
|
|
5527
|
-
var TEMPORAL_CONSTRUCTOR = {
|
|
5528
|
-
[0]: "Temporal.Instant",
|
|
5529
|
-
[1]: "Temporal.Duration",
|
|
5530
|
-
[2]: "Temporal.PlainDate",
|
|
5531
|
-
[3]: "Temporal.PlainDateTime",
|
|
5532
|
-
[4]: "Temporal.PlainMonthDay",
|
|
5533
|
-
[5]: "Temporal.PlainTime",
|
|
5534
|
-
[6]: "Temporal.PlainYearMonth",
|
|
5535
|
-
[7]: "Temporal.ZonedDateTime"
|
|
5536
|
-
};
|
|
5537
5828
|
function serializeTemporal(ctx, node) {
|
|
5538
|
-
if (ctx.base.features & 64) return
|
|
5829
|
+
if (ctx.base.features & 64) return "Temporal." + TEMPORAL_TYPE_NAME[node.c] + '.from("' + node.s + '")';
|
|
5539
5830
|
throw new SerovalUnsupportedNodeError(node);
|
|
5540
5831
|
}
|
|
5541
5832
|
function serializeRegExp(ctx, node) {
|
|
5542
|
-
if (ctx.base.features & 32)
|
|
5833
|
+
if (ctx.base.features & 32) {
|
|
5834
|
+
if (node.c.includes("\\x3C")) return 'new RegExp("' + node.c + '","' + node.m + '")';
|
|
5835
|
+
return "/" + deserializeString(node.c) + "/" + node.m;
|
|
5836
|
+
}
|
|
5543
5837
|
throw new SerovalUnsupportedNodeError(node);
|
|
5544
5838
|
}
|
|
5545
5839
|
function serializeSetItem(ctx, id, item) {
|
|
@@ -5559,7 +5853,7 @@ function serializeSet(ctx, node) {
|
|
|
5559
5853
|
if (size > 0) {
|
|
5560
5854
|
ctx.base.stack.push(id);
|
|
5561
5855
|
let result = serializeSetItem(ctx, id, items[0]);
|
|
5562
|
-
for (let i = 1, item
|
|
5856
|
+
for (let i = 1, item; i < size; i++) {
|
|
5563
5857
|
item = serializeSetItem(ctx, id, items[i]);
|
|
5564
5858
|
result += (item && result && ",") + item;
|
|
5565
5859
|
}
|
|
@@ -5568,7 +5862,7 @@ function serializeSet(ctx, node) {
|
|
|
5568
5862
|
}
|
|
5569
5863
|
return serialized;
|
|
5570
5864
|
}
|
|
5571
|
-
function serializeMapEntry(ctx, id, key, val,
|
|
5865
|
+
function serializeMapEntry(ctx, id, key, val, getSentinel) {
|
|
5572
5866
|
const base = ctx.base;
|
|
5573
5867
|
if (isIndexedValueInStack(base, key)) {
|
|
5574
5868
|
const keyRef = getRefParam(ctx, key.i);
|
|
@@ -5577,7 +5871,9 @@ function serializeMapEntry(ctx, id, key, val, sentinel) {
|
|
|
5577
5871
|
createSetAssignment(ctx, id, keyRef, getRefParam(ctx, val.i));
|
|
5578
5872
|
return "";
|
|
5579
5873
|
}
|
|
5580
|
-
if (val.t !== 4 && val.i != null &&
|
|
5874
|
+
if (val.t !== 4 && val.i != null && hasMarkedNode(base, val)) {
|
|
5875
|
+
markSerializerRef(base, val.i);
|
|
5876
|
+
const sentinel = getSentinel();
|
|
5581
5877
|
const serialized = "(" + serialize$1(ctx, val) + ",[" + sentinel + "," + sentinel + "])";
|
|
5582
5878
|
createSetAssignment(ctx, id, keyRef, getRefParam(ctx, val.i));
|
|
5583
5879
|
createDeleteAssignment(ctx, id, sentinel);
|
|
@@ -5592,7 +5888,9 @@ function serializeMapEntry(ctx, id, key, val, sentinel) {
|
|
|
5592
5888
|
if (isIndexedValueInStack(base, val)) {
|
|
5593
5889
|
const valueRef = getRefParam(ctx, val.i);
|
|
5594
5890
|
markSerializerRef(base, id);
|
|
5595
|
-
if (key.t !== 4 && key.i != null &&
|
|
5891
|
+
if (key.t !== 4 && key.i != null && hasMarkedNode(base, key)) {
|
|
5892
|
+
markSerializerRef(base, key.i);
|
|
5893
|
+
const sentinel = getSentinel();
|
|
5596
5894
|
const serialized = "(" + serialize$1(ctx, key) + ",[" + sentinel + "," + sentinel + "])";
|
|
5597
5895
|
createSetAssignment(ctx, id, getRefParam(ctx, key.i), valueRef);
|
|
5598
5896
|
createDeleteAssignment(ctx, id, sentinel);
|
|
@@ -5612,20 +5910,27 @@ function serializeMap(ctx, node) {
|
|
|
5612
5910
|
const size = keys.length;
|
|
5613
5911
|
const id = node.i;
|
|
5614
5912
|
const sentinel = node.f;
|
|
5615
|
-
|
|
5913
|
+
let sentinelRef;
|
|
5914
|
+
const getSentinel = () => {
|
|
5915
|
+
if (sentinelRef == null) {
|
|
5916
|
+
sentinelRef = getRefParam(ctx, sentinel.i);
|
|
5917
|
+
if (ctx.mode === 1) ctx.state.sentinels.add(ctx.state.valid.get(sentinel.i));
|
|
5918
|
+
}
|
|
5919
|
+
return sentinelRef;
|
|
5920
|
+
};
|
|
5616
5921
|
const base = ctx.base;
|
|
5617
5922
|
if (size > 0) {
|
|
5618
5923
|
const vals = node.e.v;
|
|
5619
5924
|
base.stack.push(id);
|
|
5620
|
-
let result = serializeMapEntry(ctx, id, keys[0], vals[0],
|
|
5621
|
-
for (let i = 1, item
|
|
5622
|
-
item = serializeMapEntry(ctx, id, keys[i], vals[i],
|
|
5925
|
+
let result = serializeMapEntry(ctx, id, keys[0], vals[0], getSentinel);
|
|
5926
|
+
for (let i = 1, item; i < size; i++) {
|
|
5927
|
+
item = serializeMapEntry(ctx, id, keys[i], vals[i], getSentinel);
|
|
5623
5928
|
result += (item && result && ",") + item;
|
|
5624
5929
|
}
|
|
5625
5930
|
base.stack.pop();
|
|
5626
5931
|
if (result) serialized += "([" + result + "])";
|
|
5627
5932
|
}
|
|
5628
|
-
if (sentinel.t === 26) {
|
|
5933
|
+
if (ctx.mode === 2 && sentinel.t === 26) {
|
|
5629
5934
|
markSerializerRef(base, sentinel.i);
|
|
5630
5935
|
serialized = "(" + serialize$1(ctx, sentinel) + "," + serialized + ")";
|
|
5631
5936
|
}
|
|
@@ -5634,11 +5939,8 @@ function serializeMap(ctx, node) {
|
|
|
5634
5939
|
function serializeArrayBuffer(ctx, node) {
|
|
5635
5940
|
return getConstructor(ctx, node.f) + '("' + node.s + '")';
|
|
5636
5941
|
}
|
|
5637
|
-
function
|
|
5638
|
-
return "new " + node.c + "(" + serialize$1(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
5639
|
-
}
|
|
5640
|
-
function serializeDataView(ctx, node) {
|
|
5641
|
-
return "new DataView(" + serialize$1(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
5942
|
+
function serializeView(ctx, node) {
|
|
5943
|
+
return "new " + (node.t === 20 ? "DataView" : node.c) + "(" + serialize$1(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
5642
5944
|
}
|
|
5643
5945
|
function serializeAggregateError(ctx, node) {
|
|
5644
5946
|
const id = node.i;
|
|
@@ -5678,11 +5980,7 @@ function serializePromiseConstructor(ctx, node) {
|
|
|
5678
5980
|
if (ctx.mode === 1) throw new SerovalUnsupportedNodeError(node);
|
|
5679
5981
|
return "(" + assignIndexedValue(ctx, node.s, getConstructor(ctx, node.f) + "()") + ").p";
|
|
5680
5982
|
}
|
|
5681
|
-
function
|
|
5682
|
-
if (ctx.mode === 1) throw new SerovalUnsupportedNodeError(node);
|
|
5683
|
-
return getConstructor(ctx, node.a[0]) + "(" + getRefParam(ctx, node.i) + "," + serialize$1(ctx, node.a[1]) + ")";
|
|
5684
|
-
}
|
|
5685
|
-
function serializePromiseReject(ctx, node) {
|
|
5983
|
+
function serializePromiseResult(ctx, node) {
|
|
5686
5984
|
if (ctx.mode === 1) throw new SerovalUnsupportedNodeError(node);
|
|
5687
5985
|
return getConstructor(ctx, node.a[0]) + "(" + getRefParam(ctx, node.i) + "," + serialize$1(ctx, node.a[1]) + ")";
|
|
5688
5986
|
}
|
|
@@ -5690,10 +5988,7 @@ function serializePlugin(ctx, node) {
|
|
|
5690
5988
|
const currentPlugins = ctx.base.plugins;
|
|
5691
5989
|
if (currentPlugins) for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
5692
5990
|
const plugin = currentPlugins[i];
|
|
5693
|
-
if (plugin.tag === node.c) {
|
|
5694
|
-
if (ctx.child == null) ctx.child = new SerializePluginContext(ctx);
|
|
5695
|
-
return plugin.serialize(node.s, ctx.child, { id: node.i });
|
|
5696
|
-
}
|
|
5991
|
+
if (plugin.tag === node.c) return plugin.serialize(node.s, { serialize: (current) => serialize$1(ctx, current) }, { id: node.i });
|
|
5697
5992
|
}
|
|
5698
5993
|
throw new SerovalMissingPluginError(node.c);
|
|
5699
5994
|
}
|
|
@@ -5730,11 +6025,8 @@ function serializeAsyncIteratorFactory(ctx, node) {
|
|
|
5730
6025
|
if (result) return result + iterator + ")";
|
|
5731
6026
|
return iterator;
|
|
5732
6027
|
}
|
|
5733
|
-
function serializeAsyncIteratorFactoryInstance(ctx, node) {
|
|
5734
|
-
return getConstructor(ctx, node.a[0]) + "(" + serialize$1(ctx, node.a[1]) + ")";
|
|
5735
|
-
}
|
|
5736
6028
|
function serializeStreamConstructor(ctx, node) {
|
|
5737
|
-
const result = assignIndexedValue(ctx, node.i, getConstructor(ctx, node.f) + "()");
|
|
6029
|
+
const result = assignIndexedValue(ctx, node.i, getConstructor(ctx, node.f) + (node.l === 1 ? "(1)" : "()"));
|
|
5738
6030
|
const len = node.a.length;
|
|
5739
6031
|
if (len) {
|
|
5740
6032
|
let values = serialize$1(ctx, node.a[0]);
|
|
@@ -5743,14 +6035,8 @@ function serializeStreamConstructor(ctx, node) {
|
|
|
5743
6035
|
}
|
|
5744
6036
|
return result;
|
|
5745
6037
|
}
|
|
5746
|
-
function
|
|
5747
|
-
return getRefParam(ctx, node.i) + ".
|
|
5748
|
-
}
|
|
5749
|
-
function serializeStreamThrow(ctx, node) {
|
|
5750
|
-
return getRefParam(ctx, node.i) + ".throw(" + serialize$1(ctx, node.f) + ")";
|
|
5751
|
-
}
|
|
5752
|
-
function serializeStreamReturn(ctx, node) {
|
|
5753
|
-
return getRefParam(ctx, node.i) + ".return(" + serialize$1(ctx, node.f) + ")";
|
|
6038
|
+
function serializeStreamCall(ctx, node, method) {
|
|
6039
|
+
return getRefParam(ctx, node.i) + "." + method + "(" + serialize$1(ctx, node.f) + ")";
|
|
5754
6040
|
}
|
|
5755
6041
|
function serializeSequenceItem(ctx, id, index, item) {
|
|
5756
6042
|
const base = ctx.base;
|
|
@@ -5768,7 +6054,7 @@ function serializeSequence(ctx, node) {
|
|
|
5768
6054
|
if (size > 0) {
|
|
5769
6055
|
ctx.base.stack.push(id);
|
|
5770
6056
|
let result = serializeSequenceItem(ctx, id, 0, items[0]);
|
|
5771
|
-
for (let i = 1, item
|
|
6057
|
+
for (let i = 1, item; i < size; i++) {
|
|
5772
6058
|
item = serializeSequenceItem(ctx, id, i, items[i]);
|
|
5773
6059
|
result += (item && result && ",") + item;
|
|
5774
6060
|
}
|
|
@@ -5801,9 +6087,8 @@ function serializeAssignable(ctx, node) {
|
|
|
5801
6087
|
return serializeArrayBuffer(ctx, node);
|
|
5802
6088
|
case 16:
|
|
5803
6089
|
case 15:
|
|
5804
|
-
return serializeTypedArray(ctx, node);
|
|
5805
6090
|
case 20:
|
|
5806
|
-
return
|
|
6091
|
+
return serializeView(ctx, node);
|
|
5807
6092
|
case 14:
|
|
5808
6093
|
return serializeAggregateError(ctx, node);
|
|
5809
6094
|
case 13:
|
|
@@ -5839,30 +6124,28 @@ function serialize$1(ctx, node) {
|
|
|
5839
6124
|
case 4:
|
|
5840
6125
|
return getRefParam(ctx, node.i);
|
|
5841
6126
|
case 23:
|
|
5842
|
-
return serializePromiseResolve(ctx, node);
|
|
5843
6127
|
case 24:
|
|
5844
|
-
return
|
|
6128
|
+
return serializePromiseResult(ctx, node);
|
|
5845
6129
|
case 27:
|
|
5846
6130
|
return serializeIteratorFactory(ctx, node);
|
|
5847
6131
|
case 28:
|
|
6132
|
+
case 30:
|
|
5848
6133
|
return serializeIteratorFactoryInstance(ctx, node);
|
|
5849
6134
|
case 29:
|
|
5850
6135
|
return serializeAsyncIteratorFactory(ctx, node);
|
|
5851
|
-
case 30:
|
|
5852
|
-
return serializeAsyncIteratorFactoryInstance(ctx, node);
|
|
5853
6136
|
case 31:
|
|
5854
6137
|
return serializeStreamConstructor(ctx, node);
|
|
5855
6138
|
case 32:
|
|
5856
|
-
return
|
|
6139
|
+
return serializeStreamCall(ctx, node, "next");
|
|
5857
6140
|
case 33:
|
|
5858
|
-
return
|
|
6141
|
+
return serializeStreamCall(ctx, node, "throw");
|
|
5859
6142
|
case 34:
|
|
5860
|
-
return
|
|
6143
|
+
return serializeStreamCall(ctx, node, "return");
|
|
5861
6144
|
default:
|
|
5862
6145
|
return assignIndexedValue(ctx, node.i, serializeAssignable(ctx, node));
|
|
5863
6146
|
}
|
|
5864
6147
|
}
|
|
5865
|
-
function
|
|
6148
|
+
function serializeCross(ctx, tree) {
|
|
5866
6149
|
const result = serialize$1(ctx, tree);
|
|
5867
6150
|
const id = tree.i;
|
|
5868
6151
|
if (id == null) return result;
|
|
@@ -5870,7 +6153,11 @@ function serializeTopCross(ctx, tree) {
|
|
|
5870
6153
|
const ref = getRefParam(ctx, id);
|
|
5871
6154
|
const scopeId = ctx.state.scopeId;
|
|
5872
6155
|
const params = scopeId == null ? "" : "$R";
|
|
5873
|
-
|
|
6156
|
+
let body = result;
|
|
6157
|
+
if (patches) {
|
|
6158
|
+
if (!ctx.base.assignAll && !result.startsWith(ref + "=")) body = ref + "=" + result;
|
|
6159
|
+
body = "(" + body + "," + patches + ref + ")";
|
|
6160
|
+
}
|
|
5874
6161
|
if (params === "") {
|
|
5875
6162
|
if (tree.t === 10 && !patches) return "(" + body + ")";
|
|
5876
6163
|
return body;
|
|
@@ -5878,67 +6165,20 @@ function serializeTopCross(ctx, tree) {
|
|
|
5878
6165
|
const args = scopeId == null ? "()" : '($R["' + serializeString(scopeId) + '"])';
|
|
5879
6166
|
return "(" + createFunction([params], body) + ")" + args;
|
|
5880
6167
|
}
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
this._p = _p;
|
|
5884
|
-
this.depth = depth;
|
|
5885
|
-
}
|
|
5886
|
-
parse(current) {
|
|
5887
|
-
return parseSOS(this._p, this.depth, current);
|
|
5888
|
-
}
|
|
5889
|
-
};
|
|
5890
|
-
var StreamParsePluginContext = class {
|
|
5891
|
-
constructor(_p, depth) {
|
|
5892
|
-
this._p = _p;
|
|
5893
|
-
this.depth = depth;
|
|
5894
|
-
}
|
|
5895
|
-
parse(current) {
|
|
5896
|
-
return parseSOS(this._p, this.depth, current);
|
|
5897
|
-
}
|
|
5898
|
-
parseWithError(current) {
|
|
5899
|
-
return parseWithError(this._p, this.depth, current);
|
|
5900
|
-
}
|
|
5901
|
-
isAlive() {
|
|
5902
|
-
return this._p.state.alive;
|
|
5903
|
-
}
|
|
5904
|
-
pushPendingState() {
|
|
5905
|
-
pushPendingState(this._p);
|
|
5906
|
-
}
|
|
5907
|
-
popPendingState() {
|
|
5908
|
-
popPendingState(this._p);
|
|
5909
|
-
}
|
|
5910
|
-
onParse(node) {
|
|
5911
|
-
onParse(this._p, node);
|
|
5912
|
-
}
|
|
5913
|
-
onError(error) {
|
|
5914
|
-
onError(this._p, error);
|
|
5915
|
-
}
|
|
5916
|
-
addCleanup(callback) {
|
|
5917
|
-
this._p.state.cleanups.push(callback);
|
|
5918
|
-
}
|
|
5919
|
-
};
|
|
5920
|
-
function createStreamParserState(options) {
|
|
5921
|
-
return {
|
|
5922
|
-
alive: true,
|
|
5923
|
-
pending: 0,
|
|
5924
|
-
initial: true,
|
|
5925
|
-
buffer: [],
|
|
5926
|
-
onParse: options.onParse,
|
|
5927
|
-
onError: options.onError,
|
|
5928
|
-
onDone: options.onDone,
|
|
5929
|
-
cleanups: []
|
|
5930
|
-
};
|
|
6168
|
+
function wrapSerializationError(error) {
|
|
6169
|
+
return error instanceof SerovalSerializationError ? error : new SerovalSerializationError(error);
|
|
5931
6170
|
}
|
|
5932
|
-
function
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
}
|
|
6171
|
+
function serializeTopCross(ctx, tree) {
|
|
6172
|
+
try {
|
|
6173
|
+
return serializeCross(ctx, tree);
|
|
6174
|
+
} catch (error) {
|
|
6175
|
+
throw wrapSerializationError(error);
|
|
6176
|
+
}
|
|
5938
6177
|
}
|
|
5939
6178
|
function parseItems(ctx, depth, current) {
|
|
5940
|
-
const
|
|
5941
|
-
|
|
6179
|
+
const len = current.length;
|
|
6180
|
+
const nodes = new Array(len);
|
|
6181
|
+
for (let i = 0; i < len; i++) if (i in current) nodes[i] = parseSOS(ctx, depth, current[i]);
|
|
5942
6182
|
else nodes[i] = 0;
|
|
5943
6183
|
return nodes;
|
|
5944
6184
|
}
|
|
@@ -5946,20 +6186,22 @@ function parseArray(ctx, depth, id, current) {
|
|
|
5946
6186
|
return createArrayNode(id, current, parseItems(ctx, depth, current));
|
|
5947
6187
|
}
|
|
5948
6188
|
function parseProperties(ctx, depth, properties) {
|
|
5949
|
-
const
|
|
5950
|
-
const
|
|
5951
|
-
const
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
6189
|
+
const keys = Object.keys(properties);
|
|
6190
|
+
const len = keys.length;
|
|
6191
|
+
const keyNodes = new Array(len);
|
|
6192
|
+
const valueNodes = new Array(len);
|
|
6193
|
+
for (let i = 0, key; i < len; i++) {
|
|
6194
|
+
key = keys[i];
|
|
6195
|
+
keyNodes[i] = serializeString(key);
|
|
6196
|
+
valueNodes[i] = parseSOS(ctx, depth, properties[key]);
|
|
5955
6197
|
}
|
|
5956
6198
|
if (SYM_ITERATOR in properties) {
|
|
5957
6199
|
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ITERATOR));
|
|
5958
|
-
valueNodes.push(createIteratorFactoryInstanceNode(parseIteratorFactory(ctx.base), parseSOS(ctx, depth, createSequenceFromIterable(properties))));
|
|
6200
|
+
valueNodes.push(createIteratorFactoryInstanceNode(28, parseIteratorFactory(ctx.base), parseSOS(ctx, depth, createSequenceFromIterable(properties))));
|
|
5959
6201
|
}
|
|
5960
6202
|
if (SYM_ASYNC_ITERATOR in properties) {
|
|
5961
6203
|
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ASYNC_ITERATOR));
|
|
5962
|
-
valueNodes.push(
|
|
6204
|
+
valueNodes.push(createIteratorFactoryInstanceNode(30, parseAsyncIteratorFactory(ctx.base), parseAsyncIterable(ctx, depth, properties)));
|
|
5963
6205
|
}
|
|
5964
6206
|
if (SYM_TO_STRING_TAG in properties) {
|
|
5965
6207
|
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_TO_STRING_TAG));
|
|
@@ -5974,206 +6216,142 @@ function parseProperties(ctx, depth, properties) {
|
|
|
5974
6216
|
v: valueNodes
|
|
5975
6217
|
};
|
|
5976
6218
|
}
|
|
6219
|
+
function parseAsyncIterable(ctx, depth, current) {
|
|
6220
|
+
if (ctx.type !== 2) throw new SerovalUnsupportedTypeError(current);
|
|
6221
|
+
const id = createIndexForValue(ctx.base, {});
|
|
6222
|
+
const result = createStreamConstructorNode(id, parseSpecialReference(ctx.base, 4), []);
|
|
6223
|
+
ctx.state.iterable(ctx, depth, id, current);
|
|
6224
|
+
return result;
|
|
6225
|
+
}
|
|
5977
6226
|
function parsePlainObject(ctx, depth, id, current, empty) {
|
|
5978
6227
|
return createObjectNode(id, current, empty, parseProperties(ctx, depth, current));
|
|
5979
6228
|
}
|
|
5980
6229
|
function parseBoxed(ctx, depth, id, current) {
|
|
5981
6230
|
return createBoxedNode(id, parseSOS(ctx, depth, current.valueOf()));
|
|
5982
6231
|
}
|
|
5983
|
-
function
|
|
6232
|
+
function parseView(ctx, depth, type, id, current) {
|
|
5984
6233
|
current = getArrayBufferView(ctx.base, current);
|
|
5985
|
-
return
|
|
6234
|
+
return createViewNode(type, id, current, parseSOS(ctx, depth, current.buffer));
|
|
5986
6235
|
}
|
|
5987
|
-
function
|
|
5988
|
-
current = getArrayBufferView(ctx.base, current);
|
|
5989
|
-
return createBigIntTypedArrayNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
5990
|
-
}
|
|
5991
|
-
function parseDataView(ctx, depth, id, current) {
|
|
5992
|
-
current = getArrayBufferView(ctx.base, current);
|
|
5993
|
-
return createDataViewNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
5994
|
-
}
|
|
5995
|
-
function parseError(ctx, depth, id, current) {
|
|
6236
|
+
function parseError(ctx, depth, type, id, current) {
|
|
5996
6237
|
const options = getErrorOptions(current, ctx.base.features);
|
|
5997
|
-
return createErrorNode(id, current, options ? parseProperties(ctx, depth, options) : void 0);
|
|
5998
|
-
}
|
|
5999
|
-
function parseAggregateError(ctx, depth, id, current) {
|
|
6000
|
-
const options = getErrorOptions(current, ctx.base.features);
|
|
6001
|
-
return createAggregateErrorNode(id, current, options ? parseProperties(ctx, depth, options) : void 0);
|
|
6238
|
+
return createErrorNode(type, id, current, options ? parseProperties(ctx, depth, options) : void 0);
|
|
6002
6239
|
}
|
|
6003
6240
|
function parseMap(ctx, depth, id, current) {
|
|
6004
|
-
const
|
|
6005
|
-
const
|
|
6241
|
+
const sentinel = parseMapSentinel(ctx.base);
|
|
6242
|
+
const keyNodes = new Array(current.size);
|
|
6243
|
+
const valueNodes = new Array(current.size);
|
|
6244
|
+
let i = 0;
|
|
6006
6245
|
for (const [key, value] of current.entries()) {
|
|
6007
|
-
keyNodes
|
|
6008
|
-
valueNodes
|
|
6246
|
+
keyNodes[i] = parseSOS(ctx, depth, key);
|
|
6247
|
+
valueNodes[i] = parseSOS(ctx, depth, value);
|
|
6248
|
+
i++;
|
|
6009
6249
|
}
|
|
6010
|
-
return createMapNode(
|
|
6250
|
+
return createMapNode(id, sentinel, keyNodes, valueNodes);
|
|
6011
6251
|
}
|
|
6012
6252
|
function parseSet(ctx, depth, id, current) {
|
|
6013
|
-
const items =
|
|
6014
|
-
|
|
6253
|
+
const items = new Array(current.size);
|
|
6254
|
+
let i = 0;
|
|
6255
|
+
for (const item of current.keys()) items[i++] = parseSOS(ctx, depth, item);
|
|
6015
6256
|
return createSetNode(id, items);
|
|
6016
6257
|
}
|
|
6017
|
-
function
|
|
6018
|
-
const
|
|
6019
|
-
if (
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
}
|
|
6027
|
-
},
|
|
6028
|
-
throw: (value) => {
|
|
6029
|
-
if (ctx.state.alive) {
|
|
6030
|
-
const parsed = parseWithError(ctx, depth, value);
|
|
6031
|
-
if (parsed) onParse(ctx, createStreamThrowNode(id, parsed));
|
|
6032
|
-
}
|
|
6033
|
-
popPendingState(ctx);
|
|
6034
|
-
},
|
|
6035
|
-
return: (value) => {
|
|
6036
|
-
if (ctx.state.alive) {
|
|
6037
|
-
const parsed = parseWithError(ctx, depth, value);
|
|
6038
|
-
if (parsed) onParse(ctx, createStreamReturnNode(id, parsed));
|
|
6039
|
-
}
|
|
6040
|
-
popPendingState(ctx);
|
|
6041
|
-
}
|
|
6042
|
-
});
|
|
6043
|
-
return result;
|
|
6258
|
+
function parseEndedStream(ctx, depth, id, current) {
|
|
6259
|
+
const events = current.endedEvents();
|
|
6260
|
+
if (!events) throw new SerovalUnsupportedTypeError(current);
|
|
6261
|
+
const values = events.values;
|
|
6262
|
+
const last2 = values.length - 1;
|
|
6263
|
+
const sequence = new Array(values.length);
|
|
6264
|
+
if (last2 >= 0) markParserRef(ctx.base, id);
|
|
6265
|
+
for (let i = 0; i <= last2; i++) sequence[i] = createStreamEventNode(i < last2 ? 32 : events.success ? 34 : 33, id, parseSOS(ctx, depth, values[i]));
|
|
6266
|
+
return sequence;
|
|
6044
6267
|
}
|
|
6045
|
-
function
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6268
|
+
function parseStream(ctx, depth, id, current) {
|
|
6269
|
+
const reference = parseSpecialReference(ctx.base, 4);
|
|
6270
|
+
if (ctx.type === 2) {
|
|
6271
|
+
const result = createStreamConstructorNode(id, reference, []);
|
|
6272
|
+
ctx.state.stream(ctx, depth, id, current);
|
|
6273
|
+
return result;
|
|
6050
6274
|
}
|
|
6275
|
+
return createStreamConstructorNode(id, reference, parseEndedStream(ctx, depth, id, current));
|
|
6051
6276
|
}
|
|
6052
|
-
function
|
|
6053
|
-
if (
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
popPendingState(this);
|
|
6277
|
+
function parseLiveStream(ctx, depth, id, current) {
|
|
6278
|
+
if (ctx.type !== 2) throw new SerovalUnsupportedTypeError(current);
|
|
6279
|
+
const result = createStreamConstructorNode(id, parseSpecialReference(ctx.base, 4), [], 1);
|
|
6280
|
+
ctx.state.live(ctx, depth, id, current);
|
|
6281
|
+
return result;
|
|
6058
6282
|
}
|
|
6059
6283
|
function parsePromise(ctx, depth, id, current) {
|
|
6284
|
+
if (ctx.type !== 2) throw new SerovalUnsupportedTypeError(current);
|
|
6060
6285
|
const resolver = createIndexForValue(ctx.base, {});
|
|
6061
|
-
|
|
6062
|
-
pushPendingState(ctx);
|
|
6063
|
-
current.then(handlePromiseSuccess.bind(ctx, resolver, depth), handlePromiseFailure.bind(ctx, resolver, depth));
|
|
6064
|
-
}
|
|
6286
|
+
ctx.state.promise(ctx, resolver, depth, current);
|
|
6065
6287
|
return createPromiseConstructorNode(ctx.base, id, resolver);
|
|
6066
6288
|
}
|
|
6067
6289
|
function parsePluginSync(ctx, depth, id, current, currentPlugins) {
|
|
6068
6290
|
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
6069
6291
|
const plugin = currentPlugins[i];
|
|
6070
|
-
if (plugin.parse.sync && plugin.test(current)) return createPluginNode(id, plugin.tag, plugin.parse.sync(current,
|
|
6071
|
-
}
|
|
6072
|
-
}
|
|
6073
|
-
function parsePluginStream(ctx, depth, id, current, currentPlugins) {
|
|
6074
|
-
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
6075
|
-
const plugin = currentPlugins[i];
|
|
6076
|
-
if (plugin.parse.stream && plugin.test(current)) return createPluginNode(id, plugin.tag, plugin.parse.stream(current, new StreamParsePluginContext(ctx, depth), { id }));
|
|
6292
|
+
if (plugin.parse.sync && plugin.test(current)) return createPluginNode(id, plugin.tag, plugin.parse.sync(current, { parse: (value) => parseSOS(ctx, depth, value) }, { id }));
|
|
6077
6293
|
}
|
|
6078
6294
|
}
|
|
6079
|
-
function parsePlugin(ctx, depth, id, current) {
|
|
6080
|
-
|
|
6081
|
-
if (currentPlugins) return ctx.type === 1 ? parsePluginSync(ctx, depth, id, current, currentPlugins) : parsePluginStream(ctx, depth, id, current, currentPlugins);
|
|
6295
|
+
function parsePlugin(ctx, depth, id, current, currentPlugins) {
|
|
6296
|
+
if (currentPlugins) return ctx.type === 1 ? parsePluginSync(ctx, depth, id, current, currentPlugins) : ctx.state.plugin(ctx, depth, id, current, currentPlugins);
|
|
6082
6297
|
}
|
|
6083
6298
|
function parseSequence(ctx, depth, id, current) {
|
|
6084
|
-
const
|
|
6085
|
-
|
|
6299
|
+
const len = current.v.length;
|
|
6300
|
+
const nodes = new Array(len);
|
|
6301
|
+
for (let i = 0; i < len; i++) nodes[i] = parseSOS(ctx, depth, current.v[i]);
|
|
6086
6302
|
return createSequenceNode(id, nodes, current.t, current.d);
|
|
6087
6303
|
}
|
|
6088
6304
|
function parseObjectPhase2(ctx, depth, id, current, currentClass) {
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
case void 0:
|
|
6305
|
+
if (currentClass === Object) return parsePlainObject(ctx, depth, id, current, false);
|
|
6306
|
+
switch (getObjectKind(current, currentClass, ctx.base.features)) {
|
|
6307
|
+
case 2:
|
|
6093
6308
|
return parsePlainObject(ctx, depth, id, current, true);
|
|
6094
|
-
case
|
|
6309
|
+
case 3:
|
|
6095
6310
|
return createDateNode(id, current);
|
|
6096
|
-
case
|
|
6097
|
-
|
|
6098
|
-
case
|
|
6099
|
-
|
|
6100
|
-
case
|
|
6101
|
-
case TypeError:
|
|
6102
|
-
case URIError:
|
|
6103
|
-
return parseError(ctx, depth, id, current);
|
|
6104
|
-
case Number:
|
|
6105
|
-
case Boolean:
|
|
6106
|
-
case String:
|
|
6107
|
-
case BigInt:
|
|
6311
|
+
case 4:
|
|
6312
|
+
return parseError(ctx, depth, 13, id, current);
|
|
6313
|
+
case 5:
|
|
6314
|
+
return parseError(ctx, depth, 14, id, current);
|
|
6315
|
+
case 6:
|
|
6108
6316
|
return parseBoxed(ctx, depth, id, current);
|
|
6109
|
-
case
|
|
6317
|
+
case 7:
|
|
6110
6318
|
return createArrayBufferNode(ctx.base, id, current);
|
|
6111
|
-
case
|
|
6112
|
-
|
|
6113
|
-
case
|
|
6114
|
-
|
|
6115
|
-
case
|
|
6116
|
-
|
|
6117
|
-
case
|
|
6118
|
-
case Float32Array:
|
|
6119
|
-
case Float64Array:
|
|
6120
|
-
return parseTypedArray(ctx, depth, id, current);
|
|
6121
|
-
case DataView:
|
|
6122
|
-
return parseDataView(ctx, depth, id, current);
|
|
6123
|
-
case Map:
|
|
6319
|
+
case 8:
|
|
6320
|
+
return parseView(ctx, depth, 15, id, current);
|
|
6321
|
+
case 9:
|
|
6322
|
+
return parseView(ctx, depth, 16, id, current);
|
|
6323
|
+
case 10:
|
|
6324
|
+
return parseView(ctx, depth, 20, id, current);
|
|
6325
|
+
case 11:
|
|
6124
6326
|
return parseMap(ctx, depth, id, current);
|
|
6125
|
-
case
|
|
6327
|
+
case 12:
|
|
6126
6328
|
return parseSet(ctx, depth, id, current);
|
|
6329
|
+
case 13:
|
|
6330
|
+
return parsePromise(ctx, depth, id, current);
|
|
6331
|
+
case 14:
|
|
6332
|
+
return createRegExpNode(id, current);
|
|
6333
|
+
case 15:
|
|
6334
|
+
return createTemporalNode(id, getTemporalType(currentClass), current);
|
|
6335
|
+
case 16:
|
|
6336
|
+
return parsePlainObject(ctx, depth, id, current, !!currentClass);
|
|
6337
|
+
default:
|
|
6338
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
6127
6339
|
}
|
|
6128
|
-
if (currentClass === Promise || current instanceof Promise) return parsePromise(ctx, depth, id, current);
|
|
6129
|
-
const currentFeatures = ctx.base.features;
|
|
6130
|
-
if (currentFeatures & 32 && currentClass === RegExp) return createRegExpNode(id, current);
|
|
6131
|
-
if (currentFeatures & 16) switch (currentClass) {
|
|
6132
|
-
case BigInt64Array:
|
|
6133
|
-
case BigUint64Array:
|
|
6134
|
-
return parseBigIntTypedArray(ctx, depth, id, current);
|
|
6135
|
-
}
|
|
6136
|
-
if (currentFeatures & 1 && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) return parseAggregateError(ctx, depth, id, current);
|
|
6137
|
-
if (currentFeatures & 64 && typeof Temporal !== "undefined") switch (currentClass) {
|
|
6138
|
-
case Temporal.Instant:
|
|
6139
|
-
return createTemporalNode(id, 0, current);
|
|
6140
|
-
case Temporal.Duration:
|
|
6141
|
-
return createTemporalNode(id, 1, current);
|
|
6142
|
-
case Temporal.PlainDate:
|
|
6143
|
-
return createTemporalNode(id, 2, current);
|
|
6144
|
-
case Temporal.PlainDateTime:
|
|
6145
|
-
return createTemporalNode(id, 3, current);
|
|
6146
|
-
case Temporal.PlainMonthDay:
|
|
6147
|
-
return createTemporalNode(id, 4, current);
|
|
6148
|
-
case Temporal.PlainTime:
|
|
6149
|
-
return createTemporalNode(id, 5, current);
|
|
6150
|
-
case Temporal.PlainYearMonth:
|
|
6151
|
-
return createTemporalNode(id, 6, current);
|
|
6152
|
-
case Temporal.ZonedDateTime:
|
|
6153
|
-
return createTemporalNode(id, 7, current);
|
|
6154
|
-
}
|
|
6155
|
-
if (current instanceof Error) return parseError(ctx, depth, id, current);
|
|
6156
|
-
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) return parsePlainObject(ctx, depth, id, current, !!currentClass);
|
|
6157
|
-
throw new SerovalUnsupportedTypeError(current);
|
|
6158
6340
|
}
|
|
6159
6341
|
function parseObject(ctx, depth, id, current) {
|
|
6160
6342
|
if (Array.isArray(current)) return parseArray(ctx, depth, id, current);
|
|
6161
|
-
if (isStream(current)) return parseStream(ctx, depth, id, current);
|
|
6343
|
+
if (isStream(current)) return isLiveStream(current) ? parseLiveStream(ctx, depth, id, current) : parseStream(ctx, depth, id, current);
|
|
6162
6344
|
if (isSequence(current)) return parseSequence(ctx, depth, id, current);
|
|
6163
|
-
|
|
6164
|
-
if (currentClass !== void 0 && typeof currentClass !== "function") {
|
|
6165
|
-
const proto = Object.getPrototypeOf(current);
|
|
6166
|
-
currentClass = proto === null ? void 0 : proto.constructor;
|
|
6167
|
-
}
|
|
6345
|
+
const currentClass = getObjectClass(current);
|
|
6168
6346
|
if (currentClass === OpaqueReference) return parseSOS(ctx, depth, current.replacement);
|
|
6169
|
-
const parsed = parsePlugin(ctx, depth, id, current);
|
|
6347
|
+
const parsed = parsePlugin(ctx, depth, id, current, getObjectPlugins(ctx.base, current, currentClass));
|
|
6170
6348
|
if (parsed) return parsed;
|
|
6171
6349
|
return parseObjectPhase2(ctx, depth, id, current, currentClass);
|
|
6172
6350
|
}
|
|
6173
6351
|
function parseFunction(ctx, depth, current) {
|
|
6174
6352
|
const ref = getReferenceNode(ctx.base, current);
|
|
6175
|
-
if (ref
|
|
6176
|
-
const plugin = parsePlugin(ctx, depth, ref
|
|
6353
|
+
if (typeof ref !== "number") return ref;
|
|
6354
|
+
const plugin = parsePlugin(ctx, depth, ref, current, ctx.base.plugins);
|
|
6177
6355
|
if (plugin) return plugin;
|
|
6178
6356
|
throw new SerovalUnsupportedTypeError(current);
|
|
6179
6357
|
}
|
|
@@ -6193,7 +6371,7 @@ function parseSOS(ctx, depth, current) {
|
|
|
6193
6371
|
case "object":
|
|
6194
6372
|
if (current) {
|
|
6195
6373
|
const ref = getReferenceNode(ctx.base, current);
|
|
6196
|
-
return ref
|
|
6374
|
+
return typeof ref === "number" ? parseObject(ctx, depth + 1, ref, current) : ref;
|
|
6197
6375
|
}
|
|
6198
6376
|
return NULL_NODE;
|
|
6199
6377
|
case "symbol":
|
|
@@ -6204,61 +6382,402 @@ function parseSOS(ctx, depth, current) {
|
|
|
6204
6382
|
throw new SerovalUnsupportedTypeError(current);
|
|
6205
6383
|
}
|
|
6206
6384
|
}
|
|
6207
|
-
function
|
|
6208
|
-
|
|
6209
|
-
|
|
6385
|
+
function createStreamParsePluginContext(ctx, depth) {
|
|
6386
|
+
const state = ctx.state;
|
|
6387
|
+
function parse(current) {
|
|
6388
|
+
state.parsing++;
|
|
6389
|
+
try {
|
|
6390
|
+
return parseSOS(ctx, depth, current);
|
|
6391
|
+
} finally {
|
|
6392
|
+
state.parsing--;
|
|
6393
|
+
if (!state.alive) releaseParserValues(ctx);
|
|
6394
|
+
}
|
|
6395
|
+
}
|
|
6396
|
+
return {
|
|
6397
|
+
parse,
|
|
6398
|
+
parseStreamSource(current) {
|
|
6399
|
+
state.parsing++;
|
|
6400
|
+
try {
|
|
6401
|
+
if (depth >= ctx.base.depthLimit) throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
6402
|
+
const id = createIndexForValue(ctx.base, {});
|
|
6403
|
+
const node = createStreamConstructorNode(id, parseSpecialReference(ctx.base, 4), [], 1);
|
|
6404
|
+
iterateAsync(ctx, depth + 1, id, current, true);
|
|
6405
|
+
return node;
|
|
6406
|
+
} finally {
|
|
6407
|
+
state.parsing--;
|
|
6408
|
+
if (!state.alive) releaseParserValues(ctx);
|
|
6409
|
+
}
|
|
6410
|
+
},
|
|
6411
|
+
parseWithError(current) {
|
|
6412
|
+
try {
|
|
6413
|
+
return parse(current);
|
|
6414
|
+
} catch (error) {
|
|
6415
|
+
stopStreamParse(ctx, 1, error);
|
|
6416
|
+
return;
|
|
6417
|
+
}
|
|
6418
|
+
},
|
|
6419
|
+
isAlive: () => state.alive,
|
|
6420
|
+
pushPendingState: () => {
|
|
6421
|
+
pushPendingState(ctx);
|
|
6422
|
+
},
|
|
6423
|
+
popPendingState: () => {
|
|
6424
|
+
popPendingState(ctx);
|
|
6425
|
+
},
|
|
6426
|
+
onParse(node) {
|
|
6427
|
+
if (state.alive) {
|
|
6428
|
+
state.queue.push({
|
|
6429
|
+
node,
|
|
6430
|
+
initial: false,
|
|
6431
|
+
accept: void 0
|
|
6432
|
+
});
|
|
6433
|
+
drainOutput(ctx);
|
|
6434
|
+
}
|
|
6435
|
+
},
|
|
6436
|
+
onError(error) {
|
|
6437
|
+
stopStreamParse(ctx, 1, error);
|
|
6438
|
+
},
|
|
6439
|
+
addCleanup(callback) {
|
|
6440
|
+
addCleanup(ctx, callback);
|
|
6441
|
+
}
|
|
6442
|
+
};
|
|
6443
|
+
}
|
|
6444
|
+
function getStreamParsePluginContext(ctx, depth) {
|
|
6445
|
+
const contexts = ctx.state.pluginContexts;
|
|
6446
|
+
return contexts[depth] ?? (contexts[depth] = createStreamParsePluginContext(ctx, depth));
|
|
6447
|
+
}
|
|
6448
|
+
function addCleanup(ctx, callback) {
|
|
6449
|
+
if (ctx.state.alive) ctx.state.cleanups.push(callback);
|
|
6450
|
+
else callback();
|
|
6210
6451
|
}
|
|
6211
|
-
function
|
|
6212
|
-
|
|
6213
|
-
|
|
6452
|
+
function parsePluginStream(ctx, depth, id, current, currentPlugins) {
|
|
6453
|
+
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
6454
|
+
const plugin = currentPlugins[i];
|
|
6455
|
+
if (plugin.parse.stream && plugin.test(current)) return createPluginNode(id, plugin.tag, plugin.parse.stream(current, getStreamParsePluginContext(ctx, depth), { id }));
|
|
6456
|
+
}
|
|
6214
6457
|
}
|
|
6215
|
-
function
|
|
6216
|
-
|
|
6217
|
-
|
|
6458
|
+
function streamListener(ctx, depth, id, subscription) {
|
|
6459
|
+
const handle = (type, terminal) => (value, accept) => {
|
|
6460
|
+
let failure = void 0;
|
|
6461
|
+
if (ctx.state.alive) try {
|
|
6462
|
+
failure = parseEvent(ctx, depth, value, createStreamEventNode.bind(null, type, id), accept);
|
|
6463
|
+
} catch (error) {
|
|
6464
|
+
if (!subscription?.active) throw error;
|
|
6465
|
+
subscription.failure ?? (subscription.failure = { value: error });
|
|
6466
|
+
failure = error;
|
|
6467
|
+
}
|
|
6468
|
+
if (terminal && !accept) popPendingState(ctx);
|
|
6469
|
+
return failure;
|
|
6470
|
+
};
|
|
6471
|
+
return {
|
|
6472
|
+
next: handle(32, false),
|
|
6473
|
+
throw: handle(33, true),
|
|
6474
|
+
return: handle(34, true),
|
|
6475
|
+
done() {
|
|
6476
|
+
popPendingState(ctx);
|
|
6477
|
+
},
|
|
6478
|
+
error(reason) {
|
|
6479
|
+
if (ctx.state.alive) stopStreamParse(ctx, 1, reason);
|
|
6480
|
+
}
|
|
6481
|
+
};
|
|
6218
6482
|
}
|
|
6219
|
-
function
|
|
6483
|
+
function subscribeStream(ctx, depth, id, current) {
|
|
6484
|
+
pushPendingState(ctx);
|
|
6485
|
+
const subscription = {
|
|
6486
|
+
active: true,
|
|
6487
|
+
failure: void 0
|
|
6488
|
+
};
|
|
6489
|
+
let cleanup;
|
|
6220
6490
|
try {
|
|
6221
|
-
|
|
6491
|
+
cleanup = current.on(streamListener(ctx, depth, id, subscription));
|
|
6492
|
+
} finally {
|
|
6493
|
+
subscription.active = false;
|
|
6494
|
+
}
|
|
6495
|
+
try {
|
|
6496
|
+
addCleanup(ctx, cleanup);
|
|
6222
6497
|
} catch (error) {
|
|
6223
|
-
|
|
6498
|
+
subscription.failure ?? (subscription.failure = { value: error });
|
|
6499
|
+
}
|
|
6500
|
+
const failure = subscription.failure;
|
|
6501
|
+
subscription.failure = void 0;
|
|
6502
|
+
if (failure) throw failure.value;
|
|
6503
|
+
}
|
|
6504
|
+
function consumeLiveStream(ctx, depth, id, current) {
|
|
6505
|
+
const cancel = current.pump(streamListener(ctx, depth, id));
|
|
6506
|
+
pushPendingState(ctx);
|
|
6507
|
+
addCleanup(ctx, () => {
|
|
6508
|
+
cancel(ctx.state.reason);
|
|
6509
|
+
});
|
|
6510
|
+
}
|
|
6511
|
+
function wrapPromiseResult(ctx, type, id, node) {
|
|
6512
|
+
return createSerovalNode(type, id, void 0, void 0, void 0, void 0, void 0, [parseSpecialReference(ctx.base, type === 23 ? 2 : 3), node], void 0, void 0, void 0, void 0);
|
|
6513
|
+
}
|
|
6514
|
+
function handlePromise(type, id, depth, data) {
|
|
6515
|
+
if (this.state.alive) parseEvent(this, depth, data, wrapPromiseResult.bind(null, this, type, id), void 0);
|
|
6516
|
+
popPendingState(this);
|
|
6517
|
+
}
|
|
6518
|
+
function watchPromise(ctx, resolver, depth, current) {
|
|
6519
|
+
pushPendingState(ctx);
|
|
6520
|
+
current.then(handlePromise.bind(ctx, 23, resolver, depth), handlePromise.bind(ctx, 24, resolver, depth));
|
|
6521
|
+
}
|
|
6522
|
+
function returnIterator(iterator) {
|
|
6523
|
+
Promise.resolve().then(() => iterator.return?.()).catch(() => {
|
|
6524
|
+
});
|
|
6525
|
+
}
|
|
6526
|
+
function iterateAsync(ctx, depth, id, current, forwardReason) {
|
|
6527
|
+
const iterator = current[SYM_ASYNC_ITERATOR]();
|
|
6528
|
+
const listener = streamListener(ctx, depth, id);
|
|
6529
|
+
let active = true;
|
|
6530
|
+
function stop() {
|
|
6531
|
+
if (active) {
|
|
6532
|
+
active = false;
|
|
6533
|
+
if (forwardReason) try {
|
|
6534
|
+
Promise.resolve(iterator.return?.(ctx.state.reason)).catch(() => {
|
|
6535
|
+
});
|
|
6536
|
+
} catch {
|
|
6537
|
+
}
|
|
6538
|
+
else returnIterator(iterator);
|
|
6539
|
+
}
|
|
6540
|
+
}
|
|
6541
|
+
function pull() {
|
|
6542
|
+
if (active) iterator.next().then((result) => {
|
|
6543
|
+
if (active) {
|
|
6544
|
+
if (result.done) {
|
|
6545
|
+
active = false;
|
|
6546
|
+
listener.return(result.value, void 0);
|
|
6547
|
+
} else if (listener.next(result.value, pull) !== void 0) {
|
|
6548
|
+
stop();
|
|
6549
|
+
listener.done();
|
|
6550
|
+
}
|
|
6551
|
+
}
|
|
6552
|
+
}, (error) => {
|
|
6553
|
+
if (active) {
|
|
6554
|
+
active = false;
|
|
6555
|
+
listener.throw(error, void 0);
|
|
6556
|
+
}
|
|
6557
|
+
});
|
|
6224
6558
|
}
|
|
6559
|
+
pushPendingState(ctx);
|
|
6560
|
+
addCleanup(ctx, stop);
|
|
6561
|
+
pull();
|
|
6562
|
+
}
|
|
6563
|
+
function createStreamParserState(options) {
|
|
6564
|
+
return {
|
|
6565
|
+
alive: true,
|
|
6566
|
+
pending: 0,
|
|
6567
|
+
parsing: 0,
|
|
6568
|
+
queue: [],
|
|
6569
|
+
writing: false,
|
|
6570
|
+
inFlight: void 0,
|
|
6571
|
+
reason: void 0,
|
|
6572
|
+
onParse: options.onParse,
|
|
6573
|
+
onError: options.onError,
|
|
6574
|
+
onDone: options.onDone,
|
|
6575
|
+
cleanups: [],
|
|
6576
|
+
pluginContexts: [],
|
|
6577
|
+
stream: subscribeStream,
|
|
6578
|
+
live: consumeLiveStream,
|
|
6579
|
+
promise: watchPromise,
|
|
6580
|
+
iterable: iterateAsync,
|
|
6581
|
+
plugin: parsePluginStream
|
|
6582
|
+
};
|
|
6583
|
+
}
|
|
6584
|
+
function createStreamParserContext(options) {
|
|
6585
|
+
return {
|
|
6586
|
+
type: 2,
|
|
6587
|
+
base: createBaseParserContext(options),
|
|
6588
|
+
state: createStreamParserState(options)
|
|
6589
|
+
};
|
|
6225
6590
|
}
|
|
6226
6591
|
function pushPendingState(ctx) {
|
|
6227
|
-
ctx.state.pending++;
|
|
6592
|
+
if (ctx.state.alive) ctx.state.pending++;
|
|
6228
6593
|
}
|
|
6229
6594
|
function popPendingState(ctx) {
|
|
6230
|
-
if (
|
|
6595
|
+
if (ctx.state.alive) {
|
|
6596
|
+
ctx.state.pending--;
|
|
6597
|
+
checkStreamParse(ctx);
|
|
6598
|
+
}
|
|
6231
6599
|
}
|
|
6232
|
-
function
|
|
6600
|
+
function parseEvent(ctx, depth, value, wrap, accept) {
|
|
6601
|
+
const state = ctx.state;
|
|
6602
|
+
const record = {
|
|
6603
|
+
node: void 0,
|
|
6604
|
+
initial: false,
|
|
6605
|
+
accept
|
|
6606
|
+
};
|
|
6607
|
+
let failure;
|
|
6608
|
+
state.queue.push(record);
|
|
6609
|
+
state.parsing++;
|
|
6233
6610
|
try {
|
|
6234
|
-
|
|
6235
|
-
} catch (
|
|
6236
|
-
|
|
6237
|
-
|
|
6611
|
+
record.node = wrap(parseSOS(ctx, depth, value));
|
|
6612
|
+
} catch (error) {
|
|
6613
|
+
failure = { value: error };
|
|
6614
|
+
} finally {
|
|
6615
|
+
state.parsing--;
|
|
6616
|
+
if (!state.alive) releaseParserValues(ctx);
|
|
6617
|
+
}
|
|
6618
|
+
if (failure) stopStreamParse(ctx, 1, failure.value);
|
|
6619
|
+
else drainOutput(ctx);
|
|
6620
|
+
return failure?.value;
|
|
6621
|
+
}
|
|
6622
|
+
function drainOutput(ctx) {
|
|
6623
|
+
const state = ctx.state;
|
|
6624
|
+
if (state.writing || state.parsing > 0) return;
|
|
6625
|
+
while (state.alive && state.queue.length > 0) {
|
|
6626
|
+
const record = state.queue.shift();
|
|
6627
|
+
if (!record.node) continue;
|
|
6628
|
+
let pending;
|
|
6629
|
+
state.writing = true;
|
|
6630
|
+
state.inFlight = record;
|
|
6631
|
+
state.parsing++;
|
|
6632
|
+
try {
|
|
6633
|
+
if (!state.onParse) throw new Error("Stream output callback is unavailable");
|
|
6634
|
+
const result = state.onParse(record.node, record.initial);
|
|
6635
|
+
if (result !== null && (typeof result === "object" || typeof result === "function")) {
|
|
6636
|
+
const then = Reflect.get(result, "then");
|
|
6637
|
+
if (typeof then === "function") pending = new Promise((resolve, reject) => {
|
|
6638
|
+
Reflect.apply(then, result, [resolve, reject]);
|
|
6639
|
+
});
|
|
6640
|
+
}
|
|
6641
|
+
} catch (error) {
|
|
6642
|
+
releaseRecord(record);
|
|
6643
|
+
stopStreamParse(ctx, 1, error);
|
|
6644
|
+
return;
|
|
6645
|
+
} finally {
|
|
6646
|
+
state.parsing--;
|
|
6647
|
+
if (!state.alive) releaseParserValues(ctx);
|
|
6648
|
+
}
|
|
6649
|
+
record.node = void 0;
|
|
6650
|
+
if (pending) {
|
|
6651
|
+
if (!state.alive) releaseRecord(record);
|
|
6652
|
+
pending.then(() => {
|
|
6653
|
+
state.writing = false;
|
|
6654
|
+
state.inFlight = void 0;
|
|
6655
|
+
if (state.alive) {
|
|
6656
|
+
const accept2 = record.accept;
|
|
6657
|
+
releaseRecord(record);
|
|
6658
|
+
accept2?.();
|
|
6659
|
+
drainOutput(ctx);
|
|
6660
|
+
}
|
|
6661
|
+
}, (error) => {
|
|
6662
|
+
state.writing = false;
|
|
6663
|
+
state.inFlight = void 0;
|
|
6664
|
+
releaseRecord(record);
|
|
6665
|
+
stopStreamParse(ctx, 1, error);
|
|
6666
|
+
});
|
|
6667
|
+
return;
|
|
6668
|
+
}
|
|
6669
|
+
if (!state.alive) {
|
|
6670
|
+
releaseRecord(record);
|
|
6671
|
+
return;
|
|
6672
|
+
}
|
|
6673
|
+
state.writing = false;
|
|
6674
|
+
state.inFlight = void 0;
|
|
6675
|
+
const accept = record.accept;
|
|
6676
|
+
releaseRecord(record);
|
|
6677
|
+
accept?.();
|
|
6238
6678
|
}
|
|
6679
|
+
checkStreamParse(ctx);
|
|
6680
|
+
}
|
|
6681
|
+
function checkStreamParse(ctx) {
|
|
6682
|
+
const state = ctx.state;
|
|
6683
|
+
if (state.alive && state.parsing === 0 && state.pending <= 0 && state.queue.length === 0 && !state.writing) stopStreamParse(ctx, 0);
|
|
6239
6684
|
}
|
|
6240
6685
|
function startStreamParse(ctx, current) {
|
|
6241
|
-
const
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6686
|
+
const state = ctx.state;
|
|
6687
|
+
let parsed;
|
|
6688
|
+
let failure;
|
|
6689
|
+
state.parsing++;
|
|
6690
|
+
try {
|
|
6691
|
+
parsed = parseSOS(ctx, 0, current);
|
|
6692
|
+
} catch (error) {
|
|
6693
|
+
failure = { value: error };
|
|
6694
|
+
} finally {
|
|
6695
|
+
state.parsing--;
|
|
6696
|
+
if (!state.alive) releaseParserValues(ctx);
|
|
6697
|
+
}
|
|
6698
|
+
if (failure) {
|
|
6699
|
+
if (state.alive) stopStreamParse(ctx, 1, failure.value);
|
|
6700
|
+
else throw failure.value;
|
|
6701
|
+
} else if (parsed && state.alive) {
|
|
6702
|
+
state.queue.unshift({
|
|
6703
|
+
node: parsed,
|
|
6704
|
+
initial: true,
|
|
6705
|
+
accept: void 0
|
|
6706
|
+
});
|
|
6707
|
+
drainOutput(ctx);
|
|
6247
6708
|
}
|
|
6248
6709
|
}
|
|
6249
|
-
function
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6710
|
+
function runCleanups(state) {
|
|
6711
|
+
const cleanups = state.cleanups;
|
|
6712
|
+
let failure;
|
|
6713
|
+
state.cleanups = [];
|
|
6714
|
+
for (const record of state.queue) releaseRecord(record);
|
|
6715
|
+
state.queue.length = 0;
|
|
6716
|
+
if (state.inFlight) releaseRecord(state.inFlight);
|
|
6717
|
+
state.inFlight = void 0;
|
|
6718
|
+
for (let i = 0, len = cleanups.length; i < len; i++) try {
|
|
6719
|
+
cleanups[i]();
|
|
6720
|
+
} catch (error) {
|
|
6721
|
+
failure ?? (failure = { value: error });
|
|
6722
|
+
}
|
|
6723
|
+
if (failure) throw failure.value;
|
|
6724
|
+
}
|
|
6725
|
+
function releaseRecord(record) {
|
|
6726
|
+
record.node = void 0;
|
|
6727
|
+
record.accept = void 0;
|
|
6728
|
+
}
|
|
6729
|
+
function releaseParserValues(ctx) {
|
|
6730
|
+
ctx.base.refs = /* @__PURE__ */ new Map();
|
|
6731
|
+
ctx.base.marked.clear();
|
|
6732
|
+
ctx.base.plugins = void 0;
|
|
6733
|
+
ctx.base.plainObjectPlugins = void 0;
|
|
6734
|
+
ctx.state.pluginContexts = [];
|
|
6735
|
+
if (ctx.state.parsing === 0) ctx.state.reason = void 0;
|
|
6736
|
+
}
|
|
6737
|
+
function stopStreamParse(ctx, mode, reason) {
|
|
6738
|
+
const state = ctx.state;
|
|
6739
|
+
if (state.alive) {
|
|
6740
|
+
state.alive = false;
|
|
6741
|
+
const onError = state.onError;
|
|
6742
|
+
const onDone = state.onDone;
|
|
6743
|
+
if (mode === 1 && !onError && !(reason instanceof SerovalParserError)) reason = new SerovalParserError(reason);
|
|
6744
|
+
state.reason = reason;
|
|
6745
|
+
state.onParse = void 0;
|
|
6746
|
+
state.onError = void 0;
|
|
6747
|
+
state.onDone = void 0;
|
|
6748
|
+
state.writing = false;
|
|
6749
|
+
state.parsing++;
|
|
6750
|
+
let failure;
|
|
6751
|
+
try {
|
|
6752
|
+
if (mode === 1) {
|
|
6753
|
+
if (onError) onError(reason);
|
|
6754
|
+
else throw reason;
|
|
6755
|
+
} else if (mode === 0) onDone?.();
|
|
6756
|
+
} catch (error) {
|
|
6757
|
+
failure = { value: error };
|
|
6758
|
+
}
|
|
6759
|
+
try {
|
|
6760
|
+
runCleanups(state);
|
|
6761
|
+
} catch (error) {
|
|
6762
|
+
failure ?? (failure = { value: error });
|
|
6763
|
+
} finally {
|
|
6764
|
+
state.parsing--;
|
|
6765
|
+
releaseParserValues(ctx);
|
|
6766
|
+
state.pending = 0;
|
|
6767
|
+
}
|
|
6768
|
+
if (failure) throw failure.value;
|
|
6256
6769
|
}
|
|
6257
6770
|
}
|
|
6771
|
+
function destroyStreamParse(ctx, reason) {
|
|
6772
|
+
stopStreamParse(ctx, 2, reason);
|
|
6773
|
+
}
|
|
6258
6774
|
function crossSerializeStream(source, options) {
|
|
6259
6775
|
const plugins = resolvePlugins(options.plugins);
|
|
6776
|
+
const onSerialize = options.onSerialize;
|
|
6777
|
+
const scopeId = options.scopeId;
|
|
6260
6778
|
const ctx = createStreamParserContext({
|
|
6261
6779
|
compactArrayBufferViews: options.compactArrayBufferViews,
|
|
6780
|
+
depthLimit: options.depthLimit,
|
|
6262
6781
|
plugins,
|
|
6263
6782
|
refs: options.refs,
|
|
6264
6783
|
disabledFeatures: options.disabledFeatures,
|
|
@@ -6266,17 +6785,10 @@ function crossSerializeStream(source, options) {
|
|
|
6266
6785
|
const serial = createCrossSerializerContext({
|
|
6267
6786
|
plugins,
|
|
6268
6787
|
features: ctx.base.features,
|
|
6269
|
-
scopeId
|
|
6788
|
+
scopeId,
|
|
6270
6789
|
markedRefs: ctx.base.marked
|
|
6271
6790
|
});
|
|
6272
|
-
|
|
6273
|
-
try {
|
|
6274
|
-
serialized = serializeTopCross(serial, node);
|
|
6275
|
-
} catch (err) {
|
|
6276
|
-
if (options.onError) options.onError(err);
|
|
6277
|
-
return;
|
|
6278
|
-
}
|
|
6279
|
-
options.onSerialize(serialized, initial);
|
|
6791
|
+
return onSerialize(serializeTopCross(serial, node), initial);
|
|
6280
6792
|
},
|
|
6281
6793
|
onError: options.onError,
|
|
6282
6794
|
onDone: options.onDone
|
|
@@ -8211,10 +8723,9 @@ export {
|
|
|
8211
8723
|
createInlineCssStyleAsset,
|
|
8212
8724
|
createInlineCssPlaceholderAsset,
|
|
8213
8725
|
createSerializationAdapter,
|
|
8214
|
-
getCrossReferenceHeader,
|
|
8215
|
-
isStream,
|
|
8216
8726
|
createStream,
|
|
8217
8727
|
createPlugin,
|
|
8728
|
+
getCrossReferenceHeader,
|
|
8218
8729
|
crossSerializeStream,
|
|
8219
8730
|
makeSerovalPlugin,
|
|
8220
8731
|
RawStream,
|