@grindxp/cli 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -7
- package/dist/web/client/assets/Copy.es-Bs4NgJu-.js +1 -0
- package/dist/web/client/assets/Sword.es-2Xm7T3t2.js +1 -0
- package/dist/web/client/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- package/dist/web/client/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- package/dist/web/client/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- package/dist/web/client/assets/index-6XDcqRbL.js +42 -0
- package/dist/web/client/assets/index-BXM1N6tm.js +1 -0
- package/dist/web/client/assets/index-B_KMiE38.js +1 -0
- package/dist/web/client/assets/index-CGj2rOLm.js +1 -0
- package/dist/web/client/assets/index-CS5BuFbt.js +1 -0
- package/dist/web/client/assets/index-CYsASiu-.js +1 -0
- package/dist/web/client/assets/index-DAvwM0SX.js +1 -0
- package/dist/web/client/assets/index-DCBFp5DJ.js +1 -0
- package/dist/web/client/assets/index-DjKt1qNz.js +1 -0
- package/dist/web/client/assets/index-PIcFs1vr.js +1 -0
- package/dist/web/client/assets/instrument-serif-latin-400-italic-DKMiL14s.woff2 +0 -0
- package/dist/web/client/assets/instrument-serif-latin-400-italic-u__WvvIK.woff +0 -0
- package/dist/web/client/assets/instrument-serif-latin-400-normal-BVbkICAY.woff +0 -0
- package/dist/web/client/assets/instrument-serif-latin-400-normal-DnYpCC2O.woff2 +0 -0
- package/dist/web/client/assets/instrument-serif-latin-ext-400-italic-C9HzH3YL.woff2 +0 -0
- package/dist/web/client/assets/instrument-serif-latin-ext-400-italic-D7-lnxEk.woff +0 -0
- package/dist/web/client/assets/instrument-serif-latin-ext-400-normal-C2je3j2s.woff2 +0 -0
- package/dist/web/client/assets/instrument-serif-latin-ext-400-normal-CFCUzsTy.woff +0 -0
- package/dist/web/client/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web/client/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web/client/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web/client/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web/client/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web/client/assets/main-BI1EOhmt.js +18 -0
- package/dist/web/client/assets/styles-7TpWqjrh.css +1 -0
- package/dist/web/client/favicon.ico +0 -0
- package/dist/web/server/assets/_tanstack-start-manifest_v-B_rvI8DG.js +4 -0
- package/dist/web/server/assets/agent.functions-zpMkBrG3.js +19144 -0
- package/dist/web/server/assets/data.functions-9hSsMFx_.js +285 -0
- package/dist/web/server/assets/index-4SxmUYH6.js +14 -0
- package/dist/web/server/assets/index-BDL7hA7T.js +5924 -0
- package/dist/web/server/assets/index-BL8u2X7w.js +14 -0
- package/dist/web/server/assets/index-BRRsXrOi.js +14 -0
- package/dist/web/server/assets/index-BiD7uOOh.js +14 -0
- package/dist/web/server/assets/index-C09LXa7Z.js +4587 -0
- package/dist/web/server/assets/index-CJ_-TSqN.js +1426 -0
- package/dist/web/server/assets/index-D2fMUSdJ.js +477 -0
- package/dist/web/server/assets/index-D2yaimYL.js +14 -0
- package/dist/web/server/assets/index-D31yYLCV.js +2275 -0
- package/dist/web/server/assets/index-D3RUqTdb.js +14 -0
- package/dist/web/server/assets/index-D7z4dRpK.js +66 -0
- package/dist/web/server/assets/index-b30aLTKp.js +66 -0
- package/dist/web/server/assets/router-1koL9I3U.js +589 -0
- package/dist/web/server/assets/sessions-DOkG47Ex.js +403 -0
- package/dist/web/server/assets/start-HYkvq4Ni.js +4 -0
- package/dist/web/server/assets/token-W0NPKas8.js +86 -0
- package/dist/web/server/assets/token-util-1cB5CD6M.js +30 -0
- package/dist/web/server/assets/token-util-DA5xS0pj.js +451 -0
- package/dist/web/server/assets/vault.server-Ndu49yTf.js +19356 -0
- package/dist/web/server/server.js +4889 -0
- package/package.json +2 -4
|
@@ -0,0 +1,4889 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { Readable, PassThrough } from "node:stream";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { defineHandlerCallback, renderRouterToStream } from "@tanstack/react-router/ssr/server";
|
|
5
|
+
import { RouterProvider } from "@tanstack/react-router";
|
|
6
|
+
function StartServer(props) {
|
|
7
|
+
return /* @__PURE__ */ jsx(RouterProvider, { router: props.router });
|
|
8
|
+
}
|
|
9
|
+
const defaultStreamHandler = defineHandlerCallback(
|
|
10
|
+
({ request, router, responseHeaders }) => renderRouterToStream({
|
|
11
|
+
request,
|
|
12
|
+
router,
|
|
13
|
+
responseHeaders,
|
|
14
|
+
children: /* @__PURE__ */ jsx(StartServer, { router })
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
const stateIndexKey = "__TSR_index";
|
|
18
|
+
function createHistory(opts) {
|
|
19
|
+
let location = opts.getLocation();
|
|
20
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
21
|
+
const notify = (action) => {
|
|
22
|
+
location = opts.getLocation();
|
|
23
|
+
subscribers.forEach((subscriber) => subscriber({ location, action }));
|
|
24
|
+
};
|
|
25
|
+
const handleIndexChange = (action) => {
|
|
26
|
+
if (opts.notifyOnIndexChange ?? true) notify(action);
|
|
27
|
+
else location = opts.getLocation();
|
|
28
|
+
};
|
|
29
|
+
const tryNavigation = async ({
|
|
30
|
+
task,
|
|
31
|
+
navigateOpts,
|
|
32
|
+
...actionInfo
|
|
33
|
+
}) => {
|
|
34
|
+
const ignoreBlocker = navigateOpts?.ignoreBlocker ?? false;
|
|
35
|
+
if (ignoreBlocker) {
|
|
36
|
+
task();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const blockers = opts.getBlockers?.() ?? [];
|
|
40
|
+
const isPushOrReplace = actionInfo.type === "PUSH" || actionInfo.type === "REPLACE";
|
|
41
|
+
if (typeof document !== "undefined" && blockers.length && isPushOrReplace) {
|
|
42
|
+
for (const blocker of blockers) {
|
|
43
|
+
const nextLocation = parseHref(actionInfo.path, actionInfo.state);
|
|
44
|
+
const isBlocked = await blocker.blockerFn({
|
|
45
|
+
currentLocation: location,
|
|
46
|
+
nextLocation,
|
|
47
|
+
action: actionInfo.type
|
|
48
|
+
});
|
|
49
|
+
if (isBlocked) {
|
|
50
|
+
opts.onBlocked?.();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
task();
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
get location() {
|
|
59
|
+
return location;
|
|
60
|
+
},
|
|
61
|
+
get length() {
|
|
62
|
+
return opts.getLength();
|
|
63
|
+
},
|
|
64
|
+
subscribers,
|
|
65
|
+
subscribe: (cb) => {
|
|
66
|
+
subscribers.add(cb);
|
|
67
|
+
return () => {
|
|
68
|
+
subscribers.delete(cb);
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
push: (path, state, navigateOpts) => {
|
|
72
|
+
const currentIndex = location.state[stateIndexKey];
|
|
73
|
+
state = assignKeyAndIndex(currentIndex + 1, state);
|
|
74
|
+
tryNavigation({
|
|
75
|
+
task: () => {
|
|
76
|
+
opts.pushState(path, state);
|
|
77
|
+
notify({ type: "PUSH" });
|
|
78
|
+
},
|
|
79
|
+
navigateOpts,
|
|
80
|
+
type: "PUSH",
|
|
81
|
+
path,
|
|
82
|
+
state
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
replace: (path, state, navigateOpts) => {
|
|
86
|
+
const currentIndex = location.state[stateIndexKey];
|
|
87
|
+
state = assignKeyAndIndex(currentIndex, state);
|
|
88
|
+
tryNavigation({
|
|
89
|
+
task: () => {
|
|
90
|
+
opts.replaceState(path, state);
|
|
91
|
+
notify({ type: "REPLACE" });
|
|
92
|
+
},
|
|
93
|
+
navigateOpts,
|
|
94
|
+
type: "REPLACE",
|
|
95
|
+
path,
|
|
96
|
+
state
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
go: (index, navigateOpts) => {
|
|
100
|
+
tryNavigation({
|
|
101
|
+
task: () => {
|
|
102
|
+
opts.go(index);
|
|
103
|
+
handleIndexChange({ type: "GO", index });
|
|
104
|
+
},
|
|
105
|
+
navigateOpts,
|
|
106
|
+
type: "GO"
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
back: (navigateOpts) => {
|
|
110
|
+
tryNavigation({
|
|
111
|
+
task: () => {
|
|
112
|
+
opts.back(navigateOpts?.ignoreBlocker ?? false);
|
|
113
|
+
handleIndexChange({ type: "BACK" });
|
|
114
|
+
},
|
|
115
|
+
navigateOpts,
|
|
116
|
+
type: "BACK"
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
forward: (navigateOpts) => {
|
|
120
|
+
tryNavigation({
|
|
121
|
+
task: () => {
|
|
122
|
+
opts.forward(navigateOpts?.ignoreBlocker ?? false);
|
|
123
|
+
handleIndexChange({ type: "FORWARD" });
|
|
124
|
+
},
|
|
125
|
+
navigateOpts,
|
|
126
|
+
type: "FORWARD"
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
canGoBack: () => location.state[stateIndexKey] !== 0,
|
|
130
|
+
createHref: (str) => opts.createHref(str),
|
|
131
|
+
block: (blocker) => {
|
|
132
|
+
if (!opts.setBlockers) return () => {
|
|
133
|
+
};
|
|
134
|
+
const blockers = opts.getBlockers?.() ?? [];
|
|
135
|
+
opts.setBlockers([...blockers, blocker]);
|
|
136
|
+
return () => {
|
|
137
|
+
const blockers2 = opts.getBlockers?.() ?? [];
|
|
138
|
+
opts.setBlockers?.(blockers2.filter((b2) => b2 !== blocker));
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
flush: () => opts.flush?.(),
|
|
142
|
+
destroy: () => opts.destroy?.(),
|
|
143
|
+
notify
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function assignKeyAndIndex(index, state) {
|
|
147
|
+
if (!state) {
|
|
148
|
+
state = {};
|
|
149
|
+
}
|
|
150
|
+
const key = createRandomKey();
|
|
151
|
+
return {
|
|
152
|
+
...state,
|
|
153
|
+
key,
|
|
154
|
+
// TODO: Remove in v2 - use __TSR_key instead
|
|
155
|
+
__TSR_key: key,
|
|
156
|
+
[stateIndexKey]: index
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function createMemoryHistory(opts = {
|
|
160
|
+
initialEntries: ["/"]
|
|
161
|
+
}) {
|
|
162
|
+
const entries = opts.initialEntries;
|
|
163
|
+
let index = opts.initialIndex ? Math.min(Math.max(opts.initialIndex, 0), entries.length - 1) : entries.length - 1;
|
|
164
|
+
const states = entries.map(
|
|
165
|
+
(_entry, index2) => assignKeyAndIndex(index2, void 0)
|
|
166
|
+
);
|
|
167
|
+
const getLocation = () => parseHref(entries[index], states[index]);
|
|
168
|
+
let blockers = [];
|
|
169
|
+
const _getBlockers = () => blockers;
|
|
170
|
+
const _setBlockers = (newBlockers) => blockers = newBlockers;
|
|
171
|
+
return createHistory({
|
|
172
|
+
getLocation,
|
|
173
|
+
getLength: () => entries.length,
|
|
174
|
+
pushState: (path, state) => {
|
|
175
|
+
if (index < entries.length - 1) {
|
|
176
|
+
entries.splice(index + 1);
|
|
177
|
+
states.splice(index + 1);
|
|
178
|
+
}
|
|
179
|
+
states.push(state);
|
|
180
|
+
entries.push(path);
|
|
181
|
+
index = Math.max(entries.length - 1, 0);
|
|
182
|
+
},
|
|
183
|
+
replaceState: (path, state) => {
|
|
184
|
+
states[index] = state;
|
|
185
|
+
entries[index] = path;
|
|
186
|
+
},
|
|
187
|
+
back: () => {
|
|
188
|
+
index = Math.max(index - 1, 0);
|
|
189
|
+
},
|
|
190
|
+
forward: () => {
|
|
191
|
+
index = Math.min(index + 1, entries.length - 1);
|
|
192
|
+
},
|
|
193
|
+
go: (n2) => {
|
|
194
|
+
index = Math.min(Math.max(index + n2, 0), entries.length - 1);
|
|
195
|
+
},
|
|
196
|
+
createHref: (path) => path,
|
|
197
|
+
getBlockers: _getBlockers,
|
|
198
|
+
setBlockers: _setBlockers
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function sanitizePath(path) {
|
|
202
|
+
let sanitized = path.replace(/[\x00-\x1f\x7f]/g, "");
|
|
203
|
+
if (sanitized.startsWith("//")) {
|
|
204
|
+
sanitized = "/" + sanitized.replace(/^\/+/, "");
|
|
205
|
+
}
|
|
206
|
+
return sanitized;
|
|
207
|
+
}
|
|
208
|
+
function parseHref(href, state) {
|
|
209
|
+
const sanitizedHref = sanitizePath(href);
|
|
210
|
+
const hashIndex = sanitizedHref.indexOf("#");
|
|
211
|
+
const searchIndex = sanitizedHref.indexOf("?");
|
|
212
|
+
const addedKey = createRandomKey();
|
|
213
|
+
return {
|
|
214
|
+
href: sanitizedHref,
|
|
215
|
+
pathname: sanitizedHref.substring(
|
|
216
|
+
0,
|
|
217
|
+
hashIndex > 0 ? searchIndex > 0 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > 0 ? searchIndex : sanitizedHref.length
|
|
218
|
+
),
|
|
219
|
+
hash: hashIndex > -1 ? sanitizedHref.substring(hashIndex) : "",
|
|
220
|
+
search: searchIndex > -1 ? sanitizedHref.slice(
|
|
221
|
+
searchIndex,
|
|
222
|
+
hashIndex === -1 ? void 0 : hashIndex
|
|
223
|
+
) : "",
|
|
224
|
+
state: state || { [stateIndexKey]: 0, key: addedKey, __TSR_key: addedKey }
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function createRandomKey() {
|
|
228
|
+
return (Math.random() + 1).toString(36).substring(7);
|
|
229
|
+
}
|
|
230
|
+
function splitSetCookieString(cookiesString) {
|
|
231
|
+
if (Array.isArray(cookiesString)) {
|
|
232
|
+
return cookiesString.flatMap((c2) => splitSetCookieString(c2));
|
|
233
|
+
}
|
|
234
|
+
if (typeof cookiesString !== "string") {
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
const cookiesStrings = [];
|
|
238
|
+
let pos = 0;
|
|
239
|
+
let start;
|
|
240
|
+
let ch;
|
|
241
|
+
let lastComma;
|
|
242
|
+
let nextStart;
|
|
243
|
+
let cookiesSeparatorFound;
|
|
244
|
+
const skipWhitespace = () => {
|
|
245
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
246
|
+
pos += 1;
|
|
247
|
+
}
|
|
248
|
+
return pos < cookiesString.length;
|
|
249
|
+
};
|
|
250
|
+
const notSpecialChar = () => {
|
|
251
|
+
ch = cookiesString.charAt(pos);
|
|
252
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
253
|
+
};
|
|
254
|
+
while (pos < cookiesString.length) {
|
|
255
|
+
start = pos;
|
|
256
|
+
cookiesSeparatorFound = false;
|
|
257
|
+
while (skipWhitespace()) {
|
|
258
|
+
ch = cookiesString.charAt(pos);
|
|
259
|
+
if (ch === ",") {
|
|
260
|
+
lastComma = pos;
|
|
261
|
+
pos += 1;
|
|
262
|
+
skipWhitespace();
|
|
263
|
+
nextStart = pos;
|
|
264
|
+
while (pos < cookiesString.length && notSpecialChar()) {
|
|
265
|
+
pos += 1;
|
|
266
|
+
}
|
|
267
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
268
|
+
cookiesSeparatorFound = true;
|
|
269
|
+
pos = nextStart;
|
|
270
|
+
cookiesStrings.push(cookiesString.slice(start, lastComma));
|
|
271
|
+
start = pos;
|
|
272
|
+
} else {
|
|
273
|
+
pos = lastComma + 1;
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
pos += 1;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
280
|
+
cookiesStrings.push(cookiesString.slice(start));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return cookiesStrings;
|
|
284
|
+
}
|
|
285
|
+
function toHeadersInstance(init) {
|
|
286
|
+
if (init instanceof Headers) {
|
|
287
|
+
return init;
|
|
288
|
+
} else if (Array.isArray(init)) {
|
|
289
|
+
return new Headers(init);
|
|
290
|
+
} else if (typeof init === "object") {
|
|
291
|
+
return new Headers(init);
|
|
292
|
+
} else {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function mergeHeaders(...headers) {
|
|
297
|
+
return headers.reduce((acc, header) => {
|
|
298
|
+
const headersInstance = toHeadersInstance(header);
|
|
299
|
+
if (!headersInstance) return acc;
|
|
300
|
+
for (const [key, value] of headersInstance.entries()) {
|
|
301
|
+
if (key === "set-cookie") {
|
|
302
|
+
const splitCookies = splitSetCookieString(value);
|
|
303
|
+
splitCookies.forEach((cookie) => acc.append("set-cookie", cookie));
|
|
304
|
+
} else {
|
|
305
|
+
acc.set(key, value);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return acc;
|
|
309
|
+
}, new Headers());
|
|
310
|
+
}
|
|
311
|
+
var prefix = "Invariant failed";
|
|
312
|
+
function invariant(condition, message) {
|
|
313
|
+
if (condition) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
{
|
|
317
|
+
throw new Error(prefix);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function isNotFound(obj) {
|
|
321
|
+
return !!obj?.isNotFound;
|
|
322
|
+
}
|
|
323
|
+
function sanitizePathSegment(segment) {
|
|
324
|
+
return segment.replace(/[\x00-\x1f\x7f]/g, "");
|
|
325
|
+
}
|
|
326
|
+
function decodeSegment(segment) {
|
|
327
|
+
let decoded;
|
|
328
|
+
try {
|
|
329
|
+
decoded = decodeURI(segment);
|
|
330
|
+
} catch {
|
|
331
|
+
decoded = segment.replaceAll(/%[0-9A-F]{2}/gi, (match) => {
|
|
332
|
+
try {
|
|
333
|
+
return decodeURI(match);
|
|
334
|
+
} catch {
|
|
335
|
+
return match;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
return sanitizePathSegment(decoded);
|
|
340
|
+
}
|
|
341
|
+
function decodePath(path) {
|
|
342
|
+
if (!path) return { path, handledProtocolRelativeURL: false };
|
|
343
|
+
if (!/[%\\\x00-\x1f\x7f]/.test(path) && !path.startsWith("//")) {
|
|
344
|
+
return { path, handledProtocolRelativeURL: false };
|
|
345
|
+
}
|
|
346
|
+
const re2 = /%25|%5C/gi;
|
|
347
|
+
let cursor = 0;
|
|
348
|
+
let result = "";
|
|
349
|
+
let match;
|
|
350
|
+
while (null !== (match = re2.exec(path))) {
|
|
351
|
+
result += decodeSegment(path.slice(cursor, match.index)) + match[0];
|
|
352
|
+
cursor = re2.lastIndex;
|
|
353
|
+
}
|
|
354
|
+
result = result + decodeSegment(cursor ? path.slice(cursor) : path);
|
|
355
|
+
let handledProtocolRelativeURL = false;
|
|
356
|
+
if (result.startsWith("//")) {
|
|
357
|
+
handledProtocolRelativeURL = true;
|
|
358
|
+
result = "/" + result.replace(/^\/+/, "");
|
|
359
|
+
}
|
|
360
|
+
return { path: result, handledProtocolRelativeURL };
|
|
361
|
+
}
|
|
362
|
+
function createLRUCache(max) {
|
|
363
|
+
const cache = /* @__PURE__ */ new Map();
|
|
364
|
+
let oldest;
|
|
365
|
+
let newest;
|
|
366
|
+
const touch = (entry) => {
|
|
367
|
+
if (!entry.next) return;
|
|
368
|
+
if (!entry.prev) {
|
|
369
|
+
entry.next.prev = void 0;
|
|
370
|
+
oldest = entry.next;
|
|
371
|
+
entry.next = void 0;
|
|
372
|
+
if (newest) {
|
|
373
|
+
entry.prev = newest;
|
|
374
|
+
newest.next = entry;
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
entry.prev.next = entry.next;
|
|
378
|
+
entry.next.prev = entry.prev;
|
|
379
|
+
entry.next = void 0;
|
|
380
|
+
if (newest) {
|
|
381
|
+
newest.next = entry;
|
|
382
|
+
entry.prev = newest;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
newest = entry;
|
|
386
|
+
};
|
|
387
|
+
return {
|
|
388
|
+
get(key) {
|
|
389
|
+
const entry = cache.get(key);
|
|
390
|
+
if (!entry) return void 0;
|
|
391
|
+
touch(entry);
|
|
392
|
+
return entry.value;
|
|
393
|
+
},
|
|
394
|
+
set(key, value) {
|
|
395
|
+
if (cache.size >= max && oldest) {
|
|
396
|
+
const toDelete = oldest;
|
|
397
|
+
cache.delete(toDelete.key);
|
|
398
|
+
if (toDelete.next) {
|
|
399
|
+
oldest = toDelete.next;
|
|
400
|
+
toDelete.next.prev = void 0;
|
|
401
|
+
}
|
|
402
|
+
if (toDelete === newest) {
|
|
403
|
+
newest = void 0;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const existing = cache.get(key);
|
|
407
|
+
if (existing) {
|
|
408
|
+
existing.value = value;
|
|
409
|
+
touch(existing);
|
|
410
|
+
} else {
|
|
411
|
+
const entry = { key, value, prev: newest };
|
|
412
|
+
if (newest) newest.next = entry;
|
|
413
|
+
newest = entry;
|
|
414
|
+
if (!oldest) oldest = entry;
|
|
415
|
+
cache.set(key, entry);
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
clear() {
|
|
419
|
+
cache.clear();
|
|
420
|
+
oldest = void 0;
|
|
421
|
+
newest = void 0;
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
const rootRouteId = "__root__";
|
|
426
|
+
function redirect(opts) {
|
|
427
|
+
opts.statusCode = opts.statusCode || opts.code || 307;
|
|
428
|
+
if (!opts._builtLocation && !opts.reloadDocument && typeof opts.href === "string") {
|
|
429
|
+
try {
|
|
430
|
+
new URL(opts.href);
|
|
431
|
+
opts.reloadDocument = true;
|
|
432
|
+
} catch {
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
const headers = new Headers(opts.headers);
|
|
436
|
+
if (opts.href && headers.get("Location") === null) {
|
|
437
|
+
headers.set("Location", opts.href);
|
|
438
|
+
}
|
|
439
|
+
const response = new Response(null, {
|
|
440
|
+
status: opts.statusCode,
|
|
441
|
+
headers
|
|
442
|
+
});
|
|
443
|
+
response.options = opts;
|
|
444
|
+
if (opts.throw) {
|
|
445
|
+
throw response;
|
|
446
|
+
}
|
|
447
|
+
return response;
|
|
448
|
+
}
|
|
449
|
+
function isRedirect(obj) {
|
|
450
|
+
return obj instanceof Response && !!obj.options;
|
|
451
|
+
}
|
|
452
|
+
function isResolvedRedirect(obj) {
|
|
453
|
+
return isRedirect(obj) && !!obj.options.href;
|
|
454
|
+
}
|
|
455
|
+
function parseRedirect(obj) {
|
|
456
|
+
if (obj !== null && typeof obj === "object" && obj.isSerializedRedirect) {
|
|
457
|
+
return redirect(obj);
|
|
458
|
+
}
|
|
459
|
+
return void 0;
|
|
460
|
+
}
|
|
461
|
+
function executeRewriteInput(rewrite, url) {
|
|
462
|
+
const res = rewrite?.input?.({ url });
|
|
463
|
+
if (res) {
|
|
464
|
+
if (typeof res === "string") {
|
|
465
|
+
return new URL(res);
|
|
466
|
+
} else if (res instanceof URL) {
|
|
467
|
+
return res;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return url;
|
|
471
|
+
}
|
|
472
|
+
var L = ((i) => (i[i.AggregateError = 1] = "AggregateError", i[i.ArrowFunction = 2] = "ArrowFunction", i[i.ErrorPrototypeStack = 4] = "ErrorPrototypeStack", i[i.ObjectAssign = 8] = "ObjectAssign", i[i.BigIntTypedArray = 16] = "BigIntTypedArray", i[i.RegExp = 32] = "RegExp", i))(L || {});
|
|
473
|
+
var v = Symbol.asyncIterator, mr = Symbol.hasInstance, R = Symbol.isConcatSpreadable, C = Symbol.iterator, pr = Symbol.match, dr = Symbol.matchAll, gr = Symbol.replace, yr = Symbol.search, Nr = Symbol.species, br = Symbol.split, vr = Symbol.toPrimitive, P$1 = Symbol.toStringTag, Cr = Symbol.unscopables;
|
|
474
|
+
var rt = { 0: "Symbol.asyncIterator", 1: "Symbol.hasInstance", 2: "Symbol.isConcatSpreadable", 3: "Symbol.iterator", 4: "Symbol.match", 5: "Symbol.matchAll", 6: "Symbol.replace", 7: "Symbol.search", 8: "Symbol.species", 9: "Symbol.split", 10: "Symbol.toPrimitive", 11: "Symbol.toStringTag", 12: "Symbol.unscopables" }, ve = { [v]: 0, [mr]: 1, [R]: 2, [C]: 3, [pr]: 4, [dr]: 5, [gr]: 6, [yr]: 7, [Nr]: 8, [br]: 9, [vr]: 10, [P$1]: 11, [Cr]: 12 }, tt = { 0: v, 1: mr, 2: R, 3: C, 4: pr, 5: dr, 6: gr, 7: yr, 8: Nr, 9: br, 10: vr, 11: P$1, 12: Cr }, nt = { 2: "!0", 3: "!1", 1: "void 0", 0: "null", 4: "-0", 5: "1/0", 6: "-1/0", 7: "0/0" }, o = void 0, ot = { 2: true, 3: false, 1: o, 0: null, 4: -0, 5: Number.POSITIVE_INFINITY, 6: Number.NEGATIVE_INFINITY, 7: Number.NaN };
|
|
475
|
+
var Ce = { 0: "Error", 1: "EvalError", 2: "RangeError", 3: "ReferenceError", 4: "SyntaxError", 5: "TypeError", 6: "URIError" }, at = { 0: Error, 1: EvalError, 2: RangeError, 3: ReferenceError, 4: SyntaxError, 5: TypeError, 6: URIError };
|
|
476
|
+
function c(e, r, t, n2, a, s, i, u, l, g, S, d) {
|
|
477
|
+
return { t: e, i: r, s: t, c: n2, m: a, p: s, e: i, a: u, f: l, b: g, o: S, l: d };
|
|
478
|
+
}
|
|
479
|
+
function F(e) {
|
|
480
|
+
return c(2, o, e, o, o, o, o, o, o, o, o, o);
|
|
481
|
+
}
|
|
482
|
+
var J = F(2), Z = F(3), Ae = F(1), Ee = F(0), st = F(4), it = F(5), ut = F(6), lt = F(7);
|
|
483
|
+
function fn(e) {
|
|
484
|
+
switch (e) {
|
|
485
|
+
case '"':
|
|
486
|
+
return '\\"';
|
|
487
|
+
case "\\":
|
|
488
|
+
return "\\\\";
|
|
489
|
+
case `
|
|
490
|
+
`:
|
|
491
|
+
return "\\n";
|
|
492
|
+
case "\r":
|
|
493
|
+
return "\\r";
|
|
494
|
+
case "\b":
|
|
495
|
+
return "\\b";
|
|
496
|
+
case " ":
|
|
497
|
+
return "\\t";
|
|
498
|
+
case "\f":
|
|
499
|
+
return "\\f";
|
|
500
|
+
case "<":
|
|
501
|
+
return "\\x3C";
|
|
502
|
+
case "\u2028":
|
|
503
|
+
return "\\u2028";
|
|
504
|
+
case "\u2029":
|
|
505
|
+
return "\\u2029";
|
|
506
|
+
default:
|
|
507
|
+
return o;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function y(e) {
|
|
511
|
+
let r = "", t = 0, n2;
|
|
512
|
+
for (let a = 0, s = e.length; a < s; a++) n2 = fn(e[a]), n2 && (r += e.slice(t, a) + n2, t = a + 1);
|
|
513
|
+
return t === 0 ? r = e : r += e.slice(t), r;
|
|
514
|
+
}
|
|
515
|
+
function Sn(e) {
|
|
516
|
+
switch (e) {
|
|
517
|
+
case "\\\\":
|
|
518
|
+
return "\\";
|
|
519
|
+
case '\\"':
|
|
520
|
+
return '"';
|
|
521
|
+
case "\\n":
|
|
522
|
+
return `
|
|
523
|
+
`;
|
|
524
|
+
case "\\r":
|
|
525
|
+
return "\r";
|
|
526
|
+
case "\\b":
|
|
527
|
+
return "\b";
|
|
528
|
+
case "\\t":
|
|
529
|
+
return " ";
|
|
530
|
+
case "\\f":
|
|
531
|
+
return "\f";
|
|
532
|
+
case "\\x3C":
|
|
533
|
+
return "<";
|
|
534
|
+
case "\\u2028":
|
|
535
|
+
return "\u2028";
|
|
536
|
+
case "\\u2029":
|
|
537
|
+
return "\u2029";
|
|
538
|
+
default:
|
|
539
|
+
return e;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function B(e) {
|
|
543
|
+
return e.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g, Sn);
|
|
544
|
+
}
|
|
545
|
+
var U = "__SEROVAL_REFS__", ce = "$R", Ie = `self.${ce}`;
|
|
546
|
+
function mn(e) {
|
|
547
|
+
return e == null ? `${Ie}=${Ie}||[]` : `(${Ie}=${Ie}||{})["${y(e)}"]=[]`;
|
|
548
|
+
}
|
|
549
|
+
var Ar = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map();
|
|
550
|
+
function Er(e) {
|
|
551
|
+
return Ar.has(e);
|
|
552
|
+
}
|
|
553
|
+
function dn(e) {
|
|
554
|
+
return j.has(e);
|
|
555
|
+
}
|
|
556
|
+
function ct(e) {
|
|
557
|
+
if (Er(e)) return Ar.get(e);
|
|
558
|
+
throw new Re(e);
|
|
559
|
+
}
|
|
560
|
+
function ft(e) {
|
|
561
|
+
if (dn(e)) return j.get(e);
|
|
562
|
+
throw new Pe(e);
|
|
563
|
+
}
|
|
564
|
+
typeof globalThis != "undefined" ? Object.defineProperty(globalThis, U, { value: j, configurable: true, writable: false, enumerable: false }) : typeof window != "undefined" ? Object.defineProperty(window, U, { value: j, configurable: true, writable: false, enumerable: false }) : typeof self != "undefined" ? Object.defineProperty(self, U, { value: j, configurable: true, writable: false, enumerable: false }) : typeof global != "undefined" && Object.defineProperty(global, U, { value: j, configurable: true, writable: false, enumerable: false });
|
|
565
|
+
function xe(e) {
|
|
566
|
+
return e instanceof EvalError ? 1 : e instanceof RangeError ? 2 : e instanceof ReferenceError ? 3 : e instanceof SyntaxError ? 4 : e instanceof TypeError ? 5 : e instanceof URIError ? 6 : 0;
|
|
567
|
+
}
|
|
568
|
+
function gn(e) {
|
|
569
|
+
let r = Ce[xe(e)];
|
|
570
|
+
return e.name !== r ? { name: e.name } : e.constructor.name !== r ? { name: e.constructor.name } : {};
|
|
571
|
+
}
|
|
572
|
+
function $(e, r) {
|
|
573
|
+
let t = gn(e), n2 = Object.getOwnPropertyNames(e);
|
|
574
|
+
for (let a = 0, s = n2.length, i; a < s; a++) i = n2[a], i !== "name" && i !== "message" && (i === "stack" ? r & 4 && (t = t || {}, t[i] = e[i]) : (t = t || {}, t[i] = e[i]));
|
|
575
|
+
return t;
|
|
576
|
+
}
|
|
577
|
+
function Oe(e) {
|
|
578
|
+
return Object.isFrozen(e) ? 3 : Object.isSealed(e) ? 2 : Object.isExtensible(e) ? 0 : 1;
|
|
579
|
+
}
|
|
580
|
+
function Te(e) {
|
|
581
|
+
switch (e) {
|
|
582
|
+
case Number.POSITIVE_INFINITY:
|
|
583
|
+
return it;
|
|
584
|
+
case Number.NEGATIVE_INFINITY:
|
|
585
|
+
return ut;
|
|
586
|
+
}
|
|
587
|
+
return e !== e ? lt : Object.is(e, -0) ? st : c(0, o, e, o, o, o, o, o, o, o, o, o);
|
|
588
|
+
}
|
|
589
|
+
function X(e) {
|
|
590
|
+
return c(1, o, y(e), o, o, o, o, o, o, o, o, o);
|
|
591
|
+
}
|
|
592
|
+
function we(e) {
|
|
593
|
+
return c(3, o, "" + e, o, o, o, o, o, o, o, o, o);
|
|
594
|
+
}
|
|
595
|
+
function mt(e) {
|
|
596
|
+
return c(4, e, o, o, o, o, o, o, o, o, o, o);
|
|
597
|
+
}
|
|
598
|
+
function he(e, r) {
|
|
599
|
+
let t = r.valueOf();
|
|
600
|
+
return c(5, e, t !== t ? "" : r.toISOString(), o, o, o, o, o, o, o, o, o);
|
|
601
|
+
}
|
|
602
|
+
function ze(e, r) {
|
|
603
|
+
return c(6, e, o, y(r.source), r.flags, o, o, o, o, o, o, o);
|
|
604
|
+
}
|
|
605
|
+
function pt(e, r) {
|
|
606
|
+
return c(17, e, ve[r], o, o, o, o, o, o, o, o, o);
|
|
607
|
+
}
|
|
608
|
+
function dt(e, r) {
|
|
609
|
+
return c(18, e, y(ct(r)), o, o, o, o, o, o, o, o, o);
|
|
610
|
+
}
|
|
611
|
+
function fe(e, r, t) {
|
|
612
|
+
return c(25, e, t, y(r), o, o, o, o, o, o, o, o);
|
|
613
|
+
}
|
|
614
|
+
function _e(e, r, t) {
|
|
615
|
+
return c(9, e, o, o, o, o, o, t, o, o, Oe(r), o);
|
|
616
|
+
}
|
|
617
|
+
function ke(e, r) {
|
|
618
|
+
return c(21, e, o, o, o, o, o, o, r, o, o, o);
|
|
619
|
+
}
|
|
620
|
+
function De(e, r, t) {
|
|
621
|
+
return c(15, e, o, r.constructor.name, o, o, o, o, t, r.byteOffset, o, r.length);
|
|
622
|
+
}
|
|
623
|
+
function Fe(e, r, t) {
|
|
624
|
+
return c(16, e, o, r.constructor.name, o, o, o, o, t, r.byteOffset, o, r.byteLength);
|
|
625
|
+
}
|
|
626
|
+
function Be(e, r, t) {
|
|
627
|
+
return c(20, e, o, o, o, o, o, o, t, r.byteOffset, o, r.byteLength);
|
|
628
|
+
}
|
|
629
|
+
function Ve(e, r, t) {
|
|
630
|
+
return c(13, e, xe(r), o, y(r.message), t, o, o, o, o, o, o);
|
|
631
|
+
}
|
|
632
|
+
function Me(e, r, t) {
|
|
633
|
+
return c(14, e, xe(r), o, y(r.message), t, o, o, o, o, o, o);
|
|
634
|
+
}
|
|
635
|
+
function Le(e, r) {
|
|
636
|
+
return c(7, e, o, o, o, o, o, r, o, o, o, o);
|
|
637
|
+
}
|
|
638
|
+
function Ue(e, r) {
|
|
639
|
+
return c(28, o, o, o, o, o, o, [e, r], o, o, o, o);
|
|
640
|
+
}
|
|
641
|
+
function je(e, r) {
|
|
642
|
+
return c(30, o, o, o, o, o, o, [e, r], o, o, o, o);
|
|
643
|
+
}
|
|
644
|
+
function Ye(e, r, t) {
|
|
645
|
+
return c(31, e, o, o, o, o, o, t, r, o, o, o);
|
|
646
|
+
}
|
|
647
|
+
function qe(e, r) {
|
|
648
|
+
return c(32, e, o, o, o, o, o, o, r, o, o, o);
|
|
649
|
+
}
|
|
650
|
+
function We(e, r) {
|
|
651
|
+
return c(33, e, o, o, o, o, o, o, r, o, o, o);
|
|
652
|
+
}
|
|
653
|
+
function Ge(e, r) {
|
|
654
|
+
return c(34, e, o, o, o, o, o, o, r, o, o, o);
|
|
655
|
+
}
|
|
656
|
+
function Ke(e, r, t, n2) {
|
|
657
|
+
return c(35, e, t, o, o, o, o, r, o, o, o, n2);
|
|
658
|
+
}
|
|
659
|
+
var yn = { parsing: 1, serialization: 2, deserialization: 3 };
|
|
660
|
+
function Nn(e) {
|
|
661
|
+
return `Seroval Error (step: ${yn[e]})`;
|
|
662
|
+
}
|
|
663
|
+
var bn = (e, r) => Nn(e), Se = class extends Error {
|
|
664
|
+
constructor(t, n2) {
|
|
665
|
+
super(bn(t));
|
|
666
|
+
this.cause = n2;
|
|
667
|
+
}
|
|
668
|
+
}, z = class extends Se {
|
|
669
|
+
constructor(r) {
|
|
670
|
+
super("parsing", r);
|
|
671
|
+
}
|
|
672
|
+
}, He = class extends Se {
|
|
673
|
+
constructor(r) {
|
|
674
|
+
super("deserialization", r);
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
function _(e) {
|
|
678
|
+
return `Seroval Error (specific: ${e})`;
|
|
679
|
+
}
|
|
680
|
+
var x$1 = class x extends Error {
|
|
681
|
+
constructor(t) {
|
|
682
|
+
super(_(1));
|
|
683
|
+
this.value = t;
|
|
684
|
+
}
|
|
685
|
+
}, w$1 = class w extends Error {
|
|
686
|
+
constructor(r) {
|
|
687
|
+
super(_(2));
|
|
688
|
+
}
|
|
689
|
+
}, Q = class extends Error {
|
|
690
|
+
constructor(r) {
|
|
691
|
+
super(_(3));
|
|
692
|
+
}
|
|
693
|
+
}, V = class extends Error {
|
|
694
|
+
constructor(r) {
|
|
695
|
+
super(_(4));
|
|
696
|
+
}
|
|
697
|
+
}, Re = class extends Error {
|
|
698
|
+
constructor(t) {
|
|
699
|
+
super(_(5));
|
|
700
|
+
this.value = t;
|
|
701
|
+
}
|
|
702
|
+
}, Pe = class extends Error {
|
|
703
|
+
constructor(r) {
|
|
704
|
+
super(_(6));
|
|
705
|
+
}
|
|
706
|
+
}, Je = class extends Error {
|
|
707
|
+
constructor(r) {
|
|
708
|
+
super(_(7));
|
|
709
|
+
}
|
|
710
|
+
}, h = class extends Error {
|
|
711
|
+
constructor(r) {
|
|
712
|
+
super(_(8));
|
|
713
|
+
}
|
|
714
|
+
}, ee$1 = class ee extends Error {
|
|
715
|
+
constructor(r) {
|
|
716
|
+
super(_(9));
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
var Y = class {
|
|
720
|
+
constructor(r, t) {
|
|
721
|
+
this.value = r;
|
|
722
|
+
this.replacement = t;
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
var re = () => {
|
|
726
|
+
let e = { p: 0, s: 0, f: 0 };
|
|
727
|
+
return e.p = new Promise((r, t) => {
|
|
728
|
+
e.s = r, e.f = t;
|
|
729
|
+
}), e;
|
|
730
|
+
}, vn = (e, r) => {
|
|
731
|
+
e.s(r), e.p.s = 1, e.p.v = r;
|
|
732
|
+
}, Cn = (e, r) => {
|
|
733
|
+
e.f(r), e.p.s = 2, e.p.v = r;
|
|
734
|
+
}, yt = re.toString(), Nt = vn.toString(), bt = Cn.toString(), Rr = () => {
|
|
735
|
+
let e = [], r = [], t = true, n2 = false, a = 0, s = (l, g, S) => {
|
|
736
|
+
for (S = 0; S < a; S++) r[S] && r[S][g](l);
|
|
737
|
+
}, i = (l, g, S, d) => {
|
|
738
|
+
for (g = 0, S = e.length; g < S; g++) d = e[g], !t && g === S - 1 ? l[n2 ? "return" : "throw"](d) : l.next(d);
|
|
739
|
+
}, u = (l, g) => (t && (g = a++, r[g] = l), i(l), () => {
|
|
740
|
+
t && (r[g] = r[a], r[a--] = void 0);
|
|
741
|
+
});
|
|
742
|
+
return { __SEROVAL_STREAM__: true, on: (l) => u(l), next: (l) => {
|
|
743
|
+
t && (e.push(l), s(l, "next"));
|
|
744
|
+
}, throw: (l) => {
|
|
745
|
+
t && (e.push(l), s(l, "throw"), t = false, n2 = false, r.length = 0);
|
|
746
|
+
}, return: (l) => {
|
|
747
|
+
t && (e.push(l), s(l, "return"), t = false, n2 = true, r.length = 0);
|
|
748
|
+
} };
|
|
749
|
+
}, vt = Rr.toString(), Pr = (e) => (r) => () => {
|
|
750
|
+
let t = 0, n2 = { [e]: () => n2, next: () => {
|
|
751
|
+
if (t > r.d) return { done: true, value: void 0 };
|
|
752
|
+
let a = t++, s = r.v[a];
|
|
753
|
+
if (a === r.t) throw s;
|
|
754
|
+
return { done: a === r.d, value: s };
|
|
755
|
+
} };
|
|
756
|
+
return n2;
|
|
757
|
+
}, Ct = Pr.toString(), xr = (e, r) => (t) => () => {
|
|
758
|
+
let n2 = 0, a = -1, s = false, i = [], u = [], l = (S = 0, d = u.length) => {
|
|
759
|
+
for (; S < d; S++) u[S].s({ done: true, value: void 0 });
|
|
760
|
+
};
|
|
761
|
+
t.on({ next: (S) => {
|
|
762
|
+
let d = u.shift();
|
|
763
|
+
d && d.s({ done: false, value: S }), i.push(S);
|
|
764
|
+
}, throw: (S) => {
|
|
765
|
+
let d = u.shift();
|
|
766
|
+
d && d.f(S), l(), a = i.length, s = true, i.push(S);
|
|
767
|
+
}, return: (S) => {
|
|
768
|
+
let d = u.shift();
|
|
769
|
+
d && d.s({ done: true, value: S }), l(), a = i.length, i.push(S);
|
|
770
|
+
} });
|
|
771
|
+
let g = { [e]: () => g, next: () => {
|
|
772
|
+
if (a === -1) {
|
|
773
|
+
let K = n2++;
|
|
774
|
+
if (K >= i.length) {
|
|
775
|
+
let et = r();
|
|
776
|
+
return u.push(et), et.p;
|
|
777
|
+
}
|
|
778
|
+
return { done: false, value: i[K] };
|
|
779
|
+
}
|
|
780
|
+
if (n2 > a) return { done: true, value: void 0 };
|
|
781
|
+
let S = n2++, d = i[S];
|
|
782
|
+
if (S !== a) return { done: false, value: d };
|
|
783
|
+
if (s) throw d;
|
|
784
|
+
return { done: true, value: d };
|
|
785
|
+
} };
|
|
786
|
+
return g;
|
|
787
|
+
}, At = xr.toString(), Or = (e) => {
|
|
788
|
+
let r = atob(e), t = r.length, n2 = new Uint8Array(t);
|
|
789
|
+
for (let a = 0; a < t; a++) n2[a] = r.charCodeAt(a);
|
|
790
|
+
return n2.buffer;
|
|
791
|
+
}, Et = Or.toString();
|
|
792
|
+
function Ze(e) {
|
|
793
|
+
return "__SEROVAL_SEQUENCE__" in e;
|
|
794
|
+
}
|
|
795
|
+
function Tr(e, r, t) {
|
|
796
|
+
return { __SEROVAL_SEQUENCE__: true, v: e, t: r, d: t };
|
|
797
|
+
}
|
|
798
|
+
function $e(e) {
|
|
799
|
+
let r = [], t = -1, n2 = -1, a = e[C]();
|
|
800
|
+
for (; ; ) try {
|
|
801
|
+
let s = a.next();
|
|
802
|
+
if (r.push(s.value), s.done) {
|
|
803
|
+
n2 = r.length - 1;
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
} catch (s) {
|
|
807
|
+
t = r.length, r.push(s);
|
|
808
|
+
}
|
|
809
|
+
return Tr(r, t, n2);
|
|
810
|
+
}
|
|
811
|
+
var An = Pr(C);
|
|
812
|
+
function It(e) {
|
|
813
|
+
return An(e);
|
|
814
|
+
}
|
|
815
|
+
var Rt = {}, Pt = {};
|
|
816
|
+
var xt = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {} }, Ot = { 0: "[]", 1: yt, 2: Nt, 3: bt, 4: vt, 5: Et };
|
|
817
|
+
function M(e) {
|
|
818
|
+
return "__SEROVAL_STREAM__" in e;
|
|
819
|
+
}
|
|
820
|
+
function te() {
|
|
821
|
+
return Rr();
|
|
822
|
+
}
|
|
823
|
+
function Xe(e) {
|
|
824
|
+
let r = te(), t = e[v]();
|
|
825
|
+
async function n2() {
|
|
826
|
+
try {
|
|
827
|
+
let a = await t.next();
|
|
828
|
+
a.done ? r.return(a.value) : (r.next(a.value), await n2());
|
|
829
|
+
} catch (a) {
|
|
830
|
+
r.throw(a);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return n2().catch(() => {
|
|
834
|
+
}), r;
|
|
835
|
+
}
|
|
836
|
+
var En = xr(v, re);
|
|
837
|
+
function Tt(e) {
|
|
838
|
+
return En(e);
|
|
839
|
+
}
|
|
840
|
+
async function wr(e) {
|
|
841
|
+
try {
|
|
842
|
+
return [1, await e];
|
|
843
|
+
} catch (r) {
|
|
844
|
+
return [0, r];
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
function pe(e, r) {
|
|
848
|
+
return { plugins: r.plugins, mode: e, marked: /* @__PURE__ */ new Set(), features: 63 ^ (r.disabledFeatures || 0), refs: r.refs || /* @__PURE__ */ new Map(), depthLimit: r.depthLimit || 1e3 };
|
|
849
|
+
}
|
|
850
|
+
function de(e, r) {
|
|
851
|
+
e.marked.add(r);
|
|
852
|
+
}
|
|
853
|
+
function hr(e, r) {
|
|
854
|
+
let t = e.refs.size;
|
|
855
|
+
return e.refs.set(r, t), t;
|
|
856
|
+
}
|
|
857
|
+
function Qe(e, r) {
|
|
858
|
+
let t = e.refs.get(r);
|
|
859
|
+
return t != null ? (de(e, t), { type: 1, value: mt(t) }) : { type: 0, value: hr(e, r) };
|
|
860
|
+
}
|
|
861
|
+
function q(e, r) {
|
|
862
|
+
let t = Qe(e, r);
|
|
863
|
+
return t.type === 1 ? t : Er(r) ? { type: 2, value: dt(t.value, r) } : t;
|
|
864
|
+
}
|
|
865
|
+
function I(e, r) {
|
|
866
|
+
let t = q(e, r);
|
|
867
|
+
if (t.type !== 0) return t.value;
|
|
868
|
+
if (r in ve) return pt(t.value, r);
|
|
869
|
+
throw new x$1(r);
|
|
870
|
+
}
|
|
871
|
+
function k(e, r) {
|
|
872
|
+
let t = Qe(e, xt[r]);
|
|
873
|
+
return t.type === 1 ? t.value : c(26, t.value, r, o, o, o, o, o, o, o, o, o);
|
|
874
|
+
}
|
|
875
|
+
function er(e) {
|
|
876
|
+
let r = Qe(e, Rt);
|
|
877
|
+
return r.type === 1 ? r.value : c(27, r.value, o, o, o, o, o, o, I(e, C), o, o, o);
|
|
878
|
+
}
|
|
879
|
+
function rr(e) {
|
|
880
|
+
let r = Qe(e, Pt);
|
|
881
|
+
return r.type === 1 ? r.value : c(29, r.value, o, o, o, o, o, [k(e, 1), I(e, v)], o, o, o, o);
|
|
882
|
+
}
|
|
883
|
+
function tr(e, r, t, n2) {
|
|
884
|
+
return c(t ? 11 : 10, e, o, o, o, n2, o, o, o, o, Oe(r), o);
|
|
885
|
+
}
|
|
886
|
+
function nr(e, r, t, n2) {
|
|
887
|
+
return c(8, r, o, o, o, o, { k: t, v: n2 }, o, k(e, 0), o, o, o);
|
|
888
|
+
}
|
|
889
|
+
function ht(e, r, t) {
|
|
890
|
+
return c(22, r, t, o, o, o, o, o, k(e, 1), o, o, o);
|
|
891
|
+
}
|
|
892
|
+
function or(e, r, t) {
|
|
893
|
+
let n2 = new Uint8Array(t), a = "";
|
|
894
|
+
for (let s = 0, i = n2.length; s < i; s++) a += String.fromCharCode(n2[s]);
|
|
895
|
+
return c(19, r, y(btoa(a)), o, o, o, o, o, k(e, 5), o, o, o);
|
|
896
|
+
}
|
|
897
|
+
function ne(e, r) {
|
|
898
|
+
return { base: pe(e, r), child: void 0 };
|
|
899
|
+
}
|
|
900
|
+
var _r = class {
|
|
901
|
+
constructor(r, t) {
|
|
902
|
+
this._p = r;
|
|
903
|
+
this.depth = t;
|
|
904
|
+
}
|
|
905
|
+
parse(r) {
|
|
906
|
+
return N(this._p, this.depth, r);
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
async function Rn(e, r, t) {
|
|
910
|
+
let n2 = [];
|
|
911
|
+
for (let a = 0, s = t.length; a < s; a++) a in t ? n2[a] = await N(e, r, t[a]) : n2[a] = 0;
|
|
912
|
+
return n2;
|
|
913
|
+
}
|
|
914
|
+
async function Pn(e, r, t, n2) {
|
|
915
|
+
return _e(t, n2, await Rn(e, r, n2));
|
|
916
|
+
}
|
|
917
|
+
async function kr(e, r, t) {
|
|
918
|
+
let n2 = Object.entries(t), a = [], s = [];
|
|
919
|
+
for (let i = 0, u = n2.length; i < u; i++) a.push(y(n2[i][0])), s.push(await N(e, r, n2[i][1]));
|
|
920
|
+
return C in t && (a.push(I(e.base, C)), s.push(Ue(er(e.base), await N(e, r, $e(t))))), v in t && (a.push(I(e.base, v)), s.push(je(rr(e.base), await N(e, r, Xe(t))))), P$1 in t && (a.push(I(e.base, P$1)), s.push(X(t[P$1]))), R in t && (a.push(I(e.base, R)), s.push(t[R] ? J : Z)), { k: a, v: s };
|
|
921
|
+
}
|
|
922
|
+
async function zr(e, r, t, n2, a) {
|
|
923
|
+
return tr(t, n2, a, await kr(e, r, n2));
|
|
924
|
+
}
|
|
925
|
+
async function xn(e, r, t, n2) {
|
|
926
|
+
return ke(t, await N(e, r, n2.valueOf()));
|
|
927
|
+
}
|
|
928
|
+
async function On(e, r, t, n2) {
|
|
929
|
+
return De(t, n2, await N(e, r, n2.buffer));
|
|
930
|
+
}
|
|
931
|
+
async function Tn(e, r, t, n2) {
|
|
932
|
+
return Fe(t, n2, await N(e, r, n2.buffer));
|
|
933
|
+
}
|
|
934
|
+
async function wn(e, r, t, n2) {
|
|
935
|
+
return Be(t, n2, await N(e, r, n2.buffer));
|
|
936
|
+
}
|
|
937
|
+
async function zt(e, r, t, n2) {
|
|
938
|
+
let a = $(n2, e.base.features);
|
|
939
|
+
return Ve(t, n2, a ? await kr(e, r, a) : o);
|
|
940
|
+
}
|
|
941
|
+
async function hn(e, r, t, n2) {
|
|
942
|
+
let a = $(n2, e.base.features);
|
|
943
|
+
return Me(t, n2, a ? await kr(e, r, a) : o);
|
|
944
|
+
}
|
|
945
|
+
async function zn(e, r, t, n2) {
|
|
946
|
+
let a = [], s = [];
|
|
947
|
+
for (let [i, u] of n2.entries()) a.push(await N(e, r, i)), s.push(await N(e, r, u));
|
|
948
|
+
return nr(e.base, t, a, s);
|
|
949
|
+
}
|
|
950
|
+
async function _n(e, r, t, n2) {
|
|
951
|
+
let a = [];
|
|
952
|
+
for (let s of n2.keys()) a.push(await N(e, r, s));
|
|
953
|
+
return Le(t, a);
|
|
954
|
+
}
|
|
955
|
+
async function _t(e, r, t, n2) {
|
|
956
|
+
let a = e.base.plugins;
|
|
957
|
+
if (a) for (let s = 0, i = a.length; s < i; s++) {
|
|
958
|
+
let u = a[s];
|
|
959
|
+
if (u.parse.async && u.test(n2)) return fe(t, u.tag, await u.parse.async(n2, new _r(e, r), { id: t }));
|
|
960
|
+
}
|
|
961
|
+
return o;
|
|
962
|
+
}
|
|
963
|
+
async function kn(e, r, t, n2) {
|
|
964
|
+
let [a, s] = await wr(n2);
|
|
965
|
+
return c(12, t, a, o, o, o, o, o, await N(e, r, s), o, o, o);
|
|
966
|
+
}
|
|
967
|
+
function Dn(e, r, t, n2, a) {
|
|
968
|
+
let s = [], i = t.on({ next: (u) => {
|
|
969
|
+
de(this.base, r), N(this, e, u).then((l) => {
|
|
970
|
+
s.push(qe(r, l));
|
|
971
|
+
}, (l) => {
|
|
972
|
+
a(l), i();
|
|
973
|
+
});
|
|
974
|
+
}, throw: (u) => {
|
|
975
|
+
de(this.base, r), N(this, e, u).then((l) => {
|
|
976
|
+
s.push(We(r, l)), n2(s), i();
|
|
977
|
+
}, (l) => {
|
|
978
|
+
a(l), i();
|
|
979
|
+
});
|
|
980
|
+
}, return: (u) => {
|
|
981
|
+
de(this.base, r), N(this, e, u).then((l) => {
|
|
982
|
+
s.push(Ge(r, l)), n2(s), i();
|
|
983
|
+
}, (l) => {
|
|
984
|
+
a(l), i();
|
|
985
|
+
});
|
|
986
|
+
} });
|
|
987
|
+
}
|
|
988
|
+
async function Fn(e, r, t, n2) {
|
|
989
|
+
return Ye(t, k(e.base, 4), await new Promise(Dn.bind(e, r, t, n2)));
|
|
990
|
+
}
|
|
991
|
+
async function Bn(e, r, t, n2) {
|
|
992
|
+
let a = [];
|
|
993
|
+
for (let s = 0, i = n2.v.length; s < i; s++) a[s] = await N(e, r, n2.v[s]);
|
|
994
|
+
return Ke(t, a, n2.t, n2.d);
|
|
995
|
+
}
|
|
996
|
+
async function Vn(e, r, t, n2) {
|
|
997
|
+
if (Array.isArray(n2)) return Pn(e, r, t, n2);
|
|
998
|
+
if (M(n2)) return Fn(e, r, t, n2);
|
|
999
|
+
if (Ze(n2)) return Bn(e, r, t, n2);
|
|
1000
|
+
let a = n2.constructor;
|
|
1001
|
+
if (a === Y) return N(e, r, n2.replacement);
|
|
1002
|
+
let s = await _t(e, r, t, n2);
|
|
1003
|
+
if (s) return s;
|
|
1004
|
+
switch (a) {
|
|
1005
|
+
case Object:
|
|
1006
|
+
return zr(e, r, t, n2, false);
|
|
1007
|
+
case o:
|
|
1008
|
+
return zr(e, r, t, n2, true);
|
|
1009
|
+
case Date:
|
|
1010
|
+
return he(t, n2);
|
|
1011
|
+
case Error:
|
|
1012
|
+
case EvalError:
|
|
1013
|
+
case RangeError:
|
|
1014
|
+
case ReferenceError:
|
|
1015
|
+
case SyntaxError:
|
|
1016
|
+
case TypeError:
|
|
1017
|
+
case URIError:
|
|
1018
|
+
return zt(e, r, t, n2);
|
|
1019
|
+
case Number:
|
|
1020
|
+
case Boolean:
|
|
1021
|
+
case String:
|
|
1022
|
+
case BigInt:
|
|
1023
|
+
return xn(e, r, t, n2);
|
|
1024
|
+
case ArrayBuffer:
|
|
1025
|
+
return or(e.base, t, n2);
|
|
1026
|
+
case Int8Array:
|
|
1027
|
+
case Int16Array:
|
|
1028
|
+
case Int32Array:
|
|
1029
|
+
case Uint8Array:
|
|
1030
|
+
case Uint16Array:
|
|
1031
|
+
case Uint32Array:
|
|
1032
|
+
case Uint8ClampedArray:
|
|
1033
|
+
case Float32Array:
|
|
1034
|
+
case Float64Array:
|
|
1035
|
+
return On(e, r, t, n2);
|
|
1036
|
+
case DataView:
|
|
1037
|
+
return wn(e, r, t, n2);
|
|
1038
|
+
case Map:
|
|
1039
|
+
return zn(e, r, t, n2);
|
|
1040
|
+
case Set:
|
|
1041
|
+
return _n(e, r, t, n2);
|
|
1042
|
+
}
|
|
1043
|
+
if (a === Promise || n2 instanceof Promise) return kn(e, r, t, n2);
|
|
1044
|
+
let i = e.base.features;
|
|
1045
|
+
if (i & 32 && a === RegExp) return ze(t, n2);
|
|
1046
|
+
if (i & 16) switch (a) {
|
|
1047
|
+
case BigInt64Array:
|
|
1048
|
+
case BigUint64Array:
|
|
1049
|
+
return Tn(e, r, t, n2);
|
|
1050
|
+
}
|
|
1051
|
+
if (i & 1 && typeof AggregateError != "undefined" && (a === AggregateError || n2 instanceof AggregateError)) return hn(e, r, t, n2);
|
|
1052
|
+
if (n2 instanceof Error) return zt(e, r, t, n2);
|
|
1053
|
+
if (C in n2 || v in n2) return zr(e, r, t, n2, !!a);
|
|
1054
|
+
throw new x$1(n2);
|
|
1055
|
+
}
|
|
1056
|
+
async function Mn(e, r, t) {
|
|
1057
|
+
let n2 = q(e.base, t);
|
|
1058
|
+
if (n2.type !== 0) return n2.value;
|
|
1059
|
+
let a = await _t(e, r, n2.value, t);
|
|
1060
|
+
if (a) return a;
|
|
1061
|
+
throw new x$1(t);
|
|
1062
|
+
}
|
|
1063
|
+
async function N(e, r, t) {
|
|
1064
|
+
switch (typeof t) {
|
|
1065
|
+
case "boolean":
|
|
1066
|
+
return t ? J : Z;
|
|
1067
|
+
case "undefined":
|
|
1068
|
+
return Ae;
|
|
1069
|
+
case "string":
|
|
1070
|
+
return X(t);
|
|
1071
|
+
case "number":
|
|
1072
|
+
return Te(t);
|
|
1073
|
+
case "bigint":
|
|
1074
|
+
return we(t);
|
|
1075
|
+
case "object": {
|
|
1076
|
+
if (t) {
|
|
1077
|
+
let n2 = q(e.base, t);
|
|
1078
|
+
return n2.type === 0 ? await Vn(e, r + 1, n2.value, t) : n2.value;
|
|
1079
|
+
}
|
|
1080
|
+
return Ee;
|
|
1081
|
+
}
|
|
1082
|
+
case "symbol":
|
|
1083
|
+
return I(e.base, t);
|
|
1084
|
+
case "function":
|
|
1085
|
+
return Mn(e, r, t);
|
|
1086
|
+
default:
|
|
1087
|
+
throw new x$1(t);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
async function oe(e, r) {
|
|
1091
|
+
try {
|
|
1092
|
+
return await N(e, 0, r);
|
|
1093
|
+
} catch (t) {
|
|
1094
|
+
throw t instanceof z ? t : new z(t);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
var ae = ((t) => (t[t.Vanilla = 1] = "Vanilla", t[t.Cross = 2] = "Cross", t))(ae || {});
|
|
1098
|
+
function ni(e) {
|
|
1099
|
+
return e;
|
|
1100
|
+
}
|
|
1101
|
+
function kt(e, r) {
|
|
1102
|
+
for (let t = 0, n2 = r.length; t < n2; t++) {
|
|
1103
|
+
let a = r[t];
|
|
1104
|
+
e.has(a) || (e.add(a), a.extends && kt(e, a.extends));
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function A(e) {
|
|
1108
|
+
if (e) {
|
|
1109
|
+
let r = /* @__PURE__ */ new Set();
|
|
1110
|
+
return kt(r, e), [...r];
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
function Dt(e) {
|
|
1114
|
+
switch (e) {
|
|
1115
|
+
case "Int8Array":
|
|
1116
|
+
return Int8Array;
|
|
1117
|
+
case "Int16Array":
|
|
1118
|
+
return Int16Array;
|
|
1119
|
+
case "Int32Array":
|
|
1120
|
+
return Int32Array;
|
|
1121
|
+
case "Uint8Array":
|
|
1122
|
+
return Uint8Array;
|
|
1123
|
+
case "Uint16Array":
|
|
1124
|
+
return Uint16Array;
|
|
1125
|
+
case "Uint32Array":
|
|
1126
|
+
return Uint32Array;
|
|
1127
|
+
case "Uint8ClampedArray":
|
|
1128
|
+
return Uint8ClampedArray;
|
|
1129
|
+
case "Float32Array":
|
|
1130
|
+
return Float32Array;
|
|
1131
|
+
case "Float64Array":
|
|
1132
|
+
return Float64Array;
|
|
1133
|
+
case "BigInt64Array":
|
|
1134
|
+
return BigInt64Array;
|
|
1135
|
+
case "BigUint64Array":
|
|
1136
|
+
return BigUint64Array;
|
|
1137
|
+
default:
|
|
1138
|
+
throw new Je(e);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
var Ln = 1e6, Un = 1e4, jn = 2e4;
|
|
1142
|
+
function Bt(e, r) {
|
|
1143
|
+
switch (r) {
|
|
1144
|
+
case 3:
|
|
1145
|
+
return Object.freeze(e);
|
|
1146
|
+
case 1:
|
|
1147
|
+
return Object.preventExtensions(e);
|
|
1148
|
+
case 2:
|
|
1149
|
+
return Object.seal(e);
|
|
1150
|
+
default:
|
|
1151
|
+
return e;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
var Yn = 1e3;
|
|
1155
|
+
function Vt(e, r) {
|
|
1156
|
+
var t;
|
|
1157
|
+
return { mode: e, plugins: r.plugins, refs: r.refs || /* @__PURE__ */ new Map(), features: (t = r.features) != null ? t : 63 ^ (r.disabledFeatures || 0), depthLimit: r.depthLimit || Yn };
|
|
1158
|
+
}
|
|
1159
|
+
function Mt(e) {
|
|
1160
|
+
return { mode: 1, base: Vt(1, e), child: o, state: { marked: new Set(e.markedRefs) } };
|
|
1161
|
+
}
|
|
1162
|
+
var Dr = class {
|
|
1163
|
+
constructor(r, t) {
|
|
1164
|
+
this._p = r;
|
|
1165
|
+
this.depth = t;
|
|
1166
|
+
}
|
|
1167
|
+
deserialize(r) {
|
|
1168
|
+
return p$1(this._p, this.depth, r);
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
function Ut(e, r) {
|
|
1172
|
+
if (r < 0 || !Number.isFinite(r) || !Number.isInteger(r)) throw new h({ t: 4, i: r });
|
|
1173
|
+
if (e.refs.has(r)) throw new Error("Conflicted ref id: " + r);
|
|
1174
|
+
}
|
|
1175
|
+
function qn(e, r, t) {
|
|
1176
|
+
return Ut(e.base, r), e.state.marked.has(r) && e.base.refs.set(r, t), t;
|
|
1177
|
+
}
|
|
1178
|
+
function Wn(e, r, t) {
|
|
1179
|
+
return Ut(e.base, r), e.base.refs.set(r, t), t;
|
|
1180
|
+
}
|
|
1181
|
+
function b(e, r, t) {
|
|
1182
|
+
return e.mode === 1 ? qn(e, r, t) : Wn(e, r, t);
|
|
1183
|
+
}
|
|
1184
|
+
function Fr(e, r, t) {
|
|
1185
|
+
if (Object.hasOwn(r, t)) return r[t];
|
|
1186
|
+
throw new h(e);
|
|
1187
|
+
}
|
|
1188
|
+
function Gn(e, r) {
|
|
1189
|
+
return b(e, r.i, ft(B(r.s)));
|
|
1190
|
+
}
|
|
1191
|
+
function Kn(e, r, t) {
|
|
1192
|
+
let n2 = t.a, a = n2.length, s = b(e, t.i, new Array(a));
|
|
1193
|
+
for (let i = 0, u; i < a; i++) u = n2[i], u && (s[i] = p$1(e, r, u));
|
|
1194
|
+
return Bt(s, t.o), s;
|
|
1195
|
+
}
|
|
1196
|
+
function Hn(e) {
|
|
1197
|
+
switch (e) {
|
|
1198
|
+
case "constructor":
|
|
1199
|
+
case "__proto__":
|
|
1200
|
+
case "prototype":
|
|
1201
|
+
case "__defineGetter__":
|
|
1202
|
+
case "__defineSetter__":
|
|
1203
|
+
case "__lookupGetter__":
|
|
1204
|
+
case "__lookupSetter__":
|
|
1205
|
+
return false;
|
|
1206
|
+
default:
|
|
1207
|
+
return true;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
function Jn(e) {
|
|
1211
|
+
switch (e) {
|
|
1212
|
+
case v:
|
|
1213
|
+
case R:
|
|
1214
|
+
case P$1:
|
|
1215
|
+
case C:
|
|
1216
|
+
return true;
|
|
1217
|
+
default:
|
|
1218
|
+
return false;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
function Ft(e, r, t) {
|
|
1222
|
+
Hn(r) ? e[r] = t : Object.defineProperty(e, r, { value: t, configurable: true, enumerable: true, writable: true });
|
|
1223
|
+
}
|
|
1224
|
+
function Zn(e, r, t, n2, a) {
|
|
1225
|
+
if (typeof n2 == "string") Ft(t, n2, p$1(e, r, a));
|
|
1226
|
+
else {
|
|
1227
|
+
let s = p$1(e, r, n2);
|
|
1228
|
+
switch (typeof s) {
|
|
1229
|
+
case "string":
|
|
1230
|
+
Ft(t, s, p$1(e, r, a));
|
|
1231
|
+
break;
|
|
1232
|
+
case "symbol":
|
|
1233
|
+
Jn(s) && (t[s] = p$1(e, r, a));
|
|
1234
|
+
break;
|
|
1235
|
+
default:
|
|
1236
|
+
throw new h(n2);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
function jt(e, r, t, n2) {
|
|
1241
|
+
let a = t.k;
|
|
1242
|
+
if (a.length > 0) for (let i = 0, u = t.v, l = a.length; i < l; i++) Zn(e, r, n2, a[i], u[i]);
|
|
1243
|
+
return n2;
|
|
1244
|
+
}
|
|
1245
|
+
function $n(e, r, t) {
|
|
1246
|
+
let n2 = b(e, t.i, t.t === 10 ? {} : /* @__PURE__ */ Object.create(null));
|
|
1247
|
+
return jt(e, r, t.p, n2), Bt(n2, t.o), n2;
|
|
1248
|
+
}
|
|
1249
|
+
function Xn(e, r) {
|
|
1250
|
+
return b(e, r.i, new Date(r.s));
|
|
1251
|
+
}
|
|
1252
|
+
function Qn(e, r) {
|
|
1253
|
+
if (e.base.features & 32) {
|
|
1254
|
+
let t = B(r.c);
|
|
1255
|
+
if (t.length > jn) throw new h(r);
|
|
1256
|
+
return b(e, r.i, new RegExp(t, r.m));
|
|
1257
|
+
}
|
|
1258
|
+
throw new w$1(r);
|
|
1259
|
+
}
|
|
1260
|
+
function eo(e, r, t) {
|
|
1261
|
+
let n2 = b(e, t.i, /* @__PURE__ */ new Set());
|
|
1262
|
+
for (let a = 0, s = t.a, i = s.length; a < i; a++) n2.add(p$1(e, r, s[a]));
|
|
1263
|
+
return n2;
|
|
1264
|
+
}
|
|
1265
|
+
function ro(e, r, t) {
|
|
1266
|
+
let n2 = b(e, t.i, /* @__PURE__ */ new Map());
|
|
1267
|
+
for (let a = 0, s = t.e.k, i = t.e.v, u = s.length; a < u; a++) n2.set(p$1(e, r, s[a]), p$1(e, r, i[a]));
|
|
1268
|
+
return n2;
|
|
1269
|
+
}
|
|
1270
|
+
function to(e, r) {
|
|
1271
|
+
if (r.s.length > Ln) throw new h(r);
|
|
1272
|
+
return b(e, r.i, Or(B(r.s)));
|
|
1273
|
+
}
|
|
1274
|
+
function no(e, r, t) {
|
|
1275
|
+
var u;
|
|
1276
|
+
let n2 = Dt(t.c), a = p$1(e, r, t.f), s = (u = t.b) != null ? u : 0;
|
|
1277
|
+
if (s < 0 || s > a.byteLength) throw new h(t);
|
|
1278
|
+
return b(e, t.i, new n2(a, s, t.l));
|
|
1279
|
+
}
|
|
1280
|
+
function oo(e, r, t) {
|
|
1281
|
+
var i;
|
|
1282
|
+
let n2 = p$1(e, r, t.f), a = (i = t.b) != null ? i : 0;
|
|
1283
|
+
if (a < 0 || a > n2.byteLength) throw new h(t);
|
|
1284
|
+
return b(e, t.i, new DataView(n2, a, t.l));
|
|
1285
|
+
}
|
|
1286
|
+
function Yt(e, r, t, n2) {
|
|
1287
|
+
if (t.p) {
|
|
1288
|
+
let a = jt(e, r, t.p, {});
|
|
1289
|
+
Object.defineProperties(n2, Object.getOwnPropertyDescriptors(a));
|
|
1290
|
+
}
|
|
1291
|
+
return n2;
|
|
1292
|
+
}
|
|
1293
|
+
function ao(e, r, t) {
|
|
1294
|
+
let n2 = b(e, t.i, new AggregateError([], B(t.m)));
|
|
1295
|
+
return Yt(e, r, t, n2);
|
|
1296
|
+
}
|
|
1297
|
+
function so(e, r, t) {
|
|
1298
|
+
let n2 = Fr(t, at, t.s), a = b(e, t.i, new n2(B(t.m)));
|
|
1299
|
+
return Yt(e, r, t, a);
|
|
1300
|
+
}
|
|
1301
|
+
function io(e, r, t) {
|
|
1302
|
+
let n2 = re(), a = b(e, t.i, n2.p), s = p$1(e, r, t.f);
|
|
1303
|
+
return t.s ? n2.s(s) : n2.f(s), a;
|
|
1304
|
+
}
|
|
1305
|
+
function uo(e, r, t) {
|
|
1306
|
+
return b(e, t.i, Object(p$1(e, r, t.f)));
|
|
1307
|
+
}
|
|
1308
|
+
function lo(e, r, t) {
|
|
1309
|
+
let n2 = e.base.plugins;
|
|
1310
|
+
if (n2) {
|
|
1311
|
+
let a = B(t.c);
|
|
1312
|
+
for (let s = 0, i = n2.length; s < i; s++) {
|
|
1313
|
+
let u = n2[s];
|
|
1314
|
+
if (u.tag === a) return b(e, t.i, u.deserialize(t.s, new Dr(e, r), { id: t.i }));
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
throw new Q(t.c);
|
|
1318
|
+
}
|
|
1319
|
+
function co(e, r) {
|
|
1320
|
+
return b(e, r.i, b(e, r.s, re()).p);
|
|
1321
|
+
}
|
|
1322
|
+
function fo(e, r, t) {
|
|
1323
|
+
let n2 = e.base.refs.get(t.i);
|
|
1324
|
+
if (n2) return n2.s(p$1(e, r, t.a[1])), o;
|
|
1325
|
+
throw new V("Promise");
|
|
1326
|
+
}
|
|
1327
|
+
function So(e, r, t) {
|
|
1328
|
+
let n2 = e.base.refs.get(t.i);
|
|
1329
|
+
if (n2) return n2.f(p$1(e, r, t.a[1])), o;
|
|
1330
|
+
throw new V("Promise");
|
|
1331
|
+
}
|
|
1332
|
+
function mo(e, r, t) {
|
|
1333
|
+
p$1(e, r, t.a[0]);
|
|
1334
|
+
let n2 = p$1(e, r, t.a[1]);
|
|
1335
|
+
return It(n2);
|
|
1336
|
+
}
|
|
1337
|
+
function po(e, r, t) {
|
|
1338
|
+
p$1(e, r, t.a[0]);
|
|
1339
|
+
let n2 = p$1(e, r, t.a[1]);
|
|
1340
|
+
return Tt(n2);
|
|
1341
|
+
}
|
|
1342
|
+
function go(e, r, t) {
|
|
1343
|
+
let n2 = b(e, t.i, te()), a = t.a, s = a.length;
|
|
1344
|
+
if (s) for (let i = 0; i < s; i++) p$1(e, r, a[i]);
|
|
1345
|
+
return n2;
|
|
1346
|
+
}
|
|
1347
|
+
function yo(e, r, t) {
|
|
1348
|
+
let n2 = e.base.refs.get(t.i);
|
|
1349
|
+
if (n2 && M(n2)) return n2.next(p$1(e, r, t.f)), o;
|
|
1350
|
+
throw new V("Stream");
|
|
1351
|
+
}
|
|
1352
|
+
function No(e, r, t) {
|
|
1353
|
+
let n2 = e.base.refs.get(t.i);
|
|
1354
|
+
if (n2 && M(n2)) return n2.throw(p$1(e, r, t.f)), o;
|
|
1355
|
+
throw new V("Stream");
|
|
1356
|
+
}
|
|
1357
|
+
function bo(e, r, t) {
|
|
1358
|
+
let n2 = e.base.refs.get(t.i);
|
|
1359
|
+
if (n2 && M(n2)) return n2.return(p$1(e, r, t.f)), o;
|
|
1360
|
+
throw new V("Stream");
|
|
1361
|
+
}
|
|
1362
|
+
function vo(e, r, t) {
|
|
1363
|
+
return p$1(e, r, t.f), o;
|
|
1364
|
+
}
|
|
1365
|
+
function Co(e, r, t) {
|
|
1366
|
+
return p$1(e, r, t.a[1]), o;
|
|
1367
|
+
}
|
|
1368
|
+
function Ao(e, r, t) {
|
|
1369
|
+
let n2 = b(e, t.i, Tr([], t.s, t.l));
|
|
1370
|
+
for (let a = 0, s = t.a.length; a < s; a++) n2.v[a] = p$1(e, r, t.a[a]);
|
|
1371
|
+
return n2;
|
|
1372
|
+
}
|
|
1373
|
+
function p$1(e, r, t) {
|
|
1374
|
+
if (r > e.base.depthLimit) throw new ee$1(e.base.depthLimit);
|
|
1375
|
+
switch (r += 1, t.t) {
|
|
1376
|
+
case 2:
|
|
1377
|
+
return Fr(t, ot, t.s);
|
|
1378
|
+
case 0:
|
|
1379
|
+
return Number(t.s);
|
|
1380
|
+
case 1:
|
|
1381
|
+
return B(String(t.s));
|
|
1382
|
+
case 3:
|
|
1383
|
+
if (String(t.s).length > Un) throw new h(t);
|
|
1384
|
+
return BigInt(t.s);
|
|
1385
|
+
case 4:
|
|
1386
|
+
return e.base.refs.get(t.i);
|
|
1387
|
+
case 18:
|
|
1388
|
+
return Gn(e, t);
|
|
1389
|
+
case 9:
|
|
1390
|
+
return Kn(e, r, t);
|
|
1391
|
+
case 10:
|
|
1392
|
+
case 11:
|
|
1393
|
+
return $n(e, r, t);
|
|
1394
|
+
case 5:
|
|
1395
|
+
return Xn(e, t);
|
|
1396
|
+
case 6:
|
|
1397
|
+
return Qn(e, t);
|
|
1398
|
+
case 7:
|
|
1399
|
+
return eo(e, r, t);
|
|
1400
|
+
case 8:
|
|
1401
|
+
return ro(e, r, t);
|
|
1402
|
+
case 19:
|
|
1403
|
+
return to(e, t);
|
|
1404
|
+
case 16:
|
|
1405
|
+
case 15:
|
|
1406
|
+
return no(e, r, t);
|
|
1407
|
+
case 20:
|
|
1408
|
+
return oo(e, r, t);
|
|
1409
|
+
case 14:
|
|
1410
|
+
return ao(e, r, t);
|
|
1411
|
+
case 13:
|
|
1412
|
+
return so(e, r, t);
|
|
1413
|
+
case 12:
|
|
1414
|
+
return io(e, r, t);
|
|
1415
|
+
case 17:
|
|
1416
|
+
return Fr(t, tt, t.s);
|
|
1417
|
+
case 21:
|
|
1418
|
+
return uo(e, r, t);
|
|
1419
|
+
case 25:
|
|
1420
|
+
return lo(e, r, t);
|
|
1421
|
+
case 22:
|
|
1422
|
+
return co(e, t);
|
|
1423
|
+
case 23:
|
|
1424
|
+
return fo(e, r, t);
|
|
1425
|
+
case 24:
|
|
1426
|
+
return So(e, r, t);
|
|
1427
|
+
case 28:
|
|
1428
|
+
return mo(e, r, t);
|
|
1429
|
+
case 30:
|
|
1430
|
+
return po(e, r, t);
|
|
1431
|
+
case 31:
|
|
1432
|
+
return go(e, r, t);
|
|
1433
|
+
case 32:
|
|
1434
|
+
return yo(e, r, t);
|
|
1435
|
+
case 33:
|
|
1436
|
+
return No(e, r, t);
|
|
1437
|
+
case 34:
|
|
1438
|
+
return bo(e, r, t);
|
|
1439
|
+
case 27:
|
|
1440
|
+
return vo(e, r, t);
|
|
1441
|
+
case 29:
|
|
1442
|
+
return Co(e, r, t);
|
|
1443
|
+
case 35:
|
|
1444
|
+
return Ao(e, r, t);
|
|
1445
|
+
default:
|
|
1446
|
+
throw new w$1(t);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
function ar(e, r) {
|
|
1450
|
+
try {
|
|
1451
|
+
return p$1(e, 0, r);
|
|
1452
|
+
} catch (t) {
|
|
1453
|
+
throw new He(t);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
var Eo = () => T, Io = Eo.toString(), qt = /=>/.test(Io);
|
|
1457
|
+
function sr(e, r) {
|
|
1458
|
+
return qt ? (e.length === 1 ? e[0] : "(" + e.join(",") + ")") + "=>" + (r.startsWith("{") ? "(" + r + ")" : r) : "function(" + e.join(",") + "){return " + r + "}";
|
|
1459
|
+
}
|
|
1460
|
+
function Wt(e, r) {
|
|
1461
|
+
return qt ? (e.length === 1 ? e[0] : "(" + e.join(",") + ")") + "=>{" + r + "}" : "function(" + e.join(",") + "){" + r + "}";
|
|
1462
|
+
}
|
|
1463
|
+
var Ht = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_", Gt = Ht.length, Jt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_", Kt = Jt.length;
|
|
1464
|
+
function Br(e) {
|
|
1465
|
+
let r = e % Gt, t = Ht[r];
|
|
1466
|
+
for (e = (e - r) / Gt; e > 0; ) r = e % Kt, t += Jt[r], e = (e - r) / Kt;
|
|
1467
|
+
return t;
|
|
1468
|
+
}
|
|
1469
|
+
var Ro = /^[$A-Z_][0-9A-Z_$]*$/i;
|
|
1470
|
+
function Vr(e) {
|
|
1471
|
+
let r = e[0];
|
|
1472
|
+
return (r === "$" || r === "_" || r >= "A" && r <= "Z" || r >= "a" && r <= "z") && Ro.test(e);
|
|
1473
|
+
}
|
|
1474
|
+
function ye(e) {
|
|
1475
|
+
switch (e.t) {
|
|
1476
|
+
case 0:
|
|
1477
|
+
return e.s + "=" + e.v;
|
|
1478
|
+
case 2:
|
|
1479
|
+
return e.s + ".set(" + e.k + "," + e.v + ")";
|
|
1480
|
+
case 1:
|
|
1481
|
+
return e.s + ".add(" + e.v + ")";
|
|
1482
|
+
case 3:
|
|
1483
|
+
return e.s + ".delete(" + e.k + ")";
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
function Po(e) {
|
|
1487
|
+
let r = [], t = e[0];
|
|
1488
|
+
for (let n2 = 1, a = e.length, s, i = t; n2 < a; n2++) s = e[n2], s.t === 0 && s.v === i.v ? t = { t: 0, s: s.s, k: o, v: ye(t) } : s.t === 2 && s.s === i.s ? t = { t: 2, s: ye(t), k: s.k, v: s.v } : s.t === 1 && s.s === i.s ? t = { t: 1, s: ye(t), k: o, v: s.v } : s.t === 3 && s.s === i.s ? t = { t: 3, s: ye(t), k: s.k, v: o } : (r.push(t), t = s), i = s;
|
|
1489
|
+
return r.push(t), r;
|
|
1490
|
+
}
|
|
1491
|
+
function tn(e) {
|
|
1492
|
+
if (e.length) {
|
|
1493
|
+
let r = "", t = Po(e);
|
|
1494
|
+
for (let n2 = 0, a = t.length; n2 < a; n2++) r += ye(t[n2]) + ",";
|
|
1495
|
+
return r;
|
|
1496
|
+
}
|
|
1497
|
+
return o;
|
|
1498
|
+
}
|
|
1499
|
+
var xo = "Object.create(null)", Oo = "new Set", To = "new Map", wo = "Promise.resolve", ho = "Promise.reject", zo = { 3: "Object.freeze", 2: "Object.seal", 1: "Object.preventExtensions", 0: o };
|
|
1500
|
+
function nn(e, r) {
|
|
1501
|
+
return { mode: e, plugins: r.plugins, features: r.features, marked: new Set(r.markedRefs), stack: [], flags: [], assignments: [] };
|
|
1502
|
+
}
|
|
1503
|
+
function ur(e) {
|
|
1504
|
+
return { mode: 2, base: nn(2, e), state: e, child: o };
|
|
1505
|
+
}
|
|
1506
|
+
var Mr = class {
|
|
1507
|
+
constructor(r) {
|
|
1508
|
+
this._p = r;
|
|
1509
|
+
}
|
|
1510
|
+
serialize(r) {
|
|
1511
|
+
return f(this._p, r);
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
function ko(e, r) {
|
|
1515
|
+
let t = e.valid.get(r);
|
|
1516
|
+
t == null && (t = e.valid.size, e.valid.set(r, t));
|
|
1517
|
+
let n2 = e.vars[t];
|
|
1518
|
+
return n2 == null && (n2 = Br(t), e.vars[t] = n2), n2;
|
|
1519
|
+
}
|
|
1520
|
+
function Do(e) {
|
|
1521
|
+
return ce + "[" + e + "]";
|
|
1522
|
+
}
|
|
1523
|
+
function m(e, r) {
|
|
1524
|
+
return e.mode === 1 ? ko(e.state, r) : Do(r);
|
|
1525
|
+
}
|
|
1526
|
+
function O(e, r) {
|
|
1527
|
+
e.marked.add(r);
|
|
1528
|
+
}
|
|
1529
|
+
function Lr(e, r) {
|
|
1530
|
+
return e.marked.has(r);
|
|
1531
|
+
}
|
|
1532
|
+
function jr(e, r, t) {
|
|
1533
|
+
r !== 0 && (O(e.base, t), e.base.flags.push({ type: r, value: m(e, t) }));
|
|
1534
|
+
}
|
|
1535
|
+
function Fo(e) {
|
|
1536
|
+
let r = "";
|
|
1537
|
+
for (let t = 0, n2 = e.flags, a = n2.length; t < a; t++) {
|
|
1538
|
+
let s = n2[t];
|
|
1539
|
+
r += zo[s.type] + "(" + s.value + "),";
|
|
1540
|
+
}
|
|
1541
|
+
return r;
|
|
1542
|
+
}
|
|
1543
|
+
function on(e) {
|
|
1544
|
+
let r = tn(e.assignments), t = Fo(e);
|
|
1545
|
+
return r ? t ? r + t : r : t;
|
|
1546
|
+
}
|
|
1547
|
+
function Yr(e, r, t) {
|
|
1548
|
+
e.assignments.push({ t: 0, s: r, k: o, v: t });
|
|
1549
|
+
}
|
|
1550
|
+
function Bo(e, r, t) {
|
|
1551
|
+
e.base.assignments.push({ t: 1, s: m(e, r), k: o, v: t });
|
|
1552
|
+
}
|
|
1553
|
+
function ge(e, r, t, n2) {
|
|
1554
|
+
e.base.assignments.push({ t: 2, s: m(e, r), k: t, v: n2 });
|
|
1555
|
+
}
|
|
1556
|
+
function Zt(e, r, t) {
|
|
1557
|
+
e.base.assignments.push({ t: 3, s: m(e, r), k: t, v: o });
|
|
1558
|
+
}
|
|
1559
|
+
function Ne(e, r, t, n2) {
|
|
1560
|
+
Yr(e.base, m(e, r) + "[" + t + "]", n2);
|
|
1561
|
+
}
|
|
1562
|
+
function Ur(e, r, t, n2) {
|
|
1563
|
+
Yr(e.base, m(e, r) + "." + t, n2);
|
|
1564
|
+
}
|
|
1565
|
+
function Vo(e, r, t, n2) {
|
|
1566
|
+
Yr(e.base, m(e, r) + ".v[" + t + "]", n2);
|
|
1567
|
+
}
|
|
1568
|
+
function D(e, r) {
|
|
1569
|
+
return r.t === 4 && e.stack.includes(r.i);
|
|
1570
|
+
}
|
|
1571
|
+
function se(e, r, t) {
|
|
1572
|
+
return e.mode === 1 && !Lr(e.base, r) ? t : m(e, r) + "=" + t;
|
|
1573
|
+
}
|
|
1574
|
+
function Mo(e) {
|
|
1575
|
+
return U + '.get("' + e.s + '")';
|
|
1576
|
+
}
|
|
1577
|
+
function $t(e, r, t, n2) {
|
|
1578
|
+
return t ? D(e.base, t) ? (O(e.base, r), Ne(e, r, n2, m(e, t.i)), "") : f(e, t) : "";
|
|
1579
|
+
}
|
|
1580
|
+
function Lo(e, r) {
|
|
1581
|
+
let t = r.i, n2 = r.a, a = n2.length;
|
|
1582
|
+
if (a > 0) {
|
|
1583
|
+
e.base.stack.push(t);
|
|
1584
|
+
let s = $t(e, t, n2[0], 0), i = s === "";
|
|
1585
|
+
for (let u = 1, l; u < a; u++) l = $t(e, t, n2[u], u), s += "," + l, i = l === "";
|
|
1586
|
+
return e.base.stack.pop(), jr(e, r.o, r.i), "[" + s + (i ? ",]" : "]");
|
|
1587
|
+
}
|
|
1588
|
+
return "[]";
|
|
1589
|
+
}
|
|
1590
|
+
function Xt(e, r, t, n2) {
|
|
1591
|
+
if (typeof t == "string") {
|
|
1592
|
+
let a = Number(t), s = a >= 0 && a.toString() === t || Vr(t);
|
|
1593
|
+
if (D(e.base, n2)) {
|
|
1594
|
+
let i = m(e, n2.i);
|
|
1595
|
+
return O(e.base, r.i), s && a !== a ? Ur(e, r.i, t, i) : Ne(e, r.i, s ? t : '"' + t + '"', i), "";
|
|
1596
|
+
}
|
|
1597
|
+
return (s ? t : '"' + t + '"') + ":" + f(e, n2);
|
|
1598
|
+
}
|
|
1599
|
+
return "[" + f(e, t) + "]:" + f(e, n2);
|
|
1600
|
+
}
|
|
1601
|
+
function an(e, r, t) {
|
|
1602
|
+
let n2 = t.k, a = n2.length;
|
|
1603
|
+
if (a > 0) {
|
|
1604
|
+
let s = t.v;
|
|
1605
|
+
e.base.stack.push(r.i);
|
|
1606
|
+
let i = Xt(e, r, n2[0], s[0]);
|
|
1607
|
+
for (let u = 1, l = i; u < a; u++) l = Xt(e, r, n2[u], s[u]), i += (l && i && ",") + l;
|
|
1608
|
+
return e.base.stack.pop(), "{" + i + "}";
|
|
1609
|
+
}
|
|
1610
|
+
return "{}";
|
|
1611
|
+
}
|
|
1612
|
+
function Uo(e, r) {
|
|
1613
|
+
return jr(e, r.o, r.i), an(e, r, r.p);
|
|
1614
|
+
}
|
|
1615
|
+
function jo(e, r, t, n2) {
|
|
1616
|
+
let a = an(e, r, t);
|
|
1617
|
+
return a !== "{}" ? "Object.assign(" + n2 + "," + a + ")" : n2;
|
|
1618
|
+
}
|
|
1619
|
+
function Yo(e, r, t, n2, a) {
|
|
1620
|
+
let s = e.base, i = f(e, a), u = Number(n2), l = u >= 0 && u.toString() === n2 || Vr(n2);
|
|
1621
|
+
if (D(s, a)) l && u !== u ? Ur(e, r.i, n2, i) : Ne(e, r.i, l ? n2 : '"' + n2 + '"', i);
|
|
1622
|
+
else {
|
|
1623
|
+
let g = s.assignments;
|
|
1624
|
+
s.assignments = t, l && u !== u ? Ur(e, r.i, n2, i) : Ne(e, r.i, l ? n2 : '"' + n2 + '"', i), s.assignments = g;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
function qo(e, r, t, n2, a) {
|
|
1628
|
+
if (typeof n2 == "string") Yo(e, r, t, n2, a);
|
|
1629
|
+
else {
|
|
1630
|
+
let s = e.base, i = s.stack;
|
|
1631
|
+
s.stack = [];
|
|
1632
|
+
let u = f(e, a);
|
|
1633
|
+
s.stack = i;
|
|
1634
|
+
let l = s.assignments;
|
|
1635
|
+
s.assignments = t, Ne(e, r.i, f(e, n2), u), s.assignments = l;
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
function Wo(e, r, t) {
|
|
1639
|
+
let n2 = t.k, a = n2.length;
|
|
1640
|
+
if (a > 0) {
|
|
1641
|
+
let s = [], i = t.v;
|
|
1642
|
+
e.base.stack.push(r.i);
|
|
1643
|
+
for (let u = 0; u < a; u++) qo(e, r, s, n2[u], i[u]);
|
|
1644
|
+
return e.base.stack.pop(), tn(s);
|
|
1645
|
+
}
|
|
1646
|
+
return o;
|
|
1647
|
+
}
|
|
1648
|
+
function qr(e, r, t) {
|
|
1649
|
+
if (r.p) {
|
|
1650
|
+
let n2 = e.base;
|
|
1651
|
+
if (n2.features & 8) t = jo(e, r, r.p, t);
|
|
1652
|
+
else {
|
|
1653
|
+
O(n2, r.i);
|
|
1654
|
+
let a = Wo(e, r, r.p);
|
|
1655
|
+
if (a) return "(" + se(e, r.i, t) + "," + a + m(e, r.i) + ")";
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
return t;
|
|
1659
|
+
}
|
|
1660
|
+
function Go(e, r) {
|
|
1661
|
+
return jr(e, r.o, r.i), qr(e, r, xo);
|
|
1662
|
+
}
|
|
1663
|
+
function Ko(e) {
|
|
1664
|
+
return 'new Date("' + e.s + '")';
|
|
1665
|
+
}
|
|
1666
|
+
function Ho(e, r) {
|
|
1667
|
+
if (e.base.features & 32) return "/" + r.c + "/" + r.m;
|
|
1668
|
+
throw new w$1(r);
|
|
1669
|
+
}
|
|
1670
|
+
function Qt(e, r, t) {
|
|
1671
|
+
let n2 = e.base;
|
|
1672
|
+
return D(n2, t) ? (O(n2, r), Bo(e, r, m(e, t.i)), "") : f(e, t);
|
|
1673
|
+
}
|
|
1674
|
+
function Jo(e, r) {
|
|
1675
|
+
let t = Oo, n2 = r.a, a = n2.length, s = r.i;
|
|
1676
|
+
if (a > 0) {
|
|
1677
|
+
e.base.stack.push(s);
|
|
1678
|
+
let i = Qt(e, s, n2[0]);
|
|
1679
|
+
for (let u = 1, l = i; u < a; u++) l = Qt(e, s, n2[u]), i += (l && i && ",") + l;
|
|
1680
|
+
e.base.stack.pop(), i && (t += "([" + i + "])");
|
|
1681
|
+
}
|
|
1682
|
+
return t;
|
|
1683
|
+
}
|
|
1684
|
+
function en(e, r, t, n2, a) {
|
|
1685
|
+
let s = e.base;
|
|
1686
|
+
if (D(s, t)) {
|
|
1687
|
+
let i = m(e, t.i);
|
|
1688
|
+
if (O(s, r), D(s, n2)) {
|
|
1689
|
+
let l = m(e, n2.i);
|
|
1690
|
+
return ge(e, r, i, l), "";
|
|
1691
|
+
}
|
|
1692
|
+
if (n2.t !== 4 && n2.i != null && Lr(s, n2.i)) {
|
|
1693
|
+
let l = "(" + f(e, n2) + ",[" + a + "," + a + "])";
|
|
1694
|
+
return ge(e, r, i, m(e, n2.i)), Zt(e, r, a), l;
|
|
1695
|
+
}
|
|
1696
|
+
let u = s.stack;
|
|
1697
|
+
return s.stack = [], ge(e, r, i, f(e, n2)), s.stack = u, "";
|
|
1698
|
+
}
|
|
1699
|
+
if (D(s, n2)) {
|
|
1700
|
+
let i = m(e, n2.i);
|
|
1701
|
+
if (O(s, r), t.t !== 4 && t.i != null && Lr(s, t.i)) {
|
|
1702
|
+
let l = "(" + f(e, t) + ",[" + a + "," + a + "])";
|
|
1703
|
+
return ge(e, r, m(e, t.i), i), Zt(e, r, a), l;
|
|
1704
|
+
}
|
|
1705
|
+
let u = s.stack;
|
|
1706
|
+
return s.stack = [], ge(e, r, f(e, t), i), s.stack = u, "";
|
|
1707
|
+
}
|
|
1708
|
+
return "[" + f(e, t) + "," + f(e, n2) + "]";
|
|
1709
|
+
}
|
|
1710
|
+
function Zo(e, r) {
|
|
1711
|
+
let t = To, n2 = r.e.k, a = n2.length, s = r.i, i = r.f, u = m(e, i.i), l = e.base;
|
|
1712
|
+
if (a > 0) {
|
|
1713
|
+
let g = r.e.v;
|
|
1714
|
+
l.stack.push(s);
|
|
1715
|
+
let S = en(e, s, n2[0], g[0], u);
|
|
1716
|
+
for (let d = 1, K = S; d < a; d++) K = en(e, s, n2[d], g[d], u), S += (K && S && ",") + K;
|
|
1717
|
+
l.stack.pop(), S && (t += "([" + S + "])");
|
|
1718
|
+
}
|
|
1719
|
+
return i.t === 26 && (O(l, i.i), t = "(" + f(e, i) + "," + t + ")"), t;
|
|
1720
|
+
}
|
|
1721
|
+
function $o(e, r) {
|
|
1722
|
+
return W(e, r.f) + '("' + r.s + '")';
|
|
1723
|
+
}
|
|
1724
|
+
function Xo(e, r) {
|
|
1725
|
+
return "new " + r.c + "(" + f(e, r.f) + "," + r.b + "," + r.l + ")";
|
|
1726
|
+
}
|
|
1727
|
+
function Qo(e, r) {
|
|
1728
|
+
return "new DataView(" + f(e, r.f) + "," + r.b + "," + r.l + ")";
|
|
1729
|
+
}
|
|
1730
|
+
function ea(e, r) {
|
|
1731
|
+
let t = r.i;
|
|
1732
|
+
e.base.stack.push(t);
|
|
1733
|
+
let n2 = qr(e, r, 'new AggregateError([],"' + r.m + '")');
|
|
1734
|
+
return e.base.stack.pop(), n2;
|
|
1735
|
+
}
|
|
1736
|
+
function ra(e, r) {
|
|
1737
|
+
return qr(e, r, "new " + Ce[r.s] + '("' + r.m + '")');
|
|
1738
|
+
}
|
|
1739
|
+
function ta(e, r) {
|
|
1740
|
+
let t, n2 = r.f, a = r.i, s = r.s ? wo : ho, i = e.base;
|
|
1741
|
+
if (D(i, n2)) {
|
|
1742
|
+
let u = m(e, n2.i);
|
|
1743
|
+
t = s + (r.s ? "().then(" + sr([], u) + ")" : "().catch(" + Wt([], "throw " + u) + ")");
|
|
1744
|
+
} else {
|
|
1745
|
+
i.stack.push(a);
|
|
1746
|
+
let u = f(e, n2);
|
|
1747
|
+
i.stack.pop(), t = s + "(" + u + ")";
|
|
1748
|
+
}
|
|
1749
|
+
return t;
|
|
1750
|
+
}
|
|
1751
|
+
function na(e, r) {
|
|
1752
|
+
return "Object(" + f(e, r.f) + ")";
|
|
1753
|
+
}
|
|
1754
|
+
function W(e, r) {
|
|
1755
|
+
let t = f(e, r);
|
|
1756
|
+
return r.t === 4 ? t : "(" + t + ")";
|
|
1757
|
+
}
|
|
1758
|
+
function oa(e, r) {
|
|
1759
|
+
if (e.mode === 1) throw new w$1(r);
|
|
1760
|
+
return "(" + se(e, r.s, W(e, r.f) + "()") + ").p";
|
|
1761
|
+
}
|
|
1762
|
+
function aa(e, r) {
|
|
1763
|
+
if (e.mode === 1) throw new w$1(r);
|
|
1764
|
+
return W(e, r.a[0]) + "(" + m(e, r.i) + "," + f(e, r.a[1]) + ")";
|
|
1765
|
+
}
|
|
1766
|
+
function sa(e, r) {
|
|
1767
|
+
if (e.mode === 1) throw new w$1(r);
|
|
1768
|
+
return W(e, r.a[0]) + "(" + m(e, r.i) + "," + f(e, r.a[1]) + ")";
|
|
1769
|
+
}
|
|
1770
|
+
function ia(e, r) {
|
|
1771
|
+
let t = e.base.plugins;
|
|
1772
|
+
if (t) for (let n2 = 0, a = t.length; n2 < a; n2++) {
|
|
1773
|
+
let s = t[n2];
|
|
1774
|
+
if (s.tag === r.c) return e.child == null && (e.child = new Mr(e)), s.serialize(r.s, e.child, { id: r.i });
|
|
1775
|
+
}
|
|
1776
|
+
throw new Q(r.c);
|
|
1777
|
+
}
|
|
1778
|
+
function ua(e, r) {
|
|
1779
|
+
let t = "", n2 = false;
|
|
1780
|
+
return r.f.t !== 4 && (O(e.base, r.f.i), t = "(" + f(e, r.f) + ",", n2 = true), t += se(e, r.i, "(" + Ct + ")(" + m(e, r.f.i) + ")"), n2 && (t += ")"), t;
|
|
1781
|
+
}
|
|
1782
|
+
function la(e, r) {
|
|
1783
|
+
return W(e, r.a[0]) + "(" + f(e, r.a[1]) + ")";
|
|
1784
|
+
}
|
|
1785
|
+
function ca(e, r) {
|
|
1786
|
+
let t = r.a[0], n2 = r.a[1], a = e.base, s = "";
|
|
1787
|
+
t.t !== 4 && (O(a, t.i), s += "(" + f(e, t)), n2.t !== 4 && (O(a, n2.i), s += (s ? "," : "(") + f(e, n2)), s && (s += ",");
|
|
1788
|
+
let i = se(e, r.i, "(" + At + ")(" + m(e, n2.i) + "," + m(e, t.i) + ")");
|
|
1789
|
+
return s ? s + i + ")" : i;
|
|
1790
|
+
}
|
|
1791
|
+
function fa(e, r) {
|
|
1792
|
+
return W(e, r.a[0]) + "(" + f(e, r.a[1]) + ")";
|
|
1793
|
+
}
|
|
1794
|
+
function Sa(e, r) {
|
|
1795
|
+
let t = se(e, r.i, W(e, r.f) + "()"), n2 = r.a.length;
|
|
1796
|
+
if (n2) {
|
|
1797
|
+
let a = f(e, r.a[0]);
|
|
1798
|
+
for (let s = 1; s < n2; s++) a += "," + f(e, r.a[s]);
|
|
1799
|
+
return "(" + t + "," + a + "," + m(e, r.i) + ")";
|
|
1800
|
+
}
|
|
1801
|
+
return t;
|
|
1802
|
+
}
|
|
1803
|
+
function ma(e, r) {
|
|
1804
|
+
return m(e, r.i) + ".next(" + f(e, r.f) + ")";
|
|
1805
|
+
}
|
|
1806
|
+
function pa(e, r) {
|
|
1807
|
+
return m(e, r.i) + ".throw(" + f(e, r.f) + ")";
|
|
1808
|
+
}
|
|
1809
|
+
function da(e, r) {
|
|
1810
|
+
return m(e, r.i) + ".return(" + f(e, r.f) + ")";
|
|
1811
|
+
}
|
|
1812
|
+
function rn(e, r, t, n2) {
|
|
1813
|
+
let a = e.base;
|
|
1814
|
+
return D(a, n2) ? (O(a, r), Vo(e, r, t, m(e, n2.i)), "") : f(e, n2);
|
|
1815
|
+
}
|
|
1816
|
+
function ga(e, r) {
|
|
1817
|
+
let t = r.a, n2 = t.length, a = r.i;
|
|
1818
|
+
if (n2 > 0) {
|
|
1819
|
+
e.base.stack.push(a);
|
|
1820
|
+
let s = rn(e, a, 0, t[0]);
|
|
1821
|
+
for (let i = 1, u = s; i < n2; i++) u = rn(e, a, i, t[i]), s += (u && s && ",") + u;
|
|
1822
|
+
if (e.base.stack.pop(), s) return "{__SEROVAL_SEQUENCE__:!0,v:[" + s + "],t:" + r.s + ",d:" + r.l + "}";
|
|
1823
|
+
}
|
|
1824
|
+
return "{__SEROVAL_SEQUENCE__:!0,v:[],t:-1,d:0}";
|
|
1825
|
+
}
|
|
1826
|
+
function ya(e, r) {
|
|
1827
|
+
switch (r.t) {
|
|
1828
|
+
case 17:
|
|
1829
|
+
return rt[r.s];
|
|
1830
|
+
case 18:
|
|
1831
|
+
return Mo(r);
|
|
1832
|
+
case 9:
|
|
1833
|
+
return Lo(e, r);
|
|
1834
|
+
case 10:
|
|
1835
|
+
return Uo(e, r);
|
|
1836
|
+
case 11:
|
|
1837
|
+
return Go(e, r);
|
|
1838
|
+
case 5:
|
|
1839
|
+
return Ko(r);
|
|
1840
|
+
case 6:
|
|
1841
|
+
return Ho(e, r);
|
|
1842
|
+
case 7:
|
|
1843
|
+
return Jo(e, r);
|
|
1844
|
+
case 8:
|
|
1845
|
+
return Zo(e, r);
|
|
1846
|
+
case 19:
|
|
1847
|
+
return $o(e, r);
|
|
1848
|
+
case 16:
|
|
1849
|
+
case 15:
|
|
1850
|
+
return Xo(e, r);
|
|
1851
|
+
case 20:
|
|
1852
|
+
return Qo(e, r);
|
|
1853
|
+
case 14:
|
|
1854
|
+
return ea(e, r);
|
|
1855
|
+
case 13:
|
|
1856
|
+
return ra(e, r);
|
|
1857
|
+
case 12:
|
|
1858
|
+
return ta(e, r);
|
|
1859
|
+
case 21:
|
|
1860
|
+
return na(e, r);
|
|
1861
|
+
case 22:
|
|
1862
|
+
return oa(e, r);
|
|
1863
|
+
case 25:
|
|
1864
|
+
return ia(e, r);
|
|
1865
|
+
case 26:
|
|
1866
|
+
return Ot[r.s];
|
|
1867
|
+
case 35:
|
|
1868
|
+
return ga(e, r);
|
|
1869
|
+
default:
|
|
1870
|
+
throw new w$1(r);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
function f(e, r) {
|
|
1874
|
+
switch (r.t) {
|
|
1875
|
+
case 2:
|
|
1876
|
+
return nt[r.s];
|
|
1877
|
+
case 0:
|
|
1878
|
+
return "" + r.s;
|
|
1879
|
+
case 1:
|
|
1880
|
+
return '"' + r.s + '"';
|
|
1881
|
+
case 3:
|
|
1882
|
+
return r.s + "n";
|
|
1883
|
+
case 4:
|
|
1884
|
+
return m(e, r.i);
|
|
1885
|
+
case 23:
|
|
1886
|
+
return aa(e, r);
|
|
1887
|
+
case 24:
|
|
1888
|
+
return sa(e, r);
|
|
1889
|
+
case 27:
|
|
1890
|
+
return ua(e, r);
|
|
1891
|
+
case 28:
|
|
1892
|
+
return la(e, r);
|
|
1893
|
+
case 29:
|
|
1894
|
+
return ca(e, r);
|
|
1895
|
+
case 30:
|
|
1896
|
+
return fa(e, r);
|
|
1897
|
+
case 31:
|
|
1898
|
+
return Sa(e, r);
|
|
1899
|
+
case 32:
|
|
1900
|
+
return ma(e, r);
|
|
1901
|
+
case 33:
|
|
1902
|
+
return pa(e, r);
|
|
1903
|
+
case 34:
|
|
1904
|
+
return da(e, r);
|
|
1905
|
+
default:
|
|
1906
|
+
return se(e, r.i, ya(e, r));
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
function cr(e, r) {
|
|
1910
|
+
let t = f(e, r), n2 = r.i;
|
|
1911
|
+
if (n2 == null) return t;
|
|
1912
|
+
let a = on(e.base), s = m(e, n2), i = e.state.scopeId, u = i == null ? "" : ce, l = a ? "(" + t + "," + a + s + ")" : t;
|
|
1913
|
+
if (u === "") return r.t === 10 && !a ? "(" + l + ")" : l;
|
|
1914
|
+
let g = i == null ? "()" : "(" + ce + '["' + y(i) + '"])';
|
|
1915
|
+
return "(" + sr([u], l) + ")" + g;
|
|
1916
|
+
}
|
|
1917
|
+
var Gr = class {
|
|
1918
|
+
constructor(r, t) {
|
|
1919
|
+
this._p = r;
|
|
1920
|
+
this.depth = t;
|
|
1921
|
+
}
|
|
1922
|
+
parse(r) {
|
|
1923
|
+
return E(this._p, this.depth, r);
|
|
1924
|
+
}
|
|
1925
|
+
}, Kr = class {
|
|
1926
|
+
constructor(r, t) {
|
|
1927
|
+
this._p = r;
|
|
1928
|
+
this.depth = t;
|
|
1929
|
+
}
|
|
1930
|
+
parse(r) {
|
|
1931
|
+
return E(this._p, this.depth, r);
|
|
1932
|
+
}
|
|
1933
|
+
parseWithError(r) {
|
|
1934
|
+
return G(this._p, this.depth, r);
|
|
1935
|
+
}
|
|
1936
|
+
isAlive() {
|
|
1937
|
+
return this._p.state.alive;
|
|
1938
|
+
}
|
|
1939
|
+
pushPendingState() {
|
|
1940
|
+
Xr(this._p);
|
|
1941
|
+
}
|
|
1942
|
+
popPendingState() {
|
|
1943
|
+
be(this._p);
|
|
1944
|
+
}
|
|
1945
|
+
onParse(r) {
|
|
1946
|
+
ie(this._p, r);
|
|
1947
|
+
}
|
|
1948
|
+
onError(r) {
|
|
1949
|
+
Zr(this._p, r);
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
function Na(e) {
|
|
1953
|
+
return { alive: true, pending: 0, initial: true, buffer: [], onParse: e.onParse, onError: e.onError, onDone: e.onDone };
|
|
1954
|
+
}
|
|
1955
|
+
function Hr(e) {
|
|
1956
|
+
return { type: 2, base: pe(2, e), state: Na(e) };
|
|
1957
|
+
}
|
|
1958
|
+
function ba(e, r, t) {
|
|
1959
|
+
let n2 = [];
|
|
1960
|
+
for (let a = 0, s = t.length; a < s; a++) a in t ? n2[a] = E(e, r, t[a]) : n2[a] = 0;
|
|
1961
|
+
return n2;
|
|
1962
|
+
}
|
|
1963
|
+
function va(e, r, t, n2) {
|
|
1964
|
+
return _e(t, n2, ba(e, r, n2));
|
|
1965
|
+
}
|
|
1966
|
+
function Jr(e, r, t) {
|
|
1967
|
+
let n2 = Object.entries(t), a = [], s = [];
|
|
1968
|
+
for (let i = 0, u = n2.length; i < u; i++) a.push(y(n2[i][0])), s.push(E(e, r, n2[i][1]));
|
|
1969
|
+
return C in t && (a.push(I(e.base, C)), s.push(Ue(er(e.base), E(e, r, $e(t))))), v in t && (a.push(I(e.base, v)), s.push(je(rr(e.base), E(e, r, e.type === 1 ? te() : Xe(t))))), P$1 in t && (a.push(I(e.base, P$1)), s.push(X(t[P$1]))), R in t && (a.push(I(e.base, R)), s.push(t[R] ? J : Z)), { k: a, v: s };
|
|
1970
|
+
}
|
|
1971
|
+
function Wr(e, r, t, n2, a) {
|
|
1972
|
+
return tr(t, n2, a, Jr(e, r, n2));
|
|
1973
|
+
}
|
|
1974
|
+
function Ca(e, r, t, n2) {
|
|
1975
|
+
return ke(t, E(e, r, n2.valueOf()));
|
|
1976
|
+
}
|
|
1977
|
+
function Aa(e, r, t, n2) {
|
|
1978
|
+
return De(t, n2, E(e, r, n2.buffer));
|
|
1979
|
+
}
|
|
1980
|
+
function Ea(e, r, t, n2) {
|
|
1981
|
+
return Fe(t, n2, E(e, r, n2.buffer));
|
|
1982
|
+
}
|
|
1983
|
+
function Ia(e, r, t, n2) {
|
|
1984
|
+
return Be(t, n2, E(e, r, n2.buffer));
|
|
1985
|
+
}
|
|
1986
|
+
function sn(e, r, t, n2) {
|
|
1987
|
+
let a = $(n2, e.base.features);
|
|
1988
|
+
return Ve(t, n2, a ? Jr(e, r, a) : o);
|
|
1989
|
+
}
|
|
1990
|
+
function Ra(e, r, t, n2) {
|
|
1991
|
+
let a = $(n2, e.base.features);
|
|
1992
|
+
return Me(t, n2, a ? Jr(e, r, a) : o);
|
|
1993
|
+
}
|
|
1994
|
+
function Pa(e, r, t, n2) {
|
|
1995
|
+
let a = [], s = [];
|
|
1996
|
+
for (let [i, u] of n2.entries()) a.push(E(e, r, i)), s.push(E(e, r, u));
|
|
1997
|
+
return nr(e.base, t, a, s);
|
|
1998
|
+
}
|
|
1999
|
+
function xa(e, r, t, n2) {
|
|
2000
|
+
let a = [];
|
|
2001
|
+
for (let s of n2.keys()) a.push(E(e, r, s));
|
|
2002
|
+
return Le(t, a);
|
|
2003
|
+
}
|
|
2004
|
+
function Oa(e, r, t, n2) {
|
|
2005
|
+
let a = Ye(t, k(e.base, 4), []);
|
|
2006
|
+
return e.type === 1 || (Xr(e), n2.on({ next: (s) => {
|
|
2007
|
+
if (e.state.alive) {
|
|
2008
|
+
let i = G(e, r, s);
|
|
2009
|
+
i && ie(e, qe(t, i));
|
|
2010
|
+
}
|
|
2011
|
+
}, throw: (s) => {
|
|
2012
|
+
if (e.state.alive) {
|
|
2013
|
+
let i = G(e, r, s);
|
|
2014
|
+
i && ie(e, We(t, i));
|
|
2015
|
+
}
|
|
2016
|
+
be(e);
|
|
2017
|
+
}, return: (s) => {
|
|
2018
|
+
if (e.state.alive) {
|
|
2019
|
+
let i = G(e, r, s);
|
|
2020
|
+
i && ie(e, Ge(t, i));
|
|
2021
|
+
}
|
|
2022
|
+
be(e);
|
|
2023
|
+
} })), a;
|
|
2024
|
+
}
|
|
2025
|
+
function Ta(e, r, t) {
|
|
2026
|
+
if (this.state.alive) {
|
|
2027
|
+
let n2 = G(this, r, t);
|
|
2028
|
+
n2 && ie(this, c(23, e, o, o, o, o, o, [k(this.base, 2), n2], o, o, o, o)), be(this);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
function wa(e, r, t) {
|
|
2032
|
+
if (this.state.alive) {
|
|
2033
|
+
let n2 = G(this, r, t);
|
|
2034
|
+
n2 && ie(this, c(24, e, o, o, o, o, o, [k(this.base, 3), n2], o, o, o, o));
|
|
2035
|
+
}
|
|
2036
|
+
be(this);
|
|
2037
|
+
}
|
|
2038
|
+
function ha(e, r, t, n2) {
|
|
2039
|
+
let a = hr(e.base, {});
|
|
2040
|
+
return e.type === 2 && (Xr(e), n2.then(Ta.bind(e, a, r), wa.bind(e, a, r))), ht(e.base, t, a);
|
|
2041
|
+
}
|
|
2042
|
+
function za(e, r, t, n2, a) {
|
|
2043
|
+
for (let s = 0, i = a.length; s < i; s++) {
|
|
2044
|
+
let u = a[s];
|
|
2045
|
+
if (u.parse.sync && u.test(n2)) return fe(t, u.tag, u.parse.sync(n2, new Gr(e, r), { id: t }));
|
|
2046
|
+
}
|
|
2047
|
+
return o;
|
|
2048
|
+
}
|
|
2049
|
+
function _a(e, r, t, n2, a) {
|
|
2050
|
+
for (let s = 0, i = a.length; s < i; s++) {
|
|
2051
|
+
let u = a[s];
|
|
2052
|
+
if (u.parse.stream && u.test(n2)) return fe(t, u.tag, u.parse.stream(n2, new Kr(e, r), { id: t }));
|
|
2053
|
+
}
|
|
2054
|
+
return o;
|
|
2055
|
+
}
|
|
2056
|
+
function un(e, r, t, n2) {
|
|
2057
|
+
let a = e.base.plugins;
|
|
2058
|
+
return a ? e.type === 1 ? za(e, r, t, n2, a) : _a(e, r, t, n2, a) : o;
|
|
2059
|
+
}
|
|
2060
|
+
function ka(e, r, t, n2) {
|
|
2061
|
+
let a = [];
|
|
2062
|
+
for (let s = 0, i = n2.v.length; s < i; s++) a[s] = E(e, r, n2.v[s]);
|
|
2063
|
+
return Ke(t, a, n2.t, n2.d);
|
|
2064
|
+
}
|
|
2065
|
+
function Da(e, r, t, n2, a) {
|
|
2066
|
+
switch (a) {
|
|
2067
|
+
case Object:
|
|
2068
|
+
return Wr(e, r, t, n2, false);
|
|
2069
|
+
case o:
|
|
2070
|
+
return Wr(e, r, t, n2, true);
|
|
2071
|
+
case Date:
|
|
2072
|
+
return he(t, n2);
|
|
2073
|
+
case Error:
|
|
2074
|
+
case EvalError:
|
|
2075
|
+
case RangeError:
|
|
2076
|
+
case ReferenceError:
|
|
2077
|
+
case SyntaxError:
|
|
2078
|
+
case TypeError:
|
|
2079
|
+
case URIError:
|
|
2080
|
+
return sn(e, r, t, n2);
|
|
2081
|
+
case Number:
|
|
2082
|
+
case Boolean:
|
|
2083
|
+
case String:
|
|
2084
|
+
case BigInt:
|
|
2085
|
+
return Ca(e, r, t, n2);
|
|
2086
|
+
case ArrayBuffer:
|
|
2087
|
+
return or(e.base, t, n2);
|
|
2088
|
+
case Int8Array:
|
|
2089
|
+
case Int16Array:
|
|
2090
|
+
case Int32Array:
|
|
2091
|
+
case Uint8Array:
|
|
2092
|
+
case Uint16Array:
|
|
2093
|
+
case Uint32Array:
|
|
2094
|
+
case Uint8ClampedArray:
|
|
2095
|
+
case Float32Array:
|
|
2096
|
+
case Float64Array:
|
|
2097
|
+
return Aa(e, r, t, n2);
|
|
2098
|
+
case DataView:
|
|
2099
|
+
return Ia(e, r, t, n2);
|
|
2100
|
+
case Map:
|
|
2101
|
+
return Pa(e, r, t, n2);
|
|
2102
|
+
case Set:
|
|
2103
|
+
return xa(e, r, t, n2);
|
|
2104
|
+
}
|
|
2105
|
+
if (a === Promise || n2 instanceof Promise) return ha(e, r, t, n2);
|
|
2106
|
+
let s = e.base.features;
|
|
2107
|
+
if (s & 32 && a === RegExp) return ze(t, n2);
|
|
2108
|
+
if (s & 16) switch (a) {
|
|
2109
|
+
case BigInt64Array:
|
|
2110
|
+
case BigUint64Array:
|
|
2111
|
+
return Ea(e, r, t, n2);
|
|
2112
|
+
}
|
|
2113
|
+
if (s & 1 && typeof AggregateError != "undefined" && (a === AggregateError || n2 instanceof AggregateError)) return Ra(e, r, t, n2);
|
|
2114
|
+
if (n2 instanceof Error) return sn(e, r, t, n2);
|
|
2115
|
+
if (C in n2 || v in n2) return Wr(e, r, t, n2, !!a);
|
|
2116
|
+
throw new x$1(n2);
|
|
2117
|
+
}
|
|
2118
|
+
function Fa(e, r, t, n2) {
|
|
2119
|
+
if (Array.isArray(n2)) return va(e, r, t, n2);
|
|
2120
|
+
if (M(n2)) return Oa(e, r, t, n2);
|
|
2121
|
+
if (Ze(n2)) return ka(e, r, t, n2);
|
|
2122
|
+
let a = n2.constructor;
|
|
2123
|
+
if (a === Y) return E(e, r, n2.replacement);
|
|
2124
|
+
let s = un(e, r, t, n2);
|
|
2125
|
+
return s || Da(e, r, t, n2, a);
|
|
2126
|
+
}
|
|
2127
|
+
function Ba(e, r, t) {
|
|
2128
|
+
let n2 = q(e.base, t);
|
|
2129
|
+
if (n2.type !== 0) return n2.value;
|
|
2130
|
+
let a = un(e, r, n2.value, t);
|
|
2131
|
+
if (a) return a;
|
|
2132
|
+
throw new x$1(t);
|
|
2133
|
+
}
|
|
2134
|
+
function E(e, r, t) {
|
|
2135
|
+
if (r >= e.base.depthLimit) throw new ee$1(e.base.depthLimit);
|
|
2136
|
+
switch (typeof t) {
|
|
2137
|
+
case "boolean":
|
|
2138
|
+
return t ? J : Z;
|
|
2139
|
+
case "undefined":
|
|
2140
|
+
return Ae;
|
|
2141
|
+
case "string":
|
|
2142
|
+
return X(t);
|
|
2143
|
+
case "number":
|
|
2144
|
+
return Te(t);
|
|
2145
|
+
case "bigint":
|
|
2146
|
+
return we(t);
|
|
2147
|
+
case "object": {
|
|
2148
|
+
if (t) {
|
|
2149
|
+
let n2 = q(e.base, t);
|
|
2150
|
+
return n2.type === 0 ? Fa(e, r + 1, n2.value, t) : n2.value;
|
|
2151
|
+
}
|
|
2152
|
+
return Ee;
|
|
2153
|
+
}
|
|
2154
|
+
case "symbol":
|
|
2155
|
+
return I(e.base, t);
|
|
2156
|
+
case "function":
|
|
2157
|
+
return Ba(e, r, t);
|
|
2158
|
+
default:
|
|
2159
|
+
throw new x$1(t);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
function ie(e, r) {
|
|
2163
|
+
e.state.initial ? e.state.buffer.push(r) : $r(e, r, false);
|
|
2164
|
+
}
|
|
2165
|
+
function Zr(e, r) {
|
|
2166
|
+
if (e.state.onError) e.state.onError(r);
|
|
2167
|
+
else throw r instanceof z ? r : new z(r);
|
|
2168
|
+
}
|
|
2169
|
+
function ln(e) {
|
|
2170
|
+
e.state.onDone && e.state.onDone();
|
|
2171
|
+
}
|
|
2172
|
+
function $r(e, r, t) {
|
|
2173
|
+
try {
|
|
2174
|
+
e.state.onParse(r, t);
|
|
2175
|
+
} catch (n2) {
|
|
2176
|
+
Zr(e, n2);
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
function Xr(e) {
|
|
2180
|
+
e.state.pending++;
|
|
2181
|
+
}
|
|
2182
|
+
function be(e) {
|
|
2183
|
+
--e.state.pending <= 0 && ln(e);
|
|
2184
|
+
}
|
|
2185
|
+
function G(e, r, t) {
|
|
2186
|
+
try {
|
|
2187
|
+
return E(e, r, t);
|
|
2188
|
+
} catch (n2) {
|
|
2189
|
+
return Zr(e, n2), o;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
function Qr(e, r) {
|
|
2193
|
+
let t = G(e, 0, r);
|
|
2194
|
+
t && ($r(e, t, true), e.state.initial = false, Va(e, e.state), e.state.pending <= 0 && fr(e));
|
|
2195
|
+
}
|
|
2196
|
+
function Va(e, r) {
|
|
2197
|
+
for (let t = 0, n2 = r.buffer.length; t < n2; t++) $r(e, r.buffer[t], false);
|
|
2198
|
+
}
|
|
2199
|
+
function fr(e) {
|
|
2200
|
+
e.state.alive && (ln(e), e.state.alive = false);
|
|
2201
|
+
}
|
|
2202
|
+
async function ou(e, r = {}) {
|
|
2203
|
+
let t = A(r.plugins), n2 = ne(2, { plugins: t, disabledFeatures: r.disabledFeatures, refs: r.refs });
|
|
2204
|
+
return await oe(n2, e);
|
|
2205
|
+
}
|
|
2206
|
+
function cn(e, r) {
|
|
2207
|
+
let t = A(r.plugins), n2 = Hr({ plugins: t, refs: r.refs, disabledFeatures: r.disabledFeatures, onParse(a, s) {
|
|
2208
|
+
let i = ur({ plugins: t, features: n2.base.features, scopeId: r.scopeId, markedRefs: n2.base.marked }), u;
|
|
2209
|
+
try {
|
|
2210
|
+
u = cr(i, a);
|
|
2211
|
+
} catch (l) {
|
|
2212
|
+
r.onError && r.onError(l);
|
|
2213
|
+
return;
|
|
2214
|
+
}
|
|
2215
|
+
r.onSerialize(u, s);
|
|
2216
|
+
}, onError: r.onError, onDone: r.onDone });
|
|
2217
|
+
return Qr(n2, e), fr.bind(null, n2);
|
|
2218
|
+
}
|
|
2219
|
+
function au(e, r) {
|
|
2220
|
+
let t = A(r.plugins), n2 = Hr({ plugins: t, refs: r.refs, disabledFeatures: r.disabledFeatures, onParse: r.onParse, onError: r.onError, onDone: r.onDone });
|
|
2221
|
+
return Qr(n2, e), fr.bind(null, n2);
|
|
2222
|
+
}
|
|
2223
|
+
function Iu(e, r = {}) {
|
|
2224
|
+
var i;
|
|
2225
|
+
let t = A(r.plugins), n2 = r.disabledFeatures || 0, a = (i = e.f) != null ? i : 63, s = Mt({ plugins: t, markedRefs: e.m, features: a & ~n2, disabledFeatures: n2 });
|
|
2226
|
+
return ar(s, e.t);
|
|
2227
|
+
}
|
|
2228
|
+
const GLOBAL_TSR = "$_TSR";
|
|
2229
|
+
const TSR_SCRIPT_BARRIER_ID = "$tsr-stream-barrier";
|
|
2230
|
+
function createSerializationAdapter(opts) {
|
|
2231
|
+
return opts;
|
|
2232
|
+
}
|
|
2233
|
+
function makeSsrSerovalPlugin(serializationAdapter, options) {
|
|
2234
|
+
return ni({
|
|
2235
|
+
tag: "$TSR/t/" + serializationAdapter.key,
|
|
2236
|
+
test: serializationAdapter.test,
|
|
2237
|
+
parse: {
|
|
2238
|
+
stream(value, ctx) {
|
|
2239
|
+
return ctx.parse(serializationAdapter.toSerializable(value));
|
|
2240
|
+
}
|
|
2241
|
+
},
|
|
2242
|
+
serialize(node, ctx) {
|
|
2243
|
+
options.didRun = true;
|
|
2244
|
+
return GLOBAL_TSR + '.t.get("' + serializationAdapter.key + '")(' + ctx.serialize(node) + ")";
|
|
2245
|
+
},
|
|
2246
|
+
// we never deserialize on the server during SSR
|
|
2247
|
+
deserialize: void 0
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
function makeSerovalPlugin(serializationAdapter) {
|
|
2251
|
+
return ni({
|
|
2252
|
+
tag: "$TSR/t/" + serializationAdapter.key,
|
|
2253
|
+
test: serializationAdapter.test,
|
|
2254
|
+
parse: {
|
|
2255
|
+
sync(value, ctx) {
|
|
2256
|
+
return ctx.parse(serializationAdapter.toSerializable(value));
|
|
2257
|
+
},
|
|
2258
|
+
async async(value, ctx) {
|
|
2259
|
+
return await ctx.parse(serializationAdapter.toSerializable(value));
|
|
2260
|
+
},
|
|
2261
|
+
stream(value, ctx) {
|
|
2262
|
+
return ctx.parse(serializationAdapter.toSerializable(value));
|
|
2263
|
+
}
|
|
2264
|
+
},
|
|
2265
|
+
// we don't generate JS code outside of SSR (for now)
|
|
2266
|
+
serialize: void 0,
|
|
2267
|
+
deserialize(node, ctx) {
|
|
2268
|
+
return serializationAdapter.fromSerializable(ctx.deserialize(node));
|
|
2269
|
+
}
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
var n = {}, P = (e) => new ReadableStream({ start: (r) => {
|
|
2273
|
+
e.on({ next: (a) => {
|
|
2274
|
+
try {
|
|
2275
|
+
r.enqueue(a);
|
|
2276
|
+
} catch (t) {
|
|
2277
|
+
}
|
|
2278
|
+
}, throw: (a) => {
|
|
2279
|
+
r.error(a);
|
|
2280
|
+
}, return: () => {
|
|
2281
|
+
try {
|
|
2282
|
+
r.close();
|
|
2283
|
+
} catch (a) {
|
|
2284
|
+
}
|
|
2285
|
+
} });
|
|
2286
|
+
} }), x2 = ni({ tag: "seroval-plugins/web/ReadableStreamFactory", test(e) {
|
|
2287
|
+
return e === n;
|
|
2288
|
+
}, parse: { sync() {
|
|
2289
|
+
return n;
|
|
2290
|
+
}, async async() {
|
|
2291
|
+
return await Promise.resolve(n);
|
|
2292
|
+
}, stream() {
|
|
2293
|
+
return n;
|
|
2294
|
+
} }, serialize() {
|
|
2295
|
+
return P.toString();
|
|
2296
|
+
}, deserialize() {
|
|
2297
|
+
return n;
|
|
2298
|
+
} });
|
|
2299
|
+
function w2(e) {
|
|
2300
|
+
let r = te(), a = e.getReader();
|
|
2301
|
+
async function t() {
|
|
2302
|
+
try {
|
|
2303
|
+
let s = await a.read();
|
|
2304
|
+
s.done ? r.return(s.value) : (r.next(s.value), await t());
|
|
2305
|
+
} catch (s) {
|
|
2306
|
+
r.throw(s);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
return t().catch(() => {
|
|
2310
|
+
}), r;
|
|
2311
|
+
}
|
|
2312
|
+
var ee2 = ni({ tag: "seroval/plugins/web/ReadableStream", extends: [x2], test(e) {
|
|
2313
|
+
return typeof ReadableStream == "undefined" ? false : e instanceof ReadableStream;
|
|
2314
|
+
}, parse: { sync(e, r) {
|
|
2315
|
+
return { factory: r.parse(n), stream: r.parse(te()) };
|
|
2316
|
+
}, async async(e, r) {
|
|
2317
|
+
return { factory: await r.parse(n), stream: await r.parse(w2(e)) };
|
|
2318
|
+
}, stream(e, r) {
|
|
2319
|
+
return { factory: r.parse(n), stream: r.parse(w2(e)) };
|
|
2320
|
+
} }, serialize(e, r) {
|
|
2321
|
+
return "(" + r.serialize(e.factory) + ")(" + r.serialize(e.stream) + ")";
|
|
2322
|
+
}, deserialize(e, r) {
|
|
2323
|
+
let a = r.deserialize(e.stream);
|
|
2324
|
+
return P(a);
|
|
2325
|
+
} }), p = ee2;
|
|
2326
|
+
const ShallowErrorPlugin = /* @__PURE__ */ ni({
|
|
2327
|
+
tag: "$TSR/Error",
|
|
2328
|
+
test(value) {
|
|
2329
|
+
return value instanceof Error;
|
|
2330
|
+
},
|
|
2331
|
+
parse: {
|
|
2332
|
+
sync(value, ctx) {
|
|
2333
|
+
return {
|
|
2334
|
+
message: ctx.parse(value.message)
|
|
2335
|
+
};
|
|
2336
|
+
},
|
|
2337
|
+
async async(value, ctx) {
|
|
2338
|
+
return {
|
|
2339
|
+
message: await ctx.parse(value.message)
|
|
2340
|
+
};
|
|
2341
|
+
},
|
|
2342
|
+
stream(value, ctx) {
|
|
2343
|
+
return {
|
|
2344
|
+
message: ctx.parse(value.message)
|
|
2345
|
+
};
|
|
2346
|
+
}
|
|
2347
|
+
},
|
|
2348
|
+
serialize(node, ctx) {
|
|
2349
|
+
return "new Error(" + ctx.serialize(node.message) + ")";
|
|
2350
|
+
},
|
|
2351
|
+
deserialize(node, ctx) {
|
|
2352
|
+
return new Error(ctx.deserialize(node.message));
|
|
2353
|
+
}
|
|
2354
|
+
});
|
|
2355
|
+
class RawStream {
|
|
2356
|
+
constructor(stream, options) {
|
|
2357
|
+
this.stream = stream;
|
|
2358
|
+
this.hint = options?.hint ?? "binary";
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
const BufferCtor = globalThis.Buffer;
|
|
2362
|
+
const hasNodeBuffer = !!BufferCtor && typeof BufferCtor.from === "function";
|
|
2363
|
+
function uint8ArrayToBase64(bytes) {
|
|
2364
|
+
if (bytes.length === 0) return "";
|
|
2365
|
+
if (hasNodeBuffer) {
|
|
2366
|
+
return BufferCtor.from(bytes).toString("base64");
|
|
2367
|
+
}
|
|
2368
|
+
const CHUNK_SIZE = 32768;
|
|
2369
|
+
const chunks = [];
|
|
2370
|
+
for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
2371
|
+
const chunk = bytes.subarray(i, i + CHUNK_SIZE);
|
|
2372
|
+
chunks.push(String.fromCharCode.apply(null, chunk));
|
|
2373
|
+
}
|
|
2374
|
+
return btoa(chunks.join(""));
|
|
2375
|
+
}
|
|
2376
|
+
function base64ToUint8Array(base64) {
|
|
2377
|
+
if (base64.length === 0) return new Uint8Array(0);
|
|
2378
|
+
if (hasNodeBuffer) {
|
|
2379
|
+
const buf = BufferCtor.from(base64, "base64");
|
|
2380
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
2381
|
+
}
|
|
2382
|
+
const binary = atob(base64);
|
|
2383
|
+
const bytes = new Uint8Array(binary.length);
|
|
2384
|
+
for (let i = 0; i < binary.length; i++) {
|
|
2385
|
+
bytes[i] = binary.charCodeAt(i);
|
|
2386
|
+
}
|
|
2387
|
+
return bytes;
|
|
2388
|
+
}
|
|
2389
|
+
const RAW_STREAM_FACTORY_BINARY = /* @__PURE__ */ Object.create(null);
|
|
2390
|
+
const RAW_STREAM_FACTORY_TEXT = /* @__PURE__ */ Object.create(null);
|
|
2391
|
+
const RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY = (stream) => new ReadableStream({
|
|
2392
|
+
start(controller) {
|
|
2393
|
+
stream.on({
|
|
2394
|
+
next(base64) {
|
|
2395
|
+
try {
|
|
2396
|
+
controller.enqueue(base64ToUint8Array(base64));
|
|
2397
|
+
} catch {
|
|
2398
|
+
}
|
|
2399
|
+
},
|
|
2400
|
+
throw(error) {
|
|
2401
|
+
controller.error(error);
|
|
2402
|
+
},
|
|
2403
|
+
return() {
|
|
2404
|
+
try {
|
|
2405
|
+
controller.close();
|
|
2406
|
+
} catch {
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
const textEncoderForFactory = new TextEncoder();
|
|
2413
|
+
const RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT = (stream) => {
|
|
2414
|
+
return new ReadableStream({
|
|
2415
|
+
start(controller) {
|
|
2416
|
+
stream.on({
|
|
2417
|
+
next(value) {
|
|
2418
|
+
try {
|
|
2419
|
+
if (typeof value === "string") {
|
|
2420
|
+
controller.enqueue(textEncoderForFactory.encode(value));
|
|
2421
|
+
} else {
|
|
2422
|
+
controller.enqueue(base64ToUint8Array(value.$b64));
|
|
2423
|
+
}
|
|
2424
|
+
} catch {
|
|
2425
|
+
}
|
|
2426
|
+
},
|
|
2427
|
+
throw(error) {
|
|
2428
|
+
controller.error(error);
|
|
2429
|
+
},
|
|
2430
|
+
return() {
|
|
2431
|
+
try {
|
|
2432
|
+
controller.close();
|
|
2433
|
+
} catch {
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
});
|
|
2439
|
+
};
|
|
2440
|
+
const 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(_){}}})}}))`;
|
|
2441
|
+
const 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(_){}}})}})})`;
|
|
2442
|
+
function toBinaryStream(readable) {
|
|
2443
|
+
const stream = te();
|
|
2444
|
+
const reader = readable.getReader();
|
|
2445
|
+
(async () => {
|
|
2446
|
+
try {
|
|
2447
|
+
while (true) {
|
|
2448
|
+
const { done, value } = await reader.read();
|
|
2449
|
+
if (done) {
|
|
2450
|
+
stream.return(void 0);
|
|
2451
|
+
break;
|
|
2452
|
+
}
|
|
2453
|
+
stream.next(uint8ArrayToBase64(value));
|
|
2454
|
+
}
|
|
2455
|
+
} catch (error) {
|
|
2456
|
+
stream.throw(error);
|
|
2457
|
+
} finally {
|
|
2458
|
+
reader.releaseLock();
|
|
2459
|
+
}
|
|
2460
|
+
})();
|
|
2461
|
+
return stream;
|
|
2462
|
+
}
|
|
2463
|
+
function toTextStream(readable) {
|
|
2464
|
+
const stream = te();
|
|
2465
|
+
const reader = readable.getReader();
|
|
2466
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
2467
|
+
(async () => {
|
|
2468
|
+
try {
|
|
2469
|
+
while (true) {
|
|
2470
|
+
const { done, value } = await reader.read();
|
|
2471
|
+
if (done) {
|
|
2472
|
+
try {
|
|
2473
|
+
const remaining = decoder.decode();
|
|
2474
|
+
if (remaining.length > 0) {
|
|
2475
|
+
stream.next(remaining);
|
|
2476
|
+
}
|
|
2477
|
+
} catch {
|
|
2478
|
+
}
|
|
2479
|
+
stream.return(void 0);
|
|
2480
|
+
break;
|
|
2481
|
+
}
|
|
2482
|
+
try {
|
|
2483
|
+
const text = decoder.decode(value, { stream: true });
|
|
2484
|
+
if (text.length > 0) {
|
|
2485
|
+
stream.next(text);
|
|
2486
|
+
}
|
|
2487
|
+
} catch {
|
|
2488
|
+
stream.next({ $b64: uint8ArrayToBase64(value) });
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
} catch (error) {
|
|
2492
|
+
stream.throw(error);
|
|
2493
|
+
} finally {
|
|
2494
|
+
reader.releaseLock();
|
|
2495
|
+
}
|
|
2496
|
+
})();
|
|
2497
|
+
return stream;
|
|
2498
|
+
}
|
|
2499
|
+
const RawStreamFactoryBinaryPlugin = ni({
|
|
2500
|
+
tag: "tss/RawStreamFactory",
|
|
2501
|
+
test(value) {
|
|
2502
|
+
return value === RAW_STREAM_FACTORY_BINARY;
|
|
2503
|
+
},
|
|
2504
|
+
parse: {
|
|
2505
|
+
sync() {
|
|
2506
|
+
return void 0;
|
|
2507
|
+
},
|
|
2508
|
+
async() {
|
|
2509
|
+
return Promise.resolve(void 0);
|
|
2510
|
+
},
|
|
2511
|
+
stream() {
|
|
2512
|
+
return void 0;
|
|
2513
|
+
}
|
|
2514
|
+
},
|
|
2515
|
+
serialize() {
|
|
2516
|
+
return FACTORY_BINARY;
|
|
2517
|
+
},
|
|
2518
|
+
deserialize() {
|
|
2519
|
+
return RAW_STREAM_FACTORY_BINARY;
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
const RawStreamFactoryTextPlugin = ni({
|
|
2523
|
+
tag: "tss/RawStreamFactoryText",
|
|
2524
|
+
test(value) {
|
|
2525
|
+
return value === RAW_STREAM_FACTORY_TEXT;
|
|
2526
|
+
},
|
|
2527
|
+
parse: {
|
|
2528
|
+
sync() {
|
|
2529
|
+
return void 0;
|
|
2530
|
+
},
|
|
2531
|
+
async() {
|
|
2532
|
+
return Promise.resolve(void 0);
|
|
2533
|
+
},
|
|
2534
|
+
stream() {
|
|
2535
|
+
return void 0;
|
|
2536
|
+
}
|
|
2537
|
+
},
|
|
2538
|
+
serialize() {
|
|
2539
|
+
return FACTORY_TEXT;
|
|
2540
|
+
},
|
|
2541
|
+
deserialize() {
|
|
2542
|
+
return RAW_STREAM_FACTORY_TEXT;
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2545
|
+
const RawStreamSSRPlugin = ni({
|
|
2546
|
+
tag: "tss/RawStream",
|
|
2547
|
+
extends: [RawStreamFactoryBinaryPlugin, RawStreamFactoryTextPlugin],
|
|
2548
|
+
test(value) {
|
|
2549
|
+
return value instanceof RawStream;
|
|
2550
|
+
},
|
|
2551
|
+
parse: {
|
|
2552
|
+
sync(value, ctx) {
|
|
2553
|
+
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
2554
|
+
return {
|
|
2555
|
+
hint: value.hint,
|
|
2556
|
+
factory: ctx.parse(factory),
|
|
2557
|
+
stream: ctx.parse(te())
|
|
2558
|
+
};
|
|
2559
|
+
},
|
|
2560
|
+
async async(value, ctx) {
|
|
2561
|
+
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
2562
|
+
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
2563
|
+
return {
|
|
2564
|
+
hint: value.hint,
|
|
2565
|
+
factory: await ctx.parse(factory),
|
|
2566
|
+
stream: await ctx.parse(encodedStream)
|
|
2567
|
+
};
|
|
2568
|
+
},
|
|
2569
|
+
stream(value, ctx) {
|
|
2570
|
+
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
2571
|
+
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
2572
|
+
return {
|
|
2573
|
+
hint: value.hint,
|
|
2574
|
+
factory: ctx.parse(factory),
|
|
2575
|
+
stream: ctx.parse(encodedStream)
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2578
|
+
},
|
|
2579
|
+
serialize(node, ctx) {
|
|
2580
|
+
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
|
|
2581
|
+
},
|
|
2582
|
+
deserialize(node, ctx) {
|
|
2583
|
+
const stream = ctx.deserialize(node.stream);
|
|
2584
|
+
return node.hint === "text" ? RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT(stream) : RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY(stream);
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
function createRawStreamRPCPlugin(onRawStream) {
|
|
2588
|
+
let nextStreamId = 1;
|
|
2589
|
+
return ni({
|
|
2590
|
+
tag: "tss/RawStream",
|
|
2591
|
+
test(value) {
|
|
2592
|
+
return value instanceof RawStream;
|
|
2593
|
+
},
|
|
2594
|
+
parse: {
|
|
2595
|
+
async(value) {
|
|
2596
|
+
const streamId = nextStreamId++;
|
|
2597
|
+
onRawStream(streamId, value.stream);
|
|
2598
|
+
return Promise.resolve({ streamId });
|
|
2599
|
+
},
|
|
2600
|
+
stream(value) {
|
|
2601
|
+
const streamId = nextStreamId++;
|
|
2602
|
+
onRawStream(streamId, value.stream);
|
|
2603
|
+
return { streamId };
|
|
2604
|
+
}
|
|
2605
|
+
},
|
|
2606
|
+
serialize() {
|
|
2607
|
+
throw new Error(
|
|
2608
|
+
"RawStreamRPCPlugin.serialize should not be called. RPC uses JSON serialization, not JS code generation."
|
|
2609
|
+
);
|
|
2610
|
+
},
|
|
2611
|
+
deserialize() {
|
|
2612
|
+
throw new Error(
|
|
2613
|
+
"RawStreamRPCPlugin.deserialize should not be called. Use createRawStreamDeserializePlugin on client."
|
|
2614
|
+
);
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
const defaultSerovalPlugins = [
|
|
2619
|
+
ShallowErrorPlugin,
|
|
2620
|
+
// RawStreamSSRPlugin must come before ReadableStreamPlugin to match first
|
|
2621
|
+
RawStreamSSRPlugin,
|
|
2622
|
+
// ReadableStreamNode is not exported by seroval
|
|
2623
|
+
p
|
|
2624
|
+
];
|
|
2625
|
+
const TSS_FORMDATA_CONTEXT = "__TSS_CONTEXT";
|
|
2626
|
+
const TSS_SERVER_FUNCTION = /* @__PURE__ */ Symbol.for("TSS_SERVER_FUNCTION");
|
|
2627
|
+
const TSS_SERVER_FUNCTION_FACTORY = /* @__PURE__ */ Symbol.for(
|
|
2628
|
+
"TSS_SERVER_FUNCTION_FACTORY"
|
|
2629
|
+
);
|
|
2630
|
+
const X_TSS_SERIALIZED = "x-tss-serialized";
|
|
2631
|
+
const X_TSS_RAW_RESPONSE = "x-tss-raw";
|
|
2632
|
+
const TSS_CONTENT_TYPE_FRAMED = "application/x-tss-framed";
|
|
2633
|
+
const FrameType = {
|
|
2634
|
+
/** Seroval JSON chunk (NDJSON line) */
|
|
2635
|
+
JSON: 0,
|
|
2636
|
+
/** Raw stream data chunk */
|
|
2637
|
+
CHUNK: 1,
|
|
2638
|
+
/** Raw stream end (EOF) */
|
|
2639
|
+
END: 2,
|
|
2640
|
+
/** Raw stream error */
|
|
2641
|
+
ERROR: 3
|
|
2642
|
+
};
|
|
2643
|
+
const FRAME_HEADER_SIZE = 9;
|
|
2644
|
+
const TSS_FRAMED_PROTOCOL_VERSION = 1;
|
|
2645
|
+
const TSS_CONTENT_TYPE_FRAMED_VERSIONED = `${TSS_CONTENT_TYPE_FRAMED}; v=${TSS_FRAMED_PROTOCOL_VERSION}`;
|
|
2646
|
+
const GLOBAL_STORAGE_KEY = /* @__PURE__ */ Symbol.for("tanstack-start:start-storage-context");
|
|
2647
|
+
const globalObj$1 = globalThis;
|
|
2648
|
+
if (!globalObj$1[GLOBAL_STORAGE_KEY]) {
|
|
2649
|
+
globalObj$1[GLOBAL_STORAGE_KEY] = new AsyncLocalStorage();
|
|
2650
|
+
}
|
|
2651
|
+
const startStorage = globalObj$1[GLOBAL_STORAGE_KEY];
|
|
2652
|
+
async function runWithStartContext(context, fn2) {
|
|
2653
|
+
return startStorage.run(context, fn2);
|
|
2654
|
+
}
|
|
2655
|
+
function getStartContext(opts) {
|
|
2656
|
+
const context = startStorage.getStore();
|
|
2657
|
+
if (!context && opts?.throwIfNotFound !== false) {
|
|
2658
|
+
throw new Error(
|
|
2659
|
+
`No Start context found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`
|
|
2660
|
+
);
|
|
2661
|
+
}
|
|
2662
|
+
return context;
|
|
2663
|
+
}
|
|
2664
|
+
const getStartOptions = () => getStartContext().startOptions;
|
|
2665
|
+
const getStartContextServerOnly = getStartContext;
|
|
2666
|
+
function isSafeKey(key) {
|
|
2667
|
+
return key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
|
2668
|
+
}
|
|
2669
|
+
function safeObjectMerge(target, source) {
|
|
2670
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
2671
|
+
if (target) {
|
|
2672
|
+
for (const key of Object.keys(target)) {
|
|
2673
|
+
if (isSafeKey(key)) result[key] = target[key];
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
if (source && typeof source === "object") {
|
|
2677
|
+
for (const key of Object.keys(source)) {
|
|
2678
|
+
if (isSafeKey(key)) result[key] = source[key];
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
return result;
|
|
2682
|
+
}
|
|
2683
|
+
function createNullProtoObject(source) {
|
|
2684
|
+
if (!source) return /* @__PURE__ */ Object.create(null);
|
|
2685
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
2686
|
+
for (const key of Object.keys(source)) {
|
|
2687
|
+
if (isSafeKey(key)) obj[key] = source[key];
|
|
2688
|
+
}
|
|
2689
|
+
return obj;
|
|
2690
|
+
}
|
|
2691
|
+
const createServerFn = (options, __opts) => {
|
|
2692
|
+
const resolvedOptions = __opts || options || {};
|
|
2693
|
+
if (typeof resolvedOptions.method === "undefined") {
|
|
2694
|
+
resolvedOptions.method = "GET";
|
|
2695
|
+
}
|
|
2696
|
+
const res = {
|
|
2697
|
+
options: resolvedOptions,
|
|
2698
|
+
middleware: (middleware) => {
|
|
2699
|
+
const newMiddleware = [...resolvedOptions.middleware || []];
|
|
2700
|
+
middleware.map((m2) => {
|
|
2701
|
+
if (TSS_SERVER_FUNCTION_FACTORY in m2) {
|
|
2702
|
+
if (m2.options.middleware) {
|
|
2703
|
+
newMiddleware.push(...m2.options.middleware);
|
|
2704
|
+
}
|
|
2705
|
+
} else {
|
|
2706
|
+
newMiddleware.push(m2);
|
|
2707
|
+
}
|
|
2708
|
+
});
|
|
2709
|
+
const newOptions = {
|
|
2710
|
+
...resolvedOptions,
|
|
2711
|
+
middleware: newMiddleware
|
|
2712
|
+
};
|
|
2713
|
+
const res2 = createServerFn(void 0, newOptions);
|
|
2714
|
+
res2[TSS_SERVER_FUNCTION_FACTORY] = true;
|
|
2715
|
+
return res2;
|
|
2716
|
+
},
|
|
2717
|
+
inputValidator: (inputValidator) => {
|
|
2718
|
+
const newOptions = { ...resolvedOptions, inputValidator };
|
|
2719
|
+
return createServerFn(void 0, newOptions);
|
|
2720
|
+
},
|
|
2721
|
+
handler: (...args) => {
|
|
2722
|
+
const [extractedFn, serverFn] = args;
|
|
2723
|
+
const newOptions = { ...resolvedOptions, extractedFn, serverFn };
|
|
2724
|
+
const resolvedMiddleware = [
|
|
2725
|
+
...newOptions.middleware || [],
|
|
2726
|
+
serverFnBaseToMiddleware(newOptions)
|
|
2727
|
+
];
|
|
2728
|
+
return Object.assign(
|
|
2729
|
+
async (opts) => {
|
|
2730
|
+
const result = await executeMiddleware$1(resolvedMiddleware, "client", {
|
|
2731
|
+
...extractedFn,
|
|
2732
|
+
...newOptions,
|
|
2733
|
+
data: opts?.data,
|
|
2734
|
+
headers: opts?.headers,
|
|
2735
|
+
signal: opts?.signal,
|
|
2736
|
+
fetch: opts?.fetch,
|
|
2737
|
+
context: createNullProtoObject()
|
|
2738
|
+
});
|
|
2739
|
+
const redirect2 = parseRedirect(result.error);
|
|
2740
|
+
if (redirect2) {
|
|
2741
|
+
throw redirect2;
|
|
2742
|
+
}
|
|
2743
|
+
if (result.error) throw result.error;
|
|
2744
|
+
return result.result;
|
|
2745
|
+
},
|
|
2746
|
+
{
|
|
2747
|
+
// This copies over the URL, function ID
|
|
2748
|
+
...extractedFn,
|
|
2749
|
+
// The extracted function on the server-side calls
|
|
2750
|
+
// this function
|
|
2751
|
+
__executeServer: async (opts) => {
|
|
2752
|
+
const startContext = getStartContextServerOnly();
|
|
2753
|
+
const serverContextAfterGlobalMiddlewares = startContext.contextAfterGlobalMiddlewares;
|
|
2754
|
+
const ctx = {
|
|
2755
|
+
...extractedFn,
|
|
2756
|
+
...opts,
|
|
2757
|
+
// Ensure we use the full serverFnMeta from the provider file's extractedFn
|
|
2758
|
+
// (which has id, name, filename) rather than the partial one from SSR/client
|
|
2759
|
+
// callers (which only has id)
|
|
2760
|
+
serverFnMeta: extractedFn.serverFnMeta,
|
|
2761
|
+
// Use safeObjectMerge for opts.context which comes from client
|
|
2762
|
+
context: safeObjectMerge(
|
|
2763
|
+
serverContextAfterGlobalMiddlewares,
|
|
2764
|
+
opts.context
|
|
2765
|
+
),
|
|
2766
|
+
request: startContext.request
|
|
2767
|
+
};
|
|
2768
|
+
const result = await executeMiddleware$1(
|
|
2769
|
+
resolvedMiddleware,
|
|
2770
|
+
"server",
|
|
2771
|
+
ctx
|
|
2772
|
+
).then((d) => ({
|
|
2773
|
+
// Only send the result and sendContext back to the client
|
|
2774
|
+
result: d.result,
|
|
2775
|
+
error: d.error,
|
|
2776
|
+
context: d.sendContext
|
|
2777
|
+
}));
|
|
2778
|
+
return result;
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
);
|
|
2782
|
+
}
|
|
2783
|
+
};
|
|
2784
|
+
const fun = (options2) => {
|
|
2785
|
+
const newOptions = {
|
|
2786
|
+
...resolvedOptions,
|
|
2787
|
+
...options2
|
|
2788
|
+
};
|
|
2789
|
+
return createServerFn(void 0, newOptions);
|
|
2790
|
+
};
|
|
2791
|
+
return Object.assign(fun, res);
|
|
2792
|
+
};
|
|
2793
|
+
async function executeMiddleware$1(middlewares, env, opts) {
|
|
2794
|
+
const globalMiddlewares = getStartOptions()?.functionMiddleware || [];
|
|
2795
|
+
let flattenedMiddlewares = flattenMiddlewares([
|
|
2796
|
+
...globalMiddlewares,
|
|
2797
|
+
...middlewares
|
|
2798
|
+
]);
|
|
2799
|
+
if (env === "server") {
|
|
2800
|
+
const startContext = getStartContextServerOnly({ throwIfNotFound: false });
|
|
2801
|
+
if (startContext?.executedRequestMiddlewares) {
|
|
2802
|
+
flattenedMiddlewares = flattenedMiddlewares.filter(
|
|
2803
|
+
(m2) => !startContext.executedRequestMiddlewares.has(m2)
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
const callNextMiddleware = async (ctx) => {
|
|
2808
|
+
const nextMiddleware = flattenedMiddlewares.shift();
|
|
2809
|
+
if (!nextMiddleware) {
|
|
2810
|
+
return ctx;
|
|
2811
|
+
}
|
|
2812
|
+
try {
|
|
2813
|
+
if ("inputValidator" in nextMiddleware.options && nextMiddleware.options.inputValidator && env === "server") {
|
|
2814
|
+
ctx.data = await execValidator(
|
|
2815
|
+
nextMiddleware.options.inputValidator,
|
|
2816
|
+
ctx.data
|
|
2817
|
+
);
|
|
2818
|
+
}
|
|
2819
|
+
let middlewareFn = void 0;
|
|
2820
|
+
if (env === "client") {
|
|
2821
|
+
if ("client" in nextMiddleware.options) {
|
|
2822
|
+
middlewareFn = nextMiddleware.options.client;
|
|
2823
|
+
}
|
|
2824
|
+
} else if ("server" in nextMiddleware.options) {
|
|
2825
|
+
middlewareFn = nextMiddleware.options.server;
|
|
2826
|
+
}
|
|
2827
|
+
if (middlewareFn) {
|
|
2828
|
+
const userNext = async (userCtx = {}) => {
|
|
2829
|
+
const nextCtx = {
|
|
2830
|
+
...ctx,
|
|
2831
|
+
...userCtx,
|
|
2832
|
+
context: safeObjectMerge(ctx.context, userCtx.context),
|
|
2833
|
+
sendContext: safeObjectMerge(ctx.sendContext, userCtx.sendContext),
|
|
2834
|
+
headers: mergeHeaders(ctx.headers, userCtx.headers),
|
|
2835
|
+
_callSiteFetch: ctx._callSiteFetch,
|
|
2836
|
+
fetch: ctx._callSiteFetch ?? userCtx.fetch ?? ctx.fetch,
|
|
2837
|
+
result: userCtx.result !== void 0 ? userCtx.result : userCtx instanceof Response ? userCtx : ctx.result,
|
|
2838
|
+
error: userCtx.error ?? ctx.error
|
|
2839
|
+
};
|
|
2840
|
+
const result2 = await callNextMiddleware(nextCtx);
|
|
2841
|
+
if (result2.error) {
|
|
2842
|
+
throw result2.error;
|
|
2843
|
+
}
|
|
2844
|
+
return result2;
|
|
2845
|
+
};
|
|
2846
|
+
const result = await middlewareFn({
|
|
2847
|
+
...ctx,
|
|
2848
|
+
next: userNext
|
|
2849
|
+
});
|
|
2850
|
+
if (isRedirect(result)) {
|
|
2851
|
+
return {
|
|
2852
|
+
...ctx,
|
|
2853
|
+
error: result
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
if (result instanceof Response) {
|
|
2857
|
+
return {
|
|
2858
|
+
...ctx,
|
|
2859
|
+
result
|
|
2860
|
+
};
|
|
2861
|
+
}
|
|
2862
|
+
if (!result) {
|
|
2863
|
+
throw new Error(
|
|
2864
|
+
"User middleware returned undefined. You must call next() or return a result in your middlewares."
|
|
2865
|
+
);
|
|
2866
|
+
}
|
|
2867
|
+
return result;
|
|
2868
|
+
}
|
|
2869
|
+
return callNextMiddleware(ctx);
|
|
2870
|
+
} catch (error) {
|
|
2871
|
+
return {
|
|
2872
|
+
...ctx,
|
|
2873
|
+
error
|
|
2874
|
+
};
|
|
2875
|
+
}
|
|
2876
|
+
};
|
|
2877
|
+
return callNextMiddleware({
|
|
2878
|
+
...opts,
|
|
2879
|
+
headers: opts.headers || {},
|
|
2880
|
+
sendContext: opts.sendContext || {},
|
|
2881
|
+
context: opts.context || createNullProtoObject(),
|
|
2882
|
+
_callSiteFetch: opts.fetch
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2885
|
+
function flattenMiddlewares(middlewares, maxDepth = 100) {
|
|
2886
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2887
|
+
const flattened = [];
|
|
2888
|
+
const recurse = (middleware, depth) => {
|
|
2889
|
+
if (depth > maxDepth) {
|
|
2890
|
+
throw new Error(
|
|
2891
|
+
`Middleware nesting depth exceeded maximum of ${maxDepth}. Check for circular references.`
|
|
2892
|
+
);
|
|
2893
|
+
}
|
|
2894
|
+
middleware.forEach((m2) => {
|
|
2895
|
+
if (m2.options.middleware) {
|
|
2896
|
+
recurse(m2.options.middleware, depth + 1);
|
|
2897
|
+
}
|
|
2898
|
+
if (!seen.has(m2)) {
|
|
2899
|
+
seen.add(m2);
|
|
2900
|
+
flattened.push(m2);
|
|
2901
|
+
}
|
|
2902
|
+
});
|
|
2903
|
+
};
|
|
2904
|
+
recurse(middlewares, 0);
|
|
2905
|
+
return flattened;
|
|
2906
|
+
}
|
|
2907
|
+
async function execValidator(validator, input) {
|
|
2908
|
+
if (validator == null) return {};
|
|
2909
|
+
if ("~standard" in validator) {
|
|
2910
|
+
const result = await validator["~standard"].validate(input);
|
|
2911
|
+
if (result.issues)
|
|
2912
|
+
throw new Error(JSON.stringify(result.issues, void 0, 2));
|
|
2913
|
+
return result.value;
|
|
2914
|
+
}
|
|
2915
|
+
if ("parse" in validator) {
|
|
2916
|
+
return validator.parse(input);
|
|
2917
|
+
}
|
|
2918
|
+
if (typeof validator === "function") {
|
|
2919
|
+
return validator(input);
|
|
2920
|
+
}
|
|
2921
|
+
throw new Error("Invalid validator type!");
|
|
2922
|
+
}
|
|
2923
|
+
function serverFnBaseToMiddleware(options) {
|
|
2924
|
+
return {
|
|
2925
|
+
"~types": void 0,
|
|
2926
|
+
options: {
|
|
2927
|
+
inputValidator: options.inputValidator,
|
|
2928
|
+
client: async ({ next, sendContext, fetch, ...ctx }) => {
|
|
2929
|
+
const payload = {
|
|
2930
|
+
...ctx,
|
|
2931
|
+
// switch the sendContext over to context
|
|
2932
|
+
context: sendContext,
|
|
2933
|
+
fetch
|
|
2934
|
+
};
|
|
2935
|
+
const res = await options.extractedFn?.(payload);
|
|
2936
|
+
return next(res);
|
|
2937
|
+
},
|
|
2938
|
+
server: async ({ next, ...ctx }) => {
|
|
2939
|
+
const result = await options.serverFn?.(ctx);
|
|
2940
|
+
return next({
|
|
2941
|
+
...ctx,
|
|
2942
|
+
result
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
function getDefaultSerovalPlugins() {
|
|
2949
|
+
const start = getStartOptions();
|
|
2950
|
+
const adapters = start?.serializationAdapters;
|
|
2951
|
+
return [
|
|
2952
|
+
...adapters?.map(makeSerovalPlugin) ?? [],
|
|
2953
|
+
...defaultSerovalPlugins
|
|
2954
|
+
];
|
|
2955
|
+
}
|
|
2956
|
+
const minifiedTsrBootStrapScript = "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:[]};\n";
|
|
2957
|
+
const SCOPE_ID = "tsr";
|
|
2958
|
+
const TSR_PREFIX = GLOBAL_TSR + ".router=";
|
|
2959
|
+
const P_PREFIX = GLOBAL_TSR + ".p(()=>";
|
|
2960
|
+
const P_SUFFIX = ")";
|
|
2961
|
+
function dehydrateMatch(match) {
|
|
2962
|
+
const dehydratedMatch = {
|
|
2963
|
+
i: match.id,
|
|
2964
|
+
u: match.updatedAt,
|
|
2965
|
+
s: match.status
|
|
2966
|
+
};
|
|
2967
|
+
const properties = [
|
|
2968
|
+
["__beforeLoadContext", "b"],
|
|
2969
|
+
["loaderData", "l"],
|
|
2970
|
+
["error", "e"],
|
|
2971
|
+
["ssr", "ssr"]
|
|
2972
|
+
];
|
|
2973
|
+
for (const [key, shorthand] of properties) {
|
|
2974
|
+
if (match[key] !== void 0) {
|
|
2975
|
+
dehydratedMatch[shorthand] = match[key];
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
return dehydratedMatch;
|
|
2979
|
+
}
|
|
2980
|
+
const INITIAL_SCRIPTS = [
|
|
2981
|
+
mn(SCOPE_ID),
|
|
2982
|
+
minifiedTsrBootStrapScript
|
|
2983
|
+
];
|
|
2984
|
+
class ScriptBuffer {
|
|
2985
|
+
constructor(router) {
|
|
2986
|
+
this._scriptBarrierLifted = false;
|
|
2987
|
+
this._cleanedUp = false;
|
|
2988
|
+
this._pendingMicrotask = false;
|
|
2989
|
+
this.router = router;
|
|
2990
|
+
this._queue = INITIAL_SCRIPTS.slice();
|
|
2991
|
+
}
|
|
2992
|
+
enqueue(script) {
|
|
2993
|
+
if (this._cleanedUp) return;
|
|
2994
|
+
this._queue.push(script);
|
|
2995
|
+
if (this._scriptBarrierLifted && !this._pendingMicrotask) {
|
|
2996
|
+
this._pendingMicrotask = true;
|
|
2997
|
+
queueMicrotask(() => {
|
|
2998
|
+
this._pendingMicrotask = false;
|
|
2999
|
+
this.injectBufferedScripts();
|
|
3000
|
+
});
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
liftBarrier() {
|
|
3004
|
+
if (this._scriptBarrierLifted || this._cleanedUp) return;
|
|
3005
|
+
this._scriptBarrierLifted = true;
|
|
3006
|
+
if (this._queue.length > 0 && !this._pendingMicrotask) {
|
|
3007
|
+
this._pendingMicrotask = true;
|
|
3008
|
+
queueMicrotask(() => {
|
|
3009
|
+
this._pendingMicrotask = false;
|
|
3010
|
+
this.injectBufferedScripts();
|
|
3011
|
+
});
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
/**
|
|
3015
|
+
* Flushes any pending scripts synchronously.
|
|
3016
|
+
* Call this before emitting onSerializationFinished to ensure all scripts are injected.
|
|
3017
|
+
*
|
|
3018
|
+
* IMPORTANT: Only injects if the barrier has been lifted. Before the barrier is lifted,
|
|
3019
|
+
* scripts should remain in the queue so takeBufferedScripts() can retrieve them
|
|
3020
|
+
*/
|
|
3021
|
+
flush() {
|
|
3022
|
+
if (!this._scriptBarrierLifted) return;
|
|
3023
|
+
if (this._cleanedUp) return;
|
|
3024
|
+
this._pendingMicrotask = false;
|
|
3025
|
+
const scriptsToInject = this.takeAll();
|
|
3026
|
+
if (scriptsToInject && this.router?.serverSsr) {
|
|
3027
|
+
this.router.serverSsr.injectScript(scriptsToInject);
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
takeAll() {
|
|
3031
|
+
const bufferedScripts = this._queue;
|
|
3032
|
+
this._queue = [];
|
|
3033
|
+
if (bufferedScripts.length === 0) {
|
|
3034
|
+
return void 0;
|
|
3035
|
+
}
|
|
3036
|
+
if (bufferedScripts.length === 1) {
|
|
3037
|
+
return bufferedScripts[0] + ";document.currentScript.remove()";
|
|
3038
|
+
}
|
|
3039
|
+
return bufferedScripts.join(";") + ";document.currentScript.remove()";
|
|
3040
|
+
}
|
|
3041
|
+
injectBufferedScripts() {
|
|
3042
|
+
if (this._cleanedUp) return;
|
|
3043
|
+
if (this._queue.length === 0) return;
|
|
3044
|
+
const scriptsToInject = this.takeAll();
|
|
3045
|
+
if (scriptsToInject && this.router?.serverSsr) {
|
|
3046
|
+
this.router.serverSsr.injectScript(scriptsToInject);
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
cleanup() {
|
|
3050
|
+
this._cleanedUp = true;
|
|
3051
|
+
this._queue = [];
|
|
3052
|
+
this.router = void 0;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
const MANIFEST_CACHE_SIZE = 100;
|
|
3056
|
+
const manifestCaches = /* @__PURE__ */ new WeakMap();
|
|
3057
|
+
function getManifestCache(manifest2) {
|
|
3058
|
+
const cache = manifestCaches.get(manifest2);
|
|
3059
|
+
if (cache) return cache;
|
|
3060
|
+
const newCache = createLRUCache(MANIFEST_CACHE_SIZE);
|
|
3061
|
+
manifestCaches.set(manifest2, newCache);
|
|
3062
|
+
return newCache;
|
|
3063
|
+
}
|
|
3064
|
+
function attachRouterServerSsrUtils({
|
|
3065
|
+
router,
|
|
3066
|
+
manifest: manifest2
|
|
3067
|
+
}) {
|
|
3068
|
+
router.ssr = {
|
|
3069
|
+
manifest: manifest2
|
|
3070
|
+
};
|
|
3071
|
+
let _dehydrated = false;
|
|
3072
|
+
let _serializationFinished = false;
|
|
3073
|
+
const renderFinishedListeners = [];
|
|
3074
|
+
const serializationFinishedListeners = [];
|
|
3075
|
+
const scriptBuffer = new ScriptBuffer(router);
|
|
3076
|
+
let injectedHtmlBuffer = "";
|
|
3077
|
+
router.serverSsr = {
|
|
3078
|
+
injectHtml: (html) => {
|
|
3079
|
+
if (!html) return;
|
|
3080
|
+
injectedHtmlBuffer += html;
|
|
3081
|
+
router.emit({
|
|
3082
|
+
type: "onInjectedHtml"
|
|
3083
|
+
});
|
|
3084
|
+
},
|
|
3085
|
+
injectScript: (script) => {
|
|
3086
|
+
if (!script) return;
|
|
3087
|
+
const html = `<script${router.options.ssr?.nonce ? ` nonce='${router.options.ssr.nonce}'` : ""}>${script}<\/script>`;
|
|
3088
|
+
router.serverSsr.injectHtml(html);
|
|
3089
|
+
},
|
|
3090
|
+
dehydrate: async () => {
|
|
3091
|
+
invariant(!_dehydrated);
|
|
3092
|
+
let matchesToDehydrate = router.state.matches;
|
|
3093
|
+
if (router.isShell()) {
|
|
3094
|
+
matchesToDehydrate = matchesToDehydrate.slice(0, 1);
|
|
3095
|
+
}
|
|
3096
|
+
const matches = matchesToDehydrate.map(dehydrateMatch);
|
|
3097
|
+
let manifestToDehydrate = void 0;
|
|
3098
|
+
if (manifest2) {
|
|
3099
|
+
const currentRouteIdsList = matchesToDehydrate.map((m2) => m2.routeId);
|
|
3100
|
+
const manifestCacheKey = currentRouteIdsList.join("\0");
|
|
3101
|
+
let filteredRoutes;
|
|
3102
|
+
{
|
|
3103
|
+
filteredRoutes = getManifestCache(manifest2).get(manifestCacheKey);
|
|
3104
|
+
}
|
|
3105
|
+
if (!filteredRoutes) {
|
|
3106
|
+
const currentRouteIds = new Set(currentRouteIdsList);
|
|
3107
|
+
const nextFilteredRoutes = {};
|
|
3108
|
+
for (const routeId in manifest2.routes) {
|
|
3109
|
+
const routeManifest = manifest2.routes[routeId];
|
|
3110
|
+
if (currentRouteIds.has(routeId)) {
|
|
3111
|
+
nextFilteredRoutes[routeId] = routeManifest;
|
|
3112
|
+
} else if (routeManifest.assets && routeManifest.assets.length > 0) {
|
|
3113
|
+
nextFilteredRoutes[routeId] = {
|
|
3114
|
+
assets: routeManifest.assets
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
{
|
|
3119
|
+
getManifestCache(manifest2).set(manifestCacheKey, nextFilteredRoutes);
|
|
3120
|
+
}
|
|
3121
|
+
filteredRoutes = nextFilteredRoutes;
|
|
3122
|
+
}
|
|
3123
|
+
manifestToDehydrate = {
|
|
3124
|
+
routes: filteredRoutes
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3127
|
+
const dehydratedRouter = {
|
|
3128
|
+
manifest: manifestToDehydrate,
|
|
3129
|
+
matches
|
|
3130
|
+
};
|
|
3131
|
+
const lastMatchId = matchesToDehydrate[matchesToDehydrate.length - 1]?.id;
|
|
3132
|
+
if (lastMatchId) {
|
|
3133
|
+
dehydratedRouter.lastMatchId = lastMatchId;
|
|
3134
|
+
}
|
|
3135
|
+
const dehydratedData = await router.options.dehydrate?.();
|
|
3136
|
+
if (dehydratedData) {
|
|
3137
|
+
dehydratedRouter.dehydratedData = dehydratedData;
|
|
3138
|
+
}
|
|
3139
|
+
_dehydrated = true;
|
|
3140
|
+
const trackPlugins = { didRun: false };
|
|
3141
|
+
const serializationAdapters = router.options.serializationAdapters;
|
|
3142
|
+
const plugins = serializationAdapters ? serializationAdapters.map((t) => makeSsrSerovalPlugin(t, trackPlugins)).concat(defaultSerovalPlugins) : defaultSerovalPlugins;
|
|
3143
|
+
const signalSerializationComplete = () => {
|
|
3144
|
+
_serializationFinished = true;
|
|
3145
|
+
try {
|
|
3146
|
+
serializationFinishedListeners.forEach((l) => l());
|
|
3147
|
+
router.emit({ type: "onSerializationFinished" });
|
|
3148
|
+
} catch (err) {
|
|
3149
|
+
console.error("Serialization listener error:", err);
|
|
3150
|
+
} finally {
|
|
3151
|
+
serializationFinishedListeners.length = 0;
|
|
3152
|
+
renderFinishedListeners.length = 0;
|
|
3153
|
+
}
|
|
3154
|
+
};
|
|
3155
|
+
cn(dehydratedRouter, {
|
|
3156
|
+
refs: /* @__PURE__ */ new Map(),
|
|
3157
|
+
plugins,
|
|
3158
|
+
onSerialize: (data, initial) => {
|
|
3159
|
+
let serialized = initial ? TSR_PREFIX + data : data;
|
|
3160
|
+
if (trackPlugins.didRun) {
|
|
3161
|
+
serialized = P_PREFIX + serialized + P_SUFFIX;
|
|
3162
|
+
}
|
|
3163
|
+
scriptBuffer.enqueue(serialized);
|
|
3164
|
+
},
|
|
3165
|
+
scopeId: SCOPE_ID,
|
|
3166
|
+
onDone: () => {
|
|
3167
|
+
scriptBuffer.enqueue(GLOBAL_TSR + ".e()");
|
|
3168
|
+
scriptBuffer.flush();
|
|
3169
|
+
signalSerializationComplete();
|
|
3170
|
+
},
|
|
3171
|
+
onError: (err) => {
|
|
3172
|
+
console.error("Serialization error:", err);
|
|
3173
|
+
signalSerializationComplete();
|
|
3174
|
+
}
|
|
3175
|
+
});
|
|
3176
|
+
},
|
|
3177
|
+
isDehydrated() {
|
|
3178
|
+
return _dehydrated;
|
|
3179
|
+
},
|
|
3180
|
+
isSerializationFinished() {
|
|
3181
|
+
return _serializationFinished;
|
|
3182
|
+
},
|
|
3183
|
+
onRenderFinished: (listener) => renderFinishedListeners.push(listener),
|
|
3184
|
+
onSerializationFinished: (listener) => serializationFinishedListeners.push(listener),
|
|
3185
|
+
setRenderFinished: () => {
|
|
3186
|
+
try {
|
|
3187
|
+
renderFinishedListeners.forEach((l) => l());
|
|
3188
|
+
} catch (err) {
|
|
3189
|
+
console.error("Error in render finished listener:", err);
|
|
3190
|
+
} finally {
|
|
3191
|
+
renderFinishedListeners.length = 0;
|
|
3192
|
+
}
|
|
3193
|
+
scriptBuffer.liftBarrier();
|
|
3194
|
+
},
|
|
3195
|
+
takeBufferedScripts() {
|
|
3196
|
+
const scripts = scriptBuffer.takeAll();
|
|
3197
|
+
const serverBufferedScript = {
|
|
3198
|
+
tag: "script",
|
|
3199
|
+
attrs: {
|
|
3200
|
+
nonce: router.options.ssr?.nonce,
|
|
3201
|
+
className: "$tsr",
|
|
3202
|
+
id: TSR_SCRIPT_BARRIER_ID
|
|
3203
|
+
},
|
|
3204
|
+
children: scripts
|
|
3205
|
+
};
|
|
3206
|
+
return serverBufferedScript;
|
|
3207
|
+
},
|
|
3208
|
+
liftScriptBarrier() {
|
|
3209
|
+
scriptBuffer.liftBarrier();
|
|
3210
|
+
},
|
|
3211
|
+
takeBufferedHtml() {
|
|
3212
|
+
if (!injectedHtmlBuffer) {
|
|
3213
|
+
return void 0;
|
|
3214
|
+
}
|
|
3215
|
+
const buffered = injectedHtmlBuffer;
|
|
3216
|
+
injectedHtmlBuffer = "";
|
|
3217
|
+
return buffered;
|
|
3218
|
+
},
|
|
3219
|
+
cleanup() {
|
|
3220
|
+
if (!router.serverSsr) return;
|
|
3221
|
+
renderFinishedListeners.length = 0;
|
|
3222
|
+
serializationFinishedListeners.length = 0;
|
|
3223
|
+
injectedHtmlBuffer = "";
|
|
3224
|
+
scriptBuffer.cleanup();
|
|
3225
|
+
router.serverSsr = void 0;
|
|
3226
|
+
}
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
3229
|
+
function getOrigin(request) {
|
|
3230
|
+
try {
|
|
3231
|
+
return new URL(request.url).origin;
|
|
3232
|
+
} catch {
|
|
3233
|
+
}
|
|
3234
|
+
return "http://localhost";
|
|
3235
|
+
}
|
|
3236
|
+
function getNormalizedURL(url, base) {
|
|
3237
|
+
if (typeof url === "string") url = url.replace("\\", "%5C");
|
|
3238
|
+
const rawUrl = new URL(url, base);
|
|
3239
|
+
const { path: decodedPathname, handledProtocolRelativeURL } = decodePath(
|
|
3240
|
+
rawUrl.pathname
|
|
3241
|
+
);
|
|
3242
|
+
const searchParams = new URLSearchParams(rawUrl.search);
|
|
3243
|
+
const normalizedHref = decodedPathname + (searchParams.size > 0 ? "?" : "") + searchParams.toString() + rawUrl.hash;
|
|
3244
|
+
return {
|
|
3245
|
+
url: new URL(normalizedHref, rawUrl.origin),
|
|
3246
|
+
handledProtocolRelativeURL
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
const NullProtoObj = /* @__PURE__ */ (() => {
|
|
3250
|
+
const e = function() {
|
|
3251
|
+
};
|
|
3252
|
+
return e.prototype = /* @__PURE__ */ Object.create(null), Object.freeze(e.prototype), e;
|
|
3253
|
+
})();
|
|
3254
|
+
function lazyInherit(target, source, sourceKey) {
|
|
3255
|
+
for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) {
|
|
3256
|
+
if (key === "constructor") continue;
|
|
3257
|
+
const targetDesc = Object.getOwnPropertyDescriptor(target, key);
|
|
3258
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
3259
|
+
let modified = false;
|
|
3260
|
+
if (desc.get) {
|
|
3261
|
+
modified = true;
|
|
3262
|
+
desc.get = targetDesc?.get || function() {
|
|
3263
|
+
return this[sourceKey][key];
|
|
3264
|
+
};
|
|
3265
|
+
}
|
|
3266
|
+
if (desc.set) {
|
|
3267
|
+
modified = true;
|
|
3268
|
+
desc.set = targetDesc?.set || function(value) {
|
|
3269
|
+
this[sourceKey][key] = value;
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
if (!targetDesc?.value && typeof desc.value === "function") {
|
|
3273
|
+
modified = true;
|
|
3274
|
+
desc.value = function(...args) {
|
|
3275
|
+
return this[sourceKey][key](...args);
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
if (modified) Object.defineProperty(target, key, desc);
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
const FastURL = /* @__PURE__ */ (() => {
|
|
3282
|
+
const NativeURL = globalThis.URL;
|
|
3283
|
+
const FastURL2 = class URL {
|
|
3284
|
+
#url;
|
|
3285
|
+
#href;
|
|
3286
|
+
#protocol;
|
|
3287
|
+
#host;
|
|
3288
|
+
#pathname;
|
|
3289
|
+
#search;
|
|
3290
|
+
#searchParams;
|
|
3291
|
+
#pos;
|
|
3292
|
+
constructor(url) {
|
|
3293
|
+
if (typeof url === "string") this.#href = url;
|
|
3294
|
+
else {
|
|
3295
|
+
this.#protocol = url.protocol;
|
|
3296
|
+
this.#host = url.host;
|
|
3297
|
+
this.#pathname = url.pathname;
|
|
3298
|
+
this.#search = url.search;
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
static [Symbol.hasInstance](val) {
|
|
3302
|
+
return val instanceof NativeURL;
|
|
3303
|
+
}
|
|
3304
|
+
get _url() {
|
|
3305
|
+
if (this.#url) return this.#url;
|
|
3306
|
+
this.#url = new NativeURL(this.href);
|
|
3307
|
+
this.#href = void 0;
|
|
3308
|
+
this.#protocol = void 0;
|
|
3309
|
+
this.#host = void 0;
|
|
3310
|
+
this.#pathname = void 0;
|
|
3311
|
+
this.#search = void 0;
|
|
3312
|
+
this.#searchParams = void 0;
|
|
3313
|
+
this.#pos = void 0;
|
|
3314
|
+
return this.#url;
|
|
3315
|
+
}
|
|
3316
|
+
get href() {
|
|
3317
|
+
if (this.#url) return this.#url.href;
|
|
3318
|
+
if (!this.#href) this.#href = `${this.#protocol || "http:"}//${this.#host || "localhost"}${this.#pathname || "/"}${this.#search || ""}`;
|
|
3319
|
+
return this.#href;
|
|
3320
|
+
}
|
|
3321
|
+
#getPos() {
|
|
3322
|
+
if (!this.#pos) {
|
|
3323
|
+
const url = this.href;
|
|
3324
|
+
const protoIndex = url.indexOf("://");
|
|
3325
|
+
const pathnameIndex = protoIndex === -1 ? -1 : url.indexOf("/", protoIndex + 4);
|
|
3326
|
+
this.#pos = [
|
|
3327
|
+
protoIndex,
|
|
3328
|
+
pathnameIndex,
|
|
3329
|
+
pathnameIndex === -1 ? -1 : url.indexOf("?", pathnameIndex)
|
|
3330
|
+
];
|
|
3331
|
+
}
|
|
3332
|
+
return this.#pos;
|
|
3333
|
+
}
|
|
3334
|
+
get pathname() {
|
|
3335
|
+
if (this.#url) return this.#url.pathname;
|
|
3336
|
+
if (this.#pathname === void 0) {
|
|
3337
|
+
const [, pathnameIndex, queryIndex] = this.#getPos();
|
|
3338
|
+
if (pathnameIndex === -1) return this._url.pathname;
|
|
3339
|
+
this.#pathname = this.href.slice(pathnameIndex, queryIndex === -1 ? void 0 : queryIndex);
|
|
3340
|
+
}
|
|
3341
|
+
return this.#pathname;
|
|
3342
|
+
}
|
|
3343
|
+
get search() {
|
|
3344
|
+
if (this.#url) return this.#url.search;
|
|
3345
|
+
if (this.#search === void 0) {
|
|
3346
|
+
const [, pathnameIndex, queryIndex] = this.#getPos();
|
|
3347
|
+
if (pathnameIndex === -1) return this._url.search;
|
|
3348
|
+
const url = this.href;
|
|
3349
|
+
this.#search = queryIndex === -1 || queryIndex === url.length - 1 ? "" : url.slice(queryIndex);
|
|
3350
|
+
}
|
|
3351
|
+
return this.#search;
|
|
3352
|
+
}
|
|
3353
|
+
get searchParams() {
|
|
3354
|
+
if (this.#url) return this.#url.searchParams;
|
|
3355
|
+
if (!this.#searchParams) this.#searchParams = new URLSearchParams(this.search);
|
|
3356
|
+
return this.#searchParams;
|
|
3357
|
+
}
|
|
3358
|
+
get protocol() {
|
|
3359
|
+
if (this.#url) return this.#url.protocol;
|
|
3360
|
+
if (this.#protocol === void 0) {
|
|
3361
|
+
const [protocolIndex] = this.#getPos();
|
|
3362
|
+
if (protocolIndex === -1) return this._url.protocol;
|
|
3363
|
+
this.#protocol = this.href.slice(0, protocolIndex + 1);
|
|
3364
|
+
}
|
|
3365
|
+
return this.#protocol;
|
|
3366
|
+
}
|
|
3367
|
+
toString() {
|
|
3368
|
+
return this.href;
|
|
3369
|
+
}
|
|
3370
|
+
toJSON() {
|
|
3371
|
+
return this.href;
|
|
3372
|
+
}
|
|
3373
|
+
};
|
|
3374
|
+
lazyInherit(FastURL2.prototype, NativeURL.prototype, "_url");
|
|
3375
|
+
Object.setPrototypeOf(FastURL2.prototype, NativeURL.prototype);
|
|
3376
|
+
Object.setPrototypeOf(FastURL2, NativeURL);
|
|
3377
|
+
return FastURL2;
|
|
3378
|
+
})();
|
|
3379
|
+
const NodeResponse = /* @__PURE__ */ (() => {
|
|
3380
|
+
const NativeResponse = globalThis.Response;
|
|
3381
|
+
const STATUS_CODES = globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES || {};
|
|
3382
|
+
class NodeResponse2 {
|
|
3383
|
+
#body;
|
|
3384
|
+
#init;
|
|
3385
|
+
#headers;
|
|
3386
|
+
#response;
|
|
3387
|
+
constructor(body, init) {
|
|
3388
|
+
this.#body = body;
|
|
3389
|
+
this.#init = init;
|
|
3390
|
+
}
|
|
3391
|
+
static [Symbol.hasInstance](val) {
|
|
3392
|
+
return val instanceof NativeResponse;
|
|
3393
|
+
}
|
|
3394
|
+
get status() {
|
|
3395
|
+
return this.#response?.status || this.#init?.status || 200;
|
|
3396
|
+
}
|
|
3397
|
+
get statusText() {
|
|
3398
|
+
return this.#response?.statusText || this.#init?.statusText || STATUS_CODES[this.status] || "";
|
|
3399
|
+
}
|
|
3400
|
+
get headers() {
|
|
3401
|
+
if (this.#response) return this.#response.headers;
|
|
3402
|
+
if (this.#headers) return this.#headers;
|
|
3403
|
+
const initHeaders = this.#init?.headers;
|
|
3404
|
+
return this.#headers = initHeaders instanceof Headers ? initHeaders : new Headers(initHeaders);
|
|
3405
|
+
}
|
|
3406
|
+
get ok() {
|
|
3407
|
+
if (this.#response) return this.#response.ok;
|
|
3408
|
+
const status = this.status;
|
|
3409
|
+
return status >= 200 && status < 300;
|
|
3410
|
+
}
|
|
3411
|
+
get _response() {
|
|
3412
|
+
if (this.#response) return this.#response;
|
|
3413
|
+
let body = this.#body;
|
|
3414
|
+
if (body && typeof body.pipe === "function" && !(body instanceof Readable)) {
|
|
3415
|
+
const stream = new PassThrough();
|
|
3416
|
+
body.pipe(stream);
|
|
3417
|
+
const abort = body.abort;
|
|
3418
|
+
if (abort) stream.once("close", () => abort());
|
|
3419
|
+
body = stream;
|
|
3420
|
+
}
|
|
3421
|
+
this.#response = new NativeResponse(body, this.#headers ? {
|
|
3422
|
+
...this.#init,
|
|
3423
|
+
headers: this.#headers
|
|
3424
|
+
} : this.#init);
|
|
3425
|
+
this.#init = void 0;
|
|
3426
|
+
this.#headers = void 0;
|
|
3427
|
+
this.#body = void 0;
|
|
3428
|
+
return this.#response;
|
|
3429
|
+
}
|
|
3430
|
+
_toNodeResponse() {
|
|
3431
|
+
const status = this.status;
|
|
3432
|
+
const statusText = this.statusText;
|
|
3433
|
+
let body;
|
|
3434
|
+
let contentType;
|
|
3435
|
+
let contentLength;
|
|
3436
|
+
if (this.#response) body = this.#response.body;
|
|
3437
|
+
else if (this.#body) if (this.#body instanceof ReadableStream) body = this.#body;
|
|
3438
|
+
else if (typeof this.#body === "string") {
|
|
3439
|
+
body = this.#body;
|
|
3440
|
+
contentType = "text/plain; charset=UTF-8";
|
|
3441
|
+
contentLength = Buffer.byteLength(this.#body);
|
|
3442
|
+
} else if (this.#body instanceof ArrayBuffer) {
|
|
3443
|
+
body = Buffer.from(this.#body);
|
|
3444
|
+
contentLength = this.#body.byteLength;
|
|
3445
|
+
} else if (this.#body instanceof Uint8Array) {
|
|
3446
|
+
body = this.#body;
|
|
3447
|
+
contentLength = this.#body.byteLength;
|
|
3448
|
+
} else if (this.#body instanceof DataView) {
|
|
3449
|
+
body = Buffer.from(this.#body.buffer);
|
|
3450
|
+
contentLength = this.#body.byteLength;
|
|
3451
|
+
} else if (this.#body instanceof Blob) {
|
|
3452
|
+
body = this.#body.stream();
|
|
3453
|
+
contentType = this.#body.type;
|
|
3454
|
+
contentLength = this.#body.size;
|
|
3455
|
+
} else if (typeof this.#body.pipe === "function") body = this.#body;
|
|
3456
|
+
else body = this._response.body;
|
|
3457
|
+
const headers = [];
|
|
3458
|
+
const initHeaders = this.#init?.headers;
|
|
3459
|
+
const headerEntries = this.#response?.headers || this.#headers || (initHeaders ? Array.isArray(initHeaders) ? initHeaders : initHeaders?.entries ? initHeaders.entries() : Object.entries(initHeaders).map(([k2, v2]) => [k2.toLowerCase(), v2]) : void 0);
|
|
3460
|
+
let hasContentTypeHeader;
|
|
3461
|
+
let hasContentLength;
|
|
3462
|
+
if (headerEntries) for (const [key, value] of headerEntries) {
|
|
3463
|
+
if (Array.isArray(value)) for (const v2 of value) headers.push([key, v2]);
|
|
3464
|
+
else headers.push([key, value]);
|
|
3465
|
+
if (key === "content-type") hasContentTypeHeader = true;
|
|
3466
|
+
else if (key === "content-length") hasContentLength = true;
|
|
3467
|
+
}
|
|
3468
|
+
if (contentType && !hasContentTypeHeader) headers.push(["content-type", contentType]);
|
|
3469
|
+
if (contentLength && !hasContentLength) headers.push(["content-length", String(contentLength)]);
|
|
3470
|
+
this.#init = void 0;
|
|
3471
|
+
this.#headers = void 0;
|
|
3472
|
+
this.#response = void 0;
|
|
3473
|
+
this.#body = void 0;
|
|
3474
|
+
return {
|
|
3475
|
+
status,
|
|
3476
|
+
statusText,
|
|
3477
|
+
headers,
|
|
3478
|
+
body
|
|
3479
|
+
};
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
lazyInherit(NodeResponse2.prototype, NativeResponse.prototype, "_response");
|
|
3483
|
+
Object.setPrototypeOf(NodeResponse2, NativeResponse);
|
|
3484
|
+
Object.setPrototypeOf(NodeResponse2.prototype, NativeResponse.prototype);
|
|
3485
|
+
return NodeResponse2;
|
|
3486
|
+
})();
|
|
3487
|
+
const kEventNS = "h3.internal.event.";
|
|
3488
|
+
const kEventRes = /* @__PURE__ */ Symbol.for(`${kEventNS}res`);
|
|
3489
|
+
const kEventResHeaders = /* @__PURE__ */ Symbol.for(`${kEventNS}res.headers`);
|
|
3490
|
+
var H3Event = class {
|
|
3491
|
+
app;
|
|
3492
|
+
req;
|
|
3493
|
+
url;
|
|
3494
|
+
context;
|
|
3495
|
+
static __is_event__ = true;
|
|
3496
|
+
constructor(req, context, app) {
|
|
3497
|
+
this.context = context || req.context || new NullProtoObj();
|
|
3498
|
+
this.req = req;
|
|
3499
|
+
this.app = app;
|
|
3500
|
+
const _url = req._url;
|
|
3501
|
+
this.url = _url && _url instanceof URL ? _url : new FastURL(req.url);
|
|
3502
|
+
}
|
|
3503
|
+
get res() {
|
|
3504
|
+
return this[kEventRes] ||= new H3EventResponse();
|
|
3505
|
+
}
|
|
3506
|
+
get runtime() {
|
|
3507
|
+
return this.req.runtime;
|
|
3508
|
+
}
|
|
3509
|
+
waitUntil(promise) {
|
|
3510
|
+
this.req.waitUntil?.(promise);
|
|
3511
|
+
}
|
|
3512
|
+
toString() {
|
|
3513
|
+
return `[${this.req.method}] ${this.req.url}`;
|
|
3514
|
+
}
|
|
3515
|
+
toJSON() {
|
|
3516
|
+
return this.toString();
|
|
3517
|
+
}
|
|
3518
|
+
get node() {
|
|
3519
|
+
return this.req.runtime?.node;
|
|
3520
|
+
}
|
|
3521
|
+
get headers() {
|
|
3522
|
+
return this.req.headers;
|
|
3523
|
+
}
|
|
3524
|
+
get path() {
|
|
3525
|
+
return this.url.pathname + this.url.search;
|
|
3526
|
+
}
|
|
3527
|
+
get method() {
|
|
3528
|
+
return this.req.method;
|
|
3529
|
+
}
|
|
3530
|
+
};
|
|
3531
|
+
var H3EventResponse = class {
|
|
3532
|
+
status;
|
|
3533
|
+
statusText;
|
|
3534
|
+
get headers() {
|
|
3535
|
+
return this[kEventResHeaders] ||= new Headers();
|
|
3536
|
+
}
|
|
3537
|
+
};
|
|
3538
|
+
const DISALLOWED_STATUS_CHARS = /[^\u0009\u0020-\u007E]/g;
|
|
3539
|
+
function sanitizeStatusMessage(statusMessage = "") {
|
|
3540
|
+
return statusMessage.replace(DISALLOWED_STATUS_CHARS, "");
|
|
3541
|
+
}
|
|
3542
|
+
function sanitizeStatusCode(statusCode, defaultStatusCode = 200) {
|
|
3543
|
+
if (!statusCode) return defaultStatusCode;
|
|
3544
|
+
if (typeof statusCode === "string") statusCode = +statusCode;
|
|
3545
|
+
if (statusCode < 100 || statusCode > 599) return defaultStatusCode;
|
|
3546
|
+
return statusCode;
|
|
3547
|
+
}
|
|
3548
|
+
var HTTPError = class HTTPError2 extends Error {
|
|
3549
|
+
get name() {
|
|
3550
|
+
return "HTTPError";
|
|
3551
|
+
}
|
|
3552
|
+
status;
|
|
3553
|
+
statusText;
|
|
3554
|
+
headers;
|
|
3555
|
+
cause;
|
|
3556
|
+
data;
|
|
3557
|
+
body;
|
|
3558
|
+
unhandled;
|
|
3559
|
+
static isError(input) {
|
|
3560
|
+
return input instanceof Error && input?.name === "HTTPError";
|
|
3561
|
+
}
|
|
3562
|
+
static status(status, statusText, details) {
|
|
3563
|
+
return new HTTPError2({
|
|
3564
|
+
...details,
|
|
3565
|
+
statusText,
|
|
3566
|
+
status
|
|
3567
|
+
});
|
|
3568
|
+
}
|
|
3569
|
+
constructor(arg1, arg2) {
|
|
3570
|
+
let messageInput;
|
|
3571
|
+
let details;
|
|
3572
|
+
if (typeof arg1 === "string") {
|
|
3573
|
+
messageInput = arg1;
|
|
3574
|
+
details = arg2;
|
|
3575
|
+
} else details = arg1;
|
|
3576
|
+
const status = sanitizeStatusCode(details?.status || details?.cause?.status || details?.status || details?.statusCode, 500);
|
|
3577
|
+
const statusText = sanitizeStatusMessage(details?.statusText || details?.cause?.statusText || details?.statusText || details?.statusMessage);
|
|
3578
|
+
const message = messageInput || details?.message || details?.cause?.message || details?.statusText || details?.statusMessage || [
|
|
3579
|
+
"HTTPError",
|
|
3580
|
+
status,
|
|
3581
|
+
statusText
|
|
3582
|
+
].filter(Boolean).join(" ");
|
|
3583
|
+
super(message, { cause: details });
|
|
3584
|
+
this.cause = details;
|
|
3585
|
+
this.status = status;
|
|
3586
|
+
this.statusText = statusText || void 0;
|
|
3587
|
+
const rawHeaders = details?.headers || details?.cause?.headers;
|
|
3588
|
+
this.headers = rawHeaders ? new Headers(rawHeaders) : void 0;
|
|
3589
|
+
this.unhandled = details?.unhandled ?? details?.cause?.unhandled ?? void 0;
|
|
3590
|
+
this.data = details?.data;
|
|
3591
|
+
this.body = details?.body;
|
|
3592
|
+
}
|
|
3593
|
+
get statusCode() {
|
|
3594
|
+
return this.status;
|
|
3595
|
+
}
|
|
3596
|
+
get statusMessage() {
|
|
3597
|
+
return this.statusText;
|
|
3598
|
+
}
|
|
3599
|
+
toJSON() {
|
|
3600
|
+
const unhandled = this.unhandled;
|
|
3601
|
+
return {
|
|
3602
|
+
status: this.status,
|
|
3603
|
+
statusText: this.statusText,
|
|
3604
|
+
unhandled,
|
|
3605
|
+
message: unhandled ? "HTTPError" : this.message,
|
|
3606
|
+
data: unhandled ? void 0 : this.data,
|
|
3607
|
+
...unhandled ? void 0 : this.body
|
|
3608
|
+
};
|
|
3609
|
+
}
|
|
3610
|
+
};
|
|
3611
|
+
function isJSONSerializable(value, _type) {
|
|
3612
|
+
if (value === null || value === void 0) return true;
|
|
3613
|
+
if (_type !== "object") return _type === "boolean" || _type === "number" || _type === "string";
|
|
3614
|
+
if (typeof value.toJSON === "function") return true;
|
|
3615
|
+
if (Array.isArray(value)) return true;
|
|
3616
|
+
if (typeof value.pipe === "function" || typeof value.pipeTo === "function") return false;
|
|
3617
|
+
if (value instanceof NullProtoObj) return true;
|
|
3618
|
+
const proto = Object.getPrototypeOf(value);
|
|
3619
|
+
return proto === Object.prototype || proto === null;
|
|
3620
|
+
}
|
|
3621
|
+
const kNotFound = /* @__PURE__ */ Symbol.for("h3.notFound");
|
|
3622
|
+
const kHandled = /* @__PURE__ */ Symbol.for("h3.handled");
|
|
3623
|
+
function toResponse(val, event, config = {}) {
|
|
3624
|
+
if (typeof val?.then === "function") return (val.catch?.((error) => error) || Promise.resolve(val)).then((resolvedVal) => toResponse(resolvedVal, event, config));
|
|
3625
|
+
const response = prepareResponse(val, event, config);
|
|
3626
|
+
if (typeof response?.then === "function") return toResponse(response, event, config);
|
|
3627
|
+
const { onResponse } = config;
|
|
3628
|
+
return onResponse ? Promise.resolve(onResponse(response, event)).then(() => response) : response;
|
|
3629
|
+
}
|
|
3630
|
+
var HTTPResponse = class {
|
|
3631
|
+
#headers;
|
|
3632
|
+
#init;
|
|
3633
|
+
body;
|
|
3634
|
+
constructor(body, init) {
|
|
3635
|
+
this.body = body;
|
|
3636
|
+
this.#init = init;
|
|
3637
|
+
}
|
|
3638
|
+
get status() {
|
|
3639
|
+
return this.#init?.status || 200;
|
|
3640
|
+
}
|
|
3641
|
+
get statusText() {
|
|
3642
|
+
return this.#init?.statusText || "OK";
|
|
3643
|
+
}
|
|
3644
|
+
get headers() {
|
|
3645
|
+
return this.#headers ||= new Headers(this.#init?.headers);
|
|
3646
|
+
}
|
|
3647
|
+
};
|
|
3648
|
+
function prepareResponse(val, event, config, nested) {
|
|
3649
|
+
if (val === kHandled) return new NodeResponse(null);
|
|
3650
|
+
if (val === kNotFound) val = new HTTPError({
|
|
3651
|
+
status: 404,
|
|
3652
|
+
message: `Cannot find any route matching [${event.req.method}] ${event.url}`
|
|
3653
|
+
});
|
|
3654
|
+
if (val && val instanceof Error) {
|
|
3655
|
+
const isHTTPError = HTTPError.isError(val);
|
|
3656
|
+
const error = isHTTPError ? val : new HTTPError(val);
|
|
3657
|
+
if (!isHTTPError) {
|
|
3658
|
+
error.unhandled = true;
|
|
3659
|
+
if (val?.stack) error.stack = val.stack;
|
|
3660
|
+
}
|
|
3661
|
+
if (error.unhandled && !config.silent) console.error(error);
|
|
3662
|
+
const { onError } = config;
|
|
3663
|
+
return onError && !nested ? Promise.resolve(onError(error, event)).catch((error2) => error2).then((newVal) => prepareResponse(newVal ?? val, event, config, true)) : errorResponse(error, config.debug);
|
|
3664
|
+
}
|
|
3665
|
+
const preparedRes = event[kEventRes];
|
|
3666
|
+
const preparedHeaders = preparedRes?.[kEventResHeaders];
|
|
3667
|
+
event[kEventRes] = void 0;
|
|
3668
|
+
if (!(val instanceof Response)) {
|
|
3669
|
+
const res = prepareResponseBody(val, event, config);
|
|
3670
|
+
const status = res.status || preparedRes?.status;
|
|
3671
|
+
return new NodeResponse(nullBody(event.req.method, status) ? null : res.body, {
|
|
3672
|
+
status,
|
|
3673
|
+
statusText: res.statusText || preparedRes?.statusText,
|
|
3674
|
+
headers: res.headers && preparedHeaders ? mergeHeaders$1(res.headers, preparedHeaders) : res.headers || preparedHeaders
|
|
3675
|
+
});
|
|
3676
|
+
}
|
|
3677
|
+
if (!preparedHeaders || nested || !val.ok) return val;
|
|
3678
|
+
try {
|
|
3679
|
+
mergeHeaders$1(val.headers, preparedHeaders, val.headers);
|
|
3680
|
+
return val;
|
|
3681
|
+
} catch {
|
|
3682
|
+
return new NodeResponse(nullBody(event.req.method, val.status) ? null : val.body, {
|
|
3683
|
+
status: val.status,
|
|
3684
|
+
statusText: val.statusText,
|
|
3685
|
+
headers: mergeHeaders$1(val.headers, preparedHeaders)
|
|
3686
|
+
});
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
function mergeHeaders$1(base, overrides, target = new Headers(base)) {
|
|
3690
|
+
for (const [name, value] of overrides) if (name === "set-cookie") target.append(name, value);
|
|
3691
|
+
else target.set(name, value);
|
|
3692
|
+
return target;
|
|
3693
|
+
}
|
|
3694
|
+
const frozen = (name) => (...args) => {
|
|
3695
|
+
throw new Error(`Headers are frozen (${name} ${args.join(", ")})`);
|
|
3696
|
+
};
|
|
3697
|
+
var FrozenHeaders = class extends Headers {
|
|
3698
|
+
set = frozen("set");
|
|
3699
|
+
append = frozen("append");
|
|
3700
|
+
delete = frozen("delete");
|
|
3701
|
+
};
|
|
3702
|
+
const emptyHeaders = /* @__PURE__ */ new FrozenHeaders({ "content-length": "0" });
|
|
3703
|
+
const jsonHeaders = /* @__PURE__ */ new FrozenHeaders({ "content-type": "application/json;charset=UTF-8" });
|
|
3704
|
+
function prepareResponseBody(val, event, config) {
|
|
3705
|
+
if (val === null || val === void 0) return {
|
|
3706
|
+
body: "",
|
|
3707
|
+
headers: emptyHeaders
|
|
3708
|
+
};
|
|
3709
|
+
const valType = typeof val;
|
|
3710
|
+
if (valType === "string") return { body: val };
|
|
3711
|
+
if (val instanceof Uint8Array) {
|
|
3712
|
+
event.res.headers.set("content-length", val.byteLength.toString());
|
|
3713
|
+
return { body: val };
|
|
3714
|
+
}
|
|
3715
|
+
if (val instanceof HTTPResponse || val?.constructor?.name === "HTTPResponse") return val;
|
|
3716
|
+
if (isJSONSerializable(val, valType)) return {
|
|
3717
|
+
body: JSON.stringify(val, void 0, config.debug ? 2 : void 0),
|
|
3718
|
+
headers: jsonHeaders
|
|
3719
|
+
};
|
|
3720
|
+
if (valType === "bigint") return {
|
|
3721
|
+
body: val.toString(),
|
|
3722
|
+
headers: jsonHeaders
|
|
3723
|
+
};
|
|
3724
|
+
if (val instanceof Blob) {
|
|
3725
|
+
const headers = new Headers({
|
|
3726
|
+
"content-type": val.type,
|
|
3727
|
+
"content-length": val.size.toString()
|
|
3728
|
+
});
|
|
3729
|
+
let filename = val.name;
|
|
3730
|
+
if (filename) {
|
|
3731
|
+
filename = encodeURIComponent(filename);
|
|
3732
|
+
headers.set("content-disposition", `filename="${filename}"; filename*=UTF-8''${filename}`);
|
|
3733
|
+
}
|
|
3734
|
+
return {
|
|
3735
|
+
body: val.stream(),
|
|
3736
|
+
headers
|
|
3737
|
+
};
|
|
3738
|
+
}
|
|
3739
|
+
if (valType === "symbol") return { body: val.toString() };
|
|
3740
|
+
if (valType === "function") return { body: `${val.name}()` };
|
|
3741
|
+
return { body: val };
|
|
3742
|
+
}
|
|
3743
|
+
function nullBody(method, status) {
|
|
3744
|
+
return method === "HEAD" || status === 100 || status === 101 || status === 102 || status === 204 || status === 205 || status === 304;
|
|
3745
|
+
}
|
|
3746
|
+
function errorResponse(error, debug) {
|
|
3747
|
+
return new NodeResponse(JSON.stringify({
|
|
3748
|
+
...error.toJSON(),
|
|
3749
|
+
stack: debug && error.stack ? error.stack.split("\n").map((l) => l.trim()) : void 0
|
|
3750
|
+
}, void 0, debug ? 2 : void 0), {
|
|
3751
|
+
status: error.status,
|
|
3752
|
+
statusText: error.statusText,
|
|
3753
|
+
headers: error.headers ? mergeHeaders$1(jsonHeaders, error.headers) : new Headers(jsonHeaders)
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
function parse(str, options) {
|
|
3757
|
+
if (typeof str !== "string") throw new TypeError("argument str must be a string");
|
|
3758
|
+
const obj = {};
|
|
3759
|
+
const opt = {};
|
|
3760
|
+
const dec = opt.decode || decode;
|
|
3761
|
+
let index = 0;
|
|
3762
|
+
while (index < str.length) {
|
|
3763
|
+
const eqIdx = str.indexOf("=", index);
|
|
3764
|
+
if (eqIdx === -1) break;
|
|
3765
|
+
let endIdx = str.indexOf(";", index);
|
|
3766
|
+
if (endIdx === -1) endIdx = str.length;
|
|
3767
|
+
else if (endIdx < eqIdx) {
|
|
3768
|
+
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
|
3769
|
+
continue;
|
|
3770
|
+
}
|
|
3771
|
+
const key = str.slice(index, eqIdx).trim();
|
|
3772
|
+
if (opt?.filter && !opt?.filter(key)) {
|
|
3773
|
+
index = endIdx + 1;
|
|
3774
|
+
continue;
|
|
3775
|
+
}
|
|
3776
|
+
if (void 0 === obj[key]) {
|
|
3777
|
+
let val = str.slice(eqIdx + 1, endIdx).trim();
|
|
3778
|
+
if (val.codePointAt(0) === 34) val = val.slice(1, -1);
|
|
3779
|
+
obj[key] = tryDecode(val, dec);
|
|
3780
|
+
}
|
|
3781
|
+
index = endIdx + 1;
|
|
3782
|
+
}
|
|
3783
|
+
return obj;
|
|
3784
|
+
}
|
|
3785
|
+
function decode(str) {
|
|
3786
|
+
return str.includes("%") ? decodeURIComponent(str) : str;
|
|
3787
|
+
}
|
|
3788
|
+
function tryDecode(str, decode2) {
|
|
3789
|
+
try {
|
|
3790
|
+
return decode2(str);
|
|
3791
|
+
} catch {
|
|
3792
|
+
return str;
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
function parseCookies(event) {
|
|
3796
|
+
return parse(event.req.headers.get("cookie") || "");
|
|
3797
|
+
}
|
|
3798
|
+
new TextEncoder();
|
|
3799
|
+
const GLOBAL_EVENT_STORAGE_KEY = /* @__PURE__ */ Symbol.for("tanstack-start:event-storage");
|
|
3800
|
+
const globalObj = globalThis;
|
|
3801
|
+
if (!globalObj[GLOBAL_EVENT_STORAGE_KEY]) {
|
|
3802
|
+
globalObj[GLOBAL_EVENT_STORAGE_KEY] = new AsyncLocalStorage();
|
|
3803
|
+
}
|
|
3804
|
+
const eventStorage = globalObj[GLOBAL_EVENT_STORAGE_KEY];
|
|
3805
|
+
function isPromiseLike(value) {
|
|
3806
|
+
return typeof value.then === "function";
|
|
3807
|
+
}
|
|
3808
|
+
function getSetCookieValues(headers) {
|
|
3809
|
+
const headersWithSetCookie = headers;
|
|
3810
|
+
if (typeof headersWithSetCookie.getSetCookie === "function") {
|
|
3811
|
+
return headersWithSetCookie.getSetCookie();
|
|
3812
|
+
}
|
|
3813
|
+
const value = headers.get("set-cookie");
|
|
3814
|
+
return value ? [value] : [];
|
|
3815
|
+
}
|
|
3816
|
+
function mergeEventResponseHeaders(response, event) {
|
|
3817
|
+
if (response.ok) {
|
|
3818
|
+
return;
|
|
3819
|
+
}
|
|
3820
|
+
const eventSetCookies = getSetCookieValues(event.res.headers);
|
|
3821
|
+
if (eventSetCookies.length === 0) {
|
|
3822
|
+
return;
|
|
3823
|
+
}
|
|
3824
|
+
const responseSetCookies = getSetCookieValues(response.headers);
|
|
3825
|
+
response.headers.delete("set-cookie");
|
|
3826
|
+
for (const cookie of responseSetCookies) {
|
|
3827
|
+
response.headers.append("set-cookie", cookie);
|
|
3828
|
+
}
|
|
3829
|
+
for (const cookie of eventSetCookies) {
|
|
3830
|
+
response.headers.append("set-cookie", cookie);
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
function attachResponseHeaders(value, event) {
|
|
3834
|
+
if (isPromiseLike(value)) {
|
|
3835
|
+
return value.then((resolved) => {
|
|
3836
|
+
if (resolved instanceof Response) {
|
|
3837
|
+
mergeEventResponseHeaders(resolved, event);
|
|
3838
|
+
}
|
|
3839
|
+
return resolved;
|
|
3840
|
+
});
|
|
3841
|
+
}
|
|
3842
|
+
if (value instanceof Response) {
|
|
3843
|
+
mergeEventResponseHeaders(value, event);
|
|
3844
|
+
}
|
|
3845
|
+
return value;
|
|
3846
|
+
}
|
|
3847
|
+
function requestHandler(handler) {
|
|
3848
|
+
return (request, requestOpts) => {
|
|
3849
|
+
const h3Event = new H3Event(request);
|
|
3850
|
+
const response = eventStorage.run(
|
|
3851
|
+
{ h3Event },
|
|
3852
|
+
() => handler(request, requestOpts)
|
|
3853
|
+
);
|
|
3854
|
+
return toResponse(attachResponseHeaders(response, h3Event), h3Event);
|
|
3855
|
+
};
|
|
3856
|
+
}
|
|
3857
|
+
function getH3Event() {
|
|
3858
|
+
const event = eventStorage.getStore();
|
|
3859
|
+
if (!event) {
|
|
3860
|
+
throw new Error(
|
|
3861
|
+
`No StartEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime.`
|
|
3862
|
+
);
|
|
3863
|
+
}
|
|
3864
|
+
return event.h3Event;
|
|
3865
|
+
}
|
|
3866
|
+
function getCookies() {
|
|
3867
|
+
const event = getH3Event();
|
|
3868
|
+
return parseCookies(event);
|
|
3869
|
+
}
|
|
3870
|
+
function getCookie(name) {
|
|
3871
|
+
return getCookies()[name] || void 0;
|
|
3872
|
+
}
|
|
3873
|
+
function getResponse() {
|
|
3874
|
+
const event = getH3Event();
|
|
3875
|
+
return event.res;
|
|
3876
|
+
}
|
|
3877
|
+
async function getStartManifest(matchedRoutes) {
|
|
3878
|
+
const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-B_rvI8DG.js");
|
|
3879
|
+
const startManifest = tsrStartManifest();
|
|
3880
|
+
const rootRoute = startManifest.routes[rootRouteId] = startManifest.routes[rootRouteId] || {};
|
|
3881
|
+
rootRoute.assets = rootRoute.assets || [];
|
|
3882
|
+
let injectedHeadScripts;
|
|
3883
|
+
const manifest2 = {
|
|
3884
|
+
routes: Object.fromEntries(
|
|
3885
|
+
Object.entries(startManifest.routes).flatMap(([k2, v2]) => {
|
|
3886
|
+
const result = {};
|
|
3887
|
+
let hasData = false;
|
|
3888
|
+
if (v2.preloads && v2.preloads.length > 0) {
|
|
3889
|
+
result["preloads"] = v2.preloads;
|
|
3890
|
+
hasData = true;
|
|
3891
|
+
}
|
|
3892
|
+
if (v2.assets && v2.assets.length > 0) {
|
|
3893
|
+
result["assets"] = v2.assets;
|
|
3894
|
+
hasData = true;
|
|
3895
|
+
}
|
|
3896
|
+
if (!hasData) {
|
|
3897
|
+
return [];
|
|
3898
|
+
}
|
|
3899
|
+
return [[k2, result]];
|
|
3900
|
+
})
|
|
3901
|
+
)
|
|
3902
|
+
};
|
|
3903
|
+
return {
|
|
3904
|
+
manifest: manifest2,
|
|
3905
|
+
clientEntry: startManifest.clientEntry,
|
|
3906
|
+
injectedHeadScripts
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
const textEncoder$1 = new TextEncoder();
|
|
3910
|
+
const EMPTY_PAYLOAD = new Uint8Array(0);
|
|
3911
|
+
function encodeFrame(type, streamId, payload) {
|
|
3912
|
+
const frame = new Uint8Array(FRAME_HEADER_SIZE + payload.length);
|
|
3913
|
+
frame[0] = type;
|
|
3914
|
+
frame[1] = streamId >>> 24 & 255;
|
|
3915
|
+
frame[2] = streamId >>> 16 & 255;
|
|
3916
|
+
frame[3] = streamId >>> 8 & 255;
|
|
3917
|
+
frame[4] = streamId & 255;
|
|
3918
|
+
frame[5] = payload.length >>> 24 & 255;
|
|
3919
|
+
frame[6] = payload.length >>> 16 & 255;
|
|
3920
|
+
frame[7] = payload.length >>> 8 & 255;
|
|
3921
|
+
frame[8] = payload.length & 255;
|
|
3922
|
+
frame.set(payload, FRAME_HEADER_SIZE);
|
|
3923
|
+
return frame;
|
|
3924
|
+
}
|
|
3925
|
+
function encodeJSONFrame(json) {
|
|
3926
|
+
return encodeFrame(FrameType.JSON, 0, textEncoder$1.encode(json));
|
|
3927
|
+
}
|
|
3928
|
+
function encodeChunkFrame(streamId, chunk) {
|
|
3929
|
+
return encodeFrame(FrameType.CHUNK, streamId, chunk);
|
|
3930
|
+
}
|
|
3931
|
+
function encodeEndFrame(streamId) {
|
|
3932
|
+
return encodeFrame(FrameType.END, streamId, EMPTY_PAYLOAD);
|
|
3933
|
+
}
|
|
3934
|
+
function encodeErrorFrame(streamId, error) {
|
|
3935
|
+
const message = error instanceof Error ? error.message : String(error ?? "Unknown error");
|
|
3936
|
+
return encodeFrame(FrameType.ERROR, streamId, textEncoder$1.encode(message));
|
|
3937
|
+
}
|
|
3938
|
+
function createMultiplexedStream(jsonStream, rawStreams) {
|
|
3939
|
+
let activePumps = 1 + rawStreams.size;
|
|
3940
|
+
let controllerRef = null;
|
|
3941
|
+
let cancelled = false;
|
|
3942
|
+
const cancelReaders = [];
|
|
3943
|
+
const safeEnqueue = (chunk) => {
|
|
3944
|
+
if (cancelled || !controllerRef) return;
|
|
3945
|
+
try {
|
|
3946
|
+
controllerRef.enqueue(chunk);
|
|
3947
|
+
} catch {
|
|
3948
|
+
}
|
|
3949
|
+
};
|
|
3950
|
+
const safeError = (err) => {
|
|
3951
|
+
if (cancelled || !controllerRef) return;
|
|
3952
|
+
try {
|
|
3953
|
+
controllerRef.error(err);
|
|
3954
|
+
} catch {
|
|
3955
|
+
}
|
|
3956
|
+
};
|
|
3957
|
+
const safeClose = () => {
|
|
3958
|
+
if (cancelled || !controllerRef) return;
|
|
3959
|
+
try {
|
|
3960
|
+
controllerRef.close();
|
|
3961
|
+
} catch {
|
|
3962
|
+
}
|
|
3963
|
+
};
|
|
3964
|
+
const checkComplete = () => {
|
|
3965
|
+
activePumps--;
|
|
3966
|
+
if (activePumps === 0) {
|
|
3967
|
+
safeClose();
|
|
3968
|
+
}
|
|
3969
|
+
};
|
|
3970
|
+
return new ReadableStream({
|
|
3971
|
+
start(controller) {
|
|
3972
|
+
controllerRef = controller;
|
|
3973
|
+
cancelReaders.length = 0;
|
|
3974
|
+
const pumpJSON = async () => {
|
|
3975
|
+
const reader = jsonStream.getReader();
|
|
3976
|
+
cancelReaders.push(() => {
|
|
3977
|
+
reader.cancel().catch(() => {
|
|
3978
|
+
});
|
|
3979
|
+
});
|
|
3980
|
+
try {
|
|
3981
|
+
while (true) {
|
|
3982
|
+
const { done, value } = await reader.read();
|
|
3983
|
+
if (cancelled) break;
|
|
3984
|
+
if (done) break;
|
|
3985
|
+
safeEnqueue(encodeJSONFrame(value));
|
|
3986
|
+
}
|
|
3987
|
+
} catch (error) {
|
|
3988
|
+
safeError(error);
|
|
3989
|
+
} finally {
|
|
3990
|
+
reader.releaseLock();
|
|
3991
|
+
checkComplete();
|
|
3992
|
+
}
|
|
3993
|
+
};
|
|
3994
|
+
const pumpRawStream = async (streamId, stream) => {
|
|
3995
|
+
const reader = stream.getReader();
|
|
3996
|
+
cancelReaders.push(() => {
|
|
3997
|
+
reader.cancel().catch(() => {
|
|
3998
|
+
});
|
|
3999
|
+
});
|
|
4000
|
+
try {
|
|
4001
|
+
while (true) {
|
|
4002
|
+
const { done, value } = await reader.read();
|
|
4003
|
+
if (cancelled) break;
|
|
4004
|
+
if (done) {
|
|
4005
|
+
safeEnqueue(encodeEndFrame(streamId));
|
|
4006
|
+
break;
|
|
4007
|
+
}
|
|
4008
|
+
safeEnqueue(encodeChunkFrame(streamId, value));
|
|
4009
|
+
}
|
|
4010
|
+
} catch (error) {
|
|
4011
|
+
safeEnqueue(encodeErrorFrame(streamId, error));
|
|
4012
|
+
} finally {
|
|
4013
|
+
reader.releaseLock();
|
|
4014
|
+
checkComplete();
|
|
4015
|
+
}
|
|
4016
|
+
};
|
|
4017
|
+
pumpJSON();
|
|
4018
|
+
for (const [streamId, stream] of rawStreams) {
|
|
4019
|
+
pumpRawStream(streamId, stream);
|
|
4020
|
+
}
|
|
4021
|
+
},
|
|
4022
|
+
cancel() {
|
|
4023
|
+
cancelled = true;
|
|
4024
|
+
controllerRef = null;
|
|
4025
|
+
for (const cancelReader of cancelReaders) {
|
|
4026
|
+
cancelReader();
|
|
4027
|
+
}
|
|
4028
|
+
cancelReaders.length = 0;
|
|
4029
|
+
}
|
|
4030
|
+
});
|
|
4031
|
+
}
|
|
4032
|
+
const manifest = { "5ae2bb0c4c003d915f9054a906ac04c5e5445504bc009ebe1b0909b118638f63": {
|
|
4033
|
+
functionName: "getSidebarPref_createServerFn_handler",
|
|
4034
|
+
importer: () => import("./assets/data.functions-9hSsMFx_.js")
|
|
4035
|
+
}, "cbb2f7cdf3f3a605c4dfa620eb06a3cf071dae878f19986d68e6ef770b13f7fa": {
|
|
4036
|
+
functionName: "getDashboardData_createServerFn_handler",
|
|
4037
|
+
importer: () => import("./assets/data.functions-9hSsMFx_.js")
|
|
4038
|
+
}, "beec9fd37fa775f9a6fdc16dd643e042dbc9e24c2b45f88ddc7b529513bd4661": {
|
|
4039
|
+
functionName: "getConversations_createServerFn_handler",
|
|
4040
|
+
importer: () => import("./assets/data.functions-9hSsMFx_.js")
|
|
4041
|
+
}, "ca03005c412458a0bc657c061b4f332f92b1ff4b8c19f40ffaf334bca75a0749": {
|
|
4042
|
+
functionName: "loadConversationMessages_createServerFn_handler",
|
|
4043
|
+
importer: () => import("./assets/data.functions-9hSsMFx_.js")
|
|
4044
|
+
}, "184ce16af80e6368f2fae4eb2360630a351114a8cc3ee5800b1a08e02b9dd7e9": {
|
|
4045
|
+
functionName: "getCompanionInfo_createServerFn_handler",
|
|
4046
|
+
importer: () => import("./assets/data.functions-9hSsMFx_.js")
|
|
4047
|
+
}, "9a5dc52f000f13d22209e6a0728000f0667bc09e1ac65adb09228596aa34819b": {
|
|
4048
|
+
functionName: "getPromptHistoryEntries_createServerFn_handler",
|
|
4049
|
+
importer: () => import("./assets/data.functions-9hSsMFx_.js")
|
|
4050
|
+
}, "0106759db375e1456f62d4c1efe7094c3733545535507409fcecd70d465fd501": {
|
|
4051
|
+
functionName: "appendPromptHistoryEntry_createServerFn_handler",
|
|
4052
|
+
importer: () => import("./assets/data.functions-9hSsMFx_.js")
|
|
4053
|
+
}, "6856120823d177dc2bccc2b8c490fcf0742fdb07eb32f1567908fb7b7e9d60b8": {
|
|
4054
|
+
functionName: "streamMessage_createServerFn_handler",
|
|
4055
|
+
importer: () => import("./assets/agent.functions-zpMkBrG3.js").then((n2) => n2.a3)
|
|
4056
|
+
} };
|
|
4057
|
+
async function getServerFnById(id) {
|
|
4058
|
+
const serverFnInfo = manifest[id];
|
|
4059
|
+
if (!serverFnInfo) {
|
|
4060
|
+
throw new Error("Server function info not found for " + id);
|
|
4061
|
+
}
|
|
4062
|
+
const fnModule = await serverFnInfo.importer();
|
|
4063
|
+
if (!fnModule) {
|
|
4064
|
+
console.info("serverFnInfo", serverFnInfo);
|
|
4065
|
+
throw new Error("Server function module not resolved for " + id);
|
|
4066
|
+
}
|
|
4067
|
+
const action = fnModule[serverFnInfo.functionName];
|
|
4068
|
+
if (!action) {
|
|
4069
|
+
console.info("serverFnInfo", serverFnInfo);
|
|
4070
|
+
console.info("fnModule", fnModule);
|
|
4071
|
+
throw new Error(
|
|
4072
|
+
`Server function module export not resolved for serverFn ID: ${id}`
|
|
4073
|
+
);
|
|
4074
|
+
}
|
|
4075
|
+
return action;
|
|
4076
|
+
}
|
|
4077
|
+
let serovalPlugins = void 0;
|
|
4078
|
+
const textEncoder = new TextEncoder();
|
|
4079
|
+
const FORM_DATA_CONTENT_TYPES = [
|
|
4080
|
+
"multipart/form-data",
|
|
4081
|
+
"application/x-www-form-urlencoded"
|
|
4082
|
+
];
|
|
4083
|
+
const MAX_PAYLOAD_SIZE = 1e6;
|
|
4084
|
+
const handleServerAction = async ({
|
|
4085
|
+
request,
|
|
4086
|
+
context,
|
|
4087
|
+
serverFnId
|
|
4088
|
+
}) => {
|
|
4089
|
+
const method = request.method;
|
|
4090
|
+
const methodUpper = method.toUpperCase();
|
|
4091
|
+
const methodLower = method.toLowerCase();
|
|
4092
|
+
const url = new URL(request.url);
|
|
4093
|
+
const action = await getServerFnById(serverFnId);
|
|
4094
|
+
const isServerFn = request.headers.get("x-tsr-serverFn") === "true";
|
|
4095
|
+
if (!serovalPlugins) {
|
|
4096
|
+
serovalPlugins = getDefaultSerovalPlugins();
|
|
4097
|
+
}
|
|
4098
|
+
const contentType = request.headers.get("Content-Type");
|
|
4099
|
+
function parsePayload(payload) {
|
|
4100
|
+
const parsedPayload = Iu(payload, { plugins: serovalPlugins });
|
|
4101
|
+
return parsedPayload;
|
|
4102
|
+
}
|
|
4103
|
+
const response = await (async () => {
|
|
4104
|
+
try {
|
|
4105
|
+
let serializeResult = function(res2) {
|
|
4106
|
+
let nonStreamingBody = void 0;
|
|
4107
|
+
const alsResponse = getResponse();
|
|
4108
|
+
if (res2 !== void 0) {
|
|
4109
|
+
const rawStreams = /* @__PURE__ */ new Map();
|
|
4110
|
+
const rawStreamPlugin = createRawStreamRPCPlugin(
|
|
4111
|
+
(id, stream2) => {
|
|
4112
|
+
rawStreams.set(id, stream2);
|
|
4113
|
+
}
|
|
4114
|
+
);
|
|
4115
|
+
const plugins = [rawStreamPlugin, ...serovalPlugins || []];
|
|
4116
|
+
let done = false;
|
|
4117
|
+
const callbacks = {
|
|
4118
|
+
onParse: (value) => {
|
|
4119
|
+
nonStreamingBody = value;
|
|
4120
|
+
},
|
|
4121
|
+
onDone: () => {
|
|
4122
|
+
done = true;
|
|
4123
|
+
},
|
|
4124
|
+
onError: (error) => {
|
|
4125
|
+
throw error;
|
|
4126
|
+
}
|
|
4127
|
+
};
|
|
4128
|
+
au(res2, {
|
|
4129
|
+
refs: /* @__PURE__ */ new Map(),
|
|
4130
|
+
plugins,
|
|
4131
|
+
onParse(value) {
|
|
4132
|
+
callbacks.onParse(value);
|
|
4133
|
+
},
|
|
4134
|
+
onDone() {
|
|
4135
|
+
callbacks.onDone();
|
|
4136
|
+
},
|
|
4137
|
+
onError: (error) => {
|
|
4138
|
+
callbacks.onError(error);
|
|
4139
|
+
}
|
|
4140
|
+
});
|
|
4141
|
+
if (done && rawStreams.size === 0) {
|
|
4142
|
+
return new Response(
|
|
4143
|
+
nonStreamingBody ? JSON.stringify(nonStreamingBody) : void 0,
|
|
4144
|
+
{
|
|
4145
|
+
status: alsResponse.status,
|
|
4146
|
+
statusText: alsResponse.statusText,
|
|
4147
|
+
headers: {
|
|
4148
|
+
"Content-Type": "application/json",
|
|
4149
|
+
[X_TSS_SERIALIZED]: "true"
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
4152
|
+
);
|
|
4153
|
+
}
|
|
4154
|
+
if (rawStreams.size > 0) {
|
|
4155
|
+
const jsonStream = new ReadableStream({
|
|
4156
|
+
start(controller) {
|
|
4157
|
+
callbacks.onParse = (value) => {
|
|
4158
|
+
controller.enqueue(JSON.stringify(value) + "\n");
|
|
4159
|
+
};
|
|
4160
|
+
callbacks.onDone = () => {
|
|
4161
|
+
try {
|
|
4162
|
+
controller.close();
|
|
4163
|
+
} catch {
|
|
4164
|
+
}
|
|
4165
|
+
};
|
|
4166
|
+
callbacks.onError = (error) => controller.error(error);
|
|
4167
|
+
if (nonStreamingBody !== void 0) {
|
|
4168
|
+
callbacks.onParse(nonStreamingBody);
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
});
|
|
4172
|
+
const multiplexedStream = createMultiplexedStream(
|
|
4173
|
+
jsonStream,
|
|
4174
|
+
rawStreams
|
|
4175
|
+
);
|
|
4176
|
+
return new Response(multiplexedStream, {
|
|
4177
|
+
status: alsResponse.status,
|
|
4178
|
+
statusText: alsResponse.statusText,
|
|
4179
|
+
headers: {
|
|
4180
|
+
"Content-Type": TSS_CONTENT_TYPE_FRAMED_VERSIONED,
|
|
4181
|
+
[X_TSS_SERIALIZED]: "true"
|
|
4182
|
+
}
|
|
4183
|
+
});
|
|
4184
|
+
}
|
|
4185
|
+
const stream = new ReadableStream({
|
|
4186
|
+
start(controller) {
|
|
4187
|
+
callbacks.onParse = (value) => controller.enqueue(
|
|
4188
|
+
textEncoder.encode(JSON.stringify(value) + "\n")
|
|
4189
|
+
);
|
|
4190
|
+
callbacks.onDone = () => {
|
|
4191
|
+
try {
|
|
4192
|
+
controller.close();
|
|
4193
|
+
} catch (error) {
|
|
4194
|
+
controller.error(error);
|
|
4195
|
+
}
|
|
4196
|
+
};
|
|
4197
|
+
callbacks.onError = (error) => controller.error(error);
|
|
4198
|
+
if (nonStreamingBody !== void 0) {
|
|
4199
|
+
callbacks.onParse(nonStreamingBody);
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
});
|
|
4203
|
+
return new Response(stream, {
|
|
4204
|
+
status: alsResponse.status,
|
|
4205
|
+
statusText: alsResponse.statusText,
|
|
4206
|
+
headers: {
|
|
4207
|
+
"Content-Type": "application/x-ndjson",
|
|
4208
|
+
[X_TSS_SERIALIZED]: "true"
|
|
4209
|
+
}
|
|
4210
|
+
});
|
|
4211
|
+
}
|
|
4212
|
+
return new Response(void 0, {
|
|
4213
|
+
status: alsResponse.status,
|
|
4214
|
+
statusText: alsResponse.statusText
|
|
4215
|
+
});
|
|
4216
|
+
};
|
|
4217
|
+
let res = await (async () => {
|
|
4218
|
+
if (FORM_DATA_CONTENT_TYPES.some(
|
|
4219
|
+
(type) => contentType && contentType.includes(type)
|
|
4220
|
+
)) {
|
|
4221
|
+
invariant(
|
|
4222
|
+
methodLower !== "get",
|
|
4223
|
+
"GET requests with FormData payloads are not supported"
|
|
4224
|
+
);
|
|
4225
|
+
const formData = await request.formData();
|
|
4226
|
+
const serializedContext = formData.get(TSS_FORMDATA_CONTEXT);
|
|
4227
|
+
formData.delete(TSS_FORMDATA_CONTEXT);
|
|
4228
|
+
const params = {
|
|
4229
|
+
context,
|
|
4230
|
+
data: formData,
|
|
4231
|
+
method: methodUpper
|
|
4232
|
+
};
|
|
4233
|
+
if (typeof serializedContext === "string") {
|
|
4234
|
+
try {
|
|
4235
|
+
const parsedContext = JSON.parse(serializedContext);
|
|
4236
|
+
const deserializedContext = Iu(parsedContext, {
|
|
4237
|
+
plugins: serovalPlugins
|
|
4238
|
+
});
|
|
4239
|
+
if (typeof deserializedContext === "object" && deserializedContext) {
|
|
4240
|
+
params.context = safeObjectMerge(
|
|
4241
|
+
context,
|
|
4242
|
+
deserializedContext
|
|
4243
|
+
);
|
|
4244
|
+
}
|
|
4245
|
+
} catch (e) {
|
|
4246
|
+
if (false) ;
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
return await action(params);
|
|
4250
|
+
}
|
|
4251
|
+
if (methodLower === "get") {
|
|
4252
|
+
const payloadParam = url.searchParams.get("payload");
|
|
4253
|
+
if (payloadParam && payloadParam.length > MAX_PAYLOAD_SIZE) {
|
|
4254
|
+
throw new Error("Payload too large");
|
|
4255
|
+
}
|
|
4256
|
+
const payload2 = payloadParam ? parsePayload(JSON.parse(payloadParam)) : {};
|
|
4257
|
+
payload2.context = safeObjectMerge(context, payload2.context);
|
|
4258
|
+
payload2.method = methodUpper;
|
|
4259
|
+
return await action(payload2);
|
|
4260
|
+
}
|
|
4261
|
+
if (methodLower !== "post") {
|
|
4262
|
+
throw new Error("expected POST method");
|
|
4263
|
+
}
|
|
4264
|
+
let jsonPayload;
|
|
4265
|
+
if (contentType?.includes("application/json")) {
|
|
4266
|
+
jsonPayload = await request.json();
|
|
4267
|
+
}
|
|
4268
|
+
const payload = jsonPayload ? parsePayload(jsonPayload) : {};
|
|
4269
|
+
payload.context = safeObjectMerge(payload.context, context);
|
|
4270
|
+
payload.method = methodUpper;
|
|
4271
|
+
return await action(payload);
|
|
4272
|
+
})();
|
|
4273
|
+
const unwrapped = res.result || res.error;
|
|
4274
|
+
if (isNotFound(res)) {
|
|
4275
|
+
res = isNotFoundResponse(res);
|
|
4276
|
+
}
|
|
4277
|
+
if (!isServerFn) {
|
|
4278
|
+
return unwrapped;
|
|
4279
|
+
}
|
|
4280
|
+
if (unwrapped instanceof Response) {
|
|
4281
|
+
if (isRedirect(unwrapped)) {
|
|
4282
|
+
return unwrapped;
|
|
4283
|
+
}
|
|
4284
|
+
unwrapped.headers.set(X_TSS_RAW_RESPONSE, "true");
|
|
4285
|
+
return unwrapped;
|
|
4286
|
+
}
|
|
4287
|
+
return serializeResult(res);
|
|
4288
|
+
} catch (error) {
|
|
4289
|
+
if (error instanceof Response) {
|
|
4290
|
+
return error;
|
|
4291
|
+
}
|
|
4292
|
+
if (isNotFound(error)) {
|
|
4293
|
+
return isNotFoundResponse(error);
|
|
4294
|
+
}
|
|
4295
|
+
console.info();
|
|
4296
|
+
console.info("Server Fn Error!");
|
|
4297
|
+
console.info();
|
|
4298
|
+
console.error(error);
|
|
4299
|
+
console.info();
|
|
4300
|
+
const serializedError = JSON.stringify(
|
|
4301
|
+
await Promise.resolve(
|
|
4302
|
+
ou(error, {
|
|
4303
|
+
refs: /* @__PURE__ */ new Map(),
|
|
4304
|
+
plugins: serovalPlugins
|
|
4305
|
+
})
|
|
4306
|
+
)
|
|
4307
|
+
);
|
|
4308
|
+
const response2 = getResponse();
|
|
4309
|
+
return new Response(serializedError, {
|
|
4310
|
+
status: response2.status ?? 500,
|
|
4311
|
+
statusText: response2.statusText,
|
|
4312
|
+
headers: {
|
|
4313
|
+
"Content-Type": "application/json",
|
|
4314
|
+
[X_TSS_SERIALIZED]: "true"
|
|
4315
|
+
}
|
|
4316
|
+
});
|
|
4317
|
+
}
|
|
4318
|
+
})();
|
|
4319
|
+
return response;
|
|
4320
|
+
};
|
|
4321
|
+
function isNotFoundResponse(error) {
|
|
4322
|
+
const { headers, ...rest } = error;
|
|
4323
|
+
return new Response(JSON.stringify(rest), {
|
|
4324
|
+
status: 404,
|
|
4325
|
+
headers: {
|
|
4326
|
+
"Content-Type": "application/json",
|
|
4327
|
+
...headers || {}
|
|
4328
|
+
}
|
|
4329
|
+
});
|
|
4330
|
+
}
|
|
4331
|
+
function resolveTransformConfig(transform) {
|
|
4332
|
+
if (typeof transform === "string") {
|
|
4333
|
+
const prefix2 = transform;
|
|
4334
|
+
return {
|
|
4335
|
+
type: "transform",
|
|
4336
|
+
transformFn: ({ url }) => `${prefix2}${url}`,
|
|
4337
|
+
cache: true
|
|
4338
|
+
};
|
|
4339
|
+
}
|
|
4340
|
+
if (typeof transform === "function") {
|
|
4341
|
+
return {
|
|
4342
|
+
type: "transform",
|
|
4343
|
+
transformFn: transform,
|
|
4344
|
+
cache: true
|
|
4345
|
+
};
|
|
4346
|
+
}
|
|
4347
|
+
if ("createTransform" in transform && transform.createTransform) {
|
|
4348
|
+
return {
|
|
4349
|
+
type: "createTransform",
|
|
4350
|
+
createTransform: transform.createTransform,
|
|
4351
|
+
cache: transform.cache !== false
|
|
4352
|
+
};
|
|
4353
|
+
}
|
|
4354
|
+
const transformFn = typeof transform.transform === "string" ? (({ url }) => `${transform.transform}${url}`) : transform.transform;
|
|
4355
|
+
return {
|
|
4356
|
+
type: "transform",
|
|
4357
|
+
transformFn,
|
|
4358
|
+
cache: transform.cache !== false
|
|
4359
|
+
};
|
|
4360
|
+
}
|
|
4361
|
+
function buildClientEntryScriptTag(clientEntry, injectedHeadScripts) {
|
|
4362
|
+
const clientEntryLiteral = JSON.stringify(clientEntry);
|
|
4363
|
+
let script = `import(${clientEntryLiteral})`;
|
|
4364
|
+
if (injectedHeadScripts) {
|
|
4365
|
+
script = `${injectedHeadScripts};${script}`;
|
|
4366
|
+
}
|
|
4367
|
+
return {
|
|
4368
|
+
tag: "script",
|
|
4369
|
+
attrs: {
|
|
4370
|
+
type: "module",
|
|
4371
|
+
async: true
|
|
4372
|
+
},
|
|
4373
|
+
children: script
|
|
4374
|
+
};
|
|
4375
|
+
}
|
|
4376
|
+
function transformManifestUrls(source, transformFn, opts) {
|
|
4377
|
+
return (async () => {
|
|
4378
|
+
const manifest2 = opts?.clone ? structuredClone(source.manifest) : source.manifest;
|
|
4379
|
+
for (const route of Object.values(manifest2.routes)) {
|
|
4380
|
+
if (route.preloads) {
|
|
4381
|
+
route.preloads = await Promise.all(
|
|
4382
|
+
route.preloads.map(
|
|
4383
|
+
(url) => Promise.resolve(transformFn({ url, type: "modulepreload" }))
|
|
4384
|
+
)
|
|
4385
|
+
);
|
|
4386
|
+
}
|
|
4387
|
+
if (route.assets) {
|
|
4388
|
+
for (const asset of route.assets) {
|
|
4389
|
+
if (asset.tag === "link" && asset.attrs?.href) {
|
|
4390
|
+
asset.attrs.href = await Promise.resolve(
|
|
4391
|
+
transformFn({
|
|
4392
|
+
url: asset.attrs.href,
|
|
4393
|
+
type: "stylesheet"
|
|
4394
|
+
})
|
|
4395
|
+
);
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
}
|
|
4400
|
+
const transformedClientEntry = await Promise.resolve(
|
|
4401
|
+
transformFn({
|
|
4402
|
+
url: source.clientEntry,
|
|
4403
|
+
type: "clientEntry"
|
|
4404
|
+
})
|
|
4405
|
+
);
|
|
4406
|
+
const rootRoute = manifest2.routes[rootRouteId];
|
|
4407
|
+
if (rootRoute) {
|
|
4408
|
+
rootRoute.assets = rootRoute.assets || [];
|
|
4409
|
+
rootRoute.assets.push(
|
|
4410
|
+
buildClientEntryScriptTag(
|
|
4411
|
+
transformedClientEntry,
|
|
4412
|
+
source.injectedHeadScripts
|
|
4413
|
+
)
|
|
4414
|
+
);
|
|
4415
|
+
}
|
|
4416
|
+
return manifest2;
|
|
4417
|
+
})();
|
|
4418
|
+
}
|
|
4419
|
+
function buildManifestWithClientEntry(source) {
|
|
4420
|
+
const scriptTag = buildClientEntryScriptTag(
|
|
4421
|
+
source.clientEntry,
|
|
4422
|
+
source.injectedHeadScripts
|
|
4423
|
+
);
|
|
4424
|
+
const baseRootRoute = source.manifest.routes[rootRouteId];
|
|
4425
|
+
const routes = {
|
|
4426
|
+
...source.manifest.routes,
|
|
4427
|
+
...baseRootRoute ? {
|
|
4428
|
+
[rootRouteId]: {
|
|
4429
|
+
...baseRootRoute,
|
|
4430
|
+
assets: [...baseRootRoute.assets || [], scriptTag]
|
|
4431
|
+
}
|
|
4432
|
+
} : {}
|
|
4433
|
+
};
|
|
4434
|
+
return { routes };
|
|
4435
|
+
}
|
|
4436
|
+
const HEADERS = {
|
|
4437
|
+
TSS_SHELL: "X-TSS_SHELL"
|
|
4438
|
+
};
|
|
4439
|
+
const ServerFunctionSerializationAdapter = createSerializationAdapter({
|
|
4440
|
+
key: "$TSS/serverfn",
|
|
4441
|
+
test: (v2) => {
|
|
4442
|
+
if (typeof v2 !== "function") return false;
|
|
4443
|
+
if (!(TSS_SERVER_FUNCTION in v2)) return false;
|
|
4444
|
+
return !!v2[TSS_SERVER_FUNCTION];
|
|
4445
|
+
},
|
|
4446
|
+
toSerializable: ({ serverFnMeta }) => ({ functionId: serverFnMeta.id }),
|
|
4447
|
+
fromSerializable: ({ functionId }) => {
|
|
4448
|
+
const fn2 = async (opts, signal) => {
|
|
4449
|
+
const serverFn = await getServerFnById(functionId);
|
|
4450
|
+
const result = await serverFn(opts ?? {}, signal);
|
|
4451
|
+
return result.result;
|
|
4452
|
+
};
|
|
4453
|
+
return fn2;
|
|
4454
|
+
}
|
|
4455
|
+
});
|
|
4456
|
+
function getStartResponseHeaders(opts) {
|
|
4457
|
+
const headers = mergeHeaders(
|
|
4458
|
+
{
|
|
4459
|
+
"Content-Type": "text/html; charset=utf-8"
|
|
4460
|
+
},
|
|
4461
|
+
...opts.router.state.matches.map((match) => {
|
|
4462
|
+
return match.headers;
|
|
4463
|
+
})
|
|
4464
|
+
);
|
|
4465
|
+
return headers;
|
|
4466
|
+
}
|
|
4467
|
+
let entriesPromise;
|
|
4468
|
+
let baseManifestPromise;
|
|
4469
|
+
let cachedFinalManifestPromise;
|
|
4470
|
+
async function loadEntries() {
|
|
4471
|
+
const routerEntry = await import("./assets/router-1koL9I3U.js").then((n2) => n2.r);
|
|
4472
|
+
const startEntry = await import("./assets/start-HYkvq4Ni.js");
|
|
4473
|
+
return { startEntry, routerEntry };
|
|
4474
|
+
}
|
|
4475
|
+
function getEntries() {
|
|
4476
|
+
if (!entriesPromise) {
|
|
4477
|
+
entriesPromise = loadEntries();
|
|
4478
|
+
}
|
|
4479
|
+
return entriesPromise;
|
|
4480
|
+
}
|
|
4481
|
+
function getBaseManifest(matchedRoutes) {
|
|
4482
|
+
if (!baseManifestPromise) {
|
|
4483
|
+
baseManifestPromise = getStartManifest();
|
|
4484
|
+
}
|
|
4485
|
+
return baseManifestPromise;
|
|
4486
|
+
}
|
|
4487
|
+
async function resolveManifest(matchedRoutes, transformFn, cache) {
|
|
4488
|
+
const base = await getBaseManifest();
|
|
4489
|
+
const computeFinalManifest = async () => {
|
|
4490
|
+
return transformFn ? await transformManifestUrls(base, transformFn, { clone: !cache }) : buildManifestWithClientEntry(base);
|
|
4491
|
+
};
|
|
4492
|
+
if (!transformFn || cache) {
|
|
4493
|
+
if (!cachedFinalManifestPromise) {
|
|
4494
|
+
cachedFinalManifestPromise = computeFinalManifest();
|
|
4495
|
+
}
|
|
4496
|
+
return cachedFinalManifestPromise;
|
|
4497
|
+
}
|
|
4498
|
+
return computeFinalManifest();
|
|
4499
|
+
}
|
|
4500
|
+
const ROUTER_BASEPATH = "/";
|
|
4501
|
+
const SERVER_FN_BASE = "/_serverFn/";
|
|
4502
|
+
const IS_PRERENDERING = process.env.TSS_PRERENDERING === "true";
|
|
4503
|
+
const IS_SHELL_ENV = process.env.TSS_SHELL === "true";
|
|
4504
|
+
const ERR_NO_RESPONSE = "Internal Server Error";
|
|
4505
|
+
const ERR_NO_DEFER = "Internal Server Error";
|
|
4506
|
+
function throwRouteHandlerError() {
|
|
4507
|
+
throw new Error(ERR_NO_RESPONSE);
|
|
4508
|
+
}
|
|
4509
|
+
function throwIfMayNotDefer() {
|
|
4510
|
+
throw new Error(ERR_NO_DEFER);
|
|
4511
|
+
}
|
|
4512
|
+
function isSpecialResponse(value) {
|
|
4513
|
+
return value instanceof Response || isRedirect(value);
|
|
4514
|
+
}
|
|
4515
|
+
function handleCtxResult(result) {
|
|
4516
|
+
if (isSpecialResponse(result)) {
|
|
4517
|
+
return { response: result };
|
|
4518
|
+
}
|
|
4519
|
+
return result;
|
|
4520
|
+
}
|
|
4521
|
+
function executeMiddleware(middlewares, ctx) {
|
|
4522
|
+
let index = -1;
|
|
4523
|
+
const next = async (nextCtx) => {
|
|
4524
|
+
if (nextCtx) {
|
|
4525
|
+
if (nextCtx.context) {
|
|
4526
|
+
ctx.context = safeObjectMerge(ctx.context, nextCtx.context);
|
|
4527
|
+
}
|
|
4528
|
+
for (const key of Object.keys(nextCtx)) {
|
|
4529
|
+
if (key !== "context") {
|
|
4530
|
+
ctx[key] = nextCtx[key];
|
|
4531
|
+
}
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
index++;
|
|
4535
|
+
const middleware = middlewares[index];
|
|
4536
|
+
if (!middleware) return ctx;
|
|
4537
|
+
let result;
|
|
4538
|
+
try {
|
|
4539
|
+
result = await middleware({ ...ctx, next });
|
|
4540
|
+
} catch (err) {
|
|
4541
|
+
if (isSpecialResponse(err)) {
|
|
4542
|
+
ctx.response = err;
|
|
4543
|
+
return ctx;
|
|
4544
|
+
}
|
|
4545
|
+
throw err;
|
|
4546
|
+
}
|
|
4547
|
+
const normalized = handleCtxResult(result);
|
|
4548
|
+
if (normalized) {
|
|
4549
|
+
if (normalized.response !== void 0) {
|
|
4550
|
+
ctx.response = normalized.response;
|
|
4551
|
+
}
|
|
4552
|
+
if (normalized.context) {
|
|
4553
|
+
ctx.context = safeObjectMerge(ctx.context, normalized.context);
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
return ctx;
|
|
4557
|
+
};
|
|
4558
|
+
return next();
|
|
4559
|
+
}
|
|
4560
|
+
function handlerToMiddleware(handler, mayDefer = false) {
|
|
4561
|
+
if (mayDefer) {
|
|
4562
|
+
return handler;
|
|
4563
|
+
}
|
|
4564
|
+
return async (ctx) => {
|
|
4565
|
+
const response = await handler({ ...ctx, next: throwIfMayNotDefer });
|
|
4566
|
+
if (!response) {
|
|
4567
|
+
throwRouteHandlerError();
|
|
4568
|
+
}
|
|
4569
|
+
return response;
|
|
4570
|
+
};
|
|
4571
|
+
}
|
|
4572
|
+
function createStartHandler(cbOrOptions) {
|
|
4573
|
+
const cb = typeof cbOrOptions === "function" ? cbOrOptions : cbOrOptions.handler;
|
|
4574
|
+
const transformAssetUrlsOption = typeof cbOrOptions === "function" ? void 0 : cbOrOptions.transformAssetUrls;
|
|
4575
|
+
const warmupTransformManifest = !!transformAssetUrlsOption && typeof transformAssetUrlsOption === "object" && transformAssetUrlsOption.warmup === true;
|
|
4576
|
+
const resolvedTransformConfig = transformAssetUrlsOption ? resolveTransformConfig(transformAssetUrlsOption) : void 0;
|
|
4577
|
+
const cache = resolvedTransformConfig ? resolvedTransformConfig.cache : true;
|
|
4578
|
+
let cachedCreateTransformPromise;
|
|
4579
|
+
const getTransformFn = async (opts) => {
|
|
4580
|
+
if (!resolvedTransformConfig) return void 0;
|
|
4581
|
+
if (resolvedTransformConfig.type === "createTransform") {
|
|
4582
|
+
if (cache) {
|
|
4583
|
+
if (!cachedCreateTransformPromise) {
|
|
4584
|
+
cachedCreateTransformPromise = Promise.resolve(
|
|
4585
|
+
resolvedTransformConfig.createTransform(opts)
|
|
4586
|
+
);
|
|
4587
|
+
}
|
|
4588
|
+
return cachedCreateTransformPromise;
|
|
4589
|
+
}
|
|
4590
|
+
return resolvedTransformConfig.createTransform(opts);
|
|
4591
|
+
}
|
|
4592
|
+
return resolvedTransformConfig.transformFn;
|
|
4593
|
+
};
|
|
4594
|
+
if (warmupTransformManifest && cache && true && !cachedFinalManifestPromise) {
|
|
4595
|
+
const warmupPromise = (async () => {
|
|
4596
|
+
const base = await getBaseManifest();
|
|
4597
|
+
const transformFn = await getTransformFn({ warmup: true });
|
|
4598
|
+
return transformFn ? await transformManifestUrls(base, transformFn, { clone: false }) : buildManifestWithClientEntry(base);
|
|
4599
|
+
})();
|
|
4600
|
+
cachedFinalManifestPromise = warmupPromise;
|
|
4601
|
+
warmupPromise.catch(() => {
|
|
4602
|
+
if (cachedFinalManifestPromise === warmupPromise) {
|
|
4603
|
+
cachedFinalManifestPromise = void 0;
|
|
4604
|
+
}
|
|
4605
|
+
cachedCreateTransformPromise = void 0;
|
|
4606
|
+
});
|
|
4607
|
+
}
|
|
4608
|
+
const startRequestResolver = async (request, requestOpts) => {
|
|
4609
|
+
let router = null;
|
|
4610
|
+
let cbWillCleanup = false;
|
|
4611
|
+
try {
|
|
4612
|
+
const { url, handledProtocolRelativeURL } = getNormalizedURL(request.url);
|
|
4613
|
+
const href = url.pathname + url.search + url.hash;
|
|
4614
|
+
const origin = getOrigin(request);
|
|
4615
|
+
if (handledProtocolRelativeURL) {
|
|
4616
|
+
return Response.redirect(url, 308);
|
|
4617
|
+
}
|
|
4618
|
+
const entries = await getEntries();
|
|
4619
|
+
const startOptions = await entries.startEntry.startInstance?.getOptions() || {};
|
|
4620
|
+
const serializationAdapters = [
|
|
4621
|
+
...startOptions.serializationAdapters || [],
|
|
4622
|
+
ServerFunctionSerializationAdapter
|
|
4623
|
+
];
|
|
4624
|
+
const requestStartOptions = {
|
|
4625
|
+
...startOptions,
|
|
4626
|
+
serializationAdapters
|
|
4627
|
+
};
|
|
4628
|
+
const flattenedRequestMiddlewares = startOptions.requestMiddleware ? flattenMiddlewares(startOptions.requestMiddleware) : [];
|
|
4629
|
+
const executedRequestMiddlewares = new Set(
|
|
4630
|
+
flattenedRequestMiddlewares
|
|
4631
|
+
);
|
|
4632
|
+
const getRouter = async () => {
|
|
4633
|
+
if (router) return router;
|
|
4634
|
+
router = await entries.routerEntry.getRouter();
|
|
4635
|
+
let isShell = IS_SHELL_ENV;
|
|
4636
|
+
if (IS_PRERENDERING && !isShell) {
|
|
4637
|
+
isShell = request.headers.get(HEADERS.TSS_SHELL) === "true";
|
|
4638
|
+
}
|
|
4639
|
+
const history = createMemoryHistory({
|
|
4640
|
+
initialEntries: [href]
|
|
4641
|
+
});
|
|
4642
|
+
router.update({
|
|
4643
|
+
history,
|
|
4644
|
+
isShell,
|
|
4645
|
+
isPrerendering: IS_PRERENDERING,
|
|
4646
|
+
origin: router.options.origin ?? origin,
|
|
4647
|
+
...{
|
|
4648
|
+
defaultSsr: requestStartOptions.defaultSsr,
|
|
4649
|
+
serializationAdapters: [
|
|
4650
|
+
...requestStartOptions.serializationAdapters,
|
|
4651
|
+
...router.options.serializationAdapters || []
|
|
4652
|
+
]
|
|
4653
|
+
},
|
|
4654
|
+
basepath: ROUTER_BASEPATH
|
|
4655
|
+
});
|
|
4656
|
+
return router;
|
|
4657
|
+
};
|
|
4658
|
+
if (SERVER_FN_BASE && url.pathname.startsWith(SERVER_FN_BASE)) {
|
|
4659
|
+
const serverFnId = url.pathname.slice(SERVER_FN_BASE.length).split("/")[0];
|
|
4660
|
+
if (!serverFnId) {
|
|
4661
|
+
throw new Error("Invalid server action param for serverFnId");
|
|
4662
|
+
}
|
|
4663
|
+
const serverFnHandler = async ({ context }) => {
|
|
4664
|
+
return runWithStartContext(
|
|
4665
|
+
{
|
|
4666
|
+
getRouter,
|
|
4667
|
+
startOptions: requestStartOptions,
|
|
4668
|
+
contextAfterGlobalMiddlewares: context,
|
|
4669
|
+
request,
|
|
4670
|
+
executedRequestMiddlewares
|
|
4671
|
+
},
|
|
4672
|
+
() => handleServerAction({
|
|
4673
|
+
request,
|
|
4674
|
+
context: requestOpts?.context,
|
|
4675
|
+
serverFnId
|
|
4676
|
+
})
|
|
4677
|
+
);
|
|
4678
|
+
};
|
|
4679
|
+
const middlewares2 = flattenedRequestMiddlewares.map(
|
|
4680
|
+
(d) => d.options.server
|
|
4681
|
+
);
|
|
4682
|
+
const ctx2 = await executeMiddleware([...middlewares2, serverFnHandler], {
|
|
4683
|
+
request,
|
|
4684
|
+
pathname: url.pathname,
|
|
4685
|
+
context: createNullProtoObject(requestOpts?.context)
|
|
4686
|
+
});
|
|
4687
|
+
return handleRedirectResponse(ctx2.response, request, getRouter);
|
|
4688
|
+
}
|
|
4689
|
+
const executeRouter = async (serverContext, matchedRoutes) => {
|
|
4690
|
+
const acceptHeader = request.headers.get("Accept") || "*/*";
|
|
4691
|
+
const acceptParts = acceptHeader.split(",");
|
|
4692
|
+
const supportedMimeTypes = ["*/*", "text/html"];
|
|
4693
|
+
const isSupported = supportedMimeTypes.some(
|
|
4694
|
+
(mimeType) => acceptParts.some((part) => part.trim().startsWith(mimeType))
|
|
4695
|
+
);
|
|
4696
|
+
if (!isSupported) {
|
|
4697
|
+
return Response.json(
|
|
4698
|
+
{ error: "Only HTML requests are supported here" },
|
|
4699
|
+
{ status: 500 }
|
|
4700
|
+
);
|
|
4701
|
+
}
|
|
4702
|
+
const manifest2 = await resolveManifest(
|
|
4703
|
+
matchedRoutes,
|
|
4704
|
+
await getTransformFn({ warmup: false, request }),
|
|
4705
|
+
cache
|
|
4706
|
+
);
|
|
4707
|
+
const routerInstance = await getRouter();
|
|
4708
|
+
attachRouterServerSsrUtils({
|
|
4709
|
+
router: routerInstance,
|
|
4710
|
+
manifest: manifest2
|
|
4711
|
+
});
|
|
4712
|
+
routerInstance.update({ additionalContext: { serverContext } });
|
|
4713
|
+
await routerInstance.load();
|
|
4714
|
+
if (routerInstance.state.redirect) {
|
|
4715
|
+
return routerInstance.state.redirect;
|
|
4716
|
+
}
|
|
4717
|
+
await routerInstance.serverSsr.dehydrate();
|
|
4718
|
+
const responseHeaders = getStartResponseHeaders({
|
|
4719
|
+
router: routerInstance
|
|
4720
|
+
});
|
|
4721
|
+
cbWillCleanup = true;
|
|
4722
|
+
return cb({
|
|
4723
|
+
request,
|
|
4724
|
+
router: routerInstance,
|
|
4725
|
+
responseHeaders
|
|
4726
|
+
});
|
|
4727
|
+
};
|
|
4728
|
+
const requestHandlerMiddleware = async ({ context }) => {
|
|
4729
|
+
return runWithStartContext(
|
|
4730
|
+
{
|
|
4731
|
+
getRouter,
|
|
4732
|
+
startOptions: requestStartOptions,
|
|
4733
|
+
contextAfterGlobalMiddlewares: context,
|
|
4734
|
+
request,
|
|
4735
|
+
executedRequestMiddlewares
|
|
4736
|
+
},
|
|
4737
|
+
async () => {
|
|
4738
|
+
try {
|
|
4739
|
+
return await handleServerRoutes({
|
|
4740
|
+
getRouter,
|
|
4741
|
+
request,
|
|
4742
|
+
url,
|
|
4743
|
+
executeRouter,
|
|
4744
|
+
context,
|
|
4745
|
+
executedRequestMiddlewares
|
|
4746
|
+
});
|
|
4747
|
+
} catch (err) {
|
|
4748
|
+
if (err instanceof Response) {
|
|
4749
|
+
return err;
|
|
4750
|
+
}
|
|
4751
|
+
throw err;
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
);
|
|
4755
|
+
};
|
|
4756
|
+
const middlewares = flattenedRequestMiddlewares.map(
|
|
4757
|
+
(d) => d.options.server
|
|
4758
|
+
);
|
|
4759
|
+
const ctx = await executeMiddleware(
|
|
4760
|
+
[...middlewares, requestHandlerMiddleware],
|
|
4761
|
+
{
|
|
4762
|
+
request,
|
|
4763
|
+
pathname: url.pathname,
|
|
4764
|
+
context: createNullProtoObject(requestOpts?.context)
|
|
4765
|
+
}
|
|
4766
|
+
);
|
|
4767
|
+
return handleRedirectResponse(ctx.response, request, getRouter);
|
|
4768
|
+
} finally {
|
|
4769
|
+
if (router && !cbWillCleanup) {
|
|
4770
|
+
router.serverSsr?.cleanup();
|
|
4771
|
+
}
|
|
4772
|
+
router = null;
|
|
4773
|
+
}
|
|
4774
|
+
};
|
|
4775
|
+
return requestHandler(startRequestResolver);
|
|
4776
|
+
}
|
|
4777
|
+
async function handleRedirectResponse(response, request, getRouter) {
|
|
4778
|
+
if (!isRedirect(response)) {
|
|
4779
|
+
return response;
|
|
4780
|
+
}
|
|
4781
|
+
if (isResolvedRedirect(response)) {
|
|
4782
|
+
if (request.headers.get("x-tsr-serverFn") === "true") {
|
|
4783
|
+
return Response.json(
|
|
4784
|
+
{ ...response.options, isSerializedRedirect: true },
|
|
4785
|
+
{ headers: response.headers }
|
|
4786
|
+
);
|
|
4787
|
+
}
|
|
4788
|
+
return response;
|
|
4789
|
+
}
|
|
4790
|
+
const opts = response.options;
|
|
4791
|
+
if (opts.to && typeof opts.to === "string" && !opts.to.startsWith("/")) {
|
|
4792
|
+
throw new Error(
|
|
4793
|
+
`Server side redirects must use absolute paths via the 'href' or 'to' options. The redirect() method's "to" property accepts an internal path only. Use the "href" property to provide an external URL. Received: ${JSON.stringify(opts)}`
|
|
4794
|
+
);
|
|
4795
|
+
}
|
|
4796
|
+
if (["params", "search", "hash"].some(
|
|
4797
|
+
(d) => typeof opts[d] === "function"
|
|
4798
|
+
)) {
|
|
4799
|
+
throw new Error(
|
|
4800
|
+
`Server side redirects must use static search, params, and hash values and do not support functional values. Received functional values for: ${Object.keys(
|
|
4801
|
+
opts
|
|
4802
|
+
).filter((d) => typeof opts[d] === "function").map((d) => `"${d}"`).join(", ")}`
|
|
4803
|
+
);
|
|
4804
|
+
}
|
|
4805
|
+
const router = await getRouter();
|
|
4806
|
+
const redirect2 = router.resolveRedirect(response);
|
|
4807
|
+
if (request.headers.get("x-tsr-serverFn") === "true") {
|
|
4808
|
+
return Response.json(
|
|
4809
|
+
{ ...response.options, isSerializedRedirect: true },
|
|
4810
|
+
{ headers: response.headers }
|
|
4811
|
+
);
|
|
4812
|
+
}
|
|
4813
|
+
return redirect2;
|
|
4814
|
+
}
|
|
4815
|
+
async function handleServerRoutes({
|
|
4816
|
+
getRouter,
|
|
4817
|
+
request,
|
|
4818
|
+
url,
|
|
4819
|
+
executeRouter,
|
|
4820
|
+
context,
|
|
4821
|
+
executedRequestMiddlewares
|
|
4822
|
+
}) {
|
|
4823
|
+
const router = await getRouter();
|
|
4824
|
+
const rewrittenUrl = executeRewriteInput(router.rewrite, url);
|
|
4825
|
+
const pathname = rewrittenUrl.pathname;
|
|
4826
|
+
const { matchedRoutes, foundRoute, routeParams } = router.getMatchedRoutes(pathname);
|
|
4827
|
+
const isExactMatch = foundRoute && routeParams["**"] === void 0;
|
|
4828
|
+
const routeMiddlewares = [];
|
|
4829
|
+
for (const route of matchedRoutes) {
|
|
4830
|
+
const serverMiddleware = route.options.server?.middleware;
|
|
4831
|
+
if (serverMiddleware) {
|
|
4832
|
+
const flattened = flattenMiddlewares(serverMiddleware);
|
|
4833
|
+
for (const m2 of flattened) {
|
|
4834
|
+
if (!executedRequestMiddlewares.has(m2)) {
|
|
4835
|
+
routeMiddlewares.push(m2.options.server);
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
}
|
|
4840
|
+
const server2 = foundRoute?.options.server;
|
|
4841
|
+
if (server2?.handlers && isExactMatch) {
|
|
4842
|
+
const handlers = typeof server2.handlers === "function" ? server2.handlers({ createHandlers: (d) => d }) : server2.handlers;
|
|
4843
|
+
const requestMethod = request.method.toUpperCase();
|
|
4844
|
+
const handler = handlers[requestMethod] ?? handlers["ANY"];
|
|
4845
|
+
if (handler) {
|
|
4846
|
+
const mayDefer = !!foundRoute.options.component;
|
|
4847
|
+
if (typeof handler === "function") {
|
|
4848
|
+
routeMiddlewares.push(handlerToMiddleware(handler, mayDefer));
|
|
4849
|
+
} else {
|
|
4850
|
+
if (handler.middleware?.length) {
|
|
4851
|
+
const handlerMiddlewares = flattenMiddlewares(handler.middleware);
|
|
4852
|
+
for (const m2 of handlerMiddlewares) {
|
|
4853
|
+
routeMiddlewares.push(m2.options.server);
|
|
4854
|
+
}
|
|
4855
|
+
}
|
|
4856
|
+
if (handler.handler) {
|
|
4857
|
+
routeMiddlewares.push(handlerToMiddleware(handler.handler, mayDefer));
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
routeMiddlewares.push(
|
|
4863
|
+
(ctx2) => executeRouter(ctx2.context, matchedRoutes)
|
|
4864
|
+
);
|
|
4865
|
+
const ctx = await executeMiddleware(routeMiddlewares, {
|
|
4866
|
+
request,
|
|
4867
|
+
context,
|
|
4868
|
+
params: routeParams,
|
|
4869
|
+
pathname
|
|
4870
|
+
});
|
|
4871
|
+
return ctx.response;
|
|
4872
|
+
}
|
|
4873
|
+
const fetch$1 = createStartHandler(defaultStreamHandler);
|
|
4874
|
+
function createServerEntry(entry) {
|
|
4875
|
+
return {
|
|
4876
|
+
async fetch(...args) {
|
|
4877
|
+
return await entry.fetch(...args);
|
|
4878
|
+
}
|
|
4879
|
+
};
|
|
4880
|
+
}
|
|
4881
|
+
const server = createServerEntry({ fetch: fetch$1 });
|
|
4882
|
+
export {
|
|
4883
|
+
TSS_SERVER_FUNCTION as T,
|
|
4884
|
+
getCookie as a,
|
|
4885
|
+
createServerFn as c,
|
|
4886
|
+
createServerEntry,
|
|
4887
|
+
server as default,
|
|
4888
|
+
getServerFnById as g
|
|
4889
|
+
};
|