@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
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
import { a as e, o as t, s as n } from "./errors-ePYxDlhU.js";
|
|
2
|
-
import { renderToString as r } from "@elurjs/core/server";
|
|
3
|
-
import { existsSync as i } from "node:fs";
|
|
4
|
-
import { createHmac as a, randomBytes as o, timingSafeEqual as s } from "node:crypto";
|
|
5
|
-
//#region src/render/ssr-flag.ts
|
|
6
|
-
var c = Symbol.for("@elurjs/core/reactivity-state");
|
|
7
|
-
function l() {
|
|
8
|
-
return globalThis[c];
|
|
9
|
-
}
|
|
10
|
-
function u(e) {
|
|
11
|
-
let t = l();
|
|
12
|
-
t && (t.ssr = e);
|
|
13
|
-
}
|
|
14
|
-
function d() {
|
|
15
|
-
return l()?.ssr ?? !1;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/render/render-to-string.ts
|
|
19
|
-
async function f(e, t = {}) {
|
|
20
|
-
u(!0);
|
|
21
|
-
try {
|
|
22
|
-
return await r(e(), { markers: t.markers ?? "hydration" });
|
|
23
|
-
} finally {
|
|
24
|
-
u(!1);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/build/document-shell.ts
|
|
29
|
-
var p = {
|
|
30
|
-
"&": "&",
|
|
31
|
-
"<": "<",
|
|
32
|
-
">": ">",
|
|
33
|
-
"\"": """,
|
|
34
|
-
"'": "'"
|
|
35
|
-
};
|
|
36
|
-
function m(e) {
|
|
37
|
-
return e.replace(/[&<>"']/g, (e) => p[e]);
|
|
38
|
-
}
|
|
39
|
-
function h(e) {
|
|
40
|
-
return JSON.stringify(e ?? null).replace(/</g, "\\u003c");
|
|
41
|
-
}
|
|
42
|
-
function g(e, t) {
|
|
43
|
-
let n = [], r = e.title ?? t;
|
|
44
|
-
e.title && n.push(`<title data-elur-head>${m(r)}</title>`), e.description && n.push(`<meta data-elur-head name="description" content="${m(e.description)}" />`), e.canonical && n.push(`<link data-elur-head rel="canonical" href="${m(e.canonical)}" />`), e.robots && n.push(`<meta data-elur-head name="robots" content="${m(e.robots)}" />`);
|
|
45
|
-
let i = e.openGraph;
|
|
46
|
-
i && (i.type && n.push(`<meta data-elur-head property="og:type" content="${m(i.type)}" />`), n.push(`<meta data-elur-head property="og:title" content="${m(i.title ?? r)}" />`), (i.description ?? e.description) && n.push(`<meta data-elur-head property="og:description" content="${m(i.description ?? e.description)}" />`), (i.url ?? e.canonical) && n.push(`<meta data-elur-head property="og:url" content="${m(i.url ?? e.canonical)}" />`), i.image && n.push(`<meta data-elur-head property="og:image" content="${m(i.image)}" />`), i.image && i.imageAlt && n.push(`<meta data-elur-head property="og:image:alt" content="${m(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="${m(i.imageType)}" />`), i.siteName && n.push(`<meta data-elur-head property="og:site_name" content="${m(i.siteName)}" />`), i.locale && n.push(`<meta data-elur-head property="og:locale" content="${m(i.locale)}" />`));
|
|
47
|
-
let a = e.twitter;
|
|
48
|
-
if (a && (a.card && n.push(`<meta data-elur-head name="twitter:card" content="${m(a.card)}" />`), (a.title ?? r) && n.push(`<meta data-elur-head name="twitter:title" content="${m(a.title ?? r)}" />`), (a.description ?? e.description) && n.push(`<meta data-elur-head name="twitter:description" content="${m(a.description ?? e.description)}" />`), a.image && n.push(`<meta data-elur-head name="twitter:image" content="${m(a.image)}" />`), a.image && a.imageAlt && n.push(`<meta data-elur-head name="twitter:image:alt" content="${m(a.imageAlt)}" />`)), e.other) for (let [t, r] of Object.entries(e.other)) n.push(`<meta data-elur-head name="${m(t)}" content="${m(r)}" />`);
|
|
49
|
-
return n.map((e) => `\n ${e}`).join("");
|
|
50
|
-
}
|
|
51
|
-
function _(e) {
|
|
52
|
-
let { body: t, title: n = "Elur Kit App", lang: r = "es", data: i, actions: a, clientEntry: o, htmlAttributes: s, headScripts: c, headLinks: l, metadata: u } = e, d = i === void 0 ? "" : `\n <script type="application/json" id="elur-data">${h(i)}<\/script>`, f = a && Object.keys(a).length > 0 ? `\n <script type="application/json" id="elur-actions">${h(a)}<\/script>` : "", p = o ? `\n <script type="module" src="${m(o)}"><\/script>` : "", _ = s ? Object.entries(s).filter(([, e]) => e != null && e !== "").map(([e, t]) => ` ${m(e)}="${m(String(t))}"`).join("") : "", v = c ? c.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("") : "", y = u ? g(u, n) : "", b = u?.title ? "" : `\n <title>${m(n)}</title>`, x = l ? l.filter((e) => typeof e == "string" && e.trim().length > 0).map((e) => `\n ${e}`).join("") : "", S = e.renderEndpoint === !1 ? "\n <meta name=\"elur:render-endpoint\" content=\"off\" />" : "";
|
|
53
|
-
return `<!DOCTYPE html>
|
|
54
|
-
<html lang="${m(r)}"${_}>
|
|
55
|
-
<head>
|
|
56
|
-
<meta charset="utf-8" />
|
|
57
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />${S}${b}${y}${x}${v}
|
|
58
|
-
</head>
|
|
59
|
-
<body>
|
|
60
|
-
<div id="app">${t}</div>${d}${f}${p}
|
|
61
|
-
</body>
|
|
62
|
-
</html>
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/action/error-store.ts
|
|
67
|
-
var v = "__elur_js_action_error", y = 3500, b = 15e3, x = process.env.ELUR_JS_ACTION_SECRET ?? o(32).toString("hex"), S = /* @__PURE__ */ new Map(), C = !1;
|
|
68
|
-
function w() {
|
|
69
|
-
C || (C = !0, setTimeout(() => {
|
|
70
|
-
C = !1;
|
|
71
|
-
let e = Date.now();
|
|
72
|
-
for (let [t, n] of S) n.expiresAt <= e && S.delete(t);
|
|
73
|
-
}, b).unref?.());
|
|
74
|
-
}
|
|
75
|
-
function T(e) {
|
|
76
|
-
return `${a("sha256", x).update(e).digest("hex")}.${e}`;
|
|
77
|
-
}
|
|
78
|
-
function E(e) {
|
|
79
|
-
let t = e.indexOf(".");
|
|
80
|
-
if (t === -1) return;
|
|
81
|
-
let n = e.slice(0, t), r = e.slice(t + 1), i = a("sha256", x).update(r).digest("hex");
|
|
82
|
-
if (n.length === i.length) try {
|
|
83
|
-
if (s(Buffer.from(n), Buffer.from(i))) return r;
|
|
84
|
-
} catch {}
|
|
85
|
-
}
|
|
86
|
-
function D(e, t) {
|
|
87
|
-
let n = JSON.stringify({
|
|
88
|
-
d: e,
|
|
89
|
-
s: t
|
|
90
|
-
}), r = T(Buffer.from(n, "utf8").toString("base64url"));
|
|
91
|
-
if (r.length <= y) return { value: r };
|
|
92
|
-
let i = o(12).toString("hex");
|
|
93
|
-
return S.set(i, {
|
|
94
|
-
data: e,
|
|
95
|
-
status: t,
|
|
96
|
-
expiresAt: Date.now() + b
|
|
97
|
-
}), w(), {
|
|
98
|
-
value: T(`id:${i}`),
|
|
99
|
-
storeId: i
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function O(e) {
|
|
103
|
-
if (!e) return;
|
|
104
|
-
let t = E(e);
|
|
105
|
-
if (t !== void 0) {
|
|
106
|
-
if (t.startsWith("id:")) {
|
|
107
|
-
let e = t.slice(3), n = S.get(e);
|
|
108
|
-
return !n || (S.delete(e), n.expiresAt <= Date.now()) ? void 0 : {
|
|
109
|
-
data: n.data,
|
|
110
|
-
status: n.status
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
let e = Buffer.from(t, "base64url").toString("utf8"), n = JSON.parse(e);
|
|
115
|
-
return {
|
|
116
|
-
data: n.d,
|
|
117
|
-
status: n.s
|
|
118
|
-
};
|
|
119
|
-
} catch {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
var k = v;
|
|
125
|
-
function A() {
|
|
126
|
-
return `${v}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
127
|
-
}
|
|
128
|
-
function j(e) {
|
|
129
|
-
return `${v}=${e}; Path=/; Max-Age=15; SameSite=Lax; HttpOnly`;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/cache/policy.ts
|
|
133
|
-
var M = {
|
|
134
|
-
mode: "dynamic",
|
|
135
|
-
revalidate: 0
|
|
136
|
-
};
|
|
137
|
-
function N(e) {
|
|
138
|
-
if (!e || typeof e != "object") return M;
|
|
139
|
-
let t = e, n = t.mode;
|
|
140
|
-
return n !== "public" && n !== "private" && n !== "dynamic" ? M : {
|
|
141
|
-
mode: n,
|
|
142
|
-
revalidate: typeof t.revalidate == "number" ? t.revalidate : 0,
|
|
143
|
-
tags: Array.isArray(t.tags) ? t.tags.filter((e) => typeof e == "string") : void 0
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function P(e, t) {
|
|
147
|
-
return !(e.mode !== "public" || e.revalidate <= 0 || t.headers.get("Cookie") || t.headers.get("Authorization"));
|
|
148
|
-
}
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/ssr/render.ts
|
|
151
|
-
var F = (e) => import(e);
|
|
152
|
-
function I(e, t) {
|
|
153
|
-
let n = {}, r = [], i = [], a = (e) => {
|
|
154
|
-
if (!e || typeof e != "object") return;
|
|
155
|
-
let t = e.htmlAttributes;
|
|
156
|
-
t && Object.assign(n, t);
|
|
157
|
-
let a = e.headScripts;
|
|
158
|
-
Array.isArray(a) && r.push(...a);
|
|
159
|
-
let o = e.headLinks;
|
|
160
|
-
Array.isArray(o) && i.push(...o);
|
|
161
|
-
};
|
|
162
|
-
for (let e of t) a(e);
|
|
163
|
-
return a(e), {
|
|
164
|
-
htmlAttributes: n,
|
|
165
|
-
headScripts: [...new Set(r)],
|
|
166
|
-
headLinks: [...new Set(i)]
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
async function L(e) {
|
|
170
|
-
let { route: t, params: n = {}, searchParams: r = new URLSearchParams(), config: a, importer: o = F, actions: s, request: c } = e, { default: l, generateMetadata: u } = await o(t.pagePath), d, p, m, h = { response: void 0 };
|
|
171
|
-
if (t.dataPath) {
|
|
172
|
-
let e = await o(t.dataPath);
|
|
173
|
-
if (e.load) try {
|
|
174
|
-
d = await e.load({
|
|
175
|
-
params: n,
|
|
176
|
-
searchParams: r,
|
|
177
|
-
request: c
|
|
178
|
-
});
|
|
179
|
-
} catch (e) {
|
|
180
|
-
if (e instanceof Response) h.response = e;
|
|
181
|
-
else throw e;
|
|
182
|
-
}
|
|
183
|
-
typeof e.revalidate == "number" && (p = e.revalidate), e.cache && (m = N(e.cache), m.revalidate > 0 && (p = m.revalidate));
|
|
184
|
-
}
|
|
185
|
-
if (h.response) return {
|
|
186
|
-
html: "",
|
|
187
|
-
response: h.response,
|
|
188
|
-
status: h.response.status
|
|
189
|
-
};
|
|
190
|
-
let v, y;
|
|
191
|
-
if (c) {
|
|
192
|
-
let e = (c.headers.get("Cookie") ?? "").match(RegExp(`(?:^|;\\s*)${k}=([^;]+)`));
|
|
193
|
-
if (e) {
|
|
194
|
-
let t = O(e[1]);
|
|
195
|
-
t && (v = {
|
|
196
|
-
__elur_js_action_error: !0,
|
|
197
|
-
status: t.status,
|
|
198
|
-
data: t.data
|
|
199
|
-
}, y = `${k}=; Path=/; Max-Age=0; SameSite=Lax`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
let b = {
|
|
203
|
-
data: d ?? {},
|
|
204
|
-
params: n,
|
|
205
|
-
searchParams: r,
|
|
206
|
-
form: v
|
|
207
|
-
}, x = await Promise.all(t.layouts.map(async (e) => o(e))), S = await Promise.all(t.layouts.map(async (e) => {
|
|
208
|
-
let t = e.replace(/layout\.ts$/, "layout.data.ts");
|
|
209
|
-
if (!i(t)) return;
|
|
210
|
-
let a = await o(t);
|
|
211
|
-
if (a.load) try {
|
|
212
|
-
return await a.load({
|
|
213
|
-
params: n,
|
|
214
|
-
searchParams: r,
|
|
215
|
-
request: c
|
|
216
|
-
});
|
|
217
|
-
} catch (e) {
|
|
218
|
-
if (e instanceof Response) {
|
|
219
|
-
h.response = e;
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
throw e;
|
|
223
|
-
}
|
|
224
|
-
})), C = h.response;
|
|
225
|
-
if (C) return {
|
|
226
|
-
html: "",
|
|
227
|
-
response: C,
|
|
228
|
-
status: C.status
|
|
229
|
-
};
|
|
230
|
-
let w;
|
|
231
|
-
if (t.slots) {
|
|
232
|
-
w = {};
|
|
233
|
-
for (let [e, n] of Object.entries(t.slots)) {
|
|
234
|
-
let t = await o(n);
|
|
235
|
-
w[e] = t.default(b);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
let T = await f(() => {
|
|
239
|
-
let e = l(b);
|
|
240
|
-
for (let t = x.length - 1; t >= 0; t--) {
|
|
241
|
-
let { default: n } = x[t];
|
|
242
|
-
e = n({
|
|
243
|
-
children: e,
|
|
244
|
-
data: S[t],
|
|
245
|
-
slots: w
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
return e;
|
|
249
|
-
}), E = typeof d == "object" && d && "title" in d ? String(d.title ?? "Elur Kit") : "Elur Kit", { htmlAttributes: D, headScripts: A, headLinks: j } = I(d, S), M;
|
|
250
|
-
typeof u == "function" && (M = await u({
|
|
251
|
-
params: n,
|
|
252
|
-
searchParams: r,
|
|
253
|
-
request: c,
|
|
254
|
-
data: d
|
|
255
|
-
})), M ||= R(d) ?? z(S);
|
|
256
|
-
let P = M?.title ?? E, L = _({
|
|
257
|
-
title: P,
|
|
258
|
-
lang: a.lang,
|
|
259
|
-
body: T,
|
|
260
|
-
data: d,
|
|
261
|
-
actions: s,
|
|
262
|
-
htmlAttributes: D,
|
|
263
|
-
headScripts: A,
|
|
264
|
-
headLinks: j,
|
|
265
|
-
metadata: M,
|
|
266
|
-
clientEntry: a.clientEntry,
|
|
267
|
-
renderEndpoint: a.renderEndpoint
|
|
268
|
-
}), B = M ? g(M, P) : "";
|
|
269
|
-
return {
|
|
270
|
-
html: L,
|
|
271
|
-
revalidate: p,
|
|
272
|
-
clearActionErrorCookie: y,
|
|
273
|
-
head: B,
|
|
274
|
-
resolvedTitle: P,
|
|
275
|
-
cachePolicy: m
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
function R(e) {
|
|
279
|
-
if (e && typeof e == "object" && "metadata" in e) {
|
|
280
|
-
let t = e.metadata;
|
|
281
|
-
if (t && typeof t == "object") return t;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
function z(e) {
|
|
285
|
-
for (let t of e) {
|
|
286
|
-
let e = R(t);
|
|
287
|
-
if (e) return e;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
async function B(e) {
|
|
291
|
-
let t = e.status === 404 ? e.routes.error404 : e.routes.error500;
|
|
292
|
-
if (t) try {
|
|
293
|
-
let { html: n } = await L({
|
|
294
|
-
route: t,
|
|
295
|
-
params: {},
|
|
296
|
-
searchParams: new URLSearchParams(),
|
|
297
|
-
config: e.config,
|
|
298
|
-
actions: e.actions,
|
|
299
|
-
importer: e.importer
|
|
300
|
-
});
|
|
301
|
-
return {
|
|
302
|
-
html: n,
|
|
303
|
-
status: e.status
|
|
304
|
-
};
|
|
305
|
-
} catch (t) {
|
|
306
|
-
console.error(`[render] error ${e.status} page failed`, t);
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/ssr/match.ts
|
|
312
|
-
function V(e, t) {
|
|
313
|
-
let n = e.split("?")[0].split("/").filter(Boolean).map(U), r = [...t].sort((e, t) => W(t.path) - W(e.path));
|
|
314
|
-
for (let e of r) {
|
|
315
|
-
let t = G(n, e.path.split("/").filter(Boolean), e.optionalCatchAll);
|
|
316
|
-
if (t) return {
|
|
317
|
-
route: e,
|
|
318
|
-
params: t,
|
|
319
|
-
searchParams: new URLSearchParams()
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function H(e, t) {
|
|
324
|
-
let n = e.split("?")[0].split("/").filter(Boolean).map(U), r = [...t].sort((e, t) => W(t.path) - W(e.path));
|
|
325
|
-
for (let e of r) {
|
|
326
|
-
let t = G(n, e.path.split("/").filter(Boolean));
|
|
327
|
-
if (t) return {
|
|
328
|
-
route: e,
|
|
329
|
-
params: t
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
function U(e) {
|
|
334
|
-
try {
|
|
335
|
-
return decodeURIComponent(e);
|
|
336
|
-
} catch {
|
|
337
|
-
return e;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function W(e) {
|
|
341
|
-
return e.split("/").filter(Boolean).reduce((e, t) => t.endsWith("*") ? e : t.startsWith(":") ? e + 1 : e + 2, 0);
|
|
342
|
-
}
|
|
343
|
-
function G(e, t, n = !1) {
|
|
344
|
-
let r = {}, i = 0;
|
|
345
|
-
for (let a = 0; a < t.length; a++) {
|
|
346
|
-
let o = t[a];
|
|
347
|
-
if (o.endsWith("*")) {
|
|
348
|
-
let t = o.slice(1, -1), a = e.slice(i);
|
|
349
|
-
return a.length === 0 && !n ? void 0 : (r[t] = a.length > 0 ? a : [], r);
|
|
350
|
-
}
|
|
351
|
-
if (o.startsWith(":")) {
|
|
352
|
-
let t = e[i];
|
|
353
|
-
if (t === void 0) return;
|
|
354
|
-
r[o.slice(1)] = t, i++;
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
if (o !== e[i]) return;
|
|
358
|
-
i++;
|
|
359
|
-
}
|
|
360
|
-
if (i === e.length) return r;
|
|
361
|
-
}
|
|
362
|
-
//#endregion
|
|
363
|
-
//#region src/action/origin.ts
|
|
364
|
-
function K(e) {
|
|
365
|
-
if (e) try {
|
|
366
|
-
let t = new URL(e);
|
|
367
|
-
return t.protocol !== "http:" && t.protocol !== "https:" ? void 0 : t.origin;
|
|
368
|
-
} catch {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
function q(e, t = {}) {
|
|
373
|
-
let n = K(e.url);
|
|
374
|
-
if (!n) return "Invalid target URL";
|
|
375
|
-
let r = e.headers.get("Origin"), i = e.headers.get("Referer");
|
|
376
|
-
if (!r && !i) return t.strictOrigin ? "Missing Origin and Referer headers" : void 0;
|
|
377
|
-
let a = K(r || i);
|
|
378
|
-
if (!a) return r ? "Invalid Origin header" : "Invalid Referer header";
|
|
379
|
-
if (a !== n && !t.allowedOrigins?.some((e) => K(e) === a)) return `Cross-origin request blocked: source "${a}" != target "${n}"`;
|
|
380
|
-
}
|
|
381
|
-
function J(e) {
|
|
382
|
-
return new Response(e, {
|
|
383
|
-
status: 403,
|
|
384
|
-
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region src/action/server.ts
|
|
389
|
-
var Y = 1048576;
|
|
390
|
-
async function X(e, t) {
|
|
391
|
-
let n = e.headers.get("Content-Length");
|
|
392
|
-
if (n && parseInt(n, 10) > t) return {
|
|
393
|
-
ok: !1,
|
|
394
|
-
response: new Response("Request body too large", {
|
|
395
|
-
status: 413,
|
|
396
|
-
headers: { "Content-Type": "text/plain" }
|
|
397
|
-
})
|
|
398
|
-
};
|
|
399
|
-
let r = e.body?.getReader();
|
|
400
|
-
if (!r) return {
|
|
401
|
-
ok: !0,
|
|
402
|
-
text: ""
|
|
403
|
-
};
|
|
404
|
-
let i = [], a = 0;
|
|
405
|
-
try {
|
|
406
|
-
for (;;) {
|
|
407
|
-
let { done: e, value: n } = await r.read();
|
|
408
|
-
if (e) break;
|
|
409
|
-
if (a += n.byteLength, a > t) {
|
|
410
|
-
try {
|
|
411
|
-
r.cancel();
|
|
412
|
-
} catch {}
|
|
413
|
-
return {
|
|
414
|
-
ok: !1,
|
|
415
|
-
response: new Response("Request body too large", {
|
|
416
|
-
status: 413,
|
|
417
|
-
headers: { "Content-Type": "text/plain" }
|
|
418
|
-
})
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
i.push(n);
|
|
422
|
-
}
|
|
423
|
-
} finally {
|
|
424
|
-
try {
|
|
425
|
-
r.releaseLock();
|
|
426
|
-
} catch {}
|
|
427
|
-
}
|
|
428
|
-
let o = new Uint8Array(a), s = 0;
|
|
429
|
-
for (let e of i) o.set(e, s), s += e.byteLength;
|
|
430
|
-
return {
|
|
431
|
-
ok: !0,
|
|
432
|
-
text: new TextDecoder().decode(o)
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
function Z(e) {
|
|
436
|
-
let t = new URLSearchParams(e), n = {};
|
|
437
|
-
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];
|
|
438
|
-
return n;
|
|
439
|
-
}
|
|
440
|
-
async function Q(e, t = Y) {
|
|
441
|
-
if (e.method !== "POST") return {
|
|
442
|
-
ok: !1,
|
|
443
|
-
response: new Response("Method not allowed", {
|
|
444
|
-
status: 405,
|
|
445
|
-
headers: { "Content-Type": "text/plain" }
|
|
446
|
-
})
|
|
447
|
-
};
|
|
448
|
-
let n = e.headers.get("Content-Type") ?? "", r = (e.headers.get("Accept") ?? "").includes("application/json"), i, a, o = [];
|
|
449
|
-
if (n.includes("application/json")) {
|
|
450
|
-
let n = await X(e, t);
|
|
451
|
-
if (!n.ok) return {
|
|
452
|
-
ok: !1,
|
|
453
|
-
response: n.response
|
|
454
|
-
};
|
|
455
|
-
let r;
|
|
456
|
-
try {
|
|
457
|
-
r = JSON.parse(n.text);
|
|
458
|
-
} catch {
|
|
459
|
-
return {
|
|
460
|
-
ok: !1,
|
|
461
|
-
response: new Response("Invalid JSON body", {
|
|
462
|
-
status: 400,
|
|
463
|
-
headers: { "Content-Type": "text/plain" }
|
|
464
|
-
})
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
i = r.name, a = r.page, o = Array.isArray(r.args) ? r.args : [];
|
|
468
|
-
} else if (n.includes("application/x-www-form-urlencoded") || n.includes("multipart/form-data")) {
|
|
469
|
-
if (n.includes("multipart/form-data")) {
|
|
470
|
-
let n = e.headers.get("Content-Length");
|
|
471
|
-
if (n && parseInt(n, 10) > t) return {
|
|
472
|
-
ok: !1,
|
|
473
|
-
response: new Response("Request body too large", {
|
|
474
|
-
status: 413,
|
|
475
|
-
headers: { "Content-Type": "text/plain" }
|
|
476
|
-
})
|
|
477
|
-
};
|
|
478
|
-
let r;
|
|
479
|
-
try {
|
|
480
|
-
r = await e.formData();
|
|
481
|
-
} catch {
|
|
482
|
-
return {
|
|
483
|
-
ok: !1,
|
|
484
|
-
response: new Response("Invalid form body", {
|
|
485
|
-
status: 400,
|
|
486
|
-
headers: { "Content-Type": "text/plain" }
|
|
487
|
-
})
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
i = r.get("__elur_js_action_name") ?? void 0, a = r.get("__elur_js_action_page") ?? void 0;
|
|
491
|
-
let s = {};
|
|
492
|
-
for (let [e, t] of r) e !== "__elur_js_action_name" && e !== "__elur_js_action_page" && (s[e] = t);
|
|
493
|
-
o = [s];
|
|
494
|
-
} else {
|
|
495
|
-
let n = await X(e, t);
|
|
496
|
-
if (!n.ok) return {
|
|
497
|
-
ok: !1,
|
|
498
|
-
response: n.response
|
|
499
|
-
};
|
|
500
|
-
let r = Z(n.text);
|
|
501
|
-
i = r.__elur_js_action_name, a = r.__elur_js_action_page;
|
|
502
|
-
let s = {};
|
|
503
|
-
for (let [e, t] of Object.entries(r)) e !== "__elur_js_action_name" && e !== "__elur_js_action_page" && (s[e] = t);
|
|
504
|
-
o = [s];
|
|
505
|
-
}
|
|
506
|
-
} else {
|
|
507
|
-
let n = await X(e, t);
|
|
508
|
-
if (!n.ok) return {
|
|
509
|
-
ok: !1,
|
|
510
|
-
response: n.response
|
|
511
|
-
};
|
|
512
|
-
let r = Z(n.text);
|
|
513
|
-
i = r.__elur_js_action_name, a = r.__elur_js_action_page;
|
|
514
|
-
let s = {};
|
|
515
|
-
for (let [e, t] of Object.entries(r)) e !== "__elur_js_action_name" && e !== "__elur_js_action_page" && (s[e] = t);
|
|
516
|
-
o = [s];
|
|
517
|
-
}
|
|
518
|
-
return !i || typeof i != "string" ? {
|
|
519
|
-
ok: !1,
|
|
520
|
-
response: new Response("Missing action name", {
|
|
521
|
-
status: 400,
|
|
522
|
-
headers: { "Content-Type": "text/plain" }
|
|
523
|
-
})
|
|
524
|
-
} : {
|
|
525
|
-
ok: !0,
|
|
526
|
-
name: i,
|
|
527
|
-
page: a,
|
|
528
|
-
args: o,
|
|
529
|
-
wantsJson: r
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
async function $(r, i, a = {}) {
|
|
533
|
-
let o = q(r, a);
|
|
534
|
-
if (o) return J(o);
|
|
535
|
-
let s = await Q(r, a.bodyLimit ?? Y);
|
|
536
|
-
if (!s.ok) return s.response;
|
|
537
|
-
let { name: c, page: l, args: u, wantsJson: d } = s;
|
|
538
|
-
try {
|
|
539
|
-
let n = await i(c, l);
|
|
540
|
-
if (!n) {
|
|
541
|
-
let e = l ? `Action not found: ${c} (page: ${l})` : `Action not found: ${c}`;
|
|
542
|
-
return new Response(e, {
|
|
543
|
-
status: 404,
|
|
544
|
-
headers: { "Content-Type": "text/plain" }
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
let a = await n(...u);
|
|
548
|
-
if (e(a)) {
|
|
549
|
-
if (d) return new Response(JSON.stringify({
|
|
550
|
-
__elur_js_action_failure: !0,
|
|
551
|
-
status: a.status,
|
|
552
|
-
data: a.data
|
|
553
|
-
}), {
|
|
554
|
-
status: a.status,
|
|
555
|
-
headers: { "Content-Type": "application/json" }
|
|
556
|
-
});
|
|
557
|
-
let e = r.headers.get("Referer") ?? "/", t = new URL(e, "http://localhost"), { value: n } = D(a.data, a.status);
|
|
558
|
-
return new Response(null, {
|
|
559
|
-
status: 303,
|
|
560
|
-
headers: {
|
|
561
|
-
Location: t.pathname + t.search,
|
|
562
|
-
"Content-Type": "text/plain",
|
|
563
|
-
"Set-Cookie": j(n)
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
if (t(a)) return d ? new Response(JSON.stringify({
|
|
568
|
-
__elur_js_action_redirect: !0,
|
|
569
|
-
status: a.status,
|
|
570
|
-
location: a.location
|
|
571
|
-
}), {
|
|
572
|
-
status: 200,
|
|
573
|
-
headers: { "Content-Type": "application/json" }
|
|
574
|
-
}) : new Response(null, {
|
|
575
|
-
status: a.status,
|
|
576
|
-
headers: {
|
|
577
|
-
Location: a.location,
|
|
578
|
-
"Content-Type": "text/plain"
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
if (d) return new Response(JSON.stringify(a ?? null), {
|
|
582
|
-
status: 200,
|
|
583
|
-
headers: { "Content-Type": "application/json" }
|
|
584
|
-
});
|
|
585
|
-
let o = r.headers.get("Referer") ?? "/";
|
|
586
|
-
return new Response(null, {
|
|
587
|
-
status: 303,
|
|
588
|
-
headers: {
|
|
589
|
-
Location: typeof a == "string" ? a : o,
|
|
590
|
-
"Content-Type": "text/plain"
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
} catch (e) {
|
|
594
|
-
return console.error("[elur-kit] Action error:", e), n(e, { includeDetail: !1 });
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
//#endregion
|
|
598
|
-
//#region src/runtime/node-http.ts
|
|
599
|
-
var ee = globalThis.AbortController ?? AbortController;
|
|
600
|
-
function te(e, t) {
|
|
601
|
-
let n = new Headers();
|
|
602
|
-
for (let t = 0; t < e.rawHeaders.length; t += 2) n.append(e.rawHeaders[t], e.rawHeaders[t + 1]);
|
|
603
|
-
let r = new ee();
|
|
604
|
-
e.once("aborted", () => r.abort()), e.once("close", () => {
|
|
605
|
-
e.complete || r.abort();
|
|
606
|
-
});
|
|
607
|
-
let i = e.socket.encrypted ? "https" : "http", a = {
|
|
608
|
-
method: e.method ?? "GET",
|
|
609
|
-
headers: n,
|
|
610
|
-
signal: r.signal
|
|
611
|
-
};
|
|
612
|
-
return t != null && a.method !== "GET" && a.method !== "HEAD" && (a.body = t), new Request(`${i}://${n.get("host") ?? "localhost"}${e.url ?? "/"}`, a);
|
|
613
|
-
}
|
|
614
|
-
//#endregion
|
|
615
|
-
export { _, H as a, B as c, k as d, A as f, g, j as h, q as i, L as l, D as m, $ as n, V as o, O as p, J as r, I as s, te as t, P as u, f as v, d as y };
|
|
616
|
-
|
|
617
|
-
//# sourceMappingURL=node-http-DRAUhO0c.js.map
|