@firsthandjs/compiler 0.9.0 → 0.9.1

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.
@@ -920,7 +920,12 @@ function compileComponent(path, state) {
920
920
  }
921
921
  }
922
922
  }
923
- const children = compileChildren(node.children, state);
923
+ const throughRunCell = (value) => t.callExpression(throughCell(t.arrowFunctionExpression([], value)), []);
924
+ const children = compileChildren(node.children, state, {
925
+ depends: (value) => dependsOnRun(value, run, path),
926
+ cell: throughRunCell,
927
+ value: throughCell
928
+ });
924
929
  if (children.length === 1) {
925
930
  properties.push(
926
931
  t.objectMethod(
@@ -1733,7 +1738,7 @@ function cleanText(value) {
1733
1738
  }
1734
1739
  return kept.join(" ");
1735
1740
  }
1736
- function compileChildren(children, state) {
1741
+ function compileChildren(children, state, kept) {
1737
1742
  const result = [];
1738
1743
  for (const entry of planChildren(children)) {
1739
1744
  if (entry.kind === "text") {
@@ -1743,15 +1748,27 @@ function compileChildren(children, state) {
1743
1748
  } else if (state.firsthand.ssr) {
1744
1749
  result.push(entry.expression);
1745
1750
  } else if (entry.kind === "list") {
1746
- result.push(t.callExpression(runtime(state, "part"), [entry.expression]));
1751
+ const list = entry.expression;
1752
+ keepReading(list, kept);
1753
+ result.push(t.callExpression(runtime(state, "part"), [list]));
1747
1754
  } else {
1748
- result.push(
1749
- t.callExpression(runtime(state, "part"), [thunk(entry.expression)])
1750
- );
1755
+ const value = entry.expression;
1756
+ const read = kept !== void 0 && kept.depends(value) ? kept.cell(value) : value;
1757
+ result.push(t.callExpression(runtime(state, "part"), [thunk(read)]));
1751
1758
  }
1752
1759
  }
1753
1760
  return result;
1754
1761
  }
1762
+ function keepReading(list, kept) {
1763
+ const each = list.arguments[0];
1764
+ if (kept === void 0 || !t.isArrowFunctionExpression(each) || !t.isExpression(each.body)) {
1765
+ return;
1766
+ }
1767
+ if (!kept.depends(each.body)) {
1768
+ return;
1769
+ }
1770
+ each.body = kept.value(each.body);
1771
+ }
1755
1772
  function thunk(expression) {
1756
1773
  const arrow = t.arrowFunctionExpression([], expression);
1757
1774
  arrow[CHILD_THUNK] = true;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  firsthandPlugin,
4
4
  stableId,
5
5
  transform
6
- } from "./chunk-ACKKPAGI.js";
6
+ } from "./chunk-GUVVHV7H.js";
7
7
  export {
8
8
  compileModule,
9
9
  firsthandPlugin,
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  compileModule
3
- } from "./chunk-ACKKPAGI.js";
3
+ } from "./chunk-GUVVHV7H.js";
4
4
 
5
5
  // packages/compiler/src/vite.ts
6
6
  function firsthand(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firsthandjs/compiler",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Build-time TSX transform for Firsthand: static markup into templates, dynamic expressions into DOM parts.",
5
5
  "license": "MIT",
6
6
  "type": "module",