@solidjs/web 2.0.0-rc.13 → 2.0.0-rc.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.
Files changed (59) hide show
  1. package/dist/server.dev.js +317 -185
  2. package/dist/server.js +298 -161
  3. package/dist/server.observe.js +299 -171
  4. package/dist/web.dev.js +207 -189
  5. package/dist/web.js +180 -178
  6. package/dist/web.observe.js +180 -180
  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 +665 -1114
  11. package/frames/dist/client.js +630 -1087
  12. package/frames/dist/client.observe.js +629 -1087
  13. package/frames/dist/regions.js +130 -0
  14. package/frames/dist/server.dev.js +400 -201
  15. package/frames/dist/server.js +397 -198
  16. package/frames/dist/server.observe.js +397 -198
  17. package/frames/dist/trace.js +45 -0
  18. package/frames/dist/wire.js +133 -0
  19. package/package.json +30 -4
  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 +38 -9
  24. package/serialization/dist/serialization.js +40 -11
  25. package/serialization/types/serializer-decode.d.ts +24 -2
  26. package/server-functions/dist/client.dev.js +101 -62
  27. package/server-functions/dist/client.js +101 -62
  28. package/server-functions/dist/client.observe.js +101 -62
  29. package/server-functions/dist/server.dev.js +178 -67
  30. package/server-functions/dist/server.js +178 -67
  31. package/server-functions/dist/server.observe.js +178 -67
  32. package/skills/server-components/SKILL.md +65 -43
  33. package/types/client.d.ts +120 -8
  34. package/types/constants.d.ts +3 -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 +33 -9
  46. package/types/frames/trace-tier.d.ts +2 -0
  47. package/types/frames/wire-tier.d.ts +116 -0
  48. package/types/head.d.ts +1 -0
  49. package/types/index.d.ts +61 -16
  50. package/types/index.server.d.ts +3 -18
  51. package/types/jsx.d.ts +4 -13
  52. package/types/observe.d.ts +4 -2
  53. package/types/response.d.ts +26 -4
  54. package/types/serializer-decode.d.ts +24 -2
  55. package/types/server-functions/client.d.ts +30 -0
  56. package/types/server-functions/registry.d.ts +4 -1
  57. package/types/server-functions/shared.d.ts +12 -8
  58. package/types/server-mock.d.ts +22 -3
  59. package/types/server.d.ts +119 -17
@@ -1,8 +1,8 @@
1
- import { createRenderEffect, createMemo, OBSERVE, getOwner, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId, untrack, NotReadyError } from 'solid-js';
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';
1
+ import { createRenderEffect, createMemo, OBSERVE, getOwner, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, 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 = {
@@ -34,6 +34,7 @@ const DOMWithState = {
34
34
  }
35
35
  };
36
36
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
37
+ const LinkAttributes = /*#__PURE__*/new Set(["href", "target", "rel", "download", "link", "aria-current"]);
37
38
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
38
39
  const SVGElements = /*#__PURE__*/new Set([
39
40
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
@@ -59,6 +60,10 @@ function isHttpNavigationTarget(target) {
59
60
  return false;
60
61
  }
61
62
  }
63
+ function isEventName(name) {
64
+ let c;
65
+ return name.startsWith("on") && (c = name.charCodeAt(2)) > 64 && c < 91;
66
+ }
62
67
 
63
68
  const transparentOptions = {
64
69
  transparent: true,
@@ -453,17 +458,15 @@ function toBorderForm(value, envelopeContainers) {
453
458
  }
454
459
  function isShareableIterable(value) {
455
460
  try {
456
- if (value.__SEROVAL_STREAM__ === true) return false;
457
- if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) return false;
458
- return typeof value[Symbol.asyncIterator] === "function";
461
+ return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
459
462
  } catch {
460
463
  return false;
461
464
  }
462
465
  }
463
- function materialize(marker) {
466
+ function materialize(marker, claiming) {
464
467
  let value = state.materialized.get(marker.$tr);
465
468
  if (value === undefined) {
466
- value = state.materializeTrace(marker);
469
+ value = state.materializeTrace(marker, claiming);
467
470
  state.materialized.set(marker.$tr, value);
468
471
  if (value !== null && typeof value === "object") state.materializedValues.add(value);
469
472
  }
@@ -521,23 +524,22 @@ setContainerTraceStreamMint(iterable => {
521
524
  })();
522
525
  return stream;
523
526
  });
524
- const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
527
+ const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
525
528
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
526
529
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
527
530
  ContainerTracePlugin]);
528
531
  function resolveSerializerPlugins(customPlugins) {
529
532
  return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
530
533
  }
531
- Feature.RegExp;
532
534
 
533
- const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
535
+ const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
534
536
  const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
535
537
  const HYDRATION_GLOBAL = "_$HY.r";
536
538
  function createSerializer(options) {
537
539
  return new Serializer({
538
540
  ...options,
539
541
  plugins: resolveSerializerPlugins(options.plugins),
540
- disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
542
+ disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
541
543
  });
542
544
  }
