@demiurgejs/core 0.2.0-beta.2 → 0.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/adapter/testing.js.map +1 -1
  2. package/dist/browser/file-router.d.ts.map +1 -1
  3. package/dist/chunks/{document-shell-D1xo6cEA.js → document-shell-WoM8yZlR.js} +2 -2
  4. package/dist/chunks/{document-shell-D1xo6cEA.js.map → document-shell-WoM8yZlR.js.map} +1 -1
  5. package/dist/chunks/{image-codec-BGTx_t5K.js → image-codec-Di53WpcH.js} +2 -2
  6. package/dist/chunks/{image-codec-BGTx_t5K.js.map → image-codec-Di53WpcH.js.map} +1 -1
  7. package/dist/chunks/{images-B9MqcjSA.js → images-Edar3eU1.js} +2 -2
  8. package/dist/chunks/{images-B9MqcjSA.js.map → images-Edar3eU1.js.map} +1 -1
  9. package/dist/chunks/{request-metadata-D5NrT8ks.js → request-metadata-DaIYq4Ea.js} +214 -179
  10. package/dist/chunks/request-metadata-DaIYq4Ea.js.map +1 -0
  11. package/dist/chunks/{streaming-BQ1bykDo.js → streaming-D0fGAuiO.js} +5 -5
  12. package/dist/chunks/streaming-D0fGAuiO.js.map +1 -0
  13. package/dist/chunks/{testing-B_iMFYz_.js → testing-CRflAw4X.js} +1228 -1074
  14. package/dist/chunks/testing-CRflAw4X.js.map +1 -0
  15. package/dist/data/cache.d.ts +8 -0
  16. package/dist/data/cache.d.ts.map +1 -1
  17. package/dist/data/idempotency.d.ts.map +1 -1
  18. package/dist/data/index.d.ts +3 -1
  19. package/dist/data/index.d.ts.map +1 -1
  20. package/dist/data/testing.d.ts.map +1 -1
  21. package/dist/data/testing.js +94 -72
  22. package/dist/data/testing.js.map +1 -1
  23. package/dist/data/tiered.d.ts +7 -0
  24. package/dist/data/tiered.d.ts.map +1 -0
  25. package/dist/document/deferred-scripts.d.ts.map +1 -1
  26. package/dist/document/hydration.d.ts.map +1 -1
  27. package/dist/document/index.d.ts +1 -0
  28. package/dist/document/index.d.ts.map +1 -1
  29. package/dist/document/trusted-types.d.ts +10 -0
  30. package/dist/document/trusted-types.d.ts.map +1 -0
  31. package/dist/edge/index.js +3 -3
  32. package/dist/index.d.ts +6 -6
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +768 -432
  35. package/dist/index.js.map +1 -1
  36. package/dist/internal/testing.js +9 -9
  37. package/dist/kv/index.d.ts +2 -0
  38. package/dist/kv/index.d.ts.map +1 -1
  39. package/dist/kv/index.js +71 -48
  40. package/dist/kv/index.js.map +1 -1
  41. package/dist/kv/rate-limit-store.d.ts +8 -0
  42. package/dist/kv/rate-limit-store.d.ts.map +1 -0
  43. package/dist/kv/store.d.ts.map +1 -1
  44. package/dist/node/http.d.ts.map +1 -1
  45. package/dist/node/image.d.ts.map +1 -1
  46. package/dist/node/index.d.ts.map +1 -1
  47. package/dist/node/index.js +3 -3
  48. package/dist/node/index.js.map +1 -1
  49. package/dist/node/static.d.ts.map +1 -1
  50. package/dist/node/streaming.d.ts.map +1 -1
  51. package/dist/platform/images.d.ts.map +1 -1
  52. package/dist/platform/index.d.ts +5 -1
  53. package/dist/platform/index.d.ts.map +1 -1
  54. package/dist/platform/observability.d.ts +2 -1
  55. package/dist/platform/observability.d.ts.map +1 -1
  56. package/dist/platform/web-vitals-client.d.ts +32 -0
  57. package/dist/platform/web-vitals-client.d.ts.map +1 -0
  58. package/dist/platform/web-vitals.d.ts +78 -0
  59. package/dist/platform/web-vitals.d.ts.map +1 -0
  60. package/dist/redis/index.d.ts +2 -0
  61. package/dist/redis/index.d.ts.map +1 -1
  62. package/dist/redis/index.js +84 -46
  63. package/dist/redis/index.js.map +1 -1
  64. package/dist/redis/rate-limit-store.d.ts +8 -0
  65. package/dist/redis/rate-limit-store.d.ts.map +1 -0
  66. package/dist/redis/store.d.ts.map +1 -1
  67. package/dist/route/action.d.ts.map +1 -1
  68. package/dist/route/middleware.d.ts.map +1 -1
  69. package/dist/route/response.d.ts.map +1 -1
  70. package/dist/router/index.d.ts +1 -1
  71. package/dist/router/index.d.ts.map +1 -1
  72. package/dist/router/manifest.d.ts +1 -0
  73. package/dist/router/manifest.d.ts.map +1 -1
  74. package/dist/security/cookies.d.ts +26 -0
  75. package/dist/security/cookies.d.ts.map +1 -0
  76. package/dist/security/env.d.ts.map +1 -1
  77. package/dist/security/fetch-metadata.d.ts +29 -0
  78. package/dist/security/fetch-metadata.d.ts.map +1 -0
  79. package/dist/security/index.d.ts +5 -1
  80. package/dist/security/index.d.ts.map +1 -1
  81. package/dist/security/policy.d.ts.map +1 -1
  82. package/dist/security/rate-limit.d.ts +6 -3
  83. package/dist/security/rate-limit.d.ts.map +1 -1
  84. package/dist/security/request.d.ts.map +1 -1
  85. package/dist/security/types.d.ts +72 -3
  86. package/dist/security/types.d.ts.map +1 -1
  87. package/dist/server/index.d.ts +1 -1
  88. package/dist/server/index.d.ts.map +1 -1
  89. package/dist/server/request-handler.d.ts +6 -2
  90. package/dist/server/request-handler.d.ts.map +1 -1
  91. package/dist/static/index.d.ts.map +1 -1
  92. package/dist/static/index.js +4 -4
  93. package/dist/static/index.js.map +1 -1
  94. package/dist/vite/index.d.ts +3 -0
  95. package/dist/vite/index.d.ts.map +1 -1
  96. package/dist/vite/index.js +1030 -666
  97. package/dist/vite/index.js.map +1 -1
  98. package/dist/vite/plugin.d.ts +2 -0
  99. package/dist/vite/plugin.d.ts.map +1 -1
  100. package/dist/vite/policy-verification.d.ts.map +1 -1
  101. package/dist/vite/route-audit.d.ts +50 -0
  102. package/dist/vite/route-audit.d.ts.map +1 -0
  103. package/package.json +1 -1
  104. package/dist/chunks/request-metadata-D5NrT8ks.js.map +0 -1
  105. package/dist/chunks/streaming-BQ1bykDo.js.map +0 -1
  106. package/dist/chunks/testing-B_iMFYz_.js.map +0 -1
@@ -1,79 +1,79 @@
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";
1
+ import { existsSync as re } from "node:fs";
2
+ import { mkdir as Ve, writeFile as We, readdir as De, readFile as Pe } from "node:fs/promises";
3
+ import { dirname as ne, resolve as b, relative as N, sep as O, join as He } from "node:path";
4
+ import Ue from "magic-string";
5
+ import { transformWithEsbuild as Je, parseAst as oe } from "vite";
6
+ import { e as qe, f as ze } from "../chunks/request-metadata-DaIYq4Ea.js";
7
+ import { v as Ge, f as Be, g as Ke, s as U, l as se, i as Ye, j as Q, t as Qe, k as Xe, n as Oe, M as Ze, o as et, p as z, q as ae, u as tt, w as rt, x as nt, r as ot, h as it, y as st } from "../chunks/testing-CRflAw4X.js";
8
8
  import "react";
9
9
  import "react-dom/server";
10
10
  import "react/jsx-runtime";
