@vesk/vesk-cli 0.2.23 → 0.2.24

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 +70 -26
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -2018,6 +2018,7 @@ function createResource(fn, key, into, options = {}) {
2018
2018
  }
2019
2019
  const ssrData = getSsrData(resourceKey);
2020
2020
  if (ssrData !== void 0) {
2021
+ if (isServer()) setSsrData(resourceKey, ssrData);
2021
2022
  settle(handle2, ssrData);
2022
2023
  writeCache(resourceKey, ssrData);
2023
2024
  return accessor;
@@ -2834,6 +2835,11 @@ function isRouteHref(href) {
2834
2835
  function setIsHydrating(v) {
2835
2836
  __isHydrating = v;
2836
2837
  }
2838
+ function captureInitialScroll() {
2839
+ if (typeof window === "undefined") return;
2840
+ _initialSavedScroll = window.scrollY || 0;
2841
+ _initialScrollRestored = false;
2842
+ }
2837
2843
  function setIsPopStateNavigation(v) {
2838
2844
  _isPopStateNavigation = v;
2839
2845
  }
@@ -2892,16 +2898,22 @@ function showLoadingInContainer(container, loadingFn, params) {
2892
2898
  container.innerHTML = loadingContent;
2893
2899
  }
2894
2900
  }
2895
- function handleScroll(pathname, isReplace) {
2901
+ function handleScroll(pathname, isReplace, scrollBehavior) {
2896
2902
  if (typeof window === "undefined" || typeof window.scrollTo !== "function") return;
2903
+ const behavior = scrollBehavior === "smooth" || scrollBehavior === "instant" ? scrollBehavior : "auto";
2897
2904
  if (_isPopStateNavigation) {
2898
2905
  setIsPopStateNavigation(false);
2899
2906
  const savedY = _scrollPositions.get(pathname);
2900
2907
  requestAnimationFrame(() => {
2901
- window.scrollTo(0, savedY !== void 0 ? savedY : 0);
2908
+ window.scrollTo({ top: savedY !== void 0 ? savedY : 0, behavior });
2909
+ });
2910
+ } else if (isReplace && !_initialScrollRestored) {
2911
+ _initialScrollRestored = true;
2912
+ requestAnimationFrame(() => {
2913
+ window.scrollTo({ top: _initialSavedScroll, behavior });
2902
2914
  });
2903
2915
  } else if (!isReplace) {
2904
- requestAnimationFrame(() => window.scrollTo(0, 0));
2916
+ requestAnimationFrame(() => window.scrollTo({ top: 0, behavior }));
2905
2917
  }
2906
2918
  }
2907
2919
  function applyHead(headHtml) {
@@ -2986,7 +2998,7 @@ function Link(props, registry, hydrate) {
2986
2998
  e.preventDefault();
2987
2999
  e.stopPropagation();
2988
3000
  const nav = useNavigate();
2989
- nav(href);
3001
+ nav(href, { scrollBehavior: props.scrollBehavior });
2990
3002
  });
2991
3003
  return claimed ? document.createDocumentFragment() : a2;
2992
3004
  }
@@ -3018,7 +3030,7 @@ function Link(props, registry, hydrate) {
3018
3030
  e.preventDefault();
3019
3031
  e.stopPropagation();
3020
3032
  const nav = useNavigate();
3021
- nav(href);
3033
+ nav(href, { scrollBehavior: props.scrollBehavior });
3022
3034
  });
3023
3035
  return a;
3024
3036
  }
@@ -3058,7 +3070,7 @@ function NavLink(props, registry, hydrate) {
3058
3070
  e.preventDefault();
3059
3071
  e.stopPropagation();
3060
3072
  const nav = useNavigate();
3061
- nav(props.href);
3073
+ nav(props.href, { scrollBehavior: props.scrollBehavior });
3062
3074
  });
3063
3075
  const path2 = usePathname();
3064
3076
  const routeHref2 = routeHrefOf(props.href);
@@ -3088,7 +3100,7 @@ function NavLink(props, registry, hydrate) {
3088
3100
  e.preventDefault();
3089
3101
  e.stopPropagation();
3090
3102
  const nav = useNavigate();
3091
- nav(props.href);
3103
+ nav(props.href, { scrollBehavior: props.scrollBehavior });
3092
3104
  });
3093
3105
  const path2 = usePathname();
3094
3106
  const routeHref2 = routeHrefOf(props.href);
@@ -3210,7 +3222,7 @@ function useRouter() {
3210
3222
  }
