@demiurgejs/core 0.2.0-beta.5 → 0.2.0-beta.7

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 (94) hide show
  1. package/README.md +14 -0
  2. package/bin/demiurge.mjs +6 -0
  3. package/dist/browser/file-router.d.ts +1 -0
  4. package/dist/browser/file-router.d.ts.map +1 -1
  5. package/dist/chunks/{document-shell-9GPwtcTt.js → document-shell-C0aPrkhd.js} +2 -2
  6. package/dist/chunks/{document-shell-9GPwtcTt.js.map → document-shell-C0aPrkhd.js.map} +1 -1
  7. package/dist/chunks/image-CRerJ5BY.js +145 -0
  8. package/dist/chunks/image-CRerJ5BY.js.map +1 -0
  9. package/dist/chunks/{image-codec-Dh1POFhE.js → image-codec-CQ8Cwxwb.js} +2 -2
  10. package/dist/chunks/{image-codec-Dh1POFhE.js.map → image-codec-CQ8Cwxwb.js.map} +1 -1
  11. package/dist/chunks/{images-CG7ZzayG.js → images-QgdmLyQ3.js} +11 -11
  12. package/dist/chunks/{images-CG7ZzayG.js.map → images-QgdmLyQ3.js.map} +1 -1
  13. package/dist/chunks/{index-0MNiR_wo.js → index-LYve1rQp.js} +286 -351
  14. package/dist/chunks/index-LYve1rQp.js.map +1 -0
  15. package/dist/chunks/links-iU22QkCE.js +68 -0
  16. package/dist/chunks/links-iU22QkCE.js.map +1 -0
  17. package/dist/chunks/{plugin-BZauDxRY.js → plugin-bkP6WwrS.js} +13 -12
  18. package/dist/chunks/{plugin-BZauDxRY.js.map → plugin-bkP6WwrS.js.map} +1 -1
  19. package/dist/chunks/runtime-BH519j2t.js +294 -0
  20. package/dist/chunks/runtime-BH519j2t.js.map +1 -0
  21. package/dist/chunks/streaming-BlKlC3nw.js +427 -0
  22. package/dist/chunks/streaming-BlKlC3nw.js.map +1 -0
  23. package/dist/chunks/{testing-CUwGj2ie.js → testing-BEW1nchS.js} +645 -630
  24. package/dist/chunks/testing-BEW1nchS.js.map +1 -0
  25. package/dist/chunks/{vite-QoqrGl6f.js → vite-BADZA8Fl.js} +73 -70
  26. package/dist/chunks/vite-BADZA8Fl.js.map +1 -0
  27. package/dist/cli.d.ts +8 -2
  28. package/dist/cli.d.ts.map +1 -1
  29. package/dist/cli.js +186 -122
  30. package/dist/cli.js.map +1 -1
  31. package/dist/config/index.js +2 -2
  32. package/dist/config/types.d.ts +3 -1
  33. package/dist/config/types.d.ts.map +1 -1
  34. package/dist/config/validate.d.ts.map +1 -1
  35. package/dist/data/cache.d.ts +5 -0
  36. package/dist/data/cache.d.ts.map +1 -1
  37. package/dist/data/index.d.ts +1 -1
  38. package/dist/data/index.d.ts.map +1 -1
  39. package/dist/data/testing.d.ts.map +1 -1
  40. package/dist/data/testing.js +101 -67
  41. package/dist/data/testing.js.map +1 -1
  42. package/dist/data/tiered.d.ts.map +1 -1
  43. package/dist/edge/index.js +27 -26
  44. package/dist/edge/index.js.map +1 -1
  45. package/dist/edge/stores.d.ts.map +1 -1
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +910 -891
  49. package/dist/index.js.map +1 -1
  50. package/dist/internal/testing.js +2 -2
  51. package/dist/kv/index.js +7 -6
  52. package/dist/kv/index.js.map +1 -1
  53. package/dist/kv/store.d.ts.map +1 -1
  54. package/dist/node/http.d.ts +2 -0
  55. package/dist/node/http.d.ts.map +1 -1
  56. package/dist/node/index.d.ts +1 -1
  57. package/dist/node/index.d.ts.map +1 -1
  58. package/dist/node/index.js +12 -11
  59. package/dist/node/index.js.map +1 -1
  60. package/dist/node/serve.d.ts +4 -0
  61. package/dist/node/serve.d.ts.map +1 -1
  62. package/dist/redis/index.js +29 -28
  63. package/dist/redis/index.js.map +1 -1
  64. package/dist/redis/store.d.ts.map +1 -1
  65. package/dist/route/serialization.d.ts +4 -4
  66. package/dist/route/serialization.d.ts.map +1 -1
  67. package/dist/static/index.d.ts.map +1 -1
  68. package/dist/static/index.js +255 -255
  69. package/dist/static/index.js.map +1 -1
  70. package/dist/static/testing.d.ts +26 -0
  71. package/dist/static/testing.d.ts.map +1 -0
  72. package/dist/static/testing.js +76 -0
  73. package/dist/static/testing.js.map +1 -0
  74. package/dist/testing/index.d.ts +47 -0
  75. package/dist/testing/index.d.ts.map +1 -0
  76. package/dist/testing/index.js +99 -0
  77. package/dist/testing/index.js.map +1 -0
  78. package/dist/vercel/build.d.ts +31 -0
  79. package/dist/vercel/build.d.ts.map +1 -0
  80. package/dist/vercel/config.d.ts +15 -0
  81. package/dist/vercel/config.d.ts.map +1 -0
  82. package/dist/vercel/index.d.ts +7 -0
  83. package/dist/vercel/index.d.ts.map +1 -0
  84. package/dist/vercel/index.js +11 -0
  85. package/dist/vercel/index.js.map +1 -0
  86. package/dist/vercel/runtime.d.ts +29 -0
  87. package/dist/vercel/runtime.d.ts.map +1 -0
  88. package/dist/vite/index.js +1 -1
  89. package/package.json +13 -1
  90. package/dist/chunks/index-0MNiR_wo.js.map +0 -1
  91. package/dist/chunks/streaming-GYIsVTQH.js +0 -560
  92. package/dist/chunks/streaming-GYIsVTQH.js.map +0 -1
  93. package/dist/chunks/testing-CUwGj2ie.js.map +0 -1
  94. package/dist/chunks/vite-QoqrGl6f.js.map +0 -1
