@qwik.dev/router 2.0.0-beta.42 → 2.0.0-beta.45
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/lib/adapters/azure-swa/vite/index.mjs +2 -1
- package/lib/adapters/bun-server/vite/index.mjs +2 -1
- package/lib/adapters/cloud-run/vite/index.mjs +2 -1
- package/lib/adapters/cloudflare-pages/vite/index.mjs +2 -1
- package/lib/adapters/deno-server/vite/index.mjs +2 -1
- package/lib/adapters/netlify-edge/vite/index.mjs +2 -1
- package/lib/adapters/node-server/vite/index.mjs +2 -1
- package/lib/adapters/shared/vite/index.mjs +35 -31
- package/lib/adapters/ssg/vite/index.mjs +4 -2
- package/lib/adapters/vercel-edge/vite/index.mjs +18 -15
- package/lib/chunks/fs.mjs +26 -23
- package/lib/chunks/head.qwik.mjs +611 -445
- package/lib/chunks/http-error.qwik.mjs +8 -7
- package/lib/chunks/pathname.mjs +9 -8
- package/lib/chunks/request-path.mjs +8 -4
- package/lib/chunks/routes.mjs +14 -14
- package/lib/chunks/server-error.mjs +11 -5
- package/lib/chunks/{url.mjs → static-file.mjs} +13 -2
- package/lib/chunks/system.mjs +18 -17
- package/lib/chunks/user-response.mjs +441 -322
- package/lib/chunks/worker-thread.mjs +97 -88
- package/lib/index.d.ts +47 -59
- package/lib/index.qwik.mjs +551 -497
- package/lib/middleware/aws-lambda/index.mjs +6 -3
- package/lib/middleware/azure-swa/index.mjs +4 -2
- package/lib/middleware/bun/index.mjs +12 -12
- package/lib/middleware/cloudflare-pages/index.mjs +19 -4
- package/lib/middleware/deno/index.mjs +12 -12
- package/lib/middleware/firebase/index.mjs +4 -2
- package/lib/middleware/netlify-edge/index.mjs +4 -2
- package/lib/middleware/node/index.mjs +16 -15
- package/lib/middleware/request-handler/index.mjs +41 -22
- package/lib/middleware/vercel-edge/index.mjs +4 -2
- package/lib/service-worker/index.mjs +2 -1
- package/lib/ssg/index.mjs +20 -16
- package/lib/vite/index.d.ts +1 -1
- package/lib/vite/index.mjs +596 -586
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { A as matchesRouteLoaderId, E as getRouteLoaderValues, J as QACTION_KEY, L as setRouteLoaders, M as resolveRouteLoaderByHash, Q as _asyncRequestStore, T as getRouteLoaderResponse, X as QFN_KEY, Y as QDATA_KEY, Z as Q_ROUTE, a as isPromise, f as FULLPATH_HEADER, g as clearRouteLoaderData, k as loadRouteLoader, r as resolveRouteConfig, w as getRouteLoaderCtx, x as getLoaderRequestEvent } from "./head.qwik.mjs";
|
|
1
2
|
import { t as ensureSlash } from "./pathname.mjs";
|
|
2
|
-
import { C as getRouteLoaderValues, D as loadRouteLoader, G as QACTION_KEY, J as Q_ROUTE, K as QDATA_KEY, N as setRouteLoaders, O as matchesRouteLoaderId, S as getRouteLoaderResponse, Y as _asyncRequestStore, a as isPromise, f as FULLPATH_HEADER, h as clearRouteLoaderData, k as resolveRouteLoaderByHash, q as QFN_KEY, r as resolveRouteConfig, v as getLoaderRequestEvent, x as getRouteLoaderCtx } from "./head.qwik.mjs";
|
|
3
3
|
import { a as QLoaderId, c as resolveValidInternalFullPathname, i as QActionId, s as recognizeRequest, t as IsQAction, u as trimRecognizedInternalPathname } from "./request-path.mjs";
|
|
4
4
|
import { i as RedirectMessage, n as throwIfControlFlowSignal, r as AbortMessage, t as ServerError } from "./server-error.mjs";
|
|
5
5
|
import { inlinedQrl, isDev } from "@qwik.dev/core";
|
|
@@ -7,7 +7,8 @@ import { _deserialize, _serialize, _verifySerializable, isDev as isDev$1 } from
|
|
|
7
7
|
/**
|
|
8
8
|
* FNV-1a 32-bit hash for generating eTags from response data. Cheap to compute, sufficient
|
|
9
9
|
* collision resistance for cache validation (not cryptographic).
|
|
10
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
function hash(str) {
|
|
11
12
|
let hash = 2166136261;
|
|
12
13
|
for (let i = 0; i < str.length; i++) {
|
|
13
14
|
hash ^= str.charCodeAt(i);
|
|
@@ -21,7 +22,8 @@ import { _deserialize, _serialize, _verifySerializable, isDev as isDev$1 } from
|
|
|
21
22
|
* character outside RFC 7232's `etagc` grammar (printable ASCII except DQUOTE — no escape mechanism
|
|
22
23
|
* exists, and non-ASCII bytes are mangled by many HTTP stacks even though `obs-text` technically
|
|
23
24
|
* permits them). Idempotent.
|
|
24
|
-
*/
|
|
25
|
+
*/
|
|
26
|
+
function normalizeETag(raw) {
|
|
25
27
|
let tag = raw.trim();
|
|
26
28
|
if (tag.endsWith("\"") && tag.startsWith("W/\"")) tag = tag.slice(3);
|
|
27
29
|
tag = tag.replace(/[^!#-~]/g, "");
|
|
@@ -35,7 +37,8 @@ function setETagHeader(requestEv, normalizedETag) {
|
|
|
35
37
|
* Set the strong ETag header on the response and check the request's `If-None-Match` against it.
|
|
36
38
|
* The eTag argument must already be normalized. Returns true if a 304 was sent (caller should stop
|
|
37
39
|
* processing).
|
|
38
|
-
*/
|
|
40
|
+
*/
|
|
41
|
+
function performETagMatch(requestEv, normalizedETag) {
|
|
39
42
|
setETagHeader(requestEv, normalizedETag);
|
|
40
43
|
const ifNoneMatch = requestEv.request.headers.get("If-None-Match");
|
|
41
44
|
if (ifNoneMatch) {
|
|
@@ -100,6 +103,20 @@ var UNIT = {
|
|
|
100
103
|
days: 86400,
|
|
101
104
|
weeks: 604800
|
|
102
105
|
};
|
|
106
|
+
var createSetCookieValue = (cookieName, cookieValue, options) => {
|
|
107
|
+
const c = [`${cookieName}=${cookieValue}`];
|
|
108
|
+
if (typeof options.domain === "string") c.push(`Domain=${options.domain}`);
|
|
109
|
+
if (typeof options.maxAge === "number") c.push(`Max-Age=${options.maxAge}`);
|
|
110
|
+
else if (Array.isArray(options.maxAge)) c.push(`Max-Age=${options.maxAge[0] * UNIT[options.maxAge[1]]}`);
|
|
111
|
+
else if (typeof options.expires === "number" || typeof options.expires == "string") c.push(`Expires=${options.expires}`);
|
|
112
|
+
else if (options.expires instanceof Date) c.push(`Expires=${options.expires.toUTCString()}`);
|
|
113
|
+
if (options.httpOnly) c.push("HttpOnly");
|
|
114
|
+
if (typeof options.path === "string") c.push(`Path=${options.path}`);
|
|
115
|
+
const sameSite = resolveSameSite(options.sameSite);
|
|
116
|
+
if (sameSite) c.push(`SameSite=${sameSite}`);
|
|
117
|
+
if (options.secure) c.push("Secure");
|
|
118
|
+
return c.join("; ");
|
|
119
|
+
};
|
|
103
120
|
function tryDecodeUriComponent(str) {
|
|
104
121
|
try {
|
|
105
122
|
return decodeURIComponent(str);
|
|
@@ -123,20 +140,6 @@ function resolveSameSite(sameSite) {
|
|
|
123
140
|
if (sameSite === false) return "None";
|
|
124
141
|
if (sameSite) return SAMESITE[sameSite];
|
|
125
142
|
}
|
|
126
|
-
var createSetCookieValue = (cookieName, cookieValue, options) => {
|
|
127
|
-
const c = [`${cookieName}=${cookieValue}`];
|
|
128
|
-
if (typeof options.domain === "string") c.push(`Domain=${options.domain}`);
|
|
129
|
-
if (typeof options.maxAge === "number") c.push(`Max-Age=${options.maxAge}`);
|
|
130
|
-
else if (Array.isArray(options.maxAge)) c.push(`Max-Age=${options.maxAge[0] * UNIT[options.maxAge[1]]}`);
|
|
131
|
-
else if (typeof options.expires === "number" || typeof options.expires == "string") c.push(`Expires=${options.expires}`);
|
|
132
|
-
else if (options.expires instanceof Date) c.push(`Expires=${options.expires.toUTCString()}`);
|
|
133
|
-
if (options.httpOnly) c.push("HttpOnly");
|
|
134
|
-
if (typeof options.path === "string") c.push(`Path=${options.path}`);
|
|
135
|
-
const sameSite = resolveSameSite(options.sameSite);
|
|
136
|
-
if (sameSite) c.push(`SameSite=${sameSite}`);
|
|
137
|
-
if (options.secure) c.push("Secure");
|
|
138
|
-
return c.join("; ");
|
|
139
|
-
};
|
|
140
143
|
var REQ_COOKIE = Symbol("request-cookies");
|
|
141
144
|
var RES_COOKIE = Symbol("response-cookies");
|
|
142
145
|
var LIVE_COOKIE = Symbol("live-cookies");
|
|
@@ -192,7 +195,8 @@ var Cookie = class {
|
|
|
192
195
|
return Object.values(this[RES_COOKIE]);
|
|
193
196
|
}
|
|
194
197
|
};
|
|
195
|
-
/** @public */
|
|
198
|
+
/** @public */
|
|
199
|
+
var mergeHeadersCookies = (headers, cookies) => {
|
|
196
200
|
const cookieHeaders = cookies.headers();
|
|
197
201
|
if (cookieHeaders.length > 0) {
|
|
198
202
|
const newHeaders = new Headers(headers);
|
|
@@ -201,10 +205,12 @@ var Cookie = class {
|
|
|
201
205
|
}
|
|
202
206
|
return headers;
|
|
203
207
|
};
|
|
204
|
-
/** @public */
|
|
208
|
+
/** @public */
|
|
209
|
+
var RewriteMessage = class extends AbortMessage {
|
|
205
210
|
pathname;
|
|
206
211
|
constructor(pathname) {
|
|
207
|
-
super()
|
|
212
|
+
super();
|
|
213
|
+
this.pathname = pathname;
|
|
208
214
|
}
|
|
209
215
|
};
|
|
210
216
|
var encoder = /*#__PURE__*/ new TextEncoder();
|
|
@@ -225,106 +231,8 @@ var RequestEvSharedNonce = "@nonce";
|
|
|
225
231
|
var RequestEvIsRewrite = "@rewrite";
|
|
226
232
|
var RequestEvShareServerTiming = "@serverTiming";
|
|
227
233
|
var RequestEvETagCacheKey = "@eTagCacheKey";
|
|
234
|
+
var RequestEvErrorBoundaryCaught = "@errorBoundaryCaught";
|
|
228
235
|
var RequestEvHttpStatusMessage = "@httpStatusMessage";
|
|
229
|
-
function getRequestRoute(requestEv) {
|
|
230
|
-
return requestEv[RequestEvRoute];
|
|
231
|
-
}
|
|
232
|
-
function getRequestMode(requestEv) {
|
|
233
|
-
return requestEv[RequestEvMode];
|
|
234
|
-
}
|
|
235
|
-
var ABORT_INDEX = Number.MAX_SAFE_INTEGER;
|
|
236
|
-
var isDangerousKey = (k) => k === "__proto__" || k === "constructor" || k === "prototype";
|
|
237
|
-
var isArrayIndexKey = (k) => /^(0|[1-9]\d*)$/.test(k);
|
|
238
|
-
var createFormPathNode = () => ({
|
|
239
|
-
children: /* @__PURE__ */ new Map(),
|
|
240
|
-
isArray: true
|
|
241
|
-
});
|
|
242
|
-
var getFormPathTree = (formData) => {
|
|
243
|
-
const root = createFormPathNode();
|
|
244
|
-
for (const [name] of formData) {
|
|
245
|
-
const keys = name.split(".");
|
|
246
|
-
let hasDangerousKey = false;
|
|
247
|
-
for (const key of keys) if (isDangerousKey(key)) {
|
|
248
|
-
hasDangerousKey = true;
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
if (hasDangerousKey) continue;
|
|
252
|
-
let pathNode = root;
|
|
253
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
254
|
-
const key = keys[i];
|
|
255
|
-
if (key.endsWith("[]")) break;
|
|
256
|
-
let childNode = pathNode.children.get(key);
|
|
257
|
-
if (!childNode) {
|
|
258
|
-
childNode = createFormPathNode();
|
|
259
|
-
pathNode.children.set(key, childNode);
|
|
260
|
-
}
|
|
261
|
-
if (!isArrayIndexKey(keys[i + 1])) childNode.isArray = false;
|
|
262
|
-
pathNode = childNode;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return root;
|
|
266
|
-
};
|
|
267
|
-
var formToObj = (formData) => {
|
|
268
|
-
/**
|
|
269
|
-
* Convert FormData to object Handle nested form input using dot notation Handle array input using
|
|
270
|
-
* indexed dot notation (name.0, name.0) or bracket notation (name[]), the later is needed for
|
|
271
|
-
* multiselects Create values object by form data entries
|
|
272
|
-
*/ const values = Object.create(null);
|
|
273
|
-
const pathTree = getFormPathTree(formData);
|
|
274
|
-
for (const [name, value] of formData) {
|
|
275
|
-
const keys = name.split(".");
|
|
276
|
-
let hasDangerousKey = false;
|
|
277
|
-
for (let i = 0; i < keys.length; i++) if (isDangerousKey(keys[i])) {
|
|
278
|
-
hasDangerousKey = true;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
if (hasDangerousKey) continue;
|
|
282
|
-
let object = values;
|
|
283
|
-
let pathNode = pathTree;
|
|
284
|
-
for (let i = 0; i < keys.length; i++) {
|
|
285
|
-
const key = keys[i];
|
|
286
|
-
if (key.endsWith("[]")) {
|
|
287
|
-
const arrayKey = key.slice(0, -2);
|
|
288
|
-
if (isDangerousKey(arrayKey)) break;
|
|
289
|
-
const existingValue = object[arrayKey];
|
|
290
|
-
if (existingValue !== void 0 && !Array.isArray(existingValue)) break;
|
|
291
|
-
object[arrayKey] = existingValue || [];
|
|
292
|
-
object[arrayKey].push(value);
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
if (Array.isArray(object) && !isArrayIndexKey(key)) break;
|
|
296
|
-
if (i < keys.length - 1) {
|
|
297
|
-
const childNode = pathNode.children.get(key);
|
|
298
|
-
const nextValue = object[key];
|
|
299
|
-
if (nextValue !== void 0) {
|
|
300
|
-
object = nextValue;
|
|
301
|
-
pathNode = childNode;
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
object = object[key] = childNode.isArray ? [] : Object.create(null);
|
|
305
|
-
pathNode = childNode;
|
|
306
|
-
} else object[key] = value;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return values;
|
|
310
|
-
};
|
|
311
|
-
var parseRequest = async ({ request, method, query }, sharedMap) => {
|
|
312
|
-
const type = getContentType(request.headers);
|
|
313
|
-
if (type === "application/x-www-form-urlencoded" || type === "multipart/form-data") {
|
|
314
|
-
const formData = await request.formData();
|
|
315
|
-
sharedMap.set(RequestEvSharedActionFormData, formData);
|
|
316
|
-
return formToObj(formData);
|
|
317
|
-
} else if (type === "application/json") return await request.json();
|
|
318
|
-
else if (type === "application/qwik-json") {
|
|
319
|
-
if (method === "GET" && query.has("qdata")) {
|
|
320
|
-
const data = query.get(QDATA_KEY);
|
|
321
|
-
if (data) try {
|
|
322
|
-
return await _deserialize(decodeURIComponent(data));
|
|
323
|
-
} catch {}
|
|
324
|
-
}
|
|
325
|
-
return await _deserialize(await request.text());
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
236
|
function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, basePathname, resolved) {
|
|
329
237
|
const { request, platform, env } = serverRequestEv;
|
|
330
238
|
const sharedMap = /* @__PURE__ */ new Map();
|
|
@@ -443,13 +351,13 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, baseP
|
|
|
443
351
|
check();
|
|
444
352
|
headers.set(target, createCacheControl(cacheControl));
|
|
445
353
|
},
|
|
446
|
-
resolveValue: async (loaderOrAction) => {
|
|
354
|
+
resolveValue: (async (loaderOrAction) => {
|
|
447
355
|
if (loaderOrAction.__brand === "server_loader") {
|
|
448
356
|
const loaderValues = getRouteLoaderValues(requestEv);
|
|
449
357
|
if (loaderOrAction.__id in loaderValues) return loaderValues[loaderOrAction.__id];
|
|
450
358
|
return loadRouteLoader(loaderOrAction, requestEv);
|
|
451
359
|
}
|
|
452
|
-
},
|
|
360
|
+
}),
|
|
453
361
|
status: (statusCode) => {
|
|
454
362
|
if (typeof statusCode === "number") {
|
|
455
363
|
check();
|
|
@@ -471,8 +379,8 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, baseP
|
|
|
471
379
|
check();
|
|
472
380
|
status = statusCode;
|
|
473
381
|
if (url) {
|
|
474
|
-
if (
|
|
475
|
-
const fixedURL = url.replace(
|
|
382
|
+
if (/^[/\\]{2,}/.test(url) || /([^:])[/\\]{2,}/.test(url)) {
|
|
383
|
+
const fixedURL = url.replace(/^[/\\]{2,}/, "/").replace(/([^:])[/\\]{2,}/g, "$1/");
|
|
476
384
|
console.warn(`Redirect URL ${url} is invalid, fixing to ${fixedURL}`);
|
|
477
385
|
url = fixedURL;
|
|
478
386
|
}
|
|
@@ -534,6 +442,107 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, baseP
|
|
|
534
442
|
};
|
|
535
443
|
return requestEv;
|
|
536
444
|
}
|
|
445
|
+
function getRequestRoute(requestEv) {
|
|
446
|
+
return requestEv[RequestEvRoute];
|
|
447
|
+
}
|
|
448
|
+
function getRequestMode(requestEv) {
|
|
449
|
+
return requestEv[RequestEvMode];
|
|
450
|
+
}
|
|
451
|
+
var ABORT_INDEX = Number.MAX_SAFE_INTEGER;
|
|
452
|
+
var parseRequest = async ({ request, method, query }, sharedMap) => {
|
|
453
|
+
const type = getContentType(request.headers);
|
|
454
|
+
if (type === "application/x-www-form-urlencoded" || type === "multipart/form-data") {
|
|
455
|
+
const formData = await request.formData();
|
|
456
|
+
sharedMap.set(RequestEvSharedActionFormData, formData);
|
|
457
|
+
return formToObj(formData);
|
|
458
|
+
} else if (type === "application/json") return await request.json();
|
|
459
|
+
else if (type === "application/qwik-json") {
|
|
460
|
+
if (method === "GET" && query.has("qdata")) {
|
|
461
|
+
const data = query.get(QDATA_KEY);
|
|
462
|
+
if (data) try {
|
|
463
|
+
return await _deserialize(decodeURIComponent(data));
|
|
464
|
+
} catch {}
|
|
465
|
+
}
|
|
466
|
+
return await _deserialize(await request.text());
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
var isDangerousKey = (k) => k === "__proto__" || k === "constructor" || k === "prototype";
|
|
470
|
+
var MAX_FORM_ARRAY_LENGTH = 1e4;
|
|
471
|
+
var isArrayIndexKey = (k) => /^(0|[1-9]\d*)$/.test(k) && Number(k) < MAX_FORM_ARRAY_LENGTH;
|
|
472
|
+
var createFormPathNode = () => ({
|
|
473
|
+
children: /* @__PURE__ */ new Map(),
|
|
474
|
+
isArray: true
|
|
475
|
+
});
|
|
476
|
+
var getFormPathTree = (formData) => {
|
|
477
|
+
const root = createFormPathNode();
|
|
478
|
+
for (const [name] of formData) {
|
|
479
|
+
const keys = name.split(".");
|
|
480
|
+
let hasDangerousKey = false;
|
|
481
|
+
for (const key of keys) if (isDangerousKey(key)) {
|
|
482
|
+
hasDangerousKey = true;
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
if (hasDangerousKey) continue;
|
|
486
|
+
let pathNode = root;
|
|
487
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
488
|
+
const key = keys[i];
|
|
489
|
+
if (key.endsWith("[]")) break;
|
|
490
|
+
let childNode = pathNode.children.get(key);
|
|
491
|
+
if (!childNode) {
|
|
492
|
+
childNode = createFormPathNode();
|
|
493
|
+
pathNode.children.set(key, childNode);
|
|
494
|
+
}
|
|
495
|
+
if (!isArrayIndexKey(keys[i + 1])) childNode.isArray = false;
|
|
496
|
+
pathNode = childNode;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return root;
|
|
500
|
+
};
|
|
501
|
+
var formToObj = (formData) => {
|
|
502
|
+
/**
|
|
503
|
+
* Convert FormData to object Handle nested form input using dot notation Handle array input using
|
|
504
|
+
* indexed dot notation (name.0, name.0) or bracket notation (name[]), the later is needed for
|
|
505
|
+
* multiselects Create values object by form data entries
|
|
506
|
+
*/
|
|
507
|
+
const values = Object.create(null);
|
|
508
|
+
const pathTree = getFormPathTree(formData);
|
|
509
|
+
for (const [name, value] of formData) {
|
|
510
|
+
const keys = name.split(".");
|
|
511
|
+
let hasDangerousKey = false;
|
|
512
|
+
for (let i = 0; i < keys.length; i++) if (isDangerousKey(keys[i])) {
|
|
513
|
+
hasDangerousKey = true;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
if (hasDangerousKey) continue;
|
|
517
|
+
let object = values;
|
|
518
|
+
let pathNode = pathTree;
|
|
519
|
+
for (let i = 0; i < keys.length; i++) {
|
|
520
|
+
const key = keys[i];
|
|
521
|
+
if (key.endsWith("[]")) {
|
|
522
|
+
const arrayKey = key.slice(0, -2);
|
|
523
|
+
if (isDangerousKey(arrayKey)) break;
|
|
524
|
+
const existingValue = object[arrayKey];
|
|
525
|
+
if (existingValue !== void 0 && !Array.isArray(existingValue)) break;
|
|
526
|
+
object[arrayKey] = existingValue || [];
|
|
527
|
+
object[arrayKey].push(value);
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
if (Array.isArray(object) && !isArrayIndexKey(key)) break;
|
|
531
|
+
if (i < keys.length - 1) {
|
|
532
|
+
const childNode = pathNode.children.get(key);
|
|
533
|
+
const nextValue = object[key];
|
|
534
|
+
if (nextValue !== void 0) {
|
|
535
|
+
object = nextValue;
|
|
536
|
+
pathNode = childNode;
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
object = object[key] = childNode.isArray ? [] : Object.create(null);
|
|
540
|
+
pathNode = childNode;
|
|
541
|
+
} else object[key] = value;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return values;
|
|
545
|
+
};
|
|
537
546
|
var MAX_CACHE_SIZE = typeof globalThis.__SSR_CACHE_SIZE__ === "number" ? globalThis.__SSR_CACHE_SIZE__ : 50;
|
|
538
547
|
function createLruCache() {
|
|
539
548
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -565,7 +574,8 @@ var loaderCache = createLruCache();
|
|
|
565
574
|
/**
|
|
566
575
|
* Resolve an eTag value from a ContentModuleETag (string, function, or undefined). Returns the eTag
|
|
567
576
|
* string or null.
|
|
568
|
-
*/
|
|
577
|
+
*/
|
|
578
|
+
function resolveETag(eTagExport, headProps) {
|
|
569
579
|
if (eTagExport === void 0) return null;
|
|
570
580
|
if (typeof eTagExport === "function") return eTagExport(headProps);
|
|
571
581
|
return eTagExport;
|
|
@@ -573,31 +583,38 @@ var loaderCache = createLruCache();
|
|
|
573
583
|
/**
|
|
574
584
|
* Resolve a cache key from a CacheKeyFn. The default key callback is only called when `cacheKey ===
|
|
575
585
|
* true`.
|
|
576
|
-
*/
|
|
586
|
+
*/
|
|
587
|
+
function resolveCacheKey(cacheKeyExport, defaultKey, requestEv, eTag) {
|
|
577
588
|
if (cacheKeyExport === true) return defaultKey(requestEv, eTag);
|
|
578
589
|
if (typeof cacheKeyExport !== "function") return "";
|
|
579
590
|
return cacheKeyExport(requestEv, eTag) || "";
|
|
580
591
|
}
|
|
581
|
-
/** Build the default SSR cache key. eTag slot is dropped when no eTag was resolved. */
|
|
592
|
+
/** Build the default SSR cache key. eTag slot is dropped when no eTag was resolved. */
|
|
593
|
+
function defaultSsrCacheKey(requestEv, eTag) {
|
|
582
594
|
const status = requestEv.status();
|
|
583
595
|
const pathname = requestEv.url.pathname;
|
|
584
596
|
return eTag ? `${status}|${eTag}|${pathname}` : `${status}|${pathname}`;
|
|
585
597
|
}
|
|
586
|
-
/** Build the default loader cache key. eTag slot is dropped when no eTag was resolved. */
|
|
598
|
+
/** Build the default loader cache key. eTag slot is dropped when no eTag was resolved. */
|
|
599
|
+
function defaultLoaderCacheKey(requestEv, eTag) {
|
|
587
600
|
const loaderId = requestEv.sharedMap.get(QLoaderId);
|
|
588
601
|
const base = `${requestEv.url.pathname}|${requestEv.url.search}|${loaderId}`;
|
|
589
602
|
return eTag ? `${base}|${eTag}` : base;
|
|
590
603
|
}
|
|
591
|
-
/** Get a cached SSR entry by key (LRU touch). */
|
|
604
|
+
/** Get a cached SSR entry by key (LRU touch). */
|
|
605
|
+
function getCachedSsr(key) {
|
|
592
606
|
return ssrCache.get(key);
|
|
593
607
|
}
|
|
594
|
-
/** Cache an SSR entry by key, evicting the least recently used entry if at capacity. */
|
|
608
|
+
/** Cache an SSR entry by key, evicting the least recently used entry if at capacity. */
|
|
609
|
+
function setCachedSsr(key, entry) {
|
|
595
610
|
ssrCache.set(key, entry);
|
|
596
611
|
}
|
|
597
|
-
/** Get a cached loader entry by key (LRU touch). */
|
|
612
|
+
/** Get a cached loader entry by key (LRU touch). */
|
|
613
|
+
function getCachedLoader(key) {
|
|
598
614
|
return loaderCache.get(key);
|
|
599
615
|
}
|
|
600
|
-
/** Cache a loader entry by key, evicting the least recently used entry if at capacity. */
|
|
616
|
+
/** Cache a loader entry by key, evicting the least recently used entry if at capacity. */
|
|
617
|
+
function setCachedLoader(key, entry) {
|
|
601
618
|
loaderCache.set(key, entry);
|
|
602
619
|
}
|
|
603
620
|
/**
|
|
@@ -607,7 +624,8 @@ var loaderCache = createLruCache();
|
|
|
607
624
|
* cleared.
|
|
608
625
|
*
|
|
609
626
|
* @public
|
|
610
|
-
*/
|
|
627
|
+
*/
|
|
628
|
+
function clearSsrCache(cacheKey) {
|
|
611
629
|
ssrCache.clear(cacheKey);
|
|
612
630
|
}
|
|
613
631
|
/**
|
|
@@ -617,59 +635,25 @@ var loaderCache = createLruCache();
|
|
|
617
635
|
* cleared.
|
|
618
636
|
*
|
|
619
637
|
* @public
|
|
620
|
-
*/
|
|
638
|
+
*/
|
|
639
|
+
function clearLoaderCache(cacheKey) {
|
|
621
640
|
loaderCache.clear(cacheKey);
|
|
622
641
|
}
|
|
623
642
|
/**
|
|
624
643
|
* Create per-loader request event views. Loader-specific URL/search data is scoped to the view,
|
|
625
644
|
* while request-wide state (headers, cookies, loader value maps, etc.) still delegates to the
|
|
626
645
|
* original request event.
|
|
627
|
-
*/
|
|
646
|
+
*/
|
|
647
|
+
function createLoaderRequestEventFactory(requestEv) {
|
|
628
648
|
return (loader) => getLoaderRequestEvent(loader, requestEv);
|
|
629
649
|
}
|
|
630
650
|
/**
|
|
631
|
-
* Resolve the loader's cacheControl option. Loaders default to `no-cache` so the browser always
|
|
632
|
-
* revalidates; pair with `eTag` for cheap 304s. A function form may return `null` to skip the
|
|
633
|
-
* header entirely.
|
|
634
|
-
*/ function resolveLoaderCacheControl(option, requestEv) {
|
|
635
|
-
const value = typeof option === "function" ? option(requestEv) : option;
|
|
636
|
-
return value === void 0 ? "no-cache" : value;
|
|
637
|
-
}
|
|
638
|
-
async function runBlockingLoadersBeforeTarget(routeLoaders, targetLoader, requestEv) {
|
|
639
|
-
for (const loader of routeLoaders) {
|
|
640
|
-
if (loader === targetLoader) return;
|
|
641
|
-
if (loader.__blockSSR) await loadRouteLoader(loader, requestEv);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
function setLoaderData(requestEv, routeLoaders, loaderPaths) {
|
|
645
|
-
if (loaderPaths) Object.assign(getRouteLoaderCtx(requestEv).loaderPaths, loaderPaths);
|
|
646
|
-
setRouteLoaders(requestEv, routeLoaders);
|
|
647
|
-
}
|
|
648
|
-
/** Resolve eTag from a static string or function (before running the loader). */ function resolvePreETag(eTagOption, requestEv) {
|
|
649
|
-
if (typeof eTagOption === "string") return normalizeETag(eTagOption);
|
|
650
|
-
const result = eTagOption(requestEv);
|
|
651
|
-
return result ? normalizeETag(result) : "";
|
|
652
|
-
}
|
|
653
|
-
function addVaryHeader(requestEv, value) {
|
|
654
|
-
const vary = requestEv.headers.get("Vary");
|
|
655
|
-
if (!vary) {
|
|
656
|
-
requestEv.headers.set("Vary", value);
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
if (!vary.split(",").map((item) => item.trim().toLowerCase()).includes(value.toLowerCase())) requestEv.headers.set("Vary", `${vary}, ${value}`);
|
|
660
|
-
}
|
|
661
|
-
async function sendLoaderResponse(requestEv, data, cacheControl) {
|
|
662
|
-
requestEv.headers.set("Content-Type", "application/json; charset=utf-8");
|
|
663
|
-
addVaryHeader(requestEv, FULLPATH_HEADER);
|
|
664
|
-
if (cacheControl !== null && !requestEv.headers.has("Cache-Control")) requestEv.cacheControl(cacheControl);
|
|
665
|
-
requestEv.send(200, data);
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
651
|
* Handler that executes the requested loader and returns the result as JSON. Runs AFTER
|
|
669
652
|
* plugin/route middleware, so middleware redirects/errors are handled by `jsonRequestWrapper`. The
|
|
670
653
|
* loader function's own redirects/errors are caught by getRouteLoaderResponse and serialized in the
|
|
671
654
|
* LoaderResponse envelope ({ d, r, e }).
|
|
672
|
-
*/
|
|
655
|
+
*/
|
|
656
|
+
function loaderHandler(routeLoaders, loaderPaths) {
|
|
673
657
|
return async (requestEvent) => {
|
|
674
658
|
const requestEv = requestEvent;
|
|
675
659
|
if (!requestEv.sharedMap.has("@isQLoader")) return;
|
|
@@ -711,7 +695,47 @@ async function sendLoaderResponse(requestEv, data, cacheControl) {
|
|
|
711
695
|
await sendLoaderResponse(requestEv, data, cacheControl);
|
|
712
696
|
};
|
|
713
697
|
}
|
|
714
|
-
/**
|
|
698
|
+
/**
|
|
699
|
+
* Resolve the loader's cacheControl option. Loaders default to `no-cache` so the browser always
|
|
700
|
+
* revalidates; pair with `eTag` for cheap 304s. A function form may return `null` to skip the
|
|
701
|
+
* header entirely.
|
|
702
|
+
*/
|
|
703
|
+
function resolveLoaderCacheControl(option, requestEv) {
|
|
704
|
+
const value = typeof option === "function" ? option(requestEv) : option;
|
|
705
|
+
return value === void 0 ? "no-cache" : value;
|
|
706
|
+
}
|
|
707
|
+
async function runBlockingLoadersBeforeTarget(routeLoaders, targetLoader, requestEv) {
|
|
708
|
+
for (const loader of routeLoaders) {
|
|
709
|
+
if (loader === targetLoader) return;
|
|
710
|
+
if (loader.__blockSSR) await loadRouteLoader(loader, requestEv);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function setLoaderData(requestEv, routeLoaders, loaderPaths) {
|
|
714
|
+
if (loaderPaths) Object.assign(getRouteLoaderCtx(requestEv).loaderPaths, loaderPaths);
|
|
715
|
+
setRouteLoaders(requestEv, routeLoaders);
|
|
716
|
+
}
|
|
717
|
+
/** Resolve eTag from a static string or function (before running the loader). */
|
|
718
|
+
function resolvePreETag(eTagOption, requestEv) {
|
|
719
|
+
if (typeof eTagOption === "string") return normalizeETag(eTagOption);
|
|
720
|
+
const result = eTagOption(requestEv);
|
|
721
|
+
return result ? normalizeETag(result) : "";
|
|
722
|
+
}
|
|
723
|
+
async function sendLoaderResponse(requestEv, data, cacheControl) {
|
|
724
|
+
requestEv.headers.set("Content-Type", "application/json; charset=utf-8");
|
|
725
|
+
addVaryHeader(requestEv, FULLPATH_HEADER);
|
|
726
|
+
if (cacheControl !== null && !requestEv.headers.has("Cache-Control")) requestEv.cacheControl(cacheControl);
|
|
727
|
+
requestEv.send(200, data);
|
|
728
|
+
}
|
|
729
|
+
function addVaryHeader(requestEv, value) {
|
|
730
|
+
const vary = requestEv.headers.get("Vary");
|
|
731
|
+
if (!vary) {
|
|
732
|
+
requestEv.headers.set("Vary", value);
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
if (!vary.split(",").map((item) => item.trim().toLowerCase()).includes(value.toLowerCase())) requestEv.headers.set("Vary", `${vary}, ${value}`);
|
|
736
|
+
}
|
|
737
|
+
/** Serialize and send a JSON response (used by error/redirect paths in jsonRequestWrapper). */
|
|
738
|
+
async function sendJsonResponse(requestEv, responseData, status = 200) {
|
|
715
739
|
const data = await _serialize(responseData);
|
|
716
740
|
requestEv.headers.set("Content-Type", "application/json; charset=utf-8");
|
|
717
741
|
requestEv.send(status, data);
|
|
@@ -730,7 +754,8 @@ async function sendActionResponse(requestEv, responseData) {
|
|
|
730
754
|
* By calling `await next()` inside a try/catch, middleware redirects and errors are captured and
|
|
731
755
|
* returned as JSON envelopes instead of HTTP redirects/error pages. This keeps SPA navigation
|
|
732
756
|
* intact on the client.
|
|
733
|
-
*/
|
|
757
|
+
*/
|
|
758
|
+
function jsonRequestWrapper() {
|
|
734
759
|
return async (requestEvent) => {
|
|
735
760
|
const requestEv = requestEvent;
|
|
736
761
|
const isLoader = requestEv.internalRequest === "loader";
|
|
@@ -770,38 +795,6 @@ async function sendActionResponse(requestEv, responseData) {
|
|
|
770
795
|
}
|
|
771
796
|
};
|
|
772
797
|
}
|
|
773
|
-
function verifySerializable$1(data, qrl) {
|
|
774
|
-
try {
|
|
775
|
-
_verifySerializable(data, void 0);
|
|
776
|
-
} catch (e) {
|
|
777
|
-
if (e instanceof Error && qrl.dev) e.loc = qrl.dev;
|
|
778
|
-
throw e;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
async function measure$1(requestEv, name, fn) {
|
|
782
|
-
const start = performance.now();
|
|
783
|
-
try {
|
|
784
|
-
return await fn();
|
|
785
|
-
} finally {
|
|
786
|
-
const duration = performance.now() - start;
|
|
787
|
-
let measurements = requestEv.sharedMap.get("@serverTiming");
|
|
788
|
-
if (!measurements) requestEv.sharedMap.set("@serverTiming", measurements = []);
|
|
789
|
-
measurements.push([name, duration]);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
async function runValidators(requestEv, validators, data, devMode) {
|
|
793
|
-
let lastResult = {
|
|
794
|
-
success: true,
|
|
795
|
-
data
|
|
796
|
-
};
|
|
797
|
-
if (validators) for (const validator of validators) {
|
|
798
|
-
if (devMode) lastResult = await measure$1(requestEv, `validator$`, () => validator.validate(requestEv, data));
|
|
799
|
-
else lastResult = await validator.validate(requestEv, data);
|
|
800
|
-
if (!lastResult.success) return lastResult;
|
|
801
|
-
else data = lastResult.data;
|
|
802
|
-
}
|
|
803
|
-
return lastResult;
|
|
804
|
-
}
|
|
805
798
|
/**
|
|
806
799
|
* Handler for action requests (`?qaction={actionId}`).
|
|
807
800
|
*
|
|
@@ -811,7 +804,8 @@ async function runValidators(requestEv, validators, data, devMode) {
|
|
|
811
804
|
* If the action has no `invalidate` list, the client invalidates all current route loaders unless
|
|
812
805
|
* strict loaders mode treats it as `invalidate: []`. If `invalidate` is specified, only those
|
|
813
806
|
* loader hashes are sent for the client to re-fetch.
|
|
814
|
-
*/
|
|
807
|
+
*/
|
|
808
|
+
function actionHandler(routeActions) {
|
|
815
809
|
return async (requestEvent) => {
|
|
816
810
|
const requestEv = requestEvent;
|
|
817
811
|
if (!requestEv.sharedMap.has("@isQAction")) return;
|
|
@@ -851,24 +845,82 @@ async function runValidators(requestEv, validators, data, devMode) {
|
|
|
851
845
|
requestEv.send(requestEv.status(), serialized);
|
|
852
846
|
};
|
|
853
847
|
}
|
|
848
|
+
async function runValidators(requestEv, validators, data, devMode) {
|
|
849
|
+
let lastResult = {
|
|
850
|
+
success: true,
|
|
851
|
+
data
|
|
852
|
+
};
|
|
853
|
+
if (validators) for (const validator of validators) {
|
|
854
|
+
if (devMode) lastResult = await measure$1(requestEv, `validator$`, () => validator.validate(requestEv, data));
|
|
855
|
+
else lastResult = await validator.validate(requestEv, data);
|
|
856
|
+
if (!lastResult.success) return lastResult;
|
|
857
|
+
else data = lastResult.data;
|
|
858
|
+
}
|
|
859
|
+
return lastResult;
|
|
860
|
+
}
|
|
861
|
+
function verifySerializable$1(data, qrl) {
|
|
862
|
+
try {
|
|
863
|
+
_verifySerializable(data, void 0);
|
|
864
|
+
} catch (e) {
|
|
865
|
+
if (e instanceof Error && qrl.dev) e.loc = qrl.dev;
|
|
866
|
+
throw e;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
async function measure$1(requestEv, name, fn) {
|
|
870
|
+
const start = performance.now();
|
|
871
|
+
try {
|
|
872
|
+
return await fn();
|
|
873
|
+
} finally {
|
|
874
|
+
const duration = performance.now() - start;
|
|
875
|
+
let measurements = requestEv.sharedMap.get("@serverTiming");
|
|
876
|
+
if (!measurements) requestEv.sharedMap.set("@serverTiming", measurements = []);
|
|
877
|
+
measurements.push([name, duration]);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* A set of static paths generated by the SSG, including loader json. Routes always have a trailing
|
|
882
|
+
* slash, short for `.../index.html`
|
|
883
|
+
*/
|
|
854
884
|
var staticPaths = /* @__PURE__ */ new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]);
|
|
855
885
|
/**
|
|
886
|
+
* Check if the current pathname needs a redirect due to trailing slash mismatch. If we're not sure,
|
|
887
|
+
* we fall through.
|
|
888
|
+
*
|
|
889
|
+
* Note that we ignore build/ and assets/, those never need trailing slash redirects.
|
|
890
|
+
*
|
|
891
|
+
* @returns The canonical path with the correct trailing slash if a redirect is needed, otherwise
|
|
892
|
+
* `undefined`.
|
|
893
|
+
*/
|
|
894
|
+
function getStaticPathRedirect(method, url) {
|
|
895
|
+
const { pathname, search } = url;
|
|
896
|
+
if (method.toUpperCase() !== "GET" || pathname === "/" || !pathname.startsWith("/") || pathname.startsWith("//")) return;
|
|
897
|
+
const hasTrailingSlash = pathname.endsWith("/");
|
|
898
|
+
const routesHaveTrailingSlash = !globalThis.__NO_TRAILING_SLASH__;
|
|
899
|
+
if (hasTrailingSlash === routesHaveTrailingSlash) return;
|
|
900
|
+
const canonicalPathname = hasTrailingSlash ? pathname.slice(0, -1) : pathname + "/";
|
|
901
|
+
if (staticPaths.has(canonicalPathname) || !routesHaveTrailingSlash && staticPaths.has(pathname)) return canonicalPathname + search;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
856
904
|
* Decide whether a given request path is a static path, for optimizing file access.
|
|
857
905
|
*
|
|
858
906
|
* @internal
|
|
859
|
-
*/
|
|
907
|
+
*/
|
|
908
|
+
function isStaticPath(method, url) {
|
|
860
909
|
method = method.toUpperCase();
|
|
861
910
|
if (method !== "GET" && method !== "HEAD") return false;
|
|
862
911
|
const p = url.pathname;
|
|
863
|
-
|
|
864
|
-
if (p.startsWith(
|
|
912
|
+
const basePathname = globalThis.__QWIK_ROUTER_BASE_PATHNAME__ || "/";
|
|
913
|
+
if (p.startsWith(basePathname + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/")) return true;
|
|
914
|
+
if (p.startsWith(basePathname + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/")) return true;
|
|
915
|
+
if (globalThis.__NO_TRAILING_SLASH__ && p !== "/") return !p.endsWith("/") && (staticPaths.has(p) || staticPaths.has(p + "/"));
|
|
865
916
|
return staticPaths.has(p);
|
|
866
917
|
}
|
|
867
918
|
/**
|
|
868
919
|
* Hypertext Transfer Protocol (HTTP) response status codes.
|
|
869
920
|
*
|
|
870
921
|
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
|
|
871
|
-
*/
|
|
922
|
+
*/
|
|
923
|
+
var HttpStatus = /* @__PURE__ */ function(HttpStatus) {
|
|
872
924
|
/**
|
|
873
925
|
* The server has received the request headers and the client should proceed to send the request
|
|
874
926
|
* body (in the case of a request for which a body needs to be sent; for example, a POST request).
|
|
@@ -877,59 +929,74 @@ var staticPaths = /* @__PURE__ */ new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]
|
|
|
877
929
|
* Expect: 100-continue as a header in its initial request and receive a 100 Continue status code
|
|
878
930
|
* in response before sending the body. The response 417 Expectation Failed indicates the request
|
|
879
931
|
* should not be continued.
|
|
880
|
-
*/
|
|
881
|
-
|
|
932
|
+
*/
|
|
933
|
+
HttpStatus[HttpStatus["Continue"] = 100] = "Continue";
|
|
934
|
+
/** The requester has asked the server to switch protocols and the server has agreed to do so. */
|
|
935
|
+
HttpStatus[HttpStatus["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
882
936
|
/**
|
|
883
937
|
* A WebDAV request may contain many sub-requests involving file operations, requiring a long time
|
|
884
938
|
* to complete the request. This code indicates that the server has received and is processing the
|
|
885
939
|
* request, but no response is available yet. This prevents the client from timing out and
|
|
886
940
|
* assuming the request was lost.
|
|
887
|
-
*/
|
|
941
|
+
*/
|
|
942
|
+
HttpStatus[HttpStatus["Processing"] = 102] = "Processing";
|
|
888
943
|
/**
|
|
889
944
|
* Standard response for successful HTTP requests. The actual response will depend on the request
|
|
890
945
|
* method used. In a GET request, the response will contain an entity corresponding to the
|
|
891
946
|
* requested resource. In a POST request, the response will contain an entity describing or
|
|
892
947
|
* containing the result of the action.
|
|
893
|
-
*/
|
|
894
|
-
|
|
948
|
+
*/
|
|
949
|
+
HttpStatus[HttpStatus["Ok"] = 200] = "Ok";
|
|
950
|
+
/** The request has been fulfilled, resulting in the creation of a new resource. */
|
|
951
|
+
HttpStatus[HttpStatus["Created"] = 201] = "Created";
|
|
895
952
|
/**
|
|
896
953
|
* The request has been accepted for processing, but the processing has not been completed. The
|
|
897
954
|
* request might or might not be eventually acted upon, and may be disallowed when processing
|
|
898
955
|
* occurs.
|
|
899
|
-
*/
|
|
956
|
+
*/
|
|
957
|
+
HttpStatus[HttpStatus["Accepted"] = 202] = "Accepted";
|
|
900
958
|
/**
|
|
901
959
|
* SINCE HTTP/1.1 The server is a transforming proxy that received a 200 OK from its origin, but
|
|
902
960
|
* is returning a modified version of the origin's response.
|
|
903
|
-
*/
|
|
904
|
-
|
|
961
|
+
*/
|
|
962
|
+
HttpStatus[HttpStatus["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
963
|
+
/** The server successfully processed the request and is not returning any content. */
|
|
964
|
+
HttpStatus[HttpStatus["NoContent"] = 204] = "NoContent";
|
|
905
965
|
/**
|
|
906
966
|
* The server successfully processed the request, but is not returning any content. Unlike a 204
|
|
907
967
|
* response, this response requires that the requester reset the document view.
|
|
908
|
-
*/
|
|
968
|
+
*/
|
|
969
|
+
HttpStatus[HttpStatus["ResetContent"] = 205] = "ResetContent";
|
|
909
970
|
/**
|
|
910
971
|
* The server is delivering only part of the resource (byte serving) due to a range header sent by
|
|
911
972
|
* the client. The range header is used by HTTP clients to enable resuming of interrupted
|
|
912
973
|
* downloads, or split a download into multiple simultaneous streams.
|
|
913
|
-
*/
|
|
974
|
+
*/
|
|
975
|
+
HttpStatus[HttpStatus["PartialContent"] = 206] = "PartialContent";
|
|
914
976
|
/**
|
|
915
977
|
* The message body that follows is an XML message and can contain a number of separate response
|
|
916
978
|
* codes, depending on how many sub-requests were made.
|
|
917
|
-
*/
|
|
979
|
+
*/
|
|
980
|
+
HttpStatus[HttpStatus["MultiStatus"] = 207] = "MultiStatus";
|
|
918
981
|
/**
|
|
919
982
|
* The members of a DAV binding have already been enumerated in a preceding part of the
|
|
920
983
|
* (multistatus) response, and are not being included again.
|
|
921
|
-
*/
|
|
984
|
+
*/
|
|
985
|
+
HttpStatus[HttpStatus["AlreadyReported"] = 208] = "AlreadyReported";
|
|
922
986
|
/**
|
|
923
987
|
* The server has fulfilled a request for the resource, and the response is a representation of
|
|
924
988
|
* the result of one or more instance-manipulations applied to the current instance.
|
|
925
|
-
*/
|
|
989
|
+
*/
|
|
990
|
+
HttpStatus[HttpStatus["ImUsed"] = 226] = "ImUsed";
|
|
926
991
|
/**
|
|
927
992
|
* Indicates multiple options for the resource from which the client may choose (via agent-driven
|
|
928
993
|
* content negotiation). For example, this code could be used to present multiple video format
|
|
929
994
|
* options, to list files with different filename extensions, or to suggest word-sense
|
|
930
995
|
* disambiguation.
|
|
931
|
-
*/
|
|
932
|
-
|
|
996
|
+
*/
|
|
997
|
+
HttpStatus[HttpStatus["MultipleChoices"] = 300] = "MultipleChoices";
|
|
998
|
+
/** This and all future requests should be directed to the given URI. */
|
|
999
|
+
HttpStatus[HttpStatus["MovedPermanently"] = 301] = "MovedPermanently";
|
|
933
1000
|
/**
|
|
934
1001
|
* This is an example of industry practice contradicting the standard. The HTTP/1.0 specification
|
|
935
1002
|
* (RFC 1945) required the client to perform a temporary redirect (the original describing phrase
|
|
@@ -937,78 +1004,95 @@ var staticPaths = /* @__PURE__ */ new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]
|
|
|
937
1004
|
* See Other. Therefore, HTTP/1.1 added status codes 303 and 307 to distinguish between the two
|
|
938
1005
|
* behaviors. However, some Web applications and frameworks use the 302 status code as if it were
|
|
939
1006
|
* the 303.
|
|
940
|
-
*/
|
|
1007
|
+
*/
|
|
1008
|
+
HttpStatus[HttpStatus["Found"] = 302] = "Found";
|
|
941
1009
|
/**
|
|
942
1010
|
* SINCE HTTP/1.1 The response to the request can be found under another URI using a GET method.
|
|
943
1011
|
* When received in response to a POST (or PUT/DELETE), the client should presume that the server
|
|
944
1012
|
* has received the data and should issue a redirect with a separate GET message.
|
|
945
|
-
*/
|
|
1013
|
+
*/
|
|
1014
|
+
HttpStatus[HttpStatus["SeeOther"] = 303] = "SeeOther";
|
|
946
1015
|
/**
|
|
947
1016
|
* Indicates that the resource has not been modified since the version specified by the request
|
|
948
1017
|
* headers If-Modified-Since or If-None-Match. In such case, there is no need to retransmit the
|
|
949
1018
|
* resource since the client still has a previously-downloaded copy.
|
|
950
|
-
*/
|
|
1019
|
+
*/
|
|
1020
|
+
HttpStatus[HttpStatus["NotModified"] = 304] = "NotModified";
|
|
951
1021
|
/**
|
|
952
1022
|
* SINCE HTTP/1.1 The requested resource is available only through a proxy, the address for which
|
|
953
1023
|
* is provided in the response. Many HTTP clients (such as Mozilla and Internet Explorer) do not
|
|
954
1024
|
* correctly handle responses with this status code, primarily for security reasons.
|
|
955
|
-
*/
|
|
956
|
-
|
|
1025
|
+
*/
|
|
1026
|
+
HttpStatus[HttpStatus["UseProxy"] = 305] = "UseProxy";
|
|
1027
|
+
/** No longer used. Originally meant "Subsequent requests should use the specified proxy." */
|
|
1028
|
+
HttpStatus[HttpStatus["SwitchProxy"] = 306] = "SwitchProxy";
|
|
957
1029
|
/**
|
|
958
1030
|
* SINCE HTTP/1.1 In this case, the request should be repeated with another URI; however, future
|
|
959
1031
|
* requests should still use the original URI. In contrast to how 302 was historically
|
|
960
1032
|
* implemented, the request method is not allowed to be changed when reissuing the original
|
|
961
1033
|
* request. For example, a POST request should be repeated using another POST request.
|
|
962
|
-
*/
|
|
1034
|
+
*/
|
|
1035
|
+
HttpStatus[HttpStatus["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
963
1036
|
/**
|
|
964
1037
|
* The request and all future requests should be repeated using another URI. 307 and 308 parallel
|
|
965
1038
|
* the behaviors of 302 and 301, but do not allow the HTTP method to change. So, for example,
|
|
966
1039
|
* submitting a form to a permanently redirected resource may continue smoothly.
|
|
967
|
-
*/
|
|
1040
|
+
*/
|
|
1041
|
+
HttpStatus[HttpStatus["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
968
1042
|
/**
|
|
969
1043
|
* The server cannot or will not process the request due to an apparent client error (e.g.,
|
|
970
1044
|
* malformed request syntax, too large size, invalid request message framing, or deceptive request
|
|
971
1045
|
* routing).
|
|
972
|
-
*/
|
|
1046
|
+
*/
|
|
1047
|
+
HttpStatus[HttpStatus["BadRequest"] = 400] = "BadRequest";
|
|
973
1048
|
/**
|
|
974
1049
|
* Similar to 403 Forbidden, but specifically for use when authentication is required and has
|
|
975
1050
|
* failed or has not yet been provided. The response must include a WWW-Authenticate header field
|
|
976
1051
|
* containing a challenge applicable to the requested resource. See Basic access authentication
|
|
977
1052
|
* and Digest access authentication. 401 semantically means "unauthenticated",i.e. the user does
|
|
978
1053
|
* not have the necessary credentials.
|
|
979
|
-
*/
|
|
1054
|
+
*/
|
|
1055
|
+
HttpStatus[HttpStatus["Unauthorized"] = 401] = "Unauthorized";
|
|
980
1056
|
/**
|
|
981
1057
|
* Reserved for future use. The original intention was that this code might be used as part of
|
|
982
1058
|
* some form of digital cash or micro payment scheme, but that has not happened, and this code is
|
|
983
1059
|
* not usually used. Google Developers API uses this status if a particular developer has exceeded
|
|
984
1060
|
* the daily limit on requests.
|
|
985
|
-
*/
|
|
1061
|
+
*/
|
|
1062
|
+
HttpStatus[HttpStatus["PaymentRequired"] = 402] = "PaymentRequired";
|
|
986
1063
|
/**
|
|
987
1064
|
* The request was valid, but the server is refusing action. The user might not have the necessary
|
|
988
1065
|
* permissions for a resource.
|
|
989
|
-
*/
|
|
1066
|
+
*/
|
|
1067
|
+
HttpStatus[HttpStatus["Forbidden"] = 403] = "Forbidden";
|
|
990
1068
|
/**
|
|
991
1069
|
* The requested resource could not be found but may be available in the future. Subsequent
|
|
992
1070
|
* requests by the client are permissible.
|
|
993
|
-
*/
|
|
1071
|
+
*/
|
|
1072
|
+
HttpStatus[HttpStatus["NotFound"] = 404] = "NotFound";
|
|
994
1073
|
/**
|
|
995
1074
|
* A request method is not supported for the requested resource; for example, a GET request on a
|
|
996
1075
|
* form that requires data to be presented via POST, or a PUT request on a read-only resource.
|
|
997
|
-
*/
|
|
1076
|
+
*/
|
|
1077
|
+
HttpStatus[HttpStatus["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
998
1078
|
/**
|
|
999
1079
|
* The requested resource is capable of generating only content not acceptable according to the
|
|
1000
1080
|
* Accept headers sent in the request.
|
|
1001
|
-
*/
|
|
1002
|
-
|
|
1081
|
+
*/
|
|
1082
|
+
HttpStatus[HttpStatus["NotAcceptable"] = 406] = "NotAcceptable";
|
|
1083
|
+
/** The client must first authenticate itself with the proxy. */
|
|
1084
|
+
HttpStatus[HttpStatus["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
1003
1085
|
/**
|
|
1004
1086
|
* The server timed out waiting for the request. According to HTTP specifications: "The client did
|
|
1005
1087
|
* not produce a request within the time that the server was prepared to wait. The client MAY
|
|
1006
1088
|
* repeat the request without modifications at any later time."
|
|
1007
|
-
*/
|
|
1089
|
+
*/
|
|
1090
|
+
HttpStatus[HttpStatus["RequestTimeout"] = 408] = "RequestTimeout";
|
|
1008
1091
|
/**
|
|
1009
1092
|
* Indicates that the request could not be processed because of conflict in the request, such as
|
|
1010
1093
|
* an edit conflict between multiple simultaneous updates.
|
|
1011
|
-
*/
|
|
1094
|
+
*/
|
|
1095
|
+
HttpStatus[HttpStatus["Conflict"] = 409] = "Conflict";
|
|
1012
1096
|
/**
|
|
1013
1097
|
* Indicates that the resource requested is no longer available and will not be available again.
|
|
1014
1098
|
* This should be used when a resource has been intentionally removed and the resource should be
|
|
@@ -1016,98 +1100,127 @@ var staticPaths = /* @__PURE__ */ new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]
|
|
|
1016
1100
|
* future. Clients such as search engines should remove the resource from their indices. Most use
|
|
1017
1101
|
* cases do not require clients and search engines to purge the resource, and a "404 Not Found"
|
|
1018
1102
|
* may be used instead.
|
|
1019
|
-
*/
|
|
1103
|
+
*/
|
|
1104
|
+
HttpStatus[HttpStatus["Gone"] = 410] = "Gone";
|
|
1020
1105
|
/**
|
|
1021
1106
|
* The request did not specify the length of its content, which is required by the requested
|
|
1022
1107
|
* resource.
|
|
1023
|
-
*/
|
|
1024
|
-
|
|
1108
|
+
*/
|
|
1109
|
+
HttpStatus[HttpStatus["LengthRequired"] = 411] = "LengthRequired";
|
|
1110
|
+
/** The server does not meet one of the preconditions that the requester put on the request. */
|
|
1111
|
+
HttpStatus[HttpStatus["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
1025
1112
|
/**
|
|
1026
1113
|
* The request is larger than the server is willing or able to process. Previously called "Request
|
|
1027
1114
|
* Entity Too Large".
|
|
1028
|
-
*/
|
|
1115
|
+
*/
|
|
1116
|
+
HttpStatus[HttpStatus["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
1029
1117
|
/**
|
|
1030
1118
|
* The URI provided was too long for the server to process. Often the result of too much data
|
|
1031
1119
|
* being encoded as a query-string of a GET request, in which case it should be converted to a
|
|
1032
1120
|
* POST request. Called "Request-URI Too Long" previously.
|
|
1033
|
-
*/
|
|
1121
|
+
*/
|
|
1122
|
+
HttpStatus[HttpStatus["UriTooLong"] = 414] = "UriTooLong";
|
|
1034
1123
|
/**
|
|
1035
1124
|
* The request entity has a media type which the server or resource does not support. For example,
|
|
1036
1125
|
* the client uploads an image as image/svg+xml, but the server requires that images use a
|
|
1037
1126
|
* different format.
|
|
1038
|
-
*/
|
|
1127
|
+
*/
|
|
1128
|
+
HttpStatus[HttpStatus["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
1039
1129
|
/**
|
|
1040
1130
|
* The client has asked for a portion of the file (byte serving), but the server cannot supply
|
|
1041
1131
|
* that portion. For example, if the client asked for a part of the file that lies beyond the end
|
|
1042
1132
|
* of the file. Called "Requested Range Not Satisfiable" previously.
|
|
1043
|
-
*/
|
|
1044
|
-
|
|
1133
|
+
*/
|
|
1134
|
+
HttpStatus[HttpStatus["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
1135
|
+
/** The server cannot meet the requirements of the Expect request-header field. */
|
|
1136
|
+
HttpStatus[HttpStatus["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
1045
1137
|
/**
|
|
1046
1138
|
* This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324,
|
|
1047
1139
|
* Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP
|
|
1048
1140
|
* servers. The RFC specifies this code should be returned by teapots requested to brew coffee.
|
|
1049
1141
|
* This HTTP status is used as an Easter egg in some websites, including Google.com.
|
|
1050
|
-
*/
|
|
1142
|
+
*/
|
|
1143
|
+
HttpStatus[HttpStatus["IAmATeapot"] = 418] = "IAmATeapot";
|
|
1051
1144
|
/**
|
|
1052
1145
|
* The request was directed at a server that is not able to produce a response (for example
|
|
1053
1146
|
* because a connection reuse).
|
|
1054
|
-
*/
|
|
1055
|
-
|
|
1056
|
-
/** The
|
|
1057
|
-
|
|
1147
|
+
*/
|
|
1148
|
+
HttpStatus[HttpStatus["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
1149
|
+
/** The request was well-formed but was unable to be followed due to semantic errors. */
|
|
1150
|
+
HttpStatus[HttpStatus["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
1151
|
+
/** The resource that is being accessed is locked. */
|
|
1152
|
+
HttpStatus[HttpStatus["Locked"] = 423] = "Locked";
|
|
1153
|
+
/** The request failed due to failure of a previous request (e.g., a PROPPATCH). */
|
|
1154
|
+
HttpStatus[HttpStatus["FailedDependency"] = 424] = "FailedDependency";
|
|
1058
1155
|
/**
|
|
1059
1156
|
* The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header
|
|
1060
1157
|
* field.
|
|
1061
|
-
*/
|
|
1158
|
+
*/
|
|
1159
|
+
HttpStatus[HttpStatus["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
1062
1160
|
/**
|
|
1063
1161
|
* The origin server requires the request to be conditional. Intended to prevent "the 'lost
|
|
1064
1162
|
* update' problem, where a client GETs a resource's state, modifies it, and PUTs it back to the
|
|
1065
1163
|
* server, when meanwhile a third party has modified the state on the server, leading to a
|
|
1066
1164
|
* conflict."
|
|
1067
|
-
*/
|
|
1165
|
+
*/
|
|
1166
|
+
HttpStatus[HttpStatus["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
1068
1167
|
/**
|
|
1069
1168
|
* The user has sent too many requests in a given amount of time. Intended for use with
|
|
1070
1169
|
* rate-limiting schemes.
|
|
1071
|
-
*/
|
|
1170
|
+
*/
|
|
1171
|
+
HttpStatus[HttpStatus["TooManyRequests"] = 429] = "TooManyRequests";
|
|
1072
1172
|
/**
|
|
1073
1173
|
* The server is unwilling to process the request because either an individual header field, or
|
|
1074
1174
|
* all the header fields collectively, are too large.
|
|
1075
|
-
*/
|
|
1175
|
+
*/
|
|
1176
|
+
HttpStatus[HttpStatus["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
1076
1177
|
/**
|
|
1077
1178
|
* A server operator has received a legal demand to deny access to a resource or to a set of
|
|
1078
1179
|
* resources that includes the requested resource. The code 451 was chosen as a reference to the
|
|
1079
1180
|
* novel Fahrenheit 451.
|
|
1080
|
-
*/
|
|
1181
|
+
*/
|
|
1182
|
+
HttpStatus[HttpStatus["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
1081
1183
|
/**
|
|
1082
1184
|
* A generic error message, given when an unexpected condition was encountered and no more
|
|
1083
1185
|
* specific message is suitable.
|
|
1084
|
-
*/
|
|
1186
|
+
*/
|
|
1187
|
+
HttpStatus[HttpStatus["InternalServerError"] = 500] = "InternalServerError";
|
|
1085
1188
|
/**
|
|
1086
1189
|
* The server either does not recognize the request method, or it lacks the ability to fulfill the
|
|
1087
1190
|
* request. Usually this implies future availability (e.g., a new feature of a web-service API).
|
|
1088
|
-
*/
|
|
1191
|
+
*/
|
|
1192
|
+
HttpStatus[HttpStatus["NotImplemented"] = 501] = "NotImplemented";
|
|
1089
1193
|
/**
|
|
1090
1194
|
* The server was acting as a gateway or proxy and received an invalid response from the upstream
|
|
1091
1195
|
* server.
|
|
1092
|
-
*/
|
|
1196
|
+
*/
|
|
1197
|
+
HttpStatus[HttpStatus["BadGateway"] = 502] = "BadGateway";
|
|
1093
1198
|
/**
|
|
1094
1199
|
* The server is currently unavailable (because it is overloaded or down for maintenance).
|
|
1095
1200
|
* Generally, this is a temporary state.
|
|
1096
|
-
*/
|
|
1201
|
+
*/
|
|
1202
|
+
HttpStatus[HttpStatus["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
1097
1203
|
/**
|
|
1098
1204
|
* The server was acting as a gateway or proxy and did not receive a timely response from the
|
|
1099
1205
|
* upstream server.
|
|
1100
|
-
*/
|
|
1101
|
-
|
|
1102
|
-
/**
|
|
1103
|
-
|
|
1104
|
-
/**
|
|
1105
|
-
|
|
1206
|
+
*/
|
|
1207
|
+
HttpStatus[HttpStatus["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
1208
|
+
/** The server does not support the HTTP protocol version used in the request */
|
|
1209
|
+
HttpStatus[HttpStatus["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
|
|
1210
|
+
/** Transparent content negotiation for the request results in a circular reference. */
|
|
1211
|
+
HttpStatus[HttpStatus["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
1212
|
+
/** The server is unable to store the representation needed to complete the request. */
|
|
1213
|
+
HttpStatus[HttpStatus["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
1214
|
+
/** The server detected an infinite loop while processing the request. */
|
|
1215
|
+
HttpStatus[HttpStatus["LoopDetected"] = 508] = "LoopDetected";
|
|
1216
|
+
/** Further extensions to the request are required for the server to fulfill it. */
|
|
1217
|
+
HttpStatus[HttpStatus["NotExtended"] = 510] = "NotExtended";
|
|
1106
1218
|
/**
|
|
1107
1219
|
* The client needs to authenticate to gain network access. Intended for use by intercepting
|
|
1108
1220
|
* proxies used to control access to the network (e.g., "captive portals" used to require
|
|
1109
1221
|
* agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
|
|
1110
|
-
*/
|
|
1222
|
+
*/
|
|
1223
|
+
HttpStatus[HttpStatus["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
1111
1224
|
return HttpStatus;
|
|
1112
1225
|
}({});
|
|
1113
1226
|
function getQwikRouterServerData(requestEv) {
|
|
@@ -1165,7 +1278,8 @@ function createResolveRequestHandlers() {
|
|
|
1165
1278
|
/**
|
|
1166
1279
|
* JSON request wrapper must be before all middleware so it can rewrite the URL and catch
|
|
1167
1280
|
* redirects/errors from plugin/route middleware via try/catch on next()
|
|
1168
|
-
*/
|
|
1281
|
+
*/
|
|
1282
|
+
requestHandlers.push(jsonRequestWrapper());
|
|
1169
1283
|
requestHandlers.push(serverErrorMiddleware(route, renderHandler));
|
|
1170
1284
|
}
|
|
1171
1285
|
if (serverPlugins) _resolveRequestHandlers(routeLoaders, routeActions, requestHandlers, serverPlugins, isPageRoute, method);
|
|
@@ -1292,16 +1406,17 @@ function createResolveRequestHandlers() {
|
|
|
1292
1406
|
}
|
|
1293
1407
|
function loadersMiddleware(routeLoaders, route) {
|
|
1294
1408
|
return (requestEvent) => {
|
|
1295
|
-
|
|
1296
|
-
|
|
1409
|
+
const requestEv = requestEvent;
|
|
1410
|
+
if (requestEv.headersSent) {
|
|
1411
|
+
requestEv.exit();
|
|
1297
1412
|
return;
|
|
1298
1413
|
}
|
|
1299
1414
|
if (routeLoaders.length === 0) return;
|
|
1300
|
-
setLoaderData(
|
|
1415
|
+
setLoaderData(requestEv, routeLoaders, route);
|
|
1301
1416
|
let allBlockSSRLoaders;
|
|
1302
1417
|
for (let i = 0; i < routeLoaders.length; i++) {
|
|
1303
1418
|
const loader = routeLoaders[i];
|
|
1304
|
-
const promise = loadRouteLoader(loader,
|
|
1419
|
+
const promise = loadRouteLoader(loader, requestEv);
|
|
1305
1420
|
promise.catch(() => {});
|
|
1306
1421
|
if (loader.__blockSSR) allBlockSSRLoaders = allBlockSSRLoaders ? allBlockSSRLoaders.then(() => promise) : promise;
|
|
1307
1422
|
}
|
|
@@ -1322,17 +1437,18 @@ function createResolveRequestHandlers() {
|
|
|
1322
1437
|
if (!mods.some((m) => {
|
|
1323
1438
|
if (!m) return false;
|
|
1324
1439
|
if (m.routeConfig) return typeof m.routeConfig === "function" || m.routeConfig.eTag !== void 0 || m.routeConfig.cacheKey !== void 0;
|
|
1325
|
-
|
|
1440
|
+
const page = m;
|
|
1441
|
+
return page.eTag !== void 0 || page.cacheKey !== void 0;
|
|
1326
1442
|
})) return;
|
|
1327
1443
|
const loaderValues = getRouteLoaderValues(requestEv);
|
|
1328
|
-
const getData = (loaderOrAction) => {
|
|
1444
|
+
const getData = ((loaderOrAction) => {
|
|
1329
1445
|
const id = loaderOrAction.__id;
|
|
1330
1446
|
if (loaderOrAction.__brand === "server_loader") {
|
|
1331
1447
|
if (!(id in loaderValues)) throw new Error("Loader not executed for this request.");
|
|
1332
1448
|
return loaderValues[id];
|
|
1333
1449
|
}
|
|
1334
1450
|
return requestEv.sharedMap.get("@actionId") === id ? requestEv.sharedMap.get("@actionResult") : void 0;
|
|
1335
|
-
};
|
|
1451
|
+
});
|
|
1336
1452
|
const routeLocation = {
|
|
1337
1453
|
params: requestEv.params,
|
|
1338
1454
|
url: requestEv.url,
|
|
@@ -1468,7 +1584,8 @@ function createResolveRequestHandlers() {
|
|
|
1468
1584
|
* Prerendered pages are pruned from the production server route plan, so a request missing the
|
|
1469
1585
|
* canonical trailing slash lands here as not found. Redirect it when the canonical path was
|
|
1470
1586
|
* prerendered, and leave a genuine 404 alone.
|
|
1471
|
-
*/
|
|
1587
|
+
*/
|
|
1588
|
+
function fixStaticTrailingSlash(ev) {
|
|
1472
1589
|
const canonicalUrl = new URL(ev.originalUrl);
|
|
1473
1590
|
canonicalUrl.pathname = globalThis.__NO_TRAILING_SLASH__ ? canonicalUrl.pathname.replace(/\/$/, "") : ensureSlash(canonicalUrl.pathname);
|
|
1474
1591
|
if (isStaticPath(ev.request.method, canonicalUrl)) fixTrailingSlash(ev);
|
|
@@ -1565,6 +1682,7 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1565
1682
|
});
|
|
1566
1683
|
if (typeof result.html === "string") await stream.write(result.html);
|
|
1567
1684
|
boundaryErrored ||= result.errorBoundaryCaught === true;
|
|
1685
|
+
if (boundaryErrored) requestEv.sharedMap.set(RequestEvErrorBoundaryCaught, true);
|
|
1568
1686
|
} finally {
|
|
1569
1687
|
try {
|
|
1570
1688
|
await stream.ready;
|
|
@@ -1626,19 +1744,15 @@ The request origin "${inputOrigin}" does not match the server origin "${origin}"
|
|
|
1626
1744
|
};
|
|
1627
1745
|
}
|
|
1628
1746
|
var { actionsMiddleware, checkBrand, checkCSRF, fixStaticTrailingSlash, fixTrailingSlash, getPathname, isLastModulePageRoute, isQrl, loadersMiddleware, measure, renderQwikMiddleware, resolveRequestHandlers, streamServerFunctionResult, verifySerializable } = createResolveRequestHandlers();
|
|
1629
|
-
/** @public */
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
});
|
|
1639
|
-
};
|
|
1640
|
-
var COLOR_400 = "#006ce9";
|
|
1641
|
-
var COLOR_500 = "#713fc2";
|
|
1747
|
+
/** @public */
|
|
1748
|
+
function getErrorHtml(status, e) {
|
|
1749
|
+
let message = "Server Error";
|
|
1750
|
+
if (e != null) {
|
|
1751
|
+
if (typeof e.message === "string") message = e.message;
|
|
1752
|
+
else message = String(e);
|
|
1753
|
+
}
|
|
1754
|
+
return `<html>` + minimalHtmlResponse(status, message) + `</html>`;
|
|
1755
|
+
}
|
|
1642
1756
|
function minimalHtmlResponse(status, message) {
|
|
1643
1757
|
if (typeof status !== "number") status = 500;
|
|
1644
1758
|
if (typeof message === "string") message = escapeHtml(message);
|
|
@@ -1661,15 +1775,39 @@ function minimalHtmlResponse(status, message) {
|
|
|
1661
1775
|
<body><p><strong>${status}</strong> <span>${message}</span></p></body>
|
|
1662
1776
|
`;
|
|
1663
1777
|
}
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1778
|
+
var ESCAPE_HTML = /[&<>]/g;
|
|
1779
|
+
var escapeHtml = (s) => {
|
|
1780
|
+
return s.replace(ESCAPE_HTML, (c) => {
|
|
1781
|
+
switch (c) {
|
|
1782
|
+
case "&": return "&";
|
|
1783
|
+
case "<": return "<";
|
|
1784
|
+
case ">": return ">";
|
|
1785
|
+
default: return "";
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
};
|
|
1789
|
+
var COLOR_400 = "#006ce9";
|
|
1790
|
+
var COLOR_500 = "#713fc2";
|
|
1791
|
+
var ensureError = (e) => e instanceof Error || typeof e === "object" && e !== null ? e : new Error(String(e));
|
|
1792
|
+
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, basePathname = "/") {
|
|
1793
|
+
let resolve;
|
|
1794
|
+
const responsePromise = new Promise((r) => resolve = r);
|
|
1795
|
+
try {
|
|
1796
|
+
const requestEv = createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, basePathname, resolve);
|
|
1797
|
+
return {
|
|
1798
|
+
response: responsePromise,
|
|
1799
|
+
requestEv,
|
|
1800
|
+
completion: _asyncRequestStore ? _asyncRequestStore.run(requestEv, runNext, requestEv, rebuildRouteInfo, resolve) : runNext(requestEv, rebuildRouteInfo, resolve)
|
|
1801
|
+
};
|
|
1802
|
+
} catch (e) {
|
|
1803
|
+
resolve(null);
|
|
1804
|
+
return {
|
|
1805
|
+
response: responsePromise,
|
|
1806
|
+
requestEv: { headersSent: false },
|
|
1807
|
+
completion: Promise.resolve(ensureError(e))
|
|
1808
|
+
};
|
|
1669
1809
|
}
|
|
1670
|
-
return `<html>` + minimalHtmlResponse(status, message) + `</html>`;
|
|
1671
1810
|
}
|
|
1672
|
-
var ensureError = (e) => e instanceof Error || typeof e === "object" && e !== null ? e : new Error(String(e));
|
|
1673
1811
|
async function runNext(requestEv, rebuildRouteInfo, resolve) {
|
|
1674
1812
|
try {
|
|
1675
1813
|
const isValidURL = (url) => new URL(url.pathname + url.search, url);
|
|
@@ -1731,23 +1869,4 @@ async function runNext(requestEv, rebuildRouteInfo, resolve) {
|
|
|
1731
1869
|
if (!requestEv.isDirty()) resolve(null);
|
|
1732
1870
|
}
|
|
1733
1871
|
}
|
|
1734
|
-
|
|
1735
|
-
let resolve;
|
|
1736
|
-
const responsePromise = new Promise((r) => resolve = r);
|
|
1737
|
-
try {
|
|
1738
|
-
const requestEv = createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, basePathname, resolve);
|
|
1739
|
-
return {
|
|
1740
|
-
response: responsePromise,
|
|
1741
|
-
requestEv,
|
|
1742
|
-
completion: _asyncRequestStore ? _asyncRequestStore.run(requestEv, runNext, requestEv, rebuildRouteInfo, resolve) : runNext(requestEv, rebuildRouteInfo, resolve)
|
|
1743
|
-
};
|
|
1744
|
-
} catch (e) {
|
|
1745
|
-
resolve(null);
|
|
1746
|
-
return {
|
|
1747
|
-
response: responsePromise,
|
|
1748
|
-
requestEv: { headersSent: false },
|
|
1749
|
-
completion: Promise.resolve(ensureError(e))
|
|
1750
|
-
};
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
export { isStaticPath as a, RewriteMessage as c, resolveRequestHandlers as i, mergeHeadersCookies as l, getErrorHtml as n, clearLoaderCache as o, renderQwikMiddleware as r, clearSsrCache as s, runQwikRouter as t };
|
|
1872
|
+
export { getStaticPathRedirect as a, clearSsrCache as c, mergeHeadersCookies as d, resolveRequestHandlers as i, RequestEvErrorBoundaryCaught as l, getErrorHtml as n, isStaticPath as o, renderQwikMiddleware as r, clearLoaderCache as s, runQwikRouter as t, RewriteMessage as u };
|