@rspress/core 2.0.0-beta.10 → 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.
@@ -1,27 +1,48 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
3
- import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__ from "@rspress/runtime/server";
4
- import * as __WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__ from "@unhead/react/server";
5
- import * as __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__ from "react-dom/server";
6
- import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
7
- import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
8
- import * as __WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__ from "virtual-routes";
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";
9
11
  const DEFAULT_THEME = 'light';
12
+ async function preloadRoute(pathname) {
13
+ const route = pathnameToRouteService(pathname);
14
+ await route?.preload();
15
+ }
16
+ function renderToHtml(app) {
17
+ return new Promise((resolve, reject)=>{
18
+ const passThrough = new PassThrough();
19
+ const { pipe } = renderToPipeableStream(app, {
20
+ onError (error) {
21
+ reject(error);
22
+ },
23
+ onAllReady () {
24
+ pipe(passThrough);
25
+ consumers_text(passThrough).then(resolve, reject);
26
+ }
27
+ });
28
+ });
29
+ }
10
30
  async function render(pagePath, head) {
11
- const initialPageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(pagePath);
12
- const appHtml = (0, __WEBPACK_EXTERNAL_MODULE_react_dom_server_98c38d5c__.renderToString)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.ThemeContext.Provider, {
31
+ const initialPageData = await initPageData(pagePath);
32
+ await preloadRoute(pagePath);
33
+ const appHtml = await renderToHtml(/*#__PURE__*/ jsx(ThemeContext.Provider, {
13
34
  value: {
14
35
  theme: DEFAULT_THEME
15
36
  },
16
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext.Provider, {
37
+ children: /*#__PURE__*/ jsx(DataContext.Provider, {
17
38
  value: {
18
39
  data: initialPageData
19
40
  },
20
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_server_673c713a__.StaticRouter, {
41
+ children: /*#__PURE__*/ jsx(StaticRouter, {
21
42
  location: pagePath,
22
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__unhead_react_server_7e85c952__.UnheadProvider, {
43
+ children: /*#__PURE__*/ jsx(UnheadProvider, {
23
44
  value: head,
24
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
45
+ children: /*#__PURE__*/ jsx(App, {})
25
46
  })
26
47
  })
27
48
  })
@@ -31,5 +52,4 @@ async function render(pagePath, head) {
31
52
  pageData: initialPageData
32
53
  };
33
54
  }
34
- var __webpack_exports__routes = __WEBPACK_EXTERNAL_MODULE_virtual_routes_98776429__.routes;
35
- 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.10",
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.21",
49
- "@rsbuild/plugin-react": "~1.3.1",
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-container-syntax": "2.0.0-beta.10",
75
- "@rspress/plugin-last-updated": "2.0.0-beta.10",
76
- "@rspress/plugin-medium-zoom": "2.0.0-beta.10",
77
- "@rspress/plugin-shiki": "2.0.0-beta.10",
78
- "@rspress/runtime": "2.0.0-beta.10",
79
- "@rspress/theme-default": "2.0.0-beta.10",
80
- "@rspress/shared": "2.0.0-beta.10",
81
- "@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.10"
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.8.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",
@@ -90,10 +90,11 @@
90
90
  "@types/lodash-es": "^4.17.12",
91
91
  "@types/mdast": "^4.0.4",
92
92
  "@types/node": "^22.8.1",
93
- "@types/react": "^18.3.22",
94
- "@types/react-dom": "^18.3.7",
93
+ "@types/react": "^19.1.6",
94
+ "@types/react-dom": "^19.1.6",
95
95
  "memfs": "^4.17.2",
96
- "postcss": "8.5.3",
96
+ "p-map": "^7.0.3",
97
+ "postcss": "8.5.4",
97
98
  "rehype-stringify": "^10.0.1",
98
99
  "remark-mdx": "^3.1.0",
99
100
  "remark-parse": "^11.0.0",