@vesk/vesk-cli 0.2.63 → 0.2.64

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 +74 -5
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -47726,7 +47726,7 @@ __export(migrate_exports, {
47726
47726
  detectInstalledVersion: () => detectInstalledVersion,
47727
47727
  runMigrate: () => runMigrate
47728
47728
  });
47729
- import { readFileSync as readFileSync41, writeFileSync as writeFileSync21, existsSync as existsSync44, statSync as statSync23, readdirSync as readdirSync15 } from "node:fs";
47729
+ import { readFileSync as readFileSync41, writeFileSync as writeFileSync22, existsSync as existsSync44, statSync as statSync23, readdirSync as readdirSync15 } from "node:fs";
47730
47730
  import { join as join29, relative as relative9, extname as extname9 } from "node:path";
47731
47731
  function detectInstalledVersion(projectDir, cliVersion) {
47732
47732
  for (const pkg of ["@vesk/vesk-cli", "@vesk/adapter", "@vesk/compiler"]) {
@@ -47815,7 +47815,7 @@ function runMigrate(options) {
47815
47815
  }
47816
47816
  if (!changed) continue;
47817
47817
  report.filesChanged.push(relPath);
47818
- if (!options.dryRun) writeFileSync21(abs, current2, "utf-8");
47818
+ if (!options.dryRun) writeFileSync22(abs, current2, "utf-8");
47819
47819
  }
47820
47820
  return report;
47821
47821
  }
@@ -47830,7 +47830,7 @@ var init_migrate = __esm({
47830
47830
  });
47831
47831
 
47832
47832
  // src/index.ts
47833
- import { readFileSync as readFileSync42, writeFileSync as writeFileSync22, mkdirSync as mkdirSync20, existsSync as existsSync45 } from "fs";
47833
+ import { readFileSync as readFileSync42, writeFileSync as writeFileSync23, mkdirSync as mkdirSync20, existsSync as existsSync45 } from "fs";
47834
47834
  import { resolve as resolve40, join as join30 } from "path";
47835
47835
  import { fileURLToPath as fileURLToPath9 } from "url";
47836
47836
 
