@vesk/vesk-cli 0.2.93 → 0.2.94

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 +675 -379
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -895,7 +895,7 @@ var init_ir = __esm({
895
895
  });
896
896
 
897
897
  // ../runtime/src/ripple-constants.ts
898
- var ROOT_BLOCK, RENDER_BLOCK, EFFECT_BLOCK, BRANCH_BLOCK, FOR_BLOCK, TRY_BLOCK, IF_BLOCK, SWITCH_BLOCK, COMPOSITE_BLOCK, ASYNC_BLOCK, HEAD_BLOCK, PRE_EFFECT_BLOCK, DIRECT_CHILD_BLOCK, CONTAINS_UPDATE, CONTAINS_TEARDOWN, BLOCK_HAS_RUN, TRACKED, DERIVED, DEFERRED, PAUSED, DESTROYED, UPDATE_SOURCE, CONTROL_FLOW_BLOCK, UNINITIALIZED, TRACKED_ARRAY, TRACKED_OBJECT, COMPUTED_PROPERTY, HMR, ARRAY_SET_INDEX_AT, MAX_ARRAY_LENGTH, TRACKED_UPDATED, SUSPENSE_PENDING, SUSPENSE_REJECTED, ASYNC_DERIVED_READ_THROWN;
898
+ var ROOT_BLOCK, RENDER_BLOCK, EFFECT_BLOCK, BRANCH_BLOCK, FOR_BLOCK, TRY_BLOCK, IF_BLOCK, SWITCH_BLOCK, COMPOSITE_BLOCK, ASYNC_BLOCK, HEAD_BLOCK, PRE_EFFECT_BLOCK, DIRECT_CHILD_BLOCK, CONTAINS_UPDATE, CONTAINS_TEARDOWN, BLOCK_HAS_RUN, TRACKED, DERIVED, DEFERRED, PAUSED, DESTROYED, UPDATE_SOURCE, MANAGED_CHILDREN, CONTROL_FLOW_BLOCK, UNINITIALIZED, TRACKED_ARRAY, TRACKED_OBJECT, COMPUTED_PROPERTY, HMR, ARRAY_SET_INDEX_AT, MAX_ARRAY_LENGTH, TRACKED_UPDATED, SUSPENSE_PENDING, SUSPENSE_REJECTED, ASYNC_DERIVED_READ_THROWN;
899
899
  var init_ripple_constants = __esm({
900
900
  "../runtime/src/ripple-constants.ts"() {
901
901
  "use strict";
@@ -921,6 +921,7 @@ var init_ripple_constants = __esm({
921
921
  PAUSED = 1 << 20;
922
922
  DESTROYED = 1 << 21;
923
923
  UPDATE_SOURCE = 1 << 22;
924
+ MANAGED_CHILDREN = 1 << 23;
924
925
  CONTROL_FLOW_BLOCK = FOR_BLOCK | IF_BLOCK | SWITCH_BLOCK | TRY_BLOCK | COMPOSITE_BLOCK;
925
926
  UNINITIALIZED = Symbol("uninitialized");
926
927
  TRACKED_ARRAY = Symbol();
@@ -955,8 +956,8 @@ function user_effect(fn) {
955
956
  }
956
957
  return block(EFFECT_BLOCK, fn);
957
958
  }
958
- function effect(fn) {
959
- return block(EFFECT_BLOCK, fn);
959
+ function effect(fn, managed = false) {
960
+ return block(EFFECT_BLOCK | (managed ? MANAGED_CHILDREN : 0), fn);
960
961
  }
961
962
  function pre_effect(fn) {
962
963
  return block(PRE_EFFECT_BLOCK, fn);
@@ -1031,16 +1032,12 @@ function destroy_block_children(parent, remove_dom = false) {
1031
1032
  }
1032
1033
  function destroy_non_branch_children(parent, remove_dom = false) {
1033
1034
  let block2 = parent.first;
1034
- if ((parent.f & CONTAINS_TEARDOWN) === 0 && parent.first !== null && (parent.first.f & BRANCH_BLOCK) === 0) {
1035
- parent.first = parent.last = null;
1036
- } else {
1037
- while (block2 !== null) {
1038
- const next = block2.next;
1039
- if ((block2.f & BRANCH_BLOCK) === 0) {
1040
- destroy_block(block2, remove_dom);
1041
- }
1042
- block2 = next;
1035
+ while (block2 !== null) {
1036
+ const next = block2.next;
1037
+ if ((block2.f & BRANCH_BLOCK) === 0) {
1038
+ destroy_block(block2, remove_dom);
1043
1039
  }
1040
+ block2 = next;
1044
1041
  }
1045
1042
  }
1046
1043
  function unlink_block(block2) {
@@ -1283,7 +1280,9 @@ function run_block(block2) {
1283
1280
  active_reaction = block2;
1284
1281
  unsubscribe_reaction(block2);
1285
1282
  active_component = block2.co;
1286
- destroy_non_branch_children(block2);
1283
+ if ((block2.f & MANAGED_CHILDREN) === 0) {
1284
+ destroy_non_branch_children(block2);
1285
+ }
1287
1286
  run_teardown(block2);
1288
1287
  tracking = (block2.f & (ROOT_BLOCK | BRANCH_BLOCK)) === 0;
1289
1288
  active_dependency = null;
@@ -1337,7 +1336,7 @@ function track(v, b, get2, set2) {
1337
1336
  }
1338
1337
  function create_dependency(tracked2) {
1339
1338
  const reaction = active_reaction;
1340
- if (is_orphan(tracked2.b)) {
1339
+ if (is_orphan(tracked2.b) || (tracked2.f & DERIVED) !== 0) {
1341
1340
  (tracked2.r ??= /* @__PURE__ */ new Set()).add(reaction);
1342
1341
  }
1343
1342
  const existing2 = reaction.d;
@@ -1579,7 +1578,7 @@ function unsubscribe_reaction(reaction) {
1579
1578
  let dep = reaction.d;
1580
1579
  while (dep !== null) {
1581
1580
  const t = dep.t;
1582
- if (is_orphan(t.b) && t.r !== null) {
1581
+ if (t.r !== null) {
1583
1582
  t.r.delete(reaction);
1584
1583
  }
1585
1584
  dep = dep.n;
@@ -20663,9 +20662,59 @@ function stripOuterQuotes(s) {
20663
20662
  function exportGetter(lines, key, valueExpr) {
20664
20663
  lines.push(`Object.defineProperty(exports, ${JSON.stringify(key)}, { get: () => ${valueExpr}, enumerable: true });`);
20665
20664
  }
20666
- function esmToCjs(body) {
20665
+ function promiseOfRequire(sourceNode) {
20666
+ return {
20667
+ type: "CallExpression",
20668
+ optional: false,
20669
+ callee: {
20670
+ type: "MemberExpression",
20671
+ optional: false,
20672
+ computed: false,
20673
+ object: {
20674
+ type: "CallExpression",
20675
+ optional: false,
20676
+ callee: {
20677
+ type: "MemberExpression",
20678
+ optional: false,
20679
+ computed: false,
20680
+ object: { type: "Identifier", name: "Promise" },
20681
+ property: { type: "Identifier", name: "resolve" }
20682
+ },
20683
+ arguments: []
20684
+ },
20685
+ property: { type: "Identifier", name: "then" }
20686
+ },
20687
+ arguments: [
20688
+ {
20689
+ type: "ArrowFunctionExpression",
20690
+ id: null,
20691
+ expression: true,
20692
+ generator: false,
20693
+ async: false,
20694
+ params: [],
20695
+ body: {
20696
+ type: "CallExpression",
20697
+ optional: false,
20698
+ callee: { type: "Identifier", name: "require" },
20699
+ arguments: [sourceNode]
20700
+ }
20701
+ }
20702
+ ]
20703
+ };
20704
+ }
20705
+ function rewriteDynamicImports(node, specs) {
20706
+ return walk2(node, null, {
20707
+ ImportExpression(n) {
20708
+ const spec = stringLiteralValue(n.source);
20709
+ if (!spec || !specs.has(spec)) return;
20710
+ return promiseOfRequire(n.source);
20711
+ }
20712
+ });
20713
+ }
20714
+ function esmToCjs(body, rewriteImports) {
20715
+ const statements = rewriteImports ? body.map((stmt) => rewriteDynamicImports(stmt, rewriteImports)) : body;
20667
20716
  const lines = [];
20668
- for (const stmt of body) {
20717
+ for (const stmt of statements) {
20669
20718
  switch (stmt.type) {
20670
20719
  case "ImportDeclaration": {
20671
20720
  const source = printNode(stmt.source);
@@ -20760,6 +20809,19 @@ function esmToCjs(body) {
20760
20809
  }
20761
20810
  return lines.join("\n");
20762
20811
  }
20812
+ function moduleKeyFor(absPath) {
20813
+ const seeds = [2166136261, 2654435761, 2246822507, 3266489909];
20814
+ let hex = "";
20815
+ for (const seed of seeds) {
20816
+ let h = seed >>> 0;
20817
+ for (let i = 0; i < absPath.length; i++) {
20818
+ h ^= absPath.charCodeAt(i);
20819
+ h = Math.imul(h, 16777619) >>> 0;
20820
+ }
20821
+ hex += h.toString(16).padStart(8, "0");
20822
+ }
20823
+ return `__veskMod${hex}`;
20824
+ }
20763
20825
  function stringLiteralValue(node) {
20764
20826
  const n = node;
20765
20827
  if (n && (n.type === "Literal" || n.type === "StringLiteral") && typeof n.value === "string") {
@@ -20770,31 +20832,40 @@ function stringLiteralValue(node) {
20770
20832
  function collectModuleSpecifiers(ast) {
20771
20833
  const specs = /* @__PURE__ */ new Set();
20772
20834
  walk2(ast, null, {
20773
- ImportDeclaration(node) {
20774
- if (node.importKind === "type") return;
20775
- const v = stringLiteralValue(node.source);
20776
- if (v) specs.add(v);
20835
+ ImportDeclaration(node, ctx2) {
20836
+ if (node.importKind !== "type") {
20837
+ const v = stringLiteralValue(node.source);
20838
+ if (v) specs.add(v);
20839
+ }
20840
+ ctx2.next();
20777
20841
  },
20778
- ExportNamedDeclaration(node) {
20779
- if (node.exportKind === "type" || !node.source) return;
20780
- const v = stringLiteralValue(node.source);
20781
- if (v) specs.add(v);
20842
+ ExportNamedDeclaration(node, ctx2) {
20843
+ if (node.exportKind !== "type" && node.source) {
20844
+ const v = stringLiteralValue(node.source);
20845
+ if (v) specs.add(v);
20846
+ }
20847
+ ctx2.next();
20782
20848
  },
20783
- ExportAllDeclaration(node) {
20784
- if (node.exportKind === "type") return;
20785
- const v = stringLiteralValue(node.source);
20786
- if (v) specs.add(v);
20849
+ ExportAllDeclaration(node, ctx2) {
20850
+ if (node.exportKind !== "type") {
20851
+ const v = stringLiteralValue(node.source);
20852
+ if (v) specs.add(v);
20853
+ }
20854
+ ctx2.next();
20787
20855
  },
20788
- CallExpression(node) {
20856
+ CallExpression(node, ctx2) {
20789
20857
  const callee = node.callee;
20790
- if (!callee || callee.type !== "Identifier" || callee.name !== "require") return;
20791
- const args2 = node.arguments || [];
20792
- const v = stringLiteralValue(args2[0]);
20793
- if (v) specs.add(v);
20858
+ if (callee && callee.type === "Identifier" && callee.name === "require") {
20859
+ const args2 = node.arguments || [];
20860
+ const v = stringLiteralValue(args2[0]);
20861
+ if (v) specs.add(v);
20862
+ }
20863
+ ctx2.next();
20794
20864
  },
20795
- ImportExpression(node) {
20865
+ ImportExpression(node, ctx2) {
20796
20866
  const v = stringLiteralValue(node.source);
20797
20867
  if (v) specs.add(v);
20868
+ ctx2.next();
20798
20869
  }
20799
20870
  });
20800
20871
  return specs;
@@ -20820,6 +20891,7 @@ function collectModuleBundled(absPath, registry) {
20820
20891
  const cached = mtimeMs >= 0 ? bundledCodeCache.get(absPath) : void 0;
20821
20892
  let code;
20822
20893
  let specifiers;
20894
+ let deps = null;
20823
20895
  if (cached && cached.mtimeMs === mtimeMs) {
20824
20896
  code = cached.code;
20825
20897
  specifiers = cached.specifiers;
@@ -20834,10 +20906,15 @@ function collectModuleBundled(absPath, registry) {
20834
20906
  if (hasTsSyntax(src2.ast)) stripped = stripTsTypes(src2.ast);
20835
20907
  stripped.body = (stripped.body || []).filter((n) => n ? !isTypeOnlyStatement(n) : false);
20836
20908
  specifiers = [...collectModuleSpecifiers(src2.ast)];
20837
- code = esmToCjs(stripped.body);
20909
+ deps = resolveBundledDeps(specifiers, dir, registry);
20910
+ code = esmToCjs(stripped.body, new Set(Object.keys(deps)));
20838
20911
  bundledCodeCache.set(absPath, { mtimeMs, code, specifiers });
20839
20912
  evict(bundledCodeCache);
20840
20913
  }
20914
+ if (!deps) deps = resolveBundledDeps(specifiers, dir, registry);
20915
+ return registry.register(absPath, { code, dir, deps });
20916
+ }
20917
+ function resolveBundledDeps(specifiers, dir, registry) {
20841
20918
  const deps = {};
20842
20919
  for (const spec of specifiers) {
20843
20920
  if (isCompilerOwnedTarget(spec) || isValueLessTarget(spec)) continue;
@@ -20845,7 +20922,7 @@ function collectModuleBundled(absPath, registry) {
20845
20922
  if (!depPath || isBuiltinPath(depPath)) continue;
20846
20923
  deps[spec] = collectModuleBundled(depPath, registry);
20847
20924
  }
20848
- return registry.register(absPath, { code, dir, deps });
20925
+ return deps;
20849
20926
  }
20850
20927
  function collectModuleBundle(importStrs, fromDir, registry, collector) {
20851
20928
  const bindings = [];
@@ -20904,13 +20981,13 @@ var init_module_imports = __esm({
20904
20981
  get size() {
20905
20982
  return this.data.size;
20906
20983
  }
20907
- /** Register a module's transpiled body, returning its globally-unique key. */
20984
+ /** Register a module's transpiled body, returning its stable key. */
20908
20985
  register(absPath, entry) {
20909
20986
  const existing2 = this.keysByAbs.get(absPath);
20910
20987
  if (existing2) return existing2;
20911
- const key = `__veskMod${this.data.size}`;
20988
+ const key = moduleKeyFor(absPath);
20912
20989
  this.keysByAbs.set(absPath, key);
20913
- this.data.set(key, entry);
20990
+ this.data.set(key, { ...entry, absPath });
20914
20991
  return key;
20915
20992
  }
20916
20993
  getModule(key) {
@@ -32277,6 +32354,7 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
32277
32354
  ctx2.push(` const __slot = createLayoutSlot(${ctx2.walker}, ${parentVar});`);
32278
32355
  ctx2.push(` const __child = props.children(__slot.walker);`);
32279
32356
  ctx2.push(` if (__child && typeof __child.then === 'function') __pendingChild = __slot.track(__child);`);
32357
+ ctx2.push(` else if (__child && __child.nodeType === 11) ${parentVar}.appendChild(__child);`);
32280
32358
  ctx2.push(` } else {`);
32281
32359
  ctx2.push(` ${parentVar}.appendChild(props.children);`);
32282
32360
  ctx2.push(` }`);
@@ -32650,6 +32728,33 @@ function emitFragment(ctx2, nodes, tracked2, effectsVar) {
32650
32728
  ctx2.push(`return $f; })();`);
32651
32729
  return frag;
32652
32730
  }
32731
+ function containsSlot(nodes) {
32732
+ for (const node of nodes) {
32733
+ if (node instanceof SlotNode) return true;
32734
+ if (node instanceof StaticNode) {
32735
+ if (containsSlot(node.children)) return true;
32736
+ } else if (node instanceof ComponentCall) {
32737
+ if (containsSlot(node.children)) return true;
32738
+ } else if (node instanceof OpaqueDynamicRegion) {
32739
+ if (containsSlot(node.consequentNodes) || containsSlot(node.alternateNodes)) return true;
32740
+ } else if (node instanceof MapRegion) {
32741
+ if (containsSlot(node.bodyTemplate) || containsSlot(node.alternateNodes)) return true;
32742
+ } else if (node instanceof WhileLoop) {
32743
+ if (containsSlot(node.bodyTemplate)) return true;
32744
+ } else if (node instanceof ForLoop) {
32745
+ if (containsSlot(node.bodyTemplate)) return true;
32746
+ } else if (node instanceof SwitchBlock) {
32747
+ for (const c of node.cases) if (containsSlot(c.body)) return true;
32748
+ } else if (node instanceof TryCatch) {
32749
+ if (containsSlot(node.bodyTemplate) || containsSlot(node.catchBody)) return true;
32750
+ } else if (node instanceof ServerBlock || node instanceof ClientBlock || node instanceof HeadBlock) {
32751
+ if (containsSlot(node.children)) return true;
32752
+ } else if (node instanceof PropSlot) {
32753
+ if (containsSlot(node.body)) return true;
32754
+ }
32755
+ }
32756
+ return false;
32757
+ }
32653
32758
  function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
32654
32759
  const propsEntries = node.props.map((p) => {
32655
32760
  if (typeof p.value === "string") return `${JSON.stringify(p.name)}: ${JSON.stringify(p.value)}`;
@@ -32708,18 +32813,45 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
32708
32813
  const wipeMount = ctx2.linkNames.has(node.componentName);
32709
32814
  const savedHydrate = ctx2.hydrate;
32710
32815
  if (wipeMount || ctx2.selfClaimNames.has(node.componentName)) ctx2.hydrate = false;
32711
- ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
32712
- const savedEffects = ctx2.effects;
32713
- ctx2.effects = [];
32714
- for (const child of regChildren) {
32715
- const childVar = emitNode(ctx2, child, tracked2, effectsVar, "$f");
32716
- if (childVar) ctx2.push(`$f.appendChild(${childVar});`);
32816
+ const lazySlotChildren = ctx2.hydrate && !plainTarget && !ctx2.selfClaimNames.has(node.componentName) && containsSlot(regChildren);
32817
+ if (lazySlotChildren) {
32818
+ const fnVar = ctx2.n();
32819
+ const savedLines = ctx2.lines;
32820
+ const savedEffects = ctx2.effects;
32821
+ const savedWalker = ctx2.walker;
32822
+ ctx2.lines = [];
32823
+ ctx2.effects = [];
32824
+ ctx2.walker = "__childWalker";
32825
+ ctx2.push(`const $f = document.createDocumentFragment();`);
32826
+ for (const child of regChildren) {
32827
+ const childVar = emitNode(ctx2, child, tracked2, effectsVar, "$f");
32828
+ if (childVar) ctx2.push(`$f.appendChild(${childVar});`);
32829
+ }
32830
+ for (const eff of ctx2.effects) ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr(eff)});` : eff);
32831
+ ctx2.push(`return $f;`);
32832
+ const body = ctx2.lines.join("\n");
32833
+ ctx2.lines = savedLines;
32834
+ ctx2.effects = savedEffects;
32835
+ ctx2.walker = savedWalker;
32836
+ const asyncKw = ctx2.isAsyncScope ? "async " : "";
32837
+ ctx2.push(`const ${fnVar} = ${asyncKw}(__childWalker) => {`);
32838
+ ctx2.push(indent2(body));
32839
+ ctx2.push(`};`);
32840
+ propsEntries.push(`children: ${fnVar}`);
32841
+ } else {
32842
+ ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
32843
+ const savedEffects = ctx2.effects;
32844
+ ctx2.effects = [];
32845
+ for (const child of regChildren) {
32846
+ const childVar = emitNode(ctx2, child, tracked2, effectsVar, "$f");
32847
+ if (childVar) ctx2.push(`$f.appendChild(${childVar});`);
32848
+ }
32849
+ for (const eff of ctx2.effects) ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr(eff)});` : eff);
32850
+ ctx2.effects = savedEffects;
32851
+ ctx2.push(`return $f; })();`);
32852
+ propsEntries.push(`children: ${frag}`);
32717
32853
  }
32718
- for (const eff of ctx2.effects) ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr(eff)});` : eff);
32719
- ctx2.effects = savedEffects;
32720
32854
  ctx2.hydrate = savedHydrate;
32721
- ctx2.push(`return $f; })();`);
32722
- propsEntries.push(`children: ${frag}`);
32723
32855
  }
32724
32856
  if (ctx2.markerless && promptExpr) {
32725
32857
  ctx2.push(`${walkerArg}.injectSkipK(${promptExpr});`);
@@ -32869,7 +33001,7 @@ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar, skipK = 0, re
32869
33001
  ${effArr}.length = 0;
32870
33002
  __cleanup(${anchor}, ${endAnchor});
32871
33003
  try { ${asyncKw}${tryRenderComp}(); } catch(${catchParam}) { ${hasCatch ? `${asyncKw}${catchRenderComp}(${catchParam});` : "throw ${catchParam};"} }
32872
- });
33004
+ }, true);
32873
33005
  }`);
32874
33006
  return null;
32875
33007
  }
@@ -32955,7 +33087,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
32955
33087
  ${effInner}
32956
33088
  __iv = __new;
32957
33089
  }
32958
- });`;
33090
+ }, true);`;
32959
33091
  if (effTarget) {
32960
33092
  ctx2.push(`${effTarget}.push((() => {
32961
33093
  let __iv = ${branchInit};
@@ -33037,7 +33169,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
33037
33169
  ${renderBranch}
33038
33170
  __iv = __nv;
33039
33171
  }
33040
- });`;
33172
+ }, true);`;
33041
33173
  if (!isReactiveExpression(node.condition, tracked2)) return null;
33042
33174
  if (effTarget) {
33043
33175
  ctx2.push(`${effTarget}.push((() => {
@@ -33123,7 +33255,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
33123
33255
  __busy = false;
33124
33256
  __iv = (${condExpr});
33125
33257
  }
33126
- });
33258
+ }, true);
33127
33259
  }`);
33128
33260
  return null;
33129
33261
  }
@@ -33207,7 +33339,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
33207
33339
  __busy = false;
33208
33340
  __iv = (${srcExpr});
33209
33341
  }
33210
- });
33342
+ }, true);
33211
33343
  }`);
33212
33344
  } else {
33213
33345
  const condReactive = isReactiveExpression(node.condition, tracked2);
@@ -33270,7 +33402,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
33270
33402
  __cleanup(${anchor}, ${endAnchor});
33271
33403
  ${ctx2.isAsyncScope ? "await " : ""}${renderLoop}();
33272
33404
  __busy = false;
33273
- });
33405
+ }, true);
33274
33406
  }`);
33275
33407
  }
33276
33408
  }
@@ -33336,7 +33468,7 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar, skipK = 0, regionBudge
33336
33468
  __busy = false;
33337
33469
  __iv = (${discExpr});
33338
33470
  }
33339
- });
33471
+ }, true);
33340
33472
  }`);
33341
33473
  return null;
33342
33474
  }
@@ -33482,7 +33614,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
33482
33614
  ${effectsVar}.length = 0;
33483
33615
  __cleanup(${anchor}, ${endAnchor});
33484
33616
  if (__new) { ${initList}(); } else { ${aw}${emptyRenderName}(); }
33485
- })`);
33617
+ }, true)`);
33486
33618
  } else {
33487
33619
  ctx2.push(`${initList}();`);
33488
33620
  if (!reactiveSource) return null;
@@ -33490,7 +33622,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
33490
33622
  const __nv = ${arrExpr};
33491
33623
  if (__first) { __first = false; __nv; ${breakReset}${reconciler}(${arrExpr}); return; }
33492
33624
  ${breakVar ? `if (${breakVar}) ${breakVar} = false;` : ""}${reconciler}(${arrExpr});
33493
- })`);
33625
+ }, true)`);
33494
33626
  }
33495
33627
  } else {
33496
33628
  const renderAllItems = (ind, collect) => {
@@ -33540,7 +33672,7 @@ ${renderAllItems(" ", null)}
33540
33672
  if (__new) {
33541
33673
  ${renderAllItems(" ", null)}
33542
33674
  } else { ${aw}${emptyRenderName}(${collectVar ? collectVar : ""}); }
33543
- })`);
33675
+ }, true)`);
33544
33676
  } else {
33545
33677
  const collectVar = hyd ? ctx2.n() : null;
33546
33678
  if (collectVar) ctx2.push(`const ${collectVar} = [];`);
@@ -33554,7 +33686,7 @@ ${renderAllItems(" ", null)}
33554
33686
  ${effectsVar}.length = 0;
33555
33687
  __cleanup(${anchor}, ${endAnchor});
33556
33688
  ${renderAllItems(" ", null)}
33557
- })`);
33689
+ }, true)`);
33558
33690
  }
33559
33691
  }
33560
33692
  return null;
@@ -36173,6 +36305,129 @@ var init_default_pages = __esm({
36173
36305
  }
36174
36306
  });
36175
36307
 
36308
+ // ../adapter/src/server-only.ts
36309
+ import { readFileSync as readFileSync11, readdirSync as readdirSync2, statSync as statSync3 } from "node:fs";
36310
+ import { join as join7 } from "node:path";
36311
+ function tcpDriverPackages() {
36312
+ return [...TCP_DRIVERS].filter((spec) => !spec.startsWith("node:"));
36313
+ }
36314
+ function classifySpecifier(spec) {
36315
+ if (typeof spec !== "string" || spec.length === 0) return null;
36316
+ if (TCP_DRIVERS.has(spec)) return "tcp-driver";
36317
+ if (spec.startsWith("node:")) return "tcp-driver";
36318
+ if (SERVER_ONLY_EXACT.has(spec)) return "server-only-package";
36319
+ return null;
36320
+ }
36321
+ function scanServerOnlyImports(files) {
36322
+ const out = [];
36323
+ for (const file of files) {
36324
+ let ast;
36325
+ try {
36326
+ ast = parse4(file.code);
36327
+ } catch {
36328
+ continue;
36329
+ }
36330
+ for (const node of ast.body ?? []) {
36331
+ if (node?.type !== "ImportDeclaration" && node?.type !== "ExportNamedDeclaration" && node?.type !== "ExportAllDeclaration") continue;
36332
+ const spec = node.source?.value;
36333
+ if (typeof spec !== "string") continue;
36334
+ const kind = classifySpecifier(spec);
36335
+ if (!kind) continue;
36336
+ out.push({
36337
+ kind,
36338
+ specifier: spec,
36339
+ file: file.path,
36340
+ line: lineOf(file.code, node.start),
36341
+ remedy: REMEDY[kind]
36342
+ });
36343
+ }
36344
+ }
36345
+ return out;
36346
+ }
36347
+ function lineOf(code, offset2) {
36348
+ if (typeof offset2 !== "number" || offset2 < 0 || offset2 > code.length) return null;
36349
+ let line = 1;
36350
+ for (let i = 0; i < offset2; i++) {
36351
+ if (code.charCodeAt(i) === 10) line++;
36352
+ }
36353
+ return line;
36354
+ }
36355
+ function edgeDriverBuildError(violations) {
36356
+ const detail = violations.map((v) => ` ${v.file}${v.line ? `:${v.line}` : ""} \u2014 import "${v.specifier}"
36357
+ ${v.remedy}`).join("\n");
36358
+ return new Error(
36359
+ `[vesk] edge-targeted build cannot include a TCP-only driver (${violations.length} found).
36360
+ ${detail}
36361
+
36362
+ This was a build error rather than a runtime one because an edge runtime has no socket: the deployed function would fail on its first query.`
36363
+ );
36364
+ }
36365
+ function isSocketlessTarget(platform, target) {
36366
+ if (target === "edge") return true;
36367
+ return typeof platform === "string" && SOCKETLESS_PLATFORMS.has(platform);
36368
+ }
36369
+ function collectAppSources(dir, out = []) {
36370
+ let entries;
36371
+ try {
36372
+ entries = readdirSync2(dir);
36373
+ } catch {
36374
+ return out;
36375
+ }
36376
+ for (const entry of entries) {
36377
+ if (SKIPPED_DIRS.has(entry) || entry.startsWith(".")) continue;
36378
+ const full = join7(dir, entry);
36379
+ let st;
36380
+ try {
36381
+ st = statSync3(full);
36382
+ } catch {
36383
+ continue;
36384
+ }
36385
+ if (st.isDirectory()) collectAppSources(full, out);
36386
+ else if (st.isFile()) {
36387
+ const dot = entry.lastIndexOf(".");
36388
+ if (dot === -1) continue;
36389
+ if (SOURCE_EXTENSIONS.includes(entry.slice(dot).toLowerCase())) out.push(full);
36390
+ }
36391
+ }
36392
+ return out;
36393
+ }
36394
+ function tcpDriverViolations(appDir) {
36395
+ const files = [];
36396
+ for (const path of collectAppSources(appDir)) {
36397
+ try {
36398
+ files.push({ path, code: readFileSync11(path, "utf-8") });
36399
+ } catch {
36400
+ }
36401
+ }
36402
+ return scanServerOnlyImports(files).filter((v) => v.kind === "tcp-driver");
36403
+ }
36404
+ var SERVER_ONLY_EXACT, TCP_DRIVERS, REMEDY, SOCKETLESS_PLATFORMS, SOURCE_EXTENSIONS, SKIPPED_DIRS;
36405
+ var init_server_only = __esm({
36406
+ "../adapter/src/server-only.ts"() {
36407
+ "use strict";
36408
+ init_parser();
36409
+ SERVER_ONLY_EXACT = /* @__PURE__ */ new Set([
36410
+ "slintorm",
36411
+ "@vesk/adapter"
36412
+ ]);
36413
+ TCP_DRIVERS = /* @__PURE__ */ new Set([
36414
+ "pg",
36415
+ "mysql2",
36416
+ "mongodb",
36417
+ "node:sqlite",
36418
+ "node:net",
36419
+ "node:tls"
36420
+ ]);
36421
+ REMEDY = {
36422
+ "server-only-package": "import it from an API route (app/api/**/route.ts) or a server action instead of a component, or use the package's browser/edge entry point if it ships one.",
36423
+ "tcp-driver": 'this driver opens a TCP socket, which no edge runtime provides. Use the driver\'s HTTP/HTTPS transport (for SlintORM: `driver: "postgrest"`), or build for a Node target.'
36424
+ };
36425
+ SOCKETLESS_PLATFORMS = /* @__PURE__ */ new Set(["edge", "cloudflare", "deno", "coxmos"]);
36426
+ SOURCE_EXTENSIONS = [".vsk", ".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
36427
+ SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".vesk", ".git", "dist", ".next", ".output", "coverage"]);
36428
+ }
36429
+ });
36430
+
36176
36431
  // ../adapter/src/paths.ts
