@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.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, 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, 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: {
|
|
@@ -224,6 +224,10 @@ function qualifierValue(name, value) {
|
|
|
224
224
|
function asciiLowerCase(value) {
|
|
225
225
|
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
226
226
|
}
|
|
227
|
+
const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
|
|
228
|
+
function headBodyText(tag, props, text) {
|
|
229
|
+
return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
|
|
230
|
+
}
|
|
227
231
|
function resourceIdentity(tag, props) {
|
|
228
232
|
const url = String(props.href || props.src || "");
|
|
229
233
|
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
@@ -394,6 +398,13 @@ function takeHydrationValue(key) {
|
|
|
394
398
|
value: v
|
|
395
399
|
};
|
|
396
400
|
}
|
|
401
|
+
function setLinkClaim(_handler) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
function hasServerLinkState() {
|
|
405
|
+
const registry = globalThis._$HY && globalThis._$HY.r;
|
|
406
|
+
return !!registry && registry.links === 1;
|
|
407
|
+
}
|
|
397
408
|
const getTraceContext = voidFn;
|
|
398
409
|
function render(code, element, init, options = {}) {
|
|
399
410
|
let disposer;
|
|
@@ -506,17 +517,31 @@ function findOwner(target, state) {
|
|
|
506
517
|
function setProperty(node, name, value) {
|
|
507
518
|
if (isHydrating(node)) return;
|
|
508
519
|
const nodeName = node.nodeName;
|
|
509
|
-
if (name === "value" && nodeName === "SELECT")
|
|
520
|
+
if (name === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
|
|
521
|
+
if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[name] = value ?? "";
|
|
522
|
+
} else node[name] = value;
|
|
523
|
+
reclaimAttribute(node, name);
|
|
510
524
|
}
|
|
511
525
|
let claimHandlers = null;
|
|
526
|
+
const claimAttributeSets = [];
|
|
512
527
|
const CLAIM_SEAM = Symbol.for("solid.element-claims");
|
|
513
|
-
function registerElementClaim(handler) {
|
|
528
|
+
function registerElementClaim(handler, options) {
|
|
514
529
|
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
530
|
+
claimAttributeSets.push(options?.attributes || ["href", "action"]);
|
|
515
531
|
return () => {
|
|
516
532
|
const index = claimHandlers.indexOf(handler);
|
|
517
|
-
index > -1
|
|
533
|
+
if (index > -1) {
|
|
534
|
+
claimHandlers.splice(index, 1);
|
|
535
|
+
claimAttributeSets.splice(index, 1);
|
|
536
|
+
}
|
|
518
537
|
};
|
|
519
538
|
}
|
|
539
|
+
function runClaimHandlers(handlers, node) {
|
|
540
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](node);
|
|
541
|
+
}
|
|
542
|
+
function reclaimAttribute(node, name) {
|
|
543
|
+
if (claimHandlers !== null && node._$claimed && claimAttributeSets.some(set => set.includes(name.slice(name.indexOf(":") + 1)))) runClaimHandlers(claimHandlers, node);
|
|
544
|
+
}
|
|
520
545
|
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
521
546
|
function claimElementTree(root) {
|
|
522
547
|
const handlers = globalThis[CLAIM_SEAM];
|
|
@@ -524,17 +549,20 @@ function claimElementTree(root) {
|
|
|
524
549
|
const isElement = root.nodeType === 1;
|
|
525
550
|
if (!isElement && root.nodeType !== 11) return root;
|
|
526
551
|
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
527
|
-
|
|
552
|
+
root._$claimed = true;
|
|
553
|
+
runClaimHandlers(handlers, root);
|
|
528
554
|
}
|
|
529
555
|
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
530
556
|
for (let i = 0; i < found.length; i++) {
|
|
531
|
-
|
|
557
|
+
found[i]._$claimed = true;
|
|
558
|
+
runClaimHandlers(handlers, found[i]);
|
|
532
559
|
}
|
|
533
560
|
return root;
|
|
534
561
|
}
|
|
535
|
-
function claimElement(node) {
|
|
536
|
-
if (claimHandlers !== null) {
|
|
537
|
-
|
|
562
|
+
function claimElement(node, owner) {
|
|
563
|
+
if (claimHandlers !== null && !node._$claimed) {
|
|
564
|
+
node._$claimed = true;
|
|
565
|
+
if (owner === undefined) runClaimHandlers(claimHandlers, node);else runWithOwner(owner, () => runClaimHandlers(claimHandlers, node));
|
|
538
566
|
}
|
|
539
567
|
return node;
|
|
540
568
|
}
|
|
@@ -551,11 +579,12 @@ function setAttribute(node, name, value) {
|
|
|
551
579
|
}
|
|
552
580
|
}
|
|
553
581
|
if (selectMultiple) node._$multiple = true;
|
|
554
|
-
|
|
582
|
+
reclaimAttribute(node, name);
|
|
555
583
|
}
|
|
556
584
|
function setAttributeNS(node, namespace, name, value) {
|
|
557
585
|
if (isHydrating(node)) return;
|
|
558
586
|
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
587
|
+
reclaimAttribute(node, name);
|
|
559
588
|
}
|
|
560
589
|
function className(node, value, prev) {
|
|
561
590
|
if (typeof value === "number") value = "" + value;
|
|
@@ -663,7 +692,7 @@ function readShallow(value) {
|
|
|
663
692
|
if (value === null || typeof value !== "object") return value;
|
|
664
693
|
if (Array.isArray(value)) return value.map(readShallow);
|
|
665
694
|
if (value[$PROXY] !== value) return value;
|
|
666
|
-
const keys =
|
|
695
|
+
const keys = Reflect.ownKeys(value);
|
|
667
696
|
const out = {};
|
|
668
697
|
for (let i = 0; i < keys.length; i++) {
|
|
669
698
|
const k = keys[i];
|
|
@@ -677,10 +706,12 @@ function setStyleProperty(node, name, value) {
|
|
|
677
706
|
}
|
|
678
707
|
function spread(node, props, skipChildren, skip, name) {
|
|
679
708
|
const prevProps = {};
|
|
709
|
+
const owner = claimHandlers !== null && (node.localName === "a" || node.localName === "form") ? getOwner() : undefined;
|
|
680
710
|
const apply = newProps => {
|
|
681
711
|
const r = newProps.ref;
|
|
682
712
|
if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
|
|
683
713
|
assign(node, newProps, true, prevProps, true);
|
|
714
|
+
if (owner !== undefined) claimElement(node, owner);
|
|
684
715
|
};
|
|
685
716
|
if (Array.isArray(props)) {
|
|
686
717
|
effect(() => collectSources({}, props, undefined, skip), apply);
|
|
@@ -1218,7 +1249,7 @@ function createHeadElement(tag, props) {
|
|
|
1218
1249
|
if (v == null || v === false) continue;
|
|
1219
1250
|
el.setAttribute(name, v === true ? "" : String(v));
|
|
1220
1251
|
}
|
|
1221
|
-
if (props.children != null) el.textContent = String(props.children);
|
|
1252
|
+
if (props.children != null) el.textContent = headBodyText(tag, props, String(props.children));
|
|
1222
1253
|
return el;
|
|
1223
1254
|
}
|
|
1224
1255
|
function renderHeadElement(t, identity, existing) {
|
|
@@ -1241,7 +1272,7 @@ function headElementMatches(el, t) {
|
|
|
1241
1272
|
} else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
|
|
1242
1273
|
}
|
|
1243
1274
|
const children = t.props.children;
|
|
1244
|
-
return (children == null ? "" : String(children)) === el.textContent;
|
|
1275
|
+
return (children == null ? "" : headBodyText(t.tag, t.props, String(children))) === el.textContent;
|
|
1245
1276
|
}
|
|
1246
1277
|
function mountHeadResource(tag, props) {
|
|
1247
1278
|
const identity = resourceIdentity(tag, props);
|
|
@@ -1357,7 +1388,22 @@ function loadModuleAssets(mapping) {
|
|
|
1357
1388
|
function hydrate(code, element, options = {}) {
|
|
1358
1389
|
enableHydration();
|
|
1359
1390
|
installHydrationRuntime();
|
|
1360
|
-
|
|
1391
|
+
const hy = globalThis._$HY;
|
|
1392
|
+
const id = options.renderId || "";
|
|
1393
|
+
if (hy.s && !hy.s[id] && !hy.s[""] && !hy.done && document.readyState === "loading") {
|
|
1394
|
+
let started, disposer;
|
|
1395
|
+
const start = () => started || (started = true, disposer = hydrate(code, element, options));
|
|
1396
|
+
(hy.sp || (hy.sp = [])).push([id, start]);
|
|
1397
|
+
hy.sw = key => hy.sp.forEach(([k, f]) => (!key || k === key) && queueMicrotask(f));
|
|
1398
|
+
document.addEventListener("DOMContentLoaded", start, {
|
|
1399
|
+
once: true
|
|
1400
|
+
});
|
|
1401
|
+
return () => {
|
|
1402
|
+
started = true;
|
|
1403
|
+
disposer && disposer();
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
if (hy.done) return render(code, element, [...element.childNodes], options);
|
|
1361
1407
|
const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
|
|
1362
1408
|
if (head && element.contains(head)) {
|
|
1363
1409
|
let n = head.firstChild;
|
|
@@ -1536,13 +1582,32 @@ function isHydrating(node) {
|
|
|
1536
1582
|
if (!sharedConfig.hydrating) return false;
|
|
1537
1583
|
if (sharedConfig.isClaiming && !sharedConfig.isClaiming()) return false;
|
|
1538
1584
|
if (!node || node.isConnected) return true;
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1585
|
+
return serverComponentClaims !== null && serverComponentClaims.claimed(node);
|
|
1586
|
+
}
|
|
1587
|
+
let serverComponentClaims = null;
|
|
1588
|
+
function installServerComponentHydration() {
|
|
1589
|
+
enableServerComponentHydration();
|
|
1590
|
+
if (serverComponentClaims !== null) return;
|
|
1591
|
+
serverComponentClaims = {
|
|
1592
|
+
claimed(node) {
|
|
1593
|
+
const roots = sharedConfig.claimRoots;
|
|
1594
|
+
if (roots) {
|
|
1595
|
+
for (let i = 0; i < roots.length; i++) {
|
|
1596
|
+
if (roots[i].contains(node)) return true;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
return false;
|
|
1600
|
+
},
|
|
1601
|
+
inFrame(element) {
|
|
1602
|
+
const frames = element.querySelectorAll("[data-fid]");
|
|
1603
|
+
const frameCount = frames.length;
|
|
1604
|
+
if (frameCount === 0) return undefined;
|
|
1605
|
+
return node => {
|
|
1606
|
+
for (let j = 0; j < frameCount; j++) if (frames[j].contains(node)) return true;
|
|
1607
|
+
return false;
|
|
1608
|
+
};
|
|
1543
1609
|
}
|
|
1544
|
-
}
|
|
1545
|
-
return false;
|
|
1610
|
+
};
|
|
1546
1611
|
}
|
|
1547
1612
|
function classListToObject(classList) {
|
|
1548
1613
|
if (Array.isArray(classList)) {
|
|
@@ -1594,8 +1659,10 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
1594
1659
|
}
|
|
1595
1660
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
1596
1661
|
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
1597
|
-
if (prop === "value" && nodeName === "SELECT")
|
|
1598
|
-
|
|
1662
|
+
if (prop === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
|
|
1663
|
+
if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[prop] = value ?? "";
|
|
1664
|
+
} else node[prop] = value;
|
|
1665
|
+
reclaimAttribute(node, prop);
|
|
1599
1666
|
} else {
|
|
1600
1667
|
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
1601
1668
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
@@ -1733,8 +1800,35 @@ function insertExpression(parent, value, current, marker) {
|
|
|
1733
1800
|
appendNodes(parent, value);
|
|
1734
1801
|
}
|
|
1735
1802
|
} else ;
|
|
1803
|
+
selectInsert && selectInsert(parent);
|
|
1736
1804
|
return value;
|
|
1737
1805
|
}
|
|
1806
|
+
let selectInsert;
|
|
1807
|
+
function selectChange(e) {
|
|
1808
|
+
(e = e.currentTarget || e)._$v = null;
|
|
1809
|
+
e.removeEventListener("change", selectChange, true);
|
|
1810
|
+
}
|
|
1811
|
+
function writeSelectValue(node, value) {
|
|
1812
|
+
const had = node._$v && node._$v.map,
|
|
1813
|
+
has = value != null && value.map;
|
|
1814
|
+
if (has) had || node.addEventListener("change", selectChange, true);else had && node.removeEventListener("change", selectChange, true);
|
|
1815
|
+
if (value == null) {
|
|
1816
|
+
node._$v = null;
|
|
1817
|
+
return queueMicrotask(() => node.value = value) || (node.value = value);
|
|
1818
|
+
}
|
|
1819
|
+
node._$v = value;
|
|
1820
|
+
(selectInsert ||= p => {
|
|
1821
|
+
p && p._$v == null && (p = p.parentNode);
|
|
1822
|
+
const v = p && p._$v;
|
|
1823
|
+
if (v == null) return;
|
|
1824
|
+
if (v.map) {
|
|
1825
|
+
const o = [...p.options];
|
|
1826
|
+
for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
|
|
1827
|
+
v.every(x => o.some(el => el.value == x)) && selectChange(p);
|
|
1828
|
+
} else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
|
|
1829
|
+
})(node);
|
|
1830
|
+
queueMicrotask(() => selectInsert(node));
|
|
1831
|
+
}
|
|
1738
1832
|
function normalize(value, current, multi, doNotUnwrap) {
|
|
1739
1833
|
value = flatten(value, {
|
|
1740
1834
|
skipNonRendered: true,
|
|
@@ -1813,22 +1907,12 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
1813
1907
|
}
|
|
1814
1908
|
function gatherHydratable(element, root) {
|
|
1815
1909
|
const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
|
|
1816
|
-
const
|
|
1817
|
-
const frameCount = frames ? frames.length : 0;
|
|
1910
|
+
const inFrame = root || serverComponentClaims === null ? undefined : serverComponentClaims.inFrame(element);
|
|
1818
1911
|
const registry = sharedConfig.registry;
|
|
1819
1912
|
for (let i = 0; i < templates.length; i++) {
|
|
1820
1913
|
const node = templates[i];
|
|
1914
|
+
if (inFrame !== undefined && inFrame(node)) continue;
|
|
1821
1915
|
const key = node.getAttribute("_hk");
|
|
1822
|
-
if (frameCount !== 0) {
|
|
1823
|
-
let inFrame = false;
|
|
1824
|
-
for (let j = 0; j < frameCount; j++) {
|
|
1825
|
-
if (frames[j].contains(node)) {
|
|
1826
|
-
inFrame = true;
|
|
1827
|
-
break;
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
if (inFrame) continue;
|
|
1831
|
-
}
|
|
1832
1916
|
if (!registry.has(key)) registry.set(key, node);
|
|
1833
1917
|
}
|
|
1834
1918
|
}
|
|
@@ -1870,6 +1954,7 @@ function composeMiddleware(middlewares) {
|
|
|
1870
1954
|
function ssr(template, ...nodes) {}
|
|
1871
1955
|
function ssrElement(name, props, children, needsId, skip, attrs) {}
|
|
1872
1956
|
function ssrElementAttribute(key, value) {}
|
|
1957
|
+
function ssrLinkClaim(attrs) {}
|
|
1873
1958
|
function ssrClassName(value) {}
|
|
1874
1959
|
function ssrStyle(value) {}
|
|
1875
1960
|
function ssrStyleProperty(name, value) {}
|
|
@@ -1881,17 +1966,24 @@ function resolveSSRNode(node, result, top, nested) {}
|
|
|
1881
1966
|
function escape(s, attr) {}
|
|
1882
1967
|
|
|
1883
1968
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
1884
|
-
|
|
1885
|
-
const ResponseEnvelope =
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1969
|
+
let EnvelopeClass;
|
|
1970
|
+
const ResponseEnvelope = function ResponseEnvelope(response, value) {
|
|
1971
|
+
if (!EnvelopeClass) {
|
|
1972
|
+
EnvelopeClass = class extends Response {
|
|
1973
|
+
constructor(response, value) {
|
|
1974
|
+
super(response ? response.body : null, response && {
|
|
1975
|
+
status: response.status,
|
|
1976
|
+
statusText: response.statusText,
|
|
1977
|
+
headers: copyHeaders(response.headers)
|
|
1978
|
+
});
|
|
1979
|
+
this.response = response ? this : undefined;
|
|
1980
|
+
this.value = value;
|
|
1981
|
+
}
|
|
1982
|
+
};
|
|
1983
|
+
EnvelopeClass.prototype[ENVELOPE] = true;
|
|
1891
1984
|
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
})();
|
|
1985
|
+
return new EnvelopeClass(response, value);
|
|
1986
|
+
};
|
|
1895
1987
|
function isResponseEnvelope(value) {
|
|
1896
1988
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1897
1989
|
}
|
|
@@ -1916,6 +2008,16 @@ function isSafeError(value) {
|
|
|
1916
2008
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
1917
2009
|
const REVALIDATE_ALL = "*";
|
|
1918
2010
|
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
2011
|
+
function copyHeaders(init) {
|
|
2012
|
+
const source = init;
|
|
2013
|
+
if (!source || !source.getSetCookie) return new Headers(init);
|
|
2014
|
+
const headers = new Headers();
|
|
2015
|
+
source.forEach((value, key) => {
|
|
2016
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
2017
|
+
});
|
|
2018
|
+
for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
2019
|
+
return headers;
|
|
2020
|
+
}
|
|
1919
2021
|
function initWithRevalidate(init = {}) {
|
|
1920
2022
|
const resolved = typeof init === "number" ? {
|
|
1921
2023
|
status: init
|
|
@@ -1924,18 +2026,7 @@ function initWithRevalidate(init = {}) {
|
|
|
1924
2026
|
revalidate,
|
|
1925
2027
|
...responseInit
|
|
1926
2028
|
} = resolved;
|
|
1927
|
-
|
|
1928
|
-
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
1929
|
-
headers = new Headers();
|
|
1930
|
-
responseInit.headers.forEach((value, key) => {
|
|
1931
|
-
if (key !== "set-cookie") headers.append(key, value);
|
|
1932
|
-
});
|
|
1933
|
-
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
1934
|
-
headers.append("Set-Cookie", cookie);
|
|
1935
|
-
}
|
|
1936
|
-
} else {
|
|
1937
|
-
headers = new Headers(responseInit.headers);
|
|
1938
|
-
}
|
|
2029
|
+
const headers = copyHeaders(responseInit.headers);
|
|
1939
2030
|
if (revalidate !== undefined) {
|
|
1940
2031
|
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
1941
2032
|
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
@@ -2059,110 +2150,9 @@ function portalImpl(props) {
|
|
|
2059
2150
|
});
|
|
2060
2151
|
return treeMarker;
|
|
2061
2152
|
}
|
|
2062
|
-
const COMPONENT_BINDING = Symbol.for("solid.component-binding");
|
|
2063
|
-
const FLIGHT = Symbol("solid.dynamic-flight");
|
|
2064
|
-
function bindingOf(value) {
|
|
2065
|
-
return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
|
|
2066
|
-
}
|
|
2067
2153
|
function dynamic(source, options) {
|
|
2068
2154
|
return dynamicCore(source, options, staticElement);
|
|
2069
2155
|
}
|
|
2070
|
-
function dynamicComponent(source, options) {
|
|
2071
|
-
return dynamicCore(source, options);
|
|
2072
|
-
}
|
|
2073
|
-
function dynamicCore(source, options, tagArm) {
|
|
2074
|
-
if (options?.static) return staticDynamic(untrack(source), tagArm);
|
|
2075
|
-
const sites = new Set();
|
|
2076
|
-
let deliveredAddress;
|
|
2077
|
-
const resolveBinding = (next, prev) => {
|
|
2078
|
-
const binding = bindingOf(next);
|
|
2079
|
-
if (!binding) return next;
|
|
2080
|
-
deliveredAddress = binding.address;
|
|
2081
|
-
const prevBinding = bindingOf(prev);
|
|
2082
|
-
if (prevBinding && prevBinding.component === binding.component) {
|
|
2083
|
-
for (const deliver of sites) deliver(binding.address);
|
|
2084
|
-
return prev;
|
|
2085
|
-
}
|
|
2086
|
-
return next;
|
|
2087
|
-
};
|
|
2088
|
-
const sameInstance = (prev, next) => {
|
|
2089
|
-
if (prev === next) return true;
|
|
2090
|
-
const held = bindingOf(prev);
|
|
2091
|
-
const incoming = bindingOf(next);
|
|
2092
|
-
if (!held || !incoming || held.component !== incoming.component) return false;
|
|
2093
|
-
if (held.address === incoming.address) return true;
|
|
2094
|
-
if (deliveredAddress === undefined) return false;
|
|
2095
|
-
if (incoming.address !== deliveredAddress) {
|
|
2096
|
-
deliveredAddress = incoming.address;
|
|
2097
|
-
for (const deliver of sites) deliver(incoming.address);
|
|
2098
|
-
}
|
|
2099
|
-
return true;
|
|
2100
|
-
};
|
|
2101
|
-
const cached = createMemo(prev => {
|
|
2102
|
-
const next = source();
|
|
2103
|
-
if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
|
|
2104
|
-
return {
|
|
2105
|
-
[FLIGHT]: next
|
|
2106
|
-
};
|
|
2107
|
-
}, {
|
|
2108
|
-
lazy: true,
|
|
2109
|
-
equals: sameInstance
|
|
2110
|
-
});
|
|
2111
|
-
return props => {
|
|
2112
|
-
if (sharedConfig.hydrating) {
|
|
2113
|
-
try {
|
|
2114
|
-
untrack(cached);
|
|
2115
|
-
} catch {}
|
|
2116
|
-
}
|
|
2117
|
-
let latest = 0;
|
|
2118
|
-
const value = createMemo(prev => {
|
|
2119
|
-
const c = cached();
|
|
2120
|
-
if (!c || !c[FLIGHT]) return resolveBinding(c, prev);
|
|
2121
|
-
const next = c[FLIGHT];
|
|
2122
|
-
const token = ++latest;
|
|
2123
|
-
return {
|
|
2124
|
-
then: (onFulfilled, onRejected) => next.then(resolved => {
|
|
2125
|
-
const landed = token === latest ? resolveBinding(resolved, prev) : resolved;
|
|
2126
|
-
return onFulfilled ? onFulfilled(landed) : landed;
|
|
2127
|
-
}, onRejected)
|
|
2128
|
-
};
|
|
2129
|
-
}, {
|
|
2130
|
-
equals: sameInstance
|
|
2131
|
-
});
|
|
2132
|
-
return createMemo(() => {
|
|
2133
|
-
const component = value();
|
|
2134
|
-
switch (typeof component) {
|
|
2135
|
-
case "function":
|
|
2136
|
-
{
|
|
2137
|
-
const binding = bindingOf(component);
|
|
2138
|
-
if (binding) {
|
|
2139
|
-
const [address, setAddress] = createSignal(deliveredAddress ??= binding.address, {
|
|
2140
|
-
ownedWrite: true
|
|
2141
|
-
});
|
|
2142
|
-
sites.add(setAddress);
|
|
2143
|
-
onCleanup(() => sites.delete(setAddress));
|
|
2144
|
-
return untrack(() => binding.component(props, address));
|
|
2145
|
-
}
|
|
2146
|
-
return untrack(() => component(props));
|
|
2147
|
-
}
|
|
2148
|
-
case "string":
|
|
2149
|
-
return tagArm ? tagArm(component, props) : undefined;
|
|
2150
|
-
}
|
|
2151
|
-
});
|
|
2152
|
-
};
|
|
2153
|
-
}
|
|
2154
|
-
function staticDynamic(component, tagArm) {
|
|
2155
|
-
if (typeof component === "function") {
|
|
2156
|
-
const binding = bindingOf(component);
|
|
2157
|
-
if (binding) {
|
|
2158
|
-
const address = () => binding.address;
|
|
2159
|
-
return props => untrack(() => binding.component(props, address));
|
|
2160
|
-
}
|
|
2161
|
-
return props => untrack(() => component(props));
|
|
2162
|
-
}
|
|
2163
|
-
if (typeof component === "string" && tagArm) return props => tagArm(component, props);
|
|
2164
|
-
return () => undefined;
|
|
2165
|
-
}
|
|
2166
2156
|
function staticElement(tag, props) {
|
|
2167
2157
|
const hydrating = sharedConfig.hydrating;
|
|
2168
2158
|
const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
|
|
@@ -2209,4 +2199,4 @@ _moduleUrl) {
|
|
|
2209
2199
|
function httpStatus(_code, _text) {}
|
|
2210
2200
|
function httpHeader(_name, _value, _options) {}
|
|
2211
2201
|
|
|
2212
|
-
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,
|
|
2202
|
+
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 };
|