@vesk/vesk-cli 0.2.35 → 0.2.37

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 +973 -335
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -2488,6 +2488,9 @@ function adoptElementRaw(marker, tag) {
2488
2488
  }
2489
2489
  function createHydrateWalker(container, markerList) {
2490
2490
  const markers = markerList || (container ? collectVskMarkers(container) : []);
2491
+ if (!markerList && container && markers.length === 0 && container.children.length > 0) {
2492
+ return new StructuralWalker(container);
2493
+ }
2491
2494
  return new WalkerEngine(container, markers);
2492
2495
  }
2493
2496
  function bumpNavEpoch() {
@@ -2685,7 +2688,7 @@ function hydrateOnInteraction(container, componentFn, props, options = {}) {
2685
2688
  }
2686
2689
  };
2687
2690
  }
2688
- var __hydrateDevMode, CLAIMED_ATTR, __hydrateStrict, __mismatchHandler, _SHOW_COMMENT, _FILTER_ACCEPT, _FILTER_SKIP, WalkerEngine;
2691
+ var __hydrateDevMode, CLAIMED_ATTR, __hydrateStrict, __mismatchHandler, _SHOW_COMMENT, _FILTER_ACCEPT, _FILTER_SKIP, WalkerEngine, StructuralWalker;
2689
2692
  var init_hydrate = __esm({
2690
2693
  "../runtime/src/hydrate.ts"() {
2691
2694
  "use strict";
@@ -2990,7 +2993,7 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
2990
2993
  }
2991
2994
  return null;
2992
2995
  }
2993
- insertBeforeNextClaim(node) {
2996
+ insertBeforeNextClaim(node, _offset = 0) {
2994
2997
  let i = this.idx;
2995
2998
  while (i < this.markers.length && this.markers[i].state === "claimed") i++;
2996
2999
  const next = i < this.markers.length ? this.markers[i] : null;
@@ -3003,6 +3006,184 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
3003
3006
  return false;
3004
3007
  }
3005
3008
  }
3009
+ injectSkipK(_n) {
3010
+ }
3011
+ takeSkipK() {
3012
+ return 0;
3013
+ }
3014
+ };
3015
+ StructuralWalker = class _StructuralWalker {
3016
+ root;
3017
+ // Snapshot taken at construction, so fresh nodes mounted during the render
3018
+ // are never re-claimed and claims stay aligned to the SSR source list.
3019
+ els;
3020
+ idx = 0;
3021
+ adopted = /* @__PURE__ */ new WeakSet();
3022
+ constructor(root3, els) {
3023
+ this.root = root3;
3024
+ this.els = els || (root3 ? Array.prototype.slice.call(root3.children) : []);
3025
+ }
3026
+ /**
3027
+ * Non-claimable framework preamble elements that the SSR renderer may emit
3028
+ * as real DOM nodes ahead of a component's first claimable element (scoped
3029
+ * `<style>` blocks, the loader title). The marker stream tracked them
3030
+ * implicitly; the structural walker must step PAST them without consuming a
3031
+ * claim slot, otherwise every subsequent positional claim shifts by one and
3032
+ * the whole subtree falls back to fresh-node building.
3033
+ */
3034
+ static skipTags = /* @__PURE__ */ new Set(["style", "script", "template", "title", "meta", "link", "base"]);
3035
+ static isSkippable(el) {
3036
+ return _StructuralWalker.skipTags.has(el.tagName.toLowerCase());
3037
+ }
3038
+ advancePastSkippable(index) {
3039
+ while (index < this.els.length && _StructuralWalker.isSkippable(this.els[index])) index++;
3040
+ return index;
3041
+ }
3042
+ done() {
3043
+ return this.idx >= this.els.length;
3044
+ }
3045
+ remainingCount() {
3046
+ return this.els.length - this.idx;
3047
+ }
3048
+ /**
3049
+ * Insert `node` immediately before the `offset`-th unconsumed SSR element
3050
+ * after the `skipK` cursor slot. Falls back to appending at the end of the
3051
+ * root. Used by root-level dynamic regions whose branch had no SSR content:
3052
+ * the fence anchors at the region's source position instead of the root's
3053
+ * end. `offset` carries the region's first-claim budget (SSR slots past the
3054
+ * cursor): a region that follows static residue must anchor after those
3055
+ * residue slots, at exactly where its own first claim will land — otherwise
3056
+ * fences wrap the WRONG slot and `__place` relocates the claimed content
3057
+ * (e.g. a try/catch whose preceding h2/p/style residue pushes its slot to
3058
+ * `idx + 3`).
3059
+ */
3060
+ insertBeforeCursor(node, offset2 = 0) {
3061
+ const host = this.root;
3062
+ if (host === null || host === void 0) return false;
3063
+ try {
3064
+ let n = this.advancePastSkippable(this.idx + (offset2 || 0));
3065
+ while (n < this.els.length && this.els[n].parentNode !== host) n++;
3066
+ if (n < this.els.length) host.insertBefore(node, this.els[n]);
3067
+ else host.appendChild(node);
3068
+ return true;
3069
+ } catch {
3070
+ return false;
3071
+ }
3072
+ }
3073
+ // Markerless value-thread offset (Phase 3.c): a transient residue deposit for
3074
+ // a compiled component's first top-level claim. `injectSkipK` is emitted by
3075
+ // the CALLER before invoking a self-claiming child (which cannot see the
3076
+ // caller's compile-time skipK); `takeSkipK` is read exactly once at the
3077
+ // callee's first claim and resets the deposit so later claims stay
3078
+ // positional against the advancing cursor. Consumed synchronously on the
3079
+ // same walker reference the call was made through.
3080
+ inheritOffset = 0;
3081
+ injectSkipK(n) {
3082
+ this.inheritOffset = n;
3083
+ }
3084
+ takeSkipK() {
3085
+ const n = this.inheritOffset;
3086
+ this.inheritOffset = 0;
3087
+ return n;
3088
+ }
3089
+ claimAt(tag, skipK, raw2) {
3090
+ if (globalThis.__vesk_hydrate_debug) {
3091
+ console.error("[hyd-dbg] claimAt", tag, "skip=", skipK, "idx=", this.idx, "els=", this.els.length);
3092
+ }
3093
+ let target = this.advancePastSkippable(this.idx + (skipK || 0));
3094
+ if (target > this.els.length) target = this.idx;
3095
+ while (target < this.els.length) {
3096
+ const el = this.els[target];
3097
+ if (tag && el.tagName.toLowerCase() !== tag) {
3098
+ this.idx = this.advancePastSkippable(target + 1);
3099
+ reportMiss(
3100
+ "tag-mismatch",
3101
+ `descriptor wanted <${tag}> but the SSR slot holds <${el.tagName.toLowerCase()}>; consuming one slot and rendering fresh.`,
3102
+ false
3103
+ );
3104
+ return document.createElement(tag || "div");
3105
+ }
3106
+ if (this.adopted.has(el)) {
3107
+ target = this.advancePastSkippable(target + 1);
3108
+ continue;
3109
+ }
3110
+ this.idx = this.advancePastSkippable(target + 1);
3111
+ this.adopted.add(el);
3112
+ if (!raw2) stripDirectTextNodes(el);
3113
+ captureSsrElementChildren(el);
3114
+ stampClaimed(el);
3115
+ return el;
3116
+ }
3117
+ this.idx = this.els.length;
3118
+ reportMiss(
3119
+ "exhausted",
3120
+ `hydration claim missed <${tag || "element"}>; the client rendered more or different content than SSR.`,
3121
+ // Not loud: an exhausted walker is the normal post-hydration
3122
+ // re-render shape (every further claim legitimately builds fresh
3123
+ // nodes) — telemetry-only, mirroring the marker engine.
3124
+ false
3125
+ );
3126
+ return document.createElement(tag || "div");
3127
+ }
3128
+ nextElement(tag, skipK = 0) {
3129
+ return this.claimAt(tag, skipK, false);
3130
+ }
3131
+ claimOnly(tag, skipK = 0) {
3132
+ return this.claimAt(tag, skipK, true);
3133
+ }
3134
+ subWalker(rootEl) {
3135
+ if (globalThis.__vesk_hydrate_debug) {
3136
+ console.error("[hyd-dbg] subWalker over <" + (rootEl && rootEl.tagName) + "> kids=" + (rootEl ? rootEl.children.length : -1));
3137
+ }
3138
+ return new _StructuralWalker(rootEl);
3139
+ }
3140
+ /**
3141
+ * Markerless region scope (Phase 3.e): keyed lists claim their items from a
3142
+ * walker over their OWN container, not the top-level walker — the top
3143
+ * walker's positional cursor would otherwise adopt the region container's
3144
+ * siblings. The scoped walker snapshots the region's children and SHARES
3145
+ * the adoption ledger, so sibling regions in the same container never
3146
+ * double-claim (skip `adopted`) and top-level claims never re-adopt a node
3147
+ * the region already claimed.
3148
+ */
3149
+ scopeToRegion(rootEl) {
3150
+ const w = new _StructuralWalker(rootEl);
3151
+ w.adopted = this.adopted;
3152
+ return w;
3153
+ }
3154
+ retireDetached() {
3155
+ }
3156
+ takeMarkers(_comments) {
3157
+ }
3158
+ claimByKey(_key, _options) {
3159
+ const k = _options && _options.skipK || 0;
3160
+ if (globalThis.__vesk_hydrate_debug) {
3161
+ console.error("[hyd-dbg] claimByKey key=", _key, "idx=", this.idx, "els=", this.els.length, "root=<", this.root ? this.root.tagName : "-", ">");
3162
+ }
3163
+ let target = this.advancePastSkippable(this.idx + k);
3164
+ if (target > this.els.length) target = this.idx;
3165
+ while (target < this.els.length) {
3166
+ const el = this.els[target];
3167
+ if (this.adopted.has(el)) {
3168
+ target = this.advancePastSkippable(target + 1);
3169
+ continue;
3170
+ }
3171
+ this.idx = this.advancePastSkippable(target + 1);
3172
+ this.adopted.add(el);
3173
+ stripDirectTextNodes(el);
3174
+ captureSsrElementChildren(el);
3175
+ stampClaimed(el);
3176
+ return { el };
3177
+ }
3178
+ this.idx = this.els.length;
3179
+ return null;
3180
+ }
3181
+ peekKey(_key) {
3182
+ return null;
3183
+ }
3184
+ insertBeforeNextClaim(node, offset2 = 0) {
3185
+ return this.insertBeforeCursor(node, offset2);
3186
+ }
3006
3187
  };
3007
3188
  }
3008
3189
  });
@@ -3543,36 +3724,58 @@ function handleScroll(pathname, isReplace, scrollBehavior) {
3543
3724
  requestAnimationFrame(() => window.scrollTo({ top: 0, behavior }));
3544
3725
  }
3545
3726
  }
