gitxp 0.0.1
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/.output/nitro.json +17 -0
- package/.output/public/assets/index-BGHvBNtP.js +11 -0
- package/.output/public/assets/routes-DuE8S6pX.js +60 -0
- package/.output/public/assets/styles-D5xbQNYu.css +1 -0
- package/.output/server/_chunks/ssr-renderer.mjs +26 -0
- package/.output/server/_libs/@floating-ui/core+[...].mjs +671 -0
- package/.output/server/_libs/@floating-ui/dom+[...].mjs +649 -0
- package/.output/server/_libs/@floating-ui/react-dom+[...].mjs +856 -0
- package/.output/server/_libs/@radix-ui/react-arrow+[...].mjs +258 -0
- package/.output/server/_libs/@radix-ui/react-dialog+[...].mjs +1862 -0
- package/.output/server/_libs/@radix-ui/react-popper+[...].mjs +320 -0
- package/.output/server/_libs/@radix-ui/react-tooltip+[...].mjs +534 -0
- package/.output/server/_libs/@tanstack/db+[...].mjs +14680 -0
- package/.output/server/_libs/@tanstack/react-router+[...].mjs +14563 -0
- package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +126 -0
- package/.output/server/_libs/@tanstack/router-core+[...].mjs +3636 -0
- package/.output/server/_libs/class-variance-authority+clsx.mjs +69 -0
- package/.output/server/_libs/cmdk.mjs +504 -0
- package/.output/server/_libs/h3+rou3+srvx.mjs +1361 -0
- package/.output/server/_libs/h3-v2.mjs +285 -0
- package/.output/server/_libs/lucide-react.mjs +158 -0
- package/.output/server/_libs/radix-ui__primitive.mjs +44 -0
- package/.output/server/_libs/radix-ui__react-context.mjs +108 -0
- package/.output/server/_libs/tailwind-merge.mjs +3380 -0
- package/.output/server/_libs/tanstack__history.mjs +384 -0
- package/.output/server/_libs/tanstack__query-core.mjs +2225 -0
- package/.output/server/_libs/tanstack__react-db.mjs +242 -0
- package/.output/server/_libs/tanstack__react-query.mjs +140 -0
- package/.output/server/_libs/ufo.mjs +64 -0
- package/.output/server/_runtime.mjs +35 -0
- package/.output/server/_ssr/empty-plugin-adapters-D9UWiqvJ.mjs +5 -0
- package/.output/server/_ssr/events-BNrmOvgU.mjs +13 -0
- package/.output/server/_ssr/notifications-DUoENv6E.mjs +514 -0
- package/.output/server/_ssr/router-DsUHD4bT.mjs +179 -0
- package/.output/server/_ssr/routes-DIFfr242.mjs +982 -0
- package/.output/server/_ssr/ssr.mjs +1854 -0
- package/.output/server/_ssr/start-5Z2QO8AU.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-CrD0YpZr.mjs +20 -0
- package/.output/server/index.mjs +310 -0
- package/.output/server/node_modules/tslib/modules/index.js +70 -0
- package/.output/server/node_modules/tslib/modules/package.json +3 -0
- package/.output/server/node_modules/tslib/package.json +47 -0
- package/.output/server/node_modules/tslib/tslib.js +484 -0
- package/.output/server/package.json +9 -0
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/bin/gitxp.js +85 -0
- package/package.json +92 -0
|
@@ -0,0 +1,3636 @@
|
|
|
1
|
+
import { A as decodePath, C as getStylesheetHref, E as _getRenderedMatches, F as rootRouteId, O as invariant, b as createInlineCssPlaceholderAsset, j as dehydrateSsrMatchId, k as createLRUCache, v as GLOBAL_TSR, x as createInlineCssStyleAsset, y as TSR_SCRIPT_BARRIER_ID } from "./react-router+[...].mjs";
|
|
2
|
+
//#region node_modules/seroval/dist/index.js
|
|
3
|
+
var SYM_ASYNC_ITERATOR = Symbol.asyncIterator;
|
|
4
|
+
var SYM_HAS_INSTANCE = Symbol.hasInstance;
|
|
5
|
+
var SYM_IS_CONCAT_SPREADABLE = Symbol.isConcatSpreadable;
|
|
6
|
+
var SYM_ITERATOR = Symbol.iterator;
|
|
7
|
+
var SYM_MATCH = Symbol.match;
|
|
8
|
+
var SYM_MATCH_ALL = Symbol.matchAll;
|
|
9
|
+
var SYM_REPLACE = Symbol.replace;
|
|
10
|
+
var SYM_SEARCH = Symbol.search;
|
|
11
|
+
var SYM_SPECIES = Symbol.species;
|
|
12
|
+
var SYM_SPLIT = Symbol.split;
|
|
13
|
+
var SYM_TO_PRIMITIVE = Symbol.toPrimitive;
|
|
14
|
+
var SYM_TO_STRING_TAG = Symbol.toStringTag;
|
|
15
|
+
var SYM_UNSCOPABLES = Symbol.unscopables;
|
|
16
|
+
var SYMBOL_STRING = {
|
|
17
|
+
[0]: "Symbol.asyncIterator",
|
|
18
|
+
[1]: "Symbol.hasInstance",
|
|
19
|
+
[2]: "Symbol.isConcatSpreadable",
|
|
20
|
+
[3]: "Symbol.iterator",
|
|
21
|
+
[4]: "Symbol.match",
|
|
22
|
+
[5]: "Symbol.matchAll",
|
|
23
|
+
[6]: "Symbol.replace",
|
|
24
|
+
[7]: "Symbol.search",
|
|
25
|
+
[8]: "Symbol.species",
|
|
26
|
+
[9]: "Symbol.split",
|
|
27
|
+
[10]: "Symbol.toPrimitive",
|
|
28
|
+
[11]: "Symbol.toStringTag",
|
|
29
|
+
[12]: "Symbol.unscopables"
|
|
30
|
+
};
|
|
31
|
+
var INV_SYMBOL_REF = {
|
|
32
|
+
[SYM_ASYNC_ITERATOR]: 0,
|
|
33
|
+
[SYM_HAS_INSTANCE]: 1,
|
|
34
|
+
[SYM_IS_CONCAT_SPREADABLE]: 2,
|
|
35
|
+
[SYM_ITERATOR]: 3,
|
|
36
|
+
[SYM_MATCH]: 4,
|
|
37
|
+
[SYM_MATCH_ALL]: 5,
|
|
38
|
+
[SYM_REPLACE]: 6,
|
|
39
|
+
[SYM_SEARCH]: 7,
|
|
40
|
+
[SYM_SPECIES]: 8,
|
|
41
|
+
[SYM_SPLIT]: 9,
|
|
42
|
+
[SYM_TO_PRIMITIVE]: 10,
|
|
43
|
+
[SYM_TO_STRING_TAG]: 11,
|
|
44
|
+
[SYM_UNSCOPABLES]: 12
|
|
45
|
+
};
|
|
46
|
+
var SYMBOL_REF = {
|
|
47
|
+
[0]: SYM_ASYNC_ITERATOR,
|
|
48
|
+
[1]: SYM_HAS_INSTANCE,
|
|
49
|
+
[2]: SYM_IS_CONCAT_SPREADABLE,
|
|
50
|
+
[3]: SYM_ITERATOR,
|
|
51
|
+
[4]: SYM_MATCH,
|
|
52
|
+
[5]: SYM_MATCH_ALL,
|
|
53
|
+
[6]: SYM_REPLACE,
|
|
54
|
+
[7]: SYM_SEARCH,
|
|
55
|
+
[8]: SYM_SPECIES,
|
|
56
|
+
[9]: SYM_SPLIT,
|
|
57
|
+
[10]: SYM_TO_PRIMITIVE,
|
|
58
|
+
[11]: SYM_TO_STRING_TAG,
|
|
59
|
+
[12]: SYM_UNSCOPABLES
|
|
60
|
+
};
|
|
61
|
+
var CONSTANT_STRING = {
|
|
62
|
+
[2]: "!0",
|
|
63
|
+
[3]: "!1",
|
|
64
|
+
[1]: "void 0",
|
|
65
|
+
[0]: "null",
|
|
66
|
+
[4]: "-0",
|
|
67
|
+
[5]: "1/0",
|
|
68
|
+
[6]: "-1/0",
|
|
69
|
+
[7]: "0/0"
|
|
70
|
+
};
|
|
71
|
+
var CONSTANT_VAL = {
|
|
72
|
+
[2]: true,
|
|
73
|
+
[3]: false,
|
|
74
|
+
[1]: void 0,
|
|
75
|
+
[0]: null,
|
|
76
|
+
[4]: -0,
|
|
77
|
+
[5]: Number.POSITIVE_INFINITY,
|
|
78
|
+
[6]: Number.NEGATIVE_INFINITY,
|
|
79
|
+
[7]: NaN
|
|
80
|
+
};
|
|
81
|
+
var ERROR_CONSTRUCTOR_STRING = {
|
|
82
|
+
[0]: "Error",
|
|
83
|
+
[1]: "EvalError",
|
|
84
|
+
[2]: "RangeError",
|
|
85
|
+
[3]: "ReferenceError",
|
|
86
|
+
[4]: "SyntaxError",
|
|
87
|
+
[5]: "TypeError",
|
|
88
|
+
[6]: "URIError"
|
|
89
|
+
};
|
|
90
|
+
var ERROR_CONSTRUCTOR = {
|
|
91
|
+
[0]: Error,
|
|
92
|
+
[1]: EvalError,
|
|
93
|
+
[2]: RangeError,
|
|
94
|
+
[3]: ReferenceError,
|
|
95
|
+
[4]: SyntaxError,
|
|
96
|
+
[5]: TypeError,
|
|
97
|
+
[6]: URIError
|
|
98
|
+
};
|
|
99
|
+
function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o, l) {
|
|
100
|
+
return {
|
|
101
|
+
t,
|
|
102
|
+
i,
|
|
103
|
+
s,
|
|
104
|
+
c,
|
|
105
|
+
m,
|
|
106
|
+
p,
|
|
107
|
+
e,
|
|
108
|
+
a,
|
|
109
|
+
f,
|
|
110
|
+
b,
|
|
111
|
+
o,
|
|
112
|
+
l
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function createConstantNode(value) {
|
|
116
|
+
return createSerovalNode(2, void 0, value, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
117
|
+
}
|
|
118
|
+
var TRUE_NODE = /* @__PURE__ */ createConstantNode(2);
|
|
119
|
+
var FALSE_NODE = /* @__PURE__ */ createConstantNode(3);
|
|
120
|
+
var UNDEFINED_NODE = /* @__PURE__ */ createConstantNode(1);
|
|
121
|
+
var NULL_NODE = /* @__PURE__ */ createConstantNode(0);
|
|
122
|
+
var NEG_ZERO_NODE = /* @__PURE__ */ createConstantNode(4);
|
|
123
|
+
var INFINITY_NODE = /* @__PURE__ */ createConstantNode(5);
|
|
124
|
+
var NEG_INFINITY_NODE = /* @__PURE__ */ createConstantNode(6);
|
|
125
|
+
var NAN_NODE = /* @__PURE__ */ createConstantNode(7);
|
|
126
|
+
function serializeChar(str) {
|
|
127
|
+
switch (str) {
|
|
128
|
+
case "\"": return "\\\"";
|
|
129
|
+
case "\\": return "\\\\";
|
|
130
|
+
case "\n": return "\\n";
|
|
131
|
+
case "\r": return "\\r";
|
|
132
|
+
case "\b": return "\\b";
|
|
133
|
+
case " ": return "\\t";
|
|
134
|
+
case "\f": return "\\f";
|
|
135
|
+
case "<": return "\\x3C";
|
|
136
|
+
case "\u2028": return "\\u2028";
|
|
137
|
+
case "\u2029": return "\\u2029";
|
|
138
|
+
default: return;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function serializeString(str) {
|
|
142
|
+
let result = "";
|
|
143
|
+
let lastPos = 0;
|
|
144
|
+
let replacement;
|
|
145
|
+
for (let i = 0, len = str.length; i < len; i++) {
|
|
146
|
+
replacement = serializeChar(str[i]);
|
|
147
|
+
if (replacement) {
|
|
148
|
+
result += str.slice(lastPos, i) + replacement;
|
|
149
|
+
lastPos = i + 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (lastPos === 0) result = str;
|
|
153
|
+
else result += str.slice(lastPos);
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
function deserializeReplacer(str) {
|
|
157
|
+
switch (str) {
|
|
158
|
+
case "\\\\": return "\\";
|
|
159
|
+
case "\\\"": return "\"";
|
|
160
|
+
case "\\n": return "\n";
|
|
161
|
+
case "\\r": return "\r";
|
|
162
|
+
case "\\b": return "\b";
|
|
163
|
+
case "\\t": return " ";
|
|
164
|
+
case "\\f": return "\f";
|
|
165
|
+
case "\\x3C": return "<";
|
|
166
|
+
case "\\u2028": return "\u2028";
|
|
167
|
+
case "\\u2029": return "\u2029";
|
|
168
|
+
default: return str;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function deserializeString(str) {
|
|
172
|
+
return str.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g, deserializeReplacer);
|
|
173
|
+
}
|
|
174
|
+
var { toString: objectToString } = Object.prototype;
|
|
175
|
+
var STEP_ERROR_CODES = {
|
|
176
|
+
parsing: 1,
|
|
177
|
+
serialization: 2,
|
|
178
|
+
deserialization: 3
|
|
179
|
+
};
|
|
180
|
+
function getErrorMessageProd(type) {
|
|
181
|
+
return `Seroval Error (step: ${STEP_ERROR_CODES[type]})`;
|
|
182
|
+
}
|
|
183
|
+
var getErrorMessage = (type, cause) => getErrorMessageProd(type);
|
|
184
|
+
var SerovalError = class extends Error {
|
|
185
|
+
constructor(type, cause) {
|
|
186
|
+
super(getErrorMessage(type, cause));
|
|
187
|
+
this.cause = cause;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var SerovalParserError = class extends SerovalError {
|
|
191
|
+
constructor(cause) {
|
|
192
|
+
super("parsing", cause);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var SerovalDeserializationError = class extends SerovalError {
|
|
196
|
+
constructor(cause) {
|
|
197
|
+
super("deserialization", cause);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
function getSpecificErrorMessage(code) {
|
|
201
|
+
return `Seroval Error (specific: ${code})`;
|
|
202
|
+
}
|
|
203
|
+
var SerovalUnsupportedTypeError = class extends Error {
|
|
204
|
+
constructor(value) {
|
|
205
|
+
super(getSpecificErrorMessage(1));
|
|
206
|
+
this.value = value;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var SerovalUnsupportedNodeError = class extends Error {
|
|
210
|
+
constructor(node) {
|
|
211
|
+
super(getSpecificErrorMessage(2));
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
var SerovalMissingPluginError = class extends Error {
|
|
215
|
+
constructor(tag) {
|
|
216
|
+
super(getSpecificErrorMessage(3));
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
var SerovalMissingInstanceError = class extends Error {
|
|
220
|
+
constructor(tag) {
|
|
221
|
+
super(getSpecificErrorMessage(4));
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var SerovalMissingReferenceError = class extends Error {
|
|
225
|
+
constructor(value) {
|
|
226
|
+
super(getSpecificErrorMessage(5));
|
|
227
|
+
this.value = value;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var SerovalMissingReferenceForIdError = class extends Error {
|
|
231
|
+
constructor(id) {
|
|
232
|
+
super(getSpecificErrorMessage(6));
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var SerovalUnknownTypedArrayError = class extends Error {
|
|
236
|
+
constructor(name) {
|
|
237
|
+
super(getSpecificErrorMessage(7));
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
var SerovalMalformedNodeError = class extends Error {
|
|
241
|
+
constructor(node) {
|
|
242
|
+
super(getSpecificErrorMessage(8));
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
var SerovalDepthLimitError = class extends Error {
|
|
246
|
+
constructor(limit) {
|
|
247
|
+
super(getSpecificErrorMessage(9));
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var REFERENCES_KEY = "__SEROVAL_REFS__";
|
|
251
|
+
var GLOBAL_CONTEXT_R = `self.\$R`;
|
|
252
|
+
function getCrossReferenceHeader(id) {
|
|
253
|
+
if (id == null) return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[]`;
|
|
254
|
+
return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(id)}"]=[]`;
|
|
255
|
+
}
|
|
256
|
+
var REFERENCE = /* @__PURE__ */ new Map();
|
|
257
|
+
var INV_REFERENCE = /* @__PURE__ */ new Map();
|
|
258
|
+
function hasReferenceID(value) {
|
|
259
|
+
return REFERENCE.has(value);
|
|
260
|
+
}
|
|
261
|
+
function hasReference(id) {
|
|
262
|
+
return INV_REFERENCE.has(id);
|
|
263
|
+
}
|
|
264
|
+
function getReferenceID(value) {
|
|
265
|
+
if (hasReferenceID(value)) return REFERENCE.get(value);
|
|
266
|
+
throw new SerovalMissingReferenceError(value);
|
|
267
|
+
}
|
|
268
|
+
function getReference(id) {
|
|
269
|
+
if (hasReference(id)) return INV_REFERENCE.get(id);
|
|
270
|
+
throw new SerovalMissingReferenceForIdError(id);
|
|
271
|
+
}
|
|
272
|
+
if (typeof globalThis !== "undefined") Object.defineProperty(globalThis, REFERENCES_KEY, {
|
|
273
|
+
value: INV_REFERENCE,
|
|
274
|
+
configurable: true,
|
|
275
|
+
writable: false,
|
|
276
|
+
enumerable: false
|
|
277
|
+
});
|
|
278
|
+
else if (typeof window !== "undefined") Object.defineProperty(window, REFERENCES_KEY, {
|
|
279
|
+
value: INV_REFERENCE,
|
|
280
|
+
configurable: true,
|
|
281
|
+
writable: false,
|
|
282
|
+
enumerable: false
|
|
283
|
+
});
|
|
284
|
+
else if (typeof self !== "undefined") Object.defineProperty(self, REFERENCES_KEY, {
|
|
285
|
+
value: INV_REFERENCE,
|
|
286
|
+
configurable: true,
|
|
287
|
+
writable: false,
|
|
288
|
+
enumerable: false
|
|
289
|
+
});
|
|
290
|
+
else if (typeof global !== "undefined") Object.defineProperty(global, REFERENCES_KEY, {
|
|
291
|
+
value: INV_REFERENCE,
|
|
292
|
+
configurable: true,
|
|
293
|
+
writable: false,
|
|
294
|
+
enumerable: false
|
|
295
|
+
});
|
|
296
|
+
function getErrorConstructor(error) {
|
|
297
|
+
if (error instanceof EvalError) return 1;
|
|
298
|
+
if (error instanceof RangeError) return 2;
|
|
299
|
+
if (error instanceof ReferenceError) return 3;
|
|
300
|
+
if (error instanceof SyntaxError) return 4;
|
|
301
|
+
if (error instanceof TypeError) return 5;
|
|
302
|
+
if (error instanceof URIError) return 6;
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
function getInitialErrorOptions(error) {
|
|
306
|
+
const construct = ERROR_CONSTRUCTOR_STRING[getErrorConstructor(error)];
|
|
307
|
+
if (error.name !== construct) return { name: error.name };
|
|
308
|
+
if (error.constructor.name !== construct) return { name: error.constructor.name };
|
|
309
|
+
return {};
|
|
310
|
+
}
|
|
311
|
+
function getErrorOptions(error, features) {
|
|
312
|
+
let options = getInitialErrorOptions(error);
|
|
313
|
+
const names = Object.getOwnPropertyNames(error);
|
|
314
|
+
for (let i = 0, len = names.length, name; i < len; i++) {
|
|
315
|
+
name = names[i];
|
|
316
|
+
if (name !== "name" && name !== "message") {
|
|
317
|
+
if (name === "stack") {
|
|
318
|
+
if (features & 4) {
|
|
319
|
+
options = options || {};
|
|
320
|
+
options[name] = error[name];
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
options = options || {};
|
|
324
|
+
options[name] = error[name];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return options;
|
|
329
|
+
}
|
|
330
|
+
function getObjectFlag(obj) {
|
|
331
|
+
if (Object.isFrozen(obj)) return 3;
|
|
332
|
+
if (Object.isSealed(obj)) return 2;
|
|
333
|
+
if (Object.isExtensible(obj)) return 0;
|
|
334
|
+
return 1;
|
|
335
|
+
}
|
|
336
|
+
function createNumberNode(value) {
|
|
337
|
+
switch (value) {
|
|
338
|
+
case Number.POSITIVE_INFINITY: return INFINITY_NODE;
|
|
339
|
+
case Number.NEGATIVE_INFINITY: return NEG_INFINITY_NODE;
|
|
340
|
+
}
|
|
341
|
+
if (value !== value) return NAN_NODE;
|
|
342
|
+
if (Object.is(value, -0)) return NEG_ZERO_NODE;
|
|
343
|
+
return createSerovalNode(0, void 0, value, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
344
|
+
}
|
|
345
|
+
function createStringNode(value) {
|
|
346
|
+
return createSerovalNode(1, void 0, serializeString(value), void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
347
|
+
}
|
|
348
|
+
function createBigIntNode(current) {
|
|
349
|
+
return createSerovalNode(3, void 0, "" + current, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
350
|
+
}
|
|
351
|
+
function createIndexedValueNode(id) {
|
|
352
|
+
return createSerovalNode(4, id, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
353
|
+
}
|
|
354
|
+
function createDateNode(id, current) {
|
|
355
|
+
const timestamp = current.valueOf();
|
|
356
|
+
return createSerovalNode(5, id, timestamp !== timestamp ? "" : current.toISOString(), void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
357
|
+
}
|
|
358
|
+
function createTemporalNode(id, type, current) {
|
|
359
|
+
return createSerovalNode(36, id, current.toString(), type, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
360
|
+
}
|
|
361
|
+
function createRegExpNode(id, current) {
|
|
362
|
+
return createSerovalNode(6, id, void 0, serializeString(current.source), current.flags, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
363
|
+
}
|
|
364
|
+
function createWKSymbolNode(id, current) {
|
|
365
|
+
return createSerovalNode(17, id, INV_SYMBOL_REF[current], void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
366
|
+
}
|
|
367
|
+
function createReferenceNode(id, ref) {
|
|
368
|
+
return createSerovalNode(18, id, serializeString(getReferenceID(ref)), void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
369
|
+
}
|
|
370
|
+
function createPluginNode(id, tag, value) {
|
|
371
|
+
return createSerovalNode(25, id, value, serializeString(tag), void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
372
|
+
}
|
|
373
|
+
function createArrayNode(id, current, parsedItems) {
|
|
374
|
+
return createSerovalNode(9, id, void 0, void 0, void 0, void 0, void 0, parsedItems, void 0, void 0, getObjectFlag(current), void 0);
|
|
375
|
+
}
|
|
376
|
+
function createBoxedNode(id, boxed) {
|
|
377
|
+
return createSerovalNode(21, id, void 0, void 0, void 0, void 0, void 0, void 0, boxed, void 0, void 0, void 0);
|
|
378
|
+
}
|
|
379
|
+
var MAX_TYPED_ARRAY_LENGTH = 1e6;
|
|
380
|
+
function createTypedArrayNode(id, current, buffer) {
|
|
381
|
+
if (current.length > MAX_TYPED_ARRAY_LENGTH) throw new SerovalUnsupportedTypeError(current);
|
|
382
|
+
return createSerovalNode(15, id, void 0, current.constructor.name, void 0, void 0, void 0, void 0, buffer, current.byteOffset, void 0, current.length);
|
|
383
|
+
}
|
|
384
|
+
function createBigIntTypedArrayNode(id, current, buffer) {
|
|
385
|
+
if (current.length > MAX_TYPED_ARRAY_LENGTH) throw new SerovalUnsupportedTypeError(current);
|
|
386
|
+
return createSerovalNode(16, id, void 0, current.constructor.name, void 0, void 0, void 0, void 0, buffer, current.byteOffset, void 0, current.length);
|
|
387
|
+
}
|
|
388
|
+
function createDataViewNode(id, current, buffer) {
|
|
389
|
+
if (current.byteLength > MAX_TYPED_ARRAY_LENGTH) throw new SerovalUnsupportedTypeError(current);
|
|
390
|
+
return createSerovalNode(20, id, void 0, void 0, void 0, void 0, void 0, void 0, buffer, current.byteOffset, void 0, current.byteLength);
|
|
391
|
+
}
|
|
392
|
+
function createErrorNode(id, current, options) {
|
|
393
|
+
return createSerovalNode(13, id, getErrorConstructor(current), void 0, serializeString(current.message), options, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
394
|
+
}
|
|
395
|
+
function createAggregateErrorNode(id, current, options) {
|
|
396
|
+
return createSerovalNode(14, id, getErrorConstructor(current), void 0, serializeString(current.message), options, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
397
|
+
}
|
|
398
|
+
function createSetNode(id, items) {
|
|
399
|
+
return createSerovalNode(7, id, void 0, void 0, void 0, void 0, void 0, items, void 0, void 0, void 0, void 0);
|
|
400
|
+
}
|
|
401
|
+
function createIteratorFactoryInstanceNode(factory, items) {
|
|
402
|
+
return createSerovalNode(28, void 0, void 0, void 0, void 0, void 0, void 0, [factory, items], void 0, void 0, void 0, void 0);
|
|
403
|
+
}
|
|
404
|
+
function createAsyncIteratorFactoryInstanceNode(factory, items) {
|
|
405
|
+
return createSerovalNode(30, void 0, void 0, void 0, void 0, void 0, void 0, [factory, items], void 0, void 0, void 0, void 0);
|
|
406
|
+
}
|
|
407
|
+
function createStreamConstructorNode(id, factory, sequence) {
|
|
408
|
+
return createSerovalNode(31, id, void 0, void 0, void 0, void 0, void 0, sequence, factory, void 0, void 0, void 0);
|
|
409
|
+
}
|
|
410
|
+
function createStreamNextNode(id, parsed) {
|
|
411
|
+
return createSerovalNode(32, id, void 0, void 0, void 0, void 0, void 0, void 0, parsed, void 0, void 0, void 0);
|
|
412
|
+
}
|
|
413
|
+
function createStreamThrowNode(id, parsed) {
|
|
414
|
+
return createSerovalNode(33, id, void 0, void 0, void 0, void 0, void 0, void 0, parsed, void 0, void 0, void 0);
|
|
415
|
+
}
|
|
416
|
+
function createStreamReturnNode(id, parsed) {
|
|
417
|
+
return createSerovalNode(34, id, void 0, void 0, void 0, void 0, void 0, void 0, parsed, void 0, void 0, void 0);
|
|
418
|
+
}
|
|
419
|
+
function createSequenceNode(id, sequence, throwAt, doneAt) {
|
|
420
|
+
return createSerovalNode(35, id, throwAt, void 0, void 0, void 0, void 0, sequence, void 0, void 0, void 0, doneAt);
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* An opaque reference allows hiding values from the serializer.
|
|
424
|
+
*/
|
|
425
|
+
var OpaqueReference = class {
|
|
426
|
+
constructor(value, replacement) {
|
|
427
|
+
this.value = value;
|
|
428
|
+
this.replacement = replacement;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
var PROMISE_CONSTRUCTOR = () => {
|
|
432
|
+
const resolver = {
|
|
433
|
+
p: 0,
|
|
434
|
+
s: 0,
|
|
435
|
+
f: 0
|
|
436
|
+
};
|
|
437
|
+
resolver.p = new Promise((resolve, reject) => {
|
|
438
|
+
resolver.s = resolve;
|
|
439
|
+
resolver.f = reject;
|
|
440
|
+
});
|
|
441
|
+
return resolver;
|
|
442
|
+
};
|
|
443
|
+
var PROMISE_SUCCESS = (resolver, data) => {
|
|
444
|
+
resolver.s(data);
|
|
445
|
+
resolver.p.s = 1;
|
|
446
|
+
resolver.p.v = data;
|
|
447
|
+
};
|
|
448
|
+
var PROMISE_FAILURE = (resolver, data) => {
|
|
449
|
+
resolver.f(data);
|
|
450
|
+
resolver.p.s = 2;
|
|
451
|
+
resolver.p.v = data;
|
|
452
|
+
};
|
|
453
|
+
var SERIALIZED_PROMISE_CONSTRUCTOR = /* @__PURE__ */ PROMISE_CONSTRUCTOR.toString();
|
|
454
|
+
var SERIALIZED_PROMISE_SUCCESS = /* @__PURE__ */ PROMISE_SUCCESS.toString();
|
|
455
|
+
var SERIALIZED_PROMISE_FAILURE = /* @__PURE__ */ PROMISE_FAILURE.toString();
|
|
456
|
+
var STREAM_CONSTRUCTOR = () => {
|
|
457
|
+
const buffer = [];
|
|
458
|
+
const listeners = [];
|
|
459
|
+
let alive = true;
|
|
460
|
+
let success = false;
|
|
461
|
+
let count = 0;
|
|
462
|
+
const internal = {
|
|
463
|
+
flush(value, mode, x) {
|
|
464
|
+
for (x = 0; x < count; x++) if (listeners[x]) listeners[x][mode](value);
|
|
465
|
+
},
|
|
466
|
+
up(listener, x, z, current) {
|
|
467
|
+
for (x = 0, z = buffer.length; x < z; x++) {
|
|
468
|
+
current = buffer[x];
|
|
469
|
+
if (!alive && x === z - 1) listener[success ? "return" : "throw"](current);
|
|
470
|
+
else listener.next(current);
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
on(listener, temp) {
|
|
474
|
+
if (alive) {
|
|
475
|
+
temp = count++;
|
|
476
|
+
listeners[temp] = listener;
|
|
477
|
+
}
|
|
478
|
+
internal.up(listener);
|
|
479
|
+
return () => {
|
|
480
|
+
if (alive) {
|
|
481
|
+
listeners[temp] = listeners[count];
|
|
482
|
+
listeners[count--] = void 0;
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
return {
|
|
488
|
+
__SEROVAL_STREAM__: true,
|
|
489
|
+
on(listener) {
|
|
490
|
+
return internal.on(listener);
|
|
491
|
+
},
|
|
492
|
+
next(value) {
|
|
493
|
+
if (alive) {
|
|
494
|
+
buffer.push(value);
|
|
495
|
+
internal.flush(value, "next");
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
throw(value) {
|
|
499
|
+
if (alive) {
|
|
500
|
+
buffer.push(value);
|
|
501
|
+
internal.flush(value, "throw");
|
|
502
|
+
alive = false;
|
|
503
|
+
success = false;
|
|
504
|
+
listeners.length = 0;
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
return(value) {
|
|
508
|
+
if (alive) {
|
|
509
|
+
buffer.push(value);
|
|
510
|
+
internal.flush(value, "return");
|
|
511
|
+
alive = false;
|
|
512
|
+
success = true;
|
|
513
|
+
listeners.length = 0;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
var SERIALIZED_STREAM_CONSTRUCTOR = /* @__PURE__ */ STREAM_CONSTRUCTOR.toString();
|
|
519
|
+
var ITERATOR_CONSTRUCTOR = (symbol) => (sequence) => () => {
|
|
520
|
+
let index = 0;
|
|
521
|
+
const instance = {
|
|
522
|
+
[symbol]() {
|
|
523
|
+
return instance;
|
|
524
|
+
},
|
|
525
|
+
next() {
|
|
526
|
+
if (index > sequence.d) return {
|
|
527
|
+
done: true,
|
|
528
|
+
value: void 0
|
|
529
|
+
};
|
|
530
|
+
const currentIndex = index++;
|
|
531
|
+
const data = sequence.v[currentIndex];
|
|
532
|
+
if (currentIndex === sequence.t) throw data;
|
|
533
|
+
return {
|
|
534
|
+
done: currentIndex === sequence.d,
|
|
535
|
+
value: data
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
return instance;
|
|
540
|
+
};
|
|
541
|
+
var SERIALIZED_ITERATOR_CONSTRUCTOR = /* @__PURE__ */ ITERATOR_CONSTRUCTOR.toString();
|
|
542
|
+
var ASYNC_ITERATOR_CONSTRUCTOR = (symbol, createPromise) => (stream) => () => {
|
|
543
|
+
let count = 0;
|
|
544
|
+
let doneAt = -1;
|
|
545
|
+
let isThrow = false;
|
|
546
|
+
const buffer = [];
|
|
547
|
+
const pending = [];
|
|
548
|
+
const internal = { finalize(i = 0, len = pending.length) {
|
|
549
|
+
for (; i < len; i++) pending[i].s({
|
|
550
|
+
done: true,
|
|
551
|
+
value: void 0
|
|
552
|
+
});
|
|
553
|
+
} };
|
|
554
|
+
stream.on({
|
|
555
|
+
next(value) {
|
|
556
|
+
const temp = pending.shift();
|
|
557
|
+
if (temp) temp.s({
|
|
558
|
+
done: false,
|
|
559
|
+
value
|
|
560
|
+
});
|
|
561
|
+
buffer.push(value);
|
|
562
|
+
},
|
|
563
|
+
throw(value) {
|
|
564
|
+
const temp = pending.shift();
|
|
565
|
+
if (temp) temp.f(value);
|
|
566
|
+
internal.finalize();
|
|
567
|
+
doneAt = buffer.length;
|
|
568
|
+
isThrow = true;
|
|
569
|
+
buffer.push(value);
|
|
570
|
+
},
|
|
571
|
+
return(value) {
|
|
572
|
+
const temp = pending.shift();
|
|
573
|
+
if (temp) temp.s({
|
|
574
|
+
done: true,
|
|
575
|
+
value
|
|
576
|
+
});
|
|
577
|
+
internal.finalize();
|
|
578
|
+
doneAt = buffer.length;
|
|
579
|
+
buffer.push(value);
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
const instance = {
|
|
583
|
+
[symbol]() {
|
|
584
|
+
return instance;
|
|
585
|
+
},
|
|
586
|
+
next() {
|
|
587
|
+
if (doneAt === -1) {
|
|
588
|
+
const index = count++;
|
|
589
|
+
if (index >= buffer.length) {
|
|
590
|
+
const temp = createPromise();
|
|
591
|
+
pending.push(temp);
|
|
592
|
+
return temp.p;
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
done: false,
|
|
596
|
+
value: buffer[index]
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
if (count > doneAt) return {
|
|
600
|
+
done: true,
|
|
601
|
+
value: void 0
|
|
602
|
+
};
|
|
603
|
+
const index = count++;
|
|
604
|
+
const value = buffer[index];
|
|
605
|
+
if (index !== doneAt) return {
|
|
606
|
+
done: false,
|
|
607
|
+
value
|
|
608
|
+
};
|
|
609
|
+
if (isThrow) throw value;
|
|
610
|
+
return {
|
|
611
|
+
done: true,
|
|
612
|
+
value
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
return instance;
|
|
617
|
+
};
|
|
618
|
+
var SERIALIZED_ASYNC_ITERATOR_CONSTRUCTOR = /* @__PURE__ */ ASYNC_ITERATOR_CONSTRUCTOR.toString();
|
|
619
|
+
var ARRAY_BUFFER_CONSTRUCTOR = (b64) => {
|
|
620
|
+
const decoded = atob(b64);
|
|
621
|
+
const length = decoded.length;
|
|
622
|
+
const arr = new Uint8Array(length);
|
|
623
|
+
for (let i = 0; i < length; i++) arr[i] = decoded.charCodeAt(i);
|
|
624
|
+
return arr.buffer;
|
|
625
|
+
};
|
|
626
|
+
var SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR = /* @__PURE__ */ ARRAY_BUFFER_CONSTRUCTOR.toString();
|
|
627
|
+
function isSequence(value) {
|
|
628
|
+
return "__SEROVAL_SEQUENCE__" in value;
|
|
629
|
+
}
|
|
630
|
+
function createSequence(values, throwAt, doneAt) {
|
|
631
|
+
return {
|
|
632
|
+
__SEROVAL_SEQUENCE__: true,
|
|
633
|
+
v: values,
|
|
634
|
+
t: throwAt,
|
|
635
|
+
d: doneAt
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function createSequenceFromIterable(source) {
|
|
639
|
+
const values = [];
|
|
640
|
+
let throwsAt = -1;
|
|
641
|
+
let doneAt = -1;
|
|
642
|
+
const iterator = source[SYM_ITERATOR]();
|
|
643
|
+
while (true) try {
|
|
644
|
+
const value = iterator.next();
|
|
645
|
+
values.push(value.value);
|
|
646
|
+
if (value.done) {
|
|
647
|
+
doneAt = values.length - 1;
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
} catch (error) {
|
|
651
|
+
throwsAt = values.length;
|
|
652
|
+
values.push(error);
|
|
653
|
+
}
|
|
654
|
+
return createSequence(values, throwsAt, doneAt);
|
|
655
|
+
}
|
|
656
|
+
var createIterator = ITERATOR_CONSTRUCTOR(SYM_ITERATOR);
|
|
657
|
+
function sequenceToIterator(sequence) {
|
|
658
|
+
return createIterator(sequence);
|
|
659
|
+
}
|
|
660
|
+
var ITERATOR = {};
|
|
661
|
+
var ASYNC_ITERATOR = {};
|
|
662
|
+
/**
|
|
663
|
+
* Placeholder references
|
|
664
|
+
*/
|
|
665
|
+
var SPECIAL_REFS = {
|
|
666
|
+
[0]: {},
|
|
667
|
+
[1]: {},
|
|
668
|
+
[2]: {},
|
|
669
|
+
[3]: {},
|
|
670
|
+
[4]: {},
|
|
671
|
+
[5]: {}
|
|
672
|
+
};
|
|
673
|
+
var SPECIAL_REF_STRING = {
|
|
674
|
+
[0]: "[]",
|
|
675
|
+
[1]: SERIALIZED_PROMISE_CONSTRUCTOR,
|
|
676
|
+
[2]: SERIALIZED_PROMISE_SUCCESS,
|
|
677
|
+
[3]: SERIALIZED_PROMISE_FAILURE,
|
|
678
|
+
[4]: SERIALIZED_STREAM_CONSTRUCTOR,
|
|
679
|
+
[5]: SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR
|
|
680
|
+
};
|
|
681
|
+
function isStream(value) {
|
|
682
|
+
return "__SEROVAL_STREAM__" in value;
|
|
683
|
+
}
|
|
684
|
+
function createStream() {
|
|
685
|
+
return STREAM_CONSTRUCTOR();
|
|
686
|
+
}
|
|
687
|
+
function createStreamFromAsyncIterable(iterable) {
|
|
688
|
+
const stream = createStream();
|
|
689
|
+
const iterator = iterable[SYM_ASYNC_ITERATOR]();
|
|
690
|
+
async function push() {
|
|
691
|
+
try {
|
|
692
|
+
const value = await iterator.next();
|
|
693
|
+
if (value.done) stream.return(value.value);
|
|
694
|
+
else {
|
|
695
|
+
stream.next(value.value);
|
|
696
|
+
await push();
|
|
697
|
+
}
|
|
698
|
+
} catch (error) {
|
|
699
|
+
stream.throw(error);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
push().catch(() => {});
|
|
703
|
+
return stream;
|
|
704
|
+
}
|
|
705
|
+
var createAsyncIterable = ASYNC_ITERATOR_CONSTRUCTOR(SYM_ASYNC_ITERATOR, PROMISE_CONSTRUCTOR);
|
|
706
|
+
function streamToAsyncIterable(stream) {
|
|
707
|
+
return createAsyncIterable(stream);
|
|
708
|
+
}
|
|
709
|
+
async function promiseToResult(current) {
|
|
710
|
+
try {
|
|
711
|
+
return [1, await current];
|
|
712
|
+
} catch (e) {
|
|
713
|
+
return [0, e];
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
function createBaseParserContext(mode, options) {
|
|
717
|
+
return {
|
|
718
|
+
plugins: options.plugins,
|
|
719
|
+
mode,
|
|
720
|
+
marked: /* @__PURE__ */ new Set(),
|
|
721
|
+
features: 127 ^ (options.disabledFeatures || 0),
|
|
722
|
+
refs: options.refs || /* @__PURE__ */ new Map(),
|
|
723
|
+
depthLimit: options.depthLimit || 1e3
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Ensures that the value (based on an identifier) has been visited by the parser.
|
|
728
|
+
* @param ctx
|
|
729
|
+
* @param id
|
|
730
|
+
*/
|
|
731
|
+
function markParserRef(ctx, id) {
|
|
732
|
+
ctx.marked.add(id);
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Creates an identifier for a value
|
|
736
|
+
* @param ctx
|
|
737
|
+
* @param current
|
|
738
|
+
*/
|
|
739
|
+
function createIndexForValue(ctx, current) {
|
|
740
|
+
const id = ctx.refs.size;
|
|
741
|
+
ctx.refs.set(current, id);
|
|
742
|
+
return id;
|
|
743
|
+
}
|
|
744
|
+
function getNodeForIndexedValue(ctx, current) {
|
|
745
|
+
const registeredId = ctx.refs.get(current);
|
|
746
|
+
if (registeredId != null) {
|
|
747
|
+
markParserRef(ctx, registeredId);
|
|
748
|
+
return {
|
|
749
|
+
type: 1,
|
|
750
|
+
value: createIndexedValueNode(registeredId)
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
return {
|
|
754
|
+
type: 0,
|
|
755
|
+
value: createIndexForValue(ctx, current)
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function getReferenceNode(ctx, current) {
|
|
759
|
+
const indexed = getNodeForIndexedValue(ctx, current);
|
|
760
|
+
if (indexed.type === 1) return indexed;
|
|
761
|
+
if (hasReferenceID(current)) return {
|
|
762
|
+
type: 2,
|
|
763
|
+
value: createReferenceNode(indexed.value, current)
|
|
764
|
+
};
|
|
765
|
+
return indexed;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Parsing methods
|
|
769
|
+
*/
|
|
770
|
+
function parseWellKnownSymbol(ctx, current) {
|
|
771
|
+
const ref = getReferenceNode(ctx, current);
|
|
772
|
+
if (ref.type !== 0) return ref.value;
|
|
773
|
+
if (current in INV_SYMBOL_REF) return createWKSymbolNode(ref.value, current);
|
|
774
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
775
|
+
}
|
|
776
|
+
function parseSpecialReference(ctx, ref) {
|
|
777
|
+
const result = getNodeForIndexedValue(ctx, SPECIAL_REFS[ref]);
|
|
778
|
+
if (result.type === 1) return result.value;
|
|
779
|
+
return createSerovalNode(26, result.value, ref, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0);
|
|
780
|
+
}
|
|
781
|
+
function parseIteratorFactory(ctx) {
|
|
782
|
+
const result = getNodeForIndexedValue(ctx, ITERATOR);
|
|
783
|
+
if (result.type === 1) return result.value;
|
|
784
|
+
return createSerovalNode(27, result.value, void 0, void 0, void 0, void 0, void 0, void 0, parseWellKnownSymbol(ctx, SYM_ITERATOR), void 0, void 0, void 0);
|
|
785
|
+
}
|
|
786
|
+
function parseAsyncIteratorFactory(ctx) {
|
|
787
|
+
const result = getNodeForIndexedValue(ctx, ASYNC_ITERATOR);
|
|
788
|
+
if (result.type === 1) return result.value;
|
|
789
|
+
return createSerovalNode(29, result.value, void 0, void 0, void 0, void 0, void 0, [parseSpecialReference(ctx, 1), parseWellKnownSymbol(ctx, SYM_ASYNC_ITERATOR)], void 0, void 0, void 0, void 0);
|
|
790
|
+
}
|
|
791
|
+
function createObjectNode(id, current, empty, record) {
|
|
792
|
+
return createSerovalNode(empty ? 11 : 10, id, void 0, void 0, void 0, record, void 0, void 0, void 0, void 0, getObjectFlag(current), void 0);
|
|
793
|
+
}
|
|
794
|
+
function createMapNode(ctx, id, k, v) {
|
|
795
|
+
return createSerovalNode(8, id, void 0, void 0, void 0, void 0, {
|
|
796
|
+
k,
|
|
797
|
+
v
|
|
798
|
+
}, void 0, parseSpecialReference(ctx, 0), void 0, void 0, void 0);
|
|
799
|
+
}
|
|
800
|
+
function createPromiseConstructorNode(ctx, id, resolver) {
|
|
801
|
+
return createSerovalNode(22, id, resolver, void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 1), void 0, void 0, void 0);
|
|
802
|
+
}
|
|
803
|
+
function createArrayBufferNode(ctx, id, current) {
|
|
804
|
+
const bytes = new Uint8Array(current);
|
|
805
|
+
let result = "";
|
|
806
|
+
for (let i = 0, len = bytes.length; i < len; i++) result += String.fromCharCode(bytes[i]);
|
|
807
|
+
return createSerovalNode(19, id, serializeString(btoa(result)), void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 5), void 0, void 0, void 0);
|
|
808
|
+
}
|
|
809
|
+
function createAsyncParserContext(mode, options) {
|
|
810
|
+
return {
|
|
811
|
+
base: createBaseParserContext(mode, options),
|
|
812
|
+
child: void 0
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
var AsyncParsePluginContext = class {
|
|
816
|
+
constructor(_p, depth) {
|
|
817
|
+
this._p = _p;
|
|
818
|
+
this.depth = depth;
|
|
819
|
+
}
|
|
820
|
+
parse(current) {
|
|
821
|
+
return parseAsync(this._p, this.depth, current);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
async function parseItems$1(ctx, depth, current) {
|
|
825
|
+
const nodes = [];
|
|
826
|
+
for (let i = 0, len = current.length; i < len; i++) if (i in current) nodes[i] = await parseAsync(ctx, depth, current[i]);
|
|
827
|
+
else nodes[i] = 0;
|
|
828
|
+
return nodes;
|
|
829
|
+
}
|
|
830
|
+
async function parseArray$1(ctx, depth, id, current) {
|
|
831
|
+
return createArrayNode(id, current, await parseItems$1(ctx, depth, current));
|
|
832
|
+
}
|
|
833
|
+
async function parseProperties$1(ctx, depth, properties) {
|
|
834
|
+
const entries = Object.entries(properties);
|
|
835
|
+
const keyNodes = [];
|
|
836
|
+
const valueNodes = [];
|
|
837
|
+
for (let i = 0, len = entries.length; i < len; i++) {
|
|
838
|
+
keyNodes.push(serializeString(entries[i][0]));
|
|
839
|
+
valueNodes.push(await parseAsync(ctx, depth, entries[i][1]));
|
|
840
|
+
}
|
|
841
|
+
if (SYM_ITERATOR in properties) {
|
|
842
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ITERATOR));
|
|
843
|
+
valueNodes.push(createIteratorFactoryInstanceNode(parseIteratorFactory(ctx.base), await parseAsync(ctx, depth, createSequenceFromIterable(properties))));
|
|
844
|
+
}
|
|
845
|
+
if (SYM_ASYNC_ITERATOR in properties) {
|
|
846
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ASYNC_ITERATOR));
|
|
847
|
+
valueNodes.push(createAsyncIteratorFactoryInstanceNode(parseAsyncIteratorFactory(ctx.base), await parseAsync(ctx, depth, createStreamFromAsyncIterable(properties))));
|
|
848
|
+
}
|
|
849
|
+
if (SYM_TO_STRING_TAG in properties) {
|
|
850
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_TO_STRING_TAG));
|
|
851
|
+
valueNodes.push(createStringNode(properties[SYM_TO_STRING_TAG]));
|
|
852
|
+
}
|
|
853
|
+
if (SYM_IS_CONCAT_SPREADABLE in properties) {
|
|
854
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_IS_CONCAT_SPREADABLE));
|
|
855
|
+
valueNodes.push(properties[SYM_IS_CONCAT_SPREADABLE] ? TRUE_NODE : FALSE_NODE);
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
k: keyNodes,
|
|
859
|
+
v: valueNodes
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
async function parsePlainObject$1(ctx, depth, id, current, empty) {
|
|
863
|
+
return createObjectNode(id, current, empty, await parseProperties$1(ctx, depth, current));
|
|
864
|
+
}
|
|
865
|
+
async function parseBoxed$1(ctx, depth, id, current) {
|
|
866
|
+
return createBoxedNode(id, await parseAsync(ctx, depth, current.valueOf()));
|
|
867
|
+
}
|
|
868
|
+
async function parseTypedArray$1(ctx, depth, id, current) {
|
|
869
|
+
return createTypedArrayNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
870
|
+
}
|
|
871
|
+
async function parseBigIntTypedArray$1(ctx, depth, id, current) {
|
|
872
|
+
return createBigIntTypedArrayNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
873
|
+
}
|
|
874
|
+
async function parseDataView$1(ctx, depth, id, current) {
|
|
875
|
+
return createDataViewNode(id, current, await parseAsync(ctx, depth, current.buffer));
|
|
876
|
+
}
|
|
877
|
+
async function parseError$1(ctx, depth, id, current) {
|
|
878
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
879
|
+
return createErrorNode(id, current, options ? await parseProperties$1(ctx, depth, options) : void 0);
|
|
880
|
+
}
|
|
881
|
+
async function parseAggregateError$1(ctx, depth, id, current) {
|
|
882
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
883
|
+
return createAggregateErrorNode(id, current, options ? await parseProperties$1(ctx, depth, options) : void 0);
|
|
884
|
+
}
|
|
885
|
+
async function parseMap$1(ctx, depth, id, current) {
|
|
886
|
+
const keyNodes = [];
|
|
887
|
+
const valueNodes = [];
|
|
888
|
+
for (const [key, value] of current.entries()) {
|
|
889
|
+
keyNodes.push(await parseAsync(ctx, depth, key));
|
|
890
|
+
valueNodes.push(await parseAsync(ctx, depth, value));
|
|
891
|
+
}
|
|
892
|
+
return createMapNode(ctx.base, id, keyNodes, valueNodes);
|
|
893
|
+
}
|
|
894
|
+
async function parseSet$1(ctx, depth, id, current) {
|
|
895
|
+
const items = [];
|
|
896
|
+
for (const item of current.keys()) items.push(await parseAsync(ctx, depth, item));
|
|
897
|
+
return createSetNode(id, items);
|
|
898
|
+
}
|
|
899
|
+
async function parsePlugin$1(ctx, depth, id, current) {
|
|
900
|
+
const currentPlugins = ctx.base.plugins;
|
|
901
|
+
if (currentPlugins) for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
902
|
+
const plugin = currentPlugins[i];
|
|
903
|
+
if (plugin.parse.async && plugin.test(current)) return createPluginNode(id, plugin.tag, await plugin.parse.async(current, new AsyncParsePluginContext(ctx, depth), { id }));
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
async function parsePromise$1(ctx, depth, id, current) {
|
|
907
|
+
const [status, result] = await promiseToResult(current);
|
|
908
|
+
return createSerovalNode(12, id, status, void 0, void 0, void 0, void 0, void 0, await parseAsync(ctx, depth, result), void 0, void 0, void 0);
|
|
909
|
+
}
|
|
910
|
+
function parseStreamHandle(depth, id, current, resolve, reject) {
|
|
911
|
+
const sequence = [];
|
|
912
|
+
const cleanup = current.on({
|
|
913
|
+
next: (value) => {
|
|
914
|
+
markParserRef(this.base, id);
|
|
915
|
+
parseAsync(this, depth, value).then((data) => {
|
|
916
|
+
sequence.push(createStreamNextNode(id, data));
|
|
917
|
+
}, (data) => {
|
|
918
|
+
reject(data);
|
|
919
|
+
cleanup();
|
|
920
|
+
});
|
|
921
|
+
},
|
|
922
|
+
throw: (value) => {
|
|
923
|
+
markParserRef(this.base, id);
|
|
924
|
+
parseAsync(this, depth, value).then((data) => {
|
|
925
|
+
sequence.push(createStreamThrowNode(id, data));
|
|
926
|
+
resolve(sequence);
|
|
927
|
+
cleanup();
|
|
928
|
+
}, (data) => {
|
|
929
|
+
reject(data);
|
|
930
|
+
cleanup();
|
|
931
|
+
});
|
|
932
|
+
},
|
|
933
|
+
return: (value) => {
|
|
934
|
+
markParserRef(this.base, id);
|
|
935
|
+
parseAsync(this, depth, value).then((data) => {
|
|
936
|
+
sequence.push(createStreamReturnNode(id, data));
|
|
937
|
+
resolve(sequence);
|
|
938
|
+
cleanup();
|
|
939
|
+
}, (data) => {
|
|
940
|
+
reject(data);
|
|
941
|
+
cleanup();
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
async function parseStream$1(ctx, depth, id, current) {
|
|
947
|
+
return createStreamConstructorNode(id, parseSpecialReference(ctx.base, 4), await new Promise(parseStreamHandle.bind(ctx, depth, id, current)));
|
|
948
|
+
}
|
|
949
|
+
async function parseSequence$1(ctx, depth, id, current) {
|
|
950
|
+
const nodes = [];
|
|
951
|
+
for (let i = 0, len = current.v.length; i < len; i++) nodes[i] = await parseAsync(ctx, depth, current.v[i]);
|
|
952
|
+
return createSequenceNode(id, nodes, current.t, current.d);
|
|
953
|
+
}
|
|
954
|
+
async function parseObjectAsync(ctx, depth, id, current) {
|
|
955
|
+
if (Array.isArray(current)) return parseArray$1(ctx, depth, id, current);
|
|
956
|
+
if (isStream(current)) return parseStream$1(ctx, depth, id, current);
|
|
957
|
+
if (isSequence(current)) return parseSequence$1(ctx, depth, id, current);
|
|
958
|
+
let currentClass = current.constructor;
|
|
959
|
+
if (currentClass !== void 0 && typeof currentClass !== "function") {
|
|
960
|
+
const proto = Object.getPrototypeOf(current);
|
|
961
|
+
currentClass = proto === null ? void 0 : proto.constructor;
|
|
962
|
+
}
|
|
963
|
+
if (currentClass === OpaqueReference) return parseAsync(ctx, depth, current.replacement);
|
|
964
|
+
const parsed = await parsePlugin$1(ctx, depth, id, current);
|
|
965
|
+
if (parsed) return parsed;
|
|
966
|
+
switch (currentClass) {
|
|
967
|
+
case Object: return parsePlainObject$1(ctx, depth, id, current, false);
|
|
968
|
+
case void 0: return parsePlainObject$1(ctx, depth, id, current, true);
|
|
969
|
+
case Date: return createDateNode(id, current);
|
|
970
|
+
case Error:
|
|
971
|
+
case EvalError:
|
|
972
|
+
case RangeError:
|
|
973
|
+
case ReferenceError:
|
|
974
|
+
case SyntaxError:
|
|
975
|
+
case TypeError:
|
|
976
|
+
case URIError: return parseError$1(ctx, depth, id, current);
|
|
977
|
+
case Number:
|
|
978
|
+
case Boolean:
|
|
979
|
+
case String:
|
|
980
|
+
case BigInt: return parseBoxed$1(ctx, depth, id, current);
|
|
981
|
+
case ArrayBuffer: return createArrayBufferNode(ctx.base, id, current);
|
|
982
|
+
case Int8Array:
|
|
983
|
+
case Int16Array:
|
|
984
|
+
case Int32Array:
|
|
985
|
+
case Uint8Array:
|
|
986
|
+
case Uint16Array:
|
|
987
|
+
case Uint32Array:
|
|
988
|
+
case Uint8ClampedArray:
|
|
989
|
+
case Float32Array:
|
|
990
|
+
case Float64Array: return parseTypedArray$1(ctx, depth, id, current);
|
|
991
|
+
case DataView: return parseDataView$1(ctx, depth, id, current);
|
|
992
|
+
case Map: return parseMap$1(ctx, depth, id, current);
|
|
993
|
+
case Set: return parseSet$1(ctx, depth, id, current);
|
|
994
|
+
}
|
|
995
|
+
if (currentClass === Promise || current instanceof Promise) return parsePromise$1(ctx, depth, id, current);
|
|
996
|
+
const currentFeatures = ctx.base.features;
|
|
997
|
+
if (currentFeatures & 32 && currentClass === RegExp) return createRegExpNode(id, current);
|
|
998
|
+
if (currentFeatures & 16) switch (currentClass) {
|
|
999
|
+
case BigInt64Array:
|
|
1000
|
+
case BigUint64Array: return parseBigIntTypedArray$1(ctx, depth, id, current);
|
|
1001
|
+
}
|
|
1002
|
+
if (currentFeatures & 1 && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) return parseAggregateError$1(ctx, depth, id, current);
|
|
1003
|
+
if (currentFeatures & 64 && typeof Temporal !== "undefined") switch (currentClass) {
|
|
1004
|
+
case Temporal.Instant: return createTemporalNode(id, 0, current);
|
|
1005
|
+
case Temporal.Duration: return createTemporalNode(id, 1, current);
|
|
1006
|
+
case Temporal.PlainDate: return createTemporalNode(id, 2, current);
|
|
1007
|
+
case Temporal.PlainDateTime: return createTemporalNode(id, 3, current);
|
|
1008
|
+
case Temporal.PlainMonthDay: return createTemporalNode(id, 4, current);
|
|
1009
|
+
case Temporal.PlainTime: return createTemporalNode(id, 5, current);
|
|
1010
|
+
case Temporal.PlainYearMonth: return createTemporalNode(id, 6, current);
|
|
1011
|
+
case Temporal.ZonedDateTime: return createTemporalNode(id, 7, current);
|
|
1012
|
+
}
|
|
1013
|
+
if (current instanceof Error) return parseError$1(ctx, depth, id, current);
|
|
1014
|
+
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) return parsePlainObject$1(ctx, depth, id, current, !!currentClass);
|
|
1015
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
1016
|
+
}
|
|
1017
|
+
async function parseFunctionAsync(ctx, depth, current) {
|
|
1018
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
1019
|
+
if (ref.type !== 0) return ref.value;
|
|
1020
|
+
const plugin = await parsePlugin$1(ctx, depth, ref.value, current);
|
|
1021
|
+
if (plugin) return plugin;
|
|
1022
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
1023
|
+
}
|
|
1024
|
+
async function parseAsync(ctx, depth, current) {
|
|
1025
|
+
if (depth >= ctx.base.depthLimit) throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
1026
|
+
switch (typeof current) {
|
|
1027
|
+
case "boolean": return current ? TRUE_NODE : FALSE_NODE;
|
|
1028
|
+
case "undefined": return UNDEFINED_NODE;
|
|
1029
|
+
case "string": return createStringNode(current);
|
|
1030
|
+
case "number": return createNumberNode(current);
|
|
1031
|
+
case "bigint": return createBigIntNode(current);
|
|
1032
|
+
case "object":
|
|
1033
|
+
if (current) {
|
|
1034
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
1035
|
+
return ref.type === 0 ? await parseObjectAsync(ctx, depth + 1, ref.value, current) : ref.value;
|
|
1036
|
+
}
|
|
1037
|
+
return NULL_NODE;
|
|
1038
|
+
case "symbol": return parseWellKnownSymbol(ctx.base, current);
|
|
1039
|
+
case "function": return parseFunctionAsync(ctx, depth, current);
|
|
1040
|
+
default: throw new SerovalUnsupportedTypeError(current);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
async function parseTopAsync(ctx, current) {
|
|
1044
|
+
try {
|
|
1045
|
+
return await parseAsync(ctx, 0, current);
|
|
1046
|
+
} catch (error) {
|
|
1047
|
+
throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
function createPlugin(plugin) {
|
|
1051
|
+
return plugin;
|
|
1052
|
+
}
|
|
1053
|
+
function dedupePlugins(deduped, plugins) {
|
|
1054
|
+
for (let i = 0, len = plugins.length; i < len; i++) {
|
|
1055
|
+
const current = plugins[i];
|
|
1056
|
+
if (!deduped.has(current)) {
|
|
1057
|
+
deduped.add(current);
|
|
1058
|
+
if (current.extends) dedupePlugins(deduped, current.extends);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
function resolvePlugins(plugins) {
|
|
1063
|
+
if (plugins) {
|
|
1064
|
+
const deduped = /* @__PURE__ */ new Set();
|
|
1065
|
+
dedupePlugins(deduped, plugins);
|
|
1066
|
+
return [...deduped];
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
function getTypedArrayConstructor(name) {
|
|
1070
|
+
switch (name) {
|
|
1071
|
+
case "Int8Array": return Int8Array;
|
|
1072
|
+
case "Int16Array": return Int16Array;
|
|
1073
|
+
case "Int32Array": return Int32Array;
|
|
1074
|
+
case "Uint8Array": return Uint8Array;
|
|
1075
|
+
case "Uint16Array": return Uint16Array;
|
|
1076
|
+
case "Uint32Array": return Uint32Array;
|
|
1077
|
+
case "Uint8ClampedArray": return Uint8ClampedArray;
|
|
1078
|
+
case "Float32Array": return Float32Array;
|
|
1079
|
+
case "Float64Array": return Float64Array;
|
|
1080
|
+
case "BigInt64Array": return BigInt64Array;
|
|
1081
|
+
case "BigUint64Array": return BigUint64Array;
|
|
1082
|
+
default: throw new SerovalUnknownTypedArrayError(name);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function isValidKey(key) {
|
|
1086
|
+
switch (key) {
|
|
1087
|
+
case "constructor":
|
|
1088
|
+
case "__proto__":
|
|
1089
|
+
case "prototype":
|
|
1090
|
+
case "__defineGetter__":
|
|
1091
|
+
case "__defineSetter__":
|
|
1092
|
+
case "__lookupGetter__":
|
|
1093
|
+
case "__lookupSetter__": return false;
|
|
1094
|
+
default: return true;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
function isValidSymbol(symbol) {
|
|
1098
|
+
switch (symbol) {
|
|
1099
|
+
case SYM_ASYNC_ITERATOR:
|
|
1100
|
+
case SYM_IS_CONCAT_SPREADABLE:
|
|
1101
|
+
case SYM_TO_STRING_TAG:
|
|
1102
|
+
case SYM_ITERATOR: return true;
|
|
1103
|
+
default: return false;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
var MAX_BASE64_LENGTH = 1e6;
|
|
1107
|
+
var MAX_BIGINT_LENGTH = 1e4;
|
|
1108
|
+
var MAX_REGEXP_SOURCE_LENGTH = 2e4;
|
|
1109
|
+
function applyObjectFlag(obj, flag) {
|
|
1110
|
+
switch (flag) {
|
|
1111
|
+
case 3: return Object.freeze(obj);
|
|
1112
|
+
case 1: return Object.preventExtensions(obj);
|
|
1113
|
+
case 2: return Object.seal(obj);
|
|
1114
|
+
default: return obj;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
var DEFAULT_DEPTH_LIMIT = 1e3;
|
|
1118
|
+
function createBaseDeserializerContext(mode, options) {
|
|
1119
|
+
var _options$features;
|
|
1120
|
+
const refs = options.refs || /* @__PURE__ */ new Map();
|
|
1121
|
+
if (!("types" in refs)) Object.assign(refs, { types: /* @__PURE__ */ new Map() });
|
|
1122
|
+
return {
|
|
1123
|
+
mode,
|
|
1124
|
+
plugins: options.plugins,
|
|
1125
|
+
refs,
|
|
1126
|
+
features: (_options$features = options.features) !== null && _options$features !== void 0 ? _options$features : 127 ^ (options.disabledFeatures || 0),
|
|
1127
|
+
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
function createVanillaDeserializerContext(options) {
|
|
1131
|
+
return {
|
|
1132
|
+
mode: 1,
|
|
1133
|
+
base: createBaseDeserializerContext(1, options),
|
|
1134
|
+
child: void 0,
|
|
1135
|
+
state: { marked: new Set(options.markedRefs) }
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
var DeserializePluginContext = class {
|
|
1139
|
+
constructor(_p, depth) {
|
|
1140
|
+
this._p = _p;
|
|
1141
|
+
this.depth = depth;
|
|
1142
|
+
}
|
|
1143
|
+
deserialize(node) {
|
|
1144
|
+
return deserialize$1(this._p, this.depth, node);
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
function guardIndexedValue(ctx, id) {
|
|
1148
|
+
if (id < 0 || !Number.isFinite(id) || !Number.isInteger(id)) throw new SerovalMalformedNodeError({
|
|
1149
|
+
t: 4,
|
|
1150
|
+
i: id
|
|
1151
|
+
});
|
|
1152
|
+
if (ctx.refs.has(id)) throw new Error("Conflicted ref id: " + id);
|
|
1153
|
+
}
|
|
1154
|
+
function isThennable(value) {
|
|
1155
|
+
return !!value && typeof value === "object" && "then" in value && typeof value.then === "function";
|
|
1156
|
+
}
|
|
1157
|
+
function assignIndexedValueVanilla(ctx, id, value) {
|
|
1158
|
+
guardIndexedValue(ctx.base, id);
|
|
1159
|
+
if (ctx.state.marked.has(id)) ctx.base.refs.set(id, value);
|
|
1160
|
+
return value;
|
|
1161
|
+
}
|
|
1162
|
+
function assignIndexedValueCross(ctx, id, value) {
|
|
1163
|
+
guardIndexedValue(ctx.base, id);
|
|
1164
|
+
ctx.base.refs.set(id, value);
|
|
1165
|
+
return value;
|
|
1166
|
+
}
|
|
1167
|
+
function assignIndexedValue$1(ctx, id, value) {
|
|
1168
|
+
return ctx.mode === 1 ? assignIndexedValueVanilla(ctx, id, value) : assignIndexedValueCross(ctx, id, value);
|
|
1169
|
+
}
|
|
1170
|
+
function deserializeKnownValue(node, record, key) {
|
|
1171
|
+
if (Object.hasOwn(record, key)) return record[key];
|
|
1172
|
+
throw new SerovalMalformedNodeError(node);
|
|
1173
|
+
}
|
|
1174
|
+
function deserializeReference(ctx, node) {
|
|
1175
|
+
return assignIndexedValue$1(ctx, node.i, getReference(deserializeString(node.s)));
|
|
1176
|
+
}
|
|
1177
|
+
function deserializeArray(ctx, depth, node) {
|
|
1178
|
+
const items = node.a;
|
|
1179
|
+
const len = items.length;
|
|
1180
|
+
const result = assignIndexedValue$1(ctx, node.i, new Array(len));
|
|
1181
|
+
for (let i = 0, item; i < len; i++) {
|
|
1182
|
+
item = items[i];
|
|
1183
|
+
if (item) result[i] = deserialize$1(ctx, depth, item);
|
|
1184
|
+
}
|
|
1185
|
+
applyObjectFlag(result, node.o);
|
|
1186
|
+
return result;
|
|
1187
|
+
}
|
|
1188
|
+
function assignStringProperty(object, key, value) {
|
|
1189
|
+
if (isValidKey(key)) object[key] = value;
|
|
1190
|
+
else Object.defineProperty(object, key, {
|
|
1191
|
+
value,
|
|
1192
|
+
configurable: true,
|
|
1193
|
+
enumerable: true,
|
|
1194
|
+
writable: true
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
function assignProperty(ctx, depth, object, key, value) {
|
|
1198
|
+
if (typeof key === "string") assignStringProperty(object, deserializeString(key), deserialize$1(ctx, depth, value));
|
|
1199
|
+
else {
|
|
1200
|
+
const actual = deserialize$1(ctx, depth, key);
|
|
1201
|
+
switch (typeof actual) {
|
|
1202
|
+
case "string":
|
|
1203
|
+
assignStringProperty(object, actual, deserialize$1(ctx, depth, value));
|
|
1204
|
+
break;
|
|
1205
|
+
case "symbol":
|
|
1206
|
+
if (isValidSymbol(actual)) object[actual] = deserialize$1(ctx, depth, value);
|
|
1207
|
+
break;
|
|
1208
|
+
default: throw new SerovalMalformedNodeError(key);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
function assignNodeType(ctx, id, type) {
|
|
1213
|
+
ctx.base.refs.types.set(id, type);
|
|
1214
|
+
}
|
|
1215
|
+
function validateNodeType(ctx, node, id, type) {
|
|
1216
|
+
if (ctx.base.refs.types.get(id) !== type) throw new SerovalMalformedNodeError(node);
|
|
1217
|
+
}
|
|
1218
|
+
function deserializeProperties(ctx, depth, node, result) {
|
|
1219
|
+
const keys = node.k;
|
|
1220
|
+
if (keys.length > 0) for (let i = 0, vals = node.v, len = keys.length; i < len; i++) assignProperty(ctx, depth, result, keys[i], vals[i]);
|
|
1221
|
+
return result;
|
|
1222
|
+
}
|
|
1223
|
+
function deserializeObject(ctx, depth, node) {
|
|
1224
|
+
const result = assignIndexedValue$1(ctx, node.i, node.t === 10 ? {} : Object.create(null));
|
|
1225
|
+
deserializeProperties(ctx, depth, node.p, result);
|
|
1226
|
+
applyObjectFlag(result, node.o);
|
|
1227
|
+
return result;
|
|
1228
|
+
}
|
|
1229
|
+
function deserializeDate(ctx, node) {
|
|
1230
|
+
return assignIndexedValue$1(ctx, node.i, new Date(node.s));
|
|
1231
|
+
}
|
|
1232
|
+
function deserializeTemporal(ctx, node) {
|
|
1233
|
+
if (!(ctx.base.features & 64)) throw new SerovalUnsupportedNodeError(node);
|
|
1234
|
+
let value;
|
|
1235
|
+
switch (node.c) {
|
|
1236
|
+
case 0:
|
|
1237
|
+
value = Temporal.Instant.from(node.s);
|
|
1238
|
+
break;
|
|
1239
|
+
case 1:
|
|
1240
|
+
value = Temporal.Duration.from(node.s);
|
|
1241
|
+
break;
|
|
1242
|
+
case 2:
|
|
1243
|
+
value = Temporal.PlainDate.from(node.s);
|
|
1244
|
+
break;
|
|
1245
|
+
case 3:
|
|
1246
|
+
value = Temporal.PlainDateTime.from(node.s);
|
|
1247
|
+
break;
|
|
1248
|
+
case 4:
|
|
1249
|
+
value = Temporal.PlainMonthDay.from(node.s);
|
|
1250
|
+
break;
|
|
1251
|
+
case 5:
|
|
1252
|
+
value = Temporal.PlainTime.from(node.s);
|
|
1253
|
+
break;
|
|
1254
|
+
case 6:
|
|
1255
|
+
value = Temporal.PlainYearMonth.from(node.s);
|
|
1256
|
+
break;
|
|
1257
|
+
case 7:
|
|
1258
|
+
value = Temporal.ZonedDateTime.from(node.s);
|
|
1259
|
+
break;
|
|
1260
|
+
default: throw new SerovalMalformedNodeError(node);
|
|
1261
|
+
}
|
|
1262
|
+
return assignIndexedValue$1(ctx, node.i, value);
|
|
1263
|
+
}
|
|
1264
|
+
function deserializeRegExp(ctx, node) {
|
|
1265
|
+
if (ctx.base.features & 32) {
|
|
1266
|
+
const source = deserializeString(node.c);
|
|
1267
|
+
if (source.length > MAX_REGEXP_SOURCE_LENGTH) throw new SerovalMalformedNodeError(node);
|
|
1268
|
+
return assignIndexedValue$1(ctx, node.i, new RegExp(source, node.m));
|
|
1269
|
+
}
|
|
1270
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
1271
|
+
}
|
|
1272
|
+
function deserializeSet(ctx, depth, node) {
|
|
1273
|
+
const result = assignIndexedValue$1(ctx, node.i, /* @__PURE__ */ new Set());
|
|
1274
|
+
for (let i = 0, items = node.a, len = items.length; i < len; i++) result.add(deserialize$1(ctx, depth, items[i]));
|
|
1275
|
+
return result;
|
|
1276
|
+
}
|
|
1277
|
+
function deserializeMap(ctx, depth, node) {
|
|
1278
|
+
const result = assignIndexedValue$1(ctx, node.i, /* @__PURE__ */ new Map());
|
|
1279
|
+
for (let i = 0, keys = node.e.k, vals = node.e.v, len = keys.length; i < len; i++) result.set(deserialize$1(ctx, depth, keys[i]), deserialize$1(ctx, depth, vals[i]));
|
|
1280
|
+
return result;
|
|
1281
|
+
}
|
|
1282
|
+
function deserializeArrayBuffer(ctx, node) {
|
|
1283
|
+
if (node.s.length > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
|
|
1284
|
+
return assignIndexedValue$1(ctx, node.i, ARRAY_BUFFER_CONSTRUCTOR(deserializeString(node.s)));
|
|
1285
|
+
}
|
|
1286
|
+
function deserializeTypedArray(ctx, depth, node) {
|
|
1287
|
+
var _node$b;
|
|
1288
|
+
const construct = getTypedArrayConstructor(node.c);
|
|
1289
|
+
const source = deserialize$1(ctx, depth, node.f);
|
|
1290
|
+
if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
|
|
1291
|
+
const offset = (_node$b = node.b) !== null && _node$b !== void 0 ? _node$b : 0;
|
|
1292
|
+
if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
|
|
1293
|
+
return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
|
|
1294
|
+
}
|
|
1295
|
+
function deserializeDataView(ctx, depth, node) {
|
|
1296
|
+
var _node$b2;
|
|
1297
|
+
const source = deserialize$1(ctx, depth, node.f);
|
|
1298
|
+
if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
|
|
1299
|
+
const offset = (_node$b2 = node.b) !== null && _node$b2 !== void 0 ? _node$b2 : 0;
|
|
1300
|
+
if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
|
|
1301
|
+
return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
|
|
1302
|
+
}
|
|
1303
|
+
function deserializeDictionary(ctx, depth, node, result) {
|
|
1304
|
+
if (node.p) {
|
|
1305
|
+
const fields = deserializeProperties(ctx, depth, node.p, {});
|
|
1306
|
+
Object.defineProperties(result, Object.getOwnPropertyDescriptors(fields));
|
|
1307
|
+
}
|
|
1308
|
+
return result;
|
|
1309
|
+
}
|
|
1310
|
+
function deserializeAggregateError(ctx, depth, node) {
|
|
1311
|
+
return deserializeDictionary(ctx, depth, node, assignIndexedValue$1(ctx, node.i, new AggregateError([], deserializeString(node.m))));
|
|
1312
|
+
}
|
|
1313
|
+
function deserializeError(ctx, depth, node) {
|
|
1314
|
+
const construct = deserializeKnownValue(node, ERROR_CONSTRUCTOR, node.s);
|
|
1315
|
+
return deserializeDictionary(ctx, depth, node, assignIndexedValue$1(ctx, node.i, new construct(deserializeString(node.m))));
|
|
1316
|
+
}
|
|
1317
|
+
function deserializePromise(ctx, depth, node) {
|
|
1318
|
+
const deferred = PROMISE_CONSTRUCTOR();
|
|
1319
|
+
const result = assignIndexedValue$1(ctx, node.i, deferred.p);
|
|
1320
|
+
const deserialized = deserialize$1(ctx, depth, node.f);
|
|
1321
|
+
if (isThennable(deserialized)) throw new SerovalMalformedNodeError(node.f);
|
|
1322
|
+
if (node.s) deferred.s(deserialized);
|
|
1323
|
+
else deferred.f(deserialized);
|
|
1324
|
+
return result;
|
|
1325
|
+
}
|
|
1326
|
+
function deserializeBoxed(ctx, depth, node) {
|
|
1327
|
+
return assignIndexedValue$1(ctx, node.i, Object(deserialize$1(ctx, depth, node.f)));
|
|
1328
|
+
}
|
|
1329
|
+
function deserializePlugin(ctx, depth, node) {
|
|
1330
|
+
const currentPlugins = ctx.base.plugins;
|
|
1331
|
+
if (currentPlugins) {
|
|
1332
|
+
const tag = deserializeString(node.c);
|
|
1333
|
+
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
1334
|
+
const plugin = currentPlugins[i];
|
|
1335
|
+
if (plugin.tag === tag) return assignIndexedValue$1(ctx, node.i, plugin.deserialize(node.s, new DeserializePluginContext(ctx, depth), { id: node.i }));
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
throw new SerovalMissingPluginError(node.c);
|
|
1339
|
+
}
|
|
1340
|
+
function deserializePromiseConstructor(ctx, node) {
|
|
1341
|
+
const value = assignIndexedValue$1(ctx, node.i, assignIndexedValue$1(ctx, node.s, PROMISE_CONSTRUCTOR()).p);
|
|
1342
|
+
assignNodeType(ctx, node.s, 22);
|
|
1343
|
+
return value;
|
|
1344
|
+
}
|
|
1345
|
+
function deserializePromiseFulfill(ctx, depth, node) {
|
|
1346
|
+
const deferred = ctx.base.refs.get(node.i);
|
|
1347
|
+
if (deferred) {
|
|
1348
|
+
validateNodeType(ctx, node, node.i, 22);
|
|
1349
|
+
const deserialized = deserialize$1(ctx, depth, node.a[1]);
|
|
1350
|
+
if (isThennable(deserialized)) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1351
|
+
if (node.t === 23) deferred.s(deserialized);
|
|
1352
|
+
else deferred.f(deserialized);
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
throw new SerovalMissingInstanceError("Promise");
|
|
1356
|
+
}
|
|
1357
|
+
function deserializeIteratorFactoryInstance(ctx, depth, node) {
|
|
1358
|
+
deserialize$1(ctx, depth, node.a[0]);
|
|
1359
|
+
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
1360
|
+
if (!source || typeof source !== "object" || !isSequence(source)) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1361
|
+
return sequenceToIterator(source);
|
|
1362
|
+
}
|
|
1363
|
+
function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
|
|
1364
|
+
deserialize$1(ctx, depth, node.a[0]);
|
|
1365
|
+
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
1366
|
+
if (!source || typeof source !== "object" || !isStream(source)) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1367
|
+
return streamToAsyncIterable(source);
|
|
1368
|
+
}
|
|
1369
|
+
function deserializeStreamConstructor(ctx, depth, node) {
|
|
1370
|
+
const result = assignIndexedValue$1(ctx, node.i, createStream());
|
|
1371
|
+
assignNodeType(ctx, node.i, 31);
|
|
1372
|
+
const items = node.a;
|
|
1373
|
+
const len = items.length;
|
|
1374
|
+
if (len) for (let i = 0; i < len; i++) deserialize$1(ctx, depth, items[i]);
|
|
1375
|
+
return result;
|
|
1376
|
+
}
|
|
1377
|
+
function deserializeStreamNext(ctx, depth, node) {
|
|
1378
|
+
const deferred = ctx.base.refs.get(node.i);
|
|
1379
|
+
if (deferred) {
|
|
1380
|
+
validateNodeType(ctx, node, node.i, 31);
|
|
1381
|
+
deferred.next(deserialize$1(ctx, depth, node.f));
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
throw new SerovalMissingInstanceError("Stream");
|
|
1385
|
+
}
|
|
1386
|
+
function deserializeStreamThrow(ctx, depth, node) {
|
|
1387
|
+
const deferred = ctx.base.refs.get(node.i);
|
|
1388
|
+
if (deferred) {
|
|
1389
|
+
validateNodeType(ctx, node, node.i, 31);
|
|
1390
|
+
deferred.throw(deserialize$1(ctx, depth, node.f));
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
throw new SerovalMissingInstanceError("Stream");
|
|
1394
|
+
}
|
|
1395
|
+
function deserializeStreamReturn(ctx, depth, node) {
|
|
1396
|
+
const deferred = ctx.base.refs.get(node.i);
|
|
1397
|
+
if (deferred) {
|
|
1398
|
+
validateNodeType(ctx, node, node.i, 31);
|
|
1399
|
+
deferred.return(deserialize$1(ctx, depth, node.f));
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
throw new SerovalMissingInstanceError("Stream");
|
|
1403
|
+
}
|
|
1404
|
+
function deserializeIteratorFactory(ctx, depth, node) {
|
|
1405
|
+
deserialize$1(ctx, depth, node.f);
|
|
1406
|
+
}
|
|
1407
|
+
function deserializeAsyncIteratorFactory(ctx, depth, node) {
|
|
1408
|
+
deserialize$1(ctx, depth, node.a[1]);
|
|
1409
|
+
}
|
|
1410
|
+
function deserializeSequence(ctx, depth, node) {
|
|
1411
|
+
const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
|
|
1412
|
+
for (let i = 0, len = node.a.length; i < len; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
|
|
1413
|
+
return result;
|
|
1414
|
+
}
|
|
1415
|
+
function deserialize$1(ctx, depth, node) {
|
|
1416
|
+
if (depth > ctx.base.depthLimit) throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
1417
|
+
depth += 1;
|
|
1418
|
+
switch (node.t) {
|
|
1419
|
+
case 2: return deserializeKnownValue(node, CONSTANT_VAL, node.s);
|
|
1420
|
+
case 0: return Number(node.s);
|
|
1421
|
+
case 1: return deserializeString(String(node.s));
|
|
1422
|
+
case 3:
|
|
1423
|
+
if (String(node.s).length > MAX_BIGINT_LENGTH) throw new SerovalMalformedNodeError(node);
|
|
1424
|
+
return BigInt(node.s);
|
|
1425
|
+
case 4: return ctx.base.refs.get(node.i);
|
|
1426
|
+
case 18: return deserializeReference(ctx, node);
|
|
1427
|
+
case 9: return deserializeArray(ctx, depth, node);
|
|
1428
|
+
case 10:
|
|
1429
|
+
case 11: return deserializeObject(ctx, depth, node);
|
|
1430
|
+
case 5: return deserializeDate(ctx, node);
|
|
1431
|
+
case 6: return deserializeRegExp(ctx, node);
|
|
1432
|
+
case 7: return deserializeSet(ctx, depth, node);
|
|
1433
|
+
case 8: return deserializeMap(ctx, depth, node);
|
|
1434
|
+
case 19: return deserializeArrayBuffer(ctx, node);
|
|
1435
|
+
case 16:
|
|
1436
|
+
case 15: return deserializeTypedArray(ctx, depth, node);
|
|
1437
|
+
case 20: return deserializeDataView(ctx, depth, node);
|
|
1438
|
+
case 14: return deserializeAggregateError(ctx, depth, node);
|
|
1439
|
+
case 13: return deserializeError(ctx, depth, node);
|
|
1440
|
+
case 12: return deserializePromise(ctx, depth, node);
|
|
1441
|
+
case 17: return deserializeKnownValue(node, SYMBOL_REF, node.s);
|
|
1442
|
+
case 21: return deserializeBoxed(ctx, depth, node);
|
|
1443
|
+
case 25: return deserializePlugin(ctx, depth, node);
|
|
1444
|
+
case 22: return deserializePromiseConstructor(ctx, node);
|
|
1445
|
+
case 23:
|
|
1446
|
+
case 24: return deserializePromiseFulfill(ctx, depth, node);
|
|
1447
|
+
case 28: return deserializeIteratorFactoryInstance(ctx, depth, node);
|
|
1448
|
+
case 30: return deserializeAsyncIteratorFactoryInstance(ctx, depth, node);
|
|
1449
|
+
case 31: return deserializeStreamConstructor(ctx, depth, node);
|
|
1450
|
+
case 32: return deserializeStreamNext(ctx, depth, node);
|
|
1451
|
+
case 33: return deserializeStreamThrow(ctx, depth, node);
|
|
1452
|
+
case 34: return deserializeStreamReturn(ctx, depth, node);
|
|
1453
|
+
case 27: return deserializeIteratorFactory(ctx, depth, node);
|
|
1454
|
+
case 29: return deserializeAsyncIteratorFactory(ctx, depth, node);
|
|
1455
|
+
case 35: return deserializeSequence(ctx, depth, node);
|
|
1456
|
+
case 36: return deserializeTemporal(ctx, node);
|
|
1457
|
+
default: throw new SerovalUnsupportedNodeError(node);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
function deserializeTop(ctx, node) {
|
|
1461
|
+
try {
|
|
1462
|
+
return deserialize$1(ctx, 0, node);
|
|
1463
|
+
} catch (error) {
|
|
1464
|
+
throw new SerovalDeserializationError(error);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
var RETURN = () => T;
|
|
1468
|
+
var SERIALIZED_RETURN = /* @__PURE__ */ RETURN.toString();
|
|
1469
|
+
var IS_MODERN = /* @__PURE__ */ /=>/.test(SERIALIZED_RETURN);
|
|
1470
|
+
function createFunction(parameters, body) {
|
|
1471
|
+
if (IS_MODERN) return (parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")") + "=>" + (body.startsWith("{") ? "(" + body + ")" : body);
|
|
1472
|
+
return "function(" + parameters.join(",") + "){return " + body + "}";
|
|
1473
|
+
}
|
|
1474
|
+
function createEffectfulFunction(parameters, body) {
|
|
1475
|
+
if (IS_MODERN) return (parameters.length === 1 ? parameters[0] : "(" + parameters.join(",") + ")") + "=>{" + body + "}";
|
|
1476
|
+
return "function(" + parameters.join(",") + "){" + body + "}";
|
|
1477
|
+
}
|
|
1478
|
+
var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
1479
|
+
var REF_START_CHARS_LEN = 34;
|
|
1480
|
+
var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
|
|
1481
|
+
var REF_CHARS_LEN = 64;
|
|
1482
|
+
function getIdentifier(index) {
|
|
1483
|
+
let mod = index % REF_START_CHARS_LEN;
|
|
1484
|
+
let ref = REF_START_CHARS[mod];
|
|
1485
|
+
index = (index - mod) / REF_START_CHARS_LEN;
|
|
1486
|
+
while (index > 0) {
|
|
1487
|
+
mod = index % REF_CHARS_LEN;
|
|
1488
|
+
ref += REF_CHARS[mod];
|
|
1489
|
+
index = (index - mod) / REF_CHARS_LEN;
|
|
1490
|
+
}
|
|
1491
|
+
return ref;
|
|
1492
|
+
}
|
|
1493
|
+
var IDENTIFIER_CHECK = /^[$A-Z_][0-9A-Z_$]*$/i;
|
|
1494
|
+
function isValidIdentifier(name) {
|
|
1495
|
+
const char = name[0];
|
|
1496
|
+
return (char === "$" || char === "_" || char >= "A" && char <= "Z" || char >= "a" && char <= "z") && IDENTIFIER_CHECK.test(name);
|
|
1497
|
+
}
|
|
1498
|
+
function getAssignmentExpression(assignment) {
|
|
1499
|
+
switch (assignment.t) {
|
|
1500
|
+
case 0: return assignment.s + "=" + assignment.v;
|
|
1501
|
+
case 2: return assignment.s + ".set(" + assignment.k + "," + assignment.v + ")";
|
|
1502
|
+
case 1: return assignment.s + ".add(" + assignment.v + ")";
|
|
1503
|
+
case 3: return assignment.s + ".delete(" + assignment.k + ")";
|
|
1504
|
+
case 4: return "Object.defineProperty(" + assignment.s + ",\"__proto__\",{value:" + assignment.k + ",configurable:!0,enumerable:!0,writable:!0})";
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
function mergeAssignments(assignments) {
|
|
1508
|
+
const newAssignments = [];
|
|
1509
|
+
let current = assignments[0];
|
|
1510
|
+
for (let i = 1, len = assignments.length, item, prev = current; i < len; i++) {
|
|
1511
|
+
item = assignments[i];
|
|
1512
|
+
if (item.t === 0 && item.v === prev.v) current = {
|
|
1513
|
+
t: 0,
|
|
1514
|
+
s: item.s,
|
|
1515
|
+
k: void 0,
|
|
1516
|
+
v: getAssignmentExpression(current)
|
|
1517
|
+
};
|
|
1518
|
+
else if (item.t === 2 && item.s === prev.s) current = {
|
|
1519
|
+
t: 2,
|
|
1520
|
+
s: getAssignmentExpression(current),
|
|
1521
|
+
k: item.k,
|
|
1522
|
+
v: item.v
|
|
1523
|
+
};
|
|
1524
|
+
else if (item.t === 1 && item.s === prev.s) current = {
|
|
1525
|
+
t: 1,
|
|
1526
|
+
s: getAssignmentExpression(current),
|
|
1527
|
+
k: void 0,
|
|
1528
|
+
v: item.v
|
|
1529
|
+
};
|
|
1530
|
+
else if (item.t === 3 && item.s === prev.s) current = {
|
|
1531
|
+
t: 3,
|
|
1532
|
+
s: getAssignmentExpression(current),
|
|
1533
|
+
k: item.k,
|
|
1534
|
+
v: void 0
|
|
1535
|
+
};
|
|
1536
|
+
else {
|
|
1537
|
+
newAssignments.push(current);
|
|
1538
|
+
current = item;
|
|
1539
|
+
}
|
|
1540
|
+
prev = item;
|
|
1541
|
+
}
|
|
1542
|
+
newAssignments.push(current);
|
|
1543
|
+
return newAssignments;
|
|
1544
|
+
}
|
|
1545
|
+
function resolveAssignments(assignments) {
|
|
1546
|
+
if (assignments.length) {
|
|
1547
|
+
let result = "";
|
|
1548
|
+
const merged = mergeAssignments(assignments);
|
|
1549
|
+
for (let i = 0, len = merged.length; i < len; i++) result += getAssignmentExpression(merged[i]) + ",";
|
|
1550
|
+
return result;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
var NULL_CONSTRUCTOR = "Object.create(null)";
|
|
1554
|
+
var SET_CONSTRUCTOR = "new Set";
|
|
1555
|
+
var MAP_CONSTRUCTOR = "new Map";
|
|
1556
|
+
var PROMISE_RESOLVE = "Promise.resolve";
|
|
1557
|
+
var PROMISE_REJECT = "Promise.reject";
|
|
1558
|
+
var OBJECT_FLAG_CONSTRUCTOR = {
|
|
1559
|
+
[3]: "Object.freeze",
|
|
1560
|
+
[2]: "Object.seal",
|
|
1561
|
+
[1]: "Object.preventExtensions",
|
|
1562
|
+
[0]: void 0
|
|
1563
|
+
};
|
|
1564
|
+
function createBaseSerializerContext(mode, options) {
|
|
1565
|
+
return {
|
|
1566
|
+
mode,
|
|
1567
|
+
plugins: options.plugins,
|
|
1568
|
+
features: options.features,
|
|
1569
|
+
marked: new Set(options.markedRefs),
|
|
1570
|
+
stack: [],
|
|
1571
|
+
flags: [],
|
|
1572
|
+
assignments: []
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
function createCrossSerializerContext(options) {
|
|
1576
|
+
return {
|
|
1577
|
+
mode: 2,
|
|
1578
|
+
base: createBaseSerializerContext(2, options),
|
|
1579
|
+
state: options,
|
|
1580
|
+
child: void 0
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
var SerializePluginContext = class {
|
|
1584
|
+
constructor(_p) {
|
|
1585
|
+
this._p = _p;
|
|
1586
|
+
}
|
|
1587
|
+
serialize(node) {
|
|
1588
|
+
return serialize$1(this._p, node);
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
/**
|
|
1592
|
+
* Creates the reference param (identifier) from the given reference ID
|
|
1593
|
+
* Calling this function means the value has been referenced somewhere
|
|
1594
|
+
*/
|
|
1595
|
+
function getVanillaRefParam(state, index) {
|
|
1596
|
+
/**
|
|
1597
|
+
* Creates a new reference ID from a given reference ID
|
|
1598
|
+
* This new reference ID means that the reference itself
|
|
1599
|
+
* has been referenced at least once, and is used to generate
|
|
1600
|
+
* the variables
|
|
1601
|
+
*/
|
|
1602
|
+
let actualIndex = state.valid.get(index);
|
|
1603
|
+
if (actualIndex == null) {
|
|
1604
|
+
actualIndex = state.valid.size;
|
|
1605
|
+
state.valid.set(index, actualIndex);
|
|
1606
|
+
}
|
|
1607
|
+
let identifier = state.vars[actualIndex];
|
|
1608
|
+
if (identifier == null) {
|
|
1609
|
+
identifier = getIdentifier(actualIndex);
|
|
1610
|
+
state.vars[actualIndex] = identifier;
|
|
1611
|
+
}
|
|
1612
|
+
return identifier;
|
|
1613
|
+
}
|
|
1614
|
+
function getCrossRefParam(id) {
|
|
1615
|
+
return "$R[" + id + "]";
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Converts the ID of a reference into a identifier string
|
|
1619
|
+
* that is used to refer to the object instance in the
|
|
1620
|
+
* generated script.
|
|
1621
|
+
*/
|
|
1622
|
+
function getRefParam(ctx, id) {
|
|
1623
|
+
return ctx.mode === 1 ? getVanillaRefParam(ctx.state, id) : getCrossRefParam(id);
|
|
1624
|
+
}
|
|
1625
|
+
function markSerializerRef(ctx, id) {
|
|
1626
|
+
ctx.marked.add(id);
|
|
1627
|
+
}
|
|
1628
|
+
function isSerializerRefMarked(ctx, id) {
|
|
1629
|
+
return ctx.marked.has(id);
|
|
1630
|
+
}
|
|
1631
|
+
function pushObjectFlag(ctx, flag, id) {
|
|
1632
|
+
if (flag !== 0) {
|
|
1633
|
+
markSerializerRef(ctx.base, id);
|
|
1634
|
+
ctx.base.flags.push({
|
|
1635
|
+
type: flag,
|
|
1636
|
+
value: getRefParam(ctx, id)
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
function resolveFlags(ctx) {
|
|
1641
|
+
let result = "";
|
|
1642
|
+
for (let i = 0, current = ctx.flags, len = current.length; i < len; i++) {
|
|
1643
|
+
const flag = current[i];
|
|
1644
|
+
result += OBJECT_FLAG_CONSTRUCTOR[flag.type] + "(" + flag.value + "),";
|
|
1645
|
+
}
|
|
1646
|
+
return result;
|
|
1647
|
+
}
|
|
1648
|
+
function resolvePatches(ctx) {
|
|
1649
|
+
const assignments = resolveAssignments(ctx.assignments);
|
|
1650
|
+
const flags = resolveFlags(ctx);
|
|
1651
|
+
if (assignments) {
|
|
1652
|
+
if (flags) return assignments + flags;
|
|
1653
|
+
return assignments;
|
|
1654
|
+
}
|
|
1655
|
+
return flags;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Generates the inlined assignment for the reference
|
|
1659
|
+
* This is different from the assignments array as this one
|
|
1660
|
+
* signifies creation rather than mutation
|
|
1661
|
+
*/
|
|
1662
|
+
function createAssignment(ctx, source, value) {
|
|
1663
|
+
ctx.assignments.push({
|
|
1664
|
+
t: 0,
|
|
1665
|
+
s: source,
|
|
1666
|
+
k: void 0,
|
|
1667
|
+
v: value
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
function createAddAssignment(ctx, ref, value) {
|
|
1671
|
+
ctx.base.assignments.push({
|
|
1672
|
+
t: 1,
|
|
1673
|
+
s: getRefParam(ctx, ref),
|
|
1674
|
+
k: void 0,
|
|
1675
|
+
v: value
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
function createSetAssignment(ctx, ref, key, value) {
|
|
1679
|
+
ctx.base.assignments.push({
|
|
1680
|
+
t: 2,
|
|
1681
|
+
s: getRefParam(ctx, ref),
|
|
1682
|
+
k: key,
|
|
1683
|
+
v: value
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
function createDeleteAssignment(ctx, ref, key) {
|
|
1687
|
+
ctx.base.assignments.push({
|
|
1688
|
+
t: 3,
|
|
1689
|
+
s: getRefParam(ctx, ref),
|
|
1690
|
+
k: key,
|
|
1691
|
+
v: void 0
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
function createArrayAssign(ctx, ref, index, value) {
|
|
1695
|
+
createAssignment(ctx.base, getRefParam(ctx, ref) + "[" + index + "]", value);
|
|
1696
|
+
}
|
|
1697
|
+
function createObjectAssign(ctx, ref, key, value) {
|
|
1698
|
+
if (!isValidKey(key)) {
|
|
1699
|
+
ctx.base.assignments.push({
|
|
1700
|
+
t: 4,
|
|
1701
|
+
s: getRefParam(ctx, ref),
|
|
1702
|
+
k: value,
|
|
1703
|
+
v: void 0
|
|
1704
|
+
});
|
|
1705
|
+
return;
|
|
1706
|
+
}
|
|
1707
|
+
createAssignment(ctx.base, getRefParam(ctx, ref) + "." + key, value);
|
|
1708
|
+
}
|
|
1709
|
+
function createSequenceAssign(ctx, ref, index, value) {
|
|
1710
|
+
createAssignment(ctx.base, getRefParam(ctx, ref) + ".v[" + index + "]", value);
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Checks if the value is in the stack. Stack here is a reference
|
|
1714
|
+
* structure to know if a object is to be accessed in a TDZ.
|
|
1715
|
+
*/
|
|
1716
|
+
function isIndexedValueInStack(ctx, node) {
|
|
1717
|
+
return node.t === 4 && ctx.stack.includes(node.i);
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Produces an assignment expression. `id` generates a reference
|
|
1721
|
+
* parameter (through `getRefParam`) and has the option to
|
|
1722
|
+
* return the reference parameter directly or assign a value to
|
|
1723
|
+
* it.
|
|
1724
|
+
*/
|
|
1725
|
+
function assignIndexedValue(ctx, index, value) {
|
|
1726
|
+
if (ctx.mode === 1 && !isSerializerRefMarked(ctx.base, index)) return value;
|
|
1727
|
+
/**
|
|
1728
|
+
* In cross-reference, we have to assume that
|
|
1729
|
+
* every reference are going to be referenced
|
|
1730
|
+
* in the future, and so we need to store
|
|
1731
|
+
* all of it into the reference array.
|
|
1732
|
+
*
|
|
1733
|
+
* otherwise in vanilla, we only do this if it
|
|
1734
|
+
* is actually referenced
|
|
1735
|
+
*/
|
|
1736
|
+
return getRefParam(ctx, index) + "=" + value;
|
|
1737
|
+
}
|
|
1738
|
+
function serializeReference(node) {
|
|
1739
|
+
return "__SEROVAL_REFS__.get(\"" + node.s + "\")";
|
|
1740
|
+
}
|
|
1741
|
+
function serializeArrayItem(ctx, id, item, index) {
|
|
1742
|
+
if (item) {
|
|
1743
|
+
if (isIndexedValueInStack(ctx.base, item)) {
|
|
1744
|
+
markSerializerRef(ctx.base, id);
|
|
1745
|
+
createArrayAssign(ctx, id, index, getRefParam(ctx, item.i));
|
|
1746
|
+
return "";
|
|
1747
|
+
}
|
|
1748
|
+
return serialize$1(ctx, item);
|
|
1749
|
+
}
|
|
1750
|
+
return "";
|
|
1751
|
+
}
|
|
1752
|
+
function serializeArray(ctx, node) {
|
|
1753
|
+
const id = node.i;
|
|
1754
|
+
const list = node.a;
|
|
1755
|
+
const len = list.length;
|
|
1756
|
+
if (len > 0) {
|
|
1757
|
+
ctx.base.stack.push(id);
|
|
1758
|
+
let values = serializeArrayItem(ctx, id, list[0], 0);
|
|
1759
|
+
let isHoley = values === "";
|
|
1760
|
+
for (let i = 1, item; i < len; i++) {
|
|
1761
|
+
item = serializeArrayItem(ctx, id, list[i], i);
|
|
1762
|
+
values += "," + item;
|
|
1763
|
+
isHoley = item === "";
|
|
1764
|
+
}
|
|
1765
|
+
ctx.base.stack.pop();
|
|
1766
|
+
pushObjectFlag(ctx, node.o, node.i);
|
|
1767
|
+
return "[" + values + (isHoley ? ",]" : "]");
|
|
1768
|
+
}
|
|
1769
|
+
return "[]";
|
|
1770
|
+
}
|
|
1771
|
+
function serializeProperty(ctx, source, key, val) {
|
|
1772
|
+
if (typeof key === "string") {
|
|
1773
|
+
const check = Number(key);
|
|
1774
|
+
const isIdentifier = check >= 0 && check.toString() === key || isValidIdentifier(key);
|
|
1775
|
+
if (isIndexedValueInStack(ctx.base, val)) {
|
|
1776
|
+
const refParam = getRefParam(ctx, val.i);
|
|
1777
|
+
markSerializerRef(ctx.base, source.i);
|
|
1778
|
+
if (isIdentifier && check !== check) createObjectAssign(ctx, source.i, key, refParam);
|
|
1779
|
+
else createArrayAssign(ctx, source.i, isIdentifier ? key : "\"" + key + "\"", refParam);
|
|
1780
|
+
return "";
|
|
1781
|
+
}
|
|
1782
|
+
if (isValidKey(key)) return (isIdentifier ? key : "\"" + key + "\"") + ":" + serialize$1(ctx, val);
|
|
1783
|
+
return "[\"" + key + "\"]:" + serialize$1(ctx, val);
|
|
1784
|
+
}
|
|
1785
|
+
return "[" + serialize$1(ctx, key) + "]:" + serialize$1(ctx, val);
|
|
1786
|
+
}
|
|
1787
|
+
function serializeProperties(ctx, source, record) {
|
|
1788
|
+
const keys = record.k;
|
|
1789
|
+
const len = keys.length;
|
|
1790
|
+
if (len > 0) {
|
|
1791
|
+
const values = record.v;
|
|
1792
|
+
ctx.base.stack.push(source.i);
|
|
1793
|
+
let result = serializeProperty(ctx, source, keys[0], values[0]);
|
|
1794
|
+
for (let i = 1, item = result; i < len; i++) {
|
|
1795
|
+
item = serializeProperty(ctx, source, keys[i], values[i]);
|
|
1796
|
+
result += (item && result && ",") + item;
|
|
1797
|
+
}
|
|
1798
|
+
ctx.base.stack.pop();
|
|
1799
|
+
return "{" + result + "}";
|
|
1800
|
+
}
|
|
1801
|
+
return "{}";
|
|
1802
|
+
}
|
|
1803
|
+
function serializeObject(ctx, node) {
|
|
1804
|
+
pushObjectFlag(ctx, node.o, node.i);
|
|
1805
|
+
return serializeProperties(ctx, node, node.p);
|
|
1806
|
+
}
|
|
1807
|
+
function serializeWithObjectAssign(ctx, source, value, serialized) {
|
|
1808
|
+
const fields = serializeProperties(ctx, source, value);
|
|
1809
|
+
if (fields !== "{}") return "Object.assign(" + serialized + "," + fields + ")";
|
|
1810
|
+
return serialized;
|
|
1811
|
+
}
|
|
1812
|
+
function serializeStringKeyAssignment(ctx, source, mainAssignments, key, value) {
|
|
1813
|
+
const base = ctx.base;
|
|
1814
|
+
const serialized = serialize$1(ctx, value);
|
|
1815
|
+
const check = Number(key);
|
|
1816
|
+
const isIdentifier = check >= 0 && check.toString() === key || isValidIdentifier(key);
|
|
1817
|
+
if (isIndexedValueInStack(base, value)) {
|
|
1818
|
+
if (isIdentifier && check !== check) createObjectAssign(ctx, source.i, key, serialized);
|
|
1819
|
+
else createArrayAssign(ctx, source.i, isIdentifier ? key : "\"" + key + "\"", serialized);
|
|
1820
|
+
} else {
|
|
1821
|
+
const parentAssignment = base.assignments;
|
|
1822
|
+
base.assignments = mainAssignments;
|
|
1823
|
+
if (isIdentifier && check !== check) createObjectAssign(ctx, source.i, key, serialized);
|
|
1824
|
+
else createArrayAssign(ctx, source.i, isIdentifier ? key : "\"" + key + "\"", serialized);
|
|
1825
|
+
base.assignments = parentAssignment;
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
function serializeAssignment(ctx, source, mainAssignments, key, value) {
|
|
1829
|
+
if (typeof key === "string") serializeStringKeyAssignment(ctx, source, mainAssignments, key, value);
|
|
1830
|
+
else {
|
|
1831
|
+
const base = ctx.base;
|
|
1832
|
+
const parent = base.stack;
|
|
1833
|
+
base.stack = [];
|
|
1834
|
+
const serialized = serialize$1(ctx, value);
|
|
1835
|
+
base.stack = parent;
|
|
1836
|
+
const parentAssignment = base.assignments;
|
|
1837
|
+
base.assignments = mainAssignments;
|
|
1838
|
+
createArrayAssign(ctx, source.i, serialize$1(ctx, key), serialized);
|
|
1839
|
+
base.assignments = parentAssignment;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
function serializeAssignments(ctx, source, node) {
|
|
1843
|
+
const keys = node.k;
|
|
1844
|
+
const len = keys.length;
|
|
1845
|
+
if (len > 0) {
|
|
1846
|
+
const mainAssignments = [];
|
|
1847
|
+
const values = node.v;
|
|
1848
|
+
ctx.base.stack.push(source.i);
|
|
1849
|
+
for (let i = 0; i < len; i++) serializeAssignment(ctx, source, mainAssignments, keys[i], values[i]);
|
|
1850
|
+
ctx.base.stack.pop();
|
|
1851
|
+
return resolveAssignments(mainAssignments);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
function serializeDictionary(ctx, node, init) {
|
|
1855
|
+
if (node.p) {
|
|
1856
|
+
const base = ctx.base;
|
|
1857
|
+
if (base.features & 8) init = serializeWithObjectAssign(ctx, node, node.p, init);
|
|
1858
|
+
else {
|
|
1859
|
+
markSerializerRef(base, node.i);
|
|
1860
|
+
const assignments = serializeAssignments(ctx, node, node.p);
|
|
1861
|
+
if (assignments) return "(" + assignIndexedValue(ctx, node.i, init) + "," + assignments + getRefParam(ctx, node.i) + ")";
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
return init;
|
|
1865
|
+
}
|
|
1866
|
+
function serializeNullConstructor(ctx, node) {
|
|
1867
|
+
pushObjectFlag(ctx, node.o, node.i);
|
|
1868
|
+
return serializeDictionary(ctx, node, NULL_CONSTRUCTOR);
|
|
1869
|
+
}
|
|
1870
|
+
function serializeDate(node) {
|
|
1871
|
+
return "new Date(\"" + node.s + "\")";
|
|
1872
|
+
}
|
|
1873
|
+
var TEMPORAL_CONSTRUCTOR = {
|
|
1874
|
+
[0]: "Temporal.Instant",
|
|
1875
|
+
[1]: "Temporal.Duration",
|
|
1876
|
+
[2]: "Temporal.PlainDate",
|
|
1877
|
+
[3]: "Temporal.PlainDateTime",
|
|
1878
|
+
[4]: "Temporal.PlainMonthDay",
|
|
1879
|
+
[5]: "Temporal.PlainTime",
|
|
1880
|
+
[6]: "Temporal.PlainYearMonth",
|
|
1881
|
+
[7]: "Temporal.ZonedDateTime"
|
|
1882
|
+
};
|
|
1883
|
+
function serializeTemporal(ctx, node) {
|
|
1884
|
+
if (ctx.base.features & 64) return TEMPORAL_CONSTRUCTOR[node.c] + ".from(\"" + node.s + "\")";
|
|
1885
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
1886
|
+
}
|
|
1887
|
+
function serializeRegExp(ctx, node) {
|
|
1888
|
+
if (ctx.base.features & 32) return "/" + deserializeString(node.c) + "/" + node.m;
|
|
1889
|
+
throw new SerovalUnsupportedNodeError(node);
|
|
1890
|
+
}
|
|
1891
|
+
function serializeSetItem(ctx, id, item) {
|
|
1892
|
+
const base = ctx.base;
|
|
1893
|
+
if (isIndexedValueInStack(base, item)) {
|
|
1894
|
+
markSerializerRef(base, id);
|
|
1895
|
+
createAddAssignment(ctx, id, getRefParam(ctx, item.i));
|
|
1896
|
+
return "";
|
|
1897
|
+
}
|
|
1898
|
+
return serialize$1(ctx, item);
|
|
1899
|
+
}
|
|
1900
|
+
function serializeSet(ctx, node) {
|
|
1901
|
+
let serialized = SET_CONSTRUCTOR;
|
|
1902
|
+
const items = node.a;
|
|
1903
|
+
const size = items.length;
|
|
1904
|
+
const id = node.i;
|
|
1905
|
+
if (size > 0) {
|
|
1906
|
+
ctx.base.stack.push(id);
|
|
1907
|
+
let result = serializeSetItem(ctx, id, items[0]);
|
|
1908
|
+
for (let i = 1, item = result; i < size; i++) {
|
|
1909
|
+
item = serializeSetItem(ctx, id, items[i]);
|
|
1910
|
+
result += (item && result && ",") + item;
|
|
1911
|
+
}
|
|
1912
|
+
ctx.base.stack.pop();
|
|
1913
|
+
if (result) serialized += "([" + result + "])";
|
|
1914
|
+
}
|
|
1915
|
+
return serialized;
|
|
1916
|
+
}
|
|
1917
|
+
function serializeMapEntry(ctx, id, key, val, sentinel) {
|
|
1918
|
+
const base = ctx.base;
|
|
1919
|
+
if (isIndexedValueInStack(base, key)) {
|
|
1920
|
+
const keyRef = getRefParam(ctx, key.i);
|
|
1921
|
+
markSerializerRef(base, id);
|
|
1922
|
+
if (isIndexedValueInStack(base, val)) {
|
|
1923
|
+
createSetAssignment(ctx, id, keyRef, getRefParam(ctx, val.i));
|
|
1924
|
+
return "";
|
|
1925
|
+
}
|
|
1926
|
+
if (val.t !== 4 && val.i != null && isSerializerRefMarked(base, val.i)) {
|
|
1927
|
+
const serialized = "(" + serialize$1(ctx, val) + ",[" + sentinel + "," + sentinel + "])";
|
|
1928
|
+
createSetAssignment(ctx, id, keyRef, getRefParam(ctx, val.i));
|
|
1929
|
+
createDeleteAssignment(ctx, id, sentinel);
|
|
1930
|
+
return serialized;
|
|
1931
|
+
}
|
|
1932
|
+
const parent = base.stack;
|
|
1933
|
+
base.stack = [];
|
|
1934
|
+
createSetAssignment(ctx, id, keyRef, serialize$1(ctx, val));
|
|
1935
|
+
base.stack = parent;
|
|
1936
|
+
return "";
|
|
1937
|
+
}
|
|
1938
|
+
if (isIndexedValueInStack(base, val)) {
|
|
1939
|
+
const valueRef = getRefParam(ctx, val.i);
|
|
1940
|
+
markSerializerRef(base, id);
|
|
1941
|
+
if (key.t !== 4 && key.i != null && isSerializerRefMarked(base, key.i)) {
|
|
1942
|
+
const serialized = "(" + serialize$1(ctx, key) + ",[" + sentinel + "," + sentinel + "])";
|
|
1943
|
+
createSetAssignment(ctx, id, getRefParam(ctx, key.i), valueRef);
|
|
1944
|
+
createDeleteAssignment(ctx, id, sentinel);
|
|
1945
|
+
return serialized;
|
|
1946
|
+
}
|
|
1947
|
+
const parent = base.stack;
|
|
1948
|
+
base.stack = [];
|
|
1949
|
+
createSetAssignment(ctx, id, serialize$1(ctx, key), valueRef);
|
|
1950
|
+
base.stack = parent;
|
|
1951
|
+
return "";
|
|
1952
|
+
}
|
|
1953
|
+
return "[" + serialize$1(ctx, key) + "," + serialize$1(ctx, val) + "]";
|
|
1954
|
+
}
|
|
1955
|
+
function serializeMap(ctx, node) {
|
|
1956
|
+
let serialized = MAP_CONSTRUCTOR;
|
|
1957
|
+
const keys = node.e.k;
|
|
1958
|
+
const size = keys.length;
|
|
1959
|
+
const id = node.i;
|
|
1960
|
+
const sentinel = node.f;
|
|
1961
|
+
const sentinelId = getRefParam(ctx, sentinel.i);
|
|
1962
|
+
const base = ctx.base;
|
|
1963
|
+
if (size > 0) {
|
|
1964
|
+
const vals = node.e.v;
|
|
1965
|
+
base.stack.push(id);
|
|
1966
|
+
let result = serializeMapEntry(ctx, id, keys[0], vals[0], sentinelId);
|
|
1967
|
+
for (let i = 1, item = result; i < size; i++) {
|
|
1968
|
+
item = serializeMapEntry(ctx, id, keys[i], vals[i], sentinelId);
|
|
1969
|
+
result += (item && result && ",") + item;
|
|
1970
|
+
}
|
|
1971
|
+
base.stack.pop();
|
|
1972
|
+
if (result) serialized += "([" + result + "])";
|
|
1973
|
+
}
|
|
1974
|
+
if (sentinel.t === 26) {
|
|
1975
|
+
markSerializerRef(base, sentinel.i);
|
|
1976
|
+
serialized = "(" + serialize$1(ctx, sentinel) + "," + serialized + ")";
|
|
1977
|
+
}
|
|
1978
|
+
return serialized;
|
|
1979
|
+
}
|
|
1980
|
+
function serializeArrayBuffer(ctx, node) {
|
|
1981
|
+
return getConstructor(ctx, node.f) + "(\"" + node.s + "\")";
|
|
1982
|
+
}
|
|
1983
|
+
function serializeTypedArray(ctx, node) {
|
|
1984
|
+
return "new " + node.c + "(" + serialize$1(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
1985
|
+
}
|
|
1986
|
+
function serializeDataView(ctx, node) {
|
|
1987
|
+
return "new DataView(" + serialize$1(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
1988
|
+
}
|
|
1989
|
+
function serializeAggregateError(ctx, node) {
|
|
1990
|
+
const id = node.i;
|
|
1991
|
+
ctx.base.stack.push(id);
|
|
1992
|
+
const serialized = serializeDictionary(ctx, node, "new AggregateError([],\"" + node.m + "\")");
|
|
1993
|
+
ctx.base.stack.pop();
|
|
1994
|
+
return serialized;
|
|
1995
|
+
}
|
|
1996
|
+
function serializeError(ctx, node) {
|
|
1997
|
+
return serializeDictionary(ctx, node, "new " + ERROR_CONSTRUCTOR_STRING[node.s] + "(\"" + node.m + "\")");
|
|
1998
|
+
}
|
|
1999
|
+
function serializePromise(ctx, node) {
|
|
2000
|
+
let serialized;
|
|
2001
|
+
const fulfilled = node.f;
|
|
2002
|
+
const id = node.i;
|
|
2003
|
+
const promiseConstructor = node.s ? PROMISE_RESOLVE : PROMISE_REJECT;
|
|
2004
|
+
const base = ctx.base;
|
|
2005
|
+
if (isIndexedValueInStack(base, fulfilled)) {
|
|
2006
|
+
const ref = getRefParam(ctx, fulfilled.i);
|
|
2007
|
+
serialized = promiseConstructor + (node.s ? "().then(" + createFunction([], ref) + ")" : "().catch(" + createEffectfulFunction([], "throw " + ref) + ")");
|
|
2008
|
+
} else {
|
|
2009
|
+
base.stack.push(id);
|
|
2010
|
+
const result = serialize$1(ctx, fulfilled);
|
|
2011
|
+
base.stack.pop();
|
|
2012
|
+
serialized = promiseConstructor + "(" + result + ")";
|
|
2013
|
+
}
|
|
2014
|
+
return serialized;
|
|
2015
|
+
}
|
|
2016
|
+
function serializeBoxed(ctx, node) {
|
|
2017
|
+
return "Object(" + serialize$1(ctx, node.f) + ")";
|
|
2018
|
+
}
|
|
2019
|
+
function getConstructor(ctx, node) {
|
|
2020
|
+
const current = serialize$1(ctx, node);
|
|
2021
|
+
return node.t === 4 ? current : "(" + current + ")";
|
|
2022
|
+
}
|
|
2023
|
+
function serializePromiseConstructor(ctx, node) {
|
|
2024
|
+
if (ctx.mode === 1) throw new SerovalUnsupportedNodeError(node);
|
|
2025
|
+
return "(" + assignIndexedValue(ctx, node.s, getConstructor(ctx, node.f) + "()") + ").p";
|
|
2026
|
+
}
|
|
2027
|
+
function serializePromiseResolve(ctx, node) {
|
|
2028
|
+
if (ctx.mode === 1) throw new SerovalUnsupportedNodeError(node);
|
|
2029
|
+
return getConstructor(ctx, node.a[0]) + "(" + getRefParam(ctx, node.i) + "," + serialize$1(ctx, node.a[1]) + ")";
|
|
2030
|
+
}
|
|
2031
|
+
function serializePromiseReject(ctx, node) {
|
|
2032
|
+
if (ctx.mode === 1) throw new SerovalUnsupportedNodeError(node);
|
|
2033
|
+
return getConstructor(ctx, node.a[0]) + "(" + getRefParam(ctx, node.i) + "," + serialize$1(ctx, node.a[1]) + ")";
|
|
2034
|
+
}
|
|
2035
|
+
function serializePlugin(ctx, node) {
|
|
2036
|
+
const currentPlugins = ctx.base.plugins;
|
|
2037
|
+
if (currentPlugins) for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
2038
|
+
const plugin = currentPlugins[i];
|
|
2039
|
+
if (plugin.tag === node.c) {
|
|
2040
|
+
if (ctx.child == null) ctx.child = new SerializePluginContext(ctx);
|
|
2041
|
+
return plugin.serialize(node.s, ctx.child, { id: node.i });
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
throw new SerovalMissingPluginError(node.c);
|
|
2045
|
+
}
|
|
2046
|
+
function serializeIteratorFactory(ctx, node) {
|
|
2047
|
+
let result = "";
|
|
2048
|
+
let initialized = false;
|
|
2049
|
+
if (node.f.t !== 4) {
|
|
2050
|
+
markSerializerRef(ctx.base, node.f.i);
|
|
2051
|
+
result = "(" + serialize$1(ctx, node.f) + ",";
|
|
2052
|
+
initialized = true;
|
|
2053
|
+
}
|
|
2054
|
+
result += assignIndexedValue(ctx, node.i, "(" + SERIALIZED_ITERATOR_CONSTRUCTOR + ")(" + getRefParam(ctx, node.f.i) + ")");
|
|
2055
|
+
if (initialized) result += ")";
|
|
2056
|
+
return result;
|
|
2057
|
+
}
|
|
2058
|
+
function serializeIteratorFactoryInstance(ctx, node) {
|
|
2059
|
+
return getConstructor(ctx, node.a[0]) + "(" + serialize$1(ctx, node.a[1]) + ")";
|
|
2060
|
+
}
|
|
2061
|
+
function serializeAsyncIteratorFactory(ctx, node) {
|
|
2062
|
+
const promise = node.a[0];
|
|
2063
|
+
const symbol = node.a[1];
|
|
2064
|
+
const base = ctx.base;
|
|
2065
|
+
let result = "";
|
|
2066
|
+
if (promise.t !== 4) {
|
|
2067
|
+
markSerializerRef(base, promise.i);
|
|
2068
|
+
result += "(" + serialize$1(ctx, promise);
|
|
2069
|
+
}
|
|
2070
|
+
if (symbol.t !== 4) {
|
|
2071
|
+
markSerializerRef(base, symbol.i);
|
|
2072
|
+
result += (result ? "," : "(") + serialize$1(ctx, symbol);
|
|
2073
|
+
}
|
|
2074
|
+
if (result) result += ",";
|
|
2075
|
+
const iterator = assignIndexedValue(ctx, node.i, "(" + SERIALIZED_ASYNC_ITERATOR_CONSTRUCTOR + ")(" + getRefParam(ctx, symbol.i) + "," + getRefParam(ctx, promise.i) + ")");
|
|
2076
|
+
if (result) return result + iterator + ")";
|
|
2077
|
+
return iterator;
|
|
2078
|
+
}
|
|
2079
|
+
function serializeAsyncIteratorFactoryInstance(ctx, node) {
|
|
2080
|
+
return getConstructor(ctx, node.a[0]) + "(" + serialize$1(ctx, node.a[1]) + ")";
|
|
2081
|
+
}
|
|
2082
|
+
function serializeStreamConstructor(ctx, node) {
|
|
2083
|
+
const result = assignIndexedValue(ctx, node.i, getConstructor(ctx, node.f) + "()");
|
|
2084
|
+
const len = node.a.length;
|
|
2085
|
+
if (len) {
|
|
2086
|
+
let values = serialize$1(ctx, node.a[0]);
|
|
2087
|
+
for (let i = 1; i < len; i++) values += "," + serialize$1(ctx, node.a[i]);
|
|
2088
|
+
return "(" + result + "," + values + "," + getRefParam(ctx, node.i) + ")";
|
|
2089
|
+
}
|
|
2090
|
+
return result;
|
|
2091
|
+
}
|
|
2092
|
+
function serializeStreamNext(ctx, node) {
|
|
2093
|
+
return getRefParam(ctx, node.i) + ".next(" + serialize$1(ctx, node.f) + ")";
|
|
2094
|
+
}
|
|
2095
|
+
function serializeStreamThrow(ctx, node) {
|
|
2096
|
+
return getRefParam(ctx, node.i) + ".throw(" + serialize$1(ctx, node.f) + ")";
|
|
2097
|
+
}
|
|
2098
|
+
function serializeStreamReturn(ctx, node) {
|
|
2099
|
+
return getRefParam(ctx, node.i) + ".return(" + serialize$1(ctx, node.f) + ")";
|
|
2100
|
+
}
|
|
2101
|
+
function serializeSequenceItem(ctx, id, index, item) {
|
|
2102
|
+
const base = ctx.base;
|
|
2103
|
+
if (isIndexedValueInStack(base, item)) {
|
|
2104
|
+
markSerializerRef(base, id);
|
|
2105
|
+
createSequenceAssign(ctx, id, index, getRefParam(ctx, item.i));
|
|
2106
|
+
return "";
|
|
2107
|
+
}
|
|
2108
|
+
return serialize$1(ctx, item);
|
|
2109
|
+
}
|
|
2110
|
+
function serializeSequence(ctx, node) {
|
|
2111
|
+
const items = node.a;
|
|
2112
|
+
const size = items.length;
|
|
2113
|
+
const id = node.i;
|
|
2114
|
+
if (size > 0) {
|
|
2115
|
+
ctx.base.stack.push(id);
|
|
2116
|
+
let result = serializeSequenceItem(ctx, id, 0, items[0]);
|
|
2117
|
+
for (let i = 1, item = result; i < size; i++) {
|
|
2118
|
+
item = serializeSequenceItem(ctx, id, i, items[i]);
|
|
2119
|
+
result += (item && result && ",") + item;
|
|
2120
|
+
}
|
|
2121
|
+
ctx.base.stack.pop();
|
|
2122
|
+
if (result) return "{__SEROVAL_SEQUENCE__:!0,v:[" + result + "],t:" + node.s + ",d:" + node.l + "}";
|
|
2123
|
+
}
|
|
2124
|
+
return "{__SEROVAL_SEQUENCE__:!0,v:[],t:-1,d:0}";
|
|
2125
|
+
}
|
|
2126
|
+
function serializeAssignable(ctx, node) {
|
|
2127
|
+
switch (node.t) {
|
|
2128
|
+
case 17: return SYMBOL_STRING[node.s];
|
|
2129
|
+
case 18: return serializeReference(node);
|
|
2130
|
+
case 9: return serializeArray(ctx, node);
|
|
2131
|
+
case 10: return serializeObject(ctx, node);
|
|
2132
|
+
case 11: return serializeNullConstructor(ctx, node);
|
|
2133
|
+
case 5: return serializeDate(node);
|
|
2134
|
+
case 6: return serializeRegExp(ctx, node);
|
|
2135
|
+
case 7: return serializeSet(ctx, node);
|
|
2136
|
+
case 8: return serializeMap(ctx, node);
|
|
2137
|
+
case 19: return serializeArrayBuffer(ctx, node);
|
|
2138
|
+
case 16:
|
|
2139
|
+
case 15: return serializeTypedArray(ctx, node);
|
|
2140
|
+
case 20: return serializeDataView(ctx, node);
|
|
2141
|
+
case 14: return serializeAggregateError(ctx, node);
|
|
2142
|
+
case 13: return serializeError(ctx, node);
|
|
2143
|
+
case 12: return serializePromise(ctx, node);
|
|
2144
|
+
case 21: return serializeBoxed(ctx, node);
|
|
2145
|
+
case 22: return serializePromiseConstructor(ctx, node);
|
|
2146
|
+
case 25: return serializePlugin(ctx, node);
|
|
2147
|
+
case 26: return SPECIAL_REF_STRING[node.s];
|
|
2148
|
+
case 35: return serializeSequence(ctx, node);
|
|
2149
|
+
case 36: return serializeTemporal(ctx, node);
|
|
2150
|
+
default: throw new SerovalUnsupportedNodeError(node);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
function serialize$1(ctx, node) {
|
|
2154
|
+
switch (node.t) {
|
|
2155
|
+
case 2: return CONSTANT_STRING[node.s];
|
|
2156
|
+
case 0: return "" + node.s;
|
|
2157
|
+
case 1: return "\"" + node.s + "\"";
|
|
2158
|
+
case 3: return node.s + "n";
|
|
2159
|
+
case 4: return getRefParam(ctx, node.i);
|
|
2160
|
+
case 23: return serializePromiseResolve(ctx, node);
|
|
2161
|
+
case 24: return serializePromiseReject(ctx, node);
|
|
2162
|
+
case 27: return serializeIteratorFactory(ctx, node);
|
|
2163
|
+
case 28: return serializeIteratorFactoryInstance(ctx, node);
|
|
2164
|
+
case 29: return serializeAsyncIteratorFactory(ctx, node);
|
|
2165
|
+
case 30: return serializeAsyncIteratorFactoryInstance(ctx, node);
|
|
2166
|
+
case 31: return serializeStreamConstructor(ctx, node);
|
|
2167
|
+
case 32: return serializeStreamNext(ctx, node);
|
|
2168
|
+
case 33: return serializeStreamThrow(ctx, node);
|
|
2169
|
+
case 34: return serializeStreamReturn(ctx, node);
|
|
2170
|
+
default: return assignIndexedValue(ctx, node.i, serializeAssignable(ctx, node));
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
function serializeTopCross(ctx, tree) {
|
|
2174
|
+
const result = serialize$1(ctx, tree);
|
|
2175
|
+
const id = tree.i;
|
|
2176
|
+
if (id == null) return result;
|
|
2177
|
+
const patches = resolvePatches(ctx.base);
|
|
2178
|
+
const ref = getRefParam(ctx, id);
|
|
2179
|
+
const scopeId = ctx.state.scopeId;
|
|
2180
|
+
const params = scopeId == null ? "" : "$R";
|
|
2181
|
+
const body = patches ? "(" + result + "," + patches + ref + ")" : result;
|
|
2182
|
+
if (params === "") {
|
|
2183
|
+
if (tree.t === 10 && !patches) return "(" + body + ")";
|
|
2184
|
+
return body;
|
|
2185
|
+
}
|
|
2186
|
+
const args = scopeId == null ? "()" : "($R[\"" + serializeString(scopeId) + "\"])";
|
|
2187
|
+
return "(" + createFunction([params], body) + ")" + args;
|
|
2188
|
+
}
|
|
2189
|
+
var SyncParsePluginContext = class {
|
|
2190
|
+
constructor(_p, depth) {
|
|
2191
|
+
this._p = _p;
|
|
2192
|
+
this.depth = depth;
|
|
2193
|
+
}
|
|
2194
|
+
parse(current) {
|
|
2195
|
+
return parseSOS(this._p, this.depth, current);
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2198
|
+
var StreamParsePluginContext = class {
|
|
2199
|
+
constructor(_p, depth) {
|
|
2200
|
+
this._p = _p;
|
|
2201
|
+
this.depth = depth;
|
|
2202
|
+
}
|
|
2203
|
+
parse(current) {
|
|
2204
|
+
return parseSOS(this._p, this.depth, current);
|
|
2205
|
+
}
|
|
2206
|
+
parseWithError(current) {
|
|
2207
|
+
return parseWithError(this._p, this.depth, current);
|
|
2208
|
+
}
|
|
2209
|
+
isAlive() {
|
|
2210
|
+
return this._p.state.alive;
|
|
2211
|
+
}
|
|
2212
|
+
pushPendingState() {
|
|
2213
|
+
pushPendingState(this._p);
|
|
2214
|
+
}
|
|
2215
|
+
popPendingState() {
|
|
2216
|
+
popPendingState(this._p);
|
|
2217
|
+
}
|
|
2218
|
+
onParse(node) {
|
|
2219
|
+
onParse(this._p, node);
|
|
2220
|
+
}
|
|
2221
|
+
onError(error) {
|
|
2222
|
+
onError(this._p, error);
|
|
2223
|
+
}
|
|
2224
|
+
addCleanup(callback) {
|
|
2225
|
+
this._p.state.cleanups.push(callback);
|
|
2226
|
+
}
|
|
2227
|
+
};
|
|
2228
|
+
function createStreamParserState(options) {
|
|
2229
|
+
return {
|
|
2230
|
+
alive: true,
|
|
2231
|
+
pending: 0,
|
|
2232
|
+
initial: true,
|
|
2233
|
+
buffer: [],
|
|
2234
|
+
onParse: options.onParse,
|
|
2235
|
+
onError: options.onError,
|
|
2236
|
+
onDone: options.onDone,
|
|
2237
|
+
cleanups: []
|
|
2238
|
+
};
|
|
2239
|
+
}
|
|
2240
|
+
function createStreamParserContext(options) {
|
|
2241
|
+
return {
|
|
2242
|
+
type: 2,
|
|
2243
|
+
base: createBaseParserContext(2, options),
|
|
2244
|
+
state: createStreamParserState(options)
|
|
2245
|
+
};
|
|
2246
|
+
}
|
|
2247
|
+
function parseItems(ctx, depth, current) {
|
|
2248
|
+
const nodes = [];
|
|
2249
|
+
for (let i = 0, len = current.length; i < len; i++) if (i in current) nodes[i] = parseSOS(ctx, depth, current[i]);
|
|
2250
|
+
else nodes[i] = 0;
|
|
2251
|
+
return nodes;
|
|
2252
|
+
}
|
|
2253
|
+
function parseArray(ctx, depth, id, current) {
|
|
2254
|
+
return createArrayNode(id, current, parseItems(ctx, depth, current));
|
|
2255
|
+
}
|
|
2256
|
+
function parseProperties(ctx, depth, properties) {
|
|
2257
|
+
const entries = Object.entries(properties);
|
|
2258
|
+
const keyNodes = [];
|
|
2259
|
+
const valueNodes = [];
|
|
2260
|
+
for (let i = 0, len = entries.length; i < len; i++) {
|
|
2261
|
+
keyNodes.push(serializeString(entries[i][0]));
|
|
2262
|
+
valueNodes.push(parseSOS(ctx, depth, entries[i][1]));
|
|
2263
|
+
}
|
|
2264
|
+
if (SYM_ITERATOR in properties) {
|
|
2265
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ITERATOR));
|
|
2266
|
+
valueNodes.push(createIteratorFactoryInstanceNode(parseIteratorFactory(ctx.base), parseSOS(ctx, depth, createSequenceFromIterable(properties))));
|
|
2267
|
+
}
|
|
2268
|
+
if (SYM_ASYNC_ITERATOR in properties) {
|
|
2269
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_ASYNC_ITERATOR));
|
|
2270
|
+
valueNodes.push(createAsyncIteratorFactoryInstanceNode(parseAsyncIteratorFactory(ctx.base), parseSOS(ctx, depth, ctx.type === 1 ? createStream() : createStreamFromAsyncIterable(properties))));
|
|
2271
|
+
}
|
|
2272
|
+
if (SYM_TO_STRING_TAG in properties) {
|
|
2273
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_TO_STRING_TAG));
|
|
2274
|
+
valueNodes.push(createStringNode(properties[SYM_TO_STRING_TAG]));
|
|
2275
|
+
}
|
|
2276
|
+
if (SYM_IS_CONCAT_SPREADABLE in properties) {
|
|
2277
|
+
keyNodes.push(parseWellKnownSymbol(ctx.base, SYM_IS_CONCAT_SPREADABLE));
|
|
2278
|
+
valueNodes.push(properties[SYM_IS_CONCAT_SPREADABLE] ? TRUE_NODE : FALSE_NODE);
|
|
2279
|
+
}
|
|
2280
|
+
return {
|
|
2281
|
+
k: keyNodes,
|
|
2282
|
+
v: valueNodes
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
function parsePlainObject(ctx, depth, id, current, empty) {
|
|
2286
|
+
return createObjectNode(id, current, empty, parseProperties(ctx, depth, current));
|
|
2287
|
+
}
|
|
2288
|
+
function parseBoxed(ctx, depth, id, current) {
|
|
2289
|
+
return createBoxedNode(id, parseSOS(ctx, depth, current.valueOf()));
|
|
2290
|
+
}
|
|
2291
|
+
function parseTypedArray(ctx, depth, id, current) {
|
|
2292
|
+
return createTypedArrayNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
2293
|
+
}
|
|
2294
|
+
function parseBigIntTypedArray(ctx, depth, id, current) {
|
|
2295
|
+
return createBigIntTypedArrayNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
2296
|
+
}
|
|
2297
|
+
function parseDataView(ctx, depth, id, current) {
|
|
2298
|
+
return createDataViewNode(id, current, parseSOS(ctx, depth, current.buffer));
|
|
2299
|
+
}
|
|
2300
|
+
function parseError(ctx, depth, id, current) {
|
|
2301
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
2302
|
+
return createErrorNode(id, current, options ? parseProperties(ctx, depth, options) : void 0);
|
|
2303
|
+
}
|
|
2304
|
+
function parseAggregateError(ctx, depth, id, current) {
|
|
2305
|
+
const options = getErrorOptions(current, ctx.base.features);
|
|
2306
|
+
return createAggregateErrorNode(id, current, options ? parseProperties(ctx, depth, options) : void 0);
|
|
2307
|
+
}
|
|
2308
|
+
function parseMap(ctx, depth, id, current) {
|
|
2309
|
+
const keyNodes = [];
|
|
2310
|
+
const valueNodes = [];
|
|
2311
|
+
for (const [key, value] of current.entries()) {
|
|
2312
|
+
keyNodes.push(parseSOS(ctx, depth, key));
|
|
2313
|
+
valueNodes.push(parseSOS(ctx, depth, value));
|
|
2314
|
+
}
|
|
2315
|
+
return createMapNode(ctx.base, id, keyNodes, valueNodes);
|
|
2316
|
+
}
|
|
2317
|
+
function parseSet(ctx, depth, id, current) {
|
|
2318
|
+
const items = [];
|
|
2319
|
+
for (const item of current.keys()) items.push(parseSOS(ctx, depth, item));
|
|
2320
|
+
return createSetNode(id, items);
|
|
2321
|
+
}
|
|
2322
|
+
function parseStream(ctx, depth, id, current) {
|
|
2323
|
+
const result = createStreamConstructorNode(id, parseSpecialReference(ctx.base, 4), []);
|
|
2324
|
+
if (ctx.type === 1) return result;
|
|
2325
|
+
pushPendingState(ctx);
|
|
2326
|
+
current.on({
|
|
2327
|
+
next: (value) => {
|
|
2328
|
+
if (ctx.state.alive) {
|
|
2329
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
2330
|
+
if (parsed) onParse(ctx, createStreamNextNode(id, parsed));
|
|
2331
|
+
}
|
|
2332
|
+
},
|
|
2333
|
+
throw: (value) => {
|
|
2334
|
+
if (ctx.state.alive) {
|
|
2335
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
2336
|
+
if (parsed) onParse(ctx, createStreamThrowNode(id, parsed));
|
|
2337
|
+
}
|
|
2338
|
+
popPendingState(ctx);
|
|
2339
|
+
},
|
|
2340
|
+
return: (value) => {
|
|
2341
|
+
if (ctx.state.alive) {
|
|
2342
|
+
const parsed = parseWithError(ctx, depth, value);
|
|
2343
|
+
if (parsed) onParse(ctx, createStreamReturnNode(id, parsed));
|
|
2344
|
+
}
|
|
2345
|
+
popPendingState(ctx);
|
|
2346
|
+
}
|
|
2347
|
+
});
|
|
2348
|
+
return result;
|
|
2349
|
+
}
|
|
2350
|
+
function handlePromiseSuccess(id, depth, data) {
|
|
2351
|
+
if (this.state.alive) {
|
|
2352
|
+
const parsed = parseWithError(this, depth, data);
|
|
2353
|
+
if (parsed) onParse(this, createSerovalNode(23, id, void 0, void 0, void 0, void 0, void 0, [parseSpecialReference(this.base, 2), parsed], void 0, void 0, void 0, void 0));
|
|
2354
|
+
popPendingState(this);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
function handlePromiseFailure(id, depth, data) {
|
|
2358
|
+
if (this.state.alive) {
|
|
2359
|
+
const parsed = parseWithError(this, depth, data);
|
|
2360
|
+
if (parsed) onParse(this, createSerovalNode(24, id, void 0, void 0, void 0, void 0, void 0, [parseSpecialReference(this.base, 3), parsed], void 0, void 0, void 0, void 0));
|
|
2361
|
+
}
|
|
2362
|
+
popPendingState(this);
|
|
2363
|
+
}
|
|
2364
|
+
function parsePromise(ctx, depth, id, current) {
|
|
2365
|
+
const resolver = createIndexForValue(ctx.base, {});
|
|
2366
|
+
if (ctx.type === 2) {
|
|
2367
|
+
pushPendingState(ctx);
|
|
2368
|
+
current.then(handlePromiseSuccess.bind(ctx, resolver, depth), handlePromiseFailure.bind(ctx, resolver, depth));
|
|
2369
|
+
}
|
|
2370
|
+
return createPromiseConstructorNode(ctx.base, id, resolver);
|
|
2371
|
+
}
|
|
2372
|
+
function parsePluginSync(ctx, depth, id, current, currentPlugins) {
|
|
2373
|
+
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
2374
|
+
const plugin = currentPlugins[i];
|
|
2375
|
+
if (plugin.parse.sync && plugin.test(current)) return createPluginNode(id, plugin.tag, plugin.parse.sync(current, new SyncParsePluginContext(ctx, depth), { id }));
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
function parsePluginStream(ctx, depth, id, current, currentPlugins) {
|
|
2379
|
+
for (let i = 0, len = currentPlugins.length; i < len; i++) {
|
|
2380
|
+
const plugin = currentPlugins[i];
|
|
2381
|
+
if (plugin.parse.stream && plugin.test(current)) return createPluginNode(id, plugin.tag, plugin.parse.stream(current, new StreamParsePluginContext(ctx, depth), { id }));
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
function parsePlugin(ctx, depth, id, current) {
|
|
2385
|
+
const currentPlugins = ctx.base.plugins;
|
|
2386
|
+
if (currentPlugins) return ctx.type === 1 ? parsePluginSync(ctx, depth, id, current, currentPlugins) : parsePluginStream(ctx, depth, id, current, currentPlugins);
|
|
2387
|
+
}
|
|
2388
|
+
function parseSequence(ctx, depth, id, current) {
|
|
2389
|
+
const nodes = [];
|
|
2390
|
+
for (let i = 0, len = current.v.length; i < len; i++) nodes[i] = parseSOS(ctx, depth, current.v[i]);
|
|
2391
|
+
return createSequenceNode(id, nodes, current.t, current.d);
|
|
2392
|
+
}
|
|
2393
|
+
function parseObjectPhase2(ctx, depth, id, current, currentClass) {
|
|
2394
|
+
switch (currentClass) {
|
|
2395
|
+
case Object: return parsePlainObject(ctx, depth, id, current, false);
|
|
2396
|
+
case void 0: return parsePlainObject(ctx, depth, id, current, true);
|
|
2397
|
+
case Date: return createDateNode(id, current);
|
|
2398
|
+
case Error:
|
|
2399
|
+
case EvalError:
|
|
2400
|
+
case RangeError:
|
|
2401
|
+
case ReferenceError:
|
|
2402
|
+
case SyntaxError:
|
|
2403
|
+
case TypeError:
|
|
2404
|
+
case URIError: return parseError(ctx, depth, id, current);
|
|
2405
|
+
case Number:
|
|
2406
|
+
case Boolean:
|
|
2407
|
+
case String:
|
|
2408
|
+
case BigInt: return parseBoxed(ctx, depth, id, current);
|
|
2409
|
+
case ArrayBuffer: return createArrayBufferNode(ctx.base, id, current);
|
|
2410
|
+
case Int8Array:
|
|
2411
|
+
case Int16Array:
|
|
2412
|
+
case Int32Array:
|
|
2413
|
+
case Uint8Array:
|
|
2414
|
+
case Uint16Array:
|
|
2415
|
+
case Uint32Array:
|
|
2416
|
+
case Uint8ClampedArray:
|
|
2417
|
+
case Float32Array:
|
|
2418
|
+
case Float64Array: return parseTypedArray(ctx, depth, id, current);
|
|
2419
|
+
case DataView: return parseDataView(ctx, depth, id, current);
|
|
2420
|
+
case Map: return parseMap(ctx, depth, id, current);
|
|
2421
|
+
case Set: return parseSet(ctx, depth, id, current);
|
|
2422
|
+
}
|
|
2423
|
+
if (currentClass === Promise || current instanceof Promise) return parsePromise(ctx, depth, id, current);
|
|
2424
|
+
const currentFeatures = ctx.base.features;
|
|
2425
|
+
if (currentFeatures & 32 && currentClass === RegExp) return createRegExpNode(id, current);
|
|
2426
|
+
if (currentFeatures & 16) switch (currentClass) {
|
|
2427
|
+
case BigInt64Array:
|
|
2428
|
+
case BigUint64Array: return parseBigIntTypedArray(ctx, depth, id, current);
|
|
2429
|
+
}
|
|
2430
|
+
if (currentFeatures & 1 && typeof AggregateError !== "undefined" && (currentClass === AggregateError || current instanceof AggregateError)) return parseAggregateError(ctx, depth, id, current);
|
|
2431
|
+
if (currentFeatures & 64 && typeof Temporal !== "undefined") switch (currentClass) {
|
|
2432
|
+
case Temporal.Instant: return createTemporalNode(id, 0, current);
|
|
2433
|
+
case Temporal.Duration: return createTemporalNode(id, 1, current);
|
|
2434
|
+
case Temporal.PlainDate: return createTemporalNode(id, 2, current);
|
|
2435
|
+
case Temporal.PlainDateTime: return createTemporalNode(id, 3, current);
|
|
2436
|
+
case Temporal.PlainMonthDay: return createTemporalNode(id, 4, current);
|
|
2437
|
+
case Temporal.PlainTime: return createTemporalNode(id, 5, current);
|
|
2438
|
+
case Temporal.PlainYearMonth: return createTemporalNode(id, 6, current);
|
|
2439
|
+
case Temporal.ZonedDateTime: return createTemporalNode(id, 7, current);
|
|
2440
|
+
}
|
|
2441
|
+
if (current instanceof Error) return parseError(ctx, depth, id, current);
|
|
2442
|
+
if (SYM_ITERATOR in current || SYM_ASYNC_ITERATOR in current) return parsePlainObject(ctx, depth, id, current, !!currentClass);
|
|
2443
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
2444
|
+
}
|
|
2445
|
+
function parseObject(ctx, depth, id, current) {
|
|
2446
|
+
if (Array.isArray(current)) return parseArray(ctx, depth, id, current);
|
|
2447
|
+
if (isStream(current)) return parseStream(ctx, depth, id, current);
|
|
2448
|
+
if (isSequence(current)) return parseSequence(ctx, depth, id, current);
|
|
2449
|
+
let currentClass = current.constructor;
|
|
2450
|
+
if (currentClass !== void 0 && typeof currentClass !== "function") {
|
|
2451
|
+
const proto = Object.getPrototypeOf(current);
|
|
2452
|
+
currentClass = proto === null ? void 0 : proto.constructor;
|
|
2453
|
+
}
|
|
2454
|
+
if (currentClass === OpaqueReference) return parseSOS(ctx, depth, current.replacement);
|
|
2455
|
+
const parsed = parsePlugin(ctx, depth, id, current);
|
|
2456
|
+
if (parsed) return parsed;
|
|
2457
|
+
return parseObjectPhase2(ctx, depth, id, current, currentClass);
|
|
2458
|
+
}
|
|
2459
|
+
function parseFunction(ctx, depth, current) {
|
|
2460
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
2461
|
+
if (ref.type !== 0) return ref.value;
|
|
2462
|
+
const plugin = parsePlugin(ctx, depth, ref.value, current);
|
|
2463
|
+
if (plugin) return plugin;
|
|
2464
|
+
throw new SerovalUnsupportedTypeError(current);
|
|
2465
|
+
}
|
|
2466
|
+
function parseSOS(ctx, depth, current) {
|
|
2467
|
+
if (depth >= ctx.base.depthLimit) throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
2468
|
+
switch (typeof current) {
|
|
2469
|
+
case "boolean": return current ? TRUE_NODE : FALSE_NODE;
|
|
2470
|
+
case "undefined": return UNDEFINED_NODE;
|
|
2471
|
+
case "string": return createStringNode(current);
|
|
2472
|
+
case "number": return createNumberNode(current);
|
|
2473
|
+
case "bigint": return createBigIntNode(current);
|
|
2474
|
+
case "object":
|
|
2475
|
+
if (current) {
|
|
2476
|
+
const ref = getReferenceNode(ctx.base, current);
|
|
2477
|
+
return ref.type === 0 ? parseObject(ctx, depth + 1, ref.value, current) : ref.value;
|
|
2478
|
+
}
|
|
2479
|
+
return NULL_NODE;
|
|
2480
|
+
case "symbol": return parseWellKnownSymbol(ctx.base, current);
|
|
2481
|
+
case "function": return parseFunction(ctx, depth, current);
|
|
2482
|
+
default: throw new SerovalUnsupportedTypeError(current);
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
function onParse(ctx, node) {
|
|
2486
|
+
if (ctx.state.initial) ctx.state.buffer.push(node);
|
|
2487
|
+
else onParseInternal(ctx, node, false);
|
|
2488
|
+
}
|
|
2489
|
+
function onError(ctx, error) {
|
|
2490
|
+
if (ctx.state.onError) ctx.state.onError(error);
|
|
2491
|
+
else throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
|
|
2492
|
+
}
|
|
2493
|
+
function onDone(ctx) {
|
|
2494
|
+
if (ctx.state.onDone) ctx.state.onDone();
|
|
2495
|
+
for (let i = 0, len = ctx.state.cleanups.length; i < len; i++) ctx.state.cleanups[i]();
|
|
2496
|
+
}
|
|
2497
|
+
function onParseInternal(ctx, node, initial) {
|
|
2498
|
+
try {
|
|
2499
|
+
ctx.state.onParse(node, initial);
|
|
2500
|
+
} catch (error) {
|
|
2501
|
+
onError(ctx, error);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
function pushPendingState(ctx) {
|
|
2505
|
+
ctx.state.pending++;
|
|
2506
|
+
}
|
|
2507
|
+
function popPendingState(ctx) {
|
|
2508
|
+
if (--ctx.state.pending <= 0) onDone(ctx);
|
|
2509
|
+
}
|
|
2510
|
+
function parseWithError(ctx, depth, current) {
|
|
2511
|
+
try {
|
|
2512
|
+
return parseSOS(ctx, depth, current);
|
|
2513
|
+
} catch (err) {
|
|
2514
|
+
onError(ctx, err);
|
|
2515
|
+
return;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
function startStreamParse(ctx, current) {
|
|
2519
|
+
const parsed = parseWithError(ctx, 0, current);
|
|
2520
|
+
if (parsed) {
|
|
2521
|
+
onParseInternal(ctx, parsed, true);
|
|
2522
|
+
ctx.state.initial = false;
|
|
2523
|
+
flushStreamParse(ctx, ctx.state);
|
|
2524
|
+
if (ctx.state.pending <= 0) destroyStreamParse(ctx);
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
function flushStreamParse(ctx, state) {
|
|
2528
|
+
for (let i = 0, len = state.buffer.length; i < len; i++) onParseInternal(ctx, state.buffer[i], false);
|
|
2529
|
+
}
|
|
2530
|
+
function destroyStreamParse(ctx) {
|
|
2531
|
+
if (ctx.state.alive) {
|
|
2532
|
+
onDone(ctx);
|
|
2533
|
+
ctx.state.alive = false;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
async function toCrossJSONAsync(source, options = {}) {
|
|
2537
|
+
return await parseTopAsync(createAsyncParserContext(2, {
|
|
2538
|
+
plugins: resolvePlugins(options.plugins),
|
|
2539
|
+
disabledFeatures: options.disabledFeatures,
|
|
2540
|
+
refs: options.refs
|
|
2541
|
+
}), source);
|
|
2542
|
+
}
|
|
2543
|
+
function crossSerializeStream(source, options) {
|
|
2544
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2545
|
+
const ctx = createStreamParserContext({
|
|
2546
|
+
plugins,
|
|
2547
|
+
refs: options.refs,
|
|
2548
|
+
disabledFeatures: options.disabledFeatures,
|
|
2549
|
+
onParse(node, initial) {
|
|
2550
|
+
const serial = createCrossSerializerContext({
|
|
2551
|
+
plugins,
|
|
2552
|
+
features: ctx.base.features,
|
|
2553
|
+
scopeId: options.scopeId,
|
|
2554
|
+
markedRefs: ctx.base.marked
|
|
2555
|
+
});
|
|
2556
|
+
let serialized;
|
|
2557
|
+
try {
|
|
2558
|
+
serialized = serializeTopCross(serial, node);
|
|
2559
|
+
} catch (err) {
|
|
2560
|
+
if (options.onError) options.onError(err);
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
options.onSerialize(serialized, initial);
|
|
2564
|
+
},
|
|
2565
|
+
onError: options.onError,
|
|
2566
|
+
onDone: options.onDone
|
|
2567
|
+
});
|
|
2568
|
+
startStreamParse(ctx, source);
|
|
2569
|
+
return destroyStreamParse.bind(null, ctx);
|
|
2570
|
+
}
|
|
2571
|
+
function toCrossJSONStream(source, options) {
|
|
2572
|
+
const ctx = createStreamParserContext({
|
|
2573
|
+
plugins: resolvePlugins(options.plugins),
|
|
2574
|
+
refs: options.refs,
|
|
2575
|
+
disabledFeatures: options.disabledFeatures,
|
|
2576
|
+
depthLimit: options.depthLimit,
|
|
2577
|
+
onParse: options.onParse,
|
|
2578
|
+
onError: options.onError,
|
|
2579
|
+
onDone: options.onDone
|
|
2580
|
+
});
|
|
2581
|
+
startStreamParse(ctx, source);
|
|
2582
|
+
return destroyStreamParse.bind(null, ctx);
|
|
2583
|
+
}
|
|
2584
|
+
function fromJSON(source, options = {}) {
|
|
2585
|
+
var _source$f;
|
|
2586
|
+
const plugins = resolvePlugins(options.plugins);
|
|
2587
|
+
const disabledFeatures = options.disabledFeatures || 0;
|
|
2588
|
+
const sourceFeatures = (_source$f = source.f) !== null && _source$f !== void 0 ? _source$f : 127;
|
|
2589
|
+
return deserializeTop(createVanillaDeserializerContext({
|
|
2590
|
+
plugins,
|
|
2591
|
+
markedRefs: source.m,
|
|
2592
|
+
features: sourceFeatures & ~disabledFeatures,
|
|
2593
|
+
disabledFeatures
|
|
2594
|
+
}), source.t);
|
|
2595
|
+
}
|
|
2596
|
+
//#endregion
|
|
2597
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/serializer/transformer.js
|
|
2598
|
+
/**
|
|
2599
|
+
* Create a strongly-typed serialization adapter for SSR hydration.
|
|
2600
|
+
* Use to register custom types with the router serializer.
|
|
2601
|
+
*/
|
|
2602
|
+
function createSerializationAdapter(opts) {
|
|
2603
|
+
return opts;
|
|
2604
|
+
}
|
|
2605
|
+
/** Create a Seroval plugin for server-side serialization only. */
|
|
2606
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2607
|
+
function makeSsrSerovalPlugin(serializationAdapter, options) {
|
|
2608
|
+
return /* @__PURE__ */ createPlugin({
|
|
2609
|
+
tag: "$TSR/t/" + serializationAdapter.key,
|
|
2610
|
+
test: serializationAdapter.test,
|
|
2611
|
+
parse: { stream(value, ctx, _data) {
|
|
2612
|
+
return { v: ctx.parse(serializationAdapter.toSerializable(value)) };
|
|
2613
|
+
} },
|
|
2614
|
+
serialize(node, ctx, _data) {
|
|
2615
|
+
options.didRun = true;
|
|
2616
|
+
return GLOBAL_TSR + ".t.get(\"" + serializationAdapter.key + "\")(" + ctx.serialize(node.v) + ")";
|
|
2617
|
+
},
|
|
2618
|
+
deserialize: void 0
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
/** Create a Seroval plugin for client/server symmetric (de)serialization. */
|
|
2622
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2623
|
+
function makeSerovalPlugin(serializationAdapter) {
|
|
2624
|
+
return /* @__PURE__ */ createPlugin({
|
|
2625
|
+
tag: "$TSR/t/" + serializationAdapter.key,
|
|
2626
|
+
test: serializationAdapter.test,
|
|
2627
|
+
parse: {
|
|
2628
|
+
sync(value, ctx, _data) {
|
|
2629
|
+
return { v: ctx.parse(serializationAdapter.toSerializable(value)) };
|
|
2630
|
+
},
|
|
2631
|
+
async async(value, ctx, _data) {
|
|
2632
|
+
return { v: await ctx.parse(serializationAdapter.toSerializable(value)) };
|
|
2633
|
+
},
|
|
2634
|
+
stream(value, ctx, _data) {
|
|
2635
|
+
return { v: ctx.parse(serializationAdapter.toSerializable(value)) };
|
|
2636
|
+
}
|
|
2637
|
+
},
|
|
2638
|
+
serialize: void 0,
|
|
2639
|
+
deserialize(node, ctx, _data) {
|
|
2640
|
+
return serializationAdapter.fromSerializable(ctx.deserialize(node.v));
|
|
2641
|
+
}
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
//#endregion
|
|
2645
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/serializer/RawStream.js
|
|
2646
|
+
/**
|
|
2647
|
+
* Marker class for ReadableStream<Uint8Array> that should be serialized
|
|
2648
|
+
* with base64 encoding (SSR) or binary framing (server functions).
|
|
2649
|
+
*
|
|
2650
|
+
* Wrap your binary streams with this to get efficient serialization:
|
|
2651
|
+
* ```ts
|
|
2652
|
+
* // For binary data (files, images, etc.)
|
|
2653
|
+
* return { data: new RawStream(file.stream()) }
|
|
2654
|
+
*
|
|
2655
|
+
* // For text-heavy data (RSC payloads, etc.)
|
|
2656
|
+
* return { data: new RawStream(rscStream, { hint: 'text' }) }
|
|
2657
|
+
* ```
|
|
2658
|
+
*/
|
|
2659
|
+
var RawStream = class {
|
|
2660
|
+
constructor(stream, options) {
|
|
2661
|
+
this.stream = stream;
|
|
2662
|
+
this.hint = options?.hint ?? "binary";
|
|
2663
|
+
}
|
|
2664
|
+
};
|
|
2665
|
+
var BufferCtor = globalThis.Buffer;
|
|
2666
|
+
var hasNodeBuffer = !!BufferCtor && typeof BufferCtor.from === "function";
|
|
2667
|
+
function uint8ArrayToBase64(bytes) {
|
|
2668
|
+
if (bytes.length === 0) return "";
|
|
2669
|
+
if (hasNodeBuffer) return BufferCtor.from(bytes).toString("base64");
|
|
2670
|
+
const CHUNK_SIZE = 32768;
|
|
2671
|
+
const chunks = [];
|
|
2672
|
+
for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
2673
|
+
const chunk = bytes.subarray(i, i + CHUNK_SIZE);
|
|
2674
|
+
chunks.push(String.fromCharCode.apply(null, chunk));
|
|
2675
|
+
}
|
|
2676
|
+
return btoa(chunks.join(""));
|
|
2677
|
+
}
|
|
2678
|
+
function base64ToUint8Array(base64) {
|
|
2679
|
+
if (base64.length === 0) return /* @__PURE__ */ new Uint8Array(0);
|
|
2680
|
+
if (hasNodeBuffer) {
|
|
2681
|
+
const buf = BufferCtor.from(base64, "base64");
|
|
2682
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
2683
|
+
}
|
|
2684
|
+
const binary = atob(base64);
|
|
2685
|
+
const bytes = new Uint8Array(binary.length);
|
|
2686
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
2687
|
+
return bytes;
|
|
2688
|
+
}
|
|
2689
|
+
var RAW_STREAM_FACTORY_BINARY = Object.create(null);
|
|
2690
|
+
var RAW_STREAM_FACTORY_TEXT = Object.create(null);
|
|
2691
|
+
var RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY = (stream) => new ReadableStream({ start(controller) {
|
|
2692
|
+
stream.on({
|
|
2693
|
+
next(base64) {
|
|
2694
|
+
try {
|
|
2695
|
+
controller.enqueue(base64ToUint8Array(base64));
|
|
2696
|
+
} catch {}
|
|
2697
|
+
},
|
|
2698
|
+
throw(error) {
|
|
2699
|
+
controller.error(error);
|
|
2700
|
+
},
|
|
2701
|
+
return() {
|
|
2702
|
+
try {
|
|
2703
|
+
controller.close();
|
|
2704
|
+
} catch {}
|
|
2705
|
+
}
|
|
2706
|
+
});
|
|
2707
|
+
} });
|
|
2708
|
+
var textEncoderForFactory = new TextEncoder();
|
|
2709
|
+
var RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT = (stream) => {
|
|
2710
|
+
return new ReadableStream({ start(controller) {
|
|
2711
|
+
stream.on({
|
|
2712
|
+
next(value) {
|
|
2713
|
+
try {
|
|
2714
|
+
if (typeof value === "string") controller.enqueue(textEncoderForFactory.encode(value));
|
|
2715
|
+
else controller.enqueue(base64ToUint8Array(value.$b64));
|
|
2716
|
+
} catch {}
|
|
2717
|
+
},
|
|
2718
|
+
throw(error) {
|
|
2719
|
+
controller.error(error);
|
|
2720
|
+
},
|
|
2721
|
+
return() {
|
|
2722
|
+
try {
|
|
2723
|
+
controller.close();
|
|
2724
|
+
} catch {}
|
|
2725
|
+
}
|
|
2726
|
+
});
|
|
2727
|
+
} });
|
|
2728
|
+
};
|
|
2729
|
+
var FACTORY_BINARY = `(s=>new ReadableStream({start(c){s.on({next(b){try{const d=atob(b),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}catch(_){}},throw(e){c.error(e)},return(){try{c.close()}catch(_){}}})}}))`;
|
|
2730
|
+
var FACTORY_TEXT = `(s=>{const e=new TextEncoder();return new ReadableStream({start(c){s.on({next(v){try{if(typeof v==='string'){c.enqueue(e.encode(v))}else{const d=atob(v.$b64),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}}catch(_){}},throw(x){c.error(x)},return(){try{c.close()}catch(_){}}})}})})`;
|
|
2731
|
+
function toBinaryStream(readable) {
|
|
2732
|
+
const stream = createStream();
|
|
2733
|
+
const reader = readable.getReader();
|
|
2734
|
+
(async () => {
|
|
2735
|
+
try {
|
|
2736
|
+
while (true) {
|
|
2737
|
+
const { done, value } = await reader.read();
|
|
2738
|
+
if (done) {
|
|
2739
|
+
stream.return(void 0);
|
|
2740
|
+
break;
|
|
2741
|
+
}
|
|
2742
|
+
stream.next(uint8ArrayToBase64(value));
|
|
2743
|
+
}
|
|
2744
|
+
} catch (error) {
|
|
2745
|
+
stream.throw(error);
|
|
2746
|
+
} finally {
|
|
2747
|
+
reader.releaseLock();
|
|
2748
|
+
}
|
|
2749
|
+
})();
|
|
2750
|
+
return stream;
|
|
2751
|
+
}
|
|
2752
|
+
function toTextStream(readable) {
|
|
2753
|
+
const stream = createStream();
|
|
2754
|
+
const reader = readable.getReader();
|
|
2755
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
2756
|
+
(async () => {
|
|
2757
|
+
try {
|
|
2758
|
+
while (true) {
|
|
2759
|
+
const { done, value } = await reader.read();
|
|
2760
|
+
if (done) {
|
|
2761
|
+
try {
|
|
2762
|
+
const remaining = decoder.decode();
|
|
2763
|
+
if (remaining.length > 0) stream.next(remaining);
|
|
2764
|
+
} catch {}
|
|
2765
|
+
stream.return(void 0);
|
|
2766
|
+
break;
|
|
2767
|
+
}
|
|
2768
|
+
try {
|
|
2769
|
+
const text = decoder.decode(value, { stream: true });
|
|
2770
|
+
if (text.length > 0) stream.next(text);
|
|
2771
|
+
} catch {
|
|
2772
|
+
stream.next({ $b64: uint8ArrayToBase64(value) });
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
} catch (error) {
|
|
2776
|
+
stream.throw(error);
|
|
2777
|
+
} finally {
|
|
2778
|
+
reader.releaseLock();
|
|
2779
|
+
}
|
|
2780
|
+
})();
|
|
2781
|
+
return stream;
|
|
2782
|
+
}
|
|
2783
|
+
/**
|
|
2784
|
+
* SSR Plugin - uses base64 or UTF-8+base64 encoding for chunks, delegates to seroval's stream mechanism.
|
|
2785
|
+
* Used during SSR when serializing to JavaScript code for HTML injection.
|
|
2786
|
+
*
|
|
2787
|
+
* Supports two modes based on RawStream hint:
|
|
2788
|
+
* - 'binary': Always base64 encode (default)
|
|
2789
|
+
* - 'text': Try UTF-8 first, fallback to base64 for invalid UTF-8
|
|
2790
|
+
*/
|
|
2791
|
+
var RawStreamSSRPlugin = /* @__PURE__ */ createPlugin({
|
|
2792
|
+
tag: "tss/RawStream",
|
|
2793
|
+
extends: [/* @__PURE__ */ createPlugin({
|
|
2794
|
+
tag: "tss/RawStreamFactory",
|
|
2795
|
+
test(value) {
|
|
2796
|
+
return value === RAW_STREAM_FACTORY_BINARY;
|
|
2797
|
+
},
|
|
2798
|
+
parse: {
|
|
2799
|
+
sync(_value, _ctx, _data) {
|
|
2800
|
+
return {};
|
|
2801
|
+
},
|
|
2802
|
+
async async(_value, _ctx, _data) {
|
|
2803
|
+
return {};
|
|
2804
|
+
},
|
|
2805
|
+
stream(_value, _ctx, _data) {
|
|
2806
|
+
return {};
|
|
2807
|
+
}
|
|
2808
|
+
},
|
|
2809
|
+
serialize(_node, _ctx, _data) {
|
|
2810
|
+
return FACTORY_BINARY;
|
|
2811
|
+
},
|
|
2812
|
+
deserialize(_node, _ctx, _data) {
|
|
2813
|
+
return RAW_STREAM_FACTORY_BINARY;
|
|
2814
|
+
}
|
|
2815
|
+
}), /* @__PURE__ */ createPlugin({
|
|
2816
|
+
tag: "tss/RawStreamFactoryText",
|
|
2817
|
+
test(value) {
|
|
2818
|
+
return value === RAW_STREAM_FACTORY_TEXT;
|
|
2819
|
+
},
|
|
2820
|
+
parse: {
|
|
2821
|
+
sync(_value, _ctx, _data) {
|
|
2822
|
+
return {};
|
|
2823
|
+
},
|
|
2824
|
+
async async(_value, _ctx, _data) {
|
|
2825
|
+
return {};
|
|
2826
|
+
},
|
|
2827
|
+
stream(_value, _ctx, _data) {
|
|
2828
|
+
return {};
|
|
2829
|
+
}
|
|
2830
|
+
},
|
|
2831
|
+
serialize(_node, _ctx, _data) {
|
|
2832
|
+
return FACTORY_TEXT;
|
|
2833
|
+
},
|
|
2834
|
+
deserialize(_node, _ctx, _data) {
|
|
2835
|
+
return RAW_STREAM_FACTORY_TEXT;
|
|
2836
|
+
}
|
|
2837
|
+
})],
|
|
2838
|
+
test(value) {
|
|
2839
|
+
return value instanceof RawStream;
|
|
2840
|
+
},
|
|
2841
|
+
parse: {
|
|
2842
|
+
sync(value, ctx, _data) {
|
|
2843
|
+
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
2844
|
+
return {
|
|
2845
|
+
hint: ctx.parse(value.hint),
|
|
2846
|
+
factory: ctx.parse(factory),
|
|
2847
|
+
stream: ctx.parse(createStream())
|
|
2848
|
+
};
|
|
2849
|
+
},
|
|
2850
|
+
async async(value, ctx, _data) {
|
|
2851
|
+
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
2852
|
+
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
2853
|
+
return {
|
|
2854
|
+
hint: await ctx.parse(value.hint),
|
|
2855
|
+
factory: await ctx.parse(factory),
|
|
2856
|
+
stream: await ctx.parse(encodedStream)
|
|
2857
|
+
};
|
|
2858
|
+
},
|
|
2859
|
+
stream(value, ctx, _data) {
|
|
2860
|
+
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
2861
|
+
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
2862
|
+
return {
|
|
2863
|
+
hint: ctx.parse(value.hint),
|
|
2864
|
+
factory: ctx.parse(factory),
|
|
2865
|
+
stream: ctx.parse(encodedStream)
|
|
2866
|
+
};
|
|
2867
|
+
}
|
|
2868
|
+
},
|
|
2869
|
+
serialize(node, ctx, _data) {
|
|
2870
|
+
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
|
|
2871
|
+
},
|
|
2872
|
+
deserialize(node, ctx, _data) {
|
|
2873
|
+
const stream = ctx.deserialize(node.stream);
|
|
2874
|
+
return ctx.deserialize(node.hint) === "text" ? RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT(stream) : RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY(stream);
|
|
2875
|
+
}
|
|
2876
|
+
});
|
|
2877
|
+
/**
|
|
2878
|
+
* Creates an RPC plugin instance that registers raw streams with a multiplexer.
|
|
2879
|
+
* Used for server function responses where we want binary framing.
|
|
2880
|
+
* Note: RPC always uses binary framing regardless of hint.
|
|
2881
|
+
*
|
|
2882
|
+
* @param onRawStream Callback invoked when a RawStream is encountered during serialization
|
|
2883
|
+
*/
|
|
2884
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2885
|
+
function createRawStreamRPCPlugin(onRawStream) {
|
|
2886
|
+
let nextStreamId = 1;
|
|
2887
|
+
return /* @__PURE__ */ createPlugin({
|
|
2888
|
+
tag: "tss/RawStream",
|
|
2889
|
+
test(value) {
|
|
2890
|
+
return value instanceof RawStream;
|
|
2891
|
+
},
|
|
2892
|
+
parse: {
|
|
2893
|
+
async async(value, ctx, _data) {
|
|
2894
|
+
const streamId = nextStreamId++;
|
|
2895
|
+
onRawStream(streamId, value.stream);
|
|
2896
|
+
return { streamId: await ctx.parse(streamId) };
|
|
2897
|
+
},
|
|
2898
|
+
stream(value, ctx, _data) {
|
|
2899
|
+
const streamId = nextStreamId++;
|
|
2900
|
+
onRawStream(streamId, value.stream);
|
|
2901
|
+
return { streamId: ctx.parse(streamId) };
|
|
2902
|
+
}
|
|
2903
|
+
},
|
|
2904
|
+
serialize() {
|
|
2905
|
+
throw new Error("RawStreamRPCPlugin.serialize should not be called. RPC uses JSON serialization, not JS code generation.");
|
|
2906
|
+
},
|
|
2907
|
+
deserialize() {
|
|
2908
|
+
throw new Error("RawStreamRPCPlugin.deserialize should not be called. Use createRawStreamDeserializePlugin on client.");
|
|
2909
|
+
}
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
//#endregion
|
|
2913
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/serializer/ShallowErrorPlugin.js
|
|
2914
|
+
/**
|
|
2915
|
+
* this plugin serializes only the `message` part of an Error
|
|
2916
|
+
* this helps with serializing e.g. a ZodError which has functions attached that cannot be serialized
|
|
2917
|
+
*/
|
|
2918
|
+
var ShallowErrorPlugin = /* @__PURE__ */ createPlugin({
|
|
2919
|
+
tag: "$TSR/Error",
|
|
2920
|
+
test(value) {
|
|
2921
|
+
return value instanceof Error;
|
|
2922
|
+
},
|
|
2923
|
+
parse: {
|
|
2924
|
+
sync(value, ctx) {
|
|
2925
|
+
return { message: ctx.parse(value.message) };
|
|
2926
|
+
},
|
|
2927
|
+
async async(value, ctx) {
|
|
2928
|
+
return { message: await ctx.parse(value.message) };
|
|
2929
|
+
},
|
|
2930
|
+
stream(value, ctx) {
|
|
2931
|
+
return { message: ctx.parse(value.message) };
|
|
2932
|
+
}
|
|
2933
|
+
},
|
|
2934
|
+
serialize(node, ctx) {
|
|
2935
|
+
return "new Error(" + ctx.serialize(node.message) + ")";
|
|
2936
|
+
},
|
|
2937
|
+
deserialize(node, ctx) {
|
|
2938
|
+
return new Error(ctx.deserialize(node.message));
|
|
2939
|
+
}
|
|
2940
|
+
});
|
|
2941
|
+
//#endregion
|
|
2942
|
+
//#region node_modules/seroval-plugins/dist/web-43VA2W_p.js
|
|
2943
|
+
var READABLE_STREAM_FACTORY = {};
|
|
2944
|
+
var READABLE_STREAM_FACTORY_CONSTRUCTOR = (stream) => new ReadableStream({ start(controller) {
|
|
2945
|
+
stream.on({
|
|
2946
|
+
next(value) {
|
|
2947
|
+
try {
|
|
2948
|
+
controller.enqueue(value);
|
|
2949
|
+
} catch (_error) {}
|
|
2950
|
+
},
|
|
2951
|
+
throw(value) {
|
|
2952
|
+
controller.error(value);
|
|
2953
|
+
},
|
|
2954
|
+
return() {
|
|
2955
|
+
try {
|
|
2956
|
+
controller.close();
|
|
2957
|
+
} catch (_error) {}
|
|
2958
|
+
}
|
|
2959
|
+
});
|
|
2960
|
+
} });
|
|
2961
|
+
var ReadableStreamFactoryPlugin = /* @__PURE__ */ createPlugin({
|
|
2962
|
+
tag: "seroval-plugins/web/ReadableStreamFactory",
|
|
2963
|
+
test(value) {
|
|
2964
|
+
return value === READABLE_STREAM_FACTORY;
|
|
2965
|
+
},
|
|
2966
|
+
parse: {
|
|
2967
|
+
sync() {
|
|
2968
|
+
return READABLE_STREAM_FACTORY;
|
|
2969
|
+
},
|
|
2970
|
+
async async() {
|
|
2971
|
+
return await Promise.resolve(READABLE_STREAM_FACTORY);
|
|
2972
|
+
},
|
|
2973
|
+
stream() {
|
|
2974
|
+
return READABLE_STREAM_FACTORY;
|
|
2975
|
+
}
|
|
2976
|
+
},
|
|
2977
|
+
serialize() {
|
|
2978
|
+
return READABLE_STREAM_FACTORY_CONSTRUCTOR.toString();
|
|
2979
|
+
},
|
|
2980
|
+
deserialize() {
|
|
2981
|
+
return READABLE_STREAM_FACTORY;
|
|
2982
|
+
}
|
|
2983
|
+
});
|
|
2984
|
+
async function drainStream(stream, reader) {
|
|
2985
|
+
try {
|
|
2986
|
+
const result = await reader.read();
|
|
2987
|
+
if (result.done) {
|
|
2988
|
+
stream.return(result.value);
|
|
2989
|
+
reader.releaseLock();
|
|
2990
|
+
} else {
|
|
2991
|
+
stream.next(result.value);
|
|
2992
|
+
await drainStream(stream, reader);
|
|
2993
|
+
}
|
|
2994
|
+
} catch (error) {
|
|
2995
|
+
stream.throw(error);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
function cleanupStream(reader) {
|
|
2999
|
+
reader.cancel().catch(() => {});
|
|
3000
|
+
reader.releaseLock();
|
|
3001
|
+
}
|
|
3002
|
+
function toStream(value) {
|
|
3003
|
+
const stream = createStream();
|
|
3004
|
+
const reader = value.getReader();
|
|
3005
|
+
const cleanup = cleanupStream.bind(null, reader);
|
|
3006
|
+
drainStream(stream, reader).catch(cleanup);
|
|
3007
|
+
return [stream, cleanup];
|
|
3008
|
+
}
|
|
3009
|
+
//#endregion
|
|
3010
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/serializer/seroval-plugins.js
|
|
3011
|
+
var defaultSerovalPlugins = [
|
|
3012
|
+
ShallowErrorPlugin,
|
|
3013
|
+
RawStreamSSRPlugin,
|
|
3014
|
+
/* @__PURE__ */ createPlugin({
|
|
3015
|
+
tag: "seroval/plugins/web/ReadableStream",
|
|
3016
|
+
extends: [ReadableStreamFactoryPlugin],
|
|
3017
|
+
test(value) {
|
|
3018
|
+
if (typeof ReadableStream === "undefined") return false;
|
|
3019
|
+
return value instanceof ReadableStream;
|
|
3020
|
+
},
|
|
3021
|
+
parse: {
|
|
3022
|
+
sync(_value, ctx) {
|
|
3023
|
+
return {
|
|
3024
|
+
factory: ctx.parse(READABLE_STREAM_FACTORY),
|
|
3025
|
+
stream: ctx.parse(createStream())
|
|
3026
|
+
};
|
|
3027
|
+
},
|
|
3028
|
+
async async(value, ctx) {
|
|
3029
|
+
return {
|
|
3030
|
+
factory: await ctx.parse(READABLE_STREAM_FACTORY),
|
|
3031
|
+
stream: await ctx.parse(toStream(value)[0])
|
|
3032
|
+
};
|
|
3033
|
+
},
|
|
3034
|
+
stream(value, ctx) {
|
|
3035
|
+
const [stream, cleanup] = toStream(value);
|
|
3036
|
+
ctx.addCleanup(cleanup);
|
|
3037
|
+
return {
|
|
3038
|
+
factory: ctx.parse(READABLE_STREAM_FACTORY),
|
|
3039
|
+
stream: ctx.parse(stream)
|
|
3040
|
+
};
|
|
3041
|
+
}
|
|
3042
|
+
},
|
|
3043
|
+
serialize(node, ctx) {
|
|
3044
|
+
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
|
|
3045
|
+
},
|
|
3046
|
+
deserialize(node, ctx) {
|
|
3047
|
+
return READABLE_STREAM_FACTORY_CONSTRUCTOR(ctx.deserialize(node.stream));
|
|
3048
|
+
}
|
|
3049
|
+
})
|
|
3050
|
+
];
|
|
3051
|
+
//#endregion
|
|
3052
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/tsrScript.js
|
|
3053
|
+
var tsrScript_default = "self.$_TSR={h(){this.hydrated=!0,this.c()},e(){this.streamEnded=!0,this.c()},c(){this.hydrated&&this.streamEnded&&(delete self.$_TSR,delete self.$R.tsr)},p(e){this.initialized?e():this.buffer.push(e)},buffer:[]}";
|
|
3054
|
+
//#endregion
|
|
3055
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/ssr-server.js
|
|
3056
|
+
var SCOPE_ID = "tsr";
|
|
3057
|
+
var TSR_PREFIX = GLOBAL_TSR + ".router=";
|
|
3058
|
+
var P_PREFIX = GLOBAL_TSR + ".p(()=>";
|
|
3059
|
+
var P_SUFFIX = ")";
|
|
3060
|
+
function dehydrateMatch(match) {
|
|
3061
|
+
const dehydratedMatch = {
|
|
3062
|
+
i: dehydrateSsrMatchId(match.id),
|
|
3063
|
+
u: match.updatedAt,
|
|
3064
|
+
s: match.status
|
|
3065
|
+
};
|
|
3066
|
+
for (const [key, shorthand] of [
|
|
3067
|
+
["__beforeLoadContext", "b"],
|
|
3068
|
+
["loaderData", "l"],
|
|
3069
|
+
["error", "e"],
|
|
3070
|
+
["ssr", "ssr"]
|
|
3071
|
+
]) if (match[key] !== void 0) dehydratedMatch[shorthand] = match[key];
|
|
3072
|
+
if (match._notFound) dehydratedMatch.g = true;
|
|
3073
|
+
return dehydratedMatch;
|
|
3074
|
+
}
|
|
3075
|
+
var INITIAL_SCRIPTS = [getCrossReferenceHeader(SCOPE_ID), tsrScript_default];
|
|
3076
|
+
var ScriptBuffer = class {
|
|
3077
|
+
constructor(injectScript) {
|
|
3078
|
+
this._scriptBarrierLifted = false;
|
|
3079
|
+
this._cleanedUp = false;
|
|
3080
|
+
this._microtaskVersion = 0;
|
|
3081
|
+
this._pendingMicrotaskVersion = 0;
|
|
3082
|
+
this.injectScript = injectScript;
|
|
3083
|
+
this._queue = INITIAL_SCRIPTS.slice();
|
|
3084
|
+
}
|
|
3085
|
+
enqueue(script) {
|
|
3086
|
+
if (this._cleanedUp) return;
|
|
3087
|
+
this._queue.push(script);
|
|
3088
|
+
if (this._scriptBarrierLifted) this.scheduleInjectBufferedScripts();
|
|
3089
|
+
}
|
|
3090
|
+
liftBarrier() {
|
|
3091
|
+
if (this._scriptBarrierLifted || this._cleanedUp) return;
|
|
3092
|
+
this._scriptBarrierLifted = true;
|
|
3093
|
+
if (this._queue.length > 0) this.scheduleInjectBufferedScripts();
|
|
3094
|
+
}
|
|
3095
|
+
scheduleInjectBufferedScripts() {
|
|
3096
|
+
if (this._pendingMicrotaskVersion !== 0) return;
|
|
3097
|
+
const pendingVersion = ++this._microtaskVersion;
|
|
3098
|
+
this._pendingMicrotaskVersion = pendingVersion;
|
|
3099
|
+
queueMicrotask(() => {
|
|
3100
|
+
if (this._pendingMicrotaskVersion !== pendingVersion) return;
|
|
3101
|
+
this._pendingMicrotaskVersion = 0;
|
|
3102
|
+
this.injectBufferedScripts();
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
clearPendingMicrotask() {
|
|
3106
|
+
if (this._pendingMicrotaskVersion === 0) return;
|
|
3107
|
+
this._pendingMicrotaskVersion = 0;
|
|
3108
|
+
this._microtaskVersion++;
|
|
3109
|
+
}
|
|
3110
|
+
/**
|
|
3111
|
+
* Flushes any pending scripts synchronously.
|
|
3112
|
+
* Call this before signaling serialization finished to ensure all scripts are injected.
|
|
3113
|
+
*
|
|
3114
|
+
* IMPORTANT: Only injects if the barrier has been lifted. Before the barrier is lifted,
|
|
3115
|
+
* scripts should remain in the queue so takeBufferedScripts() can retrieve them
|
|
3116
|
+
*/
|
|
3117
|
+
flush() {
|
|
3118
|
+
if (!this._scriptBarrierLifted) return;
|
|
3119
|
+
if (this._cleanedUp) return;
|
|
3120
|
+
this.clearPendingMicrotask();
|
|
3121
|
+
this.injectBufferedScripts();
|
|
3122
|
+
}
|
|
3123
|
+
takeAll() {
|
|
3124
|
+
return this.takeScripts(this._queue.length);
|
|
3125
|
+
}
|
|
3126
|
+
takeScripts(count) {
|
|
3127
|
+
if (count <= 0) return void 0;
|
|
3128
|
+
const bufferedScripts = this._queue.splice(0, count);
|
|
3129
|
+
if (bufferedScripts.length === 0) return;
|
|
3130
|
+
if (bufferedScripts.length === 1) return bufferedScripts[0] + ";document.currentScript.remove()";
|
|
3131
|
+
return bufferedScripts.join(";") + ";document.currentScript.remove()";
|
|
3132
|
+
}
|
|
3133
|
+
hasPending() {
|
|
3134
|
+
return this._queue.length > 0;
|
|
3135
|
+
}
|
|
3136
|
+
injectBufferedScripts() {
|
|
3137
|
+
if (this._cleanedUp) return;
|
|
3138
|
+
if (this._queue.length === 0) return;
|
|
3139
|
+
const scriptsToInject = this.takeAll();
|
|
3140
|
+
if (scriptsToInject) this.injectScript?.(scriptsToInject);
|
|
3141
|
+
}
|
|
3142
|
+
cleanup() {
|
|
3143
|
+
this._cleanedUp = true;
|
|
3144
|
+
this.clearPendingMicrotask();
|
|
3145
|
+
this._queue = [];
|
|
3146
|
+
this.injectScript = void 0;
|
|
3147
|
+
}
|
|
3148
|
+
};
|
|
3149
|
+
var MANIFEST_CACHE_SIZE = 100;
|
|
3150
|
+
var manifestCaches = /* @__PURE__ */ new WeakMap();
|
|
3151
|
+
function getManifestCache(manifest) {
|
|
3152
|
+
const cache = manifestCaches.get(manifest);
|
|
3153
|
+
if (cache) return cache;
|
|
3154
|
+
const newCache = createLRUCache(MANIFEST_CACHE_SIZE);
|
|
3155
|
+
manifestCaches.set(manifest, newCache);
|
|
3156
|
+
return newCache;
|
|
3157
|
+
}
|
|
3158
|
+
function getInlineCssForPreparedRoutes(manifest, preparedRoutes) {
|
|
3159
|
+
if (preparedRoutes.inlineCss !== void 0) return preparedRoutes.inlineCss;
|
|
3160
|
+
const styles = manifest.inlineCss?.styles;
|
|
3161
|
+
const hrefs = preparedRoutes.inlineCssHrefs;
|
|
3162
|
+
if (!styles || !hrefs?.length) return void 0;
|
|
3163
|
+
let css = "";
|
|
3164
|
+
for (const href of hrefs) css += styles[href];
|
|
3165
|
+
preparedRoutes.inlineCss = css;
|
|
3166
|
+
return css;
|
|
3167
|
+
}
|
|
3168
|
+
function getInlineCssAssetForPreparedRoutes(manifest, preparedRoutes) {
|
|
3169
|
+
const css = getInlineCssForPreparedRoutes(manifest, preparedRoutes);
|
|
3170
|
+
return css === void 0 ? void 0 : createInlineCssStyleAsset(css);
|
|
3171
|
+
}
|
|
3172
|
+
function getMatchedRoutesCacheKey(matches) {
|
|
3173
|
+
let cacheKey = "";
|
|
3174
|
+
for (let i = 0; i < matches.length; i++) cacheKey += (i === 0 ? "" : "\0") + matches[i].routeId;
|
|
3175
|
+
return cacheKey;
|
|
3176
|
+
}
|
|
3177
|
+
function getPreparedMatchedManifestRoutes(manifest, matches, cacheKey) {
|
|
3178
|
+
{
|
|
3179
|
+
const cached = getManifestCache(manifest).get(cacheKey);
|
|
3180
|
+
if (cached) return cached;
|
|
3181
|
+
}
|
|
3182
|
+
const preparedRoutes = prepareMatchedManifestRoutes(manifest, matches);
|
|
3183
|
+
getManifestCache(manifest).set(cacheKey, preparedRoutes);
|
|
3184
|
+
return preparedRoutes;
|
|
3185
|
+
}
|
|
3186
|
+
function prepareMatchedManifestRoutes(manifest, matches) {
|
|
3187
|
+
const inlineStyles = manifest.inlineCss?.styles;
|
|
3188
|
+
const routes = {};
|
|
3189
|
+
if (!inlineStyles) {
|
|
3190
|
+
for (const match of matches) {
|
|
3191
|
+
const route = manifest.routes[match.routeId];
|
|
3192
|
+
if (route) routes[match.routeId] = route;
|
|
3193
|
+
}
|
|
3194
|
+
return {
|
|
3195
|
+
routes,
|
|
3196
|
+
hasStrippedRoutes: false
|
|
3197
|
+
};
|
|
3198
|
+
}
|
|
3199
|
+
const inlineCssHrefs = [];
|
|
3200
|
+
const seenInlineCssHrefs = /* @__PURE__ */ new Set();
|
|
3201
|
+
let hasStrippedRoutes = false;
|
|
3202
|
+
for (const match of matches) {
|
|
3203
|
+
const routeId = match.routeId;
|
|
3204
|
+
const route = manifest.routes[routeId];
|
|
3205
|
+
if (!route) continue;
|
|
3206
|
+
const nextRoute = stripInlinedStylesheetAssetsFromRoute(inlineStyles, route, inlineCssHrefs, seenInlineCssHrefs);
|
|
3207
|
+
if (nextRoute !== route) hasStrippedRoutes = true;
|
|
3208
|
+
routes[routeId] = nextRoute;
|
|
3209
|
+
}
|
|
3210
|
+
return {
|
|
3211
|
+
routes,
|
|
3212
|
+
hasStrippedRoutes,
|
|
3213
|
+
...inlineCssHrefs.length ? { inlineCssHrefs } : {}
|
|
3214
|
+
};
|
|
3215
|
+
}
|
|
3216
|
+
function stripInlinedStylesheetAssetsFromRoute(inlineStyles, route, inlineCssHrefs, seenInlineCssHrefs) {
|
|
3217
|
+
const css = route.css;
|
|
3218
|
+
if (!css) return route;
|
|
3219
|
+
if (css.length === 0) {
|
|
3220
|
+
const nextRoute = { ...route };
|
|
3221
|
+
delete nextRoute.css;
|
|
3222
|
+
return nextRoute;
|
|
3223
|
+
}
|
|
3224
|
+
let cssLinks;
|
|
3225
|
+
for (let i = 0; i < css.length; i++) {
|
|
3226
|
+
const link = css[i];
|
|
3227
|
+
const href = getStylesheetHref(link);
|
|
3228
|
+
if (inlineStyles[href] === void 0) {
|
|
3229
|
+
if (cssLinks) cssLinks.push(link);
|
|
3230
|
+
continue;
|
|
3231
|
+
}
|
|
3232
|
+
if (!seenInlineCssHrefs.has(href)) {
|
|
3233
|
+
seenInlineCssHrefs.add(href);
|
|
3234
|
+
inlineCssHrefs.push(href);
|
|
3235
|
+
}
|
|
3236
|
+
if (!cssLinks) cssLinks = css.slice(0, i);
|
|
3237
|
+
}
|
|
3238
|
+
if (!cssLinks) return route;
|
|
3239
|
+
if (cssLinks.length > 0) return {
|
|
3240
|
+
...route,
|
|
3241
|
+
css: cssLinks
|
|
3242
|
+
};
|
|
3243
|
+
const nextRoute = { ...route };
|
|
3244
|
+
delete nextRoute.css;
|
|
3245
|
+
return nextRoute;
|
|
3246
|
+
}
|
|
3247
|
+
function hasRouteAssets(route) {
|
|
3248
|
+
return !!route.scripts?.length || !!route.css?.length;
|
|
3249
|
+
}
|
|
3250
|
+
function hasRequestAssets(assets) {
|
|
3251
|
+
return !!assets && (!!assets.preloads?.length || hasRouteAssets(assets));
|
|
3252
|
+
}
|
|
3253
|
+
function mergeRequestAssetsIntoRootRoute(rootRoute, requestAssets) {
|
|
3254
|
+
const preloads = requestAssets?.preloads?.length ? [...requestAssets.preloads, ...rootRoute?.preloads ?? []] : rootRoute?.preloads;
|
|
3255
|
+
const scripts = requestAssets?.scripts?.length ? [...requestAssets.scripts, ...rootRoute?.scripts ?? []] : rootRoute?.scripts;
|
|
3256
|
+
const cssLinks = requestAssets?.css?.length ? [...requestAssets.css, ...rootRoute?.css ?? []] : rootRoute?.css;
|
|
3257
|
+
return {
|
|
3258
|
+
...rootRoute ?? {},
|
|
3259
|
+
...preloads?.length ? { preloads } : {},
|
|
3260
|
+
...scripts?.length ? { scripts } : {},
|
|
3261
|
+
...cssLinks?.length ? { css: cssLinks } : {}
|
|
3262
|
+
};
|
|
3263
|
+
}
|
|
3264
|
+
function attachRouterServerSsrUtils({ router, manifest, getRequestAssets }) {
|
|
3265
|
+
router.ssr = { get manifest() {
|
|
3266
|
+
if (!manifest) return manifest;
|
|
3267
|
+
const requestAssets = getRequestAssets?.();
|
|
3268
|
+
const matches = _getRenderedMatches(router.stores.matches.get());
|
|
3269
|
+
const hasAssets = hasRequestAssets(requestAssets);
|
|
3270
|
+
if (!hasAssets && !manifest.inlineCss) return manifest;
|
|
3271
|
+
let inlineCssAsset;
|
|
3272
|
+
let routes = manifest.routes;
|
|
3273
|
+
if (manifest.inlineCss) {
|
|
3274
|
+
const preparedManifest = getPreparedMatchedManifestRoutes(manifest, matches, getMatchedRoutesCacheKey(matches));
|
|
3275
|
+
inlineCssAsset = getInlineCssAssetForPreparedRoutes(manifest, preparedManifest);
|
|
3276
|
+
if (preparedManifest.hasStrippedRoutes) routes = {
|
|
3277
|
+
...manifest.routes,
|
|
3278
|
+
...preparedManifest.routes
|
|
3279
|
+
};
|
|
3280
|
+
}
|
|
3281
|
+
if (!hasAssets) return {
|
|
3282
|
+
...manifest.scriptFormat ? { scriptFormat: manifest.scriptFormat } : {},
|
|
3283
|
+
...inlineCssAsset ? { inlineStyle: inlineCssAsset } : {},
|
|
3284
|
+
routes
|
|
3285
|
+
};
|
|
3286
|
+
const rootRoute = routes[rootRouteId];
|
|
3287
|
+
return {
|
|
3288
|
+
...manifest.scriptFormat ? { scriptFormat: manifest.scriptFormat } : {},
|
|
3289
|
+
...inlineCssAsset ? { inlineStyle: inlineCssAsset } : {},
|
|
3290
|
+
routes: {
|
|
3291
|
+
...routes,
|
|
3292
|
+
[rootRouteId]: mergeRequestAssetsIntoRootRoute(rootRoute, requestAssets)
|
|
3293
|
+
}
|
|
3294
|
+
};
|
|
3295
|
+
} };
|
|
3296
|
+
let _dehydrated = false;
|
|
3297
|
+
let _serializationFinished = false;
|
|
3298
|
+
let streamFastPathReserved = false;
|
|
3299
|
+
const renderFinishedListeners = [];
|
|
3300
|
+
const injectedHtmlListeners = [];
|
|
3301
|
+
const serializationFinishedListeners = [];
|
|
3302
|
+
const cleanupListeners = [];
|
|
3303
|
+
let cleanupStarted = false;
|
|
3304
|
+
let injectedHtmlBuffer = "";
|
|
3305
|
+
const callListeners = (listeners, errorPrefix) => {
|
|
3306
|
+
const snapshot = listeners.slice();
|
|
3307
|
+
for (const l of snapshot) try {
|
|
3308
|
+
l();
|
|
3309
|
+
} catch (err) {
|
|
3310
|
+
console.error(`${errorPrefix}:`, err);
|
|
3311
|
+
}
|
|
3312
|
+
};
|
|
3313
|
+
const removeListener = (listeners, listener) => {
|
|
3314
|
+
const index = listeners.indexOf(listener);
|
|
3315
|
+
if (index >= 0) listeners.splice(index, 1);
|
|
3316
|
+
};
|
|
3317
|
+
const scriptBuffer = new ScriptBuffer((script) => {
|
|
3318
|
+
serverSsr.injectScript(script);
|
|
3319
|
+
});
|
|
3320
|
+
const serverSsr = {
|
|
3321
|
+
injectHtml: (html) => {
|
|
3322
|
+
if (!html || cleanupStarted) return;
|
|
3323
|
+
injectedHtmlBuffer += html;
|
|
3324
|
+
callListeners(injectedHtmlListeners, "SSR injected HTML listener error");
|
|
3325
|
+
},
|
|
3326
|
+
injectScript: (script) => {
|
|
3327
|
+
if (!script || cleanupStarted) return;
|
|
3328
|
+
const html = `<script${router.options.ssr?.nonce ? ` nonce='${router.options.ssr.nonce}'` : ""}>${script}<\/script>`;
|
|
3329
|
+
serverSsr.injectHtml(html);
|
|
3330
|
+
},
|
|
3331
|
+
dehydrate: async (opts) => {
|
|
3332
|
+
if (_dehydrated) invariant();
|
|
3333
|
+
let matchesToDehydrate = _getRenderedMatches(router.stores.matches.get());
|
|
3334
|
+
if (router.isShell()) matchesToDehydrate = matchesToDehydrate.slice(0, 1);
|
|
3335
|
+
const matches = matchesToDehydrate.map(dehydrateMatch);
|
|
3336
|
+
let manifestToDehydrate = void 0;
|
|
3337
|
+
if (manifest) {
|
|
3338
|
+
const cacheKey = getMatchedRoutesCacheKey(matchesToDehydrate);
|
|
3339
|
+
const preparedManifest = getPreparedMatchedManifestRoutes(manifest, matchesToDehydrate, cacheKey);
|
|
3340
|
+
manifestToDehydrate = {
|
|
3341
|
+
...manifest.scriptFormat ? { scriptFormat: manifest.scriptFormat } : {},
|
|
3342
|
+
...preparedManifest.inlineCssHrefs ? { inlineStyle: createInlineCssPlaceholderAsset() } : {},
|
|
3343
|
+
routes: preparedManifest.routes
|
|
3344
|
+
};
|
|
3345
|
+
const requestAssets = opts?.requestAssets;
|
|
3346
|
+
if (hasRequestAssets(requestAssets)) {
|
|
3347
|
+
const existingRoot = manifestToDehydrate.routes[rootRouteId];
|
|
3348
|
+
manifestToDehydrate.routes = {
|
|
3349
|
+
...manifestToDehydrate.routes,
|
|
3350
|
+
[rootRouteId]: mergeRequestAssetsIntoRootRoute(existingRoot, requestAssets)
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
const dehydratedRouter = {
|
|
3355
|
+
manifest: manifestToDehydrate,
|
|
3356
|
+
matches
|
|
3357
|
+
};
|
|
3358
|
+
const dehydratedData = await router.options.dehydrate?.();
|
|
3359
|
+
if (cleanupStarted) return;
|
|
3360
|
+
if (dehydratedData) dehydratedRouter.dehydratedData = dehydratedData;
|
|
3361
|
+
_dehydrated = true;
|
|
3362
|
+
const trackPlugins = { didRun: false };
|
|
3363
|
+
const serializationAdapters = router.options.serializationAdapters;
|
|
3364
|
+
const plugins = serializationAdapters ? serializationAdapters.map((t) => /* @__PURE__ */ makeSsrSerovalPlugin(t, trackPlugins)).concat(defaultSerovalPlugins) : defaultSerovalPlugins;
|
|
3365
|
+
let serializationCompleteSignaled = false;
|
|
3366
|
+
const signalSerializationComplete = () => {
|
|
3367
|
+
if (serializationCompleteSignaled || cleanupStarted) return;
|
|
3368
|
+
serializationCompleteSignaled = true;
|
|
3369
|
+
_serializationFinished = true;
|
|
3370
|
+
const listeners = serializationFinishedListeners.slice();
|
|
3371
|
+
serializationFinishedListeners.length = 0;
|
|
3372
|
+
for (const l of listeners) try {
|
|
3373
|
+
l();
|
|
3374
|
+
} catch (err) {
|
|
3375
|
+
console.error("Serialization listener error:", err);
|
|
3376
|
+
}
|
|
3377
|
+
};
|
|
3378
|
+
const finishScriptSerialization = () => {
|
|
3379
|
+
if (serializationCompleteSignaled || cleanupStarted) return;
|
|
3380
|
+
scriptBuffer.enqueue(GLOBAL_TSR + ".e()");
|
|
3381
|
+
scriptBuffer.flush();
|
|
3382
|
+
signalSerializationComplete();
|
|
3383
|
+
};
|
|
3384
|
+
crossSerializeStream(dehydratedRouter, {
|
|
3385
|
+
refs: /* @__PURE__ */ new Map(),
|
|
3386
|
+
plugins,
|
|
3387
|
+
onSerialize: (data, initial) => {
|
|
3388
|
+
let serialized = initial ? TSR_PREFIX + data : data;
|
|
3389
|
+
if (trackPlugins.didRun) serialized = P_PREFIX + serialized + P_SUFFIX;
|
|
3390
|
+
scriptBuffer.enqueue(serialized);
|
|
3391
|
+
},
|
|
3392
|
+
onError: (err) => {
|
|
3393
|
+
console.error("Serialization error:", err);
|
|
3394
|
+
if (err && err.stack) console.error(err.stack);
|
|
3395
|
+
finishScriptSerialization();
|
|
3396
|
+
},
|
|
3397
|
+
scopeId: SCOPE_ID,
|
|
3398
|
+
onDone: () => {
|
|
3399
|
+
finishScriptSerialization();
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3402
|
+
},
|
|
3403
|
+
isDehydrated() {
|
|
3404
|
+
return _dehydrated;
|
|
3405
|
+
},
|
|
3406
|
+
isSerializationFinished() {
|
|
3407
|
+
return _serializationFinished;
|
|
3408
|
+
},
|
|
3409
|
+
reserveStreamFastPath() {
|
|
3410
|
+
if (!cleanupStarted && _serializationFinished && !streamFastPathReserved && renderFinishedListeners.length === 0 && !injectedHtmlBuffer && !scriptBuffer.hasPending()) {
|
|
3411
|
+
streamFastPathReserved = true;
|
|
3412
|
+
return true;
|
|
3413
|
+
}
|
|
3414
|
+
return false;
|
|
3415
|
+
},
|
|
3416
|
+
onInjectedHtml: (listener) => {
|
|
3417
|
+
if (cleanupStarted) return () => {};
|
|
3418
|
+
injectedHtmlListeners.push(listener);
|
|
3419
|
+
return () => removeListener(injectedHtmlListeners, listener);
|
|
3420
|
+
},
|
|
3421
|
+
onRenderFinished: (listener) => {
|
|
3422
|
+
if (cleanupStarted || streamFastPathReserved) return;
|
|
3423
|
+
renderFinishedListeners.push(listener);
|
|
3424
|
+
},
|
|
3425
|
+
onSerializationFinished: (listener) => {
|
|
3426
|
+
if (cleanupStarted) return () => {};
|
|
3427
|
+
if (_serializationFinished && !cleanupStarted) {
|
|
3428
|
+
try {
|
|
3429
|
+
listener();
|
|
3430
|
+
} catch (err) {
|
|
3431
|
+
console.error("Serialization listener error:", err);
|
|
3432
|
+
}
|
|
3433
|
+
return () => {};
|
|
3434
|
+
}
|
|
3435
|
+
serializationFinishedListeners.push(listener);
|
|
3436
|
+
return () => removeListener(serializationFinishedListeners, listener);
|
|
3437
|
+
},
|
|
3438
|
+
onCleanup: (listener) => {
|
|
3439
|
+
if (cleanupStarted) return;
|
|
3440
|
+
cleanupListeners.push(listener);
|
|
3441
|
+
},
|
|
3442
|
+
setRenderFinished: () => {
|
|
3443
|
+
if (cleanupStarted) return;
|
|
3444
|
+
scriptBuffer.liftBarrier();
|
|
3445
|
+
const listeners = renderFinishedListeners.slice();
|
|
3446
|
+
renderFinishedListeners.length = 0;
|
|
3447
|
+
for (const l of listeners) try {
|
|
3448
|
+
l();
|
|
3449
|
+
} catch (err) {
|
|
3450
|
+
console.error("Error in render finished listener:", err);
|
|
3451
|
+
}
|
|
3452
|
+
if (_serializationFinished) scriptBuffer.flush();
|
|
3453
|
+
},
|
|
3454
|
+
takeBufferedScripts() {
|
|
3455
|
+
const scripts = scriptBuffer.takeAll();
|
|
3456
|
+
if (!scripts) return void 0;
|
|
3457
|
+
return {
|
|
3458
|
+
tag: "script",
|
|
3459
|
+
attrs: {
|
|
3460
|
+
nonce: router.options.ssr?.nonce,
|
|
3461
|
+
className: "$tsr",
|
|
3462
|
+
id: TSR_SCRIPT_BARRIER_ID
|
|
3463
|
+
},
|
|
3464
|
+
children: scripts
|
|
3465
|
+
};
|
|
3466
|
+
},
|
|
3467
|
+
liftScriptBarrier() {
|
|
3468
|
+
scriptBuffer.liftBarrier();
|
|
3469
|
+
},
|
|
3470
|
+
takeBufferedHtml() {
|
|
3471
|
+
if (!injectedHtmlBuffer) return;
|
|
3472
|
+
const buffered = injectedHtmlBuffer;
|
|
3473
|
+
injectedHtmlBuffer = "";
|
|
3474
|
+
return buffered;
|
|
3475
|
+
},
|
|
3476
|
+
cleanup() {
|
|
3477
|
+
if (cleanupStarted) return;
|
|
3478
|
+
cleanupStarted = true;
|
|
3479
|
+
const listeners = cleanupListeners.slice();
|
|
3480
|
+
cleanupListeners.length = 0;
|
|
3481
|
+
for (const l of listeners) try {
|
|
3482
|
+
l();
|
|
3483
|
+
} catch (err) {
|
|
3484
|
+
console.error("Error in SSR cleanup listener:", err);
|
|
3485
|
+
}
|
|
3486
|
+
renderFinishedListeners.length = 0;
|
|
3487
|
+
injectedHtmlListeners.length = 0;
|
|
3488
|
+
serializationFinishedListeners.length = 0;
|
|
3489
|
+
injectedHtmlBuffer = "";
|
|
3490
|
+
scriptBuffer.cleanup();
|
|
3491
|
+
router.serverSsr = void 0;
|
|
3492
|
+
}
|
|
3493
|
+
};
|
|
3494
|
+
router.serverSsr = serverSsr;
|
|
3495
|
+
for (const listener of router.serverSsrLifecycle?.onServerSsrAttach ?? []) try {
|
|
3496
|
+
listener(serverSsr);
|
|
3497
|
+
} catch (err) {
|
|
3498
|
+
console.error("SSR attach listener error:", err);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Get the origin for the request.
|
|
3503
|
+
*
|
|
3504
|
+
* SECURITY: We intentionally do NOT trust the Origin header for determining
|
|
3505
|
+
* the router's origin. The Origin header can be spoofed by attackers, which
|
|
3506
|
+
* could lead to SSRF-like vulnerabilities where redirects are constructed
|
|
3507
|
+
* using a malicious origin (CVE-2024-34351).
|
|
3508
|
+
*
|
|
3509
|
+
* Instead, we derive the origin from request.url, which is typically set by
|
|
3510
|
+
* the server infrastructure (not client-controlled headers).
|
|
3511
|
+
*
|
|
3512
|
+
* For applications behind proxies that need to trust forwarded headers,
|
|
3513
|
+
* use the router's `origin` option to explicitly configure a trusted origin.
|
|
3514
|
+
*/
|
|
3515
|
+
function getOrigin(request) {
|
|
3516
|
+
try {
|
|
3517
|
+
return new URL(request.url).origin;
|
|
3518
|
+
} catch {}
|
|
3519
|
+
return "http://localhost";
|
|
3520
|
+
}
|
|
3521
|
+
function getNormalizedURL(url, base) {
|
|
3522
|
+
if (typeof url === "string") url = url.replace("\\", "%5C");
|
|
3523
|
+
const rawUrl = new URL(url, base);
|
|
3524
|
+
const { path: decodedPathname, handledProtocolRelativeURL } = decodePath(rawUrl.pathname);
|
|
3525
|
+
const searchParams = new URLSearchParams(rawUrl.search);
|
|
3526
|
+
const normalizedHref = decodedPathname + (searchParams.size > 0 ? "?" : "") + searchParams.toString() + rawUrl.hash;
|
|
3527
|
+
return {
|
|
3528
|
+
url: new URL(normalizedHref, rawUrl.origin),
|
|
3529
|
+
handledProtocolRelativeURL
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
//#endregion
|
|
3533
|
+
//#region node_modules/cookie-es/dist/index.mjs
|
|
3534
|
+
function splitSetCookieString(cookiesString) {
|
|
3535
|
+
if (Array.isArray(cookiesString)) return cookiesString.flatMap((c) => splitSetCookieString(c));
|
|
3536
|
+
if (typeof cookiesString !== "string") return [];
|
|
3537
|
+
const cookiesStrings = [];
|
|
3538
|
+
let pos = 0;
|
|
3539
|
+
let start;
|
|
3540
|
+
let ch;
|
|
3541
|
+
let lastComma;
|
|
3542
|
+
let nextStart;
|
|
3543
|
+
let cookiesSeparatorFound;
|
|
3544
|
+
const skipWhitespace = () => {
|
|
3545
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) pos += 1;
|
|
3546
|
+
return pos < cookiesString.length;
|
|
3547
|
+
};
|
|
3548
|
+
const notSpecialChar = () => {
|
|
3549
|
+
ch = cookiesString.charAt(pos);
|
|
3550
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
3551
|
+
};
|
|
3552
|
+
while (pos < cookiesString.length) {
|
|
3553
|
+
start = pos;
|
|
3554
|
+
cookiesSeparatorFound = false;
|
|
3555
|
+
while (skipWhitespace()) {
|
|
3556
|
+
ch = cookiesString.charAt(pos);
|
|
3557
|
+
if (ch === ",") {
|
|
3558
|
+
lastComma = pos;
|
|
3559
|
+
pos += 1;
|
|
3560
|
+
skipWhitespace();
|
|
3561
|
+
nextStart = pos;
|
|
3562
|
+
while (pos < cookiesString.length && notSpecialChar()) pos += 1;
|
|
3563
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
3564
|
+
cookiesSeparatorFound = true;
|
|
3565
|
+
pos = nextStart;
|
|
3566
|
+
cookiesStrings.push(cookiesString.slice(start, lastComma));
|
|
3567
|
+
start = pos;
|
|
3568
|
+
} else pos = lastComma + 1;
|
|
3569
|
+
} else pos += 1;
|
|
3570
|
+
}
|
|
3571
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) cookiesStrings.push(cookiesString.slice(start));
|
|
3572
|
+
}
|
|
3573
|
+
return cookiesStrings;
|
|
3574
|
+
}
|
|
3575
|
+
//#endregion
|
|
3576
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/headers.js
|
|
3577
|
+
function toHeadersInstance(init) {
|
|
3578
|
+
if (init instanceof Headers) return init;
|
|
3579
|
+
else if (Array.isArray(init)) return new Headers(init);
|
|
3580
|
+
else if (typeof init === "object") return new Headers(init);
|
|
3581
|
+
else return null;
|
|
3582
|
+
}
|
|
3583
|
+
function mergeHeaders(...headers) {
|
|
3584
|
+
return headers.reduce((acc, header) => {
|
|
3585
|
+
const headersInstance = toHeadersInstance(header);
|
|
3586
|
+
if (!headersInstance) return acc;
|
|
3587
|
+
for (const [key, value] of headersInstance.entries()) if (key === "set-cookie") splitSetCookieString(value).forEach((cookie) => acc.append("set-cookie", cookie));
|
|
3588
|
+
else acc.set(key, value);
|
|
3589
|
+
return acc;
|
|
3590
|
+
}, new Headers());
|
|
3591
|
+
}
|
|
3592
|
+
//#endregion
|
|
3593
|
+
//#region node_modules/@tanstack/router-core/dist/esm/ssr/createRequestHandler.js
|
|
3594
|
+
var requestWaiters = /* @__PURE__ */ new WeakMap();
|
|
3595
|
+
function removeRequestWaiter(waiters, index, reject) {
|
|
3596
|
+
if (waiters[index] !== reject) return;
|
|
3597
|
+
if (index !== waiters.length - 1) {
|
|
3598
|
+
waiters[index] = void 0;
|
|
3599
|
+
return;
|
|
3600
|
+
}
|
|
3601
|
+
waiters.pop();
|
|
3602
|
+
while (waiters.length && waiters[waiters.length - 1] === void 0) waiters.pop();
|
|
3603
|
+
}
|
|
3604
|
+
function waitForRequest(value, signal, onLate) {
|
|
3605
|
+
const promise = Promise.resolve(value);
|
|
3606
|
+
if (signal.aborted) {
|
|
3607
|
+
promise.then(onLate, () => {});
|
|
3608
|
+
return Promise.reject(signal.reason);
|
|
3609
|
+
}
|
|
3610
|
+
return new Promise((resolve, reject) => {
|
|
3611
|
+
let waiters = requestWaiters.get(signal);
|
|
3612
|
+
let index;
|
|
3613
|
+
if (waiters) index = waiters.push(reject) - 1;
|
|
3614
|
+
else {
|
|
3615
|
+
const newWaiters = [reject];
|
|
3616
|
+
waiters = newWaiters;
|
|
3617
|
+
index = 0;
|
|
3618
|
+
requestWaiters.set(signal, newWaiters);
|
|
3619
|
+
signal.addEventListener("abort", () => {
|
|
3620
|
+
requestWaiters.delete(signal);
|
|
3621
|
+
for (const rejectWaiter of newWaiters) rejectWaiter?.(signal.reason);
|
|
3622
|
+
newWaiters.length = 0;
|
|
3623
|
+
}, { once: true });
|
|
3624
|
+
}
|
|
3625
|
+
promise.then((result) => {
|
|
3626
|
+
removeRequestWaiter(waiters, index, reject);
|
|
3627
|
+
if (signal.aborted) onLate?.(result);
|
|
3628
|
+
else resolve(result);
|
|
3629
|
+
}, (error) => {
|
|
3630
|
+
removeRequestWaiter(waiters, index, reject);
|
|
3631
|
+
reject(error);
|
|
3632
|
+
});
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3635
|
+
//#endregion
|
|
3636
|
+
export { getOrigin as a, createSerializationAdapter as c, toCrossJSONAsync as d, toCrossJSONStream as f, getNormalizedURL as i, makeSerovalPlugin as l, mergeHeaders as n, defaultSerovalPlugins as o, attachRouterServerSsrUtils as r, createRawStreamRPCPlugin as s, waitForRequest as t, fromJSON as u };
|