@demiurgejs/core 0.2.0-beta.2 → 0.2.0-beta.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/README.md +13 -11
- package/bin/demiurge.mjs +30 -12
- package/dist/adapter/testing.js.map +1 -1
- package/dist/browser/file-router.d.ts +388 -5
- package/dist/browser/file-router.d.ts.map +1 -1
- package/dist/browser/focus.d.ts +20 -0
- package/dist/browser/focus.d.ts.map +1 -0
- package/dist/browser/index.d.ts +7 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/mutation-action.d.ts +81 -0
- package/dist/browser/mutation-action.d.ts.map +1 -0
- package/dist/chunks/document-shell-CpJnFtSC.js +36 -0
- package/dist/chunks/document-shell-CpJnFtSC.js.map +1 -0
- package/dist/chunks/env-startup-DOBYWlZD.js +257 -0
- package/dist/chunks/env-startup-DOBYWlZD.js.map +1 -0
- package/dist/chunks/{image-codec-BGTx_t5K.js → image-codec-BmzWnH6W.js} +2 -2
- package/dist/chunks/{image-codec-BGTx_t5K.js.map → image-codec-BmzWnH6W.js.map} +1 -1
- package/dist/chunks/{images-B9MqcjSA.js → images-BQ80950B.js} +99 -91
- package/dist/chunks/images-BQ80950B.js.map +1 -0
- package/dist/chunks/index-BVk9zWbe.js +832 -0
- package/dist/chunks/index-BVk9zWbe.js.map +1 -0
- package/dist/chunks/manifest-vO6c0G0W.js +19 -0
- package/dist/chunks/manifest-vO6c0G0W.js.map +1 -0
- package/dist/chunks/plugin-BQgMiHxa.js +1827 -0
- package/dist/chunks/plugin-BQgMiHxa.js.map +1 -0
- package/dist/chunks/session-store-ChModVcq.js +92 -0
- package/dist/chunks/session-store-ChModVcq.js.map +1 -0
- package/dist/chunks/static-files-ehaD1kE7.js +51 -0
- package/dist/chunks/static-files-ehaD1kE7.js.map +1 -0
- package/dist/chunks/{streaming-BQ1bykDo.js → streaming-BEbPN7Uk.js} +163 -163
- package/dist/chunks/streaming-BEbPN7Uk.js.map +1 -0
- package/dist/chunks/testing-DueXbMo4.js +4167 -0
- package/dist/chunks/testing-DueXbMo4.js.map +1 -0
- package/dist/chunks/vite-DO70kZA6.js +259 -0
- package/dist/chunks/vite-DO70kZA6.js.map +1 -0
- package/dist/cli.d.ts +17 -25
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +159 -124
- package/dist/cli.js.map +1 -1
- package/dist/config/define.d.ts +3 -0
- package/dist/config/define.d.ts.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +78 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load.d.ts +12 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/types.d.ts +64 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/validate.d.ts +9 -0
- package/dist/config/validate.d.ts.map +1 -0
- package/dist/config/vite.d.ts +12 -0
- package/dist/config/vite.d.ts.map +1 -0
- package/dist/data/cache.d.ts +10 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/idempotency.d.ts.map +1 -1
- package/dist/data/index.d.ts +3 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/testing.d.ts.map +1 -1
- package/dist/data/testing.js +94 -72
- package/dist/data/testing.js.map +1 -1
- package/dist/data/tiered.d.ts +7 -0
- package/dist/data/tiered.d.ts.map +1 -0
- package/dist/deployment/testing.d.ts +25 -0
- package/dist/deployment/testing.d.ts.map +1 -0
- package/dist/deployment/testing.js +171 -0
- package/dist/deployment/testing.js.map +1 -0
- package/dist/document/deferred-scripts.d.ts.map +1 -1
- package/dist/document/hydration.d.ts +9 -0
- package/dist/document/hydration.d.ts.map +1 -1
- package/dist/document/index.d.ts +5 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/metadata.d.ts +8 -0
- package/dist/document/metadata.d.ts.map +1 -1
- package/dist/document/navigation.d.ts +28 -0
- package/dist/document/navigation.d.ts.map +1 -0
- package/dist/document/render.d.ts +3 -1
- package/dist/document/render.d.ts.map +1 -1
- package/dist/document/seo.d.ts.map +1 -1
- package/dist/document/trusted-types.d.ts +10 -0
- package/dist/document/trusted-types.d.ts.map +1 -0
- package/dist/edge/assets.d.ts.map +1 -1
- package/dist/edge/index.js +55 -73
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +15 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2078 -573
- package/dist/index.js.map +1 -1
- package/dist/internal/testing.js +11 -11
- package/dist/kv/index.d.ts +4 -0
- package/dist/kv/index.d.ts.map +1 -1
- package/dist/kv/index.js +180 -60
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/rate-limit-store.d.ts +8 -0
- package/dist/kv/rate-limit-store.d.ts.map +1 -0
- package/dist/kv/session-store.d.ts +20 -0
- package/dist/kv/session-store.d.ts.map +1 -0
- package/dist/kv/store.d.ts.map +1 -1
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/image.d.ts.map +1 -1
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +251 -178
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +47 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/static.d.ts.map +1 -1
- package/dist/node/streaming.d.ts.map +1 -1
- package/dist/platform/fonts.d.ts.map +1 -1
- package/dist/platform/image-url.d.ts.map +1 -1
- package/dist/platform/images.d.ts.map +1 -1
- package/dist/platform/index.d.ts +5 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/observability.d.ts +2 -1
- package/dist/platform/observability.d.ts.map +1 -1
- package/dist/platform/url.d.ts +19 -0
- package/dist/platform/url.d.ts.map +1 -0
- package/dist/platform/web-vitals-client.d.ts +32 -0
- package/dist/platform/web-vitals-client.d.ts.map +1 -0
- package/dist/platform/web-vitals.d.ts +78 -0
- package/dist/platform/web-vitals.d.ts.map +1 -0
- package/dist/redis/index.d.ts +4 -0
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +209 -54
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/rate-limit-store.d.ts +8 -0
- package/dist/redis/rate-limit-store.d.ts.map +1 -0
- package/dist/redis/session-store.d.ts +9 -0
- package/dist/redis/session-store.d.ts.map +1 -0
- package/dist/redis/store.d.ts.map +1 -1
- package/dist/route/index.d.ts +2 -2
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/middleware.d.ts.map +1 -1
- package/dist/route/mutation.d.ts +97 -0
- package/dist/route/mutation.d.ts.map +1 -0
- package/dist/route/response.d.ts.map +1 -1
- package/dist/route/types.d.ts +6 -1
- package/dist/route/types.d.ts.map +1 -1
- package/dist/router/index.d.ts +1 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/manifest.d.ts +9 -0
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/router/navigation-data.d.ts +9 -1
- package/dist/router/navigation-data.d.ts.map +1 -1
- package/dist/routing/generate.d.ts +3 -0
- package/dist/routing/generate.d.ts.map +1 -1
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/locale.d.ts +43 -0
- package/dist/routing/locale.d.ts.map +1 -0
- package/dist/routing/types.d.ts +12 -0
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/security/cookie-session.d.ts +43 -0
- package/dist/security/cookie-session.d.ts.map +1 -0
- package/dist/security/cookies.d.ts +26 -0
- package/dist/security/cookies.d.ts.map +1 -0
- package/dist/security/csrf.d.ts +1 -1
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +15 -0
- package/dist/security/env-startup.d.ts.map +1 -0
- package/dist/security/env.d.ts +25 -6
- package/dist/security/env.d.ts.map +1 -1
- package/dist/security/fetch-metadata.d.ts +29 -0
- package/dist/security/fetch-metadata.d.ts.map +1 -0
- package/dist/security/index.d.ts +14 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/policy.d.ts.map +1 -1
- package/dist/security/rate-limit.d.ts +6 -3
- package/dist/security/rate-limit.d.ts.map +1 -1
- package/dist/security/report.d.ts.map +1 -1
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/session-manager.d.ts +32 -0
- package/dist/security/session-manager.d.ts.map +1 -0
- package/dist/security/session-store.d.ts +51 -0
- package/dist/security/session-store.d.ts.map +1 -0
- package/dist/security/testing.d.ts +10 -0
- package/dist/security/testing.d.ts.map +1 -0
- package/dist/security/testing.js +145 -0
- package/dist/security/testing.js.map +1 -0
- package/dist/security/types.d.ts +73 -3
- package/dist/security/types.d.ts.map +1 -1
- package/dist/server/document-shell.d.ts.map +1 -1
- package/dist/server/errors.d.ts +1 -0
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/not-found.d.ts +1 -0
- package/dist/server/not-found.d.ts.map +1 -1
- package/dist/server/render-tree.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +10 -2
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server/request-metadata.d.ts +1 -0
- package/dist/server/request-metadata.d.ts.map +1 -1
- package/dist/server/ssr.d.ts +2 -0
- package/dist/server/ssr.d.ts.map +1 -1
- package/dist/static/index.d.ts +2 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +380 -363
- package/dist/static/index.js.map +1 -1
- package/dist/static/preview.d.ts.map +1 -1
- package/dist/static/vercel.d.ts +11 -2
- package/dist/static/vercel.d.ts.map +1 -1
- package/dist/static-files.d.ts +12 -0
- package/dist/static-files.d.ts.map +1 -1
- package/dist/type-guards.d.ts +19 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/vite/env-boundary.d.ts +14 -0
- package/dist/vite/env-boundary.d.ts.map +1 -0
- package/dist/vite/index.d.ts +8 -3
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +22 -1196
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugin.d.ts +8 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/policy-verification.d.ts.map +1 -1
- package/dist/vite/route-audit.d.ts +50 -0
- package/dist/vite/route-audit.d.ts.map +1 -0
- package/package.json +19 -6
- package/dist/chunks/document-shell-D1xo6cEA.js +0 -35
- package/dist/chunks/document-shell-D1xo6cEA.js.map +0 -1
- package/dist/chunks/images-B9MqcjSA.js.map +0 -1
- package/dist/chunks/request-metadata-D5NrT8ks.js +0 -642
- package/dist/chunks/request-metadata-D5NrT8ks.js.map +0 -1
- package/dist/chunks/static-files-DUjHw-4H.js +0 -11
- package/dist/chunks/static-files-DUjHw-4H.js.map +0 -1
- package/dist/chunks/streaming-BQ1bykDo.js.map +0 -1
- package/dist/chunks/testing-B_iMFYz_.js +0 -3321
- package/dist/chunks/testing-B_iMFYz_.js.map +0 -1
- package/dist/route/action.d.ts +0 -33
- package/dist/route/action.d.ts.map +0 -1
package/dist/vite/index.js
CHANGED
|
@@ -1,1199 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdir as Et, writeFile as Dt, readdir as ht, readFile as gt } from "node:fs/promises";
|
|
3
|
-
import { dirname as q, resolve as w, relative as R, sep as S, join as Nt } from "node:path";
|
|
4
|
-
import Pt from "magic-string";
|
|
5
|
-
import { transformWithEsbuild as Ot, parseAst as Y } from "vite";
|
|
6
|
-
import { e as Mt, f as It } from "../chunks/request-metadata-D5NrT8ks.js";
|
|
7
|
-
import { v as _t, f as Ct, g as jt, s as F, i as B, r as Ft, j as Tt, h as At, k as Vt } from "../chunks/testing-B_iMFYz_.js";
|
|
8
|
-
import "react";
|
|
9
|
-
import "react-dom/server";
|
|
10
|
-
import "react/jsx-runtime";
|
|
11
|
-
import { c as Lt, t as X, U as Z, w as tt, b as T, d as kt, e as Wt } from "../chunks/streaming-BQ1bykDo.js";
|
|
12
|
-
import { p as Ht } from "../chunks/images-B9MqcjSA.js";
|
|
13
|
-
const $ = "@demiurgejs/core";
|
|
14
|
-
async function Jt(t) {
|
|
15
|
-
const e = await Bt(t.routesDir), n = e.map((i) => zt(t, i)).filter((i) => !!i), o = e.map((i) => Ut(t.routesDir, i, n)).filter((i) => !!i).sort((i, s) => i.pattern.localeCompare(s.pattern)), r = qt(o, n);
|
|
16
|
-
return await Et(q(t.outputFile), { recursive: !0 }), await Dt(t.outputFile, r), {
|
|
17
|
-
routes: o,
|
|
18
|
-
source: r
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
async function Bt(t) {
|
|
22
|
-
return (await ht(t, {
|
|
23
|
-
recursive: !0,
|
|
24
|
-
withFileTypes: !0
|
|
25
|
-
})).filter((n) => n.isFile() && /\.tsx?$/.test(n.name)).map((n) => w(n.parentPath, n.name));
|
|
26
|
-
}
|
|
27
|
-
function Ut(t, e, n) {
|
|
28
|
-
const r = R(t, e).split(S).join("/").replace(/\.tsx?$/, "").split("/");
|
|
29
|
-
if (r.at(-1)?.startsWith("@"))
|
|
30
|
-
return null;
|
|
31
|
-
const s = r.flatMap((c) => et(c) ? [] : c === "index" ? [] : c.startsWith("[...") && c.endsWith("]") ? [c] : c.startsWith("[") && c.endsWith("]") ? [c] : [c]), a = r.flatMap((c) => et(c) ? [] : c.startsWith("[...") && c.endsWith("]") ? [c.slice(4, -1)] : c.startsWith("[") && c.endsWith("]") ? [c.slice(1, -1)] : []);
|
|
32
|
-
return {
|
|
33
|
-
contextMiddleware: n.filter((c) => Gt(c.fileSegments, r)).map((c) => n.indexOf(c)),
|
|
34
|
-
fileSegments: r,
|
|
35
|
-
pathVars: a,
|
|
36
|
-
pattern: `/${s.join("/")}`.replace(/\/$/, "") || "/"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function zt(t, e) {
|
|
40
|
-
const o = R(t.routesDir, e).split(S).join("/").replace(/\.tsx?$/, "").split("/");
|
|
41
|
-
if (o.at(-1) !== "@middleware")
|
|
42
|
-
return null;
|
|
43
|
-
let r = R(q(t.outputFile), e).split(S).join("/").replace(/\.tsx?$/, "");
|
|
44
|
-
return r.startsWith(".") || (r = `./${r}`), { file: e, fileSegments: o.slice(0, -1), importPath: r };
|
|
45
|
-
}
|
|
46
|
-
function Gt(t, e) {
|
|
47
|
-
return t.every(
|
|
48
|
-
(n, o) => e[o] === n
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
function et(t) {
|
|
52
|
-
return t.startsWith("(") && t.endsWith(")");
|
|
53
|
-
}
|
|
54
|
-
function qt(t, e) {
|
|
55
|
-
return `// Generated by Demiurge. Do not edit by hand.
|
|
56
|
-
import "${$}";
|
|
57
|
-
import type { MiddlewareContextOf, PathValue } from "${$}";
|
|
58
|
-
${e.map(Yt).join(`
|
|
59
|
-
`)}
|
|
60
|
-
|
|
61
|
-
${e.map((n, o) => Kt(o)).join(`
|
|
62
|
-
`)}
|
|
63
|
-
|
|
64
|
-
declare module "${$}" {
|
|
65
|
-
interface RoutePathVars {
|
|
66
|
-
${t.map(Qt).join(`
|
|
67
|
-
`)}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
interface RouteConcretePaths {
|
|
71
|
-
${t.map(Xt).join(`
|
|
72
|
-
`)}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
interface RouteRequestContexts {
|
|
76
|
-
${t.map(Zt).join(`
|
|
77
|
-
`)}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export {};
|
|
82
|
-
`;
|
|
83
|
-
}
|
|
84
|
-
function Yt(t, e) {
|
|
85
|
-
return `type __DemiurgeMiddleware${e} = typeof import(${JSON.stringify(t.importPath)}) extends { middleware?: infer T } ? T : never;`;
|
|
86
|
-
}
|
|
87
|
-
function Kt(t) {
|
|
88
|
-
return `type __DemiurgeMiddlewareContext${t} = MiddlewareContextOf<__DemiurgeMiddleware${t}>;`;
|
|
89
|
-
}
|
|
90
|
-
function Qt(t) {
|
|
91
|
-
if (t.pathVars.length === 0)
|
|
92
|
-
return ` ${JSON.stringify(t.pattern)}: {};`;
|
|
93
|
-
const e = t.pathVars.map((n) => `${n}: PathValue`).join("; ");
|
|
94
|
-
return ` ${JSON.stringify(t.pattern)}: { ${e} };`;
|
|
95
|
-
}
|
|
96
|
-
function Xt(t) {
|
|
97
|
-
return ` ${JSON.stringify(t.pattern)}: ${te(t.pattern)};`;
|
|
98
|
-
}
|
|
99
|
-
function Zt(t) {
|
|
100
|
-
const e = t.contextMiddleware.map((o) => `__DemiurgeMiddlewareContext${o}`), n = e.length > 0 ? e.join(" & ") : "Record<never, never>";
|
|
101
|
-
return ` ${JSON.stringify(t.pattern)}: ${n};`;
|
|
102
|
-
}
|
|
103
|
-
function te(t) {
|
|
104
|
-
return t.includes("[") ? `\`${t.split(/(\[\.\.\.[^\]]+\]|\[[^\]]+\])/g).filter(Boolean).map((n) => n.startsWith("[") ? "${PathValue}" : ee(n)).join("")}\`` : JSON.stringify(t);
|
|
105
|
-
}
|
|
106
|
-
function ee(t) {
|
|
107
|
-
return t.replace(/[`$\\]/g, "\\$&");
|
|
108
|
-
}
|
|
109
|
-
const re = [
|
|
110
|
-
"GET",
|
|
111
|
-
"POST",
|
|
112
|
-
"PUT",
|
|
113
|
-
"PATCH",
|
|
114
|
-
"DELETE",
|
|
115
|
-
"OPTIONS",
|
|
116
|
-
"HEAD"
|
|
117
|
-
], ne = /* @__PURE__ */ new Set([
|
|
118
|
-
"action",
|
|
119
|
-
"html",
|
|
120
|
-
"json",
|
|
121
|
-
"jsonl",
|
|
122
|
-
"notFound",
|
|
123
|
-
"redirect",
|
|
124
|
-
"response",
|
|
125
|
-
"sse",
|
|
126
|
-
"stream",
|
|
127
|
-
"text"
|
|
128
|
-
]);
|
|
129
|
-
async function oe(t) {
|
|
130
|
-
const e = await gt(t, "utf8");
|
|
131
|
-
return await ie(e, t);
|
|
132
|
-
}
|
|
133
|
-
async function ie(t, e) {
|
|
134
|
-
const n = e.endsWith(".tsx") ? "tsx" : "ts", o = await Ot(t, e, {
|
|
135
|
-
format: "esm",
|
|
136
|
-
loader: n,
|
|
137
|
-
target: "esnext"
|
|
138
|
-
}), r = se(o.code);
|
|
139
|
-
return fe(r, e);
|
|
140
|
-
}
|
|
141
|
-
function se(t) {
|
|
142
|
-
const e = Y(t), n = pe(e), o = me(e), r = ae(e), i = ce(e), s = {}, a = /* @__PURE__ */ new Set();
|
|
143
|
-
let c;
|
|
144
|
-
for (const [u, f] of i) {
|
|
145
|
-
const g = r.get(f);
|
|
146
|
-
if (u === "policy") {
|
|
147
|
-
g && (c = wt(g, n, o));
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (!ye(u) || (a.add(u), !g)) continue;
|
|
151
|
-
const l = ue(g, n, o);
|
|
152
|
-
l && (s[u] = l);
|
|
153
|
-
}
|
|
154
|
-
return { capabilities: s, declaredMethods: a, policy: c };
|
|
155
|
-
}
|
|
156
|
-
function ae(t) {
|
|
157
|
-
const e = /* @__PURE__ */ new Map();
|
|
158
|
-
for (const n of d(t.body)) {
|
|
159
|
-
const o = n.type === "ExportNamedDeclaration" ? h(n.declaration) : n;
|
|
160
|
-
if (o?.type === "VariableDeclaration")
|
|
161
|
-
for (const r of d(o.declarations)) {
|
|
162
|
-
const i = D(r.id), s = h(r.init);
|
|
163
|
-
i && s && e.set(i, s);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return e;
|
|
167
|
-
}
|
|
168
|
-
function ce(t) {
|
|
169
|
-
const e = /* @__PURE__ */ new Map();
|
|
170
|
-
for (const n of d(t.body)) {
|
|
171
|
-
if (n.type !== "ExportNamedDeclaration") continue;
|
|
172
|
-
const o = h(n.declaration);
|
|
173
|
-
if (o?.type === "VariableDeclaration")
|
|
174
|
-
for (const r of d(o.declarations)) {
|
|
175
|
-
const i = D(r.id);
|
|
176
|
-
i && e.set(i, i);
|
|
177
|
-
}
|
|
178
|
-
for (const r of d(n.specifiers)) {
|
|
179
|
-
const i = E(r.exported), s = E(r.local);
|
|
180
|
-
i && s && e.set(i, s);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return e;
|
|
184
|
-
}
|
|
185
|
-
function ue(t, e, n) {
|
|
186
|
-
if (t.type !== "CallExpression") return;
|
|
187
|
-
const o = D(t.callee), r = o ? e.get(o) : void 0;
|
|
188
|
-
if (!r || !ne.has(r)) return;
|
|
189
|
-
const i = d(t.arguments), s = r === "action" ? i[0] : i[1];
|
|
190
|
-
if (!s) return {};
|
|
191
|
-
const a = rt(s, "cors", n), c = rt(
|
|
192
|
-
s,
|
|
193
|
-
"security",
|
|
194
|
-
n
|
|
195
|
-
);
|
|
196
|
-
return {
|
|
197
|
-
cors: P(a) ? a : void 0,
|
|
198
|
-
security: P(c) ? c : void 0
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
function rt(t, e, n) {
|
|
202
|
-
if (t.type === "Identifier") {
|
|
203
|
-
const r = n.get(String(t.name));
|
|
204
|
-
return P(r) ? r[e] : m;
|
|
205
|
-
}
|
|
206
|
-
if (t.type !== "ObjectExpression") return m;
|
|
207
|
-
let o;
|
|
208
|
-
for (const r of d(t.properties)) {
|
|
209
|
-
if (r.type !== "Property" || r.computed) return m;
|
|
210
|
-
E(r.key) === e && (o = b(h(r.value), n));
|
|
211
|
-
}
|
|
212
|
-
return o;
|
|
213
|
-
}
|
|
214
|
-
function wt(t, e, n) {
|
|
215
|
-
if (t.type === "CallExpression") {
|
|
216
|
-
const r = D(t.callee);
|
|
217
|
-
if (r && e.get(r) === "defineRoutePolicy") {
|
|
218
|
-
const i = d(t.arguments)[0];
|
|
219
|
-
return i ? wt(i, e, n) : void 0;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
if (t.type !== "ObjectExpression") {
|
|
223
|
-
const r = b(t, n);
|
|
224
|
-
return P(r) ? r : void 0;
|
|
225
|
-
}
|
|
226
|
-
const o = {};
|
|
227
|
-
for (const r of d(t.properties)) {
|
|
228
|
-
if (r.type !== "Property" || r.computed) return;
|
|
229
|
-
const i = E(r.key), s = h(r.value);
|
|
230
|
-
if (!i || !s) return;
|
|
231
|
-
if (i === "document") {
|
|
232
|
-
const c = le(s, e, n);
|
|
233
|
-
if (!c) return;
|
|
234
|
-
o.document = c;
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
const a = b(s, n);
|
|
238
|
-
if (a === m) return;
|
|
239
|
-
o[i] = a;
|
|
240
|
-
}
|
|
241
|
-
return o;
|
|
242
|
-
}
|
|
243
|
-
function le(t, e, n) {
|
|
244
|
-
if (t.type !== "CallExpression") {
|
|
245
|
-
const a = b(t, n);
|
|
246
|
-
return P(a) ? a : void 0;
|
|
247
|
-
}
|
|
248
|
-
const o = h(t.callee);
|
|
249
|
-
if (o?.type !== "MemberExpression") return;
|
|
250
|
-
const r = D(o.object), i = E(o.property);
|
|
251
|
-
if (!r || e.get(r) !== "security" || !i)
|
|
252
|
-
return;
|
|
253
|
-
const s = b(d(t.arguments)[0], n);
|
|
254
|
-
if (!(s !== m && s !== void 0 && !P(s))) {
|
|
255
|
-
if (i === "api") return F.api(s);
|
|
256
|
-
if (i === "crossOriginIsolated")
|
|
257
|
-
return F.crossOriginIsolated(s);
|
|
258
|
-
if (i === "static") return F.static(s);
|
|
259
|
-
if (i === "strict") return F.strict(s);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function fe(t, e) {
|
|
263
|
-
const n = [], o = new Set(t.declaredMethods);
|
|
264
|
-
o.has("GET") && o.add("HEAD"), o.add("OPTIONS");
|
|
265
|
-
for (const [r, i] of Object.entries(
|
|
266
|
-
t.capabilities
|
|
267
|
-
)) {
|
|
268
|
-
if (i.cors) {
|
|
269
|
-
try {
|
|
270
|
-
_t(i.cors);
|
|
271
|
-
} catch (s) {
|
|
272
|
-
n.push(V(
|
|
273
|
-
"cors-invalid",
|
|
274
|
-
e,
|
|
275
|
-
U(s, "The CORS policy is invalid."),
|
|
276
|
-
r
|
|
277
|
-
));
|
|
278
|
-
}
|
|
279
|
-
for (const s of i.cors.methods ?? [])
|
|
280
|
-
o.has(s) || n.push(V(
|
|
281
|
-
"cors-method-unavailable",
|
|
282
|
-
e,
|
|
283
|
-
`CORS method ${s} is not available from this route.`,
|
|
284
|
-
r
|
|
285
|
-
));
|
|
286
|
-
}
|
|
287
|
-
nt(i.security, e, r, n);
|
|
288
|
-
}
|
|
289
|
-
if (nt(t.policy?.security, e, void 0, n), t.policy?.document)
|
|
290
|
-
try {
|
|
291
|
-
Ct(de(t.policy.document), {
|
|
292
|
-
nonce: "build-verification-nonce"
|
|
293
|
-
});
|
|
294
|
-
} catch (r) {
|
|
295
|
-
n.push(V(
|
|
296
|
-
"security-header-render-failed",
|
|
297
|
-
e,
|
|
298
|
-
U(r, "The security headers are invalid.")
|
|
299
|
-
));
|
|
300
|
-
}
|
|
301
|
-
return n;
|
|
302
|
-
}
|
|
303
|
-
function de(t) {
|
|
304
|
-
const e = t.headers?.reportingEndpoints, n = !!(e && Object.keys(e).length), o = t.csp === !1 ? void 0 : t.csp?.reportTo;
|
|
305
|
-
return n || !o ? t : {
|
|
306
|
-
...t,
|
|
307
|
-
csp: { ...t.csp, reportTo: void 0 },
|
|
308
|
-
headers: e ? { ...t.headers, reportingEndpoints: void 0 } : t.headers
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
function nt(t, e, n, o) {
|
|
312
|
-
if (t?.rateLimit)
|
|
313
|
-
try {
|
|
314
|
-
jt(t.rateLimit);
|
|
315
|
-
} catch (r) {
|
|
316
|
-
o.push(V(
|
|
317
|
-
"rate-limit-invalid",
|
|
318
|
-
e,
|
|
319
|
-
U(r, "The rate limit policy is invalid."),
|
|
320
|
-
n
|
|
321
|
-
));
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function V(t, e, n, o) {
|
|
325
|
-
return { code: t, exportName: o, file: e, message: n, severity: "error" };
|
|
326
|
-
}
|
|
327
|
-
function pe(t) {
|
|
328
|
-
const e = /* @__PURE__ */ new Map();
|
|
329
|
-
for (const n of d(t.body))
|
|
330
|
-
if (!(n.type !== "ImportDeclaration" || h(n.source)?.value !== "@demiurgejs/core"))
|
|
331
|
-
for (const o of d(n.specifiers)) {
|
|
332
|
-
if (o.type !== "ImportSpecifier") continue;
|
|
333
|
-
const r = D(o.local), i = E(o.imported);
|
|
334
|
-
r && i && e.set(r, i);
|
|
335
|
-
}
|
|
336
|
-
return e;
|
|
337
|
-
}
|
|
338
|
-
function me(t) {
|
|
339
|
-
const e = /* @__PURE__ */ new Map();
|
|
340
|
-
for (const n of d(t.body)) {
|
|
341
|
-
const o = n.type === "ExportNamedDeclaration" ? h(n.declaration) : n;
|
|
342
|
-
if (o?.type === "VariableDeclaration")
|
|
343
|
-
for (const r of d(o.declarations)) {
|
|
344
|
-
const i = D(r.id), s = h(r.init);
|
|
345
|
-
if (!i || !s) continue;
|
|
346
|
-
const a = b(s, e);
|
|
347
|
-
a !== m && e.set(i, a);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return e;
|
|
351
|
-
}
|
|
352
|
-
const m = Symbol("unresolved");
|
|
353
|
-
function b(t, e) {
|
|
354
|
-
if (t) {
|
|
355
|
-
if (t.type === "Literal") return t.value;
|
|
356
|
-
if (t.type === "Identifier")
|
|
357
|
-
return t.name === "undefined" ? void 0 : e.has(String(t.name)) ? e.get(String(t.name)) : m;
|
|
358
|
-
if (t.type === "TemplateLiteral")
|
|
359
|
-
return d(t.expressions).length ? m : d(t.quasis).map((n) => h(n.value)?.cooked ?? "").join("");
|
|
360
|
-
if (t.type === "UnaryExpression") {
|
|
361
|
-
const n = b(h(t.argument), e);
|
|
362
|
-
return typeof n != "number" ? m : t.operator === "-" ? -n : t.operator === "+" ? n : m;
|
|
363
|
-
}
|
|
364
|
-
if (t.type === "ArrayExpression") {
|
|
365
|
-
const n = [];
|
|
366
|
-
for (const o of d(t.elements)) {
|
|
367
|
-
const r = b(o, e);
|
|
368
|
-
if (r === m) return m;
|
|
369
|
-
n.push(r);
|
|
370
|
-
}
|
|
371
|
-
return n;
|
|
372
|
-
}
|
|
373
|
-
if (t.type === "ObjectExpression") {
|
|
374
|
-
const n = {};
|
|
375
|
-
for (const o of d(t.properties)) {
|
|
376
|
-
if (o.type !== "Property" || o.computed) return m;
|
|
377
|
-
const r = E(o.key), i = b(h(o.value), e);
|
|
378
|
-
if (!r || i === m) return m;
|
|
379
|
-
n[r] = i;
|
|
380
|
-
}
|
|
381
|
-
return n;
|
|
382
|
-
}
|
|
383
|
-
return m;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
function ye(t) {
|
|
387
|
-
return re.includes(t);
|
|
388
|
-
}
|
|
389
|
-
function U(t, e) {
|
|
390
|
-
return t instanceof Error ? t.message : e;
|
|
391
|
-
}
|
|
392
|
-
function P(t) {
|
|
393
|
-
return !!t && typeof t == "object" && !Array.isArray(t);
|
|
394
|
-
}
|
|
395
|
-
function h(t) {
|
|
396
|
-
return t && typeof t == "object" && "type" in t ? t : void 0;
|
|
397
|
-
}
|
|
398
|
-
function d(t) {
|
|
399
|
-
return Array.isArray(t) ? t.map(h).filter((e) => !!e) : [];
|
|
400
|
-
}
|
|
401
|
-
function D(t) {
|
|
402
|
-
const e = h(t);
|
|
403
|
-
return e?.type === "Identifier" ? String(e.name) : void 0;
|
|
404
|
-
}
|
|
405
|
-
function E(t) {
|
|
406
|
-
const e = h(t);
|
|
407
|
-
return e?.type === "Identifier" || e?.type === "Literal" ? String(e.name ?? e.value) : void 0;
|
|
408
|
-
}
|
|
409
|
-
const W = "virtual:demiurge/client-entry", z = `/@id/${W}`, J = `\0${W}`, vt = "virtual:demiurge/server-entry", ot = `\0${vt}`, it = ".demiurge/route-manifest.d.ts";
|
|
410
|
-
function fr(t = {}) {
|
|
411
|
-
let e = process.cwd(), n = !1;
|
|
412
|
-
const o = `demiurge-${B()}`;
|
|
413
|
-
return {
|
|
414
|
-
api: {
|
|
415
|
-
demiurge: !0,
|
|
416
|
-
fonts: t.fonts,
|
|
417
|
-
images: t.images,
|
|
418
|
-
staticDeployment: t.static?.deployment,
|
|
419
|
-
staticFileHeaders: t.static?.headers
|
|
420
|
-
},
|
|
421
|
-
enforce: "post",
|
|
422
|
-
name: "demiurge",
|
|
423
|
-
config(r, i) {
|
|
424
|
-
return Se(r, i, o);
|
|
425
|
-
},
|
|
426
|
-
configResolved(r) {
|
|
427
|
-
e = r.root, n = r.command === "build";
|
|
428
|
-
},
|
|
429
|
-
resolveId(r) {
|
|
430
|
-
return r === W ? J : r === vt ? ot : null;
|
|
431
|
-
},
|
|
432
|
-
load(r) {
|
|
433
|
-
return r === J ? Ee(e, t) : r === ot ? De(e, t) : null;
|
|
434
|
-
},
|
|
435
|
-
transform: {
|
|
436
|
-
order: "post",
|
|
437
|
-
handler(r, i, s) {
|
|
438
|
-
if (!ve(e, t, i))
|
|
439
|
-
return null;
|
|
440
|
-
if (s?.ssr)
|
|
441
|
-
return n ? null : he(r, i);
|
|
442
|
-
const a = ge(r);
|
|
443
|
-
return a === r ? null : { code: a, map: null };
|
|
444
|
-
}
|
|
445
|
-
},
|
|
446
|
-
generateBundle(r, i) {
|
|
447
|
-
const s = Object.values(i).find(
|
|
448
|
-
(u) => u.type === "chunk" && u.isEntry && u.facadeModuleId === J
|
|
449
|
-
);
|
|
450
|
-
if (!s)
|
|
451
|
-
return;
|
|
452
|
-
const a = Object.values(i).filter(
|
|
453
|
-
(u) => u.type === "asset" && u.fileName.endsWith(".css")
|
|
454
|
-
).map((u) => `/${u.fileName}`), c = `/${s.fileName}`;
|
|
455
|
-
this.emitFile({
|
|
456
|
-
fileName: "index.html",
|
|
457
|
-
source: Ue({
|
|
458
|
-
entrySrc: c,
|
|
459
|
-
lang: t.document?.lang,
|
|
460
|
-
styles: a,
|
|
461
|
-
title: t.document?.title
|
|
462
|
-
}),
|
|
463
|
-
type: "asset"
|
|
464
|
-
}), this.emitFile({
|
|
465
|
-
fileName: "demiurge-manifest.json",
|
|
466
|
-
source: JSON.stringify({ clientEntry: c, styles: a }, null, 2),
|
|
467
|
-
type: "asset"
|
|
468
|
-
});
|
|
469
|
-
},
|
|
470
|
-
async buildStart() {
|
|
471
|
-
if (n) {
|
|
472
|
-
await Le(e, t);
|
|
473
|
-
const r = await yt(e, t);
|
|
474
|
-
if (r.length)
|
|
475
|
-
throw new Error(Qe(r));
|
|
476
|
-
}
|
|
477
|
-
t.typedRoutes && await _(e, t);
|
|
478
|
-
},
|
|
479
|
-
configureServer(r) {
|
|
480
|
-
const i = async () => {
|
|
481
|
-
const l = await yt(r.config.root, t);
|
|
482
|
-
for (const p of l)
|
|
483
|
-
r.config.logger.warn(St(p));
|
|
484
|
-
};
|
|
485
|
-
let s, a = Promise.resolve();
|
|
486
|
-
const c = () => {
|
|
487
|
-
a = a.then(i).catch(() => {
|
|
488
|
-
});
|
|
489
|
-
}, u = () => {
|
|
490
|
-
s && clearTimeout(s), s = setTimeout(() => {
|
|
491
|
-
s = void 0, c();
|
|
492
|
-
}, Ye), s.unref?.();
|
|
493
|
-
};
|
|
494
|
-
if (r.httpServer?.once("close", () => {
|
|
495
|
-
s && (clearTimeout(s), s = void 0);
|
|
496
|
-
}), c(), t.typedRoutes) {
|
|
497
|
-
const l = w(
|
|
498
|
-
r.config.root,
|
|
499
|
-
t.routesDir ?? "src/routes"
|
|
500
|
-
);
|
|
501
|
-
_(r.config.root, t), r.watcher.add(l), r.watcher.on("add", (p) => {
|
|
502
|
-
A(l, p) && (_(r.config.root, t), u());
|
|
503
|
-
}), r.watcher.on("change", (p) => {
|
|
504
|
-
A(l, p) && (_(r.config.root, t), u());
|
|
505
|
-
}), r.watcher.on("unlink", (p) => {
|
|
506
|
-
A(l, p) && (_(r.config.root, t), u());
|
|
507
|
-
});
|
|
508
|
-
} else {
|
|
509
|
-
const l = w(
|
|
510
|
-
r.config.root,
|
|
511
|
-
t.routesDir ?? "src/routes"
|
|
512
|
-
);
|
|
513
|
-
r.watcher.add(l);
|
|
514
|
-
for (const p of ["add", "change", "unlink"])
|
|
515
|
-
r.watcher.on(p, (N) => {
|
|
516
|
-
A(l, N) && u();
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
const f = Ie(r, t), g = Lt({
|
|
520
|
-
fonts: t.fonts,
|
|
521
|
-
root: r.config.root
|
|
522
|
-
});
|
|
523
|
-
return r.middlewares.use(async (l, p, N) => {
|
|
524
|
-
try {
|
|
525
|
-
let v;
|
|
526
|
-
try {
|
|
527
|
-
v = X(l, {
|
|
528
|
-
// Vite performs its own configured host allowlist check before
|
|
529
|
-
// Demiurge's middleware runs. Production Node listeners require
|
|
530
|
-
// an explicit application allowlist instead.
|
|
531
|
-
allowedHosts: [l.headers.host ?? "localhost"]
|
|
532
|
-
});
|
|
533
|
-
} catch (Q) {
|
|
534
|
-
if (Q instanceof Z) {
|
|
535
|
-
tt(p);
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
throw Q;
|
|
539
|
-
}
|
|
540
|
-
const O = await g(v);
|
|
541
|
-
if (O) {
|
|
542
|
-
await T(p, O);
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
const M = await f(v);
|
|
546
|
-
if (M) {
|
|
547
|
-
await T(p, M);
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
const C = w(
|
|
551
|
-
r.config.root,
|
|
552
|
-
t.routesDir ?? "src/routes"
|
|
553
|
-
), j = await dt(r, l, C), I = at(
|
|
554
|
-
r,
|
|
555
|
-
o
|
|
556
|
-
), H = await Ge(
|
|
557
|
-
j,
|
|
558
|
-
v,
|
|
559
|
-
_e(t, I.transform)
|
|
560
|
-
);
|
|
561
|
-
if (H === "next") {
|
|
562
|
-
N();
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
ut(H, I.nonce), await T(p, H);
|
|
566
|
-
} catch (v) {
|
|
567
|
-
N(v);
|
|
568
|
-
}
|
|
569
|
-
}), () => {
|
|
570
|
-
r.middlewares.use(async (l, p, N) => {
|
|
571
|
-
try {
|
|
572
|
-
let v;
|
|
573
|
-
try {
|
|
574
|
-
v = X(l, {
|
|
575
|
-
allowedHosts: [l.headers.host ?? "localhost"]
|
|
576
|
-
});
|
|
577
|
-
} catch (I) {
|
|
578
|
-
if (I instanceof Z) {
|
|
579
|
-
tt(p);
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
throw I;
|
|
583
|
-
}
|
|
584
|
-
const O = w(
|
|
585
|
-
r.config.root,
|
|
586
|
-
t.routesDir ?? "src/routes"
|
|
587
|
-
), M = await dt(r, l, O);
|
|
588
|
-
Ve(M, O);
|
|
589
|
-
const C = at(
|
|
590
|
-
r,
|
|
591
|
-
o
|
|
592
|
-
), j = await Ft(
|
|
593
|
-
M,
|
|
594
|
-
v,
|
|
595
|
-
Ae(t, C.transform)
|
|
596
|
-
);
|
|
597
|
-
ut(
|
|
598
|
-
j,
|
|
599
|
-
C.nonce
|
|
600
|
-
), await T(p, j);
|
|
601
|
-
} catch (v) {
|
|
602
|
-
N(v);
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
function he(t, e) {
|
|
610
|
-
if (!t.includes("import.meta"))
|
|
611
|
-
return null;
|
|
612
|
-
const n = Y(t), o = x(n.body).find(
|
|
613
|
-
(u) => u.type === "ImportDeclaration" && x(u.specifiers).some(
|
|
614
|
-
(f) => y(f.local)?.type === "Identifier" && y(f.local)?.name === "meta"
|
|
615
|
-
)
|
|
616
|
-
), r = o && x(o.specifiers).find(
|
|
617
|
-
(u) => y(u.local)?.type === "Identifier" && y(u.local)?.name === "meta"
|
|
618
|
-
), i = r && y(r.local);
|
|
619
|
-
if (!o || !r || !i)
|
|
620
|
-
return null;
|
|
621
|
-
let s = "__demiurge_imported_meta__";
|
|
622
|
-
for (; new RegExp(`\\b${s}\\b`).test(t); )
|
|
623
|
-
s += "_";
|
|
624
|
-
const a = new Pt(t), c = y(r.imported);
|
|
625
|
-
return a.overwrite(
|
|
626
|
-
i.start,
|
|
627
|
-
i.end,
|
|
628
|
-
c?.start === i.start ? `meta as ${s}` : s
|
|
629
|
-
), a.appendLeft(o.end, `
|
|
630
|
-
const meta = ${s};`), {
|
|
631
|
-
code: a.toString(),
|
|
632
|
-
map: a.generateMap({
|
|
633
|
-
hires: "boundary",
|
|
634
|
-
includeContent: !0,
|
|
635
|
-
source: e
|
|
636
|
-
})
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
function ge(t) {
|
|
640
|
-
const e = Y(t), n = [], o = we(e), r = [];
|
|
641
|
-
L(e, (a) => {
|
|
642
|
-
if (a.type === "ImportDeclaration" && xe(a)) {
|
|
643
|
-
r.push(a);
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
if (a.type !== "CallExpression" || !be(a.callee))
|
|
647
|
-
return;
|
|
648
|
-
const c = x(a.arguments)[0];
|
|
649
|
-
if (c?.type === "ObjectExpression")
|
|
650
|
-
for (const u of x(c.properties))
|
|
651
|
-
u.type === "Property" && k(u.key) === "data" && n.push({ end: u.end, start: u.start });
|
|
652
|
-
});
|
|
653
|
-
const i = [...n, ...o];
|
|
654
|
-
if (i.length === 0)
|
|
655
|
-
return t;
|
|
656
|
-
const s = [...i];
|
|
657
|
-
for (const a of r) {
|
|
658
|
-
const c = x(a.specifiers).map((g) => y(g.local)).filter((g) => g?.type === "Identifier").map((g) => String(g.name)), u = Re(t, [
|
|
659
|
-
...i,
|
|
660
|
-
{ end: a.end, start: a.start }
|
|
661
|
-
]), f = c.find(
|
|
662
|
-
(g) => new RegExp(`\\b${bt(g)}\\b`).test(u)
|
|
663
|
-
);
|
|
664
|
-
if (f)
|
|
665
|
-
throw new Error(
|
|
666
|
-
`Server-only import ${JSON.stringify(f)} is used by client route code. Move that use into page data, a document contribution, or a client-safe module.`
|
|
667
|
-
);
|
|
668
|
-
s.push({ end: a.end, start: a.start });
|
|
669
|
-
}
|
|
670
|
-
return $e(
|
|
671
|
-
t,
|
|
672
|
-
s,
|
|
673
|
-
(a) => n.includes(a) ? "data: undefined" : o.includes(a) ? "undefined" : ""
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
const st = /* @__PURE__ */ new Set(["links", "metadata", "scripts"]);
|
|
677
|
-
function we(t) {
|
|
678
|
-
const e = /* @__PURE__ */ new Set();
|
|
679
|
-
for (const o of x(t.body)) {
|
|
680
|
-
if (o.type !== "ExportNamedDeclaration") continue;
|
|
681
|
-
const r = y(o.declaration);
|
|
682
|
-
if (r?.type === "VariableDeclaration")
|
|
683
|
-
for (const i of x(r.declarations)) {
|
|
684
|
-
const s = y(i.id);
|
|
685
|
-
s?.type === "Identifier" && st.has(String(s.name)) && e.add(String(s.name));
|
|
686
|
-
}
|
|
687
|
-
for (const i of x(o.specifiers)) {
|
|
688
|
-
const s = k(i.exported), a = k(i.local);
|
|
689
|
-
s && a && st.has(s) && e.add(a);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
const n = [];
|
|
693
|
-
return L(t, (o) => {
|
|
694
|
-
if (o.type !== "VariableDeclarator") return;
|
|
695
|
-
const r = y(o.id), i = y(o.init);
|
|
696
|
-
r?.type === "Identifier" && e.has(String(r.name)) && i && n.push({ end: i.end, start: i.start });
|
|
697
|
-
}), n;
|
|
698
|
-
}
|
|
699
|
-
function ve(t, e, n) {
|
|
700
|
-
const o = n.split("?", 1)[0] ?? n, r = w(t, e.routesDir ?? "src/routes"), i = R(r, o);
|
|
701
|
-
return i !== "" && i !== ".." && !i.startsWith(`..${S}`);
|
|
702
|
-
}
|
|
703
|
-
function L(t, e) {
|
|
704
|
-
if (!t || typeof t != "object") return;
|
|
705
|
-
if (Array.isArray(t)) {
|
|
706
|
-
for (const o of t) L(o, e);
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
const n = t;
|
|
710
|
-
if (typeof n.type == "string") {
|
|
711
|
-
e(n);
|
|
712
|
-
for (const [o, r] of Object.entries(n))
|
|
713
|
-
(/* @__PURE__ */ new Set(["end", "loc", "start", "type"])).has(o) || L(r, e);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
function y(t) {
|
|
717
|
-
return t && typeof t == "object" && "type" in t ? t : void 0;
|
|
718
|
-
}
|
|
719
|
-
function x(t) {
|
|
720
|
-
return Array.isArray(t) ? t.map(y).filter((e) => !!e) : [];
|
|
721
|
-
}
|
|
722
|
-
function be(t) {
|
|
723
|
-
const e = y(t);
|
|
724
|
-
return e?.type === "Identifier" ? e.name === "page" : e?.type === "MemberExpression" && k(e.property) === "page";
|
|
725
|
-
}
|
|
726
|
-
function k(t) {
|
|
727
|
-
const e = y(t);
|
|
728
|
-
return e?.type === "Identifier" || e?.type === "Literal" ? String(e.name ?? e.value) : void 0;
|
|
729
|
-
}
|
|
730
|
-
function xe(t) {
|
|
731
|
-
const e = y(t.source)?.value;
|
|
732
|
-
return typeof e == "string" && /(?:^|[/.-])server(?:[/.-]|$)/.test(e);
|
|
733
|
-
}
|
|
734
|
-
function Re(t, e) {
|
|
735
|
-
const n = [...t];
|
|
736
|
-
for (const { end: o, start: r } of e)
|
|
737
|
-
n.fill(" ", r, o);
|
|
738
|
-
return n.join("");
|
|
739
|
-
}
|
|
740
|
-
function $e(t, e, n) {
|
|
741
|
-
return [...e].sort((o, r) => r.start - o.start).reduce(
|
|
742
|
-
(o, r) => `${o.slice(0, r.start)}${n(r)}${o.slice(r.end)}`,
|
|
743
|
-
t
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
function bt(t) {
|
|
747
|
-
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
748
|
-
}
|
|
749
|
-
function Se(t, e, n) {
|
|
750
|
-
return {
|
|
751
|
-
appType: "custom",
|
|
752
|
-
build: {
|
|
753
|
-
assetsInlineLimit: t.build?.assetsInlineLimit ?? 0,
|
|
754
|
-
...e.isSsrBuild && t.build?.target === void 0 && t.ssr?.target !== "webworker" ? { target: "node22.13" } : {},
|
|
755
|
-
rollupOptions: {
|
|
756
|
-
input: t.build?.rollupOptions?.input ?? W
|
|
757
|
-
}
|
|
758
|
-
},
|
|
759
|
-
...e.command === "serve" ? {
|
|
760
|
-
html: { cspNonce: n },
|
|
761
|
-
ssr: { external: [$] }
|
|
762
|
-
} : {}
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
function Ee(t, e = {}) {
|
|
766
|
-
const n = e.routesDir ?? "src/routes", o = Me(t, e);
|
|
767
|
-
return `import { hydrateFileRouter } from "${$}";
|
|
768
|
-
${o}
|
|
769
|
-
|
|
770
|
-
${xt(n, {
|
|
771
|
-
exportRoutes: !1,
|
|
772
|
-
includeServerOnly: !1
|
|
773
|
-
})}
|
|
774
|
-
|
|
775
|
-
void hydrateFileRouter({ routes });
|
|
776
|
-
`;
|
|
777
|
-
}
|
|
778
|
-
function De(t, e = {}) {
|
|
779
|
-
const n = e.routesDir ?? "src/routes";
|
|
780
|
-
return `import { createRequestHandler } from "${$}";
|
|
781
|
-
|
|
782
|
-
${xt(n, {
|
|
783
|
-
exportRoutes: !0,
|
|
784
|
-
includeServerOnly: !0,
|
|
785
|
-
eagerModules: !0
|
|
786
|
-
})}
|
|
787
|
-
|
|
788
|
-
export function createHandler(options = {}) {
|
|
789
|
-
const { clientEntry, lang, styles, title, ...handlerOptions } = options;
|
|
790
|
-
|
|
791
|
-
return createRequestHandler({
|
|
792
|
-
...handlerOptions,
|
|
793
|
-
routes,
|
|
794
|
-
routeModules,
|
|
795
|
-
ssr: {
|
|
796
|
-
clientEntry,
|
|
797
|
-
lang: lang ?? ${JSON.stringify(e.document?.lang)},
|
|
798
|
-
styles,
|
|
799
|
-
title: title ?? ${JSON.stringify(e.document?.title)},
|
|
800
|
-
},
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
`;
|
|
804
|
-
}
|
|
805
|
-
function xt(t, {
|
|
806
|
-
exportRoutes: e,
|
|
807
|
-
eagerModules: n = !1,
|
|
808
|
-
includeServerOnly: o
|
|
809
|
-
}) {
|
|
810
|
-
const r = Pe(t, o), i = Oe(t);
|
|
811
|
-
return n ? `const eagerRouteModules = import.meta.glob(${JSON.stringify(r)}, { eager: true });
|
|
812
|
-
const routePrefix = ${JSON.stringify(i)};
|
|
813
|
-
export const routeModules = Object.fromEntries(
|
|
814
|
-
Object.entries(eagerRouteModules).map(([file, module]) => [
|
|
815
|
-
\`./routes/\${file.slice(routePrefix.length)}\`,
|
|
816
|
-
module,
|
|
817
|
-
]),
|
|
818
|
-
);
|
|
819
|
-
${e ? "export " : ""}const routes = Object.fromEntries(
|
|
820
|
-
Object.entries(routeModules).map(([file, module]) => [
|
|
821
|
-
file,
|
|
822
|
-
async () => module,
|
|
823
|
-
]),
|
|
824
|
-
);` : `const routeModules = import.meta.glob(${JSON.stringify(r)});
|
|
825
|
-
const routePrefix = ${JSON.stringify(i)};
|
|
826
|
-
${e ? "export " : ""}const routes = Object.fromEntries(
|
|
827
|
-
Object.entries(routeModules).map(([file, load]) => [
|
|
828
|
-
\`./routes/\${file.slice(routePrefix.length)}\`,
|
|
829
|
-
load,
|
|
830
|
-
]),
|
|
831
|
-
);`;
|
|
832
|
-
}
|
|
833
|
-
const Ne = ["@middleware.ts", "@policy.ts"];
|
|
834
|
-
function Pe(t, e) {
|
|
835
|
-
const n = `/${t.replace(/^\/|\/$/g, "")}`, o = [`${n}/**/*.{ts,tsx}`];
|
|
836
|
-
return e || o.push(
|
|
837
|
-
...Ne.flatMap((r) => [
|
|
838
|
-
`!${n}/${r}`,
|
|
839
|
-
`!${n}/**/${r}`
|
|
840
|
-
])
|
|
841
|
-
), o;
|
|
842
|
-
}
|
|
843
|
-
function Oe(t) {
|
|
844
|
-
return `/${t.replace(/^\/|\/$/g, "")}/`;
|
|
845
|
-
}
|
|
846
|
-
function Me(t, e) {
|
|
847
|
-
if (e.styles === !1)
|
|
848
|
-
return "";
|
|
849
|
-
const n = e.styles ?? "src/styles.css", o = w(t, n);
|
|
850
|
-
return G(o) ? `import ${JSON.stringify(`/${n.replace(/^\/+/, "")}`)};` : "";
|
|
851
|
-
}
|
|
852
|
-
function Ie(t, e) {
|
|
853
|
-
const n = t.config.publicDir, o = e.images?.optimizerPath ?? "/_demiurge/image";
|
|
854
|
-
return n ? kt({
|
|
855
|
-
policy: e.images,
|
|
856
|
-
resolveVariant: (r) => Ht(r, o),
|
|
857
|
-
root: n
|
|
858
|
-
}) : async () => null;
|
|
859
|
-
}
|
|
860
|
-
function _e(t, e) {
|
|
861
|
-
return {
|
|
862
|
-
dev: !0,
|
|
863
|
-
ssr: $t(t),
|
|
864
|
-
transformDocument: e,
|
|
865
|
-
renderPage: async (n, o) => {
|
|
866
|
-
if (n.render.mode === "streaming")
|
|
867
|
-
return await Wt(n, {
|
|
868
|
-
...o,
|
|
869
|
-
clientEntry: z,
|
|
870
|
-
transformDocument: e
|
|
871
|
-
});
|
|
872
|
-
const r = await e(
|
|
873
|
-
It(n, {
|
|
874
|
-
...o,
|
|
875
|
-
clientEntry: z
|
|
876
|
-
})
|
|
877
|
-
);
|
|
878
|
-
return new Response(r, {
|
|
879
|
-
headers: { "content-type": "text/html; charset=utf-8" }
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
function at(t, e) {
|
|
885
|
-
const n = B(), o = B();
|
|
886
|
-
return {
|
|
887
|
-
nonce: n,
|
|
888
|
-
transform: async (r) => {
|
|
889
|
-
const i = Ce(r, o), s = await t.transformIndexHtml("/", i);
|
|
890
|
-
return ct(
|
|
891
|
-
ct(s, o),
|
|
892
|
-
e,
|
|
893
|
-
n
|
|
894
|
-
);
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
function Ce(t, e) {
|
|
899
|
-
const n = t.toLowerCase();
|
|
900
|
-
let o = 0, r = "";
|
|
901
|
-
for (; o < t.length; ) {
|
|
902
|
-
const i = t.indexOf("<", o);
|
|
903
|
-
if (i === -1)
|
|
904
|
-
return r + t.slice(o);
|
|
905
|
-
if (r += t.slice(o, i), n.startsWith("<!--", i)) {
|
|
906
|
-
const u = n.indexOf("-->", i + 4), f = u === -1 ? t.length : u + 3;
|
|
907
|
-
r += t.slice(i, f), o = f;
|
|
908
|
-
continue;
|
|
909
|
-
}
|
|
910
|
-
const s = n.slice(i).match(/^<\s*(script|style|link)\b/)?.[1];
|
|
911
|
-
if (!s) {
|
|
912
|
-
r += "<", o = i + 1;
|
|
913
|
-
continue;
|
|
914
|
-
}
|
|
915
|
-
const a = je(t, i);
|
|
916
|
-
if (a === -1)
|
|
917
|
-
return r + t.slice(i);
|
|
918
|
-
const c = t.slice(i, a + 1);
|
|
919
|
-
if (r += /(?:^|\s)nonce(?:\s|=|>)/i.test(c) ? c : Fe(c, e), o = a + 1, s === "script" || s === "style") {
|
|
920
|
-
const u = n.indexOf(`</${s}`, o);
|
|
921
|
-
if (u === -1)
|
|
922
|
-
return r + t.slice(o);
|
|
923
|
-
r += t.slice(o, u), o = u;
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
return r;
|
|
927
|
-
}
|
|
928
|
-
function je(t, e) {
|
|
929
|
-
let n;
|
|
930
|
-
for (let o = e + 1; o < t.length; o++) {
|
|
931
|
-
const r = t[o];
|
|
932
|
-
if (n) {
|
|
933
|
-
r === n && (n = void 0);
|
|
934
|
-
continue;
|
|
935
|
-
}
|
|
936
|
-
if (r === '"' || r === "'")
|
|
937
|
-
n = r;
|
|
938
|
-
else if (r === ">")
|
|
939
|
-
return o;
|
|
940
|
-
}
|
|
941
|
-
return -1;
|
|
942
|
-
}
|
|
943
|
-
function Fe(t, e) {
|
|
944
|
-
const n = /\/\s*>$/.test(t) ? t.lastIndexOf("/") : t.length - 1;
|
|
945
|
-
return `${t.slice(0, n)} nonce="${e}"${t.slice(n)}`;
|
|
946
|
-
}
|
|
947
|
-
function ct(t, e, n) {
|
|
948
|
-
const o = new RegExp(
|
|
949
|
-
`(\\snonce\\s*=\\s*)(["'])${bt(e)}\\2`,
|
|
950
|
-
"g"
|
|
951
|
-
);
|
|
952
|
-
return t.replace(
|
|
953
|
-
o,
|
|
954
|
-
n ? `$1"${n}"` : ""
|
|
955
|
-
);
|
|
956
|
-
}
|
|
957
|
-
function ut(t, e) {
|
|
958
|
-
const n = t.headers.get("content-type"), o = t.headers.get("content-security-policy");
|
|
959
|
-
if (!n?.toLowerCase().startsWith("text/html") || !o)
|
|
960
|
-
return;
|
|
961
|
-
const r = `'nonce-${e}'`, i = lt(
|
|
962
|
-
o,
|
|
963
|
-
["script-src-elem", "script-src"],
|
|
964
|
-
"script-src",
|
|
965
|
-
r
|
|
966
|
-
), s = Te(
|
|
967
|
-
i,
|
|
968
|
-
["style-src-elem", "style-src"]
|
|
969
|
-
) ? i : lt(
|
|
970
|
-
i,
|
|
971
|
-
["style-src-elem", "style-src"],
|
|
972
|
-
"style-src",
|
|
973
|
-
r
|
|
974
|
-
);
|
|
975
|
-
t.headers.set("content-security-policy", s), t.headers.set("cache-control", "private, no-store");
|
|
976
|
-
}
|
|
977
|
-
function lt(t, e, n, o) {
|
|
978
|
-
const r = t.split(";").map((f) => f.trim()), i = Rt(r, e), s = r.find(
|
|
979
|
-
(f) => f.split(/\s+/, 1)[0]?.toLowerCase() === "default-src"
|
|
980
|
-
);
|
|
981
|
-
if (i === -1 && !s) return t;
|
|
982
|
-
const [a, ...c] = (i === -1 ? s : r[i]).split(/\s+/), u = [
|
|
983
|
-
i === -1 ? n : a,
|
|
984
|
-
.../* @__PURE__ */ new Set([
|
|
985
|
-
...c.filter((f) => f !== "'none'"),
|
|
986
|
-
o
|
|
987
|
-
])
|
|
988
|
-
].join(" ");
|
|
989
|
-
return i === -1 ? r.push(u) : r[i] = u, r.join("; ");
|
|
990
|
-
}
|
|
991
|
-
function Te(t, e) {
|
|
992
|
-
const n = t.split(";").map((s) => s.trim()), o = Rt(n, e), i = (o === -1 ? n.find(
|
|
993
|
-
(s) => s.split(/\s+/, 1)[0]?.toLowerCase() === "default-src"
|
|
994
|
-
) : n[o])?.split(/\s+/).slice(1) ?? [];
|
|
995
|
-
return i.includes("'unsafe-inline'") && !i.some((s) => /^'(?:nonce-|sha(?:256|384|512)-)/i.test(s));
|
|
996
|
-
}
|
|
997
|
-
function Rt(t, e) {
|
|
998
|
-
for (const n of e) {
|
|
999
|
-
const o = t.findIndex(
|
|
1000
|
-
(r) => r.split(/\s+/, 1)[0]?.toLowerCase() === n
|
|
1001
|
-
);
|
|
1002
|
-
if (o !== -1) return o;
|
|
1003
|
-
}
|
|
1004
|
-
return -1;
|
|
1005
|
-
}
|
|
1006
|
-
const ft = Symbol.for("demiurge.devManifest");
|
|
1007
|
-
async function dt(t, e, n) {
|
|
1008
|
-
const o = e, r = o[ft];
|
|
1009
|
-
if (r)
|
|
1010
|
-
return r;
|
|
1011
|
-
const i = Vt(
|
|
1012
|
-
await ze(t, n)
|
|
1013
|
-
);
|
|
1014
|
-
return o[ft] = i, i;
|
|
1015
|
-
}
|
|
1016
|
-
function $t(t) {
|
|
1017
|
-
return {
|
|
1018
|
-
clientEntry: z,
|
|
1019
|
-
lang: t.document?.lang,
|
|
1020
|
-
title: t.document?.title
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
function Ae(t, e) {
|
|
1024
|
-
return {
|
|
1025
|
-
...$t(t),
|
|
1026
|
-
dev: !0,
|
|
1027
|
-
transformDocument: e
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
const pt = /* @__PURE__ */ new Set();
|
|
1031
|
-
function Ve(t, e) {
|
|
1032
|
-
pt.has(e) || t.fallbacks.notFound.some(
|
|
1033
|
-
(n) => n.fileSegments.length === 0
|
|
1034
|
-
) || (pt.add(e), console.warn(Be(Nt(e, "@not-found.tsx"))));
|
|
1035
|
-
}
|
|
1036
|
-
async function Le(t, e = {}) {
|
|
1037
|
-
const n = e.routesDir ?? "src/routes", o = w(t, n);
|
|
1038
|
-
if (!G(o))
|
|
1039
|
-
return;
|
|
1040
|
-
const r = await K(o);
|
|
1041
|
-
if (r.map(
|
|
1042
|
-
(a) => R(o, a).split(S).join("/")
|
|
1043
|
-
).some((a) => /^@not-found\.tsx?$/.test(a)))
|
|
1044
|
-
return;
|
|
1045
|
-
const s = await ke(r);
|
|
1046
|
-
if (s)
|
|
1047
|
-
throw new Error(
|
|
1048
|
-
Je(
|
|
1049
|
-
n,
|
|
1050
|
-
R(o, s).split(S).join("/")
|
|
1051
|
-
)
|
|
1052
|
-
);
|
|
1053
|
-
}
|
|
1054
|
-
async function ke(t) {
|
|
1055
|
-
for (const e of t)
|
|
1056
|
-
if (!R(q(e), e).startsWith("@") && He(await gt(e, "utf8")))
|
|
1057
|
-
return e;
|
|
1058
|
-
}
|
|
1059
|
-
const We = $.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), mt = new RegExp(
|
|
1060
|
-
`import\\s*\\{([^}]*)\\}\\s*from\\s*["']${We}["']`,
|
|
1061
|
-
"g"
|
|
1062
|
-
);
|
|
1063
|
-
function He(t) {
|
|
1064
|
-
const e = [...t.matchAll(mt)].flatMap(
|
|
1065
|
-
(o) => o[1].split(",").flatMap((r) => {
|
|
1066
|
-
const [i, s] = r.trim().split(/\s+as\s+/);
|
|
1067
|
-
return i.replace(/^type\s+/, "") === "page" ? [s ?? i] : [];
|
|
1068
|
-
})
|
|
1069
|
-
);
|
|
1070
|
-
if (e.length === 0)
|
|
1071
|
-
return !1;
|
|
1072
|
-
const n = t.replace(mt, "");
|
|
1073
|
-
return e.some((o) => new RegExp(`\\b${o}\\s*\\(`).test(n));
|
|
1074
|
-
}
|
|
1075
|
-
function Je(t, e) {
|
|
1076
|
-
return `Demiurge will not build an app with page routes and no ${t}/@not-found.tsx.
|
|
1077
|
-
|
|
1078
|
-
"${e}" declares a page, so a browser can reach a path this app does not serve. Decide what that looks like rather than shipping the framework built-in.
|
|
1079
|
-
|
|
1080
|
-
Create ${t}/@not-found.tsx:
|
|
1081
|
-
|
|
1082
|
-
export default function NotFound({ pathname }: { pathname: string }) {
|
|
1083
|
-
return <h1>Nothing at {pathname}</h1>;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
It renders inside the layouts above the requested path. Opt out with "export const layout = false".`;
|
|
1087
|
-
}
|
|
1088
|
-
function Be(t) {
|
|
1089
|
-
return `Demiurge is serving its built-in 404 because ${t} does not exist.
|
|
1090
|
-
|
|
1091
|
-
Create it before building for production:
|
|
1092
|
-
|
|
1093
|
-
export default function NotFound({ pathname }: { pathname: string }) {
|
|
1094
|
-
return <h1>Nothing at {pathname}</h1>;
|
|
1095
|
-
}
|
|
1096
|
-
`;
|
|
1097
|
-
}
|
|
1098
|
-
function Ue({
|
|
1099
|
-
entrySrc: t,
|
|
1100
|
-
lang: e,
|
|
1101
|
-
links: n,
|
|
1102
|
-
metadata: o,
|
|
1103
|
-
nonce: r,
|
|
1104
|
-
scripts: i,
|
|
1105
|
-
styles: s,
|
|
1106
|
-
title: a
|
|
1107
|
-
}) {
|
|
1108
|
-
return Mt({
|
|
1109
|
-
entrySrc: t,
|
|
1110
|
-
lang: e,
|
|
1111
|
-
links: n,
|
|
1112
|
-
metadata: o,
|
|
1113
|
-
nonce: r,
|
|
1114
|
-
scripts: i,
|
|
1115
|
-
styles: s,
|
|
1116
|
-
title: a
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
async function _(t, e) {
|
|
1120
|
-
const n = w(t, e.routesDir ?? "src/routes"), o = w(
|
|
1121
|
-
t,
|
|
1122
|
-
typeof e.typedRoutes == "object" ? e.typedRoutes.outputFile ?? it : it
|
|
1123
|
-
);
|
|
1124
|
-
await Jt({ outputFile: o, routesDir: n });
|
|
1125
|
-
}
|
|
1126
|
-
function A(t, e) {
|
|
1127
|
-
return e.startsWith(t) && /\.tsx?$/.test(e);
|
|
1128
|
-
}
|
|
1129
|
-
async function ze(t, e) {
|
|
1130
|
-
const n = await K(e), o = {};
|
|
1131
|
-
for (const r of n) {
|
|
1132
|
-
const i = Xe(e, r);
|
|
1133
|
-
o[i] = async () => await t.ssrLoadModule(r);
|
|
1134
|
-
}
|
|
1135
|
-
return o;
|
|
1136
|
-
}
|
|
1137
|
-
async function Ge(t, e, n = {}) {
|
|
1138
|
-
const o = new URL(e.url);
|
|
1139
|
-
return Tt(t.routes, o.pathname) ? await At(t, e, n) : "next";
|
|
1140
|
-
}
|
|
1141
|
-
async function K(t) {
|
|
1142
|
-
return (await ht(t, {
|
|
1143
|
-
recursive: !0,
|
|
1144
|
-
withFileTypes: !0
|
|
1145
|
-
})).filter((n) => n.isFile() && /\.tsx?$/.test(n.name)).map((n) => w(n.parentPath, n.name));
|
|
1146
|
-
}
|
|
1147
|
-
const qe = 8, Ye = 50;
|
|
1148
|
-
async function Ke(t, e, n) {
|
|
1149
|
-
const o = new Array(t.length);
|
|
1150
|
-
let r = 0;
|
|
1151
|
-
const i = Array.from(
|
|
1152
|
-
{ length: Math.min(e, t.length) },
|
|
1153
|
-
async () => {
|
|
1154
|
-
for (; r < t.length; ) {
|
|
1155
|
-
const s = r++;
|
|
1156
|
-
o[s] = await n(t[s]);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
);
|
|
1160
|
-
return await Promise.all(i), o;
|
|
1161
|
-
}
|
|
1162
|
-
async function yt(t, e = {}) {
|
|
1163
|
-
const n = w(t, e.routesDir ?? "src/routes");
|
|
1164
|
-
return G(n) ? (await Ke(
|
|
1165
|
-
await K(n),
|
|
1166
|
-
qe,
|
|
1167
|
-
oe
|
|
1168
|
-
)).flat().sort(
|
|
1169
|
-
(r, i) => r.file.localeCompare(i.file) || (r.exportName ?? "").localeCompare(i.exportName ?? "") || r.code.localeCompare(i.code)
|
|
1170
|
-
) : [];
|
|
1171
|
-
}
|
|
1172
|
-
function Qe(t) {
|
|
1173
|
-
return [
|
|
1174
|
-
"Demiurge found invalid static route policy:",
|
|
1175
|
-
...t.map(St)
|
|
1176
|
-
].join(`
|
|
1177
|
-
`);
|
|
1178
|
-
}
|
|
1179
|
-
function St(t) {
|
|
1180
|
-
return `${t.exportName ? `${t.file} export ${t.exportName}` : t.file}: [${t.code}] ${t.message}`;
|
|
1181
|
-
}
|
|
1182
|
-
function Xe(t, e) {
|
|
1183
|
-
return `./routes/${R(t, e).split(S).join("/")}`;
|
|
1184
|
-
}
|
|
1
|
+
import { R as t, a as s, c as n, b as u, d as r, e as l, f as o, g as i, h as b, i as _, j as c, k as d, l as R, m as v, n as f, o as m, p as y, r as E, s as P, v as S, q as g } from "../chunks/plugin-BQgMiHxa.js";
|
|
1185
2
|
export {
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
3
|
+
t as unstable_ROUTE_AUDIT_PATH,
|
|
4
|
+
s as unstable_assertRootNotFoundRoute,
|
|
5
|
+
n as unstable_createClientEntrySource,
|
|
6
|
+
u as unstable_createClientEnvSource,
|
|
7
|
+
r as unstable_createDevRouteImporters,
|
|
8
|
+
l as unstable_createDocumentHtml,
|
|
9
|
+
o as unstable_createRouteAudit,
|
|
10
|
+
i as unstable_createServerEntrySource,
|
|
11
|
+
b as unstable_declaresPageRoute,
|
|
12
|
+
_ as unstable_demiurge,
|
|
13
|
+
c as unstable_findEnvImportPath,
|
|
14
|
+
d as unstable_findEnvKeyReferences,
|
|
15
|
+
R as unstable_findServerEnvKeys,
|
|
16
|
+
v as unstable_formatEnvBoundaryFindings,
|
|
17
|
+
f as unstable_formatStaticPolicyFindings,
|
|
18
|
+
m as unstable_handleDevRequest,
|
|
19
|
+
y as unstable_isRouteAuditEnabled,
|
|
20
|
+
E as unstable_renderRouteAuditDocument,
|
|
21
|
+
P as unstable_stripClientPageData,
|
|
22
|
+
S as unstable_verifyRoutePolicies,
|
|
23
|
+
g as unstable_verifyRoutePolicySource
|
|
1198
24
|
};
|
|
1199
25
|
//# sourceMappingURL=index.js.map
|