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