36177
36432
  import { resolve as resolve11, sep as sep2 } from "node:path";
36178
36433
  import { existsSync as existsSync12, statSync as statSync5, readFileSync as readFileSync14 } from "node:fs";
@@ -38149,11 +38404,12 @@ export const execSync = () => '';
38149
38404
  }
38150
38405
  });
38151
38406
  }
38407
+ const qrStubPattern = nodeBuiltins ? /^(canvas|@zxing\/(browser|node))(\/|$)/ : /^(vesk-qr|qrcode-generator|canvas|@zxing\/(browser|node))(\/|$)/;
38152
38408
  plugins.push({
38153
- name: "stub-edge-packages",
38409
+ name: "stub-optional-qr-packages",
38154
38410
  setup(build5) {
38155
38411
  build5.onResolve(
38156
- { filter: /^(vesk-qr|qrcode-generator|canvas|@zxing\/(browser|node))(\/|$)/ },
38412
+ { filter: qrStubPattern },
38157
38413
  (args2) => ({ path: args2.path, namespace: "vesk-edge-stub" })
38158
38414
  );
38159
38415
  build5.onLoad({ filter: /.*/, namespace: "vesk-edge-stub" }, () => ({
@@ -38229,10 +38485,50 @@ var init_platform_handler = __esm({
38229
38485
  // ../adapter/src/platform-deploy.ts
38230
38486
  var platform_deploy_exports = {};
38231
38487
  __export(platform_deploy_exports, {
38232
- emitPlatformOutput: () => emitPlatformOutput
38488
+ emitPlatformOutput: () => emitPlatformOutput,
38489
+ shipNodeDriverClosures: () => shipNodeDriverClosures,
38490
+ vercelBootstrapSource: () => vercelBootstrapSource
38233
38491
  });
38234
- import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync10, rmSync as rmSync3, cpSync } from "node:fs";
38235
- import { resolve as resolve20 } from "node:path";
38492
+ import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync10, rmSync as rmSync3, cpSync, readFileSync as readFileSync23, existsSync as existsSync22 } from "node:fs";
38493
+ import { resolve as resolve20, dirname as dirname16, relative as relative3 } from "node:path";
38494
+ function resolveInstalledPackage(projectRoot, name) {
38495
+ let dir = projectRoot;
38496
+ while (true) {
38497
+ const candidate = resolve20(dir, "node_modules", name);
38498
+ if (existsSync22(resolve20(candidate, "package.json"))) return candidate;
38499
+ const parent = dirname16(dir);
38500
+ if (parent === dir) return null;
38501
+ dir = parent;
38502
+ }
38503
+ }
38504
+ function shipNodeDriverClosures(projectRoot, funcDir) {
38505
+ const destModules = resolve20(funcDir, "node_modules");
38506
+ const seen = /* @__PURE__ */ new Set();
38507
+ const queue = tcpDriverPackages();
38508
+ while (queue.length > 0) {
38509
+ const name = queue.shift();
38510
+ if (seen.has(name)) continue;
38511
+ seen.add(name);
38512
+ const pkgDir = resolveInstalledPackage(projectRoot, name);
38513
+ if (!pkgDir) continue;
38514
+ const dest = resolve20(destModules, name);
38515
+ mkdirSync10(dirname16(dest), { recursive: true });
38516
+ cpSync(pkgDir, dest, {
38517
+ recursive: true,
38518
+ filter: (src2) => !relative3(pkgDir, src2).split(/[\\/]/).includes("node_modules")
38519
+ });
38520
+ let pkg = {};
38521
+ try {
38522
+ pkg = JSON.parse(readFileSync23(resolve20(pkgDir, "package.json"), "utf-8"));
38523
+ } catch {
38524
+ }
38525
+ const deps = {
38526
+ ...pkg.dependencies || {},
38527
+ ...pkg.optionalDependencies || {}
38528
+ };
38529
+ for (const dep of Object.keys(deps)) queue.push(dep);
38530
+ }
38531
+ }
38236
38532
  async function emitPlatformOutput(platform, ctx2) {
38237
38533
  if (platform === "node") return null;
38238
38534
  const prerenderedPaths = ctx2.prerenderedRoutes.map((r) => r.path);
@@ -38277,6 +38573,7 @@ ${shell.bootstrap}
38277
38573
  }
38278
38574
  handlerRel = `${shell.functionFile.dir}/${shell.functionFile.file}`;
38279
38575
  await bundlePlatformHandler({ entry, outfile: resolve20(funcDir, shell.functionFile.file), nodeBuiltins: shell.nodeBuiltins });
38576
+ if (shell.nodeBuiltins) shipNodeDriverClosures(projectRoot, funcDir);
38280
38577
  } else {
38281
38578
  handlerRel = shell.outfile || "index.js";
38282
38579
  await bundlePlatformHandler({ entry, outfile: resolve20(outRoot, handlerRel), nodeBuiltins: shell.nodeBuiltins });
@@ -38396,6 +38693,34 @@ function serveEmbeddedStatic(request) {
38396
38693
  return null;
38397
38694
  }`;
38398
38695
  }
38696
+ function vercelBootstrapSource() {
38697
+ return [
38698
+ "export default async function veskNodeEntry(req, res) {",
38699
+ " const __fwdHost = String(req.headers['x-forwarded-host'] || '').split(',')[0].trim();",
38700
+ " const __host = __fwdHost || req.headers.host || 'localhost';",
38701
+ " const __fwdProto = String(req.headers['x-forwarded-proto'] || '').split(',')[0].trim();",
38702
+ " const __local = __host === 'localhost' || __host.startsWith('127.') || __host === '[::1]';",
38703
+ " const __proto = __fwdProto || (__local ? 'http' : 'https');",
38704
+ " const url = new URL(req.url, `${__proto}://${__host}`);",
38705
+ " const method = req.method || 'GET';",
38706
+ " let body;",
38707
+ " if (method !== 'GET' && method !== 'HEAD') {",
38708
+ " body = await new Promise((resolveBody, reject) => {",
38709
+ " const chunks = [];",
38710
+ " req.on('data', (c) => chunks.push(c));",
38711
+ ' req.on("error", reject);',
38712
+ ' req.on("end", () => resolveBody(Buffer.concat(chunks)));',
38713
+ " });",
38714
+ " }",
38715
+ " const headers = {};",
38716
+ " for (const key in req.headers) headers[key] = req.headers[key];",
38717
+ " const request = new Request(url, { method, headers, body });",
38718
+ " const response = await handleRequest(request);",
38719
+ " res.writeHead(response.status, Object.fromEntries(response.headers));",
38720
+ " res.end(await response.text());",
38721
+ "}"
38722
+ ].join("\n");
38723
+ }
38399
38724
  function shellFor(platform) {
38400
38725
  switch (platform) {
38401
38726
  case "vercel":
@@ -38416,27 +38741,7 @@ function shellFor(platform) {
38416
38741
  shouldAddSourcemapSupport: false,
38417
38742
  supportsResponseStreaming: true
38418
38743
  },
38419
- bootstrap: [
38420
- "export default async function veskNodeEntry(req, res) {",
38421
- " const url = new URL(req.url, 'http://' + (req.headers.host || 'localhost'));",
38422
- " const method = req.method || 'GET';",
38423
- " let body;",
38424
- " if (method !== 'GET' && method !== 'HEAD') {",
38425
- " body = await new Promise((resolveBody, reject) => {",
38426
- " const chunks = [];",
38427
- " req.on('data', (c) => chunks.push(c));",
38428
- ' req.on("error", reject);',
38429
- ' req.on("end", () => resolveBody(Buffer.concat(chunks)));',
38430
- " });",
38431
- " }",
38432
- " const headers = {};",
38433
- " for (const key in req.headers) headers[key] = req.headers[key];",
38434
- " const request = new Request(url, { method, headers, body });",
38435
- " const response = await handleRequest(request);",
38436
- " res.writeHead(response.status, Object.fromEntries(response.headers));",
38437
- " res.end(await response.text());",
38438
- "}"
38439
- ].join("\n")
38744
+ bootstrap: vercelBootstrapSource()
38440
38745
  };
38441
38746
  case "netlify":
38442
38747
  return {
@@ -38579,6 +38884,7 @@ var init_platform_deploy = __esm({
38579
38884
  "use strict";
38580
38885
  init_platform_handler();
38581
38886
  init_platform_output();
38887
+ init_server_only();
38582
38888
  }
38583
38889
  });
38584
38890
 
@@ -49659,7 +49965,7 @@ __export(codemods_exports, {
49659
49965
  applicableCodemods: () => applicableCodemods,
49660
49966
  compareCore: () => compareCore
49661
49967
  });
49662
- import { readFileSync as readFileSync44, existsSync as existsSync44 } from "node:fs";
49968
+ import { readFileSync as readFileSync44, existsSync as existsSync45 } from "node:fs";
49663
49969
  import { join as join30 } from "node:path";
49664
49970
  import { walk as walk8 } from "zimmerframe";
49665
49971
  function safeParse(source, filePath) {
@@ -49682,7 +49988,7 @@ function typesPackageExports(projectDir) {
49682
49988
  const candidates = [
49683
49989
  projectDir ? join30(projectDir, "node_modules", "@vesk", "types", "dist", "index.d.ts") : null,
49684
49990
  new URL("../../types/dist/index.d.ts", import.meta.url).pathname
49685
- ].filter((p) => typeof p === "string" && existsSync44(p));
49991
+ ].filter((p) => typeof p === "string" && existsSync45(p));
49686
49992
  for (const path of candidates) {
49687
49993
  try {
49688
49994
  const src2 = readFileSync44(path, "utf-8");
@@ -49809,12 +50115,12 @@ __export(migrate_exports, {
49809
50115
  detectInstalledVersion: () => detectInstalledVersion,
49810
50116
  runMigrate: () => runMigrate
49811
50117
  });
49812
- import { readFileSync as readFileSync45, writeFileSync as writeFileSync22, existsSync as existsSync45, statSync as statSync24, readdirSync as readdirSync16 } from "node:fs";
50118
+ import { readFileSync as readFileSync45, writeFileSync as writeFileSync22, existsSync as existsSync46, statSync as statSync24, readdirSync as readdirSync16 } from "node:fs";
49813
50119
  import { join as join31, relative as relative11, extname as extname8 } from "node:path";
49814
50120
  function detectInstalledVersion(projectDir, cliVersion) {
49815
50121
  for (const pkg of ["@vesk/vesk-cli", "@vesk/adapter", "@vesk/compiler"]) {
49816
50122
  const p = join31(projectDir, "node_modules", pkg, "package.json");
49817
- if (!existsSync45(p)) continue;
50123
+ if (!existsSync46(p)) continue;
49818
50124
  try {
49819
50125
  const version2 = JSON.parse(readFileSync45(p, "utf-8")).version;
49820
50126
  if (typeof version2 === "string" && version2) return { version: version2, source: pkg };
@@ -49870,7 +50176,7 @@ function runMigrate(options) {
49870
50176
  for (const relPath of collectTargets(options.projectDir)) {
49871
50177
  const abs = join31(options.projectDir, relPath);
49872
50178
  const ctx2 = { filePath: abs, displayPath: relPath, projectDir: options.projectDir };
49873
- if (!existsSync45(abs)) continue;
50179
+ if (!existsSync46(abs)) continue;
49874
50180
  let source;
49875
50181
  try {
49876
50182
  source = readFileSync45(abs, "utf-8");
@@ -49913,7 +50219,7 @@ var init_migrate = __esm({
49913
50219
  });
49914
50220
 
49915
50221
  // src/index.ts
49916
- import { readFileSync as readFileSync46, writeFileSync as writeFileSync23, mkdirSync as mkdirSync20, existsSync as existsSync46 } from "fs";
50222
+ import { readFileSync as readFileSync46, writeFileSync as writeFileSync23, mkdirSync as mkdirSync20, existsSync as existsSync47 } from "fs";
49917
50223
  import { resolve as resolve41, join as join32 } from "path";
49918
50224
  import { fileURLToPath as fileURLToPath9 } from "url";
49919
50225
  import { createRequire as createRequire8 } from "module";
@@ -50494,7 +50800,7 @@ function setRuntimeModule2(mod) {
50494
50800
  }
50495
50801
 
50496
50802
  // ../adapter/dist/index.js
50497
- import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as readFileSync24 } from "node:fs";
50803
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, existsSync as existsSync23, readFileSync as readFileSync24 } from "node:fs";
50498
50804
  import { resolve as resolve21, dirname as dirname17, relative as relative4, basename as basename3, join as join16 } from "node:path";
50499
50805
  import { fileURLToPath as fileURLToPath5 } from "node:url";
50500
50806
 
@@ -50801,12 +51107,33 @@ function precompileFile(source, sourcePath2, registry) {
50801
51107
  const reg = registry ?? new ModuleRegistry();
50802
51108
  if (sourcePath2 === void 0) return precompileFileInternal(source, sourcePath2, /* @__PURE__ */ new Set(), reg);
50803
51109
  const hit = precompileCache.get(sourcePath2);
50804
- if (hit !== void 0 && hit.source === source) return hit.plan;
51110
+ if (hit !== void 0 && hit.source === source) {
51111
+ for (const { absPath, entry } of hit.modules) reg.register(absPath, entry);
51112
+ return hit.plan;
51113
+ }
50805
51114
  const plan = precompileFileInternal(source, sourcePath2, /* @__PURE__ */ new Set(), reg);
50806
51115
  if (precompileCache.size >= 512) precompileCache.clear();
50807
- precompileCache.set(sourcePath2, { source, plan });
51116
+ precompileCache.set(sourcePath2, { source, plan, modules: collectPlanModules(plan, reg) });
50808
51117
  return plan;
50809
51118
  }
51119
+ function collectPlanModules(plan, registry) {
51120
+ const out = [];
51121
+ const seen = /* @__PURE__ */ new Set();
51122
+ const visitKey = (key) => {
51123
+ if (seen.has(key)) return;
51124
+ seen.add(key);
51125
+ const entry = registry.getModule(key);
51126
+ if (!entry || !entry.absPath) return;
51127
+ out.push({ absPath: entry.absPath, entry });
51128
+ for (const depKey of Object.values(entry.deps)) visitKey(depKey);
51129
+ };
51130
+ const visitPlan = (p) => {
51131
+ for (const mod of p.modules) visitKey(mod.key);
51132
+ for (const sub of p.subFiles) visitPlan(sub.plan);
51133
+ };
51134
+ visitPlan(plan);
51135
+ return out;
51136
+ }
50810
51137
  var precompileCache = /* @__PURE__ */ new Map();
50811
51138
  function precompileFileInternal(source, sourcePath2, seenImportFiles, registry) {
50812
51139
  if (sourcePath2) {
@@ -52192,123 +52519,8 @@ init_module_imports();
52192
52519
 
52193
52520
  // ../adapter/src/server-only-plugin.ts
52194
52521
  init_parser();
52522
+ init_server_only();
52195
52523
  import { readFileSync as readFileSync12 } from "node:fs";
52196
-
52197
- // ../adapter/src/server-only.ts
52198
- init_parser();
52199
- import { readFileSync as readFileSync11, readdirSync as readdirSync2, statSync as statSync3 } from "node:fs";
52200
- import { join as join7 } from "node:path";
52201
- var SERVER_ONLY_EXACT = /* @__PURE__ */ new Set([
52202
- "slintorm",
52203
- "@vesk/adapter"
52204
- ]);
52205
- var TCP_DRIVERS = /* @__PURE__ */ new Set([
52206
- "pg",
52207
- "mysql2",
52208
- "mongodb",
52209
- "node:sqlite",
52210
- "node:net",
52211
- "node:tls"
52212
- ]);
52213
- function classifySpecifier(spec) {
52214
- if (typeof spec !== "string" || spec.length === 0) return null;
52215
- if (TCP_DRIVERS.has(spec)) return "tcp-driver";
52216
- if (spec.startsWith("node:")) return "tcp-driver";
52217
- if (SERVER_ONLY_EXACT.has(spec)) return "server-only-package";
52218
- return null;
52219
- }
52220
- var REMEDY = {
52221
- "server-only-package": "import it from an API route (app/api/**/route.ts) or a server action instead of a component, or use the package's browser/edge entry point if it ships one.",
52222
- "tcp-driver": 'this driver opens a TCP socket, which no edge runtime provides. Use the driver\'s HTTP/HTTPS transport (for SlintORM: `driver: "postgrest"`), or build for a Node target.'
52223
- };
52224
- function scanServerOnlyImports(files) {
52225
- const out = [];
52226
- for (const file of files) {
52227
- let ast;
52228
- try {
52229
- ast = parse4(file.code);
52230
- } catch {
52231
- continue;
52232
- }
52233
- for (const node of ast.body ?? []) {
52234
- if (node?.type !== "ImportDeclaration" && node?.type !== "ExportNamedDeclaration" && node?.type !== "ExportAllDeclaration") continue;
52235
- const spec = node.source?.value;
52236
- if (typeof spec !== "string") continue;
52237
- const kind = classifySpecifier(spec);
52238
- if (!kind) continue;
52239
- out.push({
52240
- kind,
52241
- specifier: spec,
52242
- file: file.path,
52243
- line: lineOf(file.code, node.start),
52244
- remedy: REMEDY[kind]
52245
- });
52246
- }
52247
- }
52248
- return out;
52249
- }
52250
- function lineOf(code, offset2) {
52251
- if (typeof offset2 !== "number" || offset2 < 0 || offset2 > code.length) return null;
52252
- let line = 1;
52253
- for (let i = 0; i < offset2; i++) {
52254
- if (code.charCodeAt(i) === 10) line++;
52255
- }
52256
- return line;
52257
- }
52258
- function edgeDriverBuildError(violations) {
52259
- const detail = violations.map((v) => ` ${v.file}${v.line ? `:${v.line}` : ""} \u2014 import "${v.specifier}"
52260
- ${v.remedy}`).join("\n");
52261
- return new Error(
52262
- `[vesk] edge-targeted build cannot include a TCP-only driver (${violations.length} found).
52263
- ${detail}
52264
-
52265
- This was a build error rather than a runtime one because an edge runtime has no socket: the deployed function would fail on its first query.`
52266
- );
52267
- }
52268
- var SOCKETLESS_PLATFORMS = /* @__PURE__ */ new Set(["edge", "cloudflare", "deno", "coxmos"]);
52269
- function isSocketlessTarget(platform, target) {
52270
- if (target === "edge") return true;
52271
- return typeof platform === "string" && SOCKETLESS_PLATFORMS.has(platform);
52272
- }
52273
- var SOURCE_EXTENSIONS = [".vsk", ".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
52274
- var SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".vesk", ".git", "dist", ".next", ".output", "coverage"]);
52275
- function collectAppSources(dir, out = []) {
52276
- let entries;
52277
- try {
52278
- entries = readdirSync2(dir);
52279
- } catch {
52280
- return out;
52281
- }
52282
- for (const entry of entries) {
52283
- if (SKIPPED_DIRS.has(entry) || entry.startsWith(".")) continue;
52284
- const full = join7(dir, entry);
52285
- let st;
52286
- try {
52287
- st = statSync3(full);
52288
- } catch {
52289
- continue;
52290
- }
52291
- if (st.isDirectory()) collectAppSources(full, out);
52292
- else if (st.isFile()) {
52293
- const dot = entry.lastIndexOf(".");
52294
- if (dot === -1) continue;
52295
- if (SOURCE_EXTENSIONS.includes(entry.slice(dot).toLowerCase())) out.push(full);
52296
- }
52297
- }
52298
- return out;
52299
- }
52300
- function tcpDriverViolations(appDir) {
52301
- const files = [];
52302
- for (const path of collectAppSources(appDir)) {
52303
- try {
52304
- files.push({ path, code: readFileSync11(path, "utf-8") });
52305
- } catch {
52306
- }
52307
- }
52308
- return scanServerOnlyImports(files).filter((v) => v.kind === "tcp-driver");
52309
- }
52310
-
52311
- // ../adapter/src/server-only-plugin.ts
52312
52524
  var STUB_NAMESPACE = "vesk-server-only";
52313
52525
  var stubCounter = 0;
52314
52526
  function importedNamesFor(code, specifier) {
@@ -53471,17 +53683,23 @@ A module-scope statement runs the moment the browser evaluates the chunk, so a s
53471
53683
  loader: { ".js": "tsx" },
53472
53684
  legalComments: "none",
53473
53685
  ...appTsconfig ? { tsconfig: appTsconfig } : {},
53474
- // Stub optional CJS deps (qrcode-generator via vesk-qr, canvas,
53475
- // @zxing/*) so esbuild never bundles their CJS source into the client
53476
- // bundle — that would emit a `__require` shim that throws in the
53477
- // browser. vesk-qr now lazy-loads them via dynamic import; stubbing
53478
- // keeps the bundle valid ESM without shipping dead code.
53686
+ // Stub only the OPTIONAL CJS deps (canvas for raster export, @zxing/*
53687
+ // for scan validation). They degrade gracefully and their absence must
53688
+ // not break the bundle.
53689
+ //
53690
+ // `qrcode-generator` must NOT be stubbed: it is the pure-JS encoder
53691
+ // every client-side QR (vesk-qr's dynamic `import("qrcode-generator")`)
53692
+ // runs on. Stubbing it to `export {}` makes `getQrcode()` resolve to an
53693
+ // empty object, so `CofoundrMatrix.generate()` throws
53694
+ // "QREncodingError: generator is not a function" during hydration and
53695
+ // the page falls back to the client error boundary. esbuild bundles it
53696
+ // as CJS fine; only genuinely Node-only/optional deps belong here.
53479
53697
  plugins: [
53480
53698
  {
53481
53699
  name: "stub-browser-packages",
53482
53700
  setup(b) {
53483
53701
  b.onResolve(
53484
- { filter: /^(qrcode-generator|canvas|@zxing\/(browser|node))(\/|$)/ },
53702
+ { filter: /^(canvas|@zxing\/(browser|node))(\/|$)/ },
53485
53703
  (args2) => ({ path: args2.path, namespace: "browser-stub" })
53486
53704
  );
53487
53705
  b.onLoad({ filter: /.*/, namespace: "browser-stub" }, () => ({
@@ -53832,6 +54050,9 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
53832
54050
  };
53833
54051
  }
53834
54052
 
54053
+ // ../adapter/dist/index.js
54054
+ init_server_only();
54055
+
53835
54056
  // ../adapter/src/static.ts
53836
54057
  init_paths();
53837
54058
  import { mkdirSync as mkdirSync4, copyFileSync, readdirSync as readdirSync3, statSync as statSync6, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync15 } from "node:fs";
@@ -55003,9 +55224,9 @@ function PACKAGES_DIR_SELF() {
55003
55224
  var __dirname6 = dirname17(fileURLToPath5(import.meta.url));
55004
55225
  async function resolveCompilerApi(name) {
55005
55226
  const monorepoSrc = resolve21(__dirname6, "..", "..", "compiler", "src");
55006
- if (existsSync22(monorepoSrc)) {
55227
+ if (existsSync23(monorepoSrc)) {
55007
55228
  const tsFile = resolve21(monorepoSrc, name.replace(/\.js$/, ".ts"));
55008
- if (existsSync22(tsFile)) {
55229
+ if (existsSync23(tsFile)) {
55009
55230
  return import(tsFile);
55010
55231
  }
55011
55232
  return import(resolve21(monorepoSrc, name));
@@ -55188,7 +55409,7 @@ async function build2(appDir, options) {
55188
55409
  console.error(`vesk build: ${componentMap.size} external components found in ${componentsDir}`);
55189
55410
  }
55190
55411
  const apiDir = resolve21(appDir, "api");
55191
- const apiTree = existsSync22(apiDir) ? scanApiRoutes2(apiDir) : [];
55412
+ const apiTree = existsSync23(apiDir) ? scanApiRoutes2(apiDir) : [];
55192
55413
  console.error(`vesk build: ${routeTree.length} root routes, ${apiTree.length} API routes`);
55193
55414
  markPhase("scan routes");
55194
55415
  console.error("vesk build: bundling client runtime...");
@@ -55243,7 +55464,7 @@ async function build2(appDir, options) {
55243
55464
  const { funcPath, funcCode, name } = generateSsrFunction(node, appDir, outDir, componentMap, { ancestorLayouts: ssrAncestorLayouts, middlewareCode: mwCode, headExtra: pluginHeadExtra, clientScriptUrl: clientUrl, clientScriptIntegrity: clientIntegrity }, registry);
55244
55465
  writeFileSync12(funcPath, funcCode, "utf-8");
55245
55466
  const pagePath = resolve21(appDir, node.sourceDir, "page.vsk");
55246
- if (existsSync22(pagePath)) {
55467
+ if (existsSync23(pagePath)) {
55247
55468
  const src2 = readFileSync24(pagePath, "utf-8");
55248
55469
  const actionIds = collectActionIds(src2);
55249
55470
  if (node.layout) {
@@ -55330,13 +55551,13 @@ async function build2(appDir, options) {
55330
55551
  const publicDirResolved = resolve21(outDir, "static", "public");
55331
55552
  const siteUrl = options?.siteUrl || "http://localhost:3000";
55332
55553
  const sitemapOverride = resolve21(publicDirResolved, "sitemap.xml");
55333
- if (!existsSync22(sitemapOverride)) {
55554
+ if (!existsSync23(sitemapOverride)) {
55334
55555
  const sitemap = generateSitemap2(routeTree, ssrRoutes, prerenderedRoutes, { siteUrl });
55335
55556
  writeFileSync12(sitemapOverride, sitemap, "utf-8");
55336
55557
  console.error(`vesk build: seo \u2192 static/public/sitemap.xml (${sitemap.length} bytes)`);
55337
55558
  }
55338
55559
  const robotsOverride = resolve21(publicDirResolved, "robots.txt");
55339
- if (!existsSync22(robotsOverride)) {
55560
+ if (!existsSync23(robotsOverride)) {
55340
55561
  const robots = generateRobotsTxt2(siteUrl);
55341
55562
  writeFileSync12(robotsOverride, robots, "utf-8");
55342
55563
  console.error(`vesk build: seo \u2192 static/public/robots.txt (${robots.length} bytes)`);
@@ -55400,7 +55621,7 @@ vesk build: done (${outDir})`);
55400
55621
  init_seo_audit();
55401
55622
 
55402
55623
  // src/dev-server.ts
55403
- import { readFileSync as readFileSync42, watch, statSync as statSync22, existsSync as existsSync43, mkdirSync as mkdirSync19, readdirSync as readdirSync14, writeFileSync as writeFileSync21, renameSync as renameSync2 } from "node:fs";
55624
+ import { readFileSync as readFileSync42, watch, statSync as statSync22, existsSync as existsSync44, mkdirSync as mkdirSync19, readdirSync as readdirSync14, writeFileSync as writeFileSync21, renameSync as renameSync2 } from "node:fs";
55404
55625
  import { createHash as createHash3 } from "node:crypto";
55405
55626
  import { resolve as resolve39, extname as extname7, join as join28, dirname as dirname27, relative as relative9 } from "node:path";
55406
55627
  import { createServer as createServer2 } from "node:http";
@@ -56319,6 +56540,7 @@ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__
56319
56540
  ctx2.push(` const __slot = createLayoutSlot(${ctx2.walker}, ${parentVar});`);
56320
56541
  ctx2.push(` const __child = props.children(__slot.walker);`);
56321
56542
  ctx2.push(` if (__child && typeof __child.then === 'function') __pendingChild = __slot.track(__child);`);
56543
+ ctx2.push(` else if (__child && __child.nodeType === 11) ${parentVar}.appendChild(__child);`);
56322
56544
  ctx2.push(` } else {`);
56323
56545
  ctx2.push(` ${parentVar}.appendChild(props.children);`);
56324
56546
  ctx2.push(` }`);
@@ -56747,6 +56969,45 @@ function emitFragment2(ctx2, nodes, tracked2, effectsVar) {
56747
56969
  ctx2.push(`return $f; })();`);
56748
56970
  return frag;
56749
56971
  }
56972
+ function containsSlot2(nodes) {
56973
+ for (const node of nodes) {
56974
+ if (node instanceof SlotNode)
56975
+ return true;
56976
+ if (node instanceof StaticNode) {
56977
+ if (containsSlot2(node.children))
56978
+ return true;
56979
+ } else if (node instanceof ComponentCall) {
56980
+ if (containsSlot2(node.children))
56981
+ return true;
56982
+ } else if (node instanceof OpaqueDynamicRegion) {
56983
+ if (containsSlot2(node.consequentNodes) || containsSlot2(node.alternateNodes))
56984
+ return true;
56985
+ } else if (node instanceof MapRegion) {
56986
+ if (containsSlot2(node.bodyTemplate) || containsSlot2(node.alternateNodes))
56987
+ return true;
56988
+ } else if (node instanceof WhileLoop) {
56989
+ if (containsSlot2(node.bodyTemplate))
56990
+ return true;
56991
+ } else if (node instanceof ForLoop) {
56992
+ if (containsSlot2(node.bodyTemplate))
56993
+ return true;
56994
+ } else if (node instanceof SwitchBlock) {
56995
+ for (const c of node.cases)
56996
+ if (containsSlot2(c.body))
56997
+ return true;
56998
+ } else if (node instanceof TryCatch) {
56999
+ if (containsSlot2(node.bodyTemplate) || containsSlot2(node.catchBody))
57000
+ return true;
57001
+ } else if (node instanceof ServerBlock || node instanceof ClientBlock || node instanceof HeadBlock) {
57002
+ if (containsSlot2(node.children))
57003
+ return true;
57004
+ } else if (node instanceof PropSlot) {
57005
+ if (containsSlot2(node.body))
57006
+ return true;
57007
+ }
57008
+ }
57009
+ return false;
57010
+ }
56750
57011
  function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
56751
57012
  const propsEntries = node.props.map((p) => {
56752
57013
  if (typeof p.value === "string")
@@ -56814,20 +57075,49 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
56814
57075
  const savedHydrate = ctx2.hydrate;
56815
57076
  if (wipeMount || ctx2.selfClaimNames.has(node.componentName))
56816
57077
  ctx2.hydrate = false;
56817
- ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
56818
- const savedEffects = ctx2.effects;
56819
- ctx2.effects = [];
56820
- for (const child of regChildren) {
56821
- const childVar = emitNode2(ctx2, child, tracked2, effectsVar, "$f");
56822
- if (childVar)
56823
- ctx2.push(`$f.appendChild(${childVar});`);
57078
+ const lazySlotChildren = ctx2.hydrate && !plainTarget && !ctx2.selfClaimNames.has(node.componentName) && containsSlot2(regChildren);
57079
+ if (lazySlotChildren) {
57080
+ const fnVar = ctx2.n();
57081
+ const savedLines = ctx2.lines;
57082
+ const savedEffects = ctx2.effects;
57083
+ const savedWalker = ctx2.walker;
57084
+ ctx2.lines = [];
57085
+ ctx2.effects = [];
57086
+ ctx2.walker = "__childWalker";
57087
+ ctx2.push(`const $f = document.createDocumentFragment();`);
57088
+ for (const child of regChildren) {
57089
+ const childVar = emitNode2(ctx2, child, tracked2, effectsVar, "$f");
57090
+ if (childVar)
57091
+ ctx2.push(`$f.appendChild(${childVar});`);
57092
+ }
57093
+ for (const eff of ctx2.effects)
57094
+ ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr2(eff)});` : eff);
57095
+ ctx2.push(`return $f;`);
57096
+ const body = ctx2.lines.join("\n");
57097
+ ctx2.lines = savedLines;
57098
+ ctx2.effects = savedEffects;
57099
+ ctx2.walker = savedWalker;
57100
+ const asyncKw = ctx2.isAsyncScope ? "async " : "";
57101
+ ctx2.push(`const ${fnVar} = ${asyncKw}(__childWalker) => {`);
57102
+ ctx2.push(indent3(body));
57103
+ ctx2.push(`};`);
57104
+ propsEntries.push(`children: ${fnVar}`);
57105
+ } else {
57106
+ ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
57107
+ const savedEffects = ctx2.effects;
57108
+ ctx2.effects = [];
57109
+ for (const child of regChildren) {
57110
+ const childVar = emitNode2(ctx2, child, tracked2, effectsVar, "$f");
57111
+ if (childVar)
57112
+ ctx2.push(`$f.appendChild(${childVar});`);
57113
+ }
57114
+ for (const eff of ctx2.effects)
57115
+ ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr2(eff)});` : eff);
57116
+ ctx2.effects = savedEffects;
57117
+ ctx2.push(`return $f; })();`);
57118
+ propsEntries.push(`children: ${frag}`);
56824
57119
  }
56825
- for (const eff of ctx2.effects)
56826
- ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr2(eff)});` : eff);
56827
- ctx2.effects = savedEffects;
56828
57120
  ctx2.hydrate = savedHydrate;
56829
- ctx2.push(`return $f; })();`);
56830
- propsEntries.push(`children: ${frag}`);
56831
57121
  }
56832
57122
  if (ctx2.markerless && promptExpr) {
56833
57123
  ctx2.push(`${walkerArg}.injectSkipK(${promptExpr});`);
@@ -56989,7 +57279,7 @@ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar, skipK = 0, r
56989
57279
  ${effArr}.length = 0;
56990
57280
  __cleanup(${anchor}, ${endAnchor});
56991
57281
  try { ${asyncKw}${tryRenderComp}(); } catch(${catchParam}) { ${hasCatch ? `${asyncKw}${catchRenderComp}(${catchParam});` : "throw ${catchParam};"} }
56992
- });
57282
+ }, true);
56993
57283
  }`);
56994
57284
  return null;
56995
57285
  }
@@ -57083,7 +57373,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
57083
57373
  ${effInner}
57084
57374
  __iv = __new;
57085
57375
  }
57086
- });`;
57376
+ }, true);`;
57087
57377
  if (effTarget) {
57088
57378
  ctx2.push(`${effTarget}.push((() => {
57089
57379
  let __iv = ${branchInit};
@@ -57183,7 +57473,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
57183
57473
  ${renderBranch}
57184
57474
  __iv = __nv;
57185
57475
  }
57186
- });`;
57476
+ }, true);`;
57187
57477
  if (!isReactiveExpression2(node.condition, tracked2))
57188
57478
  return null;
57189
57479
  if (effTarget) {
@@ -57284,7 +57574,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget
57284
57574
  __busy = false;
57285
57575
  __iv = (${condExpr});
57286
57576
  }
57287
- });
57577
+ }, true);
57288
57578
  }`);
57289
57579
  return null;
57290
57580
  }
@@ -57384,7 +57674,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
57384
57674
  __busy = false;
57385
57675
  __iv = (${srcExpr});
57386
57676
  }
57387
- });
57677
+ }, true);
57388
57678
  }`);
57389
57679
  } else {
57390
57680
  const condReactive = isReactiveExpression2(node.condition, tracked2);
@@ -57449,7 +57739,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
57449
57739
  __cleanup(${anchor}, ${endAnchor});
57450
57740
  ${ctx2.isAsyncScope ? "await " : ""}${renderLoop}();
57451
57741
  __busy = false;
57452
- });
57742
+ }, true);
57453
57743
  }`);
57454
57744
  }
57455
57745
  }
@@ -57521,7 +57811,7 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudg
57521
57811
  __busy = false;
57522
57812
  __iv = (${discExpr});
57523
57813
  }
57524
- });
57814
+ }, true);
57525
57815
  }`);
57526
57816
  return null;
57527
57817
  }
@@ -57690,7 +57980,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
57690
57980
  ${effectsVar}.length = 0;
57691
57981
  __cleanup(${anchor}, ${endAnchor});
57692
57982
  if (__new) { ${initList}(); } else { ${aw}${emptyRenderName}(); }
57693
- })`);
57983
+ }, true)`);
57694
57984
  } else {
57695
57985
  ctx2.push(`${initList}();`);
57696
57986
  if (!reactiveSource)
@@ -57699,7 +57989,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
57699
57989
  const __nv = ${arrExpr};
57700
57990
  if (__first) { __first = false; __nv; ${breakReset}${reconciler}(${arrExpr}); return; }
57701
57991
  ${breakVar ? `if (${breakVar}) ${breakVar} = false;` : ""}${reconciler}(${arrExpr});
57702
- })`);
57992
+ }, true)`);
57703
57993
  }
