marko 6.3.14 → 6.3.16

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.
@@ -156,6 +156,15 @@ function assertValidLoopKey(key, seenKeys) {
156
156
  seenKeys.add(key);
157
157
  }
158
158
  }
159
+ function assertValidList(value) {
160
+ if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
161
+ }
162
+ function assertValidRangeBound(name, value) {
163
+ if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
164
+ }
165
+ function describeForValue(value) {
166
+ return typeof value === "number" || typeof value === "bigint" ? `\`${value}\`` : value === null ? "null" : `type "${typeof value}"`;
167
+ }
159
168
  function assertValidAttrName(name) {
160
169
  if (htmlAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
161
170
  const suggestion = getWrongAttrSuggestion(name);
@@ -1526,17 +1535,20 @@ function forIn(obj, cb) {
1526
1535
  for (const key in obj) cb(key, obj[key]);
1527
1536
  }
1528
1537
  function forOf(list, cb) {
1538
+ assertValidList(list);
1529
1539
  if (list) {
1530
1540
  let i = 0;
1531
1541
  for (const item of list) cb(item, i++);
1532
1542
  }
1533
1543
  }
1534
1544
  function forTo(to, from, step, cb) {
1545
+ assertValidRangeBound("to", to);
1535
1546
  const start = from || 0;
1536
1547
  const delta = step || 1;
1537
1548
  for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
1538
1549
  }
1539
1550
  function forUntil(until, from, step, cb) {
1551
+ assertValidRangeBound("until", until);
1540
1552
  const start = from || 0;
1541
1553
  const delta = step || 1;
1542
1554
  for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
@@ -1664,7 +1676,6 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1664
1676
  //#endregion
1665
1677
  //#region src/html/writer.ts
1666
1678
  let $chunk;
1667
- const NOOP$2 = () => {};
1668
1679
  function getChunk() {
1669
1680
  return $chunk;
1670
1681
  }
@@ -1677,54 +1688,22 @@ function getState() {
1677
1688
  function getScopeId(scope) {
1678
1689
  return scope[K_SCOPE_ID];
1679
1690
  }
1680
- function _html(html) {
1681
- $chunk.writeHTML(html);
1682
- }
1683
- function writeScript(script) {
1684
- $chunk.writeScript(script);
1691
+ function getScopeById(scopeId) {
1692
+ if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
1685
1693
  }
1686
- function writeWaitReady(readyId, renderer, input) {
1687
- const chunk = $chunk;
1688
- const { boundary } = chunk;
1689
- const body = new Chunk(boundary, null, chunk.context, {
1690
- readyId,
1691
- parent: chunk.serializeState,
1692
- resumes: "",
1693
- writeScopes: {},
1694
- flushScopes: false
1695
- });
1696
- const bodyEnd = body.render(renderer, input);
1697
- if (body === bodyEnd) {
1698
- chunk.writeHTML(body.html);
1699
- body.deferOwnReady();
1700
- chunk.deferredReady = push(chunk.deferredReady, body);
1701
- } else {
1702
- bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
1703
- chunk.next = body;
1704
- }
1694
+ function $global() {
1695
+ return $chunk.boundary.state.$global;
1705
1696
  }
1706
- function _script(scopeId, registryId) {
1707
- if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
1708
- $chunk.boundary.state.needsMainRuntime = true;
1709
- $chunk.writeEffect(scopeId, registryId);
1697
+ function _id() {
1698
+ const state = $chunk.boundary.state;
1699
+ const { $global } = state;
1700
+ return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
1710
1701
  }
1711
- function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1712
- const shouldResume = serializeReason !== 0;
1713
- const render = normalizeServerRender(content);
1714
- const branchId = _peek_scope_id();
1715
- if (render) if (shouldResume) withBranchId(branchId, render);
1716
- else render();
1717
- if (_peek_scope_id() !== branchId) {
1718
- if (shouldResume) writeScope(scopeId, {
1719
- ["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
1720
- ["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
1721
- });
1722
- } else _scope_id();
1702
+ function _scope_id() {
1703
+ return $chunk.boundary.state.scopeId++;
1723
1704
  }
1724
- function normalizeServerRender(value) {
1725
- const renderer = normalizeDynamicRenderer(value);
1726
- if (renderer) if (typeof renderer === "function") return renderer;
1727
- else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1705
+ function _peek_scope_id() {
1706
+ return $chunk.boundary.state.scopeId;
1728
1707
  }
1729
1708
  const kPendingContexts = Symbol("Pending Contexts");
1730
1709
  function withContext(key, value, cb, cbValue) {
@@ -1739,49 +1718,41 @@ function withContext(key, value, cb, cbValue) {
1739
1718
  ctx[key] = prev;
1740
1719
  }
1741
1720
  }
1742
- function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
1743
- writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
1744
- const childScope = writeScopePassive(childScopeId, { ["#TagVariable"]: _resume({}, registryId, parentScopeId) });
1745
- if (nodeAccessor !== void 0) writeScope(parentScopeId, { ["BranchScopes:" + nodeAccessor]: childScope });
1746
- }
1747
- function writeScopePassive(scopeId, partialScope) {
1748
- const target = $chunk.serializeState;
1749
- const scope = _scope_with_id(scopeId);
1750
- const passive = target.passiveScopes ||= {};
1751
- Object.assign(scope, partialScope);
1752
- passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
1753
- return scope;
1721
+ const kBranchId = Symbol("Branch Id");
1722
+ const kIsAsync = Symbol("Is Async");
1723
+ function isInResumedBranch() {
1724
+ return $chunk?.context?.[kBranchId] !== void 0;
1754
1725
  }
1755
- function _resume(val, id, scopeId) {
1756
- return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
1726
+ function withBranchId(branchId, cb) {
1727
+ return withContext(kBranchId, branchId, cb);
1757
1728
  }
1758
- function _id() {
1759
- const state = $chunk.boundary.state;
1760
- const { $global } = state;
1761
- return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
1729
+ function withIsAsync(cb, value) {
1730
+ return withContext(kIsAsync, true, cb, value);
1762
1731
  }
1763
- function _scope_id() {
1764
- return $chunk.boundary.state.scopeId++;
1732
+ function _html(html) {
1733
+ $chunk.writeHTML(html);
1765
1734
  }
1766
- function _peek_scope_id() {
1767
- return $chunk.boundary.state.scopeId;
1735
+ function writeScript(script) {
1736
+ $chunk.writeScript(script);
1768
1737
  }
1769
- function getScopeById(scopeId) {
1770
- if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
1738
+ function _script(scopeId, registryId) {
1739
+ if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
1740
+ $chunk.boundary.state.needsMainRuntime = true;
1741
+ $chunk.writeEffect(scopeId, registryId);
1771
1742
  }
1772
- function _set_serialize_reason(reason) {
1773
- $chunk.boundary.state.serializeReason = reason;
1743
+ function _trailers(html) {
1744
+ $chunk.boundary.state.trailerHTML += html;
1774
1745
  }
1775
- function _scope_reason() {
1776
- const reason = $chunk.boundary.state.serializeReason;
1777
- $chunk.boundary.state.serializeReason = void 0;
1778
- return reason;
1746
+ function _resume(val, id, scopeId) {
1747
+ return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
1779
1748
  }
1780
- function _serialize_if(condition, key) {
1781
- return condition && (condition === 1 || (typeof condition === "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
1749
+ function _el(scopeId, id) {
1750
+ return _resume(() => _el_read_error(), id, scopeId);
1782
1751
  }
1783
- function _serialize_guard(condition, key) {
1784
- return _serialize_if(condition, key) || 0;
1752
+ function _hoist(scopeId, id) {
1753
+ const getter = () => _hoist_read_error();
1754
+ getter[Symbol.iterator] = _hoist_read_error;
1755
+ return _resume(getter, id, scopeId);
1785
1756
  }
1786
1757
  function _el_resume(scopeId, accessor, shouldResume) {
1787
1758
  if (shouldResume === 0) return "";
@@ -1792,28 +1763,51 @@ function _el_resume(scopeId, accessor, shouldResume) {
1792
1763
  function _sep(shouldResume) {
1793
1764
  return shouldResume === 0 ? "" : "<!>";
1794
1765
  }
1795
- function _el(scopeId, id) {
1796
- return _resume(() => _el_read_error(), id, scopeId);
1797
- }
1798
- function _hoist(scopeId, id) {
1799
- const getter = () => _hoist_read_error();
1800
- getter[Symbol.iterator] = _hoist_read_error;
1801
- return _resume(getter, id, scopeId);
1802
- }
1803
1766
  function _resume_branch(scopeId) {
1804
1767
  const branchId = $chunk.context?.[kBranchId];
1805
1768
  if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { ["#ClosestBranchId"]: branchId });
1806
1769
  }
1807
- const kBranchId = Symbol("Branch Id");
1808
- const kIsAsync = Symbol("Is Async");
1809
- function isInResumedBranch() {
1810
- return $chunk?.context?.[kBranchId] !== void 0;
1770
+ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1771
+ const shouldResume = serializeReason !== 0;
1772
+ const render = normalizeServerRender(content);
1773
+ const branchId = _peek_scope_id();
1774
+ if (render) if (shouldResume) withBranchId(branchId, render);
1775
+ else render();
1776
+ if (_peek_scope_id() !== branchId) {
1777
+ if (shouldResume) writeScope(scopeId, {
1778
+ ["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
1779
+ ["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
1780
+ });
1781
+ } else _scope_id();
1811
1782
  }
1812
- function withBranchId(branchId, cb) {
1813
- return withContext(kBranchId, branchId, cb);
1783
+ function normalizeServerRender(value) {
1784
+ const renderer = normalizeDynamicRenderer(value);
1785
+ if (renderer) if (typeof renderer === "function") return renderer;
1786
+ else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1814
1787
  }
1815
- function withIsAsync(cb, value) {
1816
- return withContext(kIsAsync, true, cb, value);
1788
+ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
1789
+ writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
1790
+ const childScope = writeScopePassive(childScopeId, { ["#TagVariable"]: _resume({}, registryId, parentScopeId) });
1791
+ if (nodeAccessor !== void 0) writeScope(parentScopeId, { ["BranchScopes:" + nodeAccessor]: childScope });
1792
+ }
1793
+ function writeScopePassive(scopeId, partialScope) {
1794
+ const target = $chunk.serializeState;
1795
+ const scope = _scope_with_id(scopeId);
1796
+ const passive = target.passiveScopes ||= {};
1797
+ Object.assign(scope, partialScope);
1798
+ passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
1799
+ return scope;
1800
+ }
1801
+ function _show_start(display, mark) {
1802
+ if (display) {
1803
+ if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
1804
+ } else $chunk.writeHTML("<t hidden>");
1805
+ }
1806
+ function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1807
+ const branchId = _scope_id();
1808
+ const wrap = !display;
1809
+ if (wrap) $chunk.writeHTML("</t>");
1810
+ writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
1817
1811
  }
1818
1812
  function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1819
1813
  forBranches(by, (each) => each ? forOf(list, (item, index) => {
@@ -1900,17 +1894,6 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
1900
1894
  } else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
1901
1895
  else $chunk.writeHTML(endTag);
1902
1896
  }
1903
- function _show_start(display, mark) {
1904
- if (display) {
1905
- if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
1906
- } else $chunk.writeHTML("<t hidden>");
1907
- }
1908
- function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1909
- const branchId = _scope_id();
1910
- const wrap = !display;
1911
- if (wrap) $chunk.writeHTML("</t>");
1912
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
1913
- }
1914
1897
  let writeScope = (scopeId, partialScope) => {
1915
1898
  const { state } = $chunk.boundary;
1916
1899
  const target = $chunk.serializeState;
@@ -1940,8 +1923,47 @@ function scopeWithId(state, scopeId) {
1940
1923
  if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
1941
1924
  return scope;
1942
1925
  }
1943
- function $global() {
1944
- return $chunk.boundary.state.$global;
1926
+ function _subscribe(subscribers, scope) {
1927
+ if (subscribers) {
1928
+ const { serializer } = $chunk.boundary.state;
1929
+ if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
1930
+ else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
1931
+ }
1932
+ return scope;
1933
+ }
1934
+ function _set_serialize_reason(reason) {
1935
+ $chunk.boundary.state.serializeReason = reason;
1936
+ }
1937
+ function _scope_reason() {
1938
+ const reason = $chunk.boundary.state.serializeReason;
1939
+ $chunk.boundary.state.serializeReason = void 0;
1940
+ return reason;
1941
+ }
1942
+ function _serialize_if(condition, key) {
1943
+ return condition && (condition === 1 || (typeof condition === "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
1944
+ }
1945
+ function _serialize_guard(condition, key) {
1946
+ return _serialize_if(condition, key) || 0;
1947
+ }
1948
+ function writeWaitReady(readyId, renderer, input) {
1949
+ const chunk = $chunk;
1950
+ const { boundary } = chunk;
1951
+ const body = new Chunk(boundary, null, chunk.context, {
1952
+ readyId,
1953
+ parent: chunk.serializeState,
1954
+ resumes: "",
1955
+ writeScopes: {},
1956
+ flushScopes: false
1957
+ });
1958
+ const bodyEnd = body.render(renderer, input);
1959
+ if (body === bodyEnd) {
1960
+ chunk.writeHTML(body.html);
1961
+ body.deferOwnReady();
1962
+ chunk.deferredReady = push(chunk.deferredReady, body);
1963
+ } else {
1964
+ bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
1965
+ chunk.next = body;
1966
+ }
1945
1967
  }
1946
1968
  function _await(scopeId, accessor, promise, content, serializeMarker) {
1947
1969
  const resumeMarker = serializeMarker !== 0;
@@ -2065,6 +2087,7 @@ function tryCatch(content, catchContent) {
2065
2087
  else boundary.onNext();
2066
2088
  };
2067
2089
  }
2090
+ const NOOP$2 = () => {};
2068
2091
  var State = class {
2069
2092
  $global;
2070
2093
  tagId = 1;
@@ -2490,8 +2513,22 @@ function depsMarker(deps) {
2490
2513
  }
2491
2514
  return marker;
2492
2515
  }
2493
- function _trailers(html) {
2494
- $chunk.boundary.state.trailerHTML += html;
2516
+ function getFilteredGlobals($global) {
2517
+ if (!$global) return 0;
2518
+ const serializedGlobals = $global.serializedGlobals;
2519
+ if (!serializedGlobals) return 0;
2520
+ let filtered = 0;
2521
+ if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
2522
+ const value = $global[key];
2523
+ if (value !== void 0) if (filtered) filtered[key] = value;
2524
+ else filtered = { [key]: value };
2525
+ }
2526
+ else for (const key in serializedGlobals) if (serializedGlobals[key]) {
2527
+ const value = $global[key];
2528
+ if (value !== void 0) if (filtered) filtered[key] = value;
2529
+ else filtered = { [key]: value };
2530
+ }
2531
+ return filtered;
2495
2532
  }
2496
2533
  function concatEffects(a, b) {
2497
2534
  return a ? b ? a + " " + b : a : b;
@@ -2519,31 +2556,6 @@ function flushTickQueue() {
2519
2556
  tickQueue = void 0;
2520
2557
  for (const cb of queue) cb(true);
2521
2558
  }
2522
- function getFilteredGlobals($global) {
2523
- if (!$global) return 0;
2524
- const serializedGlobals = $global.serializedGlobals;
2525
- if (!serializedGlobals) return 0;
2526
- let filtered = 0;
2527
- if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
2528
- const value = $global[key];
2529
- if (value !== void 0) if (filtered) filtered[key] = value;
2530
- else filtered = { [key]: value };
2531
- }
2532
- else for (const key in serializedGlobals) if (serializedGlobals[key]) {
2533
- const value = $global[key];
2534
- if (value !== void 0) if (filtered) filtered[key] = value;
2535
- else filtered = { [key]: value };
2536
- }
2537
- return filtered;
2538
- }
2539
- function _subscribe(subscribers, scope) {
2540
- if (subscribers) {
2541
- const { serializer } = $chunk.boundary.state;
2542
- if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
2543
- else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
2544
- }
2545
- return scope;
2546
- }
2547
2559
  //#endregion
2548
2560
  //#region src/html/attrs.ts
2549
2561
  function _attr_class(value) {
@@ -2752,7 +2764,7 @@ function normalizedValueMatches(a, b) {
2752
2764
  return false;
2753
2765
  }
2754
2766
  function normalizeStrAttrValue(value) {
2755
- return value && value !== true || value === 0 ? value + "" : "";
2767
+ return isNotVoid(value) && value !== true ? value + "" : "";
2756
2768
  }
2757
2769
  //#endregion
2758
2770
  //#region src/html/dynamic-tag.ts
@@ -2768,27 +2780,30 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2768
2780
  assertValidTagName(renderer);
2769
2781
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2770
2782
  rendered = true;
2771
- _scope_id();
2772
- _html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
2773
- if (!voidElementsReg.test(renderer)) {
2774
- const renderContent = content || normalizeDynamicRenderer(input.content);
2775
- if (renderer === "textarea") {
2776
- if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
2777
- _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
2778
- } else if (renderContent) {
2779
- if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2780
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
2781
- else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
2783
+ const renderNative = () => {
2784
+ _scope_id();
2785
+ _html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
2786
+ if (!voidElementsReg.test(renderer)) {
2787
+ const renderContent = content || normalizeDynamicRenderer(input.content);
2788
+ if (renderer === "textarea") {
2789
+ if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
2790
+ _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
2791
+ } else if (renderContent) {
2792
+ if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2793
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
2794
+ else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
2795
+ }
2796
+ _html(`</${renderer}>`);
2797
+ } else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2798
+ const childScope = getScopeById(branchId);
2799
+ const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
2800
+ if (needsScript) {
2801
+ writeScope(branchId, { ["#Renderer"]: renderer });
2802
+ _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
2782
2803
  }
2783
- _html(`</${renderer}>`);
2784
- } else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2785
- const childScope = getScopeById(branchId);
2786
- const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
2787
- if (needsScript) {
2788
- writeScope(branchId, { ["#Renderer"]: renderer });
2789
- _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
2790
- }
2791
- if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
2804
+ if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
2805
+ };
2806
+ renderNative();
2792
2807
  } else {
2793
2808
  if (shouldResume) _html(state.mark("[", ""));
2794
2809
  const render = () => {
@@ -2828,6 +2843,7 @@ const patchDynamicTag = ((originalDynamicTag) => (patch) => {
2828
2843
  })(_dynamic_tag);
2829
2844
  //#endregion
2830
2845
  //#region src/html/template.ts
2846
+ const CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result";
2831
2847
  const _template = (templateId, renderer, page) => {
2832
2848
  renderer.render = render;
2833
2849
  renderer["embed"] = !page;
@@ -2990,7 +3006,7 @@ var ServerRendered = class {
2990
3006
  return this.#cachedPromise ||= new Promise((resolve, reject) => {
2991
3007
  const head = this.#head;
2992
3008
  this.#head = null;
2993
- if (!head) return reject(/* @__PURE__ */ new Error("Cannot read from a consumed render result"));
3009
+ if (!head) return reject(/* @__PURE__ */ new Error(CONSUMED_RESULT_MESSAGE));
2994
3010
  const { boundary } = head;
2995
3011
  (boundary.onNext = () => {
2996
3012
  switch (!boundary.count && boundary.flush()) {
@@ -2998,9 +3014,11 @@ var ServerRendered = class {
2998
3014
  boundary.onNext = NOOP$1;
2999
3015
  reject(boundary.signal.reason);
3000
3016
  break;
3001
- case 0:
3002
- resolve(head.consume().flushHTML());
3017
+ case 0: {
3018
+ const consumed = head.consume();
3019
+ if (!boundary.signal.aborted) resolve(consumed.flushHTML());
3003
3020
  break;
3021
+ }
3004
3022
  }
3005
3023
  })();
3006
3024
  });
@@ -3010,7 +3028,7 @@ var ServerRendered = class {
3010
3028
  let head = this.#head;
3011
3029
  this.#head = null;
3012
3030
  if (!head) {
3013
- onAbort(/* @__PURE__ */ new Error("Cannot read from a consumed render result"));
3031
+ onAbort(/* @__PURE__ */ new Error(CONSUMED_RESULT_MESSAGE));
3014
3032
  return;
3015
3033
  }
3016
3034
  const { boundary } = head;
@@ -3040,7 +3058,7 @@ var ServerRendered = class {
3040
3058
  toString() {
3041
3059
  const head = this.#head;
3042
3060
  this.#head = null;
3043
- if (!head) throw new Error("Cannot read from a consumed render result");
3061
+ if (!head) throw new Error(CONSUMED_RESULT_MESSAGE);
3044
3062
  const { boundary } = head;
3045
3063
  switch (boundary.flush()) {
3046
3064
  case 2: throw boundary.signal.reason;
@@ -15,59 +15,56 @@ interface SerializeState {
15
15
  type ScopeInternals = PartialScope & {
16
16
  [K_SCOPE_ID]?: number;
17
17
  };
18
- declare enum Mark {
19
- Placeholder = "!^",
20
- PlaceholderEnd = "!",
21
- ReorderMarker = "#"
22
- }
23
18
  export declare function getChunk(): Chunk | undefined;
24
19
  export declare function getContext(key: keyof NonNullable<Chunk["context"]>): unknown;
25
20
  export declare function getState(): State;
26
21
  export declare function getScopeId(scope: unknown): number | undefined;
22
+ export declare function getScopeById(scopeId: number | undefined): ScopeInternals | undefined;
23
+ export declare function $global(): $Global & {
24
+ renderId: string;
25
+ runtimeId: string;
26
+ };
27
+ export declare function _id(): string;
28
+ export declare function _scope_id(): number;
29
+ export declare function _peek_scope_id(): number;
30
+ export declare function withContext<T>(key: PropertyKey, value: unknown, cb: () => T): T;
31
+ export declare function withContext<T, U>(key: PropertyKey, value: unknown, cb: (value: U) => T, cbValue: U): T;
32
+ export declare function isInResumedBranch(): boolean;
33
+ export declare function withBranchId<T>(branchId: number, cb: () => T): T;
27
34
  export declare function _html(html: string): void;
28
35
  export declare function writeScript(script: string): void;
29
- export declare function writeWaitReady(readyId: string, renderer: ServerRenderer, input: unknown): void;
30
36
  export declare function _script(scopeId: number, registryId: string): void;
31
- export declare function _attr_content(nodeAccessor: Accessor, scopeId: number, content: unknown, serializeReason?: 1 | 0): void;
32
- export declare function withContext<T>(key: PropertyKey, value: unknown, cb: () => T): T;
33
- export declare function withContext<T, U>(key: PropertyKey, value: unknown, cb: (value: U) => T, cbValue: U): T;
34
- export declare function _var(parentScopeId: number, scopeOffsetAccessor: Accessor, childScopeId: number, registryId: string, nodeAccessor?: Accessor): void;
37
+ export declare function _trailers(html: string): void;
35
38
  export declare function _resume<T extends WeakKey>(val: T, id: string, scopeId?: number): T;
36
- export declare function _id(): string;
37
- export declare function _scope_id(): number;
38
- export declare function _peek_scope_id(): number;
39
- export declare function getScopeById(scopeId: number | undefined): ScopeInternals | undefined;
40
- export type SerializeReasonValue = undefined | number | Partial<Record<string, 0 | 1>>;
41
- export declare function _set_serialize_reason(reason: SerializeReasonValue): void;
42
- export declare function _scope_reason(): SerializeReasonValue;
43
- export declare function _serialize_if(condition: SerializeReasonValue, key: number): 1 | undefined;
44
- export declare function _serialize_guard(condition: SerializeReasonValue, key: number): 0 | 1;
45
- export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
46
- export declare function _sep(shouldResume: 0 | 1): "" | "<!>";
47
39
  export declare function _el(scopeId: number, id: string): () => void;
48
40
  export declare function _hoist(scopeId: number, id: string): {
49
41
  (): void;
50
42
  [Symbol.iterator]: typeof _hoist_read_error;
51
43
  };
44
+ export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: number): string;
45
+ export declare function _sep(shouldResume: number): "" | "<!>";
52
46
  export declare function _resume_branch(scopeId: number): void;
53
- export declare function isInResumedBranch(): boolean;
54
- export declare function withBranchId<T>(branchId: number, cb: () => T): T;
55
- 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;
56
- 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;
57
- 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;
58
- 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;
59
- 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;
47
+ export declare function _attr_content(nodeAccessor: Accessor, scopeId: number, content: unknown, serializeReason?: number): void;
48
+ export declare function _var(parentScopeId: number, scopeOffsetAccessor: Accessor, childScopeId: number, registryId: string, nodeAccessor?: Accessor): void;
60
49
  export declare function _show_start(display: unknown, mark?: unknown): void;
61
- export declare function _show_end(scopeId: number, accessor: Accessor, display: unknown, serializeMarker?: 0 | 1, serializeStateful?: 0 | 1, parentEndTag?: string | 0, singleNode?: 1 | 0): void;
50
+ export declare function _show_end(scopeId: number, accessor: Accessor, display: unknown, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1 | 0): void;
51
+ 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?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
52
+ 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?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
53
+ 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?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
54
+ 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?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
55
+ export declare function _if(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: number, serializeMarker?: number, serializeStateful?: number, parentEndTag?: string | 0, singleNode?: 1): void;
62
56
  declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
63
57
  export { writeScope as _scope };
64
58
  export declare function _existing_scope(scopeId: number): ScopeInternals;
65
59
  export declare function _scope_with_id(scopeId: number): ScopeInternals;
66
- export declare function $global(): $Global & {
67
- renderId: string;
68
- runtimeId: string;
69
- };
70
- export declare function _await<T>(scopeId: number, accessor: Accessor, promise: Promise<T> | T, content: (value: T) => void, serializeMarker?: 0 | 1): void;
60
+ export declare function _subscribe(subscribers: Set<ScopeInternals> | undefined, scope: ScopeInternals): ScopeInternals;
61
+ export type SerializeReasonValue = undefined | number | Partial<Record<string, 0 | 1>>;
62
+ export declare function _set_serialize_reason(reason: SerializeReasonValue): void;
63
+ export declare function _scope_reason(): SerializeReasonValue;
64
+ export declare function _serialize_if(condition: SerializeReasonValue, key: number): 1 | undefined;
65
+ export declare function _serialize_guard(condition: SerializeReasonValue, key: number): 0 | 1;
66
+ export declare function writeWaitReady(readyId: string, renderer: ServerRenderer, input: unknown): void;
67
+ export declare function _await<T>(scopeId: number, accessor: Accessor, promise: Promise<T> | T, content: (value: T) => void, serializeMarker?: number): void;
71
68
  export declare function _try(scopeId: number, accessor: Accessor, content: () => void, input: {
72
69
  placeholder?: {
73
70
  content?(): void;
@@ -76,6 +73,11 @@ export declare function _try(scopeId: number, accessor: Accessor, content: () =>
76
73
  content?(err: unknown): void;
77
74
  };
78
75
  }): void;
76
+ declare enum Mark {
77
+ Placeholder = "!^",
78
+ PlaceholderEnd = "!",
79
+ ReorderMarker = "#"
80
+ }
79
81
  export declare class State implements SerializeState {
80
82
  $global: $Global & {
81
83
  renderId: string;
@@ -164,8 +166,6 @@ export declare class Chunk {
164
166
  flushScript(): this;
165
167
  flushHTML(): string;
166
168
  }
167
- export declare function _trailers(html: string): void;
168
169
  type QueueCallback = (ticked: true) => void;
169
170
  export declare function queueTick(cb: QueueCallback): void;
170
171
  export declare function offTick(cb: QueueCallback): void;
171
- export declare function _subscribe(subscribers: Set<ScopeInternals> | undefined, scope: ScopeInternals): ScopeInternals;