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