57704
57994
  } else {
57705
57995
  const renderAllItems = (ind, collect) => {
@@ -57755,7 +58045,7 @@ ${renderAllItems(" ", null)}
57755
58045
  if (__new) {
57756
58046
  ${renderAllItems(" ", null)}
57757
58047
  } else { ${aw}${emptyRenderName}(${collectVar ? collectVar : ""}); }
57758
- })`);
58048
+ }, true)`);
57759
58049
  } else {
57760
58050
  const collectVar = hyd ? ctx2.n() : null;
57761
58051
  if (collectVar)
@@ -57772,7 +58062,7 @@ ${renderAllItems(" ", null)}
57772
58062
  ${effectsVar}.length = 0;
57773
58063
  __cleanup(${anchor}, ${endAnchor});
57774
58064
  ${renderAllItems(" ", null)}
57775
- })`);
58065
+ }, true)`);
57776
58066
  }
57777
58067
  }
57778
58068
  return null;
@@ -58325,7 +58615,7 @@ init_parser();
58325
58615
  init_tokens();
58326
58616
  init_scan();
58327
58617
  init_strip_ts();
58328
- import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync23, readFileSync as readFileSync25 } from "fs";
58618
+ import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync24, readFileSync as readFileSync25 } from "fs";
58329
58619
  import { join as join17, relative as relative5, basename as basename4 } from "path";
