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