marko 6.0.0-next.3.68 → 6.0.0-next.3.69

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.
@@ -501,11 +501,7 @@ var Reference = class {
501
501
  };
502
502
  var DEBUG = /* @__PURE__ */ new WeakMap();
503
503
  function setDebugInfo(obj, file, loc, vars) {
504
- DEBUG.set(obj, {
505
- file,
506
- loc,
507
- vars
508
- });
504
+ DEBUG.set(obj, { file, loc, vars });
509
505
  }
510
506
  var Serializer = class {
511
507
  #state = new State();
@@ -564,10 +560,7 @@ function register(id, val, scope) {
564
560
  function getRegistered(val) {
565
561
  const registered = REGISTRY.get(val);
566
562
  if (registered) {
567
- return {
568
- id: registered.id,
569
- scope: registered.scope
570
- };
563
+ return { id: registered.id, scope: registered.scope };
571
564
  }
572
565
  }
573
566
  function writeRoot(state, root) {
@@ -737,7 +730,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
737
730
  return true;
738
731
  }
739
732
  if (scopeRef) {
740
- if (isCircular(parent, scopeRef)) {
733
+ if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef))) {
741
734
  state.assigned.add(parent);
742
735
  state.assigned.add(fnRef);
743
736
  fnRef.init = access + "(" + ensureId(state, scopeRef) + ")";
@@ -1593,7 +1586,7 @@ function withContext(key, value, cb) {
1593
1586
  ctx[kPendingContexts]++;
1594
1587
  ctx[key] = value;
1595
1588
  try {
1596
- cb();
1589
+ return cb();
1597
1590
  } finally {
1598
1591
  ctx[kPendingContexts]--;
1599
1592
  ctx[key] = prev;
@@ -1654,23 +1647,33 @@ function hoist(scopeId, id) {
1654
1647
  function resumeClosestBranch(scopeId) {
1655
1648
  const branchId = $chunk.context?.[branchIdKey];
1656
1649
  if (branchId !== void 0 && branchId !== scopeId) {
1657
- writeScope(scopeId, {
1658
- ["#ClosestBranchId" /* ClosestBranchId */]: branchId
1659
- });
1650
+ writeScope(scopeId, { ["#ClosestBranchId" /* ClosestBranchId */]: branchId });
1660
1651
  }
1661
1652
  }
1662
1653
  var branchIdKey = Symbol();
1663
- function resumeForOf(list, cb, scopeId, accessor) {
1664
- forOf(list, (item, i) => {
1654
+ function withBranchId(branchId, cb) {
1655
+ return withContext(branchIdKey, branchId, cb);
1656
+ }
1657
+ function resumeForOf(list, cb, by, scopeId, accessor) {
1658
+ const loopScopes = /* @__PURE__ */ new Map();
1659
+ forOf(list, (item, index) => {
1665
1660
  const branchId = peekNextScopeId();
1666
1661
  $chunk.writeHTML(
1667
1662
  $chunk.boundary.state.mark(
1668
1663
  "[" /* BranchStart */,
1669
- branchId + (i ? " " : "")
1664
+ branchId + (index ? " " : "")
1670
1665
  )
1671
1666
  );
1672
- withContext(branchIdKey, branchId, () => cb(item, i));
1667
+ withBranchId(branchId, () => {
1668
+ cb(item, index);
1669
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1670
+ });
1673
1671
  });
1672
+ if (loopScopes.size) {
1673
+ writeScope(scopeId, {
1674
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1675
+ });
1676
+ }
1674
1677
  $chunk.writeHTML(
1675
1678
  $chunk.boundary.state.mark(
1676
1679
  "]" /* BranchEnd */,
@@ -1678,13 +1681,22 @@ function resumeForOf(list, cb, scopeId, accessor) {
1678
1681
  )
1679
1682
  );
1680
1683
  }
1681
- function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
1684
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
1685
+ const loopScopes = /* @__PURE__ */ new Map();
1682
1686
  let branchIds = "";
1683
1687
  forOf(list, (item, index) => {
1684
1688
  const branchId = peekNextScopeId();
1685
1689
  branchIds = " " + branchId + branchIds;
1686
- withContext(branchIdKey, branchId, () => cb(item, index));
1690
+ withBranchId(branchId, () => {
1691
+ cb(item, index);
1692
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1693
+ });
1687
1694
  });
1695
+ if (loopScopes.size) {
1696
+ writeScope(scopeId, {
1697
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1698
+ });
1699
+ }
1688
1700
  $chunk.writeHTML(
1689
1701
  $chunk.boundary.state.mark(
1690
1702
  onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1692,7 +1704,17 @@ function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
1692
1704
  )
1693
1705
  );
1694
1706
  }
1695
- function resumeForIn(obj, cb, scopeId, accessor) {
1707
+ function forOfBy(by, item, index) {
1708
+ if (by) {
1709
+ if (typeof by === "string") {
1710
+ return item[by];
1711
+ }
1712
+ return by(item, index);
1713
+ }
1714
+ return index;
1715
+ }
1716
+ function resumeForIn(obj, cb, by, scopeId, accessor) {
1717
+ const loopScopes = /* @__PURE__ */ new Map();
1696
1718
  let sep = "";
1697
1719
  forIn(obj, (key, value) => {
1698
1720
  const branchId = peekNextScopeId();
@@ -1700,8 +1722,16 @@ function resumeForIn(obj, cb, scopeId, accessor) {
1700
1722
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1701
1723
  );
1702
1724
  sep = " ";
1703
- withContext(branchIdKey, branchId, () => cb(key, value));
1725
+ withBranchId(branchId, () => {
1726
+ cb(key, value);
1727
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1728
+ });
1704
1729
  });
1730
+ if (loopScopes.size) {
1731
+ writeScope(scopeId, {
1732
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1733
+ });
1734
+ }
1705
1735
  $chunk.writeHTML(
1706
1736
  $chunk.boundary.state.mark(
1707
1737
  "]" /* BranchEnd */,
@@ -1709,13 +1739,22 @@ function resumeForIn(obj, cb, scopeId, accessor) {
1709
1739
  )
1710
1740
  );
1711
1741
  }
1712
- function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
1742
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
1743
+ const loopScopes = /* @__PURE__ */ new Map();
1713
1744
  let branchIds = "";
1714
1745
  forIn(obj, (key, value) => {
1715
1746
  const branchId = peekNextScopeId();
1716
1747
  branchIds = " " + branchId + branchIds;
1717
- withContext(branchIdKey, branchId, () => cb(key, value));
1748
+ withBranchId(branchId, () => {
1749
+ cb(key, value);
1750
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1751
+ });
1718
1752
  });
1753
+ if (loopScopes.size) {
1754
+ writeScope(scopeId, {
1755
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1756
+ });
1757
+ }
1719
1758
  $chunk.writeHTML(
1720
1759
  $chunk.boundary.state.mark(
1721
1760
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1723,7 +1762,14 @@ function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
1723
1762
  )
1724
1763
  );
1725
1764
  }
1726
- function resumeForTo(to, from, step, cb, scopeId, accessor) {
1765
+ function forInBy(by, name, value) {
1766
+ if (by) {
1767
+ return by(name, value);
1768
+ }
1769
+ return name;
1770
+ }
1771
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1772
+ const loopScopes = /* @__PURE__ */ new Map();
1727
1773
  let sep = "";
1728
1774
  forTo(to, from, step, (index) => {
1729
1775
  const branchId = peekNextScopeId();
@@ -1731,8 +1777,16 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
1731
1777
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1732
1778
  );
1733
1779
  sep = " ";
1734
- withContext(branchIdKey, branchId, () => cb(index));
1780
+ withBranchId(branchId, () => {
1781
+ cb(index);
1782
+ loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1783
+ });
1735
1784
  });
1785
+ if (loopScopes.size) {
1786
+ writeScope(scopeId, {
1787
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1788
+ });
1789
+ }
1736
1790
  $chunk.writeHTML(
1737
1791
  $chunk.boundary.state.mark(
1738
1792
  "]" /* BranchEnd */,
@@ -1740,13 +1794,22 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
1740
1794
  )
1741
1795
  );
1742
1796
  }
1743
- function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
1797
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
1798
+ const loopScopes = /* @__PURE__ */ new Map();
1744
1799
  let branchIds = "";
1745
1800
  forTo(to, from, step, (index) => {
1746
1801
  const branchId = peekNextScopeId();
1747
1802
  branchIds = " " + branchId + branchIds;
1748
- withContext(branchIdKey, branchId, () => cb(index));
1803
+ withBranchId(branchId, () => {
1804
+ cb(index);
1805
+ loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1806
+ });
1749
1807
  });
1808
+ if (loopScopes.size) {
1809
+ writeScope(scopeId, {
1810
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1811
+ });
1812
+ }
1750
1813
  $chunk.writeHTML(
1751
1814
  $chunk.boundary.state.mark(
1752
1815
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1754,40 +1817,57 @@ function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild)
1754
1817
  )
1755
1818
  );
1756
1819
  }
1757
- function resumeConditional(cb, scopeId, accessor) {
1820
+ function forToBy(by, index) {
1821
+ if (by) {
1822
+ return by(index);
1823
+ }
1824
+ return index;
1825
+ }
1826
+ function resumeConditional(cb, scopeId, accessor, dynamic) {
1758
1827
  const branchId = peekNextScopeId();
1759
- $chunk.writeHTML(
1760
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1761
- );
1762
- withContext(branchIdKey, branchId, cb);
1763
- const rendered = peekNextScopeId() !== branchId;
1764
- if (rendered) {
1765
- writeScope(branchId, {});
1828
+ if (dynamic) {
1829
+ $chunk.writeHTML(
1830
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1831
+ );
1832
+ }
1833
+ const branchIndex = withBranchId(branchId, cb);
1834
+ if (branchIndex !== void 0) {
1835
+ writeScope(scopeId, {
1836
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1837
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1838
+ });
1766
1839
  } else {
1767
1840
  nextScopeId();
1768
1841
  }
1769
- $chunk.writeHTML(
1770
- $chunk.boundary.state.mark(
1771
- "]" /* BranchEnd */,
1772
- scopeId + " " + accessor
1773
- )
1774
- );
1842
+ if (dynamic) {
1843
+ $chunk.writeHTML(
1844
+ $chunk.boundary.state.mark(
1845
+ "]" /* BranchEnd */,
1846
+ scopeId + " " + accessor
1847
+ )
1848
+ );
1849
+ }
1775
1850
  }
1776
- function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
1851
+ function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
1777
1852
  const branchId = peekNextScopeId();
1778
- withContext(branchIdKey, branchId, cb);
1779
- const rendered = peekNextScopeId() !== branchId;
1853
+ const branchIndex = withBranchId(branchId, cb);
1854
+ const rendered = branchIndex !== void 0;
1780
1855
  if (rendered) {
1781
- writeScope(branchId, {});
1856
+ writeScope(scopeId, {
1857
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1858
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1859
+ });
1782
1860
  } else {
1783
1861
  nextScopeId();
1784
1862
  }
1785
- $chunk.writeHTML(
1786
- $chunk.boundary.state.mark(
1787
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1788
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
1789
- )
1790
- );
1863
+ if (dynamic) {
1864
+ $chunk.writeHTML(
1865
+ $chunk.boundary.state.mark(
1866
+ onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1867
+ scopeId + " " + accessor + (rendered ? " " + branchId : "")
1868
+ )
1869
+ );
1870
+ }
1791
1871
  }
1792
1872
  var writeScope = (scopeId, partialScope) => {
1793
1873
  const { state } = $chunk.boundary;
@@ -2640,117 +2720,97 @@ var DEFAULT_RENDER_ID = "_";
2640
2720
 
2641
2721
  // src/html/dynamic-tag.ts
2642
2722
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2643
- function dynamicTagId(tagName) {
2644
- const normalizedRenderer = normalizeDynamicRenderer(tagName);
2645
- return normalizedRenderer?.___id || normalizedRenderer;
2646
- }
2647
- var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
2648
- if (!tag && !content) {
2649
- nextScopeId();
2650
- return;
2651
- }
2652
- if (!tag) {
2653
- resumeConditional(content, scopeId, accessor);
2654
- return;
2723
+ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
2724
+ const renderer = normalizeDynamicRenderer(tag);
2725
+ if (true) {
2726
+ if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
2727
+ throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
2728
+ }
2655
2729
  }
2656
- if (typeof tag === "string") {
2657
- resumeSingleNodeConditional(
2658
- () => {
2659
- nextScopeId();
2660
- write(`<${tag}${attrs(input, accessor, scopeId, tag)}>`);
2661
- if (!voidElementsReg.test(tag)) {
2662
- if (tag === "textarea") {
2663
- if (content) {
2664
- throw new Error(
2665
- "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
2666
- );
2667
- }
2668
- write(
2669
- controllable_textarea_value(
2670
- scopeId,
2671
- accessor,
2672
- input.value,
2673
- input.valueChange
2674
- )
2730
+ const chunk = getChunk();
2731
+ const branchId = peekNextScopeId();
2732
+ let result;
2733
+ if (typeof renderer === "string") {
2734
+ const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2735
+ nextScopeId();
2736
+ write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
2737
+ if (!voidElementsReg.test(renderer)) {
2738
+ withBranchId(branchId, () => {
2739
+ if (renderer === "textarea") {
2740
+ if (content) {
2741
+ throw new Error(
2742
+ "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
2675
2743
  );
2676
- } else if (content) {
2677
- if (tag === "select" && ("value" in input || "valueChange" in input)) {
2678
- controllable_select_value(
2679
- scopeId,
2680
- accessor,
2681
- input.value,
2682
- input.valueChange,
2683
- content
2684
- );
2685
- } else {
2686
- content();
2687
- }
2688
2744
  }
2689
- write(`</${tag}>`);
2745
+ write(
2746
+ controllable_textarea_value(
2747
+ scopeId,
2748
+ accessor,
2749
+ input.value,
2750
+ input.valueChange
2751
+ )
2752
+ );
2690
2753
  } else if (content) {
2691
- throw new Error(`Body content is not supported for a "${tag}" tag.`);
2754
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) {
2755
+ controllable_select_value(
2756
+ scopeId,
2757
+ accessor,
2758
+ input.value,
2759
+ input.valueChange,
2760
+ content
2761
+ );
2762
+ } else {
2763
+ content();
2764
+ }
2692
2765
  }
2693
- },
2694
- scopeId,
2695
- accessor
2696
- );
2697
- return;
2698
- }
2699
- const renderer = normalizeDynamicRenderer(
2700
- tag
2701
- );
2702
- if (true) {
2703
- if (typeof renderer !== "function") {
2704
- throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2766
+ });
2767
+ write(`</${renderer}>`);
2768
+ } else if (content) {
2769
+ throw new Error(`Body content is not supported for a "${renderer}" tag.`);
2770
+ }
2771
+ if (resume) {
2772
+ chunk.writeHTML(
2773
+ chunk.boundary.state.mark(
2774
+ "|" /* BranchSingleNode */,
2775
+ scopeId + " " + accessor + " " + branchId
2776
+ )
2777
+ );
2705
2778
  }
2706
- }
2707
- let result;
2708
- resumeConditional(
2709
- () => {
2710
- result = renderer(content ? { ...input, content } : input);
2711
- },
2712
- scopeId,
2713
- accessor
2714
- );
2715
- return result;
2716
- };
2717
- var dynamicTagArgs = (scopeId, accessor, tag, args) => {
2718
- if (!tag) {
2719
- nextScopeId();
2720
- return;
2721
- }
2722
- if (typeof tag === "string") {
2723
- resumeSingleNodeConditional(
2724
- () => {
2725
- nextScopeId();
2726
- write(
2727
- `<${tag}${attrs(args[0], accessor, scopeId, tag)}>`
2779
+ } else {
2780
+ if (resume) {
2781
+ chunk.writeHTML(
2782
+ chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
2783
+ );
2784
+ }
2785
+ result = withBranchId(branchId, () => {
2786
+ if (renderer) {
2787
+ return inputIsArgs ? renderer(...inputOrArgs) : renderer(
2788
+ content ? { ...inputOrArgs, content } : inputOrArgs
2728
2789
  );
2729
- if (!voidElementsReg.test(tag)) {
2730
- write(`</${tag}>`);
2731
- }
2732
- },
2733
- scopeId,
2734
- accessor
2735
- );
2736
- return;
2790
+ } else if (content) {
2791
+ return content();
2792
+ }
2793
+ });
2794
+ if (resume) {
2795
+ chunk.writeHTML(
2796
+ chunk.boundary.state.mark(
2797
+ "]" /* BranchEnd */,
2798
+ scopeId + " " + accessor
2799
+ )
2800
+ );
2801
+ }
2737
2802
  }
2738
- const renderer = normalizeDynamicRenderer(
2739
- tag
2740
- );
2741
- if (true) {
2742
- if (typeof renderer !== "function") {
2743
- throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2803
+ const rendered = peekNextScopeId() !== branchId;
2804
+ if (rendered) {
2805
+ if (resume) {
2806
+ writeScope(scopeId, {
2807
+ ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
2808
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
2809
+ });
2744
2810
  }
2811
+ } else {
2812
+ nextScopeId();
2745
2813
  }
2746
- let result;
2747
- resumeConditional(
2748
- () => {
2749
- result = renderer(...args);
2750
- },
2751
- scopeId,
2752
- accessor
2753
- );
2754
2814
  return result;
2755
2815
  };
2756
2816
  function createContent(id, fn) {
@@ -2761,19 +2821,19 @@ function registerContent(id, fn, scopeId) {
2761
2821
  return register2(createContent(id, fn), id, scopeId);
2762
2822
  }
2763
2823
  function patchDynamicTag(patch) {
2764
- dynamicTagInput = /* @__PURE__ */ ((originalDynamicTagInput) => (scopeId, accessor, tag, input, content) => originalDynamicTagInput(
2765
- scopeId,
2766
- accessor,
2767
- patch(scopeId, accessor, tag),
2768
- input,
2769
- content
2770
- ))(dynamicTagInput);
2771
- dynamicTagArgs = /* @__PURE__ */ ((originalDynamicTagArgs) => (scopeId, accessor, tag, args) => originalDynamicTagArgs(
2772
- scopeId,
2773
- accessor,
2774
- patch(scopeId, accessor, tag),
2775
- args
2776
- ))(dynamicTagArgs);
2824
+ dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
2825
+ const patched = patch(scopeId, accessor, tag);
2826
+ patched.___id = tag;
2827
+ return originalDynamicTag(
2828
+ scopeId,
2829
+ accessor,
2830
+ patched,
2831
+ input,
2832
+ content,
2833
+ inputIsArgs,
2834
+ resume
2835
+ );
2836
+ })(dynamicTag);
2777
2837
  }
2778
2838
 
2779
2839
  // src/html/compat.ts
@@ -2873,7 +2933,7 @@ var compat = {
2873
2933
  };
2874
2934
 
2875
2935
  // src/html/for.ts
2876
- function forOfBy(by, item, index) {
2936
+ function forOfBy2(by, item, index) {
2877
2937
  if (by) {
2878
2938
  if (typeof by === "string") {
2879
2939
  return item[by];
@@ -2882,13 +2942,13 @@ function forOfBy(by, item, index) {
2882
2942
  }
2883
2943
  return index;
2884
2944
  }
2885
- function forInBy(by, name, value) {
2945
+ function forInBy2(by, name, value) {
2886
2946
  if (by) {
2887
2947
  return by(name, value);
2888
2948
  }
2889
2949
  return name;
2890
2950
  }
2891
- function forToBy(by, index) {
2951
+ function forToBy2(by, index) {
2892
2952
  if (by) {
2893
2953
  return by(index);
2894
2954
  }
@@ -3133,19 +3193,17 @@ export {
3133
3193
  controllable_textarea_value,
3134
3194
  createContent,
3135
3195
  createTemplate,
3136
- dynamicTagArgs,
3137
- dynamicTagId,
3138
- dynamicTagInput,
3196
+ dynamicTag,
3139
3197
  ensureScopeWithId,
3140
3198
  escapeScript,
3141
3199
  escapeStyle,
3142
3200
  escapeXML,
3143
3201
  forIn,
3144
- forInBy,
3202
+ forInBy2 as forInBy,
3145
3203
  forOf,
3146
- forOfBy,
3204
+ forOfBy2 as forOfBy,
3147
3205
  forTo,
3148
- forToBy,
3206
+ forToBy2 as forToBy,
3149
3207
  fork,
3150
3208
  getScopeById,
3151
3209
  hoist,
package/dist/dom.js CHANGED
@@ -222,7 +222,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
222
222
  visits.length = 0;
223
223
  let branchEnd = (branchId, reference) => {
224
224
  let branch = scopeLookup[branchId] ||= {}, endNode = reference;
225
- for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
225
+ for (; endNode.previousSibling !== branch.h && visitNodes.has(endNode = endNode.previousSibling); ) ;
226
226
  return endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
227
227
  new Text(),
228
228
  reference
package/dist/dom.mjs CHANGED
@@ -137,7 +137,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
137
137
  visits.length = 0;
138
138
  let branchEnd = (branchId, reference) => {
139
139
  let branch = scopeLookup[branchId] ||= {}, endNode = reference;
140
- for (; visitNodes.has(endNode = endNode.previousSibling); ) ;
140
+ for (; endNode.previousSibling !== branch.h && visitNodes.has(endNode = endNode.previousSibling); ) ;
141
141
  return endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
142
142
  new Text(),
143
143
  reference
@@ -1,12 +1,10 @@
1
- import type { Accessor } from "../common/types";
1
+ import { type Accessor } from "../common/types";
2
2
  import type { ServerRenderer } from "./template";
3
3
  interface BodyContentObject {
4
4
  [x: PropertyKey]: unknown;
5
5
  content: ServerRenderer;
6
6
  }
7
- export declare function dynamicTagId(tagName: unknown): string | ServerRenderer | undefined;
8
- export declare let dynamicTagInput: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, input: Record<string, unknown>, content?: () => void) => undefined;
9
- export declare let dynamicTagArgs: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, args: unknown[]) => undefined;
7
+ export declare let dynamicTag: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, inputOrArgs: unknown, content?: (() => void) | 0, inputIsArgs?: 1, resume?: 1) => unknown;
10
8
  export declare function createContent(id: string, fn: ServerRenderer): ServerRenderer;
11
9
  export declare function registerContent(id: string, fn: ServerRenderer, scopeId?: number): ServerRenderer;
12
10
  export declare function patchDynamicTag(patch: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject) => unknown): void;
@@ -15,7 +15,7 @@ export declare function getScopeId(scope: unknown): number | undefined;
15
15
  export declare function write(html: string): void;
16
16
  export declare function writeScript(script: string): void;
17
17
  export declare function writeEffect(scopeId: number, registryId: string): void;
18
- export declare function withContext(key: PropertyKey, value: unknown, cb: () => void): void;
18
+ export declare function withContext<T>(key: PropertyKey, value: unknown, cb: () => T): T;
19
19
  export declare function setTagVar(parentScopeId: number, scopeOffsetAccessor: Accessor, childScope: PartialScope, registryId: string): void;
20
20
  export declare function register<T extends WeakKey>(val: T, id: string, scopeId?: number): T;
21
21
  export declare function nextTagId(): string;
@@ -30,14 +30,15 @@ export declare function hoist(scopeId: number, id?: string): {
30
30
  [Symbol.iterator]: /*elided*/ any;
31
31
  };
32
32
  export declare function resumeClosestBranch(scopeId: number): void;
33
- export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, scopeId: number, accessor: Accessor): void;
34
- export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, scopeId: number, accessor: Accessor, onlyChildInParent?: 1): void;
35
- export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, scopeId: number, accessor: Accessor): void;
36
- export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, scopeId: number, accessor: Accessor, onlyChild?: 1): void;
37
- export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, scopeId: number, accessor: Accessor): void;
38
- export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, scopeId: number, accessor: Accessor, onlyChild?: 1): void;
39
- export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor): void;
40
- export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, onlyChild?: 1): void;
33
+ export declare function withBranchId<T>(branchId: number, cb: () => T): T;
34
+ export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor): void;
35
+ export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, onlyChildInParent?: 1): void;
36
+ export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor): void;
37
+ export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, onlyChild?: 1): void;
38
+ export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor): void;
39
+ export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, onlyChild?: 1): void;
40
+ export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, dynamic?: 1): void;
41
+ export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, dynamic?: 0 | 1, onlyChild?: 1): void;
41
42
  declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
42
43
  export { writeScope };
43
44
  export declare function writeExistingScope(scope: ScopeInternals): ScopeInternals;