@rspress/core 2.0.0-beta.11 → 2.0.0-beta.12
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/index.js +192 -193
- package/dist/loader.d.ts +4 -18
- package/dist/loader.js +28 -397
- package/dist/processor.d.ts +73 -0
- package/dist/processor.js +424 -0
- package/dist/runtime/App.js +16 -16
- package/dist/runtime/ClientApp.js +16 -16
- package/dist/runtime/csrClientEntry.js +4 -4
- package/dist/runtime/initPageData.js +17 -17
- package/dist/runtime/ssrClientEntry.js +8 -8
- package/dist/runtime/ssrServerEntry.js +21 -22
- package/package.json +13 -13
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DataContext, ThemeContext, pathnameToRouteService } from "@rspress/runtime";
|
|
3
|
+
import { StaticRouter } from "@rspress/runtime/server";
|
|
4
|
+
import { UnheadProvider } from "@unhead/react/server";
|
|
5
|
+
import { renderToPipeableStream } from "react-dom/server";
|
|
6
|
+
import { PassThrough } from "node:stream";
|
|
7
|
+
import { text as consumers_text } from "node:stream/consumers";
|
|
8
|
+
import { App } from "./App.js";
|
|
9
|
+
import { initPageData } from "./initPageData.js";
|
|
10
|
+
import { routes } from "virtual-routes";
|
|
11
11
|
const DEFAULT_THEME = 'light';
|
|
12
12
|
async function preloadRoute(pathname) {
|
|
13
|
-
const route =
|
|
13
|
+
const route = pathnameToRouteService(pathname);
|
|
14
14
|
await route?.preload();
|
|
15
15
|
}
|
|
16
16
|
function renderToHtml(app) {
|
|
17
17
|
return new Promise((resolve, reject)=>{
|
|
18
|
-
const passThrough = new
|
|
19
|
-
const { pipe } =
|
|
18
|
+
const passThrough = new PassThrough();
|
|
19
|
+
const { pipe } = renderToPipeableStream(app, {
|
|
20
20
|
onError (error) {
|
|
21
21
|
reject(error);
|
|
22
22
|
},
|
|
23
23
|
onAllReady () {
|
|
24
24
|
pipe(passThrough);
|
|
25
|
-
(
|
|
25
|
+
consumers_text(passThrough).then(resolve, reject);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
async function render(pagePath, head) {
|
|
31
|
-
const initialPageData = await
|
|
31
|
+
const initialPageData = await initPageData(pagePath);
|
|
32
32
|
await preloadRoute(pagePath);
|
|
33
|
-
const appHtml = await renderToHtml(/*#__PURE__*/
|
|
33
|
+
const appHtml = await renderToHtml(/*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
34
34
|
value: {
|
|
35
35
|
theme: DEFAULT_THEME
|
|
36
36
|
},
|
|
37
|
-
children: /*#__PURE__*/
|
|
37
|
+
children: /*#__PURE__*/ jsx(DataContext.Provider, {
|
|
38
38
|
value: {
|
|
39
39
|
data: initialPageData
|
|
40
40
|
},
|
|
41
|
-
children: /*#__PURE__*/
|
|
41
|
+
children: /*#__PURE__*/ jsx(StaticRouter, {
|
|
42
42
|
location: pagePath,
|
|
43
|
-
children: /*#__PURE__*/
|
|
43
|
+
children: /*#__PURE__*/ jsx(UnheadProvider, {
|
|
44
44
|
value: head,
|
|
45
|
-
children: /*#__PURE__*/
|
|
45
|
+
children: /*#__PURE__*/ jsx(App, {})
|
|
46
46
|
})
|
|
47
47
|
})
|
|
48
48
|
})
|
|
@@ -52,5 +52,4 @@ async function render(pagePath, head) {
|
|
|
52
52
|
pageData: initialPageData
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
export { render, __webpack_exports__routes as routes };
|
|
55
|
+
export { render, routes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.12",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@mdx-js/loader": "^3.1.0",
|
|
46
46
|
"@mdx-js/mdx": "^3.1.0",
|
|
47
47
|
"@mdx-js/react": "^3.1.0",
|
|
48
|
-
"@rsbuild/core": "~1.3.
|
|
49
|
-
"@rsbuild/plugin-react": "~1.3.
|
|
48
|
+
"@rsbuild/core": "~1.3.22",
|
|
49
|
+
"@rsbuild/plugin-react": "~1.3.2",
|
|
50
50
|
"@rspress/mdx-rs": "0.6.6",
|
|
51
51
|
"@types/unist": "^3.0.3",
|
|
52
52
|
"@unhead/react": "^2.0.10",
|
|
@@ -71,18 +71,18 @@
|
|
|
71
71
|
"unified": "^11.0.5",
|
|
72
72
|
"unist-util-visit": "^5.0.0",
|
|
73
73
|
"unist-util-visit-children": "^3.0.0",
|
|
74
|
-
"@rspress/plugin-
|
|
75
|
-
"@rspress/plugin-
|
|
76
|
-
"@rspress/plugin-last-updated": "2.0.0-beta.
|
|
77
|
-
"@rspress/plugin-
|
|
78
|
-
"@rspress/plugin-
|
|
79
|
-
"@rspress/runtime": "2.0.0-beta.
|
|
80
|
-
"@rspress/
|
|
81
|
-
"@rspress/
|
|
74
|
+
"@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.12",
|
|
75
|
+
"@rspress/plugin-container-syntax": "2.0.0-beta.12",
|
|
76
|
+
"@rspress/plugin-last-updated": "2.0.0-beta.12",
|
|
77
|
+
"@rspress/plugin-shiki": "2.0.0-beta.12",
|
|
78
|
+
"@rspress/plugin-medium-zoom": "2.0.0-beta.12",
|
|
79
|
+
"@rspress/runtime": "2.0.0-beta.12",
|
|
80
|
+
"@rspress/shared": "2.0.0-beta.12",
|
|
81
|
+
"@rspress/theme-default": "2.0.0-beta.12"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@microsoft/api-extractor": "^7.52.8",
|
|
85
|
-
"@rslib/core": "0.
|
|
85
|
+
"@rslib/core": "0.9.2",
|
|
86
86
|
"@rspress-dev/plugin-preview": "link:../plugin-preview",
|
|
87
87
|
"@types/hast": "^3.0.4",
|
|
88
88
|
"@types/html-to-text": "^9.0.4",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@types/react-dom": "^19.1.6",
|
|
95
95
|
"memfs": "^4.17.2",
|
|
96
96
|
"p-map": "^7.0.3",
|
|
97
|
-
"postcss": "8.5.
|
|
97
|
+
"postcss": "8.5.4",
|
|
98
98
|
"rehype-stringify": "^10.0.1",
|
|
99
99
|
"remark-mdx": "^3.1.0",
|
|
100
100
|
"remark-parse": "^11.0.0",
|