@solidjs/web 2.0.0-rc.13 → 2.0.0-rc.14

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.
Files changed (57) hide show
  1. package/dist/server.dev.js +200 -73
  2. package/dist/server.js +182 -59
  3. package/dist/server.observe.js +183 -60
  4. package/dist/web.dev.js +70 -35
  5. package/dist/web.js +43 -31
  6. package/dist/web.observe.js +43 -33
  7. package/frames/dist/assets.js +92 -0
  8. package/frames/dist/bind.dev.js +326 -0
  9. package/frames/dist/bind.js +295 -0
  10. package/frames/dist/client.dev.js +605 -1086
  11. package/frames/dist/client.js +572 -1066
  12. package/frames/dist/client.observe.js +571 -1066
  13. package/frames/dist/regions.js +130 -0
  14. package/frames/dist/server.dev.js +339 -177
  15. package/frames/dist/server.js +335 -173
  16. package/frames/dist/server.observe.js +335 -173
  17. package/frames/dist/trace.js +42 -0
  18. package/frames/dist/wire.js +133 -0
  19. package/package.json +28 -2
  20. package/performance-tracks/dist/performance-tracks.dev.js +2 -1
  21. package/performance-tracks/dist/performance-tracks.observe.js +2 -1
  22. package/performance-tracks/types/index.d.ts +8 -6
  23. package/serialization/dist/decode.js +37 -8
  24. package/serialization/dist/serialization.js +39 -10
  25. package/serialization/types/serializer-decode.d.ts +24 -2
  26. package/server-functions/dist/client.dev.js +99 -61
  27. package/server-functions/dist/client.js +99 -61
  28. package/server-functions/dist/client.observe.js +99 -61
  29. package/server-functions/dist/server.dev.js +87 -50
  30. package/server-functions/dist/server.js +87 -50
  31. package/server-functions/dist/server.observe.js +87 -50
  32. package/skills/server-components/SKILL.md +65 -43
  33. package/types/client.d.ts +20 -0
  34. package/types/constants.d.ts +2 -1
  35. package/types/diagnostics.d.ts +8 -0
  36. package/types/frames/assets-tier.d.ts +78 -0
  37. package/types/frames/bind-tier.d.ts +60 -0
  38. package/types/frames/client.d.ts +37 -3
  39. package/types/frames/frame-client.d.ts +249 -78
  40. package/types/frames/frame-container-plugin.d.ts +2 -2
  41. package/types/frames/frame-sink.d.ts +33 -0
  42. package/types/frames/frame-transport.d.ts +66 -18
  43. package/types/frames/regions-tier.d.ts +45 -0
  44. package/types/frames/serializer-decode.d.ts +24 -2
  45. package/types/frames/server.d.ts +32 -8
  46. package/types/frames/trace-tier.d.ts +2 -0
  47. package/types/frames/wire-tier.d.ts +116 -0
  48. package/types/index.d.ts +38 -0
  49. package/types/index.server.d.ts +9 -0
  50. package/types/jsx.d.ts +1 -1
  51. package/types/observe.d.ts +4 -2
  52. package/types/serializer-decode.d.ts +24 -2
  53. package/types/server-functions/client.d.ts +26 -0
  54. package/types/server-functions/registry.d.ts +4 -1
  55. package/types/server-functions/shared.d.ts +12 -8
  56. package/types/server-mock.d.ts +13 -1
  57. package/types/server.d.ts +34 -8
@@ -1,8 +1,8 @@
1
1
  import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId, untrack, NotReadyError } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
- import { sharedConfig, viewOf, sourceOwners, reportServerError, ssrHandleError, inServerComponentScope, creationStamp, ssrSanitizeError, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
3
+ import { sharedConfig, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
4
4
  export { ssrScope as scope, sharedConfig } from 'solid-js/internal';
5
- import { Feature, createStream, Serializer, getCrossReferenceHeader } from 'seroval';
5
+ import { createStream, Serializer, getCrossReferenceHeader, Feature } from 'seroval';
6
6
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
7
7
 
8
8
  const DOMWithState = {
@@ -59,6 +59,10 @@ function isHttpNavigationTarget(target) {
59
59
  return false;
60
60
  }
61
61
  }
62
+ function isEventName(name) {
63
+ let c;
64
+ return name.startsWith("on") && (c = name.charCodeAt(2)) > 64 && c < 91;
65
+ }
62
66
 
63
67
  const transparentOptions = {
64
68
  transparent: true,
@@ -472,10 +476,10 @@ function isShareableIterable(value) {
472
476
  return false;
473
477
  }
474
478
  }
475
- function materialize(marker) {
479
+ function materialize(marker, claiming) {
476
480
  let value = state.materialized.get(marker.$tr);
477
481
  if (value === undefined) {
478
- value = state.materializeTrace(marker);
482
+ value = state.materializeTrace(marker, claiming);
479
483
  state.materialized.set(marker.$tr, value);
480
484
  if (value !== null && typeof value === "object") state.materializedValues.add(value);
481
485
  }
@@ -533,23 +537,22 @@ setContainerTraceStreamMint(iterable => {
533
537
  })();
534
538
  return stream;
535
539
  });
536
- const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
540
+ const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
537
541
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
538
542
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
539
543
  ContainerTracePlugin]);
540
544
  function resolveSerializerPlugins(customPlugins) {
541
545
  return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
542
546
  }
543
- Feature.RegExp;
544
547
 
545
- const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
548
+ const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
546
549
  const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