11
- import { 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), {
11
+ import { c as at, t as ce, U as ue, w as le, b as k, d as ct, e as ut } from "../chunks/streaming-D0fGAuiO.js";
12
+ import { p as lt } from "../chunks/images-Edar3eU1.js";
13
+ const P = "@demiurgejs/core";
14
+ async function dt(e) {
15
+ const t = await ft(e.routesDir), r = t.map((i) => mt(e, i)).filter((i) => !!i), o = t.map((i) => pt(e.routesDir, i, r)).filter((i) => !!i).sort((i, s) => i.pattern.localeCompare(s.pattern)), n = ht(o, r);
16
+ return await Ve(ne(e.outputFile), { recursive: !0 }), await We(e.outputFile, n), {
17
17
  routes: o,
18
- source: r
18
+ source: n
19
19
  };
20
20
  }
21
- async function Bt(t) {
22
- return (await ht(t, {
21
+ async function ft(e) {
22
+ return (await De(e, {
23
23
  recursive: !0,
24
24
  withFileTypes: !0
25
- })).filter((n) => n.isFile() && /\.tsx?$/.test(n.name)).map((n) => w(n.parentPath, n.name));
25
+ })).filter((r) => r.isFile() && /\.tsx?$/.test(r.name)).map((r) => b(r.parentPath, r.name));
26
26
  }
27
- function Ut(t, e, n) {
28
- const r = R(t, e).split(S).join("/").replace(/\.tsx?$/, "").split("/");
29
- if (r.at(-1)?.startsWith("@"))
27
+ function pt(e, t, r) {
28
+ const n = N(e, t).split(O).join("/").replace(/\.tsx?$/, "").split("/");
29
+ if (n.at(-1)?.startsWith("@"))
30
30
  return null;
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
+ const s = n.flatMap((c) => de(c) ? [] : c === "index" ? [] : c.startsWith("[...") && c.endsWith("]") ? [c] : c.startsWith("[") && c.endsWith("]") ? [c] : [c]), a = n.flatMap((c) => de(c) ? [] : c.startsWith("[...") && c.endsWith("]") ? [c.slice(4, -1)] : c.startsWith("[") && c.endsWith("]") ? [c.slice(1, -1)] : []);
32
32
  return {
33
- contextMiddleware: n.filter((c) => Gt(c.fileSegments, r)).map((c) => n.indexOf(c)),
34
- fileSegments: r,
33
+ contextMiddleware: r.filter((c) => yt(c.fileSegments, n)).map((c) => r.indexOf(c)),
34
+ fileSegments: n,
35
35
  pathVars: a,
36
36
  pattern: `/${s.join("/")}`.replace(/\/$/, "") || "/"
37
37
  };
38
38
  }
39
- function zt(t, e) {
40
- const o = R(t.routesDir, e).split(S).join("/").replace(/\.tsx?$/, "").split("/");
39
+ function mt(e, t) {
40
+ const o = N(e.routesDir, t).split(O).join("/").replace(/\.tsx?$/, "").split("/");
41
41
  if (o.at(-1) !== "@middleware")
42
42
  return null;
43
- let r = R(q(t.outputFile), e).split(S).join("/").replace(/\.tsx?$/, "");
44
- return r.startsWith(".") || (r = `./${r}`), { file: e, fileSegments: o.slice(0, -1), importPath: r };
43
+ let n = N(ne(e.outputFile), t).split(O).join("/").replace(/\.tsx?$/, "");
44
+ return n.startsWith(".") || (n = `./${n}`), { file: t, fileSegments: o.slice(0, -1), importPath: n };
45
45
  }
46
- function Gt(t, e) {
47
- return t.every(
48
- (n, o) => e[o] === n
46
+ function yt(e, t) {
47
+ return e.every(
48
+ (r, o) => t[o] === r
49
49
  );
50
50
  }
51
- function et(t) {
52
- return t.startsWith("(") && t.endsWith(")");
51
+ function de(e) {
52
+ return e.startsWith("(") && e.endsWith(")");
53
53
  }
54
- function qt(t, e) {
54
+ function ht(e, t) {
55
55
  return `// Generated by Demiurge. Do not edit by hand.
56
- import "${$}";
57
- import type { MiddlewareContextOf, PathValue } from "${$}";
58
- ${e.map(Yt).join(`
56
+ import "${P}";
57
+ import type { MiddlewareContextOf, PathValue } from "${P}";
58
+ ${t.map(gt).join(`
59
59
  `)}
60
60
 
61
- ${e.map((n, o) => Kt(o)).join(`
61
+ ${t.map((r, o) => wt(o)).join(`
62
62
  `)}
63
63
 
64
- declare module "${$}" {
64
+ declare module "${P}" {
65
65
  interface RoutePathVars {
66
- ${t.map(Qt).join(`
66
+ ${e.map(Rt).join(`
67
67
  `)}
68
68
  }
69
69
 
70
70
  interface RouteConcretePaths {
71
- ${t.map(Xt).join(`
71
+ ${e.map(vt).join(`
72
72
  `)}
73
73
  }
74
74
 
75
75
  interface RouteRequestContexts {
76
- ${t.map(Zt).join(`
76
+ ${e.map(bt).join(`
77
77
  `)}
78
78
  }
79
79
  }
@@ -81,32 +81,32 @@ ${t.map(Zt).join(`
81
81
  export {};
82
82
  `;
83
83
  }
84
- function Yt(t, e) {
85
- return `type __DemiurgeMiddleware${e} = typeof import(${JSON.stringify(t.importPath)}) extends { middleware?: infer T } ? T : never;`;
84
+ function gt(e, t) {
85
+ return `type __DemiurgeMiddleware${t} = typeof import(${JSON.stringify(e.importPath)}) extends { middleware?: infer T } ? T : never;`;
86
86
  }
87
- function Kt(t) {
88
- return `type __DemiurgeMiddlewareContext${t} = MiddlewareContextOf<__DemiurgeMiddleware${t}>;`;
87
+ function wt(e) {
88
+ return `type __DemiurgeMiddlewareContext${e} = MiddlewareContextOf<__DemiurgeMiddleware${e}>;`;
89
89
  }
90
- function Qt(t) {
91
- if (t.pathVars.length === 0)
92
- return ` ${JSON.stringify(t.pattern)}: {};`;
93
- const e = t.pathVars.map((n) => `${n}: PathValue`).join("; ");
94
- return ` ${JSON.stringify(t.pattern)}: { ${e} };`;
90
+ function Rt(e) {
91
+ if (e.pathVars.length === 0)
92
+ return ` ${JSON.stringify(e.pattern)}: {};`;
93
+ const t = e.pathVars.map((r) => `${r}: PathValue`).join("; ");
94
+ return ` ${JSON.stringify(e.pattern)}: { ${t} };`;
95
95
  }
96
- function Xt(t) {
97
- return ` ${JSON.stringify(t.pattern)}: ${te(t.pattern)};`;
96
+ function vt(e) {
97
+ return ` ${JSON.stringify(e.pattern)}: ${$t(e.pattern)};`;
98
98
  }
99
- function Zt(t) {
100
- const e = t.contextMiddleware.map((o) => `__DemiurgeMiddlewareContext${o}`), n = e.length > 0 ? e.join(" & ") : "Record<never, never>";
101
- return ` ${JSON.stringify(t.pattern)}: ${n};`;
99
+ function bt(e) {
100
+ const t = e.contextMiddleware.map((o) => `__DemiurgeMiddlewareContext${o}`), r = t.length > 0 ? t.join(" & ") : "Record<never, never>";
101
+ return ` ${JSON.stringify(e.pattern)}: ${r};`;
102
102
  }
103
- function te(t) {
104
- return t.includes("[") ? `\`${t.split(/(\[\.\.\.[^\]]+\]|\[[^\]]+\])/g).filter(Boolean).map((n) => n.startsWith("[") ? "${PathValue}" : ee(n)).join("")}\`` : JSON.stringify(t);
103
+ function $t(e) {
104
+ return e.includes("[") ? `\`${e.split(/(\[\.\.\.[^\]]+\]|\[[^\]]+\])/g).filter(Boolean).map((r) => r.startsWith("[") ? "${PathValue}" : St(r)).join("")}\`` : JSON.stringify(e);
105
105
  }
106
- function ee(t) {
107
- return t.replace(/[`$\\]/g, "\\$&");
106
+ function St(e) {
107
+ return e.replace(/[`$\\]/g, "\\$&");
108
108
  }
109
- const re = [
109
+ const xt = [
110
110
  "GET",
111
111
  "POST",
112
112
  "PUT",
@@ -114,7 +114,7 @@ const re = [
114
114
  "DELETE",
115
115
  "OPTIONS",
116
116
  "HEAD"
117
- ], ne = /* @__PURE__ */ new Set([
117
+ ], Et = /* @__PURE__ */ new Set([
118
118
  "action",
119
119
  "html",
120
120
  "json",
@@ -126,326 +126,671 @@ const re = [
126
126
  "stream",
127
127
  "text"
128
128
  ]);
129
- async function oe(t) {
130
- const e = await gt(t, "utf8");
131
- return await ie(e, t);
129
+ async function Nt(e) {
130
+ const t = await Pe(e, "utf8");
131
+ return await Dt(t, e);
132
132
  }
133
- async function ie(t, e) {
134
- const n = e.endsWith(".tsx") ? "tsx" : "ts", o = await Ot(t, e, {
133
+ async function Dt(e, t) {
134
+ const r = t.endsWith(".tsx") ? "tsx" : "ts", o = await Je(e, t, {
135
135
  format: "esm",
136
- loader: n,
136
+ loader: r,
137
137
  target: "esnext"
138
- }), r = se(o.code);
139
- return fe(r, e);
138
+ }), n = Pt(o.code);
139
+ return Ct(n, t);
140
140
  }
141
- function se(t) {
142
- const e = Y(t), n = pe(e), o = me(e), r = ae(e), i = ce(e), s = {}, a = /* @__PURE__ */ new Set();
141
+ function Pt(e) {
142
+ const t = oe(e), r = jt(t), o = _t(t), n = Ot(t), i = Mt(t), s = {}, a = /* @__PURE__ */ new Set();
143
143
  let c;
144
- for (const [u, f] of i) {
145
- const g = r.get(f);
144
+ for (const [u, d] of i) {
145
+ const h = n.get(d);
146
146
  if (u === "policy") {
147
- g && (c = wt(g, n, o));
147
+ h && (c = Me(h, r, o));
148
148
  continue;
149
149
  }
150
- if (!ye(u) || (a.add(u), !g)) continue;
151
- const l = ue(g, n, o);
152
- l && (s[u] = l);
150
+ if (!Ft(u) || (a.add(u), !h)) continue;
151
+ const D = Tt(h, r, o);
152
+ D && (s[u] = D);
153
153
  }
154
154
  return { capabilities: s, declaredMethods: a, policy: c };
155
155
  }
156
- function ae(t) {
157
- const e = /* @__PURE__ */ new Map();
158
- for (const n of d(t.body)) {
159
- const o = n.type === "ExportNamedDeclaration" ? h(n.declaration) : n;
156
+ function Ot(e) {
157
+ const t = /* @__PURE__ */ new Map();
158
+ for (const r of y(e.body)) {
159
+ const o = r.type === "ExportNamedDeclaration" ? R(r.declaration) : r;
160
160
  if (o?.type === "VariableDeclaration")
161
- for (const r of d(o.declarations)) {
162
- const i = D(r.id), s = h(r.init);
163
- i && s && e.set(i, s);
161
+ for (const n of y(o.declarations)) {
162
+ const i = T(n.id), s = R(n.init);
163
+ i && s && t.set(i, s);
164
164
  }
165
165
  }
166
- return e;
166
+ return t;
167
167
  }
168
- function ce(t) {
169
- const e = /* @__PURE__ */ new Map();
170
- for (const n of d(t.body)) {
171
- if (n.type !== "ExportNamedDeclaration") continue;
172
- const o = h(n.declaration);
168
+ function Mt(e) {
169
+ const t = /* @__PURE__ */ new Map();
170
+ for (const r of y(e.body)) {
171
+ if (r.type !== "ExportNamedDeclaration") continue;
172
+ const o = R(r.declaration);
173
173
  if (o?.type === "VariableDeclaration")
174
- for (const r of d(o.declarations)) {
175
- const i = D(r.id);
176
- i && e.set(i, i);
174
+ for (const n of y(o.declarations)) {
175
+ const i = T(n.id);
176
+ i && t.set(i, i);
177
177
  }
178
- for (const r of d(n.specifiers)) {
179
- const i = E(r.exported), s = E(r.local);
180
- i && s && e.set(i, s);
178
+ for (const n of y(r.specifiers)) {
179
+ const i = M(n.exported), s = M(n.local);
180
+ i && s && t.set(i, s);
181
181
  }
182
182
  }
183
- return e;
183
+ return t;
184
184
  }
185
- function ue(t, e, n) {
186
- if (t.type !== "CallExpression") return;
187
- const o = D(t.callee), r = o ? e.get(o) : void 0;
188
- if (!r || !ne.has(r)) return;
189
- const i = d(t.arguments), s = r === "action" ? i[0] : i[1];
185
+ function Tt(e, t, r) {
186
+ if (e.type !== "CallExpression") return;
187
+ const o = T(e.callee), n = o ? t.get(o) : void 0;
188
+ if (!n || !Et.has(n)) return;
189
+ const i = y(e.arguments), s = n === "action" ? i[0] : i[1];
190
190
  if (!s) return {};
191
- const a = rt(s, "cors", n), c = rt(
191
+ const a = fe(s, "cors", r), c = fe(
192
192
  s,
193
193
  "security",
194
- n
194
+ r
195
195
  );
196
196
  return {
197
- cors: P(a) ? a : void 0,
198
- security: P(c) ? c : void 0
197
+ cors: I(a) ? a : void 0,
198
+ security: I(c) ? c : void 0
199
199
  };
200
200
  }
201
- function rt(t, e, n) {
202
- if (t.type === "Identifier") {
203
- const r = n.get(String(t.name));
204
- return P(r) ? r[e] : m;
201
+ function fe(e, t, r) {
202
+ if (e.type === "Identifier") {
203
+ const n = r.get(String(e.name));
204
+ return I(n) ? n[t] : g;
205
205
  }
206
- if (t.type !== "ObjectExpression") return m;
206
+ if (e.type !== "ObjectExpression") return g;
207
207
  let o;
208
- for (const r of d(t.properties)) {
209
- if (r.type !== "Property" || r.computed) return m;
210
- E(r.key) === e && (o = b(h(r.value), n));
208
+ for (const n of y(e.properties)) {
209
+ if (n.type !== "Property" || n.computed) return g;
210
+ M(n.key) === t && (o = x(R(n.value), r));
211
211
  }
212
212
  return o;
213
213
  }
214
- function wt(t, e, n) {
215
- if (t.type === "CallExpression") {
216
- const r = D(t.callee);
217
- if (r && e.get(r) === "defineRoutePolicy") {
218
- const i = d(t.arguments)[0];
219
- return i ? wt(i, e, n) : void 0;
214
+ function Me(e, t, r) {
215
+ if (e.type === "CallExpression") {
216
+ const n = T(e.callee);
217
+ if (n && t.get(n) === "defineRoutePolicy") {
218
+ const i = y(e.arguments)[0];
219
+ return i ? Me(i, t, r) : void 0;
220
220
  }
221
221
  }
222
- if (t.type !== "ObjectExpression") {
223
- const r = b(t, n);
224
- return P(r) ? r : void 0;
222
+ if (e.type !== "ObjectExpression") {
223
+ const n = x(e, r);
224
+ return I(n) ? n : void 0;
225
225
  }
226
226
  const o = {};
227
- for (const r of d(t.properties)) {
228
- if (r.type !== "Property" || r.computed) return;
229
- const i = E(r.key), s = h(r.value);
227
+ for (const n of y(e.properties)) {
228
+ if (n.type !== "Property" || n.computed) return;
229
+ const i = M(n.key), s = R(n.value);
230
230
  if (!i || !s) return;
231
231
  if (i === "document") {
232
- const c = le(s, e, n);
232
+ const c = At(s, t, r);
233
233
  if (!c) return;
234
234
  o.document = c;
235
235
  continue;
236
236
  }
237
- const a = b(s, n);
238
- if (a === m) return;
237
+ const a = x(s, r);
238
+ if (a === g) return;
239
239
  o[i] = a;
240
240
  }
241
241
  return o;
242
242
  }
243
- function le(t, e, n) {
244
- if (t.type !== "CallExpression") {
245
- const a = b(t, n);
246
- return P(a) ? a : void 0;
243
+ function At(e, t, r) {
244
+ if (e.type !== "CallExpression") {
245
+ const a = x(e, r);
246
+ return I(a) ? a : void 0;
247
247
  }
248
- const o = h(t.callee);
248
+ const o = R(e.callee);
249
249
  if (o?.type !== "MemberExpression") return;
250
- const r = D(o.object), i = E(o.property);
251
- if (!r || e.get(r) !== "security" || !i)
250
+ const n = T(o.object), i = M(o.property);
251
+ if (!n || t.get(n) !== "security" || !i)
252
252
  return;
253
- const s = b(d(t.arguments)[0], n);
254
- if (!(s !== m && s !== void 0 && !P(s))) {
255
- if (i === "api") return F.api(s);
253
+ const s = x(y(e.arguments)[0], r);
254
+ if (!(s !== g && s !== void 0 && !I(s))) {
255
+ if (i === "api")
256
+ return U.api(s);
256
257
  if (i === "crossOriginIsolated")
257
- return F.crossOriginIsolated(s);
258
- if (i === "static") return F.static(s);
259
- if (i === "strict") return F.strict(s);
258
+ return U.crossOriginIsolated(s);
259
+ if (i === "static")
260
+ return U.static(s);
261
+ if (i === "strict")
262
+ return U.strict(s);
260
263
  }
261
264
  }
262
- function fe(t, e) {
263
- const n = [], o = new Set(t.declaredMethods);
265
+ function Ct(e, t) {
266
+ const r = [], o = new Set(e.declaredMethods);
264
267
  o.has("GET") && o.add("HEAD"), o.add("OPTIONS");
265
- for (const [r, i] of Object.entries(
266
- t.capabilities
268
+ for (const [n, i] of Object.entries(
269
+ e.capabilities
267
270
  )) {
268
271
  if (i.cors) {
269
272
  try {
270
- _t(i.cors);
273
+ Ge(i.cors);
271
274
  } catch (s) {
272
- n.push(V(
275
+ r.push(q(
273
276
  "cors-invalid",
274
- e,
275
- U(s, "The CORS policy is invalid."),
276
- r
277
+ t,
278
+ ee(s, "The CORS policy is invalid."),
279
+ n
277
280
  ));
278
281
  }
279
282
  for (const s of i.cors.methods ?? [])
280
- o.has(s) || n.push(V(
283
+ o.has(s) || r.push(q(
281
284
  "cors-method-unavailable",
282
- e,
285
+ t,
283
286
  `CORS method ${s} is not available from this route.`,
284
- r
287
+ n
285
288
  ));
286
289
  }
287
- nt(i.security, e, r, n);
290
+ pe(i.security, t, n, r);
288
291
  }
289
- if (nt(t.policy?.security, e, void 0, n), t.policy?.document)
292
+ if (pe(e.policy?.security, t, void 0, r), e.policy?.document)
290
293
  try {
291
- Ct(de(t.policy.document), {
294
+ Be(It(e.policy.document), {
292
295
  nonce: "build-verification-nonce"
293
296
  });
294
- } catch (r) {
295
- n.push(V(
297
+ } catch (n) {
298
+ r.push(q(
296
299
  "security-header-render-failed",
297
- e,
298
- U(r, "The security headers are invalid.")
300
+ t,
301
+ ee(n, "The security headers are invalid.")
299
302
  ));
300
303
  }
301
- return n;
304
+ return r;
302
305
  }
303
- function de(t) {
304
- const e = t.headers?.reportingEndpoints, n = !!(e && Object.keys(e).length), o = t.csp === !1 ? void 0 : t.csp?.reportTo;
305
- return n || !o ? t : {
306
- ...t,
307
- csp: { ...t.csp, reportTo: void 0 },
308
- headers: e ? { ...t.headers, reportingEndpoints: void 0 } : t.headers
306
+ function It(e) {
307
+ const t = e.headers?.reportingEndpoints, r = !!(t && Object.keys(t).length), o = e.csp === !1 ? void 0 : e.csp?.reportTo;
308
+ return r || !o ? e : {
309
+ ...e,
310
+ csp: { ...e.csp, reportTo: void 0 },
311
+ headers: t ? { ...e.headers, reportingEndpoints: void 0 } : e.headers
309
312
  };
310
313
  }
311
- function nt(t, e, n, o) {
312
- if (t?.rateLimit)
314
+ function pe(e, t, r, o) {
315
+ if (e?.rateLimit)
313
316
  try {
314
- jt(t.rateLimit);
315
- } catch (r) {
316
- o.push(V(
317
+ Ke(e.rateLimit);
318
+ } catch (n) {
319
+ o.push(q(
317
320
  "rate-limit-invalid",
318
- e,
319
- U(r, "The rate limit policy is invalid."),
320
- n
321
+ t,
322
+ ee(n, "The rate limit policy is invalid."),
323
+ r
321
324
  ));
322
325
  }
323
326
  }
324
- function V(t, e, n, o) {
325
- return { code: t, exportName: o, file: e, message: n, severity: "error" };
327
+ function q(e, t, r, o) {
328
+ return { code: e, exportName: o, file: t, message: r, severity: "error" };
326
329
  }
327
- function pe(t) {
328
- const e = /* @__PURE__ */ new Map();
329
- for (const n of d(t.body))
330
- if (!(n.type !== "ImportDeclaration" || h(n.source)?.value !== "@demiurgejs/core"))
331
- for (const o of d(n.specifiers)) {
330
+ function jt(e) {
331
+ const t = /* @__PURE__ */ new Map();
332
+ for (const r of y(e.body))
333
+ if (!(r.type !== "ImportDeclaration" || R(r.source)?.value !== "@demiurgejs/core"))
334
+ for (const o of y(r.specifiers)) {
332
335
  if (o.type !== "ImportSpecifier") continue;
333
- const r = D(o.local), i = E(o.imported);
334
- r && i && e.set(r, i);
336
+ const n = T(o.local), i = M(o.imported);
337
+ n && i && t.set(n, i);
335
338
  }
336
- return e;
339
+ return t;
337
340
  }
338
- function me(t) {
339
- const e = /* @__PURE__ */ new Map();
340
- for (const n of d(t.body)) {
341
- const o = n.type === "ExportNamedDeclaration" ? h(n.declaration) : n;
341
+ function _t(e) {
342
+ const t = /* @__PURE__ */ new Map();
343
+ for (const r of y(e.body)) {
344
+ const o = r.type === "ExportNamedDeclaration" ? R(r.declaration) : r;
342
345
  if (o?.type === "VariableDeclaration")
343
- for (const r of d(o.declarations)) {
344
- const i = D(r.id), s = h(r.init);
346
+ for (const n of y(o.declarations)) {
347
+ const i = T(n.id), s = R(n.init);
345
348
  if (!i || !s) continue;
346
- const a = b(s, e);
347
- a !== m && e.set(i, a);
349
+ const a = x(s, t);
350
+ a !== g && t.set(i, a);
348
351
  }
349
352
  }
350
- return e;
351
- }
352
- const m = Symbol("unresolved");
353
- function b(t, e) {
354
- if (t) {
355
- if (t.type === "Literal") return t.value;
356
- if (t.type === "Identifier")
357
- return t.name === "undefined" ? void 0 : e.has(String(t.name)) ? e.get(String(t.name)) : m;
358
- if (t.type === "TemplateLiteral")
359
- return d(t.expressions).length ? m : d(t.quasis).map((n) => h(n.value)?.cooked ?? "").join("");
360
- if (t.type === "UnaryExpression") {
361
- const n = b(h(t.argument), e);
362
- return typeof n != "number" ? m : t.operator === "-" ? -n : t.operator === "+" ? n : m;
353
+ return t;
354
+ }
355
+ const g = Symbol("unresolved");
356
+ function x(e, t) {
357
+ if (e) {
358
+ if (e.type === "Literal") return e.value;
359
+ if (e.type === "Identifier")
360
+ return e.name === "undefined" ? void 0 : t.has(String(e.name)) ? t.get(String(e.name)) : g;
361
+ if (e.type === "TemplateLiteral")
362
+ return y(e.expressions).length ? g : y(e.quasis).map((r) => R(r.value)?.cooked ?? "").join("");
363
+ if (e.type === "UnaryExpression") {
364
+ const r = x(R(e.argument), t);
365
+ return typeof r != "number" ? g : e.operator === "-" ? -r : e.operator === "+" ? r : g;
366
+ }
367
+ if (e.type === "ArrayExpression") {
368
+ const r = [];
369
+ for (const o of y(e.elements)) {
370
+ const n = x(o, t);
371
+ if (n === g) return g;
372
+ r.push(n);
373
+ }
374
+ return r;
363
375
  }
364
- if (t.type === "ArrayExpression") {
365
- const n = [];
366
- for (const o of d(t.elements)) {
367
- const r = b(o, e);
368
- if (r === m) return m;
369
- n.push(r);
376
+ if (e.type === "ObjectExpression") {
377
+ const r = {};
378
+ for (const o of y(e.properties)) {
379
+ if (o.type !== "Property" || o.computed) return g;
380
+ const n = M(o.key), i = x(R(o.value), t);
381
+ if (!n || i === g) return g;
382
+ r[n] = i;
370
383
  }
371
- return n;
384
+ return r;
372
385
  }
373
- if (t.type === "ObjectExpression") {
374
- const n = {};
375
- for (const o of d(t.properties)) {
376
- if (o.type !== "Property" || o.computed) return m;
377
- const r = E(o.key), i = b(h(o.value), e);
378
- if (!r || i === m) return m;
379
- n[r] = i;
386
+ return g;
387
+ }
388
+ }
389
+ function Ft(e) {
390
+ return xt.includes(e);
391
+ }
392
+ function ee(e, t) {
393
+ return e instanceof Error ? e.message : t;
394
+ }
395
+ function I(e) {
396
+ return !!e && typeof e == "object" && !Array.isArray(e);
397
+ }
398
+ function R(e) {
399
+ return e && typeof e == "object" && "type" in e ? e : void 0;
400
+ }
401
+ function y(e) {
402
+ return Array.isArray(e) ? e.map(R).filter((t) => !!t) : [];
403
+ }
404
+ function T(e) {
405
+ const t = R(e);
406
+ return t?.type === "Identifier" ? String(t.name) : void 0;
407
+ }
408
+ function M(e) {
409
+ const t = R(e);
410
+ return t?.type === "Identifier" || t?.type === "Literal" ? String(t.name ?? t.value) : void 0;
411
+ }
412
+ const Te = "/_demiurge/audit", Ae = [
413
+ "GET",
414
+ "POST",
415
+ "PUT",
416
+ "PATCH",
417
+ "DELETE",
418
+ "OPTIONS",
419
+ "HEAD"
420
+ ];
421
+ function kt(e) {
422
+ return new URL(e.url).pathname === Te;
423
+ }
424
+ async function Lt(e, t) {
425
+ const r = new URL(t.url), o = await Vt(
426
+ e,
427
+ r.searchParams.get("path") || "/",
428
+ t
429
+ ), n = r.searchParams.get("format") === "json";
430
+ return new Response(
431
+ n ? JSON.stringify(o, null, 2) : Jt(o),
432
+ {
433
+ headers: {
434
+ "cache-control": "no-store",
435
+ // The panel is a side channel. It declares its own policy, so the
436
+ // policy of the application stays unchanged. The panel runs no script.
437
+ "content-security-policy": "default-src 'none'; base-uri 'none'; form-action 'self'; style-src 'unsafe-inline'",
438
+ "content-type": n ? "application/json; charset=utf-8" : "text/html; charset=utf-8",
439
+ "x-robots-tag": "noindex"
380
440
  }
381
- return n;
382
441
  }
383
- return m;
442
+ );
443
+ }
444
+ async function Vt(e, t, r) {
445
+ const o = new URL(r.url).origin, n = new URL(t, o), i = n.pathname, s = new Request(n, { headers: r.headers }), a = Wt(e, i);
446
+ if (!a) {
447
+ const p = await se(
448
+ e,
449
+ { fileSegments: [] },
450
+ {},
451
+ void 0
452
+ );
453
+ return me({
454
+ cacheReads: [],
455
+ kind: "unmatched",
456
+ method: "GET",
457
+ pathname: i,
458
+ policy: p,
459
+ request: s,
460
+ scripts: []
461
+ });
462
+ }
463
+ const c = await a.route.load(), u = Ht(c), d = c[u], h = await se(
464
+ e,
465
+ a.route,
466
+ c,
467
+ d
468
+ ), D = [], m = d?.kind === "page" ? await Ye(
469
+ e,
470
+ i,
471
+ s,
472
+ void 0,
473
+ Ut(D)
474
+ ) : void 0, f = m?.status === "ready" ? m.match : void 0;
475
+ return me({
476
+ cacheReads: D,
477
+ cors: d && d.kind !== "page" ? d.cors : void 0,
478
+ kind: d?.kind === "page" ? "page" : "resource",
479
+ metadata: f?.metadata,
480
+ method: u,
481
+ pathname: i,
482
+ policy: h,
483
+ request: s,
484
+ route: {
485
+ file: a.route.file,
486
+ groups: a.route.fileSegments.filter(Xe),
487
+ layouts: e.layouts.filter((p) => Q(p.fileSegments, a.route.fileSegments)).map((p) => p.file),
488
+ methods: Ae.filter((p) => c[p]),
489
+ middlewares: e.middlewares.filter((p) => Q(p.fileSegments, a.route.fileSegments)).map((p) => p.file),
490
+ params: a.path,
491
+ pattern: Qe(a.route.segments),
492
+ policies: e.policies.filter((p) => Q(p.fileSegments, a.route.fileSegments)).map((p) => p.file),
493
+ render: f?.render.mode
494
+ },
495
+ scripts: f?.scripts ?? []
496
+ });
497
+ }
498
+ function me(e) {
499
+ const t = e.kind === "page", r = t && et(e.policy.document) ? z() : void 0, o = e.scripts.map((s) => ({
500
+ ...s,
501
+ nonce: s.nonce ?? r
502
+ })), n = {
503
+ headers: { nonce: r, request: e.request },
504
+ policy: e.policy.document ?? {},
505
+ scriptDependencies: !0
506
+ };
507
+ return {
508
+ audit: ae({
509
+ document: t ? { ...n, scripts: o } : void 0,
510
+ route: {
511
+ cors: e.cors,
512
+ method: e.method,
513
+ security: e.policy.security
514
+ }
515
+ }),
516
+ // A nonce makes a document unique for each response. The request handler
517
+ // therefore replaces the cache directives of the application.
518
+ cacheControl: r ? "private, no-store" : void 0,
519
+ cacheReads: e.cacheReads,
520
+ kind: e.kind,
521
+ metadata: e.metadata,
522
+ method: e.method,
523
+ nonce: r,
524
+ pathname: e.pathname,
525
+ policy: e.policy,
526
+ route: e.route,
527
+ scripts: o.map((s) => ({
528
+ // One audit for each script gives the status of that script alone. The
529
+ // panel reads the same code path that the complete audit reads.
530
+ findings: ae({
531
+ document: { ...n, scripts: [s] }
532
+ }).findings,
533
+ integrity: s.integrity,
534
+ nonce: s.nonce,
535
+ purpose: s.purpose,
536
+ src: s.src,
537
+ strategy: s.strategy
538
+ }))
539
+ };
540
+ }
541
+ function Wt(e, t) {
542
+ try {
543
+ return Oe(e.routes, t);
544
+ } catch (r) {
545
+ if (r instanceof Ze)
546
+ return null;
547
+ throw r;
384
548
  }
385
549
  }
386
- function ye(t) {
387
- return re.includes(t);
550
+ function Ht(e) {
551
+ return Ae.find((t) => e[t]) ?? "GET";
388
552
  }
389
- function U(t, e) {
390
- return t instanceof Error ? t.message : e;
553
+ function Ut(e) {
554
+ const t = tt();
555
+ return {
556
+ get: async (r) => (e.push({
557
+ key: nt(r.key),
558
+ scope: r.scope ?? "request",
559
+ staleWhileRevalidate: ye(r.staleWhileRevalidate),
560
+ tags: (r.tags ?? []).map(rt),
561
+ ttl: ye(r.ttl)
562
+ }), await t.get(r)),
563
+ invalidateKey: t.invalidateKey,
564
+ invalidateTags: t.invalidateTags
565
+ };
566
+ }
567
+ function ye(e) {
568
+ return e === void 0 ? void 0 : String(e);
569
+ }
570
+ function Jt(e) {
571
+ return `<!doctype html>
572
+ <html lang="en">
573
+ <head>
574
+ <meta charset="utf-8" />
575
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
576
+ <title>Demiurge route audit</title>
577
+ <style>${qt}</style>
578
+ </head>
579
+ <body>
580
+ <h1>Demiurge route audit</h1>
581
+ <form method="get" action="${Te}">
582
+ <label for="path">Path</label>
583
+ <input id="path" name="path" value="${l(e.pathname)}" />
584
+ <button type="submit">Audit</button>
585
+ </form>
586
+ ${zt(e)}
587
+ ${Gt(e.audit.findings)}
588
+ ${Bt(e.audit.headers)}
589
+ ${Kt(e)}
590
+ ${Yt(e.metadata)}
591
+ ${Qt(e.scripts)}
592
+ ${Xt(e)}
593
+ <p class="footer">
594
+ The development server serves this panel. A production build and a static
595
+ export do not contain it.
596
+ </p>
597
+ </body>
598
+ </html>
599
+ `;
600
+ }
601
+ const qt = `
602
+ :root { color-scheme: light dark; }
603
+ body {
604
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
605
+ line-height: 1.5;
606
+ margin: 0 auto;
607
+ max-width: 60rem;
608
+ padding: 2rem 1rem;
609
+ }
610
+ h1 { font-size: 1.25rem; }
611
+ h2 { font-size: 1rem; margin-bottom: 0.25rem; }
612
+ form { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
613
+ input { flex: 1; padding: 0.25rem 0.5rem; }
614
+ section { border-top: 1px solid currentColor; padding: 0.75rem 0; }
615
+ table { border-collapse: collapse; width: 100%; }
616
+ td, th { padding: 0.25rem 0.5rem 0.25rem 0; text-align: left; vertical-align: top; }
617
+ th { white-space: nowrap; width: 12rem; }
618
+ ul { margin: 0; padding-left: 1.25rem; }
619
+ .empty { opacity: 0.7; }
620
+ .error { font-weight: 700; }
621
+ .footer { opacity: 0.7; }
622
+ `;
623
+ function zt(e) {
624
+ if (!e.route)
625
+ return $(
626
+ "Route",
627
+ `<p class="empty">No route matches ${l(e.pathname)}.</p>`
628
+ );
629
+ const t = e.route;
630
+ return $(
631
+ "Route",
632
+ C([
633
+ ["Pathname", l(e.pathname)],
634
+ ["Pattern", l(t.pattern)],
635
+ ["File", l(t.file)],
636
+ ["Kind", l(e.kind)],
637
+ ["Method", l(e.method)],
638
+ ["Methods", l(t.methods.join(", "))],
639
+ ["Render mode", t.render ? l(t.render) : S()],
640
+ ["Path values", Zt(t.params)],
641
+ ["Route groups", A(t.groups)],
642
+ ["Layouts", A(t.layouts)],
643
+ ["Policies", A(t.policies)],
644
+ ["Middleware", A(t.middlewares)]
645
+ ])
646
+ );
647
+ }
648
+ function Gt(e) {
649
+ return e.length === 0 ? $("Findings", '<p class="empty">No findings.</p>') : $(
650
+ "Findings",
651
+ `<ul>${e.map(Ce).join("")}</ul>`
652
+ );
653
+ }
654
+ function Ce(e) {
655
+ return `<li${e.severity === "error" ? ' class="error"' : ""}>${l(e.severity)}: ${l(e.message)} <code>${l(e.code)}</code></li>`;
656
+ }
657
+ function Bt(e) {
658
+ const t = Object.keys(e).sort();
659
+ return t.length === 0 ? $(
660
+ "Response headers",
661
+ '<p class="empty">The response carries no document header.</p>'
662
+ ) : $(
663
+ "Response headers",
664
+ C(t.map((r) => [r, l(e[r])]))
665
+ );
666
+ }
667
+ function Kt(e) {
668
+ const t = {
669
+ cors: e.audit.route?.cors,
670
+ document: e.policy.document,
671
+ security: e.policy.security
672
+ };
673
+ return $(
674
+ "Effective policy",
675
+ `<pre>${l(JSON.stringify(t, null, 2))}</pre>`
676
+ );
677
+ }
678
+ function Yt(e) {
679
+ return e ? $(
680
+ "Metadata",
681
+ `<pre>${l(JSON.stringify(e, null, 2))}</pre>`
682
+ ) : $("Metadata", '<p class="empty">No document metadata.</p>');
683
+ }
684
+ function Qt(e) {
685
+ return e.length === 0 ? $("Scripts", '<p class="empty">No contributed scripts.</p>') : $(
686
+ "Scripts",
687
+ e.map(
688
+ (t) => C([
689
+ ["Source", l(t.src)],
690
+ ["Strategy", l(t.strategy)],
691
+ ["Purpose", t.purpose ? l(t.purpose) : S()],
692
+ ["Integrity", t.integrity ? l(t.integrity) : S()],
693
+ ["Nonce", t.nonce ? "applied" : S()],
694
+ [
695
+ "Policy status",
696
+ t.findings.length === 0 ? "allowed" : `<ul>${t.findings.map(Ce).join("")}</ul>`
697
+ ]
698
+ ])
699
+ ).join("")
700
+ );
391
701
  }
392
- function P(t) {
393
- return !!t && typeof t == "object" && !Array.isArray(t);
702
+ function Xt(e) {
703
+ const t = [
704
+ [
705
+ "Response cache-control",
706
+ e.cacheControl ? l(e.cacheControl) : S()
707
+ ],
708
+ ["Nonce", e.nonce ? "required" : S()]
709
+ ];
710
+ return e.cacheReads.length === 0 ? $(
711
+ "Cache behavior",
712
+ `${C(t)}<p class="empty">The request read no cache entry.</p>`
713
+ ) : $(
714
+ "Cache behavior",
715
+ `${C(t)}${e.cacheReads.map(
716
+ (r) => C([
717
+ ["Key", l(r.key)],
718
+ ["Scope", l(r.scope)],
719
+ ["Time to live", r.ttl ? l(r.ttl) : S()],
720
+ [
721
+ "Stale while revalidate",
722
+ r.staleWhileRevalidate ? l(r.staleWhileRevalidate) : S()
723
+ ],
724
+ ["Tags", A(r.tags)]
725
+ ])
726
+ ).join("")}`
727
+ );
728
+ }
729
+ function $(e, t) {
730
+ return ` <section>
731
+ <h2>${l(e)}</h2>
732
+ ${t}
733
+ </section>`;
394
734
  }
395
- function h(t) {
396
- return t && typeof t == "object" && "type" in t ? t : void 0;
735
+ function C(e) {
736
+ return `<table><tbody>${e.map(
737
+ ([t, r]) => `<tr><th scope="row">${l(t)}</th><td>${r}</td></tr>`
738
+ ).join("")}</tbody></table>`;
397
739
  }
398
- function d(t) {
399
- return Array.isArray(t) ? t.map(h).filter((e) => !!e) : [];
740
+ function A(e) {
741
+ return e.length === 0 ? S() : `<ul>${e.map((t) => `<li>${l(t)}</li>`).join("")}</ul>`;
400
742
  }
401
- function D(t) {
402
- const e = h(t);
403
- return e?.type === "Identifier" ? String(e.name) : void 0;
743
+ function Zt(e) {
744
+ return A(
745
+ Object.entries(e).map(([t, r]) => `${t} = ${String(r)}`)
746
+ );
404
747
  }
405
- function E(t) {
406
- const e = h(t);
407
- return e?.type === "Identifier" || e?.type === "Literal" ? String(e.name ?? e.value) : void 0;
748
+ function S() {
749
+ return '<span class="empty">none</span>';
408
750
  }
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 = {}) {
411
- let e = process.cwd(), n = !1;
412
- const o = `demiurge-${B()}`;
751
+ function l(e) {
752
+ return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
753
+ }
754
+ const K = "virtual:demiurge/client-entry", te = `/@id/${K}`, X = `\0${K}`, Ie = "virtual:demiurge/server-entry", he = `\0${Ie}`, ge = ".demiurge/route-manifest.d.ts";
755
+ function Yr(e = {}) {
756
+ let t = process.cwd(), r = !1;
757
+ const o = `demiurge-${z()}`;
413
758
  return {
414
759
  api: {
415
760
  demiurge: !0,
416
- fonts: t.fonts,
417
- images: t.images,
418
- staticDeployment: t.static?.deployment,
419
- staticFileHeaders: t.static?.headers
761
+ fonts: e.fonts,
762
+ images: e.images,
763
+ staticDeployment: e.static?.deployment,
764
+ staticFileHeaders: e.static?.headers
420
765
  },
421
766
  enforce: "post",
422
767
  name: "demiurge",
423
- config(r, i) {
424
- return Se(r, i, o);
768
+ config(n, i) {
769
+ return cr(n, i, o);
425
770
  },
426
- configResolved(r) {
427
- e = r.root, n = r.command === "build";
771
+ configResolved(n) {
772
+ t = n.root, r = n.command === "build";
428
773
  },
429
- resolveId(r) {
430
- return r === W ? J : r === vt ? ot : null;
774
+ resolveId(n) {
775
+ return n === K ? X : n === Ie ? he : null;
431
776
  },
432
- load(r) {
433
- return r === J ? Ee(e, t) : r === ot ? De(e, t) : null;
777
+ load(n) {
778
+ return n === X ? ur(t, e) : n === he ? lr(t, e) : null;
434
779
  },
435
780
  transform: {
436
781
  order: "post",
437
- handler(r, i, s) {
438
- if (!ve(e, t, i))
782
+ handler(n, i, s) {
783
+ if (!nr(t, e, i))
439
784
  return null;
440
785
  if (s?.ssr)
441
- return n ? null : he(r, i);
442
- const a = ge(r);
443
- return a === r ? null : { code: a, map: null };
786
+ return r ? null : er(n, i);
787
+ const a = tr(n);
788
+ return a === n ? null : { code: a, map: null };
444
789
  }
445
790
  },
446
- generateBundle(r, i) {
791
+ generateBundle(n, i) {
447
792
  const s = Object.values(i).find(
448
- (u) => u.type === "chunk" && u.isEntry && u.facadeModuleId === J
793
+ (u) => u.type === "chunk" && u.isEntry && u.facadeModuleId === X
449
794
  );
450
795
  if (!s)
451
796
  return;
@@ -454,11 +799,11 @@ function fr(t = {}) {
454
799
  ).map((u) => `/${u.fileName}`), c = `/${s.fileName}`;
455
800
  this.emitFile({
456
801
  fileName: "index.html",
457
- source: Ue({
802
+ source: Mr({
458
803
  entrySrc: c,
459
- lang: t.document?.lang,
804
+ lang: e.document?.lang,
460
805
  styles: a,
461
- title: t.document?.title
806
+ title: e.document?.title
462
807
  }),
463
808
  type: "asset"
464
809
  }), this.emitFile({
@@ -468,19 +813,19 @@ function fr(t = {}) {
468
813
  });
469
814
  },
470
815
  async buildStart() {
471
- if (n) {
472
- await Le(e, t);
473
- const r = await yt(e, t);
474
- if (r.length)
475
- throw new Error(Qe(r));
816
+ if (r) {
817
+ await xr(t, e);
818
+ const n = await Ne(t, e);
819
+ if (n.length)
820
+ throw new Error(_r(n));
476
821
  }
477
- t.typedRoutes && await _(e, t);
822
+ e.typedRoutes && await L(t, e);
478
823
  },
479
- configureServer(r) {
824
+ configureServer(n) {
480
825
  const i = async () => {
481
- const l = await yt(r.config.root, t);
482
- for (const p of l)
483
- r.config.logger.warn(St(p));
826
+ const m = await Ne(n.config.root, e);
827
+ for (const f of m)
828
+ n.config.logger.warn(Le(f));
484
829
  };
485
830
  let s, a = Promise.resolve();
486
831
  const c = () => {
@@ -489,139 +834,151 @@ function fr(t = {}) {
489
834
  }, u = () => {
490
835
  s && clearTimeout(s), s = setTimeout(() => {
491
836
  s = void 0, c();
492
- }, Ye), s.unref?.();
837
+ }, Ir), s.unref?.();
493
838
  };
494
- if (r.httpServer?.once("close", () => {
839
+ if (n.httpServer?.once("close", () => {
495
840
  s && (clearTimeout(s), s = void 0);
496
- }), c(), t.typedRoutes) {
497
- const l = w(
498
- r.config.root,
499
- t.routesDir ?? "src/routes"
841
+ }), c(), e.typedRoutes) {
842
+ const m = b(
843
+ n.config.root,
844
+ e.routesDir ?? "src/routes"
500
845
  );
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());
846
+ L(n.config.root, e), n.watcher.add(m), n.watcher.on("add", (f) => {
847
+ J(m, f) && (L(n.config.root, e), u());
848
+ }), n.watcher.on("change", (f) => {
849
+ J(m, f) && (L(n.config.root, e), u());
850
+ }), n.watcher.on("unlink", (f) => {
851
+ J(m, f) && (L(n.config.root, e), u());
507
852
  });
508
853
  } else {
509
- const l = w(
510
- r.config.root,
511
- t.routesDir ?? "src/routes"
854
+ const m = b(
855
+ n.config.root,
856
+ e.routesDir ?? "src/routes"
512
857
  );
513
- r.watcher.add(l);
514
- for (const p of ["add", "change", "unlink"])
515
- r.watcher.on(p, (N) => {
516
- A(l, N) && u();
858
+ n.watcher.add(m);
859
+ for (const f of ["add", "change", "unlink"])
860
+ n.watcher.on(f, (p) => {
861
+ J(m, p) && u();
517
862
  });
518
863
  }
519
- const f = Ie(r, t), g = Lt({
520
- fonts: t.fonts,
521
- root: r.config.root
864
+ const d = yr(e), h = hr(n, e), D = at({
865
+ fonts: e.fonts,
866
+ root: n.config.root
522
867
  });
523
- return r.middlewares.use(async (l, p, N) => {
868
+ return n.middlewares.use(async (m, f, p) => {
524
869
  try {
525
870
  let v;
526
871
  try {
527
- v = X(l, {
872
+ v = ce(m, {
528
873
  // Vite performs its own configured host allowlist check before
529
874
  // Demiurge's middleware runs. Production Node listeners require
530
875
  // an explicit application allowlist instead.
531
- allowedHosts: [l.headers.host ?? "localhost"]
876
+ allowedHosts: [m.headers.host ?? "localhost"]
532
877
  });
533
- } catch (Q) {
534
- if (Q instanceof Z) {
535
- tt(p);
878
+ } catch (H) {
879
+ if (H instanceof ue) {
880
+ le(f);
536
881
  return;
537
882
  }
538
- throw Q;
883
+ throw H;
884
+ }
885
+ if (d && kt(v)) {
886
+ const H = await Z(
887
+ n,
888
+ m,
889
+ b(n.config.root, e.routesDir ?? "src/routes")
890
+ );
891
+ await k(
892
+ f,
893
+ await Lt(H, v)
894
+ );
895
+ return;
539
896
  }
540
- const O = await g(v);
541
- if (O) {
542
- await T(p, O);
897
+ const j = await D(v);
898
+ if (j) {
899
+ await k(f, j);
543
900
  return;
544
901
  }
545
- const M = await f(v);
546
- if (M) {
547
- await T(p, M);
902
+ const _ = await h(v);
903
+ if (_) {
904
+ await k(f, _);
548
905
  return;
549
906
  }
550
- const C = w(
551
- r.config.root,
552
- t.routesDir ?? "src/routes"
553
- ), j = await dt(r, l, C), I = at(
554
- r,
907
+ const V = b(
908
+ n.config.root,
909
+ e.routesDir ?? "src/routes"
910
+ ), W = await Z(n, m, V), F = Re(
911
+ n,
555
912
  o
556
- ), H = await Ge(
557
- j,
913
+ ), Y = await Ar(
914
+ W,
558
915
  v,
559
- _e(t, I.transform)
916
+ gr(e, F.transform)
560
917
  );
561
- if (H === "next") {
562
- N();
918
+ if (Y === "next") {
919
+ p();
563
920
  return;
564
921
  }
565
- ut(H, I.nonce), await T(p, H);
922
+ be(Y, F.nonce), await k(f, Y);
566
923
  } catch (v) {
567
- N(v);
924
+ p(v);
568
925
  }
569
926
  }), () => {
570
- r.middlewares.use(async (l, p, N) => {
927
+ n.middlewares.use(async (m, f, p) => {
571
928
  try {
572
929
  let v;
573
930
  try {
574
- v = X(l, {
575
- allowedHosts: [l.headers.host ?? "localhost"]
931
+ v = ce(m, {
932
+ allowedHosts: [m.headers.host ?? "localhost"]
576
933
  });
577
- } catch (I) {
578
- if (I instanceof Z) {
579
- tt(p);
934
+ } catch (F) {
935
+ if (F instanceof ue) {
936
+ le(f);
580
937
  return;
581
938
  }
582
- throw I;
939
+ throw F;
583
940
  }
584
- const O = w(
585
- r.config.root,
586
- t.routesDir ?? "src/routes"
587
- ), M = await dt(r, l, O);
588
- Ve(M, O);
589
- const C = at(
590
- r,
941
+ const j = b(
942
+ n.config.root,
943
+ e.routesDir ?? "src/routes"
944
+ ), _ = await Z(n, m, j);
945
+ Sr(_, j);
946
+ const V = Re(
947
+ n,
591
948
  o
592
- ), j = await Ft(
593
- M,
949
+ ), W = await ot(
950
+ _,
594
951
  v,
595
- Ae(t, C.transform)
952
+ $r(e, V.transform)
596
953
  );
597
- ut(
598
- j,
599
- C.nonce
600
- ), await T(p, j);
954
+ be(
955
+ W,
956
+ V.nonce
957
+ ), await k(f, W);
601
958
  } catch (v) {
602
- N(v);
959
+ p(v);
603
960
  }
604
961
  });
605
962
  };
606
963
  }
607
964
  };
608
965
  }
609
- function he(t, e) {
610
- if (!t.includes("import.meta"))
966
+ function er(e, t) {
967
+ if (!e.includes("import.meta"))
611
968
  return null;
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"
969
+ const r = oe(e), o = E(r.body).find(
970
+ (u) => u.type === "ImportDeclaration" && E(u.specifiers).some(
971
+ (d) => w(d.local)?.type === "Identifier" && w(d.local)?.name === "meta"
615
972
  )
616
- ), r = o && x(o.specifiers).find(
617
- (u) => y(u.local)?.type === "Identifier" && y(u.local)?.name === "meta"
618
- ), i = r && y(r.local);
619
- if (!o || !r || !i)
973
+ ), n = o && E(o.specifiers).find(
974
+ (u) => w(u.local)?.type === "Identifier" && w(u.local)?.name === "meta"
975
+ ), i = n && w(n.local);
976
+ if (!o || !n || !i)
620
977
  return null;
621
978
  let s = "__demiurge_imported_meta__";
622
- for (; new RegExp(`\\b${s}\\b`).test(t); )
979
+ for (; new RegExp(`\\b${s}\\b`).test(e); )
623
980
  s += "_";
624
- const a = new Pt(t), c = y(r.imported);
981
+ const a = new Ue(e), c = w(n.imported);
625
982
  return a.overwrite(
626
983
  i.start,
627
984
  i.end,
@@ -632,142 +989,142 @@ const meta = ${s};`), {
632
989
  map: a.generateMap({
633
990
  hires: "boundary",
634
991
  includeContent: !0,
635
- source: e
992
+ source: t
636
993
  })
637
994
  };
638
995
  }
639
- function ge(t) {
640
- const e = Y(t), n = [], o = we(e), r = [];
641
- L(e, (a) => {
642
- if (a.type === "ImportDeclaration" && xe(a)) {
643
- r.push(a);
996
+ function tr(e) {
997
+ const t = oe(e), r = [], o = rr(t), n = [];
998
+ G(t, (a) => {
999
+ if (a.type === "ImportDeclaration" && ir(a)) {
1000
+ n.push(a);
644
1001
  return;
645
1002
  }
646
- if (a.type !== "CallExpression" || !be(a.callee))
1003
+ if (a.type !== "CallExpression" || !or(a.callee))
647
1004
  return;
648
- const c = x(a.arguments)[0];
1005
+ const c = E(a.arguments)[0];
649
1006
  if (c?.type === "ObjectExpression")
650
- for (const u of x(c.properties))
651
- u.type === "Property" && k(u.key) === "data" && n.push({ end: u.end, start: u.start });
1007
+ for (const u of E(c.properties))
1008
+ u.type === "Property" && B(u.key) === "data" && r.push({ end: u.end, start: u.start });
652
1009
  });
653
- const i = [...n, ...o];
1010
+ const i = [...r, ...o];
654
1011
  if (i.length === 0)
655
- return t;
1012
+ return e;
656
1013
  const s = [...i];
657
- for (const a of r) {
658
- const c = x(a.specifiers).map((g) => y(g.local)).filter((g) => g?.type === "Identifier").map((g) => String(g.name)), u = Re(t, [
1014
+ for (const a of n) {
1015
+ const c = E(a.specifiers).map((h) => w(h.local)).filter((h) => h?.type === "Identifier").map((h) => String(h.name)), u = sr(e, [
659
1016
  ...i,
660
1017
  { end: a.end, start: a.start }
661
- ]), f = c.find(
662
- (g) => new RegExp(`\\b${bt(g)}\\b`).test(u)
1018
+ ]), d = c.find(
1019
+ (h) => new RegExp(`\\b${je(h)}\\b`).test(u)
663
1020
  );
664
- if (f)
1021
+ if (d)
665
1022
  throw new Error(
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.`
1023
+ `Server-only import ${JSON.stringify(d)} is used by client route code. Move that use into page data, a document contribution, or a client-safe module.`
667
1024
  );
668
1025
  s.push({ end: a.end, start: a.start });
669
1026
  }
670
- return $e(
671
- t,
1027
+ return ar(
1028
+ e,
672
1029
  s,
673
- (a) => n.includes(a) ? "data: undefined" : o.includes(a) ? "undefined" : ""
1030
+ (a) => r.includes(a) ? "data: undefined" : o.includes(a) ? "undefined" : ""
674
1031
  );
675
1032
  }
676
- const st = /* @__PURE__ */ new Set(["links", "metadata", "scripts"]);
677
- function we(t) {
678
- const e = /* @__PURE__ */ new Set();
679
- for (const o of x(t.body)) {
1033
+ const we = /* @__PURE__ */ new Set(["links", "metadata", "scripts"]);
1034
+ function rr(e) {
1035
+ const t = /* @__PURE__ */ new Set();
1036
+ for (const o of E(e.body)) {
680
1037
  if (o.type !== "ExportNamedDeclaration") continue;
681
- const r = y(o.declaration);
682
- if (r?.type === "VariableDeclaration")
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));
1038
+ const n = w(o.declaration);
1039
+ if (n?.type === "VariableDeclaration")
1040
+ for (const i of E(n.declarations)) {
1041
+ const s = w(i.id);
1042
+ s?.type === "Identifier" && we.has(String(s.name)) && t.add(String(s.name));
686
1043
  }
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);
1044
+ for (const i of E(o.specifiers)) {
1045
+ const s = B(i.exported), a = B(i.local);
1046
+ s && a && we.has(s) && t.add(a);
690
1047
  }
691
1048
  }
692
- const n = [];
693
- return L(t, (o) => {
1049
+ const r = [];
1050
+ return G(e, (o) => {
694
1051
  if (o.type !== "VariableDeclarator") return;
695
- const r = y(o.id), i = y(o.init);
696
- r?.type === "Identifier" && e.has(String(r.name)) && i && n.push({ end: i.end, start: i.start });
697
- }), n;
698
- }
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}`);
702
- }
703
- function L(t, e) {
704
- if (!t || typeof t != "object") return;
705
- if (Array.isArray(t)) {
706
- for (const o of t) L(o, e);
1052
+ const n = w(o.id), i = w(o.init);
1053
+ n?.type === "Identifier" && t.has(String(n.name)) && i && r.push({ end: i.end, start: i.start });
1054
+ }), r;
1055
+ }
1056
+ function nr(e, t, r) {
1057
+ const o = r.split("?", 1)[0] ?? r, n = b(e, t.routesDir ?? "src/routes"), i = N(n, o);
1058
+ return i !== "" && i !== ".." && !i.startsWith(`..${O}`);
1059
+ }
1060
+ function G(e, t) {
1061
+ if (!e || typeof e != "object") return;
1062
+ if (Array.isArray(e)) {
1063
+ for (const o of e) G(o, t);
707
1064
  return;
708
1065
  }
709
- const n = t;
710
- if (typeof n.type == "string") {
711
- e(n);
712
- for (const [o, r] of Object.entries(n))
713
- (/* @__PURE__ */ new Set(["end", "loc", "start", "type"])).has(o) || L(r, e);
1066
+ const r = e;
1067
+ if (typeof r.type == "string") {
1068
+ t(r);
1069
+ for (const [o, n] of Object.entries(r))
1070
+ (/* @__PURE__ */ new Set(["end", "loc", "start", "type"])).has(o) || G(n, t);
714
1071
  }
715
1072
  }
716
- function y(t) {
717
- return t && typeof t == "object" && "type" in t ? t : void 0;
1073
+ function w(e) {
1074
+ return e && typeof e == "object" && "type" in e ? e : void 0;
718
1075
  }
719
- function x(t) {
720
- return Array.isArray(t) ? t.map(y).filter((e) => !!e) : [];
1076
+ function E(e) {
1077
+ return Array.isArray(e) ? e.map(w).filter((t) => !!t) : [];
721
1078
  }
722
- function be(t) {
723
- const e = y(t);
724
- return e?.type === "Identifier" ? e.name === "page" : e?.type === "MemberExpression" && k(e.property) === "page";
1079
+ function or(e) {
1080
+ const t = w(e);
1081
+ return t?.type === "Identifier" ? t.name === "page" : t?.type === "MemberExpression" && B(t.property) === "page";
725
1082
  }
726
- function k(t) {
727
- const e = y(t);
728
- return e?.type === "Identifier" || e?.type === "Literal" ? String(e.name ?? e.value) : void 0;
1083
+ function B(e) {
1084
+ const t = w(e);
1085
+ return t?.type === "Identifier" || t?.type === "Literal" ? String(t.name ?? t.value) : void 0;
729
1086
  }
730
- function xe(t) {
731
- const e = y(t.source)?.value;
732
- return typeof e == "string" && /(?:^|[/.-])server(?:[/.-]|$)/.test(e);
1087
+ function ir(e) {
1088
+ const t = w(e.source)?.value;
1089
+ return typeof t == "string" && /(?:^|[/.-])server(?:[/.-]|$)/.test(t);
733
1090
  }
734
- function Re(t, e) {
735
- const n = [...t];
736
- for (const { end: o, start: r } of e)
737
- n.fill(" ", r, o);
738
- return n.join("");
1091
+ function sr(e, t) {
1092
+ const r = [...e];
1093
+ for (const { end: o, start: n } of t)
1094
+ r.fill(" ", n, o);
1095
+ return r.join("");
739
1096
  }
740
- function $e(t, e, n) {
741
- return [...e].sort((o, r) => r.start - o.start).reduce(
742
- (o, r) => `${o.slice(0, r.start)}${n(r)}${o.slice(r.end)}`,
743
- t
1097
+ function ar(e, t, r) {
1098
+ return [...t].sort((o, n) => n.start - o.start).reduce(
1099
+ (o, n) => `${o.slice(0, n.start)}${r(n)}${o.slice(n.end)}`,
1100
+ e
744
1101
  );
745
1102
  }
746
- function bt(t) {
747
- return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1103
+ function je(e) {
1104
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
748
1105
  }
749
- function Se(t, e, n) {
1106
+ function cr(e, t, r) {
750
1107
  return {
751
1108
  appType: "custom",
752
1109
  build: {
753
- assetsInlineLimit: t.build?.assetsInlineLimit ?? 0,
754
- ...e.isSsrBuild && t.build?.target === void 0 && t.ssr?.target !== "webworker" ? { target: "node22.13" } : {},
1110
+ assetsInlineLimit: e.build?.assetsInlineLimit ?? 0,
1111
+ ...t.isSsrBuild && e.build?.target === void 0 && e.ssr?.target !== "webworker" ? { target: "node22.13" } : {},
755
1112
  rollupOptions: {
756
- input: t.build?.rollupOptions?.input ?? W
1113
+ input: e.build?.rollupOptions?.input ?? K
757
1114
  }
758
1115
  },
759
- ...e.command === "serve" ? {
760
- html: { cspNonce: n },
761
- ssr: { external: [$] }
1116
+ ...t.command === "serve" ? {
1117
+ html: { cspNonce: r },
1118
+ ssr: { external: [P] }
762
1119
  } : {}
763
1120
  };
764
1121
  }
765
- function Ee(t, e = {}) {
766
- const n = e.routesDir ?? "src/routes", o = Me(t, e);
767
- return `import { hydrateFileRouter } from "${$}";
1122
+ function ur(e, t = {}) {
1123
+ const r = t.routesDir ?? "src/routes", o = mr(e, t);
1124
+ return `import { hydrateFileRouter } from "${P}";
768
1125
  ${o}
769
1126
 
770
- ${xt(n, {
1127
+ ${_e(r, {
771
1128
  exportRoutes: !1,
772
1129
  includeServerOnly: !1
773
1130
  })}
@@ -775,11 +1132,11 @@ ${xt(n, {
775
1132
  void hydrateFileRouter({ routes });
776
1133
  `;
777
1134
  }
778
- function De(t, e = {}) {
779
- const n = e.routesDir ?? "src/routes";
780
- return `import { createRequestHandler } from "${$}";
1135
+ function lr(e, t = {}) {
1136
+ const r = t.routesDir ?? "src/routes";
1137
+ return `import { createRequestHandler } from "${P}";
781
1138
 
782
- ${xt(n, {
1139
+ ${_e(r, {
783
1140
  exportRoutes: !0,
784
1141
  includeServerOnly: !0,
785
1142
  eagerModules: !0
@@ -794,21 +1151,21 @@ export function createHandler(options = {}) {
794
1151
  routeModules,
795
1152
  ssr: {
796
1153
  clientEntry,
797
- lang: lang ?? ${JSON.stringify(e.document?.lang)},
1154
+ lang: lang ?? ${JSON.stringify(t.document?.lang)},
798
1155
  styles,
799
- title: title ?? ${JSON.stringify(e.document?.title)},
1156
+ title: title ?? ${JSON.stringify(t.document?.title)},
800
1157
  },
801
1158
  });
802
1159
  }
803
1160
  `;
804
1161
  }
805
- function xt(t, {
806
- exportRoutes: e,
807
- eagerModules: n = !1,
1162
+ function _e(e, {
1163
+ exportRoutes: t,
1164
+ eagerModules: r = !1,
808
1165
  includeServerOnly: o
809
1166
  }) {
810
- const r = Pe(t, o), i = Oe(t);
811
- return n ? `const eagerRouteModules = import.meta.glob(${JSON.stringify(r)}, { eager: true });
1167
+ const n = fr(e, o), i = pr(e);
1168
+ return r ? `const eagerRouteModules = import.meta.glob(${JSON.stringify(n)}, { eager: true });
812
1169
  const routePrefix = ${JSON.stringify(i)};
813
1170
  export const routeModules = Object.fromEntries(
814
1171
  Object.entries(eagerRouteModules).map(([file, module]) => [
@@ -816,268 +1173,271 @@ export const routeModules = Object.fromEntries(
816
1173
  module,
817
1174
  ]),
818
1175
  );
819
- ${e ? "export " : ""}const routes = Object.fromEntries(
1176
+ ${t ? "export " : ""}const routes = Object.fromEntries(
820
1177
  Object.entries(routeModules).map(([file, module]) => [
821
1178
  file,
822
1179
  async () => module,
823
1180
  ]),
824
- );` : `const routeModules = import.meta.glob(${JSON.stringify(r)});
1181
+ );` : `const routeModules = import.meta.glob(${JSON.stringify(n)});
825
1182
  const routePrefix = ${JSON.stringify(i)};
826
- ${e ? "export " : ""}const routes = Object.fromEntries(
1183
+ ${t ? "export " : ""}const routes = Object.fromEntries(
827
1184
  Object.entries(routeModules).map(([file, load]) => [
828
1185
  \`./routes/\${file.slice(routePrefix.length)}\`,
829
1186
  load,
830
1187
  ]),
831
1188
  );`;
832
1189
  }
833
- const Ne = ["@middleware.ts", "@policy.ts"];
834
- function Pe(t, e) {
835
- const n = `/${t.replace(/^\/|\/$/g, "")}`, o = [`${n}/**/*.{ts,tsx}`];
836
- return e || o.push(
837
- ...Ne.flatMap((r) => [
838
- `!${n}/${r}`,
839
- `!${n}/**/${r}`
1190
+ const dr = ["@middleware.ts", "@policy.ts"];
1191
+ function fr(e, t) {
1192
+ const r = `/${e.replace(/^\/|\/$/g, "")}`, o = [`${r}/**/*.{ts,tsx}`];
1193
+ return t || o.push(
1194
+ ...dr.flatMap((n) => [
1195
+ `!${r}/${n}`,
1196
+ `!${r}/**/${n}`
840
1197
  ])
841
1198
  ), o;
842
1199
  }
843
- function Oe(t) {
844
- return `/${t.replace(/^\/|\/$/g, "")}/`;
1200
+ function pr(e) {
1201
+ return `/${e.replace(/^\/|\/$/g, "")}/`;
845
1202
  }
846
- function Me(t, e) {
847
- if (e.styles === !1)
1203
+ function mr(e, t) {
1204
+ if (t.styles === !1)
848
1205
  return "";
849
- const n = e.styles ?? "src/styles.css", o = w(t, n);
850
- return G(o) ? `import ${JSON.stringify(`/${n.replace(/^\/+/, "")}`)};` : "";
851
- }
852
- function Ie(t, e) {
853
- const n = t.config.publicDir, o = e.images?.optimizerPath ?? "/_demiurge/image";
854
- return n ? kt({
855
- policy: e.images,
856
- resolveVariant: (r) => Ht(r, o),
857
- root: n
1206
+ const r = t.styles ?? "src/styles.css", o = b(e, r);
1207
+ return re(o) ? `import ${JSON.stringify(`/${r.replace(/^\/+/, "")}`)};` : "";
1208
+ }
1209
+ function yr(e) {
1210
+ return e.devtools !== !1 && process.env.NODE_ENV !== "production";
1211
+ }
1212
+ function hr(e, t) {
1213
+ const r = e.config.publicDir, o = t.images?.optimizerPath ?? "/_demiurge/image";
1214
+ return r ? ct({
1215
+ policy: t.images,
1216
+ resolveVariant: (n) => lt(n, o),
1217
+ root: r
858
1218
  }) : async () => null;
859
1219
  }
860
- function _e(t, e) {
1220
+ function gr(e, t) {
861
1221
  return {
862
1222
  dev: !0,
863
- ssr: $t(t),
864
- transformDocument: e,
865
- renderPage: async (n, o) => {
866
- if (n.render.mode === "streaming")
867
- return await Wt(n, {
1223
+ ssr: ke(e),
1224
+ transformDocument: t,
1225
+ renderPage: async (r, o) => {
1226
+ if (r.render.mode === "streaming")
1227
+ return await ut(r, {
868
1228
  ...o,
869
- clientEntry: z,
870
- transformDocument: e
1229
+ clientEntry: te,
1230
+ transformDocument: t
871
1231
  });
872
- const r = await e(
873
- It(n, {
1232
+ const n = await t(
1233
+ ze(r, {
874
1234
  ...o,
875
- clientEntry: z
1235
+ clientEntry: te
876
1236
  })
877
1237
  );
878
- return new Response(r, {
1238
+ return new Response(n, {
879
1239
  headers: { "content-type": "text/html; charset=utf-8" }
880
1240
  });
881
1241
  }
882
1242
  };
883
1243
  }
884
- function at(t, e) {
885
- const n = B(), o = B();
1244
+ function Re(e, t) {
1245
+ const r = z(), o = z();
886
1246
  return {
887
- nonce: n,
888
- transform: async (r) => {
889
- const i = Ce(r, o), s = await t.transformIndexHtml("/", i);
890
- return ct(
891
- ct(s, o),
892
- e,
893
- n
1247
+ nonce: r,
1248
+ transform: async (n) => {
1249
+ const i = wr(n, o), s = await e.transformIndexHtml("/", i);
1250
+ return ve(
1251
+ ve(s, o),
1252
+ t,
1253
+ r
894
1254
  );
895
1255
  }
896
1256
  };
897
1257
  }
898
- function Ce(t, e) {
899
- const n = t.toLowerCase();
900
- let o = 0, r = "";
901
- for (; o < t.length; ) {
902
- const i = t.indexOf("<", o);
1258
+ function wr(e, t) {
1259
+ const r = e.toLowerCase();
1260
+ let o = 0, n = "";
1261
+ for (; o < e.length; ) {
1262
+ const i = e.indexOf("<", o);
903
1263
  if (i === -1)
904
- return r + t.slice(o);
905
- if (r += t.slice(o, i), n.startsWith("<!--", i)) {
906
- const u = n.indexOf("-->", i + 4), f = u === -1 ? t.length : u + 3;
907
- r += t.slice(i, f), o = f;
1264
+ return n + e.slice(o);
1265
+ if (n += e.slice(o, i), r.startsWith("<!--", i)) {
1266
+ const u = r.indexOf("-->", i + 4), d = u === -1 ? e.length : u + 3;
1267
+ n += e.slice(i, d), o = d;
908
1268
  continue;
909
1269
  }
910
- const s = n.slice(i).match(/^<\s*(script|style|link)\b/)?.[1];
1270
+ const s = r.slice(i).match(/^<\s*(script|style|link)\b/)?.[1];
911
1271
  if (!s) {
912
- r += "<", o = i + 1;
1272
+ n += "<", o = i + 1;
913
1273
  continue;
914
1274
  }
915
- const a = je(t, i);
1275
+ const a = Rr(e, i);
916
1276
  if (a === -1)
917
- return r + t.slice(i);
918
- const c = t.slice(i, a + 1);
919
- if (r += /(?:^|\s)nonce(?:\s|=|>)/i.test(c) ? c : Fe(c, e), o = a + 1, s === "script" || s === "style") {
920
- const u = n.indexOf(`</${s}`, o);
1277
+ return n + e.slice(i);
1278
+ const c = e.slice(i, a + 1);
1279
+ if (n += /(?:^|\s)nonce(?:\s|=|>)/i.test(c) ? c : vr(c, t), o = a + 1, s === "script" || s === "style") {
1280
+ const u = r.indexOf(`</${s}`, o);
921
1281
  if (u === -1)
922
- return r + t.slice(o);
923
- r += t.slice(o, u), o = u;
1282
+ return n + e.slice(o);
1283
+ n += e.slice(o, u), o = u;
924
1284
  }
925
1285
  }
926
- return r;
1286
+ return n;
927
1287
  }
928
- function je(t, e) {
929
- let n;
930
- for (let o = e + 1; o < t.length; o++) {
931
- const r = t[o];
932
- if (n) {
933
- r === n && (n = void 0);
1288
+ function Rr(e, t) {
1289
+ let r;
1290
+ for (let o = t + 1; o < e.length; o++) {
1291
+ const n = e[o];
1292
+ if (r) {
1293
+ n === r && (r = void 0);
934
1294
  continue;
935
1295
  }
936
- if (r === '"' || r === "'")
937
- n = r;
938
- else if (r === ">")
1296
+ if (n === '"' || n === "'")
1297
+ r = n;
1298
+ else if (n === ">")
939
1299
  return o;
940
1300
  }
941
1301
  return -1;
942
1302
  }
943
- function Fe(t, e) {
944
- const n = /\/\s*>$/.test(t) ? t.lastIndexOf("/") : t.length - 1;
945
- return `${t.slice(0, n)} nonce="${e}"${t.slice(n)}`;
1303
+ function vr(e, t) {
1304
+ const r = /\/\s*>$/.test(e) ? e.lastIndexOf("/") : e.length - 1;
1305
+ return `${e.slice(0, r)} nonce="${t}"${e.slice(r)}`;
946
1306
  }
947
- function ct(t, e, n) {
1307
+ function ve(e, t, r) {
948
1308
  const o = new RegExp(
949
- `(\\snonce\\s*=\\s*)(["'])${bt(e)}\\2`,
1309
+ `(\\snonce\\s*=\\s*)(["'])${je(t)}\\2`,
950
1310
  "g"
951
1311
  );
952
- return t.replace(
1312
+ return e.replace(
953
1313
  o,
954
- n ? `$1"${n}"` : ""
1314
+ r ? `$1"${r}"` : ""
955
1315
  );
956
1316
  }
957
- function ut(t, e) {
958
- const n = t.headers.get("content-type"), o = t.headers.get("content-security-policy");
959
- if (!n?.toLowerCase().startsWith("text/html") || !o)
1317
+ function be(e, t) {
1318
+ const r = e.headers.get("content-type"), o = e.headers.get("content-security-policy");
1319
+ if (!r?.toLowerCase().startsWith("text/html") || !o)
960
1320
  return;
961
- const r = `'nonce-${e}'`, i = lt(
1321
+ const n = `'nonce-${t}'`, i = $e(
962
1322
  o,
963
1323
  ["script-src-elem", "script-src"],
964
1324
  "script-src",
965
- r
966
- ), s = Te(
1325
+ n
1326
+ ), s = br(
967
1327
  i,
968
1328
  ["style-src-elem", "style-src"]
969
- ) ? i : lt(
1329
+ ) ? i : $e(
970
1330
  i,
971
1331
  ["style-src-elem", "style-src"],
972
1332
  "style-src",
973
- r
1333
+ n
974
1334
  );
975
- t.headers.set("content-security-policy", s), t.headers.set("cache-control", "private, no-store");
1335
+ e.headers.set("content-security-policy", s), e.headers.set("cache-control", "private, no-store");
976
1336
  }
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"
1337
+ function $e(e, t, r, o) {
1338
+ const n = e.split(";").map((d) => d.trim()), i = Fe(n, t), s = n.find(
1339
+ (d) => d.split(/\s+/, 1)[0]?.toLowerCase() === "default-src"
980
1340
  );
981
- if (i === -1 && !s) return t;
982
- const [a, ...c] = (i === -1 ? s : r[i]).split(/\s+/), u = [
983
- i === -1 ? n : a,
1341
+ if (i === -1 && !s) return e;
1342
+ const [a, ...c] = (i === -1 ? s : n[i]).split(/\s+/), u = [
1343
+ i === -1 ? r : a,
984
1344
  .../* @__PURE__ */ new Set([
985
- ...c.filter((f) => f !== "'none'"),
1345
+ ...c.filter((d) => d !== "'none'"),
986
1346
  o
987
1347
  ])
988
1348
  ].join(" ");
989
- return i === -1 ? r.push(u) : r[i] = u, r.join("; ");
1349
+ return i === -1 ? n.push(u) : n[i] = u, n.join("; ");
990
1350
  }
991
- function Te(t, e) {
992
- const n = t.split(";").map((s) => s.trim()), o = Rt(n, e), i = (o === -1 ? n.find(
1351
+ function br(e, t) {
1352
+ const r = e.split(";").map((s) => s.trim()), o = Fe(r, t), i = (o === -1 ? r.find(
993
1353
  (s) => s.split(/\s+/, 1)[0]?.toLowerCase() === "default-src"
994
- ) : n[o])?.split(/\s+/).slice(1) ?? [];
1354
+ ) : r[o])?.split(/\s+/).slice(1) ?? [];
995
1355
  return i.includes("'unsafe-inline'") && !i.some((s) => /^'(?:nonce-|sha(?:256|384|512)-)/i.test(s));
996
1356
  }
997
- function Rt(t, e) {
998
- for (const n of e) {
999
- const o = t.findIndex(
1000
- (r) => r.split(/\s+/, 1)[0]?.toLowerCase() === n
1357
+ function Fe(e, t) {
1358
+ for (const r of t) {
1359
+ const o = e.findIndex(
1360
+ (n) => n.split(/\s+/, 1)[0]?.toLowerCase() === r
1001
1361
  );
1002
1362
  if (o !== -1) return o;
1003
1363
  }
1004
1364
  return -1;
1005
1365
  }
1006
- const ft = Symbol.for("demiurge.devManifest");
1007
- async function dt(t, e, n) {
1008
- const o = e, r = o[ft];
1009
- if (r)
1010
- return r;
1011
- const i = Vt(
1012
- await ze(t, n)
1366
+ const Se = Symbol.for("demiurge.devManifest");
1367
+ async function Z(e, t, r) {
1368
+ const o = t, n = o[Se];
1369
+ if (n)
1370
+ return n;
1371
+ const i = st(
1372
+ await Tr(e, r)
1013
1373
  );
1014
- return o[ft] = i, i;
1374
+ return o[Se] = i, i;
1015
1375
  }
1016
- function $t(t) {
1376
+ function ke(e) {
1017
1377
  return {
1018
- clientEntry: z,
1019
- lang: t.document?.lang,
1020
- title: t.document?.title
1378
+ clientEntry: te,
1379
+ lang: e.document?.lang,
1380
+ title: e.document?.title
1021
1381
  };
1022
1382
  }
1023
- function Ae(t, e) {
1383
+ function $r(e, t) {
1024
1384
  return {
1025
- ...$t(t),
1385
+ ...ke(e),
1026
1386
  dev: !0,
1027
- transformDocument: e
1387
+ transformDocument: t
1028
1388
  };
1029
1389
  }
1030
- const pt = /* @__PURE__ */ new Set();
1031
- function Ve(t, e) {
1032
- pt.has(e) || t.fallbacks.notFound.some(
1033
- (n) => n.fileSegments.length === 0
1034
- ) || (pt.add(e), console.warn(Be(Nt(e, "@not-found.tsx"))));
1390
+ const xe = /* @__PURE__ */ new Set();
1391
+ function Sr(e, t) {
1392
+ xe.has(t) || e.fallbacks.notFound.some(
1393
+ (r) => r.fileSegments.length === 0
1394
+ ) || (xe.add(t), console.warn(Or(He(t, "@not-found.tsx"))));
1035
1395
  }
1036
- async function Le(t, e = {}) {
1037
- const n = e.routesDir ?? "src/routes", o = w(t, n);
1038
- if (!G(o))
1396
+ async function xr(e, t = {}) {
1397
+ const r = t.routesDir ?? "src/routes", o = b(e, r);
1398
+ if (!re(o))
1039
1399
  return;
1040
- const r = await K(o);
1041
- if (r.map(
1042
- (a) => R(o, a).split(S).join("/")
1400
+ const n = await ie(o);
1401
+ if (n.map(
1402
+ (a) => N(o, a).split(O).join("/")
1043
1403
  ).some((a) => /^@not-found\.tsx?$/.test(a)))
1044
1404
  return;
1045
- const s = await ke(r);
1405
+ const s = await Er(n);
1046
1406
  if (s)
1047
1407
  throw new Error(
1048
- Je(
1049
- n,
1050
- R(o, s).split(S).join("/")
1408
+ Pr(
1409
+ r,
1410
+ N(o, s).split(O).join("/")
1051
1411
  )
1052
1412
  );
1053
1413
  }
1054
- async function ke(t) {
1055
- for (const e of t)
1056
- if (!R(q(e), e).startsWith("@") && He(await gt(e, "utf8")))
1057
- return e;
1414
+ async function Er(e) {
1415
+ for (const t of e)
1416
+ if (!N(ne(t), t).startsWith("@") && Dr(await Pe(t, "utf8")))
1417
+ return t;
1058
1418
  }
1059
- const We = $.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), mt = new RegExp(
1060
- `import\\s*\\{([^}]*)\\}\\s*from\\s*["']${We}["']`,
1419
+ const Nr = P.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ee = new RegExp(
1420
+ `import\\s*\\{([^}]*)\\}\\s*from\\s*["']${Nr}["']`,
1061
1421
  "g"
1062
1422
  );
1063
- function He(t) {
1064
- const e = [...t.matchAll(mt)].flatMap(
1065
- (o) => o[1].split(",").flatMap((r) => {
1066
- const [i, s] = r.trim().split(/\s+as\s+/);
1423
+ function Dr(e) {
1424
+ const t = [...e.matchAll(Ee)].flatMap(
1425
+ (o) => o[1].split(",").flatMap((n) => {
1426
+ const [i, s] = n.trim().split(/\s+as\s+/);
1067
1427
  return i.replace(/^type\s+/, "") === "page" ? [s ?? i] : [];
1068
1428
  })
1069
1429
  );
1070
- if (e.length === 0)
1430
+ if (t.length === 0)
1071
1431
  return !1;
1072
- const n = t.replace(mt, "");
1073
- return e.some((o) => new RegExp(`\\b${o}\\s*\\(`).test(n));
1432
+ const r = e.replace(Ee, "");
1433
+ return t.some((o) => new RegExp(`\\b${o}\\s*\\(`).test(r));
1074
1434
  }
1075
- function Je(t, e) {
1076
- return `Demiurge will not build an app with page routes and no ${t}/@not-found.tsx.
1435
+ function Pr(e, t) {
1436
+ return `Demiurge will not build an app with page routes and no ${e}/@not-found.tsx.
1077
1437
 
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.
1438
+ "${t}" declares a page, so a browser can reach a path this app does not serve. Decide what that looks like rather than shipping the framework built-in.
1079
1439
 
1080
- Create ${t}/@not-found.tsx:
1440
+ Create ${e}/@not-found.tsx:
1081
1441
 
1082
1442
  export default function NotFound({ pathname }: { pathname: string }) {
1083
1443
  return <h1>Nothing at {pathname}</h1>;
@@ -1085,8 +1445,8 @@ Create ${t}/@not-found.tsx:
1085
1445
 
1086
1446
  It renders inside the layouts above the requested path. Opt out with "export const layout = false".`;
1087
1447
  }
1088
- function Be(t) {
1089
- return `Demiurge is serving its built-in 404 because ${t} does not exist.
1448
+ function Or(e) {
1449
+ return `Demiurge is serving its built-in 404 because ${e} does not exist.
1090
1450
 
1091
1451
  Create it before building for production:
1092
1452
 
@@ -1095,105 +1455,109 @@ Create it before building for production:
1095
1455
  }
1096
1456
  `;
1097
1457
  }
1098
- function Ue({
1099
- entrySrc: t,
1100
- lang: e,
1101
- links: n,
1458
+ function Mr({
1459
+ entrySrc: e,
1460
+ lang: t,
1461
+ links: r,
1102
1462
  metadata: o,
1103
- nonce: r,
1463
+ nonce: n,
1104
1464
  scripts: i,
1105
1465
  styles: s,
1106
1466
  title: a
1107
1467
  }) {
1108
- return Mt({
1109
- entrySrc: t,
1110
- lang: e,
1111
- links: n,
1468
+ return qe({
1469
+ entrySrc: e,
1470
+ lang: t,
1471
+ links: r,
1112
1472
  metadata: o,
1113
- nonce: r,
1473
+ nonce: n,
1114
1474
  scripts: i,
1115
1475
  styles: s,
1116
1476
  title: a
1117
1477
  });
1118
1478
  }
1119
- async function _(t, e) {
1120
- const n = w(t, e.routesDir ?? "src/routes"), o = w(
1121
- t,
1122
- typeof e.typedRoutes == "object" ? e.typedRoutes.outputFile ?? it : it
1479
+ async function L(e, t) {
1480
+ const r = b(e, t.routesDir ?? "src/routes"), o = b(
1481
+ e,
1482
+ typeof t.typedRoutes == "object" ? t.typedRoutes.outputFile ?? ge : ge
1123
1483
  );
1124
- await Jt({ outputFile: o, routesDir: n });
1484
+ await dt({ outputFile: o, routesDir: r });
1125
1485
  }
1126
- function A(t, e) {
1127
- return e.startsWith(t) && /\.tsx?$/.test(e);
1486
+ function J(e, t) {
1487
+ return t.startsWith(e) && /\.tsx?$/.test(t);
1128
1488
  }
1129
- async function ze(t, e) {
1130
- const n = await K(e), o = {};
1131
- for (const r of n) {
1132
- const i = Xe(e, r);
1133
- o[i] = async () => await t.ssrLoadModule(r);
1489
+ async function Tr(e, t) {
1490
+ const r = await ie(t), o = {};
1491
+ for (const n of r) {
1492
+ const i = Fr(t, n);
1493
+ o[i] = async () => await e.ssrLoadModule(n);
1134
1494
  }
1135
1495
  return o;
1136
1496
  }
1137
- async function Ge(t, e, n = {}) {
1138
- const o = new URL(e.url);
1139
- return Tt(t.routes, o.pathname) ? await At(t, e, n) : "next";
1497
+ async function Ar(e, t, r = {}) {
1498
+ const o = new URL(t.url);
1499
+ return Oe(e.routes, o.pathname) ? await it(e, t, r) : "next";
1140
1500
  }
1141
- async function K(t) {
1142
- return (await ht(t, {
1501
+ async function ie(e) {
1502
+ return (await De(e, {
1143
1503
  recursive: !0,
1144
1504
  withFileTypes: !0
1145
- })).filter((n) => n.isFile() && /\.tsx?$/.test(n.name)).map((n) => w(n.parentPath, n.name));
1505
+ })).filter((r) => r.isFile() && /\.tsx?$/.test(r.name)).map((r) => b(r.parentPath, r.name));
1146
1506
  }
1147
- const qe = 8, Ye = 50;
1148
- async function Ke(t, e, n) {
1149
- const o = new Array(t.length);
1150
- let r = 0;
1507
+ const Cr = 8, Ir = 50;
1508
+ async function jr(e, t, r) {
1509
+ const o = new Array(e.length);
1510
+ let n = 0;
1151
1511
  const i = Array.from(
1152
- { length: Math.min(e, t.length) },
1512
+ { length: Math.min(t, e.length) },
1153
1513
  async () => {
1154
- for (; r < t.length; ) {
1155
- const s = r++;
1156
- o[s] = await n(t[s]);
1514
+ for (; n < e.length; ) {
1515
+ const s = n++;
1516
+ o[s] = await r(e[s]);
1157
1517
  }
1158
1518
  }
1159
1519
  );
1160
1520
  return await Promise.all(i), o;
1161
1521
  }
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
1522
+ async function Ne(e, t = {}) {
1523
+ const r = b(e, t.routesDir ?? "src/routes");
1524
+ return re(r) ? (await jr(
1525
+ await ie(r),
1526
+ Cr,
1527
+ Nt
1168
1528
  )).flat().sort(
1169
- (r, i) => r.file.localeCompare(i.file) || (r.exportName ?? "").localeCompare(i.exportName ?? "") || r.code.localeCompare(i.code)
1529
+ (n, i) => n.file.localeCompare(i.file) || (n.exportName ?? "").localeCompare(i.exportName ?? "") || n.code.localeCompare(i.code)
1170
1530
  ) : [];
1171
1531
  }
1172
- function Qe(t) {
1532
+ function _r(e) {
1173
1533
  return [
1174
1534
  "Demiurge found invalid static route policy:",
1175
- ...t.map(St)
1535
+ ...e.map(Le)
1176
1536
  ].join(`
1177
1537
  `);
1178
1538
  }
1179
- function St(t) {
1180
- return `${t.exportName ? `${t.file} export ${t.exportName}` : t.file}: [${t.code}] ${t.message}`;
1539
+ function Le(e) {
1540
+ return `${e.exportName ? `${e.file} export ${e.exportName}` : e.file}: [${e.code}] ${e.message}`;
1181
1541
  }
1182
- function Xe(t, e) {
1183
- return `./routes/${R(t, e).split(S).join("/")}`;
1542
+ function Fr(e, t) {
1543
+ return `./routes/${N(e, t).split(O).join("/")}`;
1184
1544
  }
1185
1545
  export {
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
1546
+ Yr as demiurge,
1547
+ Te as unstable_ROUTE_AUDIT_PATH,
1548
+ xr as unstable_assertRootNotFoundRoute,
1549
+ ur as unstable_createClientEntrySource,
1550
+ Tr as unstable_createDevRouteImporters,
1551
+ Mr as unstable_createDocumentHtml,
1552
+ Vt as unstable_createRouteAudit,
1553
+ lr as unstable_createServerEntrySource,
1554
+ Dr as unstable_declaresPageRoute,
1555
+ _r as unstable_formatStaticPolicyFindings,
1556
+ Ar as unstable_handleDevRequest,
1557
+ yr as unstable_isRouteAuditEnabled,
1558
+ Jt as unstable_renderRouteAuditDocument,
1559
+ tr as unstable_stripClientPageData,
1560
+ Ne as unstable_verifyRoutePolicies,
1561
+ Dt as unstable_verifyRoutePolicySource
1198
1562
  };
1199
1563
  //# sourceMappingURL=index.js.map