marko 6.3.13 → 6.3.15

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.
@@ -854,13 +854,15 @@ function writeUnknownObject(state, val, ref) {
854
854
  case Int32Array:
855
855
  case Uint32Array:
856
856
  case Float32Array:
857
- case Float64Array: return writeTypedArray(state, val, ref);
857
+ case Float64Array:
858
+ case BigInt64Array:
859
+ case BigUint64Array: return writeTypedArray(state, val, ref);
858
860
  case WeakSet: return writeWeakSet(state);
859
861
  case WeakMap: return writeWeakMap(state);
860
862
  case globalThis.URL: return writeURL(state, val);
861
863
  case globalThis.URLSearchParams: return writeURLSearchParams(state, val);
862
864
  case globalThis.Headers: return writeHeaders(state, val);
863
- case globalThis.FormData: return writeFormData(state, val);
865
+ case globalThis.FormData: return writeFormData(state, val, ref);
864
866
  case globalThis.ReadableStream: return writeReadableStream(state, val, ref);
865
867
  case globalThis.Request: return writeRequest(state, val, ref);
866
868
  case globalThis.Response: return writeResponse(state, val, ref);
@@ -1052,14 +1054,18 @@ function writeURLSearchParams(state, val) {
1052
1054
  return true;
1053
1055
  }
1054
1056
  function writeHeaders(state, val) {
1055
- const headers = stringEntriesToProps(val);
1056
- state.buf.push("new Headers" + (headers ? "({" + headers + "})" : ""));
1057
+ const headers = stringEntriesToHeadersInit(val);
1058
+ state.buf.push("new Headers" + (headers ? "(" + headers + ")" : ""));
1057
1059
  return true;
1058
1060
  }
1059
- function writeFormData(state, val) {
1061
+ function writeFormData(state, val, ref) {
1060
1062
  let sep = "[";
1061
1063
  let valStr = "";
1062
- for (const [key, value] of val) if (typeof value === "string") {
1064
+ for (const [key, value] of val) {
1065
+ if (typeof value !== "string") {
1066
+ throwUnserializable(state, value, ref, key);
1067
+ return false;
1068
+ }
1063
1069
  valStr += sep + quote(key, 0) + "," + quote(value, 0);
1064
1070
  sep = ",";
1065
1071
  }
@@ -1089,10 +1095,10 @@ function writeRequest(state, val, ref) {
1089
1095
  options += sep + "credentials:" + quote(val.credentials, 0);
1090
1096
  sep = ",";
1091
1097
  }
1092
- const headers = stringEntriesToProps(val.headers);
1098
+ const headers = stringEntriesToHeadersInit(val.headers);
1093
1099
  state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1094
1100
  if (headers) {
1095
- options += sep + "headers:{" + headers + "}";
1101
+ options += sep + "headers:" + headers;
1096
1102
  sep = ",";
1097
1103
  }
1098
1104
  if (val.integrity) {
@@ -1134,9 +1140,9 @@ function writeResponse(state, val, ref) {
1134
1140
  options += sep + "statusText:" + quote(val.statusText, 0);
1135
1141
  sep = ",";
1136
1142
  }
1137
- const headers = stringEntriesToProps(val.headers);
1143
+ const headers = stringEntriesToHeadersInit(val.headers);
1138
1144
  state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1139
- if (headers) options += sep + "headers:{" + headers + "}";
1145
+ if (headers) options += sep + "headers:" + headers;
1140
1146
  if (!val.body || val.bodyUsed) state.buf.push("new Response" + (options ? "(null,{" + options + "})" : ""));
1141
1147
  else {
1142
1148
  state.buf.push("new Response(");
@@ -1469,27 +1475,40 @@ function nextId(state) {
1469
1475
  function hasSymbolIterator(value) {
1470
1476
  return Symbol.iterator in value;
1471
1477
  }
1472
- function stringEntriesToProps(entries) {
1478
+ function stringEntriesToHeadersInit(entries) {
1479
+ const list = [...entries];
1480
+ if (!list.length) return "";
1481
+ let duplicate = false;
1482
+ const seen = /* @__PURE__ */ new Set();
1483
+ for (const [key] of list) {
1484
+ if (seen.has(key)) {
1485
+ duplicate = true;
1486
+ break;
1487
+ }
1488
+ seen.add(key);
1489
+ }
1473
1490
  let result = "";
1474
1491
  let sep = "";
1475
- for (const [key, value] of entries) {
1476
- result += sep + toObjectKey(key) + ":" + quote(value, 0);
1492
+ for (const [key, value] of list) {
1493
+ result += duplicate ? sep + "[" + quote(key, 0) + "," + quote(value, 0) + "]" : sep + toObjectKey(key) + ":" + quote(value, 0);
1477
1494
  sep = ",";
1478
1495
  }
1479
- return result;
1496
+ return duplicate ? "[" + result + "]" : "{" + result + "}";
1480
1497
  }
1481
1498
  function typedArrayToInitString(view) {
1499
+ const suffix = typeof view[0] === "bigint" ? "n" : "";
1482
1500
  let result = "[";
1483
1501
  let sep = "";
1484
1502
  for (let i = 0; i < view.length; i++) {
1485
- result += sep + view[i];
1503
+ result += sep + view[i] + suffix;
1486
1504
  sep = ",";
1487
1505
  }
1488
1506
  result += "]";
1489
1507
  return result;
1490
1508
  }
1491
1509
  function hasOnlyZeros(typedArray) {
1492
- for (let i = 0; i < typedArray.length; i++) if (typedArray[i] !== 0) return false;
1510
+ const zero = typeof typedArray[0] === "bigint" ? 0n : 0;
1511
+ for (let i = 0; i < typedArray.length; i++) if (typedArray[i] !== zero) return false;
1493
1512
  return true;
1494
1513
  }
1495
1514
  function patchIteratorNext(proto) {
@@ -1645,7 +1664,6 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
1645
1664
  //#endregion
1646
1665
  //#region src/html/writer.ts
1647
1666
  let $chunk;
1648
- const NOOP$2 = () => {};
1649
1667
  function getChunk() {
1650
1668
  return $chunk;
1651
1669
  }
@@ -1658,54 +1676,22 @@ function getState() {
1658
1676
  function getScopeId(scope) {
1659
1677
  return scope[K_SCOPE_ID];
1660
1678
  }
1661
- function _html(html) {
1662
- $chunk.writeHTML(html);
1663
- }
1664
- function writeScript(script) {
1665
- $chunk.writeScript(script);
1679
+ function getScopeById(scopeId) {
1680
+ if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
1666
1681
  }
1667
- function writeWaitReady(readyId, renderer, input) {
1668
- const chunk = $chunk;
1669
- const { boundary } = chunk;
1670
- const body = new Chunk(boundary, null, chunk.context, {
1671
- readyId,
1672
- parent: chunk.serializeState,
1673
- resumes: "",
1674
- writeScopes: {},
1675
- flushScopes: false
1676
- });
1677
- const bodyEnd = body.render(renderer, input);
1678
- if (body === bodyEnd) {
1679
- chunk.writeHTML(body.html);
1680
- body.deferOwnReady();
1681
- chunk.deferredReady = push(chunk.deferredReady, body);
1682
- } else {
1683
- bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
1684
- chunk.next = body;
1685
- }
1682
+ function $global() {
1683
+ return $chunk.boundary.state.$global;
1686
1684
  }
1687
- function _script(scopeId, registryId) {
1688
- if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
1689
- $chunk.boundary.state.needsMainRuntime = true;
1690
- $chunk.writeEffect(scopeId, registryId);
1685
+ function _id() {
1686
+ const state = $chunk.boundary.state;
1687
+ const { $global } = state;
1688
+ return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
1691
1689
  }
1692
- function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1693
- const shouldResume = serializeReason !== 0;
1694
- const render = normalizeServerRender(content);
1695
- const branchId = _peek_scope_id();
1696
- if (render) if (shouldResume) withBranchId(branchId, render);
1697
- else render();
1698
- if (_peek_scope_id() !== branchId) {
1699
- if (shouldResume) writeScope(scopeId, {
1700
- ["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
1701
- ["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
1702
- });
1703
- } else _scope_id();
1690
+ function _scope_id() {
1691
+ return $chunk.boundary.state.scopeId++;
1704
1692
  }
1705
- function normalizeServerRender(value) {
1706
- const renderer = normalizeDynamicRenderer(value);
1707
- if (renderer) if (typeof renderer === "function") return renderer;
1708
- else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1693
+ function _peek_scope_id() {
1694
+ return $chunk.boundary.state.scopeId;
1709
1695
  }
1710
1696
  const kPendingContexts = Symbol("Pending Contexts");
1711
1697
  function withContext(key, value, cb, cbValue) {
@@ -1720,49 +1706,41 @@ function withContext(key, value, cb, cbValue) {
1720
1706
  ctx[key] = prev;
1721
1707
  }
1722
1708
  }
1723
- function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
1724
- writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
1725
- const childScope = writeScopePassive(childScopeId, { ["#TagVariable"]: _resume({}, registryId, parentScopeId) });
1726
- if (nodeAccessor !== void 0) writeScope(parentScopeId, { ["BranchScopes:" + nodeAccessor]: childScope });
1727
- }
1728
- function writeScopePassive(scopeId, partialScope) {
1729
- const target = $chunk.serializeState;
1730
- const scope = _scope_with_id(scopeId);
1731
- const passive = target.passiveScopes ||= {};
1732
- Object.assign(scope, partialScope);
1733
- passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
1734
- return scope;
1709
+ const kBranchId = Symbol("Branch Id");
1710
+ const kIsAsync = Symbol("Is Async");
1711
+ function isInResumedBranch() {
1712
+ return $chunk?.context?.[kBranchId] !== void 0;
1735
1713
  }
1736
- function _resume(val, id, scopeId) {
1737
- return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
1714
+ function withBranchId(branchId, cb) {
1715
+ return withContext(kBranchId, branchId, cb);
1738
1716
  }
1739
- function _id() {
1740
- const state = $chunk.boundary.state;
1741
- const { $global } = state;
1742
- return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
1717
+ function withIsAsync(cb, value) {
1718
+ return withContext(kIsAsync, true, cb, value);
1743
1719
  }
1744
- function _scope_id() {
1745
- return $chunk.boundary.state.scopeId++;
1720
+ function _html(html) {
1721
+ $chunk.writeHTML(html);
1746
1722
  }
1747
- function _peek_scope_id() {
1748
- return $chunk.boundary.state.scopeId;
1723
+ function writeScript(script) {
1724
+ $chunk.writeScript(script);
1749
1725
  }
1750
- function getScopeById(scopeId) {
1751
- if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
1726
+ function _script(scopeId, registryId) {
1727
+ if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
1728
+ $chunk.boundary.state.needsMainRuntime = true;
1729
+ $chunk.writeEffect(scopeId, registryId);
1752
1730
  }
1753
- function _set_serialize_reason(reason) {
1754
- $chunk.boundary.state.serializeReason = reason;
1731
+ function _trailers(html) {
1732
+ $chunk.boundary.state.trailerHTML += html;
1755
1733
  }
1756
- function _scope_reason() {
1757
- const reason = $chunk.boundary.state.serializeReason;
1758
- $chunk.boundary.state.serializeReason = void 0;
1759
- return reason;
1734
+ function _resume(val, id, scopeId) {
1735
+ return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
1760
1736
  }
1761
- function _serialize_if(condition, key) {
1762
- return condition && (condition === 1 || (typeof condition === "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
1737
+ function _el(scopeId, id) {
1738
+ return _resume(() => _el_read_error(), id, scopeId);
1763
1739
  }
1764
- function _serialize_guard(condition, key) {
1765
- return _serialize_if(condition, key) || 0;
1740
+ function _hoist(scopeId, id) {
1741
+ const getter = () => _hoist_read_error();
1742
+ getter[Symbol.iterator] = _hoist_read_error;
1743
+ return _resume(getter, id, scopeId);
1766
1744
  }
1767
1745
  function _el_resume(scopeId, accessor, shouldResume) {
1768
1746
  if (shouldResume === 0) return "";
@@ -1773,28 +1751,51 @@ function _el_resume(scopeId, accessor, shouldResume) {
1773
1751
  function _sep(shouldResume) {
1774
1752
  return shouldResume === 0 ? "" : "<!>";
1775
1753
  }
1776
- function _el(scopeId, id) {
1777
- return _resume(() => _el_read_error(), id, scopeId);
1778
- }
1779
- function _hoist(scopeId, id) {
1780
- const getter = () => _hoist_read_error();
1781
- getter[Symbol.iterator] = _hoist_read_error;
1782
- return _resume(getter, id, scopeId);
1783
- }
1784
1754
  function _resume_branch(scopeId) {
1785
1755
  const branchId = $chunk.context?.[kBranchId];
1786
1756
  if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { ["#ClosestBranchId"]: branchId });
1787
1757
  }
1788
- const kBranchId = Symbol("Branch Id");
1789
- const kIsAsync = Symbol("Is Async");
1790
- function isInResumedBranch() {
1791
- return $chunk?.context?.[kBranchId] !== void 0;
1758
+ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
1759
+ const shouldResume = serializeReason !== 0;
1760
+ const render = normalizeServerRender(content);
1761
+ const branchId = _peek_scope_id();
1762
+ if (render) if (shouldResume) withBranchId(branchId, render);
1763
+ else render();
1764
+ if (_peek_scope_id() !== branchId) {
1765
+ if (shouldResume) writeScope(scopeId, {
1766
+ ["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
1767
+ ["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
1768
+ });
1769
+ } else _scope_id();
1792
1770
  }
1793
- function withBranchId(branchId, cb) {
1794
- return withContext(kBranchId, branchId, cb);
1771
+ function normalizeServerRender(value) {
1772
+ const renderer = normalizeDynamicRenderer(value);
1773
+ if (renderer) if (typeof renderer === "function") return renderer;
1774
+ else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
1795
1775
  }
1796
- function withIsAsync(cb, value) {
1797
- return withContext(kIsAsync, true, cb, value);
1776
+ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
1777
+ writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
1778
+ const childScope = writeScopePassive(childScopeId, { ["#TagVariable"]: _resume({}, registryId, parentScopeId) });
1779
+ if (nodeAccessor !== void 0) writeScope(parentScopeId, { ["BranchScopes:" + nodeAccessor]: childScope });
1780
+ }
1781
+ function writeScopePassive(scopeId, partialScope) {
1782
+ const target = $chunk.serializeState;
1783
+ const scope = _scope_with_id(scopeId);
1784
+ const passive = target.passiveScopes ||= {};
1785
+ Object.assign(scope, partialScope);
1786
+ passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
1787
+ return scope;
1788
+ }
1789
+ function _show_start(display, mark) {
1790
+ if (display) {
1791
+ if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
1792
+ } else $chunk.writeHTML("<t hidden>");
1793
+ }
1794
+ function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1795
+ const branchId = _scope_id();
1796
+ const wrap = !display;
1797
+ if (wrap) $chunk.writeHTML("</t>");
1798
+ writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
1798
1799
  }
1799
1800
  function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1800
1801
  forBranches(by, (each) => each ? forOf(list, (item, index) => {
@@ -1881,17 +1882,6 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
1881
1882
  } else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
1882
1883
  else $chunk.writeHTML(endTag);
1883
1884
  }
1884
- function _show_start(display, mark) {
1885
- if (display) {
1886
- if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
1887
- } else $chunk.writeHTML("<t hidden>");
1888
- }
1889
- function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
1890
- const branchId = _scope_id();
1891
- const wrap = !display;
1892
- if (wrap) $chunk.writeHTML("</t>");
1893
- writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
1894
- }
1895
1885
  let writeScope = (scopeId, partialScope) => {
1896
1886
  const { state } = $chunk.boundary;
1897
1887
  const target = $chunk.serializeState;
@@ -1921,8 +1911,47 @@ function scopeWithId(state, scopeId) {
1921
1911
  if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
1922
1912
  return scope;
1923
1913
  }
1924
- function $global() {
1925
- return $chunk.boundary.state.$global;
1914
+ function _subscribe(subscribers, scope) {
1915
+ if (subscribers) {
1916
+ const { serializer } = $chunk.boundary.state;
1917
+ if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
1918
+ else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
1919
+ }
1920
+ return scope;
1921
+ }
1922
+ function _set_serialize_reason(reason) {
1923
+ $chunk.boundary.state.serializeReason = reason;
1924
+ }
1925
+ function _scope_reason() {
1926
+ const reason = $chunk.boundary.state.serializeReason;
1927
+ $chunk.boundary.state.serializeReason = void 0;
1928
+ return reason;
1929
+ }
1930
+ function _serialize_if(condition, key) {
1931
+ return condition && (condition === 1 || (typeof condition === "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
1932
+ }
1933
+ function _serialize_guard(condition, key) {
1934
+ return _serialize_if(condition, key) || 0;
1935
+ }
1936
+ function writeWaitReady(readyId, renderer, input) {
1937
+ const chunk = $chunk;
1938
+ const { boundary } = chunk;
1939
+ const body = new Chunk(boundary, null, chunk.context, {
1940
+ readyId,
1941
+ parent: chunk.serializeState,
1942
+ resumes: "",
1943
+ writeScopes: {},
1944
+ flushScopes: false
1945
+ });
1946
+ const bodyEnd = body.render(renderer, input);
1947
+ if (body === bodyEnd) {
1948
+ chunk.writeHTML(body.html);
1949
+ body.deferOwnReady();
1950
+ chunk.deferredReady = push(chunk.deferredReady, body);
1951
+ } else {
1952
+ bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
1953
+ chunk.next = body;
1954
+ }
1926
1955
  }
1927
1956
  function _await(scopeId, accessor, promise, content, serializeMarker) {
1928
1957
  const resumeMarker = serializeMarker !== 0;
@@ -2046,6 +2075,7 @@ function tryCatch(content, catchContent) {
2046
2075
  else boundary.onNext();
2047
2076
  };
2048
2077
  }
2078
+ const NOOP$2 = () => {};
2049
2079
  var State = class {
2050
2080
  $global;
2051
2081
  tagId = 1;
@@ -2471,8 +2501,22 @@ function depsMarker(deps) {
2471
2501
  }
2472
2502
  return marker;
2473
2503
  }
2474
- function _trailers(html) {
2475
- $chunk.boundary.state.trailerHTML += html;
2504
+ function getFilteredGlobals($global) {
2505
+ if (!$global) return 0;
2506
+ const serializedGlobals = $global.serializedGlobals;
2507
+ if (!serializedGlobals) return 0;
2508
+ let filtered = 0;
2509
+ if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
2510
+ const value = $global[key];
2511
+ if (value !== void 0) if (filtered) filtered[key] = value;
2512
+ else filtered = { [key]: value };
2513
+ }
2514
+ else for (const key in serializedGlobals) if (serializedGlobals[key]) {
2515
+ const value = $global[key];
2516
+ if (value !== void 0) if (filtered) filtered[key] = value;
2517
+ else filtered = { [key]: value };
2518
+ }
2519
+ return filtered;
2476
2520
  }
2477
2521
  function concatEffects(a, b) {
2478
2522
  return a ? b ? a + " " + b : a : b;
@@ -2500,31 +2544,6 @@ function flushTickQueue() {
2500
2544
  tickQueue = void 0;
2501
2545
  for (const cb of queue) cb(true);
2502
2546
  }
2503
- function getFilteredGlobals($global) {
2504
- if (!$global) return 0;
2505
- const serializedGlobals = $global.serializedGlobals;
2506
- if (!serializedGlobals) return 0;
2507
- let filtered = 0;
2508
- if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
2509
- const value = $global[key];
2510
- if (value !== void 0) if (filtered) filtered[key] = value;
2511
- else filtered = { [key]: value };
2512
- }
2513
- else for (const key in serializedGlobals) if (serializedGlobals[key]) {
2514
- const value = $global[key];
2515
- if (value !== void 0) if (filtered) filtered[key] = value;
2516
- else filtered = { [key]: value };
2517
- }
2518
- return filtered;
2519
- }
2520
- function _subscribe(subscribers, scope) {
2521
- if (subscribers) {
2522
- const { serializer } = $chunk.boundary.state;
2523
- if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
2524
- else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
2525
- }
2526
- return scope;
2527
- }
2528
2547
  //#endregion
2529
2548
  //#region src/html/attrs.ts
2530
2549
  function _attr_class(value) {
@@ -2749,27 +2768,30 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
2749
2768
  assertValidTagName(renderer);
2750
2769
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2751
2770
  rendered = true;
2752
- _scope_id();
2753
- _html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
2754
- if (!voidElementsReg.test(renderer)) {
2755
- const renderContent = content || normalizeDynamicRenderer(input.content);
2756
- if (renderer === "textarea") {
2757
- if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
2758
- _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
2759
- } else if (renderContent) {
2760
- if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2761
- if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
2762
- else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
2771
+ const renderNative = () => {
2772
+ _scope_id();
2773
+ _html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
2774
+ if (!voidElementsReg.test(renderer)) {
2775
+ const renderContent = content || normalizeDynamicRenderer(input.content);
2776
+ if (renderer === "textarea") {
2777
+ if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
2778
+ _html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
2779
+ } else if (renderContent) {
2780
+ if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2781
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
2782
+ else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
2783
+ }
2784
+ _html(`</${renderer}>`);
2785
+ } else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2786
+ const childScope = getScopeById(branchId);
2787
+ const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
2788
+ if (needsScript) {
2789
+ writeScope(branchId, { ["#Renderer"]: renderer });
2790
+ _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
2763
2791
  }
2764
- _html(`</${renderer}>`);
2765
- } else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
2766
- const childScope = getScopeById(branchId);
2767
- const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
2768
- if (needsScript) {
2769
- writeScope(branchId, { ["#Renderer"]: renderer });
2770
- _script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
2771
- }
2772
- if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
2792
+ if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
2793
+ };
2794
+ renderNative();
2773
2795
  } else {
2774
2796
  if (shouldResume) _html(state.mark("[", ""));
2775
2797
  const render = () => {
@@ -2979,9 +3001,11 @@ var ServerRendered = class {
2979
3001
  boundary.onNext = NOOP$1;
2980
3002
  reject(boundary.signal.reason);
2981
3003
  break;
2982
- case 0:
2983
- resolve(head.consume().flushHTML());
3004
+ case 0: {
3005
+ const consumed = head.consume();
3006
+ if (!boundary.signal.aborted) resolve(consumed.flushHTML());
2984
3007
  break;
3008
+ }
2985
3009
  }
2986
3010
  })();
2987
3011
  });
@@ -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;