547
550
  const HYDRATION_GLOBAL = "_$HY.r";
548
551
  function createSerializer(options) {
549
552
  return new Serializer({
550
553
  ...options,
551
554
  plugins: resolveSerializerPlugins(options.plugins),
552
- disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
555
+ disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
553
556
  });
554
557
  }
555
558
  function createHydrationSerializer({
@@ -768,7 +771,7 @@ function assertServableCookie(name, options) {
768
771
  }
769
772
  }
770
773
  const FLASH_COOKIE = "flash";
771
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
774
+ const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
772
775
  function hasFlashCookie(cookieHeader) {
773
776
  return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
774
777
  }
@@ -780,7 +783,6 @@ const ERROR_HEADER = "X-Server-Function-Error";
780
783
  const BODY_FORMAT_HEADER = "X-Server-Function-Format";
781
784
  const REDIRECT_HEADER = "X-Server-Function-Redirect";
782
785
  const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
783
- new TextEncoder().encode(":\n\n");
784
786
 
785
787
  function emitFinding(finding, subject = getOwner()) {
786
788
  if (OBSERVE === undefined) return;
@@ -1578,7 +1580,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1578
1580
  const t = winner.tags[i];
1579
1581
  const attrs = {};
1580
1582
  for (const name in t.props) {
1581
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1583
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1582
1584
  if (!HEAD_ATTR_NAME.test(name)) {
1583
1585
  headTagInvalid("invalid-attribute", `useHead: ignoring invalid attribute name "${name}"`, name);
1584
1586
  continue;
@@ -1668,7 +1670,7 @@ function nonceAttr(nonce, destination) {
1668
1670
  function renderHeadAttrHtml(props) {
1669
1671
  let attrs = "";
1670
1672
  for (const name in props) {
1671
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1673
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1672
1674
  if (!HEAD_ATTR_NAME.test(name)) {
1673
1675
  headTagInvalid("invalid-attribute", `useHead: ignoring invalid attribute name "${name}"`, name);
1674
1676
  continue;
@@ -1682,7 +1684,7 @@ function renderHeadAttrHtml(props) {
1682
1684
  function headAttrRecord(props, skipRelHref) {
1683
1685
  let attrs = null;
1684
1686
  for (const name in props) {
1685
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1687
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1686
1688
  if ((name === "rel" || name === "href")) continue;
1687
1689
  if (!HEAD_ATTR_NAME.test(name)) continue;
1688
1690
  const v = props[name];
@@ -1709,10 +1711,13 @@ function useHead(tags) {
1709
1711
  ctx.registerHeadTags(tags);
1710
1712
  }
1711
1713
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
1714
+ const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
1715
+ const TAG_START = /^[a-zA-Z]/;
1712
1716
  const tagInfos = /*#__PURE__*/new Map();
1713
1717
  function tagInfo(tag) {
1714
1718
  let info = tagInfos.get(tag);
1715
1719
  if (info === undefined) {
1720
+ if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
1716
1721
  info = {
1717
1722
  open: "<" + tag,
1718
1723
  close: "</" + tag + ">",
@@ -1725,13 +1730,13 @@ function tagInfo(tag) {
1725
1730
  return info;
1726
1731
  }
1727
1732
  const safeAttrNames = /*#__PURE__*/new Set();
1728
- function attrName(prop) {
1729
- if (safeAttrNames.has(prop)) return prop;
1730
- const escaped = escape(prop);
1731
- if (escaped === prop && safeAttrNames.size < 512) safeAttrNames.add(prop);
1732
- return escaped;
1733
+ function isAttrName(prop) {
1734
+ if (safeAttrNames.has(prop)) return true;
1735
+ if (prop === "" || NOT_NAME.test(prop)) return false;
1736
+ if (safeAttrNames.size < 512) safeAttrNames.add(prop);
1737
+ return true;
1733
1738
  }
1734
- const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
1739
+ const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}function $dfe(e,t,k){(t=e.target)&&t.getAttribute&&!t._$dc&&(k=t.getAttribute("data-dfc"))&&(t._$dc=1,$dfc(k))}document.addEventListener("load",$dfe,!0);document.addEventListener("error",$dfe,!0)`;
1735
1740
  const HEAD_SCRIPT = `function $dha(o,i,e,n){for(i=0;i<o.length;i++)e=o[i],"t"==e[0]?((n=document.querySelector("title"))?n.hasAttribute("data-dh")||n.setAttribute("data-dhf",n.textContent):(n=document.createElement("title"),document.head.appendChild(n)),n.textContent=e[1],n.setAttribute("data-dh","title")):"r"==e[0]?$dhr(e[1]):(n=document.createElement(e[2]),Object.keys(e[3]).forEach(function(a){n.setAttribute(a,e[3][a])}),null!=e[4]&&(n.textContent=e[4]),n.setAttribute("data-dh",e[1]),document.head.appendChild(n))}function $dhr(v,l,i){for(l=document.head.querySelectorAll("[data-dh]"),i=0;i<l.length;i++)l[i].getAttribute("data-dh")==v&&l[i].remove()}function $dh(o){_$HY.h?_$HY.h(o):$dha(o)}`;
1736
1741
  function renderToString(code, options = {}) {
1737
1742
  const {
@@ -1826,12 +1831,20 @@ function renderToString(code, options = {}) {
1826
1831
  }
1827
1832
  rendered = true;
1828
1833
  return document;
1834
+ } catch (err) {
1835
+ reportServerError(err, {
1836
+ kind: "render",
1837
+ handling: "failed"
1838
+ }, null, options.onError);
1839
+ throw err;
1829
1840
  } finally {
1830
1841
  if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
1831
1842
  context.trace = undefined;
1832
1843
  if (dispose) dispose();
1833
1844
  }
1834
1845
  }
1846
+ const SHELL_ABANDONED = Symbol();
1847
+ const ABANDON_RENDER = Symbol();
1835
1848
  function renderToStream(code, options = {}) {
1836
1849
  let {
1837
1850
  onCompleteShell,
@@ -1852,6 +1865,7 @@ function renderToStream(code, options = {}) {
1852
1865
  let disconnected = false;
1853
1866
  let failed = false;
1854
1867
  let onFailed;
1868
+ let onDisconnectedBeforeShell;
1855
1869
  const defuse = p => {
1856
1870
  if (p && typeof p.then === "function") p.then(undefined, () => {});
1857
1871
  };
@@ -1870,9 +1884,9 @@ function renderToStream(code, options = {}) {
1870
1884
  complete(sink);
1871
1885
  } : complete;
1872
1886
  };
1873
- const abandon = disconnect => {
1887
+ const abandon = (disconnect, quiet) => {
1874
1888
  if (dead) return;
1875
- if (disconnect) emitFinding({
1889
+ if (disconnect && !quiet) emitFinding({
1876
1890
  code: "SSR_STREAM_ABANDONED",
1877
1891
  kind: "ssr",
1878
1892
  severity: "warn",
@@ -1917,7 +1931,7 @@ function renderToStream(code, options = {}) {
1917
1931
  if (!disconnect) {
1918
1932
  failed = true;
1919
1933
  onFailed && onFailed(sink);
1920
- }
1934
+ } else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
1921
1935
  };
1922
1936
  const failRender = err => {
1923
1937
  reportServerError(err, {
@@ -2044,10 +2058,10 @@ function renderToStream(code, options = {}) {
2044
2058
  const styleAttr = nonceAttr(nonce, "style");
2045
2059
  emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
2046
2060
  writeTasks();
2061
+ buffer.write(`<template id="${key}">${value}</template>`);
2047
2062
  for (const entry of styles.links) {
2048
- buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">` : `<link${entry.attrHtml}${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
2063
+ buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} data-dfc="${key}">` : `<link${entry.attrHtml}${styleAttr} data-dfc="${key}">`);
2049
2064
  }
2050
- buffer.write(`<template id="${key}">${value}</template>`);
2051
2065
  } else {
2052
2066
  buffer.write(`<template id="${key}">${value}</template>`);
2053
2067
  if (!deferActivation) {
@@ -2089,7 +2103,7 @@ function renderToStream(code, options = {}) {
2089
2103
  };
2090
2104
  let holds = 0;
2091
2105
  const flushEnd = () => {
2092
- if (!registry.size && !holds) {
2106
+ if (!registry.size && !holds && !rootHoles) {
2093
2107
  serializeRootAssets();
2094
2108
  queue(() => queue(() => {
2095
2109
  if (context.live.end) {
@@ -2231,6 +2245,12 @@ function renderToStream(code, options = {}) {
2231
2245
  }
2232
2246
  let rootHoles = null;
2233
2247
  let nextHoleId = 0;
2248
+ let parkedInlines = null;
2249
+ function inlineFragment(key, value) {
2250
+ if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
2251
+ (parkedInlines ||= new Map()).set(key, value);
2252
+ } else html = replacePlaceholder(html, key, value);
2253
+ }
2234
2254
  let buffer = {
2235
2255
  write(payload) {
2236
2256
  tmp += payload;
@@ -2359,11 +2379,16 @@ function renderToStream(code, options = {}) {
2359
2379
  });
2360
2380
  if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
2361
2381
  }
2362
- return (value, error) => {
2382
+ return (value, error, escaped) => {
2363
2383
  if (registry.has(key)) {
2364
2384
  const item = registry.get(key);
2365
2385
  registry.delete(key);
2366
2386
  if (error) abandonSubtree(key, error);
2387
+ if (error && escaped) {
2388
+ const wire = ssrSanitizeError(error, null);
2389
+ const message = wire instanceof Error ? wire.message : String(wire);
2390
+ if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
2391
+ }
2367
2392
  if (item.children && !error) {
2368
2393
  for (const k in item.children) {
2369
2394
  value = replacePlaceholder(value, k, item.children[k]);
@@ -2383,7 +2408,7 @@ function renderToStream(code, options = {}) {
2383
2408
  if (!completed) {
2384
2409
  if (error) dropHeadBoundary(headRegistry, key);
2385
2410
  if (!firstFlushed) {
2386
- queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
2411
+ queue(() => inlineFragment(key, value !== undefined ? value : ""));
2387
2412
  serializeFragmentAssets(key, tracking.boundaryModules, context);
2388
2413
  item.resolve(error);
2389
2414
  } else {
@@ -2427,7 +2452,7 @@ function renderToStream(code, options = {}) {
2427
2452
  registerEntryAssets(manifest);
2428
2453
  context.writer = createHydrationWriter(context, () => !completed);
2429
2454
  const signal = options.signal;
2430
- const onAbort = signal ? () => abandon("signal") : undefined;
2455
+ const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
2431
2456
  let html = createRoot(d => {
2432
2457
  dispose = () => {
2433
2458
  context.trace = undefined;
@@ -2436,7 +2461,16 @@ function renderToStream(code, options = {}) {
2436
2461
  };
2437
2462
  rootOwner = claimRenderRoot(context);
2438
2463
  if (requestEvent) claimEventRender(requestEvent, context);
2439
- const res = resolveSSRNode(escape(code()));
2464
+ let res;
2465
+ try {
2466
+ res = resolveSSRNode(escape(code()));
2467
+ } catch (err) {
2468
+ reportServerError(err, {
2469
+ kind: "render",
2470
+ handling: "failed"
2471
+ }, null, options.onError);
2472
+ throw err;
2473
+ }
2440
2474
  if (!res.h.length) return res.t[0];
2441
2475
  rootHoles = [];
2442
2476
  let out = res.t[0];
@@ -2483,6 +2517,13 @@ function renderToStream(code, options = {}) {
2483
2517
  for (const p of res.p) blockingPromises.add(p);
2484
2518
  }
2485
2519
  }
2520
+ if (parkedInlines) {
2521
+ for (const [key, value] of parkedInlines) {
2522
+ if (!html.includes(`<template id="pl-${key}">`)) continue;
2523
+ html = replacePlaceholder(html, key, value);
2524
+ parkedInlines.delete(key);
2525
+ }
2526
+ }
2486
2527
  if (pending.length) {
2487
2528
  rootHoles = pending;
2488
2529
  return false;
@@ -2644,11 +2685,16 @@ function renderToStream(code, options = {}) {
2644
2685
  },
2645
2686
  pipe(w) {
2646
2687
  claimConsumer("pipe");
2688
+ const abandoned = w[SHELL_ABANDONED];
2647
2689
  onFailure(sink => {
2648
2690
  try {
2649
- sink ? sink.end() : w.end();
2691
+ sink ? sink.end() : abandoned ? abandoned() : w.end();
2650
2692
  } catch (_) {}
2651
2693
  });
2694
+ if (abandoned) {
2695
+ w[ABANDON_RENDER] = abandon;
2696
+ if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
2697
+ }
2652
2698
  function flush() {
2653
2699
  allSettled(blockingPromises).then(awaited => {
2654
2700
  scheduleFlush(() => {
@@ -3388,6 +3434,14 @@ function ssrStyleProperty(name, value) {
3388
3434
  if (isSlotValue(value)) value = slotValueInline("style", value);
3389
3435
  return value != null ? name + value : "";
3390
3436
  }
3437
+ function ssrStyleProperties(...entries) {
3438
+ let result = "";
3439
+ for (let i = 0; i < entries.length; i += 2) {
3440
+ const entry = ssrStyleProperty(entries[i], entries[i + 1]);
3441
+ if (entry) result = result ? result + ";" + entry : entry;
3442
+ }
3443
+ return result;
3444
+ }
3391
3445
  function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3392
3446
  const hk = needsId ? ssrHydrationKey() : "";
3393
3447
  if (typeof props === "function") props = props();
@@ -3427,6 +3481,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3427
3481
  const skipChildren = info.isVoid;
3428
3482
  let result = info.open + hk;
3429
3483
  let behaviors = null;
3484
+ let childOwner = null;
3430
3485
  const last = sources === null ? 0 : sources.length - 1;
3431
3486
  let keysOf = null;
3432
3487
  if (sources !== null) {
@@ -3449,19 +3504,21 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3449
3504
  continue;
3450
3505
  }
3451
3506
  if (ChildProperties.has(prop)) {
3452
- if (children === undefined && !skipChildren) children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
3507
+ if (children === undefined && childOwner === null && !skipChildren) {
3508
+ if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
3509
+ }
3453
3510
  continue;
3454
3511
  }
3455
3512
  const value = props[prop];
3456
3513
  if (value == undefined) {
3457
- if (slots && claims !== undefined && (prop === "ref" || prop.startsWith("on"))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3514
+ if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3458
3515
  continue;
3459
3516
  }
3460
3517
  if (prop.startsWith("prop:")) {
3461
3518
  if (slots && typeof value === "object") spreadPropPosition(prop, value);
3462
3519
  continue;
3463
3520
  }
3464
- if (prop === "ref" || prop.startsWith("on")) {
3521
+ if (prop === "ref" || isEventName(prop)) {
3465
3522
  if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
3466
3523
  continue;
3467
3524
  }
@@ -3472,10 +3529,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3472
3529
  } else if (prop === "class") {
3473
3530
  result += ` class="${ssrClassName(value)}"`;
3474
3531
  } else if (typeof value === "boolean") {
3475
- if (!value) continue;
3476
- result += ` ${attrName(prop)}`;
3477
- } else {
3478
- result += value === "" ? ` ${attrName(prop)}` : ` ${attrName(prop)}="${escape(value, true)}"`;
3532
+ if (value && isAttrName(prop)) result += ` ${prop}`;
3533
+ } else if (isAttrName(prop)) {
3534
+ result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
3479
3535
  }
3480
3536
  }
3481
3537
  }
@@ -3484,6 +3540,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3484
3540
  if (skipChildren) return {
3485
3541
  t: result + " />"
3486
3542
  };
3543
+ if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
3487
3544
  if (typeof children === "function") children = children();
3488
3545
  const ct = typeof children;
3489
3546
  if (ct === "string" || ct === "number") return {
@@ -3507,10 +3564,12 @@ function ssrElementAttribute(key, value) {
3507
3564
  return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
3508
3565
  }
3509
3566
  function ssrAttribute(key, value) {
3567
+ if (typeof value === "string") return ` ${key}="${value}"`;
3510
3568
  if (value == null || value === false) return "";
3511
3569
  if (typeof value === "object") {
3512
3570
  return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
3513
3571
  }
3572
+ if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
3514
3573
  return value === true ? ` ${key}` : ` ${key}="${value}"`;
3515
3574
  }
3516
3575
  function ssrHydrationKey() {
@@ -3524,7 +3583,7 @@ const SLOT_MARKER = "_s:";
3524
3583
  const SLOT_FACE_STREAM = 0;
3525
3584
  const SLOT_FACE_DATA = 1;
3526
3585
  const SLOT_FACE_MARKUP = 2;
3527
- const ATTRIBUTE_SLOT_POSITION = "ATTRIBUTE_SLOT_POSITION";
3586
+ const BINDING_SLOT_POSITION = "BINDING_SLOT_POSITION";
3528
3587
  function slotFinding(sv, reason, position, message, severity = "warn") {
3529
3588
  {
3530
3589
  const ctx = sharedConfig.context;
@@ -3535,7 +3594,7 @@ function slotFinding(sv, reason, position, message, severity = "warn") {
3535
3594
  seen.add(id);
3536
3595
  }
3537
3596
  devCheck({
3538
- code: ATTRIBUTE_SLOT_POSITION,
3597
+ code: BINDING_SLOT_POSITION,
3539
3598
  kind: "ssr",
3540
3599
  severity,
3541
3600
  message,
@@ -3564,29 +3623,32 @@ function slotValue(occurrence, key, value, face) {
3564
3623
  Object.defineProperty(sv, "toString", {
3565
3624
  value: () => slotValueString(sv, "stringified")
3566
3625
  });
3626
+ Object.defineProperty(sv, "w", {
3627
+ value: () => slotText(sv)
3628
+ });
3567
3629
  return sv;
3568
3630
  }
3569
3631
  function slotValueString(sv, reason) {
3570
3632
  {
3571
3633
  const prop = propOfOccurrence(sv[SLOT_VALUE]);
3572
- slotFinding(sv, reason, undefined, reason === "coerced" ? `[${ATTRIBUTE_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is an attribute-slot value used in an expression ` + `(a comparison, arithmetic, or a branch on its result). The server does not have the value — ` + `the client owns it — so nothing can be computed from it here. It must be the WHOLE value of ` + `an attribute, class name, style property, handler or ref; a decision that depends on it ` + `belongs in the client fill (return the decided value) or in a markup slot.` : `[${ATTRIBUTE_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is an attribute-slot value ` + `and was stringified outside a bindable position — it must be the WHOLE value of an attribute, ` + `class name, style property, handler or ref (\`class={row.${sv.k}}\`, not \`class={\`x \${row.${sv.k}}\`}\`). ` + `If it is, the element was compiled without the \`serverComponents\` compiler option. ` + `Nothing renders here on either face.`);
3634
+ slotFinding(sv, reason, undefined, reason === "coerced" ? `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value used in an expression ` + `(a comparison, arithmetic, or a branch on its result). The server does not have the value — ` + `the client owns it — so nothing can be computed from it here. It must be the WHOLE value of ` + `an attribute, class name, style property, handler, ref or text child; a decision that depends on it ` + `belongs in the client fill (return the decided value) or in a markup slot.` : `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value ` + `and was stringified outside a bindable position — it must be the WHOLE value of an attribute, ` + `class name, style property, handler, ref or text child (\`class={row.${sv.k}}\`, not \`class={\`x \${row.${sv.k}}\`}\`). ` + `If it is, the element was compiled without the \`serverComponents\` compiler option. ` + `Nothing renders here on either face.`);
3573
3635
  }
3574
3636
  return "";
3575
3637
  }
3576
- function slotTextPosition(sv) {
3577
- {
3578
- slotFinding(sv, "text", undefined, `[${ATTRIBUTE_SLOT_POSITION}] \`${sv.k}\` of slot \`${propOfOccurrence(sv[SLOT_VALUE])}\` is placed as TEXT. ` + `Text is not a bindable position yet: nothing renders here on either face. ` + `Bind it to an attribute, or render the text in a markup slot.`);
3579
- }
3580
- return "";
3638
+ function slotText(sv) {
3639
+ slotMarkupRead(sv, "text");
3640
+ const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
3641
+ const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
3642
+ return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
3581
3643
  }
3582
3644
  function slotMarkupRead(sv, position) {
3583
3645
  if (sv.f === SLOT_FACE_MARKUP) {
3584
- slotFinding(sv, "markup", position, `[${ATTRIBUTE_SLOT_POSITION}] \`${position}\` reads \`${sv.k}\` off slot \`${propOfOccurrence(sv[SLOT_VALUE])}\`, ` + `but the client fill returned markup, not an object. A slot renders one or the other: ` + `return an object (\`{ ${sv.k}: … }\`) for positions, or place the slot as content.`);
3646
+ slotFinding(sv, "markup", position, `[${BINDING_SLOT_POSITION}] \`${position}\` reads \`${sv.k}\` off slot \`${propOfOccurrence(sv[SLOT_VALUE])}\`, ` + `but the client fill returned markup, not an object. A slot renders one or the other: ` + `return an object (\`{ ${sv.k}: … }\`) for positions, or place the slot as content.`);
3585
3647
  }
3586
3648
  }
3587
3649
  function slotValueInline(kind, sv) {
3588
3650
  {
3589
- slotFinding(sv, "inline", kind, `[${ATTRIBUTE_SLOT_POSITION}] An attribute-slot value (\`${sv.k}\` of \`${propOfOccurrence(sv[SLOT_VALUE])}\`) ` + `reached \`${kind}\` inside template quotes, where its position marker cannot be emitted — the ` + `element was compiled without the \`serverComponents\` compiler option. Nothing renders here ` + `on either face.`);
3651
+ slotFinding(sv, "inline", kind, `[${BINDING_SLOT_POSITION}] A binding-slot value (\`${sv.k}\` of \`${propOfOccurrence(sv[SLOT_VALUE])}\`) ` + `reached \`${kind}\` inside template quotes, where its position marker cannot be emitted — the ` + `element was compiled without the \`serverComponents\` compiler option. Nothing renders here ` + `on either face.`);
3590
3652
  }
3591
3653
  return undefined;
3592
3654
  }
@@ -3600,6 +3662,9 @@ function slotEntry(sv, name) {
3600
3662
  function slotMarker(position, entries) {
3601
3663
  return ` ${SLOT_MARKER}${position}="${entries}"`;
3602
3664
  }
3665
+ function eventSlotStamp(mode) {
3666
+ return mode === CLAIMS_DOCUMENT ? " _hk" : "";
3667
+ }
3603
3668
  function propOfOccurrence(occurrence) {
3604
3669
  const i = occurrence.indexOf("#");
3605
3670
  return i === -1 ? occurrence : occurrence.slice(0, i);
@@ -3655,6 +3720,7 @@ function eventPosition(prop) {
3655
3720
  return prop.slice(2).toLowerCase();
3656
3721
  }
3657
3722
  function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
3723
+ if (!isAttrName(prop)) return behaviors;
3658
3724
  const pos = prop === "ref" ? "ref" : eventPosition(prop);
3659
3725
  const entries = value == null ? "" : claimEntries(pos, value, mode);
3660
3726
  if (!settle) {
@@ -3701,13 +3767,18 @@ function spreadBehaviorMarkers(behaviors, claims, mode) {
3701
3767
  }
3702
3768
  }
3703
3769
  let out = "";
3770
+ let events = false;
3704
3771
  if (behaviors !== null) {
3705
3772
  for (const [pos, b] of behaviors) {
3706
3773
  const e = claims === undefined ? b : b.e;
3707
- if (e) out += slotMarker(pos === "ref" ? "ref" : "on:" + pos, e);
3774
+ if (!e) continue;
3775
+ if (pos === "ref") out += slotMarker("ref", e);else {
3776
+ out += slotMarker("on:" + pos, e);
3777
+ events = true;
3778
+ }
3708
3779
  }
3709
3780
  }
3710
- return out;
3781
+ return events ? out + eventSlotStamp(mode) : out;
3711
3782
  }
3712
3783
  function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3713
3784
  for (let i = 0; i < props.length; i++) {
@@ -3736,20 +3807,21 @@ function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3736
3807
  }
3737
3808
  function spreadPropPosition(prop, value) {
3738
3809
  if (isSlotValue(value)) {
3739
- slotFinding(value, "prop", prop, `[${ATTRIBUTE_SLOT_POSITION}] \`${value.k}\` of slot \`${propOfOccurrence(value[SLOT_VALUE])}\` is bound ` + `at \`${prop}\`. Property positions are not bindable (the server renders no properties): nothing ` + `renders here. Bind the attribute form (\`${prop.slice(5)}\`), or set the property in the client fill's ref.`);
3810
+ slotFinding(value, "prop", prop, `[${BINDING_SLOT_POSITION}] \`${value.k}\` of slot \`${propOfOccurrence(value[SLOT_VALUE])}\` is bound ` + `at \`${prop}\`. Property positions are not bindable (the server renders no properties): nothing ` + `renders here. Bind the attribute form (\`${prop.slice(5)}\`), or set the property in the client fill's ref.`);
3740
3811
  }
3741
3812
  }
3742
3813
  function spreadObjectAttribute(prop, value) {
3743
3814
  if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
3744
- if (value[SLOT_VALUE] !== undefined) return slotAttribute(attrName(prop), value);
3745
- return ` ${attrName(prop)}="${escape(value, true)}"`;
3815
+ if (!isAttrName(prop)) return "";
3816
+ if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
3817
+ return ` ${prop}="${escape(value, true)}"`;
3746
3818
  }
3747
3819
  function slotSpreadSource(tag, source) {
3748
3820
  {
3749
3821
  const occurrence = source.$occurrence;
3750
- const text = `[${ATTRIBUTE_SLOT_POSITION}] A slot${occurrence ? ` (\`${propOfOccurrence(occurrence)}\`)` : ""} is spread ` + `onto a server-rendered <${tag}>. An attribute slot binds by position — name each one ` + `(\`class={row.rowClass} onClick={row.remove}\`) so the template shows what the client owns.`;
3822
+ const text = `[${BINDING_SLOT_POSITION}] A slot${occurrence ? ` (\`${propOfOccurrence(occurrence)}\`)` : ""} is spread ` + `onto a server-rendered <${tag}>. A binding slot binds by position — name each one ` + `(\`class={row.rowClass} onClick={row.remove}\`) so the template shows what the client owns.`;
3751
3823
  recordFinding({
3752
- code: ATTRIBUTE_SLOT_POSITION,
3824
+ code: BINDING_SLOT_POSITION,
3753
3825
  kind: "ssr",
3754
3826
  severity: "error",
3755
3827
  message: text,
@@ -3766,13 +3838,27 @@ function ssrClaim(map) {
3766
3838
  const mode = sharedConfig.context && sharedConfig.context.claims;
3767
3839
  if (!mode) return "";
3768
3840
  let out = "";
3841
+ let events = false;
3769
3842
  for (const pos in map) {
3770
3843
  const entries = claimEntries(pos, map[pos], mode);
3771
- if (entries) out += slotMarker(pos === "ref" ? "ref" : "on:" + pos, entries);
3844
+ if (!entries) continue;
3845
+ if (pos === "ref") out += slotMarker("ref", entries);else {
3846
+ out += slotMarker("on:" + pos, entries);
3847
+ events = true;
3848
+ }
3772
3849
  }
3773
- return out;
3850
+ return events ? out + eventSlotStamp(mode) : out;
3774
3851
  }
3775
3852
  function claimEntries(pos, value, mode) {
3853
+ if (Array.isArray(value) && pos !== "ref") {
3854
+ {
3855
+ const sv = value.find(isSlotValue);
3856
+ if (sv !== undefined) {
3857
+ slotFinding(sv, "tuple", pos, `[${BINDING_SLOT_POSITION}] A \`${pos}\` handler position on a server-rendered element received ` + `an array. A position marker names the slot's keys, never data, so a tuple's data cannot reach ` + `the client — nothing binds here. Return the tuple from the fill (\`[handler, data]\`) and ` + `bind that one property.`);
3858
+ } else claimEntries(pos, value[0], mode);
3859
+ }
3860
+ return "";
3861
+ }
3776
3862
  if (Array.isArray(value)) {
3777
3863
  let entries = "";
3778
3864
  for (const v of value) {
@@ -3788,10 +3874,10 @@ function claimEntries(pos, value, mode) {
3788
3874
  if (typeof value === "function" && !value.$slotWarned && claimInScope(mode)) {
3789
3875
  value.$slotWarned = true;
3790
3876
  devCheck({
3791
- code: ATTRIBUTE_SLOT_POSITION,
3877
+ code: BINDING_SLOT_POSITION,
3792
3878
  kind: "ssr",
3793
3879
  severity: "warn",
3794
- message: `[${ATTRIBUTE_SLOT_POSITION}] A \`${pos}\` position on a server-rendered element received a server-local ` + `function — it can never run. Bind an attribute slot's property there ` + `(\`const row = props.row(args); ${pos === "ref" ? "ref" : "onX"}={row.${pos === "ref" ? "ref" : "onX"}}\`) ` + `so the client supplies it, or bind a mutation to \`action=\`.`,
3880
+ message: `[${BINDING_SLOT_POSITION}] A \`${pos}\` position on a server-rendered element received a server-local ` + `function — it can never run. Bind a slot's property there ` + `(\`const row = props.row(args); ${pos === "ref" ? "ref" : "onX"}={row.${pos === "ref" ? "ref" : "onX"}}\`) ` + `so the client supplies it, or bind a mutation to \`action=\`.`,
3795
3881
  data: {
3796
3882
  reason: "server-local",
3797
3883
  position: pos
@@ -4035,7 +4121,7 @@ function generateHydrationScript({
4035
4121
  eventNames = ["click", "input"],
4036
4122
  nonce
4037
4123
  } = {}) {
4038
- return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
4124
+ return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:new Proxy({},{set:(r,k,v)=>(v instanceof Promise&&v.catch(()=>{}),r[k]=v,!0)}),fe(){}});</script><!--xs-->`;
4039
4125
  }
4040
4126
  function queue(fn) {
4041
4127
  return Promise.resolve().then(fn);
@@ -4238,6 +4324,10 @@ function tryResolveString(node, nested) {
4238
4324
  if (node.h && node.h.length > 0) return {
4239
4325
  merge: node
4240
4326
  };
4327
+ if (node[SLOT_VALUE] !== undefined) {
4328
+ ssrTextTail = false;
4329
+ return node.w();
4330
+ }
4241
4331
  if (node.t === undefined) {
4242
4332
  unrecognizedInsert(node);
4243
4333
  return "";
@@ -4292,9 +4382,8 @@ function resolveSSRNode(node, result = {
4292
4382
  result.t[result.t.length - 1] += node.t;
4293
4383
  ssrTextTail = false;
4294
4384
  } else if (node[SLOT_VALUE] !== undefined) {
4295
- const text = escape(slotTextPosition(node));
4296
- result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + text : text;
4297
- ssrTextTail = true;
4385
+ result.t[result.t.length - 1] += node.w();
4386
+ ssrTextTail = false;
4298
4387
  } else unrecognizedInsert(node);
4299
4388
  } else if (t === "function") {
4300
4389
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
@@ -4347,6 +4436,14 @@ function configureServerErrors(config) {
4347
4436
  }
4348
4437
  (g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
4349
4438
  }
4439
+ function reportRequestFailure(error, event) {
4440
+ reportServerError(error, {
4441
+ kind: "request",
4442
+ handling: "failed",
4443
+ event
4444
+ }, null);
4445
+ if (ambientServerErrorHook() === undefined) console.error(error);
4446
+ }
4350
4447
  function getRequestEvent() {
4351
4448
  const store = globalThis[RequestContext];
4352
4449
  if (!store) return undefined;
@@ -4517,10 +4614,13 @@ function copyInitHeaders(init) {
4517
4614
  for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
4518
4615
  return headers;
4519
4616
  }
4520
- const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
4521
- ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
4617
+ let stubGapFillExcluded;
4618
+ function isStubGapFillExcluded(key) {
4619
+ return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
4620
+ ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
4621
+ }
4522
4622
  function fillsStubGap(key, headers, response) {
4523
- if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
4623
+ if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
4524
4624
  if (response.body === null && (key === "content-type" || key === "content-length")) return false;
4525
4625
  return !headers.has(key);
4526
4626
  }
@@ -4612,7 +4712,7 @@ function createSSRResponse(result, event, options = {}) {
4612
4712
  closed = true;
4613
4713
  }
4614
4714
  };
4615
- result.pipe({
4715
+ const sink = {
4616
4716
  write(chunk) {
4617
4717
  if (!flushed) {
4618
4718
  flushed = true;
@@ -4627,6 +4727,7 @@ function createSSRResponse(result, event, options = {}) {
4627
4727
  status: getExpectedRedirectStatus(stub),
4628
4728
  headers: head.headers
4629
4729
  }));
4730
+ sink[ABANDON_RENDER]("redirect", true);
4630
4731
  return;
4631
4732
  }
4632
4733
  if (!head.headers.has("content-type")) {
@@ -4637,7 +4738,9 @@ function createSSRResponse(result, event, options = {}) {
4637
4738
  controller = c;
4638
4739
  },
4639
4740
  cancel() {
4741
+ if (closed) return;
4640
4742
  closed = true;
4743
+ sink[ABANDON_RENDER]("consumer");
4641
4744
  }
4642
4745
  }), {
4643
4746
  status: head.status,
@@ -4648,6 +4751,7 @@ function createSSRResponse(result, event, options = {}) {
4648
4751
  enqueue(transformChunk ? transformChunk(chunk) : chunk);
4649
4752
  },
4650
4753
  end() {
4754
+ if (!flushed) sink.write("");
4651
4755
  if (closed || !controller) return;
4652
4756
  const location = stub && stub.headers.get("Location");
4653
4757
  if (location && isHttpNavigationTarget(location)) {
@@ -4658,8 +4762,23 @@ function createSSRResponse(result, event, options = {}) {
4658
4762
  try {
4659
4763
  controller.close();
4660
4764
  } catch {}
4661
- }
4662
- });
4765
+ },
4766
+ [SHELL_ABANDONED]() {
4767
+ if (flushed) return;
4768
+ flushed = closed = true;
4769
+ if (stub) commitResponseStub(stub, {
4770
+ event
4771
+ });
4772
+ const head = deriveHead(stub, responseInit);
4773
+ const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
4774
+ resolve(new Response(null, {
4775
+ status,
4776
+ headers: head.headers
4777
+ }));
4778
+ },
4779
+ [ABANDON_RENDER]() {}
4780
+ };
4781
+ result.pipe(sink);
4663
4782
  });
4664
4783
  }
4665
4784
  function composeMiddleware(middlewares) {
@@ -4684,6 +4803,9 @@ function claimElement(node) {
4684
4803
  function claimElementTree(root) {
4685
4804
  return root;
4686
4805
  }
4806
+ function dispatchAsInteraction(_e, fn) {
4807
+ return fn();
4808
+ }
4687
4809
  function notSup() {
4688
4810
  throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
4689
4811
  }
@@ -4693,11 +4815,18 @@ setAsyncIterableSharer(shareAsyncIterable);
4693
4815
  const isServer = true;
4694
4816
  const isDev = true;
4695
4817
  function dynamic(source, options) {
4818
+ return dynamicCore(source, options, ssrTag);
4819
+ }
4820
+ function dynamicComponent(source, options) {
4821
+ return dynamicCore(source, options);
4822
+ }
4823
+ const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4824
+ function dynamicCore(source, options, tagArm) {
4696
4825
  if (options?.static) {
4697
4826
  const component = untrack(source);
4698
4827
  if (component && typeof component.then === "function") throw new Error("dynamic(): a static source must resolve synchronously, not to a promise");
4699
4828
  if (typeof component === "function") return props => component(props);
4700
- if (typeof component === "string") return props => ssrElement(component, props, undefined, true);
4829
+ if (typeof component === "string" && tagArm) return props => tagArm(component, props);
4701
4830
  return () => undefined;
4702
4831
  }
4703
4832
  const cached = createMemo(() => {
@@ -4743,9 +4872,7 @@ function dynamic(source, options) {
4743
4872
  const c = value();
4744
4873
  if (c) {
4745
4874
  if (typeof c === "function") return c(props);
4746
- if (typeof c === "string") {
4747
- return ssrElement(c, props, undefined, true);
4748
- }
4875
+ if (typeof c === "string" && tagArm) return tagArm(c, props);
4749
4876
  }
4750
4877
  }, {
4751
4878
  sync: true
@@ -4896,4 +5023,4 @@ function httpHeader(name, value, options) {
4896
5023
  }
4897
5024
  }
4898
5025
 
4899
- export { CLAIMS_DOCUMENT, CLAIMS_STREAM, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SLOT_FACE_DATA, SLOT_FACE_MARKUP, SLOT_FACE_STREAM, SLOT_MARKER, SLOT_VALUE, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, isSlotValue, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, slotValue, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrSelectValues, ssrStyle, ssrStyleProperty, notSup as style, styleNonce, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
5026
+ export { CLAIMS_DOCUMENT, CLAIMS_STREAM, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SLOT_FACE_DATA, SLOT_FACE_MARKUP, SLOT_FACE_STREAM, SLOT_MARKER, SLOT_VALUE, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, dynamicComponent, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, isSlotValue, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, slotValue, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, styleNonce, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };