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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/server.dev.js +705 -151
  2. package/dist/server.js +604 -123
  3. package/dist/server.observe.js +617 -124
  4. package/dist/web.dev.js +102 -41
  5. package/dist/web.js +75 -37
  6. package/dist/web.observe.js +75 -39
  7. package/frames/dist/assets.js +92 -0
  8. package/frames/dist/bind.dev.js +326 -0
  9. package/frames/dist/bind.js +295 -0
  10. package/frames/dist/client.dev.js +693 -919
  11. package/frames/dist/client.js +636 -917
  12. package/frames/dist/client.observe.js +637 -917
  13. package/frames/dist/regions.js +130 -0
  14. package/frames/dist/server.dev.js +607 -212
  15. package/frames/dist/server.js +554 -212
  16. package/frames/dist/server.observe.js +554 -212
  17. package/frames/dist/trace.js +42 -0
  18. package/frames/dist/wire.js +133 -0
  19. package/package.json +30 -3
  20. package/performance-tracks/dist/performance-tracks.dev.js +2 -1
  21. package/performance-tracks/dist/performance-tracks.observe.js +2 -1
  22. package/performance-tracks/types/index.d.ts +8 -6
  23. package/serialization/dist/decode.js +37 -8
  24. package/serialization/dist/serialization.js +39 -10
  25. package/serialization/types/serializer-decode.d.ts +24 -2
  26. package/server-functions/dist/client.dev.js +178 -72
  27. package/server-functions/dist/client.js +99 -61
  28. package/server-functions/dist/client.observe.js +178 -72
  29. package/server-functions/dist/server.dev.js +117 -56
  30. package/server-functions/dist/server.js +117 -56
  31. package/server-functions/dist/server.observe.js +117 -56
  32. package/skills/server-components/SKILL.md +228 -0
  33. package/types/client.d.ts +37 -2
  34. package/types/constants.d.ts +2 -1
  35. package/types/diagnostics.d.ts +8 -0
  36. package/types/frames/assets-tier.d.ts +78 -0
  37. package/types/frames/bind-tier.d.ts +60 -0
  38. package/types/frames/client.d.ts +37 -3
  39. package/types/frames/frame-client.d.ts +249 -96
  40. package/types/frames/frame-container-plugin.d.ts +2 -10
  41. package/types/frames/frame-sink.d.ts +33 -0
  42. package/types/frames/frame-transport.d.ts +66 -18
  43. package/types/frames/regions-tier.d.ts +45 -0
  44. package/types/frames/serializer-decode.d.ts +24 -2
  45. package/types/frames/server.d.ts +53 -1
  46. package/types/frames/trace-tier.d.ts +2 -0
  47. package/types/frames/tree-rewrite.d.ts +39 -0
  48. package/types/frames/wire-tier.d.ts +116 -0
  49. package/types/index.d.ts +38 -0
  50. package/types/index.server.d.ts +10 -1
  51. package/types/jsx.d.ts +11 -1
  52. package/types/observe.d.ts +182 -12
  53. package/types/request-error-hook.d.ts +5 -0
  54. package/types/serializer-decode.d.ts +24 -2
  55. package/types/server-functions/client.d.ts +26 -0
  56. package/types/server-functions/registry.d.ts +4 -1
  57. package/types/server-functions/shared.d.ts +12 -8
  58. package/types/server-mock.d.ts +13 -1
  59. package/types/server-observe.d.ts +8 -0
  60. package/types/server.d.ts +125 -12
@@ -1,8 +1,8 @@
1
- import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, sharedConfig, createRoot, $PROXY, runWithOwner, createComponent, omit, getNextChildId, untrack, NotReadyError, onCleanup } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, sharedConfig, untrack } from 'solid-js';
3
- import { inServerComponentScope, sourceOwners, viewOf, reportServerError, ssrHandleError, creationStamp, ssrSanitizeError, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
4
- export { ssrScope as scope } from 'solid-js/internal';
5
- import { Feature, createStream, Serializer, getCrossReferenceHeader } from 'seroval';
1
+ import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId, untrack, NotReadyError } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
4
+ export { ssrScope as scope, sharedConfig } from 'solid-js/internal';
5
+ import { createStream, Serializer, getCrossReferenceHeader, Feature } from 'seroval';
6
6
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
7
7
 
8
8
  const DOMWithState = {
@@ -59,6 +59,10 @@ function isHttpNavigationTarget(target) {
59
59
  return false;
60
60
  }
61
61
  }
62
+ function isEventName(name) {
63
+ let c;
64
+ return name.startsWith("on") && (c = name.charCodeAt(2)) > 64 && c < 91;
65
+ }
62
66
 
63
67
  const transparentOptions = {
64
68
  transparent: true,
@@ -90,6 +94,15 @@ function memo(fn) {
90
94
  return createMemo(() => fn(), syncOptions);
91
95
  }
92
96
 
97
+ const REQUEST_ERROR_HOOK = Symbol.for("solid-js/server/request-error-hook");
98
+ function hooks() {
99
+ const g = globalThis;
100
+ return g[REQUEST_ERROR_HOOK] || (g[REQUEST_ERROR_HOOK] = new WeakMap());
101
+ }
102
+ function setRequestErrorHook(event, hook) {
103
+ if (hook !== undefined) hooks().set(event, hook);
104
+ }
105
+
93
106
  const PROVIDER = Symbol.for("solid-js/observe/server/provider");
94
107
  function currentProvider() {
95
108
  if (OBSERVE === undefined) return undefined;
@@ -306,6 +319,7 @@ function observeRender(trace, mode, event) {
306
319
  };
307
320
  trace.render = record;
308
321
  let settled = false;
322
+ let route;
309
323
  return {
310
324
  shell() {
311
325
  if (!settled && record.shellMs === undefined) record.shellMs = performance.now() - record.at;
@@ -313,11 +327,21 @@ function observeRender(trace, mode, event) {
313
327
  boundary() {
314
328
  if (!settled) record.boundaries++;
315
329
  },
330
+ route(ref) {
331
+ if (!settled) route = ref;
332
+ },
316
333
  settle(outcome) {
317
334
  if (settled) return;
318
335
  settled = true;
319
336
  record.durationMs = performance.now() - record.at;
320
337
  record.outcome = outcome;
338
+ if (route !== undefined) {
339
+ const r = {};
340
+ if (route.name !== undefined) r.name = route.name;
341
+ if (route.to !== undefined) r.to = route.to;
342
+ if (route.params !== undefined) r.params = route.params;
343
+ record.route = r;
344
+ }
321
345
  const channel = records();
322
346
  if (!channel.observed("render")) return;
323
347
  const live = {
@@ -329,6 +353,96 @@ function observeRender(trace, mode, event) {
329
353
  };
330
354
  }
331
355
 
356
+ const DESCEND = Symbol("descend");
357
+ const CYCLE = {};
358
+ const TRACK = 16;
359
+ function rewriteTree(value, visit, withPath) {
360
+ if (value === null || typeof value !== "object") return value;
361
+ const path = undefined;
362
+ const state = {
363
+ memo: undefined,
364
+ ancestors: undefined
365
+ };
366
+ try {
367
+ return cow(value, visit, path, 0, state);
368
+ } catch (err) {
369
+ if (err !== CYCLE) throw err;
370
+ }
371
+ return clone(value, visit, path, state.memo || (state.memo = new Map()));
372
+ }
373
+ function shape(value) {
374
+ return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
375
+ }
376
+ function cow(value, visit, path, depth, state) {
377
+ const memo = state.memo;
378
+ if (memo !== undefined && memo.has(value)) return memo.get(value);
379
+ const r = visit(value, path);
380
+ if (r !== DESCEND) {
381
+ if (r !== value) (memo || (state.memo = new Map())).set(value, r);
382
+ return r;
383
+ }
384
+ const s = shape(value);
385
+ if (s === 0) return value;
386
+ let ancestors;
387
+ if (depth >= TRACK) {
388
+ ancestors = state.ancestors || (state.ancestors = new Set());
389
+ if (ancestors.has(value)) throw CYCLE;
390
+ ancestors.add(value);
391
+ }
392
+ let out = value;
393
+ if (s === 1) {
394
+ for (let i = 0; i < value.length; i++) {
395
+ const c = value[i];
396
+ if (c === null || typeof c !== "object") continue;
397
+ const next = cow(c, visit, undefined , depth + 1, state);
398
+ if (next !== c) {
399
+ if (out === value) out = value.slice();
400
+ out[i] = next;
401
+ }
402
+ }
403
+ } else {
404
+ for (const k of Object.keys(value)) {
405
+ const c = value[k];
406
+ if (c === null || typeof c !== "object") continue;
407
+ const next = cow(c, visit, undefined , depth + 1, state);
408
+ if (next !== c) {
409
+ if (out === value) out = {
410
+ ...value
411
+ };
412
+ out[k] = next;
413
+ }
414
+ }
415
+ }
416
+ if (ancestors !== undefined) ancestors.delete(value);
417
+ return out;
418
+ }
419
+ function clone(value, visit, path, memo) {
420
+ if (memo.has(value)) return memo.get(value);
421
+ const r = visit(value, path);
422
+ if (r !== DESCEND) {
423
+ memo.set(value, r);
424
+ return r;
425
+ }
426
+ const s = shape(value);
427
+ if (s === 0) return value;
428
+ const out = s === 1 ? value.slice() : {
429
+ ...value
430
+ };
431
+ memo.set(value, out);
432
+ if (s === 1) {
433
+ for (let i = 0; i < value.length; i++) {
434
+ const c = value[i];
435
+ if (c !== null && typeof c === "object") out[i] = clone(c, visit, undefined , memo);
436
+ }
437
+ } else {
438
+ for (const k of Object.keys(value)) {
439
+ const c = value[k];
440
+ if (c !== null && typeof c === "object") out[k] = clone(c, visit, undefined , memo);
441
+ }
442
+ }
443
+ return out;
444
+ }
445
+
332
446
  const STATE = Symbol.for("solid.container-trace-state");
333
447
  const state = globalThis[STATE] || (globalThis[STATE] = {
334
448
  materialized: new WeakMap(),
@@ -348,32 +462,10 @@ function toBorderForm(value, envelopeContainers) {
348
462
  if (value == null || typeof value !== "object") return value;
349
463
  const share = state.shareIterable;
350
464
  if (!share) return value;
351
- if (share && isShareableIterable(value)) return share(value);
352
- if (Array.isArray(value)) {
353
- let out = value;
354
- for (let i = 0; i < value.length; i++) {
355
- const next = toBorderForm(value[i]);
356
- if (next !== value[i]) {
357
- if (out === value) out = value.slice();
358
- out[i] = next;
359
- }
360
- }
361
- return out;
362
- }
363
- if (Object.getPrototypeOf(value) === Object.prototype) {
364
- let out = value;
365
- for (const key of Object.keys(value)) {
366
- const next = toBorderForm(value[key]);
367
- if (next !== value[key]) {
368
- if (out === value) out = {
369
- ...value
370
- };
371
- out[key] = next;
372
- }
373
- }
374
- return out;
375
- }
376
- return value;
465
+ return rewriteTree(value, v => {
466
+ if (share && isShareableIterable(v)) return share(v);
467
+ return DESCEND;
468
+ });
377
469
  }
378
470
  function isShareableIterable(value) {
379
471
  try {
@@ -384,10 +476,10 @@ function isShareableIterable(value) {
384
476
  return false;
385
477
  }
386
478
  }
387
- function materialize(marker) {
479
+ function materialize(marker, claiming) {
388
480
  let value = state.materialized.get(marker.$tr);
389
481
  if (value === undefined) {
390
- value = state.materializeTrace(marker);
482
+ value = state.materializeTrace(marker, claiming);
391
483
  state.materialized.set(marker.$tr, value);
392
484
  if (value !== null && typeof value === "object") state.materializedValues.add(value);
393
485
  }
@@ -445,23 +537,22 @@ setContainerTraceStreamMint(iterable => {
445
537
  })();
446
538
  return stream;
447
539
  });
448
- const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
540
+ const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
449
541
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
450
542
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
451
543
  ContainerTracePlugin]);
452
544
  function resolveSerializerPlugins(customPlugins) {
453
545
  return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
454
546
  }
455
- Feature.RegExp;
456
547
 
457
- const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
548
+ const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
458
549
  const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
459
550
  const HYDRATION_GLOBAL = "_$HY.r";
460
551
  function createSerializer(options) {
461
552
  return new Serializer({
462
553
  ...options,
463
554
  plugins: resolveSerializerPlugins(options.plugins),
464
- disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
555
+ disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
465
556
  });
466
557
  }
467
558
  function createHydrationSerializer({
@@ -680,7 +771,7 @@ function assertServableCookie(name, options) {
680
771
  }
681
772
  }
682
773
  const FLASH_COOKIE = "flash";
683
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
774
+ const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
684
775
  function hasFlashCookie(cookieHeader) {
685
776
  return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
686
777
  }
@@ -692,7 +783,6 @@ const ERROR_HEADER = "X-Server-Function-Error";
692
783
  const BODY_FORMAT_HEADER = "X-Server-Function-Format";
693
784
  const REDIRECT_HEADER = "X-Server-Function-Redirect";
694
785
  const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
695
- new TextEncoder().encode(":\n\n");
696
786
 
697
787
  function emitFinding(finding, subject = getOwner()) {
698
788
  if (OBSERVE === undefined) return;
@@ -833,6 +923,7 @@ function resolveHead(groups) {
833
923
  return winners;
834
924
  }
835
925
 
926
+ const renderConfig = sharedConfig;
836
927
  function joinAssetPath(base, file) {
837
928
  if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
838
929
  if (typeof base !== "string" || !base) base = "/";
@@ -1014,6 +1105,7 @@ function applyAssetTracking(context, tracking, manifest, noScripts) {
1014
1105
  });
1015
1106
  context.registerModule = tracking.registerModule;
1016
1107
  context.getBoundaryModules = tracking.getBoundaryModules;
1108
+ context._lazyAssets = new Map();
1017
1109
  if (typeof manifest === "function") {
1018
1110
  context.resolveAssets = guard(manifest);
1019
1111
  } else if (manifest && typeof manifest.resolve === "function") {
@@ -1488,7 +1580,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1488
1580
  const t = winner.tags[i];
1489
1581
  const attrs = {};
1490
1582
  for (const name in t.props) {
1491
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1583
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1492
1584
  if (!HEAD_ATTR_NAME.test(name)) {
1493
1585
  headTagInvalid("invalid-attribute", `useHead: ignoring invalid attribute name "${name}"`, name);
1494
1586
  continue;
@@ -1578,7 +1670,7 @@ function nonceAttr(nonce, destination) {
1578
1670
  function renderHeadAttrHtml(props) {
1579
1671
  let attrs = "";
1580
1672
  for (const name in props) {
1581
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1673
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1582
1674
  if (!HEAD_ATTR_NAME.test(name)) {
1583
1675
  headTagInvalid("invalid-attribute", `useHead: ignoring invalid attribute name "${name}"`, name);
1584
1676
  continue;
@@ -1592,7 +1684,7 @@ function renderHeadAttrHtml(props) {
1592
1684
  function headAttrRecord(props, skipRelHref) {
1593
1685
  let attrs = null;
1594
1686
  for (const name in props) {
1595
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1687
+ if (name === "children" || name === "ref" || isEventName(name)) continue;
1596
1688
  if ((name === "rel" || name === "href")) continue;
1597
1689
  if (!HEAD_ATTR_NAME.test(name)) continue;
1598
1690
  const v = props[name];
@@ -1619,10 +1711,13 @@ function useHead(tags) {
1619
1711
  ctx.registerHeadTags(tags);
1620
1712
  }
1621
1713
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
1714
+ const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
1715
+ const TAG_START = /^[a-zA-Z]/;
1622
1716
  const tagInfos = /*#__PURE__*/new Map();
1623
1717
  function tagInfo(tag) {
1624
1718
  let info = tagInfos.get(tag);
1625
1719
  if (info === undefined) {
1720
+ if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
1626
1721
  info = {
1627
1722
  open: "<" + tag,
1628
1723
  close: "</" + tag + ">",
@@ -1635,13 +1730,13 @@ function tagInfo(tag) {
1635
1730
  return info;
1636
1731
  }
1637
1732
  const safeAttrNames = /*#__PURE__*/new Set();
1638
- function attrName(prop) {
1639
- if (safeAttrNames.has(prop)) return prop;
1640
- const escaped = escape(prop);
1641
- if (escaped === prop && safeAttrNames.size < 512) safeAttrNames.add(prop);
1642
- return escaped;
1733
+ function isAttrName(prop) {
1734
+ if (safeAttrNames.has(prop)) return true;
1735
+ if (prop === "" || NOT_NAME.test(prop)) return false;
1736
+ if (safeAttrNames.size < 512) safeAttrNames.add(prop);
1737
+ return true;
1643
1738
  }
1644
- const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
1739
+ const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}function $dfe(e,t,k){(t=e.target)&&t.getAttribute&&!t._$dc&&(k=t.getAttribute("data-dfc"))&&(t._$dc=1,$dfc(k))}document.addEventListener("load",$dfe,!0);document.addEventListener("error",$dfe,!0)`;
1645
1740
  const HEAD_SCRIPT = `function $dha(o,i,e,n){for(i=0;i<o.length;i++)e=o[i],"t"==e[0]?((n=document.querySelector("title"))?n.hasAttribute("data-dh")||n.setAttribute("data-dhf",n.textContent):(n=document.createElement("title"),document.head.appendChild(n)),n.textContent=e[1],n.setAttribute("data-dh","title")):"r"==e[0]?$dhr(e[1]):(n=document.createElement(e[2]),Object.keys(e[3]).forEach(function(a){n.setAttribute(a,e[3][a])}),null!=e[4]&&(n.textContent=e[4]),n.setAttribute("data-dh",e[1]),document.head.appendChild(n))}function $dhr(v,l,i){for(l=document.head.querySelectorAll("[data-dh]"),i=0;i<l.length;i++)l[i].getAttribute("data-dh")==v&&l[i].remove()}function $dh(o){_$HY.h?_$HY.h(o):$dha(o)}`;
1646
1741
  function renderToString(code, options = {}) {
1647
1742
  const {
@@ -1666,6 +1761,7 @@ function renderToString(code, options = {}) {
1666
1761
  });
1667
1762
  const tracking = createAssetTracking();
1668
1763
  const headRegistry = createHeadRegistry();
1764
+ let closed = false;
1669
1765
  sharedConfig.context = {
1670
1766
  nonce: options.nonce,
1671
1767
  escape: escape,
@@ -1676,7 +1772,7 @@ function renderToString(code, options = {}) {
1676
1772
  registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
1677
1773
  },
1678
1774
  serialize(id, p) {
1679
- if (sharedConfig.context.noHydrate) return;
1775
+ if (closed) return;
1680
1776
  if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
1681
1777
  throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
1682
1778
  }
@@ -1705,20 +1801,25 @@ function renderToString(code, options = {}) {
1705
1801
  applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
1706
1802
  registerEntryAssets(manifest);
1707
1803
  const context = sharedConfig.context;
1804
+ context.writer = createHydrationWriter(context, () => !closed);
1708
1805
  const requestEvent = peekRequestEvent();
1806
+ if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1709
1807
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
1710
1808
  const render = timeDocument(context, context.trace, "string", requestEvent);
1711
1809
  let dispose;
1810
+ let rootOwner;
1712
1811
  let rendered = false;
1713
1812
  try {
1714
1813
  const html = createRoot(d => {
1715
1814
  dispose = d;
1815
+ rootOwner = claimRenderRoot(context);
1816
+ if (requestEvent) claimEventRender(requestEvent, context);
1716
1817
  return resolveSSRSync(escape(code()));
1717
1818
  }, {
1718
1819
  id: renderId
1719
1820
  });
1720
1821
  serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
1721
- sharedConfig.context.noHydrate = true;
1822
+ closed = true;
1722
1823
  serializer.close();
1723
1824
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1724
1825
  const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
@@ -1730,12 +1831,20 @@ function renderToString(code, options = {}) {
1730
1831
  }
1731
1832
  rendered = true;
1732
1833
  return document;
1834
+ } catch (err) {
1835
+ reportServerError(err, {
1836
+ kind: "render",
1837
+ handling: "failed"
1838
+ }, null, options.onError);
1839
+ throw err;
1733
1840
  } finally {
1734
- if (render) render.settle(rendered ? "complete" : "error");
1841
+ if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
1735
1842
  context.trace = undefined;
1736
1843
  if (dispose) dispose();
1737
1844
  }
1738
1845
  }
1846
+ const SHELL_ABANDONED = Symbol();
1847
+ const ABANDON_RENDER = Symbol();
1739
1848
  function renderToStream(code, options = {}) {
1740
1849
  let {
1741
1850
  onCompleteShell,
@@ -1747,13 +1856,16 @@ function renderToStream(code, options = {}) {
1747
1856
  } = options;
1748
1857
  const nonce = normalizeNonce(options.nonce);
1749
1858
  const requestEvent = peekRequestEvent();
1859
+ if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
1750
1860
  let dispose;
1751
1861
  let dead = false;
1752
1862
  let render;
1863
+ let rootOwner;
1753
1864
  let serializer;
1754
1865
  let disconnected = false;
1755
1866
  let failed = false;
1756
1867
  let onFailed;
1868
+ let onDisconnectedBeforeShell;
1757
1869
  const defuse = p => {
1758
1870
  if (p && typeof p.then === "function") p.then(undefined, () => {});
1759
1871
  };
@@ -1772,9 +1884,9 @@ function renderToStream(code, options = {}) {
1772
1884
  complete(sink);
1773
1885
  } : complete;
1774
1886
  };
1775
- const abandon = disconnect => {
1887
+ const abandon = (disconnect, quiet) => {
1776
1888
  if (dead) return;
1777
- if (disconnect) emitFinding({
1889
+ if (disconnect && !quiet) emitFinding({
1778
1890
  code: "SSR_STREAM_ABANDONED",
1779
1891
  kind: "ssr",
1780
1892
  severity: "warn",
@@ -1788,7 +1900,7 @@ function renderToStream(code, options = {}) {
1788
1900
  dead = true;
1789
1901
  completed = true;
1790
1902
  if (disconnect) disconnected = true;
1791
- if (render) render.settle(disconnect ? "abandoned" : "error");
1903
+ if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
1792
1904
  const sink = writable;
1793
1905
  buffer = {
1794
1906
  write() {}
@@ -1819,13 +1931,13 @@ function renderToStream(code, options = {}) {
1819
1931
  if (!disconnect) {
1820
1932
  failed = true;
1821
1933
  onFailed && onFailed(sink);
1822
- }
1934
+ } else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
1823
1935
  };
1824
1936
  const failRender = err => {
1825
1937
  reportServerError(err, {
1826
1938
  kind: "render",
1827
1939
  handling: "failed"
1828
- }, null);
1940
+ }, null, options.onError);
1829
1941
  if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
1830
1942
  abandon();
1831
1943
  };
@@ -1929,7 +2041,7 @@ function renderToStream(code, options = {}) {
1929
2041
  });
1930
2042
  writable && writable.end();
1931
2043
  completed = true;
1932
- if (render) render.settle("complete");
2044
+ if (render) settleRender(render, rootOwner, "complete");
1933
2045
  if (firstFlushed) dispose();
1934
2046
  };
1935
2047
  const sink = {
@@ -1946,10 +2058,10 @@ function renderToStream(code, options = {}) {
1946
2058
  const styleAttr = nonceAttr(nonce, "style");
1947
2059
  emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
1948
2060
  writeTasks();
2061
+ buffer.write(`<template id="${key}">${value}</template>`);
1949
2062
  for (const entry of styles.links) {
1950
- buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">` : `<link${entry.attrHtml}${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
2063
+ buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} data-dfc="${key}">` : `<link${entry.attrHtml}${styleAttr} data-dfc="${key}">`);
1951
2064
  }
1952
- buffer.write(`<template id="${key}">${value}</template>`);
1953
2065
  } else {
1954
2066
  buffer.write(`<template id="${key}">${value}</template>`);
1955
2067
  if (!deferActivation) {
@@ -1991,7 +2103,7 @@ function renderToStream(code, options = {}) {
1991
2103
  };
1992
2104
  let holds = 0;
1993
2105
  const flushEnd = () => {
1994
- if (!registry.size && !holds) {
2106
+ if (!registry.size && !holds && !rootHoles) {
1995
2107
  serializeRootAssets();
1996
2108
  queue(() => queue(() => {
1997
2109
  if (context.live.end) {
@@ -2133,6 +2245,12 @@ function renderToStream(code, options = {}) {
2133
2245
  }
2134
2246
  let rootHoles = null;
2135
2247
  let nextHoleId = 0;
2248
+ let parkedInlines = null;
2249
+ function inlineFragment(key, value) {
2250
+ if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
2251
+ (parkedInlines ||= new Map()).set(key, value);
2252
+ } else html = replacePlaceholder(html, key, value);
2253
+ }
2136
2254
  let buffer = {
2137
2255
  write(payload) {
2138
2256
  tmp += payload;
@@ -2211,7 +2329,6 @@ function renderToStream(code, options = {}) {
2211
2329
  html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
2212
2330
  },
2213
2331
  serialize(id, p, deferStream) {
2214
- if (sharedConfig.context.noHydrate) return;
2215
2332
  p = guardChannel(p);
2216
2333
  if (p && typeof p === "object" && typeof p.then === "function") {
2217
2334
  if (!firstFlushed && deferStream) {
@@ -2262,11 +2379,16 @@ function renderToStream(code, options = {}) {
2262
2379
  });
2263
2380
  if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
2264
2381
  }
2265
- return (value, error) => {
2382
+ return (value, error, escaped) => {
2266
2383
  if (registry.has(key)) {
2267
2384
  const item = registry.get(key);
2268
2385
  registry.delete(key);
2269
2386
  if (error) abandonSubtree(key, error);
2387
+ if (error && escaped) {
2388
+ const wire = ssrSanitizeError(error, null);
2389
+ const message = wire instanceof Error ? wire.message : String(wire);
2390
+ if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
2391
+ }
2270
2392
  if (item.children && !error) {
2271
2393
  for (const k in item.children) {
2272
2394
  value = replacePlaceholder(value, k, item.children[k]);
@@ -2286,7 +2408,7 @@ function renderToStream(code, options = {}) {
2286
2408
  if (!completed) {
2287
2409
  if (error) dropHeadBoundary(headRegistry, key);
2288
2410
  if (!firstFlushed) {
2289
- queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
2411
+ queue(() => inlineFragment(key, value !== undefined ? value : ""));
2290
2412
  serializeFragmentAssets(key, tracking.boundaryModules, context);
2291
2413
  item.resolve(error);
2292
2414
  } else {
@@ -2328,15 +2450,27 @@ function renderToStream(code, options = {}) {
2328
2450
  context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
2329
2451
  render = timeDocument(context, context.trace, "stream", requestEvent);
2330
2452
  registerEntryAssets(manifest);
2453
+ context.writer = createHydrationWriter(context, () => !completed);
2331
2454
  const signal = options.signal;
2332
- const onAbort = signal ? () => abandon("signal") : undefined;
2455
+ const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
2333
2456
  let html = createRoot(d => {
2334
2457
  dispose = () => {
2335
2458
  context.trace = undefined;
2336
2459
  if (onAbort) signal.removeEventListener("abort", onAbort);
2337
2460
  d();
2338
2461
  };
2339
- const res = resolveSSRNode(escape(code()));
2462
+ rootOwner = claimRenderRoot(context);
2463
+ if (requestEvent) claimEventRender(requestEvent, context);
2464
+ let res;
2465
+ try {
2466
+ res = resolveSSRNode(escape(code()));
2467
+ } catch (err) {
2468
+ reportServerError(err, {
2469
+ kind: "render",
2470
+ handling: "failed"
2471
+ }, null, options.onError);
2472
+ throw err;
2473
+ }
2340
2474
  if (!res.h.length) return res.t[0];
2341
2475
  rootHoles = [];
2342
2476
  let out = res.t[0];
@@ -2383,6 +2517,13 @@ function renderToStream(code, options = {}) {
2383
2517
  for (const p of res.p) blockingPromises.add(p);
2384
2518
  }
2385
2519
  }
2520
+ if (parkedInlines) {
2521
+ for (const [key, value] of parkedInlines) {
2522
+ if (!html.includes(`<template id="pl-${key}">`)) continue;
2523
+ html = replacePlaceholder(html, key, value);
2524
+ parkedInlines.delete(key);
2525
+ }
2526
+ }
2386
2527
  if (pending.length) {
2387
2528
  rootHoles = pending;
2388
2529
  return false;
@@ -2544,11 +2685,16 @@ function renderToStream(code, options = {}) {
2544
2685
  },
2545
2686
  pipe(w) {
2546
2687
  claimConsumer("pipe");
2688
+ const abandoned = w[SHELL_ABANDONED];
2547
2689
  onFailure(sink => {
2548
2690
  try {
2549
- sink ? sink.end() : w.end();
2691
+ sink ? sink.end() : abandoned ? abandoned() : w.end();
2550
2692
  } catch (_) {}
2551
2693
  });
2694
+ if (abandoned) {
2695
+ w[ABANDON_RENDER] = abandon;
2696
+ if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
2697
+ }
2552
2698
  function flush() {
2553
2699
  allSettled(blockingPromises).then(awaited => {
2554
2700
  scheduleFlush(() => {
@@ -3250,14 +3396,16 @@ function ssrClassName(value) {
3250
3396
  if (typeof value === "number") return "" + value;
3251
3397
  if (!value) return "";
3252
3398
  if (typeof value === "string") return escape(value, true);
3399
+ if (isSlotValue(value)) return slotValueInline("class", value) ?? "";
3253
3400
  value = classListToObject(value);
3254
3401
  let classKeys = Object.keys(value),
3255
3402
  result = "";
3256
3403
  for (let i = 0, len = classKeys.length; i < len; i++) {
3257
- const key = classKeys[i],
3258
- classValue = !!value[key];
3404
+ const key = classKeys[i];
3405
+ let classValue = value[key];
3406
+ if (isSlotValue(classValue)) classValue = slotValueInline("class", classValue);
3259
3407
  if (!key || key === "undefined" || !classValue) continue;
3260
- i && (result += " ");
3408
+ result && (result += " ");
3261
3409
  result += escape(key, true);
3262
3410
  }
3263
3411
  return result;
@@ -3265,15 +3413,17 @@ function ssrClassName(value) {
3265
3413
  function ssrStyle(value) {
3266
3414
  if (!value) return "";
3267
3415
  if (typeof value === "string") return escape(value, true);
3416
+ if (isSlotValue(value)) return slotValueInline("style", value) ?? "";
3268
3417
  let result = "";
3269
3418
  const k = Object.keys(value);
3270
3419
  for (let i = 0; i < k.length; i++) {
3271
3420
  const s = escape(k[i], true);
3272
- const v = value[k[i]];
3421
+ let v = value[k[i]];
3422
+ if (isSlotValue(v)) v = slotValueInline("style", v);
3273
3423
  if (v != undefined) {
3274
- if (i) result += ";";
3275
3424
  const r = escape(v, true);
3276
3425
  if (r != undefined && r !== "undefined") {
3426
+ if (result) result += ";";
3277
3427
  result += `${s}:${r}`;
3278
3428
  }
3279
3429
  }
@@ -3281,28 +3431,39 @@ function ssrStyle(value) {
3281
3431
  return result;
3282
3432
  }
3283
3433
  function ssrStyleProperty(name, value) {
3434
+ if (isSlotValue(value)) value = slotValueInline("style", value);
3284
3435
  return value != null ? name + value : "";
3285
3436
  }
3286
- function ssrElement(tag, props, children, needsId, skip, attrs) {
3437
+ function ssrStyleProperties(...entries) {
3438
+ let result = "";
3439
+ for (let i = 0; i < entries.length; i += 2) {
3440
+ const entry = ssrStyleProperty(entries[i], entries[i + 1]);
3441
+ if (entry) result = result ? result + ";" + entry : entry;
3442
+ }
3443
+ return result;
3444
+ }
3445
+ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3287
3446
  const hk = needsId ? ssrHydrationKey() : "";
3288
3447
  if (typeof props === "function") props = props();
3289
3448
  let sources = null;
3290
3449
  let proxy = false;
3291
3450
  let viewKeys = null;
3292
3451
  let owners = null;
3452
+ let ownerIndex = null;
3453
+ const ctx = renderConfig.context;
3454
+ const slots = ctx !== undefined && ctx.claims !== undefined;
3293
3455
  if (Array.isArray(props)) {
3294
- let i = 0;
3295
- for (; i < props.length; i++) {
3296
- const s = props[i];
3297
- if (s == null || typeof s === "function" || $PROXY in s) break;
3298
- }
3299
- if (i === props.length) sources = props;else {
3300
- viewKeys = [];
3301
- owners = [];
3302
- for (let i = 0; i < props.length; i++) {
3303
- let s = props[i];
3304
- if (typeof s === "function") s = s();
3305
- if (s != null) sourceOwners(s, viewKeys, owners);
3456
+ if (slots && props.$slot === true) props = slotSpreadSource(tag, props);else {
3457
+ let i = 0;
3458
+ for (; i < props.length; i++) {
3459
+ const s = props[i];
3460
+ if (s == null || typeof s === "function" || $PROXY in s || slots && s.$slot === true) break;
3461
+ }
3462
+ if (i === props.length) sources = props;else {
3463
+ viewKeys = [];
3464
+ owners = [];
3465
+ if (slots) ownerIndex = [];
3466
+ collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
3306
3467
  }
3307
3468
  }
3308
3469
  } else if (props == null) {
@@ -3313,10 +3474,14 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
3313
3474
  owners = [];
3314
3475
  sourceOwners(props, viewKeys, owners);
3315
3476
  } else proxy = true;
3477
+ } else if (slots && props.$slot === true) {
3478
+ props = slotSpreadSource(tag, props);
3316
3479
  }
3317
3480
  const info = tagInfo(tag);
3318
3481
  const skipChildren = info.isVoid;
3319
3482
  let result = info.open + hk;
3483
+ let behaviors = null;
3484
+ let childOwner = null;
3320
3485
  const last = sources === null ? 0 : sources.length - 1;
3321
3486
  let keysOf = null;
3322
3487
  if (sources !== null) {
@@ -3339,42 +3504,43 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
3339
3504
  continue;
3340
3505
  }
3341
3506
  if (ChildProperties.has(prop)) {
3342
- if (children === undefined && !skipChildren) children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
3507
+ if (children === undefined && childOwner === null && !skipChildren) {
3508
+ if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
3509
+ }
3343
3510
  continue;
3344
3511
  }
3345
3512
  const value = props[prop];
3346
- if (value == undefined || prop === "ref" || prop.startsWith("on") || prop.startsWith("prop:")) {
3347
- if (typeof value === "function" && value[CLAIM_PROP] !== undefined && (prop === "ref" || prop.slice(0, 2) === "on")) {
3348
- devCheck({
3349
- code: "BEHAVIOR_CLAIM_DROPPED",
3350
- kind: "ssr",
3351
- severity: "warn",
3352
- message: `[BEHAVIOR_CLAIM_DROPPED] A spread on a server-rendered <${tag}> carries \`${prop}\` from client props — ` + `spreads don't participate in behavior claims, so this drops. ` + `Write the position out: \`${prop}={props.${String(value[CLAIM_PROP])}}\`.`,
3353
- data: {
3354
- reason: "spread",
3355
- tag,
3356
- position: prop,
3357
- prop: String(value[CLAIM_PROP])
3358
- }
3359
- });
3360
- }
3513
+ if (value == undefined) {
3514
+ if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3515
+ continue;
3516
+ }
3517
+ if (prop.startsWith("prop:")) {
3518
+ if (slots && typeof value === "object") spreadPropPosition(prop, value);
3361
3519
  continue;
3520
+ }
3521
+ if (prop === "ref" || isEventName(prop)) {
3522
+ if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
3523
+ continue;
3524
+ }
3525
+ if (slots && typeof value === "object") {
3526
+ result += spreadObjectAttribute(prop, value);
3362
3527
  } else if (prop === "style") {
3363
3528
  result += ` style="${ssrStyle(value)}"`;
3364
3529
  } else if (prop === "class") {
3365
3530
  result += ` class="${ssrClassName(value)}"`;
3366
3531
  } else if (typeof value === "boolean") {
3367
- if (!value) continue;
3368
- result += ` ${attrName(prop)}`;
3369
- } else {
3370
- result += value === "" ? ` ${attrName(prop)}` : ` ${attrName(prop)}="${escape(value, true)}"`;
3532
+ if (value && isAttrName(prop)) result += ` ${prop}`;
3533
+ } else if (isAttrName(prop)) {
3534
+ result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
3371
3535
  }
3372
3536
  }
3373
3537
  }
3538
+ if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
3374
3539
  if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
3375
3540
  if (skipChildren) return {
3376
3541
  t: result + " />"
3377
3542
  };
3543
+ if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
3378
3544
  if (typeof children === "function") children = children();
3379
3545
  const ct = typeof children;
3380
3546
  if (ct === "string" || ct === "number") return {
@@ -3390,56 +3556,338 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
3390
3556
  }
3391
3557
  function ssrElementAttribute(key, value) {
3392
3558
  if (value == undefined) return "";
3393
- if (key === "style") return ` style="${ssrStyle(value)}"`;
3394
- if (key === "class") return ` class="${ssrClassName(value)}"`;
3559
+ if (key === "style" || key === "class") {
3560
+ return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
3561
+ }
3562
+ if (isSlotValue(value)) return slotAttribute(key, value);
3395
3563
  if (typeof value === "boolean") return value ? ` ${key}` : "";
3396
3564
  return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
3397
3565
  }
3398
3566
  function ssrAttribute(key, value) {
3399
- return value == null || value === false ? "" : value === true ? ` ${key}` : ` ${key}="${value}"`;
3567
+ if (typeof value === "string") return ` ${key}="${value}"`;
3568
+ if (value == null || value === false) return "";
3569
+ if (typeof value === "object") {
3570
+ return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
3571
+ }
3572
+ if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
3573
+ return value === true ? ` ${key}` : ` ${key}="${value}"`;
3400
3574
  }
3401
3575
  function ssrHydrationKey() {
3402
3576
  const hk = getHydrationKey();
3403
3577
  return hk ? ` _hk=${hk}` : "";
3404
3578
  }
3405
- const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
3406
3579
  const CLAIMS_STREAM = 1;
3407
3580
  const CLAIMS_DOCUMENT = 2;
3408
- const CLAIM_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
3409
- function encodeClaimKey(key) {
3410
- return String(key).replace(CLAIM_UNSAFE, c => encodeURIComponent(c));
3581
+ const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
3582
+ const SLOT_MARKER = "_s:";
3583
+ const SLOT_FACE_STREAM = 0;
3584
+ const SLOT_FACE_DATA = 1;
3585
+ const SLOT_FACE_MARKUP = 2;
3586
+ const BINDING_SLOT_POSITION = "BINDING_SLOT_POSITION";
3587
+ function slotFinding(sv, reason, position, message, severity = "warn") {
3588
+ {
3589
+ const ctx = sharedConfig.context;
3590
+ if (ctx) {
3591
+ const id = `${sv[SLOT_VALUE]}\u0000${sv.k}\u0000${reason}\u0000${position || ""}`;
3592
+ const seen = ctx.slotFindings || (ctx.slotFindings = new Set());
3593
+ if (seen.has(id)) return;
3594
+ seen.add(id);
3595
+ }
3596
+ devCheck({
3597
+ code: BINDING_SLOT_POSITION,
3598
+ kind: "ssr",
3599
+ severity,
3600
+ message,
3601
+ data: {
3602
+ reason,
3603
+ occurrence: sv[SLOT_VALUE],
3604
+ key: sv.k,
3605
+ position
3606
+ }
3607
+ });
3608
+ }
3411
3609
  }
3412
- function ssrClaim(map) {
3413
- const mode = sharedConfig.context && sharedConfig.context.claims;
3414
- if (!mode || mode === CLAIMS_DOCUMENT && !(typeof inServerComponentScope === "function" && inServerComponentScope())) {
3415
- return "";
3610
+ function isSlotValue(value) {
3611
+ return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
3612
+ }
3613
+ function slotValue(occurrence, key, value, face) {
3614
+ const sv = {
3615
+ [SLOT_VALUE]: occurrence,
3616
+ k: key,
3617
+ v: value,
3618
+ f: face
3619
+ };
3620
+ Object.defineProperty(sv, Symbol.toPrimitive, {
3621
+ value: hint => slotValueString(sv, hint === "string" ? "stringified" : "coerced")
3622
+ });
3623
+ Object.defineProperty(sv, "toString", {
3624
+ value: () => slotValueString(sv, "stringified")
3625
+ });
3626
+ Object.defineProperty(sv, "w", {
3627
+ value: () => slotText(sv)
3628
+ });
3629
+ return sv;
3630
+ }
3631
+ function slotValueString(sv, reason) {
3632
+ {
3633
+ const prop = propOfOccurrence(sv[SLOT_VALUE]);
3634
+ slotFinding(sv, reason, undefined, reason === "coerced" ? `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value used in an expression ` + `(a comparison, arithmetic, or a branch on its result). The server does not have the value — ` + `the client owns it — so nothing can be computed from it here. It must be the WHOLE value of ` + `an attribute, class name, style property, handler, ref or text child; a decision that depends on it ` + `belongs in the client fill (return the decided value) or in a markup slot.` : `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value ` + `and was stringified outside a bindable position — it must be the WHOLE value of an attribute, ` + `class name, style property, handler, ref or text child (\`class={row.${sv.k}}\`, not \`class={\`x \${row.${sv.k}}\`}\`). ` + `If it is, the element was compiled without the \`serverComponents\` compiler option. ` + `Nothing renders here on either face.`);
3635
+ }
3636
+ return "";
3637
+ }
3638
+ function slotText(sv) {
3639
+ slotMarkupRead(sv, "text");
3640
+ const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
3641
+ const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
3642
+ return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
3643
+ }
3644
+ function slotMarkupRead(sv, position) {
3645
+ if (sv.f === SLOT_FACE_MARKUP) {
3646
+ slotFinding(sv, "markup", position, `[${BINDING_SLOT_POSITION}] \`${position}\` reads \`${sv.k}\` off slot \`${propOfOccurrence(sv[SLOT_VALUE])}\`, ` + `but the client fill returned markup, not an object. A slot renders one or the other: ` + `return an object (\`{ ${sv.k}: … }\`) for positions, or place the slot as content.`);
3647
+ }
3648
+ }
3649
+ function slotValueInline(kind, sv) {
3650
+ {
3651
+ slotFinding(sv, "inline", kind, `[${BINDING_SLOT_POSITION}] A binding-slot value (\`${sv.k}\` of \`${propOfOccurrence(sv[SLOT_VALUE])}\`) ` + `reached \`${kind}\` inside template quotes, where its position marker cannot be emitted — the ` + `element was compiled without the \`serverComponents\` compiler option. Nothing renders here ` + `on either face.`);
3416
3652
  }
3653
+ return undefined;
3654
+ }
3655
+ const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
3656
+ function encodeSlotKey(key) {
3657
+ return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
3658
+ }
3659
+ function slotEntry(sv, name) {
3660
+ return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
3661
+ }
3662
+ function slotMarker(position, entries) {
3663
+ return ` ${SLOT_MARKER}${position}="${entries}"`;
3664
+ }
3665
+ function eventSlotStamp(mode) {
3666
+ return mode === CLAIMS_DOCUMENT ? " _hk" : "";
3667
+ }
3668
+ function propOfOccurrence(occurrence) {
3669
+ const i = occurrence.indexOf("#");
3670
+ return i === -1 ? occurrence : occurrence.slice(0, i);
3671
+ }
3672
+ function slotAttribute(key, sv) {
3673
+ slotMarkupRead(sv, key);
3417
3674
  let out = "";
3418
- for (const pos in map) {
3419
- const value = map[pos];
3420
- const list = Array.isArray(value) ? value : [value];
3421
- for (const fn of list) {
3422
- const prop = typeof fn === "function" && fn[CLAIM_PROP] || undefined;
3423
- if (prop === undefined) {
3424
- {
3425
- devCheck({
3426
- code: "BEHAVIOR_CLAIM_DROPPED",
3427
- kind: "ssr",
3428
- severity: "warn",
3429
- message: `[BEHAVIOR_CLAIM_DROPPED] A \`${pos}\` position on a server-rendered element received a server-local ` + `${typeof fn} — this handler can never run. Pass the function through the ` + `server component's props from the client (compose on the client before ` + `passing), or bind a mutation to \`action=\`.`,
3430
- data: {
3431
- reason: "server-local",
3432
- position: pos,
3433
- received: typeof fn
3434
- }
3435
- });
3675
+ if (sv.f === SLOT_FACE_DATA) {
3676
+ const v = sv.v;
3677
+ if (v != null && v !== false) {
3678
+ out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
3679
+ }
3680
+ }
3681
+ return out + slotMarker(key, slotEntry(sv));
3682
+ }
3683
+ function slotClassOrStyle(key, value) {
3684
+ const isClass = key === "class";
3685
+ if (isSlotValue(value)) {
3686
+ slotMarkupRead(value, key);
3687
+ let out = "";
3688
+ if (value.f === SLOT_FACE_DATA && value.v != null) {
3689
+ out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
3690
+ }
3691
+ return out + slotMarker(key, slotEntry(value));
3692
+ }
3693
+ if (typeof value === "object" && value !== null) {
3694
+ const obj = isClass ? classListToObject(value) : value;
3695
+ let entries = "";
3696
+ let inner = "";
3697
+ for (const name of Object.keys(obj)) {
3698
+ let v = obj[name];
3699
+ if (isSlotValue(v)) {
3700
+ slotMarkupRead(v, `${key}:${name}`);
3701
+ entries += (entries ? "," : "") + slotEntry(v, name);
3702
+ v = v.f === SLOT_FACE_DATA ? v.v : undefined;
3703
+ }
3704
+ if (isClass) {
3705
+ if (!name || name === "undefined" || !v) continue;
3706
+ inner += (inner ? " " : "") + escape(name, true);
3707
+ } else if (v != undefined) {
3708
+ const r = escape(v, true);
3709
+ if (r != undefined && r !== "undefined") {
3710
+ inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
3436
3711
  }
3437
- continue;
3438
3712
  }
3439
- out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
3440
3713
  }
3714
+ if (entries === "") return ` ${key}="${inner}"`;
3715
+ return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
3716
+ }
3717
+ return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
3718
+ }
3719
+ function eventPosition(prop) {
3720
+ return prop.slice(2).toLowerCase();
3721
+ }
3722
+ function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
3723
+ if (!isAttrName(prop)) return behaviors;
3724
+ const pos = prop === "ref" ? "ref" : eventPosition(prop);
3725
+ const entries = value == null ? "" : claimEntries(pos, value, mode);
3726
+ if (!settle) {
3727
+ if (entries) (behaviors ||= new Map()).set(pos, entries);
3728
+ return behaviors;
3729
+ }
3730
+ behaviors ||= new Map();
3731
+ const b = behaviors.get(pos);
3732
+ if (b === undefined) behaviors.set(pos, {
3733
+ e: entries,
3734
+ at: index
3735
+ });else {
3736
+ b.e = entries;
3737
+ b.at = index;
3738
+ }
3739
+ return behaviors;
3740
+ }
3741
+ function spreadBehaviorMarkers(behaviors, claims, mode) {
3742
+ if (claims !== undefined) {
3743
+ const segments = claims();
3744
+ for (const k in segments) {
3745
+ const map = segments[k];
3746
+ for (const pos in map) {
3747
+ const value = map[pos];
3748
+ behaviors ||= new Map();
3749
+ const b = behaviors.get(pos);
3750
+ if (pos === "ref") {
3751
+ if (value == null) continue;
3752
+ const entries = claimEntries("ref", value, mode);
3753
+ if (!entries) continue;
3754
+ if (b === undefined) behaviors.set("ref", {
3755
+ e: entries,
3756
+ at: -1
3757
+ });else b.e = b.e ? b.e + "," + entries : entries;
3758
+ continue;
3759
+ }
3760
+ if (b !== undefined && b.at >= +k) continue;
3761
+ const entries = value == null ? "" : claimEntries(pos, value, mode);
3762
+ if (b === undefined) behaviors.set(pos, {
3763
+ e: entries,
3764
+ at: -1
3765
+ });else b.e = entries;
3766
+ }
3767
+ }
3768
+ }
3769
+ let out = "";
3770
+ let events = false;
3771
+ if (behaviors !== null) {
3772
+ for (const [pos, b] of behaviors) {
3773
+ const e = claims === undefined ? b : b.e;
3774
+ if (!e) continue;
3775
+ if (pos === "ref") out += slotMarker("ref", e);else {
3776
+ out += slotMarker("on:" + pos, e);
3777
+ events = true;
3778
+ }
3779
+ }
3780
+ }
3781
+ return events ? out + eventSlotStamp(mode) : out;
3782
+ }
3783
+ function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
3784
+ for (let i = 0; i < props.length; i++) {
3785
+ let s = props[i];
3786
+ if (typeof s === "function") s = s();
3787
+ if (s != null) {
3788
+ if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource(tag, s);
3789
+ if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
3790
+ const ks = [];
3791
+ const os = [];
3792
+ sourceOwners(s, ks, os);
3793
+ for (let j = 0; j < ks.length; j++) {
3794
+ const at = viewKeys.indexOf(ks[j]);
3795
+ if (at !== -1) {
3796
+ viewKeys.splice(at, 1);
3797
+ owners.splice(at, 1);
3798
+ ownerIndex.splice(at, 1);
3799
+ }
3800
+ viewKeys.push(ks[j]);
3801
+ owners.push(os[j]);
3802
+ ownerIndex.push(i);
3803
+ }
3804
+ }
3805
+ }
3806
+ }
3807
+ }
3808
+ function spreadPropPosition(prop, value) {
3809
+ if (isSlotValue(value)) {
3810
+ slotFinding(value, "prop", prop, `[${BINDING_SLOT_POSITION}] \`${value.k}\` of slot \`${propOfOccurrence(value[SLOT_VALUE])}\` is bound ` + `at \`${prop}\`. Property positions are not bindable (the server renders no properties): nothing ` + `renders here. Bind the attribute form (\`${prop.slice(5)}\`), or set the property in the client fill's ref.`);
3811
+ }
3812
+ }
3813
+ function spreadObjectAttribute(prop, value) {
3814
+ if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
3815
+ if (!isAttrName(prop)) return "";
3816
+ if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
3817
+ return ` ${prop}="${escape(value, true)}"`;
3818
+ }
3819
+ function slotSpreadSource(tag, source) {
3820
+ {
3821
+ const occurrence = source.$occurrence;
3822
+ const text = `[${BINDING_SLOT_POSITION}] A slot${occurrence ? ` (\`${propOfOccurrence(occurrence)}\`)` : ""} is spread ` + `onto a server-rendered <${tag}>. A binding slot binds by position — name each one ` + `(\`class={row.rowClass} onClick={row.remove}\`) so the template shows what the client owns.`;
3823
+ recordFinding({
3824
+ code: BINDING_SLOT_POSITION,
3825
+ kind: "ssr",
3826
+ severity: "error",
3827
+ message: text,
3828
+ data: {
3829
+ reason: "spread",
3830
+ tag,
3831
+ occurrence
3832
+ }
3833
+ });
3834
+ throw new Error(text);
3835
+ }
3836
+ }
3837
+ function ssrClaim(map) {
3838
+ const mode = sharedConfig.context && sharedConfig.context.claims;
3839
+ if (!mode) return "";
3840
+ let out = "";
3841
+ let events = false;
3842
+ for (const pos in map) {
3843
+ const entries = claimEntries(pos, map[pos], mode);
3844
+ if (!entries) continue;
3845
+ if (pos === "ref") out += slotMarker("ref", entries);else {
3846
+ out += slotMarker("on:" + pos, entries);
3847
+ events = true;
3848
+ }
3849
+ }
3850
+ return events ? out + eventSlotStamp(mode) : out;
3851
+ }
3852
+ function claimEntries(pos, value, mode) {
3853
+ if (Array.isArray(value) && pos !== "ref") {
3854
+ {
3855
+ const sv = value.find(isSlotValue);
3856
+ if (sv !== undefined) {
3857
+ slotFinding(sv, "tuple", pos, `[${BINDING_SLOT_POSITION}] A \`${pos}\` handler position on a server-rendered element received ` + `an array. A position marker names the slot's keys, never data, so a tuple's data cannot reach ` + `the client — nothing binds here. Return the tuple from the fill (\`[handler, data]\`) and ` + `bind that one property.`);
3858
+ } else claimEntries(pos, value[0], mode);
3859
+ }
3860
+ return "";
3441
3861
  }
3442
- return out ? ` _bnd="${out}"` : "";
3862
+ if (Array.isArray(value)) {
3863
+ let entries = "";
3864
+ for (const v of value) {
3865
+ const inner = claimEntries(pos, v, mode);
3866
+ if (inner) entries += (entries ? "," : "") + inner;
3867
+ }
3868
+ return entries;
3869
+ }
3870
+ if (isSlotValue(value)) {
3871
+ slotMarkupRead(value, pos);
3872
+ return slotEntry(value);
3873
+ }
3874
+ if (typeof value === "function" && !value.$slotWarned && claimInScope(mode)) {
3875
+ value.$slotWarned = true;
3876
+ devCheck({
3877
+ code: BINDING_SLOT_POSITION,
3878
+ kind: "ssr",
3879
+ severity: "warn",
3880
+ message: `[${BINDING_SLOT_POSITION}] A \`${pos}\` position on a server-rendered element received a server-local ` + `function — it can never run. Bind a slot's property there ` + `(\`const row = props.row(args); ${pos === "ref" ? "ref" : "onX"}={row.${pos === "ref" ? "ref" : "onX"}}\`) ` + `so the client supplies it, or bind a mutation to \`action=\`.`,
3881
+ data: {
3882
+ reason: "server-local",
3883
+ position: pos
3884
+ }
3885
+ });
3886
+ }
3887
+ return "";
3888
+ }
3889
+ function claimInScope(mode) {
3890
+ return mode === CLAIMS_STREAM || typeof inServerComponentScope === "function" && inServerComponentScope();
3443
3891
  }
3444
3892
  function decodeSSREntities(s) {
3445
3893
  return s.indexOf("&") < 0 ? s : s.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&amp;/g, "&");
@@ -3561,6 +4009,7 @@ function escape(s, attr) {
3561
4009
  if (!attr && t === "function") return escapeLate(s);
3562
4010
  if (attr) {
3563
4011
  if (s == null || t === "boolean" || t === "number") return s;
4012
+ if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
3564
4013
  return escape(String(s), attr);
3565
4014
  }
3566
4015
  return s;
@@ -3672,7 +4121,7 @@ function generateHydrationScript({
3672
4121
  eventNames = ["click", "input"],
3673
4122
  nonce
3674
4123
  } = {}) {
3675
- return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
4124
+ return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:new Proxy({},{set:(r,k,v)=>(v instanceof Promise&&v.catch(()=>{}),r[k]=v,!0)}),fe(){}});</script><!--xs-->`;
3676
4125
  }
3677
4126
  function queue(fn) {
3678
4127
  return Promise.resolve().then(fn);
@@ -3875,6 +4324,10 @@ function tryResolveString(node, nested) {
3875
4324
  if (node.h && node.h.length > 0) return {
3876
4325
  merge: node
3877
4326
  };
4327
+ if (node[SLOT_VALUE] !== undefined) {
4328
+ ssrTextTail = false;
4329
+ return node.w();
4330
+ }
3878
4331
  if (node.t === undefined) {
3879
4332
  unrecognizedInsert(node);
3880
4333
  return "";
@@ -3928,6 +4381,9 @@ function resolveSSRNode(node, result = {
3928
4381
  } else if (node.t !== undefined) {
3929
4382
  result.t[result.t.length - 1] += node.t;
3930
4383
  ssrTextTail = false;
4384
+ } else if (node[SLOT_VALUE] !== undefined) {
4385
+ result.t[result.t.length - 1] += node.w();
4386
+ ssrTextTail = false;
3931
4387
  } else unrecognizedInsert(node);
3932
4388
  } else if (t === "function") {
3933
4389
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
@@ -3966,7 +4422,7 @@ function serializerErrorHook(hook) {
3966
4422
  reportServerError(err, {
3967
4423
  kind: "render",
3968
4424
  handling: "serialize"
3969
- }, null);
4425
+ }, null, hook);
3970
4426
  };
3971
4427
  }
3972
4428
  function ambientServerErrorHook() {
@@ -3980,8 +4436,75 @@ function configureServerErrors(config) {
3980
4436
  }
3981
4437
  (g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
3982
4438
  }
4439
+ function reportRequestFailure(error, event) {
4440
+ reportServerError(error, {
4441
+ kind: "request",
4442
+ handling: "failed",
4443
+ event
4444
+ }, null);
4445
+ if (ambientServerErrorHook() === undefined) console.error(error);
4446
+ }
3983
4447
  function getRequestEvent() {
3984
- return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.warn("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
4448
+ const store = globalThis[RequestContext];
4449
+ if (!store) return undefined;
4450
+ const event = store.getStore();
4451
+ if (event) return event;
4452
+ const ctx = renderContextOf(getOwner());
4453
+ return ctx && ctx.event || console.warn("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.");
4454
+ }
4455
+ const RENDER_ROOTS = Symbol.for("@solidjs/web/render-roots");
4456
+ function renderRoots() {
4457
+ const g = globalThis;
4458
+ return g[RENDER_ROOTS] || (g[RENDER_ROOTS] = new WeakMap());
4459
+ }
4460
+ function claimRenderRoot(context) {
4461
+ const owner = getOwner();
4462
+ const roots = renderRoots();
4463
+ roots.set(owner, context);
4464
+ onCleanup(() => roots.delete(owner));
4465
+ return owner;
4466
+ }
4467
+ function settleRender(render, root, outcome) {
4468
+ runWithOwner(root || null, () => render.settle(outcome));
4469
+ }
4470
+ const eventRenders = new WeakMap();
4471
+ function claimEventRender(event, context) {
4472
+ let renders = eventRenders.get(event);
4473
+ if (!renders) eventRenders.set(event, renders = new Set());
4474
+ renders.add(context);
4475
+ onCleanup(() => renders.delete(context));
4476
+ }
4477
+ function createHydrationWriter(context, isOpen) {
4478
+ const keys = new Set();
4479
+ return {
4480
+ async: !!context.async,
4481
+ write(key, value, options) {
4482
+ if (!isOpen() || keys.has(key)) return false;
4483
+ context.serialize(key, value, options && options.deferStream);
4484
+ keys.add(key);
4485
+ return true;
4486
+ }
4487
+ };
4488
+ }
4489
+ function getHydrationWriter() {
4490
+ let ctx = renderContextOf(getOwner());
4491
+ if (!ctx) {
4492
+ const event = peekRequestEvent();
4493
+ const renders = event && eventRenders.get(event);
4494
+ if (renders && renders.size === 1) for (const c of renders) ctx = c;
4495
+ }
4496
+ return ctx && ctx.writer;
4497
+ }
4498
+ function takeHydrationValue(_key) {
4499
+ return undefined;
4500
+ }
4501
+ function renderContextOf(owner) {
4502
+ const roots = globalThis[RENDER_ROOTS];
4503
+ if (!roots) return undefined;
4504
+ for (; owner; owner = owner._parent) {
4505
+ const context = roots.get(owner);
4506
+ if (context) return context;
4507
+ }
3985
4508
  }
3986
4509
  function peekRequestEvent() {
3987
4510
  const store = globalThis[RequestContext];
@@ -3990,6 +4513,7 @@ function peekRequestEvent() {
3990
4513
  function timeDocument(context, trace, mode, requestEvent) {
3991
4514
  if (records() === undefined) return undefined;
3992
4515
  const render = observeRender(trace, mode, requestEvent);
4516
+ if (render) context._declareRoute = ref => render.route(ref);
3993
4517
  if (timesServerWork()) {
3994
4518
  context._recordBoundary = event => {
3995
4519
  trace.timing.push({
@@ -4004,7 +4528,7 @@ function timeDocument(context, trace, mode, requestEvent) {
4004
4528
  function getTraceContext() {
4005
4529
  const event = peekRequestEvent();
4006
4530
  if (event) return traceForEvent(event).context;
4007
- const ctx = sharedConfig.context;
4531
+ const ctx = renderContextOf(getOwner());
4008
4532
  return ctx && ctx.trace ? ctx.trace.context : undefined;
4009
4533
  }
4010
4534
  function traceForStub(stub, event) {
@@ -4090,10 +4614,13 @@ function copyInitHeaders(init) {
4090
4614
  for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
4091
4615
  return headers;
4092
4616
  }
4093
- const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
4094
- ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
4617
+ let stubGapFillExcluded;
4618
+ function isStubGapFillExcluded(key) {
4619
+ return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
4620
+ ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
4621
+ }
4095
4622
  function fillsStubGap(key, headers, response) {
4096
- if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
4623
+ if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
4097
4624
  if (response.body === null && (key === "content-type" || key === "content-length")) return false;
4098
4625
  return !headers.has(key);
4099
4626
  }
@@ -4185,7 +4712,7 @@ function createSSRResponse(result, event, options = {}) {
4185
4712
  closed = true;
4186
4713
  }
4187
4714
  };
4188
- result.pipe({
4715
+ const sink = {
4189
4716
  write(chunk) {
4190
4717
  if (!flushed) {
4191
4718
  flushed = true;
@@ -4200,6 +4727,7 @@ function createSSRResponse(result, event, options = {}) {
4200
4727
  status: getExpectedRedirectStatus(stub),
4201
4728
  headers: head.headers
4202
4729
  }));
4730
+ sink[ABANDON_RENDER]("redirect", true);
4203
4731
  return;
4204
4732
  }
4205
4733
  if (!head.headers.has("content-type")) {
@@ -4210,7 +4738,9 @@ function createSSRResponse(result, event, options = {}) {
4210
4738
  controller = c;
4211
4739
  },
4212
4740
  cancel() {
4741
+ if (closed) return;
4213
4742
  closed = true;
4743
+ sink[ABANDON_RENDER]("consumer");
4214
4744
  }
4215
4745
  }), {
4216
4746
  status: head.status,
@@ -4221,6 +4751,7 @@ function createSSRResponse(result, event, options = {}) {
4221
4751
  enqueue(transformChunk ? transformChunk(chunk) : chunk);
4222
4752
  },
4223
4753
  end() {
4754
+ if (!flushed) sink.write("");
4224
4755
  if (closed || !controller) return;
4225
4756
  const location = stub && stub.headers.get("Location");
4226
4757
  if (location && isHttpNavigationTarget(location)) {
@@ -4231,8 +4762,23 @@ function createSSRResponse(result, event, options = {}) {
4231
4762
  try {
4232
4763
  controller.close();
4233
4764
  } catch {}
4234
- }
4235
- });
4765
+ },
4766
+ [SHELL_ABANDONED]() {
4767
+ if (flushed) return;
4768
+ flushed = closed = true;
4769
+ if (stub) commitResponseStub(stub, {
4770
+ event
4771
+ });
4772
+ const head = deriveHead(stub, responseInit);
4773
+ const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
4774
+ resolve(new Response(null, {
4775
+ status,
4776
+ headers: head.headers
4777
+ }));
4778
+ },
4779
+ [ABANDON_RENDER]() {}
4780
+ };
4781
+ result.pipe(sink);
4236
4782
  });
4237
4783
  }
4238
4784
  function composeMiddleware(middlewares) {
@@ -4257,6 +4803,9 @@ function claimElement(node) {
4257
4803
  function claimElementTree(root) {
4258
4804
  return root;
4259
4805
  }
4806
+ function dispatchAsInteraction(_e, fn) {
4807
+ return fn();
4808
+ }
4260
4809
  function notSup() {
4261
4810
  throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
4262
4811
  }
@@ -4266,11 +4815,18 @@ setAsyncIterableSharer(shareAsyncIterable);
4266
4815
  const isServer = true;
4267
4816
  const isDev = true;
4268
4817
  function dynamic(source, options) {
4818
+ return dynamicCore(source, options, ssrTag);
4819
+ }
4820
+ function dynamicComponent(source, options) {
4821
+ return dynamicCore(source, options);
4822
+ }
4823
+ const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4824
+ function dynamicCore(source, options, tagArm) {
4269
4825
  if (options?.static) {
4270
4826
  const component = untrack(source);
4271
4827
  if (component && typeof component.then === "function") throw new Error("dynamic(): a static source must resolve synchronously, not to a promise");
4272
4828
  if (typeof component === "function") return props => component(props);
4273
- if (typeof component === "string") return props => ssrElement(component, props, undefined, true);
4829
+ if (typeof component === "string" && tagArm) return props => tagArm(component, props);
4274
4830
  return () => undefined;
4275
4831
  }
4276
4832
  const cached = createMemo(() => {
@@ -4316,9 +4872,7 @@ function dynamic(source, options) {
4316
4872
  const c = value();
4317
4873
  if (c) {
4318
4874
  if (typeof c === "function") return c(props);
4319
- if (typeof c === "string") {
4320
- return ssrElement(c, props, undefined, true);
4321
- }
4875
+ if (typeof c === "string" && tagArm) return tagArm(c, props);
4322
4876
  }
4323
4877
  }, {
4324
4878
  sync: true
@@ -4469,4 +5023,4 @@ function httpHeader(name, value, options) {
4469
5023
  }
4470
5024
  }
4471
5025
 
4472
- export { CLAIMS_DOCUMENT, CLAIMS_STREAM, CLAIM_PROP, 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, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, 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, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrSelectValues, ssrStyle, ssrStyleProperty, notSup as style, styleNonce, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
5026
+ export { CLAIMS_DOCUMENT, CLAIMS_STREAM, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SLOT_FACE_DATA, SLOT_FACE_MARKUP, SLOT_FACE_STREAM, SLOT_MARKER, SLOT_VALUE, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, dynamicComponent, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, isSlotValue, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, slotValue, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, styleNonce, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };