@demiurgejs/core 0.2.0-beta.4 → 0.2.0-beta.6

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 (161) hide show
  1. package/README.md +37 -0
  2. package/bin/demiurge.mjs +23 -1
  3. package/dist/adapter/index.d.ts +1 -1
  4. package/dist/adapter/index.d.ts.map +1 -1
  5. package/dist/browser/file-router.d.ts +1 -1
  6. package/dist/chunks/{document-shell-CpJnFtSC.js → document-shell-C0aPrkhd.js} +2 -2
  7. package/dist/chunks/{document-shell-CpJnFtSC.js.map → document-shell-C0aPrkhd.js.map} +1 -1
  8. package/dist/chunks/image-CRerJ5BY.js +145 -0
  9. package/dist/chunks/image-CRerJ5BY.js.map +1 -0
  10. package/dist/chunks/{image-codec-BmzWnH6W.js → image-codec-CQ8Cwxwb.js} +2 -2
  11. package/dist/chunks/{image-codec-BmzWnH6W.js.map → image-codec-CQ8Cwxwb.js.map} +1 -1
  12. package/dist/chunks/{images-BQ80950B.js → images-QgdmLyQ3.js} +11 -11
  13. package/dist/chunks/{images-BQ80950B.js.map → images-QgdmLyQ3.js.map} +1 -1
  14. package/dist/chunks/{index-BVk9zWbe.js → index-LYve1rQp.js} +287 -351
  15. package/dist/chunks/index-LYve1rQp.js.map +1 -0
  16. package/dist/chunks/links-iU22QkCE.js +68 -0
  17. package/dist/chunks/links-iU22QkCE.js.map +1 -0
  18. package/dist/chunks/plugin-bkP6WwrS.js +2311 -0
  19. package/dist/chunks/plugin-bkP6WwrS.js.map +1 -0
  20. package/dist/chunks/runtime-BH519j2t.js +294 -0
  21. package/dist/chunks/runtime-BH519j2t.js.map +1 -0
  22. package/dist/chunks/streaming-BlKlC3nw.js +427 -0
  23. package/dist/chunks/streaming-BlKlC3nw.js.map +1 -0
  24. package/dist/chunks/{testing-DueXbMo4.js → testing-BEW1nchS.js} +2161 -1562
  25. package/dist/chunks/testing-BEW1nchS.js.map +1 -0
  26. package/dist/chunks/{vite-DO70kZA6.js → vite-BADZA8Fl.js} +90 -87
  27. package/dist/chunks/vite-BADZA8Fl.js.map +1 -0
  28. package/dist/cli.d.ts +10 -2
  29. package/dist/cli.d.ts.map +1 -1
  30. package/dist/cli.js +277 -87
  31. package/dist/cli.js.map +1 -1
  32. package/dist/config/index.js +2 -2
  33. package/dist/config/types.d.ts +14 -2
  34. package/dist/config/types.d.ts.map +1 -1
  35. package/dist/config/validate.d.ts.map +1 -1
  36. package/dist/data/cache.d.ts +5 -0
  37. package/dist/data/cache.d.ts.map +1 -1
  38. package/dist/data/index.d.ts +1 -1
  39. package/dist/data/index.d.ts.map +1 -1
  40. package/dist/data/testing.d.ts.map +1 -1
  41. package/dist/data/testing.js +101 -67
  42. package/dist/data/testing.js.map +1 -1
  43. package/dist/data/tiered.d.ts.map +1 -1
  44. package/dist/edge/index.js +27 -26
  45. package/dist/edge/index.js.map +1 -1
  46. package/dist/edge/stores.d.ts.map +1 -1
  47. package/dist/index.d.ts +4 -4
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +158 -135
  50. package/dist/index.js.map +1 -1
  51. package/dist/inspect/command.d.ts +28 -0
  52. package/dist/inspect/command.d.ts.map +1 -0
  53. package/dist/inspect/index.d.ts +9 -0
  54. package/dist/inspect/index.d.ts.map +1 -0
  55. package/dist/inspect/redact.d.ts +35 -0
  56. package/dist/inspect/redact.d.ts.map +1 -0
  57. package/dist/inspect/report.d.ts +24 -0
  58. package/dist/inspect/report.d.ts.map +1 -0
  59. package/dist/inspect/types.d.ts +102 -0
  60. package/dist/inspect/types.d.ts.map +1 -0
  61. package/dist/internal/testing.js +12 -12
  62. package/dist/kv/index.js +7 -6
  63. package/dist/kv/index.js.map +1 -1
  64. package/dist/kv/store.d.ts.map +1 -1
  65. package/dist/node/http.d.ts +7 -0
  66. package/dist/node/http.d.ts.map +1 -1
  67. package/dist/node/index.d.ts +2 -2
  68. package/dist/node/index.d.ts.map +1 -1
  69. package/dist/node/index.js +31 -28
  70. package/dist/node/index.js.map +1 -1
  71. package/dist/node/serve.d.ts +4 -0
  72. package/dist/node/serve.d.ts.map +1 -1
  73. package/dist/redis/index.js +29 -28
  74. package/dist/redis/index.js.map +1 -1
  75. package/dist/redis/store.d.ts.map +1 -1
  76. package/dist/route/index.d.ts +1 -0
  77. package/dist/route/index.d.ts.map +1 -1
  78. package/dist/route/mutation.d.ts.map +1 -1
  79. package/dist/route/serialization.d.ts +24 -0
  80. package/dist/route/serialization.d.ts.map +1 -0
  81. package/dist/route/webhook.d.ts +6 -1
  82. package/dist/route/webhook.d.ts.map +1 -1
  83. package/dist/router/manifest.d.ts.map +1 -1
  84. package/dist/security/audit.d.ts +2 -1
  85. package/dist/security/audit.d.ts.map +1 -1
  86. package/dist/security/authorization.d.ts +36 -0
  87. package/dist/security/authorization.d.ts.map +1 -0
  88. package/dist/security/csrf.d.ts.map +1 -1
  89. package/dist/security/env-startup.d.ts +0 -2
  90. package/dist/security/env-startup.d.ts.map +1 -1
  91. package/dist/security/env.d.ts +27 -8
  92. package/dist/security/env.d.ts.map +1 -1
  93. package/dist/security/exceptions.d.ts +29 -0
  94. package/dist/security/exceptions.d.ts.map +1 -0
  95. package/dist/security/finding-codes.d.ts +56 -0
  96. package/dist/security/finding-codes.d.ts.map +1 -0
  97. package/dist/security/index.d.ts +5 -2
  98. package/dist/security/index.d.ts.map +1 -1
  99. package/dist/security/policy.d.ts +2 -5
  100. package/dist/security/policy.d.ts.map +1 -1
  101. package/dist/security/report.d.ts +2 -1
  102. package/dist/security/report.d.ts.map +1 -1
  103. package/dist/security/request.d.ts +1 -0
  104. package/dist/security/request.d.ts.map +1 -1
  105. package/dist/security/types.d.ts +138 -5
  106. package/dist/security/types.d.ts.map +1 -1
  107. package/dist/security/upload.d.ts +3 -3
  108. package/dist/security/upload.d.ts.map +1 -1
  109. package/dist/security/verification.d.ts.map +1 -1
  110. package/dist/server/request-handler.d.ts +3 -2
  111. package/dist/server/request-handler.d.ts.map +1 -1
  112. package/dist/server-only/browser.d.ts +2 -0
  113. package/dist/server-only/browser.d.ts.map +1 -0
  114. package/dist/server-only/browser.js +4 -0
  115. package/dist/server-only/browser.js.map +1 -0
  116. package/dist/server-only/index.d.ts +2 -0
  117. package/dist/server-only/index.d.ts.map +1 -0
  118. package/dist/server-only/index.js +2 -0
  119. package/dist/server-only/index.js.map +1 -0
  120. package/dist/static/index.d.ts.map +1 -1
  121. package/dist/static/index.js +255 -255
  122. package/dist/static/index.js.map +1 -1
  123. package/dist/static/testing.d.ts +26 -0
  124. package/dist/static/testing.d.ts.map +1 -0
  125. package/dist/static/testing.js +76 -0
  126. package/dist/static/testing.js.map +1 -0
  127. package/dist/testing/index.d.ts +47 -0
  128. package/dist/testing/index.d.ts.map +1 -0
  129. package/dist/testing/index.js +99 -0
  130. package/dist/testing/index.js.map +1 -0
  131. package/dist/vercel/build.d.ts +31 -0
  132. package/dist/vercel/build.d.ts.map +1 -0
  133. package/dist/vercel/config.d.ts +15 -0
  134. package/dist/vercel/config.d.ts.map +1 -0
  135. package/dist/vercel/index.d.ts +7 -0
  136. package/dist/vercel/index.d.ts.map +1 -0
  137. package/dist/vercel/index.js +11 -0
  138. package/dist/vercel/index.js.map +1 -0
  139. package/dist/vercel/runtime.d.ts +29 -0
  140. package/dist/vercel/runtime.d.ts.map +1 -0
  141. package/dist/vite/index.d.ts +9 -4
  142. package/dist/vite/index.d.ts.map +1 -1
  143. package/dist/vite/index.js +28 -21
  144. package/dist/vite/plugin.d.ts +18 -2
  145. package/dist/vite/plugin.d.ts.map +1 -1
  146. package/dist/vite/policy-verification.d.ts +33 -2
  147. package/dist/vite/policy-verification.d.ts.map +1 -1
  148. package/dist/vite/route-audit.d.ts +14 -2
  149. package/dist/vite/route-audit.d.ts.map +1 -1
  150. package/dist/vite/server-only-boundary.d.ts +8 -0
  151. package/dist/vite/server-only-boundary.d.ts.map +1 -0
  152. package/package.json +18 -1
  153. package/dist/chunks/env-startup-DOBYWlZD.js +0 -257
  154. package/dist/chunks/env-startup-DOBYWlZD.js.map +0 -1
  155. package/dist/chunks/index-BVk9zWbe.js.map +0 -1
  156. package/dist/chunks/plugin-BQgMiHxa.js +0 -1827
  157. package/dist/chunks/plugin-BQgMiHxa.js.map +0 -1
  158. package/dist/chunks/streaming-BEbPN7Uk.js +0 -469
  159. package/dist/chunks/streaming-BEbPN7Uk.js.map +0 -1
  160. package/dist/chunks/testing-DueXbMo4.js.map +0 -1
  161. package/dist/chunks/vite-DO70kZA6.js.map +0 -1