3211
3223
  };
3212
3224
  }
3213
- var Redirect, NotFoundError, RouterCtx, _currentRouter, _outletId, __isHydrating, _state, _scrollPositions, _isPopStateNavigation, HEAD_MARKER;
3225
+ var Redirect, NotFoundError, RouterCtx, _currentRouter, _outletId, __isHydrating, _state, _scrollPositions, _isPopStateNavigation, _initialScrollRestored, _initialSavedScroll, HEAD_MARKER;
3214
3226
  var init_router_components = __esm({
3215
3227
  "../runtime/src/router-components.ts"() {
3216
3228
  "use strict";
@@ -3245,6 +3257,8 @@ var init_router_components = __esm({
3245
3257
  };
3246
3258
  _scrollPositions = /* @__PURE__ */ new Map();
3247
3259
  _isPopStateNavigation = false;
3260
+ _initialScrollRestored = false;
3261
+ _initialSavedScroll = 0;
3248
3262
  HEAD_MARKER = "data-vesk-head";
3249
3263
  }
3250
3264
  });
@@ -4303,6 +4317,7 @@ function createRouter(routes, options = {}) {
4303
4317
  start() {
4304
4318
  setCurrentRouter(this);
4305
4319
  if (typeof window !== "undefined" && "scrollRestoration" in window.history) {
4320
+ captureInitialScroll();
4306
4321
  window.history.scrollRestoration = "manual";
4307
4322
  }
4308
4323
  if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
@@ -4416,7 +4431,7 @@ function createRouter(routes, options = {}) {
4416
4431
  }
4417
4432
  this._currentMatch = match;
4418
4433
  clearOfflineFlag(this, container);
4419
- handleScroll(url.pathname, opts.replace);
4434
+ handleScroll(url.pathname, opts.replace, opts.scrollBehavior);
4420
4435
  };
4421
4436
  const swapView = (fn) => {
4422
4437
  const d = document;
@@ -4625,6 +4640,7 @@ function createFileRouter(routeTree, options = {}) {
4625
4640
  start() {
4626
4641
  setCurrentRouter(this);
4627
4642
  if (typeof window !== "undefined" && "scrollRestoration" in window.history) {
4643
+ captureInitialScroll();
4628
4644
  window.history.scrollRestoration = "manual";
4629
4645
  }
4630
4646
  if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
@@ -4768,7 +4784,7 @@ function createFileRouter(routeTree, options = {}) {
4768
4784
  }
4769
4785
  router._currentMatch = match;
4770
4786
  clearOfflineFlag(router, container);
4771
- handleScroll(url.pathname, opts.replace);
4787
+ handleScroll(url.pathname, opts.replace, opts.scrollBehavior);
4772
4788
  };
4773
4789
  const doRender = () => {
4774
4790
  navDebug("doRender", url.pathname, "token=" + navToken);
@@ -27909,7 +27925,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27909
27925
  const cl = ctx2.n();
27910
27926
  ctx2.push(indent2(`const ${cl} = [];`));
27911
27927
  for (const n of chain[i].nodes) {
27928
+ const savedClaim = ctx2.claimStatic;
27929
+ if (hyd) ctx2.claimStatic = true;
27912
27930
  const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
27931
+ ctx2.claimStatic = savedClaim;
27913
27932
  if (v) ctx2.push(indent2(`${cl}.push(${v});`));
27914
27933
  }
27915
27934
  ctx2.push(indent2(`__place(${anchor2}, ${endAnchor2}, ${cl}, ${parent});`));
@@ -27922,7 +27941,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27922
27941
  const cl2 = ctx2.n();
27923
27942
  ctx2.push(indent2(`const ${cl2} = [];`));
27924
27943
  for (const n of finalElse) {
27944
+ const savedClaim = ctx2.claimStatic;
27945
+ if (hyd) ctx2.claimStatic = true;
27925
27946
  const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
27947
+ ctx2.claimStatic = savedClaim;
27926
27948
  if (v) ctx2.push(indent2(`${cl2}.push(${v});`));
27927
27949
  }
27928
27950
  ctx2.push(indent2(`__place(${anchor2}, ${endAnchor2}, ${cl2}, ${parent});`));
@@ -27932,16 +27954,16 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27932
27954
  for (let i = 1; i < chain.length; i++) init += ` else if (${chain[i].cond}) { ${asyncKw2}${renderNames[i]}(); }`;
27933
27955
  if (finalRender) init += ` else { ${asyncKw2}${finalRender}(); }`;
27934
27956
  ctx2.push(init);
27935
- let branchInit;
27936
- if (chain.length === 1 && finalRender) branchInit = `(${chain[0].cond} ? 0 : 1)`;
27937
- else if (chain.length === 2 && finalRender) branchInit = `(${chain[0].cond} ? 0 : (${chain[1].cond} ? 1 : 2))`;
27938
- else if (chain.length === 2 && !finalRender) branchInit = `(${chain[0].cond} ? 0 : (${chain[1].cond} ? 1 : -1))`;
27939
- else branchInit = `(${chain[0].cond} ? 0 : -1)`;
27957
+ let branchInitFallback = finalRender ? `${chain.length}` : "-1";
27958
+ for (let i = chain.length - 1; i >= 0; i--) {
27959
+ branchInitFallback = `(${chain[i].cond} ? ${i} : ${branchInitFallback})`;
27960
+ }
27961
+ const branchInit = `(${branchInitFallback})`;
27940
27962
  let effInner = `if (__new === 0) { ${asyncKw2}${renderNames[0]}(); }`;
27941
27963
  for (let i = 1; i < chain.length; i++) effInner += ` else if (__new === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
27942
27964
  if (finalRender) effInner += ` else { ${asyncKw2}${finalRender}(); }`;
27943
27965
  const effBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
27944
- if (__first) { __first = false; return; }
27966
+ if (__first) { __first = false; __iv = ${branchInit}; return; }
27945
27967
  const __new = ${branchInit};
27946
27968
  if (__new !== __iv) {
27947
27969
  for (const e of ${effectsVar2}) destroy_block(e);
@@ -27984,7 +28006,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27984
28006
  if (!hyd) ctx2.push(indent2(`const ${conFrag} = document.createDocumentFragment();`));
27985
28007
  if (hyd) ctx2.push(indent2(`const __cl = [];`));
27986
28008
  for (const n of node.consequentNodes) {
28009
+ const savedClaim = ctx2.claimStatic;
28010
+ if (hyd) ctx2.claimStatic = true;
27987
28011
  const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
28012
+ ctx2.claimStatic = savedClaim;
27988
28013
  if (v) {
27989
28014
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
27990
28015
  else ctx2.push(indent2(`${conFrag}.appendChild(${v});`));
@@ -28002,7 +28027,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28002
28027
  if (!hyd) ctx2.push(indent2(`const ${altFrag} = document.createDocumentFragment();`));
28003
28028
  if (hyd) ctx2.push(indent2(`const __cl = [];`));
28004
28029
  for (const n of node.alternateNodes) {
28030
+ const savedAltClaim = ctx2.claimStatic;
28031
+ if (hyd) ctx2.claimStatic = true;
28005
28032
  const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
28033
+ ctx2.claimStatic = savedAltClaim;
28006
28034
  if (v) {
28007
28035
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
28008
28036
  else ctx2.push(indent2(`${altFrag}.appendChild(${v});`));
@@ -29064,16 +29092,20 @@ function opaqueRegionToJS(node, isAsync = false, tracked2) {
29064
29092
  const lines = [];
29065
29093
  const cond = exprJSX(node.condition, tracked2);
29066
29094
  lines.push(`if (${cond}) {`);
29095
+ setVskForceClaim(true);
29067
29096
  for (const n of node.consequentNodes) {
29068
29097
  const code = irNodeToJS(n, null, isAsync, tracked2);
29069
29098
  if (code) lines.push(indent(code));
29070
29099
  }
29100
+ setVskForceClaim(false);
29071
29101
  if (node.alternateNodes.length > 0) {
29072
29102
  lines.push(`} else {`);
29103
+ setVskForceClaim(true);
29073
29104
  for (const n of node.alternateNodes) {
29074
29105
  const code = irNodeToJS(n, null, isAsync, tracked2);
29075
29106
  if (code) lines.push(indent(code));
29076
29107
  }
29108
+ setVskForceClaim(false);
29077
29109
  }
29078
29110
  lines.push(`}`);
29079
29111
  return lines.join("\n");
@@ -41549,7 +41581,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41549
41581
  const cl = ctx2.n();
41550
41582
  ctx2.push(indent3(`const ${cl} = [];`));
41551
41583
  for (const n of chain[i].nodes) {
41584
+ const savedClaim = ctx2.claimStatic;
41585
+ if (hyd)
41586
+ ctx2.claimStatic = true;
41552
41587
  const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
41588
+ ctx2.claimStatic = savedClaim;
41553
41589
  if (v)
41554
41590
  ctx2.push(indent3(`${cl}.push(${v});`));
41555
41591
  }
@@ -41563,7 +41599,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41563
41599
  const cl2 = ctx2.n();
41564
41600
  ctx2.push(indent3(`const ${cl2} = [];`));
41565
41601
  for (const n of finalElse) {
41602
+ const savedClaim = ctx2.claimStatic;
41603
+ if (hyd)
41604
+ ctx2.claimStatic = true;
41566
41605
  const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
41606
+ ctx2.claimStatic = savedClaim;
41567
41607
  if (v)
41568
41608
  ctx2.push(indent3(`${cl2}.push(${v});`));
41569
41609
  }
@@ -41576,22 +41616,18 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41576
41616
  if (finalRender)
41577
41617
  init += ` else { ${asyncKw2}${finalRender}(); }`;
41578
41618
  ctx2.push(init);
41579
- let branchInit;
41580
- if (chain.length === 1 && finalRender)
41581
- branchInit = `(${chain[0].cond} ? 0 : 1)`;
41582
- else if (chain.length === 2 && finalRender)
41583
- branchInit = `(${chain[0].cond} ? 0 : (${chain[1].cond} ? 1 : 2))`;
41584
- else if (chain.length === 2 && !finalRender)
41585
- branchInit = `(${chain[0].cond} ? 0 : (${chain[1].cond} ? 1 : -1))`;
41586
- else
41587
- branchInit = `(${chain[0].cond} ? 0 : -1)`;
41619
+ let branchInitFallback = finalRender ? `${chain.length}` : "-1";
41620
+ for (let i = chain.length - 1; i >= 0; i--) {
41621
+ branchInitFallback = `(${chain[i].cond} ? ${i} : ${branchInitFallback})`;
41622
+ }
41623
+ const branchInit = `(${branchInitFallback})`;
41588
41624
  let effInner = `if (__new === 0) { ${asyncKw2}${renderNames[0]}(); }`;
41589
41625
  for (let i = 1; i < chain.length; i++)
41590
41626
  effInner += ` else if (__new === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
41591
41627
  if (finalRender)
41592
41628
  effInner += ` else { ${asyncKw2}${finalRender}(); }`;
41593
41629
  const effBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
41594
- if (__first) { __first = false; return; }
41630
+ if (__first) { __first = false; __iv = ${branchInit}; return; }
41595
41631
  const __new = ${branchInit};
41596
41632
  if (__new !== __iv) {
41597
41633
  for (const e of ${effectsVar2}) destroy_block(e);
@@ -41638,7 +41674,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41638
41674
  if (hyd)
41639
41675
  ctx2.push(indent3(`const __cl = [];`));
41640
41676
  for (const n of node.consequentNodes) {
41677
+ const savedClaim = ctx2.claimStatic;
41678
+ if (hyd)
41679
+ ctx2.claimStatic = true;
41641
41680
  const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
41681
+ ctx2.claimStatic = savedClaim;
41642
41682
  if (v) {
41643
41683
  if (hyd)
41644
41684
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -41663,7 +41703,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41663
41703
  if (hyd)
41664
41704
  ctx2.push(indent3(`const __cl = [];`));
41665
41705
  for (const n of node.alternateNodes) {
41706
+ const savedAltClaim = ctx2.claimStatic;
41707
+ if (hyd)
41708
+ ctx2.claimStatic = true;
41666
41709
  const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
41710
+ ctx2.claimStatic = savedAltClaim;
41667
41711
  if (v) {
41668
41712
  if (hyd)
41669
41713
  ctx2.push(indent3(`__cl.push(${v});`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.23",
3
+ "version": "0.2.24",
4
4
  "type": "module",
5
5
  "description": "Vesk — compiler-first framework for the post-VDOM web. vesk dev, vesk build.",
6
6
  "bin": {
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "main": "./dist/cli.js",
10
10
  "dependencies": {
11
- "@vesk/adapter": "^0.2.23",
12
- "@vesk/compiler": "^0.2.23",
13
- "@vesk/plugin-tailwind": "^0.2.23",
14
- "@vesk/runtime": "^0.2.23",
11
+ "@vesk/adapter": "^0.2.24",
12
+ "@vesk/compiler": "^0.2.24",
13
+ "@vesk/plugin-tailwind": "^0.2.24",
14
+ "@vesk/runtime": "^0.2.24",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",