marko 6.0.66 → 6.0.68

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.
@@ -2,3 +2,4 @@ import type { Falsy } from "./types";
2
2
  export declare function forIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void): void;
3
3
  export declare function forOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void): void;
4
4
  export declare function forTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void): void;
5
+ export declare function forUntil(until: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void): void;
package/dist/debug/dom.js CHANGED
@@ -64,6 +64,7 @@ __export(dom_exports, {
64
64
  _for_in: () => _for_in,
65
65
  _for_of: () => _for_of,
66
66
  _for_to: () => _for_to,
67
+ _for_until: () => _for_until,
67
68
  _hoist: () => _hoist,
68
69
  _html: () => _html,
69
70
  _id: () => _id,
@@ -90,6 +91,7 @@ __export(dom_exports, {
90
91
  forIn: () => forIn,
91
92
  forOf: () => forOf,
92
93
  forTo: () => forTo,
94
+ forUntil: () => forUntil,
93
95
  init: () => init,
94
96
  run: () => run
95
97
  });
@@ -140,6 +142,13 @@ function forTo(to, from, step, cb) {
140
142
  cb(start + i * delta);
141
143
  }
142
144
  }
145
+ function forUntil(until, from, step, cb) {
146
+ const start = from || 0;
147
+ const delta = step || 1;
148
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) {
149
+ cb(start + i * delta);
150
+ }
151
+ }
143
152
 
144
153
  // src/common/helpers.ts
145
154
  function classValue(classValue2) {
@@ -1945,6 +1954,13 @@ function _for_to(nodeAccessor, renderer) {
1945
1954
  ([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
1946
1955
  );
1947
1956
  }
1957
+ function _for_until(nodeAccessor, renderer) {
1958
+ return loop(
1959
+ nodeAccessor,
1960
+ renderer,
1961
+ ([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
1962
+ );
1963
+ }
1948
1964
  function loop(nodeAccessor, renderer, forEach) {
1949
1965
  const params = renderer.___params;
1950
1966
  enableBranches();
@@ -43,6 +43,13 @@ function forTo(to, from, step, cb) {
43
43
  cb(start + i * delta);
44
44
  }
45
45
  }
46
+ function forUntil(until, from, step, cb) {
47
+ const start = from || 0;
48
+ const delta = step || 1;
49
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) {
50
+ cb(start + i * delta);
51
+ }
52
+ }
46
53
 
47
54
  // src/common/helpers.ts
48
55
  function classValue(classValue2) {
@@ -1848,6 +1855,13 @@ function _for_to(nodeAccessor, renderer) {
1848
1855
  ([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
1849
1856
  );
1850
1857
  }
1858
+ function _for_until(nodeAccessor, renderer) {
1859
+ return loop(
1860
+ nodeAccessor,
1861
+ renderer,
1862
+ ([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
1863
+ );
1864
+ }
1851
1865
  function loop(nodeAccessor, renderer, forEach) {
1852
1866
  const params = renderer.___params;
1853
1867
  enableBranches();
@@ -2315,6 +2329,7 @@ export {
2315
2329
  _for_in,
2316
2330
  _for_of,
2317
2331
  _for_to,
2332
+ _for_until,
2318
2333
  _hoist,
2319
2334
  _html,
2320
2335
  _id,
@@ -2341,6 +2356,7 @@ export {
2341
2356
  forIn,
2342
2357
  forOf,
2343
2358
  forTo,
2359
+ forUntil,
2344
2360
  init,
2345
2361
  run
2346
2362
  };
@@ -50,6 +50,7 @@ __export(html_exports, {
50
50
  _for_in: () => _for_in,
51
51
  _for_of: () => _for_of,
52
52
  _for_to: () => _for_to,
53
+ _for_until: () => _for_until,
53
54
  _hoist: () => _hoist,
54
55
  _html: () => _html,
55
56
  _id: () => _id,
@@ -77,8 +78,9 @@ __export(html_exports, {
77
78
  forInBy: () => forInBy,
78
79
  forOf: () => forOf,
79
80
  forOfBy: () => forOfBy,
81
+ forStepBy: () => forStepBy,
80
82
  forTo: () => forTo,
81
- forToBy: () => forToBy
83
+ forUntil: () => forUntil
82
84
  });
83
85
  module.exports = __toCommonJS(html_exports);
84
86
 
@@ -204,6 +206,13 @@ function forTo(to, from, step, cb) {
204
206
  cb(start + i * delta);
205
207
  }
206
208
  }
209
+ function forUntil(until, from, step, cb) {
210
+ const start = from || 0;
211
+ const delta = step || 1;
212
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) {
213
+ cb(start + i * delta);
214
+ }
215
+ }
207
216
 
208
217
  // src/html/for.ts
209
218
  function forOfBy(by, item, index) {
@@ -221,7 +230,7 @@ function forInBy(by, name, value) {
221
230
  }
222
231
  return name;
223
232
  }
224
- function forToBy(by, index) {
233
+ function forStepBy(by, index) {
225
234
  if (by) {
226
235
  return by(index);
227
236
  }
@@ -1827,12 +1836,11 @@ function isInResumedBranch() {
1827
1836
  function withBranchId(branchId, cb) {
1828
1837
  return withContext(branchIdKey, branchId, cb);
1829
1838
  }
1830
- function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1839
+ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1831
1840
  const { state } = $chunk.boundary;
1832
- const resumeBranch = serializeBranch !== 0;
1833
1841
  const resumeMarker = serializeMarker !== 0;
1834
1842
  let flushBranchIds = "";
1835
- if (resumeBranch) {
1843
+ if (serializeBranch !== 0) {
1836
1844
  const loopScopes = /* @__PURE__ */ new Map();
1837
1845
  forOf(list, (item, index) => {
1838
1846
  const branchId = _peek_scope_id();
@@ -1862,19 +1870,18 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1862
1870
  writeBranchEnd(
1863
1871
  scopeId,
1864
1872
  accessor,
1865
- resumeBranch,
1873
+ serializeStateful,
1866
1874
  resumeMarker,
1867
1875
  parentEndTag,
1868
1876
  singleNode,
1869
1877
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1870
1878
  );
1871
1879
  }
1872
- function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1880
+ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1873
1881
  const { state } = $chunk.boundary;
1874
- const resumeBranch = serializeBranch !== 0;
1875
1882
  const resumeMarker = serializeMarker !== 0;
1876
1883
  let flushBranchIds = "";
1877
- if (resumeBranch) {
1884
+ if (serializeBranch !== 0) {
1878
1885
  const loopScopes = /* @__PURE__ */ new Map();
1879
1886
  forIn(obj, (key, value) => {
1880
1887
  const branchId = _peek_scope_id();
@@ -1904,19 +1911,18 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1904
1911
  writeBranchEnd(
1905
1912
  scopeId,
1906
1913
  accessor,
1907
- resumeBranch,
1914
+ serializeStateful,
1908
1915
  resumeMarker,
1909
1916
  parentEndTag,
1910
1917
  singleNode,
1911
1918
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1912
1919
  );
1913
1920
  }
1914
- function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1921
+ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1915
1922
  const { state } = $chunk.boundary;
1916
- const resumeBranch = serializeBranch !== 0;
1917
1923
  const resumeMarker = serializeMarker !== 0;
1918
1924
  let flushBranchIds = "";
1919
- if (resumeBranch) {
1925
+ if (serializeBranch !== 0) {
1920
1926
  const loopScopes = /* @__PURE__ */ new Map();
1921
1927
  forTo(to, from, step, (i) => {
1922
1928
  const branchId = _peek_scope_id();
@@ -1932,7 +1938,7 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1932
1938
  }
1933
1939
  withBranchId(branchId, () => {
1934
1940
  cb(i);
1935
- loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1941
+ loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1936
1942
  });
1937
1943
  });
1938
1944
  if (loopScopes.size) {
@@ -1946,14 +1952,55 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1946
1952
  writeBranchEnd(
1947
1953
  scopeId,
1948
1954
  accessor,
1949
- resumeBranch,
1955
+ serializeStateful,
1956
+ resumeMarker,
1957
+ parentEndTag,
1958
+ singleNode,
1959
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1960
+ );
1961
+ }
1962
+ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1963
+ const { state } = $chunk.boundary;
1964
+ const resumeMarker = serializeMarker !== 0;
1965
+ let flushBranchIds = "";
1966
+ if (serializeBranch !== 0) {
1967
+ const loopScopes = /* @__PURE__ */ new Map();
1968
+ forUntil(to, from, step, (i) => {
1969
+ const branchId = _peek_scope_id();
1970
+ if (resumeMarker) {
1971
+ if (singleNode) {
1972
+ flushBranchIds = " " + branchId + flushBranchIds;
1973
+ } else {
1974
+ $chunk.writeHTML(
1975
+ state.mark("[" /* BranchStart */, flushBranchIds)
1976
+ );
1977
+ flushBranchIds = branchId + "";
1978
+ }
1979
+ }
1980
+ withBranchId(branchId, () => {
1981
+ cb(i);
1982
+ loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1983
+ });
1984
+ });
1985
+ if (loopScopes.size) {
1986
+ writeScope(scopeId, {
1987
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1988
+ });
1989
+ }
1990
+ } else {
1991
+ forUntil(to, from, step, cb);
1992
+ }
1993
+ writeBranchEnd(
1994
+ scopeId,
1995
+ accessor,
1996
+ serializeStateful,
1950
1997
  resumeMarker,
1951
1998
  parentEndTag,
1952
1999
  singleNode,
1953
2000
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1954
2001
  );
1955
2002
  }
1956
- function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
2003
+ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1957
2004
  const { state } = $chunk.boundary;
1958
2005
  const resumeBranch = serializeBranch !== 0;
1959
2006
  const resumeMarker = serializeMarker !== 0;
@@ -1972,17 +2019,17 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1972
2019
  writeBranchEnd(
1973
2020
  scopeId,
1974
2021
  accessor,
1975
- resumeBranch,
2022
+ serializeStateful,
1976
2023
  resumeMarker,
1977
2024
  parentEndTag,
1978
2025
  singleNode,
1979
2026
  shouldWriteBranch ? " " + branchId : ""
1980
2027
  );
1981
2028
  }
1982
- function writeBranchEnd(scopeId, accessor, resumeBranch, resumeMarker, parentEndTag, singleNode, branchIds) {
2029
+ function writeBranchEnd(scopeId, accessor, serializeStateful, resumeMarker, parentEndTag, singleNode, branchIds) {
1983
2030
  const endTag = parentEndTag || "";
1984
2031
  if (resumeMarker) {
1985
- if (!parentEndTag || resumeBranch) {
2032
+ if (!parentEndTag || serializeStateful !== 0) {
1986
2033
  const { state } = $chunk.boundary;
1987
2034
  const mark = singleNode ? state.mark(
1988
2035
  parentEndTag ? "}" /* BranchEndSingleNodeOnlyChildInParent */ : "|" /* BranchEndSingleNode */,
@@ -3412,6 +3459,7 @@ function NOOP3() {
3412
3459
  _for_in,
3413
3460
  _for_of,
3414
3461
  _for_to,
3462
+ _for_until,
3415
3463
  _hoist,
3416
3464
  _html,
3417
3465
  _id,
@@ -3439,6 +3487,7 @@ function NOOP3() {
3439
3487
  forInBy,
3440
3488
  forOf,
3441
3489
  forOfBy,
3490
+ forStepBy,
3442
3491
  forTo,
3443
- forToBy
3492
+ forUntil
3444
3493
  });
@@ -120,6 +120,13 @@ function forTo(to, from, step, cb) {
120
120
  cb(start + i * delta);
121
121
  }
122
122
  }
123
+ function forUntil(until, from, step, cb) {
124
+ const start = from || 0;
125
+ const delta = step || 1;
126
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) {
127
+ cb(start + i * delta);
128
+ }
129
+ }
123
130
 
124
131
  // src/html/for.ts
125
132
  function forOfBy(by, item, index) {
@@ -137,7 +144,7 @@ function forInBy(by, name, value) {
137
144
  }
138
145
  return name;
139
146
  }
140
- function forToBy(by, index) {
147
+ function forStepBy(by, index) {
141
148
  if (by) {
142
149
  return by(index);
143
150
  }
@@ -1743,12 +1750,11 @@ function isInResumedBranch() {
1743
1750
  function withBranchId(branchId, cb) {
1744
1751
  return withContext(branchIdKey, branchId, cb);
1745
1752
  }
1746
- function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1753
+ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1747
1754
  const { state } = $chunk.boundary;
1748
- const resumeBranch = serializeBranch !== 0;
1749
1755
  const resumeMarker = serializeMarker !== 0;
1750
1756
  let flushBranchIds = "";
1751
- if (resumeBranch) {
1757
+ if (serializeBranch !== 0) {
1752
1758
  const loopScopes = /* @__PURE__ */ new Map();
1753
1759
  forOf(list, (item, index) => {
1754
1760
  const branchId = _peek_scope_id();
@@ -1778,19 +1784,18 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1778
1784
  writeBranchEnd(
1779
1785
  scopeId,
1780
1786
  accessor,
1781
- resumeBranch,
1787
+ serializeStateful,
1782
1788
  resumeMarker,
1783
1789
  parentEndTag,
1784
1790
  singleNode,
1785
1791
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1786
1792
  );
1787
1793
  }
1788
- function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1794
+ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1789
1795
  const { state } = $chunk.boundary;
1790
- const resumeBranch = serializeBranch !== 0;
1791
1796
  const resumeMarker = serializeMarker !== 0;
1792
1797
  let flushBranchIds = "";
1793
- if (resumeBranch) {
1798
+ if (serializeBranch !== 0) {
1794
1799
  const loopScopes = /* @__PURE__ */ new Map();
1795
1800
  forIn(obj, (key, value) => {
1796
1801
  const branchId = _peek_scope_id();
@@ -1820,19 +1825,18 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1820
1825
  writeBranchEnd(
1821
1826
  scopeId,
1822
1827
  accessor,
1823
- resumeBranch,
1828
+ serializeStateful,
1824
1829
  resumeMarker,
1825
1830
  parentEndTag,
1826
1831
  singleNode,
1827
1832
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1828
1833
  );
1829
1834
  }
1830
- function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1835
+ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1831
1836
  const { state } = $chunk.boundary;
1832
- const resumeBranch = serializeBranch !== 0;
1833
1837
  const resumeMarker = serializeMarker !== 0;
1834
1838
  let flushBranchIds = "";
1835
- if (resumeBranch) {
1839
+ if (serializeBranch !== 0) {
1836
1840
  const loopScopes = /* @__PURE__ */ new Map();
1837
1841
  forTo(to, from, step, (i) => {
1838
1842
  const branchId = _peek_scope_id();
@@ -1848,7 +1852,7 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1848
1852
  }
1849
1853
  withBranchId(branchId, () => {
1850
1854
  cb(i);
1851
- loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1855
+ loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1852
1856
  });
1853
1857
  });
1854
1858
  if (loopScopes.size) {
@@ -1862,14 +1866,55 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1862
1866
  writeBranchEnd(
1863
1867
  scopeId,
1864
1868
  accessor,
1865
- resumeBranch,
1869
+ serializeStateful,
1870
+ resumeMarker,
1871
+ parentEndTag,
1872
+ singleNode,
1873
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1874
+ );
1875
+ }
1876
+ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1877
+ const { state } = $chunk.boundary;
1878
+ const resumeMarker = serializeMarker !== 0;
1879
+ let flushBranchIds = "";
1880
+ if (serializeBranch !== 0) {
1881
+ const loopScopes = /* @__PURE__ */ new Map();
1882
+ forUntil(to, from, step, (i) => {
1883
+ const branchId = _peek_scope_id();
1884
+ if (resumeMarker) {
1885
+ if (singleNode) {
1886
+ flushBranchIds = " " + branchId + flushBranchIds;
1887
+ } else {
1888
+ $chunk.writeHTML(
1889
+ state.mark("[" /* BranchStart */, flushBranchIds)
1890
+ );
1891
+ flushBranchIds = branchId + "";
1892
+ }
1893
+ }
1894
+ withBranchId(branchId, () => {
1895
+ cb(i);
1896
+ loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1897
+ });
1898
+ });
1899
+ if (loopScopes.size) {
1900
+ writeScope(scopeId, {
1901
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1902
+ });
1903
+ }
1904
+ } else {
1905
+ forUntil(to, from, step, cb);
1906
+ }
1907
+ writeBranchEnd(
1908
+ scopeId,
1909
+ accessor,
1910
+ serializeStateful,
1866
1911
  resumeMarker,
1867
1912
  parentEndTag,
1868
1913
  singleNode,
1869
1914
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1870
1915
  );
1871
1916
  }
1872
- function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1917
+ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1873
1918
  const { state } = $chunk.boundary;
1874
1919
  const resumeBranch = serializeBranch !== 0;
1875
1920
  const resumeMarker = serializeMarker !== 0;
@@ -1888,17 +1933,17 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1888
1933
  writeBranchEnd(
1889
1934
  scopeId,
1890
1935
  accessor,
1891
- resumeBranch,
1936
+ serializeStateful,
1892
1937
  resumeMarker,
1893
1938
  parentEndTag,
1894
1939
  singleNode,
1895
1940
  shouldWriteBranch ? " " + branchId : ""
1896
1941
  );
1897
1942
  }
1898
- function writeBranchEnd(scopeId, accessor, resumeBranch, resumeMarker, parentEndTag, singleNode, branchIds) {
1943
+ function writeBranchEnd(scopeId, accessor, serializeStateful, resumeMarker, parentEndTag, singleNode, branchIds) {
1899
1944
  const endTag = parentEndTag || "";
1900
1945
  if (resumeMarker) {
1901
- if (!parentEndTag || resumeBranch) {
1946
+ if (!parentEndTag || serializeStateful !== 0) {
1902
1947
  const { state } = $chunk.boundary;
1903
1948
  const mark = singleNode ? state.mark(
1904
1949
  parentEndTag ? "}" /* BranchEndSingleNodeOnlyChildInParent */ : "|" /* BranchEndSingleNode */,
@@ -3327,6 +3372,7 @@ export {
3327
3372
  _for_in,
3328
3373
  _for_of,
3329
3374
  _for_to,
3375
+ _for_until,
3330
3376
  _hoist,
3331
3377
  _html,
3332
3378
  _id,
@@ -3354,6 +3400,7 @@ export {
3354
3400
  forInBy,
3355
3401
  forOf,
3356
3402
  forOfBy,
3403
+ forStepBy,
3357
3404
  forTo,
3358
- forToBy
3405
+ forUntil
3359
3406
  };
@@ -14,3 +14,4 @@ export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Ac
14
14
  export declare function _for_of(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, value: [all: unknown[], by?: ((item: unknown, index: number) => unknown) | undefined]) => void;
15
15
  export declare function _for_in(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, value: [obj: {}, by?: ((key: string, v: unknown) => unknown) | undefined]) => void;
16
16
  export declare function _for_to(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, value: [to: number, from: number, step: number, by?: ((v: number) => unknown) | undefined]) => void;
17
+ export declare function _for_until(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, value: [until: number, from: number, step: number, by?: ((v: number) => unknown) | undefined]) => void;
package/dist/dom.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { attrTag, attrTags } from "./common/attr-tag";
2
- export { forIn, forOf, forTo } from "./common/for";
2
+ export { forIn, forOf, forTo, forUntil } from "./common/for";
3
3
  export { $signal, $signalReset } from "./dom/abort-signal";
4
4
  export { compat } from "./dom/compat";
5
- export { _await, _dynamic_tag, _for_in, _for_of, _for_to, _if, _try, } from "./dom/control-flow";
5
+ export { _await, _dynamic_tag, _for_in, _for_of, _for_to, _for_until, _if, _try, } from "./dom/control-flow";
6
6
  export { _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checked_script, _attr_input_checkedValue, _attr_input_checkedValue_script, _attr_input_value, _attr_input_value_script, _attr_select_value, _attr_select_value_script, _attr_textarea_value, _attr_textarea_value_script, } from "./dom/controllable";
7
7
  export { _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _html, _lifecycle, _text, _text_content, } from "./dom/dom";
8
8
  export { _on } from "./dom/event";
package/dist/dom.js CHANGED
@@ -61,6 +61,7 @@ __export(dom_exports, {
61
61
  _for_in: () => _for_in,
62
62
  _for_of: () => _for_of,
63
63
  _for_to: () => _for_to,
64
+ _for_until: () => _for_until,
64
65
  _hoist: () => _hoist,
65
66
  _html: () => _html,
66
67
  _id: () => _id,
@@ -87,6 +88,7 @@ __export(dom_exports, {
87
88
  forIn: () => forIn,
88
89
  forOf: () => forOf,
89
90
  forTo: () => forTo,
91
+ forUntil: () => forUntil,
90
92
  init: () => init,
91
93
  run: () => run
92
94
  });
@@ -121,6 +123,11 @@ function forTo(to, from, step, cb) {
121
123
  for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
122
124
  cb(start + i * delta);
123
125
  }
126
+ function forUntil(until, from, step, cb) {
127
+ let start = from || 0, delta = step || 1;
128
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++)
129
+ cb(start + i * delta);
130
+ }
124
131
 
125
132
  // src/common/helpers.ts
126
133
  function classValue(classValue2) {
@@ -1271,6 +1278,13 @@ function _for_to(nodeAccessor, renderer) {
1271
1278
  ([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
1272
1279
  );
1273
1280
  }
1281
+ function _for_until(nodeAccessor, renderer) {
1282
+ return loop(
1283
+ nodeAccessor,
1284
+ renderer,
1285
+ ([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
1286
+ );
1287
+ }
1274
1288
  function loop(nodeAccessor, renderer, forEach) {
1275
1289
  let params = renderer.m;
1276
1290
  return enableBranches(), (scope, value) => {
package/dist/dom.mjs CHANGED
@@ -27,6 +27,11 @@ function forTo(to, from, step, cb) {
27
27
  for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
28
28
  cb(start + i * delta);
29
29
  }
30
+ function forUntil(until, from, step, cb) {
31
+ let start = from || 0, delta = step || 1;
32
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++)
33
+ cb(start + i * delta);
34
+ }
30
35
 
31
36
  // src/common/helpers.ts
32
37
  function classValue(classValue2) {
@@ -1177,6 +1182,13 @@ function _for_to(nodeAccessor, renderer) {
1177
1182
  ([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))
1178
1183
  );
1179
1184
  }
1185
+ function _for_until(nodeAccessor, renderer) {
1186
+ return loop(
1187
+ nodeAccessor,
1188
+ renderer,
1189
+ ([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))
1190
+ );
1191
+ }
1180
1192
  function loop(nodeAccessor, renderer, forEach) {
1181
1193
  let params = renderer.m;
1182
1194
  return enableBranches(), (scope, value) => {
@@ -1491,6 +1503,7 @@ export {
1491
1503
  _for_in,
1492
1504
  _for_of,
1493
1505
  _for_to,
1506
+ _for_until,
1494
1507
  _hoist,
1495
1508
  _html,
1496
1509
  _id,
@@ -1517,6 +1530,7 @@ export {
1517
1530
  forIn,
1518
1531
  forOf,
1519
1532
  forTo,
1533
+ forUntil,
1520
1534
  init,
1521
1535
  run
1522
1536
  };
@@ -1,4 +1,4 @@
1
- export { forIn, forOf, forTo } from "../common/for";
1
+ export { forIn, forOf, forTo, forUntil } from "../common/for";
2
2
  export declare function forOfBy(by: unknown, item: any, index: unknown): any;
3
3
  export declare function forInBy(by: unknown, name: string, value: unknown): any;
4
- export declare function forToBy(by: unknown, index: number): any;
4
+ export declare function forStepBy(by: unknown, index: number): any;
@@ -39,10 +39,11 @@ export declare function _hoist(scopeId: number, id?: string): {
39
39
  export declare function _resume_branch(scopeId: number): void;
40
40
  export declare function isInResumedBranch(): boolean;
41
41
  export declare function withBranchId<T>(branchId: number, cb: () => T): T;
42
- export declare function _for_of(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
43
- export declare function _for_in(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
44
- export declare function _for_to(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
45
- export declare function _if(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
42
+ export declare function _for_of(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
43
+ export declare function _for_in(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
44
+ export declare function _for_to(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
45
+ export declare function _for_until(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
46
+ export declare function _if(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1): void;
46
47
  declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
47
48
  export declare function writeScopeToState(state: State, scopeId: number, partialScope: PartialScope): ScopeInternals;
48
49
  export { writeScope as _scope };
package/dist/html.d.ts CHANGED
@@ -3,6 +3,6 @@ export { _attr, _attr_class, _attr_details_or_dialog_open as _attr_details_open,
3
3
  export { compat } from "./html/compat";
4
4
  export { _escape, _escape_script, _escape_style, _unescaped, } from "./html/content";
5
5
  export { _content, _content_resume, _dynamic_tag } from "./html/dynamic-tag";
6
- export { forIn, forInBy, forOf, forOfBy, forTo, forToBy } from "./html/for";
6
+ export { forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, } from "./html/for";
7
7
  export { _template } from "./html/template";
8
- export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _scope, _scope_id, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _subscribe, _trailers, _try, _var, $global, } from "./html/writer";
8
+ export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _for_until, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _scope, _scope_id, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _subscribe, _trailers, _try, _var, $global, } from "./html/writer";
package/dist/html.js CHANGED
@@ -47,6 +47,7 @@ __export(html_exports, {
47
47
  _for_in: () => _for_in,
48
48
  _for_of: () => _for_of,
49
49
  _for_to: () => _for_to,
50
+ _for_until: () => _for_until,
50
51
  _hoist: () => _hoist,
51
52
  _html: () => _html,
52
53
  _id: () => _id,
@@ -74,8 +75,9 @@ __export(html_exports, {
74
75
  forInBy: () => forInBy,
75
76
  forOf: () => forOf,
76
77
  forOfBy: () => forOfBy,
78
+ forStepBy: () => forStepBy,
77
79
  forTo: () => forTo,
78
- forToBy: () => forToBy
80
+ forUntil: () => forUntil
79
81
  });
80
82
  module.exports = __toCommonJS(html_exports);
81
83
 
@@ -167,6 +169,11 @@ function forTo(to, from, step, cb) {
167
169
  for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
168
170
  cb(start + i * delta);
169
171
  }
172
+ function forUntil(until, from, step, cb) {
173
+ let start = from || 0, delta = step || 1;
174
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++)
175
+ cb(start + i * delta);
176
+ }
170
177
 
171
178
  // src/html/for.ts
172
179
  function forOfBy(by, item, index) {
@@ -175,7 +182,7 @@ function forOfBy(by, item, index) {
175
182
  function forInBy(by, name, value) {
176
183
  return by ? by(name, value) : name;
177
184
  }
178
- function forToBy(by, index) {
185
+ function forStepBy(by, index) {
179
186
  return by ? by(index) : index;
180
187
  }
181
188
 
@@ -1188,9 +1195,9 @@ function isInResumedBranch() {
1188
1195
  function withBranchId(branchId, cb) {
1189
1196
  return withContext(branchIdKey, branchId, cb);
1190
1197
  }
1191
- function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1192
- let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1193
- if (resumeBranch) {
1198
+ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1199
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1200
+ if (serializeBranch !== 0) {
1194
1201
  let loopScopes = /* @__PURE__ */ new Map();
1195
1202
  forOf(list, (item, index) => {
1196
1203
  let branchId = _peek_scope_id();
@@ -1207,16 +1214,16 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1207
1214
  writeBranchEnd(
1208
1215
  scopeId,
1209
1216
  accessor,
1210
- resumeBranch,
1217
+ serializeStateful,
1211
1218
  resumeMarker,
1212
1219
  parentEndTag,
1213
1220
  singleNode,
1214
1221
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1215
1222
  );
1216
1223
  }
1217
- function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1218
- let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1219
- if (resumeBranch) {
1224
+ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1225
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1226
+ if (serializeBranch !== 0) {
1220
1227
  let loopScopes = /* @__PURE__ */ new Map();
1221
1228
  forIn(obj, (key, value) => {
1222
1229
  let branchId = _peek_scope_id();
@@ -1233,23 +1240,23 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1233
1240
  writeBranchEnd(
1234
1241
  scopeId,
1235
1242
  accessor,
1236
- resumeBranch,
1243
+ serializeStateful,
1237
1244
  resumeMarker,
1238
1245
  parentEndTag,
1239
1246
  singleNode,
1240
1247
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1241
1248
  );
1242
1249
  }
1243
- function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1244
- let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1245
- if (resumeBranch) {
1250
+ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1251
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1252
+ if (serializeBranch !== 0) {
1246
1253
  let loopScopes = /* @__PURE__ */ new Map();
1247
1254
  forTo(to, from, step, (i) => {
1248
1255
  let branchId = _peek_scope_id();
1249
1256
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1250
1257
  state.mark("[" /* BranchStart */, flushBranchIds)
1251
1258
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1252
- cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1259
+ cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1253
1260
  });
1254
1261
  }), loopScopes.size && writeScope(scopeId, {
1255
1262
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1259,14 +1266,40 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1259
1266
  writeBranchEnd(
1260
1267
  scopeId,
1261
1268
  accessor,
1262
- resumeBranch,
1269
+ serializeStateful,
1270
+ resumeMarker,
1271
+ parentEndTag,
1272
+ singleNode,
1273
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1274
+ );
1275
+ }
1276
+ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1277
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1278
+ if (serializeBranch !== 0) {
1279
+ let loopScopes = /* @__PURE__ */ new Map();
1280
+ forUntil(to, from, step, (i) => {
1281
+ let branchId = _peek_scope_id();
1282
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1283
+ state.mark("[" /* BranchStart */, flushBranchIds)
1284
+ ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1285
+ cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1286
+ });
1287
+ }), loopScopes.size && writeScope(scopeId, {
1288
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1289
+ });
1290
+ } else
1291
+ forUntil(to, from, step, cb);
1292
+ writeBranchEnd(
1293
+ scopeId,
1294
+ accessor,
1295
+ serializeStateful,
1263
1296
  resumeMarker,
1264
1297
  parentEndTag,
1265
1298
  singleNode,
1266
1299
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1267
1300
  );
1268
1301
  }
1269
- function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1302
+ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1270
1303
  let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = _peek_scope_id();
1271
1304
  resumeMarker && resumeBranch && !singleNode && $chunk.writeHTML(state.mark("[" /* BranchStart */, ""));
1272
1305
  let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
@@ -1276,17 +1309,17 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1276
1309
  }), writeBranchEnd(
1277
1310
  scopeId,
1278
1311
  accessor,
1279
- resumeBranch,
1312
+ serializeStateful,
1280
1313
  resumeMarker,
1281
1314
  parentEndTag,
1282
1315
  singleNode,
1283
1316
  shouldWriteBranch ? " " + branchId : ""
1284
1317
  );
1285
1318
  }
1286
- function writeBranchEnd(scopeId, accessor, resumeBranch, resumeMarker, parentEndTag, singleNode, branchIds) {
1319
+ function writeBranchEnd(scopeId, accessor, serializeStateful, resumeMarker, parentEndTag, singleNode, branchIds) {
1287
1320
  let endTag = parentEndTag || "";
1288
1321
  if (resumeMarker)
1289
- if (!parentEndTag || resumeBranch) {
1322
+ if (!parentEndTag || serializeStateful !== 0) {
1290
1323
  let { state } = $chunk.boundary, mark = singleNode ? state.mark(
1291
1324
  parentEndTag ? "}" /* BranchEndSingleNodeOnlyChildInParent */ : "|" /* BranchEndSingleNode */,
1292
1325
  scopeId + " " + accessor + (branchIds || "")
@@ -2219,6 +2252,7 @@ function NOOP3() {
2219
2252
  _for_in,
2220
2253
  _for_of,
2221
2254
  _for_to,
2255
+ _for_until,
2222
2256
  _hoist,
2223
2257
  _html,
2224
2258
  _id,
@@ -2246,6 +2280,7 @@ function NOOP3() {
2246
2280
  forInBy,
2247
2281
  forOf,
2248
2282
  forOfBy,
2283
+ forStepBy,
2249
2284
  forTo,
2250
- forToBy
2285
+ forUntil
2251
2286
  });
package/dist/html.mjs CHANGED
@@ -86,6 +86,11 @@ function forTo(to, from, step, cb) {
86
86
  for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
87
87
  cb(start + i * delta);
88
88
  }
89
+ function forUntil(until, from, step, cb) {
90
+ let start = from || 0, delta = step || 1;
91
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++)
92
+ cb(start + i * delta);
93
+ }
89
94
 
90
95
  // src/html/for.ts
91
96
  function forOfBy(by, item, index) {
@@ -94,7 +99,7 @@ function forOfBy(by, item, index) {
94
99
  function forInBy(by, name, value) {
95
100
  return by ? by(name, value) : name;
96
101
  }
97
- function forToBy(by, index) {
102
+ function forStepBy(by, index) {
98
103
  return by ? by(index) : index;
99
104
  }
100
105
 
@@ -1107,9 +1112,9 @@ function isInResumedBranch() {
1107
1112
  function withBranchId(branchId, cb) {
1108
1113
  return withContext(branchIdKey, branchId, cb);
1109
1114
  }
1110
- function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1111
- let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1112
- if (resumeBranch) {
1115
+ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1116
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1117
+ if (serializeBranch !== 0) {
1113
1118
  let loopScopes = /* @__PURE__ */ new Map();
1114
1119
  forOf(list, (item, index) => {
1115
1120
  let branchId = _peek_scope_id();
@@ -1126,16 +1131,16 @@ function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMark
1126
1131
  writeBranchEnd(
1127
1132
  scopeId,
1128
1133
  accessor,
1129
- resumeBranch,
1134
+ serializeStateful,
1130
1135
  resumeMarker,
1131
1136
  parentEndTag,
1132
1137
  singleNode,
1133
1138
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1134
1139
  );
1135
1140
  }
1136
- function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1137
- let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1138
- if (resumeBranch) {
1141
+ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1142
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1143
+ if (serializeBranch !== 0) {
1139
1144
  let loopScopes = /* @__PURE__ */ new Map();
1140
1145
  forIn(obj, (key, value) => {
1141
1146
  let branchId = _peek_scope_id();
@@ -1152,23 +1157,23 @@ function _for_in(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarke
1152
1157
  writeBranchEnd(
1153
1158
  scopeId,
1154
1159
  accessor,
1155
- resumeBranch,
1160
+ serializeStateful,
1156
1161
  resumeMarker,
1157
1162
  parentEndTag,
1158
1163
  singleNode,
1159
1164
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1160
1165
  );
1161
1166
  }
1162
- function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1163
- let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1164
- if (resumeBranch) {
1167
+ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1168
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1169
+ if (serializeBranch !== 0) {
1165
1170
  let loopScopes = /* @__PURE__ */ new Map();
1166
1171
  forTo(to, from, step, (i) => {
1167
1172
  let branchId = _peek_scope_id();
1168
1173
  resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1169
1174
  state.mark("[" /* BranchStart */, flushBranchIds)
1170
1175
  ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1171
- cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1176
+ cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1172
1177
  });
1173
1178
  }), loopScopes.size && writeScope(scopeId, {
1174
1179
  ["m" /* LoopScopeMap */ + accessor]: loopScopes
@@ -1178,14 +1183,40 @@ function _for_to(to, from, step, cb, by, scopeId, accessor, serializeBranch, ser
1178
1183
  writeBranchEnd(
1179
1184
  scopeId,
1180
1185
  accessor,
1181
- resumeBranch,
1186
+ serializeStateful,
1187
+ resumeMarker,
1188
+ parentEndTag,
1189
+ singleNode,
1190
+ singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1191
+ );
1192
+ }
1193
+ function _for_until(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1194
+ let { state } = $chunk.boundary, resumeMarker = serializeMarker !== 0, flushBranchIds = "";
1195
+ if (serializeBranch !== 0) {
1196
+ let loopScopes = /* @__PURE__ */ new Map();
1197
+ forUntil(to, from, step, (i) => {
1198
+ let branchId = _peek_scope_id();
1199
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(
1200
+ state.mark("[" /* BranchStart */, flushBranchIds)
1201
+ ), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1202
+ cb(i), loopScopes.set(forStepBy(by, i), writeScope(branchId, {}));
1203
+ });
1204
+ }), loopScopes.size && writeScope(scopeId, {
1205
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1206
+ });
1207
+ } else
1208
+ forUntil(to, from, step, cb);
1209
+ writeBranchEnd(
1210
+ scopeId,
1211
+ accessor,
1212
+ serializeStateful,
1182
1213
  resumeMarker,
1183
1214
  parentEndTag,
1184
1215
  singleNode,
1185
1216
  singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : ""
1186
1217
  );
1187
1218
  }
1188
- function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndTag, singleNode) {
1219
+ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1189
1220
  let { state } = $chunk.boundary, resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = _peek_scope_id();
1190
1221
  resumeMarker && resumeBranch && !singleNode && $chunk.writeHTML(state.mark("[" /* BranchStart */, ""));
1191
1222
  let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
@@ -1195,17 +1226,17 @@ function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, parentEndT
1195
1226
  }), writeBranchEnd(
1196
1227
  scopeId,
1197
1228
  accessor,
1198
- resumeBranch,
1229
+ serializeStateful,
1199
1230
  resumeMarker,
1200
1231
  parentEndTag,
1201
1232
  singleNode,
1202
1233
  shouldWriteBranch ? " " + branchId : ""
1203
1234
  );
1204
1235
  }
1205
- function writeBranchEnd(scopeId, accessor, resumeBranch, resumeMarker, parentEndTag, singleNode, branchIds) {
1236
+ function writeBranchEnd(scopeId, accessor, serializeStateful, resumeMarker, parentEndTag, singleNode, branchIds) {
1206
1237
  let endTag = parentEndTag || "";
1207
1238
  if (resumeMarker)
1208
- if (!parentEndTag || resumeBranch) {
1239
+ if (!parentEndTag || serializeStateful !== 0) {
1209
1240
  let { state } = $chunk.boundary, mark = singleNode ? state.mark(
1210
1241
  parentEndTag ? "}" /* BranchEndSingleNodeOnlyChildInParent */ : "|" /* BranchEndSingleNode */,
1211
1242
  scopeId + " " + accessor + (branchIds || "")
@@ -2137,6 +2168,7 @@ export {
2137
2168
  _for_in,
2138
2169
  _for_of,
2139
2170
  _for_to,
2171
+ _for_until,
2140
2172
  _hoist,
2141
2173
  _html,
2142
2174
  _id,
@@ -2164,6 +2196,7 @@ export {
2164
2196
  forInBy,
2165
2197
  forOf,
2166
2198
  forOfBy,
2199
+ forStepBy,
2167
2200
  forTo,
2168
- forToBy
2201
+ forUntil
2169
2202
  };
@@ -1,5 +1,5 @@
1
1
  import { types as t } from "@marko/compiler";
2
- type ForType = "in" | "of" | "to";
2
+ type ForType = "in" | "of" | "to" | "until";
3
3
  declare const _default: {
4
4
  analyze(tag: t.NodePath<t.MarkoTag>): void;
5
5
  translate: {
@@ -28,6 +28,12 @@ declare const _default: {
28
28
  description: string;
29
29
  }[];
30
30
  };
31
+ until: {
32
+ type: string;
33
+ autocomplete: {
34
+ description: string;
35
+ }[];
36
+ };
31
37
  from: {
32
38
  type: string;
33
39
  autocomplete: {
@@ -76,6 +76,12 @@ declare const _default: {
76
76
  description: string;
77
77
  }[];
78
78
  };
79
+ until: {
80
+ type: string;
81
+ autocomplete: {
82
+ description: string;
83
+ }[];
84
+ };
79
85
  from: {
80
86
  type: string;
81
87
  autocomplete: {
@@ -82,6 +82,12 @@ export declare const taglibs: (string | {
82
82
  description: string;
83
83
  }[];
84
84
  };
85
+ until: {
86
+ type: string;
87
+ autocomplete: {
88
+ description: string;
89
+ }[];
90
+ };
85
91
  from: {
86
92
  type: string;
87
93
  autocomplete: {
@@ -2386,6 +2386,7 @@ var pureDOMFunctions = /* @__PURE__ */ new Set([
2386
2386
  "_for_in",
2387
2387
  "_for_of",
2388
2388
  "_for_to",
2389
+ "_for_until",
2389
2390
  "_let",
2390
2391
  "_const"
2391
2392
  ]);
@@ -4171,7 +4172,8 @@ function replaceAssignedNode(node) {
4171
4172
  switch (node.type) {
4172
4173
  case "ExpressionStatement": {
4173
4174
  if (node.expression.type === "SequenceExpression" && updateExpressions.delete(node.expression)) {
4174
- return node.expression.expressions[0];
4175
+ node.expression = node.expression.expressions[0];
4176
+ return node;
4175
4177
  }
4176
4178
  break;
4177
4179
  }
@@ -7258,6 +7260,7 @@ function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
7258
7260
  }
7259
7261
 
7260
7262
  // src/translator/core/for.ts
7263
+ var kStatefulReason = Symbol("<for> stateful reason");
7261
7264
  var for_default = {
7262
7265
  analyze(tag) {
7263
7266
  const tagSection = getOrCreateSection(tag);
@@ -7281,6 +7284,9 @@ var for_default = {
7281
7284
  case "to":
7282
7285
  allowAttrs = ["to", "from", "step"];
7283
7286
  break;
7287
+ case "until":
7288
+ allowAttrs = ["until", "from", "step"];
7289
+ break;
7284
7290
  default:
7285
7291
  throw tag.buildCodeFrameError(
7286
7292
  "The [`<for>` tag](https://markojs.com/docs/reference/core-tag#for) requires an `of=`, `in=`, or `to=` attribute."
@@ -7302,6 +7308,7 @@ var for_default = {
7302
7308
  tag.node,
7303
7309
  getAllTagReferenceNodes(tag.node)
7304
7310
  );
7311
+ addSectionSerializeReasonExpr(tagSection, tagExtra, kStatefulReason);
7305
7312
  if (paramsBinding) {
7306
7313
  setBindingDownstream(paramsBinding, tagExtra);
7307
7314
  }
@@ -7360,16 +7367,21 @@ var for_default = {
7360
7367
  );
7361
7368
  if (branchSerializeReason) {
7362
7369
  const skipParentEnd = onlyChildParentTagName && markerSerializeReason;
7370
+ const statefulSerializeArg = getSerializeGuard(
7371
+ getSectionSerializeReason(tagSection, kStatefulReason),
7372
+ !(skipParentEnd || singleNodeOptimization)
7373
+ );
7363
7374
  const markerSerializeArg = getSerializeGuard(
7364
7375
  markerSerializeReason,
7365
- !(skipParentEnd || singleNodeOptimization)
7376
+ !statefulSerializeArg
7366
7377
  );
7367
7378
  forTagArgs.push(
7368
7379
  forAttrs.by || import_compiler34.types.numericLiteral(0),
7369
7380
  getScopeIdIdentifier(tagSection),
7370
7381
  getScopeAccessorLiteral(nodeBinding),
7371
7382
  getSerializeGuard(branchSerializeReason, !markerSerializeArg),
7372
- markerSerializeArg
7383
+ markerSerializeArg,
7384
+ statefulSerializeArg
7373
7385
  );
7374
7386
  if (skipParentEnd) {
7375
7387
  getParentTag(tag).node.extra[kSkipEndTag] = true;
@@ -7472,6 +7484,14 @@ var for_default = {
7472
7484
  }
7473
7485
  ]
7474
7486
  },
7487
+ until: {
7488
+ type: "number",
7489
+ autocomplete: [
7490
+ {
7491
+ description: "Iterates up to the provided number (exclusive)"
7492
+ }
7493
+ ]
7494
+ },
7475
7495
  from: {
7476
7496
  type: "number",
7477
7497
  autocomplete: [
@@ -7484,7 +7504,7 @@ var for_default = {
7484
7504
  type: "number",
7485
7505
  autocomplete: [
7486
7506
  {
7487
- description: "The amount to increment during each interation (with from/to)"
7507
+ description: "The amount to increment during each iteration (with from/to/until)"
7488
7508
  }
7489
7509
  ]
7490
7510
  }
@@ -7502,6 +7522,10 @@ var for_default = {
7502
7522
  {
7503
7523
  snippet: "for|${1:index}| to=${2:number}",
7504
7524
  descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
7525
+ },
7526
+ {
7527
+ snippet: "for|${1:index}| until=${2:number}",
7528
+ descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#for"
7505
7529
  }
7506
7530
  ]
7507
7531
  };
@@ -7521,6 +7545,7 @@ function getForType(tag) {
7521
7545
  case "of":
7522
7546
  case "in":
7523
7547
  case "to":
7548
+ case "until":
7524
7549
  return attr.name;
7525
7550
  }
7526
7551
  }
@@ -7534,6 +7559,8 @@ function forTypeToRuntime(type) {
7534
7559
  return "forIn";
7535
7560
  case "to":
7536
7561
  return "forTo";
7562
+ case "until":
7563
+ return "forUntil";
7537
7564
  }
7538
7565
  }
7539
7566
  function forTypeToHTMLResumeRuntime(type) {
@@ -7544,6 +7571,8 @@ function forTypeToHTMLResumeRuntime(type) {
7544
7571
  return "_for_in";
7545
7572
  case "to":
7546
7573
  return "_for_to";
7574
+ case "until":
7575
+ return "_for_until";
7547
7576
  }
7548
7577
  }
7549
7578
  function forTypeToDOMRuntime(type) {
@@ -7554,6 +7583,8 @@ function forTypeToDOMRuntime(type) {
7554
7583
  return "_for_in";
7555
7584
  case "to":
7556
7585
  return "_for_to";
7586
+ case "until":
7587
+ return "_for_until";
7557
7588
  }
7558
7589
  }
7559
7590
  function getBaseArgsInForTag(type, attrs) {
@@ -7568,6 +7599,12 @@ function getBaseArgsInForTag(type, attrs) {
7568
7599
  attrs.from || import_compiler34.types.numericLiteral(0),
7569
7600
  attrs.step || import_compiler34.types.numericLiteral(1)
7570
7601
  ];
7602
+ case "until":
7603
+ return [
7604
+ attrs.until,
7605
+ attrs.from || import_compiler34.types.numericLiteral(0),
7606
+ attrs.step || import_compiler34.types.numericLiteral(1)
7607
+ ];
7571
7608
  }
7572
7609
  }
7573
7610
 
@@ -9172,6 +9209,7 @@ function toFirstStatementOrBlock(body) {
9172
9209
  }
9173
9210
 
9174
9211
  // src/translator/core/if.ts
9212
+ var kStatefulReason2 = Symbol("<if> stateful reason");
9175
9213
  var BRANCHES_LOOKUP = /* @__PURE__ */ new WeakMap();
9176
9214
  var IfTag = {
9177
9215
  analyze(tag) {
@@ -9206,6 +9244,7 @@ var IfTag = {
9206
9244
  }
9207
9245
  mergeReferences(ifTagSection, ifTag.node, mergeReferenceNodes);
9208
9246
  ifTagExtra.singleNodeOptimization = singleNodeOptimization;
9247
+ addSectionSerializeReasonExpr(ifTagSection, ifTagExtra, kStatefulReason2);
9209
9248
  }
9210
9249
  },
9211
9250
  translate: translateByTarget({
@@ -9294,9 +9333,13 @@ var IfTag = {
9294
9333
  if (skipParentEnd) {
9295
9334
  getParentTag(ifTag).node.extra[kSkipEndTag] = true;
9296
9335
  }
9336
+ const statefulSerializeArg = getSerializeGuard(
9337
+ getSectionSerializeReason(ifTagSection, kStatefulReason2),
9338
+ !(skipParentEnd || singleNodeOptimization)
9339
+ );
9297
9340
  const markerSerializeArg = getSerializeGuard(
9298
9341
  markerSerializeReason,
9299
- !(skipParentEnd || singleNodeOptimization)
9342
+ !statefulSerializeArg
9300
9343
  );
9301
9344
  const cbNode = import_compiler43.types.arrowFunctionExpression(
9302
9345
  [],
@@ -9313,6 +9356,7 @@ var IfTag = {
9313
9356
  !markerSerializeArg
9314
9357
  ),
9315
9358
  markerSerializeArg,
9359
+ statefulSerializeArg,
9316
9360
  skipParentEnd ? import_compiler43.types.stringLiteral(`</${onlyChildParentTagName}>`) : singleNodeOptimization ? import_compiler43.types.numericLiteral(0) : void 0,
9317
9361
  singleNodeOptimization ? import_compiler43.types.numericLiteral(1) : void 0
9318
9362
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.66",
3
+ "version": "6.0.68",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",
@@ -48,7 +48,7 @@
48
48
  "build": "node -r ~ts ./scripts/bundle.ts"
49
49
  },
50
50
  "dependencies": {
51
- "@marko/compiler": "^5.39.33",
51
+ "@marko/compiler": "^5.39.35",
52
52
  "csstype": "^3.1.3",
53
53
  "magic-string": "^0.30.17"
54
54
  },