@vesk/vesk-cli 0.2.31 → 0.2.33

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 +61 -7
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -2139,15 +2139,27 @@ var init_resource = __esm({
2139
2139
  isServer = () => !!g().__vsk_ssr;
2140
2140
  ssrSink = null;
2141
2141
  DEFAULT_FAILURE_TTL = 1e4;
2142
- useFetch.text = (url, options) => useFetch(() => doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {})).then((r) => r.text()), {
2142
+ useFetch.text = (url, options) => useFetch(async () => {
2143
+ const res = await doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {}));
2144
+ if (!res.ok) throw new HttpError(res.status, res.statusText);
2145
+ return res.text();
2146
+ }, {
2143
2147
  ...options,
2144
2148
  key: options?.key ?? url
2145
2149
  });
2146
- useFetch.json = (url, options) => useFetch(() => doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {})).then((r) => r.json()), {
2150
+ useFetch.json = (url, options) => useFetch(async () => {
2151
+ const res = await doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {}));
2152
+ if (!res.ok) throw new HttpError(res.status, res.statusText);
2153
+ return res.json();
2154
+ }, {
2147
2155
  ...options,
2148
2156
  key: options?.key ?? url
2149
2157
  });
2150
- useFetch.arrayBuffer = (url, options) => useFetch(() => doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {})).then((r) => r.arrayBuffer()), {
2158
+ useFetch.arrayBuffer = (url, options) => useFetch(async () => {
2159
+ const res = await doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {}));
2160
+ if (!res.ok) throw new HttpError(res.status, res.statusText);
2161
+ return res.arrayBuffer();
2162
+ }, {
2151
2163
  ...options,
2152
2164
  key: options?.key ?? url
2153
2165
  });
@@ -2964,6 +2976,19 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
2964
2976
  }
2965
2977
  return null;
2966
2978
  }
2979
+ insertBeforeNextClaim(node) {
2980
+ let i = this.idx;
2981
+ while (i < this.markers.length && this.markers[i].state === "claimed") i++;
2982
+ const next = i < this.markers.length ? this.markers[i] : null;
2983
+ const host = next && next.comment.parentNode ? next.comment.parentNode : this.root;
2984
+ if (host === null || host === void 0) return false;
2985
+ try {
2986
+ host.insertBefore(node, next ? next.comment : null);
2987
+ return true;
2988
+ } catch {
2989
+ return false;
2990
+ }
2991
+ }
2967
2992
  };
2968
2993
  }
2969
2994
  });
@@ -28436,7 +28461,7 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28436
28461
  } else {
28437
28462
  const expr = transformTracked(attr.expression, tracked2);
28438
28463
  const useProp = PROPERTY_ATTRS[node.tag]?.has(target);
28439
- 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)); })`;
28464
+ 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)); })`;
28440
28465
  if (effectsVar) {
28441
28466
  ctx2.push(`${effectsVar}.push(${eff});`);
28442
28467
  } else {
@@ -28492,7 +28517,7 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
28492
28517
  } else {
28493
28518
  const expr = transformTracked(attr.expression, tracked2);
28494
28519
  const useProp = PROPERTY_ATTRS[node.tag]?.has(target);
28495
- 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)); })`;
28520
+ 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)); })`;
28496
28521
  if (effectsVar) {
28497
28522
  ctx2.push(`${effectsVar}.push(${eff});`);
28498
28523
  } else {
@@ -28727,6 +28752,14 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
28727
28752
  }
28728
28753
  return v;
28729
28754
  }