package/dist/cli.js CHANGED
@@ -1,11 +1,129 @@
1
- import { readdir as g, readFile as b } from "node:fs/promises";
2
- import { resolve as p, join as D, relative as m, sep as v, isAbsolute as y } from "node:path";
3
- import { pathToFileURL as R } from "node:url";
4
- import { c as E } from "./chunks/vite-DO70kZA6.js";
5
- import { p as S } from "./chunks/manifest-vO6c0G0W.js";
6
- import { generateStaticOutput as N, generateVercelStaticOutput as T } from "./static/index.js";
7
- const I = /* @__PURE__ */ new Set(["--host", "--origin", "--out-dir", "--port"]), V = "virtual:demiurge/client-entry", _ = "virtual:demiurge/server-entry", O = "dist", j = "dist/server", U = ".demiurge/server";
8
- function J(t, e = {}) {
1
+ import { readdir as _, readFile as P } from "node:fs/promises";
2
+ import { relative as m, sep as v, resolve as d, join as O, isAbsolute as D } from "node:path";
3
+ import { pathToFileURL as h } from "node:url";
4
+ import { t as C, c as T } from "./chunks/vite-BADZA8Fl.js";
5
+ import { p as $ } from "./chunks/manifest-vO6c0G0W.js";
6
+ import { generateStaticOutput as j, generateVercelStaticOutput as V } from "./static/index.js";
7
+ import { g as F } from "./chunks/runtime-BH519j2t.js";
8
+ import { t as x, a as L } from "./chunks/testing-BEW1nchS.js";
9
+ import { v as A, B as R } from "./chunks/plugin-bkP6WwrS.js";
10
+ import "./chunks/index-LYve1rQp.js";
11
+ import "node:fs";
12
+ import "magic-string";
13
+ import "vite";
14
+ import "react-dom/server";
15
+ import "react";
16
+ import "react/jsx-runtime";
17
+ import "node:stream";
18
+ import "node:stream/promises";
19
+ import "node:net";
20
+ import "node:crypto";
21
+ const H = 1, U = 1, q = [
22
+ "authorization-result",
23
+ "cookie-values",
24
+ "csrf-token",
25
+ "environment-values",
26
+ "rate-limit-state",
27
+ "request-headers",
28
+ "response-headers",
29
+ "session-record"
30
+ ];
31
+ async function k(t) {
32
+ const e = t.options ?? {}, r = await A(t.root, e), o = r.inspections.map((i) => W(r.routesDir, i)).sort((i, n) => i.file.localeCompare(n.file));
33
+ return {
34
+ findings: r.findings,
35
+ redactions: [],
36
+ request: q,
37
+ resolutions: {
38
+ findings: "static",
39
+ redactions: "static",
40
+ request: "request",
41
+ routes: "static"
42
+ },
43
+ routes: o,
44
+ routesDir: y(m(t.root, r.routesDir)),
45
+ version: H
46
+ };
47
+ }
48
+ function B(t) {
49
+ return Object.entries(t ?? {}).filter(([, e]) => e.sensitive).map(([e]) => e).sort();
50
+ }
51
+ function N(t) {
52
+ return t.findings.filter((e) => e.severity === "error").length;
53
+ }
54
+ function M(t) {
55
+ const e = N(t), r = t.findings.length - e;
56
+ return [
57
+ `Demiurge inspected ${t.routes.length} route files in ${t.routesDir}.`,
58
+ `Findings: ${e} error, ${r} warning.`,
59
+ `The report states ${t.request.length} facts that only a request supplies.`,
60
+ ...t.findings.map(
61
+ (o) => ` ${o.severity}: ${y(o.file)} [${o.code}] ${o.message}`
62
+ )
63
+ ].join(`
64
+ `);
65
+ }
66
+ function W(t, e) {
67
+ const r = y(m(t, e.file)), o = r.replace(/\.tsx?$/, "").split("/"), i = o.at(-1)?.startsWith("@") ?? !1;
68
+ return {
69
+ declaredAccess: e.accessState,
70
+ declaredDocumentCsp: e.documentCspState,
71
+ declaresDocumentPolicy: e.declaresDocumentPolicy,
72
+ file: r,
73
+ kind: i ? "attached" : e.declaresPageRoute ? "page" : "resource",
74
+ methods: e.methods,
75
+ ...i ? {} : { pattern: x(L(o)) }
76
+ };
77
+ }
78
+ function y(t) {
79
+ return t.split(v).join("/");
80
+ }
81
+ const G = 0, J = 1, K = 2;
82
+ async function Tt(t) {
83
+ if (t.arguments.length > 0)
84
+ return g(
85
+ "invalid-argument",
86
+ "The inspect command accepts no argument.",
87
+ `The command received ${t.arguments.join(" ")}.`
88
+ );
89
+ let e;
90
+ try {
91
+ e = await t.loadConfig();
92
+ } catch (o) {
93
+ return g(
94
+ "configuration-unreadable",
95
+ "Demiurge could not read the configuration.",
96
+ o instanceof Error ? o.message : String(o)
97
+ );
98
+ }
99
+ const r = await k({
100
+ options: C(e),
101
+ root: e.root
102
+ });
103
+ return {
104
+ exitCode: N(r) > 0 ? J : G,
105
+ stderr: M(r),
106
+ stdout: R(r, {
107
+ secretEnvKeys: B(e.env)
108
+ })
109
+ };
110
+ }
111
+ function g(t, e, r) {
112
+ const o = {
113
+ code: t,
114
+ detail: r,
115
+ title: e,
116
+ version: U
117
+ };
118
+ return {
119
+ exitCode: K,
120
+ stderr: `${e}
121
+ ${r}`,
122
+ stdout: R(o)
123
+ };
124
+ }
125
+ const X = /* @__PURE__ */ new Set(["--host", "--origin", "--out-dir", "--port"]), Y = "virtual:demiurge/client-entry", I = "virtual:demiurge/server-entry", w = "dist", b = "dist/server", z = ".demiurge/server";
126
+ function Rt(t, e = {}) {
9
127
  const r = t[0];
10
128
  if (!r || r === "--help" || r === "-h" || r === "help")
11
129
  return {
@@ -13,51 +131,57 @@ function J(t, e = {}) {
13
131
  host: "localhost",
14
132
  port: 4173
15
133
  };
16
- if (r !== "build" && r !== "dev" && r !== "preview")
134
+ if (r !== "build" && r !== "dev" && r !== "inspect" && r !== "preview" && r !== "start")
17
135
  throw new Error(`Unknown command: ${r}`);
18
136
  const o = {
19
137
  command: r,
20
- host: "localhost",
138
+ host: r === "start" ? e.HOST ?? "127.0.0.1" : "localhost",
21
139
  origin: e.SITE_ORIGIN,
22
140
  port: r === "dev" ? 5173 : 4173
23
141
  };
24
- for (let n = 1; n < t.length; n += 1) {
25
- const i = t[n];
26
- if (i === "--help" || i === "-h")
142
+ for (let i = 1; i < t.length; i += 1) {
143
+ const n = t[i];
144
+ if (n === "--help" || n === "-h")
27
145
  return { command: "help", host: "localhost", port: 4173 };
28
- const [s, c] = i.split("=", 2);
29
- if (!I.has(s))
30
- throw new Error(`Unknown option: ${i}`);
31
- const a = c ?? t[++n];
146
+ const [s, u] = n.split("=", 2);
147
+ if (!X.has(s))
148
+ throw new Error(`Unknown option: ${n}`);
149
+ const a = u ?? t[++i];
32
150
  if (!a || a.startsWith("--"))
33
151
  throw new Error(`Option ${s} requires a value.`);
34
152
  if (s === "--host" && (o.host = a), s === "--origin" && (o.origin = a), s === "--out-dir" && (o.outDir = a), s === "--port") {
35
- const u = Number(a);
36
- if (!Number.isSafeInteger(u) || u < 0 || u > 65535)
153
+ const c = Number(a);
154
+ if (!Number.isSafeInteger(c) || c < 0 || c > 65535)
37
155
  throw new Error("The server port must be an integer from 0 through 65535.");
38
- o.port = u;
156
+ o.port = c;
39
157
  }
40
158
  }
41
159
  return o;
42
160
  }
43
- const G = `Usage: demiurge <command> [options]
161
+ const Nt = `Usage: demiurge <command> [options]
44
162
 
45
163
  Commands:
46
164
  dev Start the development server
47
165
  build Build production output
166
+ start Run built Node production output
167
+ inspect Write the static inspection report as JSON
48
168
  preview Serve static output with its declared headers
49
169
 
50
170
  Options:
51
- --host <host> Set the server host (default: localhost)
171
+ --host <host> Set the server host (start: HOST or 127.0.0.1; otherwise: localhost)
52
172
  --origin <origin> Set the build origin (default: SITE_ORIGIN)
53
173
  --out-dir <directory> Set the client output directory (default: dist)
54
174
  --port <port> Set the server port (dev: 5173, preview: 4173)
55
175
  -h, --help Show this help
56
176
 
177
+ The inspect command writes JSON to standard output and a summary to standard
178
+ error. It exits with 0 for no error finding, 1 for at least one error finding,
179
+ and 2 for an invalid argument or an unreadable configuration.
180
+
57
181
  Demiurge reads demiurge.config.ts from the project root.`;
58
- async function H(t, e) {
182
+ async function It(t, e) {
59
183
  const { createServer: r } = await import("vite"), o = await r(
60
- await E({
184
+ await T({
61
185
  config: e,
62
186
  overrides: {
63
187
  mode: "development",
@@ -67,60 +191,121 @@ async function H(t, e) {
67
191
  );
68
192
  return await o.listen(), o;
69
193
  }
70
- async function Y(t, e, r) {
71
- const o = e.root, n = r?.build ?? (await import("vite")).build, i = r?.createViteConfig ?? ((d) => E({ config: e, overrides: d })), s = p(
194
+ async function bt(t, e, r) {
195
+ const o = e.root, i = r?.build ?? (await import("vite")).build, n = r?.createViteConfig ?? ((p) => T({ config: e, overrides: p })), s = d(
72
196
  o,
73
- t.outDir ?? e.deployment?.outDir ?? O
74
- ), c = p(o, U);
75
- await F(
197
+ t.outDir ?? e.deployment?.outDir ?? w
198
+ ), u = d(o, z);
199
+ await tt(
76
200
  o,
77
201
  s,
78
- D(o, "public"),
79
- c
80
- ), await n(
81
- await i({
202
+ O(o, "public"),
203
+ u
204
+ ), await i(
205
+ await n({
82
206
  define: { "process.env.NODE_ENV": JSON.stringify("production") },
83
207
  mode: "production",
84
208
  build: {
85
209
  emptyOutDir: !0,
86
210
  outDir: s,
87
- rollupOptions: { input: V }
211
+ rollupOptions: { input: Y }
88
212
  }
89
213
  })
90
214
  );
91
- const a = e.deployment?.server, u = a ? p(o, a.outDir ?? j) : void 0;
92
- return a && u && await n(
93
- await i({
215
+ const a = e.deployment?.server, c = a ? d(o, a.outDir ?? b) : void 0;
216
+ a && c && await i(
217
+ await n({
94
218
  define: { "process.env.NODE_ENV": JSON.stringify("production") },
95
219
  mode: "production",
96
220
  build: {
97
221
  copyPublicDir: !1,
98
222
  emptyOutDir: !0,
99
- outDir: u,
100
- rollupOptions: { input: p(o, a.entry) },
223
+ outDir: c,
224
+ rollupOptions: {
225
+ input: a.entry ? d(o, a.entry) : I,
226
+ output: { entryFileNames: "server-entry.js" }
227
+ },
101
228
  ssr: !0
102
- }
229
+ },
230
+ ...a.provider ? {
231
+ ssr: {
232
+ external: ["@demiurgejs/core", "react", "react-dom"],
233
+ noExternal: !0
234
+ }
235
+ } : {}
103
236
  })
104
- ), e.deployment?.static ? { ...await C({
105
- build: n,
237
+ );
238
+ const l = a?.provider;
239
+ if (l && a && c) {
240
+ if (e.security?.staticFileHeaders?.length)
241
+ throw new Error(
242
+ "Vercel Node deployment does not support security.staticFileHeaders. Remove the rules or use a deployment that serves the browser output directly."
243
+ );
244
+ return { deploymentOutDir: await F({
245
+ clientDir: s,
246
+ deployment: l,
247
+ projectRoot: o,
248
+ serverDir: c
249
+ }), outDir: s, serverOutDir: c };
250
+ }
251
+ return e.deployment?.static ? { ...await Z({
252
+ build: i,
106
253
  config: e,
107
- createViteConfig: i,
108
- frameworkServerOutDir: c,
254
+ createViteConfig: n,
255
+ frameworkServerOutDir: u,
109
256
  options: t,
110
257
  outDir: s,
111
258
  root: o,
112
259
  runtime: r
113
- }), outDir: s, serverOutDir: u } : { outDir: s, serverOutDir: u };
260
+ }), outDir: s, serverOutDir: c } : { outDir: s, serverOutDir: c };
261
+ }
262
+ async function _t(t, e, r = process.env, o) {
263
+ const i = e.deployment?.server;
264
+ if (!i)
265
+ throw new Error(
266
+ "The start command requires deployment.server in demiurge.config.ts."
267
+ );
268
+ const n = r.ALLOWED_HOSTS?.split(",").map((p) => p.trim()).filter(Boolean);
269
+ if (!n?.length)
270
+ throw new Error(
271
+ "The start command requires ALLOWED_HOSTS as a comma-separated host allowlist."
272
+ );
273
+ const s = e.root, u = d(
274
+ s,
275
+ t.outDir ?? e.deployment?.outDir ?? w
276
+ ), a = d(
277
+ s,
278
+ i.outDir ?? b
279
+ ), c = h(O(a, "server-entry.js")).href, l = o ? await o.importModule(c) : await import(c);
280
+ if (!Q(l))
281
+ throw new Error(
282
+ "The application server bundle does not export a Node build runtime."
283
+ );
284
+ return (o?.serve ?? (await import("./node/index.js")).serveNodeBuild)({
285
+ allowedHosts: n,
286
+ base: h(`${s}/`).href,
287
+ clientDir: m(s, u),
288
+ createHandler: l.createHandler,
289
+ env: r,
290
+ host: t.host,
291
+ port: t.port,
292
+ readyPath: "/.well-known/ready",
293
+ shutdown: { signals: ["SIGINT", "SIGTERM"] },
294
+ static: l.createStatic
295
+ });
296
+ }
297
+ function Q(t) {
298
+ return typeof t.createHandler == "function" && (t.createStatic === void 0 || typeof t.createStatic == "function");
114
299
  }
115
- async function C({
300
+ async function Z({
116
301
  build: t,
117
302
  config: e,
118
303
  createViteConfig: r,
119
304
  frameworkServerOutDir: o,
120
- options: n,
121
- outDir: i,
305
+ options: i,
306
+ outDir: n,
122
307
  root: s,
123
- runtime: c
308
+ runtime: u
124
309
  }) {
125
310
  await t(
126
311
  await r({
@@ -131,78 +316,83 @@ async function C({
131
316
  emptyOutDir: !0,
132
317
  outDir: o,
133
318
  rollupOptions: {
134
- input: _,
319
+ input: I,
135
320
  output: { entryFileNames: "server-entry.js" }
136
321
  },
137
322
  ssr: !0
138
323
  }
139
324
  })
140
325
  );
141
- const a = S(
142
- c ? await c.readText(p(i, "demiurge-manifest.json")) : await b(p(i, "demiurge-manifest.json"), "utf8")
143
- ), u = `${R(p(o, "server-entry.js")).href}?build=${c?.now() ?? Date.now()}`, l = c ? await c.importModule(u) : await import(u);
144
- if (!A(l.routes))
326
+ const a = $(
327
+ u ? await u.readText(d(n, "demiurge-manifest.json")) : await P(d(n, "demiurge-manifest.json"), "utf8")
328
+ ), c = `${h(d(o, "server-entry.js")).href}?build=${u?.now() ?? Date.now()}`, l = u ? await u.importModule(c) : await import(c);
329
+ if (!et(l.routes))
145
330
  throw new Error("The framework server bundle does not export routes.");
146
- const d = await (c?.generate ?? N)({
331
+ const f = await (u?.generate ?? j)({
147
332
  fonts: e.assets?.fonts,
148
333
  images: e.assets?.images,
149
- origin: n.origin ?? e.deployment?.static?.origin,
150
- outDir: i,
334
+ origin: i.origin ?? e.deployment?.static?.origin,
335
+ outDir: n,
151
336
  root: s,
152
337
  routes: l.routes,
153
338
  ssr: a,
154
339
  staticFileHeaders: e.security?.staticFileHeaders ?? []
155
- }), h = e.deployment?.static?.provider;
156
- return { deploymentOutDir: h ? await T({
157
- deployment: h,
158
- manifest: d,
159
- outDir: i,
340
+ }), p = e.deployment?.static?.provider;
341
+ return { deploymentOutDir: p ? await V({
342
+ deployment: p,
343
+ manifest: f,
344
+ outDir: n,
160
345
  projectRoot: s
161
- }) : void 0, manifest: d };
346
+ }) : void 0, manifest: f };
162
347
  }
163
- function q(t, e, r) {
164
- return p(t, e ?? r ?? O);
348
+ function Pt(t, e, r) {
349
+ return d(t, e ?? r ?? w);
165
350
  }
166
- async function F(t, e, r, o) {
167
- const n = m(t, e);
168
- if (!n || n === ".." || n.startsWith(`..${v}`) || y(n))
351
+ async function tt(t, e, r, o) {
352
+ const i = m(t, e);
353
+ if (!i || i === ".." || i.startsWith(`..${v}`) || D(i))
169
354
  throw new Error("The static output directory must be inside the Vite root.");
170
- if (r && f(e, r))
355
+ if (r && E(e, r))
171
356
  throw new Error("The static output directory must not overlap the Vite public directory.");
172
- if (f(e, o))
357
+ if (E(e, o))
173
358
  throw new Error("The static output directory must not overlap the framework server directory.");
174
- let i;
359
+ let n;
175
360
  try {
176
- i = await g(e);
361
+ n = await _(e);
177
362
  } catch (s) {
178
- if ($(s)) return;
363
+ if (rt(s)) return;
179
364
  throw s;
180
365
  }
181
- if (i.length && !i.includes("demiurge-manifest.json") && !i.includes("demiurge-static-manifest.json"))
366
+ if (n.length && !n.includes("demiurge-manifest.json") && !n.includes("demiurge-static-manifest.json"))
182
367
  throw new Error(
183
368
  "The static output directory contains files that a Demiurge build did not create."
184
369
  );
185
370
  }
186
- function A(t) {
371
+ function et(t) {
187
372
  return !t || typeof t != "object" || Array.isArray(t) ? !1 : Object.values(t).every((e) => typeof e == "function");
188
373
  }
189
- function f(t, e) {
374
+ function E(t, e) {
190
375
  const r = m(t, e), o = m(e, t);
191
- return w(r) || w(o);
376
+ return S(r) || S(o);
192
377
  }
193
- function w(t) {
194
- return !t || t !== ".." && !t.startsWith(`..${v}`) && !y(t);
378
+ function S(t) {
379
+ return !t || t !== ".." && !t.startsWith(`..${v}`) && !D(t);
195
380
  }
196
- function $(t) {
381
+ function rt(t) {
197
382
  return t instanceof Error && "code" in t && t.code === "ENOENT";
198
383
  }
199
384
  export {
200
- G as helpText,
201
- J as parseCliArguments,
202
- S as parseClientManifest,
203
- q as resolvePreviewOutputDirectory,
204
- Y as runBuild,
205
- H as runDev,
206
- F as validateBuildOutputDirectory
385
+ J as INSPECT_EXIT_FINDINGS,
386
+ K as INSPECT_EXIT_INVALID,
387
+ G as INSPECT_EXIT_OK,
388
+ Nt as helpText,
389
+ Rt as parseCliArguments,
390
+ $ as parseClientManifest,
391
+ Pt as resolvePreviewOutputDirectory,
392
+ bt as runBuild,
393
+ It as runDev,
394
+ Tt as runInspectCommand,
395
+ _t as runStart,
396
+ tt as validateBuildOutputDirectory
207
397
  };
208
398
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["import { readFile, readdir } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { InlineConfig } from \"vite\";\nimport { createDemiurgeViteConfig } from \"./config/vite\";\nimport type { ResolvedDemiurgeConfig } from \"./config/types\";\nimport { parseClientManifest } from \"./manifest\";\nimport type { RouteImporter } from \"./route\";\nimport {\n generateVercelStaticOutput,\n generateStaticOutput,\n type GenerateStaticOutputOptions,\n type StaticOutputManifest,\n} from \"./static\";\n\nexport { parseClientManifest } from \"./manifest\";\nexport type { ClientBuildManifest } from \"./manifest\";\n\ntype CliEnvironment = Record<string, string | undefined>;\n\nconst cliOptionNames = new Set([\"--host\", \"--origin\", \"--out-dir\", \"--port\"]);\n\nconst CLIENT_ENTRY = \"virtual:demiurge/client-entry\";\nconst SERVER_ENTRY = \"virtual:demiurge/server-entry\";\nconst DEFAULT_CLIENT_OUT_DIR = \"dist\";\nconst DEFAULT_SERVER_OUT_DIR = \"dist/server\";\nconst FRAMEWORK_SERVER_OUT_DIR = \".demiurge/server\";\n\nexport type CliOptions = {\n command: \"build\" | \"dev\" | \"help\" | \"preview\";\n host: string;\n origin?: string;\n outDir?: string;\n port: number;\n};\n\nexport type BuildRuntime = {\n build: (config: InlineConfig) => Promise<unknown>;\n createViteConfig: (overrides: InlineConfig) => Promise<InlineConfig>;\n generate: (\n options: GenerateStaticOutputOptions,\n ) => Promise<StaticOutputManifest>;\n importModule: (specifier: string) => Promise<Record<string, unknown>>;\n now: () => number;\n readText: (file: string) => Promise<string>;\n};\n\nexport type BuildResult = {\n deploymentOutDir?: string;\n manifest?: StaticOutputManifest;\n outDir: string;\n serverOutDir?: string;\n};\n\nexport function parseCliArguments(\n arguments_: string[],\n environment: CliEnvironment = {},\n): CliOptions {\n const command = arguments_[0];\n if (!command || command === \"--help\" || command === \"-h\" || command === \"help\") {\n return {\n command: \"help\",\n host: \"localhost\",\n port: 4173,\n };\n }\n if (command !== \"build\" && command !== \"dev\" && command !== \"preview\") {\n throw new Error(`Unknown command: ${command}`);\n }\n\n const options: CliOptions = {\n command,\n host: \"localhost\",\n origin: environment.SITE_ORIGIN,\n port: command === \"dev\" ? 5173 : 4173,\n };\n\n for (let index = 1; index < arguments_.length; index += 1) {\n const argument = arguments_[index]!;\n if (argument === \"--help\" || argument === \"-h\") {\n return { command: \"help\", host: \"localhost\", port: 4173 };\n }\n const [name, inlineValue] = argument.split(\"=\", 2);\n if (!cliOptionNames.has(name!)) {\n throw new Error(`Unknown option: ${argument}`);\n }\n const value = inlineValue ?? arguments_[++index];\n if (!value || value.startsWith(\"--\")) {\n throw new Error(`Option ${name} requires a value.`);\n }\n\n if (name === \"--host\") options.host = value;\n if (name === \"--origin\") options.origin = value;\n if (name === \"--out-dir\") options.outDir = value;\n if (name === \"--port\") {\n const port = Number(value);\n if (!Number.isSafeInteger(port) || port < 0 || port > 65_535) {\n throw new Error(\"The server port must be an integer from 0 through 65535.\");\n }\n options.port = port;\n }\n }\n\n return options;\n}\n\nexport const helpText = `Usage: demiurge <command> [options]\n\nCommands:\n dev Start the development server\n build Build production output\n preview Serve static output with its declared headers\n\nOptions:\n --host <host> Set the server host (default: localhost)\n --origin <origin> Set the build origin (default: SITE_ORIGIN)\n --out-dir <directory> Set the client output directory (default: dist)\n --port <port> Set the server port (dev: 5173, preview: 4173)\n -h, --help Show this help\n\nDemiurge reads demiurge.config.ts from the project root.`;\n\nexport async function runDev(\n options: CliOptions,\n config: ResolvedDemiurgeConfig,\n) {\n const { createServer } = await import(\"vite\");\n const server = await createServer(\n await createDemiurgeViteConfig({\n config,\n overrides: {\n mode: \"development\",\n server: { host: options.host, port: options.port },\n },\n }),\n );\n await server.listen();\n return server;\n}\n\nexport async function runBuild(\n options: CliOptions,\n config: ResolvedDemiurgeConfig,\n runtime?: BuildRuntime,\n): Promise<BuildResult> {\n const root = config.root;\n const build = runtime?.build ?? (await import(\"vite\")).build;\n const createViteConfig = runtime?.createViteConfig ??\n ((overrides: InlineConfig) => createDemiurgeViteConfig({ config, overrides }));\n\n const outDir = resolve(\n root,\n options.outDir ?? config.deployment?.outDir ?? DEFAULT_CLIENT_OUT_DIR,\n );\n const frameworkServerOutDir = resolve(root, FRAMEWORK_SERVER_OUT_DIR);\n\n await validateBuildOutputDirectory(\n root,\n outDir,\n join(root, \"public\"),\n frameworkServerOutDir,\n );\n\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n emptyOutDir: true,\n outDir,\n rollupOptions: { input: CLIENT_ENTRY },\n },\n }),\n );\n\n const applicationServer = config.deployment?.server;\n const serverOutDir = applicationServer\n ? resolve(root, applicationServer.outDir ?? DEFAULT_SERVER_OUT_DIR)\n : undefined;\n\n if (applicationServer && serverOutDir) {\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n copyPublicDir: false,\n emptyOutDir: true,\n outDir: serverOutDir,\n rollupOptions: { input: resolve(root, applicationServer.entry) },\n ssr: true,\n },\n }),\n );\n }\n\n if (!config.deployment?.static) return { outDir, serverOutDir };\n\n const staticResult = await buildStaticOutput({\n build,\n config,\n createViteConfig,\n frameworkServerOutDir,\n options,\n outDir,\n root,\n runtime,\n });\n\n return { ...staticResult, outDir, serverOutDir };\n}\n\nasync function buildStaticOutput({\n build,\n config,\n createViteConfig,\n frameworkServerOutDir,\n options,\n outDir,\n root,\n runtime,\n}: {\n build: (config: InlineConfig) => Promise<unknown>;\n config: ResolvedDemiurgeConfig;\n createViteConfig: (overrides: InlineConfig) => Promise<InlineConfig>;\n frameworkServerOutDir: string;\n options: CliOptions;\n outDir: string;\n root: string;\n runtime?: BuildRuntime;\n}) {\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n copyPublicDir: false,\n emptyOutDir: true,\n outDir: frameworkServerOutDir,\n rollupOptions: {\n input: SERVER_ENTRY,\n output: { entryFileNames: \"server-entry.js\" },\n },\n ssr: true,\n },\n }),\n );\n\n const clientManifest = parseClientManifest(\n runtime\n ? await runtime.readText(resolve(outDir, \"demiurge-manifest.json\"))\n : await readFile(resolve(outDir, \"demiurge-manifest.json\"), \"utf8\"),\n );\n const serverEntryUrl = `${\n pathToFileURL(resolve(frameworkServerOutDir, \"server-entry.js\")).href\n }?build=${runtime?.now() ?? Date.now()}`;\n const serverEntry = runtime\n ? await runtime.importModule(serverEntryUrl)\n : await import(serverEntryUrl);\n if (!isRouteImporterRecord(serverEntry.routes)) {\n throw new Error(\"The framework server bundle does not export routes.\");\n }\n\n const manifest = await (runtime?.generate ?? generateStaticOutput)({\n fonts: config.assets?.fonts,\n images: config.assets?.images,\n origin: options.origin ?? config.deployment?.static?.origin,\n outDir,\n root,\n routes: serverEntry.routes,\n ssr: clientManifest,\n staticFileHeaders: config.security?.staticFileHeaders ?? [],\n });\n\n const provider = config.deployment?.static?.provider;\n const deploymentOutDir = provider\n ? await generateVercelStaticOutput({\n deployment: provider,\n manifest,\n outDir,\n projectRoot: root,\n })\n : undefined;\n\n return { deploymentOutDir, manifest };\n}\n\nexport function resolvePreviewOutputDirectory(\n root: string,\n outDir: string | undefined,\n configuredOutDir?: string,\n) {\n return resolve(root, outDir ?? configuredOutDir ?? DEFAULT_CLIENT_OUT_DIR);\n}\n\nexport async function validateBuildOutputDirectory(\n root: string,\n outDir: string,\n publicDir: false | string,\n serverOutDir: string,\n) {\n const pathFromRoot = relative(root, outDir);\n if (\n !pathFromRoot ||\n pathFromRoot === \"..\" ||\n pathFromRoot.startsWith(`..${sep}`) ||\n isAbsolute(pathFromRoot)\n ) {\n throw new Error(\"The static output directory must be inside the Vite root.\");\n }\n\n if (publicDir && pathsOverlap(outDir, publicDir)) {\n throw new Error(\"The static output directory must not overlap the Vite public directory.\");\n }\n\n if (pathsOverlap(outDir, serverOutDir)) {\n throw new Error(\"The static output directory must not overlap the framework server directory.\");\n }\n\n let entries: string[];\n try {\n entries = await readdir(outDir);\n } catch (error) {\n if (isMissingPath(error)) return;\n throw error;\n }\n\n if (\n entries.length &&\n !entries.includes(\"demiurge-manifest.json\") &&\n !entries.includes(\"demiurge-static-manifest.json\")\n ) {\n throw new Error(\n \"The static output directory contains files that a Demiurge build did not create.\",\n );\n }\n}\n\nfunction isRouteImporterRecord(\n value: unknown,\n): value is Record<string, RouteImporter> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n\n return Object.values(value).every((load) => typeof load === \"function\");\n}\n\nfunction pathsOverlap(left: string, right: string) {\n const fromLeft = relative(left, right);\n const fromRight = relative(right, left);\n return isSameOrChildPath(fromLeft) || isSameOrChildPath(fromRight);\n}\n\nfunction isSameOrChildPath(pathname: string) {\n return !pathname ||\n (pathname !== \"..\" && !pathname.startsWith(`..${sep}`) &&\n !isAbsolute(pathname));\n}\n\nfunction isMissingPath(error: unknown) {\n return error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n"],"names":["cliOptionNames","CLIENT_ENTRY","SERVER_ENTRY","DEFAULT_CLIENT_OUT_DIR","DEFAULT_SERVER_OUT_DIR","FRAMEWORK_SERVER_OUT_DIR","parseCliArguments","arguments_","environment","command","options","index","argument","name","inlineValue","value","port","helpText","runDev","config","createServer","server","createDemiurgeViteConfig","runBuild","runtime","root","build","createViteConfig","overrides","outDir","resolve","frameworkServerOutDir","validateBuildOutputDirectory","join","applicationServer","serverOutDir","buildStaticOutput","clientManifest","parseClientManifest","readFile","serverEntryUrl","pathToFileURL","serverEntry","isRouteImporterRecord","manifest","generateStaticOutput","provider","generateVercelStaticOutput","resolvePreviewOutputDirectory","configuredOutDir","publicDir","pathFromRoot","relative","sep","isAbsolute","pathsOverlap","entries","readdir","error","isMissingPath","load","left","right","fromLeft","fromRight","isSameOrChildPath","pathname"],"mappings":";;;;;;AAoBA,MAAMA,wBAAqB,IAAI,CAAC,UAAU,YAAY,aAAa,QAAQ,CAAC,GAEtEC,IAAe,iCACfC,IAAe,iCACfC,IAAyB,QACzBC,IAAyB,eACzBC,IAA2B;AA4B1B,SAASC,EACdC,GACAC,IAA8B,IAClB;AACZ,QAAMC,IAAUF,EAAW,CAAC;AAC5B,MAAI,CAACE,KAAWA,MAAY,YAAYA,MAAY,QAAQA,MAAY;AACtE,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAGV,MAAIA,MAAY,WAAWA,MAAY,SAASA,MAAY;AAC1D,UAAM,IAAI,MAAM,oBAAoBA,CAAO,EAAE;AAG/C,QAAMC,IAAsB;AAAA,IAC1B,SAAAD;AAAA,IACA,MAAM;AAAA,IACN,QAAQD,EAAY;AAAA,IACpB,MAAMC,MAAY,QAAQ,OAAO;AAAA,EAAA;AAGnC,WAASE,IAAQ,GAAGA,IAAQJ,EAAW,QAAQI,KAAS,GAAG;AACzD,UAAMC,IAAWL,EAAWI,CAAK;AACjC,QAAIC,MAAa,YAAYA,MAAa;AACxC,aAAO,EAAE,SAAS,QAAQ,MAAM,aAAa,MAAM,KAAA;AAErD,UAAM,CAACC,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AOI,EAAkBF,CAAQ,KAAKE,EAAkBD,CAAS;AACnE;AAEA,SAASC,EAAkBC,GAAkB;AAC3C,SAAO,CAACA,KACLA,MAAa,QAAQ,CAACA,EAAS,WAAW,KAAKb,CAAG,EAAE,KACnD,CAACC,EAAWY,CAAQ;AAC1B;AAEA,SAASP,EAAcD,GAAgB;AACrC,SAAOA,aAAiB,SAAS,UAAUA,KAASA,EAAM,SAAS;AACrE;"}
1
+ {"version":3,"file":"cli.js","sources":["../src/inspect/types.ts","../src/inspect/report.ts","../src/inspect/command.ts","../src/cli.ts"],"sourcesContent":["import type { HttpMethod } from \"../route\";\nimport type {\n DocumentCspState,\n RouteAccessState,\n StaticPolicyFinding,\n} from \"../vite/policy-verification\";\n\n/**\n * The version of the static policy report. ADR 0019 raises this integer when\n * the framework removes a field or changes the meaning of a field.\n */\nexport const STATIC_POLICY_REPORT_VERSION = 1;\n\n/**\n * The version of the problem document that the inspect command writes when it\n * cannot produce a report.\n */\nexport const INSPECTION_PROBLEM_VERSION = 1;\n\n/**\n * The origin of one fact in a report. The value `static` states that the build\n * knows the fact. The value `request` states that only a request supplies it.\n */\nexport type InspectionResolution = \"request\" | \"static\";\n\n/** The rule that removed one value from a report. */\nexport type InspectionRedactionReason =\n /** A cookie holds the value. */\n | \"cookie-value\"\n /** An `env.secret(...)` declaration produced the value. */\n | \"environment-secret\"\n /** A session record holds the value. */\n | \"session-record\";\n\n/** One value that the serializer removed from a report. */\nexport type InspectionRedaction = {\n /** The name of the field that held the value. */\n name: string;\n /** The dotted path of the field inside the report. */\n path: string;\n /** The rule that removed the value. */\n reason: InspectionRedactionReason;\n};\n\n/** The named sections of the static policy report. */\nexport type StaticPolicyReportSection =\n | \"findings\"\n | \"redactions\"\n | \"request\"\n | \"routes\";\n\n/** The kind of route file that the static pass read. */\nexport type StaticRouteKind = \"attached\" | \"page\" | \"resource\";\n\n/**\n * The statically readable description of one route file.\n *\n * Each declared field states what the file itself declares. The framework\n * resolves the cascade of the route tree and reports the result of the\n * cascade in the `findings` section.\n */\nexport type StaticRouteReport = {\n /** The access state that the route file declares. */\n declaredAccess: RouteAccessState;\n /** The Content-Security-Policy state that the route file declares. */\n declaredDocumentCsp: DocumentCspState;\n /** `true` when the route file declares a document policy. */\n declaresDocumentPolicy: boolean;\n /** The path of the route file, relative to the route directory. */\n file: string;\n /** The kind of the route file. */\n kind: StaticRouteKind;\n /** The HTTP methods that the route file exports. */\n methods: HttpMethod[];\n /** The route pattern. An attached file has no pattern. */\n pattern?: string;\n};\n\n/**\n * The report that `demiurge inspect` writes to standard output. Each section\n * states the resolution of its facts in the `resolutions` record.\n */\nexport type StaticPolicyReport = {\n /** The static policy findings, sorted by file, export name, and code. */\n findings: StaticPolicyFinding[];\n /** The values that the serializer removed. */\n redactions: InspectionRedaction[];\n /** The names of the facts that only a request supplies. */\n request: string[];\n /** The resolution of each section of the report. */\n resolutions: Record<StaticPolicyReportSection, InspectionResolution>;\n /** Every route file under the route directory. */\n routes: StaticRouteReport[];\n /** The route directory, relative to the project root. */\n routesDir: string;\n /** The version of this report shape. */\n version: number;\n};\n\n/** The reason that the inspect command could not produce a report. */\nexport type InspectionProblemCode =\n /** The framework could not read the configuration. */\n | \"configuration-unreadable\"\n /** The command received an invalid argument. */\n | \"invalid-argument\";\n\n/**\n * The document that the inspect command writes when it cannot produce a\n * report. The command then exits with code 2.\n */\nexport type InspectionProblem = {\n /** The stable code of the condition. */\n code: InspectionProblemCode;\n /** The description of the condition. */\n detail: string;\n /** The short name of the condition. */\n title: string;\n /** The version of this problem shape. */\n version: number;\n};\n","import { relative, sep } from \"node:path\";\nimport { toRoutePattern, toRouteSegments } from \"../router\";\nimport type { EnvSchema } from \"../security\";\nimport {\n inspectRoutePolicies,\n type DemiurgeVitePluginOptions,\n} from \"../vite/plugin\";\nimport type { RouteFileInspection } from \"../vite/policy-verification\";\nimport {\n STATIC_POLICY_REPORT_VERSION,\n type StaticPolicyReport,\n type StaticRouteReport,\n} from \"./types\";\n\nexport type StaticPolicyReportOptions = {\n /** The plugin options of the application. */\n options?: DemiurgeVitePluginOptions;\n /** The absolute path of the project root. */\n root: string;\n};\n\n// A build knows the route tree and the policy cascade. It does not know a\n// header, a cookie, a session, or an authorization result, because a request\n// supplies each one. The report names these facts, so a reader learns which\n// answer needs a running application.\nconst requestFacts = [\n \"authorization-result\",\n \"cookie-values\",\n \"csrf-token\",\n \"environment-values\",\n \"rate-limit-state\",\n \"request-headers\",\n \"response-headers\",\n \"session-record\",\n];\n\n/**\n * Builds the static inspection report of an application.\n *\n * The function reads the route tree and resolves the policy cascade through\n * `inspectRoutePolicies`. It loads no route module, so it runs no data loader\n * and no mutation handler.\n */\nexport async function createStaticPolicyReport(\n input: StaticPolicyReportOptions,\n): Promise<StaticPolicyReport> {\n const options = input.options ?? {};\n const pass = await inspectRoutePolicies(input.root, options);\n const routes = pass.inspections\n .map((inspection) => toStaticRouteReport(pass.routesDir, inspection))\n .sort((left, right) => left.file.localeCompare(right.file));\n\n return {\n findings: pass.findings,\n redactions: [],\n request: requestFacts,\n resolutions: {\n findings: \"static\",\n redactions: \"static\",\n request: \"request\",\n routes: \"static\",\n },\n routes,\n routesDir: toPosixPath(relative(input.root, pass.routesDir)),\n version: STATIC_POLICY_REPORT_VERSION,\n };\n}\n\n/** Reads the names of the variables that `env.secret(...)` declared. */\nexport function findSecretEnvKeys(schema: EnvSchema | undefined) {\n return Object.entries(schema ?? {})\n .filter(([, variable]) => variable.sensitive)\n .map(([key]) => key)\n .sort();\n}\n\n/** Counts the findings that carry error severity. */\nexport function countErrorFindings(report: StaticPolicyReport) {\n return report.findings.filter((finding) => finding.severity === \"error\")\n .length;\n}\n\n/** Writes the human summary that the command sends to standard error. */\nexport function formatStaticPolicyReportSummary(report: StaticPolicyReport) {\n const errors = countErrorFindings(report);\n const warnings = report.findings.length - errors;\n\n return [\n `Demiurge inspected ${report.routes.length} route files in ${report.routesDir}.`,\n `Findings: ${errors} error, ${warnings} warning.`,\n `The report states ${report.request.length} facts that only a request supplies.`,\n ...report.findings.map((finding) =>\n ` ${finding.severity}: ${toPosixPath(finding.file)} [${finding.code}] ${finding.message}`\n ),\n ].join(\"\\n\");\n}\n\nfunction toStaticRouteReport(\n routesDir: string,\n inspection: RouteFileInspection,\n): StaticRouteReport {\n const file = toPosixPath(relative(routesDir, inspection.file));\n const fileSegments = file.replace(/\\.tsx?$/, \"\").split(\"/\");\n const attached = fileSegments.at(-1)?.startsWith(\"@\") ?? false;\n\n return {\n declaredAccess: inspection.accessState,\n declaredDocumentCsp: inspection.documentCspState,\n declaresDocumentPolicy: inspection.declaresDocumentPolicy,\n file,\n kind: attached\n ? \"attached\"\n : inspection.declaresPageRoute\n ? \"page\"\n : \"resource\",\n methods: inspection.methods,\n ...(attached\n ? {}\n : { pattern: toRoutePattern(toRouteSegments(fileSegments)) }),\n };\n}\n\nfunction toPosixPath(pathname: string) {\n return pathname.split(sep).join(\"/\");\n}\n","import type { ResolvedDemiurgeConfig } from \"../config/types\";\nimport { toPluginOptions } from \"../config/vite\";\nimport {\n countErrorFindings,\n createStaticPolicyReport,\n findSecretEnvKeys,\n formatStaticPolicyReportSummary,\n} from \"./report\";\nimport { serializeInspectionReport } from \"./redact\";\nimport {\n INSPECTION_PROBLEM_VERSION,\n type InspectionProblem,\n type InspectionProblemCode,\n} from \"./types\";\n\n/** The exit codes of the `demiurge inspect` command. */\nexport const INSPECT_EXIT_OK = 0;\nexport const INSPECT_EXIT_FINDINGS = 1;\nexport const INSPECT_EXIT_INVALID = 2;\n\nexport type InspectCommandInput = {\n /** The arguments that follow the command name. */\n arguments: readonly string[];\n /** Reads the configuration of the application. */\n loadConfig: () => Promise<ResolvedDemiurgeConfig>;\n};\n\nexport type InspectCommandResult = {\n /** The exit code of the command. */\n exitCode: number;\n /** The human summary that the command writes to standard error. */\n stderr: string;\n /** The JSON document that the command writes to standard output. */\n stdout: string;\n};\n\n/**\n * Runs the `demiurge inspect` command.\n *\n * The command reads the route tree, resolves the policy cascade, and returns\n * one JSON document. The command loads no route module, so it runs no data\n * loader and no mutation handler.\n */\nexport async function runInspectCommand(\n input: InspectCommandInput,\n): Promise<InspectCommandResult> {\n if (input.arguments.length > 0) {\n return toProblemResult(\n \"invalid-argument\",\n \"The inspect command accepts no argument.\",\n `The command received ${input.arguments.join(\" \")}.`,\n );\n }\n\n let config: ResolvedDemiurgeConfig;\n\n try {\n config = await input.loadConfig();\n } catch (error) {\n return toProblemResult(\n \"configuration-unreadable\",\n \"Demiurge could not read the configuration.\",\n error instanceof Error ? error.message : String(error),\n );\n }\n\n const report = await createStaticPolicyReport({\n options: toPluginOptions(config),\n root: config.root,\n });\n\n return {\n exitCode: countErrorFindings(report) > 0\n ? INSPECT_EXIT_FINDINGS\n : INSPECT_EXIT_OK,\n stderr: formatStaticPolicyReportSummary(report),\n stdout: serializeInspectionReport(report, {\n secretEnvKeys: findSecretEnvKeys(config.env),\n }),\n };\n}\n\nfunction toProblemResult(\n code: InspectionProblemCode,\n title: string,\n detail: string,\n): InspectCommandResult {\n const problem: InspectionProblem = {\n code,\n detail,\n title,\n version: INSPECTION_PROBLEM_VERSION,\n };\n\n return {\n exitCode: INSPECT_EXIT_INVALID,\n stderr: `${title}\\n${detail}`,\n stdout: serializeInspectionReport(problem),\n };\n}\n","import { readFile, readdir } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { InlineConfig } from \"vite\";\nimport { createDemiurgeViteConfig } from \"./config/vite\";\nimport type { ResolvedDemiurgeConfig } from \"./config/types\";\nimport { parseClientManifest } from \"./manifest\";\nimport type { NodeBuildRuntime, ServeNodeBuildOptions } from \"./node\";\nimport type { RouteImporter } from \"./route\";\nimport {\n generateVercelStaticOutput,\n generateStaticOutput,\n type GenerateStaticOutputOptions,\n type StaticOutputManifest,\n} from \"./static\";\nimport { generateVercelNodeOutput } from \"./vercel\";\n\nexport { parseClientManifest } from \"./manifest\";\nexport type { ClientBuildManifest } from \"./manifest\";\nexport {\n INSPECT_EXIT_FINDINGS,\n INSPECT_EXIT_INVALID,\n INSPECT_EXIT_OK,\n runInspectCommand,\n} from \"./inspect\";\nexport type { InspectCommandResult } from \"./inspect\";\n\ntype CliEnvironment = Record<string, string | undefined>;\n\nconst cliOptionNames = new Set([\"--host\", \"--origin\", \"--out-dir\", \"--port\"]);\n\nconst CLIENT_ENTRY = \"virtual:demiurge/client-entry\";\nconst SERVER_ENTRY = \"virtual:demiurge/server-entry\";\nconst DEFAULT_CLIENT_OUT_DIR = \"dist\";\nconst DEFAULT_SERVER_OUT_DIR = \"dist/server\";\nconst FRAMEWORK_SERVER_OUT_DIR = \".demiurge/server\";\n\nexport type CliOptions = {\n command: \"build\" | \"dev\" | \"help\" | \"inspect\" | \"preview\" | \"start\";\n host: string;\n origin?: string;\n outDir?: string;\n port: number;\n};\n\nexport type BuildRuntime = {\n build: (config: InlineConfig) => Promise<unknown>;\n createViteConfig: (overrides: InlineConfig) => Promise<InlineConfig>;\n generate: (\n options: GenerateStaticOutputOptions,\n ) => Promise<StaticOutputManifest>;\n importModule: (specifier: string) => Promise<Record<string, unknown>>;\n now: () => number;\n readText: (file: string) => Promise<string>;\n};\n\nexport type BuildResult = {\n deploymentOutDir?: string;\n manifest?: StaticOutputManifest;\n outDir: string;\n serverOutDir?: string;\n};\n\nexport type StartRuntime = {\n importModule: (specifier: string) => Promise<Record<string, unknown>>;\n serve: (options: ServeNodeBuildOptions) => Promise<unknown>;\n};\n\nexport function parseCliArguments(\n arguments_: string[],\n environment: CliEnvironment = {},\n): CliOptions {\n const command = arguments_[0];\n if (!command || command === \"--help\" || command === \"-h\" || command === \"help\") {\n return {\n command: \"help\",\n host: \"localhost\",\n port: 4173,\n };\n }\n if (\n command !== \"build\" && command !== \"dev\" && command !== \"inspect\" &&\n command !== \"preview\" && command !== \"start\"\n ) {\n throw new Error(`Unknown command: ${command}`);\n }\n\n const options: CliOptions = {\n command,\n host: command === \"start\" ? environment.HOST ?? \"127.0.0.1\" : \"localhost\",\n origin: environment.SITE_ORIGIN,\n port: command === \"dev\" ? 5173 : 4173,\n };\n\n for (let index = 1; index < arguments_.length; index += 1) {\n const argument = arguments_[index]!;\n if (argument === \"--help\" || argument === \"-h\") {\n return { command: \"help\", host: \"localhost\", port: 4173 };\n }\n const [name, inlineValue] = argument.split(\"=\", 2);\n if (!cliOptionNames.has(name!)) {\n throw new Error(`Unknown option: ${argument}`);\n }\n const value = inlineValue ?? arguments_[++index];\n if (!value || value.startsWith(\"--\")) {\n throw new Error(`Option ${name} requires a value.`);\n }\n\n if (name === \"--host\") options.host = value;\n if (name === \"--origin\") options.origin = value;\n if (name === \"--out-dir\") options.outDir = value;\n if (name === \"--port\") {\n const port = Number(value);\n if (!Number.isSafeInteger(port) || port < 0 || port > 65_535) {\n throw new Error(\"The server port must be an integer from 0 through 65535.\");\n }\n options.port = port;\n }\n }\n\n return options;\n}\n\nexport const helpText = `Usage: demiurge <command> [options]\n\nCommands:\n dev Start the development server\n build Build production output\n start Run built Node production output\n inspect Write the static inspection report as JSON\n preview Serve static output with its declared headers\n\nOptions:\n --host <host> Set the server host (start: HOST or 127.0.0.1; otherwise: localhost)\n --origin <origin> Set the build origin (default: SITE_ORIGIN)\n --out-dir <directory> Set the client output directory (default: dist)\n --port <port> Set the server port (dev: 5173, preview: 4173)\n -h, --help Show this help\n\nThe inspect command writes JSON to standard output and a summary to standard\nerror. It exits with 0 for no error finding, 1 for at least one error finding,\nand 2 for an invalid argument or an unreadable configuration.\n\nDemiurge reads demiurge.config.ts from the project root.`;\n\nexport async function runDev(\n options: CliOptions,\n config: ResolvedDemiurgeConfig,\n) {\n const { createServer } = await import(\"vite\");\n const server = await createServer(\n await createDemiurgeViteConfig({\n config,\n overrides: {\n mode: \"development\",\n server: { host: options.host, port: options.port },\n },\n }),\n );\n await server.listen();\n return server;\n}\n\nexport async function runBuild(\n options: CliOptions,\n config: ResolvedDemiurgeConfig,\n runtime?: BuildRuntime,\n): Promise<BuildResult> {\n const root = config.root;\n const build = runtime?.build ?? (await import(\"vite\")).build;\n const createViteConfig = runtime?.createViteConfig ??\n ((overrides: InlineConfig) => createDemiurgeViteConfig({ config, overrides }));\n\n const outDir = resolve(\n root,\n options.outDir ?? config.deployment?.outDir ?? DEFAULT_CLIENT_OUT_DIR,\n );\n const frameworkServerOutDir = resolve(root, FRAMEWORK_SERVER_OUT_DIR);\n\n await validateBuildOutputDirectory(\n root,\n outDir,\n join(root, \"public\"),\n frameworkServerOutDir,\n );\n\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n emptyOutDir: true,\n outDir,\n rollupOptions: { input: CLIENT_ENTRY },\n },\n }),\n );\n\n const applicationServer = config.deployment?.server;\n const serverOutDir = applicationServer\n ? resolve(root, applicationServer.outDir ?? DEFAULT_SERVER_OUT_DIR)\n : undefined;\n\n if (applicationServer && serverOutDir) {\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n copyPublicDir: false,\n emptyOutDir: true,\n outDir: serverOutDir,\n rollupOptions: {\n input: applicationServer.entry\n ? resolve(root, applicationServer.entry)\n : SERVER_ENTRY,\n output: { entryFileNames: \"server-entry.js\" },\n },\n ssr: true,\n },\n ...(applicationServer.provider\n ? {\n ssr: {\n external: [\"@demiurgejs/core\", \"react\", \"react-dom\"],\n noExternal: true,\n },\n }\n : {}),\n }),\n );\n }\n\n const provider = applicationServer?.provider;\n if (provider && applicationServer && serverOutDir) {\n if (config.security?.staticFileHeaders?.length) {\n throw new Error(\n \"Vercel Node deployment does not support security.staticFileHeaders. Remove the rules or use a deployment that serves the browser output directly.\",\n );\n }\n const deploymentOutDir = await generateVercelNodeOutput({\n clientDir: outDir,\n deployment: provider,\n projectRoot: root,\n serverDir: serverOutDir,\n });\n return { deploymentOutDir, outDir, serverOutDir };\n }\n\n if (!config.deployment?.static) return { outDir, serverOutDir };\n\n const staticResult = await buildStaticOutput({\n build,\n config,\n createViteConfig,\n frameworkServerOutDir,\n options,\n outDir,\n root,\n runtime,\n });\n\n return { ...staticResult, outDir, serverOutDir };\n}\n\nexport async function runStart(\n options: CliOptions,\n config: ResolvedDemiurgeConfig,\n environment: CliEnvironment = process.env,\n runtime?: StartRuntime,\n) {\n const applicationServer = config.deployment?.server;\n if (!applicationServer) {\n throw new Error(\n \"The start command requires deployment.server in demiurge.config.ts.\",\n );\n }\n\n const allowedHosts = environment.ALLOWED_HOSTS\n ?.split(\",\")\n .map((value) => value.trim())\n .filter(Boolean);\n if (!allowedHosts?.length) {\n throw new Error(\n \"The start command requires ALLOWED_HOSTS as a comma-separated host allowlist.\",\n );\n }\n\n const root = config.root;\n const clientDir = resolve(\n root,\n options.outDir ?? config.deployment?.outDir ?? DEFAULT_CLIENT_OUT_DIR,\n );\n const serverOutDir = resolve(\n root,\n applicationServer.outDir ?? DEFAULT_SERVER_OUT_DIR,\n );\n const serverEntryUrl = pathToFileURL(join(serverOutDir, \"server-entry.js\")).href;\n const serverEntry = runtime\n ? await runtime.importModule(serverEntryUrl)\n : await import(serverEntryUrl);\n if (!isNodeBuildRuntime(serverEntry)) {\n throw new Error(\n \"The application server bundle does not export a Node build runtime.\",\n );\n }\n\n const serve = runtime?.serve ?? (await import(\"./node\")).serveNodeBuild;\n return serve({\n allowedHosts,\n base: pathToFileURL(`${root}/`).href,\n clientDir: relative(root, clientDir),\n createHandler: serverEntry.createHandler,\n env: environment,\n host: options.host,\n port: options.port,\n readyPath: \"/.well-known/ready\",\n shutdown: { signals: [\"SIGINT\", \"SIGTERM\"] },\n static: serverEntry.createStatic,\n });\n}\n\nfunction isNodeBuildRuntime(value: Record<string, unknown>): value is NodeBuildRuntime {\n return typeof value.createHandler === \"function\" &&\n (value.createStatic === undefined || typeof value.createStatic === \"function\");\n}\n\nasync function buildStaticOutput({\n build,\n config,\n createViteConfig,\n frameworkServerOutDir,\n options,\n outDir,\n root,\n runtime,\n}: {\n build: (config: InlineConfig) => Promise<unknown>;\n config: ResolvedDemiurgeConfig;\n createViteConfig: (overrides: InlineConfig) => Promise<InlineConfig>;\n frameworkServerOutDir: string;\n options: CliOptions;\n outDir: string;\n root: string;\n runtime?: BuildRuntime;\n}) {\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n copyPublicDir: false,\n emptyOutDir: true,\n outDir: frameworkServerOutDir,\n rollupOptions: {\n input: SERVER_ENTRY,\n output: { entryFileNames: \"server-entry.js\" },\n },\n ssr: true,\n },\n }),\n );\n\n const clientManifest = parseClientManifest(\n runtime\n ? await runtime.readText(resolve(outDir, \"demiurge-manifest.json\"))\n : await readFile(resolve(outDir, \"demiurge-manifest.json\"), \"utf8\"),\n );\n const serverEntryUrl = `${\n pathToFileURL(resolve(frameworkServerOutDir, \"server-entry.js\")).href\n }?build=${runtime?.now() ?? Date.now()}`;\n const serverEntry = runtime\n ? await runtime.importModule(serverEntryUrl)\n : await import(serverEntryUrl);\n if (!isRouteImporterRecord(serverEntry.routes)) {\n throw new Error(\"The framework server bundle does not export routes.\");\n }\n\n const manifest = await (runtime?.generate ?? generateStaticOutput)({\n fonts: config.assets?.fonts,\n images: config.assets?.images,\n origin: options.origin ?? config.deployment?.static?.origin,\n outDir,\n root,\n routes: serverEntry.routes,\n ssr: clientManifest,\n staticFileHeaders: config.security?.staticFileHeaders ?? [],\n });\n\n const provider = config.deployment?.static?.provider;\n const deploymentOutDir = provider\n ? await generateVercelStaticOutput({\n deployment: provider,\n manifest,\n outDir,\n projectRoot: root,\n })\n : undefined;\n\n return { deploymentOutDir, manifest };\n}\n\nexport function resolvePreviewOutputDirectory(\n root: string,\n outDir: string | undefined,\n configuredOutDir?: string,\n) {\n return resolve(root, outDir ?? configuredOutDir ?? DEFAULT_CLIENT_OUT_DIR);\n}\n\nexport async function validateBuildOutputDirectory(\n root: string,\n outDir: string,\n publicDir: false | string,\n serverOutDir: string,\n) {\n const pathFromRoot = relative(root, outDir);\n if (\n !pathFromRoot ||\n pathFromRoot === \"..\" ||\n pathFromRoot.startsWith(`..${sep}`) ||\n isAbsolute(pathFromRoot)\n ) {\n throw new Error(\"The static output directory must be inside the Vite root.\");\n }\n\n if (publicDir && pathsOverlap(outDir, publicDir)) {\n throw new Error(\"The static output directory must not overlap the Vite public directory.\");\n }\n\n if (pathsOverlap(outDir, serverOutDir)) {\n throw new Error(\"The static output directory must not overlap the framework server directory.\");\n }\n\n let entries: string[];\n try {\n entries = await readdir(outDir);\n } catch (error) {\n if (isMissingPath(error)) return;\n throw error;\n }\n\n if (\n entries.length &&\n !entries.includes(\"demiurge-manifest.json\") &&\n !entries.includes(\"demiurge-static-manifest.json\")\n ) {\n throw new Error(\n \"The static output directory contains files that a Demiurge build did not create.\",\n );\n }\n}\n\nfunction isRouteImporterRecord(\n value: unknown,\n): value is Record<string, RouteImporter> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n\n return Object.values(value).every((load) => typeof load === \"function\");\n}\n\nfunction pathsOverlap(left: string, right: string) {\n const fromLeft = relative(left, right);\n const fromRight = relative(right, left);\n return isSameOrChildPath(fromLeft) || isSameOrChildPath(fromRight);\n}\n\nfunction isSameOrChildPath(pathname: string) {\n return !pathname ||\n (pathname !== \"..\" && !pathname.startsWith(`..${sep}`) &&\n !isAbsolute(pathname));\n}\n\nfunction isMissingPath(error: unknown) {\n return error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n"],"names":["STATIC_POLICY_REPORT_VERSION","INSPECTION_PROBLEM_VERSION","requestFacts","createStaticPolicyReport","input","options","pass","inspectRoutePolicies","routes","inspection","toStaticRouteReport","left","right","toPosixPath","relative","findSecretEnvKeys","schema","variable","key","countErrorFindings","report","finding","formatStaticPolicyReportSummary","errors","warnings","routesDir","file","fileSegments","attached","toRoutePattern","toRouteSegments","pathname","sep","INSPECT_EXIT_OK","INSPECT_EXIT_FINDINGS","INSPECT_EXIT_INVALID","runInspectCommand","toProblemResult","config","error","toPluginOptions","serializeInspectionReport","code","title","detail","problem","cliOptionNames","CLIENT_ENTRY","SERVER_ENTRY","DEFAULT_CLIENT_OUT_DIR","DEFAULT_SERVER_OUT_DIR","FRAMEWORK_SERVER_OUT_DIR","parseCliArguments","arguments_","environment","command","index","argument","name","inlineValue","value","port","helpText","runDev","createServer","server","createDemiurgeViteConfig","runBuild","runtime","root","build","createViteConfig","overrides","outDir","resolve","frameworkServerOutDir","validateBuildOutputDirectory","join","applicationServer","serverOutDir","provider","generateVercelNodeOutput","buildStaticOutput","runStart","allowedHosts","clientDir","serverEntryUrl","pathToFileURL","serverEntry","isNodeBuildRuntime","clientManifest","parseClientManifest","readFile","isRouteImporterRecord","manifest","generateStaticOutput","generateVercelStaticOutput","resolvePreviewOutputDirectory","configuredOutDir","publicDir","pathFromRoot","isAbsolute","pathsOverlap","entries","readdir","isMissingPath","load","fromLeft","fromRight","isSameOrChildPath"],"mappings":";;;;;;;;;;;;;;;;;;;;AAWO,MAAMA,IAA+B,GAM/BC,IAA6B,GCQpCC,IAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASA,eAAsBC,EACpBC,GAC6B;AAC7B,QAAMC,IAAUD,EAAM,WAAW,CAAA,GAC3BE,IAAO,MAAMC,EAAqBH,EAAM,MAAMC,CAAO,GACrDG,IAASF,EAAK,YACjB,IAAI,CAACG,MAAeC,EAAoBJ,EAAK,WAAWG,CAAU,CAAC,EACnE,KAAK,CAACE,GAAMC,MAAUD,EAAK,KAAK,cAAcC,EAAM,IAAI,CAAC;AAE5D,SAAO;AAAA,IACL,UAAUN,EAAK;AAAA,IACf,YAAY,CAAA;AAAA,IACZ,SAASJ;AAAA,IACT,aAAa;AAAA,MACX,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,IAAA;AAAA,IAEV,QAAAM;AA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AAY,MAAM,QAAQA,CAAK,IACrD,KAGF,OAAO,OAAOA,CAAK,EAAE,MAAM,CAAC8C,MAAS,OAAOA,KAAS,UAAU;AACxE;AAEA,SAASJ,EAAa3F,GAAcC,GAAe;AACjD,QAAM+F,IAAW7F,EAASH,GAAMC,CAAK,GAC/BgG,IAAY9F,EAASF,GAAOD,CAAI;AACtC,SAAOkG,EAAkBF,CAAQ,KAAKE,EAAkBD,CAAS;AACnE;AAEA,SAASC,EAAkB9E,GAAkB;AAC3C,SAAO,CAACA,KACLA,MAAa,QAAQ,CAACA,EAAS,WAAW,KAAKC,CAAG,EAAE,KACnD,CAACqE,EAAWtE,CAAQ;AAC1B;AAEA,SAAS0E,GAAclE,GAAgB;AACrC,SAAOA,aAAiB,SAAS,UAAUA,KAASA,EAAM,SAAS;AACrE;"}
@@ -1,7 +1,7 @@
1
1
  import { existsSync as f } from "node:fs";
2
2
  import { join as u, resolve as a, dirname as s } from "node:path";
3
- import { D as r, v as d } from "../chunks/vite-DO70kZA6.js";
4
- import { c as F, t as M } from "../chunks/vite-DO70kZA6.js";
3
+ import { D as r, v as d } from "../chunks/vite-BADZA8Fl.js";
4
+ import { c as F, t as M } from "../chunks/vite-BADZA8Fl.js";
5
5
  function x(e) {
6
6
  return e;
7
7
  }