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.
@@ -26,6 +26,7 @@ __export(html_exports, {
26
26
  attrTags: () => attrTags,
27
27
  attrs: () => attrs,
28
28
  classAttr: () => classAttr,
29
+ commentSeparator: () => commentSeparator,
29
30
  compat: () => compat,
30
31
  controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
31
32
  controllable_input_checked: () => controllable_input_checked,
@@ -55,7 +56,7 @@ __export(html_exports, {
55
56
  nodeRef: () => nodeRef,
56
57
  optionValueAttr: () => optionValueAttr,
57
58
  partialAttrs: () => partialAttrs,
58
- peekNextScope: () => peekNextScope,
59
+ peekNextScopeId: () => peekNextScopeId,
59
60
  register: () => register2,
60
61
  registerContent: () => registerContent,
61
62
  resumeClosestBranch: () => resumeClosestBranch,
@@ -67,6 +68,8 @@ __export(html_exports, {
67
68
  resumeSingleNodeForIn: () => resumeSingleNodeForIn,
68
69
  resumeSingleNodeForOf: () => resumeSingleNodeForOf,
69
70
  resumeSingleNodeForTo: () => resumeSingleNodeForTo,
71
+ serializeGuard: () => serializeGuard,
72
+ serializeIf: () => serializeIf,
70
73
  setTagVar: () => setTagVar,
71
74
  styleAttr: () => styleAttr,
72
75
  toString: () => toString,
@@ -1698,9 +1701,9 @@ function withContext(key, value, cb) {
1698
1701
  ctx[key] = prev;
1699
1702
  }
1700
1703
  }
1701
- function setTagVar(parentScopeId, scopeOffsetAccessor, childScope, registryId) {
1704
+ function setTagVar(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
1702
1705
  ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId();
1703
- childScope["#TagVariable" /* TagVariable */] = register2(
1706
+ ensureScopeWithId(childScopeId)["#TagVariable" /* TagVariable */] = register2(
1704
1707
  {},
1705
1708
  registryId,
1706
1709
  parentScopeId
@@ -1720,19 +1723,26 @@ function nextScopeId() {
1720
1723
  function peekNextScopeId() {
1721
1724
  return $chunk.boundary.state.scopeId;
1722
1725
  }
1723
- function peekNextScope() {
1724
- return ensureScopeWithId(peekNextScopeId());
1725
- }
1726
1726
  function getScopeById(scopeId) {
1727
1727
  if (scopeId !== void 0) {
1728
1728
  return $chunk.boundary.state.scopes.get(scopeId);
1729
1729
  }
1730
1730
  }
1731
- function markResumeNode(scopeId, accessor) {
1731
+ function serializeIf(condition, key) {
1732
+ return condition && (condition === 1 || condition[key]) ? 1 : void 0;
1733
+ }
1734
+ function serializeGuard(condition, key) {
1735
+ return condition && (condition === 1 || condition[key]) ? 1 : 0;
1736
+ }
1737
+ function markResumeNode(scopeId, accessor, shouldResume) {
1738
+ if (shouldResume === 0) return "";
1732
1739
  const { state } = $chunk.boundary;
1733
1740
  state.needsMainRuntime = true;
1734
1741
  return state.mark("*" /* Node */, scopeId + " " + accessor);
1735
1742
  }
1743
+ function commentSeparator(shouldResume) {
1744
+ return shouldResume === 0 ? "" : "<!>";
1745
+ }
1736
1746
  function nodeRef(scopeId, id) {
1737
1747
  const getter = () => {
1738
1748
  if (true) {
@@ -1760,7 +1770,10 @@ var branchIdKey = Symbol();
1760
1770
  function withBranchId(branchId, cb) {
1761
1771
  return withContext(branchIdKey, branchId, cb);
1762
1772
  }
1763
- function resumeForOf(list, cb, by, scopeId, accessor) {
1773
+ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
1774
+ if (serializeBranch === 0) {
1775
+ return forOf(list, cb);
1776
+ }
1764
1777
  const loopScopes = /* @__PURE__ */ new Map();
1765
1778
  forOf(list, (item, index) => {
1766
1779
  const branchId = peekNextScopeId();
@@ -1787,7 +1800,10 @@ function resumeForOf(list, cb, by, scopeId, accessor) {
1787
1800
  )
1788
1801
  );
1789
1802
  }
1790
- function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
1803
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
1804
+ if (serializeBranch === 0) {
1805
+ return forOf(list, cb);
1806
+ }
1791
1807
  const loopScopes = /* @__PURE__ */ new Map();
1792
1808
  let branchIds = "";
1793
1809
  forOf(list, (item, index) => {
@@ -1819,7 +1835,10 @@ function forOfBy(by, item, index) {
1819
1835
  }
1820
1836
  return index;
1821
1837
  }
1822
- function resumeForIn(obj, cb, by, scopeId, accessor) {
1838
+ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
1839
+ if (serializeBranch === 0) {
1840
+ return forIn(obj, cb);
1841
+ }
1823
1842
  const loopScopes = /* @__PURE__ */ new Map();
1824
1843
  let sep = "";
1825
1844
  forIn(obj, (key, value) => {
@@ -1845,7 +1864,10 @@ function resumeForIn(obj, cb, by, scopeId, accessor) {
1845
1864
  )
1846
1865
  );
1847
1866
  }
1848
- function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
1867
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1868
+ if (serializeBranch === 0) {
1869
+ return forIn(obj, cb);
1870
+ }
1849
1871
  const loopScopes = /* @__PURE__ */ new Map();
1850
1872
  let branchIds = "";
1851
1873
  forIn(obj, (key, value) => {
@@ -1874,7 +1896,10 @@ function forInBy(by, name, value) {
1874
1896
  }
1875
1897
  return name;
1876
1898
  }
1877
- function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1899
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
1900
+ if (serializeBranch === 0) {
1901
+ return forTo(to, from, step, cb);
1902
+ }
1878
1903
  const loopScopes = /* @__PURE__ */ new Map();
1879
1904
  let sep = "";
1880
1905
  forTo(to, from, step, (index) => {
@@ -1900,7 +1925,10 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1900
1925
  )
1901
1926
  );
1902
1927
  }
1903
- function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
1928
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1929
+ if (serializeBranch === 0) {
1930
+ return forTo(to, from, step, cb);
1931
+ }
1904
1932
  const loopScopes = /* @__PURE__ */ new Map();
1905
1933
  let branchIds = "";
1906
1934
  forTo(to, from, step, (index) => {
@@ -1929,9 +1957,12 @@ function forToBy(by, index) {
1929
1957
  }
1930
1958
  return index;
1931
1959
  }
1932
- function resumeConditional(cb, scopeId, accessor, dynamic) {
1960
+ function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
1961
+ if (serializeBranch === 0) {
1962
+ return cb();
1963
+ }
1933
1964
  const branchId = peekNextScopeId();
1934
- if (dynamic) {
1965
+ if (serializeMarker) {
1935
1966
  $chunk.writeHTML(
1936
1967
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1937
1968
  );
@@ -1939,13 +1970,13 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
1939
1970
  const branchIndex = withBranchId(branchId, cb);
1940
1971
  if (branchIndex !== void 0) {
1941
1972
  writeScope(scopeId, {
1942
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1973
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1943
1974
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1944
1975
  });
1945
1976
  } else {
1946
1977
  nextScopeId();
1947
1978
  }
1948
- if (dynamic) {
1979
+ if (serializeMarker) {
1949
1980
  $chunk.writeHTML(
1950
1981
  $chunk.boundary.state.mark(
1951
1982
  "]" /* BranchEnd */,
@@ -1954,19 +1985,22 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
1954
1985
  );
1955
1986
  }
1956
1987
  }
1957
- function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
1988
+ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
1989
+ if (serializeBranch === 0) {
1990
+ return cb();
1991
+ }
1958
1992
  const branchId = peekNextScopeId();
1959
1993
  const branchIndex = withBranchId(branchId, cb);
1960
1994
  const rendered = branchIndex !== void 0;
1961
1995
  if (rendered) {
1962
1996
  writeScope(scopeId, {
1963
- ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1997
+ ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1964
1998
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1965
1999
  });
1966
2000
  } else {
1967
2001
  nextScopeId();
1968
2002
  }
1969
- if (dynamic) {
2003
+ if (serializeMarker) {
1970
2004
  $chunk.writeHTML(
1971
2005
  $chunk.boundary.state.mark(
1972
2006
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
@@ -2003,8 +2037,8 @@ if (true) {
2003
2037
  return scope;
2004
2038
  })(writeScope);
2005
2039
  }
2006
- function writeExistingScope(scope) {
2007
- return writeScope(scope[K_SCOPE_ID], scope);
2040
+ function writeExistingScope(scopeId) {
2041
+ return writeScope(scopeId, ensureScopeWithId(scopeId));
2008
2042
  }
2009
2043
  function ensureScopeWithId(scopeId) {
2010
2044
  const { state } = $chunk.boundary;
@@ -2838,9 +2872,232 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
2838
2872
  var DEFAULT_RUNTIME_ID = "M";
2839
2873
  var DEFAULT_RENDER_ID = "_";
2840
2874
 
2875
+ // src/html/template.ts
2876
+ var createTemplate = (templateId, renderer) => {
2877
+ renderer.render = render;
2878
+ renderer._ = renderer;
2879
+ if (true) {
2880
+ renderer.mount = () => {
2881
+ throw new Error(
2882
+ `mount() is not implemented for the HTML compilation of a Marko template`
2883
+ );
2884
+ };
2885
+ }
2886
+ return registerContent(templateId, renderer);
2887
+ };
2888
+ function isTemplate(renderer) {
2889
+ return !!renderer._;
2890
+ }
2891
+ function render(input = {}) {
2892
+ let { $global: $global2 } = input;
2893
+ if ($global2) {
2894
+ ({ $global: $global2, ...input } = input);
2895
+ $global2 = {
2896
+ runtimeId: DEFAULT_RUNTIME_ID,
2897
+ renderId: DEFAULT_RENDER_ID,
2898
+ ...$global2
2899
+ };
2900
+ } else {
2901
+ $global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
2902
+ }
2903
+ const head = new Chunk(
2904
+ new Boundary(new State2($global2), $global2.signal),
2905
+ null,
2906
+ null
2907
+ );
2908
+ head.render(this, input);
2909
+ return new ServerRendered(head);
2910
+ }
2911
+ var ServerRendered = class {
2912
+ #head;
2913
+ #cachedPromise = null;
2914
+ constructor(head) {
2915
+ this.#head = head;
2916
+ }
2917
+ [Symbol.asyncIterator]() {
2918
+ let resolve;
2919
+ let reject;
2920
+ let value = "";
2921
+ let done = false;
2922
+ let aborted = false;
2923
+ let reason;
2924
+ const boundary = this.#read(
2925
+ (html) => {
2926
+ value += html;
2927
+ if (resolve) {
2928
+ resolve({ value, done });
2929
+ value = "";
2930
+ }
2931
+ },
2932
+ (err) => {
2933
+ aborted = true;
2934
+ reason = err;
2935
+ if (reject) {
2936
+ reject(err);
2937
+ }
2938
+ },
2939
+ () => {
2940
+ done = true;
2941
+ if (resolve) {
2942
+ resolve({ value, done: !value });
2943
+ value = "";
2944
+ }
2945
+ }
2946
+ );
2947
+ return {
2948
+ next() {
2949
+ if (aborted) {
2950
+ return Promise.reject(reason);
2951
+ } else if (value) {
2952
+ const result = { value, done: false };
2953
+ value = "";
2954
+ return Promise.resolve(result);
2955
+ } else if (done) {
2956
+ return Promise.resolve({ value: "", done });
2957
+ } else {
2958
+ return new Promise(exec);
2959
+ }
2960
+ },
2961
+ throw(error) {
2962
+ if (!(done || aborted)) {
2963
+ boundary?.abort(error);
2964
+ }
2965
+ return Promise.resolve({ value: "", done: true });
2966
+ },
2967
+ return(value2) {
2968
+ if (!(done || aborted)) {
2969
+ boundary?.abort(new Error("Iterator returned before consumed."));
2970
+ }
2971
+ return Promise.resolve({ value: value2, done: true });
2972
+ }
2973
+ };
2974
+ function exec(_resolve, _reject) {
2975
+ resolve = _resolve;
2976
+ reject = _reject;
2977
+ }
2978
+ }
2979
+ pipe(stream) {
2980
+ this.#read(
2981
+ (html) => {
2982
+ stream.write(html);
2983
+ },
2984
+ (err) => {
2985
+ const socket = "socket" in stream && stream.socket;
2986
+ if (socket && typeof socket.destroySoon === "function") {
2987
+ socket.destroySoon();
2988
+ }
2989
+ if (!stream.emit?.("error", err)) {
2990
+ throw err;
2991
+ }
2992
+ },
2993
+ () => {
2994
+ stream.end();
2995
+ }
2996
+ );
2997
+ }
2998
+ toReadable() {
2999
+ let cancelled = false;
3000
+ let boundary;
3001
+ const encoder = new TextEncoder();
3002
+ return new ReadableStream({
3003
+ start: (ctrl) => {
3004
+ boundary = this.#read(
3005
+ (html) => {
3006
+ ctrl.enqueue(encoder.encode(html));
3007
+ },
3008
+ (err) => {
3009
+ boundary = void 0;
3010
+ if (!cancelled) {
3011
+ ctrl.error(err);
3012
+ }
3013
+ },
3014
+ () => {
3015
+ boundary = void 0;
3016
+ ctrl.close();
3017
+ }
3018
+ );
3019
+ },
3020
+ cancel: (reason) => {
3021
+ cancelled = true;
3022
+ boundary?.abort(reason);
3023
+ }
3024
+ });
3025
+ }
3026
+ then(onfulfilled, onrejected) {
3027
+ return this.#promise().then(onfulfilled, onrejected);
3028
+ }
3029
+ catch(onrejected) {
3030
+ return this.#promise().catch(onrejected);
3031
+ }
3032
+ finally(onfinally) {
3033
+ return this.#promise().finally(onfinally);
3034
+ }
3035
+ #promise() {
3036
+ return this.#cachedPromise ||= new Promise((resolve, reject) => {
3037
+ const head = this.#head;
3038
+ this.#head = null;
3039
+ if (!head) {
3040
+ return reject(new Error("Cannot read from a consumed render result"));
3041
+ }
3042
+ const { boundary } = head;
3043
+ (boundary.onNext = () => {
3044
+ if (boundary.signal.aborted) {
3045
+ boundary.onNext = NOOP2;
3046
+ reject(boundary.signal.reason);
3047
+ } else if (boundary.done) {
3048
+ resolve(head.consume().flushHTML());
3049
+ }
3050
+ })();
3051
+ });
3052
+ }
3053
+ #read(onWrite, onAbort, onClose) {
3054
+ let tick2 = true;
3055
+ let head = this.#head;
3056
+ this.#head = null;
3057
+ if (!head) {
3058
+ onAbort(new Error("Cannot read from a consumed render result"));
3059
+ return;
3060
+ }
3061
+ const { boundary } = head;
3062
+ const onNext = boundary.onNext = (write2) => {
3063
+ if (boundary.signal.aborted) {
3064
+ if (!tick2) offTick(onNext);
3065
+ boundary.onNext = NOOP2;
3066
+ onAbort(boundary.signal.reason);
3067
+ } else {
3068
+ const { done } = boundary;
3069
+ if (done || write2) {
3070
+ const html = (head = head.consume()).flushHTML();
3071
+ if (html) onWrite(html);
3072
+ if (done) {
3073
+ if (!tick2) offTick(onNext);
3074
+ onClose();
3075
+ } else {
3076
+ tick2 = true;
3077
+ }
3078
+ } else if (tick2) {
3079
+ tick2 = false;
3080
+ queueTick(onNext);
3081
+ }
3082
+ }
3083
+ };
3084
+ onNext();
3085
+ return boundary;
3086
+ }
3087
+ toString() {
3088
+ const head = this.#head;
3089
+ this.#head = null;
3090
+ if (!head) throw new Error("Cannot read from a consumed render result");
3091
+ if (!head.boundary.done) throw new Error("Cannot fork in sync mode");
3092
+ return head.consume().flushHTML();
3093
+ }
3094
+ };
3095
+ function NOOP2() {
3096
+ }
3097
+
2841
3098
  // src/html/dynamic-tag.ts
2842
3099
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2843
- var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
3100
+ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, shouldResume) => {
2844
3101
  const renderer = normalizeDynamicRenderer(tag);
2845
3102
  if (true) {
2846
3103
  if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
@@ -2855,7 +3112,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2855
3112
  nextScopeId();
2856
3113
  write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
2857
3114
  if (!voidElementsReg.test(renderer)) {
2858
- withBranchId(branchId, () => {
3115
+ const renderNativeTag = () => {
2859
3116
  if (renderer === "textarea") {
2860
3117
  if (content) {
2861
3118
  throw new Error(
@@ -2883,12 +3140,17 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2883
3140
  content();
2884
3141
  }
2885
3142
  }
2886
- });
3143
+ };
3144
+ if (shouldResume) {
3145
+ withBranchId(branchId, renderNativeTag);
3146
+ } else {
3147
+ renderNativeTag();
3148
+ }
2887
3149
  write(`</${renderer}>`);
2888
3150
  } else if (content) {
2889
3151
  throw new Error(`Body content is not supported for a "${renderer}" tag.`);
2890
3152
  }
2891
- if (resume) {
3153
+ if (shouldResume) {
2892
3154
  write(
2893
3155
  state.mark(
2894
3156
  "|" /* BranchSingleNode */,
@@ -2897,25 +3159,33 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, res
2897
3159
  );
2898
3160
  }
2899
3161
  } else {
2900
- if (resume) {
3162
+ if (shouldResume) {
2901
3163
  write(state.mark("[" /* BranchStart */, branchId + ""));
2902
3164
  }
2903
- result = withBranchId(branchId, () => {
3165
+ const render2 = () => {
2904
3166
  if (renderer) {
3167
+ if (isTemplate(renderer)) {
3168
+ const input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
3169
+ return renderer(
3170
+ content ? { ...input, content } : input,
3171
+ shouldResume
3172
+ );
3173
+ }
2905
3174
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(
2906
3175
  content ? { ...inputOrArgs, content } : inputOrArgs
2907
3176
  );
2908
3177
  } else if (content) {
2909
3178
  return content();
2910
3179
  }
2911
- });
2912
- if (resume) {
3180
+ };
3181
+ result = shouldResume ? withBranchId(branchId, render2) : render2();
3182
+ if (shouldResume) {
2913
3183
  write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
2914
3184
  }
2915
3185
  }
2916
3186
  const rendered = peekNextScopeId() !== branchId;
2917
3187
  if (rendered) {
2918
- if (resume) {
3188
+ if (shouldResume) {
2919
3189
  writeScope(scopeId, {
2920
3190
  ["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
2921
3191
  ["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
@@ -3010,7 +3280,11 @@ var compat = {
3010
3280
  writeScope(scopeId, { m5c: component.id });
3011
3281
  writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
3012
3282
  }
3013
- renderer(normalizedInput);
3283
+ if (isTemplate(renderer) && willRerender) {
3284
+ renderer(normalizedInput, 1);
3285
+ } else {
3286
+ renderer(normalizedInput);
3287
+ }
3014
3288
  });
3015
3289
  const asyncOut = classAPIOut.beginAsync();
3016
3290
  queueMicrotask(
@@ -3061,216 +3335,6 @@ function forToBy2(by, index) {
3061
3335
  }
3062
3336
  return index;
3063
3337
  }
3064
-
3065
- // src/html/template.ts
3066
- var createTemplate = (templateId, renderer) => {
3067
- renderer.render = render;
3068
- renderer._ = renderer;
3069
- if (true) {
3070
- renderer.mount = () => {
3071
- throw new Error(
3072
- `mount() is not implemented for the HTML compilation of a Marko template`
3073
- );
3074
- };
3075
- }
3076
- return registerContent(templateId, renderer);
3077
- };
3078
- function render(input = {}) {
3079
- let { $global: $global2 } = input;
3080
- if ($global2) {
3081
- ({ $global: $global2, ...input } = input);
3082
- $global2 = {
3083
- runtimeId: DEFAULT_RUNTIME_ID,
3084
- renderId: DEFAULT_RENDER_ID,
3085
- ...$global2
3086
- };
3087
- } else {
3088
- $global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
3089
- }
3090
- const head = new Chunk(
3091
- new Boundary(new State2($global2), $global2.signal),
3092
- null,
3093
- null
3094
- );
3095
- head.render(this, input);
3096
- return new ServerRendered(head);
3097
- }
3098
- var ServerRendered = class {
3099
- #head;
3100
- #cachedPromise = null;
3101
- constructor(head) {
3102
- this.#head = head;
3103
- }
3104
- [Symbol.asyncIterator]() {
3105
- let resolve;
3106
- let reject;
3107
- let value = "";
3108
- let done = false;
3109
- let aborted = false;
3110
- let reason;
3111
- const boundary = this.#read(
3112
- (html) => {
3113
- value += html;
3114
- if (resolve) {
3115
- resolve({ value, done });
3116
- value = "";
3117
- }
3118
- },
3119
- (err) => {
3120
- aborted = true;
3121
- reason = err;
3122
- if (reject) {
3123
- reject(err);
3124
- }
3125
- },
3126
- () => {
3127
- done = true;
3128
- if (resolve) {
3129
- resolve({ value, done: !value });
3130
- value = "";
3131
- }
3132
- }
3133
- );
3134
- return {
3135
- next() {
3136
- if (aborted) {
3137
- return Promise.reject(reason);
3138
- } else if (value) {
3139
- const result = { value, done: false };
3140
- value = "";
3141
- return Promise.resolve(result);
3142
- } else if (done) {
3143
- return Promise.resolve({ value: "", done });
3144
- } else {
3145
- return new Promise(exec);
3146
- }
3147
- },
3148
- throw(error) {
3149
- if (!(done || aborted)) {
3150
- boundary?.abort(error);
3151
- }
3152
- return Promise.resolve({ value: "", done: true });
3153
- },
3154
- return(value2) {
3155
- if (!(done || aborted)) {
3156
- boundary?.abort(new Error("Iterator returned before consumed."));
3157
- }
3158
- return Promise.resolve({ value: value2, done: true });
3159
- }
3160
- };
3161
- function exec(_resolve, _reject) {
3162
- resolve = _resolve;
3163
- reject = _reject;
3164
- }
3165
- }
3166
- pipe(stream) {
3167
- this.#read(
3168
- (html) => {
3169
- stream.write(html);
3170
- },
3171
- (err) => {
3172
- const socket = "socket" in stream && stream.socket;
3173
- if (socket && typeof socket.destroySoon === "function") {
3174
- socket.destroySoon();
3175
- }
3176
- if (!stream.emit?.("error", err)) {
3177
- throw err;
3178
- }
3179
- },
3180
- () => {
3181
- stream.end();
3182
- }
3183
- );
3184
- }
3185
- toReadable() {
3186
- const encoder = new TextEncoder();
3187
- return new ReadableStream({
3188
- start: (ctrl) => {
3189
- this.#read(
3190
- (html) => {
3191
- ctrl.enqueue(encoder.encode(html));
3192
- },
3193
- (err) => {
3194
- ctrl.error(err);
3195
- },
3196
- () => {
3197
- ctrl.close();
3198
- }
3199
- );
3200
- }
3201
- });
3202
- }
3203
- then(onfulfilled, onrejected) {
3204
- return this.#promise().then(onfulfilled, onrejected);
3205
- }
3206
- catch(onrejected) {
3207
- return this.#promise().catch(onrejected);
3208
- }
3209
- finally(onfinally) {
3210
- return this.#promise().finally(onfinally);
3211
- }
3212
- #promise() {
3213
- return this.#cachedPromise ||= new Promise((resolve, reject) => {
3214
- const head = this.#head;
3215
- this.#head = null;
3216
- if (!head) {
3217
- return reject(new Error("Cannot read from a consumed render result"));
3218
- }
3219
- const { boundary } = head;
3220
- (boundary.onNext = () => {
3221
- if (boundary.signal.aborted) {
3222
- boundary.onNext = NOOP2;
3223
- reject(boundary.signal.reason);
3224
- } else if (boundary.done) {
3225
- resolve(head.consume().flushHTML());
3226
- }
3227
- })();
3228
- });
3229
- }
3230
- #read(onWrite, onAbort, onClose) {
3231
- let tick2 = true;
3232
- let head = this.#head;
3233
- this.#head = null;
3234
- if (!head) {
3235
- onAbort(new Error("Cannot read from a consumed render result"));
3236
- return;
3237
- }
3238
- const { boundary } = head;
3239
- const onNext = boundary.onNext = (write2) => {
3240
- if (boundary.signal.aborted) {
3241
- if (!tick2) offTick(onNext);
3242
- boundary.onNext = NOOP2;
3243
- onAbort(boundary.signal.reason);
3244
- } else {
3245
- const { done } = boundary;
3246
- if (done || write2) {
3247
- const html = (head = head.consume()).flushHTML();
3248
- if (html) onWrite(html);
3249
- if (done) {
3250
- if (!tick2) offTick(onNext);
3251
- onClose();
3252
- } else {
3253
- tick2 = true;
3254
- }
3255
- } else if (tick2) {
3256
- tick2 = false;
3257
- queueTick(onNext);
3258
- }
3259
- }
3260
- };
3261
- onNext();
3262
- return boundary;
3263
- }
3264
- toString() {
3265
- const head = this.#head;
3266
- this.#head = null;
3267
- if (!head) throw new Error("Cannot read from a consumed render result");
3268
- if (!head.boundary.done) throw new Error("Cannot fork in sync mode");
3269
- return head.consume().flushHTML();
3270
- }
3271
- };
3272
- function NOOP2() {
3273
- }
3274
3338
  // Annotate the CommonJS export names for ESM import in node:
3275
3339
  0 && (module.exports = {
3276
3340
  $global,
@@ -3279,6 +3343,7 @@ function NOOP2() {
3279
3343
  attrTags,
3280
3344
  attrs,
3281
3345
  classAttr,
3346
+ commentSeparator,
3282
3347
  compat,
3283
3348
  controllable_detailsOrDialog_open,
3284
3349
  controllable_input_checked,
@@ -3308,7 +3373,7 @@ function NOOP2() {
3308
3373
  nodeRef,
3309
3374
  optionValueAttr,
3310
3375
  partialAttrs,
3311
- peekNextScope,
3376
+ peekNextScopeId,
3312
3377
  register,
3313
3378
  registerContent,
3314
3379
  resumeClosestBranch,
@@ -3320,6 +3385,8 @@ function NOOP2() {
3320
3385
  resumeSingleNodeForIn,
3321
3386
  resumeSingleNodeForOf,
3322
3387
  resumeSingleNodeForTo,
3388
+ serializeGuard,
3389
+ serializeIf,
3323
3390
  setTagVar,
3324
3391
  styleAttr,
3325
3392
  toString,