@vesk/vesk-cli 0.2.23 → 0.2.25

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 +55 -31
  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;
@@ -2892,16 +2893,17 @@ function showLoadingInContainer(container, loadingFn, params) {
2892
2893
  container.innerHTML = loadingContent;
2893
2894
  }
2894
2895
  }
2895
- function handleScroll(pathname, isReplace) {
2896
+ function handleScroll(pathname, isReplace, scrollBehavior) {
2896
2897
  if (typeof window === "undefined" || typeof window.scrollTo !== "function") return;
2898
+ const behavior = scrollBehavior === "smooth" || scrollBehavior === "instant" ? scrollBehavior : "auto";
2897
2899
  if (_isPopStateNavigation) {
2898
2900
  setIsPopStateNavigation(false);
2899
2901
  const savedY = _scrollPositions.get(pathname);
2900
2902
  requestAnimationFrame(() => {
2901
- window.scrollTo(0, savedY !== void 0 ? savedY : 0);
2903
+ window.scrollTo({ top: savedY !== void 0 ? savedY : 0, behavior });
2902
2904
  });
2903
2905
  } else if (!isReplace) {
2904
- requestAnimationFrame(() => window.scrollTo(0, 0));
2906
+ requestAnimationFrame(() => window.scrollTo({ top: 0, behavior }));
2905
2907
  }
2906
2908
  }
2907
2909
  function applyHead(headHtml) {
@@ -2986,7 +2988,7 @@ function Link(props, registry, hydrate) {
2986
2988
  e.preventDefault();
2987
2989
  e.stopPropagation();
2988
2990
  const nav = useNavigate();
2989
- nav(href);
2991
+ nav(href, { scrollBehavior: props.scrollBehavior });
2990
2992
  });
2991
2993
  return claimed ? document.createDocumentFragment() : a2;
2992
2994
  }
@@ -3018,7 +3020,7 @@ function Link(props, registry, hydrate) {
3018
3020
  e.preventDefault();
3019
3021
  e.stopPropagation();
3020
3022
  const nav = useNavigate();
3021
- nav(href);
3023
+ nav(href, { scrollBehavior: props.scrollBehavior });
3022
3024
  });
3023
3025
  return a;
3024
3026
  }
@@ -3058,7 +3060,7 @@ function NavLink(props, registry, hydrate) {
3058
3060
  e.preventDefault();
3059
3061
  e.stopPropagation();
3060
3062
  const nav = useNavigate();
3061
- nav(props.href);
3063
+ nav(props.href, { scrollBehavior: props.scrollBehavior });
3062
3064
  });
3063
3065
  const path2 = usePathname();
3064
3066
  const routeHref2 = routeHrefOf(props.href);
@@ -3088,7 +3090,7 @@ function NavLink(props, registry, hydrate) {
3088
3090
  e.preventDefault();
3089
3091
  e.stopPropagation();
3090
3092
  const nav = useNavigate();
3091
- nav(props.href);
3093
+ nav(props.href, { scrollBehavior: props.scrollBehavior });
3092
3094
  });
3093
3095
  const path2 = usePathname();
3094
3096
  const routeHref2 = routeHrefOf(props.href);
@@ -4302,9 +4304,6 @@ function createRouter(routes, options = {}) {
4302
4304
  },
