@vesk/vesk-cli 0.2.67 → 0.2.69
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 +1222 -563
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -35609,7 +35609,7 @@ var init_default_pages = __esm({
|
|
|
35609
35609
|
|
|
35610
35610
|
// ../adapter/src/paths.ts
|
|
35611
35611
|
import { resolve as resolve11, sep as sep2 } from "node:path";
|
|
35612
|
-
import { existsSync as existsSync12, statSync as
|
|
35612
|
+
import { existsSync as existsSync12, statSync as statSync5, readFileSync as readFileSync14 } from "node:fs";
|
|
35613
35613
|
function resolveWithin(baseDir, relPath) {
|
|
35614
35614
|
const base = resolve11(baseDir);
|
|
35615
35615
|
const target = resolve11(baseDir, relPath);
|
|
@@ -35628,7 +35628,7 @@ function installMdReadHook(publicDirs) {
|
|
|
35628
35628
|
if (!abs) continue;
|
|
35629
35629
|
const lower2 = abs.toLowerCase();
|
|
35630
35630
|
if (!lower2.endsWith(".md") && !lower2.endsWith(".markdown")) continue;
|
|
35631
|
-
if (existsSync12(abs) &&
|
|
35631
|
+
if (existsSync12(abs) && statSync5(abs).isFile()) return readFileSync14(abs, "utf8");
|
|
35632
35632
|
} catch {
|
|
35633
35633
|
}
|
|
35634
35634
|
}
|
|
@@ -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 readdirSync4,
|
|
35649
|
+
statSync as statSync7,
|
|
35650
|
+
existsSync as existsSync15,
|
|
35651
|
+
writeFileSync as writeFileSync7,
|
|
35652
|
+
rmSync as rmSync2,
|
|
35653
|
+
readFileSync as readFileSync17
|
|
35654
|
+
} from "node:fs";
|
|
35655
|
+
import { resolve as resolve13, join as join11, 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 readdirSync4(srcDir)) {
|
|
35664
|
+
const srcPath = join11(srcDir, entry);
|
|
35665
|
+
const destPath = join11(destDir, entry);
|
|
35666
|
+
if (statSync7(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 = readFileSync17(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 readdirSync4(d)) {
|
|
35711
|
+
const full = join11(d, entry);
|
|
35712
|
+
const rel = prefix ? `${prefix}/${entry}` : entry;
|
|
35713
|
+
if (statSync7(full).isDirectory()) {
|
|
35714
|
+
walk9(full, rel);
|
|
35715
|
+
} else {
|
|
35716
|
+
out.push({ rel, buffer: readFileSync17(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 readFileSync19,
|
|
35779
|
+
writeFileSync as writeFileSync8,
|
|
35780
|
+
existsSync as existsSync17,
|
|
35781
|
+
mkdirSync as mkdirSync7,
|
|
35782
|
+
statSync as statSync9
|
|
35669
35783
|
} from "node:fs";
|
|
35670
|
-
import { resolve as
|
|
35784
|
+
import { resolve as resolve15, dirname as dirname12, join as join12, 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(readFileSync19(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 = join12(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 = join12(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(readFileSync19(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) && statSync9(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) && statSync9(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) && statSync9(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(readFileSync19(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 readdirSync5, statSync as statSync10, existsSync as existsSync18, writeFileSync as writeFileSync9, readFileSync as readFileSync20 } from "node:fs";
|
|
36699
|
+
import { resolve as resolve16, join as join13 } 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 = readdirSync5(src2);
|
|
36594
36708
|
for (const entry of entries) {
|
|
36595
|
-
const srcPath =
|
|
36596
|
-
const destPath =
|
|
36597
|
-
const st =
|
|
36709
|
+
const srcPath = join13(src2, entry);
|
|
36710
|
+
const destPath = join13(dest, entry);
|
|
36711
|
+
const st = statSync10(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 = readFileSync20(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 readFileSync21, existsSync as existsSync19, readdirSync as readdirSync6, statSync as statSync11 } 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 join14 } 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(statSync11(entry).mtimeMs);
|
|
36855
|
+
return join14(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(readFileSync21(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 = readFileSync21(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, readFileSync21(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 = readdirSync6(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 = statSync11(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 = readFileSync21(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 readFileSync22, existsSync as existsSync20, readdirSync as readdirSync7, statSync as statSync12 } 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 = readdirSync7(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 = statSync12(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 = readFileSync22(pagePath, "utf-8");
|
|
37066
|
+
const layoutSrc = existsSync20(layoutPath) ? readFileSync22(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 join15 } 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, join15(base, "dist")]) {
|
|
37286
|
+
if (existsSync21(join15(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
|
|
|
@@ -42307,8 +42307,8 @@ __export(typecheck_exports, {
|
|
|
42307
42307
|
formatTypecheckWarnings: () => formatTypecheckWarnings,
|
|
42308
42308
|
typecheckProject: () => typecheckProject
|
|
42309
42309
|
});
|
|
42310
|
-
import { readFileSync as
|
|
42311
|
-
import { join as
|
|
42310
|
+
import { readFileSync as readFileSync41, readdirSync as readdirSync15, statSync as statSync23 } from "node:fs";
|
|
42311
|
+
import { join as join28, dirname as dirname27, normalize, relative as relative8, resolve as resolve39, sep as sep7 } from "node:path";
|
|
42312
42312
|
import * as ts8 from "typescript";
|
|
42313
42313
|
function walkProjectFiles(projectRoot) {
|
|
42314
42314
|
const code = [];
|
|
@@ -42316,15 +42316,15 @@ function walkProjectFiles(projectRoot) {
|
|
|
42316
42316
|
const walk9 = (dir) => {
|
|
42317
42317
|
let entries = [];
|
|
42318
42318
|
try {
|
|
42319
|
-
entries =
|
|
42319
|
+
entries = readdirSync15(dir);
|
|
42320
42320
|
} catch {
|
|
42321
42321
|
return;
|
|
42322
42322
|
}
|
|
42323
42323
|
for (const e of entries) {
|
|
42324
|
-
const p =
|
|
42324
|
+
const p = join28(dir, e);
|
|
42325
42325
|
let st;
|
|
42326
42326
|
try {
|
|
42327
|
-
st =
|
|
42327
|
+
st = statSync23(p);
|
|
42328
42328
|
} catch {
|
|
42329
42329
|
continue;
|
|
42330
42330
|
}
|
|
@@ -42376,8 +42376,8 @@ function checkStructureFile(appDir, file) {
|
|
|
42376
42376
|
return null;
|
|
42377
42377
|
}
|
|
42378
42378
|
function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
42379
|
-
const ambientPath =
|
|
42380
|
-
const overridePath =
|
|
42379
|
+
const ambientPath = join28(appDir, "__vesk_ambient.d.ts");
|
|
42380
|
+
const overridePath = join28(appDir, "__vesk_runtime_override.d.ts");
|
|
42381
42381
|
const cached = /* @__PURE__ */ new Map();
|
|
42382
42382
|
const scriptKindFor = (file) => file.endsWith(".vsk") ? ts8.ScriptKind.TSX : ts8.ScriptKind.TS;
|
|
42383
42383
|
const host = {
|
|
@@ -42447,7 +42447,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
42447
42447
|
directoryExists: (dir) => ts8.sys.directoryExists(dir),
|
|
42448
42448
|
getDirectories: (dir) => {
|
|
42449
42449
|
try {
|
|
42450
|
-
return
|
|
42450
|
+
return readdirSync15(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join28(dir, d.name));
|
|
42451
42451
|
} catch {
|
|
42452
42452
|
return [];
|
|
42453
42453
|
}
|
|
@@ -42459,7 +42459,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
42459
42459
|
return moduleLiterals.map(({ text }) => {
|
|
42460
42460
|
if (text.endsWith(".vsk")) {
|
|
42461
42461
|
const aliased = text.startsWith(".") ? null : resolveAliasModule(text, dirname27(containingFile));
|
|
42462
|
-
const abs = normalize(aliased ??
|
|
42462
|
+
const abs = normalize(aliased ?? join28(dirname27(containingFile), text));
|
|
42463
42463
|
return {
|
|
42464
42464
|
resolvedModule: {
|
|
42465
42465
|
resolvedFileName: abs + ".d.ts",
|
|
@@ -42470,7 +42470,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
42470
42470
|
};
|
|
42471
42471
|
}
|
|
42472
42472
|
if (text.endsWith(".css")) {
|
|
42473
|
-
const abs = normalize(
|
|
42473
|
+
const abs = normalize(join28(dirname27(containingFile), text));
|
|
42474
42474
|
return {
|
|
42475
42475
|
resolvedModule: {
|
|
42476
42476
|
resolvedFileName: abs + ".d.ts",
|
|
@@ -42517,7 +42517,7 @@ function sourcePosition(source, offset2) {
|
|
|
42517
42517
|
return { line, character: bounded - lineStart + 1 };
|
|
42518
42518
|
}
|
|
42519
42519
|
function typecheckProject(projectRoot, opts = {}) {
|
|
42520
|
-
const appDir = opts.appDir ??
|
|
42520
|
+
const appDir = opts.appDir ?? join28(projectRoot, "app");
|
|
42521
42521
|
const vskFiles = /* @__PURE__ */ new Map();
|
|
42522
42522
|
const parseErrors = [];
|
|
42523
42523
|
const warnings = [];
|
|
@@ -42539,7 +42539,7 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
42539
42539
|
}
|
|
42540
42540
|
}
|
|
42541
42541
|
if (f.endsWith(".vsk")) {
|
|
42542
|
-
const src2 =
|
|
42542
|
+
const src2 = readFileSync41(f, "utf-8");
|
|
42543
42543
|
try {
|
|
42544
42544
|
parse4(src2);
|
|
42545
42545
|
} catch (e) {
|
|
@@ -42556,8 +42556,8 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
42556
42556
|
}
|
|
42557
42557
|
rootNames.push(f);
|
|
42558
42558
|
}
|
|
42559
|
-
const ambientPath =
|
|
42560
|
-
const overridePath =
|
|
42559
|
+
const ambientPath = join28(appDir, "__vesk_ambient.d.ts");
|
|
42560
|
+
const overridePath = join28(appDir, "__vesk_runtime_override.d.ts");
|
|
42561
42561
|
rootNames.push(ambientPath);
|
|
42562
42562
|
rootNames.push(overridePath);
|
|
42563
42563
|
const options = {
|
|
@@ -48678,8 +48678,8 @@ __export(codemods_exports, {
|
|
|
48678
48678
|
applicableCodemods: () => applicableCodemods,
|
|
48679
48679
|
compareCore: () => compareCore
|
|
48680
48680
|
});
|
|
48681
|
-
import { readFileSync as
|
|
48682
|
-
import { join as
|
|
48681
|
+
import { readFileSync as readFileSync42, existsSync as existsSync43 } from "node:fs";
|
|
48682
|
+
import { join as join29 } from "node:path";
|
|
48683
48683
|
import { walk as walk8 } from "zimmerframe";
|
|
48684
48684
|
function safeParse(source, filePath) {
|
|
48685
48685
|
try {
|
|
@@ -48699,12 +48699,12 @@ function isVskFile(filePath) {
|
|
|
48699
48699
|
}
|
|
48700
48700
|
function typesPackageExports(projectDir) {
|
|
48701
48701
|
const candidates = [
|
|
48702
|
-
projectDir ?
|
|
48702
|
+
projectDir ? join29(projectDir, "node_modules", "@vesk", "types", "dist", "index.d.ts") : null,
|
|
48703
48703
|
new URL("../../types/dist/index.d.ts", import.meta.url).pathname
|
|
48704
48704
|
].filter((p) => typeof p === "string" && existsSync43(p));
|
|
48705
48705
|
for (const path of candidates) {
|
|
48706
48706
|
try {
|
|
48707
|
-
const src2 =
|
|
48707
|
+
const src2 = readFileSync42(path, "utf-8");
|
|
48708
48708
|
const names = /* @__PURE__ */ new Set();
|
|
48709
48709
|
for (const line of src2.split("\n")) {
|
|
48710
48710
|
const m = /^export\s+(?:declare\s+)?(?:abstract\s+)?(?:interface|class|type|enum|const|function|let|var|namespace)\s+([A-Za-z_$][\w$]*)/.exec(line);
|
|
@@ -48828,14 +48828,14 @@ __export(migrate_exports, {
|
|
|
48828
48828
|
detectInstalledVersion: () => detectInstalledVersion,
|
|
48829
48829
|
runMigrate: () => runMigrate
|
|
48830
48830
|
});
|
|
48831
|
-
import { readFileSync as
|
|
48832
|
-
import { join as
|
|
48831
|
+
import { readFileSync as readFileSync43, writeFileSync as writeFileSync22, existsSync as existsSync44, statSync as statSync24, readdirSync as readdirSync16 } from "node:fs";
|
|
48832
|
+
import { join as join30, 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
|
-
const p =
|
|
48835
|
+
const p = join30(projectDir, "node_modules", pkg, "package.json");
|
|
48836
48836
|
if (!existsSync44(p)) continue;
|
|
48837
48837
|
try {
|
|
48838
|
-
const version2 = JSON.parse(
|
|
48838
|
+
const version2 = JSON.parse(readFileSync43(p, "utf-8")).version;
|
|
48839
48839
|
if (typeof version2 === "string" && version2) return { version: version2, source: pkg };
|
|
48840
48840
|
} catch {
|
|
48841
48841
|
}
|
|
@@ -48846,22 +48846,22 @@ function collectTargets(dir, root3 = dir) {
|
|
|
48846
48846
|
const out = [];
|
|
48847
48847
|
let entries;
|
|
48848
48848
|
try {
|
|
48849
|
-
entries =
|
|
48849
|
+
entries = readdirSync16(dir);
|
|
48850
48850
|
} catch {
|
|
48851
48851
|
return out;
|
|
48852
48852
|
}
|
|
48853
48853
|
for (const entry of entries.sort()) {
|
|
48854
48854
|
if (SKIP_DIRS2.has(entry)) continue;
|
|
48855
|
-
const full =
|
|
48855
|
+
const full = join30(dir, entry);
|
|
48856
48856
|
let st;
|
|
48857
48857
|
try {
|
|
48858
|
-
st =
|
|
48858
|
+
st = statSync24(full);
|
|
48859
48859
|
} catch {
|
|
48860
48860
|
continue;
|
|
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
|
}
|
|
@@ -48887,12 +48887,12 @@ function runMigrate(options) {
|
|
|
48887
48887
|
return report;
|
|
48888
48888
|
}
|
|
48889
48889
|
for (const relPath of collectTargets(options.projectDir)) {
|
|
48890
|
-
const abs =
|
|
48890
|
+
const abs = join30(options.projectDir, relPath);
|
|
48891
48891
|
const ctx2 = { filePath: abs, displayPath: relPath, projectDir: options.projectDir };
|
|
48892
48892
|
if (!existsSync44(abs)) continue;
|
|
48893
48893
|
let source;
|
|
48894
48894
|
try {
|
|
48895
|
-
source =
|
|
48895
|
+
source = readFileSync43(abs, "utf-8");
|
|
48896
48896
|
} catch (e) {
|
|
48897
48897
|
report.skipped.push(`${relPath}: unreadable (${e.message})`);
|
|
48898
48898
|
continue;
|
|
@@ -48932,8 +48932,8 @@ var init_migrate = __esm({
|
|
|
48932
48932
|
});
|
|
48933
48933
|
|
|
48934
48934
|
// src/index.ts
|
|
48935
|
-
import { readFileSync as
|
|
48936
|
-
import { resolve as resolve40, join as
|
|
48935
|
+
import { readFileSync as readFileSync44, writeFileSync as writeFileSync23, mkdirSync as mkdirSync20, existsSync as existsSync45 } from "fs";
|
|
48936
|
+
import { resolve as resolve40, join as join31 } from "path";
|
|
48937
48937
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
48938
48938
|
|
|
48939
48939
|
// ../adapter/dist/load-config.js
|
|
@@ -49511,8 +49511,8 @@ function setRuntimeModule2(mod) {
|
|
|
49511
49511
|
}
|
|
49512
49512
|
|
|
49513
49513
|
// ../adapter/dist/index.js
|
|
49514
|
-
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as
|
|
49515
|
-
import { resolve as resolve21, dirname as dirname16, relative as relative4, basename as basename3, join as
|
|
49514
|
+
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as readFileSync23 } from "node:fs";
|
|
49515
|
+
import { resolve as resolve21, dirname as dirname16, relative as relative4, basename as basename3, join as join16 } from "node:path";
|
|
49516
49516
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
49517
49517
|
|
|
49518
49518
|
// ../adapter/src/runtime-bundle.ts
|
|
@@ -51013,8 +51013,8 @@ async function compileEvents(appDir, outDir) {
|
|
|
51013
51013
|
|
|
51014
51014
|
// ../adapter/src/client-bundle.ts
|
|
51015
51015
|
init_esbuild_fallback();
|
|
51016
|
-
import { readFileSync as
|
|
51017
|
-
import { resolve as resolve10, join as
|
|
51016
|
+
import { readFileSync as readFileSync13, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync4, rmSync, mkdtempSync, mkdirSync as mkdirSync3 } from "node:fs";
|
|
51017
|
+
import { resolve as resolve10, join as join8, dirname as dirname8, relative as relative2, sep } from "node:path";
|
|
51018
51018
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
51019
51019
|
import { tmpdir } from "node:os";
|
|
51020
51020
|
init_strip_ts();
|
|
@@ -51024,6 +51024,267 @@ init_vsk_collision();
|
|
|
51024
51024
|
init_vsk_imports();
|
|
51025
51025
|
init_md_inline();
|
|
51026
51026
|
init_module_imports();
|
|
51027
|
+
|
|
51028
|
+
// ../adapter/src/server-only-plugin.ts
|
|
51029
|
+
init_parser();
|
|
51030
|
+
import { readFileSync as readFileSync12 } from "node:fs";
|
|
51031
|
+
|
|
51032
|
+
// ../adapter/src/server-only.ts
|
|
51033
|
+
init_parser();
|
|
51034
|
+
import { readFileSync as readFileSync11, readdirSync as readdirSync2, statSync as statSync3 } from "node:fs";
|
|
51035
|
+
import { join as join7 } from "node:path";
|
|
51036
|
+
var SERVER_ONLY_EXACT = /* @__PURE__ */ new Set([
|
|
51037
|
+
"slintorm",
|
|
51038
|
+
"@vesk/adapter"
|
|
51039
|
+
]);
|
|
51040
|
+
var TCP_DRIVERS = /* @__PURE__ */ new Set([
|
|
51041
|
+
"pg",
|
|
51042
|
+
"mysql2",
|
|
51043
|
+
"mongodb",
|
|
51044
|
+
"node:sqlite",
|
|
51045
|
+
"node:net",
|
|
51046
|
+
"node:tls"
|
|
51047
|
+
]);
|
|
51048
|
+
function classifySpecifier(spec) {
|
|
51049
|
+
if (typeof spec !== "string" || spec.length === 0) return null;
|
|
51050
|
+
if (TCP_DRIVERS.has(spec)) return "tcp-driver";
|
|
51051
|
+
if (spec.startsWith("node:")) return "tcp-driver";
|
|
51052
|
+
if (SERVER_ONLY_EXACT.has(spec)) return "server-only-package";
|
|
51053
|
+
return null;
|
|
51054
|
+
}
|
|
51055
|
+
var REMEDY = {
|
|
51056
|
+
"server-only-package": "import it from an API route (app/api/**/route.ts) or a server action instead of a component, or use the package's browser/edge entry point if it ships one.",
|
|
51057
|
+
"tcp-driver": 'this driver opens a TCP socket, which no edge runtime provides. Use the driver\'s HTTP/HTTPS transport (for SlintORM: `driver: "postgrest"`), or build for a Node target.'
|
|
51058
|
+
};
|
|
51059
|
+
function scanServerOnlyImports(files) {
|
|
51060
|
+
const out = [];
|
|
51061
|
+
for (const file of files) {
|
|
51062
|
+
let ast;
|
|
51063
|
+
try {
|
|
51064
|
+
ast = parse4(file.code);
|
|
51065
|
+
} catch {
|
|
51066
|
+
continue;
|
|
51067
|
+
}
|
|
51068
|
+
for (const node of ast.body ?? []) {
|
|
51069
|
+
if (node?.type !== "ImportDeclaration" && node?.type !== "ExportNamedDeclaration" && node?.type !== "ExportAllDeclaration") continue;
|
|
51070
|
+
const spec = node.source?.value;
|
|
51071
|
+
if (typeof spec !== "string") continue;
|
|
51072
|
+
const kind = classifySpecifier(spec);
|
|
51073
|
+
if (!kind) continue;
|
|
51074
|
+
out.push({
|
|
51075
|
+
kind,
|
|
51076
|
+
specifier: spec,
|
|
51077
|
+
file: file.path,
|
|
51078
|
+
line: lineOf(file.code, node.start),
|
|
51079
|
+
remedy: REMEDY[kind]
|
|
51080
|
+
});
|
|
51081
|
+
}
|
|
51082
|
+
}
|
|
51083
|
+
return out;
|
|
51084
|
+
}
|
|
51085
|
+
function lineOf(code, offset2) {
|
|
51086
|
+
if (typeof offset2 !== "number" || offset2 < 0 || offset2 > code.length) return null;
|
|
51087
|
+
let line = 1;
|
|
51088
|
+
for (let i = 0; i < offset2; i++) {
|
|
51089
|
+
if (code.charCodeAt(i) === 10) line++;
|
|
51090
|
+
}
|
|
51091
|
+
return line;
|
|
51092
|
+
}
|
|
51093
|
+
function edgeDriverBuildError(violations) {
|
|
51094
|
+
const detail = violations.map((v) => ` ${v.file}${v.line ? `:${v.line}` : ""} \u2014 import "${v.specifier}"
|
|
51095
|
+
${v.remedy}`).join("\n");
|
|
51096
|
+
return new Error(
|
|
51097
|
+
`[vesk] edge-targeted build cannot include a TCP-only driver (${violations.length} found).
|
|
51098
|
+
${detail}
|
|
51099
|
+
|
|
51100
|
+
This was a build error rather than a runtime one because an edge runtime has no socket: the deployed function would fail on its first query.`
|
|
51101
|
+
);
|
|
51102
|
+
}
|
|
51103
|
+
var SOCKETLESS_PLATFORMS = /* @__PURE__ */ new Set(["edge", "cloudflare", "deno", "coxmos"]);
|
|
51104
|
+
function isSocketlessTarget(platform, target) {
|
|
51105
|
+
if (target === "edge") return true;
|
|
51106
|
+
return typeof platform === "string" && SOCKETLESS_PLATFORMS.has(platform);
|
|
51107
|
+
}
|
|
51108
|
+
var SOURCE_EXTENSIONS = [".vsk", ".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
51109
|
+
var SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".vesk", ".git", "dist", ".next", ".output", "coverage"]);
|
|
51110
|
+
function collectAppSources(dir, out = []) {
|
|
51111
|
+
let entries;
|
|
51112
|
+
try {
|
|
51113
|
+
entries = readdirSync2(dir);
|
|
51114
|
+
} catch {
|
|
51115
|
+
return out;
|
|
51116
|
+
}
|
|
51117
|
+
for (const entry of entries) {
|
|
51118
|
+
if (SKIPPED_DIRS.has(entry) || entry.startsWith(".")) continue;
|
|
51119
|
+
const full = join7(dir, entry);
|
|
51120
|
+
let st;
|
|
51121
|
+
try {
|
|
51122
|
+
st = statSync3(full);
|
|
51123
|
+
} catch {
|
|
51124
|
+
continue;
|
|
51125
|
+
}
|
|
51126
|
+
if (st.isDirectory()) collectAppSources(full, out);
|
|
51127
|
+
else if (st.isFile()) {
|
|
51128
|
+
const dot = entry.lastIndexOf(".");
|
|
51129
|
+
if (dot === -1) continue;
|
|
51130
|
+
if (SOURCE_EXTENSIONS.includes(entry.slice(dot).toLowerCase())) out.push(full);
|
|
51131
|
+
}
|
|
51132
|
+
}
|
|
51133
|
+
return out;
|
|
51134
|
+
}
|
|
51135
|
+
function tcpDriverViolations(appDir) {
|
|
51136
|
+
const files = [];
|
|
51137
|
+
for (const path of collectAppSources(appDir)) {
|
|
51138
|
+
try {
|
|
51139
|
+
files.push({ path, code: readFileSync11(path, "utf-8") });
|
|
51140
|
+
} catch {
|
|
51141
|
+
}
|
|
51142
|
+
}
|
|
51143
|
+
return scanServerOnlyImports(files).filter((v) => v.kind === "tcp-driver");
|
|
51144
|
+
}
|
|
51145
|
+
|
|
51146
|
+
// ../adapter/src/server-only-plugin.ts
|
|
51147
|
+
var STUB_NAMESPACE = "vesk-server-only";
|
|
51148
|
+
var stubCounter = 0;
|
|
51149
|
+
function importedNamesFor(code, specifier) {
|
|
51150
|
+
let ast;
|
|
51151
|
+
try {
|
|
51152
|
+
ast = parse4(code);
|
|
51153
|
+
} catch {
|
|
51154
|
+
return [];
|
|
51155
|
+
}
|
|
51156
|
+
const names = [];
|
|
51157
|
+
const sourceOf = (node) => {
|
|
51158
|
+
const src2 = node.source;
|
|
51159
|
+
if (typeof src2 === "string") return src2;
|
|
51160
|
+
const v = src2?.value;
|
|
51161
|
+
return typeof v === "string" ? v : null;
|
|
51162
|
+
};
|
|
51163
|
+
for (const node of ast.body ?? []) {
|
|
51164
|
+
if (node?.type === "ImportDeclaration") {
|
|
51165
|
+
if (sourceOf(node) !== specifier) continue;
|
|
51166
|
+
for (const spec of node.specifiers ?? []) {
|
|
51167
|
+
if (spec.type === "ImportNamespaceSpecifier") continue;
|
|
51168
|
+
const local = spec.local?.name;
|
|
51169
|
+
if (typeof local === "string" && !names.includes(local)) names.push(local);
|
|
51170
|
+
}
|
|
51171
|
+
continue;
|
|
51172
|
+
}
|
|
51173
|
+
if (node?.type === "ExportAllDeclaration" || node?.type === "ExportNamedDeclaration") {
|
|
51174
|
+
if (sourceOf(node) !== specifier) continue;
|
|
51175
|
+
for (const spec of node.specifiers ?? []) {
|
|
51176
|
+
const imported = spec.imported?.name ?? spec.imported?.value ?? spec.local?.name;
|
|
51177
|
+
if (typeof imported === "string" && !names.includes(imported)) names.push(imported);
|
|
51178
|
+
}
|
|
51179
|
+
}
|
|
51180
|
+
}
|
|
51181
|
+
return names;
|
|
51182
|
+
}
|
|
51183
|
+
function stubFactorySource(specifier) {
|
|
51184
|
+
const template2 = '"$1" comes from "$0", which is server-only. It reached the browser bundle because a component (or a module one imports) imported it \u2014 component code runs in the browser, where this module cannot work. Move the server-only work into an API route (app/api/**/route.ts) or a server action and call it over HTTP, or import the edge/browser-safe entry if the package ships one.';
|
|
51185
|
+
return [
|
|
51186
|
+
"function __vesk_stub(binding) {",
|
|
51187
|
+
" var message = " + JSON.stringify(template2) + ";",
|
|
51188
|
+
' message = message.replace("$0", ' + JSON.stringify(specifier) + ').replace("$1", String(binding));',
|
|
51189
|
+
" var thrower = function () { throw Object.assign(new Error(message), { __veskServerOnly: " + JSON.stringify(specifier) + " }); };",
|
|
51190
|
+
" return new Proxy(function () {}, {",
|
|
51191
|
+
" get: thrower,",
|
|
51192
|
+
" apply: thrower,",
|
|
51193
|
+
" construct: thrower",
|
|
51194
|
+
" });",
|
|
51195
|
+
"}"
|
|
51196
|
+
].join("\n");
|
|
51197
|
+
}
|
|
51198
|
+
function referencedAtTopLevel(code, name) {
|
|
51199
|
+
let ast;
|
|
51200
|
+
try {
|
|
51201
|
+
ast = parse4(code);
|
|
51202
|
+
} catch {
|
|
51203
|
+
return true;
|
|
51204
|
+
}
|
|
51205
|
+
let found = false;
|
|
51206
|
+
const FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
51207
|
+
"FunctionDeclaration",
|
|
51208
|
+
"FunctionExpression",
|
|
51209
|
+
"ArrowFunctionExpression",
|
|
51210
|
+
"ClassMethod",
|
|
51211
|
+
"ObjectMethod",
|
|
51212
|
+
"ClassDeclaration",
|
|
51213
|
+
"ClassExpression"
|
|
51214
|
+
]);
|
|
51215
|
+
const SKIP_KEYS = /* @__PURE__ */ new Set(["type", "start", "end", "loc", "range", "raw", "regex"]);
|
|
51216
|
+
const SKIP_EXPORT_NAMED_KEYS = /* @__PURE__ */ new Set([...SKIP_KEYS, "source", "specifiers", "exportKind", "attributes"]);
|
|
51217
|
+
const visit = (node, parentKey, fnDepth) => {
|
|
51218
|
+
if (found || node === null || typeof node !== "object") return;
|
|
51219
|
+
if (Array.isArray(node)) {
|
|
51220
|
+
for (const child of node) visit(child, parentKey, fnDepth);
|
|
51221
|
+
return;
|
|
51222
|
+
}
|
|
51223
|
+
const n = node;
|
|
51224
|
+
if (n.type === "MemberExpression" || n.type === "Property" || n.type === "PropertyDefinition" || n.type === "MethodDefinition") {
|
|
51225
|
+
const prop = n.property ?? n.key;
|
|
51226
|
+
if (prop && typeof prop === "object" && prop.name === name && n.computed !== true) return;
|
|
51227
|
+
}
|
|
51228
|
+
if (n.type === "ImportDeclaration" || n.type === "ExportAllDeclaration" || n.type === "ImportExpression") return;
|
|
51229
|
+
if (n.type === "Identifier" && n.name === name) {
|
|
51230
|
+
if (parentKey === "local" || parentKey === "id" || parentKey === "params" || parentKey === "key") return;
|
|
51231
|
+
if (fnDepth === 0) found = true;
|
|
51232
|
+
return;
|
|
51233
|
+
}
|
|
51234
|
+
const skip = n.type === "ExportNamedDeclaration" ? SKIP_EXPORT_NAMED_KEYS : SKIP_KEYS;
|
|
51235
|
+
const nextDepth = FUNCTION_TYPES.has(String(n.type)) ? fnDepth + 1 : fnDepth;
|
|
51236
|
+
for (const [key, value] of Object.entries(n)) {
|
|
51237
|
+
if (skip.has(key)) continue;
|
|
51238
|
+
visit(value, key, nextDepth);
|
|
51239
|
+
}
|
|
51240
|
+
};
|
|
51241
|
+
visit(ast.body, void 0, 0);
|
|
51242
|
+
return found;
|
|
51243
|
+
}
|
|
51244
|
+
function serverOnlyPlugin(options = {}) {
|
|
51245
|
+
const stubs = /* @__PURE__ */ new Map();
|
|
51246
|
+
return {
|
|
51247
|
+
name: "vesk-server-only",
|
|
51248
|
+
setup(build4) {
|
|
51249
|
+
build4.onResolve({ filter: /.*/ }, (args2) => {
|
|
51250
|
+
const kind = classifySpecifier(args2.path);
|
|
51251
|
+
if (!kind) return null;
|
|
51252
|
+
if (kind === "tcp-driver") {
|
|
51253
|
+
options.onDriver?.({ specifier: args2.path, importer: args2.importer });
|
|
51254
|
+
return null;
|
|
51255
|
+
}
|
|
51256
|
+
let names = [];
|
|
51257
|
+
let importerCode = "";
|
|
51258
|
+
try {
|
|
51259
|
+
importerCode = readFileSync12(args2.importer, "utf-8");
|
|
51260
|
+
names = importedNamesFor(importerCode, args2.path);
|
|
51261
|
+
} catch {
|
|
51262
|
+
}
|
|
51263
|
+
const eager = names.filter((n) => referencedAtTopLevel(importerCode, n));
|
|
51264
|
+
if (eager.length > 0) {
|
|
51265
|
+
options.onEager?.({ specifier: args2.path, bindings: eager, importer: args2.importer });
|
|
51266
|
+
return null;
|
|
51267
|
+
}
|
|
51268
|
+
const id = `vesk-stub-${stubCounter++}`;
|
|
51269
|
+
stubs.set(id, [
|
|
51270
|
+
stubFactorySource(args2.path),
|
|
51271
|
+
'export default __vesk_stub("default");',
|
|
51272
|
+
...names.map((n) => `export const ${n} = __vesk_stub(${JSON.stringify(n)});`)
|
|
51273
|
+
].join("\n"));
|
|
51274
|
+
for (const binding of names) {
|
|
51275
|
+
options.onStub?.({ specifier: args2.path, binding, importer: args2.importer });
|
|
51276
|
+
}
|
|
51277
|
+
return { path: id, namespace: STUB_NAMESPACE };
|
|
51278
|
+
});
|
|
51279
|
+
build4.onLoad({ filter: /.*/, namespace: STUB_NAMESPACE }, (args2) => ({
|
|
51280
|
+
contents: stubs.get(args2.path) ?? stubFactorySource("unknown"),
|
|
51281
|
+
loader: "js"
|
|
51282
|
+
}));
|
|
51283
|
+
}
|
|
51284
|
+
};
|
|
51285
|
+
}
|
|
51286
|
+
|
|
51287
|
+
// ../adapter/src/client-bundle.ts
|
|
51027
51288
|
import { availableParallelism } from "node:os";
|
|
51028
51289
|
async function mapWithConcurrency(items, limit, fn) {
|
|
51029
51290
|
const out = new Array(items.length);
|
|
@@ -51051,7 +51312,7 @@ async function mapWithConcurrency(items, limit, fn) {
|
|
|
51051
51312
|
var __dirname3 = dirname8(fileURLToPath2(import.meta.url));
|
|
51052
51313
|
function fileUnchanged(filePath, cached) {
|
|
51053
51314
|
try {
|
|
51054
|
-
const st =
|
|
51315
|
+
const st = statSync4(filePath);
|
|
51055
51316
|
return st.mtimeMs === cached.mtimeMs && st.size === cached.size;
|
|
51056
51317
|
} catch {
|
|
51057
51318
|
return false;
|
|
@@ -51072,8 +51333,8 @@ function findRuntimeSrc2(appDir) {
|
|
|
51072
51333
|
resolve10(appDir, "node_modules", "@vesk/runtime")
|
|
51073
51334
|
];
|
|
51074
51335
|
for (const base of candidates) {
|
|
51075
|
-
for (const dir of [base,
|
|
51076
|
-
if (existsSync11(
|
|
51336
|
+
for (const dir of [base, join8(base, "dist")]) {
|
|
51337
|
+
if (existsSync11(join8(dir, "index-client.js"))) return dir;
|
|
51077
51338
|
}
|
|
51078
51339
|
}
|
|
51079
51340
|
throw new Error('@vesk/runtime/dist not found \u2014 run "npm run build" first');
|
|
@@ -51179,6 +51440,17 @@ function nativeLibraryImportStubs(code) {
|
|
|
51179
51440
|
});
|
|
51180
51441
|
return lines.join("\n") + "\n\n";
|
|
51181
51442
|
}
|
|
51443
|
+
function reportServerOnlyImports(chunkName, hits, strict) {
|
|
51444
|
+
const detail = [...new Set(hits.map((h) => `"${h.binding}" from "${h.specifier}"`))].join(", ");
|
|
51445
|
+
if (strict) {
|
|
51446
|
+
throw new Error(
|
|
51447
|
+
`[vesk] ${chunkName} imports a server-only package in client code: ${detail}. Move that work into an API route (app/api/**/route.ts) or a server action. Pass without --strict to allow it (the binding is replaced by a throwing stub).`
|
|
51448
|
+
);
|
|
51449
|
+
}
|
|
51450
|
+
console.error(
|
|
51451
|
+
`[vesk] ${chunkName}: removed server-only import from client code (${detail}). It is replaced by a stub that throws if the component calls it at runtime \u2014 server-only work belongs in an API route or a server action.`
|
|
51452
|
+
);
|
|
51453
|
+
}
|
|
51182
51454
|
function demoteExports(code) {
|
|
51183
51455
|
let ast;
|
|
51184
51456
|
try {
|
|
@@ -51209,7 +51481,7 @@ function chunkHasImports(headLen, mergeAborted) {
|
|
|
51209
51481
|
function runtimeImportsOf(filePath) {
|
|
51210
51482
|
let text;
|
|
51211
51483
|
try {
|
|
51212
|
-
text =
|
|
51484
|
+
text = readFileSync13(filePath, "utf8");
|
|
51213
51485
|
} catch {
|
|
51214
51486
|
return [];
|
|
51215
51487
|
}
|
|
@@ -51502,11 +51774,11 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
51502
51774
|
return removeCompiledNodes(code, isVskImport);
|
|
51503
51775
|
}
|
|
51504
51776
|
function resolveVskImports(filePath, compile) {
|
|
51505
|
-
const src2 =
|
|
51777
|
+
const src2 = readFileSync13(filePath, "utf-8");
|
|
51506
51778
|
const resolved = [];
|
|
51507
51779
|
for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
|
|
51508
51780
|
try {
|
|
51509
|
-
|
|
51781
|
+
readFileSync13(importPath);
|
|
51510
51782
|
} catch {
|
|
51511
51783
|
continue;
|
|
51512
51784
|
}
|
|
@@ -51564,7 +51836,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
51564
51836
|
compiledFiles++;
|
|
51565
51837
|
__stats.compiled++;
|
|
51566
51838
|
__stats.distinct.add(filePath);
|
|
51567
|
-
let src2 =
|
|
51839
|
+
let src2 = readFileSync13(filePath, "utf-8");
|
|
51568
51840
|
if (/content=["'][^"']*\.md["']/i.test(src2)) {
|
|
51569
51841
|
src2 = inlineMdContentAttrs(src2, dirname8(filePath), guessProjectRoots(appDir));
|
|
51570
51842
|
}
|
|
@@ -51599,7 +51871,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
51599
51871
|
}
|
|
51600
51872
|
for (const reexportPath of reexportPaths || []) compileFile2(reexportPath, null, output, imports);
|
|
51601
51873
|
if (cache2 && namesBefore) {
|
|
51602
|
-
const st =
|
|
51874
|
+
const st = statSync4(filePath);
|
|
51603
51875
|
cache2.files.set(filePath, {
|
|
51604
51876
|
mtimeMs: st.mtimeMs,
|
|
51605
51877
|
size: st.size,
|
|
@@ -51725,9 +51997,9 @@ ${body}
|
|
|
51725
51997
|
let sharedBundleCode = "";
|
|
51726
51998
|
const sharedRuntimeNames = /* @__PURE__ */ new Set();
|
|
51727
51999
|
if (sharedSources.length > 0) {
|
|
51728
|
-
const tmpBase = mkdtempSync(
|
|
52000
|
+
const tmpBase = mkdtempSync(join8(resolve10(appDir, ".."), "tmp-vesk-shared-"));
|
|
51729
52001
|
try {
|
|
51730
|
-
const sharedEntry =
|
|
52002
|
+
const sharedEntry = join8(tmpBase, "shared-entry.js");
|
|
51731
52003
|
const lines = [];
|
|
51732
52004
|
const members = [];
|
|
51733
52005
|
sharedSources.forEach((source, i) => {
|
|
@@ -51737,7 +52009,7 @@ ${body}
|
|
|
51737
52009
|
lines.push(`globalThis.__veskShared = { ${members.join("\n")} };`);
|
|
51738
52010
|
writeFileSync4(sharedEntry, lines.join("\n"));
|
|
51739
52011
|
const appTsconfig = findTsconfigPath(appDir);
|
|
51740
|
-
const runtimeShim =
|
|
52012
|
+
const runtimeShim = join8(tmpBase, "runtime-shim.js");
|
|
51741
52013
|
const runtimeLines = [
|
|
51742
52014
|
"// ONE runtime instance: the entry bundle publishes these on globalThis,",
|
|
51743
52015
|
"// and route chunks import the same functions. A second bundled copy",
|
|
@@ -51777,7 +52049,7 @@ ${body}
|
|
|
51777
52049
|
bindings.named.forEach((n) => named.add(n));
|
|
51778
52050
|
hasDefault = hasDefault || bindings.hasDefault;
|
|
51779
52051
|
}
|
|
51780
|
-
const shim =
|
|
52052
|
+
const shim = join8(tmpBase, `shim-${i}.js`);
|
|
51781
52053
|
const shimLines = [`const m = globalThis.__veskShared[${JSON.stringify(source)}];`];
|
|
51782
52054
|
if (hasDefault) shimLines.push(`export default m;`);
|
|
51783
52055
|
for (const name of [...named].sort()) {
|
|
@@ -51805,13 +52077,21 @@ ${body}
|
|
|
51805
52077
|
if (!entry.code.trim()) return null;
|
|
51806
52078
|
let finalCode;
|
|
51807
52079
|
if (entry.imports) {
|
|
51808
|
-
const tmpBase = mkdtempSync(
|
|
51809
|
-
const tmpFile =
|
|
52080
|
+
const tmpBase = mkdtempSync(join8(resolve10(appDir, ".."), "tmp-vesk-chunk-"));
|
|
52081
|
+
const tmpFile = join8(tmpBase, "entry.js");
|
|
51810
52082
|
const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
|
|
51811
52083
|
const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
|
|
51812
52084
|
${entry.code}
|
|
51813
52085
|
`;
|
|
51814
52086
|
writeFileSync4(tmpFile, toBundle);
|
|
52087
|
+
const serverOnlyHits = [];
|
|
52088
|
+
const driverHits = [];
|
|
52089
|
+
const eagerHits = [];
|
|
52090
|
+
const serverOnlyGuard = serverOnlyPlugin({
|
|
52091
|
+
onStub: (hit) => serverOnlyHits.push(hit),
|
|
52092
|
+
onDriver: (hit) => driverHits.push(hit),
|
|
52093
|
+
onEager: (hit) => eagerHits.push(hit)
|
|
52094
|
+
});
|
|
51815
52095
|
try {
|
|
51816
52096
|
const appTsconfig = findTsconfigPath(appDir);
|
|
51817
52097
|
const result = await build({
|
|
@@ -51835,7 +52115,7 @@ ${entry.code}
|
|
|
51835
52115
|
// shared-modules.js serves every route chunk. (esbuild's `alias`
|
|
51836
52116
|
// option only accepts bare package names, so this is a resolver
|
|
51837
52117
|
// rather than a map.)
|
|
51838
|
-
...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin] } : {},
|
|
52118
|
+
...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin, serverOnlyGuard] } : { plugins: [serverOnlyGuard] },
|
|
51839
52119
|
...appTsconfig ? { tsconfig: appTsconfig } : {}
|
|
51840
52120
|
});
|
|
51841
52121
|
finalCode = result.outputFiles[0].text;
|
|
@@ -51857,6 +52137,24 @@ ${entry.code}
|
|
|
51857
52137
|
} catch {
|
|
51858
52138
|
}
|
|
51859
52139
|
}
|
|
52140
|
+
if (eagerHits.length > 0) {
|
|
52141
|
+
const detail = eagerHits.map((h) => `${h.importer} uses ${h.bindings.map((b) => `"${b}"`).join(", ")} from "${h.specifier}" at module scope`).join("; ");
|
|
52142
|
+
console.error("[vesk] server-only package used at module scope in client code", entry.name + ":", detail);
|
|
52143
|
+
throw new Error(
|
|
52144
|
+
`[vesk] ${entry.name}: ${detail}.
|
|
52145
|
+
A module-scope statement runs the moment the browser evaluates the chunk, so a server-only package cannot be substituted there. Move that work into an API route (app/api/**/route.ts) or a server action \u2014 if the binding is only used from inside a function, this build already handles it.`
|
|
52146
|
+
);
|
|
52147
|
+
}
|
|
52148
|
+
if (driverHits.length > 0) {
|
|
52149
|
+
const detail = [...new Set(driverHits.map((h) => `${h.specifier} (from ${h.importer})`))].join(", ");
|
|
52150
|
+
console.error("[vesk] chunk bundle contains a TCP-only driver", entry.name + ":", detail);
|
|
52151
|
+
throw new Error(
|
|
52152
|
+
`[vesk] ${entry.name} pulls a TCP-only driver into the browser bundle: ${detail}. A browser cannot open a socket. Import the package's edge/browser-safe entry if it ships one, or keep database access in an API route (app/api/**/route.ts) or a server action.`
|
|
52153
|
+
);
|
|
52154
|
+
}
|
|
52155
|
+
if (serverOnlyHits.length > 0) {
|
|
52156
|
+
reportServerOnlyImports(entry.name, serverOnlyHits, options?.strict);
|
|
52157
|
+
}
|
|
51860
52158
|
} else {
|
|
51861
52159
|
finalCode = chunkIIFE(demoteExports(entry.code));
|
|
51862
52160
|
}
|
|
@@ -51891,7 +52189,7 @@ ${entry.code}
|
|
|
51891
52189
|
let compileFileMono2 = function(filePath, resolvedName) {
|
|
51892
52190
|
if (seen.has(filePath)) return;
|
|
51893
52191
|
seen.add(filePath);
|
|
51894
|
-
const src2 =
|
|
52192
|
+
const src2 = readFileSync13(filePath, "utf-8");
|
|
51895
52193
|
resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
|
|
51896
52194
|
for (const cn of vskComponentNames(src2, filePath)) componentOwners.claim(cn, filePath);
|
|
51897
52195
|
const monoAlloc = nameAllocFor(filePath);
|
|
@@ -51973,9 +52271,9 @@ function buildRuntimeCode(runtimeDir) {
|
|
|
51973
52271
|
];
|
|
51974
52272
|
let code = "";
|
|
51975
52273
|
for (const f of runtimeFiles) {
|
|
51976
|
-
const p =
|
|
52274
|
+
const p = join8(runtimeDir, f);
|
|
51977
52275
|
if (existsSync11(p)) {
|
|
51978
|
-
let src2 =
|
|
52276
|
+
let src2 = readFileSync13(p, "utf-8");
|
|
51979
52277
|
src2 = stripTypes(src2);
|
|
51980
52278
|
src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
51981
52279
|
src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
@@ -51987,7 +52285,7 @@ ${src2}
|
|
|
51987
52285
|
`;
|
|
51988
52286
|
}
|
|
51989
52287
|
}
|
|
51990
|
-
const indexSrc =
|
|
52288
|
+
const indexSrc = readFileSync13(join8(runtimeDir, "index-client.js"), "utf-8");
|
|
51991
52289
|
const exportNames = stripTypes(indexSrc).match(/export\s*\{\s*([^}]+)\s*\}\s*from/g)?.flatMap((m) => m.replace(/export\s*\{\s*|\s*\}\s*from/g, "").split(",").map((s) => s.trim())) || [];
|
|
51992
52290
|
code += "// --- exports ---\n";
|
|
51993
52291
|
for (const name of [...new Set(exportNames)]) {
|
|
@@ -51997,7 +52295,7 @@ ${src2}
|
|
|
51997
52295
|
return code;
|
|
51998
52296
|
}
|
|
51999
52297
|
function runtimeExportNames(runtimeDir) {
|
|
52000
|
-
const indexSrc =
|
|
52298
|
+
const indexSrc = readFileSync13(join8(runtimeDir, "index-client.js"), "utf-8");
|
|
52001
52299
|
const names = /* @__PURE__ */ new Set();
|
|
52002
52300
|
for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
|
|
52003
52301
|
for (const raw2 of m[1].split(",")) {
|
|
@@ -52012,7 +52310,7 @@ function esbuildPath(p) {
|
|
|
52012
52310
|
return sep === "/" ? p : p.split(sep).join("/");
|
|
52013
52311
|
}
|
|
52014
52312
|
function runtimeTreeShakeEntry() {
|
|
52015
|
-
return
|
|
52313
|
+
return join8(tmpdir(), "vesk-runtime-tree-shake", RUNTIME_ENTRY);
|
|
52016
52314
|
}
|
|
52017
52315
|
var treeShakeQueue = Promise.resolve();
|
|
52018
52316
|
function buildTreeShakenRuntime(runtimeDir, usedNames) {
|
|
@@ -52035,7 +52333,7 @@ async function buildTreeShakenRuntimeNow(runtimeDir, usedNames) {
|
|
|
52035
52333
|
async function bundleRuntimeNames(runtimeDir, names, strict = false) {
|
|
52036
52334
|
if (names.length === 0) return null;
|
|
52037
52335
|
const entry = runtimeTreeShakeEntry();
|
|
52038
|
-
const indexClient = esbuildPath(
|
|
52336
|
+
const indexClient = esbuildPath(join8(runtimeDir, "index-client.js"));
|
|
52039
52337
|
const unique = [...new Set(names)];
|
|
52040
52338
|
try {
|
|
52041
52339
|
try {
|
|
@@ -52249,19 +52547,19 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
|
|
|
52249
52547
|
|
|
52250
52548
|
// ../adapter/src/static.ts
|
|
52251
52549
|
init_paths();
|
|
52252
|
-
import { mkdirSync as mkdirSync4, copyFileSync, readdirSync as
|
|
52253
|
-
import { resolve as resolve12, join as
|
|
52550
|
+
import { mkdirSync as mkdirSync4, copyFileSync, readdirSync as readdirSync3, statSync as statSync6, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync15 } from "node:fs";
|
|
52551
|
+
import { resolve as resolve12, join as join9 } from "node:path";
|
|
52254
52552
|
function copyStaticAssets(publicDir, outDir) {
|
|
52255
52553
|
const targetDir = resolve12(outDir, "static", "public");
|
|
52256
52554
|
mkdirSync4(targetDir, { recursive: true });
|
|
52257
52555
|
if (!existsSync13(publicDir)) return;
|
|
52258
52556
|
function copyDir(src2, dest) {
|
|
52259
52557
|
mkdirSync4(dest, { recursive: true });
|
|
52260
|
-
const entries =
|
|
52558
|
+
const entries = readdirSync3(src2);
|
|
52261
52559
|
for (const entry of entries) {
|
|
52262
|
-
const srcPath =
|
|
52263
|
-
const destPath =
|
|
52264
|
-
const st =
|
|
52560
|
+
const srcPath = join9(src2, entry);
|
|
52561
|
+
const destPath = join9(dest, entry);
|
|
52562
|
+
const st = statSync6(srcPath);
|
|
52265
52563
|
if (st.isDirectory()) {
|
|
52266
52564
|
copyDir(srcPath, destPath);
|
|
52267
52565
|
} else {
|
|
@@ -52273,8 +52571,8 @@ function copyStaticAssets(publicDir, outDir) {
|
|
|
52273
52571
|
}
|
|
52274
52572
|
|
|
52275
52573
|
// ../adapter/src/prod-server.ts
|
|
52276
|
-
import { readFileSync as
|
|
52277
|
-
import { resolve as
|
|
52574
|
+
import { readFileSync as readFileSync18, existsSync as existsSync16, statSync as statSync8 } from "node:fs";
|
|
52575
|
+
import { resolve as resolve14, dirname as dirname11, basename } from "node:path";
|
|
52278
52576
|
import { createServer } from "node:http";
|
|
52279
52577
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
52280
52578
|
init_server_utils();
|
|
@@ -52313,13 +52611,13 @@ async function reportServerError(err, options) {
|
|
|
52313
52611
|
init_paths();
|
|
52314
52612
|
|
|
52315
52613
|
// ../adapter/src/load-config.ts
|
|
52316
|
-
import { existsSync as existsSync14, readFileSync as
|
|
52317
|
-
import { join as
|
|
52614
|
+
import { existsSync as existsSync14, readFileSync as readFileSync16, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5 } from "node:fs";
|
|
52615
|
+
import { join as join10, dirname as dirname9 } from "node:path";
|
|
52318
52616
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
52319
52617
|
import { createRequire as createRequire3 } from "node:module";
|
|
52320
52618
|
async function loadVeskConfig2(projectDir) {
|
|
52321
|
-
const jsPath =
|
|
52322
|
-
const tsPath =
|
|
52619
|
+
const jsPath = join10(projectDir, "vesk.config.js");
|
|
52620
|
+
const tsPath = join10(projectDir, "vesk.config.ts");
|
|
52323
52621
|
let configPath2 = null;
|
|
52324
52622
|
if (existsSync14(jsPath)) configPath2 = jsPath;
|
|
52325
52623
|
else if (existsSync14(tsPath)) configPath2 = tsPath;
|
|
@@ -52327,10 +52625,10 @@ async function loadVeskConfig2(projectDir) {
|
|
|
52327
52625
|
let raw2;
|
|
52328
52626
|
if (configPath2.endsWith(".ts")) {
|
|
52329
52627
|
const { transpile } = await import("typescript");
|
|
52330
|
-
const src2 =
|
|
52628
|
+
const src2 = readFileSync16(configPath2, "utf-8");
|
|
52331
52629
|
let js = transpile(src2, { module: 99, target: 99 });
|
|
52332
52630
|
const inject = { defineConfig, definePlugin, preset };
|
|
52333
|
-
const projectRequire = createRequire3(
|
|
52631
|
+
const projectRequire = createRequire3(join10(projectDir, "package.json"));
|
|
52334
52632
|
const importRe = /import\s+(?:(?:\*\s*as\s+([\w$]+))|([\w$]+(?:\s*,\s*\{[^}]*\})?)|(\{[^}]*\}))\s+from\s+['"]([^'"]+)['"]\s*;?/g;
|
|
52335
52633
|
let m;
|
|
52336
52634
|
while ((m = importRe.exec(js)) !== null) {
|
|
@@ -52357,7 +52655,7 @@ async function loadVeskConfig2(projectDir) {
|
|
|
52357
52655
|
const injectKeys = Object.keys(inject);
|
|
52358
52656
|
js = `const {${injectKeys.join(",")}} = globalThis.__vesk_inject;
|
|
52359
52657
|
` + js;
|
|
52360
|
-
const tmpFile =
|
|
52658
|
+
const tmpFile = join10(projectDir, ".vesk", "config.loader.tmp.mjs");
|
|
52361
52659
|
mkdirSync5(dirname9(tmpFile), { recursive: true });
|
|
52362
52660
|
writeFileSync6(tmpFile, js, "utf-8");
|
|
52363
52661
|
globalThis.__vesk_inject = inject;
|
|
@@ -52379,12 +52677,327 @@ async function loadVeskConfig2(projectDir) {
|
|
|
52379
52677
|
|
|
52380
52678
|
// ../adapter/src/prod-server.ts
|
|
52381
52679
|
init_default_pages();
|
|
52382
|
-
|
|
52680
|
+
|
|
52681
|
+
// ../adapter/src/response-pipeline.ts
|
|
52682
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
52683
|
+
import {
|
|
52684
|
+
brotliCompress,
|
|
52685
|
+
constants as zlibConstants,
|
|
52686
|
+
createBrotliCompress,
|
|
52687
|
+
createGzip,
|
|
52688
|
+
gzip
|
|
52689
|
+
} from "node:zlib";
|
|
52690
|
+
import { promisify } from "node:util";
|
|
52691
|
+
var brotliCompressAsync = promisify(brotliCompress);
|
|
52692
|
+
var gzipAsync = promisify(gzip);
|
|
52693
|
+
function negotiateEncoding(header) {
|
|
52694
|
+
if (!header) return null;
|
|
52695
|
+
const value = Array.isArray(header) ? header.join(",") : header;
|
|
52696
|
+
const q = {};
|
|
52697
|
+
for (const part of value.split(",")) {
|
|
52698
|
+
const seg = part.trim();
|
|
52699
|
+
if (!seg) continue;
|
|
52700
|
+
const semi = seg.indexOf(";");
|
|
52701
|
+
const token = (semi === -1 ? seg : seg.slice(0, semi)).trim().toLowerCase();
|
|
52702
|
+
if (!token) continue;
|
|
52703
|
+
let weight = 1;
|
|
52704
|
+
if (semi !== -1) {
|
|
52705
|
+
for (const param of seg.slice(semi + 1).split(";")) {
|
|
52706
|
+
const eq = param.indexOf("=");
|
|
52707
|
+
if (eq === -1) continue;
|
|
52708
|
+
if (param.slice(0, eq).trim().toLowerCase() !== "q") continue;
|
|
52709
|
+
const parsed = Number.parseFloat(param.slice(eq + 1).trim());
|
|
52710
|
+
if (Number.isFinite(parsed)) weight = parsed;
|
|
52711
|
+
}
|
|
52712
|
+
}
|
|
52713
|
+
if (!(token in q)) q[token] = weight;
|
|
52714
|
+
}
|
|
52715
|
+
const star = q["*"];
|
|
52716
|
+
const br = q["br"] !== void 0 ? q["br"] : star;
|
|
52717
|
+
const gz = q["gzip"] !== void 0 ? q["gzip"] : star;
|
|
52718
|
+
if (br !== void 0 && br > 0 && (gz === void 0 || gz <= 0 || br >= gz)) return "br";
|
|
52719
|
+
if (gz !== void 0 && gz > 0) return "gzip";
|
|
52720
|
+
return null;
|
|
52721
|
+
}
|
|
52722
|
+
function isCompressibleType(contentType) {
|
|
52723
|
+
if (!contentType) return false;
|
|
52724
|
+
const type = (contentType.split(";")[0] || "").trim().toLowerCase();
|
|
52725
|
+
if (!type) return false;
|
|
52726
|
+
if (type.startsWith("text/")) return true;
|
|
52727
|
+
if (type === "image/svg+xml" || type === "image/x-icon" || type === "image/bmp") return true;
|
|
52728
|
+
if (type.endsWith("+json") || type.endsWith("+xml")) return true;
|
|
52729
|
+
switch (type) {
|
|
52730
|
+
case "application/javascript":
|
|
52731
|
+
case "application/x-javascript":
|
|
52732
|
+
case "application/ecmascript":
|
|
52733
|
+
case "application/json":
|
|
52734
|
+
case "application/manifest+json":
|
|
52735
|
+
case "application/ld+json":
|
|
52736
|
+
case "application/graphql":
|
|
52737
|
+
case "application/x-ndjson":
|
|
52738
|
+
case "application/xml":
|
|
52739
|
+
case "application/xhtml+xml":
|
|
52740
|
+
case "application/rss+xml":
|
|
52741
|
+
case "application/atom+xml":
|
|
52742
|
+
return true;
|
|
52743
|
+
default:
|
|
52744
|
+
return false;
|
|
52745
|
+
}
|
|
52746
|
+
}
|
|
52747
|
+
function etagFor(body) {
|
|
52748
|
+
return `"${createHash2("sha1").update(body).digest("base64").slice(0, 27)}"`;
|
|
52749
|
+
}
|
|
52750
|
+
function ifNoneMatchSatisfied(header, etag) {
|
|
52751
|
+
if (!header) return false;
|
|
52752
|
+
const value = Array.isArray(header) ? header.join(",") : header;
|
|
52753
|
+
const candidates = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
52754
|
+
if (candidates.includes("*")) return true;
|
|
52755
|
+
const strip = (s) => (s.startsWith("W/") ? s.slice(2) : s).trim();
|
|
52756
|
+
const target = strip(etag);
|
|
52757
|
+
for (const candidate of candidates) {
|
|
52758
|
+
if (strip(candidate) === target) return true;
|
|
52759
|
+
}
|
|
52760
|
+
return false;
|
|
52761
|
+
}
|
|
52762
|
+
function getHeader(headers2, name) {
|
|
52763
|
+
const wanted = name.toLowerCase();
|
|
52764
|
+
for (const key of Object.keys(headers2)) {
|
|
52765
|
+
if (key.toLowerCase() === wanted) {
|
|
52766
|
+
const v = headers2[key];
|
|
52767
|
+
if (v === void 0) return void 0;
|
|
52768
|
+
return Array.isArray(v) ? v.join(", ") : String(v);
|
|
52769
|
+
}
|
|
52770
|
+
}
|
|
52771
|
+
return void 0;
|
|
52772
|
+
}
|
|
52773
|
+
function hasNoStore(cacheControl) {
|
|
52774
|
+
if (!cacheControl) return false;
|
|
52775
|
+
return cacheControl.split(",").some((part) => part.trim().toLowerCase() === "no-store");
|
|
52776
|
+
}
|
|
52777
|
+
function withVary(current3, value) {
|
|
52778
|
+
if (!current3) return value;
|
|
52779
|
+
const existing2 = current3.split(",").map((s) => s.trim().toLowerCase());
|
|
52780
|
+
if (existing2.includes(value.toLowerCase())) return current3;
|
|
52781
|
+
if (existing2.includes("*")) return current3;
|
|
52782
|
+
return `${current3}, ${value}`;
|
|
52783
|
+
}
|
|
52784
|
+
function installResponsePipeline(res, req, options = {}) {
|
|
52785
|
+
const compressEnabled = options.compress !== false;
|
|
52786
|
+
const etagEnabled = options.etag !== false;
|
|
52787
|
+
const threshold = options.compressThreshold ?? 1024;
|
|
52788
|
+
const brotliQuality = options.brotliQuality ?? 5;
|
|
52789
|
+
const gzipLevel = options.gzipLevel ?? 6;
|
|
52790
|
+
const realWriteHead = res.writeHead.bind(res);
|
|
52791
|
+
const realWrite = res.write.bind(res);
|
|
52792
|
+
const realEnd = res.end.bind(res);
|
|
52793
|
+
const realFlushHeaders = res.flushHeaders.bind(res);
|
|
52794
|
+
let pendingStatus = 200;
|
|
52795
|
+
let pendingHeaders = {};
|
|
52796
|
+
let flushed = false;
|
|
52797
|
+
let streaming = false;
|
|
52798
|
+
let streamCompressor = null;
|
|
52799
|
+
function flush(extra) {
|
|
52800
|
+
if (flushed) return;
|
|
52801
|
+
flushed = true;
|
|
52802
|
+
const headers2 = {};
|
|
52803
|
+
for (const [key, value] of Object.entries(pendingHeaders)) {
|
|
52804
|
+
if (value !== void 0) headers2[key] = value;
|
|
52805
|
+
}
|
|
52806
|
+
for (const [key, value] of Object.entries(extra || {})) {
|
|
52807
|
+
if (value === void 0) delete headers2[key];
|
|
52808
|
+
else headers2[key] = value;
|
|
52809
|
+
}
|
|
52810
|
+
realWriteHead(pendingStatus, headers2);
|
|
52811
|
+
}
|
|
52812
|
+
res.writeHead = ((statusCode, headers2) => {
|
|
52813
|
+
if (flushed || streaming) return realWriteHead(statusCode, headers2);
|
|
52814
|
+
pendingStatus = statusCode;
|
|
52815
|
+
pendingHeaders = { ...headers2 || {} };
|
|
52816
|
+
return res;
|
|
52817
|
+
});
|
|
52818
|
+
function encodingIsVariable() {
|
|
52819
|
+
return compressEnabled && !getHeader(pendingHeaders, "content-encoding") && isCompressibleType(getHeader(pendingHeaders, "content-type"));
|
|
52820
|
+
}
|
|
52821
|
+
function startStreamCompression(encoding) {
|
|
52822
|
+
const compressor = encoding === "br" ? createBrotliCompress({ params: { [zlibConstants.BROTLI_PARAM_QUALITY]: brotliQuality } }) : createGzip({ level: gzipLevel });
|
|
52823
|
+
compressor.on("data", (chunk) => {
|
|
52824
|
+
realWrite(chunk);
|
|
52825
|
+
});
|
|
52826
|
+
compressor.on("end", () => {
|
|
52827
|
+
realEnd();
|
|
52828
|
+
});
|
|
52829
|
+
compressor.on("error", () => {
|
|
52830
|
+
try {
|
|
52831
|
+
realEnd();
|
|
52832
|
+
} catch {
|
|
52833
|
+
}
|
|
52834
|
+
});
|
|
52835
|
+
streamCompressor = compressor;
|
|
52836
|
+
}
|
|
52837
|
+
res.write = ((chunk, encoding) => {
|
|
52838
|
+
if (!flushed && !streaming) {
|
|
52839
|
+
streaming = true;
|
|
52840
|
+
const vary = withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding");
|
|
52841
|
+
const encodingChosen = encodingIsVariable() ? negotiateEncoding(req.headers["accept-encoding"]) : null;
|
|
52842
|
+
if (encodingChosen) {
|
|
52843
|
+
startStreamCompression(encodingChosen);
|
|
52844
|
+
flush({ "Content-Encoding": encodingChosen, Vary: vary, "Content-Length": void 0 });
|
|
52845
|
+
} else {
|
|
52846
|
+
flush({ Vary: encodingIsVariable() ? vary : void 0 });
|
|
52847
|
+
}
|
|
52848
|
+
}
|
|
52849
|
+
if (streamCompressor) {
|
|
52850
|
+
streamCompressor.write(toBuffer(chunk, encoding) || Buffer.alloc(0));
|
|
52851
|
+
return true;
|
|
52852
|
+
}
|
|
52853
|
+
return typeof encoding === "undefined" ? realWrite(chunk) : realWrite(chunk, encoding);
|
|
52854
|
+
});
|
|
52855
|
+
res.flushHeaders = (() => {
|
|
52856
|
+
if (!flushed) {
|
|
52857
|
+
streaming = true;
|
|
52858
|
+
flush();
|
|
52859
|
+
}
|
|
52860
|
+
realFlushHeaders.call(res);
|
|
52861
|
+
});
|
|
52862
|
+
function toBuffer(chunk, encoding) {
|
|
52863
|
+
if (chunk === void 0 || chunk === null) return null;
|
|
52864
|
+
if (Buffer.isBuffer(chunk)) return chunk;
|
|
52865
|
+
if (typeof chunk === "string") {
|
|
52866
|
+
return Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
|
|
52867
|
+
}
|
|
52868
|
+
if (chunk instanceof Uint8Array) return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
52869
|
+
return null;
|
|
52870
|
+
}
|
|
52871
|
+
function finish(body, endArgs) {
|
|
52872
|
+
const method = (req.method || "GET").toUpperCase();
|
|
52873
|
+
if (!body || body.length === 0 || streaming || flushed) {
|
|
52874
|
+
flush();
|
|
52875
|
+
realEnd(...endArgs);
|
|
52876
|
+
return;
|
|
52877
|
+
}
|
|
52878
|
+
const cacheable = method === "GET" || method === "HEAD";
|
|
52879
|
+
const existingEtag = getHeader(pendingHeaders, "etag");
|
|
52880
|
+
const canValidate = cacheable && pendingStatus === 200 && !hasNoStore(getHeader(pendingHeaders, "cache-control"));
|
|
52881
|
+
if (!canValidate) {
|
|
52882
|
+
maybeCompress(body, endArgs);
|
|
52883
|
+
return;
|
|
52884
|
+
}
|
|
52885
|
+
const etag = existingEtag || (etagEnabled ? etagFor(body) : void 0);
|
|
52886
|
+
if (etag && ifNoneMatchSatisfied(req.headers["if-none-match"], etag)) {
|
|
52887
|
+
const headers304 = { ETag: etag };
|
|
52888
|
+
const cc = getHeader(pendingHeaders, "cache-control");
|
|
52889
|
+
if (cc) headers304["Cache-Control"] = cc;
|
|
52890
|
+
headers304.Vary = withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding");
|
|
52891
|
+
flushed = true;
|
|
52892
|
+
realWriteHead(304, headers304);
|
|
52893
|
+
realEnd();
|
|
52894
|
+
return;
|
|
52895
|
+
}
|
|
52896
|
+
if (etag && !existingEtag) {
|
|
52897
|
+
pendingHeaders = { ...pendingHeaders, ETag: etag };
|
|
52898
|
+
}
|
|
52899
|
+
maybeCompress(body, endArgs);
|
|
52900
|
+
}
|
|
52901
|
+
function maybeCompress(body, endArgs) {
|
|
52902
|
+
if (compressEnabled && body.length < threshold || !encodingIsVariable()) {
|
|
52903
|
+
flush();
|
|
52904
|
+
realEnd(...endArgs);
|
|
52905
|
+
return;
|
|
52906
|
+
}
|
|
52907
|
+
const encoding = negotiateEncoding(req.headers["accept-encoding"]);
|
|
52908
|
+
if (!encoding) {
|
|
52909
|
+
flush({ Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding") });
|
|
52910
|
+
realEnd(...endArgs);
|
|
52911
|
+
return;
|
|
52912
|
+
}
|
|
52913
|
+
const compress = encoding === "br" ? brotliCompressAsync : gzipAsync;
|
|
52914
|
+
const params = encoding === "br" ? { params: { [zlibConstants.BROTLI_PARAM_QUALITY]: brotliQuality } } : { level: gzipLevel };
|
|
52915
|
+
void Promise.resolve().then(() => compress(body, params)).then((encoded) => {
|
|
52916
|
+
if (flushed || streaming) {
|
|
52917
|
+
flush();
|
|
52918
|
+
realEnd(...endArgs);
|
|
52919
|
+
return;
|
|
52920
|
+
}
|
|
52921
|
+
if (encoded.length >= body.length) {
|
|
52922
|
+
flush({ Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding") });
|
|
52923
|
+
realEnd(...endArgs);
|
|
52924
|
+
return;
|
|
52925
|
+
}
|
|
52926
|
+
flush({
|
|
52927
|
+
"Content-Encoding": encoding,
|
|
52928
|
+
Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding"),
|
|
52929
|
+
"Content-Length": String(encoded.length)
|
|
52930
|
+
});
|
|
52931
|
+
realEnd(encoded);
|
|
52932
|
+
}).catch(() => {
|
|
52933
|
+
flush({ Vary: withVary(getHeader(pendingHeaders, "vary"), "Accept-Encoding") });
|
|
52934
|
+
realEnd(...endArgs);
|
|
52935
|
+
});
|
|
52936
|
+
}
|
|
52937
|
+
res.end = ((chunk, encoding, callback) => {
|
|
52938
|
+
if (streamCompressor) {
|
|
52939
|
+
if (typeof callback === "function") res.once("finish", callback);
|
|
52940
|
+
const tail = toBuffer(chunk, encoding);
|
|
52941
|
+
if (tail) streamCompressor.end(tail);
|
|
52942
|
+
else streamCompressor.end();
|
|
52943
|
+
return res;
|
|
52944
|
+
}
|
|
52945
|
+
if (streaming || flushed) {
|
|
52946
|
+
return realEnd(chunk, encoding, callback);
|
|
52947
|
+
}
|
|
52948
|
+
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];
|
|
52949
|
+
const body = toBuffer(chunk, encoding);
|
|
52950
|
+
finish(body, endArgs);
|
|
52951
|
+
return res;
|
|
52952
|
+
});
|
|
52953
|
+
}
|
|
52954
|
+
|
|
52955
|
+
// ../adapter/src/prod-server.ts
|
|
52956
|
+
init_platform_output();
|
|
52957
|
+
var __dirname4 = dirname11(fileURLToPath3(import.meta.url));
|
|
52958
|
+
var STREAMING_TYPES = /* @__PURE__ */ new Set(["text/event-stream", "application/x-ndjson"]);
|
|
52959
|
+
var DELIVER_BUFFER_LIMIT = 1024 * 1024;
|
|
52383
52960
|
async function deliverResponse(res, response) {
|
|
52384
|
-
|
|
52961
|
+
const headers2 = Object.fromEntries(response.headers);
|
|
52385
52962
|
const body = response.body;
|
|
52386
|
-
if (body
|
|
52387
|
-
|
|
52963
|
+
if (!body || typeof body.getReader !== "function") {
|
|
52964
|
+
res.writeHead(response.status, headers2);
|
|
52965
|
+
res.end(await response.text());
|
|
52966
|
+
return;
|
|
52967
|
+
}
|
|
52968
|
+
const contentType = String(response.headers.get("content-type") || "").split(";")[0].trim().toLowerCase();
|
|
52969
|
+
const reader = body.getReader();
|
|
52970
|
+
if (STREAMING_TYPES.has(contentType)) {
|
|
52971
|
+
res.writeHead(response.status, headers2);
|
|
52972
|
+
pumpRemaining(res, reader);
|
|
52973
|
+
return;
|
|
52974
|
+
}
|
|
52975
|
+
const chunks = [];
|
|
52976
|
+
let size = 0;
|
|
52977
|
+
let overflow = false;
|
|
52978
|
+
try {
|
|
52979
|
+
for (; ; ) {
|
|
52980
|
+
const { done, value } = await reader.read();
|
|
52981
|
+
if (done) break;
|
|
52982
|
+
chunks.push(Buffer.from(value));
|
|
52983
|
+
size += value.byteLength;
|
|
52984
|
+
if (size > DELIVER_BUFFER_LIMIT) {
|
|
52985
|
+
overflow = true;
|
|
52986
|
+
break;
|
|
52987
|
+
}
|
|
52988
|
+
}
|
|
52989
|
+
} catch {
|
|
52990
|
+
}
|
|
52991
|
+
res.writeHead(response.status, headers2);
|
|
52992
|
+
if (overflow) {
|
|
52993
|
+
for (const chunk of chunks) res.write(chunk);
|
|
52994
|
+
pumpRemaining(res, reader);
|
|
52995
|
+
return;
|
|
52996
|
+
}
|
|
52997
|
+
res.end(Buffer.concat(chunks));
|
|
52998
|
+
}
|
|
52999
|
+
function pumpRemaining(res, reader) {
|
|
53000
|
+
void (async () => {
|
|
52388
53001
|
try {
|
|
52389
53002
|
for (; ; ) {
|
|
52390
53003
|
const { done, value } = await reader.read();
|
|
@@ -52394,9 +53007,7 @@ async function deliverResponse(res, response) {
|
|
|
52394
53007
|
} catch {
|
|
52395
53008
|
}
|
|
52396
53009
|
res.end();
|
|
52397
|
-
|
|
52398
|
-
}
|
|
52399
|
-
res.end(await response.text());
|
|
53010
|
+
})();
|
|
52400
53011
|
}
|
|
52401
53012
|
function bodyTooLarge(maxBytes) {
|
|
52402
53013
|
const err = new Error(`Request body exceeds limit (${maxBytes} bytes)`);
|
|
@@ -52457,49 +53068,42 @@ function makeWebRequest(nodeReq, url, maxBodyBytes = DEFAULT_MAX_BODY_BYTES) {
|
|
|
52457
53068
|
webRequest.query = query;
|
|
52458
53069
|
return webRequest;
|
|
52459
53070
|
}
|
|
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
53071
|
async function startProdServer(outDir, options) {
|
|
52476
53072
|
const port = options?.port || 3e3;
|
|
52477
53073
|
const host = options?.host || "127.0.0.1";
|
|
52478
53074
|
const maxBodyBytes = options?.maxBodyBytes || DEFAULT_MAX_BODY_BYTES;
|
|
52479
53075
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
|
|
52480
|
-
const staticDir =
|
|
52481
|
-
const configPath2 =
|
|
52482
|
-
installMdReadHook([
|
|
52483
|
-
if (!
|
|
53076
|
+
const staticDir = resolve14(outDir, "static");
|
|
53077
|
+
const configPath2 = resolve14(outDir, "config.json");
|
|
53078
|
+
installMdReadHook([resolve14(staticDir, "public")]);
|
|
53079
|
+
if (!existsSync16(configPath2)) {
|
|
52484
53080
|
console.error(`vesk start: no build found at ${outDir}`);
|
|
52485
53081
|
console.error('Run "vesk build" first');
|
|
52486
53082
|
process.exit(1);
|
|
52487
53083
|
}
|
|
52488
|
-
const buildConfig = JSON.parse(
|
|
53084
|
+
const buildConfig = JSON.parse(readFileSync18(configPath2, "utf-8"));
|
|
52489
53085
|
const bakedHeadExtra = buildConfig.headExtra || "";
|
|
52490
53086
|
console.error(`vesk start: serving from ${outDir}`);
|
|
52491
|
-
const projectDir =
|
|
53087
|
+
const projectDir = resolve14(outDir, "..");
|
|
52492
53088
|
let securityConfig = {};
|
|
52493
53089
|
let mdConfig;
|
|
53090
|
+
let compressionConfig = {};
|
|
53091
|
+
let healthCheckEnabled = true;
|
|
52494
53092
|
try {
|
|
52495
53093
|
const config = await loadVeskConfig2(projectDir);
|
|
52496
53094
|
if (config) {
|
|
52497
53095
|
securityConfig = { security: config.security };
|
|
52498
53096
|
mdConfig = config.md;
|
|
53097
|
+
compressionConfig = config.compression === false ? { enabled: false } : config.compression || {};
|
|
53098
|
+
healthCheckEnabled = config.healthCheck !== false;
|
|
52499
53099
|
}
|
|
52500
53100
|
} catch (e) {
|
|
52501
53101
|
console.error("vesk start: failed to load vesk.config \u2014 falling back to secure defaults:", e instanceof Error ? e.message : e);
|
|
52502
53102
|
}
|
|
53103
|
+
if (options?.compression !== void 0) {
|
|
53104
|
+
compressionConfig = options.compression === false ? { enabled: false } : options.compression;
|
|
53105
|
+
}
|
|
53106
|
+
if (options?.healthCheck !== void 0) healthCheckEnabled = options.healthCheck !== false;
|
|
52503
53107
|
if (mdConfig) {
|
|
52504
53108
|
try {
|
|
52505
53109
|
const { configureMd: configureMd3 } = await Promise.resolve().then(() => (init_md(), md_exports));
|
|
@@ -52518,16 +53122,16 @@ async function startProdServer(outDir, options) {
|
|
|
52518
53122
|
} catch {
|
|
52519
53123
|
}
|
|
52520
53124
|
let middlewareMod = null;
|
|
52521
|
-
const mwPath =
|
|
52522
|
-
if (
|
|
53125
|
+
const mwPath = resolve14(outDir, "server", "middleware.js");
|
|
53126
|
+
if (existsSync16(mwPath)) {
|
|
52523
53127
|
try {
|
|
52524
53128
|
middlewareMod = await import(`${mwPath}?t=${Date.now()}`);
|
|
52525
53129
|
} catch {
|
|
52526
53130
|
}
|
|
52527
53131
|
}
|
|
52528
53132
|
let eventsMod = null;
|
|
52529
|
-
const eventsPath =
|
|
52530
|
-
if (
|
|
53133
|
+
const eventsPath = resolve14(outDir, "server", "events.js");
|
|
53134
|
+
if (existsSync16(eventsPath)) {
|
|
52531
53135
|
try {
|
|
52532
53136
|
eventsMod = await import(`${eventsPath}?t=${Date.now()}`);
|
|
52533
53137
|
} catch {
|
|
@@ -52536,8 +53140,8 @@ async function startProdServer(outDir, options) {
|
|
|
52536
53140
|
const functionCache = /* @__PURE__ */ new Map();
|
|
52537
53141
|
async function loadFunction(funcPath) {
|
|
52538
53142
|
if (functionCache.has(funcPath)) return functionCache.get(funcPath);
|
|
52539
|
-
const fullPath =
|
|
52540
|
-
if (!
|
|
53143
|
+
const fullPath = resolve14(outDir, funcPath);
|
|
53144
|
+
if (!existsSync16(fullPath)) return null;
|
|
52541
53145
|
try {
|
|
52542
53146
|
const mod = await import(`${fullPath}?t=${Date.now()}`);
|
|
52543
53147
|
functionCache.set(funcPath, mod);
|
|
@@ -52587,6 +53191,16 @@ async function startProdServer(outDir, options) {
|
|
|
52587
53191
|
const reqHost = req.headers.host || `localhost:${port}`;
|
|
52588
53192
|
const proto = req.socket.encrypted ? "https" : getClientProtocol({ headers: req.headers }, !!securityConfig?.trustProxy);
|
|
52589
53193
|
globalThis.__vesk_ssr_base_url = `${proto}://${reqHost}`;
|
|
53194
|
+
if (healthCheckEnabled && (url.pathname === "/healthz" || url.pathname === "/_vesk/healthz")) {
|
|
53195
|
+
const probe = JSON.stringify({ status: "ok", uptime: Math.floor(process.uptime()) });
|
|
53196
|
+
res.writeHead(200, {
|
|
53197
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
53198
|
+
"Content-Length": String(Buffer.byteLength(probe)),
|
|
53199
|
+
"Cache-Control": "no-store"
|
|
53200
|
+
});
|
|
53201
|
+
res.end(probe);
|
|
53202
|
+
return;
|
|
53203
|
+
}
|
|
52590
53204
|
if (rateLimiter) {
|
|
52591
53205
|
const clientIp = getClientIpFromReq(req);
|
|
52592
53206
|
if (!rateLimiter.check(clientIp)) {
|
|
@@ -52634,12 +53248,18 @@ async function startProdServer(outDir, options) {
|
|
|
52634
53248
|
}
|
|
52635
53249
|
return origWriteHead2(statusCode, headers2);
|
|
52636
53250
|
});
|
|
52637
|
-
|
|
53251
|
+
installResponsePipeline(res, req, {
|
|
53252
|
+
compress: compressionConfig.enabled !== false,
|
|
53253
|
+
compressThreshold: compressionConfig.threshold,
|
|
53254
|
+
brotliQuality: compressionConfig.brotliQuality,
|
|
53255
|
+
gzipLevel: compressionConfig.gzipLevel,
|
|
53256
|
+
etag: compressionConfig.etag !== false
|
|
53257
|
+
});
|
|
53258
|
+
const publicDir = resolve14(staticDir, "public");
|
|
52638
53259
|
const rootFile = url.pathname.length > 1 ? resolveWithin(publicDir, url.pathname.slice(1)) : null;
|
|
52639
|
-
if (rootFile &&
|
|
52640
|
-
|
|
52641
|
-
res.
|
|
52642
|
-
res.end(readFileSync15(rootFile));
|
|
53260
|
+
if (rootFile && existsSync16(rootFile) && statSync8(rootFile).isFile()) {
|
|
53261
|
+
res.writeHead(200, { "Content-Type": mimeFor(rootFile) });
|
|
53262
|
+
res.end(readFileSync18(rootFile));
|
|
52643
53263
|
return;
|
|
52644
53264
|
}
|
|
52645
53265
|
if (url.pathname === "/ssr-data.js") {
|
|
@@ -52665,13 +53285,13 @@ async function startProdServer(outDir, options) {
|
|
|
52665
53285
|
}
|
|
52666
53286
|
if (url.pathname === "/_vesk/runtime.js") {
|
|
52667
53287
|
const clientFile = buildConfig?.assets?.client?.file || "client.js";
|
|
52668
|
-
const clientPath =
|
|
52669
|
-
if (
|
|
53288
|
+
const clientPath = resolve14(staticDir, clientFile);
|
|
53289
|
+
if (existsSync16(clientPath)) {
|
|
52670
53290
|
res.writeHead(200, {
|
|
52671
53291
|
"Content-Type": "application/javascript",
|
|
52672
53292
|
"Cache-Control": cacheControlFor(clientFile, false)
|
|
52673
53293
|
});
|
|
52674
|
-
res.end(
|
|
53294
|
+
res.end(readFileSync18(clientPath));
|
|
52675
53295
|
return;
|
|
52676
53296
|
}
|
|
52677
53297
|
}
|
|
@@ -52683,26 +53303,25 @@ async function startProdServer(outDir, options) {
|
|
|
52683
53303
|
res.end("Forbidden");
|
|
52684
53304
|
return;
|
|
52685
53305
|
}
|
|
52686
|
-
if (
|
|
52687
|
-
const ext = extname3(staticPath);
|
|
53306
|
+
if (existsSync16(staticPath) && statSync8(staticPath).isFile()) {
|
|
52688
53307
|
res.writeHead(200, {
|
|
52689
|
-
"Content-Type":
|
|
53308
|
+
"Content-Type": mimeFor(staticPath),
|
|
52690
53309
|
// A content-hashed name can never change meaning, so it is immutable
|
|
52691
53310
|
// for a year; anything unhashed must be revalidated or a deploy would
|
|
52692
53311
|
// serve stale JS forever.
|
|
52693
53312
|
"Cache-Control": cacheControlFor(basename(staticPath), false)
|
|
52694
53313
|
});
|
|
52695
|
-
res.end(
|
|
53314
|
+
res.end(readFileSync18(staticPath));
|
|
52696
53315
|
return;
|
|
52697
53316
|
}
|
|
52698
53317
|
}
|
|
52699
53318
|
if (buildConfig.prerendered) {
|
|
52700
53319
|
const prerendered = buildConfig.prerendered.find((r) => r.path === url.pathname);
|
|
52701
53320
|
if (prerendered) {
|
|
52702
|
-
const htmlPath =
|
|
52703
|
-
if (
|
|
53321
|
+
const htmlPath = resolve14(outDir, prerendered.file);
|
|
53322
|
+
if (existsSync16(htmlPath)) {
|
|
52704
53323
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
52705
|
-
res.end(
|
|
53324
|
+
res.end(readFileSync18(htmlPath));
|
|
52706
53325
|
return;
|
|
52707
53326
|
}
|
|
52708
53327
|
}
|
|
@@ -52807,17 +53426,17 @@ async function startProdServer(outDir, options) {
|
|
|
52807
53426
|
}
|
|
52808
53427
|
}
|
|
52809
53428
|
}
|
|
52810
|
-
const appDir =
|
|
53429
|
+
const appDir = resolve14(projectDir, "app");
|
|
52811
53430
|
const pageCssUrls = resolveCssUrls({
|
|
52812
53431
|
enabled: hasBuiltGlobalCss(outDir)
|
|
52813
53432
|
});
|
|
52814
|
-
const nfPath =
|
|
53433
|
+
const nfPath = resolve14(appDir, "not-found.vsk");
|
|
52815
53434
|
let notFoundHtml = null;
|
|
52816
|
-
if (
|
|
53435
|
+
if (existsSync16(nfPath)) {
|
|
52817
53436
|
try {
|
|
52818
|
-
const runtimePath =
|
|
53437
|
+
const runtimePath = resolve14(outDir, "server", "runtime.js");
|
|
52819
53438
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
52820
|
-
const src2 =
|
|
53439
|
+
const src2 = readFileSync18(nfPath, "utf-8");
|
|
52821
53440
|
const compName = resolveComponentName(src2) || "NotFound";
|
|
52822
53441
|
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
53442
|
} catch {
|
|
@@ -52891,13 +53510,13 @@ async function startProdServer(outDir, options) {
|
|
|
52891
53510
|
if (eventsMod) {
|
|
52892
53511
|
await executeError(err, { url: url.href, routePath: route.path, target: "node", status: 500 }, eventsMod);
|
|
52893
53512
|
}
|
|
52894
|
-
const errPath =
|
|
53513
|
+
const errPath = resolve14(appDir, "error.vsk");
|
|
52895
53514
|
let errorHtml = null;
|
|
52896
|
-
if (
|
|
53515
|
+
if (existsSync16(errPath)) {
|
|
52897
53516
|
try {
|
|
52898
|
-
const runtimePath =
|
|
53517
|
+
const runtimePath = resolve14(outDir, "server", "runtime.js");
|
|
52899
53518
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
52900
|
-
const src2 =
|
|
53519
|
+
const src2 = readFileSync18(errPath, "utf-8");
|
|
52901
53520
|
const compName = resolveComponentName(src2) || "Error";
|
|
52902
53521
|
const expose = process.env.NODE_ENV !== "production";
|
|
52903
53522
|
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 +53556,14 @@ async function startProdServer(outDir, options) {
|
|
|
52937
53556
|
server.close(() => process.exit(0));
|
|
52938
53557
|
setTimeout(() => process.exit(0), 3e3).unref();
|
|
52939
53558
|
}
|
|
52940
|
-
|
|
52941
|
-
|
|
53559
|
+
const onSigint = () => shutdown("SIGINT");
|
|
53560
|
+
const onSigterm = () => shutdown("SIGTERM");
|
|
53561
|
+
process.on("SIGINT", onSigint);
|
|
53562
|
+
process.on("SIGTERM", onSigterm);
|
|
53563
|
+
server.once("close", () => {
|
|
53564
|
+
process.off("SIGINT", onSigint);
|
|
53565
|
+
process.off("SIGTERM", onSigterm);
|
|
53566
|
+
});
|
|
52942
53567
|
server.listen(port, host, () => {
|
|
52943
53568
|
console.error(`vesk production server at http://localhost:${port} (listening on ${host})`);
|
|
52944
53569
|
});
|
|
@@ -52976,7 +53601,7 @@ function findRouteConflicts(routeTree, appDir) {
|
|
|
52976
53601
|
const walk9 = (nodes) => {
|
|
52977
53602
|
for (const node of nodes) {
|
|
52978
53603
|
if (node.page) {
|
|
52979
|
-
const pageFile =
|
|
53604
|
+
const pageFile = join16(node.sourceDir, "page.vsk");
|
|
52980
53605
|
const files = byPath.get(node.fullPath) ?? [];
|
|
52981
53606
|
files.push(relative4(projectRoot, pageFile));
|
|
52982
53607
|
byPath.set(node.fullPath, files);
|
|
@@ -53085,6 +53710,11 @@ async function build2(appDir, options) {
|
|
|
53085
53710
|
if (pluginHeadExtra)
|
|
53086
53711
|
console.error("vesk build: baked plugin head \u2192 config.json + SSR functions");
|
|
53087
53712
|
console.error(`vesk build: output \u2192 ${outDir}`);
|
|
53713
|
+
if (isSocketlessTarget(options?.platform, options?.target)) {
|
|
53714
|
+
const driverHits = tcpDriverViolations(appDir);
|
|
53715
|
+
if (driverHits.length > 0)
|
|
53716
|
+
throw edgeDriverBuildError(driverHits);
|
|
53717
|
+
}
|
|
53088
53718
|
const dirs = [
|
|
53089
53719
|
resolve21(outDir, "server", "functions"),
|
|
53090
53720
|
resolve21(outDir, "server", "api"),
|
|
@@ -53096,7 +53726,7 @@ async function build2(appDir, options) {
|
|
|
53096
53726
|
markPhase("config+dirs");
|
|
53097
53727
|
const cssSourcePath = resolveUserCssPath(appDir);
|
|
53098
53728
|
if (cssSourcePath !== null) {
|
|
53099
|
-
const cssContent =
|
|
53729
|
+
const cssContent = readFileSync23(cssSourcePath, "utf-8");
|
|
53100
53730
|
const cssTarget = resolve21(outDir, "static", "global.css");
|
|
53101
53731
|
const tailwindActive = isTailwindPlugin(pluginsPipelines);
|
|
53102
53732
|
let finalCss = cssContent;
|
|
@@ -53189,7 +53819,7 @@ async function build2(appDir, options) {
|
|
|
53189
53819
|
const mwChain2 = collectMiddlewareChain2(routeTree, node.fullPath, appDir);
|
|
53190
53820
|
let mwCode = null;
|
|
53191
53821
|
if (mwChain2.length > 0) {
|
|
53192
|
-
const mwSources = mwChain2.map((m) =>
|
|
53822
|
+
const mwSources = mwChain2.map((m) => readFileSync23(m.sourcePath, "utf-8"));
|
|
53193
53823
|
mwCode = compileMiddlewareCode(mwSources);
|
|
53194
53824
|
}
|
|
53195
53825
|
const ssrAncestorLayouts = isStandalone ? [] : ancestorLayouts;
|
|
@@ -53197,14 +53827,14 @@ async function build2(appDir, options) {
|
|
|
53197
53827
|
writeFileSync12(funcPath, funcCode, "utf-8");
|
|
53198
53828
|
const pagePath = resolve21(appDir, node.sourceDir, "page.vsk");
|
|
53199
53829
|
if (existsSync22(pagePath)) {
|
|
53200
|
-
const src2 =
|
|
53830
|
+
const src2 = readFileSync23(pagePath, "utf-8");
|
|
53201
53831
|
const actionIds = collectActionIds(src2);
|
|
53202
53832
|
if (node.layout) {
|
|
53203
|
-
const layoutSrc =
|
|
53833
|
+
const layoutSrc = readFileSync23(resolve21(appDir, node.sourceDir, "layout.vsk"), "utf-8");
|
|
53204
53834
|
actionIds.push(...collectActionIds(layoutSrc));
|
|
53205
53835
|
}
|
|
53206
53836
|
for (const a of ssrAncestorLayouts) {
|
|
53207
|
-
const ancestorSrc =
|
|
53837
|
+
const ancestorSrc = readFileSync23(resolve21(appDir, a.sourceDir, "layout.vsk"), "utf-8");
|
|
53208
53838
|
actionIds.push(...collectActionIds(ancestorSrc));
|
|
53209
53839
|
}
|
|
53210
53840
|
for (const id of actionIds) {
|
|
@@ -53297,7 +53927,7 @@ async function build2(appDir, options) {
|
|
|
53297
53927
|
const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap, pluginHeadExtra, hasEvents);
|
|
53298
53928
|
const buildId3 = emittedAssets.map((a) => a.hash).join("-");
|
|
53299
53929
|
manifest.buildId = buildId3.slice(0, 32);
|
|
53300
|
-
manifest.veskVersion = JSON.parse(
|
|
53930
|
+
manifest.veskVersion = JSON.parse(readFileSync23(join16(PACKAGES_DIR_SELF(), "package.json"), "utf-8")).version;
|
|
53301
53931
|
manifest.assets = {
|
|
53302
53932
|
hashed,
|
|
53303
53933
|
client: { file: clientFileName, url: clientUrl, hash: clientAsset.hash, bytes: clientAsset.bytes, integrity: clientAsset.integrity },
|
|
@@ -53351,9 +53981,9 @@ vesk build: done (${outDir})`);
|
|
|
53351
53981
|
init_seo_audit();
|
|
53352
53982
|
|
|
53353
53983
|
// src/dev-server.ts
|
|
53354
|
-
import { readFileSync as
|
|
53355
|
-
import { createHash as
|
|
53356
|
-
import { resolve as resolve38, extname as
|
|
53984
|
+
import { readFileSync as readFileSync40, watch, statSync as statSync22, existsSync as existsSync42, mkdirSync as mkdirSync19, readdirSync as readdirSync14, writeFileSync as writeFileSync21, renameSync as renameSync2 } from "node:fs";
|
|
53985
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
53986
|
+
import { resolve as resolve38, extname as extname7, join as join27, dirname as dirname26 } from "node:path";
|
|
53357
53987
|
import { createServer as createServer2 } from "node:http";
|
|
53358
53988
|
import { WebSocketServer as WebSocketServer2 } from "ws";
|
|
53359
53989
|
|
|
@@ -56242,8 +56872,8 @@ init_parser();
|
|
|
56242
56872
|
init_tokens();
|
|
56243
56873
|
init_scan();
|
|
56244
56874
|
init_strip_ts();
|
|
56245
|
-
import { readdirSync as
|
|
56246
|
-
import { join as
|
|
56875
|
+
import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync23, readFileSync as readFileSync24 } from "fs";
|
|
56876
|
+
import { join as join17, relative as relative5, basename as basename4 } from "path";
|
|
56247
56877
|
function collapseSlashes2(p) {
|
|
56248
56878
|
let out = "";
|
|
56249
56879
|
let prevSlash = false;
|
|
@@ -56263,7 +56893,7 @@ function isStandaloneLayoutFile(layoutPath) {
|
|
|
56263
56893
|
try {
|
|
56264
56894
|
if (!existsSync23(layoutPath))
|
|
56265
56895
|
return false;
|
|
56266
|
-
const src2 =
|
|
56896
|
+
const src2 = readFileSync24(layoutPath, "utf-8");
|
|
56267
56897
|
if (!src2.includes("standalone"))
|
|
56268
56898
|
return false;
|
|
56269
56899
|
try {
|
|
@@ -56341,15 +56971,15 @@ function scanComponents(componentsDir) {
|
|
|
56341
56971
|
function walk9(dir, prefix) {
|
|
56342
56972
|
let entries;
|
|
56343
56973
|
try {
|
|
56344
|
-
entries =
|
|
56974
|
+
entries = readdirSync8(dir);
|
|
56345
56975
|
} catch {
|
|
56346
56976
|
return;
|
|
56347
56977
|
}
|
|
56348
56978
|
for (const entry of entries) {
|
|
56349
|
-
const full =
|
|
56979
|
+
const full = join17(dir, entry);
|
|
56350
56980
|
let stat;
|
|
56351
56981
|
try {
|
|
56352
|
-
stat =
|
|
56982
|
+
stat = statSync13(full);
|
|
56353
56983
|
} catch {
|
|
56354
56984
|
continue;
|
|
56355
56985
|
}
|
|
@@ -56372,7 +57002,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
|
|
|
56372
57002
|
const nodes = [];
|
|
56373
57003
|
let entries;
|
|
56374
57004
|
try {
|
|
56375
|
-
entries =
|
|
57005
|
+
entries = readdirSync8(dir);
|
|
56376
57006
|
} catch {
|
|
56377
57007
|
return nodes;
|
|
56378
57008
|
}
|
|
@@ -56447,7 +57077,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
|
|
|
56447
57077
|
seg = segName;
|
|
56448
57078
|
}
|
|
56449
57079
|
const fullPath = seg ? (parentPath === "/" ? "/" : parentPath + "/") + seg : parentPath || "/";
|
|
56450
|
-
const isStandalone = hasLayout ? isStandaloneLayoutFile(
|
|
57080
|
+
const isStandalone = hasLayout ? isStandaloneLayoutFile(join17(dir, "layout.vsk")) : false;
|
|
56451
57081
|
const node = {
|
|
56452
57082
|
path: seg,
|
|
56453
57083
|
fullPath: collapseSlashes2(fullPath) || "/",
|
|
@@ -56468,10 +57098,10 @@ function scanDirectory(rootDir, dir, parentPath, options) {
|
|
|
56468
57098
|
standalone: isStandalone ? true : void 0
|
|
56469
57099
|
};
|
|
56470
57100
|
for (const entry of entries) {
|
|
56471
|
-
const entryPath =
|
|
57101
|
+
const entryPath = join17(dir, entry);
|
|
56472
57102
|
let entryStat;
|
|
56473
57103
|
try {
|
|
56474
|
-
entryStat =
|
|
57104
|
+
entryStat = statSync13(entryPath);
|
|
56475
57105
|
} catch {
|
|
56476
57106
|
continue;
|
|
56477
57107
|
}
|
|
@@ -56520,19 +57150,19 @@ function collectSources(tree) {
|
|
|
56520
57150
|
function walk9(nodes) {
|
|
56521
57151
|
for (const node of nodes) {
|
|
56522
57152
|
if (node.page)
|
|
56523
|
-
map.set(node.page,
|
|
57153
|
+
map.set(node.page, join17(node.sourceDir, "page.vsk"));
|
|
56524
57154
|
if (node.layout)
|
|
56525
|
-
map.set(node.layout,
|
|
57155
|
+
map.set(node.layout, join17(node.sourceDir, "layout.vsk"));
|
|
56526
57156
|
if (node.loading)
|
|
56527
|
-
map.set(node.loading,
|
|
57157
|
+
map.set(node.loading, join17(node.sourceDir, "loading.vsk"));
|
|
56528
57158
|
if (node.error)
|
|
56529
|
-
map.set(node.error,
|
|
57159
|
+
map.set(node.error, join17(node.sourceDir, "error.vsk"));
|
|
56530
57160
|
if (node.notFound)
|
|
56531
|
-
map.set(node.notFound,
|
|
57161
|
+
map.set(node.notFound, join17(node.sourceDir, "not-found.vsk"));
|
|
56532
57162
|
if (node.offline)
|
|
56533
|
-
map.set(node.offline,
|
|
57163
|
+
map.set(node.offline, join17(node.sourceDir, "offline.vsk"));
|
|
56534
57164
|
if (node.network)
|
|
56535
|
-
map.set(node.network,
|
|
57165
|
+
map.set(node.network, join17(node.sourceDir, "network.vsk"));
|
|
56536
57166
|
walk9(node.children);
|
|
56537
57167
|
}
|
|
56538
57168
|
}
|
|
@@ -56652,8 +57282,8 @@ function matchUrl(tree, pathname) {
|
|
|
56652
57282
|
}
|
|
56653
57283
|
|
|
56654
57284
|
// ../compiler/dist/api-routes.js
|
|
56655
|
-
import { readdirSync as
|
|
56656
|
-
import { join as
|
|
57285
|
+
import { readdirSync as readdirSync9, statSync as statSync14, existsSync as existsSync24 } from "fs";
|
|
57286
|
+
import { join as join18 } from "path";
|
|
56657
57287
|
init_server_utils();
|
|
56658
57288
|
function basename5(p) {
|
|
56659
57289
|
const idx = p.lastIndexOf("/");
|
|
@@ -56668,7 +57298,7 @@ function scanApiDir(rootDir, dir, parentPath) {
|
|
|
56668
57298
|
const nodes = [];
|
|
56669
57299
|
let entries;
|
|
56670
57300
|
try {
|
|
56671
|
-
entries =
|
|
57301
|
+
entries = readdirSync9(dir);
|
|
56672
57302
|
} catch {
|
|
56673
57303
|
return nodes;
|
|
56674
57304
|
}
|
|
@@ -56690,10 +57320,10 @@ function scanApiDir(rootDir, dir, parentPath) {
|
|
|
56690
57320
|
return nodes;
|
|
56691
57321
|
if (isRouteGroup) {
|
|
56692
57322
|
for (const entry of entries) {
|
|
56693
|
-
const entryPath =
|
|
57323
|
+
const entryPath = join18(dir, entry);
|
|
56694
57324
|
let entryStat;
|
|
56695
57325
|
try {
|
|
56696
|
-
entryStat =
|
|
57326
|
+
entryStat = statSync14(entryPath);
|
|
56697
57327
|
} catch {
|
|
56698
57328
|
continue;
|
|
56699
57329
|
}
|
|
@@ -56720,14 +57350,14 @@ function scanApiDir(rootDir, dir, parentPath) {
|
|
|
56720
57350
|
fullPath: collapseSlashes(fullPath) || "/",
|
|
56721
57351
|
isDynamic,
|
|
56722
57352
|
isCatchAll,
|
|
56723
|
-
filePath: hasRoute && routeFileName ?
|
|
57353
|
+
filePath: hasRoute && routeFileName ? join18(dir, routeFileName) : null,
|
|
56724
57354
|
children: []
|
|
56725
57355
|
};
|
|
56726
57356
|
for (const entry of entries) {
|
|
56727
|
-
const entryPath =
|
|
57357
|
+
const entryPath = join18(dir, entry);
|
|
56728
57358
|
let entryStat;
|
|
56729
57359
|
try {
|
|
56730
|
-
entryStat =
|
|
57360
|
+
entryStat = statSync14(entryPath);
|
|
56731
57361
|
} catch {
|
|
56732
57362
|
continue;
|
|
56733
57363
|
}
|
|
@@ -57281,11 +57911,11 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
|
|
|
57281
57911
|
|
|
57282
57912
|
// ../compiler/dist/events.js
|
|
57283
57913
|
import { existsSync as existsSync26 } from "fs";
|
|
57284
|
-
import { join as
|
|
57914
|
+
import { join as join19 } from "path";
|
|
57285
57915
|
var EVENTS_FILE_NAMES2 = ["_events.ts", "_events.js"];
|
|
57286
57916
|
function collectEventsFile2(appDir) {
|
|
57287
57917
|
for (const name of EVENTS_FILE_NAMES2) {
|
|
57288
|
-
const candidate =
|
|
57918
|
+
const candidate = join19(appDir, name);
|
|
57289
57919
|
if (existsSync26(candidate))
|
|
57290
57920
|
return candidate;
|
|
57291
57921
|
}
|
|
@@ -57316,8 +57946,8 @@ async function runEventHandlers(handlers, name, ctx2) {
|
|
|
57316
57946
|
}
|
|
57317
57947
|
|
|
57318
57948
|
// ../compiler/dist/md-inline.js
|
|
57319
|
-
import { readFileSync as
|
|
57320
|
-
import { dirname as dirname17, join as
|
|
57949
|
+
import { readFileSync as readFileSync25, existsSync as existsSync27 } from "node:fs";
|
|
57950
|
+
import { dirname as dirname17, join as join20, resolve as resolve23 } from "node:path";
|
|
57321
57951
|
var MD_EXT_MARKER2 = ".md";
|
|
57322
57952
|
function looksLikeMarkdownPath2(value) {
|
|
57323
57953
|
const v = value.trim();
|
|
@@ -57360,7 +57990,7 @@ function inlineMdContentAttrs2(source, importerDir, mdRoots = []) {
|
|
|
57360
57990
|
if (abs !== null) {
|
|
57361
57991
|
let contents;
|
|
57362
57992
|
try {
|
|
57363
|
-
contents =
|
|
57993
|
+
contents = readFileSync25(abs, "utf-8");
|
|
57364
57994
|
} catch {
|
|
57365
57995
|
out += source[i];
|
|
57366
57996
|
i++;
|
|
@@ -57394,10 +58024,10 @@ function resolveMdPath2(specifier, importerDir, roots) {
|
|
|
57394
58024
|
}
|
|
57395
58025
|
if (spec.startsWith("/")) {
|
|
57396
58026
|
for (const root3 of roots) {
|
|
57397
|
-
const pub =
|
|
58027
|
+
const pub = join20(root3, "public", spec);
|
|
57398
58028
|
if (existsSync27(pub))
|
|
57399
58029
|
return pub;
|
|
57400
|
-
const direct =
|
|
58030
|
+
const direct = join20(root3, spec);
|
|
57401
58031
|
if (existsSync27(direct))
|
|
57402
58032
|
return direct;
|
|
57403
58033
|
}
|
|
@@ -57411,7 +58041,7 @@ function guessProjectRoots2(dir) {
|
|
|
57411
58041
|
let cur = dir;
|
|
57412
58042
|
for (let i = 0; i < 6; i++) {
|
|
57413
58043
|
roots.push(cur);
|
|
57414
|
-
if (existsSync27(
|
|
58044
|
+
if (existsSync27(join20(cur, "package.json")))
|
|
57415
58045
|
break;
|
|
57416
58046
|
const parent = dirname17(cur);
|
|
57417
58047
|
if (parent === cur)
|
|
@@ -57422,8 +58052,8 @@ function guessProjectRoots2(dir) {
|
|
|
57422
58052
|
}
|
|
57423
58053
|
|
|
57424
58054
|
// ../adapter/dist/client-bundle.js
|
|
57425
|
-
import { readFileSync as
|
|
57426
|
-
import { resolve as resolve24, join as
|
|
58055
|
+
import { readFileSync as readFileSync26, existsSync as existsSync28, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync15, rmSync as rmSync4, mkdtempSync as mkdtempSync2, mkdirSync as mkdirSync12 } from "node:fs";
|
|
58056
|
+
import { resolve as resolve24, join as join21, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
|
|
57427
58057
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
57428
58058
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
57429
58059
|
|
|
@@ -57514,7 +58144,7 @@ async function mapWithConcurrency2(items, limit, fn) {
|
|
|
57514
58144
|
var __dirname7 = dirname18(fileURLToPath6(import.meta.url));
|
|
57515
58145
|
function fileUnchanged2(filePath, cached) {
|
|
57516
58146
|
try {
|
|
57517
|
-
const st =
|
|
58147
|
+
const st = statSync15(filePath);
|
|
57518
58148
|
return st.mtimeMs === cached.mtimeMs && st.size === cached.size;
|
|
57519
58149
|
} catch {
|
|
57520
58150
|
return false;
|
|
@@ -57535,8 +58165,8 @@ function findRuntimeSrc3(appDir) {
|
|
|
57535
58165
|
resolve24(appDir, "node_modules", "@vesk/runtime")
|
|
57536
58166
|
];
|
|
57537
58167
|
for (const base of candidates) {
|
|
57538
|
-
for (const dir of [base,
|
|
57539
|
-
if (existsSync28(
|
|
58168
|
+
for (const dir of [base, join21(base, "dist")]) {
|
|
58169
|
+
if (existsSync28(join21(dir, "index-client.js")))
|
|
57540
58170
|
return dir;
|
|
57541
58171
|
}
|
|
57542
58172
|
}
|
|
@@ -57656,6 +58286,13 @@ function nativeLibraryImportStubs2(code) {
|
|
|
57656
58286
|
});
|
|
57657
58287
|
return lines.join("\n") + "\n\n";
|
|
57658
58288
|
}
|
|
58289
|
+
function reportServerOnlyImports2(chunkName, hits, strict) {
|
|
58290
|
+
const detail = [...new Set(hits.map((h) => `"${h.binding}" from "${h.specifier}"`))].join(", ");
|
|
58291
|
+
if (strict) {
|
|
58292
|
+
throw new Error(`[vesk] ${chunkName} imports a server-only package in client code: ${detail}. Move that work into an API route (app/api/**/route.ts) or a server action. Pass without --strict to allow it (the binding is replaced by a throwing stub).`);
|
|
58293
|
+
}
|
|
58294
|
+
console.error(`[vesk] ${chunkName}: removed server-only import from client code (${detail}). It is replaced by a stub that throws if the component calls it at runtime \u2014 server-only work belongs in an API route or a server action.`);
|
|
58295
|
+
}
|
|
57659
58296
|
function demoteExports2(code) {
|
|
57660
58297
|
let ast;
|
|
57661
58298
|
try {
|
|
@@ -57689,7 +58326,7 @@ function chunkHasImports2(headLen, mergeAborted) {
|
|
|
57689
58326
|
function runtimeImportsOf2(filePath) {
|
|
57690
58327
|
let text;
|
|
57691
58328
|
try {
|
|
57692
|
-
text =
|
|
58329
|
+
text = readFileSync26(filePath, "utf8");
|
|
57693
58330
|
} catch {
|
|
57694
58331
|
return [];
|
|
57695
58332
|
}
|
|
@@ -58016,11 +58653,11 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
58016
58653
|
return removeCompiledNodes2(code, isVskImport2);
|
|
58017
58654
|
}
|
|
58018
58655
|
function resolveVskImports(filePath, compile) {
|
|
58019
|
-
const src2 =
|
|
58656
|
+
const src2 = readFileSync26(filePath, "utf-8");
|
|
58020
58657
|
const resolved = [];
|
|
58021
58658
|
for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
|
|
58022
58659
|
try {
|
|
58023
|
-
|
|
58660
|
+
readFileSync26(importPath);
|
|
58024
58661
|
} catch {
|
|
58025
58662
|
continue;
|
|
58026
58663
|
}
|
|
@@ -58082,7 +58719,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
58082
58719
|
compiledFiles++;
|
|
58083
58720
|
__stats.compiled++;
|
|
58084
58721
|
__stats.distinct.add(filePath);
|
|
58085
|
-
let src2 =
|
|
58722
|
+
let src2 = readFileSync26(filePath, "utf-8");
|
|
58086
58723
|
if (/content=["'][^"']*\.md["']/i.test(src2)) {
|
|
58087
58724
|
src2 = inlineMdContentAttrs(src2, dirname18(filePath), guessProjectRoots(appDir));
|
|
58088
58725
|
}
|
|
@@ -58122,7 +58759,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
58122
58759
|
for (const reexportPath of reexportPaths || [])
|
|
58123
58760
|
compileFile2(reexportPath, null, output, imports);
|
|
58124
58761
|
if (cache2 && namesBefore) {
|
|
58125
|
-
const st =
|
|
58762
|
+
const st = statSync15(filePath);
|
|
58126
58763
|
cache2.files.set(filePath, {
|
|
58127
58764
|
mtimeMs: st.mtimeMs,
|
|
58128
58765
|
size: st.size,
|
|
@@ -58252,9 +58889,9 @@ ${body}
|
|
|
58252
58889
|
let sharedBundleCode = "";
|
|
58253
58890
|
const sharedRuntimeNames = /* @__PURE__ */ new Set();
|
|
58254
58891
|
if (sharedSources.length > 0) {
|
|
58255
|
-
const tmpBase = mkdtempSync2(
|
|
58892
|
+
const tmpBase = mkdtempSync2(join21(resolve24(appDir, ".."), "tmp-vesk-shared-"));
|
|
58256
58893
|
try {
|
|
58257
|
-
const sharedEntry =
|
|
58894
|
+
const sharedEntry = join21(tmpBase, "shared-entry.js");
|
|
58258
58895
|
const lines = [];
|
|
58259
58896
|
const members = [];
|
|
58260
58897
|
sharedSources.forEach((source, i) => {
|
|
@@ -58264,7 +58901,7 @@ ${body}
|
|
|
58264
58901
|
lines.push(`globalThis.__veskShared = { ${members.join("\n")} };`);
|
|
58265
58902
|
writeFileSync13(sharedEntry, lines.join("\n"));
|
|
58266
58903
|
const appTsconfig = findTsconfigPath(appDir);
|
|
58267
|
-
const runtimeShim =
|
|
58904
|
+
const runtimeShim = join21(tmpBase, "runtime-shim.js");
|
|
58268
58905
|
const runtimeLines = [
|
|
58269
58906
|
"// ONE runtime instance: the entry bundle publishes these on globalThis,",
|
|
58270
58907
|
"// and route chunks import the same functions. A second bundled copy",
|
|
@@ -58305,7 +58942,7 @@ ${body}
|
|
|
58305
58942
|
bindings.named.forEach((n) => named.add(n));
|
|
58306
58943
|
hasDefault = hasDefault || bindings.hasDefault;
|
|
58307
58944
|
}
|
|
58308
|
-
const shim =
|
|
58945
|
+
const shim = join21(tmpBase, `shim-${i}.js`);
|
|
58309
58946
|
const shimLines = [`const m = globalThis.__veskShared[${JSON.stringify(source)}];`];
|
|
58310
58947
|
if (hasDefault)
|
|
58311
58948
|
shimLines.push(`export default m;`);
|
|
@@ -58336,13 +58973,21 @@ ${body}
|
|
|
58336
58973
|
return null;
|
|
58337
58974
|
let finalCode;
|
|
58338
58975
|
if (entry.imports) {
|
|
58339
|
-
const tmpBase = mkdtempSync2(
|
|
58340
|
-
const tmpFile =
|
|
58976
|
+
const tmpBase = mkdtempSync2(join21(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
|
|
58977
|
+
const tmpFile = join21(tmpBase, "entry.js");
|
|
58341
58978
|
const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
|
|
58342
58979
|
const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
|
|
58343
58980
|
${entry.code}
|
|
58344
58981
|
`;
|
|
58345
58982
|
writeFileSync13(tmpFile, toBundle);
|
|
58983
|
+
const serverOnlyHits = [];
|
|
58984
|
+
const driverHits = [];
|
|
58985
|
+
const eagerHits = [];
|
|
58986
|
+
const serverOnlyGuard = serverOnlyPlugin({
|
|
58987
|
+
onStub: (hit) => serverOnlyHits.push(hit),
|
|
58988
|
+
onDriver: (hit) => driverHits.push(hit),
|
|
58989
|
+
onEager: (hit) => eagerHits.push(hit)
|
|
58990
|
+
});
|
|
58346
58991
|
try {
|
|
58347
58992
|
const appTsconfig = findTsconfigPath(appDir);
|
|
58348
58993
|
const result = await build3({
|
|
@@ -58366,7 +59011,7 @@ ${entry.code}
|
|
|
58366
59011
|
// shared-modules.js serves every route chunk. (esbuild's `alias`
|
|
58367
59012
|
// option only accepts bare package names, so this is a resolver
|
|
58368
59013
|
// rather than a map.)
|
|
58369
|
-
...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin] } : {},
|
|
59014
|
+
...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin, serverOnlyGuard] } : { plugins: [serverOnlyGuard] },
|
|
58370
59015
|
...appTsconfig ? { tsconfig: appTsconfig } : {}
|
|
58371
59016
|
});
|
|
58372
59017
|
finalCode = result.outputFiles[0].text;
|
|
@@ -58388,6 +59033,20 @@ ${entry.code}
|
|
|
58388
59033
|
} catch {
|
|
58389
59034
|
}
|
|
58390
59035
|
}
|
|
59036
|
+
if (eagerHits.length > 0) {
|
|
59037
|
+
const detail = eagerHits.map((h) => `${h.importer} uses ${h.bindings.map((b) => `"${b}"`).join(", ")} from "${h.specifier}" at module scope`).join("; ");
|
|
59038
|
+
console.error("[vesk] server-only package used at module scope in client code", entry.name + ":", detail);
|
|
59039
|
+
throw new Error(`[vesk] ${entry.name}: ${detail}.
|
|
59040
|
+
A module-scope statement runs the moment the browser evaluates the chunk, so a server-only package cannot be substituted there. Move that work into an API route (app/api/**/route.ts) or a server action \u2014 if the binding is only used from inside a function, this build already handles it.`);
|
|
59041
|
+
}
|
|
59042
|
+
if (driverHits.length > 0) {
|
|
59043
|
+
const detail = [...new Set(driverHits.map((h) => `${h.specifier} (from ${h.importer})`))].join(", ");
|
|
59044
|
+
console.error("[vesk] chunk bundle contains a TCP-only driver", entry.name + ":", detail);
|
|
59045
|
+
throw new Error(`[vesk] ${entry.name} pulls a TCP-only driver into the browser bundle: ${detail}. A browser cannot open a socket. Import the package's edge/browser-safe entry if it ships one, or keep database access in an API route (app/api/**/route.ts) or a server action.`);
|
|
59046
|
+
}
|
|
59047
|
+
if (serverOnlyHits.length > 0) {
|
|
59048
|
+
reportServerOnlyImports2(entry.name, serverOnlyHits, options?.strict);
|
|
59049
|
+
}
|
|
58391
59050
|
} else {
|
|
58392
59051
|
finalCode = chunkIIFE(demoteExports2(entry.code));
|
|
58393
59052
|
}
|
|
@@ -58427,7 +59086,7 @@ ${entry.code}
|
|
|
58427
59086
|
if (seen.has(filePath))
|
|
58428
59087
|
return;
|
|
58429
59088
|
seen.add(filePath);
|
|
58430
|
-
const src2 =
|
|
59089
|
+
const src2 = readFileSync26(filePath, "utf-8");
|
|
58431
59090
|
resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
|
|
58432
59091
|
for (const cn of vskComponentNames(src2, filePath))
|
|
58433
59092
|
componentOwners.claim(cn, filePath);
|
|
@@ -58520,9 +59179,9 @@ function buildRuntimeCode2(runtimeDir) {
|
|
|
58520
59179
|
];
|
|
58521
59180
|
let code = "";
|
|
58522
59181
|
for (const f of runtimeFiles) {
|
|
58523
|
-
const p =
|
|
59182
|
+
const p = join21(runtimeDir, f);
|
|
58524
59183
|
if (existsSync28(p)) {
|
|
58525
|
-
let src2 =
|
|
59184
|
+
let src2 = readFileSync26(p, "utf-8");
|
|
58526
59185
|
src2 = stripTypes2(src2);
|
|
58527
59186
|
src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
58528
59187
|
src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
@@ -58534,7 +59193,7 @@ ${src2}
|
|
|
58534
59193
|
`;
|
|
58535
59194
|
}
|
|
58536
59195
|
}
|
|
58537
|
-
const indexSrc =
|
|
59196
|
+
const indexSrc = readFileSync26(join21(runtimeDir, "index-client.js"), "utf-8");
|
|
58538
59197
|
const exportNames = stripTypes2(indexSrc).match(/export\s*\{\s*([^}]+)\s*\}\s*from/g)?.flatMap((m) => m.replace(/export\s*\{\s*|\s*\}\s*from/g, "").split(",").map((s) => s.trim())) || [];
|
|
58539
59198
|
code += "// --- exports ---\n";
|
|
58540
59199
|
for (const name of [...new Set(exportNames)]) {
|
|
@@ -58545,7 +59204,7 @@ ${src2}
|
|
|
58545
59204
|
return code;
|
|
58546
59205
|
}
|
|
58547
59206
|
function runtimeExportNames2(runtimeDir) {
|
|
58548
|
-
const indexSrc =
|
|
59207
|
+
const indexSrc = readFileSync26(join21(runtimeDir, "index-client.js"), "utf-8");
|
|
58549
59208
|
const names = /* @__PURE__ */ new Set();
|
|
58550
59209
|
for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
|
|
58551
59210
|
for (const raw2 of m[1].split(",")) {
|
|
@@ -58561,7 +59220,7 @@ function esbuildPath2(p) {
|
|
|
58561
59220
|
return sep3 === "/" ? p : p.split(sep3).join("/");
|
|
58562
59221
|
}
|
|
58563
59222
|
function runtimeTreeShakeEntry2() {
|
|
58564
|
-
return
|
|
59223
|
+
return join21(tmpdir3(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
|
|
58565
59224
|
}
|
|
58566
59225
|
var treeShakeQueue2 = Promise.resolve();
|
|
58567
59226
|
function buildTreeShakenRuntime2(runtimeDir, usedNames) {
|
|
@@ -58586,7 +59245,7 @@ async function bundleRuntimeNames2(runtimeDir, names, strict = false) {
|
|
|
58586
59245
|
if (names.length === 0)
|
|
58587
59246
|
return null;
|
|
58588
59247
|
const entry = runtimeTreeShakeEntry2();
|
|
58589
|
-
const indexClient = esbuildPath2(
|
|
59248
|
+
const indexClient = esbuildPath2(join21(runtimeDir, "index-client.js"));
|
|
58590
59249
|
const unique = [...new Set(names)];
|
|
58591
59250
|
try {
|
|
58592
59251
|
try {
|
|
@@ -58734,7 +59393,7 @@ if (typeof document !== 'undefined') __router.start();
|
|
|
58734
59393
|
|
|
58735
59394
|
// ../adapter/dist/paths.js
|
|
58736
59395
|
import { resolve as resolve25, sep as sep4 } from "node:path";
|
|
58737
|
-
import { existsSync as existsSync29, statSync as
|
|
59396
|
+
import { existsSync as existsSync29, statSync as statSync16, readFileSync as readFileSync27 } from "node:fs";
|
|
58738
59397
|
function resolveWithin2(baseDir, relPath) {
|
|
58739
59398
|
const base = resolve25(baseDir);
|
|
58740
59399
|
const target = resolve25(baseDir, relPath);
|
|
@@ -58757,8 +59416,8 @@ function installMdReadHook2(publicDirs) {
|
|
|
58757
59416
|
const lower2 = abs.toLowerCase();
|
|
58758
59417
|
if (!lower2.endsWith(".md") && !lower2.endsWith(".markdown"))
|
|
58759
59418
|
continue;
|
|
58760
|
-
if (existsSync29(abs) &&
|
|
58761
|
-
return
|
|
59419
|
+
if (existsSync29(abs) && statSync16(abs).isFile())
|
|
59420
|
+
return readFileSync27(abs, "utf8");
|
|
58762
59421
|
} catch {
|
|
58763
59422
|
}
|
|
58764
59423
|
}
|
|
@@ -58825,13 +59484,13 @@ function urlAuthority3(url) {
|
|
|
58825
59484
|
}
|
|
58826
59485
|
|
|
58827
59486
|
// ../adapter/dist/dev-api.js
|
|
58828
|
-
import { readFileSync as
|
|
59487
|
+
import { readFileSync as readFileSync30, statSync as statSync18, existsSync as existsSync32, readdirSync as readdirSync10 } from "node:fs";
|
|
58829
59488
|
import { resolve as resolve28 } from "node:path";
|
|
58830
59489
|
|
|
58831
59490
|
// ../adapter/dist/plugins.js
|
|
58832
59491
|
init_paths();
|
|
58833
|
-
import { readFileSync as
|
|
58834
|
-
import { resolve as resolve26, dirname as dirname19, join as
|
|
59492
|
+
import { readFileSync as readFileSync28, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync17 } from "node:fs";
|
|
59493
|
+
import { resolve as resolve26, dirname as dirname19, join as join22, extname as extname6, basename as basename6 } from "node:path";
|
|
58835
59494
|
import { createRequire as createRequire6 } from "node:module";
|
|
58836
59495
|
import { spawn as spawn2 } from "node:child_process";
|
|
58837
59496
|
var PLUGIN_STATE_FILENAME2 = "plugins.json";
|
|
@@ -58854,7 +59513,7 @@ function readPluginState2(veskDir) {
|
|
|
58854
59513
|
return defaultState2();
|
|
58855
59514
|
let raw2;
|
|
58856
59515
|
try {
|
|
58857
|
-
raw2 = JSON.parse(
|
|
59516
|
+
raw2 = JSON.parse(readFileSync28(file, "utf-8"));
|
|
58858
59517
|
} catch {
|
|
58859
59518
|
return defaultState2();
|
|
58860
59519
|
}
|
|
@@ -58891,7 +59550,7 @@ function resolvePackage2(appDir, pkg) {
|
|
|
58891
59550
|
const seen = /* @__PURE__ */ new Set();
|
|
58892
59551
|
while (cur && cur !== dirname19(cur) && !seen.has(cur)) {
|
|
58893
59552
|
seen.add(cur);
|
|
58894
|
-
const candidate =
|
|
59553
|
+
const candidate = join22(cur, "package.json");
|
|
58895
59554
|
if (existsSync30(candidate)) {
|
|
58896
59555
|
pkgJsonPath = candidate;
|
|
58897
59556
|
break;
|
|
@@ -58920,7 +59579,7 @@ function resolvePackage2(appDir, pkg) {
|
|
|
58920
59579
|
}
|
|
58921
59580
|
}
|
|
58922
59581
|
if (localPath) {
|
|
58923
|
-
const localJson =
|
|
59582
|
+
const localJson = join22(localPath, "package.json");
|
|
58924
59583
|
let json = null;
|
|
58925
59584
|
if (existsSync30(localJson)) {
|
|
58926
59585
|
json = readJsonFile2(localJson);
|
|
@@ -58946,7 +59605,7 @@ function localDir2(base, pkg) {
|
|
|
58946
59605
|
function readJsonFile2(file) {
|
|
58947
59606
|
try {
|
|
58948
59607
|
if (existsSync30(file))
|
|
58949
|
-
return JSON.parse(
|
|
59608
|
+
return JSON.parse(readFileSync28(file, "utf-8"));
|
|
58950
59609
|
} catch {
|
|
58951
59610
|
}
|
|
58952
59611
|
return null;
|
|
@@ -59229,12 +59888,12 @@ function findIconFile2(dir, meta) {
|
|
|
59229
59888
|
const explicit = str2(meta?.icon);
|
|
59230
59889
|
if (explicit) {
|
|
59231
59890
|
const p = resolveWithin(dir, explicit);
|
|
59232
|
-
if (p && existsSync30(p) &&
|
|
59891
|
+
if (p && existsSync30(p) && statSync17(p).isFile())
|
|
59233
59892
|
return p;
|
|
59234
59893
|
}
|
|
59235
59894
|
for (const name of ["icon.png", "icon.ico"]) {
|
|
59236
59895
|
const p = resolve26(dir, name);
|
|
59237
|
-
if (existsSync30(p) &&
|
|
59896
|
+
if (existsSync30(p) && statSync17(p).isFile())
|
|
59238
59897
|
return p;
|
|
59239
59898
|
}
|
|
59240
59899
|
return null;
|
|
@@ -59248,7 +59907,7 @@ function findPluginIcon2(appDir, name) {
|
|
|
59248
59907
|
const iconPath = findIconFile2(dir, meta);
|
|
59249
59908
|
if (!iconPath)
|
|
59250
59909
|
return null;
|
|
59251
|
-
const ext =
|
|
59910
|
+
const ext = extname6(iconPath).toLowerCase();
|
|
59252
59911
|
const mime = ext === ".png" ? "image/png" : ext === ".ico" ? "image/x-icon" : "application/octet-stream";
|
|
59253
59912
|
return { file: iconPath, mime };
|
|
59254
59913
|
}
|
|
@@ -59319,7 +59978,7 @@ function resolveDtsPath2(probe, pkgJson) {
|
|
|
59319
59978
|
if (!rel)
|
|
59320
59979
|
continue;
|
|
59321
59980
|
const abs = resolveWithin(dir, rel);
|
|
59322
|
-
if (abs && existsSync30(abs) &&
|
|
59981
|
+
if (abs && existsSync30(abs) && statSync17(abs).isFile())
|
|
59323
59982
|
return abs;
|
|
59324
59983
|
}
|
|
59325
59984
|
return null;
|
|
@@ -59668,7 +60327,7 @@ function introspectPlugin2(appDir, name) {
|
|
|
59668
60327
|
const pkgName = str2(pkgJson.name) ?? name;
|
|
59669
60328
|
const exportsMap = flattenPackageExports2(pkgJson.exports);
|
|
59670
60329
|
const dtsPath = resolveDtsPath2(probe, pkgJson);
|
|
59671
|
-
const dtsExports = dtsPath ? parseDtsExports2(
|
|
60330
|
+
const dtsExports = dtsPath ? parseDtsExports2(readFileSync28(dtsPath, "utf-8")) : [];
|
|
59672
60331
|
return {
|
|
59673
60332
|
ok: true,
|
|
59674
60333
|
name: pkgName,
|
|
@@ -59806,9 +60465,9 @@ var __internals2 = {
|
|
|
59806
60465
|
};
|
|
59807
60466
|
|
|
59808
60467
|
// ../adapter/dist/dev-config.js
|
|
59809
|
-
import { existsSync as existsSync31, readFileSync as
|
|
60468
|
+
import { existsSync as existsSync31, readFileSync as readFileSync29, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
|
|
59810
60469
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
59811
|
-
import { resolve as resolve27, dirname as dirname20, join as
|
|
60470
|
+
import { resolve as resolve27, dirname as dirname20, join as join23 } from "node:path";
|
|
59812
60471
|
init_parser();
|
|
59813
60472
|
function findConfigFile2(projectDir) {
|
|
59814
60473
|
const ts9 = resolve27(projectDir, "vesk.config.ts");
|
|
@@ -59836,9 +60495,9 @@ async function parseConfigSource(source, isTs, projectDir) {
|
|
|
59836
60495
|
js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
|
|
59837
60496
|
` + js;
|
|
59838
60497
|
}
|
|
59839
|
-
const base = projectDir ? (mkdirSync14(
|
|
59840
|
-
const dir = base ? mkdtempSync3(
|
|
59841
|
-
const tmpFile =
|
|
60498
|
+
const base = projectDir ? (mkdirSync14(join23(projectDir, ".vesk"), { recursive: true }), join23(projectDir, ".vesk")) : void 0;
|
|
60499
|
+
const dir = base ? mkdtempSync3(join23(base, "cfg-")) : mkdtempSync3(join23(tmpdir4(), "vesk-cfg-"));
|
|
60500
|
+
const tmpFile = join23(dir, "config.mjs");
|
|
59842
60501
|
try {
|
|
59843
60502
|
writeFileSync15(tmpFile, js, "utf-8");
|
|
59844
60503
|
globalThis.__vesk_inject = {
|
|
@@ -59865,7 +60524,7 @@ async function readConfig2(projectDir) {
|
|
|
59865
60524
|
const { path, isTs } = findConfigFile2(projectDir);
|
|
59866
60525
|
if (!path)
|
|
59867
60526
|
return { path: null, exists: false, source: "", config: {} };
|
|
59868
|
-
const source =
|
|
60527
|
+
const source = readFileSync29(path, "utf-8");
|
|
59869
60528
|
const config = await parseConfigSource(source, isTs, projectDir);
|
|
59870
60529
|
return { path, exists: true, source, config };
|
|
59871
60530
|
}
|
|
@@ -60707,7 +61366,7 @@ export default defineConfig({
|
|
|
60707
61366
|
await writeConfigSource2(projectDir, source);
|
|
60708
61367
|
return;
|
|
60709
61368
|
}
|
|
60710
|
-
source =
|
|
61369
|
+
source = readFileSync29(path, "utf-8");
|
|
60711
61370
|
const existingImport = findPluginImportAst(source, pkg);
|
|
60712
61371
|
let importName;
|
|
60713
61372
|
if (existingImport) {
|
|
@@ -60787,7 +61446,7 @@ async function removePluginFromConfig2(projectDir, pkg) {
|
|
|
60787
61446
|
const { path } = findConfigFile2(projectDir);
|
|
60788
61447
|
if (!path)
|
|
60789
61448
|
return false;
|
|
60790
|
-
let source =
|
|
61449
|
+
let source = readFileSync29(path, "utf-8");
|
|
60791
61450
|
const original = source;
|
|
60792
61451
|
const existingImport = findPluginImportAst(source, pkg);
|
|
60793
61452
|
let importName = existingImport ? existingImport.name : null;
|
|
@@ -60908,7 +61567,7 @@ function createDevApiRouter2(opts) {
|
|
|
60908
61567
|
return badRequest2("no vesk.config file to edit");
|
|
60909
61568
|
if (!isTs)
|
|
60910
61569
|
return badRequest2("single-key toggle edits only apply to vesk.config.ts (use the source editor for .js)");
|
|
60911
|
-
const patched = applyConfigToggle2(
|
|
61570
|
+
const patched = applyConfigToggle2(readFileSync30(path, "utf-8"), b.key, b.value);
|
|
60912
61571
|
if (patched === null)
|
|
60913
61572
|
return badRequest2("could not safely edit the config object; use the source editor");
|
|
60914
61573
|
const cfg = await writeConfigSource2(projectDir, patched);
|
|
@@ -60949,12 +61608,12 @@ function createDevApiRouter2(opts) {
|
|
|
60949
61608
|
return jsonStatus(403, { error: "path escapes project root" });
|
|
60950
61609
|
if (!existsSync32(resolved))
|
|
60951
61610
|
return jsonStatus(404, { error: "not found" });
|
|
60952
|
-
if (
|
|
60953
|
-
const entries =
|
|
61611
|
+
if (statSync18(resolved).isDirectory()) {
|
|
61612
|
+
const entries = readdirSync10(resolved, { withFileTypes: true }).map((e) => e.name);
|
|
60954
61613
|
return jsonStatus(200, { ok: true, path: target, directory: true, entries });
|
|
60955
61614
|
}
|
|
60956
|
-
if (
|
|
60957
|
-
return jsonStatus(200, { ok: true, path: target, directory: false, content:
|
|
61615
|
+
if (statSync18(resolved).isFile()) {
|
|
61616
|
+
return jsonStatus(200, { ok: true, path: target, directory: false, content: readFileSync30(resolved, "utf-8") });
|
|
60958
61617
|
}
|
|
60959
61618
|
return badRequest2("unsupported file type");
|
|
60960
61619
|
} catch (e) {
|
|
@@ -61090,7 +61749,7 @@ function createDevApiRouter2(opts) {
|
|
|
61090
61749
|
return {
|
|
61091
61750
|
status: 200,
|
|
61092
61751
|
headers: { "Content-Type": icon.mime, "Cache-Control": "private, max-age=60" },
|
|
61093
|
-
body:
|
|
61752
|
+
body: readFileSync30(icon.file).toString("base64"),
|
|
61094
61753
|
encoding: "base64"
|
|
61095
61754
|
};
|
|
61096
61755
|
}
|
|
@@ -61147,8 +61806,8 @@ function produceDiagnostics(input) {
|
|
|
61147
61806
|
}
|
|
61148
61807
|
|
|
61149
61808
|
// ../agentic/dist/checkpoints.js
|
|
61150
|
-
import { existsSync as existsSync33, mkdirSync as mkdirSync15, readFileSync as
|
|
61151
|
-
import { join as
|
|
61809
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync15, readFileSync as readFileSync31, writeFileSync as writeFileSync16, statSync as statSync19, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
|
|
61810
|
+
import { join as join24, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
|
|
61152
61811
|
import { randomUUID as nodeRandomUUID } from "node:crypto";
|
|
61153
61812
|
function generateId() {
|
|
61154
61813
|
try {
|
|
@@ -61281,16 +61940,16 @@ var CheckpointManager = class {
|
|
|
61281
61940
|
}
|
|
61282
61941
|
};
|
|
61283
61942
|
function getAgenticDir(projectDir) {
|
|
61284
|
-
return
|
|
61943
|
+
return join24(resolve29(projectDir), ".vesk", "agentic");
|
|
61285
61944
|
}
|
|
61286
61945
|
function getHistoryPath(projectDir) {
|
|
61287
|
-
return
|
|
61946
|
+
return join24(getAgenticDir(projectDir), "history.json");
|
|
61288
61947
|
}
|
|
61289
61948
|
function getCheckpointDir(projectDir, id) {
|
|
61290
|
-
return
|
|
61949
|
+
return join24(getAgenticDir(projectDir), "checkpoints", id);
|
|
61291
61950
|
}
|
|
61292
61951
|
function getCheckpointPath(projectDir, id) {
|
|
61293
|
-
return
|
|
61952
|
+
return join24(getCheckpointDir(projectDir, id), "checkpoint.json");
|
|
61294
61953
|
}
|
|
61295
61954
|
function ensureDir(dir) {
|
|
61296
61955
|
mkdirSync15(dir, { recursive: true });
|
|
@@ -61299,7 +61958,7 @@ function readJson(filePath, fallback) {
|
|
|
61299
61958
|
try {
|
|
61300
61959
|
if (!existsSync33(filePath))
|
|
61301
61960
|
return fallback;
|
|
61302
|
-
const raw2 =
|
|
61961
|
+
const raw2 = readFileSync31(filePath, "utf-8");
|
|
61303
61962
|
if (raw2.trim() === "")
|
|
61304
61963
|
return fallback;
|
|
61305
61964
|
return JSON.parse(raw2);
|
|
@@ -61370,7 +62029,7 @@ function createCheckpoint(projectDir, message, changes = {}, buildResult) {
|
|
|
61370
62029
|
};
|
|
61371
62030
|
const agenticDir = getAgenticDir(projectDir);
|
|
61372
62031
|
ensureDir(agenticDir);
|
|
61373
|
-
ensureDir(
|
|
62032
|
+
ensureDir(join24(agenticDir, "checkpoints"));
|
|
61374
62033
|
const cpDir = getCheckpointDir(projectDir, id);
|
|
61375
62034
|
ensureDir(cpDir);
|
|
61376
62035
|
writeJsonAtomic(getCheckpointPath(projectDir, id), checkpoint);
|
|
@@ -61399,7 +62058,7 @@ function rollback(projectDir, id) {
|
|
|
61399
62058
|
if (f.before === null) {
|
|
61400
62059
|
try {
|
|
61401
62060
|
if (existsSync33(abs)) {
|
|
61402
|
-
const s =
|
|
62061
|
+
const s = statSync19(abs);
|
|
61403
62062
|
if (s.isDirectory())
|
|
61404
62063
|
rmSync6(abs, { recursive: true, force: true });
|
|
61405
62064
|
else
|
|
@@ -61419,7 +62078,7 @@ function rollback(projectDir, id) {
|
|
|
61419
62078
|
}
|
|
61420
62079
|
|
|
61421
62080
|
// ../agentic/dist/config.js
|
|
61422
|
-
import { readFileSync as
|
|
62081
|
+
import { readFileSync as readFileSync32, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync16, chmodSync } from "node:fs";
|
|
61423
62082
|
import { resolve as resolve30, dirname as dirname22 } from "node:path";
|
|
61424
62083
|
var DEFAULT_CONFIG = {
|
|
61425
62084
|
provider: "openai",
|
|
@@ -61468,7 +62127,7 @@ function readDotenvValue(projectDir, key, def = null) {
|
|
|
61468
62127
|
const p = dotenvPath(projectDir);
|
|
61469
62128
|
if (!existsSync34(p))
|
|
61470
62129
|
return def;
|
|
61471
|
-
const content =
|
|
62130
|
+
const content = readFileSync32(p, "utf-8");
|
|
61472
62131
|
for (const rawLine of content.split("\n")) {
|
|
61473
62132
|
const line = rawLine.trim();
|
|
61474
62133
|
if (!line || line.startsWith("#"))
|
|
@@ -61496,7 +62155,7 @@ function writeDotenvValue(projectDir, key, value) {
|
|
|
61496
62155
|
let out = "";
|
|
61497
62156
|
let replaced = false;
|
|
61498
62157
|
if (existsSync34(p)) {
|
|
61499
|
-
const lines =
|
|
62158
|
+
const lines = readFileSync32(p, "utf-8").split("\n");
|
|
61500
62159
|
for (const rawLine of lines) {
|
|
61501
62160
|
const trimmed = rawLine.trim();
|
|
61502
62161
|
const eq = trimmed.indexOf("=");
|
|
@@ -61526,7 +62185,7 @@ function loadAgenticConfig(projectDir) {
|
|
|
61526
62185
|
let cfg = { ...DEFAULT_CONFIG };
|
|
61527
62186
|
try {
|
|
61528
62187
|
if (existsSync34(p))
|
|
61529
|
-
cfg = { ...cfg, ...JSON.parse(
|
|
62188
|
+
cfg = { ...cfg, ...JSON.parse(readFileSync32(p, "utf-8")) };
|
|
61530
62189
|
} catch {
|
|
61531
62190
|
}
|
|
61532
62191
|
let hasKey = false;
|
|
@@ -61569,7 +62228,7 @@ function getProviderSpecificKey(projectDir, provider) {
|
|
|
61569
62228
|
try {
|
|
61570
62229
|
const pp2 = providerKeyPath(projectDir, prov);
|
|
61571
62230
|
if (existsSync34(pp2)) {
|
|
61572
|
-
const v =
|
|
62231
|
+
const v = readFileSync32(pp2, "utf-8").trim();
|
|
61573
62232
|
if (v)
|
|
61574
62233
|
return v;
|
|
61575
62234
|
}
|
|
@@ -61617,7 +62276,7 @@ function getApiKey(projectDir, provider) {
|
|
|
61617
62276
|
try {
|
|
61618
62277
|
const pp2 = providerKeyPath(projectDir, prov);
|
|
61619
62278
|
if (existsSync34(pp2)) {
|
|
61620
|
-
const v =
|
|
62279
|
+
const v = readFileSync32(pp2, "utf-8").trim();
|
|
61621
62280
|
if (v)
|
|
61622
62281
|
return v;
|
|
61623
62282
|
}
|
|
@@ -61640,7 +62299,7 @@ function getApiKey(projectDir, provider) {
|
|
|
61640
62299
|
}
|
|
61641
62300
|
|
|
61642
62301
|
// ../agentic/dist/dev-api.js
|
|
61643
|
-
import { existsSync as existsSync35, readFileSync as
|
|
62302
|
+
import { existsSync as existsSync35, readFileSync as readFileSync33 } from "node:fs";
|
|
61644
62303
|
import { resolve as resolve31 } from "node:path";
|
|
61645
62304
|
|
|
61646
62305
|
// ../agentic/dist/providers/openai.js
|
|
@@ -62013,7 +62672,7 @@ function getPerProviderKeyRaw(projectDir, provider) {
|
|
|
62013
62672
|
try {
|
|
62014
62673
|
const p = resolve31(projectDir, ".vesk", "agentic", "keys", `${sanitizeProviderName(prov)}.key`);
|
|
62015
62674
|
if (existsSync35(p)) {
|
|
62016
|
-
const v =
|
|
62675
|
+
const v = readFileSync33(p, "utf-8").trim();
|
|
62017
62676
|
if (v)
|
|
62018
62677
|
return v;
|
|
62019
62678
|
}
|
|
@@ -62874,8 +63533,8 @@ var Agent = class {
|
|
|
62874
63533
|
};
|
|
62875
63534
|
|
|
62876
63535
|
// ../agentic/dist/tools/vesk.js
|
|
62877
|
-
import { existsSync as existsSync36, readFileSync as
|
|
62878
|
-
import { resolve as resolve32, join as
|
|
63536
|
+
import { existsSync as existsSync36, readFileSync as readFileSync34, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync11, statSync as statSync20 } from "node:fs";
|
|
63537
|
+
import { resolve as resolve32, join as join25, dirname as dirname23, sep as sep6 } from "node:path";
|
|
62879
63538
|
function resolveWithin3(baseDir, relPath) {
|
|
62880
63539
|
const base = resolve32(baseDir);
|
|
62881
63540
|
const target = resolve32(baseDir, relPath);
|
|
@@ -62893,7 +63552,7 @@ function readPluginState3(veskDir) {
|
|
|
62893
63552
|
if (!existsSync36(file))
|
|
62894
63553
|
return { version: 1, plugins: [] };
|
|
62895
63554
|
try {
|
|
62896
|
-
const raw2 = JSON.parse(
|
|
63555
|
+
const raw2 = JSON.parse(readFileSync34(file, "utf-8"));
|
|
62897
63556
|
if (!raw2 || typeof raw2 !== "object")
|
|
62898
63557
|
return { version: 1, plugins: [] };
|
|
62899
63558
|
if (raw2.version !== 1)
|
|
@@ -62937,7 +63596,7 @@ function findConfigFile3(projectDir) {
|
|
|
62937
63596
|
return { path: null, isTs: false };
|
|
62938
63597
|
}
|
|
62939
63598
|
function checkpointDir(veskDir) {
|
|
62940
|
-
return
|
|
63599
|
+
return join25(resolve32(veskDir), "checkpoints");
|
|
62941
63600
|
}
|
|
62942
63601
|
function findMatchingBrace2(src2, openIdx) {
|
|
62943
63602
|
let inStr = null;
|
|
@@ -63082,18 +63741,18 @@ function createVeskTools(deps) {
|
|
|
63082
63741
|
async execute(_args) {
|
|
63083
63742
|
try {
|
|
63084
63743
|
const projExists = existsSync36(projectDir);
|
|
63085
|
-
const projEntries = projExists ?
|
|
63744
|
+
const projEntries = projExists ? readdirSync11(projectDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
|
|
63086
63745
|
const appExists = existsSync36(appDir);
|
|
63087
|
-
const appEntries = appExists ?
|
|
63746
|
+
const appEntries = appExists ? readdirSync11(appDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
|
|
63088
63747
|
const veskExists = existsSync36(veskDir);
|
|
63089
|
-
const veskEntries = veskExists ?
|
|
63748
|
+
const veskEntries = veskExists ? readdirSync11(veskDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
|
|
63090
63749
|
const cfgInfo = findConfigFile3(projectDir);
|
|
63091
63750
|
let configSource = null;
|
|
63092
63751
|
let configExists = false;
|
|
63093
63752
|
if (cfgInfo.path && existsSync36(cfgInfo.path)) {
|
|
63094
63753
|
configExists = true;
|
|
63095
63754
|
try {
|
|
63096
|
-
configSource =
|
|
63755
|
+
configSource = readFileSync34(cfgInfo.path, "utf-8").slice(0, 8e3);
|
|
63097
63756
|
} catch {
|
|
63098
63757
|
configSource = null;
|
|
63099
63758
|
}
|
|
@@ -63102,7 +63761,7 @@ function createVeskTools(deps) {
|
|
|
63102
63761
|
const pkgPath = resolve32(projectDir, "package.json");
|
|
63103
63762
|
if (existsSync36(pkgPath)) {
|
|
63104
63763
|
try {
|
|
63105
|
-
packageJson = JSON.parse(
|
|
63764
|
+
packageJson = JSON.parse(readFileSync34(pkgPath, "utf-8"));
|
|
63106
63765
|
} catch {
|
|
63107
63766
|
packageJson = null;
|
|
63108
63767
|
}
|
|
@@ -63184,13 +63843,13 @@ function createVeskTools(deps) {
|
|
|
63184
63843
|
return jsonError("path escapes project root", { path: rel });
|
|
63185
63844
|
if (!existsSync36(resolved))
|
|
63186
63845
|
return jsonError("not found", { path: rel });
|
|
63187
|
-
const st =
|
|
63846
|
+
const st = statSync20(resolved);
|
|
63188
63847
|
if (st.isDirectory()) {
|
|
63189
|
-
const entries =
|
|
63848
|
+
const entries = readdirSync11(resolved, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name);
|
|
63190
63849
|
return jsonOk({ ok: true, path: rel, directory: true, entries: entries.slice(0, 200) });
|
|
63191
63850
|
}
|
|
63192
63851
|
if (st.isFile()) {
|
|
63193
|
-
const content =
|
|
63852
|
+
const content = readFileSync34(resolved, "utf-8");
|
|
63194
63853
|
const capped = content.length > 2e4 ? content.slice(0, 2e4) + "\n/* truncated */" : content;
|
|
63195
63854
|
return jsonOk({ ok: true, path: rel, directory: false, content: capped, size: content.length });
|
|
63196
63855
|
}
|
|
@@ -63226,7 +63885,7 @@ function createVeskTools(deps) {
|
|
|
63226
63885
|
if (!info.path || !existsSync36(info.path)) {
|
|
63227
63886
|
return jsonOk({ ok: true, path: null, exists: false, source: "", config: {} });
|
|
63228
63887
|
}
|
|
63229
|
-
const source =
|
|
63888
|
+
const source = readFileSync34(info.path, "utf-8");
|
|
63230
63889
|
return jsonOk({ ok: true, path: info.path, exists: true, source, config: null });
|
|
63231
63890
|
} catch (e) {
|
|
63232
63891
|
return jsonError(e instanceof Error ? e.message : String(e));
|
|
@@ -63284,7 +63943,7 @@ function createVeskTools(deps) {
|
|
|
63284
63943
|
const contained = resolveWithin3(projectDir, info.path.slice(projectDir.length + 1));
|
|
63285
63944
|
if (!contained)
|
|
63286
63945
|
return jsonError("path escapes project root");
|
|
63287
|
-
const current3 =
|
|
63946
|
+
const current3 = readFileSync34(info.path, "utf-8");
|
|
63288
63947
|
const patched = applySimpleConfigToggle(current3, key, a.value);
|
|
63289
63948
|
if (patched === null)
|
|
63290
63949
|
return jsonError("could not safely edit the config object; use the source editor");
|
|
@@ -63552,7 +64211,7 @@ function createVeskTools(deps) {
|
|
|
63552
64211
|
const dir = checkpointDir(veskDir);
|
|
63553
64212
|
mkdirSync17(dir, { recursive: true });
|
|
63554
64213
|
const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
63555
|
-
const file =
|
|
64214
|
+
const file = join25(dir, `${id}.json`);
|
|
63556
64215
|
const check = resolveWithin3(dir, `${id}.json`);
|
|
63557
64216
|
if (!check)
|
|
63558
64217
|
return jsonError("path escapes project root");
|
|
@@ -63601,13 +64260,13 @@ function createVeskTools(deps) {
|
|
|
63601
64260
|
} catch {
|
|
63602
64261
|
}
|
|
63603
64262
|
const dir = checkpointDir(veskDir);
|
|
63604
|
-
const file =
|
|
64263
|
+
const file = join25(dir, `${checkpointId}.json`);
|
|
63605
64264
|
const contained = resolveWithin3(dir, `${checkpointId}.json`);
|
|
63606
64265
|
if (!contained)
|
|
63607
64266
|
return jsonError("path escapes project root");
|
|
63608
64267
|
if (!existsSync36(file))
|
|
63609
64268
|
return jsonError(`checkpoint not found: ${checkpointId}`, { checkpointId });
|
|
63610
|
-
const raw2 =
|
|
64269
|
+
const raw2 = readFileSync34(file, "utf-8");
|
|
63611
64270
|
let data2;
|
|
63612
64271
|
try {
|
|
63613
64272
|
data2 = JSON.parse(raw2);
|
|
@@ -63690,7 +64349,7 @@ function renderDefaultNotFoundPage2(opts = {}) {
|
|
|
63690
64349
|
}
|
|
63691
64350
|
|
|
63692
64351
|
// ../adapter/dist/css.js
|
|
63693
|
-
import { readFileSync as
|
|
64352
|
+
import { readFileSync as readFileSync35, existsSync as existsSync37 } from "node:fs";
|
|
63694
64353
|
import { resolve as resolve33 } from "node:path";
|
|
63695
64354
|
var GLOBAL_CSS_URL2 = "/_vesk/static/global.css";
|
|
63696
64355
|
function resolveUserCssPath2(appDir) {
|
|
@@ -63717,7 +64376,7 @@ function resolveCssUrls2(opts) {
|
|
|
63717
64376
|
// ../adapter/dist/hmr.js
|
|
63718
64377
|
init_client_codegen();
|
|
63719
64378
|
import { WebSocketServer } from "ws";
|
|
63720
|
-
import { readFileSync as
|
|
64379
|
+
import { readFileSync as readFileSync36, existsSync as existsSync38, writeFileSync as writeFileSync19 } from "node:fs";
|
|
63721
64380
|
import { resolve as resolve34, dirname as dirname24 } from "node:path";
|
|
63722
64381
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
63723
64382
|
init_default_pages();
|
|
@@ -63961,7 +64620,7 @@ function buildErrorPayload(error, filename, opts = {}) {
|
|
|
63961
64620
|
for (const absPath of candidates) {
|
|
63962
64621
|
try {
|
|
63963
64622
|
if (existsSync38(absPath)) {
|
|
63964
|
-
src2 =
|
|
64623
|
+
src2 = readFileSync36(absPath, "utf-8");
|
|
63965
64624
|
resolvedAbsPath = absPath;
|
|
63966
64625
|
break;
|
|
63967
64626
|
}
|
|
@@ -64009,7 +64668,7 @@ function buildErrorPayload(error, filename, opts = {}) {
|
|
|
64009
64668
|
}
|
|
64010
64669
|
|
|
64011
64670
|
// ../adapter/dist/ssr-error.js
|
|
64012
|
-
import { existsSync as existsSync39, readFileSync as
|
|
64671
|
+
import { existsSync as existsSync39, readFileSync as readFileSync37 } from "node:fs";
|
|
64013
64672
|
import { relative as relative7, resolve as resolve35 } from "node:path";
|
|
64014
64673
|
|
|
64015
64674
|
// ../adapter/dist/error-codeframe.js
|
|
@@ -64106,7 +64765,7 @@ function extractComponentNames(stack) {
|
|
|
64106
64765
|
}
|
|
64107
64766
|
return names;
|
|
64108
64767
|
}
|
|
64109
|
-
var
|
|
64768
|
+
var SOURCE_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".vsk"]);
|
|
64110
64769
|
function scanFrameLocation(seg) {
|
|
64111
64770
|
if (!seg)
|
|
64112
64771
|
return null;
|
|
@@ -64187,7 +64846,7 @@ function firstSourceFileFrame(stack, projectRoot) {
|
|
|
64187
64846
|
if (!p.startsWith("/"))
|
|
64188
64847
|
continue;
|
|
64189
64848
|
const ext = p.slice(p.lastIndexOf(".")).split(":")[0].toLowerCase();
|
|
64190
|
-
if (!
|
|
64849
|
+
if (!SOURCE_EXTENSIONS2.has(ext))
|
|
64191
64850
|
continue;
|
|
64192
64851
|
if (isGeneratedPath(p))
|
|
64193
64852
|
continue;
|
|
@@ -64240,7 +64899,7 @@ function readIfFile(absPath) {
|
|
|
64240
64899
|
try {
|
|
64241
64900
|
if (!existsSync39(absPath))
|
|
64242
64901
|
return null;
|
|
64243
|
-
return
|
|
64902
|
+
return readFileSync37(absPath, "utf-8");
|
|
64244
64903
|
} catch {
|
|
64245
64904
|
return null;
|
|
64246
64905
|
}
|
|
@@ -64388,9 +65047,9 @@ function renderDevErrorPage(payload, opts) {
|
|
|
64388
65047
|
|
|
64389
65048
|
// src/build-packages.ts
|
|
64390
65049
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
64391
|
-
import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync18, readFileSync as
|
|
65050
|
+
import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync18, readFileSync as readFileSync38, readdirSync as readdirSync12, statSync as statSync21, writeFileSync as writeFileSync20 } from "node:fs";
|
|
64392
65051
|
import { createRequire as createRequire7 } from "node:module";
|
|
64393
|
-
import { dirname as dirname25, join as
|
|
65052
|
+
import { dirname as dirname25, join as join26, resolve as resolve36 } from "node:path";
|
|
64394
65053
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
64395
65054
|
var require2 = createRequire7(import.meta.url);
|
|
64396
65055
|
var __dirname9 = dirname25(fileURLToPath8(import.meta.url));
|
|
@@ -64420,9 +65079,9 @@ var PACKAGES = {
|
|
|
64420
65079
|
};
|
|
64421
65080
|
function newestSourceMtime(srcDir) {
|
|
64422
65081
|
let newest = 0;
|
|
64423
|
-
for (const name of
|
|
64424
|
-
const p =
|
|
64425
|
-
const st =
|
|
65082
|
+
for (const name of readdirSync12(srcDir)) {
|
|
65083
|
+
const p = join26(srcDir, name);
|
|
65084
|
+
const st = statSync21(p);
|
|
64426
65085
|
if (st.isDirectory()) {
|
|
64427
65086
|
newest = Math.max(newest, newestSourceMtime(p));
|
|
64428
65087
|
} else if (st.isFile() && /\.ts$/.test(name) && !name.endsWith(".test.ts")) {
|
|
@@ -64432,11 +65091,11 @@ function newestSourceMtime(srcDir) {
|
|
|
64432
65091
|
return newest;
|
|
64433
65092
|
}
|
|
64434
65093
|
function distStale(pkgDir, entry) {
|
|
64435
|
-
const distIndex =
|
|
65094
|
+
const distIndex = join26(pkgDir, "dist", `${entry}.js`);
|
|
64436
65095
|
if (!existsSync40(distIndex)) return true;
|
|
64437
|
-
const distPkg =
|
|
64438
|
-
const distStamp = Math.max(
|
|
64439
|
-
return newestSourceMtime(
|
|
65096
|
+
const distPkg = join26(pkgDir, "dist", "package.json");
|
|
65097
|
+
const distStamp = Math.max(statSync21(distIndex).mtimeMs, existsSync40(distPkg) ? statSync21(distPkg).mtimeMs : 0);
|
|
65098
|
+
return newestSourceMtime(join26(pkgDir, "src")) > distStamp;
|
|
64440
65099
|
}
|
|
64441
65100
|
function distPackageJson(pkgName, entry, serverEntry, version2) {
|
|
64442
65101
|
const exports = {
|
|
@@ -64460,23 +65119,23 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
|
|
|
64460
65119
|
function buildPackages(force = false) {
|
|
64461
65120
|
for (const [pkg, cfg] of Object.entries(PACKAGES)) {
|
|
64462
65121
|
const pkgDir = resolve36(root2, "packages", pkg);
|
|
64463
|
-
if (!existsSync40(
|
|
65122
|
+
if (!existsSync40(join26(pkgDir, "src"))) continue;
|
|
64464
65123
|
if (!force && !distStale(pkgDir, cfg.entry)) continue;
|
|
64465
65124
|
console.log(`[build] ${cfg.name} -> tsc`);
|
|
64466
65125
|
const tscBin = require2.resolve("typescript/bin/tsc");
|
|
64467
|
-
const result = spawnSync2(process.execPath, [tscBin, "-p",
|
|
65126
|
+
const result = spawnSync2(process.execPath, [tscBin, "-p", join26(pkgDir, "tsconfig.build.json")], {
|
|
64468
65127
|
stdio: "inherit"
|
|
64469
65128
|
});
|
|
64470
65129
|
if (result.status !== 0) {
|
|
64471
65130
|
throw new Error(`tsc failed for ${cfg.name}`);
|
|
64472
65131
|
}
|
|
64473
|
-
const distDir =
|
|
65132
|
+
const distDir = join26(pkgDir, "dist");
|
|
64474
65133
|
for (const c of cfg.copy || []) {
|
|
64475
|
-
const to =
|
|
65134
|
+
const to = join26(distDir, c.to);
|
|
64476
65135
|
mkdirSync18(dirname25(to), { recursive: true });
|
|
64477
|
-
cpSync2(
|
|
65136
|
+
cpSync2(join26(pkgDir, c.from), to, { recursive: true });
|
|
64478
65137
|
}
|
|
64479
|
-
const srcPkg = JSON.parse(
|
|
65138
|
+
const srcPkg = JSON.parse(readFileSync38(join26(pkgDir, "package.json"), "utf-8"));
|
|
64480
65139
|
if (pkg === "lucide-vesk") {
|
|
64481
65140
|
const lucideDistPkg = {
|
|
64482
65141
|
name: srcPkg.name,
|
|
@@ -64490,9 +65149,9 @@ function buildPackages(force = false) {
|
|
|
64490
65149
|
"./package.json": "./package.json"
|
|
64491
65150
|
}
|
|
64492
65151
|
};
|
|
64493
|
-
writeFileSync20(
|
|
65152
|
+
writeFileSync20(join26(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
|
|
64494
65153
|
} else {
|
|
64495
|
-
writeFileSync20(
|
|
65154
|
+
writeFileSync20(join26(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
|
|
64496
65155
|
}
|
|
64497
65156
|
console.log(`[build] ${cfg.name} -> dist`);
|
|
64498
65157
|
}
|
|
@@ -64505,7 +65164,7 @@ if (process.argv[1] && resolve36(process.argv[1]) === fileURLToPath8(import.meta
|
|
|
64505
65164
|
}
|
|
64506
65165
|
|
|
64507
65166
|
// src/action-handler.ts
|
|
64508
|
-
import { existsSync as existsSync41, readFileSync as
|
|
65167
|
+
import { existsSync as existsSync41, readFileSync as readFileSync39, readdirSync as readdirSync13 } from "node:fs";
|
|
64509
65168
|
import { resolve as resolve37 } from "node:path";
|
|
64510
65169
|
|
|
64511
65170
|
// ../compiler/dist/server-cookies.js
|
|
@@ -64601,7 +65260,7 @@ function walkVskFiles(dir, out, seen) {
|
|
|
64601
65260
|
if (!existsSync41(dir)) return;
|
|
64602
65261
|
let entries;
|
|
64603
65262
|
try {
|
|
64604
|
-
entries =
|
|
65263
|
+
entries = readdirSync13(dir, { withFileTypes: true });
|
|
64605
65264
|
} catch {
|
|
64606
65265
|
return;
|
|
64607
65266
|
}
|
|
@@ -64635,7 +65294,7 @@ function candidateSources(appDirPath, routeTree) {
|
|
|
64635
65294
|
function registerSource(sourcePath2) {
|
|
64636
65295
|
if (!existsSync41(sourcePath2)) return;
|
|
64637
65296
|
try {
|
|
64638
|
-
compileFile(
|
|
65297
|
+
compileFile(readFileSync39(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
|
|
64639
65298
|
} catch {
|
|
64640
65299
|
}
|
|
64641
65300
|
}
|
|
@@ -64674,14 +65333,14 @@ async function renderPageHtml(pagePathname, params, ctx2) {
|
|
|
64674
65333
|
const pageFilePath = resolve37(ctx2.appDirPath, node.sourceDir, "page.vsk");
|
|
64675
65334
|
const layoutFilePath = resolve37(ctx2.appDirPath, node.sourceDir, "layout.vsk");
|
|
64676
65335
|
if (i === chain.length - 1 && node.page && existsSync41(pageFilePath)) {
|
|
64677
|
-
const src3 =
|
|
65336
|
+
const src3 = readFileSync39(pageFilePath, "utf-8");
|
|
64678
65337
|
const compName2 = resolveComponentName(src3) || node.page;
|
|
64679
65338
|
const result = await renderPage(src3, compName2, { params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
|
|
64680
65339
|
body = result.body;
|
|
64681
65340
|
head = result.head || "";
|
|
64682
65341
|
}
|
|
64683
65342
|
if (node.layout && existsSync41(layoutFilePath)) {
|
|
64684
|
-
const src3 =
|
|
65343
|
+
const src3 = readFileSync39(layoutFilePath, "utf-8");
|
|
64685
65344
|
const compName2 = resolveComponentName(src3) || node.layout;
|
|
64686
65345
|
const result = await renderPage(src3, compName2, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
|
|
64687
65346
|
body = result.body;
|
|
@@ -64712,7 +65371,7 @@ ${prettifyHtml(body)}
|
|
|
64712
65371
|
}
|
|
64713
65372
|
const leaf2 = chain.find((n) => n.page);
|
|
64714
65373
|
if (!leaf2) return null;
|
|
64715
|
-
const src2 =
|
|
65374
|
+
const src2 = readFileSync39(resolve37(ctx2.appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
|
|
64716
65375
|
const compName = resolveComponentName(src2) || leaf2.page;
|
|
64717
65376
|
const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: actionCssUrls(ctx2.appDirPath), security: ctx2.security, sourcePath: resolve37(ctx2.appDirPath, leaf2.sourceDir, "page.vsk"), plugins: ctx2.plugins });
|
|
64718
65377
|
return applyHtmlPlugins(html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>'), ctx2.plugins, { sourcePath: ctx2.url.pathname });
|
|
@@ -64879,7 +65538,7 @@ function buildDevErrorPayload(input) {
|
|
|
64879
65538
|
payload.column = colMatch ? parseInt(colMatch[1], 10) : 1;
|
|
64880
65539
|
if (fileExists && payload.line > 0) {
|
|
64881
65540
|
try {
|
|
64882
|
-
const src2 =
|
|
65541
|
+
const src2 = readFileSync40(fullPath, "utf-8");
|
|
64883
65542
|
const cf = buildCodeframe2(src2, payload.line, payload.column);
|
|
64884
65543
|
if (cf) {
|
|
64885
65544
|
cf.file = payload.file || filename;
|
|
@@ -64969,9 +65628,9 @@ function resolveRuntimeDir(projectDir) {
|
|
|
64969
65628
|
resolve38(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
|
|
64970
65629
|
];
|
|
64971
65630
|
for (const dir of candidates) {
|
|
64972
|
-
if (existsSync42(
|
|
64973
|
-
const distDir =
|
|
64974
|
-
if (existsSync42(
|
|
65631
|
+
if (existsSync42(join27(dir, "ripple-runtime.js"))) return dir;
|
|
65632
|
+
const distDir = join27(dir, "dist");
|
|
65633
|
+
if (existsSync42(join27(distDir, "ripple-runtime.js"))) return distDir;
|
|
64975
65634
|
}
|
|
64976
65635
|
return null;
|
|
64977
65636
|
}
|
|
@@ -65210,8 +65869,8 @@ function collectRoutePaths(nodes, out = []) {
|
|
|
65210
65869
|
function countFilesNamed(dir, name) {
|
|
65211
65870
|
if (!existsSync42(dir)) return 0;
|
|
65212
65871
|
let n = 0;
|
|
65213
|
-
for (const entry of
|
|
65214
|
-
const p =
|
|
65872
|
+
for (const entry of readdirSync14(dir, { withFileTypes: true })) {
|
|
65873
|
+
const p = join27(dir, entry.name);
|
|
65215
65874
|
if (entry.isDirectory()) n += countFilesNamed(p, name);
|
|
65216
65875
|
else if (entry.name === name) n++;
|
|
65217
65876
|
}
|
|
@@ -65222,7 +65881,7 @@ function cachedSsrCompile(cache2, src2, filePath) {
|
|
|
65222
65881
|
resetVskState(true);
|
|
65223
65882
|
return compileFile(source, { sourcePath: filePath });
|
|
65224
65883
|
};
|
|
65225
|
-
const st =
|
|
65884
|
+
const st = statSync22(filePath, { throwIfNoEntry: false });
|
|
65226
65885
|
if (st) {
|
|
65227
65886
|
const cur = cache2.get(filePath);
|
|
65228
65887
|
if (cur && cur.mtimeMs === st.mtimeMs && cur.size === st.size) return cur.result;
|
|
@@ -65254,7 +65913,7 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65254
65913
|
process.exit(1);
|
|
65255
65914
|
}
|
|
65256
65915
|
const runtimeDir = runtimeDirUnchecked;
|
|
65257
|
-
const veskStateDir =
|
|
65916
|
+
const veskStateDir = join27(projectDir, ".vesk");
|
|
65258
65917
|
const configPluginsRaw = config.plugins || [];
|
|
65259
65918
|
const configPluginNames = configPluginsRaw.map((p) => typeof p === "string" ? p : p?.name).filter((n) => !!n);
|
|
65260
65919
|
const rawDevPlugins = config.plugins || [];
|
|
@@ -65353,21 +66012,21 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65353
66012
|
}
|
|
65354
66013
|
let devGlobalCssContent = "";
|
|
65355
66014
|
let lastServedCssGlobal = "";
|
|
65356
|
-
const appCssPath =
|
|
65357
|
-
const srcDir =
|
|
65358
|
-
const cssPath =
|
|
65359
|
-
const altCssPath =
|
|
66015
|
+
const appCssPath = join27(appDirPath, "global.css");
|
|
66016
|
+
const srcDir = join27(projectDir, "src");
|
|
66017
|
+
const cssPath = join27(srcDir, "global.css");
|
|
66018
|
+
const altCssPath = join27(srcDir, "app.css");
|
|
65360
66019
|
let rawCss = "";
|
|
65361
66020
|
let devCssSource = "";
|
|
65362
66021
|
if (existsSync42(appCssPath)) {
|
|
65363
66022
|
devCssSource = appCssPath;
|
|
65364
|
-
rawCss =
|
|
66023
|
+
rawCss = readFileSync40(appCssPath, "utf-8");
|
|
65365
66024
|
} else if (existsSync42(cssPath)) {
|
|
65366
66025
|
devCssSource = cssPath;
|
|
65367
|
-
rawCss =
|
|
66026
|
+
rawCss = readFileSync40(cssPath, "utf-8");
|
|
65368
66027
|
} else if (existsSync42(altCssPath)) {
|
|
65369
66028
|
devCssSource = altCssPath;
|
|
65370
|
-
rawCss =
|
|
66029
|
+
rawCss = readFileSync40(altCssPath, "utf-8");
|
|
65371
66030
|
}
|
|
65372
66031
|
if (rawCss) {
|
|
65373
66032
|
const activeAtStart = getActiveDevPlugins();
|
|
@@ -65415,22 +66074,22 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65415
66074
|
}
|
|
65416
66075
|
const routeChunksBuilt = /* @__PURE__ */ new Set();
|
|
65417
66076
|
let clientGeneration = 0;
|
|
65418
|
-
const devCacheDir = () =>
|
|
66077
|
+
const devCacheDir = () => join27(projectDir, "node_modules", ".vesk", "dev-cache");
|
|
65419
66078
|
function devCacheKey() {
|
|
65420
66079
|
const parts = [`flags:${!!config.routeDataCache}`];
|
|
65421
66080
|
const walk9 = (dir) => {
|
|
65422
66081
|
let entries = [];
|
|
65423
66082
|
try {
|
|
65424
|
-
entries =
|
|
66083
|
+
entries = readdirSync14(dir);
|
|
65425
66084
|
} catch {
|
|
65426
66085
|
return;
|
|
65427
66086
|
}
|
|
65428
66087
|
for (const name of entries.sort()) {
|
|
65429
66088
|
if (name === "node_modules" || name.startsWith(".")) continue;
|
|
65430
|
-
const p =
|
|
66089
|
+
const p = join27(dir, name);
|
|
65431
66090
|
let st;
|
|
65432
66091
|
try {
|
|
65433
|
-
st =
|
|
66092
|
+
st = statSync22(p);
|
|
65434
66093
|
} catch {
|
|
65435
66094
|
continue;
|
|
65436
66095
|
}
|
|
@@ -65444,15 +66103,15 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65444
66103
|
};
|
|
65445
66104
|
walk9(appDirPath);
|
|
65446
66105
|
try {
|
|
65447
|
-
parts.push(`compiler:${
|
|
66106
|
+
parts.push(`compiler:${readFileSync40(join27(process.cwd(), "node_modules", "@vesk", "compiler", "package.json"), "utf8")}`);
|
|
65448
66107
|
} catch {
|
|
65449
66108
|
}
|
|
65450
|
-
return
|
|
66109
|
+
return createHash3("sha256").update(parts.join("\n")).digest("hex").slice(0, 32);
|
|
65451
66110
|
}
|
|
65452
66111
|
function readDevBundleCache() {
|
|
65453
66112
|
try {
|
|
65454
|
-
const file =
|
|
65455
|
-
const parsed = JSON.parse(
|
|
66113
|
+
const file = join27(devCacheDir(), "client-bundle.json");
|
|
66114
|
+
const parsed = JSON.parse(readFileSync40(file, "utf8"));
|
|
65456
66115
|
if (parsed.key !== devCacheKey() || typeof parsed.main !== "string" || !Array.isArray(parsed.chunks)) return null;
|
|
65457
66116
|
return { main: parsed.main, chunks: parsed.chunks };
|
|
65458
66117
|
} catch {
|
|
@@ -65463,8 +66122,8 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65463
66122
|
try {
|
|
65464
66123
|
const dir = devCacheDir();
|
|
65465
66124
|
mkdirSync19(dir, { recursive: true });
|
|
65466
|
-
const file =
|
|
65467
|
-
const tmp =
|
|
66125
|
+
const file = join27(dir, "client-bundle.json");
|
|
66126
|
+
const tmp = join27(dir, `client-bundle.${process.pid}.tmp`);
|
|
65468
66127
|
writeFileSync21(tmp, JSON.stringify({ key: devCacheKey(), main, chunks }), "utf8");
|
|
65469
66128
|
renameSync2(tmp, file);
|
|
65470
66129
|
} catch {
|
|
@@ -65757,7 +66416,7 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65757
66416
|
if (!filename) return;
|
|
65758
66417
|
const kind = classifyHmrWatchPath(filename);
|
|
65759
66418
|
if (kind === "ignored") return;
|
|
65760
|
-
const fullPath = filename.startsWith("/") ? filename :
|
|
66419
|
+
const fullPath = filename.startsWith("/") ? filename : join27(watchDir, filename);
|
|
65761
66420
|
const fileExists = existsSync42(fullPath);
|
|
65762
66421
|
const bcast = (msg) => {
|
|
65763
66422
|
const f = globalThis.__vesk_broadcastHmr;
|
|
@@ -65782,7 +66441,7 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
65782
66441
|
debounceTimer = setTimeout(async () => {
|
|
65783
66442
|
const t0 = Date.now();
|
|
65784
66443
|
try {
|
|
65785
|
-
const current3 = fileExists ?
|
|
66444
|
+
const current3 = fileExists ? readFileSync40(fullPath, "utf-8") : null;
|
|
65786
66445
|
if (eventType !== "rename" && current3 !== null && lastSeenContent.get(fullPath) === current3) {
|
|
65787
66446
|
LOG.info(`skipped unchanged (${filename})`);
|
|
65788
66447
|
return;
|
|
@@ -65841,7 +66500,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
65841
66500
|
if (compCode.trim()) fnSources = { _raw: compCode };
|
|
65842
66501
|
} else if (fileExists && !bundleError) {
|
|
65843
66502
|
try {
|
|
65844
|
-
const src2 =
|
|
66503
|
+
const src2 = readFileSync40(fullPath, "utf-8");
|
|
65845
66504
|
let compCode = buildHmrEvalSnippet2(
|
|
65846
66505
|
compileClient2(src2, null, { forceClient: true, sourcePath: fullPath, mdRoots: [projectDir] })
|
|
65847
66506
|
);
|
|
@@ -65925,7 +66584,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
65925
66584
|
cssDebounceTimer = setTimeout(async () => {
|
|
65926
66585
|
try {
|
|
65927
66586
|
if (fileExists) {
|
|
65928
|
-
rawCss =
|
|
66587
|
+
rawCss = readFileSync40(fullPath, "utf-8");
|
|
65929
66588
|
}
|
|
65930
66589
|
const cssChanged = await rebuildTailwindCss();
|
|
65931
66590
|
if (cssChanged && typeof globalThis.__vesk_broadcastHmr === "function") {
|
|
@@ -65959,7 +66618,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
65959
66618
|
} catch (e) {
|
|
65960
66619
|
LOG.warn("file watching unavailable, serving without auto-rebuild");
|
|
65961
66620
|
}
|
|
65962
|
-
const
|
|
66621
|
+
const MIME2 = {
|
|
65963
66622
|
".svg": "image/svg+xml",
|
|
65964
66623
|
".css": "text/css",
|
|
65965
66624
|
"": "application/javascript",
|
|
@@ -65972,8 +66631,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
65972
66631
|
".json": "application/json",
|
|
65973
66632
|
".webmanifest": "application/manifest+json"
|
|
65974
66633
|
};
|
|
65975
|
-
const hmrJsPath =
|
|
65976
|
-
const hmrTsPath =
|
|
66634
|
+
const hmrJsPath = join27(runtimeDir, "hmr-client.js");
|
|
66635
|
+
const hmrTsPath = join27(runtimeDir, "hmr-client.ts");
|
|
65977
66636
|
const hmrClientPath = existsSync42(hmrJsPath) ? hmrJsPath : existsSync42(hmrTsPath) ? hmrTsPath : null;
|
|
65978
66637
|
function extractCompName2(src2) {
|
|
65979
66638
|
return resolveComponentName(src2);
|
|
@@ -66082,7 +66741,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66082
66741
|
}
|
|
66083
66742
|
if (url.pathname === "/_vesk/hmr" || url.pathname === "/_vesk/hmr.js") {
|
|
66084
66743
|
if (hmrClientPath) {
|
|
66085
|
-
let hmrContent =
|
|
66744
|
+
let hmrContent = readFileSync40(hmrClientPath, "utf-8");
|
|
66086
66745
|
if (hmrClientPath.endsWith(".ts")) {
|
|
66087
66746
|
hmrContent = stripCodeTypes2(hmrContent);
|
|
66088
66747
|
}
|
|
@@ -66130,10 +66789,10 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66130
66789
|
}
|
|
66131
66790
|
if (url.pathname !== "/") {
|
|
66132
66791
|
const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
|
|
66133
|
-
if (staticPath && existsSync42(staticPath) &&
|
|
66134
|
-
const ext =
|
|
66135
|
-
res.writeHead(200, { "Content-Type":
|
|
66136
|
-
res.end(
|
|
66792
|
+
if (staticPath && existsSync42(staticPath) && statSync22(staticPath).isFile()) {
|
|
66793
|
+
const ext = extname7(staticPath);
|
|
66794
|
+
res.writeHead(200, { "Content-Type": MIME2[ext] || "application/octet-stream" });
|
|
66795
|
+
res.end(readFileSync40(staticPath));
|
|
66137
66796
|
return;
|
|
66138
66797
|
}
|
|
66139
66798
|
}
|
|
@@ -66157,7 +66816,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66157
66816
|
return;
|
|
66158
66817
|
}
|
|
66159
66818
|
const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
|
|
66160
|
-
const apiDirPath =
|
|
66819
|
+
const apiDirPath = join27(appDirPath, "api");
|
|
66161
66820
|
if (url.pathname.startsWith("/api") && existsSync42(apiDirPath)) {
|
|
66162
66821
|
const apiRoutes = await scanApiRoutes(apiDirPath);
|
|
66163
66822
|
const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
|
|
@@ -66236,7 +66895,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66236
66895
|
const nfPath = resolve38(appDirPath, rootNode.sourceDir, "not-found.vsk");
|
|
66237
66896
|
if (existsSync42(nfPath)) {
|
|
66238
66897
|
try {
|
|
66239
|
-
const nfSrc =
|
|
66898
|
+
const nfSrc = readFileSync40(nfPath, "utf-8");
|
|
66240
66899
|
const nfCompName = extractCompName2(nfSrc) || rootNode.notFound;
|
|
66241
66900
|
notFoundHtml = await renderFullPage(nfSrc, nfCompName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: nfPath, cached: cachedSsrCompile(ssrCompileCache, nfSrc, nfPath), plugins: getActiveDevPlugins() });
|
|
66242
66901
|
} catch {
|
|
@@ -66291,7 +66950,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66291
66950
|
const pageFilePath = resolve38(appDirPath, node.sourceDir, "page.vsk");
|
|
66292
66951
|
const layoutFilePath = resolve38(appDirPath, node.sourceDir, "layout.vsk");
|
|
66293
66952
|
if (i === chain.length - 1 && node.page && existsSync42(pageFilePath)) {
|
|
66294
|
-
const src2 =
|
|
66953
|
+
const src2 = readFileSync40(pageFilePath, "utf-8");
|
|
66295
66954
|
const compName = extractCompName2(src2) || node.page;
|
|
66296
66955
|
const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, pageFilePath) });
|
|
66297
66956
|
body = result.body;
|
|
@@ -66299,7 +66958,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
66299
66958
|
props = result.props;
|
|
66300
66959
|
}
|
|
66301
66960
|
if (node.layout && existsSync42(layoutFilePath)) {
|
|
66302
|
-
const src2 =
|
|
66961
|
+
const src2 = readFileSync40(layoutFilePath, "utf-8");
|
|
66303
66962
|
const compName = extractCompName2(src2) || node.layout;
|
|
66304
66963
|
const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, layoutFilePath) });
|
|
66305
66964
|
body = result.body;
|
|
@@ -66344,7 +67003,7 @@ ${prettifyHtml(body)}
|
|
|
66344
67003
|
} else {
|
|
66345
67004
|
const leaf2 = chain.find((n) => n.page);
|
|
66346
67005
|
if (leaf2) {
|
|
66347
|
-
const src2 =
|
|
67006
|
+
const src2 = readFileSync40(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
|
|
66348
67007
|
const compName = extractCompName2(src2) || leaf2.page;
|
|
66349
67008
|
html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), cached: cachedSsrCompile(ssrCompileCache, src2, resolve38(appDirPath, leaf2.sourceDir, "page.vsk")), plugins: getActiveDevPlugins() });
|
|
66350
67009
|
html = html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
|
|
@@ -66373,7 +67032,7 @@ ${prettifyHtml(body)}
|
|
|
66373
67032
|
if (!hasLayout) {
|
|
66374
67033
|
const leaf2 = chain.find((n) => n.page);
|
|
66375
67034
|
if (leaf2) {
|
|
66376
|
-
const src2 =
|
|
67035
|
+
const src2 = readFileSync40(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
|
|
66377
67036
|
const compName = extractCompName2(src2) || leaf2.page;
|
|
66378
67037
|
yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), cached: cachedSsrCompile(ssrCompileCache, src2, resolve38(appDirPath, leaf2.sourceDir, "page.vsk")), plugins: getActiveDevPlugins() });
|
|
66379
67038
|
} else {
|
|
@@ -66389,7 +67048,7 @@ ${prettifyHtml(body)}
|
|
|
66389
67048
|
const pageFilePath = resolve38(appDirPath, node.sourceDir, "page.vsk");
|
|
66390
67049
|
const layoutFilePath = resolve38(appDirPath, node.sourceDir, "layout.vsk");
|
|
66391
67050
|
if (i === chain.length - 1 && node.page && existsSync42(pageFilePath)) {
|
|
66392
|
-
const src2 =
|
|
67051
|
+
const src2 = readFileSync40(pageFilePath, "utf-8");
|
|
66393
67052
|
const compName = extractCompName2(src2) || node.page;
|
|
66394
67053
|
const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, pageFilePath) });
|
|
66395
67054
|
body = result.body;
|
|
@@ -66397,7 +67056,7 @@ ${prettifyHtml(body)}
|
|
|
66397
67056
|
props = result.props;
|
|
66398
67057
|
}
|
|
66399
67058
|
if (node.layout && existsSync42(layoutFilePath)) {
|
|
66400
|
-
const src2 =
|
|
67059
|
+
const src2 = readFileSync40(layoutFilePath, "utf-8");
|
|
66401
67060
|
const compName = extractCompName2(src2) || node.layout;
|
|
66402
67061
|
const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, layoutFilePath) });
|
|
66403
67062
|
body = result.body;
|
|
@@ -66541,7 +67200,7 @@ ${prettifyHtml(body)}
|
|
|
66541
67200
|
const nfPath = resolve38(appDirPath, node.sourceDir, "not-found.vsk");
|
|
66542
67201
|
if (existsSync42(nfPath)) {
|
|
66543
67202
|
try {
|
|
66544
|
-
const nfSrc =
|
|
67203
|
+
const nfSrc = readFileSync40(nfPath, "utf-8");
|
|
66545
67204
|
const nfCompName = extractCompName2(nfSrc) || node.notFound;
|
|
66546
67205
|
const html = await renderFullPage(nfSrc, nfCompName, { params: match.params, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: nfPath, cached: cachedSsrCompile(ssrCompileCache, nfSrc, nfPath), plugins: getActiveDevPlugins() });
|
|
66547
67206
|
notFoundHtml = injectDevScripts(html);
|
|
@@ -66587,7 +67246,7 @@ ${prettifyHtml(body)}
|
|
|
66587
67246
|
const errPath = resolve38(appDirPath, node.sourceDir, "error.vsk");
|
|
66588
67247
|
if (existsSync42(errPath)) {
|
|
66589
67248
|
try {
|
|
66590
|
-
const errSrc =
|
|
67249
|
+
const errSrc = readFileSync40(errPath, "utf-8");
|
|
66591
67250
|
const errCompName = extractCompName2(errSrc) || node.error;
|
|
66592
67251
|
const errProps = {
|
|
66593
67252
|
error: err.message,
|
|
@@ -66659,7 +67318,7 @@ ${prettifyHtml(body)}
|
|
|
66659
67318
|
LOG.ok(`dev server at http://localhost:${port} (listening on ${bindHost})`);
|
|
66660
67319
|
const routes = collectRoutePaths(routeTree);
|
|
66661
67320
|
const pageCount = countPages(routeTree);
|
|
66662
|
-
const apiCount = countFilesNamed(
|
|
67321
|
+
const apiCount = countFilesNamed(join27(appDirPath, "api"), "route.ts");
|
|
66663
67322
|
LOG.info(`${projectDir}`);
|
|
66664
67323
|
LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
|
|
66665
67324
|
if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
|
|
@@ -66986,12 +67645,12 @@ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
|
66986
67645
|
}
|
|
66987
67646
|
function loadEnvFiles(projectDir) {
|
|
66988
67647
|
const files = [
|
|
66989
|
-
|
|
66990
|
-
|
|
67648
|
+
join31(projectDir, ".env"),
|
|
67649
|
+
join31(projectDir, ".env.local")
|
|
66991
67650
|
];
|
|
66992
67651
|
for (const filePath of files) {
|
|
66993
67652
|
if (!existsSync45(filePath)) continue;
|
|
66994
|
-
const content =
|
|
67653
|
+
const content = readFileSync44(filePath, "utf-8");
|
|
66995
67654
|
for (const line of content.split("\n")) {
|
|
66996
67655
|
const trimmed = line.trim();
|
|
66997
67656
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -67160,7 +67819,7 @@ if (cmd === "start") {
|
|
|
67160
67819
|
if (cmd === "init") {
|
|
67161
67820
|
const projectDir = process.cwd();
|
|
67162
67821
|
const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
|
|
67163
|
-
const target =
|
|
67822
|
+
const target = join31(appDirPath, "global.css");
|
|
67164
67823
|
if (existsSync45(target)) {
|
|
67165
67824
|
console.error(`vesk init: ${target} already exists \u2014 skipping`);
|
|
67166
67825
|
process.exit(0);
|
|
@@ -67181,7 +67840,7 @@ if (cmd === "migrate") {
|
|
|
67181
67840
|
const projectDir = process.cwd();
|
|
67182
67841
|
const { runMigrate: runMigrate2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
|
67183
67842
|
const { CODEMODS: CODEMODS2 } = await Promise.resolve().then(() => (init_codemods(), codemods_exports));
|
|
67184
|
-
const { version: cliVersion } = JSON.parse(
|
|
67843
|
+
const { version: cliVersion } = JSON.parse(readFileSync44(join31(__dirname10, "..", "package.json"), "utf-8"));
|
|
67185
67844
|
if (args.includes("--list")) {
|
|
67186
67845
|
console.error("vesk migrate: available codemods");
|
|
67187
67846
|
for (const c of CODEMODS2) {
|