@@ -52184,7 +52184,8 @@ vesk build: done (${outDir})`);
52184
52184
  init_seo_audit();
52185
52185
 
52186
52186
  // src/dev-server.ts
52187
- import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, readdirSync as readdirSync13 } from "node:fs";
52187
+ 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";
52188
+ import { createHash as createHash2 } from "node:crypto";
52188
52189
  import { resolve as resolve38, extname as extname8, join as join26, dirname as dirname26 } from "node:path";
52189
52190
  import { createServer as createServer2 } from "node:http";
52190
52191
  import { WebSocketServer as WebSocketServer2 } from "ws";
@@ -64196,6 +64197,61 @@ async function startDevServer(port, projectDir, config, host) {
64196
64197
  }
64197
64198
  const routeChunksBuilt = /* @__PURE__ */ new Set();
64198
64199
  let clientGeneration = 0;
64200
+ const devCacheDir = () => join26(projectDir, "node_modules", ".vesk", "dev-cache");
64201
+ function devCacheKey() {
64202
+ const parts = [`flags:${!!config.routeDataCache}`];
64203
+ const walk9 = (dir) => {
64204
+ let entries = [];
64205
+ try {
64206
+ entries = readdirSync13(dir);
64207
+ } catch {
64208
+ return;
64209
+ }
64210
+ for (const name of entries.sort()) {
64211
+ if (name === "node_modules" || name.startsWith(".")) continue;
64212
+ const p = join26(dir, name);
64213
+ let st;
64214
+ try {
64215
+ st = statSync21(p);
64216
+ } catch {
64217
+ continue;
64218
+ }
64219
+ if (st.isDirectory()) {
64220
+ walk9(p);
64221
+ continue;
64222
+ }
64223
+ if (!/\.(vsk|ts|tsx|js|jsx|vue|svelte)$/.test(name)) continue;
64224
+ parts.push(`${p}:${st.mtimeMs}:${st.size}`);
64225
+ }
64226
+ };
64227
+ walk9(appDirPath);
64228
+ try {
64229
+ parts.push(`compiler:${readFileSync38(join26(process.cwd(), "node_modules", "@vesk", "compiler", "package.json"), "utf8")}`);
64230
+ } catch {
64231
+ }
64232
+ return createHash2("sha256").update(parts.join("\n")).digest("hex").slice(0, 32);
64233
+ }
64234
+ function readDevBundleCache() {
64235
+ try {
64236
+ const file = join26(devCacheDir(), "client-bundle.json");
64237
+ const parsed = JSON.parse(readFileSync38(file, "utf8"));
64238
+ if (parsed.key !== devCacheKey() || typeof parsed.main !== "string" || !Array.isArray(parsed.chunks)) return null;
64239
+ return { main: parsed.main, chunks: parsed.chunks };
64240
+ } catch {
64241
+ return null;
64242
+ }
64243
+ }
64244
+ function writeDevBundleCache(main, chunks) {
64245
+ try {
64246
+ const dir = devCacheDir();
64247
+ mkdirSync19(dir, { recursive: true });
64248
+ const file = join26(dir, "client-bundle.json");
64249
+ const tmp = join26(dir, `client-bundle.${process.pid}.tmp`);
64250
+ writeFileSync21(tmp, JSON.stringify({ key: devCacheKey(), main, chunks }), "utf8");
64251
+ renameSync2(tmp, file);
64252
+ } catch {
64253
+ }
64254
+ }
64199
64255
  async function ensureRouteChunk(fullPath) {
64200
64256
  if (routeChunksBuilt.has(fullPath)) return;
64201
64257
  routeChunksBuilt.add(fullPath);
@@ -64233,6 +64289,18 @@ async function startDevServer(port, projectDir, config, host) {
64233
64289
  }
64234
64290
  async function buildClientBundle() {
64235
64291
  try {
64292
+ const cached = readDevBundleCache();
64293
+ if (cached) {
64294
+ clientBundle = cached.main;
64295
+ devBundleBytes = Buffer.byteLength(cached.main, "utf8");
64296
+ storeChunks(cached.chunks);
64297
+ for (const c of cached.chunks) {
64298
+ const fullPath = c.name === SHARED_CHUNK_NAME2 ? null : routeFullPathForChunk(c.name);
64299
+ if (fullPath) routeChunksBuilt.add(fullPath);
64300
+ }
64301
+ LOG.info?.(`client bundle restored from cache (${cached.chunks.length} chunks)`);
64302
+ return;
64303
+ }
64236
64304
  const { main, chunks } = await generateClientBundle2(routeTree, appDirPath, /* @__PURE__ */ new Map(), {
64237
64305
  importRuntime: true,
64238
64306
  hmr: true,
@@ -64248,6 +64316,7 @@ async function startDevServer(port, projectDir, config, host) {
64248
64316
  clientBundle = main;
64249
64317
  devBundleBytes = Buffer.byteLength(main, "utf8");
64250
64318
  storeChunks(chunks);
64319
+ writeDevBundleCache(main, chunks);
64251
64320
  } catch (e) {
64252
64321
  LOG.err(`client build error:`, e.message);
64253
64322
  throw e;
@@ -65875,7 +65944,7 @@ if (cmd === "init") {
65875
65944
  process.exit(0);
65876
65945
  }
65877
65946
  mkdirSync20(appDirPath, { recursive: true });
65878
- writeFileSync22(target, [
65947
+ writeFileSync23(target, [
65879
65948
  `@import 'tailwindcss';`,
65880
65949
  ``,
65881
65950
  `@layer base {`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.63",
3
+ "version": "0.2.64",
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.63",
12
- "@vesk/compiler": "^0.2.63",
13
- "@vesk/plugin-tailwind": "^0.2.63",
14
- "@vesk/runtime": "^0.2.63",
11
+ "@vesk/adapter": "^0.2.64",
12
+ "@vesk/compiler": "^0.2.64",
13
+ "@vesk/plugin-tailwind": "^0.2.64",
14
+ "@vesk/runtime": "^0.2.64",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",