@solidjs/web 2.0.0-rc.15 → 2.0.0-rc.17

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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +361 -483
  3. package/dist/server.js +346 -391
  4. package/dist/server.observe.js +346 -391
  5. package/dist/web.dev.js +110 -55
  6. package/dist/web.js +51 -50
  7. package/dist/web.observe.js +61 -55
  8. package/frames/dist/client.dev.js +610 -621
  9. package/frames/dist/client.js +540 -566
  10. package/frames/dist/client.observe.js +571 -573
  11. package/frames/dist/regions.js +43 -2
  12. package/frames/dist/server.dev.js +793 -424
  13. package/frames/dist/server.js +792 -371
  14. package/frames/dist/server.observe.js +792 -371
  15. package/frames/dist/wire.js +371 -6
  16. package/package.json +11 -11
  17. package/serialization/dist/decode.js +9 -7
  18. package/serialization/dist/serialization.js +9 -7
  19. package/serialization/types/serializer-decode.d.ts +2 -2
  20. package/server-functions/dist/client.dev.js +13 -22
  21. package/server-functions/dist/client.js +11 -22
  22. package/server-functions/dist/client.observe.js +13 -22
  23. package/server-functions/dist/rich-args.js +84 -1
  24. package/server-functions/dist/server.dev.js +194 -20
  25. package/server-functions/dist/server.js +194 -20
  26. package/server-functions/dist/server.observe.js +194 -20
  27. package/skills/server-components/SKILL.md +74 -185
  28. package/types/client.d.ts +27 -5
  29. package/types/diagnostics.d.ts +16 -0
  30. package/types/frames/assets-tier.d.ts +2 -2
  31. package/types/frames/client.d.ts +8 -3
  32. package/types/frames/frame-client.d.ts +121 -157
  33. package/types/frames/frame-morph.d.ts +28 -0
  34. package/types/frames/frame-sink.d.ts +13 -9
  35. package/types/frames/frame-transport.d.ts +30 -1
  36. package/types/frames/regions-tier.d.ts +15 -0
  37. package/types/frames/serializer-decode.d.ts +2 -2
  38. package/types/frames/server.d.ts +0 -52
  39. package/types/frames/wire-tier.d.ts +54 -1
  40. package/types/index.d.ts +2 -2
  41. package/types/jsx.d.ts +11 -5
  42. package/types/observe.d.ts +14 -7
  43. package/types/render.d.ts +3 -1
  44. package/types/response.d.ts +5 -4
  45. package/types/serializer-decode.d.ts +2 -2
  46. package/types/server-functions/argument-codec.d.ts +30 -0
  47. package/types/server-functions/client.d.ts +27 -9
  48. package/types/server-functions/server.d.ts +23 -2
  49. package/types/server-functions/shared.d.ts +19 -0
  50. package/types/server-functions/uploads.d.ts +50 -0
  51. package/types/server-observe.d.ts +3 -2
  52. package/types/server.d.ts +58 -77
  53. package/frames/dist/bind.dev.js +0 -326
  54. package/frames/dist/bind.js +0 -295
  55. package/types/frames/bind-tier.d.ts +0 -60
@@ -1,7 +1,7 @@
1
1
  import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
- import { sharedConfig, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
4
- export { ssrScope as scope, sharedConfig } from 'solid-js/internal';
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
 
@@ -128,11 +128,9 @@ function parseTraceparent(value) {
128
128
  };
129
129
  }
130
130
  function randomHex(bytes) {
131
- const buffer = new Uint8Array(bytes);
132
- crypto.getRandomValues(buffer);
133
131
  let out = "";
134
- for (let i = 0; i < buffer.length; i++) out += (buffer[i] < 16 ? "0" : "") + buffer[i].toString(16);
135
- 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);
136
134
  }
137
135
  function randomTraceId() {
138
136
  let id = randomHex(16);
@@ -699,7 +697,12 @@ function respond(value, init = {}) {
699
697
  }), value);
700
698
  }
701
699
  headers.set("Content-Type", "application/json");
702
- 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
+ }), {
703
706
  ...responseInit,
704
707
  headers
705
708
  }), value);
@@ -1636,12 +1639,6 @@ function destinationNonce(nonce, destination) {
1636
1639
  const value = typeof nonce === "string" ? nonce : nonce[destination];
1637
1640
  return typeof value === "string" && value ? value : undefined;
1638
1641
  }
1639
- function scriptNonce(nonce) {
1640
- return destinationNonce(nonce, "script");
1641
- }
1642
- function styleNonce(nonce) {
1643
- return destinationNonce(nonce, "style");
1644
- }
1645
1642
  function hasNonceProp(props) {
1646
1643
  for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
1647
1644
  return false;
@@ -1772,6 +1769,8 @@ function renderToString(code, options = {}) {
1772
1769
  onHead
1773
1770
  } = options;
1774
1771
  const nonce = normalizeNonce(options.nonce);
1772
+ const requestEvent = peekRequestEvent();
1773
+ const errorScope = requestEvent || {};
1775
1774
  let scripts = "";
1776
1775
  const serializer = createHydrationSerializer({
1777
1776
  scopeId: renderId,
@@ -1794,6 +1793,7 @@ function renderToString(code, options = {}) {
1794
1793
  resolve: resolveSSRNode,
1795
1794
  ssr: ssr,
1796
1795
  errorPolicy: options.onError,
1796
+ _errorScope: errorScope,
1797
1797
  registerHeadTags(tags) {
1798
1798
  registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
1799
1799
  },
@@ -1828,7 +1828,6 @@ function renderToString(code, options = {}) {
1828
1828
  registerEntryAssets(manifest);
1829
1829
  const context = sharedConfig.context;
1830
1830
  context.writer = createHydrationWriter(context, () => !closed);
1831
- const requestEvent = peekRequestEvent();
1832
1831
  if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1833
1832
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
1834
1833
  const render = timeDocument(context, context.trace, "string", requestEvent);
@@ -1848,7 +1847,7 @@ function renderToString(code, options = {}) {
1848
1847
  closed = true;
1849
1848
  serializer.close();
1850
1849
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1851
- const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead) + shellEndMarker(context, renderId, nonce, noScripts);
1850
+ const document = withShellEnd(assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead), context, renderId, nonce, noScripts);
1852
1851
  if (render) render.shell();
1853
1852
  if (requestEvent && requestEvent.response) {
1854
1853
  commitResponseStub(requestEvent.response, {
@@ -1861,7 +1860,7 @@ function renderToString(code, options = {}) {
1861
1860
  reportServerError(err, {
1862
1861
  kind: "render",
1863
1862
  handling: "failed"
1864
- }, null, options.onError);
1863
+ }, null, options.onError, errorScope);
1865
1864
  throw err;
1866
1865
  } finally {
1867
1866
  if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
@@ -1883,6 +1882,14 @@ function renderToStream(code, options = {}) {
1883
1882
  const nonce = normalizeNonce(options.nonce);
1884
1883
  const requestEvent = peekRequestEvent();
1885
1884
  if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1885
+ const errorScope = requestEvent || {};
1886
+ const reportFailure = (err, handling) => {
1887
+ reportServerError(err, {
1888
+ kind: "render",
1889
+ handling
1890
+ }, null, options.onError, errorScope);
1891
+ if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
1892
+ };
1886
1893
  let dispose;
1887
1894
  let dead = false;
1888
1895
  let render;
@@ -1946,7 +1953,7 @@ function renderToStream(code, options = {}) {
1946
1953
  reportServerError(err, {
1947
1954
  kind: "render",
1948
1955
  handling: "serialize"
1949
- }, null, options.onError);
1956
+ }, null, options.onError, errorScope);
1950
1957
  }
1951
1958
  }
1952
1959
  serializer = abandonedSerializer;
@@ -1960,11 +1967,7 @@ function renderToStream(code, options = {}) {
1960
1967
  } else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
1961
1968
  };
1962
1969
  const failRender = err => {
1963
- reportServerError(err, {
1964
- kind: "render",
1965
- handling: "failed"
1966
- }, null, options.onError);
1967
- if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
1970
+ reportFailure(err, "failed");
1968
1971
  abandon();
1969
1972
  };
1970
1973
  const failRootRender = err => {
@@ -2028,6 +2031,18 @@ function renderToStream(code, options = {}) {
2028
2031
  const canBatchStubs = !options.serializer && !options.sink;
2029
2032
  let stubBatch = null;
2030
2033
  const STUB_BATCH_KEY = "$B";
2034
+ let stableOrder = false;
2035
+ let parkedWrites = null;
2036
+ const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
2037
+ const write = (id, value) => {
2038
+ if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else serializer.write(id, value);
2039
+ };
2040
+ const flushParkedWrites = () => {
2041
+ if (!parkedWrites) return;
2042
+ const writes = parkedWrites.sort(byKey);
2043
+ parkedWrites = null;
2044
+ for (let i = 0; i < writes.length; i++) serializer.write(writes[i][0], writes[i][1]);
2045
+ };
2031
2046
  const flushStubBatch = () => {
2032
2047
  if (!stubBatch) return;
2033
2048
  const batch = stubBatch;
@@ -2038,7 +2053,9 @@ function renderToStream(code, options = {}) {
2038
2053
  return;
2039
2054
  }
2040
2055
  const obj = {};
2041
- for (const [id, p] of batch) obj[id] = p;
2056
+ const entries = [...batch];
2057
+ if (stableOrder) entries.sort(byKey);
2058
+ for (const [id, p] of entries) obj[id] = p;
2042
2059
  serializer.write(STUB_BATCH_KEY, obj);
2043
2060
  pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
2044
2061
  };
@@ -2110,7 +2127,7 @@ function renderToStream(code, options = {}) {
2110
2127
  }
2111
2128
  },
2112
2129
  shell(shellHtml, meta) {
2113
- buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead) + shellEndMarker(context, renderId, nonce, noScripts));
2130
+ buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
2114
2131
  },
2115
2132
  ...options.sink
2116
2133
  };
@@ -2119,7 +2136,7 @@ function renderToStream(code, options = {}) {
2119
2136
  plugins: options.plugins,
2120
2137
  onData: payload => sink.data(payload),
2121
2138
  onDone,
2122
- onError: serializerErrorHook(options.onError)
2139
+ onError: err => reportFailure(err, "serialize")
2123
2140
  });
