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