3727
+ function applyHeadAttrs(el, raw2) {
3728
+ for (const attrMatch of raw2.matchAll(/([a-zA-Z0-9\-:]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) {
3729
+ const name = attrMatch[1];
3730
+ const value = attrMatch[3] ?? attrMatch[4] ?? "";
3731
+ if (name.toLowerCase() === "charset") continue;
3732
+ el.setAttribute(name, value);
3733
+ }
3734
+ }
3546
3735
  function applyHead(headHtml) {
3547
- if (typeof document === "undefined" || !headHtml) return;
3736
+ if (typeof document === "undefined") return;
3548
3737
  const head = document.head;
3549
3738
  if (!head) return;
3550
3739
  for (const el of Array.from(head.querySelectorAll("[" + HEAD_MARKER + "]"))) {
3551
3740
  el.remove();
3552
3741
  }
3742
+ if (!headHtml) return;
3553
3743
  const titleMatch = headHtml.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
3554
3744
  if (titleMatch) {
3555
- const existing = head.querySelector("title");
3556
- if (existing) existing.textContent = titleMatch[1];
3557
- else {
3558
- const t = document.createElement("title");
3559
- t.textContent = titleMatch[1];
3560
- head.appendChild(t);
3561
- }
3745
+ const t = document.createElement("title");
3746
+ t.textContent = titleMatch[1];
3747
+ t.setAttribute(HEAD_MARKER, "");
3748
+ head.appendChild(t);
3562
3749
  }
3563
3750
  for (const m of headHtml.matchAll(/<meta\b([^>]*)>/gi)) {
3564
3751
  const meta = document.createElement("meta");
3565
- const raw2 = m[1] || "";
3566
- for (const attrMatch of raw2.matchAll(/([a-zA-Z0-9\-:]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) {
3567
- const name = attrMatch[1];
3568
- const value = attrMatch[3] ?? attrMatch[4] ?? "";
3569
- if (name.toLowerCase() === "charset") continue;
3570
- meta.setAttribute(name, value);
3571
- }
3752
+ applyHeadAttrs(meta, m[1] || "");
3572
3753
  if (!meta.hasAttributes()) continue;
3573
3754
  meta.setAttribute(HEAD_MARKER, "");
3574
3755
  head.appendChild(meta);
3575
3756
  }
3757
+ for (const m of headHtml.matchAll(/<link\b([^>]*)>/gi)) {
3758
+ const link = document.createElement("link");
3759
+ applyHeadAttrs(link, m[1] || "");
3760
+ if (!link.hasAttributes()) continue;
3761
+ link.setAttribute(HEAD_MARKER, "");
3762
+ head.appendChild(link);
3763
+ }
3764
+ const baseMatch = headHtml.match(/<base\b([^>]*)>/i);
3765
+ if (baseMatch) {
3766
+ const base = document.createElement("base");
3767
+ applyHeadAttrs(base, baseMatch[1] || "");
3768
+ if (base.hasAttributes()) {
3769
+ base.setAttribute(HEAD_MARKER, "");
3770
+ head.appendChild(base);
3771
+ }
3772
+ }
3773
+ for (const m of headHtml.matchAll(/<style\b([^>]*)>([\s\S]*?)<\/style>/gi)) {
3774
+ const style = document.createElement("style");
3775
+ style.textContent = m[2];
3776
+ style.setAttribute(HEAD_MARKER, "");
3777
+ head.appendChild(style);
3778
+ }
3576
3779
  }
3577
3780
  function Outlet(props) {
3578
3781
  const router = RouterCtx.get();
@@ -3637,6 +3840,10 @@ function Link(props, registry, hydrate) {
3637
3840
  childStr = typeof props.children === "string" ? props.children : typeof props.children === "number" ? String(props.children) : "";
3638
3841
  }
3639
3842
  if (typeof document === "undefined") {
3843
+ const markerlessSsr = globalThis.__vsk_ssr_markerless === true;
3844
+ if (markerlessSsr) {
3845
+ return `<a ${attrs}>${childStr}</a>`;
3846
+ }
3640
3847
  return `<!--vsk:c:Link--><a ${attrs}>${childStr}</a>`;
3641
3848
  }
3642
3849
  const a = document.createElement("a");
@@ -4298,9 +4505,9 @@ async function applyRouteData(router, match, data2, container, render3 = renderM
4298
4505
  pageNode._dataPath = pathname;
4299
4506
  pageNode._dataFetchedAt = Date.now();
4300
4507
  }
4301
- if (data2.head) {
4302
- applyHead(data2.head);
4303
- if (pageNode) pageNode._head = data2.head;
4508
+ if (data2 && "head" in data2) {
4509
+ applyHead(data2.head || "");
4510
+ if (pageNode) pageNode._head = data2.head || "";
4304
4511
  }
4305
4512
  const hasRealProps = data2.props ? Object.keys(data2.props).some((k) => k !== "params") : false;
4306
4513
  if (!hasRealProps) {
@@ -4757,6 +4964,15 @@ async function hydrateInitial(router, match, container, strategy) {
4757
4964
  return;
4758
4965
  }
4759
4966
  const layoutNodes = chain.filter((n) => n.layout);
4967
+ if (globalThis.__vesk_hydrate_debug) {
4968
+ console.error("[hyd-dbg] hydrateInitial", {
4969
+ pageName: pageNode._pageName,
4970
+ pageType: typeof pageNode.page,
4971
+ layoutNames: layoutNodes.map((n) => n._layoutName),
4972
+ hydratorKeys: router.__hydrators ? Object.keys(router.__hydrators) : null,
4973
+ containerKids: container.children.length
4974
+ });
4975
+ }
4760
4976
  const hydrators = router.__hydrators;
4761
4977
  if (!pageNode.page && !(hydrators && pageNode._pageName && hydrators[pageNode._pageName])) {
4762
4978
  if (await looksOffline()) {
@@ -4803,6 +5019,9 @@ async function hydrateInitial(router, match, container, strategy) {
4803
5019
  const childHydrator = renderLayoutChain2(index + 1);
4804
5020
  return (walker2) => {
4805
5021
  const layoutProps = { children: childHydrator, params: paramValues };
5022
+ if (globalThis.__vesk_hydrate_debug && index === 0) {
5023
+ console.error("[hyd-dbg] invoking outer layout", node._layoutName, typeof hydLayout, "pageChild=", typeof childHydrator);
5024
+ }
4806
5025
  const result = hydLayout(layoutProps, /* @__PURE__ */ new Map(), walker2);
4807
5026
  storeLayoutInstance(router, node, layoutProps, result);
4808
5027
  return result;
@@ -4846,6 +5065,12 @@ async function hydrateInitial(router, match, container, strategy) {
4846
5065
  setIsHydrating(false);
4847
5066
  } catch (error) {
4848
5067
  setIsHydrating(false);
5068
+ if (globalThis.__vesk_hydrate_debug) {
5069
+ console.error("[hyd-dbg] hydrateInitial FAILED:", error);
5070
+ if (error instanceof Error && error.stack) {
5071
+ console.error("[hyd-dbg] hydrateInitial stack:", error.stack.split("\n").slice(0, 12).join("\n"));
5072
+ }
5073
+ }
4849
5074
  if (error instanceof NotFoundError) {
4850
5075
  if (typeof console !== "undefined") console.error("[vesk-debug] NotFoundError during hydration:", error);
4851
5076
  await renderNotFound(router, match, container);
@@ -17364,6 +17589,46 @@ function skipComment(text, i) {
17364
17589
  }
17365
17590
  return i;
17366
17591
  }
17592
+ function blankLeadingLineComments(text) {
17593
+ const chars = text.split("");
17594
+ const n = text.length;
17595
+ let lineStart = true;
17596
+ let i = 0;
17597
+ while (i < n) {
17598
+ const ch = text[i];
17599
+ if (ch === "\n") {
17600
+ lineStart = true;
17601
+ i++;
17602
+ continue;
17603
+ }
17604
+ if (isWhitespaceChar(ch)) {
17605
+ i++;
17606
+ continue;
17607
+ }
17608
+ if (ch === '"' || ch === "'" || ch === "`") {
17609
+ const end = skipString(text, i);
17610
+ for (let k = i; k < end; k++) {
17611
+ const c = text[k];
17612
+ if (c === "\n") lineStart = true;
17613
+ else if (!isWhitespaceChar(c)) lineStart = false;
17614
+ }
17615
+ i = end;
17616
+ continue;
17617
+ }
17618
+ if (ch === "/" && text[i + 1] === "/" && lineStart) {
17619
+ let j = i;
17620
+ while (j < n && text[j] !== "\n") {
17621
+ chars[j] = " ";
17622
+ j++;
17623
+ }
17624
+ i = j;
17625
+ continue;
17626
+ }
17627
+ lineStart = false;
17628
+ i++;
17629
+ }
17630
+ return chars.join("");
17631
+ }
17367
17632
  function findBalancedEnd(text, openIndex) {
17368
17633
  const open = text[openIndex];
17369
17634
  const close = open === "(" ? ")" : open === "[" ? "]" : open === "{" ? "}" : null;
@@ -17762,7 +18027,7 @@ function createBaseParser() {
17762
18027
  }
17763
18028
  function parse4(source, options = {}) {
17764
18029
  const ParserClass = createBaseParser();
17765
- const { code, annotations } = preprocessForClauses(source);
18030
+ const { code, annotations } = preprocessForClauses(blankLeadingLineComments(source));
17766
18031
  try {
17767
18032
  const ast = ParserClass.parse(code, {
17768
18033
  ecmaVersion: "latest",
@@ -18230,115 +18495,12 @@ var init_tokens = __esm({
18230
18495
  }
18231
18496
  });
18232
18497
 
18233
- // ../compiler/src/vsk-imports.ts
18234
- import { dirname as dirname2, resolve } from "node:path";
18235
- import { existsSync as existsSync2 } from "node:fs";
18236
- import { print as print2 } from "esrap";
18237
- import ts2 from "esrap/languages/ts";
18238
- function vskImportTarget(importText) {
18239
- const spec = importModuleTarget(importText);
18240
- if (spec === null || !spec.endsWith(".vsk")) return null;
18241
- const tokens = tokenizeCode(importText);
18242
- if (tokens === null) return null;
18243
- const hasFrom = tokens.some((t) => t.label === "name" && t.value === "from");
18244
- if (!hasFrom) return null;
18245
- return spec;
18246
- }
18247
- function extractImportStatements(source) {
18248
- try {
18249
- const ast = parse4(source, { filename: "imports.vsk" });
18250
- const out = [];
18251
- for (const stmt of ast.body) {
18252
- if (stmt.type === "ImportDeclaration") {
18253
- out.push(source.slice(stmt.start, stmt.end));
18254
- }
18255
- }
18256
- return out;
18257
- } catch {
18258
- return tokenExtractImportStatements(source);
18259
- }
18260
- }
18261
- function tokenExtractImportStatements(source) {
18262
- const tokens = tokenizeCode(source);
18263
- if (tokens === null) return [];
18264
- const out = [];
18265
- for (let i = 0; i < tokens.length; i++) {
18266
- if (tokens[i].label !== "import") continue;
18267
- const start = tokens[i].start;
18268
- let lastStringEnd = -1;
18269
- let end = -1;
18270
- let j = i + 1;
18271
- while (j < tokens.length) {
18272
- if (tokens[j].label === ";") {
18273
- end = tokens[j].end;
18274
- break;
18275
- }
18276
- if (tokens[j].label === "import") break;
18277
- if (tokens[j].label === "string") lastStringEnd = tokens[j].end;
18278
- j++;
18279
- }
18280
- if (end === -1) end = lastStringEnd !== -1 ? lastStringEnd : tokens[i].end;
18281
- const stmt = source.slice(start, end).trim();
18282
- if (stmt) out.push(stmt);
18283
- if (tokens[j] && tokens[j].label === ";") i = j;
18284
- }
18285
- return out;
18286
- }
18287
- function collectVskImportPaths(imports, sourcePath2) {
18288
- const out = [];
18289
- for (const imp of imports) {
18290
- if (stripTypeImport(imp) === null) continue;
18291
- const target = vskImportTarget(imp);
18292
- if (!target || !target.startsWith(".")) continue;
18293
- const full = resolve(dirname2(sourcePath2), target);
18294
- if (existsSync2(full)) out.push(full);
18295
- }
18296
- return out;
18297
- }
18298
- function vskImportLines(source) {
18299
- return extractImportStatements(source).filter((imp) => vskImportTarget(imp) !== null && stripTypeImport(imp) !== null);
18300
- }
18301
- function isTypeOnlyImport(stmt) {
18302
- if (!stmt || stmt.type !== "ImportDeclaration") return false;
18303
- if (stmt.importKind === "type") return true;
18304
- const specs = stmt.specifiers || [];
18305
- return specs.length > 0 && specs.every((s) => s.importKind === "type");
18306
- }
18307
- function stripTypeImport(importSrc) {
18308
- let ast;
18309
- try {
18310
- ast = parse4(importSrc, { filename: "import.mjs" });
18311
- } catch {
18312
- return importSrc;
18313
- }
18314
- const stmt = (ast.body || []).find((n) => n.type === "ImportDeclaration");
18315
- if (!stmt) return importSrc;
18316
- if (isTypeOnlyImport(stmt)) return null;
18317
- const specs = stmt.specifiers || [];
18318
- const kept = specs.filter((s) => s.importKind !== "type");
18319
- if (specs.length > 0 && kept.length === 0) return null;
18320
- if (kept.length === specs.length) return importSrc;
18321
- try {
18322
- const rewritten = { ...stmt, specifiers: kept };
18323
- return print2({ type: "Program", body: [rewritten], sourceType: "module" }, ts2()).code.trim();
18324
- } catch {
18325
- return importSrc;
18326
- }
18327
- }
18328
- var init_vsk_imports = __esm({
18329
- "../compiler/src/vsk-imports.ts"() {
18330
- "use strict";
18331
- init_parser();
18332
- init_tokens();
18333
- }
18334
- });
18335
-
18336
18498
  // ../compiler/src/module-imports.ts
18337
- import { readFileSync as readFileSync2, existsSync as existsSync3, realpathSync, statSync } from "node:fs";
18499
+ import { readFileSync as readFileSync2, existsSync as existsSync2, realpathSync, statSync } from "node:fs";
18338
18500
  import { createRequire as createRequire2 } from "node:module";
18339
- import { dirname as dirname3, extname, isAbsolute, join as join2, resolve as resolve2 } from "node:path";
18340
- import { print as print3 } from "esrap";
18341
- import ts3 from "esrap/languages/ts";
18501
+ import { dirname as dirname2, extname, isAbsolute, join as join2, resolve } from "node:path";
18502
+ import { print as print2 } from "esrap";
18503
+ import ts2 from "esrap/languages/ts";
18342
18504
  import { walk as walk2 } from "zimmerframe";
18343
18505
  function cacheModule(p, val) {
18344
18506
  MODULE_CACHE.delete(p);
@@ -18396,7 +18558,7 @@ function localValueImportNames(importStrs) {
18396
18558
  }
18397
18559
  function applyLocalModuleImports(__vesk, importStrs, sourcePath2) {
18398
18560
  if (!sourcePath2) return;
18399
- const fromDir = dirname3(sourcePath2);
18561
+ const fromDir = dirname2(sourcePath2);
18400
18562
  for (const imp of importStrs) {
18401
18563
  const target = importModuleTarget(imp);
18402
18564
  if (!target || isCompilerOwnedTarget(target) || isValueLessTarget(target)) continue;
@@ -18458,7 +18620,7 @@ function loadSsrModule(absPath) {
18458
18620
  const src2 = readSsrSource(absPath);
18459
18621
  const body = src2?.ast?.body || [];
18460
18622
  if (src2 && isPureReexportBarrel(body)) {
18461
- exportsObj = createLazyBarrelExports(buildBarrelSpec(body), dirname3(absPath));
18623
+ exportsObj = createLazyBarrelExports(buildBarrelSpec(body), dirname2(absPath));
18462
18624
  } else {
18463
18625
  exportsObj = {};
18464
18626
  EVALUATING.set(absPath, exportsObj);
@@ -18673,7 +18835,7 @@ function evaluateModuleFile(absPath, exportsObj, src2) {
18673
18835
  if (!ast) {
18674
18836
  try {
18675
18837
  const fn = new Function("require", "module", "exports", "__dirname", "__filename", raw2);
18676
- fn(createModuleRequire(dirname3(absPath)), { exports: exportsObj }, exportsObj, dirname3(absPath), absPath);
18838
+ fn(createModuleRequire(dirname2(absPath)), { exports: exportsObj }, exportsObj, dirname2(absPath), absPath);
18677
18839
  } catch (err) {
18678
18840
  console.warn(`[vesk] SSR: failed to load ${absPath}: ${err?.message ?? String(err)}`);
18679
18841
  return false;
@@ -18695,7 +18857,7 @@ function evaluateModuleFile(absPath, exportsObj, src2) {
18695
18857
  const body = esmToCjs(stripped.body);
18696
18858
  try {
18697
18859
  const fn = new Function("require", "module", "exports", "__dirname", "__filename", "'use strict';\n" + body);
18698
- fn(createModuleRequire(dirname3(absPath)), { exports: exportsObj }, exportsObj, dirname3(absPath), absPath);
18860
+ fn(createModuleRequire(dirname2(absPath)), { exports: exportsObj }, exportsObj, dirname2(absPath), absPath);
18699
18861
  } catch (err) {
18700
18862
  console.warn(`[vesk] SSR: failed to load ${absPath}: ${err?.message ?? String(err)}`);
18701
18863
  return false;
@@ -18789,7 +18951,7 @@ function findTsconfigPath(fromDir) {
18789
18951
  for (let depth = 0; depth < 64; depth++) {
18790
18952
  const st = statOrNull(join2(dir, "tsconfig.json"));
18791
18953
  if (st && st.isFile()) return join2(dir, "tsconfig.json");
18792
- const parent = dirname3(dir);
18954
+ const parent = dirname2(dir);
18793
18955
  if (parent === dir) break;
18794
18956
  dir = parent;
18795
18957
  }
@@ -18810,13 +18972,13 @@ function buildAliases(tsconfig) {
18810
18972
  }
18811
18973
  const co = parsed?.compilerOptions;
18812
18974
  if (!co || typeof co.paths !== "object" || co.paths === null) return EMPTY_ALIASES;
18813
- const configDir = dirname3(tsconfig);
18814
- const baseUrl = typeof co.baseUrl === "string" && co.baseUrl.length > 0 ? resolve2(configDir, co.baseUrl) : configDir;
18975
+ const configDir = dirname2(tsconfig);
18976
+ const baseUrl = typeof co.baseUrl === "string" && co.baseUrl.length > 0 ? resolve(configDir, co.baseUrl) : configDir;
18815
18977
  const exact = /* @__PURE__ */ new Map();
18816
18978
  const wildcard = [];
18817
18979
  for (const [key, value] of Object.entries(co.paths)) {
18818
18980
  if (!Array.isArray(value)) continue;
18819
- const targets = value.filter((t) => typeof t === "string").map((t) => resolve2(baseUrl, t));
18981
+ const targets = value.filter((t) => typeof t === "string").map((t) => resolve(baseUrl, t));
18820
18982
  if (targets.length === 0) continue;
18821
18983
  const star = key.indexOf("*");
18822
18984
  if (star === -1) exact.set(key, targets);
@@ -18857,12 +19019,12 @@ function resolveAliasModule(spec, fromDir) {
18857
19019
  }
18858
19020
  function resolveImportPath(spec, fromDir) {
18859
19021
  if (spec.startsWith("./") || spec.startsWith("../")) {
18860
- const base = resolve2(fromDir, spec);
19022
+ const base = resolve(fromDir, spec);
18861
19023
  if (extname(base)) return base;
18862
19024
  for (const suffix of EXTENSIONS) {
18863
- if (existsSync3(base + suffix)) return base + suffix;
19025
+ if (existsSync2(base + suffix)) return base + suffix;
18864
19026
  }
18865
- if (existsSync3(`${base}.vsk`)) return `${base}.vsk`;
19027
+ if (existsSync2(`${base}.vsk`)) return `${base}.vsk`;
18866
19028
  return `${base}.ts`;
18867
19029
  }
18868
19030
  if (!isAbsolute(spec)) {
@@ -18874,11 +19036,11 @@ function resolveImportPath(spec, fromDir) {
18874
19036
  function resolveSsrModule(specifier, fromDir) {
18875
19037
  let resolved = null;
18876
19038
  if (specifier === "." || specifier === "..") {
18877
- resolved = probeFile(resolve2(fromDir, specifier));
19039
+ resolved = probeFile(resolve(fromDir, specifier));
18878
19040
  } else if (isAbsolute(specifier)) {
18879
- resolved = probeFile(resolve2(specifier));
19041
+ resolved = probeFile(resolve(specifier));
18880
19042
  } else if (specifier.startsWith("./") || specifier.startsWith("../")) {
18881
- resolved = probeFile(resolve2(fromDir, specifier));
19043
+ resolved = probeFile(resolve(fromDir, specifier));
18882
19044
  } else {
18883
19045
  const aliased = resolveAliasModule(specifier, fromDir);
18884
19046
  if (aliased) return toRealPath(aliased);
@@ -18892,7 +19054,7 @@ function resolveSsrModule(specifier, fromDir) {
18892
19054
  resolved = found;
18893
19055
  break;
18894
19056
  }
18895
- const parent = dirname3(dir);
19057
+ const parent = dirname2(dir);
18896
19058
  if (parent === dir) break;
18897
19059
  dir = parent;
18898
19060
  }
@@ -18955,7 +19117,7 @@ function probeFile(base) {
18955
19117
  try {
18956
19118
  const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
18957
19119
  if (typeof pkg.main === "string" && pkg.main.length > 0) {
18958
- const viaMain = probeFile(resolve2(base, pkg.main));
19120
+ const viaMain = probeFile(resolve(base, pkg.main));
18959
19121
  if (viaMain) return viaMain;
18960
19122
  }
18961
19123
  } catch {
@@ -18980,7 +19142,7 @@ function astName(node) {
18980
19142
  }
18981
19143
  function printNode(node) {
18982
19144
  try {
18983
- return print3(node, ts3()).code.trim();
19145
+ return print2(node, ts2()).code.trim();
18984
19146
  } catch {
18985
19147
  return "";
18986
19148
  }
@@ -19154,7 +19316,7 @@ function collectModuleBundled(absPath, collector) {
19154
19316
  if (existing) return existing;
19155
19317
  const key = `__veskMod${collector.keysByAbs.size}`;
19156
19318
  collector.keysByAbs.set(absPath, key);
19157
- const dir = dirname3(absPath);
19319
+ const dir = dirname2(absPath);
19158
19320
  if (absPath.endsWith(".json")) {
19159
19321
  let raw2 = "";
19160
19322
  try {
@@ -19222,6 +19384,115 @@ var init_module_imports = __esm({
19222
19384
  }
19223
19385
  });
19224
19386
 
19387
+ // ../compiler/src/vsk-imports.ts
19388
+ import { dirname as dirname3, resolve as resolve2 } from "node:path";
19389
+ import { existsSync as existsSync3 } from "node:fs";
19390
+ import { print as print3 } from "esrap";
19391
+ import ts3 from "esrap/languages/ts";
19392
+ function vskImportTarget(importText) {
19393
+ const spec = importModuleTarget(importText);
19394
+ if (spec === null || !spec.endsWith(".vsk")) return null;
19395
+ const tokens = tokenizeCode(importText);
19396
+ if (tokens === null) return null;
19397
+ const hasFrom = tokens.some((t) => t.label === "name" && t.value === "from");
19398
+ if (!hasFrom) return null;
19399
+ return spec;
19400
+ }
19401
+ function extractImportStatements(source) {
19402
+ try {
19403
+ const ast = parse4(source, { filename: "imports.vsk" });
19404
+ const out = [];
19405
+ for (const stmt of ast.body) {
19406
+ if (stmt.type === "ImportDeclaration") {
19407
+ out.push(source.slice(stmt.start, stmt.end));
19408
+ }
19409
+ }
19410
+ return out;
19411
+ } catch {
19412
+ return tokenExtractImportStatements(source);
19413
+ }
19414
+ }
19415
+ function tokenExtractImportStatements(source) {
19416
+ const tokens = tokenizeCode(source);
19417
+ if (tokens === null) return [];
19418
+ const out = [];
19419
+ for (let i = 0; i < tokens.length; i++) {
19420
+ if (tokens[i].label !== "import") continue;
19421
+ const start = tokens[i].start;
19422
+ let lastStringEnd = -1;
19423
+ let end = -1;
19424
+ let j = i + 1;
19425
+ while (j < tokens.length) {
19426
+ if (tokens[j].label === ";") {
19427
+ end = tokens[j].end;
19428
+ break;
19429
+ }
19430
+ if (tokens[j].label === "import") break;
19431
+ if (tokens[j].label === "string") lastStringEnd = tokens[j].end;
19432
+ j++;
19433
+ }
19434
+ if (end === -1) end = lastStringEnd !== -1 ? lastStringEnd : tokens[i].end;
19435
+ const stmt = source.slice(start, end).trim();
19436
+ if (stmt) out.push(stmt);
19437
+ if (tokens[j] && tokens[j].label === ";") i = j;
19438
+ }
19439
+ return out;
19440
+ }
19441
+ function collectVskImportPaths(imports, sourcePath2) {
19442
+ const out = [];
19443
+ for (const imp of imports) {
19444
+ if (stripTypeImport(imp) === null) continue;
19445
+ const target = vskImportTarget(imp);
19446
+ if (!target) continue;
19447
+ if (target.startsWith(".")) {
19448
+ const full = resolve2(dirname3(sourcePath2), target);
19449
+ if (existsSync3(full)) out.push(full);
19450
+ continue;
19451
+ }
19452
+ const aliased = resolveImportPath(target, dirname3(sourcePath2));
19453
+ if (aliased !== target && existsSync3(aliased)) out.push(aliased);
19454
+ }
19455
+ return out;
19456
+ }
19457
+ function vskImportLines(source) {
19458
+ return extractImportStatements(source).filter((imp) => vskImportTarget(imp) !== null && stripTypeImport(imp) !== null);
19459
+ }
19460
+ function isTypeOnlyImport(stmt) {
19461
+ if (!stmt || stmt.type !== "ImportDeclaration") return false;
19462
+ if (stmt.importKind === "type") return true;
19463
+ const specs = stmt.specifiers || [];
19464
+ return specs.length > 0 && specs.every((s) => s.importKind === "type");
19465
+ }
19466
+ function stripTypeImport(importSrc) {
19467
+ let ast;
19468
+ try {
19469
+ ast = parse4(importSrc, { filename: "import.mjs" });
19470
+ } catch {
19471
+ return importSrc;
19472
+ }
19473
+ const stmt = (ast.body || []).find((n) => n.type === "ImportDeclaration");
19474
+ if (!stmt) return importSrc;
19475
+ if (isTypeOnlyImport(stmt)) return null;
19476
+ const specs = stmt.specifiers || [];
19477
+ const kept = specs.filter((s) => s.importKind !== "type");
19478
+ if (specs.length > 0 && kept.length === 0) return null;
19479
+ if (kept.length === specs.length) return importSrc;
19480
+ try {
19481
+ const rewritten = { ...stmt, specifiers: kept };
19482
+ return print3({ type: "Program", body: [rewritten], sourceType: "module" }, ts3()).code.trim();
19483
+ } catch {
19484
+ return importSrc;
19485
+ }
19486
+ }
19487
+ var init_vsk_imports = __esm({
19488
+ "../compiler/src/vsk-imports.ts"() {
19489
+ "use strict";
19490
+ init_parser();
19491
+ init_module_imports();
19492
+ init_tokens();
19493
+ }
19494
+ });
19495
+
19225
19496
  // ../compiler/src/ir-generator.ts
19226
19497
  function parseExprNode(text) {
19227
19498
  try {
@@ -19429,6 +19700,10 @@ function componentUsesFetch(nodes) {
19429
19700
  function extractKeyExpr(nodes) {
19430
19701
  for (const n of nodes) {
19431
19702
  if (n instanceof StaticNode && n.keyExpr) return n.keyExpr;
19703
+ if (n instanceof ComponentCall) {
19704
+ const k = n.props.find((p) => p.name === "key");
19705
+ if (k) return k.value;
19706
+ }
19432
19707
  }
19433
19708
  return null;
19434
19709
  }
@@ -20508,6 +20783,7 @@ __export(server_utils_exports, {
20508
20783
  __vskHydrate: () => __vskHydrate,
20509
20784
  __vskId: () => __vskId,
20510
20785
  __vskImportedNames: () => __vskImportedNames,
20786
+ __vskMarkerless: () => __vskMarkerless,
20511
20787
  applyTrustProxy: () => applyTrustProxy,
20512
20788
  assertSameOrigin: () => assertSameOrigin,
20513
20789
  buildParamInit: () => buildParamInit,
@@ -20548,6 +20824,7 @@ __export(server_utils_exports, {
20548
20824
  setVskForceClaim: () => setVskForceClaim,
20549
20825
  setVskHydrate: () => setVskHydrate,
20550
20826
  setVskImportedNames: () => setVskImportedNames,
20827
+ setVskMarkerless: () => setVskMarkerless,
20551
20828
  signCookie: () => signCookie,
20552
20829
  takeVskForceClaim: () => takeVskForceClaim,
20553
20830
  tryEvalExpr: () => tryEvalExpr,
@@ -20555,14 +20832,19 @@ __export(server_utils_exports, {
20555
20832
  urlAuthority: () => urlAuthority,
20556
20833
  verifyCsrfToken: () => verifyCsrfToken
20557
20834
  });
20558
- function resetVskState(hydrate = false) {
20835
+ function resetVskState(hydrate = false, markerless = true) {
20559
20836
  __vskHydrate = hydrate;
20837
+ __vskMarkerless = markerless;
20560
20838
  __vskId = 0;
20561
20839
  __vskForceClaim = false;
20840
+ globalThis.__vsk_ssr_markerless = markerless === true;
20562
20841
  }
20563
20842
  function setVskHydrate(v) {
20564
20843
  __vskHydrate = v;
20565
20844
  }
20845
+ function setVskMarkerless(v) {
20846
+ __vskMarkerless = v;
20847
+ }
20566
20848
  function setVskImportedNames(names) {
20567
20849
  __vskImportedNames = names;
20568
20850
  }
@@ -21459,7 +21741,7 @@ return load(__ctx);
21459
21741
  const resolved = result && typeof result.then === "function" ? await result : result;
21460
21742
  return resolved;
21461
21743
  }
21462
- var VOID_ELEMENTS2, RAW_TEXT_ELEMENTS, __vskHydrate, __vskId, __vskForceClaim, __vskImportedNames, DEFAULT_MAX_BODY_BYTES, TOKEN_PREFIXES, LOWER, SECRET_KEY_NAMES, _origConsoleError, _origConsoleLog, _redactEnabled, SHA_K, __csrfSecrets, UNSAFE_METHODS, __cookieSecrets, CorsResponse, __cachedRuntimeModule;
21744
+ var VOID_ELEMENTS2, RAW_TEXT_ELEMENTS, __vskHydrate, __vskMarkerless, __vskId, __vskForceClaim, __vskImportedNames, DEFAULT_MAX_BODY_BYTES, TOKEN_PREFIXES, LOWER, SECRET_KEY_NAMES, _origConsoleError, _origConsoleLog, _redactEnabled, SHA_K, __csrfSecrets, UNSAFE_METHODS, __cookieSecrets, CorsResponse, __cachedRuntimeModule;
21463
21745
  var init_server_utils = __esm({
21464
21746
  "../compiler/src/server-utils.ts"() {
21465
21747
  "use strict";
@@ -21487,6 +21769,7 @@ var init_server_utils = __esm({
21487
21769
  ]);
21488
21770
  RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set(["style", "script", "title"]);
21489
21771
  __vskHydrate = false;
21772
+ __vskMarkerless = true;
21490
21773
  __vskId = 0;
21491
21774
  __vskForceClaim = false;
21492
21775
  __vskImportedNames = null;
@@ -27704,7 +27987,12 @@ function headElementKey(node, props, locals2) {
27704
27987
  if (tag === "style") return null;
27705
27988
  return null;
27706
27989
  }
27707
- function irNodeToHeadHtml(node, props, locals2 = {}) {
27990
+ function headIsReconcilable(tag, attrMap) {
27991
+ if (!HEAD_RECONCILE_TAGS.has(tag)) return false;
27992
+ if (tag === "meta" && attrMap.has("charset")) return false;
27993
+ return true;
27994
+ }
27995
+ function irNodeToHeadHtml(node, props, locals2 = {}, reconcileable = false) {
27708
27996
  if (node instanceof StaticNode) {
27709
27997
  const attrMap = new Map(node.attributes.map((a) => [a.name, a.value]));
27710
27998
  for (const child of node.children) {
@@ -27716,10 +28004,11 @@ function irNodeToHeadHtml(node, props, locals2 = {}) {
27716
28004
  }
27717
28005
  }
27718
28006
  }
28007
+ const marker = reconcileable && headIsReconcilable(node.tag, attrMap) ? ` ${HEAD_RECONCILE_MARKER}` : "";
27719
28008
  const attrs = [...attrMap.entries()].map(([k, v]) => ` ${k}="${escapeHtml(v)}"`).join("");
27720
- if (node.selfClosing) return `<${node.tag}${attrs} />`;
27721
- const inner = node.children.filter((c) => !(c instanceof DynamicBinding && c.kind === "attribute" && c.target !== "ref")).map((c) => irNodeToHeadHtml(c, props, locals2)).join("");
27722
- return `<${node.tag}${attrs}>${inner}</${node.tag}>`;
28009
+ if (node.selfClosing) return `<${node.tag}${attrs}${marker} />`;
28010
+ const inner = node.children.filter((c) => !(c instanceof DynamicBinding && c.kind === "attribute" && c.target !== "ref")).map((c) => irNodeToHeadHtml(c, props, locals2, false)).join("");
28011
+ return `<${node.tag}${attrs}${marker}>${inner}</${node.tag}>`;
27723
28012
  }
27724
28013
  if (node instanceof TextNode) return node.value;
27725
28014
  if (node instanceof DynamicBinding) {
@@ -27742,7 +28031,7 @@ function renderHeadHtml(comp, props = {}) {
27742
28031
  const key = headElementKey(child, props, locals2);
27743
28032
  if (key !== null && seen.has(key)) continue;
27744
28033
  if (key !== null) seen.add(key);
27745
- parts.push(irNodeToHeadHtml(child, props, locals2));
28034
+ parts.push(irNodeToHeadHtml(child, props, locals2, true));
27746
28035
  }
27747
28036
  }
27748
28037
  }
@@ -27887,12 +28176,15 @@ function mergeHeadHtml(pageHead, layoutHead) {
27887
28176
  conflicts
27888
28177
  };
27889
28178
  }
28179
+ var HEAD_RECONCILE_MARKER, HEAD_RECONCILE_TAGS;
27890
28180
  var init_server_head = __esm({
27891
28181
  "../compiler/src/server-head.ts"() {
27892
28182
  "use strict";
27893
28183
  init_ir();
27894
28184
  init_server_utils();
27895
28185
  init_scan();
28186
+ HEAD_RECONCILE_MARKER = "data-vesk-head";
28187
+ HEAD_RECONCILE_TAGS = /* @__PURE__ */ new Set(["title", "meta", "link", "base", "style"]);
27896
28188
  }
27897
28189
  });
27898
28190
 
@@ -28263,6 +28555,8 @@ function transformTracked(irNode, tracked2) {
28263
28555
  return context.next();
28264
28556
  if (parent.type === "UpdateExpression" && parent.argument === node)
28265
28557
  return context.next();
28558
+ if (parent.type === "MemberExpression" && !parent.computed && parent.property === node)
28559
+ return context.next();
28266
28560
  if (parent.type === "Property" && parent.value === node && parent.key && parent.key.type === "Identifier" && parent.key.name === "into")
28267
28561
  return context.next();
28268
28562
  if (parent.type === "MemberExpression" && !parent.computed && parent.object === node && parent.property && parent.property.type === "Identifier" && parent.property.name === "set")
@@ -28315,8 +28609,8 @@ function nameAllocFor(sourcePath2, start = 0) {
28315
28609
  }
28316
28610
  return { c: h * 1e6 + start };
28317
28611
  }
28318
- function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
28319
- if (node instanceof StaticNode) return emitStatic(ctx2, node, tracked2, effectsVar);
28612
+ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
28613
+ if (node instanceof StaticNode) return emitStatic(ctx2, node, tracked2, effectsVar, skipK, regionBudget);
28320
28614
  if (node instanceof TextNode) {
28321
28615
  if (!node.value) return null;
28322
28616
  const v = ctx2.n();
@@ -28331,9 +28625,9 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
28331
28625
  return null;
28332
28626
  }
28333
28627
  if (node instanceof ComponentRef) return null;
28334
- if (node instanceof ComponentCall) return emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix);
28335
- if (node instanceof OpaqueDynamicRegion) return emitOpaque(ctx2, node, tracked2, effectsVar, parentVar);
28336
- if (node instanceof MapRegion) return emitMap(ctx2, node, tracked2, effectsVar, parentVar);
28628
+ if (node instanceof ComponentCall) return emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix, skipK, regionBudget);
28629
+ if (node instanceof OpaqueDynamicRegion) return emitOpaque(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
28630
+ if (node instanceof MapRegion) return emitMap(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
28337
28631
  if (node instanceof ServerBlock) return null;
28338
28632
  if (node instanceof ClientBlock) {
28339
28633
  const savedHydrate = ctx2.hydrate;
@@ -28370,10 +28664,10 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
28370
28664
  }
28371
28665
  return null;
28372
28666
  }
28373
- if (node instanceof TryCatch) return emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar);
28374
- if (node instanceof WhileLoop) return emitWhileLoop(ctx2, node, tracked2, parentVar);
28375
- if (node instanceof ForLoop) return emitForLoop(ctx2, node, tracked2, parentVar);
28376
- if (node instanceof SwitchBlock) return emitSwitchBlock(ctx2, node, tracked2, parentVar);
28667
+ if (node instanceof TryCatch) return emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
28668
+ if (node instanceof WhileLoop) return emitWhileLoop(ctx2, node, tracked2, parentVar, skipK, regionBudget);
28669
+ if (node instanceof ForLoop) return emitForLoop(ctx2, node, tracked2, parentVar, skipK, regionBudget);
28670
+ if (node instanceof SwitchBlock) return emitSwitchBlock(ctx2, node, tracked2, parentVar, skipK, regionBudget);
28377
28671
  if (node instanceof PropSlot) return null;
28378
28672
  if (node instanceof PropSlotRender) {
28379
28673
  const slotProp = `props.${node.propName}`;
@@ -28399,7 +28693,7 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
28399
28693
  }
28400
28694
  return null;
28401
28695
  }
28402
- function emitStatic(ctx2, node, tracked2, effectsVar) {
28696
+ function emitStatic(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
28403
28697
  const el = ctx2.n();
28404
28698
  if (ctx2.hydrate) {
28405
28699
  const claim = ctx2.claimStatic;
@@ -28407,8 +28701,11 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28407
28701
  if (!claim && isStaticIR(node.children)) return null;
28408
28702
  const rootClaim = ctx2.rootClaim;
28409
28703
  ctx2.rootClaim = false;
28410
- const claimedExpr = rootClaim ? `__root || ${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})`;
28704
+ const skipExpr = regionBudget && ctx2.markerless ? markerlessSkipExpr(regionBudget, skipK) : skipK;
28705
+ const skipArg = ctx2.markerless ? `, ${skipExpr}` : "";
28706
+ const claimedExpr = rootClaim ? `__root || document.createElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)}${skipArg})`;
28411
28707
  ctx2.push(`const ${el} = ${claimedExpr};`);
28708
+ if (regionBudget && ctx2.markerless) ctx2.push(`${regionBudget} = 0;`);
28412
28709
  } else {
28413
28710
  ctx2.push(`const ${el} = document.createElement(${JSON.stringify(node.tag)});`);
28414
28711
  }
@@ -28437,7 +28734,31 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28437
28734
  const textKids = children.filter((c) => c instanceof TextNode || c instanceof DynamicBinding && c.kind === "text");
28438
28735
  singleReactiveText = textKids.length === 1 && textKids[0] instanceof DynamicBinding && isReactiveExpression(textKids[0].expression, tracked2);
28439
28736
  }
28737
+ const savedWalker = ctx2.walker;
28738
+ let needsSubWalker = false;
28739
+ if (ctx2.hydrate && ctx2.markerless) {
28740
+ for (const child of children) {
28741
+ if (child instanceof TextNode) continue;
28742
+ if (child instanceof DynamicBinding && child.kind === "text") continue;
28743
+ if (child instanceof StaticNode && isStaticIR(child.children)) continue;
28744
+ if (child instanceof TrackDecl) continue;
28745
+ if (child instanceof ComponentRef) continue;
28746
+ if (child instanceof ServerBlock) continue;
28747
+ if (child instanceof ClientBlock) continue;
28748
+ if (child instanceof HeadBlock) continue;
28749
+ if (child instanceof RuntimeStatement) continue;
28750
+ if (child instanceof PropSlot) continue;
28751
+ needsSubWalker = true;
28752
+ break;
28753
+ }
28754
+ }
28755
+ if (needsSubWalker) {
28756
+ const sub = ctx2.n();
28757
+ ctx2.push(`const ${sub} = ${ctx2.walker}.subWalker(${el});`);
28758
+ ctx2.walker = sub;
28759
+ }
28440
28760
  let residueBefore = 0;
28761
+ let pendingSkip = 0;
28441
28762
  for (const child of children) {
28442
28763
  let childVar;
28443
28764
  const isPureStaticChild = ctx2.hydrate && child instanceof StaticNode && isStaticIR(child.children);
@@ -28491,10 +28812,12 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28491
28812
  }
28492
28813
  }
28493
28814
  childVar = ssrEl;
28815
+ pendingSkip += ssrResidueEstimate(child);
28494
28816
  } else if (singleReactiveText && child instanceof DynamicBinding && child.kind === "text") {
28495
28817
  childVar = emitDynamicBinding(ctx2, child, tracked2, effectsVar, `${el}.__vsk_ssrText`);
28496
28818
  } else {
28497
- childVar = emitNode(ctx2, child, tracked2, effectsVar, el);
28819
+ childVar = emitNode(ctx2, child, tracked2, effectsVar, el, "__components", pendingSkip);
28820
+ if (claimsWalkerNode(ctx2, child)) pendingSkip = 0;
28498
28821
  }
28499
28822
  if (childVar) {
28500
28823
  if (ctx2.hydrate) {
@@ -28546,6 +28869,7 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28546
28869
  }
28547
28870
  }
28548
28871
  }
28872
+ if (ctx2.walker !== savedWalker) ctx2.walker = savedWalker;
28549
28873
  return el;
28550
28874
  }
28551
28875
  function emitClientHead(ctx2, node, tracked2) {
@@ -28676,16 +29000,19 @@ function emitFragment(ctx2, nodes, tracked2, effectsVar) {
28676
29000
  const savedEffects = ctx2.effects;
28677
29001
  ctx2.effects = [];
28678
29002
  ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
29003
+ let fragPendingSkip = 0;
28679
29004
  for (const child of nodes) {
28680
- const childVar = emitNode(ctx2, child, tracked2, effectsVar, "$f");
29005
+ const childVar = emitNode(ctx2, child, tracked2, effectsVar, "$f", "__components", fragPendingSkip);
28681
29006
  if (childVar) ctx2.push(`$f.appendChild(${childVar});`);
29007
+ if (claimsWalkerNode(ctx2, child)) fragPendingSkip = 0;
29008
+ else fragPendingSkip += ssrResidueEstimate(child);
28682
29009
  }
28683
29010
  for (const eff of ctx2.effects) ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr(eff)});` : eff);
28684
29011
  ctx2.effects = savedEffects;
28685
29012
  ctx2.push(`return $f; })();`);
28686
29013
  return frag;
28687
29014
  }
28688
- function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
29015
+ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
28689
29016
  const propsEntries = node.props.map((p) => {
28690
29017
  if (typeof p.value === "string") return `${JSON.stringify(p.name)}: ${JSON.stringify(p.value)}`;
28691
29018
  const expr = transformTracked(p.value, tracked2);
@@ -28707,11 +29034,17 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28707
29034
  const callArgs = () => `{ ${propsEntries.join(", ")} }`;
28708
29035
  if (ctx2.hydrate) {
28709
29036
  const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `__components[${JSON.stringify(node.componentName)}]`);
29037
+ if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
29038
+ ctx2.push(`if (${access} == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
29039
+ }
28710
29040
  const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
28711
29041
  const walkerArg = ctx2.walker;
29042
+ const promptExpr = ctx2.markerless && (regionBudget || skipK > 0) ? markerlessSkipExpr(regionBudget, skipK) : null;
28712
29043
  const maybeReplace = (v2) => {
28713
29044
  if (!plainTarget) return;
28714
- ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${walkerArg}.claimOnly(); if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
29045
+ const claim = promptExpr ? `${walkerArg}.claimOnly(undefined, ${promptExpr})` : `${walkerArg}.claimOnly()`;
29046
+ ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
29047
+ if (regionBudget && ctx2.markerless) ctx2.push(`${regionBudget} = 0;`);
28715
29048
  };
28716
29049
  const maybeRetire = () => {
28717
29050
  if (ctx2.selfClaimNames.has(node.componentName)) {
@@ -28740,9 +29073,13 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28740
29073
  ctx2.push(`return $f; })();`);
28741
29074
  propsEntries.push(`children: ${frag}`);
28742
29075
  }
29076
+ if (ctx2.markerless && promptExpr && !plainTarget) {
29077
+ ctx2.push(`${walkerArg}.injectSkipK(${promptExpr});`);
29078
+ }
28743
29079
  ctx2.push(`let ${v} = undefined;`);
28744
29080
  ctx2.push(`if (__hydrate) __hydrate.childFrame = (__hydrate.childFrame || 0) + 1;`);
28745
29081
  ctx2.push(`try { ${v} = ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}); } finally { if (__hydrate) __hydrate.childFrame--; }`);
29082
+ if (ctx2.markerless && promptExpr && !plainTarget && regionBudget) ctx2.push(`${regionBudget} = 0;`);
28746
29083
  maybeReplace(v);
28747
29084
  maybeRetire();
28748
29085
  return v;
@@ -28770,30 +29107,50 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28770
29107
  } else if (ctx2.importedNames.has(node.componentName)) {
28771
29108
  ctx2.push(`const ${v} = ${awaitKw}${node.componentName}(${callArgs()});`);
28772
29109
  } else {
29110
+ ctx2.push(`if (${compPrefix}[${JSON.stringify(node.componentName)}] == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
28773
29111
  ctx2.push(`const ${v} = ${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()});`);
28774
29112
  }
28775
29113
  }
28776
29114
  return v;
28777
29115
  }
28778
- function emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, rootLevel) {
29116
+ function emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, rootLevel, offsetExpr) {
28779
29117
  if (!ctx2.hydrate || !rootLevel) return;
28780
29118
  ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
28781
- ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
28782
- ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${anchor});`));
28783
- ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
29119
+ ctx2.push(`if (${ctx2.walker} && ${ctx2.walker}.insertBeforeNextClaim) {`);
29120
+ ctx2.push(indent2(`${ctx2.walker}.insertBeforeNextClaim(${anchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
29121
+ ctx2.push(indent2(`${ctx2.walker}.insertBeforeNextClaim(${endAnchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
28784
29122
  ctx2.push(`}`);
28785
29123
  }
28786
- function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
29124
+ function regionBudgetVar(ctx2, skipK, regionBudget, inheritedInit) {
29125
+ if (!ctx2.markerless || !ctx2.hydrate) return null;
29126
+ if (skipK > 0) {
29127
+ const pk = ctx2.n();
29128
+ ctx2.push(`let ${pk} = ${skipK}; // first-claim budget: region SSR sits ${skipK} slot(s) past the walker cursor`);
29129
+ return pk;
29130
+ }
29131
+ if (inheritedInit) {
29132
+ const pk = ctx2.n();
29133
+ ctx2.push(`let ${pk} = ${inheritedInit}; // first-claim budget: inherited from the caller's walker residue`);
29134
+ return pk;
29135
+ }
29136
+ return regionBudget || null;
29137
+ }
29138
+ function markerlessSkipExpr(regionBudget, skipK) {
29139
+ if (regionBudget) return skipK > 0 ? `${regionBudget} + ${skipK}` : regionBudget;
29140
+ return String(skipK);
29141
+ }
29142
+ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar, skipK = 0, regionBudget) {
28787
29143
  const anchor = ctx2.n();
28788
29144
  const endAnchor = ctx2.n();
28789
29145
  const effArr = ctx2.n();
28790
29146
  const catchParam = node.catchParamName || "__e";
28791
29147
  const parent = parentVar || "$root";
29148
+ const budget = ctx2.hydrate ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
28792
29149
  ctx2.push(`const ${anchor} = document.createComment('try');`);
28793
29150
  if (!ctx2.hydrate) ctx2.push(`${parent}.appendChild(${anchor});`);
28794
29151
  ctx2.push(`let ${effArr} = [];`);
28795
29152
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
28796
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29153
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
28797
29154
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28798
29155
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
28799
29156
  const savedHydrate = ctx2.hydrate;
@@ -28811,7 +29168,7 @@ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28811
29168
  ctx2.push(indent2(`const __cl = [];`));
28812
29169
  }
28813
29170
  for (const child of body) {
28814
- const childVar = emitNode(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix);
29171
+ const childVar = emitNode(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix, 0, budget || void 0);
28815
29172
  if (childVar) {
28816
29173
  if (hydMode) ctx2.push(indent2(`__cl.push(${childVar});`));
28817
29174
  else ctx2.push(indent2(`__p.insertBefore(${childVar}, ${endAnchor});`));
@@ -28857,9 +29214,10 @@ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28857
29214
  }`);
28858
29215
  return null;
28859
29216
  }
28860
- function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
29217
+ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
28861
29218
  const hyd = ctx2.hydrate;
28862
29219
  const parent = parentVar || "$root";
29220
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
28863
29221
  const isOpaque = (n) => !!n && typeof n.condition !== "undefined";
28864
29222
  if (hyd && node.alternateNodes.length === 1 && isOpaque(node.alternateNodes[0])) {
28865
29223
  const chain = [];
@@ -28880,7 +29238,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28880
29238
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
28881
29239
  ctx2.push(`let ${effectsVar2} = [];`);
28882
29240
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
28883
- emitHydrateFenceAnchoring(ctx2, anchor2, endAnchor2, parent === "$root");
29241
+ emitHydrateFenceAnchoring(ctx2, anchor2, endAnchor2, parent === "$root", budget || void 0);
28884
29242
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
28885
29243
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
28886
29244
  const renderNames = [];
@@ -28893,7 +29251,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28893
29251
  for (const n of chain[i].nodes) {
28894
29252
  const savedClaim = ctx2.claimStatic;
28895
29253
  if (hyd) ctx2.claimStatic = true;
28896
- const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
29254
+ const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
28897
29255
  ctx2.claimStatic = savedClaim;
28898
29256
  if (v) ctx2.push(indent2(`${cl}.push(${v});`));
28899
29257
  }
@@ -28909,7 +29267,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28909
29267
  for (const n of finalElse) {
28910
29268
  const savedClaim = ctx2.claimStatic;
28911
29269
  if (hyd) ctx2.claimStatic = true;
28912
- const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
29270
+ const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
28913
29271
  ctx2.claimStatic = savedClaim;
28914
29272
  if (v) ctx2.push(indent2(`${cl2}.push(${v});`));
28915
29273
  }
@@ -28963,7 +29321,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28963
29321
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
28964
29322
  ctx2.push(`let ${effectsVar} = [];`);
28965
29323
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
28966
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29324
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
28967
29325
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28968
29326
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
28969
29327
  const conRenderName = ctx2.n();
@@ -28975,7 +29333,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28975
29333
  for (const n of node.consequentNodes) {
28976
29334
  const savedClaim = ctx2.claimStatic;
28977
29335
  if (hyd) ctx2.claimStatic = true;
28978
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
29336
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag, "__components", 0, budget || void 0);
28979
29337
  ctx2.claimStatic = savedClaim;
28980
29338
  if (v) {
28981
29339
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
@@ -28996,7 +29354,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28996
29354
  for (const n of node.alternateNodes) {
28997
29355
  const savedAltClaim = ctx2.claimStatic;
28998
29356
  if (hyd) ctx2.claimStatic = true;
28999
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
29357
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag, "__components", 0, budget || void 0);
29000
29358
  ctx2.claimStatic = savedAltClaim;
29001
29359
  if (v) {
29002
29360
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
@@ -29037,18 +29395,19 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
29037
29395
  }
29038
29396
  return null;
29039
29397
  }
29040
- function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29398
+ function emitWhileLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
29041
29399
  const condExpr = transformTracked(node.condition, tracked2);
29042
29400
  const anchor = ctx2.n();
29043
29401
  const endAnchor = ctx2.n();
29044
29402
  const effectsVar = ctx2.n();
29045
29403
  const hyd = ctx2.hydrate;
29046
29404
  const parent = parentVar || "$root";
29405
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29047
29406
  ctx2.push(`const ${anchor} = document.createComment('while');`);
29048
29407
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29049
29408
  ctx2.push(`let ${effectsVar} = [];`);
29050
29409
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
29051
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29410
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
29052
29411
  const renderLoop = ctx2.n();
29053
29412
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29054
29413
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29057,7 +29416,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29057
29416
  if (node.isDoWhile) {
29058
29417
  ctx2.push(indent2(`do {`));
29059
29418
  for (const n of node.bodyTemplate) {
29060
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29419
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29061
29420
  if (v) {
29062
29421
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29063
29422
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29067,7 +29426,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29067
29426
  } else {
29068
29427
  ctx2.push(indent2(`while (${condExpr}) {`));
29069
29428
  for (const n of node.bodyTemplate) {
29070
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29429
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29071
29430
  if (v) {
29072
29431
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29073
29432
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29101,17 +29460,18 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29101
29460
  }`);
29102
29461
  return null;
29103
29462
  }
29104
- function emitForLoop(ctx2, node, tracked2, parentVar) {
29463
+ function emitForLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
29105
29464
  const anchor = ctx2.n();
29106
29465
  const endAnchor = ctx2.n();
29107
29466
  const effectsVar = ctx2.n();
29108
29467
  const hyd = ctx2.hydrate;
29109
29468
  const parent = parentVar || "$root";
29469
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29110
29470
  ctx2.push(`const ${anchor} = document.createComment('for');`);
29111
29471
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29112
29472
  ctx2.push(`let ${effectsVar} = [];`);
29113
29473
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
29114
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29474
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
29115
29475
  const renderLoop = ctx2.n();
29116
29476
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29117
29477
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29121,7 +29481,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29121
29481
  const srcExpr = transformTracked(node.condition, tracked2);
29122
29482
  ctx2.push(indent2(`for (${node.init} of (Array.isArray(${srcExpr}) ? ${srcExpr} : (${srcExpr} == null ? [] : Object.keys(${srcExpr})))) {`));
29123
29483
  for (const n of node.bodyTemplate) {
29124
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29484
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29125
29485
  if (v) {
29126
29486
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29127
29487
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29137,7 +29497,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29137
29497
  const head = initPart ? `${initPart}; ${condExpr}` : `; ${condExpr}`;
29138
29498
  ctx2.push(indent2(`for (${head}; ${updatePart}) {`));
29139
29499
  for (const n of node.bodyTemplate) {
29140
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29500
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29141
29501
  if (v) {
29142
29502
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29143
29503
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29241,18 +29601,19 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29241
29601
  }
29242
29602
  return null;
29243
29603
  }
29244
- function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29604
+ function emitSwitchBlock(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
29245
29605
  const discExpr = transformTracked(node.discriminant, tracked2);
29246
29606
  const anchor = ctx2.n();
29247
29607
  const endAnchor = ctx2.n();
29248
29608
  const effectsVar = ctx2.n();
29249
29609
  const hyd = ctx2.hydrate;
29250
29610
  const parent = parentVar || "$root";
29611
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29251
29612
  ctx2.push(`const ${anchor} = document.createComment('switch');`);
29252
29613
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29253
29614
  ctx2.push(`let ${effectsVar} = [];`);
29254
29615
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
29255
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29616
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
29256
29617
  const renderSwitch = ctx2.n();
29257
29618
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29258
29619
  if (hyd) {
@@ -29269,7 +29630,7 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29269
29630
  ctx2.push(indent2(`default:`));
29270
29631
  }
29271
29632
  for (const n of c.body) {
29272
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c");
29633
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c", "__components", 0, budget || void 0);
29273
29634
  if (v) {
29274
29635
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29275
29636
  else ctx2.push(indent2(`__c.appendChild(${v});`));
@@ -29304,7 +29665,7 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29304
29665
  }`);
29305
29666
  return null;
29306
29667
  }
29307
- function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29668
+ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
29308
29669
  const arrExpr = transformTracked(node.expression, tracked2);
29309
29670
  const itemVar = node.itemVariable;
29310
29671
  const anchor = ctx2.n();
@@ -29316,6 +29677,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29316
29677
  const hyd = ctx2.hydrate && !keyed;
29317
29678
  const hydKeyed = ctx2.hydrate && keyed;
29318
29679
  const parent = parentVar || "$root";
29680
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29319
29681
  const reactiveSource = isReactiveExpression(node.expression, tracked2);
29320
29682
  const pushEffect = (lets, effCall) => {
29321
29683
  if (effTarget) {
@@ -29347,7 +29709,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29347
29709
  }
29348
29710
  if (hydKeyed) ctx2.rootClaim = true;
29349
29711
  for (const n of node.bodyTemplate) {
29350
- const v = emitNode(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it");
29712
+ const v = emitNode(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it", "__components", 0, budget || void 0);
29351
29713
  if (v) {
29352
29714
  if (hyd) {
29353
29715
  ctx2.push(indent2(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, __r);`));
@@ -29374,7 +29736,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29374
29736
  if (hydKeyed) ctx2.hydrate = false;
29375
29737
  for (const n of node.alternateNodes) {
29376
29738
  ctx2.claimStatic = true;
29377
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag);
29739
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag, "__components", 0, budget || void 0);
29378
29740
  if (v) {
29379
29741
  if (hyd) ctx2.push(indent2(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, ${endAnchor});`));
29380
29742
  else ctx2.push(indent2(`${frag}.appendChild(${v});`));
@@ -29395,7 +29757,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29395
29757
  const initList = ctx2.n();
29396
29758
  ctx2.push(`let ${reconciler} = () => {};`);
29397
29759
  if (hydKeyed) {
29398
- ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}); };`);
29760
+ ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}, ${skipK}); };`);
29399
29761
  } else {
29400
29762
  ctx2.push(`const ${initList} = () => { ${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
29401
29763
  }
@@ -29493,13 +29855,14 @@ ${renderAllItems(" ", null)}
29493
29855
  function computeAsyncComponents(comps) {
29494
29856
  return new Set(comps.filter((c) => c.isAsync).map((c) => c.name));
29495
29857
  }
29496
- function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc) {
29858
+ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc, markerless = true) {
29497
29859
  const tracked2 = collectTrackedNames(comp.body);
29498
29860
  const ctx2 = new Ctx(alloc);
29499
29861
  ctx2.importedNames = importedNames;
29500
29862
  ctx2.linkNames = linkNames;
29501
29863
  ctx2.selfClaimNames = selfClaimNames;
29502
29864
  ctx2.hydrate = hydrate;
29865
+ ctx2.markerless = markerless;
29503
29866
  ctx2.asyncComps = asyncComps;
29504
29867
  ctx2.isAsyncScope = comp.isAsync || asyncComps.has(comp.name);
29505
29868
  ctx2.push(hydrate ? ctx2.isAsyncScope ? "async (props, __registry, __hydrate) => {" : "(props, __registry, __hydrate) => {" : ctx2.isAsyncScope ? "async (props) => {" : "(props) => {");
@@ -29527,9 +29890,19 @@ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydr
29527
29890
  emitNode(ctx2, node, tracked2, null);
29528
29891
  }
29529
29892
  }
29893
+ let topPendingSkip = 0;
29894
+ let topBudget = null;
29895
+ if (ctx2.markerless && ctx2.hydrate) {
29896
+ topBudget = regionBudgetVar(
29897
+ ctx2,
29898
+ 0,
29899
+ void 0,
29900
+ `(typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0)`
29901
+ );
29902
+ }
29530
29903
  for (const node of comp.body) {
29531
29904
  if (node instanceof TrackDecl) continue;
29532
- const v = emitNode(ctx2, node, tracked2, null);
29905
+ const v = emitNode(ctx2, node, tracked2, null, void 0, "__components", topPendingSkip, topBudget || void 0);
29533
29906
  if (v) {
29534
29907
  if (ctx2.hydrate) {
29535
29908
  ctx2.push(indent2(`if ($mount === null) $mount = ${v};`));
@@ -29538,6 +29911,10 @@ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydr
29538
29911
  ctx2.push(indent2(`$root.appendChild(${v});`));
29539
29912
  }
29540
29913
  }
29914
+ if (claimsWalkerNode(ctx2, node)) {
29915
+ topBudget = null;
29916
+ topPendingSkip = 0;
29917
+ } else topPendingSkip += ssrResidueEstimate(node);
29541
29918
  }
29542
29919
  const effCode = ctx2.flushEffects();
29543
29920
  if (effCode) ctx2.push(indent2(effCode.trim()));
@@ -29560,7 +29937,7 @@ function buildParamInit2(paramNames) {
29560
29937
  if (paramNames.length === 0) return "";
29561
29938
  return `const { ${paramNames.join(", ")} } = props;`;
29562
29939
  }
29563
- function buildComponentMap(irRoot, hydrate = false, alloc) {
29940
+ function buildComponentMap(irRoot, hydrate = false, alloc, markerless = true) {
29564
29941
  const mapLines = [];
29565
29942
  mapLines.push(`const __components = {};`);
29566
29943
  const asyncComps = computeAsyncComponents(irRoot.components);
@@ -29581,11 +29958,12 @@ function buildComponentMap(irRoot, hydrate = false, alloc) {
29581
29958
  const directNames = /* @__PURE__ */ new Set([...extractRuntimeNames(irRoot.imports), ...localValueImportNames(irRoot.imports), ...topValueNames]);
29582
29959
  for (const comp of irRoot.components) {
29583
29960
  if (hydrate && isStaticComponent(comp)) {
29584
- const stub = `(props, __registry, __hydrate) => { return __hydrate.claimOnly(); }`;
29961
+ const claimExpr = markerless ? `__hydrate.claimOnly(undefined, (typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0))` : `__hydrate.claimOnly()`;
29962
+ const stub = `(props, __registry, __hydrate) => { return ${claimExpr}; }`;
29585
29963
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${stub};`);
29586
29964
  continue;
29587
29965
  }
29588
- const code = generateComponent(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc);
29966
+ const code = generateComponent(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc, markerless);
29589
29967
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${code};`);
29590
29968
  }
29591
29969
  mapLines.push(`function __cleanup(start, end) {`);
@@ -29606,6 +29984,12 @@ function buildComponentMap(irRoot, hydrate = false, alloc) {
29606
29984
  mapLines.push(` const p = nodes[0].parentNode;`);
29607
29985
  mapLines.push(` p.insertBefore(start, nodes[0]);`);
29608
29986
  mapLines.push(` p.insertBefore(end, nodes[nodes.length - 1].nextSibling);`);
29987
+ mapLines.push(` // Client-surplus nodes (SSR rendered fewer items than the client data)`);
29988
+ mapLines.push(` // are freshly claimed and still detached \u2014 move them into the region in`);
29989
+ mapLines.push(` // client order before \`end\`, instead of stranding them off-parent.`);
29990
+ mapLines.push(` for (let i = 0; i < nodes.length; i++) {`);
29991
+ mapLines.push(` if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);`);
29992
+ mapLines.push(` }`);
29609
29993
  mapLines.push(` return;`);
29610
29994
  mapLines.push(` }`);
29611
29995
  mapLines.push(` fallback.appendChild(start);`);
@@ -29656,6 +30040,17 @@ function isStaticIR(body) {
29656
30040
  }
29657
30041
  return true;
29658
30042
  }
30043
+ function claimsWalkerNode(ctx2, node) {
30044
+ if (node instanceof StaticNode) return ctx2.claimStatic || !isStaticIR(node.children);
30045
+ if (node instanceof ComponentCall) return true;
30046
+ if (node instanceof OpaqueDynamicRegion) return true;
30047
+ if (node instanceof MapRegion) return true;
30048
+ if (node instanceof ForLoop) return true;
30049
+ if (node instanceof WhileLoop) return true;
30050
+ if (node instanceof SwitchBlock) return true;
30051
+ if (node instanceof TryCatch) return true;
30052
+ return false;
30053
+ }
29659
30054
  function isStaticComponent(comp) {
29660
30055
  if (comp.style) return false;
29661
30056
  return isStaticIR(comp.body);
@@ -29784,7 +30179,7 @@ function emitClientFromIR(ir, options) {
29784
30179
  if (!options.forceClient && !needsClient) {
29785
30180
  return "";
29786
30181
  }
29787
- const componentMapCode = buildComponentMap(ir, options.hydrate, options.nameAllocator);
30182
+ const componentMapCode = buildComponentMap(ir, options.hydrate, options.nameAllocator, options.markerless !== false);
29788
30183
  const importLines = ir.imports.length > 0 ? ir.imports.join("\n") + "\n" : "";
29789
30184
  const topCode = (options.includeTopLevel === false ? [] : transformTopLevelForActions(ir.topLevelCode, "client")).join("\n") + "\n";
29790
30185
  const exportLines = [];
@@ -29862,7 +30257,7 @@ function compileClientBoth(source, _componentName, sourcePath2, opts) {
29862
30257
  if (opts?.skipHyd) return { comp, hyd: "", name };
29863
30258
  return {
29864
30259
  comp,
29865
- hyd: emitClientFromIR(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc }),
30260
+ hyd: emitClientFromIR(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
29866
30261
  name
29867
30262
  };
29868
30263
  }
@@ -29927,6 +30322,12 @@ var init_client_codegen = __esm({
29927
30322
  delegatedEvents = /* @__PURE__ */ new Set();
29928
30323
  directEvents = /* @__PURE__ */ new Set();
29929
30324
  hydrate = false;
30325
+ // Markerless structural hydration: claims run `nextElement(tag, skipK)` with
30326
+ // positional residue offsets and interior claims rebind the walker to the
30327
+ // claimed element (subWalker). Only meaningful when `hydrate` is also true.
30328
+ // Markerless is the DEFAULT; pass `markerless: false` to restore legacy
30329
+ // marker-mode claim emission.
30330
+ markerless = true;
29930
30331
  inTryBody = false;
29931
30332
  claimStatic = false;
29932
30333
  // While set, the next StaticNode claimed in hydrate mode uses `__root` (the
@@ -30035,6 +30436,7 @@ function irNodeToJS(node, importedNames, isAsync = false, tracked2) {
30035
30436
  }
30036
30437
  if (node instanceof RuntimeStatement) return semicolonizeStatement(transformTracked(node, tracked2 || /* @__PURE__ */ new Map()));
30037
30438
  if (node instanceof SlotNode) {
30439
+ if (__vskMarkerless) return `__out.push(props.children || '');`;
30038
30440
  const sid = `s${nextVskId()}`;
30039
30441
  return `__out.push('<!--vsk-slot:${sid}-->');__out.push(props.children || '');__out.push('<!--vsk-slot-end:${sid}-->');`;
30040
30442
  }
@@ -30064,7 +30466,7 @@ function staticNodeToJS(node, isAsync = false, tracked2) {
30064
30466
  let openTag = `<${node.tag}`;
30065
30467
  const forceClaim = takeVskForceClaim();
30066
30468
  const subtreeNeedsJS = __vskHydrate && (forceClaim || !isStaticIR(node.children));
30067
- if (subtreeNeedsJS) {
30469
+ if (subtreeNeedsJS && !__vskMarkerless) {
30068
30470
  lines.push("__out.push(" + JSON.stringify(`<!--vsk:t:${sanitizeMarkerName(node.tag)}-->`) + ");");
30069
30471
  }
30070
30472
  for (const attr of node.attributes) {
@@ -30157,7 +30559,7 @@ function mapRegionToJS(node, isAsync = false, tracked2) {
30157
30559
  const lines = [];
30158
30560
  const arr = exprJSX(node.expression, tracked2);
30159
30561
  const item = node.itemVariable;
30160
- const bodyForItem = __vskHydrate && node.keyExpr ? keyedItemTemplate(node) : node.bodyTemplate;
30562
+ const bodyForItem = __vskHydrate && !__vskMarkerless && node.keyExpr ? keyedItemTemplate(node) : node.bodyTemplate;
30161
30563
  const hasAlternate = node.alternateNodes.length > 0;
30162
30564
  const arrVar = hasAlternate ? `__a${nextVskId()}` : null;
30163
30565
  if (hasAlternate) {
@@ -30338,8 +30740,11 @@ function componentCallToJS(node, importedNames, isAsync = false, tracked2) {
30338
30740
  const awaitKw = isAsync ? "await " : "";
30339
30741
  const calleeVar = `__cc${nextVskId()}`;
30340
30742
  lines.push(`const ${calleeVar} = ${callee};`);
30743
+ if (!node.calleeExpr) {
30744
+ lines.push(`if (${calleeVar} == null) throw new Error(${JSON.stringify(`Component "${compName}" was not found while rendering SSR HTML. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
30745
+ }
30341
30746
  const callExpr3 = `${awaitKw}${calleeVar}(${propsObj}, __registry, (${calleeVar}.__veskScope || __vesk))`;
30342
- if (__vskHydrate) {
30747
+ if (__vskHydrate && !__vskMarkerless) {
30343
30748
  lines.push(`__out.push(${JSON.stringify(componentMarker(compName))} + (${callExpr3} || ''));`);
30344
30749
  } else {
30345
30750
  lines.push(`__out.push(${callExpr3} || '');`);
@@ -30545,7 +30950,7 @@ function compileFileInternal(source, sourcePath2, seenImportFiles) {
30545
30950
  return { ir, componentMap, __vesk };
30546
30951
  }
30547
30952
  function render2(source, componentName, props = {}, registry = /* @__PURE__ */ new Map(), options = {}) {
30548
- resetVskState(!!options.hydrate);
30953
+ resetVskState(!!options.hydrate, options.markerless !== false);
30549
30954
  const compiled = compileFile(source, { sourcePath: options.sourcePath || void 0 });
30550
30955
  const componentMap = compiled.componentMap;
30551
30956
  const renderFn = componentMap.get(componentName);
@@ -30580,7 +30985,7 @@ function render2(source, componentName, props = {}, registry = /* @__PURE__ */ n
30580
30985
  return bodyHtml;
30581
30986
  }
30582
30987
  function renderPage(source, componentName, props = {}, registry = /* @__PURE__ */ new Map(), options = {}) {
30583
- resetVskState(!!options.hydrate);
30988
+ resetVskState(!!options.hydrate, options.markerless !== false);
30584
30989
  let __vesk, componentMap, ir;
30585
30990
  if (options.cached) {
30586
30991
  const cached = options.cached;
@@ -30729,10 +31134,10 @@ async function ssg(source, componentName, customProps, options = {}) {
30729
31134
  if (c.style) return true;
30730
31135
  return !isStatic(c.body);
30731
31136
  });
30732
- const rendered = await renderPage(source, componentName, props, options.registry || /* @__PURE__ */ new Map(), { hydrate: needsClient });
31137
+ const rendered = await renderPage(source, componentName, props, options.registry || /* @__PURE__ */ new Map(), { hydrate: needsClient, markerless: options.markerless !== false });
30733
31138
  const bodyHtml = rendered.body;
30734
31139
  const headHtml = rendered.head;
30735
- const clientCode = needsClient ? compileClient(source, null, { hydrate: true }) : "";
31140
+ const clientCode = needsClient ? compileClient(source, null, { hydrate: true, markerless: options.markerless !== false }) : "";
30736
31141
  const serializedProps = safeJsonForScript(JSON.stringify(props));
30737
31142
  const hasClient = clientCode.length > 0;
30738
31143
  const scriptBlock = hasClient ? `
@@ -30908,7 +31313,7 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
30908
31313
  const fullRegistry = new Map([...registry, ...componentMap]);
30909
31314
  const renderFn = componentMap.get(componentName);
30910
31315
  if (!renderFn) throw new Error(`Component "${componentName}" not found in source`);
30911
- resetVskState(!!options.hydrate);
31316
+ resetVskState(!!options.hydrate, options.markerless !== false);
30912
31317
  const targetComp = ir.components.find((c) => c.name === componentName);
30913
31318
  const cssUrls = options.cssUrls || (options.cssUrl ? [options.cssUrl] : []);
30914
31319
  const cssLink = cssUrls.map((u) => ` <link rel="stylesheet" href="${u}" />
@@ -31070,7 +31475,7 @@ import {
31070
31475
  readFileSync as readFileSync16,
31071
31476
  writeFileSync as writeFileSync7,
31072
31477
  existsSync as existsSync16,
31073
- mkdirSync as mkdirSync5,
31478
+ mkdirSync as mkdirSync6,
31074
31479
  statSync as statSync7
31075
31480
  } from "node:fs";
31076
31481
  import { resolve as resolve14, dirname as dirname11, join as join10, extname as extname4, basename } from "node:path";
@@ -31108,7 +31513,7 @@ function readPluginState(veskDir) {
31108
31513
  function writePluginState(veskDir, state) {
31109
31514
  const file = stateFilePath(veskDir);
31110
31515
  const dir = dirname11(file);
31111
- if (!existsSync16(dir)) mkdirSync5(dir, { recursive: true });
31516
+ if (!existsSync16(dir)) mkdirSync6(dir, { recursive: true });
31112
31517
  writeFileSync7(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
31113
31518
  }
31114
31519
  function resolvePackage(appDir, pkg) {
@@ -31987,15 +32392,15 @@ __export(static_exports, {
31987
32392
  generateSitemap: () => generateSitemap,
31988
32393
  generateSsgRoutes: () => generateSsgRoutes
31989
32394
  });
31990
- import { mkdirSync as mkdirSync6, copyFileSync as copyFileSync2, readdirSync as readdirSync3, statSync as statSync8, existsSync as existsSync17, writeFileSync as writeFileSync8, readFileSync as readFileSync17 } from "node:fs";
32395
+ import { mkdirSync as mkdirSync7, copyFileSync as copyFileSync2, readdirSync as readdirSync3, statSync as statSync8, existsSync as existsSync17, writeFileSync as writeFileSync8, readFileSync as readFileSync17 } from "node:fs";
31991
32396
  import { resolve as resolve15, join as join11 } from "node:path";
31992
32397
  function copyStaticAssets2(publicDir, outDir) {
31993
32398
  const targetDir = resolve15(outDir, "static", "public");
31994
- mkdirSync6(targetDir, { recursive: true });
32399
+ mkdirSync7(targetDir, { recursive: true });
31995
32400
  if (!existsSync17(publicDir))
31996
32401
  return;
31997
32402
  function copyDir(src2, dest) {
31998
- mkdirSync6(dest, { recursive: true });
32403
+ mkdirSync7(dest, { recursive: true });
31999
32404
  const entries = readdirSync3(src2);
32000
32405
  for (const entry of entries) {
32001
32406
  const srcPath = join11(src2, entry);
@@ -32013,7 +32418,7 @@ function copyStaticAssets2(publicDir, outDir) {
32013
32418
  async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra, cssUrls) {
32014
32419
  const { ssg: ssg2 } = await Promise.resolve().then(() => (init_server_render(), server_render_exports));
32015
32420
  const prerenderDir = resolve15(outDir, "prerendered");
32016
- mkdirSync6(prerenderDir, { recursive: true });
32421
+ mkdirSync7(prerenderDir, { recursive: true });
32017
32422
  const ssgOptions = { plugins, headExtra, cssUrls };
32018
32423
  const results = [];
32019
32424
  async function evaluateExport(src2, exportName) {
@@ -32050,7 +32455,7 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
32050
32455
  console.error(`vesk: SSG path escaped output dir \u2014 skipping ${pagePath} (path: ${urlPath})`);
32051
32456
  continue;
32052
32457
  }
32053
- mkdirSync6(resolve15(htmlPath, ".."), { recursive: true });
32458
+ mkdirSync7(resolve15(htmlPath, ".."), { recursive: true });
32054
32459
  writeFileSync8(htmlPath, result.html);
32055
32460
  results.push({ path: urlPath, html: htmlPath, static: result.static, params });
32056
32461
  } catch (e) {
@@ -32063,7 +32468,7 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
32063
32468
  try {
32064
32469
  const result = await ssg2(src2, null, void 0, ssgOptions);
32065
32470
  const htmlPath = resolve15(prerenderDir, node.fullPath === "/" ? "index.html" : `${node.fullPath.slice(1)}.html`);
32066
- mkdirSync6(resolve15(htmlPath, ".."), { recursive: true });
32471
+ mkdirSync7(resolve15(htmlPath, ".."), { recursive: true });
32067
32472
  writeFileSync8(htmlPath, result.html);
32068
32473
  results.push({ path: node.fullPath, html: htmlPath, static: result.static });
32069
32474
  } catch (e) {
@@ -32133,7 +32538,7 @@ var image_pipeline_exports = {};
32133
32538
  __export(image_pipeline_exports, {
32134
32539
  optimizeImages: () => optimizeImages
32135
32540
  });
32136
- import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
32541
+ import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
32137
32542
  import { resolve as resolve16, extname as extname5, dirname as dirname12 } from "node:path";
32138
32543
  async function processImage(srcPath, outDir, baseName) {
32139
32544
  const image = sharpFn ? sharpFn(srcPath) : null;
@@ -32141,7 +32546,7 @@ async function processImage(srcPath, outDir, baseName) {
32141
32546
  const original = readFileSync18(srcPath);
32142
32547
  for (const w of OUTPUT_WIDTHS) {
32143
32548
  const outputPath = resolve16(outDir, `${baseName}-${w}w`);
32144
- mkdirSync7(dirname12(outputPath), { recursive: true });
32549
+ mkdirSync8(dirname12(outputPath), { recursive: true });
32145
32550
  writeFileSync9(outputPath, original);
32146
32551
  }
32147
32552
  return [];
@@ -32155,7 +32560,7 @@ async function processImage(srcPath, outDir, baseName) {
32155
32560
  const resized = image.clone().resize({ width: w, withoutEnlargement: true });
32156
32561
  const base = `${baseName}-${w}w`;
32157
32562
  const jpgPath = resolve16(outDir, `${base}${extname5(srcPath)}`);
32158
- mkdirSync7(dirname12(jpgPath), { recursive: true });
32563
+ mkdirSync8(dirname12(jpgPath), { recursive: true });
32159
32564
  await resized.toFile(jpgPath);
32160
32565
  generated.push(jpgPath);
32161
32566
  for (const fmt of FORMATS) {
@@ -32197,7 +32602,7 @@ function collectImageRefs(appDir) {
32197
32602
  }
32198
32603
  async function optimizeImages(appDir, outDir) {
32199
32604
  const imageOutDir = resolve16(outDir, "static", "images");
32200
- mkdirSync7(imageOutDir, { recursive: true });
32605
+ mkdirSync8(imageOutDir, { recursive: true });
32201
32606
  const refs = collectImageRefs(appDir);
32202
32607
  if (refs.length === 0) {
32203
32608
  console.error("vesk images: no <Image> refs found");
@@ -32538,6 +32943,30 @@ ${prerenderedList}
32538
32943
  ${isrCache}
32539
32944
  const __routes = [${routeEntries.join(",\n")}];
32540
32945
 
32946
+ async function __invokeRoute(route, request) {
32947
+ try {
32948
+ return await route.handler(request);
32949
+ } catch (e) {
32950
+ if (e && typeof e === 'object' && e.name === 'Redirect') {
32951
+ return new Response(null, {
32952
+ status: Number(e.status) || 302,
32953
+ headers: { Location: String(e.url || '/') },
32954
+ });
32955
+ }
32956
+ if (e && typeof e === 'object' && e.name === 'NotFoundError') {
32957
+ return new Response('<!DOCTYPE html><html><body><h1>404</h1><p>Not Found</p></body></html>', {
32958
+ status: 404,
32959
+ headers: { 'Content-Type': 'text/html' },
32960
+ });
32961
+ }
32962
+ throw e;
32963
+ }
32964
+ }
32965
+
32966
+ function __escapeScript(json) {
32967
+ return json.split('<').join('\\u003c').split('\\u2028').join('\\u2028').split('\\u2029').join('\\u2029');
32968
+ }
32969
+
32541
32970
  function __matchPath(pattern, pathname) {
32542
32971
  const patternParts = pattern.split('/').filter(Boolean);
32543
32972
  const pathParts = pathname.split('/').filter(Boolean);
@@ -32568,6 +32997,24 @@ ${serverStoreLine}
32568
32997
  return new Response(null, { status: 308, headers: { Location: '/_vesk/static/public' + (pathname.endsWith('/') ? pathname + 'index.html' : pathname + '.html') } });
32569
32998
  }
32570
32999
 
33000
+ // Serve the SSR-data handoff the page references (script tag /ssr-data.js?t=...).
33001
+ // The render stashed the payload in the shared global store \u2014 mirror the node
33002
+ // prod/dev servers so edge/serverless hydration never re-fetches resources that
33003
+ // SSR already resolved. Entry is consumed on read (bound store).
33004
+ if (pathname === '/ssr-data.js') {
33005
+ const dataToken = url.searchParams.get('t') || '';
33006
+ const dataStore = (globalThis.__vsk_ssr_data_store || {});
33007
+ const payload = dataStore[dataToken];
33008
+ if (payload) delete dataStore[dataToken];
33009
+ const dataLines = [];
33010
+ if (payload && payload.props) dataLines.push('globalThis.__vesk_props = ' + __escapeScript(JSON.stringify(payload.props)) + ';');
33011
+ if (payload && payload.ssrData) dataLines.push('globalThis.__vsk_ssr_data = ' + __escapeScript(JSON.stringify(payload.ssrData)) + ';');
33012
+ return new Response(dataLines.join('\\n') || '// no ssr data', {
33013
+ status: 200,
33014
+ headers: { 'Content-Type': 'application/javascript', 'Cache-Control': 'no-store' },
33015
+ });
33016
+ }
33017
+
32571
33018
  ${eventsStartLine}
32572
33019
  let mwCtx = { params: {}, url, locals: ${localsSeed}, cookies: {}, request, resolveUrl(u) { return new URL(u, request.url).href; }, set() {}, get() { return undefined; } };
32573
33020
  if (${hasMwLiteral}) {
@@ -32597,7 +33044,7 @@ ${eventsRequestLine}
32597
33044
  if (!params) continue;
32598
33045
 
32599
33046
  if (route.type === 'api') {
32600
- return await route.handler(request);
33047
+ return await __invokeRoute(route, request);
32601
33048
  }
32602
33049
 
32603
33050
  if (route.revalidate && route.revalidate > 0 && !isDataRequest) {
@@ -32610,7 +33057,7 @@ ${eventsRequestLine}
32610
33057
  }
32611
33058
  }
32612
33059
 
32613
- const response = await route.handler(request);
33060
+ const response = await __invokeRoute(route, request);
32614
33061
 
32615
33062
  if (route.revalidate && route.revalidate > 0 && !isDataRequest) {
32616
33063
  const html = await response.clone().text();
@@ -32721,7 +33168,7 @@ var init_platform_handler = __esm({
32721
33168
 
32722
33169
  // ../adapter/src/platform-output.ts
32723
33170
  import {
32724
- mkdirSync as mkdirSync8,
33171
+ mkdirSync as mkdirSync9,
32725
33172
  copyFileSync as copyFileSync3,
32726
33173
  readdirSync as readdirSync6,
32727
33174
  statSync as statSync11,
@@ -32733,28 +33180,28 @@ import {
32733
33180
  import { resolve as resolve19, join as join13, extname as extname6, dirname as dirname14 } from "node:path";
32734
33181
  function ensureCleanDir(dir) {
32735
33182
  rmSync2(dir, { recursive: true, force: true });
32736
- mkdirSync8(dir, { recursive: true });
33183
+ mkdirSync9(dir, { recursive: true });
32737
33184
  }
32738
33185
  function copyDirContents(srcDir, destDir) {
32739
33186
  if (!existsSync21(srcDir)) return;
32740
- mkdirSync8(destDir, { recursive: true });
33187
+ mkdirSync9(destDir, { recursive: true });
32741
33188
  for (const entry of readdirSync6(srcDir)) {
32742
33189
  const srcPath = join13(srcDir, entry);
32743
33190
  const destPath = join13(destDir, entry);
32744
33191
  if (statSync11(srcPath).isDirectory()) {
32745
33192
  copyDirContents(srcPath, destPath);
32746
33193
  } else {
32747
- mkdirSync8(dirname14(destPath), { recursive: true });
33194
+ mkdirSync9(dirname14(destPath), { recursive: true });
32748
33195
  copyFileSync3(srcPath, destPath);
32749
33196
  }
32750
33197
  }
32751
33198
  }
32752
33199
  function writeFile(path, content) {
32753
- mkdirSync8(dirname14(path), { recursive: true });
33200
+ mkdirSync9(dirname14(path), { recursive: true });
32754
33201
  writeFileSync10(path, content, "utf-8");
32755
33202
  }
32756
33203
  function writePlatformStatic(buildStaticDir, platformStaticDir) {
32757
- mkdirSync8(platformStaticDir, { recursive: true });
33204
+ mkdirSync9(platformStaticDir, { recursive: true });
32758
33205
  const publicDir = resolve19(buildStaticDir, "public");
32759
33206
  if (existsSync21(publicDir)) {
32760
33207
  copyDirContents(publicDir, platformStaticDir);
@@ -32764,7 +33211,7 @@ function writePlatformStatic(buildStaticDir, platformStaticDir) {
32764
33211
  const runtimeAlias = resolve19(platformStaticDir, "_vesk", "runtime.js");
32765
33212
  const clientPath = resolve19(buildStaticDir, "client.js");
32766
33213
  if (existsSync21(clientPath)) {
32767
- mkdirSync8(dirname14(runtimeAlias), { recursive: true });
33214
+ mkdirSync9(dirname14(runtimeAlias), { recursive: true });
32768
33215
  copyFileSync3(clientPath, runtimeAlias);
32769
33216
  }
32770
33217
  }
@@ -32838,7 +33285,7 @@ var platform_deploy_exports = {};
32838
33285
  __export(platform_deploy_exports, {
32839
33286
  emitPlatformOutput: () => emitPlatformOutput
32840
33287
  });
32841
- import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync9, rmSync as rmSync3, cpSync } from "node:fs";
33288
+ import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync10, rmSync as rmSync3, cpSync } from "node:fs";
32842
33289
  import { resolve as resolve20 } from "node:path";
32843
33290
  async function emitPlatformOutput(platform, ctx2) {
32844
33291
  if (platform === "node") return null;
@@ -32877,7 +33324,7 @@ ${shell.bootstrap}
32877
33324
  let handlerRel;
32878
33325
  if (shell.functionFile) {
32879
33326
  const funcDir = resolve20(outRoot, shell.functionFile.dir);
32880
- mkdirSync9(funcDir, { recursive: true });
33327
+ mkdirSync10(funcDir, { recursive: true });
32881
33328
  if (shell.functionConfig) {
32882
33329
  writeFileSync11(resolve20(funcDir, ".vc-config.json"), JSON.stringify(shell.functionConfig, null, 2), "utf-8");
32883
33330
  writeFileSync11(resolve20(funcDir, "package.json"), JSON.stringify({ type: "module" }, null, 2) + "\n", "utf-8");
@@ -38158,7 +38605,7 @@ declare module '@vesk/runtime' {
38158
38605
  });
38159
38606
 
38160
38607
  // src/index.ts
38161
- import { readFileSync as readFileSync40, writeFileSync as writeFileSync21, mkdirSync as mkdirSync18, existsSync as existsSync43 } from "fs";
38608
+ import { readFileSync as readFileSync40, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, existsSync as existsSync43 } from "fs";
38162
38609
  import { resolve as resolve40, join as join26 } from "path";
38163
38610
  import { fileURLToPath as fileURLToPath9 } from "url";
38164
38611
 
@@ -38728,7 +39175,7 @@ function setRuntimeModule2(mod) {
38728
39175
  }
38729
39176
 
38730
39177
  // ../adapter/dist/index.js
38731
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as readFileSync21 } from "node:fs";
39178
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as readFileSync21 } from "node:fs";
38732
39179
  import { resolve as resolve21, dirname as dirname16, relative as relative4, basename as basename2 } from "node:path";
38733
39180
  import { fileURLToPath as fileURLToPath5 } from "node:url";
38734
39181
 
@@ -39013,6 +39460,8 @@ import { readFileSync as readFileSync6, existsSync as existsSync7 } from "node:f
39013
39460
  import { resolve as resolve6 } from "node:path";
39014
39461
  var GLOBAL_CSS_URL = "/_vesk/static/global.css";
39015
39462
  function resolveUserCssPath(appDir) {
39463
+ const appCssSrc = resolve6(appDir, "global.css");
39464
+ if (existsSync7(appCssSrc)) return appCssSrc;
39016
39465
  const cssSrc = resolve6(appDir, "..", "src", "global.css");
39017
39466
  if (existsSync7(cssSrc)) return cssSrc;
39018
39467
  const altCssSrc = resolve6(appDir, "..", "src", "app.css");
@@ -39167,7 +39616,7 @@ ${layoutDecls.map((d) => " " + d.compiled + ",").join("\n")}
39167
39616
  const plan = precompilePlan(compPath);
39168
39617
  compRegEntries.push(` (() => {
39169
39618
  const _compiled = (() => { try { return hydratePrecompile(${plan}); } catch { return null; } })();
39170
- registry.set(${JSON.stringify(compName)}, async (props, __registry, __vesk) => {
39619
+ __componentRegistry.set(${JSON.stringify(compName)}, async (props, __registry, __vesk) => {
39171
39620
  const result = await renderPage('', ${JSON.stringify(compName)}, props, __registry, { hydrate: true, cached: _compiled });
39172
39621
  return result.body;
39173
39622
  });
@@ -39962,9 +40411,10 @@ init_esbuild_fallback();
39962
40411
  init_strip_ts();
39963
40412
  init_parser();
39964
40413
  init_client_codegen();
39965
- import { readFileSync as readFileSync11, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync3, rmSync, mkdtempSync } from "node:fs";
40414
+ import { readFileSync as readFileSync11, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync3, rmSync, mkdtempSync, mkdirSync as mkdirSync3 } from "node:fs";
39966
40415
  import { resolve as resolve10, join as join7, dirname as dirname8, relative as relative2, sep } from "node:path";
39967
40416
  import { fileURLToPath as fileURLToPath2 } from "node:url";
40417
+ import { tmpdir } from "node:os";
39968
40418
  init_vsk_imports();
39969
40419
  init_md_inline();
39970
40420
  init_module_imports();
@@ -40714,7 +41164,19 @@ function runtimeExportNames(runtimeDir) {
40714
41164
  return names;
40715
41165
  }
40716
41166
  var RUNTIME_ENTRY = ".runtime-tree-entry.mjs";
40717
- async function buildTreeShakenRuntime(runtimeDir, usedNames) {
41167
+ function esbuildPath(p) {
41168
+ return sep === "/" ? p : p.split(sep).join("/");
41169
+ }
41170
+ function runtimeTreeShakeEntry() {
41171
+ return join7(tmpdir(), "vesk-runtime-tree-shake", RUNTIME_ENTRY);
41172
+ }
41173
+ var treeShakeQueue = Promise.resolve();
41174
+ function buildTreeShakenRuntime(runtimeDir, usedNames) {
41175
+ const run = treeShakeQueue.then(() => buildTreeShakenRuntimeNow(runtimeDir, usedNames));
41176
+ treeShakeQueue = run.catch(() => void 0);
41177
+ return run;
41178
+ }
41179
+ async function buildTreeShakenRuntimeNow(runtimeDir, usedNames) {
40718
41180
  const unique = [...new Set(usedNames)];
40719
41181
  const available = runtimeExportNames(runtimeDir);
40720
41182
  const missing = unique.filter((n) => !available.has(n));
@@ -40722,16 +41184,21 @@ async function buildTreeShakenRuntime(runtimeDir, usedNames) {
40722
41184
  console.error(`vesk: runtime names not exported \u2014 ${missing.join(", ")}; falling back to full runtime`);
40723
41185
  return buildRuntimeCode(runtimeDir);
40724
41186
  }
40725
- const entry = join7(runtimeDir, RUNTIME_ENTRY);
41187
+ const entry = runtimeTreeShakeEntry();
41188
+ const indexClient = esbuildPath(join7(runtimeDir, "index-client.js"));
40726
41189
  try {
41190
+ try {
41191
+ mkdirSync3(dirname8(entry), { recursive: true });
41192
+ } catch {
41193
+ }
40727
41194
  try {
40728
41195
  rmSync(entry);
40729
41196
  } catch {
40730
41197
  }
40731
- writeFileSync4(entry, `export { ${unique.join(", ")} } from './index-client.js';
41198
+ writeFileSync4(entry, `export { ${unique.join(", ")} } from ${JSON.stringify(indexClient)};
40732
41199
  `);
40733
41200
  const result = await build({
40734
- entryPoints: [entry],
41201
+ entryPoints: [esbuildPath(entry)],
40735
41202
  bundle: true,
40736
41203
  format: "iife",
40737
41204
  globalName: "__veskRuntime",
@@ -40788,7 +41255,7 @@ async function buildMainBundle(routeTree, runtimeDir, codeSplit, mono, hmr, impo
40788
41255
 
40789
41256
  ` : runtimeCode + "\n";
40790
41257
  const cleanupFn = "function __cleanup(start, end) {\n let n = start.nextSibling;\n while (n && n !== end) {\n const next = n.nextSibling;\n n.remove();\n n = next;\n }\n}\n";
40791
- const placeFn = "function __place(start, end, nodes, fallback) {\n if (start.parentNode !== null) {\n const p = start.parentNode;\n for (let i = 0; i < nodes.length; i++) p.insertBefore(nodes[i], end);\n return;\n }\n if (nodes.length > 0 && nodes[0].parentNode) {\n const p = nodes[0].parentNode;\n p.insertBefore(start, nodes[0]);\n p.insertBefore(end, nodes[nodes.length - 1].nextSibling);\n return;\n }\n fallback.appendChild(start);\n fallback.appendChild(end);\n for (let i = 0; i < nodes.length; i++) fallback.insertBefore(nodes[i], end);\n}\n";
41258
+ const placeFn = "function __place(start, end, nodes, fallback) {\n if (start.parentNode !== null) {\n const p = start.parentNode;\n for (let i = 0; i < nodes.length; i++) p.insertBefore(nodes[i], end);\n return;\n }\n if (nodes.length > 0 && nodes[0].parentNode) {\n const p = nodes[0].parentNode;\n p.insertBefore(start, nodes[0]);\n p.insertBefore(end, nodes[nodes.length - 1].nextSibling);\n // Client-surplus nodes (SSR rendered fewer items than the client data)\n // are freshly claimed and still detached \u2014 move them into the region in\n // client order before `end`, instead of stranding them off-parent.\n for (let i = 0; i < nodes.length; i++) {\n if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);\n }\n return;\n }\n fallback.appendChild(start);\n fallback.appendChild(end);\n for (let i = 0; i < nodes.length; i++) fallback.insertBefore(nodes[i], end);\n}\n";
40792
41259
  const updateComponentsFn = "function __updateComponents(nodes) {\n for (const n of nodes) {\n if (n._pageName && __components[n._pageName]) n.page = __components[n._pageName];\n if (n._layoutName && __components[n._layoutName]) n.layout = __components[n._layoutName];\n if (n._errorName && __components[n._errorName]) n.error = __components[n._errorName];\n if (n._notFoundName && __components[n._notFoundName]) n.notFound = __components[n._notFoundName];\n if (n._offlineName && __components[n._offlineName]) n.offline = __components[n._offlineName];\n if (n._networkName && __components[n._networkName]) n.network = __components[n._networkName];\n if (n.children) __updateComponents(n.children);\n }\n}\n";
40793
41260
  const routeTreeJson = JSON.stringify(routeTree);
40794
41261
  if (codeSplit) {
@@ -40907,14 +41374,14 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
40907
41374
 
40908
41375
  // ../adapter/src/static.ts
40909
41376
  init_paths();
40910
- import { mkdirSync as mkdirSync3, copyFileSync, readdirSync as readdirSync2, statSync as statSync5, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync13 } from "node:fs";
41377
+ import { mkdirSync as mkdirSync4, copyFileSync, readdirSync as readdirSync2, statSync as statSync5, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync13 } from "node:fs";
40911
41378
  import { resolve as resolve12, join as join8 } from "node:path";
40912
41379
  function copyStaticAssets(publicDir, outDir) {
40913
41380
  const targetDir = resolve12(outDir, "static", "public");
40914
- mkdirSync3(targetDir, { recursive: true });
41381
+ mkdirSync4(targetDir, { recursive: true });
40915
41382
  if (!existsSync13(publicDir)) return;
40916
41383
  function copyDir(src2, dest) {
40917
- mkdirSync3(dest, { recursive: true });
41384
+ mkdirSync4(dest, { recursive: true });
40918
41385
  const entries = readdirSync2(src2);
40919
41386
  for (const entry of entries) {
40920
41387
  const srcPath = join8(src2, entry);
@@ -40939,7 +41406,7 @@ init_server_utils();
40939
41406
  init_paths();
40940
41407
 
40941
41408
  // ../adapter/src/load-config.ts
40942
- import { existsSync as existsSync14, readFileSync as readFileSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync4 } from "node:fs";
41409
+ import { existsSync as existsSync14, readFileSync as readFileSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5 } from "node:fs";
40943
41410
  import { join as join9, dirname as dirname9 } from "node:path";
40944
41411
  import { pathToFileURL as pathToFileURL2 } from "node:url";
40945
41412
  import { createRequire as createRequire3 } from "node:module";
@@ -40984,7 +41451,7 @@ async function loadVeskConfig2(projectDir) {
40984
41451
  js = `const {${injectKeys.join(",")}} = globalThis.__vesk_inject;
40985
41452
  ` + js;
40986
41453
  const tmpFile = join9(projectDir, ".vesk", "config.loader.tmp.mjs");
40987
- mkdirSync4(dirname9(tmpFile), { recursive: true });
41454
+ mkdirSync5(dirname9(tmpFile), { recursive: true });
40988
41455
  writeFileSync6(tmpFile, js, "utf-8");
40989
41456
  globalThis.__vesk_inject = inject;
40990
41457
  try {
@@ -41437,6 +41904,12 @@ async function startProdServer(outDir, options) {
41437
41904
  return;
41438
41905
  } catch (e) {
41439
41906
  const err = e instanceof Error ? e : new Error(String(e));
41907
+ if (err.name === "Redirect") {
41908
+ const redirect2 = err;
41909
+ res.writeHead(Number(redirect2.status) || 302, { Location: typeof redirect2.url === "string" ? redirect2.url : "/" });
41910
+ res.end();
41911
+ return;
41912
+ }
41440
41913
  if (err.name === "NotFoundError") {
41441
41914
  res.writeHead(404, { "Content-Type": "text/html" });
41442
41915
  res.end(notFoundHtml || "<!DOCTYPE html><html><body><h1>404</h1><p>Not Found</p></body></html>");
@@ -41601,7 +42074,7 @@ async function build2(appDir, options) {
41601
42074
  resolve21(outDir, "prerendered")
41602
42075
  ];
41603
42076
  for (const d of dirs)
41604
- mkdirSync10(d, { recursive: true });
42077
+ mkdirSync11(d, { recursive: true });
41605
42078
  const cssSourcePath = resolveUserCssPath(appDir);
41606
42079
  if (cssSourcePath !== null) {
41607
42080
  const cssContent = readFileSync21(cssSourcePath, "utf-8");
@@ -42218,6 +42691,8 @@ function transformTracked2(irNode, tracked2) {
42218
42691
  return context.next();
42219
42692
  if (parent.type === "UpdateExpression" && parent.argument === node)
42220
42693
  return context.next();
42694
+ if (parent.type === "MemberExpression" && !parent.computed && parent.property === node)
42695
+ return context.next();
42221
42696
  if (parent.type === "Property" && parent.value === node && parent.key && parent.key.type === "Identifier" && parent.key.name === "into")
42222
42697
  return context.next();
42223
42698
  if (parent.type === "MemberExpression" && !parent.computed && parent.object === node && parent.property && parent.property.type === "Identifier" && parent.property.name === "set")
@@ -42321,6 +42796,12 @@ var Ctx2 = class {
42321
42796
  delegatedEvents = /* @__PURE__ */ new Set();
42322
42797
  directEvents = /* @__PURE__ */ new Set();
42323
42798
  hydrate = false;
42799
+ // Markerless structural hydration: claims run `nextElement(tag, skipK)` with
42800
+ // positional residue offsets and interior claims rebind the walker to the
42801
+ // claimed element (subWalker). Only meaningful when `hydrate` is also true.
42802
+ // Markerless is the DEFAULT; pass `markerless: false` to restore legacy
42803
+ // marker-mode claim emission.
42804
+ markerless = true;
42324
42805
  inTryBody = false;
42325
42806
  claimStatic = false;
42326
42807
  // While set, the next StaticNode claimed in hydrate mode uses `__root` (the
@@ -42370,9 +42851,9 @@ var Ctx2 = class {
42370
42851
  return "\n" + lines.join("\n");
42371
42852
  }
42372
42853
  };
42373
- function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
42854
+ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
42374
42855
  if (node instanceof StaticNode)
42375
- return emitStatic2(ctx2, node, tracked2, effectsVar);
42856
+ return emitStatic2(ctx2, node, tracked2, effectsVar, skipK, regionBudget);
42376
42857
  if (node instanceof TextNode) {
42377
42858
  if (!node.value)
42378
42859
  return null;
@@ -42391,11 +42872,11 @@ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__
42391
42872
  if (node instanceof ComponentRef)
42392
42873
  return null;
42393
42874
  if (node instanceof ComponentCall)
42394
- return emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix);
42875
+ return emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix, skipK, regionBudget);
42395
42876
  if (node instanceof OpaqueDynamicRegion)
42396
- return emitOpaque2(ctx2, node, tracked2, effectsVar, parentVar);
42877
+ return emitOpaque2(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
42397
42878
  if (node instanceof MapRegion)
42398
- return emitMap2(ctx2, node, tracked2, effectsVar, parentVar);
42879
+ return emitMap2(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
42399
42880
  if (node instanceof ServerBlock)
42400
42881
  return null;
42401
42882
  if (node instanceof ClientBlock) {
@@ -42435,13 +42916,13 @@ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__
42435
42916
  return null;
42436
42917
  }
42437
42918
  if (node instanceof TryCatch)
42438
- return emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar);
42919
+ return emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
42439
42920
  if (node instanceof WhileLoop)
42440
- return emitWhileLoop2(ctx2, node, tracked2, parentVar);
42921
+ return emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK, regionBudget);
42441
42922
  if (node instanceof ForLoop)
42442
- return emitForLoop2(ctx2, node, tracked2, parentVar);
42923
+ return emitForLoop2(ctx2, node, tracked2, parentVar, skipK, regionBudget);
42443
42924
  if (node instanceof SwitchBlock)
42444
- return emitSwitchBlock2(ctx2, node, tracked2, parentVar);
42925
+ return emitSwitchBlock2(ctx2, node, tracked2, parentVar, skipK, regionBudget);
42445
42926
  if (node instanceof PropSlot)
42446
42927
  return null;
42447
42928
  if (node instanceof PropSlotRender) {
@@ -42476,7 +42957,7 @@ var PROPERTY_ATTRS2 = {
42476
42957
  option: /* @__PURE__ */ new Set(["selected"]),
42477
42958
  progress: /* @__PURE__ */ new Set(["value"])
42478
42959
  };
42479
- function emitStatic2(ctx2, node, tracked2, effectsVar) {
42960
+ function emitStatic2(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
42480
42961
  const el = ctx2.n();
42481
42962
  if (ctx2.hydrate) {
42482
42963
  const claim = ctx2.claimStatic;
@@ -42485,8 +42966,12 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42485
42966
  return null;
42486
42967
  const rootClaim = ctx2.rootClaim;
42487
42968
  ctx2.rootClaim = false;
42488
- const claimedExpr = rootClaim ? `__root || ${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})`;
42969
+ const skipExpr = regionBudget && ctx2.markerless ? markerlessSkipExpr2(regionBudget, skipK) : skipK;
42970
+ const skipArg = ctx2.markerless ? `, ${skipExpr}` : "";
42971
+ const claimedExpr = rootClaim ? `__root || document.createElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)}${skipArg})`;
42489
42972
  ctx2.push(`const ${el} = ${claimedExpr};`);
42973
+ if (regionBudget && ctx2.markerless)
42974
+ ctx2.push(`${regionBudget} = 0;`);
42490
42975
  } else {
42491
42976
  ctx2.push(`const ${el} = document.createElement(${JSON.stringify(node.tag)});`);
42492
42977
  }
@@ -42519,7 +43004,41 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42519
43004
  const textKids = children.filter((c) => c instanceof TextNode || c instanceof DynamicBinding && c.kind === "text");
42520
43005
  singleReactiveText = textKids.length === 1 && textKids[0] instanceof DynamicBinding && isReactiveExpression2(textKids[0].expression, tracked2);
42521
43006
  }
43007
+ const savedWalker = ctx2.walker;
43008
+ let needsSubWalker = false;
43009
+ if (ctx2.hydrate && ctx2.markerless) {
43010
+ for (const child of children) {
43011
+ if (child instanceof TextNode)
43012
+ continue;
43013
+ if (child instanceof DynamicBinding && child.kind === "text")
43014
+ continue;
43015
+ if (child instanceof StaticNode && isStaticIR2(child.children))
43016
+ continue;
43017
+ if (child instanceof TrackDecl)
43018
+ continue;
43019
+ if (child instanceof ComponentRef)
43020
+ continue;
43021
+ if (child instanceof ServerBlock)
43022
+ continue;
43023
+ if (child instanceof ClientBlock)
43024
+ continue;
43025
+ if (child instanceof HeadBlock)
43026
+ continue;
43027
+ if (child instanceof RuntimeStatement)
43028
+ continue;
43029
+ if (child instanceof PropSlot)
43030
+ continue;
43031
+ needsSubWalker = true;
43032
+ break;
43033
+ }
43034
+ }
43035
+ if (needsSubWalker) {
43036
+ const sub = ctx2.n();
43037
+ ctx2.push(`const ${sub} = ${ctx2.walker}.subWalker(${el});`);
43038
+ ctx2.walker = sub;
43039
+ }
42522
43040
  let residueBefore = 0;
43041
+ let pendingSkip = 0;
42523
43042
  for (const child of children) {
42524
43043
  let childVar;
42525
43044
  const isPureStaticChild = ctx2.hydrate && child instanceof StaticNode && isStaticIR2(child.children);
@@ -42573,10 +43092,13 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42573
43092
  }
42574
43093
  }
42575
43094
  childVar = ssrEl;
43095
+ pendingSkip += ssrResidueEstimate2(child);
42576
43096
  } else if (singleReactiveText && child instanceof DynamicBinding && child.kind === "text") {
42577
43097
  childVar = emitDynamicBinding2(ctx2, child, tracked2, effectsVar, `${el}.__vsk_ssrText`);
42578
43098
  } else {
42579
- childVar = emitNode2(ctx2, child, tracked2, effectsVar, el);
43099
+ childVar = emitNode2(ctx2, child, tracked2, effectsVar, el, "__components", pendingSkip);
43100
+ if (claimsWalkerNode2(ctx2, child))
43101
+ pendingSkip = 0;
42580
43102
  }
42581
43103
  if (childVar) {
42582
43104
  if (ctx2.hydrate) {
@@ -42628,6 +43150,8 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42628
43150
  }
42629
43151
  }
42630
43152
  }
43153
+ if (ctx2.walker !== savedWalker)
43154
+ ctx2.walker = savedWalker;
42631
43155
  return el;
42632
43156
  }
42633
43157
  function emitClientHead2(ctx2, node, tracked2) {
@@ -42777,10 +43301,15 @@ function emitFragment2(ctx2, nodes, tracked2, effectsVar) {
42777
43301
  const savedEffects = ctx2.effects;
42778
43302
  ctx2.effects = [];
42779
43303
  ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
43304
+ let fragPendingSkip = 0;
42780
43305
  for (const child of nodes) {
42781
- const childVar = emitNode2(ctx2, child, tracked2, effectsVar, "$f");
43306
+ const childVar = emitNode2(ctx2, child, tracked2, effectsVar, "$f", "__components", fragPendingSkip);
42782
43307
  if (childVar)
42783
43308
  ctx2.push(`$f.appendChild(${childVar});`);
43309
+ if (claimsWalkerNode2(ctx2, child))
43310
+ fragPendingSkip = 0;
43311
+ else
43312
+ fragPendingSkip += ssrResidueEstimate2(child);
42784
43313
  }
42785
43314
  for (const eff of ctx2.effects)
42786
43315
  ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr2(eff)});` : eff);
@@ -42788,7 +43317,7 @@ function emitFragment2(ctx2, nodes, tracked2, effectsVar) {
42788
43317
  ctx2.push(`return $f; })();`);
42789
43318
  return frag;
42790
43319
  }
42791
- function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
43320
+ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
42792
43321
  const propsEntries = node.props.map((p) => {
42793
43322
  if (typeof p.value === "string")
42794
43323
  return `${JSON.stringify(p.name)}: ${JSON.stringify(p.value)}`;
@@ -42811,12 +43340,19 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42811
43340
  const callArgs = () => `{ ${propsEntries.join(", ")} }`;
42812
43341
  if (ctx2.hydrate) {
42813
43342
  const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `__components[${JSON.stringify(node.componentName)}]`);
43343
+ if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
43344
+ ctx2.push(`if (${access} == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
43345
+ }
42814
43346
  const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
42815
43347
  const walkerArg = ctx2.walker;
43348
+ const promptExpr = ctx2.markerless && (regionBudget || skipK > 0) ? markerlessSkipExpr2(regionBudget, skipK) : null;
42816
43349
  const maybeReplace = (v2) => {
42817
43350
  if (!plainTarget)
42818
43351
  return;
42819
- ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${walkerArg}.claimOnly(); if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
43352
+ const claim = promptExpr ? `${walkerArg}.claimOnly(undefined, ${promptExpr})` : `${walkerArg}.claimOnly()`;
43353
+ ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
43354
+ if (regionBudget && ctx2.markerless)
43355
+ ctx2.push(`${regionBudget} = 0;`);
42820
43356
  };
42821
43357
  const maybeRetire = () => {
42822
43358
  if (ctx2.selfClaimNames.has(node.componentName)) {
@@ -42848,9 +43384,14 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42848
43384
  ctx2.push(`return $f; })();`);
42849
43385
  propsEntries.push(`children: ${frag}`);
42850
43386
  }
43387
+ if (ctx2.markerless && promptExpr && !plainTarget) {
43388
+ ctx2.push(`${walkerArg}.injectSkipK(${promptExpr});`);
43389
+ }
42851
43390
  ctx2.push(`let ${v} = undefined;`);
42852
43391
  ctx2.push(`if (__hydrate) __hydrate.childFrame = (__hydrate.childFrame || 0) + 1;`);
42853
43392
  ctx2.push(`try { ${v} = ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}); } finally { if (__hydrate) __hydrate.childFrame--; }`);
43393
+ if (ctx2.markerless && promptExpr && !plainTarget && regionBudget)
43394
+ ctx2.push(`${regionBudget} = 0;`);
42854
43395
  maybeReplace(v);
42855
43396
  maybeRetire();
42856
43397
  return v;
@@ -42880,32 +43421,54 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42880
43421
  } else if (ctx2.importedNames.has(node.componentName)) {
42881
43422
  ctx2.push(`const ${v} = ${awaitKw}${node.componentName}(${callArgs()});`);
42882
43423
  } else {
43424
+ ctx2.push(`if (${compPrefix}[${JSON.stringify(node.componentName)}] == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
42883
43425
  ctx2.push(`const ${v} = ${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()});`);
42884
43426
  }
42885
43427
  }
42886
43428
  return v;
42887
43429
  }
42888
- function emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, rootLevel) {
43430
+ function emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, rootLevel, offsetExpr) {
42889
43431
  if (!ctx2.hydrate || !rootLevel)
42890
43432
  return;
42891
43433
  ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
42892
- ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
42893
- ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${anchor});`));
42894
- ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
43434
+ ctx2.push(`if (${ctx2.walker} && ${ctx2.walker}.insertBeforeNextClaim) {`);
43435
+ ctx2.push(indent3(`${ctx2.walker}.insertBeforeNextClaim(${anchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
43436
+ ctx2.push(indent3(`${ctx2.walker}.insertBeforeNextClaim(${endAnchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
42895
43437
  ctx2.push(`}`);
42896
43438
  }
42897
- function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
43439
+ function regionBudgetVar2(ctx2, skipK, regionBudget, inheritedInit) {
43440
+ if (!ctx2.markerless || !ctx2.hydrate)
43441
+ return null;
43442
+ if (skipK > 0) {
43443
+ const pk = ctx2.n();
43444
+ ctx2.push(`let ${pk} = ${skipK}; // first-claim budget: region SSR sits ${skipK} slot(s) past the walker cursor`);
43445
+ return pk;
43446
+ }
43447
+ if (inheritedInit) {
43448
+ const pk = ctx2.n();
43449
+ ctx2.push(`let ${pk} = ${inheritedInit}; // first-claim budget: inherited from the caller's walker residue`);
43450
+ return pk;
43451
+ }
43452
+ return regionBudget || null;
43453
+ }
43454
+ function markerlessSkipExpr2(regionBudget, skipK) {
43455
+ if (regionBudget)
43456
+ return skipK > 0 ? `${regionBudget} + ${skipK}` : regionBudget;
43457
+ return String(skipK);
43458
+ }
43459
+ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar, skipK = 0, regionBudget) {
42898
43460
  const anchor = ctx2.n();
42899
43461
  const endAnchor = ctx2.n();
42900
43462
  const effArr = ctx2.n();
42901
43463
  const catchParam = node.catchParamName || "__e";
42902
43464
  const parent = parentVar || "$root";
43465
+ const budget = ctx2.hydrate ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
42903
43466
  ctx2.push(`const ${anchor} = document.createComment('try');`);
42904
43467
  if (!ctx2.hydrate)
42905
43468
  ctx2.push(`${parent}.appendChild(${anchor});`);
42906
43469
  ctx2.push(`let ${effArr} = [];`);
42907
43470
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
42908
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43471
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
42909
43472
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
42910
43473
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
42911
43474
  const savedHydrate = ctx2.hydrate;
@@ -42923,7 +43486,7 @@ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42923
43486
  ctx2.push(indent3(`const __cl = [];`));
42924
43487
  }
42925
43488
  for (const child of body) {
42926
- const childVar = emitNode2(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix);
43489
+ const childVar = emitNode2(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix, 0, budget || void 0);
42927
43490
  if (childVar) {
42928
43491
  if (hydMode)
42929
43492
  ctx2.push(indent3(`__cl.push(${childVar});`));
@@ -42973,9 +43536,10 @@ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42973
43536
  }`);
42974
43537
  return null;
42975
43538
  }
42976
- function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43539
+ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
42977
43540
  const hyd = ctx2.hydrate;
42978
43541
  const parent = parentVar || "$root";
43542
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
42979
43543
  const isOpaque = (n) => !!n && typeof n.condition !== "undefined";
42980
43544
  if (hyd && node.alternateNodes.length === 1 && isOpaque(node.alternateNodes[0])) {
42981
43545
  const chain = [];
@@ -42996,7 +43560,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
42996
43560
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
42997
43561
  ctx2.push(`let ${effectsVar2} = [];`);
42998
43562
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
42999
- emitHydrateFenceAnchoring2(ctx2, anchor2, endAnchor2, parent === "$root");
43563
+ emitHydrateFenceAnchoring2(ctx2, anchor2, endAnchor2, parent === "$root", budget || void 0);
43000
43564
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
43001
43565
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
43002
43566
  const renderNames = [];
@@ -43010,7 +43574,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43010
43574
  const savedClaim = ctx2.claimStatic;
43011
43575
  if (hyd)
43012
43576
  ctx2.claimStatic = true;
43013
- const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
43577
+ const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
43014
43578
  ctx2.claimStatic = savedClaim;
43015
43579
  if (v)
43016
43580
  ctx2.push(indent3(`${cl}.push(${v});`));
@@ -43028,7 +43592,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43028
43592
  const savedClaim = ctx2.claimStatic;
43029
43593
  if (hyd)
43030
43594
  ctx2.claimStatic = true;
43031
- const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
43595
+ const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
43032
43596
  ctx2.claimStatic = savedClaim;
43033
43597
  if (v)
43034
43598
  ctx2.push(indent3(`${cl2}.push(${v});`));
@@ -43088,7 +43652,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43088
43652
  ctx2.push(`${parent}.appendChild(${anchor});`);
43089
43653
  ctx2.push(`let ${effectsVar} = [];`);
43090
43654
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
43091
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43655
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43092
43656
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
43093
43657
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
43094
43658
  const conRenderName = ctx2.n();
@@ -43104,7 +43668,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43104
43668
  const savedClaim = ctx2.claimStatic;
43105
43669
  if (hyd)
43106
43670
  ctx2.claimStatic = true;
43107
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
43671
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag, "__components", 0, budget || void 0);
43108
43672
  ctx2.claimStatic = savedClaim;
43109
43673
  if (v) {
43110
43674
  if (hyd)
@@ -43133,7 +43697,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43133
43697
  const savedAltClaim = ctx2.claimStatic;
43134
43698
  if (hyd)
43135
43699
  ctx2.claimStatic = true;
43136
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
43700
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag, "__components", 0, budget || void 0);
43137
43701
  ctx2.claimStatic = savedAltClaim;
43138
43702
  if (v) {
43139
43703
  if (hyd)
@@ -43180,19 +43744,20 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43180
43744
  }
43181
43745
  return null;
43182
43746
  }
43183
- function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43747
+ function emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
43184
43748
  const condExpr = transformTracked2(node.condition, tracked2);
43185
43749
  const anchor = ctx2.n();
43186
43750
  const endAnchor = ctx2.n();
43187
43751
  const effectsVar = ctx2.n();
43188
43752
  const hyd = ctx2.hydrate;
43189
43753
  const parent = parentVar || "$root";
43754
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43190
43755
  ctx2.push(`const ${anchor} = document.createComment('while');`);
43191
43756
  if (!hyd)
43192
43757
  ctx2.push(`${parent}.appendChild(${anchor});`);
43193
43758
  ctx2.push(`let ${effectsVar} = [];`);
43194
43759
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
43195
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43760
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43196
43761
  const renderLoop = ctx2.n();
43197
43762
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43198
43763
  if (!hyd)
@@ -43204,7 +43769,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43204
43769
  if (node.isDoWhile) {
43205
43770
  ctx2.push(indent3(`do {`));
43206
43771
  for (const n of node.bodyTemplate) {
43207
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43772
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43208
43773
  if (v) {
43209
43774
  if (hyd)
43210
43775
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43216,7 +43781,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43216
43781
  } else {
43217
43782
  ctx2.push(indent3(`while (${condExpr}) {`));
43218
43783
  for (const n of node.bodyTemplate) {
43219
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43784
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43220
43785
  if (v) {
43221
43786
  if (hyd)
43222
43787
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43255,18 +43820,19 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43255
43820
  }`);
43256
43821
  return null;
43257
43822
  }
43258
- function emitForLoop2(ctx2, node, tracked2, parentVar) {
43823
+ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
43259
43824
  const anchor = ctx2.n();
43260
43825
  const endAnchor = ctx2.n();
43261
43826
  const effectsVar = ctx2.n();
43262
43827
  const hyd = ctx2.hydrate;
43263
43828
  const parent = parentVar || "$root";
43829
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43264
43830
  ctx2.push(`const ${anchor} = document.createComment('for');`);
43265
43831
  if (!hyd)
43266
43832
  ctx2.push(`${parent}.appendChild(${anchor});`);
43267
43833
  ctx2.push(`let ${effectsVar} = [];`);
43268
43834
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
43269
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43835
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43270
43836
  const renderLoop = ctx2.n();
43271
43837
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43272
43838
  if (!hyd)
@@ -43279,7 +43845,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43279
43845
  const srcExpr = transformTracked2(node.condition, tracked2);
43280
43846
  ctx2.push(indent3(`for (${node.init} of (Array.isArray(${srcExpr}) ? ${srcExpr} : (${srcExpr} == null ? [] : Object.keys(${srcExpr})))) {`));
43281
43847
  for (const n of node.bodyTemplate) {
43282
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43848
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43283
43849
  if (v) {
43284
43850
  if (hyd)
43285
43851
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43299,7 +43865,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43299
43865
  const head = initPart ? `${initPart}; ${condExpr}` : `; ${condExpr}`;
43300
43866
  ctx2.push(indent3(`for (${head}; ${updatePart}) {`));
43301
43867
  for (const n of node.bodyTemplate) {
43302
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43868
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43303
43869
  if (v) {
43304
43870
  if (hyd)
43305
43871
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43410,19 +43976,20 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43410
43976
  }
43411
43977
  return null;
43412
43978
  }
43413
- function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43979
+ function emitSwitchBlock2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
43414
43980
  const discExpr = transformTracked2(node.discriminant, tracked2);
43415
43981
  const anchor = ctx2.n();
43416
43982
  const endAnchor = ctx2.n();
43417
43983
  const effectsVar = ctx2.n();
43418
43984
  const hyd = ctx2.hydrate;
43419
43985
  const parent = parentVar || "$root";
43986
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43420
43987
  ctx2.push(`const ${anchor} = document.createComment('switch');`);
43421
43988
  if (!hyd)
43422
43989
  ctx2.push(`${parent}.appendChild(${anchor});`);
43423
43990
  ctx2.push(`let ${effectsVar} = [];`);
43424
43991
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
43425
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43992
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43426
43993
  const renderSwitch = ctx2.n();
43427
43994
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43428
43995
  if (hyd) {
@@ -43439,7 +44006,7 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43439
44006
  ctx2.push(indent3(`default:`));
43440
44007
  }
43441
44008
  for (const n of c.body) {
43442
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c");
44009
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c", "__components", 0, budget || void 0);
43443
44010
  if (v) {
43444
44011
  if (hyd)
43445
44012
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43479,7 +44046,7 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43479
44046
  }`);
43480
44047
  return null;
43481
44048
  }
43482
- function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
44049
+ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
43483
44050
  const arrExpr = transformTracked2(node.expression, tracked2);
43484
44051
  const itemVar = node.itemVariable;
43485
44052
  const anchor = ctx2.n();
@@ -43491,6 +44058,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43491
44058
  const hyd = ctx2.hydrate && !keyed;
43492
44059
  const hydKeyed = ctx2.hydrate && keyed;
43493
44060
  const parent = parentVar || "$root";
44061
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43494
44062
  const reactiveSource = isReactiveExpression2(node.expression, tracked2);
43495
44063
  const pushEffect = (lets, effCall) => {
43496
44064
  if (effTarget) {
@@ -43525,7 +44093,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43525
44093
  if (hydKeyed)
43526
44094
  ctx2.rootClaim = true;
43527
44095
  for (const n of node.bodyTemplate) {
43528
- const v = emitNode2(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it");
44096
+ const v = emitNode2(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it", "__components", 0, budget || void 0);
43529
44097
  if (v) {
43530
44098
  if (hyd) {
43531
44099
  ctx2.push(indent3(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, __r);`));
@@ -43556,7 +44124,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43556
44124
  ctx2.hydrate = false;
43557
44125
  for (const n of node.alternateNodes) {
43558
44126
  ctx2.claimStatic = true;
43559
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag);
44127
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag, "__components", 0, budget || void 0);
43560
44128
  if (v) {
43561
44129
  if (hyd)
43562
44130
  ctx2.push(indent3(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, ${endAnchor});`));
@@ -43581,7 +44149,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43581
44149
  const initList = ctx2.n();
43582
44150
  ctx2.push(`let ${reconciler} = () => {};`);
43583
44151
  if (hydKeyed) {
43584
- ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}); };`);
44152
+ ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}, ${skipK}); };`);
43585
44153
  } else {
43586
44154
  ctx2.push(`const ${initList} = () => { ${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
43587
44155
  }
@@ -43687,13 +44255,14 @@ ${renderAllItems(" ", null)}
43687
44255
  function computeAsyncComponents2(comps) {
43688
44256
  return new Set(comps.filter((c) => c.isAsync).map((c) => c.name));
43689
44257
  }
43690
- function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc) {
44258
+ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc, markerless = true) {
43691
44259
  const tracked2 = collectTrackedNames2(comp.body);
43692
44260
  const ctx2 = new Ctx2(alloc);
43693
44261
  ctx2.importedNames = importedNames;
43694
44262
  ctx2.linkNames = linkNames;
43695
44263
  ctx2.selfClaimNames = selfClaimNames;
43696
44264
  ctx2.hydrate = hydrate;
44265
+ ctx2.markerless = markerless;
43697
44266
  ctx2.asyncComps = asyncComps;
43698
44267
  ctx2.isAsyncScope = comp.isAsync || asyncComps.has(comp.name);
43699
44268
  ctx2.push(hydrate ? ctx2.isAsyncScope ? "async (props, __registry, __hydrate) => {" : "(props, __registry, __hydrate) => {" : ctx2.isAsyncScope ? "async (props) => {" : "(props) => {");
@@ -43722,10 +44291,15 @@ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hyd
43722
44291
  emitNode2(ctx2, node, tracked2, null);
43723
44292
  }
43724
44293
  }
44294
+ let topPendingSkip = 0;
44295
+ let topBudget = null;
44296
+ if (ctx2.markerless && ctx2.hydrate) {
44297
+ topBudget = regionBudgetVar2(ctx2, 0, void 0, `(typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0)`);
44298
+ }
43725
44299
  for (const node of comp.body) {
43726
44300
  if (node instanceof TrackDecl)
43727
44301
  continue;
43728
- const v = emitNode2(ctx2, node, tracked2, null);
44302
+ const v = emitNode2(ctx2, node, tracked2, null, void 0, "__components", topPendingSkip, topBudget || void 0);
43729
44303
  if (v) {
43730
44304
  if (ctx2.hydrate) {
43731
44305
  ctx2.push(indent3(`if ($mount === null) $mount = ${v};`));
@@ -43734,6 +44308,11 @@ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hyd
43734
44308
  ctx2.push(indent3(`$root.appendChild(${v});`));
43735
44309
  }
43736
44310
  }
44311
+ if (claimsWalkerNode2(ctx2, node)) {
44312
+ topBudget = null;
44313
+ topPendingSkip = 0;
44314
+ } else
44315
+ topPendingSkip += ssrResidueEstimate2(node);
43737
44316
  }
43738
44317
  const effCode = ctx2.flushEffects();
43739
44318
  if (effCode)
@@ -43760,7 +44339,7 @@ function buildParamInit3(paramNames) {
43760
44339
  return "";
43761
44340
  return `const { ${paramNames.join(", ")} } = props;`;
43762
44341
  }
43763
- function buildComponentMap3(irRoot, hydrate = false, alloc) {
44342
+ function buildComponentMap3(irRoot, hydrate = false, alloc, markerless = true) {
43764
44343
  const mapLines = [];
43765
44344
  mapLines.push(`const __components = {};`);
43766
44345
  const asyncComps = computeAsyncComponents2(irRoot.components);
@@ -43784,11 +44363,12 @@ function buildComponentMap3(irRoot, hydrate = false, alloc) {
43784
44363
  const directNames = /* @__PURE__ */ new Set([...extractRuntimeNames(irRoot.imports), ...localValueImportNames(irRoot.imports), ...topValueNames]);
43785
44364
  for (const comp of irRoot.components) {
43786
44365
  if (hydrate && isStaticComponent2(comp)) {
43787
- const stub = `(props, __registry, __hydrate) => { return __hydrate.claimOnly(); }`;
44366
+ const claimExpr = markerless ? `__hydrate.claimOnly(undefined, (typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0))` : `__hydrate.claimOnly()`;
44367
+ const stub = `(props, __registry, __hydrate) => { return ${claimExpr}; }`;
43788
44368
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${stub};`);
43789
44369
  continue;
43790
44370
  }
43791
- const code = generateComponent2(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc);
44371
+ const code = generateComponent2(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc, markerless);
43792
44372
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${code};`);
43793
44373
  }
43794
44374
  mapLines.push(`function __cleanup(start, end) {`);
@@ -43809,6 +44389,12 @@ function buildComponentMap3(irRoot, hydrate = false, alloc) {
43809
44389
  mapLines.push(` const p = nodes[0].parentNode;`);
43810
44390
  mapLines.push(` p.insertBefore(start, nodes[0]);`);
43811
44391
  mapLines.push(` p.insertBefore(end, nodes[nodes.length - 1].nextSibling);`);
44392
+ mapLines.push(` // Client-surplus nodes (SSR rendered fewer items than the client data)`);
44393
+ mapLines.push(` // are freshly claimed and still detached \u2014 move them into the region in`);
44394
+ mapLines.push(` // client order before \`end\`, instead of stranding them off-parent.`);
44395
+ mapLines.push(` for (let i = 0; i < nodes.length; i++) {`);
44396
+ mapLines.push(` if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);`);
44397
+ mapLines.push(` }`);
43812
44398
  mapLines.push(` return;`);
43813
44399
  mapLines.push(` }`);
43814
44400
  mapLines.push(` fallback.appendChild(start);`);
@@ -43867,6 +44453,25 @@ function isStaticIR2(body) {
43867
44453
  }
43868
44454
  return true;
43869
44455
  }
44456
+ function claimsWalkerNode2(ctx2, node) {
44457
+ if (node instanceof StaticNode)
44458
+ return ctx2.claimStatic || !isStaticIR2(node.children);
44459
+ if (node instanceof ComponentCall)
44460
+ return true;
44461
+ if (node instanceof OpaqueDynamicRegion)
44462
+ return true;
44463
+ if (node instanceof MapRegion)
44464
+ return true;
44465
+ if (node instanceof ForLoop)
44466
+ return true;
44467
+ if (node instanceof WhileLoop)
44468
+ return true;
44469
+ if (node instanceof SwitchBlock)
44470
+ return true;
44471
+ if (node instanceof TryCatch)
44472
+ return true;
44473
+ return false;
44474
+ }
43870
44475
  function isStaticComponent2(comp) {
43871
44476
  if (comp.style)
43872
44477
  return false;
@@ -44041,7 +44646,7 @@ function emitClientFromIR2(ir, options) {
44041
44646
  if (!options.forceClient && !needsClient) {
44042
44647
  return "";
44043
44648
  }
44044
- const componentMapCode = buildComponentMap3(ir, options.hydrate, options.nameAllocator);
44649
+ const componentMapCode = buildComponentMap3(ir, options.hydrate, options.nameAllocator, options.markerless !== false);
44045
44650
  const importLines = ir.imports.length > 0 ? ir.imports.join("\n") + "\n" : "";
44046
44651
  const topCode = (options.includeTopLevel === false ? [] : transformTopLevelForActions(ir.topLevelCode, "client")).join("\n") + "\n";
44047
44652
  const exportLines = [];
@@ -44127,7 +44732,7 @@ function compileClientBoth2(source, _componentName, sourcePath2, opts) {
44127
44732
  return { comp, hyd: "", name };
44128
44733
  return {
44129
44734
  comp,
44130
- hyd: emitClientFromIR2(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc }),
44735
+ hyd: emitClientFromIR2(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
44131
44736
  name
44132
44737
  };
44133
44738
  }
@@ -45268,9 +45873,10 @@ function guessProjectRoots2(dir) {
45268
45873
  }
45269
45874
 
45270
45875
  // ../adapter/dist/client-bundle.js
45271
- import { readFileSync as readFileSync24, existsSync as existsSync28, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync14, rmSync as rmSync4, mkdtempSync as mkdtempSync2 } from "node:fs";
45876
+ import { readFileSync as readFileSync24, existsSync as existsSync28, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync14, rmSync as rmSync4, mkdtempSync as mkdtempSync2, mkdirSync as mkdirSync12 } from "node:fs";
45272
45877
  import { resolve as resolve24, join as join18, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
45273
45878
  import { fileURLToPath as fileURLToPath6 } from "node:url";
45879
+ import { tmpdir as tmpdir2 } from "node:os";
45274
45880
 
45275
45881
  // ../adapter/dist/esbuild-fallback.js
45276
45882
  var _nativeBuild2 = null;
@@ -46137,7 +46743,19 @@ function runtimeExportNames2(runtimeDir) {
46137
46743
  return names;
46138
46744
  }
46139
46745
  var RUNTIME_ENTRY2 = ".runtime-tree-entry.mjs";
46140
- async function buildTreeShakenRuntime2(runtimeDir, usedNames) {
46746
+ function esbuildPath2(p) {
46747
+ return sep3 === "/" ? p : p.split(sep3).join("/");
46748
+ }
46749
+ function runtimeTreeShakeEntry2() {
46750
+ return join18(tmpdir2(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
46751
+ }
46752
+ var treeShakeQueue2 = Promise.resolve();
46753
+ function buildTreeShakenRuntime2(runtimeDir, usedNames) {
46754
+ const run = treeShakeQueue2.then(() => buildTreeShakenRuntimeNow2(runtimeDir, usedNames));
46755
+ treeShakeQueue2 = run.catch(() => void 0);
46756
+ return run;
46757
+ }
46758
+ async function buildTreeShakenRuntimeNow2(runtimeDir, usedNames) {
46141
46759
  const unique = [...new Set(usedNames)];
46142
46760
  const available = runtimeExportNames2(runtimeDir);
46143
46761
  const missing = unique.filter((n) => !available.has(n));
@@ -46145,16 +46763,21 @@ async function buildTreeShakenRuntime2(runtimeDir, usedNames) {
46145
46763
  console.error(`vesk: runtime names not exported \u2014 ${missing.join(", ")}; falling back to full runtime`);
46146
46764
  return buildRuntimeCode2(runtimeDir);
46147
46765
  }
46148
- const entry = join18(runtimeDir, RUNTIME_ENTRY2);
46766
+ const entry = runtimeTreeShakeEntry2();
46767
+ const indexClient = esbuildPath2(join18(runtimeDir, "index-client.js"));
46149
46768
  try {
46769
+ try {
46770
+ mkdirSync12(dirname18(entry), { recursive: true });
46771
+ } catch {
46772
+ }
46150
46773
  try {
46151
46774
  rmSync4(entry);
46152
46775
  } catch {
46153
46776
  }
46154
- writeFileSync13(entry, `export { ${unique.join(", ")} } from './index-client.js';
46777
+ writeFileSync13(entry, `export { ${unique.join(", ")} } from ${JSON.stringify(indexClient)};
46155
46778
  `);
46156
46779
  const result = await build3({
46157
- entryPoints: [entry],
46780
+ entryPoints: [esbuildPath2(entry)],
46158
46781
  bundle: true,
46159
46782
  format: "iife",
46160
46783
  globalName: "__veskRuntime",
@@ -46211,7 +46834,7 @@ async function buildMainBundle2(routeTree, runtimeDir, codeSplit, mono, hmr, imp
46211
46834
 
46212
46835
  ` : runtimeCode + "\n";
46213
46836
  const cleanupFn = "function __cleanup(start, end) {\n let n = start.nextSibling;\n while (n && n !== end) {\n const next = n.nextSibling;\n n.remove();\n n = next;\n }\n}\n";
46214
- const placeFn = "function __place(start, end, nodes, fallback) {\n if (start.parentNode !== null) {\n const p = start.parentNode;\n for (let i = 0; i < nodes.length; i++) p.insertBefore(nodes[i], end);\n return;\n }\n if (nodes.length > 0 && nodes[0].parentNode) {\n const p = nodes[0].parentNode;\n p.insertBefore(start, nodes[0]);\n p.insertBefore(end, nodes[nodes.length - 1].nextSibling);\n return;\n }\n fallback.appendChild(start);\n fallback.appendChild(end);\n for (let i = 0; i < nodes.length; i++) fallback.insertBefore(nodes[i], end);\n}\n";
46837
+ const placeFn = "function __place(start, end, nodes, fallback) {\n if (start.parentNode !== null) {\n const p = start.parentNode;\n for (let i = 0; i < nodes.length; i++) p.insertBefore(nodes[i], end);\n return;\n }\n if (nodes.length > 0 && nodes[0].parentNode) {\n const p = nodes[0].parentNode;\n p.insertBefore(start, nodes[0]);\n p.insertBefore(end, nodes[nodes.length - 1].nextSibling);\n // Client-surplus nodes (SSR rendered fewer items than the client data)\n // are freshly claimed and still detached \u2014 move them into the region in\n // client order before `end`, instead of stranding them off-parent.\n for (let i = 0; i < nodes.length; i++) {\n if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);\n }\n return;\n }\n fallback.appendChild(start);\n fallback.appendChild(end);\n for (let i = 0; i < nodes.length; i++) fallback.insertBefore(nodes[i], end);\n}\n";
46215
46838
  const updateComponentsFn = "function __updateComponents(nodes) {\n for (const n of nodes) {\n if (n._pageName && __components[n._pageName]) n.page = __components[n._pageName];\n if (n._layoutName && __components[n._layoutName]) n.layout = __components[n._layoutName];\n if (n._errorName && __components[n._errorName]) n.error = __components[n._errorName];\n if (n._notFoundName && __components[n._notFoundName]) n.notFound = __components[n._notFoundName];\n if (n._offlineName && __components[n._offlineName]) n.offline = __components[n._offlineName];\n if (n._networkName && __components[n._networkName]) n.network = __components[n._networkName];\n if (n.children) __updateComponents(n.children);\n }\n}\n";
46216
46839
  const routeTreeJson = JSON.stringify(routeTree);
46217
46840
  if (codeSplit) {
@@ -46379,7 +47002,7 @@ import { resolve as resolve28 } from "node:path";
46379
47002
 
46380
47003
  // ../adapter/dist/plugins.js
46381
47004
  init_paths();
46382
- import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync11, statSync as statSync16 } from "node:fs";
47005
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
46383
47006
  import { resolve as resolve26, dirname as dirname19, join as join19, extname as extname7, basename as basename5 } from "node:path";
46384
47007
  import { createRequire as createRequire5 } from "node:module";
46385
47008
  import { spawn as spawn2 } from "node:child_process";
@@ -46423,7 +47046,7 @@ function writePluginState2(veskDir, state) {
46423
47046
  const file = stateFilePath2(veskDir);
46424
47047
  const dir = dirname19(file);
46425
47048
  if (!existsSync30(dir))
46426
- mkdirSync11(dir, { recursive: true });
47049
+ mkdirSync13(dir, { recursive: true });
46427
47050
  writeFileSync14(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
46428
47051
  }
46429
47052
  function resolvePackage2(appDir, pkg) {
@@ -47355,8 +47978,8 @@ var __internals2 = {
47355
47978
  };
47356
47979
 
47357
47980
  // ../adapter/dist/dev-config.js
47358
- import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
47359
- import { tmpdir } from "node:os";
47981
+ import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
47982
+ import { tmpdir as tmpdir3 } from "node:os";
47360
47983
  import { resolve as resolve27, dirname as dirname20, join as join20 } from "node:path";
47361
47984
  init_parser();
47362
47985
  function findConfigFile2(projectDir) {
@@ -47385,8 +48008,8 @@ async function parseConfigSource(source, isTs, projectDir) {
47385
48008
  js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
47386
48009
  ` + js;
47387
48010
  }
47388
- const base = projectDir ? (mkdirSync12(join20(projectDir, ".vesk"), { recursive: true }), join20(projectDir, ".vesk")) : void 0;
47389
- const dir = base ? mkdtempSync3(join20(base, "cfg-")) : mkdtempSync3(join20(tmpdir(), "vesk-cfg-"));
48011
+ const base = projectDir ? (mkdirSync14(join20(projectDir, ".vesk"), { recursive: true }), join20(projectDir, ".vesk")) : void 0;
48012
+ const dir = base ? mkdtempSync3(join20(base, "cfg-")) : mkdtempSync3(join20(tmpdir3(), "vesk-cfg-"));
47390
48013
  const tmpFile = join20(dir, "config.mjs");
47391
48014
  try {
47392
48015
  writeFileSync15(tmpFile, js, "utf-8");
@@ -47422,7 +48045,7 @@ async function writeConfigSource2(projectDir, source) {
47422
48045
  const { path, isTs } = findConfigFile2(projectDir);
47423
48046
  const target = path || resolve27(projectDir, "vesk.config.ts");
47424
48047
  await parseConfigSource(source, isTs, projectDir);
47425
- mkdirSync12(dirname20(target), { recursive: true });
48048
+ mkdirSync14(dirname20(target), { recursive: true });
47426
48049
  writeFileSync15(target, source, "utf-8");
47427
48050
  const config = await parseConfigSource(source, isTs, projectDir);
47428
48051
  return { path: target, exists: true, source, config };
@@ -48242,7 +48865,7 @@ async function addPluginToConfig2(projectDir, pkg) {
48242
48865
  let source;
48243
48866
  if (!path) {
48244
48867
  const importName2 = importNameForPackage(pkg);
48245
- const entry2 = pkg === "@vesk/plugin-tailwind" ? `${importName2}({ entry: 'src/global.css', appDir: 'app' })` : `${importName2}()`;
48868
+ const entry2 = pkg === "@vesk/plugin-tailwind" ? `${importName2}({ entry: 'app/global.css', appDir: 'app' })` : `${importName2}()`;
48246
48869
  source = `import { defineConfig } from '@vesk/compiler'
48247
48870
  import ${importName2} from '${pkg}'
48248
48871
 
@@ -48326,7 +48949,7 @@ export default defineConfig({
48326
48949
  source = importLine + source;
48327
48950
  }
48328
48951
  }
48329
- const entry = pkg === "@vesk/plugin-tailwind" ? `${importName}({ entry: 'src/global.css', appDir: 'app' })` : `${importName}()`;
48952
+ const entry = pkg === "@vesk/plugin-tailwind" ? `${importName}({ entry: 'app/global.css', appDir: 'app' })` : `${importName}()`;
48330
48953
  const newSource = insertIntoPluginsArray(source, entry);
48331
48954
  if (newSource === source)
48332
48955
  return;
@@ -48696,7 +49319,7 @@ function produceDiagnostics(input) {
48696
49319
  }
48697
49320
 
48698
49321
  // ../agentic/dist/checkpoints.js
48699
- import { existsSync as existsSync33, mkdirSync as mkdirSync13, readFileSync as readFileSync29, writeFileSync as writeFileSync16, statSync as statSync18, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
49322
+ import { existsSync as existsSync33, mkdirSync as mkdirSync15, readFileSync as readFileSync29, writeFileSync as writeFileSync16, statSync as statSync18, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
48700
49323
  import { join as join21, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
48701
49324
  import { randomUUID as nodeRandomUUID } from "node:crypto";
48702
49325
  function generateId() {
@@ -48842,7 +49465,7 @@ function getCheckpointPath(projectDir, id) {
48842
49465
  return join21(getCheckpointDir(projectDir, id), "checkpoint.json");
48843
49466
  }
48844
49467
  function ensureDir(dir) {
48845
- mkdirSync13(dir, { recursive: true });
49468
+ mkdirSync15(dir, { recursive: true });
48846
49469
  }
48847
49470
  function readJson(filePath, fallback) {
48848
49471
  try {
@@ -48968,7 +49591,7 @@ function rollback(projectDir, id) {
48968
49591
  }
48969
49592
 
48970
49593
  // ../agentic/dist/config.js
48971
- import { readFileSync as readFileSync30, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync14, chmodSync } from "node:fs";
49594
+ import { readFileSync as readFileSync30, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync16, chmodSync } from "node:fs";
48972
49595
  import { resolve as resolve30, dirname as dirname22 } from "node:path";
48973
49596
  var DEFAULT_CONFIG = {
48974
49597
  provider: "openai",
@@ -49098,7 +49721,7 @@ function saveAgenticConfig(projectDir, patch) {
49098
49721
  if (next.baseUrl)
49099
49722
  toWrite.baseUrl = next.baseUrl;
49100
49723
  try {
49101
- mkdirSync14(dirname22(p), { recursive: true });
49724
+ mkdirSync16(dirname22(p), { recursive: true });
49102
49725
  writeFileSync17(p, JSON.stringify(toWrite, null, 2), "utf-8");
49103
49726
  } catch {
49104
49727
  }
@@ -50423,7 +51046,7 @@ var Agent = class {
50423
51046
  };
50424
51047
 
50425
51048
  // ../agentic/dist/tools/vesk.js
50426
- import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync15, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
51049
+ import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
50427
51050
  import { resolve as resolve32, join as join22, dirname as dirname23, sep as sep6 } from "node:path";
50428
51051
  function resolveWithin3(baseDir, relPath) {
50429
51052
  const base = resolve32(baseDir);
@@ -50457,7 +51080,7 @@ function readPluginState3(veskDir) {
50457
51080
  }
50458
51081
  function writePluginState3(veskDir, state) {
50459
51082
  const file = stateFilePath3(veskDir);
50460
- mkdirSync15(dirname23(file), { recursive: true });
51083
+ mkdirSync17(dirname23(file), { recursive: true });
50461
51084
  writeFileSync18(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
50462
51085
  }
50463
51086
  function eqIgnoreCase3(a, b) {
@@ -50817,7 +51440,7 @@ function createVeskTools(deps) {
50817
51440
  if (!contained)
50818
51441
  return jsonError("path escapes project root");
50819
51442
  }
50820
- mkdirSync15(dirname23(target), { recursive: true });
51443
+ mkdirSync17(dirname23(target), { recursive: true });
50821
51444
  writeFileSync18(target, source, "utf-8");
50822
51445
  return jsonOk({ ok: true, path: target, source });
50823
51446
  }
@@ -51099,7 +51722,7 @@ function createVeskTools(deps) {
51099
51722
  } catch {
51100
51723
  }
51101
51724
  const dir = checkpointDir(veskDir);
51102
- mkdirSync15(dir, { recursive: true });
51725
+ mkdirSync17(dir, { recursive: true });
51103
51726
  const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
51104
51727
  const file = join22(dir, `${id}.json`);
51105
51728
  const check = resolveWithin3(dir, `${id}.json`);
@@ -51178,6 +51801,9 @@ import { readFileSync as readFileSync33, existsSync as existsSync37 } from "node
51178
51801
  import { resolve as resolve33 } from "node:path";
51179
51802
  var GLOBAL_CSS_URL2 = "/_vesk/static/global.css";
51180
51803
  function resolveUserCssPath2(appDir) {
51804
+ const appCssSrc = resolve33(appDir, "global.css");
51805
+ if (existsSync37(appCssSrc))
51806
+ return appCssSrc;
51181
51807
  const cssSrc = resolve33(appDir, "..", "src", "global.css");
51182
51808
  if (existsSync37(cssSrc))
51183
51809
  return cssSrc;
@@ -51868,7 +52494,7 @@ function renderDevErrorPage(payload, opts) {
51868
52494
 
51869
52495
  // src/build-packages.ts
51870
52496
  import { spawnSync } from "node:child_process";
51871
- import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync16, readFileSync as readFileSync36, readdirSync as readdirSync11, statSync as statSync20, writeFileSync as writeFileSync20 } from "node:fs";
52497
+ import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync18, readFileSync as readFileSync36, readdirSync as readdirSync11, statSync as statSync20, writeFileSync as writeFileSync20 } from "node:fs";
51872
52498
  import { createRequire as createRequire6 } from "node:module";
51873
52499
  import { dirname as dirname25, join as join23, resolve as resolve36 } from "node:path";
51874
52500
  import { fileURLToPath as fileURLToPath8 } from "node:url";
@@ -51951,7 +52577,7 @@ function buildPackages(force = false) {
51951
52577
  const distDir = join23(pkgDir, "dist");
51952
52578
  for (const c of cfg.copy || []) {
51953
52579
  const to = join23(distDir, c.to);
51954
- mkdirSync16(dirname25(to), { recursive: true });
52580
+ mkdirSync18(dirname25(to), { recursive: true });
51955
52581
  cpSync2(join23(pkgDir, c.from), to, { recursive: true });
51956
52582
  }
51957
52583
  const srcPkg = JSON.parse(readFileSync36(join23(pkgDir, "package.json"), "utf-8"));
@@ -52600,7 +53226,11 @@ var HMR_CONFIG_NAMES = /* @__PURE__ */ new Set([
52600
53226
  "tsconfig.json",
52601
53227
  "package.json"
52602
53228
  ]);
52603
- function classifyHmrWatchPath(relPath) {
53229
+ function normalizeWatchPath(relPath) {
53230
+ return relPath.includes("\\") ? relPath.split("\\").join("/") : relPath;
53231
+ }
53232
+ function classifyHmrWatchPath(relPathRaw) {
53233
+ const relPath = normalizeWatchPath(relPathRaw);
52604
53234
  const first = relPath.split("/")[0];
52605
53235
  if (HMR_SKIP_DIRS.has(first) || HMR_SKIP_MARKERS.some((m) => relPath.includes(m))) return "ignored";
52606
53236
  const name = relPath.slice(relPath.lastIndexOf("/") + 1);
@@ -52611,8 +53241,9 @@ function classifyHmrWatchPath(relPath) {
52611
53241
  if (HMR_SCRIPT_EXTS.some((ext) => relPath.endsWith(ext))) return "script";
52612
53242
  return "ignored";
52613
53243
  }
52614
- function shouldRescanRoutes(relPath, eventType) {
53244
+ function shouldRescanRoutes(relPathRaw, eventType) {
52615
53245
  if (eventType === "rename") return true;
53246
+ const relPath = normalizeWatchPath(relPathRaw);
52616
53247
  const name = relPath.slice(relPath.lastIndexOf("/") + 1);
52617
53248
  return relPath.endsWith(".vsk") && ROUTE_STRUCTURAL_VSK.has(name);
52618
53249
  }
@@ -52793,13 +53424,20 @@ async function startDevServer(port, projectDir, config, host) {
52793
53424
  }
52794
53425
  let devGlobalCssContent = "";
52795
53426
  let lastServedCssGlobal = "";
53427
+ const appCssPath = join24(appDirPath, "global.css");
52796
53428
  const srcDir = join24(projectDir, "src");
52797
53429
  const cssPath = join24(srcDir, "global.css");
52798
53430
  const altCssPath = join24(srcDir, "app.css");
52799
53431
  let rawCss = "";
52800
- if (existsSync42(cssPath)) {
53432
+ let devCssSource = "";
53433
+ if (existsSync42(appCssPath)) {
53434
+ devCssSource = appCssPath;
53435
+ rawCss = readFileSync38(appCssPath, "utf-8");
53436
+ } else if (existsSync42(cssPath)) {
53437
+ devCssSource = cssPath;
52801
53438
  rawCss = readFileSync38(cssPath, "utf-8");
52802
53439
  } else if (existsSync42(altCssPath)) {
53440
+ devCssSource = altCssPath;
52803
53441
  rawCss = readFileSync38(altCssPath, "utf-8");
52804
53442
  }
52805
53443
  if (rawCss) {
@@ -52812,7 +53450,7 @@ async function startDevServer(port, projectDir, config, host) {
52812
53450
  devGlobalCssContent = rawCss;
52813
53451
  for (const plugin of activeAtStart) {
52814
53452
  if (typeof plugin.onCSS === "function") {
52815
- const result = await plugin.onCSS(rawCss, cssPath);
53453
+ const result = await plugin.onCSS(rawCss, devCssSource);
52816
53454
  if (result !== null && typeof result === "string") {
52817
53455
  devGlobalCssContent = result;
52818
53456
  }
@@ -53016,7 +53654,7 @@ async function startDevServer(port, projectDir, config, host) {
53016
53654
  const active = getActiveDevPlugins();
53017
53655
  for (const plugin of active) {
53018
53656
  if (typeof plugin.onCSS === "function") {
53019
- const result = await plugin.onCSS(rawCss, cssPath);
53657
+ const result = await plugin.onCSS(rawCss, devCssSource);
53020
53658
  if (result !== null && typeof result === "string") {
53021
53659
  nextGlobal = result;
53022
53660
  }
@@ -54220,7 +54858,7 @@ function usage(code = 0) {
54220
54858
  console.error(" vesk typecheck [--no-strict] Typecheck .vsk/.ts files via tsc-in-.vsk (strict by default)");
54221
54859
  console.error(" vesk start [-p 3000] Start production server");
54222
54860
  console.error(" vesk dev [-p 3000] Start dev server with HMR");
54223
- console.error(" vesk init Create src/global.css (Tailwind entrypoint) if missing");
54861
+ console.error(" vesk init Create app/global.css (Tailwind entrypoint) if missing");
54224
54862
  console.error(" vesk --help Show this help");
54225
54863
  console.error("");
54226
54864
  console.error("Scaffolding: npx create-vesk@latest <project-name>");
@@ -54408,13 +55046,13 @@ if (cmd === "start") {
54408
55046
  }
54409
55047
  if (cmd === "init") {
54410
55048
  const projectDir = process.cwd();
54411
- const srcDir = join26(projectDir, "src");
54412
- const target = join26(srcDir, "global.css");
55049
+ const appDirPath = join26(projectDir, "app");
55050
+ const target = join26(appDirPath, "global.css");
54413
55051
  if (existsSync43(target)) {
54414
55052
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
54415
55053
  process.exit(0);
54416
55054
  }
54417
- mkdirSync18(srcDir, { recursive: true });
55055
+ mkdirSync20(appDirPath, { recursive: true });
54418
55056
  writeFileSync21(target, [
54419
55057
  `@import 'tailwindcss';`,
54420
55058
  ``,