@vesk/vesk-cli 0.2.66 → 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 +627 -290
- 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);
|
|
@@ -36725,19 +36839,20 @@ var init_static = __esm({
|
|
|
36725
36839
|
// ../adapter/dist/image-pipeline.js
|
|
36726
36840
|
var image_pipeline_exports = {};
|
|
36727
36841
|
__export(image_pipeline_exports, {
|
|
36842
|
+
collectImageRefs: () => collectImageRefs,
|
|
36728
36843
|
optimizeImages: () => optimizeImages
|
|
36729
36844
|
});
|
|
36730
|
-
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";
|
|
36731
36846
|
import { spawnSync } from "node:child_process";
|
|
36732
|
-
import { resolve as
|
|
36847
|
+
import { resolve as resolve17, extname as extname5, dirname as dirname13, join as join13 } from "node:path";
|
|
36733
36848
|
import { createRequire as createRequire5 } from "node:module";
|
|
36734
36849
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
36735
36850
|
function probeMemoPath() {
|
|
36736
36851
|
try {
|
|
36737
36852
|
const req = createRequire5(import.meta.url);
|
|
36738
36853
|
const entry = req.resolve("sharp");
|
|
36739
|
-
const stamp = Math.round(
|
|
36740
|
-
return
|
|
36854
|
+
const stamp = Math.round(statSync10(entry).mtimeMs);
|
|
36855
|
+
return join13(tmpdir2(), `vesk-sharp-probe-${process.platform}-${process.arch}-${stamp}.json`);
|
|
36741
36856
|
} catch {
|
|
36742
36857
|
return null;
|
|
36743
36858
|
}
|
|
@@ -36747,7 +36862,7 @@ function readProbeMemo() {
|
|
|
36747
36862
|
if (path === null)
|
|
36748
36863
|
return null;
|
|
36749
36864
|
try {
|
|
36750
|
-
return JSON.parse(
|
|
36865
|
+
return JSON.parse(readFileSync19(path, "utf-8"))?.usable === true;
|
|
36751
36866
|
} catch {
|
|
36752
36867
|
return null;
|
|
36753
36868
|
}
|
|
@@ -36757,7 +36872,7 @@ function writeProbeMemo(usable) {
|
|
|
36757
36872
|
if (path === null)
|
|
36758
36873
|
return;
|
|
36759
36874
|
try {
|
|
36760
|
-
|
|
36875
|
+
writeFileSync10(path, JSON.stringify({ usable, at: Date.now() }), "utf-8");
|
|
36761
36876
|
} catch {
|
|
36762
36877
|
}
|
|
36763
36878
|
}
|
|
@@ -36790,28 +36905,36 @@ async function ensureSharp() {
|
|
|
36790
36905
|
async function processImage(srcPath, outDir, baseName) {
|
|
36791
36906
|
const image = sharpFn ? sharpFn(srcPath) : null;
|
|
36792
36907
|
if (!image) {
|
|
36793
|
-
const original =
|
|
36908
|
+
const original = readFileSync19(srcPath);
|
|
36909
|
+
const ext = extname5(srcPath);
|
|
36910
|
+
const written = [];
|
|
36794
36911
|
for (const w of OUTPUT_WIDTHS) {
|
|
36795
|
-
const outputPath =
|
|
36796
|
-
|
|
36797
|
-
|
|
36912
|
+
const outputPath = resolve17(outDir, `${baseName}-${w}w${ext}`);
|
|
36913
|
+
mkdirSync9(dirname13(outputPath), { recursive: true });
|
|
36914
|
+
writeFileSync10(outputPath, original);
|
|
36915
|
+
written.push(outputPath);
|
|
36798
36916
|
}
|
|
36799
|
-
return
|
|
36917
|
+
return written;
|
|
36800
36918
|
}
|
|
36801
36919
|
const meta = await image.metadata();
|
|
36802
36920
|
const originalWidth = meta.width || 1920;
|
|
36803
36921
|
const generated = [];
|
|
36804
36922
|
for (const w of OUTPUT_WIDTHS) {
|
|
36805
|
-
|
|
36923
|
+
const base = `${baseName}-${w}w`;
|
|
36924
|
+
if (w >= originalWidth) {
|
|
36925
|
+
const copyPath = resolve17(outDir, `${base}${extname5(srcPath)}`);
|
|
36926
|
+
mkdirSync9(dirname13(copyPath), { recursive: true });
|
|
36927
|
+
writeFileSync10(copyPath, readFileSync19(srcPath));
|
|
36928
|
+
generated.push(copyPath);
|
|
36806
36929
|
continue;
|
|
36930
|
+
}
|
|
36807
36931
|
const resized = image.clone().resize({ width: w, withoutEnlargement: true });
|
|
36808
|
-
const
|
|
36809
|
-
|
|
36810
|
-
mkdirSync8(dirname12(jpgPath), { recursive: true });
|
|
36932
|
+
const jpgPath = resolve17(outDir, `${base}${extname5(srcPath)}`);
|
|
36933
|
+
mkdirSync9(dirname13(jpgPath), { recursive: true });
|
|
36811
36934
|
await resized.toFile(jpgPath);
|
|
36812
36935
|
generated.push(jpgPath);
|
|
36813
36936
|
for (const fmt of FORMATS) {
|
|
36814
|
-
const fmtPath =
|
|
36937
|
+
const fmtPath = resolve17(outDir, `${base}.${fmt}`);
|
|
36815
36938
|
await resized.toFormat(fmt, { quality: 80 }).toFile(fmtPath);
|
|
36816
36939
|
generated.push(fmtPath);
|
|
36817
36940
|
}
|
|
@@ -36823,20 +36946,20 @@ function collectImageRefs(appDir) {
|
|
|
36823
36946
|
function walk9(dir) {
|
|
36824
36947
|
let entries;
|
|
36825
36948
|
try {
|
|
36826
|
-
entries =
|
|
36949
|
+
entries = readdirSync5(dir);
|
|
36827
36950
|
} catch {
|
|
36828
36951
|
return;
|
|
36829
36952
|
}
|
|
36830
36953
|
for (const entry of entries) {
|
|
36831
|
-
const full =
|
|
36832
|
-
const st =
|
|
36954
|
+
const full = resolve17(dir, entry);
|
|
36955
|
+
const st = statSync10(full);
|
|
36833
36956
|
if (st.isDirectory()) {
|
|
36834
36957
|
if (entry.startsWith("."))
|
|
36835
36958
|
continue;
|
|
36836
36959
|
walk9(full);
|
|
36837
|
-
} else if (entry
|
|
36838
|
-
const src2 =
|
|
36839
|
-
const imgRegex = /<Image\s
|
|
36960
|
+
} else if (entry.endsWith(".vsk")) {
|
|
36961
|
+
const src2 = readFileSync19(full, "utf-8");
|
|
36962
|
+
const imgRegex = /<Image\s[^>]*src=["']([^"']+)["']/g;
|
|
36840
36963
|
let m;
|
|
36841
36964
|
while ((m = imgRegex.exec(src2)) !== null) {
|
|
36842
36965
|
refs.push({ source: full, src: m[1] });
|
|
@@ -36848,8 +36971,7 @@ function collectImageRefs(appDir) {
|
|
|
36848
36971
|
return refs;
|
|
36849
36972
|
}
|
|
36850
36973
|
async function optimizeImages(appDir, outDir) {
|
|
36851
|
-
|
|
36852
|
-
mkdirSync8(imageOutDir, { recursive: true });
|
|
36974
|
+
mkdirSync9(resolve17(outDir, "static", "public"), { recursive: true });
|
|
36853
36975
|
const refs = collectImageRefs(appDir);
|
|
36854
36976
|
if (refs.length === 0) {
|
|
36855
36977
|
console.error("vesk images: no <Image> refs found");
|
|
@@ -36860,14 +36982,14 @@ async function optimizeImages(appDir, outDir) {
|
|
|
36860
36982
|
for (const ref2 of refs) {
|
|
36861
36983
|
const rel = ref2.src.replace(/^\//, "");
|
|
36862
36984
|
const possiblePaths = [
|
|
36863
|
-
|
|
36864
|
-
|
|
36865
|
-
|
|
36866
|
-
|
|
36985
|
+
resolve17(appDir, rel),
|
|
36986
|
+
resolve17(appDir, "..", "public", rel),
|
|
36987
|
+
resolve17(appDir, "..", "src", rel),
|
|
36988
|
+
resolve17(outDir, "static", "public", rel)
|
|
36867
36989
|
];
|
|
36868
36990
|
let srcPath = null;
|
|
36869
36991
|
for (const p of possiblePaths) {
|
|
36870
|
-
if (
|
|
36992
|
+
if (existsSync19(p)) {
|
|
36871
36993
|
srcPath = p;
|
|
36872
36994
|
break;
|
|
36873
36995
|
}
|
|
@@ -36882,6 +37004,8 @@ async function optimizeImages(appDir, outDir) {
|
|
|
36882
37004
|
continue;
|
|
36883
37005
|
}
|
|
36884
37006
|
const baseName = ref2.src.replace(/^\//, "").replace(extname5(ref2.src), "");
|
|
37007
|
+
const imageOutDir = resolve17(outDir, "static", "public");
|
|
37008
|
+
mkdirSync9(imageOutDir, { recursive: true });
|
|
36885
37009
|
const files = await processImage(srcPath, imageOutDir, baseName);
|
|
36886
37010
|
results.push({ src: ref2.src, baseName, files, widths: OUTPUT_WIDTHS });
|
|
36887
37011
|
console.error(`vesk images: ${ref2.src} \u2192 ${files.length} variants`);
|
|
@@ -36910,19 +37034,19 @@ var seo_audit_exports = {};
|
|
|
36910
37034
|
__export(seo_audit_exports, {
|
|
36911
37035
|
runSeoAudit: () => runSeoAudit
|
|
36912
37036
|
});
|
|
36913
|
-
import { readFileSync as
|
|
36914
|
-
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";
|
|
36915
37039
|
function walkFiles(dir) {
|
|
36916
37040
|
const results = [];
|
|
36917
37041
|
let entries;
|
|
36918
37042
|
try {
|
|
36919
|
-
entries =
|
|
37043
|
+
entries = readdirSync6(dir);
|
|
36920
37044
|
} catch {
|
|
36921
37045
|
return results;
|
|
36922
37046
|
}
|
|
36923
37047
|
for (const entry of entries) {
|
|
36924
|
-
const full =
|
|
36925
|
-
const st =
|
|
37048
|
+
const full = resolve18(dir, entry);
|
|
37049
|
+
const st = statSync11(full);
|
|
36926
37050
|
if (st.isDirectory()) {
|
|
36927
37051
|
if (!entry.startsWith("."))
|
|
36928
37052
|
results.push(...walkFiles(full));
|
|
@@ -36936,10 +37060,10 @@ function collectCombinedSource(appDir) {
|
|
|
36936
37060
|
const pages = files.filter((f) => f.endsWith("/page.vsk") || f.endsWith("\\page.vsk"));
|
|
36937
37061
|
const combined = [];
|
|
36938
37062
|
for (const pagePath of pages) {
|
|
36939
|
-
const dir =
|
|
36940
|
-
const layoutPath =
|
|
36941
|
-
const pageSrc =
|
|
36942
|
-
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") : "";
|
|
36943
37067
|
const combinedSrc = layoutSrc ? layoutSrc + "\n" + pageSrc : pageSrc;
|
|
36944
37068
|
combined.push({
|
|
36945
37069
|
path: pagePath,
|
|
@@ -37134,8 +37258,8 @@ var init_platform = __esm({
|
|
|
37134
37258
|
});
|
|
37135
37259
|
|
|
37136
37260
|
// ../adapter/src/platform-handler.ts
|
|
37137
|
-
import { existsSync as
|
|
37138
|
-
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";
|
|
37139
37263
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
37140
37264
|
function routeName2(segments) {
|
|
37141
37265
|
const parts = segments.filter(Boolean).map((s) => {
|
|
@@ -37153,13 +37277,13 @@ function toId(s) {
|
|
|
37153
37277
|
}
|
|
37154
37278
|
function findCompilerSrc2(appDir) {
|
|
37155
37279
|
const candidates = [
|
|
37156
|
-
|
|
37157
|
-
|
|
37158
|
-
|
|
37280
|
+
resolve19(__dirname5, "..", "..", "..", "packages", "compiler", "dist"),
|
|
37281
|
+
resolve19(appDir, "..", "node_modules", "@vesk/compiler"),
|
|
37282
|
+
resolve19(appDir, "node_modules", "@vesk/compiler")
|
|
37159
37283
|
];
|
|
37160
37284
|
for (const base of candidates) {
|
|
37161
|
-
for (const dir of [base,
|
|
37162
|
-
if (
|
|
37285
|
+
for (const dir of [base, join14(base, "dist")]) {
|
|
37286
|
+
if (existsSync21(join14(dir, "server-cookies.js"))) return dir;
|
|
37163
37287
|
}
|
|
37164
37288
|
}
|
|
37165
37289
|
throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
|
|
@@ -37199,7 +37323,7 @@ function generatePlatformHandlerSource(input) {
|
|
|
37199
37323
|
const eventsRequestLine = hasEvents ? " await __eventsRequest(mwCtx);" : "";
|
|
37200
37324
|
const localsSeed = hasEvents ? "Object.assign({}, __serverStore)" : "{}";
|
|
37201
37325
|
const compilerSrc = findCompilerSrc2(appDir);
|
|
37202
|
-
const parseCookiesImport = hasMiddleware ? `import { parseCookies } from ${JSON.stringify(
|
|
37326
|
+
const parseCookiesImport = hasMiddleware ? `import { parseCookies } from ${JSON.stringify(resolve19(compilerSrc, "server-cookies.js"))};` : "";
|
|
37203
37327
|
return `
|
|
37204
37328
|
${imports}
|
|
37205
37329
|
${parseCookiesImport}
|
|
@@ -37449,121 +37573,7 @@ var init_platform_handler = __esm({
|
|
|
37449
37573
|
"../adapter/src/platform-handler.ts"() {
|
|
37450
37574
|
"use strict";
|
|
37451
37575
|
init_default_pages();
|
|
37452
|
-
__dirname5 =
|
|
37453
|
-
}
|
|
37454
|
-
});
|
|
37455
|
-
|
|
37456
|
-
// ../adapter/src/platform-output.ts
|
|
37457
|
-
import {
|
|
37458
|
-
mkdirSync as mkdirSync9,
|
|
37459
|
-
copyFileSync as copyFileSync3,
|
|
37460
|
-
readdirSync as readdirSync6,
|
|
37461
|
-
statSync as statSync11,
|
|
37462
|
-
existsSync as existsSync21,
|
|
37463
|
-
writeFileSync as writeFileSync10,
|
|
37464
|
-
rmSync as rmSync2,
|
|
37465
|
-
readFileSync as readFileSync20
|
|
37466
|
-
} from "node:fs";
|
|
37467
|
-
import { resolve as resolve19, join as join14, extname as extname6, dirname as dirname14 } from "node:path";
|
|
37468
|
-
function ensureCleanDir(dir) {
|
|
37469
|
-
rmSync2(dir, { recursive: true, force: true });
|
|
37470
|
-
mkdirSync9(dir, { recursive: true });
|
|
37471
|
-
}
|
|
37472
|
-
function copyDirContents(srcDir, destDir) {
|
|
37473
|
-
if (!existsSync21(srcDir)) return;
|
|
37474
|
-
mkdirSync9(destDir, { recursive: true });
|
|
37475
|
-
for (const entry of readdirSync6(srcDir)) {
|
|
37476
|
-
const srcPath = join14(srcDir, entry);
|
|
37477
|
-
const destPath = join14(destDir, entry);
|
|
37478
|
-
if (statSync11(srcPath).isDirectory()) {
|
|
37479
|
-
copyDirContents(srcPath, destPath);
|
|
37480
|
-
} else {
|
|
37481
|
-
mkdirSync9(dirname14(destPath), { recursive: true });
|
|
37482
|
-
copyFileSync3(srcPath, destPath);
|
|
37483
|
-
}
|
|
37484
|
-
}
|
|
37485
|
-
}
|
|
37486
|
-
function writeFile(path, content) {
|
|
37487
|
-
mkdirSync9(dirname14(path), { recursive: true });
|
|
37488
|
-
writeFileSync10(path, content, "utf-8");
|
|
37489
|
-
}
|
|
37490
|
-
function writePlatformStatic(buildStaticDir, platformStaticDir) {
|
|
37491
|
-
mkdirSync9(platformStaticDir, { recursive: true });
|
|
37492
|
-
const publicDir = resolve19(buildStaticDir, "public");
|
|
37493
|
-
if (existsSync21(publicDir)) {
|
|
37494
|
-
copyDirContents(publicDir, platformStaticDir);
|
|
37495
|
-
}
|
|
37496
|
-
const assetsDir = resolve19(platformStaticDir, "_vesk", "static");
|
|
37497
|
-
copyDirContents(buildStaticDir, assetsDir);
|
|
37498
|
-
const runtimeAlias = resolve19(platformStaticDir, "_vesk", "runtime.js");
|
|
37499
|
-
const clientPath = resolve19(buildStaticDir, "client.js");
|
|
37500
|
-
if (existsSync21(clientPath)) {
|
|
37501
|
-
mkdirSync9(dirname14(runtimeAlias), { recursive: true });
|
|
37502
|
-
copyFileSync3(clientPath, runtimeAlias);
|
|
37503
|
-
}
|
|
37504
|
-
}
|
|
37505
|
-
function writePrerenderedStatic(prerenderedRoutes, platformStaticDir) {
|
|
37506
|
-
for (const route of prerenderedRoutes) {
|
|
37507
|
-
if (!existsSync21(route.html)) continue;
|
|
37508
|
-
const content = readFileSync20(route.html);
|
|
37509
|
-
const htmlRel = route.path === "/" ? "index.html" : `${route.path.replace(/^\//, "")}.html`;
|
|
37510
|
-
const target = resolve19(platformStaticDir, "_vesk", "static", "public", htmlRel);
|
|
37511
|
-
writeFile(target, content);
|
|
37512
|
-
if (route.path !== "/" && route.path.endsWith("/")) {
|
|
37513
|
-
const dirIndex = resolve19(platformStaticDir, "_vesk", "static", "public", `${route.path.replace(/^\//, "")}index.html`);
|
|
37514
|
-
writeFile(dirIndex, content);
|
|
37515
|
-
}
|
|
37516
|
-
}
|
|
37517
|
-
}
|
|
37518
|
-
function listStaticDir(dir) {
|
|
37519
|
-
const out = [];
|
|
37520
|
-
if (!existsSync21(dir)) return out;
|
|
37521
|
-
function walk9(d, prefix) {
|
|
37522
|
-
for (const entry of readdirSync6(d)) {
|
|
37523
|
-
const full = join14(d, entry);
|
|
37524
|
-
const rel = prefix ? `${prefix}/${entry}` : entry;
|
|
37525
|
-
if (statSync11(full).isDirectory()) {
|
|
37526
|
-
walk9(full, rel);
|
|
37527
|
-
} else {
|
|
37528
|
-
out.push({ rel, buffer: readFileSync20(full) });
|
|
37529
|
-
}
|
|
37530
|
-
}
|
|
37531
|
-
}
|
|
37532
|
-
walk9(dir, "");
|
|
37533
|
-
return out;
|
|
37534
|
-
}
|
|
37535
|
-
function mimeFor(path) {
|
|
37536
|
-
return MIME2[extname6(path).toLowerCase()] || "application/octet-stream";
|
|
37537
|
-
}
|
|
37538
|
-
var MIME2;
|
|
37539
|
-
var init_platform_output = __esm({
|
|
37540
|
-
"../adapter/src/platform-output.ts"() {
|
|
37541
|
-
"use strict";
|
|
37542
|
-
MIME2 = {
|
|
37543
|
-
".html": "text/html; charset=utf-8",
|
|
37544
|
-
".htm": "text/html; charset=utf-8",
|
|
37545
|
-
".js": "application/javascript; charset=utf-8",
|
|
37546
|
-
".mjs": "application/javascript; charset=utf-8",
|
|
37547
|
-
".css": "text/css; charset=utf-8",
|
|
37548
|
-
".json": "application/json; charset=utf-8",
|
|
37549
|
-
".svg": "image/svg+xml",
|
|
37550
|
-
".png": "image/png",
|
|
37551
|
-
".jpg": "image/jpeg",
|
|
37552
|
-
".jpeg": "image/jpeg",
|
|
37553
|
-
".gif": "image/gif",
|
|
37554
|
-
".webp": "image/webp",
|
|
37555
|
-
".avif": "image/avif",
|
|
37556
|
-
".ico": "image/x-icon",
|
|
37557
|
-
".txt": "text/plain; charset=utf-8",
|
|
37558
|
-
".xml": "application/xml",
|
|
37559
|
-
".woff": "font/woff",
|
|
37560
|
-
".woff2": "font/woff2",
|
|
37561
|
-
".ttf": "font/ttf",
|
|
37562
|
-
".otf": "font/otf",
|
|
37563
|
-
".wasm": "application/wasm",
|
|
37564
|
-
".map": "application/json",
|
|
37565
|
-
".webmanifest": "application/manifest+json"
|
|
37566
|
-
};
|
|
37576
|
+
__dirname5 = dirname14(fileURLToPath4(import.meta.url));
|
|
37567
37577
|
}
|
|
37568
37578
|
});
|
|
37569
37579
|
|
|
@@ -48819,7 +48829,7 @@ __export(migrate_exports, {
|
|
|
48819
48829
|
runMigrate: () => runMigrate
|
|
48820
48830
|
});
|
|
48821
48831
|
import { readFileSync as readFileSync41, writeFileSync as writeFileSync22, existsSync as existsSync44, statSync as statSync23, readdirSync as readdirSync15 } from "node:fs";
|
|
48822
|
-
import { join as join29, relative as relative9, extname as
|
|
48832
|
+
import { join as join29, relative as relative9, extname as extname8 } from "node:path";
|
|
48823
48833
|
function detectInstalledVersion(projectDir, cliVersion) {
|
|
48824
48834
|
for (const pkg of ["@vesk/vesk-cli", "@vesk/adapter", "@vesk/compiler"]) {
|
|
48825
48835
|
const p = join29(projectDir, "node_modules", pkg, "package.json");
|
|
@@ -48851,7 +48861,7 @@ function collectTargets(dir, root3 = dir) {
|
|
|
48851
48861
|
}
|
|
48852
48862
|
if (st.isDirectory()) {
|
|
48853
48863
|
out.push(...collectTargets(full, root3));
|
|
48854
|
-
} else if (SCAN_EXTENSIONS.has(
|
|
48864
|
+
} else if (SCAN_EXTENSIONS.has(extname8(entry))) {
|
|
48855
48865
|
out.push(relative9(root3, full));
|
|
48856
48866
|
}
|
|
48857
48867
|
}
|
|
@@ -52263,8 +52273,8 @@ function copyStaticAssets(publicDir, outDir) {
|
|
|
52263
52273
|
}
|
|
52264
52274
|
|
|
52265
52275
|
// ../adapter/src/prod-server.ts
|
|
52266
|
-
import { readFileSync as
|
|
52267
|
-
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";
|
|
52268
52278
|
import { createServer } from "node:http";
|
|
52269
52279
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
52270
52280
|
init_server_utils();
|
|
@@ -52369,12 +52379,327 @@ async function loadVeskConfig2(projectDir) {
|
|
|
52369
52379
|
|
|
52370
52380
|
// ../adapter/src/prod-server.ts
|
|
52371
52381
|
init_default_pages();
|
|
52372
|
-
|
|
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;
|
|
52373
52662
|
async function deliverResponse(res, response) {
|
|
52374
|
-
|
|
52663
|
+
const headers2 = Object.fromEntries(response.headers);
|
|
52375
52664
|
const body = response.body;
|
|
52376
|
-
if (body
|
|
52377
|
-
|
|
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 () => {
|
|
52378
52703
|
try {
|
|
52379
52704
|
for (; ; ) {
|
|
52380
52705
|
const { done, value } = await reader.read();
|
|
@@ -52384,9 +52709,7 @@ async function deliverResponse(res, response) {
|
|
|
52384
52709
|
} catch {
|
|
52385
52710
|
}
|
|
52386
52711
|
res.end();
|
|
52387
|
-
|
|
52388
|
-
}
|
|
52389
|
-
res.end(await response.text());
|
|
52712
|
+
})();
|
|
52390
52713
|
}
|
|
52391
52714
|
function bodyTooLarge(maxBytes) {
|
|
52392
52715
|
const err = new Error(`Request body exceeds limit (${maxBytes} bytes)`);
|
|
@@ -52447,49 +52770,42 @@ function makeWebRequest(nodeReq, url, maxBodyBytes = DEFAULT_MAX_BODY_BYTES) {
|
|
|
52447
52770
|
webRequest.query = query;
|
|
52448
52771
|
return webRequest;
|
|
52449
52772
|
}
|
|
52450
|
-
var MIME = {
|
|
52451
|
-
".svg": "image/svg+xml",
|
|
52452
|
-
".css": "text/css",
|
|
52453
|
-
".js": "application/javascript",
|
|
52454
|
-
".png": "image/png",
|
|
52455
|
-
".jpg": "image/jpeg",
|
|
52456
|
-
".jpeg": "image/jpeg",
|
|
52457
|
-
".ico": "image/x-icon",
|
|
52458
|
-
".html": "text/html",
|
|
52459
|
-
".json": "application/json",
|
|
52460
|
-
".webmanifest": "application/manifest+json",
|
|
52461
|
-
".woff": "font/woff",
|
|
52462
|
-
".woff2": "font/woff2",
|
|
52463
|
-
".wasm": "application/wasm"
|
|
52464
|
-
};
|
|
52465
52773
|
async function startProdServer(outDir, options) {
|
|
52466
52774
|
const port = options?.port || 3e3;
|
|
52467
52775
|
const host = options?.host || "127.0.0.1";
|
|
52468
52776
|
const maxBodyBytes = options?.maxBodyBytes || DEFAULT_MAX_BODY_BYTES;
|
|
52469
52777
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
|
|
52470
|
-
const staticDir =
|
|
52471
|
-
const configPath2 =
|
|
52472
|
-
installMdReadHook([
|
|
52473
|
-
if (!
|
|
52778
|
+
const staticDir = resolve14(outDir, "static");
|
|
52779
|
+
const configPath2 = resolve14(outDir, "config.json");
|
|
52780
|
+
installMdReadHook([resolve14(staticDir, "public")]);
|
|
52781
|
+
if (!existsSync16(configPath2)) {
|
|
52474
52782
|
console.error(`vesk start: no build found at ${outDir}`);
|
|
52475
52783
|
console.error('Run "vesk build" first');
|
|
52476
52784
|
process.exit(1);
|
|
52477
52785
|
}
|
|
52478
|
-
const buildConfig = JSON.parse(
|
|
52786
|
+
const buildConfig = JSON.parse(readFileSync16(configPath2, "utf-8"));
|
|
52479
52787
|
const bakedHeadExtra = buildConfig.headExtra || "";
|
|
52480
52788
|
console.error(`vesk start: serving from ${outDir}`);
|
|
52481
|
-
const projectDir =
|
|
52789
|
+
const projectDir = resolve14(outDir, "..");
|
|
52482
52790
|
let securityConfig = {};
|
|
52483
52791
|
let mdConfig;
|
|
52792
|
+
let compressionConfig = {};
|
|
52793
|
+
let healthCheckEnabled = true;
|
|
52484
52794
|
try {
|
|
52485
52795
|
const config = await loadVeskConfig2(projectDir);
|
|
52486
52796
|
if (config) {
|
|
52487
52797
|
securityConfig = { security: config.security };
|
|
52488
52798
|
mdConfig = config.md;
|
|
52799
|
+
compressionConfig = config.compression === false ? { enabled: false } : config.compression || {};
|
|
52800
|
+
healthCheckEnabled = config.healthCheck !== false;
|
|
52489
52801
|
}
|
|
52490
52802
|
} catch (e) {
|
|
52491
52803
|
console.error("vesk start: failed to load vesk.config \u2014 falling back to secure defaults:", e instanceof Error ? e.message : e);
|
|
52492
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;
|
|
52493
52809
|
if (mdConfig) {
|
|
52494
52810
|
try {
|
|
52495
52811
|
const { configureMd: configureMd3 } = await Promise.resolve().then(() => (init_md(), md_exports));
|
|
@@ -52508,16 +52824,16 @@ async function startProdServer(outDir, options) {
|
|
|
52508
52824
|
} catch {
|
|
52509
52825
|
}
|
|
52510
52826
|
let middlewareMod = null;
|
|
52511
|
-
const mwPath =
|
|
52512
|
-
if (
|
|
52827
|
+
const mwPath = resolve14(outDir, "server", "middleware.js");
|
|
52828
|
+
if (existsSync16(mwPath)) {
|
|
52513
52829
|
try {
|
|
52514
52830
|
middlewareMod = await import(`${mwPath}?t=${Date.now()}`);
|
|
52515
52831
|
} catch {
|
|
52516
52832
|
}
|
|
52517
52833
|
}
|
|
52518
52834
|
let eventsMod = null;
|
|
52519
|
-
const eventsPath =
|
|
52520
|
-
if (
|
|
52835
|
+
const eventsPath = resolve14(outDir, "server", "events.js");
|
|
52836
|
+
if (existsSync16(eventsPath)) {
|
|
52521
52837
|
try {
|
|
52522
52838
|
eventsMod = await import(`${eventsPath}?t=${Date.now()}`);
|
|
52523
52839
|
} catch {
|
|
@@ -52526,8 +52842,8 @@ async function startProdServer(outDir, options) {
|
|
|
52526
52842
|
const functionCache = /* @__PURE__ */ new Map();
|
|
52527
52843
|
async function loadFunction(funcPath) {
|
|
52528
52844
|
if (functionCache.has(funcPath)) return functionCache.get(funcPath);
|
|
52529
|
-
const fullPath =
|
|
52530
|
-
if (!
|
|
52845
|
+
const fullPath = resolve14(outDir, funcPath);
|
|
52846
|
+
if (!existsSync16(fullPath)) return null;
|
|
52531
52847
|
try {
|
|
52532
52848
|
const mod = await import(`${fullPath}?t=${Date.now()}`);
|
|
52533
52849
|
functionCache.set(funcPath, mod);
|
|
@@ -52577,6 +52893,16 @@ async function startProdServer(outDir, options) {
|
|
|
52577
52893
|
const reqHost = req.headers.host || `localhost:${port}`;
|
|
52578
52894
|
const proto = req.socket.encrypted ? "https" : getClientProtocol({ headers: req.headers }, !!securityConfig?.trustProxy);
|
|
52579
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
|
+
}
|
|
52580
52906
|
if (rateLimiter) {
|
|
52581
52907
|
const clientIp = getClientIpFromReq(req);
|
|
52582
52908
|
if (!rateLimiter.check(clientIp)) {
|
|
@@ -52624,12 +52950,18 @@ async function startProdServer(outDir, options) {
|
|
|
52624
52950
|
}
|
|
52625
52951
|
return origWriteHead2(statusCode, headers2);
|
|
52626
52952
|
});
|
|
52627
|
-
|
|
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");
|
|
52628
52961
|
const rootFile = url.pathname.length > 1 ? resolveWithin(publicDir, url.pathname.slice(1)) : null;
|
|
52629
|
-
if (rootFile &&
|
|
52630
|
-
|
|
52631
|
-
res.
|
|
52632
|
-
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));
|
|
52633
52965
|
return;
|
|
52634
52966
|
}
|
|
52635
52967
|
if (url.pathname === "/ssr-data.js") {
|
|
@@ -52655,13 +52987,13 @@ async function startProdServer(outDir, options) {
|
|
|
52655
52987
|
}
|
|
52656
52988
|
if (url.pathname === "/_vesk/runtime.js") {
|
|
52657
52989
|
const clientFile = buildConfig?.assets?.client?.file || "client.js";
|
|
52658
|
-
const clientPath =
|
|
52659
|
-
if (
|
|
52990
|
+
const clientPath = resolve14(staticDir, clientFile);
|
|
52991
|
+
if (existsSync16(clientPath)) {
|
|
52660
52992
|
res.writeHead(200, {
|
|
52661
52993
|
"Content-Type": "application/javascript",
|
|
52662
52994
|
"Cache-Control": cacheControlFor(clientFile, false)
|
|
52663
52995
|
});
|
|
52664
|
-
res.end(
|
|
52996
|
+
res.end(readFileSync16(clientPath));
|
|
52665
52997
|
return;
|
|
52666
52998
|
}
|
|
52667
52999
|
}
|
|
@@ -52673,26 +53005,25 @@ async function startProdServer(outDir, options) {
|
|
|
52673
53005
|
res.end("Forbidden");
|
|
52674
53006
|
return;
|
|
52675
53007
|
}
|
|
52676
|
-
if (
|
|
52677
|
-
const ext = extname3(staticPath);
|
|
53008
|
+
if (existsSync16(staticPath) && statSync7(staticPath).isFile()) {
|
|
52678
53009
|
res.writeHead(200, {
|
|
52679
|
-
"Content-Type":
|
|
53010
|
+
"Content-Type": mimeFor(staticPath),
|
|
52680
53011
|
// A content-hashed name can never change meaning, so it is immutable
|
|
52681
53012
|
// for a year; anything unhashed must be revalidated or a deploy would
|
|
52682
53013
|
// serve stale JS forever.
|
|
52683
53014
|
"Cache-Control": cacheControlFor(basename(staticPath), false)
|
|
52684
53015
|
});
|
|
52685
|
-
res.end(
|
|
53016
|
+
res.end(readFileSync16(staticPath));
|
|
52686
53017
|
return;
|
|
52687
53018
|
}
|
|
52688
53019
|
}
|
|
52689
53020
|
if (buildConfig.prerendered) {
|
|
52690
53021
|
const prerendered = buildConfig.prerendered.find((r) => r.path === url.pathname);
|
|
52691
53022
|
if (prerendered) {
|
|
52692
|
-
const htmlPath =
|
|
52693
|
-
if (
|
|
53023
|
+
const htmlPath = resolve14(outDir, prerendered.file);
|
|
53024
|
+
if (existsSync16(htmlPath)) {
|
|
52694
53025
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
52695
|
-
res.end(
|
|
53026
|
+
res.end(readFileSync16(htmlPath));
|
|
52696
53027
|
return;
|
|
52697
53028
|
}
|
|
52698
53029
|
}
|
|
@@ -52797,17 +53128,17 @@ async function startProdServer(outDir, options) {
|
|
|
52797
53128
|
}
|
|
52798
53129
|
}
|
|
52799
53130
|
}
|
|
52800
|
-
const appDir =
|
|
53131
|
+
const appDir = resolve14(projectDir, "app");
|
|
52801
53132
|
const pageCssUrls = resolveCssUrls({
|
|
52802
53133
|
enabled: hasBuiltGlobalCss(outDir)
|
|
52803
53134
|
});
|
|
52804
|
-
const nfPath =
|
|
53135
|
+
const nfPath = resolve14(appDir, "not-found.vsk");
|
|
52805
53136
|
let notFoundHtml = null;
|
|
52806
|
-
if (
|
|
53137
|
+
if (existsSync16(nfPath)) {
|
|
52807
53138
|
try {
|
|
52808
|
-
const runtimePath =
|
|
53139
|
+
const runtimePath = resolve14(outDir, "server", "runtime.js");
|
|
52809
53140
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
52810
|
-
const src2 =
|
|
53141
|
+
const src2 = readFileSync16(nfPath, "utf-8");
|
|
52811
53142
|
const compName = resolveComponentName(src2) || "NotFound";
|
|
52812
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 });
|
|
52813
53144
|
} catch {
|
|
@@ -52881,13 +53212,13 @@ async function startProdServer(outDir, options) {
|
|
|
52881
53212
|
if (eventsMod) {
|
|
52882
53213
|
await executeError(err, { url: url.href, routePath: route.path, target: "node", status: 500 }, eventsMod);
|
|
52883
53214
|
}
|
|
52884
|
-
const errPath =
|
|
53215
|
+
const errPath = resolve14(appDir, "error.vsk");
|
|
52885
53216
|
let errorHtml = null;
|
|
52886
|
-
if (
|
|
53217
|
+
if (existsSync16(errPath)) {
|
|
52887
53218
|
try {
|
|
52888
|
-
const runtimePath =
|
|
53219
|
+
const runtimePath = resolve14(outDir, "server", "runtime.js");
|
|
52889
53220
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
52890
|
-
const src2 =
|
|
53221
|
+
const src2 = readFileSync16(errPath, "utf-8");
|
|
52891
53222
|
const compName = resolveComponentName(src2) || "Error";
|
|
52892
53223
|
const expose = process.env.NODE_ENV !== "production";
|
|
52893
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 });
|
|
@@ -52927,8 +53258,14 @@ async function startProdServer(outDir, options) {
|
|
|
52927
53258
|
server.close(() => process.exit(0));
|
|
52928
53259
|
setTimeout(() => process.exit(0), 3e3).unref();
|
|
52929
53260
|
}
|
|
52930
|
-
|
|
52931
|
-
|
|
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
|
+
});
|
|
52932
53269
|
server.listen(port, host, () => {
|
|
52933
53270
|
console.error(`vesk production server at http://localhost:${port} (listening on ${host})`);
|
|
52934
53271
|
});
|
|
@@ -53342,8 +53679,8 @@ init_seo_audit();
|
|
|
53342
53679
|
|
|
53343
53680
|
// src/dev-server.ts
|
|
53344
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";
|
|
53345
|
-
import { createHash as
|
|
53346
|
-
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";
|
|
53347
53684
|
import { createServer as createServer2 } from "node:http";
|
|
53348
53685
|
import { WebSocketServer as WebSocketServer2 } from "ws";
|
|
53349
53686
|
|
|
@@ -58821,7 +59158,7 @@ import { resolve as resolve28 } from "node:path";
|
|
|
58821
59158
|
// ../adapter/dist/plugins.js
|
|
58822
59159
|
init_paths();
|
|
58823
59160
|
import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
|
|
58824
|
-
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";
|
|
58825
59162
|
import { createRequire as createRequire6 } from "node:module";
|
|
58826
59163
|
import { spawn as spawn2 } from "node:child_process";
|
|
58827
59164
|
var PLUGIN_STATE_FILENAME2 = "plugins.json";
|
|
@@ -59238,7 +59575,7 @@ function findPluginIcon2(appDir, name) {
|
|
|
59238
59575
|
const iconPath = findIconFile2(dir, meta);
|
|
59239
59576
|
if (!iconPath)
|
|
59240
59577
|
return null;
|
|
59241
|
-
const ext =
|
|
59578
|
+
const ext = extname6(iconPath).toLowerCase();
|
|
59242
59579
|
const mime = ext === ".png" ? "image/png" : ext === ".ico" ? "image/x-icon" : "application/octet-stream";
|
|
59243
59580
|
return { file: iconPath, mime };
|
|
59244
59581
|
}
|
|
@@ -65437,7 +65774,7 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65437
65774
|
parts.push(`compiler:${readFileSync38(join26(process.cwd(), "node_modules", "@vesk", "compiler", "package.json"), "utf8")}`);
|
|
65438
65775
|
} catch {
|
|
65439
65776
|
}
|
|
65440
|
-
return
|
|
65777
|
+
return createHash3("sha256").update(parts.join("\n")).digest("hex").slice(0, 32);
|
|
65441
65778
|
}
|
|
65442
65779
|
function readDevBundleCache() {
|
|
65443
65780
|
try {
|
|
@@ -65949,7 +66286,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
65949
66286
|
} catch (e) {
|
|
65950
66287
|
LOG.warn("file watching unavailable, serving without auto-rebuild");
|
|
65951
66288
|
}
|
|
65952
|
-
const
|
|
66289
|
+
const MIME2 = {
|
|
65953
66290
|
".svg": "image/svg+xml",
|
|
65954
66291
|
".css": "text/css",
|
|
65955
66292
|
"": "application/javascript",
|
|
@@ -66121,8 +66458,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66121
66458
|
if (url.pathname !== "/") {
|
|
66122
66459
|
const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
|
|
66123
66460
|
if (staticPath && existsSync42(staticPath) && statSync21(staticPath).isFile()) {
|
|
66124
|
-
const ext =
|
|
66125
|
-
res.writeHead(200, { "Content-Type":
|
|
66461
|
+
const ext = extname7(staticPath);
|
|
66462
|
+
res.writeHead(200, { "Content-Type": MIME2[ext] || "application/octet-stream" });
|
|
66126
66463
|
res.end(readFileSync38(staticPath));
|
|
66127
66464
|
return;
|
|
66128
66465
|
}
|