@solidjs/web 2.0.0-rc.5 → 2.0.0-rc.7
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 +122 -38
- package/dist/server.dev.cjs +3794 -0
- package/dist/server.dev.js +3627 -0
- package/dist/server.js +123 -39
- package/dist/web.cjs +102 -366
- package/dist/{dev.cjs → web.dev.cjs} +153 -376
- package/dist/{dev.js → web.dev.js} +155 -374
- package/dist/web.js +104 -364
- package/frames/dist/client.cjs +11 -3
- package/frames/dist/client.dev.cjs +11 -3
- package/frames/dist/client.dev.js +11 -3
- package/frames/dist/client.js +11 -3
- package/frames/dist/server.cjs +320 -53
- package/frames/dist/server.dev.cjs +4584 -0
- package/frames/dist/server.dev.js +4571 -0
- package/frames/dist/server.js +320 -53
- package/frames/package.json +10 -0
- package/package.json +78 -8
- package/serialization/dist/decode.cjs +18 -4
- package/serialization/dist/decode.js +18 -4
- package/serialization/dist/serialization.cjs +18 -4
- package/serialization/dist/serialization.js +18 -4
- package/server-functions/dist/client.cjs +27 -16
- package/server-functions/dist/client.js +27 -16
- package/server-functions/dist/server.cjs +529 -131
- package/server-functions/dist/server.dev.cjs +536 -130
- package/server-functions/dist/server.dev.js +536 -130
- package/server-functions/dist/server.js +529 -131
- package/types/client.d.ts +1 -3
- package/types/constants.d.ts +3 -1
- package/types/frames/frame-client.d.ts +1 -1
- 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/server-functions/flash.d.ts +12 -3
- package/types/server-functions/server.d.ts +100 -5
- package/types/server-mock.d.ts +43 -7
- package/types/server.d.ts +47 -5
- package/types-cjs/client.d.cts +1 -3
- package/types-cjs/constants.d.cts +3 -1
- package/types-cjs/frames/frame-client.d.cts +1 -1
- package/types-cjs/head.d.cts +3 -0
- package/types-cjs/index.d.cts +18 -7
- package/types-cjs/index.server.d.cts +31 -9
- package/types-cjs/render.d.cts +3 -1
- package/types-cjs/server-functions/flash.d.cts +12 -3
- package/types-cjs/server-functions/server.d.cts +100 -5
- package/types-cjs/server-mock.d.cts +43 -7
- package/types-cjs/server.d.cts +47 -5
- package/types/patch-driver.d.ts +0 -3
- package/types-cjs/patch-driver.d.cts +0 -3
package/frames/dist/server.js
CHANGED
|
@@ -99,6 +99,8 @@ const ContainerTracePlugin = {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
|
|
103
|
+
|
|
102
104
|
setContainerTraceStreamMint(iterable => {
|
|
103
105
|
const stream = createStream();
|
|
104
106
|
(async () => {
|
|
@@ -289,6 +291,18 @@ const ERROR_HEADER = "X-Server-Function-Error";
|
|
|
289
291
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
290
292
|
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
291
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
|
+
};
|
|
292
306
|
function createChunk(data) {
|
|
293
307
|
const encoder = new TextEncoder();
|
|
294
308
|
const encodeData = encoder.encode(data);
|
|
@@ -424,12 +438,24 @@ function classifyHeadTag(desc) {
|
|
|
424
438
|
resource: false
|
|
425
439
|
};
|
|
426
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
|
+
}
|
|
427
452
|
function resourceIdentity(tag, props) {
|
|
428
|
-
|
|
453
|
+
const url = String(props.href || props.src || "");
|
|
454
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
429
455
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
430
456
|
const q = RESOURCE_QUALIFIERS[i];
|
|
431
|
-
const value = props[q];
|
|
432
|
-
if (value
|
|
457
|
+
const value = qualifierValue(q, props[q]);
|
|
458
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
433
459
|
}
|
|
434
460
|
return id;
|
|
435
461
|
}
|
|
@@ -503,12 +529,20 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
503
529
|
if (e.preloads) {
|
|
504
530
|
for (let i = 0; i < e.preloads.length; i++) {
|
|
505
531
|
const link = e.preloads[i];
|
|
506
|
-
|
|
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;
|
|
507
535
|
if (!preloads) preloads = [];
|
|
508
|
-
preloads.push({
|
|
536
|
+
if (href) preloads.push({
|
|
509
537
|
...link,
|
|
510
|
-
href: joinAssetPath(base,
|
|
511
|
-
});
|
|
538
|
+
href: joinAssetPath(base, href)
|
|
539
|
+
});else {
|
|
540
|
+
const {
|
|
541
|
+
href: bad,
|
|
542
|
+
...rest
|
|
543
|
+
} = link;
|
|
544
|
+
preloads.push(rest);
|
|
545
|
+
}
|
|
512
546
|
}
|
|
513
547
|
}
|
|
514
548
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
@@ -640,9 +674,13 @@ function isCssUrl(url) {
|
|
|
640
674
|
const q = url.search(/[?#]/);
|
|
641
675
|
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
642
676
|
}
|
|
643
|
-
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"];
|
|
644
682
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
645
|
-
if (!link || typeof link !== "object"
|
|
683
|
+
if (!link || typeof link !== "object") {
|
|
646
684
|
return null;
|
|
647
685
|
}
|
|
648
686
|
if (typeof link.as !== "string") {
|
|
@@ -663,13 +701,35 @@ function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
|
663
701
|
default:
|
|
664
702
|
return null;
|
|
665
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
|
+
}
|
|
666
721
|
const props = {
|
|
667
|
-
rel: "preload"
|
|
668
|
-
href: link.href,
|
|
669
|
-
as
|
|
722
|
+
rel: "preload"
|
|
670
723
|
};
|
|
724
|
+
if (href) props.href = href;
|
|
725
|
+
props.as = as;
|
|
671
726
|
for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
|
|
672
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
|
+
}
|
|
673
733
|
const value = link[name];
|
|
674
734
|
if (value == null || value === false) continue;
|
|
675
735
|
props[name] = value === true ? "" : String(value);
|
|
@@ -1034,9 +1094,6 @@ function normalizeNonce(nonce) {
|
|
|
1034
1094
|
styleAttr: typeof style === "string" && style ? ` nonce="${escape(style, true)}"` : ""
|
|
1035
1095
|
};
|
|
1036
1096
|
}
|
|
1037
|
-
function asciiLowerCase(value) {
|
|
1038
|
-
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
1039
|
-
}
|
|
1040
1097
|
function hasNonceProp(props) {
|
|
1041
1098
|
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
1042
1099
|
return false;
|
|
@@ -1117,6 +1174,7 @@ function renderToStream(code, options = {}) {
|
|
|
1117
1174
|
onHead
|
|
1118
1175
|
} = options;
|
|
1119
1176
|
const nonce = normalizeNonce(options.nonce);
|
|
1177
|
+
const requestEvent = peekRequestEvent();
|
|
1120
1178
|
let dispose;
|
|
1121
1179
|
let dead = false;
|
|
1122
1180
|
const abandon = () => {
|
|
@@ -1218,6 +1276,7 @@ function renderToStream(code, options = {}) {
|
|
|
1218
1276
|
};
|
|
1219
1277
|
const onDone = () => {
|
|
1220
1278
|
writeTasks();
|
|
1279
|
+
lastBlockingSize = blockingPromises.size;
|
|
1221
1280
|
doShell();
|
|
1222
1281
|
onCompleteAll && onCompleteAll({
|
|
1223
1282
|
write(v) {
|
|
@@ -1607,9 +1666,9 @@ function renderToStream(code, options = {}) {
|
|
|
1607
1666
|
function doShell() {
|
|
1608
1667
|
if (shellCompleted) return;
|
|
1609
1668
|
sharedConfig.context = context;
|
|
1610
|
-
|
|
1669
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1611
1670
|
if (!resolveRootHoles()) return;
|
|
1612
|
-
if (blockingPromises.size !==
|
|
1671
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1613
1672
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1614
1673
|
headStyles = new Set();
|
|
1615
1674
|
for (const url of tracking.emittedAssets) {
|
|
@@ -1637,7 +1696,7 @@ function renderToStream(code, options = {}) {
|
|
|
1637
1696
|
let lastBlockingSize = -1;
|
|
1638
1697
|
let lastRegistrySize = -1;
|
|
1639
1698
|
let drainTurn = 0;
|
|
1640
|
-
const scheduleFlush = fn => {
|
|
1699
|
+
const scheduleFlush = (fn, awaited) => {
|
|
1641
1700
|
const attempt = () => {
|
|
1642
1701
|
flushStubBatch();
|
|
1643
1702
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
@@ -1648,8 +1707,8 @@ function renderToStream(code, options = {}) {
|
|
|
1648
1707
|
}
|
|
1649
1708
|
fn();
|
|
1650
1709
|
};
|
|
1651
|
-
const progressed =
|
|
1652
|
-
lastBlockingSize =
|
|
1710
|
+
const progressed = awaited !== lastBlockingSize;
|
|
1711
|
+
lastBlockingSize = awaited;
|
|
1653
1712
|
lastRegistrySize = -1;
|
|
1654
1713
|
drainTurn = 0;
|
|
1655
1714
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
@@ -1666,7 +1725,7 @@ function renderToStream(code, options = {}) {
|
|
|
1666
1725
|
let resolve;
|
|
1667
1726
|
const p = new Promise(r => resolve = r);
|
|
1668
1727
|
function flush() {
|
|
1669
|
-
allSettled(blockingPromises).then(
|
|
1728
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1670
1729
|
scheduleFlush(() => {
|
|
1671
1730
|
if (dead) return resolve();
|
|
1672
1731
|
try {
|
|
@@ -1704,7 +1763,7 @@ function renderToStream(code, options = {}) {
|
|
|
1704
1763
|
dispose();
|
|
1705
1764
|
writable.end();
|
|
1706
1765
|
} else flushEnd();
|
|
1707
|
-
});
|
|
1766
|
+
}, awaited);
|
|
1708
1767
|
});
|
|
1709
1768
|
}
|
|
1710
1769
|
flush();
|
|
@@ -1712,8 +1771,12 @@ function renderToStream(code, options = {}) {
|
|
|
1712
1771
|
};
|
|
1713
1772
|
return {
|
|
1714
1773
|
then(onFulfilled, onRejected) {
|
|
1774
|
+
const freezeHead = () => {
|
|
1775
|
+
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response);
|
|
1776
|
+
};
|
|
1715
1777
|
const p = new Promise(resolve => {
|
|
1716
1778
|
function complete() {
|
|
1779
|
+
freezeHead();
|
|
1717
1780
|
dispose();
|
|
1718
1781
|
resolve(tmp);
|
|
1719
1782
|
}
|
|
@@ -1725,17 +1788,16 @@ function renderToStream(code, options = {}) {
|
|
|
1725
1788
|
};
|
|
1726
1789
|
} else onCompleteAll = complete;
|
|
1727
1790
|
function flush() {
|
|
1728
|
-
allSettled(blockingPromises).then(
|
|
1791
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1729
1792
|
scheduleFlush(() => {
|
|
1730
1793
|
try {
|
|
1731
|
-
|
|
1732
|
-
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();
|
|
1733
1795
|
} catch (err) {
|
|
1734
1796
|
failRender(err);
|
|
1735
1797
|
return resolve(tmp);
|
|
1736
1798
|
}
|
|
1737
1799
|
queue(flushEnd);
|
|
1738
|
-
});
|
|
1800
|
+
}, awaited);
|
|
1739
1801
|
});
|
|
1740
1802
|
}
|
|
1741
1803
|
flush();
|
|
@@ -1745,7 +1807,7 @@ function renderToStream(code, options = {}) {
|
|
|
1745
1807
|
pipe(w) {
|
|
1746
1808
|
claimConsumer("pipe");
|
|
1747
1809
|
function flush() {
|
|
1748
|
-
allSettled(blockingPromises).then(
|
|
1810
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1749
1811
|
scheduleFlush(() => {
|
|
1750
1812
|
if (dead) return;
|
|
1751
1813
|
try {
|
|
@@ -1767,7 +1829,7 @@ function renderToStream(code, options = {}) {
|
|
|
1767
1829
|
dispose();
|
|
1768
1830
|
writable.end();
|
|
1769
1831
|
} else flushEnd();
|
|
1770
|
-
});
|
|
1832
|
+
}, awaited);
|
|
1771
1833
|
});
|
|
1772
1834
|
}
|
|
1773
1835
|
flush();
|
|
@@ -2539,7 +2601,7 @@ function allSettled(promises) {
|
|
|
2539
2601
|
let size = promises.size;
|
|
2540
2602
|
return Promise.allSettled(promises).then(() => {
|
|
2541
2603
|
if (promises.size !== size) return allSettled(promises);
|
|
2542
|
-
return;
|
|
2604
|
+
return size;
|
|
2543
2605
|
});
|
|
2544
2606
|
}
|
|
2545
2607
|
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
@@ -2789,12 +2851,195 @@ function resolveSSRSync(node) {
|
|
|
2789
2851
|
if (!res.h.length) return res.t[0];
|
|
2790
2852
|
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
2791
2853
|
}
|
|
2792
|
-
|
|
2854
|
+
const RequestContext = Symbol.for("solid.RequestContext");
|
|
2855
|
+
function peekRequestEvent() {
|
|
2856
|
+
const store = globalThis[RequestContext];
|
|
2857
|
+
return store ? store.getStore() : undefined;
|
|
2858
|
+
}
|
|
2859
|
+
function reportLostHeaderWrite(method, name) {
|
|
2860
|
+
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).";
|
|
2861
|
+
console.error(message);
|
|
2862
|
+
}
|
|
2863
|
+
function commitResponseStub(stub, {
|
|
2864
|
+
allowLateLocation = false
|
|
2865
|
+
} = {}) {
|
|
2866
|
+
if (!stub || stub.committed) return stub;
|
|
2867
|
+
stub.committed = true;
|
|
2868
|
+
const headers = stub.headers;
|
|
2869
|
+
if (!headers || typeof headers.set !== "function") return stub;
|
|
2870
|
+
for (const method of ["set", "append", "delete"]) {
|
|
2871
|
+
const original = headers[method].bind(headers);
|
|
2872
|
+
headers[method] = function (name, ...rest) {
|
|
2873
|
+
if (allowLateLocation && method === "set" && String(name).toLowerCase() === "location") {
|
|
2874
|
+
return original(name, ...rest);
|
|
2875
|
+
}
|
|
2876
|
+
reportLostHeaderWrite(method, name);
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2879
|
+
return stub;
|
|
2880
|
+
}
|
|
2881
|
+
/*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
2882
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
|
|
2793
2883
|
|
|
2884
|
+
function scopeDeferredResult(value, scope) {
|
|
2885
|
+
const bound = bindDeferredBody(value, scope);
|
|
2886
|
+
if (bound !== value || value === null || typeof value !== "object") return bound;
|
|
2887
|
+
return scopeDeferredContents(value, scope);
|
|
2888
|
+
}
|
|
2889
|
+
class ScopeFrame {
|
|
2890
|
+
constructor(value, next, keys, descriptors) {
|
|
2891
|
+
this.value = value;
|
|
2892
|
+
this.next = next;
|
|
2893
|
+
this.keys = keys;
|
|
2894
|
+
this.descriptors = descriptors;
|
|
2895
|
+
this.i = 0;
|
|
2896
|
+
this.changed = false;
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
function enterScopeCarrier(value, state) {
|
|
2900
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return value;
|
|
2901
|
+
if (state.seen.has(value)) {
|
|
2902
|
+
state.cyclic.add(value);
|
|
2903
|
+
return state.seen.get(value);
|
|
2904
|
+
}
|
|
2905
|
+
const bound = bindDeferredBody(value, state.scope);
|
|
2906
|
+
if (bound !== value) {
|
|
2907
|
+
state.seen.set(value, bound);
|
|
2908
|
+
return bound;
|
|
2909
|
+
}
|
|
2910
|
+
if (typeof value !== "object") return value;
|
|
2911
|
+
if (Array.isArray(value)) {
|
|
2912
|
+
if (Object.isFrozen(value)) {
|
|
2913
|
+
state.seen.set(value, value);
|
|
2914
|
+
return value;
|
|
2915
|
+
}
|
|
2916
|
+
const next = value.slice();
|
|
2917
|
+
state.seen.set(value, next);
|
|
2918
|
+
return new ScopeFrame(value, next, null, null);
|
|
2919
|
+
}
|
|
2920
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2921
|
+
if (prototype !== Object.prototype && prototype !== null || Object.isFrozen(value)) {
|
|
2922
|
+
state.seen.set(value, value);
|
|
2923
|
+
return value;
|
|
2924
|
+
}
|
|
2925
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
2926
|
+
const next = Object.create(prototype, descriptors);
|
|
2927
|
+
state.seen.set(value, next);
|
|
2928
|
+
return new ScopeFrame(value, next, Object.keys(value), descriptors);
|
|
2929
|
+
}
|
|
2930
|
+
function scopeDeferredContents(root, scope) {
|
|
2931
|
+
const state = {
|
|
2932
|
+
seen: new Map(),
|
|
2933
|
+
cyclic: new Set(),
|
|
2934
|
+
scope
|
|
2935
|
+
};
|
|
2936
|
+
const entered = enterScopeCarrier(root, state);
|
|
2937
|
+
if (!(entered instanceof ScopeFrame)) return entered;
|
|
2938
|
+
const stack = [entered];
|
|
2939
|
+
let delivered = NOTHING;
|
|
2940
|
+
for (;;) {
|
|
2941
|
+
const top = stack[stack.length - 1];
|
|
2942
|
+
const length = top.keys ? top.keys.length : top.value.length;
|
|
2943
|
+
let pushed = null;
|
|
2944
|
+
while (top.i < length) {
|
|
2945
|
+
const i = top.i;
|
|
2946
|
+
let original;
|
|
2947
|
+
let writable = true;
|
|
2948
|
+
if (top.keys) {
|
|
2949
|
+
const descriptor = top.descriptors[top.keys[i]];
|
|
2950
|
+
writable = "value" in descriptor && descriptor.writable === true;
|
|
2951
|
+
original = writable ? descriptor.value : undefined;
|
|
2952
|
+
} else {
|
|
2953
|
+
original = top.value[i];
|
|
2954
|
+
}
|
|
2955
|
+
if (!writable) {
|
|
2956
|
+
top.i++;
|
|
2957
|
+
continue;
|
|
2958
|
+
}
|
|
2959
|
+
let bound;
|
|
2960
|
+
if (delivered !== NOTHING) {
|
|
2961
|
+
bound = delivered;
|
|
2962
|
+
delivered = NOTHING;
|
|
2963
|
+
} else {
|
|
2964
|
+
bound = enterScopeCarrier(original, state);
|
|
2965
|
+
if (bound instanceof ScopeFrame) {
|
|
2966
|
+
pushed = bound;
|
|
2967
|
+
break;
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
if (bound !== original) {
|
|
2971
|
+
if (top.keys) top.next[top.keys[i]] = bound;else top.next[i] = bound;
|
|
2972
|
+
top.changed = true;
|
|
2973
|
+
}
|
|
2974
|
+
top.i++;
|
|
2975
|
+
}
|
|
2976
|
+
if (pushed !== null) {
|
|
2977
|
+
stack.push(pushed);
|
|
2978
|
+
continue;
|
|
2979
|
+
}
|
|
2980
|
+
stack.pop();
|
|
2981
|
+
let out;
|
|
2982
|
+
if (top.changed || state.cyclic.has(top.value)) {
|
|
2983
|
+
out = top.next;
|
|
2984
|
+
} else {
|
|
2985
|
+
state.seen.set(top.value, top.value);
|
|
2986
|
+
out = top.value;
|
|
2987
|
+
}
|
|
2988
|
+
if (stack.length === 0) return out;
|
|
2989
|
+
delivered = out;
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
function bindDeferredBody(value, scope) {
|
|
2993
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return value;
|
|
2994
|
+
const promised = scope(() => nativePromise(value));
|
|
2995
|
+
if (promised) {
|
|
2996
|
+
return promised.then(result => scope(() => scopeDeferredResult(result, scope)));
|
|
2997
|
+
}
|
|
2998
|
+
if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) {
|
|
2999
|
+
let reader;
|
|
3000
|
+
return new ReadableStream({
|
|
3001
|
+
async pull(controller) {
|
|
3002
|
+
try {
|
|
3003
|
+
const step = await scope(() => {
|
|
3004
|
+
if (!reader) reader = value.getReader();
|
|
3005
|
+
return reader.read();
|
|
3006
|
+
});
|
|
3007
|
+
if (step.done) controller.close();else controller.enqueue(step.value);
|
|
3008
|
+
} catch (error) {
|
|
3009
|
+
controller.error(error);
|
|
3010
|
+
}
|
|
3011
|
+
},
|
|
3012
|
+
cancel(reason) {
|
|
3013
|
+
return scope(() => reader ? reader.cancel(reason) : value.cancel(reason));
|
|
3014
|
+
}
|
|
3015
|
+
}, {
|
|
3016
|
+
highWaterMark: 0
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
const scopedIterator = symbol => ({
|
|
3020
|
+
[symbol]() {
|
|
3021
|
+
const iterator = scope(() => value[symbol]());
|
|
3022
|
+
return new Proxy(iterator, {
|
|
3023
|
+
get(target, property) {
|
|
3024
|
+
const member = Reflect.get(target, property, target);
|
|
3025
|
+
return typeof member === "function" && (property === "next" || property === "return" || property === "throw") ? (...args) => scope(() => member.apply(target, args)) : member;
|
|
3026
|
+
}
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
if (typeof value[Symbol.asyncIterator] === "function") {
|
|
3031
|
+
return scopedIterator(Symbol.asyncIterator);
|
|
3032
|
+
}
|
|
3033
|
+
if (typeof value[Symbol.iterator] === "function" && !Array.isArray(value) && !(value instanceof Map) && !(value instanceof Set) && !ArrayBuffer.isView(value)) {
|
|
3034
|
+
return scopedIterator(Symbol.iterator);
|
|
3035
|
+
}
|
|
3036
|
+
return value;
|
|
3037
|
+
}
|
|
2794
3038
|
const INVOCATIONS = new WeakMap();
|
|
2795
3039
|
function getEventServerFunctionInvocation(event) {
|
|
2796
3040
|
return event && INVOCATIONS.get(event);
|
|
2797
3041
|
}
|
|
3042
|
+
new Set(Object.values(BodyFormat));
|
|
2798
3043
|
function guardFailures(value, state) {
|
|
2799
3044
|
if (!state) state = {
|
|
2800
3045
|
seen: new WeakMap(),
|
|
@@ -2855,14 +3100,11 @@ function guardFailures(value, state) {
|
|
|
2855
3100
|
top.next.add(guarded);
|
|
2856
3101
|
if (guarded !== original) top.changed = true;
|
|
2857
3102
|
} else if (guarded !== original || top.accessorRead === i) {
|
|
2858
|
-
Object.defineProperty(top.next, items[i],
|
|
2859
|
-
|
|
2860
|
-
configurable: true,
|
|
3103
|
+
Object.defineProperty(top.next, items[i], {
|
|
3104
|
+
value: guarded,
|
|
2861
3105
|
writable: true,
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
...top.descriptors[items[i]],
|
|
2865
|
-
value: guarded
|
|
3106
|
+
configurable: true,
|
|
3107
|
+
enumerable: top.descriptors[items[i]].enumerable
|
|
2866
3108
|
});
|
|
2867
3109
|
top.changed = true;
|
|
2868
3110
|
}
|
|
@@ -2897,6 +3139,9 @@ class Frame {
|
|
|
2897
3139
|
this.pendingKey = undefined;
|
|
2898
3140
|
}
|
|
2899
3141
|
}
|
|
3142
|
+
function guardOperation(state, run) {
|
|
3143
|
+
return state.scope ? state.scope(run) : run();
|
|
3144
|
+
}
|
|
2900
3145
|
function enterGuard(value, state) {
|
|
2901
3146
|
if (value === null || typeof value !== "object") return value;
|
|
2902
3147
|
if (state.seen.has(value)) {
|
|
@@ -2911,7 +3156,7 @@ function enterGuard(value, state) {
|
|
|
2911
3156
|
if (finished) return;
|
|
2912
3157
|
finished = true;
|
|
2913
3158
|
try {
|
|
2914
|
-
const cancelled = reader ? reader.cancel() : value.cancel();
|
|
3159
|
+
const cancelled = guardOperation(state, () => reader ? reader.cancel() : value.cancel());
|
|
2915
3160
|
if (cancelled && typeof cancelled.then === "function") cancelled.then(undefined, () => {});
|
|
2916
3161
|
} catch {}
|
|
2917
3162
|
};
|
|
@@ -2923,19 +3168,19 @@ function enterGuard(value, state) {
|
|
|
2923
3168
|
controller.close();
|
|
2924
3169
|
return;
|
|
2925
3170
|
}
|
|
2926
|
-
if (!reader) reader = value.getReader();
|
|
3171
|
+
if (!reader) reader = guardOperation(state, () => value.getReader());
|
|
2927
3172
|
const {
|
|
2928
3173
|
done,
|
|
2929
3174
|
value: chunk
|
|
2930
|
-
} = await reader.read();
|
|
2931
|
-
done ? controller.close() : controller.enqueue(guardFailures(chunk, state));
|
|
3175
|
+
} = await guardOperation(state, () => reader.read());
|
|
3176
|
+
done ? controller.close() : controller.enqueue(guardOperation(state, () => guardFailures(chunk, state)));
|
|
2932
3177
|
} catch (error) {
|
|
2933
|
-
controller.error(sanitizeServerError(error));
|
|
3178
|
+
controller.error(guardOperation(state, () => sanitizeServerError(error)));
|
|
2934
3179
|
}
|
|
2935
3180
|
},
|
|
2936
3181
|
cancel(reason) {
|
|
2937
3182
|
finished = true;
|
|
2938
|
-
return reader ? reader.cancel(reason) : value.cancel(reason);
|
|
3183
|
+
return guardOperation(state, () => reader ? reader.cancel(reason) : value.cancel(reason));
|
|
2939
3184
|
}
|
|
2940
3185
|
});
|
|
2941
3186
|
if (gate) gate.onOpen(close);
|
|
@@ -2943,9 +3188,10 @@ function enterGuard(value, state) {
|
|
|
2943
3188
|
return guardedStream;
|
|
2944
3189
|
}
|
|
2945
3190
|
if (typeof value.then === "function") {
|
|
2946
|
-
const guardedPromise = Promise.resolve(value).then(resolved => guardFailures(resolved, state), error => {
|
|
2947
|
-
throw sanitizeServerError(error);
|
|
3191
|
+
const guardedPromise = Promise.resolve(value).then(resolved => guardOperation(state, () => guardFailures(resolved, state)), error => {
|
|
3192
|
+
throw guardOperation(state, () => sanitizeServerError(error));
|
|
2948
3193
|
});
|
|
3194
|
+
guardedPromise.catch(() => {});
|
|
2949
3195
|
state.seen.set(value, guardedPromise);
|
|
2950
3196
|
return guardedPromise;
|
|
2951
3197
|
}
|
|
@@ -2954,13 +3200,13 @@ function enterGuard(value, state) {
|
|
|
2954
3200
|
const gate = state.gate;
|
|
2955
3201
|
const guardedIterable = {
|
|
2956
3202
|
[Symbol.asyncIterator]() {
|
|
2957
|
-
const iterator = source[Symbol.asyncIterator]();
|
|
3203
|
+
const iterator = guardOperation(state, () => source[Symbol.asyncIterator]());
|
|
2958
3204
|
let finished = false;
|
|
2959
3205
|
const close = () => {
|
|
2960
3206
|
if (finished) return;
|
|
2961
3207
|
finished = true;
|
|
2962
3208
|
try {
|
|
2963
|
-
const returned = iterator.return && iterator.return();
|
|
3209
|
+
const returned = iterator.return && guardOperation(state, () => iterator.return());
|
|
2964
3210
|
if (returned && typeof returned.then === "function") returned.then(undefined, () => {});
|
|
2965
3211
|
} catch {}
|
|
2966
3212
|
};
|
|
@@ -2968,17 +3214,17 @@ function enterGuard(value, state) {
|
|
|
2968
3214
|
const step = () => finished ? Promise.resolve({
|
|
2969
3215
|
done: true,
|
|
2970
3216
|
value: undefined
|
|
2971
|
-
}) : iterator.next().then(step => {
|
|
3217
|
+
}) : guardOperation(state, () => iterator.next()).then(step => {
|
|
2972
3218
|
if (step.done) {
|
|
2973
3219
|
finished = true;
|
|
2974
3220
|
return step;
|
|
2975
3221
|
}
|
|
2976
3222
|
return {
|
|
2977
3223
|
done: false,
|
|
2978
|
-
value: guardFailures(step.value, state)
|
|
3224
|
+
value: guardOperation(state, () => guardFailures(step.value, state))
|
|
2979
3225
|
};
|
|
2980
3226
|
}, error => {
|
|
2981
|
-
throw sanitizeServerError(error);
|
|
3227
|
+
throw guardOperation(state, () => sanitizeServerError(error));
|
|
2982
3228
|
});
|
|
2983
3229
|
return {
|
|
2984
3230
|
next: () => finished || !gate || gate.wantsMore() ? step() : gate.awaitDemand().then(step),
|
|
@@ -2995,6 +3241,11 @@ function enterGuard(value, state) {
|
|
|
2995
3241
|
state.seen.set(value, guardedIterable);
|
|
2996
3242
|
return guardedIterable;
|
|
2997
3243
|
}
|
|
3244
|
+
if (state.scope && typeof value[Symbol.iterator] === "function" && !Array.isArray(value) && !(value instanceof Map) && !(value instanceof Set) && !ArrayBuffer.isView(value)) {
|
|
3245
|
+
const scopedIterable = scopeDeferredResult(value, state.scope);
|
|
3246
|
+
state.seen.set(value, scopedIterable);
|
|
3247
|
+
return scopedIterable;
|
|
3248
|
+
}
|
|
2998
3249
|
if (Array.isArray(value)) {
|
|
2999
3250
|
const next = value.slice();
|
|
3000
3251
|
state.seen.set(value, next);
|
|
@@ -3013,14 +3264,22 @@ function enterGuard(value, state) {
|
|
|
3013
3264
|
return new Frame(SET, value, next, [...value], null);
|
|
3014
3265
|
}
|
|
3015
3266
|
const prototype = Object.getPrototypeOf(value);
|
|
3016
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
3267
|
+
if (prototype !== Object.prototype && prototype !== null && !(value instanceof Error)) {
|
|
3017
3268
|
state.seen.set(value, value);
|
|
3018
3269
|
return value;
|
|
3019
3270
|
}
|
|
3020
3271
|
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
3272
|
+
for (const key of Object.keys(descriptors)) {
|
|
3273
|
+
descriptors[key].configurable = true;
|
|
3274
|
+
if ("value" in descriptors[key]) descriptors[key].writable = true;
|
|
3275
|
+
}
|
|
3021
3276
|
const next = Object.create(prototype, descriptors);
|
|
3022
3277
|
state.seen.set(value, next);
|
|
3023
|
-
|
|
3278
|
+
const children = !(value instanceof Error) ? Object.keys(value) : Object.getOwnPropertyNames(value).filter(key => {
|
|
3279
|
+
const descriptor = descriptors[key];
|
|
3280
|
+
return descriptor.enumerable || "value" in descriptor;
|
|
3281
|
+
});
|
|
3282
|
+
return new Frame(OBJECT, value, next, children, descriptors);
|
|
3024
3283
|
}
|
|
3025
3284
|
function keepGuarded(value, next, changed, state) {
|
|
3026
3285
|
if (changed || state.cyclic.has(value)) return next;
|
|
@@ -3032,6 +3291,12 @@ function sanitizeServerError(value) {
|
|
|
3032
3291
|
if (isSafeError(value)) return value;
|
|
3033
3292
|
return new Error(GENERIC_SERVER_ERROR_MESSAGE);
|
|
3034
3293
|
}
|
|
3294
|
+
function nativePromise(value) {
|
|
3295
|
+
if (value instanceof Promise) return value;
|
|
3296
|
+
try {
|
|
3297
|
+
if (Object.prototype.toString.call(value) === "[object Promise]") return Promise.prototype.then.call(value, value => value);
|
|
3298
|
+
} catch {}
|
|
3299
|
+
}
|
|
3035
3300
|
|
|
3036
3301
|
const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
3037
3302
|
function isFrameStreamResponse(response) {
|
|
@@ -3102,9 +3367,11 @@ function serverComponentScope(render) {
|
|
|
3102
3367
|
return runInServerComponentScope ? runInServerComponentScope(render) : render();
|
|
3103
3368
|
}
|
|
3104
3369
|
function wirePreload(entry) {
|
|
3105
|
-
return {
|
|
3370
|
+
return entry.href ? {
|
|
3106
3371
|
href: entry.href,
|
|
3107
3372
|
attrs: entry.attrs
|
|
3373
|
+
} : {
|
|
3374
|
+
attrs: entry.attrs
|
|
3108
3375
|
};
|
|
3109
3376
|
}
|
|
3110
3377
|
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
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
"default": "./dist/client.cjs"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
+
"development": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "../types/frames/server.d.ts",
|
|
23
|
+
"default": "./dist/server.dev.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "../types-cjs/frames/server.d.cts",
|
|
27
|
+
"default": "./dist/server.dev.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
20
30
|
"import": {
|
|
21
31
|
"types": "../types/frames/server.d.ts",
|
|
22
32
|
"default": "./dist/server.js"
|