@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.observe.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, OBSERVE, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, 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, createMemo, OBSERVE, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, 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: {
|
|
@@ -232,6 +232,10 @@ function qualifierValue(name, value) {
|
|
|
232
232
|
function asciiLowerCase(value) {
|
|
233
233
|
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
234
234
|
}
|
|
235
|
+
const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
|
|
236
|
+
function headBodyText(tag, props, text) {
|
|
237
|
+
return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
|
|
238
|
+
}
|
|
235
239
|
function resourceIdentity(tag, props) {
|
|
236
240
|
const url = String(props.href || props.src || "");
|
|
237
241
|
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
@@ -402,6 +406,13 @@ function takeHydrationValue(key) {
|
|
|
402
406
|
value: v
|
|
403
407
|
};
|
|
404
408
|
}
|
|
409
|
+
function setLinkClaim(_handler) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
function hasServerLinkState() {
|
|
413
|
+
const registry = globalThis._$HY && globalThis._$HY.r;
|
|
414
|
+
return !!registry && registry.links === 1;
|
|
415
|
+
}
|
|
405
416
|
const getTraceContext = voidFn;
|
|
406
417
|
function render(code, element, init, options = {}) {
|
|
407
418
|
let disposer;
|
|
@@ -534,17 +545,31 @@ function findOwner(target, state) {
|
|
|
534
545
|
function setProperty(node, name, value) {
|
|
535
546
|
if (isHydrating(node)) return;
|
|
536
547
|
const nodeName = node.nodeName;
|
|
537
|
-
if (name === "value" && nodeName === "SELECT")
|
|
548
|
+
if (name === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
|
|
549
|
+
if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[name] = value ?? "";
|
|
550
|
+
} else node[name] = value;
|
|
551
|
+
reclaimAttribute(node, name);
|
|
538
552
|
}
|
|
539
553
|
let claimHandlers = null;
|
|
554
|
+
const claimAttributeSets = [];
|
|
540
555
|
const CLAIM_SEAM = Symbol.for("solid.element-claims");
|
|
541
|
-
function registerElementClaim(handler) {
|
|
556
|
+
function registerElementClaim(handler, options) {
|
|
542
557
|
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
558
|
+
claimAttributeSets.push(options?.attributes || ["href", "action"]);
|
|
543
559
|
return () => {
|
|
544
560
|
const index = claimHandlers.indexOf(handler);
|
|
545
|
-
index > -1
|
|
561
|
+
if (index > -1) {
|
|
562
|
+
claimHandlers.splice(index, 1);
|
|
563
|
+
claimAttributeSets.splice(index, 1);
|
|
564
|
+
}
|
|
546
565
|
};
|
|
547
566
|
}
|
|
567
|
+
function runClaimHandlers(handlers, node) {
|
|
568
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](node);
|
|
569
|
+
}
|
|
570
|
+
function reclaimAttribute(node, name) {
|
|
571
|
+
if (claimHandlers !== null && node._$claimed && claimAttributeSets.some(set => set.includes(name.slice(name.indexOf(":") + 1)))) runClaimHandlers(claimHandlers, node);
|
|
572
|
+
}
|
|
548
573
|
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
549
574
|
function claimElementTree(root) {
|
|
550
575
|
const handlers = globalThis[CLAIM_SEAM];
|
|
@@ -552,17 +577,20 @@ function claimElementTree(root) {
|
|
|
552
577
|
const isElement = root.nodeType === 1;
|
|
553
578
|
if (!isElement && root.nodeType !== 11) return root;
|
|
554
579
|
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
555
|
-
|
|
580
|
+
root._$claimed = true;
|
|
581
|
+
runClaimHandlers(handlers, root);
|
|
556
582
|
}
|
|
557
583
|
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
558
584
|
for (let i = 0; i < found.length; i++) {
|
|
559
|
-
|
|
585
|
+
found[i]._$claimed = true;
|
|
586
|
+
runClaimHandlers(handlers, found[i]);
|
|
560
587
|
}
|
|
561
588
|
return root;
|
|
562
589
|
}
|
|
563
|
-
function claimElement(node) {
|
|
564
|
-
if (claimHandlers !== null) {
|
|
565
|
-
|
|
590
|
+
function claimElement(node, owner) {
|
|
591
|
+
if (claimHandlers !== null && !node._$claimed) {
|
|
592
|
+
node._$claimed = true;
|
|
593
|
+
if (owner === undefined) runClaimHandlers(claimHandlers, node);else runWithOwner(owner, () => runClaimHandlers(claimHandlers, node));
|
|
566
594
|
}
|
|
567
595
|
return node;
|
|
568
596
|
}
|
|
@@ -579,11 +607,12 @@ function setAttribute(node, name, value) {
|
|
|
579
607
|
}
|
|
580
608
|
}
|
|
581
609
|
if (selectMultiple) node._$multiple = true;
|
|
582
|
-
|
|
610
|
+
reclaimAttribute(node, name);
|
|
583
611
|
}
|
|
584
612
|
function setAttributeNS(node, namespace, name, value) {
|
|
585
613
|
if (isHydrating(node)) return;
|
|
586
614
|
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
615
|
+
reclaimAttribute(node, name);
|
|
587
616
|
}
|
|
588
617
|
function className(node, value, prev) {
|
|
589
618
|
if (typeof value === "number") value = "" + value;
|
|
@@ -696,7 +725,7 @@ function readShallow(value) {
|
|
|
696
725
|
if (value === null || typeof value !== "object") return value;
|
|
697
726
|
if (Array.isArray(value)) return value.map(readShallow);
|
|
698
727
|
if (value[$PROXY] !== value) return value;
|
|
699
|
-
const keys =
|
|
728
|
+
const keys = Reflect.ownKeys(value);
|
|
700
729
|
const out = {};
|
|
701
730
|
for (let i = 0; i < keys.length; i++) {
|
|
702
731
|
const k = keys[i];
|
|
@@ -719,10 +748,12 @@ function spread(node, props, skipChildren, skip, name) {
|
|
|
719
748
|
}
|
|
720
749
|
}
|
|
721
750
|
const prevProps = {};
|
|
751
|
+
const owner = claimHandlers !== null && (node.localName === "a" || node.localName === "form") ? getOwner() : undefined;
|
|
722
752
|
const apply = newProps => {
|
|
723
753
|
const r = newProps.ref;
|
|
724
754
|
if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
|
|
725
755
|
assign(node, newProps, true, prevProps, true);
|
|
756
|
+
if (owner !== undefined) claimElement(node, owner);
|
|
726
757
|
};
|
|
727
758
|
if (Array.isArray(props)) {
|
|
728
759
|
effect(() => collectSources({}, props, undefined, skip), apply);
|
|
@@ -1264,7 +1295,7 @@ function createHeadElement(tag, props) {
|
|
|
1264
1295
|
if (v == null || v === false) continue;
|
|
1265
1296
|
el.setAttribute(name, v === true ? "" : String(v));
|
|
1266
1297
|
}
|
|
1267
|
-
if (props.children != null) el.textContent = String(props.children);
|
|
1298
|
+
if (props.children != null) el.textContent = headBodyText(tag, props, String(props.children));
|
|
1268
1299
|
return el;
|
|
1269
1300
|
}
|
|
1270
1301
|
function renderHeadElement(t, identity, existing) {
|
|
@@ -1287,7 +1318,7 @@ function headElementMatches(el, t) {
|
|
|
1287
1318
|
} else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
|
|
1288
1319
|
}
|
|
1289
1320
|
const children = t.props.children;
|
|
1290
|
-
return (children == null ? "" : String(children)) === el.textContent;
|
|
1321
|
+
return (children == null ? "" : headBodyText(t.tag, t.props, String(children))) === el.textContent;
|
|
1291
1322
|
}
|
|
1292
1323
|
function mountHeadResource(tag, props) {
|
|
1293
1324
|
const identity = resourceIdentity(tag, props);
|
|
@@ -1403,7 +1434,22 @@ function loadModuleAssets(mapping) {
|
|
|
1403
1434
|
function hydrate(code, element, options = {}) {
|
|
1404
1435
|
enableHydration();
|
|
1405
1436
|
installHydrationRuntime();
|
|
1406
|
-
|
|
1437
|
+
const hy = globalThis._$HY;
|
|
1438
|
+
const id = options.renderId || "";
|
|
1439
|
+
if (hy.s && !hy.s[id] && !hy.s[""] && !hy.done && document.readyState === "loading") {
|
|
1440
|
+
let started, disposer;
|
|
1441
|
+
const start = () => started || (started = true, disposer = hydrate(code, element, options));
|
|
1442
|
+
(hy.sp || (hy.sp = [])).push([id, start]);
|
|
1443
|
+
hy.sw = key => hy.sp.forEach(([k, f]) => (!key || k === key) && queueMicrotask(f));
|
|
1444
|
+
document.addEventListener("DOMContentLoaded", start, {
|
|
1445
|
+
once: true
|
|
1446
|
+
});
|
|
1447
|
+
return () => {
|
|
1448
|
+
started = true;
|
|
1449
|
+
disposer && disposer();
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
if (hy.done) return render(code, element, [...element.childNodes], options);
|
|
1407
1453
|
const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
|
|
1408
1454
|
if (head && element.contains(head)) {
|
|
1409
1455
|
let n = head.firstChild;
|
|
@@ -1582,13 +1628,32 @@ function isHydrating(node) {
|
|
|
1582
1628
|
if (!sharedConfig.hydrating) return false;
|
|
1583
1629
|
if (sharedConfig.isClaiming && !sharedConfig.isClaiming()) return false;
|
|
1584
1630
|
if (!node || node.isConnected) return true;
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1631
|
+
return serverComponentClaims !== null && serverComponentClaims.claimed(node);
|
|
1632
|
+
}
|
|
1633
|
+
let serverComponentClaims = null;
|
|
1634
|
+
function installServerComponentHydration() {
|
|
1635
|
+
enableServerComponentHydration();
|
|
1636
|
+
if (serverComponentClaims !== null) return;
|
|
1637
|
+
serverComponentClaims = {
|
|
1638
|
+
claimed(node) {
|
|
1639
|
+
const roots = sharedConfig.claimRoots;
|
|
1640
|
+
if (roots) {
|
|
1641
|
+
for (let i = 0; i < roots.length; i++) {
|
|
1642
|
+
if (roots[i].contains(node)) return true;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
return false;
|
|
1646
|
+
},
|
|
1647
|
+
inFrame(element) {
|
|
1648
|
+
const frames = element.querySelectorAll("[data-fid]");
|
|
1649
|
+
const frameCount = frames.length;
|
|
1650
|
+
if (frameCount === 0) return undefined;
|
|
1651
|
+
return node => {
|
|
1652
|
+
for (let j = 0; j < frameCount; j++) if (frames[j].contains(node)) return true;
|
|
1653
|
+
return false;
|
|
1654
|
+
};
|
|
1589
1655
|
}
|
|
1590
|
-
}
|
|
1591
|
-
return false;
|
|
1656
|
+
};
|
|
1592
1657
|
}
|
|
1593
1658
|
function classListToObject(classList) {
|
|
1594
1659
|
if (Array.isArray(classList)) {
|
|
@@ -1640,8 +1705,10 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
1640
1705
|
}
|
|
1641
1706
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
1642
1707
|
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
1643
|
-
if (prop === "value" && nodeName === "SELECT")
|
|
1644
|
-
|
|
1708
|
+
if (prop === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
|
|
1709
|
+
if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[prop] = value ?? "";
|
|
1710
|
+
} else node[prop] = value;
|
|
1711
|
+
reclaimAttribute(node, prop);
|
|
1645
1712
|
} else {
|
|
1646
1713
|
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
1647
1714
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
@@ -1779,8 +1846,35 @@ function insertExpression(parent, value, current, marker) {
|
|
|
1779
1846
|
appendNodes(parent, value);
|
|
1780
1847
|
}
|
|
1781
1848
|
} else ;
|
|
1849
|
+
selectInsert && selectInsert(parent);
|
|
1782
1850
|
return value;
|
|
1783
1851
|
}
|
|
1852
|
+
let selectInsert;
|
|
1853
|
+
function selectChange(e) {
|
|
1854
|
+
(e = e.currentTarget || e)._$v = null;
|
|
1855
|
+
e.removeEventListener("change", selectChange, true);
|
|
1856
|
+
}
|
|
1857
|
+
function writeSelectValue(node, value) {
|
|
1858
|
+
const had = node._$v && node._$v.map,
|
|
1859
|
+
has = value != null && value.map;
|
|
1860
|
+
if (has) had || node.addEventListener("change", selectChange, true);else had && node.removeEventListener("change", selectChange, true);
|
|
1861
|
+
if (value == null) {
|
|
1862
|
+
node._$v = null;
|
|
1863
|
+
return queueMicrotask(() => node.value = value) || (node.value = value);
|
|
1864
|
+
}
|
|
1865
|
+
node._$v = value;
|
|
1866
|
+
(selectInsert ||= p => {
|
|
1867
|
+
p && p._$v == null && (p = p.parentNode);
|
|
1868
|
+
const v = p && p._$v;
|
|
1869
|
+
if (v == null) return;
|
|
1870
|
+
if (v.map) {
|
|
1871
|
+
const o = [...p.options];
|
|
1872
|
+
for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
|
|
1873
|
+
v.every(x => o.some(el => el.value == x)) && selectChange(p);
|
|
1874
|
+
} else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
|
|
1875
|
+
})(node);
|
|
1876
|
+
queueMicrotask(() => selectInsert(node));
|
|
1877
|
+
}
|
|
1784
1878
|
function normalize(value, current, multi, doNotUnwrap) {
|
|
1785
1879
|
value = flatten(value, {
|
|
1786
1880
|
skipNonRendered: true,
|
|
@@ -1859,22 +1953,12 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
1859
1953
|
}
|
|
1860
1954
|
function gatherHydratable(element, root) {
|
|
1861
1955
|
const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
|
|
1862
|
-
const
|
|
1863
|
-
const frameCount = frames ? frames.length : 0;
|
|
1956
|
+
const inFrame = root || serverComponentClaims === null ? undefined : serverComponentClaims.inFrame(element);
|
|
1864
1957
|
const registry = sharedConfig.registry;
|
|
1865
1958
|
for (let i = 0; i < templates.length; i++) {
|
|
1866
1959
|
const node = templates[i];
|
|
1960
|
+
if (inFrame !== undefined && inFrame(node)) continue;
|
|
1867
1961
|
const key = node.getAttribute("_hk");
|
|
1868
|
-
if (frameCount !== 0) {
|
|
1869
|
-
let inFrame = false;
|
|
1870
|
-
for (let j = 0; j < frameCount; j++) {
|
|
1871
|
-
if (frames[j].contains(node)) {
|
|
1872
|
-
inFrame = true;
|
|
1873
|
-
break;
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
if (inFrame) continue;
|
|
1877
|
-
}
|
|
1878
1962
|
if (!registry.has(key)) registry.set(key, node);
|
|
1879
1963
|
}
|
|
1880
1964
|
}
|
|
@@ -1916,6 +2000,7 @@ function composeMiddleware(middlewares) {
|
|
|
1916
2000
|
function ssr(template, ...nodes) {}
|
|
1917
2001
|
function ssrElement(name, props, children, needsId, skip, attrs) {}
|
|
1918
2002
|
function ssrElementAttribute(key, value) {}
|
|
2003
|
+
function ssrLinkClaim(attrs) {}
|
|
1919
2004
|
function ssrClassName(value) {}
|
|
1920
2005
|
function ssrStyle(value) {}
|
|
1921
2006
|
function ssrStyleProperty(name, value) {}
|
|
@@ -1927,17 +2012,24 @@ function resolveSSRNode(node, result, top, nested) {}
|
|
|
1927
2012
|
function escape(s, attr) {}
|
|
1928
2013
|
|
|
1929
2014
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
1930
|
-
|
|
1931
|
-
const ResponseEnvelope =
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
2015
|
+
let EnvelopeClass;
|
|
2016
|
+
const ResponseEnvelope = function ResponseEnvelope(response, value) {
|
|
2017
|
+
if (!EnvelopeClass) {
|
|
2018
|
+
EnvelopeClass = class extends Response {
|
|
2019
|
+
constructor(response, value) {
|
|
2020
|
+
super(response ? response.body : null, response && {
|
|
2021
|
+
status: response.status,
|
|
2022
|
+
statusText: response.statusText,
|
|
2023
|
+
headers: copyHeaders(response.headers)
|
|
2024
|
+
});
|
|
2025
|
+
this.response = response ? this : undefined;
|
|
2026
|
+
this.value = value;
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
EnvelopeClass.prototype[ENVELOPE] = true;
|
|
1937
2030
|
}
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
})();
|
|
2031
|
+
return new EnvelopeClass(response, value);
|
|
2032
|
+
};
|
|
1941
2033
|
function isResponseEnvelope(value) {
|
|
1942
2034
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1943
2035
|
}
|
|
@@ -1962,6 +2054,16 @@ function isSafeError(value) {
|
|
|
1962
2054
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
1963
2055
|
const REVALIDATE_ALL = "*";
|
|
1964
2056
|
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
2057
|
+
function copyHeaders(init) {
|
|
2058
|
+
const source = init;
|
|
2059
|
+
if (!source || !source.getSetCookie) return new Headers(init);
|
|
2060
|
+
const headers = new Headers();
|
|
2061
|
+
source.forEach((value, key) => {
|
|
2062
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
2063
|
+
});
|
|
2064
|
+
for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
2065
|
+
return headers;
|
|
2066
|
+
}
|
|
1965
2067
|
function initWithRevalidate(init = {}) {
|
|
1966
2068
|
const resolved = typeof init === "number" ? {
|
|
1967
2069
|
status: init
|
|
@@ -1970,18 +2072,7 @@ function initWithRevalidate(init = {}) {
|
|
|
1970
2072
|
revalidate,
|
|
1971
2073
|
...responseInit
|
|
1972
2074
|
} = resolved;
|
|
1973
|
-
|
|
1974
|
-
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
1975
|
-
headers = new Headers();
|
|
1976
|
-
responseInit.headers.forEach((value, key) => {
|
|
1977
|
-
if (key !== "set-cookie") headers.append(key, value);
|
|
1978
|
-
});
|
|
1979
|
-
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
1980
|
-
headers.append("Set-Cookie", cookie);
|
|
1981
|
-
}
|
|
1982
|
-
} else {
|
|
1983
|
-
headers = new Headers(responseInit.headers);
|
|
1984
|
-
}
|
|
2075
|
+
const headers = copyHeaders(responseInit.headers);
|
|
1985
2076
|
if (revalidate !== undefined) {
|
|
1986
2077
|
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
1987
2078
|
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
@@ -2105,110 +2196,9 @@ function portalImpl(props) {
|
|
|
2105
2196
|
});
|
|
2106
2197
|
return treeMarker;
|
|
2107
2198
|
}
|
|
2108
|
-
const COMPONENT_BINDING = Symbol.for("solid.component-binding");
|
|
2109
|
-
const FLIGHT = Symbol("solid.dynamic-flight");
|
|
2110
|
-
function bindingOf(value) {
|
|
2111
|
-
return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
|
|
2112
|
-
}
|
|
2113
2199
|
function dynamic(source, options) {
|
|
2114
2200
|
return dynamicCore(source, options, staticElement);
|
|
2115
2201
|
}
|
|
2116
|
-
function dynamicComponent(source, options) {
|
|
2117
|
-
return dynamicCore(source, options);
|
|
2118
|
-
}
|
|
2119
|
-
function dynamicCore(source, options, tagArm) {
|
|
2120
|
-
if (options?.static) return staticDynamic(untrack(source), tagArm);
|
|
2121
|
-
const sites = new Set();
|
|
2122
|
-
let deliveredAddress;
|
|
2123
|
-
const resolveBinding = (next, prev) => {
|
|
2124
|
-
const binding = bindingOf(next);
|
|
2125
|
-
if (!binding) return next;
|
|
2126
|
-
deliveredAddress = binding.address;
|
|
2127
|
-
const prevBinding = bindingOf(prev);
|
|
2128
|
-
if (prevBinding && prevBinding.component === binding.component) {
|
|
2129
|
-
for (const deliver of sites) deliver(binding.address);
|
|
2130
|
-
return prev;
|
|
2131
|
-
}
|
|
2132
|
-
return next;
|
|
2133
|
-
};
|
|
2134
|
-
const sameInstance = (prev, next) => {
|
|
2135
|
-
if (prev === next) return true;
|
|
2136
|
-
const held = bindingOf(prev);
|
|
2137
|
-
const incoming = bindingOf(next);
|
|
2138
|
-
if (!held || !incoming || held.component !== incoming.component) return false;
|
|
2139
|
-
if (held.address === incoming.address) return true;
|
|
2140
|
-
if (deliveredAddress === undefined) return false;
|
|
2141
|
-
if (incoming.address !== deliveredAddress) {
|
|
2142
|
-
deliveredAddress = incoming.address;
|
|
2143
|
-
for (const deliver of sites) deliver(incoming.address);
|
|
2144
|
-
}
|
|
2145
|
-
return true;
|
|
2146
|
-
};
|
|
2147
|
-
const cached = createMemo(prev => {
|
|
2148
|
-
const next = source();
|
|
2149
|
-
if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
|
|
2150
|
-
return {
|
|
2151
|
-
[FLIGHT]: next
|
|
2152
|
-
};
|
|
2153
|
-
}, {
|
|
2154
|
-
lazy: true,
|
|
2155
|
-
equals: sameInstance
|
|
2156
|
-
});
|
|
2157
|
-
return props => {
|
|
2158
|
-
if (sharedConfig.hydrating) {
|
|
2159
|
-
try {
|
|
2160
|
-
untrack(cached);
|
|
2161
|
-
} catch {}
|
|
2162
|
-
}
|
|
2163
|
-
let latest = 0;
|
|
2164
|
-
const value = createMemo(prev => {
|
|
2165
|
-
const c = cached();
|
|
2166
|
-
if (!c || !c[FLIGHT]) return resolveBinding(c, prev);
|
|
2167
|
-
const next = c[FLIGHT];
|
|
2168
|
-
const token = ++latest;
|
|
2169
|
-
return {
|
|
2170
|
-
then: (onFulfilled, onRejected) => next.then(resolved => {
|
|
2171
|
-
const landed = token === latest ? resolveBinding(resolved, prev) : resolved;
|
|
2172
|
-
return onFulfilled ? onFulfilled(landed) : landed;
|
|
2173
|
-
}, onRejected)
|
|
2174
|
-
};
|
|
2175
|
-
}, {
|
|
2176
|
-
equals: sameInstance
|
|
2177
|
-
});
|
|
2178
|
-
return createMemo(() => {
|
|
2179
|
-
const component = value();
|
|
2180
|
-
switch (typeof component) {
|
|
2181
|
-
case "function":
|
|
2182
|
-
{
|
|
2183
|
-
const binding = bindingOf(component);
|
|
2184
|
-
if (binding) {
|
|
2185
|
-
const [address, setAddress] = createSignal(deliveredAddress ??= binding.address, {
|
|
2186
|
-
ownedWrite: true
|
|
2187
|
-
});
|
|
2188
|
-
sites.add(setAddress);
|
|
2189
|
-
onCleanup(() => sites.delete(setAddress));
|
|
2190
|
-
return untrack(() => binding.component(props, address));
|
|
2191
|
-
}
|
|
2192
|
-
return untrack(() => component(props));
|
|
2193
|
-
}
|
|
2194
|
-
case "string":
|
|
2195
|
-
return tagArm ? tagArm(component, props) : undefined;
|
|
2196
|
-
}
|
|
2197
|
-
});
|
|
2198
|
-
};
|
|
2199
|
-
}
|
|
2200
|
-
function staticDynamic(component, tagArm) {
|
|
2201
|
-
if (typeof component === "function") {
|
|
2202
|
-
const binding = bindingOf(component);
|
|
2203
|
-
if (binding) {
|
|
2204
|
-
const address = () => binding.address;
|
|
2205
|
-
return props => untrack(() => binding.component(props, address));
|
|
2206
|
-
}
|
|
2207
|
-
return props => untrack(() => component(props));
|
|
2208
|
-
}
|
|
2209
|
-
if (typeof component === "string" && tagArm) return props => tagArm(component, props);
|
|
2210
|
-
return () => undefined;
|
|
2211
|
-
}
|
|
2212
2202
|
function staticElement(tag, props) {
|
|
2213
2203
|
const hydrating = sharedConfig.hydrating;
|
|
2214
2204
|
const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
|
|
@@ -2255,4 +2245,4 @@ _moduleUrl) {
|
|
|
2255
2245
|
function httpStatus(_code, _text) {}
|
|
2256
2246
|
function httpHeader(_name, _value, _options) {}
|
|
2257
2247
|
|
|
2258
|
-
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,
|
|
2248
|
+
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 };
|