58330
58620
  function collapseSlashes2(p) {
58331
58621
  let out = "";
@@ -58344,7 +58634,7 @@ function collapseSlashes2(p) {
58344
58634
  }
58345
58635
  function isStandaloneLayoutFile(layoutPath) {
58346
58636
  try {
58347
- if (!existsSync23(layoutPath))
58637
+ if (!existsSync24(layoutPath))
58348
58638
  return false;
58349
58639
  const src2 = readFileSync25(layoutPath, "utf-8");
58350
58640
  if (!src2.includes("standalone"))
@@ -58409,7 +58699,7 @@ function isStandaloneLayoutFile(layoutPath) {
58409
58699
  }
58410
58700
  }
58411
58701
  function scanRoutes(appDir, options = {}) {
58412
- if (!existsSync23(appDir)) {
58702
+ if (!existsSync24(appDir)) {
58413
58703
  return [];
58414
58704
  }
58415
58705
  return scanDirectory(appDir, appDir, "/", options);
@@ -58419,7 +58709,7 @@ function capitalize(s) {
58419
58709
  }
58420
58710
  function scanComponents(componentsDir) {
58421
58711
  const map = /* @__PURE__ */ new Map();
58422
- if (!existsSync23(componentsDir))
58712
+ if (!existsSync24(componentsDir))
58423
58713
  return map;
58424
58714
  function walk9(dir, prefix) {
58425
58715
  let entries;
@@ -58735,7 +59025,7 @@ function matchUrl(tree, pathname) {
58735
59025
  }
58736
59026
 
58737
59027
  // ../compiler/dist/api-routes.js
58738
- import { readdirSync as readdirSync9, statSync as statSync14, existsSync as existsSync24 } from "fs";
59028
+ import { readdirSync as readdirSync9, statSync as statSync14, existsSync as existsSync25 } from "fs";
58739
59029
  import { join as join18 } from "path";
58740
59030
  init_server_utils();
58741
59031
  function basename5(p) {
@@ -58743,7 +59033,7 @@ function basename5(p) {
58743
59033
  return idx === -1 ? p : p.slice(idx + 1);
58744
59034
  }
58745
59035
  function scanApiRoutes(apiDir) {
58746
- if (!existsSync24(apiDir))
59036
+ if (!existsSync25(apiDir))
58747
59037
  return [];
58748
59038
  return scanApiDir(apiDir, apiDir, "/");
58749
59039
  }
@@ -59138,7 +59428,7 @@ async function executeRewrite(url, originalRequest) {
59138
59428
  }
59139
59429
 
59140
59430
  // ../compiler/dist/middleware.js
59141
- import { existsSync as existsSync25 } from "fs";
59431
+ import { existsSync as existsSync26 } from "fs";
59142
59432
  import { resolve as resolve22 } from "path";
59143
59433
 
59144
59434
  // ../compiler/src/api-routes.ts
@@ -59199,7 +59489,7 @@ function collectMiddlewareChain(routeTree, url, appDir) {
59199
59489
  function collectForNode(node) {
59200
59490
  if (node.hasMiddleware) {
59201
59491
  const mwPath = resolve22(appDir, node.sourceDir, "middleware.ts");
59202
- if (existsSync25(mwPath)) {
59492
+ if (existsSync26(mwPath)) {
59203
59493
  chain.push({ sourcePath: mwPath, node });
59204
59494
  }
59205
59495
  }
@@ -59370,13 +59660,13 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
59370
59660
  }
59371
59661
 
59372
59662
  // ../compiler/dist/events.js
59373
- import { existsSync as existsSync26 } from "fs";
59663
+ import { existsSync as existsSync27 } from "fs";
59374
59664
  import { join as join19 } from "path";
59375
59665
  var EVENTS_FILE_NAMES2 = ["_events.ts", "_events.js"];
59376
59666
  function collectEventsFile2(appDir) {
59377
59667
  for (const name of EVENTS_FILE_NAMES2) {
59378
59668
  const candidate = join19(appDir, name);
59379
- if (existsSync26(candidate))
59669
+ if (existsSync27(candidate))
59380
59670
  return candidate;
59381
59671
  }
59382
59672
  return null;
@@ -59406,7 +59696,7 @@ async function runEventHandlers(handlers, name, ctx2) {
59406
59696
  }
59407
59697
 
59408
59698
  // ../compiler/dist/md-inline.js
59409
- import { readFileSync as readFileSync26, existsSync as existsSync27 } from "node:fs";
59699
+ import { readFileSync as readFileSync26, existsSync as existsSync28 } from "node:fs";
59410
59700
  import { dirname as dirname18, join as join20, resolve as resolve23 } from "node:path";
59411
59701
  var MD_EXT_MARKER2 = ".md";
59412
59702
  function looksLikeMarkdownPath2(value) {
@@ -59480,15 +59770,15 @@ function resolveMdPath2(specifier, importerDir, roots) {
59480
59770
  if (!importerDir)
59481
59771
  return null;
59482
59772
  const abs = resolve23(importerDir, spec);
59483
- return existsSync27(abs) ? abs : null;
59773
+ return existsSync28(abs) ? abs : null;
59484
59774
  }
59485
59775
  if (spec.startsWith("/")) {
59486
59776
  for (const root3 of roots) {
59487
59777
  const pub = join20(root3, "public", spec);
59488
- if (existsSync27(pub))
59778
+ if (existsSync28(pub))
59489
59779
  return pub;
59490
59780
  const direct = join20(root3, spec);
59491
- if (existsSync27(direct))
59781
+ if (existsSync28(direct))
59492
59782
  return direct;
59493
59783
  }
59494
59784
  }
@@ -59501,7 +59791,7 @@ function guessProjectRoots2(dir) {
59501
59791
  let cur = dir;
59502
59792
  for (let i = 0; i < 6; i++) {
59503
59793
  roots.push(cur);
59504
- if (existsSync27(join20(cur, "package.json")))
59794
+ if (existsSync28(join20(cur, "package.json")))
59505
59795
  break;
59506
59796
  const parent = dirname18(cur);
59507
59797
  if (parent === cur)
@@ -59512,7 +59802,7 @@ function guessProjectRoots2(dir) {
59512
59802
  }
59513
59803
 
59514
59804
  // ../adapter/dist/client-bundle.js
59515
- import { readFileSync as readFileSync27, existsSync as existsSync28, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync15, rmSync as rmSync4, mkdtempSync as mkdtempSync2, mkdirSync as mkdirSync12 } from "node:fs";
59805
+ import { readFileSync as readFileSync27, existsSync as existsSync29, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync15, rmSync as rmSync4, mkdtempSync as mkdtempSync2, mkdirSync as mkdirSync12 } from "node:fs";
59516
59806
  import { resolve as resolve24, join as join21, dirname as dirname19, relative as relative6, sep as sep3 } from "node:path";
59517
59807
  import { fileURLToPath as fileURLToPath6 } from "node:url";
59518
59808
  import { tmpdir as tmpdir3 } from "node:os";
@@ -59629,7 +59919,7 @@ function findRuntimeSrc3(appDir) {
59629
59919
  ];
59630
59920
  for (const base of candidates) {
59631
59921
  for (const dir of [base, join21(base, "dist")]) {
59632
- if (existsSync28(join21(dir, "index-client.js")))
59922
+ if (existsSync29(join21(dir, "index-client.js")))
59633
59923
  return dir;
59634
59924
  }
59635
59925
  }
@@ -59800,7 +60090,7 @@ function runtimeImportsOf2(filePath, seen = /* @__PURE__ */ new Set()) {
59800
60090
  ];
59801
60091
  for (const candidate of candidates) {
59802
60092
  try {
59803
- if (!existsSync28(candidate) || !statSync15(candidate).isFile())
60093
+ if (!existsSync29(candidate) || !statSync15(candidate).isFile())
59804
60094
  continue;
59805
60095
  } catch {
59806
60096
  continue;
@@ -60263,31 +60553,31 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
60263
60553
  const chunkCode = [];
60264
60554
  const chunkImports = new ChunkImports2();
60265
60555
  const pagePath = resolve24(appDir, node.sourceDir, "page.vsk");
60266
- if (node.page && existsSync28(pagePath)) {
60556
+ if (node.page && existsSync29(pagePath)) {
60267
60557
  compileFile2(pagePath, node.page, chunkCode, chunkImports);
60268
60558
  }
60269
60559
  const layoutPath = resolve24(appDir, node.sourceDir, "layout.vsk");
60270
- if (node.layout && existsSync28(layoutPath)) {
60560
+ if (node.layout && existsSync29(layoutPath)) {
60271
60561
  compileFile2(layoutPath, node.layout, chunkCode, chunkImports);
60272
60562
  }
60273
60563
  const errorPath = resolve24(appDir, node.sourceDir, "error.vsk");
60274
- if (node.error && existsSync28(errorPath)) {
60564
+ if (node.error && existsSync29(errorPath)) {
60275
60565
  compileFile2(errorPath, node.error, chunkCode, chunkImports);
60276
60566
  }
60277
60567
  const notFoundPath = resolve24(appDir, node.sourceDir, "not-found.vsk");
60278
- if (node.notFound && existsSync28(notFoundPath)) {
60568
+ if (node.notFound && existsSync29(notFoundPath)) {
60279
60569
  compileFile2(notFoundPath, node.notFound, chunkCode, chunkImports);
60280
60570
  }
60281
60571
  const offlinePath = resolve24(appDir, node.sourceDir, "offline.vsk");
60282
- if (node.offline && existsSync28(offlinePath)) {
60572
+ if (node.offline && existsSync29(offlinePath)) {
60283
60573
  compileFile2(offlinePath, node.offline, chunkCode, chunkImports);
60284
60574
  }
60285
60575
  const networkPath = resolve24(appDir, node.sourceDir, "network.vsk");
60286
- if (node.network && existsSync28(networkPath)) {
60576
+ if (node.network && existsSync29(networkPath)) {
60287
60577
  compileFile2(networkPath, node.network, chunkCode, chunkImports);
60288
60578
  }
60289
60579
  const loadingPath = resolve24(appDir, node.sourceDir, "loading.vsk");
60290
- if (node.loading && existsSync28(loadingPath)) {
60580
+ if (node.loading && existsSync29(loadingPath)) {
60291
60581
  compileFile2(loadingPath, node.loading, chunkCode, chunkImports);
60292
60582
  }
60293
60583
  if (chunkCode.length > 0) {
@@ -60359,7 +60649,7 @@ ${body}
60359
60649
  } catch {
60360
60650
  }
60361
60651
  }
60362
- if (file.endsWith(".vsk") || !existsSync28(file))
60652
+ if (file.endsWith(".vsk") || !existsSync29(file))
60363
60653
  continue;
60364
60654
  let needsRuntime = false;
60365
60655
  try {
@@ -60618,25 +60908,25 @@ A module-scope statement runs the moment the browser evaluates the chunk, so a s
60618
60908
  }, walkMono2 = function(nodes) {
60619
60909
  for (const node of nodes) {
60620
60910
  const pagePath = resolve24(appDir, node.sourceDir, "page.vsk");
60621
- if (node.page && existsSync28(pagePath))
60911
+ if (node.page && existsSync29(pagePath))
60622
60912
  compileFileMono2(pagePath, node.page);
60623
60913
  const layoutPath = resolve24(appDir, node.sourceDir, "layout.vsk");
60624
- if (node.layout && existsSync28(layoutPath))
60914
+ if (node.layout && existsSync29(layoutPath))
60625
60915
  compileFileMono2(layoutPath, node.layout);
60626
60916
  const errorPath = resolve24(appDir, node.sourceDir, "error.vsk");
60627
- if (node.error && existsSync28(errorPath))
60917
+ if (node.error && existsSync29(errorPath))
60628
60918
  compileFileMono2(errorPath, node.error);
60629
60919
  const notFoundPath = resolve24(appDir, node.sourceDir, "not-found.vsk");
60630
- if (node.notFound && existsSync28(notFoundPath))
60920
+ if (node.notFound && existsSync29(notFoundPath))
60631
60921
  compileFileMono2(notFoundPath, node.notFound);
60632
60922
  const offlinePath = resolve24(appDir, node.sourceDir, "offline.vsk");
60633
- if (node.offline && existsSync28(offlinePath))
60923
+ if (node.offline && existsSync29(offlinePath))
60634
60924
  compileFileMono2(offlinePath, node.offline);
60635
60925
  const networkPath = resolve24(appDir, node.sourceDir, "network.vsk");
60636
- if (node.network && existsSync28(networkPath))
60926
+ if (node.network && existsSync29(networkPath))
60637
60927
  compileFileMono2(networkPath, node.network);
60638
60928
  const loadingPath = resolve24(appDir, node.sourceDir, "loading.vsk");
60639
- if (node.loading && existsSync28(loadingPath))
60929
+ if (node.loading && existsSync29(loadingPath))
60640
60930
  compileFileMono2(loadingPath, node.loading);
60641
60931
  walkMono2(node.children || []);
60642
60932
  }
@@ -60680,16 +60970,22 @@ A module-scope statement runs the moment the browser evaluates the chunk, so a s
60680
60970
  loader: { ".js": "tsx" },
60681
60971
  legalComments: "none",
60682
60972
  ...appTsconfig ? { tsconfig: appTsconfig } : {},
60683
- // Stub optional CJS deps (qrcode-generator via vesk-qr, canvas,
60684
- // @zxing/*) so esbuild never bundles their CJS source into the client
60685
- // bundle — that would emit a `__require` shim that throws in the
60686
- // browser. vesk-qr now lazy-loads them via dynamic import; stubbing
60687
- // keeps the bundle valid ESM without shipping dead code.
60973
+ // Stub only the OPTIONAL CJS deps (canvas for raster export, @zxing/*
60974
+ // for scan validation). They degrade gracefully and their absence must
60975
+ // not break the bundle.
60976
+ //
60977
+ // `qrcode-generator` must NOT be stubbed: it is the pure-JS encoder
60978
+ // every client-side QR (vesk-qr's dynamic `import("qrcode-generator")`)
60979
+ // runs on. Stubbing it to `export {}` makes `getQrcode()` resolve to an
60980
+ // empty object, so `CofoundrMatrix.generate()` throws
60981
+ // "QREncodingError: generator is not a function" during hydration and
60982
+ // the page falls back to the client error boundary. esbuild bundles it
60983
+ // as CJS fine; only genuinely Node-only/optional deps belong here.
60688
60984
  plugins: [
60689
60985
  {
60690
60986
  name: "stub-browser-packages",
60691
60987
  setup(b) {
60692
- b.onResolve({ filter: /^(qrcode-generator|canvas|@zxing\/(browser|node))(\/|$)/ }, (args2) => ({ path: args2.path, namespace: "browser-stub" }));
60988
+ b.onResolve({ filter: /^(canvas|@zxing\/(browser|node))(\/|$)/ }, (args2) => ({ path: args2.path, namespace: "browser-stub" }));
60693
60989
  b.onLoad({ filter: /.*/, namespace: "browser-stub" }, () => ({
60694
60990
  contents: "export {}\n",
60695
60991
  loader: "js"
@@ -60740,7 +61036,7 @@ function buildRuntimeCode2(runtimeDir) {
60740
61036
  let code = "";
60741
61037
  for (const f of runtimeFiles) {
60742
61038
  const p = join21(runtimeDir, f);
60743
- if (existsSync28(p)) {
61039
+ if (existsSync29(p)) {
60744
61040
  let src2 = readFileSync27(p, "utf-8");
60745
61041
  src2 = stripTypes2(src2);
60746
61042
  src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
@@ -60977,7 +61273,7 @@ if (typeof document !== 'undefined') __router.start();
60977
61273
 
60978
61274
  // ../adapter/dist/paths.js
60979
61275
  import { resolve as resolve25, sep as sep4 } from "node:path";
60980
- import { existsSync as existsSync29, statSync as statSync16, readFileSync as readFileSync28 } from "node:fs";
61276
+ import { existsSync as existsSync30, statSync as statSync16, readFileSync as readFileSync28 } from "node:fs";
60981
61277
  function resolveWithin2(baseDir, relPath) {
60982
61278
  const base = resolve25(baseDir);
60983
61279
  const target = resolve25(baseDir, relPath);
@@ -61000,7 +61296,7 @@ function installMdReadHook2(publicDirs) {
61000
61296
  const lower2 = abs.toLowerCase();
61001
61297
  if (!lower2.endsWith(".md") && !lower2.endsWith(".markdown"))
61002
61298
  continue;
61003
- if (existsSync29(abs) && statSync16(abs).isFile())
61299
+ if (existsSync30(abs) && statSync16(abs).isFile())
61004
61300
  return readFileSync28(abs, "utf8");
61005
61301
  } catch {
61006
61302
  }
@@ -61068,12 +61364,12 @@ function urlAuthority3(url) {
61068
61364
  }
61069
61365
 
61070
61366
  // ../adapter/dist/dev-api.js
61071
- import { readFileSync as readFileSync31, statSync as statSync18, existsSync as existsSync32, readdirSync as readdirSync10 } from "node:fs";
61367
+ import { readFileSync as readFileSync31, statSync as statSync18, existsSync as existsSync33, readdirSync as readdirSync10 } from "node:fs";
61072
61368
  import { resolve as resolve28 } from "node:path";
61073
61369
 
61074
61370
  // ../adapter/dist/plugins.js
61075
61371
  init_paths();
61076
- import { readFileSync as readFileSync29, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync17 } from "node:fs";
61372
+ import { readFileSync as readFileSync29, writeFileSync as writeFileSync14, existsSync as existsSync31, mkdirSync as mkdirSync13, statSync as statSync17 } from "node:fs";
61077
61373
  import { resolve as resolve26, dirname as dirname20, join as join22, extname as extname6, basename as basename6 } from "node:path";
61078
61374
  import { createRequire as createRequire6 } from "node:module";
61079
61375
  import { spawn as spawn2 } from "node:child_process";
@@ -61093,7 +61389,7 @@ function stateFilePath2(veskDir) {
61093
61389
  }
61094
61390
  function readPluginState2(veskDir) {
61095
61391
  const file = stateFilePath2(veskDir);
61096
- if (!existsSync30(file))
61392
+ if (!existsSync31(file))
61097
61393
  return defaultState2();
61098
61394
  let raw2;
61099
61395
  try {
@@ -61116,7 +61412,7 @@ function readPluginState2(veskDir) {
61116
61412
  function writePluginState2(veskDir, state) {
61117
61413
  const file = stateFilePath2(veskDir);
61118
61414
  const dir = dirname20(file);
61119
- if (!existsSync30(dir))
61415
+ if (!existsSync31(dir))
61120
61416
  mkdirSync13(dir, { recursive: true });
61121
61417
  writeFileSync14(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
61122
61418
  }
@@ -61135,7 +61431,7 @@ function resolvePackage2(appDir, pkg) {
61135
61431
  while (cur && cur !== dirname20(cur) && !seen.has(cur)) {
61136
61432
  seen.add(cur);
61137
61433
  const candidate = join22(cur, "package.json");
61138
- if (existsSync30(candidate)) {
61434
+ if (existsSync31(candidate)) {
61139
61435
  pkgJsonPath = candidate;
61140
61436
  break;
61141
61437
  }
@@ -61147,7 +61443,7 @@ function resolvePackage2(appDir, pkg) {
61147
61443
  } catch {
61148
61444
  }
61149
61445
  }
61150
- if (pkgJsonPath && existsSync30(pkgJsonPath)) {
61446
+ if (pkgJsonPath && existsSync31(pkgJsonPath)) {
61151
61447
  pkgJson = readJsonFile2(pkgJsonPath);
61152
61448
  const main = pkgJson?.main || pkgJson?.module || "index.js";
61153
61449
  entryPath = resolve26(dirname20(pkgJsonPath), main);
@@ -61165,30 +61461,30 @@ function resolvePackage2(appDir, pkg) {
61165
61461
  if (localPath) {
61166
61462
  const localJson = join22(localPath, "package.json");
61167
61463
  let json = null;
61168
- if (existsSync30(localJson)) {
61464
+ if (existsSync31(localJson)) {
61169
61465
  json = readJsonFile2(localJson);
61170
61466
  }
61171
61467
  return { installed: true, path: localPath, dir: localPath, packageJson: json ?? pkgJson };
61172
61468
  }
61173
- const installed2 = !!pkgJsonPath && existsSync30(pkgJsonPath);
61469
+ const installed2 = !!pkgJsonPath && existsSync31(pkgJsonPath);
61174
61470
  return { installed: installed2, path: entryPath, dir: installed2 ? dirname20(pkgJsonPath) : null, packageJson: pkgJson };
61175
61471
  }
61176
61472
  function localDir2(base, pkg) {
61177
61473
  if (pkg.startsWith("@")) {
61178
61474
  const parts = pkg.split("/");
61179
61475
  const p2 = resolve26(base, parts[0], parts[1] ?? "");
61180
- if (existsSync30(p2))
61476
+ if (existsSync31(p2))
61181
61477
  return p2;
61182
61478
  return null;
61183
61479
  }
61184
61480
  const p = resolve26(base, pkg);
61185
- if (existsSync30(p))
61481
+ if (existsSync31(p))
61186
61482
  return p;
61187
61483
  return null;
61188
61484
  }
61189
61485
  function readJsonFile2(file) {
61190
61486
  try {
61191
- if (existsSync30(file))
61487
+ if (existsSync31(file))
61192
61488
  return JSON.parse(readFileSync29(file, "utf-8"));
61193
61489
  } catch {
61194
61490
  }
@@ -61472,12 +61768,12 @@ function findIconFile2(dir, meta) {
61472
61768
  const explicit = str2(meta?.icon);
61473
61769
  if (explicit) {
61474
61770
  const p = resolveWithin(dir, explicit);
61475
- if (p && existsSync30(p) && statSync17(p).isFile())
61771
+ if (p && existsSync31(p) && statSync17(p).isFile())
61476
61772
  return p;
61477
61773
  }
61478
61774
  for (const name of ["icon.png", "icon.ico"]) {
61479
61775
  const p = resolve26(dir, name);
61480
- if (existsSync30(p) && statSync17(p).isFile())
61776
+ if (existsSync31(p) && statSync17(p).isFile())
61481
61777
  return p;
61482
61778
  }
61483
61779
  return null;
@@ -61562,7 +61858,7 @@ function resolveDtsPath2(probe, pkgJson) {
61562
61858
  if (!rel)
61563
61859
  continue;
61564
61860
  const abs = resolveWithin(dir, rel);
61565
- if (abs && existsSync30(abs) && statSync17(abs).isFile())
61861
+ if (abs && existsSync31(abs) && statSync17(abs).isFile())
61566
61862
  return abs;
61567
61863
  }
61568
61864
  return null;
@@ -62049,16 +62345,16 @@ var __internals2 = {
62049
62345
  };
62050
62346
 
62051
62347
  // ../adapter/dist/dev-config.js
62052
- import { existsSync as existsSync31, readFileSync as readFileSync30, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
62348
+ import { existsSync as existsSync32, readFileSync as readFileSync30, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
62053
62349
  import { tmpdir as tmpdir4 } from "node:os";
62054
62350
  import { resolve as resolve27, dirname as dirname21, join as join23 } from "node:path";
62055
62351
  init_parser();
62056
62352
  function findConfigFile2(projectDir) {
62057
62353
  const ts9 = resolve27(projectDir, "vesk.config.ts");
62058
- if (existsSync31(ts9))
62354
+ if (existsSync32(ts9))
62059
62355
  return { path: ts9, isTs: true };
62060
62356
  const js = resolve27(projectDir, "vesk.config.js");
62061
- if (existsSync31(js))
62357
+ if (existsSync32(js))
62062
62358
  return { path: js, isTs: false };
62063
62359
  return { path: null, isTs: false };
62064
62360
  }
@@ -63190,7 +63486,7 @@ function createDevApiRouter2(opts) {
63190
63486
  const resolved = resolveWithin2(projectDir, target);
63191
63487
  if (!resolved)
63192
63488
  return jsonStatus(403, { error: "path escapes project root" });
63193
- if (!existsSync32(resolved))
63489
+ if (!existsSync33(resolved))
63194
63490
  return jsonStatus(404, { error: "not found" });
63195
63491
  if (statSync18(resolved).isDirectory()) {
63196
63492
  const entries = readdirSync10(resolved, { withFileTypes: true }).map((e) => e.name);
@@ -63390,7 +63686,7 @@ function produceDiagnostics(input) {
63390
63686
  }
63391
63687
 
63392
63688
  // ../agentic/dist/checkpoints.js
63393
- import { existsSync as existsSync33, mkdirSync as mkdirSync15, readFileSync as readFileSync32, writeFileSync as writeFileSync16, statSync as statSync19, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
63689
+ import { existsSync as existsSync34, mkdirSync as mkdirSync15, readFileSync as readFileSync32, writeFileSync as writeFileSync16, statSync as statSync19, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
63394
63690
  import { join as join24, resolve as resolve29, dirname as dirname22, sep as sep5 } from "node:path";
63395
63691
  import { randomUUID as nodeRandomUUID } from "node:crypto";
63396
63692
  function generateId() {
@@ -63540,7 +63836,7 @@ function ensureDir(dir) {
63540
63836
  }
63541
63837
  function readJson(filePath, fallback) {
63542
63838
  try {
63543
- if (!existsSync33(filePath))
63839
+ if (!existsSync34(filePath))
63544
63840
  return fallback;
63545
63841
  const raw2 = readFileSync32(filePath, "utf-8");
63546
63842
  if (raw2.trim() === "")
@@ -63641,7 +63937,7 @@ function rollback(projectDir, id) {
63641
63937
  const abs = resolve29(projectRoot, f.path);
63642
63938
  if (f.before === null) {
63643
63939
  try {
63644
- if (existsSync33(abs)) {
63940
+ if (existsSync34(abs)) {
63645
63941
  const s = statSync19(abs);
63646
63942
  if (s.isDirectory())
63647
63943
  rmSync6(abs, { recursive: true, force: true });
@@ -63662,7 +63958,7 @@ function rollback(projectDir, id) {
63662
63958
  }
63663
63959
 
63664
63960
  // ../agentic/dist/config.js
63665
- import { readFileSync as readFileSync33, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync16, chmodSync } from "node:fs";
63961
+ import { readFileSync as readFileSync33, writeFileSync as writeFileSync17, existsSync as existsSync35, mkdirSync as mkdirSync16, chmodSync } from "node:fs";
63666
63962
  import { resolve as resolve30, dirname as dirname23 } from "node:path";
63667
63963
  var DEFAULT_CONFIG = {
63668
63964
  provider: "openai",
@@ -63709,7 +64005,7 @@ function dotenvPath(projectDir) {
63709
64005
  function readDotenvValue(projectDir, key, def = null) {
63710
64006
  try {
63711
64007
  const p = dotenvPath(projectDir);
63712
- if (!existsSync34(p))
64008
+ if (!existsSync35(p))
63713
64009
  return def;
63714
64010
  const content = readFileSync33(p, "utf-8");
63715
64011
  for (const rawLine of content.split("\n")) {
@@ -63738,7 +64034,7 @@ function writeDotenvValue(projectDir, key, value) {
63738
64034
  try {
63739
64035
  let out = "";
63740
64036
  let replaced = false;
63741
- if (existsSync34(p)) {
64037
+ if (existsSync35(p)) {
63742
64038
  const lines = readFileSync33(p, "utf-8").split("\n");
63743
64039
  for (const rawLine of lines) {
63744
64040
  const trimmed = rawLine.trim();
@@ -63768,7 +64064,7 @@ function loadAgenticConfig(projectDir) {
63768
64064
  const p = configPath(projectDir);
63769
64065
  let cfg = { ...DEFAULT_CONFIG };
63770
64066
  try {
63771
- if (existsSync34(p))
64067
+ if (existsSync35(p))
63772
64068
  cfg = { ...cfg, ...JSON.parse(readFileSync33(p, "utf-8")) };
63773
64069
  } catch {
63774
64070
  }
@@ -63811,7 +64107,7 @@ function getProviderSpecificKey(projectDir, provider) {
63811
64107
  return dotenvFile.trim();
63812
64108
  try {
63813
64109
  const pp2 = providerKeyPath(projectDir, prov);
63814
- if (existsSync34(pp2)) {
64110
+ if (existsSync35(pp2)) {
63815
64111
  const v = readFileSync33(pp2, "utf-8").trim();
63816
64112
  if (v)
63817
64113
  return v;
@@ -63859,7 +64155,7 @@ function getApiKey(projectDir, provider) {
63859
64155
  }
63860
64156
  try {
63861
64157
  const pp2 = providerKeyPath(projectDir, prov);
63862
- if (existsSync34(pp2)) {
64158
+ if (existsSync35(pp2)) {
63863
64159
  const v = readFileSync33(pp2, "utf-8").trim();
63864
64160
  if (v)
63865
64161
  return v;
@@ -63883,7 +64179,7 @@ function getApiKey(projectDir, provider) {
63883
64179
  }
63884
64180
 
63885
64181
  // ../agentic/dist/dev-api.js
63886
- import { existsSync as existsSync35, readFileSync as readFileSync34 } from "node:fs";
64182
+ import { existsSync as existsSync36, readFileSync as readFileSync34 } from "node:fs";
63887
64183
  import { resolve as resolve31 } from "node:path";
63888
64184
 
63889
64185
  // ../agentic/dist/providers/openai.js
@@ -64255,7 +64551,7 @@ function getPerProviderKeyRaw(projectDir, provider) {
64255
64551
  }
64256
64552
  try {
64257
64553
  const p = resolve31(projectDir, ".vesk", "agentic", "keys", `${sanitizeProviderName(prov)}.key`);
64258
- if (existsSync35(p)) {
64554
+ if (existsSync36(p)) {
64259
64555
  const v = readFileSync34(p, "utf-8").trim();
64260
64556
  if (v)
64261
64557
  return v;
@@ -65117,7 +65413,7 @@ var Agent = class {
65117
65413
  };
65118
65414
 
65119
65415
  // ../agentic/dist/tools/vesk.js
65120
- import { existsSync as existsSync36, readFileSync as readFileSync35, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync11, statSync as statSync20 } from "node:fs";
65416
+ import { existsSync as existsSync37, readFileSync as readFileSync35, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync11, statSync as statSync20 } from "node:fs";
65121
65417
  import { resolve as resolve32, join as join25, dirname as dirname24, sep as sep6 } from "node:path";
65122
65418
  function resolveWithin3(baseDir, relPath) {
65123
65419
  const base = resolve32(baseDir);
@@ -65133,7 +65429,7 @@ function stateFilePath3(veskDir) {
65133
65429
  }
65134
65430
  function readPluginState3(veskDir) {
65135
65431
  const file = stateFilePath3(veskDir);
65136
- if (!existsSync36(file))
65432
+ if (!existsSync37(file))
65137
65433
  return { version: 1, plugins: [] };
65138
65434
  try {
65139
65435
  const raw2 = JSON.parse(readFileSync35(file, "utf-8"));
@@ -65172,10 +65468,10 @@ function validatePackageSpec3(pkg) {
65172
65468
  }
65173
65469
  function findConfigFile3(projectDir) {
65174
65470
  const ts9 = resolve32(projectDir, "vesk.config.ts");
65175
- if (existsSync36(ts9))
65471
+ if (existsSync37(ts9))
65176
65472
  return { path: ts9, isTs: true };
65177
65473
  const js = resolve32(projectDir, "vesk.config.js");
65178
- if (existsSync36(js))
65474
+ if (existsSync37(js))
65179
65475
  return { path: js, isTs: false };
65180
65476
  return { path: null, isTs: false };
65181
65477
  }
@@ -65324,16 +65620,16 @@ function createVeskTools(deps) {
65324
65620
  },
65325
65621
  async execute(_args) {
65326
65622
  try {
65327
- const projExists = existsSync36(projectDir);
65623
+ const projExists = existsSync37(projectDir);
65328
65624
  const projEntries = projExists ? readdirSync11(projectDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
65329
- const appExists = existsSync36(appDir);
65625
+ const appExists = existsSync37(appDir);
65330
65626
  const appEntries = appExists ? readdirSync11(appDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
65331
- const veskExists = existsSync36(veskDir);
65627
+ const veskExists = existsSync37(veskDir);
65332
65628
  const veskEntries = veskExists ? readdirSync11(veskDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
65333
65629
  const cfgInfo = findConfigFile3(projectDir);
65334
65630
  let configSource = null;
65335
65631
  let configExists = false;
65336
- if (cfgInfo.path && existsSync36(cfgInfo.path)) {
65632
+ if (cfgInfo.path && existsSync37(cfgInfo.path)) {
65337
65633
  configExists = true;
65338
65634
  try {
65339
65635
  configSource = readFileSync35(cfgInfo.path, "utf-8").slice(0, 8e3);
@@ -65343,7 +65639,7 @@ function createVeskTools(deps) {
65343
65639
  }
65344
65640
  let packageJson = null;
65345
65641
  const pkgPath = resolve32(projectDir, "package.json");
65346
- if (existsSync36(pkgPath)) {
65642
+ if (existsSync37(pkgPath)) {
65347
65643
  try {
65348
65644
  packageJson = JSON.parse(readFileSync35(pkgPath, "utf-8"));
65349
65645
  } catch {
@@ -65425,7 +65721,7 @@ function createVeskTools(deps) {
65425
65721
  resolved = resolveWithin3(appDir, rel);
65426
65722
  if (!resolved)
65427
65723
  return jsonError("path escapes project root", { path: rel });
65428
- if (!existsSync36(resolved))
65724
+ if (!existsSync37(resolved))
65429
65725
  return jsonError("not found", { path: rel });
65430
65726
  const st = statSync20(resolved);
65431
65727
  if (st.isDirectory()) {
@@ -65466,7 +65762,7 @@ function createVeskTools(deps) {
65466
65762
  }
65467
65763
  }
65468
65764
  const info = findConfigFile3(projectDir);
65469
- if (!info.path || !existsSync36(info.path)) {
65765
+ if (!info.path || !existsSync37(info.path)) {
65470
65766
  return jsonOk({ ok: true, path: null, exists: false, source: "", config: {} });
65471
65767
  }
65472
65768
  const source = readFileSync35(info.path, "utf-8");
@@ -65848,7 +66144,7 @@ function createVeskTools(deps) {
65848
66144
  const contained = resolveWithin3(dir, `${checkpointId}.json`);
65849
66145
  if (!contained)
65850
66146
  return jsonError("path escapes project root");
65851
- if (!existsSync36(file))
66147
+ if (!existsSync37(file))
65852
66148
  return jsonError(`checkpoint not found: ${checkpointId}`, { checkpointId });
65853
66149
  const raw2 = readFileSync35(file, "utf-8");
65854
66150
  let data2;
@@ -65933,7 +66229,7 @@ function renderDefaultNotFoundPage2(opts = {}) {
65933
66229
  }
65934
66230
 
65935
66231
  // ../adapter/dist/ssr-function.js
65936
- import { readFileSync as readFileSync36, existsSync as existsSync37 } from "node:fs";
66232
+ import { readFileSync as readFileSync36, existsSync as existsSync38 } from "node:fs";
65937
66233
  import { resolve as resolve33, relative as relative7, join as join26 } from "node:path";
65938
66234
  init_default_pages();
65939
66235
  init_module_imports();
@@ -65942,25 +66238,25 @@ function resolveBoundaryFileForUrl2(pathname, appDir, file) {
65942
66238
  for (let depth = segments.length; depth >= 0; depth--) {
65943
66239
  const dir = join26(appDir, ...segments.slice(0, depth));
65944
66240
  const p = join26(dir, file);
65945
- if (existsSync37(p))
66241
+ if (existsSync38(p))
65946
66242
  return p;
65947
66243
  }
65948
66244
  return null;
65949
66245
  }
65950
66246
 
65951
66247
  // ../adapter/dist/css.js
65952
- import { readFileSync as readFileSync37, existsSync as existsSync38 } from "node:fs";
66248
+ import { readFileSync as readFileSync37, existsSync as existsSync39 } from "node:fs";
65953
66249
  import { resolve as resolve34 } from "node:path";
65954
66250
  var GLOBAL_CSS_URL2 = "/_vesk/static/global.css";
65955
66251
  function resolveUserCssPath2(appDir) {
65956
66252
  const appCssSrc = resolve34(appDir, "global.css");
65957
- if (existsSync38(appCssSrc))
66253
+ if (existsSync39(appCssSrc))
65958
66254
  return appCssSrc;
65959
66255
  const cssSrc = resolve34(appDir, "..", "src", "global.css");
65960
- if (existsSync38(cssSrc))
66256
+ if (existsSync39(cssSrc))
65961
66257
  return cssSrc;
65962
66258
  const altCssSrc = resolve34(appDir, "..", "src", "app.css");
65963
- if (existsSync38(altCssSrc))
66259
+ if (existsSync39(altCssSrc))
65964
66260
  return altCssSrc;
65965
66261
  return null;
65966
66262
  }
@@ -65976,7 +66272,7 @@ function resolveCssUrls2(opts) {
65976
66272
  // ../adapter/dist/hmr.js
65977
66273
  init_client_codegen();
65978
66274
  import { WebSocketServer } from "ws";
65979
- import { readFileSync as readFileSync38, existsSync as existsSync39, writeFileSync as writeFileSync19 } from "node:fs";
66275
+ import { readFileSync as readFileSync38, existsSync as existsSync40, writeFileSync as writeFileSync19 } from "node:fs";
65980
66276
  import { resolve as resolve35, dirname as dirname25 } from "node:path";
65981
66277
  import { fileURLToPath as fileURLToPath7 } from "node:url";
65982
66278
  init_default_pages();
@@ -66219,7 +66515,7 @@ function buildErrorPayload(error, filename, opts = {}) {
66219
66515
  }
66220
66516
  for (const absPath of candidates) {
66221
66517
  try {
66222
- if (existsSync39(absPath)) {
66518
+ if (existsSync40(absPath)) {
66223
66519
  src2 = readFileSync38(absPath, "utf-8");
66224
66520
  resolvedAbsPath = absPath;
66225
66521
  break;
@@ -66268,7 +66564,7 @@ function buildErrorPayload(error, filename, opts = {}) {
66268
66564
  }
66269
66565
 
66270
66566
  // ../adapter/dist/ssr-error.js
66271
- import { existsSync as existsSync40, readFileSync as readFileSync39 } from "node:fs";
66567
+ import { existsSync as existsSync41, readFileSync as readFileSync39 } from "node:fs";
66272
66568
  import { relative as relative8, resolve as resolve36 } from "node:path";
66273
66569
 
66274
66570
  // ../adapter/dist/error-codeframe.js
@@ -66453,7 +66749,7 @@ function firstSourceFileFrame(stack, projectRoot) {
66453
66749
  if (!isInsideRoot(p, projectRoot))
66454
66750
  continue;
66455
66751
  try {
66456
- if (!existsSync40(p))
66752
+ if (!existsSync41(p))
66457
66753
  continue;
66458
66754
  } catch {
66459
66755
  continue;
@@ -66497,7 +66793,7 @@ function displayPath(absPath, ctx2) {
66497
66793
  }
66498
66794
  function readIfFile(absPath) {
66499
66795
  try {
66500
- if (!existsSync40(absPath))
66796
+ if (!existsSync41(absPath))
66501
66797
  return null;
66502
66798
  return readFileSync39(absPath, "utf-8");
66503
66799
  } catch {
@@ -66647,7 +66943,7 @@ function renderDevErrorPage(payload, opts) {
66647
66943
 
66648
66944
  // src/build-packages.ts
66649
66945
  import { spawnSync as spawnSync2 } from "node:child_process";
66650
- import { cpSync as cpSync2, existsSync as existsSync41, mkdirSync as mkdirSync18, readFileSync as readFileSync40, readdirSync as readdirSync12, statSync as statSync21, writeFileSync as writeFileSync20 } from "node:fs";
66946
+ import { cpSync as cpSync2, existsSync as existsSync42, mkdirSync as mkdirSync18, readFileSync as readFileSync40, readdirSync as readdirSync12, statSync as statSync21, writeFileSync as writeFileSync20 } from "node:fs";
66651
66947
  import { createRequire as createRequire7 } from "node:module";
66652
66948
  import { dirname as dirname26, join as join27, resolve as resolve37 } from "node:path";
66653
66949
  import { fileURLToPath as fileURLToPath8 } from "node:url";
@@ -66696,9 +66992,9 @@ function newestSourceMtime(srcDir) {
66696
66992
  }
66697
66993
  function distStale(pkgDir, entry) {
66698
66994
  const distIndex = join27(pkgDir, "dist", `${entry}.js`);
66699
- if (!existsSync41(distIndex)) return true;
66995
+ if (!existsSync42(distIndex)) return true;
66700
66996
  const distPkg = join27(pkgDir, "dist", "package.json");
66701
- const distStamp = Math.max(statSync21(distIndex).mtimeMs, existsSync41(distPkg) ? statSync21(distPkg).mtimeMs : 0);
66997
+ const distStamp = Math.max(statSync21(distIndex).mtimeMs, existsSync42(distPkg) ? statSync21(distPkg).mtimeMs : 0);
66702
66998
  return newestSourceMtime(join27(pkgDir, "src")) > distStamp;
66703
66999
  }
66704
67000
  function distPackageJson(pkgName, entry, serverEntry, version2) {
@@ -66723,7 +67019,7 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
66723
67019
  function buildPackages(force = false) {
66724
67020
  for (const [pkg, cfg] of Object.entries(PACKAGES)) {
66725
67021
  const pkgDir = resolve37(root2, "packages", pkg);
66726
- if (!existsSync41(join27(pkgDir, "src"))) continue;
67022
+ if (!existsSync42(join27(pkgDir, "src"))) continue;
66727
67023
  if (!force && !distStale(pkgDir, cfg.entry)) continue;
66728
67024
  console.log(`[build] ${cfg.name} -> tsc`);
66729
67025
  const tscBin = require2.resolve("typescript/bin/tsc");
@@ -66772,7 +67068,7 @@ if (process.argv[1] && resolve37(process.argv[1]) === fileURLToPath8(import.meta
66772
67068
  }
66773
67069
 
66774
67070
  // src/action-handler.ts
66775
- import { existsSync as existsSync42, readFileSync as readFileSync41, readdirSync as readdirSync13 } from "node:fs";
67071
+ import { existsSync as existsSync43, readFileSync as readFileSync41, readdirSync as readdirSync13 } from "node:fs";
66776
67072
  import { resolve as resolve38 } from "node:path";
66777
67073
 
66778
67074
  // ../compiler/dist/server-cookies.js
@@ -66865,7 +67161,7 @@ function pageSourcesFor(appDirPath, routeTree) {
66865
67161
  return out;
66866
67162
  }
66867
67163
  function walkVskFiles(dir, out, seen) {
66868
- if (!existsSync42(dir)) return;
67164
+ if (!existsSync43(dir)) return;
66869
67165
  let entries;
66870
67166
  try {
66871
67167
  entries = readdirSync13(dir, { withFileTypes: true });
@@ -66900,7 +67196,7 @@ function candidateSources(appDirPath, routeTree) {
66900
67196
  return out;
66901
67197
  }
66902
67198
  function registerSource(sourcePath2) {
66903
- if (!existsSync42(sourcePath2)) return;
67199
+ if (!existsSync43(sourcePath2)) return;
66904
67200
  try {
66905
67201
  compileFile(readFileSync41(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
66906
67202
  } catch {
@@ -66940,14 +67236,14 @@ async function renderPageHtml(pagePathname, params, ctx2) {
66940
67236
  const node = chain[i];
66941
67237
  const pageFilePath = resolve38(ctx2.appDirPath, node.sourceDir, "page.vsk");
66942
67238
  const layoutFilePath = resolve38(ctx2.appDirPath, node.sourceDir, "layout.vsk");
66943
- if (i === chain.length - 1 && node.page && existsSync42(pageFilePath)) {
67239
+ if (i === chain.length - 1 && node.page && existsSync43(pageFilePath)) {
66944
67240
  const src3 = readFileSync41(pageFilePath, "utf-8");
66945
67241
  const compName2 = resolveComponentName(src3) || node.page;
66946
67242
  const result = await renderPage(src3, compName2, { params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
66947
67243
  body = result.body;
66948
67244
  head = result.head || "";
66949
67245
  }
66950
- if (node.layout && existsSync42(layoutFilePath)) {
67246
+ if (node.layout && existsSync43(layoutFilePath)) {
66951
67247
  const src3 = readFileSync41(layoutFilePath, "utf-8");
66952
67248
  const compName2 = resolveComponentName(src3) || node.layout;
66953
67249
  const result = await renderPage(src3, compName2, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
@@ -66955,7 +67251,7 @@ async function renderPageHtml(pagePathname, params, ctx2) {
66955
67251
  head = (result.head || "") + head;
66956
67252
  }
66957
67253
  }
66958
- const hasLayout = chain.some((n) => n.layout && existsSync42(resolve38(ctx2.appDirPath, n.sourceDir, "layout.vsk")));
67254
+ const hasLayout = chain.some((n) => n.layout && existsSync43(resolve38(ctx2.appDirPath, n.sourceDir, "layout.vsk")));
66959
67255
  if (hasLayout) {
66960
67256
  const secMeta = securityMeta(ctx2.security);
66961
67257
  const headBlock = await applyHeadInjects(
@@ -67210,7 +67506,7 @@ function devErrorContextForMatch(match, appDir, projectDir, routeTree) {
67210
67506
  if (!node || typeof node.sourceDir !== "string") continue;
67211
67507
  const p = resolve39(appDir, node.sourceDir, kind);
67212
67508
  try {
67213
- if (existsSync43(p) && !routeFiles.includes(p)) routeFiles.push(p);
67509
+ if (existsSync44(p) && !routeFiles.includes(p)) routeFiles.push(p);
67214
67510
  } catch {
67215
67511
  }
67216
67512
  }
@@ -67242,9 +67538,9 @@ function resolveRuntimeDir(projectDir) {
67242
67538
  resolve39(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
67243
67539
  ];
67244
67540
  for (const dir of candidates) {
67245
- if (existsSync43(join28(dir, "ripple-runtime.js"))) return dir;
67541
+ if (existsSync44(join28(dir, "ripple-runtime.js"))) return dir;
67246
67542
  const distDir = join28(dir, "dist");
67247
- if (existsSync43(join28(distDir, "ripple-runtime.js"))) return distDir;
67543
+ if (existsSync44(join28(distDir, "ripple-runtime.js"))) return distDir;
67248
67544
  }
67249
67545
  return null;
67250
67546
  }
@@ -67482,7 +67778,7 @@ function collectRoutePaths(nodes, out = []) {
67482
67778
  return out;
67483
67779
  }
67484
67780
  function countFilesNamed(dir, name) {
67485
- if (!existsSync43(dir)) return 0;
67781
+ if (!existsSync44(dir)) return 0;
67486
67782
  let n = 0;
67487
67783
  for (const entry of readdirSync14(dir, { withFileTypes: true })) {
67488
67784
  const p = join28(dir, entry.name);
@@ -67633,13 +67929,13 @@ async function startDevServer(port, projectDir, config, host) {
67633
67929
  const altCssPath = join28(srcDir, "app.css");
67634
67930
  let rawCss = "";
67635
67931
  let devCssSource = "";
67636
- if (existsSync43(appCssPath)) {
67932
+ if (existsSync44(appCssPath)) {
67637
67933
  devCssSource = appCssPath;
67638
67934
  rawCss = readFileSync42(appCssPath, "utf-8");
67639
- } else if (existsSync43(cssPath)) {
67935
+ } else if (existsSync44(cssPath)) {
67640
67936
  devCssSource = cssPath;
67641
67937
  rawCss = readFileSync42(cssPath, "utf-8");
67642
- } else if (existsSync43(altCssPath)) {
67938
+ } else if (existsSync44(altCssPath)) {
67643
67939
  devCssSource = altCssPath;
67644
67940
  rawCss = readFileSync42(altCssPath, "utf-8");
67645
67941
  }
@@ -68127,7 +68423,7 @@ async function startDevServer(port, projectDir, config, host) {
68127
68423
  const kind = classifyHmrWatchPath(filename);
68128
68424
  if (kind === "ignored") return;
68129
68425
  const fullPath = filename.startsWith("/") ? filename : join28(watchDir, filename);
68130
- const fileExists = existsSync43(fullPath);
68426
+ const fileExists = existsSync44(fullPath);
68131
68427
  const bcast = (msg) => {
68132
68428
  const f = globalThis.__vesk_broadcastHmr;
68133
68429
  if (typeof f === "function") f(msg);
@@ -68344,7 +68640,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
68344
68640
  };
68345
68641
  const hmrJsPath = join28(runtimeDir, "hmr-client.js");
68346
68642
  const hmrTsPath = join28(runtimeDir, "hmr-client.ts");
68347
- const hmrClientPath = existsSync43(hmrJsPath) ? hmrJsPath : existsSync43(hmrTsPath) ? hmrTsPath : null;
68643
+ const hmrClientPath = existsSync44(hmrJsPath) ? hmrJsPath : existsSync44(hmrTsPath) ? hmrTsPath : null;
68348
68644
  function extractCompName2(src2) {
68349
68645
  return resolveComponentName(src2);
68350
68646
  }
@@ -68505,7 +68801,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
68505
68801
  }
68506
68802
  if (url.pathname !== "/") {
68507
68803
  const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
68508
- if (staticPath && existsSync43(staticPath) && statSync22(staticPath).isFile()) {
68804
+ if (staticPath && existsSync44(staticPath) && statSync22(staticPath).isFile()) {
68509
68805
  const ext = extname7(staticPath);
68510
68806
  res.writeHead(200, { "Content-Type": MIME2[ext] || "application/octet-stream" });
68511
68807
  res.end(readFileSync42(staticPath));
@@ -68533,7 +68829,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
68533
68829
  }
68534
68830
  const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
68535
68831
  const apiDirPath = join28(appDirPath, "api");
68536
- if (url.pathname.startsWith("/api") && existsSync43(apiDirPath)) {
68832
+ if (url.pathname.startsWith("/api") && existsSync44(apiDirPath)) {
68537
68833
  const apiRoutes = await scanApiRoutes(apiDirPath);
68538
68834
  const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
68539
68835
  if (apiMatch) {
@@ -68660,7 +68956,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
68660
68956
  const node = chain[i];
68661
68957
  const pageFilePath = resolve39(appDirPath, node.sourceDir, "page.vsk");
68662
68958
  const layoutFilePath = resolve39(appDirPath, node.sourceDir, "layout.vsk");
68663
- if (i === chain.length - 1 && node.page && existsSync43(pageFilePath)) {
68959
+ if (i === chain.length - 1 && node.page && existsSync44(pageFilePath)) {
68664
68960
  const src2 = readFileSync42(pageFilePath, "utf-8");
68665
68961
  const compName = extractCompName2(src2) || node.page;
68666
68962
  const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, pageFilePath) });
@@ -68668,7 +68964,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
68668
68964
  head = result.head || "";
68669
68965
  props = result.props;
68670
68966
  }
68671
- if (node.layout && existsSync43(layoutFilePath)) {
68967
+ if (node.layout && existsSync44(layoutFilePath)) {
68672
68968
  const src2 = readFileSync42(layoutFilePath, "utf-8");
68673
68969
  const compName = extractCompName2(src2) || node.layout;
68674
68970
  const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, layoutFilePath) });
@@ -68679,7 +68975,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
68679
68975
  if (forData) {
68680
68976
  return { html: "", props: props || { params: matched.params }, head };
68681
68977
  }
68682
- const hasLayout = chain.some((n) => n.layout && existsSync43(resolve39(appDirPath, n.sourceDir, "layout.vsk")));
68978
+ const hasLayout = chain.some((n) => n.layout && existsSync44(resolve39(appDirPath, n.sourceDir, "layout.vsk")));
68683
68979
  let html;
68684
68980
  if (hasLayout) {
68685
68981
  const ssrData = currentSsrData();
@@ -68748,7 +69044,7 @@ ${prettifyHtml(body)}
68748
69044
  };
68749
69045
  async function* raw2() {
68750
69046
  const chain = cleanChain;
68751
- const hasLayout = chain.some((n) => n.layout && existsSync43(resolve39(appDirPath, n.sourceDir, "layout.vsk")));
69047
+ const hasLayout = chain.some((n) => n.layout && existsSync44(resolve39(appDirPath, n.sourceDir, "layout.vsk")));
68752
69048
  if (!hasLayout) {
68753
69049
  const leaf2 = chain.find((n) => n.page);
68754
69050
  if (leaf2) {
@@ -68767,7 +69063,7 @@ ${prettifyHtml(body)}
68767
69063
  const node = chain[i];
68768
69064
  const pageFilePath = resolve39(appDirPath, node.sourceDir, "page.vsk");
68769
69065
  const layoutFilePath = resolve39(appDirPath, node.sourceDir, "layout.vsk");
68770
- if (i === chain.length - 1 && node.page && existsSync43(pageFilePath)) {
69066
+ if (i === chain.length - 1 && node.page && existsSync44(pageFilePath)) {
68771
69067
  const src2 = readFileSync42(pageFilePath, "utf-8");
68772
69068
  const compName = extractCompName2(src2) || node.page;
68773
69069
  const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, pageFilePath) });
@@ -68775,7 +69071,7 @@ ${prettifyHtml(body)}
68775
69071
  head = result.head || "";
68776
69072
  props = result.props;
68777
69073
  }
68778
- if (node.layout && existsSync43(layoutFilePath)) {
69074
+ if (node.layout && existsSync44(layoutFilePath)) {
68779
69075
  const src2 = readFileSync42(layoutFilePath, "utf-8");
68780
69076
  const compName = extractCompName2(src2) || node.layout;
68781
69077
  const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath, cached: cachedSsrCompile(ssrCompileCache, src2, layoutFilePath) });
@@ -68919,7 +69215,7 @@ ${prettifyHtml(body)}
68919
69215
  const node = match.nodes[i];
68920
69216
  if (node.notFound) {
68921
69217
  const nfPath = resolve39(appDirPath, node.sourceDir, "not-found.vsk");
68922
- if (existsSync43(nfPath)) {
69218
+ if (existsSync44(nfPath)) {
68923
69219
  try {
68924
69220
  const nfSrc = readFileSync42(nfPath, "utf-8");
68925
69221
  const nfCompName = extractCompName2(nfSrc) || node.notFound;
@@ -68965,7 +69261,7 @@ ${prettifyHtml(body)}
68965
69261
  const node = match.nodes[i];
68966
69262
  if (node.error) {
68967
69263
  const errPath = resolve39(appDirPath, node.sourceDir, "error.vsk");
68968
- if (existsSync43(errPath)) {
69264
+ if (existsSync44(errPath)) {
68969
69265
  try {
68970
69266
  const errSrc = readFileSync42(errPath, "utf-8");
68971
69267
  const errCompName = extractCompName2(errSrc) || node.error;
@@ -69371,7 +69667,7 @@ function loadEnvFiles(projectDir) {
69371
69667
  join32(projectDir, ".env.local")
69372
69668
  ];
69373
69669
  for (const filePath of files) {
69374
- if (!existsSync46(filePath)) continue;
69670
+ if (!existsSync47(filePath)) continue;
69375
69671
  const content = readFileSync46(filePath, "utf-8");
69376
69672
  for (const line of content.split("\n")) {
69377
69673
  const trimmed = line.trim();
@@ -69411,7 +69707,7 @@ function resolveProjectDirs(projectDir, config) {
69411
69707
  };
69412
69708
  }
69413
69709
  async function typecheckBeforeBuild(projectDir) {
69414
- if (!existsSync46(join32(projectDir, "tsconfig.json"))) return;
69710
+ if (!existsSync47(join32(projectDir, "tsconfig.json"))) return;
69415
69711
  let tscPath;
69416
69712
  try {
69417
69713
  tscPath = requireFromCli.resolve("typescript/bin/tsc", { paths: [projectDir] });
@@ -69437,7 +69733,7 @@ if (cmd === "build") {
69437
69733
  const projectDir = process.cwd();
69438
69734
  const rawConfig = await loadConfig(projectDir) || {};
69439
69735
  const { appDir: appDirPath, publicDir, outDir } = resolveProjectDirs(projectDir, rawConfig);
69440
- if (!existsSync46(appDirPath)) {
69736
+ if (!existsSync47(appDirPath)) {
69441
69737
  console.error(`vesk build: no app directory found in ${projectDir} (config appDir: ${rawConfig.appDir ?? "./app"})`);
69442
69738
  process.exit(1);
69443
69739
  }
@@ -69512,7 +69808,7 @@ ${frame}`;
69512
69808
  if (cmd === "seo") {
69513
69809
  const projectDir = process.cwd();
69514
69810
  const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
69515
- if (!existsSync46(appDirPath)) {
69811
+ if (!existsSync47(appDirPath)) {
69516
69812
  console.error(`vesk seo: no app directory found in ${projectDir}`);
69517
69813
  process.exit(1);
69518
69814
  }
@@ -69527,7 +69823,7 @@ if (cmd === "seo") {
69527
69823
  if (cmd === "typecheck") {
69528
69824
  const projectDir = process.cwd();
69529
69825
  const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
69530
- if (!existsSync46(appDirPath)) {
69826
+ if (!existsSync47(appDirPath)) {
69531
69827
  console.error(`vesk typecheck: no app directory found in ${projectDir}`);
69532
69828
  process.exit(1);
69533
69829
  }
@@ -69554,7 +69850,7 @@ if (cmd === "start") {
69554
69850
  const { outDir } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
69555
69851
  const port = parsePortArg(args);
69556
69852
  const host = parseHostArg(args);
69557
- if (!existsSync46(outDir)) {
69853
+ if (!existsSync47(outDir)) {
69558
69854
  console.error(`vesk start: no build found at ${outDir} \u2014 run "vesk build" first.`);
69559
69855
  process.exit(1);
69560
69856
  }
@@ -69566,7 +69862,7 @@ if (cmd === "init") {
69566
69862
  const projectDir = process.cwd();
69567
69863
  const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
69568
69864
  const target = join32(appDirPath, "global.css");
69569
- if (existsSync46(target)) {
69865
+ if (existsSync47(target)) {
69570
69866
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
69571
69867
  process.exit(0);
69572
69868
  }
@@ -69628,7 +69924,7 @@ if (cmd === "dev") {
69628
69924
  const { appDir: appDirPath, publicDir } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
69629
69925
  const port = parsePortArg(args);
69630
69926
  const host = parseHostArg(args);
69631
- if (!existsSync46(appDirPath)) {
69927
+ if (!existsSync47(appDirPath)) {
69632
69928
  console.error(`vesk: no app/ directory found in ${projectDir}`);
69633
69929
  console.error('Run "npx create-vesk@latest <project-name>" first');
69634
69930
  process.exit(1);