@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.
- package/dist/server.dev.js +128 -123
- package/dist/server.js +127 -113
- package/dist/server.observe.js +127 -122
- package/dist/web.dev.js +150 -167
- package/dist/web.js +150 -160
- package/dist/web.observe.js +150 -160
- package/frames/dist/client.dev.js +91 -59
- package/frames/dist/client.js +89 -52
- package/frames/dist/client.observe.js +89 -52
- package/frames/dist/server.dev.js +67 -30
- package/frames/dist/server.js +68 -31
- package/frames/dist/server.observe.js +68 -31
- package/frames/dist/trace.js +4 -1
- package/package.json +4 -4
- package/serialization/dist/decode.js +2 -2
- package/serialization/dist/serialization.js +2 -2
- package/server-functions/dist/client.dev.js +2 -1
- package/server-functions/dist/client.js +2 -1
- package/server-functions/dist/client.observe.js +2 -1
- package/server-functions/dist/server.dev.js +91 -17
- package/server-functions/dist/server.js +91 -17
- package/server-functions/dist/server.observe.js +91 -17
- package/types/client.d.ts +100 -8
- package/types/constants.d.ts +2 -1
- package/types/frames/server.d.ts +1 -1
- package/types/head.d.ts +1 -0
- package/types/index.d.ts +56 -49
- package/types/index.server.d.ts +3 -27
- package/types/jsx.d.ts +3 -12
- package/types/response.d.ts +26 -4
- package/types/server-functions/client.d.ts +4 -0
- package/types/server-mock.d.ts +9 -2
- package/types/server.d.ts +85 -9
package/dist/web.dev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, enableHydration, $PROXY, untrack, runWithOwner, resetErrorHalt, enforceLoadingBoundary, createRoot, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, createEffect
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
-
import { sharedConfig,
|
|
1
|
+
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, enableHydration, $PROXY, untrack, runWithOwner, resetErrorHalt, enforceLoadingBoundary, createRoot, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, createEffect } 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, enableServerComponentHydration, resolvedTable, viewOf, OmitView, hasStaticKeys, SOURCE_MEMO, sourceHas, SOURCE_OMIT, sourceGet, sourceKeys, SOURCE_PROXY, SOURCE_PLAIN, dynamicCore } from 'solid-js/internal';
|
|
4
4
|
|
|
5
5
|
const DOMWithState = {
|
|
6
6
|
INPUT: {
|
|
@@ -293,6 +293,10 @@ function qualifierValue(name, value) {
|
|
|
293
293
|
function asciiLowerCase(value) {
|
|
294
294
|
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
295
295
|
}
|
|
296
|
+
const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
|
|
297
|
+
function headBodyText(tag, props, text) {
|
|
298
|
+
return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
|
|
299
|
+
}
|
|
296
300
|
function resourceIdentity(tag, props) {
|
|
297
301
|
const url = String(props.href || props.src || "");
|
|
298
302
|
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
@@ -493,6 +497,13 @@ function takeHydrationValue(key) {
|
|
|
493
497
|
value: v
|
|
494
498
|
};
|
|
495
499
|
}
|
|
500
|
+
function setLinkClaim(_handler) {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
function hasServerLinkState() {
|
|
504
|
+
const registry = globalThis._$HY && globalThis._$HY.r;
|
|
505
|
+
return !!registry && registry.links === 1;
|
|
506
|
+
}
|
|
496
507
|
const getTraceContext = voidFn;
|
|
497
508
|
function render(code, element, init, options = {}) {
|
|
498
509
|
if (!element) {
|
|
@@ -635,17 +646,31 @@ function setProperty(node, name, value) {
|
|
|
635
646
|
tagElement(node);
|
|
636
647
|
if (isHydrating(node)) return;
|
|
637
648
|
const nodeName = node.nodeName;
|
|
638
|
-
if (name === "value" && nodeName === "SELECT")
|
|
649
|
+
if (name === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
|
|
650
|
+
if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[name] = value ?? "";
|
|
651
|
+
} else node[name] = value;
|
|
652
|
+
reclaimAttribute(node, name);
|
|
639
653
|
}
|
|
640
654
|
let claimHandlers = null;
|
|
655
|
+
const claimAttributeSets = [];
|
|
641
656
|
const CLAIM_SEAM = Symbol.for("solid.element-claims");
|
|
642
|
-
function registerElementClaim(handler) {
|
|
657
|
+
function registerElementClaim(handler, options) {
|
|
643
658
|
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
659
|
+
claimAttributeSets.push(options?.attributes || ["href", "action"]);
|
|
644
660
|
return () => {
|
|
645
661
|
const index = claimHandlers.indexOf(handler);
|
|
646
|
-
index > -1
|
|
662
|
+
if (index > -1) {
|
|
663
|
+
claimHandlers.splice(index, 1);
|
|
664
|
+
claimAttributeSets.splice(index, 1);
|
|
665
|
+
}
|
|
647
666
|
};
|
|
648
667
|
}
|
|
668
|
+
function runClaimHandlers(handlers, node) {
|
|
669
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](node);
|
|
670
|
+
}
|
|
671
|
+
function reclaimAttribute(node, name) {
|
|
672
|
+
if (claimHandlers !== null && node._$claimed && claimAttributeSets.some(set => set.includes(name.slice(name.indexOf(":") + 1)))) runClaimHandlers(claimHandlers, node);
|
|
673
|
+
}
|
|
649
674
|
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
650
675
|
function claimElementTree(root) {
|
|
651
676
|
const handlers = globalThis[CLAIM_SEAM];
|
|
@@ -653,17 +678,20 @@ function claimElementTree(root) {
|
|
|
653
678
|
const isElement = root.nodeType === 1;
|
|
654
679
|
if (!isElement && root.nodeType !== 11) return root;
|
|
655
680
|
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
656
|
-
|
|
681
|
+
root._$claimed = true;
|
|
682
|
+
runClaimHandlers(handlers, root);
|
|
657
683
|
}
|
|
658
684
|
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
659
685
|
for (let i = 0; i < found.length; i++) {
|
|
660
|
-
|
|
686
|
+
found[i]._$claimed = true;
|
|
687
|
+
runClaimHandlers(handlers, found[i]);
|
|
661
688
|
}
|
|
662
689
|
return root;
|
|
663
690
|
}
|
|
664
|
-
function claimElement(node) {
|
|
665
|
-
if (claimHandlers !== null) {
|
|
666
|
-
|
|
691
|
+
function claimElement(node, owner) {
|
|
692
|
+
if (claimHandlers !== null && !node._$claimed) {
|
|
693
|
+
node._$claimed = true;
|
|
694
|
+
if (owner === undefined) runClaimHandlers(claimHandlers, node);else runWithOwner(owner, () => runClaimHandlers(claimHandlers, node));
|
|
667
695
|
}
|
|
668
696
|
return node;
|
|
669
697
|
}
|
|
@@ -684,12 +712,13 @@ function setAttribute(node, name, value) {
|
|
|
684
712
|
}
|
|
685
713
|
}
|
|
686
714
|
if (selectMultiple) node._$multiple = true;
|
|
687
|
-
|
|
715
|
+
reclaimAttribute(node, name);
|
|
688
716
|
}
|
|
689
717
|
function setAttributeNS(node, namespace, name, value) {
|
|
690
718
|
tagElement(node);
|
|
691
719
|
if (isHydrating(node)) return;
|
|
692
720
|
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
721
|
+
reclaimAttribute(node, name);
|
|
693
722
|
}
|
|
694
723
|
function className(node, value, prev) {
|
|
695
724
|
tagElement(node);
|
|
@@ -804,7 +833,7 @@ function readShallow(value) {
|
|
|
804
833
|
if (value === null || typeof value !== "object") return value;
|
|
805
834
|
if (Array.isArray(value)) return value.map(readShallow);
|
|
806
835
|
if (value[$PROXY] !== value) return value;
|
|
807
|
-
const keys =
|
|
836
|
+
const keys = Reflect.ownKeys(value);
|
|
808
837
|
const out = {};
|
|
809
838
|
for (let i = 0; i < keys.length; i++) {
|
|
810
839
|
const k = keys[i];
|
|
@@ -828,10 +857,12 @@ function spread(node, props, skipChildren, skip, name) {
|
|
|
828
857
|
}
|
|
829
858
|
}
|
|
830
859
|
const prevProps = {};
|
|
860
|
+
const owner = claimHandlers !== null && (node.localName === "a" || node.localName === "form") ? getOwner() : undefined;
|
|
831
861
|
const apply = newProps => {
|
|
832
862
|
const r = newProps.ref;
|
|
833
863
|
if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
|
|
834
864
|
assign(node, newProps, true, prevProps, true);
|
|
865
|
+
if (owner !== undefined) claimElement(node, owner);
|
|
835
866
|
};
|
|
836
867
|
if (Array.isArray(props)) {
|
|
837
868
|
effect(() => collectSources({}, props, undefined, skip), apply);
|
|
@@ -1408,7 +1439,7 @@ function createHeadElement(tag, props) {
|
|
|
1408
1439
|
if (v == null || v === false) continue;
|
|
1409
1440
|
el.setAttribute(name, v === true ? "" : String(v));
|
|
1410
1441
|
}
|
|
1411
|
-
if (props.children != null) el.textContent = String(props.children);
|
|
1442
|
+
if (props.children != null) el.textContent = headBodyText(tag, props, String(props.children));
|
|
1412
1443
|
return el;
|
|
1413
1444
|
}
|
|
1414
1445
|
function renderHeadElement(t, identity, existing) {
|
|
@@ -1431,7 +1462,7 @@ function headElementMatches(el, t) {
|
|
|
1431
1462
|
} else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
|
|
1432
1463
|
}
|
|
1433
1464
|
const children = t.props.children;
|
|
1434
|
-
return (children == null ? "" : String(children)) === el.textContent;
|
|
1465
|
+
return (children == null ? "" : headBodyText(t.tag, t.props, String(children))) === el.textContent;
|
|
1435
1466
|
}
|
|
1436
1467
|
function mountHeadResource(tag, props) {
|
|
1437
1468
|
const identity = resourceIdentity(tag, props);
|
|
@@ -1548,7 +1579,22 @@ function loadModuleAssets(mapping) {
|
|
|
1548
1579
|
function hydrate(code, element, options = {}) {
|
|
1549
1580
|
enableHydration();
|
|
1550
1581
|
installHydrationRuntime();
|
|
1551
|
-
|
|
1582
|
+
const hy = globalThis._$HY;
|
|
1583
|
+
const id = options.renderId || "";
|
|
1584
|
+
if (hy.s && !hy.s[id] && !hy.s[""] && !hy.done && document.readyState === "loading") {
|
|
1585
|
+
let started, disposer;
|
|
1586
|
+
const start = () => started || (started = true, disposer = hydrate(code, element, options));
|
|
1587
|
+
(hy.sp || (hy.sp = [])).push([id, start]);
|
|
1588
|
+
hy.sw = key => hy.sp.forEach(([k, f]) => (!key || k === key) && queueMicrotask(f));
|
|
1589
|
+
document.addEventListener("DOMContentLoaded", start, {
|
|
1590
|
+
once: true
|
|
1591
|
+
});
|
|
1592
|
+
return () => {
|
|
1593
|
+
started = true;
|
|
1594
|
+
disposer && disposer();
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
if (hy.done) return render(code, element, [...element.childNodes], options);
|
|
1552
1598
|
const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
|
|
1553
1599
|
if (head && element.contains(head)) {
|
|
1554
1600
|
let n = head.firstChild;
|
|
@@ -1784,13 +1830,32 @@ function isHydrating(node) {
|
|
|
1784
1830
|
if (!sharedConfig.hydrating) return false;
|
|
1785
1831
|
if (sharedConfig.isClaiming && !sharedConfig.isClaiming()) return false;
|
|
1786
1832
|
if (!node || node.isConnected) return true;
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1833
|
+
return serverComponentClaims !== null && serverComponentClaims.claimed(node);
|
|
1834
|
+
}
|
|
1835
|
+
let serverComponentClaims = null;
|
|
1836
|
+
function installServerComponentHydration() {
|
|
1837
|
+
enableServerComponentHydration();
|
|
1838
|
+
if (serverComponentClaims !== null) return;
|
|
1839
|
+
serverComponentClaims = {
|
|
1840
|
+
claimed(node) {
|
|
1841
|
+
const roots = sharedConfig.claimRoots;
|
|
1842
|
+
if (roots) {
|
|
1843
|
+
for (let i = 0; i < roots.length; i++) {
|
|
1844
|
+
if (roots[i].contains(node)) return true;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
return false;
|
|
1848
|
+
},
|
|
1849
|
+
inFrame(element) {
|
|
1850
|
+
const frames = element.querySelectorAll("[data-fid]");
|
|
1851
|
+
const frameCount = frames.length;
|
|
1852
|
+
if (frameCount === 0) return undefined;
|
|
1853
|
+
return node => {
|
|
1854
|
+
for (let j = 0; j < frameCount; j++) if (frames[j].contains(node)) return true;
|
|
1855
|
+
return false;
|
|
1856
|
+
};
|
|
1791
1857
|
}
|
|
1792
|
-
}
|
|
1793
|
-
return false;
|
|
1858
|
+
};
|
|
1794
1859
|
}
|
|
1795
1860
|
function classListToObject(classList) {
|
|
1796
1861
|
if (Array.isArray(classList)) {
|
|
@@ -1842,8 +1907,10 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
1842
1907
|
}
|
|
1843
1908
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
1844
1909
|
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
1845
|
-
if (prop === "value" && nodeName === "SELECT")
|
|
1846
|
-
|
|
1910
|
+
if (prop === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
|
|
1911
|
+
if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[prop] = value ?? "";
|
|
1912
|
+
} else node[prop] = value;
|
|
1913
|
+
reclaimAttribute(node, prop);
|
|
1847
1914
|
} else {
|
|
1848
1915
|
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
1849
1916
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
@@ -1991,8 +2058,35 @@ function insertExpression(parent, value, current, marker) {
|
|
|
1991
2058
|
value
|
|
1992
2059
|
}
|
|
1993
2060
|
});
|
|
2061
|
+
selectInsert && selectInsert(parent);
|
|
1994
2062
|
return value;
|
|
1995
2063
|
}
|
|
2064
|
+
let selectInsert;
|
|
2065
|
+
function selectChange(e) {
|
|
2066
|
+
(e = e.currentTarget || e)._$v = null;
|
|
2067
|
+
e.removeEventListener("change", selectChange, true);
|
|
2068
|
+
}
|
|
2069
|
+
function writeSelectValue(node, value) {
|
|
2070
|
+
const had = node._$v && node._$v.map,
|
|
2071
|
+
has = value != null && value.map;
|
|
2072
|
+
if (has) had || node.addEventListener("change", selectChange, true);else had && node.removeEventListener("change", selectChange, true);
|
|
2073
|
+
if (value == null) {
|
|
2074
|
+
node._$v = null;
|
|
2075
|
+
return queueMicrotask(() => node.value = value) || (node.value = value);
|
|
2076
|
+
}
|
|
2077
|
+
node._$v = value;
|
|
2078
|
+
(selectInsert ||= p => {
|
|
2079
|
+
p && p._$v == null && (p = p.parentNode);
|
|
2080
|
+
const v = p && p._$v;
|
|
2081
|
+
if (v == null) return;
|
|
2082
|
+
if (v.map) {
|
|
2083
|
+
const o = [...p.options];
|
|
2084
|
+
for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
|
|
2085
|
+
v.every(x => o.some(el => el.value == x)) && selectChange(p);
|
|
2086
|
+
} else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
|
|
2087
|
+
})(node);
|
|
2088
|
+
queueMicrotask(() => selectInsert(node));
|
|
2089
|
+
}
|
|
1996
2090
|
function normalize(value, current, multi, doNotUnwrap) {
|
|
1997
2091
|
value = flatten(value, {
|
|
1998
2092
|
skipNonRendered: true,
|
|
@@ -2071,22 +2165,12 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
2071
2165
|
}
|
|
2072
2166
|
function gatherHydratable(element, root) {
|
|
2073
2167
|
const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
|
|
2074
|
-
const
|
|
2075
|
-
const frameCount = frames ? frames.length : 0;
|
|
2168
|
+
const inFrame = root || serverComponentClaims === null ? undefined : serverComponentClaims.inFrame(element);
|
|
2076
2169
|
const registry = sharedConfig.registry;
|
|
2077
2170
|
for (let i = 0; i < templates.length; i++) {
|
|
2078
2171
|
const node = templates[i];
|
|
2172
|
+
if (inFrame !== undefined && inFrame(node)) continue;
|
|
2079
2173
|
const key = node.getAttribute("_hk");
|
|
2080
|
-
if (frameCount !== 0) {
|
|
2081
|
-
let inFrame = false;
|
|
2082
|
-
for (let j = 0; j < frameCount; j++) {
|
|
2083
|
-
if (frames[j].contains(node)) {
|
|
2084
|
-
inFrame = true;
|
|
2085
|
-
break;
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
if (inFrame) continue;
|
|
2089
|
-
}
|
|
2090
2174
|
if (!registry.has(key)) registry.set(key, node);
|
|
2091
2175
|
}
|
|
2092
2176
|
}
|
|
@@ -2128,6 +2212,7 @@ function composeMiddleware(middlewares) {
|
|
|
2128
2212
|
function ssr(template, ...nodes) {}
|
|
2129
2213
|
function ssrElement(name, props, children, needsId, skip, attrs) {}
|
|
2130
2214
|
function ssrElementAttribute(key, value) {}
|
|
2215
|
+
function ssrLinkClaim(attrs) {}
|
|
2131
2216
|
function ssrClassName(value) {}
|
|
2132
2217
|
function ssrStyle(value) {}
|
|
2133
2218
|
function ssrStyleProperty(name, value) {}
|
|
@@ -2139,17 +2224,24 @@ function resolveSSRNode(node, result, top, nested) {}
|
|
|
2139
2224
|
function escape(s, attr) {}
|
|
2140
2225
|
|
|
2141
2226
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
2142
|
-
|
|
2143
|
-
const ResponseEnvelope =
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2227
|
+
let EnvelopeClass;
|
|
2228
|
+
const ResponseEnvelope = function ResponseEnvelope(response, value) {
|
|
2229
|
+
if (!EnvelopeClass) {
|
|
2230
|
+
EnvelopeClass = class extends Response {
|
|
2231
|
+
constructor(response, value) {
|
|
2232
|
+
super(response ? response.body : null, response && {
|
|
2233
|
+
status: response.status,
|
|
2234
|
+
statusText: response.statusText,
|
|
2235
|
+
headers: copyHeaders(response.headers)
|
|
2236
|
+
});
|
|
2237
|
+
this.response = response ? this : undefined;
|
|
2238
|
+
this.value = value;
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
EnvelopeClass.prototype[ENVELOPE] = true;
|
|
2149
2242
|
}
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
})();
|
|
2243
|
+
return new EnvelopeClass(response, value);
|
|
2244
|
+
};
|
|
2153
2245
|
function isResponseEnvelope(value) {
|
|
2154
2246
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
2155
2247
|
}
|
|
@@ -2174,6 +2266,16 @@ function isSafeError(value) {
|
|
|
2174
2266
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
2175
2267
|
const REVALIDATE_ALL = "*";
|
|
2176
2268
|
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
2269
|
+
function copyHeaders(init) {
|
|
2270
|
+
const source = init;
|
|
2271
|
+
if (!source || !source.getSetCookie) return new Headers(init);
|
|
2272
|
+
const headers = new Headers();
|
|
2273
|
+
source.forEach((value, key) => {
|
|
2274
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
2275
|
+
});
|
|
2276
|
+
for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
2277
|
+
return headers;
|
|
2278
|
+
}
|
|
2177
2279
|
function initWithRevalidate(init = {}) {
|
|
2178
2280
|
const resolved = typeof init === "number" ? {
|
|
2179
2281
|
status: init
|
|
@@ -2182,18 +2284,7 @@ function initWithRevalidate(init = {}) {
|
|
|
2182
2284
|
revalidate,
|
|
2183
2285
|
...responseInit
|
|
2184
2286
|
} = resolved;
|
|
2185
|
-
|
|
2186
|
-
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
2187
|
-
headers = new Headers();
|
|
2188
|
-
responseInit.headers.forEach((value, key) => {
|
|
2189
|
-
if (key !== "set-cookie") headers.append(key, value);
|
|
2190
|
-
});
|
|
2191
|
-
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
2192
|
-
headers.append("Set-Cookie", cookie);
|
|
2193
|
-
}
|
|
2194
|
-
} else {
|
|
2195
|
-
headers = new Headers(responseInit.headers);
|
|
2196
|
-
}
|
|
2287
|
+
const headers = copyHeaders(responseInit.headers);
|
|
2197
2288
|
if (revalidate !== undefined) {
|
|
2198
2289
|
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
2199
2290
|
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
@@ -2317,117 +2408,9 @@ function portalImpl(props) {
|
|
|
2317
2408
|
});
|
|
2318
2409
|
return treeMarker;
|
|
2319
2410
|
}
|
|
2320
|
-
const COMPONENT_BINDING = Symbol.for("solid.component-binding");
|
|
2321
|
-
const FLIGHT = Symbol("solid.dynamic-flight");
|
|
2322
|
-
function bindingOf(value) {
|
|
2323
|
-
return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
|
|
2324
|
-
}
|
|
2325
2411
|
function dynamic(source, options) {
|
|
2326
2412
|
return dynamicCore(source, options, staticElement);
|
|
2327
2413
|
}
|
|
2328
|
-
function dynamicComponent(source, options) {
|
|
2329
|
-
return dynamicCore(source, options);
|
|
2330
|
-
}
|
|
2331
|
-
function dynamicCore(source, options, tagArm) {
|
|
2332
|
-
if (options?.static) return staticDynamic(untrack(source), tagArm);
|
|
2333
|
-
const sites = new Set();
|
|
2334
|
-
let deliveredAddress;
|
|
2335
|
-
const resolveBinding = (next, prev) => {
|
|
2336
|
-
const binding = bindingOf(next);
|
|
2337
|
-
if (!binding) return next;
|
|
2338
|
-
deliveredAddress = binding.address;
|
|
2339
|
-
const prevBinding = bindingOf(prev);
|
|
2340
|
-
if (prevBinding && prevBinding.component === binding.component) {
|
|
2341
|
-
for (const deliver of sites) deliver(binding.address);
|
|
2342
|
-
return prev;
|
|
2343
|
-
}
|
|
2344
|
-
return next;
|
|
2345
|
-
};
|
|
2346
|
-
const sameInstance = (prev, next) => {
|
|
2347
|
-
if (prev === next) return true;
|
|
2348
|
-
const held = bindingOf(prev);
|
|
2349
|
-
const incoming = bindingOf(next);
|
|
2350
|
-
if (!held || !incoming || held.component !== incoming.component) return false;
|
|
2351
|
-
if (held.address === incoming.address) return true;
|
|
2352
|
-
if (deliveredAddress === undefined) return false;
|
|
2353
|
-
if (incoming.address !== deliveredAddress) {
|
|
2354
|
-
deliveredAddress = incoming.address;
|
|
2355
|
-
for (const deliver of sites) deliver(incoming.address);
|
|
2356
|
-
}
|
|
2357
|
-
return true;
|
|
2358
|
-
};
|
|
2359
|
-
const cached = createMemo(prev => {
|
|
2360
|
-
const next = source();
|
|
2361
|
-
if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
|
|
2362
|
-
return {
|
|
2363
|
-
[FLIGHT]: next
|
|
2364
|
-
};
|
|
2365
|
-
}, {
|
|
2366
|
-
lazy: true,
|
|
2367
|
-
equals: sameInstance
|
|
2368
|
-
});
|
|
2369
|
-
return props => {
|
|
2370
|
-
if (sharedConfig.hydrating) {
|
|
2371
|
-
try {
|
|
2372
|
-
untrack(cached);
|
|
2373
|
-
} catch {}
|
|
2374
|
-
}
|
|
2375
|
-
let latest = 0;
|
|
2376
|
-
const value = createMemo(prev => {
|
|
2377
|
-
const c = cached();
|
|
2378
|
-
if (!c || !c[FLIGHT]) return resolveBinding(c, prev);
|
|
2379
|
-
const next = c[FLIGHT];
|
|
2380
|
-
const token = ++latest;
|
|
2381
|
-
return {
|
|
2382
|
-
then: (onFulfilled, onRejected) => next.then(resolved => {
|
|
2383
|
-
const landed = token === latest ? resolveBinding(resolved, prev) : resolved;
|
|
2384
|
-
return onFulfilled ? onFulfilled(landed) : landed;
|
|
2385
|
-
}, onRejected)
|
|
2386
|
-
};
|
|
2387
|
-
}, {
|
|
2388
|
-
equals: sameInstance
|
|
2389
|
-
});
|
|
2390
|
-
return createMemo(() => {
|
|
2391
|
-
const component = value();
|
|
2392
|
-
switch (typeof component) {
|
|
2393
|
-
case "function":
|
|
2394
|
-
{
|
|
2395
|
-
Object.assign(component, {
|
|
2396
|
-
[$DEVCOMP]: true
|
|
2397
|
-
});
|
|
2398
|
-
const binding = bindingOf(component);
|
|
2399
|
-
if (binding) {
|
|
2400
|
-
const [address, setAddress] = createSignal(deliveredAddress ??= binding.address, {
|
|
2401
|
-
ownedWrite: true
|
|
2402
|
-
});
|
|
2403
|
-
sites.add(setAddress);
|
|
2404
|
-
onCleanup(() => sites.delete(setAddress));
|
|
2405
|
-
return untrack(() => binding.component(props, address));
|
|
2406
|
-
}
|
|
2407
|
-
return untrack(() => component(props));
|
|
2408
|
-
}
|
|
2409
|
-
case "string":
|
|
2410
|
-
return tagArm ? tagArm(component, props) : undefined;
|
|
2411
|
-
}
|
|
2412
|
-
});
|
|
2413
|
-
};
|
|
2414
|
-
}
|
|
2415
|
-
function staticDynamic(component, tagArm) {
|
|
2416
|
-
if (component && typeof component.then === "function") throw new Error("dynamic(): a static source must resolve synchronously, not to a promise");
|
|
2417
|
-
if (typeof component === "function") {
|
|
2418
|
-
Object.assign(component, {
|
|
2419
|
-
[$DEVCOMP]: true
|
|
2420
|
-
});
|
|
2421
|
-
const binding = bindingOf(component);
|
|
2422
|
-
if (binding) {
|
|
2423
|
-
const address = () => binding.address;
|
|
2424
|
-
return props => untrack(() => binding.component(props, address));
|
|
2425
|
-
}
|
|
2426
|
-
return props => untrack(() => component(props));
|
|
2427
|
-
}
|
|
2428
|
-
if (typeof component === "string" && tagArm) return props => tagArm(component, props);
|
|
2429
|
-
return () => undefined;
|
|
2430
|
-
}
|
|
2431
2414
|
function staticElement(tag, props) {
|
|
2432
2415
|
const hydrating = sharedConfig.hydrating;
|
|
2433
2416
|
const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
|
|
@@ -2474,4 +2457,4 @@ _moduleUrl) {
|
|
|
2474
2457
|
function httpStatus(_code, _text) {}
|
|
2475
2458
|
function httpHeader(_name, _value, _options) {}
|
|
2476
2459
|
|
|
2477
|
-
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic,
|
|
2460
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installServerComponentHydration, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setLinkClaim, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
|