@elurjs/kit 2.4.4
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 +874 -0
- package/LICENSE +21 -0
- package/README.md +1330 -0
- package/bin/elur-kit.js +54 -0
- package/dist/lib/action/define.d.cts +72 -0
- package/dist/lib/action/define.d.ts +72 -0
- package/dist/lib/action/error-store.d.cts +29 -0
- package/dist/lib/action/error-store.d.ts +29 -0
- package/dist/lib/action/index.cjs +1 -0
- package/dist/lib/action/index.d.cts +64 -0
- package/dist/lib/action/index.d.ts +64 -0
- package/dist/lib/action/index.js +2 -0
- package/dist/lib/action/origin.d.cts +20 -0
- package/dist/lib/action/origin.d.ts +20 -0
- package/dist/lib/action/scan.d.cts +28 -0
- package/dist/lib/action/scan.d.ts +28 -0
- package/dist/lib/action/server.d.cts +30 -0
- package/dist/lib/action/server.d.ts +30 -0
- package/dist/lib/action-BB6N5yD-.js +111 -0
- package/dist/lib/action-BB6N5yD-.js.map +1 -0
- package/dist/lib/action-DZHihU3Z.cjs +2 -0
- package/dist/lib/action-DZHihU3Z.cjs.map +1 -0
- package/dist/lib/adapters/bun.cjs +30 -0
- package/dist/lib/adapters/bun.cjs.map +1 -0
- package/dist/lib/adapters/bun.d.cts +13 -0
- package/dist/lib/adapters/bun.d.ts +13 -0
- package/dist/lib/adapters/bun.js +65 -0
- package/dist/lib/adapters/bun.js.map +1 -0
- package/dist/lib/adapters/index.cjs +0 -0
- package/dist/lib/adapters/index.d.cts +30 -0
- package/dist/lib/adapters/index.d.ts +30 -0
- package/dist/lib/adapters/index.js +0 -0
- package/dist/lib/adapters/netlify.cjs +10 -0
- package/dist/lib/adapters/netlify.cjs.map +1 -0
- package/dist/lib/adapters/netlify.d.cts +13 -0
- package/dist/lib/adapters/netlify.d.ts +13 -0
- package/dist/lib/adapters/netlify.js +51 -0
- package/dist/lib/adapters/netlify.js.map +1 -0
- package/dist/lib/adapters/node.cjs +46 -0
- package/dist/lib/adapters/node.cjs.map +1 -0
- package/dist/lib/adapters/node.d.cts +13 -0
- package/dist/lib/adapters/node.d.ts +13 -0
- package/dist/lib/adapters/node.js +105 -0
- package/dist/lib/adapters/node.js.map +1 -0
- package/dist/lib/adapters/shared.d.cts +17 -0
- package/dist/lib/adapters/shared.d.ts +17 -0
- package/dist/lib/adapters/vercel.cjs +2 -0
- package/dist/lib/adapters/vercel.cjs.map +1 -0
- package/dist/lib/adapters/vercel.d.cts +9 -0
- package/dist/lib/adapters/vercel.d.ts +9 -0
- package/dist/lib/adapters/vercel.js +62 -0
- package/dist/lib/adapters/vercel.js.map +1 -0
- package/dist/lib/build/build.d.cts +83 -0
- package/dist/lib/build/build.d.ts +83 -0
- package/dist/lib/build/document-shell.d.cts +48 -0
- package/dist/lib/build/document-shell.d.ts +48 -0
- package/dist/lib/build/transform-source.d.cts +26 -0
- package/dist/lib/build/transform-source.d.ts +26 -0
- package/dist/lib/build/vite-build.d.cts +78 -0
- package/dist/lib/build/vite-build.d.ts +78 -0
- package/dist/lib/cache/policy.d.cts +25 -0
- package/dist/lib/cache/policy.d.ts +25 -0
- package/dist/lib/cache.d.cts +13 -0
- package/dist/lib/cache.d.ts +13 -0
- package/dist/lib/capabilities-C0TDQoMY.cjs +2 -0
- package/dist/lib/capabilities-C0TDQoMY.cjs.map +1 -0
- package/dist/lib/capabilities-C7txofmY.js +45 -0
- package/dist/lib/capabilities-C7txofmY.js.map +1 -0
- package/dist/lib/cli/commands.d.cts +15 -0
- package/dist/lib/cli/commands.d.ts +15 -0
- package/dist/lib/cli.cjs +5132 -0
- package/dist/lib/cli.cjs.map +1 -0
- package/dist/lib/cli.d.cts +30 -0
- package/dist/lib/cli.d.ts +30 -0
- package/dist/lib/cli.js +5131 -0
- package/dist/lib/cli.js.map +1 -0
- package/dist/lib/collections-Dbc8aRLf.js +233 -0
- package/dist/lib/collections-Dbc8aRLf.js.map +1 -0
- package/dist/lib/collections-VDy5g9p8.cjs +13 -0
- package/dist/lib/collections-VDy5g9p8.cjs.map +1 -0
- package/dist/lib/config/index.cjs +2 -0
- package/dist/lib/config/index.cjs.map +1 -0
- package/dist/lib/config/index.d.cts +100 -0
- package/dist/lib/config/index.d.ts +100 -0
- package/dist/lib/config/index.js +122 -0
- package/dist/lib/config/index.js.map +1 -0
- package/dist/lib/content/collections.d.cts +69 -0
- package/dist/lib/content/collections.d.ts +69 -0
- package/dist/lib/content/frontmatter.d.cts +20 -0
- package/dist/lib/content/frontmatter.d.ts +20 -0
- package/dist/lib/content/index.cjs +2 -0
- package/dist/lib/content/index.cjs.map +1 -0
- package/dist/lib/content/index.d.cts +5 -0
- package/dist/lib/content/index.d.ts +5 -0
- package/dist/lib/content/index.js +28 -0
- package/dist/lib/content/index.js.map +1 -0
- package/dist/lib/content/markdown.d.cts +6 -0
- package/dist/lib/content/markdown.d.ts +6 -0
- package/dist/lib/content/raw.d.cts +9 -0
- package/dist/lib/content/raw.d.ts +9 -0
- package/dist/lib/content/schema.d.cts +14 -0
- package/dist/lib/content/schema.d.ts +14 -0
- package/dist/lib/errors-0X7pCFNU.cjs +2 -0
- package/dist/lib/errors-0X7pCFNU.cjs.map +1 -0
- package/dist/lib/errors-ePYxDlhU.js +70 -0
- package/dist/lib/errors-ePYxDlhU.js.map +1 -0
- package/dist/lib/errors.d.cts +84 -0
- package/dist/lib/errors.d.ts +84 -0
- package/dist/lib/hydrate-8a3TbQbs.cjs +2 -0
- package/dist/lib/hydrate-8a3TbQbs.cjs.map +1 -0
- package/dist/lib/hydrate-CgZGrTxF.js +126 -0
- package/dist/lib/hydrate-CgZGrTxF.js.map +1 -0
- package/dist/lib/image/index.cjs +2 -0
- package/dist/lib/image/index.cjs.map +1 -0
- package/dist/lib/image/index.d.cts +37 -0
- package/dist/lib/image/index.d.ts +37 -0
- package/dist/lib/image/index.js +49 -0
- package/dist/lib/image/index.js.map +1 -0
- package/dist/lib/image/pipeline.d.cts +37 -0
- package/dist/lib/image/pipeline.d.ts +37 -0
- package/dist/lib/image/registry.cjs +2 -0
- package/dist/lib/image/registry.cjs.map +1 -0
- package/dist/lib/image/registry.d.cts +26 -0
- package/dist/lib/image/registry.d.ts +26 -0
- package/dist/lib/image/registry.js +23 -0
- package/dist/lib/image/registry.js.map +1 -0
- package/dist/lib/image/service.cjs +2 -0
- package/dist/lib/image/service.cjs.map +1 -0
- package/dist/lib/image/service.d.cts +164 -0
- package/dist/lib/image/service.d.ts +164 -0
- package/dist/lib/image/service.js +308 -0
- package/dist/lib/image/service.js.map +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.cjs.map +1 -0
- package/dist/lib/index.d.cts +38 -0
- package/dist/lib/index.d.ts +38 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/integrations/hooks.d.cts +58 -0
- package/dist/lib/integrations/hooks.d.ts +58 -0
- package/dist/lib/integrations/index.cjs +1 -0
- package/dist/lib/integrations/index.d.cts +18 -0
- package/dist/lib/integrations/index.d.ts +18 -0
- package/dist/lib/integrations/index.js +2 -0
- package/dist/lib/integrations-7dpN1RYB.js +35 -0
- package/dist/lib/integrations-7dpN1RYB.js.map +1 -0
- package/dist/lib/integrations-DDqfWjvH.cjs +2 -0
- package/dist/lib/integrations-DDqfWjvH.cjs.map +1 -0
- package/dist/lib/interpolation-plugin-Bt-KRKVY.js +365 -0
- package/dist/lib/interpolation-plugin-Bt-KRKVY.js.map +1 -0
- package/dist/lib/interpolation-plugin-CMPCDlVJ.cjs +31 -0
- package/dist/lib/interpolation-plugin-CMPCDlVJ.cjs.map +1 -0
- package/dist/lib/island/generate-entry.d.cts +27 -0
- package/dist/lib/island/generate-entry.d.ts +27 -0
- package/dist/lib/island/hydrate.d.cts +33 -0
- package/dist/lib/island/hydrate.d.ts +33 -0
- package/dist/lib/island/index.cjs +1 -0
- package/dist/lib/island/index.d.cts +2 -0
- package/dist/lib/island/index.d.ts +2 -0
- package/dist/lib/island/index.js +1 -0
- package/dist/lib/island/island.d.cts +32 -0
- package/dist/lib/island/island.d.ts +32 -0
- package/dist/lib/island/scan.d.cts +14 -0
- package/dist/lib/island/scan.d.ts +14 -0
- package/dist/lib/manifest/index.cjs +3 -0
- package/dist/lib/manifest/index.cjs.map +1 -0
- package/dist/lib/manifest/index.d.cts +18 -0
- package/dist/lib/manifest/index.d.ts +18 -0
- package/dist/lib/manifest/index.js +110 -0
- package/dist/lib/manifest/index.js.map +1 -0
- package/dist/lib/middleware/index.d.cts +56 -0
- package/dist/lib/middleware/index.d.ts +56 -0
- package/dist/lib/middleware/stream-boundary.d.cts +53 -0
- package/dist/lib/middleware/stream-boundary.d.ts +53 -0
- package/dist/lib/node-http-DRAUhO0c.js +617 -0
- package/dist/lib/node-http-DRAUhO0c.js.map +1 -0
- package/dist/lib/node-http-DhxguYyz.cjs +13 -0
- package/dist/lib/node-http-DhxguYyz.cjs.map +1 -0
- package/dist/lib/render/render-to-string.d.cts +12 -0
- package/dist/lib/render/render-to-string.d.ts +12 -0
- package/dist/lib/render/ssr-flag.d.cts +4 -0
- package/dist/lib/render/ssr-flag.d.ts +4 -0
- package/dist/lib/route-scanner-JY6YrNH5.cjs +2 -0
- package/dist/lib/route-scanner-JY6YrNH5.cjs.map +1 -0
- package/dist/lib/route-scanner-XcLId7lK.js +100 -0
- package/dist/lib/route-scanner-XcLId7lK.js.map +1 -0
- package/dist/lib/router/client.cjs +2 -0
- package/dist/lib/router/client.cjs.map +1 -0
- package/dist/lib/router/client.d.cts +47 -0
- package/dist/lib/router/client.d.ts +47 -0
- package/dist/lib/router/client.js +298 -0
- package/dist/lib/router/client.js.map +1 -0
- package/dist/lib/router/route-scanner.d.cts +50 -0
- package/dist/lib/router/route-scanner.d.ts +50 -0
- package/dist/lib/runtime/capabilities.d.cts +47 -0
- package/dist/lib/runtime/capabilities.d.ts +47 -0
- package/dist/lib/runtime/context.d.cts +140 -0
- package/dist/lib/runtime/context.d.ts +140 -0
- package/dist/lib/runtime/handler.d.cts +39 -0
- package/dist/lib/runtime/handler.d.ts +39 -0
- package/dist/lib/runtime/index.cjs +1 -0
- package/dist/lib/runtime/index.d.cts +6 -0
- package/dist/lib/runtime/index.d.ts +6 -0
- package/dist/lib/runtime/index.js +4 -0
- package/dist/lib/runtime/node-http.d.cts +2 -0
- package/dist/lib/runtime/node-http.d.ts +2 -0
- package/dist/lib/runtime/security-headers.d.cts +13 -0
- package/dist/lib/runtime/security-headers.d.ts +13 -0
- package/dist/lib/runtime/static.d.cts +1 -0
- package/dist/lib/runtime/static.d.ts +1 -0
- package/dist/lib/runtime-CrH5X-Es.cjs +2 -0
- package/dist/lib/runtime-CrH5X-Es.cjs.map +1 -0
- package/dist/lib/runtime-Ds2-wH6P.js +520 -0
- package/dist/lib/runtime-Ds2-wH6P.js.map +1 -0
- package/dist/lib/scan-CY2O9ty6.cjs +2 -0
- package/dist/lib/scan-CY2O9ty6.cjs.map +1 -0
- package/dist/lib/scan-CjMUgnsd.js +22 -0
- package/dist/lib/scan-CjMUgnsd.js.map +1 -0
- package/dist/lib/scan-DXzYtmRQ.cjs +2 -0
- package/dist/lib/scan-DXzYtmRQ.cjs.map +1 -0
- package/dist/lib/scan-Dn93ycXG.js +33 -0
- package/dist/lib/scan-Dn93ycXG.js.map +1 -0
- package/dist/lib/seo/index.cjs +10 -0
- package/dist/lib/seo/index.cjs.map +1 -0
- package/dist/lib/seo/index.d.cts +99 -0
- package/dist/lib/seo/index.d.ts +99 -0
- package/dist/lib/seo/index.js +41 -0
- package/dist/lib/seo/index.js.map +1 -0
- package/dist/lib/shared-CfqOLsKj.cjs +183 -0
- package/dist/lib/shared-CfqOLsKj.cjs.map +1 -0
- package/dist/lib/shared-DU3iQgr7.js +236 -0
- package/dist/lib/shared-DU3iQgr7.js.map +1 -0
- package/dist/lib/ssr/match.d.cts +25 -0
- package/dist/lib/ssr/match.d.ts +25 -0
- package/dist/lib/ssr/render.d.cts +62 -0
- package/dist/lib/ssr/render.d.ts +62 -0
- package/dist/lib/ssr/server.d.cts +41 -0
- package/dist/lib/ssr/server.d.ts +41 -0
- package/dist/lib/ssr/stream.d.cts +48 -0
- package/dist/lib/ssr/stream.d.ts +48 -0
- package/dist/lib/stream-CpOG052V.js +104 -0
- package/dist/lib/stream-CpOG052V.js.map +1 -0
- package/dist/lib/stream-DmZjYqHm.cjs +17 -0
- package/dist/lib/stream-DmZjYqHm.cjs.map +1 -0
- package/dist/lib/types.d.cts +97 -0
- package/dist/lib/types.d.ts +97 -0
- package/dist/lib/vite/index.cjs +2 -0
- package/dist/lib/vite/index.cjs.map +1 -0
- package/dist/lib/vite/index.d.cts +41 -0
- package/dist/lib/vite/index.d.ts +41 -0
- package/dist/lib/vite/index.js +229 -0
- package/dist/lib/vite/index.js.map +1 -0
- package/dist/lib/vite/interpolation-plugin.d.cts +64 -0
- package/dist/lib/vite/interpolation-plugin.d.ts +64 -0
- package/package.json +292 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { t as e } from "../integrations-7dpN1RYB.js";
|
|
2
|
+
import { access as t } from "node:fs/promises";
|
|
3
|
+
import { isAbsolute as n, relative as r, resolve as i, sep as a } from "node:path";
|
|
4
|
+
import { loadConfigFromFile as o } from "vite";
|
|
5
|
+
//#region src/config/index.ts
|
|
6
|
+
function s(e) {
|
|
7
|
+
return e;
|
|
8
|
+
}
|
|
9
|
+
async function c(t = {}) {
|
|
10
|
+
let n = i(t.root ?? process.cwd()), r = t.configFile ? i(n, t.configFile) : await h(n), a = {};
|
|
11
|
+
if (r) {
|
|
12
|
+
let e = await o({
|
|
13
|
+
command: t.command === "build" ? "build" : "serve",
|
|
14
|
+
mode: t.mode ?? "development"
|
|
15
|
+
}, r, n);
|
|
16
|
+
if (!e) throw Error(`[elur-kit] Could not load config: ${r}`);
|
|
17
|
+
a = e.config;
|
|
18
|
+
}
|
|
19
|
+
let s = u(a, t.overrides ?? {}), c = i(n, s.root ?? "."), d = l(c, s, r);
|
|
20
|
+
return await e(d.integrations, "config", [d, {
|
|
21
|
+
root: c,
|
|
22
|
+
command: t.command ?? "dev"
|
|
23
|
+
}]), d;
|
|
24
|
+
}
|
|
25
|
+
function l(e, t, n) {
|
|
26
|
+
t.site && new URL(t.site);
|
|
27
|
+
let r = f(t.base ?? "/"), i = t.images?.quality ?? 80;
|
|
28
|
+
if (!Number.isFinite(i) || i < 1 || i > 100) throw Error("[elur-kit] images.quality must be between 1 and 100");
|
|
29
|
+
return {
|
|
30
|
+
root: e,
|
|
31
|
+
appDir: d(e, t.appDir ?? "src/app", "appDir"),
|
|
32
|
+
islandsDir: d(e, t.islandsDir ?? "src/islands", "islandsDir"),
|
|
33
|
+
contentDir: d(e, t.contentDir ?? "src/content", "contentDir"),
|
|
34
|
+
publicDir: d(e, t.publicDir ?? "public", "publicDir"),
|
|
35
|
+
outDir: d(e, t.outDir ?? "dist", "outDir"),
|
|
36
|
+
site: t.site,
|
|
37
|
+
base: r,
|
|
38
|
+
trailingSlash: t.trailingSlash ?? "ignore",
|
|
39
|
+
output: t.output ?? "static",
|
|
40
|
+
adapter: t.adapter,
|
|
41
|
+
images: {
|
|
42
|
+
formats: t.images?.formats ?? ["webp", "avif"],
|
|
43
|
+
quality: i,
|
|
44
|
+
strict: t.images?.strict ?? !1
|
|
45
|
+
},
|
|
46
|
+
cache: {
|
|
47
|
+
dir: d(e, t.cache?.dir ?? ".elur/cache", "cache.dir"),
|
|
48
|
+
defaultRevalidate: t.cache?.defaultRevalidate
|
|
49
|
+
},
|
|
50
|
+
security: {
|
|
51
|
+
allowedOrigins: t.security?.allowedOrigins ?? [],
|
|
52
|
+
strictOrigin: t.security?.strictOrigin ?? !1,
|
|
53
|
+
bodyLimit: t.security?.bodyLimit ?? 1048576,
|
|
54
|
+
headers: t.security?.headers === !1 ? !1 : t.security?.headers ?? {}
|
|
55
|
+
},
|
|
56
|
+
router: {
|
|
57
|
+
enabled: t.router?.enabled ?? !0,
|
|
58
|
+
prefetch: t.router?.prefetch ?? !0
|
|
59
|
+
},
|
|
60
|
+
integrations: t.integrations ?? [],
|
|
61
|
+
configFile: n
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function u(e, t) {
|
|
65
|
+
return {
|
|
66
|
+
...e,
|
|
67
|
+
...t,
|
|
68
|
+
images: {
|
|
69
|
+
...e.images,
|
|
70
|
+
...t.images
|
|
71
|
+
},
|
|
72
|
+
cache: {
|
|
73
|
+
...e.cache,
|
|
74
|
+
...t.cache
|
|
75
|
+
},
|
|
76
|
+
security: {
|
|
77
|
+
...e.security,
|
|
78
|
+
...t.security
|
|
79
|
+
},
|
|
80
|
+
router: {
|
|
81
|
+
...e.router,
|
|
82
|
+
...t.router
|
|
83
|
+
},
|
|
84
|
+
integrations: t.integrations ?? e.integrations
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function d(e, t, o) {
|
|
88
|
+
let s = n(t) ? i(t) : i(e, t), c = r(e, s);
|
|
89
|
+
if (c === ".." || c.startsWith(`..${a}`) || n(c)) throw Error(`[elur-kit] ${o} must stay inside root: ${s}`);
|
|
90
|
+
return s;
|
|
91
|
+
}
|
|
92
|
+
function f(e) {
|
|
93
|
+
if (!e.startsWith("/")) throw Error("[elur-kit] base must start with /");
|
|
94
|
+
return e === "/" ? e : `${e.replace(/\/+$/, "")}/`;
|
|
95
|
+
}
|
|
96
|
+
var p = [
|
|
97
|
+
"elur.config.ts",
|
|
98
|
+
"elur.config.js",
|
|
99
|
+
"elur.config.mjs"
|
|
100
|
+
], m = [
|
|
101
|
+
"elur.config.ts",
|
|
102
|
+
"elur.config.js",
|
|
103
|
+
"elur.config.mjs"
|
|
104
|
+
];
|
|
105
|
+
async function h(e) {
|
|
106
|
+
for (let n of p) {
|
|
107
|
+
let r = i(e, n);
|
|
108
|
+
try {
|
|
109
|
+
return await t(r), r;
|
|
110
|
+
} catch {}
|
|
111
|
+
}
|
|
112
|
+
for (let n of m) {
|
|
113
|
+
let r = i(e, n);
|
|
114
|
+
try {
|
|
115
|
+
return await t(r), console.warn(`[elur-kit] "${n}" is deprecated and will be removed in a future release. Rename it to "elur.config.${n.split(".").slice(1).join(".")}" to keep your config working.`), r;
|
|
116
|
+
} catch {}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { s as defineConfig, c as loadElurConfig };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/config/index.ts"],"sourcesContent":["import { access } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { loadConfigFromFile } from \"vite\";\nimport type { Adapter } from \"../adapters/index.js\";\nimport type { ImageFormat } from \"../image/index.js\";\nimport type { ElurKitIntegration } from \"../integrations/index.js\";\nimport { runIntegrationHook } from \"../integrations/index.js\";\n\nexport type ElurOutputMode = \"static\" | \"server\" | \"hybrid\";\nexport type TrailingSlashMode = \"always\" | \"never\" | \"ignore\";\n\nexport interface ElurConfig {\n root?: string;\n appDir?: string;\n islandsDir?: string;\n contentDir?: string;\n publicDir?: string;\n outDir?: string;\n site?: string;\n base?: string;\n trailingSlash?: TrailingSlashMode;\n output?: ElurOutputMode;\n adapter?: Adapter;\n images?: {\n formats?: ImageFormat[];\n quality?: number;\n strict?: boolean;\n };\n cache?: {\n dir?: string;\n defaultRevalidate?: number;\n };\n security?: {\n allowedOrigins?: string[];\n strictOrigin?: boolean;\n bodyLimit?: number;\n /** Security response headers. Set to `false` to disable defaults. */\n headers?: SecurityHeadersConfig | false;\n };\n router?: {\n enabled?: boolean;\n prefetch?: boolean;\n };\n integrations?: ElurKitIntegration[];\n}\n\n/** Security headers configuration (runtime-security §14). */\nexport interface SecurityHeadersConfig {\n /** X-Content-Type-Options: nosniff. Default: true. */\n noSniff?: boolean;\n /** Referrer-Policy. Default: \"strict-origin-when-cross-origin\". */\n referrerPolicy?: string;\n /**\n * Content-Security-Policy. Set to a string to enable.\n * Use \"nonce\" placeholder to inject per-request nonces.\n */\n contentSecurityPolicy?: string;\n /** Strict-Transport-Security. Only applied under HTTPS. Default: unset. */\n hsts?: string | true;\n /** X-Frame-Options or CSP frame-ancestors. Default: \"SAMEORIGIN\". */\n frameAncestors?: string;\n /** Permissions-Policy. Default: unset. */\n permissionsPolicy?: string;\n}\n\nexport interface ResolvedElurConfig {\n root: string;\n appDir: string;\n islandsDir: string;\n contentDir: string;\n publicDir: string;\n outDir: string;\n site?: string;\n base: string;\n trailingSlash: TrailingSlashMode;\n output: ElurOutputMode;\n adapter?: Adapter;\n images: {\n formats: ImageFormat[];\n quality: number;\n strict: boolean;\n };\n cache: {\n dir: string;\n defaultRevalidate?: number;\n };\n security: {\n allowedOrigins: string[];\n strictOrigin: boolean;\n bodyLimit: number;\n headers: SecurityHeadersConfig | false;\n };\n router: {\n enabled: boolean;\n prefetch: boolean;\n };\n integrations: ElurKitIntegration[];\n configFile?: string;\n}\n\nexport interface LoadElurConfigOptions {\n root?: string;\n configFile?: string;\n command?: \"dev\" | \"build\" | \"preview\" | \"start\" | \"check\" | \"routes\" | \"doctor\";\n mode?: string;\n overrides?: ElurConfig;\n}\n\nexport function defineConfig(config: ElurConfig): ElurConfig {\n return config;\n}\n\nexport async function loadElurConfig(options: LoadElurConfigOptions = {}): Promise<ResolvedElurConfig> {\n const initialRoot = resolve(options.root ?? process.cwd());\n const configFile = options.configFile\n ? resolve(initialRoot, options.configFile)\n : await findConfigFile(initialRoot);\n let loaded: ElurConfig = {};\n\n if (configFile) {\n const result = await loadConfigFromFile(\n { command: options.command === \"build\" ? \"build\" : \"serve\", mode: options.mode ?? \"development\" },\n configFile,\n initialRoot,\n );\n if (!result) throw new Error(`[elur-kit] Could not load config: ${configFile}`);\n loaded = result.config as ElurConfig;\n }\n\n const merged = mergeConfig(loaded, options.overrides ?? {});\n const root = resolve(initialRoot, merged.root ?? \".\");\n const resolved = resolveConfig(root, merged, configFile);\n await runIntegrationHook(resolved.integrations, \"config\", [\n resolved as unknown as Record<string, unknown>,\n { root, command: options.command ?? \"dev\" },\n ]);\n return resolved;\n}\n\nfunction resolveConfig(root: string, config: ElurConfig, configFile?: string): ResolvedElurConfig {\n if (config.site) new URL(config.site);\n const base = normalizeBase(config.base ?? \"/\");\n const imageQuality = config.images?.quality ?? 80;\n if (!Number.isFinite(imageQuality) || imageQuality < 1 || imageQuality > 100) {\n throw new Error(\"[elur-kit] images.quality must be between 1 and 100\");\n }\n\n return {\n root,\n appDir: resolveInside(root, config.appDir ?? \"src/app\", \"appDir\"),\n islandsDir: resolveInside(root, config.islandsDir ?? \"src/islands\", \"islandsDir\"),\n contentDir: resolveInside(root, config.contentDir ?? \"src/content\", \"contentDir\"),\n publicDir: resolveInside(root, config.publicDir ?? \"public\", \"publicDir\"),\n outDir: resolveInside(root, config.outDir ?? \"dist\", \"outDir\"),\n site: config.site,\n base,\n trailingSlash: config.trailingSlash ?? \"ignore\",\n output: config.output ?? \"static\",\n adapter: config.adapter,\n images: {\n formats: config.images?.formats ?? [\"webp\", \"avif\"],\n quality: imageQuality,\n strict: config.images?.strict ?? false,\n },\n cache: {\n dir: resolveInside(root, config.cache?.dir ?? \".elur/cache\", \"cache.dir\"),\n defaultRevalidate: config.cache?.defaultRevalidate,\n },\n security: {\n allowedOrigins: config.security?.allowedOrigins ?? [],\n strictOrigin: config.security?.strictOrigin ?? false,\n bodyLimit: config.security?.bodyLimit ?? 1_048_576,\n headers: config.security?.headers === false\n ? false\n : config.security?.headers ?? {},\n },\n router: {\n enabled: config.router?.enabled ?? true,\n prefetch: config.router?.prefetch ?? true,\n },\n integrations: config.integrations ?? [],\n configFile,\n };\n}\n\nfunction mergeConfig(base: ElurConfig, override: ElurConfig): ElurConfig {\n return {\n ...base,\n ...override,\n images: { ...base.images, ...override.images },\n cache: { ...base.cache, ...override.cache },\n security: { ...base.security, ...override.security },\n router: { ...base.router, ...override.router },\n integrations: override.integrations ?? base.integrations,\n };\n}\n\nfunction resolveInside(root: string, path: string, name: string): string {\n const resolved = isAbsolute(path) ? resolve(path) : resolve(root, path);\n const rel = relative(root, resolved);\n if (rel === \"..\" || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {\n throw new Error(`[elur-kit] ${name} must stay inside root: ${resolved}`);\n }\n return resolved;\n}\n\nfunction normalizeBase(base: string): string {\n if (!base.startsWith(\"/\")) throw new Error(\"[elur-kit] base must start with /\");\n return base === \"/\" ? base : `${base.replace(/\\/+$/, \"\")}/`;\n}\n\nconst PREFERRED_CONFIG_FILES = [\"elur.config.ts\", \"elur.config.js\", \"elur.config.mjs\"];\n// Legacy names kept for backward compatibility. Emit a deprecation warning\n// when a project still uses them so authors migrate to `elur.config.*`.\nconst LEGACY_CONFIG_FILES = [\"elur.config.ts\", \"elur.config.js\", \"elur.config.mjs\"];\n\nasync function findConfigFile(root: string): Promise<string | undefined> {\n for (const name of PREFERRED_CONFIG_FILES) {\n const path = resolve(root, name);\n try {\n await access(path);\n return path;\n } catch {\n }\n }\n for (const name of LEGACY_CONFIG_FILES) {\n const path = resolve(root, name);\n try {\n await access(path);\n console.warn(\n `[elur-kit] \"${name}\" is deprecated and will be removed in a future release. ` +\n `Rename it to \"elur.config.${name.split(\".\").slice(1).join(\".\")}\" to keep your config working.`,\n );\n return path;\n } catch {\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;AA4GA,SAAgB,EAAa,GAAgC;CAC3D,OAAO;AACT;AAEA,eAAsB,EAAe,IAAiC,CAAC,GAAgC;CACrG,IAAM,IAAc,EAAQ,EAAQ,QAAQ,QAAQ,IAAI,CAAC,GACnD,IAAa,EAAQ,aACvB,EAAQ,GAAa,EAAQ,UAAU,IACvC,MAAM,EAAe,CAAW,GAChC,IAAqB,CAAC;CAE1B,IAAI,GAAY;EACd,IAAM,IAAS,MAAM,EACnB;GAAE,SAAS,EAAQ,YAAY,UAAU,UAAU;GAAS,MAAM,EAAQ,QAAQ;EAAc,GAChG,GACA,CACF;EACA,IAAI,CAAC,GAAQ,MAAU,MAAM,qCAAqC,GAAY;EAC9E,IAAS,EAAO;CAClB;CAEA,IAAM,IAAS,EAAY,GAAQ,EAAQ,aAAa,CAAC,CAAC,GACpD,IAAO,EAAQ,GAAa,EAAO,QAAQ,GAAG,GAC9C,IAAW,EAAc,GAAM,GAAQ,CAAU;CAKvD,OAJA,MAAM,EAAmB,EAAS,cAAc,UAAU,CACxD,GACA;EAAE;EAAM,SAAS,EAAQ,WAAW;CAAM,CAC5C,CAAC,GACM;AACT;AAEA,SAAS,EAAc,GAAc,GAAoB,GAAyC;CAChG,AAAI,EAAO,QAAM,IAAI,IAAI,EAAO,IAAI;CACpC,IAAM,IAAO,EAAc,EAAO,QAAQ,GAAG,GACvC,IAAe,EAAO,QAAQ,WAAW;CAC/C,IAAI,CAAC,OAAO,SAAS,CAAY,KAAK,IAAe,KAAK,IAAe,KACvE,MAAU,MAAM,qDAAqD;CAGvE,OAAO;EACL;EACA,QAAQ,EAAc,GAAM,EAAO,UAAU,WAAW,QAAQ;EAChE,YAAY,EAAc,GAAM,EAAO,cAAc,eAAe,YAAY;EAChF,YAAY,EAAc,GAAM,EAAO,cAAc,eAAe,YAAY;EAChF,WAAW,EAAc,GAAM,EAAO,aAAa,UAAU,WAAW;EACxE,QAAQ,EAAc,GAAM,EAAO,UAAU,QAAQ,QAAQ;EAC7D,MAAM,EAAO;EACb;EACA,eAAe,EAAO,iBAAiB;EACvC,QAAQ,EAAO,UAAU;EACzB,SAAS,EAAO;EAChB,QAAQ;GACN,SAAS,EAAO,QAAQ,WAAW,CAAC,QAAQ,MAAM;GAClD,SAAS;GACT,QAAQ,EAAO,QAAQ,UAAU;EACnC;EACA,OAAO;GACL,KAAK,EAAc,GAAM,EAAO,OAAO,OAAO,eAAe,WAAW;GACxE,mBAAmB,EAAO,OAAO;EACnC;EACA,UAAU;GACR,gBAAgB,EAAO,UAAU,kBAAkB,CAAC;GACpD,cAAc,EAAO,UAAU,gBAAgB;GAC/C,WAAW,EAAO,UAAU,aAAa;GACzC,SAAS,EAAO,UAAU,YAAY,KAClC,KACA,EAAO,UAAU,WAAW,CAAC;EACnC;EACA,QAAQ;GACN,SAAS,EAAO,QAAQ,WAAW;GACnC,UAAU,EAAO,QAAQ,YAAY;EACvC;EACA,cAAc,EAAO,gBAAgB,CAAC;EACtC;CACF;AACF;AAEA,SAAS,EAAY,GAAkB,GAAkC;CACvE,OAAO;EACL,GAAG;EACH,GAAG;EACH,QAAQ;GAAE,GAAG,EAAK;GAAQ,GAAG,EAAS;EAAO;EAC7C,OAAO;GAAE,GAAG,EAAK;GAAO,GAAG,EAAS;EAAM;EAC1C,UAAU;GAAE,GAAG,EAAK;GAAU,GAAG,EAAS;EAAS;EACnD,QAAQ;GAAE,GAAG,EAAK;GAAQ,GAAG,EAAS;EAAO;EAC7C,cAAc,EAAS,gBAAgB,EAAK;CAC9C;AACF;AAEA,SAAS,EAAc,GAAc,GAAc,GAAsB;CACvE,IAAM,IAAW,EAAW,CAAI,IAAI,EAAQ,CAAI,IAAI,EAAQ,GAAM,CAAI,GAChE,IAAM,EAAS,GAAM,CAAQ;CACnC,IAAI,MAAQ,QAAQ,EAAI,WAAW,KAAK,GAAK,KAAK,EAAW,CAAG,GAC9D,MAAU,MAAM,cAAc,EAAK,0BAA0B,GAAU;CAEzE,OAAO;AACT;AAEA,SAAS,EAAc,GAAsB;CAC3C,IAAI,CAAC,EAAK,WAAW,GAAG,GAAG,MAAU,MAAM,mCAAmC;CAC9E,OAAO,MAAS,MAAM,IAAO,GAAG,EAAK,QAAQ,QAAQ,EAAE,EAAE;AAC3D;AAEA,IAAM,IAAyB;CAAC;CAAkB;CAAkB;AAAiB,GAG/E,IAAsB;CAAC;CAAkB;CAAkB;AAAiB;AAElF,eAAe,EAAe,GAA2C;CACvE,KAAK,IAAM,KAAQ,GAAwB;EACzC,IAAM,IAAO,EAAQ,GAAM,CAAI;EAC/B,IAAI;GAEF,OADA,MAAM,EAAO,CAAI,GACV;EACT,QAAQ,CACR;CACF;CACA,KAAK,IAAM,KAAQ,GAAqB;EACtC,IAAM,IAAO,EAAQ,GAAM,CAAI;EAC/B,IAAI;GAMF,OALA,MAAM,EAAO,CAAI,GACjB,QAAQ,KACN,eAAe,EAAK,qFACS,EAAK,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,+BAClE,GACO;EACT,QAAQ,CACR;CACF;AAEF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface CollectionDefinition {
|
|
2
|
+
/** Schema for frontmatter validation (zod schema or plain function). */
|
|
3
|
+
schema?: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface ContentEntry<TData = Record<string, unknown>> {
|
|
6
|
+
/** Collection name, e.g. "blog". */
|
|
7
|
+
collection: string;
|
|
8
|
+
/** Entry slug (filename without `.md`), e.g. "hello-world". */
|
|
9
|
+
slug: string;
|
|
10
|
+
/** Parsed and validated frontmatter. */
|
|
11
|
+
data: TData;
|
|
12
|
+
/** Raw Markdown body (not yet rendered to HTML). */
|
|
13
|
+
body: string;
|
|
14
|
+
/** Rendered HTML body (lazily computed via `renderHTML()`). */
|
|
15
|
+
html?: string;
|
|
16
|
+
/** Absolute path to the source `.md` file. */
|
|
17
|
+
filePath: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Defines a collection with an optional schema. Used in `src/content/config.ts`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function defineCollection(def: CollectionDefinition): CollectionDefinition;
|
|
23
|
+
/** Type for the `collections` export from `src/content/config.ts`. */
|
|
24
|
+
export type CollectionsConfig = Record<string, CollectionDefinition>;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the root directory for content. Called by the Vite plugin / CLI on
|
|
27
|
+
* startup so `getCollection` knows where to find `src/content/`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function setContentRoot(root: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Runs a function with a per-request content root (plan §11.4).
|
|
32
|
+
* This prevents global state leakage between concurrent requests.
|
|
33
|
+
*/
|
|
34
|
+
export declare function withContentRoot<T>(root: string, fn: () => T): T;
|
|
35
|
+
/**
|
|
36
|
+
* Clears the in-memory cache for all collections. Called by the HMR handler
|
|
37
|
+
* when a `.md` file changes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function clearContentCache(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Returns all entries in a collection.
|
|
42
|
+
*
|
|
43
|
+
* @param name Collection name (directory under `src/content/`).
|
|
44
|
+
*
|
|
45
|
+
* Per plan §11.4: collection names are validated for containment — no
|
|
46
|
+
* path traversal or escape from the content root is allowed.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getCollection<TData = Record<string, unknown>>(name: string): Promise<ContentEntry<TData>[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns a single entry by slug, or `undefined` if not found.
|
|
51
|
+
*
|
|
52
|
+
* @param collection Collection name.
|
|
53
|
+
* @param slug Entry slug (filename without `.md`).
|
|
54
|
+
*/
|
|
55
|
+
export declare function getEntry<TData = Record<string, unknown>>(collection: string, slug: string): Promise<ContentEntry<TData> | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns multiple entries by slug.
|
|
58
|
+
*
|
|
59
|
+
* @param collection Collection name.
|
|
60
|
+
* @param slugs Array of slugs.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getEntries<TData = Record<string, unknown>>(collection: string, slugs: string[]): Promise<ContentEntry<TData>[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Renders the Markdown body of an entry to HTML. The result is cached on the
|
|
65
|
+
* entry object so repeated calls don't re-render.
|
|
66
|
+
*
|
|
67
|
+
* @throws If `marked` is not installed.
|
|
68
|
+
*/
|
|
69
|
+
export declare function renderEntryHTML(entry: ContentEntry): Promise<string>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface CollectionDefinition {
|
|
2
|
+
/** Schema for frontmatter validation (zod schema or plain function). */
|
|
3
|
+
schema?: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface ContentEntry<TData = Record<string, unknown>> {
|
|
6
|
+
/** Collection name, e.g. "blog". */
|
|
7
|
+
collection: string;
|
|
8
|
+
/** Entry slug (filename without `.md`), e.g. "hello-world". */
|
|
9
|
+
slug: string;
|
|
10
|
+
/** Parsed and validated frontmatter. */
|
|
11
|
+
data: TData;
|
|
12
|
+
/** Raw Markdown body (not yet rendered to HTML). */
|
|
13
|
+
body: string;
|
|
14
|
+
/** Rendered HTML body (lazily computed via `renderHTML()`). */
|
|
15
|
+
html?: string;
|
|
16
|
+
/** Absolute path to the source `.md` file. */
|
|
17
|
+
filePath: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Defines a collection with an optional schema. Used in `src/content/config.ts`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function defineCollection(def: CollectionDefinition): CollectionDefinition;
|
|
23
|
+
/** Type for the `collections` export from `src/content/config.ts`. */
|
|
24
|
+
export type CollectionsConfig = Record<string, CollectionDefinition>;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the root directory for content. Called by the Vite plugin / CLI on
|
|
27
|
+
* startup so `getCollection` knows where to find `src/content/`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function setContentRoot(root: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Runs a function with a per-request content root (plan §11.4).
|
|
32
|
+
* This prevents global state leakage between concurrent requests.
|
|
33
|
+
*/
|
|
34
|
+
export declare function withContentRoot<T>(root: string, fn: () => T): T;
|
|
35
|
+
/**
|
|
36
|
+
* Clears the in-memory cache for all collections. Called by the HMR handler
|
|
37
|
+
* when a `.md` file changes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function clearContentCache(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Returns all entries in a collection.
|
|
42
|
+
*
|
|
43
|
+
* @param name Collection name (directory under `src/content/`).
|
|
44
|
+
*
|
|
45
|
+
* Per plan §11.4: collection names are validated for containment — no
|
|
46
|
+
* path traversal or escape from the content root is allowed.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getCollection<TData = Record<string, unknown>>(name: string): Promise<ContentEntry<TData>[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns a single entry by slug, or `undefined` if not found.
|
|
51
|
+
*
|
|
52
|
+
* @param collection Collection name.
|
|
53
|
+
* @param slug Entry slug (filename without `.md`).
|
|
54
|
+
*/
|
|
55
|
+
export declare function getEntry<TData = Record<string, unknown>>(collection: string, slug: string): Promise<ContentEntry<TData> | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns multiple entries by slug.
|
|
58
|
+
*
|
|
59
|
+
* @param collection Collection name.
|
|
60
|
+
* @param slugs Array of slugs.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getEntries<TData = Record<string, unknown>>(collection: string, slugs: string[]): Promise<ContentEntry<TData>[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Renders the Markdown body of an entry to HTML. The result is cached on the
|
|
65
|
+
* entry object so repeated calls don't re-render.
|
|
66
|
+
*
|
|
67
|
+
* @throws If `marked` is not installed.
|
|
68
|
+
*/
|
|
69
|
+
export declare function renderEntryHTML(entry: ContentEntry): Promise<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ParsedFrontmatter {
|
|
2
|
+
data: Record<string, unknown>;
|
|
3
|
+
body: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Splits a Markdown document into frontmatter and body. Returns the raw
|
|
7
|
+
* frontmatter string (without the `---` fences) and the body.
|
|
8
|
+
*/
|
|
9
|
+
export declare function splitFrontmatter(source: string): {
|
|
10
|
+
raw: string;
|
|
11
|
+
body: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Parses a YAML-subset frontmatter string into a JS object.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseFrontmatter(raw: string): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Parses a full Markdown document (frontmatter + body) in one call.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseDocument(source: string): ParsedFrontmatter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ParsedFrontmatter {
|
|
2
|
+
data: Record<string, unknown>;
|
|
3
|
+
body: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Splits a Markdown document into frontmatter and body. Returns the raw
|
|
7
|
+
* frontmatter string (without the `---` fences) and the body.
|
|
8
|
+
*/
|
|
9
|
+
export declare function splitFrontmatter(source: string): {
|
|
10
|
+
raw: string;
|
|
11
|
+
body: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Parses a YAML-subset frontmatter string into a JS object.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseFrontmatter(raw: string): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Parses a full Markdown document (frontmatter + body) in one call.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseDocument(source: string): ParsedFrontmatter;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../collections-VDy5g9p8.cjs");let t=require("@elurjs/core");function n(e){return{__isElurTemplate:!0,[t.ELUR_RENDER_PROTOCOL]:{renderServer:()=>e},mount(t){let n=typeof t==`string`?document.querySelector(t):t;if(!n)throw Error(`[elur-kit] raw(): container not found`);return n.innerHTML=e,{unmount(){n.innerHTML=``}}},_render(t,n){let r=document.createElement(`template`);r.innerHTML=e;let i=r.content,a=Array.from(i.childNodes);return t.insertBefore(i,n),()=>{for(let e of a)e.parentNode&&e.parentNode.removeChild(e)}}}}exports.clearContentCache=e.t,exports.createValidator=e.l,exports.defineCollection=e.n,exports.getCollection=e.r,exports.getEntries=e.i,exports.getEntry=e.a,exports.getZod=e.u,exports.parseDocument=e.f,exports.parseFrontmatter=e.p,exports.raw=n,exports.renderEntryHTML=e.o,exports.renderMarkdown=e.d,exports.setContentRoot=e.s,exports.splitFrontmatter=e.m,exports.withContentRoot=e.c;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../src/content/raw.ts"],"sourcesContent":["// --- raw() helper: inject pre-rendered HTML without escaping ---\n//\n// Elur templates escape interpolated values by default. When rendering\n// Markdown or other trusted HTML, we need to bypass that escaping. `raw()`\n// creates a ElurTemplate that inserts the HTML string directly, the same\n// pattern used by `island()` for server-side rendering.\n\nimport { ELUR_RENDER_PROTOCOL, type ElurTemplate } from \"@elurjs/core\";\n\n/**\n * Creates a ElurTemplate that renders the given HTML string without escaping.\n *\n * **Security:** Only use `raw()` with trusted content (e.g. Markdown you\n * authored, or HTML you generated and sanitized). Never use it with\n * user-supplied input without sanitization.\n */\nexport function raw(html: string): ElurTemplate {\n return {\n __isElurTemplate: true as const,\n [ELUR_RENDER_PROTOCOL]: {\n renderServer: () => html,\n },\n mount(container: Element | string) {\n const el = typeof container === \"string\" ? document.querySelector(container) : container;\n if (!el) throw new Error(\"[elur-kit] raw(): container not found\");\n el.innerHTML = html;\n return {\n unmount() {\n el.innerHTML = \"\";\n },\n };\n },\n _render(parent: Node, before: Node | null): () => void {\n const wrapper = document.createElement(\"template\");\n wrapper.innerHTML = html;\n const fragment = wrapper.content;\n const inserted = Array.from(fragment.childNodes);\n parent.insertBefore(fragment, before);\n return () => {\n for (const node of inserted) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n };\n },\n } as unknown as ElurTemplate;\n}\n"],"mappings":"gJAgBA,SAAgB,EAAI,EAA4B,CAC9C,MAAO,CACL,iBAAkB,IACjB,EAAA,sBAAuB,CACtB,iBAAoB,CACtB,EACA,MAAM,EAA6B,CACjC,IAAM,EAAK,OAAO,GAAc,SAAW,SAAS,cAAc,CAAS,EAAI,EAC/E,GAAI,CAAC,EAAI,MAAU,MAAM,uCAAuC,EAEhE,MADA,GAAG,UAAY,EACR,CACL,SAAU,CACR,EAAG,UAAY,EACjB,CACF,CACF,EACA,QAAQ,EAAc,EAAiC,CACrD,IAAM,EAAU,SAAS,cAAc,UAAU,EACjD,EAAQ,UAAY,EACpB,IAAM,EAAW,EAAQ,QACnB,EAAW,MAAM,KAAK,EAAS,UAAU,EAE/C,OADA,EAAO,aAAa,EAAU,CAAM,MACvB,CACX,IAAK,IAAM,KAAQ,EACb,EAAK,YAAY,EAAK,WAAW,YAAY,CAAI,CAEzD,CACF,CACF,CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { defineCollection, getCollection, getEntry, getEntries, renderEntryHTML, setContentRoot, withContentRoot, clearContentCache, type CollectionDefinition, type CollectionsConfig, type ContentEntry, } from "./collections.js";
|
|
2
|
+
export { parseDocument, parseFrontmatter, splitFrontmatter } from "./frontmatter.js";
|
|
3
|
+
export { renderMarkdown } from "./markdown.js";
|
|
4
|
+
export { raw } from "./raw.js";
|
|
5
|
+
export { createValidator, getZod, type SchemaValidator } from "./schema.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { defineCollection, getCollection, getEntry, getEntries, renderEntryHTML, setContentRoot, withContentRoot, clearContentCache, type CollectionDefinition, type CollectionsConfig, type ContentEntry, } from "./collections.js";
|
|
2
|
+
export { parseDocument, parseFrontmatter, splitFrontmatter } from "./frontmatter.js";
|
|
3
|
+
export { renderMarkdown } from "./markdown.js";
|
|
4
|
+
export { raw } from "./raw.js";
|
|
5
|
+
export { createValidator, getZod, type SchemaValidator } from "./schema.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, m as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "../collections-Dbc8aRLf.js";
|
|
2
|
+
import { ELUR_RENDER_PROTOCOL as m } from "@elurjs/core";
|
|
3
|
+
//#region src/content/raw.ts
|
|
4
|
+
function h(e) {
|
|
5
|
+
return {
|
|
6
|
+
__isElurTemplate: !0,
|
|
7
|
+
[m]: { renderServer: () => e },
|
|
8
|
+
mount(t) {
|
|
9
|
+
let n = typeof t == "string" ? document.querySelector(t) : t;
|
|
10
|
+
if (!n) throw Error("[elur-kit] raw(): container not found");
|
|
11
|
+
return n.innerHTML = e, { unmount() {
|
|
12
|
+
n.innerHTML = "";
|
|
13
|
+
} };
|
|
14
|
+
},
|
|
15
|
+
_render(t, n) {
|
|
16
|
+
let r = document.createElement("template");
|
|
17
|
+
r.innerHTML = e;
|
|
18
|
+
let i = r.content, a = Array.from(i.childNodes);
|
|
19
|
+
return t.insertBefore(i, n), () => {
|
|
20
|
+
for (let e of a) e.parentNode && e.parentNode.removeChild(e);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { f as clearContentCache, a as createValidator, s as defineCollection, u as getCollection, i as getEntries, e as getEntry, p as getZod, r as parseDocument, l as parseFrontmatter, h as raw, c as renderEntryHTML, n as renderMarkdown, d as setContentRoot, o as splitFrontmatter, t as withContentRoot };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/content/raw.ts"],"sourcesContent":["// --- raw() helper: inject pre-rendered HTML without escaping ---\n//\n// Elur templates escape interpolated values by default. When rendering\n// Markdown or other trusted HTML, we need to bypass that escaping. `raw()`\n// creates a ElurTemplate that inserts the HTML string directly, the same\n// pattern used by `island()` for server-side rendering.\n\nimport { ELUR_RENDER_PROTOCOL, type ElurTemplate } from \"@elurjs/core\";\n\n/**\n * Creates a ElurTemplate that renders the given HTML string without escaping.\n *\n * **Security:** Only use `raw()` with trusted content (e.g. Markdown you\n * authored, or HTML you generated and sanitized). Never use it with\n * user-supplied input without sanitization.\n */\nexport function raw(html: string): ElurTemplate {\n return {\n __isElurTemplate: true as const,\n [ELUR_RENDER_PROTOCOL]: {\n renderServer: () => html,\n },\n mount(container: Element | string) {\n const el = typeof container === \"string\" ? document.querySelector(container) : container;\n if (!el) throw new Error(\"[elur-kit] raw(): container not found\");\n el.innerHTML = html;\n return {\n unmount() {\n el.innerHTML = \"\";\n },\n };\n },\n _render(parent: Node, before: Node | null): () => void {\n const wrapper = document.createElement(\"template\");\n wrapper.innerHTML = html;\n const fragment = wrapper.content;\n const inserted = Array.from(fragment.childNodes);\n parent.insertBefore(fragment, before);\n return () => {\n for (const node of inserted) {\n if (node.parentNode) node.parentNode.removeChild(node);\n }\n };\n },\n } as unknown as ElurTemplate;\n}\n"],"mappings":";;;AAgBA,SAAgB,EAAI,GAA4B;CAC9C,OAAO;EACL,kBAAkB;GACjB,IAAuB,EACtB,oBAAoB,EACtB;EACA,MAAM,GAA6B;GACjC,IAAM,IAAK,OAAO,KAAc,WAAW,SAAS,cAAc,CAAS,IAAI;GAC/E,IAAI,CAAC,GAAI,MAAU,MAAM,uCAAuC;GAEhE,OADA,EAAG,YAAY,GACR,EACL,UAAU;IACR,EAAG,YAAY;GACjB,EACF;EACF;EACA,QAAQ,GAAc,GAAiC;GACrD,IAAM,IAAU,SAAS,cAAc,UAAU;GACjD,EAAQ,YAAY;GACpB,IAAM,IAAW,EAAQ,SACnB,IAAW,MAAM,KAAK,EAAS,UAAU;GAE/C,OADA,EAAO,aAAa,GAAU,CAAM,SACvB;IACX,KAAK,IAAM,KAAQ,GACjB,AAAI,EAAK,cAAY,EAAK,WAAW,YAAY,CAAI;GAEzD;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ElurTemplate } from "@elurjs/core";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a ElurTemplate that renders the given HTML string without escaping.
|
|
4
|
+
*
|
|
5
|
+
* **Security:** Only use `raw()` with trusted content (e.g. Markdown you
|
|
6
|
+
* authored, or HTML you generated and sanitized). Never use it with
|
|
7
|
+
* user-supplied input without sanitization.
|
|
8
|
+
*/
|
|
9
|
+
export declare function raw(html: string): ElurTemplate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ElurTemplate } from "@elurjs/core";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a ElurTemplate that renders the given HTML string without escaping.
|
|
4
|
+
*
|
|
5
|
+
* **Security:** Only use `raw()` with trusted content (e.g. Markdown you
|
|
6
|
+
* authored, or HTML you generated and sanitized). Never use it with
|
|
7
|
+
* user-supplied input without sanitization.
|
|
8
|
+
*/
|
|
9
|
+
export declare function raw(html: string): ElurTemplate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SchemaValidator {
|
|
2
|
+
(data: unknown, filePath: string): Record<string, unknown>;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Creates a validator function from a schema object. If the schema is a zod
|
|
6
|
+
* schema (has a `.parse` method), it is used directly. If `zod` is not
|
|
7
|
+
* installed but a schema is provided, validation is skipped with a warning.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createValidator(schema: unknown): SchemaValidator | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Ensures `zod` is available and re-exports it. Used by `defineCollection`
|
|
12
|
+
* consumers who want to write `z.object(...)` schemas.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getZod(): Promise<any>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SchemaValidator {
|
|
2
|
+
(data: unknown, filePath: string): Record<string, unknown>;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Creates a validator function from a schema object. If the schema is a zod
|
|
6
|
+
* schema (has a `.parse` method), it is used directly. If `zod` is not
|
|
7
|
+
* installed but a schema is provided, validation is skipped with a warning.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createValidator(schema: unknown): SchemaValidator | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Ensures `zod` is available and re-exports it. Used by `defineCollection`
|
|
12
|
+
* consumers who want to write `z.object(...)` schemas.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getZod(): Promise<any>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=t({ActionFailure:()=>r,RedirectResponse:()=>i,fail:()=>a,isActionFailure:()=>s,isRedirectResponse:()=>c,publicErrorResponse:()=>u,redirect:()=>o,toPublicErrorInfo:()=>l}),r=class{status;data;__elur_js_action_failure=!0;constructor(e,t){this.status=e,this.data=t}},i=class{status;location;__elur_js_action_redirect=!0;constructor(e,t){this.status=e,this.location=t}};function a(e,t){return typeof e==`number`?new r(e,t):new r(t??400,e)}function o(e,t){return typeof e==`number`?new i(e,t):new i(t??303,e)}function s(e){return typeof e==`object`&&!!e&&e.__elur_js_action_failure===!0}function c(e){return typeof e==`object`&&!!e&&e.__elur_js_action_redirect===!0}function l(e,t={}){let n=`INTERNAL_SERVER_ERROR`;return t.includeDetail&&e instanceof Error&&e.message?{code:n,status:500,message:e.message}:{code:n,status:500,message:`Internal Server Error`}}function u(e,t={}){let n=l(e,t),r={"Content-Type":`application/json; charset=utf-8`,"Cache-Control":`no-store`};return t.requestId&&(r[`X-Request-Id`]=t.requestId),new Response(JSON.stringify({error:n}),{status:n.status,headers:r})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=errors-0X7pCFNU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-0X7pCFNU.cjs","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["/**\n * Represents a failed action result. Returned by `fail()` from server actions.\n *\n * The `__elur_js_action_failure` marker is set on the instance so the server can\n * detect it even when the value crosses a bundling boundary (e.g. the CLI is\n * bundled separately from the user's action modules).\n */\nexport class ActionFailure<TData = unknown> {\n readonly __elur_js_action_failure = true;\n constructor(\n public status: number,\n public data: TData,\n ) {}\n}\n\n/**\n * Represents a redirect returned by a server action. Returned by `redirect()`.\n */\nexport class RedirectResponse {\n readonly __elur_js_action_redirect = true;\n constructor(\n public status: number,\n public location: string,\n ) {}\n}\n\n/**\n * Helper to return a validation/error response from a server action.\n *\n * Both argument orders are accepted:\n *\n * ```ts\n * return fail(400, { email: \"Invalid email\" });\n * return fail({ email: \"Invalid email\" }, 400);\n * return fail({ email: \"Invalid email\" }); // defaults to status 400\n * ```\n */\nexport function fail<TData>(\n statusOrData: number | TData,\n dataOrStatus?: TData | number,\n): ActionFailure<unknown> {\n if (typeof statusOrData === \"number\") {\n return new ActionFailure(statusOrData, dataOrStatus as TData);\n }\n return new ActionFailure((dataOrStatus as number) ?? 400, statusOrData);\n}\n\n/**\n * Helper to return a redirect from a server action.\n *\n * Both argument orders are accepted:\n *\n * ```ts\n * return redirect(303, \"/login\");\n * return redirect(\"/login\"); // defaults to status 303\n * ```\n */\nexport function redirect(\n statusOrLocation: number | string,\n locationOrStatus?: string | number,\n): RedirectResponse {\n if (typeof statusOrLocation === \"number\") {\n return new RedirectResponse(statusOrLocation, locationOrStatus as string);\n }\n return new RedirectResponse((locationOrStatus as number) ?? 303, statusOrLocation);\n}\n\n/**\n * Type guard for action failures. Uses the marker field so it works across\n * bundling boundaries where `instanceof` fails.\n */\nexport function isActionFailure(value: unknown): value is ActionFailure {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { __elur_js_action_failure?: unknown }).__elur_js_action_failure === true\n );\n}\n\n/**\n * Type guard for redirects. Uses the marker field so it works across bundling\n * boundaries where `instanceof` fails.\n */\nexport function isRedirectResponse(value: unknown): value is RedirectResponse {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { __elur_js_action_redirect?: unknown }).__elur_js_action_redirect === true\n );\n}\n\n// --- Public error sanitization (production-safe 500 responses) ---\n\n/**\n * A stable, publicly safe error description. Never includes stacks, internal\n * paths or messages that could leak secrets or filesystem details.\n */\nexport interface PublicErrorInfo {\n /** Stable machine-readable code for the response body. */\n code: string;\n /** Stable public message. In non-production this may include the raw message. */\n message: string;\n status: number;\n}\n\n/**\n * Maps an arbitrary thrown value to a public-safe error info. By default the\n * public message is generic; `includeDetail` (dev/verbose mode) appends the\n * original `Error.message` for local debugging.\n */\nexport function toPublicErrorInfo(error: unknown, options: { includeDetail?: boolean } = {}): PublicErrorInfo {\n const code = \"INTERNAL_SERVER_ERROR\";\n const status = 500;\n if (options.includeDetail && error instanceof Error && error.message) {\n return { code, status, message: error.message };\n }\n return { code, status, message: \"Internal Server Error\" };\n}\n\n/**\n * Builds a production-safe JSON error Response. Logs the raw error separately\n * (never reflected in the response body) and keeps the request id header.\n */\nexport function publicErrorResponse(\n error: unknown,\n options: { includeDetail?: boolean; requestId?: string } = {},\n): Response {\n const info = toPublicErrorInfo(error, options);\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Cache-Control\": \"no-store\",\n };\n if (options.requestId) headers[\"X-Request-Id\"] = options.requestId;\n return new Response(JSON.stringify({ error: info }), {\n status: info.status,\n headers,\n });\n}\n\n/** True when the error should be re-thrown as control flow instead of a 500. */\nexport function isFirstClassResponse(error: unknown): error is Response {\n return typeof Response !== \"undefined\" && error instanceof Response;\n}\n"],"mappings":"iUAOa,EAAb,KAA4C,CAGjC,OACA,KAHT,yBAAoC,GACpC,YACE,EACA,EACA,CAFO,KAAA,OAAA,EACA,KAAA,KAAA,CACN,CACL,EAKa,EAAb,KAA8B,CAGnB,OACA,SAHT,0BAAqC,GACrC,YACE,EACA,EACA,CAFO,KAAA,OAAA,EACA,KAAA,SAAA,CACN,CACL,EAaA,SAAgB,EACd,EACA,EACwB,CAIxB,OAHI,OAAO,GAAiB,SACnB,IAAI,EAAc,EAAc,CAAqB,EAEvD,IAAI,EAAe,GAA2B,IAAK,CAAY,CACxE,CAYA,SAAgB,EACd,EACA,EACkB,CAIlB,OAHI,OAAO,GAAqB,SACvB,IAAI,EAAiB,EAAkB,CAA0B,EAEnE,IAAI,EAAkB,GAA+B,IAAK,CAAgB,CACnF,CAMA,SAAgB,EAAgB,EAAwC,CACtE,OACE,OAAO,GAAU,YACjB,GACC,EAAiD,2BAA6B,EAEnF,CAMA,SAAgB,EAAmB,EAA2C,CAC5E,OACE,OAAO,GAAU,YACjB,GACC,EAAkD,4BAA8B,EAErF,CAqBA,SAAgB,EAAkB,EAAgB,EAAuC,CAAC,EAAoB,CAC5G,IAAM,EAAO,wBAKb,OAHI,EAAQ,eAAiB,aAAiB,OAAS,EAAM,QACpD,CAAE,OAAM,WAAQ,QAAS,EAAM,OAAQ,EAEzC,CAAE,OAAM,WAAQ,QAAS,uBAAwB,CAC1D,CAMA,SAAgB,EACd,EACA,EAA2D,CAAC,EAClD,CACV,IAAM,EAAO,EAAkB,EAAO,CAAO,EACvC,EAAkC,CACtC,eAAgB,kCAChB,gBAAiB,UACnB,EAEA,OADI,EAAQ,YAAW,EAAQ,gBAAkB,EAAQ,WAClD,IAAI,SAAS,KAAK,UAAU,CAAE,MAAO,CAAK,CAAC,EAAG,CACnD,OAAQ,EAAK,OACb,SACF,CAAC,CACH"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, n = /* @__PURE__ */ t({
|
|
10
|
+
ActionFailure: () => r,
|
|
11
|
+
RedirectResponse: () => i,
|
|
12
|
+
fail: () => a,
|
|
13
|
+
isActionFailure: () => s,
|
|
14
|
+
isRedirectResponse: () => c,
|
|
15
|
+
publicErrorResponse: () => u,
|
|
16
|
+
redirect: () => o,
|
|
17
|
+
toPublicErrorInfo: () => l
|
|
18
|
+
}), r = class {
|
|
19
|
+
status;
|
|
20
|
+
data;
|
|
21
|
+
__elur_js_action_failure = !0;
|
|
22
|
+
constructor(e, t) {
|
|
23
|
+
this.status = e, this.data = t;
|
|
24
|
+
}
|
|
25
|
+
}, i = class {
|
|
26
|
+
status;
|
|
27
|
+
location;
|
|
28
|
+
__elur_js_action_redirect = !0;
|
|
29
|
+
constructor(e, t) {
|
|
30
|
+
this.status = e, this.location = t;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function a(e, t) {
|
|
34
|
+
return typeof e == "number" ? new r(e, t) : new r(t ?? 400, e);
|
|
35
|
+
}
|
|
36
|
+
function o(e, t) {
|
|
37
|
+
return typeof e == "number" ? new i(e, t) : new i(t ?? 303, e);
|
|
38
|
+
}
|
|
39
|
+
function s(e) {
|
|
40
|
+
return typeof e == "object" && !!e && e.__elur_js_action_failure === !0;
|
|
41
|
+
}
|
|
42
|
+
function c(e) {
|
|
43
|
+
return typeof e == "object" && !!e && e.__elur_js_action_redirect === !0;
|
|
44
|
+
}
|
|
45
|
+
function l(e, t = {}) {
|
|
46
|
+
let n = "INTERNAL_SERVER_ERROR";
|
|
47
|
+
return t.includeDetail && e instanceof Error && e.message ? {
|
|
48
|
+
code: n,
|
|
49
|
+
status: 500,
|
|
50
|
+
message: e.message
|
|
51
|
+
} : {
|
|
52
|
+
code: n,
|
|
53
|
+
status: 500,
|
|
54
|
+
message: "Internal Server Error"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function u(e, t = {}) {
|
|
58
|
+
let n = l(e, t), r = {
|
|
59
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
60
|
+
"Cache-Control": "no-store"
|
|
61
|
+
};
|
|
62
|
+
return t.requestId && (r["X-Request-Id"] = t.requestId), new Response(JSON.stringify({ error: n }), {
|
|
63
|
+
status: n.status,
|
|
64
|
+
headers: r
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { s as a, o as c, a as i, l, i as n, c as o, n as r, u as s, r as t, t as u };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=errors-ePYxDlhU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-ePYxDlhU.js","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["/**\n * Represents a failed action result. Returned by `fail()` from server actions.\n *\n * The `__elur_js_action_failure` marker is set on the instance so the server can\n * detect it even when the value crosses a bundling boundary (e.g. the CLI is\n * bundled separately from the user's action modules).\n */\nexport class ActionFailure<TData = unknown> {\n readonly __elur_js_action_failure = true;\n constructor(\n public status: number,\n public data: TData,\n ) {}\n}\n\n/**\n * Represents a redirect returned by a server action. Returned by `redirect()`.\n */\nexport class RedirectResponse {\n readonly __elur_js_action_redirect = true;\n constructor(\n public status: number,\n public location: string,\n ) {}\n}\n\n/**\n * Helper to return a validation/error response from a server action.\n *\n * Both argument orders are accepted:\n *\n * ```ts\n * return fail(400, { email: \"Invalid email\" });\n * return fail({ email: \"Invalid email\" }, 400);\n * return fail({ email: \"Invalid email\" }); // defaults to status 400\n * ```\n */\nexport function fail<TData>(\n statusOrData: number | TData,\n dataOrStatus?: TData | number,\n): ActionFailure<unknown> {\n if (typeof statusOrData === \"number\") {\n return new ActionFailure(statusOrData, dataOrStatus as TData);\n }\n return new ActionFailure((dataOrStatus as number) ?? 400, statusOrData);\n}\n\n/**\n * Helper to return a redirect from a server action.\n *\n * Both argument orders are accepted:\n *\n * ```ts\n * return redirect(303, \"/login\");\n * return redirect(\"/login\"); // defaults to status 303\n * ```\n */\nexport function redirect(\n statusOrLocation: number | string,\n locationOrStatus?: string | number,\n): RedirectResponse {\n if (typeof statusOrLocation === \"number\") {\n return new RedirectResponse(statusOrLocation, locationOrStatus as string);\n }\n return new RedirectResponse((locationOrStatus as number) ?? 303, statusOrLocation);\n}\n\n/**\n * Type guard for action failures. Uses the marker field so it works across\n * bundling boundaries where `instanceof` fails.\n */\nexport function isActionFailure(value: unknown): value is ActionFailure {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { __elur_js_action_failure?: unknown }).__elur_js_action_failure === true\n );\n}\n\n/**\n * Type guard for redirects. Uses the marker field so it works across bundling\n * boundaries where `instanceof` fails.\n */\nexport function isRedirectResponse(value: unknown): value is RedirectResponse {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { __elur_js_action_redirect?: unknown }).__elur_js_action_redirect === true\n );\n}\n\n// --- Public error sanitization (production-safe 500 responses) ---\n\n/**\n * A stable, publicly safe error description. Never includes stacks, internal\n * paths or messages that could leak secrets or filesystem details.\n */\nexport interface PublicErrorInfo {\n /** Stable machine-readable code for the response body. */\n code: string;\n /** Stable public message. In non-production this may include the raw message. */\n message: string;\n status: number;\n}\n\n/**\n * Maps an arbitrary thrown value to a public-safe error info. By default the\n * public message is generic; `includeDetail` (dev/verbose mode) appends the\n * original `Error.message` for local debugging.\n */\nexport function toPublicErrorInfo(error: unknown, options: { includeDetail?: boolean } = {}): PublicErrorInfo {\n const code = \"INTERNAL_SERVER_ERROR\";\n const status = 500;\n if (options.includeDetail && error instanceof Error && error.message) {\n return { code, status, message: error.message };\n }\n return { code, status, message: \"Internal Server Error\" };\n}\n\n/**\n * Builds a production-safe JSON error Response. Logs the raw error separately\n * (never reflected in the response body) and keeps the request id header.\n */\nexport function publicErrorResponse(\n error: unknown,\n options: { includeDetail?: boolean; requestId?: string } = {},\n): Response {\n const info = toPublicErrorInfo(error, options);\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Cache-Control\": \"no-store\",\n };\n if (options.requestId) headers[\"X-Request-Id\"] = options.requestId;\n return new Response(JSON.stringify({ error: info }), {\n status: info.status,\n headers,\n });\n}\n\n/** True when the error should be re-thrown as control flow instead of a 500. */\nexport function isFirstClassResponse(error: unknown): error is Response {\n return typeof Response !== \"undefined\" && error instanceof Response;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;IAOa,IAAb,MAA4C;CAGjC;CACA;CAHT,2BAAoC;CACpC,YACE,GACA,GACA;EADO,AADA,KAAA,SAAA,GACA,KAAA,OAAA;CACN;AACL,GAKa,IAAb,MAA8B;CAGnB;CACA;CAHT,4BAAqC;CACrC,YACE,GACA,GACA;EADO,AADA,KAAA,SAAA,GACA,KAAA,WAAA;CACN;AACL;AAaA,SAAgB,EACd,GACA,GACwB;CAIxB,OAHI,OAAO,KAAiB,WACnB,IAAI,EAAc,GAAc,CAAqB,IAEvD,IAAI,EAAe,KAA2B,KAAK,CAAY;AACxE;AAYA,SAAgB,EACd,GACA,GACkB;CAIlB,OAHI,OAAO,KAAqB,WACvB,IAAI,EAAiB,GAAkB,CAA0B,IAEnE,IAAI,EAAkB,KAA+B,KAAK,CAAgB;AACnF;AAMA,SAAgB,EAAgB,GAAwC;CACtE,OACE,OAAO,KAAU,cACjB,KACC,EAAiD,6BAA6B;AAEnF;AAMA,SAAgB,EAAmB,GAA2C;CAC5E,OACE,OAAO,KAAU,cACjB,KACC,EAAkD,8BAA8B;AAErF;AAqBA,SAAgB,EAAkB,GAAgB,IAAuC,CAAC,GAAoB;CAC5G,IAAM,IAAO;CAKb,OAHI,EAAQ,iBAAiB,aAAiB,SAAS,EAAM,UACpD;EAAE;EAAM;EAAQ,SAAS,EAAM;CAAQ,IAEzC;EAAE;EAAM;EAAQ,SAAS;CAAwB;AAC1D;AAMA,SAAgB,EACd,GACA,IAA2D,CAAC,GAClD;CACV,IAAM,IAAO,EAAkB,GAAO,CAAO,GACvC,IAAkC;EACtC,gBAAgB;EAChB,iBAAiB;CACnB;CAEA,OADI,EAAQ,cAAW,EAAQ,kBAAkB,EAAQ,YAClD,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,EAAK,CAAC,GAAG;EACnD,QAAQ,EAAK;EACb;CACF,CAAC;AACH"}
|