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

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 (58) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +475 -591
  3. package/dist/server.js +459 -489
  4. package/dist/server.observe.js +459 -498
  5. package/dist/web.dev.js +206 -220
  6. package/dist/web.js +196 -208
  7. package/dist/web.observe.js +206 -213
  8. package/frames/dist/client.dev.js +664 -643
  9. package/frames/dist/client.js +593 -582
  10. package/frames/dist/client.observe.js +624 -589
  11. package/frames/dist/regions.js +43 -2
  12. package/frames/dist/server.dev.js +578 -450
  13. package/frames/dist/server.js +578 -397
  14. package/frames/dist/server.observe.js +578 -397
  15. package/frames/dist/trace.js +4 -1
  16. package/frames/dist/wire.js +371 -6
  17. package/package.json +13 -13
  18. package/serialization/dist/decode.js +11 -9
  19. package/serialization/dist/serialization.js +11 -9
  20. package/serialization/types/serializer-decode.d.ts +2 -2
  21. package/server-functions/dist/client.dev.js +5 -2
  22. package/server-functions/dist/client.js +3 -2
  23. package/server-functions/dist/client.observe.js +5 -2
  24. package/server-functions/dist/rich-args.js +33 -1
  25. package/server-functions/dist/server.dev.js +218 -35
  26. package/server-functions/dist/server.js +218 -35
  27. package/server-functions/dist/server.observe.js +218 -35
  28. package/skills/server-components/SKILL.md +74 -185
  29. package/types/client.d.ts +112 -10
  30. package/types/constants.d.ts +2 -1
  31. package/types/frames/assets-tier.d.ts +2 -2
  32. package/types/frames/client.d.ts +8 -3
  33. package/types/frames/frame-client.d.ts +121 -157
  34. package/types/frames/frame-morph.d.ts +28 -0
  35. package/types/frames/frame-sink.d.ts +13 -9
  36. package/types/frames/frame-transport.d.ts +30 -1
  37. package/types/frames/regions-tier.d.ts +15 -0
  38. package/types/frames/serializer-decode.d.ts +2 -2
  39. package/types/frames/server.d.ts +1 -53
  40. package/types/frames/wire-tier.d.ts +54 -1
  41. package/types/head.d.ts +1 -0
  42. package/types/index.d.ts +57 -50
  43. package/types/index.server.d.ts +3 -27
  44. package/types/jsx.d.ts +14 -17
  45. package/types/observe.d.ts +14 -7
  46. package/types/render.d.ts +3 -1
  47. package/types/response.d.ts +31 -8
  48. package/types/serializer-decode.d.ts +2 -2
  49. package/types/server-functions/argument-codec.d.ts +21 -0
  50. package/types/server-functions/client.d.ts +18 -5
  51. package/types/server-functions/server.d.ts +6 -2
  52. package/types/server-functions/shared.d.ts +19 -0
  53. package/types/server-mock.d.ts +9 -2
  54. package/types/server-observe.d.ts +3 -2
  55. package/types/server.d.ts +124 -67
  56. package/frames/dist/bind.dev.js +0 -326
  57. package/frames/dist/bind.js +0 -295
  58. package/types/frames/bind-tier.d.ts +0 -60
@@ -1,7 +1,7 @@
1
- import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, 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, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
4
- export { ssrScope as scope, sharedConfig } from 'solid-js/internal';
1
+ import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, 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, beginEdgesRender, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
4
+ export { ssrScope as scope } from 'solid-js/internal';
5
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
 
@@ -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",
@@ -127,11 +128,9 @@ function parseTraceparent(value) {
127
128
  };
128
129
  }
129
130
  function randomHex(bytes) {
130
- const buffer = new Uint8Array(bytes);
131
- crypto.getRandomValues(buffer);
132
131
  let out = "";
133
- for (let i = 0; i < buffer.length; i++) out += (buffer[i] < 16 ? "0" : "") + buffer[i].toString(16);
134
- return out;
132
+ for (let i = 0; i < bytes; i += 4) out += (Math.random() * 0x100000000 >>> 0).toString(16).padStart(8, "0");
133
+ return out.length === bytes * 2 ? out : out.slice(0, bytes * 2);
135
134
  }
136
135
  function randomTraceId() {
137
136
  let id = randomHex(16);
@@ -469,9 +468,7 @@ function toBorderForm(value, envelopeContainers) {
469
468
  }
470
469
  function isShareableIterable(value) {
471
470
  try {
472
- if (value.__SEROVAL_STREAM__ === true) return false;
473
- if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) return false;
474
- return typeof value[Symbol.asyncIterator] === "function";
471
+ return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
475
472
  } catch {
476
473
  return false;
477
474
  }
@@ -576,17 +573,24 @@ function getLocalHeaderScript(id) {
576
573
  }
577
574
 
578
575
  const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
579
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
580
- const ResponseEnvelope = /* @__PURE__ */(() => {
581
- class ResponseEnvelope {
582
- constructor(response, value) {
583
- this.response = response;
584
- this.value = value;
585
- }
576
+ let EnvelopeClass;
577
+ const ResponseEnvelope = function ResponseEnvelope(response, value) {
578
+ if (!EnvelopeClass) {
579
+ EnvelopeClass = class extends Response {
580
+ constructor(response, value) {
581
+ super(response ? response.body : null, response && {
582
+ status: response.status,
583
+ statusText: response.statusText,
584
+ headers: copyHeaders(response.headers)
585
+ });
586
+ this.response = response ? this : undefined;
587
+ this.value = value;
588
+ }
589
+ };
590
+ EnvelopeClass.prototype[ENVELOPE] = true;
586
591
  }
587
- ResponseEnvelope.prototype[ENVELOPE] = true;
588
- return ResponseEnvelope;
589
- })();
592
+ return new EnvelopeClass(response, value);
593
+ };
590
594
  function isResponseEnvelope(value) {
591
595
  return !!(value && typeof value === "object" && value[ENVELOPE]);
592
596
  }
@@ -611,6 +615,16 @@ function isSafeError(value) {
611
615
  const REVALIDATE_HEADER = "X-Revalidate";
612
616
  const REVALIDATE_ALL = "*";
613
617
  const RESPONSE_HEADER_VALUE_LIMIT = 4096;
618
+ function copyHeaders(init) {
619
+ const source = init;
620
+ if (!source || !source.getSetCookie) return new Headers(init);
621
+ const headers = new Headers();
622
+ source.forEach((value, key) => {
623
+ if (key !== "set-cookie") headers.append(key, value);
624
+ });
625
+ for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
626
+ return headers;
627
+ }
614
628
  function initWithRevalidate(init = {}) {
615
629
  const resolved = typeof init === "number" ? {
616
630
  status: init
@@ -619,18 +633,7 @@ function initWithRevalidate(init = {}) {
619
633
  revalidate,
620
634
  ...responseInit
621
635
  } = resolved;
622
- let headers;
623
- if (responseInit.headers && responseInit.headers.getSetCookie) {
624
- headers = new Headers();
625
- responseInit.headers.forEach((value, key) => {
626
- if (key !== "set-cookie") headers.append(key, value);
627
- });
628
- for (const cookie of responseInit.headers.getSetCookie()) {
629
- headers.append("Set-Cookie", cookie);
630
- }
631
- } else {
632
- headers = new Headers(responseInit.headers);
633
- }
636
+ const headers = copyHeaders(responseInit.headers);
634
637
  if (revalidate !== undefined) {
635
638
  const list = Array.isArray(revalidate) ? revalidate : [revalidate];
636
639
  if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
@@ -694,7 +697,12 @@ function respond(value, init = {}) {
694
697
  }), value);
695
698
  }
696
699
  headers.set("Content-Type", "application/json");
697
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
700
+ return new ResponseEnvelope(new Response(new ReadableStream({
701
+ pull(controller) {
702
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
703
+ controller.close();
704
+ }
705
+ }), {
698
706
  ...responseInit,
699
707
  headers
700
708
  }), value);
@@ -858,6 +866,10 @@ function qualifierValue(name, value) {
858
866
  function asciiLowerCase(value) {
859
867
  return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
860
868
  }
869
+ const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
870
+ function headBodyText(tag, props, text) {
871
+ return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
872
+ }
861
873
  function resourceIdentity(tag, props) {
862
874
  const url = String(props.href || props.src || "");
863
875
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
@@ -1557,6 +1569,7 @@ function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMet
1557
1569
  noScripts
1558
1570
  };
1559
1571
  }
1572
+ let headBodyHook;
1560
1573
  function flushHeadFragment(registry, boundary, nonce) {
1561
1574
  const groups = commitHeadBoundary(registry, boundary);
1562
1575
  if (!groups.length) return null;
@@ -1595,7 +1608,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1595
1608
  if (value) attrs.nonce = String(value);
1596
1609
  }
1597
1610
  const children = t.props.children;
1598
- ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
1611
+ ops.push(["a", identity, t.tag, attrs, children == null ? null : headBodyHook ? headBodyHook(t.tag, t.props, String(children)) : String(children)]);
1599
1612
  }
1600
1613
  }
1601
1614
  return ops.length ? ops : null;
@@ -1623,16 +1636,9 @@ function normalizeNonce(nonce) {
1623
1636
  }
1624
1637
  function destinationNonce(nonce, destination) {
1625
1638
  if (nonce == null) return undefined;
1626
- if (typeof nonce === "string") return nonce || undefined;
1627
- const value = nonce[destination];
1639
+ const value = typeof nonce === "string" ? nonce : nonce[destination];
1628
1640
  return typeof value === "string" && value ? value : undefined;
1629
1641
  }
1630
- function scriptNonce(nonce) {
1631
- return destinationNonce(nonce, "script");
1632
- }
1633
- function styleNonce(nonce) {
1634
- return destinationNonce(nonce, "style");
1635
- }
1636
1642
  function hasNonceProp(props) {
1637
1643
  for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
1638
1644
  return false;
@@ -1699,6 +1705,7 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
1699
1705
  if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
1700
1706
  if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
1701
1707
  let body = props.children == null ? "" : String(props.children);
1708
+ if (headBodyHook) body = headBodyHook(tag, props, body);
1702
1709
  if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
1703
1710
  return `<${tag}${attrs}>${body}</${tag}>`;
1704
1711
  }
@@ -1708,6 +1715,7 @@ function useHead(tags) {
1708
1715
  headTagInvalid("outside-render", "useHead() called outside of a server render; registration ignored.");
1709
1716
  return;
1710
1717
  }
1718
+ headBodyHook = headBodyText;
1711
1719
  ctx.registerHeadTags(tags);
1712
1720
  }