543
545
  function createHydrationSerializer({
@@ -561,17 +563,24 @@ function getLocalHeaderScript(id) {
561
563
  }
562
564
 
563
565
  const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
564
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
565
- const ResponseEnvelope = /* @__PURE__ */(() => {
566
- class ResponseEnvelope {
567
- constructor(response, value) {
568
- this.response = response;
569
- this.value = value;
570
- }
566
+ let EnvelopeClass;
567
+ const ResponseEnvelope = function ResponseEnvelope(response, value) {
568
+ if (!EnvelopeClass) {
569
+ EnvelopeClass = class extends Response {
570
+ constructor(response, value) {
571
+ super(response ? response.body : null, response && {
572
+ status: response.status,
573
+ statusText: response.statusText,
574
+ headers: copyHeaders(response.headers)
575
+ });
576
+ this.response = response ? this : undefined;
577
+ this.value = value;
578
+ }
579
+ };
580
+ EnvelopeClass.prototype[ENVELOPE] = true;
571
581
  }
572
- ResponseEnvelope.prototype[ENVELOPE] = true;
573
- return ResponseEnvelope;
574
- })();
582
+ return new EnvelopeClass(response, value);
583
+ };
575
584
  function isResponseEnvelope(value) {
576
585
  return !!(value && typeof value === "object" && value[ENVELOPE]);
577
586
  }
@@ -596,6 +605,16 @@ function isSafeError(value) {
596
605
  const REVALIDATE_HEADER = "X-Revalidate";
597
606
  const REVALIDATE_ALL = "*";
598
607
  const RESPONSE_HEADER_VALUE_LIMIT = 4096;
608
+ function copyHeaders(init) {
609
+ const source = init;
610
+ if (!source || !source.getSetCookie) return new Headers(init);
611
+ const headers = new Headers();
612
+ source.forEach((value, key) => {
613
+ if (key !== "set-cookie") headers.append(key, value);
614
+ });
615
+ for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
616
+ return headers;
617
+ }
599
618
  function initWithRevalidate(init = {}) {
600
619
  const resolved = typeof init === "number" ? {
601
620
  status: init
@@ -604,18 +623,7 @@ function initWithRevalidate(init = {}) {
604
623
  revalidate,
605
624
  ...responseInit
606
625
  } = resolved;
607
- let headers;
608
- if (responseInit.headers && responseInit.headers.getSetCookie) {
609
- headers = new Headers();
610
- responseInit.headers.forEach((value, key) => {
611
- if (key !== "set-cookie") headers.append(key, value);
612
- });
613
- for (const cookie of responseInit.headers.getSetCookie()) {
614
- headers.append("Set-Cookie", cookie);
615
- }
616
- } else {
617
- headers = new Headers(responseInit.headers);
618
- }
626
+ const headers = copyHeaders(responseInit.headers);
619
627
  if (revalidate !== undefined) {
620
628
  const list = Array.isArray(revalidate) ? revalidate : [revalidate];
621
629
  if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
@@ -736,7 +744,7 @@ function serializeCookie(name, value, options = {}) {
736
744
  return cookie;
737
745
  }
738
746
  const FLASH_COOKIE = "flash";
739
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
747
+ const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
740
748
  function hasFlashCookie(cookieHeader) {
741
749
  return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
742
750
  }
@@ -748,7 +756,6 @@ const ERROR_HEADER = "X-Server-Function-Error";
748
756
  const BODY_FORMAT_HEADER = "X-Server-Function-Format";
749
757
  const REDIRECT_HEADER = "X-Server-Function-Redirect";
750
758
  const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
751
- new TextEncoder().encode(":\n\n");
752
759
 
753
760
  function emitFinding(finding, subject = getOwner()) {
754
761
  if (OBSERVE === undefined) return;
@@ -805,6 +812,10 @@ function qualifierValue(name, value) {
805
812
  function asciiLowerCase(value) {
806
813
  return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
807
814
  }
815
+ const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
816
+ function headBodyText(tag, props, text) {
817
+ return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
818
+ }
808
819
  function resourceIdentity(tag, props) {
809
820
  const url = String(props.href || props.src || "");
810
821
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
@@ -1389,6 +1400,7 @@ function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMet
1389
1400
  noScripts
1390
1401
  };
1391
1402
  }
1403
+ let headBodyHook;
1392
1404
  function flushHeadFragment(registry, boundary, nonce) {
1393
1405
  const groups = commitHeadBoundary(registry, boundary);
1394
1406
  if (!groups.length) return null;
@@ -1412,7 +1424,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1412
1424
  const t = winner.tags[i];
1413
1425
  const attrs = {};
1414
1426
  for (const name in t.props) {
1415
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1427
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1416
1428
  if (!HEAD_ATTR_NAME.test(name)) {
1417
1429
  continue;
1418
1430
  }
@@ -1426,7 +1438,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1426
1438
  if (value) attrs.nonce = String(value);
1427
1439
  }
1428
1440
  const children = t.props.children;
1429
- ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
1441
+ ops.push(["a", identity, t.tag, attrs, children == null ? null : headBodyHook ? headBodyHook(t.tag, t.props, String(children)) : String(children)]);
1430
1442
  }
1431
1443
  }
1432
1444
  return ops.length ? ops : null;
@@ -1454,8 +1466,7 @@ function normalizeNonce(nonce) {
1454
1466
  }
1455
1467
  function destinationNonce(nonce, destination) {
1456
1468
  if (nonce == null) return undefined;
1457
- if (typeof nonce === "string") return nonce || undefined;
1458
- const value = nonce[destination];
1469
+ const value = typeof nonce === "string" ? nonce : nonce[destination];
1459
1470
  return typeof value === "string" && value ? value : undefined;
1460
1471
  }
1461
1472
  function scriptNonce(nonce) {
@@ -1501,7 +1512,7 @@ function nonceAttr(nonce, destination) {
1501
1512
  function renderHeadAttrHtml(props) {
1502
1513
  let attrs = "";
1503
1514
  for (const name in props) {
1504
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1515
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1505
1516
  if (!HEAD_ATTR_NAME.test(name)) {
1506
1517
  continue;
1507
1518
  }
@@ -1514,7 +1525,7 @@ function renderHeadAttrHtml(props) {
1514
1525
  function headAttrRecord(props, skipRelHref) {
1515
1526
  let attrs = null;
1516
1527
  for (const name in props) {
1517
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1528
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1518
1529
  if ((name === "rel" || name === "href")) continue;
1519
1530
  if (!HEAD_ATTR_NAME.test(name)) continue;
1520
1531
  const v = props[name];
@@ -1529,6 +1540,7 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
1529
1540
  if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
1530
1541
  if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
1531
1542
  let body = props.children == null ? "" : String(props.children);
1543
+ if (headBodyHook) body = headBodyHook(tag, props, body);
1532
1544
  if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
1533
1545
  return `<${tag}${attrs}>${body}</${tag}>`;
1534
1546
  }
@@ -1537,32 +1549,51 @@ function useHead(tags) {
1537
1549
  if (!ctx || !ctx.registerHeadTags) {
1538
1550
  return;
1539
1551
  }
1552
+ headBodyHook = headBodyText;
1540
1553
  ctx.registerHeadTags(tags);
1541
1554
  }
1542
1555
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
1556
+ const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
1557
+ const TAG_START = /^[a-zA-Z]/;
1543
1558
  const tagInfos = /*#__PURE__*/new Map();
1544
1559
  function tagInfo(tag) {
1545
1560
  let info = tagInfos.get(tag);
1546
1561
  if (info === undefined) {
1562
+ if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
1563
+ let formDefaults, formAttributes;
1564
+ if (tag === "input" || tag === "option") {
1565
+ formDefaults = Object.create(null);
1566
+ formAttributes = Object.create(null);
1567
+ const state = DOMWithState[tag.toUpperCase()];
1568
+ for (const prop in state) {
1569
+ if (state[prop] === 2) {
1570
+ const attr = prop.slice(7).toLowerCase();
1571
+ formDefaults[attr] = prop;
1572
+ formAttributes[prop] = attr;
1573
+ }
1574
+ }
1575
+ }
1547
1576
  info = {
1548
1577
  open: "<" + tag,
1549
1578
  close: "</" + tag + ">",
1550
1579
  isVoid: VOID_ELEMENTS.test(tag),
1551
1580
  textarea: tag === "textarea",
1552
- raw: tag === "script" || tag === "style"
1581
+ raw: tag === "script" || tag === "style",
1582
+ formDefaults,
1583
+ formAttributes
1553
1584
  };
1554
1585
  if (tagInfos.size < 512) tagInfos.set(tag, info);
1555
1586
  }
1556
1587
  return info;
1557
1588
  }
1558
1589
  const safeAttrNames = /*#__PURE__*/new Set();
1559
- function attrName(prop) {
1560
- if (safeAttrNames.has(prop)) return prop;
1561
- const escaped = escape(prop);
1562
- if (escaped === prop && safeAttrNames.size < 512) safeAttrNames.add(prop);
1563
- return escaped;
1590
+ function isAttrName(prop) {
1591
+ if (safeAttrNames.has(prop)) return true;
1592
+ if (prop === "" || NOT_NAME.test(prop)) return false;
1593
+ if (safeAttrNames.size < 512) safeAttrNames.add(prop);
1594
+ return true;
1564
1595
  }
1565
- 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])}`;
1596
+ 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)`;
1566
1597
  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)}`;
1567
1598
  function renderToString(code, options = {}) {
1568
1599
  const {
@@ -1648,7 +1679,7 @@ function renderToString(code, options = {}) {
1648
1679
  closed = true;
1649
1680
  serializer.close();
1650
1681
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1651
- const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
1682
+ const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead) + shellEndMarker(context, renderId, nonce, noScripts);
1652
1683
  if (render) render.shell();
1653
1684
  if (requestEvent && requestEvent.response) {
1654
1685
  commitResponseStub(requestEvent.response, {
@@ -1657,12 +1688,20 @@ function renderToString(code, options = {}) {
1657
1688
  }
1658
1689
  rendered = true;
1659
1690
  return document;
1691
+ } catch (err) {
1692
+ reportServerError(err, {
1693
+ kind: "render",
1694
+ handling: "failed"
1695
+ }, null, options.onError);
1696
+ throw err;
1660
1697
  } finally {
1661
1698
  if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
1662
1699
  context.trace = undefined;
1663
1700
  if (dispose) dispose();
1664
1701
  }
1665
1702
  }
1703
+ const SHELL_ABANDONED = Symbol();
1704
+ const ABANDON_RENDER = Symbol();
1666
1705
  function renderToStream(code, options = {}) {
1667
1706
  let {
1668
1707
  onCompleteShell,
@@ -1683,6 +1722,7 @@ function renderToStream(code, options = {}) {
1683
1722
  let disconnected = false;
1684
1723
  let failed = false;
1685
1724
  let onFailed;
1725
+ let onDisconnectedBeforeShell;
1686
1726
  const defuse = p => {
1687
1727
  if (p && typeof p.then === "function") p.then(undefined, () => {});
1688
1728
  };
@@ -1701,9 +1741,9 @@ function renderToStream(code, options = {}) {
1701
1741
  complete(sink);
1702
1742
  } : complete;
1703
1743
  };
1704
- const abandon = disconnect => {
1744
+ const abandon = (disconnect, quiet) => {
1705
1745
  if (dead) return;
1706
- if (disconnect) emitFinding({
1746
+ if (disconnect && !quiet) emitFinding({
1707
1747
  code: "SSR_STREAM_ABANDONED",
1708
1748
  kind: "ssr",
1709
1749
  severity: "warn",
@@ -1748,7 +1788,7 @@ function renderToStream(code, options = {}) {
1748
1788
  if (!disconnect) {
1749
1789
  failed = true;
1750
1790
  onFailed && onFailed(sink);
1751
- }
1791
+ } else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
1752
1792
  };
1753
1793
  const failRender = err => {
1754
1794
  reportServerError(err, {
@@ -1875,10 +1915,10 @@ function renderToStream(code, options = {}) {
1875
1915
  const styleAttr = nonceAttr(nonce, "style");
1876
1916
  emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
1877
1917
  writeTasks();
1918
+ buffer.write(`<template id="${key}">${value}</template>`);
1878
1919
  for (const entry of styles.links) {
1879
- 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}')">`);
1920
+ buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} data-dfc="${key}">` : `<link${entry.attrHtml}${styleAttr} data-dfc="${key}">`);
1880
1921
  }
1881
- buffer.write(`<template id="${key}">${value}</template>`);
1882
1922
  } else {
1883
1923
  buffer.write(`<template id="${key}">${value}</template>`);
1884
1924
  if (!deferActivation) {
@@ -1901,7 +1941,7 @@ function renderToStream(code, options = {}) {
1901
1941
  }
1902
1942
  },
1903
1943
  shell(shellHtml, meta) {
1904
- buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
1944
+ buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead) + shellEndMarker(context, renderId, nonce, noScripts));
1905
1945
  },
1906
1946
  ...options.sink
1907
1947
  };
@@ -1920,7 +1960,7 @@ function renderToStream(code, options = {}) {
1920
1960
  };
1921
1961
  let holds = 0;
1922
1962
  const flushEnd = () => {
1923
- if (!registry.size && !holds) {
1963
+ if (!registry.size && !holds && !rootHoles) {
1924
1964
  serializeRootAssets();
1925
1965
  queue(() => queue(() => {
1926
1966
  if (context.live.end) {
@@ -2062,6 +2102,12 @@ function renderToStream(code, options = {}) {
2062
2102
  }
2063
2103
  let rootHoles = null;
2064
2104
  let nextHoleId = 0;
2105
+ let parkedInlines = null;
2106
+ function inlineFragment(key, value) {
2107
+ if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
2108
+ (parkedInlines ||= new Map()).set(key, value);
2109
+ } else html = replacePlaceholder(html, key, value);
2110
+ }
2065
2111
  let buffer = {
2066
2112
  write(payload) {
2067
2113
  tmp += payload;
@@ -2190,11 +2236,16 @@ function renderToStream(code, options = {}) {
2190
2236
  });
2191
2237
  if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
2192
2238
  }
2193
- return (value, error) => {
2239
+ return (value, error, escaped) => {
2194
2240
  if (registry.has(key)) {
2195
2241
  const item = registry.get(key);
2196
2242
  registry.delete(key);
2197
2243
  if (error) abandonSubtree(key, error);
2244
+ if (error && escaped) {
2245
+ const wire = ssrSanitizeError(error, null);
2246
+ const message = wire instanceof Error ? wire.message : String(wire);
2247
+ if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
2248
+ }
2198
2249
  if (item.children && !error) {
2199
2250
  for (const k in item.children) {
2200
2251
  value = replacePlaceholder(value, k, item.children[k]);
@@ -2214,7 +2265,7 @@ function renderToStream(code, options = {}) {
2214
2265
  if (!completed) {
2215
2266
  if (error) dropHeadBoundary(headRegistry, key);
2216
2267
  if (!firstFlushed) {
2217
- queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
2268
+ queue(() => inlineFragment(key, value !== undefined ? value : ""));
2218
2269
  serializeFragmentAssets(key, tracking.boundaryModules, context);
2219
2270
  item.resolve(error);
2220
2271
  } else {
@@ -2258,7 +2309,7 @@ function renderToStream(code, options = {}) {
2258
2309
  registerEntryAssets(manifest);
2259
2310
  context.writer = createHydrationWriter(context, () => !completed);
2260
2311
  const signal = options.signal;
2261
- const onAbort = signal ? () => abandon("signal") : undefined;
2312
+ const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
2262
2313
  let html = createRoot(d => {
2263
2314
  dispose = () => {
2264
2315
  context.trace = undefined;
@@ -2267,7 +2318,16 @@ function renderToStream(code, options = {}) {
2267
2318
  };
2268
2319
  rootOwner = claimRenderRoot(context);
2269
2320
  if (requestEvent) claimEventRender(requestEvent, context);
2270
- const res = resolveSSRNode(escape(code()));
2321
+ let res;
2322
+ try {
2323
+ res = resolveSSRNode(escape(code()));
2324
+ } catch (err) {
2325
+ reportServerError(err, {
2326
+ kind: "render",
2327
+ handling: "failed"
2328
+ }, null, options.onError);
2329
+ throw err;
2330
+ }
2271
2331
  if (!res.h.length) return res.t[0];
2272
2332
  rootHoles = [];
2273
2333
  let out = res.t[0];
@@ -2314,6 +2374,13 @@ function renderToStream(code, options = {}) {
2314
2374
  for (const p of res.p) blockingPromises.add(p);
2315
2375
  }
2316
2376
  }
2377
+ if (parkedInlines) {
2378
+ for (const [key, value] of parkedInlines) {
2379
+ if (!html.includes(`<template id="pl-${key}">`)) continue;
2380
+ html = replacePlaceholder(html, key, value);
2381
+ parkedInlines.delete(key);
2382
+ }
2383
+ }
2317
2384
  if (pending.length) {
2318
2385
  rootHoles = pending;
2319
2386
  return false;
@@ -2475,11 +2542,16 @@ function renderToStream(code, options = {}) {
2475
2542
  },
2476
2543
  pipe(w) {
2477
2544
  claimConsumer("pipe");
2545
+ const abandoned = w[SHELL_ABANDONED];
2478
2546
  onFailure(sink => {
2479
2547
  try {
2480
- sink ? sink.end() : w.end();
2548
+ sink ? sink.end() : abandoned ? abandoned() : w.end();
2481
2549
  } catch (_) {}
2482
2550
  });
2551
+ if (abandoned) {
2552
+ w[ABANDON_RENDER] = abandon;
2553
+ if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
2554
+ }
2483
2555
  function flush() {
2484
2556
  allSettled(blockingPromises).then(awaited => {
2485
2557
  scheduleFlush(() => {
@@ -2521,11 +2593,15 @@ function renderToStream(code, options = {}) {
2521
2593
  };
2522
2594
  }
2523
2595
  function HydrationScript(props) {
2524
- const nonce = scriptNonce(sharedConfig.context && sharedConfig.context.nonce);
2525
- return ssr(generateHydrationScript({
2526
- nonce,
2596
+ if (sharedConfig.context) sharedConfig.context.bootstrap = true;
2597
+ const {
2598
+ eventNames,
2599
+ nonce
2600
+ } = {
2601
+ nonce: sharedConfig.context && sharedConfig.context.nonce,
2527
2602
  ...props
2528
- }));
2603
+ };
2604
+ return ssr(hydrationBootstrap(eventNames, scriptNonce(nonce), true));
2529
2605
  }
2530
2606
  function ssrGroup(fn, n) {
2531
2607
  fn.$g = n;
@@ -2681,7 +2757,7 @@ function createLiveHoles(sink, scoped) {
2681
2757
  let nextId = 0;
2682
2758
  const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
2683
2759
  const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
2684
- const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
2760
+ const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
2685
2761
  const swept = (owner, ctx, fn) => {
2686
2762
  const prev = sharedConfig.context;
2687
2763
  sharedConfig.context = ctx;
@@ -3217,6 +3293,14 @@ function ssrStyleProperty(name, value) {
3217
3293
  if (isSlotValue(value)) value = slotValueInline();
3218
3294
  return value != null ? name + value : "";
3219
3295
  }
3296
+ function ssrStyleProperties(...entries) {
3297
+ let result = "";
3298
+ for (let i = 0; i < entries.length; i += 2) {
3299
+ const entry = ssrStyleProperty(entries[i], entries[i + 1]);
3300
+ if (entry) result = result ? result + ";" + entry : entry;
3301
+ }
3302
+ return result;
3303
+ }
3220
3304
  function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3221
3305
  const hk = needsId ? ssrHydrationKey() : "";
3222
3306
  if (typeof props === "function") props = props();
@@ -3227,6 +3311,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3227
3311
  let ownerIndex = null;
3228
3312
  const ctx = renderConfig.context;
3229
3313
  const slots = ctx !== undefined && ctx.claims !== undefined;
3314
+ const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
3230
3315
  if (Array.isArray(props)) {
3231
3316
  if (slots && props.$slot === true) props = slotSpreadSource();else {
3232
3317
  let i = 0;
@@ -3256,6 +3341,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3256
3341
  const skipChildren = info.isVoid;
3257
3342
  let result = info.open + hk;
3258
3343
  let behaviors = null;
3344
+ let childOwner = null;
3259
3345
  const last = sources === null ? 0 : sources.length - 1;
3260
3346
  let keysOf = null;
3261
3347
  if (sources !== null) {
@@ -3266,7 +3352,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3266
3352
  const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
3267
3353
  if (sources !== null) props = sources[s];
3268
3354
  nextKey: for (let i = 0; i < keys.length; i++) {
3269
- const prop = keys[i];
3355
+ let prop = keys[i];
3270
3356
  if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
3271
3357
  if (owners !== null) props = owners[i];
3272
3358
  for (let j = s + 1; j <= last; j++) {
@@ -3278,21 +3364,29 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3278
3364
  continue;
3279
3365
  }
3280
3366
  if (ChildProperties.has(prop)) {
3281
- if (children === undefined && !skipChildren) children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
3367
+ if (children === undefined && childOwner === null && !skipChildren) {
3368
+ if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
3369
+ }
3282
3370
  continue;
3283
3371
  }
3284
- const value = props[prop];
3372
+ const key = prop;
3373
+ if (info.formAttributes !== undefined) {
3374
+ prop = spreadFormAttribute(prop, info, keys, keysOf, skip);
3375
+ if (prop === undefined) continue;
3376
+ }
3377
+ const value = props[key];
3285
3378
  if (value == undefined) {
3286
- if (slots && claims !== undefined && (prop === "ref" || prop.startsWith("on"))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3379
+ if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3287
3380
  continue;
3288
3381
  }
3289
3382
  if (prop.startsWith("prop:")) {
3290
3383
  continue;
3291
3384
  }
3292
- if (prop === "ref" || prop.startsWith("on")) {
3385
+ if (prop === "ref" || isEventName(prop)) {
3293
3386
  if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
3294
3387
  continue;
3295
3388
  }
3389
+ if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
3296
3390
  if (slots && typeof value === "object") {
3297
3391
  result += spreadObjectAttribute(prop, value);
3298
3392
  } else if (prop === "style") {
@@ -3300,18 +3394,19 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3300
3394
  } else if (prop === "class") {
3301
3395
  result += ` class="${ssrClassName(value)}"`;
3302
3396
  } else if (typeof value === "boolean") {
3303
- if (!value) continue;
3304
- result += ` ${attrName(prop)}`;
3305
- } else {
3306
- result += value === "" ? ` ${attrName(prop)}` : ` ${attrName(prop)}="${escape(value, true)}"`;
3397
+ if (value && isAttrName(prop)) result += ` ${prop}`;
3398
+ } else if (isAttrName(prop)) {
3399
+ result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
3307
3400
  }
3308
3401
  }
3309
3402
  }
3310
3403
  if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
3311
3404
  if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
3405
+ if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
3312
3406
  if (skipChildren) return {
3313
3407
  t: result + " />"
3314
3408
  };
3409
+ if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
3315
3410
  if (typeof children === "function") children = children();
3316
3411
  const ct = typeof children;
3317
3412
  if (ct === "string" || ct === "number") return {
@@ -3325,6 +3420,19 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3325
3420
  };
3326
3421
  return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
3327
3422
  }
3423
+ function spreadFormAttribute(prop, info, keys, keysOf, skip) {
3424
+ const defaultProp = info.formDefaults[prop];
3425
+ if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
3426
+ if (keysOf !== null) {
3427
+ for (let j = 0; j < keysOf.length; j++) {
3428
+ if (keysOf[j].includes(defaultProp)) return;
3429
+ }
3430
+ } else if (keys.includes(defaultProp)) return;
3431
+ }
3432
+ const attr = info.formAttributes[prop];
3433
+ if (attr !== undefined && skip !== undefined && skip(attr)) return;
3434
+ return attr === undefined ? prop : attr;
3435
+ }
3328
3436
  function ssrElementAttribute(key, value) {
3329
3437
  if (value == undefined) return "";
3330
3438
  if (key === "style" || key === "class") {
@@ -3335,10 +3443,12 @@ function ssrElementAttribute(key, value) {
3335
3443
  return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
3336
3444
  }
3337
3445
  function ssrAttribute(key, value) {
3446
+ if (typeof value === "string") return ` ${key}="${value}"`;
3338
3447
  if (value == null || value === false) return "";
3339
3448
  if (typeof value === "object") {
3340
3449
  return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
3341
3450
  }
3451
+ if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
3342
3452
  return value === true ? ` ${key}` : ` ${key}="${value}"`;
3343
3453
  }
3344
3454
  function ssrHydrationKey() {
@@ -3368,13 +3478,18 @@ function slotValue(occurrence, key, value, face) {
3368
3478
  Object.defineProperty(sv, "toString", {
3369
3479
  value: () => slotValueString()
3370
3480
  });
3481
+ Object.defineProperty(sv, "w", {
3482
+ value: () => slotText(sv)
3483
+ });
3371
3484
  return sv;
3372
3485
  }
3373
3486
  function slotValueString(sv, reason) {
3374
3487
  return "";
3375
3488
  }
3376
- function slotTextPosition(sv) {
3377
- return "";
3489
+ function slotText(sv) {
3490
+ const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
3491
+ const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
3492
+ return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
3378
3493
  }
3379
3494
  function slotValueInline(kind, sv) {
3380
3495
  return undefined;
@@ -3389,6 +3504,9 @@ function slotEntry(sv, name) {
3389
3504
  function slotMarker(position, entries) {
3390
3505
  return ` ${SLOT_MARKER}${position}="${entries}"`;
3391
3506
  }
3507
+ function eventSlotStamp(mode) {
3508
+ return mode === CLAIMS_DOCUMENT ? " _hk" : "";
3509
+ }
3392
3510
  function slotAttribute(key, sv) {
3393
3511
  let out = "";
3394
3512
  if (sv.f === SLOT_FACE_DATA) {
@@ -3437,6 +3555,7 @@ function eventPosition(prop) {
3437
3555
  return prop.slice(2).toLowerCase();
3438
3556
  }
3439
3557
  function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
3558
+ if (!isAttrName(prop)) return behaviors;
3440
3559
  const pos = prop === "ref" ? "ref" : eventPosition(prop);
3441
3560
  const entries = value == null ? "" : claimEntries(pos, value);
3442
3561
  if (!settle) {
@@ -3483,13 +3602,18 @@ function spreadBehaviorMarkers(behaviors, claims, mode) {
3483
3602
  }
3484
3603
  }
3485
3604
  let out = "";
3605
+ let events = false;
3486
3606
  if (behaviors !== null) {
3487
3607
  for (const [pos, b] of behaviors) {
3488
3608
  const e = claims === undefined ? b : b.e;
3489
- if (e) out += slotMarker(pos === "ref" ? "ref" : "on:" + pos, e);
3609
+ if (!e) continue;
3610
+ if (pos === "ref") out += slotMarker("ref", e);else {
3611
+ out += slotMarker("on:" + pos, e);
3612
+ events = true;
3613
+ }
3490
3614
  }
3491
3615
  }
3492
- return out;
3616
+ return events ? out + eventSlotStamp(mode) : out;
3493
3617
  }
3494
3618
  function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3495
3619
  for (let i = 0; i < props.length; i++) {
@@ -3518,8 +3642,9 @@ function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3518
3642
  }
3519
3643
  function spreadObjectAttribute(prop, value) {
3520
3644
  if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
3521
- if (value[SLOT_VALUE] !== undefined) return slotAttribute(attrName(prop), value);
3522
- return ` ${attrName(prop)}="${escape(value, true)}"`;
3645
+ if (!isAttrName(prop)) return "";
3646
+ if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
3647
+ return ` ${prop}="${escape(value, true)}"`;
3523
3648
  }
3524
3649
  function slotSpreadSource(tag, source) {
3525
3650
  return {};
@@ -3528,13 +3653,21 @@ function ssrClaim(map) {
3528
3653
  const mode = sharedConfig.context && sharedConfig.context.claims;
3529
3654
  if (!mode) return "";
3530
3655
  let out = "";
3656
+ let events = false;
3531
3657
  for (const pos in map) {
3532
3658
  const entries = claimEntries(pos, map[pos]);
3533
- if (entries) out += slotMarker(pos === "ref" ? "ref" : "on:" + pos, entries);
3659
+ if (!entries) continue;
3660
+ if (pos === "ref") out += slotMarker("ref", entries);else {
3661
+ out += slotMarker("on:" + pos, entries);
3662
+ events = true;
3663
+ }
3534
3664
  }
3535
- return out;
3665
+ return events ? out + eventSlotStamp(mode) : out;
3536
3666
  }
3537
3667
  function claimEntries(pos, value, mode) {
3668
+ if (Array.isArray(value) && pos !== "ref") {
3669
+ return "";
3670
+ }
3538
3671
  if (Array.isArray(value)) {
3539
3672
  let entries = "";
3540
3673
  for (const v of value) {
@@ -3548,6 +3681,11 @@ function claimEntries(pos, value, mode) {
3548
3681
  }
3549
3682
  return "";
3550
3683
  }
3684
+ function ssrLinkClaim(attrs) {
3685
+ const ctx = renderConfig.context;
3686
+ if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
3687
+ return ctx.linkClaim(attrs);
3688
+ }
3551
3689
  function decodeSSREntities(s) {
3552
3690
  return s.indexOf("&") < 0 ? s : s.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&amp;/g, "&");
3553
3691
  }
@@ -3773,10 +3911,13 @@ function applyRef(r, element) {
3773
3911
  Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
3774
3912
  }
3775
3913
  function generateHydrationScript({
3776
- eventNames = ["click", "input"],
3914
+ eventNames,
3777
3915
  nonce
3778
3916
  } = {}) {
3779
- 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-->`;
3917
+ return hydrationBootstrap(eventNames, scriptNonce(nonce), false);
3918
+ }
3919
+ function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
3920
+ 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)}),${ledger ? "s:{}," : ""}fe(){}});</script><!--xs-->`;
3780
3921
  }
3781
3922
  function queue(fn) {
3782
3923
  return Promise.resolve().then(fn);
@@ -3789,6 +3930,11 @@ function allSettled(promises) {
3789
3930
  return size;
3790
3931
  });
3791
3932
  }
3933
+ function shellEndMarker(context, renderId, nonce, noScripts) {
3934
+ if (noScripts || !context || !context.bootstrap) return "";
3935
+ const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
3936
+ return `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
3937
+ }
3792
3938
  function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