4303
4305
  start() {
4304
4306
  setCurrentRouter(this);
4305
- if (typeof window !== "undefined" && "scrollRestoration" in window.history) {
4306
- window.history.scrollRestoration = "manual";
4307
- }
4308
4307
  if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
4309
4308
  let _scrollTimer = null;
4310
4309
  window.addEventListener("scroll", () => {
@@ -4416,7 +4415,7 @@ function createRouter(routes, options = {}) {
4416
4415
  }
4417
4416
  this._currentMatch = match;
4418
4417
  clearOfflineFlag(this, container);
4419
- handleScroll(url.pathname, opts.replace);
4418
+ handleScroll(url.pathname, opts.replace, opts.scrollBehavior);
4420
4419
  };
4421
4420
  const swapView = (fn) => {
4422
4421
  const d = document;
@@ -4624,9 +4623,6 @@ function createFileRouter(routeTree, options = {}) {
4624
4623
  },
4625
4624
  start() {
4626
4625
  setCurrentRouter(this);
4627
- if (typeof window !== "undefined" && "scrollRestoration" in window.history) {
4628
- window.history.scrollRestoration = "manual";
4629
- }
4630
4626
  if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
4631
4627
  let _scrollTimer = null;
4632
4628
  const _onScroll = () => {
@@ -4768,7 +4764,7 @@ function createFileRouter(routeTree, options = {}) {
4768
4764
  }
4769
4765
  router._currentMatch = match;
4770
4766
  clearOfflineFlag(router, container);
4771
- handleScroll(url.pathname, opts.replace);
4767
+ handleScroll(url.pathname, opts.replace, opts.scrollBehavior);
4772
4768
  };
4773
4769
  const doRender = () => {
4774
4770
  navDebug("doRender", url.pathname, "token=" + navToken);
@@ -27909,7 +27905,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27909
27905
  const cl = ctx2.n();
27910
27906
  ctx2.push(indent2(`const ${cl} = [];`));
27911
27907
  for (const n of chain[i].nodes) {
27908
+ const savedClaim = ctx2.claimStatic;
27909
+ if (hyd) ctx2.claimStatic = true;
27912
27910
  const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
27911
+ ctx2.claimStatic = savedClaim;
27913
27912
  if (v) ctx2.push(indent2(`${cl}.push(${v});`));
27914
27913
  }
27915
27914
  ctx2.push(indent2(`__place(${anchor2}, ${endAnchor2}, ${cl}, ${parent});`));
@@ -27922,7 +27921,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27922
27921
  const cl2 = ctx2.n();
27923
27922
  ctx2.push(indent2(`const ${cl2} = [];`));
27924
27923
  for (const n of finalElse) {
27924
+ const savedClaim = ctx2.claimStatic;
27925
+ if (hyd) ctx2.claimStatic = true;
27925
27926
  const v = emitNode(ctx2, n, tracked2, effectsVar2, parentVar);
27927
+ ctx2.claimStatic = savedClaim;
27926
27928
  if (v) ctx2.push(indent2(`${cl2}.push(${v});`));
27927
27929
  }
27928
27930
  ctx2.push(indent2(`__place(${anchor2}, ${endAnchor2}, ${cl2}, ${parent});`));
@@ -27932,16 +27934,16 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27932
27934
  for (let i = 1; i < chain.length; i++) init += ` else if (${chain[i].cond}) { ${asyncKw2}${renderNames[i]}(); }`;
27933
27935
  if (finalRender) init += ` else { ${asyncKw2}${finalRender}(); }`;
27934
27936
  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)`;
27937
+ let branchInitFallback = finalRender ? `${chain.length}` : "-1";
27938
+ for (let i = chain.length - 1; i >= 0; i--) {
27939
+ branchInitFallback = `(${chain[i].cond} ? ${i} : ${branchInitFallback})`;
27940
+ }
27941
+ const branchInit = `(${branchInitFallback})`;
27940
27942
  let effInner = `if (__new === 0) { ${asyncKw2}${renderNames[0]}(); }`;
27941
27943
  for (let i = 1; i < chain.length; i++) effInner += ` else if (__new === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
27942
27944
  if (finalRender) effInner += ` else { ${asyncKw2}${finalRender}(); }`;
27943
27945
  const effBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
27944
- if (__first) { __first = false; return; }
27946
+ if (__first) { __first = false; __iv = ${branchInit}; return; }
27945
27947
  const __new = ${branchInit};
27946
27948
  if (__new !== __iv) {
27947
27949
  for (const e of ${effectsVar2}) destroy_block(e);
@@ -27984,7 +27986,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
27984
27986
  if (!hyd) ctx2.push(indent2(`const ${conFrag} = document.createDocumentFragment();`));
27985
27987
  if (hyd) ctx2.push(indent2(`const __cl = [];`));
27986
27988
  for (const n of node.consequentNodes) {
27989
+ const savedClaim = ctx2.claimStatic;
27990
+ if (hyd) ctx2.claimStatic = true;
27987
27991
  const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
27992
+ ctx2.claimStatic = savedClaim;
27988
27993
  if (v) {
27989
27994
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
27990
27995
  else ctx2.push(indent2(`${conFrag}.appendChild(${v});`));
@@ -28002,7 +28007,10 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28002
28007
  if (!hyd) ctx2.push(indent2(`const ${altFrag} = document.createDocumentFragment();`));
28003
28008
  if (hyd) ctx2.push(indent2(`const __cl = [];`));
28004
28009
  for (const n of node.alternateNodes) {
28010
+ const savedAltClaim = ctx2.claimStatic;
28011
+ if (hyd) ctx2.claimStatic = true;
28005
28012
  const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
28013
+ ctx2.claimStatic = savedAltClaim;
28006
28014
  if (v) {
28007
28015
  if (hyd) ctx2.push(indent2(`__cl.push(${v});`));
28008
28016
  else ctx2.push(indent2(`${altFrag}.appendChild(${v});`));
@@ -29064,16 +29072,20 @@ function opaqueRegionToJS(node, isAsync = false, tracked2) {
29064
29072
  const lines = [];
29065
29073
  const cond = exprJSX(node.condition, tracked2);
29066
29074
  lines.push(`if (${cond}) {`);
29075
+ setVskForceClaim(true);
29067
29076
  for (const n of node.consequentNodes) {
29068
29077
  const code = irNodeToJS(n, null, isAsync, tracked2);
29069
29078
  if (code) lines.push(indent(code));
29070
29079
  }
29080
+ setVskForceClaim(false);
29071
29081
  if (node.alternateNodes.length > 0) {
29072
29082
  lines.push(`} else {`);
29083
+ setVskForceClaim(true);
29073
29084
  for (const n of node.alternateNodes) {
29074
29085
  const code = irNodeToJS(n, null, isAsync, tracked2);
29075
29086
  if (code) lines.push(indent(code));
29076
29087
  }
29088
+ setVskForceClaim(false);
29077
29089
  }
29078
29090
  lines.push(`}`);
29079
29091
  return lines.join("\n");
@@ -41549,7 +41561,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41549
41561
  const cl = ctx2.n();
41550
41562
  ctx2.push(indent3(`const ${cl} = [];`));
41551
41563
  for (const n of chain[i].nodes) {
41564
+ const savedClaim = ctx2.claimStatic;
41565
+ if (hyd)
41566
+ ctx2.claimStatic = true;
41552
41567
  const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
41568
+ ctx2.claimStatic = savedClaim;
41553
41569
  if (v)
41554
41570
  ctx2.push(indent3(`${cl}.push(${v});`));
41555
41571
  }
@@ -41563,7 +41579,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41563
41579
  const cl2 = ctx2.n();
41564
41580
  ctx2.push(indent3(`const ${cl2} = [];`));
41565
41581
  for (const n of finalElse) {
41582
+ const savedClaim = ctx2.claimStatic;
41583
+ if (hyd)
41584
+ ctx2.claimStatic = true;
41566
41585
  const v = emitNode2(ctx2, n, tracked2, effectsVar2, parentVar);
41586
+ ctx2.claimStatic = savedClaim;
41567
41587
  if (v)
41568
41588
  ctx2.push(indent3(`${cl2}.push(${v});`));
41569
41589
  }
@@ -41576,22 +41596,18 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41576
41596
  if (finalRender)
41577
41597
  init += ` else { ${asyncKw2}${finalRender}(); }`;
41578
41598
  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)`;
41599
+ let branchInitFallback = finalRender ? `${chain.length}` : "-1";
41600
+ for (let i = chain.length - 1; i >= 0; i--) {
41601
+ branchInitFallback = `(${chain[i].cond} ? ${i} : ${branchInitFallback})`;
41602
+ }
41603
+ const branchInit = `(${branchInitFallback})`;
41588
41604
  let effInner = `if (__new === 0) { ${asyncKw2}${renderNames[0]}(); }`;
41589
41605
  for (let i = 1; i < chain.length; i++)
41590
41606
  effInner += ` else if (__new === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
41591
41607
  if (finalRender)
41592
41608
  effInner += ` else { ${asyncKw2}${finalRender}(); }`;
41593
41609
  const effBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
41594
- if (__first) { __first = false; return; }
41610
+ if (__first) { __first = false; __iv = ${branchInit}; return; }
41595
41611
  const __new = ${branchInit};
41596
41612
  if (__new !== __iv) {
41597
41613
  for (const e of ${effectsVar2}) destroy_block(e);
@@ -41638,7 +41654,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41638
41654
  if (hyd)
41639
41655
  ctx2.push(indent3(`const __cl = [];`));
41640
41656
  for (const n of node.consequentNodes) {
41657
+ const savedClaim = ctx2.claimStatic;
41658
+ if (hyd)
41659
+ ctx2.claimStatic = true;
41641
41660
  const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : conFrag);
41661
+ ctx2.claimStatic = savedClaim;
41642
41662
  if (v) {
41643
41663
  if (hyd)
41644
41664
  ctx2.push(indent3(`__cl.push(${v});`));
@@ -41663,7 +41683,11 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
41663
41683
  if (hyd)
41664
41684
  ctx2.push(indent3(`const __cl = [];`));
41665
41685
  for (const n of node.alternateNodes) {
41686
+ const savedAltClaim = ctx2.claimStatic;
41687
+ if (hyd)
41688
+ ctx2.claimStatic = true;
41666
41689
  const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : altFrag);
41690
+ ctx2.claimStatic = savedAltClaim;
41667
41691
  if (v) {
41668
41692
  if (hyd)
41669
41693
  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.25",
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.25",
12
+ "@vesk/compiler": "^0.2.25",
13
+ "@vesk/plugin-tailwind": "^0.2.25",
14
+ "@vesk/runtime": "^0.2.25",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",