1713
1721
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
@@ -1718,12 +1726,27 @@ function tagInfo(tag) {
1718
1726
  let info = tagInfos.get(tag);
1719
1727
  if (info === undefined) {
1720
1728
  if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
1729
+ let formDefaults, formAttributes;
1730
+ if (tag === "input" || tag === "option") {
1731
+ formDefaults = Object.create(null);
1732
+ formAttributes = Object.create(null);
1733
+ const state = DOMWithState[tag.toUpperCase()];
1734
+ for (const prop in state) {
1735
+ if (state[prop] === 2) {
1736
+ const attr = prop.slice(7).toLowerCase();
1737
+ formDefaults[attr] = prop;
1738
+ formAttributes[prop] = attr;
1739
+ }
1740
+ }
1741
+ }
1721
1742
  info = {
1722
1743
  open: "<" + tag,
1723
1744
  close: "</" + tag + ">",
1724
1745
  isVoid: VOID_ELEMENTS.test(tag),
1725
1746
  textarea: tag === "textarea",
1726
- raw: tag === "script" || tag === "style"
1747
+ raw: tag === "script" || tag === "style",
1748
+ formDefaults,
1749
+ formAttributes
1727
1750
  };
1728
1751
  if (tagInfos.size < 512) tagInfos.set(tag, info);
1729
1752
  }
@@ -1746,6 +1769,8 @@ function renderToString(code, options = {}) {
1746
1769
  onHead
1747
1770
  } = options;
1748
1771
  const nonce = normalizeNonce(options.nonce);
1772
+ const requestEvent = peekRequestEvent();
1773
+ const errorScope = requestEvent || {};
1749
1774
  let scripts = "";
1750
1775
  const serializer = createHydrationSerializer({
1751
1776
  scopeId: renderId,
@@ -1768,6 +1793,7 @@ function renderToString(code, options = {}) {
1768
1793
  resolve: resolveSSRNode,
1769
1794
  ssr: ssr,
1770
1795
  errorPolicy: options.onError,
1796
+ _errorScope: errorScope,
1771
1797
  registerHeadTags(tags) {
1772
1798
  registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
1773
1799
  },
@@ -1802,7 +1828,6 @@ function renderToString(code, options = {}) {
1802
1828
  registerEntryAssets(manifest);
1803
1829
  const context = sharedConfig.context;
1804
1830
  context.writer = createHydrationWriter(context, () => !closed);
1805
- const requestEvent = peekRequestEvent();
1806
1831
  if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1807
1832
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
1808
1833
  const render = timeDocument(context, context.trace, "string", requestEvent);
@@ -1822,7 +1847,7 @@ function renderToString(code, options = {}) {
1822
1847
  closed = true;
1823
1848
  serializer.close();
1824
1849
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1825
- const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
1850
+ const document = withShellEnd(assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead), context, renderId, nonce, noScripts);
1826
1851
  if (render) render.shell();
1827
1852
  if (requestEvent && requestEvent.response) {
1828
1853
  commitResponseStub(requestEvent.response, {
@@ -1835,7 +1860,7 @@ function renderToString(code, options = {}) {
1835
1860
  reportServerError(err, {
1836
1861
  kind: "render",
1837
1862
  handling: "failed"
1838
- }, null, options.onError);
1863
+ }, null, options.onError, errorScope);
1839
1864
  throw err;
1840
1865
  } finally {
1841
1866
  if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
@@ -1857,6 +1882,7 @@ function renderToStream(code, options = {}) {
1857
1882
  const nonce = normalizeNonce(options.nonce);
1858
1883
  const requestEvent = peekRequestEvent();
1859
1884
  if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1885
+ const errorScope = requestEvent || {};
1860
1886
  let dispose;
1861
1887
  let dead = false;
1862
1888
  let render;
@@ -1911,7 +1937,15 @@ function renderToStream(code, options = {}) {
1911
1937
  if (dispose) {
1912
1938
  const d = dispose;
1913
1939
  dispose = () => {};
1914
- d();
1940
+ try {
1941
+ d();
1942
+ } catch (err) {
1943
+ reportServerError(err, {
1944
+ kind: "render",
1945
+ handling: "failed"
1946
+ }, null, options.onError, errorScope);
1947
+ if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
1948
+ }
1915
1949
  }
1916
1950
  if (serializer && typeof serializer.close === "function") {
1917
1951
  try {
@@ -1920,7 +1954,7 @@ function renderToStream(code, options = {}) {
1920
1954
  reportServerError(err, {
1921
1955
  kind: "render",
1922
1956
  handling: "serialize"
1923
- }, null, options.onError);
1957
+ }, null, options.onError, errorScope);
1924
1958
  }
1925
1959
  }
1926
1960
  serializer = abandonedSerializer;
@@ -1937,7 +1971,7 @@ function renderToStream(code, options = {}) {
1937
1971
  reportServerError(err, {
1938
1972
  kind: "render",
1939
1973
  handling: "failed"
1940
- }, null, options.onError);
1974
+ }, null, options.onError, errorScope);
1941
1975
  if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
1942
1976
  abandon();
1943
1977
  };
@@ -2002,6 +2036,18 @@ function renderToStream(code, options = {}) {
2002
2036
  const canBatchStubs = !options.serializer && !options.sink;
2003
2037
  let stubBatch = null;
2004
2038
  const STUB_BATCH_KEY = "$B";
2039
+ let stableOrder = false;
2040
+ let parkedWrites = null;
2041
+ const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
2042
+ const write = (id, value) => {
2043
+ if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else serializer.write(id, value);
2044
+ };
2045
+ const flushParkedWrites = () => {
2046
+ if (!parkedWrites) return;
2047
+ const writes = parkedWrites.sort(byKey);
2048
+ parkedWrites = null;
2049
+ for (let i = 0; i < writes.length; i++) serializer.write(writes[i][0], writes[i][1]);
2050
+ };
2005
2051
  const flushStubBatch = () => {
2006
2052
  if (!stubBatch) return;
2007
2053
  const batch = stubBatch;
@@ -2012,7 +2058,9 @@ function renderToStream(code, options = {}) {
2012
2058
  return;
2013
2059
  }
2014
2060
  const obj = {};
2015
- for (const [id, p] of batch) obj[id] = p;
2061
+ const entries = [...batch];
2062
+ if (stableOrder) entries.sort(byKey);
2063
+ for (const [id, p] of entries) obj[id] = p;
2016
2064
  serializer.write(STUB_BATCH_KEY, obj);
2017
2065
  pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
2018
2066
  };
@@ -2084,7 +2132,7 @@ function renderToStream(code, options = {}) {
2084
2132
  }
2085
2133
  },
2086
2134
  shell(shellHtml, meta) {
2087
- buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
2135
+ buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
2088
2136
  },
2089
2137
  ...options.sink
2090
2138
  };
@@ -2112,6 +2160,7 @@ function renderToStream(code, options = {}) {
2112
2160
  end();
2113
2161
  }
2114
2162
  flushStubBatch();
2163
+ flushParkedWrites();
2115
2164
  serializer.flush();
2116
2165
  }));
2117
2166
  }
@@ -2120,7 +2169,7 @@ function renderToStream(code, options = {}) {
2120
2169
  const pendingSerialized = new Map();
2121
2170
  const guardedChannels = new WeakMap();
2122
2171
  const verdictNow = error => {
2123
- throw ssrSanitizeError(error, null);
2172
+ throw ssrSanitizeError(error, null, undefined, undefined, errorScope);
2124
2173
  };
2125
2174
  const borderForm = value => toBorderForm(value);
2126
2175
  const guardIterable = iterable => ({
@@ -2268,6 +2317,7 @@ function renderToStream(code, options = {}) {
2268
2317
  async: true,
2269
2318
  nonce: options.nonce,
2270
2319
  document: !options.sink,
2320
+ edges: !!options.plugins && options.plugins.some(p => p.tag === "solid/server-component"),
2271
2321
  live: {},
2272
2322
  registerHeadTags(tags) {
2273
2323
  registerHeadTags(headRegistry, context, tracking,
@@ -2333,7 +2383,7 @@ function renderToStream(code, options = {}) {
2333
2383
  if (p && typeof p === "object" && typeof p.then === "function") {
2334
2384
  if (!firstFlushed && deferStream) {
2335
2385
  blockingPromises.add(p);
2336
- p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
2386
+ p.then(d => write(id, d)).catch(e => write(id, e));
2337
2387
  return;
2338
2388
  }
2339
2389
  p = trackSerialized(id, p);
@@ -2342,7 +2392,7 @@ function renderToStream(code, options = {}) {
2342
2392
  return;
2343
2393
  }
2344
2394
  }
2345
- serializer.write(id, p);
2395
+ write(id, p);
2346
2396
  },
2347
2397
  escape: escape,
2348
2398
  resolve: resolveSSRNode,
@@ -2373,11 +2423,11 @@ function renderToStream(code, options = {}) {
2373
2423
  defuse(p);
2374
2424
  registry.set(key, {
2375
2425
  resolve: err => queue(() => queue(() => {
2376
- err ? reject(ssrSanitizeError(err, null)) : resolve(true);
2426
+ err ? reject(ssrSanitizeError(err, null, undefined, undefined, errorScope)) : resolve(true);
2377
2427
  queue(flushEnd);
2378
2428
  }))
2379
2429
  });
2380
- if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
2430
+ if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else write(key + "_fr", p);
2381
2431
  }
2382
2432
  return (value, error, escaped) => {
2383
2433
  if (registry.has(key)) {
@@ -2385,7 +2435,7 @@ function renderToStream(code, options = {}) {
2385
2435
  registry.delete(key);
2386
2436
  if (error) abandonSubtree(key, error);
2387
2437
  if (error && escaped) {
2388
- const wire = ssrSanitizeError(error, null);
2438
+ const wire = ssrSanitizeError(error, null, undefined, undefined, errorScope);
2389
2439
  const message = wire instanceof Error ? wire.message : String(wire);
2390
2440
  if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
2391
2441
  }
@@ -2419,7 +2469,7 @@ function renderToStream(code, options = {}) {
2419
2469
  sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
2420
2470
  styles,
2421
2471
  revealGroup,
2422
- error: error ? ssrSanitizeError(error, null) : error
2472
+ error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
2423
2473
  });
2424
2474
  item.resolve(error);
2425
2475
  }
@@ -2446,6 +2496,7 @@ function renderToStream(code, options = {}) {
2446
2496
  applyAssetTracking(context, tracking, manifest, noScripts);
2447
2497
  context.failRender = failRender;
2448
2498
  context.errorPolicy = options.onError;
2499
+ context._errorScope = errorScope;
2449
2500
  context.flushed = () => firstFlushed;
2450
2501
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
2451
2502
  render = timeDocument(context, context.trace, "stream", requestEvent);
@@ -2453,40 +2504,48 @@ function renderToStream(code, options = {}) {
2453
2504
  context.writer = createHydrationWriter(context, () => !completed);
2454
2505
  const signal = options.signal;
2455
2506
  const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
2456
- let html = createRoot(d => {
2457
- dispose = () => {
2458
- context.trace = undefined;
2459
- if (onAbort) signal.removeEventListener("abort", onAbort);
2460
- d();
2461
- };
2462
- rootOwner = claimRenderRoot(context);
2463
- if (requestEvent) claimEventRender(requestEvent, context);
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
- }
2474
- if (!res.h.length) return res.t[0];
2475
- rootHoles = [];
2476
- let out = res.t[0];
2477
- for (let i = 0; i < res.h.length; i++) {
2478
- const id = nextHoleId++;
2479
- rootHoles.push({
2480
- id,
2481
- fn: res.h[i]
2482
- });
2483
- out += `<!--rh${id}-->` + res.t[i + 1];
2484
- }
2485
- for (const p of res.p) blockingPromises.add(p);
2486
- return out;
2487
- }, {
2488
- id: renderId
2489
- });
2507
+ const endEdges = context.edges ? beginEdgesRender() : undefined;
2508
+ let html;
2509
+ try {
2510
+ html = createRoot(d => {
2511
+ dispose = () => {
2512
+ context.trace = undefined;
2513
+ if (onAbort) signal.removeEventListener("abort", onAbort);
2514
+ if (endEdges) endEdges();
2515
+ d();
2516
+ };
2517
+ rootOwner = claimRenderRoot(context);
2518
+ if (requestEvent) claimEventRender(requestEvent, context);
2519
+ let res;
2520
+ try {
2521
+ res = resolveSSRNode(escape(code()));
2522
+ } catch (err) {
2523
+ reportServerError(err, {
2524
+ kind: "render",
2525
+ handling: "failed"
2526
+ }, null, options.onError, errorScope);
2527
+ throw err;
2528
+ }
2529
+ if (!res.h.length) return res.t[0];
2530
+ rootHoles = [];
2531
+ let out = res.t[0];
2532
+ for (let i = 0; i < res.h.length; i++) {
2533
+ const id = nextHoleId++;
2534
+ rootHoles.push({
2535
+ id,
2536
+ fn: res.h[i]
2537
+ });
2538
+ out += `<!--rh${id}-->` + res.t[i + 1];
2539
+ }
2540
+ for (const p of res.p) blockingPromises.add(p);
2541
+ return out;
2542
+ }, {
2543
+ id: renderId
2544
+ });
2545
+ } catch (err) {
2546
+ if (endEdges) endEdges();
2547
+ throw err;
2548
+ }
2490
2549
  if (onAbort) {
2491
2550
  if (signal.aborted) onAbort();else signal.addEventListener("abort", onAbort, {
2492
2551
  once: true
@@ -2565,21 +2624,30 @@ function renderToStream(code, options = {}) {
2565
2624
  let lastBlockingSize = -1;
2566
2625
  let lastRegistrySize = -1;
2567
2626
  let drainTurn = 0;
2627
+ let graced = false;
2568
2628
  const scheduleFlush = (fn, awaited) => {
2569
2629
  const attempt = () => {
2570
- flushStubBatch();
2630
+ if (!stableOrder) flushStubBatch();
2571
2631
  if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
2572
2632
  if (registry.size !== lastRegistrySize) drainTurn = 0;
2573
2633
  lastRegistrySize = registry.size;
2574
2634
  queue(attempt);
2575
2635
  return;
2576
2636
  }
2637
+ if (!graced && registry.size) {
2638
+ graced = true;
2639
+ lastRegistrySize = -1;
2640
+ drainTurn = 0;
2641
+ deferFlush(attempt);
2642
+ return;
2643
+ }
2577
2644
  fn();
2578
2645
  };
2579
2646
  const progressed = awaited !== lastBlockingSize;
2580
2647
  lastBlockingSize = awaited;
2581
2648
  lastRegistrySize = -1;
2582
2649
  drainTurn = 0;
2650
+ graced = false;
2583
2651
  progressed ? queue(attempt) : setTimeout(attempt);
2584
2652
  };
2585
2653
  let cachedReadable;
@@ -2646,6 +2714,7 @@ function renderToStream(code, options = {}) {
2646
2714
  };
2647
2715
  return {
2648
2716
  then(onFulfilled, onRejected) {
2717
+ if (canBatchStubs) stableOrder = true;
2649
2718
  const freezeHead = () => {
2650
2719
  if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response, {
2651
2720
  event: requestEvent
@@ -2736,11 +2805,15 @@ function renderToStream(code, options = {}) {
2736
2805
  };
2737
2806
  }
2738
2807
  function HydrationScript(props) {
2739
- const nonce = scriptNonce(sharedConfig.context && sharedConfig.context.nonce);
2740
- return ssr(generateHydrationScript({
2741
- nonce,
2808
+ if (sharedConfig.context) sharedConfig.context.bootstrap = true;
2809
+ const {
2810
+ eventNames,
2811
+ nonce
2812
+ } = {
2813
+ nonce: sharedConfig.context && sharedConfig.context.nonce,
2742
2814
  ...props
2743
- }));
2815
+ };
2816
+ return ssr(hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), true));
2744
2817
  }
2745
2818
  function ssrGroup(fn, n) {
2746
2819
  fn.$g = n;
@@ -2829,8 +2902,8 @@ function ssrGroupSlot(fn, idx) {
2829
2902
  }
2830
2903
  };
2831
2904
  }
2832
- function wireErrorMessage(err) {
2833
- const wire = ssrSanitizeError(err, null);
2905
+ function wireErrorMessage(err, scope) {
2906
+ const wire = ssrSanitizeError(err, null, undefined, undefined, scope);
2834
2907
  return String(wire && wire.message || wire);
2835
2908
  }
2836
2909
  const holePositionCache = new WeakMap();
@@ -2892,28 +2965,89 @@ function holeContentPositions(t) {
2892
2965
  holePositionCache.set(t, cached);
2893
2966
  return cached;
2894
2967
  }
2895
- function createLiveHoles(sink, scoped) {
2968
+ function createLiveHoles(sink, scoped, settled, errorScope) {
2896
2969
  let nextId = 0;
2897
2970
  const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
2898
2971
  const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
2899
- const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
2972
+ const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
2973
+ const latched = (owner, cause, content) => {
2974
+ devCheck({
2975
+ code: "SSR_LIVE_HOLE_LATCHED",
2976
+ kind: "ssr",
2977
+ severity: "warn",
2978
+ message: cause === "records" ? `[SSR_LIVE_HOLE_LATCHED] A live attribute stopped updating: re-running it ` + `called a slot, which places a client component in markup, not in an ` + `attribute, so it keeps the value it last sent. Call the slot in the ` + `element's content instead.` : `[SSR_LIVE_HOLE_LATCHED] A live ${content ? "markup hole" : "attribute"} stopped updating: ` + `re-running it created a reactive scope that waits on async work (a memo over a fetch or a stream), ` + `so it cannot re-run and keeps the markup it last sent. ` + `Create async sources outside markup that re-renders from a live source ` + `(in the component body, not inside the hole's expression).`,
2979
+ data: {
2980
+ cause
2981
+ }
2982
+ }, owner);
2983
+ };
2900
2984
  const swept = (owner, ctx, fn) => {
2901
2985
  const prev = sharedConfig.context;
2902
2986
  sharedConfig.context = ctx;
2987
+ let dispose;
2988
+ let before;
2989
+ const run = () => createRoot(d => {
2990
+ dispose = d;
2991
+ before = stamp();
2992
+ return fn();
2993
+ }, {
2994
+ transparent: true
2995
+ });
2903
2996
  try {
2904
- return owner ? runWithOwner(owner, fn) : fn();
2997
+ return owner ? runWithOwner(owner, run) : run();
2905
2998
  } finally {
2906
2999
  sharedConfig.context = prev;
3000
+ engine.sweptOwners = before !== undefined && stamp() !== before;
3001
+ if (dispose) dispose();
2907
3002
  }
2908
3003
  };
3004
+ const stripRow = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"|<!--lr-->/g, "");
3005
+ const rowsOf = v => Array.isArray(v) && v.$rows ? v : null;
3006
+ function holeValue(hole) {
3007
+ const b = hole.$lhBinding;
3008
+ if (b) {
3009
+ const v = hole();
3010
+ return b.fn && rowsOf(b.fn()) || v;
3011
+ }
3012
+ if (!hole.$fn) return hole();
3013
+ const v = hole.$fn();
3014
+ return rowsOf(v) || escape(v);
3015
+ }
3016
+ function resolveValue(value, res) {
3017
+ if (!Array.isArray(value) || !value.$rows) {
3018
+ resolveSSRNode(value, res);
3019
+ return null;
3020
+ }
3021
+ let rows = [];
3022
+ for (const row of value) {
3023
+ const r = resolveSSRNode(escape(row));
3024
+ res.t[res.t.length - 1] += "<!--lr-->" + r.t[0];
3025
+ if (r.h.length) {
3026
+ res.t.push(...r.t.slice(1));
3027
+ res.h.push(...r.h);
3028
+ res.p.push(...r.p);
3029
+ rows = null;
3030
+ } else if (rows) rows.push(engine.sweeping ? r.t[0] : stripRow(r.t[0]));
3031
+ }
3032
+ return rows;
3033
+ }
3034
+ function rowOps(last, rows) {
3035
+ const ops = [];
3036
+ for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) ops.push([i, rows[i]]);
3037
+ return ops.length < rows.length ? {
3038
+ n: rows.length,
3039
+ r: ops
3040
+ } : null;
3041
+ }
2909
3042
  function resolveHoleValue(hole) {
2910
3043
  const result = {
2911
3044
  t: [""],
2912
3045
  h: [],
2913
- p: []
3046
+ p: [],
3047
+ rows: null
2914
3048
  };
2915
3049
  try {
2916
- resolveSSRNode(hole(), result);
3050
+ result.rows = resolveValue(holeValue(hole), result);
2917
3051
  } catch (err) {
2918
3052
  const wrap = buildAsyncWrap(err, hole);
2919
3053
  if (!wrap) throw err;
@@ -2931,12 +3065,88 @@ function createLiveHoles(sink, scoped) {
2931
3065
  }
2932
3066
  b.children.length = 0;
2933
3067
  }
3068
+ let tops = 0;
3069
+ const ids = new Map();
3070
+ const scopeFor = hole => {
3071
+ const p = engine.scope;
3072
+ return {
3073
+ id: undefined,
3074
+ p,
3075
+ i: p ? p.c++ : tops++,
3076
+ n: null,
3077
+ c: 0,
3078
+ h: hole
3079
+ };
3080
+ };
3081
+ const scopeId = s => s.id !== undefined ? s.id : s.id = s.p ? scopeId(s.p) + "." + s.i : String(s.i);
3082
+ const collect = (v, id, forget) => (v.occ || (v.occ = new Map())).set(id, forget);
3083
+ function rescope(b, hole, fn) {
3084
+ const prevScope = engine.scope;
3085
+ const prevVisit = engine.visit;
3086
+ engine.scope = {
3087
+ id: scopeId(b.scope),
3088
+ p: null,
3089
+ i: 0,
3090
+ n: null,
3091
+ c: 0,
3092
+ h: hole
3093
+ };
3094
+ const visit = engine.visit = {
3095
+ occ: null
3096
+ };
3097
+ try {
3098
+ return fn();
3099
+ } finally {
3100
+ engine.scope = prevScope;
3101
+ engine.visit = prevVisit;
3102
+ b.next = visit.occ;
3103
+ }
3104
+ }
3105
+ function settleOccurrences(b) {
3106
+ const occ = b.next;
3107
+ b.next = null;
3108
+ if (b.occ) for (const [id, forget] of b.occ) if (!occ || !occ.has(id)) forget();
3109
+ b.occ = occ;
3110
+ if (occ) for (let a = b.up; a; a = a.up) for (const [id, forget] of occ) collect(a, id, forget);
3111
+ }
3112
+ function leave(b, parent, scope, visit) {
3113
+ engine.parent = parent;
3114
+ engine.scope = scope;
3115
+ engine.visit = visit;
3116
+ if (visit && b.occ) for (const [id, forget] of b.occ) collect(visit, id, forget);
3117
+ }
2934
3118
  const engine = {
2935
3119
  suppressed: 0,
2936
3120
  sweeping: false,
2937
3121
  parent: null,
2938
- recordStamp: 0,
2939
3122
  gateHit: false,
3123
+ sweptOwners: false,
3124
+ scope: null,
3125
+ visit: null,
3126
+ dry: false,
3127
+ slotId(prop, given) {
3128
+ const s = engine.scope;
3129
+ if (!s) return given;
3130
+ const n = s.n || (s.n = Object.create(null));
3131
+ const i = n[prop] || 0;
3132
+ n[prop] = i + 1;
3133
+ const sid = scopeId(s);
3134
+ const at = sid + "." + i + "\0" + prop;
3135
+ if (given !== undefined) {
3136
+ ids.set(at, given);
3137
+ return given;
3138
+ }
3139
+ return ids.get(at) || `${prop}#~${sid}.${i}`;
3140
+ },
3141
+ seen(id, forget) {
3142
+ if (engine.visit) collect(engine.visit, id, forget);
3143
+ },
3144
+ nest(hole) {
3145
+ const s = engine.scope;
3146
+ if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
3147
+ engine.scope = scopeFor(hole);
3148
+ return s;
3149
+ },
2940
3150
  content(hole) {
2941
3151
  if (hole.$lhSuppress) {
2942
3152
  const r = {
@@ -2944,10 +3154,12 @@ function createLiveHoles(sink, scoped) {
2944
3154
  h: [],
2945
3155
  p: []
2946
3156
  };
2947
- engine.suppressed++;
2948
- try {
3157
+ let rows = null;
3158
+ const b = hole.$lhBinding;
3159
+ const run = () => {
3160
+ engine.suppressed++;
2949
3161
  try {
2950
- resolveSSRNode(hole(), r);
3162
+ rows = resolveValue(holeValue(hole), r);
2951
3163
  } catch (err) {
2952
3164
  const wrap = buildAsyncWrap(err, hole);
2953
3165
  if (wrap) {
@@ -2955,20 +3167,21 @@ function createLiveHoles(sink, scoped) {
2955
3167
  r.p.push(wrap.p);
2956
3168
  r.t.push("");
2957
3169
  }
3170
+ } finally {
3171
+ engine.suppressed--;
2958
3172
  }
2959
- } finally {
2960
- engine.suppressed--;
2961
- }
2962
- const b = hole.$lhBinding;
3173
+ };
3174
+ b && !engine.sweeping ? rescope(b, hole, run) : run();
2963
3175
  if (b && !b.closed && !r.h.length && !engine.sweeping) {
2964
3176
  b.last = stripMarkers(r.t[0]);
3177
+ b.rows = rows;
3178
+ settleOccurrences(b);
2965
3179
  }
2966
3180
  return r.h.length ? r : r.t[0];
2967
3181
  }
2968
3182
  if (engine.suppressed || engine.sweeping) return null;
2969
3183
  if (hole.$lhSkip) return null;
2970
3184
  if (inScope && !inScope()) return null;
2971
- const recordsBefore = engine.recordStamp;
2972
3185
  const ownersBefore = stamp();
2973
3186
  const owner = getOwner();
2974
3187
  const holeCtx = sharedConfig.context;
@@ -2976,25 +3189,32 @@ function createLiveHoles(sink, scoped) {
2976
3189
  key: null,
2977
3190
  children: [],
2978
3191
  last: null,
3192
+ rows: null,
3193
+ fn: hole.$fn,
2979
3194
  closed: false,
3195
+ scope: undefined,
3196
+ occ: null,
3197
+ next: null,
3198
+ up: engine.parent,
2980
3199
  sweep() {
2981
3200
  if (b.closed) return;
2982
3201
  const prevSweeping = engine.sweeping;
2983
3202
  engine.sweeping = true;
2984
- engine.gateHit = false;
2985
- const sweepOwnersBefore = stamp();
3203
+ engine.dry = b.last === null;
2986
3204
  let res;
2987
3205
  try {
2988
- res = swept(owner, holeCtx, () => resolveHoleValue(hole));
3206
+ res = rescope(b, hole, () => swept(owner, holeCtx, () => resolveHoleValue(hole)));
2989
3207
  } catch (err) {
2990
3208
  b.closed = true;
2991
3209
  sink.closeBinding(b.key);
2992
- sink.error(b.key, wireErrorMessage(err));
3210
+ sink.error(b.key, wireErrorMessage(err, errorScope));
2993
3211
  return;
2994
3212
  } finally {
2995
3213
  engine.sweeping = prevSweeping;
3214
+ engine.dry = false;
2996
3215
  }
2997
- if (engine.gateHit || stamp() !== sweepOwnersBefore) {
3216
+ if (engine.sweptOwners && res.h.length) {
3217
+ latched(owner, "owners", true);
2998
3218
  b.closed = true;
2999
3219
  sink.closeBinding(b.key);
3000
3220
  return;
@@ -3002,29 +3222,38 @@ function createLiveHoles(sink, scoped) {
3002
3222
  if (res.h.length) return;
3003
3223
  const html = res.t[0];
3004
3224
  if (b.last === null || html === b.last) return;
3225
+ const ops = b.rows && res.rows && rowOps(b.rows, res.rows);
3005
3226
  b.last = html;
3227
+ if (ops && !ops.r.length && ops.n === b.rows.length) return;
3228
+ b.rows = res.rows;
3006
3229
  closeChildren(b);
3007
- sink.hole(b.key, html);
3230
+ settleOccurrences(b);
3231
+ sink.hole(b.key, html, ops && !html.includes("<!--slot:") ? ops : null);
3008
3232
  }
3009
3233
  };
3010
3234
  if (engine.parent) engine.parent.children.push(b);
3011
3235
  const prevParent = engine.parent;
3236
+ const prevScope = engine.scope;
3237
+ const prevVisit = engine.visit;
3238
+ const scope = b.scope = scopeFor(hole);
3012
3239
  engine.parent = b;
3240
+ engine.scope = scope;
3241
+ engine.visit = b;
3013
3242
  let value;
3014
3243
  let escalated = null;
3015
3244
  try {
3016
- value = hole();
3245
+ value = holeValue(hole);
3017
3246
  } catch (err) {
3018
3247
  const wrap = buildAsyncWrap(err, hole);
3019
3248
  if (!wrap) {
3020
- engine.parent = prevParent;
3249
+ leave(b, prevParent, prevScope, prevVisit);
3021
3250
  closeChildren(b);
3022
3251
  return "";
3023
3252
  }
3024
3253
  escalated = wrap;
3025
3254
  }
3026
3255
  if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
3027
- engine.parent = prevParent;
3256
+ leave(b, prevParent, prevScope, prevVisit);
3028
3257
  const r = {
3029
3258
  t: [""],
3030
3259
  h: [],
@@ -3039,6 +3268,7 @@ function createLiveHoles(sink, scoped) {
3039
3268
  return r.h.length ? r : r.t[0];
3040
3269
  }
3041
3270
  let res;
3271
+ let rows = null;
3042
3272
  if (escalated) {
3043
3273
  closeChildren(b);
3044
3274
  escalated.fn.$lhSuppress = true;
@@ -3055,23 +3285,25 @@ function createLiveHoles(sink, scoped) {
3055
3285
  p: []
3056
3286
  };
3057
3287
  try {
3058
- resolveSSRNode(value, res);
3288
+ rows = resolveValue(value, res);
3059
3289
  } catch (_) {
3060
- engine.parent = prevParent;
3290
+ leave(b, prevParent, prevScope, prevVisit);
3061
3291
  closeChildren(b);
3062
3292
  return "";
3063
3293
  }
3064
3294
  }
3065
- engine.parent = prevParent;
3066
- if (engine.recordStamp !== recordsBefore || stamp() !== ownersBefore) {
3295
+ leave(b, prevParent, prevScope, prevVisit);
3296
+ if (stamp() !== ownersBefore) {
3067
3297
  return res.h.length ? res : res.t[0];
3068
3298
  }
3299
+ if (!res.h.length && settled && settled()) return res.t[0];
3069
3300
  const id = nextId++;
3070
3301
  const key = b.key = "lh:" + id;
3071
3302
  const open = `<!--lh:${id}-->`;
3072
3303
  const close = `<!--lh:/${id}-->`;
3073
3304
  if (!res.h.length) {
3074
3305
  b.last = stripMarkers(res.t[0]);
3306
+ b.rows = rows;
3075
3307
  sink.openBinding(key, b);
3076
3308
  return open + res.t[0] + close;
3077
3309
  }
@@ -3089,7 +3321,7 @@ function createLiveHoles(sink, scoped) {
3089
3321
  return nextId++;
3090
3322
  },
3091
3323
  active() {
3092
- return !inScope || inScope();
3324
+ return (!inScope || inScope()) && !(settled && settled());
3093
3325
  },
3094
3326
  attr(cap) {
3095
3327
  const owner = getOwner();
@@ -3102,9 +3334,10 @@ function createLiveHoles(sink, scoped) {
3102
3334
  sweep() {
3103
3335
  if (b.closed) return;
3104
3336
  const prevSweeping = engine.sweeping;
3337
+ const prevScope = engine.scope;
3105
3338
  engine.sweeping = true;
3339
+ engine.scope = null;
3106
3340
  engine.gateHit = false;
3107
- const sweepOwnersBefore = stamp();
3108
3341
  let html = "";
3109
3342
  try {
3110
3343
  let group = null;
@@ -3131,15 +3364,23 @@ function createLiveHoles(sink, scoped) {
3131
3364
  };
3132
3365
  swept(owner, holeCtx, run);
3133
3366
  } catch (err) {
3134
- if (ssrHandleError(err, true)) return;
3367
+ if (ssrHandleError(err, true)) {
3368
+ if (!engine.sweptOwners) return;
3369
+ latched(owner, "owners", false);
3370
+ b.closed = true;
3371
+ sink.closeBinding(b.key);
3372
+ return;
3373
+ }
3135
3374
  b.closed = true;
3136
3375
  sink.closeBinding(b.key);
3137
- sink.error("lha:" + cap.id, wireErrorMessage(err));
3376
+ sink.error("lha:" + cap.id, wireErrorMessage(err, errorScope));
3138
3377
  return;
3139
3378
  } finally {
3140
3379
  engine.sweeping = prevSweeping;
3380
+ engine.scope = prevScope;
3141
3381
  }
3142
- if (engine.gateHit || stamp() !== sweepOwnersBefore) {
3382
+ if (engine.gateHit) {
3383
+ latched(owner, "records", false);
3143
3384
  b.closed = true;
3144
3385
  sink.closeBinding(b.key);
3145
3386
  return;
@@ -3204,7 +3445,9 @@ function ssr(t) {
3204
3445
  cap = {
3205
3446
  id,
3206
3447
  parts: [prefix],
3207
- base: prefix
3448
+ base: prefix,
3449
+ at: lastOpen.seg,
3450
+ inject
3208
3451
  };
3209
3452
  return true;
3210
3453
  };
@@ -3253,7 +3496,10 @@ function ssr(t) {
3253
3496
  });
3254
3497
  }
3255
3498
  } else {
3256
- cap = null;
3499
+ if (cap) {
3500
+ result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
3501
+ cap = null;
3502
+ }
3257
3503
  result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
3258
3504
  result.p.push(lastGroupVal.p);
3259
3505
  result.t.push("");
@@ -3316,12 +3562,15 @@ function ssr(t) {
3316
3562
  f: hole
3317
3563
  });
3318
3564
  } else {
3565
+ result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
3319
3566
  cap = null;
3320
3567
  }
3321
3568
  }
3322
3569
  } else {
3323
3570
  const capturing = live && !hp.pos[i - 1] && captureStart();
3571
+ const scope = live && hp.pos[i - 1] && live.nest(hole);
3324
3572
  const r = tryResolveFunctionHole(hole);
3573
+ if (scope) live.scope = scope;
3325
3574
  if (typeof r === "string") {
3326
3575
  s += r;
3327
3576
  if (capturing) {
@@ -3331,7 +3580,10 @@ function ssr(t) {
3331
3580
  });
3332
3581
  }
3333
3582
  } else {
3334
- if (capturing) cap = null;
3583
+ if (capturing) {
3584
+ s = s.replace(cap.inject, "");
3585
+ cap = null;
3586
+ }
3335
3587
  result = {
3336
3588
  t: [s],
3337
3589
  h: [],
@@ -3396,14 +3648,12 @@ function ssrClassName(value) {
3396
3648
  if (typeof value === "number") return "" + value;
3397
3649
  if (!value) return "";
3398
3650
  if (typeof value === "string") return escape(value, true);
3399
- if (isSlotValue(value)) return slotValueInline("class", value) ?? "";
3400
3651
  value = classListToObject(value);
3401
3652
  let classKeys = Object.keys(value),
3402
3653
  result = "";
3403
3654
  for (let i = 0, len = classKeys.length; i < len; i++) {
3404
3655
  const key = classKeys[i];
3405
- let classValue = value[key];
3406
- if (isSlotValue(classValue)) classValue = slotValueInline("class", classValue);
3656
+ const classValue = value[key];
3407
3657
  if (!key || key === "undefined" || !classValue) continue;
3408
3658
  result && (result += " ");
3409
3659
  result += escape(key, true);
@@ -3413,13 +3663,11 @@ function ssrClassName(value) {
3413
3663
  function ssrStyle(value) {
3414
3664
  if (!value) return "";
3415
3665
  if (typeof value === "string") return escape(value, true);
3416
- if (isSlotValue(value)) return slotValueInline("style", value) ?? "";
3417
3666
  let result = "";
3418
3667
  const k = Object.keys(value);
3419
3668
  for (let i = 0; i < k.length; i++) {
3420
3669
  const s = escape(k[i], true);
3421
- let v = value[k[i]];
3422
- if (isSlotValue(v)) v = slotValueInline("style", v);
3670
+ const v = value[k[i]];
3423
3671
  if (v != undefined) {
3424
3672
  const r = escape(v, true);
3425
3673
  if (r != undefined && r !== "undefined") {
@@ -3431,7 +3679,6 @@ function ssrStyle(value) {
3431
3679
  return result;
3432
3680
  }
3433
3681
  function ssrStyleProperty(name, value) {
3434
- if (isSlotValue(value)) value = slotValueInline("style", value);
3435
3682
  return value != null ? name + value : "";
3436
3683
  }
3437
3684
  function ssrStyleProperties(...entries) {
@@ -3442,29 +3689,25 @@ function ssrStyleProperties(...entries) {
3442
3689
  }
3443
3690
  return result;
3444
3691
  }
3445
- function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3692
+ function ssrElement(tag, props, children, needsId, skip, attrs) {
3446
3693
  const hk = needsId ? ssrHydrationKey() : "";
3447
3694
  if (typeof props === "function") props = props();
3448
3695
  let sources = null;
3449
3696
  let proxy = false;
3450
3697
  let viewKeys = null;
3451
3698
  let owners = null;
3452
- let ownerIndex = null;
3453
3699
  const ctx = renderConfig.context;
3454
- const slots = ctx !== undefined && ctx.claims !== undefined;
3700
+ const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
3455
3701
  if (Array.isArray(props)) {
3456
- if (slots && props.$slot === true) props = slotSpreadSource(tag, props);else {
3457
- let i = 0;
3458
- for (; i < props.length; i++) {
3459
- const s = props[i];
3460
- if (s == null || typeof s === "function" || $PROXY in s || slots && s.$slot === true) break;
3461
- }
3462
- if (i === props.length) sources = props;else {
3463
- viewKeys = [];
3464
- owners = [];
3465
- if (slots) ownerIndex = [];
3466
- collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
3467
- }
3702
+ let i = 0;
3703
+ for (; i < props.length; i++) {
3704
+ const s = props[i];
3705
+ if (s == null || typeof s === "function" || $PROXY in s) break;
3706
+ }
3707
+ if (i === props.length) sources = props;else {
3708
+ viewKeys = [];
3709
+ owners = [];
3710
+ collectSpreadSources(props, viewKeys, owners);
3468
3711
  }
3469
3712
  } else if (props == null) {
3470
3713
  props = {};
@@ -3474,13 +3717,10 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3474
3717
  owners = [];
3475
3718
  sourceOwners(props, viewKeys, owners);
3476
3719
  } else proxy = true;
3477
- } else if (slots && props.$slot === true) {
3478
- props = slotSpreadSource(tag, props);
3479
3720
  }
3480
3721
  const info = tagInfo(tag);
3481
3722
  const skipChildren = info.isVoid;
3482
3723
  let result = info.open + hk;
3483
- let behaviors = null;
3484
3724
  let childOwner = null;
3485
3725
  const last = sources === null ? 0 : sources.length - 1;
3486
3726
  let keysOf = null;
@@ -3492,7 +3732,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3492
3732
  const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
3493
3733
  if (sources !== null) props = sources[s];
3494
3734
  nextKey: for (let i = 0; i < keys.length; i++) {
3495
- const prop = keys[i];
3735
+ let prop = keys[i];
3496
3736
  if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
3497
3737
  if (owners !== null) props = owners[i];
3498
3738
  for (let j = s + 1; j <= last; j++) {
@@ -3509,22 +3749,15 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3509
3749
  }
3510
3750
  continue;
3511
3751
  }
3512
- const value = props[prop];
3513
- if (value == undefined) {
3514
- if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3515
- continue;
3516
- }
3517
- if (prop.startsWith("prop:")) {
3518
- if (slots && typeof value === "object") spreadPropPosition(prop, value);
3519
- continue;
3752
+ const key = prop;
3753
+ if (info.formAttributes !== undefined) {
3754
+ prop = spreadFormAttribute(prop, info, keys, keysOf, skip);
3755
+ if (prop === undefined) continue;
3520
3756
  }
3521
- if (prop === "ref" || isEventName(prop)) {
3522
- if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
3523
- continue;
3524
- }
3525
- if (slots && typeof value === "object") {
3526
- result += spreadObjectAttribute(prop, value);
3527
- } else if (prop === "style") {
3757
+ const value = props[key];
3758
+ if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
3759
+ if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
3760
+ if (prop === "style") {
3528
3761
  result += ` style="${ssrStyle(value)}"`;
3529
3762
  } else if (prop === "class") {
3530
3763
  result += ` class="${ssrClassName(value)}"`;
@@ -3535,8 +3768,8 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3535
3768
  }
3536
3769
  }
3537
3770
  }
3538
- if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
3539
3771
  if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
3772
+ if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
3540
3773
  if (skipChildren) return {
3541
3774
  t: result + " />"
3542
3775
  };
@@ -3554,21 +3787,36 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3554
3787
  };
3555
3788
  return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
3556
3789
  }
3790
+ function collectSpreadSources(props, viewKeys, owners) {
3791
+ for (let i = 0; i < props.length; i++) {
3792
+ let s = props[i];
3793
+ if (typeof s === "function") s = s();
3794
+ if (s != null) sourceOwners(s, viewKeys, owners);
3795
+ }
3796
+ }
3797
+ function spreadFormAttribute(prop, info, keys, keysOf, skip) {
3798
+ const defaultProp = info.formDefaults[prop];
3799
+ if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
3800
+ if (keysOf !== null) {
3801
+ for (let j = 0; j < keysOf.length; j++) {
3802
+ if (keysOf[j].includes(defaultProp)) return;
3803
+ }
3804
+ } else if (keys.includes(defaultProp)) return;
3805
+ }
3806
+ const attr = info.formAttributes[prop];
3807
+ if (attr !== undefined && skip !== undefined && skip(attr)) return;
3808
+ return attr === undefined ? prop : attr;
3809
+ }
3557
3810
  function ssrElementAttribute(key, value) {
3558
3811
  if (value == undefined) return "";
3559
- if (key === "style" || key === "class") {
3560
- return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
3561
- }
3562
- if (isSlotValue(value)) return slotAttribute(key, value);
3812
+ if (key === "style" || key === "class") return ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
3563
3813
  if (typeof value === "boolean") return value ? ` ${key}` : "";
3564
3814
  return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
3565
3815
  }
3566
3816
  function ssrAttribute(key, value) {
3567
3817
  if (typeof value === "string") return ` ${key}="${value}"`;
3568
3818
  if (value == null || value === false) return "";
3569
- if (typeof value === "object") {
3570
- return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
3571
- }
3819
+ if (typeof value === "object") return ` ${key}="${escape(String(value), true)}"`;
3572
3820
  if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
3573
3821
  return value === true ? ` ${key}` : ` ${key}="${value}"`;
3574
3822
  }
@@ -3576,318 +3824,10 @@ function ssrHydrationKey() {
3576
3824
  const hk = getHydrationKey();
3577
3825
  return hk ? ` _hk=${hk}` : "";
3578
3826
  }
3579
- const CLAIMS_STREAM = 1;
3580
- const CLAIMS_DOCUMENT = 2;
3581
- const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
3582
- const SLOT_MARKER = "_s:";
3583
- const SLOT_FACE_STREAM = 0;
3584
- const SLOT_FACE_DATA = 1;
3585
- const SLOT_FACE_MARKUP = 2;
3586
- const BINDING_SLOT_POSITION = "BINDING_SLOT_POSITION";
3587
- function slotFinding(sv, reason, position, message, severity = "warn") {
3588
- {
3589
- const ctx = sharedConfig.context;
3590
- if (ctx) {
3591
- const id = `${sv[SLOT_VALUE]}\u0000${sv.k}\u0000${reason}\u0000${position || ""}`;
3592
- const seen = ctx.slotFindings || (ctx.slotFindings = new Set());
3593
- if (seen.has(id)) return;
3594
- seen.add(id);
3595
- }
3596
- devCheck({
3597
- code: BINDING_SLOT_POSITION,
3598
- kind: "ssr",
3599
- severity,
3600
- message,
3601
- data: {
3602
- reason,
3603
- occurrence: sv[SLOT_VALUE],
3604
- key: sv.k,
3605
- position
3606
- }
3607
- });
3608
- }
3609
- }
3610
- function isSlotValue(value) {
3611
- return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
3612
- }
3613
- function slotValue(occurrence, key, value, face) {
3614
- const sv = {
3615
- [SLOT_VALUE]: occurrence,
3616
- k: key,
3617
- v: value,
3618
- f: face
3619
- };
3620
- Object.defineProperty(sv, Symbol.toPrimitive, {
3621
- value: hint => slotValueString(sv, hint === "string" ? "stringified" : "coerced")
3622
- });
3623
- Object.defineProperty(sv, "toString", {
3624
- value: () => slotValueString(sv, "stringified")
3625
- });
3626
- Object.defineProperty(sv, "w", {
3627
- value: () => slotText(sv)
3628
- });
3629
- return sv;
3630
- }
3631
- function slotValueString(sv, reason) {
3632
- {
3633
- const prop = propOfOccurrence(sv[SLOT_VALUE]);
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.`);
3635
- }
3636
- return "";
3637
- }
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-->`;
3643
- }
3644
- function slotMarkupRead(sv, position) {
3645
- if (sv.f === SLOT_FACE_MARKUP) {
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.`);
3647
- }
3648
- }
3649
- function slotValueInline(kind, sv) {
3650
- {
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.`);
3652
- }
3653
- return undefined;
3654
- }
3655
- const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
3656
- function encodeSlotKey(key) {
3657
- return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
3658
- }
3659
- function slotEntry(sv, name) {
3660
- return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
3661
- }
3662
- function slotMarker(position, entries) {
3663
- return ` ${SLOT_MARKER}${position}="${entries}"`;
3664
- }
3665
- function eventSlotStamp(mode) {
3666
- return mode === CLAIMS_DOCUMENT ? " _hk" : "";
3667
- }
3668
- function propOfOccurrence(occurrence) {
3669
- const i = occurrence.indexOf("#");
3670
- return i === -1 ? occurrence : occurrence.slice(0, i);
3671
- }
3672
- function slotAttribute(key, sv) {
3673
- slotMarkupRead(sv, key);
3674
- let out = "";
3675
- if (sv.f === SLOT_FACE_DATA) {
3676
- const v = sv.v;
3677
- if (v != null && v !== false) {
3678
- out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
3679
- }
3680
- }
3681
- return out + slotMarker(key, slotEntry(sv));
3682
- }
3683
- function slotClassOrStyle(key, value) {
3684
- const isClass = key === "class";
3685
- if (isSlotValue(value)) {
3686
- slotMarkupRead(value, key);
3687
- let out = "";
3688
- if (value.f === SLOT_FACE_DATA && value.v != null) {
3689
- out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
3690
- }
3691
- return out + slotMarker(key, slotEntry(value));
3692
- }
3693
- if (typeof value === "object" && value !== null) {
3694
- const obj = isClass ? classListToObject(value) : value;
3695
- let entries = "";
3696
- let inner = "";
3697
- for (const name of Object.keys(obj)) {
3698
- let v = obj[name];
3699
- if (isSlotValue(v)) {
3700
- slotMarkupRead(v, `${key}:${name}`);
3701
- entries += (entries ? "," : "") + slotEntry(v, name);
3702
- v = v.f === SLOT_FACE_DATA ? v.v : undefined;
3703
- }
3704
- if (isClass) {
3705
- if (!name || name === "undefined" || !v) continue;
3706
- inner += (inner ? " " : "") + escape(name, true);
3707
- } else if (v != undefined) {
3708
- const r = escape(v, true);
3709
- if (r != undefined && r !== "undefined") {
3710
- inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
3711
- }
3712
- }
3713
- }
3714
- if (entries === "") return ` ${key}="${inner}"`;
3715
- return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
3716
- }
3717
- return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
3718
- }
3719
- function eventPosition(prop) {
3720
- return prop.slice(2).toLowerCase();
3721
- }
3722
- function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
3723
- if (!isAttrName(prop)) return behaviors;
3724
- const pos = prop === "ref" ? "ref" : eventPosition(prop);
3725
- const entries = value == null ? "" : claimEntries(pos, value, mode);
3726
- if (!settle) {
3727
- if (entries) (behaviors ||= new Map()).set(pos, entries);
3728
- return behaviors;
3729
- }
3730
- behaviors ||= new Map();
3731
- const b = behaviors.get(pos);
3732
- if (b === undefined) behaviors.set(pos, {
3733
- e: entries,
3734
- at: index
3735
- });else {
3736
- b.e = entries;
3737
- b.at = index;
3738
- }
3739
- return behaviors;
3740
- }
3741
- function spreadBehaviorMarkers(behaviors, claims, mode) {
3742
- if (claims !== undefined) {
3743
- const segments = claims();
3744
- for (const k in segments) {
3745
- const map = segments[k];
3746
- for (const pos in map) {
3747
- const value = map[pos];
3748
- behaviors ||= new Map();
3749
- const b = behaviors.get(pos);
3750
- if (pos === "ref") {
3751
- if (value == null) continue;
3752
- const entries = claimEntries("ref", value, mode);
3753
- if (!entries) continue;
3754
- if (b === undefined) behaviors.set("ref", {
3755
- e: entries,
3756
- at: -1
3757
- });else b.e = b.e ? b.e + "," + entries : entries;
3758
- continue;
3759
- }
3760
- if (b !== undefined && b.at >= +k) continue;
3761
- const entries = value == null ? "" : claimEntries(pos, value, mode);
3762
- if (b === undefined) behaviors.set(pos, {
3763
- e: entries,
3764
- at: -1
3765
- });else b.e = entries;
3766
- }
3767
- }
3768
- }
3769
- let out = "";
3770
- let events = false;
3771
- if (behaviors !== null) {
3772
- for (const [pos, b] of behaviors) {
3773
- const e = claims === undefined ? b : b.e;
3774
- if (!e) continue;
3775
- if (pos === "ref") out += slotMarker("ref", e);else {
3776
- out += slotMarker("on:" + pos, e);
3777
- events = true;
3778
- }
3779
- }
3780
- }
3781
- return events ? out + eventSlotStamp(mode) : out;
3782
- }
3783
- function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3784
- for (let i = 0; i < props.length; i++) {
3785
- let s = props[i];
3786
- if (typeof s === "function") s = s();
3787
- if (s != null) {
3788
- if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource(tag, s);
3789
- if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
3790
- const ks = [];
3791
- const os = [];
3792
- sourceOwners(s, ks, os);
3793
- for (let j = 0; j < ks.length; j++) {
3794
- const at = viewKeys.indexOf(ks[j]);
3795
- if (at !== -1) {
3796
- viewKeys.splice(at, 1);
3797
- owners.splice(at, 1);
3798
- ownerIndex.splice(at, 1);
3799
- }
3800
- viewKeys.push(ks[j]);
3801
- owners.push(os[j]);
3802
- ownerIndex.push(i);
3803
- }
3804
- }
3805
- }
3806
- }
3807
- }
3808
- function spreadPropPosition(prop, value) {
3809
- if (isSlotValue(value)) {
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.`);
3811
- }
3812
- }
3813
- function spreadObjectAttribute(prop, value) {
3814
- if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
3815
- if (!isAttrName(prop)) return "";
3816
- if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
3817
- return ` ${prop}="${escape(value, true)}"`;
3818
- }
3819
- function slotSpreadSource(tag, source) {
3820
- {
3821
- const occurrence = source.$occurrence;
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.`;
3823
- recordFinding({
3824
- code: BINDING_SLOT_POSITION,
3825
- kind: "ssr",
3826
- severity: "error",
3827
- message: text,
3828
- data: {
3829
- reason: "spread",
3830
- tag,
3831
- occurrence
3832
- }
3833
- });
3834
- throw new Error(text);
3835
- }
3836
- }
3837
- function ssrClaim(map) {
3838
- const mode = sharedConfig.context && sharedConfig.context.claims;
3839
- if (!mode) return "";
3840
- let out = "";
3841
- let events = false;
3842
- for (const pos in map) {
3843
- const entries = claimEntries(pos, map[pos], mode);
3844
- if (!entries) continue;
3845
- if (pos === "ref") out += slotMarker("ref", entries);else {
3846
- out += slotMarker("on:" + pos, entries);
3847
- events = true;
3848
- }
3849
- }
3850
- return events ? out + eventSlotStamp(mode) : out;
3851
- }
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
- }
3862
- if (Array.isArray(value)) {
3863
- let entries = "";
3864
- for (const v of value) {
3865
- const inner = claimEntries(pos, v, mode);
3866
- if (inner) entries += (entries ? "," : "") + inner;
3867
- }
3868
- return entries;
3869
- }
3870
- if (isSlotValue(value)) {
3871
- slotMarkupRead(value, pos);
3872
- return slotEntry(value);
3873
- }
3874
- if (typeof value === "function" && !value.$slotWarned && claimInScope(mode)) {
3875
- value.$slotWarned = true;
3876
- devCheck({
3877
- code: BINDING_SLOT_POSITION,
3878
- kind: "ssr",
3879
- severity: "warn",
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=\`.`,
3881
- data: {
3882
- reason: "server-local",
3883
- position: pos
3884
- }
3885
- });
3886
- }
3887
- return "";
3888
- }
3889
- function claimInScope(mode) {
3890
- return mode === CLAIMS_STREAM || typeof inServerComponentScope === "function" && inServerComponentScope();
3827
+ function ssrLinkClaim(attrs) {
3828
+ const ctx = renderConfig.context;
3829
+ if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
3830
+ return ctx.linkClaim(attrs);
3891
3831
  }
3892
3832
  function decodeSSREntities(s) {
3893
3833
  return s.indexOf("&") < 0 ? s : s.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&amp;/g, "&");
@@ -4009,7 +3949,6 @@ function escape(s, attr) {
4009
3949
  if (!attr && t === "function") return escapeLate(s);
4010
3950
  if (attr) {
4011
3951
  if (s == null || t === "boolean" || t === "number") return s;
4012
- if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
4013
3952
  return escape(String(s), attr);
4014
3953
  }
4015
3954
  return s;
@@ -4022,10 +3961,8 @@ function escapeLate(fn) {
4022
3961
  if (fn.$esc) return fn;
4023
3962
  const w = () => escape(fn());
4024
3963
  w.$esc = true;
4025
- {
4026
- w.$fn = fn;
4027
- w.$reg = devPeekId();
4028
- }
3964
+ w.$fn = fn;
3965
+ w.$reg = devPeekId();
4029
3966
  if (fn.$lhSkip) w.$lhSkip = true;
4030
3967
  if (fn.$lhSuppress) w.$lhSuppress = true;
4031
3968
  if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
@@ -4118,10 +4055,13 @@ function applyRef(r, element) {
4118
4055
  Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
4119
4056
  }
4120
4057
  function generateHydrationScript({
4121
- eventNames = ["click", "input"],
4058
+ eventNames,
4122
4059
  nonce
4123
4060
  } = {}) {
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-->`;
4061
+ return hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), false);
4062
+ }
4063
+ function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
4064
+ 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-->`;
4125
4065
  }
4126
4066
  function queue(fn) {
4127
4067
  return Promise.resolve().then(fn);
@@ -4134,6 +4074,13 @@ function allSettled(promises) {
4134
4074
  return size;
4135
4075
  });
4136
4076
  }
4077
+ function withShellEnd(html, context, renderId, nonce, noScripts) {
4078
+ if (noScripts || !context || !context.bootstrap) return html;
4079
+ const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
4080
+ const marker = `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
4081
+ const at = html.indexOf("</body>", html.length - 512);
4082
+ return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
4083
+ }
4137
4084
  function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
4138
4085
  const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
4139
4086
  const title = headTags ? headTags.title : null;
@@ -4324,10 +4271,6 @@ function tryResolveString(node, nested) {
4324
4271
  if (node.h && node.h.length > 0) return {
4325
4272
  merge: node
4326
4273
  };
4327
- if (node[SLOT_VALUE] !== undefined) {
4328
- ssrTextTail = false;
4329
- return node.w();
4330
- }
4331
4274
  if (node.t === undefined) {
4332
4275
  unrecognizedInsert(node);
4333
4276
  return "";
@@ -4381,9 +4324,6 @@ function resolveSSRNode(node, result = {
4381
4324
  } else if (node.t !== undefined) {
4382
4325
  result.t[result.t.length - 1] += node.t;
4383
4326
  ssrTextTail = false;
4384
- } else if (node[SLOT_VALUE] !== undefined) {
4385
- result.t[result.t.length - 1] += node.w();
4386
- ssrTextTail = false;
4387
4327
  } else unrecognizedInsert(node);
4388
4328
  } else if (t === "function") {
4389
4329
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
@@ -4394,6 +4334,7 @@ function resolveSSRNode(node, result = {
4394
4334
  ssrTextTail = true;
4395
4335
  } else resolveSSRNode(liveNode, result, false, true);
4396
4336
  } else {
4337
+ const scope = live && live.nest(node);
4397
4338
  try {
4398
4339
  resolveSSRNode(node(), result, false, true);
4399
4340
  } catch (err) {
@@ -4405,6 +4346,8 @@ function resolveSSRNode(node, result = {
4405
4346
  result.t.push("");
4406
4347
  ssrTextTail = true;
4407
4348
  }
4349
+ } finally {
4350
+ if (scope) live.scope = scope;
4408
4351
  }
4409
4352
  }
4410
4353
  }
@@ -4487,13 +4430,31 @@ function createHydrationWriter(context, isOpen) {
4487
4430
  };
4488
4431
  }
4489
4432
  function getHydrationWriter() {
4433
+ const ctx = currentRenderContext();
4434
+ return ctx && ctx.writer;
4435
+ }
4436
+ function currentRenderContext() {
4490
4437
  let ctx = renderContextOf(getOwner());
4491
4438
  if (!ctx) {
4492
4439
  const event = peekRequestEvent();
4493
4440
  const renders = event && eventRenders.get(event);
4494
4441
  if (renders && renders.size === 1) for (const c of renders) ctx = c;
4495
4442
  }
4496
- return ctx && ctx.writer;
4443
+ return ctx;
4444
+ }
4445
+ const LINK_STATE_RECORD = "links";
4446
+ function setLinkClaim(handler) {
4447
+ const ctx = currentRenderContext();
4448
+ if (!ctx) {
4449
+ console.warn("setLinkClaim was called outside a render: no render was found through the current owner or the request scope. Call it during component setup.");
4450
+ return false;
4451
+ }
4452
+ ctx.linkClaim = handler;
4453
+ if (handler !== undefined) ctx.writer.write(LINK_STATE_RECORD, 1);
4454
+ return true;
4455
+ }
4456
+ function hasServerLinkState() {
4457
+ return false;
4497
4458
  }
4498
4459
  function takeHydrationValue(_key) {
4499
4460
  return undefined;
@@ -4807,94 +4768,17 @@ function dispatchAsInteraction(_e, fn) {
4807
4768
  return fn();
4808
4769
  }
4809
4770
  function notSup() {
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>.");
4771
+ throw new Error("Client-only API called on the server side. Run client-only code in onSettled, or conditionally run client-only component with <Show>.");
4811
4772
  }
4812
4773
 
4813
4774
  setContainerTraceResolver(getProjectionTrace);
4814
4775
  setAsyncIterableSharer(shareAsyncIterable);
4815
4776
  const isServer = true;
4816
4777
  const isDev = true;
4778
+ const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4817
4779
  function dynamic(source, options) {
4818
4780
  return dynamicCore(source, options, ssrTag);
4819
4781
  }
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) {
4825
- if (options?.static) {
4826
- const component = untrack(source);
4827
- if (component && typeof component.then === "function") throw new Error("dynamic(): a static source must resolve synchronously, not to a promise");
4828
- if (typeof component === "function") return props => component(props);
4829
- if (typeof component === "string" && tagArm) return props => tagArm(component, props);
4830
- return () => undefined;
4831
- }
4832
- const cached = createMemo(() => {
4833
- const next = source();
4834
- if (!next || typeof next.then !== "function") return next;
4835
- return {
4836
- [FLIGHT]: next
4837
- };
4838
- });
4839
- const deferStream = !!options?.deferStream;
4840
- return props => {
4841
- const ctx = sharedConfig.context;
4842
- let gated = !deferStream || !ctx?.async;
4843
- const value = createMemo(() => {
4844
- let c;
4845
- try {
4846
- c = cached();
4847
- } catch (err) {
4848
- if (!gated && err instanceof NotReadyError && !err.source?.$clientHole) {
4849
- gated = true;
4850
- ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
4851
- }
4852
- throw err;
4853
- }
4854
- if (!c || !c[FLIGHT]) return c;
4855
- const next = c[FLIGHT];
4856
- return {
4857
- then: (onFulfilled, onRejected) => next.then(resolved => {
4858
- let landed;
4859
- try {
4860
- landed = classifyLanding(resolved);
4861
- } catch (err) {
4862
- if (onRejected) return onRejected(err);
4863
- throw err;
4864
- }
4865
- return onFulfilled ? onFulfilled(landed) : landed;
4866
- }, onRejected)
4867
- };
4868
- }, {
4869
- deferStream
4870
- });
4871
- return createMemo(() => {
4872
- const c = value();
4873
- if (c) {
4874
- if (typeof c === "function") return c(props);
4875
- if (typeof c === "string" && tagArm) return tagArm(c, props);
4876
- }
4877
- }, {
4878
- sync: true
4879
- });
4880
- };
4881
- }
4882
- const FLIGHT = Symbol("solid.dynamic-flight");
4883
- const SERVER_COMPONENT = Symbol.for("solid.server-component");
4884
- function classifyLanding(resolved) {
4885
- if (typeof resolved !== "function" || SERVER_COMPONENT in resolved) return resolved;
4886
- const message = "[DYNAMIC_ASYNC_COMPONENT] An async dynamic() source resolved to a client component " + "function, which cannot be serialized for hydration: the client would re-run the source " + "and wait on it while hydrating, committing the enclosing <Loading> to a fallback the " + "server never rendered. Resolve the async upstream — a createAsync()/createMemo() the " + "source reads synchronously (`dynamic(() => page() ? Editor : Viewer)`) — or use lazy() " + "for a code-split component. A source may stay async when it resolves to a server " + "component or a serializable value (a tag name)." ;
4887
- recordFinding({
4888
- code: "DYNAMIC_ASYNC_COMPONENT",
4889
- kind: "ssr",
4890
- severity: "error",
4891
- message,
4892
- data: {
4893
- component: resolved.name || undefined
4894
- }
4895
- }, null);
4896
- throw new Error(message);
4897
- }
4898
4782
  function Dynamic(props) {
4899
4783
  const Comp = dynamic(() => props.component);
4900
4784
  return createComponent(Comp, omit(props, "component"));
@@ -5023,4 +4907,4 @@ function httpHeader(name, value, options) {
5023
4907
  }
5024
4908
  }
5025
4909
 
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 };
4910
+ export { 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, 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, 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, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };