@vesk/vesk-cli 0.2.44 → 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 +722 -598
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -1659,11 +1659,11 @@ var init_context = __esm({
1659
1659
 
1660
1660
  // ../runtime/src/server-events.ts
1661
1661
  function getStore() {
1662
- const g2 = globalThis;
1663
- if (!g2.__vesk_server_ctx || typeof g2.__vesk_server_ctx !== "object") {
1664
- g2.__vesk_server_ctx = {};
1662
+ const g4 = globalThis;
1663
+ if (!g4.__vesk_server_ctx || typeof g4.__vesk_server_ctx !== "object") {
1664
+ g4.__vesk_server_ctx = {};
1665
1665
  }
1666
- return g2.__vesk_server_ctx;
1666
+ return g4.__vesk_server_ctx;
1667
1667
  }
1668
1668
  function server_locals() {
1669
1669
  return getStore();
@@ -2032,16 +2032,6 @@ function startRequest(handle2, skipCache) {
2032
2032
  if (getInflight().get(key) === prom2) getInflight().delete(key);
2033
2033
  });
2034
2034
  } else {
2035
- const ownerToken = g().__vsk_ssr_token || void 0;
2036
- if (ownerToken) {
2037
- prom2.then(
2038
- (data2) => {
2039
- setSsrData(key, data2, ownerToken);
2040
- },
2041
- () => {
2042
- }
2043
- );
2044
- }
2045
2035
  attachSettle(handle2, prom2);
2046
2036
  }
2047
2037
  trackSsrPromise(prom2);
@@ -2663,9 +2653,9 @@ function createHydrateWalker(container, markerList) {
2663
2653
  }
2664
2654
  function bumpNavEpoch() {
2665
2655
  try {
2666
- const g2 = globalThis;
2667
- const next = (g2.__vesk_nav_epoch || 0) + 1;
2668
- g2.__vesk_nav_epoch = next;
2656
+ const g4 = globalThis;
2657
+ const next = (g4.__vesk_nav_epoch || 0) + 1;
2658
+ g4.__vesk_nav_epoch = next;
2669
2659
  return next;
2670
2660
  } catch {
2671
2661
  return 0;
@@ -5345,8 +5335,8 @@ function createRouter(routes, options = {}) {
5345
5335
  },
5346
5336
  _runGuards(to) {
5347
5337
  const from = get(_state.path) || window.location.pathname;
5348
- for (const g2 of this._beforeGuards ?? []) {
5349
- const d = g2(to, from);
5338
+ for (const g4 of this._beforeGuards ?? []) {
5339
+ const d = g4(to, from);
5350
5340
  if (d instanceof Promise) {
5351
5341
  return d.then((r) => {
5352
5342
  if (r === false || typeof r === "string") return r;
@@ -5672,8 +5662,8 @@ function createFileRouter(routeTree, options = {}) {
5672
5662
  },
5673
5663
  _runGuards(to) {
5674
5664
  const from = get(_state.path) || window.location.pathname;
5675
- for (const g2 of this._beforeGuards ?? []) {
5676
- const d = g2(to, from);
5665
+ for (const g4 of this._beforeGuards ?? []) {
5666
+ const d = g4(to, from);
5677
5667
  if (d instanceof Promise) {
5678
5668
  return d.then((r) => {
5679
5669
  if (r === false || typeof r === "string") return r;
@@ -18618,6 +18608,13 @@ function preprocessForClauses(source) {
18618
18608
  function createBaseParser() {
18619
18609
  return Parser.extend(tsPlugin({}), VeskParserPlugin());
18620
18610
  }
18611
+ function parseGeneratedJs(source) {
18612
+ try {
18613
+ return parse3(source, { ecmaVersion: "latest", sourceType: "module" });
18614
+ } catch {
18615
+ return null;
18616
+ }
18617
+ }
18621
18618
  function parse4(source, options = {}) {
18622
18619
  const ParserClass = createBaseParser();
18623
18620
  const { code, annotations } = preprocessForClauses(blankComments(source));
@@ -21759,16 +21756,16 @@ function sha256Bytes(msg) {
21759
21756
  const s1 = rr(w[j - 2], 17) ^ rr(w[j - 2], 19) ^ w[j - 2] >>> 10;
21760
21757
  w[j] = w[j - 16] + s0 + w[j - 7] + s1 >>> 0;
21761
21758
  }
21762
- let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g2 = h6, h = h7;
21759
+ let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g4 = h6, h = h7;
21763
21760
  for (let j = 0; j < 64; j++) {
21764
21761
  const S1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25);
21765
- const ch = e & f ^ ~e & g2;
21762
+ const ch = e & f ^ ~e & g4;
21766
21763
  const t1 = h + S1 + ch + SHA_K[j] + w[j] >>> 0;
21767
21764
  const S0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22);
21768
21765
  const maj = a & b ^ a & c ^ b & c;
21769
21766
  const t2 = S0 + maj >>> 0;
21770
- h = g2;
21771
- g2 = f;
21767
+ h = g4;
21768
+ g4 = f;
21772
21769
  f = e;
21773
21770
  e = d + t1 >>> 0;
21774
21771
  d = c;
@@ -21782,7 +21779,7 @@ function sha256Bytes(msg) {
21782
21779
  h3 = h3 + d >>> 0;
21783
21780
  h4 = h4 + e >>> 0;
21784
21781
  h5 = h5 + f >>> 0;
21785
- h6 = h6 + g2 >>> 0;
21782
+ h6 = h6 + g4 >>> 0;
21786
21783
  h7 = h7 + h >>> 0;
21787
21784
  }
21788
21785
  const out = new Uint8Array(32);
@@ -22833,23 +22830,23 @@ async function _getImpl() {
22833
22830
  return _signImpl;
22834
22831
  }
22835
22832
  async function signCookie2(name, value, host) {
22836
- const impl = await _getImpl();
22837
- if (impl.signCookie) return impl.signCookie(name, value, host);
22833
+ const impl3 = await _getImpl();
22834
+ if (impl3.signCookie) return impl3.signCookie(name, value, host);
22838
22835
  throw new Error("signCookie: @vesk/compiler not available");
22839
22836
  }
22840
22837
  async function unsignCookie2(name, signedValue, host) {
22841
- const impl = await _getImpl();
22842
- if (impl.unsignCookie) return impl.unsignCookie(name, signedValue, host);
22838
+ const impl3 = await _getImpl();
22839
+ if (impl3.unsignCookie) return impl3.unsignCookie(name, signedValue, host);
22843
22840
  throw new Error("unsignCookie: @vesk/compiler not available");
22844
22841
  }
22845
22842
  async function setSignedCookie2(name, value, options = {}, host) {
22846
- const impl = await _getImpl();
22847
- if (impl.setSignedCookie) return impl.setSignedCookie(name, value, options, host);
22843
+ const impl3 = await _getImpl();
22844
+ if (impl3.setSignedCookie) return impl3.setSignedCookie(name, value, options, host);
22848
22845
  throw new Error("setSignedCookie: @vesk/compiler not available");
22849
22846
  }
22850
22847
  async function readSignedCookie2(name, cookieString, host) {
22851
- const impl = await _getImpl();
22852
- if (impl.readSignedCookie) return impl.readSignedCookie(name, cookieString, host);
22848
+ const impl3 = await _getImpl();
22849
+ if (impl3.readSignedCookie) return impl3.readSignedCookie(name, cookieString, host);
22853
22850
  throw new Error("readSignedCookie: @vesk/compiler not available");
22854
22851
  }
22855
22852
  var ServerRequest, ServerResponse, DEFAULT_MAX_BODY_BYTES2, PayloadTooLargeError, VeskRequest, _VeskResponse, VeskResponse, _signImpl;
@@ -26365,9 +26362,9 @@ var init_primitive = __esm({
26365
26362
 
26366
26363
  // ../runtime/src/action.ts
26367
26364
  function getActionRegistry() {
26368
- const g2 = globalThis;
26369
- if (!g2[registryKey]) g2[registryKey] = {};
26370
- return g2[registryKey];
26365
+ const g4 = globalThis;
26366
+ if (!g4[registryKey]) g4[registryKey] = {};
26367
+ return g4[registryKey];
26371
26368
  }
26372
26369
  function hashString(str3) {
26373
26370
  let h1 = 2166136261;
@@ -26405,8 +26402,8 @@ function getAction(id) {
26405
26402
  return getActionRegistry()[id] || null;
26406
26403
  }
26407
26404
  function clearActions() {
26408
- const g2 = globalThis;
26409
- g2[registryKey] = {};
26405
+ const g4 = globalThis;
26406
+ g4[registryKey] = {};
26410
26407
  }
26411
26408
  function isFormAction(action) {
26412
26409
  return typeof action === "object" && action !== null && (action.__veskAction === true || typeof action.id === "string" && typeof action.url === "string");
@@ -31810,14 +31807,23 @@ function dropSsrSlot(token) {
31810
31807
  function isSsrSlotLive(token) {
31811
31808
  return liveSlots.has(token);
31812
31809
  }
31813
- var TOKEN_KEY, storage, liveSlots, ssrSink2;
31810
+ var TOKEN_KEY, IMPL_KEY, g2, impl, storage, liveSlots, ssrSink2;
31814
31811
  var init_ssr_store = __esm({
31815
31812
  "../compiler/src/ssr-store.ts"() {
31816
31813
  "use strict";
31817
31814
  init_index_server();
31818
31815
  TOKEN_KEY = "__vsk_ssr_token";
31819
- storage = new AsyncLocalStorage();
31820
- liveSlots = /* @__PURE__ */ new Map();
31816
+ IMPL_KEY = "__vsk_ssr_store_impl";
31817
+ g2 = globalThis;
31818
+ impl = g2[IMPL_KEY] ?? (g2[IMPL_KEY] = {
31819
+ storage: new AsyncLocalStorage(),
31820
+ liveSlots: /* @__PURE__ */ new Map(),
31821
+ // Only the copy that created the implementation installs the token
31822
+ // accessor; a later copy must not redefine it over the shared storage.
31823
+ ownsAccessor: true
31824
+ });
31825
+ storage = impl.storage;
31826
+ liveSlots = impl.liveSlots;
31821
31827
  ssrSink2 = {
31822
31828
  set: (key, value) => {
31823
31829
  const store = storage.getStore();
@@ -31836,16 +31842,18 @@ var init_ssr_store = __esm({
31836
31842
  }
31837
31843
  };
31838
31844
  setSsrSink(ssrSink2);
31839
- Object.defineProperty(globalThis, TOKEN_KEY, {
31840
- configurable: true,
31841
- get() {
31842
- return storage.getStore()?.token;
31843
- },
31844
- set(value) {
31845
- const store = storage.getStore();
31846
- if (store) store.token = value;
31847
- }
31848
- });
31845
+ if (impl.ownsAccessor) {
31846
+ Object.defineProperty(globalThis, TOKEN_KEY, {
31847
+ configurable: true,
31848
+ get() {
31849
+ return storage.getStore()?.token;
31850
+ },
31851
+ set(value) {
31852
+ const store = storage.getStore();
31853
+ if (store) store.token = value;
31854
+ }
31855
+ });
31856
+ }
31849
31857
  }
31850
31858
  });
31851
31859
 
@@ -32104,17 +32112,17 @@ async function settleSsrPromises(token) {
32104
32112
  }
32105
32113
  }
32106
32114
  function pruneSsrDataSlots() {
32107
- const g2 = globalThis;
32115
+ const g4 = globalThis;
32108
32116
  const prefix = "__vsk_ssr_data_";
32109
32117
  const stale = [];
32110
- for (const k of Object.keys(g2)) {
32118
+ for (const k of Object.keys(g4)) {
32111
32119
  if (typeof k !== "string" || !k.startsWith(prefix)) continue;
32112
32120
  if (isSsrSlotLive(k.slice(prefix.length))) continue;
32113
32121
  stale.push(k);
32114
32122
  }
32115
32123
  if (stale.length <= 40) return;
32116
32124
  stale.sort().slice(0, stale.length - 40).forEach((k) => {
32117
- delete g2[k];
32125
+ delete g4[k];
32118
32126
  });
32119
32127
  }
32120
32128
  async function applyHeadPlugins(headHtml, plugins, ctx2) {
@@ -33589,7 +33597,64 @@ __export(image_pipeline_exports, {
33589
33597
  });
33590
33598
  import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
33591
33599
  import { spawnSync } from "node:child_process";
33592
- 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
+ }
33593
33658
  async function processImage(srcPath, outDir, baseName) {
33594
33659
  const image = sharpFn ? sharpFn(srcPath) : null;
33595
33660
  if (!image) {
@@ -33658,13 +33723,15 @@ async function optimizeImages(appDir, outDir) {
33658
33723
  console.error("vesk images: no <Image> refs found");
33659
33724
  return [];
33660
33725
  }
33726
+ await ensureSharp();
33661
33727
  const results = [];
33662
33728
  for (const ref2 of refs) {
33729
+ const rel = ref2.src.replace(/^\//, "");
33663
33730
  const possiblePaths = [
33664
- resolve16(appDir, ref2.src),
33665
- resolve16(appDir, "..", "public", ref2.src.replace(/^\//, "")),
33666
- resolve16(appDir, "..", "src", ref2.src.replace(/^\//, "")),
33667
- 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)
33668
33735
  ];
33669
33736
  let srcPath = null;
33670
33737
  for (const p of possiblePaths) {
@@ -33694,28 +33761,15 @@ async function optimizeImages(appDir, outDir) {
33694
33761
  }
33695
33762
  return results;
33696
33763
  }
33697
- var SUPPORTED, OUTPUT_WIDTHS, FORMATS, sharpFn;
33764
+ var SUPPORTED, OUTPUT_WIDTHS, FORMATS, sharpFn, sharpProbed;
33698
33765
  var init_image_pipeline = __esm({
33699
- async "../adapter/dist/image-pipeline.js"() {
33766
+ "../adapter/dist/image-pipeline.js"() {
33700
33767
  "use strict";
33701
33768
  SUPPORTED = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png", ".webp", ".avif", ".tiff"]);
33702
33769
  OUTPUT_WIDTHS = [640, 768, 1024, 1280, 1536];
33703
33770
  FORMATS = ["webp", "avif"];
33704
33771
  sharpFn = null;
33705
- try {
33706
- const probe = spawnSync(process.execPath, [
33707
- "--input-type=module",
33708
- "-e",
33709
- "import sharp from 'sharp'; await sharp({ create: { width: 2, height: 2, channels: 3, background: 'red' } }).png().toBuffer();"
33710
- ], { stdio: "ignore" });
33711
- if (probe.status === 0) {
33712
- const mod = await import("sharp");
33713
- sharpFn = mod.default;
33714
- } else {
33715
- console.warn("vesk images: sharp native probe failed; using copy-only image pipeline");
33716
- }
33717
- } catch {
33718
- }
33772
+ sharpProbed = false;
33719
33773
  }
33720
33774
  });
33721
33775
 
@@ -33929,7 +33983,7 @@ var init_platform = __esm({
33929
33983
 
33930
33984
  // ../adapter/src/platform-handler.ts
33931
33985
  import { existsSync as existsSync20 } from "node:fs";
33932
- 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";
33933
33987
  import { fileURLToPath as fileURLToPath4 } from "node:url";
33934
33988
  function routeName2(segments) {
33935
33989
  const parts = segments.filter(Boolean).map((s) => {
@@ -33952,8 +34006,8 @@ function findCompilerSrc2(appDir) {
33952
34006
  resolve18(appDir, "node_modules", "@vesk/compiler")
33953
34007
  ];
33954
34008
  for (const base of candidates) {
33955
- for (const dir of [base, join12(base, "dist")]) {
33956
- 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;
33957
34011
  }
33958
34012
  }
33959
34013
  throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
@@ -34062,7 +34116,7 @@ ${serverStoreLine}
34062
34116
  // SSR already resolved. Entry is consumed on read (bound store).
34063
34117
  if (pathname === '/ssr-data.js') {
34064
34118
  const dataToken = url.searchParams.get('t') || '';
34065
- const dataStore = (globalThis.__vsk_ssr_data_store || {});
34119
+ const dataStore = (globalThis.__vsk_ssr_payload_store || {});
34066
34120
  const payload = dataStore[dataToken];
34067
34121
  if (payload) delete dataStore[dataToken];
34068
34122
  const dataLines = [];
@@ -34236,7 +34290,7 @@ import {
34236
34290
  rmSync as rmSync2,
34237
34291
  readFileSync as readFileSync20
34238
34292
  } from "node:fs";
34239
- 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";
34240
34294
  function ensureCleanDir(dir) {
34241
34295
  rmSync2(dir, { recursive: true, force: true });
34242
34296
  mkdirSync9(dir, { recursive: true });
@@ -34245,8 +34299,8 @@ function copyDirContents(srcDir, destDir) {
34245
34299
  if (!existsSync21(srcDir)) return;
34246
34300
  mkdirSync9(destDir, { recursive: true });
34247
34301
  for (const entry of readdirSync6(srcDir)) {
34248
- const srcPath = join13(srcDir, entry);
34249
- const destPath = join13(destDir, entry);
34302
+ const srcPath = join14(srcDir, entry);
34303
+ const destPath = join14(destDir, entry);
34250
34304
  if (statSync11(srcPath).isDirectory()) {
34251
34305
  copyDirContents(srcPath, destPath);
34252
34306
  } else {
@@ -34292,7 +34346,7 @@ function listStaticDir(dir) {
34292
34346
  if (!existsSync21(dir)) return out;
34293
34347
  function walk7(d, prefix) {
34294
34348
  for (const entry of readdirSync6(d)) {
34295
- const full = join13(d, entry);
34349
+ const full = join14(d, entry);
34296
34350
  const rel = prefix ? `${prefix}/${entry}` : entry;
34297
34351
  if (statSync11(full).isDirectory()) {
34298
34352
  walk7(full, rel);
@@ -37846,9 +37900,9 @@ function getJSXTagName2(el) {
37846
37900
  if (name.type === "JSXNamespacedName") return name.namespace.name + ":" + name.name.name;
37847
37901
  return null;
37848
37902
  }
37849
- function emitJSXText(g2, text, start, end) {
37903
+ function emitJSXText(g4, text, start, end) {
37850
37904
  if (text.indexOf("<") === -1 && text.indexOf(">") === -1 && text.indexOf("&") === -1 && text.indexOf("{") === -1 && text.indexOf("}") === -1) {
37851
- g2.add(text, start, end);
37905
+ g4.add(text, start, end);
37852
37906
  return;
37853
37907
  }
37854
37908
  let out = "";
@@ -37861,7 +37915,7 @@ function emitJSXText(g2, text, start, end) {
37861
37915
  else if (c === "}") out += "&#125;";
37862
37916
  else out += c;
37863
37917
  }
37864
- g2.add(out, start, end);
37918
+ g4.add(out, start, end);
37865
37919
  }
37866
37920
  function collapseWithMap(value) {
37867
37921
  let out = "";
@@ -38018,31 +38072,31 @@ function stripCallTypeArgs(text) {
38018
38072
  }
38019
38073
  return text;
38020
38074
  }
38021
- function emitTrackDeclStatement(g2, source, stmt, indent4, isLast, opts) {
38075
+ function emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts) {
38022
38076
  const fullText = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
38023
38077
  const text = fullText + (!fullText.endsWith("}") && !isLast ? ";" : "");
38024
38078
  const decls = stmt.declarations || [];
38025
- g2.add(indent4);
38079
+ g4.add(indent4);
38026
38080
  let prevEnd = stmt.start;
38027
38081
  for (let di = 0; di < decls.length; di++) {
38028
38082
  const decl = decls[di];
38029
38083
  const id = decl.id;
38030
38084
  const isLazy = id && id.type === "ArrayPattern" && id.lazy === true && decl.init;
38031
38085
  if (!isLazy) {
38032
- g2.addRaw(source.slice(prevEnd, decl.start));
38033
- g2.add(source.slice(decl.start, decl.end), decl.start, decl.end);
38086
+ g4.addRaw(source.slice(prevEnd, decl.start));
38087
+ g4.add(source.slice(decl.start, decl.end), decl.start, decl.end);
38034
38088
  prevEnd = decl.end;
38035
38089
  continue;
38036
38090
  }
38037
- if (di > 0) g2.addRaw(source.slice(prevEnd, decl.start));
38091
+ if (di > 0) g4.addRaw(source.slice(prevEnd, decl.start));
38038
38092
  const ch = text[decl.end - stmt.start] ?? " ";
38039
38093
  const elements = id.elements || [];
38040
38094
  const names = elements.map((el) => el ? el.name : null).filter((n) => typeof n === "string");
38041
38095
  const initText = source.slice(decl.init.start, decl.init.end);
38042
38096
  if (names.length === 0) {
38043
- g2.add("let _ = ");
38044
- g2.add(initText, decl.init.start, decl.init.end);
38045
- if (ch !== ";") g2.addRaw(";");
38097
+ g4.add("let _ = ");
38098
+ g4.add(initText, decl.init.start, decl.init.end);
38099
+ if (ch !== ";") g4.addRaw(";");
38046
38100
  prevEnd = decl.end;
38047
38101
  continue;
38048
38102
  }
@@ -38053,133 +38107,133 @@ function emitTrackDeclStatement(g2, source, stmt, indent4, isLast, opts) {
38053
38107
  const firstRange = [elements[0].start, elements[0].end];
38054
38108
  const dropLastSemi = ch === ";";
38055
38109
  if (opts.typedCells) {
38056
- const cellName = g2.cellCount === 0 ? "__cell" : `__cell${g2.cellCount}`;
38057
- g2.cellCount++;
38110
+ const cellName = g4.cellCount === 0 ? "__cell" : `__cell${g4.cellCount}`;
38111
+ g4.cellCount++;
38058
38112
  if (annotation) {
38059
- g2.add(`const ${cellName}: Tracked<`);
38060
- g2.add(annotation, annStart, annEnd);
38061
- g2.add("> = ");
38113
+ g4.add(`const ${cellName}: Tracked<`);
38114
+ g4.add(annotation, annStart, annEnd);
38115
+ g4.add("> = ");
38062
38116
  } else {
38063
- g2.add(`const ${cellName} = `);
38117
+ g4.add(`const ${cellName} = `);
38064
38118
  }
38065
38119
  const cellInit = annotation ? stripCallTypeArgs(initText) : initText;
38066
- g2.add(cellInit, decl.init.start, decl.init.end);
38067
- g2.add(";");
38068
- g2.add(" let ");
38069
- g2.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
38120
+ g4.add(cellInit, decl.init.start, decl.init.end);
38121
+ g4.add(";");
38122
+ g4.add(" let ");
38123
+ g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
38070
38124
  if (annotation) {
38071
- g2.add(": ");
38072
- g2.add(annotation, annStart, annEnd);
38125
+ g4.add(": ");
38126
+ g4.add(annotation, annStart, annEnd);
38073
38127
  }
38074
- g2.add(` = ${cellName}.get();`);
38128
+ g4.add(` = ${cellName}.get();`);
38075
38129
  for (let n = 1; n < names.length; n++) {
38076
- g2.add(" let ");
38077
- g2.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
38078
- g2.add(` = ${cellName};`);
38130
+ g4.add(" let ");
38131
+ g4.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
38132
+ g4.add(` = ${cellName};`);
38079
38133
  }
38080
- if (dropLastSemi) g2.code = g2.code.slice(0, -1);
38134
+ if (dropLastSemi) g4.code = g4.code.slice(0, -1);
38081
38135
  } else {
38082
38136
  if (annotation) {
38083
- g2.add("let ");
38084
- g2.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
38085
- g2.add(": ");
38086
- g2.add(annotation, annStart, annEnd);
38087
- g2.add(" = (");
38088
- g2.add(stripCallTypeArgs(initText), decl.init.start, decl.init.end);
38089
- g2.add(" as unknown as ");
38090
- g2.add(annotation, annStart, annEnd);
38091
- g2.add(");");
38137
+ g4.add("let ");
38138
+ g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
38139
+ g4.add(": ");
38140
+ g4.add(annotation, annStart, annEnd);
38141
+ g4.add(" = (");
38142
+ g4.add(stripCallTypeArgs(initText), decl.init.start, decl.init.end);
38143
+ g4.add(" as unknown as ");
38144
+ g4.add(annotation, annStart, annEnd);
38145
+ g4.add(");");
38092
38146
  } else {
38093
- const cellName = g2.cellCount === 0 ? "__cell" : `__cell${g2.cellCount}`;
38094
- g2.cellCount++;
38095
- g2.add(`const ${cellName} = `);
38096
- g2.add(initText, decl.init.start, decl.init.end);
38097
- g2.add("; let ");
38098
- g2.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
38099
- g2.add(` = ${cellName}.get();`);
38147
+ const cellName = g4.cellCount === 0 ? "__cell" : `__cell${g4.cellCount}`;
38148
+ g4.cellCount++;
38149
+ g4.add(`const ${cellName} = `);
38150
+ g4.add(initText, decl.init.start, decl.init.end);
38151
+ g4.add("; let ");
38152
+ g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
38153
+ g4.add(` = ${cellName}.get();`);
38100
38154
  }
38101
38155
  for (let n = 1; n < names.length; n++) {
38102
- g2.add(" let ");
38103
- g2.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
38104
- g2.add(": any = ");
38105
- g2.add(first, firstRange[0], firstRange[1]);
38106
- g2.add(";");
38107
- if (n === names.length - 1 && dropLastSemi) g2.code = g2.code.slice(0, -1);
38156
+ g4.add(" let ");
38157
+ g4.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
38158
+ g4.add(": any = ");
38159
+ g4.add(first, firstRange[0], firstRange[1]);
38160
+ g4.add(";");
38161
+ if (n === names.length - 1 && dropLastSemi) g4.code = g4.code.slice(0, -1);
38108
38162
  }
38109
- if (names.length === 1 && dropLastSemi) g2.code = g2.code.slice(0, -1);
38163
+ if (names.length === 1 && dropLastSemi) g4.code = g4.code.slice(0, -1);
38110
38164
  }
38111
38165
  prevEnd = decl.end;
38112
38166
  }
38113
- if (!isLast) g2.addRaw(";");
38167
+ if (!isLast) g4.addRaw(";");
38114
38168
  }
38115
- function emitBlock(g2, source, body, indent4, opts) {
38169
+ function emitBlock(g4, source, body, indent4, opts) {
38116
38170
  const stmts = body && body.type === "BlockStatement" ? body.body : body ? Array.isArray(body) ? body : [body] : [];
38117
- g2.addRaw("{\n");
38118
- emitBody(g2, source, stmts, indent4 + " ", opts);
38119
- g2.addRaw("\n");
38120
- g2.add(indent4);
38121
- g2.addRaw("}");
38171
+ g4.addRaw("{\n");
38172
+ emitBody(g4, source, stmts, indent4 + " ", opts);
38173
+ g4.addRaw("\n");
38174
+ g4.add(indent4);
38175
+ g4.addRaw("}");
38122
38176
  }
38123
- function emitJSXAttr(g2, source, attr) {
38177
+ function emitJSXAttr(g4, source, attr) {
38124
38178
  if (attr.type === "JSXSpreadAttribute") {
38125
- g2.add(source.slice(attr.start, attr.end), attr.start, attr.end);
38179
+ g4.add(source.slice(attr.start, attr.end), attr.start, attr.end);
38126
38180
  return;
38127
38181
  }
38128
38182
  const name = attr.name;
38129
- g2.add(source.slice(name.start, name.end), name.start, name.end);
38183
+ g4.add(source.slice(name.start, name.end), name.start, name.end);
38130
38184
  const v = attr.value;
38131
38185
  if (!v) return;
38132
- g2.add(source.slice(name.end, v.start), name.end, v.start);
38186
+ g4.add(source.slice(name.end, v.start), name.end, v.start);
38133
38187
  if (v.type === "JSXExpressionContainer") {
38134
- g2.add(source.slice(v.start, v.expression.start), v.start, v.expression.start);
38135
- g2.add(source.slice(v.expression.start, v.expression.end), v.expression.start, v.expression.end);
38136
- g2.add(source.slice(v.expression.end, v.end), v.expression.end, v.end);
38188
+ g4.add(source.slice(v.start, v.expression.start), v.start, v.expression.start);
38189
+ g4.add(source.slice(v.expression.start, v.expression.end), v.expression.start, v.expression.end);
38190
+ g4.add(source.slice(v.expression.end, v.end), v.expression.end, v.end);
38137
38191
  } else {
38138
- g2.add(source.slice(v.start, v.end), v.start, v.end);
38192
+ g4.add(source.slice(v.start, v.end), v.start, v.end);
38139
38193
  }
38140
38194
  }
38141
- function emitJSXElement(g2, source, el, opts, hoist) {
38195
+ function emitJSXElement(g4, source, el, opts, hoist) {
38142
38196
  const op = el.openingElement;
38143
38197
  const name = op.name;
38144
38198
  let prev;
38145
38199
  if (name) {
38146
- g2.add(source.slice(op.start, name.start), op.start, name.start);
38147
- g2.add(source.slice(name.start, name.end), name.start, name.end);
38200
+ g4.add(source.slice(op.start, name.start), op.start, name.start);
38201
+ g4.add(source.slice(name.start, name.end), name.start, name.end);
38148
38202
  prev = name.end;
38149
38203
  } else {
38150
38204
  prev = op.start + 1;
38151
38205
  }
38152
38206
  for (const attr of op.attributes ?? []) {
38153
- g2.add(source.slice(prev, attr.start), prev, attr.start);
38154
- emitJSXAttr(g2, source, attr);
38207
+ g4.add(source.slice(prev, attr.start), prev, attr.start);
38208
+ emitJSXAttr(g4, source, attr);
38155
38209
  prev = attr.end;
38156
38210
  }
38157
38211
  const tail = source.slice(prev, op.end);
38158
38212
  if (op.selfClosing && !tail.includes("/")) {
38159
38213
  const gt = tail.lastIndexOf(">");
38160
38214
  const head = gt === -1 ? tail : tail.slice(0, gt);
38161
- if (head) g2.add(head, prev, prev + head.length);
38162
- g2.addRaw("/>");
38215
+ if (head) g4.add(head, prev, prev + head.length);
38216
+ g4.addRaw("/>");
38163
38217
  } else {
38164
- g2.add(tail, prev, op.end);
38218
+ g4.add(tail, prev, op.end);
38165
38219
  }
38166
38220
  if (op.selfClosing) return;
38167
- emitJSXChildren(g2, source, el.children ?? [], opts, hoist);
38221
+ emitJSXChildren(g4, source, el.children ?? [], opts, hoist);
38168
38222
  if (el.closingElement) {
38169
- g2.add(source.slice(el.closingElement.start, el.closingElement.end), el.closingElement.start, el.closingElement.end);
38223
+ g4.add(source.slice(el.closingElement.start, el.closingElement.end), el.closingElement.start, el.closingElement.end);
38170
38224
  }
38171
38225
  }
38172
- function emitJSXExprBody(g2, source, expr, opts) {
38173
- if (expr.type === "JSXElement") return emitJSXElement(g2, source, expr, opts);
38174
- if (expr.type === "JSXFragment") return emitJSXFragment(g2, source, expr, opts);
38175
- g2.add(source.slice(expr.start, expr.end), expr.start, expr.end);
38226
+ function emitJSXExprBody(g4, source, expr, opts) {
38227
+ if (expr.type === "JSXElement") return emitJSXElement(g4, source, expr, opts);
38228
+ if (expr.type === "JSXFragment") return emitJSXFragment(g4, source, expr, opts);
38229
+ g4.add(source.slice(expr.start, expr.end), expr.start, expr.end);
38176
38230
  }
38177
- function emitJSXFragment(g2, source, frag, opts, hoist) {
38178
- g2.addRaw("<>");
38179
- emitJSXChildren(g2, source, frag.children ?? [], opts, hoist);
38180
- g2.addRaw("</>");
38231
+ function emitJSXFragment(g4, source, frag, opts, hoist) {
38232
+ g4.addRaw("<>");
38233
+ emitJSXChildren(g4, source, frag.children ?? [], opts, hoist);
38234
+ g4.addRaw("</>");
38181
38235
  }
38182
- function emitForClauseMap(g2, source, child, text, map, clauseStart, bodyEmit, emptyEmit) {
38236
+ function emitForClauseMap(g4, source, child, text, map, clauseStart, bodyEmit, emptyEmit) {
38183
38237
  const clauseEnd = findBalancedEnd(text, clauseStart - 1);
38184
38238
  const clause = text.slice(clauseStart, clauseEnd);
38185
38239
  const ofIdx = findTopLevelSep(clause, "of");
@@ -38196,38 +38250,38 @@ function emitForClauseMap(g2, source, child, text, map, clauseStart, bodyEmit, e
38196
38250
  const itemVar = stripDeclKeyword(lhs).trim();
38197
38251
  if (ofIdx !== -1) {
38198
38252
  if (emptyEmit) {
38199
- g2.addRaw("{ (() => { const _v = ");
38200
- g2.add(arrExpr, arrStart, arrEnd);
38201
- g2.addRaw("; return _v.length === 0 ? (");
38253
+ g4.addRaw("{ (() => { const _v = ");
38254
+ g4.add(arrExpr, arrStart, arrEnd);
38255
+ g4.addRaw("; return _v.length === 0 ? (");
38202
38256
  emptyEmit();
38203
- g2.addRaw(") : _v.map((");
38204
- g2.addRaw(itemVar);
38205
- g2.addRaw(": (typeof _v)[number]) => (");
38257
+ g4.addRaw(") : _v.map((");
38258
+ g4.addRaw(itemVar);
38259
+ g4.addRaw(": (typeof _v)[number]) => (");
38206
38260
  bodyEmit();
38207
- g2.addRaw(")); })() }");
38261
+ g4.addRaw(")); })() }");
38208
38262
  } else {
38209
- g2.addRaw("{ ");
38210
- g2.add(arrExpr, arrStart, arrEnd);
38211
- g2.addRaw(".map((");
38212
- g2.addRaw(itemVar);
38213
- g2.addRaw(": (typeof ");
38214
- g2.add(arrExpr, arrStart, arrEnd);
38215
- g2.addRaw(")[number]) => (");
38263
+ g4.addRaw("{ ");
38264
+ g4.add(arrExpr, arrStart, arrEnd);
38265
+ g4.addRaw(".map((");
38266
+ g4.addRaw(itemVar);
38267
+ g4.addRaw(": (typeof ");
38268
+ g4.add(arrExpr, arrStart, arrEnd);
38269
+ g4.addRaw(")[number]) => (");
38216
38270
  bodyEmit();
38217
- g2.addRaw(")) }");
38271
+ g4.addRaw(")) }");
38218
38272
  }
38219
38273
  } else {
38220
- g2.addRaw("{ Object.keys(");
38221
- g2.add(arrExpr, arrStart, arrEnd);
38222
- g2.addRaw(").map((");
38223
- g2.addRaw(itemVar);
38224
- g2.addRaw(") => (");
38274
+ g4.addRaw("{ Object.keys(");
38275
+ g4.add(arrExpr, arrStart, arrEnd);
38276
+ g4.addRaw(").map((");
38277
+ g4.addRaw(itemVar);
38278
+ g4.addRaw(") => (");
38225
38279
  bodyEmit();
38226
- g2.addRaw(")) }");
38280
+ g4.addRaw(")) }");
38227
38281
  }
38228
38282
  return true;
38229
38283
  }
38230
- function emitJSXChildren(g2, source, children, opts, hoist) {
38284
+ function emitJSXChildren(g4, source, children, opts, hoist) {
38231
38285
  let i = 0;
38232
38286
  let forPending = false;
38233
38287
  while (i < children.length) {
@@ -38253,46 +38307,46 @@ function emitJSXChildren(g2, source, children, opts, hoist) {
38253
38307
  const emptyContainer = children[i + 3];
38254
38308
  if (emptyTextNode && emptyTextNode.type === "JSXText" && ["#empty", "empty"].includes(emptyTextNode.value.trim()) && emptyContainer && emptyContainer.type === "JSXExpressionContainer" && emptyContainer.expression.type !== "JSXEmptyExpression") {
38255
38309
  consumed = 4;
38256
- emptyEmit = () => emitJSXExprBody(g2, source, emptyContainer.expression, opts);
38310
+ emptyEmit = () => emitJSXExprBody(g4, source, emptyContainer.expression, opts);
38257
38311
  }
38258
38312
  let matched = false;
38259
38313
  if (nextChild.type === "JSXExpressionContainer") {
38260
38314
  const exprNode = nextChild.expression;
38261
38315
  if (exprNode.type === "JSXEmptyExpression") {
38262
- g2.add(text, child.start, child.end);
38316
+ g4.add(text, child.start, child.end);
38263
38317
  i++;
38264
38318
  continue;
38265
38319
  }
38266
38320
  matched = emitForClauseMap(
38267
- g2,
38321
+ g4,
38268
38322
  source,
38269
38323
  child,
38270
38324
  text,
38271
38325
  map,
38272
38326
  clauseStartCollapsed,
38273
- () => emitJSXExprBody(g2, source, exprNode, opts),
38327
+ () => emitJSXExprBody(g4, source, exprNode, opts),
38274
38328
  emptyEmit
38275
38329
  );
38276
38330
  } else if (nextChild.type === "JSXFragment") {
38277
38331
  matched = emitForClauseMap(
38278
- g2,
38332
+ g4,
38279
38333
  source,
38280
38334
  child,
38281
38335
  text,
38282
38336
  map,
38283
38337
  clauseStartCollapsed,
38284
- () => emitJSXFragment(g2, source, nextChild, opts),
38338
+ () => emitJSXFragment(g4, source, nextChild, opts),
38285
38339
  emptyEmit
38286
38340
  );
38287
38341
  } else {
38288
38342
  matched = emitForClauseMap(
38289
- g2,
38343
+ g4,
38290
38344
  source,
38291
38345
  child,
38292
38346
  text,
38293
38347
  map,
38294
38348
  clauseStartCollapsed,
38295
- () => emitJSXElement(g2, source, nextChild, opts),
38349
+ () => emitJSXElement(g4, source, nextChild, opts),
38296
38350
  emptyEmit
38297
38351
  );
38298
38352
  }
@@ -38309,184 +38363,184 @@ function emitJSXChildren(g2, source, children, opts, hoist) {
38309
38363
  continue;
38310
38364
  }
38311
38365
  forPending = false;
38312
- emitJSXText(g2, text, child.start, child.end);
38366
+ emitJSXText(g4, text, child.start, child.end);
38313
38367
  i++;
38314
38368
  } else if (child.type === "JSXExpressionContainer") {
38315
38369
  if (child.expression.type === "JSXEmptyExpression") {
38316
38370
  i++;
38317
38371
  continue;
38318
38372
  }
38319
- g2.addRaw("{");
38320
- g2.add(source.slice(child.expression.start, child.expression.end), child.expression.start, child.expression.end);
38321
- g2.addRaw("}");
38373
+ g4.addRaw("{");
38374
+ g4.add(source.slice(child.expression.start, child.expression.end), child.expression.start, child.expression.end);
38375
+ g4.addRaw("}");
38322
38376
  i++;
38323
38377
  } else if (child.type === "JSXElement") {
38324
38378
  if (getJSXTagName2(child) === "style") {
38325
38379
  const openEnd = child.openingElement?.end ?? child.start;
38326
38380
  const closeStart = child.closingElement?.start ?? child.end;
38327
- g2.recordStyle(child.start, child.end, source.slice(openEnd, closeStart));
38381
+ g4.recordStyle(child.start, child.end, source.slice(openEnd, closeStart));
38328
38382
  i++;
38329
38383
  continue;
38330
38384
  }
38331
- emitJSXElement(g2, source, child, opts, hoist);
38385
+ emitJSXElement(g4, source, child, opts, hoist);
38332
38386
  i++;
38333
38387
  } else if (child.type === "JSXFragment") {
38334
- emitJSXFragment(g2, source, child, opts, hoist);
38388
+ emitJSXFragment(g4, source, child, opts, hoist);
38335
38389
  i++;
38336
38390
  } else if (child.type === "IfStatement" || child.type === "ForOfStatement" || child.type === "ForStatement" || child.type === "ForInStatement" || child.type === "WhileStatement" || child.type === "DoWhileStatement" || child.type === "SwitchStatement" || child.type === "TryStatement" || child.type === "VariableDeclaration" || child.type === "ExpressionStatement") {
38337
38391
  if (hoist && hoist.set.has(child)) {
38338
38392
  i++;
38339
38393
  continue;
38340
38394
  }
38341
- g2.addRaw("{(() => { ");
38342
- emitBody(g2, source, [child], "", opts);
38343
- g2.addRaw(" })()}");
38395
+ g4.addRaw("{(() => { ");
38396
+ emitBody(g4, source, [child], "", opts);
38397
+ g4.addRaw(" })()}");
38344
38398
  i++;
38345
38399
  } else {
38346
38400
  i++;
38347
38401
  }
38348
38402
  }
38349
38403
  }
38350
- function emitIf(g2, source, stmt, indent4, opts) {
38351
- g2.add(indent4);
38352
- g2.addRaw("if (");
38353
- g2.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38354
- g2.addRaw(") ");
38355
- emitBlock(g2, source, stmt.consequent, indent4, opts);
38404
+ function emitIf(g4, source, stmt, indent4, opts) {
38405
+ g4.add(indent4);
38406
+ g4.addRaw("if (");
38407
+ g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38408
+ g4.addRaw(") ");
38409
+ emitBlock(g4, source, stmt.consequent, indent4, opts);
38356
38410
  if (stmt.alternate) {
38357
- g2.addRaw(" else ");
38358
- emitBlock(g2, source, stmt.alternate, indent4, opts);
38411
+ g4.addRaw(" else ");
38412
+ emitBlock(g4, source, stmt.alternate, indent4, opts);
38359
38413
  }
38360
38414
  }
38361
- function emitLoopVariable(g2, source, left) {
38415
+ function emitLoopVariable(g4, source, left) {
38362
38416
  if (left && left.type === "Identifier") {
38363
- g2.addRaw("const ");
38364
- g2.add(source.slice(left.start, left.end), left.start, left.end);
38417
+ g4.addRaw("const ");
38418
+ g4.add(source.slice(left.start, left.end), left.start, left.end);
38365
38419
  return;
38366
38420
  }
38367
- g2.add(source.slice(left.start, left.end), left.start, left.end);
38368
- }
38369
- function emitForOf(g2, source, stmt, indent4, opts) {
38370
- g2.add(indent4);
38371
- g2.addRaw("for (");
38372
- emitLoopVariable(g2, source, stmt.left);
38373
- g2.addRaw(" of ");
38374
- g2.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
38375
- g2.addRaw(") ");
38376
- emitBlock(g2, source, stmt.body, indent4, opts);
38377
- }
38378
- function emitForIn(g2, source, stmt, indent4, opts) {
38379
- g2.add(indent4);
38380
- g2.addRaw("for (");
38381
- emitLoopVariable(g2, source, stmt.left);
38382
- g2.addRaw(" in ");
38383
- g2.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
38384
- g2.addRaw(") ");
38385
- emitBlock(g2, source, stmt.body, indent4, opts);
38386
- }
38387
- function emitFor(g2, source, stmt, indent4, opts) {
38388
- g2.add(indent4);
38389
- g2.addRaw("for (");
38390
- if (stmt.init) g2.add(source.slice(stmt.init.start, stmt.init.end), stmt.init.start, stmt.init.end);
38391
- g2.addRaw("; ");
38392
- if (stmt.test) g2.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38393
- g2.addRaw("; ");
38394
- if (stmt.update) g2.add(source.slice(stmt.update.start, stmt.update.end), stmt.update.start, stmt.update.end);
38395
- g2.addRaw(") ");
38396
- emitBlock(g2, source, stmt.body, indent4, opts);
38397
- }
38398
- function emitWhile(g2, source, stmt, indent4, opts) {
38399
- g2.add(indent4);
38400
- g2.addRaw("while (");
38401
- g2.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38402
- g2.addRaw(") ");
38403
- emitBlock(g2, source, stmt.body, indent4, opts);
38404
- }
38405
- function emitDoWhile(g2, source, stmt, indent4, opts) {
38406
- g2.add(indent4);
38407
- g2.addRaw("do ");
38408
- emitBlock(g2, source, stmt.body, indent4, opts);
38409
- g2.addRaw(" while (");
38410
- g2.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38411
- g2.addRaw(");");
38412
- }
38413
- function emitSwitch(g2, source, stmt, indent4, opts) {
38414
- g2.add(indent4);
38415
- g2.addRaw("switch (");
38416
- g2.add(source.slice(stmt.discriminant.start, stmt.discriminant.end), stmt.discriminant.start, stmt.discriminant.end);
38417
- g2.addRaw(") {");
38421
+ g4.add(source.slice(left.start, left.end), left.start, left.end);
38422
+ }
38423
+ function emitForOf(g4, source, stmt, indent4, opts) {
38424
+ g4.add(indent4);
38425
+ g4.addRaw("for (");
38426
+ emitLoopVariable(g4, source, stmt.left);
38427
+ g4.addRaw(" of ");
38428
+ g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
38429
+ g4.addRaw(") ");
38430
+ emitBlock(g4, source, stmt.body, indent4, opts);
38431
+ }
38432
+ function emitForIn(g4, source, stmt, indent4, opts) {
38433
+ g4.add(indent4);
38434
+ g4.addRaw("for (");
38435
+ emitLoopVariable(g4, source, stmt.left);
38436
+ g4.addRaw(" in ");
38437
+ g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
38438
+ g4.addRaw(") ");
38439
+ emitBlock(g4, source, stmt.body, indent4, opts);
38440
+ }
38441
+ function emitFor(g4, source, stmt, indent4, opts) {
38442
+ g4.add(indent4);
38443
+ g4.addRaw("for (");
38444
+ if (stmt.init) g4.add(source.slice(stmt.init.start, stmt.init.end), stmt.init.start, stmt.init.end);
38445
+ g4.addRaw("; ");
38446
+ if (stmt.test) g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38447
+ g4.addRaw("; ");
38448
+ if (stmt.update) g4.add(source.slice(stmt.update.start, stmt.update.end), stmt.update.start, stmt.update.end);
38449
+ g4.addRaw(") ");
38450
+ emitBlock(g4, source, stmt.body, indent4, opts);
38451
+ }
38452
+ function emitWhile(g4, source, stmt, indent4, opts) {
38453
+ g4.add(indent4);
38454
+ g4.addRaw("while (");
38455
+ g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38456
+ g4.addRaw(") ");
38457
+ emitBlock(g4, source, stmt.body, indent4, opts);
38458
+ }
38459
+ function emitDoWhile(g4, source, stmt, indent4, opts) {
38460
+ g4.add(indent4);
38461
+ g4.addRaw("do ");
38462
+ emitBlock(g4, source, stmt.body, indent4, opts);
38463
+ g4.addRaw(" while (");
38464
+ g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
38465
+ g4.addRaw(");");
38466
+ }
38467
+ function emitSwitch(g4, source, stmt, indent4, opts) {
38468
+ g4.add(indent4);
38469
+ g4.addRaw("switch (");
38470
+ g4.add(source.slice(stmt.discriminant.start, stmt.discriminant.end), stmt.discriminant.start, stmt.discriminant.end);
38471
+ g4.addRaw(") {");
38418
38472
  let firstCase = true;
38419
38473
  for (const c of stmt.cases ?? []) {
38420
- g2.addRaw(firstCase ? "\n" : "\n");
38474
+ g4.addRaw(firstCase ? "\n" : "\n");
38421
38475
  firstCase = false;
38422
- g2.add(indent4);
38423
- g2.addRaw(" ");
38476
+ g4.add(indent4);
38477
+ g4.addRaw(" ");
38424
38478
  if (c.test) {
38425
- g2.addRaw("case ");
38426
- g2.add(source.slice(c.test.start, c.test.end), c.test.start, c.test.end);
38427
- g2.addRaw(":");
38479
+ g4.addRaw("case ");
38480
+ g4.add(source.slice(c.test.start, c.test.end), c.test.start, c.test.end);
38481
+ g4.addRaw(":");
38428
38482
  } else {
38429
- g2.addRaw("default:");
38483
+ g4.addRaw("default:");
38430
38484
  }
38431
- const before = g2.code.length;
38432
- emitBody(g2, source, c.consequent, indent4 + " ", opts);
38433
- if (g2.code.length > before) g2.addRaw("\n");
38485
+ const before = g4.code.length;
38486
+ emitBody(g4, source, c.consequent, indent4 + " ", opts);
38487
+ if (g4.code.length > before) g4.addRaw("\n");
38434
38488
  }
38435
- g2.addRaw("\n");
38436
- g2.add(indent4);
38437
- g2.addRaw("}");
38489
+ g4.addRaw("\n");
38490
+ g4.add(indent4);
38491
+ g4.addRaw("}");
38438
38492
  }
38439
- function emitTry(g2, source, stmt, indent4, opts) {
38440
- g2.add(indent4);
38441
- g2.addRaw("try ");
38442
- emitBlock(g2, source, stmt.block, indent4, opts);
38493
+ function emitTry(g4, source, stmt, indent4, opts) {
38494
+ g4.add(indent4);
38495
+ g4.addRaw("try ");
38496
+ emitBlock(g4, source, stmt.block, indent4, opts);
38443
38497
  if (stmt.handler) {
38444
- g2.addRaw(" catch");
38498
+ g4.addRaw(" catch");
38445
38499
  if (stmt.handler.param) {
38446
- g2.addRaw(" (");
38447
- g2.add(source.slice(stmt.handler.param.start, stmt.handler.param.end), stmt.handler.param.start, stmt.handler.param.end);
38448
- g2.addRaw(")");
38500
+ g4.addRaw(" (");
38501
+ g4.add(source.slice(stmt.handler.param.start, stmt.handler.param.end), stmt.handler.param.start, stmt.handler.param.end);
38502
+ g4.addRaw(")");
38449
38503
  }
38450
- g2.addRaw(" ");
38451
- emitBlock(g2, source, stmt.handler.body, indent4, opts);
38504
+ g4.addRaw(" ");
38505
+ emitBlock(g4, source, stmt.handler.body, indent4, opts);
38452
38506
  }
38453
38507
  if (stmt.finalizer) {
38454
- g2.addRaw(" finally ");
38455
- emitBlock(g2, source, stmt.finalizer, indent4, opts);
38508
+ g4.addRaw(" finally ");
38509
+ emitBlock(g4, source, stmt.finalizer, indent4, opts);
38456
38510
  }
38457
38511
  }
38458
- function emitPlainStatement(g2, source, stmt, indent4, isLast) {
38512
+ function emitPlainStatement(g4, source, stmt, indent4, isLast) {
38459
38513
  let text = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
38460
38514
  if (text === "") return;
38461
- g2.add(indent4);
38462
- g2.add(text, stmt.start, stmt.end);
38463
- if (!text.endsWith("}") && !isLast) g2.addRaw(";");
38515
+ g4.add(indent4);
38516
+ g4.add(text, stmt.start, stmt.end);
38517
+ if (!text.endsWith("}") && !isLast) g4.addRaw(";");
38464
38518
  }
38465
- function emitStatement(g2, source, stmt, indent4, isLast, opts, hoist) {
38519
+ function emitStatement(g4, source, stmt, indent4, isLast, opts, hoist) {
38466
38520
  switch (stmt.type) {
38467
38521
  case "JSXElement":
38468
38522
  if (getJSXTagName2(stmt) === "style") {
38469
38523
  const openEnd = stmt.openingElement?.end ?? stmt.start;
38470
38524
  const closeStart = stmt.closingElement?.start ?? stmt.end;
38471
- g2.recordStyle(stmt.start, stmt.end, source.slice(openEnd, closeStart));
38525
+ g4.recordStyle(stmt.start, stmt.end, source.slice(openEnd, closeStart));
38472
38526
  return;
38473
38527
  }
38474
- g2.add(indent4);
38475
- emitJSXElement(g2, source, stmt, opts, hoist);
38476
- if (!isLast) g2.addRaw(";");
38528
+ g4.add(indent4);
38529
+ emitJSXElement(g4, source, stmt, opts, hoist);
38530
+ if (!isLast) g4.addRaw(";");
38477
38531
  return;
38478
38532
  case "JSXFragment":
38479
- g2.add(indent4);
38480
- emitJSXFragment(g2, source, stmt, opts, hoist);
38481
- if (!isLast) g2.addRaw(";");
38533
+ g4.add(indent4);
38534
+ emitJSXFragment(g4, source, stmt, opts, hoist);
38535
+ if (!isLast) g4.addRaw(";");
38482
38536
  return;
38483
38537
  case "JSXExpressionContainer": {
38484
38538
  if (stmt.expression.type === "JSXEmptyExpression") return;
38485
- g2.add(indent4);
38486
- g2.addRaw("{");
38487
- g2.add(source.slice(stmt.expression.start, stmt.expression.end), stmt.expression.start, stmt.expression.end);
38488
- g2.addRaw("}");
38489
- if (!isLast) g2.addRaw(";");
38539
+ g4.add(indent4);
38540
+ g4.addRaw("{");
38541
+ g4.add(source.slice(stmt.expression.start, stmt.expression.end), stmt.expression.start, stmt.expression.end);
38542
+ g4.addRaw("}");
38543
+ if (!isLast) g4.addRaw(";");
38490
38544
  return;
38491
38545
  }
38492
38546
  case "VeskBlock": {
@@ -38494,10 +38548,10 @@ function emitStatement(g2, source, stmt, indent4, isLast, opts, hoist) {
38494
38548
  const innerStmts = stmt.body ?? [];
38495
38549
  let firstLine = true;
38496
38550
  for (let i = 0; i < innerStmts.length; i++) {
38497
- const before = g2.code.length;
38498
- emitStatement(g2, source, innerStmts[i], indent4, isLast && i === innerStmts.length - 1, opts, hoist);
38499
- if (g2.code.length > before) {
38500
- if (!firstLine) g2.addRaw("\n");
38551
+ const before = g4.code.length;
38552
+ emitStatement(g4, source, innerStmts[i], indent4, isLast && i === innerStmts.length - 1, opts, hoist);
38553
+ if (g4.code.length > before) {
38554
+ if (!firstLine) g4.addRaw("\n");
38501
38555
  firstLine = false;
38502
38556
  }
38503
38557
  }
@@ -38505,38 +38559,38 @@ function emitStatement(g2, source, stmt, indent4, isLast, opts, hoist) {
38505
38559
  }
38506
38560
  case "VariableDeclaration":
38507
38561
  if (isTrackDeclStatement(stmt)) {
38508
- emitTrackDeclStatement(g2, source, stmt, indent4, isLast, opts);
38562
+ emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts);
38509
38563
  return;
38510
38564
  }
38511
- return emitPlainStatement(g2, source, stmt, indent4, isLast);
38565
+ return emitPlainStatement(g4, source, stmt, indent4, isLast);
38512
38566
  case "IfStatement":
38513
- return emitIf(g2, source, stmt, indent4, opts);
38567
+ return emitIf(g4, source, stmt, indent4, opts);
38514
38568
  case "ForOfStatement":
38515
- return emitForOf(g2, source, stmt, indent4, opts);
38569
+ return emitForOf(g4, source, stmt, indent4, opts);
38516
38570
  case "ForInStatement":
38517
- return emitForIn(g2, source, stmt, indent4, opts);
38571
+ return emitForIn(g4, source, stmt, indent4, opts);
38518
38572
  case "ForStatement":
38519
- return emitFor(g2, source, stmt, indent4, opts);
38573
+ return emitFor(g4, source, stmt, indent4, opts);
38520
38574
  case "WhileStatement":
38521
- return emitWhile(g2, source, stmt, indent4, opts);
38575
+ return emitWhile(g4, source, stmt, indent4, opts);
38522
38576
  case "DoWhileStatement":
38523
- return emitDoWhile(g2, source, stmt, indent4, opts);
38577
+ return emitDoWhile(g4, source, stmt, indent4, opts);
38524
38578
  case "SwitchStatement":
38525
- return emitSwitch(g2, source, stmt, indent4, opts);
38579
+ return emitSwitch(g4, source, stmt, indent4, opts);
38526
38580
  case "TryStatement":
38527
- return emitTry(g2, source, stmt, indent4, opts);
38581
+ return emitTry(g4, source, stmt, indent4, opts);
38528
38582
  case "LabeledStatement": {
38529
- g2.add(indent4);
38530
- g2.add(stmt.label.name, stmt.label.start, stmt.label.end);
38531
- g2.addRaw(":\n");
38532
- emitStatement(g2, source, stmt.body, indent4, isLast, opts);
38583
+ g4.add(indent4);
38584
+ g4.add(stmt.label.name, stmt.label.start, stmt.label.end);
38585
+ g4.addRaw(":\n");
38586
+ emitStatement(g4, source, stmt.body, indent4, isLast, opts);
38533
38587
  return;
38534
38588
  }
38535
38589
  default:
38536
- return emitPlainStatement(g2, source, stmt, indent4, isLast);
38590
+ return emitPlainStatement(g4, source, stmt, indent4, isLast);
38537
38591
  }
38538
38592
  }
38539
- function emitBody(g2, source, stmts, indent4, opts, hoist) {
38593
+ function emitBody(g4, source, stmts, indent4, opts, hoist) {
38540
38594
  let firstLine = true;
38541
38595
  let i = 0;
38542
38596
  while (i < stmts.length) {
@@ -38544,34 +38598,34 @@ function emitBody(g2, source, stmts, indent4, opts, hoist) {
38544
38598
  const isLast = i === stmts.length - 1;
38545
38599
  if (stmt.type === "ForOfStatement" && stmts[i + 1] && stmts[i + 1].type === "VeskBlock" && stmts[i + 1].tag === "empty") {
38546
38600
  const empty2 = stmts[i + 1];
38547
- if (!firstLine) g2.addRaw("\n");
38601
+ if (!firstLine) g4.addRaw("\n");
38548
38602
  firstLine = false;
38549
- emitForOf(g2, source, stmt, indent4, opts);
38603
+ emitForOf(g4, source, stmt, indent4, opts);
38550
38604
  const inner = empty2.body ?? [];
38551
38605
  if (inner.length > 0) {
38552
- g2.addRaw("\n");
38553
- g2.add(indent4);
38554
- g2.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
38555
- g2.addRaw(".length === 0 && (() => {");
38556
- g2.addRaw("\n");
38557
- emitBody(g2, source, inner, indent4 + " ", opts);
38558
- g2.addRaw("\n");
38559
- g2.add(indent4);
38560
- g2.addRaw("})();");
38606
+ g4.addRaw("\n");
38607
+ g4.add(indent4);
38608
+ g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
38609
+ g4.addRaw(".length === 0 && (() => {");
38610
+ g4.addRaw("\n");
38611
+ emitBody(g4, source, inner, indent4 + " ", opts);
38612
+ g4.addRaw("\n");
38613
+ g4.add(indent4);
38614
+ g4.addRaw("})();");
38561
38615
  }
38562
38616
  i += 2;
38563
38617
  continue;
38564
38618
  }
38565
- const before = g2.code.length;
38566
- emitStatement(g2, source, stmt, indent4, isLast, opts, hoist);
38567
- if (g2.code.length > before) {
38568
- if (!firstLine) g2.addRaw("\n");
38619
+ const before = g4.code.length;
38620
+ emitStatement(g4, source, stmt, indent4, isLast, opts, hoist);
38621
+ if (g4.code.length > before) {
38622
+ if (!firstLine) g4.addRaw("\n");
38569
38623
  firstLine = false;
38570
38624
  }
38571
38625
  i++;
38572
38626
  }
38573
38627
  }
38574
- function emitChunkMapped(g2, source, start, end) {
38628
+ function emitChunkMapped(g4, source, start, end) {
38575
38629
  if (end <= start) return;
38576
38630
  let pos = start;
38577
38631
  let i = start;
@@ -38583,8 +38637,8 @@ function emitChunkMapped(g2, source, start, end) {
38583
38637
  if (openEnd !== -1 && openEnd <= end) {
38584
38638
  const closeIdx = source.indexOf("</style>", openEnd);
38585
38639
  if (closeIdx !== -1 && closeIdx + 8 <= end) {
38586
- g2.add(source.slice(pos, i), pos, i);
38587
- g2.recordStyle(i, closeIdx + 8, source.slice(openEnd, closeIdx));
38640
+ g4.add(source.slice(pos, i), pos, i);
38641
+ g4.recordStyle(i, closeIdx + 8, source.slice(openEnd, closeIdx));
38588
38642
  pos = closeIdx + 8;
38589
38643
  i = closeIdx + 8;
38590
38644
  continue;
@@ -38594,20 +38648,20 @@ function emitChunkMapped(g2, source, start, end) {
38594
38648
  }
38595
38649
  i++;
38596
38650
  }
38597
- g2.add(source.slice(pos, end), pos, end);
38651
+ g4.add(source.slice(pos, end), pos, end);
38598
38652
  }
38599
- function emitReturn(g2, source, stmt, opts) {
38600
- g2.add(source.slice(stmt.start, stmt.start + 6), stmt.start, stmt.start + 6);
38653
+ function emitReturn(g4, source, stmt, opts) {
38654
+ g4.add(source.slice(stmt.start, stmt.start + 6), stmt.start, stmt.start + 6);
38601
38655
  const arg = stmt.argument;
38602
38656
  if (!arg) {
38603
- emitChunkMapped(g2, source, stmt.start + 6, stmt.end);
38657
+ emitChunkMapped(g4, source, stmt.start + 6, stmt.end);
38604
38658
  return;
38605
38659
  }
38606
- emitChunkMapped(g2, source, stmt.start + 6, arg.start);
38607
- if (arg.type === "JSXElement") emitJSXElement(g2, source, arg, opts);
38608
- else if (arg.type === "JSXFragment") emitJSXFragment(g2, source, arg, opts);
38609
- else emitChunkMapped(g2, source, arg.start, arg.end);
38610
- emitChunkMapped(g2, source, arg.end, stmt.end);
38660
+ emitChunkMapped(g4, source, stmt.start + 6, arg.start);
38661
+ if (arg.type === "JSXElement") emitJSXElement(g4, source, arg, opts);
38662
+ else if (arg.type === "JSXFragment") emitJSXFragment(g4, source, arg, opts);
38663
+ else emitChunkMapped(g4, source, arg.start, arg.end);
38664
+ emitChunkMapped(g4, source, arg.end, stmt.end);
38611
38665
  }
38612
38666
  function collectHoistEligible(children, set2, list) {
38613
38667
  for (const child of children ?? []) {
@@ -38627,7 +38681,7 @@ function collectHoistEligible(children, set2, list) {
38627
38681
  }
38628
38682
  }
38629
38683
  }
38630
- function emitBodyCore(g2, source, stmts, opts) {
38684
+ function emitBodyCore(g4, source, stmts, opts) {
38631
38685
  const hoistSet = /* @__PURE__ */ new Set();
38632
38686
  const byRoot = /* @__PURE__ */ new Map();
38633
38687
  const collectRoot = (root3) => {
@@ -38678,107 +38732,107 @@ function emitBodyCore(g2, source, stmts, opts) {
38678
38732
  byRoot.delete(u.node);
38679
38733
  const n = list.length;
38680
38734
  for (let k = 0; k < n; k++) {
38681
- const before2 = g2.code.length;
38682
- emitStatement(g2, source, list[k], "", false, opts, ctx2);
38683
- if (g2.code.length > before2) g2.addRaw("\n");
38735
+ const before2 = g4.code.length;
38736
+ emitStatement(g4, source, list[k], "", false, opts, ctx2);
38737
+ if (g4.code.length > before2) g4.addRaw("\n");
38684
38738
  }
38685
38739
  }
38686
38740
  }
38687
38741
  if (u.empty !== void 0) {
38688
- emitForOf(g2, source, u.node, "", opts);
38742
+ emitForOf(g4, source, u.node, "", opts);
38689
38743
  const inner = u.empty.body ?? [];
38690
38744
  if (inner.length > 0) {
38691
- g2.addRaw("\n");
38692
- g2.add("");
38693
- g2.add(
38745
+ g4.addRaw("\n");
38746
+ g4.add("");
38747
+ g4.add(
38694
38748
  source.slice(u.node.right.start, u.node.right.end),
38695
38749
  u.node.right.start,
38696
38750
  u.node.right.end
38697
38751
  );
38698
- g2.addRaw(".length === 0 && (() => {");
38699
- g2.addRaw("\n");
38700
- emitBody(g2, source, inner, " ", opts);
38701
- g2.addRaw("\n");
38702
- g2.add("");
38703
- g2.addRaw("})();");
38752
+ g4.addRaw(".length === 0 && (() => {");
38753
+ g4.addRaw("\n");
38754
+ emitBody(g4, source, inner, " ", opts);
38755
+ g4.addRaw("\n");
38756
+ g4.add("");
38757
+ g4.addRaw("})();");
38704
38758
  }
38705
38759
  return;
38706
38760
  }
38707
- const before = g2.code.length;
38708
- emitStatement(g2, source, u.node, "", isLast, opts, ctx2);
38709
- if (g2.code.length > before && !isLast) g2.addRaw("\n");
38761
+ const before = g4.code.length;
38762
+ emitStatement(g4, source, u.node, "", isLast, opts, ctx2);
38763
+ if (g4.code.length > before && !isLast) g4.addRaw("\n");
38710
38764
  };
38711
38765
  for (let i = 0; i < units.length; i++) {
38712
38766
  emitUnit(units[i], i === units.length - 1);
38713
38767
  }
38714
38768
  }
38715
- function emitExpressionBody(g2, source, coreStart, coreEnd, stmts, opts) {
38769
+ function emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts) {
38716
38770
  let pos = coreStart;
38717
38771
  for (const stmt of stmts) {
38718
38772
  if (!stmt) continue;
38719
- emitChunkMapped(g2, source, pos, stmt.start);
38773
+ emitChunkMapped(g4, source, pos, stmt.start);
38720
38774
  pos = stmt.start;
38721
38775
  if (isTrackDeclStatement(stmt)) {
38722
- emitTrackDeclStatement(g2, source, stmt, "", true, opts);
38776
+ emitTrackDeclStatement(g4, source, stmt, "", true, opts);
38723
38777
  } else if (stmt.type === "ReturnStatement") {
38724
- emitReturn(g2, source, stmt, opts);
38778
+ emitReturn(g4, source, stmt, opts);
38725
38779
  } else {
38726
- emitChunkMapped(g2, source, stmt.start, stmt.end);
38780
+ emitChunkMapped(g4, source, stmt.start, stmt.end);
38727
38781
  }
38728
38782
  pos = stmt.end;
38729
38783
  }
38730
- emitChunkMapped(g2, source, pos, coreEnd);
38784
+ emitChunkMapped(g4, source, pos, coreEnd);
38731
38785
  }
38732
- function emitRestMapped(g2, text, base, end) {
38786
+ function emitRestMapped(g4, text, base, end) {
38733
38787
  let i = 0;
38734
38788
  while (i < text.length && !isIdentStart(text[i])) i++;
38735
38789
  if (i >= text.length) {
38736
- g2.add(text, base, end);
38790
+ g4.add(text, base, end);
38737
38791
  return;
38738
38792
  }
38739
38793
  let j = i + 1;
38740
38794
  while (j < text.length && isIdentChar(text[j])) j++;
38741
- g2.add(text.slice(0, i), base, base + i);
38742
- g2.add(text.slice(i, j), base + i, base + j);
38743
- g2.add(text.slice(j), base + j, end);
38795
+ g4.add(text.slice(0, i), base, base + i);
38796
+ g4.add(text.slice(i, j), base + i, base + j);
38797
+ g4.add(text.slice(j), base + j, end);
38744
38798
  }
38745
- function emitComponentHeader(g2, source, start, bodyStart) {
38799
+ function emitComponentHeader(g4, source, start, bodyStart) {
38746
38800
  const h = source.slice(start, bodyStart);
38747
38801
  const k = findFirstKeyword(h, "component");
38748
38802
  if (k === -1) {
38749
38803
  const { text, end: end2 } = stripTrailingClientRange(h);
38750
38804
  if (!text.includes("(")) {
38751
38805
  const trimmed = text.trimEnd();
38752
- g2.add(trimmed, start, start + end2 - (text.length - trimmed.length));
38753
- g2.addRaw("() ");
38806
+ g4.add(trimmed, start, start + end2 - (text.length - trimmed.length));
38807
+ g4.addRaw("() ");
38754
38808
  } else {
38755
- g2.add(text, start, start + end2);
38809
+ g4.add(text, start, start + end2);
38756
38810
  }
38757
38811
  return;
38758
38812
  }
38759
- g2.add(h.slice(0, k), start, start + k);
38760
- g2.add("function", start + k, start + k + "component".length);
38813
+ g4.add(h.slice(0, k), start, start + k);
38814
+ g4.add("function", start + k, start + k + "component".length);
38761
38815
  const restBase = start + k + "component".length;
38762
38816
  const { text: rest, end } = stripTrailingClientRange(h.slice(k + "component".length));
38763
38817
  const transformed = h.slice(0, k) + "function" + rest;
38764
38818
  if (!transformed.includes("(")) {
38765
38819
  const trimmed = rest.trimEnd();
38766
- emitRestMapped(g2, trimmed, restBase, restBase + end - (rest.length - trimmed.length));
38767
- g2.addRaw("() ");
38820
+ emitRestMapped(g4, trimmed, restBase, restBase + end - (rest.length - trimmed.length));
38821
+ g4.addRaw("() ");
38768
38822
  } else {
38769
- emitRestMapped(g2, rest, restBase, restBase + end);
38823
+ emitRestMapped(g4, rest, restBase, restBase + end);
38770
38824
  }
38771
38825
  }
38772
- function emitComponent(g2, source, node, start, opts) {
38826
+ function emitComponent(g4, source, node, start, opts) {
38773
38827
  const body = node.body;
38774
38828
  if (!body || body.start == null || body.end == null) return;
38775
- emitComponentHeader(g2, source, start, body.start);
38829
+ emitComponentHeader(g4, source, start, body.start);
38776
38830
  const statementMode = isStatementMode2(node);
38777
38831
  const stmts = body.body ?? [];
38778
38832
  if (statementMode) {
38779
- g2.addRaw("{ ");
38780
- emitBodyCore(g2, source, stmts, opts);
38781
- g2.addRaw(" }");
38833
+ g4.addRaw("{ ");
38834
+ emitBodyCore(g4, source, stmts, opts);
38835
+ g4.addRaw(" }");
38782
38836
  } else {
38783
38837
  const raw2 = source.slice(body.start, body.end);
38784
38838
  const rawLen = raw2.length;
@@ -38798,9 +38852,9 @@ function emitComponent(g2, source, node, start, opts) {
38798
38852
  }
38799
38853
  while (coreStart < coreEnd && isWhitespaceChar(source[coreStart])) coreStart++;
38800
38854
  while (coreEnd > coreStart && isWhitespaceChar(source[coreEnd - 1])) coreEnd--;
38801
- if (hasBraces) g2.addRaw("{ ");
38802
- emitExpressionBody(g2, source, coreStart, coreEnd, stmts, opts);
38803
- if (hasBraces) g2.addRaw(" }");
38855
+ if (hasBraces) g4.addRaw("{ ");
38856
+ emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts);
38857
+ if (hasBraces) g4.addRaw(" }");
38804
38858
  }
38805
38859
  }
38806
38860
  function isModuleAst(ast) {
@@ -38830,26 +38884,26 @@ function compileVskCodegen(source, opts = {}) {
38830
38884
  };
38831
38885
  }
38832
38886
  const clean = blankForClauses(source, ast);
38833
- const g2 = new VskGen();
38887
+ const g4 = new VskGen();
38834
38888
  const components = getComponents(ast).sort((a, b) => a.start - b.start);
38835
38889
  let pos = 0;
38836
38890
  for (const { node, start } of components) {
38837
38891
  const body = node.body;
38838
38892
  if (!body || body.start == null || body.end == null) continue;
38839
- g2.add(clean.slice(pos, start), pos, start);
38840
- emitComponent(g2, clean, node, start, opts);
38893
+ g4.add(clean.slice(pos, start), pos, start);
38894
+ emitComponent(g4, clean, node, start, opts);
38841
38895
  pos = body.end;
38842
38896
  }
38843
- g2.add(clean.slice(pos), pos, source.length);
38844
- let code = g2.code;
38897
+ g4.add(clean.slice(pos), pos, source.length);
38898
+ let code = g4.code;
38845
38899
  if (isModuleAst(ast) && containsIdentifier(code, "Head") && !isIdentifierImported(code, "Head")) {
38846
- g2.prepend("declare const Head: (props: { children?: Component }) => Component;\n");
38847
- code = g2.code;
38900
+ g4.prepend("declare const Head: (props: { children?: Component }) => Component;\n");
38901
+ code = g4.code;
38848
38902
  }
38849
38903
  if (!isModuleAst(ast)) {
38850
38904
  code += "\nexport {};\n";
38851
38905
  }
38852
- return { code, mappings: g2.mappings, styleRegions: g2.styleRegions, errors: [] };
38906
+ return { code, mappings: g4.mappings, styleRegions: g4.styleRegions, errors: [] };
38853
38907
  }
38854
38908
  function isTypeDecl(stmt) {
38855
38909
  return stmt.type === "TSInterfaceDeclaration" || stmt.type === "TSTypeAliasDeclaration" || stmt.type === "ExportNamedDeclaration" && (stmt.declaration?.type === "TSInterfaceDeclaration" || stmt.declaration?.type === "TSTypeAliasDeclaration");
@@ -38963,7 +39017,7 @@ __export(typecheck_exports, {
38963
39017
  typecheckProject: () => typecheckProject
38964
39018
  });
38965
39019
  import { readFileSync as readFileSync39, readdirSync as readdirSync14, statSync as statSync22 } from "node:fs";
38966
- 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";
38967
39021
  import * as ts8 from "typescript";
38968
39022
  function walkProjectFiles(projectRoot) {
38969
39023
  const code = [];
@@ -38976,7 +39030,7 @@ function walkProjectFiles(projectRoot) {
38976
39030
  return;
38977
39031
  }
38978
39032
  for (const e of entries) {
38979
- const p = join25(dir, e);
39033
+ const p = join26(dir, e);
38980
39034
  let st;
38981
39035
  try {
38982
39036
  st = statSync22(p);
@@ -39031,8 +39085,8 @@ function checkStructureFile(appDir, file) {
39031
39085
  return null;
39032
39086
  }
39033
39087
  function createTypecheckHost(projectRoot, appDir, vskFiles) {
39034
- const ambientPath = join25(appDir, "__vesk_ambient.d.ts");
39035
- 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");
39036
39090
  const cached = /* @__PURE__ */ new Map();
39037
39091
  const scriptKindFor = (file) => file.endsWith(".vsk") ? ts8.ScriptKind.TSX : ts8.ScriptKind.TS;
39038
39092
  const host = {
@@ -39102,7 +39156,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39102
39156
  directoryExists: (dir) => ts8.sys.directoryExists(dir),
39103
39157
  getDirectories: (dir) => {
39104
39158
  try {
39105
- 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));
39106
39160
  } catch {
39107
39161
  return [];
39108
39162
  }
@@ -39114,7 +39168,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39114
39168
  return moduleLiterals.map(({ text }) => {
39115
39169
  if (text.endsWith(".vsk")) {
39116
39170
  const aliased = text.startsWith(".") ? null : resolveAliasModule(text, dirname27(containingFile));
39117
- const abs = normalize(aliased ?? join25(dirname27(containingFile), text));
39171
+ const abs = normalize(aliased ?? join26(dirname27(containingFile), text));
39118
39172
  return {
39119
39173
  resolvedModule: {
39120
39174
  resolvedFileName: abs + ".d.ts",
@@ -39125,7 +39179,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39125
39179
  };
39126
39180
  }
39127
39181
  if (text.endsWith(".css")) {
39128
- const abs = normalize(join25(dirname27(containingFile), text));
39182
+ const abs = normalize(join26(dirname27(containingFile), text));
39129
39183
  return {
39130
39184
  resolvedModule: {
39131
39185
  resolvedFileName: abs + ".d.ts",
@@ -39172,7 +39226,7 @@ function sourcePosition(source, offset2) {
39172
39226
  return { line, character: bounded - lineStart + 1 };
39173
39227
  }
39174
39228
  function typecheckProject(projectRoot, opts = {}) {
39175
- const appDir = opts.appDir ?? join25(projectRoot, "app");
39229
+ const appDir = opts.appDir ?? join26(projectRoot, "app");
39176
39230
  const vskFiles = /* @__PURE__ */ new Map();
39177
39231
  const parseErrors = [];
39178
39232
  const warnings = [];
@@ -39211,8 +39265,8 @@ function typecheckProject(projectRoot, opts = {}) {
39211
39265
  }
39212
39266
  rootNames.push(f);
39213
39267
  }
39214
- const ambientPath = join25(appDir, "__vesk_ambient.d.ts");
39215
- 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");
39216
39270
  rootNames.push(ambientPath);
39217
39271
  rootNames.push(overridePath);
39218
39272
  const options = {
@@ -39840,7 +39894,7 @@ declare module '@vesk/runtime' {
39840
39894
 
39841
39895
  // src/index.ts
39842
39896
  import { readFileSync as readFileSync40, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, existsSync as existsSync43 } from "fs";
39843
- import { resolve as resolve40, join as join26 } from "path";
39897
+ import { resolve as resolve40, join as join27 } from "path";
39844
39898
  import { fileURLToPath as fileURLToPath9 } from "url";
39845
39899
 
39846
39900
  // ../adapter/dist/load-config.js
@@ -40462,7 +40516,7 @@ async function bundleRuntime(appDir, outDir) {
40462
40516
  const runtimeRoot = findRuntimeSrc(appDir);
40463
40517
  const entryFile = resolve3(outDir, "server", `.runtime-entry-${buildId++}.mjs`);
40464
40518
  const entryContent = [
40465
- `import { renderPage, renderFullPage, renderPageStream, compileFile, setRuntimeModule, setVskHydrate, hydratePrecompile, assertSameOrigin } from ${JSON.stringify(resolve3(compilerRoot, "server-codegen.js"))};`,
40519
+ `import { renderPage, renderFullPage, renderPageStream, compileFile, setRuntimeModule, setVskHydrate, hydratePrecompile, assertSameOrigin, withSsrStore } from ${JSON.stringify(resolve3(compilerRoot, "server-codegen.js"))};`,
40466
40520
  `import { parseCookies } from ${JSON.stringify(resolve3(compilerRoot, "server-cookies.js"))};`,
40467
40521
  `import * as __veskRuntime from ${JSON.stringify(resolve3(runtimeRoot, "index-server.js"))};`,
40468
40522
  "",
@@ -40501,7 +40555,7 @@ async function bundleRuntime(appDir, outDir) {
40501
40555
  "}",
40502
40556
  "",
40503
40557
  "export { renderPage, renderFullPage, renderPageStream, compileFile, setVskHydrate, hydratePrecompile, parseCookies, assertSameOrigin };",
40504
- 'export { withSsrStore } from "@vesk/compiler/src/ssr-store";',
40558
+ "export { withSsrStore };",
40505
40559
  "",
40506
40560
  "// Deliver hydration data as an origin-served script so strict CSP (no unsafe-inline)",
40507
40561
  "// does not block it. The prod server serves /ssr-data.js from the global store.",
@@ -40513,7 +40567,11 @@ async function bundleRuntime(appDir, outDir) {
40513
40567
  " let tk = '';",
40514
40568
  " for (const b of bytes) tk += b.toString(16).padStart(2, '0');",
40515
40569
  " const token = tk;",
40516
- " const store = (globalThis.__vsk_ssr_data_store ||= {});",
40570
+ " // Named __vsk_ssr_payload_store, NOT __vsk_ssr_data_*: the compiler keys",
40571
+ " // per-request slots `__vsk_ssr_data_<token>` and pruneSsrDataSlots()",
40572
+ " // reaps that prefix. Sharing it let the reaper wipe every pending",
40573
+ " // /ssr-data.js payload, so a served page's hydration script 404'd.",
40574
+ " const store = (globalThis.__vsk_ssr_payload_store ||= {});",
40517
40575
  " store[token] = payload;",
40518
40576
  " // Bound the store: if the browser never fetches /ssr-data.js the entry",
40519
40577
  " // would otherwise linger forever. Evict the oldest entry past 100.",
@@ -40683,8 +40741,15 @@ init_module_imports();
40683
40741
  import { readFileSync as readFileSync4 } from "node:fs";
40684
40742
  import { dirname as dirname6 } from "node:path";
40685
40743
  function precompileFile(source, sourcePath2) {
40686
- return precompileFileInternal(source, sourcePath2, /* @__PURE__ */ new Set());
40687
- }
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();
40688
40753
  function precompileFileInternal(source, sourcePath2, seenImportFiles) {
40689
40754
  if (sourcePath2) {
40690
40755
  const dir = dirname6(sourcePath2);
@@ -40737,6 +40802,7 @@ function precompileFileInternal(source, sourcePath2, seenImportFiles) {
40737
40802
 
40738
40803
  // ../compiler/src/server-codegen.ts
40739
40804
  init_server_render();
40805
+ init_ssr_store();
40740
40806
 
40741
40807
  // ../adapter/src/css.ts
40742
40808
  import { readFileSync as readFileSync6, existsSync as existsSync7 } from "node:fs";
@@ -41786,12 +41852,8 @@ function findRuntimeSrc2(appDir) {
41786
41852
  }
41787
41853
  function extractRuntimeImportNames(code) {
41788
41854
  const names = [];
41789
- let ast;
41790
- try {
41791
- ast = parse4(code);
41792
- } catch {
41793
- return names;
41794
- }
41855
+ const ast = parseForStrip(code);
41856
+ if (!ast) return names;
41795
41857
  const body = ast.body ?? [];
41796
41858
  for (const raw2 of body) {
41797
41859
  const node = raw2;
@@ -42019,11 +42081,11 @@ var ChunkImports = class {
42019
42081
  const lines = [];
42020
42082
  const sources = [...this.bySource.keys()].sort();
42021
42083
  for (const src2 of sources) {
42022
- const g2 = this.bySource.get(src2);
42084
+ const g4 = this.bySource.get(src2);
42023
42085
  const parts = [];
42024
- if (g2.default) parts.push(`import ${g2.default.local} from ${JSON.stringify(src2)}`);
42025
- if (g2.namespace) parts.push(`import * as ${g2.namespace.local} from ${JSON.stringify(src2)}`);
42026
- const named = [...g2.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
42086
+ if (g4.default) parts.push(`import ${g4.default.local} from ${JSON.stringify(src2)}`);
42087
+ if (g4.namespace) parts.push(`import * as ${g4.namespace.local} from ${JSON.stringify(src2)}`);
42088
+ const named = [...g4.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
42027
42089
  if (named.length > 0) {
42028
42090
  const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
42029
42091
  parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
@@ -42059,12 +42121,8 @@ function scopeFileContribution(code) {
42059
42121
  }
42060
42122
  }
42061
42123
  function stripAndDemoteInOnePass(code) {
42062
- let ast;
42063
- try {
42064
- ast = parse4(code);
42065
- } catch {
42066
- return code;
42067
- }
42124
+ const ast = parseForStrip(code);
42125
+ if (!ast) return code;
42068
42126
  const body = ast.body ?? [];
42069
42127
  const edits = [];
42070
42128
  for (const raw2 of body) {
@@ -42098,20 +42156,28 @@ function buildHmrEvalSnippet(code) {
42098
42156
  const scoped = `{
42099
42157
  ${body}
42100
42158
  }`;
42101
- try {
42102
- parse4(scoped);
42103
- return scoped;
42104
- } catch {
42105
- 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
+ }
42106
42173
  }
42174
+ if (stripAstCache.size >= STRIP_AST_CACHE_MAX) stripAstCache.clear();
42175
+ stripAstCache.set(code, ast);
42176
+ return ast;
42107
42177
  }
42108
42178
  function removeCompiledNodes(code, isTarget) {
42109
- let ast;
42110
- try {
42111
- ast = parse4(code);
42112
- } catch {
42113
- return code;
42114
- }
42179
+ const ast = parseForStrip(code);
42180
+ if (!ast) return code;
42115
42181
  const ranges = [];
42116
42182
  for (const raw2 of ast.body ?? []) {
42117
42183
  const node = raw2;
@@ -42133,6 +42199,7 @@ function removeCompiledNodes(code, isTarget) {
42133
42199
  async function generateClientBundle(routeTree, appDir, componentMap, options) {
42134
42200
  const runtimeDir = findRuntimeSrc2(appDir);
42135
42201
  let seen = /* @__PURE__ */ new Set();
42202
+ const __stats = { chunks: 0, compiled: 0, distinct: /* @__PURE__ */ new Set(), parseMs: 0 };
42136
42203
  const chunks = [];
42137
42204
  const runtimeImportNames = /* @__PURE__ */ new Set();
42138
42205
  const cache2 = options?.cache;
@@ -42216,13 +42283,17 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
42216
42283
  return;
42217
42284
  }
42218
42285
  compiledFiles++;
42286
+ __stats.compiled++;
42287
+ __stats.distinct.add(filePath);
42219
42288
  let src2 = readFileSync11(filePath, "utf-8");
42220
42289
  if (/content=["'][^"']*\.md["']/i.test(src2)) {
42221
42290
  src2 = inlineMdContentAttrs(src2, dirname8(filePath), guessProjectRoots(appDir));
42222
42291
  }
42223
42292
  const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
42224
42293
  const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
42294
+ const __p0 = performance.now();
42225
42295
  const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths, componentNames } = compileClientBoth(src2, null, filePath);
42296
+ __stats.parseMs += performance.now() - __p0;
42226
42297
  for (const cn of componentNames || []) componentOwners.claim(cn, filePath);
42227
42298
  const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
42228
42299
  const hydWithImports = rawHyd ? stripExports(stripVskImports(stripRuntimeImport(rawHyd))) : "";
@@ -42413,6 +42484,7 @@ ${entry.code}
42413
42484
  transformedChunks.push({ ...chunk, code: await applyTransformPlugins(chunk.code, chunk.name) });
42414
42485
  }
42415
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)}`);
42416
42488
  return { main: await applyTransformPlugins(main, "client.js"), chunks: transformedChunks, cachedFileHits, compiledFiles, mainFromCache, editedSources, editedNames };
42417
42489
  } else {
42418
42490
  let compileFileMono2 = function(filePath, resolvedName) {
@@ -43070,7 +43142,7 @@ async function startProdServer(outDir, options) {
43070
43142
  }
43071
43143
  if (url.pathname === "/ssr-data.js") {
43072
43144
  const token = url.searchParams.get("t") || "";
43073
- const store = globalThis.__vsk_ssr_data_store;
43145
+ const store = globalThis.__vsk_ssr_payload_store;
43074
43146
  const payload = store?.[token];
43075
43147
  if (payload) delete store[token];
43076
43148
  const lines = [];
@@ -43396,7 +43468,24 @@ async function collectPluginHeadExtra(pluginsPipelines) {
43396
43468
  }
43397
43469
  return parts.join("\n");
43398
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
+ }
43399
43483
  async function build2(appDir, options) {
43484
+ if (profileEnabled()) {
43485
+ buildStarted = Date.now();
43486
+ phaseMarks = [];
43487
+ phaseStarted = performance.now();
43488
+ }
43400
43489
  appDir = resolve21(appDir);
43401
43490
  const outDir = resolve21(options?.outDir || resolve21(appDir, "..", ".vesk"));
43402
43491
  const publicDir = options?.publicDir || resolve21(appDir, "..", "public");
@@ -43446,6 +43535,7 @@ async function build2(appDir, options) {
43446
43535
  ];
43447
43536
  for (const d of dirs)
43448
43537
  mkdirSync11(d, { recursive: true });
43538
+ markPhase("config+dirs");
43449
43539
  const cssSourcePath = resolveUserCssPath(appDir);
43450
43540
  if (cssSourcePath !== null) {
43451
43541
  const cssContent = readFileSync21(cssSourcePath, "utf-8");
@@ -43469,6 +43559,7 @@ async function build2(appDir, options) {
43469
43559
  console.error(`vesk build: css \u2192 static/global.css (${finalCss.length} bytes, tailwind plugin inactive)`);
43470
43560
  }
43471
43561
  }
43562
+ markPhase("css/tailwind");
43472
43563
  const { scanRoutes: scanRoutes2, scanComponents: scanComponents2 } = await resolveCompilerApi("router.js");
43473
43564
  const { scanApiRoutes: scanApiRoutes2 } = await resolveCompilerApi("api-routes.js");
43474
43565
  const { collectMiddlewareChain: collectMiddlewareChain2 } = await resolveCompilerApi("middleware.js");
@@ -43486,6 +43577,7 @@ async function build2(appDir, options) {
43486
43577
  const apiDir = resolve21(appDir, "api");
43487
43578
  const apiTree = existsSync22(apiDir) ? scanApiRoutes2(apiDir) : [];
43488
43579
  console.error(`vesk build: ${routeTree.length} root routes, ${apiTree.length} API routes`);
43580
+ markPhase("scan routes");
43489
43581
  console.error("vesk build: bundling server runtime...");
43490
43582
  await bundleRuntime(appDir, outDir);
43491
43583
  const ssrRoutes = [];
@@ -43538,6 +43630,7 @@ async function build2(appDir, options) {
43538
43630
  }
43539
43631
  }
43540
43632
  walk7(routeTree);
43633
+ markPhase("server runtime + ssr functions");
43541
43634
  const apiRoutes = [];
43542
43635
  function walkApi(nodes) {
43543
43636
  for (const node of nodes) {
@@ -43564,6 +43657,7 @@ async function build2(appDir, options) {
43564
43657
  const hasEvents = await compileEvents(appDir, outDir);
43565
43658
  if (hasEvents)
43566
43659
  console.error("vesk build: evt \u2192 server/events.js (onStart/onRequest/onStop)");
43660
+ markPhase("api functions");
43567
43661
  console.error("vesk build: bundling client runtime...");
43568
43662
  const bundleOpts = {};
43569
43663
  if (options?.codeSplit)
@@ -43586,6 +43680,7 @@ async function build2(appDir, options) {
43586
43680
  }
43587
43681
  }
43588
43682
  copyStaticAssets(publicDir, outDir);
43683
+ markPhase("client runtime + chunks");
43589
43684
  console.error("vesk build: static \u2192 static/public/");
43590
43685
  let prerenderedRoutes = [];
43591
43686
  if (options?.ssg) {
@@ -43597,7 +43692,7 @@ async function build2(appDir, options) {
43597
43692
  console.error(`vesk build: ssg \u2192 prerendered/ (${prerenderedRoutes.length} pages)`);
43598
43693
  }
43599
43694
  {
43600
- 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));
43601
43696
  await optimizeImages2(appDir, outDir);
43602
43697
  }
43603
43698
  if (options?.seo) {
@@ -43607,10 +43702,6 @@ async function build2(appDir, options) {
43607
43702
  throw new Error(`SEO audit failed with ${audit.errors} error(s) \u2014 fix them before deploying`);
43608
43703
  }
43609
43704
  }
43610
- {
43611
- const { optimizeImages: optimizeImages2 } = await init_image_pipeline().then(() => image_pipeline_exports);
43612
- await optimizeImages2(appDir, outDir);
43613
- }
43614
43705
  {
43615
43706
  const { generateSitemap: generateSitemap2, generateRobotsTxt: generateRobotsTxt2 } = await Promise.resolve().then(() => (init_static(), static_exports));
43616
43707
  const publicDirResolved = resolve21(outDir, "static", "public");
@@ -43628,6 +43719,7 @@ async function build2(appDir, options) {
43628
43719
  console.error(`vesk build: seo \u2192 static/public/robots.txt (${robots.length} bytes)`);
43629
43720
  }
43630
43721
  }
43722
+ markPhase("ssg+images+seo");
43631
43723
  const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap, pluginHeadExtra, hasEvents);
43632
43724
  writeFileSync12(resolve21(outDir, "config.json"), JSON.stringify(manifest, null, 2) + "\n", "utf-8");
43633
43725
  console.error("vesk build: config \u2192 config.json");
@@ -43660,6 +43752,14 @@ async function build2(appDir, options) {
43660
43752
  await plugin.onBuildEnd();
43661
43753
  }
43662
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
+ }
43663
43763
  console.error(`
43664
43764
  vesk build: done (${outDir})`);
43665
43765
  return { routeTree, apiTree, ssrRoutes, apiRoutes, manifest };
@@ -43670,7 +43770,7 @@ init_seo_audit();
43670
43770
 
43671
43771
  // src/dev-server.ts
43672
43772
  import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, readdirSync as readdirSync13 } from "node:fs";
43673
- 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";
43674
43774
  import { createServer as createServer2 } from "node:http";
43675
43775
  import { WebSocketServer as WebSocketServer2 } from "ws";
43676
43776
 
@@ -43885,13 +43985,23 @@ init_server_utils();
43885
43985
  init_server_head();
43886
43986
  init_server_jsgen();
43887
43987
  init_server_render();
43988
+ init_ssr_store();
43888
43989
 
43889
43990
  // ../compiler/dist/ssr-store.js
43890
43991
  init_index_server();
43891
43992
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
43892
43993
  var TOKEN_KEY2 = "__vsk_ssr_token";
43893
- var storage2 = new AsyncLocalStorage2();
43894
- var liveSlots2 = /* @__PURE__ */ new Map();
43994
+ var IMPL_KEY2 = "__vsk_ssr_store_impl";
43995
+ var g3 = globalThis;
43996
+ var impl2 = g3[IMPL_KEY2] ?? (g3[IMPL_KEY2] = {
43997
+ storage: new AsyncLocalStorage2(),
43998
+ liveSlots: /* @__PURE__ */ new Map(),
43999
+ // Only the copy that created the implementation installs the token
44000
+ // accessor; a later copy must not redefine it over the shared storage.
44001
+ ownsAccessor: true
44002
+ });
44003
+ var storage2 = impl2.storage;
44004
+ var liveSlots2 = impl2.liveSlots;
43895
44005
  function newSsrToken2() {
43896
44006
  return Math.random().toString(36).slice(2);
43897
44007
  }
@@ -43929,7 +44039,7 @@ function withSsrStore2(fn) {
43929
44039
  function withSsrStoreOf2(store, fn) {
43930
44040
  return storage2.run(store, fn);
43931
44041
  }
43932
- function resetSsrToken() {
44042
+ function resetSsrToken2() {
43933
44043
  const store = storage2.getStore();
43934
44044
  const token = newSsrToken2();
43935
44045
  if (store) {
@@ -43976,17 +44086,19 @@ var ssrSink3 = {
43976
44086
  }
43977
44087
  };
43978
44088
  setSsrSink(ssrSink3);
43979
- Object.defineProperty(globalThis, TOKEN_KEY2, {
43980
- configurable: true,
43981
- get() {
43982
- return storage2.getStore()?.token;
43983
- },
43984
- set(value) {
43985
- const store = storage2.getStore();
43986
- if (store)
43987
- store.token = value;
43988
- }
43989
- });
44089
+ if (impl2.ownsAccessor) {
44090
+ Object.defineProperty(globalThis, TOKEN_KEY2, {
44091
+ configurable: true,
44092
+ get() {
44093
+ return storage2.getStore()?.token;
44094
+ },
44095
+ set(value) {
44096
+ const store = storage2.getStore();
44097
+ if (store)
44098
+ store.token = value;
44099
+ }
44100
+ });
44101
+ }
43990
44102
 
43991
44103
  // ../compiler/dist/client-codegen.js
43992
44104
  init_ir();
@@ -46308,7 +46420,7 @@ init_tokens();
46308
46420
  init_scan();
46309
46421
  init_strip_ts();
46310
46422
  import { readdirSync as readdirSync7, statSync as statSync12, existsSync as existsSync23, readFileSync as readFileSync22 } from "fs";
46311
- 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";
46312
46424
  function collapseSlashes2(p) {
46313
46425
  let out = "";
46314
46426
  let prevSlash = false;
@@ -46411,7 +46523,7 @@ function scanComponents(componentsDir) {
46411
46523
  return;
46412
46524
  }
46413
46525
  for (const entry of entries) {
46414
- const full = join14(dir, entry);
46526
+ const full = join15(dir, entry);
46415
46527
  let stat;
46416
46528
  try {
46417
46529
  stat = statSync12(full);
@@ -46512,7 +46624,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
46512
46624
  seg = segName;
46513
46625
  }
46514
46626
  const fullPath = seg ? (parentPath === "/" ? "/" : parentPath + "/") + seg : parentPath || "/";
46515
- const isStandalone = hasLayout ? isStandaloneLayoutFile(join14(dir, "layout.vsk")) : false;
46627
+ const isStandalone = hasLayout ? isStandaloneLayoutFile(join15(dir, "layout.vsk")) : false;
46516
46628
  const node = {
46517
46629
  path: seg,
46518
46630
  fullPath: collapseSlashes2(fullPath) || "/",
@@ -46533,7 +46645,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
46533
46645
  standalone: isStandalone ? true : void 0
46534
46646
  };
46535
46647
  for (const entry of entries) {
46536
- const entryPath = join14(dir, entry);
46648
+ const entryPath = join15(dir, entry);
46537
46649
  let entryStat;
46538
46650
  try {
46539
46651
  entryStat = statSync12(entryPath);
@@ -46585,19 +46697,19 @@ function collectSources(tree) {
46585
46697
  function walk7(nodes) {
46586
46698
  for (const node of nodes) {
46587
46699
  if (node.page)
46588
- map.set(node.page, join14(node.sourceDir, "page.vsk"));
46700
+ map.set(node.page, join15(node.sourceDir, "page.vsk"));
46589
46701
  if (node.layout)
46590
- map.set(node.layout, join14(node.sourceDir, "layout.vsk"));
46702
+ map.set(node.layout, join15(node.sourceDir, "layout.vsk"));
46591
46703
  if (node.loading)
46592
- map.set(node.loading, join14(node.sourceDir, "loading.vsk"));
46704
+ map.set(node.loading, join15(node.sourceDir, "loading.vsk"));
46593
46705
  if (node.error)
46594
- map.set(node.error, join14(node.sourceDir, "error.vsk"));
46706
+ map.set(node.error, join15(node.sourceDir, "error.vsk"));
46595
46707
  if (node.notFound)
46596
- map.set(node.notFound, join14(node.sourceDir, "not-found.vsk"));
46708
+ map.set(node.notFound, join15(node.sourceDir, "not-found.vsk"));
46597
46709
  if (node.offline)
46598
- map.set(node.offline, join14(node.sourceDir, "offline.vsk"));
46710
+ map.set(node.offline, join15(node.sourceDir, "offline.vsk"));
46599
46711
  if (node.network)
46600
- map.set(node.network, join14(node.sourceDir, "network.vsk"));
46712
+ map.set(node.network, join15(node.sourceDir, "network.vsk"));
46601
46713
  walk7(node.children);
46602
46714
  }
46603
46715
  }
@@ -46699,7 +46811,7 @@ function matchUrl(tree, pathname) {
46699
46811
 
46700
46812
  // ../compiler/dist/api-routes.js
46701
46813
  import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync24 } from "fs";
46702
- import { join as join15 } from "path";
46814
+ import { join as join16 } from "path";
46703
46815
  init_server_utils();
46704
46816
  function basename4(p) {
46705
46817
  const idx = p.lastIndexOf("/");
@@ -46736,7 +46848,7 @@ function scanApiDir(rootDir, dir, parentPath) {
46736
46848
  return nodes;
46737
46849
  if (isRouteGroup) {
46738
46850
  for (const entry of entries) {
46739
- const entryPath = join15(dir, entry);
46851
+ const entryPath = join16(dir, entry);
46740
46852
  let entryStat;
46741
46853
  try {
46742
46854
  entryStat = statSync13(entryPath);
@@ -46766,11 +46878,11 @@ function scanApiDir(rootDir, dir, parentPath) {
46766
46878
  fullPath: collapseSlashes(fullPath) || "/",
46767
46879
  isDynamic,
46768
46880
  isCatchAll,
46769
- filePath: hasRoute && routeFileName ? join15(dir, routeFileName) : null,
46881
+ filePath: hasRoute && routeFileName ? join16(dir, routeFileName) : null,
46770
46882
  children: []
46771
46883
  };
46772
46884
  for (const entry of entries) {
46773
- const entryPath = join15(dir, entry);
46885
+ const entryPath = join16(dir, entry);
46774
46886
  let entryStat;
46775
46887
  try {
46776
46888
  entryStat = statSync13(entryPath);
@@ -47300,11 +47412,11 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
47300
47412
 
47301
47413
  // ../compiler/dist/events.js
47302
47414
  import { existsSync as existsSync26 } from "fs";
47303
- import { join as join16 } from "path";
47415
+ import { join as join17 } from "path";
47304
47416
  var EVENTS_FILE_NAMES2 = ["_events.ts", "_events.js"];
47305
47417
  function collectEventsFile2(appDir) {
47306
47418
  for (const name of EVENTS_FILE_NAMES2) {
47307
- const candidate = join16(appDir, name);
47419
+ const candidate = join17(appDir, name);
47308
47420
  if (existsSync26(candidate))
47309
47421
  return candidate;
47310
47422
  }
@@ -47336,7 +47448,7 @@ async function runEventHandlers(handlers, name, ctx2) {
47336
47448
 
47337
47449
  // ../compiler/dist/md-inline.js
47338
47450
  import { readFileSync as readFileSync23, existsSync as existsSync27 } from "node:fs";
47339
- 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";
47340
47452
  var MD_EXT_MARKER2 = ".md";
47341
47453
  function looksLikeMarkdownPath2(value) {
47342
47454
  const v = value.trim();
@@ -47413,10 +47525,10 @@ function resolveMdPath2(specifier, importerDir, roots) {
47413
47525
  }
47414
47526
  if (spec.startsWith("/")) {
47415
47527
  for (const root3 of roots) {
47416
- const pub = join17(root3, "public", spec);
47528
+ const pub = join18(root3, "public", spec);
47417
47529
  if (existsSync27(pub))
47418
47530
  return pub;
47419
- const direct = join17(root3, spec);
47531
+ const direct = join18(root3, spec);
47420
47532
  if (existsSync27(direct))
47421
47533
  return direct;
47422
47534
  }
@@ -47430,7 +47542,7 @@ function guessProjectRoots2(dir) {
47430
47542
  let cur = dir;
47431
47543
  for (let i = 0; i < 6; i++) {
47432
47544
  roots.push(cur);
47433
- if (existsSync27(join17(cur, "package.json")))
47545
+ if (existsSync27(join18(cur, "package.json")))
47434
47546
  break;
47435
47547
  const parent = dirname17(cur);
47436
47548
  if (parent === cur)
@@ -47442,9 +47554,9 @@ function guessProjectRoots2(dir) {
47442
47554
 
47443
47555
  // ../adapter/dist/client-bundle.js
47444
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";
47445
- 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";
47446
47558
  import { fileURLToPath as fileURLToPath6 } from "node:url";
47447
- import { tmpdir as tmpdir2 } from "node:os";
47559
+ import { tmpdir as tmpdir3 } from "node:os";
47448
47560
 
47449
47561
  // ../adapter/dist/esbuild-fallback.js
47450
47562
  var _nativeBuild2 = null;
@@ -47525,8 +47637,8 @@ function findRuntimeSrc3(appDir) {
47525
47637
  resolve24(appDir, "node_modules", "@vesk/runtime")
47526
47638
  ];
47527
47639
  for (const base of candidates) {
47528
- for (const dir of [base, join18(base, "dist")]) {
47529
- if (existsSync28(join18(dir, "index-client.js")))
47640
+ for (const dir of [base, join19(base, "dist")]) {
47641
+ if (existsSync28(join19(dir, "index-client.js")))
47530
47642
  return dir;
47531
47643
  }
47532
47644
  }
@@ -47534,12 +47646,9 @@ function findRuntimeSrc3(appDir) {
47534
47646
  }
47535
47647
  function extractRuntimeImportNames2(code) {
47536
47648
  const names = [];
47537
- let ast;
47538
- try {
47539
- ast = parse4(code);
47540
- } catch {
47649
+ const ast = parseForStrip2(code);
47650
+ if (!ast)
47541
47651
  return names;
47542
- }
47543
47652
  const body = ast.body ?? [];
47544
47653
  for (const raw2 of body) {
47545
47654
  const node = raw2;
@@ -47793,13 +47902,13 @@ var ChunkImports2 = class {
47793
47902
  const lines = [];
47794
47903
  const sources = [...this.bySource.keys()].sort();
47795
47904
  for (const src2 of sources) {
47796
- const g2 = this.bySource.get(src2);
47905
+ const g4 = this.bySource.get(src2);
47797
47906
  const parts = [];
47798
- if (g2.default)
47799
- parts.push(`import ${g2.default.local} from ${JSON.stringify(src2)}`);
47800
- if (g2.namespace)
47801
- parts.push(`import * as ${g2.namespace.local} from ${JSON.stringify(src2)}`);
47802
- const named = [...g2.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
47907
+ if (g4.default)
47908
+ parts.push(`import ${g4.default.local} from ${JSON.stringify(src2)}`);
47909
+ if (g4.namespace)
47910
+ parts.push(`import * as ${g4.namespace.local} from ${JSON.stringify(src2)}`);
47911
+ const named = [...g4.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
47803
47912
  if (named.length > 0) {
47804
47913
  const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
47805
47914
  parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
@@ -47836,12 +47945,9 @@ function scopeFileContribution2(code) {
47836
47945
  }
47837
47946
  }
47838
47947
  function stripAndDemoteInOnePass2(code) {
47839
- let ast;
47840
- try {
47841
- ast = parse4(code);
47842
- } catch {
47948
+ const ast = parseForStrip2(code);
47949
+ if (!ast)
47843
47950
  return code;
47844
- }
47845
47951
  const body = ast.body ?? [];
47846
47952
  const edits = [];
47847
47953
  for (const raw2 of body) {
@@ -47882,20 +47988,31 @@ function buildHmrEvalSnippet2(code) {
47882
47988
  const scoped = `{
47883
47989
  ${body}
47884
47990
  }`;
47885
- try {
47886
- parse4(scoped);
47887
- return scoped;
47888
- } catch {
47889
- 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
+ }
47890
48006
  }
48007
+ if (stripAstCache2.size >= STRIP_AST_CACHE_MAX2)
48008
+ stripAstCache2.clear();
48009
+ stripAstCache2.set(code, ast);
48010
+ return ast;
47891
48011
  }
47892
48012
  function removeCompiledNodes2(code, isTarget) {
47893
- let ast;
47894
- try {
47895
- ast = parse4(code);
47896
- } catch {
48013
+ const ast = parseForStrip2(code);
48014
+ if (!ast)
47897
48015
  return code;
47898
- }
47899
48016
  const ranges = [];
47900
48017
  for (const raw2 of ast.body ?? []) {
47901
48018
  const node = raw2;
@@ -47921,6 +48038,7 @@ function removeCompiledNodes2(code, isTarget) {
47921
48038
  async function generateClientBundle2(routeTree, appDir, componentMap, options) {
47922
48039
  const runtimeDir = findRuntimeSrc3(appDir);
47923
48040
  let seen = /* @__PURE__ */ new Set();
48041
+ const __stats = { chunks: 0, compiled: 0, distinct: /* @__PURE__ */ new Set(), parseMs: 0 };
47924
48042
  const chunks = [];
47925
48043
  const runtimeImportNames = /* @__PURE__ */ new Set();
47926
48044
  const cache2 = options?.cache;
@@ -48009,13 +48127,17 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
48009
48127
  return;
48010
48128
  }
48011
48129
  compiledFiles++;
48130
+ __stats.compiled++;
48131
+ __stats.distinct.add(filePath);
48012
48132
  let src2 = readFileSync24(filePath, "utf-8");
48013
48133
  if (/content=["'][^"']*\.md["']/i.test(src2)) {
48014
48134
  src2 = inlineMdContentAttrs(src2, dirname18(filePath), guessProjectRoots(appDir));
48015
48135
  }
48016
48136
  const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
48017
48137
  const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
48138
+ const __p0 = performance.now();
48018
48139
  const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths, componentNames } = compileClientBoth(src2, null, filePath);
48140
+ __stats.parseMs += performance.now() - __p0;
48019
48141
  for (const cn of componentNames || [])
48020
48142
  componentOwners.claim(cn, filePath);
48021
48143
  const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
@@ -48166,8 +48288,8 @@ ${body}
48166
48288
  continue;
48167
48289
  let finalCode;
48168
48290
  if (entry.imports) {
48169
- const tmpBase = mkdtempSync2(join18(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
48170
- const tmpFile = join18(tmpBase, "entry.js");
48291
+ const tmpBase = mkdtempSync2(join19(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
48292
+ const tmpFile = join19(tmpBase, "entry.js");
48171
48293
  const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
48172
48294
  const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
48173
48295
  ${entry.code}
@@ -48218,6 +48340,8 @@ ${entry.code}
48218
48340
  transformedChunks.push({ ...chunk, code: await applyTransformPlugins(chunk.code, chunk.name) });
48219
48341
  }
48220
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)}`);
48221
48345
  return { main: await applyTransformPlugins(main, "client.js"), chunks: transformedChunks, cachedFileHits, compiledFiles, mainFromCache, editedSources, editedNames };
48222
48346
  } else {
48223
48347
  let compileFileMono2 = function(filePath, resolvedName) {
@@ -48317,7 +48441,7 @@ function buildRuntimeCode2(runtimeDir) {
48317
48441
  ];
48318
48442
  let code = "";
48319
48443
  for (const f of runtimeFiles) {
48320
- const p = join18(runtimeDir, f);
48444
+ const p = join19(runtimeDir, f);
48321
48445
  if (existsSync28(p)) {
48322
48446
  let src2 = readFileSync24(p, "utf-8");
48323
48447
  src2 = stripTypes2(src2);
@@ -48331,7 +48455,7 @@ ${src2}
48331
48455
  `;
48332
48456
  }
48333
48457
  }
48334
- const indexSrc = readFileSync24(join18(runtimeDir, "index-client.js"), "utf-8");
48458
+ const indexSrc = readFileSync24(join19(runtimeDir, "index-client.js"), "utf-8");
48335
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())) || [];
48336
48460
  code += "// --- exports ---\n";
48337
48461
  for (const name of [...new Set(exportNames)]) {
@@ -48342,7 +48466,7 @@ ${src2}
48342
48466
  return code;
48343
48467
  }
48344
48468
  function runtimeExportNames2(runtimeDir) {
48345
- const indexSrc = readFileSync24(join18(runtimeDir, "index-client.js"), "utf-8");
48469
+ const indexSrc = readFileSync24(join19(runtimeDir, "index-client.js"), "utf-8");
48346
48470
  const names = /* @__PURE__ */ new Set();
48347
48471
  for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
48348
48472
  for (const raw2 of m[1].split(",")) {
@@ -48358,7 +48482,7 @@ function esbuildPath2(p) {
48358
48482
  return sep3 === "/" ? p : p.split(sep3).join("/");
48359
48483
  }
48360
48484
  function runtimeTreeShakeEntry2() {
48361
- return join18(tmpdir2(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
48485
+ return join19(tmpdir3(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
48362
48486
  }
48363
48487
  var treeShakeQueue2 = Promise.resolve();
48364
48488
  function buildTreeShakenRuntime2(runtimeDir, usedNames) {
@@ -48375,7 +48499,7 @@ async function buildTreeShakenRuntimeNow2(runtimeDir, usedNames) {
48375
48499
  return buildRuntimeCode2(runtimeDir);
48376
48500
  }
48377
48501
  const entry = runtimeTreeShakeEntry2();
48378
- const indexClient = esbuildPath2(join18(runtimeDir, "index-client.js"));
48502
+ const indexClient = esbuildPath2(join19(runtimeDir, "index-client.js"));
48379
48503
  try {
48380
48504
  try {
48381
48505
  mkdirSync12(dirname18(entry), { recursive: true });
@@ -48614,8 +48738,8 @@ import { resolve as resolve28 } from "node:path";
48614
48738
  // ../adapter/dist/plugins.js
48615
48739
  init_paths();
48616
48740
  import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
48617
- import { resolve as resolve26, dirname as dirname19, join as join19, extname as extname7, basename as basename5 } from "node:path";
48618
- 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";
48619
48743
  import { spawn as spawn2 } from "node:child_process";
48620
48744
  var PLUGIN_STATE_FILENAME2 = "plugins.json";
48621
48745
  var STATE_VERSION2 = 1;
@@ -48661,7 +48785,7 @@ function writePluginState2(veskDir, state) {
48661
48785
  writeFileSync14(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
48662
48786
  }
48663
48787
  function resolvePackage2(appDir, pkg) {
48664
- const require3 = createRequire5(resolve26(appDir, "package.json"));
48788
+ const require3 = createRequire6(resolve26(appDir, "package.json"));
48665
48789
  let entryPath = null;
48666
48790
  let pkgJsonPath = null;
48667
48791
  let pkgJson = null;
@@ -48674,7 +48798,7 @@ function resolvePackage2(appDir, pkg) {
48674
48798
  const seen = /* @__PURE__ */ new Set();
48675
48799
  while (cur && cur !== dirname19(cur) && !seen.has(cur)) {
48676
48800
  seen.add(cur);
48677
- const candidate = join19(cur, "package.json");
48801
+ const candidate = join20(cur, "package.json");
48678
48802
  if (existsSync30(candidate)) {
48679
48803
  pkgJsonPath = candidate;
48680
48804
  break;
@@ -48703,7 +48827,7 @@ function resolvePackage2(appDir, pkg) {
48703
48827
  }
48704
48828
  }
48705
48829
  if (localPath) {
48706
- const localJson = join19(localPath, "package.json");
48830
+ const localJson = join20(localPath, "package.json");
48707
48831
  let json = null;
48708
48832
  if (existsSync30(localJson)) {
48709
48833
  json = readJsonFile2(localJson);
@@ -49590,8 +49714,8 @@ var __internals2 = {
49590
49714
 
49591
49715
  // ../adapter/dist/dev-config.js
49592
49716
  import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
49593
- import { tmpdir as tmpdir3 } from "node:os";
49594
- 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";
49595
49719
  init_parser();
49596
49720
  function findConfigFile2(projectDir) {
49597
49721
  const ts9 = resolve27(projectDir, "vesk.config.ts");
@@ -49619,9 +49743,9 @@ async function parseConfigSource(source, isTs, projectDir) {
49619
49743
  js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
49620
49744
  ` + js;
49621
49745
  }
49622
- const base = projectDir ? (mkdirSync14(join20(projectDir, ".vesk"), { recursive: true }), join20(projectDir, ".vesk")) : void 0;
49623
- const dir = base ? mkdtempSync3(join20(base, "cfg-")) : mkdtempSync3(join20(tmpdir3(), "vesk-cfg-"));
49624
- 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");
49625
49749
  try {
49626
49750
  writeFileSync15(tmpFile, js, "utf-8");
49627
49751
  globalThis.__vesk_inject = {
@@ -50931,7 +51055,7 @@ function produceDiagnostics(input) {
50931
51055
 
50932
51056
  // ../agentic/dist/checkpoints.js
50933
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";
50934
- 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";
50935
51059
  import { randomUUID as nodeRandomUUID } from "node:crypto";
50936
51060
  function generateId() {
50937
51061
  try {
@@ -51064,16 +51188,16 @@ var CheckpointManager = class {
51064
51188
  }
51065
51189
  };
51066
51190
  function getAgenticDir(projectDir) {
51067
- return join21(resolve29(projectDir), ".vesk", "agentic");
51191
+ return join22(resolve29(projectDir), ".vesk", "agentic");
51068
51192
  }
51069
51193
  function getHistoryPath(projectDir) {
51070
- return join21(getAgenticDir(projectDir), "history.json");
51194
+ return join22(getAgenticDir(projectDir), "history.json");
51071
51195
  }
51072
51196
  function getCheckpointDir(projectDir, id) {
51073
- return join21(getAgenticDir(projectDir), "checkpoints", id);
51197
+ return join22(getAgenticDir(projectDir), "checkpoints", id);
51074
51198
  }
51075
51199
  function getCheckpointPath(projectDir, id) {
51076
- return join21(getCheckpointDir(projectDir, id), "checkpoint.json");
51200
+ return join22(getCheckpointDir(projectDir, id), "checkpoint.json");
51077
51201
  }
51078
51202
  function ensureDir(dir) {
51079
51203
  mkdirSync15(dir, { recursive: true });
@@ -51153,7 +51277,7 @@ function createCheckpoint(projectDir, message, changes = {}, buildResult) {
51153
51277
  };
51154
51278
  const agenticDir = getAgenticDir(projectDir);
51155
51279
  ensureDir(agenticDir);
51156
- ensureDir(join21(agenticDir, "checkpoints"));
51280
+ ensureDir(join22(agenticDir, "checkpoints"));
51157
51281
  const cpDir = getCheckpointDir(projectDir, id);
51158
51282
  ensureDir(cpDir);
51159
51283
  writeJsonAtomic(getCheckpointPath(projectDir, id), checkpoint);
@@ -52658,7 +52782,7 @@ var Agent = class {
52658
52782
 
52659
52783
  // ../agentic/dist/tools/vesk.js
52660
52784
  import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
52661
- 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";
52662
52786
  function resolveWithin3(baseDir, relPath) {
52663
52787
  const base = resolve32(baseDir);
52664
52788
  const target = resolve32(baseDir, relPath);
@@ -52720,7 +52844,7 @@ function findConfigFile3(projectDir) {
52720
52844
  return { path: null, isTs: false };
52721
52845
  }
52722
52846
  function checkpointDir(veskDir) {
52723
- return join22(resolve32(veskDir), "checkpoints");
52847
+ return join23(resolve32(veskDir), "checkpoints");
52724
52848
  }
52725
52849
  function findMatchingBrace2(src2, openIdx) {
52726
52850
  let inStr = null;
@@ -53335,7 +53459,7 @@ function createVeskTools(deps) {
53335
53459
  const dir = checkpointDir(veskDir);
53336
53460
  mkdirSync17(dir, { recursive: true });
53337
53461
  const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
53338
- const file = join22(dir, `${id}.json`);
53462
+ const file = join23(dir, `${id}.json`);
53339
53463
  const check = resolveWithin3(dir, `${id}.json`);
53340
53464
  if (!check)
53341
53465
  return jsonError("path escapes project root");
@@ -53384,7 +53508,7 @@ function createVeskTools(deps) {
53384
53508
  } catch {
53385
53509
  }
53386
53510
  const dir = checkpointDir(veskDir);
53387
- const file = join22(dir, `${checkpointId}.json`);
53511
+ const file = join23(dir, `${checkpointId}.json`);
53388
53512
  const contained = resolveWithin3(dir, `${checkpointId}.json`);
53389
53513
  if (!contained)
53390
53514
  return jsonError("path escapes project root");
@@ -54106,10 +54230,10 @@ function renderDevErrorPage(payload, opts) {
54106
54230
  // src/build-packages.ts
54107
54231
  import { spawnSync as spawnSync2 } from "node:child_process";
54108
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";
54109
- import { createRequire as createRequire6 } from "node:module";
54110
- 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";
54111
54235
  import { fileURLToPath as fileURLToPath8 } from "node:url";
54112
- var require2 = createRequire6(import.meta.url);
54236
+ var require2 = createRequire7(import.meta.url);
54113
54237
  var __dirname9 = dirname25(fileURLToPath8(import.meta.url));
54114
54238
  var root2 = resolve36(__dirname9, "..", "..", "..");
54115
54239
  var PACKAGES = {
@@ -54136,7 +54260,7 @@ var PACKAGES = {
54136
54260
  function newestSourceMtime(srcDir) {
54137
54261
  let newest = 0;
54138
54262
  for (const name of readdirSync11(srcDir)) {
54139
- const p = join23(srcDir, name);
54263
+ const p = join24(srcDir, name);
54140
54264
  const st = statSync20(p);
54141
54265
  if (st.isDirectory()) {
54142
54266
  newest = Math.max(newest, newestSourceMtime(p));
@@ -54147,11 +54271,11 @@ function newestSourceMtime(srcDir) {
54147
54271
  return newest;
54148
54272
  }
54149
54273
  function distStale(pkgDir, entry) {
54150
- const distIndex = join23(pkgDir, "dist", `${entry}.js`);
54274
+ const distIndex = join24(pkgDir, "dist", `${entry}.js`);
54151
54275
  if (!existsSync40(distIndex)) return true;
54152
- const distPkg = join23(pkgDir, "dist", "package.json");
54276
+ const distPkg = join24(pkgDir, "dist", "package.json");
54153
54277
  const distStamp = Math.max(statSync20(distIndex).mtimeMs, existsSync40(distPkg) ? statSync20(distPkg).mtimeMs : 0);
54154
- return newestSourceMtime(join23(pkgDir, "src")) > distStamp;
54278
+ return newestSourceMtime(join24(pkgDir, "src")) > distStamp;
54155
54279
  }
54156
54280
  function distPackageJson(pkgName, entry, serverEntry, version2) {
54157
54281
  const exports = {
@@ -54175,23 +54299,23 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
54175
54299
  function buildPackages(force = false) {
54176
54300
  for (const [pkg, cfg] of Object.entries(PACKAGES)) {
54177
54301
  const pkgDir = resolve36(root2, "packages", pkg);
54178
- if (!existsSync40(join23(pkgDir, "src"))) continue;
54302
+ if (!existsSync40(join24(pkgDir, "src"))) continue;
54179
54303
  if (!force && !distStale(pkgDir, cfg.entry)) continue;
54180
54304
  console.log(`[build] ${cfg.name} -> tsc`);
54181
54305
  const tscBin = require2.resolve("typescript/bin/tsc");
54182
- 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")], {
54183
54307
  stdio: "inherit"
54184
54308
  });
54185
54309
  if (result.status !== 0) {
54186
54310
  throw new Error(`tsc failed for ${cfg.name}`);
54187
54311
  }
54188
- const distDir = join23(pkgDir, "dist");
54312
+ const distDir = join24(pkgDir, "dist");
54189
54313
  for (const c of cfg.copy || []) {
54190
- const to = join23(distDir, c.to);
54314
+ const to = join24(distDir, c.to);
54191
54315
  mkdirSync18(dirname25(to), { recursive: true });
54192
- cpSync2(join23(pkgDir, c.from), to, { recursive: true });
54316
+ cpSync2(join24(pkgDir, c.from), to, { recursive: true });
54193
54317
  }
54194
- const srcPkg = JSON.parse(readFileSync36(join23(pkgDir, "package.json"), "utf-8"));
54318
+ const srcPkg = JSON.parse(readFileSync36(join24(pkgDir, "package.json"), "utf-8"));
54195
54319
  if (pkg === "lucide-vesk") {
54196
54320
  const lucideDistPkg = {
54197
54321
  name: srcPkg.name,
@@ -54205,9 +54329,9 @@ function buildPackages(force = false) {
54205
54329
  "./package.json": "./package.json"
54206
54330
  }
54207
54331
  };
54208
- writeFileSync20(join23(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
54332
+ writeFileSync20(join24(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
54209
54333
  } else {
54210
- 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"));
54211
54335
  }
54212
54336
  console.log(`[build] ${cfg.name} -> dist`);
54213
54337
  }
@@ -54243,10 +54367,10 @@ function parseCookies3(str3) {
54243
54367
  // ../runtime/dist/action.js
54244
54368
  var registryKey2 = "__vesk_actions";
54245
54369
  function getActionRegistry2() {
54246
- const g2 = globalThis;
54247
- if (!g2[registryKey2])
54248
- g2[registryKey2] = {};
54249
- return g2[registryKey2];
54370
+ const g4 = globalThis;
54371
+ if (!g4[registryKey2])
54372
+ g4[registryKey2] = {};
54373
+ return g4[registryKey2];
54250
54374
  }
54251
54375
  function getAction2(id) {
54252
54376
  return getActionRegistry2()[id] || null;
@@ -54684,9 +54808,9 @@ function resolveRuntimeDir(projectDir) {
54684
54808
  resolve38(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
54685
54809
  ];
54686
54810
  for (const dir of candidates) {
54687
- if (existsSync42(join24(dir, "ripple-runtime.js"))) return dir;
54688
- const distDir = join24(dir, "dist");
54689
- 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;
54690
54814
  }
54691
54815
  return null;
54692
54816
  }
@@ -54902,9 +55026,9 @@ function storeDataScript(payload) {
54902
55026
  return "/_vesk/ssr-data.js?t=" + token;
54903
55027
  }
54904
55028
  function currentSsrData() {
54905
- const g2 = globalThis;
54906
- const token = g2.__vsk_ssr_token;
54907
- const slot = (token ? g2[`__vsk_ssr_data_${token}`] : void 0) || {};
55029
+ const g4 = globalThis;
55030
+ const token = g4.__vsk_ssr_token;
55031
+ const slot = (token ? g4[`__vsk_ssr_data_${token}`] : void 0) || {};
54908
55032
  return { ...ssrSink3.snapshot() || {}, ...slot };
54909
55033
  }
54910
55034
  function countPages(nodes) {
@@ -54926,7 +55050,7 @@ function countFilesNamed(dir, name) {
54926
55050
  if (!existsSync42(dir)) return 0;
54927
55051
  let n = 0;
54928
55052
  for (const entry of readdirSync13(dir, { withFileTypes: true })) {
54929
- const p = join24(dir, entry.name);
55053
+ const p = join25(dir, entry.name);
54930
55054
  if (entry.isDirectory()) n += countFilesNamed(p, name);
54931
55055
  else if (entry.name === name) n++;
54932
55056
  }
@@ -54969,7 +55093,7 @@ async function startDevServer(port, projectDir, config, host) {
54969
55093
  process.exit(1);
54970
55094
  }
54971
55095
  const runtimeDir = runtimeDirUnchecked;
54972
- const veskStateDir = join24(projectDir, ".vesk");
55096
+ const veskStateDir = join25(projectDir, ".vesk");
54973
55097
  const configPluginsRaw = config.plugins || [];
54974
55098
  const configPluginNames = configPluginsRaw.map((p) => typeof p === "string" ? p : p?.name).filter((n) => !!n);
54975
55099
  const rawDevPlugins = config.plugins || [];
@@ -54997,9 +55121,9 @@ async function startDevServer(port, projectDir, config, host) {
54997
55121
  }
54998
55122
  }
54999
55123
  function eventsStore() {
55000
- const g2 = globalThis;
55001
- if (!g2.__vesk_server_ctx) g2.__vesk_server_ctx = {};
55002
- return g2.__vesk_server_ctx;
55124
+ const g4 = globalThis;
55125
+ if (!g4.__vesk_server_ctx) g4.__vesk_server_ctx = {};
55126
+ return g4.__vesk_server_ctx;
55003
55127
  }
55004
55128
  function makeEventCtx(overrides) {
55005
55129
  const store = eventsStore();
@@ -55068,10 +55192,10 @@ async function startDevServer(port, projectDir, config, host) {
55068
55192
  }
55069
55193
  let devGlobalCssContent = "";
55070
55194
  let lastServedCssGlobal = "";
55071
- const appCssPath = join24(appDirPath, "global.css");
55072
- const srcDir = join24(projectDir, "src");
55073
- const cssPath = join24(srcDir, "global.css");
55074
- 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");
55075
55199
  let rawCss = "";
55076
55200
  let devCssSource = "";
55077
55201
  if (existsSync42(appCssPath)) {
@@ -55358,7 +55482,7 @@ async function startDevServer(port, projectDir, config, host) {
55358
55482
  if (!filename) return;
55359
55483
  const kind = classifyHmrWatchPath(filename);
55360
55484
  if (kind === "ignored") return;
55361
- const fullPath = filename.startsWith("/") ? filename : join24(watchDir, filename);
55485
+ const fullPath = filename.startsWith("/") ? filename : join25(watchDir, filename);
55362
55486
  const fileExists = existsSync42(fullPath);
55363
55487
  const bcast = (msg) => {
55364
55488
  const f = globalThis.__vesk_broadcastHmr;
@@ -55573,8 +55697,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
55573
55697
  ".json": "application/json",
55574
55698
  ".webmanifest": "application/manifest+json"
55575
55699
  };
55576
- const hmrJsPath = join24(runtimeDir, "hmr-client.js");
55577
- const hmrTsPath = join24(runtimeDir, "hmr-client.ts");
55700
+ const hmrJsPath = join25(runtimeDir, "hmr-client.js");
55701
+ const hmrTsPath = join25(runtimeDir, "hmr-client.ts");
55578
55702
  const hmrClientPath = existsSync42(hmrJsPath) ? hmrJsPath : existsSync42(hmrTsPath) ? hmrTsPath : null;
55579
55703
  function extractCompName2(src2) {
55580
55704
  return resolveComponentName(src2);
@@ -55746,7 +55870,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
55746
55870
  return;
55747
55871
  }
55748
55872
  const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
55749
- const apiDirPath = join24(appDirPath, "api");
55873
+ const apiDirPath = join25(appDirPath, "api");
55750
55874
  if (url.pathname.startsWith("/api") && existsSync42(apiDirPath)) {
55751
55875
  const apiRoutes = await scanApiRoutes(apiDirPath);
55752
55876
  const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
@@ -55860,7 +55984,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
55860
55984
  let freshToken;
55861
55985
  try {
55862
55986
  return await withSsrStore2(async () => {
55863
- freshToken = resetSsrToken();
55987
+ freshToken = resetSsrToken2();
55864
55988
  const chain = cleanChain;
55865
55989
  let body = "";
55866
55990
  let head = "";
@@ -56238,7 +56362,7 @@ ${prettifyHtml(body)}
56238
56362
  LOG.ok(`dev server at http://localhost:${port} (listening on ${bindHost})`);
56239
56363
  const routes = collectRoutePaths(routeTree);
56240
56364
  const pageCount = countPages(routeTree);
56241
- const apiCount = countFilesNamed(join24(appDirPath, "api"), "route.ts");
56365
+ const apiCount = countFilesNamed(join25(appDirPath, "api"), "route.ts");
56242
56366
  LOG.info(`${projectDir}`);
56243
56367
  LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
56244
56368
  if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
@@ -56550,8 +56674,8 @@ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
56550
56674
  }
56551
56675
  function loadEnvFiles(projectDir) {
56552
56676
  const files = [
56553
- join26(projectDir, ".env"),
56554
- join26(projectDir, ".env.local")
56677
+ join27(projectDir, ".env"),
56678
+ join27(projectDir, ".env.local")
56555
56679
  ];
56556
56680
  for (const filePath of files) {
56557
56681
  if (!existsSync43(filePath)) continue;
@@ -56722,7 +56846,7 @@ if (cmd === "start") {
56722
56846
  if (cmd === "init") {
56723
56847
  const projectDir = process.cwd();
56724
56848
  const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
56725
- const target = join26(appDirPath, "global.css");
56849
+ const target = join27(appDirPath, "global.css");
56726
56850
  if (existsSync43(target)) {
56727
56851
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
56728
56852
  process.exit(0);