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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
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';
1
+ import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
4
4
  export { ssrScope as scope, sharedConfig } from 'solid-js/internal';
5
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';
@@ -34,6 +34,7 @@ const DOMWithState = {
34
34
  }
35
35
  };
36
36
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
37
+ const LinkAttributes = /*#__PURE__*/new Set(["href", "target", "rel", "download", "link", "aria-current"]);
37
38
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
38
39
  const SVGElements = /*#__PURE__*/new Set([
39
40
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
@@ -469,9 +470,7 @@ function toBorderForm(value, envelopeContainers) {
469
470
  }
470
471
  function isShareableIterable(value) {
471
472
  try {
472
- if (value.__SEROVAL_STREAM__ === true) return false;
473
- if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) return false;
474
- return typeof value[Symbol.asyncIterator] === "function";
473
+ return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
475
474
  } catch {
476
475
  return false;
477
476
  }
@@ -576,17 +575,24 @@ function getLocalHeaderScript(id) {
576
575
  }
577
576
 
578
577
  const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
579
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
580
- const ResponseEnvelope = /* @__PURE__ */(() => {
581
- class ResponseEnvelope {
582
- constructor(response, value) {
583
- this.response = response;
584
- this.value = value;
585
- }
578
+ let EnvelopeClass;
579
+ const ResponseEnvelope = function ResponseEnvelope(response, value) {
580
+ if (!EnvelopeClass) {
581
+ EnvelopeClass = class extends Response {
582
+ constructor(response, value) {
583
+ super(response ? response.body : null, response && {
584
+ status: response.status,
585
+ statusText: response.statusText,
586
+ headers: copyHeaders(response.headers)
587
+ });
588
+ this.response = response ? this : undefined;
589
+ this.value = value;
590
+ }
591
+ };
592
+ EnvelopeClass.prototype[ENVELOPE] = true;
586
593
  }
587
- ResponseEnvelope.prototype[ENVELOPE] = true;
588
- return ResponseEnvelope;
589
- })();
594
+ return new EnvelopeClass(response, value);
595
+ };
590
596
  function isResponseEnvelope(value) {
591
597
  return !!(value && typeof value === "object" && value[ENVELOPE]);
592
598
  }
@@ -611,6 +617,16 @@ function isSafeError(value) {
611
617
  const REVALIDATE_HEADER = "X-Revalidate";
612
618
  const REVALIDATE_ALL = "*";
613
619
  const RESPONSE_HEADER_VALUE_LIMIT = 4096;
620
+ function copyHeaders(init) {
621
+ const source = init;
622
+ if (!source || !source.getSetCookie) return new Headers(init);
623
+ const headers = new Headers();
624
+ source.forEach((value, key) => {
625
+ if (key !== "set-cookie") headers.append(key, value);
626
+ });
627
+ for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
628
+ return headers;
629
+ }
614
630
  function initWithRevalidate(init = {}) {
615
631
  const resolved = typeof init === "number" ? {
616
632
  status: init
@@ -619,18 +635,7 @@ function initWithRevalidate(init = {}) {
619
635
  revalidate,
620
636
  ...responseInit
621
637
  } = resolved;
622
- let headers;
623
- if (responseInit.headers && responseInit.headers.getSetCookie) {
624
- headers = new Headers();
625
- responseInit.headers.forEach((value, key) => {
626
- if (key !== "set-cookie") headers.append(key, value);
627
- });
628
- for (const cookie of responseInit.headers.getSetCookie()) {
629
- headers.append("Set-Cookie", cookie);
630
- }
631
- } else {
632
- headers = new Headers(responseInit.headers);
633
- }
638
+ const headers = copyHeaders(responseInit.headers);
634
639
  if (revalidate !== undefined) {
635
640
  const list = Array.isArray(revalidate) ? revalidate : [revalidate];
636
641
  if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
@@ -858,6 +863,10 @@ function qualifierValue(name, value) {
858
863
  function asciiLowerCase(value) {
859
864
  return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
860
865
  }
866
+ const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
867
+ function headBodyText(tag, props, text) {
868
+ return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
869
+ }
861
870
  function resourceIdentity(tag, props) {
862
871
  const url = String(props.href || props.src || "");
863
872
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
@@ -1557,6 +1566,7 @@ function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMet
1557
1566
  noScripts
1558
1567
  };
1559
1568
  }
1569
+ let headBodyHook;
1560
1570
  function flushHeadFragment(registry, boundary, nonce) {
1561
1571
  const groups = commitHeadBoundary(registry, boundary);
1562
1572
  if (!groups.length) return null;
@@ -1595,7 +1605,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1595
1605
  if (value) attrs.nonce = String(value);
1596
1606
  }
1597
1607
  const children = t.props.children;
1598
- ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
1608
+ ops.push(["a", identity, t.tag, attrs, children == null ? null : headBodyHook ? headBodyHook(t.tag, t.props, String(children)) : String(children)]);
1599
1609
  }
1600
1610
  }
1601
1611
  return ops.length ? ops : null;
@@ -1623,8 +1633,7 @@ function normalizeNonce(nonce) {
1623
1633
  }
1624
1634
  function destinationNonce(nonce, destination) {
1625
1635
  if (nonce == null) return undefined;
1626
- if (typeof nonce === "string") return nonce || undefined;
1627
- const value = nonce[destination];
1636
+ const value = typeof nonce === "string" ? nonce : nonce[destination];
1628
1637
  return typeof value === "string" && value ? value : undefined;
1629
1638
  }
1630
1639
  function scriptNonce(nonce) {
@@ -1699,6 +1708,7 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
1699
1708
  if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
1700
1709
  if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
1701
1710
  let body = props.children == null ? "" : String(props.children);
1711
+ if (headBodyHook) body = headBodyHook(tag, props, body);
1702
1712
  if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
1703
1713
  return `<${tag}${attrs}>${body}</${tag}>`;
1704
1714
  }
@@ -1708,6 +1718,7 @@ function useHead(tags) {
1708
1718
  headTagInvalid("outside-render", "useHead() called outside of a server render; registration ignored.");
1709
1719
  return;
1710
1720
  }
1721
+ headBodyHook = headBodyText;
1711
1722
  ctx.registerHeadTags(tags);
1712
1723
  }
1713
1724
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
@@ -1718,12 +1729,27 @@ function tagInfo(tag) {
1718
1729
  let info = tagInfos.get(tag);
1719
1730
  if (info === undefined) {
1720
1731
  if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
1732
+ let formDefaults, formAttributes;
1733
+ if (tag === "input" || tag === "option") {
1734
+ formDefaults = Object.create(null);
1735
+ formAttributes = Object.create(null);
1736
+ const state = DOMWithState[tag.toUpperCase()];
1737
+ for (const prop in state) {
1738
+ if (state[prop] === 2) {
1739
+ const attr = prop.slice(7).toLowerCase();
1740
+ formDefaults[attr] = prop;
1741
+ formAttributes[prop] = attr;
1742
+ }
1743
+ }
1744
+ }
1721
1745
  info = {
1722
1746
  open: "<" + tag,
1723
1747
  close: "</" + tag + ">",
1724
1748
  isVoid: VOID_ELEMENTS.test(tag),
1725
1749
  textarea: tag === "textarea",
1726
- raw: tag === "script" || tag === "style"
1750
+ raw: tag === "script" || tag === "style",
1751
+ formDefaults,
1752
+ formAttributes
1727
1753
  };
1728
1754
  if (tagInfos.size < 512) tagInfos.set(tag, info);
1729
1755
  }
@@ -1822,7 +1848,7 @@ function renderToString(code, options = {}) {
1822
1848
  closed = true;
1823
1849
  serializer.close();
1824
1850
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1825
- const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
1851
+ const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead) + shellEndMarker(context, renderId, nonce, noScripts);
1826
1852
  if (render) render.shell();
1827
1853
  if (requestEvent && requestEvent.response) {
1828
1854
  commitResponseStub(requestEvent.response, {
@@ -2084,7 +2110,7 @@ function renderToStream(code, options = {}) {
2084
2110
  }
2085
2111
  },
2086
2112
  shell(shellHtml, meta) {
2087
- buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
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));
2088
2114
  },
2089
2115
  ...options.sink
2090
2116
  };
@@ -2736,11 +2762,15 @@ function renderToStream(code, options = {}) {
2736
2762
  };
2737
2763
  }
2738
2764
  function HydrationScript(props) {
2739
- const nonce = scriptNonce(sharedConfig.context && sharedConfig.context.nonce);
2740
- return ssr(generateHydrationScript({
2741
- nonce,
2765
+ if (sharedConfig.context) sharedConfig.context.bootstrap = true;
2766
+ const {
2767
+ eventNames,
2768
+ nonce
2769
+ } = {
2770
+ nonce: sharedConfig.context && sharedConfig.context.nonce,
2742
2771
  ...props
2743
- }));
2772
+ };
2773
+ return ssr(hydrationBootstrap(eventNames, scriptNonce(nonce), true));
2744
2774
  }
2745
2775
  function ssrGroup(fn, n) {
2746
2776
  fn.$g = n;
@@ -2896,7 +2926,7 @@ function createLiveHoles(sink, scoped) {
2896
2926
  let nextId = 0;
2897
2927
  const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
2898
2928
  const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
2899
- const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
2929
+ const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
2900
2930
  const swept = (owner, ctx, fn) => {
2901
2931
  const prev = sharedConfig.context;
2902
2932
  sharedConfig.context = ctx;
@@ -3452,6 +3482,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3452
3482
  let ownerIndex = null;
3453
3483
  const ctx = renderConfig.context;
3454
3484
  const slots = ctx !== undefined && ctx.claims !== undefined;
3485
+ const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
3455
3486
  if (Array.isArray(props)) {
3456
3487
  if (slots && props.$slot === true) props = slotSpreadSource(tag, props);else {
3457
3488
  let i = 0;
@@ -3492,7 +3523,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3492
3523
  const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
3493
3524
  if (sources !== null) props = sources[s];
3494
3525
  nextKey: for (let i = 0; i < keys.length; i++) {
3495
- const prop = keys[i];
3526
+ let prop = keys[i];
3496
3527
  if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
3497
3528
  if (owners !== null) props = owners[i];
3498
3529
  for (let j = s + 1; j <= last; j++) {
@@ -3509,7 +3540,12 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3509
3540
  }
3510
3541
  continue;
3511
3542
  }
3512
- const value = props[prop];
3543
+ const key = prop;
3544
+ if (info.formAttributes !== undefined) {
3545
+ prop = spreadFormAttribute(prop, info, keys, keysOf, skip);
3546
+ if (prop === undefined) continue;
3547
+ }
3548
+ const value = props[key];
3513
3549
  if (value == undefined) {
3514
3550
  if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
3515
3551
  continue;
@@ -3522,6 +3558,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3522
3558
  if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
3523
3559
  continue;
3524
3560
  }
3561
+ if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
3525
3562
  if (slots && typeof value === "object") {
3526
3563
  result += spreadObjectAttribute(prop, value);
3527
3564
  } else if (prop === "style") {
@@ -3537,6 +3574,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3537
3574
  }
3538
3575
  if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
3539
3576
  if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
3577
+ if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
3540
3578
  if (skipChildren) return {
3541
3579
  t: result + " />"
3542
3580
  };
@@ -3554,6 +3592,19 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
3554
3592
  };
3555
3593
  return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
3556
3594
  }
3595
+ function spreadFormAttribute(prop, info, keys, keysOf, skip) {
3596
+ const defaultProp = info.formDefaults[prop];
3597
+ if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
3598
+ if (keysOf !== null) {
3599
+ for (let j = 0; j < keysOf.length; j++) {
3600
+ if (keysOf[j].includes(defaultProp)) return;
3601
+ }
3602
+ } else if (keys.includes(defaultProp)) return;
3603
+ }
3604
+ const attr = info.formAttributes[prop];
3605
+ if (attr !== undefined && skip !== undefined && skip(attr)) return;
3606
+ return attr === undefined ? prop : attr;
3607
+ }
3557
3608
  function ssrElementAttribute(key, value) {
3558
3609
  if (value == undefined) return "";
3559
3610
  if (key === "style" || key === "class") {
@@ -3889,6 +3940,11 @@ function claimEntries(pos, value, mode) {
3889
3940
  function claimInScope(mode) {
3890
3941
  return mode === CLAIMS_STREAM || typeof inServerComponentScope === "function" && inServerComponentScope();
3891
3942
  }
3943
+ function ssrLinkClaim(attrs) {
3944
+ const ctx = renderConfig.context;
3945
+ if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
3946
+ return ctx.linkClaim(attrs);
3947
+ }
3892
3948
  function decodeSSREntities(s) {
3893
3949
  return s.indexOf("&") < 0 ? s : s.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&amp;/g, "&");
3894
3950
  }
@@ -4118,10 +4174,13 @@ function applyRef(r, element) {
4118
4174
  Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
4119
4175
  }
4120
4176
  function generateHydrationScript({
4121
- eventNames = ["click", "input"],
4177
+ eventNames,
4122
4178
  nonce
4123
4179
  } = {}) {
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-->`;
4180
+ return hydrationBootstrap(eventNames, scriptNonce(nonce), false);
4181
+ }
4182
+ function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
4183
+ return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:new Proxy({},{set:(r,k,v)=>(v instanceof Promise&&v.catch(()=>{}),r[k]=v,!0)}),${ledger ? "s:{}," : ""}fe(){}});</script><!--xs-->`;
4125
4184
  }
4126
4185
  function queue(fn) {
4127
4186
  return Promise.resolve().then(fn);
@@ -4134,6 +4193,11 @@ function allSettled(promises) {
4134
4193
  return size;
4135
4194
  });
4136
4195
  }
4196
+ function shellEndMarker(context, renderId, nonce, noScripts) {
4197
+ if (noScripts || !context || !context.bootstrap) return "";
4198
+ const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
4199
+ return `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
4200
+ }
4137
4201
  function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
4138
4202
  const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
4139
4203
  const title = headTags ? headTags.title : null;
@@ -4487,13 +4551,31 @@ function createHydrationWriter(context, isOpen) {
4487
4551
  };
4488
4552
  }
4489
4553
  function getHydrationWriter() {
4554
+ const ctx = currentRenderContext();
4555
+ return ctx && ctx.writer;
4556
+ }
4557
+ function currentRenderContext() {
4490
4558
  let ctx = renderContextOf(getOwner());
4491
4559
  if (!ctx) {
4492
4560
  const event = peekRequestEvent();
4493
4561
  const renders = event && eventRenders.get(event);
4494
4562
  if (renders && renders.size === 1) for (const c of renders) ctx = c;
4495
4563
  }
4496
- return ctx && ctx.writer;
4564
+ return ctx;
4565
+ }
4566
+ const LINK_STATE_RECORD = "links";
4567
+ function setLinkClaim(handler) {
4568
+ const ctx = currentRenderContext();
4569
+ if (!ctx) {
4570
+ console.warn("setLinkClaim was called outside a render: no render was found through the current owner or the request scope. Call it during component setup.");
4571
+ return false;
4572
+ }
4573
+ ctx.linkClaim = handler;
4574
+ if (handler !== undefined) ctx.writer.write(LINK_STATE_RECORD, 1);
4575
+ return true;
4576
+ }
4577
+ function hasServerLinkState() {
4578
+ return false;
4497
4579
  }
4498
4580
  function takeHydrationValue(_key) {
4499
4581
  return undefined;
@@ -4814,87 +4896,10 @@ setContainerTraceResolver(getProjectionTrace);
4814
4896
  setAsyncIterableSharer(shareAsyncIterable);
4815
4897
  const isServer = true;
4816
4898
  const isDev = true;
4899
+ const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4817
4900
  function dynamic(source, options) {
4818
4901
  return dynamicCore(source, options, ssrTag);
4819
4902
  }
4820
- function dynamicComponent(source, options) {
4821
- return dynamicCore(source, options);
4822
- }
4823
- const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
4824
- function dynamicCore(source, options, tagArm) {
4825
- if (options?.static) {
4826
- const component = untrack(source);
4827
- if (component && typeof component.then === "function") throw new Error("dynamic(): a static source must resolve synchronously, not to a promise");
4828
- if (typeof component === "function") return props => component(props);
4829
- if (typeof component === "string" && tagArm) return props => tagArm(component, props);
4830
- return () => undefined;
4831
- }
4832
- const cached = createMemo(() => {
4833
- const next = source();
4834
- if (!next || typeof next.then !== "function") return next;
4835
- return {
4836
- [FLIGHT]: next
4837
- };
4838
- });
4839
- const deferStream = !!options?.deferStream;
4840
- return props => {
4841
- const ctx = sharedConfig.context;
4842
- let gated = !deferStream || !ctx?.async;
4843
- const value = createMemo(() => {
4844
- let c;
4845
- try {
4846
- c = cached();
4847
- } catch (err) {
4848
- if (!gated && err instanceof NotReadyError && !err.source?.$clientHole) {
4849
- gated = true;
4850
- ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
4851
- }
4852
- throw err;
4853
- }
4854
- if (!c || !c[FLIGHT]) return c;
4855
- const next = c[FLIGHT];
4856
- return {
4857
- then: (onFulfilled, onRejected) => next.then(resolved => {
4858
- let landed;
4859
- try {
4860
- landed = classifyLanding(resolved);
4861
- } catch (err) {
4862
- if (onRejected) return onRejected(err);
4863
- throw err;
4864
- }
4865
- return onFulfilled ? onFulfilled(landed) : landed;
4866
- }, onRejected)
4867
- };
4868
- }, {
4869
- deferStream
4870
- });
4871
- return createMemo(() => {
4872
- const c = value();
4873
- if (c) {
4874
- if (typeof c === "function") return c(props);
4875
- if (typeof c === "string" && tagArm) return tagArm(c, props);
4876
- }
4877
- }, {
4878
- sync: true
4879
- });
4880
- };
4881
- }
4882
- const FLIGHT = Symbol("solid.dynamic-flight");
4883
- const SERVER_COMPONENT = Symbol.for("solid.server-component");
4884
- function classifyLanding(resolved) {
4885
- if (typeof resolved !== "function" || SERVER_COMPONENT in resolved) return resolved;
4886
- const message = "[DYNAMIC_ASYNC_COMPONENT] An async dynamic() source resolved to a client component " + "function, which cannot be serialized for hydration: the client would re-run the source " + "and wait on it while hydrating, committing the enclosing <Loading> to a fallback the " + "server never rendered. Resolve the async upstream — a createAsync()/createMemo() the " + "source reads synchronously (`dynamic(() => page() ? Editor : Viewer)`) — or use lazy() " + "for a code-split component. A source may stay async when it resolves to a server " + "component or a serializable value (a tag name)." ;
4887
- recordFinding({
4888
- code: "DYNAMIC_ASYNC_COMPONENT",
4889
- kind: "ssr",
4890
- severity: "error",
4891
- message,
4892
- data: {
4893
- component: resolved.name || undefined
4894
- }
4895
- }, null);
4896
- throw new Error(message);
4897
- }
4898
4903
  function Dynamic(props) {
4899
4904
  const Comp = dynamic(() => props.component);
4900
4905
  return createComponent(Comp, omit(props, "component"));
@@ -5023,4 +5028,4 @@ function httpHeader(name, value, options) {
5023
5028
  }
5024
5029
  }
5025
5030
 
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 };
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 };