@vesk/vesk-cli 0.2.67 → 0.2.68
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/dist/cli.js +616 -289
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -35641,6 +35641,120 @@ var init_paths = __esm({
|
|
|
35641
35641
|
}
|
|
35642
35642
|
});
|
|
35643
35643
|
|
|
35644
|
+
// ../adapter/src/platform-output.ts
|
|
35645
|
+
import {
|
|
35646
|
+
mkdirSync as mkdirSync6,
|
|
35647
|
+
copyFileSync as copyFileSync2,
|
|
35648
|
+
readdirSync as readdirSync3,
|
|
35649
|
+
statSync as statSync6,
|
|
35650
|
+
existsSync as existsSync15,
|
|
35651
|
+
writeFileSync as writeFileSync7,
|
|
35652
|
+
rmSync as rmSync2,
|
|
35653
|
+
readFileSync as readFileSync15
|
|
35654
|
+
} from "node:fs";
|
|
35655
|
+
import { resolve as resolve13, join as join10, extname as extname3, dirname as dirname10 } from "node:path";
|
|
35656
|
+
function ensureCleanDir(dir) {
|
|
35657
|
+
rmSync2(dir, { recursive: true, force: true });
|
|
35658
|
+
mkdirSync6(dir, { recursive: true });
|
|
35659
|
+
}
|
|
35660
|
+
function copyDirContents(srcDir, destDir) {
|
|
35661
|
+
if (!existsSync15(srcDir)) return;
|
|
35662
|
+
mkdirSync6(destDir, { recursive: true });
|
|
35663
|
+
for (const entry of readdirSync3(srcDir)) {
|
|
35664
|
+
const srcPath = join10(srcDir, entry);
|
|
35665
|
+
const destPath = join10(destDir, entry);
|
|
35666
|
+
if (statSync6(srcPath).isDirectory()) {
|
|
35667
|
+
copyDirContents(srcPath, destPath);
|
|
35668
|
+
} else {
|
|
35669
|
+
mkdirSync6(dirname10(destPath), { recursive: true });
|
|
35670
|
+
copyFileSync2(srcPath, destPath);
|
|
35671
|
+
}
|
|
35672
|
+
}
|
|
35673
|
+
}
|
|
35674
|
+
function writeFile(path, content) {
|
|
35675
|
+
mkdirSync6(dirname10(path), { recursive: true });
|
|
35676
|
+
writeFileSync7(path, content, "utf-8");
|
|
35677
|
+
}
|
|
35678
|
+
function writePlatformStatic(buildStaticDir, platformStaticDir) {
|
|
35679
|
+
mkdirSync6(platformStaticDir, { recursive: true });
|
|
35680
|
+
const publicDir = resolve13(buildStaticDir, "public");
|
|
35681
|
+
if (existsSync15(publicDir)) {
|
|
35682
|
+
copyDirContents(publicDir, platformStaticDir);
|
|
35683
|
+
}
|
|
35684
|
+
const assetsDir = resolve13(platformStaticDir, "_vesk", "static");
|
|
35685
|
+
copyDirContents(buildStaticDir, assetsDir);
|
|
35686
|
+
const runtimeAlias = resolve13(platformStaticDir, "_vesk", "runtime.js");
|
|
35687
|
+
const clientPath = resolve13(buildStaticDir, "client.js");
|
|
35688
|
+
if (existsSync15(clientPath)) {
|
|
35689
|
+
mkdirSync6(dirname10(runtimeAlias), { recursive: true });
|
|
35690
|
+
copyFileSync2(clientPath, runtimeAlias);
|
|
35691
|
+
}
|
|
35692
|
+
}
|
|
35693
|
+
function writePrerenderedStatic(prerenderedRoutes, platformStaticDir) {
|
|
35694
|
+
for (const route of prerenderedRoutes) {
|
|
35695
|
+
if (!existsSync15(route.html)) continue;
|
|
35696
|
+
const content = readFileSync15(route.html);
|
|
35697
|
+
const htmlRel = route.path === "/" ? "index.html" : `${route.path.replace(/^\//, "")}.html`;
|
|
35698
|
+
const target = resolve13(platformStaticDir, "_vesk", "static", "public", htmlRel);
|
|
35699
|
+
writeFile(target, content);
|
|
35700
|
+
if (route.path !== "/" && route.path.endsWith("/")) {
|
|
35701
|
+
const dirIndex = resolve13(platformStaticDir, "_vesk", "static", "public", `${route.path.replace(/^\//, "")}index.html`);
|
|
35702
|
+
writeFile(dirIndex, content);
|
|
35703
|
+
}
|
|
35704
|
+
}
|
|
35705
|
+
}
|
|
35706
|
+
function listStaticDir(dir) {
|
|
35707
|
+
const out = [];
|
|
35708
|
+
if (!existsSync15(dir)) return out;
|
|
35709
|
+
function walk9(d, prefix) {
|
|
35710
|
+
for (const entry of readdirSync3(d)) {
|
|
35711
|
+
const full = join10(d, entry);
|
|
35712
|
+
const rel = prefix ? `${prefix}/${entry}` : entry;
|
|
35713
|
+
if (statSync6(full).isDirectory()) {
|
|
35714
|
+
walk9(full, rel);
|
|
35715
|
+
} else {
|
|
35716
|
+
out.push({ rel, buffer: readFileSync15(full) });
|
|
35717
|
+
}
|
|
35718
|
+
}
|
|
35719
|
+
}
|
|
35720
|
+
walk9(dir, "");
|
|
35721
|
+
return out;
|
|
35722
|
+
}
|
|
35723
|
+
function mimeFor(path) {
|
|
35724
|
+
return MIME[extname3(path).toLowerCase()] || "application/octet-stream";
|
|
35725
|
+
}
|
|
35726
|
+
var MIME;
|
|
35727
|
+
var init_platform_output = __esm({
|
|
35728
|
+
"../adapter/src/platform-output.ts"() {
|
|
35729
|
+
"use strict";
|
|
35730
|
+
MIME = {
|
|
35731
|
+
".html": "text/html; charset=utf-8",
|
|
35732
|
+
".htm": "text/html; charset=utf-8",
|
|
35733
|
+
".js": "application/javascript; charset=utf-8",
|
|
35734
|
+
".mjs": "application/javascript; charset=utf-8",
|
|
35735
|
+
".css": "text/css; charset=utf-8",
|
|
35736
|
+
".json": "application/json; charset=utf-8",
|
|
35737
|
+
".svg": "image/svg+xml",
|
|
35738
|
+
".png": "image/png",
|
|
35739
|
+
".jpg": "image/jpeg",
|
|
35740
|
+
".jpeg": "image/jpeg",
|
|
35741
|
+
".gif": "image/gif",
|
|
35742
|
+
".webp": "image/webp",
|
|
35743
|
+
".avif": "image/avif",
|
|
35744
|
+
".ico": "image/x-icon",
|
|
35745
|
+
".txt": "text/plain; charset=utf-8",
|
|
35746
|
+
".xml": "application/xml",
|
|
35747
|
+
".woff": "font/woff",
|
|
35748
|
+
".woff2": "font/woff2",
|
|
35749
|
+
".ttf": "font/ttf",
|
|
35750
|
+
".otf": "font/otf",
|
|
35751
|
+
".wasm": "application/wasm",
|
|
35752
|
+
".map": "application/json",
|
|
35753
|
+
".webmanifest": "application/manifest+json"
|
|
35754
|
+
};
|
|
35755
|
+
}
|
|
35756
|
+
});
|
|
35757
|
+
|
|
35644
35758
|
// ../adapter/src/plugins.ts
|
|
35645
35759
|
var plugins_exports = {};
|
|
35646
35760
|
__export(plugins_exports, {
|
|
@@ -35661,13 +35775,13 @@ __export(plugins_exports, {
|
|
|
35661
35775
|
writePluginState: () => writePluginState
|
|
35662
35776
|
});
|
|
35663
35777
|
import {
|
|
35664
|
-
readFileSync as
|
|
35665
|
-
writeFileSync as
|
|
35666
|
-
existsSync as
|
|
35667
|
-
mkdirSync as
|
|
35668
|
-
statSync as
|
|
35778
|
+
readFileSync as readFileSync17,
|
|
35779
|
+
writeFileSync as writeFileSync8,
|
|
35780
|
+
existsSync as existsSync17,
|
|
35781
|
+
mkdirSync as mkdirSync7,
|
|
35782
|
+
statSync as statSync8
|
|
35669
35783
|
} from "node:fs";
|
|
35670
|
-
import { resolve as
|
|
35784
|
+
import { resolve as resolve15, dirname as dirname12, join as join11, extname as extname4, basename as basename2 } from "node:path";
|
|
35671
35785
|
import { createRequire as createRequire4 } from "node:module";
|
|
35672
35786
|
import { spawn } from "node:child_process";
|
|
35673
35787
|
function defaultState() {
|
|
@@ -35677,14 +35791,14 @@ function eqIgnoreCase(a, b) {
|
|
|
35677
35791
|
return String(a || "").toLowerCase() === String(b || "").toLowerCase();
|
|
35678
35792
|
}
|
|
35679
35793
|
function stateFilePath(veskDir) {
|
|
35680
|
-
return
|
|
35794
|
+
return resolve15(veskDir, PLUGIN_STATE_FILENAME);
|
|
35681
35795
|
}
|
|
35682
35796
|
function readPluginState(veskDir) {
|
|
35683
35797
|
const file = stateFilePath(veskDir);
|
|
35684
|
-
if (!
|
|
35798
|
+
if (!existsSync17(file)) return defaultState();
|
|
35685
35799
|
let raw2;
|
|
35686
35800
|
try {
|
|
35687
|
-
raw2 = JSON.parse(
|
|
35801
|
+
raw2 = JSON.parse(readFileSync17(file, "utf-8"));
|
|
35688
35802
|
} catch {
|
|
35689
35803
|
return defaultState();
|
|
35690
35804
|
}
|
|
@@ -35701,12 +35815,12 @@ function readPluginState(veskDir) {
|
|
|
35701
35815
|
}
|
|
35702
35816
|
function writePluginState(veskDir, state) {
|
|
35703
35817
|
const file = stateFilePath(veskDir);
|
|
35704
|
-
const dir =
|
|
35705
|
-
if (!
|
|
35706
|
-
|
|
35818
|
+
const dir = dirname12(file);
|
|
35819
|
+
if (!existsSync17(dir)) mkdirSync7(dir, { recursive: true });
|
|
35820
|
+
writeFileSync8(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
|
|
35707
35821
|
}
|
|
35708
35822
|
function resolvePackage(appDir, pkg) {
|
|
35709
|
-
const require3 = createRequire4(
|
|
35823
|
+
const require3 = createRequire4(resolve15(appDir, "package.json"));
|
|
35710
35824
|
let entryPath = null;
|
|
35711
35825
|
let pkgJsonPath = null;
|
|
35712
35826
|
let pkgJson = null;
|
|
@@ -35715,31 +35829,31 @@ function resolvePackage(appDir, pkg) {
|
|
|
35715
35829
|
} catch {
|
|
35716
35830
|
try {
|
|
35717
35831
|
entryPath = require3.resolve(pkg);
|
|
35718
|
-
let cur =
|
|
35832
|
+
let cur = dirname12(entryPath);
|
|
35719
35833
|
const seen = /* @__PURE__ */ new Set();
|
|
35720
|
-
while (cur && cur !==
|
|
35834
|
+
while (cur && cur !== dirname12(cur) && !seen.has(cur)) {
|
|
35721
35835
|
seen.add(cur);
|
|
35722
|
-
const candidate =
|
|
35723
|
-
if (
|
|
35836
|
+
const candidate = join11(cur, "package.json");
|
|
35837
|
+
if (existsSync17(candidate)) {
|
|
35724
35838
|
pkgJsonPath = candidate;
|
|
35725
35839
|
break;
|
|
35726
35840
|
}
|
|
35727
|
-
const parent =
|
|
35841
|
+
const parent = dirname12(cur);
|
|
35728
35842
|
if (parent !== cur && basename2(cur) === "node_modules") break;
|
|
35729
35843
|
cur = parent;
|
|
35730
35844
|
}
|
|
35731
35845
|
} catch {
|
|
35732
35846
|
}
|
|
35733
35847
|
}
|
|
35734
|
-
if (pkgJsonPath &&
|
|
35848
|
+
if (pkgJsonPath && existsSync17(pkgJsonPath)) {
|
|
35735
35849
|
pkgJson = readJsonFile(pkgJsonPath);
|
|
35736
35850
|
const main = pkgJson?.main || pkgJson?.module || "index.js";
|
|
35737
|
-
entryPath =
|
|
35851
|
+
entryPath = resolve15(dirname12(pkgJsonPath), main);
|
|
35738
35852
|
}
|
|
35739
35853
|
let localPath = localDir(appDir, pkg);
|
|
35740
35854
|
if (!localPath) {
|
|
35741
35855
|
for (const sub of ["src/plugins", "plugins", "lib/plugins"]) {
|
|
35742
|
-
const candidate = localDir(
|
|
35856
|
+
const candidate = localDir(resolve15(appDir, sub), pkg);
|
|
35743
35857
|
if (candidate) {
|
|
35744
35858
|
localPath = candidate;
|
|
35745
35859
|
break;
|
|
@@ -35747,30 +35861,30 @@ function resolvePackage(appDir, pkg) {
|
|
|
35747
35861
|
}
|
|
35748
35862
|
}
|
|
35749
35863
|
if (localPath) {
|
|
35750
|
-
const localJson =
|
|
35864
|
+
const localJson = join11(localPath, "package.json");
|
|
35751
35865
|
let json = null;
|
|
35752
|
-
if (
|
|
35866
|
+
if (existsSync17(localJson)) {
|
|
35753
35867
|
json = readJsonFile(localJson);
|
|
35754
35868
|
}
|
|
35755
35869
|
return { installed: true, path: localPath, dir: localPath, packageJson: json ?? pkgJson };
|
|
35756
35870
|
}
|
|
35757
|
-
const installed2 = !!pkgJsonPath &&
|
|
35758
|
-
return { installed: installed2, path: entryPath, dir: installed2 ?
|
|
35871
|
+
const installed2 = !!pkgJsonPath && existsSync17(pkgJsonPath);
|
|
35872
|
+
return { installed: installed2, path: entryPath, dir: installed2 ? dirname12(pkgJsonPath) : null, packageJson: pkgJson };
|
|
35759
35873
|
}
|
|
35760
35874
|
function localDir(base, pkg) {
|
|
35761
35875
|
if (pkg.startsWith("@")) {
|
|
35762
35876
|
const parts = pkg.split("/");
|
|
35763
|
-
const p2 =
|
|
35764
|
-
if (
|
|
35877
|
+
const p2 = resolve15(base, parts[0], parts[1] ?? "");
|
|
35878
|
+
if (existsSync17(p2)) return p2;
|
|
35765
35879
|
return null;
|
|
35766
35880
|
}
|
|
35767
|
-
const p =
|
|
35768
|
-
if (
|
|
35881
|
+
const p = resolve15(base, pkg);
|
|
35882
|
+
if (existsSync17(p)) return p;
|
|
35769
35883
|
return null;
|
|
35770
35884
|
}
|
|
35771
35885
|
function readJsonFile(file) {
|
|
35772
35886
|
try {
|
|
35773
|
-
if (
|
|
35887
|
+
if (existsSync17(file)) return JSON.parse(readFileSync17(file, "utf-8"));
|
|
35774
35888
|
} catch {
|
|
35775
35889
|
}
|
|
35776
35890
|
return null;
|
|
@@ -35810,7 +35924,7 @@ function repositoryToString(r) {
|
|
|
35810
35924
|
function assemblePluginMeta(probe) {
|
|
35811
35925
|
const pkgJson = probe.packageJson || {};
|
|
35812
35926
|
const dir = probe.dir;
|
|
35813
|
-
const meta = dir ? readJsonFile(
|
|
35927
|
+
const meta = dir ? readJsonFile(resolve15(dir, "vesk.meta.json")) : null;
|
|
35814
35928
|
const hasMeta = !!meta && Object.keys(meta).length > 0;
|
|
35815
35929
|
const m = meta || {};
|
|
35816
35930
|
const metaSource = hasMeta ? "vesk.meta.json" : probe.packageJson ? "package.json" : "none";
|
|
@@ -36049,11 +36163,11 @@ function findIconFile(dir, meta) {
|
|
|
36049
36163
|
const explicit = str(meta?.icon);
|
|
36050
36164
|
if (explicit) {
|
|
36051
36165
|
const p = resolveWithin(dir, explicit);
|
|
36052
|
-
if (p &&
|
|
36166
|
+
if (p && existsSync17(p) && statSync8(p).isFile()) return p;
|
|
36053
36167
|
}
|
|
36054
36168
|
for (const name of ["icon.png", "icon.ico"]) {
|
|
36055
|
-
const p =
|
|
36056
|
-
if (
|
|
36169
|
+
const p = resolve15(dir, name);
|
|
36170
|
+
if (existsSync17(p) && statSync8(p).isFile()) return p;
|
|
36057
36171
|
}
|
|
36058
36172
|
return null;
|
|
36059
36173
|
}
|
|
@@ -36061,7 +36175,7 @@ function findPluginIcon(appDir, name) {
|
|
|
36061
36175
|
const probe = resolvePackage(appDir, name);
|
|
36062
36176
|
const dir = probe.dir;
|
|
36063
36177
|
if (!dir) return null;
|
|
36064
|
-
const meta = readJsonFile(
|
|
36178
|
+
const meta = readJsonFile(resolve15(dir, "vesk.meta.json"));
|
|
36065
36179
|
const iconPath = findIconFile(dir, meta);
|
|
36066
36180
|
if (!iconPath) return null;
|
|
36067
36181
|
const ext = extname4(iconPath).toLowerCase();
|
|
@@ -36124,7 +36238,7 @@ function resolveDtsPath(probe, pkgJson) {
|
|
|
36124
36238
|
for (const rel of candidates) {
|
|
36125
36239
|
if (!rel) continue;
|
|
36126
36240
|
const abs = resolveWithin(dir, rel);
|
|
36127
|
-
if (abs &&
|
|
36241
|
+
if (abs && existsSync17(abs) && statSync8(abs).isFile()) return abs;
|
|
36128
36242
|
}
|
|
36129
36243
|
return null;
|
|
36130
36244
|
}
|
|
@@ -36440,7 +36554,7 @@ function introspectPlugin(appDir, name) {
|
|
|
36440
36554
|
const pkgName = str(pkgJson.name) ?? name;
|
|
36441
36555
|
const exportsMap = flattenPackageExports(pkgJson.exports);
|
|
36442
36556
|
const dtsPath = resolveDtsPath(probe, pkgJson);
|
|
36443
|
-
const dtsExports = dtsPath ? parseDtsExports(
|
|
36557
|
+
const dtsExports = dtsPath ? parseDtsExports(readFileSync17(dtsPath, "utf-8")) : [];
|
|
36444
36558
|
return {
|
|
36445
36559
|
ok: true,
|
|
36446
36560
|
name: pkgName,
|
|
@@ -36581,24 +36695,24 @@ __export(static_exports, {
|
|
|
36581
36695
|
generateSitemap: () => generateSitemap,
|
|
36582
36696
|
generateSsgRoutes: () => generateSsgRoutes
|
|
36583
36697
|
});
|
|
36584
|
-
import { mkdirSync as
|
|
36585
|
-
import { resolve as
|
|
36698
|
+
import { mkdirSync as mkdirSync8, copyFileSync as copyFileSync3, readdirSync as readdirSync4, statSync as statSync9, existsSync as existsSync18, writeFileSync as writeFileSync9, readFileSync as readFileSync18 } from "node:fs";
|
|
36699
|
+
import { resolve as resolve16, join as join12 } from "node:path";
|
|
36586
36700
|
function copyStaticAssets2(publicDir, outDir) {
|
|
36587
|
-
const targetDir =
|
|
36588
|
-
|
|
36589
|
-
if (!
|
|
36701
|
+
const targetDir = resolve16(outDir, "static", "public");
|
|
36702
|
+
mkdirSync8(targetDir, { recursive: true });
|
|
36703
|
+
if (!existsSync18(publicDir))
|
|
36590
36704
|
return;
|
|
36591
36705
|
function copyDir(src2, dest) {
|
|
36592
|
-
|
|
36593
|
-
const entries =
|
|
36706
|
+
mkdirSync8(dest, { recursive: true });
|
|
36707
|
+
const entries = readdirSync4(src2);
|
|
36594
36708
|
for (const entry of entries) {
|
|
36595
|
-
const srcPath =
|
|
36596
|
-
const destPath =
|
|
36597
|
-
const st =
|
|
36709
|
+
const srcPath = join12(src2, entry);
|
|
36710
|
+
const destPath = join12(dest, entry);
|
|
36711
|
+
const st = statSync9(srcPath);
|
|
36598
36712
|
if (st.isDirectory()) {
|
|
36599
36713
|
copyDir(srcPath, destPath);
|
|
36600
36714
|
} else {
|
|
36601
|
-
|
|
36715
|
+
copyFileSync3(srcPath, destPath);
|
|
36602
36716
|
}
|
|
36603
36717
|
}
|
|
36604
36718
|
}
|
|
@@ -36606,8 +36720,8 @@ function copyStaticAssets2(publicDir, outDir) {
|
|
|
36606
36720
|
}
|
|
36607
36721
|
async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra, cssUrls) {
|
|
36608
36722
|
const { ssg: ssg2 } = await Promise.resolve().then(() => (init_server_render(), server_render_exports));
|
|
36609
|
-
const prerenderDir =
|
|
36610
|
-
|
|
36723
|
+
const prerenderDir = resolve16(outDir, "prerendered");
|
|
36724
|
+
mkdirSync8(prerenderDir, { recursive: true });
|
|
36611
36725
|
const ssgOptions = { plugins, headExtra, cssUrls };
|
|
36612
36726
|
const results = [];
|
|
36613
36727
|
async function evaluateExport(src2, exportName) {
|
|
@@ -36626,8 +36740,8 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
|
|
|
36626
36740
|
async function walk9(nodes) {
|
|
36627
36741
|
for (const node of nodes) {
|
|
36628
36742
|
if (node.page) {
|
|
36629
|
-
const pagePath =
|
|
36630
|
-
const src2 =
|
|
36743
|
+
const pagePath = resolve16(appDir, node.sourceDir, "page.vsk");
|
|
36744
|
+
const src2 = readFileSync18(pagePath, "utf-8");
|
|
36631
36745
|
const hasStaticProps = src2.includes("getStaticProps");
|
|
36632
36746
|
const hasStaticPaths = src2.includes("getStaticPaths");
|
|
36633
36747
|
if (hasStaticPaths) {
|
|
@@ -36644,8 +36758,8 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
|
|
|
36644
36758
|
console.error(`vesk: SSG path escaped output dir \u2014 skipping ${pagePath} (path: ${urlPath})`);
|
|
36645
36759
|
continue;
|
|
36646
36760
|
}
|
|
36647
|
-
|
|
36648
|
-
|
|
36761
|
+
mkdirSync8(resolve16(htmlPath, ".."), { recursive: true });
|
|
36762
|
+
writeFileSync9(htmlPath, result.html);
|
|
36649
36763
|
results.push({ path: urlPath, html: htmlPath, static: result.static, params });
|
|
36650
36764
|
} catch (e) {
|
|
36651
36765
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -36656,9 +36770,9 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
|
|
|
36656
36770
|
} else if (hasStaticProps) {
|
|
36657
36771
|
try {
|
|
36658
36772
|
const result = await ssg2(src2, null, void 0, ssgOptions);
|
|
36659
|
-
const htmlPath =
|
|
36660
|
-
|
|
36661
|
-
|
|
36773
|
+
const htmlPath = resolve16(prerenderDir, node.fullPath === "/" ? "index.html" : `${node.fullPath.slice(1)}.html`);
|
|
36774
|
+
mkdirSync8(resolve16(htmlPath, ".."), { recursive: true });
|
|
36775
|
+
writeFileSync9(htmlPath, result.html);
|
|
36662
36776
|
results.push({ path: node.fullPath, html: htmlPath, static: result.static });
|
|
36663
36777
|
} catch (e) {
|
|
36664
36778
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -36728,17 +36842,17 @@ __export(image_pipeline_exports, {
|
|
|
36728
36842
|
collectImageRefs: () => collectImageRefs,
|
|
36729
36843
|
optimizeImages: () => optimizeImages
|
|
36730
36844
|
});
|
|
36731
|
-
import { mkdirSync as
|
|
36845
|
+
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync10, readFileSync as readFileSync19, existsSync as existsSync19, readdirSync as readdirSync5, statSync as statSync10 } from "node:fs";
|
|
36732
36846
|
import { spawnSync } from "node:child_process";
|
|
36733
|
-
import { resolve as
|
|
36847
|
+
import { resolve as resolve17, extname as extname5, dirname as dirname13, join as join13 } from "node:path";
|
|
36734
36848
|
import { createRequire as createRequire5 } from "node:module";
|
|
36735
36849
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
36736
36850
|
function probeMemoPath() {
|
|
36737
36851
|
try {
|
|
36738
36852
|
const req = createRequire5(import.meta.url);
|
|
36739
36853
|
const entry = req.resolve("sharp");
|
|
36740
|
-
const stamp = Math.round(
|
|
36741
|
-
return
|
|
36854
|
+
const stamp = Math.round(statSync10(entry).mtimeMs);
|
|
36855
|
+
return join13(tmpdir2(), `vesk-sharp-probe-${process.platform}-${process.arch}-${stamp}.json`);
|
|
36742
36856
|
} catch {
|
|
36743
36857
|
return null;
|
|
36744
36858
|
}
|
|
@@ -36748,7 +36862,7 @@ function readProbeMemo() {
|
|
|
36748
36862
|
if (path === null)
|
|
36749
36863
|
return null;
|
|
36750
36864
|
try {
|
|
36751
|
-
return JSON.parse(
|
|
36865
|
+
return JSON.parse(readFileSync19(path, "utf-8"))?.usable === true;
|
|
36752
36866
|
} catch {
|
|
36753
36867
|
return null;
|
|
36754
36868
|
}
|
|
@@ -36758,7 +36872,7 @@ function writeProbeMemo(usable) {
|
|
|
36758
36872
|
if (path === null)
|
|
36759
36873
|
return;
|
|
36760
36874
|
try {
|
|
36761
|
-
|
|
36875
|
+
writeFileSync10(path, JSON.stringify({ usable, at: Date.now() }), "utf-8");
|
|
36762
36876
|
} catch {
|
|
36763
36877
|
}
|
|
36764
36878
|
}
|
|
@@ -36791,13 +36905,13 @@ async function ensureSharp() {
|
|
|
36791
36905
|
async function processImage(srcPath, outDir, baseName) {
|
|
36792
36906
|
const image = sharpFn ? sharpFn(srcPath) : null;
|
|
36793
36907
|
if (!image) {
|
|
36794
|
-
const original =
|
|
36908
|
+
const original = readFileSync19(srcPath);
|
|
36795
36909
|
const ext = extname5(srcPath);
|
|
36796
36910
|
const written = [];
|
|
36797
36911
|
for (const w of OUTPUT_WIDTHS) {
|
|
36798
|
-
const outputPath =
|
|
36799
|
-
|
|
36800
|
-
|
|
36912
|
+
const outputPath = resolve17(outDir, `${baseName}-${w}w${ext}`);
|
|
36913
|
+
mkdirSync9(dirname13(outputPath), { recursive: true });
|
|
36914
|
+
writeFileSync10(outputPath, original);
|
|
36801
36915
|
written.push(outputPath);
|
|
36802
36916
|
}
|
|
36803
36917
|
return written;
|
|
@@ -36808,19 +36922,19 @@ async function processImage(srcPath, outDir, baseName) {
|
|
|
36808
36922
|
for (const w of OUTPUT_WIDTHS) {
|
|
36809
36923
|
const base = `${baseName}-${w}w`;
|
|
36810
36924
|
if (w >= originalWidth) {
|
|
36811
|
-
const copyPath =
|
|
36812
|
-
|
|
36813
|
-
|
|
36925
|
+
const copyPath = resolve17(outDir, `${base}${extname5(srcPath)}`);
|
|
36926
|
+
mkdirSync9(dirname13(copyPath), { recursive: true });
|
|
36927
|
+
writeFileSync10(copyPath, readFileSync19(srcPath));
|
|
36814
36928
|
generated.push(copyPath);
|
|
36815
36929
|
continue;
|
|
36816
36930
|
}
|
|
36817
36931
|
const resized = image.clone().resize({ width: w, withoutEnlargement: true });
|
|
36818
|
-
const jpgPath =
|
|
36819
|
-
|
|
36932
|
+
const jpgPath = resolve17(outDir, `${base}${extname5(srcPath)}`);
|
|
36933
|
+
mkdirSync9(dirname13(jpgPath), { recursive: true });
|
|
36820
36934
|
await resized.toFile(jpgPath);
|
|
36821
36935
|
generated.push(jpgPath);
|
|
36822
36936
|
for (const fmt of FORMATS) {
|
|
36823
|
-
const fmtPath =
|
|
36937
|
+
const fmtPath = resolve17(outDir, `${base}.${fmt}`);
|
|
36824
36938
|
await resized.toFormat(fmt, { quality: 80 }).toFile(fmtPath);
|
|
36825
36939
|
generated.push(fmtPath);
|
|
36826
36940
|
}
|
|
@@ -36832,19 +36946,19 @@ function collectImageRefs(appDir) {
|
|
|
36832
36946
|
function walk9(dir) {
|
|
36833
36947
|
let entries;
|
|
36834
36948
|
try {
|
|
36835
|
-
entries =
|
|
36949
|
+
entries = readdirSync5(dir);
|
|
36836
36950
|
} catch {
|
|
36837
36951
|
return;
|
|
36838
36952
|
}
|
|
36839
36953
|
for (const entry of entries) {
|
|
36840
|
-
const full =
|
|
36841
|
-
const st =
|
|
36954
|
+
const full = resolve17(dir, entry);
|
|
36955
|
+
const st = statSync10(full);
|
|
36842
36956
|
if (st.isDirectory()) {
|
|
36843
36957
|
if (entry.startsWith("."))
|
|
36844
36958
|
continue;
|
|
36845
36959
|
walk9(full);
|
|
36846
36960
|
} else if (entry.endsWith(".vsk")) {
|
|
36847
|
-
const src2 =
|
|
36961
|
+
const src2 = readFileSync19(full, "utf-8");
|
|
36848
36962
|
const imgRegex = /<Image\s[^>]*src=["']([^"']+)["']/g;
|
|
36849
36963
|
let m;
|
|
36850
36964
|
while ((m = imgRegex.exec(src2)) !== null) {
|
|
@@ -36857,7 +36971,7 @@ function collectImageRefs(appDir) {
|
|
|
36857
36971
|
return refs;
|
|
36858
36972
|
}
|
|
36859
36973
|
async function optimizeImages(appDir, outDir) {
|
|
36860
|
-
|
|
36974
|
+
mkdirSync9(resolve17(outDir, "static", "public"), { recursive: true });
|
|
36861
36975
|
const refs = collectImageRefs(appDir);
|
|
36862
36976
|
if (refs.length === 0) {
|
|
36863
36977
|
console.error("vesk images: no <Image> refs found");
|
|
@@ -36868,14 +36982,14 @@ async function optimizeImages(appDir, outDir) {
|
|
|
36868
36982
|
for (const ref2 of refs) {
|
|
36869
36983
|
const rel = ref2.src.replace(/^\//, "");
|
|
36870
36984
|
const possiblePaths = [
|
|
36871
|
-
|
|
36872
|
-
|
|
36873
|
-
|
|
36874
|
-
|
|
36985
|
+
resolve17(appDir, rel),
|
|
36986
|
+
resolve17(appDir, "..", "public", rel),
|
|
36987
|
+
resolve17(appDir, "..", "src", rel),
|
|
36988
|
+
resolve17(outDir, "static", "public", rel)
|
|
36875
36989
|
];
|
|
36876
36990
|
let srcPath = null;
|
|
36877
36991
|
for (const p of possiblePaths) {
|
|
36878
|
-
if (
|
|
36992
|
+
if (existsSync19(p)) {
|
|
36879
36993
|
srcPath = p;
|
|
36880
36994
|
break;
|
|
36881
36995
|
}
|
|
@@ -36890,8 +37004,8 @@ async function optimizeImages(appDir, outDir) {
|
|
|
36890
37004
|
continue;
|
|
36891
37005
|
}
|
|
36892
37006
|
const baseName = ref2.src.replace(/^\//, "").replace(extname5(ref2.src), "");
|
|
36893
|
-
const imageOutDir =
|
|
36894
|
-
|
|
37007
|
+
const imageOutDir = resolve17(outDir, "static", "public");
|
|
37008
|
+
mkdirSync9(imageOutDir, { recursive: true });
|
|
36895
37009
|
const files = await processImage(srcPath, imageOutDir, baseName);
|
|
36896
37010
|
results.push({ src: ref2.src, baseName, files, widths: OUTPUT_WIDTHS });
|
|
36897
37011
|
console.error(`vesk images: ${ref2.src} \u2192 ${files.length} variants`);
|
|
@@ -36920,19 +37034,19 @@ var seo_audit_exports = {};
|
|
|
36920
37034
|
__export(seo_audit_exports, {
|
|
36921
37035
|
runSeoAudit: () => runSeoAudit
|
|
36922
37036
|
});
|
|
36923
|
-
import { readFileSync as
|
|
36924
|
-
import { resolve as
|
|
37037
|
+
import { readFileSync as readFileSync20, existsSync as existsSync20, readdirSync as readdirSync6, statSync as statSync11 } from "node:fs";
|
|
37038
|
+
import { resolve as resolve18 } from "node:path";
|
|
36925
37039
|
function walkFiles(dir) {
|
|
36926
37040
|
const results = [];
|
|
36927
37041
|
let entries;
|
|
36928
37042
|
try {
|
|
36929
|
-
entries =
|
|
37043
|
+
entries = readdirSync6(dir);
|
|
36930
37044
|
} catch {
|
|
36931
37045
|
return results;
|
|
36932
37046
|
}
|
|
36933
37047
|
for (const entry of entries) {
|
|
36934
|
-
const full =
|
|
36935
|
-
const st =
|
|
37048
|
+
const full = resolve18(dir, entry);
|
|
37049
|
+
const st = statSync11(full);
|
|
36936
37050
|
if (st.isDirectory()) {
|
|
36937
37051
|
if (!entry.startsWith("."))
|
|
36938
37052
|
results.push(...walkFiles(full));
|
|
@@ -36946,10 +37060,10 @@ function collectCombinedSource(appDir) {
|
|
|
36946
37060
|
const pages = files.filter((f) => f.endsWith("/page.vsk") || f.endsWith("\\page.vsk"));
|
|
36947
37061
|
const combined = [];
|
|
36948
37062
|
for (const pagePath of pages) {
|
|
36949
|
-
const dir =
|
|
36950
|
-
const layoutPath =
|
|
36951
|
-
const pageSrc =
|
|
36952
|
-
const layoutSrc =
|
|
37063
|
+
const dir = resolve18(pagePath, "..");
|
|
37064
|
+
const layoutPath = resolve18(dir, "layout.vsk");
|
|
37065
|
+
const pageSrc = readFileSync20(pagePath, "utf-8");
|
|
37066
|
+
const layoutSrc = existsSync20(layoutPath) ? readFileSync20(layoutPath, "utf-8") : "";
|
|
36953
37067
|
const combinedSrc = layoutSrc ? layoutSrc + "\n" + pageSrc : pageSrc;
|
|
36954
37068
|
combined.push({
|
|
36955
37069
|
path: pagePath,
|
|
@@ -37144,8 +37258,8 @@ var init_platform = __esm({
|
|
|
37144
37258
|
});
|
|
37145
37259
|
|
|
37146
37260
|
// ../adapter/src/platform-handler.ts
|
|
37147
|
-
import { existsSync as
|
|
37148
|
-
import { resolve as
|
|
37261
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
37262
|
+
import { resolve as resolve19, dirname as dirname14, join as join14 } from "node:path";
|
|
37149
37263
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
37150
37264
|
function routeName2(segments) {
|
|
37151
37265
|
const parts = segments.filter(Boolean).map((s) => {
|
|
@@ -37163,13 +37277,13 @@ function toId(s) {
|
|
|
37163
37277
|
}
|
|
37164
37278
|
function findCompilerSrc2(appDir) {
|
|
37165
37279
|
const candidates = [
|
|
37166
|
-
|
|
37167
|
-
|
|
37168
|
-
|
|
37280
|
+
resolve19(__dirname5, "..", "..", "..", "packages", "compiler", "dist"),
|
|
37281
|
+
resolve19(appDir, "..", "node_modules", "@vesk/compiler"),
|
|
37282
|
+
resolve19(appDir, "node_modules", "@vesk/compiler")
|
|
37169
37283
|
];
|
|
37170
37284
|
for (const base of candidates) {
|
|
37171
|
-
for (const dir of [base,
|
|
37172
|
-
if (
|
|
37285
|
+
for (const dir of [base, join14(base, "dist")]) {
|
|
37286
|
+
if (existsSync21(join14(dir, "server-cookies.js"))) return dir;
|
|
37173
37287
|
}
|
|
37174
37288
|
}
|
|
37175
37289
|
throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
|
|
@@ -37209,7 +37323,7 @@ function generatePlatformHandlerSource(input) {
|
|
|
37209
37323
|
const eventsRequestLine = hasEvents ? " await __eventsRequest(mwCtx);" : "";
|
|
37210
37324
|
const localsSeed = hasEvents ? "Object.assign({}, __serverStore)" : "{}";
|
|
37211
37325
|
const compilerSrc = findCompilerSrc2(appDir);
|
|
37212
|
-
const parseCookiesImport = hasMiddleware ? `import { parseCookies } from ${JSON.stringify(
|
|
37326
|
+
const parseCookiesImport = hasMiddleware ? `import { parseCookies } from ${JSON.stringify(resolve19(compilerSrc, "server-cookies.js"))};` : "";
|
|
37213
37327
|
return `
|
|
37214
37328
|
${imports}
|
|
37215
37329
|
${parseCookiesImport}
|
|
@@ -37459,121 +37573,7 @@ var init_platform_handler = __esm({
|
|
|
37459
37573
|
"../adapter/src/platform-handler.ts"() {
|
|
37460
37574
|
"use strict";
|
|
37461
37575
|
init_default_pages();
|
|
37462
|
-
__dirname5 =
|
|
37463
|
-
}
|
|
37464
|
-
});
|
|
37465
|
-
|
|
37466
|
-
// ../adapter/src/platform-output.ts
|
|
37467
|
-
import {
|
|
37468
|
-
mkdirSync as mkdirSync9,
|
|
37469
|
-
copyFileSync as copyFileSync3,
|
|
37470
|
-
readdirSync as readdirSync6,
|
|
37471
|
-
statSync as statSync11,
|
|
37472
|
-
existsSync as existsSync21,
|
|
37473
|
-
writeFileSync as writeFileSync10,
|
|
37474
|
-
rmSync as rmSync2,
|
|
37475
|
-
readFileSync as readFileSync20
|
|
37476
|
-
} from "node:fs";
|
|
37477
|
-
import { resolve as resolve19, join as join14, extname as extname6, dirname as dirname14 } from "node:path";
|
|
37478
|
-
function ensureCleanDir(dir) {
|
|
37479
|
-
rmSync2(dir, { recursive: true, force: true });
|
|
37480
|
-
mkdirSync9(dir, { recursive: true });
|
|
37481
|
-
}
|
|
37482
|
-
function copyDirContents(srcDir, destDir) {
|
|
37483
|
-
if (!existsSync21(srcDir)) return;
|
|
37484
|
-
mkdirSync9(destDir, { recursive: true });
|
|
37485
|
-
for (const entry of readdirSync6(srcDir)) {
|
|
37486
|
-
const srcPath = join14(srcDir, entry);
|
|
37487
|
-
const destPath = join14(destDir, entry);
|
|
37488
|
-
if (statSync11(srcPath).isDirectory()) {
|
|
37489
|
-
copyDirContents(srcPath, destPath);
|
|
37490
|
-
} else {
|
|
37491
|
-
mkdirSync9(dirname14(destPath), { recursive: true });
|
|
37492
|
-
copyFileSync3(srcPath, destPath);
|
|
37493
|
-
}
|
|
37494
|
-
}
|
|
37495
|
-
}
|
|
37496
|
-
function writeFile(path, content) {
|
|
37497
|
-
mkdirSync9(dirname14(path), { recursive: true });
|
|
37498
|
-
writeFileSync10(path, content, "utf-8");
|
|
37499
|
-
}
|
|
37500
|
-
function writePlatformStatic(buildStaticDir, platformStaticDir) {
|
|
37501
|
-
mkdirSync9(platformStaticDir, { recursive: true });
|
|
37502
|
-
const publicDir = resolve19(buildStaticDir, "public");
|
|
37503
|
-
if (existsSync21(publicDir)) {
|
|
37504
|
-
copyDirContents(publicDir, platformStaticDir);
|
|
37505
|
-
}
|
|
37506
|
-
const assetsDir = resolve19(platformStaticDir, "_vesk", "static");
|
|
37507
|
-
copyDirContents(buildStaticDir, assetsDir);
|
|
37508
|
-
const runtimeAlias = resolve19(platformStaticDir, "_vesk", "runtime.js");
|
|
37509
|
-
const clientPath = resolve19(buildStaticDir, "client.js");
|
|
37510
|
-
if (existsSync21(clientPath)) {
|
|
37511
|
-
mkdirSync9(dirname14(runtimeAlias), { recursive: true });
|
|
37512
|
-
copyFileSync3(clientPath, runtimeAlias);
|
|
37513
|
-
}
|
|
37514
|
-
}
|
|
37515
|
-
function writePrerenderedStatic(prerenderedRoutes, platformStaticDir) {
|
|
37516
|
-
for (const route of prerenderedRoutes) {
|
|
37517
|
-
if (!existsSync21(route.html)) continue;
|
|
37518
|
-
const content = readFileSync20(route.html);
|
|
37519
|
-
const htmlRel = route.path === "/" ? "index.html" : `${route.path.replace(/^\//, "")}.html`;
|
|
37520
|
-
const target = resolve19(platformStaticDir, "_vesk", "static", "public", htmlRel);
|
|
37521
|
-
writeFile(target, content);
|
|
37522
|
-
if (route.path !== "/" && route.path.endsWith("/")) {
|
|
37523
|
-
const dirIndex = resolve19(platformStaticDir, "_vesk", "static", "public", `${route.path.replace(/^\//, "")}index.html`);
|
|
37524
|
-
writeFile(dirIndex, content);
|
|
37525
|
-
}
|
|
37526
|
-
}
|
|
37527
|
-
}
|
|
37528
|
-
function listStaticDir(dir) {
|
|
37529
|
-
const out = [];
|
|
37530
|
-
if (!existsSync21(dir)) return out;
|
|
37531
|
-
function walk9(d, prefix) {
|
|
37532
|
-
for (const entry of readdirSync6(d)) {
|
|
37533
|
-
const full = join14(d, entry);
|
|
37534
|
-
const rel = prefix ? `${prefix}/${entry}` : entry;
|
|
37535
|
-
if (statSync11(full).isDirectory()) {
|
|
37536
|
-
walk9(full, rel);
|
|
37537
|
-
} else {
|
|
37538
|
-
out.push({ rel, buffer: readFileSync20(full) });
|
|
37539
|
-
}
|
|
37540
|
-
}
|
|
37541
|
-
}
|
|
37542
|
-
walk9(dir, "");
|
|
37543
|
-
return out;
|
|
37544
|
-
}
|
|
37545
|
-
function mimeFor(path) {
|
|
37546
|
-
return MIME2[extname6(path).toLowerCase()] || "application/octet-stream";
|
|
37547
|
-
}
|
|
37548
|
-
var MIME2;
|
|
37549
|
-
var init_platform_output = __esm({
|
|
37550
|
-
"../adapter/src/platform-output.ts"() {
|
|
37551
|
-
"use strict";
|
|
37552
|
-
MIME2 = {
|
|
37553
|
-
".html": "text/html; charset=utf-8",
|
|
37554
|
-
".htm": "text/html; charset=utf-8",
|
|
37555
|
-
".js": "application/javascript; charset=utf-8",
|
|
37556
|
-
".mjs": "application/javascript; charset=utf-8",
|
|
37557
|
-
".css": "text/css; charset=utf-8",
|
|
37558
|
-
".json": "application/json; charset=utf-8",
|
|
37559
|
-
".svg": "image/svg+xml",
|
|
37560
|
-
".png": "image/png",
|
|
37561
|
-
".jpg": "image/jpeg",
|
|
37562
|
-
".jpeg": "image/jpeg",
|
|
37563
|
-
".gif": "image/gif",
|
|
37564
|
-
".webp": "image/webp",
|
|
37565
|
-
".avif": "image/avif",
|
|
37566
|
-
".ico": "image/x-icon",
|
|
37567
|
-
".txt": "text/plain; charset=utf-8",
|
|
37568
|
-
".xml": "application/xml",
|
|
37569
|
-
".woff": "font/woff",
|
|
37570
|
-
".woff2": "font/woff2",
|
|
37571
|
-
".ttf": "font/ttf",
|
|
37572
|
-
".otf": "font/otf",
|
|
37573
|
-
".wasm": "application/wasm",
|
|
37574
|
-
".map": "application/json",
|
|
37575
|
-
".webmanifest": "application/manifest+json"
|
|
37576
|
-
};
|
|
37576
|
+
__dirname5 = dirname14(fileURLToPath4(import.meta.url));
|
|
37577
37577
|
}
|
|
37578
37578
|
});
|
|
37579
37579
|
|
|
@@ -48829,7 +48829,7 @@ __export(migrate_exports, {
|
|
|
48829
48829
|
runMigrate: () => runMigrate
|
|
48830
48830
|
});
|
|
48831
48831
|
import { readFileSync as readFileSync41, writeFileSync as writeFileSync22, existsSync as existsSync44, statSync as statSync23, readdirSync as readdirSync15 } from "node:fs";
|
|
48832
|
-
import { join as join29, relative as relative9, extname as
|
|
48832
|
+
import { join as join29, relative as relative9, extname as extname8 } from "node:path";
|
|
48833
48833
|
function detectInstalledVersion(projectDir, cliVersion) {
|
|
48834
48834
|
for (const pkg of ["@vesk/vesk-cli", "@vesk/adapter", "@vesk/compiler"]) {
|
|
48835
48835
|
const p = join29(projectDir, "node_modules", pkg, "package.json");
|
|
@@ -48861,7 +48861,7 @@ function collectTargets(dir, root3 = dir) {
|
|
|
48861
48861
|
}
|
|
48862
48862
|
if (st.isDirectory()) {
|
|
48863
48863
|
out.push(...collectTargets(full, root3));
|
|
48864
|
-
} else if (SCAN_EXTENSIONS.has(
|
|
48864
|
+
} else if (SCAN_EXTENSIONS.has(extname8(entry))) {
|
|
48865
48865
|
out.push(relative9(root3, full));
|
|
48866
48866
|
}
|
|
48867
48867
|
}
|
|
@@ -52273,8 +52273,8 @@ function copyStaticAssets(publicDir, outDir) {
|
|
|
52273
52273
|
}
|
|
52274
52274
|
|
|
52275
52275
|
// ../adapter/src/prod-server.ts
|
|
52276
|
-
import { readFileSync as
|
|
52277
|
-
import { resolve as
|
|
52276
|
+
import { readFileSync as readFileSync16, existsSync as existsSync16, statSync as statSync7 } from "node:fs";
|
|
52277
|
+
import { resolve as resolve14, dirname as dirname11, basename } from "node:path";
|
|
52278
52278
|
import { createServer } from "node:http";
|
|
52279
52279
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
52280
52280
|
init_server_utils();
|
|
@@ -52379,12 +52379,327 @@ async function loadVeskConfig2(projectDir) {
|
|
|
52379
52379
|
|
|
52380
52380
|
// ../adapter/src/prod-server.ts
|
|
52381
52381
|
init_default_pages();
|
|
52382
|
-
|
|
52382
|
+
|
|
52383
|
+
// ../adapter/src/response-pipeline.ts
|
|
52384
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
52385
|
+
import {
|
|
52386
|
+
brotliCompress,
|
|
52387
|
+
constants as zlibConstants,
|
|
52388
|
+
createBrotliCompress,
|
|
52389
|
+
createGzip,
|
|
52390
|
+
gzip
|
|
52391
|
+
} from "node:zlib";
|
|
52392
|
+
import { promisify } from "node:util";
|
|
52393
|
+
var brotliCompressAsync = promisify(brotliCompress);
|
|
52394
|
+
var gzipAsync = promisify(gzip);
|
|
52395
|
+
function negotiateEncoding(header) {
|
|
52396
|
+
if (!header) return null;
|
|
52397
|
+
const value = Array.isArray(header) ? header.join(",") : header;
|
|
52398
|
+
const q = {};
|
|
52399
|
+
for (const part of value.split(",")) {
|
|
52400
|
+
const seg = part.trim();
|
|
52401
|
+
if (!seg) continue;
|
|
52402
|
+
const semi = seg.indexOf(";");
|
|
52403
|
+
const token = (semi === -1 ? seg : seg.slice(0, semi)).trim().toLowerCase();
|
|
52404
|
+
if (!token) continue;
|
|
52405
|
+
let weight = 1;
|
|
52406
|
+
if (semi !== -1) {
|
|
52407
|
+
for (const param of seg.slice(semi + 1).split(";")) {
|
|
52408
|
+
const eq = param.indexOf("=");
|
|
52409
|
+
if (eq === -1) continue;
|
|
52410
|
+
if (param.slice(0, eq).trim().toLowerCase() !== "q") continue;
|
|
52411
|
+
const parsed = Number.parseFloat(param.slice(eq + 1).trim());
|
|
52412
|
+
if (Number.isFinite(parsed)) weight = parsed;
|
|
52413
|
+
}
|
|
52414
|
+
}
|
|
52415
|
+
if (!(token in q)) q[token] = weight;
|
|
52416
|
+
}
|
|
52417
|
+
const star = q["*"];
|
|
52418
|
+
const br = q["br"] !== void 0 ? q["br"] : star;
|
|
52419
|
+
const gz = q["gzip"] !== void 0 ? q["gzip"] : star;
|
|
52420
|
+
if (br !== void 0 && br > 0 && (gz === void 0 || gz <= 0 || br >= gz)) return "br";
|
|
52421
|
+
if (gz !== void 0 && gz > 0) return "gzip";
|
|
52422
|
+
return null;
|
|
52423
|
+
}
|
|
52424
|
+
function isCompressibleType(contentType) {
|
|
52425
|
+
if (!contentType) return false;
|
|
52426
|
+
const type = (contentType.split(";")[0] || "").trim().toLowerCase();
|
|
52427
|
+
if (!type) return false;
|
|
52428
|
+
if (type.startsWith("text/")) return true;
|
|
52429
|
+
if (type === "image/svg+xml" || type === "image/x-icon" || type === "image/bmp") return true;
|
|
52430
|
+
if (type.endsWith("+json") || type.endsWith("+xml")) return true;
|
|
52431
|
+
switch (type) {
|
|
52432
|
+
case "application/javascript":
|
|
52433
|
+
case "application/x-javascript":
|
|
52434
|
+
case "application/ecmascript":
|
|
52435
|
+
case "application/json":
|
|
52436
|
+
case "application/manifest+json":
|
|
52437
|
+
case "application/ld+json":
|
|
52438
|
+
case "application/graphql":
|
|
52439
|
+
case "application/x-ndjson":
|
|
52440
|
+
case "application/xml":
|
|
52441
|
+
case "application/xhtml+xml":
|
|
52442
|
+
case "application/rss+xml":
|
|
52443
|
+
case "application/atom+xml":
|
|
52444
|
+
return true;
|
|
52445
|
+
default:
|
|
52446
|
+
return false;
|
|
52447
|
+
}
|
|
52448
|
+
}
|
|
52449
|
+
function etagFor(body) {
|
|
52450
|
+
return `"${createHash2("sha1").update(body).digest("base64").slice(0, 27)}"`;
|
|
52451
|
+
}
|
|
52452
|
+
function ifNoneMatchSatisfied(header, etag) {
|
|
52453
|
+
if (!header) return false;
|
|
52454
|
+
const value = Array.isArray(header) ? header.join(",") : header;
|
|
52455
|
+
const candidates = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
52456
|
+
if (candidates.includes("*")) return true;
|
|
52457
|
+
const strip = (s) => (s.startsWith("W/") ? s.slice(2) : s).trim();
|
|
52458
|
+
const target = strip(etag);
|
|
52459
|
+
for (const candidate of candidates) {
|
|
52460
|
+
if (strip(candidate) === target) return true;
|
|
52461
|
+
}
|
|
52462
|
+
return false;
|
|
52463
|
+
}
|
|
52464
|
+
function getHeader(headers2, name) {
|
|
52465
|
+
const wanted = name.toLowerCase();
|
|
52466
|
+
for (const key of Object.keys(headers2)) {
|
|
52467
|
+
if (key.toLowerCase() === wanted) {
|
|
52468
|
+
const v = headers2[key];
|
|
52469
|
+
if (v === void 0) return void 0;
|
|
52470
|
+
return Array.isArray(v) ? v.join(", ") : String(v);
|
|
52471
|
+
}
|
|
52472
|
+
}
|
|
52473
|
+
return void 0;
|
|
52474
|
+
}
|
|
52475
|
+
function hasNoStore(cacheControl) {
|
|
52476
|
+
if (!cacheControl) return false;
|
|
52477
|
+
return cacheControl.split(",").some((part) => part.trim().toLowerCase() === "no-store");
|
|
52478
|
+
}
|
|
52479
|
+
function withVary(current3, value) {
|
|
52480
|
+
if (!current3) return value;
|
|
52481
|
+
const existing2 = current3.split(",").map((s) => s.trim().toLowerCase());
|
|
52482
|
+
if (existing2.includes(value.toLowerCase())) return current3;
|
|
52483
|
+
if (existing2.includes("*")) return current3;
|
|
52484
|
+
return `${current3}, ${value}`;
|
|
52485
|
+
}
|
|
52486
|
+
function installResponsePipeline(res, req, options = {}) {
|
|
52487
|
+
const compressEnabled = options.compress !== false;
|
|
52488
|
+
const etagEnabled = options.etag !== false;
|
|
52489
|
+
const threshold = options.compressThreshold ?? 1024;
|
|
52490
|
+
const brotliQuality = options.brotliQuality ?? 5;
|
|
52491
|
+
const gzipLevel = options.gzipLevel ?? 6;
|
|
52492
|
+
const realWriteHead = res.writeHead.bind(res);
|
|
52493
|
+
const realWrite = res.write.bind(res);
|
|
52494
|
+
const realEnd = res.end.bind(res);
|
|
52495
|
+
const realFlushHeaders = res.flushHeaders.bind(res);
|
|
52496
|
+
let pendingStatus = 200;
|
|
52497
|
+
let pendingHeaders = {};
|
|
52498
|
+
let flushed = false;
|
|
52499
|
+
let streaming = false;
|
|
52500
|
+
let streamCompressor = null;
|
|
52501
|
+
function flush(extra) {
|
|
52502
|
+
if (flushed) return;
|
|
52503
|
+
flushed = true;
|
|
52504
|
+
const headers2 = {};
|
|
52505
|
+
for (const [key, value] of Object.entries(pendingHeaders)) {
|
|
52506
|
+
if (value !== void 0) headers2[key] = value;
|
|
52507
|
+
}
|
|
52508
|
+
for (const [key, value] of Object.entries(extra || {})) {
|
|
52509
|
+
if (value === void 0) delete headers2[key];
|
|
52510
|
+
else headers2[key] = value;
|
|
52511
|
+
}
|
|
52512
|
+
realWriteHead(pendingStatus, headers2);
|
|
52513
|
+
}
|
|
52514
|
+
res.writeHead = ((statusCode, headers2) => {
|
|
52515
|
+
if (flushed || streaming) return realWriteHead(statusCode, headers2);
|
|
52516
|
+
pendingStatus = statusCode;
|
|
52517
|
+
pendingHeaders = { ...headers2 || {} };
|
|
52518
|
+
return res;
|
|
52519
|
+
});
|
|
52520
|
+
function encodingIsVariable() {
|
|
52521
|
+
return compressEnabled && !getHeader(pendingHeaders, "content-encoding") && isCompressibleType(getHeader(pendingHeaders, "content-type"));
|
|
52522
|
+
}
|
|
52523
|
+
function startStreamCompression(encoding) {
|
|
52524
|
+
const compressor = encoding === "br" ? createBrotliCompress({ params: { [zlibConstants.BROTLI_PARAM_QUALITY]: brotliQuality } }) : createGzip({ level: gzipLevel });
|
|
52525
|
+
compressor.on("data", (chunk) => {
|
|
52526
|
+
realWrite(chunk);
|
|
52527
|
+
});
|
|
52528
|
+
compressor.on("end", () => {
|
|
52529
|
+
realEnd();
|
|
52530
|
+
});
|
|
52531
|
+
compressor.on("error", () => {
|
|
52532
|
+
try {
|
|
52533
|
+
realEnd();
|
|
52534
|
+
} catch {
|
|
52535
|
+
}
|
|
52536
|
+
});
|
|
52537
|
+
streamCompressor = compressor;
|
|
52538
|
+
}
|
|
52539
|
+
res.write = ((chunk, encoding) => {
|
|
52540
|
+
if (!flushed && !streaming) {
|
|
52541
|
+
streaming = true;
|
|
52542
|
+
const vary = withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding");
|
|
52543
|
+
const encodingChosen = encodingIsVariable() ? negotiateEncoding(req.headers["accept-encoding"]) : null;
|
|
52544
|
+
if (encodingChosen) {
|
|
52545
|
+
startStreamCompression(encodingChosen);
|
|
52546
|
+
flush({ "Content-Encoding": encodingChosen, Vary: vary, "Content-Length": void 0 });
|
|
52547
|
+
} else {
|
|
52548
|
+
flush({ Vary: encodingIsVariable() ? vary : void 0 });
|
|
52549
|
+
}
|
|
52550
|
+
}
|
|
52551
|
+
if (streamCompressor) {
|
|
52552
|
+
streamCompressor.write(toBuffer(chunk, encoding) || Buffer.alloc(0));
|
|
52553
|
+
return true;
|
|
52554
|
+
}
|
|
52555
|
+
return typeof encoding === "undefined" ? realWrite(chunk) : realWrite(chunk, encoding);
|
|
52556
|
+
});
|
|
52557
|
+
res.flushHeaders = (() => {
|
|
52558
|
+
if (!flushed) {
|
|
52559
|
+
streaming = true;
|
|
52560
|
+
flush();
|
|
52561
|
+
}
|
|
52562
|
+
realFlushHeaders.call(res);
|
|
52563
|
+
});
|
|
52564
|
+
function toBuffer(chunk, encoding) {
|
|
52565
|
+
if (chunk === void 0 || chunk === null) return null;
|
|
52566
|
+
if (Buffer.isBuffer(chunk)) return chunk;
|
|
52567
|
+
if (typeof chunk === "string") {
|
|
52568
|
+
return Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
|
|
52569
|
+
}
|
|
52570
|
+
if (chunk instanceof Uint8Array) return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
52571
|
+
return null;
|
|
52572
|
+
}
|
|
52573
|
+
function finish(body, endArgs) {
|
|
52574
|
+
const method = (req.method || "GET").toUpperCase();
|
|
52575
|
+
if (!body || body.length === 0 || streaming || flushed) {
|
|
52576
|
+
flush();
|
|
52577
|
+
realEnd(...endArgs);
|
|
52578
|
+
return;
|
|
52579
|
+
}
|
|
52580
|
+
const cacheable = method === "GET" || method === "HEAD";
|
|
52581
|
+
const existingEtag = getHeader(pendingHeaders, "etag");
|
|
52582
|
+
const canValidate = cacheable && pendingStatus === 200 && !hasNoStore(getHeader(pendingHeaders, "cache-control"));
|
|
52583
|
+
if (!canValidate) {
|
|
52584
|
+
maybeCompress(body, endArgs);
|
|
52585
|
+
return;
|
|
52586
|
+
}
|
|
52587
|
+
const etag = existingEtag || (etagEnabled ? etagFor(body) : void 0);
|
|
52588
|
+
if (etag && ifNoneMatchSatisfied(req.headers["if-none-match"], etag)) {
|
|
52589
|
+
const headers304 = { ETag: etag };
|
|
52590
|
+
const cc = getHeader(pendingHeaders, "cache-control");
|
|
52591
|
+
if (cc) headers304["Cache-Control"] = cc;
|
|
52592
|
+
headers304.Vary = withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding");
|
|
52593
|
+
flushed = true;
|
|
52594
|
+
realWriteHead(304, headers304);
|
|
52595
|
+
realEnd();
|
|
52596
|
+
return;
|
|
52597
|
+
}
|
|
52598
|
+
if (etag && !existingEtag) {
|
|
52599
|
+
pendingHeaders = { ...pendingHeaders, ETag: etag };
|
|
52600
|
+
}
|
|
52601
|
+
maybeCompress(body, endArgs);
|
|
52602
|
+
}
|
|
52603
|
+
function maybeCompress(body, endArgs) {
|
|
52604
|
+
if (compressEnabled && body.length < threshold || !encodingIsVariable()) {
|
|
52605
|
+
flush();
|
|
52606
|
+
realEnd(...endArgs);
|
|
52607
|
+
return;
|
|
52608
|
+
}
|
|
52609
|
+
const encoding = negotiateEncoding(req.headers["accept-encoding"]);
|
|
52610
|
+
if (!encoding) {
|
|
52611
|
+
flush({ Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding") });
|
|
52612
|
+
realEnd(...endArgs);
|
|
52613
|
+
return;
|
|
52614
|
+
}
|
|
52615
|
+
const compress = encoding === "br" ? brotliCompressAsync : gzipAsync;
|
|
52616
|
+
const params = encoding === "br" ? { params: { [zlibConstants.BROTLI_PARAM_QUALITY]: brotliQuality } } : { level: gzipLevel };
|
|
52617
|
+
void Promise.resolve().then(() => compress(body, params)).then((encoded) => {
|
|
52618
|
+
if (flushed || streaming) {
|
|
52619
|
+
flush();
|
|
52620
|
+
realEnd(...endArgs);
|
|
52621
|
+
return;
|
|
52622
|
+
}
|
|
52623
|
+
if (encoded.length >= body.length) {
|
|
52624
|
+
flush({ Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding") });
|
|
52625
|
+
realEnd(...endArgs);
|
|
52626
|
+
return;
|
|
52627
|
+
}
|
|
52628
|
+
flush({
|
|
52629
|
+
"Content-Encoding": encoding,
|
|
52630
|
+
Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding"),
|
|
52631
|
+
"Content-Length": String(encoded.length)
|
|
52632
|
+
});
|
|
52633
|
+
realEnd(encoded);
|
|
52634
|
+
}).catch(() => {
|
|
52635
|
+
flush({ Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding") });
|
|
52636
|
+
realEnd(...endArgs);
|
|
52637
|
+
});
|
|
52638
|
+
}
|
|
52639
|
+
res.end = ((chunk, encoding, callback) => {
|
|
52640
|
+
if (streamCompressor) {
|
|
52641
|
+
if (typeof callback === "function") res.once("finish", callback);
|
|
52642
|
+
const tail = toBuffer(chunk, encoding);
|
|
52643
|
+
if (tail) streamCompressor.end(tail);
|
|
52644
|
+
else streamCompressor.end();
|
|
52645
|
+
return res;
|
|
52646
|
+
}
|
|
52647
|
+
if (streaming || flushed) {
|
|
52648
|
+
return realEnd(chunk, encoding, callback);
|
|
52649
|
+
}
|
|
52650
|
+
const endArgs = chunk === void 0 ? callback === void 0 ? [] : [callback] : encoding === void 0 ? callback === void 0 ? [chunk] : [chunk, callback] : callback === void 0 ? [chunk, encoding] : [chunk, encoding, callback];
|
|
52651
|
+
const body = toBuffer(chunk, encoding);
|
|
52652
|
+
finish(body, endArgs);
|
|
52653
|
+
return res;
|
|
52654
|
+
});
|
|
52655
|
+
}
|
|
52656
|
+
|
|
52657
|
+
// ../adapter/src/prod-server.ts
|
|
52658
|
+
init_platform_output();
|
|
52659
|
+
var __dirname4 = dirname11(fileURLToPath3(import.meta.url));
|
|
52660
|
+
var STREAMING_TYPES = /* @__PURE__ */ new Set(["text/event-stream", "application/x-ndjson"]);
|
|
52661
|
+
var DELIVER_BUFFER_LIMIT = 1024 * 1024;
|
|
52383
52662
|
async function deliverResponse(res, response) {
|
|
52384
|
-
|
|
52663
|
+
const headers2 = Object.fromEntries(response.headers);
|
|
52385
52664
|
const body = response.body;
|
|
52386
|
-
if (body
|
|
52387
|
-
|
|
52665
|
+
if (!body || typeof body.getReader !== "function") {
|
|
52666
|
+
res.writeHead(response.status, headers2);
|
|
52667
|
+
res.end(await response.text());
|
|
52668
|
+
return;
|
|
52669
|
+
}
|
|
52670
|
+
const contentType = String(response.headers.get("content-type") || "").split(";")[0].trim().toLowerCase();
|
|
52671
|
+
const reader = body.getReader();
|
|
52672
|
+
if (STREAMING_TYPES.has(contentType)) {
|
|
52673
|
+
res.writeHead(response.status, headers2);
|
|
52674
|
+
pumpRemaining(res, reader);
|
|
52675
|
+
return;
|
|
52676
|
+
}
|
|
52677
|
+
const chunks = [];
|
|
52678
|
+
let size = 0;
|
|
52679
|
+
let overflow = false;
|
|
52680
|
+
try {
|
|
52681
|
+
for (; ; ) {
|
|
52682
|
+
const { done, value } = await reader.read();
|
|
52683
|
+
if (done) break;
|
|
52684
|
+
chunks.push(Buffer.from(value));
|
|
52685
|
+
size += value.byteLength;
|
|
52686
|
+
if (size > DELIVER_BUFFER_LIMIT) {
|
|
52687
|
+
overflow = true;
|
|
52688
|
+
break;
|
|
52689
|
+
}
|
|
52690
|
+
}
|
|
52691
|
+
} catch {
|
|
52692
|
+
}
|
|
52693
|
+
res.writeHead(response.status, headers2);
|
|
52694
|
+
if (overflow) {
|
|
52695
|
+
for (const chunk of chunks) res.write(chunk);
|
|
52696
|
+
pumpRemaining(res, reader);
|
|
52697
|
+
return;
|
|
52698
|
+
}
|
|
52699
|
+
res.end(Buffer.concat(chunks));
|
|
52700
|
+
}
|
|
52701
|
+
function pumpRemaining(res, reader) {
|
|
52702
|
+
void (async () => {
|
|
52388
52703
|
try {
|
|
52389
52704
|
for (; ; ) {
|
|
52390
52705
|
const { done, value } = await reader.read();
|
|
@@ -52394,9 +52709,7 @@ async function deliverResponse(res, response) {
|
|
|
52394
52709
|
} catch {
|
|
52395
52710
|
}
|
|
52396
52711
|
res.end();
|
|
52397
|
-
|
|
52398
|
-
}
|
|
52399
|
-
res.end(await response.text());
|
|
52712
|
+
})();
|
|
52400
52713
|
}
|
|
52401
52714
|
function bodyTooLarge(maxBytes) {
|
|
52402
52715
|
const err = new Error(`Request body exceeds limit (${maxBytes} bytes)`);
|
|
@@ -52457,49 +52770,42 @@ function makeWebRequest(nodeReq, url, maxBodyBytes = DEFAULT_MAX_BODY_BYTES) {
|
|
|
52457
52770
|
webRequest.query = query;
|
|
52458
52771
|
return webRequest;
|
|
52459
52772
|
}
|
|
52460
|
-
var MIME = {
|
|
52461
|
-
".svg": "image/svg+xml",
|
|
52462
|
-
".css": "text/css",
|
|
52463
|
-
".js": "application/javascript",
|
|
52464
|
-
".png": "image/png",
|
|
52465
|
-
".jpg": "image/jpeg",
|
|
52466
|
-
".jpeg": "image/jpeg",
|
|
52467
|
-
".ico": "image/x-icon",
|
|
52468
|
-
".html": "text/html",
|
|
52469
|
-
".json": "application/json",
|
|
52470
|
-
".webmanifest": "application/manifest+json",
|
|
52471
|
-
".woff": "font/woff",
|
|
52472
|
-
".woff2": "font/woff2",
|
|
52473
|
-
".wasm": "application/wasm"
|
|
52474
|
-
};
|
|
52475
52773
|
async function startProdServer(outDir, options) {
|
|
52476
52774
|
const port = options?.port || 3e3;
|
|
52477
52775
|
const host = options?.host || "127.0.0.1";
|
|
52478
52776
|
const maxBodyBytes = options?.maxBodyBytes || DEFAULT_MAX_BODY_BYTES;
|
|
52479
52777
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
|
|
52480
|
-
const staticDir =
|
|
52481
|
-
const configPath2 =
|
|
52482
|
-
installMdReadHook([
|
|
52483
|
-
if (!
|
|
52778
|
+
const staticDir = resolve14(outDir, "static");
|
|
52779
|
+
const configPath2 = resolve14(outDir, "config.json");
|
|
52780
|
+
installMdReadHook([resolve14(staticDir, "public")]);
|
|
52781
|
+
if (!existsSync16(configPath2)) {
|
|
52484
52782
|
console.error(`vesk start: no build found at ${outDir}`);
|
|
52485
52783
|
console.error('Run "vesk build" first');
|
|
52486
52784
|
process.exit(1);
|
|
52487
52785
|
}
|
|
52488
|
-
const buildConfig = JSON.parse(
|
|
52786
|
+
const buildConfig = JSON.parse(readFileSync16(configPath2, "utf-8"));
|
|
52489
52787
|
const bakedHeadExtra = buildConfig.headExtra || "";
|
|
52490
52788
|
console.error(`vesk start: serving from ${outDir}`);
|
|
52491
|
-
const projectDir =
|
|
52789
|
+
const projectDir = resolve14(outDir, "..");
|
|
52492
52790
|
let securityConfig = {};
|
|
52493
52791
|
let mdConfig;
|
|
52792
|
+
let compressionConfig = {};
|
|
52793
|
+
let healthCheckEnabled = true;
|
|
52494
52794
|
try {
|
|
52495
52795
|
const config = await loadVeskConfig2(projectDir);
|
|
52496
52796
|
if (config) {
|
|
52497
52797
|
securityConfig = { security: config.security };
|
|
52498
52798
|
mdConfig = config.md;
|
|
52799
|
+
compressionConfig = config.compression === false ? { enabled: false } : config.compression || {};
|
|
52800
|
+
healthCheckEnabled = config.healthCheck !== false;
|
|
52499
52801
|
}
|
|
52500
52802
|
} catch (e) {
|
|
52501
52803
|
console.error("vesk start: failed to load vesk.config \u2014 falling back to secure defaults:", e instanceof Error ? e.message : e);
|
|
52502
52804
|
}
|
|
52805
|
+
if (options?.compression !== void 0) {
|
|
52806
|
+
compressionConfig = options.compression === false ? { enabled: false } : options.compression;
|
|
52807
|
+
}
|
|
52808
|
+
if (options?.healthCheck !== void 0) healthCheckEnabled = options.healthCheck !== false;
|
|
52503
52809
|
if (mdConfig) {
|
|
52504
52810
|
try {
|
|
52505
52811
|
const { configureMd: configureMd3 } = await Promise.resolve().then(() => (init_md(), md_exports));
|
|
@@ -52518,16 +52824,16 @@ async function startProdServer(outDir, options) {
|
|
|
52518
52824
|
} catch {
|
|
52519
52825
|
}
|
|
52520
52826
|
let middlewareMod = null;
|
|
52521
|
-
const mwPath =
|
|
52522
|
-
if (
|
|
52827
|
+
const mwPath = resolve14(outDir, "server", "middleware.js");
|
|
52828
|
+
if (existsSync16(mwPath)) {
|
|
52523
52829
|
try {
|
|
52524
52830
|
middlewareMod = await import(`${mwPath}?t=${Date.now()}`);
|
|
52525
52831
|
} catch {
|
|
52526
52832
|
}
|
|
52527
52833
|
}
|
|
52528
52834
|
let eventsMod = null;
|
|
52529
|
-
const eventsPath =
|
|
52530
|
-
if (
|
|
52835
|
+
const eventsPath = resolve14(outDir, "server", "events.js");
|
|
52836
|
+
if (existsSync16(eventsPath)) {
|
|
52531
52837
|
try {
|
|
52532
52838
|
eventsMod = await import(`${eventsPath}?t=${Date.now()}`);
|
|
52533
52839
|
} catch {
|
|
@@ -52536,8 +52842,8 @@ async function startProdServer(outDir, options) {
|
|
|
52536
52842
|
const functionCache = /* @__PURE__ */ new Map();
|
|
52537
52843
|
async function loadFunction(funcPath) {
|
|
52538
52844
|
if (functionCache.has(funcPath)) return functionCache.get(funcPath);
|
|
52539
|
-
const fullPath =
|
|
52540
|
-
if (!
|
|
52845
|
+
const fullPath = resolve14(outDir, funcPath);
|
|
52846
|
+
if (!existsSync16(fullPath)) return null;
|
|
52541
52847
|
try {
|
|
52542
52848
|
const mod = await import(`${fullPath}?t=${Date.now()}`);
|
|
52543
52849
|
functionCache.set(funcPath, mod);
|
|
@@ -52587,6 +52893,16 @@ async function startProdServer(outDir, options) {
|
|
|
52587
52893
|
const reqHost = req.headers.host || `localhost:${port}`;
|
|
52588
52894
|
const proto = req.socket.encrypted ? "https" : getClientProtocol({ headers: req.headers }, !!securityConfig?.trustProxy);
|
|
52589
52895
|
globalThis.__vesk_ssr_base_url = `${proto}://${reqHost}`;
|
|
52896
|
+
if (healthCheckEnabled && (url.pathname === "/healthz" || url.pathname === "/_vesk/healthz")) {
|
|
52897
|
+
const probe = JSON.stringify({ status: "ok", uptime: Math.floor(process.uptime()) });
|
|
52898
|
+
res.writeHead(200, {
|
|
52899
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
52900
|
+
"Content-Length": String(Buffer.byteLength(probe)),
|
|
52901
|
+
"Cache-Control": "no-store"
|
|
52902
|
+
});
|
|
52903
|
+
res.end(probe);
|
|
52904
|
+
return;
|
|
52905
|
+
}
|
|
52590
52906
|
if (rateLimiter) {
|
|
52591
52907
|
const clientIp = getClientIpFromReq(req);
|
|
52592
52908
|
if (!rateLimiter.check(clientIp)) {
|
|
@@ -52634,12 +52950,18 @@ async function startProdServer(outDir, options) {
|
|
|
52634
52950
|
}
|
|
52635
52951
|
return origWriteHead2(statusCode, headers2);
|
|
52636
52952
|
});
|
|
52637
|
-
|
|
52953
|
+
installResponsePipeline(res, req, {
|
|
52954
|
+
compress: compressionConfig.enabled !== false,
|
|
52955
|
+
compressThreshold: compressionConfig.threshold,
|
|
52956
|
+
brotliQuality: compressionConfig.brotliQuality,
|
|
52957
|
+
gzipLevel: compressionConfig.gzipLevel,
|
|
52958
|
+
etag: compressionConfig.etag !== false
|
|
52959
|
+
});
|
|
52960
|
+
const publicDir = resolve14(staticDir, "public");
|
|
52638
52961
|
const rootFile = url.pathname.length > 1 ? resolveWithin(publicDir, url.pathname.slice(1)) : null;
|
|
52639
|
-
if (rootFile &&
|
|
52640
|
-
|
|
52641
|
-
res.
|
|
52642
|
-
res.end(readFileSync15(rootFile));
|
|
52962
|
+
if (rootFile && existsSync16(rootFile) && statSync7(rootFile).isFile()) {
|
|
52963
|
+
res.writeHead(200, { "Content-Type": mimeFor(rootFile) });
|
|
52964
|
+
res.end(readFileSync16(rootFile));
|
|
52643
52965
|
return;
|
|
52644
52966
|
}
|
|
52645
52967
|
if (url.pathname === "/ssr-data.js") {
|
|
@@ -52665,13 +52987,13 @@ async function startProdServer(outDir, options) {
|
|
|
52665
52987
|
}
|
|
52666
52988
|
if (url.pathname === "/_vesk/runtime.js") {
|
|
52667
52989
|
const clientFile = buildConfig?.assets?.client?.file || "client.js";
|
|
52668
|
-
const clientPath =
|
|
52669
|
-
if (
|
|
52990
|
+
const clientPath = resolve14(staticDir, clientFile);
|
|
52991
|
+
if (existsSync16(clientPath)) {
|
|
52670
52992
|
res.writeHead(200, {
|
|
52671
52993
|
"Content-Type": "application/javascript",
|
|
52672
52994
|
"Cache-Control": cacheControlFor(clientFile, false)
|
|
52673
52995
|
});
|
|
52674
|
-
res.end(
|
|
52996
|
+
res.end(readFileSync16(clientPath));
|
|
52675
52997
|
return;
|
|
52676
52998
|
}
|
|
52677
52999
|
}
|
|
@@ -52683,26 +53005,25 @@ async function startProdServer(outDir, options) {
|
|
|
52683
53005
|
res.end("Forbidden");
|
|
52684
53006
|
return;
|
|
52685
53007
|
}
|
|
52686
|
-
if (
|
|
52687
|
-
const ext = extname3(staticPath);
|
|
53008
|
+
if (existsSync16(staticPath) && statSync7(staticPath).isFile()) {
|
|
52688
53009
|
res.writeHead(200, {
|
|
52689
|
-
"Content-Type":
|
|
53010
|
+
"Content-Type": mimeFor(staticPath),
|
|
52690
53011
|
// A content-hashed name can never change meaning, so it is immutable
|
|
52691
53012
|
// for a year; anything unhashed must be revalidated or a deploy would
|
|
52692
53013
|
// serve stale JS forever.
|
|
52693
53014
|
"Cache-Control": cacheControlFor(basename(staticPath), false)
|
|
52694
53015
|
});
|
|
52695
|
-
res.end(
|
|
53016
|
+
res.end(readFileSync16(staticPath));
|
|
52696
53017
|
return;
|
|
52697
53018
|
}
|
|
52698
53019
|
}
|
|
52699
53020
|
if (buildConfig.prerendered) {
|
|
52700
53021
|
const prerendered = buildConfig.prerendered.find((r) => r.path === url.pathname);
|
|
52701
53022
|
if (prerendered) {
|
|
52702
|
-
const htmlPath =
|
|
52703
|
-
if (
|
|
53023
|
+
const htmlPath = resolve14(outDir, prerendered.file);
|
|
53024
|
+
if (existsSync16(htmlPath)) {
|
|
52704
53025
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
52705
|
-
res.end(
|
|
53026
|
+
res.end(readFileSync16(htmlPath));
|
|
52706
53027
|
return;
|
|
52707
53028
|
}
|
|
52708
53029
|
}
|
|
@@ -52807,17 +53128,17 @@ async function startProdServer(outDir, options) {
|
|
|
52807
53128
|
}
|
|
52808
53129
|
}
|
|
52809
53130
|
}
|
|
52810
|
-
const appDir =
|
|
53131
|
+
const appDir = resolve14(projectDir, "app");
|
|
52811
53132
|
const pageCssUrls = resolveCssUrls({
|
|
52812
53133
|
enabled: hasBuiltGlobalCss(outDir)
|
|
52813
53134
|
});
|
|
52814
|
-
const nfPath =
|
|
53135
|
+
const nfPath = resolve14(appDir, "not-found.vsk");
|
|
52815
53136
|
let notFoundHtml = null;
|
|
52816
|
-
if (
|
|
53137
|
+
if (existsSync16(nfPath)) {
|
|
52817
53138
|
try {
|
|
52818
|
-
const runtimePath =
|
|
53139
|
+
const runtimePath = resolve14(outDir, "server", "runtime.js");
|
|
52819
53140
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
52820
|
-
const src2 =
|
|
53141
|
+
const src2 = readFileSync16(nfPath, "utf-8");
|
|
52821
53142
|
const compName = resolveComponentName(src2) || "NotFound";
|
|
52822
53143
|
notFoundHtml = await renderFullPage2(src2, compName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: pageCssUrls, security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: nfPath, headExtra: bakedHeadExtra });
|
|
52823
53144
|
} catch {
|
|
@@ -52891,13 +53212,13 @@ async function startProdServer(outDir, options) {
|
|
|
52891
53212
|
if (eventsMod) {
|
|
52892
53213
|
await executeError(err, { url: url.href, routePath: route.path, target: "node", status: 500 }, eventsMod);
|
|
52893
53214
|
}
|
|
52894
|
-
const errPath =
|
|
53215
|
+
const errPath = resolve14(appDir, "error.vsk");
|
|
52895
53216
|
let errorHtml = null;
|
|
52896
|
-
if (
|
|
53217
|
+
if (existsSync16(errPath)) {
|
|
52897
53218
|
try {
|
|
52898
|
-
const runtimePath =
|
|
53219
|
+
const runtimePath = resolve14(outDir, "server", "runtime.js");
|
|
52899
53220
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
52900
|
-
const src2 =
|
|
53221
|
+
const src2 = readFileSync16(errPath, "utf-8");
|
|
52901
53222
|
const compName = resolveComponentName(src2) || "Error";
|
|
52902
53223
|
const expose = process.env.NODE_ENV !== "production";
|
|
52903
53224
|
errorHtml = await renderFullPage2(src2, compName, { error: expose ? err.message : "Internal Server Error", stack: expose ? err.stack : "", statusCode: 500, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: pageCssUrls, clientScriptUrl: buildConfig?.assets?.client?.url || "/_vesk/static/client.js", clientScriptIntegrity: buildConfig?.assets?.client?.integrity, security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: errPath, headExtra: bakedHeadExtra });
|
|
@@ -52937,8 +53258,14 @@ async function startProdServer(outDir, options) {
|
|
|
52937
53258
|
server.close(() => process.exit(0));
|
|
52938
53259
|
setTimeout(() => process.exit(0), 3e3).unref();
|
|
52939
53260
|
}
|
|
52940
|
-
|
|
52941
|
-
|
|
53261
|
+
const onSigint = () => shutdown("SIGINT");
|
|
53262
|
+
const onSigterm = () => shutdown("SIGTERM");
|
|
53263
|
+
process.on("SIGINT", onSigint);
|
|
53264
|
+
process.on("SIGTERM", onSigterm);
|
|
53265
|
+
server.once("close", () => {
|
|
53266
|
+
process.off("SIGINT", onSigint);
|
|
53267
|
+
process.off("SIGTERM", onSigterm);
|
|
53268
|
+
});
|
|
52942
53269
|
server.listen(port, host, () => {
|
|
52943
53270
|
console.error(`vesk production server at http://localhost:${port} (listening on ${host})`);
|
|
52944
53271
|
});
|
|
@@ -53352,8 +53679,8 @@ init_seo_audit();
|
|
|
53352
53679
|
|
|
53353
53680
|
// src/dev-server.ts
|
|
53354
53681
|
import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, mkdirSync as mkdirSync19, readdirSync as readdirSync13, writeFileSync as writeFileSync21, renameSync as renameSync2 } from "node:fs";
|
|
53355
|
-
import { createHash as
|
|
53356
|
-
import { resolve as resolve38, extname as
|
|
53682
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
53683
|
+
import { resolve as resolve38, extname as extname7, join as join26, dirname as dirname26 } from "node:path";
|
|
53357
53684
|
import { createServer as createServer2 } from "node:http";
|
|
53358
53685
|
import { WebSocketServer as WebSocketServer2 } from "ws";
|
|
53359
53686
|
|
|
@@ -58831,7 +59158,7 @@ import { resolve as resolve28 } from "node:path";
|
|
|
58831
59158
|
// ../adapter/dist/plugins.js
|
|
58832
59159
|
init_paths();
|
|
58833
59160
|
import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
|
|
58834
|
-
import { resolve as resolve26, dirname as dirname19, join as join21, extname as
|
|
59161
|
+
import { resolve as resolve26, dirname as dirname19, join as join21, extname as extname6, basename as basename6 } from "node:path";
|
|
58835
59162
|
import { createRequire as createRequire6 } from "node:module";
|
|
58836
59163
|
import { spawn as spawn2 } from "node:child_process";
|
|
58837
59164
|
var PLUGIN_STATE_FILENAME2 = "plugins.json";
|
|
@@ -59248,7 +59575,7 @@ function findPluginIcon2(appDir, name) {
|
|
|
59248
59575
|
const iconPath = findIconFile2(dir, meta);
|
|
59249
59576
|
if (!iconPath)
|
|
59250
59577
|
return null;
|
|
59251
|
-
const ext =
|
|
59578
|
+
const ext = extname6(iconPath).toLowerCase();
|
|
59252
59579
|
const mime = ext === ".png" ? "image/png" : ext === ".ico" ? "image/x-icon" : "application/octet-stream";
|
|
59253
59580
|
return { file: iconPath, mime };
|
|
59254
59581
|
}
|
|
@@ -65447,7 +65774,7 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65447
65774
|
parts.push(`compiler:${readFileSync38(join26(process.cwd(), "node_modules", "@vesk", "compiler", "package.json"), "utf8")}`);
|
|
65448
65775
|
} catch {
|
|
65449
65776
|
}
|
|
65450
|
-
return
|
|
65777
|
+
return createHash3("sha256").update(parts.join("\n")).digest("hex").slice(0, 32);
|
|
65451
65778
|
}
|
|
65452
65779
|
function readDevBundleCache() {
|
|
65453
65780
|
try {
|
|
@@ -65959,7 +66286,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
65959
66286
|
} catch (e) {
|
|
65960
66287
|
LOG.warn("file watching unavailable, serving without auto-rebuild");
|
|
65961
66288
|
}
|
|
65962
|
-
const
|
|
66289
|
+
const MIME2 = {
|
|
65963
66290
|
".svg": "image/svg+xml",
|
|
65964
66291
|
".css": "text/css",
|
|
65965
66292
|
"": "application/javascript",
|
|
@@ -66131,8 +66458,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66131
66458
|
if (url.pathname !== "/") {
|
|
66132
66459
|
const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
|
|
66133
66460
|
if (staticPath && existsSync42(staticPath) && statSync21(staticPath).isFile()) {
|
|
66134
|
-
const ext =
|
|
66135
|
-
res.writeHead(200, { "Content-Type":
|
|
66461
|
+
const ext = extname7(staticPath);
|
|
66462
|
+
res.writeHead(200, { "Content-Type": MIME2[ext] || "application/octet-stream" });
|
|
66136
66463
|
res.end(readFileSync38(staticPath));
|
|
66137
66464
|
return;
|
|
66138
66465
|
}
|