@vesk/vesk-cli 0.2.45 → 0.2.46

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 +280 -174
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -18608,6 +18608,13 @@ function preprocessForClauses(source) {
18608
18608
  function createBaseParser() {
18609
18609
  return Parser.extend(tsPlugin({}), VeskParserPlugin());
18610
18610
  }
18611
+ function parseGeneratedJs(source) {
18612
+ try {
18613
+ return parse3(source, { ecmaVersion: "latest", sourceType: "module" });
18614
+ } catch {
18615
+ return null;
18616
+ }
18617
+ }
18611
18618
  function parse4(source, options = {}) {
18612
18619
  const ParserClass = createBaseParser();
18613
18620
  const { code, annotations } = preprocessForClauses(blankComments(source));
@@ -33590,7 +33597,64 @@ __export(image_pipeline_exports, {
33590
33597
  });
33591
33598
  import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
33592
33599
  import { spawnSync } from "node:child_process";
33593
- import { resolve as resolve16, extname as extname5, dirname as dirname12 } from "node:path";
33600
+ import { resolve as resolve16, extname as extname5, dirname as dirname12, join as join12 } from "node:path";
33601
+ import { createRequire as createRequire5 } from "node:module";
33602
+ import { tmpdir as tmpdir2 } from "node:os";
33603
+ function probeMemoPath() {
33604
+ try {
33605
+ const req = createRequire5(import.meta.url);
33606
+ const entry = req.resolve("sharp");
33607
+ const stamp = Math.round(statSync9(entry).mtimeMs);
33608
+ return join12(tmpdir2(), `vesk-sharp-probe-${process.platform}-${process.arch}-${stamp}.json`);
33609
+ } catch {
33610
+ return null;
33611
+ }
33612
+ }
33613
+ function readProbeMemo() {
33614
+ const path = probeMemoPath();
33615
+ if (path === null)
33616
+ return null;
33617
+ try {
33618
+ return JSON.parse(readFileSync18(path, "utf-8"))?.usable === true;
33619
+ } catch {
33620
+ return null;
33621
+ }
33622
+ }
33623
+ function writeProbeMemo(usable) {
33624
+ const path = probeMemoPath();
33625
+ if (path === null)
33626
+ return;
33627
+ try {
33628
+ writeFileSync9(path, JSON.stringify({ usable, at: Date.now() }), "utf-8");
33629
+ } catch {
33630
+ }
33631
+ }
33632
+ async function ensureSharp() {
33633
+ if (sharpProbed)
33634
+ return;
33635
+ sharpProbed = true;
33636
+ const memo = readProbeMemo();
33637
+ if (memo === false) {
33638
+ console.warn("vesk images: sharp unusable on this machine (cached); using copy-only image pipeline");
33639
+ return;
33640
+ }
33641
+ try {
33642
+ const probe = spawnSync(process.execPath, [
33643
+ "--input-type=module",
33644
+ "-e",
33645
+ "import sharp from 'sharp'; await sharp({ create: { width: 2, height: 2, channels: 3, background: 'red' } }).png().toBuffer();"
33646
+ ], { stdio: "ignore" });
33647
+ if (probe.status === 0) {
33648
+ const mod = await import("sharp");
33649
+ sharpFn = mod.default;
33650
+ writeProbeMemo(true);
33651
+ } else {
33652
+ console.warn("vesk images: sharp native probe failed; using copy-only image pipeline");
33653
+ writeProbeMemo(false);
33654
+ }
33655
+ } catch {
33656
+ }
33657
+ }
33594
33658
  async function processImage(srcPath, outDir, baseName) {
33595
33659
  const image = sharpFn ? sharpFn(srcPath) : null;
33596
33660
  if (!image) {
@@ -33659,13 +33723,15 @@ async function optimizeImages(appDir, outDir) {
33659
33723
  console.error("vesk images: no <Image> refs found");
33660
33724
  return [];
33661
33725
  }
33726
+ await ensureSharp();
33662
33727
  const results = [];
33663
33728
  for (const ref2 of refs) {
33729
+ const rel = ref2.src.replace(/^\//, "");
33664
33730
  const possiblePaths = [
33665
- resolve16(appDir, ref2.src),
33666
- resolve16(appDir, "..", "public", ref2.src.replace(/^\//, "")),
33667
- resolve16(appDir, "..", "src", ref2.src.replace(/^\//, "")),
33668
- resolve16(outDir, "static", "public", ref2.src.replace(/^\//, ""))
33731
+ resolve16(appDir, rel),
33732
+ resolve16(appDir, "..", "public", rel),
33733
+ resolve16(appDir, "..", "src", rel),
33734
+ resolve16(outDir, "static", "public", rel)
33669
33735
  ];
33670
33736
  let srcPath = null;
33671
33737
  for (const p of possiblePaths) {
@@ -33695,28 +33761,15 @@ async function optimizeImages(appDir, outDir) {
33695
33761
  }
33696
33762
  return results;
33697
33763
  }
33698
- var SUPPORTED, OUTPUT_WIDTHS, FORMATS, sharpFn;
33764
+ var SUPPORTED, OUTPUT_WIDTHS, FORMATS, sharpFn, sharpProbed;
33699
33765
  var init_image_pipeline = __esm({
33700
- async "../adapter/dist/image-pipeline.js"() {
33766
+ "../adapter/dist/image-pipeline.js"() {
33701
33767
  "use strict";
33702
33768
  SUPPORTED = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png", ".webp", ".avif", ".tiff"]);
33703
33769
  OUTPUT_WIDTHS = [640, 768, 1024, 1280, 1536];
33704
33770
  FORMATS = ["webp", "avif"];
33705
33771
  sharpFn = null;
33706
- try {
33707
- const probe = spawnSync(process.execPath, [
33708
- "--input-type=module",
33709
- "-e",
33710
- "import sharp from 'sharp'; await sharp({ create: { width: 2, height: 2, channels: 3, background: 'red' } }).png().toBuffer();"
33711
- ], { stdio: "ignore" });
33712
- if (probe.status === 0) {
33713
- const mod = await import("sharp");
33714
- sharpFn = mod.default;
33715
- } else {
33716
- console.warn("vesk images: sharp native probe failed; using copy-only image pipeline");
33717
- }
33718
- } catch {
33719
- }
33772
+ sharpProbed = false;
33720
33773
  }
33721
33774
  });
33722
33775
 
@@ -33930,7 +33983,7 @@ var init_platform = __esm({
33930
33983
 
33931
33984
  // ../adapter/src/platform-handler.ts
33932
33985
  import { existsSync as existsSync20 } from "node:fs";
33933
- import { resolve as resolve18, dirname as dirname13, join as join12 } from "node:path";
33986
+ import { resolve as resolve18, dirname as dirname13, join as join13 } from "node:path";
33934
33987
  import { fileURLToPath as fileURLToPath4 } from "node:url";
33935
33988
  function routeName2(segments) {
33936
33989
  const parts = segments.filter(Boolean).map((s) => {
@@ -33953,8 +34006,8 @@ function findCompilerSrc2(appDir) {
33953
34006
  resolve18(appDir, "node_modules", "@vesk/compiler")
33954
34007
  ];
33955
34008
  for (const base of candidates) {
33956
- for (const dir of [base, join12(base, "dist")]) {
33957
- if (existsSync20(join12(dir, "server-cookies.js"))) return dir;
34009
+ for (const dir of [base, join13(base, "dist")]) {
34010
+ if (existsSync20(join13(dir, "server-cookies.js"))) return dir;
33958
34011
  }
33959
34012
  }
33960
34013
  throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
@@ -34237,7 +34290,7 @@ import {
34237
34290
  rmSync as rmSync2,
34238
34291
  readFileSync as readFileSync20
34239
34292
  } from "node:fs";
34240
- import { resolve as resolve19, join as join13, extname as extname6, dirname as dirname14 } from "node:path";
34293
+ import { resolve as resolve19, join as join14, extname as extname6, dirname as dirname14 } from "node:path";
34241
34294
  function ensureCleanDir(dir) {
34242
34295
  rmSync2(dir, { recursive: true, force: true });
34243
34296
  mkdirSync9(dir, { recursive: true });
@@ -34246,8 +34299,8 @@ function copyDirContents(srcDir, destDir) {
34246
34299
  if (!existsSync21(srcDir)) return;
34247
34300
  mkdirSync9(destDir, { recursive: true });
34248
34301
  for (const entry of readdirSync6(srcDir)) {
34249
- const srcPath = join13(srcDir, entry);
34250
- const destPath = join13(destDir, entry);
34302
+ const srcPath = join14(srcDir, entry);
34303
+ const destPath = join14(destDir, entry);
34251
34304
  if (statSync11(srcPath).isDirectory()) {
34252
34305
  copyDirContents(srcPath, destPath);
34253
34306
  } else {
@@ -34293,7 +34346,7 @@ function listStaticDir(dir) {
34293
34346
  if (!existsSync21(dir)) return out;
34294
34347
  function walk7(d, prefix) {
34295
34348
  for (const entry of readdirSync6(d)) {
34296
- const full = join13(d, entry);
34349
+ const full = join14(d, entry);
34297
34350
  const rel = prefix ? `${prefix}/${entry}` : entry;
34298
34351
  if (statSync11(full).isDirectory()) {
34299
34352
  walk7(full, rel);
@@ -38964,7 +39017,7 @@ __export(typecheck_exports, {
38964
39017
  typecheckProject: () => typecheckProject
38965
39018
  });
38966
39019
  import { readFileSync as readFileSync39, readdirSync as readdirSync14, statSync as statSync22 } from "node:fs";
38967
- import { join as join25, dirname as dirname27, normalize, relative as relative8, resolve as resolve39, sep as sep7 } from "node:path";
39020
+ import { join as join26, dirname as dirname27, normalize, relative as relative8, resolve as resolve39, sep as sep7 } from "node:path";
38968
39021
  import * as ts8 from "typescript";
38969
39022
  function walkProjectFiles(projectRoot) {
38970
39023
  const code = [];
@@ -38977,7 +39030,7 @@ function walkProjectFiles(projectRoot) {
38977
39030
  return;
38978
39031
  }
38979
39032
  for (const e of entries) {
38980
- const p = join25(dir, e);
39033
+ const p = join26(dir, e);
38981
39034
  let st;
38982
39035
  try {
38983
39036
  st = statSync22(p);
@@ -39032,8 +39085,8 @@ function checkStructureFile(appDir, file) {
39032
39085
  return null;
39033
39086
  }
39034
39087
  function createTypecheckHost(projectRoot, appDir, vskFiles) {
39035
- const ambientPath = join25(appDir, "__vesk_ambient.d.ts");
39036
- const overridePath = join25(appDir, "__vesk_runtime_override.d.ts");
39088
+ const ambientPath = join26(appDir, "__vesk_ambient.d.ts");
39089
+ const overridePath = join26(appDir, "__vesk_runtime_override.d.ts");
39037
39090
  const cached = /* @__PURE__ */ new Map();
39038
39091
  const scriptKindFor = (file) => file.endsWith(".vsk") ? ts8.ScriptKind.TSX : ts8.ScriptKind.TS;
39039
39092
  const host = {
@@ -39103,7 +39156,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39103
39156
  directoryExists: (dir) => ts8.sys.directoryExists(dir),
39104
39157
  getDirectories: (dir) => {
39105
39158
  try {
39106
- return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join25(dir, d.name));
39159
+ return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join26(dir, d.name));
39107
39160
  } catch {
39108
39161
  return [];
39109
39162
  }
@@ -39115,7 +39168,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39115
39168
  return moduleLiterals.map(({ text }) => {
39116
39169
  if (text.endsWith(".vsk")) {
39117
39170
  const aliased = text.startsWith(".") ? null : resolveAliasModule(text, dirname27(containingFile));
39118
- const abs = normalize(aliased ?? join25(dirname27(containingFile), text));
39171
+ const abs = normalize(aliased ?? join26(dirname27(containingFile), text));
39119
39172
  return {
39120
39173
  resolvedModule: {
39121
39174
  resolvedFileName: abs + ".d.ts",
@@ -39126,7 +39179,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39126
39179
  };
39127
39180
  }
39128
39181
  if (text.endsWith(".css")) {
39129
- const abs = normalize(join25(dirname27(containingFile), text));
39182
+ const abs = normalize(join26(dirname27(containingFile), text));
39130
39183
  return {
39131
39184
  resolvedModule: {
39132
39185
  resolvedFileName: abs + ".d.ts",
@@ -39173,7 +39226,7 @@ function sourcePosition(source, offset2) {
39173
39226
  return { line, character: bounded - lineStart + 1 };
39174
39227
  }
39175
39228
  function typecheckProject(projectRoot, opts = {}) {
39176
- const appDir = opts.appDir ?? join25(projectRoot, "app");
39229
+ const appDir = opts.appDir ?? join26(projectRoot, "app");
39177
39230
  const vskFiles = /* @__PURE__ */ new Map();
39178
39231
  const parseErrors = [];
39179
39232
  const warnings = [];
@@ -39212,8 +39265,8 @@ function typecheckProject(projectRoot, opts = {}) {
39212
39265
  }
39213
39266
  rootNames.push(f);
39214
39267
  }
39215
- const ambientPath = join25(appDir, "__vesk_ambient.d.ts");
39216
- const overridePath = join25(appDir, "__vesk_runtime_override.d.ts");
39268
+ const ambientPath = join26(appDir, "__vesk_ambient.d.ts");
39269
+ const overridePath = join26(appDir, "__vesk_runtime_override.d.ts");
39217
39270
  rootNames.push(ambientPath);
39218
39271
  rootNames.push(overridePath);
39219
39272
  const options = {
@@ -39841,7 +39894,7 @@ declare module '@vesk/runtime' {
39841
39894
 
39842
39895
  // src/index.ts
39843
39896
  import { readFileSync as readFileSync40, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, existsSync as existsSync43 } from "fs";
39844
- import { resolve as resolve40, join as join26 } from "path";
39897
+ import { resolve as resolve40, join as join27 } from "path";
39845
39898
  import { fileURLToPath as fileURLToPath9 } from "url";
39846
39899
 
39847
39900
  // ../adapter/dist/load-config.js
@@ -40688,8 +40741,15 @@ init_module_imports();
40688
40741
  import { readFileSync as readFileSync4 } from "node:fs";
40689
40742
  import { dirname as dirname6 } from "node:path";
40690
40743
  function precompileFile(source, sourcePath2) {
40691
- return precompileFileInternal(source, sourcePath2, /* @__PURE__ */ new Set());
40692
- }
40744
+ if (sourcePath2 === void 0) return precompileFileInternal(source, sourcePath2, /* @__PURE__ */ new Set());
40745
+ const hit = precompileCache.get(sourcePath2);
40746
+ if (hit !== void 0 && hit.source === source) return hit.plan;
40747
+ const plan = precompileFileInternal(source, sourcePath2, /* @__PURE__ */ new Set());
40748
+ if (precompileCache.size >= 512) precompileCache.clear();
40749
+ precompileCache.set(sourcePath2, { source, plan });
40750
+ return plan;
40751
+ }
40752
+ var precompileCache = /* @__PURE__ */ new Map();
40693
40753
  function precompileFileInternal(source, sourcePath2, seenImportFiles) {
40694
40754
  if (sourcePath2) {
40695
40755
  const dir = dirname6(sourcePath2);
@@ -41792,12 +41852,8 @@ function findRuntimeSrc2(appDir) {
41792
41852
  }
41793
41853
  function extractRuntimeImportNames(code) {
41794
41854
  const names = [];
41795
- let ast;
41796
- try {
41797
- ast = parse4(code);
41798
- } catch {
41799
- return names;
41800
- }
41855
+ const ast = parseForStrip(code);
41856
+ if (!ast) return names;
41801
41857
  const body = ast.body ?? [];
41802
41858
  for (const raw2 of body) {
41803
41859
  const node = raw2;
@@ -42065,12 +42121,8 @@ function scopeFileContribution(code) {
42065
42121
  }
42066
42122
  }
42067
42123
  function stripAndDemoteInOnePass(code) {
42068
- let ast;
42069
- try {
42070
- ast = parse4(code);
42071
- } catch {
42072
- return code;
42073
- }
42124
+ const ast = parseForStrip(code);
42125
+ if (!ast) return code;
42074
42126
  const body = ast.body ?? [];
42075
42127
  const edits = [];
42076
42128
  for (const raw2 of body) {
@@ -42104,20 +42156,28 @@ function buildHmrEvalSnippet(code) {
42104
42156
  const scoped = `{
42105
42157
  ${body}
42106
42158
  }`;
42107
- try {
42108
- parse4(scoped);
42109
- return scoped;
42110
- } catch {
42111
- return body;
42159
+ return parseGeneratedJs(scoped) !== null ? scoped : body;
42160
+ }
42161
+ var stripAstCache = /* @__PURE__ */ new Map();
42162
+ var STRIP_AST_CACHE_MAX = 512;
42163
+ function parseForStrip(code) {
42164
+ const hit = stripAstCache.get(code);
42165
+ if (hit !== void 0) return hit;
42166
+ let ast = parseGeneratedJs(code);
42167
+ if (!ast) {
42168
+ try {
42169
+ ast = parse4(code);
42170
+ } catch {
42171
+ ast = null;
42172
+ }
42112
42173
  }
42174
+ if (stripAstCache.size >= STRIP_AST_CACHE_MAX) stripAstCache.clear();
42175
+ stripAstCache.set(code, ast);
42176
+ return ast;
42113
42177
  }
42114
42178
  function removeCompiledNodes(code, isTarget) {
42115
- let ast;
42116
- try {
42117
- ast = parse4(code);
42118
- } catch {
42119
- return code;
42120
- }
42179
+ const ast = parseForStrip(code);
42180
+ if (!ast) return code;
42121
42181
  const ranges = [];
42122
42182
  for (const raw2 of ast.body ?? []) {
42123
42183
  const node = raw2;
@@ -42139,6 +42199,7 @@ function removeCompiledNodes(code, isTarget) {
42139
42199
  async function generateClientBundle(routeTree, appDir, componentMap, options) {
42140
42200
  const runtimeDir = findRuntimeSrc2(appDir);
42141
42201
  let seen = /* @__PURE__ */ new Set();
42202
+ const __stats = { chunks: 0, compiled: 0, distinct: /* @__PURE__ */ new Set(), parseMs: 0 };
42142
42203
  const chunks = [];
42143
42204
  const runtimeImportNames = /* @__PURE__ */ new Set();
42144
42205
  const cache2 = options?.cache;
@@ -42222,13 +42283,17 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
42222
42283
  return;
42223
42284
  }
42224
42285
  compiledFiles++;
42286
+ __stats.compiled++;
42287
+ __stats.distinct.add(filePath);
42225
42288
  let src2 = readFileSync11(filePath, "utf-8");
42226
42289
  if (/content=["'][^"']*\.md["']/i.test(src2)) {
42227
42290
  src2 = inlineMdContentAttrs(src2, dirname8(filePath), guessProjectRoots(appDir));
42228
42291
  }
42229
42292
  const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
42230
42293
  const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
42294
+ const __p0 = performance.now();
42231
42295
  const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths, componentNames } = compileClientBoth(src2, null, filePath);
42296
+ __stats.parseMs += performance.now() - __p0;
42232
42297
  for (const cn of componentNames || []) componentOwners.claim(cn, filePath);
42233
42298
  const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
42234
42299
  const hydWithImports = rawHyd ? stripExports(stripVskImports(stripRuntimeImport(rawHyd))) : "";
@@ -42419,6 +42484,7 @@ ${entry.code}
42419
42484
  transformedChunks.push({ ...chunk, code: await applyTransformPlugins(chunk.code, chunk.name) });
42420
42485
  }
42421
42486
  componentOwners.report("client bundle");
42487
+ if (process.env.VESK_BUILD_PROFILE) console.error(` [client] chunks=${chunks.length} compiled=${__stats.compiled} distinct=${__stats.distinct.size} parseMs=${__stats.parseMs.toFixed(0)}`);
42422
42488
  return { main: await applyTransformPlugins(main, "client.js"), chunks: transformedChunks, cachedFileHits, compiledFiles, mainFromCache, editedSources, editedNames };
42423
42489
  } else {
42424
42490
  let compileFileMono2 = function(filePath, resolvedName) {
@@ -43402,7 +43468,24 @@ async function collectPluginHeadExtra(pluginsPipelines) {
43402
43468
  }
43403
43469
  return parts.join("\n");
43404
43470
  }
43471
+ var profileEnabled = () => process.env.VESK_BUILD_PROFILE === "1";
43472
+ var phaseMarks = [];
43473
+ var phaseStarted = 0;
43474
+ var buildStarted = 0;
43475
+ function markPhase(name) {
43476
+ if (!profileEnabled())
43477
+ return;
43478
+ const now2 = performance.now();
43479
+ if (phaseStarted > 0)
43480
+ phaseMarks.push([name, now2 - phaseStarted]);
43481
+ phaseStarted = now2;
43482
+ }
43405
43483
  async function build2(appDir, options) {
43484
+ if (profileEnabled()) {
43485
+ buildStarted = Date.now();
43486
+ phaseMarks = [];
43487
+ phaseStarted = performance.now();
43488
+ }
43406
43489
  appDir = resolve21(appDir);
43407
43490
  const outDir = resolve21(options?.outDir || resolve21(appDir, "..", ".vesk"));
43408
43491
  const publicDir = options?.publicDir || resolve21(appDir, "..", "public");
@@ -43452,6 +43535,7 @@ async function build2(appDir, options) {
43452
43535
  ];
43453
43536
  for (const d of dirs)
43454
43537
  mkdirSync11(d, { recursive: true });
43538
+ markPhase("config+dirs");
43455
43539
  const cssSourcePath = resolveUserCssPath(appDir);
43456
43540
  if (cssSourcePath !== null) {
43457
43541
  const cssContent = readFileSync21(cssSourcePath, "utf-8");
@@ -43475,6 +43559,7 @@ async function build2(appDir, options) {
43475
43559
  console.error(`vesk build: css \u2192 static/global.css (${finalCss.length} bytes, tailwind plugin inactive)`);
43476
43560
  }
43477
43561
  }
43562
+ markPhase("css/tailwind");
43478
43563
  const { scanRoutes: scanRoutes2, scanComponents: scanComponents2 } = await resolveCompilerApi("router.js");
43479
43564
  const { scanApiRoutes: scanApiRoutes2 } = await resolveCompilerApi("api-routes.js");
43480
43565
  const { collectMiddlewareChain: collectMiddlewareChain2 } = await resolveCompilerApi("middleware.js");
@@ -43492,6 +43577,7 @@ async function build2(appDir, options) {
43492
43577
  const apiDir = resolve21(appDir, "api");
43493
43578
  const apiTree = existsSync22(apiDir) ? scanApiRoutes2(apiDir) : [];
43494
43579
  console.error(`vesk build: ${routeTree.length} root routes, ${apiTree.length} API routes`);
43580
+ markPhase("scan routes");
43495
43581
  console.error("vesk build: bundling server runtime...");
43496
43582
  await bundleRuntime(appDir, outDir);
43497
43583
  const ssrRoutes = [];
@@ -43544,6 +43630,7 @@ async function build2(appDir, options) {
43544
43630
  }
43545
43631
  }
43546
43632
  walk7(routeTree);
43633
+ markPhase("server runtime + ssr functions");
43547
43634
  const apiRoutes = [];
43548
43635
  function walkApi(nodes) {
43549
43636
  for (const node of nodes) {
@@ -43570,6 +43657,7 @@ async function build2(appDir, options) {
43570
43657
  const hasEvents = await compileEvents(appDir, outDir);
43571
43658
  if (hasEvents)
43572
43659
  console.error("vesk build: evt \u2192 server/events.js (onStart/onRequest/onStop)");
43660
+ markPhase("api functions");
43573
43661
  console.error("vesk build: bundling client runtime...");
43574
43662
  const bundleOpts = {};
43575
43663
  if (options?.codeSplit)
@@ -43592,6 +43680,7 @@ async function build2(appDir, options) {
43592
43680
  }
43593
43681
  }
43594
43682
  copyStaticAssets(publicDir, outDir);
43683
+ markPhase("client runtime + chunks");
43595
43684
  console.error("vesk build: static \u2192 static/public/");
43596
43685
  let prerenderedRoutes = [];
43597
43686
  if (options?.ssg) {
@@ -43603,7 +43692,7 @@ async function build2(appDir, options) {
43603
43692
  console.error(`vesk build: ssg \u2192 prerendered/ (${prerenderedRoutes.length} pages)`);
43604
43693
  }
43605
43694
  {
43606
- const { optimizeImages: optimizeImages2 } = await init_image_pipeline().then(() => image_pipeline_exports);
43695
+ const { optimizeImages: optimizeImages2 } = await Promise.resolve().then(() => (init_image_pipeline(), image_pipeline_exports));
43607
43696
  await optimizeImages2(appDir, outDir);
43608
43697
  }
43609
43698
  if (options?.seo) {
@@ -43613,10 +43702,6 @@ async function build2(appDir, options) {
43613
43702
  throw new Error(`SEO audit failed with ${audit.errors} error(s) \u2014 fix them before deploying`);
43614
43703
  }
43615
43704
  }
43616
- {
43617
- const { optimizeImages: optimizeImages2 } = await init_image_pipeline().then(() => image_pipeline_exports);
43618
- await optimizeImages2(appDir, outDir);
43619
- }
43620
43705
  {
43621
43706
  const { generateSitemap: generateSitemap2, generateRobotsTxt: generateRobotsTxt2 } = await Promise.resolve().then(() => (init_static(), static_exports));
43622
43707
  const publicDirResolved = resolve21(outDir, "static", "public");
@@ -43634,6 +43719,7 @@ async function build2(appDir, options) {
43634
43719
  console.error(`vesk build: seo \u2192 static/public/robots.txt (${robots.length} bytes)`);
43635
43720
  }
43636
43721
  }
43722
+ markPhase("ssg+images+seo");
43637
43723
  const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap, pluginHeadExtra, hasEvents);
43638
43724
  writeFileSync12(resolve21(outDir, "config.json"), JSON.stringify(manifest, null, 2) + "\n", "utf-8");
43639
43725
  console.error("vesk build: config \u2192 config.json");
@@ -43666,6 +43752,14 @@ async function build2(appDir, options) {
43666
43752
  await plugin.onBuildEnd();
43667
43753
  }
43668
43754
  }
43755
+ markPhase("manifest+platform");
43756
+ markPhase("tail");
43757
+ if (profileEnabled()) {
43758
+ for (const [name, ms] of phaseMarks) {
43759
+ console.error(` phase ${name.padEnd(30)} ${ms.toFixed(0).padStart(6)}ms`);
43760
+ }
43761
+ console.error(` TOTAL ${(Date.now() - buildStarted).toFixed(0)}ms`);
43762
+ }
43669
43763
  console.error(`
43670
43764
  vesk build: done (${outDir})`);
43671
43765
  return { routeTree, apiTree, ssrRoutes, apiRoutes, manifest };
@@ -43676,7 +43770,7 @@ init_seo_audit();
43676
43770
 
43677
43771
  // src/dev-server.ts
43678
43772
  import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, readdirSync as readdirSync13 } from "node:fs";
43679
- import { resolve as resolve38, extname as extname8, join as join24, dirname as dirname26 } from "node:path";
43773
+ import { resolve as resolve38, extname as extname8, join as join25, dirname as dirname26 } from "node:path";
43680
43774
  import { createServer as createServer2 } from "node:http";
43681
43775
  import { WebSocketServer as WebSocketServer2 } from "ws";
43682
43776
 
@@ -46326,7 +46420,7 @@ init_tokens();
46326
46420
  init_scan();
46327
46421
  init_strip_ts();
46328
46422
  import { readdirSync as readdirSync7, statSync as statSync12, existsSync as existsSync23, readFileSync as readFileSync22 } from "fs";
46329
- import { join as join14, relative as relative5, basename as basename3 } from "path";
46423
+ import { join as join15, relative as relative5, basename as basename3 } from "path";
46330
46424
  function collapseSlashes2(p) {
46331
46425
  let out = "";
46332
46426
  let prevSlash = false;
@@ -46429,7 +46523,7 @@ function scanComponents(componentsDir) {
46429
46523
  return;
46430
46524
  }
46431
46525
  for (const entry of entries) {
46432
- const full = join14(dir, entry);
46526
+ const full = join15(dir, entry);
46433
46527
  let stat;
46434
46528
  try {
46435
46529
  stat = statSync12(full);
@@ -46530,7 +46624,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
46530
46624
  seg = segName;
46531
46625
  }
46532
46626
  const fullPath = seg ? (parentPath === "/" ? "/" : parentPath + "/") + seg : parentPath || "/";
46533
- const isStandalone = hasLayout ? isStandaloneLayoutFile(join14(dir, "layout.vsk")) : false;
46627
+ const isStandalone = hasLayout ? isStandaloneLayoutFile(join15(dir, "layout.vsk")) : false;
46534
46628
  const node = {
46535
46629
  path: seg,
46536
46630
  fullPath: collapseSlashes2(fullPath) || "/",
@@ -46551,7 +46645,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
46551
46645
  standalone: isStandalone ? true : void 0
46552
46646
  };
46553
46647
  for (const entry of entries) {
46554
- const entryPath = join14(dir, entry);
46648
+ const entryPath = join15(dir, entry);
46555
46649
  let entryStat;
46556
46650
  try {
46557
46651
  entryStat = statSync12(entryPath);
@@ -46603,19 +46697,19 @@ function collectSources(tree) {
46603
46697
  function walk7(nodes) {
46604
46698
  for (const node of nodes) {
46605
46699
  if (node.page)
46606
- map.set(node.page, join14(node.sourceDir, "page.vsk"));
46700
+ map.set(node.page, join15(node.sourceDir, "page.vsk"));
46607
46701
  if (node.layout)
46608
- map.set(node.layout, join14(node.sourceDir, "layout.vsk"));
46702
+ map.set(node.layout, join15(node.sourceDir, "layout.vsk"));
46609
46703
  if (node.loading)
46610
- map.set(node.loading, join14(node.sourceDir, "loading.vsk"));
46704
+ map.set(node.loading, join15(node.sourceDir, "loading.vsk"));
46611
46705
  if (node.error)
46612
- map.set(node.error, join14(node.sourceDir, "error.vsk"));
46706
+ map.set(node.error, join15(node.sourceDir, "error.vsk"));
46613
46707
  if (node.notFound)
46614
- map.set(node.notFound, join14(node.sourceDir, "not-found.vsk"));
46708
+ map.set(node.notFound, join15(node.sourceDir, "not-found.vsk"));
46615
46709
  if (node.offline)
46616
- map.set(node.offline, join14(node.sourceDir, "offline.vsk"));
46710
+ map.set(node.offline, join15(node.sourceDir, "offline.vsk"));
46617
46711
  if (node.network)
46618
- map.set(node.network, join14(node.sourceDir, "network.vsk"));
46712
+ map.set(node.network, join15(node.sourceDir, "network.vsk"));
46619
46713
  walk7(node.children);
46620
46714
  }
46621
46715
  }
@@ -46717,7 +46811,7 @@ function matchUrl(tree, pathname) {
46717
46811
 
46718
46812
  // ../compiler/dist/api-routes.js
46719
46813
  import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync24 } from "fs";
46720
- import { join as join15 } from "path";
46814
+ import { join as join16 } from "path";
46721
46815
  init_server_utils();
46722
46816
  function basename4(p) {
46723
46817
  const idx = p.lastIndexOf("/");
@@ -46754,7 +46848,7 @@ function scanApiDir(rootDir, dir, parentPath) {
46754
46848
  return nodes;
46755
46849
  if (isRouteGroup) {
46756
46850
  for (const entry of entries) {
46757
- const entryPath = join15(dir, entry);
46851
+ const entryPath = join16(dir, entry);
46758
46852
  let entryStat;
46759
46853
  try {
46760
46854
  entryStat = statSync13(entryPath);
@@ -46784,11 +46878,11 @@ function scanApiDir(rootDir, dir, parentPath) {
46784
46878
  fullPath: collapseSlashes(fullPath) || "/",
46785
46879
  isDynamic,
46786
46880
  isCatchAll,
46787
- filePath: hasRoute && routeFileName ? join15(dir, routeFileName) : null,
46881
+ filePath: hasRoute && routeFileName ? join16(dir, routeFileName) : null,
46788
46882
  children: []
46789
46883
  };
46790
46884
  for (const entry of entries) {
46791
- const entryPath = join15(dir, entry);
46885
+ const entryPath = join16(dir, entry);
46792
46886
  let entryStat;
46793
46887
  try {
46794
46888
  entryStat = statSync13(entryPath);
@@ -47318,11 +47412,11 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
47318
47412
 
47319
47413
  // ../compiler/dist/events.js
47320
47414
  import { existsSync as existsSync26 } from "fs";
47321
- import { join as join16 } from "path";
47415
+ import { join as join17 } from "path";
47322
47416
  var EVENTS_FILE_NAMES2 = ["_events.ts", "_events.js"];
47323
47417
  function collectEventsFile2(appDir) {
47324
47418
  for (const name of EVENTS_FILE_NAMES2) {
47325
- const candidate = join16(appDir, name);
47419
+ const candidate = join17(appDir, name);
47326
47420
  if (existsSync26(candidate))
47327
47421
  return candidate;
47328
47422
  }
@@ -47354,7 +47448,7 @@ async function runEventHandlers(handlers, name, ctx2) {
47354
47448
 
47355
47449
  // ../compiler/dist/md-inline.js
47356
47450
  import { readFileSync as readFileSync23, existsSync as existsSync27 } from "node:fs";
47357
- import { dirname as dirname17, join as join17, resolve as resolve23 } from "node:path";
47451
+ import { dirname as dirname17, join as join18, resolve as resolve23 } from "node:path";
47358
47452
  var MD_EXT_MARKER2 = ".md";
47359
47453
  function looksLikeMarkdownPath2(value) {
47360
47454
  const v = value.trim();
@@ -47431,10 +47525,10 @@ function resolveMdPath2(specifier, importerDir, roots) {
47431
47525
  }
47432
47526
  if (spec.startsWith("/")) {
47433
47527
  for (const root3 of roots) {
47434
- const pub = join17(root3, "public", spec);
47528
+ const pub = join18(root3, "public", spec);
47435
47529
  if (existsSync27(pub))
47436
47530
  return pub;
47437
- const direct = join17(root3, spec);
47531
+ const direct = join18(root3, spec);
47438
47532
  if (existsSync27(direct))
47439
47533
  return direct;
47440
47534
  }
@@ -47448,7 +47542,7 @@ function guessProjectRoots2(dir) {
47448
47542
  let cur = dir;
47449
47543
  for (let i = 0; i < 6; i++) {
47450
47544
  roots.push(cur);
47451
- if (existsSync27(join17(cur, "package.json")))
47545
+ if (existsSync27(join18(cur, "package.json")))
47452
47546
  break;
47453
47547
  const parent = dirname17(cur);
47454
47548
  if (parent === cur)
@@ -47460,9 +47554,9 @@ function guessProjectRoots2(dir) {
47460
47554
 
47461
47555
  // ../adapter/dist/client-bundle.js
47462
47556
  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";
47463
- import { resolve as resolve24, join as join18, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
47557
+ import { resolve as resolve24, join as join19, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
47464
47558
  import { fileURLToPath as fileURLToPath6 } from "node:url";
47465
- import { tmpdir as tmpdir2 } from "node:os";
47559
+ import { tmpdir as tmpdir3 } from "node:os";
47466
47560
 
47467
47561
  // ../adapter/dist/esbuild-fallback.js
47468
47562
  var _nativeBuild2 = null;
@@ -47543,8 +47637,8 @@ function findRuntimeSrc3(appDir) {
47543
47637
  resolve24(appDir, "node_modules", "@vesk/runtime")
47544
47638
  ];
47545
47639
  for (const base of candidates) {
47546
- for (const dir of [base, join18(base, "dist")]) {
47547
- if (existsSync28(join18(dir, "index-client.js")))
47640
+ for (const dir of [base, join19(base, "dist")]) {
47641
+ if (existsSync28(join19(dir, "index-client.js")))
47548
47642
  return dir;
47549
47643
  }
47550
47644
  }
@@ -47552,12 +47646,9 @@ function findRuntimeSrc3(appDir) {
47552
47646
  }
47553
47647
  function extractRuntimeImportNames2(code) {
47554
47648
  const names = [];
47555
- let ast;
47556
- try {
47557
- ast = parse4(code);
47558
- } catch {
47649
+ const ast = parseForStrip2(code);
47650
+ if (!ast)
47559
47651
  return names;
47560
- }
47561
47652
  const body = ast.body ?? [];
47562
47653
  for (const raw2 of body) {
47563
47654
  const node = raw2;
@@ -47854,12 +47945,9 @@ function scopeFileContribution2(code) {
47854
47945
  }
47855
47946
  }
47856
47947
  function stripAndDemoteInOnePass2(code) {
47857
- let ast;
47858
- try {
47859
- ast = parse4(code);
47860
- } catch {
47948
+ const ast = parseForStrip2(code);
47949
+ if (!ast)
47861
47950
  return code;
47862
- }
47863
47951
  const body = ast.body ?? [];
47864
47952
  const edits = [];
47865
47953
  for (const raw2 of body) {
@@ -47900,20 +47988,31 @@ function buildHmrEvalSnippet2(code) {
47900
47988
  const scoped = `{
47901
47989
  ${body}
47902
47990
  }`;
47903
- try {
47904
- parse4(scoped);
47905
- return scoped;
47906
- } catch {
47907
- return body;
47991
+ return parseGeneratedJs(scoped) !== null ? scoped : body;
47992
+ }
47993
+ var stripAstCache2 = /* @__PURE__ */ new Map();
47994
+ var STRIP_AST_CACHE_MAX2 = 512;
47995
+ function parseForStrip2(code) {
47996
+ const hit = stripAstCache2.get(code);
47997
+ if (hit !== void 0)
47998
+ return hit;
47999
+ let ast = parseGeneratedJs(code);
48000
+ if (!ast) {
48001
+ try {
48002
+ ast = parse4(code);
48003
+ } catch {
48004
+ ast = null;
48005
+ }
47908
48006
  }
48007
+ if (stripAstCache2.size >= STRIP_AST_CACHE_MAX2)
48008
+ stripAstCache2.clear();
48009
+ stripAstCache2.set(code, ast);
48010
+ return ast;
47909
48011
  }
47910
48012
  function removeCompiledNodes2(code, isTarget) {
47911
- let ast;
47912
- try {
47913
- ast = parse4(code);
47914
- } catch {
48013
+ const ast = parseForStrip2(code);
48014
+ if (!ast)
47915
48015
  return code;
47916
- }
47917
48016
  const ranges = [];
47918
48017
  for (const raw2 of ast.body ?? []) {
47919
48018
  const node = raw2;
@@ -47939,6 +48038,7 @@ function removeCompiledNodes2(code, isTarget) {
47939
48038
  async function generateClientBundle2(routeTree, appDir, componentMap, options) {
47940
48039
  const runtimeDir = findRuntimeSrc3(appDir);
47941
48040
  let seen = /* @__PURE__ */ new Set();
48041
+ const __stats = { chunks: 0, compiled: 0, distinct: /* @__PURE__ */ new Set(), parseMs: 0 };
47942
48042
  const chunks = [];
47943
48043
  const runtimeImportNames = /* @__PURE__ */ new Set();
47944
48044
  const cache2 = options?.cache;
@@ -48027,13 +48127,17 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
48027
48127
  return;
48028
48128
  }
48029
48129
  compiledFiles++;
48130
+ __stats.compiled++;
48131
+ __stats.distinct.add(filePath);
48030
48132
  let src2 = readFileSync24(filePath, "utf-8");
48031
48133
  if (/content=["'][^"']*\.md["']/i.test(src2)) {
48032
48134
  src2 = inlineMdContentAttrs(src2, dirname18(filePath), guessProjectRoots(appDir));
48033
48135
  }
48034
48136
  const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
48035
48137
  const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
48138
+ const __p0 = performance.now();
48036
48139
  const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths, componentNames } = compileClientBoth(src2, null, filePath);
48140
+ __stats.parseMs += performance.now() - __p0;
48037
48141
  for (const cn of componentNames || [])
48038
48142
  componentOwners.claim(cn, filePath);
48039
48143
  const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
@@ -48184,8 +48288,8 @@ ${body}
48184
48288
  continue;
48185
48289
  let finalCode;
48186
48290
  if (entry.imports) {
48187
- const tmpBase = mkdtempSync2(join18(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
48188
- const tmpFile = join18(tmpBase, "entry.js");
48291
+ const tmpBase = mkdtempSync2(join19(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
48292
+ const tmpFile = join19(tmpBase, "entry.js");
48189
48293
  const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
48190
48294
  const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
48191
48295
  ${entry.code}
@@ -48236,6 +48340,8 @@ ${entry.code}
48236
48340
  transformedChunks.push({ ...chunk, code: await applyTransformPlugins(chunk.code, chunk.name) });
48237
48341
  }
48238
48342
  componentOwners.report("client bundle");
48343
+ if (process.env.VESK_BUILD_PROFILE)
48344
+ console.error(` [client] chunks=${chunks.length} compiled=${__stats.compiled} distinct=${__stats.distinct.size} parseMs=${__stats.parseMs.toFixed(0)}`);
48239
48345
  return { main: await applyTransformPlugins(main, "client.js"), chunks: transformedChunks, cachedFileHits, compiledFiles, mainFromCache, editedSources, editedNames };
48240
48346
  } else {
48241
48347
  let compileFileMono2 = function(filePath, resolvedName) {
@@ -48335,7 +48441,7 @@ function buildRuntimeCode2(runtimeDir) {
48335
48441
  ];
48336
48442
  let code = "";
48337
48443
  for (const f of runtimeFiles) {
48338
- const p = join18(runtimeDir, f);
48444
+ const p = join19(runtimeDir, f);
48339
48445
  if (existsSync28(p)) {
48340
48446
  let src2 = readFileSync24(p, "utf-8");
48341
48447
  src2 = stripTypes2(src2);
@@ -48349,7 +48455,7 @@ ${src2}
48349
48455
  `;
48350
48456
  }
48351
48457
  }
48352
- const indexSrc = readFileSync24(join18(runtimeDir, "index-client.js"), "utf-8");
48458
+ const indexSrc = readFileSync24(join19(runtimeDir, "index-client.js"), "utf-8");
48353
48459
  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())) || [];
48354
48460
  code += "// --- exports ---\n";
48355
48461
  for (const name of [...new Set(exportNames)]) {
@@ -48360,7 +48466,7 @@ ${src2}
48360
48466
  return code;
48361
48467
  }
48362
48468
  function runtimeExportNames2(runtimeDir) {
48363
- const indexSrc = readFileSync24(join18(runtimeDir, "index-client.js"), "utf-8");
48469
+ const indexSrc = readFileSync24(join19(runtimeDir, "index-client.js"), "utf-8");
48364
48470
  const names = /* @__PURE__ */ new Set();
48365
48471
  for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
48366
48472
  for (const raw2 of m[1].split(",")) {
@@ -48376,7 +48482,7 @@ function esbuildPath2(p) {
48376
48482
  return sep3 === "/" ? p : p.split(sep3).join("/");
48377
48483
  }
48378
48484
  function runtimeTreeShakeEntry2() {
48379
- return join18(tmpdir2(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
48485
+ return join19(tmpdir3(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
48380
48486
  }
48381
48487
  var treeShakeQueue2 = Promise.resolve();
48382
48488
  function buildTreeShakenRuntime2(runtimeDir, usedNames) {
@@ -48393,7 +48499,7 @@ async function buildTreeShakenRuntimeNow2(runtimeDir, usedNames) {
48393
48499
  return buildRuntimeCode2(runtimeDir);
48394
48500
  }
48395
48501
  const entry = runtimeTreeShakeEntry2();
48396
- const indexClient = esbuildPath2(join18(runtimeDir, "index-client.js"));
48502
+ const indexClient = esbuildPath2(join19(runtimeDir, "index-client.js"));
48397
48503
  try {
48398
48504
  try {
48399
48505
  mkdirSync12(dirname18(entry), { recursive: true });
@@ -48632,8 +48738,8 @@ import { resolve as resolve28 } from "node:path";
48632
48738
  // ../adapter/dist/plugins.js
48633
48739
  init_paths();
48634
48740
  import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
48635
- import { resolve as resolve26, dirname as dirname19, join as join19, extname as extname7, basename as basename5 } from "node:path";
48636
- import { createRequire as createRequire5 } from "node:module";
48741
+ import { resolve as resolve26, dirname as dirname19, join as join20, extname as extname7, basename as basename5 } from "node:path";
48742
+ import { createRequire as createRequire6 } from "node:module";
48637
48743
  import { spawn as spawn2 } from "node:child_process";
48638
48744
  var PLUGIN_STATE_FILENAME2 = "plugins.json";
48639
48745
  var STATE_VERSION2 = 1;
@@ -48679,7 +48785,7 @@ function writePluginState2(veskDir, state) {
48679
48785
  writeFileSync14(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
48680
48786
  }
48681
48787
  function resolvePackage2(appDir, pkg) {
48682
- const require3 = createRequire5(resolve26(appDir, "package.json"));
48788
+ const require3 = createRequire6(resolve26(appDir, "package.json"));
48683
48789
  let entryPath = null;
48684
48790
  let pkgJsonPath = null;
48685
48791
  let pkgJson = null;
@@ -48692,7 +48798,7 @@ function resolvePackage2(appDir, pkg) {
48692
48798
  const seen = /* @__PURE__ */ new Set();
48693
48799
  while (cur && cur !== dirname19(cur) && !seen.has(cur)) {
48694
48800
  seen.add(cur);
48695
- const candidate = join19(cur, "package.json");
48801
+ const candidate = join20(cur, "package.json");
48696
48802
  if (existsSync30(candidate)) {
48697
48803
  pkgJsonPath = candidate;
48698
48804
  break;
@@ -48721,7 +48827,7 @@ function resolvePackage2(appDir, pkg) {
48721
48827
  }
48722
48828
  }
48723
48829
  if (localPath) {
48724
- const localJson = join19(localPath, "package.json");
48830
+ const localJson = join20(localPath, "package.json");
48725
48831
  let json = null;
48726
48832
  if (existsSync30(localJson)) {
48727
48833
  json = readJsonFile2(localJson);
@@ -49608,8 +49714,8 @@ var __internals2 = {
49608
49714
 
49609
49715
  // ../adapter/dist/dev-config.js
49610
49716
  import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
49611
- import { tmpdir as tmpdir3 } from "node:os";
49612
- import { resolve as resolve27, dirname as dirname20, join as join20 } from "node:path";
49717
+ import { tmpdir as tmpdir4 } from "node:os";
49718
+ import { resolve as resolve27, dirname as dirname20, join as join21 } from "node:path";
49613
49719
  init_parser();
49614
49720
  function findConfigFile2(projectDir) {
49615
49721
  const ts9 = resolve27(projectDir, "vesk.config.ts");
@@ -49637,9 +49743,9 @@ async function parseConfigSource(source, isTs, projectDir) {
49637
49743
  js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
49638
49744
  ` + js;
49639
49745
  }
49640
- const base = projectDir ? (mkdirSync14(join20(projectDir, ".vesk"), { recursive: true }), join20(projectDir, ".vesk")) : void 0;
49641
- const dir = base ? mkdtempSync3(join20(base, "cfg-")) : mkdtempSync3(join20(tmpdir3(), "vesk-cfg-"));
49642
- const tmpFile = join20(dir, "config.mjs");
49746
+ const base = projectDir ? (mkdirSync14(join21(projectDir, ".vesk"), { recursive: true }), join21(projectDir, ".vesk")) : void 0;
49747
+ const dir = base ? mkdtempSync3(join21(base, "cfg-")) : mkdtempSync3(join21(tmpdir4(), "vesk-cfg-"));
49748
+ const tmpFile = join21(dir, "config.mjs");
49643
49749
  try {
49644
49750
  writeFileSync15(tmpFile, js, "utf-8");
49645
49751
  globalThis.__vesk_inject = {
@@ -50949,7 +51055,7 @@ function produceDiagnostics(input) {
50949
51055
 
50950
51056
  // ../agentic/dist/checkpoints.js
50951
51057
  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";
50952
- import { join as join21, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
51058
+ import { join as join22, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
50953
51059
  import { randomUUID as nodeRandomUUID } from "node:crypto";
50954
51060
  function generateId() {
50955
51061
  try {
@@ -51082,16 +51188,16 @@ var CheckpointManager = class {
51082
51188
  }
51083
51189
  };
51084
51190
  function getAgenticDir(projectDir) {
51085
- return join21(resolve29(projectDir), ".vesk", "agentic");
51191
+ return join22(resolve29(projectDir), ".vesk", "agentic");
51086
51192
  }
51087
51193
  function getHistoryPath(projectDir) {
51088
- return join21(getAgenticDir(projectDir), "history.json");
51194
+ return join22(getAgenticDir(projectDir), "history.json");
51089
51195
  }
51090
51196
  function getCheckpointDir(projectDir, id) {
51091
- return join21(getAgenticDir(projectDir), "checkpoints", id);
51197
+ return join22(getAgenticDir(projectDir), "checkpoints", id);
51092
51198
  }
51093
51199
  function getCheckpointPath(projectDir, id) {
51094
- return join21(getCheckpointDir(projectDir, id), "checkpoint.json");
51200
+ return join22(getCheckpointDir(projectDir, id), "checkpoint.json");
51095
51201
  }
51096
51202
  function ensureDir(dir) {
51097
51203
  mkdirSync15(dir, { recursive: true });
@@ -51171,7 +51277,7 @@ function createCheckpoint(projectDir, message, changes = {}, buildResult) {
51171
51277
  };
51172
51278
  const agenticDir = getAgenticDir(projectDir);
51173
51279
  ensureDir(agenticDir);
51174
- ensureDir(join21(agenticDir, "checkpoints"));
51280
+ ensureDir(join22(agenticDir, "checkpoints"));
51175
51281
  const cpDir = getCheckpointDir(projectDir, id);
51176
51282
  ensureDir(cpDir);
51177
51283
  writeJsonAtomic(getCheckpointPath(projectDir, id), checkpoint);
@@ -52676,7 +52782,7 @@ var Agent = class {
52676
52782
 
52677
52783
  // ../agentic/dist/tools/vesk.js
52678
52784
  import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
52679
- import { resolve as resolve32, join as join22, dirname as dirname23, sep as sep6 } from "node:path";
52785
+ import { resolve as resolve32, join as join23, dirname as dirname23, sep as sep6 } from "node:path";
52680
52786
  function resolveWithin3(baseDir, relPath) {
52681
52787
  const base = resolve32(baseDir);
52682
52788
  const target = resolve32(baseDir, relPath);
@@ -52738,7 +52844,7 @@ function findConfigFile3(projectDir) {
52738
52844
  return { path: null, isTs: false };
52739
52845
  }
52740
52846
  function checkpointDir(veskDir) {
52741
- return join22(resolve32(veskDir), "checkpoints");
52847
+ return join23(resolve32(veskDir), "checkpoints");
52742
52848
  }
52743
52849
  function findMatchingBrace2(src2, openIdx) {
52744
52850
  let inStr = null;
@@ -53353,7 +53459,7 @@ function createVeskTools(deps) {
53353
53459
  const dir = checkpointDir(veskDir);
53354
53460
  mkdirSync17(dir, { recursive: true });
53355
53461
  const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
53356
- const file = join22(dir, `${id}.json`);
53462
+ const file = join23(dir, `${id}.json`);
53357
53463
  const check = resolveWithin3(dir, `${id}.json`);
53358
53464
  if (!check)
53359
53465
  return jsonError("path escapes project root");
@@ -53402,7 +53508,7 @@ function createVeskTools(deps) {
53402
53508
  } catch {
53403
53509
  }
53404
53510
  const dir = checkpointDir(veskDir);
53405
- const file = join22(dir, `${checkpointId}.json`);
53511
+ const file = join23(dir, `${checkpointId}.json`);
53406
53512
  const contained = resolveWithin3(dir, `${checkpointId}.json`);
53407
53513
  if (!contained)
53408
53514
  return jsonError("path escapes project root");
@@ -54124,10 +54230,10 @@ function renderDevErrorPage(payload, opts) {
54124
54230
  // src/build-packages.ts
54125
54231
  import { spawnSync as spawnSync2 } from "node:child_process";
54126
54232
  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";
54127
- import { createRequire as createRequire6 } from "node:module";
54128
- import { dirname as dirname25, join as join23, resolve as resolve36 } from "node:path";
54233
+ import { createRequire as createRequire7 } from "node:module";
54234
+ import { dirname as dirname25, join as join24, resolve as resolve36 } from "node:path";
54129
54235
  import { fileURLToPath as fileURLToPath8 } from "node:url";
54130
- var require2 = createRequire6(import.meta.url);
54236
+ var require2 = createRequire7(import.meta.url);
54131
54237
  var __dirname9 = dirname25(fileURLToPath8(import.meta.url));
54132
54238
  var root2 = resolve36(__dirname9, "..", "..", "..");
54133
54239
  var PACKAGES = {
@@ -54154,7 +54260,7 @@ var PACKAGES = {
54154
54260
  function newestSourceMtime(srcDir) {
54155
54261
  let newest = 0;
54156
54262
  for (const name of readdirSync11(srcDir)) {
54157
- const p = join23(srcDir, name);
54263
+ const p = join24(srcDir, name);
54158
54264
  const st = statSync20(p);
54159
54265
  if (st.isDirectory()) {
54160
54266
  newest = Math.max(newest, newestSourceMtime(p));
@@ -54165,11 +54271,11 @@ function newestSourceMtime(srcDir) {
54165
54271
  return newest;
54166
54272
  }
54167
54273
  function distStale(pkgDir, entry) {
54168
- const distIndex = join23(pkgDir, "dist", `${entry}.js`);
54274
+ const distIndex = join24(pkgDir, "dist", `${entry}.js`);
54169
54275
  if (!existsSync40(distIndex)) return true;
54170
- const distPkg = join23(pkgDir, "dist", "package.json");
54276
+ const distPkg = join24(pkgDir, "dist", "package.json");
54171
54277
  const distStamp = Math.max(statSync20(distIndex).mtimeMs, existsSync40(distPkg) ? statSync20(distPkg).mtimeMs : 0);
54172
- return newestSourceMtime(join23(pkgDir, "src")) > distStamp;
54278
+ return newestSourceMtime(join24(pkgDir, "src")) > distStamp;
54173
54279
  }
54174
54280
  function distPackageJson(pkgName, entry, serverEntry, version2) {
54175
54281
  const exports = {
@@ -54193,23 +54299,23 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
54193
54299
  function buildPackages(force = false) {
54194
54300
  for (const [pkg, cfg] of Object.entries(PACKAGES)) {
54195
54301
  const pkgDir = resolve36(root2, "packages", pkg);
54196
- if (!existsSync40(join23(pkgDir, "src"))) continue;
54302
+ if (!existsSync40(join24(pkgDir, "src"))) continue;
54197
54303
  if (!force && !distStale(pkgDir, cfg.entry)) continue;
54198
54304
  console.log(`[build] ${cfg.name} -> tsc`);
54199
54305
  const tscBin = require2.resolve("typescript/bin/tsc");
54200
- const result = spawnSync2(process.execPath, [tscBin, "-p", join23(pkgDir, "tsconfig.build.json")], {
54306
+ const result = spawnSync2(process.execPath, [tscBin, "-p", join24(pkgDir, "tsconfig.build.json")], {
54201
54307
  stdio: "inherit"
54202
54308
  });
54203
54309
  if (result.status !== 0) {
54204
54310
  throw new Error(`tsc failed for ${cfg.name}`);
54205
54311
  }
54206
- const distDir = join23(pkgDir, "dist");
54312
+ const distDir = join24(pkgDir, "dist");
54207
54313
  for (const c of cfg.copy || []) {
54208
- const to = join23(distDir, c.to);
54314
+ const to = join24(distDir, c.to);
54209
54315
  mkdirSync18(dirname25(to), { recursive: true });
54210
- cpSync2(join23(pkgDir, c.from), to, { recursive: true });
54316
+ cpSync2(join24(pkgDir, c.from), to, { recursive: true });
54211
54317
  }
54212
- const srcPkg = JSON.parse(readFileSync36(join23(pkgDir, "package.json"), "utf-8"));
54318
+ const srcPkg = JSON.parse(readFileSync36(join24(pkgDir, "package.json"), "utf-8"));
54213
54319
  if (pkg === "lucide-vesk") {
54214
54320
  const lucideDistPkg = {
54215
54321
  name: srcPkg.name,
@@ -54223,9 +54329,9 @@ function buildPackages(force = false) {
54223
54329
  "./package.json": "./package.json"
54224
54330
  }
54225
54331
  };
54226
- writeFileSync20(join23(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
54332
+ writeFileSync20(join24(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
54227
54333
  } else {
54228
- writeFileSync20(join23(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
54334
+ writeFileSync20(join24(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
54229
54335
  }
54230
54336
  console.log(`[build] ${cfg.name} -> dist`);
54231
54337
  }
@@ -54702,9 +54808,9 @@ function resolveRuntimeDir(projectDir) {
54702
54808
  resolve38(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
54703
54809
  ];
54704
54810
  for (const dir of candidates) {
54705
- if (existsSync42(join24(dir, "ripple-runtime.js"))) return dir;
54706
- const distDir = join24(dir, "dist");
54707
- if (existsSync42(join24(distDir, "ripple-runtime.js"))) return distDir;
54811
+ if (existsSync42(join25(dir, "ripple-runtime.js"))) return dir;
54812
+ const distDir = join25(dir, "dist");
54813
+ if (existsSync42(join25(distDir, "ripple-runtime.js"))) return distDir;
54708
54814
  }
54709
54815
  return null;
54710
54816
  }
@@ -54944,7 +55050,7 @@ function countFilesNamed(dir, name) {
54944
55050
  if (!existsSync42(dir)) return 0;
54945
55051
  let n = 0;
54946
55052
  for (const entry of readdirSync13(dir, { withFileTypes: true })) {
54947
- const p = join24(dir, entry.name);
55053
+ const p = join25(dir, entry.name);
54948
55054
  if (entry.isDirectory()) n += countFilesNamed(p, name);
54949
55055
  else if (entry.name === name) n++;
54950
55056
  }
@@ -54987,7 +55093,7 @@ async function startDevServer(port, projectDir, config, host) {
54987
55093
  process.exit(1);
54988
55094
  }
54989
55095
  const runtimeDir = runtimeDirUnchecked;
54990
- const veskStateDir = join24(projectDir, ".vesk");
55096
+ const veskStateDir = join25(projectDir, ".vesk");
54991
55097
  const configPluginsRaw = config.plugins || [];
54992
55098
  const configPluginNames = configPluginsRaw.map((p) => typeof p === "string" ? p : p?.name).filter((n) => !!n);
54993
55099
  const rawDevPlugins = config.plugins || [];
@@ -55086,10 +55192,10 @@ async function startDevServer(port, projectDir, config, host) {
55086
55192
  }
55087
55193
  let devGlobalCssContent = "";
55088
55194
  let lastServedCssGlobal = "";
55089
- const appCssPath = join24(appDirPath, "global.css");
55090
- const srcDir = join24(projectDir, "src");
55091
- const cssPath = join24(srcDir, "global.css");
55092
- const altCssPath = join24(srcDir, "app.css");
55195
+ const appCssPath = join25(appDirPath, "global.css");
55196
+ const srcDir = join25(projectDir, "src");
55197
+ const cssPath = join25(srcDir, "global.css");
55198
+ const altCssPath = join25(srcDir, "app.css");
55093
55199
  let rawCss = "";
55094
55200
  let devCssSource = "";
55095
55201
  if (existsSync42(appCssPath)) {
@@ -55376,7 +55482,7 @@ async function startDevServer(port, projectDir, config, host) {
55376
55482
  if (!filename) return;
55377
55483
  const kind = classifyHmrWatchPath(filename);
55378
55484
  if (kind === "ignored") return;
55379
- const fullPath = filename.startsWith("/") ? filename : join24(watchDir, filename);
55485
+ const fullPath = filename.startsWith("/") ? filename : join25(watchDir, filename);
55380
55486
  const fileExists = existsSync42(fullPath);
55381
55487
  const bcast = (msg) => {
55382
55488
  const f = globalThis.__vesk_broadcastHmr;
@@ -55591,8 +55697,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
55591
55697
  ".json": "application/json",
55592
55698
  ".webmanifest": "application/manifest+json"
55593
55699
  };
55594
- const hmrJsPath = join24(runtimeDir, "hmr-client.js");
55595
- const hmrTsPath = join24(runtimeDir, "hmr-client.ts");
55700
+ const hmrJsPath = join25(runtimeDir, "hmr-client.js");
55701
+ const hmrTsPath = join25(runtimeDir, "hmr-client.ts");
55596
55702
  const hmrClientPath = existsSync42(hmrJsPath) ? hmrJsPath : existsSync42(hmrTsPath) ? hmrTsPath : null;
55597
55703
  function extractCompName2(src2) {
55598
55704
  return resolveComponentName(src2);
@@ -55764,7 +55870,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
55764
55870
  return;
55765
55871
  }
55766
55872
  const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
55767
- const apiDirPath = join24(appDirPath, "api");
55873
+ const apiDirPath = join25(appDirPath, "api");
55768
55874
  if (url.pathname.startsWith("/api") && existsSync42(apiDirPath)) {
55769
55875
  const apiRoutes = await scanApiRoutes(apiDirPath);
55770
55876
  const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
@@ -56256,7 +56362,7 @@ ${prettifyHtml(body)}
56256
56362
  LOG.ok(`dev server at http://localhost:${port} (listening on ${bindHost})`);
56257
56363
  const routes = collectRoutePaths(routeTree);
56258
56364
  const pageCount = countPages(routeTree);
56259
- const apiCount = countFilesNamed(join24(appDirPath, "api"), "route.ts");
56365
+ const apiCount = countFilesNamed(join25(appDirPath, "api"), "route.ts");
56260
56366
  LOG.info(`${projectDir}`);
56261
56367
  LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
56262
56368
  if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
@@ -56568,8 +56674,8 @@ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
56568
56674
  }
56569
56675
  function loadEnvFiles(projectDir) {
56570
56676
  const files = [
56571
- join26(projectDir, ".env"),
56572
- join26(projectDir, ".env.local")
56677
+ join27(projectDir, ".env"),
56678
+ join27(projectDir, ".env.local")
56573
56679
  ];
56574
56680
  for (const filePath of files) {
56575
56681
  if (!existsSync43(filePath)) continue;
@@ -56740,7 +56846,7 @@ if (cmd === "start") {
56740
56846
  if (cmd === "init") {
56741
56847
  const projectDir = process.cwd();
56742
56848
  const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
56743
- const target = join26(appDirPath, "global.css");
56849
+ const target = join27(appDirPath, "global.css");
56744
56850
  if (existsSync43(target)) {
56745
56851
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
56746
56852
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.45",
3
+ "version": "0.2.46",
4
4
  "type": "module",
5
5
  "description": "Vesk — compiler-first framework for the post-VDOM web. vesk dev, vesk build.",
6
6
  "bin": {
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "main": "./dist/cli.js",
10
10
  "dependencies": {
11
- "@vesk/adapter": "^0.2.45",
12
- "@vesk/compiler": "^0.2.45",
13
- "@vesk/plugin-tailwind": "^0.2.45",
14
- "@vesk/runtime": "^0.2.45",
11
+ "@vesk/adapter": "^0.2.46",
12
+ "@vesk/compiler": "^0.2.46",
13
+ "@vesk/plugin-tailwind": "^0.2.46",
14
+ "@vesk/runtime": "^0.2.46",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",