@solidjs/web 2.0.0-rc.13 → 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.
- package/dist/server.dev.js +317 -185
- package/dist/server.js +298 -161
- package/dist/server.observe.js +299 -171
- package/dist/web.dev.js +207 -189
- package/dist/web.js +180 -178
- package/dist/web.observe.js +180 -180
- package/frames/dist/assets.js +92 -0
- package/frames/dist/bind.dev.js +326 -0
- package/frames/dist/bind.js +295 -0
- package/frames/dist/client.dev.js +665 -1114
- package/frames/dist/client.js +630 -1087
- package/frames/dist/client.observe.js +629 -1087
- package/frames/dist/regions.js +130 -0
- package/frames/dist/server.dev.js +400 -201
- package/frames/dist/server.js +397 -198
- package/frames/dist/server.observe.js +397 -198
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +133 -0
- package/package.json +30 -4
- package/performance-tracks/dist/performance-tracks.dev.js +2 -1
- package/performance-tracks/dist/performance-tracks.observe.js +2 -1
- package/performance-tracks/types/index.d.ts +8 -6
- package/serialization/dist/decode.js +38 -9
- package/serialization/dist/serialization.js +40 -11
- package/serialization/types/serializer-decode.d.ts +24 -2
- package/server-functions/dist/client.dev.js +101 -62
- package/server-functions/dist/client.js +101 -62
- package/server-functions/dist/client.observe.js +101 -62
- package/server-functions/dist/server.dev.js +178 -67
- package/server-functions/dist/server.js +178 -67
- package/server-functions/dist/server.observe.js +178 -67
- package/skills/server-components/SKILL.md +65 -43
- package/types/client.d.ts +120 -8
- package/types/constants.d.ts +3 -1
- package/types/diagnostics.d.ts +8 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/bind-tier.d.ts +60 -0
- package/types/frames/client.d.ts +37 -3
- package/types/frames/frame-client.d.ts +249 -78
- package/types/frames/frame-container-plugin.d.ts +2 -2
- package/types/frames/frame-sink.d.ts +33 -0
- package/types/frames/frame-transport.d.ts +66 -18
- package/types/frames/regions-tier.d.ts +45 -0
- package/types/frames/serializer-decode.d.ts +24 -2
- package/types/frames/server.d.ts +33 -9
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/wire-tier.d.ts +116 -0
- package/types/head.d.ts +1 -0
- package/types/index.d.ts +61 -16
- package/types/index.server.d.ts +3 -18
- package/types/jsx.d.ts +4 -13
- package/types/observe.d.ts +4 -2
- package/types/response.d.ts +26 -4
- package/types/serializer-decode.d.ts +24 -2
- package/types/server-functions/client.d.ts +30 -0
- package/types/server-functions/registry.d.ts +4 -1
- package/types/server-functions/shared.d.ts +12 -8
- package/types/server-mock.d.ts +22 -3
- package/types/server.d.ts +119 -17
package/dist/server.dev.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
-
import { sharedConfig, viewOf, sourceOwners,
|
|
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
|
-
import {
|
|
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 = {
|
|
@@ -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",
|
|
@@ -59,6 +60,10 @@ function isHttpNavigationTarget(target) {
|
|
|
59
60
|
return false;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
63
|
+
function isEventName(name) {
|
|
64
|
+
let c;
|
|
65
|
+
return name.startsWith("on") && (c = name.charCodeAt(2)) > 64 && c < 91;
|
|
66
|
+
}
|
|
62
67
|
|
|
63
68
|
const transparentOptions = {
|
|
64
69
|
transparent: true,
|
|
@@ -465,17 +470,15 @@ function toBorderForm(value, envelopeContainers) {
|
|
|
465
470
|
}
|
|
466
471
|
function isShareableIterable(value) {
|
|
467
472
|
try {
|
|
468
|
-
|
|
469
|
-
if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) return false;
|
|
470
|
-
return typeof value[Symbol.asyncIterator] === "function";
|
|
473
|
+
return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
|
|
471
474
|
} catch {
|
|
472
475
|
return false;
|
|
473
476
|
}
|
|
474
477
|
}
|
|
475
|
-
function materialize(marker) {
|
|
478
|
+
function materialize(marker, claiming) {
|
|
476
479
|
let value = state.materialized.get(marker.$tr);
|
|
477
480
|
if (value === undefined) {
|
|
478
|
-
value = state.materializeTrace(marker);
|
|
481
|
+
value = state.materializeTrace(marker, claiming);
|
|
479
482
|
state.materialized.set(marker.$tr, value);
|
|
480
483
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
481
484
|
}
|
|
@@ -533,23 +536,22 @@ setContainerTraceStreamMint(iterable => {
|
|
|
533
536
|
})();
|
|
534
537
|
return stream;
|
|
535
538
|
});
|
|
536
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
539
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
537
540
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
538
541
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
539
542
|
ContainerTracePlugin]);
|
|
540
543
|
function resolveSerializerPlugins(customPlugins) {
|
|
541
544
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
542
545
|
}
|
|
543
|
-
Feature.RegExp;
|
|
544
546
|
|
|
545
|
-
const
|
|
547
|
+
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
546
548
|
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
|
|
547
549
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
548
550
|
function createSerializer(options) {
|
|
549
551
|
return new Serializer({
|
|
550
552
|
...options,
|
|
551
553
|
plugins: resolveSerializerPlugins(options.plugins),
|
|
552
|
-
disabledFeatures: (options.disabledFeatures === undefined ?
|
|
554
|
+
disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
|
|
553
555
|
});
|
|
554
556
|
}
|
|
555
557
|
function createHydrationSerializer({
|
|
@@ -573,17 +575,24 @@ function getLocalHeaderScript(id) {
|
|
|
573
575
|
}
|
|
574
576
|
|
|
575
577
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
576
|
-
|
|
577
|
-
const ResponseEnvelope =
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
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;
|
|
583
593
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
})();
|
|
594
|
+
return new EnvelopeClass(response, value);
|
|
595
|
+
};
|
|
587
596
|
function isResponseEnvelope(value) {
|
|
588
597
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
589
598
|
}
|
|
@@ -608,6 +617,16 @@ function isSafeError(value) {
|
|
|
608
617
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
609
618
|
const REVALIDATE_ALL = "*";
|
|
610
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
|
+
}
|
|
611
630
|
function initWithRevalidate(init = {}) {
|
|
612
631
|
const resolved = typeof init === "number" ? {
|
|
613
632
|
status: init
|
|
@@ -616,18 +635,7 @@ function initWithRevalidate(init = {}) {
|
|
|
616
635
|
revalidate,
|
|
617
636
|
...responseInit
|
|
618
637
|
} = resolved;
|
|
619
|
-
|
|
620
|
-
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
621
|
-
headers = new Headers();
|
|
622
|
-
responseInit.headers.forEach((value, key) => {
|
|
623
|
-
if (key !== "set-cookie") headers.append(key, value);
|
|
624
|
-
});
|
|
625
|
-
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
626
|
-
headers.append("Set-Cookie", cookie);
|
|
627
|
-
}
|
|
628
|
-
} else {
|
|
629
|
-
headers = new Headers(responseInit.headers);
|
|
630
|
-
}
|
|
638
|
+
const headers = copyHeaders(responseInit.headers);
|
|
631
639
|
if (revalidate !== undefined) {
|
|
632
640
|
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
633
641
|
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
@@ -768,7 +776,7 @@ function assertServableCookie(name, options) {
|
|
|
768
776
|
}
|
|
769
777
|
}
|
|
770
778
|
const FLASH_COOKIE = "flash";
|
|
771
|
-
const FLASH_MATCHER =
|
|
779
|
+
const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
|
|
772
780
|
function hasFlashCookie(cookieHeader) {
|
|
773
781
|
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
774
782
|
}
|
|
@@ -780,7 +788,6 @@ const ERROR_HEADER = "X-Server-Function-Error";
|
|
|
780
788
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
781
789
|
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
782
790
|
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
783
|
-
new TextEncoder().encode(":\n\n");
|
|
784
791
|
|
|
785
792
|
function emitFinding(finding, subject = getOwner()) {
|
|
786
793
|
if (OBSERVE === undefined) return;
|
|
@@ -856,6 +863,10 @@ function qualifierValue(name, value) {
|
|
|
856
863
|
function asciiLowerCase(value) {
|
|
857
864
|
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
858
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
|
+
}
|
|
859
870
|
function resourceIdentity(tag, props) {
|
|
860
871
|
const url = String(props.href || props.src || "");
|
|
861
872
|
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
@@ -1555,6 +1566,7 @@ function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMet
|
|
|
1555
1566
|
noScripts
|
|
1556
1567
|
};
|
|
1557
1568
|
}
|
|
1569
|
+
let headBodyHook;
|
|
1558
1570
|
function flushHeadFragment(registry, boundary, nonce) {
|
|
1559
1571
|
const groups = commitHeadBoundary(registry, boundary);
|
|
1560
1572
|
if (!groups.length) return null;
|
|
@@ -1578,7 +1590,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
1578
1590
|
const t = winner.tags[i];
|
|
1579
1591
|
const attrs = {};
|
|
1580
1592
|
for (const name in t.props) {
|
|
1581
|
-
if (name === "children" || name === "ref" || name
|
|
1593
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1582
1594
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
1583
1595
|
headTagInvalid("invalid-attribute", `useHead: ignoring invalid attribute name "${name}"`, name);
|
|
1584
1596
|
continue;
|
|
@@ -1593,7 +1605,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
1593
1605
|
if (value) attrs.nonce = String(value);
|
|
1594
1606
|
}
|
|
1595
1607
|
const children = t.props.children;
|
|
1596
|
-
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)]);
|
|
1597
1609
|
}
|
|
1598
1610
|
}
|
|
1599
1611
|
return ops.length ? ops : null;
|
|
@@ -1621,8 +1633,7 @@ function normalizeNonce(nonce) {
|
|
|
1621
1633
|
}
|
|
1622
1634
|
function destinationNonce(nonce, destination) {
|
|
1623
1635
|
if (nonce == null) return undefined;
|
|
1624
|
-
|
|
1625
|
-
const value = nonce[destination];
|
|
1636
|
+
const value = typeof nonce === "string" ? nonce : nonce[destination];
|
|
1626
1637
|
return typeof value === "string" && value ? value : undefined;
|
|
1627
1638
|
}
|
|
1628
1639
|
function scriptNonce(nonce) {
|
|
@@ -1668,7 +1679,7 @@ function nonceAttr(nonce, destination) {
|
|
|
1668
1679
|
function renderHeadAttrHtml(props) {
|
|
1669
1680
|
let attrs = "";
|
|
1670
1681
|
for (const name in props) {
|
|
1671
|
-
if (name === "children" || name === "ref" || name
|
|
1682
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1672
1683
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
1673
1684
|
headTagInvalid("invalid-attribute", `useHead: ignoring invalid attribute name "${name}"`, name);
|
|
1674
1685
|
continue;
|
|
@@ -1682,7 +1693,7 @@ function renderHeadAttrHtml(props) {
|
|
|
1682
1693
|
function headAttrRecord(props, skipRelHref) {
|
|
1683
1694
|
let attrs = null;
|
|
1684
1695
|
for (const name in props) {
|
|
1685
|
-
if (name === "children" || name === "ref" || name
|
|
1696
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1686
1697
|
if ((name === "rel" || name === "href")) continue;
|
|
1687
1698
|
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
1688
1699
|
const v = props[name];
|
|
@@ -1697,6 +1708,7 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
|
1697
1708
|
if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
|
|
1698
1709
|
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
1699
1710
|
let body = props.children == null ? "" : String(props.children);
|
|
1711
|
+
if (headBodyHook) body = headBodyHook(tag, props, body);
|
|
1700
1712
|
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
1701
1713
|
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
1702
1714
|
}
|
|
@@ -1706,32 +1718,51 @@ function useHead(tags) {
|
|
|
1706
1718
|
headTagInvalid("outside-render", "useHead() called outside of a server render; registration ignored.");
|
|
1707
1719
|
return;
|
|
1708
1720
|
}
|
|
1721
|
+
headBodyHook = headBodyText;
|
|
1709
1722
|
ctx.registerHeadTags(tags);
|
|
1710
1723
|
}
|
|
1711
1724
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
1725
|
+
const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
|
|
1726
|
+
const TAG_START = /^[a-zA-Z]/;
|
|
1712
1727
|
const tagInfos = /*#__PURE__*/new Map();
|
|
1713
1728
|
function tagInfo(tag) {
|
|
1714
1729
|
let info = tagInfos.get(tag);
|
|
1715
1730
|
if (info === undefined) {
|
|
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
|
+
}
|
|
1716
1745
|
info = {
|
|
1717
1746
|
open: "<" + tag,
|
|
1718
1747
|
close: "</" + tag + ">",
|
|
1719
1748
|
isVoid: VOID_ELEMENTS.test(tag),
|
|
1720
1749
|
textarea: tag === "textarea",
|
|
1721
|
-
raw: tag === "script" || tag === "style"
|
|
1750
|
+
raw: tag === "script" || tag === "style",
|
|
1751
|
+
formDefaults,
|
|
1752
|
+
formAttributes
|
|
1722
1753
|
};
|
|
1723
1754
|
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1724
1755
|
}
|
|
1725
1756
|
return info;
|
|
1726
1757
|
}
|
|
1727
1758
|
const safeAttrNames = /*#__PURE__*/new Set();
|
|
1728
|
-
function
|
|
1729
|
-
if (safeAttrNames.has(prop)) return
|
|
1730
|
-
|
|
1731
|
-
if (
|
|
1732
|
-
return
|
|
1759
|
+
function isAttrName(prop) {
|
|
1760
|
+
if (safeAttrNames.has(prop)) return true;
|
|
1761
|
+
if (prop === "" || NOT_NAME.test(prop)) return false;
|
|
1762
|
+
if (safeAttrNames.size < 512) safeAttrNames.add(prop);
|
|
1763
|
+
return true;
|
|
1733
1764
|
}
|
|
1734
|
-
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])}`;
|
|
1765
|
+
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)`;
|
|
1735
1766
|
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)}`;
|
|
1736
1767
|
function renderToString(code, options = {}) {
|
|
1737
1768
|
const {
|
|
@@ -1817,7 +1848,7 @@ function renderToString(code, options = {}) {
|
|
|
1817
1848
|
closed = true;
|
|
1818
1849
|
serializer.close();
|
|
1819
1850
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1820
|
-
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);
|
|
1821
1852
|
if (render) render.shell();
|
|
1822
1853
|
if (requestEvent && requestEvent.response) {
|
|
1823
1854
|
commitResponseStub(requestEvent.response, {
|
|
@@ -1826,12 +1857,20 @@ function renderToString(code, options = {}) {
|
|
|
1826
1857
|
}
|
|
1827
1858
|
rendered = true;
|
|
1828
1859
|
return document;
|
|
1860
|
+
} catch (err) {
|
|
1861
|
+
reportServerError(err, {
|
|
1862
|
+
kind: "render",
|
|
1863
|
+
handling: "failed"
|
|
1864
|
+
}, null, options.onError);
|
|
1865
|
+
throw err;
|
|
1829
1866
|
} finally {
|
|
1830
1867
|
if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
|
|
1831
1868
|
context.trace = undefined;
|
|
1832
1869
|
if (dispose) dispose();
|
|
1833
1870
|
}
|
|
1834
1871
|
}
|
|
1872
|
+
const SHELL_ABANDONED = Symbol();
|
|
1873
|
+
const ABANDON_RENDER = Symbol();
|
|
1835
1874
|
function renderToStream(code, options = {}) {
|
|
1836
1875
|
let {
|
|
1837
1876
|
onCompleteShell,
|
|
@@ -1852,6 +1891,7 @@ function renderToStream(code, options = {}) {
|
|
|
1852
1891
|
let disconnected = false;
|
|
1853
1892
|
let failed = false;
|
|
1854
1893
|
let onFailed;
|
|
1894
|
+
let onDisconnectedBeforeShell;
|
|
1855
1895
|
const defuse = p => {
|
|
1856
1896
|
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1857
1897
|
};
|
|
@@ -1870,9 +1910,9 @@ function renderToStream(code, options = {}) {
|
|
|
1870
1910
|
complete(sink);
|
|
1871
1911
|
} : complete;
|
|
1872
1912
|
};
|
|
1873
|
-
const abandon = disconnect => {
|
|
1913
|
+
const abandon = (disconnect, quiet) => {
|
|
1874
1914
|
if (dead) return;
|
|
1875
|
-
if (disconnect) emitFinding({
|
|
1915
|
+
if (disconnect && !quiet) emitFinding({
|
|
1876
1916
|
code: "SSR_STREAM_ABANDONED",
|
|
1877
1917
|
kind: "ssr",
|
|
1878
1918
|
severity: "warn",
|
|
@@ -1917,7 +1957,7 @@ function renderToStream(code, options = {}) {
|
|
|
1917
1957
|
if (!disconnect) {
|
|
1918
1958
|
failed = true;
|
|
1919
1959
|
onFailed && onFailed(sink);
|
|
1920
|
-
}
|
|
1960
|
+
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1921
1961
|
};
|
|
1922
1962
|
const failRender = err => {
|
|
1923
1963
|
reportServerError(err, {
|
|
@@ -2044,10 +2084,10 @@ function renderToStream(code, options = {}) {
|
|
|
2044
2084
|
const styleAttr = nonceAttr(nonce, "style");
|
|
2045
2085
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
2046
2086
|
writeTasks();
|
|
2087
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
2047
2088
|
for (const entry of styles.links) {
|
|
2048
|
-
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr}
|
|
2089
|
+
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} data-dfc="${key}">` : `<link${entry.attrHtml}${styleAttr} data-dfc="${key}">`);
|
|
2049
2090
|
}
|
|
2050
|
-
buffer.write(`<template id="${key}">${value}</template>`);
|
|
2051
2091
|
} else {
|
|
2052
2092
|
buffer.write(`<template id="${key}">${value}</template>`);
|
|
2053
2093
|
if (!deferActivation) {
|
|
@@ -2070,7 +2110,7 @@ function renderToStream(code, options = {}) {
|
|
|
2070
2110
|
}
|
|
2071
2111
|
},
|
|
2072
2112
|
shell(shellHtml, meta) {
|
|
2073
|
-
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));
|
|
2074
2114
|
},
|
|
2075
2115
|
...options.sink
|
|
2076
2116
|
};
|
|
@@ -2089,7 +2129,7 @@ function renderToStream(code, options = {}) {
|
|
|
2089
2129
|
};
|
|
2090
2130
|
let holds = 0;
|
|
2091
2131
|
const flushEnd = () => {
|
|
2092
|
-
if (!registry.size && !holds) {
|
|
2132
|
+
if (!registry.size && !holds && !rootHoles) {
|
|
2093
2133
|
serializeRootAssets();
|
|
2094
2134
|
queue(() => queue(() => {
|
|
2095
2135
|
if (context.live.end) {
|
|
@@ -2231,6 +2271,12 @@ function renderToStream(code, options = {}) {
|
|
|
2231
2271
|
}
|
|
2232
2272
|
let rootHoles = null;
|
|
2233
2273
|
let nextHoleId = 0;
|
|
2274
|
+
let parkedInlines = null;
|
|
2275
|
+
function inlineFragment(key, value) {
|
|
2276
|
+
if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
|
|
2277
|
+
(parkedInlines ||= new Map()).set(key, value);
|
|
2278
|
+
} else html = replacePlaceholder(html, key, value);
|
|
2279
|
+
}
|
|
2234
2280
|
let buffer = {
|
|
2235
2281
|
write(payload) {
|
|
2236
2282
|
tmp += payload;
|
|
@@ -2359,11 +2405,16 @@ function renderToStream(code, options = {}) {
|
|
|
2359
2405
|
});
|
|
2360
2406
|
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
|
|
2361
2407
|
}
|
|
2362
|
-
return (value, error) => {
|
|
2408
|
+
return (value, error, escaped) => {
|
|
2363
2409
|
if (registry.has(key)) {
|
|
2364
2410
|
const item = registry.get(key);
|
|
2365
2411
|
registry.delete(key);
|
|
2366
2412
|
if (error) abandonSubtree(key, error);
|
|
2413
|
+
if (error && escaped) {
|
|
2414
|
+
const wire = ssrSanitizeError(error, null);
|
|
2415
|
+
const message = wire instanceof Error ? wire.message : String(wire);
|
|
2416
|
+
if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
|
|
2417
|
+
}
|
|
2367
2418
|
if (item.children && !error) {
|
|
2368
2419
|
for (const k in item.children) {
|
|
2369
2420
|
value = replacePlaceholder(value, k, item.children[k]);
|
|
@@ -2383,7 +2434,7 @@ function renderToStream(code, options = {}) {
|
|
|
2383
2434
|
if (!completed) {
|
|
2384
2435
|
if (error) dropHeadBoundary(headRegistry, key);
|
|
2385
2436
|
if (!firstFlushed) {
|
|
2386
|
-
queue(() =>
|
|
2437
|
+
queue(() => inlineFragment(key, value !== undefined ? value : ""));
|
|
2387
2438
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
2388
2439
|
item.resolve(error);
|
|
2389
2440
|
} else {
|
|
@@ -2427,7 +2478,7 @@ function renderToStream(code, options = {}) {
|
|
|
2427
2478
|
registerEntryAssets(manifest);
|
|
2428
2479
|
context.writer = createHydrationWriter(context, () => !completed);
|
|
2429
2480
|
const signal = options.signal;
|
|
2430
|
-
const onAbort = signal ? () => abandon("signal") : undefined;
|
|
2481
|
+
const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
|
|
2431
2482
|
let html = createRoot(d => {
|
|
2432
2483
|
dispose = () => {
|
|
2433
2484
|
context.trace = undefined;
|
|
@@ -2436,7 +2487,16 @@ function renderToStream(code, options = {}) {
|
|
|
2436
2487
|
};
|
|
2437
2488
|
rootOwner = claimRenderRoot(context);
|
|
2438
2489
|
if (requestEvent) claimEventRender(requestEvent, context);
|
|
2439
|
-
|
|
2490
|
+
let res;
|
|
2491
|
+
try {
|
|
2492
|
+
res = resolveSSRNode(escape(code()));
|
|
2493
|
+
} catch (err) {
|
|
2494
|
+
reportServerError(err, {
|
|
2495
|
+
kind: "render",
|
|
2496
|
+
handling: "failed"
|
|
2497
|
+
}, null, options.onError);
|
|
2498
|
+
throw err;
|
|
2499
|
+
}
|
|
2440
2500
|
if (!res.h.length) return res.t[0];
|
|
2441
2501
|
rootHoles = [];
|
|
2442
2502
|
let out = res.t[0];
|
|
@@ -2483,6 +2543,13 @@ function renderToStream(code, options = {}) {
|
|
|
2483
2543
|
for (const p of res.p) blockingPromises.add(p);
|
|
2484
2544
|
}
|
|
2485
2545
|
}
|
|
2546
|
+
if (parkedInlines) {
|
|
2547
|
+
for (const [key, value] of parkedInlines) {
|
|
2548
|
+
if (!html.includes(`<template id="pl-${key}">`)) continue;
|
|
2549
|
+
html = replacePlaceholder(html, key, value);
|
|
2550
|
+
parkedInlines.delete(key);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2486
2553
|
if (pending.length) {
|
|
2487
2554
|
rootHoles = pending;
|
|
2488
2555
|
return false;
|
|
@@ -2644,11 +2711,16 @@ function renderToStream(code, options = {}) {
|
|
|
2644
2711
|
},
|
|
2645
2712
|
pipe(w) {
|
|
2646
2713
|
claimConsumer("pipe");
|
|
2714
|
+
const abandoned = w[SHELL_ABANDONED];
|
|
2647
2715
|
onFailure(sink => {
|
|
2648
2716
|
try {
|
|
2649
|
-
sink ? sink.end() : w.end();
|
|
2717
|
+
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
2650
2718
|
} catch (_) {}
|
|
2651
2719
|
});
|
|
2720
|
+
if (abandoned) {
|
|
2721
|
+
w[ABANDON_RENDER] = abandon;
|
|
2722
|
+
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2723
|
+
}
|
|
2652
2724
|
function flush() {
|
|
2653
2725
|
allSettled(blockingPromises).then(awaited => {
|
|
2654
2726
|
scheduleFlush(() => {
|
|
@@ -2690,11 +2762,15 @@ function renderToStream(code, options = {}) {
|
|
|
2690
2762
|
};
|
|
2691
2763
|
}
|
|
2692
2764
|
function HydrationScript(props) {
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2765
|
+
if (sharedConfig.context) sharedConfig.context.bootstrap = true;
|
|
2766
|
+
const {
|
|
2767
|
+
eventNames,
|
|
2768
|
+
nonce
|
|
2769
|
+
} = {
|
|
2770
|
+
nonce: sharedConfig.context && sharedConfig.context.nonce,
|
|
2696
2771
|
...props
|
|
2697
|
-
}
|
|
2772
|
+
};
|
|
2773
|
+
return ssr(hydrationBootstrap(eventNames, scriptNonce(nonce), true));
|
|
2698
2774
|
}
|
|
2699
2775
|
function ssrGroup(fn, n) {
|
|
2700
2776
|
fn.$g = n;
|
|
@@ -2850,7 +2926,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
2850
2926
|
let nextId = 0;
|
|
2851
2927
|
const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
|
|
2852
2928
|
const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
|
|
2853
|
-
const stripMarkers = html => html.replace(/<!--lh:\/?\d
|
|
2929
|
+
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
|
|
2854
2930
|
const swept = (owner, ctx, fn) => {
|
|
2855
2931
|
const prev = sharedConfig.context;
|
|
2856
2932
|
sharedConfig.context = ctx;
|
|
@@ -3388,6 +3464,14 @@ function ssrStyleProperty(name, value) {
|
|
|
3388
3464
|
if (isSlotValue(value)) value = slotValueInline("style", value);
|
|
3389
3465
|
return value != null ? name + value : "";
|
|
3390
3466
|
}
|
|
3467
|
+
function ssrStyleProperties(...entries) {
|
|
3468
|
+
let result = "";
|
|
3469
|
+
for (let i = 0; i < entries.length; i += 2) {
|
|
3470
|
+
const entry = ssrStyleProperty(entries[i], entries[i + 1]);
|
|
3471
|
+
if (entry) result = result ? result + ";" + entry : entry;
|
|
3472
|
+
}
|
|
3473
|
+
return result;
|
|
3474
|
+
}
|
|
3391
3475
|
function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
3392
3476
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
3393
3477
|
if (typeof props === "function") props = props();
|
|
@@ -3398,6 +3482,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3398
3482
|
let ownerIndex = null;
|
|
3399
3483
|
const ctx = renderConfig.context;
|
|
3400
3484
|
const slots = ctx !== undefined && ctx.claims !== undefined;
|
|
3485
|
+
const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
|
|
3401
3486
|
if (Array.isArray(props)) {
|
|
3402
3487
|
if (slots && props.$slot === true) props = slotSpreadSource(tag, props);else {
|
|
3403
3488
|
let i = 0;
|
|
@@ -3427,6 +3512,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3427
3512
|
const skipChildren = info.isVoid;
|
|
3428
3513
|
let result = info.open + hk;
|
|
3429
3514
|
let behaviors = null;
|
|
3515
|
+
let childOwner = null;
|
|
3430
3516
|
const last = sources === null ? 0 : sources.length - 1;
|
|
3431
3517
|
let keysOf = null;
|
|
3432
3518
|
if (sources !== null) {
|
|
@@ -3437,7 +3523,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3437
3523
|
const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
|
|
3438
3524
|
if (sources !== null) props = sources[s];
|
|
3439
3525
|
nextKey: for (let i = 0; i < keys.length; i++) {
|
|
3440
|
-
|
|
3526
|
+
let prop = keys[i];
|
|
3441
3527
|
if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
|
|
3442
3528
|
if (owners !== null) props = owners[i];
|
|
3443
3529
|
for (let j = s + 1; j <= last; j++) {
|
|
@@ -3449,22 +3535,30 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3449
3535
|
continue;
|
|
3450
3536
|
}
|
|
3451
3537
|
if (ChildProperties.has(prop)) {
|
|
3452
|
-
if (children === undefined &&
|
|
3538
|
+
if (children === undefined && childOwner === null && !skipChildren) {
|
|
3539
|
+
if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
3540
|
+
}
|
|
3453
3541
|
continue;
|
|
3454
3542
|
}
|
|
3455
|
-
const
|
|
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];
|
|
3456
3549
|
if (value == undefined) {
|
|
3457
|
-
if (slots && claims !== undefined && (prop === "ref" || prop
|
|
3550
|
+
if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
|
|
3458
3551
|
continue;
|
|
3459
3552
|
}
|
|
3460
3553
|
if (prop.startsWith("prop:")) {
|
|
3461
3554
|
if (slots && typeof value === "object") spreadPropPosition(prop, value);
|
|
3462
3555
|
continue;
|
|
3463
3556
|
}
|
|
3464
|
-
if (prop === "ref" || prop
|
|
3557
|
+
if (prop === "ref" || isEventName(prop)) {
|
|
3465
3558
|
if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
|
|
3466
3559
|
continue;
|
|
3467
3560
|
}
|
|
3561
|
+
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3468
3562
|
if (slots && typeof value === "object") {
|
|
3469
3563
|
result += spreadObjectAttribute(prop, value);
|
|
3470
3564
|
} else if (prop === "style") {
|
|
@@ -3472,18 +3566,19 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3472
3566
|
} else if (prop === "class") {
|
|
3473
3567
|
result += ` class="${ssrClassName(value)}"`;
|
|
3474
3568
|
} else if (typeof value === "boolean") {
|
|
3475
|
-
if (
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
result += value === "" ? ` ${attrName(prop)}` : ` ${attrName(prop)}="${escape(value, true)}"`;
|
|
3569
|
+
if (value && isAttrName(prop)) result += ` ${prop}`;
|
|
3570
|
+
} else if (isAttrName(prop)) {
|
|
3571
|
+
result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
|
|
3479
3572
|
}
|
|
3480
3573
|
}
|
|
3481
3574
|
}
|
|
3482
3575
|
if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
|
|
3483
3576
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3577
|
+
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
3484
3578
|
if (skipChildren) return {
|
|
3485
3579
|
t: result + " />"
|
|
3486
3580
|
};
|
|
3581
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
3487
3582
|
if (typeof children === "function") children = children();
|
|
3488
3583
|
const ct = typeof children;
|
|
3489
3584
|
if (ct === "string" || ct === "number") return {
|
|
@@ -3497,6 +3592,19 @@ function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
|
3497
3592
|
};
|
|
3498
3593
|
return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3499
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
|
+
}
|
|
3500
3608
|
function ssrElementAttribute(key, value) {
|
|
3501
3609
|
if (value == undefined) return "";
|
|
3502
3610
|
if (key === "style" || key === "class") {
|
|
@@ -3507,10 +3615,12 @@ function ssrElementAttribute(key, value) {
|
|
|
3507
3615
|
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
3508
3616
|
}
|
|
3509
3617
|
function ssrAttribute(key, value) {
|
|
3618
|
+
if (typeof value === "string") return ` ${key}="${value}"`;
|
|
3510
3619
|
if (value == null || value === false) return "";
|
|
3511
3620
|
if (typeof value === "object") {
|
|
3512
3621
|
return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
|
|
3513
3622
|
}
|
|
3623
|
+
if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
|
|
3514
3624
|
return value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
3515
3625
|
}
|
|
3516
3626
|
function ssrHydrationKey() {
|
|
@@ -3524,7 +3634,7 @@ const SLOT_MARKER = "_s:";
|
|
|
3524
3634
|
const SLOT_FACE_STREAM = 0;
|
|
3525
3635
|
const SLOT_FACE_DATA = 1;
|
|
3526
3636
|
const SLOT_FACE_MARKUP = 2;
|
|
3527
|
-
const
|
|
3637
|
+
const BINDING_SLOT_POSITION = "BINDING_SLOT_POSITION";
|
|
3528
3638
|
function slotFinding(sv, reason, position, message, severity = "warn") {
|
|
3529
3639
|
{
|
|
3530
3640
|
const ctx = sharedConfig.context;
|
|
@@ -3535,7 +3645,7 @@ function slotFinding(sv, reason, position, message, severity = "warn") {
|
|
|
3535
3645
|
seen.add(id);
|
|
3536
3646
|
}
|
|
3537
3647
|
devCheck({
|
|
3538
|
-
code:
|
|
3648
|
+
code: BINDING_SLOT_POSITION,
|
|
3539
3649
|
kind: "ssr",
|
|
3540
3650
|
severity,
|
|
3541
3651
|
message,
|
|
@@ -3564,29 +3674,32 @@ function slotValue(occurrence, key, value, face) {
|
|
|
3564
3674
|
Object.defineProperty(sv, "toString", {
|
|
3565
3675
|
value: () => slotValueString(sv, "stringified")
|
|
3566
3676
|
});
|
|
3677
|
+
Object.defineProperty(sv, "w", {
|
|
3678
|
+
value: () => slotText(sv)
|
|
3679
|
+
});
|
|
3567
3680
|
return sv;
|
|
3568
3681
|
}
|
|
3569
3682
|
function slotValueString(sv, reason) {
|
|
3570
3683
|
{
|
|
3571
3684
|
const prop = propOfOccurrence(sv[SLOT_VALUE]);
|
|
3572
|
-
slotFinding(sv, reason, undefined, reason === "coerced" ? `[${
|
|
3685
|
+
slotFinding(sv, reason, undefined, reason === "coerced" ? `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value used in an expression ` + `(a comparison, arithmetic, or a branch on its result). The server does not have the value — ` + `the client owns it — so nothing can be computed from it here. It must be the WHOLE value of ` + `an attribute, class name, style property, handler, ref or text child; a decision that depends on it ` + `belongs in the client fill (return the decided value) or in a markup slot.` : `[${BINDING_SLOT_POSITION}] \`${prop}\`'s \`${sv.k}\` is a binding-slot value ` + `and was stringified outside a bindable position — it must be the WHOLE value of an attribute, ` + `class name, style property, handler, ref or text child (\`class={row.${sv.k}}\`, not \`class={\`x \${row.${sv.k}}\`}\`). ` + `If it is, the element was compiled without the \`serverComponents\` compiler option. ` + `Nothing renders here on either face.`);
|
|
3573
3686
|
}
|
|
3574
3687
|
return "";
|
|
3575
3688
|
}
|
|
3576
|
-
function
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
return
|
|
3689
|
+
function slotText(sv) {
|
|
3690
|
+
slotMarkupRead(sv, "text");
|
|
3691
|
+
const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
|
|
3692
|
+
const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
|
|
3693
|
+
return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
|
|
3581
3694
|
}
|
|
3582
3695
|
function slotMarkupRead(sv, position) {
|
|
3583
3696
|
if (sv.f === SLOT_FACE_MARKUP) {
|
|
3584
|
-
slotFinding(sv, "markup", position, `[${
|
|
3697
|
+
slotFinding(sv, "markup", position, `[${BINDING_SLOT_POSITION}] \`${position}\` reads \`${sv.k}\` off slot \`${propOfOccurrence(sv[SLOT_VALUE])}\`, ` + `but the client fill returned markup, not an object. A slot renders one or the other: ` + `return an object (\`{ ${sv.k}: … }\`) for positions, or place the slot as content.`);
|
|
3585
3698
|
}
|
|
3586
3699
|
}
|
|
3587
3700
|
function slotValueInline(kind, sv) {
|
|
3588
3701
|
{
|
|
3589
|
-
slotFinding(sv, "inline", kind, `[${
|
|
3702
|
+
slotFinding(sv, "inline", kind, `[${BINDING_SLOT_POSITION}] A binding-slot value (\`${sv.k}\` of \`${propOfOccurrence(sv[SLOT_VALUE])}\`) ` + `reached \`${kind}\` inside template quotes, where its position marker cannot be emitted — the ` + `element was compiled without the \`serverComponents\` compiler option. Nothing renders here ` + `on either face.`);
|
|
3590
3703
|
}
|
|
3591
3704
|
return undefined;
|
|
3592
3705
|
}
|
|
@@ -3600,6 +3713,9 @@ function slotEntry(sv, name) {
|
|
|
3600
3713
|
function slotMarker(position, entries) {
|
|
3601
3714
|
return ` ${SLOT_MARKER}${position}="${entries}"`;
|
|
3602
3715
|
}
|
|
3716
|
+
function eventSlotStamp(mode) {
|
|
3717
|
+
return mode === CLAIMS_DOCUMENT ? " _hk" : "";
|
|
3718
|
+
}
|
|
3603
3719
|
function propOfOccurrence(occurrence) {
|
|
3604
3720
|
const i = occurrence.indexOf("#");
|
|
3605
3721
|
return i === -1 ? occurrence : occurrence.slice(0, i);
|
|
@@ -3655,6 +3771,7 @@ function eventPosition(prop) {
|
|
|
3655
3771
|
return prop.slice(2).toLowerCase();
|
|
3656
3772
|
}
|
|
3657
3773
|
function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
|
|
3774
|
+
if (!isAttrName(prop)) return behaviors;
|
|
3658
3775
|
const pos = prop === "ref" ? "ref" : eventPosition(prop);
|
|
3659
3776
|
const entries = value == null ? "" : claimEntries(pos, value, mode);
|
|
3660
3777
|
if (!settle) {
|
|
@@ -3701,13 +3818,18 @@ function spreadBehaviorMarkers(behaviors, claims, mode) {
|
|
|
3701
3818
|
}
|
|
3702
3819
|
}
|
|
3703
3820
|
let out = "";
|
|
3821
|
+
let events = false;
|
|
3704
3822
|
if (behaviors !== null) {
|
|
3705
3823
|
for (const [pos, b] of behaviors) {
|
|
3706
3824
|
const e = claims === undefined ? b : b.e;
|
|
3707
|
-
if (e)
|
|
3825
|
+
if (!e) continue;
|
|
3826
|
+
if (pos === "ref") out += slotMarker("ref", e);else {
|
|
3827
|
+
out += slotMarker("on:" + pos, e);
|
|
3828
|
+
events = true;
|
|
3829
|
+
}
|
|
3708
3830
|
}
|
|
3709
3831
|
}
|
|
3710
|
-
return out;
|
|
3832
|
+
return events ? out + eventSlotStamp(mode) : out;
|
|
3711
3833
|
}
|
|
3712
3834
|
function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
|
|
3713
3835
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -3736,20 +3858,21 @@ function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
|
|
|
3736
3858
|
}
|
|
3737
3859
|
function spreadPropPosition(prop, value) {
|
|
3738
3860
|
if (isSlotValue(value)) {
|
|
3739
|
-
slotFinding(value, "prop", prop, `[${
|
|
3861
|
+
slotFinding(value, "prop", prop, `[${BINDING_SLOT_POSITION}] \`${value.k}\` of slot \`${propOfOccurrence(value[SLOT_VALUE])}\` is bound ` + `at \`${prop}\`. Property positions are not bindable (the server renders no properties): nothing ` + `renders here. Bind the attribute form (\`${prop.slice(5)}\`), or set the property in the client fill's ref.`);
|
|
3740
3862
|
}
|
|
3741
3863
|
}
|
|
3742
3864
|
function spreadObjectAttribute(prop, value) {
|
|
3743
3865
|
if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
|
|
3744
|
-
if (
|
|
3745
|
-
return
|
|
3866
|
+
if (!isAttrName(prop)) return "";
|
|
3867
|
+
if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
|
|
3868
|
+
return ` ${prop}="${escape(value, true)}"`;
|
|
3746
3869
|
}
|
|
3747
3870
|
function slotSpreadSource(tag, source) {
|
|
3748
3871
|
{
|
|
3749
3872
|
const occurrence = source.$occurrence;
|
|
3750
|
-
const text = `[${
|
|
3873
|
+
const text = `[${BINDING_SLOT_POSITION}] A slot${occurrence ? ` (\`${propOfOccurrence(occurrence)}\`)` : ""} is spread ` + `onto a server-rendered <${tag}>. A binding slot binds by position — name each one ` + `(\`class={row.rowClass} onClick={row.remove}\`) so the template shows what the client owns.`;
|
|
3751
3874
|
recordFinding({
|
|
3752
|
-
code:
|
|
3875
|
+
code: BINDING_SLOT_POSITION,
|
|
3753
3876
|
kind: "ssr",
|
|
3754
3877
|
severity: "error",
|
|
3755
3878
|
message: text,
|
|
@@ -3766,13 +3889,27 @@ function ssrClaim(map) {
|
|
|
3766
3889
|
const mode = sharedConfig.context && sharedConfig.context.claims;
|
|
3767
3890
|
if (!mode) return "";
|
|
3768
3891
|
let out = "";
|
|
3892
|
+
let events = false;
|
|
3769
3893
|
for (const pos in map) {
|
|
3770
3894
|
const entries = claimEntries(pos, map[pos], mode);
|
|
3771
|
-
if (entries)
|
|
3895
|
+
if (!entries) continue;
|
|
3896
|
+
if (pos === "ref") out += slotMarker("ref", entries);else {
|
|
3897
|
+
out += slotMarker("on:" + pos, entries);
|
|
3898
|
+
events = true;
|
|
3899
|
+
}
|
|
3772
3900
|
}
|
|
3773
|
-
return out;
|
|
3901
|
+
return events ? out + eventSlotStamp(mode) : out;
|
|
3774
3902
|
}
|
|
3775
3903
|
function claimEntries(pos, value, mode) {
|
|
3904
|
+
if (Array.isArray(value) && pos !== "ref") {
|
|
3905
|
+
{
|
|
3906
|
+
const sv = value.find(isSlotValue);
|
|
3907
|
+
if (sv !== undefined) {
|
|
3908
|
+
slotFinding(sv, "tuple", pos, `[${BINDING_SLOT_POSITION}] A \`${pos}\` handler position on a server-rendered element received ` + `an array. A position marker names the slot's keys, never data, so a tuple's data cannot reach ` + `the client — nothing binds here. Return the tuple from the fill (\`[handler, data]\`) and ` + `bind that one property.`);
|
|
3909
|
+
} else claimEntries(pos, value[0], mode);
|
|
3910
|
+
}
|
|
3911
|
+
return "";
|
|
3912
|
+
}
|
|
3776
3913
|
if (Array.isArray(value)) {
|
|
3777
3914
|
let entries = "";
|
|
3778
3915
|
for (const v of value) {
|
|
@@ -3788,10 +3925,10 @@ function claimEntries(pos, value, mode) {
|
|
|
3788
3925
|
if (typeof value === "function" && !value.$slotWarned && claimInScope(mode)) {
|
|
3789
3926
|
value.$slotWarned = true;
|
|
3790
3927
|
devCheck({
|
|
3791
|
-
code:
|
|
3928
|
+
code: BINDING_SLOT_POSITION,
|
|
3792
3929
|
kind: "ssr",
|
|
3793
3930
|
severity: "warn",
|
|
3794
|
-
message: `[${
|
|
3931
|
+
message: `[${BINDING_SLOT_POSITION}] A \`${pos}\` position on a server-rendered element received a server-local ` + `function — it can never run. Bind a slot's property there ` + `(\`const row = props.row(args); ${pos === "ref" ? "ref" : "onX"}={row.${pos === "ref" ? "ref" : "onX"}}\`) ` + `so the client supplies it, or bind a mutation to \`action=\`.`,
|
|
3795
3932
|
data: {
|
|
3796
3933
|
reason: "server-local",
|
|
3797
3934
|
position: pos
|
|
@@ -3803,6 +3940,11 @@ function claimEntries(pos, value, mode) {
|
|
|
3803
3940
|
function claimInScope(mode) {
|
|
3804
3941
|
return mode === CLAIMS_STREAM || typeof inServerComponentScope === "function" && inServerComponentScope();
|
|
3805
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
|
+
}
|
|
3806
3948
|
function decodeSSREntities(s) {
|
|
3807
3949
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
3808
3950
|
}
|
|
@@ -4032,10 +4174,13 @@ function applyRef(r, element) {
|
|
|
4032
4174
|
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
4033
4175
|
}
|
|
4034
4176
|
function generateHydrationScript({
|
|
4035
|
-
eventNames
|
|
4177
|
+
eventNames,
|
|
4036
4178
|
nonce
|
|
4037
4179
|
} = {}) {
|
|
4038
|
-
return
|
|
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-->`;
|
|
4039
4184
|
}
|
|
4040
4185
|
function queue(fn) {
|
|
4041
4186
|
return Promise.resolve().then(fn);
|
|
@@ -4048,6 +4193,11 @@ function allSettled(promises) {
|
|
|
4048
4193
|
return size;
|
|
4049
4194
|
});
|
|
4050
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
|
+
}
|
|
4051
4201
|
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
4052
4202
|
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
4053
4203
|
const title = headTags ? headTags.title : null;
|
|
@@ -4238,6 +4388,10 @@ function tryResolveString(node, nested) {
|
|
|
4238
4388
|
if (node.h && node.h.length > 0) return {
|
|
4239
4389
|
merge: node
|
|
4240
4390
|
};
|
|
4391
|
+
if (node[SLOT_VALUE] !== undefined) {
|
|
4392
|
+
ssrTextTail = false;
|
|
4393
|
+
return node.w();
|
|
4394
|
+
}
|
|
4241
4395
|
if (node.t === undefined) {
|
|
4242
4396
|
unrecognizedInsert(node);
|
|
4243
4397
|
return "";
|
|
@@ -4292,9 +4446,8 @@ function resolveSSRNode(node, result = {
|
|
|
4292
4446
|
result.t[result.t.length - 1] += node.t;
|
|
4293
4447
|
ssrTextTail = false;
|
|
4294
4448
|
} else if (node[SLOT_VALUE] !== undefined) {
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
ssrTextTail = true;
|
|
4449
|
+
result.t[result.t.length - 1] += node.w();
|
|
4450
|
+
ssrTextTail = false;
|
|
4298
4451
|
} else unrecognizedInsert(node);
|
|
4299
4452
|
} else if (t === "function") {
|
|
4300
4453
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
@@ -4347,6 +4500,14 @@ function configureServerErrors(config) {
|
|
|
4347
4500
|
}
|
|
4348
4501
|
(g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
|
|
4349
4502
|
}
|
|
4503
|
+
function reportRequestFailure(error, event) {
|
|
4504
|
+
reportServerError(error, {
|
|
4505
|
+
kind: "request",
|
|
4506
|
+
handling: "failed",
|
|
4507
|
+
event
|
|
4508
|
+
}, null);
|
|
4509
|
+
if (ambientServerErrorHook() === undefined) console.error(error);
|
|
4510
|
+
}
|
|
4350
4511
|
function getRequestEvent() {
|
|
4351
4512
|
const store = globalThis[RequestContext];
|
|
4352
4513
|
if (!store) return undefined;
|
|
@@ -4390,13 +4551,31 @@ function createHydrationWriter(context, isOpen) {
|
|
|
4390
4551
|
};
|
|
4391
4552
|
}
|
|
4392
4553
|
function getHydrationWriter() {
|
|
4554
|
+
const ctx = currentRenderContext();
|
|
4555
|
+
return ctx && ctx.writer;
|
|
4556
|
+
}
|
|
4557
|
+
function currentRenderContext() {
|
|
4393
4558
|
let ctx = renderContextOf(getOwner());
|
|
4394
4559
|
if (!ctx) {
|
|
4395
4560
|
const event = peekRequestEvent();
|
|
4396
4561
|
const renders = event && eventRenders.get(event);
|
|
4397
4562
|
if (renders && renders.size === 1) for (const c of renders) ctx = c;
|
|
4398
4563
|
}
|
|
4399
|
-
return ctx
|
|
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;
|
|
4400
4579
|
}
|
|
4401
4580
|
function takeHydrationValue(_key) {
|
|
4402
4581
|
return undefined;
|
|
@@ -4517,10 +4696,13 @@ function copyInitHeaders(init) {
|
|
|
4517
4696
|
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
4518
4697
|
return headers;
|
|
4519
4698
|
}
|
|
4520
|
-
|
|
4521
|
-
|
|
4699
|
+
let stubGapFillExcluded;
|
|
4700
|
+
function isStubGapFillExcluded(key) {
|
|
4701
|
+
return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
4702
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
|
|
4703
|
+
}
|
|
4522
4704
|
function fillsStubGap(key, headers, response) {
|
|
4523
|
-
if (key === "set-cookie" ||
|
|
4705
|
+
if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
|
|
4524
4706
|
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
4525
4707
|
return !headers.has(key);
|
|
4526
4708
|
}
|
|
@@ -4612,7 +4794,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4612
4794
|
closed = true;
|
|
4613
4795
|
}
|
|
4614
4796
|
};
|
|
4615
|
-
|
|
4797
|
+
const sink = {
|
|
4616
4798
|
write(chunk) {
|
|
4617
4799
|
if (!flushed) {
|
|
4618
4800
|
flushed = true;
|
|
@@ -4627,6 +4809,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4627
4809
|
status: getExpectedRedirectStatus(stub),
|
|
4628
4810
|
headers: head.headers
|
|
4629
4811
|
}));
|
|
4812
|
+
sink[ABANDON_RENDER]("redirect", true);
|
|
4630
4813
|
return;
|
|
4631
4814
|
}
|
|
4632
4815
|
if (!head.headers.has("content-type")) {
|
|
@@ -4637,7 +4820,9 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4637
4820
|
controller = c;
|
|
4638
4821
|
},
|
|
4639
4822
|
cancel() {
|
|
4823
|
+
if (closed) return;
|
|
4640
4824
|
closed = true;
|
|
4825
|
+
sink[ABANDON_RENDER]("consumer");
|
|
4641
4826
|
}
|
|
4642
4827
|
}), {
|
|
4643
4828
|
status: head.status,
|
|
@@ -4648,6 +4833,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4648
4833
|
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
4649
4834
|
},
|
|
4650
4835
|
end() {
|
|
4836
|
+
if (!flushed) sink.write("");
|
|
4651
4837
|
if (closed || !controller) return;
|
|
4652
4838
|
const location = stub && stub.headers.get("Location");
|
|
4653
4839
|
if (location && isHttpNavigationTarget(location)) {
|
|
@@ -4658,8 +4844,23 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4658
4844
|
try {
|
|
4659
4845
|
controller.close();
|
|
4660
4846
|
} catch {}
|
|
4661
|
-
}
|
|
4662
|
-
|
|
4847
|
+
},
|
|
4848
|
+
[SHELL_ABANDONED]() {
|
|
4849
|
+
if (flushed) return;
|
|
4850
|
+
flushed = closed = true;
|
|
4851
|
+
if (stub) commitResponseStub(stub, {
|
|
4852
|
+
event
|
|
4853
|
+
});
|
|
4854
|
+
const head = deriveHead(stub, responseInit);
|
|
4855
|
+
const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
|
|
4856
|
+
resolve(new Response(null, {
|
|
4857
|
+
status,
|
|
4858
|
+
headers: head.headers
|
|
4859
|
+
}));
|
|
4860
|
+
},
|
|
4861
|
+
[ABANDON_RENDER]() {}
|
|
4862
|
+
};
|
|
4863
|
+
result.pipe(sink);
|
|
4663
4864
|
});
|
|
4664
4865
|
}
|
|
4665
4866
|
function composeMiddleware(middlewares) {
|
|
@@ -4684,6 +4885,9 @@ function claimElement(node) {
|
|
|
4684
4885
|
function claimElementTree(root) {
|
|
4685
4886
|
return root;
|
|
4686
4887
|
}
|
|
4888
|
+
function dispatchAsInteraction(_e, fn) {
|
|
4889
|
+
return fn();
|
|
4890
|
+
}
|
|
4687
4891
|
function notSup() {
|
|
4688
4892
|
throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
|
|
4689
4893
|
}
|
|
@@ -4692,81 +4896,9 @@ setContainerTraceResolver(getProjectionTrace);
|
|
|
4692
4896
|
setAsyncIterableSharer(shareAsyncIterable);
|
|
4693
4897
|
const isServer = true;
|
|
4694
4898
|
const isDev = true;
|
|
4899
|
+
const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
|
|
4695
4900
|
function dynamic(source, options) {
|
|
4696
|
-
|
|
4697
|
-
const component = untrack(source);
|
|
4698
|
-
if (component && typeof component.then === "function") throw new Error("dynamic(): a static source must resolve synchronously, not to a promise");
|
|
4699
|
-
if (typeof component === "function") return props => component(props);
|
|
4700
|
-
if (typeof component === "string") return props => ssrElement(component, props, undefined, true);
|
|
4701
|
-
return () => undefined;
|
|
4702
|
-
}
|
|
4703
|
-
const cached = createMemo(() => {
|
|
4704
|
-
const next = source();
|
|
4705
|
-
if (!next || typeof next.then !== "function") return next;
|
|
4706
|
-
return {
|
|
4707
|
-
[FLIGHT]: next
|
|
4708
|
-
};
|
|
4709
|
-
});
|
|
4710
|
-
const deferStream = !!options?.deferStream;
|
|
4711
|
-
return props => {
|
|
4712
|
-
const ctx = sharedConfig.context;
|
|
4713
|
-
let gated = !deferStream || !ctx?.async;
|
|
4714
|
-
const value = createMemo(() => {
|
|
4715
|
-
let c;
|
|
4716
|
-
try {
|
|
4717
|
-
c = cached();
|
|
4718
|
-
} catch (err) {
|
|
4719
|
-
if (!gated && err instanceof NotReadyError && !err.source?.$clientHole) {
|
|
4720
|
-
gated = true;
|
|
4721
|
-
ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
|
|
4722
|
-
}
|
|
4723
|
-
throw err;
|
|
4724
|
-
}
|
|
4725
|
-
if (!c || !c[FLIGHT]) return c;
|
|
4726
|
-
const next = c[FLIGHT];
|
|
4727
|
-
return {
|
|
4728
|
-
then: (onFulfilled, onRejected) => next.then(resolved => {
|
|
4729
|
-
let landed;
|
|
4730
|
-
try {
|
|
4731
|
-
landed = classifyLanding(resolved);
|
|
4732
|
-
} catch (err) {
|
|
4733
|
-
if (onRejected) return onRejected(err);
|
|
4734
|
-
throw err;
|
|
4735
|
-
}
|
|
4736
|
-
return onFulfilled ? onFulfilled(landed) : landed;
|
|
4737
|
-
}, onRejected)
|
|
4738
|
-
};
|
|
4739
|
-
}, {
|
|
4740
|
-
deferStream
|
|
4741
|
-
});
|
|
4742
|
-
return createMemo(() => {
|
|
4743
|
-
const c = value();
|
|
4744
|
-
if (c) {
|
|
4745
|
-
if (typeof c === "function") return c(props);
|
|
4746
|
-
if (typeof c === "string") {
|
|
4747
|
-
return ssrElement(c, props, undefined, true);
|
|
4748
|
-
}
|
|
4749
|
-
}
|
|
4750
|
-
}, {
|
|
4751
|
-
sync: true
|
|
4752
|
-
});
|
|
4753
|
-
};
|
|
4754
|
-
}
|
|
4755
|
-
const FLIGHT = Symbol("solid.dynamic-flight");
|
|
4756
|
-
const SERVER_COMPONENT = Symbol.for("solid.server-component");
|
|
4757
|
-
function classifyLanding(resolved) {
|
|
4758
|
-
if (typeof resolved !== "function" || SERVER_COMPONENT in resolved) return resolved;
|
|
4759
|
-
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)." ;
|
|
4760
|
-
recordFinding({
|
|
4761
|
-
code: "DYNAMIC_ASYNC_COMPONENT",
|
|
4762
|
-
kind: "ssr",
|
|
4763
|
-
severity: "error",
|
|
4764
|
-
message,
|
|
4765
|
-
data: {
|
|
4766
|
-
component: resolved.name || undefined
|
|
4767
|
-
}
|
|
4768
|
-
}, null);
|
|
4769
|
-
throw new Error(message);
|
|
4901
|
+
return dynamicCore(source, options, ssrTag);
|
|
4770
4902
|
}
|
|
4771
4903
|
function Dynamic(props) {
|
|
4772
4904
|
const Comp = dynamic(() => props.component);
|
|
@@ -4896,4 +5028,4 @@ function httpHeader(name, value, options) {
|
|
|
4896
5028
|
}
|
|
4897
5029
|
}
|
|
4898
5030
|
|
|
4899
|
-
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, 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, 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, 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, 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 };
|