@elurjs/kit 2.4.10 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +313 -0
- package/README.md +248 -15
- package/dist/lib/action/index.cjs +1 -1
- package/dist/lib/action/index.js +1 -1
- package/dist/lib/{action-DZHihU3Z.cjs → action-BiE4tEty.cjs} +2 -2
- package/dist/lib/{action-DZHihU3Z.cjs.map → action-BiE4tEty.cjs.map} +1 -1
- package/dist/lib/{action-BB6N5yD-.js → action-CXVk8rWt.js} +3 -3
- package/dist/lib/{action-BB6N5yD-.js.map → action-CXVk8rWt.js.map} +1 -1
- package/dist/lib/adapter-DNsjXvq5.js +160 -0
- package/dist/lib/adapter-DNsjXvq5.js.map +1 -0
- package/dist/lib/adapter-Dz2hzR36.cjs +3 -0
- package/dist/lib/adapter-Dz2hzR36.cjs.map +1 -0
- package/dist/lib/adapters/bun.cjs +2 -2
- package/dist/lib/adapters/bun.cjs.map +1 -1
- package/dist/lib/adapters/bun.js +17 -9
- package/dist/lib/adapters/bun.js.map +1 -1
- package/dist/lib/adapters/index.d.cts +34 -0
- package/dist/lib/adapters/index.d.ts +34 -0
- package/dist/lib/adapters/netlify.cjs +1 -1
- package/dist/lib/adapters/netlify.js +7 -7
- package/dist/lib/adapters/node.cjs +5 -5
- package/dist/lib/adapters/node.cjs.map +1 -1
- package/dist/lib/adapters/node.js +20 -12
- package/dist/lib/adapters/node.js.map +1 -1
- package/dist/lib/adapters/vercel.cjs +1 -1
- package/dist/lib/adapters/vercel.js +8 -8
- package/dist/lib/build/build.d.cts +40 -0
- package/dist/lib/build/build.d.ts +40 -0
- package/dist/lib/build/document-shell.d.cts +47 -1
- package/dist/lib/build/document-shell.d.ts +47 -1
- package/dist/lib/build/vite-build.d.cts +25 -2
- package/dist/lib/build/vite-build.d.ts +25 -2
- package/dist/lib/cache/adapter.d.cts +41 -0
- package/dist/lib/cache/adapter.d.ts +41 -0
- package/dist/lib/cache/index.cjs +2 -0
- package/dist/lib/cache/index.cjs.map +1 -0
- package/dist/lib/cache/index.d.cts +5 -0
- package/dist/lib/cache/index.d.ts +5 -0
- package/dist/lib/cache/index.js +113 -0
- package/dist/lib/cache/index.js.map +1 -0
- package/dist/lib/cache/invalidation.d.cts +36 -0
- package/dist/lib/cache/invalidation.d.ts +36 -0
- package/dist/lib/cache/redis-adapter.d.cts +49 -0
- package/dist/lib/cache/redis-adapter.d.ts +49 -0
- package/dist/lib/cache-DGhTYyqh.js +50 -0
- package/dist/lib/cache-DGhTYyqh.js.map +1 -0
- package/dist/lib/cache-X1n4Ossu.cjs +2 -0
- package/dist/lib/cache-X1n4Ossu.cjs.map +1 -0
- package/dist/lib/cli/output.d.cts +58 -0
- package/dist/lib/cli/output.d.ts +58 -0
- package/dist/lib/cli/ports.d.cts +20 -0
- package/dist/lib/cli/ports.d.ts +20 -0
- package/dist/lib/cli.cjs +2559 -1488
- package/dist/lib/cli.cjs.map +1 -1
- package/dist/lib/cli.d.cts +21 -0
- package/dist/lib/cli.d.ts +21 -0
- package/dist/lib/cli.js +2558 -1488
- package/dist/lib/cli.js.map +1 -1
- package/dist/lib/config/index.cjs +1 -1
- package/dist/lib/config/index.cjs.map +1 -1
- package/dist/lib/config/index.d.cts +79 -0
- package/dist/lib/config/index.d.ts +79 -0
- package/dist/lib/config/index.js +21 -14
- package/dist/lib/config/index.js.map +1 -1
- package/dist/lib/{errors-ePYxDlhU.js → errors-j4cg9VN3.js} +24 -30
- package/dist/lib/{errors-ePYxDlhU.js.map → errors-j4cg9VN3.js.map} +1 -1
- package/dist/lib/errors-kSl9yLkg.cjs +2 -0
- package/dist/lib/{errors-0X7pCFNU.cjs.map → errors-kSl9yLkg.cjs.map} +1 -1
- package/dist/lib/hydrate-BSLuI0Nh.cjs +2 -0
- package/dist/lib/hydrate-BSLuI0Nh.cjs.map +1 -0
- package/dist/lib/hydrate-BaS7-d8C.js +133 -0
- package/dist/lib/hydrate-BaS7-d8C.js.map +1 -0
- package/dist/lib/idiomorph.esm-BOOTOg1r.cjs +2 -0
- package/dist/lib/idiomorph.esm-BOOTOg1r.cjs.map +1 -0
- package/dist/lib/idiomorph.esm-CXuY-EHB.js +371 -0
- package/dist/lib/idiomorph.esm-CXuY-EHB.js.map +1 -0
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.d.cts +8 -6
- package/dist/lib/index.d.ts +8 -6
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/interpolation-plugin-C0dTd69H.cjs +58 -0
- package/dist/lib/interpolation-plugin-C0dTd69H.cjs.map +1 -0
- package/dist/lib/{interpolation-plugin-Wgb1j4pT.js → interpolation-plugin-K2qE69tF.js} +95 -126
- package/dist/lib/interpolation-plugin-K2qE69tF.js.map +1 -0
- package/dist/lib/invalidation-CFpNQUv6.cjs +2 -0
- package/dist/lib/invalidation-CFpNQUv6.cjs.map +1 -0
- package/dist/lib/invalidation-DXhdE9wj.js +64 -0
- package/dist/lib/invalidation-DXhdE9wj.js.map +1 -0
- package/dist/lib/island/generate-entry.d.cts +40 -2
- package/dist/lib/island/generate-entry.d.ts +40 -2
- package/dist/lib/island/hydrate.d.cts +19 -6
- package/dist/lib/island/hydrate.d.ts +19 -6
- package/dist/lib/island/index.cjs +1 -1
- package/dist/lib/island/index.d.cts +2 -1
- package/dist/lib/island/index.d.ts +2 -1
- package/dist/lib/island/index.js +1 -1
- package/dist/lib/island/island.d.cts +15 -0
- package/dist/lib/island/island.d.ts +15 -0
- package/dist/lib/island-CTBnsOhI.js +59 -0
- package/dist/lib/island-CTBnsOhI.js.map +1 -0
- package/dist/lib/island-kfQEKRe_.cjs +2 -0
- package/dist/lib/island-kfQEKRe_.cjs.map +1 -0
- package/dist/lib/node-http-DVFcYeBS.js +723 -0
- package/dist/lib/node-http-DVFcYeBS.js.map +1 -0
- package/dist/lib/node-http-Uct7DhmN.cjs +13 -0
- package/dist/lib/node-http-Uct7DhmN.cjs.map +1 -0
- package/dist/lib/rolldown-runtime-BIInC43l.cjs +1 -0
- package/dist/lib/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/lib/router/client.cjs +1 -1
- package/dist/lib/router/client.cjs.map +1 -1
- package/dist/lib/router/client.d.cts +55 -8
- package/dist/lib/router/client.d.ts +55 -8
- package/dist/lib/router/client.js +298 -97
- package/dist/lib/router/client.js.map +1 -1
- package/dist/lib/router/redirects.d.cts +34 -0
- package/dist/lib/router/redirects.d.ts +34 -0
- package/dist/lib/runtime/handler.d.cts +59 -0
- package/dist/lib/runtime/handler.d.ts +59 -0
- package/dist/lib/runtime/index.cjs +1 -1
- package/dist/lib/runtime/index.d.cts +2 -1
- package/dist/lib/runtime/index.d.ts +2 -1
- package/dist/lib/runtime/index.js +4 -4
- package/dist/lib/runtime/logger.d.cts +47 -0
- package/dist/lib/runtime/logger.d.ts +47 -0
- package/dist/lib/runtime/node-http.d.cts +11 -1
- package/dist/lib/runtime/node-http.d.ts +11 -1
- package/dist/lib/runtime-ChE4flX3.cjs +2 -0
- package/dist/lib/runtime-ChE4flX3.cjs.map +1 -0
- package/dist/lib/runtime-OMyz5yE-.js +905 -0
- package/dist/lib/runtime-OMyz5yE-.js.map +1 -0
- package/dist/lib/seo/index.cjs +1 -10
- package/dist/lib/seo/index.d.cts +1 -0
- package/dist/lib/seo/index.d.ts +1 -0
- package/dist/lib/seo/index.js +2 -41
- package/dist/lib/seo/sitemap-from-routes.d.cts +24 -0
- package/dist/lib/seo/sitemap-from-routes.d.ts +24 -0
- package/dist/lib/{shared-CfqOLsKj.cjs → shared-CP0Dc3cp.cjs} +72 -47
- package/dist/lib/shared-CP0Dc3cp.cjs.map +1 -0
- package/dist/lib/{shared-DU3iQgr7.js → shared-D8w-neq2.js} +87 -58
- package/dist/lib/shared-D8w-neq2.js.map +1 -0
- package/dist/lib/sitemap-from-routes-CaBoiGvE.js +77 -0
- package/dist/lib/sitemap-from-routes-CaBoiGvE.js.map +1 -0
- package/dist/lib/sitemap-from-routes-DbcLLL4G.cjs +13 -0
- package/dist/lib/sitemap-from-routes-DbcLLL4G.cjs.map +1 -0
- package/dist/lib/ssr/render.d.cts +8 -2
- package/dist/lib/ssr/render.d.ts +8 -2
- package/dist/lib/ssr/server.d.cts +7 -0
- package/dist/lib/ssr/server.d.ts +7 -0
- package/dist/lib/ssr/stream-response.d.cts +30 -0
- package/dist/lib/ssr/stream-response.d.ts +30 -0
- package/dist/lib/ssr/stream.d.cts +16 -1
- package/dist/lib/ssr/stream.d.ts +16 -1
- package/dist/lib/{stream-DmZjYqHm.cjs → stream-Cg-xYG82.cjs} +3 -3
- package/dist/lib/stream-Cg-xYG82.cjs.map +1 -0
- package/dist/lib/stream-D-ytogdu.js +106 -0
- package/dist/lib/stream-D-ytogdu.js.map +1 -0
- package/dist/lib/vite/index.cjs +1 -1
- package/dist/lib/vite/index.cjs.map +1 -1
- package/dist/lib/vite/index.d.cts +11 -0
- package/dist/lib/vite/index.d.ts +11 -0
- package/dist/lib/vite/index.js +101 -94
- package/dist/lib/vite/index.js.map +1 -1
- package/package.json +25 -8
- package/dist/lib/errors-0X7pCFNU.cjs +0 -2
- package/dist/lib/hydrate-CJbUWdXu.js +0 -126
- package/dist/lib/hydrate-CJbUWdXu.js.map +0 -1
- package/dist/lib/hydrate-D6MR24mz.cjs +0 -2
- package/dist/lib/hydrate-D6MR24mz.cjs.map +0 -1
- package/dist/lib/interpolation-plugin-TWDch8nn.cjs +0 -39
- package/dist/lib/interpolation-plugin-TWDch8nn.cjs.map +0 -1
- package/dist/lib/interpolation-plugin-Wgb1j4pT.js.map +0 -1
- package/dist/lib/node-http-DRAUhO0c.js +0 -617
- package/dist/lib/node-http-DRAUhO0c.js.map +0 -1
- package/dist/lib/node-http-DhxguYyz.cjs +0 -13
- package/dist/lib/node-http-DhxguYyz.cjs.map +0 -1
- package/dist/lib/runtime-CrH5X-Es.cjs +0 -2
- package/dist/lib/runtime-CrH5X-Es.cjs.map +0 -1
- package/dist/lib/runtime-Ds2-wH6P.js +0 -520
- package/dist/lib/runtime-Ds2-wH6P.js.map +0 -1
- package/dist/lib/seo/index.cjs.map +0 -1
- package/dist/lib/seo/index.js.map +0 -1
- package/dist/lib/shared-CfqOLsKj.cjs.map +0 -1
- package/dist/lib/shared-DU3iQgr7.js.map +0 -1
- package/dist/lib/stream-CpOG052V.js +0 -104
- package/dist/lib/stream-CpOG052V.js.map +0 -1
- package/dist/lib/stream-DmZjYqHm.cjs.map +0 -1
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import { t as e } from "./island-CTBnsOhI.js";
|
|
2
|
+
import { a as t, r as n } from "./invalidation-DXhdE9wj.js";
|
|
3
|
+
import { a as r, o as i, s as a } from "./errors-j4cg9VN3.js";
|
|
4
|
+
import { renderToString as o } from "@elurjs/core/server";
|
|
5
|
+
import { existsSync as s } from "node:fs";
|
|
6
|
+
import { createHmac as c, randomBytes as l, timingSafeEqual as u } from "node:crypto";
|
|
7
|
+
//#region src/render/ssr-flag.ts
|
|
8
|
+
var d = Symbol.for("@elurjs/core/reactivity-state");
|
|
9
|
+
function f() {
|
|
10
|
+
return globalThis[d];
|
|
11
|
+
}
|
|
12
|
+
function p(e) {
|
|
13
|
+
let t = f();
|
|
14
|
+
t && (t.ssr = e);
|
|
15
|
+
}
|
|
16
|
+
function m() {
|
|
17
|
+
return f()?.ssr ?? !1;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/render/render-to-string.ts
|
|
21
|
+
async function h(e, t = {}) {
|
|
22
|
+
p(!0);
|
|
23
|
+
try {
|
|
24
|
+
return await o(e(), { markers: t.markers ?? "hydration" });
|
|
25
|
+
} finally {
|
|
26
|
+
p(!1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/build/document-shell.ts
|
|
31
|
+
var g = {
|
|
32
|
+
"&": "&",
|
|
33
|
+
"<": "<",
|
|
34
|
+
">": ">",
|
|
35
|
+
"\"": """,
|
|
36
|
+
"'": "'"
|
|
37
|
+
}, _ = "<!--elur:app:start-->", v = "<!--elur:app:end-->";
|
|
38
|
+
function y(e) {
|
|
39
|
+
let t = e.indexOf(_);
|
|
40
|
+
if (t < 0) return;
|
|
41
|
+
let n = e.indexOf(v, t + 21);
|
|
42
|
+
if (!(n < 0)) return e.slice(t + 21, n);
|
|
43
|
+
}
|
|
44
|
+
function b(e) {
|
|
45
|
+
return e.replace(/[&<>"']/g, (e) => g[e]);
|
|
46
|
+
}
|
|
47
|
+
function x(e) {
|
|
48
|
+
return JSON.stringify(e ?? null).replace(/</g, "\\u003c");
|
|
49
|
+
}
|
|
50
|
+
function S(e, t) {
|
|
51
|
+
let n = [], r = e.title ?? t;
|
|
52
|
+
e.title && n.push(`<title data-elur-head>${b(r)}</title>`), e.description && n.push(`<meta data-elur-head name="description" content="${b(e.description)}" />`), e.canonical && n.push(`<link data-elur-head rel="canonical" href="${b(e.canonical)}" />`), e.robots && n.push(`<meta data-elur-head name="robots" content="${b(e.robots)}" />`);
|
|
53
|
+
let i = e.openGraph;
|
|
54
|
+
i && (i.type && n.push(`<meta data-elur-head property="og:type" content="${b(i.type)}" />`), n.push(`<meta data-elur-head property="og:title" content="${b(i.title ?? r)}" />`), (i.description ?? e.description) && n.push(`<meta data-elur-head property="og:description" content="${b(i.description ?? e.description)}" />`), (i.url ?? e.canonical) && n.push(`<meta data-elur-head property="og:url" content="${b(i.url ?? e.canonical)}" />`), i.image && n.push(`<meta data-elur-head property="og:image" content="${b(i.image)}" />`), i.image && i.imageAlt && n.push(`<meta data-elur-head property="og:image:alt" content="${b(i.imageAlt)}" />`), i.image && i.imageWidth && n.push(`<meta data-elur-head property="og:image:width" content="${String(i.imageWidth)}" />`), i.image && i.imageHeight && n.push(`<meta data-elur-head property="og:image:height" content="${String(i.imageHeight)}" />`), i.image && i.imageType && n.push(`<meta data-elur-head property="og:image:type" content="${b(i.imageType)}" />`), i.siteName && n.push(`<meta data-elur-head property="og:site_name" content="${b(i.siteName)}" />`), i.locale && n.push(`<meta data-elur-head property="og:locale" content="${b(i.locale)}" />`));
|
|
55
|
+
let a = e.twitter;
|
|
56
|
+
if (a && (a.card && n.push(`<meta data-elur-head name="twitter:card" content="${b(a.card)}" />`), (a.title ?? r) && n.push(`<meta data-elur-head name="twitter:title" content="${b(a.title ?? r)}" />`), (a.description ?? e.description) && n.push(`<meta data-elur-head name="twitter:description" content="${b(a.description ?? e.description)}" />`), a.image && n.push(`<meta data-elur-head name="twitter:image" content="${b(a.image)}" />`), a.image && a.imageAlt && n.push(`<meta data-elur-head name="twitter:image:alt" content="${b(a.imageAlt)}" />`)), e.other) for (let [t, r] of Object.entries(e.other)) n.push(`<meta data-elur-head name="${b(t)}" content="${b(r)}" />`);
|
|
57
|
+
return n.map((e) => `\n ${e}`).join("");
|
|
58
|
+
}
|
|
59
|
+
function C(e) {
|
|
60
|
+
return `\n <script type="speculationrules">${JSON.stringify({ [e]: [{
|
|
61
|
+
source: "document",
|
|
62
|
+
where: { and: [{ href_matches: "/*" }, { not: { selector_matches: "a[download], a[target], a[data-no-router], a[data-no-speculation]" } }] },
|
|
63
|
+
eagerness: "moderate"
|
|
64
|
+
}] })}<\/script>`;
|
|
65
|
+
}
|
|
66
|
+
function w(e) {
|
|
67
|
+
let { body: t, title: n = "Elur Kit App", lang: r = "es", data: i, actions: a, clientEntry: o, routerEntry: s, htmlAttributes: c, headScripts: l, headLinks: u, metadata: d } = e, f = i === void 0 ? "" : `\n <script type="application/json" id="elur-data">${x(i)}<\/script>`, p = a && Object.keys(a).length > 0 ? `\n <script type="application/json" id="elur-actions">${x(a)}<\/script>` : "", m = (e) => `\n <link rel="modulepreload" href="${b(e)}" />`, h = (o ? m(o) : "") + (s ? m(s) : ""), g = o ? `\n <script type="module" src="${b(o)}"><\/script>` : "", y = s ? `\n <script type="module" src="${b(s)}"><\/script>` : "", w = e.speculation ? C(e.speculation) : "", T = c ? Object.entries(c).filter(([, e]) => e != null && e !== "").map(([e, t]) => ` ${b(e)}="${b(String(t))}"`).join("") : "", E = l ? l.filter((e) => typeof e == "string" && e.trim().length > 0).map((e) => e.trimStart().startsWith("<script") ? `\n ${e}` : `\n <script>${e.replace(/<\/script>/gi, "<\\/script>")}<\/script>`).join("") : "", D = d ? S(d, n) : "", O = d?.title ? "" : `\n <title>${b(n)}</title>`, k = u ? u.filter((e) => typeof e == "string" && e.trim().length > 0).map((e) => `\n ${e}`).join("") : "", A = e.renderEndpoint === !1 && e.routerEnabled !== !1 ? "\n <meta name=\"elur:render-endpoint\" content=\"off\" />" : "";
|
|
68
|
+
return `<!DOCTYPE html>
|
|
69
|
+
<html lang="${b(r)}"${T}>
|
|
70
|
+
<head>
|
|
71
|
+
<meta charset="utf-8" />
|
|
72
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />${A}${O}${D}${k}${E}${h}${w}
|
|
73
|
+
</head>
|
|
74
|
+
<body>
|
|
75
|
+
<div id="app">${_}${t}${v}</div>${f}${p}${g}${y}
|
|
76
|
+
</body>
|
|
77
|
+
</html>
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/action/error-store.ts
|
|
82
|
+
var T = "__elur_js_action_error", E = 3500, D = 15e3, O = process.env.ELUR_JS_ACTION_SECRET ?? l(32).toString("hex"), k = /* @__PURE__ */ new Map(), A = !1;
|
|
83
|
+
function j() {
|
|
84
|
+
A || (A = !0, setTimeout(() => {
|
|
85
|
+
A = !1;
|
|
86
|
+
let e = Date.now();
|
|
87
|
+
for (let [t, n] of k) n.expiresAt <= e && k.delete(t);
|
|
88
|
+
}, D).unref?.());
|
|
89
|
+
}
|
|
90
|
+
function M(e) {
|
|
91
|
+
return `${c("sha256", O).update(e).digest("hex")}.${e}`;
|
|
92
|
+
}
|
|
93
|
+
function N(e) {
|
|
94
|
+
let t = e.indexOf(".");
|
|
95
|
+
if (t === -1) return;
|
|
96
|
+
let n = e.slice(0, t), r = e.slice(t + 1), i = c("sha256", O).update(r).digest("hex");
|
|
97
|
+
if (n.length === i.length) try {
|
|
98
|
+
if (u(Buffer.from(n), Buffer.from(i))) return r;
|
|
99
|
+
} catch {}
|
|
100
|
+
}
|
|
101
|
+
function P(e, t) {
|
|
102
|
+
let n = JSON.stringify({
|
|
103
|
+
d: e,
|
|
104
|
+
s: t
|
|
105
|
+
}), r = M(Buffer.from(n, "utf8").toString("base64url"));
|
|
106
|
+
if (r.length <= E) return { value: r };
|
|
107
|
+
let i = l(12).toString("hex");
|
|
108
|
+
return k.set(i, {
|
|
109
|
+
data: e,
|
|
110
|
+
status: t,
|
|
111
|
+
expiresAt: Date.now() + D
|
|
112
|
+
}), j(), {
|
|
113
|
+
value: M(`id:${i}`),
|
|
114
|
+
storeId: i
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function F(e) {
|
|
118
|
+
if (!e) return;
|
|
119
|
+
let t = N(e);
|
|
120
|
+
if (t !== void 0) {
|
|
121
|
+
if (t.startsWith("id:")) {
|
|
122
|
+
let e = t.slice(3), n = k.get(e);
|
|
123
|
+
return !n || (k.delete(e), n.expiresAt <= Date.now()) ? void 0 : {
|
|
124
|
+
data: n.data,
|
|
125
|
+
status: n.status
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
let e = Buffer.from(t, "base64url").toString("utf8"), n = JSON.parse(e);
|
|
130
|
+
return {
|
|
131
|
+
data: n.d,
|
|
132
|
+
status: n.s
|
|
133
|
+
};
|
|
134
|
+
} catch {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
var I = T;
|
|
140
|
+
function L() {
|
|
141
|
+
return `${T}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
142
|
+
}
|
|
143
|
+
function R(e) {
|
|
144
|
+
return `${T}=${e}; Path=/; Max-Age=15; SameSite=Lax; HttpOnly`;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/ssr/render.ts
|
|
148
|
+
var ee = (e) => import(e);
|
|
149
|
+
function z(e, t) {
|
|
150
|
+
let n = {}, r = [], i = [], a = (e) => {
|
|
151
|
+
if (!e || typeof e != "object") return;
|
|
152
|
+
let t = e.htmlAttributes;
|
|
153
|
+
t && Object.assign(n, t);
|
|
154
|
+
let a = e.headScripts;
|
|
155
|
+
Array.isArray(a) && r.push(...a);
|
|
156
|
+
let o = e.headLinks;
|
|
157
|
+
Array.isArray(o) && i.push(...o);
|
|
158
|
+
};
|
|
159
|
+
for (let e of t) a(e);
|
|
160
|
+
return a(e), {
|
|
161
|
+
htmlAttributes: n,
|
|
162
|
+
headScripts: [...new Set(r)],
|
|
163
|
+
headLinks: [...new Set(i)]
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async function B(n) {
|
|
167
|
+
let { route: r, params: i = {}, searchParams: a = new URLSearchParams(), config: o, importer: c = ee, actions: l, request: u } = n, { default: d, generateMetadata: f } = await c(r.pagePath), p, m, g, _ = { response: void 0 };
|
|
168
|
+
if (r.dataPath) {
|
|
169
|
+
let e = await c(r.dataPath);
|
|
170
|
+
if (e.load) try {
|
|
171
|
+
p = await e.load({
|
|
172
|
+
params: i,
|
|
173
|
+
searchParams: a,
|
|
174
|
+
request: u
|
|
175
|
+
});
|
|
176
|
+
} catch (e) {
|
|
177
|
+
if (e instanceof Response) _.response = e;
|
|
178
|
+
else throw e;
|
|
179
|
+
}
|
|
180
|
+
typeof e.revalidate == "number" && (m = e.revalidate), e.cache && (g = t(e.cache), g.revalidate > 0 && (m = g.revalidate));
|
|
181
|
+
}
|
|
182
|
+
if (_.response) return {
|
|
183
|
+
html: "",
|
|
184
|
+
response: _.response,
|
|
185
|
+
status: _.response.status
|
|
186
|
+
};
|
|
187
|
+
let v, y;
|
|
188
|
+
if (u) {
|
|
189
|
+
let e = (u.headers.get("Cookie") ?? "").match(RegExp(`(?:^|;\\s*)${I}=([^;]+)`));
|
|
190
|
+
if (e) {
|
|
191
|
+
let t = F(e[1]);
|
|
192
|
+
t && (v = {
|
|
193
|
+
__elur_js_action_error: !0,
|
|
194
|
+
status: t.status,
|
|
195
|
+
data: t.data
|
|
196
|
+
}, y = `${I}=; Path=/; Max-Age=0; SameSite=Lax`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
let b = {
|
|
200
|
+
data: p ?? {},
|
|
201
|
+
params: i,
|
|
202
|
+
searchParams: a,
|
|
203
|
+
form: v
|
|
204
|
+
}, x = await Promise.all(r.layouts.map(async (e) => c(e))), C = await Promise.all(r.layouts.map(async (e) => {
|
|
205
|
+
let t = e.replace(/layout\.ts$/, "layout.data.ts");
|
|
206
|
+
if (!s(t)) return;
|
|
207
|
+
let n = await c(t);
|
|
208
|
+
if (n.load) try {
|
|
209
|
+
return await n.load({
|
|
210
|
+
params: i,
|
|
211
|
+
searchParams: a,
|
|
212
|
+
request: u
|
|
213
|
+
});
|
|
214
|
+
} catch (e) {
|
|
215
|
+
if (e instanceof Response) {
|
|
216
|
+
_.response = e;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
throw e;
|
|
220
|
+
}
|
|
221
|
+
})), T = _.response;
|
|
222
|
+
if (T) return {
|
|
223
|
+
html: "",
|
|
224
|
+
response: T,
|
|
225
|
+
status: T.status
|
|
226
|
+
};
|
|
227
|
+
let E;
|
|
228
|
+
if (r.slots) {
|
|
229
|
+
E = {};
|
|
230
|
+
for (let [e, t] of Object.entries(r.slots)) {
|
|
231
|
+
let n = await c(t);
|
|
232
|
+
E[e] = n.default(b);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
let D = await h(() => {
|
|
236
|
+
let e = d(b);
|
|
237
|
+
for (let t = x.length - 1; t >= 0; t--) {
|
|
238
|
+
let { default: n } = x[t];
|
|
239
|
+
e = n({
|
|
240
|
+
children: e,
|
|
241
|
+
data: C[t],
|
|
242
|
+
slots: E
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return e;
|
|
246
|
+
}), O = typeof p == "object" && p && "title" in p ? String(p.title ?? "Elur Kit") : "Elur Kit", { htmlAttributes: k, headScripts: A, headLinks: j } = z(p, C), M;
|
|
247
|
+
typeof f == "function" && (M = await f({
|
|
248
|
+
params: i,
|
|
249
|
+
searchParams: a,
|
|
250
|
+
request: u,
|
|
251
|
+
data: p
|
|
252
|
+
})), M ||= V(p) ?? te(C);
|
|
253
|
+
let N = M?.title ?? O, P = D.includes(e), L = o.router, R = L?.enabled !== !1, B, H;
|
|
254
|
+
!L || o.js === "legacy" ? B = o.clientEntry : L.entry ? (P && (B = o.clientEntry), R && (H = L.entry)) : (P || R) && (B = o.clientEntry);
|
|
255
|
+
let U = w({
|
|
256
|
+
title: N,
|
|
257
|
+
lang: o.lang,
|
|
258
|
+
body: D,
|
|
259
|
+
data: p,
|
|
260
|
+
actions: l,
|
|
261
|
+
htmlAttributes: k,
|
|
262
|
+
headScripts: A,
|
|
263
|
+
headLinks: j,
|
|
264
|
+
metadata: M,
|
|
265
|
+
clientEntry: B,
|
|
266
|
+
routerEntry: H,
|
|
267
|
+
routerEnabled: L ? R : void 0,
|
|
268
|
+
speculation: L?.speculation,
|
|
269
|
+
renderEndpoint: o.renderEndpoint
|
|
270
|
+
}), W = M ? S(M, N) : "";
|
|
271
|
+
return {
|
|
272
|
+
html: U,
|
|
273
|
+
revalidate: m,
|
|
274
|
+
clearActionErrorCookie: y,
|
|
275
|
+
head: W,
|
|
276
|
+
resolvedTitle: N,
|
|
277
|
+
cachePolicy: g,
|
|
278
|
+
data: p
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function V(e) {
|
|
282
|
+
if (e && typeof e == "object" && "metadata" in e) {
|
|
283
|
+
let t = e.metadata;
|
|
284
|
+
if (t && typeof t == "object") return t;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function te(e) {
|
|
288
|
+
for (let t of e) {
|
|
289
|
+
let e = V(t);
|
|
290
|
+
if (e) return e;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
async function H(e) {
|
|
294
|
+
let t = e.status === 404 ? e.routes.error404 : e.routes.error500;
|
|
295
|
+
if (t) try {
|
|
296
|
+
let { html: n } = await B({
|
|
297
|
+
route: t,
|
|
298
|
+
params: {},
|
|
299
|
+
searchParams: new URLSearchParams(),
|
|
300
|
+
config: e.config,
|
|
301
|
+
actions: e.actions,
|
|
302
|
+
importer: e.importer
|
|
303
|
+
});
|
|
304
|
+
return {
|
|
305
|
+
html: n,
|
|
306
|
+
status: e.status
|
|
307
|
+
};
|
|
308
|
+
} catch (t) {
|
|
309
|
+
console.error(`[render] error ${e.status} page failed`, t);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/ssr/match.ts
|
|
315
|
+
function U(e, t) {
|
|
316
|
+
let n = e.split("?")[0].split("/").filter(Boolean).map(G), r = [...t].sort((e, t) => K(t.path) - K(e.path));
|
|
317
|
+
for (let e of r) {
|
|
318
|
+
let t = q(n, e.path.split("/").filter(Boolean), e.optionalCatchAll);
|
|
319
|
+
if (t) return {
|
|
320
|
+
route: e,
|
|
321
|
+
params: t,
|
|
322
|
+
searchParams: new URLSearchParams()
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function W(e, t) {
|
|
327
|
+
let n = e.split("?")[0].split("/").filter(Boolean).map(G), r = [...t].sort((e, t) => K(t.path) - K(e.path));
|
|
328
|
+
for (let e of r) {
|
|
329
|
+
let t = q(n, e.path.split("/").filter(Boolean));
|
|
330
|
+
if (t) return {
|
|
331
|
+
route: e,
|
|
332
|
+
params: t
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function G(e) {
|
|
337
|
+
try {
|
|
338
|
+
return decodeURIComponent(e);
|
|
339
|
+
} catch {
|
|
340
|
+
return e;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function K(e) {
|
|
344
|
+
return e.split("/").filter(Boolean).reduce((e, t) => t.endsWith("*") ? e : t.startsWith(":") ? e + 1 : e + 2, 0);
|
|
345
|
+
}
|
|
346
|
+
function q(e, t, n = !1) {
|
|
347
|
+
let r = {}, i = 0;
|
|
348
|
+
for (let a = 0; a < t.length; a++) {
|
|
349
|
+
let o = t[a];
|
|
350
|
+
if (o.endsWith("*")) {
|
|
351
|
+
let t = o.slice(1, -1), a = e.slice(i);
|
|
352
|
+
return a.length === 0 && !n ? void 0 : (r[t] = a.length > 0 ? a : [], r);
|
|
353
|
+
}
|
|
354
|
+
if (o.startsWith(":")) {
|
|
355
|
+
let t = e[i];
|
|
356
|
+
if (t === void 0) return;
|
|
357
|
+
r[o.slice(1)] = t, i++;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (o !== e[i]) return;
|
|
361
|
+
i++;
|
|
362
|
+
}
|
|
363
|
+
if (i === e.length) return r;
|
|
364
|
+
}
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/action/origin.ts
|
|
367
|
+
function J(e) {
|
|
368
|
+
if (e) try {
|
|
369
|
+
let t = new URL(e);
|
|
370
|
+
return t.protocol !== "http:" && t.protocol !== "https:" ? void 0 : t.origin;
|
|
371
|
+
} catch {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function Y(e, t = {}) {
|
|
376
|
+
let n = J(e.url);
|
|
377
|
+
if (!n) return "Invalid target URL";
|
|
378
|
+
let r = e.headers.get("Origin"), i = e.headers.get("Referer");
|
|
379
|
+
if (!r && !i) return t.strictOrigin ? "Missing Origin and Referer headers" : void 0;
|
|
380
|
+
let a = J(r || i);
|
|
381
|
+
if (!a) return r ? "Invalid Origin header" : "Invalid Referer header";
|
|
382
|
+
if (a !== n && !t.allowedOrigins?.some((e) => J(e) === a)) return `Cross-origin request blocked: source "${a}" != target "${n}"`;
|
|
383
|
+
}
|
|
384
|
+
function X(e) {
|
|
385
|
+
return new Response(e, {
|
|
386
|
+
status: 403,
|
|
387
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/action/server.ts
|
|
392
|
+
var Z = 1048576;
|
|
393
|
+
async function Q(e, t) {
|
|
394
|
+
let n = e.headers.get("Content-Length");
|
|
395
|
+
if (n && parseInt(n, 10) > t) return {
|
|
396
|
+
ok: !1,
|
|
397
|
+
response: new Response("Request body too large", {
|
|
398
|
+
status: 413,
|
|
399
|
+
headers: { "Content-Type": "text/plain" }
|
|
400
|
+
})
|
|
401
|
+
};
|
|
402
|
+
let r = e.body?.getReader();
|
|
403
|
+
if (!r) return {
|
|
404
|
+
ok: !0,
|
|
405
|
+
text: ""
|
|
406
|
+
};
|
|
407
|
+
let i = [], a = 0;
|
|
408
|
+
try {
|
|
409
|
+
for (;;) {
|
|
410
|
+
let { done: e, value: n } = await r.read();
|
|
411
|
+
if (e) break;
|
|
412
|
+
if (a += n.byteLength, a > t) {
|
|
413
|
+
try {
|
|
414
|
+
r.cancel();
|
|
415
|
+
} catch {}
|
|
416
|
+
return {
|
|
417
|
+
ok: !1,
|
|
418
|
+
response: new Response("Request body too large", {
|
|
419
|
+
status: 413,
|
|
420
|
+
headers: { "Content-Type": "text/plain" }
|
|
421
|
+
})
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
i.push(n);
|
|
425
|
+
}
|
|
426
|
+
} finally {
|
|
427
|
+
try {
|
|
428
|
+
r.releaseLock();
|
|
429
|
+
} catch {}
|
|
430
|
+
}
|
|
431
|
+
let o = new Uint8Array(a), s = 0;
|
|
432
|
+
for (let e of i) o.set(e, s), s += e.byteLength;
|
|
433
|
+
return {
|
|
434
|
+
ok: !0,
|
|
435
|
+
text: new TextDecoder().decode(o)
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function $(e) {
|
|
439
|
+
let t = new URLSearchParams(e), n = {};
|
|
440
|
+
for (let [e, r] of t) n[e] === void 0 ? n[e] = r : Array.isArray(n[e]) ? n[e].push(r) : n[e] = [n[e], r];
|
|
441
|
+
return n;
|
|
442
|
+
}
|
|
443
|
+
async function ne(e, t = Z) {
|
|
444
|
+
if (e.method !== "POST") return {
|
|
445
|
+
ok: !1,
|
|
446
|
+
response: new Response("Method not allowed", {
|
|
447
|
+
status: 405,
|
|
448
|
+
headers: { "Content-Type": "text/plain" }
|
|
449
|
+
})
|
|
450
|
+
};
|
|
451
|
+
let n = e.headers.get("Content-Type") ?? "", r = (e.headers.get("Accept") ?? "").includes("application/json"), i, a, o = [];
|
|
452
|
+
if (n.includes("application/json")) {
|
|
453
|
+
let n = await Q(e, t);
|
|
454
|
+
if (!n.ok) return {
|
|
455
|
+
ok: !1,
|
|
456
|
+
response: n.response
|
|
457
|
+
};
|
|
458
|
+
let r;
|
|
459
|
+
try {
|
|
460
|
+
r = JSON.parse(n.text);
|
|
461
|
+
} catch {
|
|
462
|
+
return {
|
|
463
|
+
ok: !1,
|
|
464
|
+
response: new Response("Invalid JSON body", {
|
|
465
|
+
status: 400,
|
|
466
|
+
headers: { "Content-Type": "text/plain" }
|
|
467
|
+
})
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
i = r.name, a = r.page, o = Array.isArray(r.args) ? r.args : [];
|
|
471
|
+
} else if (n.includes("application/x-www-form-urlencoded") || n.includes("multipart/form-data")) {
|
|
472
|
+
if (n.includes("multipart/form-data")) {
|
|
473
|
+
let n = e.headers.get("Content-Length");
|
|
474
|
+
if (n && parseInt(n, 10) > t) return {
|
|
475
|
+
ok: !1,
|
|
476
|
+
response: new Response("Request body too large", {
|
|
477
|
+
status: 413,
|
|
478
|
+
headers: { "Content-Type": "text/plain" }
|
|
479
|
+
})
|
|
480
|
+
};
|
|
481
|
+
let r;
|
|
482
|
+
try {
|
|
483
|
+
r = await e.formData();
|
|
484
|
+
} catch {
|
|
485
|
+
return {
|
|
486
|
+
ok: !1,
|
|
487
|
+
response: new Response("Invalid form body", {
|
|
488
|
+
status: 400,
|
|
489
|
+
headers: { "Content-Type": "text/plain" }
|
|
490
|
+
})
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
i = r.get("__elur_js_action_name") ?? void 0, a = r.get("__elur_js_action_page") ?? void 0;
|
|
494
|
+
let s = {};
|
|
495
|
+
for (let [e, t] of r) e !== "__elur_js_action_name" && e !== "__elur_js_action_page" && (s[e] = t);
|
|
496
|
+
o = [s];
|
|
497
|
+
} else {
|
|
498
|
+
let n = await Q(e, t);
|
|
499
|
+
if (!n.ok) return {
|
|
500
|
+
ok: !1,
|
|
501
|
+
response: n.response
|
|
502
|
+
};
|
|
503
|
+
let r = $(n.text);
|
|
504
|
+
i = r.__elur_js_action_name, a = r.__elur_js_action_page;
|
|
505
|
+
let s = {};
|
|
506
|
+
for (let [e, t] of Object.entries(r)) e !== "__elur_js_action_name" && e !== "__elur_js_action_page" && (s[e] = t);
|
|
507
|
+
o = [s];
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
let n = await Q(e, t);
|
|
511
|
+
if (!n.ok) return {
|
|
512
|
+
ok: !1,
|
|
513
|
+
response: n.response
|
|
514
|
+
};
|
|
515
|
+
let r = $(n.text);
|
|
516
|
+
i = r.__elur_js_action_name, a = r.__elur_js_action_page;
|
|
517
|
+
let s = {};
|
|
518
|
+
for (let [e, t] of Object.entries(r)) e !== "__elur_js_action_name" && e !== "__elur_js_action_page" && (s[e] = t);
|
|
519
|
+
o = [s];
|
|
520
|
+
}
|
|
521
|
+
return !i || typeof i != "string" ? {
|
|
522
|
+
ok: !1,
|
|
523
|
+
response: new Response("Missing action name", {
|
|
524
|
+
status: 400,
|
|
525
|
+
headers: { "Content-Type": "text/plain" }
|
|
526
|
+
})
|
|
527
|
+
} : {
|
|
528
|
+
ok: !0,
|
|
529
|
+
name: i,
|
|
530
|
+
page: a,
|
|
531
|
+
args: o,
|
|
532
|
+
wantsJson: r
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
async function re(e, t, o = {}) {
|
|
536
|
+
let s = Y(e, o);
|
|
537
|
+
if (s) return X(s);
|
|
538
|
+
let c = await ne(e, o.bodyLimit ?? Z);
|
|
539
|
+
if (!c.ok) return c.response;
|
|
540
|
+
let { name: l, page: u, args: d, wantsJson: f } = c;
|
|
541
|
+
try {
|
|
542
|
+
let a = await t(l, u);
|
|
543
|
+
if (!a) {
|
|
544
|
+
let e = u ? `Action not found: ${l} (page: ${u})` : `Action not found: ${l}`;
|
|
545
|
+
return new Response(e, {
|
|
546
|
+
status: 404,
|
|
547
|
+
headers: { "Content-Type": "text/plain" }
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
let o = a.__elurAction, s;
|
|
551
|
+
if (o) {
|
|
552
|
+
let t = {
|
|
553
|
+
request: e,
|
|
554
|
+
signal: e.signal,
|
|
555
|
+
idempotencyKey: e.headers.get("Idempotency-Key") ?? void 0,
|
|
556
|
+
params: {},
|
|
557
|
+
locals: {}
|
|
558
|
+
};
|
|
559
|
+
s = await a(d[0], t);
|
|
560
|
+
} else s = await a(...d);
|
|
561
|
+
if (!r(s) && o) {
|
|
562
|
+
let e = o.invalidateTags ?? [], t = o.invalidatePaths ?? [];
|
|
563
|
+
(e.length > 0 || t.length > 0) && await n.emit({
|
|
564
|
+
tags: e,
|
|
565
|
+
paths: t,
|
|
566
|
+
source: l
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
if (r(s)) {
|
|
570
|
+
if (f) return new Response(JSON.stringify({
|
|
571
|
+
__elur_js_action_failure: !0,
|
|
572
|
+
status: s.status,
|
|
573
|
+
data: s.data
|
|
574
|
+
}), {
|
|
575
|
+
status: s.status,
|
|
576
|
+
headers: { "Content-Type": "application/json" }
|
|
577
|
+
});
|
|
578
|
+
let t = e.headers.get("Referer") ?? "/", n = new URL(t, "http://localhost"), { value: r } = P(s.data, s.status);
|
|
579
|
+
return new Response(null, {
|
|
580
|
+
status: 303,
|
|
581
|
+
headers: {
|
|
582
|
+
Location: n.pathname + n.search,
|
|
583
|
+
"Content-Type": "text/plain",
|
|
584
|
+
"Set-Cookie": R(r)
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
if (i(s)) return f ? new Response(JSON.stringify({
|
|
589
|
+
__elur_js_action_redirect: !0,
|
|
590
|
+
status: s.status,
|
|
591
|
+
location: s.location
|
|
592
|
+
}), {
|
|
593
|
+
status: 200,
|
|
594
|
+
headers: { "Content-Type": "application/json" }
|
|
595
|
+
}) : new Response(null, {
|
|
596
|
+
status: s.status,
|
|
597
|
+
headers: {
|
|
598
|
+
Location: s.location,
|
|
599
|
+
"Content-Type": "text/plain"
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
if (f) return new Response(JSON.stringify(s ?? null), {
|
|
603
|
+
status: 200,
|
|
604
|
+
headers: { "Content-Type": "application/json" }
|
|
605
|
+
});
|
|
606
|
+
let c = e.headers.get("Referer") ?? "/";
|
|
607
|
+
return new Response(null, {
|
|
608
|
+
status: 303,
|
|
609
|
+
headers: {
|
|
610
|
+
Location: typeof s == "string" ? s : c,
|
|
611
|
+
"Content-Type": "text/plain"
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
} catch (e) {
|
|
615
|
+
return console.error("[elur-kit] Action error:", e), a(e, { includeDetail: !1 });
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region src/middleware/index.ts
|
|
620
|
+
async function ie(e) {
|
|
621
|
+
let t = [`${e}/src/middleware.ts`, `${e}/middleware.ts`];
|
|
622
|
+
for (let e of t) try {
|
|
623
|
+
let t = await import(e), n = t.default ?? t.middleware;
|
|
624
|
+
if (typeof n != "function") continue;
|
|
625
|
+
return {
|
|
626
|
+
handler: n,
|
|
627
|
+
config: t.config ?? {}
|
|
628
|
+
};
|
|
629
|
+
} catch (e) {
|
|
630
|
+
let t = typeof e == "object" && e && "message" in e ? String(e.message) : String(e);
|
|
631
|
+
if (t.includes("Cannot find module") || t.includes("Cannot find package") || t.includes("ENOENT") || t.includes("Module not found")) continue;
|
|
632
|
+
throw Error(`[elur-kit] Error loading middleware: ${t}`, { cause: e });
|
|
633
|
+
}
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
function ae(e, t) {
|
|
637
|
+
if (!t.matcher || t.matcher.length === 0) return !0;
|
|
638
|
+
let n = e.split("?")[0];
|
|
639
|
+
for (let e of t.matcher) {
|
|
640
|
+
if (e === n) return !0;
|
|
641
|
+
let t = e.match(/^(.*)\/:[\w]+\*$/);
|
|
642
|
+
if (t && n === t[1] || U(n, [{
|
|
643
|
+
path: e,
|
|
644
|
+
pagePath: "",
|
|
645
|
+
params: [],
|
|
646
|
+
layouts: []
|
|
647
|
+
}])) return !0;
|
|
648
|
+
}
|
|
649
|
+
return !1;
|
|
650
|
+
}
|
|
651
|
+
async function oe(e, t, n) {
|
|
652
|
+
let r, i, a, o = [], s = {
|
|
653
|
+
next(e) {
|
|
654
|
+
e?.headers && (r = e.headers), e?.params && (i = e.params), e?.locals && (a = e.locals);
|
|
655
|
+
},
|
|
656
|
+
params: n,
|
|
657
|
+
locals: {}
|
|
658
|
+
};
|
|
659
|
+
try {
|
|
660
|
+
let o = await e.handler(t, s);
|
|
661
|
+
return o instanceof Response ? {
|
|
662
|
+
kind: "response",
|
|
663
|
+
response: o
|
|
664
|
+
} : {
|
|
665
|
+
kind: "continue",
|
|
666
|
+
headers: r,
|
|
667
|
+
params: i ?? n,
|
|
668
|
+
locals: a
|
|
669
|
+
};
|
|
670
|
+
} finally {
|
|
671
|
+
for (let e of o) try {
|
|
672
|
+
await e();
|
|
673
|
+
} catch (e) {
|
|
674
|
+
console.error("[elur-kit] middleware cleanup error:", e);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/runtime/node-http.ts
|
|
680
|
+
var se = globalThis.AbortController ?? AbortController;
|
|
681
|
+
function ce(e, t) {
|
|
682
|
+
let n = new Headers();
|
|
683
|
+
for (let t = 0; t < e.rawHeaders.length; t += 2) n.append(e.rawHeaders[t], e.rawHeaders[t + 1]);
|
|
684
|
+
let r = new se();
|
|
685
|
+
e.once("aborted", () => r.abort()), e.once("close", () => {
|
|
686
|
+
e.complete || r.abort();
|
|
687
|
+
});
|
|
688
|
+
let i = e.socket.encrypted ? "https" : "http", a = {
|
|
689
|
+
method: e.method ?? "GET",
|
|
690
|
+
headers: n,
|
|
691
|
+
signal: r.signal
|
|
692
|
+
};
|
|
693
|
+
return t != null && a.method !== "GET" && a.method !== "HEAD" && (a.body = t), new Request(`${i}://${n.get("host") ?? "localhost"}${e.url ?? "/"}`, a);
|
|
694
|
+
}
|
|
695
|
+
async function le(e, t) {
|
|
696
|
+
let n = Object.fromEntries(t.headers.entries());
|
|
697
|
+
t.body !== null && (delete n["content-length"], delete n["transfer-encoding"]), e.writeHead(t.status, n);
|
|
698
|
+
let r = t.body;
|
|
699
|
+
if (!r) {
|
|
700
|
+
e.end();
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
let i = r.getReader(), a = !1, o = () => {
|
|
704
|
+
a || i.cancel().catch(() => {});
|
|
705
|
+
};
|
|
706
|
+
e.once("close", o);
|
|
707
|
+
try {
|
|
708
|
+
for (;;) {
|
|
709
|
+
let { done: t, value: n } = await i.read();
|
|
710
|
+
if (t) break;
|
|
711
|
+
n && n.byteLength > 0 && !e.write(n) && await new Promise((t) => e.once("drain", t));
|
|
712
|
+
}
|
|
713
|
+
a = !0, e.end();
|
|
714
|
+
} catch {
|
|
715
|
+
a = !0, e.destroy();
|
|
716
|
+
} finally {
|
|
717
|
+
e.removeListener("close", o);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
//#endregion
|
|
721
|
+
export { y as C, m as E, w as S, h as T, P as _, oe as a, _ as b, Y as c, z as d, H as f, F as g, L as h, ae as i, W as l, I as m, le as n, re as o, B as p, ie as r, X as s, ce as t, U as u, R as v, x as w, S as x, v as y };
|
|
722
|
+
|
|
723
|
+
//# sourceMappingURL=node-http-DVFcYeBS.js.map
|