@@ -1,54 +1,54 @@
1
- import { readFile as A, mkdir as x, mkdtemp as G, cp as K, writeFile as L, rm as C, rename as ut } from "node:fs/promises";
2
- import { resolve as h, relative as E, sep as O, extname as lt, dirname as M, join as $ } from "node:path";
3
- import { d as ft, S as j } from "../chunks/index-0MNiR_wo.js";
4
- import { i as H, v as dt, b as ht, d as D, l as Z, e as pt, c as mt, h as wt, r as yt, f as gt, g as St, j as Et, m as vt, k as Y, n as $t } from "../chunks/testing-CUwGj2ie.js";
1
+ import { readFile as F, mkdir as b, mkdtemp as K, cp as Z, writeFile as M, rm as x, rename as lt } from "node:fs/promises";
2
+ import { resolve as p, relative as E, sep as $, extname as ft, dirname as j, join as v } from "node:path";
3
+ import { d as dt, S as D } from "../chunks/index-LYve1rQp.js";
4
+ import { i as C, v as ht, b as pt, d as W, l as Y, e as mt, c as wt, h as yt, r as gt, f as St, g as Et, j as vt, m as $t, k as Q, n as Ot } from "../chunks/testing-BEW1nchS.js";
5
5
  import "react-dom/server";
6
- import { c as Ot, D as Rt, C as Q, I as Tt, R as At } from "../chunks/static-files-ehaD1kE7.js";
6
+ import { c as Rt, D as Tt, C as X, I as At, R as Ft } from "../chunks/static-files-ehaD1kE7.js";
7
7
  import "react";
8
8
  import "react/jsx-runtime";
