seroval 0.10.4 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/development/index.cjs +842 -318
- package/dist/cjs/development/index.cjs.map +4 -4
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +842 -318
- package/dist/esm/development/index.mjs.map +4 -4
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/compat.d.ts +2 -1
- package/dist/types/core/constants.d.ts +6 -1
- package/dist/types/core/constructors.d.ts +4 -0
- package/dist/types/core/types.d.ts +31 -2
- package/dist/types/core/web-api.d.ts +4 -4
- package/package.json +8 -9
- package/src/core/compat.ts +3 -1
- package/src/core/constants.ts +5 -0
- package/src/core/constructors.ts +49 -0
- package/src/core/cross/async.ts +208 -76
- package/src/core/cross/serialize.ts +61 -0
- package/src/core/cross/stream.ts +203 -79
- package/src/core/cross/sync.ts +126 -61
- package/src/core/tree/async.ts +209 -76
- package/src/core/tree/deserialize.ts +82 -0
- package/src/core/tree/primitives.ts +0 -9
- package/src/core/tree/serialize.ts +62 -0
- package/src/core/tree/sync.ts +126 -61
- package/src/core/types.ts +49 -2
- package/src/core/web-api.ts +21 -9
|
@@ -63,6 +63,7 @@ var Feature = /* @__PURE__ */ ((Feature2) => {
|
|
|
63
63
|
return Feature2;
|
|
64
64
|
})(Feature || {});
|
|
65
65
|
var ALL_ENABLED = 16383;
|
|
66
|
+
var BIGINT_FLAG = 4096 /* BigIntTypedArray */ | 8 /* BigInt */;
|
|
66
67
|
|
|
67
68
|
// src/core/constants.ts
|
|
68
69
|
var SYMBOL_STRING = {
|
|
@@ -155,13 +156,6 @@ function deserializeConstant(node) {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
// src/core/assert.ts
|
|
159
|
-
function assert(cond, error) {
|
|
160
|
-
if (!cond) {
|
|
161
|
-
throw error;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
159
|
// src/core/get-identifier.ts
|
|
166
160
|
var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
167
161
|
var REF_START_CHARS_LEN = REF_START_CHARS.length;
|
|
@@ -320,6 +314,13 @@ var INFINITY_NODE = createConstantNode(5 /* Infinity */);
|
|
|
320
314
|
var NEG_INFINITY_NODE = createConstantNode(6 /* NegativeInfinity */);
|
|
321
315
|
var NAN_NODE = createConstantNode(7 /* NaN */);
|
|
322
316
|
|
|
317
|
+
// src/core/assert.ts
|
|
318
|
+
function assert(cond, error) {
|
|
319
|
+
if (!cond) {
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
323
324
|
// src/core/keys.ts
|
|
324
325
|
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
325
326
|
var GLOBAL_CONTEXT_API = "_$";
|
|
@@ -569,7 +570,6 @@ function serializeArrayBuffer(ctx, current) {
|
|
|
569
570
|
return createArrayBufferNode(id, current);
|
|
570
571
|
}
|
|
571
572
|
function createTypedArrayNode(ctx, id, current) {
|
|
572
|
-
assert(ctx.features & 2048 /* TypedArray */, new UnsupportedTypeError(current));
|
|
573
573
|
return {
|
|
574
574
|
t: 15 /* TypedArray */,
|
|
575
575
|
i: id,
|
|
@@ -585,12 +585,7 @@ function createTypedArrayNode(ctx, id, current) {
|
|
|
585
585
|
o: void 0
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
var BIGINT_FLAG = 4096 /* BigIntTypedArray */ | 8 /* BigInt */;
|
|
589
588
|
function createBigIntTypedArrayNode(ctx, id, current) {
|
|
590
|
-
assert(
|
|
591
|
-
(ctx.features & BIGINT_FLAG) === BIGINT_FLAG,
|
|
592
|
-
new UnsupportedTypeError(current)
|
|
593
|
-
);
|
|
594
589
|
return {
|
|
595
590
|
t: 16 /* BigIntTypedArray */,
|
|
596
591
|
i: id,
|
|
@@ -817,8 +812,7 @@ async function createFileNode(ctx, id, current) {
|
|
|
817
812
|
}
|
|
818
813
|
|
|
819
814
|
// src/core/web-api.ts
|
|
820
|
-
function createURLNode(
|
|
821
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
815
|
+
function createURLNode(id, current) {
|
|
822
816
|
return {
|
|
823
817
|
t: 18 /* URL */,
|
|
824
818
|
i: id,
|
|
@@ -834,8 +828,7 @@ function createURLNode(ctx, id, current) {
|
|
|
834
828
|
o: void 0
|
|
835
829
|
};
|
|
836
830
|
}
|
|
837
|
-
function createURLSearchParamsNode(
|
|
838
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
831
|
+
function createURLSearchParamsNode(id, current) {
|
|
839
832
|
return {
|
|
840
833
|
t: 19 /* URLSearchParams */,
|
|
841
834
|
i: id,
|
|
@@ -851,6 +844,22 @@ function createURLSearchParamsNode(ctx, id, current) {
|
|
|
851
844
|
o: void 0
|
|
852
845
|
};
|
|
853
846
|
}
|
|
847
|
+
function createDOMExceptionNode(id, current) {
|
|
848
|
+
return {
|
|
849
|
+
t: 39 /* DOMException */,
|
|
850
|
+
i: id,
|
|
851
|
+
s: serializeString(current.message),
|
|
852
|
+
l: void 0,
|
|
853
|
+
c: serializeString(current.name),
|
|
854
|
+
m: void 0,
|
|
855
|
+
p: void 0,
|
|
856
|
+
e: void 0,
|
|
857
|
+
a: void 0,
|
|
858
|
+
f: void 0,
|
|
859
|
+
b: void 0,
|
|
860
|
+
o: void 0
|
|
861
|
+
};
|
|
862
|
+
}
|
|
854
863
|
|
|
855
864
|
// src/core/promise-to-result.ts
|
|
856
865
|
async function promiseToResult(current) {
|
|
@@ -861,6 +870,45 @@ async function promiseToResult(current) {
|
|
|
861
870
|
}
|
|
862
871
|
}
|
|
863
872
|
|
|
873
|
+
// src/core/constructors.ts
|
|
874
|
+
function createRequestOptions(current, body) {
|
|
875
|
+
return {
|
|
876
|
+
body,
|
|
877
|
+
cache: current.cache,
|
|
878
|
+
credentials: current.credentials,
|
|
879
|
+
headers: current.headers,
|
|
880
|
+
integrity: current.integrity,
|
|
881
|
+
keepalive: current.keepalive,
|
|
882
|
+
method: current.method,
|
|
883
|
+
mode: current.mode,
|
|
884
|
+
redirect: current.redirect,
|
|
885
|
+
referrer: current.referrer,
|
|
886
|
+
referrerPolicy: current.referrerPolicy
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function createResponseOptions(current) {
|
|
890
|
+
return {
|
|
891
|
+
headers: current.headers,
|
|
892
|
+
status: current.status,
|
|
893
|
+
statusText: current.statusText
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function createEventOptions(current) {
|
|
897
|
+
return {
|
|
898
|
+
bubbles: current.bubbles,
|
|
899
|
+
cancelable: current.cancelable,
|
|
900
|
+
composed: current.composed
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
function createCustomEventOptions(current) {
|
|
904
|
+
return {
|
|
905
|
+
detail: current.detail,
|
|
906
|
+
bubbles: current.bubbles,
|
|
907
|
+
cancelable: current.cancelable,
|
|
908
|
+
composed: current.composed
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
864
912
|
// src/core/tree/async.ts
|
|
865
913
|
async function generateNodeList(ctx, current) {
|
|
866
914
|
const size = current.length;
|
|
@@ -901,7 +949,6 @@ async function generateArrayNode(ctx, id, current) {
|
|
|
901
949
|
};
|
|
902
950
|
}
|
|
903
951
|
async function generateMapNode(ctx, id, current) {
|
|
904
|
-
assert(ctx.features & 32 /* Map */, new UnsupportedTypeError(current));
|
|
905
952
|
const len = current.size;
|
|
906
953
|
const keyNodes = new Array(len);
|
|
907
954
|
const valueNodes = new Array(len);
|
|
@@ -940,7 +987,6 @@ async function generateMapNode(ctx, id, current) {
|
|
|
940
987
|
};
|
|
941
988
|
}
|
|
942
989
|
async function generateSetNode(ctx, id, current) {
|
|
943
|
-
assert(ctx.features & 512 /* Set */, new UnsupportedTypeError(current));
|
|
944
990
|
const len = current.size;
|
|
945
991
|
const nodes = new Array(len);
|
|
946
992
|
const deferred = new Array(len);
|
|
@@ -1052,7 +1098,6 @@ async function generatePlainProperties(ctx, properties) {
|
|
|
1052
1098
|
};
|
|
1053
1099
|
}
|
|
1054
1100
|
async function generatePromiseNode(ctx, id, current) {
|
|
1055
|
-
assert(ctx.features & 256 /* Promise */, new UnsupportedTypeError(current));
|
|
1056
1101
|
const [status, result] = await promiseToResult(current);
|
|
1057
1102
|
return {
|
|
1058
1103
|
t: 12 /* Promise */,
|
|
@@ -1122,7 +1167,6 @@ async function generateErrorNode(ctx, id, current) {
|
|
|
1122
1167
|
};
|
|
1123
1168
|
}
|
|
1124
1169
|
async function generateHeadersNode(ctx, id, current) {
|
|
1125
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
1126
1170
|
const items = {};
|
|
1127
1171
|
current.forEach((value, key) => {
|
|
1128
1172
|
items[key] = value;
|
|
@@ -1143,7 +1187,6 @@ async function generateHeadersNode(ctx, id, current) {
|
|
|
1143
1187
|
};
|
|
1144
1188
|
}
|
|
1145
1189
|
async function generateFormDataNode(ctx, id, current) {
|
|
1146
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
1147
1190
|
const items = {};
|
|
1148
1191
|
current.forEach((value, key) => {
|
|
1149
1192
|
items[key] = value;
|
|
@@ -1179,6 +1222,76 @@ async function generateBoxedNode(ctx, id, current) {
|
|
|
1179
1222
|
o: void 0
|
|
1180
1223
|
};
|
|
1181
1224
|
}
|
|
1225
|
+
async function generateRequestNode(ctx, id, current) {
|
|
1226
|
+
return {
|
|
1227
|
+
t: 35 /* Request */,
|
|
1228
|
+
i: id,
|
|
1229
|
+
s: serializeString(current.url),
|
|
1230
|
+
l: void 0,
|
|
1231
|
+
c: void 0,
|
|
1232
|
+
m: void 0,
|
|
1233
|
+
p: void 0,
|
|
1234
|
+
e: void 0,
|
|
1235
|
+
f: await parseObject(
|
|
1236
|
+
ctx,
|
|
1237
|
+
createRequestOptions(current, current.body ? await current.clone().arrayBuffer() : null)
|
|
1238
|
+
),
|
|
1239
|
+
a: void 0,
|
|
1240
|
+
b: void 0,
|
|
1241
|
+
o: void 0
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
async function generateResponseNode(ctx, id, current) {
|
|
1245
|
+
return {
|
|
1246
|
+
t: 36 /* Response */,
|
|
1247
|
+
i: id,
|
|
1248
|
+
s: void 0,
|
|
1249
|
+
l: void 0,
|
|
1250
|
+
c: void 0,
|
|
1251
|
+
m: void 0,
|
|
1252
|
+
p: void 0,
|
|
1253
|
+
e: void 0,
|
|
1254
|
+
f: void 0,
|
|
1255
|
+
a: [
|
|
1256
|
+
current.body ? serializeArrayBuffer(ctx, await current.clone().arrayBuffer()) : NULL_NODE,
|
|
1257
|
+
await parseObject(ctx, createResponseOptions(current))
|
|
1258
|
+
],
|
|
1259
|
+
b: void 0,
|
|
1260
|
+
o: void 0
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
async function generateEventNode(ctx, id, current) {
|
|
1264
|
+
return {
|
|
1265
|
+
t: 37 /* Event */,
|
|
1266
|
+
i: id,
|
|
1267
|
+
s: serializeString(current.type),
|
|
1268
|
+
l: void 0,
|
|
1269
|
+
c: void 0,
|
|
1270
|
+
m: void 0,
|
|
1271
|
+
p: void 0,
|
|
1272
|
+
e: void 0,
|
|
1273
|
+
a: void 0,
|
|
1274
|
+
f: await parseObject(ctx, createEventOptions(current)),
|
|
1275
|
+
b: void 0,
|
|
1276
|
+
o: void 0
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
async function generateCustomEventNode(ctx, id, current) {
|
|
1280
|
+
return {
|
|
1281
|
+
t: 38 /* CustomEvent */,
|
|
1282
|
+
i: id,
|
|
1283
|
+
s: serializeString(current.type),
|
|
1284
|
+
l: void 0,
|
|
1285
|
+
c: void 0,
|
|
1286
|
+
m: void 0,
|
|
1287
|
+
p: void 0,
|
|
1288
|
+
e: void 0,
|
|
1289
|
+
a: void 0,
|
|
1290
|
+
f: await parseObject(ctx, createCustomEventOptions(current)),
|
|
1291
|
+
b: void 0,
|
|
1292
|
+
o: void 0
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1182
1295
|
async function parseObject(ctx, current) {
|
|
1183
1296
|
if (!current) {
|
|
1184
1297
|
return NULL_NODE;
|
|
@@ -1193,49 +1306,17 @@ async function parseObject(ctx, current) {
|
|
|
1193
1306
|
if (Array.isArray(current)) {
|
|
1194
1307
|
return generateArrayNode(ctx, id, current);
|
|
1195
1308
|
}
|
|
1196
|
-
|
|
1309
|
+
const currentClass = current.constructor;
|
|
1310
|
+
switch (currentClass) {
|
|
1197
1311
|
case Number:
|
|
1198
1312
|
case Boolean:
|
|
1199
1313
|
case String:
|
|
1200
1314
|
case BigInt:
|
|
1201
|
-
case Function:
|
|
1202
|
-
case Symbol:
|
|
1203
1315
|
return generateBoxedNode(ctx, id, current);
|
|
1204
1316
|
case Date:
|
|
1205
1317
|
return createDateNode(id, current);
|
|
1206
1318
|
case RegExp:
|
|
1207
1319
|
return createRegExpNode(id, current);
|
|
1208
|
-
case Promise:
|
|
1209
|
-
return generatePromiseNode(ctx, id, current);
|
|
1210
|
-
case ArrayBuffer:
|
|
1211
|
-
return createArrayBufferNode(id, current);
|
|
1212
|
-
case Int8Array:
|
|
1213
|
-
case Int16Array:
|
|
1214
|
-
case Int32Array:
|
|
1215
|
-
case Uint8Array:
|
|
1216
|
-
case Uint16Array:
|
|
1217
|
-
case Uint32Array:
|
|
1218
|
-
case Uint8ClampedArray:
|
|
1219
|
-
case Float32Array:
|
|
1220
|
-
case Float64Array:
|
|
1221
|
-
return createTypedArrayNode(ctx, id, current);
|
|
1222
|
-
case BigInt64Array:
|
|
1223
|
-
case BigUint64Array:
|
|
1224
|
-
return createBigIntTypedArrayNode(ctx, id, current);
|
|
1225
|
-
case DataView:
|
|
1226
|
-
return createDataViewNode(ctx, id, current);
|
|
1227
|
-
case Map:
|
|
1228
|
-
return generateMapNode(
|
|
1229
|
-
ctx,
|
|
1230
|
-
id,
|
|
1231
|
-
current
|
|
1232
|
-
);
|
|
1233
|
-
case Set:
|
|
1234
|
-
return generateSetNode(
|
|
1235
|
-
ctx,
|
|
1236
|
-
id,
|
|
1237
|
-
current
|
|
1238
|
-
);
|
|
1239
1320
|
case Object:
|
|
1240
1321
|
return generateObjectNode(
|
|
1241
1322
|
ctx,
|
|
@@ -1250,11 +1331,6 @@ async function parseObject(ctx, current) {
|
|
|
1250
1331
|
current,
|
|
1251
1332
|
true
|
|
1252
1333
|
);
|
|
1253
|
-
case AggregateError:
|
|
1254
|
-
if (ctx.features & 1 /* AggregateError */) {
|
|
1255
|
-
return generateAggregateErrorNode(ctx, id, current);
|
|
1256
|
-
}
|
|
1257
|
-
return generateErrorNode(ctx, id, current);
|
|
1258
1334
|
case Error:
|
|
1259
1335
|
case EvalError:
|
|
1260
1336
|
case RangeError:
|
|
@@ -1263,40 +1339,100 @@ async function parseObject(ctx, current) {
|
|
|
1263
1339
|
case TypeError:
|
|
1264
1340
|
case URIError:
|
|
1265
1341
|
return generateErrorNode(ctx, id, current);
|
|
1266
|
-
case URL:
|
|
1267
|
-
return createURLNode(ctx, id, current);
|
|
1268
|
-
case URLSearchParams:
|
|
1269
|
-
return createURLSearchParamsNode(ctx, id, current);
|
|
1270
|
-
case Blob:
|
|
1271
|
-
return createBlobNode(ctx, id, current);
|
|
1272
|
-
case File:
|
|
1273
|
-
return createFileNode(ctx, id, current);
|
|
1274
|
-
case Headers:
|
|
1275
|
-
return generateHeadersNode(ctx, id, current);
|
|
1276
|
-
case FormData:
|
|
1277
|
-
return generateFormDataNode(ctx, id, current);
|
|
1278
1342
|
default:
|
|
1279
1343
|
break;
|
|
1280
1344
|
}
|
|
1281
|
-
if (
|
|
1282
|
-
|
|
1283
|
-
|
|
1345
|
+
if (ctx.features & 2048 /* TypedArray */) {
|
|
1346
|
+
switch (currentClass) {
|
|
1347
|
+
case ArrayBuffer:
|
|
1348
|
+
return createArrayBufferNode(id, current);
|
|
1349
|
+
case Int8Array:
|
|
1350
|
+
case Int16Array:
|
|
1351
|
+
case Int32Array:
|
|
1352
|
+
case Uint8Array:
|
|
1353
|
+
case Uint16Array:
|
|
1354
|
+
case Uint32Array:
|
|
1355
|
+
case Uint8ClampedArray:
|
|
1356
|
+
case Float32Array:
|
|
1357
|
+
case Float64Array:
|
|
1358
|
+
return createTypedArrayNode(ctx, id, current);
|
|
1359
|
+
case DataView:
|
|
1360
|
+
return createDataViewNode(ctx, id, current);
|
|
1361
|
+
default:
|
|
1362
|
+
break;
|
|
1284
1363
|
}
|
|
1285
|
-
return generateErrorNode(ctx, id, current);
|
|
1286
1364
|
}
|
|
1287
|
-
if (
|
|
1288
|
-
|
|
1365
|
+
if ((ctx.features & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
1366
|
+
switch (currentClass) {
|
|
1367
|
+
case BigInt64Array:
|
|
1368
|
+
case BigUint64Array:
|
|
1369
|
+
return createBigIntTypedArrayNode(ctx, id, current);
|
|
1370
|
+
default:
|
|
1371
|
+
break;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
if (ctx.features & 32 /* Map */ && currentClass === Map) {
|
|
1375
|
+
return generateMapNode(
|
|
1376
|
+
ctx,
|
|
1377
|
+
id,
|
|
1378
|
+
current
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
if (ctx.features & 512 /* Set */ && currentClass === Set) {
|
|
1382
|
+
return generateSetNode(
|
|
1383
|
+
ctx,
|
|
1384
|
+
id,
|
|
1385
|
+
current
|
|
1386
|
+
);
|
|
1289
1387
|
}
|
|
1290
|
-
if (
|
|
1388
|
+
if (ctx.features & 8192 /* WebAPI */) {
|
|
1389
|
+
switch (currentClass) {
|
|
1390
|
+
case URL:
|
|
1391
|
+
return createURLNode(id, current);
|
|
1392
|
+
case URLSearchParams:
|
|
1393
|
+
return createURLSearchParamsNode(id, current);
|
|
1394
|
+
case Blob:
|
|
1395
|
+
return createBlobNode(ctx, id, current);
|
|
1396
|
+
case File:
|
|
1397
|
+
return createFileNode(ctx, id, current);
|
|
1398
|
+
case Headers:
|
|
1399
|
+
return generateHeadersNode(ctx, id, current);
|
|
1400
|
+
case FormData:
|
|
1401
|
+
return generateFormDataNode(ctx, id, current);
|
|
1402
|
+
case Request:
|
|
1403
|
+
return generateRequestNode(ctx, id, current);
|
|
1404
|
+
case Response:
|
|
1405
|
+
return generateResponseNode(ctx, id, current);
|
|
1406
|
+
case Event:
|
|
1407
|
+
return generateEventNode(ctx, id, current);
|
|
1408
|
+
case CustomEvent:
|
|
1409
|
+
return generateCustomEventNode(ctx, id, current);
|
|
1410
|
+
case DOMException:
|
|
1411
|
+
return createDOMExceptionNode(id, current);
|
|
1412
|
+
default:
|
|
1413
|
+
break;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
if (ctx.features & 1 /* AggregateError */ && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
1417
|
+
return generateAggregateErrorNode(ctx, id, current);
|
|
1418
|
+
}
|
|
1419
|
+
if (ctx.features & 256 /* Promise */ && (currentClass === Promise || current instanceof Promise)) {
|
|
1291
1420
|
return generatePromiseNode(ctx, id, current);
|
|
1292
1421
|
}
|
|
1293
|
-
if (
|
|
1294
|
-
return
|
|
1422
|
+
if (current instanceof Error) {
|
|
1423
|
+
return generateErrorNode(ctx, id, current);
|
|
1424
|
+
}
|
|
1425
|
+
if (ctx.features & 1024 /* Symbol */ && Symbol.iterator in current) {
|
|
1426
|
+
return generateObjectNode(ctx, id, current, !!currentClass);
|
|
1295
1427
|
}
|
|
1296
1428
|
throw new UnsupportedTypeError(current);
|
|
1297
1429
|
}
|
|
1298
1430
|
async function parseAsync(ctx, current) {
|
|
1299
|
-
|
|
1431
|
+
const t = typeof current;
|
|
1432
|
+
if (ctx.features & 8 /* BigInt */ && t === "bigint") {
|
|
1433
|
+
return createBigIntNode(ctx, current);
|
|
1434
|
+
}
|
|
1435
|
+
switch (t) {
|
|
1300
1436
|
case "boolean":
|
|
1301
1437
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
1302
1438
|
case "undefined":
|
|
@@ -1305,8 +1441,6 @@ async function parseAsync(ctx, current) {
|
|
|
1305
1441
|
return createStringNode(current);
|
|
1306
1442
|
case "number":
|
|
1307
1443
|
return createNumberNode(current);
|
|
1308
|
-
case "bigint":
|
|
1309
|
-
return createBigIntNode(ctx, current);
|
|
1310
1444
|
case "object":
|
|
1311
1445
|
return parseObject(ctx, current);
|
|
1312
1446
|
case "symbol":
|
|
@@ -1547,6 +1681,53 @@ function deserializeBoxed(ctx, node) {
|
|
|
1547
1681
|
Object(deserializeTree(ctx, node.f))
|
|
1548
1682
|
);
|
|
1549
1683
|
}
|
|
1684
|
+
function deserializeRequest(ctx, node) {
|
|
1685
|
+
return assignIndexedValue(
|
|
1686
|
+
ctx,
|
|
1687
|
+
node.i,
|
|
1688
|
+
new Request(deserializeString(node.s), deserializeTree(ctx, node.f))
|
|
1689
|
+
);
|
|
1690
|
+
}
|
|
1691
|
+
function deserializeResponse(ctx, node) {
|
|
1692
|
+
return assignIndexedValue(
|
|
1693
|
+
ctx,
|
|
1694
|
+
node.i,
|
|
1695
|
+
new Response(
|
|
1696
|
+
deserializeTree(ctx, node.a[0]),
|
|
1697
|
+
deserializeTree(ctx, node.a[1])
|
|
1698
|
+
)
|
|
1699
|
+
);
|
|
1700
|
+
}
|
|
1701
|
+
function deserializeEvent(ctx, node) {
|
|
1702
|
+
return assignIndexedValue(
|
|
1703
|
+
ctx,
|
|
1704
|
+
node.i,
|
|
1705
|
+
new Event(
|
|
1706
|
+
deserializeString(node.s),
|
|
1707
|
+
deserializeTree(ctx, node.f)
|
|
1708
|
+
)
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1711
|
+
function deserializeCustomEvent(ctx, node) {
|
|
1712
|
+
return assignIndexedValue(
|
|
1713
|
+
ctx,
|
|
1714
|
+
node.i,
|
|
1715
|
+
new CustomEvent(
|
|
1716
|
+
deserializeString(node.s),
|
|
1717
|
+
deserializeTree(ctx, node.f)
|
|
1718
|
+
)
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1721
|
+
function deserializeDOMException(ctx, node) {
|
|
1722
|
+
return assignIndexedValue(
|
|
1723
|
+
ctx,
|
|
1724
|
+
node.i,
|
|
1725
|
+
new DOMException(
|
|
1726
|
+
deserializeString(node.s),
|
|
1727
|
+
deserializeString(node.c)
|
|
1728
|
+
)
|
|
1729
|
+
);
|
|
1730
|
+
}
|
|
1550
1731
|
function deserializeTree(ctx, node) {
|
|
1551
1732
|
switch (node.t) {
|
|
1552
1733
|
case 2 /* Constant */:
|
|
@@ -1603,6 +1784,16 @@ function deserializeTree(ctx, node) {
|
|
|
1603
1784
|
return deserializeFormData(ctx, node);
|
|
1604
1785
|
case 27 /* Boxed */:
|
|
1605
1786
|
return deserializeBoxed(ctx, node);
|
|
1787
|
+
case 35 /* Request */:
|
|
1788
|
+
return deserializeRequest(ctx, node);
|
|
1789
|
+
case 36 /* Response */:
|
|
1790
|
+
return deserializeResponse(ctx, node);
|
|
1791
|
+
case 37 /* Event */:
|
|
1792
|
+
return deserializeEvent(ctx, node);
|
|
1793
|
+
case 38 /* CustomEvent */:
|
|
1794
|
+
return deserializeCustomEvent(ctx, node);
|
|
1795
|
+
case 39 /* DOMException */:
|
|
1796
|
+
return deserializeDOMException(ctx, node);
|
|
1606
1797
|
default:
|
|
1607
1798
|
throw new Error("invariant");
|
|
1608
1799
|
}
|
|
@@ -2177,6 +2368,33 @@ function serializeBoxed(ctx, node) {
|
|
|
2177
2368
|
function serializeWKSymbol(ctx, node) {
|
|
2178
2369
|
return assignIndexedValue2(ctx, node.i, SYMBOL_STRING[node.s]);
|
|
2179
2370
|
}
|
|
2371
|
+
function serializeRequest(ctx, node) {
|
|
2372
|
+
return assignIndexedValue2(ctx, node.i, 'new Request("' + node.s + '",' + serializeTree(ctx, node.f) + ")");
|
|
2373
|
+
}
|
|
2374
|
+
function serializeResponse(ctx, node) {
|
|
2375
|
+
return assignIndexedValue2(ctx, node.i, "new Response(" + serializeTree(ctx, node.a[0]) + "," + serializeTree(ctx, node.a[1]) + ")");
|
|
2376
|
+
}
|
|
2377
|
+
function serializeEvent(ctx, node) {
|
|
2378
|
+
return assignIndexedValue2(
|
|
2379
|
+
ctx,
|
|
2380
|
+
node.i,
|
|
2381
|
+
'new Event("' + node.s + '",' + serializeTree(ctx, node.f) + ")"
|
|
2382
|
+
);
|
|
2383
|
+
}
|
|
2384
|
+
function serializeCustomEvent(ctx, node) {
|
|
2385
|
+
return assignIndexedValue2(
|
|
2386
|
+
ctx,
|
|
2387
|
+
node.i,
|
|
2388
|
+
'new CustomEvent("' + node.s + '",' + serializeTree(ctx, node.f) + ")"
|
|
2389
|
+
);
|
|
2390
|
+
}
|
|
2391
|
+
function serializeDOMException(ctx, node) {
|
|
2392
|
+
return assignIndexedValue2(
|
|
2393
|
+
ctx,
|
|
2394
|
+
node.i,
|
|
2395
|
+
'new DOMException("' + node.s + '","' + node.c + '")'
|
|
2396
|
+
);
|
|
2397
|
+
}
|
|
2180
2398
|
function serializeTree(ctx, node) {
|
|
2181
2399
|
switch (node.t) {
|
|
2182
2400
|
case 0 /* Number */:
|
|
@@ -2234,6 +2452,16 @@ function serializeTree(ctx, node) {
|
|
|
2234
2452
|
return serializeFormData(ctx, node);
|
|
2235
2453
|
case 27 /* Boxed */:
|
|
2236
2454
|
return serializeBoxed(ctx, node);
|
|
2455
|
+
case 35 /* Request */:
|
|
2456
|
+
return serializeRequest(ctx, node);
|
|
2457
|
+
case 36 /* Response */:
|
|
2458
|
+
return serializeResponse(ctx, node);
|
|
2459
|
+
case 37 /* Event */:
|
|
2460
|
+
return serializeEvent(ctx, node);
|
|
2461
|
+
case 38 /* CustomEvent */:
|
|
2462
|
+
return serializeCustomEvent(ctx, node);
|
|
2463
|
+
case 39 /* DOMException */:
|
|
2464
|
+
return serializeDOMException(ctx, node);
|
|
2237
2465
|
default:
|
|
2238
2466
|
throw new Error("invariant");
|
|
2239
2467
|
}
|
|
@@ -2279,7 +2507,6 @@ function generateArrayNode2(ctx, id, current) {
|
|
|
2279
2507
|
};
|
|
2280
2508
|
}
|
|
2281
2509
|
function generateMapNode2(ctx, id, current) {
|
|
2282
|
-
assert(ctx.features & 32 /* Map */, new UnsupportedTypeError(current));
|
|
2283
2510
|
const len = current.size;
|
|
2284
2511
|
const keyNodes = new Array(len);
|
|
2285
2512
|
const valueNodes = new Array(len);
|
|
@@ -2318,7 +2545,6 @@ function generateMapNode2(ctx, id, current) {
|
|
|
2318
2545
|
};
|
|
2319
2546
|
}
|
|
2320
2547
|
function generateSetNode2(ctx, id, current) {
|
|
2321
|
-
assert(ctx.features & 512 /* Set */, new UnsupportedTypeError(current));
|
|
2322
2548
|
const len = current.size;
|
|
2323
2549
|
const nodes = new Array(len);
|
|
2324
2550
|
const deferred = new Array(len);
|
|
@@ -2479,7 +2705,6 @@ function generateErrorNode2(ctx, id, current) {
|
|
|
2479
2705
|
};
|
|
2480
2706
|
}
|
|
2481
2707
|
function generateHeadersNode2(ctx, id, current) {
|
|
2482
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
2483
2708
|
const items = {};
|
|
2484
2709
|
current.forEach((value, key) => {
|
|
2485
2710
|
items[key] = value;
|
|
@@ -2500,7 +2725,6 @@ function generateHeadersNode2(ctx, id, current) {
|
|
|
2500
2725
|
};
|
|
2501
2726
|
}
|
|
2502
2727
|
function generateFormDataNode2(ctx, id, current) {
|
|
2503
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
2504
2728
|
const items = {};
|
|
2505
2729
|
current.forEach((value, key) => {
|
|
2506
2730
|
items[key] = value;
|
|
@@ -2536,6 +2760,38 @@ function generateBoxedNode2(ctx, id, current) {
|
|
|
2536
2760
|
o: void 0
|
|
2537
2761
|
};
|
|
2538
2762
|
}
|
|
2763
|
+
function generateEventNode2(ctx, id, current) {
|
|
2764
|
+
return {
|
|
2765
|
+
t: 37 /* Event */,
|
|
2766
|
+
i: id,
|
|
2767
|
+
s: serializeString(current.type),
|
|
2768
|
+
l: void 0,
|
|
2769
|
+
c: void 0,
|
|
2770
|
+
m: void 0,
|
|
2771
|
+
p: void 0,
|
|
2772
|
+
e: void 0,
|
|
2773
|
+
a: void 0,
|
|
2774
|
+
f: parseObject2(ctx, createEventOptions(current)),
|
|
2775
|
+
b: void 0,
|
|
2776
|
+
o: void 0
|
|
2777
|
+
};
|
|
2778
|
+
}
|
|
2779
|
+
function generateCustomEventNode2(ctx, id, current) {
|
|
2780
|
+
return {
|
|
2781
|
+
t: 38 /* CustomEvent */,
|
|
2782
|
+
i: id,
|
|
2783
|
+
s: serializeString(current.type),
|
|
2784
|
+
l: void 0,
|
|
2785
|
+
c: void 0,
|
|
2786
|
+
m: void 0,
|
|
2787
|
+
p: void 0,
|
|
2788
|
+
e: void 0,
|
|
2789
|
+
a: void 0,
|
|
2790
|
+
f: parseObject2(ctx, createCustomEventOptions(current)),
|
|
2791
|
+
b: void 0,
|
|
2792
|
+
o: void 0
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2539
2795
|
function parseObject2(ctx, current) {
|
|
2540
2796
|
if (!current) {
|
|
2541
2797
|
return NULL_NODE;
|
|
@@ -2550,39 +2806,17 @@ function parseObject2(ctx, current) {
|
|
|
2550
2806
|
if (Array.isArray(current)) {
|
|
2551
2807
|
return generateArrayNode2(ctx, id, current);
|
|
2552
2808
|
}
|
|
2553
|
-
|
|
2809
|
+
const currentClass = current.constructor;
|
|
2810
|
+
switch (currentClass) {
|
|
2554
2811
|
case Number:
|
|
2555
2812
|
case Boolean:
|
|
2556
2813
|
case String:
|
|
2557
2814
|
case BigInt:
|
|
2558
|
-
case Function:
|
|
2559
|
-
case Symbol:
|
|
2560
2815
|
return generateBoxedNode2(ctx, id, current);
|
|
2561
2816
|
case Date:
|
|
2562
2817
|
return createDateNode(id, current);
|
|
2563
2818
|
case RegExp:
|
|
2564
2819
|
return createRegExpNode(id, current);
|
|
2565
|
-
case ArrayBuffer:
|
|
2566
|
-
return createArrayBufferNode(id, current);
|
|
2567
|
-
case Int8Array:
|
|
2568
|
-
case Int16Array:
|
|
2569
|
-
case Int32Array:
|
|
2570
|
-
case Uint8Array:
|
|
2571
|
-
case Uint16Array:
|
|
2572
|
-
case Uint32Array:
|
|
2573
|
-
case Uint8ClampedArray:
|
|
2574
|
-
case Float32Array:
|
|
2575
|
-
case Float64Array:
|
|
2576
|
-
return createTypedArrayNode(ctx, id, current);
|
|
2577
|
-
case BigInt64Array:
|
|
2578
|
-
case BigUint64Array:
|
|
2579
|
-
return createBigIntTypedArrayNode(ctx, id, current);
|
|
2580
|
-
case DataView:
|
|
2581
|
-
return createDataViewNode(ctx, id, current);
|
|
2582
|
-
case Map:
|
|
2583
|
-
return generateMapNode2(ctx, id, current);
|
|
2584
|
-
case Set:
|
|
2585
|
-
return generateSetNode2(ctx, id, current);
|
|
2586
2820
|
case Object:
|
|
2587
2821
|
return generateObjectNode2(
|
|
2588
2822
|
ctx,
|
|
@@ -2597,11 +2831,6 @@ function parseObject2(ctx, current) {
|
|
|
2597
2831
|
current,
|
|
2598
2832
|
true
|
|
2599
2833
|
);
|
|
2600
|
-
case AggregateError:
|
|
2601
|
-
if (ctx.features & 1 /* AggregateError */) {
|
|
2602
|
-
return generateAggregateErrorNode2(ctx, id, current);
|
|
2603
|
-
}
|
|
2604
|
-
return generateErrorNode2(ctx, id, current);
|
|
2605
2834
|
case Error:
|
|
2606
2835
|
case EvalError:
|
|
2607
2836
|
case RangeError:
|
|
@@ -2610,33 +2839,81 @@ function parseObject2(ctx, current) {
|
|
|
2610
2839
|
case TypeError:
|
|
2611
2840
|
case URIError:
|
|
2612
2841
|
return generateErrorNode2(ctx, id, current);
|
|
2613
|
-
case URL:
|
|
2614
|
-
return createURLNode(ctx, id, current);
|
|
2615
|
-
case URLSearchParams:
|
|
2616
|
-
return createURLSearchParamsNode(ctx, id, current);
|
|
2617
|
-
case Headers:
|
|
2618
|
-
return generateHeadersNode2(ctx, id, current);
|
|
2619
|
-
case FormData:
|
|
2620
|
-
return generateFormDataNode2(ctx, id, current);
|
|
2621
2842
|
default:
|
|
2622
2843
|
break;
|
|
2623
2844
|
}
|
|
2624
|
-
if (
|
|
2625
|
-
|
|
2626
|
-
|
|
2845
|
+
if (ctx.features & 2048 /* TypedArray */) {
|
|
2846
|
+
switch (currentClass) {
|
|
2847
|
+
case ArrayBuffer:
|
|
2848
|
+
return createArrayBufferNode(id, current);
|
|
2849
|
+
case Int8Array:
|
|
2850
|
+
case Int16Array:
|
|
2851
|
+
case Int32Array:
|
|
2852
|
+
case Uint8Array:
|
|
2853
|
+
case Uint16Array:
|
|
2854
|
+
case Uint32Array:
|
|
2855
|
+
case Uint8ClampedArray:
|
|
2856
|
+
case Float32Array:
|
|
2857
|
+
case Float64Array:
|
|
2858
|
+
return createTypedArrayNode(ctx, id, current);
|
|
2859
|
+
case DataView:
|
|
2860
|
+
return createDataViewNode(ctx, id, current);
|
|
2861
|
+
default:
|
|
2862
|
+
break;
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
if ((ctx.features & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
2866
|
+
switch (currentClass) {
|
|
2867
|
+
case BigInt64Array:
|
|
2868
|
+
case BigUint64Array:
|
|
2869
|
+
return createBigIntTypedArrayNode(ctx, id, current);
|
|
2870
|
+
default:
|
|
2871
|
+
break;
|
|
2627
2872
|
}
|
|
2628
|
-
|
|
2873
|
+
}
|
|
2874
|
+
if (ctx.features & 32 /* Map */ && currentClass === Map) {
|
|
2875
|
+
return generateMapNode2(ctx, id, current);
|
|
2876
|
+
}
|
|
2877
|
+
if (ctx.features & 512 /* Set */ && currentClass === Set) {
|
|
2878
|
+
return generateSetNode2(ctx, id, current);
|
|
2879
|
+
}
|
|
2880
|
+
if (ctx.features & 8192 /* WebAPI */) {
|
|
2881
|
+
switch (currentClass) {
|
|
2882
|
+
case URL:
|
|
2883
|
+
return createURLNode(id, current);
|
|
2884
|
+
case URLSearchParams:
|
|
2885
|
+
return createURLSearchParamsNode(id, current);
|
|
2886
|
+
case Headers:
|
|
2887
|
+
return generateHeadersNode2(ctx, id, current);
|
|
2888
|
+
case FormData:
|
|
2889
|
+
return generateFormDataNode2(ctx, id, current);
|
|
2890
|
+
case Event:
|
|
2891
|
+
return generateEventNode2(ctx, id, current);
|
|
2892
|
+
case CustomEvent:
|
|
2893
|
+
return generateCustomEventNode2(ctx, id, current);
|
|
2894
|
+
case DOMException:
|
|
2895
|
+
return createDOMExceptionNode(id, current);
|
|
2896
|
+
default:
|
|
2897
|
+
break;
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
if (ctx.features & 1 /* AggregateError */ && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
2901
|
+
return generateAggregateErrorNode2(ctx, id, current);
|
|
2629
2902
|
}
|
|
2630
2903
|
if (current instanceof Error) {
|
|
2631
2904
|
return generateErrorNode2(ctx, id, current);
|
|
2632
2905
|
}
|
|
2633
|
-
if (Symbol.iterator in current) {
|
|
2634
|
-
return generateObjectNode2(ctx, id, current, !!
|
|
2906
|
+
if (ctx.features & 1024 /* Symbol */ && Symbol.iterator in current) {
|
|
2907
|
+
return generateObjectNode2(ctx, id, current, !!currentClass);
|
|
2635
2908
|
}
|
|
2636
2909
|
throw new UnsupportedTypeError(current);
|
|
2637
2910
|
}
|
|
2638
2911
|
function parseSync(ctx, current) {
|
|
2639
|
-
|
|
2912
|
+
const t = typeof current;
|
|
2913
|
+
if (ctx.features & 8 /* BigInt */ && t === "bigint") {
|
|
2914
|
+
return createBigIntNode(ctx, current);
|
|
2915
|
+
}
|
|
2916
|
+
switch (t) {
|
|
2640
2917
|
case "boolean":
|
|
2641
2918
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
2642
2919
|
case "undefined":
|
|
@@ -2645,8 +2922,6 @@ function parseSync(ctx, current) {
|
|
|
2645
2922
|
return createStringNode(current);
|
|
2646
2923
|
case "number":
|
|
2647
2924
|
return createNumberNode(current);
|
|
2648
|
-
case "bigint":
|
|
2649
|
-
return createBigIntNode(ctx, current);
|
|
2650
2925
|
case "object":
|
|
2651
2926
|
return parseObject2(ctx, current);
|
|
2652
2927
|
case "symbol":
|
|
@@ -2958,7 +3233,6 @@ async function generateArrayNode3(ctx, id, current) {
|
|
|
2958
3233
|
};
|
|
2959
3234
|
}
|
|
2960
3235
|
async function generateMapNode3(ctx, id, current) {
|
|
2961
|
-
assert(ctx.features & 32 /* Map */, new UnsupportedTypeError(current));
|
|
2962
3236
|
const len = current.size;
|
|
2963
3237
|
const keyNodes = new Array(len);
|
|
2964
3238
|
const valueNodes = new Array(len);
|
|
@@ -2997,7 +3271,6 @@ async function generateMapNode3(ctx, id, current) {
|
|
|
2997
3271
|
};
|
|
2998
3272
|
}
|
|
2999
3273
|
async function generateSetNode3(ctx, id, current) {
|
|
3000
|
-
assert(ctx.features & 512 /* Set */, new UnsupportedTypeError(current));
|
|
3001
3274
|
const len = current.size;
|
|
3002
3275
|
const nodes = new Array(len);
|
|
3003
3276
|
const deferred = new Array(len);
|
|
@@ -3109,7 +3382,6 @@ async function generatePlainProperties3(ctx, properties) {
|
|
|
3109
3382
|
};
|
|
3110
3383
|
}
|
|
3111
3384
|
async function generatePromiseNode2(ctx, id, current) {
|
|
3112
|
-
assert(ctx.features & 256 /* Promise */, new UnsupportedTypeError(current));
|
|
3113
3385
|
const [status, result] = await promiseToResult(current);
|
|
3114
3386
|
return {
|
|
3115
3387
|
t: 12 /* Promise */,
|
|
@@ -3179,7 +3451,6 @@ async function generateErrorNode3(ctx, id, current) {
|
|
|
3179
3451
|
};
|
|
3180
3452
|
}
|
|
3181
3453
|
async function generateHeadersNode3(ctx, id, current) {
|
|
3182
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
3183
3454
|
const items = {};
|
|
3184
3455
|
current.forEach((value, key) => {
|
|
3185
3456
|
items[key] = value;
|
|
@@ -3200,7 +3471,6 @@ async function generateHeadersNode3(ctx, id, current) {
|
|
|
3200
3471
|
};
|
|
3201
3472
|
}
|
|
3202
3473
|
async function generateFormDataNode3(ctx, id, current) {
|
|
3203
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
3204
3474
|
const items = {};
|
|
3205
3475
|
current.forEach((value, key) => {
|
|
3206
3476
|
items[key] = value;
|
|
@@ -3236,6 +3506,76 @@ async function generateBoxedNode3(ctx, id, current) {
|
|
|
3236
3506
|
o: void 0
|
|
3237
3507
|
};
|
|
3238
3508
|
}
|
|
3509
|
+
async function generateRequestNode2(ctx, id, current) {
|
|
3510
|
+
return {
|
|
3511
|
+
t: 35 /* Request */,
|
|
3512
|
+
i: id,
|
|
3513
|
+
s: serializeString(current.url),
|
|
3514
|
+
l: void 0,
|
|
3515
|
+
c: void 0,
|
|
3516
|
+
m: void 0,
|
|
3517
|
+
p: void 0,
|
|
3518
|
+
e: void 0,
|
|
3519
|
+
f: await parseObject3(
|
|
3520
|
+
ctx,
|
|
3521
|
+
createRequestOptions(current, current.body ? await current.clone().arrayBuffer() : null)
|
|
3522
|
+
),
|
|
3523
|
+
a: void 0,
|
|
3524
|
+
b: void 0,
|
|
3525
|
+
o: void 0
|
|
3526
|
+
};
|
|
3527
|
+
}
|
|
3528
|
+
async function generateResponseNode2(ctx, id, current) {
|
|
3529
|
+
return {
|
|
3530
|
+
t: 36 /* Response */,
|
|
3531
|
+
i: id,
|
|
3532
|
+
s: void 0,
|
|
3533
|
+
l: void 0,
|
|
3534
|
+
c: void 0,
|
|
3535
|
+
m: void 0,
|
|
3536
|
+
p: void 0,
|
|
3537
|
+
e: void 0,
|
|
3538
|
+
f: void 0,
|
|
3539
|
+
a: [
|
|
3540
|
+
current.body ? serializeArrayBuffer3(ctx, await current.clone().arrayBuffer()) : NULL_NODE,
|
|
3541
|
+
await parseObject3(ctx, createResponseOptions(current))
|
|
3542
|
+
],
|
|
3543
|
+
b: void 0,
|
|
3544
|
+
o: void 0
|
|
3545
|
+
};
|
|
3546
|
+
}
|
|
3547
|
+
async function generateEventNode3(ctx, id, current) {
|
|
3548
|
+
return {
|
|
3549
|
+
t: 37 /* Event */,
|
|
3550
|
+
i: id,
|
|
3551
|
+
s: serializeString(current.type),
|
|
3552
|
+
l: void 0,
|
|
3553
|
+
c: void 0,
|
|
3554
|
+
m: void 0,
|
|
3555
|
+
p: void 0,
|
|
3556
|
+
e: void 0,
|
|
3557
|
+
a: void 0,
|
|
3558
|
+
f: await parseObject3(ctx, createEventOptions(current)),
|
|
3559
|
+
b: void 0,
|
|
3560
|
+
o: void 0
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
async function generateCustomEventNode3(ctx, id, current) {
|
|
3564
|
+
return {
|
|
3565
|
+
t: 38 /* CustomEvent */,
|
|
3566
|
+
i: id,
|
|
3567
|
+
s: serializeString(current.type),
|
|
3568
|
+
l: void 0,
|
|
3569
|
+
c: void 0,
|
|
3570
|
+
m: void 0,
|
|
3571
|
+
p: void 0,
|
|
3572
|
+
e: void 0,
|
|
3573
|
+
a: void 0,
|
|
3574
|
+
f: await parseObject3(ctx, createCustomEventOptions(current)),
|
|
3575
|
+
b: void 0,
|
|
3576
|
+
o: void 0
|
|
3577
|
+
};
|
|
3578
|
+
}
|
|
3239
3579
|
async function parseObject3(ctx, current) {
|
|
3240
3580
|
if (!current) {
|
|
3241
3581
|
return NULL_NODE;
|
|
@@ -3252,49 +3592,17 @@ async function parseObject3(ctx, current) {
|
|
|
3252
3592
|
if (Array.isArray(current)) {
|
|
3253
3593
|
return generateArrayNode3(ctx, id, current);
|
|
3254
3594
|
}
|
|
3255
|
-
|
|
3595
|
+
const currentClass = current.constructor;
|
|
3596
|
+
switch (currentClass) {
|
|
3256
3597
|
case Number:
|
|
3257
3598
|
case Boolean:
|
|
3258
3599
|
case String:
|
|
3259
3600
|
case BigInt:
|
|
3260
|
-
case Function:
|
|
3261
|
-
case Symbol:
|
|
3262
3601
|
return generateBoxedNode3(ctx, id, current);
|
|
3263
3602
|
case Date:
|
|
3264
3603
|
return createDateNode(id, current);
|
|
3265
3604
|
case RegExp:
|
|
3266
3605
|
return createRegExpNode(id, current);
|
|
3267
|
-
case Promise:
|
|
3268
|
-
return generatePromiseNode2(ctx, id, current);
|
|
3269
|
-
case ArrayBuffer:
|
|
3270
|
-
return createArrayBufferNode(id, current);
|
|
3271
|
-
case Int8Array:
|
|
3272
|
-
case Int16Array:
|
|
3273
|
-
case Int32Array:
|
|
3274
|
-
case Uint8Array:
|
|
3275
|
-
case Uint16Array:
|
|
3276
|
-
case Uint32Array:
|
|
3277
|
-
case Uint8ClampedArray:
|
|
3278
|
-
case Float32Array:
|
|
3279
|
-
case Float64Array:
|
|
3280
|
-
return createTypedArrayNode2(ctx, id, current);
|
|
3281
|
-
case BigInt64Array:
|
|
3282
|
-
case BigUint64Array:
|
|
3283
|
-
return createBigIntTypedArrayNode2(ctx, id, current);
|
|
3284
|
-
case DataView:
|
|
3285
|
-
return createDataViewNode2(ctx, id, current);
|
|
3286
|
-
case Map:
|
|
3287
|
-
return generateMapNode3(
|
|
3288
|
-
ctx,
|
|
3289
|
-
id,
|
|
3290
|
-
current
|
|
3291
|
-
);
|
|
3292
|
-
case Set:
|
|
3293
|
-
return generateSetNode3(
|
|
3294
|
-
ctx,
|
|
3295
|
-
id,
|
|
3296
|
-
current
|
|
3297
|
-
);
|
|
3298
3606
|
case Object:
|
|
3299
3607
|
return generateObjectNode3(
|
|
3300
3608
|
ctx,
|
|
@@ -3309,11 +3617,6 @@ async function parseObject3(ctx, current) {
|
|
|
3309
3617
|
current,
|
|
3310
3618
|
true
|
|
3311
3619
|
);
|
|
3312
|
-
case AggregateError:
|
|
3313
|
-
if (ctx.features & 1 /* AggregateError */) {
|
|
3314
|
-
return generateAggregateErrorNode3(ctx, id, current);
|
|
3315
|
-
}
|
|
3316
|
-
return generateErrorNode3(ctx, id, current);
|
|
3317
3620
|
case Error:
|
|
3318
3621
|
case EvalError:
|
|
3319
3622
|
case RangeError:
|
|
@@ -3322,40 +3625,100 @@ async function parseObject3(ctx, current) {
|
|
|
3322
3625
|
case TypeError:
|
|
3323
3626
|
case URIError:
|
|
3324
3627
|
return generateErrorNode3(ctx, id, current);
|
|
3325
|
-
case URL:
|
|
3326
|
-
return createURLNode(ctx, id, current);
|
|
3327
|
-
case URLSearchParams:
|
|
3328
|
-
return createURLSearchParamsNode(ctx, id, current);
|
|
3329
|
-
case Blob:
|
|
3330
|
-
return createBlobNode2(ctx, id, current);
|
|
3331
|
-
case File:
|
|
3332
|
-
return createFileNode2(ctx, id, current);
|
|
3333
|
-
case Headers:
|
|
3334
|
-
return generateHeadersNode3(ctx, id, current);
|
|
3335
|
-
case FormData:
|
|
3336
|
-
return generateFormDataNode3(ctx, id, current);
|
|
3337
3628
|
default:
|
|
3338
3629
|
break;
|
|
3339
3630
|
}
|
|
3340
|
-
if (
|
|
3341
|
-
|
|
3342
|
-
|
|
3631
|
+
if (ctx.features & 2048 /* TypedArray */) {
|
|
3632
|
+
switch (currentClass) {
|
|
3633
|
+
case ArrayBuffer:
|
|
3634
|
+
return createArrayBufferNode(id, current);
|
|
3635
|
+
case Int8Array:
|
|
3636
|
+
case Int16Array:
|
|
3637
|
+
case Int32Array:
|
|
3638
|
+
case Uint8Array:
|
|
3639
|
+
case Uint16Array:
|
|
3640
|
+
case Uint32Array:
|
|
3641
|
+
case Uint8ClampedArray:
|
|
3642
|
+
case Float32Array:
|
|
3643
|
+
case Float64Array:
|
|
3644
|
+
return createTypedArrayNode2(ctx, id, current);
|
|
3645
|
+
case DataView:
|
|
3646
|
+
return createDataViewNode2(ctx, id, current);
|
|
3647
|
+
default:
|
|
3648
|
+
break;
|
|
3343
3649
|
}
|
|
3344
|
-
return generateErrorNode3(ctx, id, current);
|
|
3345
3650
|
}
|
|
3346
|
-
if (
|
|
3347
|
-
|
|
3651
|
+
if ((ctx.features & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
3652
|
+
switch (currentClass) {
|
|
3653
|
+
case BigInt64Array:
|
|
3654
|
+
case BigUint64Array:
|
|
3655
|
+
return createBigIntTypedArrayNode2(ctx, id, current);
|
|
3656
|
+
default:
|
|
3657
|
+
break;
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
if (ctx.features & 32 /* Map */ && currentClass === Map) {
|
|
3661
|
+
return generateMapNode3(
|
|
3662
|
+
ctx,
|
|
3663
|
+
id,
|
|
3664
|
+
current
|
|
3665
|
+
);
|
|
3348
3666
|
}
|
|
3349
|
-
if (
|
|
3667
|
+
if (ctx.features & 512 /* Set */ && currentClass === Set) {
|
|
3668
|
+
return generateSetNode3(
|
|
3669
|
+
ctx,
|
|
3670
|
+
id,
|
|
3671
|
+
current
|
|
3672
|
+
);
|
|
3673
|
+
}
|
|
3674
|
+
if (ctx.features & 8192 /* WebAPI */) {
|
|
3675
|
+
switch (currentClass) {
|
|
3676
|
+
case URL:
|
|
3677
|
+
return createURLNode(id, current);
|
|
3678
|
+
case URLSearchParams:
|
|
3679
|
+
return createURLSearchParamsNode(id, current);
|
|
3680
|
+
case Blob:
|
|
3681
|
+
return createBlobNode2(ctx, id, current);
|
|
3682
|
+
case File:
|
|
3683
|
+
return createFileNode2(ctx, id, current);
|
|
3684
|
+
case Headers:
|
|
3685
|
+
return generateHeadersNode3(ctx, id, current);
|
|
3686
|
+
case FormData:
|
|
3687
|
+
return generateFormDataNode3(ctx, id, current);
|
|
3688
|
+
case Request:
|
|
3689
|
+
return generateRequestNode2(ctx, id, current);
|
|
3690
|
+
case Response:
|
|
3691
|
+
return generateResponseNode2(ctx, id, current);
|
|
3692
|
+
case Event:
|
|
3693
|
+
return generateEventNode3(ctx, id, current);
|
|
3694
|
+
case CustomEvent:
|
|
3695
|
+
return generateCustomEventNode3(ctx, id, current);
|
|
3696
|
+
case DOMException:
|
|
3697
|
+
return createDOMExceptionNode(id, current);
|
|
3698
|
+
default:
|
|
3699
|
+
break;
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
if (ctx.features & 1 /* AggregateError */ && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
3703
|
+
return generateAggregateErrorNode3(ctx, id, current);
|
|
3704
|
+
}
|
|
3705
|
+
if (ctx.features & 256 /* Promise */ && (currentClass === Promise || current instanceof Promise)) {
|
|
3350
3706
|
return generatePromiseNode2(ctx, id, current);
|
|
3351
3707
|
}
|
|
3352
|
-
if (
|
|
3353
|
-
return
|
|
3708
|
+
if (current instanceof Error) {
|
|
3709
|
+
return generateErrorNode3(ctx, id, current);
|
|
3710
|
+
}
|
|
3711
|
+
if (ctx.features & 1024 /* Symbol */ && Symbol.iterator in current) {
|
|
3712
|
+
return generateObjectNode3(ctx, id, current, !!currentClass);
|
|
3354
3713
|
}
|
|
3355
3714
|
throw new UnsupportedTypeError(current);
|
|
3356
3715
|
}
|
|
3357
3716
|
async function crossParseAsync(ctx, current) {
|
|
3358
|
-
|
|
3717
|
+
const t = typeof current;
|
|
3718
|
+
if (ctx.features & 8 /* BigInt */ && t === "bigint") {
|
|
3719
|
+
return createBigIntNode(ctx, current);
|
|
3720
|
+
}
|
|
3721
|
+
switch (t) {
|
|
3359
3722
|
case "boolean":
|
|
3360
3723
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
3361
3724
|
case "undefined":
|
|
@@ -3364,8 +3727,6 @@ async function crossParseAsync(ctx, current) {
|
|
|
3364
3727
|
return createStringNode(current);
|
|
3365
3728
|
case "number":
|
|
3366
3729
|
return createNumberNode(current);
|
|
3367
|
-
case "bigint":
|
|
3368
|
-
return createBigIntNode(ctx, current);
|
|
3369
3730
|
case "object":
|
|
3370
3731
|
return parseObject3(ctx, current);
|
|
3371
3732
|
case "symbol":
|
|
@@ -3845,6 +4206,33 @@ function serializeReadableStreamError(ctx, node) {
|
|
|
3845
4206
|
function serializeReadableStreamConstructor(node) {
|
|
3846
4207
|
return assignIndexedValue3(node.i, GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_STREAM_CONSTRUCTOR + "()");
|
|
3847
4208
|
}
|
|
4209
|
+
function serializeRequest2(ctx, node) {
|
|
4210
|
+
return assignIndexedValue3(node.i, 'new Request("' + node.s + '",' + crossSerializeTree(ctx, node.f) + ")");
|
|
4211
|
+
}
|
|
4212
|
+
function serializeResponse2(ctx, node) {
|
|
4213
|
+
return assignIndexedValue3(
|
|
4214
|
+
node.i,
|
|
4215
|
+
"new Response(" + crossSerializeTree(ctx, node.a[0]) + "," + crossSerializeTree(ctx, node.a[1]) + ")"
|
|
4216
|
+
);
|
|
4217
|
+
}
|
|
4218
|
+
function serializeEvent2(ctx, node) {
|
|
4219
|
+
return assignIndexedValue3(
|
|
4220
|
+
node.i,
|
|
4221
|
+
'new Event("' + node.s + '",' + crossSerializeTree(ctx, node.f) + ")"
|
|
4222
|
+
);
|
|
4223
|
+
}
|
|
4224
|
+
function serializeCustomEvent2(ctx, node) {
|
|
4225
|
+
return assignIndexedValue3(
|
|
4226
|
+
node.i,
|
|
4227
|
+
'new CustomEvent("' + node.s + '",' + crossSerializeTree(ctx, node.f) + ")"
|
|
4228
|
+
);
|
|
4229
|
+
}
|
|
4230
|
+
function serializeDOMException2(node) {
|
|
4231
|
+
return assignIndexedValue3(
|
|
4232
|
+
node.i,
|
|
4233
|
+
'new DOMException("' + node.s + '","' + node.c + '")'
|
|
4234
|
+
);
|
|
4235
|
+
}
|
|
3848
4236
|
function crossSerializeTree(ctx, node) {
|
|
3849
4237
|
switch (node.t) {
|
|
3850
4238
|
case 0 /* Number */:
|
|
@@ -3916,6 +4304,16 @@ function crossSerializeTree(ctx, node) {
|
|
|
3916
4304
|
return serializeReadableStreamEnqueue(ctx, node);
|
|
3917
4305
|
case 34 /* ReadableStreamError */:
|
|
3918
4306
|
return serializeReadableStreamError(ctx, node);
|
|
4307
|
+
case 35 /* Request */:
|
|
4308
|
+
return serializeRequest2(ctx, node);
|
|
4309
|
+
case 36 /* Response */:
|
|
4310
|
+
return serializeResponse2(ctx, node);
|
|
4311
|
+
case 37 /* Event */:
|
|
4312
|
+
return serializeEvent2(ctx, node);
|
|
4313
|
+
case 38 /* CustomEvent */:
|
|
4314
|
+
return serializeCustomEvent2(ctx, node);
|
|
4315
|
+
case 39 /* DOMException */:
|
|
4316
|
+
return serializeDOMException2(node);
|
|
3919
4317
|
default:
|
|
3920
4318
|
throw new Error("invariant");
|
|
3921
4319
|
}
|
|
@@ -3961,7 +4359,6 @@ function generateArrayNode4(ctx, id, current) {
|
|
|
3961
4359
|
};
|
|
3962
4360
|
}
|
|
3963
4361
|
function generateMapNode4(ctx, id, current) {
|
|
3964
|
-
assert(ctx.features & 32 /* Map */, new UnsupportedTypeError(current));
|
|
3965
4362
|
const len = current.size;
|
|
3966
4363
|
const keyNodes = new Array(len);
|
|
3967
4364
|
const valueNodes = new Array(len);
|
|
@@ -4000,7 +4397,6 @@ function generateMapNode4(ctx, id, current) {
|
|
|
4000
4397
|
};
|
|
4001
4398
|
}
|
|
4002
4399
|
function generateSetNode4(ctx, id, current) {
|
|
4003
|
-
assert(ctx.features & 512 /* Set */, new UnsupportedTypeError(current));
|
|
4004
4400
|
const len = current.size;
|
|
4005
4401
|
const nodes = new Array(len);
|
|
4006
4402
|
const deferred = new Array(len);
|
|
@@ -4112,7 +4508,6 @@ function generatePlainProperties4(ctx, properties) {
|
|
|
4112
4508
|
};
|
|
4113
4509
|
}
|
|
4114
4510
|
function generatePromiseNode3(ctx, id, current) {
|
|
4115
|
-
assert(ctx.features & 256 /* Promise */, new UnsupportedTypeError(current));
|
|
4116
4511
|
current.then(
|
|
4117
4512
|
(data) => {
|
|
4118
4513
|
if (ctx.alive) {
|
|
@@ -4222,7 +4617,6 @@ function generateErrorNode4(ctx, id, current) {
|
|
|
4222
4617
|
};
|
|
4223
4618
|
}
|
|
4224
4619
|
function generateHeadersNode4(ctx, id, current) {
|
|
4225
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
4226
4620
|
const items = {};
|
|
4227
4621
|
current.forEach((value, key) => {
|
|
4228
4622
|
items[key] = value;
|
|
@@ -4243,7 +4637,6 @@ function generateHeadersNode4(ctx, id, current) {
|
|
|
4243
4637
|
};
|
|
4244
4638
|
}
|
|
4245
4639
|
function generateFormDataNode4(ctx, id, current) {
|
|
4246
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
4247
4640
|
const items = {};
|
|
4248
4641
|
current.forEach((value, key) => {
|
|
4249
4642
|
items[key] = value;
|
|
@@ -4280,7 +4673,6 @@ function generateBoxedNode4(ctx, id, current) {
|
|
|
4280
4673
|
};
|
|
4281
4674
|
}
|
|
4282
4675
|
function generateReadableStreamNode(ctx, id, current) {
|
|
4283
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
4284
4676
|
const reader = current.getReader();
|
|
4285
4677
|
pushPendingState(ctx);
|
|
4286
4678
|
function push() {
|
|
@@ -4359,6 +4751,76 @@ function generateReadableStreamNode(ctx, id, current) {
|
|
|
4359
4751
|
o: void 0
|
|
4360
4752
|
};
|
|
4361
4753
|
}
|
|
4754
|
+
function generateRequestNode3(ctx, id, current) {
|
|
4755
|
+
return {
|
|
4756
|
+
t: 35 /* Request */,
|
|
4757
|
+
i: id,
|
|
4758
|
+
s: serializeString(current.url),
|
|
4759
|
+
l: void 0,
|
|
4760
|
+
c: void 0,
|
|
4761
|
+
m: void 0,
|
|
4762
|
+
p: void 0,
|
|
4763
|
+
e: void 0,
|
|
4764
|
+
f: parseObject4(
|
|
4765
|
+
ctx,
|
|
4766
|
+
createRequestOptions(current, current.clone().body)
|
|
4767
|
+
),
|
|
4768
|
+
a: void 0,
|
|
4769
|
+
b: void 0,
|
|
4770
|
+
o: void 0
|
|
4771
|
+
};
|
|
4772
|
+
}
|
|
4773
|
+
function generateResponseNode3(ctx, id, current) {
|
|
4774
|
+
return {
|
|
4775
|
+
t: 36 /* Response */,
|
|
4776
|
+
i: id,
|
|
4777
|
+
s: void 0,
|
|
4778
|
+
l: void 0,
|
|
4779
|
+
c: void 0,
|
|
4780
|
+
m: void 0,
|
|
4781
|
+
p: void 0,
|
|
4782
|
+
e: void 0,
|
|
4783
|
+
f: void 0,
|
|
4784
|
+
a: [
|
|
4785
|
+
current.body ? parseObject4(ctx, current.clone().body) : NULL_NODE,
|
|
4786
|
+
parseObject4(ctx, createResponseOptions(current))
|
|
4787
|
+
],
|
|
4788
|
+
b: void 0,
|
|
4789
|
+
o: void 0
|
|
4790
|
+
};
|
|
4791
|
+
}
|
|
4792
|
+
function generateEventNode4(ctx, id, current) {
|
|
4793
|
+
return {
|
|
4794
|
+
t: 37 /* Event */,
|
|
4795
|
+
i: id,
|
|
4796
|
+
s: serializeString(current.type),
|
|
4797
|
+
l: void 0,
|
|
4798
|
+
c: void 0,
|
|
4799
|
+
m: void 0,
|
|
4800
|
+
p: void 0,
|
|
4801
|
+
e: void 0,
|
|
4802
|
+
a: void 0,
|
|
4803
|
+
f: parseObject4(ctx, createEventOptions(current)),
|
|
4804
|
+
b: void 0,
|
|
4805
|
+
o: void 0
|
|
4806
|
+
};
|
|
4807
|
+
}
|
|
4808
|
+
function generateCustomEventNode4(ctx, id, current) {
|
|
4809
|
+
return {
|
|
4810
|
+
t: 38 /* CustomEvent */,
|
|
4811
|
+
i: id,
|
|
4812
|
+
s: serializeString(current.type),
|
|
4813
|
+
l: void 0,
|
|
4814
|
+
c: void 0,
|
|
4815
|
+
m: void 0,
|
|
4816
|
+
p: void 0,
|
|
4817
|
+
e: void 0,
|
|
4818
|
+
a: void 0,
|
|
4819
|
+
f: parseObject4(ctx, createCustomEventOptions(current)),
|
|
4820
|
+
b: void 0,
|
|
4821
|
+
o: void 0
|
|
4822
|
+
};
|
|
4823
|
+
}
|
|
4362
4824
|
function parseObject4(ctx, current) {
|
|
4363
4825
|
if (!current) {
|
|
4364
4826
|
return NULL_NODE;
|
|
@@ -4375,7 +4837,8 @@ function parseObject4(ctx, current) {
|
|
|
4375
4837
|
if (Array.isArray(current)) {
|
|
4376
4838
|
return generateArrayNode4(ctx, id, current);
|
|
4377
4839
|
}
|
|
4378
|
-
|
|
4840
|
+
const currentClass = current.constructor;
|
|
4841
|
+
switch (currentClass) {
|
|
4379
4842
|
case Number:
|
|
4380
4843
|
case Boolean:
|
|
4381
4844
|
case String:
|
|
@@ -4387,37 +4850,6 @@ function parseObject4(ctx, current) {
|
|
|
4387
4850
|
return createDateNode(id, current);
|
|
4388
4851
|
case RegExp:
|
|
4389
4852
|
return createRegExpNode(id, current);
|
|
4390
|
-
case Promise:
|
|
4391
|
-
return generatePromiseNode3(ctx, id, current);
|
|
4392
|
-
case ArrayBuffer:
|
|
4393
|
-
return createArrayBufferNode(id, current);
|
|
4394
|
-
case Int8Array:
|
|
4395
|
-
case Int16Array:
|
|
4396
|
-
case Int32Array:
|
|
4397
|
-
case Uint8Array:
|
|
4398
|
-
case Uint16Array:
|
|
4399
|
-
case Uint32Array:
|
|
4400
|
-
case Uint8ClampedArray:
|
|
4401
|
-
case Float32Array:
|
|
4402
|
-
case Float64Array:
|
|
4403
|
-
return createTypedArrayNode2(ctx, id, current);
|
|
4404
|
-
case BigInt64Array:
|
|
4405
|
-
case BigUint64Array:
|
|
4406
|
-
return createBigIntTypedArrayNode2(ctx, id, current);
|
|
4407
|
-
case DataView:
|
|
4408
|
-
return createDataViewNode2(ctx, id, current);
|
|
4409
|
-
case Map:
|
|
4410
|
-
return generateMapNode4(
|
|
4411
|
-
ctx,
|
|
4412
|
-
id,
|
|
4413
|
-
current
|
|
4414
|
-
);
|
|
4415
|
-
case Set:
|
|
4416
|
-
return generateSetNode4(
|
|
4417
|
-
ctx,
|
|
4418
|
-
id,
|
|
4419
|
-
current
|
|
4420
|
-
);
|
|
4421
4853
|
case Object:
|
|
4422
4854
|
return generateObjectNode4(
|
|
4423
4855
|
ctx,
|
|
@@ -4432,11 +4864,6 @@ function parseObject4(ctx, current) {
|
|
|
4432
4864
|
current,
|
|
4433
4865
|
true
|
|
4434
4866
|
);
|
|
4435
|
-
case AggregateError:
|
|
4436
|
-
if (ctx.features & 1 /* AggregateError */) {
|
|
4437
|
-
return generateAggregateErrorNode4(ctx, id, current);
|
|
4438
|
-
}
|
|
4439
|
-
return generateErrorNode4(ctx, id, current);
|
|
4440
4867
|
case Error:
|
|
4441
4868
|
case EvalError:
|
|
4442
4869
|
case RangeError:
|
|
@@ -4445,38 +4872,90 @@ function parseObject4(ctx, current) {
|
|
|
4445
4872
|
case TypeError:
|
|
4446
4873
|
case URIError:
|
|
4447
4874
|
return generateErrorNode4(ctx, id, current);
|
|
4448
|
-
case URL:
|
|
4449
|
-
return createURLNode(ctx, id, current);
|
|
4450
|
-
case URLSearchParams:
|
|
4451
|
-
return createURLSearchParamsNode(ctx, id, current);
|
|
4452
|
-
case Headers:
|
|
4453
|
-
return generateHeadersNode4(ctx, id, current);
|
|
4454
|
-
case FormData:
|
|
4455
|
-
return generateFormDataNode4(ctx, id, current);
|
|
4456
|
-
case ReadableStream:
|
|
4457
|
-
return generateReadableStreamNode(ctx, id, current);
|
|
4458
4875
|
default:
|
|
4459
4876
|
break;
|
|
4460
4877
|
}
|
|
4461
|
-
if (
|
|
4462
|
-
|
|
4463
|
-
|
|
4878
|
+
if (ctx.features & 2048 /* TypedArray */) {
|
|
4879
|
+
switch (currentClass) {
|
|
4880
|
+
case ArrayBuffer:
|
|
4881
|
+
return createArrayBufferNode(id, current);
|
|
4882
|
+
case Int8Array:
|
|
4883
|
+
case Int16Array:
|
|
4884
|
+
case Int32Array:
|
|
4885
|
+
case Uint8Array:
|
|
4886
|
+
case Uint16Array:
|
|
4887
|
+
case Uint32Array:
|
|
4888
|
+
case Uint8ClampedArray:
|
|
4889
|
+
case Float32Array:
|
|
4890
|
+
case Float64Array:
|
|
4891
|
+
return createTypedArrayNode2(ctx, id, current);
|
|
4892
|
+
case DataView:
|
|
4893
|
+
return createDataViewNode2(ctx, id, current);
|
|
4894
|
+
default:
|
|
4895
|
+
break;
|
|
4464
4896
|
}
|
|
4465
|
-
return generateErrorNode4(ctx, id, current);
|
|
4466
4897
|
}
|
|
4467
|
-
if (
|
|
4468
|
-
|
|
4898
|
+
if ((ctx.features & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
4899
|
+
switch (currentClass) {
|
|
4900
|
+
case BigInt64Array:
|
|
4901
|
+
case BigUint64Array:
|
|
4902
|
+
return createBigIntTypedArrayNode2(ctx, id, current);
|
|
4903
|
+
default:
|
|
4904
|
+
break;
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
if (ctx.features & 32 /* Map */ && currentClass === Map) {
|
|
4908
|
+
return generateMapNode4(ctx, id, current);
|
|
4909
|
+
}
|
|
4910
|
+
if (ctx.features & 512 /* Set */ && currentClass === Set) {
|
|
4911
|
+
return generateSetNode4(ctx, id, current);
|
|
4912
|
+
}
|
|
4913
|
+
if (ctx.features & 8192 /* WebAPI */) {
|
|
4914
|
+
switch (currentClass) {
|
|
4915
|
+
case URL:
|
|
4916
|
+
return createURLNode(id, current);
|
|
4917
|
+
case URLSearchParams:
|
|
4918
|
+
return createURLSearchParamsNode(id, current);
|
|
4919
|
+
case Headers:
|
|
4920
|
+
return generateHeadersNode4(ctx, id, current);
|
|
4921
|
+
case FormData:
|
|
4922
|
+
return generateFormDataNode4(ctx, id, current);
|
|
4923
|
+
case ReadableStream:
|
|
4924
|
+
return generateReadableStreamNode(ctx, id, current);
|
|
4925
|
+
case Request:
|
|
4926
|
+
return generateRequestNode3(ctx, id, current);
|
|
4927
|
+
case Response:
|
|
4928
|
+
return generateResponseNode3(ctx, id, current);
|
|
4929
|
+
case Event:
|
|
4930
|
+
return generateEventNode4(ctx, id, current);
|
|
4931
|
+
case CustomEvent:
|
|
4932
|
+
return generateCustomEventNode4(ctx, id, current);
|
|
4933
|
+
case DOMException:
|
|
4934
|
+
return createDOMExceptionNode(id, current);
|
|
4935
|
+
default:
|
|
4936
|
+
break;
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
if (ctx.features & 1 /* AggregateError */ && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
4940
|
+
return generateAggregateErrorNode4(ctx, id, current);
|
|
4469
4941
|
}
|
|
4470
|
-
if (current instanceof Promise) {
|
|
4942
|
+
if (ctx.features & 256 /* Promise */ && (currentClass === Promise || current instanceof Promise)) {
|
|
4471
4943
|
return generatePromiseNode3(ctx, id, current);
|
|
4472
4944
|
}
|
|
4473
|
-
if (
|
|
4474
|
-
return
|
|
4945
|
+
if (current instanceof Error) {
|
|
4946
|
+
return generateErrorNode4(ctx, id, current);
|
|
4947
|
+
}
|
|
4948
|
+
if (ctx.features & 1024 /* Symbol */ && Symbol.iterator in current) {
|
|
4949
|
+
return generateObjectNode4(ctx, id, current, !!currentClass);
|
|
4475
4950
|
}
|
|
4476
4951
|
throw new UnsupportedTypeError(current);
|
|
4477
4952
|
}
|
|
4478
4953
|
function crossParseStream(ctx, current) {
|
|
4479
|
-
|
|
4954
|
+
const t = typeof current;
|
|
4955
|
+
if (ctx.features & 8 /* BigInt */ && t === "bigint") {
|
|
4956
|
+
return createBigIntNode(ctx, current);
|
|
4957
|
+
}
|
|
4958
|
+
switch (t) {
|
|
4480
4959
|
case "boolean":
|
|
4481
4960
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
4482
4961
|
case "undefined":
|
|
@@ -4485,8 +4964,6 @@ function crossParseStream(ctx, current) {
|
|
|
4485
4964
|
return createStringNode(current);
|
|
4486
4965
|
case "number":
|
|
4487
4966
|
return createNumberNode(current);
|
|
4488
|
-
case "bigint":
|
|
4489
|
-
return createBigIntNode(ctx, current);
|
|
4490
4967
|
case "object":
|
|
4491
4968
|
return parseObject4(ctx, current);
|
|
4492
4969
|
case "symbol":
|
|
@@ -4538,7 +5015,6 @@ function generateArrayNode5(ctx, id, current) {
|
|
|
4538
5015
|
};
|
|
4539
5016
|
}
|
|
4540
5017
|
function generateMapNode5(ctx, id, current) {
|
|
4541
|
-
assert(ctx.features & 32 /* Map */, new UnsupportedTypeError(current));
|
|
4542
5018
|
const len = current.size;
|
|
4543
5019
|
const keyNodes = new Array(len);
|
|
4544
5020
|
const valueNodes = new Array(len);
|
|
@@ -4577,7 +5053,6 @@ function generateMapNode5(ctx, id, current) {
|
|
|
4577
5053
|
};
|
|
4578
5054
|
}
|
|
4579
5055
|
function generateSetNode5(ctx, id, current) {
|
|
4580
|
-
assert(ctx.features & 512 /* Set */, new UnsupportedTypeError(current));
|
|
4581
5056
|
const len = current.size;
|
|
4582
5057
|
const nodes = new Array(len);
|
|
4583
5058
|
const deferred = new Array(len);
|
|
@@ -4737,7 +5212,6 @@ function generateErrorNode5(ctx, id, current) {
|
|
|
4737
5212
|
};
|
|
4738
5213
|
}
|
|
4739
5214
|
function generateHeadersNode5(ctx, id, current) {
|
|
4740
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
4741
5215
|
const items = {};
|
|
4742
5216
|
current.forEach((value, key) => {
|
|
4743
5217
|
items[key] = value;
|
|
@@ -4758,7 +5232,6 @@ function generateHeadersNode5(ctx, id, current) {
|
|
|
4758
5232
|
};
|
|
4759
5233
|
}
|
|
4760
5234
|
function generateFormDataNode5(ctx, id, current) {
|
|
4761
|
-
assert(ctx.features & 8192 /* WebAPI */, new UnsupportedTypeError(current));
|
|
4762
5235
|
const items = {};
|
|
4763
5236
|
current.forEach((value, key) => {
|
|
4764
5237
|
items[key] = value;
|
|
@@ -4794,6 +5267,38 @@ function generateBoxedNode5(ctx, id, current) {
|
|
|
4794
5267
|
o: void 0
|
|
4795
5268
|
};
|
|
4796
5269
|
}
|
|
5270
|
+
function generateEventNode5(ctx, id, current) {
|
|
5271
|
+
return {
|
|
5272
|
+
t: 37 /* Event */,
|
|
5273
|
+
i: id,
|
|
5274
|
+
s: serializeString(current.type),
|
|
5275
|
+
l: void 0,
|
|
5276
|
+
c: void 0,
|
|
5277
|
+
m: void 0,
|
|
5278
|
+
p: void 0,
|
|
5279
|
+
e: void 0,
|
|
5280
|
+
a: void 0,
|
|
5281
|
+
f: parseObject5(ctx, createEventOptions(current)),
|
|
5282
|
+
b: void 0,
|
|
5283
|
+
o: void 0
|
|
5284
|
+
};
|
|
5285
|
+
}
|
|
5286
|
+
function generateCustomEventNode5(ctx, id, current) {
|
|
5287
|
+
return {
|
|
5288
|
+
t: 38 /* CustomEvent */,
|
|
5289
|
+
i: id,
|
|
5290
|
+
s: serializeString(current.type),
|
|
5291
|
+
l: void 0,
|
|
5292
|
+
c: void 0,
|
|
5293
|
+
m: void 0,
|
|
5294
|
+
p: void 0,
|
|
5295
|
+
e: void 0,
|
|
5296
|
+
a: void 0,
|
|
5297
|
+
f: parseObject5(ctx, createCustomEventOptions(current)),
|
|
5298
|
+
b: void 0,
|
|
5299
|
+
o: void 0
|
|
5300
|
+
};
|
|
5301
|
+
}
|
|
4797
5302
|
function parseObject5(ctx, current) {
|
|
4798
5303
|
if (!current) {
|
|
4799
5304
|
return NULL_NODE;
|
|
@@ -4810,39 +5315,17 @@ function parseObject5(ctx, current) {
|
|
|
4810
5315
|
if (Array.isArray(current)) {
|
|
4811
5316
|
return generateArrayNode5(ctx, id, current);
|
|
4812
5317
|
}
|
|
4813
|
-
|
|
5318
|
+
const currentClass = current.constructor;
|
|
5319
|
+
switch (currentClass) {
|
|
4814
5320
|
case Number:
|
|
4815
5321
|
case Boolean:
|
|
4816
5322
|
case String:
|
|
4817
5323
|
case BigInt:
|
|
4818
|
-
case Function:
|
|
4819
|
-
case Symbol:
|
|
4820
5324
|
return generateBoxedNode5(ctx, id, current);
|
|
4821
5325
|
case Date:
|
|
4822
5326
|
return createDateNode(id, current);
|
|
4823
5327
|
case RegExp:
|
|
4824
5328
|
return createRegExpNode(id, current);
|
|
4825
|
-
case ArrayBuffer:
|
|
4826
|
-
return createArrayBufferNode(id, current);
|
|
4827
|
-
case Int8Array:
|
|
4828
|
-
case Int16Array:
|
|
4829
|
-
case Int32Array:
|
|
4830
|
-
case Uint8Array:
|
|
4831
|
-
case Uint16Array:
|
|
4832
|
-
case Uint32Array:
|
|
4833
|
-
case Uint8ClampedArray:
|
|
4834
|
-
case Float32Array:
|
|
4835
|
-
case Float64Array:
|
|
4836
|
-
return createTypedArrayNode2(ctx, id, current);
|
|
4837
|
-
case BigInt64Array:
|
|
4838
|
-
case BigUint64Array:
|
|
4839
|
-
return createBigIntTypedArrayNode2(ctx, id, current);
|
|
4840
|
-
case DataView:
|
|
4841
|
-
return createDataViewNode2(ctx, id, current);
|
|
4842
|
-
case Map:
|
|
4843
|
-
return generateMapNode5(ctx, id, current);
|
|
4844
|
-
case Set:
|
|
4845
|
-
return generateSetNode5(ctx, id, current);
|
|
4846
5329
|
case Object:
|
|
4847
5330
|
return generateObjectNode5(
|
|
4848
5331
|
ctx,
|
|
@@ -4857,11 +5340,6 @@ function parseObject5(ctx, current) {
|
|
|
4857
5340
|
current,
|
|
4858
5341
|
true
|
|
4859
5342
|
);
|
|
4860
|
-
case AggregateError:
|
|
4861
|
-
if (ctx.features & 1 /* AggregateError */) {
|
|
4862
|
-
return generateAggregateErrorNode5(ctx, id, current);
|
|
4863
|
-
}
|
|
4864
|
-
return generateErrorNode5(ctx, id, current);
|
|
4865
5343
|
case Error:
|
|
4866
5344
|
case EvalError:
|
|
4867
5345
|
case RangeError:
|
|
@@ -4870,33 +5348,81 @@ function parseObject5(ctx, current) {
|
|
|
4870
5348
|
case TypeError:
|
|
4871
5349
|
case URIError:
|
|
4872
5350
|
return generateErrorNode5(ctx, id, current);
|
|
4873
|
-
case URL:
|
|
4874
|
-
return createURLNode(ctx, id, current);
|
|
4875
|
-
case URLSearchParams:
|
|
4876
|
-
return createURLSearchParamsNode(ctx, id, current);
|
|
4877
|
-
case Headers:
|
|
4878
|
-
return generateHeadersNode5(ctx, id, current);
|
|
4879
|
-
case FormData:
|
|
4880
|
-
return generateFormDataNode5(ctx, id, current);
|
|
4881
5351
|
default:
|
|
4882
5352
|
break;
|
|
4883
5353
|
}
|
|
4884
|
-
if (
|
|
4885
|
-
|
|
4886
|
-
|
|
5354
|
+
if (ctx.features & 2048 /* TypedArray */) {
|
|
5355
|
+
switch (currentClass) {
|
|
5356
|
+
case ArrayBuffer:
|
|
5357
|
+
return createArrayBufferNode(id, current);
|
|
5358
|
+
case Int8Array:
|
|
5359
|
+
case Int16Array:
|
|
5360
|
+
case Int32Array:
|
|
5361
|
+
case Uint8Array:
|
|
5362
|
+
case Uint16Array:
|
|
5363
|
+
case Uint32Array:
|
|
5364
|
+
case Uint8ClampedArray:
|
|
5365
|
+
case Float32Array:
|
|
5366
|
+
case Float64Array:
|
|
5367
|
+
return createTypedArrayNode2(ctx, id, current);
|
|
5368
|
+
case DataView:
|
|
5369
|
+
return createDataViewNode2(ctx, id, current);
|
|
5370
|
+
default:
|
|
5371
|
+
break;
|
|
4887
5372
|
}
|
|
4888
|
-
|
|
5373
|
+
}
|
|
5374
|
+
if ((ctx.features & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
5375
|
+
switch (currentClass) {
|
|
5376
|
+
case BigInt64Array:
|
|
5377
|
+
case BigUint64Array:
|
|
5378
|
+
return createBigIntTypedArrayNode2(ctx, id, current);
|
|
5379
|
+
default:
|
|
5380
|
+
break;
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
if (ctx.features & 32 /* Map */ && currentClass === Map) {
|
|
5384
|
+
return generateMapNode5(ctx, id, current);
|
|
5385
|
+
}
|
|
5386
|
+
if (ctx.features & 512 /* Set */ && currentClass === Set) {
|
|
5387
|
+
return generateSetNode5(ctx, id, current);
|
|
5388
|
+
}
|
|
5389
|
+
if (ctx.features & 8192 /* WebAPI */) {
|
|
5390
|
+
switch (currentClass) {
|
|
5391
|
+
case URL:
|
|
5392
|
+
return createURLNode(id, current);
|
|
5393
|
+
case URLSearchParams:
|
|
5394
|
+
return createURLSearchParamsNode(id, current);
|
|
5395
|
+
case Headers:
|
|
5396
|
+
return generateHeadersNode5(ctx, id, current);
|
|
5397
|
+
case FormData:
|
|
5398
|
+
return generateFormDataNode5(ctx, id, current);
|
|
5399
|
+
case Event:
|
|
5400
|
+
return generateEventNode5(ctx, id, current);
|
|
5401
|
+
case CustomEvent:
|
|
5402
|
+
return generateCustomEventNode5(ctx, id, current);
|
|
5403
|
+
case DOMException:
|
|
5404
|
+
return createDOMExceptionNode(id, current);
|
|
5405
|
+
default:
|
|
5406
|
+
break;
|
|
5407
|
+
}
|
|
5408
|
+
}
|
|
5409
|
+
if (ctx.features & 1 /* AggregateError */ && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
5410
|
+
return generateAggregateErrorNode5(ctx, id, current);
|
|
4889
5411
|
}
|
|
4890
5412
|
if (current instanceof Error) {
|
|
4891
5413
|
return generateErrorNode5(ctx, id, current);
|
|
4892
5414
|
}
|
|
4893
|
-
if (Symbol.iterator in current) {
|
|
4894
|
-
return generateObjectNode5(ctx, id, current, !!
|
|
5415
|
+
if (ctx.features & 1024 /* Symbol */ && Symbol.iterator in current) {
|
|
5416
|
+
return generateObjectNode5(ctx, id, current, !!currentClass);
|
|
4895
5417
|
}
|
|
4896
5418
|
throw new UnsupportedTypeError(current);
|
|
4897
5419
|
}
|
|
4898
5420
|
function crossParseSync(ctx, current) {
|
|
4899
|
-
|
|
5421
|
+
const t = typeof current;
|
|
5422
|
+
if (ctx.features & 8 /* BigInt */ && t === "bigint") {
|
|
5423
|
+
return createBigIntNode(ctx, current);
|
|
5424
|
+
}
|
|
5425
|
+
switch (t) {
|
|
4900
5426
|
case "boolean":
|
|
4901
5427
|
return current ? TRUE_NODE : FALSE_NODE;
|
|
4902
5428
|
case "undefined":
|
|
@@ -4905,8 +5431,6 @@ function crossParseSync(ctx, current) {
|
|
|
4905
5431
|
return createStringNode(current);
|
|
4906
5432
|
case "number":
|
|
4907
5433
|
return createNumberNode(current);
|
|
4908
|
-
case "bigint":
|
|
4909
|
-
return createBigIntNode(ctx, current);
|
|
4910
5434
|
case "object":
|
|
4911
5435
|
return parseObject5(ctx, current);
|
|
4912
5436
|
case "symbol":
|