@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.
- package/README.md +13 -11
- package/bin/demiurge.mjs +30 -12
- package/dist/browser/file-router.d.ts +388 -5
- package/dist/browser/file-router.d.ts.map +1 -1
- package/dist/browser/focus.d.ts +20 -0
- package/dist/browser/focus.d.ts.map +1 -0
- package/dist/browser/index.d.ts +7 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/mutation-action.d.ts +81 -0
- package/dist/browser/mutation-action.d.ts.map +1 -0
- package/dist/chunks/document-shell-CpJnFtSC.js +36 -0
- package/dist/chunks/document-shell-CpJnFtSC.js.map +1 -0
- package/dist/chunks/env-startup-DOBYWlZD.js +257 -0
- package/dist/chunks/env-startup-DOBYWlZD.js.map +1 -0
- package/dist/chunks/{image-codec-Di53WpcH.js → image-codec-BmzWnH6W.js} +2 -2
- package/dist/chunks/{image-codec-Di53WpcH.js.map → image-codec-BmzWnH6W.js.map} +1 -1
- package/dist/chunks/{images-Edar3eU1.js → images-BQ80950B.js} +99 -91
- package/dist/chunks/images-BQ80950B.js.map +1 -0
- package/dist/chunks/index-BVk9zWbe.js +832 -0
- package/dist/chunks/index-BVk9zWbe.js.map +1 -0
- package/dist/chunks/manifest-vO6c0G0W.js +19 -0
- package/dist/chunks/manifest-vO6c0G0W.js.map +1 -0
- package/dist/chunks/plugin-BQgMiHxa.js +1827 -0
- package/dist/chunks/plugin-BQgMiHxa.js.map +1 -0
- package/dist/chunks/session-store-ChModVcq.js +92 -0
- package/dist/chunks/session-store-ChModVcq.js.map +1 -0
- package/dist/chunks/static-files-ehaD1kE7.js +51 -0
- package/dist/chunks/static-files-ehaD1kE7.js.map +1 -0
- package/dist/chunks/{streaming-D0fGAuiO.js → streaming-BEbPN7Uk.js} +163 -163
- package/dist/chunks/streaming-BEbPN7Uk.js.map +1 -0
- package/dist/chunks/testing-DueXbMo4.js +4167 -0
- package/dist/chunks/testing-DueXbMo4.js.map +1 -0
- package/dist/chunks/vite-DO70kZA6.js +259 -0
- package/dist/chunks/vite-DO70kZA6.js.map +1 -0
- package/dist/cli.d.ts +17 -25
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +159 -124
- package/dist/cli.js.map +1 -1
- package/dist/config/define.d.ts +3 -0
- package/dist/config/define.d.ts.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +78 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load.d.ts +12 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/types.d.ts +64 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/validate.d.ts +9 -0
- package/dist/config/validate.d.ts.map +1 -0
- package/dist/config/vite.d.ts +12 -0
- package/dist/config/vite.d.ts.map +1 -0
- package/dist/data/cache.d.ts +2 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/idempotency.d.ts.map +1 -1
- package/dist/deployment/testing.d.ts +25 -0
- package/dist/deployment/testing.d.ts.map +1 -0
- package/dist/deployment/testing.js +171 -0
- package/dist/deployment/testing.js.map +1 -0
- package/dist/document/hydration.d.ts +9 -0
- package/dist/document/hydration.d.ts.map +1 -1
- package/dist/document/index.d.ts +4 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/metadata.d.ts +8 -0
- package/dist/document/metadata.d.ts.map +1 -1
- package/dist/document/navigation.d.ts +28 -0
- package/dist/document/navigation.d.ts.map +1 -0
- package/dist/document/render.d.ts +3 -1
- package/dist/document/render.d.ts.map +1 -1
- package/dist/document/seo.d.ts.map +1 -1
- package/dist/edge/assets.d.ts.map +1 -1
- package/dist/edge/index.js +55 -73
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1860 -691
- package/dist/index.js.map +1 -1
- package/dist/internal/testing.js +12 -12
- package/dist/kv/index.d.ts +2 -0
- package/dist/kv/index.d.ts.map +1 -1
- package/dist/kv/index.js +170 -73
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/session-store.d.ts +20 -0
- package/dist/kv/session-store.d.ts.map +1 -0
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/node/image.d.ts.map +1 -1
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +251 -178
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +47 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/static.d.ts.map +1 -1
- package/dist/platform/fonts.d.ts.map +1 -1
- package/dist/platform/image-url.d.ts.map +1 -1
- package/dist/platform/url.d.ts +19 -0
- package/dist/platform/url.d.ts.map +1 -0
- package/dist/platform/web-vitals.d.ts.map +1 -1
- package/dist/redis/index.d.ts +2 -0
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +186 -69
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/session-store.d.ts +9 -0
- package/dist/redis/session-store.d.ts.map +1 -0
- package/dist/route/index.d.ts +2 -2
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/mutation.d.ts +97 -0
- package/dist/route/mutation.d.ts.map +1 -0
- package/dist/route/types.d.ts +6 -1
- package/dist/route/types.d.ts.map +1 -1
- package/dist/router/manifest.d.ts +8 -0
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/router/navigation-data.d.ts +9 -1
- package/dist/router/navigation-data.d.ts.map +1 -1
- package/dist/routing/generate.d.ts +3 -0
- package/dist/routing/generate.d.ts.map +1 -1
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/locale.d.ts +43 -0
- package/dist/routing/locale.d.ts.map +1 -0
- package/dist/routing/types.d.ts +12 -0
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/security/cookie-session.d.ts +43 -0
- package/dist/security/cookie-session.d.ts.map +1 -0
- package/dist/security/csrf.d.ts +1 -1
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +15 -0
- package/dist/security/env-startup.d.ts.map +1 -0
- package/dist/security/env.d.ts +25 -6
- package/dist/security/env.d.ts.map +1 -1
- package/dist/security/index.d.ts +9 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/report.d.ts.map +1 -1
- package/dist/security/session-manager.d.ts +32 -0
- package/dist/security/session-manager.d.ts.map +1 -0
- package/dist/security/session-store.d.ts +51 -0
- package/dist/security/session-store.d.ts.map +1 -0
- package/dist/security/testing.d.ts +10 -0
- package/dist/security/testing.d.ts.map +1 -0
- package/dist/security/testing.js +145 -0
- package/dist/security/testing.js.map +1 -0
- package/dist/security/types.d.ts +1 -0
- package/dist/security/types.d.ts.map +1 -1
- package/dist/server/document-shell.d.ts.map +1 -1
- package/dist/server/errors.d.ts +1 -0
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/not-found.d.ts +1 -0
- package/dist/server/not-found.d.ts.map +1 -1
- package/dist/server/render-tree.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +4 -0
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server/request-metadata.d.ts +1 -0
- package/dist/server/request-metadata.d.ts.map +1 -1
- package/dist/server/ssr.d.ts +2 -0
- package/dist/server/ssr.d.ts.map +1 -1
- package/dist/static/index.d.ts +2 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +380 -363
- package/dist/static/index.js.map +1 -1
- package/dist/static/preview.d.ts.map +1 -1
- package/dist/static/vercel.d.ts +11 -2
- package/dist/static/vercel.d.ts.map +1 -1
- package/dist/static-files.d.ts +12 -0
- package/dist/static-files.d.ts.map +1 -1
- package/dist/type-guards.d.ts +19 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/vite/env-boundary.d.ts +14 -0
- package/dist/vite/env-boundary.d.ts.map +1 -0
- package/dist/vite/index.d.ts +5 -3
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +22 -1560
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugin.d.ts +6 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/policy-verification.d.ts.map +1 -1
- package/package.json +19 -6
- package/dist/chunks/document-shell-WoM8yZlR.js +0 -35
- package/dist/chunks/document-shell-WoM8yZlR.js.map +0 -1
- package/dist/chunks/images-Edar3eU1.js.map +0 -1
- package/dist/chunks/request-metadata-DaIYq4Ea.js +0 -677
- package/dist/chunks/request-metadata-DaIYq4Ea.js.map +0 -1
- package/dist/chunks/static-files-DUjHw-4H.js +0 -11
- package/dist/chunks/static-files-DUjHw-4H.js.map +0 -1
- package/dist/chunks/streaming-D0fGAuiO.js.map +0 -1
- package/dist/chunks/testing-CRflAw4X.js +0 -3475
- package/dist/chunks/testing-CRflAw4X.js.map +0 -1
- package/dist/route/action.d.ts +0 -33
- 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 "./
|
|
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-
|
|
7
|
-
import { d as G, e as W, h as B, j as V } from "./images-
|
|
8
|
-
import { R } from "./static-files-
|
|
9
|
-
import { readFile as
|
|
10
|
-
import { resolve as v, relative as
|
|
11
|
-
import { renderToPipeableStream as
|
|
12
|
-
import { c as
|
|
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,
|
|
18
|
-
class
|
|
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
|
|
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
|
|
34
|
-
if (!b(
|
|
35
|
-
throw new Error(`Demiurge Node allowed host "${
|
|
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
|
|
46
|
-
const
|
|
47
|
-
I(
|
|
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
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
throw new
|
|
56
|
-
const
|
|
57
|
-
|
|
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
|
-
|
|
63
|
-
), c =
|
|
62
|
+
o.forwardedDepth
|
|
63
|
+
), c = te(e, s), l = A(
|
|
64
64
|
e.headers[y.host],
|
|
65
|
-
|
|
66
|
-
) ?? e.headers.host, a =
|
|
67
|
-
headers:
|
|
68
|
-
method:
|
|
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
|
-
|
|
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:
|
|
73
|
+
return M(h, { clientIp: o.clientIp }), h;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function te(e, t) {
|
|
76
76
|
if (t) {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
77
|
+
const r = t.toLowerCase();
|
|
78
|
+
if (r !== "http" && r !== "https")
|
|
79
79
|
throw new Error(`Unsupported forwarded protocol "${t}".`);
|
|
80
|
-
return
|
|
80
|
+
return r;
|
|
81
81
|
}
|
|
82
82
|
return e.socket?.encrypted ? "https" : "http";
|
|
83
83
|
}
|
|
84
|
-
function
|
|
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
|
|
90
|
-
if (!
|
|
89
|
+
const r = b(e);
|
|
90
|
+
if (!r)
|
|
91
91
|
throw new E(e);
|
|
92
|
-
if (!t.some((
|
|
93
|
-
const s = b(
|
|
92
|
+
if (!t.some((o) => {
|
|
93
|
+
const s = b(o);
|
|
94
94
|
if (!s)
|
|
95
|
-
throw new Error(`Demiurge Node allowed host "${
|
|
96
|
-
return s.port ? s.host ===
|
|
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
|
|
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,
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
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
|
|
116
|
-
if (!Number.isSafeInteger(
|
|
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(
|
|
120
|
+
const l = Math.min(r.hops, n.length);
|
|
121
121
|
return {
|
|
122
|
-
clientIp:
|
|
123
|
-
forwardedDepth:
|
|
122
|
+
clientIp: o[o.length - 1 - l],
|
|
123
|
+
forwardedDepth: r.hops
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
let s =
|
|
127
|
-
for (; s > 0 && x(
|
|
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:
|
|
131
|
-
forwardedDepth: c || (x(e,
|
|
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
|
|
138
|
-
if (
|
|
139
|
-
return
|
|
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((
|
|
145
|
+
return t.some((r) => I(e, r));
|
|
146
146
|
}
|
|
147
147
|
function I(e, t) {
|
|
148
|
-
const [
|
|
149
|
-
if (!
|
|
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 =
|
|
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 ((
|
|
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 [
|
|
173
|
+
const [r = "", n = ""] = e.split("::"), o = r ? r.split(":") : [], s = n ? n.split(":") : [], c = 8 - o.length - s.length;
|
|
174
174
|
return [
|
|
175
|
-
...
|
|
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
|
|
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
|
|
187
|
-
const
|
|
188
|
-
if (t.headers.forEach((
|
|
189
|
-
|
|
190
|
-
}),
|
|
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 (
|
|
202
|
-
if (!
|
|
203
|
-
throw
|
|
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
|
|
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
|
|
215
|
+
function ae(e) {
|
|
216
216
|
const t = new Headers();
|
|
217
|
-
for (const [
|
|
218
|
-
if (Array.isArray(
|
|
219
|
-
for (const
|
|
220
|
-
t.append(
|
|
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
|
-
|
|
223
|
+
n && t.set(r, n);
|
|
224
224
|
}
|
|
225
225
|
return t;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function ie(e) {
|
|
228
228
|
const t = e.getSetCookie;
|
|
229
229
|
if (t)
|
|
230
230
|
return t.call(e);
|
|
231
|
-
const
|
|
232
|
-
return
|
|
231
|
+
const r = e.get("set-cookie");
|
|
232
|
+
return r ? ce(r) : [];
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function ce(e) {
|
|
235
235
|
return e.split(/,\s*(?=[^;,=\s]+\s*=)/);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function Pe(e) {
|
|
238
238
|
const t = e.basePath ?? G;
|
|
239
|
-
let
|
|
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
|
-
|
|
252
|
+
r ??= n();
|
|
253
253
|
let l;
|
|
254
254
|
try {
|
|
255
|
-
l = await
|
|
255
|
+
l = await r;
|
|
256
256
|
} catch (i) {
|
|
257
|
-
throw
|
|
257
|
+
throw r = void 0, i;
|
|
258
258
|
}
|
|
259
259
|
const a = l.get(c.pathname);
|
|
260
|
-
return a ?
|
|
260
|
+
return a ? le(s, a) : null;
|
|
261
261
|
};
|
|
262
|
-
async function
|
|
263
|
-
const
|
|
264
|
-
return new Map(
|
|
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
|
|
268
|
-
const
|
|
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:
|
|
271
|
+
etag: r
|
|
272
272
|
});
|
|
273
|
-
return e.headers.get("if-none-match") ===
|
|
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:
|
|
275
|
+
{ headers: n, status: 200 }
|
|
276
276
|
));
|
|
277
277
|
}
|
|
278
|
-
const
|
|
279
|
-
function
|
|
280
|
-
const t = v(e.root),
|
|
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 ===
|
|
283
|
-
if (f.pathname !==
|
|
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,
|
|
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,
|
|
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 >
|
|
311
|
+
for (c.set(d, p); c.size > o; )
|
|
312
312
|
c.delete(c.keys().next().value);
|
|
313
|
-
return
|
|
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 >
|
|
325
|
+
return u.byteLength > de ? void 0 : u;
|
|
326
326
|
}
|
|
327
|
-
const i =
|
|
327
|
+
const i = he(t, a.src);
|
|
328
328
|
if (i)
|
|
329
329
|
try {
|
|
330
|
-
return new Uint8Array(await
|
|
330
|
+
return new Uint8Array(await K(i));
|
|
331
331
|
} catch {
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
function
|
|
337
|
-
const
|
|
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:
|
|
340
|
+
etag: n
|
|
341
341
|
});
|
|
342
|
-
return
|
|
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:
|
|
344
|
+
{ headers: o, status: 200 }
|
|
345
345
|
));
|
|
346
346
|
}
|
|
347
|
-
function g(e, t,
|
|
347
|
+
function g(e, t, r = {}) {
|
|
348
348
|
return new Response(t, {
|
|
349
|
-
headers: { "content-type": "text/plain; charset=utf-8", ...
|
|
349
|
+
headers: { "content-type": "text/plain; charset=utf-8", ...r },
|
|
350
350
|
status: e
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
let
|
|
353
|
+
function he(e, t) {
|
|
354
|
+
let r;
|
|
355
355
|
try {
|
|
356
|
-
|
|
356
|
+
r = decodeURIComponent(j(t));
|
|
357
357
|
} catch {
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
|
-
if (
|
|
360
|
+
if (r.split(/[\\/]/).includes(".."))
|
|
361
361
|
return;
|
|
362
|
-
const
|
|
363
|
-
return
|
|
362
|
+
const n = v(e, `.${r}`);
|
|
363
|
+
return Y(e, n).split(J).includes("..") ? void 0 : n;
|
|
364
364
|
}
|
|
365
|
-
function
|
|
366
|
-
let t = 2166136261,
|
|
367
|
-
for (const
|
|
368
|
-
t = Math.imul(t ^
|
|
369
|
-
return `${t.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
|
|
372
|
-
return e.render.mode === "streaming" ?
|
|
371
|
+
function Me(e, t = {}) {
|
|
372
|
+
return e.render.mode === "streaming" ? me(e, t) : $(e, t);
|
|
373
373
|
}
|
|
374
|
-
async function
|
|
374
|
+
async function me(e, t = {}) {
|
|
375
375
|
if (t.signal?.aborted)
|
|
376
376
|
throw t.signal.reason;
|
|
377
|
-
const
|
|
378
|
-
return await new Promise((
|
|
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 =
|
|
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
|
|
408
|
+
const d = await X(e, {
|
|
409
409
|
...t,
|
|
410
|
-
scripts:
|
|
410
|
+
scripts: r.scripts()
|
|
411
411
|
});
|
|
412
|
-
i = d.suffix,
|
|
413
|
-
new Response(
|
|
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
|
|
426
|
-
let t = !1,
|
|
425
|
+
function we(e) {
|
|
426
|
+
let t = !1, r = () => {
|
|
427
427
|
};
|
|
428
428
|
return new ReadableStream({
|
|
429
429
|
cancel() {
|
|
430
|
-
t = !0,
|
|
430
|
+
t = !0, r(), e.pause(), e.destroy();
|
|
431
431
|
},
|
|
432
432
|
pull() {
|
|
433
433
|
e.resume();
|
|
434
434
|
},
|
|
435
|
-
start(
|
|
436
|
-
e.on("data",
|
|
437
|
-
function
|
|
438
|
-
t || (
|
|
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(),
|
|
441
|
+
t || (t = !0, a(), n.close());
|
|
442
442
|
}
|
|
443
443
|
function c(i) {
|
|
444
|
-
t || (t = !0, a(),
|
|
444
|
+
t || (t = !0, a(), n.error(i));
|
|
445
445
|
}
|
|
446
446
|
function l() {
|
|
447
|
-
t || (t = !0, a(),
|
|
447
|
+
t || (t = !0, a(), n.close());
|
|
448
448
|
}
|
|
449
449
|
function a() {
|
|
450
|
-
e.off("data",
|
|
450
|
+
e.off("data", o), e.off("end", s), e.off("error", c), e.off("close", l);
|
|
451
451
|
}
|
|
452
|
-
|
|
452
|
+
r = a;
|
|
453
453
|
}
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
456
|
export {
|
|
457
|
-
|
|
457
|
+
q as U,
|
|
458
458
|
E as a,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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-
|
|
469
|
+
//# sourceMappingURL=streaming-BEbPN7Uk.js.map
|