@demiurgejs/core 0.2.0-beta.1 → 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/README.md +2 -0
- package/dist/adapter/testing.d.ts +33 -0
- package/dist/adapter/testing.d.ts.map +1 -0
- package/dist/adapter/testing.js +251 -0
- package/dist/adapter/testing.js.map +1 -0
- package/dist/browser/file-router.d.ts.map +1 -1
- package/dist/chunks/document-shell-WoM8yZlR.js +35 -0
- package/dist/chunks/document-shell-WoM8yZlR.js.map +1 -0
- package/dist/chunks/image-codec-Di53WpcH.js +141 -0
- package/dist/chunks/image-codec-Di53WpcH.js.map +1 -0
- package/dist/chunks/images-Edar3eU1.js +339 -0
- package/dist/chunks/images-Edar3eU1.js.map +1 -0
- package/dist/chunks/request-metadata-DaIYq4Ea.js +677 -0
- package/dist/chunks/request-metadata-DaIYq4Ea.js.map +1 -0
- package/dist/chunks/streaming-D0fGAuiO.js +469 -0
- package/dist/chunks/streaming-D0fGAuiO.js.map +1 -0
- package/dist/chunks/{testing-DBjVCN5v.js → testing-CRflAw4X.js} +1300 -1139
- package/dist/chunks/testing-CRflAw4X.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +63 -54
- package/dist/cli.js.map +1 -1
- 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 +11 -0
- package/dist/document/deferred-scripts.d.ts.map +1 -0
- package/dist/document/hydration.d.ts.map +1 -1
- package/dist/document/index.d.ts +4 -1
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/render.d.ts.map +1 -1
- package/dist/document/scripts.d.ts +12 -1
- package/dist/document/scripts.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 +14 -0
- package/dist/edge/assets.d.ts.map +1 -0
- package/dist/edge/index.d.ts +19 -0
- package/dist/edge/index.d.ts.map +1 -0
- package/dist/edge/index.js +286 -0
- package/dist/edge/index.js.map +1 -0
- package/dist/edge/stores.d.ts +8 -0
- package/dist/edge/stores.d.ts.map +1 -0
- package/dist/edge/streaming.d.ts +7 -0
- package/dist/edge/streaming.d.ts.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +895 -556
- package/dist/index.js.map +1 -1
- package/dist/internal/testing.js +6 -6
- package/dist/kv/index.d.ts +5 -0
- package/dist/kv/index.d.ts.map +1 -0
- package/dist/kv/index.js +126 -0
- package/dist/kv/index.js.map +1 -0
- 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 +28 -0
- package/dist/kv/store.d.ts.map +1 -0
- package/dist/node/font.d.ts +5 -0
- package/dist/node/font.d.ts.map +1 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/image.d.ts +15 -0
- package/dist/node/image.d.ts.map +1 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +25 -23
- 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/analytics.d.ts +58 -5
- package/dist/platform/analytics.d.ts.map +1 -1
- package/dist/platform/font-assets.d.ts +19 -0
- package/dist/platform/font-assets.d.ts.map +1 -0
- package/dist/platform/fonts.d.ts +14 -4
- package/dist/platform/fonts.d.ts.map +1 -1
- package/dist/platform/image-codec.d.ts +15 -0
- package/dist/platform/image-codec.d.ts.map +1 -0
- package/dist/platform/image-url.d.ts +17 -0
- package/dist/platform/image-url.d.ts.map +1 -0
- package/dist/platform/image.d.ts +8 -0
- package/dist/platform/image.d.ts.map +1 -0
- package/dist/platform/images.d.ts +15 -0
- package/dist/platform/images.d.ts.map +1 -1
- package/dist/platform/index.d.ts +13 -6
- 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 +5 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +209 -0
- package/dist/redis/index.js.map +1 -0
- 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 +8 -0
- package/dist/redis/store.d.ts.map +1 -0
- 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 +2 -27
- 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 +82 -6
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/verification.d.ts.map +1 -1
- package/dist/server/document-shell.d.ts +12 -0
- package/dist/server/document-shell.d.ts.map +1 -0
- 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/images.d.ts +13 -0
- package/dist/static/images.d.ts.map +1 -0
- package/dist/static/index.d.ts +8 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +421 -313
- package/dist/static/index.js.map +1 -1
- package/dist/static/vercel.d.ts +3 -0
- package/dist/static/vercel.d.ts.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 +1041 -652
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugin.d.ts +9 -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 +34 -3
- package/dist/chunks/request-metadata-DwEO1EAS.js +0 -477
- package/dist/chunks/request-metadata-DwEO1EAS.js.map +0 -1
- package/dist/chunks/streaming-Ci6vf3BB.js +0 -353
- package/dist/chunks/streaming-Ci6vf3BB.js.map +0 -1
- package/dist/chunks/testing-DBjVCN5v.js.map +0 -1
package/dist/vite/index.js
CHANGED
|
@@ -1,78 +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 {
|
|
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 { t as
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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), {
|
|
16
17
|
routes: o,
|
|
17
|
-
source:
|
|
18
|
+
source: n
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
async function
|
|
21
|
-
return (await
|
|
21
|
+
async function ft(e) {
|
|
22
|
+
return (await De(e, {
|
|
22
23
|
recursive: !0,
|
|
23
24
|
withFileTypes: !0
|
|
24
|
-
})).filter((
|
|
25
|
+
})).filter((r) => r.isFile() && /\.tsx?$/.test(r.name)).map((r) => b(r.parentPath, r.name));
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
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("@"))
|
|
29
30
|
return null;
|
|
30
|
-
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)] : []);
|
|
31
32
|
return {
|
|
32
|
-
contextMiddleware:
|
|
33
|
-
fileSegments:
|
|
33
|
+
contextMiddleware: r.filter((c) => yt(c.fileSegments, n)).map((c) => r.indexOf(c)),
|
|
34
|
+
fileSegments: n,
|
|
34
35
|
pathVars: a,
|
|
35
36
|
pattern: `/${s.join("/")}`.replace(/\/$/, "") || "/"
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
const o =
|
|
39
|
+
function mt(e, t) {
|
|
40
|
+
const o = N(e.routesDir, t).split(O).join("/").replace(/\.tsx?$/, "").split("/");
|
|
40
41
|
if (o.at(-1) !== "@middleware")
|
|
41
42
|
return null;
|
|
42
|
-
let
|
|
43
|
-
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 };
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
47
|
-
(
|
|
46
|
+
function yt(e, t) {
|
|
47
|
+
return e.every(
|
|
48
|
+
(r, o) => t[o] === r
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
51
|
+
function de(e) {
|
|
52
|
+
return e.startsWith("(") && e.endsWith(")");
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
+
function ht(e, t) {
|
|
54
55
|
return `// Generated by Demiurge. Do not edit by hand.
|
|
55
|
-
import "${
|
|
56
|
-
import type { MiddlewareContextOf, PathValue } from "${
|
|
57
|
-
${
|
|
56
|
+
import "${P}";
|
|
57
|
+
import type { MiddlewareContextOf, PathValue } from "${P}";
|
|
58
|
+
${t.map(gt).join(`
|
|
58
59
|
`)}
|
|
59
60
|
|
|
60
|
-
${
|
|
61
|
+
${t.map((r, o) => wt(o)).join(`
|
|
61
62
|
`)}
|
|
62
63
|
|
|
63
|
-
declare module "${
|
|
64
|
+
declare module "${P}" {
|
|
64
65
|
interface RoutePathVars {
|
|
65
|
-
${
|
|
66
|
+
${e.map(Rt).join(`
|
|
66
67
|
`)}
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
interface RouteConcretePaths {
|
|
70
|
-
${
|
|
71
|
+
${e.map(vt).join(`
|
|
71
72
|
`)}
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
interface RouteRequestContexts {
|
|
75
|
-
${
|
|
76
|
+
${e.map(bt).join(`
|
|
76
77
|
`)}
|
|
77
78
|
}
|
|
78
79
|
}
|
|
@@ -80,32 +81,32 @@ ${t.map(Gt).join(`
|
|
|
80
81
|
export {};
|
|
81
82
|
`;
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
-
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;`;
|
|
85
86
|
}
|
|
86
|
-
function
|
|
87
|
-
return `type __DemiurgeMiddlewareContext${
|
|
87
|
+
function wt(e) {
|
|
88
|
+
return `type __DemiurgeMiddlewareContext${e} = MiddlewareContextOf<__DemiurgeMiddleware${e}>;`;
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
-
if (
|
|
91
|
-
return ` ${JSON.stringify(
|
|
92
|
-
const
|
|
93
|
-
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} };`;
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
-
return ` ${JSON.stringify(
|
|
96
|
+
function vt(e) {
|
|
97
|
+
return ` ${JSON.stringify(e.pattern)}: ${$t(e.pattern)};`;
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
-
const
|
|
100
|
-
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};`;
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
-
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);
|
|
104
105
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
106
|
+
function St(e) {
|
|
107
|
+
return e.replace(/[`$\\]/g, "\\$&");
|
|
107
108
|
}
|
|
108
|
-
const
|
|
109
|
+
const xt = [
|
|
109
110
|
"GET",
|
|
110
111
|
"POST",
|
|
111
112
|
"PUT",
|
|
@@ -113,7 +114,7 @@ const zt = [
|
|
|
113
114
|
"DELETE",
|
|
114
115
|
"OPTIONS",
|
|
115
116
|
"HEAD"
|
|
116
|
-
],
|
|
117
|
+
], Et = /* @__PURE__ */ new Set([
|
|
117
118
|
"action",
|
|
118
119
|
"html",
|
|
119
120
|
"json",
|
|
@@ -125,324 +126,671 @@ const zt = [
|
|
|
125
126
|
"stream",
|
|
126
127
|
"text"
|
|
127
128
|
]);
|
|
128
|
-
async function
|
|
129
|
-
const
|
|
130
|
-
return await
|
|
129
|
+
async function Nt(e) {
|
|
130
|
+
const t = await Pe(e, "utf8");
|
|
131
|
+
return await Dt(t, e);
|
|
131
132
|
}
|
|
132
|
-
async function
|
|
133
|
-
const
|
|
133
|
+
async function Dt(e, t) {
|
|
134
|
+
const r = t.endsWith(".tsx") ? "tsx" : "ts", o = await Je(e, t, {
|
|
134
135
|
format: "esm",
|
|
135
|
-
loader:
|
|
136
|
+
loader: r,
|
|
136
137
|
target: "esnext"
|
|
137
|
-
}),
|
|
138
|
-
return
|
|
138
|
+
}), n = Pt(o.code);
|
|
139
|
+
return Ct(n, t);
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
-
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();
|
|
142
143
|
let c;
|
|
143
|
-
for (const [u,
|
|
144
|
-
const
|
|
144
|
+
for (const [u, d] of i) {
|
|
145
|
+
const h = n.get(d);
|
|
145
146
|
if (u === "policy") {
|
|
146
|
-
|
|
147
|
+
h && (c = Me(h, r, o));
|
|
147
148
|
continue;
|
|
148
149
|
}
|
|
149
|
-
if (!
|
|
150
|
-
const
|
|
151
|
-
|
|
150
|
+
if (!Ft(u) || (a.add(u), !h)) continue;
|
|
151
|
+
const D = Tt(h, r, o);
|
|
152
|
+
D && (s[u] = D);
|
|
152
153
|
}
|
|
153
154
|
return { capabilities: s, declaredMethods: a, policy: c };
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
-
const
|
|
157
|
-
for (const
|
|
158
|
-
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;
|
|
159
160
|
if (o?.type === "VariableDeclaration")
|
|
160
|
-
for (const
|
|
161
|
-
const i =
|
|
162
|
-
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);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
|
-
return
|
|
166
|
+
return t;
|
|
166
167
|
}
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
for (const
|
|
170
|
-
if (
|
|
171
|
-
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);
|
|
172
173
|
if (o?.type === "VariableDeclaration")
|
|
173
|
-
for (const
|
|
174
|
-
const i =
|
|
175
|
-
i &&
|
|
174
|
+
for (const n of y(o.declarations)) {
|
|
175
|
+
const i = T(n.id);
|
|
176
|
+
i && t.set(i, i);
|
|
176
177
|
}
|
|
177
|
-
for (const
|
|
178
|
-
const i =
|
|
179
|
-
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);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
|
-
return
|
|
183
|
+
return t;
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
-
if (
|
|
186
|
-
const o =
|
|
187
|
-
if (!
|
|
188
|
-
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];
|
|
189
190
|
if (!s) return {};
|
|
190
|
-
const a =
|
|
191
|
+
const a = fe(s, "cors", r), c = fe(
|
|
191
192
|
s,
|
|
192
193
|
"security",
|
|
193
|
-
|
|
194
|
+
r
|
|
194
195
|
);
|
|
195
196
|
return {
|
|
196
|
-
cors:
|
|
197
|
-
security:
|
|
197
|
+
cors: I(a) ? a : void 0,
|
|
198
|
+
security: I(c) ? c : void 0
|
|
198
199
|
};
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
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;
|
|
204
205
|
}
|
|
205
|
-
if (
|
|
206
|
+
if (e.type !== "ObjectExpression") return g;
|
|
206
207
|
let o;
|
|
207
|
-
for (const
|
|
208
|
-
if (
|
|
209
|
-
|
|
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));
|
|
210
211
|
}
|
|
211
212
|
return o;
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
-
if (
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
const i =
|
|
218
|
-
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;
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
return
|
|
222
|
+
if (e.type !== "ObjectExpression") {
|
|
223
|
+
const n = x(e, r);
|
|
224
|
+
return I(n) ? n : void 0;
|
|
224
225
|
}
|
|
225
226
|
const o = {};
|
|
226
|
-
for (const
|
|
227
|
-
if (
|
|
228
|
-
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);
|
|
229
230
|
if (!i || !s) return;
|
|
230
231
|
if (i === "document") {
|
|
231
|
-
const c =
|
|
232
|
+
const c = At(s, t, r);
|
|
232
233
|
if (!c) return;
|
|
233
234
|
o.document = c;
|
|
234
235
|
continue;
|
|
235
236
|
}
|
|
236
|
-
const a =
|
|
237
|
-
if (a ===
|
|
237
|
+
const a = x(s, r);
|
|
238
|
+
if (a === g) return;
|
|
238
239
|
o[i] = a;
|
|
239
240
|
}
|
|
240
241
|
return o;
|
|
241
242
|
}
|
|
242
|
-
function
|
|
243
|
-
if (
|
|
244
|
-
const a =
|
|
245
|
-
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;
|
|
246
247
|
}
|
|
247
|
-
const o =
|
|
248
|
+
const o = R(e.callee);
|
|
248
249
|
if (o?.type !== "MemberExpression") return;
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
250
|
+
const n = T(o.object), i = M(o.property);
|
|
251
|
+
if (!n || t.get(n) !== "security" || !i)
|
|
251
252
|
return;
|
|
252
|
-
const s =
|
|
253
|
-
if (!(s !==
|
|
254
|
-
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);
|
|
255
257
|
if (i === "crossOriginIsolated")
|
|
256
|
-
return
|
|
257
|
-
if (i === "static")
|
|
258
|
-
|
|
258
|
+
return U.crossOriginIsolated(s);
|
|
259
|
+
if (i === "static")
|
|
260
|
+
return U.static(s);
|
|
261
|
+
if (i === "strict")
|
|
262
|
+
return U.strict(s);
|
|
259
263
|
}
|
|
260
264
|
}
|
|
261
|
-
function
|
|
262
|
-
const
|
|
265
|
+
function Ct(e, t) {
|
|
266
|
+
const r = [], o = new Set(e.declaredMethods);
|
|
263
267
|
o.has("GET") && o.add("HEAD"), o.add("OPTIONS");
|
|
264
|
-
for (const [
|
|
265
|
-
|
|
268
|
+
for (const [n, i] of Object.entries(
|
|
269
|
+
e.capabilities
|
|
266
270
|
)) {
|
|
267
271
|
if (i.cors) {
|
|
268
272
|
try {
|
|
269
|
-
|
|
273
|
+
Ge(i.cors);
|
|
270
274
|
} catch (s) {
|
|
271
|
-
|
|
275
|
+
r.push(q(
|
|
272
276
|
"cors-invalid",
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
t,
|
|
278
|
+
ee(s, "The CORS policy is invalid."),
|
|
279
|
+
n
|
|
276
280
|
));
|
|
277
281
|
}
|
|
278
282
|
for (const s of i.cors.methods ?? [])
|
|
279
|
-
o.has(s) ||
|
|
283
|
+
o.has(s) || r.push(q(
|
|
280
284
|
"cors-method-unavailable",
|
|
281
|
-
|
|
285
|
+
t,
|
|
282
286
|
`CORS method ${s} is not available from this route.`,
|
|
283
|
-
|
|
287
|
+
n
|
|
284
288
|
));
|
|
285
289
|
}
|
|
286
|
-
|
|
290
|
+
pe(i.security, t, n, r);
|
|
287
291
|
}
|
|
288
|
-
if (
|
|
292
|
+
if (pe(e.policy?.security, t, void 0, r), e.policy?.document)
|
|
289
293
|
try {
|
|
290
|
-
|
|
294
|
+
Be(It(e.policy.document), {
|
|
291
295
|
nonce: "build-verification-nonce"
|
|
292
296
|
});
|
|
293
|
-
} catch (
|
|
294
|
-
|
|
297
|
+
} catch (n) {
|
|
298
|
+
r.push(q(
|
|
295
299
|
"security-header-render-failed",
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
t,
|
|
301
|
+
ee(n, "The security headers are invalid.")
|
|
298
302
|
));
|
|
299
303
|
}
|
|
300
|
-
return
|
|
304
|
+
return r;
|
|
301
305
|
}
|
|
302
|
-
function
|
|
303
|
-
const
|
|
304
|
-
return
|
|
305
|
-
...
|
|
306
|
-
csp: { ...
|
|
307
|
-
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
|
|
308
312
|
};
|
|
309
313
|
}
|
|
310
|
-
function
|
|
311
|
-
if (
|
|
314
|
+
function pe(e, t, r, o) {
|
|
315
|
+
if (e?.rateLimit)
|
|
312
316
|
try {
|
|
313
|
-
|
|
314
|
-
} catch (
|
|
315
|
-
o.push(
|
|
317
|
+
Ke(e.rateLimit);
|
|
318
|
+
} catch (n) {
|
|
319
|
+
o.push(q(
|
|
316
320
|
"rate-limit-invalid",
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
321
|
+
t,
|
|
322
|
+
ee(n, "The rate limit policy is invalid."),
|
|
323
|
+
r
|
|
320
324
|
));
|
|
321
325
|
}
|
|
322
326
|
}
|
|
323
|
-
function
|
|
324
|
-
return { code:
|
|
327
|
+
function q(e, t, r, o) {
|
|
328
|
+
return { code: e, exportName: o, file: t, message: r, severity: "error" };
|
|
325
329
|
}
|
|
326
|
-
function
|
|
327
|
-
const
|
|
328
|
-
for (const
|
|
329
|
-
if (!(
|
|
330
|
-
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)) {
|
|
331
335
|
if (o.type !== "ImportSpecifier") continue;
|
|
332
|
-
const
|
|
333
|
-
|
|
336
|
+
const n = T(o.local), i = M(o.imported);
|
|
337
|
+
n && i && t.set(n, i);
|
|
334
338
|
}
|
|
335
|
-
return
|
|
339
|
+
return t;
|
|
336
340
|
}
|
|
337
|
-
function
|
|
338
|
-
const
|
|
339
|
-
for (const
|
|
340
|
-
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;
|
|
341
345
|
if (o?.type === "VariableDeclaration")
|
|
342
|
-
for (const
|
|
343
|
-
const i =
|
|
346
|
+
for (const n of y(o.declarations)) {
|
|
347
|
+
const i = T(n.id), s = R(n.init);
|
|
344
348
|
if (!i || !s) continue;
|
|
345
|
-
const a =
|
|
346
|
-
a !==
|
|
349
|
+
const a = x(s, t);
|
|
350
|
+
a !== g && t.set(i, a);
|
|
347
351
|
}
|
|
348
352
|
}
|
|
349
|
-
return
|
|
350
|
-
}
|
|
351
|
-
const
|
|
352
|
-
function
|
|
353
|
-
if (
|
|
354
|
-
if (
|
|
355
|
-
if (
|
|
356
|
-
return
|
|
357
|
-
if (
|
|
358
|
-
return
|
|
359
|
-
if (
|
|
360
|
-
const
|
|
361
|
-
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;
|
|
362
366
|
}
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
for (const o of
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
|
|
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);
|
|
369
373
|
}
|
|
370
|
-
return
|
|
374
|
+
return r;
|
|
371
375
|
}
|
|
372
|
-
if (
|
|
373
|
-
const
|
|
374
|
-
for (const o of
|
|
375
|
-
if (o.type !== "Property" || o.computed) return
|
|
376
|
-
const
|
|
377
|
-
if (!
|
|
378
|
-
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;
|
|
379
383
|
}
|
|
380
|
-
return
|
|
384
|
+
return r;
|
|
381
385
|
}
|
|
382
|
-
return
|
|
386
|
+
return g;
|
|
383
387
|
}
|
|
384
388
|
}
|
|
385
|
-
function
|
|
386
|
-
return
|
|
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);
|
|
387
397
|
}
|
|
388
|
-
function
|
|
389
|
-
return
|
|
398
|
+
function R(e) {
|
|
399
|
+
return e && typeof e == "object" && "type" in e ? e : void 0;
|
|
390
400
|
}
|
|
391
|
-
function
|
|
392
|
-
return
|
|
401
|
+
function y(e) {
|
|
402
|
+
return Array.isArray(e) ? e.map(R).filter((t) => !!t) : [];
|
|
393
403
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
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"
|
|
440
|
+
}
|
|
441
|
+
}
|
|
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
|
+
});
|
|
396
497
|
}
|
|
397
|
-
function
|
|
398
|
-
|
|
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
|
+
};
|
|
399
540
|
}
|
|
400
|
-
function
|
|
401
|
-
|
|
402
|
-
|
|
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;
|
|
548
|
+
}
|
|
403
549
|
}
|
|
404
|
-
function
|
|
405
|
-
|
|
406
|
-
return e?.type === "Identifier" || e?.type === "Literal" ? String(e.name ?? e.value) : void 0;
|
|
550
|
+
function Ht(e) {
|
|
551
|
+
return Ae.find((t) => e[t]) ?? "GET";
|
|
407
552
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
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
|
+
);
|
|
701
|
+
}
|
|
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>`;
|
|
734
|
+
}
|
|
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>`;
|
|
739
|
+
}
|
|
740
|
+
function A(e) {
|
|
741
|
+
return e.length === 0 ? S() : `<ul>${e.map((t) => `<li>${l(t)}</li>`).join("")}</ul>`;
|
|
742
|
+
}
|
|
743
|
+
function Zt(e) {
|
|
744
|
+
return A(
|
|
745
|
+
Object.entries(e).map(([t, r]) => `${t} = ${String(r)}`)
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
function S() {
|
|
749
|
+
return '<span class="empty">none</span>';
|
|
750
|
+
}
|
|
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()}`;
|
|
412
758
|
return {
|
|
413
759
|
api: {
|
|
414
760
|
demiurge: !0,
|
|
415
|
-
|
|
416
|
-
|
|
761
|
+
fonts: e.fonts,
|
|
762
|
+
images: e.images,
|
|
763
|
+
staticDeployment: e.static?.deployment,
|
|
764
|
+
staticFileHeaders: e.static?.headers
|
|
417
765
|
},
|
|
418
766
|
enforce: "post",
|
|
419
767
|
name: "demiurge",
|
|
420
|
-
config(
|
|
421
|
-
return
|
|
768
|
+
config(n, i) {
|
|
769
|
+
return cr(n, i, o);
|
|
422
770
|
},
|
|
423
|
-
configResolved(
|
|
424
|
-
|
|
771
|
+
configResolved(n) {
|
|
772
|
+
t = n.root, r = n.command === "build";
|
|
425
773
|
},
|
|
426
|
-
resolveId(
|
|
427
|
-
return
|
|
774
|
+
resolveId(n) {
|
|
775
|
+
return n === K ? X : n === Ie ? he : null;
|
|
428
776
|
},
|
|
429
|
-
load(
|
|
430
|
-
return
|
|
777
|
+
load(n) {
|
|
778
|
+
return n === X ? ur(t, e) : n === he ? lr(t, e) : null;
|
|
431
779
|
},
|
|
432
780
|
transform: {
|
|
433
781
|
order: "post",
|
|
434
|
-
handler(
|
|
435
|
-
if (!
|
|
782
|
+
handler(n, i, s) {
|
|
783
|
+
if (!nr(t, e, i))
|
|
436
784
|
return null;
|
|
437
785
|
if (s?.ssr)
|
|
438
|
-
return
|
|
439
|
-
const a =
|
|
440
|
-
return a ===
|
|
786
|
+
return r ? null : er(n, i);
|
|
787
|
+
const a = tr(n);
|
|
788
|
+
return a === n ? null : { code: a, map: null };
|
|
441
789
|
}
|
|
442
790
|
},
|
|
443
|
-
generateBundle(
|
|
791
|
+
generateBundle(n, i) {
|
|
444
792
|
const s = Object.values(i).find(
|
|
445
|
-
(u) => u.type === "chunk" && u.isEntry && u.facadeModuleId ===
|
|
793
|
+
(u) => u.type === "chunk" && u.isEntry && u.facadeModuleId === X
|
|
446
794
|
);
|
|
447
795
|
if (!s)
|
|
448
796
|
return;
|
|
@@ -451,11 +799,11 @@ function rr(t = {}) {
|
|
|
451
799
|
).map((u) => `/${u.fileName}`), c = `/${s.fileName}`;
|
|
452
800
|
this.emitFile({
|
|
453
801
|
fileName: "index.html",
|
|
454
|
-
source:
|
|
802
|
+
source: Mr({
|
|
455
803
|
entrySrc: c,
|
|
456
|
-
lang:
|
|
804
|
+
lang: e.document?.lang,
|
|
457
805
|
styles: a,
|
|
458
|
-
title:
|
|
806
|
+
title: e.document?.title
|
|
459
807
|
}),
|
|
460
808
|
type: "asset"
|
|
461
809
|
}), this.emitFile({
|
|
@@ -465,19 +813,19 @@ function rr(t = {}) {
|
|
|
465
813
|
});
|
|
466
814
|
},
|
|
467
815
|
async buildStart() {
|
|
468
|
-
if (
|
|
469
|
-
await
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
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));
|
|
473
821
|
}
|
|
474
|
-
|
|
822
|
+
e.typedRoutes && await L(t, e);
|
|
475
823
|
},
|
|
476
|
-
configureServer(
|
|
824
|
+
configureServer(n) {
|
|
477
825
|
const i = async () => {
|
|
478
|
-
const
|
|
479
|
-
for (const f of
|
|
480
|
-
|
|
826
|
+
const m = await Ne(n.config.root, e);
|
|
827
|
+
for (const f of m)
|
|
828
|
+
n.config.logger.warn(Le(f));
|
|
481
829
|
};
|
|
482
830
|
let s, a = Promise.resolve();
|
|
483
831
|
const c = () => {
|
|
@@ -486,125 +834,151 @@ function rr(t = {}) {
|
|
|
486
834
|
}, u = () => {
|
|
487
835
|
s && clearTimeout(s), s = setTimeout(() => {
|
|
488
836
|
s = void 0, c();
|
|
489
|
-
},
|
|
837
|
+
}, Ir), s.unref?.();
|
|
490
838
|
};
|
|
491
|
-
if (
|
|
839
|
+
if (n.httpServer?.once("close", () => {
|
|
492
840
|
s && (clearTimeout(s), s = void 0);
|
|
493
|
-
}), c(),
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
841
|
+
}), c(), e.typedRoutes) {
|
|
842
|
+
const m = b(
|
|
843
|
+
n.config.root,
|
|
844
|
+
e.routesDir ?? "src/routes"
|
|
497
845
|
);
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}),
|
|
501
|
-
|
|
502
|
-
}),
|
|
503
|
-
|
|
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());
|
|
504
852
|
});
|
|
505
853
|
} else {
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
854
|
+
const m = b(
|
|
855
|
+
n.config.root,
|
|
856
|
+
e.routesDir ?? "src/routes"
|
|
509
857
|
);
|
|
510
|
-
|
|
858
|
+
n.watcher.add(m);
|
|
511
859
|
for (const f of ["add", "change", "unlink"])
|
|
512
|
-
|
|
513
|
-
|
|
860
|
+
n.watcher.on(f, (p) => {
|
|
861
|
+
J(m, p) && u();
|
|
514
862
|
});
|
|
515
863
|
}
|
|
516
|
-
|
|
864
|
+
const d = yr(e), h = hr(n, e), D = at({
|
|
865
|
+
fonts: e.fonts,
|
|
866
|
+
root: n.config.root
|
|
867
|
+
});
|
|
868
|
+
return n.middlewares.use(async (m, f, p) => {
|
|
517
869
|
try {
|
|
518
|
-
let
|
|
870
|
+
let v;
|
|
519
871
|
try {
|
|
520
|
-
|
|
872
|
+
v = ce(m, {
|
|
521
873
|
// Vite performs its own configured host allowlist check before
|
|
522
874
|
// Demiurge's middleware runs. Production Node listeners require
|
|
523
875
|
// an explicit application allowlist instead.
|
|
524
|
-
allowedHosts: [
|
|
876
|
+
allowedHosts: [m.headers.host ?? "localhost"]
|
|
525
877
|
});
|
|
526
|
-
} catch (
|
|
527
|
-
if (
|
|
528
|
-
|
|
878
|
+
} catch (H) {
|
|
879
|
+
if (H instanceof ue) {
|
|
880
|
+
le(f);
|
|
529
881
|
return;
|
|
530
882
|
}
|
|
531
|
-
throw
|
|
883
|
+
throw H;
|
|
532
884
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
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;
|
|
896
|
+
}
|
|
897
|
+
const j = await D(v);
|
|
898
|
+
if (j) {
|
|
899
|
+
await k(f, j);
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const _ = await h(v);
|
|
903
|
+
if (_) {
|
|
904
|
+
await k(f, _);
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
const V = b(
|
|
908
|
+
n.config.root,
|
|
909
|
+
e.routesDir ?? "src/routes"
|
|
910
|
+
), W = await Z(n, m, V), F = Re(
|
|
911
|
+
n,
|
|
538
912
|
o
|
|
539
|
-
),
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
913
|
+
), Y = await Ar(
|
|
914
|
+
W,
|
|
915
|
+
v,
|
|
916
|
+
gr(e, F.transform)
|
|
543
917
|
);
|
|
544
|
-
if (
|
|
545
|
-
|
|
918
|
+
if (Y === "next") {
|
|
919
|
+
p();
|
|
546
920
|
return;
|
|
547
921
|
}
|
|
548
|
-
|
|
549
|
-
} catch (
|
|
550
|
-
|
|
922
|
+
be(Y, F.nonce), await k(f, Y);
|
|
923
|
+
} catch (v) {
|
|
924
|
+
p(v);
|
|
551
925
|
}
|
|
552
926
|
}), () => {
|
|
553
|
-
|
|
927
|
+
n.middlewares.use(async (m, f, p) => {
|
|
554
928
|
try {
|
|
555
|
-
let
|
|
929
|
+
let v;
|
|
556
930
|
try {
|
|
557
|
-
|
|
558
|
-
allowedHosts: [
|
|
931
|
+
v = ce(m, {
|
|
932
|
+
allowedHosts: [m.headers.host ?? "localhost"]
|
|
559
933
|
});
|
|
560
|
-
} catch (
|
|
561
|
-
if (
|
|
562
|
-
|
|
934
|
+
} catch (F) {
|
|
935
|
+
if (F instanceof ue) {
|
|
936
|
+
le(f);
|
|
563
937
|
return;
|
|
564
938
|
}
|
|
565
|
-
throw
|
|
939
|
+
throw F;
|
|
566
940
|
}
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
),
|
|
571
|
-
|
|
572
|
-
const
|
|
573
|
-
|
|
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,
|
|
574
948
|
o
|
|
575
|
-
),
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
949
|
+
), W = await ot(
|
|
950
|
+
_,
|
|
951
|
+
v,
|
|
952
|
+
$r(e, V.transform)
|
|
579
953
|
);
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
), await
|
|
584
|
-
} catch (
|
|
585
|
-
|
|
954
|
+
be(
|
|
955
|
+
W,
|
|
956
|
+
V.nonce
|
|
957
|
+
), await k(f, W);
|
|
958
|
+
} catch (v) {
|
|
959
|
+
p(v);
|
|
586
960
|
}
|
|
587
961
|
});
|
|
588
962
|
};
|
|
589
963
|
}
|
|
590
964
|
};
|
|
591
965
|
}
|
|
592
|
-
function
|
|
593
|
-
if (!
|
|
966
|
+
function er(e, t) {
|
|
967
|
+
if (!e.includes("import.meta"))
|
|
594
968
|
return null;
|
|
595
|
-
const
|
|
596
|
-
(u) => u.type === "ImportDeclaration" &&
|
|
597
|
-
(
|
|
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"
|
|
598
972
|
)
|
|
599
|
-
),
|
|
600
|
-
(u) =>
|
|
601
|
-
), i =
|
|
602
|
-
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)
|
|
603
977
|
return null;
|
|
604
978
|
let s = "__demiurge_imported_meta__";
|
|
605
|
-
for (; new RegExp(`\\b${s}\\b`).test(
|
|
979
|
+
for (; new RegExp(`\\b${s}\\b`).test(e); )
|
|
606
980
|
s += "_";
|
|
607
|
-
const a = new
|
|
981
|
+
const a = new Ue(e), c = w(n.imported);
|
|
608
982
|
return a.overwrite(
|
|
609
983
|
i.start,
|
|
610
984
|
i.end,
|
|
@@ -615,142 +989,142 @@ const meta = ${s};`), {
|
|
|
615
989
|
map: a.generateMap({
|
|
616
990
|
hires: "boundary",
|
|
617
991
|
includeContent: !0,
|
|
618
|
-
source:
|
|
992
|
+
source: t
|
|
619
993
|
})
|
|
620
994
|
};
|
|
621
995
|
}
|
|
622
|
-
function
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
if (a.type === "ImportDeclaration" &&
|
|
626
|
-
|
|
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);
|
|
627
1001
|
return;
|
|
628
1002
|
}
|
|
629
|
-
if (a.type !== "CallExpression" || !
|
|
1003
|
+
if (a.type !== "CallExpression" || !or(a.callee))
|
|
630
1004
|
return;
|
|
631
|
-
const c =
|
|
1005
|
+
const c = E(a.arguments)[0];
|
|
632
1006
|
if (c?.type === "ObjectExpression")
|
|
633
|
-
for (const u of
|
|
634
|
-
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 });
|
|
635
1009
|
});
|
|
636
|
-
const i = [...
|
|
1010
|
+
const i = [...r, ...o];
|
|
637
1011
|
if (i.length === 0)
|
|
638
|
-
return
|
|
1012
|
+
return e;
|
|
639
1013
|
const s = [...i];
|
|
640
|
-
for (const a of
|
|
641
|
-
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, [
|
|
642
1016
|
...i,
|
|
643
1017
|
{ end: a.end, start: a.start }
|
|
644
|
-
]),
|
|
645
|
-
(
|
|
1018
|
+
]), d = c.find(
|
|
1019
|
+
(h) => new RegExp(`\\b${je(h)}\\b`).test(u)
|
|
646
1020
|
);
|
|
647
|
-
if (
|
|
1021
|
+
if (d)
|
|
648
1022
|
throw new Error(
|
|
649
|
-
`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.`
|
|
650
1024
|
);
|
|
651
1025
|
s.push({ end: a.end, start: a.start });
|
|
652
1026
|
}
|
|
653
|
-
return
|
|
654
|
-
|
|
1027
|
+
return ar(
|
|
1028
|
+
e,
|
|
655
1029
|
s,
|
|
656
|
-
(a) =>
|
|
1030
|
+
(a) => r.includes(a) ? "data: undefined" : o.includes(a) ? "undefined" : ""
|
|
657
1031
|
);
|
|
658
1032
|
}
|
|
659
|
-
const
|
|
660
|
-
function
|
|
661
|
-
const
|
|
662
|
-
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)) {
|
|
663
1037
|
if (o.type !== "ExportNamedDeclaration") continue;
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
for (const i of
|
|
667
|
-
const s =
|
|
668
|
-
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));
|
|
669
1043
|
}
|
|
670
|
-
for (const i of
|
|
671
|
-
const s =
|
|
672
|
-
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);
|
|
673
1047
|
}
|
|
674
1048
|
}
|
|
675
|
-
const
|
|
676
|
-
return
|
|
1049
|
+
const r = [];
|
|
1050
|
+
return G(e, (o) => {
|
|
677
1051
|
if (o.type !== "VariableDeclarator") return;
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
}),
|
|
681
|
-
}
|
|
682
|
-
function
|
|
683
|
-
const o =
|
|
684
|
-
return i !== "" && i !== ".." && !i.startsWith(`..${
|
|
685
|
-
}
|
|
686
|
-
function
|
|
687
|
-
if (!
|
|
688
|
-
if (Array.isArray(
|
|
689
|
-
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);
|
|
690
1064
|
return;
|
|
691
1065
|
}
|
|
692
|
-
const
|
|
693
|
-
if (typeof
|
|
694
|
-
|
|
695
|
-
for (const [o,
|
|
696
|
-
(/* @__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);
|
|
697
1071
|
}
|
|
698
1072
|
}
|
|
699
|
-
function
|
|
700
|
-
return
|
|
1073
|
+
function w(e) {
|
|
1074
|
+
return e && typeof e == "object" && "type" in e ? e : void 0;
|
|
701
1075
|
}
|
|
702
|
-
function
|
|
703
|
-
return Array.isArray(
|
|
1076
|
+
function E(e) {
|
|
1077
|
+
return Array.isArray(e) ? e.map(w).filter((t) => !!t) : [];
|
|
704
1078
|
}
|
|
705
|
-
function
|
|
706
|
-
const
|
|
707
|
-
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";
|
|
708
1082
|
}
|
|
709
|
-
function
|
|
710
|
-
const
|
|
711
|
-
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;
|
|
712
1086
|
}
|
|
713
|
-
function
|
|
714
|
-
const
|
|
715
|
-
return typeof
|
|
1087
|
+
function ir(e) {
|
|
1088
|
+
const t = w(e.source)?.value;
|
|
1089
|
+
return typeof t == "string" && /(?:^|[/.-])server(?:[/.-]|$)/.test(t);
|
|
716
1090
|
}
|
|
717
|
-
function
|
|
718
|
-
const
|
|
719
|
-
for (const { end: o, start:
|
|
720
|
-
|
|
721
|
-
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("");
|
|
722
1096
|
}
|
|
723
|
-
function
|
|
724
|
-
return [...
|
|
725
|
-
(o,
|
|
726
|
-
|
|
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
|
|
727
1101
|
);
|
|
728
1102
|
}
|
|
729
|
-
function
|
|
730
|
-
return
|
|
1103
|
+
function je(e) {
|
|
1104
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
731
1105
|
}
|
|
732
|
-
function
|
|
1106
|
+
function cr(e, t, r) {
|
|
733
1107
|
return {
|
|
734
1108
|
appType: "custom",
|
|
735
1109
|
build: {
|
|
736
|
-
assetsInlineLimit:
|
|
737
|
-
...
|
|
1110
|
+
assetsInlineLimit: e.build?.assetsInlineLimit ?? 0,
|
|
1111
|
+
...t.isSsrBuild && e.build?.target === void 0 && e.ssr?.target !== "webworker" ? { target: "node22.13" } : {},
|
|
738
1112
|
rollupOptions: {
|
|
739
|
-
input:
|
|
1113
|
+
input: e.build?.rollupOptions?.input ?? K
|
|
740
1114
|
}
|
|
741
1115
|
},
|
|
742
|
-
...
|
|
743
|
-
html: { cspNonce:
|
|
744
|
-
ssr: { external: [
|
|
1116
|
+
...t.command === "serve" ? {
|
|
1117
|
+
html: { cspNonce: r },
|
|
1118
|
+
ssr: { external: [P] }
|
|
745
1119
|
} : {}
|
|
746
1120
|
};
|
|
747
1121
|
}
|
|
748
|
-
function
|
|
749
|
-
const
|
|
750
|
-
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}";
|
|
751
1125
|
${o}
|
|
752
1126
|
|
|
753
|
-
${
|
|
1127
|
+
${_e(r, {
|
|
754
1128
|
exportRoutes: !1,
|
|
755
1129
|
includeServerOnly: !1
|
|
756
1130
|
})}
|
|
@@ -758,11 +1132,11 @@ ${gt(n, {
|
|
|
758
1132
|
void hydrateFileRouter({ routes });
|
|
759
1133
|
`;
|
|
760
1134
|
}
|
|
761
|
-
function
|
|
762
|
-
const
|
|
763
|
-
return `import { createRequestHandler } from "${
|
|
1135
|
+
function lr(e, t = {}) {
|
|
1136
|
+
const r = t.routesDir ?? "src/routes";
|
|
1137
|
+
return `import { createRequestHandler } from "${P}";
|
|
764
1138
|
|
|
765
|
-
${
|
|
1139
|
+
${_e(r, {
|
|
766
1140
|
exportRoutes: !0,
|
|
767
1141
|
includeServerOnly: !0,
|
|
768
1142
|
eagerModules: !0
|
|
@@ -777,21 +1151,21 @@ export function createHandler(options = {}) {
|
|
|
777
1151
|
routeModules,
|
|
778
1152
|
ssr: {
|
|
779
1153
|
clientEntry,
|
|
780
|
-
lang: lang ?? ${JSON.stringify(
|
|
1154
|
+
lang: lang ?? ${JSON.stringify(t.document?.lang)},
|
|
781
1155
|
styles,
|
|
782
|
-
title: title ?? ${JSON.stringify(
|
|
1156
|
+
title: title ?? ${JSON.stringify(t.document?.title)},
|
|
783
1157
|
},
|
|
784
1158
|
});
|
|
785
1159
|
}
|
|
786
1160
|
`;
|
|
787
1161
|
}
|
|
788
|
-
function
|
|
789
|
-
exportRoutes:
|
|
790
|
-
eagerModules:
|
|
1162
|
+
function _e(e, {
|
|
1163
|
+
exportRoutes: t,
|
|
1164
|
+
eagerModules: r = !1,
|
|
791
1165
|
includeServerOnly: o
|
|
792
1166
|
}) {
|
|
793
|
-
const
|
|
794
|
-
return
|
|
1167
|
+
const n = fr(e, o), i = pr(e);
|
|
1168
|
+
return r ? `const eagerRouteModules = import.meta.glob(${JSON.stringify(n)}, { eager: true });
|
|
795
1169
|
const routePrefix = ${JSON.stringify(i)};
|
|
796
1170
|
export const routeModules = Object.fromEntries(
|
|
797
1171
|
Object.entries(eagerRouteModules).map(([file, module]) => [
|
|
@@ -799,260 +1173,271 @@ export const routeModules = Object.fromEntries(
|
|
|
799
1173
|
module,
|
|
800
1174
|
]),
|
|
801
1175
|
);
|
|
802
|
-
${
|
|
1176
|
+
${t ? "export " : ""}const routes = Object.fromEntries(
|
|
803
1177
|
Object.entries(routeModules).map(([file, module]) => [
|
|
804
1178
|
file,
|
|
805
1179
|
async () => module,
|
|
806
1180
|
]),
|
|
807
|
-
);` : `const routeModules = import.meta.glob(${JSON.stringify(
|
|
1181
|
+
);` : `const routeModules = import.meta.glob(${JSON.stringify(n)});
|
|
808
1182
|
const routePrefix = ${JSON.stringify(i)};
|
|
809
|
-
${
|
|
1183
|
+
${t ? "export " : ""}const routes = Object.fromEntries(
|
|
810
1184
|
Object.entries(routeModules).map(([file, load]) => [
|
|
811
1185
|
\`./routes/\${file.slice(routePrefix.length)}\`,
|
|
812
1186
|
load,
|
|
813
1187
|
]),
|
|
814
1188
|
);`;
|
|
815
1189
|
}
|
|
816
|
-
const
|
|
817
|
-
function
|
|
818
|
-
const
|
|
819
|
-
return
|
|
820
|
-
...
|
|
821
|
-
`!${
|
|
822
|
-
`!${
|
|
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}`
|
|
823
1197
|
])
|
|
824
1198
|
), o;
|
|
825
1199
|
}
|
|
826
|
-
function
|
|
827
|
-
return `/${
|
|
1200
|
+
function pr(e) {
|
|
1201
|
+
return `/${e.replace(/^\/|\/$/g, "")}/`;
|
|
828
1202
|
}
|
|
829
|
-
function
|
|
830
|
-
if (
|
|
1203
|
+
function mr(e, t) {
|
|
1204
|
+
if (t.styles === !1)
|
|
831
1205
|
return "";
|
|
832
|
-
const
|
|
833
|
-
return
|
|
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
|
|
1218
|
+
}) : async () => null;
|
|
834
1219
|
}
|
|
835
|
-
function
|
|
1220
|
+
function gr(e, t) {
|
|
836
1221
|
return {
|
|
837
1222
|
dev: !0,
|
|
838
|
-
ssr:
|
|
839
|
-
transformDocument:
|
|
840
|
-
renderPage: async (
|
|
841
|
-
if (
|
|
842
|
-
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, {
|
|
843
1228
|
...o,
|
|
844
|
-
clientEntry:
|
|
845
|
-
transformDocument:
|
|
1229
|
+
clientEntry: te,
|
|
1230
|
+
transformDocument: t
|
|
846
1231
|
});
|
|
847
|
-
const
|
|
848
|
-
|
|
1232
|
+
const n = await t(
|
|
1233
|
+
ze(r, {
|
|
849
1234
|
...o,
|
|
850
|
-
clientEntry:
|
|
1235
|
+
clientEntry: te
|
|
851
1236
|
})
|
|
852
1237
|
);
|
|
853
|
-
return new Response(
|
|
1238
|
+
return new Response(n, {
|
|
854
1239
|
headers: { "content-type": "text/html; charset=utf-8" }
|
|
855
1240
|
});
|
|
856
1241
|
}
|
|
857
1242
|
};
|
|
858
1243
|
}
|
|
859
|
-
function
|
|
860
|
-
const
|
|
1244
|
+
function Re(e, t) {
|
|
1245
|
+
const r = z(), o = z();
|
|
861
1246
|
return {
|
|
862
|
-
nonce:
|
|
863
|
-
transform: async (
|
|
864
|
-
const i =
|
|
865
|
-
return
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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
|
|
869
1254
|
);
|
|
870
1255
|
}
|
|
871
1256
|
};
|
|
872
1257
|
}
|
|
873
|
-
function
|
|
874
|
-
const
|
|
875
|
-
let o = 0,
|
|
876
|
-
for (; o <
|
|
877
|
-
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);
|
|
878
1263
|
if (i === -1)
|
|
879
|
-
return
|
|
880
|
-
if (
|
|
881
|
-
const u =
|
|
882
|
-
|
|
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;
|
|
883
1268
|
continue;
|
|
884
1269
|
}
|
|
885
|
-
const s =
|
|
1270
|
+
const s = r.slice(i).match(/^<\s*(script|style|link)\b/)?.[1];
|
|
886
1271
|
if (!s) {
|
|
887
|
-
|
|
1272
|
+
n += "<", o = i + 1;
|
|
888
1273
|
continue;
|
|
889
1274
|
}
|
|
890
|
-
const a =
|
|
1275
|
+
const a = Rr(e, i);
|
|
891
1276
|
if (a === -1)
|
|
892
|
-
return
|
|
893
|
-
const c =
|
|
894
|
-
if (
|
|
895
|
-
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);
|
|
896
1281
|
if (u === -1)
|
|
897
|
-
return
|
|
898
|
-
|
|
1282
|
+
return n + e.slice(o);
|
|
1283
|
+
n += e.slice(o, u), o = u;
|
|
899
1284
|
}
|
|
900
1285
|
}
|
|
901
|
-
return
|
|
1286
|
+
return n;
|
|
902
1287
|
}
|
|
903
|
-
function
|
|
904
|
-
let
|
|
905
|
-
for (let o =
|
|
906
|
-
const
|
|
907
|
-
if (
|
|
908
|
-
|
|
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);
|
|
909
1294
|
continue;
|
|
910
1295
|
}
|
|
911
|
-
if (
|
|
912
|
-
|
|
913
|
-
else if (
|
|
1296
|
+
if (n === '"' || n === "'")
|
|
1297
|
+
r = n;
|
|
1298
|
+
else if (n === ">")
|
|
914
1299
|
return o;
|
|
915
1300
|
}
|
|
916
1301
|
return -1;
|
|
917
1302
|
}
|
|
918
|
-
function
|
|
919
|
-
const
|
|
920
|
-
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)}`;
|
|
921
1306
|
}
|
|
922
|
-
function
|
|
1307
|
+
function ve(e, t, r) {
|
|
923
1308
|
const o = new RegExp(
|
|
924
|
-
`(\\snonce\\s*=\\s*)(["'])${
|
|
1309
|
+
`(\\snonce\\s*=\\s*)(["'])${je(t)}\\2`,
|
|
925
1310
|
"g"
|
|
926
1311
|
);
|
|
927
|
-
return
|
|
1312
|
+
return e.replace(
|
|
928
1313
|
o,
|
|
929
|
-
|
|
1314
|
+
r ? `$1"${r}"` : ""
|
|
930
1315
|
);
|
|
931
1316
|
}
|
|
932
|
-
function
|
|
933
|
-
const
|
|
934
|
-
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)
|
|
935
1320
|
return;
|
|
936
|
-
const
|
|
1321
|
+
const n = `'nonce-${t}'`, i = $e(
|
|
937
1322
|
o,
|
|
938
1323
|
["script-src-elem", "script-src"],
|
|
939
1324
|
"script-src",
|
|
940
|
-
|
|
941
|
-
), s =
|
|
1325
|
+
n
|
|
1326
|
+
), s = br(
|
|
942
1327
|
i,
|
|
943
1328
|
["style-src-elem", "style-src"]
|
|
944
|
-
) ? i :
|
|
1329
|
+
) ? i : $e(
|
|
945
1330
|
i,
|
|
946
1331
|
["style-src-elem", "style-src"],
|
|
947
1332
|
"style-src",
|
|
948
|
-
|
|
1333
|
+
n
|
|
949
1334
|
);
|
|
950
|
-
|
|
1335
|
+
e.headers.set("content-security-policy", s), e.headers.set("cache-control", "private, no-store");
|
|
951
1336
|
}
|
|
952
|
-
function
|
|
953
|
-
const
|
|
954
|
-
(
|
|
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"
|
|
955
1340
|
);
|
|
956
|
-
if (i === -1 && !s) return
|
|
957
|
-
const [a, ...c] = (i === -1 ? s :
|
|
958
|
-
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,
|
|
959
1344
|
.../* @__PURE__ */ new Set([
|
|
960
|
-
...c.filter((
|
|
1345
|
+
...c.filter((d) => d !== "'none'"),
|
|
961
1346
|
o
|
|
962
1347
|
])
|
|
963
1348
|
].join(" ");
|
|
964
|
-
return i === -1 ?
|
|
1349
|
+
return i === -1 ? n.push(u) : n[i] = u, n.join("; ");
|
|
965
1350
|
}
|
|
966
|
-
function
|
|
967
|
-
const
|
|
1351
|
+
function br(e, t) {
|
|
1352
|
+
const r = e.split(";").map((s) => s.trim()), o = Fe(r, t), i = (o === -1 ? r.find(
|
|
968
1353
|
(s) => s.split(/\s+/, 1)[0]?.toLowerCase() === "default-src"
|
|
969
|
-
) :
|
|
1354
|
+
) : r[o])?.split(/\s+/).slice(1) ?? [];
|
|
970
1355
|
return i.includes("'unsafe-inline'") && !i.some((s) => /^'(?:nonce-|sha(?:256|384|512)-)/i.test(s));
|
|
971
1356
|
}
|
|
972
|
-
function
|
|
973
|
-
for (const
|
|
974
|
-
const o =
|
|
975
|
-
(
|
|
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
|
|
976
1361
|
);
|
|
977
1362
|
if (o !== -1) return o;
|
|
978
1363
|
}
|
|
979
1364
|
return -1;
|
|
980
1365
|
}
|
|
981
|
-
const
|
|
982
|
-
async function
|
|
983
|
-
const o =
|
|
984
|
-
if (
|
|
985
|
-
return
|
|
986
|
-
const i =
|
|
987
|
-
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)
|
|
988
1373
|
);
|
|
989
|
-
return o[
|
|
1374
|
+
return o[Se] = i, i;
|
|
990
1375
|
}
|
|
991
|
-
function
|
|
1376
|
+
function ke(e) {
|
|
992
1377
|
return {
|
|
993
|
-
clientEntry:
|
|
994
|
-
lang:
|
|
995
|
-
title:
|
|
1378
|
+
clientEntry: te,
|
|
1379
|
+
lang: e.document?.lang,
|
|
1380
|
+
title: e.document?.title
|
|
996
1381
|
};
|
|
997
1382
|
}
|
|
998
|
-
function
|
|
1383
|
+
function $r(e, t) {
|
|
999
1384
|
return {
|
|
1000
|
-
...
|
|
1385
|
+
...ke(e),
|
|
1001
1386
|
dev: !0,
|
|
1002
|
-
transformDocument:
|
|
1387
|
+
transformDocument: t
|
|
1003
1388
|
};
|
|
1004
1389
|
}
|
|
1005
|
-
const
|
|
1006
|
-
function
|
|
1007
|
-
|
|
1008
|
-
(
|
|
1009
|
-
) || (
|
|
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"))));
|
|
1010
1395
|
}
|
|
1011
|
-
async function
|
|
1012
|
-
const
|
|
1013
|
-
if (!
|
|
1396
|
+
async function xr(e, t = {}) {
|
|
1397
|
+
const r = t.routesDir ?? "src/routes", o = b(e, r);
|
|
1398
|
+
if (!re(o))
|
|
1014
1399
|
return;
|
|
1015
|
-
const
|
|
1016
|
-
if (
|
|
1017
|
-
(a) =>
|
|
1400
|
+
const n = await ie(o);
|
|
1401
|
+
if (n.map(
|
|
1402
|
+
(a) => N(o, a).split(O).join("/")
|
|
1018
1403
|
).some((a) => /^@not-found\.tsx?$/.test(a)))
|
|
1019
1404
|
return;
|
|
1020
|
-
const s = await
|
|
1405
|
+
const s = await Er(n);
|
|
1021
1406
|
if (s)
|
|
1022
1407
|
throw new Error(
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1408
|
+
Pr(
|
|
1409
|
+
r,
|
|
1410
|
+
N(o, s).split(O).join("/")
|
|
1026
1411
|
)
|
|
1027
1412
|
);
|
|
1028
1413
|
}
|
|
1029
|
-
async function
|
|
1030
|
-
for (const
|
|
1031
|
-
if (!
|
|
1032
|
-
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;
|
|
1033
1418
|
}
|
|
1034
|
-
const
|
|
1035
|
-
`import\\s*\\{([^}]*)\\}\\s*from\\s*["']${
|
|
1419
|
+
const Nr = P.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ee = new RegExp(
|
|
1420
|
+
`import\\s*\\{([^}]*)\\}\\s*from\\s*["']${Nr}["']`,
|
|
1036
1421
|
"g"
|
|
1037
1422
|
);
|
|
1038
|
-
function
|
|
1039
|
-
const
|
|
1040
|
-
(o) => o[1].split(",").flatMap((
|
|
1041
|
-
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+/);
|
|
1042
1427
|
return i.replace(/^type\s+/, "") === "page" ? [s ?? i] : [];
|
|
1043
1428
|
})
|
|
1044
1429
|
);
|
|
1045
|
-
if (
|
|
1430
|
+
if (t.length === 0)
|
|
1046
1431
|
return !1;
|
|
1047
|
-
const
|
|
1048
|
-
return
|
|
1432
|
+
const r = e.replace(Ee, "");
|
|
1433
|
+
return t.some((o) => new RegExp(`\\b${o}\\s*\\(`).test(r));
|
|
1049
1434
|
}
|
|
1050
|
-
function
|
|
1051
|
-
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.
|
|
1052
1437
|
|
|
1053
|
-
"${
|
|
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.
|
|
1054
1439
|
|
|
1055
|
-
Create ${
|
|
1440
|
+
Create ${e}/@not-found.tsx:
|
|
1056
1441
|
|
|
1057
1442
|
export default function NotFound({ pathname }: { pathname: string }) {
|
|
1058
1443
|
return <h1>Nothing at {pathname}</h1>;
|
|
@@ -1060,8 +1445,8 @@ Create ${t}/@not-found.tsx:
|
|
|
1060
1445
|
|
|
1061
1446
|
It renders inside the layouts above the requested path. Opt out with "export const layout = false".`;
|
|
1062
1447
|
}
|
|
1063
|
-
function
|
|
1064
|
-
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.
|
|
1065
1450
|
|
|
1066
1451
|
Create it before building for production:
|
|
1067
1452
|
|
|
@@ -1070,105 +1455,109 @@ Create it before building for production:
|
|
|
1070
1455
|
}
|
|
1071
1456
|
`;
|
|
1072
1457
|
}
|
|
1073
|
-
function
|
|
1074
|
-
entrySrc:
|
|
1075
|
-
lang:
|
|
1076
|
-
links:
|
|
1458
|
+
function Mr({
|
|
1459
|
+
entrySrc: e,
|
|
1460
|
+
lang: t,
|
|
1461
|
+
links: r,
|
|
1077
1462
|
metadata: o,
|
|
1078
|
-
nonce:
|
|
1463
|
+
nonce: n,
|
|
1079
1464
|
scripts: i,
|
|
1080
1465
|
styles: s,
|
|
1081
1466
|
title: a
|
|
1082
1467
|
}) {
|
|
1083
|
-
return
|
|
1084
|
-
entrySrc:
|
|
1085
|
-
lang:
|
|
1086
|
-
links:
|
|
1468
|
+
return qe({
|
|
1469
|
+
entrySrc: e,
|
|
1470
|
+
lang: t,
|
|
1471
|
+
links: r,
|
|
1087
1472
|
metadata: o,
|
|
1088
|
-
nonce:
|
|
1473
|
+
nonce: n,
|
|
1089
1474
|
scripts: i,
|
|
1090
1475
|
styles: s,
|
|
1091
1476
|
title: a
|
|
1092
1477
|
});
|
|
1093
1478
|
}
|
|
1094
|
-
async function
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
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
|
|
1098
1483
|
);
|
|
1099
|
-
await
|
|
1484
|
+
await dt({ outputFile: o, routesDir: r });
|
|
1100
1485
|
}
|
|
1101
|
-
function
|
|
1102
|
-
return
|
|
1486
|
+
function J(e, t) {
|
|
1487
|
+
return t.startsWith(e) && /\.tsx?$/.test(t);
|
|
1103
1488
|
}
|
|
1104
|
-
async function
|
|
1105
|
-
const
|
|
1106
|
-
for (const
|
|
1107
|
-
const i =
|
|
1108
|
-
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);
|
|
1109
1494
|
}
|
|
1110
1495
|
return o;
|
|
1111
1496
|
}
|
|
1112
|
-
async function
|
|
1113
|
-
const o = new URL(
|
|
1114
|
-
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";
|
|
1115
1500
|
}
|
|
1116
|
-
async function
|
|
1117
|
-
return (await
|
|
1501
|
+
async function ie(e) {
|
|
1502
|
+
return (await De(e, {
|
|
1118
1503
|
recursive: !0,
|
|
1119
1504
|
withFileTypes: !0
|
|
1120
|
-
})).filter((
|
|
1505
|
+
})).filter((r) => r.isFile() && /\.tsx?$/.test(r.name)).map((r) => b(r.parentPath, r.name));
|
|
1121
1506
|
}
|
|
1122
|
-
const
|
|
1123
|
-
async function
|
|
1124
|
-
const o = new Array(
|
|
1125
|
-
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;
|
|
1126
1511
|
const i = Array.from(
|
|
1127
|
-
{ length: Math.min(
|
|
1512
|
+
{ length: Math.min(t, e.length) },
|
|
1128
1513
|
async () => {
|
|
1129
|
-
for (;
|
|
1130
|
-
const s =
|
|
1131
|
-
o[s] = await
|
|
1514
|
+
for (; n < e.length; ) {
|
|
1515
|
+
const s = n++;
|
|
1516
|
+
o[s] = await r(e[s]);
|
|
1132
1517
|
}
|
|
1133
1518
|
}
|
|
1134
1519
|
);
|
|
1135
1520
|
return await Promise.all(i), o;
|
|
1136
1521
|
}
|
|
1137
|
-
async function
|
|
1138
|
-
const
|
|
1139
|
-
return
|
|
1140
|
-
await
|
|
1141
|
-
|
|
1142
|
-
|
|
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
|
|
1143
1528
|
)).flat().sort(
|
|
1144
|
-
(
|
|
1529
|
+
(n, i) => n.file.localeCompare(i.file) || (n.exportName ?? "").localeCompare(i.exportName ?? "") || n.code.localeCompare(i.code)
|
|
1145
1530
|
) : [];
|
|
1146
1531
|
}
|
|
1147
|
-
function
|
|
1532
|
+
function _r(e) {
|
|
1148
1533
|
return [
|
|
1149
1534
|
"Demiurge found invalid static route policy:",
|
|
1150
|
-
...
|
|
1535
|
+
...e.map(Le)
|
|
1151
1536
|
].join(`
|
|
1152
1537
|
`);
|
|
1153
1538
|
}
|
|
1154
|
-
function
|
|
1155
|
-
return `${
|
|
1539
|
+
function Le(e) {
|
|
1540
|
+
return `${e.exportName ? `${e.file} export ${e.exportName}` : e.file}: [${e.code}] ${e.message}`;
|
|
1156
1541
|
}
|
|
1157
|
-
function
|
|
1158
|
-
return `./routes/${
|
|
1542
|
+
function Fr(e, t) {
|
|
1543
|
+
return `./routes/${N(e, t).split(O).join("/")}`;
|
|
1159
1544
|
}
|
|
1160
1545
|
export {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
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
|
|
1173
1562
|
};
|
|
1174
1563
|
//# sourceMappingURL=index.js.map
|