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