@demiurgejs/core 0.2.0-beta.2 → 0.2.0-beta.3
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/dist/adapter/testing.js.map +1 -1
- package/dist/browser/file-router.d.ts.map +1 -1
- package/dist/chunks/{document-shell-D1xo6cEA.js → document-shell-WoM8yZlR.js} +2 -2
- package/dist/chunks/{document-shell-D1xo6cEA.js.map → document-shell-WoM8yZlR.js.map} +1 -1
- package/dist/chunks/{image-codec-BGTx_t5K.js → image-codec-Di53WpcH.js} +2 -2
- package/dist/chunks/{image-codec-BGTx_t5K.js.map → image-codec-Di53WpcH.js.map} +1 -1
- package/dist/chunks/{images-B9MqcjSA.js → images-Edar3eU1.js} +2 -2
- package/dist/chunks/{images-B9MqcjSA.js.map → images-Edar3eU1.js.map} +1 -1
- package/dist/chunks/{request-metadata-D5NrT8ks.js → request-metadata-DaIYq4Ea.js} +214 -179
- package/dist/chunks/request-metadata-DaIYq4Ea.js.map +1 -0
- package/dist/chunks/{streaming-BQ1bykDo.js → streaming-D0fGAuiO.js} +5 -5
- package/dist/chunks/streaming-D0fGAuiO.js.map +1 -0
- package/dist/chunks/{testing-B_iMFYz_.js → testing-CRflAw4X.js} +1228 -1074
- package/dist/chunks/testing-CRflAw4X.js.map +1 -0
- package/dist/data/cache.d.ts +8 -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/document/deferred-scripts.d.ts.map +1 -1
- package/dist/document/hydration.d.ts.map +1 -1
- package/dist/document/index.d.ts +1 -0
- package/dist/document/index.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/index.js +3 -3
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +768 -432
- package/dist/index.js.map +1 -1
- package/dist/internal/testing.js +9 -9
- package/dist/kv/index.d.ts +2 -0
- package/dist/kv/index.d.ts.map +1 -1
- package/dist/kv/index.js +71 -48
- 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/store.d.ts.map +1 -1
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/image.d.ts.map +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +3 -3
- package/dist/node/index.js.map +1 -1
- package/dist/node/static.d.ts.map +1 -1
- package/dist/node/streaming.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/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 +2 -0
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +84 -46
- 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/store.d.ts.map +1 -1
- package/dist/route/action.d.ts.map +1 -1
- package/dist/route/middleware.d.ts.map +1 -1
- package/dist/route/response.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 +1 -0
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/security/cookies.d.ts +26 -0
- package/dist/security/cookies.d.ts.map +1 -0
- 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 +5 -1
- 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/request.d.ts.map +1 -1
- package/dist/security/types.d.ts +72 -3
- package/dist/security/types.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +6 -2
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +4 -4
- package/dist/static/index.js.map +1 -1
- package/dist/vite/index.d.ts +3 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +1030 -666
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugin.d.ts +2 -0
- 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 +1 -1
- package/dist/chunks/request-metadata-D5NrT8ks.js.map +0 -1
- package/dist/chunks/streaming-BQ1bykDo.js.map +0 -1
- package/dist/chunks/testing-B_iMFYz_.js.map +0 -1
package/dist/vite/index.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { existsSync as
|
|
2
|
-
import { mkdir as
|
|
3
|
-
import { dirname as
|
|
4
|
-
import
|
|
5
|
-
import { transformWithEsbuild as
|
|
6
|
-
import { e as
|
|
7
|
-
import { v as
|
|
1
|
+
import { existsSync as re } from "node:fs";
|
|
2
|
+
import { mkdir as Ve, writeFile as We, readdir as De, readFile as Pe } from "node:fs/promises";
|
|
3
|
+
import { dirname as ne, resolve as b, relative as N, sep as O, join as He } from "node:path";
|
|
4
|
+
import Ue from "magic-string";
|
|
5
|
+
import { transformWithEsbuild as Je, parseAst as oe } from "vite";
|
|
6
|
+
import { e as qe, f as ze } from "../chunks/request-metadata-DaIYq4Ea.js";
|
|
7
|
+
import { v as Ge, f as Be, g as Ke, s as U, l as se, i as Ye, j as Q, t as Qe, k as Xe, n as Oe, M as Ze, o as et, p as z, q as ae, u as tt, w as rt, x as nt, r as ot, h as it, y as st } from "../chunks/testing-CRflAw4X.js";
|
|
8
8
|
import "react";
|
|
9
9
|
import "react-dom/server";
|
|
10
10
|
import "react/jsx-runtime";
|
|
11
|
-
import { c as
|
|
12
|
-
import { p as
|
|
13
|
-
const
|
|
14
|
-
async function
|
|
15
|
-
const
|
|
16
|
-
return await
|
|
11
|
+
import { c as at, t as ce, U as ue, w as le, b as k, d as ct, e as ut } from "../chunks/streaming-D0fGAuiO.js";
|
|
12
|
+
import { p as lt } from "../chunks/images-Edar3eU1.js";
|
|
13
|
+
const P = "@demiurgejs/core";
|
|
14
|
+
async function dt(e) {
|
|
15
|
+
const t = await ft(e.routesDir), r = t.map((i) => mt(e, i)).filter((i) => !!i), o = t.map((i) => pt(e.routesDir, i, r)).filter((i) => !!i).sort((i, s) => i.pattern.localeCompare(s.pattern)), n = ht(o, r);
|
|
16
|
+
return await Ve(ne(e.outputFile), { recursive: !0 }), await We(e.outputFile, n), {
|
|
17
17
|
routes: o,
|
|
18
|
-
source:
|
|
18
|
+
source: n
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
async function
|
|
22
|
-
return (await
|
|
21
|
+
async function ft(e) {
|
|
22
|
+
return (await De(e, {
|
|
23
23
|
recursive: !0,
|
|
24
24
|
withFileTypes: !0
|
|
25
|
-
})).filter((
|
|
25
|
+
})).filter((r) => r.isFile() && /\.tsx?$/.test(r.name)).map((r) => b(r.parentPath, r.name));
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
27
|
+
function pt(e, t, r) {
|
|
28
|
+
const n = N(e, t).split(O).join("/").replace(/\.tsx?$/, "").split("/");
|
|
29
|
+
if (n.at(-1)?.startsWith("@"))
|
|
30
30
|
return null;
|
|
31
|
-
const s =
|
|
31
|
+
const s = n.flatMap((c) => de(c) ? [] : c === "index" ? [] : c.startsWith("[...") && c.endsWith("]") ? [c] : c.startsWith("[") && c.endsWith("]") ? [c] : [c]), a = n.flatMap((c) => de(c) ? [] : c.startsWith("[...") && c.endsWith("]") ? [c.slice(4, -1)] : c.startsWith("[") && c.endsWith("]") ? [c.slice(1, -1)] : []);
|
|
32
32
|
return {
|
|
33
|
-
contextMiddleware:
|
|
34
|
-
fileSegments:
|
|
33
|
+
contextMiddleware: r.filter((c) => yt(c.fileSegments, n)).map((c) => r.indexOf(c)),
|
|
34
|
+
fileSegments: n,
|
|
35
35
|
pathVars: a,
|
|
36
36
|
pattern: `/${s.join("/")}`.replace(/\/$/, "") || "/"
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const o =
|
|
39
|
+
function mt(e, t) {
|
|
40
|
+
const o = N(e.routesDir, t).split(O).join("/").replace(/\.tsx?$/, "").split("/");
|
|
41
41
|
if (o.at(-1) !== "@middleware")
|
|
42
42
|
return null;
|
|
43
|
-
let
|
|
44
|
-
return
|
|
43
|
+
let n = N(ne(e.outputFile), t).split(O).join("/").replace(/\.tsx?$/, "");
|
|
44
|
+
return n.startsWith(".") || (n = `./${n}`), { file: t, fileSegments: o.slice(0, -1), importPath: n };
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
return
|
|
48
|
-
(
|
|
46
|
+
function yt(e, t) {
|
|
47
|
+
return e.every(
|
|
48
|
+
(r, o) => t[o] === r
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
51
|
+
function de(e) {
|
|
52
|
+
return e.startsWith("(") && e.endsWith(")");
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function ht(e, t) {
|
|
55
55
|
return `// Generated by Demiurge. Do not edit by hand.
|
|
56
|
-
import "${
|
|
57
|
-
import type { MiddlewareContextOf, PathValue } from "${
|
|
58
|
-
${
|
|
56
|
+
import "${P}";
|
|
57
|
+
import type { MiddlewareContextOf, PathValue } from "${P}";
|
|
58
|
+
${t.map(gt).join(`
|
|
59
59
|
`)}
|
|
60
60
|
|
|
61
|
-
${
|
|
61
|
+
${t.map((r, o) => wt(o)).join(`
|
|
62
62
|
`)}
|
|
63
63
|
|
|
64
|
-
declare module "${
|
|
64
|
+
declare module "${P}" {
|
|
65
65
|
interface RoutePathVars {
|
|
66
|
-
${
|
|
66
|
+
${e.map(Rt).join(`
|
|
67
67
|
`)}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
interface RouteConcretePaths {
|
|
71
|
-
${
|
|
71
|
+
${e.map(vt).join(`
|
|
72
72
|
`)}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
interface RouteRequestContexts {
|
|
76
|
-
${
|
|
76
|
+
${e.map(bt).join(`
|
|
77
77
|
`)}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -81,32 +81,32 @@ ${t.map(Zt).join(`
|
|
|
81
81
|
export {};
|
|
82
82
|
`;
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
return `type __DemiurgeMiddleware${
|
|
84
|
+
function gt(e, t) {
|
|
85
|
+
return `type __DemiurgeMiddleware${t} = typeof import(${JSON.stringify(e.importPath)}) extends { middleware?: infer T } ? T : never;`;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
return `type __DemiurgeMiddlewareContext${
|
|
87
|
+
function wt(e) {
|
|
88
|
+
return `type __DemiurgeMiddlewareContext${e} = MiddlewareContextOf<__DemiurgeMiddleware${e}>;`;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
if (
|
|
92
|
-
return ` ${JSON.stringify(
|
|
93
|
-
const
|
|
94
|
-
return ` ${JSON.stringify(
|
|
90
|
+
function Rt(e) {
|
|
91
|
+
if (e.pathVars.length === 0)
|
|
92
|
+
return ` ${JSON.stringify(e.pattern)}: {};`;
|
|
93
|
+
const t = e.pathVars.map((r) => `${r}: PathValue`).join("; ");
|
|
94
|
+
return ` ${JSON.stringify(e.pattern)}: { ${t} };`;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
return ` ${JSON.stringify(
|
|
96
|
+
function vt(e) {
|
|
97
|
+
return ` ${JSON.stringify(e.pattern)}: ${$t(e.pattern)};`;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
const
|
|
101
|
-
return ` ${JSON.stringify(
|
|
99
|
+
function bt(e) {
|
|
100
|
+
const t = e.contextMiddleware.map((o) => `__DemiurgeMiddlewareContext${o}`), r = t.length > 0 ? t.join(" & ") : "Record<never, never>";
|
|
101
|
+
return ` ${JSON.stringify(e.pattern)}: ${r};`;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
103
|
+
function $t(e) {
|
|
104
|
+
return e.includes("[") ? `\`${e.split(/(\[\.\.\.[^\]]+\]|\[[^\]]+\])/g).filter(Boolean).map((r) => r.startsWith("[") ? "${PathValue}" : St(r)).join("")}\`` : JSON.stringify(e);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return
|
|
106
|
+
function St(e) {
|
|
107
|
+
return e.replace(/[`$\\]/g, "\\$&");
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const xt = [
|
|
110
110
|
"GET",
|
|
111
111
|
"POST",
|
|
112
112
|
"PUT",
|
|
@@ -114,7 +114,7 @@ const re = [
|
|
|
114
114
|
"DELETE",
|
|
115
115
|
"OPTIONS",
|
|
116
116
|
"HEAD"
|
|
117
|
-
],
|
|
117
|
+
], Et = /* @__PURE__ */ new Set([
|
|
118
118
|
"action",
|
|
119
119
|
"html",
|
|
120
120
|
"json",
|
|
@@ -126,326 +126,671 @@ const re = [
|
|
|
126
126
|
"stream",
|
|
127
127
|
"text"
|
|
128
128
|
]);
|
|
129
|
-
async function
|
|
130
|
-
const
|
|
131
|
-
return await
|
|
129
|
+
async function Nt(e) {
|
|
130
|
+
const t = await Pe(e, "utf8");
|
|
131
|
+
return await Dt(t, e);
|
|
132
132
|
}
|
|
133
|
-
async function
|
|
134
|
-
const
|
|
133
|
+
async function Dt(e, t) {
|
|
134
|
+
const r = t.endsWith(".tsx") ? "tsx" : "ts", o = await Je(e, t, {
|
|
135
135
|
format: "esm",
|
|
136
|
-
loader:
|
|
136
|
+
loader: r,
|
|
137
137
|
target: "esnext"
|
|
138
|
-
}),
|
|
139
|
-
return
|
|
138
|
+
}), n = Pt(o.code);
|
|
139
|
+
return Ct(n, t);
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
const
|
|
141
|
+
function Pt(e) {
|
|
142
|
+
const t = oe(e), r = jt(t), o = _t(t), n = Ot(t), i = Mt(t), s = {}, a = /* @__PURE__ */ new Set();
|
|
143
143
|
let c;
|
|
144
|
-
for (const [u,
|
|
145
|
-
const
|
|
144
|
+
for (const [u, d] of i) {
|
|
145
|
+
const h = n.get(d);
|
|
146
146
|
if (u === "policy") {
|
|
147
|
-
|
|
147
|
+
h && (c = Me(h, r, o));
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
|
-
if (!
|
|
151
|
-
const
|
|
152
|
-
|
|
150
|
+
if (!Ft(u) || (a.add(u), !h)) continue;
|
|
151
|
+
const D = Tt(h, r, o);
|
|
152
|
+
D && (s[u] = D);
|
|
153
153
|
}
|
|
154
154
|
return { capabilities: s, declaredMethods: a, policy: c };
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
const
|
|
158
|
-
for (const
|
|
159
|
-
const o =
|
|
156
|
+
function Ot(e) {
|
|
157
|
+
const t = /* @__PURE__ */ new Map();
|
|
158
|
+
for (const r of y(e.body)) {
|
|
159
|
+
const o = r.type === "ExportNamedDeclaration" ? R(r.declaration) : r;
|
|
160
160
|
if (o?.type === "VariableDeclaration")
|
|
161
|
-
for (const
|
|
162
|
-
const i =
|
|
163
|
-
i && s &&
|
|
161
|
+
for (const n of y(o.declarations)) {
|
|
162
|
+
const i = T(n.id), s = R(n.init);
|
|
163
|
+
i && s && t.set(i, s);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
return
|
|
166
|
+
return t;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
const
|
|
170
|
-
for (const
|
|
171
|
-
if (
|
|
172
|
-
const o =
|
|
168
|
+
function Mt(e) {
|
|
169
|
+
const t = /* @__PURE__ */ new Map();
|
|
170
|
+
for (const r of y(e.body)) {
|
|
171
|
+
if (r.type !== "ExportNamedDeclaration") continue;
|
|
172
|
+
const o = R(r.declaration);
|
|
173
173
|
if (o?.type === "VariableDeclaration")
|
|
174
|
-
for (const
|
|
175
|
-
const i =
|
|
176
|
-
i &&
|
|
174
|
+
for (const n of y(o.declarations)) {
|
|
175
|
+
const i = T(n.id);
|
|
176
|
+
i && t.set(i, i);
|
|
177
177
|
}
|
|
178
|
-
for (const
|
|
179
|
-
const i =
|
|
180
|
-
i && s &&
|
|
178
|
+
for (const n of y(r.specifiers)) {
|
|
179
|
+
const i = M(n.exported), s = M(n.local);
|
|
180
|
+
i && s && t.set(i, s);
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
return
|
|
183
|
+
return t;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
if (
|
|
187
|
-
const o =
|
|
188
|
-
if (!
|
|
189
|
-
const i =
|
|
185
|
+
function Tt(e, t, r) {
|
|
186
|
+
if (e.type !== "CallExpression") return;
|
|
187
|
+
const o = T(e.callee), n = o ? t.get(o) : void 0;
|
|
188
|
+
if (!n || !Et.has(n)) return;
|
|
189
|
+
const i = y(e.arguments), s = n === "action" ? i[0] : i[1];
|
|
190
190
|
if (!s) return {};
|
|
191
|
-
const a =
|
|
191
|
+
const a = fe(s, "cors", r), c = fe(
|
|
192
192
|
s,
|
|
193
193
|
"security",
|
|
194
|
-
|
|
194
|
+
r
|
|
195
195
|
);
|
|
196
196
|
return {
|
|
197
|
-
cors:
|
|
198
|
-
security:
|
|
197
|
+
cors: I(a) ? a : void 0,
|
|
198
|
+
security: I(c) ? c : void 0
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
if (
|
|
203
|
-
const
|
|
204
|
-
return
|
|
201
|
+
function fe(e, t, r) {
|
|
202
|
+
if (e.type === "Identifier") {
|
|
203
|
+
const n = r.get(String(e.name));
|
|
204
|
+
return I(n) ? n[t] : g;
|
|
205
205
|
}
|
|
206
|
-
if (
|
|
206
|
+
if (e.type !== "ObjectExpression") return g;
|
|
207
207
|
let o;
|
|
208
|
-
for (const
|
|
209
|
-
if (
|
|
210
|
-
|
|
208
|
+
for (const n of y(e.properties)) {
|
|
209
|
+
if (n.type !== "Property" || n.computed) return g;
|
|
210
|
+
M(n.key) === t && (o = x(R(n.value), r));
|
|
211
211
|
}
|
|
212
212
|
return o;
|
|
213
213
|
}
|
|
214
|
-
function
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
const i =
|
|
219
|
-
return i ?
|
|
214
|
+
function Me(e, t, r) {
|
|
215
|
+
if (e.type === "CallExpression") {
|
|
216
|
+
const n = T(e.callee);
|
|
217
|
+
if (n && t.get(n) === "defineRoutePolicy") {
|
|
218
|
+
const i = y(e.arguments)[0];
|
|
219
|
+
return i ? Me(i, t, r) : void 0;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
if (
|
|
223
|
-
const
|
|
224
|
-
return
|
|
222
|
+
if (e.type !== "ObjectExpression") {
|
|
223
|
+
const n = x(e, r);
|
|
224
|
+
return I(n) ? n : void 0;
|
|
225
225
|
}
|
|
226
226
|
const o = {};
|
|
227
|
-
for (const
|
|
228
|
-
if (
|
|
229
|
-
const i =
|
|
227
|
+
for (const n of y(e.properties)) {
|
|
228
|
+
if (n.type !== "Property" || n.computed) return;
|
|
229
|
+
const i = M(n.key), s = R(n.value);
|
|
230
230
|
if (!i || !s) return;
|
|
231
231
|
if (i === "document") {
|
|
232
|
-
const c =
|
|
232
|
+
const c = At(s, t, r);
|
|
233
233
|
if (!c) return;
|
|
234
234
|
o.document = c;
|
|
235
235
|
continue;
|
|
236
236
|
}
|
|
237
|
-
const a =
|
|
238
|
-
if (a ===
|
|
237
|
+
const a = x(s, r);
|
|
238
|
+
if (a === g) return;
|
|
239
239
|
o[i] = a;
|
|
240
240
|
}
|
|
241
241
|
return o;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
if (
|
|
245
|
-
const a =
|
|
246
|
-
return
|
|
243
|
+
function At(e, t, r) {
|
|
244
|
+
if (e.type !== "CallExpression") {
|
|
245
|
+
const a = x(e, r);
|
|
246
|
+
return I(a) ? a : void 0;
|
|
247
247
|
}
|
|
248
|
-
const o =
|
|
248
|
+
const o = R(e.callee);
|
|
249
249
|
if (o?.type !== "MemberExpression") return;
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
250
|
+
const n = T(o.object), i = M(o.property);
|
|
251
|
+
if (!n || t.get(n) !== "security" || !i)
|
|
252
252
|
return;
|
|
253
|
-
const s =
|
|
254
|
-
if (!(s !==
|
|
255
|
-
if (i === "api")
|
|
253
|
+
const s = x(y(e.arguments)[0], r);
|
|
254
|
+
if (!(s !== g && s !== void 0 && !I(s))) {
|
|
255
|
+
if (i === "api")
|
|
256
|
+
return U.api(s);
|
|
256
257
|
if (i === "crossOriginIsolated")
|
|
257
|
-
return
|
|
258
|
-
if (i === "static")
|
|
259
|
-
|
|
258
|
+
return U.crossOriginIsolated(s);
|
|
259
|
+
if (i === "static")
|
|
260
|
+
return U.static(s);
|
|
261
|
+
if (i === "strict")
|
|
262
|
+
return U.strict(s);
|
|
260
263
|
}
|
|
261
264
|
}
|
|
262
|
-
function
|
|
263
|
-
const
|
|
265
|
+
function Ct(e, t) {
|
|
266
|
+
const r = [], o = new Set(e.declaredMethods);
|
|
264
267
|
o.has("GET") && o.add("HEAD"), o.add("OPTIONS");
|
|
265
|
-
for (const [
|
|
266
|
-
|
|
268
|
+
for (const [n, i] of Object.entries(
|
|
269
|
+
e.capabilities
|
|
267
270
|
)) {
|
|
268
271
|
if (i.cors) {
|
|
269
272
|
try {
|
|
270
|
-
|
|
273
|
+
Ge(i.cors);
|
|
271
274
|
} catch (s) {
|
|
272
|
-
|
|
275
|
+
r.push(q(
|
|
273
276
|
"cors-invalid",
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
t,
|
|
278
|
+
ee(s, "The CORS policy is invalid."),
|
|
279
|
+
n
|
|
277
280
|
));
|
|
278
281
|
}
|
|
279
282
|
for (const s of i.cors.methods ?? [])
|
|
280
|
-
o.has(s) ||
|
|
283
|
+
o.has(s) || r.push(q(
|
|
281
284
|
"cors-method-unavailable",
|
|
282
|
-
|
|
285
|
+
t,
|
|
283
286
|
`CORS method ${s} is not available from this route.`,
|
|
284
|
-
|
|
287
|
+
n
|
|
285
288
|
));
|
|
286
289
|
}
|
|
287
|
-
|
|
290
|
+
pe(i.security, t, n, r);
|
|
288
291
|
}
|
|
289
|
-
if (
|
|
292
|
+
if (pe(e.policy?.security, t, void 0, r), e.policy?.document)
|
|
290
293
|
try {
|
|
291
|
-
|
|
294
|
+
Be(It(e.policy.document), {
|
|
292
295
|
nonce: "build-verification-nonce"
|
|
293
296
|
});
|
|
294
|
-
} catch (
|
|
295
|
-
|
|
297
|
+
} catch (n) {
|
|
298
|
+
r.push(q(
|
|
296
299
|
"security-header-render-failed",
|
|
297
|
-
|
|
298
|
-
|
|
300
|
+
t,
|
|
301
|
+
ee(n, "The security headers are invalid.")
|
|
299
302
|
));
|
|
300
303
|
}
|
|
301
|
-
return
|
|
304
|
+
return r;
|
|
302
305
|
}
|
|
303
|
-
function
|
|
304
|
-
const
|
|
305
|
-
return
|
|
306
|
-
...
|
|
307
|
-
csp: { ...
|
|
308
|
-
headers:
|
|
306
|
+
function It(e) {
|
|
307
|
+
const t = e.headers?.reportingEndpoints, r = !!(t && Object.keys(t).length), o = e.csp === !1 ? void 0 : e.csp?.reportTo;
|
|
308
|
+
return r || !o ? e : {
|
|
309
|
+
...e,
|
|
310
|
+
csp: { ...e.csp, reportTo: void 0 },
|
|
311
|
+
headers: t ? { ...e.headers, reportingEndpoints: void 0 } : e.headers
|
|
309
312
|
};
|
|
310
313
|
}
|
|
311
|
-
function
|
|
312
|
-
if (
|
|
314
|
+
function pe(e, t, r, o) {
|
|
315
|
+
if (e?.rateLimit)
|
|
313
316
|
try {
|
|
314
|
-
|
|
315
|
-
} catch (
|
|
316
|
-
o.push(
|
|
317
|
+
Ke(e.rateLimit);
|
|
318
|
+
} catch (n) {
|
|
319
|
+
o.push(q(
|
|
317
320
|
"rate-limit-invalid",
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
+
t,
|
|
322
|
+
ee(n, "The rate limit policy is invalid."),
|
|
323
|
+
r
|
|
321
324
|
));
|
|
322
325
|
}
|
|
323
326
|
}
|
|
324
|
-
function
|
|
325
|
-
return { code:
|
|
327
|
+
function q(e, t, r, o) {
|
|
328
|
+
return { code: e, exportName: o, file: t, message: r, severity: "error" };
|
|
326
329
|
}
|
|
327
|
-
function
|
|
328
|
-
const
|
|
329
|
-
for (const
|
|
330
|
-
if (!(
|
|
331
|
-
for (const o of
|
|
330
|
+
function jt(e) {
|
|
331
|
+
const t = /* @__PURE__ */ new Map();
|
|
332
|
+
for (const r of y(e.body))
|
|
333
|
+
if (!(r.type !== "ImportDeclaration" || R(r.source)?.value !== "@demiurgejs/core"))
|
|
334
|
+
for (const o of y(r.specifiers)) {
|
|
332
335
|
if (o.type !== "ImportSpecifier") continue;
|
|
333
|
-
const
|
|
334
|
-
|
|
336
|
+
const n = T(o.local), i = M(o.imported);
|
|
337
|
+
n && i && t.set(n, i);
|
|
335
338
|
}
|
|
336
|
-
return
|
|
339
|
+
return t;
|
|
337
340
|
}
|
|
338
|
-
function
|
|
339
|
-
const
|
|
340
|
-
for (const
|
|
341
|
-
const o =
|
|
341
|
+
function _t(e) {
|
|
342
|
+
const t = /* @__PURE__ */ new Map();
|
|
343
|
+
for (const r of y(e.body)) {
|
|
344
|
+
const o = r.type === "ExportNamedDeclaration" ? R(r.declaration) : r;
|
|
342
345
|
if (o?.type === "VariableDeclaration")
|
|
343
|
-
for (const
|
|
344
|
-
const i =
|
|
346
|
+
for (const n of y(o.declarations)) {
|
|
347
|
+
const i = T(n.id), s = R(n.init);
|
|
345
348
|
if (!i || !s) continue;
|
|
346
|
-
const a =
|
|
347
|
-
a !==
|
|
349
|
+
const a = x(s, t);
|
|
350
|
+
a !== g && t.set(i, a);
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
const
|
|
353
|
-
function
|
|
354
|
-
if (
|
|
355
|
-
if (
|
|
356
|
-
if (
|
|
357
|
-
return
|
|
358
|
-
if (
|
|
359
|
-
return
|
|
360
|
-
if (
|
|
361
|
-
const
|
|
362
|
-
return typeof
|
|
353
|
+
return t;
|
|
354
|
+
}
|
|
355
|
+
const g = Symbol("unresolved");
|
|
356
|
+
function x(e, t) {
|
|
357
|
+
if (e) {
|
|
358
|
+
if (e.type === "Literal") return e.value;
|
|
359
|
+
if (e.type === "Identifier")
|
|
360
|
+
return e.name === "undefined" ? void 0 : t.has(String(e.name)) ? t.get(String(e.name)) : g;
|
|
361
|
+
if (e.type === "TemplateLiteral")
|
|
362
|
+
return y(e.expressions).length ? g : y(e.quasis).map((r) => R(r.value)?.cooked ?? "").join("");
|
|
363
|
+
if (e.type === "UnaryExpression") {
|
|
364
|
+
const r = x(R(e.argument), t);
|
|
365
|
+
return typeof r != "number" ? g : e.operator === "-" ? -r : e.operator === "+" ? r : g;
|
|
366
|
+
}
|
|
367
|
+
if (e.type === "ArrayExpression") {
|
|
368
|
+
const r = [];
|
|
369
|
+
for (const o of y(e.elements)) {
|
|
370
|
+
const n = x(o, t);
|
|
371
|
+
if (n === g) return g;
|
|
372
|
+
r.push(n);
|
|
373
|
+
}
|
|
374
|
+
return r;
|
|
363
375
|
}
|
|
364
|
-
if (
|
|
365
|
-
const
|
|
366
|
-
for (const o of
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
n
|
|
376
|
+
if (e.type === "ObjectExpression") {
|
|
377
|
+
const r = {};
|
|
378
|
+
for (const o of y(e.properties)) {
|
|
379
|
+
if (o.type !== "Property" || o.computed) return g;
|
|
380
|
+
const n = M(o.key), i = x(R(o.value), t);
|
|
381
|
+
if (!n || i === g) return g;
|
|
382
|
+
r[n] = i;
|
|
370
383
|
}
|
|
371
|
-
return
|
|
384
|
+
return r;
|
|
372
385
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
386
|
+
return g;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function Ft(e) {
|
|
390
|
+
return xt.includes(e);
|
|
391
|
+
}
|
|
392
|
+
function ee(e, t) {
|
|
393
|
+
return e instanceof Error ? e.message : t;
|
|
394
|
+
}
|
|
395
|
+
function I(e) {
|
|
396
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
397
|
+
}
|
|
398
|
+
function R(e) {
|
|
399
|
+
return e && typeof e == "object" && "type" in e ? e : void 0;
|
|
400
|
+
}
|
|
401
|
+
function y(e) {
|
|
402
|
+
return Array.isArray(e) ? e.map(R).filter((t) => !!t) : [];
|
|
403
|
+
}
|
|
404
|
+
function T(e) {
|
|
405
|
+
const t = R(e);
|
|
406
|
+
return t?.type === "Identifier" ? String(t.name) : void 0;
|
|
407
|
+
}
|
|
408
|
+
function M(e) {
|
|
409
|
+
const t = R(e);
|
|
410
|
+
return t?.type === "Identifier" || t?.type === "Literal" ? String(t.name ?? t.value) : void 0;
|
|
411
|
+
}
|
|
412
|
+
const Te = "/_demiurge/audit", Ae = [
|
|
413
|
+
"GET",
|
|
414
|
+
"POST",
|
|
415
|
+
"PUT",
|
|
416
|
+
"PATCH",
|
|
417
|
+
"DELETE",
|
|
418
|
+
"OPTIONS",
|
|
419
|
+
"HEAD"
|
|
420
|
+
];
|
|
421
|
+
function kt(e) {
|
|
422
|
+
return new URL(e.url).pathname === Te;
|
|
423
|
+
}
|
|
424
|
+
async function Lt(e, t) {
|
|
425
|
+
const r = new URL(t.url), o = await Vt(
|
|
426
|
+
e,
|
|
427
|
+
r.searchParams.get("path") || "/",
|
|
428
|
+
t
|
|
429
|
+
), n = r.searchParams.get("format") === "json";
|
|
430
|
+
return new Response(
|
|
431
|
+
n ? JSON.stringify(o, null, 2) : Jt(o),
|
|
432
|
+
{
|
|
433
|
+
headers: {
|
|
434
|
+
"cache-control": "no-store",
|
|
435
|
+
// The panel is a side channel. It declares its own policy, so the
|
|
436
|
+
// policy of the application stays unchanged. The panel runs no script.
|
|
437
|
+
"content-security-policy": "default-src 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline'",
|
|
438
|
+
"content-type": n ? "application/json; charset=utf-8" : "text/html; charset=utf-8",
|
|
439
|
+
"x-robots-tag": "noindex"
|
|
380
440
|
}
|
|
381
|
-
return n;
|
|
382
441
|
}
|
|
383
|
-
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
async function Vt(e, t, r) {
|
|
445
|
+
const o = new URL(r.url).origin, n = new URL(t, o), i = n.pathname, s = new Request(n, { headers: r.headers }), a = Wt(e, i);
|
|
446
|
+
if (!a) {
|
|
447
|
+
const p = await se(
|
|
448
|
+
e,
|
|
449
|
+
{ fileSegments: [] },
|
|
450
|
+
{},
|
|
451
|
+
void 0
|
|
452
|
+
);
|
|
453
|
+
return me({
|
|
454
|
+
cacheReads: [],
|
|
455
|
+
kind: "unmatched",
|
|
456
|
+
method: "GET",
|
|
457
|
+
pathname: i,
|
|
458
|
+
policy: p,
|
|
459
|
+
request: s,
|
|
460
|
+
scripts: []
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
const c = await a.route.load(), u = Ht(c), d = c[u], h = await se(
|
|
464
|
+
e,
|
|
465
|
+
a.route,
|
|
466
|
+
c,
|
|
467
|
+
d
|
|
468
|
+
), D = [], m = d?.kind === "page" ? await Ye(
|
|
469
|
+
e,
|
|
470
|
+
i,
|
|
471
|
+
s,
|
|
472
|
+
void 0,
|
|
473
|
+
Ut(D)
|
|
474
|
+
) : void 0, f = m?.status === "ready" ? m.match : void 0;
|
|
475
|
+
return me({
|
|
476
|
+
cacheReads: D,
|
|
477
|
+
cors: d && d.kind !== "page" ? d.cors : void 0,
|
|
478
|
+
kind: d?.kind === "page" ? "page" : "resource",
|
|
479
|
+
metadata: f?.metadata,
|
|
480
|
+
method: u,
|
|
481
|
+
pathname: i,
|
|
482
|
+
policy: h,
|
|
483
|
+
request: s,
|
|
484
|
+
route: {
|
|
485
|
+
file: a.route.file,
|
|
486
|
+
groups: a.route.fileSegments.filter(Xe),
|
|
487
|
+
layouts: e.layouts.filter((p) => Q(p.fileSegments, a.route.fileSegments)).map((p) => p.file),
|
|
488
|
+
methods: Ae.filter((p) => c[p]),
|
|
489
|
+
middlewares: e.middlewares.filter((p) => Q(p.fileSegments, a.route.fileSegments)).map((p) => p.file),
|
|
490
|
+
params: a.path,
|
|
491
|
+
pattern: Qe(a.route.segments),
|
|
492
|
+
policies: e.policies.filter((p) => Q(p.fileSegments, a.route.fileSegments)).map((p) => p.file),
|
|
493
|
+
render: f?.render.mode
|
|
494
|
+
},
|
|
495
|
+
scripts: f?.scripts ?? []
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
function me(e) {
|
|
499
|
+
const t = e.kind === "page", r = t && et(e.policy.document) ? z() : void 0, o = e.scripts.map((s) => ({
|
|
500
|
+
...s,
|
|
501
|
+
nonce: s.nonce ?? r
|
|
502
|
+
})), n = {
|
|
503
|
+
headers: { nonce: r, request: e.request },
|
|
504
|
+
policy: e.policy.document ?? {},
|
|
505
|
+
scriptDependencies: !0
|
|
506
|
+
};
|
|
507
|
+
return {
|
|
508
|
+
audit: ae({
|
|
509
|
+
document: t ? { ...n, scripts: o } : void 0,
|
|
510
|
+
route: {
|
|
511
|
+
cors: e.cors,
|
|
512
|
+
method: e.method,
|
|
513
|
+
security: e.policy.security
|
|
514
|
+
}
|
|
515
|
+
}),
|
|
516
|
+
// A nonce makes a document unique for each response. The request handler
|
|
517
|
+
// therefore replaces the cache directives of the application.
|
|
518
|
+
cacheControl: r ? "private, no-store" : void 0,
|
|
519
|
+
cacheReads: e.cacheReads,
|
|
520
|
+
kind: e.kind,
|
|
521
|
+
metadata: e.metadata,
|
|
522
|
+
method: e.method,
|
|
523
|
+
nonce: r,
|
|
524
|
+
pathname: e.pathname,
|
|
525
|
+
policy: e.policy,
|
|
526
|
+
route: e.route,
|
|
527
|
+
scripts: o.map((s) => ({
|
|
528
|
+
// One audit for each script gives the status of that script alone. The
|
|
529
|
+
// panel reads the same code path that the complete audit reads.
|
|
530
|
+
findings: ae({
|
|
531
|
+
document: { ...n, scripts: [s] }
|
|
532
|
+
}).findings,
|
|
533
|
+
integrity: s.integrity,
|
|
534
|
+
nonce: s.nonce,
|
|
535
|
+
purpose: s.purpose,
|
|
536
|
+
src: s.src,
|
|
537
|
+
strategy: s.strategy
|
|
538
|
+
}))
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function Wt(e, t) {
|
|
542
|
+
try {
|
|
543
|
+
return Oe(e.routes, t);
|
|
544
|
+
} catch (r) {
|
|
545
|
+
if (r instanceof Ze)
|
|
546
|
+
return null;
|
|
547
|
+
throw r;
|
|
384
548
|
}
|
|
385
549
|
}
|
|
386
|
-
function
|
|
387
|
-
return
|
|
550
|
+
function Ht(e) {
|
|
551
|
+
return Ae.find((t) => e[t]) ?? "GET";
|
|
388
552
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
553
|
+
function Ut(e) {
|
|
554
|
+
const t = tt();
|
|
555
|
+
return {
|
|
556
|
+
get: async (r) => (e.push({
|
|
557
|
+
key: nt(r.key),
|
|
558
|
+
scope: r.scope ?? "request",
|
|
559
|
+
staleWhileRevalidate: ye(r.staleWhileRevalidate),
|
|
560
|
+
tags: (r.tags ?? []).map(rt),
|
|
561
|
+
ttl: ye(r.ttl)
|
|
562
|
+
}), await t.get(r)),
|
|
563
|
+
invalidateKey: t.invalidateKey,
|
|
564
|
+
invalidateTags: t.invalidateTags
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
function ye(e) {
|
|
568
|
+
return e === void 0 ? void 0 : String(e);
|
|
569
|
+
}
|
|
570
|
+
function Jt(e) {
|
|
571
|
+
return `<!doctype html>
|
|
572
|
+
<html lang="en">
|
|
573
|
+
<head>
|
|
574
|
+
<meta charset="utf-8" />
|
|
575
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
576
|
+
<title>Demiurge route audit</title>
|
|
577
|
+
<style>${qt}</style>
|
|
578
|
+
</head>
|
|
579
|
+
<body>
|
|
580
|
+
<h1>Demiurge route audit</h1>
|
|
581
|
+
<form method="get" action="${Te}">
|
|
582
|
+
<label for="path">Path</label>
|
|
583
|
+
<input id="path" name="path" value="${l(e.pathname)}" />
|
|
584
|
+
<button type="submit">Audit</button>
|
|
585
|
+
</form>
|
|
586
|
+
${zt(e)}
|
|
587
|
+
${Gt(e.audit.findings)}
|
|
588
|
+
${Bt(e.audit.headers)}
|
|
589
|
+
${Kt(e)}
|
|
590
|
+
${Yt(e.metadata)}
|
|
591
|
+
${Qt(e.scripts)}
|
|
592
|
+
${Xt(e)}
|
|
593
|
+
<p class="footer">
|
|
594
|
+
The development server serves this panel. A production build and a static
|
|
595
|
+
export do not contain it.
|
|
596
|
+
</p>
|
|
597
|
+
</body>
|
|
598
|
+
</html>
|
|
599
|
+
`;
|
|
600
|
+
}
|
|
601
|
+
const qt = `
|
|
602
|
+
:root { color-scheme: light dark; }
|
|
603
|
+
body {
|
|
604
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
605
|
+
line-height: 1.5;
|
|
606
|
+
margin: 0 auto;
|
|
607
|
+
max-width: 60rem;
|
|
608
|
+
padding: 2rem 1rem;
|
|
609
|
+
}
|
|
610
|
+
h1 { font-size: 1.25rem; }
|
|
611
|
+
h2 { font-size: 1rem; margin-bottom: 0.25rem; }
|
|
612
|
+
form { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
|
|
613
|
+
input { flex: 1; padding: 0.25rem 0.5rem; }
|
|
614
|
+
section { border-top: 1px solid currentColor; padding: 0.75rem 0; }
|
|
615
|
+
table { border-collapse: collapse; width: 100%; }
|
|
616
|
+
td, th { padding: 0.25rem 0.5rem 0.25rem 0; text-align: left; vertical-align: top; }
|
|
617
|
+
th { white-space: nowrap; width: 12rem; }
|
|
618
|
+
ul { margin: 0; padding-left: 1.25rem; }
|
|
619
|
+
.empty { opacity: 0.7; }
|
|
620
|
+
.error { font-weight: 700; }
|
|
621
|
+
.footer { opacity: 0.7; }
|
|
622
|
+
`;
|
|
623
|
+
function zt(e) {
|
|
624
|
+
if (!e.route)
|
|
625
|
+
return $(
|
|
626
|
+
"Route",
|
|
627
|
+
`<p class="empty">No route matches ${l(e.pathname)}.</p>`
|
|
628
|
+
);
|
|
629
|
+
const t = e.route;
|
|
630
|
+
return $(
|
|
631
|
+
"Route",
|
|
632
|
+
C([
|
|
633
|
+
["Pathname", l(e.pathname)],
|
|
634
|
+
["Pattern", l(t.pattern)],
|
|
635
|
+
["File", l(t.file)],
|
|
636
|
+
["Kind", l(e.kind)],
|
|
637
|
+
["Method", l(e.method)],
|
|
638
|
+
["Methods", l(t.methods.join(", "))],
|
|
639
|
+
["Render mode", t.render ? l(t.render) : S()],
|
|
640
|
+
["Path values", Zt(t.params)],
|
|
641
|
+
["Route groups", A(t.groups)],
|
|
642
|
+
["Layouts", A(t.layouts)],
|
|
643
|
+
["Policies", A(t.policies)],
|
|
644
|
+
["Middleware", A(t.middlewares)]
|
|
645
|
+
])
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
function Gt(e) {
|
|
649
|
+
return e.length === 0 ? $("Findings", '<p class="empty">No findings.</p>') : $(
|
|
650
|
+
"Findings",
|
|
651
|
+
`<ul>${e.map(Ce).join("")}</ul>`
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
function Ce(e) {
|
|
655
|
+
return `<li${e.severity === "error" ? ' class="error"' : ""}>${l(e.severity)}: ${l(e.message)} <code>${l(e.code)}</code></li>`;
|
|
656
|
+
}
|
|
657
|
+
function Bt(e) {
|
|
658
|
+
const t = Object.keys(e).sort();
|
|
659
|
+
return t.length === 0 ? $(
|
|
660
|
+
"Response headers",
|
|
661
|
+
'<p class="empty">The response carries no document header.</p>'
|
|
662
|
+
) : $(
|
|
663
|
+
"Response headers",
|
|
664
|
+
C(t.map((r) => [r, l(e[r])]))
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
function Kt(e) {
|
|
668
|
+
const t = {
|
|
669
|
+
cors: e.audit.route?.cors,
|
|
670
|
+
document: e.policy.document,
|
|
671
|
+
security: e.policy.security
|
|
672
|
+
};
|
|
673
|
+
return $(
|
|
674
|
+
"Effective policy",
|
|
675
|
+
`<pre>${l(JSON.stringify(t, null, 2))}</pre>`
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
function Yt(e) {
|
|
679
|
+
return e ? $(
|
|
680
|
+
"Metadata",
|
|
681
|
+
`<pre>${l(JSON.stringify(e, null, 2))}</pre>`
|
|
682
|
+
) : $("Metadata", '<p class="empty">No document metadata.</p>');
|
|
683
|
+
}
|
|
684
|
+
function Qt(e) {
|
|
685
|
+
return e.length === 0 ? $("Scripts", '<p class="empty">No contributed scripts.</p>') : $(
|
|
686
|
+
"Scripts",
|
|
687
|
+
e.map(
|
|
688
|
+
(t) => C([
|
|
689
|
+
["Source", l(t.src)],
|
|
690
|
+
["Strategy", l(t.strategy)],
|
|
691
|
+
["Purpose", t.purpose ? l(t.purpose) : S()],
|
|
692
|
+
["Integrity", t.integrity ? l(t.integrity) : S()],
|
|
693
|
+
["Nonce", t.nonce ? "applied" : S()],
|
|
694
|
+
[
|
|
695
|
+
"Policy status",
|
|
696
|
+
t.findings.length === 0 ? "allowed" : `<ul>${t.findings.map(Ce).join("")}</ul>`
|
|
697
|
+
]
|
|
698
|
+
])
|
|
699
|
+
).join("")
|
|
700
|
+
);
|
|
391
701
|
}
|
|
392
|
-
function
|
|
393
|
-
|
|
702
|
+
function Xt(e) {
|
|
703
|
+
const t = [
|
|
704
|
+
[
|
|
705
|
+
"Response cache-control",
|
|
706
|
+
e.cacheControl ? l(e.cacheControl) : S()
|
|
707
|
+
],
|
|
708
|
+
["Nonce", e.nonce ? "required" : S()]
|
|
709
|
+
];
|
|
710
|
+
return e.cacheReads.length === 0 ? $(
|
|
711
|
+
"Cache behavior",
|
|
712
|
+
`${C(t)}<p class="empty">The request read no cache entry.</p>`
|
|
713
|
+
) : $(
|
|
714
|
+
"Cache behavior",
|
|
715
|
+
`${C(t)}${e.cacheReads.map(
|
|
716
|
+
(r) => C([
|
|
717
|
+
["Key", l(r.key)],
|
|
718
|
+
["Scope", l(r.scope)],
|
|
719
|
+
["Time to live", r.ttl ? l(r.ttl) : S()],
|
|
720
|
+
[
|
|
721
|
+
"Stale while revalidate",
|
|
722
|
+
r.staleWhileRevalidate ? l(r.staleWhileRevalidate) : S()
|
|
723
|
+
],
|
|
724
|
+
["Tags", A(r.tags)]
|
|
725
|
+
])
|
|
726
|
+
).join("")}`
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
function $(e, t) {
|
|
730
|
+
return ` <section>
|
|
731
|
+
<h2>${l(e)}</h2>
|
|
732
|
+
${t}
|
|
733
|
+
</section>`;
|
|
394
734
|
}
|
|
395
|
-
function
|
|
396
|
-
return
|
|
735
|
+
function C(e) {
|
|
736
|
+
return `<table><tbody>${e.map(
|
|
737
|
+
([t, r]) => `<tr><th scope="row">${l(t)}</th><td>${r}</td></tr>`
|
|
738
|
+
).join("")}</tbody></table>`;
|
|
397
739
|
}
|
|
398
|
-
function
|
|
399
|
-
return
|
|
740
|
+
function A(e) {
|
|
741
|
+
return e.length === 0 ? S() : `<ul>${e.map((t) => `<li>${l(t)}</li>`).join("")}</ul>`;
|
|
400
742
|
}
|
|
401
|
-
function
|
|
402
|
-
|
|
403
|
-
|
|
743
|
+
function Zt(e) {
|
|
744
|
+
return A(
|
|
745
|
+
Object.entries(e).map(([t, r]) => `${t} = ${String(r)}`)
|
|
746
|
+
);
|
|
404
747
|
}
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
-
return e?.type === "Identifier" || e?.type === "Literal" ? String(e.name ?? e.value) : void 0;
|
|
748
|
+
function S() {
|
|
749
|
+
return '<span class="empty">none</span>';
|
|
408
750
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
751
|
+
function l(e) {
|
|
752
|
+
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
753
|
+
}
|
|
754
|
+
const K = "virtual:demiurge/client-entry", te = `/@id/${K}`, X = `\0${K}`, Ie = "virtual:demiurge/server-entry", he = `\0${Ie}`, ge = ".demiurge/route-manifest.d.ts";
|
|
755
|
+
function Yr(e = {}) {
|
|
756
|
+
let t = process.cwd(), r = !1;
|
|
757
|
+
const o = `demiurge-${z()}`;
|
|
413
758
|
return {
|
|
414
759
|
api: {
|
|
415
760
|
demiurge: !0,
|
|
416
|
-
fonts:
|
|
417
|
-
images:
|
|
418
|
-
staticDeployment:
|
|
419
|
-
staticFileHeaders:
|
|
761
|
+
fonts: e.fonts,
|
|
762
|
+
images: e.images,
|
|
763
|
+
staticDeployment: e.static?.deployment,
|
|
764
|
+
staticFileHeaders: e.static?.headers
|
|
420
765
|
},
|
|
421
766
|
enforce: "post",
|
|
422
767
|
name: "demiurge",
|
|
423
|
-
config(
|
|
424
|
-
return
|
|
768
|
+
config(n, i) {
|
|
769
|
+
return cr(n, i, o);
|
|
425
770
|
},
|
|
426
|
-
configResolved(
|
|
427
|
-
|
|
771
|
+
configResolved(n) {
|
|
772
|
+
t = n.root, r = n.command === "build";
|
|
428
773
|
},
|
|
429
|
-
resolveId(
|
|
430
|
-
return
|
|
774
|
+
resolveId(n) {
|
|
775
|
+
return n === K ? X : n === Ie ? he : null;
|
|
431
776
|
},
|
|
432
|
-
load(
|
|
433
|
-
return
|
|
777
|
+
load(n) {
|
|
778
|
+
return n === X ? ur(t, e) : n === he ? lr(t, e) : null;
|
|
434
779
|
},
|
|
435
780
|
transform: {
|
|
436
781
|
order: "post",
|
|
437
|
-
handler(
|
|
438
|
-
if (!
|
|
782
|
+
handler(n, i, s) {
|
|
783
|
+
if (!nr(t, e, i))
|
|
439
784
|
return null;
|
|
440
785
|
if (s?.ssr)
|
|
441
|
-
return
|
|
442
|
-
const a =
|
|
443
|
-
return a ===
|
|
786
|
+
return r ? null : er(n, i);
|
|
787
|
+
const a = tr(n);
|
|
788
|
+
return a === n ? null : { code: a, map: null };
|
|
444
789
|
}
|
|
445
790
|
},
|
|
446
|
-
generateBundle(
|
|
791
|
+
generateBundle(n, i) {
|
|
447
792
|
const s = Object.values(i).find(
|
|
448
|
-
(u) => u.type === "chunk" && u.isEntry && u.facadeModuleId ===
|
|
793
|
+
(u) => u.type === "chunk" && u.isEntry && u.facadeModuleId === X
|
|
449
794
|
);
|
|
450
795
|
if (!s)
|
|
451
796
|
return;
|
|
@@ -454,11 +799,11 @@ function fr(t = {}) {
|
|
|
454
799
|
).map((u) => `/${u.fileName}`), c = `/${s.fileName}`;
|
|
455
800
|
this.emitFile({
|
|
456
801
|
fileName: "index.html",
|
|
457
|
-
source:
|
|
802
|
+
source: Mr({
|
|
458
803
|
entrySrc: c,
|
|
459
|
-
lang:
|
|
804
|
+
lang: e.document?.lang,
|
|
460
805
|
styles: a,
|
|
461
|
-
title:
|
|
806
|
+
title: e.document?.title
|
|
462
807
|
}),
|
|
463
808
|
type: "asset"
|
|
464
809
|
}), this.emitFile({
|
|
@@ -468,19 +813,19 @@ function fr(t = {}) {
|
|
|
468
813
|
});
|
|
469
814
|
},
|
|
470
815
|
async buildStart() {
|
|
471
|
-
if (
|
|
472
|
-
await
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
throw new Error(
|
|
816
|
+
if (r) {
|
|
817
|
+
await xr(t, e);
|
|
818
|
+
const n = await Ne(t, e);
|
|
819
|
+
if (n.length)
|
|
820
|
+
throw new Error(_r(n));
|
|
476
821
|
}
|
|
477
|
-
|
|
822
|
+
e.typedRoutes && await L(t, e);
|
|
478
823
|
},
|
|
479
|
-
configureServer(
|
|
824
|
+
configureServer(n) {
|
|
480
825
|
const i = async () => {
|
|
481
|
-
const
|
|
482
|
-
for (const
|
|
483
|
-
|
|
826
|
+
const m = await Ne(n.config.root, e);
|
|
827
|
+
for (const f of m)
|
|
828
|
+
n.config.logger.warn(Le(f));
|
|
484
829
|
};
|
|
485
830
|
let s, a = Promise.resolve();
|
|
486
831
|
const c = () => {
|
|
@@ -489,139 +834,151 @@ function fr(t = {}) {
|
|
|
489
834
|
}, u = () => {
|
|
490
835
|
s && clearTimeout(s), s = setTimeout(() => {
|
|
491
836
|
s = void 0, c();
|
|
492
|
-
},
|
|
837
|
+
}, Ir), s.unref?.();
|
|
493
838
|
};
|
|
494
|
-
if (
|
|
839
|
+
if (n.httpServer?.once("close", () => {
|
|
495
840
|
s && (clearTimeout(s), s = void 0);
|
|
496
|
-
}), c(),
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
841
|
+
}), c(), e.typedRoutes) {
|
|
842
|
+
const m = b(
|
|
843
|
+
n.config.root,
|
|
844
|
+
e.routesDir ?? "src/routes"
|
|
500
845
|
);
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}),
|
|
504
|
-
|
|
505
|
-
}),
|
|
506
|
-
|
|
846
|
+
L(n.config.root, e), n.watcher.add(m), n.watcher.on("add", (f) => {
|
|
847
|
+
J(m, f) && (L(n.config.root, e), u());
|
|
848
|
+
}), n.watcher.on("change", (f) => {
|
|
849
|
+
J(m, f) && (L(n.config.root, e), u());
|
|
850
|
+
}), n.watcher.on("unlink", (f) => {
|
|
851
|
+
J(m, f) && (L(n.config.root, e), u());
|
|
507
852
|
});
|
|
508
853
|
} else {
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
|
|
854
|
+
const m = b(
|
|
855
|
+
n.config.root,
|
|
856
|
+
e.routesDir ?? "src/routes"
|
|
512
857
|
);
|
|
513
|
-
|
|
514
|
-
for (const
|
|
515
|
-
|
|
516
|
-
|
|
858
|
+
n.watcher.add(m);
|
|
859
|
+
for (const f of ["add", "change", "unlink"])
|
|
860
|
+
n.watcher.on(f, (p) => {
|
|
861
|
+
J(m, p) && u();
|
|
517
862
|
});
|
|
518
863
|
}
|
|
519
|
-
const
|
|
520
|
-
fonts:
|
|
521
|
-
root:
|
|
864
|
+
const d = yr(e), h = hr(n, e), D = at({
|
|
865
|
+
fonts: e.fonts,
|
|
866
|
+
root: n.config.root
|
|
522
867
|
});
|
|
523
|
-
return
|
|
868
|
+
return n.middlewares.use(async (m, f, p) => {
|
|
524
869
|
try {
|
|
525
870
|
let v;
|
|
526
871
|
try {
|
|
527
|
-
v =
|
|
872
|
+
v = ce(m, {
|
|
528
873
|
// Vite performs its own configured host allowlist check before
|
|
529
874
|
// Demiurge's middleware runs. Production Node listeners require
|
|
530
875
|
// an explicit application allowlist instead.
|
|
531
|
-
allowedHosts: [
|
|
876
|
+
allowedHosts: [m.headers.host ?? "localhost"]
|
|
532
877
|
});
|
|
533
|
-
} catch (
|
|
534
|
-
if (
|
|
535
|
-
|
|
878
|
+
} catch (H) {
|
|
879
|
+
if (H instanceof ue) {
|
|
880
|
+
le(f);
|
|
536
881
|
return;
|
|
537
882
|
}
|
|
538
|
-
throw
|
|
883
|
+
throw H;
|
|
884
|
+
}
|
|
885
|
+
if (d && kt(v)) {
|
|
886
|
+
const H = await Z(
|
|
887
|
+
n,
|
|
888
|
+
m,
|
|
889
|
+
b(n.config.root, e.routesDir ?? "src/routes")
|
|
890
|
+
);
|
|
891
|
+
await k(
|
|
892
|
+
f,
|
|
893
|
+
await Lt(H, v)
|
|
894
|
+
);
|
|
895
|
+
return;
|
|
539
896
|
}
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
await
|
|
897
|
+
const j = await D(v);
|
|
898
|
+
if (j) {
|
|
899
|
+
await k(f, j);
|
|
543
900
|
return;
|
|
544
901
|
}
|
|
545
|
-
const
|
|
546
|
-
if (
|
|
547
|
-
await
|
|
902
|
+
const _ = await h(v);
|
|
903
|
+
if (_) {
|
|
904
|
+
await k(f, _);
|
|
548
905
|
return;
|
|
549
906
|
}
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
),
|
|
554
|
-
|
|
907
|
+
const V = b(
|
|
908
|
+
n.config.root,
|
|
909
|
+
e.routesDir ?? "src/routes"
|
|
910
|
+
), W = await Z(n, m, V), F = Re(
|
|
911
|
+
n,
|
|
555
912
|
o
|
|
556
|
-
),
|
|
557
|
-
|
|
913
|
+
), Y = await Ar(
|
|
914
|
+
W,
|
|
558
915
|
v,
|
|
559
|
-
|
|
916
|
+
gr(e, F.transform)
|
|
560
917
|
);
|
|
561
|
-
if (
|
|
562
|
-
|
|
918
|
+
if (Y === "next") {
|
|
919
|
+
p();
|
|
563
920
|
return;
|
|
564
921
|
}
|
|
565
|
-
|
|
922
|
+
be(Y, F.nonce), await k(f, Y);
|
|
566
923
|
} catch (v) {
|
|
567
|
-
|
|
924
|
+
p(v);
|
|
568
925
|
}
|
|
569
926
|
}), () => {
|
|
570
|
-
|
|
927
|
+
n.middlewares.use(async (m, f, p) => {
|
|
571
928
|
try {
|
|
572
929
|
let v;
|
|
573
930
|
try {
|
|
574
|
-
v =
|
|
575
|
-
allowedHosts: [
|
|
931
|
+
v = ce(m, {
|
|
932
|
+
allowedHosts: [m.headers.host ?? "localhost"]
|
|
576
933
|
});
|
|
577
|
-
} catch (
|
|
578
|
-
if (
|
|
579
|
-
|
|
934
|
+
} catch (F) {
|
|
935
|
+
if (F instanceof ue) {
|
|
936
|
+
le(f);
|
|
580
937
|
return;
|
|
581
938
|
}
|
|
582
|
-
throw
|
|
939
|
+
throw F;
|
|
583
940
|
}
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
),
|
|
588
|
-
|
|
589
|
-
const
|
|
590
|
-
|
|
941
|
+
const j = b(
|
|
942
|
+
n.config.root,
|
|
943
|
+
e.routesDir ?? "src/routes"
|
|
944
|
+
), _ = await Z(n, m, j);
|
|
945
|
+
Sr(_, j);
|
|
946
|
+
const V = Re(
|
|
947
|
+
n,
|
|
591
948
|
o
|
|
592
|
-
),
|
|
593
|
-
|
|
949
|
+
), W = await ot(
|
|
950
|
+
_,
|
|
594
951
|
v,
|
|
595
|
-
|
|
952
|
+
$r(e, V.transform)
|
|
596
953
|
);
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
), await
|
|
954
|
+
be(
|
|
955
|
+
W,
|
|
956
|
+
V.nonce
|
|
957
|
+
), await k(f, W);
|
|
601
958
|
} catch (v) {
|
|
602
|
-
|
|
959
|
+
p(v);
|
|
603
960
|
}
|
|
604
961
|
});
|
|
605
962
|
};
|
|
606
963
|
}
|
|
607
964
|
};
|
|
608
965
|
}
|
|
609
|
-
function
|
|
610
|
-
if (!
|
|
966
|
+
function er(e, t) {
|
|
967
|
+
if (!e.includes("import.meta"))
|
|
611
968
|
return null;
|
|
612
|
-
const
|
|
613
|
-
(u) => u.type === "ImportDeclaration" &&
|
|
614
|
-
(
|
|
969
|
+
const r = oe(e), o = E(r.body).find(
|
|
970
|
+
(u) => u.type === "ImportDeclaration" && E(u.specifiers).some(
|
|
971
|
+
(d) => w(d.local)?.type === "Identifier" && w(d.local)?.name === "meta"
|
|
615
972
|
)
|
|
616
|
-
),
|
|
617
|
-
(u) =>
|
|
618
|
-
), i =
|
|
619
|
-
if (!o || !
|
|
973
|
+
), n = o && E(o.specifiers).find(
|
|
974
|
+
(u) => w(u.local)?.type === "Identifier" && w(u.local)?.name === "meta"
|
|
975
|
+
), i = n && w(n.local);
|
|
976
|
+
if (!o || !n || !i)
|
|
620
977
|
return null;
|
|
621
978
|
let s = "__demiurge_imported_meta__";
|
|
622
|
-
for (; new RegExp(`\\b${s}\\b`).test(
|
|
979
|
+
for (; new RegExp(`\\b${s}\\b`).test(e); )
|
|
623
980
|
s += "_";
|
|
624
|
-
const a = new
|
|
981
|
+
const a = new Ue(e), c = w(n.imported);
|
|
625
982
|
return a.overwrite(
|
|
626
983
|
i.start,
|
|
627
984
|
i.end,
|
|
@@ -632,142 +989,142 @@ const meta = ${s};`), {
|
|
|
632
989
|
map: a.generateMap({
|
|
633
990
|
hires: "boundary",
|
|
634
991
|
includeContent: !0,
|
|
635
|
-
source:
|
|
992
|
+
source: t
|
|
636
993
|
})
|
|
637
994
|
};
|
|
638
995
|
}
|
|
639
|
-
function
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
if (a.type === "ImportDeclaration" &&
|
|
643
|
-
|
|
996
|
+
function tr(e) {
|
|
997
|
+
const t = oe(e), r = [], o = rr(t), n = [];
|
|
998
|
+
G(t, (a) => {
|
|
999
|
+
if (a.type === "ImportDeclaration" && ir(a)) {
|
|
1000
|
+
n.push(a);
|
|
644
1001
|
return;
|
|
645
1002
|
}
|
|
646
|
-
if (a.type !== "CallExpression" || !
|
|
1003
|
+
if (a.type !== "CallExpression" || !or(a.callee))
|
|
647
1004
|
return;
|
|
648
|
-
const c =
|
|
1005
|
+
const c = E(a.arguments)[0];
|
|
649
1006
|
if (c?.type === "ObjectExpression")
|
|
650
|
-
for (const u of
|
|
651
|
-
u.type === "Property" &&
|
|
1007
|
+
for (const u of E(c.properties))
|
|
1008
|
+
u.type === "Property" && B(u.key) === "data" && r.push({ end: u.end, start: u.start });
|
|
652
1009
|
});
|
|
653
|
-
const i = [...
|
|
1010
|
+
const i = [...r, ...o];
|
|
654
1011
|
if (i.length === 0)
|
|
655
|
-
return
|
|
1012
|
+
return e;
|
|
656
1013
|
const s = [...i];
|
|
657
|
-
for (const a of
|
|
658
|
-
const c =
|
|
1014
|
+
for (const a of n) {
|
|
1015
|
+
const c = E(a.specifiers).map((h) => w(h.local)).filter((h) => h?.type === "Identifier").map((h) => String(h.name)), u = sr(e, [
|
|
659
1016
|
...i,
|
|
660
1017
|
{ end: a.end, start: a.start }
|
|
661
|
-
]),
|
|
662
|
-
(
|
|
1018
|
+
]), d = c.find(
|
|
1019
|
+
(h) => new RegExp(`\\b${je(h)}\\b`).test(u)
|
|
663
1020
|
);
|
|
664
|
-
if (
|
|
1021
|
+
if (d)
|
|
665
1022
|
throw new Error(
|
|
666
|
-
`Server-only import ${JSON.stringify(
|
|
1023
|
+
`Server-only import ${JSON.stringify(d)} is used by client route code. Move that use into page data, a document contribution, or a client-safe module.`
|
|
667
1024
|
);
|
|
668
1025
|
s.push({ end: a.end, start: a.start });
|
|
669
1026
|
}
|
|
670
|
-
return
|
|
671
|
-
|
|
1027
|
+
return ar(
|
|
1028
|
+
e,
|
|
672
1029
|
s,
|
|
673
|
-
(a) =>
|
|
1030
|
+
(a) => r.includes(a) ? "data: undefined" : o.includes(a) ? "undefined" : ""
|
|
674
1031
|
);
|
|
675
1032
|
}
|
|
676
|
-
const
|
|
677
|
-
function
|
|
678
|
-
const
|
|
679
|
-
for (const o of
|
|
1033
|
+
const we = /* @__PURE__ */ new Set(["links", "metadata", "scripts"]);
|
|
1034
|
+
function rr(e) {
|
|
1035
|
+
const t = /* @__PURE__ */ new Set();
|
|
1036
|
+
for (const o of E(e.body)) {
|
|
680
1037
|
if (o.type !== "ExportNamedDeclaration") continue;
|
|
681
|
-
const
|
|
682
|
-
if (
|
|
683
|
-
for (const i of
|
|
684
|
-
const s =
|
|
685
|
-
s?.type === "Identifier" &&
|
|
1038
|
+
const n = w(o.declaration);
|
|
1039
|
+
if (n?.type === "VariableDeclaration")
|
|
1040
|
+
for (const i of E(n.declarations)) {
|
|
1041
|
+
const s = w(i.id);
|
|
1042
|
+
s?.type === "Identifier" && we.has(String(s.name)) && t.add(String(s.name));
|
|
686
1043
|
}
|
|
687
|
-
for (const i of
|
|
688
|
-
const s =
|
|
689
|
-
s && a &&
|
|
1044
|
+
for (const i of E(o.specifiers)) {
|
|
1045
|
+
const s = B(i.exported), a = B(i.local);
|
|
1046
|
+
s && a && we.has(s) && t.add(a);
|
|
690
1047
|
}
|
|
691
1048
|
}
|
|
692
|
-
const
|
|
693
|
-
return
|
|
1049
|
+
const r = [];
|
|
1050
|
+
return G(e, (o) => {
|
|
694
1051
|
if (o.type !== "VariableDeclarator") return;
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
}),
|
|
698
|
-
}
|
|
699
|
-
function
|
|
700
|
-
const o =
|
|
701
|
-
return i !== "" && i !== ".." && !i.startsWith(`..${
|
|
702
|
-
}
|
|
703
|
-
function
|
|
704
|
-
if (!
|
|
705
|
-
if (Array.isArray(
|
|
706
|
-
for (const o of
|
|
1052
|
+
const n = w(o.id), i = w(o.init);
|
|
1053
|
+
n?.type === "Identifier" && t.has(String(n.name)) && i && r.push({ end: i.end, start: i.start });
|
|
1054
|
+
}), r;
|
|
1055
|
+
}
|
|
1056
|
+
function nr(e, t, r) {
|
|
1057
|
+
const o = r.split("?", 1)[0] ?? r, n = b(e, t.routesDir ?? "src/routes"), i = N(n, o);
|
|
1058
|
+
return i !== "" && i !== ".." && !i.startsWith(`..${O}`);
|
|
1059
|
+
}
|
|
1060
|
+
function G(e, t) {
|
|
1061
|
+
if (!e || typeof e != "object") return;
|
|
1062
|
+
if (Array.isArray(e)) {
|
|
1063
|
+
for (const o of e) G(o, t);
|
|
707
1064
|
return;
|
|
708
1065
|
}
|
|
709
|
-
const
|
|
710
|
-
if (typeof
|
|
711
|
-
|
|
712
|
-
for (const [o,
|
|
713
|
-
(/* @__PURE__ */ new Set(["end", "loc", "start", "type"])).has(o) ||
|
|
1066
|
+
const r = e;
|
|
1067
|
+
if (typeof r.type == "string") {
|
|
1068
|
+
t(r);
|
|
1069
|
+
for (const [o, n] of Object.entries(r))
|
|
1070
|
+
(/* @__PURE__ */ new Set(["end", "loc", "start", "type"])).has(o) || G(n, t);
|
|
714
1071
|
}
|
|
715
1072
|
}
|
|
716
|
-
function
|
|
717
|
-
return
|
|
1073
|
+
function w(e) {
|
|
1074
|
+
return e && typeof e == "object" && "type" in e ? e : void 0;
|
|
718
1075
|
}
|
|
719
|
-
function
|
|
720
|
-
return Array.isArray(
|
|
1076
|
+
function E(e) {
|
|
1077
|
+
return Array.isArray(e) ? e.map(w).filter((t) => !!t) : [];
|
|
721
1078
|
}
|
|
722
|
-
function
|
|
723
|
-
const
|
|
724
|
-
return
|
|
1079
|
+
function or(e) {
|
|
1080
|
+
const t = w(e);
|
|
1081
|
+
return t?.type === "Identifier" ? t.name === "page" : t?.type === "MemberExpression" && B(t.property) === "page";
|
|
725
1082
|
}
|
|
726
|
-
function
|
|
727
|
-
const
|
|
728
|
-
return
|
|
1083
|
+
function B(e) {
|
|
1084
|
+
const t = w(e);
|
|
1085
|
+
return t?.type === "Identifier" || t?.type === "Literal" ? String(t.name ?? t.value) : void 0;
|
|
729
1086
|
}
|
|
730
|
-
function
|
|
731
|
-
const
|
|
732
|
-
return typeof
|
|
1087
|
+
function ir(e) {
|
|
1088
|
+
const t = w(e.source)?.value;
|
|
1089
|
+
return typeof t == "string" && /(?:^|[/.-])server(?:[/.-]|$)/.test(t);
|
|
733
1090
|
}
|
|
734
|
-
function
|
|
735
|
-
const
|
|
736
|
-
for (const { end: o, start:
|
|
737
|
-
|
|
738
|
-
return
|
|
1091
|
+
function sr(e, t) {
|
|
1092
|
+
const r = [...e];
|
|
1093
|
+
for (const { end: o, start: n } of t)
|
|
1094
|
+
r.fill(" ", n, o);
|
|
1095
|
+
return r.join("");
|
|
739
1096
|
}
|
|
740
|
-
function
|
|
741
|
-
return [...
|
|
742
|
-
(o,
|
|
743
|
-
|
|
1097
|
+
function ar(e, t, r) {
|
|
1098
|
+
return [...t].sort((o, n) => n.start - o.start).reduce(
|
|
1099
|
+
(o, n) => `${o.slice(0, n.start)}${r(n)}${o.slice(n.end)}`,
|
|
1100
|
+
e
|
|
744
1101
|
);
|
|
745
1102
|
}
|
|
746
|
-
function
|
|
747
|
-
return
|
|
1103
|
+
function je(e) {
|
|
1104
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
748
1105
|
}
|
|
749
|
-
function
|
|
1106
|
+
function cr(e, t, r) {
|
|
750
1107
|
return {
|
|
751
1108
|
appType: "custom",
|
|
752
1109
|
build: {
|
|
753
|
-
assetsInlineLimit:
|
|
754
|
-
...
|
|
1110
|
+
assetsInlineLimit: e.build?.assetsInlineLimit ?? 0,
|
|
1111
|
+
...t.isSsrBuild && e.build?.target === void 0 && e.ssr?.target !== "webworker" ? { target: "node22.13" } : {},
|
|
755
1112
|
rollupOptions: {
|
|
756
|
-
input:
|
|
1113
|
+
input: e.build?.rollupOptions?.input ?? K
|
|
757
1114
|
}
|
|
758
1115
|
},
|
|
759
|
-
...
|
|
760
|
-
html: { cspNonce:
|
|
761
|
-
ssr: { external: [
|
|
1116
|
+
...t.command === "serve" ? {
|
|
1117
|
+
html: { cspNonce: r },
|
|
1118
|
+
ssr: { external: [P] }
|
|
762
1119
|
} : {}
|
|
763
1120
|
};
|
|
764
1121
|
}
|
|
765
|
-
function
|
|
766
|
-
const
|
|
767
|
-
return `import { hydrateFileRouter } from "${
|
|
1122
|
+
function ur(e, t = {}) {
|
|
1123
|
+
const r = t.routesDir ?? "src/routes", o = mr(e, t);
|
|
1124
|
+
return `import { hydrateFileRouter } from "${P}";
|
|
768
1125
|
${o}
|
|
769
1126
|
|
|
770
|
-
${
|
|
1127
|
+
${_e(r, {
|
|
771
1128
|
exportRoutes: !1,
|
|
772
1129
|
includeServerOnly: !1
|
|
773
1130
|
})}
|
|
@@ -775,11 +1132,11 @@ ${xt(n, {
|
|
|
775
1132
|
void hydrateFileRouter({ routes });
|
|
776
1133
|
`;
|
|
777
1134
|
}
|
|
778
|
-
function
|
|
779
|
-
const
|
|
780
|
-
return `import { createRequestHandler } from "${
|
|
1135
|
+
function lr(e, t = {}) {
|
|
1136
|
+
const r = t.routesDir ?? "src/routes";
|
|
1137
|
+
return `import { createRequestHandler } from "${P}";
|
|
781
1138
|
|
|
782
|
-
${
|
|
1139
|
+
${_e(r, {
|
|
783
1140
|
exportRoutes: !0,
|
|
784
1141
|
includeServerOnly: !0,
|
|
785
1142
|
eagerModules: !0
|
|
@@ -794,21 +1151,21 @@ export function createHandler(options = {}) {
|
|
|
794
1151
|
routeModules,
|
|
795
1152
|
ssr: {
|
|
796
1153
|
clientEntry,
|
|
797
|
-
lang: lang ?? ${JSON.stringify(
|
|
1154
|
+
lang: lang ?? ${JSON.stringify(t.document?.lang)},
|
|
798
1155
|
styles,
|
|
799
|
-
title: title ?? ${JSON.stringify(
|
|
1156
|
+
title: title ?? ${JSON.stringify(t.document?.title)},
|
|
800
1157
|
},
|
|
801
1158
|
});
|
|
802
1159
|
}
|
|
803
1160
|
`;
|
|
804
1161
|
}
|
|
805
|
-
function
|
|
806
|
-
exportRoutes:
|
|
807
|
-
eagerModules:
|
|
1162
|
+
function _e(e, {
|
|
1163
|
+
exportRoutes: t,
|
|
1164
|
+
eagerModules: r = !1,
|
|
808
1165
|
includeServerOnly: o
|
|
809
1166
|
}) {
|
|
810
|
-
const
|
|
811
|
-
return
|
|
1167
|
+
const n = fr(e, o), i = pr(e);
|
|
1168
|
+
return r ? `const eagerRouteModules = import.meta.glob(${JSON.stringify(n)}, { eager: true });
|
|
812
1169
|
const routePrefix = ${JSON.stringify(i)};
|
|
813
1170
|
export const routeModules = Object.fromEntries(
|
|
814
1171
|
Object.entries(eagerRouteModules).map(([file, module]) => [
|
|
@@ -816,268 +1173,271 @@ export const routeModules = Object.fromEntries(
|
|
|
816
1173
|
module,
|
|
817
1174
|
]),
|
|
818
1175
|
);
|
|
819
|
-
${
|
|
1176
|
+
${t ? "export " : ""}const routes = Object.fromEntries(
|
|
820
1177
|
Object.entries(routeModules).map(([file, module]) => [
|
|
821
1178
|
file,
|
|
822
1179
|
async () => module,
|
|
823
1180
|
]),
|
|
824
|
-
);` : `const routeModules = import.meta.glob(${JSON.stringify(
|
|
1181
|
+
);` : `const routeModules = import.meta.glob(${JSON.stringify(n)});
|
|
825
1182
|
const routePrefix = ${JSON.stringify(i)};
|
|
826
|
-
${
|
|
1183
|
+
${t ? "export " : ""}const routes = Object.fromEntries(
|
|
827
1184
|
Object.entries(routeModules).map(([file, load]) => [
|
|
828
1185
|
\`./routes/\${file.slice(routePrefix.length)}\`,
|
|
829
1186
|
load,
|
|
830
1187
|
]),
|
|
831
1188
|
);`;
|
|
832
1189
|
}
|
|
833
|
-
const
|
|
834
|
-
function
|
|
835
|
-
const
|
|
836
|
-
return
|
|
837
|
-
...
|
|
838
|
-
`!${
|
|
839
|
-
`!${
|
|
1190
|
+
const dr = ["@middleware.ts", "@policy.ts"];
|
|
1191
|
+
function fr(e, t) {
|
|
1192
|
+
const r = `/${e.replace(/^\/|\/$/g, "")}`, o = [`${r}/**/*.{ts,tsx}`];
|
|
1193
|
+
return t || o.push(
|
|
1194
|
+
...dr.flatMap((n) => [
|
|
1195
|
+
`!${r}/${n}`,
|
|
1196
|
+
`!${r}/**/${n}`
|
|
840
1197
|
])
|
|
841
1198
|
), o;
|
|
842
1199
|
}
|
|
843
|
-
function
|
|
844
|
-
return `/${
|
|
1200
|
+
function pr(e) {
|
|
1201
|
+
return `/${e.replace(/^\/|\/$/g, "")}/`;
|
|
845
1202
|
}
|
|
846
|
-
function
|
|
847
|
-
if (
|
|
1203
|
+
function mr(e, t) {
|
|
1204
|
+
if (t.styles === !1)
|
|
848
1205
|
return "";
|
|
849
|
-
const
|
|
850
|
-
return
|
|
851
|
-
}
|
|
852
|
-
function
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1206
|
+
const r = t.styles ?? "src/styles.css", o = b(e, r);
|
|
1207
|
+
return re(o) ? `import ${JSON.stringify(`/${r.replace(/^\/+/, "")}`)};` : "";
|
|
1208
|
+
}
|
|
1209
|
+
function yr(e) {
|
|
1210
|
+
return e.devtools !== !1 && process.env.NODE_ENV !== "production";
|
|
1211
|
+
}
|
|
1212
|
+
function hr(e, t) {
|
|
1213
|
+
const r = e.config.publicDir, o = t.images?.optimizerPath ?? "/_demiurge/image";
|
|
1214
|
+
return r ? ct({
|
|
1215
|
+
policy: t.images,
|
|
1216
|
+
resolveVariant: (n) => lt(n, o),
|
|
1217
|
+
root: r
|
|
858
1218
|
}) : async () => null;
|
|
859
1219
|
}
|
|
860
|
-
function
|
|
1220
|
+
function gr(e, t) {
|
|
861
1221
|
return {
|
|
862
1222
|
dev: !0,
|
|
863
|
-
ssr:
|
|
864
|
-
transformDocument:
|
|
865
|
-
renderPage: async (
|
|
866
|
-
if (
|
|
867
|
-
return await
|
|
1223
|
+
ssr: ke(e),
|
|
1224
|
+
transformDocument: t,
|
|
1225
|
+
renderPage: async (r, o) => {
|
|
1226
|
+
if (r.render.mode === "streaming")
|
|
1227
|
+
return await ut(r, {
|
|
868
1228
|
...o,
|
|
869
|
-
clientEntry:
|
|
870
|
-
transformDocument:
|
|
1229
|
+
clientEntry: te,
|
|
1230
|
+
transformDocument: t
|
|
871
1231
|
});
|
|
872
|
-
const
|
|
873
|
-
|
|
1232
|
+
const n = await t(
|
|
1233
|
+
ze(r, {
|
|
874
1234
|
...o,
|
|
875
|
-
clientEntry:
|
|
1235
|
+
clientEntry: te
|
|
876
1236
|
})
|
|
877
1237
|
);
|
|
878
|
-
return new Response(
|
|
1238
|
+
return new Response(n, {
|
|
879
1239
|
headers: { "content-type": "text/html; charset=utf-8" }
|
|
880
1240
|
});
|
|
881
1241
|
}
|
|
882
1242
|
};
|
|
883
1243
|
}
|
|
884
|
-
function
|
|
885
|
-
const
|
|
1244
|
+
function Re(e, t) {
|
|
1245
|
+
const r = z(), o = z();
|
|
886
1246
|
return {
|
|
887
|
-
nonce:
|
|
888
|
-
transform: async (
|
|
889
|
-
const i =
|
|
890
|
-
return
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1247
|
+
nonce: r,
|
|
1248
|
+
transform: async (n) => {
|
|
1249
|
+
const i = wr(n, o), s = await e.transformIndexHtml("/", i);
|
|
1250
|
+
return ve(
|
|
1251
|
+
ve(s, o),
|
|
1252
|
+
t,
|
|
1253
|
+
r
|
|
894
1254
|
);
|
|
895
1255
|
}
|
|
896
1256
|
};
|
|
897
1257
|
}
|
|
898
|
-
function
|
|
899
|
-
const
|
|
900
|
-
let o = 0,
|
|
901
|
-
for (; o <
|
|
902
|
-
const i =
|
|
1258
|
+
function wr(e, t) {
|
|
1259
|
+
const r = e.toLowerCase();
|
|
1260
|
+
let o = 0, n = "";
|
|
1261
|
+
for (; o < e.length; ) {
|
|
1262
|
+
const i = e.indexOf("<", o);
|
|
903
1263
|
if (i === -1)
|
|
904
|
-
return
|
|
905
|
-
if (
|
|
906
|
-
const u =
|
|
907
|
-
|
|
1264
|
+
return n + e.slice(o);
|
|
1265
|
+
if (n += e.slice(o, i), r.startsWith("<!--", i)) {
|
|
1266
|
+
const u = r.indexOf("-->", i + 4), d = u === -1 ? e.length : u + 3;
|
|
1267
|
+
n += e.slice(i, d), o = d;
|
|
908
1268
|
continue;
|
|
909
1269
|
}
|
|
910
|
-
const s =
|
|
1270
|
+
const s = r.slice(i).match(/^<\s*(script|style|link)\b/)?.[1];
|
|
911
1271
|
if (!s) {
|
|
912
|
-
|
|
1272
|
+
n += "<", o = i + 1;
|
|
913
1273
|
continue;
|
|
914
1274
|
}
|
|
915
|
-
const a =
|
|
1275
|
+
const a = Rr(e, i);
|
|
916
1276
|
if (a === -1)
|
|
917
|
-
return
|
|
918
|
-
const c =
|
|
919
|
-
if (
|
|
920
|
-
const u =
|
|
1277
|
+
return n + e.slice(i);
|
|
1278
|
+
const c = e.slice(i, a + 1);
|
|
1279
|
+
if (n += /(?:^|\s)nonce(?:\s|=|>)/i.test(c) ? c : vr(c, t), o = a + 1, s === "script" || s === "style") {
|
|
1280
|
+
const u = r.indexOf(`</${s}`, o);
|
|
921
1281
|
if (u === -1)
|
|
922
|
-
return
|
|
923
|
-
|
|
1282
|
+
return n + e.slice(o);
|
|
1283
|
+
n += e.slice(o, u), o = u;
|
|
924
1284
|
}
|
|
925
1285
|
}
|
|
926
|
-
return
|
|
1286
|
+
return n;
|
|
927
1287
|
}
|
|
928
|
-
function
|
|
929
|
-
let
|
|
930
|
-
for (let o =
|
|
931
|
-
const
|
|
932
|
-
if (
|
|
933
|
-
|
|
1288
|
+
function Rr(e, t) {
|
|
1289
|
+
let r;
|
|
1290
|
+
for (let o = t + 1; o < e.length; o++) {
|
|
1291
|
+
const n = e[o];
|
|
1292
|
+
if (r) {
|
|
1293
|
+
n === r && (r = void 0);
|
|
934
1294
|
continue;
|
|
935
1295
|
}
|
|
936
|
-
if (
|
|
937
|
-
|
|
938
|
-
else if (
|
|
1296
|
+
if (n === '"' || n === "'")
|
|
1297
|
+
r = n;
|
|
1298
|
+
else if (n === ">")
|
|
939
1299
|
return o;
|
|
940
1300
|
}
|
|
941
1301
|
return -1;
|
|
942
1302
|
}
|
|
943
|
-
function
|
|
944
|
-
const
|
|
945
|
-
return `${
|
|
1303
|
+
function vr(e, t) {
|
|
1304
|
+
const r = /\/\s*>$/.test(e) ? e.lastIndexOf("/") : e.length - 1;
|
|
1305
|
+
return `${e.slice(0, r)} nonce="${t}"${e.slice(r)}`;
|
|
946
1306
|
}
|
|
947
|
-
function
|
|
1307
|
+
function ve(e, t, r) {
|
|
948
1308
|
const o = new RegExp(
|
|
949
|
-
`(\\snonce\\s*=\\s*)(["'])${
|
|
1309
|
+
`(\\snonce\\s*=\\s*)(["'])${je(t)}\\2`,
|
|
950
1310
|
"g"
|
|
951
1311
|
);
|
|
952
|
-
return
|
|
1312
|
+
return e.replace(
|
|
953
1313
|
o,
|
|
954
|
-
|
|
1314
|
+
r ? `$1"${r}"` : ""
|
|
955
1315
|
);
|
|
956
1316
|
}
|
|
957
|
-
function
|
|
958
|
-
const
|
|
959
|
-
if (!
|
|
1317
|
+
function be(e, t) {
|
|
1318
|
+
const r = e.headers.get("content-type"), o = e.headers.get("content-security-policy");
|
|
1319
|
+
if (!r?.toLowerCase().startsWith("text/html") || !o)
|
|
960
1320
|
return;
|
|
961
|
-
const
|
|
1321
|
+
const n = `'nonce-${t}'`, i = $e(
|
|
962
1322
|
o,
|
|
963
1323
|
["script-src-elem", "script-src"],
|
|
964
1324
|
"script-src",
|
|
965
|
-
|
|
966
|
-
), s =
|
|
1325
|
+
n
|
|
1326
|
+
), s = br(
|
|
967
1327
|
i,
|
|
968
1328
|
["style-src-elem", "style-src"]
|
|
969
|
-
) ? i :
|
|
1329
|
+
) ? i : $e(
|
|
970
1330
|
i,
|
|
971
1331
|
["style-src-elem", "style-src"],
|
|
972
1332
|
"style-src",
|
|
973
|
-
|
|
1333
|
+
n
|
|
974
1334
|
);
|
|
975
|
-
|
|
1335
|
+
e.headers.set("content-security-policy", s), e.headers.set("cache-control", "private, no-store");
|
|
976
1336
|
}
|
|
977
|
-
function
|
|
978
|
-
const
|
|
979
|
-
(
|
|
1337
|
+
function $e(e, t, r, o) {
|
|
1338
|
+
const n = e.split(";").map((d) => d.trim()), i = Fe(n, t), s = n.find(
|
|
1339
|
+
(d) => d.split(/\s+/, 1)[0]?.toLowerCase() === "default-src"
|
|
980
1340
|
);
|
|
981
|
-
if (i === -1 && !s) return
|
|
982
|
-
const [a, ...c] = (i === -1 ? s :
|
|
983
|
-
i === -1 ?
|
|
1341
|
+
if (i === -1 && !s) return e;
|
|
1342
|
+
const [a, ...c] = (i === -1 ? s : n[i]).split(/\s+/), u = [
|
|
1343
|
+
i === -1 ? r : a,
|
|
984
1344
|
.../* @__PURE__ */ new Set([
|
|
985
|
-
...c.filter((
|
|
1345
|
+
...c.filter((d) => d !== "'none'"),
|
|
986
1346
|
o
|
|
987
1347
|
])
|
|
988
1348
|
].join(" ");
|
|
989
|
-
return i === -1 ?
|
|
1349
|
+
return i === -1 ? n.push(u) : n[i] = u, n.join("; ");
|
|
990
1350
|
}
|
|
991
|
-
function
|
|
992
|
-
const
|
|
1351
|
+
function br(e, t) {
|
|
1352
|
+
const r = e.split(";").map((s) => s.trim()), o = Fe(r, t), i = (o === -1 ? r.find(
|
|
993
1353
|
(s) => s.split(/\s+/, 1)[0]?.toLowerCase() === "default-src"
|
|
994
|
-
) :
|
|
1354
|
+
) : r[o])?.split(/\s+/).slice(1) ?? [];
|
|
995
1355
|
return i.includes("'unsafe-inline'") && !i.some((s) => /^'(?:nonce-|sha(?:256|384|512)-)/i.test(s));
|
|
996
1356
|
}
|
|
997
|
-
function
|
|
998
|
-
for (const
|
|
999
|
-
const o =
|
|
1000
|
-
(
|
|
1357
|
+
function Fe(e, t) {
|
|
1358
|
+
for (const r of t) {
|
|
1359
|
+
const o = e.findIndex(
|
|
1360
|
+
(n) => n.split(/\s+/, 1)[0]?.toLowerCase() === r
|
|
1001
1361
|
);
|
|
1002
1362
|
if (o !== -1) return o;
|
|
1003
1363
|
}
|
|
1004
1364
|
return -1;
|
|
1005
1365
|
}
|
|
1006
|
-
const
|
|
1007
|
-
async function
|
|
1008
|
-
const o =
|
|
1009
|
-
if (
|
|
1010
|
-
return
|
|
1011
|
-
const i =
|
|
1012
|
-
await
|
|
1366
|
+
const Se = Symbol.for("demiurge.devManifest");
|
|
1367
|
+
async function Z(e, t, r) {
|
|
1368
|
+
const o = t, n = o[Se];
|
|
1369
|
+
if (n)
|
|
1370
|
+
return n;
|
|
1371
|
+
const i = st(
|
|
1372
|
+
await Tr(e, r)
|
|
1013
1373
|
);
|
|
1014
|
-
return o[
|
|
1374
|
+
return o[Se] = i, i;
|
|
1015
1375
|
}
|
|
1016
|
-
function
|
|
1376
|
+
function ke(e) {
|
|
1017
1377
|
return {
|
|
1018
|
-
clientEntry:
|
|
1019
|
-
lang:
|
|
1020
|
-
title:
|
|
1378
|
+
clientEntry: te,
|
|
1379
|
+
lang: e.document?.lang,
|
|
1380
|
+
title: e.document?.title
|
|
1021
1381
|
};
|
|
1022
1382
|
}
|
|
1023
|
-
function
|
|
1383
|
+
function $r(e, t) {
|
|
1024
1384
|
return {
|
|
1025
|
-
|
|
1385
|
+
...ke(e),
|
|
1026
1386
|
dev: !0,
|
|
1027
|
-
transformDocument:
|
|
1387
|
+
transformDocument: t
|
|
1028
1388
|
};
|
|
1029
1389
|
}
|
|
1030
|
-
const
|
|
1031
|
-
function
|
|
1032
|
-
|
|
1033
|
-
(
|
|
1034
|
-
) || (
|
|
1390
|
+
const xe = /* @__PURE__ */ new Set();
|
|
1391
|
+
function Sr(e, t) {
|
|
1392
|
+
xe.has(t) || e.fallbacks.notFound.some(
|
|
1393
|
+
(r) => r.fileSegments.length === 0
|
|
1394
|
+
) || (xe.add(t), console.warn(Or(He(t, "@not-found.tsx"))));
|
|
1035
1395
|
}
|
|
1036
|
-
async function
|
|
1037
|
-
const
|
|
1038
|
-
if (!
|
|
1396
|
+
async function xr(e, t = {}) {
|
|
1397
|
+
const r = t.routesDir ?? "src/routes", o = b(e, r);
|
|
1398
|
+
if (!re(o))
|
|
1039
1399
|
return;
|
|
1040
|
-
const
|
|
1041
|
-
if (
|
|
1042
|
-
(a) =>
|
|
1400
|
+
const n = await ie(o);
|
|
1401
|
+
if (n.map(
|
|
1402
|
+
(a) => N(o, a).split(O).join("/")
|
|
1043
1403
|
).some((a) => /^@not-found\.tsx?$/.test(a)))
|
|
1044
1404
|
return;
|
|
1045
|
-
const s = await
|
|
1405
|
+
const s = await Er(n);
|
|
1046
1406
|
if (s)
|
|
1047
1407
|
throw new Error(
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1408
|
+
Pr(
|
|
1409
|
+
r,
|
|
1410
|
+
N(o, s).split(O).join("/")
|
|
1051
1411
|
)
|
|
1052
1412
|
);
|
|
1053
1413
|
}
|
|
1054
|
-
async function
|
|
1055
|
-
for (const
|
|
1056
|
-
if (!
|
|
1057
|
-
return
|
|
1414
|
+
async function Er(e) {
|
|
1415
|
+
for (const t of e)
|
|
1416
|
+
if (!N(ne(t), t).startsWith("@") && Dr(await Pe(t, "utf8")))
|
|
1417
|
+
return t;
|
|
1058
1418
|
}
|
|
1059
|
-
const
|
|
1060
|
-
`import\\s*\\{([^}]*)\\}\\s*from\\s*["']${
|
|
1419
|
+
const Nr = P.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ee = new RegExp(
|
|
1420
|
+
`import\\s*\\{([^}]*)\\}\\s*from\\s*["']${Nr}["']`,
|
|
1061
1421
|
"g"
|
|
1062
1422
|
);
|
|
1063
|
-
function
|
|
1064
|
-
const
|
|
1065
|
-
(o) => o[1].split(",").flatMap((
|
|
1066
|
-
const [i, s] =
|
|
1423
|
+
function Dr(e) {
|
|
1424
|
+
const t = [...e.matchAll(Ee)].flatMap(
|
|
1425
|
+
(o) => o[1].split(",").flatMap((n) => {
|
|
1426
|
+
const [i, s] = n.trim().split(/\s+as\s+/);
|
|
1067
1427
|
return i.replace(/^type\s+/, "") === "page" ? [s ?? i] : [];
|
|
1068
1428
|
})
|
|
1069
1429
|
);
|
|
1070
|
-
if (
|
|
1430
|
+
if (t.length === 0)
|
|
1071
1431
|
return !1;
|
|
1072
|
-
const
|
|
1073
|
-
return
|
|
1432
|
+
const r = e.replace(Ee, "");
|
|
1433
|
+
return t.some((o) => new RegExp(`\\b${o}\\s*\\(`).test(r));
|
|
1074
1434
|
}
|
|
1075
|
-
function
|
|
1076
|
-
return `Demiurge will not build an app with page routes and no ${
|
|
1435
|
+
function Pr(e, t) {
|
|
1436
|
+
return `Demiurge will not build an app with page routes and no ${e}/@not-found.tsx.
|
|
1077
1437
|
|
|
1078
|
-
"${
|
|
1438
|
+
"${t}" 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
1439
|
|
|
1080
|
-
Create ${
|
|
1440
|
+
Create ${e}/@not-found.tsx:
|
|
1081
1441
|
|
|
1082
1442
|
export default function NotFound({ pathname }: { pathname: string }) {
|
|
1083
1443
|
return <h1>Nothing at {pathname}</h1>;
|
|
@@ -1085,8 +1445,8 @@ Create ${t}/@not-found.tsx:
|
|
|
1085
1445
|
|
|
1086
1446
|
It renders inside the layouts above the requested path. Opt out with "export const layout = false".`;
|
|
1087
1447
|
}
|
|
1088
|
-
function
|
|
1089
|
-
return `Demiurge is serving its built-in 404 because ${
|
|
1448
|
+
function Or(e) {
|
|
1449
|
+
return `Demiurge is serving its built-in 404 because ${e} does not exist.
|
|
1090
1450
|
|
|
1091
1451
|
Create it before building for production:
|
|
1092
1452
|
|
|
@@ -1095,105 +1455,109 @@ Create it before building for production:
|
|
|
1095
1455
|
}
|
|
1096
1456
|
`;
|
|
1097
1457
|
}
|
|
1098
|
-
function
|
|
1099
|
-
entrySrc:
|
|
1100
|
-
lang:
|
|
1101
|
-
links:
|
|
1458
|
+
function Mr({
|
|
1459
|
+
entrySrc: e,
|
|
1460
|
+
lang: t,
|
|
1461
|
+
links: r,
|
|
1102
1462
|
metadata: o,
|
|
1103
|
-
nonce:
|
|
1463
|
+
nonce: n,
|
|
1104
1464
|
scripts: i,
|
|
1105
1465
|
styles: s,
|
|
1106
1466
|
title: a
|
|
1107
1467
|
}) {
|
|
1108
|
-
return
|
|
1109
|
-
entrySrc:
|
|
1110
|
-
lang:
|
|
1111
|
-
links:
|
|
1468
|
+
return qe({
|
|
1469
|
+
entrySrc: e,
|
|
1470
|
+
lang: t,
|
|
1471
|
+
links: r,
|
|
1112
1472
|
metadata: o,
|
|
1113
|
-
nonce:
|
|
1473
|
+
nonce: n,
|
|
1114
1474
|
scripts: i,
|
|
1115
1475
|
styles: s,
|
|
1116
1476
|
title: a
|
|
1117
1477
|
});
|
|
1118
1478
|
}
|
|
1119
|
-
async function
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
typeof
|
|
1479
|
+
async function L(e, t) {
|
|
1480
|
+
const r = b(e, t.routesDir ?? "src/routes"), o = b(
|
|
1481
|
+
e,
|
|
1482
|
+
typeof t.typedRoutes == "object" ? t.typedRoutes.outputFile ?? ge : ge
|
|
1123
1483
|
);
|
|
1124
|
-
await
|
|
1484
|
+
await dt({ outputFile: o, routesDir: r });
|
|
1125
1485
|
}
|
|
1126
|
-
function
|
|
1127
|
-
return
|
|
1486
|
+
function J(e, t) {
|
|
1487
|
+
return t.startsWith(e) && /\.tsx?$/.test(t);
|
|
1128
1488
|
}
|
|
1129
|
-
async function
|
|
1130
|
-
const
|
|
1131
|
-
for (const
|
|
1132
|
-
const i =
|
|
1133
|
-
o[i] = async () => await
|
|
1489
|
+
async function Tr(e, t) {
|
|
1490
|
+
const r = await ie(t), o = {};
|
|
1491
|
+
for (const n of r) {
|
|
1492
|
+
const i = Fr(t, n);
|
|
1493
|
+
o[i] = async () => await e.ssrLoadModule(n);
|
|
1134
1494
|
}
|
|
1135
1495
|
return o;
|
|
1136
1496
|
}
|
|
1137
|
-
async function
|
|
1138
|
-
const o = new URL(
|
|
1139
|
-
return
|
|
1497
|
+
async function Ar(e, t, r = {}) {
|
|
1498
|
+
const o = new URL(t.url);
|
|
1499
|
+
return Oe(e.routes, o.pathname) ? await it(e, t, r) : "next";
|
|
1140
1500
|
}
|
|
1141
|
-
async function
|
|
1142
|
-
return (await
|
|
1501
|
+
async function ie(e) {
|
|
1502
|
+
return (await De(e, {
|
|
1143
1503
|
recursive: !0,
|
|
1144
1504
|
withFileTypes: !0
|
|
1145
|
-
})).filter((
|
|
1505
|
+
})).filter((r) => r.isFile() && /\.tsx?$/.test(r.name)).map((r) => b(r.parentPath, r.name));
|
|
1146
1506
|
}
|
|
1147
|
-
const
|
|
1148
|
-
async function
|
|
1149
|
-
const o = new Array(
|
|
1150
|
-
let
|
|
1507
|
+
const Cr = 8, Ir = 50;
|
|
1508
|
+
async function jr(e, t, r) {
|
|
1509
|
+
const o = new Array(e.length);
|
|
1510
|
+
let n = 0;
|
|
1151
1511
|
const i = Array.from(
|
|
1152
|
-
{ length: Math.min(
|
|
1512
|
+
{ length: Math.min(t, e.length) },
|
|
1153
1513
|
async () => {
|
|
1154
|
-
for (;
|
|
1155
|
-
const s =
|
|
1156
|
-
o[s] = await
|
|
1514
|
+
for (; n < e.length; ) {
|
|
1515
|
+
const s = n++;
|
|
1516
|
+
o[s] = await r(e[s]);
|
|
1157
1517
|
}
|
|
1158
1518
|
}
|
|
1159
1519
|
);
|
|
1160
1520
|
return await Promise.all(i), o;
|
|
1161
1521
|
}
|
|
1162
|
-
async function
|
|
1163
|
-
const
|
|
1164
|
-
return
|
|
1165
|
-
await
|
|
1166
|
-
|
|
1167
|
-
|
|
1522
|
+
async function Ne(e, t = {}) {
|
|
1523
|
+
const r = b(e, t.routesDir ?? "src/routes");
|
|
1524
|
+
return re(r) ? (await jr(
|
|
1525
|
+
await ie(r),
|
|
1526
|
+
Cr,
|
|
1527
|
+
Nt
|
|
1168
1528
|
)).flat().sort(
|
|
1169
|
-
(
|
|
1529
|
+
(n, i) => n.file.localeCompare(i.file) || (n.exportName ?? "").localeCompare(i.exportName ?? "") || n.code.localeCompare(i.code)
|
|
1170
1530
|
) : [];
|
|
1171
1531
|
}
|
|
1172
|
-
function
|
|
1532
|
+
function _r(e) {
|
|
1173
1533
|
return [
|
|
1174
1534
|
"Demiurge found invalid static route policy:",
|
|
1175
|
-
...
|
|
1535
|
+
...e.map(Le)
|
|
1176
1536
|
].join(`
|
|
1177
1537
|
`);
|
|
1178
1538
|
}
|
|
1179
|
-
function
|
|
1180
|
-
return `${
|
|
1539
|
+
function Le(e) {
|
|
1540
|
+
return `${e.exportName ? `${e.file} export ${e.exportName}` : e.file}: [${e.code}] ${e.message}`;
|
|
1181
1541
|
}
|
|
1182
|
-
function
|
|
1183
|
-
return `./routes/${
|
|
1542
|
+
function Fr(e, t) {
|
|
1543
|
+
return `./routes/${N(e, t).split(O).join("/")}`;
|
|
1184
1544
|
}
|
|
1185
1545
|
export {
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1546
|
+
Yr as demiurge,
|
|
1547
|
+
Te as unstable_ROUTE_AUDIT_PATH,
|
|
1548
|
+
xr as unstable_assertRootNotFoundRoute,
|
|
1549
|
+
ur as unstable_createClientEntrySource,
|
|
1550
|
+
Tr as unstable_createDevRouteImporters,
|
|
1551
|
+
Mr as unstable_createDocumentHtml,
|
|
1552
|
+
Vt as unstable_createRouteAudit,
|
|
1553
|
+
lr as unstable_createServerEntrySource,
|
|
1554
|
+
Dr as unstable_declaresPageRoute,
|
|
1555
|
+
_r as unstable_formatStaticPolicyFindings,
|
|
1556
|
+
Ar as unstable_handleDevRequest,
|
|
1557
|
+
yr as unstable_isRouteAuditEnabled,
|
|
1558
|
+
Jt as unstable_renderRouteAuditDocument,
|
|
1559
|
+
tr as unstable_stripClientPageData,
|
|
1560
|
+
Ne as unstable_verifyRoutePolicies,
|
|
1561
|
+
Dt as unstable_verifyRoutePolicySource
|
|
1198
1562
|
};
|
|
1199
1563
|
//# sourceMappingURL=index.js.map
|