@vesk/vesk-cli 0.2.68 → 0.2.70

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.
Files changed (2) hide show
  1. package/dist/cli.js +770 -374
  2. 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 statSync4, readFileSync as readFileSync12 } from "node:fs";
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) && statSync4(abs).isFile()) return readFileSync12(abs, "utf8");
35631
+ if (existsSync12(abs) && statSync5(abs).isFile()) return readFileSync14(abs, "utf8");
35632
35632
  } catch {
35633
35633
  }
35634
35634
  }
@@ -35645,14 +35645,14 @@ var init_paths = __esm({
35645
35645
  import {
35646
35646
  mkdirSync as mkdirSync6,
35647
35647
  copyFileSync as copyFileSync2,
35648
- readdirSync as readdirSync3,
35649
- statSync as statSync6,
35648
+ readdirSync as readdirSync4,
35649
+ statSync as statSync7,
35650
35650
  existsSync as existsSync15,
35651
35651
  writeFileSync as writeFileSync7,
35652
35652
  rmSync as rmSync2,
35653
- readFileSync as readFileSync15
35653
+ readFileSync as readFileSync17
35654
35654
  } from "node:fs";
35655
- import { resolve as resolve13, join as join10, extname as extname3, dirname as dirname10 } from "node:path";
35655
+ import { resolve as resolve13, join as join11, extname as extname3, dirname as dirname10 } from "node:path";
35656
35656
  function ensureCleanDir(dir) {
35657
35657
  rmSync2(dir, { recursive: true, force: true });
35658
35658
  mkdirSync6(dir, { recursive: true });
@@ -35660,10 +35660,10 @@ function ensureCleanDir(dir) {
35660
35660
  function copyDirContents(srcDir, destDir) {
35661
35661
  if (!existsSync15(srcDir)) return;
35662
35662
  mkdirSync6(destDir, { recursive: true });
35663
- for (const entry of readdirSync3(srcDir)) {
35664
- const srcPath = join10(srcDir, entry);
35665
- const destPath = join10(destDir, entry);
35666
- if (statSync6(srcPath).isDirectory()) {
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
35667
  copyDirContents(srcPath, destPath);
35668
35668
  } else {
35669
35669
  mkdirSync6(dirname10(destPath), { recursive: true });
@@ -35693,7 +35693,7 @@ function writePlatformStatic(buildStaticDir, platformStaticDir) {
35693
35693
  function writePrerenderedStatic(prerenderedRoutes, platformStaticDir) {
35694
35694
  for (const route of prerenderedRoutes) {
35695
35695
  if (!existsSync15(route.html)) continue;
35696
- const content = readFileSync15(route.html);
35696
+ const content = readFileSync17(route.html);
35697
35697
  const htmlRel = route.path === "/" ? "index.html" : `${route.path.replace(/^\//, "")}.html`;
35698
35698
  const target = resolve13(platformStaticDir, "_vesk", "static", "public", htmlRel);
35699
35699
  writeFile(target, content);
@@ -35707,13 +35707,13 @@ function listStaticDir(dir) {
35707
35707
  const out = [];
35708
35708
  if (!existsSync15(dir)) return out;
35709
35709
  function walk9(d, prefix) {
35710
- for (const entry of readdirSync3(d)) {
35711
- const full = join10(d, entry);
35710
+ for (const entry of readdirSync4(d)) {
35711
+ const full = join11(d, entry);
35712
35712
  const rel = prefix ? `${prefix}/${entry}` : entry;
35713
- if (statSync6(full).isDirectory()) {
35713
+ if (statSync7(full).isDirectory()) {
35714
35714
  walk9(full, rel);
35715
35715
  } else {
35716
- out.push({ rel, buffer: readFileSync15(full) });
35716
+ out.push({ rel, buffer: readFileSync17(full) });
35717
35717
  }
35718
35718
  }
35719
35719
  }
@@ -35775,13 +35775,13 @@ __export(plugins_exports, {
35775
35775
  writePluginState: () => writePluginState
35776
35776
  });
35777
35777
  import {
35778
- readFileSync as readFileSync17,
35778
+ readFileSync as readFileSync19,
35779
35779
  writeFileSync as writeFileSync8,
35780
35780
  existsSync as existsSync17,
35781
35781
  mkdirSync as mkdirSync7,
35782
- statSync as statSync8
35782
+ statSync as statSync9
35783
35783
  } from "node:fs";
35784
- import { resolve as resolve15, dirname as dirname12, join as join11, extname as extname4, basename as basename2 } from "node:path";
35784
+ import { resolve as resolve15, dirname as dirname12, join as join12, extname as extname4, basename as basename2 } from "node:path";
35785
35785
  import { createRequire as createRequire4 } from "node:module";
35786
35786
  import { spawn } from "node:child_process";
35787
35787
  function defaultState() {
@@ -35798,7 +35798,7 @@ function readPluginState(veskDir) {
35798
35798
  if (!existsSync17(file)) return defaultState();
35799
35799
  let raw2;
35800
35800
  try {
35801
- raw2 = JSON.parse(readFileSync17(file, "utf-8"));
35801
+ raw2 = JSON.parse(readFileSync19(file, "utf-8"));
35802
35802
  } catch {
35803
35803
  return defaultState();
35804
35804
  }
@@ -35833,7 +35833,7 @@ function resolvePackage(appDir, pkg) {
35833
35833
  const seen = /* @__PURE__ */ new Set();
35834
35834
  while (cur && cur !== dirname12(cur) && !seen.has(cur)) {
35835
35835
  seen.add(cur);
35836
- const candidate = join11(cur, "package.json");
35836
+ const candidate = join12(cur, "package.json");
35837
35837
  if (existsSync17(candidate)) {
35838
35838
  pkgJsonPath = candidate;
35839
35839
  break;
@@ -35861,7 +35861,7 @@ function resolvePackage(appDir, pkg) {
35861
35861
  }
35862
35862
  }
35863
35863
  if (localPath) {
35864
- const localJson = join11(localPath, "package.json");
35864
+ const localJson = join12(localPath, "package.json");
35865
35865
  let json = null;
35866
35866
  if (existsSync17(localJson)) {
35867
35867
  json = readJsonFile(localJson);
@@ -35884,7 +35884,7 @@ function localDir(base, pkg) {
35884
35884
  }
35885
35885
  function readJsonFile(file) {
35886
35886
  try {
35887
- if (existsSync17(file)) return JSON.parse(readFileSync17(file, "utf-8"));
35887
+ if (existsSync17(file)) return JSON.parse(readFileSync19(file, "utf-8"));
35888
35888
  } catch {
35889
35889
  }
35890
35890
  return null;
@@ -36163,11 +36163,11 @@ function findIconFile(dir, meta) {
36163
36163
  const explicit = str(meta?.icon);
36164
36164
  if (explicit) {
36165
36165
  const p = resolveWithin(dir, explicit);
36166
- if (p && existsSync17(p) && statSync8(p).isFile()) return p;
36166
+ if (p && existsSync17(p) && statSync9(p).isFile()) return p;
36167
36167
  }
36168
36168
  for (const name of ["icon.png", "icon.ico"]) {
36169
36169
  const p = resolve15(dir, name);
36170
- if (existsSync17(p) && statSync8(p).isFile()) return p;
36170
+ if (existsSync17(p) && statSync9(p).isFile()) return p;
36171
36171
  }
36172
36172
  return null;
36173
36173
  }
@@ -36238,7 +36238,7 @@ function resolveDtsPath(probe, pkgJson) {
36238
36238
  for (const rel of candidates) {
36239
36239
  if (!rel) continue;
36240
36240
  const abs = resolveWithin(dir, rel);
36241
- if (abs && existsSync17(abs) && statSync8(abs).isFile()) return abs;
36241
+ if (abs && existsSync17(abs) && statSync9(abs).isFile()) return abs;
36242
36242
  }
36243
36243
  return null;
36244
36244
  }
@@ -36554,7 +36554,7 @@ function introspectPlugin(appDir, name) {
36554
36554
  const pkgName = str(pkgJson.name) ?? name;
36555
36555
  const exportsMap = flattenPackageExports(pkgJson.exports);
36556
36556
  const dtsPath = resolveDtsPath(probe, pkgJson);
36557
- const dtsExports = dtsPath ? parseDtsExports(readFileSync17(dtsPath, "utf-8")) : [];
36557
+ const dtsExports = dtsPath ? parseDtsExports(readFileSync19(dtsPath, "utf-8")) : [];
36558
36558
  return {
36559
36559
  ok: true,
36560
36560
  name: pkgName,
@@ -36695,8 +36695,8 @@ __export(static_exports, {
36695
36695
  generateSitemap: () => generateSitemap,
36696
36696
  generateSsgRoutes: () => generateSsgRoutes
36697
36697
  });
36698
- import { mkdirSync as mkdirSync8, copyFileSync as copyFileSync3, readdirSync as readdirSync4, statSync as statSync9, existsSync as existsSync18, writeFileSync as writeFileSync9, readFileSync as readFileSync18 } from "node:fs";
36699
- import { resolve as resolve16, join as join12 } from "node:path";
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";
36700
36700
  function copyStaticAssets2(publicDir, outDir) {
36701
36701
  const targetDir = resolve16(outDir, "static", "public");
36702
36702
  mkdirSync8(targetDir, { recursive: true });
@@ -36704,11 +36704,11 @@ function copyStaticAssets2(publicDir, outDir) {
36704
36704
  return;
36705
36705
  function copyDir(src2, dest) {
36706
36706
  mkdirSync8(dest, { recursive: true });
36707
- const entries = readdirSync4(src2);
36707
+ const entries = readdirSync5(src2);
36708
36708
  for (const entry of entries) {
36709
- const srcPath = join12(src2, entry);
36710
- const destPath = join12(dest, entry);
36711
- const st = statSync9(srcPath);
36709
+ const srcPath = join13(src2, entry);
36710
+ const destPath = join13(dest, entry);
36711
+ const st = statSync10(srcPath);
36712
36712
  if (st.isDirectory()) {
36713
36713
  copyDir(srcPath, destPath);
36714
36714
  } else {
@@ -36741,7 +36741,7 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
36741
36741
  for (const node of nodes) {
36742
36742
  if (node.page) {
36743
36743
  const pagePath = resolve16(appDir, node.sourceDir, "page.vsk");
36744
- const src2 = readFileSync18(pagePath, "utf-8");
36744
+ const src2 = readFileSync20(pagePath, "utf-8");
36745
36745
  const hasStaticProps = src2.includes("getStaticProps");
36746
36746
  const hasStaticPaths = src2.includes("getStaticPaths");
36747
36747
  if (hasStaticPaths) {
@@ -36842,17 +36842,17 @@ __export(image_pipeline_exports, {
36842
36842
  collectImageRefs: () => collectImageRefs,
36843
36843
  optimizeImages: () => optimizeImages
36844
36844
  });
36845
- import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync10, readFileSync as readFileSync19, existsSync as existsSync19, readdirSync as readdirSync5, statSync as statSync10 } from "node:fs";
36845
+ import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync10, readFileSync as readFileSync21, existsSync as existsSync19, readdirSync as readdirSync6, statSync as statSync11 } from "node:fs";
36846
36846
  import { spawnSync } from "node:child_process";
36847
- import { resolve as resolve17, extname as extname5, dirname as dirname13, join as join13 } from "node:path";
36847
+ import { resolve as resolve17, extname as extname5, dirname as dirname13, join as join14 } from "node:path";
36848
36848
  import { createRequire as createRequire5 } from "node:module";
36849
36849
  import { tmpdir as tmpdir2 } from "node:os";
36850
36850
  function probeMemoPath() {
36851
36851
  try {
36852
36852
  const req = createRequire5(import.meta.url);
36853
36853
  const entry = req.resolve("sharp");
36854
- const stamp = Math.round(statSync10(entry).mtimeMs);
36855
- return join13(tmpdir2(), `vesk-sharp-probe-${process.platform}-${process.arch}-${stamp}.json`);
36854
+ const stamp = Math.round(statSync11(entry).mtimeMs);
36855
+ return join14(tmpdir2(), `vesk-sharp-probe-${process.platform}-${process.arch}-${stamp}.json`);
36856
36856
  } catch {
36857
36857
  return null;
36858
36858
  }
@@ -36862,7 +36862,7 @@ function readProbeMemo() {
36862
36862
  if (path === null)
36863
36863
  return null;
36864
36864
  try {
36865
- return JSON.parse(readFileSync19(path, "utf-8"))?.usable === true;
36865
+ return JSON.parse(readFileSync21(path, "utf-8"))?.usable === true;
36866
36866
  } catch {
36867
36867
  return null;
36868
36868
  }
@@ -36905,7 +36905,7 @@ async function ensureSharp() {
36905
36905
  async function processImage(srcPath, outDir, baseName) {
36906
36906
  const image = sharpFn ? sharpFn(srcPath) : null;
36907
36907
  if (!image) {
36908
- const original = readFileSync19(srcPath);
36908
+ const original = readFileSync21(srcPath);
36909
36909
  const ext = extname5(srcPath);
36910
36910
  const written = [];
36911
36911
  for (const w of OUTPUT_WIDTHS) {
@@ -36924,7 +36924,7 @@ async function processImage(srcPath, outDir, baseName) {
36924
36924
  if (w >= originalWidth) {
36925
36925
  const copyPath = resolve17(outDir, `${base}${extname5(srcPath)}`);
36926
36926
  mkdirSync9(dirname13(copyPath), { recursive: true });
36927
- writeFileSync10(copyPath, readFileSync19(srcPath));
36927
+ writeFileSync10(copyPath, readFileSync21(srcPath));
36928
36928
  generated.push(copyPath);
36929
36929
  continue;
36930
36930
  }
@@ -36946,19 +36946,19 @@ function collectImageRefs(appDir) {
36946
36946
  function walk9(dir) {
36947
36947
  let entries;
36948
36948
  try {
36949
- entries = readdirSync5(dir);
36949
+ entries = readdirSync6(dir);
36950
36950
  } catch {
36951
36951
  return;
36952
36952
  }
36953
36953
  for (const entry of entries) {
36954
36954
  const full = resolve17(dir, entry);
36955
- const st = statSync10(full);
36955
+ const st = statSync11(full);
36956
36956
  if (st.isDirectory()) {
36957
36957
  if (entry.startsWith("."))
36958
36958
  continue;
36959
36959
  walk9(full);
36960
36960
  } else if (entry.endsWith(".vsk")) {
36961
- const src2 = readFileSync19(full, "utf-8");
36961
+ const src2 = readFileSync21(full, "utf-8");
36962
36962
  const imgRegex = /<Image\s[^>]*src=["']([^"']+)["']/g;
36963
36963
  let m;
36964
36964
  while ((m = imgRegex.exec(src2)) !== null) {
@@ -37034,19 +37034,19 @@ var seo_audit_exports = {};
37034
37034
  __export(seo_audit_exports, {
37035
37035
  runSeoAudit: () => runSeoAudit
37036
37036
  });
37037
- import { readFileSync as readFileSync20, existsSync as existsSync20, readdirSync as readdirSync6, statSync as statSync11 } from "node:fs";
37037
+ import { readFileSync as readFileSync22, existsSync as existsSync20, readdirSync as readdirSync7, statSync as statSync12 } from "node:fs";
37038
37038
  import { resolve as resolve18 } from "node:path";
37039
37039
  function walkFiles(dir) {
37040
37040
  const results = [];
37041
37041
  let entries;
37042
37042
  try {
37043
- entries = readdirSync6(dir);
37043
+ entries = readdirSync7(dir);
37044
37044
  } catch {
37045
37045
  return results;
37046
37046
  }
37047
37047
  for (const entry of entries) {
37048
37048
  const full = resolve18(dir, entry);
37049
- const st = statSync11(full);
37049
+ const st = statSync12(full);
37050
37050
  if (st.isDirectory()) {
37051
37051
  if (!entry.startsWith("."))
37052
37052
  results.push(...walkFiles(full));
@@ -37062,8 +37062,8 @@ function collectCombinedSource(appDir) {
37062
37062
  for (const pagePath of pages) {
37063
37063
  const dir = resolve18(pagePath, "..");
37064
37064
  const layoutPath = resolve18(dir, "layout.vsk");
37065
- const pageSrc = readFileSync20(pagePath, "utf-8");
37066
- const layoutSrc = existsSync20(layoutPath) ? readFileSync20(layoutPath, "utf-8") : "";
37065
+ const pageSrc = readFileSync22(pagePath, "utf-8");
37066
+ const layoutSrc = existsSync20(layoutPath) ? readFileSync22(layoutPath, "utf-8") : "";
37067
37067
  const combinedSrc = layoutSrc ? layoutSrc + "\n" + pageSrc : pageSrc;
37068
37068
  combined.push({
37069
37069
  path: pagePath,
@@ -37259,7 +37259,7 @@ var init_platform = __esm({
37259
37259
 
37260
37260
  // ../adapter/src/platform-handler.ts
37261
37261
  import { existsSync as existsSync21 } from "node:fs";
37262
- import { resolve as resolve19, dirname as dirname14, join as join14 } from "node:path";
37262
+ import { resolve as resolve19, dirname as dirname14, join as join15 } from "node:path";
37263
37263
  import { fileURLToPath as fileURLToPath4 } from "node:url";
37264
37264
  function routeName2(segments) {
37265
37265
  const parts = segments.filter(Boolean).map((s) => {
@@ -37282,8 +37282,8 @@ function findCompilerSrc2(appDir) {
37282
37282
  resolve19(appDir, "node_modules", "@vesk/compiler")
37283
37283
  ];
37284
37284
  for (const base of candidates) {
37285
- for (const dir of [base, join14(base, "dist")]) {
37286
- if (existsSync21(join14(dir, "server-cookies.js"))) return dir;
37285
+ for (const dir of [base, join15(base, "dist")]) {
37286
+ if (existsSync21(join15(dir, "server-cookies.js"))) return dir;
37287
37287
  }
37288
37288
  }
37289
37289
  throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
@@ -42307,8 +42307,8 @@ __export(typecheck_exports, {
42307
42307
  formatTypecheckWarnings: () => formatTypecheckWarnings,
42308
42308
  typecheckProject: () => typecheckProject
42309
42309
  });
42310
- import { readFileSync as readFileSync39, readdirSync as readdirSync14, statSync as statSync22 } from "node:fs";
42311
- import { join as join27, dirname as dirname27, normalize, relative as relative8, resolve as resolve39, sep as sep7 } from "node:path";
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 = readdirSync14(dir);
42319
+ entries = readdirSync15(dir);
42320
42320
  } catch {
42321
42321
  return;
42322
42322
  }
42323
42323
  for (const e of entries) {
42324
- const p = join27(dir, e);
42324
+ const p = join28(dir, e);
42325
42325
  let st;
42326
42326
  try {
42327
- st = statSync22(p);
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 = join27(appDir, "__vesk_ambient.d.ts");
42380
- const overridePath = join27(appDir, "__vesk_runtime_override.d.ts");
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 readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join27(dir, d.name));
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 ?? join27(dirname27(containingFile), text));
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(join27(dirname27(containingFile), text));
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 ?? join27(projectRoot, "app");
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 = readFileSync39(f, "utf-8");
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 = join27(appDir, "__vesk_ambient.d.ts");
42560
- const overridePath = join27(appDir, "__vesk_runtime_override.d.ts");
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 readFileSync40, existsSync as existsSync43 } from "node:fs";
48682
- import { join as join28 } from "node:path";
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 ? join28(projectDir, "node_modules", "@vesk", "types", "dist", "index.d.ts") : null,
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 = readFileSync40(path, "utf-8");
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 readFileSync41, writeFileSync as writeFileSync22, existsSync as existsSync44, statSync as statSync23, readdirSync as readdirSync15 } from "node:fs";
48832
- import { join as join29, relative as relative9, extname as extname8 } from "node:path";
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 = join29(projectDir, "node_modules", pkg, "package.json");
48835
+ const p = join30(projectDir, "node_modules", pkg, "package.json");
48836
48836
  if (!existsSync44(p)) continue;
48837
48837
  try {
48838
- const version2 = JSON.parse(readFileSync41(p, "utf-8")).version;
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,16 +48846,16 @@ function collectTargets(dir, root3 = dir) {
48846
48846
  const out = [];
48847
48847
  let entries;
48848
48848
  try {
48849
- entries = readdirSync15(dir);
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 = join29(dir, entry);
48855
+ const full = join30(dir, entry);
48856
48856
  let st;
48857
48857
  try {
48858
- st = statSync23(full);
48858
+ st = statSync24(full);
48859
48859
  } catch {
48860
48860
  continue;
48861
48861
  }
@@ -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 = join29(options.projectDir, relPath);
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 = readFileSync41(abs, "utf-8");
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 readFileSync42, writeFileSync as writeFileSync23, mkdirSync as mkdirSync20, existsSync as existsSync45 } from "fs";
48936
- import { resolve as resolve40, join as join30 } from "path";
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 readFileSync21 } from "node:fs";
49515
- import { resolve as resolve21, dirname as dirname16, relative as relative4, basename as basename3, join as join15 } from "node:path";
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
@@ -49909,11 +49909,26 @@ function resolveCssUrls(opts) {
49909
49909
 
49910
49910
  // ../adapter/src/ssr-function.ts
49911
49911
  init_default_pages();
49912
- function resolveErrorFile(sourceDir, appDir) {
49912
+ function resolveBoundaryFile(sourceDir, appDir, file) {
49913
49913
  const rel = relative(appDir, sourceDir).split("/").filter(Boolean);
49914
49914
  for (let depth = rel.length; depth >= 0; depth--) {
49915
49915
  const dir = depth === 0 ? appDir : join5(appDir, ...rel.slice(0, depth));
49916
- const p = join5(dir, "error.vsk");
49916
+ const p = join5(dir, file);
49917
+ if (existsSync8(p)) return p;
49918
+ }
49919
+ return null;
49920
+ }
49921
+ function resolveErrorFile(sourceDir, appDir) {
49922
+ return resolveBoundaryFile(sourceDir, appDir, "error.vsk");
49923
+ }
49924
+ function resolveNotFoundFile(sourceDir, appDir) {
49925
+ return resolveBoundaryFile(sourceDir, appDir, "not-found.vsk");
49926
+ }
49927
+ function resolveBoundaryFileForUrl(pathname, appDir, file) {
49928
+ const segments = pathname.split("/").filter(Boolean);
49929
+ for (let depth = segments.length; depth >= 0; depth--) {
49930
+ const dir = join5(appDir, ...segments.slice(0, depth));
49931
+ const p = join5(dir, file);
49917
49932
  if (existsSync8(p)) return p;
49918
49933
  }
49919
49934
  return null;
@@ -50053,6 +50068,12 @@ function generateSsrFunction(routeNode, appDir, outDir, componentMap, options) {
50053
50068
  const errorVars = errorPath ? `const _errorComp = ${JSON.stringify(errorComp)};
50054
50069
  const _errorCompiled = ${hydrateInvoke(precompilePlan(errorPath))};
50055
50070
  ` : "const _errorComp = null;\nconst _errorCompiled = null;\n";
50071
+ const notFoundPath = resolveNotFoundFile(routeNode.sourceDir, appDir);
50072
+ const notFoundSrc = notFoundPath ? readFileSync7(notFoundPath, "utf-8") : null;
50073
+ const notFoundComp = notFoundPath ? extractCompName(notFoundSrc) || "NotFound" : null;
50074
+ const notFoundVars = notFoundPath ? `const _notFoundComp = ${JSON.stringify(notFoundComp)};
50075
+ const _notFoundCompiled = ${hydrateInvoke(precompilePlan(notFoundPath))};
50076
+ ` : "const _notFoundComp = null;\nconst _notFoundCompiled = null;\n";
50056
50077
  let src2 = "";
50057
50078
  if (layoutDecls.length > 0) {
50058
50079
  src2 = `const _pageComp = ${JSON.stringify(pageComp)};
@@ -50065,13 +50086,13 @@ const _errorCompiled = ${hydrateInvoke(precompilePlan(errorPath))};
50065
50086
  ${layoutDecls.map((d) => " " + d.compiled + ",").join("\n")}
50066
50087
  ];
50067
50088
  `;
50068
- src2 += errorVars;
50089
+ src2 += errorVars + notFoundVars;
50069
50090
  } else {
50070
50091
  src2 = `const _comp = ${JSON.stringify(pageComp)};
50071
50092
  `;
50072
50093
  src2 += `const _compiled = (() => { try { return hydratePrecompile(${pagePlan}); } catch { return null; } })();
50073
50094
  `;
50074
- src2 += errorVars;
50095
+ src2 += errorVars + notFoundVars;
50075
50096
  }
50076
50097
  const urlParts = routeNode.fullPath.split("/").filter(Boolean);
50077
50098
  const paramExprs = buildParamExtraction(routeNode, urlParts);
@@ -50113,30 +50134,66 @@ ${layoutDecls.map((d) => " " + d.compiled + ",").join("\n")}
50113
50134
  " }",
50114
50135
  "}",
50115
50136
  "",
50137
+ // Returns null rather than throwing when there is no boundary, so the
50138
+ // caller can re-throw the original NotFoundError and let the server answer
50139
+ // — a page with no not-found.vsk anywhere must still get a 404.
50140
+ "async function __renderNotFoundBody(props) {",
50141
+ " if (!_notFoundComp) return null;",
50142
+ " try {",
50143
+ " const result = await renderPage('', _notFoundComp, props, __componentRegistry, { hydrate: true, cached: _notFoundCompiled });",
50144
+ " return result.body;",
50145
+ " } catch {",
50146
+ " return null;",
50147
+ " }",
50148
+ "}",
50149
+ "",
50150
+ // The layout wrap, shared by the page / error / not-found paths. Extracted
50151
+ // because three call sites that each re-implemented it is three chances to
50152
+ // forget the head merge.
50153
+ "async function __wrapLayouts(params, body, head) {",
50154
+ " let _b = body;",
50155
+ ' let _h = head || "";',
50156
+ " for (let _i = _layoutCompList.length - 1; _i > 0; _i--) {",
50157
+ " const _inner = await renderPage('', _layoutCompList[_i], { params, children: _b }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[_i] });",
50158
+ " _b = _inner.body;",
50159
+ " if (_inner.head) _h = _inner.head + _h;",
50160
+ " }",
50161
+ " return renderFullPage('', _layoutCompList[0], { params, children: _b }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[0]" + bakedOptions + clientScriptOption + dataScriptOption + ", pageHead: _h });",
50162
+ "}",
50163
+ "",
50116
50164
  "async function __renderHtml(params, requestUrl) {",
50117
50165
  " return withSsrStore(async () => {",
50118
50166
  " resetPersistedStoreKeys();",
50119
50167
  " let page;",
50120
50168
  " let caughtError = null;",
50169
+ " let notFound = false;",
50121
50170
  " const __expose = process.env.NODE_ENV !== 'production';",
50122
50171
  " try {",
50123
50172
  " page = await renderPage('', _pageComp, { params }, __componentRegistry, { hydrate: true, cached: _pageCompiled });",
50124
50173
  " } catch (err) {",
50125
- " if (err && (err.name === 'NotFoundError' || err.name === 'Redirect')) throw err;",
50126
- " caughtError = err;",
50127
- " const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : String(err);",
50128
- " const stack = err && typeof err === 'object' && 'stack' in err ? String(err.stack) : '';",
50129
- " page = { body: await __renderErrorBody({ params, statusCode: 500, error: __expose ? message : 'Internal Server Error', stack: __expose ? stack : '', url: requestUrl || '' }), head: '' };",
50174
+ " if (err && err.name === 'Redirect') throw err;",
50175
+ " if (err && err.name === 'NotFoundError') {",
50176
+ // The boundary is chosen per-route at build time (resolveNotFoundFile walks
50177
+ // this route's own directory up to the app root), so a nested
50178
+ // app/admin/not-found.vsk answers /admin/* and the root one answers the
50179
+ // rest — matching the client router's deepest-first chain walk.
50180
+ " const nfBody = await __renderNotFoundBody({ params, url: requestUrl || '' });",
50181
+ " if (nfBody !== null) {",
50182
+ " notFound = true;",
50183
+ " page = { body: nfBody, head: '' };",
50184
+ " } else {",
50185
+ " throw err;",
50186
+ " }",
50187
+ " } else {",
50188
+ " caughtError = err;",
50189
+ " const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : String(err);",
50190
+ " const stack = err && typeof err === 'object' && 'stack' in err ? String(err.stack) : '';",
50191
+ " page = { body: await __renderErrorBody({ params, statusCode: 500, error: __expose ? message : 'Internal Server Error', stack: __expose ? stack : '', url: requestUrl || '' }), head: '' };",
50192
+ " }",
50130
50193
  " }",
50131
50194
  " let _body = (caughtError ? '<!--vesk-ssr-error:' + (caughtError && typeof caughtError === 'object' && 'message' in caughtError ? encodeURIComponent(__expose ? String(caughtError.message) : 'Internal Server Error') : '') + '-->' : '') + page.body;",
50132
- " let _head = page.head || '';",
50133
- " for (let _i = _layoutCompList.length - 1; _i > 0; _i--) {",
50134
- " const _inner = await renderPage('', _layoutCompList[_i], { params, children: _body }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[_i] });",
50135
- " _body = _inner.body;",
50136
- " if (_inner.head) _head = _inner.head + _head;",
50137
- " }",
50138
- " const html = await renderFullPage('', _layoutCompList[0], { params, children: _body }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[0]" + bakedOptions + clientScriptOption + dataScriptOption + ", pageHead: _head });",
50139
- " return new Response(__injectStoreInit(html), { headers: { 'Content-Type': 'text/html' }, status: caughtError ? 500 : 200 });",
50195
+ " const html = await __wrapLayouts(params, _body, page.head || '');",
50196
+ " return new Response(__injectStoreInit(html), { headers: { 'Content-Type': 'text/html' }, status: notFound ? 404 : (caughtError ? 500 : 200) });",
50140
50197
  " });",
50141
50198
  "}",
50142
50199
  ""
@@ -51013,8 +51070,8 @@ async function compileEvents(appDir, outDir) {
51013
51070
 
51014
51071
  // ../adapter/src/client-bundle.ts
51015
51072
  init_esbuild_fallback();
51016
- import { readFileSync as readFileSync11, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync3, rmSync, mkdtempSync, mkdirSync as mkdirSync3 } from "node:fs";
51017
- import { resolve as resolve10, join as join7, dirname as dirname8, relative as relative2, sep } from "node:path";
51073
+ import { readFileSync as readFileSync13, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync4, rmSync, mkdtempSync, mkdirSync as mkdirSync3 } from "node:fs";
51074
+ import { resolve as resolve10, join as join8, dirname as dirname8, relative as relative2, sep } from "node:path";
51018
51075
  import { fileURLToPath as fileURLToPath2 } from "node:url";
51019
51076
  import { tmpdir } from "node:os";
51020
51077
  init_strip_ts();
@@ -51024,6 +51081,267 @@ init_vsk_collision();
51024
51081
  init_vsk_imports();
51025
51082
  init_md_inline();
51026
51083
  init_module_imports();
51084
+
51085
+ // ../adapter/src/server-only-plugin.ts
51086
+ init_parser();
51087
+ import { readFileSync as readFileSync12 } from "node:fs";
51088
+
51089
+ // ../adapter/src/server-only.ts
51090
+ init_parser();
51091
+ import { readFileSync as readFileSync11, readdirSync as readdirSync2, statSync as statSync3 } from "node:fs";
51092
+ import { join as join7 } from "node:path";
51093
+ var SERVER_ONLY_EXACT = /* @__PURE__ */ new Set([
51094
+ "slintorm",
51095
+ "@vesk/adapter"
51096
+ ]);
51097
+ var TCP_DRIVERS = /* @__PURE__ */ new Set([
51098
+ "pg",
51099
+ "mysql2",
51100
+ "mongodb",
51101
+ "node:sqlite",
51102
+ "node:net",
51103
+ "node:tls"
51104
+ ]);
51105
+ function classifySpecifier(spec) {
51106
+ if (typeof spec !== "string" || spec.length === 0) return null;
51107
+ if (TCP_DRIVERS.has(spec)) return "tcp-driver";
51108
+ if (spec.startsWith("node:")) return "tcp-driver";
51109
+ if (SERVER_ONLY_EXACT.has(spec)) return "server-only-package";
51110
+ return null;
51111
+ }
51112
+ var REMEDY = {
51113
+ "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.",
51114
+ "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.'
51115
+ };
51116
+ function scanServerOnlyImports(files) {
51117
+ const out = [];
51118
+ for (const file of files) {
51119
+ let ast;
51120
+ try {
51121
+ ast = parse4(file.code);
51122
+ } catch {
51123
+ continue;
51124
+ }
51125
+ for (const node of ast.body ?? []) {
51126
+ if (node?.type !== "ImportDeclaration" && node?.type !== "ExportNamedDeclaration" && node?.type !== "ExportAllDeclaration") continue;
51127
+ const spec = node.source?.value;
51128
+ if (typeof spec !== "string") continue;
51129
+ const kind = classifySpecifier(spec);
51130
+ if (!kind) continue;
51131
+ out.push({
51132
+ kind,
51133
+ specifier: spec,
51134
+ file: file.path,
51135
+ line: lineOf(file.code, node.start),
51136
+ remedy: REMEDY[kind]
51137
+ });
51138
+ }
51139
+ }
51140
+ return out;
51141
+ }
51142
+ function lineOf(code, offset2) {
51143
+ if (typeof offset2 !== "number" || offset2 < 0 || offset2 > code.length) return null;
51144
+ let line = 1;
51145
+ for (let i = 0; i < offset2; i++) {
51146
+ if (code.charCodeAt(i) === 10) line++;
51147
+ }
51148
+ return line;
51149
+ }
51150
+ function edgeDriverBuildError(violations) {
51151
+ const detail = violations.map((v) => ` ${v.file}${v.line ? `:${v.line}` : ""} \u2014 import "${v.specifier}"
51152
+ ${v.remedy}`).join("\n");
51153
+ return new Error(
51154
+ `[vesk] edge-targeted build cannot include a TCP-only driver (${violations.length} found).
51155
+ ${detail}
51156
+
51157
+ 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.`
51158
+ );
51159
+ }
51160
+ var SOCKETLESS_PLATFORMS = /* @__PURE__ */ new Set(["edge", "cloudflare", "deno", "coxmos"]);
51161
+ function isSocketlessTarget(platform, target) {
51162
+ if (target === "edge") return true;
51163
+ return typeof platform === "string" && SOCKETLESS_PLATFORMS.has(platform);
51164
+ }
51165
+ var SOURCE_EXTENSIONS = [".vsk", ".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
51166
+ var SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".vesk", ".git", "dist", ".next", ".output", "coverage"]);
51167
+ function collectAppSources(dir, out = []) {
51168
+ let entries;
51169
+ try {
51170
+ entries = readdirSync2(dir);
51171
+ } catch {
51172
+ return out;
51173
+ }
51174
+ for (const entry of entries) {
51175
+ if (SKIPPED_DIRS.has(entry) || entry.startsWith(".")) continue;
51176
+ const full = join7(dir, entry);
51177
+ let st;
51178
+ try {
51179
+ st = statSync3(full);
51180
+ } catch {
51181
+ continue;
51182
+ }
51183
+ if (st.isDirectory()) collectAppSources(full, out);
51184
+ else if (st.isFile()) {
51185
+ const dot = entry.lastIndexOf(".");
51186
+ if (dot === -1) continue;
51187
+ if (SOURCE_EXTENSIONS.includes(entry.slice(dot).toLowerCase())) out.push(full);
51188
+ }
51189
+ }
51190
+ return out;
51191
+ }
51192
+ function tcpDriverViolations(appDir) {
51193
+ const files = [];
51194
+ for (const path of collectAppSources(appDir)) {
51195
+ try {
51196
+ files.push({ path, code: readFileSync11(path, "utf-8") });
51197
+ } catch {
51198
+ }
51199
+ }
51200
+ return scanServerOnlyImports(files).filter((v) => v.kind === "tcp-driver");
51201
+ }
51202
+
51203
+ // ../adapter/src/server-only-plugin.ts
51204
+ var STUB_NAMESPACE = "vesk-server-only";
51205
+ var stubCounter = 0;
51206
+ function importedNamesFor(code, specifier) {
51207
+ let ast;
51208
+ try {
51209
+ ast = parse4(code);
51210
+ } catch {
51211
+ return [];
51212
+ }
51213
+ const names = [];
51214
+ const sourceOf = (node) => {
51215
+ const src2 = node.source;
51216
+ if (typeof src2 === "string") return src2;
51217
+ const v = src2?.value;
51218
+ return typeof v === "string" ? v : null;
51219
+ };
51220
+ for (const node of ast.body ?? []) {
51221
+ if (node?.type === "ImportDeclaration") {
51222
+ if (sourceOf(node) !== specifier) continue;
51223
+ for (const spec of node.specifiers ?? []) {
51224
+ if (spec.type === "ImportNamespaceSpecifier") continue;
51225
+ const local = spec.local?.name;
51226
+ if (typeof local === "string" && !names.includes(local)) names.push(local);
51227
+ }
51228
+ continue;
51229
+ }
51230
+ if (node?.type === "ExportAllDeclaration" || node?.type === "ExportNamedDeclaration") {
51231
+ if (sourceOf(node) !== specifier) continue;
51232
+ for (const spec of node.specifiers ?? []) {
51233
+ const imported = spec.imported?.name ?? spec.imported?.value ?? spec.local?.name;
51234
+ if (typeof imported === "string" && !names.includes(imported)) names.push(imported);
51235
+ }
51236
+ }
51237
+ }
51238
+ return names;
51239
+ }
51240
+ function stubFactorySource(specifier) {
51241
+ 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.';
51242
+ return [
51243
+ "function __vesk_stub(binding) {",
51244
+ " var message = " + JSON.stringify(template2) + ";",
51245
+ ' message = message.replace("$0", ' + JSON.stringify(specifier) + ').replace("$1", String(binding));',
51246
+ " var thrower = function () { throw Object.assign(new Error(message), { __veskServerOnly: " + JSON.stringify(specifier) + " }); };",
51247
+ " return new Proxy(function () {}, {",
51248
+ " get: thrower,",
51249
+ " apply: thrower,",
51250
+ " construct: thrower",
51251
+ " });",
51252
+ "}"
51253
+ ].join("\n");
51254
+ }
51255
+ function referencedAtTopLevel(code, name) {
51256
+ let ast;
51257
+ try {
51258
+ ast = parse4(code);
51259
+ } catch {
51260
+ return true;
51261
+ }
51262
+ let found = false;
51263
+ const FUNCTION_TYPES = /* @__PURE__ */ new Set([
51264
+ "FunctionDeclaration",
51265
+ "FunctionExpression",
51266
+ "ArrowFunctionExpression",
51267
+ "ClassMethod",
51268
+ "ObjectMethod",
51269
+ "ClassDeclaration",
51270
+ "ClassExpression"
51271
+ ]);
51272
+ const SKIP_KEYS = /* @__PURE__ */ new Set(["type", "start", "end", "loc", "range", "raw", "regex"]);
51273
+ const SKIP_EXPORT_NAMED_KEYS = /* @__PURE__ */ new Set([...SKIP_KEYS, "source", "specifiers", "exportKind", "attributes"]);
51274
+ const visit = (node, parentKey, fnDepth) => {
51275
+ if (found || node === null || typeof node !== "object") return;
51276
+ if (Array.isArray(node)) {
51277
+ for (const child of node) visit(child, parentKey, fnDepth);
51278
+ return;
51279
+ }
51280
+ const n = node;
51281
+ if (n.type === "MemberExpression" || n.type === "Property" || n.type === "PropertyDefinition" || n.type === "MethodDefinition") {
51282
+ const prop = n.property ?? n.key;
51283
+ if (prop && typeof prop === "object" && prop.name === name && n.computed !== true) return;
51284
+ }
51285
+ if (n.type === "ImportDeclaration" || n.type === "ExportAllDeclaration" || n.type === "ImportExpression") return;
51286
+ if (n.type === "Identifier" && n.name === name) {
51287
+ if (parentKey === "local" || parentKey === "id" || parentKey === "params" || parentKey === "key") return;
51288
+ if (fnDepth === 0) found = true;
51289
+ return;
51290
+ }
51291
+ const skip = n.type === "ExportNamedDeclaration" ? SKIP_EXPORT_NAMED_KEYS : SKIP_KEYS;
51292
+ const nextDepth = FUNCTION_TYPES.has(String(n.type)) ? fnDepth + 1 : fnDepth;
51293
+ for (const [key, value] of Object.entries(n)) {
51294
+ if (skip.has(key)) continue;
51295
+ visit(value, key, nextDepth);
51296
+ }
51297
+ };
51298
+ visit(ast.body, void 0, 0);
51299
+ return found;
51300
+ }
51301
+ function serverOnlyPlugin(options = {}) {
51302
+ const stubs = /* @__PURE__ */ new Map();
51303
+ return {
51304
+ name: "vesk-server-only",
51305
+ setup(build4) {
51306
+ build4.onResolve({ filter: /.*/ }, (args2) => {
51307
+ const kind = classifySpecifier(args2.path);
51308
+ if (!kind) return null;
51309
+ if (kind === "tcp-driver") {
51310
+ options.onDriver?.({ specifier: args2.path, importer: args2.importer });
51311
+ return null;
51312
+ }
51313
+ let names = [];
51314
+ let importerCode = "";
51315
+ try {
51316
+ importerCode = readFileSync12(args2.importer, "utf-8");
51317
+ names = importedNamesFor(importerCode, args2.path);
51318
+ } catch {
51319
+ }
51320
+ const eager = names.filter((n) => referencedAtTopLevel(importerCode, n));
51321
+ if (eager.length > 0) {
51322
+ options.onEager?.({ specifier: args2.path, bindings: eager, importer: args2.importer });
51323
+ return null;
51324
+ }
51325
+ const id = `vesk-stub-${stubCounter++}`;
51326
+ stubs.set(id, [
51327
+ stubFactorySource(args2.path),
51328
+ 'export default __vesk_stub("default");',
51329
+ ...names.map((n) => `export const ${n} = __vesk_stub(${JSON.stringify(n)});`)
51330
+ ].join("\n"));
51331
+ for (const binding of names) {
51332
+ options.onStub?.({ specifier: args2.path, binding, importer: args2.importer });
51333
+ }
51334
+ return { path: id, namespace: STUB_NAMESPACE };
51335
+ });
51336
+ build4.onLoad({ filter: /.*/, namespace: STUB_NAMESPACE }, (args2) => ({
51337
+ contents: stubs.get(args2.path) ?? stubFactorySource("unknown"),
51338
+ loader: "js"
51339
+ }));
51340
+ }
51341
+ };
51342
+ }
51343
+
51344
+ // ../adapter/src/client-bundle.ts
51027
51345
  import { availableParallelism } from "node:os";
51028
51346
  async function mapWithConcurrency(items, limit, fn) {
51029
51347
  const out = new Array(items.length);
@@ -51051,7 +51369,7 @@ async function mapWithConcurrency(items, limit, fn) {
51051
51369
  var __dirname3 = dirname8(fileURLToPath2(import.meta.url));
51052
51370
  function fileUnchanged(filePath, cached) {
51053
51371
  try {
51054
- const st = statSync3(filePath);
51372
+ const st = statSync4(filePath);
51055
51373
  return st.mtimeMs === cached.mtimeMs && st.size === cached.size;
51056
51374
  } catch {
51057
51375
  return false;
@@ -51072,8 +51390,8 @@ function findRuntimeSrc2(appDir) {
51072
51390
  resolve10(appDir, "node_modules", "@vesk/runtime")
51073
51391
  ];
51074
51392
  for (const base of candidates) {
51075
- for (const dir of [base, join7(base, "dist")]) {
51076
- if (existsSync11(join7(dir, "index-client.js"))) return dir;
51393
+ for (const dir of [base, join8(base, "dist")]) {
51394
+ if (existsSync11(join8(dir, "index-client.js"))) return dir;
51077
51395
  }
51078
51396
  }
51079
51397
  throw new Error('@vesk/runtime/dist not found \u2014 run "npm run build" first');
@@ -51179,6 +51497,17 @@ function nativeLibraryImportStubs(code) {
51179
51497
  });
51180
51498
  return lines.join("\n") + "\n\n";
51181
51499
  }
51500
+ function reportServerOnlyImports(chunkName, hits, strict) {
51501
+ const detail = [...new Set(hits.map((h) => `"${h.binding}" from "${h.specifier}"`))].join(", ");
51502
+ if (strict) {
51503
+ throw new Error(
51504
+ `[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).`
51505
+ );
51506
+ }
51507
+ console.error(
51508
+ `[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.`
51509
+ );
51510
+ }
51182
51511
  function demoteExports(code) {
51183
51512
  let ast;
51184
51513
  try {
@@ -51209,7 +51538,7 @@ function chunkHasImports(headLen, mergeAborted) {
51209
51538
  function runtimeImportsOf(filePath) {
51210
51539
  let text;
51211
51540
  try {
51212
- text = readFileSync11(filePath, "utf8");
51541
+ text = readFileSync13(filePath, "utf8");
51213
51542
  } catch {
51214
51543
  return [];
51215
51544
  }
@@ -51502,11 +51831,11 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
51502
51831
  return removeCompiledNodes(code, isVskImport);
51503
51832
  }
51504
51833
  function resolveVskImports(filePath, compile) {
51505
- const src2 = readFileSync11(filePath, "utf-8");
51834
+ const src2 = readFileSync13(filePath, "utf-8");
51506
51835
  const resolved = [];
51507
51836
  for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
51508
51837
  try {
51509
- readFileSync11(importPath);
51838
+ readFileSync13(importPath);
51510
51839
  } catch {
51511
51840
  continue;
51512
51841
  }
@@ -51564,7 +51893,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
51564
51893
  compiledFiles++;
51565
51894
  __stats.compiled++;
51566
51895
  __stats.distinct.add(filePath);
51567
- let src2 = readFileSync11(filePath, "utf-8");
51896
+ let src2 = readFileSync13(filePath, "utf-8");
51568
51897
  if (/content=["'][^"']*\.md["']/i.test(src2)) {
51569
51898
  src2 = inlineMdContentAttrs(src2, dirname8(filePath), guessProjectRoots(appDir));
51570
51899
  }
@@ -51599,7 +51928,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
51599
51928
  }
51600
51929
  for (const reexportPath of reexportPaths || []) compileFile2(reexportPath, null, output, imports);
51601
51930
  if (cache2 && namesBefore) {
51602
- const st = statSync3(filePath);
51931
+ const st = statSync4(filePath);
51603
51932
  cache2.files.set(filePath, {
51604
51933
  mtimeMs: st.mtimeMs,
51605
51934
  size: st.size,
@@ -51725,9 +52054,9 @@ ${body}
51725
52054
  let sharedBundleCode = "";
51726
52055
  const sharedRuntimeNames = /* @__PURE__ */ new Set();
51727
52056
  if (sharedSources.length > 0) {
51728
- const tmpBase = mkdtempSync(join7(resolve10(appDir, ".."), "tmp-vesk-shared-"));
52057
+ const tmpBase = mkdtempSync(join8(resolve10(appDir, ".."), "tmp-vesk-shared-"));
51729
52058
  try {
51730
- const sharedEntry = join7(tmpBase, "shared-entry.js");
52059
+ const sharedEntry = join8(tmpBase, "shared-entry.js");
51731
52060
  const lines = [];
51732
52061
  const members = [];
51733
52062
  sharedSources.forEach((source, i) => {
@@ -51737,7 +52066,7 @@ ${body}
51737
52066
  lines.push(`globalThis.__veskShared = { ${members.join("\n")} };`);
51738
52067
  writeFileSync4(sharedEntry, lines.join("\n"));
51739
52068
  const appTsconfig = findTsconfigPath(appDir);
51740
- const runtimeShim = join7(tmpBase, "runtime-shim.js");
52069
+ const runtimeShim = join8(tmpBase, "runtime-shim.js");
51741
52070
  const runtimeLines = [
51742
52071
  "// ONE runtime instance: the entry bundle publishes these on globalThis,",
51743
52072
  "// and route chunks import the same functions. A second bundled copy",
@@ -51777,7 +52106,7 @@ ${body}
51777
52106
  bindings.named.forEach((n) => named.add(n));
51778
52107
  hasDefault = hasDefault || bindings.hasDefault;
51779
52108
  }
51780
- const shim = join7(tmpBase, `shim-${i}.js`);
52109
+ const shim = join8(tmpBase, `shim-${i}.js`);
51781
52110
  const shimLines = [`const m = globalThis.__veskShared[${JSON.stringify(source)}];`];
51782
52111
  if (hasDefault) shimLines.push(`export default m;`);
51783
52112
  for (const name of [...named].sort()) {
@@ -51805,13 +52134,21 @@ ${body}
51805
52134
  if (!entry.code.trim()) return null;
51806
52135
  let finalCode;
51807
52136
  if (entry.imports) {
51808
- const tmpBase = mkdtempSync(join7(resolve10(appDir, ".."), "tmp-vesk-chunk-"));
51809
- const tmpFile = join7(tmpBase, "entry.js");
52137
+ const tmpBase = mkdtempSync(join8(resolve10(appDir, ".."), "tmp-vesk-chunk-"));
52138
+ const tmpFile = join8(tmpBase, "entry.js");
51810
52139
  const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
51811
52140
  const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
51812
52141
  ${entry.code}
51813
52142
  `;
51814
52143
  writeFileSync4(tmpFile, toBundle);
52144
+ const serverOnlyHits = [];
52145
+ const driverHits = [];
52146
+ const eagerHits = [];
52147
+ const serverOnlyGuard = serverOnlyPlugin({
52148
+ onStub: (hit) => serverOnlyHits.push(hit),
52149
+ onDriver: (hit) => driverHits.push(hit),
52150
+ onEager: (hit) => eagerHits.push(hit)
52151
+ });
51815
52152
  try {
51816
52153
  const appTsconfig = findTsconfigPath(appDir);
51817
52154
  const result = await build({
@@ -51835,7 +52172,7 @@ ${entry.code}
51835
52172
  // shared-modules.js serves every route chunk. (esbuild's `alias`
51836
52173
  // option only accepts bare package names, so this is a resolver
51837
52174
  // rather than a map.)
51838
- ...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin] } : {},
52175
+ ...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin, serverOnlyGuard] } : { plugins: [serverOnlyGuard] },
51839
52176
  ...appTsconfig ? { tsconfig: appTsconfig } : {}
51840
52177
  });
51841
52178
  finalCode = result.outputFiles[0].text;
@@ -51857,6 +52194,24 @@ ${entry.code}
51857
52194
  } catch {
51858
52195
  }
51859
52196
  }
52197
+ if (eagerHits.length > 0) {
52198
+ const detail = eagerHits.map((h) => `${h.importer} uses ${h.bindings.map((b) => `"${b}"`).join(", ")} from "${h.specifier}" at module scope`).join("; ");
52199
+ console.error("[vesk] server-only package used at module scope in client code", entry.name + ":", detail);
52200
+ throw new Error(
52201
+ `[vesk] ${entry.name}: ${detail}.
52202
+ 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.`
52203
+ );
52204
+ }
52205
+ if (driverHits.length > 0) {
52206
+ const detail = [...new Set(driverHits.map((h) => `${h.specifier} (from ${h.importer})`))].join(", ");
52207
+ console.error("[vesk] chunk bundle contains a TCP-only driver", entry.name + ":", detail);
52208
+ throw new Error(
52209
+ `[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.`
52210
+ );
52211
+ }
52212
+ if (serverOnlyHits.length > 0) {
52213
+ reportServerOnlyImports(entry.name, serverOnlyHits, options?.strict);
52214
+ }
51860
52215
  } else {
51861
52216
  finalCode = chunkIIFE(demoteExports(entry.code));
51862
52217
  }
@@ -51891,7 +52246,7 @@ ${entry.code}
51891
52246
  let compileFileMono2 = function(filePath, resolvedName) {
51892
52247
  if (seen.has(filePath)) return;
51893
52248
  seen.add(filePath);
51894
- const src2 = readFileSync11(filePath, "utf-8");
52249
+ const src2 = readFileSync13(filePath, "utf-8");
51895
52250
  resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
51896
52251
  for (const cn of vskComponentNames(src2, filePath)) componentOwners.claim(cn, filePath);
51897
52252
  const monoAlloc = nameAllocFor(filePath);
@@ -51973,9 +52328,9 @@ function buildRuntimeCode(runtimeDir) {
51973
52328
  ];
51974
52329
  let code = "";
51975
52330
  for (const f of runtimeFiles) {
51976
- const p = join7(runtimeDir, f);
52331
+ const p = join8(runtimeDir, f);
51977
52332
  if (existsSync11(p)) {
51978
- let src2 = readFileSync11(p, "utf-8");
52333
+ let src2 = readFileSync13(p, "utf-8");
51979
52334
  src2 = stripTypes(src2);
51980
52335
  src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
51981
52336
  src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
@@ -51987,7 +52342,7 @@ ${src2}
51987
52342
  `;
51988
52343
  }
51989
52344
  }
51990
- const indexSrc = readFileSync11(join7(runtimeDir, "index-client.js"), "utf-8");
52345
+ const indexSrc = readFileSync13(join8(runtimeDir, "index-client.js"), "utf-8");
51991
52346
  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
52347
  code += "// --- exports ---\n";
51993
52348
  for (const name of [...new Set(exportNames)]) {
@@ -51997,7 +52352,7 @@ ${src2}
51997
52352
  return code;
51998
52353
  }
51999
52354
  function runtimeExportNames(runtimeDir) {
52000
- const indexSrc = readFileSync11(join7(runtimeDir, "index-client.js"), "utf-8");
52355
+ const indexSrc = readFileSync13(join8(runtimeDir, "index-client.js"), "utf-8");
52001
52356
  const names = /* @__PURE__ */ new Set();
52002
52357
  for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
52003
52358
  for (const raw2 of m[1].split(",")) {
@@ -52012,7 +52367,7 @@ function esbuildPath(p) {
52012
52367
  return sep === "/" ? p : p.split(sep).join("/");
52013
52368
  }
52014
52369
  function runtimeTreeShakeEntry() {
52015
- return join7(tmpdir(), "vesk-runtime-tree-shake", RUNTIME_ENTRY);
52370
+ return join8(tmpdir(), "vesk-runtime-tree-shake", RUNTIME_ENTRY);
52016
52371
  }
52017
52372
  var treeShakeQueue = Promise.resolve();
52018
52373
  function buildTreeShakenRuntime(runtimeDir, usedNames) {
@@ -52035,7 +52390,7 @@ async function buildTreeShakenRuntimeNow(runtimeDir, usedNames) {
52035
52390
  async function bundleRuntimeNames(runtimeDir, names, strict = false) {
52036
52391
  if (names.length === 0) return null;
52037
52392
  const entry = runtimeTreeShakeEntry();
52038
- const indexClient = esbuildPath(join7(runtimeDir, "index-client.js"));
52393
+ const indexClient = esbuildPath(join8(runtimeDir, "index-client.js"));
52039
52394
  const unique = [...new Set(names)];
52040
52395
  try {
52041
52396
  try {
@@ -52207,6 +52562,7 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
52207
52562
  if (r._isrTags) entry.tags = r._isrTags;
52208
52563
  routeEntries.push(entry);
52209
52564
  }
52565
+ routeEntries.sort((a, b) => compareSpecificity(a.path, b.path));
52210
52566
  const apiEntries = [];
52211
52567
  for (const r of apiRoutes) {
52212
52568
  const urlParts = r.fullPath.split("/").filter(Boolean);
@@ -52249,19 +52605,19 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
52249
52605
 
52250
52606
  // ../adapter/src/static.ts
52251
52607
  init_paths();
52252
- import { mkdirSync as mkdirSync4, copyFileSync, readdirSync as readdirSync2, statSync as statSync5, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync13 } from "node:fs";
52253
- import { resolve as resolve12, join as join8 } from "node:path";
52608
+ import { mkdirSync as mkdirSync4, copyFileSync, readdirSync as readdirSync3, statSync as statSync6, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync15 } from "node:fs";
52609
+ import { resolve as resolve12, join as join9 } from "node:path";
52254
52610
  function copyStaticAssets(publicDir, outDir) {
52255
52611
  const targetDir = resolve12(outDir, "static", "public");
52256
52612
  mkdirSync4(targetDir, { recursive: true });
52257
52613
  if (!existsSync13(publicDir)) return;
52258
52614
  function copyDir(src2, dest) {
52259
52615
  mkdirSync4(dest, { recursive: true });
52260
- const entries = readdirSync2(src2);
52616
+ const entries = readdirSync3(src2);
52261
52617
  for (const entry of entries) {
52262
- const srcPath = join8(src2, entry);
52263
- const destPath = join8(dest, entry);
52264
- const st = statSync5(srcPath);
52618
+ const srcPath = join9(src2, entry);
52619
+ const destPath = join9(dest, entry);
52620
+ const st = statSync6(srcPath);
52265
52621
  if (st.isDirectory()) {
52266
52622
  copyDir(srcPath, destPath);
52267
52623
  } else {
@@ -52273,7 +52629,7 @@ function copyStaticAssets(publicDir, outDir) {
52273
52629
  }
52274
52630
 
52275
52631
  // ../adapter/src/prod-server.ts
52276
- import { readFileSync as readFileSync16, existsSync as existsSync16, statSync as statSync7 } from "node:fs";
52632
+ import { readFileSync as readFileSync18, existsSync as existsSync16, statSync as statSync8 } from "node:fs";
52277
52633
  import { resolve as resolve14, dirname as dirname11, basename } from "node:path";
52278
52634
  import { createServer } from "node:http";
52279
52635
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -52313,13 +52669,13 @@ async function reportServerError(err, options) {
52313
52669
  init_paths();
52314
52670
 
52315
52671
  // ../adapter/src/load-config.ts
52316
- import { existsSync as existsSync14, readFileSync as readFileSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5 } from "node:fs";
52317
- import { join as join9, dirname as dirname9 } from "node:path";
52672
+ import { existsSync as existsSync14, readFileSync as readFileSync16, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5 } from "node:fs";
52673
+ import { join as join10, dirname as dirname9 } from "node:path";
52318
52674
  import { pathToFileURL as pathToFileURL2 } from "node:url";
52319
52675
  import { createRequire as createRequire3 } from "node:module";
52320
52676
  async function loadVeskConfig2(projectDir) {
52321
- const jsPath = join9(projectDir, "vesk.config.js");
52322
- const tsPath = join9(projectDir, "vesk.config.ts");
52677
+ const jsPath = join10(projectDir, "vesk.config.js");
52678
+ const tsPath = join10(projectDir, "vesk.config.ts");
52323
52679
  let configPath2 = null;
52324
52680
  if (existsSync14(jsPath)) configPath2 = jsPath;
52325
52681
  else if (existsSync14(tsPath)) configPath2 = tsPath;
@@ -52327,10 +52683,10 @@ async function loadVeskConfig2(projectDir) {
52327
52683
  let raw2;
52328
52684
  if (configPath2.endsWith(".ts")) {
52329
52685
  const { transpile } = await import("typescript");
52330
- const src2 = readFileSync14(configPath2, "utf-8");
52686
+ const src2 = readFileSync16(configPath2, "utf-8");
52331
52687
  let js = transpile(src2, { module: 99, target: 99 });
52332
52688
  const inject = { defineConfig, definePlugin, preset };
52333
- const projectRequire = createRequire3(join9(projectDir, "package.json"));
52689
+ const projectRequire = createRequire3(join10(projectDir, "package.json"));
52334
52690
  const importRe = /import\s+(?:(?:\*\s*as\s+([\w$]+))|([\w$]+(?:\s*,\s*\{[^}]*\})?)|(\{[^}]*\}))\s+from\s+['"]([^'"]+)['"]\s*;?/g;
52335
52691
  let m;
52336
52692
  while ((m = importRe.exec(js)) !== null) {
@@ -52357,7 +52713,7 @@ async function loadVeskConfig2(projectDir) {
52357
52713
  const injectKeys = Object.keys(inject);
52358
52714
  js = `const {${injectKeys.join(",")}} = globalThis.__vesk_inject;
52359
52715
  ` + js;
52360
- const tmpFile = join9(projectDir, ".vesk", "config.loader.tmp.mjs");
52716
+ const tmpFile = join10(projectDir, ".vesk", "config.loader.tmp.mjs");
52361
52717
  mkdirSync5(dirname9(tmpFile), { recursive: true });
52362
52718
  writeFileSync6(tmpFile, js, "utf-8");
52363
52719
  globalThis.__vesk_inject = inject;
@@ -52783,7 +53139,7 @@ async function startProdServer(outDir, options) {
52783
53139
  console.error('Run "vesk build" first');
52784
53140
  process.exit(1);
52785
53141
  }
52786
- const buildConfig = JSON.parse(readFileSync16(configPath2, "utf-8"));
53142
+ const buildConfig = JSON.parse(readFileSync18(configPath2, "utf-8"));
52787
53143
  const bakedHeadExtra = buildConfig.headExtra || "";
52788
53144
  console.error(`vesk start: serving from ${outDir}`);
52789
53145
  const projectDir = resolve14(outDir, "..");
@@ -52959,9 +53315,9 @@ async function startProdServer(outDir, options) {
52959
53315
  });
52960
53316
  const publicDir = resolve14(staticDir, "public");
52961
53317
  const rootFile = url.pathname.length > 1 ? resolveWithin(publicDir, url.pathname.slice(1)) : null;
52962
- if (rootFile && existsSync16(rootFile) && statSync7(rootFile).isFile()) {
53318
+ if (rootFile && existsSync16(rootFile) && statSync8(rootFile).isFile()) {
52963
53319
  res.writeHead(200, { "Content-Type": mimeFor(rootFile) });
52964
- res.end(readFileSync16(rootFile));
53320
+ res.end(readFileSync18(rootFile));
52965
53321
  return;
52966
53322
  }
52967
53323
  if (url.pathname === "/ssr-data.js") {
@@ -52993,7 +53349,7 @@ async function startProdServer(outDir, options) {
52993
53349
  "Content-Type": "application/javascript",
52994
53350
  "Cache-Control": cacheControlFor(clientFile, false)
52995
53351
  });
52996
- res.end(readFileSync16(clientPath));
53352
+ res.end(readFileSync18(clientPath));
52997
53353
  return;
52998
53354
  }
52999
53355
  }
@@ -53005,7 +53361,7 @@ async function startProdServer(outDir, options) {
53005
53361
  res.end("Forbidden");
53006
53362
  return;
53007
53363
  }
53008
- if (existsSync16(staticPath) && statSync7(staticPath).isFile()) {
53364
+ if (existsSync16(staticPath) && statSync8(staticPath).isFile()) {
53009
53365
  res.writeHead(200, {
53010
53366
  "Content-Type": mimeFor(staticPath),
53011
53367
  // A content-hashed name can never change meaning, so it is immutable
@@ -53013,7 +53369,7 @@ async function startProdServer(outDir, options) {
53013
53369
  // serve stale JS forever.
53014
53370
  "Cache-Control": cacheControlFor(basename(staticPath), false)
53015
53371
  });
53016
- res.end(readFileSync16(staticPath));
53372
+ res.end(readFileSync18(staticPath));
53017
53373
  return;
53018
53374
  }
53019
53375
  }
@@ -53023,7 +53379,7 @@ async function startProdServer(outDir, options) {
53023
53379
  const htmlPath = resolve14(outDir, prerendered.file);
53024
53380
  if (existsSync16(htmlPath)) {
53025
53381
  res.writeHead(200, { "Content-Type": "text/html" });
53026
- res.end(readFileSync16(htmlPath));
53382
+ res.end(readFileSync18(htmlPath));
53027
53383
  return;
53028
53384
  }
53029
53385
  }
@@ -53132,17 +53488,29 @@ async function startProdServer(outDir, options) {
53132
53488
  const pageCssUrls = resolveCssUrls({
53133
53489
  enabled: hasBuiltGlobalCss(outDir)
53134
53490
  });
53135
- const nfPath = resolve14(appDir, "not-found.vsk");
53136
- let notFoundHtml = null;
53137
- if (existsSync16(nfPath)) {
53138
- try {
53139
- const runtimePath = resolve14(outDir, "server", "runtime.js");
53140
- const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
53141
- const src2 = readFileSync16(nfPath, "utf-8");
53142
- const compName = resolveComponentName(src2) || "NotFound";
53143
- notFoundHtml = await renderFullPage2(src2, compName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: pageCssUrls, security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: nfPath, headExtra: bakedHeadExtra });
53144
- } catch {
53491
+ const boundaryCache = /* @__PURE__ */ new Map();
53492
+ async function renderBoundaryFile(file, pathname, props) {
53493
+ const boundaryPath = resolveBoundaryFileForUrl(pathname, appDir, file);
53494
+ if (!boundaryPath) return null;
53495
+ const key = `${file}:${boundaryPath}`;
53496
+ let html = boundaryCache.has(key) ? boundaryCache.get(key) : null;
53497
+ if (html === null) {
53498
+ try {
53499
+ const runtimePath = resolve14(outDir, "server", "runtime.js");
53500
+ const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
53501
+ const src2 = readFileSync18(boundaryPath, "utf-8");
53502
+ const compName = resolveComponentName(src2) || (file === "error.vsk" ? "Error" : "NotFound");
53503
+ html = await renderFullPage2(src2, compName, props, /* @__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: boundaryPath, headExtra: bakedHeadExtra });
53504
+ } catch {
53505
+ return null;
53506
+ }
53145
53507
  }
53508
+ return html;
53509
+ }
53510
+ let notFoundHtml = null;
53511
+ {
53512
+ const rendered = await renderBoundaryFile("not-found.vsk", url.pathname, { params: {}, url: url.pathname });
53513
+ notFoundHtml = rendered;
53146
53514
  }
53147
53515
  for (const route of buildConfig.routes) {
53148
53516
  if (route.type === "ssr") {
@@ -53212,19 +53580,13 @@ async function startProdServer(outDir, options) {
53212
53580
  if (eventsMod) {
53213
53581
  await executeError(err, { url: url.href, routePath: route.path, target: "node", status: 500 }, eventsMod);
53214
53582
  }
53215
- const errPath = resolve14(appDir, "error.vsk");
53216
- let errorHtml = null;
53217
- if (existsSync16(errPath)) {
53218
- try {
53219
- const runtimePath = resolve14(outDir, "server", "runtime.js");
53220
- const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
53221
- const src2 = readFileSync16(errPath, "utf-8");
53222
- const compName = resolveComponentName(src2) || "Error";
53223
- const expose = process.env.NODE_ENV !== "production";
53224
- errorHtml = await renderFullPage2(src2, compName, { error: expose ? err.message : "Internal Server Error", stack: expose ? err.stack : "", statusCode: 500, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: pageCssUrls, clientScriptUrl: buildConfig?.assets?.client?.url || "/_vesk/static/client.js", clientScriptIntegrity: buildConfig?.assets?.client?.integrity, security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: errPath, headExtra: bakedHeadExtra });
53225
- } catch {
53226
- }
53227
- }
53583
+ const expose = process.env.NODE_ENV !== "production";
53584
+ const errorHtml = await renderBoundaryFile("error.vsk", url.pathname, {
53585
+ error: expose ? err.message : "Internal Server Error",
53586
+ stack: expose ? err.stack : "",
53587
+ statusCode: 500,
53588
+ url: url.pathname
53589
+ });
53228
53590
  res.writeHead(500, { "Content-Type": "text/html" });
53229
53591
  res.end(errorHtml || renderDefaultErrorPage({ message: process.env.NODE_ENV !== "production" ? err.message : void 0, url: url.pathname, headExtra: bakedHeadExtra }));
53230
53592
  return;
@@ -53303,7 +53665,7 @@ function findRouteConflicts(routeTree, appDir) {
53303
53665
  const walk9 = (nodes) => {
53304
53666
  for (const node of nodes) {
53305
53667
  if (node.page) {
53306
- const pageFile = join15(node.sourceDir, "page.vsk");
53668
+ const pageFile = join16(node.sourceDir, "page.vsk");
53307
53669
  const files = byPath.get(node.fullPath) ?? [];
53308
53670
  files.push(relative4(projectRoot, pageFile));
53309
53671
  byPath.set(node.fullPath, files);
@@ -53412,6 +53774,11 @@ async function build2(appDir, options) {
53412
53774
  if (pluginHeadExtra)
53413
53775
  console.error("vesk build: baked plugin head \u2192 config.json + SSR functions");
53414
53776
  console.error(`vesk build: output \u2192 ${outDir}`);
53777
+ if (isSocketlessTarget(options?.platform, options?.target)) {
53778
+ const driverHits = tcpDriverViolations(appDir);
53779
+ if (driverHits.length > 0)
53780
+ throw edgeDriverBuildError(driverHits);
53781
+ }
53415
53782
  const dirs = [
53416
53783
  resolve21(outDir, "server", "functions"),
53417
53784
  resolve21(outDir, "server", "api"),
@@ -53423,7 +53790,7 @@ async function build2(appDir, options) {
53423
53790
  markPhase("config+dirs");
53424
53791
  const cssSourcePath = resolveUserCssPath(appDir);
53425
53792
  if (cssSourcePath !== null) {
53426
- const cssContent = readFileSync21(cssSourcePath, "utf-8");
53793
+ const cssContent = readFileSync23(cssSourcePath, "utf-8");
53427
53794
  const cssTarget = resolve21(outDir, "static", "global.css");
53428
53795
  const tailwindActive = isTailwindPlugin(pluginsPipelines);
53429
53796
  let finalCss = cssContent;
@@ -53516,7 +53883,7 @@ async function build2(appDir, options) {
53516
53883
  const mwChain2 = collectMiddlewareChain2(routeTree, node.fullPath, appDir);
53517
53884
  let mwCode = null;
53518
53885
  if (mwChain2.length > 0) {
53519
- const mwSources = mwChain2.map((m) => readFileSync21(m.sourcePath, "utf-8"));
53886
+ const mwSources = mwChain2.map((m) => readFileSync23(m.sourcePath, "utf-8"));
53520
53887
  mwCode = compileMiddlewareCode(mwSources);
53521
53888
  }
53522
53889
  const ssrAncestorLayouts = isStandalone ? [] : ancestorLayouts;
@@ -53524,14 +53891,14 @@ async function build2(appDir, options) {
53524
53891
  writeFileSync12(funcPath, funcCode, "utf-8");
53525
53892
  const pagePath = resolve21(appDir, node.sourceDir, "page.vsk");
53526
53893
  if (existsSync22(pagePath)) {
53527
- const src2 = readFileSync21(pagePath, "utf-8");
53894
+ const src2 = readFileSync23(pagePath, "utf-8");
53528
53895
  const actionIds = collectActionIds(src2);
53529
53896
  if (node.layout) {
53530
- const layoutSrc = readFileSync21(resolve21(appDir, node.sourceDir, "layout.vsk"), "utf-8");
53897
+ const layoutSrc = readFileSync23(resolve21(appDir, node.sourceDir, "layout.vsk"), "utf-8");
53531
53898
  actionIds.push(...collectActionIds(layoutSrc));
53532
53899
  }
53533
53900
  for (const a of ssrAncestorLayouts) {
53534
- const ancestorSrc = readFileSync21(resolve21(appDir, a.sourceDir, "layout.vsk"), "utf-8");
53901
+ const ancestorSrc = readFileSync23(resolve21(appDir, a.sourceDir, "layout.vsk"), "utf-8");
53535
53902
  actionIds.push(...collectActionIds(ancestorSrc));
53536
53903
  }
53537
53904
  for (const id of actionIds) {
@@ -53624,7 +53991,7 @@ async function build2(appDir, options) {
53624
53991
  const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap, pluginHeadExtra, hasEvents);
53625
53992
  const buildId3 = emittedAssets.map((a) => a.hash).join("-");
53626
53993
  manifest.buildId = buildId3.slice(0, 32);
53627
- manifest.veskVersion = JSON.parse(readFileSync21(join15(PACKAGES_DIR_SELF(), "package.json"), "utf-8")).version;
53994
+ manifest.veskVersion = JSON.parse(readFileSync23(join16(PACKAGES_DIR_SELF(), "package.json"), "utf-8")).version;
53628
53995
  manifest.assets = {
53629
53996
  hashed,
53630
53997
  client: { file: clientFileName, url: clientUrl, hash: clientAsset.hash, bytes: clientAsset.bytes, integrity: clientAsset.integrity },
@@ -53678,9 +54045,9 @@ vesk build: done (${outDir})`);
53678
54045
  init_seo_audit();
53679
54046
 
53680
54047
  // src/dev-server.ts
53681
- import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, mkdirSync as mkdirSync19, readdirSync as readdirSync13, writeFileSync as writeFileSync21, renameSync as renameSync2 } from "node:fs";
54048
+ 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";
53682
54049
  import { createHash as createHash3 } from "node:crypto";
53683
- import { resolve as resolve38, extname as extname7, join as join26, dirname as dirname26 } from "node:path";
54050
+ import { resolve as resolve38, extname as extname7, join as join27, dirname as dirname26 } from "node:path";
53684
54051
  import { createServer as createServer2 } from "node:http";
53685
54052
  import { WebSocketServer as WebSocketServer2 } from "ws";
53686
54053
 
@@ -56569,8 +56936,8 @@ init_parser();
56569
56936
  init_tokens();
56570
56937
  init_scan();
56571
56938
  init_strip_ts();
56572
- import { readdirSync as readdirSync7, statSync as statSync12, existsSync as existsSync23, readFileSync as readFileSync22 } from "fs";
56573
- import { join as join16, relative as relative5, basename as basename4 } from "path";
56939
+ import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync23, readFileSync as readFileSync24 } from "fs";
56940
+ import { join as join17, relative as relative5, basename as basename4 } from "path";
56574
56941
  function collapseSlashes2(p) {
56575
56942
  let out = "";
56576
56943
  let prevSlash = false;
@@ -56590,7 +56957,7 @@ function isStandaloneLayoutFile(layoutPath) {
56590
56957
  try {
56591
56958
  if (!existsSync23(layoutPath))
56592
56959
  return false;
56593
- const src2 = readFileSync22(layoutPath, "utf-8");
56960
+ const src2 = readFileSync24(layoutPath, "utf-8");
56594
56961
  if (!src2.includes("standalone"))
56595
56962
  return false;
56596
56963
  try {
@@ -56668,15 +57035,15 @@ function scanComponents(componentsDir) {
56668
57035
  function walk9(dir, prefix) {
56669
57036
  let entries;
56670
57037
  try {
56671
- entries = readdirSync7(dir);
57038
+ entries = readdirSync8(dir);
56672
57039
  } catch {
56673
57040
  return;
56674
57041
  }
56675
57042
  for (const entry of entries) {
56676
- const full = join16(dir, entry);
57043
+ const full = join17(dir, entry);
56677
57044
  let stat;
56678
57045
  try {
56679
- stat = statSync12(full);
57046
+ stat = statSync13(full);
56680
57047
  } catch {
56681
57048
  continue;
56682
57049
  }
@@ -56699,7 +57066,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
56699
57066
  const nodes = [];
56700
57067
  let entries;
56701
57068
  try {
56702
- entries = readdirSync7(dir);
57069
+ entries = readdirSync8(dir);
56703
57070
  } catch {
56704
57071
  return nodes;
56705
57072
  }
@@ -56774,7 +57141,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
56774
57141
  seg = segName;
56775
57142
  }
56776
57143
  const fullPath = seg ? (parentPath === "/" ? "/" : parentPath + "/") + seg : parentPath || "/";
56777
- const isStandalone = hasLayout ? isStandaloneLayoutFile(join16(dir, "layout.vsk")) : false;
57144
+ const isStandalone = hasLayout ? isStandaloneLayoutFile(join17(dir, "layout.vsk")) : false;
56778
57145
  const node = {
56779
57146
  path: seg,
56780
57147
  fullPath: collapseSlashes2(fullPath) || "/",
@@ -56795,10 +57162,10 @@ function scanDirectory(rootDir, dir, parentPath, options) {
56795
57162
  standalone: isStandalone ? true : void 0
56796
57163
  };
56797
57164
  for (const entry of entries) {
56798
- const entryPath = join16(dir, entry);
57165
+ const entryPath = join17(dir, entry);
56799
57166
  let entryStat;
56800
57167
  try {
56801
- entryStat = statSync12(entryPath);
57168
+ entryStat = statSync13(entryPath);
56802
57169
  } catch {
56803
57170
  continue;
56804
57171
  }
@@ -56847,19 +57214,19 @@ function collectSources(tree) {
56847
57214
  function walk9(nodes) {
56848
57215
  for (const node of nodes) {
56849
57216
  if (node.page)
56850
- map.set(node.page, join16(node.sourceDir, "page.vsk"));
57217
+ map.set(node.page, join17(node.sourceDir, "page.vsk"));
56851
57218
  if (node.layout)
56852
- map.set(node.layout, join16(node.sourceDir, "layout.vsk"));
57219
+ map.set(node.layout, join17(node.sourceDir, "layout.vsk"));
56853
57220
  if (node.loading)
56854
- map.set(node.loading, join16(node.sourceDir, "loading.vsk"));
57221
+ map.set(node.loading, join17(node.sourceDir, "loading.vsk"));
56855
57222
  if (node.error)
56856
- map.set(node.error, join16(node.sourceDir, "error.vsk"));
57223
+ map.set(node.error, join17(node.sourceDir, "error.vsk"));
56857
57224
  if (node.notFound)
56858
- map.set(node.notFound, join16(node.sourceDir, "not-found.vsk"));
57225
+ map.set(node.notFound, join17(node.sourceDir, "not-found.vsk"));
56859
57226
  if (node.offline)
56860
- map.set(node.offline, join16(node.sourceDir, "offline.vsk"));
57227
+ map.set(node.offline, join17(node.sourceDir, "offline.vsk"));
56861
57228
  if (node.network)
56862
- map.set(node.network, join16(node.sourceDir, "network.vsk"));
57229
+ map.set(node.network, join17(node.sourceDir, "network.vsk"));
56863
57230
  walk9(node.children);
56864
57231
  }
56865
57232
  }
@@ -56979,8 +57346,8 @@ function matchUrl(tree, pathname) {
56979
57346
  }
56980
57347
 
56981
57348
  // ../compiler/dist/api-routes.js
56982
- import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync24 } from "fs";
56983
- import { join as join17 } from "path";
57349
+ import { readdirSync as readdirSync9, statSync as statSync14, existsSync as existsSync24 } from "fs";
57350
+ import { join as join18 } from "path";
56984
57351
  init_server_utils();
56985
57352
  function basename5(p) {
56986
57353
  const idx = p.lastIndexOf("/");
@@ -56995,7 +57362,7 @@ function scanApiDir(rootDir, dir, parentPath) {
56995
57362
  const nodes = [];
56996
57363
  let entries;
56997
57364
  try {
56998
- entries = readdirSync8(dir);
57365
+ entries = readdirSync9(dir);
56999
57366
  } catch {
57000
57367
  return nodes;
57001
57368
  }
@@ -57017,10 +57384,10 @@ function scanApiDir(rootDir, dir, parentPath) {
57017
57384
  return nodes;
57018
57385
  if (isRouteGroup) {
57019
57386
  for (const entry of entries) {
57020
- const entryPath = join17(dir, entry);
57387
+ const entryPath = join18(dir, entry);
57021
57388
  let entryStat;
57022
57389
  try {
57023
- entryStat = statSync13(entryPath);
57390
+ entryStat = statSync14(entryPath);
57024
57391
  } catch {
57025
57392
  continue;
57026
57393
  }
@@ -57047,14 +57414,14 @@ function scanApiDir(rootDir, dir, parentPath) {
57047
57414
  fullPath: collapseSlashes(fullPath) || "/",
57048
57415
  isDynamic,
57049
57416
  isCatchAll,
57050
- filePath: hasRoute && routeFileName ? join17(dir, routeFileName) : null,
57417
+ filePath: hasRoute && routeFileName ? join18(dir, routeFileName) : null,
57051
57418
  children: []
57052
57419
  };
57053
57420
  for (const entry of entries) {
57054
- const entryPath = join17(dir, entry);
57421
+ const entryPath = join18(dir, entry);
57055
57422
  let entryStat;
57056
57423
  try {
57057
- entryStat = statSync13(entryPath);
57424
+ entryStat = statSync14(entryPath);
57058
57425
  } catch {
57059
57426
  continue;
57060
57427
  }
@@ -57608,11 +57975,11 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
57608
57975
 
57609
57976
  // ../compiler/dist/events.js
57610
57977
  import { existsSync as existsSync26 } from "fs";
57611
- import { join as join18 } from "path";
57978
+ import { join as join19 } from "path";
57612
57979
  var EVENTS_FILE_NAMES2 = ["_events.ts", "_events.js"];
57613
57980
  function collectEventsFile2(appDir) {
57614
57981
  for (const name of EVENTS_FILE_NAMES2) {
57615
- const candidate = join18(appDir, name);
57982
+ const candidate = join19(appDir, name);
57616
57983
  if (existsSync26(candidate))
57617
57984
  return candidate;
57618
57985
  }
@@ -57643,8 +58010,8 @@ async function runEventHandlers(handlers, name, ctx2) {
57643
58010
  }
57644
58011
 
57645
58012
  // ../compiler/dist/md-inline.js
57646
- import { readFileSync as readFileSync23, existsSync as existsSync27 } from "node:fs";
57647
- import { dirname as dirname17, join as join19, resolve as resolve23 } from "node:path";
58013
+ import { readFileSync as readFileSync25, existsSync as existsSync27 } from "node:fs";
58014
+ import { dirname as dirname17, join as join20, resolve as resolve23 } from "node:path";
57648
58015
  var MD_EXT_MARKER2 = ".md";
57649
58016
  function looksLikeMarkdownPath2(value) {
57650
58017
  const v = value.trim();
@@ -57687,7 +58054,7 @@ function inlineMdContentAttrs2(source, importerDir, mdRoots = []) {
57687
58054
  if (abs !== null) {
57688
58055
  let contents;
57689
58056
  try {
57690
- contents = readFileSync23(abs, "utf-8");
58057
+ contents = readFileSync25(abs, "utf-8");
57691
58058
  } catch {
57692
58059
  out += source[i];
57693
58060
  i++;
@@ -57721,10 +58088,10 @@ function resolveMdPath2(specifier, importerDir, roots) {
57721
58088
  }
57722
58089
  if (spec.startsWith("/")) {
57723
58090
  for (const root3 of roots) {
57724
- const pub = join19(root3, "public", spec);
58091
+ const pub = join20(root3, "public", spec);
57725
58092
  if (existsSync27(pub))
57726
58093
  return pub;
57727
- const direct = join19(root3, spec);
58094
+ const direct = join20(root3, spec);
57728
58095
  if (existsSync27(direct))
57729
58096
  return direct;
57730
58097
  }
@@ -57738,7 +58105,7 @@ function guessProjectRoots2(dir) {
57738
58105
  let cur = dir;
57739
58106
  for (let i = 0; i < 6; i++) {
57740
58107
  roots.push(cur);
57741
- if (existsSync27(join19(cur, "package.json")))
58108
+ if (existsSync27(join20(cur, "package.json")))
57742
58109
  break;
57743
58110
  const parent = dirname17(cur);
57744
58111
  if (parent === cur)
@@ -57749,8 +58116,8 @@ function guessProjectRoots2(dir) {
57749
58116
  }
57750
58117
 
57751
58118
  // ../adapter/dist/client-bundle.js
57752
- import { readFileSync as readFileSync24, existsSync as existsSync28, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync14, rmSync as rmSync4, mkdtempSync as mkdtempSync2, mkdirSync as mkdirSync12 } from "node:fs";
57753
- import { resolve as resolve24, join as join20, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
58119
+ 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";
58120
+ import { resolve as resolve24, join as join21, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
57754
58121
  import { fileURLToPath as fileURLToPath6 } from "node:url";
57755
58122
  import { tmpdir as tmpdir3 } from "node:os";
57756
58123
 
@@ -57841,7 +58208,7 @@ async function mapWithConcurrency2(items, limit, fn) {
57841
58208
  var __dirname7 = dirname18(fileURLToPath6(import.meta.url));
57842
58209
  function fileUnchanged2(filePath, cached) {
57843
58210
  try {
57844
- const st = statSync14(filePath);
58211
+ const st = statSync15(filePath);
57845
58212
  return st.mtimeMs === cached.mtimeMs && st.size === cached.size;
57846
58213
  } catch {
57847
58214
  return false;
@@ -57862,8 +58229,8 @@ function findRuntimeSrc3(appDir) {
57862
58229
  resolve24(appDir, "node_modules", "@vesk/runtime")
57863
58230
  ];
57864
58231
  for (const base of candidates) {
57865
- for (const dir of [base, join20(base, "dist")]) {
57866
- if (existsSync28(join20(dir, "index-client.js")))
58232
+ for (const dir of [base, join21(base, "dist")]) {
58233
+ if (existsSync28(join21(dir, "index-client.js")))
57867
58234
  return dir;
57868
58235
  }
57869
58236
  }
@@ -57983,6 +58350,13 @@ function nativeLibraryImportStubs2(code) {
57983
58350
  });
57984
58351
  return lines.join("\n") + "\n\n";
57985
58352
  }
58353
+ function reportServerOnlyImports2(chunkName, hits, strict) {
58354
+ const detail = [...new Set(hits.map((h) => `"${h.binding}" from "${h.specifier}"`))].join(", ");
58355
+ if (strict) {
58356
+ 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).`);
58357
+ }
58358
+ 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.`);
58359
+ }
57986
58360
  function demoteExports2(code) {
57987
58361
  let ast;
57988
58362
  try {
@@ -58016,7 +58390,7 @@ function chunkHasImports2(headLen, mergeAborted) {
58016
58390
  function runtimeImportsOf2(filePath) {
58017
58391
  let text;
58018
58392
  try {
58019
- text = readFileSync24(filePath, "utf8");
58393
+ text = readFileSync26(filePath, "utf8");
58020
58394
  } catch {
58021
58395
  return [];
58022
58396
  }
@@ -58343,11 +58717,11 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
58343
58717
  return removeCompiledNodes2(code, isVskImport2);
58344
58718
  }
58345
58719
  function resolveVskImports(filePath, compile) {
58346
- const src2 = readFileSync24(filePath, "utf-8");
58720
+ const src2 = readFileSync26(filePath, "utf-8");
58347
58721
  const resolved = [];
58348
58722
  for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
58349
58723
  try {
58350
- readFileSync24(importPath);
58724
+ readFileSync26(importPath);
58351
58725
  } catch {
58352
58726
  continue;
58353
58727
  }
@@ -58409,7 +58783,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
58409
58783
  compiledFiles++;
58410
58784
  __stats.compiled++;
58411
58785
  __stats.distinct.add(filePath);
58412
- let src2 = readFileSync24(filePath, "utf-8");
58786
+ let src2 = readFileSync26(filePath, "utf-8");
58413
58787
  if (/content=["'][^"']*\.md["']/i.test(src2)) {
58414
58788
  src2 = inlineMdContentAttrs(src2, dirname18(filePath), guessProjectRoots(appDir));
58415
58789
  }
@@ -58449,7 +58823,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
58449
58823
  for (const reexportPath of reexportPaths || [])
58450
58824
  compileFile2(reexportPath, null, output, imports);
58451
58825
  if (cache2 && namesBefore) {
58452
- const st = statSync14(filePath);
58826
+ const st = statSync15(filePath);
58453
58827
  cache2.files.set(filePath, {
58454
58828
  mtimeMs: st.mtimeMs,
58455
58829
  size: st.size,
@@ -58579,9 +58953,9 @@ ${body}
58579
58953
  let sharedBundleCode = "";
58580
58954
  const sharedRuntimeNames = /* @__PURE__ */ new Set();
58581
58955
  if (sharedSources.length > 0) {
58582
- const tmpBase = mkdtempSync2(join20(resolve24(appDir, ".."), "tmp-vesk-shared-"));
58956
+ const tmpBase = mkdtempSync2(join21(resolve24(appDir, ".."), "tmp-vesk-shared-"));
58583
58957
  try {
58584
- const sharedEntry = join20(tmpBase, "shared-entry.js");
58958
+ const sharedEntry = join21(tmpBase, "shared-entry.js");
58585
58959
  const lines = [];
58586
58960
  const members = [];
58587
58961
  sharedSources.forEach((source, i) => {
@@ -58591,7 +58965,7 @@ ${body}
58591
58965
  lines.push(`globalThis.__veskShared = { ${members.join("\n")} };`);
58592
58966
  writeFileSync13(sharedEntry, lines.join("\n"));
58593
58967
  const appTsconfig = findTsconfigPath(appDir);
58594
- const runtimeShim = join20(tmpBase, "runtime-shim.js");
58968
+ const runtimeShim = join21(tmpBase, "runtime-shim.js");
58595
58969
  const runtimeLines = [
58596
58970
  "// ONE runtime instance: the entry bundle publishes these on globalThis,",
58597
58971
  "// and route chunks import the same functions. A second bundled copy",
@@ -58632,7 +59006,7 @@ ${body}
58632
59006
  bindings.named.forEach((n) => named.add(n));
58633
59007
  hasDefault = hasDefault || bindings.hasDefault;
58634
59008
  }
58635
- const shim = join20(tmpBase, `shim-${i}.js`);
59009
+ const shim = join21(tmpBase, `shim-${i}.js`);
58636
59010
  const shimLines = [`const m = globalThis.__veskShared[${JSON.stringify(source)}];`];
58637
59011
  if (hasDefault)
58638
59012
  shimLines.push(`export default m;`);
@@ -58663,13 +59037,21 @@ ${body}
58663
59037
  return null;
58664
59038
  let finalCode;
58665
59039
  if (entry.imports) {
58666
- const tmpBase = mkdtempSync2(join20(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
58667
- const tmpFile = join20(tmpBase, "entry.js");
59040
+ const tmpBase = mkdtempSync2(join21(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
59041
+ const tmpFile = join21(tmpBase, "entry.js");
58668
59042
  const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
58669
59043
  const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
58670
59044
  ${entry.code}
58671
59045
  `;
58672
59046
  writeFileSync13(tmpFile, toBundle);
59047
+ const serverOnlyHits = [];
59048
+ const driverHits = [];
59049
+ const eagerHits = [];
59050
+ const serverOnlyGuard = serverOnlyPlugin({
59051
+ onStub: (hit) => serverOnlyHits.push(hit),
59052
+ onDriver: (hit) => driverHits.push(hit),
59053
+ onEager: (hit) => eagerHits.push(hit)
59054
+ });
58673
59055
  try {
58674
59056
  const appTsconfig = findTsconfigPath(appDir);
58675
59057
  const result = await build3({
@@ -58693,7 +59075,7 @@ ${entry.code}
58693
59075
  // shared-modules.js serves every route chunk. (esbuild's `alias`
58694
59076
  // option only accepts bare package names, so this is a resolver
58695
59077
  // rather than a map.)
58696
- ...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin] } : {},
59078
+ ...sharedRedirectPlugin ? { plugins: [sharedRedirectPlugin, serverOnlyGuard] } : { plugins: [serverOnlyGuard] },
58697
59079
  ...appTsconfig ? { tsconfig: appTsconfig } : {}
58698
59080
  });
58699
59081
  finalCode = result.outputFiles[0].text;
@@ -58715,6 +59097,20 @@ ${entry.code}
58715
59097
  } catch {
58716
59098
  }
58717
59099
  }
59100
+ if (eagerHits.length > 0) {
59101
+ const detail = eagerHits.map((h) => `${h.importer} uses ${h.bindings.map((b) => `"${b}"`).join(", ")} from "${h.specifier}" at module scope`).join("; ");
59102
+ console.error("[vesk] server-only package used at module scope in client code", entry.name + ":", detail);
59103
+ throw new Error(`[vesk] ${entry.name}: ${detail}.
59104
+ 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.`);
59105
+ }
59106
+ if (driverHits.length > 0) {
59107
+ const detail = [...new Set(driverHits.map((h) => `${h.specifier} (from ${h.importer})`))].join(", ");
59108
+ console.error("[vesk] chunk bundle contains a TCP-only driver", entry.name + ":", detail);
59109
+ 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.`);
59110
+ }
59111
+ if (serverOnlyHits.length > 0) {
59112
+ reportServerOnlyImports2(entry.name, serverOnlyHits, options?.strict);
59113
+ }
58718
59114
  } else {
58719
59115
  finalCode = chunkIIFE(demoteExports2(entry.code));
58720
59116
  }
@@ -58754,7 +59150,7 @@ ${entry.code}
58754
59150
  if (seen.has(filePath))
58755
59151
  return;
58756
59152
  seen.add(filePath);
58757
- const src2 = readFileSync24(filePath, "utf-8");
59153
+ const src2 = readFileSync26(filePath, "utf-8");
58758
59154
  resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
58759
59155
  for (const cn of vskComponentNames(src2, filePath))
58760
59156
  componentOwners.claim(cn, filePath);
@@ -58847,9 +59243,9 @@ function buildRuntimeCode2(runtimeDir) {
58847
59243
  ];
58848
59244
  let code = "";
58849
59245
  for (const f of runtimeFiles) {
58850
- const p = join20(runtimeDir, f);
59246
+ const p = join21(runtimeDir, f);
58851
59247
  if (existsSync28(p)) {
58852
- let src2 = readFileSync24(p, "utf-8");
59248
+ let src2 = readFileSync26(p, "utf-8");
58853
59249
  src2 = stripTypes2(src2);
58854
59250
  src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
58855
59251
  src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
@@ -58861,7 +59257,7 @@ ${src2}
58861
59257
  `;
58862
59258
  }
58863
59259
  }
58864
- const indexSrc = readFileSync24(join20(runtimeDir, "index-client.js"), "utf-8");
59260
+ const indexSrc = readFileSync26(join21(runtimeDir, "index-client.js"), "utf-8");
58865
59261
  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())) || [];
58866
59262
  code += "// --- exports ---\n";
58867
59263
  for (const name of [...new Set(exportNames)]) {
@@ -58872,7 +59268,7 @@ ${src2}
58872
59268
  return code;
58873
59269
  }
58874
59270
  function runtimeExportNames2(runtimeDir) {
58875
- const indexSrc = readFileSync24(join20(runtimeDir, "index-client.js"), "utf-8");
59271
+ const indexSrc = readFileSync26(join21(runtimeDir, "index-client.js"), "utf-8");
58876
59272
  const names = /* @__PURE__ */ new Set();
58877
59273
  for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
58878
59274
  for (const raw2 of m[1].split(",")) {
@@ -58888,7 +59284,7 @@ function esbuildPath2(p) {
58888
59284
  return sep3 === "/" ? p : p.split(sep3).join("/");
58889
59285
  }
58890
59286
  function runtimeTreeShakeEntry2() {
58891
- return join20(tmpdir3(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
59287
+ return join21(tmpdir3(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
58892
59288
  }
58893
59289
  var treeShakeQueue2 = Promise.resolve();
58894
59290
  function buildTreeShakenRuntime2(runtimeDir, usedNames) {
@@ -58913,7 +59309,7 @@ async function bundleRuntimeNames2(runtimeDir, names, strict = false) {
58913
59309
  if (names.length === 0)
58914
59310
  return null;
58915
59311
  const entry = runtimeTreeShakeEntry2();
58916
- const indexClient = esbuildPath2(join20(runtimeDir, "index-client.js"));
59312
+ const indexClient = esbuildPath2(join21(runtimeDir, "index-client.js"));
58917
59313
  const unique = [...new Set(names)];
58918
59314
  try {
58919
59315
  try {
@@ -59061,7 +59457,7 @@ if (typeof document !== 'undefined') __router.start();
59061
59457
 
59062
59458
  // ../adapter/dist/paths.js
59063
59459
  import { resolve as resolve25, sep as sep4 } from "node:path";
59064
- import { existsSync as existsSync29, statSync as statSync15, readFileSync as readFileSync25 } from "node:fs";
59460
+ import { existsSync as existsSync29, statSync as statSync16, readFileSync as readFileSync27 } from "node:fs";
59065
59461
  function resolveWithin2(baseDir, relPath) {
59066
59462
  const base = resolve25(baseDir);
59067
59463
  const target = resolve25(baseDir, relPath);
@@ -59084,8 +59480,8 @@ function installMdReadHook2(publicDirs) {
59084
59480
  const lower2 = abs.toLowerCase();
59085
59481
  if (!lower2.endsWith(".md") && !lower2.endsWith(".markdown"))
59086
59482
  continue;
59087
- if (existsSync29(abs) && statSync15(abs).isFile())
59088
- return readFileSync25(abs, "utf8");
59483
+ if (existsSync29(abs) && statSync16(abs).isFile())
59484
+ return readFileSync27(abs, "utf8");
59089
59485
  } catch {
59090
59486
  }
59091
59487
  }
@@ -59152,13 +59548,13 @@ function urlAuthority3(url) {
59152
59548
  }
59153
59549
 
59154
59550
  // ../adapter/dist/dev-api.js
59155
- import { readFileSync as readFileSync28, statSync as statSync17, existsSync as existsSync32, readdirSync as readdirSync9 } from "node:fs";
59551
+ import { readFileSync as readFileSync30, statSync as statSync18, existsSync as existsSync32, readdirSync as readdirSync10 } from "node:fs";
59156
59552
  import { resolve as resolve28 } from "node:path";
59157
59553
 
59158
59554
  // ../adapter/dist/plugins.js
59159
59555
  init_paths();
59160
- import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
59161
- import { resolve as resolve26, dirname as dirname19, join as join21, extname as extname6, basename as basename6 } from "node:path";
59556
+ import { readFileSync as readFileSync28, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync17 } from "node:fs";
59557
+ import { resolve as resolve26, dirname as dirname19, join as join22, extname as extname6, basename as basename6 } from "node:path";
59162
59558
  import { createRequire as createRequire6 } from "node:module";
59163
59559
  import { spawn as spawn2 } from "node:child_process";
59164
59560
  var PLUGIN_STATE_FILENAME2 = "plugins.json";
@@ -59181,7 +59577,7 @@ function readPluginState2(veskDir) {
59181
59577
  return defaultState2();
59182
59578
  let raw2;
59183
59579
  try {
59184
- raw2 = JSON.parse(readFileSync26(file, "utf-8"));
59580
+ raw2 = JSON.parse(readFileSync28(file, "utf-8"));
59185
59581
  } catch {
59186
59582
  return defaultState2();
59187
59583
  }
@@ -59218,7 +59614,7 @@ function resolvePackage2(appDir, pkg) {
59218
59614
  const seen = /* @__PURE__ */ new Set();
59219
59615
  while (cur && cur !== dirname19(cur) && !seen.has(cur)) {
59220
59616
  seen.add(cur);
59221
- const candidate = join21(cur, "package.json");
59617
+ const candidate = join22(cur, "package.json");
59222
59618
  if (existsSync30(candidate)) {
59223
59619
  pkgJsonPath = candidate;
59224
59620
  break;
@@ -59247,7 +59643,7 @@ function resolvePackage2(appDir, pkg) {
59247
59643
  }
59248
59644
  }
59249
59645
  if (localPath) {
59250
- const localJson = join21(localPath, "package.json");
59646
+ const localJson = join22(localPath, "package.json");
59251
59647
  let json = null;
59252
59648
  if (existsSync30(localJson)) {
59253
59649
  json = readJsonFile2(localJson);
@@ -59273,7 +59669,7 @@ function localDir2(base, pkg) {
59273
59669
  function readJsonFile2(file) {
59274
59670
  try {
59275
59671
  if (existsSync30(file))
59276
- return JSON.parse(readFileSync26(file, "utf-8"));
59672
+ return JSON.parse(readFileSync28(file, "utf-8"));
59277
59673
  } catch {
59278
59674
  }
59279
59675
  return null;
@@ -59556,12 +59952,12 @@ function findIconFile2(dir, meta) {
59556
59952
  const explicit = str2(meta?.icon);
59557
59953
  if (explicit) {
59558
59954
  const p = resolveWithin(dir, explicit);
59559
- if (p && existsSync30(p) && statSync16(p).isFile())
59955
+ if (p && existsSync30(p) && statSync17(p).isFile())
59560
59956
  return p;
59561
59957
  }
59562
59958
  for (const name of ["icon.png", "icon.ico"]) {
59563
59959
  const p = resolve26(dir, name);
59564
- if (existsSync30(p) && statSync16(p).isFile())
59960
+ if (existsSync30(p) && statSync17(p).isFile())
59565
59961
  return p;
59566
59962
  }
59567
59963
  return null;
@@ -59646,7 +60042,7 @@ function resolveDtsPath2(probe, pkgJson) {
59646
60042
  if (!rel)
59647
60043
  continue;
59648
60044
  const abs = resolveWithin(dir, rel);
59649
- if (abs && existsSync30(abs) && statSync16(abs).isFile())
60045
+ if (abs && existsSync30(abs) && statSync17(abs).isFile())
59650
60046
  return abs;
59651
60047
  }
59652
60048
  return null;
@@ -59995,7 +60391,7 @@ function introspectPlugin2(appDir, name) {
59995
60391
  const pkgName = str2(pkgJson.name) ?? name;
59996
60392
  const exportsMap = flattenPackageExports2(pkgJson.exports);
59997
60393
  const dtsPath = resolveDtsPath2(probe, pkgJson);
59998
- const dtsExports = dtsPath ? parseDtsExports2(readFileSync26(dtsPath, "utf-8")) : [];
60394
+ const dtsExports = dtsPath ? parseDtsExports2(readFileSync28(dtsPath, "utf-8")) : [];
59999
60395
  return {
60000
60396
  ok: true,
60001
60397
  name: pkgName,
@@ -60133,9 +60529,9 @@ var __internals2 = {
60133
60529
  };
60134
60530
 
60135
60531
  // ../adapter/dist/dev-config.js
60136
- import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
60532
+ import { existsSync as existsSync31, readFileSync as readFileSync29, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
60137
60533
  import { tmpdir as tmpdir4 } from "node:os";
60138
- import { resolve as resolve27, dirname as dirname20, join as join22 } from "node:path";
60534
+ import { resolve as resolve27, dirname as dirname20, join as join23 } from "node:path";
60139
60535
  init_parser();
60140
60536
  function findConfigFile2(projectDir) {
60141
60537
  const ts9 = resolve27(projectDir, "vesk.config.ts");
@@ -60163,9 +60559,9 @@ async function parseConfigSource(source, isTs, projectDir) {
60163
60559
  js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
60164
60560
  ` + js;
60165
60561
  }
60166
- const base = projectDir ? (mkdirSync14(join22(projectDir, ".vesk"), { recursive: true }), join22(projectDir, ".vesk")) : void 0;
60167
- const dir = base ? mkdtempSync3(join22(base, "cfg-")) : mkdtempSync3(join22(tmpdir4(), "vesk-cfg-"));
60168
- const tmpFile = join22(dir, "config.mjs");
60562
+ const base = projectDir ? (mkdirSync14(join23(projectDir, ".vesk"), { recursive: true }), join23(projectDir, ".vesk")) : void 0;
60563
+ const dir = base ? mkdtempSync3(join23(base, "cfg-")) : mkdtempSync3(join23(tmpdir4(), "vesk-cfg-"));
60564
+ const tmpFile = join23(dir, "config.mjs");
60169
60565
  try {
60170
60566
  writeFileSync15(tmpFile, js, "utf-8");
60171
60567
  globalThis.__vesk_inject = {
@@ -60192,7 +60588,7 @@ async function readConfig2(projectDir) {
60192
60588
  const { path, isTs } = findConfigFile2(projectDir);
60193
60589
  if (!path)
60194
60590
  return { path: null, exists: false, source: "", config: {} };
60195
- const source = readFileSync27(path, "utf-8");
60591
+ const source = readFileSync29(path, "utf-8");
60196
60592
  const config = await parseConfigSource(source, isTs, projectDir);
60197
60593
  return { path, exists: true, source, config };
60198
60594
  }
@@ -61034,7 +61430,7 @@ export default defineConfig({
61034
61430
  await writeConfigSource2(projectDir, source);
61035
61431
  return;
61036
61432
  }
61037
- source = readFileSync27(path, "utf-8");
61433
+ source = readFileSync29(path, "utf-8");
61038
61434
  const existingImport = findPluginImportAst(source, pkg);
61039
61435
  let importName;
61040
61436
  if (existingImport) {
@@ -61114,7 +61510,7 @@ async function removePluginFromConfig2(projectDir, pkg) {
61114
61510
  const { path } = findConfigFile2(projectDir);
61115
61511
  if (!path)
61116
61512
  return false;
61117
- let source = readFileSync27(path, "utf-8");
61513
+ let source = readFileSync29(path, "utf-8");
61118
61514
  const original = source;
61119
61515
  const existingImport = findPluginImportAst(source, pkg);
61120
61516
  let importName = existingImport ? existingImport.name : null;
@@ -61235,7 +61631,7 @@ function createDevApiRouter2(opts) {
61235
61631
  return badRequest2("no vesk.config file to edit");
61236
61632
  if (!isTs)
61237
61633
  return badRequest2("single-key toggle edits only apply to vesk.config.ts (use the source editor for .js)");
61238
- const patched = applyConfigToggle2(readFileSync28(path, "utf-8"), b.key, b.value);
61634
+ const patched = applyConfigToggle2(readFileSync30(path, "utf-8"), b.key, b.value);
61239
61635
  if (patched === null)
61240
61636
  return badRequest2("could not safely edit the config object; use the source editor");
61241
61637
  const cfg = await writeConfigSource2(projectDir, patched);
@@ -61276,12 +61672,12 @@ function createDevApiRouter2(opts) {
61276
61672
  return jsonStatus(403, { error: "path escapes project root" });
61277
61673
  if (!existsSync32(resolved))
61278
61674
  return jsonStatus(404, { error: "not found" });
61279
- if (statSync17(resolved).isDirectory()) {
61280
- const entries = readdirSync9(resolved, { withFileTypes: true }).map((e) => e.name);
61675
+ if (statSync18(resolved).isDirectory()) {
61676
+ const entries = readdirSync10(resolved, { withFileTypes: true }).map((e) => e.name);
61281
61677
  return jsonStatus(200, { ok: true, path: target, directory: true, entries });
61282
61678
  }
61283
- if (statSync17(resolved).isFile()) {
61284
- return jsonStatus(200, { ok: true, path: target, directory: false, content: readFileSync28(resolved, "utf-8") });
61679
+ if (statSync18(resolved).isFile()) {
61680
+ return jsonStatus(200, { ok: true, path: target, directory: false, content: readFileSync30(resolved, "utf-8") });
61285
61681
  }
61286
61682
  return badRequest2("unsupported file type");
61287
61683
  } catch (e) {
@@ -61417,7 +61813,7 @@ function createDevApiRouter2(opts) {
61417
61813
  return {
61418
61814
  status: 200,
61419
61815
  headers: { "Content-Type": icon.mime, "Cache-Control": "private, max-age=60" },
61420
- body: readFileSync28(icon.file).toString("base64"),
61816
+ body: readFileSync30(icon.file).toString("base64"),
61421
61817
  encoding: "base64"
61422
61818
  };
61423
61819
  }
@@ -61474,8 +61870,8 @@ function produceDiagnostics(input) {
61474
61870
  }
61475
61871
 
61476
61872
  // ../agentic/dist/checkpoints.js
61477
- import { existsSync as existsSync33, mkdirSync as mkdirSync15, readFileSync as readFileSync29, writeFileSync as writeFileSync16, statSync as statSync18, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
61478
- import { join as join23, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
61873
+ 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";
61874
+ import { join as join24, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
61479
61875
  import { randomUUID as nodeRandomUUID } from "node:crypto";
61480
61876
  function generateId() {
61481
61877
  try {
@@ -61608,16 +62004,16 @@ var CheckpointManager = class {
61608
62004
  }
61609
62005
  };
61610
62006
  function getAgenticDir(projectDir) {
61611
- return join23(resolve29(projectDir), ".vesk", "agentic");
62007
+ return join24(resolve29(projectDir), ".vesk", "agentic");
61612
62008
  }
61613
62009
  function getHistoryPath(projectDir) {
61614
- return join23(getAgenticDir(projectDir), "history.json");
62010
+ return join24(getAgenticDir(projectDir), "history.json");
61615
62011
  }
61616
62012
  function getCheckpointDir(projectDir, id) {
61617
- return join23(getAgenticDir(projectDir), "checkpoints", id);
62013
+ return join24(getAgenticDir(projectDir), "checkpoints", id);
61618
62014
  }
61619
62015
  function getCheckpointPath(projectDir, id) {
61620
- return join23(getCheckpointDir(projectDir, id), "checkpoint.json");
62016
+ return join24(getCheckpointDir(projectDir, id), "checkpoint.json");
61621
62017
  }
61622
62018
  function ensureDir(dir) {
61623
62019
  mkdirSync15(dir, { recursive: true });
@@ -61626,7 +62022,7 @@ function readJson(filePath, fallback) {
61626
62022
  try {
61627
62023
  if (!existsSync33(filePath))
61628
62024
  return fallback;
61629
- const raw2 = readFileSync29(filePath, "utf-8");
62025
+ const raw2 = readFileSync31(filePath, "utf-8");
61630
62026
  if (raw2.trim() === "")
61631
62027
  return fallback;
61632
62028
  return JSON.parse(raw2);
@@ -61697,7 +62093,7 @@ function createCheckpoint(projectDir, message, changes = {}, buildResult) {
61697
62093
  };
61698
62094
  const agenticDir = getAgenticDir(projectDir);
61699
62095
  ensureDir(agenticDir);
61700
- ensureDir(join23(agenticDir, "checkpoints"));
62096
+ ensureDir(join24(agenticDir, "checkpoints"));
61701
62097
  const cpDir = getCheckpointDir(projectDir, id);
61702
62098
  ensureDir(cpDir);
61703
62099
  writeJsonAtomic(getCheckpointPath(projectDir, id), checkpoint);
@@ -61726,7 +62122,7 @@ function rollback(projectDir, id) {
61726
62122
  if (f.before === null) {
61727
62123
  try {
61728
62124
  if (existsSync33(abs)) {
61729
- const s = statSync18(abs);
62125
+ const s = statSync19(abs);
61730
62126
  if (s.isDirectory())
61731
62127
  rmSync6(abs, { recursive: true, force: true });
61732
62128
  else
@@ -61746,7 +62142,7 @@ function rollback(projectDir, id) {
61746
62142
  }
61747
62143
 
61748
62144
  // ../agentic/dist/config.js
61749
- import { readFileSync as readFileSync30, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync16, chmodSync } from "node:fs";
62145
+ import { readFileSync as readFileSync32, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync16, chmodSync } from "node:fs";
61750
62146
  import { resolve as resolve30, dirname as dirname22 } from "node:path";
61751
62147
  var DEFAULT_CONFIG = {
61752
62148
  provider: "openai",
@@ -61795,7 +62191,7 @@ function readDotenvValue(projectDir, key, def = null) {
61795
62191
  const p = dotenvPath(projectDir);
61796
62192
  if (!existsSync34(p))
61797
62193
  return def;
61798
- const content = readFileSync30(p, "utf-8");
62194
+ const content = readFileSync32(p, "utf-8");
61799
62195
  for (const rawLine of content.split("\n")) {
61800
62196
  const line = rawLine.trim();
61801
62197
  if (!line || line.startsWith("#"))
@@ -61823,7 +62219,7 @@ function writeDotenvValue(projectDir, key, value) {
61823
62219
  let out = "";
61824
62220
  let replaced = false;
61825
62221
  if (existsSync34(p)) {
61826
- const lines = readFileSync30(p, "utf-8").split("\n");
62222
+ const lines = readFileSync32(p, "utf-8").split("\n");
61827
62223
  for (const rawLine of lines) {
61828
62224
  const trimmed = rawLine.trim();
61829
62225
  const eq = trimmed.indexOf("=");
@@ -61853,7 +62249,7 @@ function loadAgenticConfig(projectDir) {
61853
62249
  let cfg = { ...DEFAULT_CONFIG };
61854
62250
  try {
61855
62251
  if (existsSync34(p))
61856
- cfg = { ...cfg, ...JSON.parse(readFileSync30(p, "utf-8")) };
62252
+ cfg = { ...cfg, ...JSON.parse(readFileSync32(p, "utf-8")) };
61857
62253
  } catch {
61858
62254
  }
61859
62255
  let hasKey = false;
@@ -61896,7 +62292,7 @@ function getProviderSpecificKey(projectDir, provider) {
61896
62292
  try {
61897
62293
  const pp2 = providerKeyPath(projectDir, prov);
61898
62294
  if (existsSync34(pp2)) {
61899
- const v = readFileSync30(pp2, "utf-8").trim();
62295
+ const v = readFileSync32(pp2, "utf-8").trim();
61900
62296
  if (v)
61901
62297
  return v;
61902
62298
  }
@@ -61944,7 +62340,7 @@ function getApiKey(projectDir, provider) {
61944
62340
  try {
61945
62341
  const pp2 = providerKeyPath(projectDir, prov);
61946
62342
  if (existsSync34(pp2)) {
61947
- const v = readFileSync30(pp2, "utf-8").trim();
62343
+ const v = readFileSync32(pp2, "utf-8").trim();
61948
62344
  if (v)
61949
62345
  return v;
61950
62346
  }
@@ -61967,7 +62363,7 @@ function getApiKey(projectDir, provider) {
61967
62363
  }
61968
62364
 
61969
62365
  // ../agentic/dist/dev-api.js
61970
- import { existsSync as existsSync35, readFileSync as readFileSync31 } from "node:fs";
62366
+ import { existsSync as existsSync35, readFileSync as readFileSync33 } from "node:fs";
61971
62367
  import { resolve as resolve31 } from "node:path";
61972
62368
 
61973
62369
  // ../agentic/dist/providers/openai.js
@@ -62340,7 +62736,7 @@ function getPerProviderKeyRaw(projectDir, provider) {
62340
62736
  try {
62341
62737
  const p = resolve31(projectDir, ".vesk", "agentic", "keys", `${sanitizeProviderName(prov)}.key`);
62342
62738
  if (existsSync35(p)) {
62343
- const v = readFileSync31(p, "utf-8").trim();
62739
+ const v = readFileSync33(p, "utf-8").trim();
62344
62740
  if (v)
62345
62741
  return v;
62346
62742
  }
@@ -63201,8 +63597,8 @@ var Agent = class {
63201
63597
  };
63202
63598
 
63203
63599
  // ../agentic/dist/tools/vesk.js
63204
- import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
63205
- import { resolve as resolve32, join as join24, dirname as dirname23, sep as sep6 } from "node:path";
63600
+ import { existsSync as existsSync36, readFileSync as readFileSync34, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync11, statSync as statSync20 } from "node:fs";
63601
+ import { resolve as resolve32, join as join25, dirname as dirname23, sep as sep6 } from "node:path";
63206
63602
  function resolveWithin3(baseDir, relPath) {
63207
63603
  const base = resolve32(baseDir);
63208
63604
  const target = resolve32(baseDir, relPath);
@@ -63220,7 +63616,7 @@ function readPluginState3(veskDir) {
63220
63616
  if (!existsSync36(file))
63221
63617
  return { version: 1, plugins: [] };
63222
63618
  try {
63223
- const raw2 = JSON.parse(readFileSync32(file, "utf-8"));
63619
+ const raw2 = JSON.parse(readFileSync34(file, "utf-8"));
63224
63620
  if (!raw2 || typeof raw2 !== "object")
63225
63621
  return { version: 1, plugins: [] };
63226
63622
  if (raw2.version !== 1)
@@ -63264,7 +63660,7 @@ function findConfigFile3(projectDir) {
63264
63660
  return { path: null, isTs: false };
63265
63661
  }
63266
63662
  function checkpointDir(veskDir) {
63267
- return join24(resolve32(veskDir), "checkpoints");
63663
+ return join25(resolve32(veskDir), "checkpoints");
63268
63664
  }
63269
63665
  function findMatchingBrace2(src2, openIdx) {
63270
63666
  let inStr = null;
@@ -63409,18 +63805,18 @@ function createVeskTools(deps) {
63409
63805
  async execute(_args) {
63410
63806
  try {
63411
63807
  const projExists = existsSync36(projectDir);
63412
- const projEntries = projExists ? readdirSync10(projectDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
63808
+ const projEntries = projExists ? readdirSync11(projectDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
63413
63809
  const appExists = existsSync36(appDir);
63414
- const appEntries = appExists ? readdirSync10(appDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
63810
+ const appEntries = appExists ? readdirSync11(appDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
63415
63811
  const veskExists = existsSync36(veskDir);
63416
- const veskEntries = veskExists ? readdirSync10(veskDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
63812
+ const veskEntries = veskExists ? readdirSync11(veskDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
63417
63813
  const cfgInfo = findConfigFile3(projectDir);
63418
63814
  let configSource = null;
63419
63815
  let configExists = false;
63420
63816
  if (cfgInfo.path && existsSync36(cfgInfo.path)) {
63421
63817
  configExists = true;
63422
63818
  try {
63423
- configSource = readFileSync32(cfgInfo.path, "utf-8").slice(0, 8e3);
63819
+ configSource = readFileSync34(cfgInfo.path, "utf-8").slice(0, 8e3);
63424
63820
  } catch {
63425
63821
  configSource = null;
63426
63822
  }
@@ -63429,7 +63825,7 @@ function createVeskTools(deps) {
63429
63825
  const pkgPath = resolve32(projectDir, "package.json");
63430
63826
  if (existsSync36(pkgPath)) {
63431
63827
  try {
63432
- packageJson = JSON.parse(readFileSync32(pkgPath, "utf-8"));
63828
+ packageJson = JSON.parse(readFileSync34(pkgPath, "utf-8"));
63433
63829
  } catch {
63434
63830
  packageJson = null;
63435
63831
  }
@@ -63511,13 +63907,13 @@ function createVeskTools(deps) {
63511
63907
  return jsonError("path escapes project root", { path: rel });
63512
63908
  if (!existsSync36(resolved))
63513
63909
  return jsonError("not found", { path: rel });
63514
- const st = statSync19(resolved);
63910
+ const st = statSync20(resolved);
63515
63911
  if (st.isDirectory()) {
63516
- const entries = readdirSync10(resolved, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name);
63912
+ const entries = readdirSync11(resolved, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name);
63517
63913
  return jsonOk({ ok: true, path: rel, directory: true, entries: entries.slice(0, 200) });
63518
63914
  }
63519
63915
  if (st.isFile()) {
63520
- const content = readFileSync32(resolved, "utf-8");
63916
+ const content = readFileSync34(resolved, "utf-8");
63521
63917
  const capped = content.length > 2e4 ? content.slice(0, 2e4) + "\n/* truncated */" : content;
63522
63918
  return jsonOk({ ok: true, path: rel, directory: false, content: capped, size: content.length });
63523
63919
  }
@@ -63553,7 +63949,7 @@ function createVeskTools(deps) {
63553
63949
  if (!info.path || !existsSync36(info.path)) {
63554
63950
  return jsonOk({ ok: true, path: null, exists: false, source: "", config: {} });
63555
63951
  }
63556
- const source = readFileSync32(info.path, "utf-8");
63952
+ const source = readFileSync34(info.path, "utf-8");
63557
63953
  return jsonOk({ ok: true, path: info.path, exists: true, source, config: null });
63558
63954
  } catch (e) {
63559
63955
  return jsonError(e instanceof Error ? e.message : String(e));
@@ -63611,7 +64007,7 @@ function createVeskTools(deps) {
63611
64007
  const contained = resolveWithin3(projectDir, info.path.slice(projectDir.length + 1));
63612
64008
  if (!contained)
63613
64009
  return jsonError("path escapes project root");
63614
- const current3 = readFileSync32(info.path, "utf-8");
64010
+ const current3 = readFileSync34(info.path, "utf-8");
63615
64011
  const patched = applySimpleConfigToggle(current3, key, a.value);
63616
64012
  if (patched === null)
63617
64013
  return jsonError("could not safely edit the config object; use the source editor");
@@ -63879,7 +64275,7 @@ function createVeskTools(deps) {
63879
64275
  const dir = checkpointDir(veskDir);
63880
64276
  mkdirSync17(dir, { recursive: true });
63881
64277
  const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
63882
- const file = join24(dir, `${id}.json`);
64278
+ const file = join25(dir, `${id}.json`);
63883
64279
  const check = resolveWithin3(dir, `${id}.json`);
63884
64280
  if (!check)
63885
64281
  return jsonError("path escapes project root");
@@ -63928,13 +64324,13 @@ function createVeskTools(deps) {
63928
64324
  } catch {
63929
64325
  }
63930
64326
  const dir = checkpointDir(veskDir);
63931
- const file = join24(dir, `${checkpointId}.json`);
64327
+ const file = join25(dir, `${checkpointId}.json`);
63932
64328
  const contained = resolveWithin3(dir, `${checkpointId}.json`);
63933
64329
  if (!contained)
63934
64330
  return jsonError("path escapes project root");
63935
64331
  if (!existsSync36(file))
63936
64332
  return jsonError(`checkpoint not found: ${checkpointId}`, { checkpointId });
63937
- const raw2 = readFileSync32(file, "utf-8");
64333
+ const raw2 = readFileSync34(file, "utf-8");
63938
64334
  let data2;
63939
64335
  try {
63940
64336
  data2 = JSON.parse(raw2);
@@ -64017,7 +64413,7 @@ function renderDefaultNotFoundPage2(opts = {}) {
64017
64413
  }
64018
64414
 
64019
64415
  // ../adapter/dist/css.js
64020
- import { readFileSync as readFileSync33, existsSync as existsSync37 } from "node:fs";
64416
+ import { readFileSync as readFileSync35, existsSync as existsSync37 } from "node:fs";
64021
64417
  import { resolve as resolve33 } from "node:path";
64022
64418
  var GLOBAL_CSS_URL2 = "/_vesk/static/global.css";
64023
64419
  function resolveUserCssPath2(appDir) {
@@ -64044,7 +64440,7 @@ function resolveCssUrls2(opts) {
64044
64440
  // ../adapter/dist/hmr.js
64045
64441
  init_client_codegen();
64046
64442
  import { WebSocketServer } from "ws";
64047
- import { readFileSync as readFileSync34, existsSync as existsSync38, writeFileSync as writeFileSync19 } from "node:fs";
64443
+ import { readFileSync as readFileSync36, existsSync as existsSync38, writeFileSync as writeFileSync19 } from "node:fs";
64048
64444
  import { resolve as resolve34, dirname as dirname24 } from "node:path";
64049
64445
  import { fileURLToPath as fileURLToPath7 } from "node:url";
64050
64446
  init_default_pages();
@@ -64288,7 +64684,7 @@ function buildErrorPayload(error, filename, opts = {}) {
64288
64684
  for (const absPath of candidates) {
64289
64685
  try {
64290
64686
  if (existsSync38(absPath)) {
64291
- src2 = readFileSync34(absPath, "utf-8");
64687
+ src2 = readFileSync36(absPath, "utf-8");
64292
64688
  resolvedAbsPath = absPath;
64293
64689
  break;
64294
64690
  }
@@ -64336,7 +64732,7 @@ function buildErrorPayload(error, filename, opts = {}) {
64336
64732
  }
64337
64733
 
64338
64734
  // ../adapter/dist/ssr-error.js
64339
- import { existsSync as existsSync39, readFileSync as readFileSync35 } from "node:fs";
64735
+ import { existsSync as existsSync39, readFileSync as readFileSync37 } from "node:fs";
64340
64736
  import { relative as relative7, resolve as resolve35 } from "node:path";
64341
64737
 
64342
64738
  // ../adapter/dist/error-codeframe.js
@@ -64433,7 +64829,7 @@ function extractComponentNames(stack) {
64433
64829
  }
64434
64830
  return names;
64435
64831
  }
64436
- var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".vsk"]);
64832
+ var SOURCE_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".vsk"]);
64437
64833
  function scanFrameLocation(seg) {
64438
64834
  if (!seg)
64439
64835
  return null;
@@ -64514,7 +64910,7 @@ function firstSourceFileFrame(stack, projectRoot) {
64514
64910
  if (!p.startsWith("/"))
64515
64911
  continue;
64516
64912
  const ext = p.slice(p.lastIndexOf(".")).split(":")[0].toLowerCase();
64517
- if (!SOURCE_EXTENSIONS.has(ext))
64913
+ if (!SOURCE_EXTENSIONS2.has(ext))
64518
64914
  continue;
64519
64915
  if (isGeneratedPath(p))
64520
64916
  continue;
@@ -64567,7 +64963,7 @@ function readIfFile(absPath) {
64567
64963
  try {
64568
64964
  if (!existsSync39(absPath))
64569
64965
  return null;
64570
- return readFileSync35(absPath, "utf-8");
64966
+ return readFileSync37(absPath, "utf-8");
64571
64967
  } catch {
64572
64968
  return null;
64573
64969
  }
@@ -64715,9 +65111,9 @@ function renderDevErrorPage(payload, opts) {
64715
65111
 
64716
65112
  // src/build-packages.ts
64717
65113
  import { spawnSync as spawnSync2 } from "node:child_process";
64718
- import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync18, readFileSync as readFileSync36, readdirSync as readdirSync11, statSync as statSync20, writeFileSync as writeFileSync20 } from "node:fs";
65114
+ 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";
64719
65115
  import { createRequire as createRequire7 } from "node:module";
64720
- import { dirname as dirname25, join as join25, resolve as resolve36 } from "node:path";
65116
+ import { dirname as dirname25, join as join26, resolve as resolve36 } from "node:path";
64721
65117
  import { fileURLToPath as fileURLToPath8 } from "node:url";
64722
65118
  var require2 = createRequire7(import.meta.url);
64723
65119
  var __dirname9 = dirname25(fileURLToPath8(import.meta.url));
@@ -64747,9 +65143,9 @@ var PACKAGES = {
64747
65143
  };
64748
65144
  function newestSourceMtime(srcDir) {
64749
65145
  let newest = 0;
64750
- for (const name of readdirSync11(srcDir)) {
64751
- const p = join25(srcDir, name);
64752
- const st = statSync20(p);
65146
+ for (const name of readdirSync12(srcDir)) {
65147
+ const p = join26(srcDir, name);
65148
+ const st = statSync21(p);
64753
65149
  if (st.isDirectory()) {
64754
65150
  newest = Math.max(newest, newestSourceMtime(p));
64755
65151
  } else if (st.isFile() && /\.ts$/.test(name) && !name.endsWith(".test.ts")) {
@@ -64759,11 +65155,11 @@ function newestSourceMtime(srcDir) {
64759
65155
  return newest;
64760
65156
  }
64761
65157
  function distStale(pkgDir, entry) {
64762
- const distIndex = join25(pkgDir, "dist", `${entry}.js`);
65158
+ const distIndex = join26(pkgDir, "dist", `${entry}.js`);
64763
65159
  if (!existsSync40(distIndex)) return true;
64764
- const distPkg = join25(pkgDir, "dist", "package.json");
64765
- const distStamp = Math.max(statSync20(distIndex).mtimeMs, existsSync40(distPkg) ? statSync20(distPkg).mtimeMs : 0);
64766
- return newestSourceMtime(join25(pkgDir, "src")) > distStamp;
65160
+ const distPkg = join26(pkgDir, "dist", "package.json");
65161
+ const distStamp = Math.max(statSync21(distIndex).mtimeMs, existsSync40(distPkg) ? statSync21(distPkg).mtimeMs : 0);
65162
+ return newestSourceMtime(join26(pkgDir, "src")) > distStamp;
64767
65163
  }
64768
65164
  function distPackageJson(pkgName, entry, serverEntry, version2) {
64769
65165
  const exports = {
@@ -64787,23 +65183,23 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
64787
65183
  function buildPackages(force = false) {
64788
65184
  for (const [pkg, cfg] of Object.entries(PACKAGES)) {
64789
65185
  const pkgDir = resolve36(root2, "packages", pkg);
64790
- if (!existsSync40(join25(pkgDir, "src"))) continue;
65186
+ if (!existsSync40(join26(pkgDir, "src"))) continue;
64791
65187
  if (!force && !distStale(pkgDir, cfg.entry)) continue;
64792
65188
  console.log(`[build] ${cfg.name} -> tsc`);
64793
65189
  const tscBin = require2.resolve("typescript/bin/tsc");
64794
- const result = spawnSync2(process.execPath, [tscBin, "-p", join25(pkgDir, "tsconfig.build.json")], {
65190
+ const result = spawnSync2(process.execPath, [tscBin, "-p", join26(pkgDir, "tsconfig.build.json")], {
64795
65191
  stdio: "inherit"
64796
65192
  });
64797
65193
  if (result.status !== 0) {
64798
65194
  throw new Error(`tsc failed for ${cfg.name}`);
64799
65195
  }
64800
- const distDir = join25(pkgDir, "dist");
65196
+ const distDir = join26(pkgDir, "dist");
64801
65197
  for (const c of cfg.copy || []) {
64802
- const to = join25(distDir, c.to);
65198
+ const to = join26(distDir, c.to);
64803
65199
  mkdirSync18(dirname25(to), { recursive: true });
64804
- cpSync2(join25(pkgDir, c.from), to, { recursive: true });
65200
+ cpSync2(join26(pkgDir, c.from), to, { recursive: true });
64805
65201
  }
64806
- const srcPkg = JSON.parse(readFileSync36(join25(pkgDir, "package.json"), "utf-8"));
65202
+ const srcPkg = JSON.parse(readFileSync38(join26(pkgDir, "package.json"), "utf-8"));
64807
65203
  if (pkg === "lucide-vesk") {
64808
65204
  const lucideDistPkg = {
64809
65205
  name: srcPkg.name,
@@ -64817,9 +65213,9 @@ function buildPackages(force = false) {
64817
65213
  "./package.json": "./package.json"
64818
65214
  }
64819
65215
  };
64820
- writeFileSync20(join25(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
65216
+ writeFileSync20(join26(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
64821
65217
  } else {
64822
- writeFileSync20(join25(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
65218
+ writeFileSync20(join26(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
64823
65219
  }
64824
65220
  console.log(`[build] ${cfg.name} -> dist`);
64825
65221
  }
@@ -64832,7 +65228,7 @@ if (process.argv[1] && resolve36(process.argv[1]) === fileURLToPath8(import.meta
64832
65228
  }
64833
65229
 
64834
65230
  // src/action-handler.ts
64835
- import { existsSync as existsSync41, readFileSync as readFileSync37, readdirSync as readdirSync12 } from "node:fs";
65231
+ import { existsSync as existsSync41, readFileSync as readFileSync39, readdirSync as readdirSync13 } from "node:fs";
64836
65232
  import { resolve as resolve37 } from "node:path";
64837
65233
 
64838
65234
  // ../compiler/dist/server-cookies.js
@@ -64928,7 +65324,7 @@ function walkVskFiles(dir, out, seen) {
64928
65324
  if (!existsSync41(dir)) return;
64929
65325
  let entries;
64930
65326
  try {
64931
- entries = readdirSync12(dir, { withFileTypes: true });
65327
+ entries = readdirSync13(dir, { withFileTypes: true });
64932
65328
  } catch {
64933
65329
  return;
64934
65330
  }
@@ -64962,7 +65358,7 @@ function candidateSources(appDirPath, routeTree) {
64962
65358
  function registerSource(sourcePath2) {
64963
65359
  if (!existsSync41(sourcePath2)) return;
64964
65360
  try {
64965
- compileFile(readFileSync37(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
65361
+ compileFile(readFileSync39(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
64966
65362
  } catch {
64967
65363
  }
64968
65364
  }
@@ -65001,14 +65397,14 @@ async function renderPageHtml(pagePathname, params, ctx2) {
65001
65397
  const pageFilePath = resolve37(ctx2.appDirPath, node.sourceDir, "page.vsk");
65002
65398
  const layoutFilePath = resolve37(ctx2.appDirPath, node.sourceDir, "layout.vsk");
65003
65399
  if (i === chain.length - 1 && node.page && existsSync41(pageFilePath)) {
65004
- const src3 = readFileSync37(pageFilePath, "utf-8");
65400
+ const src3 = readFileSync39(pageFilePath, "utf-8");
65005
65401
  const compName2 = resolveComponentName(src3) || node.page;
65006
65402
  const result = await renderPage(src3, compName2, { params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
65007
65403
  body = result.body;
65008
65404
  head = result.head || "";
65009
65405
  }
65010
65406
  if (node.layout && existsSync41(layoutFilePath)) {
65011
- const src3 = readFileSync37(layoutFilePath, "utf-8");
65407
+ const src3 = readFileSync39(layoutFilePath, "utf-8");
65012
65408
  const compName2 = resolveComponentName(src3) || node.layout;
65013
65409
  const result = await renderPage(src3, compName2, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
65014
65410
  body = result.body;
@@ -65039,7 +65435,7 @@ ${prettifyHtml(body)}
65039
65435
  }
65040
65436
  const leaf2 = chain.find((n) => n.page);
65041
65437
  if (!leaf2) return null;
65042
- const src2 = readFileSync37(resolve37(ctx2.appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
65438
+ const src2 = readFileSync39(resolve37(ctx2.appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
65043
65439
  const compName = resolveComponentName(src2) || leaf2.page;
65044
65440
  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 });
65045
65441
  return applyHtmlPlugins(html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>'), ctx2.plugins, { sourcePath: ctx2.url.pathname });
@@ -65206,7 +65602,7 @@ function buildDevErrorPayload(input) {
65206
65602
  payload.column = colMatch ? parseInt(colMatch[1], 10) : 1;
65207
65603
  if (fileExists && payload.line > 0) {
65208
65604
  try {
65209
- const src2 = readFileSync38(fullPath, "utf-8");
65605
+ const src2 = readFileSync40(fullPath, "utf-8");
65210
65606
  const cf = buildCodeframe2(src2, payload.line, payload.column);
65211
65607
  if (cf) {
65212
65608
  cf.file = payload.file || filename;
@@ -65296,9 +65692,9 @@ function resolveRuntimeDir(projectDir) {
65296
65692
  resolve38(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
65297
65693
  ];
65298
65694
  for (const dir of candidates) {
65299
- if (existsSync42(join26(dir, "ripple-runtime.js"))) return dir;
65300
- const distDir = join26(dir, "dist");
65301
- if (existsSync42(join26(distDir, "ripple-runtime.js"))) return distDir;
65695
+ if (existsSync42(join27(dir, "ripple-runtime.js"))) return dir;
65696
+ const distDir = join27(dir, "dist");
65697
+ if (existsSync42(join27(distDir, "ripple-runtime.js"))) return distDir;
65302
65698
  }
65303
65699
  return null;
65304
65700
  }
@@ -65537,8 +65933,8 @@ function collectRoutePaths(nodes, out = []) {
65537
65933
  function countFilesNamed(dir, name) {
65538
65934
  if (!existsSync42(dir)) return 0;
65539
65935
  let n = 0;
65540
- for (const entry of readdirSync13(dir, { withFileTypes: true })) {
65541
- const p = join26(dir, entry.name);
65936
+ for (const entry of readdirSync14(dir, { withFileTypes: true })) {
65937
+ const p = join27(dir, entry.name);
65542
65938
  if (entry.isDirectory()) n += countFilesNamed(p, name);
65543
65939
  else if (entry.name === name) n++;
65544
65940
  }
@@ -65549,7 +65945,7 @@ function cachedSsrCompile(cache2, src2, filePath) {
65549
65945
  resetVskState(true);
65550
65946
  return compileFile(source, { sourcePath: filePath });
65551
65947
  };
65552
- const st = statSync21(filePath, { throwIfNoEntry: false });
65948
+ const st = statSync22(filePath, { throwIfNoEntry: false });
65553
65949
  if (st) {
65554
65950
  const cur = cache2.get(filePath);
65555
65951
  if (cur && cur.mtimeMs === st.mtimeMs && cur.size === st.size) return cur.result;
@@ -65581,7 +65977,7 @@ async function startDevServer(port, projectDir, config, host) {
65581
65977
  process.exit(1);
65582
65978
  }
65583
65979
  const runtimeDir = runtimeDirUnchecked;
65584
- const veskStateDir = join26(projectDir, ".vesk");
65980
+ const veskStateDir = join27(projectDir, ".vesk");
65585
65981
  const configPluginsRaw = config.plugins || [];
65586
65982
  const configPluginNames = configPluginsRaw.map((p) => typeof p === "string" ? p : p?.name).filter((n) => !!n);
65587
65983
  const rawDevPlugins = config.plugins || [];
@@ -65680,21 +66076,21 @@ async function startDevServer(port, projectDir, config, host) {
65680
66076
  }
65681
66077
  let devGlobalCssContent = "";
65682
66078
  let lastServedCssGlobal = "";
65683
- const appCssPath = join26(appDirPath, "global.css");
65684
- const srcDir = join26(projectDir, "src");
65685
- const cssPath = join26(srcDir, "global.css");
65686
- const altCssPath = join26(srcDir, "app.css");
66079
+ const appCssPath = join27(appDirPath, "global.css");
66080
+ const srcDir = join27(projectDir, "src");
66081
+ const cssPath = join27(srcDir, "global.css");
66082
+ const altCssPath = join27(srcDir, "app.css");
65687
66083
  let rawCss = "";
65688
66084
  let devCssSource = "";
65689
66085
  if (existsSync42(appCssPath)) {
65690
66086
  devCssSource = appCssPath;
65691
- rawCss = readFileSync38(appCssPath, "utf-8");
66087
+ rawCss = readFileSync40(appCssPath, "utf-8");
65692
66088
  } else if (existsSync42(cssPath)) {
65693
66089
  devCssSource = cssPath;
65694
- rawCss = readFileSync38(cssPath, "utf-8");
66090
+ rawCss = readFileSync40(cssPath, "utf-8");
65695
66091
  } else if (existsSync42(altCssPath)) {
65696
66092
  devCssSource = altCssPath;
65697
- rawCss = readFileSync38(altCssPath, "utf-8");
66093
+ rawCss = readFileSync40(altCssPath, "utf-8");
65698
66094
  }
65699
66095
  if (rawCss) {
65700
66096
  const activeAtStart = getActiveDevPlugins();
@@ -65742,22 +66138,22 @@ async function startDevServer(port, projectDir, config, host) {
65742
66138
  }
65743
66139
  const routeChunksBuilt = /* @__PURE__ */ new Set();
65744
66140
  let clientGeneration = 0;
65745
- const devCacheDir = () => join26(projectDir, "node_modules", ".vesk", "dev-cache");
66141
+ const devCacheDir = () => join27(projectDir, "node_modules", ".vesk", "dev-cache");
65746
66142
  function devCacheKey() {
65747
66143
  const parts = [`flags:${!!config.routeDataCache}`];
65748
66144
  const walk9 = (dir) => {
65749
66145
  let entries = [];
65750
66146
  try {
65751
- entries = readdirSync13(dir);
66147
+ entries = readdirSync14(dir);
65752
66148
  } catch {
65753
66149
  return;
65754
66150
  }
65755
66151
  for (const name of entries.sort()) {
65756
66152
  if (name === "node_modules" || name.startsWith(".")) continue;
65757
- const p = join26(dir, name);
66153
+ const p = join27(dir, name);
65758
66154
  let st;
65759
66155
  try {
65760
- st = statSync21(p);
66156
+ st = statSync22(p);
65761
66157
  } catch {
65762
66158
  continue;
65763
66159
  }
@@ -65771,15 +66167,15 @@ async function startDevServer(port, projectDir, config, host) {
65771
66167
  };
65772
66168
  walk9(appDirPath);
65773
66169
  try {
65774
- parts.push(`compiler:${readFileSync38(join26(process.cwd(), "node_modules", "@vesk", "compiler", "package.json"), "utf8")}`);
66170
+ parts.push(`compiler:${readFileSync40(join27(process.cwd(), "node_modules", "@vesk", "compiler", "package.json"), "utf8")}`);
65775
66171
  } catch {
65776
66172
  }
65777
66173
  return createHash3("sha256").update(parts.join("\n")).digest("hex").slice(0, 32);
65778
66174
  }
65779
66175
  function readDevBundleCache() {
65780
66176
  try {
65781
- const file = join26(devCacheDir(), "client-bundle.json");
65782
- const parsed = JSON.parse(readFileSync38(file, "utf8"));
66177
+ const file = join27(devCacheDir(), "client-bundle.json");
66178
+ const parsed = JSON.parse(readFileSync40(file, "utf8"));
65783
66179
  if (parsed.key !== devCacheKey() || typeof parsed.main !== "string" || !Array.isArray(parsed.chunks)) return null;
65784
66180
  return { main: parsed.main, chunks: parsed.chunks };
65785
66181
  } catch {
@@ -65790,8 +66186,8 @@ async function startDevServer(port, projectDir, config, host) {
65790
66186
  try {
65791
66187
  const dir = devCacheDir();
65792
66188
  mkdirSync19(dir, { recursive: true });
65793
- const file = join26(dir, "client-bundle.json");
65794
- const tmp = join26(dir, `client-bundle.${process.pid}.tmp`);
66189
+ const file = join27(dir, "client-bundle.json");
66190
+ const tmp = join27(dir, `client-bundle.${process.pid}.tmp`);
65795
66191
  writeFileSync21(tmp, JSON.stringify({ key: devCacheKey(), main, chunks }), "utf8");
65796
66192
  renameSync2(tmp, file);
65797
66193
  } catch {
@@ -66084,7 +66480,7 @@ async function startDevServer(port, projectDir, config, host) {
66084
66480
  if (!filename) return;
66085
66481
  const kind = classifyHmrWatchPath(filename);
66086
66482
  if (kind === "ignored") return;
66087
- const fullPath = filename.startsWith("/") ? filename : join26(watchDir, filename);
66483
+ const fullPath = filename.startsWith("/") ? filename : join27(watchDir, filename);
66088
66484
  const fileExists = existsSync42(fullPath);
66089
66485
  const bcast = (msg) => {
66090
66486
  const f = globalThis.__vesk_broadcastHmr;
@@ -66109,7 +66505,7 @@ async function startDevServer(port, projectDir, config, host) {
66109
66505
  debounceTimer = setTimeout(async () => {
66110
66506
  const t0 = Date.now();
66111
66507
  try {
66112
- const current3 = fileExists ? readFileSync38(fullPath, "utf-8") : null;
66508
+ const current3 = fileExists ? readFileSync40(fullPath, "utf-8") : null;
66113
66509
  if (eventType !== "rename" && current3 !== null && lastSeenContent.get(fullPath) === current3) {
66114
66510
  LOG.info(`skipped unchanged (${filename})`);
66115
66511
  return;
@@ -66168,7 +66564,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66168
66564
  if (compCode.trim()) fnSources = { _raw: compCode };
66169
66565
  } else if (fileExists && !bundleError) {
66170
66566
  try {
66171
- const src2 = readFileSync38(fullPath, "utf-8");
66567
+ const src2 = readFileSync40(fullPath, "utf-8");
66172
66568
  let compCode = buildHmrEvalSnippet2(
66173
66569
  compileClient2(src2, null, { forceClient: true, sourcePath: fullPath, mdRoots: [projectDir] })
66174
66570
  );
@@ -66252,7 +66648,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66252
66648
  cssDebounceTimer = setTimeout(async () => {
66253
66649
  try {
66254
66650
  if (fileExists) {
66255
- rawCss = readFileSync38(fullPath, "utf-8");
66651
+ rawCss = readFileSync40(fullPath, "utf-8");
66256
66652
  }
66257
66653
  const cssChanged = await rebuildTailwindCss();
66258
66654
  if (cssChanged && typeof globalThis.__vesk_broadcastHmr === "function") {
@@ -66299,8 +66695,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66299
66695
  ".json": "application/json",
66300
66696
  ".webmanifest": "application/manifest+json"
66301
66697
  };
66302
- const hmrJsPath = join26(runtimeDir, "hmr-client.js");
66303
- const hmrTsPath = join26(runtimeDir, "hmr-client.ts");
66698
+ const hmrJsPath = join27(runtimeDir, "hmr-client.js");
66699
+ const hmrTsPath = join27(runtimeDir, "hmr-client.ts");
66304
66700
  const hmrClientPath = existsSync42(hmrJsPath) ? hmrJsPath : existsSync42(hmrTsPath) ? hmrTsPath : null;
66305
66701
  function extractCompName2(src2) {
66306
66702
  return resolveComponentName(src2);
@@ -66409,7 +66805,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66409
66805
  }
66410
66806
  if (url.pathname === "/_vesk/hmr" || url.pathname === "/_vesk/hmr.js") {
66411
66807
  if (hmrClientPath) {
66412
- let hmrContent = readFileSync38(hmrClientPath, "utf-8");
66808
+ let hmrContent = readFileSync40(hmrClientPath, "utf-8");
66413
66809
  if (hmrClientPath.endsWith(".ts")) {
66414
66810
  hmrContent = stripCodeTypes2(hmrContent);
66415
66811
  }
@@ -66457,10 +66853,10 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66457
66853
  }
66458
66854
  if (url.pathname !== "/") {
66459
66855
  const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
66460
- if (staticPath && existsSync42(staticPath) && statSync21(staticPath).isFile()) {
66856
+ if (staticPath && existsSync42(staticPath) && statSync22(staticPath).isFile()) {
66461
66857
  const ext = extname7(staticPath);
66462
66858
  res.writeHead(200, { "Content-Type": MIME2[ext] || "application/octet-stream" });
66463
- res.end(readFileSync38(staticPath));
66859
+ res.end(readFileSync40(staticPath));
66464
66860
  return;
66465
66861
  }
66466
66862
  }
@@ -66484,7 +66880,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66484
66880
  return;
66485
66881
  }
66486
66882
  const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
66487
- const apiDirPath = join26(appDirPath, "api");
66883
+ const apiDirPath = join27(appDirPath, "api");
66488
66884
  if (url.pathname.startsWith("/api") && existsSync42(apiDirPath)) {
66489
66885
  const apiRoutes = await scanApiRoutes(apiDirPath);
66490
66886
  const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
@@ -66563,7 +66959,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66563
66959
  const nfPath = resolve38(appDirPath, rootNode.sourceDir, "not-found.vsk");
66564
66960
  if (existsSync42(nfPath)) {
66565
66961
  try {
66566
- const nfSrc = readFileSync38(nfPath, "utf-8");
66962
+ const nfSrc = readFileSync40(nfPath, "utf-8");
66567
66963
  const nfCompName = extractCompName2(nfSrc) || rootNode.notFound;
66568
66964
  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() });
66569
66965
  } catch {
@@ -66618,7 +67014,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66618
67014
  const pageFilePath = resolve38(appDirPath, node.sourceDir, "page.vsk");
66619
67015
  const layoutFilePath = resolve38(appDirPath, node.sourceDir, "layout.vsk");
66620
67016
  if (i === chain.length - 1 && node.page && existsSync42(pageFilePath)) {
66621
- const src2 = readFileSync38(pageFilePath, "utf-8");
67017
+ const src2 = readFileSync40(pageFilePath, "utf-8");
66622
67018
  const compName = extractCompName2(src2) || node.page;
66623
67019
  const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, pageFilePath) });
66624
67020
  body = result.body;
@@ -66626,7 +67022,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
66626
67022
  props = result.props;
66627
67023
  }
66628
67024
  if (node.layout && existsSync42(layoutFilePath)) {
66629
- const src2 = readFileSync38(layoutFilePath, "utf-8");
67025
+ const src2 = readFileSync40(layoutFilePath, "utf-8");
66630
67026
  const compName = extractCompName2(src2) || node.layout;
66631
67027
  const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, layoutFilePath) });
66632
67028
  body = result.body;
@@ -66671,7 +67067,7 @@ ${prettifyHtml(body)}
66671
67067
  } else {
66672
67068
  const leaf2 = chain.find((n) => n.page);
66673
67069
  if (leaf2) {
66674
- const src2 = readFileSync38(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
67070
+ const src2 = readFileSync40(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
66675
67071
  const compName = extractCompName2(src2) || leaf2.page;
66676
67072
  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() });
66677
67073
  html = html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
@@ -66700,7 +67096,7 @@ ${prettifyHtml(body)}
66700
67096
  if (!hasLayout) {
66701
67097
  const leaf2 = chain.find((n) => n.page);
66702
67098
  if (leaf2) {
66703
- const src2 = readFileSync38(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
67099
+ const src2 = readFileSync40(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
66704
67100
  const compName = extractCompName2(src2) || leaf2.page;
66705
67101
  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() });
66706
67102
  } else {
@@ -66716,7 +67112,7 @@ ${prettifyHtml(body)}
66716
67112
  const pageFilePath = resolve38(appDirPath, node.sourceDir, "page.vsk");
66717
67113
  const layoutFilePath = resolve38(appDirPath, node.sourceDir, "layout.vsk");
66718
67114
  if (i === chain.length - 1 && node.page && existsSync42(pageFilePath)) {
66719
- const src2 = readFileSync38(pageFilePath, "utf-8");
67115
+ const src2 = readFileSync40(pageFilePath, "utf-8");
66720
67116
  const compName = extractCompName2(src2) || node.page;
66721
67117
  const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, pageFilePath) });
66722
67118
  body = result.body;
@@ -66724,7 +67120,7 @@ ${prettifyHtml(body)}
66724
67120
  props = result.props;
66725
67121
  }
66726
67122
  if (node.layout && existsSync42(layoutFilePath)) {
66727
- const src2 = readFileSync38(layoutFilePath, "utf-8");
67123
+ const src2 = readFileSync40(layoutFilePath, "utf-8");
66728
67124
  const compName = extractCompName2(src2) || node.layout;
66729
67125
  const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, layoutFilePath) });
66730
67126
  body = result.body;
@@ -66868,7 +67264,7 @@ ${prettifyHtml(body)}
66868
67264
  const nfPath = resolve38(appDirPath, node.sourceDir, "not-found.vsk");
66869
67265
  if (existsSync42(nfPath)) {
66870
67266
  try {
66871
- const nfSrc = readFileSync38(nfPath, "utf-8");
67267
+ const nfSrc = readFileSync40(nfPath, "utf-8");
66872
67268
  const nfCompName = extractCompName2(nfSrc) || node.notFound;
66873
67269
  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() });
66874
67270
  notFoundHtml = injectDevScripts(html);
@@ -66914,7 +67310,7 @@ ${prettifyHtml(body)}
66914
67310
  const errPath = resolve38(appDirPath, node.sourceDir, "error.vsk");
66915
67311
  if (existsSync42(errPath)) {
66916
67312
  try {
66917
- const errSrc = readFileSync38(errPath, "utf-8");
67313
+ const errSrc = readFileSync40(errPath, "utf-8");
66918
67314
  const errCompName = extractCompName2(errSrc) || node.error;
66919
67315
  const errProps = {
66920
67316
  error: err.message,
@@ -66986,7 +67382,7 @@ ${prettifyHtml(body)}
66986
67382
  LOG.ok(`dev server at http://localhost:${port} (listening on ${bindHost})`);
66987
67383
  const routes = collectRoutePaths(routeTree);
66988
67384
  const pageCount = countPages(routeTree);
66989
- const apiCount = countFilesNamed(join26(appDirPath, "api"), "route.ts");
67385
+ const apiCount = countFilesNamed(join27(appDirPath, "api"), "route.ts");
66990
67386
  LOG.info(`${projectDir}`);
66991
67387
  LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
66992
67388
  if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
@@ -67313,12 +67709,12 @@ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
67313
67709
  }
67314
67710
  function loadEnvFiles(projectDir) {
67315
67711
  const files = [
67316
- join30(projectDir, ".env"),
67317
- join30(projectDir, ".env.local")
67712
+ join31(projectDir, ".env"),
67713
+ join31(projectDir, ".env.local")
67318
67714
  ];
67319
67715
  for (const filePath of files) {
67320
67716
  if (!existsSync45(filePath)) continue;
67321
- const content = readFileSync42(filePath, "utf-8");
67717
+ const content = readFileSync44(filePath, "utf-8");
67322
67718
  for (const line of content.split("\n")) {
67323
67719
  const trimmed = line.trim();
67324
67720
  if (!trimmed || trimmed.startsWith("#")) continue;
@@ -67487,7 +67883,7 @@ if (cmd === "start") {
67487
67883
  if (cmd === "init") {
67488
67884
  const projectDir = process.cwd();
67489
67885
  const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
67490
- const target = join30(appDirPath, "global.css");
67886
+ const target = join31(appDirPath, "global.css");
67491
67887
  if (existsSync45(target)) {
67492
67888
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
67493
67889
  process.exit(0);
@@ -67508,7 +67904,7 @@ if (cmd === "migrate") {
67508
67904
  const projectDir = process.cwd();
67509
67905
  const { runMigrate: runMigrate2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
67510
67906
  const { CODEMODS: CODEMODS2 } = await Promise.resolve().then(() => (init_codemods(), codemods_exports));
67511
- const { version: cliVersion } = JSON.parse(readFileSync42(join30(__dirname10, "..", "package.json"), "utf-8"));
67907
+ const { version: cliVersion } = JSON.parse(readFileSync44(join31(__dirname10, "..", "package.json"), "utf-8"));
67512
67908
  if (args.includes("--list")) {
67513
67909
  console.error("vesk migrate: available codemods");
67514
67910
  for (const c of CODEMODS2) {