@demiurgejs/core 0.2.0-beta.3 → 0.2.0-beta.5
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 +36 -11
- package/bin/demiurge.mjs +47 -13
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.d.ts.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-9GPwtcTt.js +36 -0
- package/dist/chunks/document-shell-9GPwtcTt.js.map +1 -0
- package/dist/chunks/{image-codec-Di53WpcH.js → image-codec-Dh1POFhE.js} +2 -2
- package/dist/chunks/{image-codec-Di53WpcH.js.map → image-codec-Dh1POFhE.js.map} +1 -1
- package/dist/chunks/{images-Edar3eU1.js → images-CG7ZzayG.js} +99 -91
- package/dist/chunks/images-CG7ZzayG.js.map +1 -0
- package/dist/chunks/index-0MNiR_wo.js +833 -0
- package/dist/chunks/index-0MNiR_wo.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-BZauDxRY.js +2310 -0
- package/dist/chunks/plugin-BZauDxRY.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-GYIsVTQH.js +560 -0
- package/dist/chunks/streaming-GYIsVTQH.js.map +1 -0
- package/dist/chunks/testing-CUwGj2ie.js +4751 -0
- package/dist/chunks/testing-CUwGj2ie.js.map +1 -0
- package/dist/chunks/vite-QoqrGl6f.js +259 -0
- package/dist/chunks/vite-QoqrGl6f.js.map +1 -0
- package/dist/cli.d.ts +19 -25
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +289 -128
- 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 +74 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/validate.d.ts +9 -0
- package/dist/config/validate.d.ts.map +1 -0
- package/dist/config/vite.d.ts +12 -0
- package/dist/config/vite.d.ts.map +1 -0
- package/dist/data/cache.d.ts +2 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/idempotency.d.ts.map +1 -1
- package/dist/deployment/testing.d.ts +25 -0
- package/dist/deployment/testing.d.ts.map +1 -0
- package/dist/deployment/testing.js +171 -0
- package/dist/deployment/testing.js.map +1 -0
- package/dist/document/hydration.d.ts +9 -0
- package/dist/document/hydration.d.ts.map +1 -1
- package/dist/document/index.d.ts +4 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/metadata.d.ts +8 -0
- package/dist/document/metadata.d.ts.map +1 -1
- package/dist/document/navigation.d.ts +28 -0
- package/dist/document/navigation.d.ts.map +1 -0
- package/dist/document/render.d.ts +3 -1
- package/dist/document/render.d.ts.map +1 -1
- package/dist/document/seo.d.ts.map +1 -1
- package/dist/edge/assets.d.ts.map +1 -1
- package/dist/edge/index.js +55 -73
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1883 -692
- 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 +5 -5
- package/dist/kv/index.d.ts +2 -0
- package/dist/kv/index.d.ts.map +1 -1
- package/dist/kv/index.js +170 -73
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/session-store.d.ts +20 -0
- package/dist/kv/session-store.d.ts.map +1 -0
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/node/http.d.ts +5 -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 +4 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +257 -182
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +47 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/static.d.ts.map +1 -1
- package/dist/platform/fonts.d.ts.map +1 -1
- package/dist/platform/image-url.d.ts.map +1 -1
- package/dist/platform/url.d.ts +19 -0
- package/dist/platform/url.d.ts.map +1 -0
- package/dist/platform/web-vitals.d.ts.map +1 -1
- package/dist/redis/index.d.ts +2 -0
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +186 -69
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/session-store.d.ts +9 -0
- package/dist/redis/session-store.d.ts.map +1 -0
- package/dist/route/index.d.ts +3 -2
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/mutation.d.ts +97 -0
- package/dist/route/mutation.d.ts.map +1 -0
- package/dist/route/serialization.d.ts +24 -0
- package/dist/route/serialization.d.ts.map +1 -0
- package/dist/route/types.d.ts +6 -1
- package/dist/route/types.d.ts.map +1 -1
- package/dist/route/webhook.d.ts +6 -1
- package/dist/route/webhook.d.ts.map +1 -1
- package/dist/router/manifest.d.ts +8 -0
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/router/navigation-data.d.ts +9 -1
- package/dist/router/navigation-data.d.ts.map +1 -1
- package/dist/routing/generate.d.ts +3 -0
- package/dist/routing/generate.d.ts.map +1 -1
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/locale.d.ts +43 -0
- package/dist/routing/locale.d.ts.map +1 -0
- package/dist/routing/types.d.ts +12 -0
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/security/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/cookie-session.d.ts +43 -0
- package/dist/security/cookie-session.d.ts.map +1 -0
- package/dist/security/csrf.d.ts +1 -1
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +13 -0
- package/dist/security/env-startup.d.ts.map +1 -0
- package/dist/security/env.d.ts +49 -11
- 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 +14 -3
- 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/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 +139 -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/document-shell.d.ts.map +1 -1
- package/dist/server/errors.d.ts +1 -0
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/not-found.d.ts +1 -0
- package/dist/server/not-found.d.ts.map +1 -1
- package/dist/server/render-tree.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +7 -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/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 +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 +13 -6
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +29 -1560
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugin.d.ts +24 -3
- 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 +24 -6
- package/dist/chunks/document-shell-WoM8yZlR.js +0 -35
- package/dist/chunks/document-shell-WoM8yZlR.js.map +0 -1
- package/dist/chunks/images-Edar3eU1.js.map +0 -1
- package/dist/chunks/request-metadata-DaIYq4Ea.js +0 -677
- package/dist/chunks/request-metadata-DaIYq4Ea.js.map +0 -1
- package/dist/chunks/static-files-DUjHw-4H.js +0 -11
- package/dist/chunks/static-files-DUjHw-4H.js.map +0 -1
- package/dist/chunks/streaming-D0fGAuiO.js +0 -469
- package/dist/chunks/streaming-D0fGAuiO.js.map +0 -1
- package/dist/chunks/testing-CRflAw4X.js +0 -3475
- package/dist/chunks/testing-CRflAw4X.js.map +0 -1
- package/dist/route/action.d.ts +0 -33
- package/dist/route/action.d.ts.map +0 -1
package/dist/node/index.js
CHANGED
|
@@ -1,95 +1,79 @@
|
|
|
1
|
-
import { createServer as
|
|
2
|
-
import { d as
|
|
3
|
-
import { v, t as
|
|
4
|
-
import {
|
|
1
|
+
import { createServer as H } from "node:http";
|
|
2
|
+
import { d as C } from "../chunks/index-0MNiR_wo.js";
|
|
3
|
+
import { r as I, v as L, t as x, U as A, w as F, a as M, b as k } from "../chunks/streaming-GYIsVTQH.js";
|
|
4
|
+
import { C as _e, c as je, d as Be, e as ze, f as qe } from "../chunks/streaming-GYIsVTQH.js";
|
|
5
5
|
import { constants as S } from "node:fs";
|
|
6
|
-
import { realpath as T, open as
|
|
7
|
-
import { resolve as
|
|
8
|
-
import { Readable as
|
|
9
|
-
import { I as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
".jpg": "image/jpeg",
|
|
18
|
-
".js": "text/javascript; charset=utf-8",
|
|
19
|
-
".json": "application/json; charset=utf-8",
|
|
20
|
-
".mjs": "text/javascript; charset=utf-8",
|
|
21
|
-
".png": "image/png",
|
|
22
|
-
".svg": "image/svg+xml",
|
|
23
|
-
".txt": "text/plain; charset=utf-8",
|
|
24
|
-
".webmanifest": "application/manifest+json",
|
|
25
|
-
".webp": "image/webp",
|
|
26
|
-
".woff": "font/woff",
|
|
27
|
-
".woff2": "font/woff2"
|
|
28
|
-
}, G = /* @__PURE__ */ new Set(["demiurge-manifest.json", "index.html"]);
|
|
29
|
-
function V(e) {
|
|
30
|
-
const t = x(e.root), n = T(t), r = te(e.prefix), o = e.exclude ?? re, i = e.immutable ?? ne;
|
|
31
|
-
return async function(s) {
|
|
32
|
-
if (s.method !== "GET" && s.method !== "HEAD")
|
|
6
|
+
import { realpath as T, open as W, lstat as D, readFile as $ } from "node:fs/promises";
|
|
7
|
+
import { resolve as P, sep as y, extname as U, relative as _, join as O } from "node:path";
|
|
8
|
+
import { Readable as E } from "node:stream";
|
|
9
|
+
import { I as j, R as B, i as z, c as q } from "../chunks/static-files-ehaD1kE7.js";
|
|
10
|
+
import { fileURLToPath as G } from "node:url";
|
|
11
|
+
import { p as V } from "../chunks/manifest-vO6c0G0W.js";
|
|
12
|
+
const Y = /* @__PURE__ */ new Set(["demiurge-manifest.json", "index.html"]);
|
|
13
|
+
function J(e) {
|
|
14
|
+
const t = P(e.root), n = T(t), r = ae(e.prefix), o = e.exclude ?? se, a = e.immutable ?? ie;
|
|
15
|
+
return async function(c) {
|
|
16
|
+
if (c.method !== "GET" && c.method !== "HEAD")
|
|
33
17
|
return null;
|
|
34
|
-
const m =
|
|
18
|
+
const m = ee(
|
|
35
19
|
t,
|
|
36
20
|
r,
|
|
37
|
-
new URL(
|
|
21
|
+
new URL(c.url).pathname
|
|
38
22
|
);
|
|
39
|
-
if (!m || o(
|
|
23
|
+
if (!m || o(ce(t, m)))
|
|
40
24
|
return null;
|
|
41
|
-
const g = await
|
|
25
|
+
const g = await ne(t, await te(n), m);
|
|
42
26
|
if (!g)
|
|
43
27
|
return null;
|
|
44
|
-
const { file: h, stats:
|
|
28
|
+
const { file: h, stats: i } = g, s = K(i.size, i.mtimeMs), f = i.mtime.toUTCString(), l = new Headers({
|
|
45
29
|
"accept-ranges": "bytes",
|
|
46
|
-
"cache-control":
|
|
47
|
-
"content-length": String(
|
|
48
|
-
"content-type":
|
|
30
|
+
"cache-control": a(le(m)) ? j : B,
|
|
31
|
+
"content-length": String(i.size),
|
|
32
|
+
"content-type": ue(m),
|
|
49
33
|
"cross-origin-resource-policy": "same-origin",
|
|
50
|
-
etag:
|
|
34
|
+
etag: s,
|
|
51
35
|
"last-modified": f,
|
|
52
36
|
"x-content-type-options": "nosniff"
|
|
53
37
|
});
|
|
54
|
-
if (
|
|
55
|
-
return await h.close(),
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
return await h.close(),
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
h.createReadStream({ end:
|
|
38
|
+
if (Q(c, s, i.mtimeMs))
|
|
39
|
+
return await h.close(), l.delete("content-length"), l.delete("content-type"), new Response(null, { headers: l, status: 304 });
|
|
40
|
+
const u = Z(c, i.mtimeMs) ? X(c.headers.get("range"), i.size) : null;
|
|
41
|
+
if (u === "unsatisfiable")
|
|
42
|
+
return await h.close(), l.delete("content-length"), l.delete("content-type"), l.set("content-range", `bytes */${i.size}`), new Response(null, { headers: l, status: 416 });
|
|
43
|
+
if (u) {
|
|
44
|
+
const w = u.end - u.start + 1;
|
|
45
|
+
return l.set("content-length", String(w)), l.set("content-range", `bytes ${u.start}-${u.end}/${i.size}`), c.method === "HEAD" ? (await h.close(), new Response(null, { headers: l, status: 206 })) : new Response(
|
|
46
|
+
E.toWeb(
|
|
47
|
+
h.createReadStream({ end: u.end, start: u.start })
|
|
64
48
|
),
|
|
65
|
-
{ headers:
|
|
49
|
+
{ headers: l, status: 206 }
|
|
66
50
|
);
|
|
67
51
|
}
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
{ headers:
|
|
52
|
+
return c.method === "HEAD" ? (await h.close(), new Response(null, { headers: l })) : new Response(
|
|
53
|
+
E.toWeb(h.createReadStream()),
|
|
54
|
+
{ headers: l }
|
|
71
55
|
);
|
|
72
56
|
};
|
|
73
57
|
}
|
|
74
|
-
function
|
|
58
|
+
function K(e, t) {
|
|
75
59
|
return `W/"${e.toString(16)}-${Math.trunc(t).toString(16)}"`;
|
|
76
60
|
}
|
|
77
|
-
function
|
|
61
|
+
function Q(e, t, n) {
|
|
78
62
|
const r = e.headers.get("if-none-match");
|
|
79
63
|
if (r !== null)
|
|
80
64
|
return r.trim() === "*" || r.split(",").some(
|
|
81
|
-
(
|
|
65
|
+
(d) => N(d) === N(t)
|
|
82
66
|
);
|
|
83
67
|
const o = e.headers.get("if-modified-since");
|
|
84
68
|
if (o === null)
|
|
85
69
|
return !1;
|
|
86
|
-
const
|
|
87
|
-
return Number.isFinite(
|
|
70
|
+
const a = Date.parse(o);
|
|
71
|
+
return Number.isFinite(a) && Math.floor(n / 1e3) * 1e3 <= a;
|
|
88
72
|
}
|
|
89
|
-
function
|
|
73
|
+
function N(e) {
|
|
90
74
|
return e.trim().replace(/^W\//i, "");
|
|
91
75
|
}
|
|
92
|
-
function
|
|
76
|
+
function X(e, t) {
|
|
93
77
|
if (e === null)
|
|
94
78
|
return null;
|
|
95
79
|
const n = /^bytes=(\d*)-(\d*)$/.exec(e.trim());
|
|
@@ -98,13 +82,13 @@ function Y(e, t) {
|
|
|
98
82
|
if (t === 0)
|
|
99
83
|
return "unsatisfiable";
|
|
100
84
|
if (!n[1]) {
|
|
101
|
-
const
|
|
102
|
-
return !Number.isSafeInteger(
|
|
85
|
+
const a = Number(n[2]);
|
|
86
|
+
return !Number.isSafeInteger(a) || a <= 0 ? null : { start: Math.max(0, t - a), end: t - 1 };
|
|
103
87
|
}
|
|
104
88
|
const r = Number(n[1]), o = n[2] ? Number(n[2]) : t - 1;
|
|
105
89
|
return !Number.isSafeInteger(r) || !Number.isSafeInteger(o) ? null : r >= t ? "unsatisfiable" : n[2] && o < r ? null : { start: r, end: Math.min(o, t - 1) };
|
|
106
90
|
}
|
|
107
|
-
function
|
|
91
|
+
function Z(e, t) {
|
|
108
92
|
const n = e.headers.get("if-range");
|
|
109
93
|
if (n === null)
|
|
110
94
|
return !0;
|
|
@@ -113,7 +97,7 @@ function J(e, t) {
|
|
|
113
97
|
const r = Date.parse(n);
|
|
114
98
|
return Number.isFinite(r) && Math.floor(t / 1e3) * 1e3 <= r;
|
|
115
99
|
}
|
|
116
|
-
function
|
|
100
|
+
function ee(e, t, n) {
|
|
117
101
|
let r;
|
|
118
102
|
try {
|
|
119
103
|
r = decodeURIComponent(n);
|
|
@@ -129,18 +113,18 @@ function K(e, t, n) {
|
|
|
129
113
|
}
|
|
130
114
|
if (r.endsWith("/"))
|
|
131
115
|
return null;
|
|
132
|
-
const o =
|
|
133
|
-
return o.startsWith(`${e}${
|
|
116
|
+
const o = P(e, `.${r}`);
|
|
117
|
+
return o.startsWith(`${e}${y}`) ? o : null;
|
|
134
118
|
}
|
|
135
|
-
async function
|
|
119
|
+
async function te(e) {
|
|
136
120
|
try {
|
|
137
121
|
return await e;
|
|
138
122
|
} catch {
|
|
139
123
|
return null;
|
|
140
124
|
}
|
|
141
125
|
}
|
|
142
|
-
async function
|
|
143
|
-
if (!t || !await
|
|
126
|
+
async function ne(e, t, n) {
|
|
127
|
+
if (!t || !await re(e, n))
|
|
144
128
|
return null;
|
|
145
129
|
let r;
|
|
146
130
|
try {
|
|
@@ -148,104 +132,169 @@ async function X(e, t, n) {
|
|
|
148
132
|
} catch {
|
|
149
133
|
return null;
|
|
150
134
|
}
|
|
151
|
-
if (!
|
|
135
|
+
if (!oe(t, r))
|
|
152
136
|
return null;
|
|
153
137
|
const o = typeof S.O_NOFOLLOW == "number" ? S.O_NOFOLLOW : 0;
|
|
154
|
-
let
|
|
138
|
+
let a;
|
|
155
139
|
try {
|
|
156
|
-
|
|
140
|
+
a = await W(n, S.O_RDONLY | o);
|
|
157
141
|
} catch {
|
|
158
142
|
return null;
|
|
159
143
|
}
|
|
160
144
|
try {
|
|
161
|
-
const
|
|
162
|
-
return
|
|
145
|
+
const d = await a.stat();
|
|
146
|
+
return d.isFile() ? { file: a, stats: d } : (await a.close(), null);
|
|
163
147
|
} catch {
|
|
164
|
-
return await
|
|
148
|
+
return await a.close(), null;
|
|
165
149
|
}
|
|
166
150
|
}
|
|
167
|
-
async function
|
|
168
|
-
const n =
|
|
151
|
+
async function re(e, t) {
|
|
152
|
+
const n = _(e, t).split(y);
|
|
169
153
|
let r = e;
|
|
170
154
|
try {
|
|
171
155
|
for (const o of n)
|
|
172
|
-
if (r =
|
|
156
|
+
if (r = O(r, o), (await D(r)).isSymbolicLink())
|
|
173
157
|
return !1;
|
|
174
158
|
} catch {
|
|
175
159
|
return !1;
|
|
176
160
|
}
|
|
177
161
|
return !0;
|
|
178
162
|
}
|
|
179
|
-
function
|
|
180
|
-
return t.startsWith(`${e}${
|
|
163
|
+
function oe(e, t) {
|
|
164
|
+
return t.startsWith(`${e}${y}`);
|
|
181
165
|
}
|
|
182
|
-
function
|
|
166
|
+
function ae(e) {
|
|
183
167
|
return !e || e === "/" ? "" : `/${e.replace(/^\/|\/$/g, "")}/`;
|
|
184
168
|
}
|
|
185
|
-
function
|
|
186
|
-
return
|
|
169
|
+
function ie(e) {
|
|
170
|
+
return z(e);
|
|
187
171
|
}
|
|
188
|
-
function
|
|
189
|
-
return
|
|
172
|
+
function se(e) {
|
|
173
|
+
return Y.has(e);
|
|
190
174
|
}
|
|
191
|
-
function
|
|
192
|
-
return t.slice(e.length + 1).split(
|
|
175
|
+
function ce(e, t) {
|
|
176
|
+
return t.slice(e.length + 1).split(y).join("/");
|
|
193
177
|
}
|
|
194
|
-
function
|
|
195
|
-
return e.slice(e.lastIndexOf(
|
|
178
|
+
function le(e) {
|
|
179
|
+
return e.slice(e.lastIndexOf(y) + 1);
|
|
196
180
|
}
|
|
197
|
-
function
|
|
198
|
-
return
|
|
181
|
+
function ue(e) {
|
|
182
|
+
return q(U(e));
|
|
183
|
+
}
|
|
184
|
+
const de = "dist/client", fe = "/.well-known/ready";
|
|
185
|
+
async function We(e) {
|
|
186
|
+
const t = e.env ?? process.env, n = G(
|
|
187
|
+
new URL(e.clientDir ?? de, e.base)
|
|
188
|
+
), r = V(
|
|
189
|
+
await $(O(n, "demiurge-manifest.json"), "utf8")
|
|
190
|
+
), o = e.host ?? t.HOST ?? "127.0.0.1", a = me(t.PORT, e.port), d = he(
|
|
191
|
+
e.allowedHosts,
|
|
192
|
+
t.ALLOWED_HOSTS,
|
|
193
|
+
o
|
|
194
|
+
), c = e.name ?? "Demiurge Node server", m = e.readyPath === !1 ? void 0 : e.readyPath ?? fe, g = [], h = {
|
|
195
|
+
page: {
|
|
196
|
+
clientEntry: r.clientEntry,
|
|
197
|
+
renderPage: I,
|
|
198
|
+
styles: r.styles
|
|
199
|
+
},
|
|
200
|
+
root: n,
|
|
201
|
+
waitUntil(u) {
|
|
202
|
+
g.push(u);
|
|
203
|
+
}
|
|
204
|
+
}, i = await e.createHandler(h), s = Se({
|
|
205
|
+
allowedHosts: d,
|
|
206
|
+
handler: i,
|
|
207
|
+
onError: e.onError,
|
|
208
|
+
readyPath: m,
|
|
209
|
+
shutdown: e.shutdown,
|
|
210
|
+
static: ge(e.static, h),
|
|
211
|
+
timeouts: e.timeouts,
|
|
212
|
+
trustProxy: e.trustProxy
|
|
213
|
+
});
|
|
214
|
+
h.waitUntil = (u) => {
|
|
215
|
+
s.waitUntil(u);
|
|
216
|
+
};
|
|
217
|
+
for (const u of g)
|
|
218
|
+
s.waitUntil(u);
|
|
219
|
+
await new Promise((u, w) => {
|
|
220
|
+
s.once("error", w), s.listen(a, o, () => {
|
|
221
|
+
s.off("error", w), u();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
const f = s.address(), l = typeof f == "object" && f ? f.port : a;
|
|
225
|
+
return e.onListen ? e.onListen({ host: o, port: l, server: s }) : console.log(`${c} listening on http://${o}:${l}`), s;
|
|
226
|
+
}
|
|
227
|
+
function me(e, t) {
|
|
228
|
+
const n = e ?? String(t ?? 4173), r = Number(n);
|
|
229
|
+
if (!Number.isSafeInteger(r) || r < 0 || r > 65535)
|
|
230
|
+
throw new Error("Demiurge Node PORT must be an integer from 0 through 65535.");
|
|
231
|
+
return r;
|
|
232
|
+
}
|
|
233
|
+
function he(e, t, n) {
|
|
234
|
+
return e || (t ? t.split(",").map((r) => r.trim()).filter(Boolean) : n === "localhost" ? [n] : [n, "localhost"]);
|
|
235
|
+
}
|
|
236
|
+
function ge(e, t) {
|
|
237
|
+
if (!e)
|
|
238
|
+
return { root: t.root };
|
|
239
|
+
if (typeof e != "function")
|
|
240
|
+
return e;
|
|
241
|
+
const n = e(t);
|
|
242
|
+
if (n instanceof Promise)
|
|
243
|
+
throw new TypeError(
|
|
244
|
+
"The `static` option must be a StaticFileHandlerOptions object or a factory `(context) => StaticFileHandler | StaticFileHandlerOptions`. It looks like a StaticFileHandler was passed directly. Wrap it: `static: () => yourHandler`."
|
|
245
|
+
);
|
|
246
|
+
return n;
|
|
199
247
|
}
|
|
200
|
-
const
|
|
248
|
+
const De = C({
|
|
201
249
|
name: "node",
|
|
202
250
|
capabilities: {
|
|
203
251
|
backgroundLifetime: !0,
|
|
204
252
|
crossOriginIsolationHeaders: !0,
|
|
205
253
|
nonceInjection: !0,
|
|
254
|
+
requestTimeoutEnforcement: !0,
|
|
206
255
|
streaming: !0
|
|
207
256
|
}
|
|
208
|
-
}),
|
|
257
|
+
}), we = {
|
|
209
258
|
headersTimeout: 66e3,
|
|
210
259
|
keepAliveTimeout: 65e3,
|
|
211
260
|
requestTimeout: 3e5
|
|
212
|
-
},
|
|
213
|
-
function
|
|
214
|
-
|
|
215
|
-
const t =
|
|
216
|
-
return function(
|
|
217
|
-
const
|
|
218
|
-
r(
|
|
219
|
-
|
|
220
|
-
}).finally(
|
|
261
|
+
}, ye = 3e4;
|
|
262
|
+
function pe(e) {
|
|
263
|
+
L(e);
|
|
264
|
+
const t = Pe(e.static), n = e.onError ?? p;
|
|
265
|
+
return function(a, d) {
|
|
266
|
+
const c = be(a, d);
|
|
267
|
+
r(a, d, c.signal).catch((m) => {
|
|
268
|
+
c.signal.aborted || (n(m, a), Oe(d));
|
|
269
|
+
}).finally(c.cleanup);
|
|
221
270
|
};
|
|
222
|
-
async function r(o,
|
|
223
|
-
let
|
|
271
|
+
async function r(o, a, d) {
|
|
272
|
+
let c;
|
|
224
273
|
try {
|
|
225
|
-
|
|
274
|
+
c = x(o, {
|
|
226
275
|
allowedHosts: e.allowedHosts,
|
|
227
|
-
signal:
|
|
276
|
+
signal: d,
|
|
228
277
|
trustProxy: e.trustProxy
|
|
229
278
|
});
|
|
230
279
|
} catch (g) {
|
|
231
|
-
if (g instanceof
|
|
232
|
-
|
|
280
|
+
if (g instanceof A) {
|
|
281
|
+
F(a);
|
|
233
282
|
return;
|
|
234
283
|
}
|
|
235
|
-
if (g instanceof
|
|
236
|
-
|
|
284
|
+
if (g instanceof M) {
|
|
285
|
+
Re(a);
|
|
237
286
|
return;
|
|
238
287
|
}
|
|
239
288
|
throw g;
|
|
240
289
|
}
|
|
241
|
-
const m = await t?.(
|
|
290
|
+
const m = await t?.(c);
|
|
242
291
|
await k(
|
|
243
|
-
|
|
244
|
-
m ?? await e.handler(
|
|
292
|
+
a,
|
|
293
|
+
m ?? await e.handler(c)
|
|
245
294
|
);
|
|
246
295
|
}
|
|
247
296
|
}
|
|
248
|
-
function
|
|
297
|
+
function be(e, t) {
|
|
249
298
|
const n = new AbortController(), r = () => {
|
|
250
299
|
n.signal.aborted || n.abort(new DOMException("Client disconnected.", "AbortError"));
|
|
251
300
|
}, o = () => {
|
|
@@ -258,16 +307,38 @@ function ue(e, t) {
|
|
|
258
307
|
signal: n.signal
|
|
259
308
|
};
|
|
260
309
|
}
|
|
261
|
-
function
|
|
310
|
+
function Re(e) {
|
|
262
311
|
e.statusCode = 421, e.setHeader("content-type", "text/plain; charset=utf-8"), e.end("Misdirected Request");
|
|
263
312
|
}
|
|
264
|
-
function
|
|
265
|
-
const t =
|
|
266
|
-
|
|
313
|
+
function Se(e) {
|
|
314
|
+
const t = Ne(e.timeouts), n = Ee(e.readyPath), r = n ? async (a) => {
|
|
315
|
+
if (new URL(a.url).pathname !== n)
|
|
316
|
+
return e.handler(a);
|
|
317
|
+
const d = o.isReady();
|
|
318
|
+
return new Response(d ? "ready" : "draining", {
|
|
319
|
+
headers: {
|
|
320
|
+
"cache-control": "no-store",
|
|
321
|
+
"content-type": "text/plain; charset=utf-8"
|
|
322
|
+
},
|
|
323
|
+
status: d ? 200 : 503
|
|
324
|
+
});
|
|
325
|
+
} : e.handler, o = H(
|
|
326
|
+
pe({ ...e, handler: r })
|
|
327
|
+
);
|
|
328
|
+
return o.keepAliveTimeout = t.keepAliveTimeout, o.headersTimeout = t.headersTimeout, o.requestTimeout = t.requestTimeout, Te(o, e.shutdown);
|
|
329
|
+
}
|
|
330
|
+
function Ee(e) {
|
|
331
|
+
if (e !== void 0) {
|
|
332
|
+
if (!e.startsWith("/") || e.includes("?"))
|
|
333
|
+
throw new Error(
|
|
334
|
+
"Demiurge Node readyPath must be an absolute path without a query string."
|
|
335
|
+
);
|
|
336
|
+
return e;
|
|
337
|
+
}
|
|
267
338
|
}
|
|
268
|
-
function
|
|
339
|
+
function Ne(e) {
|
|
269
340
|
const t = {
|
|
270
|
-
...
|
|
341
|
+
...we,
|
|
271
342
|
...e
|
|
272
343
|
};
|
|
273
344
|
for (const [n, r] of Object.entries(t))
|
|
@@ -281,87 +352,87 @@ function de(e) {
|
|
|
281
352
|
);
|
|
282
353
|
return t;
|
|
283
354
|
}
|
|
284
|
-
function
|
|
285
|
-
const n = t?.gracePeriod ??
|
|
355
|
+
function Te(e, t) {
|
|
356
|
+
const n = t?.gracePeriod ?? ye;
|
|
286
357
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
287
358
|
throw new Error(
|
|
288
359
|
"Demiurge Node shutdown gracePeriod must be a non-negative integer in milliseconds."
|
|
289
360
|
);
|
|
290
|
-
let r = !1, o,
|
|
291
|
-
const
|
|
292
|
-
e.on("connection", (
|
|
293
|
-
|
|
294
|
-
}), e.on("request", (
|
|
295
|
-
const f =
|
|
361
|
+
let r = !1, o, a;
|
|
362
|
+
const d = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
|
|
363
|
+
e.on("connection", (i) => {
|
|
364
|
+
c.set(i, 0), i.once("close", () => c.delete(i));
|
|
365
|
+
}), e.on("request", (i, s) => {
|
|
366
|
+
const f = s.socket;
|
|
296
367
|
if (!f)
|
|
297
368
|
return;
|
|
298
|
-
|
|
299
|
-
let
|
|
300
|
-
const
|
|
301
|
-
if (
|
|
369
|
+
c.set(f, (c.get(f) ?? 0) + 1);
|
|
370
|
+
let l = !1;
|
|
371
|
+
const u = () => {
|
|
372
|
+
if (l)
|
|
302
373
|
return;
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
374
|
+
l = !0;
|
|
375
|
+
const w = Math.max(0, (c.get(f) ?? 1) - 1);
|
|
376
|
+
c.set(f, w), r && w === 0 && f.destroy();
|
|
306
377
|
};
|
|
307
|
-
|
|
308
|
-
}), e.isReady = () => e.listening && !r, e.waitUntil = (
|
|
309
|
-
const
|
|
378
|
+
s.once("finish", u), s.once("close", u);
|
|
379
|
+
}), e.isReady = () => e.listening && !r, e.waitUntil = (i) => {
|
|
380
|
+
const s = Promise.resolve(i).catch((f) => {
|
|
310
381
|
try {
|
|
311
|
-
(t?.onBackgroundError ??
|
|
312
|
-
} catch (
|
|
313
|
-
|
|
382
|
+
(t?.onBackgroundError ?? p)(f);
|
|
383
|
+
} catch (l) {
|
|
384
|
+
p(l);
|
|
314
385
|
}
|
|
315
386
|
}).then(() => {
|
|
316
387
|
}).finally(() => {
|
|
317
|
-
m.delete(
|
|
388
|
+
m.delete(s), a?.();
|
|
318
389
|
});
|
|
319
|
-
m.add(
|
|
320
|
-
}, e.shutdown = () => o || (r = !0, t?.onStateChange?.("draining"), o = new Promise((
|
|
321
|
-
let f,
|
|
322
|
-
const
|
|
323
|
-
|
|
390
|
+
m.add(s);
|
|
391
|
+
}, e.shutdown = () => o || (r = !0, t?.onStateChange?.("draining"), o = new Promise((i, s) => {
|
|
392
|
+
let f, l = !1, u = !1, w = !1;
|
|
393
|
+
const v = setTimeout(() => {
|
|
394
|
+
l = !0, e.closeAllConnections(), b();
|
|
324
395
|
}, n);
|
|
325
396
|
e.close((R) => {
|
|
326
|
-
R && R.code !== "ERR_SERVER_NOT_RUNNING" && (f = R),
|
|
397
|
+
R && R.code !== "ERR_SERVER_NOT_RUNNING" && (f = R), u = !0, b();
|
|
327
398
|
}), e.closeIdleConnections(), h(), setImmediate(() => {
|
|
328
399
|
e.closeIdleConnections(), h();
|
|
329
|
-
}),
|
|
330
|
-
function
|
|
331
|
-
if (!(
|
|
332
|
-
if (
|
|
333
|
-
|
|
400
|
+
}), a = b;
|
|
401
|
+
function b() {
|
|
402
|
+
if (!(w || !u || !l && m.size > 0)) {
|
|
403
|
+
if (w = !0, a = void 0, clearTimeout(v), g(), t?.onStateChange?.("stopped"), f) {
|
|
404
|
+
s(f);
|
|
334
405
|
return;
|
|
335
406
|
}
|
|
336
|
-
|
|
407
|
+
i();
|
|
337
408
|
}
|
|
338
409
|
}
|
|
339
410
|
}), o), e.on("listening", () => t?.onStateChange?.("ready"));
|
|
340
|
-
for (const
|
|
341
|
-
const
|
|
342
|
-
e.shutdown().catch(
|
|
411
|
+
for (const i of new Set(t?.signals ?? [])) {
|
|
412
|
+
const s = () => {
|
|
413
|
+
e.shutdown().catch(p);
|
|
343
414
|
};
|
|
344
|
-
|
|
415
|
+
d.set(i, s), process.once(i, s);
|
|
345
416
|
}
|
|
346
417
|
return e.once("close", g), e;
|
|
347
418
|
function g() {
|
|
348
|
-
for (const [
|
|
349
|
-
process.off(
|
|
350
|
-
|
|
419
|
+
for (const [i, s] of d)
|
|
420
|
+
process.off(i, s);
|
|
421
|
+
d.clear();
|
|
351
422
|
}
|
|
352
423
|
function h() {
|
|
353
|
-
for (const [
|
|
354
|
-
|
|
424
|
+
for (const [i, s] of c)
|
|
425
|
+
s === 0 && i.destroy();
|
|
355
426
|
}
|
|
356
427
|
}
|
|
357
|
-
function
|
|
428
|
+
function Pe(e) {
|
|
358
429
|
if (e)
|
|
359
|
-
return typeof e == "function" ? e :
|
|
430
|
+
return typeof e == "function" ? e : J(e);
|
|
360
431
|
}
|
|
361
|
-
function
|
|
432
|
+
function p(e) {
|
|
362
433
|
console.error(e);
|
|
363
434
|
}
|
|
364
|
-
function
|
|
435
|
+
function Oe(e) {
|
|
365
436
|
if (e.headersSent) {
|
|
366
437
|
e.destroy();
|
|
367
438
|
return;
|
|
@@ -369,20 +440,24 @@ function he(e) {
|
|
|
369
440
|
e.statusCode = 500, e.setHeader("content-type", "text/plain; charset=utf-8"), e.end("Internal Server Error");
|
|
370
441
|
}
|
|
371
442
|
export {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
443
|
+
_e as ConsumedRequestBodyError,
|
|
444
|
+
A as UnsupportedMethodError,
|
|
445
|
+
M as UntrustedHostError,
|
|
446
|
+
je as createFontAssetHandler,
|
|
447
|
+
Be as createImageOptimizer,
|
|
448
|
+
pe as createNodeRequestListener,
|
|
449
|
+
Se as createNodeServer,
|
|
450
|
+
J as createStaticFileHandler,
|
|
451
|
+
de as defaultNodeBuildClientDir,
|
|
452
|
+
fe as defaultNodeBuildReadyPath,
|
|
453
|
+
we as defaultNodeServerTimeouts,
|
|
454
|
+
De as nodeAdapter,
|
|
455
|
+
I as renderNodePageResponse,
|
|
456
|
+
ze as renderStreamingPageResponse,
|
|
457
|
+
We as serveNodeBuild,
|
|
458
|
+
qe as toHeaders,
|
|
459
|
+
x as toWebRequest,
|
|
460
|
+
L as validateNodeOriginPolicy,
|
|
386
461
|
k as writeWebResponse
|
|
387
462
|
};
|
|
388
463
|
//# sourceMappingURL=index.js.map
|