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