3793
3939
  const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
3794
3940
  const title = headTags ? headTags.title : null;
@@ -3979,6 +4125,10 @@ function tryResolveString(node, nested) {
3979
4125
  if (node.h && node.h.length > 0) return {
3980
4126
  merge: node
3981
4127
  };
4128
+ if (node[SLOT_VALUE] !== undefined) {
4129
+ ssrTextTail = false;
4130
+ return node.w();
4131
+ }
3982
4132
  if (node.t === undefined) {
3983
4133
  return "";
3984
4134
  }
@@ -4032,9 +4182,8 @@ function resolveSSRNode(node, result = {
4032
4182
  result.t[result.t.length - 1] += node.t;
4033
4183
  ssrTextTail = false;
4034
4184
  } else if (node[SLOT_VALUE] !== undefined) {
4035
- const text = escape(slotTextPosition());
4036
- result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + text : text;
4037
- ssrTextTail = true;
4185
+ result.t[result.t.length - 1] += node.w();
4186
+ ssrTextTail = false;
4038
4187
  } else ;
4039
4188
  } else if (t === "function") {
4040
4189
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
@@ -4087,6 +4236,14 @@ function configureServerErrors(config) {
4087
4236
  }
4088
4237
  (g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
4089
4238
  }
4239
+ function reportRequestFailure(error, event) {
4240
+ reportServerError(error, {
4241
+ kind: "request",
4242
+ handling: "failed",
4243
+ event
4244
+ }, null);
4245
+ if (ambientServerErrorHook() === undefined) console.error(error);
4246
+ }
4090
4247
  function getRequestEvent() {
4091
4248
  const store = globalThis[RequestContext];
4092
4249
  if (!store) return undefined;
@@ -4130,13 +4287,30 @@ function createHydrationWriter(context, isOpen) {
4130
4287
  };
4131
4288
  }
4132
4289
  function getHydrationWriter() {
4290
+ const ctx = currentRenderContext();
4291
+ return ctx && ctx.writer;
4292
+ }
4293
+ function currentRenderContext() {
4133
4294
  let ctx = renderContextOf(getOwner());
4134
4295
  if (!ctx) {
4135
4296
  const event = peekRequestEvent();
4136
4297
  const renders = event && eventRenders.get(event);
4137
4298
  if (renders && renders.size === 1) for (const c of renders) ctx = c;
4138
4299
  }
4139
- return ctx && ctx.writer;
4300
+ return ctx;
4301
+ }
4302
+ const LINK_STATE_RECORD = "links";
4303
+ function setLinkClaim(handler) {
4304
+ const ctx = currentRenderContext();
4305
+ if (!ctx) {
4306
+ return false;
4307
+ }
4308
+ ctx.linkClaim = handler;
4309
+ if (handler !== undefined) ctx.writer.write(LINK_STATE_RECORD, 1);
4310
+ return true;
4311
+ }
4312
+ function hasServerLinkState() {
4313
+ return false;
4140
4314
  }
4141
4315
  function takeHydrationValue(_key) {
4142
4316
  return undefined;
@@ -4257,10 +4431,13 @@ function copyInitHeaders(init) {
4257
4431
  for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
4258
4432
  return headers;
4259
4433
  }
4260
- const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
4261
- ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
4434
+ let stubGapFillExcluded;
4435
+ function isStubGapFillExcluded(key) {
4436
+ return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
4437
+ ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
4438
+ }
4262
4439
  function fillsStubGap(key, headers, response) {
4263
- if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
4440
+ if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
4264
4441
  if (response.body === null && (key === "content-type" || key === "content-length")) return false;
4265
4442
  return !headers.has(key);
4266
4443
  }
@@ -4352,7 +4529,7 @@ function createSSRResponse(result, event, options = {}) {
4352
4529
  closed = true;
4353
4530
  }
4354
4531
  };
4355
- result.pipe({
4532
+ const sink = {
4356
4533
  write(chunk) {
4357
4534
  if (!flushed) {
4358
4535
  flushed = true;
@@ -4367,6 +4544,7 @@ function createSSRResponse(result, event, options = {}) {
4367
4544
  status: getExpectedRedirectStatus(stub),
4368
4545
  headers: head.headers
4369
4546
  }));
4547
+ sink[ABANDON_RENDER]("redirect", true);
4370
4548
  return;
4371
4549
  }
4372
4550
  if (!head.headers.has("content-type")) {
@@ -4377,7 +4555,9 @@ function createSSRResponse(result, event, options = {}) {
4377
4555
  controller = c;
4378
4556
  },
4379
4557
  cancel() {
4558
+ if (closed) return;
4380
4559
  closed = true;
4560
+ sink[ABANDON_RENDER]("consumer");
4381
4561
  }
4382
4562
  }), {
4383
4563
  status: head.status,
@@ -4388,6 +4568,7 @@ function createSSRResponse(result, event, options = {}) {
4388
4568
  enqueue(transformChunk ? transformChunk(chunk) : chunk);
4389
4569
  },
4390
4570
  end() {
4571
+ if (!flushed) sink.write("");
4391
4572
  if (closed || !controller) return;
4392
4573
  const location = stub && stub.headers.get("Location");
4393
4574
  if (location && isHttpNavigationTarget(location)) {
@@ -4398,8 +4579,23 @@ function createSSRResponse(result, event, options = {}) {
4398
4579
  try {
4399
4580
  controller.close();
4400
4581
  } catch {}
4401
- }
4402
- });
4582
+ },
4583
+ [SHELL_ABANDONED]() {
4584
+ if (flushed) return;
4585
+ flushed = closed = true;
4586
+ if (stub) commitResponseStub(stub, {
4587
+ event
4588
+ });
4589
+ const head = deriveHead(stub, responseInit);
4590
+ const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
4591
+ resolve(new Response(null, {
4592
+ status,
4593
+ headers: head.headers
4594
+ }));
4595
+ },
4596
+ [ABANDON_RENDER]() {}
4597
+ };
4598
+ result.pipe(sink);
4403
4599
  });