2124
2141
  let rootAssetsSerialized = false;
2125
2142
  const serializeRootAssets = () => {
@@ -2138,6 +2155,7 @@ function renderToStream(code, options = {}) {
2138
2155
  end();
2139
2156
  }
2140
2157
  flushStubBatch();
2158
+ flushParkedWrites();
2141
2159
  serializer.flush();
2142
2160
  }));
2143
2161
  }
@@ -2146,7 +2164,7 @@ function renderToStream(code, options = {}) {
2146
2164
  const pendingSerialized = new Map();
2147
2165
  const guardedChannels = new WeakMap();
2148
2166
  const verdictNow = error => {
2149
- throw ssrSanitizeError(error, null);
2167
+ throw ssrSanitizeError(error, null, undefined, undefined, errorScope);
2150
2168
  };
2151
2169
  const borderForm = value => toBorderForm(value);
2152
2170
  const guardIterable = iterable => ({
@@ -2294,6 +2312,7 @@ function renderToStream(code, options = {}) {
2294
2312
  async: true,
2295
2313
  nonce: options.nonce,
2296
2314
  document: !options.sink,
2315
+ edges: !!options.plugins && options.plugins.some(p => p.tag === "solid/server-component"),
2297
2316
  live: {},
2298
2317
  registerHeadTags(tags) {
2299
2318
  registerHeadTags(headRegistry, context, tracking,
@@ -2359,7 +2378,7 @@ function renderToStream(code, options = {}) {
2359
2378
  if (p && typeof p === "object" && typeof p.then === "function") {
2360
2379
  if (!firstFlushed && deferStream) {
2361
2380
  blockingPromises.add(p);
2362
- p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
2381
+ p.then(d => write(id, d)).catch(e => write(id, e));
2363
2382
  return;
2364
2383
  }
2365
2384
  p = trackSerialized(id, p);
@@ -2368,7 +2387,7 @@ function renderToStream(code, options = {}) {
2368
2387
  return;
2369
2388
  }
2370
2389
  }
2371
- serializer.write(id, p);
2390
+ write(id, p);
2372
2391
  },
2373
2392
  escape: escape,
2374
2393
  resolve: resolveSSRNode,
@@ -2399,11 +2418,11 @@ function renderToStream(code, options = {}) {
2399
2418
  defuse(p);
2400
2419
  registry.set(key, {
2401
2420
  resolve: err => queue(() => queue(() => {
2402
- err ? reject(ssrSanitizeError(err, null)) : resolve(true);
2421
+ err ? reject(ssrSanitizeError(err, null, undefined, undefined, errorScope)) : resolve(true);
2403
2422
  queue(flushEnd);
2404
2423
  }))
2405
2424
  });
2406
- if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
2425
+ if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else write(key + "_fr", p);
2407
2426
  }
2408
2427
  return (value, error, escaped) => {
2409
2428
  if (registry.has(key)) {
@@ -2411,7 +2430,7 @@ function renderToStream(code, options = {}) {
2411
2430
  registry.delete(key);
2412
2431
  if (error) abandonSubtree(key, error);
2413
2432
  if (error && escaped) {
2414
- const wire = ssrSanitizeError(error, null);
2433
+ const wire = ssrSanitizeError(error, null, undefined, undefined, errorScope);
2415
2434
  const message = wire instanceof Error ? wire.message : String(wire);
2416
2435
  if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
2417
2436
  }
@@ -2445,7 +2464,7 @@ function renderToStream(code, options = {}) {
2445
2464
  sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
2446
2465
  styles,
2447
2466
  revealGroup,
2448
- error: error ? ssrSanitizeError(error, null) : error
2467
+ error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
2449
2468
  });
2450
2469
  item.resolve(error);
2451
2470
  }
@@ -2472,6 +2491,7 @@ function renderToStream(code, options = {}) {
2472
2491
  applyAssetTracking(context, tracking, manifest, noScripts);
2473
2492
  context.failRender = failRender;
2474
2493
  context.errorPolicy = options.onError;
2494
+ context._errorScope = errorScope;
2475
2495
  context.flushed = () => firstFlushed;
2476
2496
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
2477
2497
  render = timeDocument(context, context.trace, "stream", requestEvent);
@@ -2479,40 +2499,52 @@ function renderToStream(code, options = {}) {
2479
2499
  context.writer = createHydrationWriter(context, () => !completed);
2480
2500
  const signal = options.signal;
2481
2501
  const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
2482
- let html = createRoot(d => {
2483
- dispose = () => {
2484
- context.trace = undefined;
2485
- if (onAbort) signal.removeEventListener("abort", onAbort);
2486
- d();
2487
- };
2488
- rootOwner = claimRenderRoot(context);
2489
- if (requestEvent) claimEventRender(requestEvent, context);
2490
- let res;
2491
- try {
2492
- res = resolveSSRNode(escape(code()));
2493
- } catch (err) {
2494
- reportServerError(err, {
2495
- kind: "render",
2496
- handling: "failed"
2497
- }, null, options.onError);
2498
- throw err;
2499
- }
2500
- if (!res.h.length) return res.t[0];
2501
- rootHoles = [];
2502
- let out = res.t[0];
2503
- for (let i = 0; i < res.h.length; i++) {
2504
- const id = nextHoleId++;
2505
- rootHoles.push({
2506
- id,
2507
- fn: res.h[i]
2508
- });
2509
- out += `<!--rh${id}-->` + res.t[i + 1];
2510
- }
2511
- for (const p of res.p) blockingPromises.add(p);
2512
- return out;
2513
- }, {
2514
- id: renderId
2515
- });
2502
+ const endEdges = context.edges ? beginEdgesRender() : undefined;
2503
+ let html;
2504
+ try {
2505
+ html = createRoot(d => {
2506
+ dispose = () => {
2507
+ context.trace = undefined;
2508
+ if (onAbort) signal.removeEventListener("abort", onAbort);
2509
+ if (endEdges) endEdges();
2510
+ try {
2511
+ d();
2512
+ } catch (err) {
2513
+ reportFailure(err, "failed");
2514
+ }
2515
+ };
2516
+ rootOwner = claimRenderRoot(context);
2517
+ if (requestEvent) claimEventRender(requestEvent, context);
2518
+ let res;
2519
+ try {
2520
+ res = resolveSSRNode(escape(code()));
2521
+ } catch (err) {
2522
+ reportServerError(err, {
2523
+ kind: "render",
2524
+ handling: "failed"
2525
+ }, null, options.onError, errorScope);
2526
+ throw err;
2527
+ }
2528
+ if (!res.h.length) return res.t[0];
2529
+ rootHoles = [];
2530
+ let out = res.t[0];
2531
+ for (let i = 0; i < res.h.length; i++) {
2532
+ const id = nextHoleId++;
2533
+ rootHoles.push({
2534
+ id,
2535
+ fn: res.h[i]
2536
+ });
2537
+ out += `<!--rh${id}-->` + res.t[i + 1];
2538
+ }
2539
+ for (const p of res.p) blockingPromises.add(p);
2540
+ return out;
2541
+ }, {
2542
+ id: renderId
2543
+ });
2544
+ } catch (err) {
2545
+ if (endEdges) endEdges();
2546
+ throw err;
2547
+ }
2516
2548
  if (onAbort) {
2517
2549
  if (signal.aborted) onAbort();else signal.addEventListener("abort", onAbort, {
2518
2550
  once: true
@@ -2591,21 +2623,30 @@ function renderToStream(code, options = {}) {
2591
2623
  let lastBlockingSize = -1;
2592
2624
  let lastRegistrySize = -1;
2593
2625
  let drainTurn = 0;
2626
+ let graced = false;
2594
2627
  const scheduleFlush = (fn, awaited) => {
2595
2628
  const attempt = () => {
2596
- flushStubBatch();
2629
+ if (!stableOrder) flushStubBatch();
2597
2630
  if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
2598
2631
  if (registry.size !== lastRegistrySize) drainTurn = 0;
2599
2632
  lastRegistrySize = registry.size;
2600
2633
  queue(attempt);
2601
2634
  return;
2602
2635
  }
2636
+ if (!graced && registry.size) {
2637
+ graced = true;
2638
+ lastRegistrySize = -1;
2639
+ drainTurn = 0;
2640
+ deferFlush(attempt);
2641
+ return;
2642
+ }
2603
2643
  fn();
2604
2644
  };
2605
2645
  const progressed = awaited !== lastBlockingSize;
2606
2646
  lastBlockingSize = awaited;
2607
2647
  lastRegistrySize = -1;
2608
2648
  drainTurn = 0;
2649
+ graced = false;
2609
2650
  progressed ? queue(attempt) : setTimeout(attempt);
2610
2651
  };
2611
2652
  let cachedReadable;
@@ -2672,6 +2713,7 @@ function renderToStream(code, options = {}) {
2672
2713
  };
2673
2714
  return {
2674
2715
  then(onFulfilled, onRejected) {
2716
+ if (canBatchStubs) stableOrder = true;
2675
2717
  const freezeHead = () => {
2676
2718
  if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response, {
2677
2719
  event: requestEvent
@@ -2770,7 +2812,7 @@ function HydrationScript(props) {
2770
2812
  nonce: sharedConfig.context && sharedConfig.context.nonce,
2771
2813
  ...props
2772
2814
  };
2773
- return ssr(hydrationBootstrap(eventNames, scriptNonce(nonce), true));
2815
+ return ssr(hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), true));
2774
2816
  }
2775
2817
  function ssrGroup(fn, n) {
2776
2818
  fn.$g = n;
@@ -2859,8 +2901,8 @@ function ssrGroupSlot(fn, idx) {
2859
2901
  }
2860
2902
  };
2861
2903
  }
2862
- function wireErrorMessage(err) {
2863
- const wire = ssrSanitizeError(err, null);
2904
+ function wireErrorMessage(err, scope) {
2905
+ const wire = ssrSanitizeError(err, null, undefined, undefined, scope);
2864
2906
  return String(wire && wire.message || wire);
2865
2907
  }
2866
2908
  const holePositionCache = new WeakMap();
@@ -2922,28 +2964,89 @@ function holeContentPositions(t) {
2922
2964
  holePositionCache.set(t, cached);
2923
2965
  return cached;
2924
2966
  }
2925
- function createLiveHoles(sink, scoped) {
2967
+ function createLiveHoles(sink, scoped, settled, errorScope) {
2926
2968
  let nextId = 0;
2927
2969
  const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
2928
2970
  const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
2929
2971
  const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
2972
+ const latched = (owner, cause, content) => {
2973
+ devCheck({
2974
+ code: "SSR_LIVE_HOLE_LATCHED",
2975
+ kind: "ssr",
2976
+ severity: "warn",
2977
+ 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).`,
2978
+ data: {
2979
+ cause
2980
+ }
2981
+ }, owner);
2982
+ };
2930
2983
  const swept = (owner, ctx, fn) => {
2931
2984
  const prev = sharedConfig.context;
2932
2985
  sharedConfig.context = ctx;
2986
+ let dispose;
2987
+ let before;
2988
+ const run = () => createRoot(d => {
2989
+ dispose = d;
2990
+ before = stamp();
2991
+ return fn();
2992
+ }, {
2993
+ transparent: true
2994
+ });
2933
2995
  try {
2934
- return owner ? runWithOwner(owner, fn) : fn();
2996
+ return owner ? runWithOwner(owner, run) : run();
2935
2997
  } finally {
2936
2998
  sharedConfig.context = prev;
2999
+ engine.sweptOwners = before !== undefined && stamp() !== before;
3000
+ if (dispose) dispose();
2937
3001
  }
2938
3002
  };
3003
+ const stripRow = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"|<!--lr-->/g, "");
3004
+ const rowsOf = v => Array.isArray(v) && v.$rows ? v : null;
3005
+ function holeValue(hole) {
3006
+ const b = hole.$lhBinding;
3007
+ if (b) {
3008
+ const v = hole();
3009
+ return b.fn && rowsOf(b.fn()) || v;
3010
+ }
3011
+ if (!hole.$fn) return hole();
3012
+ const v = hole.$fn();
3013
+ return rowsOf(v) || escape(v);
3014
+ }
3015
+ function resolveValue(value, res) {
3016
+ if (!Array.isArray(value) || !value.$rows) {
3017
+ resolveSSRNode(value, res);
3018
+ return null;
3019
+ }
3020
+ let rows = [];
3021
+ for (const row of value) {
3022
+ const r = resolveSSRNode(escape(row));
3023
+ res.t[res.t.length - 1] += "<!--lr-->" + r.t[0];
3024
+ if (r.h.length) {
3025
+ res.t.push(...r.t.slice(1));
3026
+ res.h.push(...r.h);
3027
+ res.p.push(...r.p);
3028
+ rows = null;
3029
+ } else if (rows) rows.push(engine.sweeping ? r.t[0] : stripRow(r.t[0]));
3030
+ }
3031
+ return rows;
3032
+ }
3033
+ function rowOps(last, rows) {
3034
+ const ops = [];
3035
+ for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) ops.push([i, rows[i]]);
3036
+ return ops.length < rows.length ? {
3037
+ n: rows.length,
3038
+ r: ops
3039
+ } : null;
3040
+ }
2939
3041
  function resolveHoleValue(hole) {
2940
3042
  const result = {
2941
3043
  t: [""],
2942
3044
  h: [],
2943
- p: []
3045
+ p: [],
3046
+ rows: null
2944
3047
  };
2945
3048
  try {
2946
- resolveSSRNode(hole(), result);
3049
+ result.rows = resolveValue(holeValue(hole), result);
2947
3050
  } catch (err) {
2948
3051
  const wrap = buildAsyncWrap(err, hole);
2949
3052
  if (!wrap) throw err;
@@ -2961,12 +3064,88 @@ function createLiveHoles(sink, scoped) {
2961
3064
  }
2962
3065
  b.children.length = 0;
2963
3066
  }
3067
+ let tops = 0;
3068
+ const ids = new Map();
3069
+ const scopeFor = hole => {
3070
+ const p = engine.scope;
3071
+ return {
3072
+ id: undefined,
3073
+ p,
3074
+ i: p ? p.c++ : tops++,
3075
+ n: null,
3076
+ c: 0,
3077
+ h: hole
3078
+ };
3079
+ };
3080
+ const scopeId = s => s.id !== undefined ? s.id : s.id = s.p ? scopeId(s.p) + "." + s.i : String(s.i);
3081
+ const collect = (v, id, forget) => (v.occ || (v.occ = new Map())).set(id, forget);
3082
+ function rescope(b, hole, fn) {
3083
+ const prevScope = engine.scope;
3084
+ const prevVisit = engine.visit;
3085
+ engine.scope = {
3086
+ id: scopeId(b.scope),
3087
+ p: null,
3088
+ i: 0,
3089
+ n: null,
3090
+ c: 0,
3091
+ h: hole
3092
+ };
3093
+ const visit = engine.visit = {
3094
+ occ: null
3095
+ };
3096
+ try {
3097
+ return fn();
3098
+ } finally {
3099
+ engine.scope = prevScope;
3100
+ engine.visit = prevVisit;
3101
+ b.next = visit.occ;
3102
+ }
3103
+ }
3104
+ function settleOccurrences(b) {
3105
+ const occ = b.next;
3106
+ b.next = null;
3107
+ if (b.occ) for (const [id, forget] of b.occ) if (!occ || !occ.has(id)) forget();
3108
+ b.occ = occ;
3109
+ if (occ) for (let a = b.up; a; a = a.up) for (const [id, forget] of occ) collect(a, id, forget);
3110
+ }
3111
+ function leave(b, parent, scope, visit) {
3112
+ engine.parent = parent;
3113
+ engine.scope = scope;
3114
+ engine.visit = visit;
3115
+ if (visit && b.occ) for (const [id, forget] of b.occ) collect(visit, id, forget);
3116
+ }
2964
3117
  const engine = {
2965
3118
  suppressed: 0,
2966
3119
  sweeping: false,
2967
3120
  parent: null,
2968
- recordStamp: 0,
2969
3121
  gateHit: false,
3122
+ sweptOwners: false,
3123
+ scope: null,
3124
+ visit: null,
3125
+ dry: false,
3126
+ slotId(prop, given) {
3127
+ const s = engine.scope;
3128
+ if (!s) return given;
3129
+ const n = s.n || (s.n = Object.create(null));
3130
+ const i = n[prop] || 0;
3131
+ n[prop] = i + 1;
3132
+ const sid = scopeId(s);
3133
+ const at = sid + "." + i + "\0" + prop;
3134
+ if (given !== undefined) {
3135
+ ids.set(at, given);
3136
+ return given;
3137
+ }
3138
+ return ids.get(at) || `${prop}#~${sid}.${i}`;
3139
+ },
3140
+ seen(id, forget) {
3141
+ if (engine.visit) collect(engine.visit, id, forget);
3142
+ },
3143
+ nest(hole) {
3144
+ const s = engine.scope;
3145
+ if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
3146
+ engine.scope = scopeFor(hole);
3147
+ return s;
3148
+ },
2970
3149
  content(hole) {
2971
3150
  if (hole.$lhSuppress) {
2972
3151
  const r = {
@@ -2974,10 +3153,12 @@ function createLiveHoles(sink, scoped) {
2974
3153
  h: [],
2975
3154
  p: []
2976
3155
  };
2977
- engine.suppressed++;
2978
- try {
3156
+ let rows = null;
3157
+ const b = hole.$lhBinding;
3158
+ const run = () => {
3159
+ engine.suppressed++;
2979
3160
  try {
2980
- resolveSSRNode(hole(), r);
3161
+ rows = resolveValue(holeValue(hole), r);
2981
3162
  } catch (err) {
2982
3163
  const wrap = buildAsyncWrap(err, hole);
2983
3164
  if (wrap) {
@@ -2985,20 +3166,21 @@ function createLiveHoles(sink, scoped) {
2985
3166
  r.p.push(wrap.p);
2986
3167
  r.t.push("");
2987
3168
  }
3169
+ } finally {
3170
+ engine.suppressed--;
2988
3171
  }
2989
- } finally {
2990
- engine.suppressed--;
2991
- }
2992
- const b = hole.$lhBinding;
3172
+ };
3173
+ b && !engine.sweeping ? rescope(b, hole, run) : run();
2993
3174
  if (b && !b.closed && !r.h.length && !engine.sweeping) {
2994
3175
  b.last = stripMarkers(r.t[0]);
3176
+ b.rows = rows;
3177
+ settleOccurrences(b);
2995
3178
  }
2996
3179
  return r.h.length ? r : r.t[0];
2997
3180
  }
2998
3181
  if (engine.suppressed || engine.sweeping) return null;
2999
3182
  if (hole.$lhSkip) return null;
3000
3183
  if (inScope && !inScope()) return null;
3001
- const recordsBefore = engine.recordStamp;
3002
3184
  const ownersBefore = stamp();
3003
3185
  const owner = getOwner();
3004
3186
  const holeCtx = sharedConfig.context;
@@ -3006,25 +3188,32 @@ function createLiveHoles(sink, scoped) {
3006
3188
  key: null,
3007
3189
  children: [],
3008
3190
  last: null,
3191
+ rows: null,
3192
+ fn: hole.$fn,
3009
3193
  closed: false,
3194
+ scope: undefined,
3195
+ occ: null,
3196
+ next: null,
3197
+ up: engine.parent,
3010
3198
  sweep() {
3011
3199
  if (b.closed) return;
3012
3200
  const prevSweeping = engine.sweeping;
3013
3201
  engine.sweeping = true;
3014
- engine.gateHit = false;
3015
- const sweepOwnersBefore = stamp();
3202
+ engine.dry = b.last === null;
3016
3203
  let res;
3017
3204
  try {
3018
- res = swept(owner, holeCtx, () => resolveHoleValue(hole));
3205
+ res = rescope(b, hole, () => swept(owner, holeCtx, () => resolveHoleValue(hole)));
3019
3206
  } catch (err) {
3020
3207
  b.closed = true;
3021
3208
  sink.closeBinding(b.key);
3022
- sink.error(b.key, wireErrorMessage(err));
3209
+ sink.error(b.key, wireErrorMessage(err, errorScope));
3023
3210
  return;
3024
3211
  } finally {
3025
3212
  engine.sweeping = prevSweeping;
3213
+ engine.dry = false;
3026
3214
  }
3027
- if (engine.gateHit || stamp() !== sweepOwnersBefore) {
3215
+ if (engine.sweptOwners && res.h.length) {
3216
+ latched(owner, "owners", true);
3028
3217
  b.closed = true;
3029
3218
  sink.closeBinding(b.key);
3030
3219
  return;
@@ -3032,29 +3221,38 @@ function createLiveHoles(sink, scoped) {
3032
3221
  if (res.h.length) return;
3033
3222
  const html = res.t[0];
3034
3223
  if (b.last === null || html === b.last) return;
3224
+ const ops = b.rows && res.rows && rowOps(b.rows, res.rows);
3035
3225
  b.last = html;
3226
+ if (ops && !ops.r.length && ops.n === b.rows.length) return;
3227
+ b.rows = res.rows;
3036
3228
  closeChildren(b);
3037
- sink.hole(b.key, html);
3229
+ settleOccurrences(b);
3230
+ sink.hole(b.key, html, ops && !html.includes("<!--slot:") ? ops : null);
3038
3231
  }
3039
3232
  };
3040
3233
  if (engine.parent) engine.parent.children.push(b);
3041
3234
  const prevParent = engine.parent;
3235
+ const prevScope = engine.scope;
3236
+ const prevVisit = engine.visit;
3237
+ const scope = b.scope = scopeFor(hole);
3042
3238
  engine.parent = b;
3239
+ engine.scope = scope;
3240
+ engine.visit = b;
3043
3241
  let value;
3044
3242
  let escalated = null;
3045
3243
  try {
3046
- value = hole();
3244
+ value = holeValue(hole);
3047
3245
  } catch (err) {
3048
3246
  const wrap = buildAsyncWrap(err, hole);
3049
3247
  if (!wrap) {
3050
- engine.parent = prevParent;
3248
+ leave(b, prevParent, prevScope, prevVisit);
3051
3249
  closeChildren(b);
3052
3250
  return "";
3053
3251
  }
3054
3252
  escalated = wrap;
3055
3253
  }
3056
3254
  if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
3057
- engine.parent = prevParent;
3255
+ leave(b, prevParent, prevScope, prevVisit);
3058
3256
  const r = {
3059
3257
  t: [""],
3060
3258
  h: [],
@@ -3069,6 +3267,7 @@ function createLiveHoles(sink, scoped) {
3069
3267
  return r.h.length ? r : r.t[0];
3070
3268
  }
3071
3269
  let res;
3270
+ let rows = null;
3072
3271
  if (escalated) {
3073
3272
  closeChildren(b);
3074
3273
  escalated.fn.$lhSuppress = true;
@@ -3085,23 +3284,25 @@ function createLiveHoles(sink, scoped) {
3085
3284
  p: []
3086
3285
  };
3087
3286
  try {
3088
- resolveSSRNode(value, res);
3287
+ rows = resolveValue(value, res);
3089
3288
  } catch (_) {
3090
- engine.parent = prevParent;
3289
+ leave(b, prevParent, prevScope, prevVisit);
3091
3290
  closeChildren(b);
3092
3291
  return "";
3093
3292
  }
3094
3293
  }
3095
- engine.parent = prevParent;
3096
- if (engine.recordStamp !== recordsBefore || stamp() !== ownersBefore) {
3294
+ leave(b, prevParent, prevScope, prevVisit);
3295
+ if (stamp() !== ownersBefore) {
3097
3296
  return res.h.length ? res : res.t[0];
3098
3297
  }
3298
+ if (!res.h.length && settled && settled()) return res.t[0];
3099
3299
  const id = nextId++;
3100
3300
  const key = b.key = "lh:" + id;
3101
3301
  const open = `<!--lh:${id}-->`;
3102
3302
  const close = `<!--lh:/${id}-->`;
3103
3303
  if (!res.h.length) {
3104
3304
  b.last = stripMarkers(res.t[0]);
3305
+ b.rows = rows;
3105
3306
  sink.openBinding(key, b);
3106
3307
  return open + res.t[0] + close;
3107
3308
  }
@@ -3119,7 +3320,7 @@ function createLiveHoles(sink, scoped) {
3119
3320
  return nextId++;
3120
3321
  },
3121
3322
  active() {
3122
- return !inScope || inScope();
3323
+ return (!inScope || inScope()) && !(settled && settled());
3123
3324
  },
3124
3325
  attr(cap) {
3125
3326
  const owner = getOwner();
@@ -3132,9 +3333,10 @@ function createLiveHoles(sink, scoped) {
3132
3333
  sweep() {
3133
3334
  if (b.closed) return;
3134
3335
  const prevSweeping = engine.sweeping;
3336
+ const prevScope = engine.scope;
3135
3337
  engine.sweeping = true;
3338
+ engine.scope = null;
3136
3339
  engine.gateHit = false;
3137
- const sweepOwnersBefore = stamp();
3138
3340
  let html = "";
3139
3341
  try {
3140
3342
  let group = null;
@@ -3161,15 +3363,23 @@ function createLiveHoles(sink, scoped) {
3161
3363
  };
3162
3364
  swept(owner, holeCtx, run);
3163
3365
  } catch (err) {
3164
- if (ssrHandleError(err, true)) return;
3366
+ if (ssrHandleError(err, true)) {
3367
+ if (!engine.sweptOwners) return;
3368
+ latched(owner, "owners", false);
3369
+ b.closed = true;
3370
+ sink.closeBinding(b.key);
3371
+ return;
3372
+ }
3165
3373
  b.closed = true;
3166
3374
  sink.closeBinding(b.key);
3167
- sink.error("lha:" + cap.id, wireErrorMessage(err));
3375
+ sink.error("lha:" + cap.id, wireErrorMessage(err, errorScope));
3168
3376
  return;
3169
3377
  } finally {
3170
3378
  engine.sweeping = prevSweeping;
3379
+ engine.scope = prevScope;
3171
3380
  }
3172
- if (engine.gateHit || stamp() !== sweepOwnersBefore) {
3381
+ if (engine.gateHit) {
3382
+ latched(owner, "records", false);
3173
3383
  b.closed = true;
3174
3384
  sink.closeBinding(b.key);
3175
3385
  return;
@@ -3234,7 +3444,9 @@ function ssr(t) {
3234
3444
  cap = {
3235
3445
  id,
3236
3446
  parts: [prefix],
3237
- base: prefix
3447
+ base: prefix,
3448
+ at: lastOpen.seg,
3449
+ inject
3238
3450
  };
3239
3451
  return true;
3240
3452
  };
@@ -3283,7 +3495,10 @@ function ssr(t) {
3283
3495
  });
3284
3496
  }
3285
3497
  } else {
3286
- cap = null;
3498
+ if (cap) {
3499
+ result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
3500
+ cap = null;
3501
+ }
3287
3502
  result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
3288
3503
  result.p.push(lastGroupVal.p);
3289
3504
  result.t.push("");
@@ -3346,12 +3561,15 @@ function ssr(t) {
3346
3561
  f: hole
3347
3562
  });
3348
3563
  } else {
3564
+ result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
3349
3565
  cap = null;
3350
3566
  }
3351
3567
  }
3352
3568
  } else {
3353
3569
  const capturing = live && !hp.pos[i - 1] && captureStart();
3570
+ const scope = live && hp.pos[i - 1] && live.nest(hole);
3354
3571
  const r = tryResolveFunctionHole(hole);
3572
+ if (scope) live.scope = scope;
3355
3573
  if (typeof r === "string") {
3356
3574
  s += r;
3357
3575
  if (capturing) {
@@ -3361,7 +3579,10 @@ function ssr(t) {
3361
3579
  });
3362
3580
  }
3363
3581
  } else {
3364
- if (capturing) cap = null;
3582
+ if (capturing) {
3583
+ s = s.replace(cap.inject, "");
3584
+ cap = null;
3585
+ }
3365
3586
  result = {
3366
3587
  t: [s],
3367
3588
  h: [],
@@ -3426,14 +3647,12 @@ function ssrClassName(value) {
3426
3647
  if (typeof value === "number") return "" + value;
3427
3648
  if (!value) return "";
3428
3649
  if (typeof value === "string") return escape(value, true);
3429
- if (isSlotValue(value)) return slotValueInline("class", value) ?? "";
3430
3650
  value = classListToObject(value);
3431
3651
  let classKeys = Object.keys(value),
3432
3652
  result = "";
3433
3653
  for (let i = 0, len = classKeys.length; i < len; i++) {
3434
3654
  const key = classKeys[i];
3435
- let classValue = value[key];
3436
- if (isSlotValue(classValue)) classValue = slotValueInline("class", classValue);
3655
+ const classValue = value[key];
3437
3656
  if (!key || key === "undefined" || !classValue) continue;
3438
3657
  result && (result += " ");
3439
3658
  result += escape(key, true);
@@ -3443,13 +3662,11 @@ function ssrClassName(value) {
3443
3662
  function ssrStyle(value) {
3444
3663
  if (!value) return "";
3445
3664
  if (typeof value === "string") return escape(value, true);
3446
- if (isSlotValue(value)) return slotValueInline("style", value) ?? "";
3447
3665
  let result = "";
3448
3666
  const k = Object.keys(value);
3449
3667
  for (let i = 0; i < k.length; i++) {
3450
3668
  const s = escape(k[i], true);
3451
- let v = value[k[i]];
3452
- if (isSlotValue(v)) v = slotValueInline("style", v);
3669
+ const v = value[k[i]];
3453
3670
  if (v != undefined) {
3454
3671
  const r = escape(v, true);
3455
3672
  if (r != undefined && r !== "undefined") {
@@ -3461,7 +3678,6 @@ function ssrStyle(value) {
3461
3678
  return result;
3462
3679
  }
3463
3680
  function ssrStyleProperty(name, value) {
3464
- if (isSlotValue(value)) value = slotValueInline("style", value);
3465
3681
  return value != null ? name + value : "";
3466
3682
  }
3467
3683
  function ssrStyleProperties(...entries) {
@@ -3472,30 +3688,25 @@ function ssrStyleProperties(...entries) {
3472
3688
  }
3473
3689
  return result;
3474
3690
  }
3475
- function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3691
+ function ssrElement(tag, props, children, needsId, skip, attrs) {
3476
3692
  const hk = needsId ? ssrHydrationKey() : "";
3477
3693
  if (typeof props === "function") props = props();
3478
3694
  let sources = null;
3479
3695
  let proxy = false;
3480
3696
  let viewKeys = null;
3481
3697
  let owners = null;
3482
- let ownerIndex = null;
3483
3698
  const ctx = renderConfig.context;
3484
- const slots = ctx !== undefined && ctx.claims !== undefined;
3485
3699
  const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
3486
3700
  if (Array.isArray(props)) {
3487
- if (slots && props.$slot === true) props = slotSpreadSource(tag, props);else {
3488
- let i = 0;
3489
- for (; i < props.length; i++) {
3490
- const s = props[i];
3491
- if (s == null || typeof s === "function" || $PROXY in s || slots && s.$slot === true) break;
3492
- }
3493
- if (i === props.length) sources = props;else {
3494
- viewKeys = [];
3495
- owners = [];
3496
- if (slots) ownerIndex = [];
3497
- collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
3498
- }
3701
+ let i = 0;
3702
+ for (; i < props.length; i++) {
3703
+ const s = props[i];
3704
+ if (s == null || typeof s === "function" || $PROXY in s) break;
3705
+ }
3706
+ if (i === props.length) sources = props;else {
3707
+ viewKeys = [];
3708
+ owners = [];
3709
+ collectSpreadSources(props, viewKeys, owners);
3499
3710
  }
3500
3711
  } else if (props == null) {
3501
3712
  props = {};
@@ -3505,13 +3716,10 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3505
3716
  owners = [];
3506
3717
  sourceOwners(props, viewKeys, owners);
3507
3718
  } else proxy = true;
3508
- } else if (slots && props.$slot === true) {
3509
- props = slotSpreadSource(tag, props);
3510
3719
  }
3511
3720
  const info = tagInfo(tag);
3512
3721
  const skipChildren = info.isVoid;
3513
3722
  let result = info.open + hk;
3514
- let behaviors = null;
3515
3723
  let childOwner = null;
3516
3724
  const last = sources === null ? 0 : sources.length - 1;
3517
3725
  let keysOf = null;
@@ -3546,22 +3754,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3546
3754
  if (prop === undefined) continue;
3547
3755
  }
3548
3756
  const value = props[key];
3549
- if (value == undefined) {
3550
- if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3551
- continue;
3552
- }
3553
- if (prop.startsWith("prop:")) {
3554
- if (slots && typeof value === "object") spreadPropPosition(prop, value);
3555
- continue;
3556
- }
3557
- if (prop === "ref" || isEventName(prop)) {
3558
- if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
3559
- continue;
3560
- }
3757
+ if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
3561
3758
  if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
3562
- if (slots && typeof value === "object") {
3563
- result += spreadObjectAttribute(prop, value);
3564
- } else if (prop === "style") {
3759
+ if (prop === "style") {
3565
3760
  result += ` style="${ssrStyle(value)}"`;
3566
3761
  } else if (prop === "class") {
3567
3762
  result += ` class="${ssrClassName(value)}"`;
@@ -3572,7 +3767,6 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3572
3767
  }
3573
3768
  }
3574
3769
  }
3575
- if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
3576
3770
  if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
3577
3771
  if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
3578
3772
  if (skipChildren) return {
@@ -3592,6 +3786,13 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3592
3786
  };
3593
3787
  return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
3594
3788
  }
3789
+ function collectSpreadSources(props, viewKeys, owners) {
3790
+ for (let i = 0; i < props.length; i++) {
3791
+ let s = props[i];
3792
+ if (typeof s === "function") s = s();
3793
+ if (s != null) sourceOwners(s, viewKeys, owners);
3794
+ }
3795
+ }
3595
3796
  function spreadFormAttribute(prop, info, keys, keysOf, skip) {
3596
3797
  const defaultProp = info.formDefaults[prop];
3597
3798
  if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
@@ -3607,19 +3808,14 @@ function spreadFormAttribute(prop, info, keys, keysOf, skip) {
3607
3808
  }
3608
3809
  function ssrElementAttribute(key, value) {
3609
3810
  if (value == undefined) return "";
3610
- if (key === "style" || key === "class") {
3611
- return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
3612
- }
3613
- if (isSlotValue(value)) return slotAttribute(key, value);
3811
+ if (key === "style" || key === "class") return ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
3614
3812
  if (typeof value === "boolean") return value ? ` ${key}` : "";
3615
3813
  return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
3616
3814
  }
3617
3815
  function ssrAttribute(key, value) {
3618
3816
  if (typeof value === "string") return ` ${key}="${value}"`;
3619
3817
  if (value == null || value === false) return "";
3620
- if (typeof value === "object") {
3621
- return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
3622
- }
3818
+ if (typeof value === "object") return ` ${key}="${escape(String(value), true)}"`;
3623
3819
  if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
3624
3820
  return value === true ? ` ${key}` : ` ${key}="${value}"`;
3625
3821
  }
@@ -3627,319 +3823,6 @@ function ssrHydrationKey() {
3627
3823
  const hk = getHydrationKey();
3628
3824
  return hk ? ` _hk=${hk}` : "";
3629
3825
  }
3630
- const CLAIMS_STREAM = 1;
3631
- const CLAIMS_DOCUMENT = 2;
3632
- const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
3633
- const SLOT_MARKER = "_s:";
3634
- const SLOT_FACE_STREAM = 0;
3635
- const SLOT_FACE_DATA = 1;
3636
- const SLOT_FACE_MARKUP = 2;
3637
- const BINDING_SLOT_POSITION = "BINDING_SLOT_POSITION";
3638
- function slotFinding(sv, reason, position, message, severity = "warn") {
3639
- {
3640
- const ctx = sharedConfig.context;
3641
- if (ctx) {
3642
- const id = `${sv[SLOT_VALUE]}\u0000${sv.k}\u0000${reason}\u0000${position || ""}`;
3643
- const seen = ctx.slotFindings || (ctx.slotFindings = new Set());
3644
- if (seen.has(id)) return;
3645
- seen.add(id);
3646
- }
3647
- devCheck({
3648
- code: BINDING_SLOT_POSITION,
3649
- kind: "ssr",
3650
- severity,
3651
- message,
3652
- data: {
3653
- reason,
3654
- occurrence: sv[SLOT_VALUE],
3655
- key: sv.k,
3656
- position
3657
- }
3658
- });
3659
- }
3660
- }
3661
- function isSlotValue(value) {
3662
- return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
3663
- }
3664
- function slotValue(occurrence, key, value, face) {
3665
- const sv = {
3666
- [SLOT_VALUE]: occurrence,
3667
- k: key,
3668
- v: value,
3669
- f: face
3670
- };
3671
- Object.defineProperty(sv, Symbol.toPrimitive, {
3672
- value: hint => slotValueString(sv, hint === "string" ? "stringified" : "coerced")
3673
- });
3674
- Object.defineProperty(sv, "toString", {
3675
- value: () => slotValueString(sv, "stringified")
3676
- });
3677
- Object.defineProperty(sv, "w", {
3678
- value: () => slotText(sv)
3679
- });
3680
- return sv;
3681
- }
3682
- function slotValueString(sv, reason) {
3683
- {
3684
- const prop = propOfOccurrence(sv[SLOT_VALUE]);
3685
- 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.`);
3686
- }
3687
- return "";
3688
- }
3689
- function slotText(sv) {
3690
- slotMarkupRead(sv, "text");
3691
- const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
3692
- const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
3693
- return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
3694
- }
3695
- function slotMarkupRead(sv, position) {
3696
- if (sv.f === SLOT_FACE_MARKUP) {
3697
- 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.`);
3698
- }
3699
- }
3700
- function slotValueInline(kind, sv) {
3701
- {
3702
- 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.`);
3703
- }
3704
- return undefined;
3705
- }
3706
- const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
3707
- function encodeSlotKey(key) {
3708
- return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
3709
- }
3710
- function slotEntry(sv, name) {
3711
- return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
3712
- }
3713
- function slotMarker(position, entries) {
3714
- return ` ${SLOT_MARKER}${position}="${entries}"`;
3715
- }
3716
- function eventSlotStamp(mode) {
3717
- return mode === CLAIMS_DOCUMENT ? " _hk" : "";
3718
- }
3719
- function propOfOccurrence(occurrence) {
3720
- const i = occurrence.indexOf("#");
3721
- return i === -1 ? occurrence : occurrence.slice(0, i);
3722
- }
3723
- function slotAttribute(key, sv) {
3724
- slotMarkupRead(sv, key);
3725
- let out = "";
3726
- if (sv.f === SLOT_FACE_DATA) {
3727
- const v = sv.v;
3728
- if (v != null && v !== false) {
3729
- out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
3730
- }
3731
- }
3732
- return out + slotMarker(key, slotEntry(sv));
3733
- }
3734
- function slotClassOrStyle(key, value) {
3735
- const isClass = key === "class";
3736
- if (isSlotValue(value)) {
3737
- slotMarkupRead(value, key);
3738
- let out = "";
3739
- if (value.f === SLOT_FACE_DATA && value.v != null) {
3740
- out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
3741
- }
3742
- return out + slotMarker(key, slotEntry(value));
3743
- }
3744
- if (typeof value === "object" && value !== null) {
3745
- const obj = isClass ? classListToObject(value) : value;
3746
- let entries = "";
3747
- let inner = "";
3748
- for (const name of Object.keys(obj)) {
3749
- let v = obj[name];
3750
- if (isSlotValue(v)) {
3751
- slotMarkupRead(v, `${key}:${name}`);
3752
- entries += (entries ? "," : "") + slotEntry(v, name);
3753
- v = v.f === SLOT_FACE_DATA ? v.v : undefined;
3754
- }
3755
- if (isClass) {
3756
- if (!name || name === "undefined" || !v) continue;
3757
- inner += (inner ? " " : "") + escape(name, true);
3758
- } else if (v != undefined) {
3759
- const r = escape(v, true);
3760
- if (r != undefined && r !== "undefined") {
3761
- inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
3762
- }
3763
- }
3764
- }
3765
- if (entries === "") return ` ${key}="${inner}"`;
3766
- return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
3767
- }
3768
- return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
3769
- }
3770
- function eventPosition(prop) {
3771
- return prop.slice(2).toLowerCase();
3772
- }
3773
- function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
3774
- if (!isAttrName(prop)) return behaviors;
3775
- const pos = prop === "ref" ? "ref" : eventPosition(prop);
3776
- const entries = value == null ? "" : claimEntries(pos, value, mode);
3777
- if (!settle) {
3778
- if (entries) (behaviors ||= new Map()).set(pos, entries);
3779
- return behaviors;
3780
- }
3781
- behaviors ||= new Map();
3782
- const b = behaviors.get(pos);
3783
- if (b === undefined) behaviors.set(pos, {
3784
- e: entries,
3785
- at: index
3786
- });else {
3787
- b.e = entries;
3788
- b.at = index;
3789
- }
3790
- return behaviors;
3791
- }
3792
- function spreadBehaviorMarkers(behaviors, claims, mode) {
3793
- if (claims !== undefined) {
3794
- const segments = claims();
3795
- for (const k in segments) {
3796
- const map = segments[k];
3797
- for (const pos in map) {
3798
- const value = map[pos];
3799
- behaviors ||= new Map();
3800
- const b = behaviors.get(pos);
3801
- if (pos === "ref") {
3802
- if (value == null) continue;
3803
- const entries = claimEntries("ref", value, mode);
3804
- if (!entries) continue;
3805
- if (b === undefined) behaviors.set("ref", {
3806
- e: entries,
3807
- at: -1
3808
- });else b.e = b.e ? b.e + "," + entries : entries;
3809
- continue;
3810
- }
3811
- if (b !== undefined && b.at >= +k) continue;
3812
- const entries = value == null ? "" : claimEntries(pos, value, mode);
3813
- if (b === undefined) behaviors.set(pos, {
3814
- e: entries,
3815
- at: -1
3816
- });else b.e = entries;
3817
- }
3818
- }
3819
- }
3820
- let out = "";
3821
- let events = false;
3822
- if (behaviors !== null) {
3823
- for (const [pos, b] of behaviors) {
3824
- const e = claims === undefined ? b : b.e;
3825
- if (!e) continue;
3826
- if (pos === "ref") out += slotMarker("ref", e);else {
3827
- out += slotMarker("on:" + pos, e);
3828
- events = true;
3829
- }
3830
- }
3831
- }
3832
- return events ? out + eventSlotStamp(mode) : out;
3833
- }
3834
- function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3835
- for (let i = 0; i < props.length; i++) {
3836
- let s = props[i];
3837
- if (typeof s === "function") s = s();
3838
- if (s != null) {
3839
- if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource(tag, s);
3840
- if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
3841
- const ks = [];
3842
- const os = [];
3843
- sourceOwners(s, ks, os);
3844
- for (let j = 0; j < ks.length; j++) {
3845
- const at = viewKeys.indexOf(ks[j]);
3846
- if (at !== -1) {
3847
- viewKeys.splice(at, 1);
3848
- owners.splice(at, 1);
3849
- ownerIndex.splice(at, 1);
3850
- }
3851
- viewKeys.push(ks[j]);
3852
- owners.push(os[j]);
3853
- ownerIndex.push(i);
3854
- }
3855
- }
3856
- }
3857
- }
3858
- }
3859
- function spreadPropPosition(prop, value) {
3860
- if (isSlotValue(value)) {
3861
- 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.`);
3862
- }
3863
- }
3864
- function spreadObjectAttribute(prop, value) {
3865
- if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
3866
- if (!isAttrName(prop)) return "";
3867
- if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
3868
- return ` ${prop}="${escape(value, true)}"`;
3869
- }
3870
- function slotSpreadSource(tag, source) {
3871
- {
3872
- const occurrence = source.$occurrence;
3873
- 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.`;
3874
- recordFinding({
3875
- code: BINDING_SLOT_POSITION,
3876
- kind: "ssr",
3877
- severity: "error",
3878
- message: text,
3879
- data: {
3880
- reason: "spread",
3881
- tag,
3882
- occurrence
3883
- }
3884
- });
3885
- throw new Error(text);
3886
- }
3887
- }
3888
- function ssrClaim(map) {
3889
- const mode = sharedConfig.context && sharedConfig.context.claims;
3890
- if (!mode) return "";
3891
- let out = "";
3892
- let events = false;
3893
- for (const pos in map) {
3894
- const entries = claimEntries(pos, map[pos], mode);
3895
- if (!entries) continue;
3896
- if (pos === "ref") out += slotMarker("ref", entries);else {
3897
- out += slotMarker("on:" + pos, entries);
3898
- events = true;
3899
- }
3900
- }
3901
- return events ? out + eventSlotStamp(mode) : out;
3902
- }
3903
- function claimEntries(pos, value, mode) {
3904
- if (Array.isArray(value) && pos !== "ref") {
3905
- {
3906
- const sv = value.find(isSlotValue);
3907
- if (sv !== undefined) {
3908
- 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.`);
3909
- } else claimEntries(pos, value[0], mode);
3910
- }
3911
- return "";
3912
- }
3913
- if (Array.isArray(value)) {
3914
- let entries = "";
3915
- for (const v of value) {
3916
- const inner = claimEntries(pos, v, mode);
3917
- if (inner) entries += (entries ? "," : "") + inner;
3918
- }
3919
- return entries;
3920
- }
3921
- if (isSlotValue(value)) {
3922
- slotMarkupRead(value, pos);
3923
- return slotEntry(value);
3924
- }
3925
- if (typeof value === "function" && !value.$slotWarned && claimInScope(mode)) {
3926
- value.$slotWarned = true;
3927
- devCheck({
3928
- code: BINDING_SLOT_POSITION,
3929
- kind: "ssr",
3930
- severity: "warn",
3931
- 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=\`.`,
3932
- data: {
3933
- reason: "server-local",
3934
- position: pos
3935
- }
3936
- });
3937
- }
3938
- return "";
3939
- }
3940
- function claimInScope(mode) {
3941
- return mode === CLAIMS_STREAM || typeof inServerComponentScope === "function" && inServerComponentScope();
3942
- }
3943
3826
  function ssrLinkClaim(attrs) {
3944
3827
  const ctx = renderConfig.context;
3945
3828
  if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
@@ -4065,7 +3948,6 @@ function escape(s, attr) {
4065
3948
  if (!attr && t === "function") return escapeLate(s);
4066
3949
  if (attr) {
4067
3950
  if (s == null || t === "boolean" || t === "number") return s;
4068
- if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
4069
3951
  return escape(String(s), attr);
4070
3952
  }
4071
3953
  return s;
@@ -4078,10 +3960,8 @@ function escapeLate(fn) {
4078
3960
  if (fn.$esc) return fn;
4079
3961
  const w = () => escape(fn());
4080
3962
  w.$esc = true;
4081
- {
4082
- w.$fn = fn;
4083
- w.$reg = devPeekId();
4084
- }
3963
+ w.$fn = fn;
3964
+ w.$reg = devPeekId();
4085
3965
  if (fn.$lhSkip) w.$lhSkip = true;
4086
3966
  if (fn.$lhSuppress) w.$lhSuppress = true;
4087
3967
  if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
@@ -4177,7 +4057,7 @@ function generateHydrationScript({
4177
4057
  eventNames,
4178
4058
  nonce
4179
4059
  } = {}) {
4180
- return hydrationBootstrap(eventNames, scriptNonce(nonce), false);
4060
+ return hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), false);
4181
4061
  }
4182
4062
  function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
4183
4063
  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-->`;
@@ -4193,10 +4073,12 @@ function allSettled(promises) {
4193
4073
  return size;
4194
4074
  });
4195
4075
  }
4196
- function shellEndMarker(context, renderId, nonce, noScripts) {
4197
- if (noScripts || !context || !context.bootstrap) return "";
4076
+ function withShellEnd(html, context, renderId, nonce, noScripts) {
4077
+ if (noScripts || !context || !context.bootstrap) return html;
4198
4078
  const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
4199
- return `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
4079
+ const marker = `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
4080
+ const at = html.indexOf("</body>", html.length - 512);
4081
+ return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
4200
4082
  }
4201
4083
  function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
4202
4084
  const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
@@ -4388,10 +4270,6 @@ function tryResolveString(node, nested) {
4388
4270
  if (node.h && node.h.length > 0) return {
4389
4271
  merge: node
4390
4272
  };
4391
- if (node[SLOT_VALUE] !== undefined) {
4392
- ssrTextTail = false;
4393
- return node.w();
4394
- }
4395
4273
  if (node.t === undefined) {
4396
4274
  unrecognizedInsert(node);
4397
4275
  return "";
@@ -4445,9 +4323,6 @@ function resolveSSRNode(node, result = {
4445
4323
  } else if (node.t !== undefined) {
4446
4324
  result.t[result.t.length - 1] += node.t;
4447
4325
  ssrTextTail = false;
4448
- } else if (node[SLOT_VALUE] !== undefined) {
4449
- result.t[result.t.length - 1] += node.w();
4450
- ssrTextTail = false;
4451
4326
  } else unrecognizedInsert(node);
4452
4327
  } else if (t === "function") {
4453
4328
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
@@ -4458,6 +4333,7 @@ function resolveSSRNode(node, result = {
4458
4333
  ssrTextTail = true;
4459
4334
  } else resolveSSRNode(liveNode, result, false, true);
4460
4335
  } else {
4336
+ const scope = live && live.nest(node);
4461
4337
  try {
4462
4338
  resolveSSRNode(node(), result, false, true);
4463
4339
  } catch (err) {
@@ -4469,6 +4345,8 @@ function resolveSSRNode(node, result = {
4469
4345
  result.t.push("");
4470
4346
  ssrTextTail = true;
4471
4347
  }
4348
+ } finally {
4349
+ if (scope) live.scope = scope;
4472
4350
  }
4473
4351
  }
4474
4352
  }
@@ -4889,7 +4767,7 @@ function dispatchAsInteraction(_e, fn) {
4889
4767
  return fn();
4890
4768
  }
4891
4769
  function notSup() {
4892
- 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>.");
4770
+ 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>.");
4893
4771
  }
4894
4772
 
4895
4773
  setContainerTraceResolver(getProjectionTrace);
@@ -5028,4 +4906,4 @@ function httpHeader(name, value, options) {
5028
4906
  }
5029
4907
  }
5030
4908
 
5031
- export { CLAIMS_DOCUMENT, CLAIMS_STREAM, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SLOT_FACE_DATA, SLOT_FACE_MARKUP, SLOT_FACE_STREAM, SLOT_MARKER, SLOT_VALUE, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, isSlotValue, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStyleProperty, slotValue, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, styleNonce, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
4909
+ 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 setStatefulProperty, 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 };