marko 6.0.3 → 6.0.4

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.
@@ -42,11 +42,11 @@ __export(html_exports, {
42
42
  escapeStyle: () => escapeStyle,
43
43
  escapeXML: () => escapeXML,
44
44
  forIn: () => forIn,
45
- forInBy: () => forInBy2,
45
+ forInBy: () => forInBy,
46
46
  forOf: () => forOf,
47
- forOfBy: () => forOfBy2,
47
+ forOfBy: () => forOfBy,
48
48
  forTo: () => forTo,
49
- forToBy: () => forToBy2,
49
+ forToBy: () => forToBy,
50
50
  fork: () => fork,
51
51
  getScopeById: () => getScopeById,
52
52
  hoist: () => hoist,
@@ -210,6 +210,29 @@ function forTo(to, from, step, cb) {
210
210
  }
211
211
  }
212
212
 
213
+ // src/html/for.ts
214
+ function forOfBy(by, item, index) {
215
+ if (by) {
216
+ if (typeof by === "string") {
217
+ return item[by];
218
+ }
219
+ return by(item, index);
220
+ }
221
+ return index;
222
+ }
223
+ function forInBy(by, name, value) {
224
+ if (by) {
225
+ return by(name, value);
226
+ }
227
+ return name;
228
+ }
229
+ function forToBy(by, index) {
230
+ if (by) {
231
+ return by(index);
232
+ }
233
+ return index;
234
+ }
235
+
213
236
  // src/html/inlined-runtimes.ts
214
237
  var WALKER_RUNTIME_CODE = true ? (
215
238
  /* js */
@@ -1771,213 +1794,232 @@ var branchIdKey = Symbol();
1771
1794
  function withBranchId(branchId, cb) {
1772
1795
  return withContext(branchIdKey, branchId, cb);
1773
1796
  }
1774
- function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
1775
- if (serializeBranch === 0) {
1776
- return forOf(list, cb);
1797
+ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1798
+ const resumeBranch = serializeBranch !== 0;
1799
+ const resumeMarker = serializeMarker !== 0;
1800
+ if (resumeBranch) {
1801
+ const loopScopes = /* @__PURE__ */ new Map();
1802
+ forOf(list, (item, index) => {
1803
+ const branchId = peekNextScopeId();
1804
+ if (resumeMarker) {
1805
+ $chunk.writeHTML(
1806
+ $chunk.boundary.state.mark(
1807
+ "[" /* BranchStart */,
1808
+ branchId + (index ? " " : "")
1809
+ )
1810
+ );
1811
+ }
1812
+ withBranchId(branchId, () => {
1813
+ cb(item, index);
1814
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1815
+ });
1816
+ });
1817
+ if (loopScopes.size) {
1818
+ writeScope(scopeId, {
1819
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1820
+ });
1821
+ }
1822
+ } else {
1823
+ forOf(list, cb);
1777
1824
  }
1778
- const loopScopes = /* @__PURE__ */ new Map();
1779
- forOf(list, (item, index) => {
1780
- const branchId = peekNextScopeId();
1825
+ if (resumeMarker) {
1781
1826
  $chunk.writeHTML(
1782
1827
  $chunk.boundary.state.mark(
1783
- "[" /* BranchStart */,
1784
- branchId + (index ? " " : "")
1828
+ "]" /* BranchEnd */,
1829
+ scopeId + " " + accessor
1785
1830
  )
1786
1831
  );
1787
- withBranchId(branchId, () => {
1788
- cb(item, index);
1789
- loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1790
- });
1791
- });
1792
- if (loopScopes.size) {
1793
- writeScope(scopeId, {
1794
- ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1795
- });
1796
1832
  }
1797
- $chunk.writeHTML(
1798
- $chunk.boundary.state.mark(
1799
- "]" /* BranchEnd */,
1800
- scopeId + " " + accessor
1801
- )
1802
- );
1803
1833
  }
1804
- function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
1805
- if (serializeBranch === 0) {
1806
- return forOf(list, cb);
1807
- }
1808
- const loopScopes = /* @__PURE__ */ new Map();
1834
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1835
+ const resumeBranch = serializeBranch !== 0;
1836
+ const resumeMarker = serializeMarker !== 0;
1809
1837
  let branchIds = "";
1810
- forOf(list, (item, index) => {
1811
- const branchId = peekNextScopeId();
1812
- branchIds = " " + branchId + branchIds;
1813
- withBranchId(branchId, () => {
1814
- cb(item, index);
1815
- loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1816
- });
1817
- });
1818
- if (loopScopes.size) {
1819
- writeScope(scopeId, {
1820
- ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1838
+ if (resumeBranch) {
1839
+ const loopScopes = /* @__PURE__ */ new Map();
1840
+ forOf(list, (item, index) => {
1841
+ const branchId = peekNextScopeId();
1842
+ if (resumeMarker) {
1843
+ branchIds = " " + branchId + branchIds;
1844
+ }
1845
+ withBranchId(branchId, () => {
1846
+ cb(item, index);
1847
+ loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1848
+ });
1821
1849
  });
1822
- }
1823
- $chunk.writeHTML(
1824
- $chunk.boundary.state.mark(
1825
- onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1826
- scopeId + " " + accessor + branchIds
1827
- )
1828
- );
1829
- }
1830
- function forOfBy(by, item, index) {
1831
- if (by) {
1832
- if (typeof by === "string") {
1833
- return item[by];
1850
+ if (loopScopes.size) {
1851
+ writeScope(scopeId, {
1852
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1853
+ });
1834
1854
  }
1835
- return by(item, index);
1855
+ } else {
1856
+ forOf(list, cb);
1857
+ }
1858
+ if (resumeMarker) {
1859
+ $chunk.writeHTML(
1860
+ $chunk.boundary.state.mark(
1861
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1862
+ scopeId + " " + accessor + branchIds
1863
+ )
1864
+ );
1836
1865
  }
1837
- return index;
1838
1866
  }
1839
- function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
1840
- if (serializeBranch === 0) {
1841
- return forIn(obj, cb);
1867
+ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1868
+ const resumeBranch = serializeBranch !== 0;
1869
+ const resumeMarker = serializeMarker !== 0;
1870
+ if (resumeBranch) {
1871
+ const loopScopes = /* @__PURE__ */ new Map();
1872
+ let sep = "";
1873
+ forIn(obj, (key, value) => {
1874
+ const branchId = peekNextScopeId();
1875
+ if (resumeMarker) {
1876
+ $chunk.writeHTML(
1877
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1878
+ );
1879
+ sep = " ";
1880
+ }
1881
+ withBranchId(branchId, () => {
1882
+ cb(key, value);
1883
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1884
+ });
1885
+ });
1886
+ if (loopScopes.size) {
1887
+ writeScope(scopeId, {
1888
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1889
+ });
1890
+ }
1891
+ } else {
1892
+ forIn(obj, cb);
1842
1893
  }
1843
- const loopScopes = /* @__PURE__ */ new Map();
1844
- let sep = "";
1845
- forIn(obj, (key, value) => {
1846
- const branchId = peekNextScopeId();
1894
+ if (resumeMarker) {
1847
1895
  $chunk.writeHTML(
1848
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1896
+ $chunk.boundary.state.mark(
1897
+ "]" /* BranchEnd */,
1898
+ scopeId + " " + accessor
1899
+ )
1849
1900
  );
1850
- sep = " ";
1851
- withBranchId(branchId, () => {
1852
- cb(key, value);
1853
- loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1854
- });
1855
- });
1856
- if (loopScopes.size) {
1857
- writeScope(scopeId, {
1858
- ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1859
- });
1860
1901
  }
1861
- $chunk.writeHTML(
1862
- $chunk.boundary.state.mark(
1863
- "]" /* BranchEnd */,
1864
- scopeId + " " + accessor
1865
- )
1866
- );
1867
1902
  }
1868
- function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1869
- if (serializeBranch === 0) {
1870
- return forIn(obj, cb);
1871
- }
1872
- const loopScopes = /* @__PURE__ */ new Map();
1903
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1904
+ const resumeBranch = serializeBranch !== 0;
1905
+ const resumeMarker = serializeMarker !== 0;
1873
1906
  let branchIds = "";
1874
- forIn(obj, (key, value) => {
1875
- const branchId = peekNextScopeId();
1876
- branchIds = " " + branchId + branchIds;
1877
- withBranchId(branchId, () => {
1878
- cb(key, value);
1879
- loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1880
- });
1881
- });
1882
- if (loopScopes.size) {
1883
- writeScope(scopeId, {
1884
- ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1907
+ if (resumeBranch) {
1908
+ const loopScopes = /* @__PURE__ */ new Map();
1909
+ forIn(obj, (key, value) => {
1910
+ const branchId = peekNextScopeId();
1911
+ if (resumeMarker) {
1912
+ branchIds = " " + branchId + branchIds;
1913
+ }
1914
+ withBranchId(branchId, () => {
1915
+ cb(key, value);
1916
+ loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1917
+ });
1885
1918
  });
1919
+ if (loopScopes.size) {
1920
+ writeScope(scopeId, {
1921
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1922
+ });
1923
+ }
1924
+ } else {
1925
+ forIn(obj, cb);
1886
1926
  }
1887
- $chunk.writeHTML(
1888
- $chunk.boundary.state.mark(
1889
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1890
- scopeId + " " + accessor + branchIds
1891
- )
1892
- );
1893
- }
1894
- function forInBy(by, name, value) {
1895
- if (by) {
1896
- return by(name, value);
1927
+ if (resumeMarker) {
1928
+ $chunk.writeHTML(
1929
+ $chunk.boundary.state.mark(
1930
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1931
+ scopeId + " " + accessor + branchIds
1932
+ )
1933
+ );
1897
1934
  }
1898
- return name;
1899
1935
  }
1900
- function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
1901
- if (serializeBranch === 0) {
1902
- return forTo(to, from, step, cb);
1936
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1937
+ const resumeBranch = serializeBranch !== 0;
1938
+ const resumeMarker = serializeMarker !== 0;
1939
+ if (resumeBranch) {
1940
+ const loopScopes = /* @__PURE__ */ new Map();
1941
+ let sep = "";
1942
+ forTo(to, from, step, (i) => {
1943
+ const branchId = peekNextScopeId();
1944
+ if (resumeMarker) {
1945
+ $chunk.writeHTML(
1946
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1947
+ );
1948
+ sep = " ";
1949
+ }
1950
+ withBranchId(branchId, () => {
1951
+ cb(i);
1952
+ loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1953
+ });
1954
+ });
1955
+ if (loopScopes.size) {
1956
+ writeScope(scopeId, {
1957
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1958
+ });
1959
+ }
1960
+ } else {
1961
+ forTo(to, from, step, cb);
1903
1962
  }
1904
- const loopScopes = /* @__PURE__ */ new Map();
1905
- let sep = "";
1906
- forTo(to, from, step, (index) => {
1907
- const branchId = peekNextScopeId();
1963
+ if (resumeMarker) {
1908
1964
  $chunk.writeHTML(
1909
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1965
+ $chunk.boundary.state.mark(
1966
+ "]" /* BranchEnd */,
1967
+ scopeId + " " + accessor
1968
+ )
1910
1969
  );
1911
- sep = " ";
1912
- withBranchId(branchId, () => {
1913
- cb(index);
1914
- loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1915
- });
1916
- });
1917
- if (loopScopes.size) {
1918
- writeScope(scopeId, {
1919
- ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1920
- });
1921
1970
  }
1922
- $chunk.writeHTML(
1923
- $chunk.boundary.state.mark(
1924
- "]" /* BranchEnd */,
1925
- scopeId + " " + accessor
1926
- )
1927
- );
1928
1971
  }
1929
- function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1930
- if (serializeBranch === 0) {
1931
- return forTo(to, from, step, cb);
1932
- }
1933
- const loopScopes = /* @__PURE__ */ new Map();
1972
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1973
+ const resumeBranch = serializeBranch !== 0;
1974
+ const resumeMarker = serializeMarker !== 0;
1934
1975
  let branchIds = "";
1935
- forTo(to, from, step, (index) => {
1936
- const branchId = peekNextScopeId();
1937
- branchIds = " " + branchId + branchIds;
1938
- withBranchId(branchId, () => {
1939
- cb(index);
1940
- loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1941
- });
1942
- });
1943
- if (loopScopes.size) {
1944
- writeScope(scopeId, {
1945
- ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1976
+ if (resumeBranch) {
1977
+ const loopScopes = /* @__PURE__ */ new Map();
1978
+ forTo(to, from, step, (i) => {
1979
+ const branchId = peekNextScopeId();
1980
+ if (resumeMarker) {
1981
+ branchIds = " " + branchId + branchIds;
1982
+ }
1983
+ withBranchId(branchId, () => {
1984
+ cb(i);
1985
+ loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1986
+ });
1946
1987
  });
1988
+ if (loopScopes.size) {
1989
+ writeScope(scopeId, {
1990
+ ["LoopScopeMap:" /* LoopScopeMap */ + accessor]: loopScopes
1991
+ });
1992
+ }
1993
+ } else {
1994
+ forTo(to, from, step, cb);
1947
1995
  }
1948
- $chunk.writeHTML(
1949
- $chunk.boundary.state.mark(
1950
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1951
- scopeId + " " + accessor + branchIds
1952
- )
1953
- );
1954
- }
1955
- function forToBy(by, index) {
1956
- if (by) {
1957
- return by(index);
1996
+ if (resumeMarker) {
1997
+ $chunk.writeHTML(
1998
+ $chunk.boundary.state.mark(
1999
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
2000
+ scopeId + " " + accessor + branchIds
2001
+ )
2002
+ );
1958
2003
  }
1959
- return index;
1960
2004
  }
1961
2005
  function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
1962
- if (serializeBranch === 0) {
1963
- return cb();
1964
- }
2006
+ const resumeBranch = serializeBranch !== 0;
2007
+ const resumeMarker = serializeMarker !== 0;
1965
2008
  const branchId = peekNextScopeId();
1966
- if (serializeMarker) {
2009
+ if (resumeMarker && resumeBranch) {
1967
2010
  $chunk.writeHTML(
1968
2011
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1969
2012
  );
1970
2013
  }
1971
- const branchIndex = withBranchId(branchId, cb);
1972
- if (branchIndex !== void 0) {
2014
+ const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
2015
+ const rendered = branchIndex !== void 0;
2016
+ if (resumeBranch && rendered) {
1973
2017
  writeScope(scopeId, {
1974
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
2018
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1975
2019
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1976
2020
  });
1977
- } else {
1978
- nextScopeId();
1979
2021
  }
1980
- if (serializeMarker) {
2022
+ if (resumeMarker) {
1981
2023
  $chunk.writeHTML(
1982
2024
  $chunk.boundary.state.mark(
1983
2025
  "]" /* BranchEnd */,
@@ -1986,26 +2028,23 @@ function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMark
1986
2028
  );
1987
2029
  }
1988
2030
  }
1989
- function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
1990
- if (serializeBranch === 0) {
1991
- return cb();
1992
- }
2031
+ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
2032
+ const resumeBranch = serializeBranch !== 0;
2033
+ const resumeMarker = serializeMarker !== 0;
1993
2034
  const branchId = peekNextScopeId();
1994
- const branchIndex = withBranchId(branchId, cb);
1995
- const rendered = branchIndex !== void 0;
1996
- if (rendered) {
2035
+ const branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
2036
+ const shouldWriteBranch = resumeBranch && branchIndex !== void 0;
2037
+ if (shouldWriteBranch) {
1997
2038
  writeScope(scopeId, {
1998
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
2039
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1999
2040
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
2000
2041
  });
2001
- } else {
2002
- nextScopeId();
2003
2042
  }
2004
- if (serializeMarker) {
2043
+ if (resumeMarker) {
2005
2044
  $chunk.writeHTML(
2006
2045
  $chunk.boundary.state.mark(
2007
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
2008
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
2046
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
2047
+ scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
2009
2048
  )
2010
2049
  );
2011
2050
  }
@@ -3108,7 +3147,8 @@ function NOOP2() {
3108
3147
 
3109
3148
  // src/html/dynamic-tag.ts
3110
3149
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
3111
- var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, shouldResume) => {
3150
+ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
3151
+ const shouldResume = serializeReason !== 0;
3112
3152
  const renderer = normalizeDynamicRenderer(tag);
3113
3153
  if (true) {
3114
3154
  if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
@@ -3179,7 +3219,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, sho
3179
3219
  const input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
3180
3220
  return renderer(
3181
3221
  content ? { ...input, content } : input,
3182
- shouldResume
3222
+ shouldResume ? 1 : 0
3183
3223
  );
3184
3224
  }
3185
3225
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(
@@ -3323,29 +3363,6 @@ var compat = {
3323
3363
  register(RENDER_BODY_ID, fn);
3324
3364
  }
3325
3365
  };
3326
-
3327
- // src/html/for.ts
3328
- function forOfBy2(by, item, index) {
3329
- if (by) {
3330
- if (typeof by === "string") {
3331
- return item[by];
3332
- }
3333
- return by(item, index);
3334
- }
3335
- return index;
3336
- }
3337
- function forInBy2(by, name, value) {
3338
- if (by) {
3339
- return by(name, value);
3340
- }
3341
- return name;
3342
- }
3343
- function forToBy2(by, index) {
3344
- if (by) {
3345
- return by(index);
3346
- }
3347
- return index;
3348
- }
3349
3366
  // Annotate the CommonJS export names for ESM import in node:
3350
3367
  0 && (module.exports = {
3351
3368
  $global,