4404
4600
  }
4405
4601
  function composeMiddleware(middlewares) {
@@ -4424,6 +4620,9 @@ function claimElement(node) {
4424
4620
  function claimElementTree(root) {
4425
4621
  return root;
4426
4622
  }
4623
+ function dispatchAsInteraction(_e, fn) {
4624
+ return fn();
4625
+ }
4427
4626
  function notSup() {
4428
4627
  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>.");
4429
4628
  }
@@ -4432,80 +4631,9 @@ setContainerTraceResolver(getProjectionTrace);
4432
4631
  setAsyncIterableSharer(shareAsyncIterable);
4433
4632
  const isServer = true;
4434
4633
  const isDev = false;
4634
+ const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4435
4635
  function dynamic(source, options) {
4436
- if (options?.static) {
4437
- const component = untrack(source);
4438
- if (typeof component === "function") return props => component(props);
4439
- if (typeof component === "string") return props => ssrElement(component, props, undefined, true);
4440
- return () => undefined;
4441
- }
4442
- const cached = createMemo(() => {
4443
- const next = source();
4444
- if (!next || typeof next.then !== "function") return next;
4445
- return {
4446
- [FLIGHT]: next
4447
- };
4448
- });
4449
- const deferStream = !!options?.deferStream;
4450
- return props => {
4451
- const ctx = sharedConfig.context;
4452
- let gated = !deferStream || !ctx?.async;
4453
- const value = createMemo(() => {
4454
- let c;
4455
- try {
4456
- c = cached();
4457
- } catch (err) {
4458
- if (!gated && err instanceof NotReadyError && !err.source?.$clientHole) {
4459
- gated = true;
4460
- ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
4461
- }
4462
- throw err;
4463
- }
4464
- if (!c || !c[FLIGHT]) return c;
4465
- const next = c[FLIGHT];
4466
- return {
4467
- then: (onFulfilled, onRejected) => next.then(resolved => {
4468
- let landed;
4469
- try {
4470
- landed = classifyLanding(resolved);
4471
- } catch (err) {
4472
- if (onRejected) return onRejected(err);
4473
- throw err;
4474
- }
4475
- return onFulfilled ? onFulfilled(landed) : landed;
4476
- }, onRejected)
4477
- };
4478
- }, {
4479
- deferStream
4480
- });
4481
- return createMemo(() => {
4482
- const c = value();
4483
- if (c) {
4484
- if (typeof c === "function") return c(props);
4485
- if (typeof c === "string") {
4486
- return ssrElement(c, props, undefined, true);
4487
- }
4488
- }
4489
- }, {
4490
- sync: true
4491
- });
4492
- };
4493
- }
4494
- const FLIGHT = Symbol("solid.dynamic-flight");
4495
- const SERVER_COMPONENT = Symbol.for("solid.server-component");
4496
- function classifyLanding(resolved) {
4497
- if (typeof resolved !== "function" || SERVER_COMPONENT in resolved) return resolved;
4498
- const message = "[DYNAMIC_ASYNC_COMPONENT] An async dynamic() source resolved to a client component function";
4499
- recordFinding({
4500
- code: "DYNAMIC_ASYNC_COMPONENT",
4501
- kind: "ssr",
4502
- severity: "error",
4503
- message,
4504
- data: {
4505
- component: resolved.name || undefined
4506
- }
4507
- }, null);
4508
- throw new Error(message);
4636
+ return dynamicCore(source, options, ssrTag);
4509
4637
  }
4510
4638
  function Dynamic(props) {
4511
4639
  const Comp = dynamic(() => props.component);
@@ -4635,4 +4763,4 @@ function httpHeader(name, value, options) {
4635
4763
  }
4636
4764
  }
4637
4765
 
4638
- 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 };
4766
+ 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, 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, hasServerLinkState, 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, setLinkClaim, notSup as setProperty, notSup as setStyleProperty, slotValue, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, styleNonce, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };