@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,905 @@
|
|
|
1
|
+
import { C as e, S as t, T as n, a as r, f as i, i as a, l as o, o as s, p as c, u as l } from "./node-http-DVFcYeBS.js";
|
|
2
|
+
import { n as u, o as d } from "./invalidation-DXhdE9wj.js";
|
|
3
|
+
import { t as f } from "./scan-CjMUgnsd.js";
|
|
4
|
+
import { n as p, t as m } from "./stream-D-ytogdu.js";
|
|
5
|
+
import { o as h, t as g } from "./capabilities-C7txofmY.js";
|
|
6
|
+
import { s as _ } from "./errors-j4cg9VN3.js";
|
|
7
|
+
import { n as v, r as y } from "./adapter-DNsjXvq5.js";
|
|
8
|
+
import { readFile as b, realpath as x, stat as S } from "node:fs/promises";
|
|
9
|
+
import { extname as ee, resolve as C, sep as w } from "node:path";
|
|
10
|
+
import { createHash as T, randomUUID as E } from "node:crypto";
|
|
11
|
+
import { AsyncLocalStorage as D } from "node:async_hooks";
|
|
12
|
+
//#region src/middleware/stream-boundary.ts
|
|
13
|
+
var O = new D();
|
|
14
|
+
function k(e, t) {
|
|
15
|
+
return `<template id="${e}-tpl">${t}</template><script>(function(){var t=document.getElementById(${JSON.stringify(e + "-tpl")});var f=document.getElementById(${JSON.stringify(e)});if(t&&f){f.replaceWith(t.content.cloneNode(true));}document.dispatchEvent(new CustomEvent("elur:rendered"));})();<\/script>`;
|
|
16
|
+
}
|
|
17
|
+
function A(e) {
|
|
18
|
+
let t = `elur-stream-${E().slice(0, 8)}`, n = O.getStore();
|
|
19
|
+
return n && n.boundaries.set(t, {
|
|
20
|
+
promise: e.promise,
|
|
21
|
+
children: e.children
|
|
22
|
+
}), {
|
|
23
|
+
__isElurTemplate: !0,
|
|
24
|
+
mount(n) {
|
|
25
|
+
let r = typeof n == "string" ? document.querySelector(n) : n;
|
|
26
|
+
if (!r) throw Error("[elur-kit] streamBoundary(): container not found");
|
|
27
|
+
let i = e.fallback.mount(r);
|
|
28
|
+
return e.promise.then((t) => {
|
|
29
|
+
let n = e.children(t);
|
|
30
|
+
r.innerHTML = "";
|
|
31
|
+
let a = n.mount(r);
|
|
32
|
+
i.__elurChildHandle = a;
|
|
33
|
+
}).catch((e) => {
|
|
34
|
+
console.error(`[elur-kit] streamBoundary ${t} failed:`, e);
|
|
35
|
+
}), { unmount() {
|
|
36
|
+
let e = i.__elurChildHandle;
|
|
37
|
+
e?.unmount && e.unmount(), i.unmount();
|
|
38
|
+
} };
|
|
39
|
+
},
|
|
40
|
+
_render(n, r) {
|
|
41
|
+
let i = e.fallback._render(n, r);
|
|
42
|
+
return e.promise.then((e) => {}).catch((e) => {
|
|
43
|
+
console.error(`[elur-kit] streamBoundary ${t} failed:`, e);
|
|
44
|
+
}), i;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/ssr/stream-response.ts
|
|
50
|
+
var j = {
|
|
51
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
52
|
+
"X-Accel-Buffering": "no",
|
|
53
|
+
"Cache-Control": "no-store"
|
|
54
|
+
};
|
|
55
|
+
function M() {
|
|
56
|
+
return "<div role=\"alert\" style=\"margin:2rem auto;max-width:32rem;padding:1rem 1.25rem;border:1px solid #e5484d;border-radius:8px;color:#b3373c;font-family:system-ui,sans-serif\"><strong style=\"display:block;margin-bottom:.25rem\">No se pudo cargar el contenido.</strong><span>Recarga la página para intentarlo de nuevo.</span></div>";
|
|
57
|
+
}
|
|
58
|
+
async function te(r) {
|
|
59
|
+
let { route: i, params: a, searchParams: o, config: s, actions: l, importer: u = P, request: d, signal: f } = r;
|
|
60
|
+
if (!i.loadingPath) {
|
|
61
|
+
let e = await c({
|
|
62
|
+
route: i,
|
|
63
|
+
params: a,
|
|
64
|
+
searchParams: o,
|
|
65
|
+
config: s,
|
|
66
|
+
actions: l,
|
|
67
|
+
importer: u,
|
|
68
|
+
request: d
|
|
69
|
+
});
|
|
70
|
+
return e.response ? e.response : new Response(e.html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
|
71
|
+
}
|
|
72
|
+
if (f?.aborted) return new Response("Client Closed Request", { status: 499 });
|
|
73
|
+
let p = await u(i.loadingPath), m = await n(p.default), h = `elur-stream-${E().slice(0, 8)}`, g = s.router, _ = g?.enabled !== !1, v = g?.entry && _ && s.js !== "legacy" ? g.entry : void 0, y = t({
|
|
74
|
+
title: "Loading...",
|
|
75
|
+
lang: s.lang,
|
|
76
|
+
body: `<div id="${h}">${m}</div>`,
|
|
77
|
+
data: {
|
|
78
|
+
__elur_js_streaming: !0,
|
|
79
|
+
page: i.path
|
|
80
|
+
},
|
|
81
|
+
actions: l,
|
|
82
|
+
clientEntry: s.clientEntry,
|
|
83
|
+
routerEntry: v,
|
|
84
|
+
routerEnabled: g ? _ : void 0,
|
|
85
|
+
renderEndpoint: s.renderEndpoint
|
|
86
|
+
}), b = !1, x = new ReadableStream({
|
|
87
|
+
async start(t) {
|
|
88
|
+
let n = new TextEncoder(), r = () => {
|
|
89
|
+
b = !0;
|
|
90
|
+
try {
|
|
91
|
+
t.close();
|
|
92
|
+
} catch {}
|
|
93
|
+
};
|
|
94
|
+
f?.addEventListener("abort", r, { once: !0 });
|
|
95
|
+
let p = (e) => {
|
|
96
|
+
b || t.enqueue(n.encode(e));
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
p(y);
|
|
100
|
+
let t = await c({
|
|
101
|
+
route: i,
|
|
102
|
+
params: a,
|
|
103
|
+
searchParams: o,
|
|
104
|
+
config: s,
|
|
105
|
+
actions: l,
|
|
106
|
+
importer: u,
|
|
107
|
+
request: d
|
|
108
|
+
});
|
|
109
|
+
if (b) return;
|
|
110
|
+
if (t.response) {
|
|
111
|
+
let e = t.response.status, n = t.response.headers.get("Location");
|
|
112
|
+
p(n && (e === 301 || e === 302 || e === 307 || e === 308) ? `<script>window.location.href=${JSON.stringify(n)};<\/script>` : k(h, M()) + `<script>console.error(${JSON.stringify(`Loader responded with status ${e}`)});<\/script>`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let n = e(t.html) ?? t.html.match(/<div id="app">([\s\S]*)<\/div>\s*(<script|$)/)?.[1]?.trim() ?? t.html;
|
|
116
|
+
p(k(h, n));
|
|
117
|
+
} catch (e) {
|
|
118
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
119
|
+
p(k(h, M()) + `<script>console.error(${JSON.stringify(t)});<\/script>`);
|
|
120
|
+
} finally {
|
|
121
|
+
f?.removeEventListener("abort", r), b || t.close();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
cancel() {
|
|
125
|
+
b = !0;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return new Response(x, { headers: j });
|
|
129
|
+
}
|
|
130
|
+
async function N(e) {
|
|
131
|
+
let { route: t, params: n, searchParams: r, config: i, actions: a, importer: o = P, request: s } = e, l = await c({
|
|
132
|
+
route: t,
|
|
133
|
+
params: n,
|
|
134
|
+
searchParams: r,
|
|
135
|
+
config: i,
|
|
136
|
+
actions: a,
|
|
137
|
+
importer: o,
|
|
138
|
+
request: s
|
|
139
|
+
});
|
|
140
|
+
return l.response ? l.response : new Response(l.html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
|
141
|
+
}
|
|
142
|
+
var P = (e) => import(e);
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/runtime/static.ts
|
|
145
|
+
function F(e, t) {
|
|
146
|
+
return t === e || t.startsWith(`${e}${w}`);
|
|
147
|
+
}
|
|
148
|
+
function I(e) {
|
|
149
|
+
try {
|
|
150
|
+
let t = decodeURIComponent(e);
|
|
151
|
+
return t.includes("\0") || t.includes("\\") || /%(?:00|2e|2f|5c)/i.test(t) || t.split("/").some((e) => e === "..") ? null : t;
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async function L(e, t) {
|
|
157
|
+
let n = I(t);
|
|
158
|
+
if (n === null) return null;
|
|
159
|
+
let r = C(e), i = n.replace(/^\/+/, ""), a = C(r, i);
|
|
160
|
+
if (!F(r, a)) return null;
|
|
161
|
+
try {
|
|
162
|
+
(await S(a)).isDirectory() && (a = C(a, "index.html"));
|
|
163
|
+
} catch {
|
|
164
|
+
(n.endsWith("/") || ee(n) === "") && (a = C(a, "index.html"));
|
|
165
|
+
}
|
|
166
|
+
if (!F(r, a)) return null;
|
|
167
|
+
try {
|
|
168
|
+
let [e, t, n] = await Promise.all([
|
|
169
|
+
x(r),
|
|
170
|
+
x(a),
|
|
171
|
+
S(a)
|
|
172
|
+
]);
|
|
173
|
+
return !n.isFile() || !F(e, t) ? null : t;
|
|
174
|
+
} catch {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/runtime/context.ts
|
|
180
|
+
var R = class {
|
|
181
|
+
cookies;
|
|
182
|
+
constructor(e) {
|
|
183
|
+
this.cookies = re(e.headers.get("Cookie") ?? "");
|
|
184
|
+
}
|
|
185
|
+
get(e) {
|
|
186
|
+
return this.cookies[e];
|
|
187
|
+
}
|
|
188
|
+
getAll() {
|
|
189
|
+
return { ...this.cookies };
|
|
190
|
+
}
|
|
191
|
+
has(e) {
|
|
192
|
+
return e in this.cookies;
|
|
193
|
+
}
|
|
194
|
+
}, ne = class {
|
|
195
|
+
entries = [];
|
|
196
|
+
set(e, t, n = {}) {
|
|
197
|
+
this.entries.push(z(e, t, n));
|
|
198
|
+
}
|
|
199
|
+
clear(e, t = {}) {
|
|
200
|
+
this.entries.push(z(e, "", {
|
|
201
|
+
...t,
|
|
202
|
+
maxAge: 0,
|
|
203
|
+
expires: /* @__PURE__ */ new Date(0)
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
getAll() {
|
|
207
|
+
return [...this.entries];
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
function re(e) {
|
|
211
|
+
let t = {};
|
|
212
|
+
if (!e) return t;
|
|
213
|
+
for (let n of e.split(";")) {
|
|
214
|
+
let e = n.indexOf("=");
|
|
215
|
+
if (e === -1) continue;
|
|
216
|
+
let r = n.slice(0, e).trim();
|
|
217
|
+
t[r] = n.slice(e + 1).trim();
|
|
218
|
+
}
|
|
219
|
+
return t;
|
|
220
|
+
}
|
|
221
|
+
function z(e, t, n) {
|
|
222
|
+
let r = [`${e}=${t}`];
|
|
223
|
+
return n.httpOnly && r.push("HttpOnly"), n.secure && r.push("Secure"), n.sameSite && r.push(`SameSite=${n.sameSite}`), n.maxAge !== void 0 && r.push(`Max-Age=${n.maxAge}`), n.expires && r.push(`Expires=${n.expires.toUTCString()}`), n.path && r.push(`Path=${n.path}`), n.domain && r.push(`Domain=${n.domain}`), r.join("; ");
|
|
224
|
+
}
|
|
225
|
+
var ie = class {
|
|
226
|
+
request;
|
|
227
|
+
url;
|
|
228
|
+
config;
|
|
229
|
+
routes;
|
|
230
|
+
actions;
|
|
231
|
+
publicActions;
|
|
232
|
+
importer;
|
|
233
|
+
renderEndpoint;
|
|
234
|
+
noCache;
|
|
235
|
+
cacheDir;
|
|
236
|
+
defaultRevalidate;
|
|
237
|
+
params;
|
|
238
|
+
locals;
|
|
239
|
+
cookies;
|
|
240
|
+
signal;
|
|
241
|
+
requestId;
|
|
242
|
+
platform;
|
|
243
|
+
route;
|
|
244
|
+
response;
|
|
245
|
+
constructor(e) {
|
|
246
|
+
this.request = e.request, this.url = new URL(e.request.url), this.config = e.config, this.routes = e.routes, this.actions = e.actions, this.publicActions = e.publicActions, this.importer = e.importer, this.renderEndpoint = e.renderEndpoint ?? !0, this.noCache = e.noCache ?? !1, this.cacheDir = e.cacheDir, this.defaultRevalidate = e.defaultRevalidate, this.params = e.params ?? {}, this.locals = e.locals ?? {}, this.cookies = new R(e.request), this.signal = e.signal ?? new AbortController().signal, this.requestId = e.requestId ?? E(), this.platform = e.platform, this.route = e.route, this.response = {
|
|
247
|
+
status: void 0,
|
|
248
|
+
headers: new Headers(),
|
|
249
|
+
cookies: new ne()
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
get pathname() {
|
|
253
|
+
return this.url.pathname;
|
|
254
|
+
}
|
|
255
|
+
get method() {
|
|
256
|
+
return (this.request.method ?? "GET").toUpperCase();
|
|
257
|
+
}
|
|
258
|
+
get wantsJson() {
|
|
259
|
+
return (this.request.headers.get("Accept") ?? "").includes("application/json");
|
|
260
|
+
}
|
|
261
|
+
get searchParams() {
|
|
262
|
+
return this.url.searchParams;
|
|
263
|
+
}
|
|
264
|
+
get renderConfig() {
|
|
265
|
+
return {
|
|
266
|
+
lang: void 0,
|
|
267
|
+
clientEntry: void 0,
|
|
268
|
+
renderEndpoint: this.renderEndpoint
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
applyToResponse(e) {
|
|
272
|
+
let t = new Headers(e.headers);
|
|
273
|
+
for (let [e, n] of this.response.headers.entries()) t.set(e, n);
|
|
274
|
+
for (let e of this.response.cookies.getAll()) t.append("Set-Cookie", e);
|
|
275
|
+
let n = this.response.status ?? e.status;
|
|
276
|
+
return new Response(e.body, {
|
|
277
|
+
status: n,
|
|
278
|
+
statusText: e.statusText,
|
|
279
|
+
headers: t
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
function B(e, t = 200, n) {
|
|
284
|
+
return new Response(e, {
|
|
285
|
+
status: t,
|
|
286
|
+
headers: {
|
|
287
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
288
|
+
...n
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function V(e, t = 200, n) {
|
|
293
|
+
return new Response(JSON.stringify(e), {
|
|
294
|
+
status: t,
|
|
295
|
+
headers: {
|
|
296
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
297
|
+
...n
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function H(e, t = 200, n) {
|
|
302
|
+
return new Response(e, {
|
|
303
|
+
status: t,
|
|
304
|
+
headers: {
|
|
305
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
306
|
+
...n
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function U(e = "Not Found") {
|
|
311
|
+
return H(e, 404);
|
|
312
|
+
}
|
|
313
|
+
function W(e) {
|
|
314
|
+
return H(`Method not allowed: ${e}`, 405);
|
|
315
|
+
}
|
|
316
|
+
function ae(e) {
|
|
317
|
+
return H(e, 500);
|
|
318
|
+
}
|
|
319
|
+
function G(e) {
|
|
320
|
+
switch (e.slice(e.lastIndexOf(".") + 1).toLowerCase()) {
|
|
321
|
+
case "html": return "text/html; charset=utf-8";
|
|
322
|
+
case "js": return "application/javascript; charset=utf-8";
|
|
323
|
+
case "mjs": return "application/javascript; charset=utf-8";
|
|
324
|
+
case "css": return "text/css; charset=utf-8";
|
|
325
|
+
case "json": return "application/json; charset=utf-8";
|
|
326
|
+
case "svg": return "image/svg+xml";
|
|
327
|
+
case "png": return "image/png";
|
|
328
|
+
case "jpg":
|
|
329
|
+
case "jpeg": return "image/jpeg";
|
|
330
|
+
case "webp": return "image/webp";
|
|
331
|
+
case "avif": return "image/avif";
|
|
332
|
+
case "ico": return "image/x-icon";
|
|
333
|
+
case "woff": return "font/woff";
|
|
334
|
+
case "woff2": return "font/woff2";
|
|
335
|
+
case "wasm": return "application/wasm";
|
|
336
|
+
case "txt": return "text/plain; charset=utf-8";
|
|
337
|
+
default: return "application/octet-stream";
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
async function K(e, t, n) {
|
|
341
|
+
let r = await L(e, t);
|
|
342
|
+
if (!r) return null;
|
|
343
|
+
try {
|
|
344
|
+
let [e, t] = await Promise.all([b(r), S(r)]), i = G(r), a = `"${T("sha1").update(e).digest("hex").slice(0, 16)}"`, o = t.mtime.toUTCString(), s = n?.method === "HEAD", c = e.byteLength, l = {
|
|
345
|
+
"Content-Type": i,
|
|
346
|
+
"Content-Length": String(c),
|
|
347
|
+
ETag: a,
|
|
348
|
+
"Last-Modified": o,
|
|
349
|
+
"Accept-Ranges": "bytes"
|
|
350
|
+
}, u = r.split("/").pop() ?? "";
|
|
351
|
+
l["Cache-Control"] = /[a-f0-9]{8,}\.(js|css|woff2?|wasm|png|jpg|jpeg|webp|avif|svg)$/i.test(u) ? "public, max-age=31536000, immutable" : "public, max-age=0, must-revalidate";
|
|
352
|
+
let d = n?.headers.get("If-None-Match");
|
|
353
|
+
if (d && oe(d, a)) return new Response(null, {
|
|
354
|
+
status: 304,
|
|
355
|
+
headers: l
|
|
356
|
+
});
|
|
357
|
+
let f = n?.headers.get("If-Modified-Since");
|
|
358
|
+
if (f) {
|
|
359
|
+
let e = Date.parse(f);
|
|
360
|
+
if (!isNaN(e) && Math.floor(t.mtime.getTime() / 1e3) <= Math.floor(e / 1e3)) return new Response(null, {
|
|
361
|
+
status: 304,
|
|
362
|
+
headers: l
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
let p = n?.headers.get("Range"), m = n?.headers.get("If-Range");
|
|
366
|
+
if (p && (!m || se(m, a, t.mtime))) {
|
|
367
|
+
let t = ce(p, c);
|
|
368
|
+
if (t === null) return new Response(null, {
|
|
369
|
+
status: 416,
|
|
370
|
+
headers: {
|
|
371
|
+
...l,
|
|
372
|
+
"Content-Range": `bytes */${c}`
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
if (t) {
|
|
376
|
+
let [n, r] = t, i = e.subarray(n, r + 1), a = {
|
|
377
|
+
...l,
|
|
378
|
+
"Content-Length": String(i.byteLength),
|
|
379
|
+
"Content-Range": `bytes ${n}-${r}/${c}`
|
|
380
|
+
};
|
|
381
|
+
return s ? new Response(null, {
|
|
382
|
+
status: 206,
|
|
383
|
+
headers: a
|
|
384
|
+
}) : new Response(i, {
|
|
385
|
+
status: 206,
|
|
386
|
+
headers: a
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return s ? new Response(null, {
|
|
391
|
+
status: 200,
|
|
392
|
+
headers: l
|
|
393
|
+
}) : new Response(e, {
|
|
394
|
+
status: 200,
|
|
395
|
+
headers: l
|
|
396
|
+
});
|
|
397
|
+
} catch {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function oe(e, t) {
|
|
402
|
+
return e.split(",").map((e) => e.trim()).some((e) => e === "*" || e === t);
|
|
403
|
+
}
|
|
404
|
+
function se(e, t, n) {
|
|
405
|
+
if (e.startsWith("\"") || e.startsWith("W/")) return e === t;
|
|
406
|
+
let r = Date.parse(e);
|
|
407
|
+
return !isNaN(r) && Math.floor(n.getTime() / 1e3) <= Math.floor(r / 1e3);
|
|
408
|
+
}
|
|
409
|
+
function ce(e, t) {
|
|
410
|
+
let n = /^bytes=(\d*)-(\d*)$/.exec(e.trim());
|
|
411
|
+
if (!n) return null;
|
|
412
|
+
let r = n[1], i = n[2];
|
|
413
|
+
if (r === "" && i === "") return null;
|
|
414
|
+
if (r === "") {
|
|
415
|
+
let e = Number(i);
|
|
416
|
+
if (!Number.isSafeInteger(e) || e <= 0) return null;
|
|
417
|
+
let n = Math.max(0, t - e);
|
|
418
|
+
return t === 0 ? void 0 : [n, t - 1];
|
|
419
|
+
}
|
|
420
|
+
let a = Number(r);
|
|
421
|
+
if (!Number.isSafeInteger(a) || a < 0 || a >= t) return null;
|
|
422
|
+
let o = i === "" ? t - 1 : Number(i);
|
|
423
|
+
return !Number.isSafeInteger(o) || o < a ? null : [a, Math.min(o, t - 1)];
|
|
424
|
+
}
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/runtime/security-headers.ts
|
|
427
|
+
var q = {
|
|
428
|
+
noSniff: !0,
|
|
429
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
430
|
+
frameAncestors: "SAMEORIGIN"
|
|
431
|
+
};
|
|
432
|
+
function J(e, t, n) {
|
|
433
|
+
if (e === !1) return {};
|
|
434
|
+
let r = {}, i = {
|
|
435
|
+
...q,
|
|
436
|
+
...e
|
|
437
|
+
};
|
|
438
|
+
if (i.noSniff && (r["X-Content-Type-Options"] = "nosniff"), i.referrerPolicy && (r["Referrer-Policy"] = i.referrerPolicy), i.contentSecurityPolicy) {
|
|
439
|
+
let e = i.contentSecurityPolicy;
|
|
440
|
+
n && (e = e.replace(/\bnonce\b/g, `'nonce-${n}'`)), r["Content-Security-Policy"] = e;
|
|
441
|
+
} else if (i.frameAncestors) {
|
|
442
|
+
let e = i.frameAncestors;
|
|
443
|
+
r["X-Frame-Options"] = e === "NONE" ? "DENY" : e === "SAMEORIGIN" ? "SAMEORIGIN" : e;
|
|
444
|
+
}
|
|
445
|
+
return i.hsts === !0 && t ? r["Strict-Transport-Security"] = "max-age=15552000; includeSubDomains" : typeof i.hsts == "string" && (r["Strict-Transport-Security"] = i.hsts), i.permissionsPolicy && (r["Permissions-Policy"] = i.permissionsPolicy), r;
|
|
446
|
+
}
|
|
447
|
+
function Y(e, t) {
|
|
448
|
+
if (Object.keys(t).length === 0) return e;
|
|
449
|
+
let n = new Headers(e.headers);
|
|
450
|
+
for (let [e, r] of Object.entries(t)) n.has(e) || n.set(e, r);
|
|
451
|
+
return new Response(e.body, {
|
|
452
|
+
status: e.status,
|
|
453
|
+
statusText: e.statusText,
|
|
454
|
+
headers: n
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/runtime/logger.ts
|
|
459
|
+
var X = {
|
|
460
|
+
debug: 10,
|
|
461
|
+
info: 20,
|
|
462
|
+
warn: 30,
|
|
463
|
+
error: 40
|
|
464
|
+
}, le = /* @__PURE__ */ new Set([
|
|
465
|
+
"cookie",
|
|
466
|
+
"authorization",
|
|
467
|
+
"set-cookie",
|
|
468
|
+
"x-api-key",
|
|
469
|
+
"x-auth-token"
|
|
470
|
+
]), ue = class {
|
|
471
|
+
minLevel;
|
|
472
|
+
requestId;
|
|
473
|
+
timings = [];
|
|
474
|
+
entries = [];
|
|
475
|
+
constructor(e = {}) {
|
|
476
|
+
this.minLevel = e.minLevel ?? (process.env.NODE_ENV === "production" ? "info" : "debug"), this.requestId = e.requestId ?? E();
|
|
477
|
+
}
|
|
478
|
+
getRequestId() {
|
|
479
|
+
return this.requestId;
|
|
480
|
+
}
|
|
481
|
+
debug(e, t) {
|
|
482
|
+
this.log("debug", e, t);
|
|
483
|
+
}
|
|
484
|
+
info(e, t) {
|
|
485
|
+
this.log("info", e, t);
|
|
486
|
+
}
|
|
487
|
+
warn(e, t) {
|
|
488
|
+
this.log("warn", e, t);
|
|
489
|
+
}
|
|
490
|
+
error(e, t) {
|
|
491
|
+
this.log("error", e, t);
|
|
492
|
+
}
|
|
493
|
+
timing(e, t, n) {
|
|
494
|
+
this.timings.push({
|
|
495
|
+
name: e,
|
|
496
|
+
durationMs: t,
|
|
497
|
+
description: n
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
startTimer(e, t) {
|
|
501
|
+
let n = performance.now();
|
|
502
|
+
return () => {
|
|
503
|
+
this.timing(e, performance.now() - n, t);
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
getServerTimingHeader() {
|
|
507
|
+
return this.timings.map((e) => {
|
|
508
|
+
let t = e.description ? `;desc="${e.description}"` : "";
|
|
509
|
+
return `${e.name};dur=${e.durationMs.toFixed(1)}${t}`;
|
|
510
|
+
}).join(", ");
|
|
511
|
+
}
|
|
512
|
+
getEntries() {
|
|
513
|
+
return this.entries;
|
|
514
|
+
}
|
|
515
|
+
log(e, t, n) {
|
|
516
|
+
if (X[e] < X[this.minLevel]) return;
|
|
517
|
+
let r = {
|
|
518
|
+
level: e,
|
|
519
|
+
message: t,
|
|
520
|
+
requestId: this.requestId,
|
|
521
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
522
|
+
fields: n ? de(n) : void 0
|
|
523
|
+
};
|
|
524
|
+
if (this.entries.push(r), process.env.NODE_ENV === "production") {
|
|
525
|
+
let t = JSON.stringify(r);
|
|
526
|
+
e === "error" ? console.error(t) : e === "warn" ? console.warn(t) : console.log(t);
|
|
527
|
+
} else {
|
|
528
|
+
let n = `${`[${e.toUpperCase()}]`} ${t}${r.fields ? " " + JSON.stringify(r.fields) : ""}`;
|
|
529
|
+
e === "error" ? console.error(n) : e === "warn" ? console.warn(n) : console.log(n);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
function de(e) {
|
|
534
|
+
let t = {};
|
|
535
|
+
for (let [n, r] of Object.entries(e)) {
|
|
536
|
+
let e = n.toLowerCase();
|
|
537
|
+
t[n] = le.has(e) ? "[REDACTED]" : typeof r == "object" && r && !Array.isArray(r) ? de(r) : r;
|
|
538
|
+
}
|
|
539
|
+
return t;
|
|
540
|
+
}
|
|
541
|
+
function fe(e, t) {
|
|
542
|
+
return new ue({
|
|
543
|
+
minLevel: t,
|
|
544
|
+
requestId: e?.headers.get("X-Request-ID") ?? void 0
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/router/redirects.ts
|
|
549
|
+
function pe(e, t) {
|
|
550
|
+
for (let n of t) {
|
|
551
|
+
let t = Z(e, n.from);
|
|
552
|
+
if (t) {
|
|
553
|
+
let e = ge(n.to, t), r = n.status ?? 308;
|
|
554
|
+
return new Response(null, {
|
|
555
|
+
status: r,
|
|
556
|
+
headers: { Location: e }
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function me(e, t) {
|
|
562
|
+
for (let n of t) {
|
|
563
|
+
let t = Z(e, n.from);
|
|
564
|
+
if (t) return ge(n.to, t);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
function he(e, t) {
|
|
568
|
+
for (let n of t) if (Z(e, n.path)) return n.headers;
|
|
569
|
+
}
|
|
570
|
+
function Z(e, t) {
|
|
571
|
+
let n = e.split("?")[0].split("/").filter(Boolean), r = t.split("/").filter(Boolean), i = {}, a = 0;
|
|
572
|
+
for (let e = 0; e < r.length; e++) {
|
|
573
|
+
let t = r[e];
|
|
574
|
+
if (t === "*") return i;
|
|
575
|
+
if (t.endsWith("*")) {
|
|
576
|
+
let e = t.slice(1, -1);
|
|
577
|
+
return i[e] = n.slice(a).join("/"), i;
|
|
578
|
+
}
|
|
579
|
+
if (t.startsWith(":")) {
|
|
580
|
+
let e = t.slice(1);
|
|
581
|
+
if (n[a] === void 0) return;
|
|
582
|
+
i[e] = n[a], a++;
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (t !== n[a]) return;
|
|
586
|
+
a++;
|
|
587
|
+
}
|
|
588
|
+
if (a === n.length) return i;
|
|
589
|
+
}
|
|
590
|
+
function ge(e, t) {
|
|
591
|
+
return e.replace(/:(\w+)\*?/g, (e, n) => t[n] ?? "");
|
|
592
|
+
}
|
|
593
|
+
//#endregion
|
|
594
|
+
//#region src/runtime/handler.ts
|
|
595
|
+
function _e(e, t, n) {
|
|
596
|
+
let d = f(t), y = n.lang ?? "es", b = n.clientEntry, x = n.renderEndpoint ?? !0, S = n.noCache ?? !1, ee = n.defaultRevalidate, C = {
|
|
597
|
+
lang: y,
|
|
598
|
+
clientEntry: b,
|
|
599
|
+
renderEndpoint: x,
|
|
600
|
+
router: n.router ? {
|
|
601
|
+
enabled: n.router.enabled !== !1,
|
|
602
|
+
entry: n.router.entry
|
|
603
|
+
} : void 0,
|
|
604
|
+
js: n.js
|
|
605
|
+
}, w = n.securityHeaders ?? {}, T = n.redirects ?? [], E = n.rewrites ?? [], D = n.routeHeaders ?? [], O = n.capabilities ?? g, k = n.streaming === !0 && h(O), A = be(n);
|
|
606
|
+
A && !ye.has(A) && (ye.add(A), u(A));
|
|
607
|
+
function j() {
|
|
608
|
+
return async (r, i) => {
|
|
609
|
+
let a = i ? e.pages.some((e) => e.path === i) ? i : l(i, e.pages)?.route.path ?? i : void 0, o = a ? t[a] : Object.values(t).find((e) => e[r]) ?? void 0, s = o ? o[r] : void 0;
|
|
610
|
+
if (!s) return;
|
|
611
|
+
if (n.importer) {
|
|
612
|
+
let e = (await n.importer(s))[r];
|
|
613
|
+
return typeof e == "function" ? e : void 0;
|
|
614
|
+
}
|
|
615
|
+
let c = (await import(s))[r];
|
|
616
|
+
if (typeof c == "function") return c;
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
let M = j();
|
|
620
|
+
async function N(e, t) {
|
|
621
|
+
let n = t.startTimer("action", "Server action");
|
|
622
|
+
try {
|
|
623
|
+
return await s(e, M);
|
|
624
|
+
} catch (n) {
|
|
625
|
+
return t.error("[elur-kit] action error", {
|
|
626
|
+
path: new URL(e.url).pathname,
|
|
627
|
+
method: e.method,
|
|
628
|
+
error: Q(n),
|
|
629
|
+
stack: $(n)
|
|
630
|
+
}), _(n, { includeDetail: S });
|
|
631
|
+
} finally {
|
|
632
|
+
n();
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
async function P(t, r, i) {
|
|
636
|
+
let a = r.searchParams.get("page") ?? "/", o = r.searchParams.get("search") ?? "", s = (t.headers.get("Accept") ?? "").includes("application/json"), c = i.startTimer("render-endpoint", "SPA render endpoint");
|
|
637
|
+
try {
|
|
638
|
+
let r = await p({
|
|
639
|
+
routes: e,
|
|
640
|
+
pathname: a,
|
|
641
|
+
searchParams: new URLSearchParams(o),
|
|
642
|
+
config: C,
|
|
643
|
+
actions: d,
|
|
644
|
+
request: t,
|
|
645
|
+
importer: n.importer
|
|
646
|
+
});
|
|
647
|
+
if (r.response) return r.response;
|
|
648
|
+
let { body: i, title: c, head: l, clearActionErrorCookie: u, data: f, actions: m } = r;
|
|
649
|
+
if (s) {
|
|
650
|
+
let e = {};
|
|
651
|
+
return u && (e["X-Elur-Action-Clear-Cookie"] = u), V({
|
|
652
|
+
title: c,
|
|
653
|
+
body: i,
|
|
654
|
+
head: l ?? null,
|
|
655
|
+
data: f ?? null,
|
|
656
|
+
actions: m ?? null,
|
|
657
|
+
clearActionErrorCookie: u ?? null
|
|
658
|
+
}, 200, e);
|
|
659
|
+
}
|
|
660
|
+
return B(i, 200, u ? { "Set-Cookie": u } : void 0);
|
|
661
|
+
} catch (e) {
|
|
662
|
+
return e instanceof m ? U("Not Found") : e instanceof Response ? e : (i.error("[elur-kit] render endpoint error", {
|
|
663
|
+
path: r.pathname,
|
|
664
|
+
page: a,
|
|
665
|
+
error: Q(e),
|
|
666
|
+
stack: $(e)
|
|
667
|
+
}), _(e, { includeDetail: S }));
|
|
668
|
+
} finally {
|
|
669
|
+
c();
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
async function F(t, r, i, a) {
|
|
673
|
+
let s = o(r, e.api);
|
|
674
|
+
if (!s) return null;
|
|
675
|
+
let c = i.startTimer("api", "API route");
|
|
676
|
+
try {
|
|
677
|
+
let e;
|
|
678
|
+
e = n.importer ? await n.importer(s.route.routePath) : await import(s.route.routePath);
|
|
679
|
+
let r = e[t.method ?? "GET"];
|
|
680
|
+
return typeof r == "function" ? await r(t, {
|
|
681
|
+
params: s.params,
|
|
682
|
+
locals: a ?? {}
|
|
683
|
+
}) : W(t.method ?? "GET");
|
|
684
|
+
} catch (e) {
|
|
685
|
+
return i.error("[elur-kit] API route error", {
|
|
686
|
+
path: r,
|
|
687
|
+
method: t.method,
|
|
688
|
+
route: s.route.path,
|
|
689
|
+
error: Q(e),
|
|
690
|
+
stack: $(e)
|
|
691
|
+
}), _(e, { includeDetail: S });
|
|
692
|
+
} finally {
|
|
693
|
+
c();
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
async function I(e, t) {
|
|
697
|
+
let r = await K(n.staticRoot, e, t);
|
|
698
|
+
if (r && S) {
|
|
699
|
+
let e = r.headers.get("Content-Type") ?? "";
|
|
700
|
+
if (e.includes("text/html")) {
|
|
701
|
+
let t = (await r.text()).replace("<meta name=\"elur:render-endpoint\" content=\"off\" />", "");
|
|
702
|
+
return new Response(t, {
|
|
703
|
+
status: r.status,
|
|
704
|
+
headers: {
|
|
705
|
+
"Content-Type": e,
|
|
706
|
+
"Cache-Control": "no-store, must-revalidate"
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
return new Response(r.body, {
|
|
711
|
+
status: r.status,
|
|
712
|
+
headers: {
|
|
713
|
+
...Object.fromEntries(r.headers.entries()),
|
|
714
|
+
"Cache-Control": "no-store, must-revalidate"
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
if (r && x && (r.headers.get("Content-Type") ?? "").includes("text/html")) {
|
|
719
|
+
let e = Object.fromEntries(r.headers.entries());
|
|
720
|
+
delete e["content-length"];
|
|
721
|
+
let t = await r.text();
|
|
722
|
+
if (t.includes("elur:render-endpoint\" content=\"off\"")) {
|
|
723
|
+
let n = t.replace("<meta name=\"elur:render-endpoint\" content=\"off\" />", "<meta name=\"elur:render-endpoint\" content=\"on\" />");
|
|
724
|
+
return new Response(n, {
|
|
725
|
+
status: r.status,
|
|
726
|
+
headers: e
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
return new Response(t, {
|
|
730
|
+
status: r.status,
|
|
731
|
+
headers: e
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
return r;
|
|
735
|
+
}
|
|
736
|
+
async function L(t, r, a) {
|
|
737
|
+
let o = l(r, e.pages);
|
|
738
|
+
if (!o) {
|
|
739
|
+
let t = await i({
|
|
740
|
+
routes: e,
|
|
741
|
+
status: 404,
|
|
742
|
+
config: C,
|
|
743
|
+
actions: d,
|
|
744
|
+
importer: n.importer
|
|
745
|
+
});
|
|
746
|
+
return t ? B(t.html, t.status) : U(`Not found: ${r}`);
|
|
747
|
+
}
|
|
748
|
+
if (k && o.route.loadingPath) {
|
|
749
|
+
let s = a.startTimer("ssr", "SSR stream shell");
|
|
750
|
+
try {
|
|
751
|
+
return await te({
|
|
752
|
+
route: o.route,
|
|
753
|
+
params: o.params,
|
|
754
|
+
searchParams: new URLSearchParams(t.url.split("?")[1] ?? ""),
|
|
755
|
+
config: C,
|
|
756
|
+
actions: d,
|
|
757
|
+
importer: n.importer,
|
|
758
|
+
request: t,
|
|
759
|
+
signal: t.signal
|
|
760
|
+
});
|
|
761
|
+
} catch (t) {
|
|
762
|
+
if (t instanceof Response) return t;
|
|
763
|
+
a.error("[elur-kit] SSR stream error", {
|
|
764
|
+
path: r,
|
|
765
|
+
route: o.route.path,
|
|
766
|
+
error: Q(t),
|
|
767
|
+
stack: $(t)
|
|
768
|
+
});
|
|
769
|
+
let s = await i({
|
|
770
|
+
routes: e,
|
|
771
|
+
status: 500,
|
|
772
|
+
error: t,
|
|
773
|
+
config: C,
|
|
774
|
+
actions: d,
|
|
775
|
+
importer: n.importer
|
|
776
|
+
}).catch(() => void 0);
|
|
777
|
+
return s ? B(s.html, s.status) : _(t, { includeDetail: S });
|
|
778
|
+
} finally {
|
|
779
|
+
s();
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
let s = !S && A && xe(t), u = s ? v(r) : void 0, f = async () => {
|
|
783
|
+
let e = await c({
|
|
784
|
+
route: o.route,
|
|
785
|
+
params: o.params,
|
|
786
|
+
searchParams: new URLSearchParams(t.url.split("?")[1] ?? ""),
|
|
787
|
+
config: C,
|
|
788
|
+
actions: d,
|
|
789
|
+
request: t,
|
|
790
|
+
importer: n.importer
|
|
791
|
+
});
|
|
792
|
+
if (e.response) return e.response;
|
|
793
|
+
if (s && A && u && Se(e, t)) {
|
|
794
|
+
let t = e.revalidate ?? ee ?? 0;
|
|
795
|
+
t > 0 && await A.set(u, {
|
|
796
|
+
html: e.html,
|
|
797
|
+
generatedAt: Date.now(),
|
|
798
|
+
revalidate: t
|
|
799
|
+
}, {
|
|
800
|
+
revalidate: t,
|
|
801
|
+
tags: e.cachePolicy?.tags
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
return B(e.html);
|
|
805
|
+
};
|
|
806
|
+
if (s && A && u) {
|
|
807
|
+
let e = await A.get(u);
|
|
808
|
+
if (e) return Date.now() - e.generatedAt >= e.revalidate * 1e3 && f().catch((e) => {
|
|
809
|
+
a.error("[elur-kit] background cache revalidation failed", {
|
|
810
|
+
path: r,
|
|
811
|
+
error: Q(e),
|
|
812
|
+
stack: $(e)
|
|
813
|
+
});
|
|
814
|
+
}), B(e.html);
|
|
815
|
+
}
|
|
816
|
+
let p = a.startTimer("ssr", "SSR render");
|
|
817
|
+
try {
|
|
818
|
+
return await f();
|
|
819
|
+
} catch (t) {
|
|
820
|
+
if (t instanceof Response) return t;
|
|
821
|
+
a.error("[elur-kit] SSR render error", {
|
|
822
|
+
path: r,
|
|
823
|
+
route: o.route.path,
|
|
824
|
+
error: Q(t),
|
|
825
|
+
stack: $(t)
|
|
826
|
+
});
|
|
827
|
+
let s = await i({
|
|
828
|
+
routes: e,
|
|
829
|
+
status: 500,
|
|
830
|
+
error: t,
|
|
831
|
+
config: C,
|
|
832
|
+
actions: d,
|
|
833
|
+
importer: n.importer
|
|
834
|
+
}).catch(() => void 0);
|
|
835
|
+
return s ? B(s.html, s.status) : _(t, { includeDetail: S });
|
|
836
|
+
} finally {
|
|
837
|
+
p();
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
function R(e, t, n, r) {
|
|
841
|
+
let i = Y(e, n), a = new Headers(i.headers);
|
|
842
|
+
if (r) for (let [e, t] of Object.entries(r)) a.set(e, t);
|
|
843
|
+
let o = t.getServerTimingHeader();
|
|
844
|
+
return o && a.set("Server-Timing", o), a.set("X-Request-ID", t.getRequestId()), new Response(i.body, {
|
|
845
|
+
status: i.status,
|
|
846
|
+
statusText: i.statusText,
|
|
847
|
+
headers: a
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
return async function(e) {
|
|
851
|
+
let t = fe(e, n.logLevel), i = new URL(e.url), o = i.pathname, s = i.protocol === "https:", c = w === !1 ? {} : J(w, s);
|
|
852
|
+
if (T.length > 0) {
|
|
853
|
+
let e = pe(o, T);
|
|
854
|
+
if (e) return R(e, t, c, he(o, D));
|
|
855
|
+
}
|
|
856
|
+
let l = o;
|
|
857
|
+
E.length > 0 && (l = me(o, E) ?? o);
|
|
858
|
+
let u = he(o, D);
|
|
859
|
+
if (l === "/__elur-js/actions" && e.method === "POST") return R(await N(e, t), t, c, u);
|
|
860
|
+
if (l === "/__elur-js/render" && x) return R(await P(e, i, t), t, c, u);
|
|
861
|
+
let d, f = n.middleware;
|
|
862
|
+
if (f && a(l, f.config)) {
|
|
863
|
+
let n;
|
|
864
|
+
try {
|
|
865
|
+
n = await r(f, e);
|
|
866
|
+
} catch (e) {
|
|
867
|
+
return t.error("[elur-kit] middleware error", {
|
|
868
|
+
path: l,
|
|
869
|
+
error: Q(e),
|
|
870
|
+
stack: $(e)
|
|
871
|
+
}), R(_(e, { includeDetail: S }), t, c, u);
|
|
872
|
+
}
|
|
873
|
+
if (n.kind === "response") return R(n.response, t, c, u);
|
|
874
|
+
if (d = n.locals, n.headers) {
|
|
875
|
+
let t = new Headers(e.headers);
|
|
876
|
+
for (let [e, r] of Object.entries(n.headers)) t.set(e, r);
|
|
877
|
+
e = new Request(e, { headers: t });
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return R(await F(e, l, t, d) || await I(l, e) || await L(e, l, t), t, c, u);
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
var ve = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new WeakSet();
|
|
884
|
+
function be(e) {
|
|
885
|
+
if (e.cacheAdapter) return e.cacheAdapter;
|
|
886
|
+
if (!e.cacheDir) return;
|
|
887
|
+
let t = ve.get(e.cacheDir);
|
|
888
|
+
return t || (t = y({ cacheDir: e.cacheDir }), ve.set(e.cacheDir, t)), t;
|
|
889
|
+
}
|
|
890
|
+
function Q(e) {
|
|
891
|
+
return e instanceof Error ? e.message : String(e);
|
|
892
|
+
}
|
|
893
|
+
function $(e) {
|
|
894
|
+
return e instanceof Error ? e.stack : void 0;
|
|
895
|
+
}
|
|
896
|
+
function xe(e) {
|
|
897
|
+
return !(e.method !== "GET" && e.method !== "HEAD" || e.headers.get("Cookie") || e.headers.get("Authorization"));
|
|
898
|
+
}
|
|
899
|
+
function Se(e, t) {
|
|
900
|
+
return e.html.includes("__elur_js_action_error") ? !1 : e.cachePolicy ? d(e.cachePolicy, t) : !(!e.revalidate || e.revalidate <= 0 || t.headers.get("Cookie") || t.headers.get("Authorization"));
|
|
901
|
+
}
|
|
902
|
+
//#endregion
|
|
903
|
+
export { N as _, Y as a, G as c, W as d, U as f, L as g, H as h, q as i, B as l, ae as m, ue as n, J as o, K as p, fe as r, ie as s, _e as t, V as u, te as v, A as y };
|
|
904
|
+
|
|
905
|
+
//# sourceMappingURL=runtime-OMyz5yE-.js.map
|