@solidjs/web 2.0.0-rc.6 → 2.0.0-rc.8
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.cjs → server.dev.js} +274 -272
- package/dist/server.js +119 -36
- package/dist/{dev.js → web.dev.js} +131 -399
- package/dist/web.js +78 -388
- package/dist/{web.cjs → web.observe.js} +174 -622
- package/frames/dist/client.dev.js +11 -3
- package/frames/dist/client.js +11 -3
- package/frames/dist/{server.cjs → server.dev.js} +375 -125
- package/frames/dist/server.js +253 -32
- package/frames/package.json +7 -15
- package/package.json +88 -251
- package/serialization/decode/package.json +3 -9
- package/serialization/dist/decode.js +18 -4
- package/serialization/dist/serialization.js +18 -4
- package/serialization/package.json +3 -9
- package/serialization/types/serializer-decode.d.ts +49 -2
- package/server-functions/dist/client.js +13 -14
- package/server-functions/dist/server.dev.js +359 -85
- package/server-functions/dist/server.js +352 -86
- package/server-functions/package.json +6 -24
- package/server-functions/rich-args/package.json +3 -9
- package/storage/package.json +3 -9
- package/types/client.d.ts +17 -3
- package/types/frames/frame-client.d.ts +1 -1
- package/types/frames/serializer-decode.d.ts +49 -2
- package/types/head.d.ts +3 -0
- package/types/index.d.ts +18 -7
- package/types/index.server.d.ts +31 -9
- package/types/render.d.ts +3 -1
- package/types/serializer-decode.d.ts +49 -2
- package/types/server-functions/flash.d.ts +12 -3
- package/types/server-functions/server.d.ts +50 -3
- package/types/server-mock.d.ts +43 -7
- package/types/server.d.ts +48 -6
- package/dist/dev.cjs +0 -2590
- package/frames/dist/client.cjs +0 -2035
- package/frames/dist/client.dev.cjs +0 -2055
- package/serialization/dist/decode.cjs +0 -141
- package/serialization/dist/serialization.cjs +0 -261
- package/serialization/types-cjs/index.d.cts +0 -101
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -172
- package/serialization/types-cjs/serializer.d.cts +0 -101
- package/server-functions/dist/client.cjs +0 -1070
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -2133
- package/server-functions/dist/server.dev.cjs +0 -2153
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/patch-driver.d.ts +0 -3
- package/types-cjs/client.d.cts +0 -200
- package/types-cjs/constants.d.cts +0 -20
- package/types-cjs/cookies.d.cts +0 -41
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -370
- package/types-cjs/frames/frame-container-plugin.d.cts +0 -71
- package/types-cjs/frames/frame-sink.d.cts +0 -92
- package/types-cjs/frames/frame-transport.d.cts +0 -189
- package/types-cjs/frames/serializer-decode.d.cts +0 -172
- package/types-cjs/frames/serializer.d.cts +0 -101
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/head.d.cts +0 -16
- package/types-cjs/index.d.cts +0 -180
- package/types-cjs/index.server.d.cts +0 -125
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4146
- package/types-cjs/package.json +0 -3
- package/types-cjs/patch-driver.d.cts +0 -3
- package/types-cjs/reconcile.d.cts +0 -1
- package/types-cjs/render.d.cts +0 -4
- package/types-cjs/response.d.cts +0 -81
- package/types-cjs/serializer-decode.d.cts +0 -172
- package/types-cjs/serializer.d.cts +0 -101
- package/types-cjs/server-functions/client.d.cts +0 -184
- package/types-cjs/server-functions/flash.d.cts +0 -27
- package/types-cjs/server-functions/registry.d.cts +0 -100
- package/types-cjs/server-functions/rich-args.d.cts +0 -1
- package/types-cjs/server-functions/server.d.cts +0 -522
- package/types-cjs/server-functions/shared.d.cts +0 -283
- package/types-cjs/server-mock.d.cts +0 -301
- package/types-cjs/server.d.cts +0 -366
package/frames/dist/server.js
CHANGED
|
@@ -291,6 +291,18 @@ const ERROR_HEADER = "X-Server-Function-Error";
|
|
|
291
291
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
292
292
|
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
293
293
|
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
294
|
+
const BodyFormat = {
|
|
295
|
+
Serialized: "0",
|
|
296
|
+
String: "1",
|
|
297
|
+
FormData: "2",
|
|
298
|
+
URLSearchParams: "3",
|
|
299
|
+
Blob: "4",
|
|
300
|
+
File: "5",
|
|
301
|
+
ArrayBuffer: "6",
|
|
302
|
+
Uint8Array: "7",
|
|
303
|
+
Json: "8",
|
|
304
|
+
Void: "9"
|
|
305
|
+
};
|
|
294
306
|
function createChunk(data) {
|
|
295
307
|
const encoder = new TextEncoder();
|
|
296
308
|
const encodeData = encoder.encode(data);
|
|
@@ -426,12 +438,24 @@ function classifyHeadTag(desc) {
|
|
|
426
438
|
resource: false
|
|
427
439
|
};
|
|
428
440
|
}
|
|
441
|
+
function qualifierValue(name, value) {
|
|
442
|
+
if (value == null || value === false) return null;
|
|
443
|
+
if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
|
|
444
|
+
const v = value === true ? "" : String(value);
|
|
445
|
+
if (name === "as") return asciiLowerCase(v);
|
|
446
|
+
if (name !== "crossorigin") return v;
|
|
447
|
+
return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
|
|
448
|
+
}
|
|
449
|
+
function asciiLowerCase(value) {
|
|
450
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
451
|
+
}
|
|
429
452
|
function resourceIdentity(tag, props) {
|
|
430
|
-
|
|
453
|
+
const url = String(props.href || props.src || "");
|
|
454
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
431
455
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
432
456
|
const q = RESOURCE_QUALIFIERS[i];
|
|
433
|
-
const value = props[q];
|
|
434
|
-
if (value
|
|
457
|
+
const value = qualifierValue(q, props[q]);
|
|
458
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
435
459
|
}
|
|
436
460
|
return id;
|
|
437
461
|
}
|
|
@@ -505,12 +529,20 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
505
529
|
if (e.preloads) {
|
|
506
530
|
for (let i = 0; i < e.preloads.length; i++) {
|
|
507
531
|
const link = e.preloads[i];
|
|
508
|
-
|
|
532
|
+
const href = link && typeof link.href === "string" && link.href;
|
|
533
|
+
const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
|
|
534
|
+
if (!href && !srcset) continue;
|
|
509
535
|
if (!preloads) preloads = [];
|
|
510
|
-
preloads.push({
|
|
536
|
+
if (href) preloads.push({
|
|
511
537
|
...link,
|
|
512
|
-
href: joinAssetPath(base,
|
|
513
|
-
});
|
|
538
|
+
href: joinAssetPath(base, href)
|
|
539
|
+
});else {
|
|
540
|
+
const {
|
|
541
|
+
href: bad,
|
|
542
|
+
...rest
|
|
543
|
+
} = link;
|
|
544
|
+
preloads.push(rest);
|
|
545
|
+
}
|
|
514
546
|
}
|
|
515
547
|
}
|
|
516
548
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
@@ -642,9 +674,13 @@ function isCssUrl(url) {
|
|
|
642
674
|
const q = url.search(/[?#]/);
|
|
643
675
|
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
644
676
|
}
|
|
645
|
-
const
|
|
677
|
+
const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
|
|
678
|
+
function isSetAttr(value) {
|
|
679
|
+
return value != null && value !== false && value !== "";
|
|
680
|
+
}
|
|
681
|
+
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
646
682
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
647
|
-
if (!link || typeof link !== "object"
|
|
683
|
+
if (!link || typeof link !== "object") {
|
|
648
684
|
return null;
|
|
649
685
|
}
|
|
650
686
|
if (typeof link.as !== "string") {
|
|
@@ -665,13 +701,35 @@ function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
|
665
701
|
default:
|
|
666
702
|
return null;
|
|
667
703
|
}
|
|
704
|
+
const responsive = as === "image";
|
|
705
|
+
let srcset = null;
|
|
706
|
+
let sizes = null;
|
|
707
|
+
if (responsive) {
|
|
708
|
+
for (const name of RESPONSIVE_ATTRIBUTES) {
|
|
709
|
+
const value = link[name];
|
|
710
|
+
if (!isSetAttr(value)) continue;
|
|
711
|
+
if (typeof value !== "string") {
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
if (name === "imagesrcset") srcset = value;else sizes = value;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
const href = typeof link.href === "string" && link.href ? link.href : null;
|
|
718
|
+
if (!href && !srcset) {
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
668
721
|
const props = {
|
|
669
|
-
rel: "preload"
|
|
670
|
-
href: link.href,
|
|
671
|
-
as
|
|
722
|
+
rel: "preload"
|
|
672
723
|
};
|
|
724
|
+
if (href) props.href = href;
|
|
725
|
+
props.as = as;
|
|
673
726
|
for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
|
|
674
727
|
const name = PRELOAD_LINK_ATTRIBUTES[i];
|
|
728
|
+
if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
|
|
729
|
+
const value = name === "imagesrcset" ? srcset : sizes;
|
|
730
|
+
if (value !== null) props[name] = value;
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
675
733
|
const value = link[name];
|
|
676
734
|
if (value == null || value === false) continue;
|
|
677
735
|
props[name] = value === true ? "" : String(value);
|
|
@@ -1036,9 +1094,6 @@ function normalizeNonce(nonce) {
|
|
|
1036
1094
|
styleAttr: typeof style === "string" && style ? ` nonce="${escape(style, true)}"` : ""
|
|
1037
1095
|
};
|
|
1038
1096
|
}
|
|
1039
|
-
function asciiLowerCase(value) {
|
|
1040
|
-
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
1041
|
-
}
|
|
1042
1097
|
function hasNonceProp(props) {
|
|
1043
1098
|
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
1044
1099
|
return false;
|
|
@@ -1119,6 +1174,7 @@ function renderToStream(code, options = {}) {
|
|
|
1119
1174
|
onHead
|
|
1120
1175
|
} = options;
|
|
1121
1176
|
const nonce = normalizeNonce(options.nonce);
|
|
1177
|
+
const requestEvent = peekRequestEvent();
|
|
1122
1178
|
let dispose;
|
|
1123
1179
|
let dead = false;
|
|
1124
1180
|
const abandon = () => {
|
|
@@ -1220,6 +1276,7 @@ function renderToStream(code, options = {}) {
|
|
|
1220
1276
|
};
|
|
1221
1277
|
const onDone = () => {
|
|
1222
1278
|
writeTasks();
|
|
1279
|
+
lastBlockingSize = blockingPromises.size;
|
|
1223
1280
|
doShell();
|
|
1224
1281
|
onCompleteAll && onCompleteAll({
|
|
1225
1282
|
write(v) {
|
|
@@ -1609,9 +1666,9 @@ function renderToStream(code, options = {}) {
|
|
|
1609
1666
|
function doShell() {
|
|
1610
1667
|
if (shellCompleted) return;
|
|
1611
1668
|
sharedConfig.context = context;
|
|
1612
|
-
|
|
1669
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1613
1670
|
if (!resolveRootHoles()) return;
|
|
1614
|
-
if (blockingPromises.size !==
|
|
1671
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1615
1672
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1616
1673
|
headStyles = new Set();
|
|
1617
1674
|
for (const url of tracking.emittedAssets) {
|
|
@@ -1639,7 +1696,7 @@ function renderToStream(code, options = {}) {
|
|
|
1639
1696
|
let lastBlockingSize = -1;
|
|
1640
1697
|
let lastRegistrySize = -1;
|
|
1641
1698
|
let drainTurn = 0;
|
|
1642
|
-
const scheduleFlush = fn => {
|
|
1699
|
+
const scheduleFlush = (fn, awaited) => {
|
|
1643
1700
|
const attempt = () => {
|
|
1644
1701
|
flushStubBatch();
|
|
1645
1702
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
@@ -1650,8 +1707,8 @@ function renderToStream(code, options = {}) {
|
|
|
1650
1707
|
}
|
|
1651
1708
|
fn();
|
|
1652
1709
|
};
|
|
1653
|
-
const progressed =
|
|
1654
|
-
lastBlockingSize =
|
|
1710
|
+
const progressed = awaited !== lastBlockingSize;
|
|
1711
|
+
lastBlockingSize = awaited;
|
|
1655
1712
|
lastRegistrySize = -1;
|
|
1656
1713
|
drainTurn = 0;
|
|
1657
1714
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
@@ -1668,7 +1725,7 @@ function renderToStream(code, options = {}) {
|
|
|
1668
1725
|
let resolve;
|
|
1669
1726
|
const p = new Promise(r => resolve = r);
|
|
1670
1727
|
function flush() {
|
|
1671
|
-
allSettled(blockingPromises).then(
|
|
1728
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1672
1729
|
scheduleFlush(() => {
|
|
1673
1730
|
if (dead) return resolve();
|
|
1674
1731
|
try {
|
|
@@ -1706,7 +1763,7 @@ function renderToStream(code, options = {}) {
|
|
|
1706
1763
|
dispose();
|
|
1707
1764
|
writable.end();
|
|
1708
1765
|
} else flushEnd();
|
|
1709
|
-
});
|
|
1766
|
+
}, awaited);
|
|
1710
1767
|
});
|
|
1711
1768
|
}
|
|
1712
1769
|
flush();
|
|
@@ -1714,8 +1771,12 @@ function renderToStream(code, options = {}) {
|
|
|
1714
1771
|
};
|
|
1715
1772
|
return {
|
|
1716
1773
|
then(onFulfilled, onRejected) {
|
|
1774
|
+
const freezeHead = () => {
|
|
1775
|
+
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response);
|
|
1776
|
+
};
|
|
1717
1777
|
const p = new Promise(resolve => {
|
|
1718
1778
|
function complete() {
|
|
1779
|
+
freezeHead();
|
|
1719
1780
|
dispose();
|
|
1720
1781
|
resolve(tmp);
|
|
1721
1782
|
}
|
|
@@ -1727,17 +1788,16 @@ function renderToStream(code, options = {}) {
|
|
|
1727
1788
|
};
|
|
1728
1789
|
} else onCompleteAll = complete;
|
|
1729
1790
|
function flush() {
|
|
1730
|
-
allSettled(blockingPromises).then(
|
|
1791
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1731
1792
|
scheduleFlush(() => {
|
|
1732
1793
|
try {
|
|
1733
|
-
|
|
1734
|
-
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1794
|
+
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1735
1795
|
} catch (err) {
|
|
1736
1796
|
failRender(err);
|
|
1737
1797
|
return resolve(tmp);
|
|
1738
1798
|
}
|
|
1739
1799
|
queue(flushEnd);
|
|
1740
|
-
});
|
|
1800
|
+
}, awaited);
|
|
1741
1801
|
});
|
|
1742
1802
|
}
|
|
1743
1803
|
flush();
|
|
@@ -1747,7 +1807,7 @@ function renderToStream(code, options = {}) {
|
|
|
1747
1807
|
pipe(w) {
|
|
1748
1808
|
claimConsumer("pipe");
|
|
1749
1809
|
function flush() {
|
|
1750
|
-
allSettled(blockingPromises).then(
|
|
1810
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1751
1811
|
scheduleFlush(() => {
|
|
1752
1812
|
if (dead) return;
|
|
1753
1813
|
try {
|
|
@@ -1769,7 +1829,7 @@ function renderToStream(code, options = {}) {
|
|
|
1769
1829
|
dispose();
|
|
1770
1830
|
writable.end();
|
|
1771
1831
|
} else flushEnd();
|
|
1772
|
-
});
|
|
1832
|
+
}, awaited);
|
|
1773
1833
|
});
|
|
1774
1834
|
}
|
|
1775
1835
|
flush();
|
|
@@ -2440,10 +2500,13 @@ function escape(s, attr) {
|
|
|
2440
2500
|
if (!attr && Array.isArray(s)) {
|
|
2441
2501
|
const joined = tryJoinPlainSSRArray(s);
|
|
2442
2502
|
if (joined !== undefined) return joined;
|
|
2503
|
+
const src = s;
|
|
2443
2504
|
s = s.slice();
|
|
2444
2505
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
2506
|
+
if (src.$slot) s.$slot = true;
|
|
2445
2507
|
return s;
|
|
2446
2508
|
}
|
|
2509
|
+
if (!attr && t === "function") return escapeLate(s);
|
|
2447
2510
|
if (attr) {
|
|
2448
2511
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
2449
2512
|
return escape(String(s), attr);
|
|
@@ -2454,6 +2517,15 @@ function escape(s, attr) {
|
|
|
2454
2517
|
if (i < 0) return s;
|
|
2455
2518
|
return escapeSlow(s, attr, i);
|
|
2456
2519
|
}
|
|
2520
|
+
function escapeLate(fn) {
|
|
2521
|
+
if (fn.$esc) return fn;
|
|
2522
|
+
const w = () => escape(fn());
|
|
2523
|
+
w.$esc = true;
|
|
2524
|
+
if (fn.$lhSkip) w.$lhSkip = true;
|
|
2525
|
+
if (fn.$lhSuppress) w.$lhSuppress = true;
|
|
2526
|
+
if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
|
|
2527
|
+
return w;
|
|
2528
|
+
}
|
|
2457
2529
|
const ESCAPE_CONTENT = /[&<]/;
|
|
2458
2530
|
const ESCAPE_ATTR = /[&"<]/;
|
|
2459
2531
|
function escapeSlow(s, attr, start) {
|
|
@@ -2541,7 +2613,7 @@ function allSettled(promises) {
|
|
|
2541
2613
|
let size = promises.size;
|
|
2542
2614
|
return Promise.allSettled(promises).then(() => {
|
|
2543
2615
|
if (promises.size !== size) return allSettled(promises);
|
|
2544
|
-
return;
|
|
2616
|
+
return size;
|
|
2545
2617
|
});
|
|
2546
2618
|
}
|
|
2547
2619
|
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
@@ -2791,10 +2863,145 @@ function resolveSSRSync(node) {
|
|
|
2791
2863
|
if (!res.h.length) return res.t[0];
|
|
2792
2864
|
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
2793
2865
|
}
|
|
2866
|
+
const RequestContext = Symbol.for("solid.RequestContext");
|
|
2867
|
+
function peekRequestEvent() {
|
|
2868
|
+
const store = globalThis[RequestContext];
|
|
2869
|
+
return store ? store.getStore() : undefined;
|
|
2870
|
+
}
|
|
2871
|
+
function reportLostHeaderWrite(method, name) {
|
|
2872
|
+
const message = `Response header write dropped: headers.${method}(${JSON.stringify(String(name))}) ` + "ran after the response head was sent. Write headers before the shell flushes " + "(or before the handler returns).";
|
|
2873
|
+
console.error(message);
|
|
2874
|
+
}
|
|
2875
|
+
function commitResponseStub(stub, {
|
|
2876
|
+
allowLateLocation = false
|
|
2877
|
+
} = {}) {
|
|
2878
|
+
if (!stub || stub.committed) return stub;
|
|
2879
|
+
stub.committed = true;
|
|
2880
|
+
const headers = stub.headers;
|
|
2881
|
+
if (!headers || typeof headers.set !== "function") return stub;
|
|
2882
|
+
for (const method of ["set", "append", "delete"]) {
|
|
2883
|
+
const original = headers[method].bind(headers);
|
|
2884
|
+
headers[method] = function (name, ...rest) {
|
|
2885
|
+
if (allowLateLocation && method === "set" && String(name).toLowerCase() === "location") {
|
|
2886
|
+
return original(name, ...rest);
|
|
2887
|
+
}
|
|
2888
|
+
reportLostHeaderWrite(method, name);
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
return stub;
|
|
2892
|
+
}
|
|
2794
2893
|
/*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
2795
2894
|
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
|
|
2796
2895
|
|
|
2797
2896
|
function scopeDeferredResult(value, scope) {
|
|
2897
|
+
const bound = bindDeferredBody(value, scope);
|
|
2898
|
+
if (bound !== value || value === null || typeof value !== "object") return bound;
|
|
2899
|
+
return scopeDeferredContents(value, scope);
|
|
2900
|
+
}
|
|
2901
|
+
class ScopeFrame {
|
|
2902
|
+
constructor(value, next, keys, descriptors) {
|
|
2903
|
+
this.value = value;
|
|
2904
|
+
this.next = next;
|
|
2905
|
+
this.keys = keys;
|
|
2906
|
+
this.descriptors = descriptors;
|
|
2907
|
+
this.i = 0;
|
|
2908
|
+
this.changed = false;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
function enterScopeCarrier(value, state) {
|
|
2912
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return value;
|
|
2913
|
+
if (state.seen.has(value)) {
|
|
2914
|
+
state.cyclic.add(value);
|
|
2915
|
+
return state.seen.get(value);
|
|
2916
|
+
}
|
|
2917
|
+
const bound = bindDeferredBody(value, state.scope);
|
|
2918
|
+
if (bound !== value) {
|
|
2919
|
+
state.seen.set(value, bound);
|
|
2920
|
+
return bound;
|
|
2921
|
+
}
|
|
2922
|
+
if (typeof value !== "object") return value;
|
|
2923
|
+
if (Array.isArray(value)) {
|
|
2924
|
+
if (Object.isFrozen(value)) {
|
|
2925
|
+
state.seen.set(value, value);
|
|
2926
|
+
return value;
|
|
2927
|
+
}
|
|
2928
|
+
const next = value.slice();
|
|
2929
|
+
state.seen.set(value, next);
|
|
2930
|
+
return new ScopeFrame(value, next, null, null);
|
|
2931
|
+
}
|
|
2932
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2933
|
+
if (prototype !== Object.prototype && prototype !== null || Object.isFrozen(value)) {
|
|
2934
|
+
state.seen.set(value, value);
|
|
2935
|
+
return value;
|
|
2936
|
+
}
|
|
2937
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
2938
|
+
const next = Object.create(prototype, descriptors);
|
|
2939
|
+
state.seen.set(value, next);
|
|
2940
|
+
return new ScopeFrame(value, next, Object.keys(value), descriptors);
|
|
2941
|
+
}
|
|
2942
|
+
function scopeDeferredContents(root, scope) {
|
|
2943
|
+
const state = {
|
|
2944
|
+
seen: new Map(),
|
|
2945
|
+
cyclic: new Set(),
|
|
2946
|
+
scope
|
|
2947
|
+
};
|
|
2948
|
+
const entered = enterScopeCarrier(root, state);
|
|
2949
|
+
if (!(entered instanceof ScopeFrame)) return entered;
|
|
2950
|
+
const stack = [entered];
|
|
2951
|
+
let delivered = NOTHING;
|
|
2952
|
+
for (;;) {
|
|
2953
|
+
const top = stack[stack.length - 1];
|
|
2954
|
+
const length = top.keys ? top.keys.length : top.value.length;
|
|
2955
|
+
let pushed = null;
|
|
2956
|
+
while (top.i < length) {
|
|
2957
|
+
const i = top.i;
|
|
2958
|
+
let original;
|
|
2959
|
+
let writable = true;
|
|
2960
|
+
if (top.keys) {
|
|
2961
|
+
const descriptor = top.descriptors[top.keys[i]];
|
|
2962
|
+
writable = "value" in descriptor && descriptor.writable === true;
|
|
2963
|
+
original = writable ? descriptor.value : undefined;
|
|
2964
|
+
} else {
|
|
2965
|
+
original = top.value[i];
|
|
2966
|
+
}
|
|
2967
|
+
if (!writable) {
|
|
2968
|
+
top.i++;
|
|
2969
|
+
continue;
|
|
2970
|
+
}
|
|
2971
|
+
let bound;
|
|
2972
|
+
if (delivered !== NOTHING) {
|
|
2973
|
+
bound = delivered;
|
|
2974
|
+
delivered = NOTHING;
|
|
2975
|
+
} else {
|
|
2976
|
+
bound = enterScopeCarrier(original, state);
|
|
2977
|
+
if (bound instanceof ScopeFrame) {
|
|
2978
|
+
pushed = bound;
|
|
2979
|
+
break;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
if (bound !== original) {
|
|
2983
|
+
if (top.keys) top.next[top.keys[i]] = bound;else top.next[i] = bound;
|
|
2984
|
+
top.changed = true;
|
|
2985
|
+
}
|
|
2986
|
+
top.i++;
|
|
2987
|
+
}
|
|
2988
|
+
if (pushed !== null) {
|
|
2989
|
+
stack.push(pushed);
|
|
2990
|
+
continue;
|
|
2991
|
+
}
|
|
2992
|
+
stack.pop();
|
|
2993
|
+
let out;
|
|
2994
|
+
if (top.changed || state.cyclic.has(top.value)) {
|
|
2995
|
+
out = top.next;
|
|
2996
|
+
} else {
|
|
2997
|
+
state.seen.set(top.value, top.value);
|
|
2998
|
+
out = top.value;
|
|
2999
|
+
}
|
|
3000
|
+
if (stack.length === 0) return out;
|
|
3001
|
+
delivered = out;
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
function bindDeferredBody(value, scope) {
|
|
2798
3005
|
if (value === null || typeof value !== "object" && typeof value !== "function") return value;
|
|
2799
3006
|
const promised = scope(() => nativePromise(value));
|
|
2800
3007
|
if (promised) {
|
|
@@ -2840,10 +3047,18 @@ function scopeDeferredResult(value, scope) {
|
|
|
2840
3047
|
}
|
|
2841
3048
|
return value;
|
|
2842
3049
|
}
|
|
3050
|
+
function processState(key, create) {
|
|
3051
|
+
const slot = Symbol.for(key);
|
|
3052
|
+
return globalThis[slot] || (globalThis[slot] = create());
|
|
3053
|
+
}
|
|
3054
|
+
processState("solid.ServerFunctionRegistrations", () => new Map());
|
|
3055
|
+
processState("solid.ServerFunctionMethods", () => new Map());
|
|
3056
|
+
processState("solid.ServerFunctionReferenceBindings", () => new WeakMap());
|
|
2843
3057
|
const INVOCATIONS = new WeakMap();
|
|
2844
3058
|
function getEventServerFunctionInvocation(event) {
|
|
2845
3059
|
return event && INVOCATIONS.get(event);
|
|
2846
3060
|
}
|
|
3061
|
+
new Set(Object.values(BodyFormat));
|
|
2847
3062
|
function guardFailures(value, state) {
|
|
2848
3063
|
if (!state) state = {
|
|
2849
3064
|
seen: new WeakMap(),
|
|
@@ -3068,7 +3283,7 @@ function enterGuard(value, state) {
|
|
|
3068
3283
|
return new Frame(SET, value, next, [...value], null);
|
|
3069
3284
|
}
|
|
3070
3285
|
const prototype = Object.getPrototypeOf(value);
|
|
3071
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
3286
|
+
if (prototype !== Object.prototype && prototype !== null && !(value instanceof Error)) {
|
|
3072
3287
|
state.seen.set(value, value);
|
|
3073
3288
|
return value;
|
|
3074
3289
|
}
|
|
@@ -3079,7 +3294,11 @@ function enterGuard(value, state) {
|
|
|
3079
3294
|
}
|
|
3080
3295
|
const next = Object.create(prototype, descriptors);
|
|
3081
3296
|
state.seen.set(value, next);
|
|
3082
|
-
|
|
3297
|
+
const children = !(value instanceof Error) ? Object.keys(value) : Object.getOwnPropertyNames(value).filter(key => {
|
|
3298
|
+
const descriptor = descriptors[key];
|
|
3299
|
+
return descriptor.enumerable || "value" in descriptor;
|
|
3300
|
+
});
|
|
3301
|
+
return new Frame(OBJECT, value, next, children, descriptors);
|
|
3083
3302
|
}
|
|
3084
3303
|
function keepGuarded(value, next, changed, state) {
|
|
3085
3304
|
if (changed || state.cyclic.has(value)) return next;
|
|
@@ -3167,9 +3386,11 @@ function serverComponentScope(render) {
|
|
|
3167
3386
|
return runInServerComponentScope ? runInServerComponentScope(render) : render();
|
|
3168
3387
|
}
|
|
3169
3388
|
function wirePreload(entry) {
|
|
3170
|
-
return {
|
|
3389
|
+
return entry.href ? {
|
|
3171
3390
|
href: entry.href,
|
|
3172
3391
|
attrs: entry.attrs
|
|
3392
|
+
} : {
|
|
3393
|
+
attrs: entry.attrs
|
|
3173
3394
|
};
|
|
3174
3395
|
}
|
|
3175
3396
|
const SERVER_COMPONENT_BOOTSTRAP_EXPR = "(self._$SC||(self._$SC={c:{},a:{},r(i,a){a&&(this.a[a]=i,this.reg&&this.reg(a,i));return this.c[i]||(this.c[i]=(p,b)=>self._$SC.impl(i,p,b))}}))";
|
package/frames/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web/frames",
|
|
3
|
-
"main": "./dist/server.
|
|
3
|
+
"main": "./dist/server.js",
|
|
4
4
|
"module": "./dist/server.js",
|
|
5
5
|
"types": "../types/frames/server.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -8,23 +8,15 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"browser": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"default": "./dist/client.js"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "../types-cjs/frames/client.d.cts",
|
|
17
|
-
"default": "./dist/client.cjs"
|
|
18
|
-
}
|
|
11
|
+
"types": "../types/frames/client.d.ts",
|
|
12
|
+
"default": "./dist/client.js"
|
|
19
13
|
},
|
|
20
|
-
"
|
|
14
|
+
"development": {
|
|
21
15
|
"types": "../types/frames/server.d.ts",
|
|
22
|
-
"default": "./dist/server.js"
|
|
16
|
+
"default": "./dist/server.dev.js"
|
|
23
17
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"default": "./dist/server.cjs"
|
|
27
|
-
}
|
|
18
|
+
"types": "../types/frames/server.d.ts",
|
|
19
|
+
"default": "./dist/server.js"
|
|
28
20
|
}
|
|
29
21
|
}
|
|
30
22
|
}
|