seroval 0.15.0 → 1.0.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/README.md +3 -3
- package/dist/cjs/development/index.cjs +1278 -1929
- package/dist/cjs/development/index.cjs.map +3 -3
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +1278 -1929
- package/dist/esm/development/index.mjs.map +3 -3
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/Serializer.d.ts +2 -1
- package/dist/types/core/Serializer.d.ts.map +1 -1
- package/dist/types/core/UnsupportedTypeError.d.ts.map +1 -1
- package/dist/types/core/base-primitives.d.ts +6 -2
- package/dist/types/core/base-primitives.d.ts.map +1 -1
- package/dist/types/core/compat.d.ts +5 -13
- package/dist/types/core/compat.d.ts.map +1 -1
- package/dist/types/core/constants.d.ts +17 -29
- package/dist/types/core/constants.d.ts.map +1 -1
- package/dist/types/core/context/deserializer.d.ts +6 -16
- package/dist/types/core/context/deserializer.d.ts.map +1 -1
- package/dist/types/core/context/parser/async.d.ts +2 -11
- package/dist/types/core/context/parser/async.d.ts.map +1 -1
- package/dist/types/core/context/parser/stream.d.ts +10 -10
- package/dist/types/core/context/parser/stream.d.ts.map +1 -1
- package/dist/types/core/context/parser/sync.d.ts +5 -7
- package/dist/types/core/context/parser/sync.d.ts.map +1 -1
- package/dist/types/core/context/parser.d.ts +19 -4
- package/dist/types/core/context/parser.d.ts.map +1 -1
- package/dist/types/core/context/serializer.d.ts +11 -25
- package/dist/types/core/context/serializer.d.ts.map +1 -1
- package/dist/types/core/cross/async.d.ts.map +1 -1
- package/dist/types/core/cross/deserializer.d.ts.map +1 -1
- package/dist/types/core/cross/index.d.ts.map +1 -1
- package/dist/types/core/cross/parser.d.ts.map +1 -1
- package/dist/types/core/cross/serializer.d.ts +1 -1
- package/dist/types/core/cross/serializer.d.ts.map +1 -1
- package/dist/types/core/cross/stream.d.ts.map +1 -1
- package/dist/types/core/cross/sync.d.ts.map +1 -1
- package/dist/types/core/keys.d.ts.map +1 -1
- package/dist/types/core/literals.d.ts.map +1 -1
- package/dist/types/core/plugin.d.ts +21 -0
- package/dist/types/core/plugin.d.ts.map +1 -1
- package/dist/types/core/reference.d.ts.map +1 -1
- package/dist/types/core/special-reference.d.ts +4 -9
- package/dist/types/core/special-reference.d.ts.map +1 -1
- package/dist/types/core/stream.d.ts +18 -0
- package/dist/types/core/stream.d.ts.map +1 -0
- package/dist/types/core/string.d.ts.map +1 -1
- package/dist/types/core/tree/async.d.ts.map +1 -1
- package/dist/types/core/tree/deserializer.d.ts.map +1 -1
- package/dist/types/core/tree/index.d.ts +1 -1
- package/dist/types/core/tree/index.d.ts.map +1 -1
- package/dist/types/core/tree/serializer.d.ts +3 -11
- package/dist/types/core/tree/serializer.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +28 -122
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/core/utils/deferred.d.ts +0 -7
- package/dist/types/core/utils/deferred.d.ts.map +1 -1
- package/dist/types/core/utils/error.d.ts +2 -1
- package/dist/types/core/utils/error.d.ts.map +1 -1
- package/dist/types/core/utils/get-identifier.d.ts.map +1 -1
- package/dist/types/core/utils/is-valid-identifier.d.ts.map +1 -1
- package/dist/types/core/utils/iterator-to-sequence.d.ts +0 -12
- package/dist/types/core/utils/iterator-to-sequence.d.ts.map +1 -1
- package/dist/types/core/utils/typed-array.d.ts +2 -0
- package/dist/types/core/utils/typed-array.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/core/Serializer.ts +44 -28
- package/src/core/UnsupportedTypeError.ts +2 -3
- package/src/core/base-primitives.ts +124 -38
- package/src/core/compat.ts +5 -14
- package/src/core/constants.ts +28 -39
- package/src/core/context/deserializer.ts +122 -308
- package/src/core/context/parser/async.ts +163 -375
- package/src/core/context/parser/stream.ts +109 -367
- package/src/core/context/parser/sync.ts +139 -266
- package/src/core/context/parser.ts +93 -68
- package/src/core/context/serializer.ts +370 -439
- package/src/core/cross/async.ts +1 -1
- package/src/core/cross/deserializer.ts +1 -4
- package/src/core/cross/index.ts +28 -31
- package/src/core/cross/parser.ts +1 -1
- package/src/core/cross/serializer.ts +30 -20
- package/src/core/cross/stream.ts +1 -1
- package/src/core/cross/sync.ts +1 -1
- package/src/core/keys.ts +3 -1
- package/src/core/literals.ts +22 -8
- package/src/core/plugin.ts +48 -10
- package/src/core/reference.ts +4 -5
- package/src/core/special-reference.ts +5 -15
- package/src/core/stream.ts +205 -0
- package/src/core/string.ts +53 -22
- package/src/core/tree/async.ts +1 -1
- package/src/core/tree/deserializer.ts +4 -9
- package/src/core/tree/index.ts +15 -10
- package/src/core/tree/serializer.ts +6 -50
- package/src/core/types.ts +39 -179
- package/src/core/utils/deferred.ts +0 -27
- package/src/core/utils/error.ts +26 -15
- package/src/core/utils/get-identifier.ts +5 -4
- package/src/core/utils/is-valid-identifier.ts +6 -5
- package/src/core/utils/iterator-to-sequence.ts +0 -174
- package/src/core/utils/typed-array.ts +35 -11
- package/src/index.ts +5 -12
- package/dist/types/core/utils/constructors.d.ts +0 -5
- package/dist/types/core/utils/constructors.d.ts.map +0 -1
- package/dist/types/core/web-api.d.ts +0 -8
- package/dist/types/core/web-api.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -21
- package/dist/types/types.d.ts.map +0 -1
- package/src/core/utils/constructors.ts +0 -49
- package/src/core/web-api.ts +0 -138
- package/src/example.ts +0 -25
- package/src/types.ts +0 -84
|
@@ -25,13 +25,15 @@ __export(src_exports, {
|
|
|
25
25
|
compileJSON: () => compileJSON,
|
|
26
26
|
createPlugin: () => createPlugin,
|
|
27
27
|
createReference: () => createReference,
|
|
28
|
+
createStream: () => createStream,
|
|
28
29
|
crossSerialize: () => crossSerialize,
|
|
29
30
|
crossSerializeAsync: () => crossSerializeAsync,
|
|
30
31
|
crossSerializeStream: () => crossSerializeStream,
|
|
31
|
-
default: () => src_default,
|
|
32
32
|
deserialize: () => deserialize,
|
|
33
33
|
fromCrossJSON: () => fromCrossJSON,
|
|
34
34
|
fromJSON: () => fromJSON,
|
|
35
|
+
getCrossReferenceHeader: () => getCrossReferenceHeader,
|
|
36
|
+
resolvePlugins: () => resolvePlugins,
|
|
35
37
|
serialize: () => serialize,
|
|
36
38
|
serializeAsync: () => serializeAsync,
|
|
37
39
|
toCrossJSON: () => toCrossJSON,
|
|
@@ -42,14 +44,16 @@ __export(src_exports, {
|
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(src_exports);
|
|
44
46
|
|
|
45
|
-
// src/core/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
// src/core/compat.ts
|
|
48
|
+
var Feature = /* @__PURE__ */ ((Feature2) => {
|
|
49
|
+
Feature2[Feature2["AggregateError"] = 1] = "AggregateError";
|
|
50
|
+
Feature2[Feature2["ArrowFunction"] = 2] = "ArrowFunction";
|
|
51
|
+
Feature2[Feature2["ErrorPrototypeStack"] = 4] = "ErrorPrototypeStack";
|
|
52
|
+
Feature2[Feature2["ObjectAssign"] = 8] = "ObjectAssign";
|
|
53
|
+
Feature2[Feature2["BigIntTypedArray"] = 16] = "BigIntTypedArray";
|
|
54
|
+
return Feature2;
|
|
55
|
+
})(Feature || {});
|
|
56
|
+
var ALL_ENABLED = 31;
|
|
53
57
|
|
|
54
58
|
// src/core/utils/assert.ts
|
|
55
59
|
function assert(cond, error) {
|
|
@@ -58,117 +62,6 @@ function assert(cond, error) {
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
// src/core/constants.ts
|
|
62
|
-
var SYMBOL_STRING = {
|
|
63
|
-
[0 /* AsyncIterator */]: "Symbol.asyncIterator",
|
|
64
|
-
[1 /* HasInstance */]: "Symbol.hasInstance",
|
|
65
|
-
[2 /* IsConcatSpreadable */]: "Symbol.isConcatSpreadable",
|
|
66
|
-
[3 /* Iterator */]: "Symbol.iterator",
|
|
67
|
-
[4 /* Match */]: "Symbol.match",
|
|
68
|
-
[5 /* MatchAll */]: "Symbol.matchAll",
|
|
69
|
-
[6 /* Replace */]: "Symbol.replace",
|
|
70
|
-
[7 /* Search */]: "Symbol.search",
|
|
71
|
-
[8 /* Species */]: "Symbol.species",
|
|
72
|
-
[9 /* Split */]: "Symbol.split",
|
|
73
|
-
[10 /* ToPrimitive */]: "Symbol.toPrimitive",
|
|
74
|
-
[11 /* ToStringTag */]: "Symbol.toStringTag",
|
|
75
|
-
[12 /* Unscopables */]: "Symbol.unscopables"
|
|
76
|
-
};
|
|
77
|
-
var INV_SYMBOL_REF = {
|
|
78
|
-
[Symbol.asyncIterator]: 0 /* AsyncIterator */,
|
|
79
|
-
[Symbol.hasInstance]: 1 /* HasInstance */,
|
|
80
|
-
[Symbol.isConcatSpreadable]: 2 /* IsConcatSpreadable */,
|
|
81
|
-
[Symbol.iterator]: 3 /* Iterator */,
|
|
82
|
-
[Symbol.match]: 4 /* Match */,
|
|
83
|
-
[Symbol.matchAll]: 5 /* MatchAll */,
|
|
84
|
-
[Symbol.replace]: 6 /* Replace */,
|
|
85
|
-
[Symbol.search]: 7 /* Search */,
|
|
86
|
-
[Symbol.species]: 8 /* Species */,
|
|
87
|
-
[Symbol.split]: 9 /* Split */,
|
|
88
|
-
[Symbol.toPrimitive]: 10 /* ToPrimitive */,
|
|
89
|
-
[Symbol.toStringTag]: 11 /* ToStringTag */,
|
|
90
|
-
[Symbol.unscopables]: 12 /* Unscopables */
|
|
91
|
-
};
|
|
92
|
-
var SYMBOL_REF = {
|
|
93
|
-
[0 /* AsyncIterator */]: Symbol.asyncIterator,
|
|
94
|
-
[1 /* HasInstance */]: Symbol.hasInstance,
|
|
95
|
-
[2 /* IsConcatSpreadable */]: Symbol.isConcatSpreadable,
|
|
96
|
-
[3 /* Iterator */]: Symbol.iterator,
|
|
97
|
-
[4 /* Match */]: Symbol.match,
|
|
98
|
-
[5 /* MatchAll */]: Symbol.matchAll,
|
|
99
|
-
[6 /* Replace */]: Symbol.replace,
|
|
100
|
-
[7 /* Search */]: Symbol.search,
|
|
101
|
-
[8 /* Species */]: Symbol.species,
|
|
102
|
-
[9 /* Split */]: Symbol.split,
|
|
103
|
-
[10 /* ToPrimitive */]: Symbol.toPrimitive,
|
|
104
|
-
[11 /* ToStringTag */]: Symbol.toStringTag,
|
|
105
|
-
[12 /* Unscopables */]: Symbol.unscopables
|
|
106
|
-
};
|
|
107
|
-
var CONSTANT_STRING = {
|
|
108
|
-
[2 /* True */]: "!0",
|
|
109
|
-
[3 /* False */]: "!1",
|
|
110
|
-
[1 /* Undefined */]: "void 0",
|
|
111
|
-
[0 /* Null */]: "null",
|
|
112
|
-
[4 /* NegativeZero */]: "-0",
|
|
113
|
-
[5 /* Infinity */]: "1/0",
|
|
114
|
-
[6 /* NegativeInfinity */]: "-1/0",
|
|
115
|
-
[7 /* NaN */]: "0/0"
|
|
116
|
-
};
|
|
117
|
-
var CONSTANT_VAL = {
|
|
118
|
-
[2 /* True */]: true,
|
|
119
|
-
[3 /* False */]: false,
|
|
120
|
-
[1 /* Undefined */]: void 0,
|
|
121
|
-
[0 /* Null */]: null,
|
|
122
|
-
[4 /* NegativeZero */]: -0,
|
|
123
|
-
[5 /* Infinity */]: Infinity,
|
|
124
|
-
[6 /* NegativeInfinity */]: -Infinity,
|
|
125
|
-
[7 /* NaN */]: NaN
|
|
126
|
-
};
|
|
127
|
-
var ERROR_CONSTRUCTOR_STRING = {
|
|
128
|
-
[0 /* Error */]: "Error",
|
|
129
|
-
[1 /* EvalError */]: "EvalError",
|
|
130
|
-
[2 /* RangeError */]: "RangeError",
|
|
131
|
-
[3 /* ReferenceError */]: "ReferenceError",
|
|
132
|
-
[4 /* SyntaxError */]: "SyntaxError",
|
|
133
|
-
[5 /* TypeError */]: "TypeError",
|
|
134
|
-
[6 /* URIError */]: "URIError"
|
|
135
|
-
};
|
|
136
|
-
var ERROR_CONSTRUCTOR = {
|
|
137
|
-
[0 /* Error */]: Error,
|
|
138
|
-
[1 /* EvalError */]: EvalError,
|
|
139
|
-
[2 /* RangeError */]: RangeError,
|
|
140
|
-
[3 /* ReferenceError */]: ReferenceError,
|
|
141
|
-
[4 /* SyntaxError */]: SyntaxError,
|
|
142
|
-
[5 /* TypeError */]: TypeError,
|
|
143
|
-
[6 /* URIError */]: URIError
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// src/core/literals.ts
|
|
147
|
-
function createConstantNode(value) {
|
|
148
|
-
return {
|
|
149
|
-
t: 2 /* Constant */,
|
|
150
|
-
i: void 0,
|
|
151
|
-
s: value,
|
|
152
|
-
l: void 0,
|
|
153
|
-
c: void 0,
|
|
154
|
-
m: void 0,
|
|
155
|
-
p: void 0,
|
|
156
|
-
e: void 0,
|
|
157
|
-
a: void 0,
|
|
158
|
-
f: void 0,
|
|
159
|
-
b: void 0,
|
|
160
|
-
o: void 0
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
var TRUE_NODE = createConstantNode(2 /* True */);
|
|
164
|
-
var FALSE_NODE = createConstantNode(3 /* False */);
|
|
165
|
-
var UNDEFINED_NODE = createConstantNode(1 /* Undefined */);
|
|
166
|
-
var NULL_NODE = createConstantNode(0 /* Null */);
|
|
167
|
-
var NEG_ZERO_NODE = createConstantNode(4 /* NegativeZero */);
|
|
168
|
-
var INFINITY_NODE = createConstantNode(5 /* Infinity */);
|
|
169
|
-
var NEG_INFINITY_NODE = createConstantNode(6 /* NegativeInfinity */);
|
|
170
|
-
var NAN_NODE = createConstantNode(7 /* NaN */);
|
|
171
|
-
|
|
172
65
|
// src/core/string.ts
|
|
173
66
|
function serializeChar(str) {
|
|
174
67
|
switch (str) {
|
|
@@ -214,8 +107,37 @@ function serializeString(str) {
|
|
|
214
107
|
}
|
|
215
108
|
return result;
|
|
216
109
|
}
|
|
110
|
+
function deserializeReplacer(str) {
|
|
111
|
+
switch (str) {
|
|
112
|
+
case "\\\\":
|
|
113
|
+
return "\\";
|
|
114
|
+
case '\\"':
|
|
115
|
+
return '"';
|
|
116
|
+
case "\\n":
|
|
117
|
+
return "\n";
|
|
118
|
+
case "\\r":
|
|
119
|
+
return "\r";
|
|
120
|
+
case "\\b":
|
|
121
|
+
return "\b";
|
|
122
|
+
case "\\t":
|
|
123
|
+
return " ";
|
|
124
|
+
case "\\f":
|
|
125
|
+
return "\f";
|
|
126
|
+
case "\\x3C":
|
|
127
|
+
return "<";
|
|
128
|
+
case "\\u2028":
|
|
129
|
+
return "\u2028";
|
|
130
|
+
case "\\u2029":
|
|
131
|
+
return "\u2029";
|
|
132
|
+
default:
|
|
133
|
+
return str;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
217
136
|
function deserializeString(str) {
|
|
218
|
-
return str.replace(
|
|
137
|
+
return str.replace(
|
|
138
|
+
/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g,
|
|
139
|
+
deserializeReplacer
|
|
140
|
+
);
|
|
219
141
|
}
|
|
220
142
|
|
|
221
143
|
// src/core/keys.ts
|
|
@@ -226,7 +148,9 @@ function getCrossReferenceHeader(id) {
|
|
|
226
148
|
if (id == null) {
|
|
227
149
|
return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[]`;
|
|
228
150
|
}
|
|
229
|
-
return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(
|
|
151
|
+
return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(
|
|
152
|
+
id
|
|
153
|
+
)}"]=[]`;
|
|
230
154
|
}
|
|
231
155
|
|
|
232
156
|
// src/core/reference.ts
|
|
@@ -251,28 +175,28 @@ function getReference(id) {
|
|
|
251
175
|
assert(hasReference(id), new Error("Missing reference for id:" + id));
|
|
252
176
|
return INV_REFERENCE.get(id);
|
|
253
177
|
}
|
|
254
|
-
if (typeof globalThis !==
|
|
178
|
+
if (typeof globalThis !== "undefined") {
|
|
255
179
|
Object.defineProperty(globalThis, REFERENCES_KEY, {
|
|
256
180
|
value: INV_REFERENCE,
|
|
257
181
|
configurable: true,
|
|
258
182
|
writable: false,
|
|
259
183
|
enumerable: false
|
|
260
184
|
});
|
|
261
|
-
} else if (typeof window !==
|
|
185
|
+
} else if (typeof window !== "undefined") {
|
|
262
186
|
Object.defineProperty(window, REFERENCES_KEY, {
|
|
263
187
|
value: INV_REFERENCE,
|
|
264
188
|
configurable: true,
|
|
265
189
|
writable: false,
|
|
266
190
|
enumerable: false
|
|
267
191
|
});
|
|
268
|
-
} else if (typeof self !==
|
|
192
|
+
} else if (typeof self !== "undefined") {
|
|
269
193
|
Object.defineProperty(self, REFERENCES_KEY, {
|
|
270
194
|
value: INV_REFERENCE,
|
|
271
195
|
configurable: true,
|
|
272
196
|
writable: false,
|
|
273
197
|
enumerable: false
|
|
274
198
|
});
|
|
275
|
-
} else if (typeof global !==
|
|
199
|
+
} else if (typeof global !== "undefined") {
|
|
276
200
|
Object.defineProperty(global, REFERENCES_KEY, {
|
|
277
201
|
value: INV_REFERENCE,
|
|
278
202
|
configurable: true,
|
|
@@ -281,24 +205,163 @@ if (typeof globalThis !== void 0) {
|
|
|
281
205
|
});
|
|
282
206
|
}
|
|
283
207
|
|
|
284
|
-
// src/core/
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
208
|
+
// src/core/plugin.ts
|
|
209
|
+
function createPlugin(plugin) {
|
|
210
|
+
return plugin;
|
|
211
|
+
}
|
|
212
|
+
function dedupePlugins(deduped, plugins) {
|
|
213
|
+
for (let i = 0, len = plugins.length; i < len; i++) {
|
|
214
|
+
const current = plugins[i];
|
|
215
|
+
if (!deduped.has(current)) {
|
|
216
|
+
deduped.add(current);
|
|
217
|
+
if (current.extends) {
|
|
218
|
+
dedupePlugins(deduped, current.extends);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function resolvePlugins(plugins) {
|
|
224
|
+
if (plugins) {
|
|
225
|
+
const deduped = /* @__PURE__ */ new Set();
|
|
226
|
+
dedupePlugins(deduped, plugins);
|
|
227
|
+
return [...deduped];
|
|
228
|
+
}
|
|
229
|
+
return void 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/core/UnsupportedTypeError.ts
|
|
233
|
+
var { toString: objectToString } = Object.prototype;
|
|
234
|
+
var UnsupportedTypeError = class extends Error {
|
|
235
|
+
constructor(value) {
|
|
236
|
+
super('Unsupported type "' + objectToString.call(value) + '"');
|
|
237
|
+
this.value = value;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// src/core/constants.ts
|
|
242
|
+
var SYMBOL_STRING = {
|
|
243
|
+
[0 /* AsyncIterator */]: "Symbol.asyncIterator",
|
|
244
|
+
[1 /* HasInstance */]: "Symbol.hasInstance",
|
|
245
|
+
[2 /* IsConcatSpreadable */]: "Symbol.isConcatSpreadable",
|
|
246
|
+
[3 /* Iterator */]: "Symbol.iterator",
|
|
247
|
+
[4 /* Match */]: "Symbol.match",
|
|
248
|
+
[5 /* MatchAll */]: "Symbol.matchAll",
|
|
249
|
+
[6 /* Replace */]: "Symbol.replace",
|
|
250
|
+
[7 /* Search */]: "Symbol.search",
|
|
251
|
+
[8 /* Species */]: "Symbol.species",
|
|
252
|
+
[9 /* Split */]: "Symbol.split",
|
|
253
|
+
[10 /* ToPrimitive */]: "Symbol.toPrimitive",
|
|
254
|
+
[11 /* ToStringTag */]: "Symbol.toStringTag",
|
|
255
|
+
[12 /* Unscopables */]: "Symbol.unscopables"
|
|
256
|
+
};
|
|
257
|
+
var INV_SYMBOL_REF = {
|
|
258
|
+
[Symbol.asyncIterator]: 0 /* AsyncIterator */,
|
|
259
|
+
[Symbol.hasInstance]: 1 /* HasInstance */,
|
|
260
|
+
[Symbol.isConcatSpreadable]: 2 /* IsConcatSpreadable */,
|
|
261
|
+
[Symbol.iterator]: 3 /* Iterator */,
|
|
262
|
+
[Symbol.match]: 4 /* Match */,
|
|
263
|
+
[Symbol.matchAll]: 5 /* MatchAll */,
|
|
264
|
+
[Symbol.replace]: 6 /* Replace */,
|
|
265
|
+
[Symbol.search]: 7 /* Search */,
|
|
266
|
+
[Symbol.species]: 8 /* Species */,
|
|
267
|
+
[Symbol.split]: 9 /* Split */,
|
|
268
|
+
[Symbol.toPrimitive]: 10 /* ToPrimitive */,
|
|
269
|
+
[Symbol.toStringTag]: 11 /* ToStringTag */,
|
|
270
|
+
[Symbol.unscopables]: 12 /* Unscopables */
|
|
271
|
+
};
|
|
272
|
+
var SYMBOL_REF = {
|
|
273
|
+
[0 /* AsyncIterator */]: Symbol.asyncIterator,
|
|
274
|
+
[1 /* HasInstance */]: Symbol.hasInstance,
|
|
275
|
+
[2 /* IsConcatSpreadable */]: Symbol.isConcatSpreadable,
|
|
276
|
+
[3 /* Iterator */]: Symbol.iterator,
|
|
277
|
+
[4 /* Match */]: Symbol.match,
|
|
278
|
+
[5 /* MatchAll */]: Symbol.matchAll,
|
|
279
|
+
[6 /* Replace */]: Symbol.replace,
|
|
280
|
+
[7 /* Search */]: Symbol.search,
|
|
281
|
+
[8 /* Species */]: Symbol.species,
|
|
282
|
+
[9 /* Split */]: Symbol.split,
|
|
283
|
+
[10 /* ToPrimitive */]: Symbol.toPrimitive,
|
|
284
|
+
[11 /* ToStringTag */]: Symbol.toStringTag,
|
|
285
|
+
[12 /* Unscopables */]: Symbol.unscopables
|
|
286
|
+
};
|
|
287
|
+
var CONSTANT_STRING = {
|
|
288
|
+
[2 /* True */]: "!0",
|
|
289
|
+
[3 /* False */]: "!1",
|
|
290
|
+
[1 /* Undefined */]: "void 0",
|
|
291
|
+
[0 /* Null */]: "null",
|
|
292
|
+
[4 /* NegativeZero */]: "-0",
|
|
293
|
+
[5 /* Infinity */]: "1/0",
|
|
294
|
+
[6 /* NegativeInfinity */]: "-1/0",
|
|
295
|
+
[7 /* NaN */]: "0/0"
|
|
296
|
+
};
|
|
297
|
+
var CONSTANT_VAL = {
|
|
298
|
+
[2 /* True */]: true,
|
|
299
|
+
[3 /* False */]: false,
|
|
300
|
+
[1 /* Undefined */]: void 0,
|
|
301
|
+
[0 /* Null */]: null,
|
|
302
|
+
[4 /* NegativeZero */]: -0,
|
|
303
|
+
[5 /* Infinity */]: Infinity,
|
|
304
|
+
[6 /* NegativeInfinity */]: -Infinity,
|
|
305
|
+
[7 /* NaN */]: NaN
|
|
306
|
+
};
|
|
307
|
+
var ERROR_CONSTRUCTOR_STRING = {
|
|
308
|
+
[0 /* Error */]: "Error",
|
|
309
|
+
[1 /* EvalError */]: "EvalError",
|
|
310
|
+
[2 /* RangeError */]: "RangeError",
|
|
311
|
+
[3 /* ReferenceError */]: "ReferenceError",
|
|
312
|
+
[4 /* SyntaxError */]: "SyntaxError",
|
|
313
|
+
[5 /* TypeError */]: "TypeError",
|
|
314
|
+
[6 /* URIError */]: "URIError"
|
|
315
|
+
};
|
|
316
|
+
var ERROR_CONSTRUCTOR = {
|
|
317
|
+
[0 /* Error */]: Error,
|
|
318
|
+
[1 /* EvalError */]: EvalError,
|
|
319
|
+
[2 /* RangeError */]: RangeError,
|
|
320
|
+
[3 /* ReferenceError */]: ReferenceError,
|
|
321
|
+
[4 /* SyntaxError */]: SyntaxError,
|
|
322
|
+
[5 /* TypeError */]: TypeError,
|
|
323
|
+
[6 /* URIError */]: URIError
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// src/core/literals.ts
|
|
327
|
+
function createConstantNode(value) {
|
|
328
|
+
return {
|
|
329
|
+
t: 2 /* Constant */,
|
|
330
|
+
i: void 0,
|
|
331
|
+
s: value,
|
|
332
|
+
l: void 0,
|
|
333
|
+
c: void 0,
|
|
334
|
+
m: void 0,
|
|
335
|
+
p: void 0,
|
|
336
|
+
e: void 0,
|
|
337
|
+
a: void 0,
|
|
338
|
+
f: void 0,
|
|
339
|
+
b: void 0,
|
|
340
|
+
o: void 0
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
var TRUE_NODE = /* @__PURE__ */ createConstantNode(
|
|
344
|
+
2 /* True */
|
|
345
|
+
);
|
|
346
|
+
var FALSE_NODE = /* @__PURE__ */ createConstantNode(
|
|
347
|
+
3 /* False */
|
|
348
|
+
);
|
|
349
|
+
var UNDEFINED_NODE = /* @__PURE__ */ createConstantNode(
|
|
350
|
+
1 /* Undefined */
|
|
351
|
+
);
|
|
352
|
+
var NULL_NODE = /* @__PURE__ */ createConstantNode(
|
|
353
|
+
0 /* Null */
|
|
354
|
+
);
|
|
355
|
+
var NEG_ZERO_NODE = /* @__PURE__ */ createConstantNode(
|
|
356
|
+
4 /* NegativeZero */
|
|
357
|
+
);
|
|
358
|
+
var INFINITY_NODE = /* @__PURE__ */ createConstantNode(
|
|
359
|
+
5 /* Infinity */
|
|
360
|
+
);
|
|
361
|
+
var NEG_INFINITY_NODE = /* @__PURE__ */ createConstantNode(
|
|
362
|
+
6 /* NegativeInfinity */
|
|
363
|
+
);
|
|
364
|
+
var NAN_NODE = /* @__PURE__ */ createConstantNode(7 /* NaN */);
|
|
302
365
|
|
|
303
366
|
// src/core/utils/error.ts
|
|
304
367
|
function getErrorConstructor(error) {
|
|
@@ -322,20 +385,24 @@ function getErrorConstructor(error) {
|
|
|
322
385
|
}
|
|
323
386
|
return 0 /* Error */;
|
|
324
387
|
}
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
388
|
+
function getInitialErrorOptions(error) {
|
|
389
|
+
const construct = ERROR_CONSTRUCTOR_STRING[getErrorConstructor(error)];
|
|
390
|
+
if (error.name !== construct) {
|
|
391
|
+
return { name: error.name };
|
|
392
|
+
}
|
|
393
|
+
if (error.constructor.name !== construct) {
|
|
394
|
+
return { name: error.constructor.name };
|
|
332
395
|
}
|
|
396
|
+
return {};
|
|
397
|
+
}
|
|
398
|
+
function getErrorOptions(error, features) {
|
|
399
|
+
let options = getInitialErrorOptions(error);
|
|
333
400
|
const names = Object.getOwnPropertyNames(error);
|
|
334
401
|
for (let i = 0, len = names.length, name; i < len; i++) {
|
|
335
402
|
name = names[i];
|
|
336
403
|
if (name !== "name" && name !== "message") {
|
|
337
404
|
if (name === "stack") {
|
|
338
|
-
if (features &
|
|
405
|
+
if (features & 4 /* ErrorPrototypeStack */) {
|
|
339
406
|
options = options || {};
|
|
340
407
|
options[name] = error[name];
|
|
341
408
|
}
|
|
@@ -369,31 +436,30 @@ function createNumberNode(value) {
|
|
|
369
436
|
return INFINITY_NODE;
|
|
370
437
|
case -Infinity:
|
|
371
438
|
return NEG_INFINITY_NODE;
|
|
372
|
-
default:
|
|
373
|
-
if (value !== value) {
|
|
374
|
-
return NAN_NODE;
|
|
375
|
-
}
|
|
376
|
-
if (Object.is(value, -0)) {
|
|
377
|
-
return NEG_ZERO_NODE;
|
|
378
|
-
}
|
|
379
|
-
return {
|
|
380
|
-
t: 0 /* Number */,
|
|
381
|
-
i: void 0,
|
|
382
|
-
s: value,
|
|
383
|
-
l: void 0,
|
|
384
|
-
c: void 0,
|
|
385
|
-
m: void 0,
|
|
386
|
-
p: void 0,
|
|
387
|
-
e: void 0,
|
|
388
|
-
a: void 0,
|
|
389
|
-
f: void 0,
|
|
390
|
-
b: void 0,
|
|
391
|
-
o: void 0
|
|
392
|
-
};
|
|
393
439
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
440
|
+
if (value !== value) {
|
|
441
|
+
return NAN_NODE;
|
|
442
|
+
}
|
|
443
|
+
if (Object.is(value, -0)) {
|
|
444
|
+
return NEG_ZERO_NODE;
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
t: 0 /* Number */,
|
|
448
|
+
i: void 0,
|
|
449
|
+
s: value,
|
|
450
|
+
l: void 0,
|
|
451
|
+
c: void 0,
|
|
452
|
+
m: void 0,
|
|
453
|
+
p: void 0,
|
|
454
|
+
e: void 0,
|
|
455
|
+
a: void 0,
|
|
456
|
+
f: void 0,
|
|
457
|
+
b: void 0,
|
|
458
|
+
o: void 0
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function createStringNode(value) {
|
|
462
|
+
return {
|
|
397
463
|
t: 1 /* String */,
|
|
398
464
|
i: void 0,
|
|
399
465
|
s: serializeString(value),
|
|
@@ -462,7 +528,7 @@ function createRegExpNode(id, current) {
|
|
|
462
528
|
i: id,
|
|
463
529
|
s: void 0,
|
|
464
530
|
l: void 0,
|
|
465
|
-
c: current.source,
|
|
531
|
+
c: serializeString(current.source),
|
|
466
532
|
m: current.flags,
|
|
467
533
|
p: void 0,
|
|
468
534
|
e: void 0,
|
|
@@ -480,7 +546,7 @@ function createArrayBufferNode(id, current) {
|
|
|
480
546
|
values[i] = bytes[i];
|
|
481
547
|
}
|
|
482
548
|
return {
|
|
483
|
-
t:
|
|
549
|
+
t: 19 /* ArrayBuffer */,
|
|
484
550
|
i: id,
|
|
485
551
|
s: values,
|
|
486
552
|
l: void 0,
|
|
@@ -495,7 +561,10 @@ function createArrayBufferNode(id, current) {
|
|
|
495
561
|
};
|
|
496
562
|
}
|
|
497
563
|
function createWKSymbolNode(id, current) {
|
|
498
|
-
assert(
|
|
564
|
+
assert(
|
|
565
|
+
current in INV_SYMBOL_REF,
|
|
566
|
+
new Error("Only well-known symbols are supported.")
|
|
567
|
+
);
|
|
499
568
|
return {
|
|
500
569
|
t: 17 /* WKSymbol */,
|
|
501
570
|
i: id,
|
|
@@ -513,7 +582,7 @@ function createWKSymbolNode(id, current) {
|
|
|
513
582
|
}
|
|
514
583
|
function createReferenceNode(id, ref) {
|
|
515
584
|
return {
|
|
516
|
-
t:
|
|
585
|
+
t: 18 /* Reference */,
|
|
517
586
|
i: id,
|
|
518
587
|
s: serializeString(getReferenceID(ref)),
|
|
519
588
|
l: void 0,
|
|
@@ -529,7 +598,7 @@ function createReferenceNode(id, ref) {
|
|
|
529
598
|
}
|
|
530
599
|
function createPluginNode(id, tag, value) {
|
|
531
600
|
return {
|
|
532
|
-
t:
|
|
601
|
+
t: 25 /* Plugin */,
|
|
533
602
|
i: id,
|
|
534
603
|
s: value,
|
|
535
604
|
l: void 0,
|
|
@@ -561,7 +630,7 @@ function createArrayNode(id, current, parsedItems) {
|
|
|
561
630
|
}
|
|
562
631
|
function createBoxedNode(id, boxed) {
|
|
563
632
|
return {
|
|
564
|
-
t:
|
|
633
|
+
t: 21 /* Boxed */,
|
|
565
634
|
i: id,
|
|
566
635
|
s: void 0,
|
|
567
636
|
l: void 0,
|
|
@@ -609,7 +678,7 @@ function createBigIntTypedArrayNode(id, current, buffer) {
|
|
|
609
678
|
}
|
|
610
679
|
function createDataViewNode(id, current, buffer) {
|
|
611
680
|
return {
|
|
612
|
-
t:
|
|
681
|
+
t: 20 /* DataView */,
|
|
613
682
|
i: id,
|
|
614
683
|
s: void 0,
|
|
615
684
|
l: current.byteLength,
|
|
@@ -673,7 +742,7 @@ function createSetNode(id, size, items) {
|
|
|
673
742
|
}
|
|
674
743
|
function createIteratorFactoryInstanceNode(factory, items) {
|
|
675
744
|
return {
|
|
676
|
-
t:
|
|
745
|
+
t: 28 /* IteratorFactoryInstance */,
|
|
677
746
|
i: void 0,
|
|
678
747
|
s: void 0,
|
|
679
748
|
l: void 0,
|
|
@@ -681,10 +750,7 @@ function createIteratorFactoryInstanceNode(factory, items) {
|
|
|
681
750
|
m: void 0,
|
|
682
751
|
p: void 0,
|
|
683
752
|
e: void 0,
|
|
684
|
-
a: [
|
|
685
|
-
factory,
|
|
686
|
-
items
|
|
687
|
-
],
|
|
753
|
+
a: [factory, items],
|
|
688
754
|
f: void 0,
|
|
689
755
|
b: void 0,
|
|
690
756
|
o: void 0
|
|
@@ -692,7 +758,7 @@ function createIteratorFactoryInstanceNode(factory, items) {
|
|
|
692
758
|
}
|
|
693
759
|
function createAsyncIteratorFactoryInstanceNode(factory, items) {
|
|
694
760
|
return {
|
|
695
|
-
t:
|
|
761
|
+
t: 30 /* AsyncIteratorFactoryInstance */,
|
|
696
762
|
i: void 0,
|
|
697
763
|
s: void 0,
|
|
698
764
|
l: void 0,
|
|
@@ -700,52 +766,74 @@ function createAsyncIteratorFactoryInstanceNode(factory, items) {
|
|
|
700
766
|
m: void 0,
|
|
701
767
|
p: void 0,
|
|
702
768
|
e: void 0,
|
|
703
|
-
a: [
|
|
704
|
-
factory,
|
|
705
|
-
items
|
|
706
|
-
],
|
|
769
|
+
a: [factory, items],
|
|
707
770
|
f: void 0,
|
|
708
771
|
b: void 0,
|
|
709
772
|
o: void 0
|
|
710
773
|
};
|
|
711
774
|
}
|
|
712
|
-
|
|
713
|
-
// src/core/utils/constructors.ts
|
|
714
|
-
function createRequestOptions(current, body) {
|
|
775
|
+
function createStreamConstructorNode(id, factory, sequence) {
|
|
715
776
|
return {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
777
|
+
t: 31 /* StreamConstructor */,
|
|
778
|
+
i: id,
|
|
779
|
+
s: void 0,
|
|
780
|
+
l: void 0,
|
|
781
|
+
c: void 0,
|
|
782
|
+
m: void 0,
|
|
783
|
+
p: void 0,
|
|
784
|
+
e: void 0,
|
|
785
|
+
a: sequence,
|
|
786
|
+
f: factory,
|
|
787
|
+
b: void 0,
|
|
788
|
+
o: void 0
|
|
727
789
|
};
|
|
728
790
|
}
|
|
729
|
-
function
|
|
791
|
+
function createStreamNextNode(id, parsed) {
|
|
730
792
|
return {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
793
|
+
t: 32 /* StreamNext */,
|
|
794
|
+
i: id,
|
|
795
|
+
s: void 0,
|
|
796
|
+
l: void 0,
|
|
797
|
+
c: void 0,
|
|
798
|
+
m: void 0,
|
|
799
|
+
p: void 0,
|
|
800
|
+
e: void 0,
|
|
801
|
+
a: void 0,
|
|
802
|
+
f: parsed,
|
|
803
|
+
b: void 0,
|
|
804
|
+
o: void 0
|
|
734
805
|
};
|
|
735
806
|
}
|
|
736
|
-
function
|
|
807
|
+
function createStreamThrowNode(id, parsed) {
|
|
737
808
|
return {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
809
|
+
t: 33 /* StreamThrow */,
|
|
810
|
+
i: id,
|
|
811
|
+
s: void 0,
|
|
812
|
+
l: void 0,
|
|
813
|
+
c: void 0,
|
|
814
|
+
m: void 0,
|
|
815
|
+
p: void 0,
|
|
816
|
+
e: void 0,
|
|
817
|
+
a: void 0,
|
|
818
|
+
f: parsed,
|
|
819
|
+
b: void 0,
|
|
820
|
+
o: void 0
|
|
741
821
|
};
|
|
742
822
|
}
|
|
743
|
-
function
|
|
823
|
+
function createStreamReturnNode(id, parsed) {
|
|
744
824
|
return {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
825
|
+
t: 34 /* StreamReturn */,
|
|
826
|
+
i: id,
|
|
827
|
+
s: void 0,
|
|
828
|
+
l: void 0,
|
|
829
|
+
c: void 0,
|
|
830
|
+
m: void 0,
|
|
831
|
+
p: void 0,
|
|
832
|
+
e: void 0,
|
|
833
|
+
a: void 0,
|
|
834
|
+
f: parsed,
|
|
835
|
+
b: void 0,
|
|
836
|
+
o: void 0
|
|
749
837
|
};
|
|
750
838
|
}
|
|
751
839
|
|
|
@@ -801,163 +889,16 @@ function sequenceToIterator(sequence) {
|
|
|
801
889
|
};
|
|
802
890
|
};
|
|
803
891
|
}
|
|
804
|
-
async function asyncIteratorToSequence(source) {
|
|
805
|
-
const values = [];
|
|
806
|
-
let throwsAt = -1;
|
|
807
|
-
let doneAt = -1;
|
|
808
|
-
const iterator = source[Symbol.asyncIterator]();
|
|
809
|
-
while (true) {
|
|
810
|
-
try {
|
|
811
|
-
const value = await iterator.next();
|
|
812
|
-
values.push(value.value);
|
|
813
|
-
if (value.done) {
|
|
814
|
-
doneAt = values.length - 1;
|
|
815
|
-
break;
|
|
816
|
-
}
|
|
817
|
-
} catch (error) {
|
|
818
|
-
throwsAt = values.length;
|
|
819
|
-
values.push(error);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
return {
|
|
823
|
-
v: values,
|
|
824
|
-
t: throwsAt,
|
|
825
|
-
d: doneAt
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
function sequenceToAsyncIterator(sequence) {
|
|
829
|
-
return () => {
|
|
830
|
-
let index = 0;
|
|
831
|
-
return {
|
|
832
|
-
[Symbol.asyncIterator]() {
|
|
833
|
-
return this;
|
|
834
|
-
},
|
|
835
|
-
async next() {
|
|
836
|
-
if (index > sequence.d) {
|
|
837
|
-
return {
|
|
838
|
-
done: true,
|
|
839
|
-
value: void 0
|
|
840
|
-
};
|
|
841
|
-
}
|
|
842
|
-
const currentIndex = index++;
|
|
843
|
-
const currentItem = sequence.v[currentIndex];
|
|
844
|
-
if (currentIndex === sequence.t) {
|
|
845
|
-
throw currentItem;
|
|
846
|
-
}
|
|
847
|
-
return Promise.resolve({
|
|
848
|
-
done: currentIndex === sequence.d,
|
|
849
|
-
value: currentItem
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
};
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
function asyncIteratorToReadableStream(source, parser) {
|
|
856
|
-
return new ReadableStream({
|
|
857
|
-
async start(controller) {
|
|
858
|
-
const iterator = source[Symbol.asyncIterator]();
|
|
859
|
-
while (parser.isAlive()) {
|
|
860
|
-
try {
|
|
861
|
-
const result = await iterator.next();
|
|
862
|
-
controller.enqueue([result.done ? 2 : 0, result.value]);
|
|
863
|
-
if (result.done) {
|
|
864
|
-
controller.close();
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
} catch (error) {
|
|
868
|
-
controller.enqueue([1, error]);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
controller.close();
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
}
|
|
875
|
-
function readableStreamToAsyncIterator(source) {
|
|
876
|
-
let current = source;
|
|
877
|
-
return () => {
|
|
878
|
-
const [left, right] = current.tee();
|
|
879
|
-
const clone = left;
|
|
880
|
-
current = right;
|
|
881
|
-
const reader = clone.getReader();
|
|
882
|
-
return {
|
|
883
|
-
[Symbol.asyncIterator]() {
|
|
884
|
-
return this;
|
|
885
|
-
},
|
|
886
|
-
async next() {
|
|
887
|
-
const result = await reader.read();
|
|
888
|
-
if (result.done) {
|
|
889
|
-
return {
|
|
890
|
-
done: true,
|
|
891
|
-
value: void 0
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
const [status, value] = result.value;
|
|
895
|
-
if (status === 1) {
|
|
896
|
-
throw value;
|
|
897
|
-
}
|
|
898
|
-
return {
|
|
899
|
-
done: status === 2,
|
|
900
|
-
value
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
async function readableStreamToSequence(stream) {
|
|
907
|
-
const values = [];
|
|
908
|
-
let throwsAt = -1;
|
|
909
|
-
let doneAt = -1;
|
|
910
|
-
const iterator = stream.getReader();
|
|
911
|
-
while (true) {
|
|
912
|
-
try {
|
|
913
|
-
const value = await iterator.read();
|
|
914
|
-
values.push(value.value);
|
|
915
|
-
if (value.done) {
|
|
916
|
-
doneAt = values.length - 1;
|
|
917
|
-
break;
|
|
918
|
-
}
|
|
919
|
-
} catch (error) {
|
|
920
|
-
throwsAt = values.length;
|
|
921
|
-
doneAt = throwsAt;
|
|
922
|
-
values.push(error);
|
|
923
|
-
break;
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
return {
|
|
927
|
-
v: values,
|
|
928
|
-
t: throwsAt,
|
|
929
|
-
d: doneAt
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
function sequenceToReadableStream(sequence) {
|
|
933
|
-
return new ReadableStream({
|
|
934
|
-
start(controller) {
|
|
935
|
-
for (let i = 0; i < sequence.d; i++) {
|
|
936
|
-
controller.enqueue(sequence.v[i]);
|
|
937
|
-
}
|
|
938
|
-
if (sequence.t === -1) {
|
|
939
|
-
controller.close();
|
|
940
|
-
} else {
|
|
941
|
-
controller.error(sequence.v[sequence.t]);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
892
|
|
|
947
893
|
// src/core/special-reference.ts
|
|
948
|
-
var UNIVERSAL_SENTINEL = {};
|
|
949
894
|
var ITERATOR = {};
|
|
950
895
|
var ASYNC_ITERATOR = {};
|
|
951
896
|
var SPECIAL_REFS = {
|
|
952
897
|
[0 /* MapSentinel */]: {},
|
|
953
|
-
[1 /*
|
|
954
|
-
[2 /*
|
|
955
|
-
[3 /*
|
|
956
|
-
[4 /*
|
|
957
|
-
[5 /* ReadableStreamConstructor */]: {},
|
|
958
|
-
[6 /* ReadableStreamEnqueue */]: {},
|
|
959
|
-
[7 /* ReadableStreamError */]: {},
|
|
960
|
-
[8 /* ReadableStreamClose */]: {}
|
|
898
|
+
[1 /* PromiseConstructor */]: {},
|
|
899
|
+
[2 /* PromiseResolve */]: {},
|
|
900
|
+
[3 /* PromiseReject */]: {},
|
|
901
|
+
[4 /* StreamConstructor */]: {}
|
|
961
902
|
};
|
|
962
903
|
|
|
963
904
|
// src/core/context/parser.ts
|
|
@@ -974,62 +915,70 @@ var BaseParserContext = class {
|
|
|
974
915
|
isMarked(id) {
|
|
975
916
|
return this.marked.has(id);
|
|
976
917
|
}
|
|
977
|
-
|
|
978
|
-
const
|
|
979
|
-
if (
|
|
980
|
-
this.markRef(
|
|
981
|
-
return
|
|
918
|
+
getIndexedValue(current) {
|
|
919
|
+
const registeredId = this.refs.get(current);
|
|
920
|
+
if (registeredId != null) {
|
|
921
|
+
this.markRef(registeredId);
|
|
922
|
+
return {
|
|
923
|
+
type: 1,
|
|
924
|
+
value: createIndexedValueNode(registeredId)
|
|
925
|
+
};
|
|
982
926
|
}
|
|
983
927
|
const id = this.refs.size;
|
|
984
928
|
this.refs.set(current, id);
|
|
929
|
+
return {
|
|
930
|
+
type: 0,
|
|
931
|
+
value: id
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
getReference(current) {
|
|
935
|
+
const indexed = this.getIndexedValue(current);
|
|
936
|
+
if (indexed.type === 1) {
|
|
937
|
+
return indexed;
|
|
938
|
+
}
|
|
985
939
|
if (hasReferenceID(current)) {
|
|
986
|
-
return
|
|
940
|
+
return {
|
|
941
|
+
type: 2,
|
|
942
|
+
value: createReferenceNode(indexed.value, current)
|
|
943
|
+
};
|
|
987
944
|
}
|
|
988
|
-
return
|
|
945
|
+
return indexed;
|
|
989
946
|
}
|
|
990
947
|
getStrictReference(current) {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
948
|
+
assert(
|
|
949
|
+
hasReferenceID(current),
|
|
950
|
+
new Error(
|
|
951
|
+
"Cannot serialize " + typeof current + " without reference ID."
|
|
952
|
+
)
|
|
953
|
+
);
|
|
954
|
+
const result = this.getIndexedValue(current);
|
|
955
|
+
if (result.type === 1) {
|
|
956
|
+
return result.value;
|
|
995
957
|
}
|
|
996
|
-
|
|
997
|
-
this.refs.set(current, id);
|
|
998
|
-
return createReferenceNode(id, current);
|
|
958
|
+
return createReferenceNode(result.value, current);
|
|
999
959
|
}
|
|
1000
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1001
960
|
parseFunction(current) {
|
|
1002
|
-
assert(hasReferenceID(current), new Error("Cannot serialize function without reference ID."));
|
|
1003
961
|
return this.getStrictReference(current);
|
|
1004
962
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
this.markRef(registeredID);
|
|
1010
|
-
return createIndexedValueNode(registeredID);
|
|
1011
|
-
}
|
|
1012
|
-
const isValid = current in INV_SYMBOL_REF;
|
|
1013
|
-
assert(current in INV_SYMBOL_REF || hasReferenceID(current), new Error("Cannot serialize symbol without reference ID."));
|
|
1014
|
-
const id = this.refs.size;
|
|
1015
|
-
this.refs.set(current, id);
|
|
1016
|
-
if (isValid) {
|
|
1017
|
-
return createWKSymbolNode(id, current);
|
|
963
|
+
parseWellKnownSymbol(current) {
|
|
964
|
+
const ref = this.getReference(current);
|
|
965
|
+
if (ref.type !== 0) {
|
|
966
|
+
return ref.value;
|
|
1018
967
|
}
|
|
1019
|
-
|
|
968
|
+
assert(
|
|
969
|
+
current in INV_SYMBOL_REF,
|
|
970
|
+
new Error("Cannot serialized unsupported symbol.")
|
|
971
|
+
);
|
|
972
|
+
return createWKSymbolNode(ref.value, current);
|
|
1020
973
|
}
|
|
1021
974
|
parseSpecialReference(ref) {
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
this.markRef(registeredID);
|
|
1026
|
-
return createIndexedValueNode(registeredID);
|
|
975
|
+
const result = this.getIndexedValue(SPECIAL_REFS[ref]);
|
|
976
|
+
if (result.type === 1) {
|
|
977
|
+
return result.value;
|
|
1027
978
|
}
|
|
1028
|
-
const id = this.refs.size;
|
|
1029
|
-
this.refs.set(specialRef, id);
|
|
1030
979
|
return {
|
|
1031
|
-
t:
|
|
1032
|
-
i:
|
|
980
|
+
t: 26 /* SpecialReference */,
|
|
981
|
+
i: result.value,
|
|
1033
982
|
s: ref,
|
|
1034
983
|
l: void 0,
|
|
1035
984
|
c: void 0,
|
|
@@ -1043,16 +992,13 @@ var BaseParserContext = class {
|
|
|
1043
992
|
};
|
|
1044
993
|
}
|
|
1045
994
|
parseIteratorFactory() {
|
|
1046
|
-
const
|
|
1047
|
-
if (
|
|
1048
|
-
|
|
1049
|
-
return createIndexedValueNode(registeredID);
|
|
995
|
+
const result = this.getIndexedValue(ITERATOR);
|
|
996
|
+
if (result.type === 1) {
|
|
997
|
+
return result.value;
|
|
1050
998
|
}
|
|
1051
|
-
const id = this.refs.size;
|
|
1052
|
-
this.refs.set(ITERATOR, id);
|
|
1053
999
|
return {
|
|
1054
|
-
t:
|
|
1055
|
-
i:
|
|
1000
|
+
t: 27 /* IteratorFactory */,
|
|
1001
|
+
i: result.value,
|
|
1056
1002
|
s: void 0,
|
|
1057
1003
|
l: void 0,
|
|
1058
1004
|
c: void 0,
|
|
@@ -1060,30 +1006,30 @@ var BaseParserContext = class {
|
|
|
1060
1006
|
p: void 0,
|
|
1061
1007
|
e: void 0,
|
|
1062
1008
|
a: void 0,
|
|
1063
|
-
f: this.
|
|
1009
|
+
f: this.parseWellKnownSymbol(Symbol.iterator),
|
|
1064
1010
|
b: void 0,
|
|
1065
1011
|
o: void 0
|
|
1066
1012
|
};
|
|
1067
1013
|
}
|
|
1068
|
-
parseAsyncIteratorFactory(
|
|
1069
|
-
const
|
|
1070
|
-
if (
|
|
1071
|
-
|
|
1072
|
-
return createIndexedValueNode(registeredID);
|
|
1014
|
+
parseAsyncIteratorFactory() {
|
|
1015
|
+
const result = this.getIndexedValue(ASYNC_ITERATOR);
|
|
1016
|
+
if (result.type === 1) {
|
|
1017
|
+
return result.value;
|
|
1073
1018
|
}
|
|
1074
|
-
const id = this.refs.size;
|
|
1075
|
-
this.refs.set(ASYNC_ITERATOR, id);
|
|
1076
1019
|
return {
|
|
1077
|
-
t:
|
|
1078
|
-
i:
|
|
1079
|
-
s:
|
|
1020
|
+
t: 29 /* AsyncIteratorFactory */,
|
|
1021
|
+
i: result.value,
|
|
1022
|
+
s: void 0,
|
|
1080
1023
|
l: void 0,
|
|
1081
1024
|
c: void 0,
|
|
1082
1025
|
m: void 0,
|
|
1083
1026
|
p: void 0,
|
|
1084
1027
|
e: void 0,
|
|
1085
|
-
a:
|
|
1086
|
-
|
|
1028
|
+
a: [
|
|
1029
|
+
this.parseSpecialReference(1 /* PromiseConstructor */),
|
|
1030
|
+
this.parseWellKnownSymbol(Symbol.asyncIterator)
|
|
1031
|
+
],
|
|
1032
|
+
f: void 0,
|
|
1087
1033
|
b: void 0,
|
|
1088
1034
|
o: void 0
|
|
1089
1035
|
};
|
|
@@ -1131,104 +1077,189 @@ async function promiseToResult(current) {
|
|
|
1131
1077
|
}
|
|
1132
1078
|
}
|
|
1133
1079
|
|
|
1134
|
-
// src/core/
|
|
1135
|
-
function
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
i: id,
|
|
1139
|
-
s: serializeString(current.href),
|
|
1140
|
-
l: void 0,
|
|
1141
|
-
c: void 0,
|
|
1142
|
-
m: void 0,
|
|
1143
|
-
p: void 0,
|
|
1144
|
-
e: void 0,
|
|
1145
|
-
f: void 0,
|
|
1146
|
-
a: void 0,
|
|
1147
|
-
b: void 0,
|
|
1148
|
-
o: void 0
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
function createURLSearchParamsNode(id, current) {
|
|
1080
|
+
// src/core/utils/deferred.ts
|
|
1081
|
+
function createDeferred() {
|
|
1082
|
+
let resolve;
|
|
1083
|
+
let reject;
|
|
1152
1084
|
return {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
b: void 0,
|
|
1164
|
-
o: void 0
|
|
1085
|
+
promise: new Promise((res, rej) => {
|
|
1086
|
+
resolve = res;
|
|
1087
|
+
reject = rej;
|
|
1088
|
+
}),
|
|
1089
|
+
resolve(value) {
|
|
1090
|
+
resolve(value);
|
|
1091
|
+
},
|
|
1092
|
+
reject(value) {
|
|
1093
|
+
reject(value);
|
|
1094
|
+
}
|
|
1165
1095
|
};
|
|
1166
1096
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
s: serializeString(current.message),
|
|
1172
|
-
l: void 0,
|
|
1173
|
-
c: serializeString(current.name),
|
|
1174
|
-
m: void 0,
|
|
1175
|
-
p: void 0,
|
|
1176
|
-
e: void 0,
|
|
1177
|
-
a: void 0,
|
|
1178
|
-
f: void 0,
|
|
1179
|
-
b: void 0,
|
|
1180
|
-
o: void 0
|
|
1181
|
-
};
|
|
1097
|
+
|
|
1098
|
+
// src/core/stream.ts
|
|
1099
|
+
function isStream(value) {
|
|
1100
|
+
return "__SEROVAL_STREAM__" in value;
|
|
1182
1101
|
}
|
|
1183
|
-
function
|
|
1102
|
+
function createStream() {
|
|
1103
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1104
|
+
const buffer = [];
|
|
1105
|
+
let alive = true;
|
|
1106
|
+
let success = false;
|
|
1107
|
+
function flushNext(value) {
|
|
1108
|
+
for (const listener of listeners.keys()) {
|
|
1109
|
+
listener.next(value);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
function flushThrow(value) {
|
|
1113
|
+
for (const listener of listeners.keys()) {
|
|
1114
|
+
listener.throw(value);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
function flushReturn(value) {
|
|
1118
|
+
for (const listener of listeners.keys()) {
|
|
1119
|
+
listener.return(value);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1184
1122
|
return {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1123
|
+
__SEROVAL_STREAM__: true,
|
|
1124
|
+
on(listener) {
|
|
1125
|
+
if (alive) {
|
|
1126
|
+
listeners.add(listener);
|
|
1127
|
+
}
|
|
1128
|
+
for (let i = 0, len = buffer.length; i < len; i++) {
|
|
1129
|
+
const value = buffer[i];
|
|
1130
|
+
if (i === len - 1) {
|
|
1131
|
+
if (success) {
|
|
1132
|
+
listener.return(value);
|
|
1133
|
+
} else {
|
|
1134
|
+
listener.throw(value);
|
|
1135
|
+
}
|
|
1136
|
+
} else {
|
|
1137
|
+
listener.next(value);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return () => {
|
|
1141
|
+
if (alive) {
|
|
1142
|
+
listeners.delete(listener);
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
},
|
|
1146
|
+
next(value) {
|
|
1147
|
+
if (alive) {
|
|
1148
|
+
buffer.push(value);
|
|
1149
|
+
flushNext(value);
|
|
1150
|
+
}
|
|
1151
|
+
},
|
|
1152
|
+
throw(value) {
|
|
1153
|
+
if (alive) {
|
|
1154
|
+
buffer.push(value);
|
|
1155
|
+
flushThrow(value);
|
|
1156
|
+
alive = false;
|
|
1157
|
+
success = false;
|
|
1158
|
+
listeners.clear();
|
|
1159
|
+
}
|
|
1160
|
+
},
|
|
1161
|
+
return(value) {
|
|
1162
|
+
if (alive) {
|
|
1163
|
+
buffer.push(value);
|
|
1164
|
+
flushReturn(value);
|
|
1165
|
+
alive = false;
|
|
1166
|
+
success = true;
|
|
1167
|
+
listeners.clear();
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1197
1170
|
};
|
|
1198
1171
|
}
|
|
1199
|
-
function
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1172
|
+
function createStreamFromAsyncIterable(iterable) {
|
|
1173
|
+
const stream = createStream();
|
|
1174
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
1175
|
+
async function push() {
|
|
1176
|
+
try {
|
|
1177
|
+
const value = await iterator.next();
|
|
1178
|
+
if (value.done) {
|
|
1179
|
+
stream.return(value.value);
|
|
1180
|
+
} else {
|
|
1181
|
+
stream.next(value.value);
|
|
1182
|
+
await push();
|
|
1183
|
+
}
|
|
1184
|
+
} catch (error) {
|
|
1185
|
+
stream.throw(error);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
push().catch(() => {
|
|
1189
|
+
});
|
|
1190
|
+
return stream;
|
|
1214
1191
|
}
|
|
1215
|
-
function
|
|
1216
|
-
return {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1192
|
+
function streamToAsyncIterable(stream) {
|
|
1193
|
+
return () => {
|
|
1194
|
+
const buffer = [];
|
|
1195
|
+
const pending = [];
|
|
1196
|
+
let count = 0;
|
|
1197
|
+
let doneAt = -1;
|
|
1198
|
+
let isThrow = false;
|
|
1199
|
+
function resolveAll() {
|
|
1200
|
+
for (let i = 0, len = pending.length; i < len; i++) {
|
|
1201
|
+
pending[i].resolve({ done: true, value: void 0 });
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
stream.on({
|
|
1205
|
+
next(value) {
|
|
1206
|
+
const current = pending.shift();
|
|
1207
|
+
if (current) {
|
|
1208
|
+
current.resolve({ done: false, value });
|
|
1209
|
+
}
|
|
1210
|
+
buffer.push(value);
|
|
1211
|
+
},
|
|
1212
|
+
throw(value) {
|
|
1213
|
+
const current = pending.shift();
|
|
1214
|
+
if (current) {
|
|
1215
|
+
current.reject(value);
|
|
1216
|
+
}
|
|
1217
|
+
resolveAll();
|
|
1218
|
+
doneAt = buffer.length;
|
|
1219
|
+
buffer.push(value);
|
|
1220
|
+
isThrow = true;
|
|
1221
|
+
},
|
|
1222
|
+
return(value) {
|
|
1223
|
+
const current = pending.shift();
|
|
1224
|
+
if (current) {
|
|
1225
|
+
current.resolve({ done: true, value });
|
|
1226
|
+
}
|
|
1227
|
+
resolveAll();
|
|
1228
|
+
doneAt = buffer.length;
|
|
1229
|
+
buffer.push(value);
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
function finalize() {
|
|
1233
|
+
const current = count++;
|
|
1234
|
+
const value = buffer[current];
|
|
1235
|
+
if (current !== doneAt) {
|
|
1236
|
+
return { done: false, value };
|
|
1237
|
+
}
|
|
1238
|
+
if (isThrow) {
|
|
1239
|
+
throw value;
|
|
1240
|
+
}
|
|
1241
|
+
return { done: true, value };
|
|
1242
|
+
}
|
|
1243
|
+
return {
|
|
1244
|
+
[Symbol.asyncIterator]() {
|
|
1245
|
+
return this;
|
|
1246
|
+
},
|
|
1247
|
+
async next() {
|
|
1248
|
+
if (doneAt === -1) {
|
|
1249
|
+
const current = count++;
|
|
1250
|
+
if (current >= buffer.length) {
|
|
1251
|
+
const deferred = createDeferred();
|
|
1252
|
+
pending.push(deferred);
|
|
1253
|
+
return await deferred.promise;
|
|
1254
|
+
}
|
|
1255
|
+
return { done: false, value: buffer[current] };
|
|
1256
|
+
}
|
|
1257
|
+
if (count > doneAt) {
|
|
1258
|
+
return { done: true, value: void 0 };
|
|
1259
|
+
}
|
|
1260
|
+
return finalize();
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1232
1263
|
};
|
|
1233
1264
|
}
|
|
1234
1265
|
|
|
@@ -1243,257 +1274,115 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1243
1274
|
}
|
|
1244
1275
|
return nodes;
|
|
1245
1276
|
}
|
|
1246
|
-
async parseArray(id, current) {
|
|
1247
|
-
return createArrayNode(
|
|
1248
|
-
id,
|
|
1249
|
-
current,
|
|
1250
|
-
await this.parseItems(current)
|
|
1251
|
-
);
|
|
1252
|
-
}
|
|
1253
|
-
async parseProperties(properties) {
|
|
1254
|
-
const entries = Object.entries(properties);
|
|
1255
|
-
const keyNodes = [];
|
|
1256
|
-
const valueNodes = [];
|
|
1257
|
-
for (let i = 0, len = entries.length; i < len; i++) {
|
|
1258
|
-
keyNodes.push(serializeString(entries[i][0]));
|
|
1259
|
-
valueNodes.push(await this.parse(entries[i][1]));
|
|
1260
|
-
}
|
|
1261
|
-
if (this.features & 1024 /* Symbol */) {
|
|
1262
|
-
let symbol = Symbol.iterator;
|
|
1263
|
-
if (symbol in properties) {
|
|
1264
|
-
keyNodes.push(
|
|
1265
|
-
this.parseWKSymbol(symbol)
|
|
1266
|
-
);
|
|
1267
|
-
valueNodes.push(
|
|
1268
|
-
createIteratorFactoryInstanceNode(
|
|
1269
|
-
this.parseIteratorFactory(),
|
|
1270
|
-
await this.parse(
|
|
1271
|
-
iteratorToSequence(properties)
|
|
1272
|
-
)
|
|
1273
|
-
)
|
|
1274
|
-
);
|
|
1275
|
-
}
|
|
1276
|
-
symbol = Symbol.asyncIterator;
|
|
1277
|
-
if (symbol in properties) {
|
|
1278
|
-
keyNodes.push(
|
|
1279
|
-
this.parseWKSymbol(symbol)
|
|
1280
|
-
);
|
|
1281
|
-
valueNodes.push(
|
|
1282
|
-
createAsyncIteratorFactoryInstanceNode(
|
|
1283
|
-
this.parseAsyncIteratorFactory(0),
|
|
1284
|
-
await this.parse(
|
|
1285
|
-
await asyncIteratorToSequence(properties)
|
|
1286
|
-
)
|
|
1287
|
-
)
|
|
1288
|
-
);
|
|
1289
|
-
}
|
|
1290
|
-
symbol = Symbol.toStringTag;
|
|
1291
|
-
if (symbol in properties) {
|
|
1292
|
-
keyNodes.push(this.parseWKSymbol(symbol));
|
|
1293
|
-
valueNodes.push(createStringNode(properties[symbol]));
|
|
1294
|
-
}
|
|
1295
|
-
symbol = Symbol.isConcatSpreadable;
|
|
1296
|
-
if (symbol in properties) {
|
|
1297
|
-
keyNodes.push(this.parseWKSymbol(symbol));
|
|
1298
|
-
valueNodes.push(properties[symbol] ? TRUE_NODE : FALSE_NODE);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
return {
|
|
1302
|
-
k: keyNodes,
|
|
1303
|
-
v: valueNodes,
|
|
1304
|
-
s: keyNodes.length
|
|
1305
|
-
};
|
|
1306
|
-
}
|
|
1307
|
-
async parsePlainObject(id, current, empty) {
|
|
1308
|
-
return this.createObjectNode(
|
|
1309
|
-
id,
|
|
1310
|
-
current,
|
|
1311
|
-
empty,
|
|
1312
|
-
await this.parseProperties(current)
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
|
-
async parseBoxed(id, current) {
|
|
1316
|
-
return createBoxedNode(id, await this.parse(current.valueOf()));
|
|
1317
|
-
}
|
|
1318
|
-
async parseTypedArray(id, current) {
|
|
1319
|
-
return createTypedArrayNode(id, current, await this.parse(current.buffer));
|
|
1320
|
-
}
|
|
1321
|
-
async parseBigIntTypedArray(id, current) {
|
|
1322
|
-
return createBigIntTypedArrayNode(id, current, await this.parse(current.buffer));
|
|
1323
|
-
}
|
|
1324
|
-
async parseDataView(id, current) {
|
|
1325
|
-
return createDataViewNode(id, current, await this.parse(current.buffer));
|
|
1326
|
-
}
|
|
1327
|
-
async parseError(id, current) {
|
|
1328
|
-
const options = getErrorOptions(current, this.features);
|
|
1329
|
-
return createErrorNode(
|
|
1330
|
-
id,
|
|
1331
|
-
current,
|
|
1332
|
-
options ? await this.parseProperties(options) : void 0
|
|
1333
|
-
);
|
|
1334
|
-
}
|
|
1335
|
-
async parseAggregateError(id, current) {
|
|
1336
|
-
const options = getErrorOptions(current, this.features);
|
|
1337
|
-
return createAggregateErrorNode(
|
|
1338
|
-
id,
|
|
1339
|
-
current,
|
|
1340
|
-
options ? await this.parseProperties(options) : void 0
|
|
1341
|
-
);
|
|
1342
|
-
}
|
|
1343
|
-
async parseMap(id, current) {
|
|
1344
|
-
const keyNodes = [];
|
|
1345
|
-
const valueNodes = [];
|
|
1346
|
-
for (const [key, value] of current.entries()) {
|
|
1347
|
-
keyNodes.push(await this.parse(key));
|
|
1348
|
-
valueNodes.push(await this.parse(value));
|
|
1349
|
-
}
|
|
1350
|
-
return this.createMapNode(
|
|
1351
|
-
id,
|
|
1352
|
-
keyNodes,
|
|
1353
|
-
valueNodes,
|
|
1354
|
-
current.size
|
|
1355
|
-
);
|
|
1356
|
-
}
|
|
1357
|
-
async parseSet(id, current) {
|
|
1358
|
-
const items = [];
|
|
1359
|
-
for (const item of current.keys()) {
|
|
1360
|
-
items.push(await this.parse(item));
|
|
1361
|
-
}
|
|
1362
|
-
return createSetNode(id, current.size, items);
|
|
1363
|
-
}
|
|
1364
|
-
async parseBlob(id, current) {
|
|
1365
|
-
return {
|
|
1366
|
-
t: 23 /* Blob */,
|
|
1367
|
-
i: id,
|
|
1368
|
-
s: void 0,
|
|
1369
|
-
l: void 0,
|
|
1370
|
-
c: serializeString(current.type),
|
|
1371
|
-
m: void 0,
|
|
1372
|
-
p: void 0,
|
|
1373
|
-
e: void 0,
|
|
1374
|
-
f: await this.parse(await current.arrayBuffer()),
|
|
1375
|
-
a: void 0,
|
|
1376
|
-
b: void 0,
|
|
1377
|
-
o: void 0
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
async parseFile(id, current) {
|
|
1381
|
-
return {
|
|
1382
|
-
t: 24 /* File */,
|
|
1383
|
-
i: id,
|
|
1384
|
-
s: void 0,
|
|
1385
|
-
l: void 0,
|
|
1386
|
-
c: serializeString(current.type),
|
|
1387
|
-
m: serializeString(current.name),
|
|
1388
|
-
p: void 0,
|
|
1389
|
-
e: void 0,
|
|
1390
|
-
f: await this.parse(await current.arrayBuffer()),
|
|
1391
|
-
a: void 0,
|
|
1392
|
-
b: current.lastModified,
|
|
1393
|
-
o: void 0
|
|
1394
|
-
};
|
|
1395
|
-
}
|
|
1396
|
-
async parsePlainProperties(entries) {
|
|
1397
|
-
const size = entries.length;
|
|
1398
|
-
const keyNodes = [];
|
|
1399
|
-
const valueNodes = [];
|
|
1400
|
-
for (let i = 0; i < size; i++) {
|
|
1401
|
-
keyNodes.push(serializeString(entries[i][0]));
|
|
1402
|
-
valueNodes.push(await this.parse(entries[i][1]));
|
|
1403
|
-
}
|
|
1404
|
-
return {
|
|
1405
|
-
k: keyNodes,
|
|
1406
|
-
v: valueNodes,
|
|
1407
|
-
s: size
|
|
1408
|
-
};
|
|
1409
|
-
}
|
|
1410
|
-
async parseHeaders(id, current) {
|
|
1411
|
-
const items = [];
|
|
1412
|
-
current.forEach((value, key) => {
|
|
1413
|
-
items.push([key, value]);
|
|
1414
|
-
});
|
|
1415
|
-
return {
|
|
1416
|
-
t: 25 /* Headers */,
|
|
1417
|
-
i: id,
|
|
1418
|
-
s: void 0,
|
|
1419
|
-
l: void 0,
|
|
1420
|
-
c: void 0,
|
|
1421
|
-
m: void 0,
|
|
1422
|
-
p: void 0,
|
|
1423
|
-
e: await this.parsePlainProperties(items),
|
|
1424
|
-
a: void 0,
|
|
1425
|
-
f: void 0,
|
|
1426
|
-
b: void 0,
|
|
1427
|
-
o: void 0
|
|
1428
|
-
};
|
|
1429
|
-
}
|
|
1430
|
-
async parseFormData(id, current) {
|
|
1431
|
-
const items = [];
|
|
1432
|
-
current.forEach((value, key) => {
|
|
1433
|
-
items.push([key, value]);
|
|
1434
|
-
});
|
|
1435
|
-
return {
|
|
1436
|
-
t: 26 /* FormData */,
|
|
1437
|
-
i: id,
|
|
1438
|
-
s: void 0,
|
|
1439
|
-
l: void 0,
|
|
1440
|
-
c: void 0,
|
|
1441
|
-
m: void 0,
|
|
1442
|
-
p: void 0,
|
|
1443
|
-
e: await this.parsePlainProperties(items),
|
|
1444
|
-
a: void 0,
|
|
1445
|
-
f: void 0,
|
|
1446
|
-
b: void 0,
|
|
1447
|
-
o: void 0
|
|
1448
|
-
};
|
|
1277
|
+
async parseArray(id, current) {
|
|
1278
|
+
return createArrayNode(id, current, await this.parseItems(current));
|
|
1449
1279
|
}
|
|
1450
|
-
async
|
|
1280
|
+
async parseProperties(properties) {
|
|
1281
|
+
const entries = Object.entries(properties);
|
|
1282
|
+
const keyNodes = [];
|
|
1283
|
+
const valueNodes = [];
|
|
1284
|
+
for (let i = 0, len = entries.length; i < len; i++) {
|
|
1285
|
+
keyNodes.push(serializeString(entries[i][0]));
|
|
1286
|
+
valueNodes.push(await this.parse(entries[i][1]));
|
|
1287
|
+
}
|
|
1288
|
+
let symbol = Symbol.iterator;
|
|
1289
|
+
if (symbol in properties) {
|
|
1290
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
1291
|
+
valueNodes.push(
|
|
1292
|
+
createIteratorFactoryInstanceNode(
|
|
1293
|
+
this.parseIteratorFactory(),
|
|
1294
|
+
await this.parse(
|
|
1295
|
+
iteratorToSequence(properties)
|
|
1296
|
+
)
|
|
1297
|
+
)
|
|
1298
|
+
);
|
|
1299
|
+
}
|
|
1300
|
+
symbol = Symbol.asyncIterator;
|
|
1301
|
+
if (symbol in properties) {
|
|
1302
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
1303
|
+
valueNodes.push(
|
|
1304
|
+
createAsyncIteratorFactoryInstanceNode(
|
|
1305
|
+
this.parseAsyncIteratorFactory(),
|
|
1306
|
+
await this.parse(
|
|
1307
|
+
createStreamFromAsyncIterable(
|
|
1308
|
+
properties
|
|
1309
|
+
)
|
|
1310
|
+
)
|
|
1311
|
+
)
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
symbol = Symbol.toStringTag;
|
|
1315
|
+
if (symbol in properties) {
|
|
1316
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
1317
|
+
valueNodes.push(createStringNode(properties[symbol]));
|
|
1318
|
+
}
|
|
1319
|
+
symbol = Symbol.isConcatSpreadable;
|
|
1320
|
+
if (symbol in properties) {
|
|
1321
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
1322
|
+
valueNodes.push(properties[symbol] ? TRUE_NODE : FALSE_NODE);
|
|
1323
|
+
}
|
|
1451
1324
|
return {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
s:
|
|
1455
|
-
l: void 0,
|
|
1456
|
-
c: void 0,
|
|
1457
|
-
m: void 0,
|
|
1458
|
-
p: void 0,
|
|
1459
|
-
e: void 0,
|
|
1460
|
-
f: await this.parse(
|
|
1461
|
-
createRequestOptions(current, current.body ? await current.clone().arrayBuffer() : null)
|
|
1462
|
-
),
|
|
1463
|
-
a: void 0,
|
|
1464
|
-
b: void 0,
|
|
1465
|
-
o: void 0
|
|
1325
|
+
k: keyNodes,
|
|
1326
|
+
v: valueNodes,
|
|
1327
|
+
s: keyNodes.length
|
|
1466
1328
|
};
|
|
1467
1329
|
}
|
|
1468
|
-
async
|
|
1469
|
-
return
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1330
|
+
async parsePlainObject(id, current, empty) {
|
|
1331
|
+
return this.createObjectNode(
|
|
1332
|
+
id,
|
|
1333
|
+
current,
|
|
1334
|
+
empty,
|
|
1335
|
+
await this.parseProperties(current)
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
async parseBoxed(id, current) {
|
|
1339
|
+
return createBoxedNode(id, await this.parse(current.valueOf()));
|
|
1340
|
+
}
|
|
1341
|
+
async parseTypedArray(id, current) {
|
|
1342
|
+
return createTypedArrayNode(id, current, await this.parse(current.buffer));
|
|
1343
|
+
}
|
|
1344
|
+
async parseBigIntTypedArray(id, current) {
|
|
1345
|
+
return createBigIntTypedArrayNode(
|
|
1346
|
+
id,
|
|
1347
|
+
current,
|
|
1348
|
+
await this.parse(current.buffer)
|
|
1349
|
+
);
|
|
1486
1350
|
}
|
|
1487
|
-
async
|
|
1488
|
-
return
|
|
1351
|
+
async parseDataView(id, current) {
|
|
1352
|
+
return createDataViewNode(id, current, await this.parse(current.buffer));
|
|
1353
|
+
}
|
|
1354
|
+
async parseError(id, current) {
|
|
1355
|
+
const options = getErrorOptions(current, this.features);
|
|
1356
|
+
return createErrorNode(
|
|
1357
|
+
id,
|
|
1358
|
+
current,
|
|
1359
|
+
options ? await this.parseProperties(options) : void 0
|
|
1360
|
+
);
|
|
1489
1361
|
}
|
|
1490
|
-
async
|
|
1491
|
-
|
|
1362
|
+
async parseAggregateError(id, current) {
|
|
1363
|
+
const options = getErrorOptions(current, this.features);
|
|
1364
|
+
return createAggregateErrorNode(
|
|
1492
1365
|
id,
|
|
1493
|
-
current
|
|
1494
|
-
await this.
|
|
1366
|
+
current,
|
|
1367
|
+
options ? await this.parseProperties(options) : void 0
|
|
1495
1368
|
);
|
|
1496
1369
|
}
|
|
1370
|
+
async parseMap(id, current) {
|
|
1371
|
+
const keyNodes = [];
|
|
1372
|
+
const valueNodes = [];
|
|
1373
|
+
for (const [key, value] of current.entries()) {
|
|
1374
|
+
keyNodes.push(await this.parse(key));
|
|
1375
|
+
valueNodes.push(await this.parse(value));
|
|
1376
|
+
}
|
|
1377
|
+
return this.createMapNode(id, keyNodes, valueNodes, current.size);
|
|
1378
|
+
}
|
|
1379
|
+
async parseSet(id, current) {
|
|
1380
|
+
const items = [];
|
|
1381
|
+
for (const item of current.keys()) {
|
|
1382
|
+
items.push(await this.parse(item));
|
|
1383
|
+
}
|
|
1384
|
+
return createSetNode(id, current.size, items);
|
|
1385
|
+
}
|
|
1497
1386
|
async parsePromise(id, current) {
|
|
1498
1387
|
const [status, result] = await promiseToResult(current);
|
|
1499
1388
|
return {
|
|
@@ -1529,19 +1418,68 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1529
1418
|
}
|
|
1530
1419
|
return void 0;
|
|
1531
1420
|
}
|
|
1532
|
-
async
|
|
1533
|
-
return
|
|
1421
|
+
async parseStream(id, current) {
|
|
1422
|
+
return createStreamConstructorNode(
|
|
1534
1423
|
id,
|
|
1535
|
-
this.parseSpecialReference(
|
|
1536
|
-
await
|
|
1537
|
-
|
|
1538
|
-
|
|
1424
|
+
this.parseSpecialReference(4 /* StreamConstructor */),
|
|
1425
|
+
await new Promise((resolve, reject) => {
|
|
1426
|
+
const sequence = [];
|
|
1427
|
+
const cleanup = current.on({
|
|
1428
|
+
next: (value) => {
|
|
1429
|
+
this.markRef(id);
|
|
1430
|
+
this.parse(value).then(
|
|
1431
|
+
(data) => {
|
|
1432
|
+
sequence.push(createStreamNextNode(id, data));
|
|
1433
|
+
},
|
|
1434
|
+
(data) => {
|
|
1435
|
+
reject(data);
|
|
1436
|
+
cleanup();
|
|
1437
|
+
}
|
|
1438
|
+
);
|
|
1439
|
+
},
|
|
1440
|
+
throw: (value) => {
|
|
1441
|
+
this.markRef(id);
|
|
1442
|
+
this.parse(value).then(
|
|
1443
|
+
(data) => {
|
|
1444
|
+
sequence.push(createStreamThrowNode(id, data));
|
|
1445
|
+
resolve(sequence);
|
|
1446
|
+
cleanup();
|
|
1447
|
+
},
|
|
1448
|
+
(data) => {
|
|
1449
|
+
reject(data);
|
|
1450
|
+
cleanup();
|
|
1451
|
+
}
|
|
1452
|
+
);
|
|
1453
|
+
},
|
|
1454
|
+
return: (value) => {
|
|
1455
|
+
this.markRef(id);
|
|
1456
|
+
this.parse(value).then(
|
|
1457
|
+
(data) => {
|
|
1458
|
+
sequence.push(createStreamReturnNode(id, data));
|
|
1459
|
+
resolve(sequence);
|
|
1460
|
+
cleanup();
|
|
1461
|
+
},
|
|
1462
|
+
(data) => {
|
|
1463
|
+
reject(data);
|
|
1464
|
+
cleanup();
|
|
1465
|
+
}
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
});
|
|
1469
|
+
})
|
|
1539
1470
|
);
|
|
1540
1471
|
}
|
|
1541
1472
|
async parseObject(id, current) {
|
|
1542
1473
|
if (Array.isArray(current)) {
|
|
1543
1474
|
return this.parseArray(id, current);
|
|
1544
1475
|
}
|
|
1476
|
+
if (isStream(current)) {
|
|
1477
|
+
return this.parseStream(id, current);
|
|
1478
|
+
}
|
|
1479
|
+
const parsed = await this.parsePlugin(id, current);
|
|
1480
|
+
if (parsed) {
|
|
1481
|
+
return parsed;
|
|
1482
|
+
}
|
|
1545
1483
|
const currentClass = current.constructor;
|
|
1546
1484
|
switch (currentClass) {
|
|
1547
1485
|
case Object:
|
|
@@ -1573,126 +1511,75 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1573
1511
|
case String:
|
|
1574
1512
|
case BigInt:
|
|
1575
1513
|
return this.parseBoxed(id, current);
|
|
1514
|
+
case ArrayBuffer:
|
|
1515
|
+
return createArrayBufferNode(id, current);
|
|
1516
|
+
case Int8Array:
|
|
1517
|
+
case Int16Array:
|
|
1518
|
+
case Int32Array:
|
|
1519
|
+
case Uint8Array:
|
|
1520
|
+
case Uint16Array:
|
|
1521
|
+
case Uint32Array:
|
|
1522
|
+
case Uint8ClampedArray:
|
|
1523
|
+
case Float32Array:
|
|
1524
|
+
case Float64Array:
|
|
1525
|
+
return this.parseTypedArray(id, current);
|
|
1526
|
+
case DataView:
|
|
1527
|
+
return this.parseDataView(id, current);
|
|
1528
|
+
case Map:
|
|
1529
|
+
return this.parseMap(id, current);
|
|
1530
|
+
case Set:
|
|
1531
|
+
return this.parseSet(id, current);
|
|
1576
1532
|
default:
|
|
1577
1533
|
break;
|
|
1578
1534
|
}
|
|
1579
|
-
|
|
1580
|
-
if (currentFeatures & 256 /* Promise */ && (currentClass === Promise || current instanceof Promise)) {
|
|
1535
|
+
if (currentClass === Promise || current instanceof Promise) {
|
|
1581
1536
|
return this.parsePromise(id, current);
|
|
1582
1537
|
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
case ArrayBuffer:
|
|
1586
|
-
return createArrayBufferNode(id, current);
|
|
1587
|
-
case Int8Array:
|
|
1588
|
-
case Int16Array:
|
|
1589
|
-
case Int32Array:
|
|
1590
|
-
case Uint8Array:
|
|
1591
|
-
case Uint16Array:
|
|
1592
|
-
case Uint32Array:
|
|
1593
|
-
case Uint8ClampedArray:
|
|
1594
|
-
case Float32Array:
|
|
1595
|
-
case Float64Array:
|
|
1596
|
-
return this.parseTypedArray(id, current);
|
|
1597
|
-
case DataView:
|
|
1598
|
-
return this.parseDataView(id, current);
|
|
1599
|
-
default:
|
|
1600
|
-
break;
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
if ((currentFeatures & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
1538
|
+
const currentFeatures = this.features;
|
|
1539
|
+
if (currentFeatures & 16 /* BigIntTypedArray */) {
|
|
1604
1540
|
switch (currentClass) {
|
|
1605
1541
|
case BigInt64Array:
|
|
1606
1542
|
case BigUint64Array:
|
|
1607
|
-
return this.parseBigIntTypedArray(
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
}
|
|
1612
|
-
if (currentFeatures & 32 /* Map */ && currentClass === Map) {
|
|
1613
|
-
return this.parseMap(
|
|
1614
|
-
id,
|
|
1615
|
-
current
|
|
1616
|
-
);
|
|
1617
|
-
}
|
|
1618
|
-
if (currentFeatures & 512 /* Set */ && currentClass === Set) {
|
|
1619
|
-
return this.parseSet(
|
|
1620
|
-
id,
|
|
1621
|
-
current
|
|
1622
|
-
);
|
|
1623
|
-
}
|
|
1624
|
-
if (currentFeatures & 8192 /* WebAPI */) {
|
|
1625
|
-
switch (currentClass) {
|
|
1626
|
-
case (typeof URL !== "undefined" ? URL : UNIVERSAL_SENTINEL):
|
|
1627
|
-
return createURLNode(id, current);
|
|
1628
|
-
case (typeof URLSearchParams !== "undefined" ? URLSearchParams : UNIVERSAL_SENTINEL):
|
|
1629
|
-
return createURLSearchParamsNode(id, current);
|
|
1630
|
-
case (typeof Blob !== "undefined" ? Blob : UNIVERSAL_SENTINEL):
|
|
1631
|
-
return this.parseBlob(id, current);
|
|
1632
|
-
case (typeof File !== "undefined" ? File : UNIVERSAL_SENTINEL):
|
|
1633
|
-
return this.parseFile(id, current);
|
|
1634
|
-
case (typeof Headers !== "undefined" ? Headers : UNIVERSAL_SENTINEL):
|
|
1635
|
-
return this.parseHeaders(id, current);
|
|
1636
|
-
case (typeof FormData !== "undefined" ? FormData : UNIVERSAL_SENTINEL):
|
|
1637
|
-
return this.parseFormData(id, current);
|
|
1638
|
-
case (typeof Request !== "undefined" ? Request : UNIVERSAL_SENTINEL):
|
|
1639
|
-
return this.parseRequest(id, current);
|
|
1640
|
-
case (typeof Response !== "undefined" ? Response : UNIVERSAL_SENTINEL):
|
|
1641
|
-
return this.parseResponse(id, current);
|
|
1642
|
-
case (typeof Event !== "undefined" ? Event : UNIVERSAL_SENTINEL):
|
|
1643
|
-
return this.parseEvent(id, current);
|
|
1644
|
-
case (typeof CustomEvent !== "undefined" ? CustomEvent : UNIVERSAL_SENTINEL):
|
|
1645
|
-
return this.parseCustomEvent(id, current);
|
|
1646
|
-
case (typeof DOMException !== "undefined" ? DOMException : UNIVERSAL_SENTINEL):
|
|
1647
|
-
return createDOMExceptionNode(id, current);
|
|
1648
|
-
case (typeof ReadableStream !== "undefined" ? ReadableStream : UNIVERSAL_SENTINEL):
|
|
1649
|
-
return this.parseReadableStream(id, current);
|
|
1543
|
+
return this.parseBigIntTypedArray(
|
|
1544
|
+
id,
|
|
1545
|
+
current
|
|
1546
|
+
);
|
|
1650
1547
|
default:
|
|
1651
1548
|
break;
|
|
1652
1549
|
}
|
|
1653
1550
|
}
|
|
1654
|
-
const parsed = await this.parsePlugin(id, current);
|
|
1655
|
-
if (parsed) {
|
|
1656
|
-
return parsed;
|
|
1657
|
-
}
|
|
1658
1551
|
if (currentFeatures & 1 /* AggregateError */ && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
1659
1552
|
return this.parseAggregateError(id, current);
|
|
1660
1553
|
}
|
|
1661
1554
|
if (current instanceof Error) {
|
|
1662
1555
|
return this.parseError(id, current);
|
|
1663
1556
|
}
|
|
1664
|
-
if (
|
|
1557
|
+
if (Symbol.iterator in current || Symbol.asyncIterator in current) {
|
|
1665
1558
|
return this.parsePlainObject(id, current, !!currentClass);
|
|
1666
1559
|
}
|
|
1667
1560
|
throw new UnsupportedTypeError(current);
|
|
1668
1561
|
}
|
|
1669
1562
|
async parse(current) {
|
|
1670
|
-
switch (current) {
|
|
1671
|
-
case true:
|
|
1672
|
-
return TRUE_NODE;
|
|
1673
|
-
case false:
|
|
1674
|
-
return FALSE_NODE;
|
|
1675
|
-
case void 0:
|
|
1676
|
-
return UNDEFINED_NODE;
|
|
1677
|
-
case null:
|
|
1678
|
-
return NULL_NODE;
|
|
1679
|
-
default:
|
|
1680
|
-
break;
|
|
1681
|
-
}
|
|
1682
1563
|
switch (typeof current) {
|
|
1564
|
+
case "boolean":
|
|
1565
|
+
return current ? TRUE_NODE : FALSE_NODE;
|
|
1566
|
+
case "undefined":
|
|
1567
|
+
return UNDEFINED_NODE;
|
|
1683
1568
|
case "string":
|
|
1684
1569
|
return createStringNode(current);
|
|
1685
1570
|
case "number":
|
|
1686
1571
|
return createNumberNode(current);
|
|
1687
1572
|
case "bigint":
|
|
1688
|
-
assert(this.features & 8 /* BigInt */, new UnsupportedTypeError(current));
|
|
1689
1573
|
return createBigIntNode(current);
|
|
1690
1574
|
case "object": {
|
|
1691
|
-
|
|
1692
|
-
|
|
1575
|
+
if (current) {
|
|
1576
|
+
const ref = this.getReference(current);
|
|
1577
|
+
return ref.type === 0 ? await this.parseObject(ref.value, current) : ref.value;
|
|
1578
|
+
}
|
|
1579
|
+
return NULL_NODE;
|
|
1693
1580
|
}
|
|
1694
1581
|
case "symbol":
|
|
1695
|
-
return this.
|
|
1582
|
+
return this.parseWellKnownSymbol(current);
|
|
1696
1583
|
case "function":
|
|
1697
1584
|
return this.parseFunction(current);
|
|
1698
1585
|
default:
|
|
@@ -1739,43 +1626,6 @@ function getTypedArrayConstructor(name) {
|
|
|
1739
1626
|
}
|
|
1740
1627
|
}
|
|
1741
1628
|
|
|
1742
|
-
// src/core/utils/deferred.ts
|
|
1743
|
-
function createDeferred() {
|
|
1744
|
-
let resolve;
|
|
1745
|
-
let reject;
|
|
1746
|
-
return {
|
|
1747
|
-
promise: new Promise((res, rej) => {
|
|
1748
|
-
resolve = res;
|
|
1749
|
-
reject = rej;
|
|
1750
|
-
}),
|
|
1751
|
-
resolve(value) {
|
|
1752
|
-
resolve(value);
|
|
1753
|
-
},
|
|
1754
|
-
reject(value) {
|
|
1755
|
-
reject(value);
|
|
1756
|
-
}
|
|
1757
|
-
};
|
|
1758
|
-
}
|
|
1759
|
-
function createDeferredStream() {
|
|
1760
|
-
let controller;
|
|
1761
|
-
return {
|
|
1762
|
-
stream: new ReadableStream({
|
|
1763
|
-
start(current) {
|
|
1764
|
-
controller = current;
|
|
1765
|
-
}
|
|
1766
|
-
}),
|
|
1767
|
-
close() {
|
|
1768
|
-
controller.close();
|
|
1769
|
-
},
|
|
1770
|
-
enqueue(data) {
|
|
1771
|
-
controller.enqueue(data);
|
|
1772
|
-
},
|
|
1773
|
-
error(e) {
|
|
1774
|
-
controller.error(e);
|
|
1775
|
-
}
|
|
1776
|
-
};
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
1629
|
// src/core/context/deserializer.ts
|
|
1780
1630
|
function applyObjectFlag(obj, flag) {
|
|
1781
1631
|
switch (flag) {
|
|
@@ -1795,7 +1645,10 @@ var BaseDeserializerContext = class {
|
|
|
1795
1645
|
this.refs = options.refs || /* @__PURE__ */ new Map();
|
|
1796
1646
|
}
|
|
1797
1647
|
deserializeReference(node) {
|
|
1798
|
-
return this.assignIndexedValue(
|
|
1648
|
+
return this.assignIndexedValue(
|
|
1649
|
+
node.i,
|
|
1650
|
+
getReference(deserializeString(node.s))
|
|
1651
|
+
);
|
|
1799
1652
|
}
|
|
1800
1653
|
deserializeArray(node) {
|
|
1801
1654
|
const len = node.l;
|
|
@@ -1842,7 +1695,10 @@ var BaseDeserializerContext = class {
|
|
|
1842
1695
|
return this.assignIndexedValue(node.i, new Date(node.s));
|
|
1843
1696
|
}
|
|
1844
1697
|
deserializeRegExp(node) {
|
|
1845
|
-
return this.assignIndexedValue(
|
|
1698
|
+
return this.assignIndexedValue(
|
|
1699
|
+
node.i,
|
|
1700
|
+
new RegExp(deserializeString(node.c), node.m)
|
|
1701
|
+
);
|
|
1846
1702
|
}
|
|
1847
1703
|
deserializeSet(node) {
|
|
1848
1704
|
const result = this.assignIndexedValue(node.i, /* @__PURE__ */ new Set());
|
|
@@ -1853,17 +1709,11 @@ var BaseDeserializerContext = class {
|
|
|
1853
1709
|
return result;
|
|
1854
1710
|
}
|
|
1855
1711
|
deserializeMap(node) {
|
|
1856
|
-
const result = this.assignIndexedValue(
|
|
1857
|
-
node.i,
|
|
1858
|
-
/* @__PURE__ */ new Map()
|
|
1859
|
-
);
|
|
1712
|
+
const result = this.assignIndexedValue(node.i, /* @__PURE__ */ new Map());
|
|
1860
1713
|
const keys = node.e.k;
|
|
1861
1714
|
const vals = node.e.v;
|
|
1862
1715
|
for (let i = 0, len = node.e.s; i < len; i++) {
|
|
1863
|
-
result.set(
|
|
1864
|
-
this.deserialize(keys[i]),
|
|
1865
|
-
this.deserialize(vals[i])
|
|
1866
|
-
);
|
|
1716
|
+
result.set(this.deserialize(keys[i]), this.deserialize(vals[i]));
|
|
1867
1717
|
}
|
|
1868
1718
|
return result;
|
|
1869
1719
|
}
|
|
@@ -1873,22 +1723,20 @@ var BaseDeserializerContext = class {
|
|
|
1873
1723
|
return result;
|
|
1874
1724
|
}
|
|
1875
1725
|
deserializeTypedArray(node) {
|
|
1876
|
-
const
|
|
1726
|
+
const construct = getTypedArrayConstructor(node.c);
|
|
1877
1727
|
const source = this.deserialize(node.f);
|
|
1878
|
-
const result = this.assignIndexedValue(
|
|
1879
|
-
|
|
1880
|
-
node.b,
|
|
1881
|
-
|
|
1882
|
-
));
|
|
1728
|
+
const result = this.assignIndexedValue(
|
|
1729
|
+
node.i,
|
|
1730
|
+
new construct(source, node.b, node.l)
|
|
1731
|
+
);
|
|
1883
1732
|
return result;
|
|
1884
1733
|
}
|
|
1885
1734
|
deserializeDataView(node) {
|
|
1886
1735
|
const source = this.deserialize(node.f);
|
|
1887
|
-
const result = this.assignIndexedValue(
|
|
1888
|
-
|
|
1889
|
-
node.b,
|
|
1890
|
-
|
|
1891
|
-
));
|
|
1736
|
+
const result = this.assignIndexedValue(
|
|
1737
|
+
node.i,
|
|
1738
|
+
new DataView(source, node.b, node.l)
|
|
1739
|
+
);
|
|
1892
1740
|
return result;
|
|
1893
1741
|
}
|
|
1894
1742
|
deserializeDictionary(node, result) {
|
|
@@ -1906,14 +1754,14 @@ var BaseDeserializerContext = class {
|
|
|
1906
1754
|
return this.deserializeDictionary(node, result);
|
|
1907
1755
|
}
|
|
1908
1756
|
deserializeError(node) {
|
|
1909
|
-
const
|
|
1757
|
+
const construct = ERROR_CONSTRUCTOR[node.s];
|
|
1910
1758
|
const result = this.assignIndexedValue(
|
|
1911
1759
|
node.i,
|
|
1912
|
-
new
|
|
1760
|
+
new construct(deserializeString(node.m))
|
|
1913
1761
|
);
|
|
1914
1762
|
return this.deserializeDictionary(node, result);
|
|
1915
1763
|
}
|
|
1916
|
-
|
|
1764
|
+
deserializePromise(node) {
|
|
1917
1765
|
const deferred = createDeferred();
|
|
1918
1766
|
const result = this.assignIndexedValue(node.i, deferred);
|
|
1919
1767
|
const deserialized = this.deserialize(node.f);
|
|
@@ -1924,107 +1772,16 @@ var BaseDeserializerContext = class {
|
|
|
1924
1772
|
}
|
|
1925
1773
|
return result.promise;
|
|
1926
1774
|
}
|
|
1927
|
-
deserializeURL(node) {
|
|
1928
|
-
return this.assignIndexedValue(node.i, new URL(deserializeString(node.s)));
|
|
1929
|
-
}
|
|
1930
|
-
deserializeURLSearchParams(node) {
|
|
1931
|
-
return this.assignIndexedValue(node.i, new URLSearchParams(deserializeString(node.s)));
|
|
1932
|
-
}
|
|
1933
|
-
deserializeBlob(node) {
|
|
1934
|
-
const source = this.deserialize(node.f);
|
|
1935
|
-
const result = this.assignIndexedValue(node.i, new Blob(
|
|
1936
|
-
[source],
|
|
1937
|
-
{ type: deserializeString(node.c) }
|
|
1938
|
-
));
|
|
1939
|
-
return result;
|
|
1940
|
-
}
|
|
1941
|
-
deserializeFile(node) {
|
|
1942
|
-
const source = this.deserialize(node.f);
|
|
1943
|
-
const result = this.assignIndexedValue(node.i, new File(
|
|
1944
|
-
[source],
|
|
1945
|
-
deserializeString(node.m),
|
|
1946
|
-
{ type: deserializeString(node.c), lastModified: node.b }
|
|
1947
|
-
));
|
|
1948
|
-
return result;
|
|
1949
|
-
}
|
|
1950
|
-
deserializeHeaders(node) {
|
|
1951
|
-
const result = this.assignIndexedValue(node.i, new Headers());
|
|
1952
|
-
const keys = node.e.k;
|
|
1953
|
-
const vals = node.e.v;
|
|
1954
|
-
for (let i = 0, len = node.e.s; i < len; i++) {
|
|
1955
|
-
result.set(
|
|
1956
|
-
deserializeString(keys[i]),
|
|
1957
|
-
this.deserialize(vals[i])
|
|
1958
|
-
);
|
|
1959
|
-
}
|
|
1960
|
-
return result;
|
|
1961
|
-
}
|
|
1962
|
-
deserializeFormData(node) {
|
|
1963
|
-
const result = this.assignIndexedValue(node.i, new FormData());
|
|
1964
|
-
const keys = node.e.k;
|
|
1965
|
-
const vals = node.e.v;
|
|
1966
|
-
for (let i = 0, len = node.e.s; i < len; i++) {
|
|
1967
|
-
result.set(
|
|
1968
|
-
deserializeString(keys[i]),
|
|
1969
|
-
this.deserialize(vals[i])
|
|
1970
|
-
);
|
|
1971
|
-
}
|
|
1972
|
-
return result;
|
|
1973
|
-
}
|
|
1974
1775
|
deserializeBoxed(node) {
|
|
1975
|
-
return this.assignIndexedValue(
|
|
1976
|
-
node.i,
|
|
1977
|
-
Object(this.deserialize(node.f))
|
|
1978
|
-
);
|
|
1979
|
-
}
|
|
1980
|
-
deserializeRequest(node) {
|
|
1981
|
-
return this.assignIndexedValue(
|
|
1982
|
-
node.i,
|
|
1983
|
-
new Request(deserializeString(node.s), this.deserialize(node.f))
|
|
1984
|
-
);
|
|
1985
|
-
}
|
|
1986
|
-
deserializeResponse(node) {
|
|
1987
|
-
return this.assignIndexedValue(
|
|
1988
|
-
node.i,
|
|
1989
|
-
new Response(
|
|
1990
|
-
this.deserialize(node.a[0]),
|
|
1991
|
-
this.deserialize(node.a[1])
|
|
1992
|
-
)
|
|
1993
|
-
);
|
|
1994
|
-
}
|
|
1995
|
-
deserializeEvent(node) {
|
|
1996
|
-
return this.assignIndexedValue(
|
|
1997
|
-
node.i,
|
|
1998
|
-
new Event(
|
|
1999
|
-
deserializeString(node.s),
|
|
2000
|
-
this.deserialize(node.f)
|
|
2001
|
-
)
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
deserializeCustomEvent(node) {
|
|
2005
|
-
return this.assignIndexedValue(
|
|
2006
|
-
node.i,
|
|
2007
|
-
new CustomEvent(
|
|
2008
|
-
deserializeString(node.s),
|
|
2009
|
-
this.deserialize(node.f)
|
|
2010
|
-
)
|
|
2011
|
-
);
|
|
2012
|
-
}
|
|
2013
|
-
deserializeDOMException(node) {
|
|
2014
|
-
return this.assignIndexedValue(
|
|
2015
|
-
node.i,
|
|
2016
|
-
new DOMException(
|
|
2017
|
-
deserializeString(node.s),
|
|
2018
|
-
deserializeString(node.c)
|
|
2019
|
-
)
|
|
2020
|
-
);
|
|
1776
|
+
return this.assignIndexedValue(node.i, Object(this.deserialize(node.f)));
|
|
2021
1777
|
}
|
|
2022
1778
|
deserializePlugin(node) {
|
|
2023
1779
|
const currentPlugins = this.plugins;
|
|
2024
1780
|
if (currentPlugins) {
|
|
1781
|
+
const tag = deserializeString(node.c);
|
|
2025
1782
|
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
2026
1783
|
const plugin = currentPlugins[i];
|
|
2027
|
-
if (plugin.tag ===
|
|
1784
|
+
if (plugin.tag === tag) {
|
|
2028
1785
|
return this.assignIndexedValue(
|
|
2029
1786
|
node.i,
|
|
2030
1787
|
plugin.deserialize(node.s, this, {
|
|
@@ -2037,75 +1794,65 @@ var BaseDeserializerContext = class {
|
|
|
2037
1794
|
throw new Error('Missing plugin for tag "' + node.c + '".');
|
|
2038
1795
|
}
|
|
2039
1796
|
deserializePromiseConstructor(node) {
|
|
2040
|
-
return this.assignIndexedValue(
|
|
2041
|
-
node.i,
|
|
2042
|
-
createDeferred()
|
|
2043
|
-
).promise;
|
|
1797
|
+
return this.assignIndexedValue(node.i, createDeferred()).promise;
|
|
2044
1798
|
}
|
|
2045
1799
|
deserializePromiseResolve(node) {
|
|
2046
1800
|
const deferred = this.refs.get(node.i);
|
|
2047
1801
|
assert(deferred, new Error("Missing Promise instance."));
|
|
2048
|
-
deferred.resolve(
|
|
2049
|
-
this.deserialize(node.a[1])
|
|
2050
|
-
);
|
|
1802
|
+
deferred.resolve(this.deserialize(node.a[1]));
|
|
2051
1803
|
return void 0;
|
|
2052
1804
|
}
|
|
2053
1805
|
deserializePromiseReject(node) {
|
|
2054
1806
|
const deferred = this.refs.get(node.i);
|
|
2055
1807
|
assert(deferred, new Error("Missing Promise instance."));
|
|
2056
|
-
deferred.reject(
|
|
2057
|
-
this.deserialize(node.a[1])
|
|
2058
|
-
);
|
|
1808
|
+
deferred.reject(this.deserialize(node.a[1]));
|
|
2059
1809
|
return void 0;
|
|
2060
1810
|
}
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
).stream;
|
|
1811
|
+
deserializeIteratorFactoryInstance(node) {
|
|
1812
|
+
this.deserialize(node.a[0]);
|
|
1813
|
+
const source = this.deserialize(node.a[1]);
|
|
1814
|
+
return sequenceToIterator(source);
|
|
2066
1815
|
}
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
1816
|
+
deserializeAsyncIteratorFactoryInstance(node) {
|
|
1817
|
+
this.deserialize(node.a[0]);
|
|
1818
|
+
const source = this.deserialize(node.a[1]);
|
|
1819
|
+
return streamToAsyncIterable(source);
|
|
1820
|
+
}
|
|
1821
|
+
deserializeStreamConstructor(node) {
|
|
1822
|
+
const result = this.assignIndexedValue(node.i, createStream());
|
|
1823
|
+
const len = node.a.length;
|
|
1824
|
+
if (len) {
|
|
1825
|
+
for (let i = 0; i < len; i++) {
|
|
1826
|
+
this.deserialize(node.a[i]);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
return result;
|
|
2074
1830
|
}
|
|
2075
|
-
|
|
1831
|
+
deserializeStreamNext(node) {
|
|
2076
1832
|
const deferred = this.refs.get(node.i);
|
|
2077
|
-
assert(deferred, new Error("Missing
|
|
2078
|
-
deferred.
|
|
2079
|
-
this.deserialize(node.a[1])
|
|
2080
|
-
);
|
|
1833
|
+
assert(deferred, new Error("Missing Stream instance."));
|
|
1834
|
+
deferred.next(this.deserialize(node.f));
|
|
2081
1835
|
return void 0;
|
|
2082
1836
|
}
|
|
2083
|
-
|
|
1837
|
+
deserializeStreamThrow(node) {
|
|
2084
1838
|
const deferred = this.refs.get(node.i);
|
|
2085
|
-
assert(deferred, new Error("Missing
|
|
2086
|
-
deferred.
|
|
1839
|
+
assert(deferred, new Error("Missing Stream instance."));
|
|
1840
|
+
deferred.throw(this.deserialize(node.f));
|
|
2087
1841
|
return void 0;
|
|
2088
1842
|
}
|
|
2089
|
-
|
|
2090
|
-
const
|
|
2091
|
-
|
|
1843
|
+
deserializeStreamReturn(node) {
|
|
1844
|
+
const deferred = this.refs.get(node.i);
|
|
1845
|
+
assert(deferred, new Error("Missing Stream instance."));
|
|
1846
|
+
deferred.return(this.deserialize(node.f));
|
|
1847
|
+
return void 0;
|
|
2092
1848
|
}
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
return readableStreamToAsyncIterator(
|
|
2097
|
-
source
|
|
2098
|
-
);
|
|
2099
|
-
}
|
|
2100
|
-
return sequenceToAsyncIterator(source);
|
|
1849
|
+
deserializeIteratorFactory(node) {
|
|
1850
|
+
this.deserialize(node.f);
|
|
1851
|
+
return void 0;
|
|
2101
1852
|
}
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
sequenceToReadableStream(
|
|
2106
|
-
this.deserialize(node.a[1])
|
|
2107
|
-
)
|
|
2108
|
-
);
|
|
1853
|
+
deserializeAsyncIteratorFactory(node) {
|
|
1854
|
+
this.deserialize(node.a[1]);
|
|
1855
|
+
return void 0;
|
|
2109
1856
|
}
|
|
2110
1857
|
deserialize(node) {
|
|
2111
1858
|
switch (node.t) {
|
|
@@ -2119,7 +1866,7 @@ var BaseDeserializerContext = class {
|
|
|
2119
1866
|
return BigInt(node.s);
|
|
2120
1867
|
case 4 /* IndexedValue */:
|
|
2121
1868
|
return this.refs.get(node.i);
|
|
2122
|
-
case
|
|
1869
|
+
case 18 /* Reference */:
|
|
2123
1870
|
return this.deserializeReference(node);
|
|
2124
1871
|
case 9 /* Array */:
|
|
2125
1872
|
return this.deserializeArray(node);
|
|
@@ -2134,12 +1881,12 @@ var BaseDeserializerContext = class {
|
|
|
2134
1881
|
return this.deserializeSet(node);
|
|
2135
1882
|
case 8 /* Map */:
|
|
2136
1883
|
return this.deserializeMap(node);
|
|
2137
|
-
case
|
|
1884
|
+
case 19 /* ArrayBuffer */:
|
|
2138
1885
|
return this.deserializeArrayBuffer(node);
|
|
2139
1886
|
case 16 /* BigIntTypedArray */:
|
|
2140
1887
|
case 15 /* TypedArray */:
|
|
2141
1888
|
return this.deserializeTypedArray(node);
|
|
2142
|
-
case
|
|
1889
|
+
case 20 /* DataView */:
|
|
2143
1890
|
return this.deserializeDataView(node);
|
|
2144
1891
|
case 14 /* AggregateError */:
|
|
2145
1892
|
return this.deserializeAggregateError(node);
|
|
@@ -2149,55 +1896,32 @@ var BaseDeserializerContext = class {
|
|
|
2149
1896
|
return this.deserializePromise(node);
|
|
2150
1897
|
case 17 /* WKSymbol */:
|
|
2151
1898
|
return SYMBOL_REF[node.s];
|
|
2152
|
-
case
|
|
2153
|
-
return this.deserializeURL(node);
|
|
2154
|
-
case 19 /* URLSearchParams */:
|
|
2155
|
-
return this.deserializeURLSearchParams(node);
|
|
2156
|
-
case 23 /* Blob */:
|
|
2157
|
-
return this.deserializeBlob(node);
|
|
2158
|
-
case 24 /* File */:
|
|
2159
|
-
return this.deserializeFile(node);
|
|
2160
|
-
case 25 /* Headers */:
|
|
2161
|
-
return this.deserializeHeaders(node);
|
|
2162
|
-
case 26 /* FormData */:
|
|
2163
|
-
return this.deserializeFormData(node);
|
|
2164
|
-
case 27 /* Boxed */:
|
|
1899
|
+
case 21 /* Boxed */:
|
|
2165
1900
|
return this.deserializeBoxed(node);
|
|
2166
|
-
case
|
|
2167
|
-
return this.deserializeRequest(node);
|
|
2168
|
-
case 36 /* Response */:
|
|
2169
|
-
return this.deserializeResponse(node);
|
|
2170
|
-
case 37 /* Event */:
|
|
2171
|
-
return this.deserializeEvent(node);
|
|
2172
|
-
case 38 /* CustomEvent */:
|
|
2173
|
-
return this.deserializeCustomEvent(node);
|
|
2174
|
-
case 39 /* DOMException */:
|
|
2175
|
-
return this.deserializeDOMException(node);
|
|
2176
|
-
case 40 /* Plugin */:
|
|
1901
|
+
case 25 /* Plugin */:
|
|
2177
1902
|
return this.deserializePlugin(node);
|
|
2178
|
-
case
|
|
1903
|
+
case 22 /* PromiseConstructor */:
|
|
2179
1904
|
return this.deserializePromiseConstructor(node);
|
|
2180
|
-
case
|
|
1905
|
+
case 23 /* PromiseResolve */:
|
|
2181
1906
|
return this.deserializePromiseResolve(node);
|
|
2182
|
-
case
|
|
1907
|
+
case 24 /* PromiseReject */:
|
|
2183
1908
|
return this.deserializePromiseReject(node);
|
|
2184
|
-
case
|
|
2185
|
-
return this.deserializeReadableStreamConstructor(node);
|
|
2186
|
-
case 32 /* ReadableStreamEnqueue */:
|
|
2187
|
-
return this.deserializeReadableStreamEnqueue(node);
|
|
2188
|
-
case 34 /* ReadableStreamError */:
|
|
2189
|
-
return this.deserializeReadableStreamError(node);
|
|
2190
|
-
case 33 /* ReadableStreamClose */:
|
|
2191
|
-
return this.deserializeReadableStreamClose(node);
|
|
2192
|
-
case 43 /* IteratorFactoryInstance */:
|
|
1909
|
+
case 28 /* IteratorFactoryInstance */:
|
|
2193
1910
|
return this.deserializeIteratorFactoryInstance(node);
|
|
2194
|
-
case
|
|
1911
|
+
case 30 /* AsyncIteratorFactoryInstance */:
|
|
2195
1912
|
return this.deserializeAsyncIteratorFactoryInstance(node);
|
|
2196
|
-
case
|
|
2197
|
-
return this.
|
|
2198
|
-
case
|
|
2199
|
-
|
|
2200
|
-
case
|
|
1913
|
+
case 31 /* StreamConstructor */:
|
|
1914
|
+
return this.deserializeStreamConstructor(node);
|
|
1915
|
+
case 32 /* StreamNext */:
|
|
1916
|
+
return this.deserializeStreamNext(node);
|
|
1917
|
+
case 33 /* StreamThrow */:
|
|
1918
|
+
return this.deserializeStreamThrow(node);
|
|
1919
|
+
case 34 /* StreamReturn */:
|
|
1920
|
+
return this.deserializeStreamReturn(node);
|
|
1921
|
+
case 27 /* IteratorFactory */:
|
|
1922
|
+
return this.deserializeIteratorFactory(node);
|
|
1923
|
+
case 29 /* AsyncIteratorFactory */:
|
|
1924
|
+
return this.deserializeAsyncIteratorFactory(node);
|
|
2201
1925
|
default:
|
|
2202
1926
|
throw new Error("invariant");
|
|
2203
1927
|
}
|
|
@@ -2207,10 +1931,7 @@ var BaseDeserializerContext = class {
|
|
|
2207
1931
|
// src/core/tree/deserializer.ts
|
|
2208
1932
|
var VanillaDeserializerContext = class extends BaseDeserializerContext {
|
|
2209
1933
|
constructor(options) {
|
|
2210
|
-
super(
|
|
2211
|
-
plugins: options.plugins,
|
|
2212
|
-
refs: void 0
|
|
2213
|
-
});
|
|
1934
|
+
super(options);
|
|
2214
1935
|
this.mode = "vanilla";
|
|
2215
1936
|
this.marked = new Set(options.markedRefs);
|
|
2216
1937
|
}
|
|
@@ -2330,14 +2051,14 @@ var BaseSerializerContext = class {
|
|
|
2330
2051
|
this.marked = new Set(options.markedRefs);
|
|
2331
2052
|
}
|
|
2332
2053
|
createFunction(parameters, body) {
|
|
2333
|
-
if (this.features &
|
|
2054
|
+
if (this.features & 2 /* ArrowFunction */) {
|
|
2334
2055
|
const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
|
|
2335
2056
|
return joined + "=>" + body;
|
|
2336
2057
|
}
|
|
2337
2058
|
return "function(" + parameters.join(",") + "){return " + body + "}";
|
|
2338
2059
|
}
|
|
2339
2060
|
createEffectfulFunction(parameters, body) {
|
|
2340
|
-
if (this.features &
|
|
2061
|
+
if (this.features & 2 /* ArrowFunction */) {
|
|
2341
2062
|
const joined = parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")";
|
|
2342
2063
|
return joined + "=>{" + body + "}";
|
|
2343
2064
|
}
|
|
@@ -2434,13 +2155,20 @@ var BaseSerializerContext = class {
|
|
|
2434
2155
|
return node.t === 4 /* IndexedValue */ && this.stack.includes(node.i);
|
|
2435
2156
|
}
|
|
2436
2157
|
serializeReference(node) {
|
|
2437
|
-
return this.assignIndexedValue(
|
|
2158
|
+
return this.assignIndexedValue(
|
|
2159
|
+
node.i,
|
|
2160
|
+
REFERENCES_KEY + '.get("' + node.s + '")'
|
|
2161
|
+
);
|
|
2438
2162
|
}
|
|
2439
2163
|
serializeArrayItem(id, item, index) {
|
|
2440
2164
|
if (item) {
|
|
2441
2165
|
if (this.isIndexedValueInStack(item)) {
|
|
2442
2166
|
this.markRef(id);
|
|
2443
|
-
this.createArrayAssign(
|
|
2167
|
+
this.createArrayAssign(
|
|
2168
|
+
id,
|
|
2169
|
+
index,
|
|
2170
|
+
this.getRefParam(item.i)
|
|
2171
|
+
);
|
|
2444
2172
|
return "";
|
|
2445
2173
|
}
|
|
2446
2174
|
return this.serialize(item);
|
|
@@ -2475,7 +2203,11 @@ var BaseSerializerContext = class {
|
|
|
2475
2203
|
if (isIdentifier && check !== check) {
|
|
2476
2204
|
this.createObjectAssign(source.i, key, refParam);
|
|
2477
2205
|
} else {
|
|
2478
|
-
this.createArrayAssign(
|
|
2206
|
+
this.createArrayAssign(
|
|
2207
|
+
source.i,
|
|
2208
|
+
isIdentifier ? key : '"' + key + '"',
|
|
2209
|
+
refParam
|
|
2210
|
+
);
|
|
2479
2211
|
}
|
|
2480
2212
|
return "";
|
|
2481
2213
|
}
|
|
@@ -2501,7 +2233,10 @@ var BaseSerializerContext = class {
|
|
|
2501
2233
|
}
|
|
2502
2234
|
serializeObject(node) {
|
|
2503
2235
|
this.pushObjectFlag(node.o, node.i);
|
|
2504
|
-
return this.assignIndexedValue(
|
|
2236
|
+
return this.assignIndexedValue(
|
|
2237
|
+
node.i,
|
|
2238
|
+
this.serializeProperties(node, node.p)
|
|
2239
|
+
);
|
|
2505
2240
|
}
|
|
2506
2241
|
serializeWithObjectAssign(source, value, serialized) {
|
|
2507
2242
|
const fields = this.serializeProperties(source, value);
|
|
@@ -2510,27 +2245,38 @@ var BaseSerializerContext = class {
|
|
|
2510
2245
|
}
|
|
2511
2246
|
return serialized;
|
|
2512
2247
|
}
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
if (
|
|
2519
|
-
|
|
2520
|
-
this.createObjectAssign(source.i, key, serialized);
|
|
2521
|
-
} else {
|
|
2522
|
-
this.createArrayAssign(source.i, isIdentifier ? key : '"' + key + '"', serialized);
|
|
2523
|
-
}
|
|
2248
|
+
serializeStringKeyAssignment(source, mainAssignments, key, value) {
|
|
2249
|
+
const serialized = this.serialize(value);
|
|
2250
|
+
const check = Number(key);
|
|
2251
|
+
const isIdentifier = check >= 0 || isValidIdentifier(key);
|
|
2252
|
+
if (this.isIndexedValueInStack(value)) {
|
|
2253
|
+
if (isIdentifier && check !== check) {
|
|
2254
|
+
this.createObjectAssign(source.i, key, serialized);
|
|
2524
2255
|
} else {
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2256
|
+
this.createArrayAssign(
|
|
2257
|
+
source.i,
|
|
2258
|
+
isIdentifier ? key : '"' + key + '"',
|
|
2259
|
+
serialized
|
|
2260
|
+
);
|
|
2261
|
+
}
|
|
2262
|
+
} else {
|
|
2263
|
+
const parentAssignment = this.assignments;
|
|
2264
|
+
this.assignments = mainAssignments;
|
|
2265
|
+
if (isIdentifier) {
|
|
2266
|
+
this.createObjectAssign(source.i, key, serialized);
|
|
2267
|
+
} else {
|
|
2268
|
+
this.createArrayAssign(
|
|
2269
|
+
source.i,
|
|
2270
|
+
isIdentifier ? key : '"' + key + '"',
|
|
2271
|
+
serialized
|
|
2272
|
+
);
|
|
2533
2273
|
}
|
|
2274
|
+
this.assignments = parentAssignment;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
serializeAssignment(source, mainAssignments, key, value) {
|
|
2278
|
+
if (typeof key === "string") {
|
|
2279
|
+
this.serializeStringKeyAssignment(source, mainAssignments, key, value);
|
|
2534
2280
|
} else {
|
|
2535
2281
|
const parent = this.stack;
|
|
2536
2282
|
this.stack = [];
|
|
@@ -2538,11 +2284,7 @@ var BaseSerializerContext = class {
|
|
|
2538
2284
|
this.stack = parent;
|
|
2539
2285
|
const parentAssignment = this.assignments;
|
|
2540
2286
|
this.assignments = mainAssignments;
|
|
2541
|
-
this.createArrayAssign(
|
|
2542
|
-
source.i,
|
|
2543
|
-
this.serialize(key),
|
|
2544
|
-
serialized
|
|
2545
|
-
);
|
|
2287
|
+
this.createArrayAssign(source.i, this.serialize(key), serialized);
|
|
2546
2288
|
this.assignments = parentAssignment;
|
|
2547
2289
|
}
|
|
2548
2290
|
}
|
|
@@ -2563,7 +2305,7 @@ var BaseSerializerContext = class {
|
|
|
2563
2305
|
}
|
|
2564
2306
|
serializeDictionary(node, init) {
|
|
2565
2307
|
if (node.p) {
|
|
2566
|
-
if (this.features &
|
|
2308
|
+
if (this.features & 8 /* ObjectAssign */) {
|
|
2567
2309
|
init = this.serializeWithObjectAssign(node, node.p, init);
|
|
2568
2310
|
} else {
|
|
2569
2311
|
this.markRef(node.i);
|
|
@@ -2588,7 +2330,10 @@ var BaseSerializerContext = class {
|
|
|
2588
2330
|
serializeSetItem(id, item) {
|
|
2589
2331
|
if (this.isIndexedValueInStack(item)) {
|
|
2590
2332
|
this.markRef(id);
|
|
2591
|
-
this.createAddAssignment(
|
|
2333
|
+
this.createAddAssignment(
|
|
2334
|
+
id,
|
|
2335
|
+
this.getRefParam(item.i)
|
|
2336
|
+
);
|
|
2592
2337
|
return "";
|
|
2593
2338
|
}
|
|
2594
2339
|
return this.serialize(item);
|
|
@@ -2655,14 +2400,14 @@ var BaseSerializerContext = class {
|
|
|
2655
2400
|
const size = node.e.s;
|
|
2656
2401
|
const id = node.i;
|
|
2657
2402
|
const sentinel = node.f;
|
|
2658
|
-
const
|
|
2403
|
+
const sentinelId = this.getRefParam(sentinel.i);
|
|
2659
2404
|
if (size) {
|
|
2660
2405
|
const keys = node.e.k;
|
|
2661
2406
|
const vals = node.e.v;
|
|
2662
2407
|
this.stack.push(id);
|
|
2663
|
-
let result = this.serializeMapEntry(id, keys[0], vals[0],
|
|
2408
|
+
let result = this.serializeMapEntry(id, keys[0], vals[0], sentinelId);
|
|
2664
2409
|
for (let i = 1, item = result; i < size; i++) {
|
|
2665
|
-
item = this.serializeMapEntry(id, keys[i], vals[i],
|
|
2410
|
+
item = this.serializeMapEntry(id, keys[i], vals[i], sentinelId);
|
|
2666
2411
|
result += (item && result && ",") + item;
|
|
2667
2412
|
}
|
|
2668
2413
|
this.stack.pop();
|
|
@@ -2670,7 +2415,7 @@ var BaseSerializerContext = class {
|
|
|
2670
2415
|
serialized += "([" + result + "])";
|
|
2671
2416
|
}
|
|
2672
2417
|
}
|
|
2673
|
-
if (sentinel.t ===
|
|
2418
|
+
if (sentinel.t === 26 /* SpecialReference */) {
|
|
2674
2419
|
this.markRef(sentinel.i);
|
|
2675
2420
|
serialized = "(" + this.serialize(sentinel) + "," + serialized + ")";
|
|
2676
2421
|
}
|
|
@@ -2709,108 +2454,37 @@ var BaseSerializerContext = class {
|
|
|
2709
2454
|
return this.serializeDictionary(node, serialized);
|
|
2710
2455
|
}
|
|
2711
2456
|
serializeError(node) {
|
|
2712
|
-
return this.serializeDictionary(
|
|
2457
|
+
return this.serializeDictionary(
|
|
2458
|
+
node,
|
|
2459
|
+
"new " + ERROR_CONSTRUCTOR_STRING[node.s] + '("' + node.m + '")'
|
|
2460
|
+
);
|
|
2713
2461
|
}
|
|
2714
2462
|
serializePromise(node) {
|
|
2715
2463
|
let serialized;
|
|
2716
2464
|
const fulfilled = node.f;
|
|
2717
2465
|
const id = node.i;
|
|
2718
|
-
const
|
|
2466
|
+
const promiseConstructor = node.s ? PROMISE_RESOLVE : PROMISE_REJECT;
|
|
2719
2467
|
if (this.isIndexedValueInStack(fulfilled)) {
|
|
2720
2468
|
const ref = this.getRefParam(fulfilled.i);
|
|
2721
|
-
serialized =
|
|
2469
|
+
serialized = promiseConstructor + (node.s ? "().then(" + this.createFunction([], ref) + ")" : "().catch(" + this.createEffectfulFunction([], "throw " + ref) + ")");
|
|
2722
2470
|
} else {
|
|
2723
2471
|
this.stack.push(id);
|
|
2724
2472
|
const result = this.serialize(fulfilled);
|
|
2725
2473
|
this.stack.pop();
|
|
2726
|
-
serialized =
|
|
2474
|
+
serialized = promiseConstructor + "(" + result + ")";
|
|
2727
2475
|
}
|
|
2728
2476
|
return this.assignIndexedValue(id, serialized);
|
|
2729
2477
|
}
|
|
2730
|
-
|
|
2478
|
+
serializeWellKnownSymbol(node) {
|
|
2731
2479
|
return this.assignIndexedValue(node.i, SYMBOL_STRING[node.s]);
|
|
2732
2480
|
}
|
|
2733
|
-
serializeURL(node) {
|
|
2734
|
-
return this.assignIndexedValue(node.i, 'new URL("' + node.s + '")');
|
|
2735
|
-
}
|
|
2736
|
-
serializeURLSearchParams(node) {
|
|
2737
|
-
return this.assignIndexedValue(
|
|
2738
|
-
node.i,
|
|
2739
|
-
node.s ? 'new URLSearchParams("' + node.s + '")' : "new URLSearchParams"
|
|
2740
|
-
);
|
|
2741
|
-
}
|
|
2742
|
-
serializeBlob(node) {
|
|
2743
|
-
return this.assignIndexedValue(
|
|
2744
|
-
node.i,
|
|
2745
|
-
"new Blob([" + this.serialize(node.f) + '],{type:"' + node.c + '"})'
|
|
2746
|
-
);
|
|
2747
|
-
}
|
|
2748
|
-
serializeFile(node) {
|
|
2749
|
-
return this.assignIndexedValue(
|
|
2750
|
-
node.i,
|
|
2751
|
-
"new File([" + this.serialize(node.f) + '],"' + node.m + '",{type:"' + node.c + '",lastModified:' + node.b + "})"
|
|
2752
|
-
);
|
|
2753
|
-
}
|
|
2754
|
-
serializeHeaders(node) {
|
|
2755
|
-
return this.assignIndexedValue(
|
|
2756
|
-
node.i,
|
|
2757
|
-
"new Headers(" + this.serializeProperties(node, node.e) + ")"
|
|
2758
|
-
);
|
|
2759
|
-
}
|
|
2760
2481
|
serializeFormDataEntry(id, key, value) {
|
|
2761
2482
|
return this.getRefParam(id) + '.append("' + key + '",' + this.serialize(value) + ")";
|
|
2762
2483
|
}
|
|
2763
|
-
serializeFormDataEntries(node, size) {
|
|
2764
|
-
const keys = node.e.k;
|
|
2765
|
-
const vals = node.e.v;
|
|
2766
|
-
const id = node.i;
|
|
2767
|
-
let result = this.serializeFormDataEntry(id, keys[0], vals[0]);
|
|
2768
|
-
for (let i = 1; i < size; i++) {
|
|
2769
|
-
result += "," + this.serializeFormDataEntry(id, keys[i], vals[i]);
|
|
2770
|
-
}
|
|
2771
|
-
return result;
|
|
2772
|
-
}
|
|
2773
|
-
serializeFormData(node) {
|
|
2774
|
-
const size = node.e.s;
|
|
2775
|
-
const id = node.i;
|
|
2776
|
-
if (size) {
|
|
2777
|
-
this.markRef(id);
|
|
2778
|
-
}
|
|
2779
|
-
const result = this.assignIndexedValue(id, "new FormData()");
|
|
2780
|
-
if (size) {
|
|
2781
|
-
const entries = this.serializeFormDataEntries(node, size);
|
|
2782
|
-
return "(" + result + "," + (entries ? entries + "," : "") + this.getRefParam(id) + ")";
|
|
2783
|
-
}
|
|
2784
|
-
return result;
|
|
2785
|
-
}
|
|
2786
2484
|
serializeBoxed(node) {
|
|
2787
|
-
return this.assignIndexedValue(node.i, "Object(" + this.serialize(node.f) + ")");
|
|
2788
|
-
}
|
|
2789
|
-
serializeRequest(node) {
|
|
2790
|
-
return this.assignIndexedValue(node.i, 'new Request("' + node.s + '",' + this.serialize(node.f) + ")");
|
|
2791
|
-
}
|
|
2792
|
-
serializeResponse(node) {
|
|
2793
|
-
return this.assignIndexedValue(
|
|
2794
|
-
node.i,
|
|
2795
|
-
"new Response(" + this.serialize(node.a[0]) + "," + this.serialize(node.a[1]) + ")"
|
|
2796
|
-
);
|
|
2797
|
-
}
|
|
2798
|
-
serializeEvent(node) {
|
|
2799
|
-
return this.assignIndexedValue(
|
|
2800
|
-
node.i,
|
|
2801
|
-
'new Event("' + node.s + '",' + this.serialize(node.f) + ")"
|
|
2802
|
-
);
|
|
2803
|
-
}
|
|
2804
|
-
serializeCustomEvent(node) {
|
|
2805
|
-
return this.assignIndexedValue(
|
|
2806
|
-
node.i,
|
|
2807
|
-
'new CustomEvent("' + node.s + '",' + this.serialize(node.f) + ")"
|
|
2808
|
-
);
|
|
2809
|
-
}
|
|
2810
|
-
serializeDOMException(node) {
|
|
2811
2485
|
return this.assignIndexedValue(
|
|
2812
2486
|
node.i,
|
|
2813
|
-
|
|
2487
|
+
"Object(" + this.serialize(node.f) + ")"
|
|
2814
2488
|
);
|
|
2815
2489
|
}
|
|
2816
2490
|
serializePlugin(node) {
|
|
@@ -2831,14 +2505,11 @@ var BaseSerializerContext = class {
|
|
|
2831
2505
|
throw new Error('Missing plugin for tag "' + node.c + '".');
|
|
2832
2506
|
}
|
|
2833
2507
|
getConstructor(node) {
|
|
2834
|
-
const
|
|
2835
|
-
return
|
|
2508
|
+
const current = this.serialize(node);
|
|
2509
|
+
return current === this.getRefParam(node.i) ? current : "(" + current + ")";
|
|
2836
2510
|
}
|
|
2837
2511
|
serializePromiseConstructor(node) {
|
|
2838
|
-
return this.assignIndexedValue(
|
|
2839
|
-
node.i,
|
|
2840
|
-
this.getConstructor(node.f) + "()"
|
|
2841
|
-
);
|
|
2512
|
+
return this.assignIndexedValue(node.i, this.getConstructor(node.f) + "()");
|
|
2842
2513
|
}
|
|
2843
2514
|
serializePromiseResolve(node) {
|
|
2844
2515
|
return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
|
|
@@ -2846,70 +2517,44 @@ var BaseSerializerContext = class {
|
|
|
2846
2517
|
serializePromiseReject(node) {
|
|
2847
2518
|
return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
|
|
2848
2519
|
}
|
|
2849
|
-
serializeReadableStreamConstructor(node) {
|
|
2850
|
-
return this.assignIndexedValue(
|
|
2851
|
-
node.i,
|
|
2852
|
-
this.getConstructor(node.f) + "()"
|
|
2853
|
-
);
|
|
2854
|
-
}
|
|
2855
|
-
serializeReadableStreamEnqueue(node) {
|
|
2856
|
-
return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
|
|
2857
|
-
}
|
|
2858
|
-
serializeReadableStreamError(node) {
|
|
2859
|
-
return this.getConstructor(node.a[0]) + "(" + this.getRefParam(node.i) + "," + this.serialize(node.a[1]) + ")";
|
|
2860
|
-
}
|
|
2861
|
-
serializeReadableStreamClose(node) {
|
|
2862
|
-
return this.getConstructor(node.f) + "(" + this.getRefParam(node.i) + ")";
|
|
2863
|
-
}
|
|
2864
2520
|
serializeSpecialReferenceValue(ref) {
|
|
2865
2521
|
switch (ref) {
|
|
2866
2522
|
case 0 /* MapSentinel */:
|
|
2867
2523
|
return "[]";
|
|
2868
|
-
case 1 /*
|
|
2869
|
-
return this.createFunction(
|
|
2870
|
-
["s"],
|
|
2871
|
-
"new ReadableStream({start:" + this.createFunction(
|
|
2872
|
-
["c"],
|
|
2873
|
-
"Promise.resolve().then(" + this.createEffectfulFunction(
|
|
2874
|
-
["i", "v"],
|
|
2875
|
-
"for(i=0;i<s.d;i++)c.enqueue(s.v[i]);(s.t===-1)?c.close():c.error(s.v[i])"
|
|
2876
|
-
) + ")"
|
|
2877
|
-
) + "})"
|
|
2878
|
-
);
|
|
2879
|
-
case 2 /* PromiseConstructor */:
|
|
2524
|
+
case 1 /* PromiseConstructor */:
|
|
2880
2525
|
return this.createFunction(
|
|
2881
2526
|
["s", "f", "p"],
|
|
2882
2527
|
"((p=new Promise(" + this.createEffectfulFunction(["a", "b"], "s=a,f=b") + ")).s=s,p.f=f,p)"
|
|
2883
2528
|
);
|
|
2884
|
-
case
|
|
2529
|
+
case 2 /* PromiseResolve */:
|
|
2885
2530
|
return this.createEffectfulFunction(
|
|
2886
2531
|
["p", "d"],
|
|
2887
2532
|
'p.s(d),p.status="success",p.value=d;delete p.s;delete p.f'
|
|
2888
2533
|
);
|
|
2889
|
-
case
|
|
2534
|
+
case 3 /* PromiseReject */:
|
|
2890
2535
|
return this.createEffectfulFunction(
|
|
2891
2536
|
["p", "d"],
|
|
2892
2537
|
'p.f(d),p.status="failure",p.value=d;delete p.s;delete p.f'
|
|
2893
2538
|
);
|
|
2894
|
-
case
|
|
2539
|
+
case 4 /* StreamConstructor */:
|
|
2895
2540
|
return this.createFunction(
|
|
2896
|
-
["s", "
|
|
2897
|
-
"(
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
["
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2541
|
+
["b", "a", "s", "l", "p", "f", "e", "n"],
|
|
2542
|
+
"(b=[],a=!0,s=!1,l=[],s=0,f=" + this.createEffectfulFunction(
|
|
2543
|
+
["v", "m", "x"],
|
|
2544
|
+
"for(x=0;x<s;x++)l[x]&&l[x][m](v)"
|
|
2545
|
+
) + ",n=" + this.createEffectfulFunction(
|
|
2546
|
+
["o", "x", "z", "c"],
|
|
2547
|
+
'for(x=0,z=b.length;x<z;x++)(c=b[x],x===z-1?o[s?"return":"throw"](c):o.next(c))'
|
|
2548
|
+
) + ",e=" + this.createFunction(
|
|
2549
|
+
["o", "t"],
|
|
2550
|
+
"(a&&(l[t=p++]=o),n(o)," + this.createEffectfulFunction([], "a&&(l[t]=void 0)") + ")"
|
|
2551
|
+
) + ",{__SEROVAL_STREAM__:!0,on:" + this.createFunction(["o"], "e(o)") + ",next:" + this.createEffectfulFunction(["v"], 'a&&(b.push(v),f(v,"next"))') + ",throw:" + this.createEffectfulFunction(
|
|
2552
|
+
["v"],
|
|
2553
|
+
'a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)'
|
|
2554
|
+
) + ",return:" + this.createEffectfulFunction(
|
|
2555
|
+
["v"],
|
|
2556
|
+
'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)'
|
|
2557
|
+
) + "})"
|
|
2913
2558
|
);
|
|
2914
2559
|
default:
|
|
2915
2560
|
return "";
|
|
@@ -2922,67 +2567,105 @@ var BaseSerializerContext = class {
|
|
|
2922
2567
|
);
|
|
2923
2568
|
}
|
|
2924
2569
|
serializeIteratorFactory(node) {
|
|
2925
|
-
|
|
2570
|
+
let result = "";
|
|
2571
|
+
let initialized = false;
|
|
2572
|
+
if (node.f.t !== 4 /* IndexedValue */) {
|
|
2573
|
+
this.markRef(node.f.i);
|
|
2574
|
+
result = "(" + this.serialize(node.f) + ",";
|
|
2575
|
+
initialized = true;
|
|
2576
|
+
}
|
|
2577
|
+
result += this.assignIndexedValue(
|
|
2926
2578
|
node.i,
|
|
2927
2579
|
this.createFunction(
|
|
2928
2580
|
["s"],
|
|
2929
2581
|
this.createFunction(
|
|
2930
2582
|
["i", "c", "d", "t"],
|
|
2931
|
-
"(i=0,t={[" + this.
|
|
2583
|
+
"(i=0,t={[" + this.getRefParam(node.f.i) + "]:" + this.createFunction([], "t") + ",next:" + this.createEffectfulFunction(
|
|
2584
|
+
[],
|
|
2585
|
+
"if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}"
|
|
2586
|
+
) + "})"
|
|
2932
2587
|
)
|
|
2933
2588
|
)
|
|
2934
2589
|
);
|
|
2590
|
+
if (initialized) {
|
|
2591
|
+
result += ")";
|
|
2592
|
+
}
|
|
2593
|
+
return result;
|
|
2935
2594
|
}
|
|
2936
2595
|
serializeIteratorFactoryInstance(node) {
|
|
2937
2596
|
return this.getConstructor(node.a[0]) + "(" + this.serialize(node.a[1]) + ")";
|
|
2938
2597
|
}
|
|
2939
|
-
getStreamingAsyncIteratorFactory(node) {
|
|
2940
|
-
return this.createFunction(
|
|
2941
|
-
["s"],
|
|
2942
|
-
this.createFunction(
|
|
2943
|
-
["b", "t"],
|
|
2944
|
-
"(b=s.tee(),s=b[0],b=b[1].getReader(),t={[" + this.serialize(node.f) + "]:" + this.createFunction([], "t") + ",next:" + this.createFunction(
|
|
2945
|
-
[],
|
|
2946
|
-
"b.read().then(" + this.createEffectfulFunction(
|
|
2947
|
-
["d"],
|
|
2948
|
-
"if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}"
|
|
2949
|
-
) + ")"
|
|
2950
|
-
) + "})"
|
|
2951
|
-
)
|
|
2952
|
-
);
|
|
2953
|
-
}
|
|
2954
|
-
getBlockingAsyncIteratorFactory(node) {
|
|
2955
|
-
return this.createFunction(
|
|
2956
|
-
["s"],
|
|
2957
|
-
this.createFunction(
|
|
2958
|
-
["i", "t"],
|
|
2959
|
-
"(i=0,t={[" + this.serialize(node.f) + "]:" + this.createFunction([], "t") + ",next:" + this.createFunction(
|
|
2960
|
-
[],
|
|
2961
|
-
"Promise.resolve().then(" + this.createEffectfulFunction(
|
|
2962
|
-
["c", "d"],
|
|
2963
|
-
"if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}"
|
|
2964
|
-
) + ")"
|
|
2965
|
-
) + "})"
|
|
2966
|
-
)
|
|
2967
|
-
);
|
|
2968
|
-
}
|
|
2969
2598
|
serializeAsyncIteratorFactory(node) {
|
|
2970
|
-
|
|
2599
|
+
const promise = node.a[0];
|
|
2600
|
+
const symbol = node.a[1];
|
|
2601
|
+
let result = "";
|
|
2602
|
+
if (promise.t !== 4 /* IndexedValue */) {
|
|
2603
|
+
this.markRef(promise.i);
|
|
2604
|
+
result += "(" + this.serialize(promise);
|
|
2605
|
+
}
|
|
2606
|
+
if (symbol.t !== 4 /* IndexedValue */) {
|
|
2607
|
+
this.markRef(symbol.i);
|
|
2608
|
+
result += (result ? "," : "(") + this.serialize(symbol);
|
|
2609
|
+
}
|
|
2610
|
+
if (result) {
|
|
2611
|
+
result += ",";
|
|
2612
|
+
}
|
|
2613
|
+
const iterator = this.assignIndexedValue(
|
|
2971
2614
|
node.i,
|
|
2972
|
-
|
|
2615
|
+
this.createFunction(
|
|
2616
|
+
["s"],
|
|
2617
|
+
this.createFunction(
|
|
2618
|
+
["b", "c", "p", "d", "e", "t", "f"],
|
|
2619
|
+
"(b=[],c=0,p=[],d=-1,e=!1,f=" + this.createEffectfulFunction(
|
|
2620
|
+
["i", "l"],
|
|
2621
|
+
"for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})"
|
|
2622
|
+
) + ",s.on({next:" + this.createEffectfulFunction(
|
|
2623
|
+
["v", "t"],
|
|
2624
|
+
"if(t=p.shift())t.s({done:!1,value:v});b.push(v)"
|
|
2625
|
+
) + ",throw:" + this.createEffectfulFunction(
|
|
2626
|
+
["v", "t"],
|
|
2627
|
+
"if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)"
|
|
2628
|
+
) + ",return:" + this.createEffectfulFunction(
|
|
2629
|
+
["v", "t"],
|
|
2630
|
+
"if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)"
|
|
2631
|
+
) + "}),t={[" + this.getRefParam(symbol.i) + "]:" + this.createFunction([], "t") + ",next:" + this.createEffectfulFunction(
|
|
2632
|
+
["i", "t", "v"],
|
|
2633
|
+
"if(d===-1){return((i=c++)>=b.length)?(p.push(t=" + this.getRefParam(promise.i) + "()),t):{done:!0,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}"
|
|
2634
|
+
) + "})"
|
|
2635
|
+
)
|
|
2636
|
+
)
|
|
2973
2637
|
);
|
|
2638
|
+
if (result) {
|
|
2639
|
+
return result + iterator + ")";
|
|
2640
|
+
}
|
|
2641
|
+
return iterator;
|
|
2974
2642
|
}
|
|
2975
2643
|
serializeAsyncIteratorFactoryInstance(node) {
|
|
2976
2644
|
return this.getConstructor(node.a[0]) + "(" + this.serialize(node.a[1]) + ")";
|
|
2977
2645
|
}
|
|
2978
|
-
|
|
2979
|
-
this.
|
|
2980
|
-
const result = this.getConstructor(node.a[0]) + "(" + this.serialize(node.a[1]) + ")";
|
|
2981
|
-
this.stack.pop();
|
|
2982
|
-
return this.assignIndexedValue(
|
|
2646
|
+
serializeStreamConstructor(node) {
|
|
2647
|
+
const result = this.assignIndexedValue(
|
|
2983
2648
|
node.i,
|
|
2984
|
-
|
|
2649
|
+
this.getConstructor(node.f) + "()"
|
|
2985
2650
|
);
|
|
2651
|
+
const len = node.a.length;
|
|
2652
|
+
if (len) {
|
|
2653
|
+
let values = this.serialize(node.a[0]);
|
|
2654
|
+
for (let i = 1; i < len; i++) {
|
|
2655
|
+
values += "," + this.serialize(node.a[i]);
|
|
2656
|
+
}
|
|
2657
|
+
return "(" + result + "," + values + "," + this.getRefParam(node.i) + ")";
|
|
2658
|
+
}
|
|
2659
|
+
return result;
|
|
2660
|
+
}
|
|
2661
|
+
serializeStreamNext(node) {
|
|
2662
|
+
return this.getRefParam(node.i) + ".next(" + this.serialize(node.f) + ")";
|
|
2663
|
+
}
|
|
2664
|
+
serializeStreamThrow(node) {
|
|
2665
|
+
return this.getRefParam(node.i) + ".throw(" + this.serialize(node.f) + ")";
|
|
2666
|
+
}
|
|
2667
|
+
serializeStreamReturn(node) {
|
|
2668
|
+
return this.getRefParam(node.i) + ".return(" + this.serialize(node.f) + ")";
|
|
2986
2669
|
}
|
|
2987
2670
|
serialize(node) {
|
|
2988
2671
|
switch (node.t) {
|
|
@@ -2996,7 +2679,7 @@ var BaseSerializerContext = class {
|
|
|
2996
2679
|
return node.s + "n";
|
|
2997
2680
|
case 4 /* IndexedValue */:
|
|
2998
2681
|
return this.getRefParam(node.i);
|
|
2999
|
-
case
|
|
2682
|
+
case 18 /* Reference */:
|
|
3000
2683
|
return this.serializeReference(node);
|
|
3001
2684
|
case 9 /* Array */:
|
|
3002
2685
|
return this.serializeArray(node);
|
|
@@ -3012,12 +2695,12 @@ var BaseSerializerContext = class {
|
|
|
3012
2695
|
return this.serializeSet(node);
|
|
3013
2696
|
case 8 /* Map */:
|
|
3014
2697
|
return this.serializeMap(node);
|
|
3015
|
-
case
|
|
2698
|
+
case 19 /* ArrayBuffer */:
|
|
3016
2699
|
return this.serializeArrayBuffer(node);
|
|
3017
2700
|
case 16 /* BigIntTypedArray */:
|
|
3018
2701
|
case 15 /* TypedArray */:
|
|
3019
2702
|
return this.serializeTypedArray(node);
|
|
3020
|
-
case
|
|
2703
|
+
case 20 /* DataView */:
|
|
3021
2704
|
return this.serializeDataView(node);
|
|
3022
2705
|
case 14 /* AggregateError */:
|
|
3023
2706
|
return this.serializeAggregateError(node);
|
|
@@ -3026,59 +2709,35 @@ var BaseSerializerContext = class {
|
|
|
3026
2709
|
case 12 /* Promise */:
|
|
3027
2710
|
return this.serializePromise(node);
|
|
3028
2711
|
case 17 /* WKSymbol */:
|
|
3029
|
-
return this.
|
|
3030
|
-
case
|
|
3031
|
-
return this.serializeURL(node);
|
|
3032
|
-
case 19 /* URLSearchParams */:
|
|
3033
|
-
return this.serializeURLSearchParams(node);
|
|
3034
|
-
case 23 /* Blob */:
|
|
3035
|
-
return this.serializeBlob(node);
|
|
3036
|
-
case 24 /* File */:
|
|
3037
|
-
return this.serializeFile(node);
|
|
3038
|
-
case 25 /* Headers */:
|
|
3039
|
-
return this.serializeHeaders(node);
|
|
3040
|
-
case 26 /* FormData */:
|
|
3041
|
-
return this.serializeFormData(node);
|
|
3042
|
-
case 27 /* Boxed */:
|
|
2712
|
+
return this.serializeWellKnownSymbol(node);
|
|
2713
|
+
case 21 /* Boxed */:
|
|
3043
2714
|
return this.serializeBoxed(node);
|
|
3044
|
-
case
|
|
2715
|
+
case 22 /* PromiseConstructor */:
|
|
3045
2716
|
return this.serializePromiseConstructor(node);
|
|
3046
|
-
case
|
|
2717
|
+
case 23 /* PromiseResolve */:
|
|
3047
2718
|
return this.serializePromiseResolve(node);
|
|
3048
|
-
case
|
|
2719
|
+
case 24 /* PromiseReject */:
|
|
3049
2720
|
return this.serializePromiseReject(node);
|
|
3050
|
-
case
|
|
3051
|
-
return this.serializeReadableStreamConstructor(node);
|
|
3052
|
-
case 32 /* ReadableStreamEnqueue */:
|
|
3053
|
-
return this.serializeReadableStreamEnqueue(node);
|
|
3054
|
-
case 34 /* ReadableStreamError */:
|
|
3055
|
-
return this.serializeReadableStreamError(node);
|
|
3056
|
-
case 33 /* ReadableStreamClose */:
|
|
3057
|
-
return this.serializeReadableStreamClose(node);
|
|
3058
|
-
case 35 /* Request */:
|
|
3059
|
-
return this.serializeRequest(node);
|
|
3060
|
-
case 36 /* Response */:
|
|
3061
|
-
return this.serializeResponse(node);
|
|
3062
|
-
case 37 /* Event */:
|
|
3063
|
-
return this.serializeEvent(node);
|
|
3064
|
-
case 38 /* CustomEvent */:
|
|
3065
|
-
return this.serializeCustomEvent(node);
|
|
3066
|
-
case 39 /* DOMException */:
|
|
3067
|
-
return this.serializeDOMException(node);
|
|
3068
|
-
case 40 /* Plugin */:
|
|
2721
|
+
case 25 /* Plugin */:
|
|
3069
2722
|
return this.serializePlugin(node);
|
|
3070
|
-
case
|
|
2723
|
+
case 26 /* SpecialReference */:
|
|
3071
2724
|
return this.serializeSpecialReference(node);
|
|
3072
|
-
case
|
|
2725
|
+
case 27 /* IteratorFactory */:
|
|
3073
2726
|
return this.serializeIteratorFactory(node);
|
|
3074
|
-
case
|
|
2727
|
+
case 28 /* IteratorFactoryInstance */:
|
|
3075
2728
|
return this.serializeIteratorFactoryInstance(node);
|
|
3076
|
-
case
|
|
2729
|
+
case 29 /* AsyncIteratorFactory */:
|
|
3077
2730
|
return this.serializeAsyncIteratorFactory(node);
|
|
3078
|
-
case
|
|
2731
|
+
case 30 /* AsyncIteratorFactoryInstance */:
|
|
3079
2732
|
return this.serializeAsyncIteratorFactoryInstance(node);
|
|
3080
|
-
case
|
|
3081
|
-
return this.
|
|
2733
|
+
case 31 /* StreamConstructor */:
|
|
2734
|
+
return this.serializeStreamConstructor(node);
|
|
2735
|
+
case 32 /* StreamNext */:
|
|
2736
|
+
return this.serializeStreamNext(node);
|
|
2737
|
+
case 33 /* StreamThrow */:
|
|
2738
|
+
return this.serializeStreamThrow(node);
|
|
2739
|
+
case 34 /* StreamReturn */:
|
|
2740
|
+
return this.serializeStreamReturn(node);
|
|
3082
2741
|
default:
|
|
3083
2742
|
throw new Error("invariant");
|
|
3084
2743
|
}
|
|
@@ -3118,12 +2777,6 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
|
|
|
3118
2777
|
*/
|
|
3119
2778
|
this.vars = [];
|
|
3120
2779
|
}
|
|
3121
|
-
/**
|
|
3122
|
-
* Increments the number of references the referenced value has
|
|
3123
|
-
*/
|
|
3124
|
-
markRef(current) {
|
|
3125
|
-
this.marked.add(current);
|
|
3126
|
-
}
|
|
3127
2780
|
/**
|
|
3128
2781
|
* Creates the reference param (identifier) from the given reference ID
|
|
3129
2782
|
* Calling this function means the value has been referenced somewhere
|
|
@@ -3156,18 +2809,6 @@ var VanillaSerializerContext = class extends BaseSerializerContext {
|
|
|
3156
2809
|
serializePromiseReject(node) {
|
|
3157
2810
|
throw new Error('Unsupported node type "' + node.t + '".');
|
|
3158
2811
|
}
|
|
3159
|
-
serializeReadableStreamConstructor(node) {
|
|
3160
|
-
throw new Error('Unsupported node type "' + node.t + '".');
|
|
3161
|
-
}
|
|
3162
|
-
serializeReadableStreamEnqueue(node) {
|
|
3163
|
-
throw new Error('Unsupported node type "' + node.t + '".');
|
|
3164
|
-
}
|
|
3165
|
-
serializeReadableStreamError(node) {
|
|
3166
|
-
throw new Error('Unsupported node type "' + node.t + '".');
|
|
3167
|
-
}
|
|
3168
|
-
serializeReadableStreamClose(node) {
|
|
3169
|
-
throw new Error('Unsupported node type "' + node.t + '".');
|
|
3170
|
-
}
|
|
3171
2812
|
serializeTop(tree) {
|
|
3172
2813
|
const result = this.serialize(tree);
|
|
3173
2814
|
if (tree.i != null && this.vars.length) {
|
|
@@ -3201,11 +2842,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3201
2842
|
return nodes;
|
|
3202
2843
|
}
|
|
3203
2844
|
parseArray(id, current) {
|
|
3204
|
-
return createArrayNode(
|
|
3205
|
-
id,
|
|
3206
|
-
current,
|
|
3207
|
-
this.parseItems(current)
|
|
3208
|
-
);
|
|
2845
|
+
return createArrayNode(id, current, this.parseItems(current));
|
|
3209
2846
|
}
|
|
3210
2847
|
parseProperties(properties) {
|
|
3211
2848
|
const entries = Object.entries(properties);
|
|
@@ -3215,31 +2852,37 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3215
2852
|
keyNodes.push(serializeString(entries[i][0]));
|
|
3216
2853
|
valueNodes.push(this.parse(entries[i][1]));
|
|
3217
2854
|
}
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
this.parseIteratorFactory(),
|
|
3227
|
-
this.parse(
|
|
3228
|
-
iteratorToSequence(properties)
|
|
3229
|
-
)
|
|
2855
|
+
let symbol = Symbol.iterator;
|
|
2856
|
+
if (symbol in properties) {
|
|
2857
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
2858
|
+
valueNodes.push(
|
|
2859
|
+
createIteratorFactoryInstanceNode(
|
|
2860
|
+
this.parseIteratorFactory(),
|
|
2861
|
+
this.parse(
|
|
2862
|
+
iteratorToSequence(properties)
|
|
3230
2863
|
)
|
|
3231
|
-
)
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
2864
|
+
)
|
|
2865
|
+
);
|
|
2866
|
+
}
|
|
2867
|
+
symbol = Symbol.asyncIterator;
|
|
2868
|
+
if (symbol in properties) {
|
|
2869
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
2870
|
+
valueNodes.push(
|
|
2871
|
+
createAsyncIteratorFactoryInstanceNode(
|
|
2872
|
+
this.parseAsyncIteratorFactory(),
|
|
2873
|
+
this.parse(createStream())
|
|
2874
|
+
)
|
|
2875
|
+
);
|
|
2876
|
+
}
|
|
2877
|
+
symbol = Symbol.toStringTag;
|
|
2878
|
+
if (symbol in properties) {
|
|
2879
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
2880
|
+
valueNodes.push(createStringNode(properties[symbol]));
|
|
2881
|
+
}
|
|
2882
|
+
symbol = Symbol.isConcatSpreadable;
|
|
2883
|
+
if (symbol in properties) {
|
|
2884
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
2885
|
+
valueNodes.push(properties[symbol] ? TRUE_NODE : FALSE_NODE);
|
|
3243
2886
|
}
|
|
3244
2887
|
return {
|
|
3245
2888
|
k: keyNodes,
|
|
@@ -3290,12 +2933,7 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3290
2933
|
keyNodes.push(this.parse(key));
|
|
3291
2934
|
valueNodes.push(this.parse(value));
|
|
3292
2935
|
}
|
|
3293
|
-
return this.createMapNode(
|
|
3294
|
-
id,
|
|
3295
|
-
keyNodes,
|
|
3296
|
-
valueNodes,
|
|
3297
|
-
current.size
|
|
3298
|
-
);
|
|
2936
|
+
return this.createMapNode(id, keyNodes, valueNodes, current.size);
|
|
3299
2937
|
}
|
|
3300
2938
|
parseSet(id, current) {
|
|
3301
2939
|
const items = [];
|
|
@@ -3304,66 +2942,6 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3304
2942
|
}
|
|
3305
2943
|
return createSetNode(id, current.size, items);
|
|
3306
2944
|
}
|
|
3307
|
-
parsePlainProperties(entries) {
|
|
3308
|
-
const size = entries.length;
|
|
3309
|
-
const keyNodes = [];
|
|
3310
|
-
const valueNodes = [];
|
|
3311
|
-
for (let i = 0; i < size; i++) {
|
|
3312
|
-
keyNodes.push(serializeString(entries[i][0]));
|
|
3313
|
-
valueNodes.push(this.parse(entries[i][1]));
|
|
3314
|
-
}
|
|
3315
|
-
return {
|
|
3316
|
-
k: keyNodes,
|
|
3317
|
-
v: valueNodes,
|
|
3318
|
-
s: size
|
|
3319
|
-
};
|
|
3320
|
-
}
|
|
3321
|
-
parseHeaders(id, current) {
|
|
3322
|
-
const items = [];
|
|
3323
|
-
current.forEach((value, key) => {
|
|
3324
|
-
items.push([key, value]);
|
|
3325
|
-
});
|
|
3326
|
-
return {
|
|
3327
|
-
t: 25 /* Headers */,
|
|
3328
|
-
i: id,
|
|
3329
|
-
s: void 0,
|
|
3330
|
-
l: void 0,
|
|
3331
|
-
c: void 0,
|
|
3332
|
-
m: void 0,
|
|
3333
|
-
p: void 0,
|
|
3334
|
-
e: this.parsePlainProperties(items),
|
|
3335
|
-
a: void 0,
|
|
3336
|
-
f: void 0,
|
|
3337
|
-
b: void 0,
|
|
3338
|
-
o: void 0
|
|
3339
|
-
};
|
|
3340
|
-
}
|
|
3341
|
-
parseFormData(id, current) {
|
|
3342
|
-
const items = [];
|
|
3343
|
-
current.forEach((value, key) => {
|
|
3344
|
-
items.push([key, value]);
|
|
3345
|
-
});
|
|
3346
|
-
return {
|
|
3347
|
-
t: 26 /* FormData */,
|
|
3348
|
-
i: id,
|
|
3349
|
-
s: void 0,
|
|
3350
|
-
l: void 0,
|
|
3351
|
-
c: void 0,
|
|
3352
|
-
m: void 0,
|
|
3353
|
-
p: void 0,
|
|
3354
|
-
e: this.parsePlainProperties(items),
|
|
3355
|
-
a: void 0,
|
|
3356
|
-
f: void 0,
|
|
3357
|
-
b: void 0,
|
|
3358
|
-
o: void 0
|
|
3359
|
-
};
|
|
3360
|
-
}
|
|
3361
|
-
parseEvent(id, current) {
|
|
3362
|
-
return createEventNode(id, current.type, this.parse(createEventOptions(current)));
|
|
3363
|
-
}
|
|
3364
|
-
parseCustomEvent(id, current) {
|
|
3365
|
-
return createCustomEventNode(id, current.type, this.parse(createCustomEventOptions(current)));
|
|
3366
|
-
}
|
|
3367
2945
|
parsePlugin(id, current) {
|
|
3368
2946
|
const currentPlugins = this.plugins;
|
|
3369
2947
|
if (currentPlugins) {
|
|
@@ -3382,10 +2960,40 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3382
2960
|
}
|
|
3383
2961
|
return void 0;
|
|
3384
2962
|
}
|
|
2963
|
+
parseStream(id, _current) {
|
|
2964
|
+
return createStreamConstructorNode(
|
|
2965
|
+
id,
|
|
2966
|
+
this.parseSpecialReference(4 /* StreamConstructor */),
|
|
2967
|
+
[]
|
|
2968
|
+
);
|
|
2969
|
+
}
|
|
2970
|
+
parsePromise(id, _current) {
|
|
2971
|
+
return {
|
|
2972
|
+
t: 22 /* PromiseConstructor */,
|
|
2973
|
+
i: id,
|
|
2974
|
+
s: void 0,
|
|
2975
|
+
l: void 0,
|
|
2976
|
+
c: void 0,
|
|
2977
|
+
m: void 0,
|
|
2978
|
+
p: void 0,
|
|
2979
|
+
e: void 0,
|
|
2980
|
+
a: void 0,
|
|
2981
|
+
f: this.parseSpecialReference(1 /* PromiseConstructor */),
|
|
2982
|
+
b: void 0,
|
|
2983
|
+
o: void 0
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
3385
2986
|
parseObject(id, current) {
|
|
3386
2987
|
if (Array.isArray(current)) {
|
|
3387
2988
|
return this.parseArray(id, current);
|
|
3388
2989
|
}
|
|
2990
|
+
if (isStream(current)) {
|
|
2991
|
+
return this.parseStream(id, current);
|
|
2992
|
+
}
|
|
2993
|
+
const parsed = this.parsePlugin(id, current);
|
|
2994
|
+
if (parsed) {
|
|
2995
|
+
return parsed;
|
|
2996
|
+
}
|
|
3389
2997
|
const currentClass = current.constructor;
|
|
3390
2998
|
switch (currentClass) {
|
|
3391
2999
|
case Object:
|
|
@@ -3417,119 +3025,77 @@ var BaseSyncParserContext = class extends BaseParserContext {
|
|
|
3417
3025
|
case String:
|
|
3418
3026
|
case BigInt:
|
|
3419
3027
|
return this.parseBoxed(id, current);
|
|
3028
|
+
case ArrayBuffer:
|
|
3029
|
+
return createArrayBufferNode(id, current);
|
|
3030
|
+
case Int8Array:
|
|
3031
|
+
case Int16Array:
|
|
3032
|
+
case Int32Array:
|
|
3033
|
+
case Uint8Array:
|
|
3034
|
+
case Uint16Array:
|
|
3035
|
+
case Uint32Array:
|
|
3036
|
+
case Uint8ClampedArray:
|
|
3037
|
+
case Float32Array:
|
|
3038
|
+
case Float64Array:
|
|
3039
|
+
return this.parseTypedArray(id, current);
|
|
3040
|
+
case DataView:
|
|
3041
|
+
return this.parseDataView(id, current);
|
|
3042
|
+
case Map:
|
|
3043
|
+
return this.parseMap(id, current);
|
|
3044
|
+
case Set:
|
|
3045
|
+
return this.parseSet(id, current);
|
|
3420
3046
|
default:
|
|
3421
3047
|
break;
|
|
3422
3048
|
}
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
case Int8Array:
|
|
3429
|
-
case Int16Array:
|
|
3430
|
-
case Int32Array:
|
|
3431
|
-
case Uint8Array:
|
|
3432
|
-
case Uint16Array:
|
|
3433
|
-
case Uint32Array:
|
|
3434
|
-
case Uint8ClampedArray:
|
|
3435
|
-
case Float32Array:
|
|
3436
|
-
case Float64Array:
|
|
3437
|
-
return this.parseTypedArray(id, current);
|
|
3438
|
-
case DataView:
|
|
3439
|
-
return this.parseDataView(id, current);
|
|
3440
|
-
default:
|
|
3441
|
-
break;
|
|
3442
|
-
}
|
|
3443
|
-
}
|
|
3444
|
-
if ((currentFeatures & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
3049
|
+
if (currentClass === Promise || current instanceof Promise) {
|
|
3050
|
+
return this.parsePromise(id, current);
|
|
3051
|
+
}
|
|
3052
|
+
const currentFeatures = this.features;
|
|
3053
|
+
if (currentFeatures & 16 /* BigIntTypedArray */) {
|
|
3445
3054
|
switch (currentClass) {
|
|
3446
3055
|
case BigInt64Array:
|
|
3447
3056
|
case BigUint64Array:
|
|
3448
|
-
return this.parseBigIntTypedArray(
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
}
|
|
3453
|
-
if (currentFeatures & 32 /* Map */ && currentClass === Map) {
|
|
3454
|
-
return this.parseMap(
|
|
3455
|
-
id,
|
|
3456
|
-
current
|
|
3457
|
-
);
|
|
3458
|
-
}
|
|
3459
|
-
if (currentFeatures & 512 /* Set */ && currentClass === Set) {
|
|
3460
|
-
return this.parseSet(
|
|
3461
|
-
id,
|
|
3462
|
-
current
|
|
3463
|
-
);
|
|
3464
|
-
}
|
|
3465
|
-
if (currentFeatures & 8192 /* WebAPI */) {
|
|
3466
|
-
switch (currentClass) {
|
|
3467
|
-
case (typeof URL !== "undefined" ? URL : UNIVERSAL_SENTINEL):
|
|
3468
|
-
return createURLNode(id, current);
|
|
3469
|
-
case (typeof URLSearchParams !== "undefined" ? URLSearchParams : UNIVERSAL_SENTINEL):
|
|
3470
|
-
return createURLSearchParamsNode(id, current);
|
|
3471
|
-
case (typeof Headers !== "undefined" ? Headers : UNIVERSAL_SENTINEL):
|
|
3472
|
-
return this.parseHeaders(id, current);
|
|
3473
|
-
case (typeof FormData !== "undefined" ? FormData : UNIVERSAL_SENTINEL):
|
|
3474
|
-
return this.parseFormData(id, current);
|
|
3475
|
-
case (typeof Event !== "undefined" ? Event : UNIVERSAL_SENTINEL):
|
|
3476
|
-
return this.parseEvent(id, current);
|
|
3477
|
-
case (typeof CustomEvent !== "undefined" ? CustomEvent : UNIVERSAL_SENTINEL):
|
|
3478
|
-
return this.parseCustomEvent(id, current);
|
|
3479
|
-
case (typeof DOMException !== "undefined" ? DOMException : UNIVERSAL_SENTINEL):
|
|
3480
|
-
return createDOMExceptionNode(id, current);
|
|
3057
|
+
return this.parseBigIntTypedArray(
|
|
3058
|
+
id,
|
|
3059
|
+
current
|
|
3060
|
+
);
|
|
3481
3061
|
default:
|
|
3482
3062
|
break;
|
|
3483
3063
|
}
|
|
3484
3064
|
}
|
|
3485
|
-
const parsed = this.parsePlugin(id, current);
|
|
3486
|
-
if (parsed) {
|
|
3487
|
-
return parsed;
|
|
3488
|
-
}
|
|
3489
3065
|
if (currentFeatures & 1 /* AggregateError */ && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
3490
3066
|
return this.parseAggregateError(id, current);
|
|
3491
3067
|
}
|
|
3492
3068
|
if (current instanceof Error) {
|
|
3493
3069
|
return this.parseError(id, current);
|
|
3494
3070
|
}
|
|
3495
|
-
if (
|
|
3071
|
+
if (Symbol.iterator in current || Symbol.asyncIterator in current) {
|
|
3496
3072
|
return this.parsePlainObject(id, current, !!currentClass);
|
|
3497
3073
|
}
|
|
3498
3074
|
throw new UnsupportedTypeError(current);
|
|
3499
3075
|
}
|
|
3500
3076
|
parse(current) {
|
|
3501
|
-
switch (current) {
|
|
3502
|
-
case true:
|
|
3503
|
-
return TRUE_NODE;
|
|
3504
|
-
case false:
|
|
3505
|
-
return FALSE_NODE;
|
|
3506
|
-
case void 0:
|
|
3507
|
-
return UNDEFINED_NODE;
|
|
3508
|
-
case null:
|
|
3509
|
-
return NULL_NODE;
|
|
3510
|
-
default:
|
|
3511
|
-
break;
|
|
3512
|
-
}
|
|
3513
3077
|
switch (typeof current) {
|
|
3078
|
+
case "boolean":
|
|
3079
|
+
return current ? TRUE_NODE : FALSE_NODE;
|
|
3080
|
+
case "undefined":
|
|
3081
|
+
return UNDEFINED_NODE;
|
|
3514
3082
|
case "string":
|
|
3515
3083
|
return createStringNode(current);
|
|
3516
3084
|
case "number":
|
|
3517
3085
|
return createNumberNode(current);
|
|
3518
3086
|
case "bigint":
|
|
3519
|
-
assert(this.features & 8 /* BigInt */, new UnsupportedTypeError(current));
|
|
3520
3087
|
return createBigIntNode(current);
|
|
3521
3088
|
case "object": {
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
const id = this.getReference(current);
|
|
3528
|
-
return typeof id === "number" ? createWKSymbolNode(id, current) : id;
|
|
3089
|
+
if (current) {
|
|
3090
|
+
const ref = this.getReference(current);
|
|
3091
|
+
return ref.type === 0 ? this.parseObject(ref.value, current) : ref.value;
|
|
3092
|
+
}
|
|
3093
|
+
return NULL_NODE;
|
|
3529
3094
|
}
|
|
3095
|
+
case "symbol":
|
|
3096
|
+
return this.parseWellKnownSymbol(current);
|
|
3530
3097
|
case "function":
|
|
3531
|
-
|
|
3532
|
-
return this.getStrictReference(current);
|
|
3098
|
+
return this.parseFunction(current);
|
|
3533
3099
|
default:
|
|
3534
3100
|
throw new UnsupportedTypeError(current);
|
|
3535
3101
|
}
|
|
@@ -3546,26 +3112,28 @@ var SyncParserContext = class extends BaseSyncParserContext {
|
|
|
3546
3112
|
|
|
3547
3113
|
// src/core/tree/index.ts
|
|
3548
3114
|
function serialize(source, options = {}) {
|
|
3115
|
+
const plugins = resolvePlugins(options.plugins);
|
|
3549
3116
|
const ctx = new SyncParserContext({
|
|
3550
|
-
plugins
|
|
3117
|
+
plugins,
|
|
3551
3118
|
disabledFeatures: options.disabledFeatures
|
|
3552
3119
|
});
|
|
3553
3120
|
const tree = ctx.parse(source);
|
|
3554
3121
|
const serial = new VanillaSerializerContext({
|
|
3555
|
-
plugins
|
|
3122
|
+
plugins,
|
|
3556
3123
|
features: ctx.features,
|
|
3557
3124
|
markedRefs: ctx.marked
|
|
3558
3125
|
});
|
|
3559
3126
|
return serial.serializeTop(tree);
|
|
3560
3127
|
}
|
|
3561
3128
|
async function serializeAsync(source, options = {}) {
|
|
3129
|
+
const plugins = resolvePlugins(options.plugins);
|
|
3562
3130
|
const ctx = new AsyncParserContext({
|
|
3563
|
-
plugins
|
|
3131
|
+
plugins,
|
|
3564
3132
|
disabledFeatures: options.disabledFeatures
|
|
3565
3133
|
});
|
|
3566
3134
|
const tree = await ctx.parse(source);
|
|
3567
3135
|
const serial = new VanillaSerializerContext({
|
|
3568
|
-
plugins
|
|
3136
|
+
plugins,
|
|
3569
3137
|
features: ctx.features,
|
|
3570
3138
|
markedRefs: ctx.marked
|
|
3571
3139
|
});
|
|
@@ -3575,8 +3143,9 @@ function deserialize(source) {
|
|
|
3575
3143
|
return (0, eval)(source);
|
|
3576
3144
|
}
|
|
3577
3145
|
function toJSON(source, options = {}) {
|
|
3146
|
+
const plugins = resolvePlugins(options.plugins);
|
|
3578
3147
|
const ctx = new SyncParserContext({
|
|
3579
|
-
plugins
|
|
3148
|
+
plugins,
|
|
3580
3149
|
disabledFeatures: options.disabledFeatures
|
|
3581
3150
|
});
|
|
3582
3151
|
return {
|
|
@@ -3586,8 +3155,9 @@ function toJSON(source, options = {}) {
|
|
|
3586
3155
|
};
|
|
3587
3156
|
}
|
|
3588
3157
|
async function toJSONAsync(source, options = {}) {
|
|
3158
|
+
const plugins = resolvePlugins(options.plugins);
|
|
3589
3159
|
const ctx = new AsyncParserContext({
|
|
3590
|
-
plugins
|
|
3160
|
+
plugins,
|
|
3591
3161
|
disabledFeatures: options.disabledFeatures
|
|
3592
3162
|
});
|
|
3593
3163
|
return {
|
|
@@ -3597,16 +3167,18 @@ async function toJSONAsync(source, options = {}) {
|
|
|
3597
3167
|
};
|
|
3598
3168
|
}
|
|
3599
3169
|
function compileJSON(source, options = {}) {
|
|
3170
|
+
const plugins = resolvePlugins(options.plugins);
|
|
3600
3171
|
const ctx = new VanillaSerializerContext({
|
|
3601
|
-
plugins
|
|
3172
|
+
plugins,
|
|
3602
3173
|
features: source.f,
|
|
3603
3174
|
markedRefs: source.m
|
|
3604
3175
|
});
|
|
3605
3176
|
return ctx.serializeTop(source.t);
|
|
3606
3177
|
}
|
|
3607
3178
|
function fromJSON(source, options = {}) {
|
|
3179
|
+
const plugins = resolvePlugins(options.plugins);
|
|
3608
3180
|
const ctx = new VanillaDeserializerContext({
|
|
3609
|
-
plugins
|
|
3181
|
+
plugins,
|
|
3610
3182
|
markedRefs: source.m
|
|
3611
3183
|
});
|
|
3612
3184
|
return ctx.deserialize(source.t);
|
|
@@ -3642,9 +3214,6 @@ var CrossSerializerContext = class extends BaseSerializerContext {
|
|
|
3642
3214
|
this.scopeId = options.scopeId;
|
|
3643
3215
|
}
|
|
3644
3216
|
getRefParam(id) {
|
|
3645
|
-
if (typeof id === "string") {
|
|
3646
|
-
return GLOBAL_CONTEXT_REFERENCES + "." + id;
|
|
3647
|
-
}
|
|
3648
3217
|
return GLOBAL_CONTEXT_REFERENCES + "[" + id + "]";
|
|
3649
3218
|
}
|
|
3650
3219
|
assignIndexedValue(index, value) {
|
|
@@ -3659,12 +3228,11 @@ var CrossSerializerContext = class extends BaseSerializerContext {
|
|
|
3659
3228
|
const patches = this.resolvePatches();
|
|
3660
3229
|
const ref = this.getRefParam(id);
|
|
3661
3230
|
const params = this.scopeId == null ? "" : GLOBAL_CONTEXT_REFERENCES;
|
|
3662
|
-
const
|
|
3231
|
+
const body = patches ? result + "," + patches + ref : result;
|
|
3663
3232
|
if (params === "") {
|
|
3664
|
-
return patches ? "(" +
|
|
3233
|
+
return patches ? "(" + body + ")" : body;
|
|
3665
3234
|
}
|
|
3666
3235
|
const args = this.scopeId == null ? "()" : "(" + GLOBAL_CONTEXT_REFERENCES + '["' + serializeString(this.scopeId) + '"])';
|
|
3667
|
-
const body = mainBody + (patches ? ref : "");
|
|
3668
3236
|
return "(" + this.createFunction([params], body) + ")" + args;
|
|
3669
3237
|
}
|
|
3670
3238
|
};
|
|
@@ -3677,17 +3245,31 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3677
3245
|
this.alive = true;
|
|
3678
3246
|
// Amount of pending promises/streams
|
|
3679
3247
|
this.pending = 0;
|
|
3248
|
+
this.initial = true;
|
|
3249
|
+
this.buffer = [];
|
|
3680
3250
|
this.onParseCallback = options.onParse;
|
|
3681
3251
|
this.onErrorCallback = options.onError;
|
|
3682
3252
|
this.onDoneCallback = options.onDone;
|
|
3683
3253
|
}
|
|
3684
|
-
|
|
3254
|
+
onParseInternal(node, initial) {
|
|
3685
3255
|
try {
|
|
3686
3256
|
this.onParseCallback(node, initial);
|
|
3687
3257
|
} catch (error) {
|
|
3688
3258
|
this.onError(error);
|
|
3689
3259
|
}
|
|
3690
3260
|
}
|
|
3261
|
+
flush() {
|
|
3262
|
+
for (let i = 0, len = this.buffer.length; i < len; i++) {
|
|
3263
|
+
this.onParseInternal(this.buffer[i], false);
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
onParse(node) {
|
|
3267
|
+
if (this.initial) {
|
|
3268
|
+
this.buffer.push(node);
|
|
3269
|
+
} else {
|
|
3270
|
+
this.onParseInternal(node, false);
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3691
3273
|
onError(error) {
|
|
3692
3274
|
if (this.onErrorCallback) {
|
|
3693
3275
|
this.onErrorCallback(error);
|
|
@@ -3700,12 +3282,6 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3700
3282
|
this.onDoneCallback();
|
|
3701
3283
|
}
|
|
3702
3284
|
}
|
|
3703
|
-
push(value) {
|
|
3704
|
-
this.onParse(
|
|
3705
|
-
this.parse(value),
|
|
3706
|
-
false
|
|
3707
|
-
);
|
|
3708
|
-
}
|
|
3709
3285
|
pushPendingState() {
|
|
3710
3286
|
this.pending++;
|
|
3711
3287
|
}
|
|
@@ -3722,48 +3298,41 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3722
3298
|
keyNodes.push(serializeString(entries[i][0]));
|
|
3723
3299
|
valueNodes.push(this.parse(entries[i][1]));
|
|
3724
3300
|
}
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
this.parseIteratorFactory(),
|
|
3734
|
-
this.parse(
|
|
3735
|
-
iteratorToSequence(properties)
|
|
3736
|
-
)
|
|
3301
|
+
let symbol = Symbol.iterator;
|
|
3302
|
+
if (symbol in properties) {
|
|
3303
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
3304
|
+
valueNodes.push(
|
|
3305
|
+
createIteratorFactoryInstanceNode(
|
|
3306
|
+
this.parseIteratorFactory(),
|
|
3307
|
+
this.parse(
|
|
3308
|
+
iteratorToSequence(properties)
|
|
3737
3309
|
)
|
|
3738
|
-
)
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
properties,
|
|
3751
|
-
this
|
|
3752
|
-
)
|
|
3310
|
+
)
|
|
3311
|
+
);
|
|
3312
|
+
}
|
|
3313
|
+
symbol = Symbol.asyncIterator;
|
|
3314
|
+
if (symbol in properties) {
|
|
3315
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
3316
|
+
valueNodes.push(
|
|
3317
|
+
createAsyncIteratorFactoryInstanceNode(
|
|
3318
|
+
this.parseAsyncIteratorFactory(),
|
|
3319
|
+
this.parse(
|
|
3320
|
+
createStreamFromAsyncIterable(
|
|
3321
|
+
properties
|
|
3753
3322
|
)
|
|
3754
3323
|
)
|
|
3755
|
-
)
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3324
|
+
)
|
|
3325
|
+
);
|
|
3326
|
+
}
|
|
3327
|
+
symbol = Symbol.toStringTag;
|
|
3328
|
+
if (symbol in properties) {
|
|
3329
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
3330
|
+
valueNodes.push(createStringNode(properties[symbol]));
|
|
3331
|
+
}
|
|
3332
|
+
symbol = Symbol.isConcatSpreadable;
|
|
3333
|
+
if (symbol in properties) {
|
|
3334
|
+
keyNodes.push(this.parseWellKnownSymbol(symbol));
|
|
3335
|
+
valueNodes.push(properties[symbol] ? TRUE_NODE : FALSE_NODE);
|
|
3767
3336
|
}
|
|
3768
3337
|
return {
|
|
3769
3338
|
k: keyNodes,
|
|
@@ -3771,141 +3340,13 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3771
3340
|
s: keyNodes.length
|
|
3772
3341
|
};
|
|
3773
3342
|
}
|
|
3774
|
-
pushReadableStreamReader(id, reader) {
|
|
3775
|
-
reader.read().then(
|
|
3776
|
-
(data) => {
|
|
3777
|
-
if (this.alive) {
|
|
3778
|
-
if (data.done) {
|
|
3779
|
-
this.onParse({
|
|
3780
|
-
t: 33 /* ReadableStreamClose */,
|
|
3781
|
-
i: id,
|
|
3782
|
-
s: void 0,
|
|
3783
|
-
l: void 0,
|
|
3784
|
-
c: void 0,
|
|
3785
|
-
m: void 0,
|
|
3786
|
-
p: void 0,
|
|
3787
|
-
e: void 0,
|
|
3788
|
-
a: void 0,
|
|
3789
|
-
f: this.parseSpecialReference(8 /* ReadableStreamClose */),
|
|
3790
|
-
b: void 0,
|
|
3791
|
-
o: void 0
|
|
3792
|
-
}, false);
|
|
3793
|
-
this.popPendingState();
|
|
3794
|
-
} else {
|
|
3795
|
-
const parsed = this.parseWithError(data.value);
|
|
3796
|
-
if (parsed) {
|
|
3797
|
-
this.onParse({
|
|
3798
|
-
t: 32 /* ReadableStreamEnqueue */,
|
|
3799
|
-
i: id,
|
|
3800
|
-
s: void 0,
|
|
3801
|
-
l: void 0,
|
|
3802
|
-
c: void 0,
|
|
3803
|
-
m: void 0,
|
|
3804
|
-
p: void 0,
|
|
3805
|
-
e: void 0,
|
|
3806
|
-
a: [
|
|
3807
|
-
this.parseSpecialReference(6 /* ReadableStreamEnqueue */),
|
|
3808
|
-
parsed
|
|
3809
|
-
],
|
|
3810
|
-
f: void 0,
|
|
3811
|
-
b: void 0,
|
|
3812
|
-
o: void 0
|
|
3813
|
-
}, false);
|
|
3814
|
-
this.pushReadableStreamReader(id, reader);
|
|
3815
|
-
}
|
|
3816
|
-
}
|
|
3817
|
-
}
|
|
3818
|
-
},
|
|
3819
|
-
(value) => {
|
|
3820
|
-
if (this.alive) {
|
|
3821
|
-
const parsed = this.parseWithError(value);
|
|
3822
|
-
if (parsed) {
|
|
3823
|
-
this.onParse({
|
|
3824
|
-
t: 34 /* ReadableStreamError */,
|
|
3825
|
-
i: id,
|
|
3826
|
-
s: void 0,
|
|
3827
|
-
l: void 0,
|
|
3828
|
-
c: void 0,
|
|
3829
|
-
m: void 0,
|
|
3830
|
-
p: void 0,
|
|
3831
|
-
e: void 0,
|
|
3832
|
-
a: [
|
|
3833
|
-
this.parseSpecialReference(7 /* ReadableStreamError */),
|
|
3834
|
-
parsed
|
|
3835
|
-
],
|
|
3836
|
-
f: void 0,
|
|
3837
|
-
b: void 0,
|
|
3838
|
-
o: void 0
|
|
3839
|
-
}, false);
|
|
3840
|
-
}
|
|
3841
|
-
this.popPendingState();
|
|
3842
|
-
}
|
|
3843
|
-
}
|
|
3844
|
-
);
|
|
3845
|
-
}
|
|
3846
|
-
parseReadableStream(id, current) {
|
|
3847
|
-
const reader = current.getReader();
|
|
3848
|
-
this.pushPendingState();
|
|
3849
|
-
this.pushReadableStreamReader(id, reader);
|
|
3850
|
-
return {
|
|
3851
|
-
t: 31 /* ReadableStreamConstructor */,
|
|
3852
|
-
i: id,
|
|
3853
|
-
s: void 0,
|
|
3854
|
-
l: void 0,
|
|
3855
|
-
c: void 0,
|
|
3856
|
-
m: void 0,
|
|
3857
|
-
p: void 0,
|
|
3858
|
-
e: void 0,
|
|
3859
|
-
a: void 0,
|
|
3860
|
-
f: this.parseSpecialReference(5 /* ReadableStreamConstructor */),
|
|
3861
|
-
b: void 0,
|
|
3862
|
-
o: void 0
|
|
3863
|
-
};
|
|
3864
|
-
}
|
|
3865
|
-
parseRequest(id, current) {
|
|
3866
|
-
return {
|
|
3867
|
-
t: 35 /* Request */,
|
|
3868
|
-
i: id,
|
|
3869
|
-
s: serializeString(current.url),
|
|
3870
|
-
l: void 0,
|
|
3871
|
-
c: void 0,
|
|
3872
|
-
m: void 0,
|
|
3873
|
-
p: void 0,
|
|
3874
|
-
e: void 0,
|
|
3875
|
-
f: this.parse(
|
|
3876
|
-
createRequestOptions(current, current.clone().body)
|
|
3877
|
-
),
|
|
3878
|
-
a: void 0,
|
|
3879
|
-
b: void 0,
|
|
3880
|
-
o: void 0
|
|
3881
|
-
};
|
|
3882
|
-
}
|
|
3883
|
-
parseResponse(id, current) {
|
|
3884
|
-
return {
|
|
3885
|
-
t: 36 /* Response */,
|
|
3886
|
-
i: id,
|
|
3887
|
-
s: void 0,
|
|
3888
|
-
l: void 0,
|
|
3889
|
-
c: void 0,
|
|
3890
|
-
m: void 0,
|
|
3891
|
-
p: void 0,
|
|
3892
|
-
e: void 0,
|
|
3893
|
-
f: void 0,
|
|
3894
|
-
a: [
|
|
3895
|
-
current.body ? this.parse(current.clone().body) : NULL_NODE,
|
|
3896
|
-
this.parse(createResponseOptions(current))
|
|
3897
|
-
],
|
|
3898
|
-
b: void 0,
|
|
3899
|
-
o: void 0
|
|
3900
|
-
};
|
|
3901
|
-
}
|
|
3902
3343
|
parsePromise(id, current) {
|
|
3903
3344
|
current.then(
|
|
3904
3345
|
(data) => {
|
|
3905
3346
|
const parsed = this.parseWithError(data);
|
|
3906
3347
|
if (parsed) {
|
|
3907
3348
|
this.onParse({
|
|
3908
|
-
t:
|
|
3349
|
+
t: 23 /* PromiseResolve */,
|
|
3909
3350
|
i: id,
|
|
3910
3351
|
s: void 0,
|
|
3911
3352
|
l: void 0,
|
|
@@ -3914,13 +3355,13 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3914
3355
|
p: void 0,
|
|
3915
3356
|
e: void 0,
|
|
3916
3357
|
a: [
|
|
3917
|
-
this.parseSpecialReference(
|
|
3358
|
+
this.parseSpecialReference(2 /* PromiseResolve */),
|
|
3918
3359
|
parsed
|
|
3919
3360
|
],
|
|
3920
3361
|
f: void 0,
|
|
3921
3362
|
b: void 0,
|
|
3922
3363
|
o: void 0
|
|
3923
|
-
}
|
|
3364
|
+
});
|
|
3924
3365
|
}
|
|
3925
3366
|
this.popPendingState();
|
|
3926
3367
|
},
|
|
@@ -3929,7 +3370,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3929
3370
|
const parsed = this.parseWithError(data);
|
|
3930
3371
|
if (parsed) {
|
|
3931
3372
|
this.onParse({
|
|
3932
|
-
t:
|
|
3373
|
+
t: 24 /* PromiseReject */,
|
|
3933
3374
|
i: id,
|
|
3934
3375
|
s: void 0,
|
|
3935
3376
|
l: void 0,
|
|
@@ -3938,13 +3379,13 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3938
3379
|
p: void 0,
|
|
3939
3380
|
e: void 0,
|
|
3940
3381
|
a: [
|
|
3941
|
-
this.parseSpecialReference(
|
|
3382
|
+
this.parseSpecialReference(3 /* PromiseReject */),
|
|
3942
3383
|
parsed
|
|
3943
3384
|
],
|
|
3944
3385
|
f: void 0,
|
|
3945
3386
|
b: void 0,
|
|
3946
3387
|
o: void 0
|
|
3947
|
-
}
|
|
3388
|
+
});
|
|
3948
3389
|
}
|
|
3949
3390
|
}
|
|
3950
3391
|
this.popPendingState();
|
|
@@ -3952,7 +3393,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3952
3393
|
);
|
|
3953
3394
|
this.pushPendingState();
|
|
3954
3395
|
return {
|
|
3955
|
-
t:
|
|
3396
|
+
t: 22 /* PromiseConstructor */,
|
|
3956
3397
|
i: id,
|
|
3957
3398
|
s: void 0,
|
|
3958
3399
|
l: void 0,
|
|
@@ -3961,7 +3402,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3961
3402
|
p: void 0,
|
|
3962
3403
|
e: void 0,
|
|
3963
3404
|
a: void 0,
|
|
3964
|
-
f: this.parseSpecialReference(
|
|
3405
|
+
f: this.parseSpecialReference(1 /* PromiseConstructor */),
|
|
3965
3406
|
b: void 0,
|
|
3966
3407
|
o: void 0
|
|
3967
3408
|
};
|
|
@@ -3984,129 +3425,42 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3984
3425
|
}
|
|
3985
3426
|
return void 0;
|
|
3986
3427
|
}
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
)
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
case BigInt:
|
|
4021
|
-
return this.parseBoxed(id, current);
|
|
4022
|
-
default:
|
|
4023
|
-
break;
|
|
4024
|
-
}
|
|
4025
|
-
const currentFeatures = this.features;
|
|
4026
|
-
if (currentFeatures & 256 /* Promise */ && (currentClass === Promise || current instanceof Promise)) {
|
|
4027
|
-
return this.parsePromise(id, current);
|
|
4028
|
-
}
|
|
4029
|
-
if (currentFeatures & 2048 /* TypedArray */) {
|
|
4030
|
-
switch (currentClass) {
|
|
4031
|
-
case ArrayBuffer:
|
|
4032
|
-
return createArrayBufferNode(id, current);
|
|
4033
|
-
case Int8Array:
|
|
4034
|
-
case Int16Array:
|
|
4035
|
-
case Int32Array:
|
|
4036
|
-
case Uint8Array:
|
|
4037
|
-
case Uint16Array:
|
|
4038
|
-
case Uint32Array:
|
|
4039
|
-
case Uint8ClampedArray:
|
|
4040
|
-
case Float32Array:
|
|
4041
|
-
case Float64Array:
|
|
4042
|
-
return this.parseTypedArray(id, current);
|
|
4043
|
-
case DataView:
|
|
4044
|
-
return this.parseDataView(id, current);
|
|
4045
|
-
default:
|
|
4046
|
-
break;
|
|
4047
|
-
}
|
|
4048
|
-
}
|
|
4049
|
-
if ((currentFeatures & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
4050
|
-
switch (currentClass) {
|
|
4051
|
-
case BigInt64Array:
|
|
4052
|
-
case BigUint64Array:
|
|
4053
|
-
return this.parseBigIntTypedArray(id, current);
|
|
4054
|
-
default:
|
|
4055
|
-
break;
|
|
4056
|
-
}
|
|
4057
|
-
}
|
|
4058
|
-
if (currentFeatures & 32 /* Map */ && currentClass === Map) {
|
|
4059
|
-
return this.parseMap(
|
|
4060
|
-
id,
|
|
4061
|
-
current
|
|
4062
|
-
);
|
|
4063
|
-
}
|
|
4064
|
-
if (currentFeatures & 512 /* Set */ && currentClass === Set) {
|
|
4065
|
-
return this.parseSet(
|
|
4066
|
-
id,
|
|
4067
|
-
current
|
|
4068
|
-
);
|
|
4069
|
-
}
|
|
4070
|
-
if (currentFeatures & 8192 /* WebAPI */) {
|
|
4071
|
-
switch (currentClass) {
|
|
4072
|
-
case (typeof URL !== "undefined" ? URL : UNIVERSAL_SENTINEL):
|
|
4073
|
-
return createURLNode(id, current);
|
|
4074
|
-
case (typeof URLSearchParams !== "undefined" ? URLSearchParams : UNIVERSAL_SENTINEL):
|
|
4075
|
-
return createURLSearchParamsNode(id, current);
|
|
4076
|
-
case (typeof Headers !== "undefined" ? Headers : UNIVERSAL_SENTINEL):
|
|
4077
|
-
return this.parseHeaders(id, current);
|
|
4078
|
-
case (typeof FormData !== "undefined" ? FormData : UNIVERSAL_SENTINEL):
|
|
4079
|
-
return this.parseFormData(id, current);
|
|
4080
|
-
case (typeof ReadableStream !== "undefined" ? ReadableStream : UNIVERSAL_SENTINEL):
|
|
4081
|
-
return this.parseReadableStream(id, current);
|
|
4082
|
-
case (typeof Request !== "undefined" ? Request : UNIVERSAL_SENTINEL):
|
|
4083
|
-
return this.parseRequest(id, current);
|
|
4084
|
-
case (typeof Response !== "undefined" ? Response : UNIVERSAL_SENTINEL):
|
|
4085
|
-
return this.parseResponse(id, current);
|
|
4086
|
-
case (typeof Event !== "undefined" ? Event : UNIVERSAL_SENTINEL):
|
|
4087
|
-
return this.parseEvent(id, current);
|
|
4088
|
-
case (typeof CustomEvent !== "undefined" ? CustomEvent : UNIVERSAL_SENTINEL):
|
|
4089
|
-
return this.parseCustomEvent(id, current);
|
|
4090
|
-
case (typeof DOMException !== "undefined" ? DOMException : UNIVERSAL_SENTINEL):
|
|
4091
|
-
return createDOMExceptionNode(id, current);
|
|
4092
|
-
default:
|
|
4093
|
-
break;
|
|
3428
|
+
parseStream(id, current) {
|
|
3429
|
+
const result = createStreamConstructorNode(
|
|
3430
|
+
id,
|
|
3431
|
+
this.parseSpecialReference(4 /* StreamConstructor */),
|
|
3432
|
+
[]
|
|
3433
|
+
);
|
|
3434
|
+
this.pushPendingState();
|
|
3435
|
+
current.on({
|
|
3436
|
+
next: (value) => {
|
|
3437
|
+
if (this.alive) {
|
|
3438
|
+
const parsed = this.parseWithError(value);
|
|
3439
|
+
if (parsed) {
|
|
3440
|
+
this.onParse(createStreamNextNode(id, parsed));
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
},
|
|
3444
|
+
throw: (value) => {
|
|
3445
|
+
if (this.alive) {
|
|
3446
|
+
const parsed = this.parseWithError(value);
|
|
3447
|
+
if (parsed) {
|
|
3448
|
+
this.onParse(createStreamThrowNode(id, parsed));
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
this.popPendingState();
|
|
3452
|
+
},
|
|
3453
|
+
return: (value) => {
|
|
3454
|
+
if (this.alive) {
|
|
3455
|
+
const parsed = this.parseWithError(value);
|
|
3456
|
+
if (parsed) {
|
|
3457
|
+
this.onParse(createStreamReturnNode(id, parsed));
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
this.popPendingState();
|
|
4094
3461
|
}
|
|
4095
|
-
}
|
|
4096
|
-
|
|
4097
|
-
if (parsed) {
|
|
4098
|
-
return parsed;
|
|
4099
|
-
}
|
|
4100
|
-
if (currentFeatures & 1 /* AggregateError */ && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) {
|
|
4101
|
-
return this.parseAggregateError(id, current);
|
|
4102
|
-
}
|
|
4103
|
-
if (current instanceof Error) {
|
|
4104
|
-
return this.parseError(id, current);
|
|
4105
|
-
}
|
|
4106
|
-
if (currentFeatures & 1024 /* Symbol */ && (Symbol.iterator in current || Symbol.asyncIterator in current)) {
|
|
4107
|
-
return this.parsePlainObject(id, current, !!currentClass);
|
|
4108
|
-
}
|
|
4109
|
-
throw new UnsupportedTypeError(current);
|
|
3462
|
+
});
|
|
3463
|
+
return result;
|
|
4110
3464
|
}
|
|
4111
3465
|
parseWithError(current) {
|
|
4112
3466
|
try {
|
|
@@ -4122,7 +3476,9 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
4122
3476
|
start(current) {
|
|
4123
3477
|
const parsed = this.parseWithError(current);
|
|
4124
3478
|
if (parsed) {
|
|
4125
|
-
this.
|
|
3479
|
+
this.onParseInternal(parsed, true);
|
|
3480
|
+
this.initial = false;
|
|
3481
|
+
this.flush();
|
|
4126
3482
|
if (this.pending <= 0) {
|
|
4127
3483
|
this.destroy();
|
|
4128
3484
|
}
|
|
@@ -4159,63 +3515,65 @@ var CrossSyncParserContext = class extends BaseSyncParserContext {
|
|
|
4159
3515
|
};
|
|
4160
3516
|
|
|
4161
3517
|
// src/core/cross/index.ts
|
|
4162
|
-
function insertCrossReferenceHeader(scopeId, value) {
|
|
4163
|
-
return "(" + getCrossReferenceHeader(scopeId) + "," + value + ")";
|
|
4164
|
-
}
|
|
4165
3518
|
function crossSerialize(source, options = {}) {
|
|
3519
|
+
const plugins = resolvePlugins(options.plugins);
|
|
4166
3520
|
const ctx = new CrossSyncParserContext({
|
|
4167
|
-
plugins
|
|
3521
|
+
plugins,
|
|
4168
3522
|
disabledFeatures: options.disabledFeatures,
|
|
4169
3523
|
refs: options.refs
|
|
4170
3524
|
});
|
|
4171
3525
|
const tree = ctx.parse(source);
|
|
4172
3526
|
const serial = new CrossSerializerContext({
|
|
4173
|
-
plugins
|
|
3527
|
+
plugins,
|
|
4174
3528
|
features: ctx.features,
|
|
4175
3529
|
scopeId: options.scopeId,
|
|
4176
3530
|
markedRefs: ctx.marked
|
|
4177
3531
|
});
|
|
4178
|
-
return
|
|
3532
|
+
return serial.serializeTop(tree);
|
|
4179
3533
|
}
|
|
4180
3534
|
async function crossSerializeAsync(source, options = {}) {
|
|
3535
|
+
const plugins = resolvePlugins(options.plugins);
|
|
4181
3536
|
const ctx = new CrossAsyncParserContext({
|
|
4182
|
-
plugins
|
|
3537
|
+
plugins,
|
|
4183
3538
|
disabledFeatures: options.disabledFeatures,
|
|
4184
3539
|
refs: options.refs
|
|
4185
3540
|
});
|
|
4186
3541
|
const tree = await ctx.parse(source);
|
|
4187
3542
|
const serial = new CrossSerializerContext({
|
|
4188
|
-
plugins
|
|
3543
|
+
plugins,
|
|
4189
3544
|
features: ctx.features,
|
|
4190
3545
|
scopeId: options.scopeId,
|
|
4191
3546
|
markedRefs: ctx.marked
|
|
4192
3547
|
});
|
|
4193
|
-
return
|
|
3548
|
+
return serial.serializeTop(tree);
|
|
4194
3549
|
}
|
|
4195
3550
|
function toCrossJSON(source, options = {}) {
|
|
3551
|
+
const plugins = resolvePlugins(options.plugins);
|
|
4196
3552
|
const ctx = new CrossSyncParserContext({
|
|
4197
|
-
plugins
|
|
3553
|
+
plugins,
|
|
4198
3554
|
disabledFeatures: options.disabledFeatures,
|
|
4199
3555
|
refs: options.refs
|
|
4200
3556
|
});
|
|
4201
3557
|
return ctx.parse(source);
|
|
4202
3558
|
}
|
|
4203
3559
|
async function toCrossJSONAsync(source, options = {}) {
|
|
3560
|
+
const plugins = resolvePlugins(options.plugins);
|
|
4204
3561
|
const ctx = new CrossAsyncParserContext({
|
|
4205
|
-
plugins
|
|
3562
|
+
plugins,
|
|
4206
3563
|
disabledFeatures: options.disabledFeatures,
|
|
4207
3564
|
refs: options.refs
|
|
4208
3565
|
});
|
|
4209
|
-
return ctx.parse(source);
|
|
3566
|
+
return await ctx.parse(source);
|
|
4210
3567
|
}
|
|
4211
3568
|
function crossSerializeStream(source, options) {
|
|
3569
|
+
const plugins = resolvePlugins(options.plugins);
|
|
4212
3570
|
const ctx = new CrossStreamParserContext({
|
|
4213
|
-
plugins
|
|
3571
|
+
plugins,
|
|
4214
3572
|
refs: options.refs,
|
|
4215
3573
|
disabledFeatures: options.disabledFeatures,
|
|
4216
3574
|
onParse(node, initial) {
|
|
4217
3575
|
const serial = new CrossSerializerContext({
|
|
4218
|
-
plugins
|
|
3576
|
+
plugins,
|
|
4219
3577
|
features: ctx.features,
|
|
4220
3578
|
scopeId: options.scopeId,
|
|
4221
3579
|
markedRefs: ctx.marked
|
|
@@ -4229,13 +3587,7 @@ function crossSerializeStream(source, options) {
|
|
|
4229
3587
|
}
|
|
4230
3588
|
return;
|
|
4231
3589
|
}
|
|
4232
|
-
|
|
4233
|
-
serialized = insertCrossReferenceHeader(options.scopeId, serialized);
|
|
4234
|
-
}
|
|
4235
|
-
options.onSerialize(
|
|
4236
|
-
serialized,
|
|
4237
|
-
initial
|
|
4238
|
-
);
|
|
3590
|
+
options.onSerialize(serialized, initial);
|
|
4239
3591
|
},
|
|
4240
3592
|
onError: options.onError,
|
|
4241
3593
|
onDone: options.onDone
|
|
@@ -4246,8 +3598,9 @@ function crossSerializeStream(source, options) {
|
|
|
4246
3598
|
};
|
|
4247
3599
|
}
|
|
4248
3600
|
function toCrossJSONStream(source, options) {
|
|
3601
|
+
const plugins = resolvePlugins(options.plugins);
|
|
4249
3602
|
const ctx = new CrossStreamParserContext({
|
|
4250
|
-
plugins
|
|
3603
|
+
plugins,
|
|
4251
3604
|
refs: options.refs,
|
|
4252
3605
|
disabledFeatures: options.disabledFeatures,
|
|
4253
3606
|
onParse: options.onParse,
|
|
@@ -4260,8 +3613,9 @@ function toCrossJSONStream(source, options) {
|
|
|
4260
3613
|
};
|
|
4261
3614
|
}
|
|
4262
3615
|
function fromCrossJSON(source, options) {
|
|
3616
|
+
const plugins = resolvePlugins(options.plugins);
|
|
4263
3617
|
const ctx = new CrossDeserializerContext({
|
|
4264
|
-
plugins
|
|
3618
|
+
plugins,
|
|
4265
3619
|
refs: options.refs
|
|
4266
3620
|
});
|
|
4267
3621
|
return ctx.deserialize(source);
|
|
@@ -4279,34 +3633,37 @@ var Serializer = class {
|
|
|
4279
3633
|
this.refs = /* @__PURE__ */ new Map();
|
|
4280
3634
|
this.keys = /* @__PURE__ */ new Set();
|
|
4281
3635
|
this.ids = 0;
|
|
3636
|
+
this.plugins = resolvePlugins(options.plugins);
|
|
4282
3637
|
}
|
|
4283
3638
|
write(key, value) {
|
|
4284
3639
|
if (this.alive && !this.flushed) {
|
|
4285
3640
|
this.pending++;
|
|
4286
3641
|
this.keys.add(key);
|
|
4287
|
-
this.cleanups.push(
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
this.
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
this.
|
|
4303
|
-
|
|
4304
|
-
this.options.onDone
|
|
4305
|
-
|
|
3642
|
+
this.cleanups.push(
|
|
3643
|
+
crossSerializeStream(value, {
|
|
3644
|
+
plugins: this.plugins,
|
|
3645
|
+
scopeId: this.options.scopeId,
|
|
3646
|
+
refs: this.refs,
|
|
3647
|
+
disabledFeatures: this.options.disabledFeatures,
|
|
3648
|
+
onError: this.options.onError,
|
|
3649
|
+
onSerialize: (data, initial) => {
|
|
3650
|
+
if (this.alive) {
|
|
3651
|
+
this.options.onData(
|
|
3652
|
+
initial ? this.options.globalIdentifier + '["' + serializeString(key) + '"]=' + data : data
|
|
3653
|
+
);
|
|
3654
|
+
}
|
|
3655
|
+
},
|
|
3656
|
+
onDone: () => {
|
|
3657
|
+
if (this.alive) {
|
|
3658
|
+
this.pending--;
|
|
3659
|
+
if (this.pending <= 0 && this.flushed && !this.done && this.options.onDone) {
|
|
3660
|
+
this.options.onDone();
|
|
3661
|
+
this.done = true;
|
|
3662
|
+
}
|
|
4306
3663
|
}
|
|
4307
3664
|
}
|
|
4308
|
-
}
|
|
4309
|
-
|
|
3665
|
+
})
|
|
3666
|
+
);
|
|
4310
3667
|
}
|
|
4311
3668
|
}
|
|
4312
3669
|
getNextID() {
|
|
@@ -4342,12 +3699,4 @@ var Serializer = class {
|
|
|
4342
3699
|
}
|
|
4343
3700
|
}
|
|
4344
3701
|
};
|
|
4345
|
-
|
|
4346
|
-
// src/core/plugin.ts
|
|
4347
|
-
function createPlugin(plugin) {
|
|
4348
|
-
return plugin;
|
|
4349
|
-
}
|
|
4350
|
-
|
|
4351
|
-
// src/index.ts
|
|
4352
|
-
var src_default = serialize;
|
|
4353
3702
|
//# sourceMappingURL=index.cjs.map
|