rwsdk 1.0.0-beta.21 → 1.0.0-beta.23
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineLinks } from "../lib/links.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineLinks } from "../lib/links.js";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { injectRSCPayload } from "rsc-html-stream/server";
|
|
3
|
+
import { ssrWebpackRequire } from "../imports/worker.js";
|
|
3
4
|
import { constructWithDefaultRequestInfo } from "../requestInfo/utils";
|
|
4
|
-
import { getRequestInfo } from "../requestInfo/worker";
|
|
5
|
+
import { getRequestInfo, runWithRequestInfo } from "../requestInfo/worker";
|
|
5
6
|
import { renderDocumentHtmlStream } from "./renderDocumentHtmlStream";
|
|
6
7
|
import { renderToRscStream } from "./renderToRscStream";
|
|
7
8
|
export const IdentityDocument = ({ children }) => (_jsx(_Fragment, { children: children }));
|
|
8
9
|
export const renderToStream = async (element, { ssr: shouldSSR = true, Document = IdentityDocument, injectRSCPayload: shouldInjectRSCPayload = true, requestInfo: givenRequestInfo, onError = () => { }, } = {}) => {
|
|
10
|
+
if (!globalThis.__webpack_require__) {
|
|
11
|
+
globalThis.__webpack_require__ = ssrWebpackRequire;
|
|
12
|
+
}
|
|
9
13
|
// Try to get the context requestInfo from the async store.
|
|
10
14
|
let contextRequestInfo;
|
|
11
15
|
try {
|
|
@@ -24,30 +28,36 @@ export const renderToStream = async (element, { ssr: shouldSSR = true, Document
|
|
|
24
28
|
...givenRequestInfo?.rw,
|
|
25
29
|
},
|
|
26
30
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
injectRSCStream = injectRSCPayload(rscPayloadStream2, {
|
|
39
|
-
nonce: requestInfo.rw.nonce,
|
|
31
|
+
// context(gching, 2025-10-29): We wrap the following with context to the requestInfo
|
|
32
|
+
// due to `ssrWebpackRequire` needing to reference the `requestInfo` in context.
|
|
33
|
+
// Therefore, we need to wrap + also pass in the requestInfo in their independent
|
|
34
|
+
// function calls
|
|
35
|
+
return runWithRequestInfo(requestInfo, async () => {
|
|
36
|
+
let rscStream = renderToRscStream({
|
|
37
|
+
input: {
|
|
38
|
+
node: element,
|
|
39
|
+
actionResult: undefined,
|
|
40
|
+
},
|
|
41
|
+
onError,
|
|
40
42
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
let injectRSCStream;
|
|
44
|
+
if (shouldInjectRSCPayload) {
|
|
45
|
+
const [rscPayloadStream1, rscPayloadStream2] = rscStream.tee();
|
|
46
|
+
rscStream = rscPayloadStream1;
|
|
47
|
+
injectRSCStream = injectRSCPayload(rscPayloadStream2, {
|
|
48
|
+
nonce: requestInfo.rw.nonce,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
let htmlStream = await renderDocumentHtmlStream({
|
|
52
|
+
rscPayloadStream: rscStream,
|
|
53
|
+
Document,
|
|
54
|
+
requestInfo,
|
|
55
|
+
shouldSSR,
|
|
56
|
+
onError,
|
|
57
|
+
});
|
|
58
|
+
if (injectRSCStream) {
|
|
59
|
+
htmlStream = htmlStream.pipeThrough(injectRSCStream);
|
|
60
|
+
}
|
|
61
|
+
return htmlStream;
|
|
48
62
|
});
|
|
49
|
-
if (injectRSCStream) {
|
|
50
|
-
htmlStream = htmlStream.pipeThrough(injectRSCStream);
|
|
51
|
-
}
|
|
52
|
-
return htmlStream;
|
|
53
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rwsdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.23",
|
|
4
4
|
"description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"./router": {
|
|
60
60
|
"types": "./dist/runtime/entries/router.d.ts",
|
|
61
|
-
"
|
|
61
|
+
"workerd": "./dist/runtime/entries/router.js",
|
|
62
|
+
"default": "./dist/runtime/entries/routerClient.js"
|
|
62
63
|
},
|
|
63
64
|
"./auth": {
|
|
64
65
|
"types": "./dist/runtime/entries/auth.d.ts",
|