@vesk/vesk-cli 0.2.36 → 0.2.38

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 +834 -201
  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,59 @@ function skipComment(text, i) {
17364
17589
  }
17365
17590
  return i;
17366
17591
  }
17592
+ function blankComments(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] === "/") {
17619
+ if (!lineStart) {
17620
+ i += 2;
17621
+ continue;
17622
+ }
17623
+ let j = i;
17624
+ while (j < n && text[j] !== "\n") {
17625
+ chars[j] = " ";
17626
+ j++;
17627
+ }
17628
+ i = j;
17629
+ continue;
17630
+ }
17631
+ if (ch === "/" && text[i + 1] === "*") {
17632
+ let j = i;
17633
+ while (j < n && !(text[j] === "*" && text[j + 1] === "/")) j++;
17634
+ const end = Math.min(j + 2, n);
17635
+ for (let k = i; k < end; k++) if (text[k] !== "\n") chars[k] = " ";
17636
+ lineStart = false;
17637
+ i = end;
17638
+ continue;
17639
+ }
17640
+ lineStart = false;
17641
+ i++;
17642
+ }
17643
+ return chars.join("");
17644
+ }
17367
17645
  function findBalancedEnd(text, openIndex) {
17368
17646
  const open = text[openIndex];
17369
17647
  const close = open === "(" ? ")" : open === "[" ? "]" : open === "{" ? "}" : null;
@@ -17762,7 +18040,7 @@ function createBaseParser() {
17762
18040
  }
17763
18041
  function parse4(source, options = {}) {
17764
18042
  const ParserClass = createBaseParser();
17765
- const { code, annotations } = preprocessForClauses(source);
18043
+ const { code, annotations } = preprocessForClauses(blankComments(source));
17766
18044
  try {
17767
18045
  const ast = ParserClass.parse(code, {
17768
18046
  ecmaVersion: "latest",
@@ -19435,6 +19713,10 @@ function componentUsesFetch(nodes) {
19435
19713
  function extractKeyExpr(nodes) {
19436
19714
  for (const n of nodes) {
19437
19715
  if (n instanceof StaticNode && n.keyExpr) return n.keyExpr;
19716
+ if (n instanceof ComponentCall) {
19717
+ const k = n.props.find((p) => p.name === "key");
19718
+ if (k) return k.value;
19719
+ }
19438
19720
  }
19439
19721
  return null;
19440
19722
  }
@@ -20514,6 +20796,7 @@ __export(server_utils_exports, {
20514
20796
  __vskHydrate: () => __vskHydrate,
20515
20797
  __vskId: () => __vskId,
20516
20798
  __vskImportedNames: () => __vskImportedNames,
20799
+ __vskMarkerless: () => __vskMarkerless,
20517
20800
  applyTrustProxy: () => applyTrustProxy,
20518
20801
  assertSameOrigin: () => assertSameOrigin,
20519
20802
  buildParamInit: () => buildParamInit,
@@ -20554,6 +20837,7 @@ __export(server_utils_exports, {
20554
20837
  setVskForceClaim: () => setVskForceClaim,
20555
20838
  setVskHydrate: () => setVskHydrate,
20556
20839
  setVskImportedNames: () => setVskImportedNames,
20840
+ setVskMarkerless: () => setVskMarkerless,
20557
20841
  signCookie: () => signCookie,
20558
20842
  takeVskForceClaim: () => takeVskForceClaim,
20559
20843
  tryEvalExpr: () => tryEvalExpr,
@@ -20561,14 +20845,19 @@ __export(server_utils_exports, {
20561
20845
  urlAuthority: () => urlAuthority,
20562
20846
  verifyCsrfToken: () => verifyCsrfToken
20563
20847
  });
20564
- function resetVskState(hydrate = false) {
20848
+ function resetVskState(hydrate = false, markerless = true) {
20565
20849
  __vskHydrate = hydrate;
20850
+ __vskMarkerless = markerless;
20566
20851
  __vskId = 0;
20567
20852
  __vskForceClaim = false;
20853
+ globalThis.__vsk_ssr_markerless = markerless === true;
20568
20854
  }
20569
20855
  function setVskHydrate(v) {
20570
20856
  __vskHydrate = v;
20571
20857
  }
20858
+ function setVskMarkerless(v) {
20859
+ __vskMarkerless = v;
20860
+ }
20572
20861
  function setVskImportedNames(names) {
20573
20862
  __vskImportedNames = names;
20574
20863
  }
@@ -21465,7 +21754,7 @@ return load(__ctx);
21465
21754
  const resolved = result && typeof result.then === "function" ? await result : result;
21466
21755
  return resolved;
21467
21756
  }
21468
- 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;
21757
+ 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;
21469
21758
  var init_server_utils = __esm({
21470
21759
  "../compiler/src/server-utils.ts"() {
21471
21760
  "use strict";
@@ -21493,6 +21782,7 @@ var init_server_utils = __esm({
21493
21782
  ]);
21494
21783
  RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set(["style", "script", "title"]);
21495
21784
  __vskHydrate = false;
21785
+ __vskMarkerless = true;
21496
21786
  __vskId = 0;
21497
21787
  __vskForceClaim = false;
21498
21788
  __vskImportedNames = null;
@@ -27710,7 +28000,12 @@ function headElementKey(node, props, locals2) {
27710
28000
  if (tag === "style") return null;
27711
28001
  return null;
27712
28002
  }
27713
- function irNodeToHeadHtml(node, props, locals2 = {}) {
28003
+ function headIsReconcilable(tag, attrMap) {
28004
+ if (!HEAD_RECONCILE_TAGS.has(tag)) return false;
28005
+ if (tag === "meta" && attrMap.has("charset")) return false;
28006
+ return true;
28007
+ }
28008
+ function irNodeToHeadHtml(node, props, locals2 = {}, reconcileable = false) {
27714
28009
  if (node instanceof StaticNode) {
27715
28010
  const attrMap = new Map(node.attributes.map((a) => [a.name, a.value]));
27716
28011
  for (const child of node.children) {
@@ -27722,10 +28017,11 @@ function irNodeToHeadHtml(node, props, locals2 = {}) {
27722
28017
  }
27723
28018
  }
27724
28019
  }
28020
+ const marker = reconcileable && headIsReconcilable(node.tag, attrMap) ? ` ${HEAD_RECONCILE_MARKER}` : "";
27725
28021
  const attrs = [...attrMap.entries()].map(([k, v]) => ` ${k}="${escapeHtml(v)}"`).join("");
27726
- if (node.selfClosing) return `<${node.tag}${attrs} />`;
27727
- const inner = node.children.filter((c) => !(c instanceof DynamicBinding && c.kind === "attribute" && c.target !== "ref")).map((c) => irNodeToHeadHtml(c, props, locals2)).join("");
27728
- return `<${node.tag}${attrs}>${inner}</${node.tag}>`;
28022
+ if (node.selfClosing) return `<${node.tag}${attrs}${marker} />`;
28023
+ const inner = node.children.filter((c) => !(c instanceof DynamicBinding && c.kind === "attribute" && c.target !== "ref")).map((c) => irNodeToHeadHtml(c, props, locals2, false)).join("");
28024
+ return `<${node.tag}${attrs}${marker}>${inner}</${node.tag}>`;
27729
28025
  }
27730
28026
  if (node instanceof TextNode) return node.value;
27731
28027
  if (node instanceof DynamicBinding) {
@@ -27748,7 +28044,7 @@ function renderHeadHtml(comp, props = {}) {
27748
28044
  const key = headElementKey(child, props, locals2);
27749
28045
  if (key !== null && seen.has(key)) continue;
27750
28046
  if (key !== null) seen.add(key);
27751
- parts.push(irNodeToHeadHtml(child, props, locals2));
28047
+ parts.push(irNodeToHeadHtml(child, props, locals2, true));
27752
28048
  }
27753
28049
  }
27754
28050
  }
@@ -27893,12 +28189,15 @@ function mergeHeadHtml(pageHead, layoutHead) {
27893
28189
  conflicts
27894
28190
  };
27895
28191
  }
28192
+ var HEAD_RECONCILE_MARKER, HEAD_RECONCILE_TAGS;
27896
28193
  var init_server_head = __esm({
27897
28194
  "../compiler/src/server-head.ts"() {
27898
28195
  "use strict";
27899
28196
  init_ir();
27900
28197
  init_server_utils();
27901
28198
  init_scan();
28199
+ HEAD_RECONCILE_MARKER = "data-vesk-head";
28200
+ HEAD_RECONCILE_TAGS = /* @__PURE__ */ new Set(["title", "meta", "link", "base", "style"]);
27902
28201
  }
27903
28202
  });
27904
28203
 
@@ -28269,6 +28568,8 @@ function transformTracked(irNode, tracked2) {
28269
28568
  return context.next();
28270
28569
  if (parent.type === "UpdateExpression" && parent.argument === node)
28271
28570
  return context.next();
28571
+ if (parent.type === "MemberExpression" && !parent.computed && parent.property === node)
28572
+ return context.next();
28272
28573
  if (parent.type === "Property" && parent.value === node && parent.key && parent.key.type === "Identifier" && parent.key.name === "into")
28273
28574
  return context.next();
28274
28575
  if (parent.type === "MemberExpression" && !parent.computed && parent.object === node && parent.property && parent.property.type === "Identifier" && parent.property.name === "set")
@@ -28321,8 +28622,8 @@ function nameAllocFor(sourcePath2, start = 0) {
28321
28622
  }
28322
28623
  return { c: h * 1e6 + start };
28323
28624
  }
28324
- function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
28325
- if (node instanceof StaticNode) return emitStatic(ctx2, node, tracked2, effectsVar);
28625
+ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
28626
+ if (node instanceof StaticNode) return emitStatic(ctx2, node, tracked2, effectsVar, skipK, regionBudget);
28326
28627
  if (node instanceof TextNode) {
28327
28628
  if (!node.value) return null;
28328
28629
  const v = ctx2.n();
@@ -28337,9 +28638,9 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
28337
28638
  return null;
28338
28639
  }
28339
28640
  if (node instanceof ComponentRef) return null;
28340
- if (node instanceof ComponentCall) return emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix);
28341
- if (node instanceof OpaqueDynamicRegion) return emitOpaque(ctx2, node, tracked2, effectsVar, parentVar);
28342
- if (node instanceof MapRegion) return emitMap(ctx2, node, tracked2, effectsVar, parentVar);
28641
+ if (node instanceof ComponentCall) return emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix, skipK, regionBudget);
28642
+ if (node instanceof OpaqueDynamicRegion) return emitOpaque(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
28643
+ if (node instanceof MapRegion) return emitMap(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
28343
28644
  if (node instanceof ServerBlock) return null;
28344
28645
  if (node instanceof ClientBlock) {
28345
28646
  const savedHydrate = ctx2.hydrate;
@@ -28376,10 +28677,10 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
28376
28677
  }
28377
28678
  return null;
28378
28679
  }
28379
- if (node instanceof TryCatch) return emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar);
28380
- if (node instanceof WhileLoop) return emitWhileLoop(ctx2, node, tracked2, parentVar);
28381
- if (node instanceof ForLoop) return emitForLoop(ctx2, node, tracked2, parentVar);
28382
- if (node instanceof SwitchBlock) return emitSwitchBlock(ctx2, node, tracked2, parentVar);
28680
+ if (node instanceof TryCatch) return emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
28681
+ if (node instanceof WhileLoop) return emitWhileLoop(ctx2, node, tracked2, parentVar, skipK, regionBudget);
28682
+ if (node instanceof ForLoop) return emitForLoop(ctx2, node, tracked2, parentVar, skipK, regionBudget);
28683
+ if (node instanceof SwitchBlock) return emitSwitchBlock(ctx2, node, tracked2, parentVar, skipK, regionBudget);
28383
28684
  if (node instanceof PropSlot) return null;
28384
28685
  if (node instanceof PropSlotRender) {
28385
28686
  const slotProp = `props.${node.propName}`;
@@ -28405,7 +28706,7 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
28405
28706
  }
28406
28707
  return null;
28407
28708
  }
28408
- function emitStatic(ctx2, node, tracked2, effectsVar) {
28709
+ function emitStatic(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
28409
28710
  const el = ctx2.n();
28410
28711
  if (ctx2.hydrate) {
28411
28712
  const claim = ctx2.claimStatic;
@@ -28413,8 +28714,11 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28413
28714
  if (!claim && isStaticIR(node.children)) return null;
28414
28715
  const rootClaim = ctx2.rootClaim;
28415
28716
  ctx2.rootClaim = false;
28416
- const claimedExpr = rootClaim ? `__root || ${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})`;
28717
+ const skipExpr = regionBudget && ctx2.markerless ? markerlessSkipExpr(regionBudget, skipK) : skipK;
28718
+ const skipArg = ctx2.markerless ? `, ${skipExpr}` : "";
28719
+ const claimedExpr = rootClaim ? `__root || document.createElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)}${skipArg})`;
28417
28720
  ctx2.push(`const ${el} = ${claimedExpr};`);
28721
+ if (regionBudget && ctx2.markerless) ctx2.push(`${regionBudget} = 0;`);
28418
28722
  } else {
28419
28723
  ctx2.push(`const ${el} = document.createElement(${JSON.stringify(node.tag)});`);
28420
28724
  }
@@ -28443,7 +28747,31 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28443
28747
  const textKids = children.filter((c) => c instanceof TextNode || c instanceof DynamicBinding && c.kind === "text");
28444
28748
  singleReactiveText = textKids.length === 1 && textKids[0] instanceof DynamicBinding && isReactiveExpression(textKids[0].expression, tracked2);
28445
28749
  }
28750
+ const savedWalker = ctx2.walker;
28751
+ let needsSubWalker = false;
28752
+ if (ctx2.hydrate && ctx2.markerless) {
28753
+ for (const child of children) {
28754
+ if (child instanceof TextNode) continue;
28755
+ if (child instanceof DynamicBinding && child.kind === "text") continue;
28756
+ if (child instanceof StaticNode && isStaticIR(child.children)) continue;
28757
+ if (child instanceof TrackDecl) continue;
28758
+ if (child instanceof ComponentRef) continue;
28759
+ if (child instanceof ServerBlock) continue;
28760
+ if (child instanceof ClientBlock) continue;
28761
+ if (child instanceof HeadBlock) continue;
28762
+ if (child instanceof RuntimeStatement) continue;
28763
+ if (child instanceof PropSlot) continue;
28764
+ needsSubWalker = true;
28765
+ break;
28766
+ }
28767
+ }
28768
+ if (needsSubWalker) {
28769
+ const sub = ctx2.n();
28770
+ ctx2.push(`const ${sub} = ${ctx2.walker}.subWalker(${el});`);
28771
+ ctx2.walker = sub;
28772
+ }
28446
28773
  let residueBefore = 0;
28774
+ let pendingSkip = 0;
28447
28775
  for (const child of children) {
28448
28776
  let childVar;
28449
28777
  const isPureStaticChild = ctx2.hydrate && child instanceof StaticNode && isStaticIR(child.children);
@@ -28497,10 +28825,12 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28497
28825
  }
28498
28826
  }
28499
28827
  childVar = ssrEl;
28828
+ pendingSkip += ssrResidueEstimate(child);
28500
28829
  } else if (singleReactiveText && child instanceof DynamicBinding && child.kind === "text") {
28501
28830
  childVar = emitDynamicBinding(ctx2, child, tracked2, effectsVar, `${el}.__vsk_ssrText`);
28502
28831
  } else {
28503
- childVar = emitNode(ctx2, child, tracked2, effectsVar, el);
28832
+ childVar = emitNode(ctx2, child, tracked2, effectsVar, el, "__components", pendingSkip);
28833
+ if (claimsWalkerNode(ctx2, child)) pendingSkip = 0;
28504
28834
  }
28505
28835
  if (childVar) {
28506
28836
  if (ctx2.hydrate) {
@@ -28552,6 +28882,7 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28552
28882
  }
28553
28883
  }
28554
28884
  }
28885
+ if (ctx2.walker !== savedWalker) ctx2.walker = savedWalker;
28555
28886
  return el;
28556
28887
  }
28557
28888
  function emitClientHead(ctx2, node, tracked2) {
@@ -28682,16 +29013,19 @@ function emitFragment(ctx2, nodes, tracked2, effectsVar) {
28682
29013
  const savedEffects = ctx2.effects;
28683
29014
  ctx2.effects = [];
28684
29015
  ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
29016
+ let fragPendingSkip = 0;
28685
29017
  for (const child of nodes) {
28686
- const childVar = emitNode(ctx2, child, tracked2, effectsVar, "$f");
29018
+ const childVar = emitNode(ctx2, child, tracked2, effectsVar, "$f", "__components", fragPendingSkip);
28687
29019
  if (childVar) ctx2.push(`$f.appendChild(${childVar});`);
29020
+ if (claimsWalkerNode(ctx2, child)) fragPendingSkip = 0;
29021
+ else fragPendingSkip += ssrResidueEstimate(child);
28688
29022
  }
28689
29023
  for (const eff of ctx2.effects) ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr(eff)});` : eff);
28690
29024
  ctx2.effects = savedEffects;
28691
29025
  ctx2.push(`return $f; })();`);
28692
29026
  return frag;
28693
29027
  }
28694
- function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
29028
+ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
28695
29029
  const propsEntries = node.props.map((p) => {
28696
29030
  if (typeof p.value === "string") return `${JSON.stringify(p.name)}: ${JSON.stringify(p.value)}`;
28697
29031
  const expr = transformTracked(p.value, tracked2);
@@ -28713,11 +29047,17 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28713
29047
  const callArgs = () => `{ ${propsEntries.join(", ")} }`;
28714
29048
  if (ctx2.hydrate) {
28715
29049
  const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `__components[${JSON.stringify(node.componentName)}]`);
29050
+ if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
29051
+ 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.`)});`);
29052
+ }
28716
29053
  const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
28717
29054
  const walkerArg = ctx2.walker;
29055
+ const promptExpr = ctx2.markerless && (regionBudget || skipK > 0) ? markerlessSkipExpr(regionBudget, skipK) : null;
28718
29056
  const maybeReplace = (v2) => {
28719
29057
  if (!plainTarget) return;
28720
- ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${walkerArg}.claimOnly(); if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
29058
+ const claim = promptExpr ? `${walkerArg}.claimOnly(undefined, ${promptExpr})` : `${walkerArg}.claimOnly()`;
29059
+ ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
29060
+ if (regionBudget && ctx2.markerless) ctx2.push(`${regionBudget} = 0;`);
28721
29061
  };
28722
29062
  const maybeRetire = () => {
28723
29063
  if (ctx2.selfClaimNames.has(node.componentName)) {
@@ -28746,9 +29086,13 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28746
29086
  ctx2.push(`return $f; })();`);
28747
29087
  propsEntries.push(`children: ${frag}`);
28748
29088
  }
29089
+ if (ctx2.markerless && promptExpr && !plainTarget) {
29090
+ ctx2.push(`${walkerArg}.injectSkipK(${promptExpr});`);
29091
+ }
28749
29092
  ctx2.push(`let ${v} = undefined;`);
28750
29093
  ctx2.push(`if (__hydrate) __hydrate.childFrame = (__hydrate.childFrame || 0) + 1;`);
28751
29094
  ctx2.push(`try { ${v} = ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}); } finally { if (__hydrate) __hydrate.childFrame--; }`);
29095
+ if (ctx2.markerless && promptExpr && !plainTarget && regionBudget) ctx2.push(`${regionBudget} = 0;`);
28752
29096
  maybeReplace(v);
28753
29097
  maybeRetire();
28754
29098
  return v;
@@ -28776,30 +29120,50 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28776
29120
  } else if (ctx2.importedNames.has(node.componentName)) {
28777
29121
  ctx2.push(`const ${v} = ${awaitKw}${node.componentName}(${callArgs()});`);
28778
29122
  } else {
29123
+ 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.`)});`);
28779
29124
  ctx2.push(`const ${v} = ${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()});`);
28780
29125
  }
28781
29126
  }
28782
29127
  return v;
28783
29128
  }
28784
- function emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, rootLevel) {
29129
+ function emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, rootLevel, offsetExpr) {
28785
29130
  if (!ctx2.hydrate || !rootLevel) return;
28786
29131
  ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
28787
- ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
28788
- ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${anchor});`));
28789
- ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
29132
+ ctx2.push(`if (${ctx2.walker} && ${ctx2.walker}.insertBeforeNextClaim) {`);
29133
+ ctx2.push(indent2(`${ctx2.walker}.insertBeforeNextClaim(${anchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
29134
+ ctx2.push(indent2(`${ctx2.walker}.insertBeforeNextClaim(${endAnchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
28790
29135
  ctx2.push(`}`);
28791
29136
  }
28792
- function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
29137
+ function regionBudgetVar(ctx2, skipK, regionBudget, inheritedInit) {
29138
+ if (!ctx2.markerless || !ctx2.hydrate) return null;
29139
+ if (skipK > 0) {
29140
+ const pk = ctx2.n();
29141
+ ctx2.push(`let ${pk} = ${skipK}; // first-claim budget: region SSR sits ${skipK} slot(s) past the walker cursor`);
29142
+ return pk;
29143
+ }
29144
+ if (inheritedInit) {
29145
+ const pk = ctx2.n();
29146
+ ctx2.push(`let ${pk} = ${inheritedInit}; // first-claim budget: inherited from the caller's walker residue`);
29147
+ return pk;
29148
+ }
29149
+ return regionBudget || null;
29150
+ }
29151
+ function markerlessSkipExpr(regionBudget, skipK) {
29152
+ if (regionBudget) return skipK > 0 ? `${regionBudget} + ${skipK}` : regionBudget;
29153
+ return String(skipK);
29154
+ }
29155
+ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar, skipK = 0, regionBudget) {
28793
29156
  const anchor = ctx2.n();
28794
29157
  const endAnchor = ctx2.n();
28795
29158
  const effArr = ctx2.n();
28796
29159
  const catchParam = node.catchParamName || "__e";
28797
29160
  const parent = parentVar || "$root";
29161
+ const budget = ctx2.hydrate ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
28798
29162
  ctx2.push(`const ${anchor} = document.createComment('try');`);
28799
29163
  if (!ctx2.hydrate) ctx2.push(`${parent}.appendChild(${anchor});`);
28800
29164
  ctx2.push(`let ${effArr} = [];`);
28801
29165
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
28802
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29166
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
28803
29167
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28804
29168
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
28805
29169
  const savedHydrate = ctx2.hydrate;
@@ -28817,7 +29181,7 @@ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28817
29181
  ctx2.push(indent2(`const __cl = [];`));
28818
29182
  }
28819
29183
  for (const child of body) {
28820
- const childVar = emitNode(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix);
29184
+ const childVar = emitNode(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix, 0, budget || void 0);
28821
29185
  if (childVar) {
28822
29186
  if (hydMode) ctx2.push(indent2(`__cl.push(${childVar});`));
28823
29187
  else ctx2.push(indent2(`__p.insertBefore(${childVar}, ${endAnchor});`));
@@ -28863,9 +29227,10 @@ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28863
29227
  }`);
28864
29228
  return null;
28865
29229
  }
28866
- function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
29230
+ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
28867
29231
  const hyd = ctx2.hydrate;
28868
29232
  const parent = parentVar || "$root";
29233
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
28869
29234
  const isOpaque = (n) => !!n && typeof n.condition !== "undefined";
28870
29235
  if (hyd && node.alternateNodes.length === 1 && isOpaque(node.alternateNodes[0])) {
28871
29236
  const chain = [];
@@ -28886,7 +29251,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28886
29251
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
28887
29252
  ctx2.push(`let ${effectsVar2} = [];`);
28888
29253
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
28889
- emitHydrateFenceAnchoring(ctx2, anchor2, endAnchor2, parent === "$root");
29254
+ emitHydrateFenceAnchoring(ctx2, anchor2, endAnchor2, parent === "$root", budget || void 0);
28890
29255
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
28891
29256
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
28892
29257
  const renderNames = [];
@@ -28899,7 +29264,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28899
29264
  for (const n of chain[i].nodes) {
28900
29265
  const savedClaim = ctx2.claimStatic;
28901
29266
  if (hyd) ctx2.claimStatic = true;
28902
- const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
29267
+ const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
28903
29268
  ctx2.claimStatic = savedClaim;
28904
29269
  if (v) ctx2.push(indent2(`${cl}.push(${v});`));
28905
29270
  }
@@ -28915,7 +29280,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28915
29280
  for (const n of finalElse) {
28916
29281
  const savedClaim = ctx2.claimStatic;
28917
29282
  if (hyd) ctx2.claimStatic = true;
28918
- const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
29283
+ const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
28919
29284
  ctx2.claimStatic = savedClaim;
28920
29285
  if (v) ctx2.push(indent2(`${cl2}.push(${v});`));
28921
29286
  }
@@ -28969,7 +29334,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28969
29334
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
28970
29335
  ctx2.push(`let ${effectsVar} = [];`);
28971
29336
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
28972
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29337
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
28973
29338
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28974
29339
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
28975
29340
  const conRenderName = ctx2.n();
@@ -28981,7 +29346,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28981
29346
  for (const n of node.consequentNodes) {
28982
29347
  const savedClaim = ctx2.claimStatic;
28983
29348
  if (hyd) ctx2.claimStatic = true;
28984
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
29349
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag, "__components", 0, budget || void 0);
28985
29350
  ctx2.claimStatic = savedClaim;
28986
29351
  if (v) {
28987
29352
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
@@ -29002,7 +29367,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
29002
29367
  for (const n of node.alternateNodes) {
29003
29368
  const savedAltClaim = ctx2.claimStatic;
29004
29369
  if (hyd) ctx2.claimStatic = true;
29005
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
29370
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag, "__components", 0, budget || void 0);
29006
29371
  ctx2.claimStatic = savedAltClaim;
29007
29372
  if (v) {
29008
29373
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
@@ -29043,18 +29408,19 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
29043
29408
  }
29044
29409
  return null;
29045
29410
  }
29046
- function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29411
+ function emitWhileLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
29047
29412
  const condExpr = transformTracked(node.condition, tracked2);
29048
29413
  const anchor = ctx2.n();
29049
29414
  const endAnchor = ctx2.n();
29050
29415
  const effectsVar = ctx2.n();
29051
29416
  const hyd = ctx2.hydrate;
29052
29417
  const parent = parentVar || "$root";
29418
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29053
29419
  ctx2.push(`const ${anchor} = document.createComment('while');`);
29054
29420
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29055
29421
  ctx2.push(`let ${effectsVar} = [];`);
29056
29422
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
29057
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29423
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
29058
29424
  const renderLoop = ctx2.n();
29059
29425
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29060
29426
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29063,7 +29429,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29063
29429
  if (node.isDoWhile) {
29064
29430
  ctx2.push(indent2(`do {`));
29065
29431
  for (const n of node.bodyTemplate) {
29066
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29432
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29067
29433
  if (v) {
29068
29434
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29069
29435
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29073,7 +29439,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29073
29439
  } else {
29074
29440
  ctx2.push(indent2(`while (${condExpr}) {`));
29075
29441
  for (const n of node.bodyTemplate) {
29076
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29442
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29077
29443
  if (v) {
29078
29444
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29079
29445
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29107,17 +29473,18 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
29107
29473
  }`);
29108
29474
  return null;
29109
29475
  }
29110
- function emitForLoop(ctx2, node, tracked2, parentVar) {
29476
+ function emitForLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
29111
29477
  const anchor = ctx2.n();
29112
29478
  const endAnchor = ctx2.n();
29113
29479
  const effectsVar = ctx2.n();
29114
29480
  const hyd = ctx2.hydrate;
29115
29481
  const parent = parentVar || "$root";
29482
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29116
29483
  ctx2.push(`const ${anchor} = document.createComment('for');`);
29117
29484
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29118
29485
  ctx2.push(`let ${effectsVar} = [];`);
29119
29486
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
29120
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29487
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
29121
29488
  const renderLoop = ctx2.n();
29122
29489
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29123
29490
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29127,7 +29494,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29127
29494
  const srcExpr = transformTracked(node.condition, tracked2);
29128
29495
  ctx2.push(indent2(`for (${node.init} of (Array.isArray(${srcExpr}) ? ${srcExpr} : (${srcExpr} == null ? [] : Object.keys(${srcExpr})))) {`));
29129
29496
  for (const n of node.bodyTemplate) {
29130
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29497
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29131
29498
  if (v) {
29132
29499
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29133
29500
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29143,7 +29510,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29143
29510
  const head = initPart ? `${initPart}; ${condExpr}` : `; ${condExpr}`;
29144
29511
  ctx2.push(indent2(`for (${head}; ${updatePart}) {`));
29145
29512
  for (const n of node.bodyTemplate) {
29146
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
29513
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
29147
29514
  if (v) {
29148
29515
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29149
29516
  else ctx2.push(indent2(`__b.appendChild(${v});`));
@@ -29247,18 +29614,19 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29247
29614
  }
29248
29615
  return null;
29249
29616
  }
29250
- function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29617
+ function emitSwitchBlock(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
29251
29618
  const discExpr = transformTracked(node.discriminant, tracked2);
29252
29619
  const anchor = ctx2.n();
29253
29620
  const endAnchor = ctx2.n();
29254
29621
  const effectsVar = ctx2.n();
29255
29622
  const hyd = ctx2.hydrate;
29256
29623
  const parent = parentVar || "$root";
29624
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29257
29625
  ctx2.push(`const ${anchor} = document.createComment('switch');`);
29258
29626
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29259
29627
  ctx2.push(`let ${effectsVar} = [];`);
29260
29628
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
29261
- emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29629
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
29262
29630
  const renderSwitch = ctx2.n();
29263
29631
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29264
29632
  if (hyd) {
@@ -29275,7 +29643,7 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29275
29643
  ctx2.push(indent2(`default:`));
29276
29644
  }
29277
29645
  for (const n of c.body) {
29278
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c");
29646
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c", "__components", 0, budget || void 0);
29279
29647
  if (v) {
29280
29648
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
29281
29649
  else ctx2.push(indent2(`__c.appendChild(${v});`));
@@ -29310,7 +29678,7 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29310
29678
  }`);
29311
29679
  return null;
29312
29680
  }
29313
- function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29681
+ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
29314
29682
  const arrExpr = transformTracked(node.expression, tracked2);
29315
29683
  const itemVar = node.itemVariable;
29316
29684
  const anchor = ctx2.n();
@@ -29322,6 +29690,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29322
29690
  const hyd = ctx2.hydrate && !keyed;
29323
29691
  const hydKeyed = ctx2.hydrate && keyed;
29324
29692
  const parent = parentVar || "$root";
29693
+ const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
29325
29694
  const reactiveSource = isReactiveExpression(node.expression, tracked2);
29326
29695
  const pushEffect = (lets, effCall) => {
29327
29696
  if (effTarget) {
@@ -29353,7 +29722,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29353
29722
  }
29354
29723
  if (hydKeyed) ctx2.rootClaim = true;
29355
29724
  for (const n of node.bodyTemplate) {
29356
- const v = emitNode(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it");
29725
+ const v = emitNode(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it", "__components", 0, budget || void 0);
29357
29726
  if (v) {
29358
29727
  if (hyd) {
29359
29728
  ctx2.push(indent2(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, __r);`));
@@ -29380,7 +29749,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29380
29749
  if (hydKeyed) ctx2.hydrate = false;
29381
29750
  for (const n of node.alternateNodes) {
29382
29751
  ctx2.claimStatic = true;
29383
- const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag);
29752
+ const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag, "__components", 0, budget || void 0);
29384
29753
  if (v) {
29385
29754
  if (hyd) ctx2.push(indent2(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, ${endAnchor});`));
29386
29755
  else ctx2.push(indent2(`${frag}.appendChild(${v});`));
@@ -29401,7 +29770,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar) {
29401
29770
  const initList = ctx2.n();
29402
29771
  ctx2.push(`let ${reconciler} = () => {};`);
29403
29772
  if (hydKeyed) {
29404
- ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}); };`);
29773
+ 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}); };`);
29405
29774
  } else {
29406
29775
  ctx2.push(`const ${initList} = () => { ${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
29407
29776
  }
@@ -29499,13 +29868,14 @@ ${renderAllItems(" ", null)}
29499
29868
  function computeAsyncComponents(comps) {
29500
29869
  return new Set(comps.filter((c) => c.isAsync).map((c) => c.name));
29501
29870
  }
29502
- function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc) {
29871
+ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc, markerless = true) {
29503
29872
  const tracked2 = collectTrackedNames(comp.body);
29504
29873
  const ctx2 = new Ctx(alloc);
29505
29874
  ctx2.importedNames = importedNames;
29506
29875
  ctx2.linkNames = linkNames;
29507
29876
  ctx2.selfClaimNames = selfClaimNames;
29508
29877
  ctx2.hydrate = hydrate;
29878
+ ctx2.markerless = markerless;
29509
29879
  ctx2.asyncComps = asyncComps;
29510
29880
  ctx2.isAsyncScope = comp.isAsync || asyncComps.has(comp.name);
29511
29881
  ctx2.push(hydrate ? ctx2.isAsyncScope ? "async (props, __registry, __hydrate) => {" : "(props, __registry, __hydrate) => {" : ctx2.isAsyncScope ? "async (props) => {" : "(props) => {");
@@ -29533,9 +29903,19 @@ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydr
29533
29903
  emitNode(ctx2, node, tracked2, null);
29534
29904
  }
29535
29905
  }
29906
+ let topPendingSkip = 0;
29907
+ let topBudget = null;
29908
+ if (ctx2.markerless && ctx2.hydrate) {
29909
+ topBudget = regionBudgetVar(
29910
+ ctx2,
29911
+ 0,
29912
+ void 0,
29913
+ `(typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0)`
29914
+ );
29915
+ }
29536
29916
  for (const node of comp.body) {
29537
29917
  if (node instanceof TrackDecl) continue;
29538
- const v = emitNode(ctx2, node, tracked2, null);
29918
+ const v = emitNode(ctx2, node, tracked2, null, void 0, "__components", topPendingSkip, topBudget || void 0);
29539
29919
  if (v) {
29540
29920
  if (ctx2.hydrate) {
29541
29921
  ctx2.push(indent2(`if ($mount === null) $mount = ${v};`));
@@ -29544,6 +29924,10 @@ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydr
29544
29924
  ctx2.push(indent2(`$root.appendChild(${v});`));
29545
29925
  }
29546
29926
  }
29927
+ if (claimsWalkerNode(ctx2, node)) {
29928
+ topBudget = null;
29929
+ topPendingSkip = 0;
29930
+ } else topPendingSkip += ssrResidueEstimate(node);
29547
29931
  }
29548
29932
  const effCode = ctx2.flushEffects();
29549
29933
  if (effCode) ctx2.push(indent2(effCode.trim()));
@@ -29566,7 +29950,7 @@ function buildParamInit2(paramNames) {
29566
29950
  if (paramNames.length === 0) return "";
29567
29951
  return `const { ${paramNames.join(", ")} } = props;`;
29568
29952
  }
29569
- function buildComponentMap(irRoot, hydrate = false, alloc) {
29953
+ function buildComponentMap(irRoot, hydrate = false, alloc, markerless = true) {
29570
29954
  const mapLines = [];
29571
29955
  mapLines.push(`const __components = {};`);
29572
29956
  const asyncComps = computeAsyncComponents(irRoot.components);
@@ -29587,11 +29971,12 @@ function buildComponentMap(irRoot, hydrate = false, alloc) {
29587
29971
  const directNames = /* @__PURE__ */ new Set([...extractRuntimeNames(irRoot.imports), ...localValueImportNames(irRoot.imports), ...topValueNames]);
29588
29972
  for (const comp of irRoot.components) {
29589
29973
  if (hydrate && isStaticComponent(comp)) {
29590
- const stub = `(props, __registry, __hydrate) => { return __hydrate.claimOnly(); }`;
29974
+ const claimExpr = markerless ? `__hydrate.claimOnly(undefined, (typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0))` : `__hydrate.claimOnly()`;
29975
+ const stub = `(props, __registry, __hydrate) => { return ${claimExpr}; }`;
29591
29976
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${stub};`);
29592
29977
  continue;
29593
29978
  }
29594
- const code = generateComponent(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc);
29979
+ const code = generateComponent(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc, markerless);
29595
29980
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${code};`);
29596
29981
  }
29597
29982
  mapLines.push(`function __cleanup(start, end) {`);
@@ -29612,6 +29997,12 @@ function buildComponentMap(irRoot, hydrate = false, alloc) {
29612
29997
  mapLines.push(` const p = nodes[0].parentNode;`);
29613
29998
  mapLines.push(` p.insertBefore(start, nodes[0]);`);
29614
29999
  mapLines.push(` p.insertBefore(end, nodes[nodes.length - 1].nextSibling);`);
30000
+ mapLines.push(` // Client-surplus nodes (SSR rendered fewer items than the client data)`);
30001
+ mapLines.push(` // are freshly claimed and still detached \u2014 move them into the region in`);
30002
+ mapLines.push(` // client order before \`end\`, instead of stranding them off-parent.`);
30003
+ mapLines.push(` for (let i = 0; i < nodes.length; i++) {`);
30004
+ mapLines.push(` if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);`);
30005
+ mapLines.push(` }`);
29615
30006
  mapLines.push(` return;`);
29616
30007
  mapLines.push(` }`);
29617
30008
  mapLines.push(` fallback.appendChild(start);`);
@@ -29662,6 +30053,17 @@ function isStaticIR(body) {
29662
30053
  }
29663
30054
  return true;
29664
30055
  }
30056
+ function claimsWalkerNode(ctx2, node) {
30057
+ if (node instanceof StaticNode) return ctx2.claimStatic || !isStaticIR(node.children);
30058
+ if (node instanceof ComponentCall) return true;
30059
+ if (node instanceof OpaqueDynamicRegion) return true;
30060
+ if (node instanceof MapRegion) return true;
30061
+ if (node instanceof ForLoop) return true;
30062
+ if (node instanceof WhileLoop) return true;
30063
+ if (node instanceof SwitchBlock) return true;
30064
+ if (node instanceof TryCatch) return true;
30065
+ return false;
30066
+ }
29665
30067
  function isStaticComponent(comp) {
29666
30068
  if (comp.style) return false;
29667
30069
  return isStaticIR(comp.body);
@@ -29790,7 +30192,7 @@ function emitClientFromIR(ir, options) {
29790
30192
  if (!options.forceClient && !needsClient) {
29791
30193
  return "";
29792
30194
  }
29793
- const componentMapCode = buildComponentMap(ir, options.hydrate, options.nameAllocator);
30195
+ const componentMapCode = buildComponentMap(ir, options.hydrate, options.nameAllocator, options.markerless !== false);
29794
30196
  const importLines = ir.imports.length > 0 ? ir.imports.join("\n") + "\n" : "";
29795
30197
  const topCode = (options.includeTopLevel === false ? [] : transformTopLevelForActions(ir.topLevelCode, "client")).join("\n") + "\n";
29796
30198
  const exportLines = [];
@@ -29868,7 +30270,7 @@ function compileClientBoth(source, _componentName, sourcePath2, opts) {
29868
30270
  if (opts?.skipHyd) return { comp, hyd: "", name };
29869
30271
  return {
29870
30272
  comp,
29871
- hyd: emitClientFromIR(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc }),
30273
+ hyd: emitClientFromIR(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
29872
30274
  name
29873
30275
  };
29874
30276
  }
@@ -29933,6 +30335,12 @@ var init_client_codegen = __esm({
29933
30335
  delegatedEvents = /* @__PURE__ */ new Set();
29934
30336
  directEvents = /* @__PURE__ */ new Set();
29935
30337
  hydrate = false;
30338
+ // Markerless structural hydration: claims run `nextElement(tag, skipK)` with
30339
+ // positional residue offsets and interior claims rebind the walker to the
30340
+ // claimed element (subWalker). Only meaningful when `hydrate` is also true.
30341
+ // Markerless is the DEFAULT; pass `markerless: false` to restore legacy
30342
+ // marker-mode claim emission.
30343
+ markerless = true;
29936
30344
  inTryBody = false;
29937
30345
  claimStatic = false;
29938
30346
  // While set, the next StaticNode claimed in hydrate mode uses `__root` (the
@@ -30041,6 +30449,7 @@ function irNodeToJS(node, importedNames, isAsync = false, tracked2) {
30041
30449
  }
30042
30450
  if (node instanceof RuntimeStatement) return semicolonizeStatement(transformTracked(node, tracked2 || /* @__PURE__ */ new Map()));
30043
30451
  if (node instanceof SlotNode) {
30452
+ if (__vskMarkerless) return `__out.push(props.children || '');`;
30044
30453
  const sid = `s${nextVskId()}`;
30045
30454
  return `__out.push('<!--vsk-slot:${sid}-->');__out.push(props.children || '');__out.push('<!--vsk-slot-end:${sid}-->');`;
30046
30455
  }
@@ -30070,7 +30479,7 @@ function staticNodeToJS(node, isAsync = false, tracked2) {
30070
30479
  let openTag = `<${node.tag}`;
30071
30480
  const forceClaim = takeVskForceClaim();
30072
30481
  const subtreeNeedsJS = __vskHydrate && (forceClaim || !isStaticIR(node.children));
30073
- if (subtreeNeedsJS) {
30482
+ if (subtreeNeedsJS && !__vskMarkerless) {
30074
30483
  lines.push("__out.push(" + JSON.stringify(`<!--vsk:t:${sanitizeMarkerName(node.tag)}-->`) + ");");
30075
30484
  }
30076
30485
  for (const attr of node.attributes) {
@@ -30163,7 +30572,7 @@ function mapRegionToJS(node, isAsync = false, tracked2) {
30163
30572
  const lines = [];
30164
30573
  const arr = exprJSX(node.expression, tracked2);
30165
30574
  const item = node.itemVariable;
30166
- const bodyForItem = __vskHydrate && node.keyExpr ? keyedItemTemplate(node) : node.bodyTemplate;
30575
+ const bodyForItem = __vskHydrate && !__vskMarkerless && node.keyExpr ? keyedItemTemplate(node) : node.bodyTemplate;
30167
30576
  const hasAlternate = node.alternateNodes.length > 0;
30168
30577
  const arrVar = hasAlternate ? `__a${nextVskId()}` : null;
30169
30578
  if (hasAlternate) {
@@ -30344,8 +30753,11 @@ function componentCallToJS(node, importedNames, isAsync = false, tracked2) {
30344
30753
  const awaitKw = isAsync ? "await " : "";
30345
30754
  const calleeVar = `__cc${nextVskId()}`;
30346
30755
  lines.push(`const ${calleeVar} = ${callee};`);
30756
+ if (!node.calleeExpr) {
30757
+ 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.`)});`);
30758
+ }
30347
30759
  const callExpr3 = `${awaitKw}${calleeVar}(${propsObj}, __registry, (${calleeVar}.__veskScope || __vesk))`;
30348
- if (__vskHydrate) {
30760
+ if (__vskHydrate && !__vskMarkerless) {
30349
30761
  lines.push(`__out.push(${JSON.stringify(componentMarker(compName))} + (${callExpr3} || ''));`);
30350
30762
  } else {
30351
30763
  lines.push(`__out.push(${callExpr3} || '');`);
@@ -30551,7 +30963,7 @@ function compileFileInternal(source, sourcePath2, seenImportFiles) {
30551
30963
  return { ir, componentMap, __vesk };
30552
30964
  }
30553
30965
  function render2(source, componentName, props = {}, registry = /* @__PURE__ */ new Map(), options = {}) {
30554
- resetVskState(!!options.hydrate);
30966
+ resetVskState(!!options.hydrate, options.markerless !== false);
30555
30967
  const compiled = compileFile(source, { sourcePath: options.sourcePath || void 0 });
30556
30968
  const componentMap = compiled.componentMap;
30557
30969
  const renderFn = componentMap.get(componentName);
@@ -30586,7 +30998,7 @@ function render2(source, componentName, props = {}, registry = /* @__PURE__ */ n
30586
30998
  return bodyHtml;
30587
30999
  }
30588
31000
  function renderPage(source, componentName, props = {}, registry = /* @__PURE__ */ new Map(), options = {}) {
30589
- resetVskState(!!options.hydrate);
31001
+ resetVskState(!!options.hydrate, options.markerless !== false);
30590
31002
  let __vesk, componentMap, ir;
30591
31003
  if (options.cached) {
30592
31004
  const cached = options.cached;
@@ -30735,10 +31147,10 @@ async function ssg(source, componentName, customProps, options = {}) {
30735
31147
  if (c.style) return true;
30736
31148
  return !isStatic(c.body);
30737
31149
  });
30738
- const rendered = await renderPage(source, componentName, props, options.registry || /* @__PURE__ */ new Map(), { hydrate: needsClient });
31150
+ const rendered = await renderPage(source, componentName, props, options.registry || /* @__PURE__ */ new Map(), { hydrate: needsClient, markerless: options.markerless !== false });
30739
31151
  const bodyHtml = rendered.body;
30740
31152
  const headHtml = rendered.head;
30741
- const clientCode = needsClient ? compileClient(source, null, { hydrate: true }) : "";
31153
+ const clientCode = needsClient ? compileClient(source, null, { hydrate: true, markerless: options.markerless !== false }) : "";
30742
31154
  const serializedProps = safeJsonForScript(JSON.stringify(props));
30743
31155
  const hasClient = clientCode.length > 0;
30744
31156
  const scriptBlock = hasClient ? `
@@ -30914,7 +31326,7 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
30914
31326
  const fullRegistry = new Map([...registry, ...componentMap]);
30915
31327
  const renderFn = componentMap.get(componentName);
30916
31328
  if (!renderFn) throw new Error(`Component "${componentName}" not found in source`);
30917
- resetVskState(!!options.hydrate);
31329
+ resetVskState(!!options.hydrate, options.markerless !== false);
30918
31330
  const targetComp = ir.components.find((c) => c.name === componentName);
30919
31331
  const cssUrls = options.cssUrls || (options.cssUrl ? [options.cssUrl] : []);
30920
31332
  const cssLink = cssUrls.map((u) => ` <link rel="stylesheet" href="${u}" />
@@ -31076,7 +31488,7 @@ import {
31076
31488
  readFileSync as readFileSync16,
31077
31489
  writeFileSync as writeFileSync7,
31078
31490
  existsSync as existsSync16,
31079
- mkdirSync as mkdirSync5,
31491
+ mkdirSync as mkdirSync6,
31080
31492
  statSync as statSync7
31081
31493
  } from "node:fs";
31082
31494
  import { resolve as resolve14, dirname as dirname11, join as join10, extname as extname4, basename } from "node:path";
@@ -31114,7 +31526,7 @@ function readPluginState(veskDir) {
31114
31526
  function writePluginState(veskDir, state) {
31115
31527
  const file = stateFilePath(veskDir);
31116
31528
  const dir = dirname11(file);
31117
- if (!existsSync16(dir)) mkdirSync5(dir, { recursive: true });
31529
+ if (!existsSync16(dir)) mkdirSync6(dir, { recursive: true });
31118
31530
  writeFileSync7(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
31119
31531
  }
31120
31532
  function resolvePackage(appDir, pkg) {
@@ -31993,15 +32405,15 @@ __export(static_exports, {
31993
32405
  generateSitemap: () => generateSitemap,
31994
32406
  generateSsgRoutes: () => generateSsgRoutes
31995
32407
  });
31996
- 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";
32408
+ 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";
31997
32409
  import { resolve as resolve15, join as join11 } from "node:path";
31998
32410
  function copyStaticAssets2(publicDir, outDir) {
31999
32411
  const targetDir = resolve15(outDir, "static", "public");
32000
- mkdirSync6(targetDir, { recursive: true });
32412
+ mkdirSync7(targetDir, { recursive: true });
32001
32413
  if (!existsSync17(publicDir))
32002
32414
  return;
32003
32415
  function copyDir(src2, dest) {
32004
- mkdirSync6(dest, { recursive: true });
32416
+ mkdirSync7(dest, { recursive: true });
32005
32417
  const entries = readdirSync3(src2);
32006
32418
  for (const entry of entries) {
32007
32419
  const srcPath = join11(src2, entry);
@@ -32019,7 +32431,7 @@ function copyStaticAssets2(publicDir, outDir) {
32019
32431
  async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra, cssUrls) {
32020
32432
  const { ssg: ssg2 } = await Promise.resolve().then(() => (init_server_render(), server_render_exports));
32021
32433
  const prerenderDir = resolve15(outDir, "prerendered");
32022
- mkdirSync6(prerenderDir, { recursive: true });
32434
+ mkdirSync7(prerenderDir, { recursive: true });
32023
32435
  const ssgOptions = { plugins, headExtra, cssUrls };
32024
32436
  const results = [];
32025
32437
  async function evaluateExport(src2, exportName) {
@@ -32056,7 +32468,7 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
32056
32468
  console.error(`vesk: SSG path escaped output dir \u2014 skipping ${pagePath} (path: ${urlPath})`);
32057
32469
  continue;
32058
32470
  }
32059
- mkdirSync6(resolve15(htmlPath, ".."), { recursive: true });
32471
+ mkdirSync7(resolve15(htmlPath, ".."), { recursive: true });
32060
32472
  writeFileSync8(htmlPath, result.html);
32061
32473
  results.push({ path: urlPath, html: htmlPath, static: result.static, params });
32062
32474
  } catch (e) {
@@ -32069,7 +32481,7 @@ async function generateSsgRoutes(routeTree, appDir, outDir, plugins, headExtra,
32069
32481
  try {
32070
32482
  const result = await ssg2(src2, null, void 0, ssgOptions);
32071
32483
  const htmlPath = resolve15(prerenderDir, node.fullPath === "/" ? "index.html" : `${node.fullPath.slice(1)}.html`);
32072
- mkdirSync6(resolve15(htmlPath, ".."), { recursive: true });
32484
+ mkdirSync7(resolve15(htmlPath, ".."), { recursive: true });
32073
32485
  writeFileSync8(htmlPath, result.html);
32074
32486
  results.push({ path: node.fullPath, html: htmlPath, static: result.static });
32075
32487
  } catch (e) {
@@ -32139,7 +32551,7 @@ var image_pipeline_exports = {};
32139
32551
  __export(image_pipeline_exports, {
32140
32552
  optimizeImages: () => optimizeImages
32141
32553
  });
32142
- import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
32554
+ import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
32143
32555
  import { resolve as resolve16, extname as extname5, dirname as dirname12 } from "node:path";
32144
32556
  async function processImage(srcPath, outDir, baseName) {
32145
32557
  const image = sharpFn ? sharpFn(srcPath) : null;
@@ -32147,7 +32559,7 @@ async function processImage(srcPath, outDir, baseName) {
32147
32559
  const original = readFileSync18(srcPath);
32148
32560
  for (const w of OUTPUT_WIDTHS) {
32149
32561
  const outputPath = resolve16(outDir, `${baseName}-${w}w`);
32150
- mkdirSync7(dirname12(outputPath), { recursive: true });
32562
+ mkdirSync8(dirname12(outputPath), { recursive: true });
32151
32563
  writeFileSync9(outputPath, original);
32152
32564
  }
32153
32565
  return [];
@@ -32161,7 +32573,7 @@ async function processImage(srcPath, outDir, baseName) {
32161
32573
  const resized = image.clone().resize({ width: w, withoutEnlargement: true });
32162
32574
  const base = `${baseName}-${w}w`;
32163
32575
  const jpgPath = resolve16(outDir, `${base}${extname5(srcPath)}`);
32164
- mkdirSync7(dirname12(jpgPath), { recursive: true });
32576
+ mkdirSync8(dirname12(jpgPath), { recursive: true });
32165
32577
  await resized.toFile(jpgPath);
32166
32578
  generated.push(jpgPath);
32167
32579
  for (const fmt of FORMATS) {
@@ -32203,7 +32615,7 @@ function collectImageRefs(appDir) {
32203
32615
  }
32204
32616
  async function optimizeImages(appDir, outDir) {
32205
32617
  const imageOutDir = resolve16(outDir, "static", "images");
32206
- mkdirSync7(imageOutDir, { recursive: true });
32618
+ mkdirSync8(imageOutDir, { recursive: true });
32207
32619
  const refs = collectImageRefs(appDir);
32208
32620
  if (refs.length === 0) {
32209
32621
  console.error("vesk images: no <Image> refs found");
@@ -32544,6 +32956,30 @@ ${prerenderedList}
32544
32956
  ${isrCache}
32545
32957
  const __routes = [${routeEntries.join(",\n")}];
32546
32958
 
32959
+ async function __invokeRoute(route, request) {
32960
+ try {
32961
+ return await route.handler(request);
32962
+ } catch (e) {
32963
+ if (e && typeof e === 'object' && e.name === 'Redirect') {
32964
+ return new Response(null, {
32965
+ status: Number(e.status) || 302,
32966
+ headers: { Location: String(e.url || '/') },
32967
+ });
32968
+ }
32969
+ if (e && typeof e === 'object' && e.name === 'NotFoundError') {
32970
+ return new Response('<!DOCTYPE html><html><body><h1>404</h1><p>Not Found</p></body></html>', {
32971
+ status: 404,
32972
+ headers: { 'Content-Type': 'text/html' },
32973
+ });
32974
+ }
32975
+ throw e;
32976
+ }
32977
+ }
32978
+
32979
+ function __escapeScript(json) {
32980
+ return json.split('<').join('\\u003c').split('\\u2028').join('\\u2028').split('\\u2029').join('\\u2029');
32981
+ }
32982
+
32547
32983
  function __matchPath(pattern, pathname) {
32548
32984
  const patternParts = pattern.split('/').filter(Boolean);
32549
32985
  const pathParts = pathname.split('/').filter(Boolean);
@@ -32574,6 +33010,24 @@ ${serverStoreLine}
32574
33010
  return new Response(null, { status: 308, headers: { Location: '/_vesk/static/public' + (pathname.endsWith('/') ? pathname + 'index.html' : pathname + '.html') } });
32575
33011
  }
32576
33012
 
33013
+ // Serve the SSR-data handoff the page references (script tag /ssr-data.js?t=...).
33014
+ // The render stashed the payload in the shared global store \u2014 mirror the node
33015
+ // prod/dev servers so edge/serverless hydration never re-fetches resources that
33016
+ // SSR already resolved. Entry is consumed on read (bound store).
33017
+ if (pathname === '/ssr-data.js') {
33018
+ const dataToken = url.searchParams.get('t') || '';
33019
+ const dataStore = (globalThis.__vsk_ssr_data_store || {});
33020
+ const payload = dataStore[dataToken];
33021
+ if (payload) delete dataStore[dataToken];
33022
+ const dataLines = [];
33023
+ if (payload && payload.props) dataLines.push('globalThis.__vesk_props = ' + __escapeScript(JSON.stringify(payload.props)) + ';');
33024
+ if (payload && payload.ssrData) dataLines.push('globalThis.__vsk_ssr_data = ' + __escapeScript(JSON.stringify(payload.ssrData)) + ';');
33025
+ return new Response(dataLines.join('\\n') || '// no ssr data', {
33026
+ status: 200,
33027
+ headers: { 'Content-Type': 'application/javascript', 'Cache-Control': 'no-store' },
33028
+ });
33029
+ }
33030
+
32577
33031
  ${eventsStartLine}
32578
33032
  let mwCtx = { params: {}, url, locals: ${localsSeed}, cookies: {}, request, resolveUrl(u) { return new URL(u, request.url).href; }, set() {}, get() { return undefined; } };
32579
33033
  if (${hasMwLiteral}) {
@@ -32603,7 +33057,7 @@ ${eventsRequestLine}
32603
33057
  if (!params) continue;
32604
33058
 
32605
33059
  if (route.type === 'api') {
32606
- return await route.handler(request);
33060
+ return await __invokeRoute(route, request);
32607
33061
  }
32608
33062
 
32609
33063
  if (route.revalidate && route.revalidate > 0 && !isDataRequest) {
@@ -32616,7 +33070,7 @@ ${eventsRequestLine}
32616
33070
  }
32617
33071
  }
32618
33072
 
32619
- const response = await route.handler(request);
33073
+ const response = await __invokeRoute(route, request);
32620
33074
 
32621
33075
  if (route.revalidate && route.revalidate > 0 && !isDataRequest) {
32622
33076
  const html = await response.clone().text();
@@ -32727,7 +33181,7 @@ var init_platform_handler = __esm({
32727
33181
 
32728
33182
  // ../adapter/src/platform-output.ts
32729
33183
  import {
32730
- mkdirSync as mkdirSync8,
33184
+ mkdirSync as mkdirSync9,
32731
33185
  copyFileSync as copyFileSync3,
32732
33186
  readdirSync as readdirSync6,
32733
33187
  statSync as statSync11,
@@ -32739,28 +33193,28 @@ import {
32739
33193
  import { resolve as resolve19, join as join13, extname as extname6, dirname as dirname14 } from "node:path";
32740
33194
  function ensureCleanDir(dir) {
32741
33195
  rmSync2(dir, { recursive: true, force: true });
32742
- mkdirSync8(dir, { recursive: true });
33196
+ mkdirSync9(dir, { recursive: true });
32743
33197
  }
32744
33198
  function copyDirContents(srcDir, destDir) {
32745
33199
  if (!existsSync21(srcDir)) return;
32746
- mkdirSync8(destDir, { recursive: true });
33200
+ mkdirSync9(destDir, { recursive: true });
32747
33201
  for (const entry of readdirSync6(srcDir)) {
32748
33202
  const srcPath = join13(srcDir, entry);
32749
33203
  const destPath = join13(destDir, entry);
32750
33204
  if (statSync11(srcPath).isDirectory()) {
32751
33205
  copyDirContents(srcPath, destPath);
32752
33206
  } else {
32753
- mkdirSync8(dirname14(destPath), { recursive: true });
33207
+ mkdirSync9(dirname14(destPath), { recursive: true });
32754
33208
  copyFileSync3(srcPath, destPath);
32755
33209
  }
32756
33210
  }
32757
33211
  }
32758
33212
  function writeFile(path, content) {
32759
- mkdirSync8(dirname14(path), { recursive: true });
33213
+ mkdirSync9(dirname14(path), { recursive: true });
32760
33214
  writeFileSync10(path, content, "utf-8");
32761
33215
  }
32762
33216
  function writePlatformStatic(buildStaticDir, platformStaticDir) {
32763
- mkdirSync8(platformStaticDir, { recursive: true });
33217
+ mkdirSync9(platformStaticDir, { recursive: true });
32764
33218
  const publicDir = resolve19(buildStaticDir, "public");
32765
33219
  if (existsSync21(publicDir)) {
32766
33220
  copyDirContents(publicDir, platformStaticDir);
@@ -32770,7 +33224,7 @@ function writePlatformStatic(buildStaticDir, platformStaticDir) {
32770
33224
  const runtimeAlias = resolve19(platformStaticDir, "_vesk", "runtime.js");
32771
33225
  const clientPath = resolve19(buildStaticDir, "client.js");
32772
33226
  if (existsSync21(clientPath)) {
32773
- mkdirSync8(dirname14(runtimeAlias), { recursive: true });
33227
+ mkdirSync9(dirname14(runtimeAlias), { recursive: true });
32774
33228
  copyFileSync3(clientPath, runtimeAlias);
32775
33229
  }
32776
33230
  }
@@ -32844,7 +33298,7 @@ var platform_deploy_exports = {};
32844
33298
  __export(platform_deploy_exports, {
32845
33299
  emitPlatformOutput: () => emitPlatformOutput
32846
33300
  });
32847
- import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync9, rmSync as rmSync3, cpSync } from "node:fs";
33301
+ import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync10, rmSync as rmSync3, cpSync } from "node:fs";
32848
33302
  import { resolve as resolve20 } from "node:path";
32849
33303
  async function emitPlatformOutput(platform, ctx2) {
32850
33304
  if (platform === "node") return null;
@@ -32883,7 +33337,7 @@ ${shell.bootstrap}
32883
33337
  let handlerRel;
32884
33338
  if (shell.functionFile) {
32885
33339
  const funcDir = resolve20(outRoot, shell.functionFile.dir);
32886
- mkdirSync9(funcDir, { recursive: true });
33340
+ mkdirSync10(funcDir, { recursive: true });
32887
33341
  if (shell.functionConfig) {
32888
33342
  writeFileSync11(resolve20(funcDir, ".vc-config.json"), JSON.stringify(shell.functionConfig, null, 2), "utf-8");
32889
33343
  writeFileSync11(resolve20(funcDir, "package.json"), JSON.stringify({ type: "module" }, null, 2) + "\n", "utf-8");
@@ -38164,7 +38618,7 @@ declare module '@vesk/runtime' {
38164
38618
  });
38165
38619
 
38166
38620
  // src/index.ts
38167
- import { readFileSync as readFileSync40, writeFileSync as writeFileSync21, mkdirSync as mkdirSync18, existsSync as existsSync43 } from "fs";
38621
+ import { readFileSync as readFileSync40, writeFileSync as writeFileSync21, mkdirSync as mkdirSync20, existsSync as existsSync43 } from "fs";
38168
38622
  import { resolve as resolve40, join as join26 } from "path";
38169
38623
  import { fileURLToPath as fileURLToPath9 } from "url";
38170
38624
 
@@ -38734,7 +39188,7 @@ function setRuntimeModule2(mod) {
38734
39188
  }
38735
39189
 
38736
39190
  // ../adapter/dist/index.js
38737
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as readFileSync21 } from "node:fs";
39191
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as readFileSync21 } from "node:fs";
38738
39192
  import { resolve as resolve21, dirname as dirname16, relative as relative4, basename as basename2 } from "node:path";
38739
39193
  import { fileURLToPath as fileURLToPath5 } from "node:url";
38740
39194
 
@@ -39970,9 +40424,10 @@ init_esbuild_fallback();
39970
40424
  init_strip_ts();
39971
40425
  init_parser();
39972
40426
  init_client_codegen();
39973
- import { readFileSync as readFileSync11, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync3, rmSync, mkdtempSync } from "node:fs";
40427
+ import { readFileSync as readFileSync11, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync3, rmSync, mkdtempSync, mkdirSync as mkdirSync3 } from "node:fs";
39974
40428
  import { resolve as resolve10, join as join7, dirname as dirname8, relative as relative2, sep } from "node:path";
39975
40429
  import { fileURLToPath as fileURLToPath2 } from "node:url";
40430
+ import { tmpdir } from "node:os";
39976
40431
  init_vsk_imports();
39977
40432
  init_md_inline();
39978
40433
  init_module_imports();
@@ -40722,7 +41177,19 @@ function runtimeExportNames(runtimeDir) {
40722
41177
  return names;
40723
41178
  }
40724
41179
  var RUNTIME_ENTRY = ".runtime-tree-entry.mjs";
40725
- async function buildTreeShakenRuntime(runtimeDir, usedNames) {
41180
+ function esbuildPath(p) {
41181
+ return sep === "/" ? p : p.split(sep).join("/");
41182
+ }
41183
+ function runtimeTreeShakeEntry() {
41184
+ return join7(tmpdir(), "vesk-runtime-tree-shake", RUNTIME_ENTRY);
41185
+ }
41186
+ var treeShakeQueue = Promise.resolve();
41187
+ function buildTreeShakenRuntime(runtimeDir, usedNames) {
41188
+ const run = treeShakeQueue.then(() => buildTreeShakenRuntimeNow(runtimeDir, usedNames));
41189
+ treeShakeQueue = run.catch(() => void 0);
41190
+ return run;
41191
+ }
41192
+ async function buildTreeShakenRuntimeNow(runtimeDir, usedNames) {
40726
41193
  const unique = [...new Set(usedNames)];
40727
41194
  const available = runtimeExportNames(runtimeDir);
40728
41195
  const missing = unique.filter((n) => !available.has(n));
@@ -40730,16 +41197,21 @@ async function buildTreeShakenRuntime(runtimeDir, usedNames) {
40730
41197
  console.error(`vesk: runtime names not exported \u2014 ${missing.join(", ")}; falling back to full runtime`);
40731
41198
  return buildRuntimeCode(runtimeDir);
40732
41199
  }
40733
- const entry = join7(runtimeDir, RUNTIME_ENTRY);
41200
+ const entry = runtimeTreeShakeEntry();
41201
+ const indexClient = esbuildPath(join7(runtimeDir, "index-client.js"));
40734
41202
  try {
41203
+ try {
41204
+ mkdirSync3(dirname8(entry), { recursive: true });
41205
+ } catch {
41206
+ }
40735
41207
  try {
40736
41208
  rmSync(entry);
40737
41209
  } catch {
40738
41210
  }
40739
- writeFileSync4(entry, `export { ${unique.join(", ")} } from './index-client.js';
41211
+ writeFileSync4(entry, `export { ${unique.join(", ")} } from ${JSON.stringify(indexClient)};
40740
41212
  `);
40741
41213
  const result = await build({
40742
- entryPoints: [entry],
41214
+ entryPoints: [esbuildPath(entry)],
40743
41215
  bundle: true,
40744
41216
  format: "iife",
40745
41217
  globalName: "__veskRuntime",
@@ -40796,7 +41268,7 @@ async function buildMainBundle(routeTree, runtimeDir, codeSplit, mono, hmr, impo
40796
41268
 
40797
41269
  ` : runtimeCode + "\n";
40798
41270
  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";
40799
- 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";
41271
+ 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";
40800
41272
  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";
40801
41273
  const routeTreeJson = JSON.stringify(routeTree);
40802
41274
  if (codeSplit) {
@@ -40915,14 +41387,14 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
40915
41387
 
40916
41388
  // ../adapter/src/static.ts
40917
41389
  init_paths();
40918
- import { mkdirSync as mkdirSync3, copyFileSync, readdirSync as readdirSync2, statSync as statSync5, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync13 } from "node:fs";
41390
+ import { mkdirSync as mkdirSync4, copyFileSync, readdirSync as readdirSync2, statSync as statSync5, existsSync as existsSync13, writeFileSync as writeFileSync5, readFileSync as readFileSync13 } from "node:fs";
40919
41391
  import { resolve as resolve12, join as join8 } from "node:path";
40920
41392
  function copyStaticAssets(publicDir, outDir) {
40921
41393
  const targetDir = resolve12(outDir, "static", "public");
40922
- mkdirSync3(targetDir, { recursive: true });
41394
+ mkdirSync4(targetDir, { recursive: true });
40923
41395
  if (!existsSync13(publicDir)) return;
40924
41396
  function copyDir(src2, dest) {
40925
- mkdirSync3(dest, { recursive: true });
41397
+ mkdirSync4(dest, { recursive: true });
40926
41398
  const entries = readdirSync2(src2);
40927
41399
  for (const entry of entries) {
40928
41400
  const srcPath = join8(src2, entry);
@@ -40947,7 +41419,7 @@ init_server_utils();
40947
41419
  init_paths();
40948
41420
 
40949
41421
  // ../adapter/src/load-config.ts
40950
- import { existsSync as existsSync14, readFileSync as readFileSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync4 } from "node:fs";
41422
+ import { existsSync as existsSync14, readFileSync as readFileSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5 } from "node:fs";
40951
41423
  import { join as join9, dirname as dirname9 } from "node:path";
40952
41424
  import { pathToFileURL as pathToFileURL2 } from "node:url";
40953
41425
  import { createRequire as createRequire3 } from "node:module";
@@ -40992,7 +41464,7 @@ async function loadVeskConfig2(projectDir) {
40992
41464
  js = `const {${injectKeys.join(",")}} = globalThis.__vesk_inject;
40993
41465
  ` + js;
40994
41466
  const tmpFile = join9(projectDir, ".vesk", "config.loader.tmp.mjs");
40995
- mkdirSync4(dirname9(tmpFile), { recursive: true });
41467
+ mkdirSync5(dirname9(tmpFile), { recursive: true });
40996
41468
  writeFileSync6(tmpFile, js, "utf-8");
40997
41469
  globalThis.__vesk_inject = inject;
40998
41470
  try {
@@ -41445,6 +41917,12 @@ async function startProdServer(outDir, options) {
41445
41917
  return;
41446
41918
  } catch (e) {
41447
41919
  const err = e instanceof Error ? e : new Error(String(e));
41920
+ if (err.name === "Redirect") {
41921
+ const redirect2 = err;
41922
+ res.writeHead(Number(redirect2.status) || 302, { Location: typeof redirect2.url === "string" ? redirect2.url : "/" });
41923
+ res.end();
41924
+ return;
41925
+ }
41448
41926
  if (err.name === "NotFoundError") {
41449
41927
  res.writeHead(404, { "Content-Type": "text/html" });
41450
41928
  res.end(notFoundHtml || "<!DOCTYPE html><html><body><h1>404</h1><p>Not Found</p></body></html>");
@@ -41609,7 +42087,7 @@ async function build2(appDir, options) {
41609
42087
  resolve21(outDir, "prerendered")
41610
42088
  ];
41611
42089
  for (const d of dirs)
41612
- mkdirSync10(d, { recursive: true });
42090
+ mkdirSync11(d, { recursive: true });
41613
42091
  const cssSourcePath = resolveUserCssPath(appDir);
41614
42092
  if (cssSourcePath !== null) {
41615
42093
  const cssContent = readFileSync21(cssSourcePath, "utf-8");
@@ -42226,6 +42704,8 @@ function transformTracked2(irNode, tracked2) {
42226
42704
  return context.next();
42227
42705
  if (parent.type === "UpdateExpression" && parent.argument === node)
42228
42706
  return context.next();
42707
+ if (parent.type === "MemberExpression" && !parent.computed && parent.property === node)
42708
+ return context.next();
42229
42709
  if (parent.type === "Property" && parent.value === node && parent.key && parent.key.type === "Identifier" && parent.key.name === "into")
42230
42710
  return context.next();
42231
42711
  if (parent.type === "MemberExpression" && !parent.computed && parent.object === node && parent.property && parent.property.type === "Identifier" && parent.property.name === "set")
@@ -42329,6 +42809,12 @@ var Ctx2 = class {
42329
42809
  delegatedEvents = /* @__PURE__ */ new Set();
42330
42810
  directEvents = /* @__PURE__ */ new Set();
42331
42811
  hydrate = false;
42812
+ // Markerless structural hydration: claims run `nextElement(tag, skipK)` with
42813
+ // positional residue offsets and interior claims rebind the walker to the
42814
+ // claimed element (subWalker). Only meaningful when `hydrate` is also true.
42815
+ // Markerless is the DEFAULT; pass `markerless: false` to restore legacy
42816
+ // marker-mode claim emission.
42817
+ markerless = true;
42332
42818
  inTryBody = false;
42333
42819
  claimStatic = false;
42334
42820
  // While set, the next StaticNode claimed in hydrate mode uses `__root` (the
@@ -42378,9 +42864,9 @@ var Ctx2 = class {
42378
42864
  return "\n" + lines.join("\n");
42379
42865
  }
42380
42866
  };
42381
- function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
42867
+ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
42382
42868
  if (node instanceof StaticNode)
42383
- return emitStatic2(ctx2, node, tracked2, effectsVar);
42869
+ return emitStatic2(ctx2, node, tracked2, effectsVar, skipK, regionBudget);
42384
42870
  if (node instanceof TextNode) {
42385
42871
  if (!node.value)
42386
42872
  return null;
@@ -42399,11 +42885,11 @@ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__
42399
42885
  if (node instanceof ComponentRef)
42400
42886
  return null;
42401
42887
  if (node instanceof ComponentCall)
42402
- return emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix);
42888
+ return emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix, skipK, regionBudget);
42403
42889
  if (node instanceof OpaqueDynamicRegion)
42404
- return emitOpaque2(ctx2, node, tracked2, effectsVar, parentVar);
42890
+ return emitOpaque2(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
42405
42891
  if (node instanceof MapRegion)
42406
- return emitMap2(ctx2, node, tracked2, effectsVar, parentVar);
42892
+ return emitMap2(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
42407
42893
  if (node instanceof ServerBlock)
42408
42894
  return null;
42409
42895
  if (node instanceof ClientBlock) {
@@ -42443,13 +42929,13 @@ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__
42443
42929
  return null;
42444
42930
  }
42445
42931
  if (node instanceof TryCatch)
42446
- return emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar);
42932
+ return emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar, skipK, regionBudget);
42447
42933
  if (node instanceof WhileLoop)
42448
- return emitWhileLoop2(ctx2, node, tracked2, parentVar);
42934
+ return emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK, regionBudget);
42449
42935
  if (node instanceof ForLoop)
42450
- return emitForLoop2(ctx2, node, tracked2, parentVar);
42936
+ return emitForLoop2(ctx2, node, tracked2, parentVar, skipK, regionBudget);
42451
42937
  if (node instanceof SwitchBlock)
42452
- return emitSwitchBlock2(ctx2, node, tracked2, parentVar);
42938
+ return emitSwitchBlock2(ctx2, node, tracked2, parentVar, skipK, regionBudget);
42453
42939
  if (node instanceof PropSlot)
42454
42940
  return null;
42455
42941
  if (node instanceof PropSlotRender) {
@@ -42484,7 +42970,7 @@ var PROPERTY_ATTRS2 = {
42484
42970
  option: /* @__PURE__ */ new Set(["selected"]),
42485
42971
  progress: /* @__PURE__ */ new Set(["value"])
42486
42972
  };
42487
- function emitStatic2(ctx2, node, tracked2, effectsVar) {
42973
+ function emitStatic2(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
42488
42974
  const el = ctx2.n();
42489
42975
  if (ctx2.hydrate) {
42490
42976
  const claim = ctx2.claimStatic;
@@ -42493,8 +42979,12 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42493
42979
  return null;
42494
42980
  const rootClaim = ctx2.rootClaim;
42495
42981
  ctx2.rootClaim = false;
42496
- const claimedExpr = rootClaim ? `__root || ${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)})`;
42982
+ const skipExpr = regionBudget && ctx2.markerless ? markerlessSkipExpr2(regionBudget, skipK) : skipK;
42983
+ const skipArg = ctx2.markerless ? `, ${skipExpr}` : "";
42984
+ const claimedExpr = rootClaim ? `__root || document.createElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)}${skipArg})`;
42497
42985
  ctx2.push(`const ${el} = ${claimedExpr};`);
42986
+ if (regionBudget && ctx2.markerless)
42987
+ ctx2.push(`${regionBudget} = 0;`);
42498
42988
  } else {
42499
42989
  ctx2.push(`const ${el} = document.createElement(${JSON.stringify(node.tag)});`);
42500
42990
  }
@@ -42527,7 +43017,41 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42527
43017
  const textKids = children.filter((c) => c instanceof TextNode || c instanceof DynamicBinding && c.kind === "text");
42528
43018
  singleReactiveText = textKids.length === 1 && textKids[0] instanceof DynamicBinding && isReactiveExpression2(textKids[0].expression, tracked2);
42529
43019
  }
43020
+ const savedWalker = ctx2.walker;
43021
+ let needsSubWalker = false;
43022
+ if (ctx2.hydrate && ctx2.markerless) {
43023
+ for (const child of children) {
43024
+ if (child instanceof TextNode)
43025
+ continue;
43026
+ if (child instanceof DynamicBinding && child.kind === "text")
43027
+ continue;
43028
+ if (child instanceof StaticNode && isStaticIR2(child.children))
43029
+ continue;
43030
+ if (child instanceof TrackDecl)
43031
+ continue;
43032
+ if (child instanceof ComponentRef)
43033
+ continue;
43034
+ if (child instanceof ServerBlock)
43035
+ continue;
43036
+ if (child instanceof ClientBlock)
43037
+ continue;
43038
+ if (child instanceof HeadBlock)
43039
+ continue;
43040
+ if (child instanceof RuntimeStatement)
43041
+ continue;
43042
+ if (child instanceof PropSlot)
43043
+ continue;
43044
+ needsSubWalker = true;
43045
+ break;
43046
+ }
43047
+ }
43048
+ if (needsSubWalker) {
43049
+ const sub = ctx2.n();
43050
+ ctx2.push(`const ${sub} = ${ctx2.walker}.subWalker(${el});`);
43051
+ ctx2.walker = sub;
43052
+ }
42530
43053
  let residueBefore = 0;
43054
+ let pendingSkip = 0;
42531
43055
  for (const child of children) {
42532
43056
  let childVar;
42533
43057
  const isPureStaticChild = ctx2.hydrate && child instanceof StaticNode && isStaticIR2(child.children);
@@ -42581,10 +43105,13 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42581
43105
  }
42582
43106
  }
42583
43107
  childVar = ssrEl;
43108
+ pendingSkip += ssrResidueEstimate2(child);
42584
43109
  } else if (singleReactiveText && child instanceof DynamicBinding && child.kind === "text") {
42585
43110
  childVar = emitDynamicBinding2(ctx2, child, tracked2, effectsVar, `${el}.__vsk_ssrText`);
42586
43111
  } else {
42587
- childVar = emitNode2(ctx2, child, tracked2, effectsVar, el);
43112
+ childVar = emitNode2(ctx2, child, tracked2, effectsVar, el, "__components", pendingSkip);
43113
+ if (claimsWalkerNode2(ctx2, child))
43114
+ pendingSkip = 0;
42588
43115
  }
42589
43116
  if (childVar) {
42590
43117
  if (ctx2.hydrate) {
@@ -42636,6 +43163,8 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42636
43163
  }
42637
43164
  }
42638
43165
  }
43166
+ if (ctx2.walker !== savedWalker)
43167
+ ctx2.walker = savedWalker;
42639
43168
  return el;
42640
43169
  }
42641
43170
  function emitClientHead2(ctx2, node, tracked2) {
@@ -42785,10 +43314,15 @@ function emitFragment2(ctx2, nodes, tracked2, effectsVar) {
42785
43314
  const savedEffects = ctx2.effects;
42786
43315
  ctx2.effects = [];
42787
43316
  ctx2.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
43317
+ let fragPendingSkip = 0;
42788
43318
  for (const child of nodes) {
42789
- const childVar = emitNode2(ctx2, child, tracked2, effectsVar, "$f");
43319
+ const childVar = emitNode2(ctx2, child, tracked2, effectsVar, "$f", "__components", fragPendingSkip);
42790
43320
  if (childVar)
42791
43321
  ctx2.push(`$f.appendChild(${childVar});`);
43322
+ if (claimsWalkerNode2(ctx2, child))
43323
+ fragPendingSkip = 0;
43324
+ else
43325
+ fragPendingSkip += ssrResidueEstimate2(child);
42792
43326
  }
42793
43327
  for (const eff of ctx2.effects)
42794
43328
  ctx2.push(effectsVar ? `${effectsVar}.push(${effectBlockToHandlerExpr2(eff)});` : eff);
@@ -42796,7 +43330,7 @@ function emitFragment2(ctx2, nodes, tracked2, effectsVar) {
42796
43330
  ctx2.push(`return $f; })();`);
42797
43331
  return frag;
42798
43332
  }
42799
- function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components") {
43333
+ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__components", skipK = 0, regionBudget) {
42800
43334
  const propsEntries = node.props.map((p) => {
42801
43335
  if (typeof p.value === "string")
42802
43336
  return `${JSON.stringify(p.name)}: ${JSON.stringify(p.value)}`;
@@ -42819,12 +43353,19 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42819
43353
  const callArgs = () => `{ ${propsEntries.join(", ")} }`;
42820
43354
  if (ctx2.hydrate) {
42821
43355
  const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `__components[${JSON.stringify(node.componentName)}]`);
43356
+ if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
43357
+ 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.`)});`);
43358
+ }
42822
43359
  const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
42823
43360
  const walkerArg = ctx2.walker;
43361
+ const promptExpr = ctx2.markerless && (regionBudget || skipK > 0) ? markerlessSkipExpr2(regionBudget, skipK) : null;
42824
43362
  const maybeReplace = (v2) => {
42825
43363
  if (!plainTarget)
42826
43364
  return;
42827
- ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${walkerArg}.claimOnly(); if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
43365
+ const claim = promptExpr ? `${walkerArg}.claimOnly(undefined, ${promptExpr})` : `${walkerArg}.claimOnly()`;
43366
+ ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
43367
+ if (regionBudget && ctx2.markerless)
43368
+ ctx2.push(`${regionBudget} = 0;`);
42828
43369
  };
42829
43370
  const maybeRetire = () => {
42830
43371
  if (ctx2.selfClaimNames.has(node.componentName)) {
@@ -42856,9 +43397,14 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42856
43397
  ctx2.push(`return $f; })();`);
42857
43398
  propsEntries.push(`children: ${frag}`);
42858
43399
  }
43400
+ if (ctx2.markerless && promptExpr && !plainTarget) {
43401
+ ctx2.push(`${walkerArg}.injectSkipK(${promptExpr});`);
43402
+ }
42859
43403
  ctx2.push(`let ${v} = undefined;`);
42860
43404
  ctx2.push(`if (__hydrate) __hydrate.childFrame = (__hydrate.childFrame || 0) + 1;`);
42861
43405
  ctx2.push(`try { ${v} = ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}); } finally { if (__hydrate) __hydrate.childFrame--; }`);
43406
+ if (ctx2.markerless && promptExpr && !plainTarget && regionBudget)
43407
+ ctx2.push(`${regionBudget} = 0;`);
42862
43408
  maybeReplace(v);
42863
43409
  maybeRetire();
42864
43410
  return v;
@@ -42888,32 +43434,54 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42888
43434
  } else if (ctx2.importedNames.has(node.componentName)) {
42889
43435
  ctx2.push(`const ${v} = ${awaitKw}${node.componentName}(${callArgs()});`);
42890
43436
  } else {
43437
+ 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.`)});`);
42891
43438
  ctx2.push(`const ${v} = ${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()});`);
42892
43439
  }
42893
43440
  }
42894
43441
  return v;
42895
43442
  }
42896
- function emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, rootLevel) {
43443
+ function emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, rootLevel, offsetExpr) {
42897
43444
  if (!ctx2.hydrate || !rootLevel)
42898
43445
  return;
42899
43446
  ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
42900
- ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
42901
- ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${anchor});`));
42902
- ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
43447
+ ctx2.push(`if (${ctx2.walker} && ${ctx2.walker}.insertBeforeNextClaim) {`);
43448
+ ctx2.push(indent3(`${ctx2.walker}.insertBeforeNextClaim(${anchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
43449
+ ctx2.push(indent3(`${ctx2.walker}.insertBeforeNextClaim(${endAnchor}${offsetExpr ? `, ${offsetExpr}` : ""});`));
42903
43450
  ctx2.push(`}`);
42904
43451
  }
42905
- function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
43452
+ function regionBudgetVar2(ctx2, skipK, regionBudget, inheritedInit) {
43453
+ if (!ctx2.markerless || !ctx2.hydrate)
43454
+ return null;
43455
+ if (skipK > 0) {
43456
+ const pk = ctx2.n();
43457
+ ctx2.push(`let ${pk} = ${skipK}; // first-claim budget: region SSR sits ${skipK} slot(s) past the walker cursor`);
43458
+ return pk;
43459
+ }
43460
+ if (inheritedInit) {
43461
+ const pk = ctx2.n();
43462
+ ctx2.push(`let ${pk} = ${inheritedInit}; // first-claim budget: inherited from the caller's walker residue`);
43463
+ return pk;
43464
+ }
43465
+ return regionBudget || null;
43466
+ }
43467
+ function markerlessSkipExpr2(regionBudget, skipK) {
43468
+ if (regionBudget)
43469
+ return skipK > 0 ? `${regionBudget} + ${skipK}` : regionBudget;
43470
+ return String(skipK);
43471
+ }
43472
+ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar, skipK = 0, regionBudget) {
42906
43473
  const anchor = ctx2.n();
42907
43474
  const endAnchor = ctx2.n();
42908
43475
  const effArr = ctx2.n();
42909
43476
  const catchParam = node.catchParamName || "__e";
42910
43477
  const parent = parentVar || "$root";
43478
+ const budget = ctx2.hydrate ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
42911
43479
  ctx2.push(`const ${anchor} = document.createComment('try');`);
42912
43480
  if (!ctx2.hydrate)
42913
43481
  ctx2.push(`${parent}.appendChild(${anchor});`);
42914
43482
  ctx2.push(`let ${effArr} = [];`);
42915
43483
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
42916
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43484
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
42917
43485
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
42918
43486
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
42919
43487
  const savedHydrate = ctx2.hydrate;
@@ -42931,7 +43499,7 @@ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42931
43499
  ctx2.push(indent3(`const __cl = [];`));
42932
43500
  }
42933
43501
  for (const child of body) {
42934
- const childVar = emitNode2(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix);
43502
+ const childVar = emitNode2(ctx2, child, tracked2, isCatch ? null : effArr, hydMode ? void 0 : "__p", compPrefix, 0, budget || void 0);
42935
43503
  if (childVar) {
42936
43504
  if (hydMode)
42937
43505
  ctx2.push(indent3(`__cl.push(${childVar});`));
@@ -42981,9 +43549,10 @@ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42981
43549
  }`);
42982
43550
  return null;
42983
43551
  }
42984
- function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43552
+ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
42985
43553
  const hyd = ctx2.hydrate;
42986
43554
  const parent = parentVar || "$root";
43555
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
42987
43556
  const isOpaque = (n) => !!n && typeof n.condition !== "undefined";
42988
43557
  if (hyd && node.alternateNodes.length === 1 && isOpaque(node.alternateNodes[0])) {
42989
43558
  const chain = [];
@@ -43004,7 +43573,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43004
43573
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
43005
43574
  ctx2.push(`let ${effectsVar2} = [];`);
43006
43575
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
43007
- emitHydrateFenceAnchoring2(ctx2, anchor2, endAnchor2, parent === "$root");
43576
+ emitHydrateFenceAnchoring2(ctx2, anchor2, endAnchor2, parent === "$root", budget || void 0);
43008
43577
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
43009
43578
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
43010
43579
  const renderNames = [];
@@ -43018,7 +43587,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43018
43587
  const savedClaim = ctx2.claimStatic;
43019
43588
  if (hyd)
43020
43589
  ctx2.claimStatic = true;
43021
- const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
43590
+ const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
43022
43591
  ctx2.claimStatic = savedClaim;
43023
43592
  if (v)
43024
43593
  ctx2.push(indent3(`${cl}.push(${v});`));
@@ -43036,7 +43605,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43036
43605
  const savedClaim = ctx2.claimStatic;
43037
43606
  if (hyd)
43038
43607
  ctx2.claimStatic = true;
43039
- const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
43608
+ const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar, "__components", 0, budget || void 0);
43040
43609
  ctx2.claimStatic = savedClaim;
43041
43610
  if (v)
43042
43611
  ctx2.push(indent3(`${cl2}.push(${v});`));
@@ -43096,7 +43665,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43096
43665
  ctx2.push(`${parent}.appendChild(${anchor});`);
43097
43666
  ctx2.push(`let ${effectsVar} = [];`);
43098
43667
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
43099
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43668
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43100
43669
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
43101
43670
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
43102
43671
  const conRenderName = ctx2.n();
@@ -43112,7 +43681,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43112
43681
  const savedClaim = ctx2.claimStatic;
43113
43682
  if (hyd)
43114
43683
  ctx2.claimStatic = true;
43115
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
43684
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag, "__components", 0, budget || void 0);
43116
43685
  ctx2.claimStatic = savedClaim;
43117
43686
  if (v) {
43118
43687
  if (hyd)
@@ -43141,7 +43710,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43141
43710
  const savedAltClaim = ctx2.claimStatic;
43142
43711
  if (hyd)
43143
43712
  ctx2.claimStatic = true;
43144
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
43713
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag, "__components", 0, budget || void 0);
43145
43714
  ctx2.claimStatic = savedAltClaim;
43146
43715
  if (v) {
43147
43716
  if (hyd)
@@ -43188,19 +43757,20 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
43188
43757
  }
43189
43758
  return null;
43190
43759
  }
43191
- function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43760
+ function emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
43192
43761
  const condExpr = transformTracked2(node.condition, tracked2);
43193
43762
  const anchor = ctx2.n();
43194
43763
  const endAnchor = ctx2.n();
43195
43764
  const effectsVar = ctx2.n();
43196
43765
  const hyd = ctx2.hydrate;
43197
43766
  const parent = parentVar || "$root";
43767
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43198
43768
  ctx2.push(`const ${anchor} = document.createComment('while');`);
43199
43769
  if (!hyd)
43200
43770
  ctx2.push(`${parent}.appendChild(${anchor});`);
43201
43771
  ctx2.push(`let ${effectsVar} = [];`);
43202
43772
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
43203
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43773
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43204
43774
  const renderLoop = ctx2.n();
43205
43775
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43206
43776
  if (!hyd)
@@ -43212,7 +43782,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43212
43782
  if (node.isDoWhile) {
43213
43783
  ctx2.push(indent3(`do {`));
43214
43784
  for (const n of node.bodyTemplate) {
43215
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43785
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43216
43786
  if (v) {
43217
43787
  if (hyd)
43218
43788
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43224,7 +43794,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43224
43794
  } else {
43225
43795
  ctx2.push(indent3(`while (${condExpr}) {`));
43226
43796
  for (const n of node.bodyTemplate) {
43227
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43797
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43228
43798
  if (v) {
43229
43799
  if (hyd)
43230
43800
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43263,18 +43833,19 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
43263
43833
  }`);
43264
43834
  return null;
43265
43835
  }
43266
- function emitForLoop2(ctx2, node, tracked2, parentVar) {
43836
+ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
43267
43837
  const anchor = ctx2.n();
43268
43838
  const endAnchor = ctx2.n();
43269
43839
  const effectsVar = ctx2.n();
43270
43840
  const hyd = ctx2.hydrate;
43271
43841
  const parent = parentVar || "$root";
43842
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43272
43843
  ctx2.push(`const ${anchor} = document.createComment('for');`);
43273
43844
  if (!hyd)
43274
43845
  ctx2.push(`${parent}.appendChild(${anchor});`);
43275
43846
  ctx2.push(`let ${effectsVar} = [];`);
43276
43847
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
43277
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43848
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43278
43849
  const renderLoop = ctx2.n();
43279
43850
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43280
43851
  if (!hyd)
@@ -43287,7 +43858,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43287
43858
  const srcExpr = transformTracked2(node.condition, tracked2);
43288
43859
  ctx2.push(indent3(`for (${node.init} of (Array.isArray(${srcExpr}) ? ${srcExpr} : (${srcExpr} == null ? [] : Object.keys(${srcExpr})))) {`));
43289
43860
  for (const n of node.bodyTemplate) {
43290
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43861
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43291
43862
  if (v) {
43292
43863
  if (hyd)
43293
43864
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43307,7 +43878,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43307
43878
  const head = initPart ? `${initPart}; ${condExpr}` : `; ${condExpr}`;
43308
43879
  ctx2.push(indent3(`for (${head}; ${updatePart}) {`));
43309
43880
  for (const n of node.bodyTemplate) {
43310
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b");
43881
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
43311
43882
  if (v) {
43312
43883
  if (hyd)
43313
43884
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43418,19 +43989,20 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43418
43989
  }
43419
43990
  return null;
43420
43991
  }
43421
- function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43992
+ function emitSwitchBlock2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
43422
43993
  const discExpr = transformTracked2(node.discriminant, tracked2);
43423
43994
  const anchor = ctx2.n();
43424
43995
  const endAnchor = ctx2.n();
43425
43996
  const effectsVar = ctx2.n();
43426
43997
  const hyd = ctx2.hydrate;
43427
43998
  const parent = parentVar || "$root";
43999
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43428
44000
  ctx2.push(`const ${anchor} = document.createComment('switch');`);
43429
44001
  if (!hyd)
43430
44002
  ctx2.push(`${parent}.appendChild(${anchor});`);
43431
44003
  ctx2.push(`let ${effectsVar} = [];`);
43432
44004
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
43433
- emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
44005
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
43434
44006
  const renderSwitch = ctx2.n();
43435
44007
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43436
44008
  if (hyd) {
@@ -43447,7 +44019,7 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43447
44019
  ctx2.push(indent3(`default:`));
43448
44020
  }
43449
44021
  for (const n of c.body) {
43450
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c");
44022
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__c", "__components", 0, budget || void 0);
43451
44023
  if (v) {
43452
44024
  if (hyd)
43453
44025
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -43487,7 +44059,7 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43487
44059
  }`);
43488
44060
  return null;
43489
44061
  }
43490
- function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
44062
+ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
43491
44063
  const arrExpr = transformTracked2(node.expression, tracked2);
43492
44064
  const itemVar = node.itemVariable;
43493
44065
  const anchor = ctx2.n();
@@ -43499,6 +44071,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43499
44071
  const hyd = ctx2.hydrate && !keyed;
43500
44072
  const hydKeyed = ctx2.hydrate && keyed;
43501
44073
  const parent = parentVar || "$root";
44074
+ const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
43502
44075
  const reactiveSource = isReactiveExpression2(node.expression, tracked2);
43503
44076
  const pushEffect = (lets, effCall) => {
43504
44077
  if (effTarget) {
@@ -43533,7 +44106,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43533
44106
  if (hydKeyed)
43534
44107
  ctx2.rootClaim = true;
43535
44108
  for (const n of node.bodyTemplate) {
43536
- const v = emitNode2(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it");
44109
+ const v = emitNode2(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it", "__components", 0, budget || void 0);
43537
44110
  if (v) {
43538
44111
  if (hyd) {
43539
44112
  ctx2.push(indent3(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, __r);`));
@@ -43564,7 +44137,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43564
44137
  ctx2.hydrate = false;
43565
44138
  for (const n of node.alternateNodes) {
43566
44139
  ctx2.claimStatic = true;
43567
- const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag);
44140
+ const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? void 0 : frag, "__components", 0, budget || void 0);
43568
44141
  if (v) {
43569
44142
  if (hyd)
43570
44143
  ctx2.push(indent3(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, ${endAnchor});`));
@@ -43589,7 +44162,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar) {
43589
44162
  const initList = ctx2.n();
43590
44163
  ctx2.push(`let ${reconciler} = () => {};`);
43591
44164
  if (hydKeyed) {
43592
- ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}); };`);
44165
+ 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}); };`);
43593
44166
  } else {
43594
44167
  ctx2.push(`const ${initList} = () => { ${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
43595
44168
  }
@@ -43695,13 +44268,14 @@ ${renderAllItems(" ", null)}
43695
44268
  function computeAsyncComponents2(comps) {
43696
44269
  return new Set(comps.filter((c) => c.isAsync).map((c) => c.name));
43697
44270
  }
43698
- function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc) {
44271
+ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hydrate = false, asyncComps = /* @__PURE__ */ new Set(), linkNames = /* @__PURE__ */ new Set(), selfClaimNames = /* @__PURE__ */ new Set(), alloc, markerless = true) {
43699
44272
  const tracked2 = collectTrackedNames2(comp.body);
43700
44273
  const ctx2 = new Ctx2(alloc);
43701
44274
  ctx2.importedNames = importedNames;
43702
44275
  ctx2.linkNames = linkNames;
43703
44276
  ctx2.selfClaimNames = selfClaimNames;
43704
44277
  ctx2.hydrate = hydrate;
44278
+ ctx2.markerless = markerless;
43705
44279
  ctx2.asyncComps = asyncComps;
43706
44280
  ctx2.isAsyncScope = comp.isAsync || asyncComps.has(comp.name);
43707
44281
  ctx2.push(hydrate ? ctx2.isAsyncScope ? "async (props, __registry, __hydrate) => {" : "(props, __registry, __hydrate) => {" : ctx2.isAsyncScope ? "async (props) => {" : "(props) => {");
@@ -43730,10 +44304,15 @@ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hyd
43730
44304
  emitNode2(ctx2, node, tracked2, null);
43731
44305
  }
43732
44306
  }
44307
+ let topPendingSkip = 0;
44308
+ let topBudget = null;
44309
+ if (ctx2.markerless && ctx2.hydrate) {
44310
+ topBudget = regionBudgetVar2(ctx2, 0, void 0, `(typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0)`);
44311
+ }
43733
44312
  for (const node of comp.body) {
43734
44313
  if (node instanceof TrackDecl)
43735
44314
  continue;
43736
- const v = emitNode2(ctx2, node, tracked2, null);
44315
+ const v = emitNode2(ctx2, node, tracked2, null, void 0, "__components", topPendingSkip, topBudget || void 0);
43737
44316
  if (v) {
43738
44317
  if (ctx2.hydrate) {
43739
44318
  ctx2.push(indent3(`if ($mount === null) $mount = ${v};`));
@@ -43742,6 +44321,11 @@ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hyd
43742
44321
  ctx2.push(indent3(`$root.appendChild(${v});`));
43743
44322
  }
43744
44323
  }
44324
+ if (claimsWalkerNode2(ctx2, node)) {
44325
+ topBudget = null;
44326
+ topPendingSkip = 0;
44327
+ } else
44328
+ topPendingSkip += ssrResidueEstimate2(node);
43745
44329
  }
43746
44330
  const effCode = ctx2.flushEffects();
43747
44331
  if (effCode)
@@ -43768,7 +44352,7 @@ function buildParamInit3(paramNames) {
43768
44352
  return "";
43769
44353
  return `const { ${paramNames.join(", ")} } = props;`;
43770
44354
  }
43771
- function buildComponentMap3(irRoot, hydrate = false, alloc) {
44355
+ function buildComponentMap3(irRoot, hydrate = false, alloc, markerless = true) {
43772
44356
  const mapLines = [];
43773
44357
  mapLines.push(`const __components = {};`);
43774
44358
  const asyncComps = computeAsyncComponents2(irRoot.components);
@@ -43792,11 +44376,12 @@ function buildComponentMap3(irRoot, hydrate = false, alloc) {
43792
44376
  const directNames = /* @__PURE__ */ new Set([...extractRuntimeNames(irRoot.imports), ...localValueImportNames(irRoot.imports), ...topValueNames]);
43793
44377
  for (const comp of irRoot.components) {
43794
44378
  if (hydrate && isStaticComponent2(comp)) {
43795
- const stub = `(props, __registry, __hydrate) => { return __hydrate.claimOnly(); }`;
44379
+ const claimExpr = markerless ? `__hydrate.claimOnly(undefined, (typeof __hydrate.takeSkipK === 'function' ? __hydrate.takeSkipK() : 0))` : `__hydrate.claimOnly()`;
44380
+ const stub = `(props, __registry, __hydrate) => { return ${claimExpr}; }`;
43796
44381
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${stub};`);
43797
44382
  continue;
43798
44383
  }
43799
- const code = generateComponent2(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc);
44384
+ const code = generateComponent2(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc, markerless);
43800
44385
  mapLines.push(`__components[${JSON.stringify(comp.name)}] = ${code};`);
43801
44386
  }
43802
44387
  mapLines.push(`function __cleanup(start, end) {`);
@@ -43817,6 +44402,12 @@ function buildComponentMap3(irRoot, hydrate = false, alloc) {
43817
44402
  mapLines.push(` const p = nodes[0].parentNode;`);
43818
44403
  mapLines.push(` p.insertBefore(start, nodes[0]);`);
43819
44404
  mapLines.push(` p.insertBefore(end, nodes[nodes.length - 1].nextSibling);`);
44405
+ mapLines.push(` // Client-surplus nodes (SSR rendered fewer items than the client data)`);
44406
+ mapLines.push(` // are freshly claimed and still detached \u2014 move them into the region in`);
44407
+ mapLines.push(` // client order before \`end\`, instead of stranding them off-parent.`);
44408
+ mapLines.push(` for (let i = 0; i < nodes.length; i++) {`);
44409
+ mapLines.push(` if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);`);
44410
+ mapLines.push(` }`);
43820
44411
  mapLines.push(` return;`);
43821
44412
  mapLines.push(` }`);
43822
44413
  mapLines.push(` fallback.appendChild(start);`);
@@ -43875,6 +44466,25 @@ function isStaticIR2(body) {
43875
44466
  }
43876
44467
  return true;
43877
44468
  }
44469
+ function claimsWalkerNode2(ctx2, node) {
44470
+ if (node instanceof StaticNode)
44471
+ return ctx2.claimStatic || !isStaticIR2(node.children);
44472
+ if (node instanceof ComponentCall)
44473
+ return true;
44474
+ if (node instanceof OpaqueDynamicRegion)
44475
+ return true;
44476
+ if (node instanceof MapRegion)
44477
+ return true;
44478
+ if (node instanceof ForLoop)
44479
+ return true;
44480
+ if (node instanceof WhileLoop)
44481
+ return true;
44482
+ if (node instanceof SwitchBlock)
44483
+ return true;
44484
+ if (node instanceof TryCatch)
44485
+ return true;
44486
+ return false;
44487
+ }
43878
44488
  function isStaticComponent2(comp) {
43879
44489
  if (comp.style)
43880
44490
  return false;
@@ -44049,7 +44659,7 @@ function emitClientFromIR2(ir, options) {
44049
44659
  if (!options.forceClient && !needsClient) {
44050
44660
  return "";
44051
44661
  }
44052
- const componentMapCode = buildComponentMap3(ir, options.hydrate, options.nameAllocator);
44662
+ const componentMapCode = buildComponentMap3(ir, options.hydrate, options.nameAllocator, options.markerless !== false);
44053
44663
  const importLines = ir.imports.length > 0 ? ir.imports.join("\n") + "\n" : "";
44054
44664
  const topCode = (options.includeTopLevel === false ? [] : transformTopLevelForActions(ir.topLevelCode, "client")).join("\n") + "\n";
44055
44665
  const exportLines = [];
@@ -44135,7 +44745,7 @@ function compileClientBoth2(source, _componentName, sourcePath2, opts) {
44135
44745
  return { comp, hyd: "", name };
44136
44746
  return {
44137
44747
  comp,
44138
- hyd: emitClientFromIR2(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc }),
44748
+ hyd: emitClientFromIR2(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
44139
44749
  name
44140
44750
  };
44141
44751
  }
@@ -45276,9 +45886,10 @@ function guessProjectRoots2(dir) {
45276
45886
  }
45277
45887
 
45278
45888
  // ../adapter/dist/client-bundle.js
45279
- 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";
45889
+ 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";
45280
45890
  import { resolve as resolve24, join as join18, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
45281
45891
  import { fileURLToPath as fileURLToPath6 } from "node:url";
45892
+ import { tmpdir as tmpdir2 } from "node:os";
45282
45893
 
45283
45894
  // ../adapter/dist/esbuild-fallback.js
45284
45895
  var _nativeBuild2 = null;
@@ -46145,7 +46756,19 @@ function runtimeExportNames2(runtimeDir) {
46145
46756
  return names;
46146
46757
  }
46147
46758
  var RUNTIME_ENTRY2 = ".runtime-tree-entry.mjs";
46148
- async function buildTreeShakenRuntime2(runtimeDir, usedNames) {
46759
+ function esbuildPath2(p) {
46760
+ return sep3 === "/" ? p : p.split(sep3).join("/");
46761
+ }
46762
+ function runtimeTreeShakeEntry2() {
46763
+ return join18(tmpdir2(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
46764
+ }
46765
+ var treeShakeQueue2 = Promise.resolve();
46766
+ function buildTreeShakenRuntime2(runtimeDir, usedNames) {
46767
+ const run = treeShakeQueue2.then(() => buildTreeShakenRuntimeNow2(runtimeDir, usedNames));
46768
+ treeShakeQueue2 = run.catch(() => void 0);
46769
+ return run;
46770
+ }
46771
+ async function buildTreeShakenRuntimeNow2(runtimeDir, usedNames) {
46149
46772
  const unique = [...new Set(usedNames)];
46150
46773
  const available = runtimeExportNames2(runtimeDir);
46151
46774
  const missing = unique.filter((n) => !available.has(n));
@@ -46153,16 +46776,21 @@ async function buildTreeShakenRuntime2(runtimeDir, usedNames) {
46153
46776
  console.error(`vesk: runtime names not exported \u2014 ${missing.join(", ")}; falling back to full runtime`);
46154
46777
  return buildRuntimeCode2(runtimeDir);
46155
46778
  }
46156
- const entry = join18(runtimeDir, RUNTIME_ENTRY2);
46779
+ const entry = runtimeTreeShakeEntry2();
46780
+ const indexClient = esbuildPath2(join18(runtimeDir, "index-client.js"));
46157
46781
  try {
46782
+ try {
46783
+ mkdirSync12(dirname18(entry), { recursive: true });
46784
+ } catch {
46785
+ }
46158
46786
  try {
46159
46787
  rmSync4(entry);
46160
46788
  } catch {
46161
46789
  }
46162
- writeFileSync13(entry, `export { ${unique.join(", ")} } from './index-client.js';
46790
+ writeFileSync13(entry, `export { ${unique.join(", ")} } from ${JSON.stringify(indexClient)};
46163
46791
  `);
46164
46792
  const result = await build3({
46165
- entryPoints: [entry],
46793
+ entryPoints: [esbuildPath2(entry)],
46166
46794
  bundle: true,
46167
46795
  format: "iife",
46168
46796
  globalName: "__veskRuntime",
@@ -46219,7 +46847,7 @@ async function buildMainBundle2(routeTree, runtimeDir, codeSplit, mono, hmr, imp
46219
46847
 
46220
46848
  ` : runtimeCode + "\n";
46221
46849
  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";
46222
- 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";
46850
+ 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";
46223
46851
  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";
46224
46852
  const routeTreeJson = JSON.stringify(routeTree);
46225
46853
  if (codeSplit) {
@@ -46387,7 +47015,7 @@ import { resolve as resolve28 } from "node:path";
46387
47015
 
46388
47016
  // ../adapter/dist/plugins.js
46389
47017
  init_paths();
46390
- import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync11, statSync as statSync16 } from "node:fs";
47018
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
46391
47019
  import { resolve as resolve26, dirname as dirname19, join as join19, extname as extname7, basename as basename5 } from "node:path";
46392
47020
  import { createRequire as createRequire5 } from "node:module";
46393
47021
  import { spawn as spawn2 } from "node:child_process";
@@ -46431,7 +47059,7 @@ function writePluginState2(veskDir, state) {
46431
47059
  const file = stateFilePath2(veskDir);
46432
47060
  const dir = dirname19(file);
46433
47061
  if (!existsSync30(dir))
46434
- mkdirSync11(dir, { recursive: true });
47062
+ mkdirSync13(dir, { recursive: true });
46435
47063
  writeFileSync14(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
46436
47064
  }
46437
47065
  function resolvePackage2(appDir, pkg) {
@@ -47363,8 +47991,8 @@ var __internals2 = {
47363
47991
  };
47364
47992
 
47365
47993
  // ../adapter/dist/dev-config.js
47366
- import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
47367
- import { tmpdir } from "node:os";
47994
+ import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
47995
+ import { tmpdir as tmpdir3 } from "node:os";
47368
47996
  import { resolve as resolve27, dirname as dirname20, join as join20 } from "node:path";
47369
47997
  init_parser();
47370
47998
  function findConfigFile2(projectDir) {
@@ -47393,8 +48021,8 @@ async function parseConfigSource(source, isTs, projectDir) {
47393
48021
  js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
47394
48022
  ` + js;
47395
48023
  }
47396
- const base = projectDir ? (mkdirSync12(join20(projectDir, ".vesk"), { recursive: true }), join20(projectDir, ".vesk")) : void 0;
47397
- const dir = base ? mkdtempSync3(join20(base, "cfg-")) : mkdtempSync3(join20(tmpdir(), "vesk-cfg-"));
48024
+ const base = projectDir ? (mkdirSync14(join20(projectDir, ".vesk"), { recursive: true }), join20(projectDir, ".vesk")) : void 0;
48025
+ const dir = base ? mkdtempSync3(join20(base, "cfg-")) : mkdtempSync3(join20(tmpdir3(), "vesk-cfg-"));
47398
48026
  const tmpFile = join20(dir, "config.mjs");
47399
48027
  try {
47400
48028
  writeFileSync15(tmpFile, js, "utf-8");
@@ -47430,7 +48058,7 @@ async function writeConfigSource2(projectDir, source) {
47430
48058
  const { path, isTs } = findConfigFile2(projectDir);
47431
48059
  const target = path || resolve27(projectDir, "vesk.config.ts");
47432
48060
  await parseConfigSource(source, isTs, projectDir);
47433
- mkdirSync12(dirname20(target), { recursive: true });
48061
+ mkdirSync14(dirname20(target), { recursive: true });
47434
48062
  writeFileSync15(target, source, "utf-8");
47435
48063
  const config = await parseConfigSource(source, isTs, projectDir);
47436
48064
  return { path: target, exists: true, source, config };
@@ -48704,7 +49332,7 @@ function produceDiagnostics(input) {
48704
49332
  }
48705
49333
 
48706
49334
  // ../agentic/dist/checkpoints.js
48707
- 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";
49335
+ 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";
48708
49336
  import { join as join21, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
48709
49337
  import { randomUUID as nodeRandomUUID } from "node:crypto";
48710
49338
  function generateId() {
@@ -48850,7 +49478,7 @@ function getCheckpointPath(projectDir, id) {
48850
49478
  return join21(getCheckpointDir(projectDir, id), "checkpoint.json");
48851
49479
  }
48852
49480
  function ensureDir(dir) {
48853
- mkdirSync13(dir, { recursive: true });
49481
+ mkdirSync15(dir, { recursive: true });
48854
49482
  }
48855
49483
  function readJson(filePath, fallback) {
48856
49484
  try {
@@ -48976,7 +49604,7 @@ function rollback(projectDir, id) {
48976
49604
  }
48977
49605
 
48978
49606
  // ../agentic/dist/config.js
48979
- import { readFileSync as readFileSync30, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync14, chmodSync } from "node:fs";
49607
+ import { readFileSync as readFileSync30, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync16, chmodSync } from "node:fs";
48980
49608
  import { resolve as resolve30, dirname as dirname22 } from "node:path";
48981
49609
  var DEFAULT_CONFIG = {
48982
49610
  provider: "openai",
@@ -49106,7 +49734,7 @@ function saveAgenticConfig(projectDir, patch) {
49106
49734
  if (next.baseUrl)
49107
49735
  toWrite.baseUrl = next.baseUrl;
49108
49736
  try {
49109
- mkdirSync14(dirname22(p), { recursive: true });
49737
+ mkdirSync16(dirname22(p), { recursive: true });
49110
49738
  writeFileSync17(p, JSON.stringify(toWrite, null, 2), "utf-8");
49111
49739
  } catch {
49112
49740
  }
@@ -50431,7 +51059,7 @@ var Agent = class {
50431
51059
  };
50432
51060
 
50433
51061
  // ../agentic/dist/tools/vesk.js
50434
- import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync15, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
51062
+ import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
50435
51063
  import { resolve as resolve32, join as join22, dirname as dirname23, sep as sep6 } from "node:path";
50436
51064
  function resolveWithin3(baseDir, relPath) {
50437
51065
  const base = resolve32(baseDir);
@@ -50465,7 +51093,7 @@ function readPluginState3(veskDir) {
50465
51093
  }
50466
51094
  function writePluginState3(veskDir, state) {
50467
51095
  const file = stateFilePath3(veskDir);
50468
- mkdirSync15(dirname23(file), { recursive: true });
51096
+ mkdirSync17(dirname23(file), { recursive: true });
50469
51097
  writeFileSync18(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
50470
51098
  }
50471
51099
  function eqIgnoreCase3(a, b) {
@@ -50825,7 +51453,7 @@ function createVeskTools(deps) {
50825
51453
  if (!contained)
50826
51454
  return jsonError("path escapes project root");
50827
51455
  }
50828
- mkdirSync15(dirname23(target), { recursive: true });
51456
+ mkdirSync17(dirname23(target), { recursive: true });
50829
51457
  writeFileSync18(target, source, "utf-8");
50830
51458
  return jsonOk({ ok: true, path: target, source });
50831
51459
  }
@@ -51107,7 +51735,7 @@ function createVeskTools(deps) {
51107
51735
  } catch {
51108
51736
  }
51109
51737
  const dir = checkpointDir(veskDir);
51110
- mkdirSync15(dir, { recursive: true });
51738
+ mkdirSync17(dir, { recursive: true });
51111
51739
  const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
51112
51740
  const file = join22(dir, `${id}.json`);
51113
51741
  const check = resolveWithin3(dir, `${id}.json`);
@@ -51879,7 +52507,7 @@ function renderDevErrorPage(payload, opts) {
51879
52507
 
51880
52508
  // src/build-packages.ts
51881
52509
  import { spawnSync } from "node:child_process";
51882
- 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";
52510
+ 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";
51883
52511
  import { createRequire as createRequire6 } from "node:module";
51884
52512
  import { dirname as dirname25, join as join23, resolve as resolve36 } from "node:path";
51885
52513
  import { fileURLToPath as fileURLToPath8 } from "node:url";
@@ -51962,7 +52590,7 @@ function buildPackages(force = false) {
51962
52590
  const distDir = join23(pkgDir, "dist");
51963
52591
  for (const c of cfg.copy || []) {
51964
52592
  const to = join23(distDir, c.to);
51965
- mkdirSync16(dirname25(to), { recursive: true });
52593
+ mkdirSync18(dirname25(to), { recursive: true });
51966
52594
  cpSync2(join23(pkgDir, c.from), to, { recursive: true });
51967
52595
  }
51968
52596
  const srcPkg = JSON.parse(readFileSync36(join23(pkgDir, "package.json"), "utf-8"));
@@ -52611,7 +53239,11 @@ var HMR_CONFIG_NAMES = /* @__PURE__ */ new Set([
52611
53239
  "tsconfig.json",
52612
53240
  "package.json"
52613
53241
  ]);
52614
- function classifyHmrWatchPath(relPath) {
53242
+ function normalizeWatchPath(relPath) {
53243
+ return relPath.includes("\\") ? relPath.split("\\").join("/") : relPath;
53244
+ }
53245
+ function classifyHmrWatchPath(relPathRaw) {
53246
+ const relPath = normalizeWatchPath(relPathRaw);
52615
53247
  const first = relPath.split("/")[0];
52616
53248
  if (HMR_SKIP_DIRS.has(first) || HMR_SKIP_MARKERS.some((m) => relPath.includes(m))) return "ignored";
52617
53249
  const name = relPath.slice(relPath.lastIndexOf("/") + 1);
@@ -52622,8 +53254,9 @@ function classifyHmrWatchPath(relPath) {
52622
53254
  if (HMR_SCRIPT_EXTS.some((ext) => relPath.endsWith(ext))) return "script";
52623
53255
  return "ignored";
52624
53256
  }
52625
- function shouldRescanRoutes(relPath, eventType) {
53257
+ function shouldRescanRoutes(relPathRaw, eventType) {
52626
53258
  if (eventType === "rename") return true;
53259
+ const relPath = normalizeWatchPath(relPathRaw);
52627
53260
  const name = relPath.slice(relPath.lastIndexOf("/") + 1);
52628
53261
  return relPath.endsWith(".vsk") && ROUTE_STRUCTURAL_VSK.has(name);
52629
53262
  }
@@ -54432,7 +55065,7 @@ if (cmd === "init") {
54432
55065
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
54433
55066
  process.exit(0);
54434
55067
  }
54435
- mkdirSync18(appDirPath, { recursive: true });
55068
+ mkdirSync20(appDirPath, { recursive: true });
54436
55069
  writeFileSync21(target, [
54437
55070
  `@import 'tailwindcss';`,
54438
55071
  ``,