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

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 (191) hide show
  1. package/README.md +13 -11
  2. package/bin/demiurge.mjs +30 -12
  3. package/dist/browser/file-router.d.ts +388 -5
  4. package/dist/browser/file-router.d.ts.map +1 -1
  5. package/dist/browser/focus.d.ts +20 -0
  6. package/dist/browser/focus.d.ts.map +1 -0
  7. package/dist/browser/index.d.ts +7 -1
  8. package/dist/browser/index.d.ts.map +1 -1
  9. package/dist/browser/mutation-action.d.ts +81 -0
  10. package/dist/browser/mutation-action.d.ts.map +1 -0
  11. package/dist/chunks/document-shell-CpJnFtSC.js +36 -0
  12. package/dist/chunks/document-shell-CpJnFtSC.js.map +1 -0
  13. package/dist/chunks/env-startup-DOBYWlZD.js +257 -0
  14. package/dist/chunks/env-startup-DOBYWlZD.js.map +1 -0
  15. package/dist/chunks/{image-codec-Di53WpcH.js → image-codec-BmzWnH6W.js} +2 -2
  16. package/dist/chunks/{image-codec-Di53WpcH.js.map → image-codec-BmzWnH6W.js.map} +1 -1
  17. package/dist/chunks/{images-Edar3eU1.js → images-BQ80950B.js} +99 -91
  18. package/dist/chunks/images-BQ80950B.js.map +1 -0
  19. package/dist/chunks/index-BVk9zWbe.js +832 -0
  20. package/dist/chunks/index-BVk9zWbe.js.map +1 -0
  21. package/dist/chunks/manifest-vO6c0G0W.js +19 -0
  22. package/dist/chunks/manifest-vO6c0G0W.js.map +1 -0
  23. package/dist/chunks/plugin-BQgMiHxa.js +1827 -0
  24. package/dist/chunks/plugin-BQgMiHxa.js.map +1 -0
  25. package/dist/chunks/session-store-ChModVcq.js +92 -0
  26. package/dist/chunks/session-store-ChModVcq.js.map +1 -0
  27. package/dist/chunks/static-files-ehaD1kE7.js +51 -0
  28. package/dist/chunks/static-files-ehaD1kE7.js.map +1 -0
  29. package/dist/chunks/{streaming-D0fGAuiO.js → streaming-BEbPN7Uk.js} +163 -163
  30. package/dist/chunks/streaming-BEbPN7Uk.js.map +1 -0
  31. package/dist/chunks/testing-DueXbMo4.js +4167 -0
  32. package/dist/chunks/testing-DueXbMo4.js.map +1 -0
  33. package/dist/chunks/vite-DO70kZA6.js +259 -0
  34. package/dist/chunks/vite-DO70kZA6.js.map +1 -0
  35. package/dist/cli.d.ts +17 -25
  36. package/dist/cli.d.ts.map +1 -1
  37. package/dist/cli.js +159 -124
  38. package/dist/cli.js.map +1 -1
  39. package/dist/config/define.d.ts +3 -0
  40. package/dist/config/define.d.ts.map +1 -0
  41. package/dist/config/index.d.ts +7 -0
  42. package/dist/config/index.d.ts.map +1 -0
  43. package/dist/config/index.js +78 -0
  44. package/dist/config/index.js.map +1 -0
  45. package/dist/config/load.d.ts +12 -0
  46. package/dist/config/load.d.ts.map +1 -0
  47. package/dist/config/types.d.ts +64 -0
  48. package/dist/config/types.d.ts.map +1 -0
  49. package/dist/config/validate.d.ts +9 -0
  50. package/dist/config/validate.d.ts.map +1 -0
  51. package/dist/config/vite.d.ts +12 -0
  52. package/dist/config/vite.d.ts.map +1 -0
  53. package/dist/data/cache.d.ts +2 -0
  54. package/dist/data/cache.d.ts.map +1 -1
  55. package/dist/data/idempotency.d.ts.map +1 -1
  56. package/dist/deployment/testing.d.ts +25 -0
  57. package/dist/deployment/testing.d.ts.map +1 -0
  58. package/dist/deployment/testing.js +171 -0
  59. package/dist/deployment/testing.js.map +1 -0
  60. package/dist/document/hydration.d.ts +9 -0
  61. package/dist/document/hydration.d.ts.map +1 -1
  62. package/dist/document/index.d.ts +4 -2
  63. package/dist/document/index.d.ts.map +1 -1
  64. package/dist/document/metadata.d.ts +8 -0
  65. package/dist/document/metadata.d.ts.map +1 -1
  66. package/dist/document/navigation.d.ts +28 -0
  67. package/dist/document/navigation.d.ts.map +1 -0
  68. package/dist/document/render.d.ts +3 -1
  69. package/dist/document/render.d.ts.map +1 -1
  70. package/dist/document/seo.d.ts.map +1 -1
  71. package/dist/edge/assets.d.ts.map +1 -1
  72. package/dist/edge/index.js +55 -73
  73. package/dist/edge/index.js.map +1 -1
  74. package/dist/index.d.ts +12 -10
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +1860 -691
  77. package/dist/index.js.map +1 -1
  78. package/dist/internal/testing.js +12 -12
  79. package/dist/kv/index.d.ts +2 -0
  80. package/dist/kv/index.d.ts.map +1 -1
  81. package/dist/kv/index.js +170 -73
  82. package/dist/kv/index.js.map +1 -1
  83. package/dist/kv/session-store.d.ts +20 -0
  84. package/dist/kv/session-store.d.ts.map +1 -0
  85. package/dist/manifest.d.ts +10 -0
  86. package/dist/manifest.d.ts.map +1 -0
  87. package/dist/node/image.d.ts.map +1 -1
  88. package/dist/node/index.d.ts +3 -0
  89. package/dist/node/index.d.ts.map +1 -1
  90. package/dist/node/index.js +251 -178
  91. package/dist/node/index.js.map +1 -1
  92. package/dist/node/serve.d.ts +47 -0
  93. package/dist/node/serve.d.ts.map +1 -0
  94. package/dist/node/static.d.ts.map +1 -1
  95. package/dist/platform/fonts.d.ts.map +1 -1
  96. package/dist/platform/image-url.d.ts.map +1 -1
  97. package/dist/platform/url.d.ts +19 -0
  98. package/dist/platform/url.d.ts.map +1 -0
  99. package/dist/platform/web-vitals.d.ts.map +1 -1
  100. package/dist/redis/index.d.ts +2 -0
  101. package/dist/redis/index.d.ts.map +1 -1
  102. package/dist/redis/index.js +186 -69
  103. package/dist/redis/index.js.map +1 -1
  104. package/dist/redis/session-store.d.ts +9 -0
  105. package/dist/redis/session-store.d.ts.map +1 -0
  106. package/dist/route/index.d.ts +2 -2
  107. package/dist/route/index.d.ts.map +1 -1
  108. package/dist/route/mutation.d.ts +97 -0
  109. package/dist/route/mutation.d.ts.map +1 -0
  110. package/dist/route/types.d.ts +6 -1
  111. package/dist/route/types.d.ts.map +1 -1
  112. package/dist/router/manifest.d.ts +8 -0
  113. package/dist/router/manifest.d.ts.map +1 -1
  114. package/dist/router/navigation-data.d.ts +9 -1
  115. package/dist/router/navigation-data.d.ts.map +1 -1
  116. package/dist/routing/generate.d.ts +3 -0
  117. package/dist/routing/generate.d.ts.map +1 -1
  118. package/dist/routing/index.d.ts +3 -1
  119. package/dist/routing/index.d.ts.map +1 -1
  120. package/dist/routing/locale.d.ts +43 -0
  121. package/dist/routing/locale.d.ts.map +1 -0
  122. package/dist/routing/types.d.ts +12 -0
  123. package/dist/routing/types.d.ts.map +1 -1
  124. package/dist/security/cookie-session.d.ts +43 -0
  125. package/dist/security/cookie-session.d.ts.map +1 -0
  126. package/dist/security/csrf.d.ts +1 -1
  127. package/dist/security/csrf.d.ts.map +1 -1
  128. package/dist/security/env-startup.d.ts +15 -0
  129. package/dist/security/env-startup.d.ts.map +1 -0
  130. package/dist/security/env.d.ts +25 -6
  131. package/dist/security/env.d.ts.map +1 -1
  132. package/dist/security/index.d.ts +9 -1
  133. package/dist/security/index.d.ts.map +1 -1
  134. package/dist/security/report.d.ts.map +1 -1
  135. package/dist/security/session-manager.d.ts +32 -0
  136. package/dist/security/session-manager.d.ts.map +1 -0
  137. package/dist/security/session-store.d.ts +51 -0
  138. package/dist/security/session-store.d.ts.map +1 -0
  139. package/dist/security/testing.d.ts +10 -0
  140. package/dist/security/testing.d.ts.map +1 -0
  141. package/dist/security/testing.js +145 -0
  142. package/dist/security/testing.js.map +1 -0
  143. package/dist/security/types.d.ts +1 -0
  144. package/dist/security/types.d.ts.map +1 -1
  145. package/dist/server/document-shell.d.ts.map +1 -1
  146. package/dist/server/errors.d.ts +1 -0
  147. package/dist/server/errors.d.ts.map +1 -1
  148. package/dist/server/index.d.ts +1 -0
  149. package/dist/server/index.d.ts.map +1 -1
  150. package/dist/server/not-found.d.ts +1 -0
  151. package/dist/server/not-found.d.ts.map +1 -1
  152. package/dist/server/render-tree.d.ts.map +1 -1
  153. package/dist/server/request-handler.d.ts +4 -0
  154. package/dist/server/request-handler.d.ts.map +1 -1
  155. package/dist/server/request-metadata.d.ts +1 -0
  156. package/dist/server/request-metadata.d.ts.map +1 -1
  157. package/dist/server/ssr.d.ts +2 -0
  158. package/dist/server/ssr.d.ts.map +1 -1
  159. package/dist/static/index.d.ts +2 -0
  160. package/dist/static/index.d.ts.map +1 -1
  161. package/dist/static/index.js +380 -363
  162. package/dist/static/index.js.map +1 -1
  163. package/dist/static/preview.d.ts.map +1 -1
  164. package/dist/static/vercel.d.ts +11 -2
  165. package/dist/static/vercel.d.ts.map +1 -1
  166. package/dist/static-files.d.ts +12 -0
  167. package/dist/static-files.d.ts.map +1 -1
  168. package/dist/type-guards.d.ts +19 -0
  169. package/dist/type-guards.d.ts.map +1 -0
  170. package/dist/vite/env-boundary.d.ts +14 -0
  171. package/dist/vite/env-boundary.d.ts.map +1 -0
  172. package/dist/vite/index.d.ts +5 -3
  173. package/dist/vite/index.d.ts.map +1 -1
  174. package/dist/vite/index.js +22 -1560
  175. package/dist/vite/index.js.map +1 -1
  176. package/dist/vite/plugin.d.ts +6 -1
  177. package/dist/vite/plugin.d.ts.map +1 -1
  178. package/dist/vite/policy-verification.d.ts.map +1 -1
  179. package/package.json +19 -6
  180. package/dist/chunks/document-shell-WoM8yZlR.js +0 -35
  181. package/dist/chunks/document-shell-WoM8yZlR.js.map +0 -1
  182. package/dist/chunks/images-Edar3eU1.js.map +0 -1
  183. package/dist/chunks/request-metadata-DaIYq4Ea.js +0 -677
  184. package/dist/chunks/request-metadata-DaIYq4Ea.js.map +0 -1
  185. package/dist/chunks/static-files-DUjHw-4H.js +0 -11
  186. package/dist/chunks/static-files-DUjHw-4H.js.map +0 -1
  187. package/dist/chunks/streaming-D0fGAuiO.js.map +0 -1
  188. package/dist/chunks/testing-CRflAw4X.js +0 -3475
  189. package/dist/chunks/testing-CRflAw4X.js.map +0 -1
  190. package/dist/route/action.d.ts +0 -33
  191. package/dist/route/action.d.ts.map +0 -1
