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