marko 6.0.0-next.3.84 → 6.0.0-next.3.86

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.
@@ -1616,9 +1616,9 @@ function withContext(key, value, cb) {
1616
1616
  ctx[key] = prev;
1617
1617
  }
1618
1618
  }
1619
- function setTagVar(parentScopeId, scopeOffsetAccessor, childScope, registryId) {
1619
+ function setTagVar(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
1620
1620
  ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId();
1621
- childScope["#TagVariable" /* TagVariable */] = register2(
1621
+ ensureScopeWithId(childScopeId)["#TagVariable" /* TagVariable */] = register2(
1622
1622
  {},
1623
1623
  registryId,
1624
1624
  parentScopeId
@@ -1638,19 +1638,26 @@ function nextScopeId() {
1638
1638
  function peekNextScopeId() {
1639
1639
  return $chunk.boundary.state.scopeId;
1640
1640
  }
1641
- function peekNextScope() {
1642
- return ensureScopeWithId(peekNextScopeId());
1643
- }
1644
1641
  function getScopeById(scopeId) {
1645
1642
  if (scopeId !== void 0) {
1646
1643
  return $chunk.boundary.state.scopes.get(scopeId);
1647
1644
  }
1648
1645
  }
1649
- function markResumeNode(scopeId, accessor) {
1646
+ function serializeIf(condition, key) {
1647
+ return condition && (condition === 1 || condition[key]) ? 1 : void 0;
1648
+ }
1649
+ function serializeGuard(condition, key) {
1650
+ return condition && (condition === 1 || condition[key]) ? 1 : 0;
1651
+ }
1652
+ function markResumeNode(scopeId, accessor, shouldResume) {
1653
+ if (shouldResume === 0) return "";
1650
1654
  const { state } = $chunk.boundary;
1651
1655
  state.needsMainRuntime = true;
1652
1656
  return state.mark("*" /* Node */, scopeId + " " + accessor);
1653
1657
  }
1658
+ function commentSeparator(shouldResume) {
1659
+ return shouldResume === 0 ? "" : "<!>";
1660
+ }
1654
1661
  function nodeRef(scopeId, id) {
1655
1662
  const getter = () => {
1656
1663
  if (true) {
@@ -1678,7 +1685,10 @@ var branchIdKey = Symbol();
1678
1685
  function withBranchId(branchId, cb) {
1679
1686
  return withContext(branchIdKey, branchId, cb);
1680
1687
  }
1681
- function resumeForOf(list, cb, by, scopeId, accessor) {
1688
+ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
1689
+ if (serializeBranch === 0) {
1690
+ return forOf(list, cb);
1691
+ }
1682
1692
  const loopScopes = /* @__PURE__ */ new Map();
1683
1693
  forOf(list, (item, index) => {
1684
1694
  const branchId = peekNextScopeId();
@@ -1705,7 +1715,10 @@ function resumeForOf(list, cb, by, scopeId, accessor) {
1705
1715
  )
1706
1716
  );
1707
1717
  }
1708
- function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
1718
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
1719
+ if (serializeBranch === 0) {
1720
+ return forOf(list, cb);
1721
+ }
1709
1722
  const loopScopes = /* @__PURE__ */ new Map();
1710
1723
  let branchIds = "";
1711
1724
  forOf(list, (item, index) => {
@@ -1737,7 +1750,10 @@ function forOfBy(by, item, index) {
1737
1750
  }
1738
1751
  return index;
1739
1752
  }
1740
- function resumeForIn(obj, cb, by, scopeId, accessor) {
1753
+ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
1754
+ if (serializeBranch === 0) {
1755
+ return forIn(obj, cb);
1756
+ }
1741
1757
  const loopScopes = /* @__PURE__ */ new Map();
1742
1758
  let sep = "";
1743
1759
  forIn(obj, (key, value) => {
@@ -1763,7 +1779,10 @@ function resumeForIn(obj, cb, by, scopeId, accessor) {
1763
1779
  )
1764
1780
  );
1765
1781
  }
1766
- function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
1782
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1783
+ if (serializeBranch === 0) {
1784
+ return forIn(obj, cb);
1785
+ }
1767
1786
  const loopScopes = /* @__PURE__ */ new Map();
1768
1787
  let branchIds = "";
1769
1788
  forIn(obj, (key, value) => {
@@ -1792,7 +1811,10 @@ function forInBy(by, name, value) {
1792
1811
  }
1793
1812
  return name;
1794
1813
  }
1795
- function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1814
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
1815
+ if (serializeBranch === 0) {
1816
+ return forTo(to, from, step, cb);
1817
+ }
1796
1818
  const loopScopes = /* @__PURE__ */ new Map();
1797
1819
  let sep = "";
1798
1820
  forTo(to, from, step, (index) => {
@@ -1818,7 +1840,10 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1818
1840
  )
1819
1841
  );
1820
1842
  }
1821
- function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
1843
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1844
+ if (serializeBranch === 0) {
1845
+ return forTo(to, from, step, cb);
1846
+ }
1822
1847
  const loopScopes = /* @__PURE__ */ new Map();
1823
1848
  let branchIds = "";
1824
1849
  forTo(to, from, step, (index) => {
@@ -1847,9 +1872,12 @@ function forToBy(by, index) {
1847
1872
  }
1848
1873
  return index;
1849
1874
  }
1850
- function resumeConditional(cb, scopeId, accessor, dynamic) {
1875
+ function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
1876
+ if (serializeBranch === 0) {
1877
+ return cb();
1878
+ }
1851
1879
  const branchId = peekNextScopeId();
1852
- if (dynamic) {
1880
+ if (serializeMarker) {
1853
1881
  $chunk.writeHTML(
1854
1882
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1855
1883
  );
@@ -1857,13 +1885,13 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
1857
1885
  const branchIndex = withBranchId(branchId, cb);
1858
1886
  if (branchIndex !== void 0) {
1859
1887
  writeScope(scopeId, {
1860
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1888
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1861
1889
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1862
1890
  });
1863
1891
  } else {
1864
1892
  nextScopeId();
1865
1893
  }
1866
- if (dynamic) {
1894
+ if (serializeMarker) {
1867
1895
  $chunk.writeHTML(
1868
1896
  $chunk.boundary.state.mark(
1869
1897
  "]" /* BranchEnd */,
@@ -1872,19 +1900,22 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
1872
1900
  );
1873
1901
  }
1874
1902
  }
1875
- function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
1903
+ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
1904
+ if (serializeBranch === 0) {
1905
+ return cb();
1906
+ }
1876
1907
  const branchId = peekNextScopeId();
1877
1908
  const branchIndex = withBranchId(branchId, cb);
1878
1909
  const rendered = branchIndex !== void 0;
1879
1910
  if (rendered) {
1880
1911
  writeScope(scopeId, {
1881
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1912
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1882
1913
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1883
1914
  });
1884
1915
  } else {
1885
1916
  nextScopeId();
1886
1917
  }
1887
- if (dynamic) {
1918
+ if (serializeMarker) {
1888
1919
  $chunk.writeHTML(
1889
1920
  $chunk.boundary.state.mark(
1890
1921
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -1921,8 +1952,8 @@ if (true) {
1921
1952
  return scope;
1922
1953
  })(writeScope);
1923
1954
  }
1924
- function writeExistingScope(scope) {
1925
- return writeScope(scope[K_SCOPE_ID], scope);
1955
+ function writeExistingScope(scopeId) {
1956
+ return writeScope(scopeId, ensureScopeWithId(scopeId));
1926
1957
  }
1927
1958
  function ensureScopeWithId(scopeId) {
1928
1959
  const { state } = $chunk.boundary;
@@ -2756,9 +2787,232 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
2756
2787
  var DEFAULT_RUNTIME_ID = "M";
2757
2788
  var DEFAULT_RENDER_ID = "_";
2758
2789
 
2790
+ // src/html/template.ts
2791
+ var createTemplate = (templateId, renderer) => {
2792
+ renderer.render = render;
2793
+ renderer._ = renderer;
2794
+ if (true) {
2795
+ renderer.mount = () => {
2796
+ throw new Error(
2797
+ `mount() is not implemented for the HTML compilation of a Marko template`
2798
+ );
2799
+ };
2800
+ }
2801
+ return registerContent(templateId, renderer);
2802
+ };
2803
+ function isTemplate(renderer) {
2804
+ return !!renderer._;
2805
+ }
2806
+ function render(input = {}) {
2807
+ let { $global: $global2 } = input;
2808
+ if ($global2) {
2809
+ ({ $global: $global2, ...input } = input);
2810
+ $global2 = {
2811
+ runtimeId: DEFAULT_RUNTIME_ID,
2812
+ renderId: DEFAULT_RENDER_ID,
2813
+ ...$global2
2814
+ };
2815
+ } else {
2816
+ $global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
2817
+ }
2818
+ const head = new Chunk(
2819
+ new Boundary(new State2($global2), $global2.signal),
2820
+ null,
2821
+ null
2822
+ );
2823
+ head.render(this, input);
2824
+ return new ServerRendered(head);
2825
+ }
2826
+ var ServerRendered = class {
2827
+ #head;
2828
+ #cachedPromise = null;
2829
+ constructor(head) {
2830
+ this.#head = head;
2831
+ }
2832
+ [Symbol.asyncIterator]() {
2833
+ let resolve;
2834
+ let reject;
2835
+ let value = "";
2836
+ let done = false;
2837
+ let aborted = false;
2838
+ let reason;
2839
+ const boundary = this.#read(
2840
+ (html) => {
2841
+ value += html;
2842
+ if (resolve) {
2843
+ resolve({ value, done });
2844
+ value = "";
2845
+ }
2846
+ },
2847
+ (err) => {
2848
+ aborted = true;
2849
+ reason = err;
2850
+ if (reject) {
2851
+ reject(err);
2852
+ }
2853
+ },
2854
+ () => {
2855
+ done = true;
2856
+ if (resolve) {
2857
+ resolve({ value, done: !value });
2858
+ value = "";
2859
+ }
2860
+ }
2861
+ );
2862
+ return {
2863
+ next() {
2864
+ if (aborted) {
2865
+ return Promise.reject(reason);
2866
+ } else if (value) {
2867
+ const result = { value, done: false };
2868
+ value = "";
2869
+ return Promise.resolve(result);
2870
+ } else if (done) {
2871
+ return Promise.resolve({ value: "", done });
2872
+ } else {
2873
+ return new Promise(exec);
2874
+ }
2875
+ },
2876
+ throw(error) {
2877
+ if (!(done || aborted)) {
2878
+ boundary?.abort(error);
2879
+ }
2880
+ return Promise.resolve({ value: "", done: true });
2881
+ },
2882
+ return(value2) {
2883
+ if (!(done || aborted)) {
2884
+ boundary?.abort(new Error("Iterator returned before consumed."));
2885
+ }
2886
+ return Promise.resolve({ value: value2, done: true });
2887
+ }
2888
+ };
2889
+ function exec(_resolve, _reject) {
2890
+ resolve = _resolve;
2891
+ reject = _reject;
2892
+ }
2893
+ }
2894
+ pipe(stream) {
2895
+ this.#read(
2896
+ (html) => {
2897
+ stream.write(html);
2898
+ },
2899
+ (err) => {
2900
+ const socket = "socket" in stream && stream.socket;
2901
+ if (socket && typeof socket.destroySoon === "function") {
2902
+ socket.destroySoon();
2903
+ }
2904
+ if (!stream.emit?.("error", err)) {
2905
+ throw err;
2906
+ }
2907
+ },
2908
+ () => {
2909
+ stream.end();
2910
+ }
2911
+ );
2912
+ }
2913
+ toReadable() {
2914
+ let cancelled = false;
2915
+ let boundary;
2916
+ const encoder = new TextEncoder();
2917
+ return new ReadableStream({
2918
+ start: (ctrl) => {
2919
+ boundary = this.#read(
2920
+ (html) => {
2921
+ ctrl.enqueue(encoder.encode(html));
2922
+ },
2923
+ (err) => {
2924
+ boundary = void 0;
2925
+ if (!cancelled) {
2926
+ ctrl.error(err);
2927
+ }
2928
+ },
2929
+ () => {
2930
+ boundary = void 0;
2931
+ ctrl.close();
2932
+ }
2933
+ );
2934
+ },
2935
+ cancel: (reason) => {
2936
+ cancelled = true;
2937
+ boundary?.abort(reason);
2938
+ }
2939
+ });
2940
+ }
2941
+ then(onfulfilled, onrejected) {
2942
+ return this.#promise().then(onfulfilled, onrejected);
2943
+ }
2944
+ catch(onrejected) {
2945
+ return this.#promise().catch(onrejected);
2946
+ }
2947
+ finally(onfinally) {
2948
+ return this.#promise().finally(onfinally);
2949
+ }
2950
+ #promise() {
2951
+ return this.#cachedPromise ||= new Promise((resolve, reject) => {
2952
+ const head = this.#head;
2953
+ this.#head = null;
2954
+ if (!head) {
2955
+ return reject(new Error("Cannot read from a consumed render result"));
2956
+ }
2957
+ const { boundary } = head;
2958
+ (boundary.onNext = () => {
2959
+ if (boundary.signal.aborted) {
2960
+ boundary.onNext = NOOP2;
2961
+ reject(boundary.signal.reason);
2962
+ } else if (boundary.done) {
2963
+ resolve(head.consume().flushHTML());
2964
+ }
2965
+ })();
2966
+ });
2967
+ }
2968
+ #read(onWrite, onAbort, onClose) {
2969
+ let tick2 = true;
2970
+ let head = this.#head;
2971
+ this.#head = null;
2972
+ if (!head) {
2973
+ onAbort(new Error("Cannot read from a consumed render result"));
2974
+ return;
2975
+ }
2976
+ const { boundary } = head;
2977
+ const onNext = boundary.onNext = (write2) => {
2978
+ if (boundary.signal.aborted) {
2979
+ if (!tick2) offTick(onNext);
2980
+ boundary.onNext = NOOP2;
2981
+ onAbort(boundary.signal.reason);
2982
+ } else {
2983
+ const { done } = boundary;
2984
+ if (done || write2) {
2985
+ const html = (head = head.consume()).flushHTML();
2986
+ if (html) onWrite(html);
2987
+ if (done) {
2988
+ if (!tick2) offTick(onNext);
2989
+ onClose();
2990
+ } else {
2991
+ tick2 = true;
2992
+ }
2993
+ } else if (tick2) {
2994
+ tick2 = false;
2995
+ queueTick(onNext);
2996
+ }
2997
+ }
2998
+ };
2999
+ onNext();
3000
+ return boundary;
3001
+ }
3002
+ toString() {
3003
+ const head = this.#head;
3004
+ this.#head = null;
3005
+ if (!head) throw new Error("Cannot read from a consumed render result");
3006
+ if (!head.boundary.done) throw new Error("Cannot fork in sync mode");
3007
+ return head.consume().flushHTML();
3008
+ }
3009
+ };
3010
+ function NOOP2() {
3011
+ }
3012
+
2759
3013
  // src/html/dynamic-tag.ts
2760
3014
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2761
- var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
3015
+ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, shouldResume) => {
2762
3016
  const renderer = normalizeDynamicRenderer(tag);
2763
3017
  if (true) {
2764
3018
  if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
@@ -2773,7 +3027,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2773
3027
  nextScopeId();
2774
3028
  write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
2775
3029
  if (!voidElementsReg.test(renderer)) {
2776
- withBranchId(branchId, () => {
3030
+ const renderNativeTag = () => {
2777
3031
  if (renderer === "textarea") {
2778
3032
  if (content) {
2779
3033
  throw new Error(
@@ -2801,12 +3055,17 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2801
3055
  content();
2802
3056
  }
2803
3057
  }
2804
- });
3058
+ };
3059
+ if (shouldResume) {
3060
+ withBranchId(branchId, renderNativeTag);
3061
+ } else {
3062
+ renderNativeTag();
3063
+ }
2805
3064
  write(`</${renderer}>`);
2806
3065
  } else if (content) {
2807
3066
  throw new Error(`Body content is not supported for a "${renderer}" tag.`);
2808
3067
  }
2809
- if (resume) {
3068
+ if (shouldResume) {
2810
3069
  write(
2811
3070
  state.mark(
2812
3071
  "|" /* BranchSingleNode */,
@@ -2815,25 +3074,33 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2815
3074
  );
2816
3075
  }
2817
3076
  } else {
2818
- if (resume) {
3077
+ if (shouldResume) {
2819
3078
  write(state.mark("[" /* BranchStart */, branchId + ""));
2820
3079
  }
2821
- result = withBranchId(branchId, () => {
3080
+ const render2 = () => {
2822
3081
  if (renderer) {
3082
+ if (isTemplate(renderer)) {
3083
+ const input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
3084
+ return renderer(
3085
+ content ? { ...input, content } : input,
3086
+ shouldResume
3087
+ );
3088
+ }
2823
3089
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(
2824
3090
  content ? { ...inputOrArgs, content } : inputOrArgs
2825
3091
  );
2826
3092
  } else if (content) {
2827
3093
  return content();
2828
3094
  }
2829
- });
2830
- if (resume) {
3095
+ };
3096
+ result = shouldResume ? withBranchId(branchId, render2) : render2();
3097
+ if (shouldResume) {
2831
3098
  write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
2832
3099
  }
2833
3100
  }
2834
3101
  const rendered = peekNextScopeId() !== branchId;
2835
3102
  if (rendered) {
2836
- if (resume) {
3103
+ if (shouldResume) {
2837
3104
  writeScope(scopeId, {
2838
3105
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
2839
3106
  ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
@@ -2928,7 +3195,11 @@ var compat = {
2928
3195
  writeScope(scopeId, { m5c: component.id });
2929
3196
  writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
2930
3197
  }
2931
- renderer(normalizedInput);
3198
+ if (isTemplate(renderer) && willRerender) {
3199
+ renderer(normalizedInput, 1);
3200
+ } else {
3201
+ renderer(normalizedInput);
3202
+ }
2932
3203
  });
2933
3204
  const asyncOut = classAPIOut.beginAsync();
2934
3205
  queueMicrotask(
@@ -2979,216 +3250,6 @@ function forToBy2(by, index) {
2979
3250
  }
2980
3251
  return index;
2981
3252
  }
2982
-
2983
- // src/html/template.ts
2984
- var createTemplate = (templateId, renderer) => {
2985
- renderer.render = render;
2986
- renderer._ = renderer;
2987
- if (true) {
2988
- renderer.mount = () => {
2989
- throw new Error(
2990
- `mount() is not implemented for the HTML compilation of a Marko template`
2991
- );
2992
- };
2993
- }
2994
- return registerContent(templateId, renderer);
2995
- };
2996
- function render(input = {}) {
2997
- let { $global: $global2 } = input;
2998
- if ($global2) {
2999
- ({ $global: $global2, ...input } = input);
3000
- $global2 = {
3001
- runtimeId: DEFAULT_RUNTIME_ID,
3002
- renderId: DEFAULT_RENDER_ID,
3003
- ...$global2
3004
- };
3005
- } else {
3006
- $global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
3007
- }
3008
- const head = new Chunk(
3009
- new Boundary(new State2($global2), $global2.signal),
3010
- null,
3011
- null
3012
- );
3013
- head.render(this, input);
3014
- return new ServerRendered(head);
3015
- }
3016
- var ServerRendered = class {
3017
- #head;
3018
- #cachedPromise = null;
3019
- constructor(head) {
3020
- this.#head = head;
3021
- }
3022
- [Symbol.asyncIterator]() {
3023
- let resolve;
3024
- let reject;
3025
- let value = "";
3026
- let done = false;
3027
- let aborted = false;
3028
- let reason;
3029
- const boundary = this.#read(
3030
- (html) => {
3031
- value += html;
3032
- if (resolve) {
3033
- resolve({ value, done });
3034
- value = "";
3035
- }
3036
- },
3037
- (err) => {
3038
- aborted = true;
3039
- reason = err;
3040
- if (reject) {
3041
- reject(err);
3042
- }
3043
- },
3044
- () => {
3045
- done = true;
3046
- if (resolve) {
3047
- resolve({ value, done: !value });
3048
- value = "";
3049
- }
3050
- }
3051
- );
3052
- return {
3053
- next() {
3054
- if (aborted) {
3055
- return Promise.reject(reason);
3056
- } else if (value) {
3057
- const result = { value, done: false };
3058
- value = "";
3059
- return Promise.resolve(result);
3060
- } else if (done) {
3061
- return Promise.resolve({ value: "", done });
3062
- } else {
3063
- return new Promise(exec);
3064
- }
3065
- },
3066
- throw(error) {
3067
- if (!(done || aborted)) {
3068
- boundary?.abort(error);
3069
- }
3070
- return Promise.resolve({ value: "", done: true });
3071
- },
3072
- return(value2) {
3073
- if (!(done || aborted)) {
3074
- boundary?.abort(new Error("Iterator returned before consumed."));
3075
- }
3076
- return Promise.resolve({ value: value2, done: true });
3077
- }
3078
- };
3079
- function exec(_resolve, _reject) {
3080
- resolve = _resolve;
3081
- reject = _reject;
3082
- }
3083
- }
3084
- pipe(stream) {
3085
- this.#read(
3086
- (html) => {
3087
- stream.write(html);
3088
- },
3089
- (err) => {
3090
- const socket = "socket" in stream && stream.socket;
3091
- if (socket && typeof socket.destroySoon === "function") {
3092
- socket.destroySoon();
3093
- }
3094
- if (!stream.emit?.("error", err)) {
3095
- throw err;
3096
- }
3097
- },
3098
- () => {
3099
- stream.end();
3100
- }
3101
- );
3102
- }
3103
- toReadable() {
3104
- const encoder = new TextEncoder();
3105
- return new ReadableStream({
3106
- start: (ctrl) => {
3107
- this.#read(
3108
- (html) => {
3109
- ctrl.enqueue(encoder.encode(html));
3110
- },
3111
- (err) => {
3112
- ctrl.error(err);
3113
- },
3114
- () => {
3115
- ctrl.close();
3116
- }
3117
- );
3118
- }
3119
- });
3120
- }
3121
- then(onfulfilled, onrejected) {
3122
- return this.#promise().then(onfulfilled, onrejected);
3123
- }
3124
- catch(onrejected) {
3125
- return this.#promise().catch(onrejected);
3126
- }
3127
- finally(onfinally) {
3128
- return this.#promise().finally(onfinally);
3129
- }
3130
- #promise() {
3131
- return this.#cachedPromise ||= new Promise((resolve, reject) => {
3132
- const head = this.#head;
3133
- this.#head = null;
3134
- if (!head) {
3135
- return reject(new Error("Cannot read from a consumed render result"));
3136
- }
3137
- const { boundary } = head;
3138
- (boundary.onNext = () => {
3139
- if (boundary.signal.aborted) {
3140
- boundary.onNext = NOOP2;
3141
- reject(boundary.signal.reason);
3142
- } else if (boundary.done) {
3143
- resolve(head.consume().flushHTML());
3144
- }
3145
- })();
3146
- });
3147
- }
3148
- #read(onWrite, onAbort, onClose) {
3149
- let tick2 = true;
3150
- let head = this.#head;
3151
- this.#head = null;
3152
- if (!head) {
3153
- onAbort(new Error("Cannot read from a consumed render result"));
3154
- return;
3155
- }
3156
- const { boundary } = head;
3157
- const onNext = boundary.onNext = (write2) => {
3158
- if (boundary.signal.aborted) {
3159
- if (!tick2) offTick(onNext);
3160
- boundary.onNext = NOOP2;
3161
- onAbort(boundary.signal.reason);
3162
- } else {
3163
- const { done } = boundary;
3164
- if (done || write2) {
3165
- const html = (head = head.consume()).flushHTML();
3166
- if (html) onWrite(html);
3167
- if (done) {
3168
- if (!tick2) offTick(onNext);
3169
- onClose();
3170
- } else {
3171
- tick2 = true;
3172
- }
3173
- } else if (tick2) {
3174
- tick2 = false;
3175
- queueTick(onNext);
3176
- }
3177
- }
3178
- };
3179
- onNext();
3180
- return boundary;
3181
- }
3182
- toString() {
3183
- const head = this.#head;
3184
- this.#head = null;
3185
- if (!head) throw new Error("Cannot read from a consumed render result");
3186
- if (!head.boundary.done) throw new Error("Cannot fork in sync mode");
3187
- return head.consume().flushHTML();
3188
- }
3189
- };
3190
- function NOOP2() {
3191
- }
3192
3253
  export {
3193
3254
  $global,
3194
3255
  attr,
@@ -3196,6 +3257,7 @@ export {
3196
3257
  attrTags,
3197
3258
  attrs,
3198
3259
  classAttr,
3260
+ commentSeparator,
3199
3261
  compat,
3200
3262
  controllable_detailsOrDialog_open,
3201
3263
  controllable_input_checked,
@@ -3225,7 +3287,7 @@ export {
3225
3287
  nodeRef,
3226
3288
  optionValueAttr,
3227
3289
  partialAttrs,
3228
- peekNextScope,
3290
+ peekNextScopeId,
3229
3291
  register2 as register,
3230
3292
  registerContent,
3231
3293
  resumeClosestBranch,
@@ -3237,6 +3299,8 @@ export {
3237
3299
  resumeSingleNodeForIn,
3238
3300
  resumeSingleNodeForOf,
3239
3301
  resumeSingleNodeForTo,
3302
+ serializeGuard,
3303
+ serializeIf,
3240
3304
  setTagVar,
3241
3305
  styleAttr,
3242
3306
  toString,