9
- import { t as Ft, n as Nt, r as Pt } from "../chunks/image-codec-Dh1POFhE.js";
10
- import { e as X, g as bt, p as xt, h as Ct } from "../chunks/images-CG7ZzayG.js";
11
- import { createServer as Ht } from "node:http";
12
- import { pathToRegexp as It } from "path-to-regexp";
13
- async function Jt(t) {
14
- const e = h(t.outDir), r = t.policy ?? {}, n = r.optimizerPath ?? X, o = new Set(
9
+ import { t as Nt, n as Pt, r as bt } from "../chunks/image-codec-CQ8Cwxwb.js";
10
+ import { a as tt, h as xt, j as Ct, i as Ht } from "../chunks/images-QgdmLyQ3.js";
11
+ import { createServer as It } from "node:http";
12
+ import { pathToRegexp as Jt } from "path-to-regexp";
13
+ async function Lt(t) {
14
+ const e = p(t.outDir), r = t.policy ?? {}, n = r.optimizerPath ?? tt, o = new Set(
15
15
  t.documents.flatMap(
16
- (s) => bt(s, n)
16
+ (s) => xt(s, n)
17
17
  )
18
18
  ), i = [], c = /* @__PURE__ */ new Map();
19
19
  for (const s of [...o].sort()) {
20
- const a = xt(s, n);
20
+ const a = Ct(s, n);
21
21
  if (!a)
22
22
  throw new Error(
23
23
  `Static output references image variant ${JSON.stringify(s)}, which does not describe a transform the build can emit.`
24
24
  );
25
- if (!Ct(a.src, r))
25
+ if (!Ht(a.src, r))
26
26
  throw new Error(
27
27
  `Image source ${JSON.stringify(a.src)} is not allowed by the image policy.`
28
28
  );
29
- const u = jt(e, a.src);
29
+ const u = Dt(e, a.src);
30
30
  let d = c.get(u);
31
- d || (d = await Mt(u, a.src), c.set(u, d));
32
- const p = await Ft(d, {
33
- format: Nt(a, null),
31
+ d || (d = await jt(u, a.src), c.set(u, d));
32
+ const m = await Nt(d, {
33
+ format: Pt(a, null),
34
34
  quality: a.quality,
35
35
  width: a.width
36
36
  });
37
- i.push({ body: p.body, file: s.slice(1) });
37
+ i.push({ body: m.body, file: s.slice(1) });
38
38
  }
39
39
  return i;
40
40
  }
41
- function Lt(t, e = {}) {
42
- const r = e.optimizerPath ?? X, n = new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\?`);
41
+ function Mt(t, e = {}) {
42
+ const r = e.optimizerPath ?? tt, n = new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\?`);
43
43
  for (const o of t)
44
44
  if (n.test(o))
45
45
  throw new Error(
46
46
  'Static output references the request-time image optimizer, which a static build cannot serve. Set loader: "static" in the image policy, or deploy a runtime adapter.'
47
47
  );
48
48
  }
49
- async function Mt(t, e) {
49
+ async function jt(t, e) {
50
50
  try {
51
- return new Uint8Array(await A(t));
51
+ return new Uint8Array(await F(t));
52
52
  } catch (r) {
53
53
  throw new Error(
54
54
  `Demiurge could not read the source image ${JSON.stringify(e)} from the build output.`,
@@ -56,24 +56,24 @@ async function Mt(t, e) {
56
56
  );
57
57
  }
58
58
  }
59
- function jt(t, e) {
59
+ function Dt(t, e) {
60
60
  let r;
61
61
  try {
62
62
  r = decodeURIComponent(e);
63
63
  } catch {
64
64
  throw new Error(`Image source is not valid UTF-8: ${JSON.stringify(e)}.`);
65
65
  }
66
- const n = h(t, `.${r}`);
67
- if (E(t, n).split(O).includes(".."))
66
+ const n = p(t, `.${r}`);
67
+ if (E(t, n).split($).includes(".."))
68
68
  throw new Error(
69
69
  `Image source escaped the build output directory: ${JSON.stringify(e)}.`
70
70
  );
71
71
  return n;
72
72
  }
73
- const Dt = "demiurge-static-manifest.json";
74
- async function Me(t) {
75
- const e = h(t.outDir), r = Ut(
76
- await A(h(e, Dt), "utf8")
73
+ const Wt = "demiurge-static-manifest.json";
74
+ async function je(t) {
75
+ const e = p(t.outDir), r = kt(
76
+ await F(p(e, Wt), "utf8")
77
77
  ), n = new Map(
78
78
  r.entries.map((a) => [a.pathname, a])
79
79
  ), o = new Map(
@@ -81,7 +81,7 @@ async function Me(t) {
81
81
  ), i = r.fileHeaderRules.map((a) => ({
82
82
  ...a,
83
83
  expression: new RegExp(a.pattern)
84
- })), c = Ht((a, u) => {
84
+ })), c = It((a, u) => {
85
85
  s(a, u);
86
86
  });
87
87
  async function s(a, u) {
@@ -91,42 +91,42 @@ async function Me(t) {
91
91
  return;
92
92
  }
93
93
  const d = new URL(a.url ?? "/", "http://demiurge.local");
94
- let p;
94
+ let m;
95
95
  try {
96
- p = decodeURIComponent(d.pathname);
96
+ m = decodeURIComponent(d.pathname);
97
97
  } catch {
98
98
  u.writeHead(400, {
99
99
  "content-type": "text/plain; charset=utf-8"
100
100
  }), u.end("The request path is not valid UTF-8.");
101
101
  return;
102
102
  }
103
- const y = p.replace(/\/$/, "") || "/", m = n.get(y);
104
- if (m) {
105
- await I(e, m, a.method, u);
103
+ const H = m.replace(/\/$/, "") || "/", w = n.get(H);
104
+ if (w) {
105
+ await J(e, w, a.method, u);
106
106
  return;
107
107
  }
108
- const g = Wt(e, p);
109
- if (g)
108
+ const h = Ut(e, m);
109
+ if (h)
110
110
  try {
111
- const w = E(e, g).split(O).join("/"), F = o.get(w);
112
- if (F) {
113
- await I(e, F, a.method, u);
111
+ const y = E(e, h).split($).join("/"), g = o.get(y);
112
+ if (g) {
113
+ await J(e, g, a.method, u);
114
114
  return;
115
115
  }
116
- const N = await A(g), v = Ot(lt(g));
117
- v !== Rt && u.setHeader("content-type", v);
118
- const T = p.split("/").at(-1) ?? "", P = i.find(({ expression: l }) => l.test(T));
119
- tt(u, P?.headers ?? {}), u.writeHead(200), u.end(a.method === "HEAD" ? void 0 : N);
116
+ const I = await F(h), R = Rt(ft(h));
117
+ R !== Tt && u.setHeader("content-type", R);
118
+ const T = m.split("/").at(-1) ?? "", A = i.find(({ expression: N }) => N.test(T));
119
+ et(u, A?.headers ?? {}), u.writeHead(200), u.end(a.method === "HEAD" ? void 0 : I);
120
120
  return;
121
- } catch (w) {
122
- if (!Vt(w)) throw w;
121
+ } catch (y) {
122
+ if (!qt(y)) throw y;
123
123
  }
124
- const R = n.get("*");
125
- if (!R) {
124
+ const O = n.get("*");
125
+ if (!O) {
126
126
  u.writeHead(404), u.end();
127
127
  return;
128
128
  }
129
- await I(e, R, a.method, u);
129
+ await J(e, O, a.method, u);
130
130
  } catch {
131
131
  u.writeHead(500, {
132
132
  "content-type": "text/plain; charset=utf-8"
@@ -134,7 +134,7 @@ async function Me(t) {
134
134
  }
135
135
  }
136
136
  return await new Promise((a, u) => {
137
- const d = (p) => u(p);
137
+ const d = (m) => u(m);
138
138
  c.once("error", d), c.listen(
139
139
  t.port ?? 4173,
140
140
  t.host ?? "localhost",
@@ -144,42 +144,42 @@ async function Me(t) {
144
144
  );
145
145
  }), c;
146
146
  }
147
- async function I(t, e, r, n) {
148
- const o = et(t, e.file), i = await A(o);
149
- tt(n, e.headers), n.writeHead(e.status), n.end(r === "HEAD" ? void 0 : i);
147
+ async function J(t, e, r, n) {
148
+ const o = rt(t, e.file), i = await F(o);
149
+ et(n, e.headers), n.writeHead(e.status), n.end(r === "HEAD" ? void 0 : i);
150
150
  }
151
- function tt(t, e) {
151
+ function et(t, e) {
152
152
  for (const [r, n] of Object.entries(e))
153
153
  t.setHeader(r, n);
154
154
  }
155
- function Wt(t, e) {
155
+ function Ut(t, e) {
156
156
  if (!e.endsWith("/"))
157
- return rt(t, `.${e}`);
157
+ return nt(t, `.${e}`);
158
158
  }
159
- function et(t, e) {
160
- const r = rt(t, e);
159
+ function rt(t, e) {
160
+ const r = nt(t, e);
161
161
  if (!r)
162
162
  throw new Error(`Static preview file is outside the output directory: ${JSON.stringify(e)}.`);
163
163
  return r;
164
164
  }
165
- function rt(t, e) {
165
+ function nt(t, e) {
166
166
  if (!e || e.startsWith("/") || e.startsWith("\\") || e.split(/[\\/]/).includes(".."))
167
167
  return;
168
- const r = h(t, e), n = E(t, r);
169
- return n !== ".." && !n.startsWith(`..${O}`) ? r : void 0;
168
+ const r = p(t, e), n = E(t, r);
169
+ return n !== ".." && !n.startsWith(`..${$}`) ? r : void 0;
170
170
  }
171
- function Ut(t) {
171
+ function kt(t) {
172
172
  let e;
173
173
  try {
174
174
  e = JSON.parse(t);
175
175
  } catch {
176
176
  throw new Error("The static output manifest is not valid JSON.");
177
177
  }
178
- if (!H(e) || e.adapter !== "static" || e.version !== 1)
178
+ if (!C(e) || e.adapter !== "static" || e.version !== 1)
179
179
  throw new Error("The static output manifest has an unsupported format.");
180
180
  if (!Array.isArray(e.entries) || !Array.isArray(e.fileHeaderRules))
181
181
  throw new Error("The static output manifest does not contain header rules and entries.");
182
- const r = e.entries.map(kt), n = e.fileHeaderRules.map(_t), o = /* @__PURE__ */ new Set();
182
+ const r = e.entries.map(_t), n = e.fileHeaderRules.map(Vt), o = /* @__PURE__ */ new Set();
183
183
  for (const i of r) {
184
184
  if (o.has(i.pathname))
185
185
  throw new Error(`The static output manifest repeats pathname ${JSON.stringify(i.pathname)}.`);
@@ -187,18 +187,18 @@ function Ut(t) {
187
187
  }
188
188
  return { adapter: "static", entries: r, fileHeaderRules: n, version: 1 };
189
189
  }
190
- function kt(t) {
191
- if (!H(t) || typeof t.file != "string" || typeof t.pathname != "string" || t.status !== 200 && t.status !== 404 || !nt(t.headers))
190
+ function _t(t) {
191
+ if (!C(t) || typeof t.file != "string" || typeof t.pathname != "string" || t.status !== 200 && t.status !== 404 || !ot(t.headers))
192
192
  throw new Error("The static output manifest contains an invalid entry.");
193
- return et("/demiurge-manifest-root", t.file), {
193
+ return rt("/demiurge-manifest-root", t.file), {
194
194
  file: t.file,
195
195
  headers: t.headers,
196
196
  pathname: t.pathname,
197
197
  status: t.status
198
198
  };
199
199
  }
200
- function _t(t) {
201
- if (!H(t) || typeof t.pattern != "string" || !nt(t.headers))
200
+ function Vt(t) {
201
+ if (!C(t) || typeof t.pattern != "string" || !ot(t.headers))
202
202
  throw new Error("The static output manifest contains an invalid file header rule.");
203
203
  try {
204
204
  new RegExp(t.pattern);
@@ -207,16 +207,16 @@ function _t(t) {
207
207
  }
208
208
  return { headers: t.headers, pattern: t.pattern };
209
209
  }
210
- function nt(t) {
211
- return H(t) && Object.values(t).every(
210
+ function ot(t) {
211
+ return C(t) && Object.values(t).every(
212
212
  (e) => typeof e == "string"
213
213
  );
214
214
  }
215
- function Vt(t) {
215
+ function qt(t) {
216
216
  return t instanceof Error && "code" in t && (t.code === "EISDIR" || t.code === "ENOENT");
217
217
  }
218
- const qt = "demiurge-manifest.json", zt = "demiurge-static-manifest.json";
219
- function je(t = {}) {
218
+ const zt = "demiurge-manifest.json", Bt = "demiurge-static-manifest.json";
219
+ function De(t = {}) {
220
220
  return {
221
221
  adapter: "vercel",
222
222
  cache: t.cache?.map((e) => ({
@@ -226,45 +226,45 @@ function je(t = {}) {
226
226
  cors: t.cors
227
227
  };
228
228
  }
229
- async function De(t) {
230
- te(t.deployment);
231
- const e = h(t.projectRoot), r = h(t.outDir), n = h(e, ".vercel/output");
232
- if (ee(r, n))
229
+ async function We(t) {
230
+ ee(t.deployment);
231
+ const e = p(t.projectRoot), r = p(t.outDir), n = p(e, ".vercel/output");
232
+ if (re(r, n))
233
233
  throw new Error(
234
234
  "The static output directory must not overlap the Vercel output directory."
235
235
  );
236
- const o = M(n);
237
- await x(o, { recursive: !0 });
238
- const i = await G($(o, "output-demiurge-"));
236
+ const o = j(n);
237
+ await b(o, { recursive: !0 });
238
+ const i = await K(v(o, "output-demiurge-"));
239
239
  try {
240
- const c = $(i, "static");
241
- await K(r, c, {
240
+ const c = v(i, "static");
241
+ await Z(r, c, {
242
242
  filter: (s) => {
243
- const a = E(r, s).split(O).join("/");
244
- return a !== qt && a !== zt;
243
+ const a = E(r, s).split($).join("/");
244
+ return a !== zt && a !== Bt;
245
245
  },
246
246
  recursive: !0
247
- }), await L(
248
- $(i, "config.json"),
249
- `${JSON.stringify(Bt(
247
+ }), await M(
248
+ v(i, "config.json"),
249
+ `${JSON.stringify(Gt(
250
250
  t.manifest,
251
251
  t.deployment
252
252
  ), null, 2)}
253
253
  `
254
- ), await C(n, { force: !0, recursive: !0 }), await ut(i, n);
254
+ ), await x(n, { force: !0, recursive: !0 }), await lt(i, n);
255
255
  } catch (c) {
256
- throw await C(i, { force: !0, recursive: !0 }), c;
256
+ throw await x(i, { force: !0, recursive: !0 }), c;
257
257
  }
258
258
  return n;
259
259
  }
260
- function Bt(t, e) {
260
+ function Gt(t, e) {
261
261
  const r = t.entries.find((s) => s.pathname === "*");
262
262
  if (!r)
263
263
  throw new Error("Vercel output requires a static fallback entry.");
264
- const n = Yt(e.cache), i = [
264
+ const n = Qt(e.cache), i = [
265
265
  {
266
266
  continue: !0,
267
- headers: { "access-control-allow-origin": Xt(e.cors, t.origin) },
267
+ headers: { "access-control-allow-origin": te(e.cors, t.origin) },
268
268
  src: "^/.*$"
269
269
  }
270
270
  ];
@@ -274,17 +274,17 @@ function Bt(t, e) {
274
274
  a !== s.pathname && i.push({
275
275
  continue: !0,
276
276
  dest: s.pathname,
277
- src: b(a)
277
+ src: P(a)
278
278
  });
279
279
  }
280
280
  for (const s of t.entries) {
281
- const a = W(s.headers);
281
+ const a = U(s.headers);
282
282
  if (Object.keys(a).length === 0) continue;
283
283
  const u = s.pathname === "*" ? `/${s.file}` : s.pathname;
284
284
  i.push({
285
285
  continue: !0,
286
286
  headers: a,
287
- src: b(u)
287
+ src: P(u)
288
288
  });
289
289
  }
290
290
  i.push(...n);
@@ -292,14 +292,14 @@ function Bt(t, e) {
292
292
  if (s.pathname === "*") {
293
293
  i.push({
294
294
  dest: `/${s.file}`,
295
- src: b(`/${s.file}`),
295
+ src: P(`/${s.file}`),
296
296
  status: 404
297
297
  });
298
298
  continue;
299
299
  }
300
300
  i.push({
301
301
  dest: s.pathname === "/" ? `/${s.file}` : s.pathname,
302
- src: b(s.pathname)
302
+ src: P(s.pathname)
303
303
  });
304
304
  }
305
305
  i.push({ handle: "hit" });
@@ -307,24 +307,24 @@ function Bt(t, e) {
307
307
  i.push({
308
308
  continue: !0,
309
309
  headers: { ...s.headers },
310
- src: Kt(s.pattern)
310
+ src: Zt(s.pattern)
311
311
  });
312
312
  i.push(...n.map((s) => ({ ...s }))), i.push({ handle: "error" });
313
- const c = W(r.headers);
313
+ const c = U(r.headers);
314
314
  return i.push(...n.map((s) => ({ ...s }))), i.push({
315
315
  dest: `/${r.file}`,
316
316
  headers: c,
317
317
  src: "^/.*$",
318
318
  status: 404
319
- }), Qt(i), {
319
+ }), Xt(i), {
320
320
  overrides: Object.fromEntries(
321
- t.entries.map((s) => [s.file, Gt(s)])
321
+ t.entries.map((s) => [s.file, Kt(s)])
322
322
  ),
323
323
  routes: i,
324
324
  version: 3
325
325
  };
326
326
  }
327
- function Gt(t) {
327
+ function Kt(t) {
328
328
  const e = {}, r = t.headers["content-type"];
329
329
  if (r && (e.contentType = r), t.pathname !== "*") {
330
330
  const n = t.file === "index.html" ? "/" : `/${t.file}`;
@@ -332,31 +332,31 @@ function Gt(t) {
332
332
  }
333
333
  return e;
334
334
  }
335
- function b(t) {
335
+ function P(t) {
336
336
  const e = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
337
337
  return t === "/" ? "^/$" : `^${e}/?$`;
338
338
  }
339
- function W(t) {
339
+ function U(t) {
340
340
  return Object.fromEntries(
341
341
  Object.entries(t).filter(([e]) => e.toLowerCase() !== "content-type")
342
342
  );
343
343
  }
344
- function Kt(t) {
345
- return t === ".*" ? "^/.*$" : t === Q.source ? "^/(?:.*/)?[^/]*-[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9]+$" : `^/${Zt(t)}$`;
346
- }
347
344
  function Zt(t) {
345
+ return t === ".*" ? "^/.*$" : t === X.source ? "^/(?:.*/)?[^/]*-[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9]+$" : `^/${Yt(t)}$`;
346
+ }
347
+ function Yt(t) {
348
348
  const e = t.startsWith("^"), r = t.endsWith("$") && !t.endsWith("\\$"), n = t.slice(
349
349
  e ? 1 : 0,
350
350
  r ? -1 : void 0
351
351
  );
352
352
  return `${e ? "(?:.*/)?" : "(?:.*/)?[^/]*"}(?:${n})${r ? "" : "[^/]*"}`;
353
353
  }
354
- function Yt(t) {
354
+ function Qt(t) {
355
355
  try {
356
356
  return t.map((e) => ({
357
357
  continue: !0,
358
358
  headers: { "cache-control": e.value },
359
- src: It(e.source, [], {
359
+ src: Jt(e.source, [], {
360
360
  delimiter: "/",
361
361
  strict: !0
362
362
  }).source.replaceAll("\\/", "/")
@@ -367,7 +367,7 @@ function Yt(t) {
367
367
  );
368
368
  }
369
369
  }
370
- function Qt(t) {
370
+ function Xt(t) {
371
371
  for (const e of t)
372
372
  if (!("handle" in e))
373
373
  try {
@@ -376,9 +376,9 @@ function Qt(t) {
376
376
  throw new Error("A generated Vercel route is not valid.");
377
377
  }
378
378
  }
379
- function Xt(t, e) {
379
+ function te(t, e) {
380
380
  if (t) {
381
- if (dt(t), t.origins === "*")
381
+ if (ht(t), t.origins === "*")
382
382
  return "*";
383
383
  if (t.origins.length === 1)
384
384
  return t.origins[0];
@@ -392,31 +392,31 @@ function Xt(t, e) {
392
392
  );
393
393
  return e;
394
394
  }
395
- function te(t) {
395
+ function ee(t) {
396
396
  if (t.adapter !== "vercel" || !Array.isArray(t.cache))
397
397
  throw new Error("The Vercel static adapter configuration is not valid.");
398
398
  for (const e of t.cache)
399
399
  if (!e || typeof e != "object" || typeof e.source != "string" || !e.source || typeof e.value != "string" || !e.value)
400
400
  throw new Error("A Vercel static header rule is not valid.");
401
401
  }
402
- function ee(t, e) {
402
+ function re(t, e) {
403
403
  const r = E(t, e), n = E(e, t);
404
- return U(r) || U(n);
404
+ return k(r) || k(n);
405
405
  }
406
- function U(t) {
407
- return !t || t !== ".." && !t.startsWith(`..${O}`) && !t.startsWith("/");
406
+ function k(t) {
407
+ return !t || t !== ".." && !t.startsWith(`..${$}`) && !t.startsWith("/");
408
408
  }
409
- const ot = "demiurge-static-manifest.json", k = ft({
409
+ const it = "demiurge-static-manifest.json", _ = dt({
410
410
  name: "static",
411
411
  capabilities: {
412
412
  staticOutput: !0
413
413
  }
414
- }), re = 8;
415
- async function ne(t) {
414
+ }), ne = 8;
415
+ async function oe(t) {
416
416
  const e = Object.entries(t), r = new Array(e.length);
417
417
  let n = 0;
418
418
  const o = Array.from(
419
- { length: Math.min(re, e.length) },
419
+ { length: Math.min(ne, e.length) },
420
420
  async () => {
421
421
  for (; n < e.length; ) {
422
422
  const i = n++, [c, s] = e[i];
@@ -433,135 +433,135 @@ async function ne(t) {
433
433
  );
434
434
  return await Promise.all(o), Object.fromEntries(r);
435
435
  }
436
- async function We(t) {
437
- const e = await ne(t.routes), r = ht(e, {
438
- adapter: k
439
- }), n = ce(t.origin), o = h(t.outDir), i = await le(r), c = await D(r, {
436
+ async function Ue(t) {
437
+ const e = await oe(t.routes), r = pt(e, {
438
+ adapter: _
439
+ }), n = t.origin === void 0 ? void 0 : ue(t.origin), o = n ?? "http://demiurge.local", i = p(t.outDir), c = await fe(r), s = await W(r, {
440
440
  includePages: !1,
441
441
  includeResources: !0
442
- }), s = t.locales ? oe(n, t.locales) : [void 0], a = (await Promise.all(
443
- s.map((l) => D(r, { locale: l }))
442
+ }), a = t.locales ? ie(o, t.locales) : [void 0], u = (await Promise.all(
443
+ a.map((l) => W(r, { locale: l }))
444
444
  )).flatMap((l, f) => l.map((S) => ({
445
445
  ...S,
446
- locale: s[f]
447
- }))), u = [...c, ...a];
448
- ue(
446
+ locale: a[f]
447
+ }))), d = [...s, ...u];
448
+ le(
449
449
  r,
450
- a.length
450
+ u.length
451
451
  );
452
- const d = he(
453
- u.flatMap((l) => {
454
- const f = i.get(l.file) ?? "resource";
452
+ const m = pe(
453
+ d.flatMap((l) => {
454
+ const f = c.get(l.file) ?? "resource";
455
455
  if (f !== "document" || !t.locales || !l.locale)
456
456
  return [{ kind: f, pathname: l.pathname }];
457
457
  const S = new URL(
458
- Z(l.pathname, l.locale, t.locales, n),
459
- n
458
+ Y(l.pathname, l.locale, t.locales, o),
459
+ o
460
460
  );
461
461
  return [{ kind: f, pathname: `${S.pathname}${S.search}` }];
462
462
  })
463
- ), p = pt(), y = [], m = { ...t.ssr, navigation: "document" }, g = t.locales ? mt({
464
- adapter: k,
463
+ ), H = mt(), w = [], h = { ...t.ssr, navigation: "document" }, O = t.locales ? wt({
464
+ adapter: _,
465
465
  locales: t.locales,
466
466
  onError: t.onError,
467
467
  routeModules: e,
468
468
  routes: t.routes,
469
- ssr: m
469
+ ssr: h
470
470
  }) : void 0;
471
- for (const l of d) {
472
- const f = V(n, l.pathname, l.kind), S = g ? await g(f) : await wt(r, f, {
471
+ for (const l of m) {
472
+ const f = q(o, l.pathname, l.kind), S = O ? await O(f) : await yt(r, f, {
473
473
  onError: t.onError,
474
- rateLimitStore: p,
475
- ssr: m
474
+ rateLimitStore: H,
475
+ ssr: h
476
476
  });
477
- y.push(
478
- l.kind === "document" ? await q(l, S, 200) : await we(l, S)
477
+ w.push(
478
+ l.kind === "document" ? await z(l, S, 200) : await ye(l, S)
479
479
  );
480
480
  }
481
- const R = V(n, "/404", "document"), w = t.locales ? yt(R, gt(t.locales)).locale : void 0, F = await St(
481
+ const y = q(o, "/404", "document"), g = t.locales ? gt(y, St(t.locales)).locale : void 0, I = await Et(
482
482
  r,
483
- R,
483
+ y,
484
484
  {
485
- ...m,
486
- dir: w ? Et(w, t.locales) : m.dir,
487
- lang: w ?? m.lang,
488
- locale: w ?? m.locale,
485
+ ...h,
486
+ dir: g ? vt(g, t.locales) : h.dir,
487
+ lang: g ?? h.lang,
488
+ locale: g ?? h.locale,
489
489
  onError: (l, f) => t.onError?.(l, { pathname: "/404", site: f })
490
490
  }
491
491
  );
492
- y.push(
493
- await q(
492
+ w.push(
493
+ await z(
494
494
  {
495
495
  file: "404.html",
496
496
  pathname: "*"
497
497
  },
498
- F,
498
+ I,
499
499
  404
500
500
  )
501
501
  );
502
- const N = y.map((l) => l.body);
503
- Lt(N, t.images);
504
- const v = await Jt({
505
- documents: N,
506
- outDir: o,
502
+ const R = w.map((l) => l.body);
503
+ Mt(R, t.images);
504
+ const T = await Lt({
505
+ documents: R,
506
+ outDir: i,
507
507
  policy: t.images
508
- }), T = await Pt({
508
+ }), A = await bt({
509
509
  fonts: t.fonts,
510
510
  root: t.root ?? process.cwd()
511
511
  });
512
- y.sort((l, f) => l.file.localeCompare(f.file)), v.sort((l, f) => l.file.localeCompare(f.file)), T.sort((l, f) => l.file.localeCompare(f.file));
513
- const P = {
512
+ w.sort((l, f) => l.file.localeCompare(f.file)), T.sort((l, f) => l.file.localeCompare(f.file)), A.sort((l, f) => l.file.localeCompare(f.file));
513
+ const N = {
514
514
  adapter: "static",
515
- entries: y.map(({ body: l, ...f }) => f),
516
- fileHeaderRules: await ie(
515
+ entries: w.map(({ body: l, ...f }) => f),
516
+ fileHeaderRules: await ae(
517
517
  r,
518
518
  t.staticFileHeaders ?? []
519
519
  ),
520
- fontFiles: T.map((l) => l.file),
521
- imageFiles: v.map((l) => l.file),
520
+ fontFiles: A.map((l) => l.file),
521
+ imageFiles: T.map((l) => l.file),
522
522
  origin: n,
523
523
  version: 1
524
524
  };
525
- return await Oe(o, y, [...v, ...T], P), P;
525
+ return await Re(i, w, [...T, ...A], N), N;
526
526
  }
527
- function oe(t, e) {
527
+ function ie(t, e) {
528
528
  const r = new URL(t);
529
- return e.supportedLocales.flatMap((n) => new URL(Z("/", n, e, t), t).origin === r.origin ? [n] : []);
529
+ return e.supportedLocales.flatMap((n) => new URL(Y("/", n, e, t), t).origin === r.origin ? [n] : []);
530
530
  }
531
- async function ie(t, e) {
532
- const r = await ae(t), n = _(r);
531
+ async function ae(t, e) {
532
+ const r = await se(t), n = V(r);
533
533
  return [
534
- ...e.map((o) => (se(o.pattern), {
535
- headers: _(
536
- vt(r, { headers: o.headers })
534
+ ...e.map((o) => (ce(o.pattern), {
535
+ headers: V(
536
+ $t(r, { headers: o.headers })
537
537
  ),
538
538
  pattern: o.pattern
539
539
  })),
540
540
  {
541
541
  headers: {
542
542
  ...n,
543
- "cache-control": Tt
543
+ "cache-control": At
544
544
  },
545
- pattern: Q.source
545
+ pattern: X.source
546
546
  },
547
547
  {
548
548
  headers: {
549
549
  ...n,
550
- "cache-control": At
550
+ "cache-control": Ft
551
551
  },
552
552
  pattern: ".*"
553
553
  }
554
554
  ];
555
555
  }
556
- async function ae(t) {
556
+ async function se(t) {
557
557
  return { headers: (await t.policies.find(
558
558
  (n) => n.fileSegments.length === 0
559
559
  )?.load())?.policy?.document?.headers };
560
560
  }
561
- function _(t) {
562
- return Object.fromEntries($t(t, {}).entries());
561
+ function V(t) {
562
+ return Object.fromEntries(Ot(t, {}).entries());
563
563
  }
564
- function se(t) {
564
+ function ce(t) {
565
565
  try {
566
566
  new RegExp(t);
567
567
  } catch {
@@ -570,7 +570,7 @@ function se(t) {
570
570
  );
571
571
  }
572
572
  }
573
- function ce(t) {
573
+ function ue(t) {
574
574
  let e;
575
575
  try {
576
576
  e = new URL(t ?? "http://demiurge.local");
@@ -585,7 +585,7 @@ function ce(t) {
585
585
  );
586
586
  return e.origin;
587
587
  }
588
- function ue(t, e) {
588
+ function le(t, e) {
589
589
  if (e === 0)
590
590
  throw new Error("Static output requires at least one page route.");
591
591
  if (!t.fallbacks.notFound.some(
@@ -595,10 +595,10 @@ function ue(t, e) {
595
595
  "Static output requires a root @not-found.tsx so 404.html is app-owned."
596
596
  );
597
597
  }
598
- async function le(t) {
598
+ async function fe(t) {
599
599
  const e = /* @__PURE__ */ new Map();
600
600
  for (const r of t.routes) {
601
- const n = await r.load(), o = fe(n);
601
+ const n = await r.load(), o = de(n);
602
602
  if (o.length > 0)
603
603
  throw new Error(
604
604
  `Static route ${JSON.stringify(r.file)} exports unsupported methods ${o.join(", ")}. Deploy a runtime adapter for request-time methods.`
@@ -611,14 +611,14 @@ async function le(t) {
611
611
  e.set(r.file, "document");
612
612
  continue;
613
613
  }
614
- de(r.file, n.GET), e.set(r.file, "resource");
614
+ he(r.file, n.GET), e.set(r.file, "resource");
615
615
  }
616
616
  return e;
617
617
  }
618
- function fe(t) {
618
+ function de(t) {
619
619
  return ["POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"].filter((e) => t[e] !== void 0);
620
620
  }
621
- function de(t, e) {
621
+ function he(t, e) {
622
622
  if ((e.kind === "text" || e.kind === "html" || e.kind === "json") && typeof e.value != "function")
623
623
  return;
624
624
  const r = "value" in e && typeof e.value == "function" ? `uses a request-dependent ${e.kind} value` : `uses the ${e.kind} response helper`;
@@ -626,13 +626,13 @@ function de(t, e) {
626
626
  `Static route ${JSON.stringify(t)} ${r} and cannot produce a fixed output file. Use a fixed text, html, or json value, or deploy a runtime adapter.`
627
627
  );
628
628
  }
629
- function he(t) {
629
+ function pe(t) {
630
630
  const e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
631
631
  return t.map(({ kind: n, pathname: o }) => {
632
632
  if (r.has(o))
633
633
  throw new Error(`Static output collected duplicate pathname ${JSON.stringify(o)}.`);
634
634
  r.add(o);
635
- const i = n === "document" ? it(o) : pe(o), c = i.toLocaleLowerCase("en-US"), s = [...e.entries()].find(
635
+ const i = n === "document" ? at(o) : me(o), c = i.toLocaleLowerCase("en-US"), s = [...e.entries()].find(
636
636
  ([a]) => a === c || a.startsWith(`${c}/`) || c.startsWith(`${a}/`)
637
637
  );
638
638
  if (s)
@@ -642,7 +642,7 @@ function he(t) {
642
642
  return e.set(c, o), { file: i, kind: n, pathname: o };
643
643
  });
644
644
  }
645
- function it(t) {
645
+ function at(t) {
646
646
  if (!t.startsWith("/") || t.includes("?") || t.includes("#"))
647
647
  throw new Error(`Static output received invalid pathname ${JSON.stringify(t)}.`);
648
648
  return t === "/" ? "index.html" : [...t.split("/").slice(1).map((r) => {
@@ -652,27 +652,27 @@ function it(t) {
652
652
  } catch {
653
653
  throw new Error(`Static output pathname is not valid UTF-8: ${JSON.stringify(t)}.`);
654
654
  }
655
- return me(n, t), n;
655
+ return we(n, t), n;
656
656
  }), "index.html"].join("/");
657
657
  }
658
- function pe(t) {
658
+ function me(t) {
659
659
  if (t === "/")
660
660
  throw new Error("A static resource route cannot own the root pathname.");
661
- return it(t).slice(0, -11);
661
+ return at(t).slice(0, -11);
662
662
  }
663
- function me(t, e) {
663
+ function we(t, e) {
664
664
  const r = /[<>:"|?*]/.test(t) || [...t].some((n) => n.charCodeAt(0) <= 31) || /[. ]$/.test(t) || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(t);
665
665
  if (!t || t === "." || t === ".." || t.includes("/") || t.includes("\\") || r)
666
666
  throw new Error(
667
667
  `Static pathname ${JSON.stringify(e)} contains a segment that is unsafe or not portable as a file name: ${JSON.stringify(t)}.`
668
668
  );
669
669
  }
670
- function V(t, e, r) {
670
+ function q(t, e, r) {
671
671
  return new Request(`${t}${e}`, {
672
672
  headers: { accept: r === "document" ? "text/html" : "*/*" }
673
673
  });
674
674
  }
675
- async function q(t, e, r) {
675
+ async function z(t, e, r) {
676
676
  if (e.status !== r)
677
677
  throw new Error(
678
678
  `Static output for ${JSON.stringify(t.pathname)} returned status ${e.status}; expected ${r}.`
@@ -686,19 +686,19 @@ async function q(t, e, r) {
686
686
  throw new Error(
687
687
  `Static output for ${JSON.stringify(t.pathname)} attempted to set a cookie. Build artifacts cannot contain per-user response state.`
688
688
  );
689
- const o = await ye(
689
+ const o = await ge(
690
690
  await e.text(),
691
691
  e.headers
692
692
  );
693
- return await Se(t.pathname, o, e.headers), {
693
+ return await Ee(t.pathname, o, e.headers), {
694
694
  file: t.file,
695
- headers: st(e.headers),
695
+ headers: ct(e.headers),
696
696
  body: o,
697
697
  pathname: t.pathname,
698
698
  status: r
699
699
  };
700
700
  }
701
- async function we(t, e) {
701
+ async function ye(t, e) {
702
702
  if (e.status !== 200)
703
703
  throw new Error(
704
704
  `Static output for ${JSON.stringify(t.pathname)} returned status ${e.status}; expected 200.`
@@ -709,34 +709,34 @@ async function we(t, e) {
709
709
  );
710
710
  return {
711
711
  file: t.file,
712
- headers: st(e.headers),
712
+ headers: ct(e.headers),
713
713
  body: await e.text(),
714
714
  pathname: t.pathname,
715
715
  status: 200
716
716
  };
717
717
  }
718
- async function ye(t, e) {
718
+ async function ge(t, e) {
719
719
  const r = new RegExp(
720
- `(?:^|\\s)${j}(?:\\s|$)`
721
- ), n = at(t, "script").filter((i) => r.test(i.attributes));
720
+ `(?:^|\\s)${D}(?:\\s|$)`
721
+ ), n = st(t, "script").filter((i) => r.test(i.attributes));
722
722
  if (n.length === 0)
723
723
  return t;
724
724
  const o = await Promise.all(
725
- n.map((i) => Y(i.content))
725
+ n.map((i) => Q(i.content))
726
726
  );
727
727
  for (const i of [
728
728
  "content-security-policy",
729
729
  "content-security-policy-report-only"
730
730
  ]) {
731
731
  const c = e.get(i);
732
- c && e.set(i, ge(c, o));
732
+ c && e.set(i, Se(c, o));
733
733
  }
734
734
  return t.replace(
735
- new RegExp(`\\s${j}(?=\\s|>)`, "g"),
735
+ new RegExp(`\\s${D}(?=\\s|>)`, "g"),
736
736
  ""
737
737
  );
738
738
  }
739
- function ge(t, e) {
739
+ function Se(t, e) {
740
740
  const r = t.split(";").map((a) => a.trim()).filter(Boolean), n = r.findIndex(
741
741
  (a) => a.split(/\s+/, 1)[0]?.toLowerCase() === "script-src"
742
742
  ), o = r.find(
@@ -750,7 +750,7 @@ function ge(t, e) {
750
750
  ].join(" ");
751
751
  return n === -1 ? r.push(s) : r[n] = s, r.join("; ");
752
752
  }
753
- async function Se(t, e, r) {
753
+ async function Ee(t, e, r) {
754
754
  const n = r.get("content-security-policy");
755
755
  if (!n)
756
756
  return;
@@ -758,24 +758,24 @@ async function Se(t, e, r) {
758
758
  throw new Error(
759
759
  `Static output for ${JSON.stringify(t)} uses a nonce-backed CSP. Use security.static() with stable hashes or a runtime adapter that injects a fresh nonce.`
760
760
  );
761
- const o = Ee(n);
762
- await z(
761
+ const o = ve(n);
762
+ await B(
763
763
  t,
764
764
  e,
765
765
  "script",
766
- J(o, "script-src", "default-src")
767
- ), await z(
766
+ L(o, "script-src", "default-src")
767
+ ), await B(
768
768
  t,
769
769
  e,
770
770
  "style",
771
- J(
771
+ L(
772
772
  o,
773
773
  "style-src-elem",
774
774
  "style-src",
775
775
  "default-src"
776
776
  )
777
777
  );
778
- const i = J(
778
+ const i = L(
779
779
  o,
780
780
  "style-src-attr",
781
781
  "style-src",
@@ -786,7 +786,7 @@ async function Se(t, e, r) {
786
786
  `Static output for ${JSON.stringify(t)} contains an inline style attribute that its CSP does not allow. Move the style into a stylesheet or explicitly allow inline styles.`
787
787
  );
788
788
  }
789
- function Ee(t) {
789
+ function ve(t) {
790
790
  const e = /* @__PURE__ */ new Map();
791
791
  for (const r of t.split(";")) {
792
792
  const [n, ...o] = r.trim().split(/\s+/);
@@ -794,20 +794,20 @@ function Ee(t) {
794
794
  }
795
795
  return e;
796
796
  }
797
- function J(t, ...e) {
797
+ function L(t, ...e) {
798
798
  for (const r of e) {
799
799
  const n = t.get(r);
800
800
  if (n)
801
801
  return n;
802
802
  }
803
803
  }
804
- async function z(t, e, r, n) {
804
+ async function B(t, e, r, n) {
805
805
  if (!(!n || n.includes("'unsafe-inline'")))
806
- for (const o of at(e, r)) {
806
+ for (const o of st(e, r)) {
807
807
  if (r === "script") {
808
- const c = ve(o.attributes, "src");
808
+ const c = $e(o.attributes, "src");
809
809
  if (c) {
810
- if (!$e(n, c))
810
+ if (!Oe(n, c))
811
811
  throw new Error(
812
812
  `Static output for ${JSON.stringify(t)} contains script ${JSON.stringify(c)} that the effective script-src directive does not allow. Add its origin to security.needs.script or the route CSP policy.`
813
813
  );
@@ -816,19 +816,19 @@ async function z(t, e, r, n) {
816
816
  }
817
817
  if (!o.content)
818
818
  continue;
819
- const i = await Y(o.content);
819
+ const i = await Q(o.content);
820
820
  if (!n.includes(i))
821
821
  throw new Error(
822
822
  `Static output for ${JSON.stringify(t)} contains an inline ${r} without the required CSP hash ${i}.`
823
823
  );
824
824
  }
825
825
  }
826
- function ve(t, e) {
826
+ function $e(t, e) {
827
827
  return t.match(
828
828
  new RegExp(`(?:^|\\s)${e}\\s*=\\s*["']([^"']+)["']`, "i")
829
829
  )?.[1]?.replaceAll("&amp;", "&");
830
830
  }
831
- function $e(t, e) {
831
+ function Oe(t, e) {
832
832
  if (!t)
833
833
  return !0;
834
834
  if (t.includes("'none'") || t.includes("'strict-dynamic'") && t.some(
@@ -856,7 +856,7 @@ function $e(t, e) {
856
856
  return r.protocol === o.protocol && i && r.port === o.port && c;
857
857
  });
858
858
  }
859
- function at(t, e) {
859
+ function st(t, e) {
860
860
  const r = t.toLowerCase(), n = [], o = `<${e}`, i = `</${e}`;
861
861
  let c = 0;
862
862
  for (; c < t.length; ) {
@@ -873,39 +873,39 @@ function at(t, e) {
873
873
  }
874
874
  return n;
875
875
  }
876
- function st(t) {
876
+ function ct(t) {
877
877
  return Object.fromEntries(
878
878
  [...t.entries()].sort(([e], [r]) => e.localeCompare(r))
879
879
  );
880
880
  }
881
- async function Oe(t, e, r, n) {
882
- const o = M(t);
883
- await x(o, { recursive: !0 });
884
- const i = await G($(o, ".demiurge-static-"));
881
+ async function Re(t, e, r, n) {
882
+ const o = j(t);
883
+ await b(o, { recursive: !0 });
884
+ const i = await K(v(o, ".demiurge-static-"));
885
885
  try {
886
886
  for (const a of [...e, ...r]) {
887
- const u = B(i, a.file);
888
- await x(M(u), { recursive: !0 }), await L(u, a.body);
887
+ const u = G(i, a.file);
888
+ await b(j(u), { recursive: !0 }), await M(u, a.body);
889
889
  }
890
- await L(
891
- $(i, ot),
890
+ await M(
891
+ v(i, it),
892
892
  `${JSON.stringify(n, null, 2)}
893
893
  `
894
894
  );
895
- const c = await Re(t);
896
- await x(t, { recursive: !0 }), await K(i, t, { recursive: !0, force: !0 });
895
+ const c = await Te(t);
896
+ await b(t, { recursive: !0 }), await Z(i, t, { recursive: !0, force: !0 });
897
897
  const s = new Set(
898
898
  [...e, ...r].map((a) => a.file)
899
899
  );
900
900
  for (const a of c)
901
- s.has(a) || await C(B(t, a), { force: !0 });
901
+ s.has(a) || await x(G(t, a), { force: !0 });
902
902
  } finally {
903
- await C(i, { force: !0, recursive: !0 });
903
+ await x(i, { force: !0, recursive: !0 });
904
904
  }
905
905
  }
906
- async function Re(t) {
906
+ async function Te(t) {
907
907
  try {
908
- const e = await A($(t, ot), "utf8"), r = JSON.parse(e);
908
+ const e = await F(v(t, it), "utf8"), r = JSON.parse(e);
909
909
  if (r.adapter !== "static" || r.version !== 1 || !Array.isArray(r.entries))
910
910
  return [];
911
911
  const n = Array.isArray(r.fontFiles) ? r.fontFiles : [], o = Array.isArray(r.imageFiles) ? r.imageFiles : [];
@@ -914,29 +914,29 @@ async function Re(t) {
914
914
  ...n,
915
915
  ...o
916
916
  ].flatMap(
917
- (i) => typeof i == "string" && ct(i) ? [i] : []
917
+ (i) => typeof i == "string" && ut(i) ? [i] : []
918
918
  );
919
919
  } catch {
920
920
  return [];
921
921
  }
922
922
  }
923
- function B(t, e) {
924
- if (!ct(e))
923
+ function G(t, e) {
924
+ if (!ut(e))
925
925
  throw new Error(`Static output file must stay inside the output directory: ${JSON.stringify(e)}.`);
926
- const r = h(t), n = h(r, e);
927
- if (E(r, n).split(O).includes(".."))
926
+ const r = p(t), n = p(r, e);
927
+ if (E(r, n).split($).includes(".."))
928
928
  throw new Error(`Static output file escaped the output directory: ${JSON.stringify(e)}.`);
929
929
  return n;
930
930
  }
931
- function ct(t) {
931
+ function ut(t) {
932
932
  return !!t && !t.startsWith("/") && !t.startsWith("\\") && !t.split(/[\\/]/).includes("..");
933
933
  }
934
934
  export {
935
- Me as createStaticPreviewServer,
936
- Bt as createVercelOutputConfig,
937
- We as generateStaticOutput,
938
- De as generateVercelStaticOutput,
939
- k as staticAdapter,
940
- je as vercelStatic
935
+ je as createStaticPreviewServer,
936
+ Gt as createVercelOutputConfig,
937
+ Ue as generateStaticOutput,
938
+ We as generateVercelStaticOutput,
939
+ _ as staticAdapter,
940
+ De as vercelStatic
941
941
  };
942
942
  //# sourceMappingURL=index.js.map