@modern-js/render 3.0.5 → 3.1.1
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/cjs/rsc-html-stream/server.js +3 -3
- package/dist/cjs/server/rsc/csr.js +1 -1
- package/dist/cjs/server/ssr/ssr.js +9 -2
- package/dist/esm/rsc-html-stream/server.js +3 -3
- package/dist/esm/server/rsc/csr.js +1 -1
- package/dist/esm/server/ssr/ssr.js +9 -2
- package/dist/esm-node/rsc-html-stream/server.mjs +3 -3
- package/dist/esm-node/server/rsc/csr.mjs +1 -1
- package/dist/esm-node/server/ssr/ssr.mjs +9 -2
- package/package.json +6 -6
|
@@ -23,7 +23,7 @@ __export(server_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(server_exports);
|
|
25
25
|
const encoder = new TextEncoder();
|
|
26
|
-
const
|
|
26
|
+
const closingTagsPattern = /<\/body>\s*<\/html>\s*$/i;
|
|
27
27
|
function injectRSCPayload(rscStream, { injectClosingTags = true }) {
|
|
28
28
|
const decoder = new TextDecoder();
|
|
29
29
|
let resolveFlightDataPromise;
|
|
@@ -34,8 +34,8 @@ function injectRSCPayload(rscStream, { injectClosingTags = true }) {
|
|
|
34
34
|
function flushBufferedChunks(controller) {
|
|
35
35
|
for (const chunk of buffered) {
|
|
36
36
|
let buf = decoder.decode(chunk);
|
|
37
|
-
if (
|
|
38
|
-
buf = buf.
|
|
37
|
+
if (closingTagsPattern.test(buf)) {
|
|
38
|
+
buf = buf.replace(closingTagsPattern, "");
|
|
39
39
|
}
|
|
40
40
|
controller.enqueue(encoder.encode(buf));
|
|
41
41
|
}
|
|
@@ -39,7 +39,7 @@ async function renderCSRWithRSC(options) {
|
|
|
39
39
|
const stream = htmlStream.pipeThrough((0, import_server.injectCSS)(cssFiles, {
|
|
40
40
|
injectClosingTags: false
|
|
41
41
|
})).pipeThrough((0, import_server.injectRSCPayload)(rscPayloadStream, {
|
|
42
|
-
injectClosingTags:
|
|
42
|
+
injectClosingTags: true
|
|
43
43
|
}));
|
|
44
44
|
return new Response(stream, {
|
|
45
45
|
status: 200,
|
|
@@ -32,6 +32,7 @@ __export(ssr_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(ssr_exports);
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_constants = require("@modern-js/utils/universal/constants");
|
|
35
36
|
var import_server = require("react-dom/server.edge");
|
|
36
37
|
var import_client = require("../../client/index");
|
|
37
38
|
function CSSLinks({ cssFiles }) {
|
|
@@ -62,7 +63,10 @@ const renderSSRStream = async (children, options) => {
|
|
|
62
63
|
const entryCssFiles = (__rspack_rsc_manifest__3 = __rspack_rsc_manifest__) === null || __rspack_rsc_manifest__3 === void 0 ? void 0 : __rspack_rsc_manifest__3.entryCssFiles;
|
|
63
64
|
const hasRoutes = Boolean(routes && routes.length > 0);
|
|
64
65
|
if (!clientManifest || !serverConsumerModuleMap) {
|
|
65
|
-
return (0, import_server.renderToReadableStream)(children,
|
|
66
|
+
return (0, import_server.renderToReadableStream)(children, {
|
|
67
|
+
...options,
|
|
68
|
+
identifierPrefix: import_constants.SSR_HYDRATION_ID_PREFIX
|
|
69
|
+
});
|
|
66
70
|
}
|
|
67
71
|
try {
|
|
68
72
|
const [{ renderRsc }, { createFromReadableStream }, { injectRSCPayload }] = await Promise.all([
|
|
@@ -87,7 +91,10 @@ const renderSSRStream = async (children, options) => {
|
|
|
87
91
|
}),
|
|
88
92
|
children
|
|
89
93
|
]
|
|
90
|
-
}),
|
|
94
|
+
}), {
|
|
95
|
+
...options,
|
|
96
|
+
identifierPrefix: import_constants.SSR_HYDRATION_ID_PREFIX
|
|
97
|
+
});
|
|
91
98
|
const stream = htmlStream.pipeThrough(injectRSCPayload(rscPayloadStream, {
|
|
92
99
|
injectClosingTags: true
|
|
93
100
|
}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const encoder = new TextEncoder();
|
|
2
|
-
const
|
|
2
|
+
const closingTagsPattern = /<\/body>\s*<\/html>\s*$/i;
|
|
3
3
|
function injectRSCPayload(rscStream, { injectClosingTags = true }) {
|
|
4
4
|
const decoder = new TextDecoder();
|
|
5
5
|
let resolveFlightDataPromise;
|
|
@@ -10,8 +10,8 @@ function injectRSCPayload(rscStream, { injectClosingTags = true }) {
|
|
|
10
10
|
function flushBufferedChunks(controller) {
|
|
11
11
|
for (const chunk of buffered) {
|
|
12
12
|
let buf = decoder.decode(chunk);
|
|
13
|
-
if (
|
|
14
|
-
buf = buf.
|
|
13
|
+
if (closingTagsPattern.test(buf)) {
|
|
14
|
+
buf = buf.replace(closingTagsPattern, "");
|
|
15
15
|
}
|
|
16
16
|
controller.enqueue(encoder.encode(buf));
|
|
17
17
|
}
|
|
@@ -16,7 +16,7 @@ async function renderCSRWithRSC(options) {
|
|
|
16
16
|
const stream = htmlStream.pipeThrough(injectCSS(cssFiles, {
|
|
17
17
|
injectClosingTags: false
|
|
18
18
|
})).pipeThrough(injectRSCPayload(rscPayloadStream, {
|
|
19
|
-
injectClosingTags:
|
|
19
|
+
injectClosingTags: true
|
|
20
20
|
}));
|
|
21
21
|
return new Response(stream, {
|
|
22
22
|
status: 200,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
2
3
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
3
4
|
import { ServerElementsProvider } from "../../client/index";
|
|
4
5
|
function CSSLinks({ cssFiles }) {
|
|
@@ -29,7 +30,10 @@ const renderSSRStream = async (children, options) => {
|
|
|
29
30
|
const entryCssFiles = (__rspack_rsc_manifest__3 = __rspack_rsc_manifest__) === null || __rspack_rsc_manifest__3 === void 0 ? void 0 : __rspack_rsc_manifest__3.entryCssFiles;
|
|
30
31
|
const hasRoutes = Boolean(routes && routes.length > 0);
|
|
31
32
|
if (!clientManifest || !serverConsumerModuleMap) {
|
|
32
|
-
return renderToReadableStream(children,
|
|
33
|
+
return renderToReadableStream(children, {
|
|
34
|
+
...options,
|
|
35
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
36
|
+
});
|
|
33
37
|
}
|
|
34
38
|
try {
|
|
35
39
|
const [{ renderRsc }, { createFromReadableStream }, { injectRSCPayload }] = await Promise.all([
|
|
@@ -54,7 +58,10 @@ const renderSSRStream = async (children, options) => {
|
|
|
54
58
|
}),
|
|
55
59
|
children
|
|
56
60
|
]
|
|
57
|
-
}),
|
|
61
|
+
}), {
|
|
62
|
+
...options,
|
|
63
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
64
|
+
});
|
|
58
65
|
const stream = htmlStream.pipeThrough(injectRSCPayload(rscPayloadStream, {
|
|
59
66
|
injectClosingTags: true
|
|
60
67
|
}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const encoder = new TextEncoder();
|
|
2
|
-
const
|
|
2
|
+
const closingTagsPattern = /<\/body>\s*<\/html>\s*$/i;
|
|
3
3
|
function injectRSCPayload(rscStream, { injectClosingTags = true }) {
|
|
4
4
|
const decoder = new TextDecoder();
|
|
5
5
|
let resolveFlightDataPromise;
|
|
@@ -10,8 +10,8 @@ function injectRSCPayload(rscStream, { injectClosingTags = true }) {
|
|
|
10
10
|
function flushBufferedChunks(controller) {
|
|
11
11
|
for (const chunk of buffered) {
|
|
12
12
|
let buf = decoder.decode(chunk);
|
|
13
|
-
if (
|
|
14
|
-
buf = buf.
|
|
13
|
+
if (closingTagsPattern.test(buf)) {
|
|
14
|
+
buf = buf.replace(closingTagsPattern, "");
|
|
15
15
|
}
|
|
16
16
|
controller.enqueue(encoder.encode(buf));
|
|
17
17
|
}
|
|
@@ -16,7 +16,7 @@ async function renderCSRWithRSC(options) {
|
|
|
16
16
|
const stream = htmlStream.pipeThrough(injectCSS(cssFiles, {
|
|
17
17
|
injectClosingTags: false
|
|
18
18
|
})).pipeThrough(injectRSCPayload(rscPayloadStream, {
|
|
19
|
-
injectClosingTags:
|
|
19
|
+
injectClosingTags: true
|
|
20
20
|
}));
|
|
21
21
|
return new Response(stream, {
|
|
22
22
|
status: 200,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { SSR_HYDRATION_ID_PREFIX } from "@modern-js/utils/universal/constants";
|
|
2
3
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
3
4
|
import { ServerElementsProvider } from "../../client/index.mjs";
|
|
4
5
|
function CSSLinks({ cssFiles }) {
|
|
@@ -29,7 +30,10 @@ const renderSSRStream = async (children, options) => {
|
|
|
29
30
|
const entryCssFiles = (__rspack_rsc_manifest__3 = __rspack_rsc_manifest__) === null || __rspack_rsc_manifest__3 === void 0 ? void 0 : __rspack_rsc_manifest__3.entryCssFiles;
|
|
30
31
|
const hasRoutes = Boolean(routes && routes.length > 0);
|
|
31
32
|
if (!clientManifest || !serverConsumerModuleMap) {
|
|
32
|
-
return renderToReadableStream(children,
|
|
33
|
+
return renderToReadableStream(children, {
|
|
34
|
+
...options,
|
|
35
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
36
|
+
});
|
|
33
37
|
}
|
|
34
38
|
try {
|
|
35
39
|
const [{ renderRsc }, { createFromReadableStream }, { injectRSCPayload }] = await Promise.all([
|
|
@@ -54,7 +58,10 @@ const renderSSRStream = async (children, options) => {
|
|
|
54
58
|
}),
|
|
55
59
|
children
|
|
56
60
|
]
|
|
57
|
-
}),
|
|
61
|
+
}), {
|
|
62
|
+
...options,
|
|
63
|
+
identifierPrefix: SSR_HYDRATION_ID_PREFIX
|
|
64
|
+
});
|
|
58
65
|
const stream = htmlStream.pipeThrough(injectRSCPayload(rscPayloadStream, {
|
|
59
66
|
injectClosingTags: true
|
|
60
67
|
}));
|
package/package.json
CHANGED
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.
|
|
18
|
+
"version": "3.1.1",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
21
|
"hook.d.ts"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@swc/helpers": "^0.5.17",
|
|
25
|
-
"@modern-js/types": "3.
|
|
26
|
-
"@modern-js/utils": "3.
|
|
25
|
+
"@modern-js/types": "3.1.1",
|
|
26
|
+
"@modern-js/utils": "3.1.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@rslib/core": "0.
|
|
29
|
+
"@rslib/core": "0.20.0",
|
|
30
30
|
"@types/react": "^19.2.14",
|
|
31
31
|
"@types/react-dom": "^19.2.3",
|
|
32
32
|
"react": "^19.2.4",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"react-server-dom-rspack": "0.0.1-beta.1",
|
|
35
35
|
"typescript": "^5",
|
|
36
36
|
"@modern-js/rslib": "2.68.10",
|
|
37
|
-
"@
|
|
37
|
+
"@scripts/rstest-config": "2.66.0",
|
|
38
38
|
"@scripts/build": "2.66.0",
|
|
39
|
-
"@
|
|
39
|
+
"@modern-js/server-core": "3.1.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": ">=17.0.2",
|