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