@@ -1,21 +1,21 @@
1
1
  import { Readable as T, Transform as N } from "node:stream";
2
2
  import { pipeline as P } from "node:stream/promises";
3
3
  import { isIP as k } from "node:net";
4
- import { s as M, a as $, c as L, b as U } from "./request-metadata-DaIYq4Ea.js";
4
+ import { s as M, a as $, c as L, b as U } from "./index-BVk9zWbe.js";
5
5
  import { createHash as z } from "node:crypto";
6
- import { r as O, n as F, t as _ } from "./image-codec-Di53WpcH.js";
7
- import { d as G, e as W, h as B, j as V } from "./images-Edar3eU1.js";
8
- import { R } from "./static-files-DUjHw-4H.js";
9
- import { readFile as j } from "node:fs/promises";
10
- import { resolve as v, relative as K, sep as Y } from "node:path";
11
- import { renderToPipeableStream as J } from "react-dom/server";
12
- import { c as Q } from "./document-shell-WoM8yZlR.js";
6
+ import { r as O, n as F, t as _ } from "./image-codec-BmzWnH6W.js";
7
+ import { d as G, e as W, h as B, j as V, u as j } from "./images-BQ80950B.js";
8
+ import { R } from "./static-files-ehaD1kE7.js";
9
+ import { readFile as K } from "node:fs/promises";
10
+ import { resolve as v, relative as Y, sep as J } from "node:path";
11
+ import { renderToPipeableStream as Q } from "react-dom/server";
12
+ import { c as X } from "./document-shell-CpJnFtSC.js";
13
13
  const y = {
14
14
  for: "x-forwarded-for",
15
15
  host: "x-forwarded-host",
16
16
  protocol: "x-forwarded-proto"
17
- }, C = !1, X = /* @__PURE__ */ new Set(["CONNECT", "TRACE", "TRACK"]);
18
- class Z extends Error {
17
+ }, C = !1, Z = /* @__PURE__ */ new Set(["CONNECT", "TRACE", "TRACK"]);
18
+ class q extends Error {
19
19
  method;
20
20
  constructor(t) {
21
21
  super(`HTTP method "${t}" is not supported.`), this.method = t, this.name = "UnsupportedMethodError";
@@ -27,12 +27,12 @@ class E extends Error {
27
27
  super(`HTTP host "${t}" is not allowed.`), this.host = t, this.name = "UntrustedHostError";
28
28
  }
29
29
  }
30
- function q(e) {
30
+ function ee(e) {
31
31
  if (e.allowedHosts.length === 0)
32
32
  throw new Error("Demiurge Node allowedHosts must contain at least one host.");
33
- for (const n of e.allowedHosts)
34
- if (!b(n))
35
- throw new Error(`Demiurge Node allowed host "${n}" is invalid.`);
33
+ for (const r of e.allowedHosts)
34
+ if (!b(r))
35
+ throw new Error(`Demiurge Node allowed host "${r}" is invalid.`);
36
36
  const t = e.trustProxy ?? C;
37
37
  if (t !== !1) {
38
38
  if ("hops" in t) {
@@ -42,61 +42,61 @@ function q(e) {
42
42
  );
43
43
  return;
44
44
  }
45
- for (const n of t.ranges) {
46
- const o = n.split("/")[0];
47
- I(o, n);
45
+ for (const r of t.ranges) {
46
+ const n = r.split("/")[0];
47
+ I(n, r);
48
48
  }
49
49
  }
50
50
  }
51
- function Ce(e, t) {
52
- q(t);
53
- const n = e.method ?? "GET";
54
- if (X.has(n.toUpperCase()))
55
- throw new Z(n);
56
- const o = S(e.socket?.remoteAddress), r = ne(
57
- o,
51
+ function De(e, t) {
52
+ ee(t);
53
+ const r = e.method ?? "GET";
54
+ if (Z.has(r.toUpperCase()))
55
+ throw new q(r);
56
+ const n = S(e.socket?.remoteAddress), o = ne(
57
+ n,
58
58
  e.headers[y.for],
59
59
  t.trustProxy ?? C
60
60
  ), s = A(
61
61
  e.headers[y.protocol],
62
- r.forwardedDepth
63
- ), c = ee(e, s), l = A(
62
+ o.forwardedDepth
63
+ ), c = te(e, s), l = A(
64
64
  e.headers[y.host],
65
- r.forwardedDepth
66
- ) ?? e.headers.host, a = te(l, t.allowedHosts), i = `${c}://${a}`, f = new URL(e.url ?? "/", i), u = {
67
- headers: se(e.headers),
68
- method: n,
65
+ o.forwardedDepth
66
+ ) ?? e.headers.host, a = re(l, t.allowedHosts), i = `${c}://${a}`, f = new URL(e.url ?? "/", i), u = {
67
+ headers: ae(e.headers),
68
+ method: r,
69
69
  signal: t.signal
70
70
  };
71
- n !== "GET" && n !== "HEAD" && (u.body = T.toWeb(e), u.duplex = "half");
71
+ r !== "GET" && r !== "HEAD" && (u.body = T.toWeb(e), u.duplex = "half");
72
72
  const h = new Request(f, u);
73
- return M(h, { clientIp: r.clientIp }), h;
73
+ return M(h, { clientIp: o.clientIp }), h;
74
74
  }
75
- function ee(e, t) {
75
+ function te(e, t) {
76
76
  if (t) {
77
- const n = t.toLowerCase();
78
- if (n !== "http" && n !== "https")
77
+ const r = t.toLowerCase();
78
+ if (r !== "http" && r !== "https")
79
79
  throw new Error(`Unsupported forwarded protocol "${t}".`);
80
- return n;
80
+ return r;
81
81
  }
82
82
  return e.socket?.encrypted ? "https" : "http";
83
83
  }
84
- function te(e, t) {
84
+ function re(e, t) {
85
85
  if (t.length === 0)
86
86
  throw new Error("Demiurge Node allowedHosts must contain at least one host.");
87
87
  if (!e)
88
88
  throw new E("");
89
- const n = b(e);
90
- if (!n)
89
+ const r = b(e);
90
+ if (!r)
91
91
  throw new E(e);
92
- if (!t.some((r) => {
93
- const s = b(r);
92
+ if (!t.some((o) => {
93
+ const s = b(o);
94
94
  if (!s)
95
- throw new Error(`Demiurge Node allowed host "${r}" is invalid.`);
96
- return s.port ? s.host === n.host : s.hostname === n.hostname;
95
+ throw new Error(`Demiurge Node allowed host "${o}" is invalid.`);
96
+ return s.port ? s.host === r.host : s.hostname === r.hostname;
97
97
  }))
98
98
  throw new E(e);
99
- return n.host;
99
+ return r.host;
100
100
  }
101
101
  function b(e) {
102
102
  if (e.trim() !== e || e.includes("@"))
@@ -108,55 +108,55 @@ function b(e) {
108
108
  return null;
109
109
  }
110
110
  }
111
- function ne(e, t, n) {
112
- const o = D(t), r = [...o, e];
113
- if (n === !1)
111
+ function ne(e, t, r) {
112
+ const n = D(t), o = [...n, e];
113
+ if (r === !1)
114
114
  return { clientIp: e, forwardedDepth: 0 };
115
- if ("hops" in n) {
116
- if (!Number.isSafeInteger(n.hops) || n.hops < 0)
115
+ if ("hops" in r) {
116
+ if (!Number.isSafeInteger(r.hops) || r.hops < 0)
117
117
  throw new Error(
118
118
  "Demiurge Node trustProxy hop count must be a non-negative integer."
119
119
  );
120
- const l = Math.min(n.hops, o.length);
120
+ const l = Math.min(r.hops, n.length);
121
121
  return {
122
- clientIp: r[r.length - 1 - l],
123
- forwardedDepth: n.hops
122
+ clientIp: o[o.length - 1 - l],
123
+ forwardedDepth: r.hops
124
124
  };
125
125
  }
126
- let s = r.length - 1, c = 0;
127
- for (; s > 0 && x(r[s], n.ranges); )
126
+ let s = o.length - 1, c = 0;
127
+ for (; s > 0 && x(o[s], r.ranges); )
128
128
  s -= 1, c += 1;
129
129
  return {
130
- clientIp: r[s],
131
- forwardedDepth: c || (x(e, n.ranges) ? 1 : 0)
130
+ clientIp: o[s],
131
+ forwardedDepth: c || (x(e, r.ranges) ? 1 : 0)
132
132
  };
133
133
  }
134
134
  function A(e, t) {
135
135
  if (t === 0)
136
136
  return;
137
- const n = D(e);
138
- if (n.length !== 0)
139
- return n[Math.max(0, n.length - t)];
137
+ const r = D(e);
138
+ if (r.length !== 0)
139
+ return r[Math.max(0, r.length - t)];
140
140
  }
141
141
  function D(e) {
142
142
  return (Array.isArray(e) ? e : [e]).flatMap((t) => t?.split(",") ?? []).map((t) => t.trim()).filter(Boolean);
143
143
  }
144
144
  function x(e, t) {
145
- return t.some((n) => I(e, n));
145
+ return t.some((r) => I(e, r));
146
146
  }
147
147
  function I(e, t) {
148
- const [n, o] = t.split("/"), r = H(S(e)), s = H(S(n));
149
- if (!r || !s || r.length !== s.length) {
148
+ const [r, n] = t.split("/"), o = H(S(e)), s = H(S(r));
149
+ if (!o || !s || o.length !== s.length) {
150
150
  if (!s)
151
151
  throw new Error(`Demiurge Node trustProxy range "${t}" is invalid.`);
152
152
  return !1;
153
153
  }
154
- const c = r.length * 8, l = o === void 0 ? c : Number(o);
154
+ const c = o.length * 8, l = n === void 0 ? c : Number(n);
155
155
  if (!Number.isInteger(l) || l < 0 || l > c)
156
156
  throw new Error(`Demiurge Node trustProxy range "${t}" is invalid.`);
157
157
  for (let a = 0; a < l; a += 1) {
158
158
  const i = 1 << 7 - a % 8;
159
- if ((r[Math.floor(a / 8)] & i) !== (s[Math.floor(a / 8)] & i))
159
+ if ((o[Math.floor(a / 8)] & i) !== (s[Math.floor(a / 8)] & i))
160
160
  return !1;
161
161
  }
162
162
  return !0;
@@ -170,9 +170,9 @@ function H(e) {
170
170
  return e.split(".").map(Number);
171
171
  if (t !== 6)
172
172
  return null;
173
- const [n = "", o = ""] = e.split("::"), r = n ? n.split(":") : [], s = o ? o.split(":") : [], c = 8 - r.length - s.length;
173
+ const [r = "", n = ""] = e.split("::"), o = r ? r.split(":") : [], s = n ? n.split(":") : [], c = 8 - o.length - s.length;
174
174
  return [
175
- ...r,
175
+ ...o,
176
176
  ...Array.from({ length: c }, () => "0"),
177
177
  ...s
178
178
  ].flatMap((a) => {
@@ -180,14 +180,14 @@ function H(e) {
180
180
  return [i >> 8, i & 255];
181
181
  });
182
182
  }
183
- function De(e) {
183
+ function Ie(e) {
184
184
  e.statusCode = 501, e.setHeader("content-type", "text/plain; charset=utf-8"), e.end("Not Implemented");
185
185
  }
186
- async function Ie(e, t) {
187
- const n = ae(t.headers);
188
- if (t.headers.forEach((o, r) => {
189
- r !== "set-cookie" && e.setHeader(r, o);
190
- }), n.length > 0 && e.setHeader("set-cookie", n), e.statusCode = t.status, t.statusText && (e.statusMessage = t.statusText), !t.body) {
186
+ async function Ne(e, t) {
187
+ const r = ie(t.headers);
188
+ if (t.headers.forEach((n, o) => {
189
+ o !== "set-cookie" && e.setHeader(o, n);
190
+ }), r.length > 0 && e.setHeader("set-cookie", r), e.statusCode = t.status, t.statusText && (e.statusMessage = t.statusText), !t.body) {
191
191
  e.end();
192
192
  return;
193
193
  }
@@ -198,9 +198,9 @@ async function Ie(e, t) {
198
198
  ),
199
199
  e
200
200
  );
201
- } catch (o) {
202
- if (!re(o))
203
- throw o;
201
+ } catch (n) {
202
+ if (!se(n))
203
+ throw n;
204
204
  }
205
205
  }
206
206
  const oe = /* @__PURE__ */ new Set([
@@ -209,34 +209,34 @@ const oe = /* @__PURE__ */ new Set([
209
209
  "ERR_STREAM_DESTROYED",
210
210
  "ERR_STREAM_PREMATURE_CLOSE"
211
211
  ]);
212
- function re(e) {
212
+ function se(e) {
213
213
  return e instanceof Error && "code" in e && typeof e.code == "string" && oe.has(e.code);
214
214
  }
215
- function se(e) {
215
+ function ae(e) {
216
216
  const t = new Headers();
217
- for (const [n, o] of Object.entries(e)) {
218
- if (Array.isArray(o)) {
219
- for (const r of o)
220
- t.append(n, r);
217
+ for (const [r, n] of Object.entries(e)) {
218
+ if (Array.isArray(n)) {
219
+ for (const o of n)
220
+ t.append(r, o);
221
221
  continue;
222
222
  }
223
- o && t.set(n, o);
223
+ n && t.set(r, n);
224
224
  }
225
225
  return t;
226
226
  }
227
- function ae(e) {
227
+ function ie(e) {
228
228
  const t = e.getSetCookie;
229
229
  if (t)
230
230
  return t.call(e);
231
- const n = e.get("set-cookie");
232
- return n ? ie(n) : [];
231
+ const r = e.get("set-cookie");
232
+ return r ? ce(r) : [];
233
233
  }
234
- function ie(e) {
234
+ function ce(e) {
235
235
  return e.split(/,\s*(?=[^;,=\s]+\s*=)/);
236
236
  }
237
- function Ne(e) {
237
+ function Pe(e) {
238
238
  const t = e.basePath ?? G;
239
- let n;
239
+ let r;
240
240
  return async function(s) {
241
241
  const c = new URL(s.url);
242
242
  if (!c.pathname.startsWith(`${t}/`))
@@ -249,46 +249,46 @@ function Ne(e) {
249
249
  },
250
250
  status: 405
251
251
  });
252
- n ??= o();
252
+ r ??= n();
253
253
  let l;
254
254
  try {
255
- l = await n;
255
+ l = await r;
256
256
  } catch (i) {
257
- throw n = void 0, i;
257
+ throw r = void 0, i;
258
258
  }
259
259
  const a = l.get(c.pathname);
260
- return a ? ce(s, a) : null;
260
+ return a ? le(s, a) : null;
261
261
  };
262
- async function o() {
263
- const r = await O({ ...e, basePath: t });
264
- return new Map(r.map((s) => [s.url, s]));
262
+ async function n() {
263
+ const o = await O({ ...e, basePath: t });
264
+ return new Map(o.map((s) => [s.url, s]));
265
265
  }
266
266
  }
267
- function ce(e, t) {
268
- const n = `"${z("sha256").update(t.body).digest("base64url").slice(0, 27)}"`, o = new Headers({
267
+ function le(e, t) {
268
+ const r = `"${z("sha256").update(t.body).digest("base64url").slice(0, 27)}"`, n = new Headers({
269
269
  "cache-control": R,
270
270
  "content-type": t.contentType,
271
- etag: n
271
+ etag: r
272
272
  });
273
- return e.headers.get("if-none-match") === n ? new Response(null, { headers: o, status: 304 }) : (o.set("content-length", String(t.body.byteLength)), new Response(
273
+ return e.headers.get("if-none-match") === r ? new Response(null, { headers: n, status: 304 }) : (n.set("content-length", String(t.body.byteLength)), new Response(
274
274
  e.method === "HEAD" ? null : t.body,
275
- { headers: o, status: 200 }
275
+ { headers: n, status: 200 }
276
276
  ));
277
277
  }
278
- const le = 64, ue = 20 * 1024 * 1024;
279
- function Pe(e) {
280
- const t = v(e.root), n = e.policy ?? {}, o = n.optimizerPath ?? W, r = e.cacheSize ?? le, s = e.fetch ?? ((a, i) => fetch(a, i)), c = /* @__PURE__ */ new Map();
278
+ const ue = 64, de = 20 * 1024 * 1024;
279
+ function ke(e) {
280
+ const t = v(e.root), r = e.policy ?? {}, n = r.optimizerPath ?? W, o = e.cacheSize ?? ue, s = e.fetch ?? ((a, i) => fetch(a, i)), c = /* @__PURE__ */ new Map();
281
281
  return async function(i) {
282
- const f = new URL(i.url), u = f.pathname === o ? void 0 : e.resolveVariant?.(f.pathname);
283
- if (f.pathname !== o && !u)
282
+ const f = new URL(i.url), u = f.pathname === n ? void 0 : e.resolveVariant?.(f.pathname);
283
+ if (f.pathname !== n && !u)
284
284
  return null;
285
285
  if (i.method !== "GET" && i.method !== "HEAD")
286
286
  return g(405, "Method Not Allowed", {
287
287
  allow: "GET, HEAD"
288
288
  });
289
- if (u && !B(u.src, n))
289
+ if (u && !B(u.src, r))
290
290
  return g(403, "The image policy does not allow this image source.");
291
- const h = u ? { descriptor: u, ok: !0 } : V(f, n);
291
+ const h = u ? { descriptor: u, ok: !0 } : V(f, r);
292
292
  if (!h.ok)
293
293
  return g(h.rejection.status, h.rejection.reason);
294
294
  const m = F(
@@ -308,9 +308,9 @@ function Pe(e) {
308
308
  width: h.descriptor.width
309
309
  });
310
310
  }
311
- for (c.set(d, p); c.size > r; )
311
+ for (c.set(d, p); c.size > o; )
312
312
  c.delete(c.keys().next().value);
313
- return de(
313
+ return fe(
314
314
  i,
315
315
  p,
316
316
  !u && h.descriptor.format === "auto"
@@ -322,60 +322,60 @@ function Pe(e) {
322
322
  if (!f.ok)
323
323
  return;
324
324
  const u = new Uint8Array(await f.arrayBuffer());
325
- return u.byteLength > ue ? void 0 : u;
325
+ return u.byteLength > de ? void 0 : u;
326
326
  }
327
- const i = fe(t, a.src);
327
+ const i = he(t, a.src);
328
328
  if (i)
329
329
  try {
330
- return new Uint8Array(await j(i));
330
+ return new Uint8Array(await K(i));
331
331
  } catch {
332
332
  return;
333
333
  }
334
334
  }
335
335
  }
336
- function de(e, t, n) {
337
- const o = `"${he(t.body)}"`, r = new Headers({
336
+ function fe(e, t, r) {
337
+ const n = `"${pe(t.body)}"`, o = new Headers({
338
338
  "cache-control": R,
339
339
  "content-type": t.contentType,
340
- etag: o
340
+ etag: n
341
341
  });
342
- return n && r.set("vary", "accept"), e.headers.get("if-none-match") === o ? new Response(null, { headers: r, status: 304 }) : (r.set("content-length", String(t.body.byteLength)), new Response(
342
+ return r && o.set("vary", "accept"), e.headers.get("if-none-match") === n ? new Response(null, { headers: o, status: 304 }) : (o.set("content-length", String(t.body.byteLength)), new Response(
343
343
  e.method === "HEAD" ? null : t.body,
344
- { headers: r, status: 200 }
344
+ { headers: o, status: 200 }
345
345
  ));
346
346
  }
347
- function g(e, t, n = {}) {
347
+ function g(e, t, r = {}) {
348
348
  return new Response(t, {
349
- headers: { "content-type": "text/plain; charset=utf-8", ...n },
349
+ headers: { "content-type": "text/plain; charset=utf-8", ...r },
350
350
  status: e
351
351
  });
352
352
  }
353
- function fe(e, t) {
354
- let n;
353
+ function he(e, t) {
354
+ let r;
355
355
  try {
356
- n = decodeURIComponent(t.split("?")[0].split("#")[0]);
356
+ r = decodeURIComponent(j(t));
357
357
  } catch {
358
358
  return;
359
359
  }
360
- if (n.split(/[\\/]/).includes(".."))
360
+ if (r.split(/[\\/]/).includes(".."))
361
361
  return;
362
- const o = v(e, `.${n}`);
363
- return K(e, o).split(Y).includes("..") ? void 0 : o;
362
+ const n = v(e, `.${r}`);
363
+ return Y(e, n).split(J).includes("..") ? void 0 : n;
364
364
  }
365
- function he(e) {
366
- let t = 2166136261, n = 16777619;
367
- for (const o of e)
368
- t = Math.imul(t ^ o, 16777619) >>> 0, n = Math.imul(n ^ o, 2246822507) >>> 0;
369
- return `${t.toString(36)}${n.toString(36)}${e.byteLength.toString(36)}`;
365
+ function pe(e) {
366
+ let t = 2166136261, r = 16777619;
367
+ for (const n of e)
368
+ t = Math.imul(t ^ n, 16777619) >>> 0, r = Math.imul(r ^ n, 2246822507) >>> 0;
369
+ return `${t.toString(36)}${r.toString(36)}${e.byteLength.toString(36)}`;
370
370
  }
371
- function ke(e, t = {}) {
372
- return e.render.mode === "streaming" ? pe(e, t) : $(e, t);
371
+ function Me(e, t = {}) {
372
+ return e.render.mode === "streaming" ? me(e, t) : $(e, t);
373
373
  }
374
- async function pe(e, t = {}) {
374
+ async function me(e, t = {}) {
375
375
  if (t.signal?.aborted)
376
376
  throw t.signal.reason;
377
- const n = L(e, t), o = U(e, n);
378
- return await new Promise((r, s) => {
377
+ const r = L(e, t), n = U(e, r);
378
+ return await new Promise((o, s) => {
379
379
  let c = !1, l = !1, a = !1, i = "", f;
380
380
  const u = new N({
381
381
  destroy(d, p) {
@@ -394,7 +394,7 @@ async function pe(e, t = {}) {
394
394
  c = !0;
395
395
  }), u.once("close", () => {
396
396
  m(), c || (l = !0, f?.abort(new Error("Demiurge streaming response was cancelled.")));
397
- }), t.signal?.addEventListener("abort", h, { once: !0 }), f = J(o, {
397
+ }), t.signal?.addEventListener("abort", h, { once: !0 }), f = Q(n, {
398
398
  nonce: t.nonce,
399
399
  onError(d) {
400
400
  a && !l && t.onStreamError?.(d);
@@ -405,12 +405,12 @@ async function pe(e, t = {}) {
405
405
  onShellReady() {
406
406
  (async () => {
407
407
  try {
408
- const d = await Q(e, {
408
+ const d = await X(e, {
409
409
  ...t,
410
- scripts: n.scripts()
410
+ scripts: r.scripts()
411
411
  });
412
- i = d.suffix, n.flushHead(), u.push(d.prefix), a = !0, f?.pipe(u), r(
413
- new Response(me(u), {
412
+ i = d.suffix, r.flushHead(), u.push(d.prefix), a = !0, f?.pipe(u), o(
413
+ new Response(we(u), {
414
414
  headers: { "content-type": "text/html; charset=utf-8" }
415
415
  })
416
416
  );
@@ -422,48 +422,48 @@ async function pe(e, t = {}) {
422
422
  });
423
423
  });
424
424
  }
425
- function me(e) {
426
- let t = !1, n = () => {
425
+ function we(e) {
426
+ let t = !1, r = () => {
427
427
  };
428
428
  return new ReadableStream({
429
429
  cancel() {
430
- t = !0, n(), e.pause(), e.destroy();
430
+ t = !0, r(), e.pause(), e.destroy();
431
431
  },
432
432
  pull() {
433
433
  e.resume();
434
434
  },
435
- start(o) {
436
- e.on("data", r), e.once("end", s), e.once("error", c), e.once("close", l);
437
- function r(i) {
438
- t || (o.enqueue(Uint8Array.from(i)), (o.desiredSize ?? 1) <= 0 && e.pause());
435
+ start(n) {
436
+ e.on("data", o), e.once("end", s), e.once("error", c), e.once("close", l);
437
+ function o(i) {
438
+ t || (n.enqueue(Uint8Array.from(i)), (n.desiredSize ?? 1) <= 0 && e.pause());
439
439
  }
440
440
  function s() {
441
- t || (t = !0, a(), o.close());
441
+ t || (t = !0, a(), n.close());
442
442
  }
443
443
  function c(i) {
444
- t || (t = !0, a(), o.error(i));
444
+ t || (t = !0, a(), n.error(i));
445
445
  }
446
446
  function l() {
447
- t || (t = !0, a(), o.close());
447
+ t || (t = !0, a(), n.close());
448
448
  }
449
449
  function a() {
450
- e.off("data", r), e.off("end", s), e.off("error", c), e.off("close", l);
450
+ e.off("data", o), e.off("end", s), e.off("error", c), e.off("close", l);
451
451
  }
452
- n = a;
452
+ r = a;
453
453
  }
454
454
  });
455
455
  }
456
456
  export {
457
- Z as U,
457
+ q as U,
458
458
  E as a,
459
- Ie as b,
460
- Ne as c,
461
- Pe as d,
462
- pe as e,
463
- se as f,
464
- ke as r,
465
- Ce as t,
466
- q as v,
467
- De as w
459
+ Ne as b,
460
+ Pe as c,
461
+ ke as d,
462
+ me as e,
463
+ ae as f,
464
+ Me as r,
465
+ De as t,
466
+ ee as v,
467
+ Ie as w
468
468
  };
469
- //# sourceMappingURL=streaming-D0fGAuiO.js.map
469
+ //# sourceMappingURL=streaming-BEbPN7Uk.js.map