@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
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
- import { createRenderEffect, createMemo, 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, 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, createMemo, 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, 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",
@@ -110,11 +111,9 @@ function parseTraceparent(value) {
110
111
  };
111
112
  }
112
113
  function randomHex(bytes) {
113
- const buffer = new Uint8Array(bytes);
114
- crypto.getRandomValues(buffer);
115
114
  let out = "";
116
- for (let i = 0; i < buffer.length; i++) out += (buffer[i] < 16 ? "0" : "") + buffer[i].toString(16);
117
- return out;
115
+ for (let i = 0; i < bytes; i += 4) out += (Math.random() * 0x100000000 >>> 0).toString(16).padStart(8, "0");
116
+ return out.length === bytes * 2 ? out : out.slice(0, bytes * 2);
118
117
  }
119
118
  function randomTraceId() {
120
119
  let id = randomHex(16);
@@ -373,9 +372,7 @@ function toBorderForm(value, envelopeContainers) {
373
372
  }
374
373
  function isShareableIterable(value) {
375
374
  try {
376
- if (value.__SEROVAL_STREAM__ === true) return false;
377
- if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) return false;
378
- return typeof value[Symbol.asyncIterator] === "function";
375
+ return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
379
376
  } catch {
380
377
  return false;
381
378
  }
@@ -480,17 +477,24 @@ function getLocalHeaderScript(id) {
480
477
  }
481
478
 
482
479
  const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
483
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
484
- const ResponseEnvelope = /* @__PURE__ */(() => {
485
- class ResponseEnvelope {
486
- constructor(response, value) {
487
- this.response = response;
488
- this.value = value;
489
- }
480
+ let EnvelopeClass;
481
+ const ResponseEnvelope = function ResponseEnvelope(response, value) {
482
+ if (!EnvelopeClass) {
483
+ EnvelopeClass = class extends Response {
484
+ constructor(response, value) {
485
+ super(response ? response.body : null, response && {
486
+ status: response.status,
487
+ statusText: response.statusText,
488
+ headers: copyHeaders(response.headers)
489
+ });
490
+ this.response = response ? this : undefined;
491
+ this.value = value;
492
+ }
493
+ };
494
+ EnvelopeClass.prototype[ENVELOPE] = true;
490
495
  }
491
- ResponseEnvelope.prototype[ENVELOPE] = true;
492
- return ResponseEnvelope;
493
- })();
496
+ return new EnvelopeClass(response, value);
497
+ };
494
498
  function isResponseEnvelope(value) {
495
499
  return !!(value && typeof value === "object" && value[ENVELOPE]);
496
500
  }
@@ -515,6 +519,16 @@ function isSafeError(value) {
515
519
  const REVALIDATE_HEADER = "X-Revalidate";
516
520
  const REVALIDATE_ALL = "*";
517
521
  const RESPONSE_HEADER_VALUE_LIMIT = 4096;
522
+ function copyHeaders(init) {
523
+ const source = init;
524
+ if (!source || !source.getSetCookie) return new Headers(init);
525
+ const headers = new Headers();
526
+ source.forEach((value, key) => {
527
+ if (key !== "set-cookie") headers.append(key, value);
528
+ });
529
+ for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
530
+ return headers;
531
+ }
518
532
  function initWithRevalidate(init = {}) {
519
533
  const resolved = typeof init === "number" ? {
520
534
  status: init
@@ -523,18 +537,7 @@ function initWithRevalidate(init = {}) {
523
537
  revalidate,
524
538
  ...responseInit
525
539
  } = resolved;
526
- let headers;
527
- if (responseInit.headers && responseInit.headers.getSetCookie) {
528
- headers = new Headers();
529
- responseInit.headers.forEach((value, key) => {
530
- if (key !== "set-cookie") headers.append(key, value);
531
- });
532
- for (const cookie of responseInit.headers.getSetCookie()) {
533
- headers.append("Set-Cookie", cookie);
534
- }
535
- } else {
536
- headers = new Headers(responseInit.headers);
537
- }
540
+ const headers = copyHeaders(responseInit.headers);
538
541
  if (revalidate !== undefined) {
539
542
  const list = Array.isArray(revalidate) ? revalidate : [revalidate];
540
543
  if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
@@ -598,7 +601,12 @@ function respond(value, init = {}) {
598
601
  }), value);
599
602
  }
600
603
  headers.set("Content-Type", "application/json");
601
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
604
+ return new ResponseEnvelope(new Response(new ReadableStream({
605
+ pull(controller) {
606
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
607
+ controller.close();
608
+ }
609
+ }), {
602
610
  ...responseInit,
603
611
  headers
604
612
  }), value);
@@ -711,6 +719,10 @@ function qualifierValue(name, value) {
711
719
  function asciiLowerCase(value) {
712
720
  return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
713
721
  }
722
+ const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
723
+ function headBodyText(tag, props, text) {
724
+ return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
725
+ }
714
726
  function resourceIdentity(tag, props) {
715
727
  const url = String(props.href || props.src || "");
716
728
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
@@ -1295,6 +1307,7 @@ function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMet
1295
1307
  noScripts
1296
1308
  };
1297
1309
  }
1310
+ let headBodyHook;
1298
1311
  function flushHeadFragment(registry, boundary, nonce) {
1299
1312
  const groups = commitHeadBoundary(registry, boundary);
1300
1313
  if (!groups.length) return null;
@@ -1332,7 +1345,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1332
1345
  if (value) attrs.nonce = String(value);
1333
1346
  }
1334
1347
  const children = t.props.children;
1335
- ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
1348
+ ops.push(["a", identity, t.tag, attrs, children == null ? null : headBodyHook ? headBodyHook(t.tag, t.props, String(children)) : String(children)]);
1336
1349
  }
1337
1350
  }
1338
1351
  return ops.length ? ops : null;
@@ -1360,16 +1373,9 @@ function normalizeNonce(nonce) {
1360
1373
  }
1361
1374
  function destinationNonce(nonce, destination) {
1362
1375
  if (nonce == null) return undefined;
1363
- if (typeof nonce === "string") return nonce || undefined;
1364
- const value = nonce[destination];
1376
+ const value = typeof nonce === "string" ? nonce : nonce[destination];
1365
1377
  return typeof value === "string" && value ? value : undefined;
1366
1378
  }
1367
- function scriptNonce(nonce) {
1368
- return destinationNonce(nonce, "script");
1369
- }
1370
- function styleNonce(nonce) {
1371
- return destinationNonce(nonce, "style");
1372
- }
1373
1379
  function hasNonceProp(props) {
1374
1380
  for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
1375
1381
  return false;
@@ -1435,6 +1441,7 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
1435
1441
  if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
1436
1442
  if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
1437
1443
  let body = props.children == null ? "" : String(props.children);
1444
+ if (headBodyHook) body = headBodyHook(tag, props, body);
1438
1445
  if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
1439
1446
  return `<${tag}${attrs}>${body}</${tag}>`;
1440
1447
  }
@@ -1443,6 +1450,7 @@ function useHead(tags) {
1443
1450
  if (!ctx || !ctx.registerHeadTags) {
1444
1451
  return;
1445
1452
  }
1453
+ headBodyHook = headBodyText;
1446
1454
  ctx.registerHeadTags(tags);
1447
1455
  }
1448
1456
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
@@ -1453,12 +1461,27 @@ function tagInfo(tag) {
1453
1461
  let info = tagInfos.get(tag);
1454
1462
  if (info === undefined) {
1455
1463
  if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
1464
+ let formDefaults, formAttributes;
1465
+ if (tag === "input" || tag === "option") {
1466
+ formDefaults = Object.create(null);
1467
+ formAttributes = Object.create(null);
1468
+ const state = DOMWithState[tag.toUpperCase()];
1469
+ for (const prop in state) {
1470
+ if (state[prop] === 2) {
1471
+ const attr = prop.slice(7).toLowerCase();
1472
+ formDefaults[attr] = prop;
1473
+ formAttributes[prop] = attr;
1474
+ }
1475
+ }
1476
+ }
1456
1477
  info = {
1457
1478
  open: "<" + tag,
1458
1479
  close: "</" + tag + ">",
1459
1480
  isVoid: VOID_ELEMENTS.test(tag),
1460
1481
  textarea: tag === "textarea",
1461
- raw: tag === "script" || tag === "style"
1482
+ raw: tag === "script" || tag === "style",
1483
+ formDefaults,
1484
+ formAttributes
1462
1485
  };
1463
1486
  if (tagInfos.size < 512) tagInfos.set(tag, info);
1464
1487
  }
@@ -1481,6 +1504,8 @@ function renderToString(code, options = {}) {
1481
1504
  onHead
1482
1505
  } = options;
1483
1506
  const nonce = normalizeNonce(options.nonce);
1507
+ const requestEvent = peekRequestEvent();
1508
+ const errorScope = requestEvent || {};
1484
1509
  let scripts = "";
1485
1510
  const serializer = createHydrationSerializer({
1486
1511
  scopeId: renderId,
@@ -1503,6 +1528,7 @@ function renderToString(code, options = {}) {
1503
1528
  resolve: resolveSSRNode,
1504
1529
  ssr: ssr,
1505
1530
  errorPolicy: options.onError,
1531
+ _errorScope: errorScope,
1506
1532
  registerHeadTags(tags) {
1507
1533
  registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
1508
1534
  },
@@ -1537,7 +1563,6 @@ function renderToString(code, options = {}) {
1537
1563
  registerEntryAssets(manifest);
1538
1564
  const context = sharedConfig.context;
1539
1565
  context.writer = createHydrationWriter(context, () => !closed);
1540
- const requestEvent = peekRequestEvent();
1541
1566
  if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1542
1567
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
1543
1568
  const render = timeDocument(context, context.trace);
@@ -1557,7 +1582,7 @@ function renderToString(code, options = {}) {
1557
1582
  closed = true;
1558
1583
  serializer.close();
1559
1584
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1560
- const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
1585
+ const document = withShellEnd(assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead), context, renderId, nonce, noScripts);
1561
1586
  if (render) render.shell();
1562
1587
  if (requestEvent && requestEvent.response) {
1563
1588
  commitResponseStub(requestEvent.response, {
@@ -1570,7 +1595,7 @@ function renderToString(code, options = {}) {
1570
1595
  reportServerError(err, {
1571
1596
  kind: "render",
1572
1597
  handling: "failed"
1573
- }, null, options.onError);
1598
+ }, null, options.onError, errorScope);
1574
1599
  throw err;
1575
1600
  } finally {
1576
1601
  if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
@@ -1592,6 +1617,7 @@ function renderToStream(code, options = {}) {
1592
1617
  const nonce = normalizeNonce(options.nonce);
1593
1618
  const requestEvent = peekRequestEvent();
1594
1619
  if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1620
+ const errorScope = requestEvent || {};
1595
1621
  let dispose;
1596
1622
  let dead = false;
1597
1623
  let render;
@@ -1635,7 +1661,15 @@ function renderToStream(code, options = {}) {
1635
1661
  if (dispose) {
1636
1662
  const d = dispose;
1637
1663
  dispose = () => {};
1638
- d();
1664
+ try {
1665
+ d();
1666
+ } catch (err) {
1667
+ reportServerError(err, {
1668
+ kind: "render",
1669
+ handling: "failed"
1670
+ }, null, options.onError, errorScope);
1671
+ if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
1672
+ }
1639
1673
  }
1640
1674
  if (serializer && typeof serializer.close === "function") {
1641
1675
  try {
@@ -1644,7 +1678,7 @@ function renderToStream(code, options = {}) {
1644
1678
  reportServerError(err, {
1645
1679
  kind: "render",
1646
1680
  handling: "serialize"
1647
- }, null, options.onError);
1681
+ }, null, options.onError, errorScope);
1648
1682
  }
1649
1683
  }
1650
1684
  serializer = abandonedSerializer;
@@ -1661,7 +1695,7 @@ function renderToStream(code, options = {}) {
1661
1695
  reportServerError(err, {
1662
1696
  kind: "render",
1663
1697
  handling: "failed"
1664
- }, null, options.onError);
1698
+ }, null, options.onError, errorScope);
1665
1699
  if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
1666
1700
  abandon();
1667
1701
  };
@@ -1716,6 +1750,18 @@ function renderToStream(code, options = {}) {
1716
1750
  const canBatchStubs = !options.serializer && !options.sink;
1717
1751
  let stubBatch = null;
1718
1752
  const STUB_BATCH_KEY = "$B";
1753
+ let stableOrder = false;
1754
+ let parkedWrites = null;
1755
+ const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
1756
+ const write = (id, value) => {
1757
+ if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else serializer.write(id, value);
1758
+ };
1759
+ const flushParkedWrites = () => {
1760
+ if (!parkedWrites) return;
1761
+ const writes = parkedWrites.sort(byKey);
1762
+ parkedWrites = null;
1763
+ for (let i = 0; i < writes.length; i++) serializer.write(writes[i][0], writes[i][1]);
1764
+ };
1719
1765
  const flushStubBatch = () => {
1720
1766
  if (!stubBatch) return;
1721
1767
  const batch = stubBatch;
@@ -1726,7 +1772,9 @@ function renderToStream(code, options = {}) {
1726
1772
  return;
1727
1773
  }
1728
1774
  const obj = {};
1729
- for (const [id, p] of batch) obj[id] = p;
1775
+ const entries = [...batch];
1776
+ if (stableOrder) entries.sort(byKey);
1777
+ for (const [id, p] of entries) obj[id] = p;
1730
1778
  serializer.write(STUB_BATCH_KEY, obj);
1731
1779
  pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
1732
1780
  };
@@ -1798,7 +1846,7 @@ function renderToStream(code, options = {}) {
1798
1846
  }
1799
1847
  },
1800
1848
  shell(shellHtml, meta) {
1801
- buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
1849
+ buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
1802
1850
  },
1803
1851
  ...options.sink
1804
1852
  };
@@ -1826,6 +1874,7 @@ function renderToStream(code, options = {}) {
1826
1874
  end();
1827
1875
  }
1828
1876
  flushStubBatch();
1877
+ flushParkedWrites();
1829
1878
  serializer.flush();
1830
1879
  }));
1831
1880
  }
@@ -1834,7 +1883,7 @@ function renderToStream(code, options = {}) {
1834
1883
  const pendingSerialized = new Map();
1835
1884
  const guardedChannels = new WeakMap();
1836
1885
  const verdictNow = error => {
1837
- throw ssrSanitizeError(error, null);
1886
+ throw ssrSanitizeError(error, null, undefined, undefined, errorScope);
1838
1887
  };
1839
1888
  const borderForm = value => toBorderForm(value);
1840
1889
  const guardIterable = iterable => ({
@@ -1966,6 +2015,7 @@ function renderToStream(code, options = {}) {
1966
2015
  async: true,
1967
2016
  nonce: options.nonce,
1968
2017
  document: !options.sink,
2018
+ edges: !!options.plugins && options.plugins.some(p => p.tag === "solid/server-component"),
1969
2019
  live: {},
1970
2020
  registerHeadTags(tags) {
1971
2021
  registerHeadTags(headRegistry, context, tracking,
@@ -2031,7 +2081,7 @@ function renderToStream(code, options = {}) {
2031
2081
  if (p && typeof p === "object" && typeof p.then === "function") {
2032
2082
  if (!firstFlushed && deferStream) {
2033
2083
  blockingPromises.add(p);
2034
- p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
2084
+ p.then(d => write(id, d)).catch(e => write(id, e));
2035
2085
  return;
2036
2086
  }
2037
2087
  p = trackSerialized(id, p);
@@ -2040,7 +2090,7 @@ function renderToStream(code, options = {}) {
2040
2090
  return;
2041
2091
  }
2042
2092
  }
2043
- serializer.write(id, p);
2093
+ write(id, p);
2044
2094
  },
2045
2095
  escape: escape,
2046
2096
  resolve: resolveSSRNode,
@@ -2071,11 +2121,11 @@ function renderToStream(code, options = {}) {
2071
2121
  defuse(p);
2072
2122
  registry.set(key, {
2073
2123
  resolve: err => queue(() => queue(() => {
2074
- err ? reject(ssrSanitizeError(err, null)) : resolve(true);
2124
+ err ? reject(ssrSanitizeError(err, null, undefined, undefined, errorScope)) : resolve(true);
2075
2125
  queue(flushEnd);
2076
2126
  }))
2077
2127
  });
2078
- if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
2128
+ if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else write(key + "_fr", p);
2079
2129
  }
2080
2130
  return (value, error, escaped) => {
2081
2131
  if (registry.has(key)) {
@@ -2083,7 +2133,7 @@ function renderToStream(code, options = {}) {
2083
2133
  registry.delete(key);
2084
2134
  if (error) abandonSubtree(key);
2085
2135
  if (error && escaped) {
2086
- const wire = ssrSanitizeError(error, null);
2136
+ const wire = ssrSanitizeError(error, null, undefined, undefined, errorScope);
2087
2137
  const message = wire instanceof Error ? wire.message : String(wire);
2088
2138
  if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
2089
2139
  }
@@ -2117,7 +2167,7 @@ function renderToStream(code, options = {}) {
2117
2167
  sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
2118
2168
  styles,
2119
2169
  revealGroup,
2120
- error: error ? ssrSanitizeError(error, null) : error
2170
+ error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
2121
2171
  });
2122
2172
  item.resolve(error);
2123
2173
  }
@@ -2144,6 +2194,7 @@ function renderToStream(code, options = {}) {
2144
2194
  applyAssetTracking(context, tracking, manifest, noScripts);
2145
2195
  context.failRender = failRender;
2146
2196
  context.errorPolicy = options.onError;
2197
+ context._errorScope = errorScope;
2147
2198
  context.flushed = () => firstFlushed;
2148
2199
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
2149
2200
  render = timeDocument(context, context.trace);
@@ -2151,40 +2202,48 @@ function renderToStream(code, options = {}) {
2151
2202
  context.writer = createHydrationWriter(context, () => !completed);
2152
2203
  const signal = options.signal;
2153
2204
  const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
2154
- let html = createRoot(d => {
2155
- dispose = () => {
2156
- context.trace = undefined;
2157
- if (onAbort) signal.removeEventListener("abort", onAbort);
2158
- d();
2159
- };
2160
- rootOwner = claimRenderRoot(context);
2161
- if (requestEvent) claimEventRender(requestEvent, context);
2162
- let res;
2163
- try {
2164
- res = resolveSSRNode(escape(code()));
2165
- } catch (err) {
2166
- reportServerError(err, {
2167
- kind: "render",
2168
- handling: "failed"
2169
- }, null, options.onError);
2170
- throw err;
2171
- }
2172
- if (!res.h.length) return res.t[0];
2173
- rootHoles = [];
2174
- let out = res.t[0];
2175
- for (let i = 0; i < res.h.length; i++) {
2176
- const id = nextHoleId++;
2177
- rootHoles.push({
2178
- id,
2179
- fn: res.h[i]
2180
- });
2181
- out += `<!--rh${id}-->` + res.t[i + 1];
2182
- }
2183
- for (const p of res.p) blockingPromises.add(p);
2184
- return out;
2185
- }, {
2186
- id: renderId
2187
- });
2205
+ const endEdges = context.edges ? beginEdgesRender() : undefined;
2206
+ let html;
2207
+ try {
2208
+ html = createRoot(d => {
2209
+ dispose = () => {
2210
+ context.trace = undefined;
2211
+ if (onAbort) signal.removeEventListener("abort", onAbort);
2212
+ if (endEdges) endEdges();
2213
+ d();
2214
+ };
2215
+ rootOwner = claimRenderRoot(context);
2216
+ if (requestEvent) claimEventRender(requestEvent, context);
2217
+ let res;
2218
+ try {
2219
+ res = resolveSSRNode(escape(code()));
2220
+ } catch (err) {
2221
+ reportServerError(err, {
2222
+ kind: "render",
2223
+ handling: "failed"
2224
+ }, null, options.onError, errorScope);
2225
+ throw err;
2226
+ }
2227
+ if (!res.h.length) return res.t[0];
2228
+ rootHoles = [];
2229
+ let out = res.t[0];
2230
+ for (let i = 0; i < res.h.length; i++) {
2231
+ const id = nextHoleId++;
2232
+ rootHoles.push({
2233
+ id,
2234
+ fn: res.h[i]
2235
+ });
2236
+ out += `<!--rh${id}-->` + res.t[i + 1];
2237
+ }
2238
+ for (const p of res.p) blockingPromises.add(p);
2239
+ return out;
2240
+ }, {
2241
+ id: renderId
2242
+ });
2243
+ } catch (err) {
2244
+ if (endEdges) endEdges();
2245
+ throw err;
2246
+ }
2188
2247
  if (onAbort) {
2189
2248
  if (signal.aborted) onAbort();else signal.addEventListener("abort", onAbort, {
2190
2249
  once: true
@@ -2263,21 +2322,30 @@ function renderToStream(code, options = {}) {
2263
2322
  let lastBlockingSize = -1;
2264
2323
  let lastRegistrySize = -1;
2265
2324
  let drainTurn = 0;
2325
+ let graced = false;
2266
2326
  const scheduleFlush = (fn, awaited) => {
2267
2327
  const attempt = () => {
2268
- flushStubBatch();
2328
+ if (!stableOrder) flushStubBatch();
2269
2329
  if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
2270
2330
  if (registry.size !== lastRegistrySize) drainTurn = 0;
2271
2331
  lastRegistrySize = registry.size;
2272
2332
  queue(attempt);
2273
2333
  return;
2274
2334
  }
2335
+ if (!graced && registry.size) {
2336
+ graced = true;
2337
+ lastRegistrySize = -1;
2338
+ drainTurn = 0;
2339
+ deferFlush(attempt);
2340
+ return;
2341
+ }
2275
2342
  fn();
2276
2343
  };
2277
2344
  const progressed = awaited !== lastBlockingSize;
2278
2345
  lastBlockingSize = awaited;
2279
2346
  lastRegistrySize = -1;
2280
2347
  drainTurn = 0;
2348
+ graced = false;
2281
2349
  progressed ? queue(attempt) : setTimeout(attempt);
2282
2350
  };
2283
2351
  let cachedReadable;
@@ -2344,6 +2412,7 @@ function renderToStream(code, options = {}) {
2344
2412
  };
2345
2413
  return {
2346
2414
  then(onFulfilled, onRejected) {
2415
+ if (canBatchStubs) stableOrder = true;
2347
2416
  const freezeHead = () => {
2348
2417
  if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response, {
2349
2418
  event: requestEvent
@@ -2434,11 +2503,15 @@ function renderToStream(code, options = {}) {
2434
2503
  };
2435
2504
  }
2436
2505
  function HydrationScript(props) {
2437
- const nonce = scriptNonce(sharedConfig.context && sharedConfig.context.nonce);
2438
- return ssr(generateHydrationScript({
2439
- nonce,
2506
+ if (sharedConfig.context) sharedConfig.context.bootstrap = true;
2507
+ const {
2508
+ eventNames,
2509
+ nonce
2510
+ } = {
2511
+ nonce: sharedConfig.context && sharedConfig.context.nonce,
2440
2512
  ...props
2441
- }));
2513
+ };
2514
+ return ssr(hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), true));
2442
2515
  }
2443
2516
  function ssrGroup(fn, n) {
2444
2517
  fn.$g = n;
@@ -2527,8 +2600,8 @@ function ssrGroupSlot(fn, idx) {
2527
2600
  }
2528
2601
  };
2529
2602
  }
2530
- function wireErrorMessage(err) {
2531
- const wire = ssrSanitizeError(err, null);
2603
+ function wireErrorMessage(err, scope) {
2604
+ const wire = ssrSanitizeError(err, null, undefined, undefined, scope);
2532
2605
  return String(wire && wire.message || wire);
2533
2606
  }
2534
2607
  const holePositionCache = new WeakMap();
@@ -2590,28 +2663,78 @@ function holeContentPositions(t) {
2590
2663
  holePositionCache.set(t, cached);
2591
2664
  return cached;
2592
2665
  }
2593
- function createLiveHoles(sink, scoped) {
2666
+ function createLiveHoles(sink, scoped, settled, errorScope) {
2594
2667
  let nextId = 0;
2595
2668
  const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
2596
2669
  const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
2597
- const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
2670
+ const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
2598
2671
  const swept = (owner, ctx, fn) => {
2599
2672
  const prev = sharedConfig.context;
2600
2673
  sharedConfig.context = ctx;
2674
+ let dispose;
2675
+ let before;
2676
+ const run = () => createRoot(d => {
2677
+ dispose = d;
2678
+ before = stamp();
2679
+ return fn();
2680
+ }, {
2681
+ transparent: true
2682
+ });
2601
2683
  try {
2602
- return owner ? runWithOwner(owner, fn) : fn();
2684
+ return owner ? runWithOwner(owner, run) : run();
2603
2685
  } finally {
2604
2686
  sharedConfig.context = prev;
2687
+ engine.sweptOwners = before !== undefined && stamp() !== before;
2688
+ if (dispose) dispose();
2605
2689
  }
2606
2690
  };
2691
+ const stripRow = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"|<!--lr-->/g, "");
2692
+ const rowsOf = v => Array.isArray(v) && v.$rows ? v : null;
2693
+ function holeValue(hole) {
2694
+ const b = hole.$lhBinding;
2695
+ if (b) {
2696
+ const v = hole();
2697
+ return b.fn && rowsOf(b.fn()) || v;
2698
+ }
2699
+ if (!hole.$fn) return hole();
2700
+ const v = hole.$fn();
2701
+ return rowsOf(v) || escape(v);
2702
+ }
2703
+ function resolveValue(value, res) {
2704
+ if (!Array.isArray(value) || !value.$rows) {
2705
+ resolveSSRNode(value, res);
2706
+ return null;
2707
+ }
2708
+ let rows = [];
2709
+ for (const row of value) {
2710
+ const r = resolveSSRNode(escape(row));
2711
+ res.t[res.t.length - 1] += "<!--lr-->" + r.t[0];
2712
+ if (r.h.length) {
2713
+ res.t.push(...r.t.slice(1));
2714
+ res.h.push(...r.h);
2715
+ res.p.push(...r.p);
2716
+ rows = null;
2717
+ } else if (rows) rows.push(engine.sweeping ? r.t[0] : stripRow(r.t[0]));
2718
+ }
2719
+ return rows;
2720
+ }
2721
+ function rowOps(last, rows) {
2722
+ const ops = [];
2723
+ for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) ops.push([i, rows[i]]);
2724
+ return ops.length < rows.length ? {
2725
+ n: rows.length,
2726
+ r: ops
2727
+ } : null;
2728
+ }
2607
2729
  function resolveHoleValue(hole) {
2608
2730
  const result = {
2609
2731
  t: [""],
2610
2732
  h: [],
2611
- p: []
2733
+ p: [],
2734
+ rows: null
2612
2735
  };
2613
2736
  try {
2614
- resolveSSRNode(hole(), result);
2737
+ result.rows = resolveValue(holeValue(hole), result);
2615
2738
  } catch (err) {
2616
2739
  const wrap = buildAsyncWrap(err, hole);
2617
2740
  if (!wrap) throw err;
@@ -2629,12 +2752,88 @@ function createLiveHoles(sink, scoped) {
2629
2752
  }
2630
2753
  b.children.length = 0;
2631
2754
  }
2755
+ let tops = 0;
2756
+ const ids = new Map();
2757
+ const scopeFor = hole => {
2758
+ const p = engine.scope;
2759
+ return {
2760
+ id: undefined,
2761
+ p,
2762
+ i: p ? p.c++ : tops++,
2763
+ n: null,
2764
+ c: 0,
2765
+ h: hole
2766
+ };
2767
+ };
2768
+ const scopeId = s => s.id !== undefined ? s.id : s.id = s.p ? scopeId(s.p) + "." + s.i : String(s.i);
2769
+ const collect = (v, id, forget) => (v.occ || (v.occ = new Map())).set(id, forget);
2770
+ function rescope(b, hole, fn) {
2771
+ const prevScope = engine.scope;
2772
+ const prevVisit = engine.visit;
2773
+ engine.scope = {
2774
+ id: scopeId(b.scope),
2775
+ p: null,
2776
+ i: 0,
2777
+ n: null,
2778
+ c: 0,
2779
+ h: hole
2780
+ };
2781
+ const visit = engine.visit = {
2782
+ occ: null
2783
+ };
2784
+ try {
2785
+ return fn();
2786
+ } finally {
2787
+ engine.scope = prevScope;
2788
+ engine.visit = prevVisit;
2789
+ b.next = visit.occ;
2790
+ }
2791
+ }
2792
+ function settleOccurrences(b) {
2793
+ const occ = b.next;
2794
+ b.next = null;
2795
+ if (b.occ) for (const [id, forget] of b.occ) if (!occ || !occ.has(id)) forget();
2796
+ b.occ = occ;
2797
+ if (occ) for (let a = b.up; a; a = a.up) for (const [id, forget] of occ) collect(a, id, forget);
2798
+ }
2799
+ function leave(b, parent, scope, visit) {
2800
+ engine.parent = parent;
2801
+ engine.scope = scope;
2802
+ engine.visit = visit;
2803
+ if (visit && b.occ) for (const [id, forget] of b.occ) collect(visit, id, forget);
2804
+ }
2632
2805
  const engine = {
2633
2806
  suppressed: 0,
2634
2807
  sweeping: false,
2635
2808
  parent: null,
2636
- recordStamp: 0,
2637
2809
  gateHit: false,
2810
+ sweptOwners: false,
2811
+ scope: null,
2812
+ visit: null,
2813
+ dry: false,
2814
+ slotId(prop, given) {
2815
+ const s = engine.scope;
2816
+ if (!s) return given;
2817
+ const n = s.n || (s.n = Object.create(null));
2818
+ const i = n[prop] || 0;
2819
+ n[prop] = i + 1;
2820
+ const sid = scopeId(s);
2821
+ const at = sid + "." + i + "\0" + prop;
2822
+ if (given !== undefined) {
2823
+ ids.set(at, given);
2824
+ return given;
2825
+ }
2826
+ return ids.get(at) || `${prop}#~${sid}.${i}`;
2827
+ },
2828
+ seen(id, forget) {
2829
+ if (engine.visit) collect(engine.visit, id, forget);
2830
+ },
2831
+ nest(hole) {
2832
+ const s = engine.scope;
2833
+ if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
2834
+ engine.scope = scopeFor(hole);
2835
+ return s;
2836
+ },
2638
2837
  content(hole) {
2639
2838
  if (hole.$lhSuppress) {
2640
2839
  const r = {
@@ -2642,10 +2841,12 @@ function createLiveHoles(sink, scoped) {
2642
2841
  h: [],
2643
2842
  p: []
2644
2843
  };
2645
- engine.suppressed++;
2646
- try {
2844
+ let rows = null;
2845
+ const b = hole.$lhBinding;
2846
+ const run = () => {
2847
+ engine.suppressed++;
2647
2848
  try {
2648
- resolveSSRNode(hole(), r);
2849
+ rows = resolveValue(holeValue(hole), r);
2649
2850
  } catch (err) {
2650
2851
  const wrap = buildAsyncWrap(err, hole);
2651
2852
  if (wrap) {
@@ -2653,20 +2854,21 @@ function createLiveHoles(sink, scoped) {
2653
2854
  r.p.push(wrap.p);
2654
2855
  r.t.push("");
2655
2856
  }
2857
+ } finally {
2858
+ engine.suppressed--;
2656
2859
  }
2657
- } finally {
2658
- engine.suppressed--;
2659
- }
2660
- const b = hole.$lhBinding;
2860
+ };
2861
+ b && !engine.sweeping ? rescope(b, hole, run) : run();
2661
2862
  if (b && !b.closed && !r.h.length && !engine.sweeping) {
2662
2863
  b.last = stripMarkers(r.t[0]);
2864
+ b.rows = rows;
2865
+ settleOccurrences(b);
2663
2866
  }
2664
2867
  return r.h.length ? r : r.t[0];
2665
2868
  }
2666
2869
  if (engine.suppressed || engine.sweeping) return null;
2667
2870
  if (hole.$lhSkip) return null;
2668
2871
  if (inScope && !inScope()) return null;
2669
- const recordsBefore = engine.recordStamp;
2670
2872
  const ownersBefore = stamp();
2671
2873
  const owner = getOwner();
2672
2874
  const holeCtx = sharedConfig.context;
@@ -2674,25 +2876,31 @@ function createLiveHoles(sink, scoped) {
2674
2876
  key: null,
2675
2877
  children: [],
2676
2878
  last: null,
2879
+ rows: null,
2880
+ fn: hole.$fn,
2677
2881
  closed: false,
2882
+ scope: undefined,
2883
+ occ: null,
2884
+ next: null,
2885
+ up: engine.parent,
2678
2886
  sweep() {
2679
2887
  if (b.closed) return;
2680
2888
  const prevSweeping = engine.sweeping;
2681
2889
  engine.sweeping = true;
2682
- engine.gateHit = false;
2683
- const sweepOwnersBefore = stamp();
2890
+ engine.dry = b.last === null;
2684
2891
  let res;
2685
2892
  try {
2686
- res = swept(owner, holeCtx, () => resolveHoleValue(hole));
2893
+ res = rescope(b, hole, () => swept(owner, holeCtx, () => resolveHoleValue(hole)));
2687
2894
  } catch (err) {
2688
2895
  b.closed = true;
2689
2896
  sink.closeBinding(b.key);
2690
- sink.error(b.key, wireErrorMessage(err));
2897
+ sink.error(b.key, wireErrorMessage(err, errorScope));
2691
2898
  return;
2692
2899
  } finally {
2693
2900
  engine.sweeping = prevSweeping;
2901
+ engine.dry = false;
2694
2902
  }
2695
- if (engine.gateHit || stamp() !== sweepOwnersBefore) {
2903
+ if (engine.sweptOwners && res.h.length) {
2696
2904
  b.closed = true;
2697
2905
  sink.closeBinding(b.key);
2698
2906
  return;
@@ -2700,29 +2908,38 @@ function createLiveHoles(sink, scoped) {
2700
2908
  if (res.h.length) return;
2701
2909
  const html = res.t[0];
2702
2910
  if (b.last === null || html === b.last) return;
2911
+ const ops = b.rows && res.rows && rowOps(b.rows, res.rows);
2703
2912
  b.last = html;
2913
+ if (ops && !ops.r.length && ops.n === b.rows.length) return;
2914
+ b.rows = res.rows;
2704
2915
  closeChildren(b);
2705
- sink.hole(b.key, html);
2916
+ settleOccurrences(b);
2917
+ sink.hole(b.key, html, ops && !html.includes("<!--slot:") ? ops : null);
2706
2918
  }
2707
2919
  };
2708
2920
  if (engine.parent) engine.parent.children.push(b);
2709
2921
  const prevParent = engine.parent;
2922
+ const prevScope = engine.scope;
2923
+ const prevVisit = engine.visit;
2924
+ const scope = b.scope = scopeFor(hole);
2710
2925
  engine.parent = b;
2926
+ engine.scope = scope;
2927
+ engine.visit = b;
2711
2928
  let value;
2712
2929
  let escalated = null;
2713
2930
  try {
2714
- value = hole();
2931
+ value = holeValue(hole);
2715
2932
  } catch (err) {
2716
2933
  const wrap = buildAsyncWrap(err, hole);
2717
2934
  if (!wrap) {
2718
- engine.parent = prevParent;
2935
+ leave(b, prevParent, prevScope, prevVisit);
2719
2936
  closeChildren(b);
2720
2937
  return "";
2721
2938
  }
2722
2939
  escalated = wrap;
2723
2940
  }
2724
2941
  if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
2725
- engine.parent = prevParent;
2942
+ leave(b, prevParent, prevScope, prevVisit);
2726
2943
  const r = {
2727
2944
  t: [""],
2728
2945
  h: [],
@@ -2737,6 +2954,7 @@ function createLiveHoles(sink, scoped) {
2737
2954
  return r.h.length ? r : r.t[0];
2738
2955
  }
2739
2956
  let res;
2957
+ let rows = null;
2740
2958
  if (escalated) {
2741
2959
  closeChildren(b);
2742
2960
  escalated.fn.$lhSuppress = true;
@@ -2753,23 +2971,25 @@ function createLiveHoles(sink, scoped) {
2753
2971
  p: []
2754
2972
  };
2755
2973
  try {
2756
- resolveSSRNode(value, res);
2974
+ rows = resolveValue(value, res);
2757
2975
  } catch (_) {
2758
- engine.parent = prevParent;
2976
+ leave(b, prevParent, prevScope, prevVisit);
2759
2977
  closeChildren(b);
2760
2978
  return "";
2761
2979
  }
2762
2980
  }
2763
- engine.parent = prevParent;
2764
- if (engine.recordStamp !== recordsBefore || stamp() !== ownersBefore) {
2981
+ leave(b, prevParent, prevScope, prevVisit);
2982
+ if (stamp() !== ownersBefore) {
2765
2983
  return res.h.length ? res : res.t[0];
2766
2984
  }
2985
+ if (!res.h.length && settled && settled()) return res.t[0];
2767
2986
  const id = nextId++;
2768
2987
  const key = b.key = "lh:" + id;
2769
2988
  const open = `<!--lh:${id}-->`;
2770
2989
  const close = `<!--lh:/${id}-->`;
2771
2990
  if (!res.h.length) {
2772
2991
  b.last = stripMarkers(res.t[0]);
2992
+ b.rows = rows;
2773
2993
  sink.openBinding(key, b);
2774
2994
  return open + res.t[0] + close;
2775
2995
  }
@@ -2787,7 +3007,7 @@ function createLiveHoles(sink, scoped) {
2787
3007
  return nextId++;
2788
3008
  },
2789
3009
  active() {
2790
- return !inScope || inScope();
3010
+ return (!inScope || inScope()) && !(settled && settled());
2791
3011
  },
2792
3012
  attr(cap) {
2793
3013
  const owner = getOwner();
@@ -2800,9 +3020,10 @@ function createLiveHoles(sink, scoped) {
2800
3020
  sweep() {
2801
3021
  if (b.closed) return;
2802
3022
  const prevSweeping = engine.sweeping;
3023
+ const prevScope = engine.scope;
2803
3024
  engine.sweeping = true;
3025
+ engine.scope = null;
2804
3026
  engine.gateHit = false;
2805
- const sweepOwnersBefore = stamp();
2806
3027
  let html = "";
2807
3028
  try {
2808
3029
  let group = null;
@@ -2829,15 +3050,21 @@ function createLiveHoles(sink, scoped) {
2829
3050
  };
2830
3051
  swept(owner, holeCtx, run);
2831
3052
  } catch (err) {
2832
- if (ssrHandleError(err, true)) return;
3053
+ if (ssrHandleError(err, true)) {
3054
+ if (!engine.sweptOwners) return;
3055
+ b.closed = true;
3056
+ sink.closeBinding(b.key);
3057
+ return;
3058
+ }
2833
3059
  b.closed = true;
2834
3060
  sink.closeBinding(b.key);
2835
- sink.error("lha:" + cap.id, wireErrorMessage(err));
3061
+ sink.error("lha:" + cap.id, wireErrorMessage(err, errorScope));
2836
3062
  return;
2837
3063
  } finally {
2838
3064
  engine.sweeping = prevSweeping;
3065
+ engine.scope = prevScope;
2839
3066
  }
2840
- if (engine.gateHit || stamp() !== sweepOwnersBefore) {
3067
+ if (engine.gateHit) {
2841
3068
  b.closed = true;
2842
3069
  sink.closeBinding(b.key);
2843
3070
  return;
@@ -2902,7 +3129,9 @@ function ssr(t) {
2902
3129
  cap = {
2903
3130
  id,
2904
3131
  parts: [prefix],
2905
- base: prefix
3132
+ base: prefix,
3133
+ at: lastOpen.seg,
3134
+ inject
2906
3135
  };
2907
3136
  return true;
2908
3137
  };
@@ -2951,7 +3180,10 @@ function ssr(t) {
2951
3180
  });
2952
3181
  }
2953
3182
  } else {
2954
- cap = null;
3183
+ if (cap) {
3184
+ result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
3185
+ cap = null;
3186
+ }
2955
3187
  result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
2956
3188
  result.p.push(lastGroupVal.p);
2957
3189
  result.t.push("");
@@ -3013,12 +3245,15 @@ function ssr(t) {
3013
3245
  f: hole
3014
3246
  });
3015
3247
  } else {
3248
+ result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
3016
3249
  cap = null;
3017
3250
  }
3018
3251
  }
3019
3252
  } else {
3020
3253
  const capturing = live && !hp.pos[i - 1] && captureStart();
3254
+ const scope = live && hp.pos[i - 1] && live.nest(hole);
3021
3255
  const r = tryResolveFunctionHole(hole);
3256
+ if (scope) live.scope = scope;
3022
3257
  if (typeof r === "string") {
3023
3258
  s += r;
3024
3259
  if (capturing) {
@@ -3028,7 +3263,10 @@ function ssr(t) {
3028
3263
  });
3029
3264
  }
3030
3265
  } else {
3031
- if (capturing) cap = null;
3266
+ if (capturing) {
3267
+ s = s.replace(cap.inject, "");
3268
+ cap = null;
3269
+ }
3032
3270
  result = {
3033
3271
  t: [s],
3034
3272
  h: [],
@@ -3092,14 +3330,12 @@ function ssrClassName(value) {
3092
3330
  if (typeof value === "number") return "" + value;
3093
3331
  if (!value) return "";
3094
3332
  if (typeof value === "string") return escape(value, true);
3095
- if (isSlotValue(value)) return "";
3096
3333
  value = classListToObject(value);
3097
3334
  let classKeys = Object.keys(value),
3098
3335
  result = "";
3099
3336
  for (let i = 0, len = classKeys.length; i < len; i++) {
3100
3337
  const key = classKeys[i];
3101
- let classValue = value[key];
3102
- if (isSlotValue(classValue)) classValue = slotValueInline();
3338
+ const classValue = value[key];
3103
3339
  if (!key || key === "undefined" || !classValue) continue;
3104
3340
  result && (result += " ");
3105
3341
  result += escape(key, true);
@@ -3109,13 +3345,11 @@ function ssrClassName(value) {
3109
3345
  function ssrStyle(value) {
3110
3346
  if (!value) return "";
3111
3347
  if (typeof value === "string") return escape(value, true);
3112
- if (isSlotValue(value)) return "";
3113
3348
  let result = "";
3114
3349
  const k = Object.keys(value);
3115
3350
  for (let i = 0; i < k.length; i++) {
3116
3351
  const s = escape(k[i], true);
3117
- let v = value[k[i]];
3118
- if (isSlotValue(v)) v = slotValueInline();
3352
+ const v = value[k[i]];
3119
3353
  if (v != undefined) {
3120
3354
  const r = escape(v, true);
3121
3355
  if (r != undefined && r !== "undefined") {
@@ -3127,7 +3361,6 @@ function ssrStyle(value) {
3127
3361
  return result;
3128
3362
  }
3129
3363
  function ssrStyleProperty(name, value) {
3130
- if (isSlotValue(value)) value = slotValueInline();
3131
3364
  return value != null ? name + value : "";
3132
3365
  }
3133
3366
  function ssrStyleProperties(...entries) {
@@ -3138,29 +3371,25 @@ function ssrStyleProperties(...entries) {
3138
3371
  }
3139
3372
  return result;
3140
3373
  }
3141
- function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3374
+ function ssrElement(tag, props, children, needsId, skip, attrs) {
3142
3375
  const hk = needsId ? ssrHydrationKey() : "";
3143
3376
  if (typeof props === "function") props = props();
3144
3377
  let sources = null;
3145
3378
  let proxy = false;
3146
3379
  let viewKeys = null;
3147
3380
  let owners = null;
3148
- let ownerIndex = null;
3149
3381
  const ctx = renderConfig.context;
3150
- const slots = ctx !== undefined && ctx.claims !== undefined;
3382
+ const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
3151
3383
  if (Array.isArray(props)) {
3152
- if (slots && props.$slot === true) props = slotSpreadSource();else {
3153
- let i = 0;
3154
- for (; i < props.length; i++) {
3155
- const s = props[i];
3156
- if (s == null || typeof s === "function" || $PROXY in s || slots && s.$slot === true) break;
3157
- }
3158
- if (i === props.length) sources = props;else {
3159
- viewKeys = [];
3160
- owners = [];
3161
- if (slots) ownerIndex = [];
3162
- collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
3163
- }
3384
+ let i = 0;
3385
+ for (; i < props.length; i++) {
3386
+ const s = props[i];
3387
+ if (s == null || typeof s === "function" || $PROXY in s) break;
3388
+ }
3389
+ if (i === props.length) sources = props;else {
3390
+ viewKeys = [];
3391
+ owners = [];
3392
+ collectSpreadSources(props, viewKeys, owners);
3164
3393
  }
3165
3394
  } else if (props == null) {
3166
3395
  props = {};
@@ -3170,13 +3399,10 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3170
3399
  owners = [];
3171
3400
  sourceOwners(props, viewKeys, owners);
3172
3401
  } else proxy = true;
3173
- } else if (slots && props.$slot === true) {
3174
- props = slotSpreadSource();
3175
3402
  }
3176
3403
  const info = tagInfo(tag);
3177
3404
  const skipChildren = info.isVoid;
3178
3405
  let result = info.open + hk;
3179
- let behaviors = null;
3180
3406
  let childOwner = null;
3181
3407
  const last = sources === null ? 0 : sources.length - 1;
3182
3408
  let keysOf = null;
@@ -3188,7 +3414,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3188
3414
  const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
3189
3415
  if (sources !== null) props = sources[s];
3190
3416
  nextKey: for (let i = 0; i < keys.length; i++) {
3191
- const prop = keys[i];
3417
+ let prop = keys[i];
3192
3418
  if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
3193
3419
  if (owners !== null) props = owners[i];
3194
3420
  for (let j = s + 1; j <= last; j++) {
@@ -3205,21 +3431,15 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3205
3431
  }
3206
3432
  continue;
3207
3433
  }
3208
- const value = props[prop];
3209
- if (value == undefined) {
3210
- if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3211
- continue;
3434
+ const key = prop;
3435
+ if (info.formAttributes !== undefined) {
3436
+ prop = spreadFormAttribute(prop, info, keys, keysOf, skip);
3437
+ if (prop === undefined) continue;
3212
3438
  }
3213
- if (prop.startsWith("prop:")) {
3214
- continue;
3215
- }
3216
- if (prop === "ref" || isEventName(prop)) {
3217
- if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
3218
- continue;
3219
- }
3220
- if (slots && typeof value === "object") {
3221
- result += spreadObjectAttribute(prop, value);
3222
- } else if (prop === "style") {
3439
+ const value = props[key];
3440
+ if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
3441
+ if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
3442
+ if (prop === "style") {
3223
3443
  result += ` style="${ssrStyle(value)}"`;
3224
3444
  } else if (prop === "class") {
3225
3445
  result += ` class="${ssrClassName(value)}"`;
@@ -3230,8 +3450,8 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3230
3450
  }
3231
3451
  }
3232
3452
  }
3233
- if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
3234
3453
  if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
3454
+ if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
3235
3455
  if (skipChildren) return {
3236
3456
  t: result + " />"
3237
3457
  };
@@ -3249,21 +3469,36 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3249
3469
  };
3250
3470
  return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
3251
3471
  }
3472
+ function collectSpreadSources(props, viewKeys, owners) {
3473
+ for (let i = 0; i < props.length; i++) {
3474
+ let s = props[i];
3475
+ if (typeof s === "function") s = s();
3476
+ if (s != null) sourceOwners(s, viewKeys, owners);
3477
+ }
3478
+ }
3479
+ function spreadFormAttribute(prop, info, keys, keysOf, skip) {
3480
+ const defaultProp = info.formDefaults[prop];
3481
+ if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
3482
+ if (keysOf !== null) {
3483
+ for (let j = 0; j < keysOf.length; j++) {
3484
+ if (keysOf[j].includes(defaultProp)) return;
3485
+ }
3486
+ } else if (keys.includes(defaultProp)) return;
3487
+ }
3488
+ const attr = info.formAttributes[prop];
3489
+ if (attr !== undefined && skip !== undefined && skip(attr)) return;
3490
+ return attr === undefined ? prop : attr;
3491
+ }
3252
3492
  function ssrElementAttribute(key, value) {
3253
3493
  if (value == undefined) return "";
3254
- if (key === "style" || key === "class") {
3255
- return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
3256
- }
3257
- if (isSlotValue(value)) return slotAttribute(key, value);
3494
+ if (key === "style" || key === "class") return ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
3258
3495
  if (typeof value === "boolean") return value ? ` ${key}` : "";
3259
3496
  return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
3260
3497
  }
3261
3498
  function ssrAttribute(key, value) {
3262
3499
  if (typeof value === "string") return ` ${key}="${value}"`;
3263
3500
  if (value == null || value === false) return "";
3264
- if (typeof value === "object") {
3265
- return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
3266
- }
3501
+ if (typeof value === "object") return ` ${key}="${escape(String(value), true)}"`;
3267
3502
  if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
3268
3503
  return value === true ? ` ${key}` : ` ${key}="${value}"`;
3269
3504
  }
@@ -3271,231 +3506,10 @@ function ssrHydrationKey() {
3271
3506
  const hk = getHydrationKey();
3272
3507
  return hk ? ` _hk=${hk}` : "";
3273
3508
  }
3274
- const CLAIMS_STREAM = 1;
3275
- const CLAIMS_DOCUMENT = 2;
3276
- const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
3277
- const SLOT_MARKER = "_s:";
3278
- const SLOT_FACE_STREAM = 0;
3279
- const SLOT_FACE_DATA = 1;
3280
- const SLOT_FACE_MARKUP = 2;
3281
- function isSlotValue(value) {
3282
- return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
3283
- }
3284
- function slotValue(occurrence, key, value, face) {
3285
- const sv = {
3286
- [SLOT_VALUE]: occurrence,
3287
- k: key,
3288
- v: value,
3289
- f: face
3290
- };
3291
- Object.defineProperty(sv, Symbol.toPrimitive, {
3292
- value: hint => slotValueString()
3293
- });
3294
- Object.defineProperty(sv, "toString", {
3295
- value: () => slotValueString()
3296
- });
3297
- Object.defineProperty(sv, "w", {
3298
- value: () => slotText(sv)
3299
- });
3300
- return sv;
3301
- }
3302
- function slotValueString(sv, reason) {
3303
- return "";
3304
- }
3305
- function slotText(sv) {
3306
- const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
3307
- const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
3308
- return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
3309
- }
3310
- function slotValueInline(kind, sv) {
3311
- return undefined;
3312
- }
3313
- const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
3314
- function encodeSlotKey(key) {
3315
- return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
3316
- }
3317
- function slotEntry(sv, name) {
3318
- return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
3319
- }
3320
- function slotMarker(position, entries) {
3321
- return ` ${SLOT_MARKER}${position}="${entries}"`;
3322
- }
3323
- function eventSlotStamp(mode) {
3324
- return mode === CLAIMS_DOCUMENT ? " _hk" : "";
3325
- }
3326
- function slotAttribute(key, sv) {
3327
- let out = "";
3328
- if (sv.f === SLOT_FACE_DATA) {
3329
- const v = sv.v;
3330
- if (v != null && v !== false) {
3331
- out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
3332
- }
3333
- }
3334
- return out + slotMarker(key, slotEntry(sv));
3335
- }
3336
- function slotClassOrStyle(key, value) {
3337
- const isClass = key === "class";
3338
- if (isSlotValue(value)) {
3339
- let out = "";
3340
- if (value.f === SLOT_FACE_DATA && value.v != null) {
3341
- out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
3342
- }
3343
- return out + slotMarker(key, slotEntry(value));
3344
- }
3345
- if (typeof value === "object" && value !== null) {
3346
- const obj = isClass ? classListToObject(value) : value;
3347
- let entries = "";
3348
- let inner = "";
3349
- for (const name of Object.keys(obj)) {
3350
- let v = obj[name];
3351
- if (isSlotValue(v)) {
3352
- entries += (entries ? "," : "") + slotEntry(v, name);
3353
- v = v.f === SLOT_FACE_DATA ? v.v : undefined;
3354
- }
3355
- if (isClass) {
3356
- if (!name || name === "undefined" || !v) continue;
3357
- inner += (inner ? " " : "") + escape(name, true);
3358
- } else if (v != undefined) {
3359
- const r = escape(v, true);
3360
- if (r != undefined && r !== "undefined") {
3361
- inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
3362
- }
3363
- }
3364
- }
3365
- if (entries === "") return ` ${key}="${inner}"`;
3366
- return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
3367
- }
3368
- return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
3369
- }
3370
- function eventPosition(prop) {
3371
- return prop.slice(2).toLowerCase();
3372
- }
3373
- function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
3374
- if (!isAttrName(prop)) return behaviors;
3375
- const pos = prop === "ref" ? "ref" : eventPosition(prop);
3376
- const entries = value == null ? "" : claimEntries(pos, value);
3377
- if (!settle) {
3378
- if (entries) (behaviors ||= new Map()).set(pos, entries);
3379
- return behaviors;
3380
- }
3381
- behaviors ||= new Map();
3382
- const b = behaviors.get(pos);
3383
- if (b === undefined) behaviors.set(pos, {
3384
- e: entries,
3385
- at: index
3386
- });else {
3387
- b.e = entries;
3388
- b.at = index;
3389
- }
3390
- return behaviors;
3391
- }
3392
- function spreadBehaviorMarkers(behaviors, claims, mode) {
3393
- if (claims !== undefined) {
3394
- const segments = claims();
3395
- for (const k in segments) {
3396
- const map = segments[k];
3397
- for (const pos in map) {
3398
- const value = map[pos];
3399
- behaviors ||= new Map();
3400
- const b = behaviors.get(pos);
3401
- if (pos === "ref") {
3402
- if (value == null) continue;
3403
- const entries = claimEntries("ref", value);
3404
- if (!entries) continue;
3405
- if (b === undefined) behaviors.set("ref", {
3406
- e: entries,
3407
- at: -1
3408
- });else b.e = b.e ? b.e + "," + entries : entries;
3409
- continue;
3410
- }
3411
- if (b !== undefined && b.at >= +k) continue;
3412
- const entries = value == null ? "" : claimEntries(pos, value);
3413
- if (b === undefined) behaviors.set(pos, {
3414
- e: entries,
3415
- at: -1
3416
- });else b.e = entries;
3417
- }
3418
- }
3419
- }
3420
- let out = "";
3421
- let events = false;
3422
- if (behaviors !== null) {
3423
- for (const [pos, b] of behaviors) {
3424
- const e = claims === undefined ? b : b.e;
3425
- if (!e) continue;
3426
- if (pos === "ref") out += slotMarker("ref", e);else {
3427
- out += slotMarker("on:" + pos, e);
3428
- events = true;
3429
- }
3430
- }
3431
- }
3432
- return events ? out + eventSlotStamp(mode) : out;
3433
- }
3434
- function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3435
- for (let i = 0; i < props.length; i++) {
3436
- let s = props[i];
3437
- if (typeof s === "function") s = s();
3438
- if (s != null) {
3439
- if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource();
3440
- if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
3441
- const ks = [];
3442
- const os = [];
3443
- sourceOwners(s, ks, os);
3444
- for (let j = 0; j < ks.length; j++) {
3445
- const at = viewKeys.indexOf(ks[j]);
3446
- if (at !== -1) {
3447
- viewKeys.splice(at, 1);
3448
- owners.splice(at, 1);
3449
- ownerIndex.splice(at, 1);
3450
- }
3451
- viewKeys.push(ks[j]);
3452
- owners.push(os[j]);
3453
- ownerIndex.push(i);
3454
- }
3455
- }
3456
- }
3457
- }
3458
- }
3459
- function spreadObjectAttribute(prop, value) {
3460
- if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
3461
- if (!isAttrName(prop)) return "";
3462
- if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
3463
- return ` ${prop}="${escape(value, true)}"`;
3464
- }
3465
- function slotSpreadSource(tag, source) {
3466
- return {};
3467
- }
3468
- function ssrClaim(map) {
3469
- const mode = sharedConfig.context && sharedConfig.context.claims;
3470
- if (!mode) return "";
3471
- let out = "";
3472
- let events = false;
3473
- for (const pos in map) {
3474
- const entries = claimEntries(pos, map[pos]);
3475
- if (!entries) continue;
3476
- if (pos === "ref") out += slotMarker("ref", entries);else {
3477
- out += slotMarker("on:" + pos, entries);
3478
- events = true;
3479
- }
3480
- }
3481
- return events ? out + eventSlotStamp(mode) : out;
3482
- }
3483
- function claimEntries(pos, value, mode) {
3484
- if (Array.isArray(value) && pos !== "ref") {
3485
- return "";
3486
- }
3487
- if (Array.isArray(value)) {
3488
- let entries = "";
3489
- for (const v of value) {
3490
- const inner = claimEntries(pos, v);
3491
- if (inner) entries += (entries ? "," : "") + inner;
3492
- }
3493
- return entries;
3494
- }
3495
- if (isSlotValue(value)) {
3496
- return slotEntry(value);
3497
- }
3498
- return "";
3509
+ function ssrLinkClaim(attrs) {
3510
+ const ctx = renderConfig.context;
3511
+ if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
3512
+ return ctx.linkClaim(attrs);
3499
3513
  }
3500
3514
  function decodeSSREntities(s) {
3501
3515
  return s.indexOf("&") < 0 ? s : s.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&amp;/g, "&");
@@ -3617,7 +3631,6 @@ function escape(s, attr) {
3617
3631
  if (!attr && t === "function") return escapeLate(s);
3618
3632
  if (attr) {
3619
3633
  if (s == null || t === "boolean" || t === "number") return s;
3620
- if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
3621
3634
  return escape(String(s), attr);
3622
3635
  }
3623
3636
  return s;
@@ -3630,6 +3643,7 @@ function escapeLate(fn) {
3630
3643
  if (fn.$esc) return fn;
3631
3644
  const w = () => escape(fn());
3632
3645
  w.$esc = true;
3646
+ w.$fn = fn;
3633
3647
  if (fn.$lhSkip) w.$lhSkip = true;
3634
3648
  if (fn.$lhSuppress) w.$lhSuppress = true;
3635
3649
  if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
@@ -3722,10 +3736,13 @@ function applyRef(r, element) {
3722
3736
  Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
3723
3737
  }
3724
3738
  function generateHydrationScript({
3725
- eventNames = ["click", "input"],
3739
+ eventNames,
3726
3740
  nonce
3727
3741
  } = {}) {
3728
- 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-->`;
3742
+ return hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), false);
3743
+ }
3744
+ function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
3745
+ 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-->`;
3729
3746
  }
3730
3747
  function queue(fn) {
3731
3748
  return Promise.resolve().then(fn);
@@ -3738,6 +3755,13 @@ function allSettled(promises) {
3738
3755
  return size;
3739
3756
  });
3740
3757
  }
3758
+ function withShellEnd(html, context, renderId, nonce, noScripts) {
3759
+ if (noScripts || !context || !context.bootstrap) return html;
3760
+ const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
3761
+ const marker = `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
3762
+ const at = html.indexOf("</body>", html.length - 512);
3763
+ return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
3764
+ }
3741
3765
  function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
3742
3766
  const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
3743
3767
  const title = headTags ? headTags.title : null;
@@ -3928,10 +3952,6 @@ function tryResolveString(node, nested) {
3928
3952
  if (node.h && node.h.length > 0) return {
3929
3953
  merge: node
3930
3954
  };
3931
- if (node[SLOT_VALUE] !== undefined) {
3932
- ssrTextTail = false;
3933
- return node.w();
3934
- }
3935
3955
  if (node.t === undefined) {
3936
3956
  return "";
3937
3957
  }
@@ -3984,9 +4004,6 @@ function resolveSSRNode(node, result = {
3984
4004
  } else if (node.t !== undefined) {
3985
4005
  result.t[result.t.length - 1] += node.t;
3986
4006
  ssrTextTail = false;
3987
- } else if (node[SLOT_VALUE] !== undefined) {
3988
- result.t[result.t.length - 1] += node.w();
3989
- ssrTextTail = false;
3990
4007
  } else ;
3991
4008
  } else if (t === "function") {
3992
4009
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
@@ -3997,6 +4014,7 @@ function resolveSSRNode(node, result = {
3997
4014
  ssrTextTail = true;
3998
4015
  } else resolveSSRNode(liveNode, result, false, true);
3999
4016
  } else {
4017
+ const scope = live && live.nest(node);
4000
4018
  try {
4001
4019
  resolveSSRNode(node(), result, false, true);
4002
4020
  } catch (err) {
@@ -4008,6 +4026,8 @@ function resolveSSRNode(node, result = {
4008
4026
  result.t.push("");
4009
4027
  ssrTextTail = true;
4010
4028
  }
4029
+ } finally {
4030
+ if (scope) live.scope = scope;
4011
4031
  }
4012
4032
  }
4013
4033
  }
@@ -4090,13 +4110,30 @@ function createHydrationWriter(context, isOpen) {
4090
4110
  };
4091
4111
  }
4092
4112
  function getHydrationWriter() {
4113
+ const ctx = currentRenderContext();
4114
+ return ctx && ctx.writer;
4115
+ }
4116
+ function currentRenderContext() {
4093
4117
  let ctx = renderContextOf(getOwner());
4094
4118
  if (!ctx) {
4095
4119
  const event = peekRequestEvent();
4096
4120
  const renders = event && eventRenders.get(event);
4097
4121
  if (renders && renders.size === 1) for (const c of renders) ctx = c;
4098
4122
  }
4099
- return ctx && ctx.writer;
4123
+ return ctx;
4124
+ }
4125
+ const LINK_STATE_RECORD = "links";
4126
+ function setLinkClaim(handler) {
4127
+ const ctx = currentRenderContext();
4128
+ if (!ctx) {
4129
+ return false;
4130
+ }
4131
+ ctx.linkClaim = handler;
4132
+ if (handler !== undefined) ctx.writer.write(LINK_STATE_RECORD, 1);
4133
+ return true;
4134
+ }
4135
+ function hasServerLinkState() {
4136
+ return false;
4100
4137
  }
4101
4138
  function takeHydrationValue(_key) {
4102
4139
  return undefined;
@@ -4388,84 +4425,17 @@ function dispatchAsInteraction(_e, fn) {
4388
4425
  return fn();
4389
4426
  }
4390
4427
  function notSup() {
4391
- 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>.");
4428
+ 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>.");
4392
4429
  }
4393
4430
 
4394
4431
  setContainerTraceResolver(getProjectionTrace);
4395
4432
  setAsyncIterableSharer(shareAsyncIterable);
4396
4433
  const isServer = true;
4397
4434
  const isDev = false;
4435
+ const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4398
4436
  function dynamic(source, options) {
4399
4437
  return dynamicCore(source, options, ssrTag);
4400
4438
  }
4401
- function dynamicComponent(source, options) {
4402
- return dynamicCore(source, options);
4403
- }
4404
- const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4405
- function dynamicCore(source, options, tagArm) {
4406
- if (options?.static) {
4407
- const component = untrack(source);
4408
- if (typeof component === "function") return props => component(props);
4409
- if (typeof component === "string" && tagArm) return props => tagArm(component, props);
4410
- return () => undefined;
4411
- }
4412
- const cached = createMemo(() => {
4413
- const next = source();
4414
- if (!next || typeof next.then !== "function") return next;
4415
- return {
4416
- [FLIGHT]: next
4417
- };
4418
- });
4419
- const deferStream = !!options?.deferStream;
4420
- return props => {
4421
- const ctx = sharedConfig.context;
4422
- let gated = !deferStream || !ctx?.async;
4423
- const value = createMemo(() => {
4424
- let c;
4425
- try {
4426
- c = cached();
4427
- } catch (err) {
4428
- if (!gated && err instanceof NotReadyError && !err.source?.$clientHole) {
4429
- gated = true;
4430
- ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
4431
- }
4432
- throw err;
4433
- }
4434
- if (!c || !c[FLIGHT]) return c;
4435
- const next = c[FLIGHT];
4436
- return {
4437
- then: (onFulfilled, onRejected) => next.then(resolved => {
4438
- let landed;
4439
- try {
4440
- landed = classifyLanding(resolved);
4441
- } catch (err) {
4442
- if (onRejected) return onRejected(err);
4443
- throw err;
4444
- }
4445
- return onFulfilled ? onFulfilled(landed) : landed;
4446
- }, onRejected)
4447
- };
4448
- }, {
4449
- deferStream
4450
- });
4451
- return createMemo(() => {
4452
- const c = value();
4453
- if (c) {
4454
- if (typeof c === "function") return c(props);
4455
- if (typeof c === "string" && tagArm) return tagArm(c, props);
4456
- }
4457
- }, {
4458
- sync: true
4459
- });
4460
- };
4461
- }
4462
- const FLIGHT = Symbol("solid.dynamic-flight");
4463
- const SERVER_COMPONENT = Symbol.for("solid.server-component");
4464
- function classifyLanding(resolved) {
4465
- if (typeof resolved !== "function" || SERVER_COMPONENT in resolved) return resolved;
4466
- const message = "[DYNAMIC_ASYNC_COMPONENT] An async dynamic() source resolved to a client component function";
4467
- throw new Error(message);
4468
- }
4469
4439
  function Dynamic(props) {
4470
4440
  const Comp = dynamic(() => props.component);
4471
4441
  return createComponent(Comp, omit(props, "component"));
@@ -4594,4 +4564,4 @@ function httpHeader(name, value, options) {
4594
4564
  }
4595
4565
  }
4596
4566
 
4597
- 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 };
4567
+ 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 };