@demiurgejs/core 0.2.0-beta.4 → 0.2.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/bin/demiurge.mjs +23 -1
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/browser/file-router.d.ts +1 -1
- package/dist/chunks/{document-shell-CpJnFtSC.js → document-shell-C0aPrkhd.js} +2 -2
- package/dist/chunks/{document-shell-CpJnFtSC.js.map → document-shell-C0aPrkhd.js.map} +1 -1
- package/dist/chunks/image-CRerJ5BY.js +145 -0
- package/dist/chunks/image-CRerJ5BY.js.map +1 -0
- package/dist/chunks/{image-codec-BmzWnH6W.js → image-codec-CQ8Cwxwb.js} +2 -2
- package/dist/chunks/{image-codec-BmzWnH6W.js.map → image-codec-CQ8Cwxwb.js.map} +1 -1
- package/dist/chunks/{images-BQ80950B.js → images-QgdmLyQ3.js} +11 -11
- package/dist/chunks/{images-BQ80950B.js.map → images-QgdmLyQ3.js.map} +1 -1
- package/dist/chunks/{index-BVk9zWbe.js → index-LYve1rQp.js} +287 -351
- package/dist/chunks/index-LYve1rQp.js.map +1 -0
- package/dist/chunks/links-iU22QkCE.js +68 -0
- package/dist/chunks/links-iU22QkCE.js.map +1 -0
- package/dist/chunks/plugin-bkP6WwrS.js +2311 -0
- package/dist/chunks/plugin-bkP6WwrS.js.map +1 -0
- package/dist/chunks/runtime-BH519j2t.js +294 -0
- package/dist/chunks/runtime-BH519j2t.js.map +1 -0
- package/dist/chunks/streaming-BlKlC3nw.js +427 -0
- package/dist/chunks/streaming-BlKlC3nw.js.map +1 -0
- package/dist/chunks/{testing-DueXbMo4.js → testing-BEW1nchS.js} +2161 -1562
- package/dist/chunks/testing-BEW1nchS.js.map +1 -0
- package/dist/chunks/{vite-DO70kZA6.js → vite-BADZA8Fl.js} +90 -87
- package/dist/chunks/vite-BADZA8Fl.js.map +1 -0
- package/dist/cli.d.ts +10 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +277 -87
- package/dist/cli.js.map +1 -1
- package/dist/config/index.js +2 -2
- package/dist/config/types.d.ts +14 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/validate.d.ts.map +1 -1
- package/dist/data/cache.d.ts +5 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/testing.d.ts.map +1 -1
- package/dist/data/testing.js +101 -67
- package/dist/data/testing.js.map +1 -1
- package/dist/data/tiered.d.ts.map +1 -1
- package/dist/edge/index.js +27 -26
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/stores.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +158 -135
- package/dist/index.js.map +1 -1
- package/dist/inspect/command.d.ts +28 -0
- package/dist/inspect/command.d.ts.map +1 -0
- package/dist/inspect/index.d.ts +9 -0
- package/dist/inspect/index.d.ts.map +1 -0
- package/dist/inspect/redact.d.ts +35 -0
- package/dist/inspect/redact.d.ts.map +1 -0
- package/dist/inspect/report.d.ts +24 -0
- package/dist/inspect/report.d.ts.map +1 -0
- package/dist/inspect/types.d.ts +102 -0
- package/dist/inspect/types.d.ts.map +1 -0
- package/dist/internal/testing.js +12 -12
- package/dist/kv/index.js +7 -6
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/store.d.ts.map +1 -1
- package/dist/node/http.d.ts +7 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +31 -28
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +4 -0
- package/dist/node/serve.d.ts.map +1 -1
- package/dist/redis/index.js +29 -28
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/store.d.ts.map +1 -1
- package/dist/route/index.d.ts +1 -0
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/mutation.d.ts.map +1 -1
- package/dist/route/serialization.d.ts +24 -0
- package/dist/route/serialization.d.ts.map +1 -0
- package/dist/route/webhook.d.ts +6 -1
- package/dist/route/webhook.d.ts.map +1 -1
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/security/audit.d.ts +2 -1
- package/dist/security/audit.d.ts.map +1 -1
- package/dist/security/authorization.d.ts +36 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +0 -2
- package/dist/security/env-startup.d.ts.map +1 -1
- package/dist/security/env.d.ts +27 -8
- package/dist/security/env.d.ts.map +1 -1
- package/dist/security/exceptions.d.ts +29 -0
- package/dist/security/exceptions.d.ts.map +1 -0
- package/dist/security/finding-codes.d.ts +56 -0
- package/dist/security/finding-codes.d.ts.map +1 -0
- package/dist/security/index.d.ts +5 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/policy.d.ts +2 -5
- package/dist/security/policy.d.ts.map +1 -1
- package/dist/security/report.d.ts +2 -1
- package/dist/security/report.d.ts.map +1 -1
- package/dist/security/request.d.ts +1 -0
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/types.d.ts +138 -5
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/upload.d.ts +3 -3
- package/dist/security/upload.d.ts.map +1 -1
- package/dist/security/verification.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +3 -2
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server-only/browser.d.ts +2 -0
- package/dist/server-only/browser.d.ts.map +1 -0
- package/dist/server-only/browser.js +4 -0
- package/dist/server-only/browser.js.map +1 -0
- package/dist/server-only/index.d.ts +2 -0
- package/dist/server-only/index.d.ts.map +1 -0
- package/dist/server-only/index.js +2 -0
- package/dist/server-only/index.js.map +1 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +255 -255
- package/dist/static/index.js.map +1 -1
- package/dist/static/testing.d.ts +26 -0
- package/dist/static/testing.d.ts.map +1 -0
- package/dist/static/testing.js +76 -0
- package/dist/static/testing.js.map +1 -0
- package/dist/testing/index.d.ts +47 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +99 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/vercel/build.d.ts +31 -0
- package/dist/vercel/build.d.ts.map +1 -0
- package/dist/vercel/config.d.ts +15 -0
- package/dist/vercel/config.d.ts.map +1 -0
- package/dist/vercel/index.d.ts +7 -0
- package/dist/vercel/index.d.ts.map +1 -0
- package/dist/vercel/index.js +11 -0
- package/dist/vercel/index.js.map +1 -0
- package/dist/vercel/runtime.d.ts +29 -0
- package/dist/vercel/runtime.d.ts.map +1 -0
- package/dist/vite/index.d.ts +9 -4
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +28 -21
- package/dist/vite/plugin.d.ts +18 -2
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/policy-verification.d.ts +33 -2
- package/dist/vite/policy-verification.d.ts.map +1 -1
- package/dist/vite/route-audit.d.ts +14 -2
- package/dist/vite/route-audit.d.ts.map +1 -1
- package/dist/vite/server-only-boundary.d.ts +8 -0
- package/dist/vite/server-only-boundary.d.ts.map +1 -0
- package/package.json +18 -1
- package/dist/chunks/env-startup-DOBYWlZD.js +0 -257
- package/dist/chunks/env-startup-DOBYWlZD.js.map +0 -1
- package/dist/chunks/index-BVk9zWbe.js.map +0 -1
- package/dist/chunks/plugin-BQgMiHxa.js +0 -1827
- package/dist/chunks/plugin-BQgMiHxa.js.map +0 -1
- package/dist/chunks/streaming-BEbPN7Uk.js +0 -469
- package/dist/chunks/streaming-BEbPN7Uk.js.map +0 -1
- package/dist/chunks/testing-DueXbMo4.js.map +0 -1
- package/dist/chunks/vite-DO70kZA6.js.map +0 -1
package/dist/static/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { readFile as
|
|
2
|
-
import { resolve as
|
|
3
|
-
import { d as
|
|
4
|
-
import { i as
|
|
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
|
|
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
|
|
10
|
-
import {
|
|
11
|
-
import { createServer as
|
|
12
|
-
import { pathToRegexp as
|
|
13
|
-
async function
|
|
14
|
-
const e =
|
|
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) =>
|
|
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 =
|
|
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 (!
|
|
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 =
|
|
29
|
+
const u = Dt(e, a.src);
|
|
30
30
|
let d = c.get(u);
|
|
31
|
-
d || (d = await
|
|
32
|
-
const
|
|
33
|
-
format:
|
|
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:
|
|
37
|
+
i.push({ body: m.body, file: s.slice(1) });
|
|
38
38
|
}
|
|
39
39
|
return i;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const r = e.optimizerPath ??
|
|
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
|
|
49
|
+
async function jt(t, e) {
|
|
50
50
|
try {
|
|
51
|
-
return new Uint8Array(await
|
|
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
|
|
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 =
|
|
67
|
-
if (E(t, n).split(
|
|
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
|
|
74
|
-
async function
|
|
75
|
-
const e =
|
|
76
|
-
await
|
|
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 =
|
|
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
|
|
94
|
+
let m;
|
|
95
95
|
try {
|
|
96
|
-
|
|
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
|
|
104
|
-
if (
|
|
105
|
-
await
|
|
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
|
|
109
|
-
if (
|
|
108
|
+
const h = Ut(e, m);
|
|
109
|
+
if (h)
|
|
110
110
|
try {
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
await
|
|
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
|
|
117
|
-
|
|
118
|
-
const T =
|
|
119
|
-
|
|
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 (
|
|
122
|
-
if (!
|
|
121
|
+
} catch (y) {
|
|
122
|
+
if (!qt(y)) throw y;
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
124
|
+
const O = n.get("*");
|
|
125
|
+
if (!O) {
|
|
126
126
|
u.writeHead(404), u.end();
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
await
|
|
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 = (
|
|
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
|
|
148
|
-
const o =
|
|
149
|
-
|
|
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
|
|
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
|
|
155
|
+
function Ut(t, e) {
|
|
156
156
|
if (!e.endsWith("/"))
|
|
157
|
-
return
|
|
157
|
+
return nt(t, `.${e}`);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
const r =
|
|
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
|
|
165
|
+
function nt(t, e) {
|
|
166
166
|
if (!e || e.startsWith("/") || e.startsWith("\\") || e.split(/[\\/]/).includes(".."))
|
|
167
167
|
return;
|
|
168
|
-
const r =
|
|
169
|
-
return n !== ".." && !n.startsWith(`..${
|
|
168
|
+
const r = p(t, e), n = E(t, r);
|
|
169
|
+
return n !== ".." && !n.startsWith(`..${$}`) ? r : void 0;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
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 (!
|
|
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(
|
|
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
|
|
191
|
-
if (!
|
|
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
|
|
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
|
|
201
|
-
if (!
|
|
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
|
|
211
|
-
return
|
|
210
|
+
function ot(t) {
|
|
211
|
+
return C(t) && Object.values(t).every(
|
|
212
212
|
(e) => typeof e == "string"
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function qt(t) {
|
|
216
216
|
return t instanceof Error && "code" in t && (t.code === "EISDIR" || t.code === "ENOENT");
|
|
217
217
|
}
|
|
218
|
-
const
|
|
219
|
-
function
|
|
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
|
|
230
|
-
|
|
231
|
-
const e =
|
|
232
|
-
if (
|
|
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 =
|
|
237
|
-
await
|
|
238
|
-
const i = await
|
|
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 =
|
|
241
|
-
await
|
|
240
|
+
const c = v(i, "static");
|
|
241
|
+
await Z(r, c, {
|
|
242
242
|
filter: (s) => {
|
|
243
|
-
const a = E(r, s).split(
|
|
244
|
-
return a !==
|
|
243
|
+
const a = E(r, s).split($).join("/");
|
|
244
|
+
return a !== zt && a !== Bt;
|
|
245
245
|
},
|
|
246
246
|
recursive: !0
|
|
247
|
-
}), await
|
|
248
|
-
|
|
249
|
-
`${JSON.stringify(
|
|
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
|
|
254
|
+
), await x(n, { force: !0, recursive: !0 }), await lt(i, n);
|
|
255
255
|
} catch (c) {
|
|
256
|
-
throw await
|
|
256
|
+
throw await x(i, { force: !0, recursive: !0 }), c;
|
|
257
257
|
}
|
|
258
258
|
return n;
|
|
259
259
|
}
|
|
260
|
-
function
|
|
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 =
|
|
264
|
+
const n = Qt(e.cache), i = [
|
|
265
265
|
{
|
|
266
266
|
continue: !0,
|
|
267
|
-
headers: { "access-control-allow-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:
|
|
277
|
+
src: P(a)
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
280
|
for (const s of t.entries) {
|
|
281
|
-
const a =
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
310
|
+
src: Zt(s.pattern)
|
|
311
311
|
});
|
|
312
312
|
i.push(...n.map((s) => ({ ...s }))), i.push({ handle: "error" });
|
|
313
|
-
const c =
|
|
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
|
-
}),
|
|
319
|
+
}), Xt(i), {
|
|
320
320
|
overrides: Object.fromEntries(
|
|
321
|
-
t.entries.map((s) => [s.file,
|
|
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
|
|
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
|
|
335
|
+
function P(t) {
|
|
336
336
|
const e = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
337
337
|
return t === "/" ? "^/$" : `^${e}/?$`;
|
|
338
338
|
}
|
|
339
|
-
function
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
379
|
+
function te(t, e) {
|
|
380
380
|
if (t) {
|
|
381
|
-
if (
|
|
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
|
|
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
|
|
402
|
+
function re(t, e) {
|
|
403
403
|
const r = E(t, e), n = E(e, t);
|
|
404
|
-
return
|
|
404
|
+
return k(r) || k(n);
|
|
405
405
|
}
|
|
406
|
-
function
|
|
407
|
-
return !t || t !== ".." && !t.startsWith(`..${
|
|
406
|
+
function k(t) {
|
|
407
|
+
return !t || t !== ".." && !t.startsWith(`..${$}`) && !t.startsWith("/");
|
|
408
408
|
}
|
|
409
|
-
const
|
|
409
|
+
const it = "demiurge-static-manifest.json", _ = dt({
|
|
410
410
|
name: "static",
|
|
411
411
|
capabilities: {
|
|
412
412
|
staticOutput: !0
|
|
413
413
|
}
|
|
414
|
-
}),
|
|
415
|
-
async function
|
|
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(
|
|
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
|
|
437
|
-
const e = await
|
|
438
|
-
adapter:
|
|
439
|
-
}), n =
|
|
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
|
-
}),
|
|
443
|
-
|
|
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:
|
|
447
|
-
}))),
|
|
448
|
-
|
|
446
|
+
locale: a[f]
|
|
447
|
+
}))), d = [...s, ...u];
|
|
448
|
+
le(
|
|
449
449
|
r,
|
|
450
|
-
|
|
450
|
+
u.length
|
|
451
451
|
);
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
const f =
|
|
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
|
-
|
|
459
|
-
|
|
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
|
-
),
|
|
464
|
-
adapter:
|
|
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:
|
|
469
|
+
ssr: h
|
|
470
470
|
}) : void 0;
|
|
471
|
-
for (const l of
|
|
472
|
-
const 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:
|
|
475
|
-
ssr:
|
|
474
|
+
rateLimitStore: H,
|
|
475
|
+
ssr: h
|
|
476
476
|
});
|
|
477
|
-
|
|
478
|
-
l.kind === "document" ? await
|
|
477
|
+
w.push(
|
|
478
|
+
l.kind === "document" ? await z(l, S, 200) : await ye(l, S)
|
|
479
479
|
);
|
|
480
480
|
}
|
|
481
|
-
const
|
|
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
|
-
|
|
483
|
+
y,
|
|
484
484
|
{
|
|
485
|
-
...
|
|
486
|
-
dir:
|
|
487
|
-
lang:
|
|
488
|
-
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
|
-
|
|
493
|
-
await
|
|
492
|
+
w.push(
|
|
493
|
+
await z(
|
|
494
494
|
{
|
|
495
495
|
file: "404.html",
|
|
496
496
|
pathname: "*"
|
|
497
497
|
},
|
|
498
|
-
|
|
498
|
+
I,
|
|
499
499
|
404
|
|
500
500
|
)
|
|
501
501
|
);
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
documents:
|
|
506
|
-
outDir:
|
|
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
|
-
}),
|
|
508
|
+
}), A = await bt({
|
|
509
509
|
fonts: t.fonts,
|
|
510
510
|
root: t.root ?? process.cwd()
|
|
511
511
|
});
|
|
512
|
-
|
|
513
|
-
const
|
|
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:
|
|
516
|
-
fileHeaderRules: await
|
|
515
|
+
entries: w.map(({ body: l, ...f }) => f),
|
|
516
|
+
fileHeaderRules: await ae(
|
|
517
517
|
r,
|
|
518
518
|
t.staticFileHeaders ?? []
|
|
519
519
|
),
|
|
520
|
-
fontFiles:
|
|
521
|
-
imageFiles:
|
|
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
|
|
525
|
+
return await Re(i, w, [...T, ...A], N), N;
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function ie(t, e) {
|
|
528
528
|
const r = new URL(t);
|
|
529
|
-
return e.supportedLocales.flatMap((n) => new URL(
|
|
529
|
+
return e.supportedLocales.flatMap((n) => new URL(Y("/", n, e, t), t).origin === r.origin ? [n] : []);
|
|
530
530
|
}
|
|
531
|
-
async function
|
|
532
|
-
const r = await
|
|
531
|
+
async function ae(t, e) {
|
|
532
|
+
const r = await se(t), n = V(r);
|
|
533
533
|
return [
|
|
534
|
-
...e.map((o) => (
|
|
535
|
-
headers:
|
|
536
|
-
|
|
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":
|
|
543
|
+
"cache-control": At
|
|
544
544
|
},
|
|
545
|
-
pattern:
|
|
545
|
+
pattern: X.source
|
|
546
546
|
},
|
|
547
547
|
{
|
|
548
548
|
headers: {
|
|
549
549
|
...n,
|
|
550
|
-
"cache-control":
|
|
550
|
+
"cache-control": Ft
|
|
551
551
|
},
|
|
552
552
|
pattern: ".*"
|
|
553
553
|
}
|
|
554
554
|
];
|
|
555
555
|
}
|
|
556
|
-
async function
|
|
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
|
|
562
|
-
return Object.fromEntries(
|
|
561
|
+
function V(t) {
|
|
562
|
+
return Object.fromEntries(Ot(t, {}).entries());
|
|
563
563
|
}
|
|
564
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
614
|
+
he(r.file, n.GET), e.set(r.file, "resource");
|
|
615
615
|
}
|
|
616
616
|
return e;
|
|
617
617
|
}
|
|
618
|
-
function
|
|
618
|
+
function de(t) {
|
|
619
619
|
return ["POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"].filter((e) => t[e] !== void 0);
|
|
620
620
|
}
|
|
621
|
-
function
|
|
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
|
|
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" ?
|
|
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
|
|
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
|
|
655
|
+
return we(n, t), n;
|
|
656
656
|
}), "index.html"].join("/");
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function me(t) {
|
|
659
659
|
if (t === "/")
|
|
660
660
|
throw new Error("A static resource route cannot own the root pathname.");
|
|
661
|
-
return
|
|
661
|
+
return at(t).slice(0, -11);
|
|
662
662
|
}
|
|
663
|
-
function
|
|
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
|
|
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
|
|
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
|
|
689
|
+
const o = await ge(
|
|
690
690
|
await e.text(),
|
|
691
691
|
e.headers
|
|
692
692
|
);
|
|
693
|
-
return await
|
|
693
|
+
return await Ee(t.pathname, o, e.headers), {
|
|
694
694
|
file: t.file,
|
|
695
|
-
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
|
|
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:
|
|
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
|
|
718
|
+
async function ge(t, e) {
|
|
719
719
|
const r = new RegExp(
|
|
720
|
-
`(?:^|\\s)${
|
|
721
|
-
), n =
|
|
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) =>
|
|
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,
|
|
732
|
+
c && e.set(i, Se(c, o));
|
|
733
733
|
}
|
|
734
734
|
return t.replace(
|
|
735
|
-
new RegExp(`\\s${
|
|
735
|
+
new RegExp(`\\s${D}(?=\\s|>)`, "g"),
|
|
736
736
|
""
|
|
737
737
|
);
|
|
738
738
|
}
|
|
739
|
-
function
|
|
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
|
|
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 =
|
|
762
|
-
await
|
|
761
|
+
const o = ve(n);
|
|
762
|
+
await B(
|
|
763
763
|
t,
|
|
764
764
|
e,
|
|
765
765
|
"script",
|
|
766
|
-
|
|
767
|
-
), await
|
|
766
|
+
L(o, "script-src", "default-src")
|
|
767
|
+
), await B(
|
|
768
768
|
t,
|
|
769
769
|
e,
|
|
770
770
|
"style",
|
|
771
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
804
|
+
async function B(t, e, r, n) {
|
|
805
805
|
if (!(!n || n.includes("'unsafe-inline'")))
|
|
806
|
-
for (const o of
|
|
806
|
+
for (const o of st(e, r)) {
|
|
807
807
|
if (r === "script") {
|
|
808
|
-
const c =
|
|
808
|
+
const c = $e(o.attributes, "src");
|
|
809
809
|
if (c) {
|
|
810
|
-
if (
|
|
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
|
|
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
|
|
826
|
+
function $e(t, e) {
|
|
827
827
|
return t.match(
|
|
828
828
|
new RegExp(`(?:^|\\s)${e}\\s*=\\s*["']([^"']+)["']`, "i")
|
|
829
829
|
)?.[1]?.replaceAll("&", "&");
|
|
830
830
|
}
|
|
831
|
-
function
|
|
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
|
|
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
|
|
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
|
|
882
|
-
const o =
|
|
883
|
-
await
|
|
884
|
-
const i = await
|
|
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 =
|
|
888
|
-
await
|
|
887
|
+
const u = G(i, a.file);
|
|
888
|
+
await b(j(u), { recursive: !0 }), await M(u, a.body);
|
|
889
889
|
}
|
|
890
|
-
await
|
|
891
|
-
|
|
890
|
+
await M(
|
|
891
|
+
v(i, it),
|
|
892
892
|
`${JSON.stringify(n, null, 2)}
|
|
893
893
|
`
|
|
894
894
|
);
|
|
895
|
-
const c = await
|
|
896
|
-
await
|
|
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
|
|
901
|
+
s.has(a) || await x(G(t, a), { force: !0 });
|
|
902
902
|
} finally {
|
|
903
|
-
await
|
|
903
|
+
await x(i, { force: !0, recursive: !0 });
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
|
-
async function
|
|
906
|
+
async function Te(t) {
|
|
907
907
|
try {
|
|
908
|
-
const e = await
|
|
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" &&
|
|
917
|
+
(i) => typeof i == "string" && ut(i) ? [i] : []
|
|
918
918
|
);
|
|
919
919
|
} catch {
|
|
920
920
|
return [];
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
function
|
|
924
|
-
if (!
|
|
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 =
|
|
927
|
-
if (E(r, n).split(
|
|
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
|
|
931
|
+
function ut(t) {
|
|
932
932
|
return !!t && !t.startsWith("/") && !t.startsWith("\\") && !t.split(/[\\/]/).includes("..");
|
|
933
933
|
}
|
|
934
934
|
export {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
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
|