@qwik.dev/router 2.0.0-beta.10 → 2.0.0-beta.13
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.cjs +61 -5
- package/lib/adapters/azure-swa/vite/index.mjs +26 -201
- package/lib/adapters/bun-server/vite/index.cjs +27 -5
- package/lib/adapters/bun-server/vite/index.mjs +14 -196
- package/lib/adapters/cloud-run/vite/index.cjs +24 -5
- package/lib/adapters/cloud-run/vite/index.mjs +13 -195
- package/lib/adapters/cloudflare-pages/vite/index.cjs +65 -1
- package/lib/adapters/cloudflare-pages/vite/index.mjs +63 -4
- package/lib/adapters/deno-server/vite/index.cjs +39 -5
- package/lib/adapters/deno-server/vite/index.mjs +16 -198
- package/lib/adapters/netlify-edge/vite/index.cjs +88 -6
- package/lib/adapters/netlify-edge/vite/index.mjs +56 -240
- package/lib/adapters/node-server/vite/index.cjs +27 -5
- package/lib/adapters/node-server/vite/index.mjs +14 -196
- package/lib/adapters/shared/vite/index.cjs +303 -2
- package/lib/adapters/shared/vite/index.d.ts +4 -4
- package/lib/adapters/shared/vite/index.mjs +248 -143
- package/lib/adapters/ssg/vite/index.cjs +19 -5
- package/lib/adapters/ssg/vite/index.mjs +11 -193
- package/lib/adapters/vercel-edge/vite/index.cjs +81 -5
- package/lib/adapters/vercel-edge/vite/index.d.ts +1 -1
- package/lib/adapters/vercel-edge/vite/index.mjs +48 -229
- package/lib/chunks/error-handler.cjs +58 -0
- package/lib/chunks/error-handler.mjs +59 -0
- package/lib/chunks/format-error.cjs +136 -0
- package/lib/chunks/format-error.mjs +137 -0
- package/lib/chunks/fs.cjs +274 -0
- package/lib/chunks/fs.mjs +275 -0
- package/lib/chunks/index.cjs +877 -0
- package/lib/chunks/index.mjs +876 -0
- package/lib/chunks/mime-types.cjs +52 -0
- package/lib/chunks/mime-types.mjs +53 -0
- package/lib/chunks/routing.qwik.cjs +452 -0
- package/lib/chunks/routing.qwik.mjs +453 -0
- package/lib/chunks/types.qwik.cjs +24 -0
- package/lib/chunks/types.qwik.mjs +25 -0
- package/lib/index.d.ts +9 -3
- package/lib/index.qwik.cjs +543 -1001
- package/lib/index.qwik.mjs +512 -972
- package/lib/middleware/aws-lambda/index.cjs +52 -1
- package/lib/middleware/aws-lambda/index.mjs +37 -26
- package/lib/middleware/azure-swa/index.cjs +92 -1
- package/lib/middleware/azure-swa/index.mjs +64 -46
- package/lib/middleware/bun/index.cjs +143 -1
- package/lib/middleware/bun/index.mjs +103 -117
- package/lib/middleware/cloudflare-pages/index.cjs +96 -1
- package/lib/middleware/cloudflare-pages/index.mjs +68 -47
- package/lib/middleware/deno/index.cjs +130 -1
- package/lib/middleware/deno/index.mjs +93 -112
- package/lib/middleware/firebase/index.cjs +33 -1
- package/lib/middleware/firebase/index.mjs +25 -16
- package/lib/middleware/netlify-edge/index.cjs +71 -1
- package/lib/middleware/netlify-edge/index.mjs +52 -36
- package/lib/middleware/node/index.cjs +219 -1
- package/lib/middleware/node/index.mjs +178 -165
- package/lib/middleware/request-handler/index.cjs +1488 -18
- package/lib/middleware/request-handler/index.d.ts +20 -2
- package/lib/middleware/request-handler/index.mjs +1225 -873
- package/lib/middleware/vercel-edge/index.cjs +98 -1
- package/lib/middleware/vercel-edge/index.mjs +71 -47
- package/lib/service-worker/index.cjs +5 -0
- package/lib/service-worker/index.mjs +5 -0
- package/lib/ssg/index.cjs +15 -1
- package/lib/ssg/index.mjs +12 -19
- package/lib/vite/index.cjs +2006 -27
- package/lib/vite/index.d.ts +9 -9
- package/lib/vite/index.mjs +1597 -1216
- package/package.json +9 -8
- package/lib/adapters/azure-swa/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/azure-swa/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/azure-swa/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/azure-swa/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/azure-swa/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/azure-swa/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/bun-server/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/bun-server/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/bun-server/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/bun-server/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/bun-server/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/bun-server/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/cloud-run/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/cloud-run/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/cloud-run/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/cloud-run/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/cloud-run/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/cloud-run/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/cloudflare-pages/vite/index-BIeHg2Cj.cjs +0 -5
- package/lib/adapters/cloudflare-pages/vite/index-C455V8_A.cjs +0 -1
- package/lib/adapters/cloudflare-pages/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/cloudflare-pages/vite/index-D3HITboM.js +0 -645
- package/lib/adapters/cloudflare-pages/vite/index-DKcVHRBy.cjs +0 -11
- package/lib/adapters/cloudflare-pages/vite/index-DwovcBp3.js +0 -22
- package/lib/adapters/cloudflare-pages/vite/index-bogwy7wh.js +0 -250
- package/lib/adapters/cloudflare-pages/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/deno-server/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/deno-server/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/deno-server/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/deno-server/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/deno-server/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/deno-server/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/netlify-edge/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/netlify-edge/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/netlify-edge/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/netlify-edge/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/netlify-edge/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/netlify-edge/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/node-server/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/node-server/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/node-server/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/node-server/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/node-server/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/node-server/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/shared/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/shared/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/shared/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/shared/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/shared/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/shared/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/ssg/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/ssg/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/ssg/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/ssg/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/ssg/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/ssg/vite/index-vQuPcef3.cjs +0 -1
- package/lib/adapters/vercel-edge/vite/index-BqUeglYs.cjs +0 -1
- package/lib/adapters/vercel-edge/vite/index-CBIchDYq.js +0 -651
- package/lib/adapters/vercel-edge/vite/index-ClHGw5z1.js +0 -6
- package/lib/adapters/vercel-edge/vite/index-CrwlB95_.js +0 -22
- package/lib/adapters/vercel-edge/vite/index-DTIOTwZo.cjs +0 -11
- package/lib/adapters/vercel-edge/vite/index-vQuPcef3.cjs +0 -1
- package/lib/service-worker.cjs +0 -1
- package/lib/service-worker.mjs +0 -5
- package/lib/ssg/deno.cjs +0 -1
- package/lib/ssg/deno.mjs +0 -6
- package/lib/ssg/index-CBIchDYq.js +0 -651
- package/lib/ssg/index-ClHGw5z1.js +0 -6
- package/lib/ssg/index-DTIOTwZo.cjs +0 -11
- package/lib/ssg/index-vQuPcef3.cjs +0 -1
- package/lib/ssg/node.cjs +0 -11
- package/lib/ssg/node.mjs +0 -651
|
@@ -1,1116 +1,1468 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
+
var _a, _b, _c, _pendingHighSurrogate, _handle, _transform;
|
|
12
|
+
import { isServer } from "@qwik.dev/core/build";
|
|
13
|
+
import { i as isPromise, k as QDATA_KEY, Q as Q_ROUTE, h as QFN_KEY, m as QLOADER_KEY, j as QACTION_KEY, d as loadRoute } from "../../chunks/routing.qwik.mjs";
|
|
14
|
+
import { inlinedQrl } from "@qwik.dev/core";
|
|
15
|
+
import { _serialize, _UNINITIALIZED, _deserialize, _verifySerializable } from "@qwik.dev/core/internal";
|
|
16
|
+
import { L as LoadedRouteProp } from "../../chunks/types.qwik.mjs";
|
|
17
|
+
import { _asyncRequestStore as _asyncRequestStore$1, ServerError as ServerError$1, RedirectMessage as RedirectMessage$1, RewriteMessage as RewriteMessage$1, AbortMessage as AbortMessage$1 } from "@qwik.dev/router/middleware/request-handler";
|
|
18
|
+
import { g as getErrorHtml, m as minimalHtmlResponse } from "../../chunks/error-handler.mjs";
|
|
19
|
+
import "@qwik.dev/core/preloader";
|
|
20
|
+
var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
21
|
+
HttpStatus2[HttpStatus2["Continue"] = 100] = "Continue";
|
|
22
|
+
HttpStatus2[HttpStatus2["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
23
|
+
HttpStatus2[HttpStatus2["Processing"] = 102] = "Processing";
|
|
24
|
+
HttpStatus2[HttpStatus2["Ok"] = 200] = "Ok";
|
|
25
|
+
HttpStatus2[HttpStatus2["Created"] = 201] = "Created";
|
|
26
|
+
HttpStatus2[HttpStatus2["Accepted"] = 202] = "Accepted";
|
|
27
|
+
HttpStatus2[HttpStatus2["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
28
|
+
HttpStatus2[HttpStatus2["NoContent"] = 204] = "NoContent";
|
|
29
|
+
HttpStatus2[HttpStatus2["ResetContent"] = 205] = "ResetContent";
|
|
30
|
+
HttpStatus2[HttpStatus2["PartialContent"] = 206] = "PartialContent";
|
|
31
|
+
HttpStatus2[HttpStatus2["MultiStatus"] = 207] = "MultiStatus";
|
|
32
|
+
HttpStatus2[HttpStatus2["AlreadyReported"] = 208] = "AlreadyReported";
|
|
33
|
+
HttpStatus2[HttpStatus2["ImUsed"] = 226] = "ImUsed";
|
|
34
|
+
HttpStatus2[HttpStatus2["MultipleChoices"] = 300] = "MultipleChoices";
|
|
35
|
+
HttpStatus2[HttpStatus2["MovedPermanently"] = 301] = "MovedPermanently";
|
|
36
|
+
HttpStatus2[HttpStatus2["Found"] = 302] = "Found";
|
|
37
|
+
HttpStatus2[HttpStatus2["SeeOther"] = 303] = "SeeOther";
|
|
38
|
+
HttpStatus2[HttpStatus2["NotModified"] = 304] = "NotModified";
|
|
39
|
+
HttpStatus2[HttpStatus2["UseProxy"] = 305] = "UseProxy";
|
|
40
|
+
HttpStatus2[HttpStatus2["SwitchProxy"] = 306] = "SwitchProxy";
|
|
41
|
+
HttpStatus2[HttpStatus2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
42
|
+
HttpStatus2[HttpStatus2["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
43
|
+
HttpStatus2[HttpStatus2["BadRequest"] = 400] = "BadRequest";
|
|
44
|
+
HttpStatus2[HttpStatus2["Unauthorized"] = 401] = "Unauthorized";
|
|
45
|
+
HttpStatus2[HttpStatus2["PaymentRequired"] = 402] = "PaymentRequired";
|
|
46
|
+
HttpStatus2[HttpStatus2["Forbidden"] = 403] = "Forbidden";
|
|
47
|
+
HttpStatus2[HttpStatus2["NotFound"] = 404] = "NotFound";
|
|
48
|
+
HttpStatus2[HttpStatus2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
49
|
+
HttpStatus2[HttpStatus2["NotAcceptable"] = 406] = "NotAcceptable";
|
|
50
|
+
HttpStatus2[HttpStatus2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
51
|
+
HttpStatus2[HttpStatus2["RequestTimeout"] = 408] = "RequestTimeout";
|
|
52
|
+
HttpStatus2[HttpStatus2["Conflict"] = 409] = "Conflict";
|
|
53
|
+
HttpStatus2[HttpStatus2["Gone"] = 410] = "Gone";
|
|
54
|
+
HttpStatus2[HttpStatus2["LengthRequired"] = 411] = "LengthRequired";
|
|
55
|
+
HttpStatus2[HttpStatus2["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
56
|
+
HttpStatus2[HttpStatus2["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
57
|
+
HttpStatus2[HttpStatus2["UriTooLong"] = 414] = "UriTooLong";
|
|
58
|
+
HttpStatus2[HttpStatus2["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
59
|
+
HttpStatus2[HttpStatus2["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
60
|
+
HttpStatus2[HttpStatus2["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
61
|
+
HttpStatus2[HttpStatus2["IAmATeapot"] = 418] = "IAmATeapot";
|
|
62
|
+
HttpStatus2[HttpStatus2["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
63
|
+
HttpStatus2[HttpStatus2["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
64
|
+
HttpStatus2[HttpStatus2["Locked"] = 423] = "Locked";
|
|
65
|
+
HttpStatus2[HttpStatus2["FailedDependency"] = 424] = "FailedDependency";
|
|
66
|
+
HttpStatus2[HttpStatus2["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
67
|
+
HttpStatus2[HttpStatus2["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
68
|
+
HttpStatus2[HttpStatus2["TooManyRequests"] = 429] = "TooManyRequests";
|
|
69
|
+
HttpStatus2[HttpStatus2["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
70
|
+
HttpStatus2[HttpStatus2["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
71
|
+
HttpStatus2[HttpStatus2["InternalServerError"] = 500] = "InternalServerError";
|
|
72
|
+
HttpStatus2[HttpStatus2["NotImplemented"] = 501] = "NotImplemented";
|
|
73
|
+
HttpStatus2[HttpStatus2["BadGateway"] = 502] = "BadGateway";
|
|
74
|
+
HttpStatus2[HttpStatus2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
75
|
+
HttpStatus2[HttpStatus2["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
76
|
+
HttpStatus2[HttpStatus2["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
|
|
77
|
+
HttpStatus2[HttpStatus2["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
78
|
+
HttpStatus2[HttpStatus2["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
79
|
+
HttpStatus2[HttpStatus2["LoopDetected"] = 508] = "LoopDetected";
|
|
80
|
+
HttpStatus2[HttpStatus2["NotExtended"] = 510] = "NotExtended";
|
|
81
|
+
HttpStatus2[HttpStatus2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
82
|
+
return HttpStatus2;
|
|
83
|
+
})(HttpStatus || {});
|
|
84
|
+
function createCacheControl(cacheControl) {
|
|
85
|
+
const controls = [];
|
|
86
|
+
if (cacheControl === "day") {
|
|
87
|
+
cacheControl = 60 * 60 * 24;
|
|
88
|
+
} else if (cacheControl === "week") {
|
|
89
|
+
cacheControl = 60 * 60 * 24 * 7;
|
|
90
|
+
} else if (cacheControl === "month") {
|
|
91
|
+
cacheControl = 60 * 60 * 24 * 30;
|
|
92
|
+
} else if (cacheControl === "year") {
|
|
93
|
+
cacheControl = 60 * 60 * 24 * 365;
|
|
94
|
+
} else if (cacheControl === "private") {
|
|
95
|
+
cacheControl = {
|
|
96
|
+
private: true,
|
|
97
|
+
noCache: true
|
|
98
|
+
};
|
|
99
|
+
} else if (cacheControl === "immutable") {
|
|
100
|
+
cacheControl = {
|
|
101
|
+
public: true,
|
|
102
|
+
immutable: true,
|
|
103
|
+
maxAge: 60 * 60 * 24 * 365
|
|
104
|
+
};
|
|
105
|
+
} else if (cacheControl === "no-cache") {
|
|
106
|
+
cacheControl = {
|
|
107
|
+
noCache: true
|
|
108
|
+
};
|
|
54
109
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
function ie(e) {
|
|
61
|
-
const t = e.length;
|
|
62
|
-
return t > 1 && e.charCodeAt(t - 1) === 47 ? t - 1 : t;
|
|
63
|
-
}
|
|
64
|
-
function oe(e, t) {
|
|
65
|
-
const n = e.length;
|
|
66
|
-
return t >= n || t == n - 1 && e.charCodeAt(t) === 47;
|
|
67
|
-
}
|
|
68
|
-
function ae(e) {
|
|
69
|
-
return e.charCodeAt(0) === 47 ? 1 : 0;
|
|
70
|
-
}
|
|
71
|
-
function be(e, t) {
|
|
72
|
-
return e.charCodeAt(t) === 46 && e.charCodeAt(t + 1) === 46 && e.charCodeAt(t + 2) === 46;
|
|
73
|
-
}
|
|
74
|
-
function B(e, t, n, r, o = "") {
|
|
75
|
-
for (; t < n && e.charCodeAt(t) !== r; )
|
|
76
|
-
t++;
|
|
77
|
-
const i = o.length;
|
|
78
|
-
for (let a = 0; a < i; a++)
|
|
79
|
-
if (e.charCodeAt(t - i + a) !== o.charCodeAt(a))
|
|
80
|
-
return -1;
|
|
81
|
-
return t - i;
|
|
82
|
-
}
|
|
83
|
-
function ze(e, t, n, r, o, i, a, s) {
|
|
84
|
-
n.charCodeAt(r) === 47 && r++;
|
|
85
|
-
let c = o;
|
|
86
|
-
const f = t + "/";
|
|
87
|
-
for (; c >= r; ) {
|
|
88
|
-
const l = Re(i, a, s, n, c, o);
|
|
89
|
-
if (l) {
|
|
90
|
-
let h = n.substring(r, Math.min(c, o));
|
|
91
|
-
return h.endsWith(f) && (h = h.substring(0, h.length - f.length)), l[e] = decodeURIComponent(h), l;
|
|
92
|
-
}
|
|
93
|
-
const u = Be(n, r, f, c, r - 1) + f.length;
|
|
94
|
-
if (c === u)
|
|
95
|
-
break;
|
|
96
|
-
c = u;
|
|
110
|
+
if (typeof cacheControl === "number") {
|
|
111
|
+
cacheControl = {
|
|
112
|
+
maxAge: cacheControl,
|
|
113
|
+
sMaxAge: cacheControl
|
|
114
|
+
};
|
|
97
115
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function Be(e, t, n, r, o) {
|
|
101
|
-
let i = e.lastIndexOf(n, r);
|
|
102
|
-
return i == r - n.length && (i = e.lastIndexOf(n, r - n.length - 1)), i > t ? i : o;
|
|
103
|
-
}
|
|
104
|
-
var k = /* @__PURE__ */ ((e) => (e[e.RouteName = 0] = "RouteName", e[e.Loaders = 1] = "Loaders", e[e.OriginalPathname = 2] = "OriginalPathname", e[e.RouteBundleNames = 3] = "RouteBundleNames", e))(k || {}), $ = /* @__PURE__ */ ((e) => (e[e.Pathname = 0] = "Pathname", e[e.MenuLoader = 1] = "MenuLoader", e))($ || {}), L = /* @__PURE__ */ ((e) => (e[e.RouteName = 0] = "RouteName", e[e.Params = 1] = "Params", e[e.Mods = 2] = "Mods", e[e.Menu = 3] = "Menu", e[e.RouteBundleNames = 4] = "RouteBundleNames", e))(L || {});
|
|
105
|
-
const Ae = (e) => e == null ? e : (Object.getOwnPropertyNames(e).forEach((t) => {
|
|
106
|
-
const n = e[t];
|
|
107
|
-
n && typeof n == "object" && !Object.isFrozen(n) && Ae(n);
|
|
108
|
-
}), Object.freeze(e)), Ke = async (e, t, n, r) => {
|
|
109
|
-
if (!Array.isArray(e))
|
|
110
|
-
return null;
|
|
111
|
-
for (const o of e) {
|
|
112
|
-
const i = o[k.RouteName], a = Ee(i, r);
|
|
113
|
-
if (!a)
|
|
114
|
-
continue;
|
|
115
|
-
const s = o[k.Loaders], c = o[k.RouteBundleNames], f = new Array(s.length), l = [];
|
|
116
|
-
s.forEach((y, w) => {
|
|
117
|
-
se(
|
|
118
|
-
y,
|
|
119
|
-
l,
|
|
120
|
-
(R) => f[w] = R,
|
|
121
|
-
n
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
const u = Je(t, r);
|
|
125
|
-
let h;
|
|
126
|
-
return se(
|
|
127
|
-
u,
|
|
128
|
-
l,
|
|
129
|
-
(y) => h = y?.default,
|
|
130
|
-
n
|
|
131
|
-
), l.length > 0 && await Promise.all(l), [i, a, f, Ae(h), c];
|
|
116
|
+
if (cacheControl.immutable) {
|
|
117
|
+
controls.push("immutable");
|
|
132
118
|
}
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
if (typeof e == "function") {
|
|
136
|
-
const o = ne.get(e);
|
|
137
|
-
if (o)
|
|
138
|
-
n(o);
|
|
139
|
-
else {
|
|
140
|
-
const i = e();
|
|
141
|
-
typeof i.then == "function" ? t.push(
|
|
142
|
-
i.then((a) => {
|
|
143
|
-
r !== !1 && ne.set(e, a), n(a);
|
|
144
|
-
})
|
|
145
|
-
) : i && n(i);
|
|
146
|
-
}
|
|
119
|
+
if (cacheControl.maxAge) {
|
|
120
|
+
controls.push(`max-age=${cacheControl.maxAge}`);
|
|
147
121
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
t = t.endsWith("/") ? t : t + "/";
|
|
151
|
-
const n = e.find(
|
|
152
|
-
(r) => r[$.Pathname] === t || t.startsWith(r[$.Pathname] + (t.endsWith("/") ? "" : "/"))
|
|
153
|
-
);
|
|
154
|
-
if (n)
|
|
155
|
-
return n[$.MenuLoader];
|
|
122
|
+
if (cacheControl.sMaxAge) {
|
|
123
|
+
controls.push(`s-maxage=${cacheControl.sMaxAge}`);
|
|
156
124
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
125
|
+
if (cacheControl.noStore) {
|
|
126
|
+
controls.push("no-store");
|
|
127
|
+
}
|
|
128
|
+
if (cacheControl.noCache) {
|
|
129
|
+
controls.push("no-cache");
|
|
130
|
+
}
|
|
131
|
+
if (cacheControl.private) {
|
|
132
|
+
controls.push("private");
|
|
133
|
+
}
|
|
134
|
+
if (cacheControl.public) {
|
|
135
|
+
controls.push("public");
|
|
136
|
+
}
|
|
137
|
+
if (cacheControl.staleWhileRevalidate) {
|
|
138
|
+
controls.push(`stale-while-revalidate=${cacheControl.staleWhileRevalidate}`);
|
|
139
|
+
}
|
|
140
|
+
if (cacheControl.staleIfError) {
|
|
141
|
+
controls.push(`stale-if-error=${cacheControl.staleIfError}`);
|
|
142
|
+
}
|
|
143
|
+
return controls.join(", ");
|
|
175
144
|
}
|
|
176
|
-
const
|
|
145
|
+
const SAMESITE = {
|
|
177
146
|
lax: "Lax",
|
|
178
147
|
Lax: "Lax",
|
|
179
148
|
None: "None",
|
|
180
149
|
none: "None",
|
|
181
150
|
strict: "Strict",
|
|
182
151
|
Strict: "Strict"
|
|
183
|
-
}
|
|
152
|
+
};
|
|
153
|
+
const UNIT = {
|
|
184
154
|
seconds: 1,
|
|
185
|
-
minutes: 60,
|
|
186
|
-
hours:
|
|
187
|
-
days:
|
|
188
|
-
weeks:
|
|
189
|
-
}, ce = (e, t, n) => {
|
|
190
|
-
const r = [`${e}=${t}`];
|
|
191
|
-
typeof n.domain == "string" && r.push(`Domain=${n.domain}`), typeof n.maxAge == "number" ? r.push(`Max-Age=${n.maxAge}`) : Array.isArray(n.maxAge) ? r.push(`Max-Age=${n.maxAge[0] * Xe[n.maxAge[1]]}`) : typeof n.expires == "number" || typeof n.expires == "string" ? r.push(`Expires=${n.expires}`) : n.expires instanceof Date && r.push(`Expires=${n.expires.toUTCString()}`), n.httpOnly && r.push("HttpOnly"), typeof n.path == "string" && r.push(`Path=${n.path}`);
|
|
192
|
-
const o = He(n.sameSite);
|
|
193
|
-
return o && r.push(`SameSite=${o}`), n.secure && r.push("Secure"), r.join("; ");
|
|
155
|
+
minutes: 1 * 60,
|
|
156
|
+
hours: 1 * 60 * 60,
|
|
157
|
+
days: 1 * 60 * 60 * 24,
|
|
158
|
+
weeks: 1 * 60 * 60 * 24 * 7
|
|
194
159
|
};
|
|
195
|
-
|
|
160
|
+
const createSetCookieValue = (cookieName, cookieValue, options) => {
|
|
161
|
+
const c = [`${cookieName}=${cookieValue}`];
|
|
162
|
+
if (typeof options.domain === "string") {
|
|
163
|
+
c.push(`Domain=${options.domain}`);
|
|
164
|
+
}
|
|
165
|
+
if (typeof options.maxAge === "number") {
|
|
166
|
+
c.push(`Max-Age=${options.maxAge}`);
|
|
167
|
+
} else if (Array.isArray(options.maxAge)) {
|
|
168
|
+
c.push(`Max-Age=${options.maxAge[0] * UNIT[options.maxAge[1]]}`);
|
|
169
|
+
} else if (typeof options.expires === "number" || typeof options.expires == "string") {
|
|
170
|
+
c.push(`Expires=${options.expires}`);
|
|
171
|
+
} else if (options.expires instanceof Date) {
|
|
172
|
+
c.push(`Expires=${options.expires.toUTCString()}`);
|
|
173
|
+
}
|
|
174
|
+
if (options.httpOnly) {
|
|
175
|
+
c.push("HttpOnly");
|
|
176
|
+
}
|
|
177
|
+
if (typeof options.path === "string") {
|
|
178
|
+
c.push(`Path=${options.path}`);
|
|
179
|
+
}
|
|
180
|
+
const sameSite = resolveSameSite(options.sameSite);
|
|
181
|
+
if (sameSite) {
|
|
182
|
+
c.push(`SameSite=${sameSite}`);
|
|
183
|
+
}
|
|
184
|
+
if (options.secure) {
|
|
185
|
+
c.push("Secure");
|
|
186
|
+
}
|
|
187
|
+
return c.join("; ");
|
|
188
|
+
};
|
|
189
|
+
function tryDecodeUriComponent(str) {
|
|
196
190
|
try {
|
|
197
|
-
return decodeURIComponent(
|
|
191
|
+
return decodeURIComponent(str);
|
|
198
192
|
} catch {
|
|
199
|
-
return
|
|
193
|
+
return str;
|
|
200
194
|
}
|
|
201
195
|
}
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
if (typeof
|
|
205
|
-
const
|
|
206
|
-
for (const
|
|
207
|
-
const
|
|
208
|
-
|
|
196
|
+
const parseCookieString = (cookieString) => {
|
|
197
|
+
const cookie = {};
|
|
198
|
+
if (typeof cookieString === "string" && cookieString !== "") {
|
|
199
|
+
const cookieSegments = cookieString.split(";");
|
|
200
|
+
for (const cookieSegment of cookieSegments) {
|
|
201
|
+
const separatorIndex = cookieSegment.indexOf("=");
|
|
202
|
+
if (separatorIndex !== -1) {
|
|
203
|
+
cookie[tryDecodeUriComponent(cookieSegment.slice(0, separatorIndex).trim())] = tryDecodeUriComponent(cookieSegment.slice(separatorIndex + 1).trim());
|
|
204
|
+
}
|
|
209
205
|
}
|
|
210
206
|
}
|
|
211
|
-
return
|
|
207
|
+
return cookie;
|
|
212
208
|
};
|
|
213
|
-
function
|
|
214
|
-
if (
|
|
209
|
+
function resolveSameSite(sameSite) {
|
|
210
|
+
if (sameSite === true) {
|
|
215
211
|
return "Strict";
|
|
216
|
-
|
|
212
|
+
}
|
|
213
|
+
if (sameSite === false) {
|
|
217
214
|
return "None";
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
}
|
|
216
|
+
if (sameSite) {
|
|
217
|
+
return SAMESITE[sameSite];
|
|
218
|
+
}
|
|
219
|
+
return void 0;
|
|
220
220
|
}
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
221
|
+
const REQ_COOKIE = Symbol("request-cookies");
|
|
222
|
+
const RES_COOKIE = Symbol("response-cookies");
|
|
223
|
+
const LIVE_COOKIE = Symbol("live-cookies");
|
|
224
|
+
_c = REQ_COOKIE, _b = RES_COOKIE, _a = LIVE_COOKIE;
|
|
225
|
+
class Cookie {
|
|
226
|
+
constructor(cookieString) {
|
|
227
|
+
__publicField(this, _c);
|
|
228
|
+
__publicField(this, _b, {});
|
|
229
|
+
__publicField(this, _a, {});
|
|
230
|
+
__publicField(this, "appendCounter", 0);
|
|
231
|
+
this[REQ_COOKIE] = parseCookieString(cookieString);
|
|
232
|
+
this[LIVE_COOKIE] = { ...this[REQ_COOKIE] };
|
|
233
|
+
}
|
|
234
|
+
get(cookieName, live = true) {
|
|
235
|
+
const value = this[live ? LIVE_COOKIE : REQ_COOKIE][cookieName];
|
|
236
|
+
if (!value) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
value,
|
|
234
241
|
json() {
|
|
235
|
-
return JSON.parse(
|
|
242
|
+
return JSON.parse(value);
|
|
236
243
|
},
|
|
237
244
|
number() {
|
|
238
|
-
return Number(
|
|
245
|
+
return Number(value);
|
|
239
246
|
}
|
|
240
|
-
}
|
|
247
|
+
};
|
|
241
248
|
}
|
|
242
|
-
getAll(
|
|
243
|
-
return Object.keys(this[
|
|
244
|
-
(
|
|
249
|
+
getAll(live = true) {
|
|
250
|
+
return Object.keys(this[live ? LIVE_COOKIE : REQ_COOKIE]).reduce(
|
|
251
|
+
(cookies, cookieName) => {
|
|
252
|
+
cookies[cookieName] = this.get(cookieName);
|
|
253
|
+
return cookies;
|
|
254
|
+
},
|
|
245
255
|
{}
|
|
246
256
|
);
|
|
247
257
|
}
|
|
248
|
-
has(
|
|
249
|
-
return !!this[
|
|
250
|
-
}
|
|
251
|
-
set(
|
|
252
|
-
this[
|
|
253
|
-
const
|
|
254
|
-
this[
|
|
255
|
-
}
|
|
256
|
-
append(
|
|
257
|
-
this[
|
|
258
|
-
const
|
|
259
|
-
this[
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
258
|
+
has(cookieName, live = true) {
|
|
259
|
+
return !!this[live ? LIVE_COOKIE : REQ_COOKIE][cookieName];
|
|
260
|
+
}
|
|
261
|
+
set(cookieName, cookieValue, options = {}) {
|
|
262
|
+
this[LIVE_COOKIE][cookieName] = typeof cookieValue === "string" ? cookieValue : JSON.stringify(cookieValue);
|
|
263
|
+
const resolvedValue = typeof cookieValue === "string" ? cookieValue : encodeURIComponent(JSON.stringify(cookieValue));
|
|
264
|
+
this[RES_COOKIE][cookieName] = createSetCookieValue(cookieName, resolvedValue, options);
|
|
265
|
+
}
|
|
266
|
+
append(cookieName, cookieValue, options = {}) {
|
|
267
|
+
this[LIVE_COOKIE][cookieName] = typeof cookieValue === "string" ? cookieValue : JSON.stringify(cookieValue);
|
|
268
|
+
const resolvedValue = typeof cookieValue === "string" ? cookieValue : encodeURIComponent(JSON.stringify(cookieValue));
|
|
269
|
+
this[RES_COOKIE][++this.appendCounter] = createSetCookieValue(
|
|
270
|
+
cookieName,
|
|
271
|
+
resolvedValue,
|
|
272
|
+
options
|
|
263
273
|
);
|
|
264
274
|
}
|
|
265
|
-
delete(
|
|
266
|
-
this.set(
|
|
275
|
+
delete(name, options) {
|
|
276
|
+
this.set(name, "deleted", { ...options, maxAge: 0 });
|
|
277
|
+
this[LIVE_COOKIE][name] = null;
|
|
267
278
|
}
|
|
268
279
|
headers() {
|
|
269
|
-
return Object.values(this[
|
|
280
|
+
return Object.values(this[RES_COOKIE]);
|
|
270
281
|
}
|
|
271
282
|
}
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
const
|
|
276
|
-
for (const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
283
|
+
const mergeHeadersCookies = (headers, cookies) => {
|
|
284
|
+
const cookieHeaders = cookies.headers();
|
|
285
|
+
if (cookieHeaders.length > 0) {
|
|
286
|
+
const newHeaders = new Headers(headers);
|
|
287
|
+
for (const cookie of cookieHeaders) {
|
|
288
|
+
newHeaders.append("Set-Cookie", cookie);
|
|
289
|
+
}
|
|
290
|
+
return newHeaders;
|
|
291
|
+
}
|
|
292
|
+
return headers;
|
|
281
293
|
};
|
|
282
|
-
function
|
|
283
|
-
let
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
<meta charset="utf-8">
|
|
292
|
-
<meta http-equiv="Status" content="${e}">
|
|
293
|
-
<title>${e} ${t}</title>
|
|
294
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
295
|
-
<style>
|
|
296
|
-
body { color: ${r}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
|
|
297
|
-
p { max-width: ${n}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${r}; overflow: hidden; }
|
|
298
|
-
strong { display: inline-block; padding: 15px; background: ${r}; color: white; }
|
|
299
|
-
span { display: inline-block; padding: 15px; }
|
|
300
|
-
</style>
|
|
301
|
-
</head>
|
|
302
|
-
<body><p><strong>${e}</strong> <span>${t}</span></p></body>
|
|
303
|
-
`;
|
|
304
|
-
}
|
|
305
|
-
const nn = /[&<>]/g, tn = (e) => e.replace(nn, (t) => {
|
|
306
|
-
switch (t) {
|
|
307
|
-
case "&":
|
|
308
|
-
return "&";
|
|
309
|
-
case "<":
|
|
310
|
-
return "<";
|
|
311
|
-
case ">":
|
|
312
|
-
return ">";
|
|
313
|
-
default:
|
|
314
|
-
return "";
|
|
315
|
-
}
|
|
316
|
-
}), rn = "#006ce9", on = "#713fc2";
|
|
317
|
-
let S;
|
|
318
|
-
import("node:async_hooks").then((e) => {
|
|
319
|
-
const t = e.AsyncLocalStorage;
|
|
320
|
-
S = new t(), globalThis.qcAsyncRequestStore = S;
|
|
321
|
-
}).catch((e) => {
|
|
322
|
-
console.warn(
|
|
323
|
-
"AsyncLocalStorage not available, continuing without it. This might impact concurrent server calls.",
|
|
324
|
-
e
|
|
325
|
-
);
|
|
326
|
-
});
|
|
327
|
-
function an(e, t, n, r, o = "/") {
|
|
328
|
-
let i;
|
|
329
|
-
const a = new Promise((c) => i = c), s = cn(
|
|
330
|
-
e,
|
|
331
|
-
t,
|
|
332
|
-
n,
|
|
333
|
-
o,
|
|
334
|
-
i
|
|
294
|
+
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, basePathname = "/") {
|
|
295
|
+
let resolve;
|
|
296
|
+
const responsePromise = new Promise((r) => resolve = r);
|
|
297
|
+
const requestEv = createRequestEvent(
|
|
298
|
+
serverRequestEv,
|
|
299
|
+
loadedRoute,
|
|
300
|
+
requestHandlers,
|
|
301
|
+
basePathname,
|
|
302
|
+
resolve
|
|
335
303
|
);
|
|
336
304
|
return {
|
|
337
|
-
response:
|
|
338
|
-
requestEv
|
|
339
|
-
completion:
|
|
305
|
+
response: responsePromise,
|
|
306
|
+
requestEv,
|
|
307
|
+
completion: _asyncRequestStore$1 ? _asyncRequestStore$1.run(requestEv, runNext, requestEv, rebuildRouteInfo, resolve) : runNext(requestEv, rebuildRouteInfo, resolve)
|
|
340
308
|
};
|
|
341
309
|
}
|
|
342
|
-
async function
|
|
310
|
+
async function runNext(requestEv, rebuildRouteInfo, resolve) {
|
|
343
311
|
try {
|
|
344
|
-
(
|
|
312
|
+
const isValidURL = (url) => new URL(url.pathname + url.search, url);
|
|
313
|
+
isValidURL(requestEv.originalUrl);
|
|
345
314
|
} catch {
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
315
|
+
const status = 404;
|
|
316
|
+
const message = "Resource Not Found";
|
|
317
|
+
requestEv.status(status);
|
|
318
|
+
const html = getErrorHtml(status, message);
|
|
319
|
+
requestEv.html(status, html);
|
|
320
|
+
return new ServerError$1(status, message);
|
|
350
321
|
}
|
|
351
|
-
let
|
|
352
|
-
async function
|
|
322
|
+
let rewriteAttempt = 1;
|
|
323
|
+
async function _runNext() {
|
|
353
324
|
try {
|
|
354
|
-
await
|
|
355
|
-
} catch (
|
|
356
|
-
if (
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
a.pathname = i.pathname;
|
|
364
|
-
const { loadedRoute: s, requestHandlers: c } = await t(a);
|
|
365
|
-
return e.resetRoute(s, c, a), await o();
|
|
366
|
-
} else if (i instanceof F) {
|
|
367
|
-
if (!e.headersSent) {
|
|
368
|
-
const a = i.status, s = e.request.headers.get("Accept");
|
|
369
|
-
if (s && !s.includes("text/html"))
|
|
370
|
-
e.headers.set("Content-Type", "application/qwik-json"), e.send(a, await D([i.data]));
|
|
371
|
-
else {
|
|
372
|
-
const c = K(i.status, i.data);
|
|
373
|
-
e.html(a, c);
|
|
374
|
-
}
|
|
325
|
+
await requestEv.next();
|
|
326
|
+
} catch (e) {
|
|
327
|
+
if (e instanceof RedirectMessage$1) {
|
|
328
|
+
const stream = requestEv.getWritableStream();
|
|
329
|
+
await stream.close();
|
|
330
|
+
return e;
|
|
331
|
+
} else if (e instanceof RewriteMessage$1) {
|
|
332
|
+
if (rewriteAttempt > 50) {
|
|
333
|
+
return new Error(`Infinite rewrite loop`);
|
|
375
334
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
335
|
+
rewriteAttempt += 1;
|
|
336
|
+
const url = new URL(requestEv.url);
|
|
337
|
+
url.pathname = e.pathname;
|
|
338
|
+
const { loadedRoute, requestHandlers } = await rebuildRouteInfo(url);
|
|
339
|
+
requestEv.resetRoute(loadedRoute, requestHandlers, url);
|
|
340
|
+
return await _runNext();
|
|
341
|
+
} else if (e instanceof AbortMessage$1) {
|
|
342
|
+
return;
|
|
343
|
+
} else if (e instanceof ServerError$1 && !requestEv.headersSent) {
|
|
344
|
+
const status = e.status;
|
|
345
|
+
const accept = requestEv.request.headers.get("Accept");
|
|
346
|
+
if (accept && !accept.includes("text/html")) {
|
|
347
|
+
requestEv.headers.set("Content-Type", "application/qwik-json");
|
|
348
|
+
requestEv.send(status, await _serialize([e.data]));
|
|
349
|
+
} else {
|
|
350
|
+
requestEv.html(status, getErrorHtml(status, e.data));
|
|
351
|
+
}
|
|
352
|
+
return e;
|
|
353
|
+
}
|
|
354
|
+
if (getRequestMode(requestEv) !== "dev") {
|
|
355
|
+
try {
|
|
356
|
+
if (!requestEv.headersSent) {
|
|
357
|
+
requestEv.headers.set("content-type", "text/html; charset=utf-8");
|
|
358
|
+
requestEv.cacheControl({ noCache: true });
|
|
359
|
+
requestEv.status(500);
|
|
387
360
|
}
|
|
388
|
-
|
|
361
|
+
const stream = requestEv.getWritableStream();
|
|
362
|
+
if (!stream.locked) {
|
|
363
|
+
const writer = stream.getWriter();
|
|
364
|
+
await writer.write(encoder.encode(getErrorHtml(500, "Internal Server Error")));
|
|
365
|
+
await writer.close();
|
|
366
|
+
}
|
|
367
|
+
} catch {
|
|
368
|
+
console.error("Unable to render error page");
|
|
369
|
+
}
|
|
389
370
|
}
|
|
371
|
+
return e;
|
|
390
372
|
}
|
|
391
373
|
}
|
|
392
374
|
try {
|
|
393
|
-
return await
|
|
375
|
+
return await _runNext();
|
|
394
376
|
} finally {
|
|
395
|
-
|
|
377
|
+
if (!requestEv.isDirty()) {
|
|
378
|
+
resolve(null);
|
|
379
|
+
}
|
|
396
380
|
}
|
|
397
381
|
}
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
382
|
+
function getRouteMatchPathname(pathname) {
|
|
383
|
+
const isInternal = pathname.endsWith(QDATA_JSON);
|
|
384
|
+
if (isInternal) {
|
|
385
|
+
const trimEnd = pathname.length - QDATA_JSON.length + (globalThis.__NO_TRAILING_SLASH__ ? 0 : 1);
|
|
386
|
+
pathname = pathname.slice(0, trimEnd);
|
|
387
|
+
if (pathname === "") {
|
|
388
|
+
pathname = "/";
|
|
389
|
+
}
|
|
402
390
|
}
|
|
403
|
-
return
|
|
391
|
+
return { pathname, isInternal };
|
|
404
392
|
}
|
|
405
|
-
const
|
|
393
|
+
const IsQData = "@isQData";
|
|
394
|
+
const QDATA_JSON = "/q-data.json";
|
|
395
|
+
const RequestEvLoaders = Symbol("RequestEvLoaders");
|
|
396
|
+
const RequestEvMode = Symbol("RequestEvMode");
|
|
397
|
+
const RequestEvRoute = Symbol("RequestEvRoute");
|
|
398
|
+
const RequestEvLoaderSerializationStrategyMap = Symbol(
|
|
406
399
|
"RequestEvLoaderSerializationStrategyMap"
|
|
407
|
-
)
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
400
|
+
);
|
|
401
|
+
const RequestRouteName = "@routeName";
|
|
402
|
+
const RequestEvSharedActionId = "@actionId";
|
|
403
|
+
const RequestEvSharedActionFormData = "@actionFormData";
|
|
404
|
+
const RequestEvSharedNonce = "@nonce";
|
|
405
|
+
const RequestEvIsRewrite = "@rewrite";
|
|
406
|
+
const RequestEvShareServerTiming = "@serverTiming";
|
|
407
|
+
const RequestEvShareQData = "qData";
|
|
408
|
+
function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, basePathname, resolved) {
|
|
409
|
+
const { request, platform, env } = serverRequestEv;
|
|
410
|
+
const sharedMap = /* @__PURE__ */ new Map();
|
|
411
|
+
const cookie = new Cookie(request.headers.get("cookie"));
|
|
412
|
+
const headers = new Headers();
|
|
413
|
+
const url = new URL(request.url);
|
|
414
|
+
const { pathname, isInternal } = getRouteMatchPathname(url.pathname);
|
|
415
|
+
if (isInternal) {
|
|
416
|
+
url.pathname = pathname;
|
|
417
|
+
sharedMap.set(IsQData, true);
|
|
418
|
+
}
|
|
419
|
+
let routeModuleIndex = -1;
|
|
420
|
+
let writableStream = null;
|
|
421
|
+
let requestData = void 0;
|
|
422
|
+
let locale = serverRequestEv.locale;
|
|
423
|
+
let status = 200;
|
|
424
|
+
const next = async () => {
|
|
425
|
+
routeModuleIndex++;
|
|
426
|
+
while (routeModuleIndex < requestHandlers.length) {
|
|
427
|
+
const moduleRequestHandler = requestHandlers[routeModuleIndex];
|
|
428
|
+
const result = moduleRequestHandler(requestEv);
|
|
429
|
+
if (isPromise(result)) {
|
|
430
|
+
await result;
|
|
431
|
+
}
|
|
432
|
+
routeModuleIndex++;
|
|
416
433
|
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
434
|
+
};
|
|
435
|
+
const resetRoute = (_loadedRoute, _requestHandlers, _url = url) => {
|
|
436
|
+
loadedRoute = _loadedRoute;
|
|
437
|
+
requestHandlers = _requestHandlers;
|
|
438
|
+
url.pathname = _url.pathname;
|
|
439
|
+
url.search = _url.search;
|
|
440
|
+
routeModuleIndex = -1;
|
|
441
|
+
};
|
|
442
|
+
const check = () => {
|
|
443
|
+
if (writableStream !== null) {
|
|
421
444
|
throw new Error("Response already sent");
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const send = (statusOrResponse, body) => {
|
|
448
|
+
check();
|
|
449
|
+
if (typeof statusOrResponse === "number") {
|
|
450
|
+
status = statusOrResponse;
|
|
451
|
+
const writableStream2 = requestEv.getWritableStream();
|
|
452
|
+
const writer = writableStream2.getWriter();
|
|
453
|
+
writer.write(typeof body === "string" ? encoder.encode(body) : body);
|
|
454
|
+
writer.close();
|
|
455
|
+
} else {
|
|
456
|
+
status = statusOrResponse.status;
|
|
457
|
+
statusOrResponse.headers.forEach((value, key) => {
|
|
458
|
+
if (key.toLowerCase() === "set-cookie") {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
headers.append(key, value);
|
|
462
|
+
});
|
|
463
|
+
statusOrResponse.headers.getSetCookie().forEach((ck) => {
|
|
464
|
+
const index = ck.indexOf("=");
|
|
465
|
+
if (index === -1) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const key = ck.slice(0, index).trim();
|
|
469
|
+
const value = ck.slice(index + 1).trim();
|
|
470
|
+
cookie.set(key, value);
|
|
471
|
+
});
|
|
472
|
+
if (statusOrResponse.body) {
|
|
473
|
+
const writableStream2 = requestEv.getWritableStream();
|
|
474
|
+
statusOrResponse.body.pipeTo(writableStream2);
|
|
475
|
+
} else {
|
|
476
|
+
requestEv.getWritableStream().getWriter().close();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return exit();
|
|
480
|
+
};
|
|
481
|
+
const exit = (message = new AbortMessage$1()) => {
|
|
482
|
+
routeModuleIndex = ABORT_INDEX;
|
|
483
|
+
return message;
|
|
484
|
+
};
|
|
485
|
+
const loaders = {};
|
|
486
|
+
const requestEv = {
|
|
487
|
+
[RequestEvLoaders]: loaders,
|
|
488
|
+
[RequestEvLoaderSerializationStrategyMap]: /* @__PURE__ */ new Map(),
|
|
489
|
+
[RequestEvMode]: serverRequestEv.mode,
|
|
490
|
+
get [RequestEvRoute]() {
|
|
491
|
+
return loadedRoute;
|
|
447
492
|
},
|
|
448
|
-
cookie
|
|
449
|
-
headers
|
|
450
|
-
env
|
|
451
|
-
method:
|
|
452
|
-
signal:
|
|
453
|
-
originalUrl: new URL(
|
|
493
|
+
cookie,
|
|
494
|
+
headers,
|
|
495
|
+
env,
|
|
496
|
+
method: request.method,
|
|
497
|
+
signal: request.signal,
|
|
498
|
+
originalUrl: new URL(url),
|
|
454
499
|
get params() {
|
|
455
|
-
return
|
|
500
|
+
return loadedRoute?.[LoadedRouteProp.Params] ?? {};
|
|
456
501
|
},
|
|
457
502
|
get pathname() {
|
|
458
|
-
return
|
|
503
|
+
return url.pathname;
|
|
459
504
|
},
|
|
460
|
-
platform
|
|
505
|
+
platform,
|
|
461
506
|
get query() {
|
|
462
|
-
return
|
|
507
|
+
return url.searchParams;
|
|
463
508
|
},
|
|
464
|
-
request
|
|
465
|
-
url
|
|
466
|
-
basePathname
|
|
467
|
-
sharedMap
|
|
509
|
+
request,
|
|
510
|
+
url,
|
|
511
|
+
basePathname,
|
|
512
|
+
sharedMap,
|
|
468
513
|
get headersSent() {
|
|
469
|
-
return
|
|
514
|
+
return writableStream !== null;
|
|
470
515
|
},
|
|
471
516
|
get exited() {
|
|
472
|
-
return
|
|
517
|
+
return routeModuleIndex >= ABORT_INDEX;
|
|
473
518
|
},
|
|
474
519
|
get clientConn() {
|
|
475
|
-
return
|
|
520
|
+
return serverRequestEv.getClientConn();
|
|
476
521
|
},
|
|
477
|
-
next
|
|
478
|
-
resetRoute
|
|
479
|
-
exit
|
|
480
|
-
cacheControl: (
|
|
481
|
-
|
|
522
|
+
next,
|
|
523
|
+
resetRoute,
|
|
524
|
+
exit,
|
|
525
|
+
cacheControl: (cacheControl, target = "Cache-Control") => {
|
|
526
|
+
check();
|
|
527
|
+
headers.set(target, createCacheControl(cacheControl));
|
|
482
528
|
},
|
|
483
|
-
resolveValue: (async (
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
if (!(
|
|
529
|
+
resolveValue: (async (loaderOrAction) => {
|
|
530
|
+
const id = loaderOrAction.__id;
|
|
531
|
+
if (loaderOrAction.__brand === "server_loader") {
|
|
532
|
+
if (!(id in loaders)) {
|
|
487
533
|
throw new Error(
|
|
488
534
|
"You can not get the returned data of a loader that has not been executed for this request."
|
|
489
535
|
);
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
536
|
+
}
|
|
537
|
+
if (loaders[id] === _UNINITIALIZED) {
|
|
538
|
+
const isDev = getRequestMode(requestEv) === "dev";
|
|
539
|
+
await getRouteLoaderPromise(loaderOrAction, loaders, requestEv, isDev);
|
|
493
540
|
}
|
|
494
541
|
}
|
|
495
|
-
return
|
|
542
|
+
return loaders[id];
|
|
496
543
|
}),
|
|
497
|
-
status: (
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
544
|
+
status: (statusCode) => {
|
|
545
|
+
if (typeof statusCode === "number") {
|
|
546
|
+
check();
|
|
547
|
+
status = statusCode;
|
|
548
|
+
return statusCode;
|
|
549
|
+
}
|
|
550
|
+
return status;
|
|
551
|
+
},
|
|
552
|
+
locale: (_locale) => {
|
|
553
|
+
if (typeof _locale === "string") {
|
|
554
|
+
locale = _locale;
|
|
555
|
+
}
|
|
556
|
+
return locale || "";
|
|
557
|
+
},
|
|
558
|
+
error: (statusCode, message) => {
|
|
559
|
+
status = statusCode;
|
|
560
|
+
headers.delete("Cache-Control");
|
|
561
|
+
return new ServerError$1(statusCode, message);
|
|
562
|
+
},
|
|
563
|
+
redirect: (statusCode, url2) => {
|
|
564
|
+
check();
|
|
565
|
+
status = statusCode;
|
|
566
|
+
if (url2) {
|
|
567
|
+
if (/([^:])\/{2,}/.test(url2)) {
|
|
568
|
+
const fixedURL = url2.replace(/([^:])\/{2,}/g, "$1/");
|
|
569
|
+
console.warn(`Redirect URL ${url2} is invalid, fixing to ${fixedURL}`);
|
|
570
|
+
url2 = fixedURL;
|
|
571
|
+
}
|
|
572
|
+
headers.set("Location", url2);
|
|
504
573
|
}
|
|
505
|
-
|
|
574
|
+
headers.delete("Cache-Control");
|
|
575
|
+
if (statusCode > 301) {
|
|
576
|
+
headers.set("Cache-Control", "no-store");
|
|
577
|
+
}
|
|
578
|
+
return exit(new RedirectMessage$1());
|
|
506
579
|
},
|
|
507
|
-
rewrite: (
|
|
508
|
-
|
|
580
|
+
rewrite: (pathname2) => {
|
|
581
|
+
check();
|
|
582
|
+
if (pathname2.startsWith("http")) {
|
|
509
583
|
throw new Error("Rewrite does not support absolute urls");
|
|
510
|
-
|
|
584
|
+
}
|
|
585
|
+
sharedMap.set(RequestEvIsRewrite, true);
|
|
586
|
+
return exit(new RewriteMessage$1(pathname2.replace(/\/+/g, "/")));
|
|
587
|
+
},
|
|
588
|
+
defer: (returnData) => {
|
|
589
|
+
return typeof returnData === "function" ? returnData : () => returnData;
|
|
590
|
+
},
|
|
591
|
+
fail: (statusCode, data) => {
|
|
592
|
+
check();
|
|
593
|
+
status = statusCode;
|
|
594
|
+
headers.delete("Cache-Control");
|
|
595
|
+
return {
|
|
596
|
+
failed: true,
|
|
597
|
+
...data
|
|
598
|
+
};
|
|
599
|
+
},
|
|
600
|
+
text: (statusCode, text) => {
|
|
601
|
+
headers.set("Content-Type", "text/plain; charset=utf-8");
|
|
602
|
+
return send(statusCode, text);
|
|
603
|
+
},
|
|
604
|
+
html: (statusCode, html) => {
|
|
605
|
+
headers.set("Content-Type", "text/html; charset=utf-8");
|
|
606
|
+
return send(statusCode, html);
|
|
607
|
+
},
|
|
608
|
+
parseBody: async () => {
|
|
609
|
+
if (requestData !== void 0) {
|
|
610
|
+
return requestData;
|
|
611
|
+
}
|
|
612
|
+
return requestData = parseRequest(requestEv, sharedMap);
|
|
613
|
+
},
|
|
614
|
+
json: (statusCode, data) => {
|
|
615
|
+
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
616
|
+
return send(statusCode, JSON.stringify(data));
|
|
617
|
+
},
|
|
618
|
+
send,
|
|
619
|
+
isDirty: () => {
|
|
620
|
+
return writableStream !== null;
|
|
511
621
|
},
|
|
512
|
-
defer: (d) => typeof d == "function" ? d : () => d,
|
|
513
|
-
fail: (d, m) => (N(), p = d, l.delete("Cache-Control"), {
|
|
514
|
-
failed: !0,
|
|
515
|
-
...m
|
|
516
|
-
}),
|
|
517
|
-
text: (d, m) => (l.set("Content-Type", "text/plain; charset=utf-8"), W(d, m)),
|
|
518
|
-
html: (d, m) => (l.set("Content-Type", "text/html; charset=utf-8"), W(d, m)),
|
|
519
|
-
parseBody: async () => w !== void 0 ? w : w = dn(b, c),
|
|
520
|
-
json: (d, m) => (l.set("Content-Type", "application/json; charset=utf-8"), W(d, JSON.stringify(m))),
|
|
521
|
-
send: W,
|
|
522
|
-
isDirty: () => y !== null,
|
|
523
622
|
getWritableStream: () => {
|
|
524
|
-
if (
|
|
525
|
-
if (
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
623
|
+
if (writableStream === null) {
|
|
624
|
+
if (serverRequestEv.mode === "dev") {
|
|
625
|
+
const serverTiming = sharedMap.get(RequestEvShareServerTiming);
|
|
626
|
+
if (serverTiming) {
|
|
627
|
+
headers.set(
|
|
628
|
+
"Server-Timing",
|
|
629
|
+
serverTiming.map(([name, duration]) => `${name};dur=${duration}`).join(",")
|
|
630
|
+
);
|
|
631
|
+
}
|
|
531
632
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
633
|
+
writableStream = serverRequestEv.getWritableStream(
|
|
634
|
+
status,
|
|
635
|
+
headers,
|
|
636
|
+
cookie,
|
|
637
|
+
resolved,
|
|
638
|
+
requestEv
|
|
538
639
|
);
|
|
539
640
|
}
|
|
540
|
-
return
|
|
641
|
+
return writableStream;
|
|
541
642
|
}
|
|
542
643
|
};
|
|
543
|
-
return Object.freeze(
|
|
644
|
+
return Object.freeze(requestEv);
|
|
544
645
|
}
|
|
545
|
-
function
|
|
546
|
-
return
|
|
646
|
+
function getRequestLoaders(requestEv) {
|
|
647
|
+
return requestEv[RequestEvLoaders];
|
|
547
648
|
}
|
|
548
|
-
function
|
|
549
|
-
return
|
|
649
|
+
function getRequestLoaderSerializationStrategyMap(requestEv) {
|
|
650
|
+
return requestEv[RequestEvLoaderSerializationStrategyMap];
|
|
550
651
|
}
|
|
551
|
-
function
|
|
552
|
-
return
|
|
652
|
+
function getRequestRoute(requestEv) {
|
|
653
|
+
return requestEv[RequestEvRoute];
|
|
553
654
|
}
|
|
554
|
-
function
|
|
555
|
-
return
|
|
655
|
+
function getRequestMode(requestEv) {
|
|
656
|
+
return requestEv[RequestEvMode];
|
|
556
657
|
}
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
658
|
+
const ABORT_INDEX = Number.MAX_SAFE_INTEGER;
|
|
659
|
+
const parseRequest = async ({ request, method, query }, sharedMap) => {
|
|
660
|
+
const type = request.headers.get("content-type")?.split(/[;,]/, 1)[0].trim() ?? "";
|
|
661
|
+
if (type === "application/x-www-form-urlencoded" || type === "multipart/form-data") {
|
|
662
|
+
const formData = await request.formData();
|
|
663
|
+
sharedMap.set(RequestEvSharedActionFormData, formData);
|
|
664
|
+
return formToObj(formData);
|
|
665
|
+
} else if (type === "application/json") {
|
|
666
|
+
const data = await request.json();
|
|
667
|
+
return data;
|
|
668
|
+
} else if (type === "application/qwik-json") {
|
|
669
|
+
if (method === "GET" && query.has(QDATA_KEY)) {
|
|
670
|
+
const data = query.get(QDATA_KEY);
|
|
671
|
+
if (data) {
|
|
672
|
+
try {
|
|
673
|
+
return _deserialize(decodeURIComponent(data));
|
|
674
|
+
} catch {
|
|
675
|
+
}
|
|
573
676
|
}
|
|
574
|
-
return ee(await e.text());
|
|
575
677
|
}
|
|
678
|
+
return _deserialize(await request.text());
|
|
679
|
+
}
|
|
680
|
+
return void 0;
|
|
681
|
+
};
|
|
682
|
+
const formToObj = (formData) => {
|
|
683
|
+
const values = [...formData.entries()].reduce((values2, [name, value]) => {
|
|
684
|
+
name.split(".").reduce((object, key, index, keys) => {
|
|
685
|
+
if (key.endsWith("[]")) {
|
|
686
|
+
const arrayKey = key.slice(0, -2);
|
|
687
|
+
object[arrayKey] = object[arrayKey] || [];
|
|
688
|
+
return object[arrayKey] = [...object[arrayKey], value];
|
|
689
|
+
}
|
|
690
|
+
if (index < keys.length - 1) {
|
|
691
|
+
return object[key] = object[key] || (Number.isNaN(+keys[index + 1]) ? {} : []);
|
|
692
|
+
}
|
|
693
|
+
return object[key] = value;
|
|
694
|
+
}, values2);
|
|
695
|
+
return values2;
|
|
696
|
+
}, {});
|
|
697
|
+
return values;
|
|
698
|
+
};
|
|
699
|
+
function getQwikRouterServerData(requestEv) {
|
|
700
|
+
const { params, request, status, locale, originalUrl } = requestEv;
|
|
701
|
+
const requestHeaders = {};
|
|
702
|
+
request.headers.forEach((value, key) => requestHeaders[key] = value);
|
|
703
|
+
const action = requestEv.sharedMap.get(RequestEvSharedActionId);
|
|
704
|
+
const formData = requestEv.sharedMap.get(RequestEvSharedActionFormData);
|
|
705
|
+
const routeName = requestEv.sharedMap.get(RequestRouteName);
|
|
706
|
+
const nonce = requestEv.sharedMap.get(RequestEvSharedNonce);
|
|
707
|
+
const headers = requestEv.request.headers;
|
|
708
|
+
const reconstructedUrl = new URL(originalUrl.pathname + originalUrl.search, originalUrl);
|
|
709
|
+
const host = headers.get("X-Forwarded-Host");
|
|
710
|
+
const protocol = headers.get("X-Forwarded-Proto");
|
|
711
|
+
if (host) {
|
|
712
|
+
reconstructedUrl.port = "";
|
|
713
|
+
reconstructedUrl.host = host;
|
|
576
714
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
return s < c.length - 1 ? i[a] = i[a] || (Number.isNaN(+c[s + 1]) ? {} : []) : i[a] = o;
|
|
583
|
-
}, n), n), {});
|
|
584
|
-
function un(e) {
|
|
585
|
-
const { params: t, request: n, status: r, locale: o, originalUrl: i } = e, a = {};
|
|
586
|
-
n.headers.forEach((T, M) => a[M] = T);
|
|
587
|
-
const s = e.sharedMap.get(j), c = e.sharedMap.get(Ie), f = e.sharedMap.get(Pe), l = e.sharedMap.get(sn), u = e.request.headers, h = new URL(i.pathname + i.search, i), y = u.get("X-Forwarded-Host"), w = u.get("X-Forwarded-Proto");
|
|
588
|
-
y && (h.port = "", h.host = y), w && (h.protocol = w);
|
|
589
|
-
const R = U(e), p = Ue(e);
|
|
715
|
+
if (protocol) {
|
|
716
|
+
reconstructedUrl.protocol = protocol;
|
|
717
|
+
}
|
|
718
|
+
const loaders = getRequestLoaders(requestEv);
|
|
719
|
+
const loadersSerializationStrategy = getRequestLoaderSerializationStrategyMap(requestEv);
|
|
590
720
|
return {
|
|
591
|
-
url:
|
|
592
|
-
requestHeaders
|
|
593
|
-
locale:
|
|
594
|
-
nonce
|
|
721
|
+
url: reconstructedUrl.href,
|
|
722
|
+
requestHeaders,
|
|
723
|
+
locale: locale(),
|
|
724
|
+
nonce,
|
|
595
725
|
containerAttributes: {
|
|
596
|
-
[
|
|
726
|
+
[Q_ROUTE]: routeName
|
|
597
727
|
},
|
|
598
728
|
qwikrouter: {
|
|
599
|
-
routeName
|
|
600
|
-
ev:
|
|
601
|
-
params: { ...
|
|
602
|
-
loadedRoute:
|
|
729
|
+
routeName,
|
|
730
|
+
ev: requestEv,
|
|
731
|
+
params: { ...params },
|
|
732
|
+
loadedRoute: getRequestRoute(requestEv),
|
|
603
733
|
response: {
|
|
604
|
-
status:
|
|
605
|
-
loaders
|
|
606
|
-
loadersSerializationStrategy
|
|
607
|
-
action
|
|
608
|
-
formData
|
|
734
|
+
status: status(),
|
|
735
|
+
loaders,
|
|
736
|
+
loadersSerializationStrategy,
|
|
737
|
+
action,
|
|
738
|
+
formData
|
|
609
739
|
}
|
|
610
740
|
}
|
|
611
741
|
};
|
|
612
742
|
}
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
743
|
+
const resolveRequestHandlers = (serverPlugins, route, method, checkOrigin, renderHandler, isInternal) => {
|
|
744
|
+
const routeLoaders = [];
|
|
745
|
+
const routeActions = [];
|
|
746
|
+
const requestHandlers = [];
|
|
747
|
+
const isPageRoute = !!(route && isLastModulePageRoute(route[LoadedRouteProp.Mods]));
|
|
748
|
+
if (isInternal) {
|
|
749
|
+
requestHandlers.push(handleQDataRedirect);
|
|
750
|
+
}
|
|
751
|
+
if (serverPlugins) {
|
|
752
|
+
_resolveRequestHandlers(
|
|
753
|
+
routeLoaders,
|
|
754
|
+
routeActions,
|
|
755
|
+
requestHandlers,
|
|
756
|
+
serverPlugins,
|
|
757
|
+
isPageRoute,
|
|
758
|
+
method
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
if (route) {
|
|
762
|
+
const routeModules = route[LoadedRouteProp.Mods];
|
|
763
|
+
_resolveRequestHandlers(
|
|
764
|
+
routeLoaders,
|
|
765
|
+
routeActions,
|
|
766
|
+
requestHandlers,
|
|
767
|
+
routeModules,
|
|
768
|
+
isPageRoute,
|
|
769
|
+
method
|
|
770
|
+
);
|
|
771
|
+
const routeName = route[LoadedRouteProp.RouteName];
|
|
772
|
+
if (checkOrigin && (method === "POST" || method === "PUT" || method === "PATCH" || method === "DELETE")) {
|
|
773
|
+
if (checkOrigin === "lax-proto") {
|
|
774
|
+
requestHandlers.unshift(csrfLaxProtoCheckMiddleware);
|
|
775
|
+
} else {
|
|
776
|
+
requestHandlers.unshift(csrfCheckMiddleware);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
if (isPageRoute) {
|
|
780
|
+
if (method === "POST" || method === "GET") {
|
|
781
|
+
requestHandlers.push(runServerFunction);
|
|
782
|
+
}
|
|
783
|
+
requestHandlers.push(fixTrailingSlash);
|
|
784
|
+
if (isInternal) {
|
|
785
|
+
requestHandlers.push(renderQData);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (isPageRoute) {
|
|
789
|
+
requestHandlers.push((ev) => {
|
|
790
|
+
ev.sharedMap.set(RequestRouteName, routeName);
|
|
791
|
+
});
|
|
792
|
+
requestHandlers.push(actionsMiddleware(routeActions));
|
|
793
|
+
requestHandlers.push(loadersMiddleware(routeLoaders));
|
|
794
|
+
requestHandlers.push(renderHandler);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return requestHandlers;
|
|
798
|
+
};
|
|
799
|
+
const _resolveRequestHandlers = (routeLoaders, routeActions, requestHandlers, routeModules, collectActions, method) => {
|
|
800
|
+
for (const routeModule of routeModules) {
|
|
801
|
+
if (typeof routeModule.onRequest === "function") {
|
|
802
|
+
requestHandlers.push(routeModule.onRequest);
|
|
803
|
+
} else if (Array.isArray(routeModule.onRequest)) {
|
|
804
|
+
requestHandlers.push(...routeModule.onRequest);
|
|
805
|
+
}
|
|
806
|
+
let methodReqHandler;
|
|
807
|
+
switch (method) {
|
|
643
808
|
case "GET": {
|
|
644
|
-
|
|
809
|
+
methodReqHandler = routeModule.onGet;
|
|
645
810
|
break;
|
|
646
811
|
}
|
|
647
812
|
case "POST": {
|
|
648
|
-
|
|
813
|
+
methodReqHandler = routeModule.onPost;
|
|
649
814
|
break;
|
|
650
815
|
}
|
|
651
816
|
case "PUT": {
|
|
652
|
-
|
|
817
|
+
methodReqHandler = routeModule.onPut;
|
|
653
818
|
break;
|
|
654
819
|
}
|
|
655
820
|
case "PATCH": {
|
|
656
|
-
|
|
821
|
+
methodReqHandler = routeModule.onPatch;
|
|
657
822
|
break;
|
|
658
823
|
}
|
|
659
824
|
case "DELETE": {
|
|
660
|
-
|
|
825
|
+
methodReqHandler = routeModule.onDelete;
|
|
661
826
|
break;
|
|
662
827
|
}
|
|
663
828
|
case "OPTIONS": {
|
|
664
|
-
|
|
829
|
+
methodReqHandler = routeModule.onOptions;
|
|
665
830
|
break;
|
|
666
831
|
}
|
|
667
832
|
case "HEAD": {
|
|
668
|
-
|
|
833
|
+
methodReqHandler = routeModule.onHead;
|
|
669
834
|
break;
|
|
670
835
|
}
|
|
671
836
|
}
|
|
672
|
-
if (typeof
|
|
673
|
-
|
|
674
|
-
|
|
837
|
+
if (typeof methodReqHandler === "function") {
|
|
838
|
+
requestHandlers.push(methodReqHandler);
|
|
839
|
+
} else if (Array.isArray(methodReqHandler)) {
|
|
840
|
+
requestHandlers.push(...methodReqHandler);
|
|
841
|
+
}
|
|
842
|
+
if (collectActions) {
|
|
843
|
+
for (const module of Object.values(routeModule)) {
|
|
844
|
+
if (typeof module === "function") {
|
|
845
|
+
if (module.__brand === "server_loader") {
|
|
846
|
+
routeLoaders.push(module);
|
|
847
|
+
} else if (module.__brand === "server_action") {
|
|
848
|
+
routeActions.push(module);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
675
853
|
}
|
|
676
854
|
};
|
|
677
|
-
function
|
|
678
|
-
return async (
|
|
679
|
-
const
|
|
680
|
-
if (
|
|
681
|
-
|
|
855
|
+
function actionsMiddleware(routeActions) {
|
|
856
|
+
return async (requestEvent) => {
|
|
857
|
+
const requestEv = requestEvent;
|
|
858
|
+
if (requestEv.headersSent) {
|
|
859
|
+
requestEv.exit();
|
|
682
860
|
return;
|
|
683
861
|
}
|
|
684
|
-
const { method
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
862
|
+
const { method } = requestEv;
|
|
863
|
+
const loaders = getRequestLoaders(requestEv);
|
|
864
|
+
const isDev = getRequestMode(requestEv) === "dev";
|
|
865
|
+
if (isDev && method === "GET") {
|
|
866
|
+
if (requestEv.query.has(QACTION_KEY)) {
|
|
867
|
+
console.warn(
|
|
868
|
+
'Seems like you are submitting a Qwik Action via GET request. Qwik Actions should be submitted via POST request.\nMake sure your <form> has method="POST" attribute, like this: <form method="POST">'
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
if (method === "POST") {
|
|
873
|
+
const selectedActionId = requestEv.query.get(QACTION_KEY);
|
|
874
|
+
if (selectedActionId) {
|
|
875
|
+
const serverActionsMap = globalThis._qwikActionsMap;
|
|
876
|
+
const action = routeActions.find((action2) => action2.__id === selectedActionId) ?? serverActionsMap?.get(selectedActionId);
|
|
877
|
+
if (action) {
|
|
878
|
+
requestEv.sharedMap.set(RequestEvSharedActionId, selectedActionId);
|
|
879
|
+
const data = await requestEv.parseBody();
|
|
880
|
+
if (!data || typeof data !== "object") {
|
|
696
881
|
throw new Error(
|
|
697
|
-
`Expected request data for the action id ${
|
|
882
|
+
`Expected request data for the action id ${selectedActionId} to be an object`
|
|
698
883
|
);
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
884
|
+
}
|
|
885
|
+
const result = await runValidators(requestEv, action.__validators, data, isDev);
|
|
886
|
+
if (!result.success) {
|
|
887
|
+
loaders[selectedActionId] = requestEv.fail(result.status ?? 500, result.error);
|
|
888
|
+
} else {
|
|
889
|
+
const actionResolved = isDev ? await measure(
|
|
890
|
+
requestEv,
|
|
891
|
+
action.__qrl.getHash(),
|
|
892
|
+
() => action.__qrl.call(requestEv, result.data, requestEv)
|
|
893
|
+
) : await action.__qrl.call(requestEv, result.data, requestEv);
|
|
894
|
+
if (isDev) {
|
|
895
|
+
verifySerializable(actionResolved, action.__qrl);
|
|
896
|
+
}
|
|
897
|
+
loaders[selectedActionId] = actionResolved;
|
|
709
898
|
}
|
|
710
899
|
}
|
|
711
900
|
}
|
|
712
901
|
}
|
|
713
902
|
};
|
|
714
903
|
}
|
|
715
|
-
function
|
|
716
|
-
return async (
|
|
717
|
-
const
|
|
718
|
-
if (
|
|
719
|
-
|
|
904
|
+
function loadersMiddleware(routeLoaders) {
|
|
905
|
+
return async (requestEvent) => {
|
|
906
|
+
const requestEv = requestEvent;
|
|
907
|
+
if (requestEv.headersSent) {
|
|
908
|
+
requestEv.exit();
|
|
720
909
|
return;
|
|
721
910
|
}
|
|
722
|
-
const
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
for (const c of e)
|
|
728
|
-
s.includes(c.__id) ? i.push(c) : r[c.__id] = ye;
|
|
729
|
-
} else
|
|
730
|
-
i = e;
|
|
731
|
-
const a = i.map(
|
|
732
|
-
(s) => We(s, r, n, o)
|
|
911
|
+
const loaders = getRequestLoaders(requestEv);
|
|
912
|
+
const isDev = getRequestMode(requestEv) === "dev";
|
|
913
|
+
if (routeLoaders.length > 0) {
|
|
914
|
+
const resolvedLoadersPromises = routeLoaders.map(
|
|
915
|
+
(loader) => getRouteLoaderPromise(loader, loaders, requestEv, isDev)
|
|
733
916
|
);
|
|
734
|
-
await Promise.all(
|
|
917
|
+
await Promise.all(resolvedLoadersPromises);
|
|
735
918
|
}
|
|
736
919
|
};
|
|
737
920
|
}
|
|
738
|
-
async function
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
921
|
+
async function getRouteLoaderPromise(loader, loaders, requestEv, isDev) {
|
|
922
|
+
const loaderId = loader.__id;
|
|
923
|
+
loaders[loaderId] = runValidators(
|
|
924
|
+
requestEv,
|
|
925
|
+
loader.__validators,
|
|
743
926
|
void 0,
|
|
744
927
|
// data
|
|
745
|
-
|
|
746
|
-
).then((
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
928
|
+
isDev
|
|
929
|
+
).then((res) => {
|
|
930
|
+
if (res.success) {
|
|
931
|
+
if (isDev) {
|
|
932
|
+
return measure(
|
|
933
|
+
requestEv,
|
|
934
|
+
loader.__qrl.getHash(),
|
|
935
|
+
() => loader.__qrl.call(requestEv, requestEv)
|
|
936
|
+
);
|
|
937
|
+
} else {
|
|
938
|
+
return loader.__qrl.call(requestEv, requestEv);
|
|
939
|
+
}
|
|
940
|
+
} else {
|
|
941
|
+
return requestEv.fail(res.status ?? 500, res.error);
|
|
942
|
+
}
|
|
943
|
+
}).then((resolvedLoader) => {
|
|
944
|
+
if (typeof resolvedLoader === "function") {
|
|
945
|
+
loaders[loaderId] = resolvedLoader();
|
|
946
|
+
} else {
|
|
947
|
+
if (isDev) {
|
|
948
|
+
verifySerializable(resolvedLoader, loader.__qrl);
|
|
949
|
+
}
|
|
950
|
+
loaders[loaderId] = resolvedLoader;
|
|
951
|
+
}
|
|
952
|
+
return resolvedLoader;
|
|
953
|
+
});
|
|
954
|
+
const loadersSerializationStrategy = getRequestLoaderSerializationStrategyMap(requestEv);
|
|
955
|
+
loadersSerializationStrategy.set(loaderId, loader.__serializationStrategy);
|
|
956
|
+
return loaders[loaderId];
|
|
751
957
|
}
|
|
752
|
-
async function
|
|
753
|
-
let
|
|
754
|
-
success:
|
|
755
|
-
data
|
|
958
|
+
async function runValidators(requestEv, validators, data, isDev) {
|
|
959
|
+
let lastResult = {
|
|
960
|
+
success: true,
|
|
961
|
+
data
|
|
756
962
|
};
|
|
757
|
-
if (
|
|
758
|
-
for (const
|
|
759
|
-
if (
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
else
|
|
766
|
-
|
|
767
|
-
|
|
963
|
+
if (validators) {
|
|
964
|
+
for (const validator of validators) {
|
|
965
|
+
if (isDev) {
|
|
966
|
+
lastResult = await measure(
|
|
967
|
+
requestEv,
|
|
968
|
+
`validator$`,
|
|
969
|
+
() => validator.validate(requestEv, data)
|
|
970
|
+
);
|
|
971
|
+
} else {
|
|
972
|
+
lastResult = await validator.validate(requestEv, data);
|
|
973
|
+
}
|
|
974
|
+
if (!lastResult.success) {
|
|
975
|
+
return lastResult;
|
|
976
|
+
} else {
|
|
977
|
+
data = lastResult.data;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
return lastResult;
|
|
768
982
|
}
|
|
769
|
-
function
|
|
770
|
-
return
|
|
983
|
+
function isAsyncIterator(obj) {
|
|
984
|
+
return obj ? typeof obj === "object" && Symbol.asyncIterator in obj : false;
|
|
771
985
|
}
|
|
772
|
-
async function
|
|
773
|
-
const
|
|
774
|
-
if (
|
|
775
|
-
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
986
|
+
async function runServerFunction(ev) {
|
|
987
|
+
const serverFnHash = ev.query.get(QFN_KEY);
|
|
988
|
+
if (serverFnHash && ev.request.headers.get("X-QRL") === serverFnHash && ev.request.headers.get("Content-Type") === "application/qwik-json") {
|
|
989
|
+
ev.exit();
|
|
990
|
+
const isDev = getRequestMode(ev) === "dev";
|
|
991
|
+
const data = await ev.parseBody();
|
|
992
|
+
if (Array.isArray(data)) {
|
|
993
|
+
const qrl = inlinedQrl(null, serverFnHash, data[1]);
|
|
994
|
+
let result;
|
|
995
|
+
try {
|
|
996
|
+
if (isDev) {
|
|
997
|
+
result = await measure(
|
|
998
|
+
ev,
|
|
999
|
+
`server_${serverFnHash}`,
|
|
1000
|
+
() => qrl.apply(ev, data[0])
|
|
1001
|
+
);
|
|
1002
|
+
} else {
|
|
1003
|
+
result = await qrl.apply(ev, data[0]);
|
|
789
1004
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
1005
|
+
} catch (err) {
|
|
1006
|
+
if (err instanceof ServerError$1) {
|
|
1007
|
+
throw ev.error(err.status, err.data);
|
|
1008
|
+
}
|
|
1009
|
+
console.error(`Server function ${serverFnHash} failed:`, err);
|
|
1010
|
+
throw ev.error(500, "Invalid request");
|
|
1011
|
+
}
|
|
1012
|
+
if (isAsyncIterator(result)) {
|
|
1013
|
+
ev.headers.set("Content-Type", "text/qwik-json-stream");
|
|
1014
|
+
const writable = ev.getWritableStream();
|
|
1015
|
+
const stream = writable.getWriter();
|
|
1016
|
+
for await (const item of result) {
|
|
1017
|
+
if (isDev) {
|
|
1018
|
+
verifySerializable(item, qrl);
|
|
800
1019
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1020
|
+
const message = await _serialize([item]);
|
|
1021
|
+
if (ev.signal.aborted) {
|
|
1022
|
+
break;
|
|
1023
|
+
}
|
|
1024
|
+
await stream.write(encoder.encode(`${message}
|
|
1025
|
+
`));
|
|
806
1026
|
}
|
|
807
|
-
|
|
1027
|
+
stream.close();
|
|
1028
|
+
} else {
|
|
1029
|
+
verifySerializable(result, qrl);
|
|
1030
|
+
ev.headers.set("Content-Type", "application/qwik-json");
|
|
1031
|
+
const message = await _serialize([result]);
|
|
1032
|
+
ev.send(200, message);
|
|
808
1033
|
}
|
|
1034
|
+
return;
|
|
809
1035
|
}
|
|
810
|
-
throw
|
|
1036
|
+
throw ev.error(500, "Invalid request");
|
|
811
1037
|
}
|
|
812
1038
|
}
|
|
813
|
-
function
|
|
814
|
-
const { basePathname
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1039
|
+
function fixTrailingSlash(ev) {
|
|
1040
|
+
const { basePathname, originalUrl, sharedMap } = ev;
|
|
1041
|
+
const { pathname, search } = originalUrl;
|
|
1042
|
+
const isQData = sharedMap.has(IsQData);
|
|
1043
|
+
if (!isQData && pathname !== basePathname && !pathname.endsWith(".html")) {
|
|
1044
|
+
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
1045
|
+
if (!pathname.endsWith("/")) {
|
|
1046
|
+
throw ev.redirect(HttpStatus.MovedPermanently, pathname + "/" + search);
|
|
1047
|
+
}
|
|
1048
|
+
} else {
|
|
1049
|
+
if (pathname.endsWith("/")) {
|
|
1050
|
+
throw ev.redirect(
|
|
1051
|
+
HttpStatus.MovedPermanently,
|
|
1052
|
+
pathname.slice(0, pathname.length - 1) + search
|
|
821
1053
|
);
|
|
822
|
-
|
|
823
|
-
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
824
1056
|
}
|
|
825
1057
|
}
|
|
826
|
-
function
|
|
1058
|
+
function verifySerializable(data, qrl) {
|
|
827
1059
|
try {
|
|
828
|
-
|
|
829
|
-
} catch (
|
|
830
|
-
|
|
1060
|
+
_verifySerializable(data, void 0);
|
|
1061
|
+
} catch (e) {
|
|
1062
|
+
if (e instanceof Error && qrl.dev) {
|
|
1063
|
+
e.loc = qrl.dev;
|
|
1064
|
+
}
|
|
1065
|
+
throw e;
|
|
831
1066
|
}
|
|
832
1067
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
return t && typeof t.default == "function";
|
|
1068
|
+
function isLastModulePageRoute(routeModules) {
|
|
1069
|
+
const lastRouteModule = routeModules[routeModules.length - 1];
|
|
1070
|
+
return lastRouteModule && typeof lastRouteModule.default === "function";
|
|
837
1071
|
}
|
|
838
|
-
function
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
1072
|
+
function getPathname(url) {
|
|
1073
|
+
url = new URL(url);
|
|
1074
|
+
if (url.pathname.endsWith(QDATA_JSON)) {
|
|
1075
|
+
url.pathname = url.pathname.slice(0, -QDATA_JSON.length);
|
|
1076
|
+
}
|
|
1077
|
+
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
1078
|
+
if (!url.pathname.endsWith("/")) {
|
|
1079
|
+
url.pathname += "/";
|
|
1080
|
+
}
|
|
1081
|
+
} else {
|
|
1082
|
+
if (url.pathname.endsWith("/")) {
|
|
1083
|
+
url.pathname = url.pathname.slice(0, -1);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
const search = url.search.slice(1).replaceAll(/&?q(action|data|func|loaders)=[^&]+/g, "");
|
|
1087
|
+
return `${url.pathname}${search ? `?${search}` : ""}${url.hash}`;
|
|
842
1088
|
}
|
|
843
|
-
const
|
|
844
|
-
function
|
|
845
|
-
|
|
1089
|
+
const encoder = /* @__PURE__ */ new TextEncoder();
|
|
1090
|
+
function csrfLaxProtoCheckMiddleware(requestEv) {
|
|
1091
|
+
checkCSRF(requestEv, "lax-proto");
|
|
846
1092
|
}
|
|
847
|
-
function
|
|
848
|
-
|
|
1093
|
+
function csrfCheckMiddleware(requestEv) {
|
|
1094
|
+
checkCSRF(requestEv);
|
|
849
1095
|
}
|
|
850
|
-
function
|
|
851
|
-
|
|
852
|
-
|
|
1096
|
+
function checkCSRF(requestEv, laxProto) {
|
|
1097
|
+
const isForm = isContentType(
|
|
1098
|
+
requestEv.request.headers,
|
|
853
1099
|
"application/x-www-form-urlencoded",
|
|
854
1100
|
"multipart/form-data",
|
|
855
1101
|
"text/plain"
|
|
856
|
-
)
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1102
|
+
);
|
|
1103
|
+
if (isForm) {
|
|
1104
|
+
const inputOrigin = requestEv.request.headers.get("origin");
|
|
1105
|
+
const origin = requestEv.url.origin;
|
|
1106
|
+
let forbidden = inputOrigin !== origin;
|
|
1107
|
+
if (forbidden && laxProto && inputOrigin?.replace(/^http(s)?/g, "") === origin.replace(/^http(s)?/g, "")) {
|
|
1108
|
+
forbidden = false;
|
|
1109
|
+
}
|
|
1110
|
+
if (forbidden) {
|
|
1111
|
+
throw requestEv.error(
|
|
861
1112
|
403,
|
|
862
|
-
`CSRF check failed. Cross-site ${
|
|
863
|
-
The request origin "${
|
|
1113
|
+
`CSRF check failed. Cross-site ${requestEv.method} form submissions are forbidden.
|
|
1114
|
+
The request origin "${inputOrigin}" does not match the server origin "${origin}".`
|
|
864
1115
|
);
|
|
1116
|
+
}
|
|
865
1117
|
}
|
|
866
1118
|
}
|
|
867
|
-
function
|
|
868
|
-
return async (
|
|
869
|
-
if (
|
|
1119
|
+
function renderQwikMiddleware(render) {
|
|
1120
|
+
return async (requestEv) => {
|
|
1121
|
+
if (requestEv.headersSent) {
|
|
870
1122
|
return;
|
|
871
|
-
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
1123
|
+
}
|
|
1124
|
+
const isPageDataReq = requestEv.sharedMap.has(IsQData);
|
|
1125
|
+
if (isPageDataReq) {
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
requestEv.request.headers.forEach((value, key) => value);
|
|
1129
|
+
const responseHeaders = requestEv.headers;
|
|
1130
|
+
if (!responseHeaders.has("Content-Type")) {
|
|
1131
|
+
responseHeaders.set("Content-Type", "text/html; charset=utf-8");
|
|
1132
|
+
}
|
|
1133
|
+
const { readable, writable } = new TextEncoderStream();
|
|
1134
|
+
const writableStream = requestEv.getWritableStream();
|
|
1135
|
+
const pipe = readable.pipeTo(writableStream, { preventClose: true });
|
|
1136
|
+
const stream = writable.getWriter();
|
|
1137
|
+
const status = requestEv.status();
|
|
875
1138
|
try {
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
1139
|
+
const isStatic = getRequestMode(requestEv) === "static";
|
|
1140
|
+
const serverData = getQwikRouterServerData(requestEv);
|
|
1141
|
+
const result = await render({
|
|
1142
|
+
base: requestEv.basePathname + "build/",
|
|
1143
|
+
stream,
|
|
1144
|
+
serverData,
|
|
880
1145
|
containerAttributes: {
|
|
881
|
-
"q:render":
|
|
882
|
-
...
|
|
1146
|
+
["q:render"]: isStatic ? "static" : "",
|
|
1147
|
+
...serverData.containerAttributes
|
|
883
1148
|
}
|
|
884
|
-
})
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1149
|
+
});
|
|
1150
|
+
const qData = {
|
|
1151
|
+
loaders: getRequestLoaders(requestEv),
|
|
1152
|
+
action: requestEv.sharedMap.get(RequestEvSharedActionId),
|
|
1153
|
+
status: status !== 200 ? status : 200,
|
|
1154
|
+
href: getPathname(requestEv.url)
|
|
889
1155
|
};
|
|
890
|
-
typeof
|
|
1156
|
+
if (typeof result.html === "string") {
|
|
1157
|
+
await stream.write(result.html);
|
|
1158
|
+
}
|
|
1159
|
+
requestEv.sharedMap.set(RequestEvShareQData, qData);
|
|
891
1160
|
} finally {
|
|
892
|
-
await
|
|
1161
|
+
await stream.ready;
|
|
1162
|
+
await stream.close();
|
|
1163
|
+
await pipe;
|
|
893
1164
|
}
|
|
894
|
-
await
|
|
1165
|
+
await writableStream.close();
|
|
895
1166
|
};
|
|
896
1167
|
}
|
|
897
|
-
async function
|
|
898
|
-
if (!e.sharedMap.has(O))
|
|
899
|
-
return;
|
|
1168
|
+
async function handleQDataRedirect(requestEv) {
|
|
900
1169
|
try {
|
|
901
|
-
await
|
|
902
|
-
} catch (
|
|
903
|
-
if (!(
|
|
904
|
-
throw
|
|
1170
|
+
await requestEv.next();
|
|
1171
|
+
} catch (err) {
|
|
1172
|
+
if (!(err instanceof RedirectMessage$1)) {
|
|
1173
|
+
throw err;
|
|
1174
|
+
}
|
|
905
1175
|
}
|
|
906
|
-
if (
|
|
1176
|
+
if (requestEv.headersSent) {
|
|
907
1177
|
return;
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1178
|
+
}
|
|
1179
|
+
const status = requestEv.status();
|
|
1180
|
+
const location = requestEv.headers.get("Location");
|
|
1181
|
+
const isRedirect = status >= 301 && status <= 308 && location;
|
|
1182
|
+
if (isRedirect) {
|
|
1183
|
+
const adaptedLocation = makeQDataPath(location);
|
|
1184
|
+
if (adaptedLocation) {
|
|
1185
|
+
requestEv.headers.set("Location", adaptedLocation);
|
|
1186
|
+
requestEv.getWritableStream().close();
|
|
913
1187
|
return;
|
|
914
|
-
} else
|
|
915
|
-
|
|
1188
|
+
} else {
|
|
1189
|
+
requestEv.status(200);
|
|
1190
|
+
requestEv.headers.delete("Location");
|
|
1191
|
+
}
|
|
916
1192
|
}
|
|
917
1193
|
}
|
|
918
|
-
async function
|
|
919
|
-
|
|
1194
|
+
async function renderQData(requestEv) {
|
|
1195
|
+
await requestEv.next();
|
|
1196
|
+
if (requestEv.headersSent || requestEv.exited) {
|
|
920
1197
|
return;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1198
|
+
}
|
|
1199
|
+
const status = requestEv.status();
|
|
1200
|
+
const redirectLocation = requestEv.headers.get("Location");
|
|
1201
|
+
requestEv.request.headers.forEach((value, key) => value);
|
|
1202
|
+
requestEv.headers.set("Content-Type", "application/json; charset=utf-8");
|
|
1203
|
+
let loaders = getRequestLoaders(requestEv);
|
|
1204
|
+
const selectedLoaderIds = requestEv.query.getAll(QLOADER_KEY);
|
|
1205
|
+
const hasCustomLoaders = selectedLoaderIds.length > 0;
|
|
1206
|
+
if (hasCustomLoaders) {
|
|
1207
|
+
const selectedLoaders = {};
|
|
1208
|
+
for (const loaderId of selectedLoaderIds) {
|
|
1209
|
+
const loader = loaders[loaderId];
|
|
1210
|
+
selectedLoaders[loaderId] = loader;
|
|
930
1211
|
}
|
|
931
|
-
|
|
1212
|
+
loaders = selectedLoaders;
|
|
932
1213
|
}
|
|
933
|
-
const
|
|
1214
|
+
const qData = hasCustomLoaders ? {
|
|
934
1215
|
// send minimal data to the client
|
|
935
|
-
loaders
|
|
936
|
-
status:
|
|
937
|
-
href:
|
|
1216
|
+
loaders,
|
|
1217
|
+
status: status !== 200 ? status : 200,
|
|
1218
|
+
href: getPathname(requestEv.url)
|
|
938
1219
|
} : {
|
|
939
|
-
loaders
|
|
940
|
-
action:
|
|
941
|
-
status:
|
|
942
|
-
href:
|
|
943
|
-
redirect:
|
|
944
|
-
isRewrite:
|
|
945
|
-
}
|
|
946
|
-
|
|
1220
|
+
loaders,
|
|
1221
|
+
action: requestEv.sharedMap.get(RequestEvSharedActionId),
|
|
1222
|
+
status: status !== 200 ? status : 200,
|
|
1223
|
+
href: getPathname(requestEv.url),
|
|
1224
|
+
redirect: redirectLocation ?? void 0,
|
|
1225
|
+
isRewrite: requestEv.sharedMap.get(RequestEvIsRewrite)
|
|
1226
|
+
};
|
|
1227
|
+
const writer = requestEv.getWritableStream().getWriter();
|
|
1228
|
+
const data = await _serialize([qData]);
|
|
1229
|
+
writer.write(encoder.encode(data));
|
|
1230
|
+
requestEv.sharedMap.set(RequestEvShareQData, qData);
|
|
1231
|
+
writer.close();
|
|
947
1232
|
}
|
|
948
|
-
function
|
|
949
|
-
if (
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1233
|
+
function makeQDataPath(href) {
|
|
1234
|
+
if (href.startsWith("/")) {
|
|
1235
|
+
if (!href.includes(QDATA_JSON)) {
|
|
1236
|
+
const url = new URL(href, "http://localhost");
|
|
1237
|
+
const pathname = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
|
|
1238
|
+
return pathname + QDATA_JSON + url.search;
|
|
1239
|
+
}
|
|
1240
|
+
return href;
|
|
1241
|
+
} else {
|
|
1242
|
+
return void 0;
|
|
1243
|
+
}
|
|
954
1244
|
}
|
|
955
|
-
function
|
|
956
|
-
return typeof performance
|
|
1245
|
+
function now() {
|
|
1246
|
+
return typeof performance !== "undefined" ? performance.now() : 0;
|
|
957
1247
|
}
|
|
958
|
-
async function
|
|
959
|
-
const
|
|
1248
|
+
async function measure(requestEv, name, fn) {
|
|
1249
|
+
const start = now();
|
|
960
1250
|
try {
|
|
961
|
-
return await
|
|
1251
|
+
return await fn();
|
|
962
1252
|
} finally {
|
|
963
|
-
const
|
|
964
|
-
let
|
|
965
|
-
|
|
1253
|
+
const duration = now() - start;
|
|
1254
|
+
let measurements = requestEv.sharedMap.get(RequestEvShareServerTiming);
|
|
1255
|
+
if (!measurements) {
|
|
1256
|
+
requestEv.sharedMap.set(RequestEvShareServerTiming, measurements = []);
|
|
1257
|
+
}
|
|
1258
|
+
measurements.push([name, duration]);
|
|
966
1259
|
}
|
|
967
1260
|
}
|
|
968
|
-
function
|
|
969
|
-
const
|
|
970
|
-
return
|
|
1261
|
+
function isContentType(headers, ...types) {
|
|
1262
|
+
const type = headers.get("content-type")?.split(/;/, 1)[0].trim() ?? "";
|
|
1263
|
+
return types.includes(type);
|
|
1264
|
+
}
|
|
1265
|
+
let _asyncRequestStore;
|
|
1266
|
+
if (isServer) {
|
|
1267
|
+
import("node:async_hooks").then((module) => {
|
|
1268
|
+
_asyncRequestStore = new module.AsyncLocalStorage();
|
|
1269
|
+
}).catch((err) => {
|
|
1270
|
+
console.warn(
|
|
1271
|
+
"\n=====================\n Qwik Router Warning:\n AsyncLocalStorage is not available, continuing without it.\n This impacts concurrent async server calls, where they lose access to the ServerRequestEv object.\n=====================\n\n",
|
|
1272
|
+
err
|
|
1273
|
+
);
|
|
1274
|
+
});
|
|
971
1275
|
}
|
|
972
|
-
let
|
|
973
|
-
async function
|
|
974
|
-
const { render
|
|
975
|
-
let { qwikRouterConfig
|
|
976
|
-
if (
|
|
1276
|
+
let qwikRouterConfigActual;
|
|
1277
|
+
async function requestHandler(serverRequestEv, opts) {
|
|
1278
|
+
const { render, checkOrigin } = opts;
|
|
1279
|
+
let { qwikRouterConfig } = opts;
|
|
1280
|
+
if (!qwikRouterConfig) {
|
|
1281
|
+
if (!qwikRouterConfigActual) {
|
|
1282
|
+
qwikRouterConfigActual = await import("@qwik-router-config");
|
|
1283
|
+
}
|
|
1284
|
+
qwikRouterConfig = qwikRouterConfigActual;
|
|
1285
|
+
}
|
|
1286
|
+
if (!qwikRouterConfig) {
|
|
977
1287
|
throw new Error("qwikRouterConfig is required.");
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1288
|
+
}
|
|
1289
|
+
const { pathname, isInternal } = getRouteMatchPathname(serverRequestEv.url.pathname);
|
|
1290
|
+
const routeAndHandlers = await loadRequestHandlers(
|
|
1291
|
+
qwikRouterConfig,
|
|
1292
|
+
pathname,
|
|
1293
|
+
serverRequestEv.request.method,
|
|
1294
|
+
checkOrigin ?? true,
|
|
1295
|
+
render,
|
|
1296
|
+
isInternal
|
|
984
1297
|
);
|
|
985
|
-
if (
|
|
986
|
-
const [
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1298
|
+
if (routeAndHandlers) {
|
|
1299
|
+
const [route, requestHandlers] = routeAndHandlers;
|
|
1300
|
+
const rebuildRouteInfo = async (url) => {
|
|
1301
|
+
const { pathname: pathname2 } = getRouteMatchPathname(url.pathname);
|
|
1302
|
+
const routeAndHandlers2 = await loadRequestHandlers(
|
|
1303
|
+
qwikRouterConfig,
|
|
1304
|
+
pathname2,
|
|
1305
|
+
serverRequestEv.request.method,
|
|
1306
|
+
checkOrigin ?? true,
|
|
1307
|
+
render,
|
|
1308
|
+
isInternal
|
|
1309
|
+
);
|
|
1310
|
+
if (routeAndHandlers2) {
|
|
1311
|
+
const [loadedRoute, requestHandlers2] = routeAndHandlers2;
|
|
1312
|
+
return { loadedRoute, requestHandlers: requestHandlers2 };
|
|
1313
|
+
} else {
|
|
1314
|
+
return { loadedRoute: null, requestHandlers: [] };
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
return runQwikRouter(
|
|
1318
|
+
serverRequestEv,
|
|
1319
|
+
route,
|
|
1320
|
+
requestHandlers,
|
|
1321
|
+
rebuildRouteInfo,
|
|
1322
|
+
qwikRouterConfig.basePathname
|
|
1006
1323
|
);
|
|
1007
1324
|
}
|
|
1008
1325
|
return null;
|
|
1009
1326
|
}
|
|
1010
|
-
async function
|
|
1011
|
-
const { routes
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1327
|
+
async function loadRequestHandlers(qwikRouterConfig, pathname, method, checkOrigin, renderFn, isInternal) {
|
|
1328
|
+
const { routes, serverPlugins, menus, cacheModules } = qwikRouterConfig;
|
|
1329
|
+
const route = await loadRoute(routes, menus, cacheModules, pathname, isInternal);
|
|
1330
|
+
const requestHandlers = resolveRequestHandlers(
|
|
1331
|
+
serverPlugins,
|
|
1332
|
+
route,
|
|
1333
|
+
method,
|
|
1334
|
+
checkOrigin,
|
|
1335
|
+
renderQwikMiddleware(renderFn),
|
|
1336
|
+
isInternal
|
|
1017
1337
|
);
|
|
1018
|
-
|
|
1338
|
+
if (requestHandlers.length > 0) {
|
|
1339
|
+
return [route, requestHandlers];
|
|
1340
|
+
}
|
|
1341
|
+
return null;
|
|
1019
1342
|
}
|
|
1020
|
-
const
|
|
1343
|
+
const notFounds = [
|
|
1021
1344
|
// Will be replaced in post-build with the 404s generated by SSG
|
|
1022
1345
|
"__QWIK_ROUTER_NOT_FOUND_ARRAY__"
|
|
1023
1346
|
];
|
|
1024
|
-
function
|
|
1025
|
-
for (const [
|
|
1026
|
-
if (
|
|
1027
|
-
return
|
|
1028
|
-
|
|
1347
|
+
function getNotFound(prefix) {
|
|
1348
|
+
for (const [path, html] of notFounds) {
|
|
1349
|
+
if (prefix.startsWith(path)) {
|
|
1350
|
+
return html;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
return minimalHtmlResponse(404, "Resource Not Found");
|
|
1029
1354
|
}
|
|
1030
|
-
const
|
|
1031
|
-
function
|
|
1032
|
-
if (
|
|
1033
|
-
return
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1355
|
+
const staticPaths = /* @__PURE__ */ new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]);
|
|
1356
|
+
function isStaticPath(method, url) {
|
|
1357
|
+
if (method.toUpperCase() !== "GET") {
|
|
1358
|
+
return false;
|
|
1359
|
+
}
|
|
1360
|
+
const p = url.pathname;
|
|
1361
|
+
if (p.startsWith("/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/")) {
|
|
1362
|
+
return true;
|
|
1363
|
+
}
|
|
1364
|
+
if (p.startsWith("/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/")) {
|
|
1365
|
+
return true;
|
|
1366
|
+
}
|
|
1367
|
+
if (staticPaths.has(p)) {
|
|
1368
|
+
return true;
|
|
1369
|
+
}
|
|
1370
|
+
if (p.endsWith("/q-data.json")) {
|
|
1371
|
+
const pWithoutQdata = p.replace(/\/q-data.json$/, "");
|
|
1372
|
+
if (staticPaths.has(pWithoutQdata + "/")) {
|
|
1373
|
+
return true;
|
|
1374
|
+
}
|
|
1375
|
+
if (staticPaths.has(pWithoutQdata)) {
|
|
1376
|
+
return true;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
return false;
|
|
1043
1380
|
}
|
|
1044
|
-
class
|
|
1045
|
-
constructor(
|
|
1046
|
-
super(typeof
|
|
1381
|
+
class ServerError extends Error {
|
|
1382
|
+
constructor(status, data) {
|
|
1383
|
+
super(typeof data === "string" ? data : void 0);
|
|
1384
|
+
this.status = status;
|
|
1385
|
+
this.data = data;
|
|
1047
1386
|
}
|
|
1048
1387
|
}
|
|
1049
|
-
class
|
|
1388
|
+
class AbortMessage {
|
|
1050
1389
|
}
|
|
1051
|
-
class
|
|
1390
|
+
class RedirectMessage extends AbortMessage {
|
|
1052
1391
|
}
|
|
1053
|
-
class
|
|
1054
|
-
constructor(
|
|
1055
|
-
super()
|
|
1392
|
+
class RewriteMessage extends AbortMessage {
|
|
1393
|
+
constructor(pathname) {
|
|
1394
|
+
super();
|
|
1395
|
+
this.pathname = pathname;
|
|
1056
1396
|
}
|
|
1057
1397
|
}
|
|
1058
|
-
class
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
const
|
|
1069
|
-
if (this
|
|
1070
|
-
|
|
1398
|
+
class _TextEncoderStream_polyfill {
|
|
1399
|
+
constructor() {
|
|
1400
|
+
__privateAdd(this, _pendingHighSurrogate, null);
|
|
1401
|
+
__privateAdd(this, _handle, new TextEncoder());
|
|
1402
|
+
__privateAdd(this, _transform, new TransformStream({
|
|
1403
|
+
transform: (chunk, controller) => {
|
|
1404
|
+
chunk = String(chunk);
|
|
1405
|
+
let finalChunk = "";
|
|
1406
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
1407
|
+
const item = chunk[i];
|
|
1408
|
+
const codeUnit = item.charCodeAt(0);
|
|
1409
|
+
if (__privateGet(this, _pendingHighSurrogate) !== null) {
|
|
1410
|
+
const highSurrogate = __privateGet(this, _pendingHighSurrogate);
|
|
1411
|
+
__privateSet(this, _pendingHighSurrogate, null);
|
|
1412
|
+
if (56320 <= codeUnit && codeUnit <= 57343) {
|
|
1413
|
+
finalChunk += highSurrogate + item;
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
finalChunk += "�";
|
|
1417
|
+
}
|
|
1418
|
+
if (55296 <= codeUnit && codeUnit <= 56319) {
|
|
1419
|
+
__privateSet(this, _pendingHighSurrogate, item);
|
|
1071
1420
|
continue;
|
|
1072
1421
|
}
|
|
1073
|
-
|
|
1422
|
+
if (56320 <= codeUnit && codeUnit <= 57343) {
|
|
1423
|
+
finalChunk += "�";
|
|
1424
|
+
continue;
|
|
1425
|
+
}
|
|
1426
|
+
finalChunk += item;
|
|
1074
1427
|
}
|
|
1075
|
-
if (
|
|
1076
|
-
this
|
|
1077
|
-
continue;
|
|
1428
|
+
if (finalChunk) {
|
|
1429
|
+
controller.enqueue(__privateGet(this, _handle).encode(finalChunk));
|
|
1078
1430
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1431
|
+
},
|
|
1432
|
+
flush: (controller) => {
|
|
1433
|
+
if (__privateGet(this, _pendingHighSurrogate) !== null) {
|
|
1434
|
+
controller.enqueue(new Uint8Array([239, 191, 189]));
|
|
1082
1435
|
}
|
|
1083
|
-
r += i;
|
|
1084
1436
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
flush: (t) => {
|
|
1088
|
-
this.#e !== null && t.enqueue(new Uint8Array([239, 191, 189]));
|
|
1089
|
-
}
|
|
1090
|
-
});
|
|
1437
|
+
}));
|
|
1438
|
+
}
|
|
1091
1439
|
get encoding() {
|
|
1092
|
-
return this
|
|
1440
|
+
return __privateGet(this, _handle).encoding;
|
|
1093
1441
|
}
|
|
1094
1442
|
get readable() {
|
|
1095
|
-
return this
|
|
1443
|
+
return __privateGet(this, _transform).readable;
|
|
1096
1444
|
}
|
|
1097
1445
|
get writable() {
|
|
1098
|
-
return this
|
|
1446
|
+
return __privateGet(this, _transform).writable;
|
|
1099
1447
|
}
|
|
1100
1448
|
get [Symbol.toStringTag]() {
|
|
1101
1449
|
return "TextEncoderStream";
|
|
1102
1450
|
}
|
|
1103
1451
|
}
|
|
1452
|
+
_pendingHighSurrogate = new WeakMap();
|
|
1453
|
+
_handle = new WeakMap();
|
|
1454
|
+
_transform = new WeakMap();
|
|
1104
1455
|
export {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1456
|
+
AbortMessage,
|
|
1457
|
+
RedirectMessage,
|
|
1458
|
+
RequestEvShareQData,
|
|
1459
|
+
RewriteMessage,
|
|
1460
|
+
ServerError,
|
|
1461
|
+
_TextEncoderStream_polyfill,
|
|
1462
|
+
_asyncRequestStore,
|
|
1463
|
+
getErrorHtml,
|
|
1464
|
+
getNotFound,
|
|
1465
|
+
isStaticPath,
|
|
1466
|
+
mergeHeadersCookies,
|
|
1467
|
+
requestHandler
|
|
1116
1468
|
};
|