@vesk/vesk-cli 0.2.30 → 0.2.32

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 +81 -6
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -1619,6 +1619,17 @@ function getInflight() {
1619
1619
  g().__vsk_fetch_inflight = map;
1620
1620
  return map;
1621
1621
  }
1622
+ function getServerFailureCache() {
1623
+ const value = g().__vsk_ssr_failure_cache;
1624
+ if (value) return value;
1625
+ const map = /* @__PURE__ */ new Map();
1626
+ g().__vsk_ssr_failure_cache = map;
1627
+ return map;
1628
+ }
1629
+ function clearFailureCache(key) {
1630
+ if (!isServer()) return;
1631
+ g().__vsk_ssr_failure_cache?.delete(key);
1632
+ }
1622
1633
  function getRegistry() {
1623
1634
  const value = g().__vsk_fetch_registry;
1624
1635
  if (value) return value;
@@ -1887,6 +1898,20 @@ function startRequest(handle2, skipCache) {
1887
1898
  const key = handle2.key;
1888
1899
  const options = handle2.options;
1889
1900
  if (isServer()) {
1901
+ const failureTtl = options.failureTtl ?? DEFAULT_FAILURE_TTL;
1902
+ if (!skipCache && failureTtl > 0) {
1903
+ const failed = getServerFailureCache().get(key);
1904
+ if (failed && failed.ttl > 0 && Date.now() - failed.failedAt < failed.ttl) {
1905
+ getSsrFailures()?.set(key, failed.error);
1906
+ settleError(handle2, failed.error);
1907
+ const settled = handle2.settled.then(() => {
1908
+ throw failed.error;
1909
+ });
1910
+ settled.catch(() => {
1911
+ });
1912
+ return settled;
1913
+ }
1914
+ }
1890
1915
  const recorded = !skipCache ? getSsrFailures()?.get(key) : void 0;
1891
1916
  if (recorded !== void 0) {
1892
1917
  settleError(handle2, recorded);
@@ -1905,10 +1930,14 @@ function startRequest(handle2, skipCache) {
1905
1930
  prom2.then(
1906
1931
  (data2) => {
1907
1932
  setSsrData(key, data2, startToken);
1933
+ clearFailureCache(key);
1908
1934
  settle(handle2, data2);
1909
1935
  },
1910
1936
  (error) => {
1911
1937
  getSsrFailures()?.set(key, error);
1938
+ if (isServer() && !isAbortError(error) && failureTtl > 0) {
1939
+ getServerFailureCache().set(key, { error, failedAt: Date.now(), ttl: failureTtl });
1940
+ }
1912
1941
  settleError(handle2, error);
1913
1942
  }
1914
1943
  ).finally(() => {
@@ -2056,7 +2085,10 @@ function createResource(fn, key, into, options = {}) {
2056
2085
  }
2057
2086
  const ssrData = getSsrData(resourceKey);
2058
2087
  if (ssrData !== void 0) {
2059
- if (isServer()) setSsrData(resourceKey, ssrData);
2088
+ if (isServer()) {
2089
+ setSsrData(resourceKey, ssrData);
2090
+ clearFailureCache(resourceKey);
2091
+ }
2060
2092
  settle(handle2, ssrData);
2061
2093
  writeCache(resourceKey, ssrData);
2062
2094
  return accessor;
@@ -2081,7 +2113,7 @@ async function resolveSsrResources() {
2081
2113
  delete g().__vsk_ssr_failures;
2082
2114
  return data2;
2083
2115
  }
2084
- var HttpError, TimeoutError, g, isServer, ssrSink;
2116
+ var HttpError, TimeoutError, g, isServer, ssrSink, DEFAULT_FAILURE_TTL;
2085
2117
  var init_resource = __esm({
2086
2118
  "../runtime/src/resource.ts"() {
2087
2119
  "use strict";
@@ -2106,6 +2138,7 @@ var init_resource = __esm({
2106
2138
  g = () => globalThis;
2107
2139
  isServer = () => !!g().__vsk_ssr;
2108
2140
  ssrSink = null;
2141
+ DEFAULT_FAILURE_TTL = 1e4;
2109
2142
  useFetch.text = (url, options) => useFetch(() => doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {})).then((r) => r.text()), {
2110
2143
  ...options,
2111
2144
  key: options?.key ?? url
@@ -2931,6 +2964,19 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
2931
2964
  }
2932
2965
  return null;
2933
2966
  }
2967
+ insertBeforeNextClaim(node) {
2968
+ let i = this.idx;
2969
+ while (i < this.markers.length && this.markers[i].state === "claimed") i++;
2970
+ const next = i < this.markers.length ? this.markers[i] : null;
2971
+ const host = next && next.comment.parentNode ? next.comment.parentNode : this.root;
2972
+ if (host === null || host === void 0) return false;
2973
+ try {
2974
+ host.insertBefore(node, next ? next.comment : null);
2975
+ return true;
2976
+ } catch {
2977
+ return false;
2978
+ }
2979
+ }
2934
2980
  };
2935
2981
  }
2936
2982
  });
@@ -28403,7 +28449,7 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28403
28449
  } else {
28404
28450
  const expr = transformTracked(attr.expression, tracked2);
28405
28451
  const useProp = PROPERTY_ATTRS[node.tag]?.has(target);
28406
- const eff = useProp ? `effect(() => { ${ssrEl}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v != null && __v !== false) ${ssrEl}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
28452
+ const eff = useProp ? `effect(() => { ${ssrEl}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v == null || __v === false) ${ssrEl}.removeAttribute(${JSON.stringify(target)}); else ${ssrEl}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
28407
28453
  if (effectsVar) {
28408
28454
  ctx2.push(`${effectsVar}.push(${eff});`);
28409
28455
  } else {
@@ -28459,7 +28505,7 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28459
28505
  } else {
28460
28506
  const expr = transformTracked(attr.expression, tracked2);
28461
28507
  const useProp = PROPERTY_ATTRS[node.tag]?.has(target);
28462
- const eff = useProp ? `effect(() => { ${el}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v != null && __v !== false) ${el}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
28508
+ const eff = useProp ? `effect(() => { ${el}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v == null || __v === false) ${el}.removeAttribute(${JSON.stringify(target)}); else ${el}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
28463
28509
  if (effectsVar) {
28464
28510
  ctx2.push(`${effectsVar}.push(${eff});`);
28465
28511
  } else {
@@ -28694,6 +28740,14 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28694
28740
  }
28695
28741
  return v;
28696
28742
  }
28743
+ function emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, rootLevel) {
28744
+ if (!ctx2.hydrate || !rootLevel) return;
28745
+ ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
28746
+ ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
28747
+ ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${anchor});`));
28748
+ ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
28749
+ ctx2.push(`}`);
28750
+ }
28697
28751
  function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28698
28752
  const anchor = ctx2.n();
28699
28753
  const endAnchor = ctx2.n();
@@ -28704,6 +28758,7 @@ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28704
28758
  if (!ctx2.hydrate) ctx2.push(`${parent}.appendChild(${anchor});`);
28705
28759
  ctx2.push(`let ${effArr} = [];`);
28706
28760
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
28761
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
28707
28762
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28708
28763
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
28709
28764
  const savedHydrate = ctx2.hydrate;
@@ -28790,6 +28845,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28790
28845
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
28791
28846
  ctx2.push(`let ${effectsVar2} = [];`);
28792
28847
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
28848
+ emitHydrateFenceAnchoring(ctx2, anchor2, endAnchor2, parent === "$root");
28793
28849
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
28794
28850
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
28795
28851
  const renderNames = [];
@@ -28872,6 +28928,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28872
28928
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
28873
28929
  ctx2.push(`let ${effectsVar} = [];`);
28874
28930
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
28931
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
28875
28932
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28876
28933
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
28877
28934
  const conRenderName = ctx2.n();
@@ -28956,6 +29013,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
28956
29013
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
28957
29014
  ctx2.push(`let ${effectsVar} = [];`);
28958
29015
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
29016
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
28959
29017
  const renderLoop = ctx2.n();
28960
29018
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
28961
29019
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29018,6 +29076,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29018
29076
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29019
29077
  ctx2.push(`let ${effectsVar} = [];`);
29020
29078
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
29079
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29021
29080
  const renderLoop = ctx2.n();
29022
29081
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29023
29082
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29158,6 +29217,7 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29158
29217
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29159
29218
  ctx2.push(`let ${effectsVar} = [];`);
29160
29219
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
29220
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29161
29221
  const renderSwitch = ctx2.n();
29162
29222
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29163
29223
  if (hyd) {
@@ -42335,7 +42395,7 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42335
42395
  } else {
42336
42396
  const expr = transformTracked2(attr.expression, tracked2);
42337
42397
  const useProp = PROPERTY_ATTRS2[node.tag]?.has(target);
42338
- const eff = useProp ? `effect(() => { ${ssrEl}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v != null && __v !== false) ${ssrEl}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
42398
+ const eff = useProp ? `effect(() => { ${ssrEl}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v == null || __v === false) ${ssrEl}.removeAttribute(${JSON.stringify(target)}); else ${ssrEl}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
42339
42399
  if (effectsVar) {
42340
42400
  ctx2.push(`${effectsVar}.push(${eff});`);
42341
42401
  } else {
@@ -42391,7 +42451,7 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42391
42451
  } else {
42392
42452
  const expr = transformTracked2(attr.expression, tracked2);
42393
42453
  const useProp = PROPERTY_ATTRS2[node.tag]?.has(target);
42394
- const eff = useProp ? `effect(() => { ${el}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v != null && __v !== false) ${el}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
42454
+ const eff = useProp ? `effect(() => { ${el}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v == null || __v === false) ${el}.removeAttribute(${JSON.stringify(target)}); else ${el}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
42395
42455
  if (effectsVar) {
42396
42456
  ctx2.push(`${effectsVar}.push(${eff});`);
42397
42457
  } else {
@@ -42654,6 +42714,15 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42654
42714
  }
42655
42715
  return v;
42656
42716
  }
42717
+ function emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, rootLevel) {
42718
+ if (!ctx2.hydrate || !rootLevel)
42719
+ return;
42720
+ ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
42721
+ ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
42722
+ ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${anchor});`));
42723
+ ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
42724
+ ctx2.push(`}`);
42725
+ }
42657
42726
  function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42658
42727
  const anchor = ctx2.n();
42659
42728
  const endAnchor = ctx2.n();
@@ -42665,6 +42734,7 @@ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42665
42734
  ctx2.push(`${parent}.appendChild(${anchor});`);
42666
42735
  ctx2.push(`let ${effArr} = [];`);
42667
42736
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
42737
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
42668
42738
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
42669
42739
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
42670
42740
  const savedHydrate = ctx2.hydrate;
@@ -42755,6 +42825,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
42755
42825
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
42756
42826
  ctx2.push(`let ${effectsVar2} = [];`);
42757
42827
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
42828
+ emitHydrateFenceAnchoring2(ctx2, anchor2, endAnchor2, parent === "$root");
42758
42829
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
42759
42830
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
42760
42831
  const renderNames = [];
@@ -42846,6 +42917,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
42846
42917
  ctx2.push(`${parent}.appendChild(${anchor});`);
42847
42918
  ctx2.push(`let ${effectsVar} = [];`);
42848
42919
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
42920
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
42849
42921
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
42850
42922
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
42851
42923
  const conRenderName = ctx2.n();
@@ -42949,6 +43021,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
42949
43021
  ctx2.push(`${parent}.appendChild(${anchor});`);
42950
43022
  ctx2.push(`let ${effectsVar} = [];`);
42951
43023
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
43024
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
42952
43025
  const renderLoop = ctx2.n();
42953
43026
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
42954
43027
  if (!hyd)
@@ -43022,6 +43095,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43022
43095
  ctx2.push(`${parent}.appendChild(${anchor});`);
43023
43096
  ctx2.push(`let ${effectsVar} = [];`);
43024
43097
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
43098
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43025
43099
  const renderLoop = ctx2.n();
43026
43100
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43027
43101
  if (!hyd)
@@ -43177,6 +43251,7 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43177
43251
  ctx2.push(`${parent}.appendChild(${anchor});`);
43178
43252
  ctx2.push(`let ${effectsVar} = [];`);
43179
43253
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
43254
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43180
43255
  const renderSwitch = ctx2.n();
43181
43256
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43182
43257
  if (hyd) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.30",
3
+ "version": "0.2.32",
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.30",
12
- "@vesk/compiler": "^0.2.30",
13
- "@vesk/plugin-tailwind": "^0.2.30",
14
- "@vesk/runtime": "^0.2.30",
11
+ "@vesk/adapter": "^0.2.32",
12
+ "@vesk/compiler": "^0.2.32",
13
+ "@vesk/plugin-tailwind": "^0.2.32",
14
+ "@vesk/runtime": "^0.2.32",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",