28755
+ function emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, rootLevel) {
28756
+ if (!ctx2.hydrate || !rootLevel) return;
28757
+ ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
28758
+ ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
28759
+ ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${anchor});`));
28760
+ ctx2.push(indent2(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
28761
+ ctx2.push(`}`);
28762
+ }
28730
28763
  function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28731
28764
  const anchor = ctx2.n();
28732
28765
  const endAnchor = ctx2.n();
@@ -28737,6 +28770,7 @@ function emitTryCatch(ctx2, node, tracked2, effectsVar, parentVar) {
28737
28770
  if (!ctx2.hydrate) ctx2.push(`${parent}.appendChild(${anchor});`);
28738
28771
  ctx2.push(`let ${effArr} = [];`);
28739
28772
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
28773
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
28740
28774
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28741
28775
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
28742
28776
  const savedHydrate = ctx2.hydrate;
@@ -28823,6 +28857,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28823
28857
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
28824
28858
  ctx2.push(`let ${effectsVar2} = [];`);
28825
28859
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
28860
+ emitHydrateFenceAnchoring(ctx2, anchor2, endAnchor2, parent === "$root");
28826
28861
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
28827
28862
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
28828
28863
  const renderNames = [];
@@ -28905,6 +28940,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar) {
28905
28940
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
28906
28941
  ctx2.push(`let ${effectsVar} = [];`);
28907
28942
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
28943
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
28908
28944
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
28909
28945
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
28910
28946
  const conRenderName = ctx2.n();
@@ -28989,6 +29025,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar) {
28989
29025
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
28990
29026
  ctx2.push(`let ${effectsVar} = [];`);
28991
29027
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
29028
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
28992
29029
  const renderLoop = ctx2.n();
28993
29030
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
28994
29031
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29051,6 +29088,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar) {
29051
29088
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29052
29089
  ctx2.push(`let ${effectsVar} = [];`);
29053
29090
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
29091
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29054
29092
  const renderLoop = ctx2.n();
29055
29093
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29056
29094
  if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
@@ -29191,6 +29229,7 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar) {
29191
29229
  if (!hyd) ctx2.push(`${parent}.appendChild(${anchor});`);
29192
29230
  ctx2.push(`let ${effectsVar} = [];`);
29193
29231
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
29232
+ emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root");
29194
29233
  const renderSwitch = ctx2.n();
29195
29234
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
29196
29235
  if (hyd) {
@@ -42368,7 +42407,7 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42368
42407
  } else {
42369
42408
  const expr = transformTracked2(attr.expression, tracked2);
42370
42409
  const useProp = PROPERTY_ATTRS2[node.tag]?.has(target);
42371
- 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)); })`;
42410
+ 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)); })`;
42372
42411
  if (effectsVar) {
42373
42412
  ctx2.push(`${effectsVar}.push(${eff});`);
42374
42413
  } else {
@@ -42424,7 +42463,7 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
42424
42463
  } else {
42425
42464
  const expr = transformTracked2(attr.expression, tracked2);
42426
42465
  const useProp = PROPERTY_ATTRS2[node.tag]?.has(target);
42427
- 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)); })`;
42466
+ 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)); })`;
42428
42467
  if (effectsVar) {
42429
42468
  ctx2.push(`${effectsVar}.push(${eff});`);
42430
42469
  } else {
@@ -42687,6 +42726,15 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
42687
42726
  }
42688
42727
  return v;
42689
42728
  }
42729
+ function emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, rootLevel) {
42730
+ if (!ctx2.hydrate || !rootLevel)
42731
+ return;
42732
+ ctx2.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
42733
+ ctx2.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
42734
+ ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${anchor});`));
42735
+ ctx2.push(indent3(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
42736
+ ctx2.push(`}`);
42737
+ }
42690
42738
  function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42691
42739
  const anchor = ctx2.n();
42692
42740
  const endAnchor = ctx2.n();
@@ -42698,6 +42746,7 @@ function emitTryCatch2(ctx2, node, tracked2, effectsVar, parentVar) {
42698
42746
  ctx2.push(`${parent}.appendChild(${anchor});`);
42699
42747
  ctx2.push(`let ${effArr} = [];`);
42700
42748
  ctx2.push(`const ${endAnchor} = document.createComment('try-end');`);
42749
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
42701
42750
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
42702
42751
  function emitRenderFunc(name, isCatch, hydMode, compPrefix = "__components") {
42703
42752
  const savedHydrate = ctx2.hydrate;
@@ -42788,6 +42837,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
42788
42837
  ctx2.push(`const ${anchor2} = document.createComment('if');`);
42789
42838
  ctx2.push(`let ${effectsVar2} = [];`);
42790
42839
  ctx2.push(`const ${endAnchor2} = document.createComment('if-end');`);
42840
+ emitHydrateFenceAnchoring2(ctx2, anchor2, endAnchor2, parent === "$root");
42791
42841
  const asyncKw2 = ctx2.isAsyncScope ? "await " : "";
42792
42842
  const fnOpen2 = ctx2.isAsyncScope ? "async () => {" : "() => {";
42793
42843
  const renderNames = [];
@@ -42879,6 +42929,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar) {
42879
42929
  ctx2.push(`${parent}.appendChild(${anchor});`);
42880
42930
  ctx2.push(`let ${effectsVar} = [];`);
42881
42931
  ctx2.push(`const ${endAnchor} = document.createComment('if-end');`);
42932
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
42882
42933
  const asyncKw = ctx2.isAsyncScope ? "await " : "";
42883
42934
  const fnOpen = ctx2.isAsyncScope ? "async () => {" : "() => {";
42884
42935
  const conRenderName = ctx2.n();
@@ -42982,6 +43033,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar) {
42982
43033
  ctx2.push(`${parent}.appendChild(${anchor});`);
42983
43034
  ctx2.push(`let ${effectsVar} = [];`);
42984
43035
  ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
43036
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
42985
43037
  const renderLoop = ctx2.n();
42986
43038
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
42987
43039
  if (!hyd)
@@ -43055,6 +43107,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar) {
43055
43107
  ctx2.push(`${parent}.appendChild(${anchor});`);
43056
43108
  ctx2.push(`let ${effectsVar} = [];`);
43057
43109
  ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
43110
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43058
43111
  const renderLoop = ctx2.n();
43059
43112
  ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43060
43113
  if (!hyd)
@@ -43210,6 +43263,7 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar) {
43210
43263
  ctx2.push(`${parent}.appendChild(${anchor});`);
43211
43264
  ctx2.push(`let ${effectsVar} = [];`);
43212
43265
  ctx2.push(`const ${endAnchor} = document.createComment('switch-end');`);
43266
+ emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root");
43213
43267
  const renderSwitch = ctx2.n();
43214
43268
  ctx2.push(`const ${renderSwitch} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
43215
43269
  if (hyd) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.31",
3
+ "version": "0.2.33",
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.31",
12
- "@vesk/compiler": "^0.2.31",
13
- "@vesk/plugin-tailwind": "^0.2.31",
14
- "@vesk/runtime": "^0.2.31",
11
+ "@vesk/adapter": "^0.2.33",
12
+ "@vesk/compiler": "^0.2.33",
13
+ "@vesk/plugin-tailwind": "^0.2.33",
14
+ "@vesk/runtime": "^0.2.33",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",