@rspress/core 2.0.22 → 2.1.0-beta.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/bin/rspress.js +3 -1
- package/dist/{v~0.js → b~0.js} +19 -16
- package/dist/cli/index.js +2 -2
- package/dist/{common-Qw-RoVFD.js → common-Bo3KCGim.js} +4 -1
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Link/getHref.ts +1 -0
- package/dist/eject-theme/components/Link/index.tsx +0 -3
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +29 -54
- package/dist/eject-theme/components/Search/SearchPanel.tsx +9 -5
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +5 -2
- package/dist/eject-theme/components/Search/useSearchPanel.ts +105 -37
- package/dist/eject-theme/components/SocialLinks/GithubStars.test.tsx +4 -1
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +1 -1
- package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +2 -2
- package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
- package/dist/entry/worker.js +1 -1
- package/dist/{o~0.js → h~0.js} +18 -29
- package/dist/index.d.ts +1 -1
- package/dist/node/PluginDriver.js +8 -2
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +9 -5
- package/dist/node/llms.d.ts +1 -1
- package/dist/node/llms.js +2 -2
- package/dist/node/logger/hint.d.ts +1 -0
- package/dist/node/logger/hint.js +8 -2
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +28 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +2 -2
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/sitemap.d.ts +2 -0
- package/dist/node/sitemap.js +103 -0
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +4 -3
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +2 -2
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/renderPage.js +5 -4
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +5 -2
- package/dist/n~0.js +11 -10
- package/dist/runtime/App.js +15 -27
- package/dist/runtime/ClientApp.d.ts +3 -2
- package/dist/runtime/ClientApp.js +27 -21
- package/dist/runtime/ErrorRoute.d.ts +1 -0
- package/dist/runtime/ErrorRoute.js +30 -0
- package/dist/runtime/PageRoute.d.ts +2 -0
- package/dist/runtime/PageRoute.js +58 -0
- package/dist/runtime/createServerRouter.d.ts +4 -0
- package/dist/runtime/createServerRouter.js +17 -0
- package/dist/runtime/csrClientEntry.js +5 -2
- package/dist/runtime/hooks/createExternalStore.d.ts +4 -0
- package/dist/runtime/hooks/createExternalStore.js +20 -0
- package/dist/runtime/hooks/useGlobalComponents.d.ts +1 -0
- package/dist/runtime/hooks/useGlobalComponents.js +10 -0
- package/dist/runtime/hooks/useI18n.js +5 -3
- package/dist/runtime/hooks/useI18nText.d.ts +1 -0
- package/dist/runtime/hooks/useI18nText.js +10 -0
- package/dist/runtime/hooks/usePages.d.ts +2 -0
- package/dist/runtime/hooks/usePages.js +12 -3
- package/dist/runtime/hooks/useSearchHooks.d.ts +8 -0
- package/dist/runtime/hooks/useSearchHooks.js +14 -0
- package/dist/runtime/hooks/useSite.d.ts +1 -0
- package/dist/runtime/hooks/useSite.js +9 -2
- package/dist/runtime/hooks/useWebMcp.d.ts +36 -0
- package/dist/runtime/hooks/useWebMcp.js +80 -0
- package/dist/runtime/index.d.ts +6 -2
- package/dist/runtime/index.js +8 -2
- package/dist/runtime/initPageData.d.ts +0 -3
- package/dist/runtime/initPageData.js +13 -49
- package/dist/runtime/pageDataLoader.d.ts +11 -0
- package/dist/runtime/pageDataLoader.js +7 -0
- package/dist/runtime/route.js +5 -5
- package/dist/runtime/ssrClientEntry.js +14 -6
- package/dist/runtime/ssrMdServerEntry.js +10 -21
- package/dist/runtime/ssrServerEntry.js +10 -21
- package/dist/runtime/utils.js +6 -6
- package/dist/static/assets/package.json +58 -0
- package/dist/theme/components/Link/index.js +0 -4
- package/dist/theme/components/Link/useLinkNavigate.d.ts +2 -2
- package/dist/theme/components/Link/useLinkNavigate.js +13 -35
- package/dist/theme/components/Search/SearchPanel.js +8 -6
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +5 -2
- package/dist/theme/components/Search/useSearchPanel.js +75 -27
- package/dist/theme/components/SocialLinks/GithubStars.js +1 -1
- package/dist/theme/components/SocialLinks/SocialLink.js +2 -2
- package/dist/theme/components/SourceCode/index.js +1 -1
- package/dist/theme/hooks/useWebMcpNavigation.d.ts +6 -0
- package/dist/theme/hooks/useWebMcpNavigation.js +123 -0
- package/dist/theme/hooks/useWebMcpPageList.d.ts +6 -0
- package/dist/theme/hooks/useWebMcpPageList.js +25 -0
- package/dist/theme/hooks/useWebMcpPageReading.d.ts +7 -0
- package/dist/theme/hooks/useWebMcpPageReading.js +23 -0
- package/dist/theme/hooks/useWebMcpSiteInfo.d.ts +6 -0
- package/dist/theme/hooks/useWebMcpSiteInfo.js +22 -0
- package/dist/theme/index.d.ts +5 -0
- package/dist/theme/index.js +5 -0
- package/dist/theme/layout/ErrorLayout/index.css +52 -0
- package/dist/theme/layout/ErrorLayout/index.d.ts +8 -0
- package/dist/theme/layout/ErrorLayout/index.js +76 -0
- package/dist/theme/logic/utils.d.ts +0 -2
- package/dist/theme/logic/utils.js +56 -6
- package/dist/theme/webMcp/tools.d.ts +56 -0
- package/dist/theme/webMcp/tools.js +122 -0
- package/dist/theme/webMcp/types.d.ts +35 -0
- package/dist/theme/webMcp/types.js +0 -0
- package/dist/tinypool~0.js +19 -49
- package/dist/tu~0.js +3 -0
- package/package.json +17 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeFile, mkdir, dirname, workerData } from "../../4~0.js";
|
|
2
2
|
import { createError } from "../utils/error.js";
|
|
3
3
|
import { resolveHtmlFilePath } from "./htmlFile.js";
|
|
4
|
-
import { pMap } from "../../
|
|
4
|
+
import { pMap } from "../../b~0.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
const params = workerData?.[1]?.params;
|
|
7
7
|
if (!params) throw createError('SSG Worker Thread workerData params missing');
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! LICENSE: renderPages.js.LICENSE.txt */
|
|
2
2
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
3
3
|
import "../../t~0.js";
|
|
4
|
-
import { node_path, fileURLToPath, logger, chunk } from "../../
|
|
4
|
+
import { node_path, fileURLToPath, logger, chunk } from "../../h~0.js";
|
|
5
5
|
import { createAlternateLinksByRoute } from "./alternateLinks.js";
|
|
6
6
|
import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
|
|
7
7
|
import { routePath2HtmlFileName } from "./htmlFile.js";
|
|
8
|
-
import { pMap } from "../../
|
|
8
|
+
import { pMap } from "../../b~0.js";
|
|
9
9
|
import { renderPage } from "./renderPage.js";
|
|
10
10
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
11
11
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../h~0.js";
|
|
2
2
|
import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
4
|
const rsbuildPluginSSG = ({ routeService, config, routeChunkAssets })=>({
|
package/dist/node/ssg/ssgEnv.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! LICENSE: ssgEnv.js.LICENSE.txt */
|
|
2
|
-
import { node_os } from "../../
|
|
2
|
+
import { node_os } from "../../h~0.js";
|
|
3
3
|
/**
|
|
4
4
|
* these codes are copied from
|
|
5
5
|
* @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { matchPath, getSidebarDataGroup } from "../../../
|
|
1
|
+
import { matchPath, getSidebarDataGroup } from "../../../h~0.js";
|
|
2
2
|
import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
|
|
3
3
|
async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
|
|
4
4
|
const base = config.base ?? '/';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../
|
|
1
|
+
import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../h~0.js";
|
|
2
2
|
import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
|
|
3
3
|
function routePathToMdPath(routePath, base, siteOrigin) {
|
|
4
4
|
let url = routePath;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { createHead, pathToFileURL, logger } from "../../
|
|
4
|
-
import {
|
|
3
|
+
import { createHead, pathToFileURL, logger } from "../../h~0.js";
|
|
4
|
+
import { hintSSGMDFailed } from "../logger/hint.js";
|
|
5
5
|
const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
6
6
|
var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
|
|
7
7
|
async function renderPage(route, ssrBundlePath) {
|
|
@@ -12,9 +12,9 @@ async function renderPage(route, ssrBundlePath) {
|
|
|
12
12
|
render = ssrExports.render;
|
|
13
13
|
} catch (e) {
|
|
14
14
|
if (e instanceof Error) {
|
|
15
|
-
logger.error(`Failed to load SSG bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
|
|
15
|
+
logger.error(`Failed to load SSG-MD bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
|
|
16
16
|
logger.debug(e);
|
|
17
|
-
|
|
17
|
+
hintSSGMDFailed();
|
|
18
18
|
}
|
|
19
19
|
throw e;
|
|
20
20
|
}
|
|
@@ -27,6 +27,7 @@ async function renderPage(route, ssrBundlePath) {
|
|
|
27
27
|
if (e instanceof Error) {
|
|
28
28
|
logger.error(`Page "${picocolors_default().yellow(routePath)}" SSG-MD rendering failed.
|
|
29
29
|
${absolutePath ? picocolors_default().gray(` File: ${absolutePath}\n`) : ''} ${picocolors_default().gray(e.toString())}`);
|
|
30
|
+
hintSSGMDFailed();
|
|
30
31
|
throw e;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { logger } from "../../
|
|
4
|
-
import { pMap } from "../../
|
|
3
|
+
import { logger } from "../../h~0.js";
|
|
4
|
+
import { pMap } from "../../b~0.js";
|
|
5
5
|
import { renderPage } from "./renderPage.js";
|
|
6
6
|
import { SSGConcurrency } from "../ssg/ssgEnv.js";
|
|
7
7
|
const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFile, mkdir, rm, join, isDebugMode } from "../../
|
|
1
|
+
import { writeFile, mkdir, rm, join, isDebugMode } from "../../h~0.js";
|
|
2
2
|
import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
|
|
3
3
|
import { renderPages } from "./renderPages.js";
|
|
4
4
|
import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash as external_node_crypto_createHash } from "../../
|
|
1
|
+
import { createHash as external_node_crypto_createHash } from "../../h~0.js";
|
|
2
2
|
function createHash(str, length = 8) {
|
|
3
3
|
return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, length);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../
|
|
1
|
+
import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../h~0.js";
|
|
2
2
|
import { createError } from "./error.js";
|
|
3
3
|
import { importStatementRegex } from "../constants.js";
|
|
4
4
|
const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
|
|
2
2
|
import "../../t~0.js";
|
|
3
|
-
import { node_path, core_rspack, logger } from "../../
|
|
3
|
+
import { node_path, core_rspack, logger } from "../../h~0.js";
|
|
4
4
|
import { pathExists, readJson } from "./fs.js";
|
|
5
5
|
import { PACKAGE_ROOT } from "../constants.js";
|
|
6
6
|
import { hintReactVersion } from "../logger/hint.js";
|
|
@@ -36,8 +36,11 @@ async function resolveReactRouterDomAlias() {
|
|
|
36
36
|
const resolved = await resolver.async(basedir, 'react-router-dom/package.json');
|
|
37
37
|
if (resolved.error) throw Error(resolved.error);
|
|
38
38
|
if (!resolved.path) throw Error("'react-router-dom' resolved to empty path");
|
|
39
|
+
const packageRoot = node_path.dirname(resolved.path);
|
|
40
|
+
const { version } = await readJson(resolved.path);
|
|
39
41
|
return {
|
|
40
|
-
'react-router-dom':
|
|
42
|
+
'react-router-dom': packageRoot,
|
|
43
|
+
'virtual-react-router-server': version.startsWith('6.') ? node_path.join(packageRoot, 'server.mjs') : packageRoot
|
|
41
44
|
};
|
|
42
45
|
} catch (e) {
|
|
43
46
|
logger.warn('react-router-dom not found: \n', e);
|
package/dist/n~0.js
CHANGED
|
@@ -8,10 +8,11 @@ import node_os, { constants } from "node:os";
|
|
|
8
8
|
import { createReadStream, createWriteStream, readFileSync } from "node:fs";
|
|
9
9
|
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
10
10
|
import { debuglog } from "node:util";
|
|
11
|
-
import "
|
|
11
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
12
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
12
13
|
moduleFactories.add({
|
|
13
14
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module) {
|
|
14
|
-
const cp =
|
|
15
|
+
const cp = __rspack_createRequire_require("child_process");
|
|
15
16
|
const parse = rspackRequire("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js");
|
|
16
17
|
const enoent = rspackRequire("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js");
|
|
17
18
|
function spawn(command, args, options) {
|
|
@@ -70,7 +71,7 @@ moduleFactories.add({
|
|
|
70
71
|
};
|
|
71
72
|
},
|
|
72
73
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js" (module) {
|
|
73
|
-
const path =
|
|
74
|
+
const path = __rspack_createRequire_require("path");
|
|
74
75
|
const resolveCommand = rspackRequire("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js");
|
|
75
76
|
const escape = rspackRequire("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js");
|
|
76
77
|
const readShebang = rspackRequire("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js");
|
|
@@ -150,7 +151,7 @@ moduleFactories.add({
|
|
|
150
151
|
module.exports.argument = escapeArgument;
|
|
151
152
|
},
|
|
152
153
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js" (module) {
|
|
153
|
-
const fs =
|
|
154
|
+
const fs = __rspack_createRequire_require("fs");
|
|
154
155
|
const shebangCommand = rspackRequire("../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js");
|
|
155
156
|
function readShebang(command) {
|
|
156
157
|
const size = 150;
|
|
@@ -166,7 +167,7 @@ moduleFactories.add({
|
|
|
166
167
|
module.exports = readShebang;
|
|
167
168
|
},
|
|
168
169
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js" (module) {
|
|
169
|
-
const path =
|
|
170
|
+
const path = __rspack_createRequire_require("path");
|
|
170
171
|
const which = rspackRequire("../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js");
|
|
171
172
|
const getPathKey = rspackRequire("../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js");
|
|
172
173
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -197,7 +198,7 @@ moduleFactories.add({
|
|
|
197
198
|
module.exports = resolveCommand;
|
|
198
199
|
},
|
|
199
200
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js" (module) {
|
|
200
|
-
|
|
201
|
+
__rspack_createRequire_require("fs");
|
|
201
202
|
var core;
|
|
202
203
|
core = 'win32' === process.platform || global.TESTING_WINDOWS ? rspackRequire("../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js") : rspackRequire("../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js");
|
|
203
204
|
module.exports = isexe;
|
|
@@ -238,7 +239,7 @@ moduleFactories.add({
|
|
|
238
239
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js" (module) {
|
|
239
240
|
module.exports = isexe;
|
|
240
241
|
isexe.sync = sync;
|
|
241
|
-
var fs =
|
|
242
|
+
var fs = __rspack_createRequire_require("fs");
|
|
242
243
|
function isexe(path, options, cb) {
|
|
243
244
|
fs.stat(path, function(er, stat) {
|
|
244
245
|
cb(er, er ? false : checkStat(stat, options));
|
|
@@ -267,7 +268,7 @@ moduleFactories.add({
|
|
|
267
268
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js" (module) {
|
|
268
269
|
module.exports = isexe;
|
|
269
270
|
isexe.sync = sync;
|
|
270
|
-
var fs =
|
|
271
|
+
var fs = __rspack_createRequire_require("fs");
|
|
271
272
|
function checkPathExt(path, options) {
|
|
272
273
|
var pathext = void 0 !== options.pathExt ? options.pathExt : process.env.PATHEXT;
|
|
273
274
|
if (!pathext) return true;
|
|
@@ -293,7 +294,7 @@ moduleFactories.add({
|
|
|
293
294
|
}
|
|
294
295
|
},
|
|
295
296
|
"../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js" (module) {
|
|
296
|
-
const { PassThrough } =
|
|
297
|
+
const { PassThrough } = __rspack_createRequire_require("stream");
|
|
297
298
|
module.exports = function() {
|
|
298
299
|
var sources = [];
|
|
299
300
|
var output = new PassThrough({
|
|
@@ -355,7 +356,7 @@ moduleFactories.add({
|
|
|
355
356
|
},
|
|
356
357
|
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js" (module) {
|
|
357
358
|
const isWindows = 'win32' === process.platform || 'cygwin' === process.env.OSTYPE || 'msys' === process.env.OSTYPE;
|
|
358
|
-
const path =
|
|
359
|
+
const path = __rspack_createRequire_require("path");
|
|
359
360
|
const COLON = isWindows ? ';' : ':';
|
|
360
361
|
const isexe = rspackRequire("../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js");
|
|
361
362
|
const getNotFoundError = (cmd)=>Object.assign(new Error(`not found: ${cmd}`), {
|
package/dist/runtime/App.js
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { PageContext, useLocation } from "@rspress/core/runtime";
|
|
3
|
-
import { Layout, Root } from "@rspress/core/theme";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import virtual_global_components from "virtual-global-components";
|
|
7
|
-
import { consumeCachedPageData, initPageData, setCurrentPageData } from "./initPageData.js";
|
|
3
|
+
import { Layout, LlmsHint, Root, useWebMcpNavigation, useWebMcpPageList, useWebMcpPageReading, useWebMcpSiteInfo } from "@rspress/core/theme";
|
|
4
|
+
import react, { useContext } from "react";
|
|
5
|
+
import { useGlobalComponents } from "./hooks/useGlobalComponents.js";
|
|
8
6
|
function App() {
|
|
9
|
-
const
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} catch (e) {
|
|
20
|
-
console.log(e);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
refetchData();
|
|
24
|
-
}, [
|
|
25
|
-
pathname,
|
|
26
|
-
setPageData
|
|
27
|
-
]);
|
|
28
|
-
if (!data) return /*#__PURE__*/ jsx(Fragment, {});
|
|
7
|
+
const globalComponents = useGlobalComponents();
|
|
8
|
+
const { data } = useContext(PageContext);
|
|
9
|
+
const location = useLocation();
|
|
10
|
+
const { search } = location;
|
|
11
|
+
if (import.meta.env.ENABLE_WEBMCP && !import.meta.env.SSR) {
|
|
12
|
+
useWebMcpSiteInfo();
|
|
13
|
+
useWebMcpPageList();
|
|
14
|
+
useWebMcpNavigation();
|
|
15
|
+
if (import.meta.env.ENABLE_SSG_MD) useWebMcpPageReading();
|
|
16
|
+
}
|
|
29
17
|
const frontmatter = data.frontmatter || {};
|
|
30
18
|
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
31
19
|
const query = new URLSearchParams(search);
|
|
@@ -40,7 +28,7 @@ function App() {
|
|
|
40
28
|
children: [
|
|
41
29
|
import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHint, {}),
|
|
42
30
|
/*#__PURE__*/ jsx(Layout, {}),
|
|
43
|
-
!hideGlobalUIComponents &&
|
|
31
|
+
!hideGlobalUIComponents && globalComponents.map((componentInfo, index)=>{
|
|
44
32
|
if (Array.isArray(componentInfo)) {
|
|
45
33
|
const [component, props] = componentInfo;
|
|
46
34
|
return /*#__PURE__*/ react.createElement(component, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Page } from './initPageData.js';
|
|
2
|
-
export declare function
|
|
3
|
-
|
|
2
|
+
export declare function createClientRouter(initialPageData?: Page): import("react-router-dom").DataRouter;
|
|
3
|
+
export declare function ClientApp({ router, }: {
|
|
4
|
+
router: ReturnType<typeof createClientRouter>;
|
|
4
5
|
}): import("react").JSX.Element;
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { RouterProvider, ThemeContext, createBrowserRouter, removeTrailingSlash, useSite, withBase } from "@rspress/core/runtime";
|
|
3
3
|
import { useThemeState } from "@rspress/core/theme";
|
|
4
4
|
import { UnheadProvider, createHead } from "@unhead/react/client";
|
|
5
|
-
import { useMemo
|
|
6
|
-
import {
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { PAGE_ROUTE_ID } from "./pageDataLoader.js";
|
|
7
|
+
import { createPageRoutes } from "./PageRoute.js";
|
|
7
8
|
const head = createHead();
|
|
8
|
-
function
|
|
9
|
-
|
|
9
|
+
function createClientRouter(initialPageData) {
|
|
10
|
+
return createBrowserRouter(createPageRoutes(), {
|
|
11
|
+
basename: removeTrailingSlash(withBase('/')),
|
|
12
|
+
hydrationData: initialPageData ? {
|
|
13
|
+
loaderData: {
|
|
14
|
+
[PAGE_ROUTE_ID]: initialPageData
|
|
15
|
+
}
|
|
16
|
+
} : void 0
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function ClientApp({ router }) {
|
|
10
20
|
const [theme, setTheme] = useThemeState();
|
|
11
21
|
const { site } = useSite();
|
|
22
|
+
const transitionOptions = {
|
|
23
|
+
useTransitions: site.route.useTransitions,
|
|
24
|
+
future: {
|
|
25
|
+
v7_startTransition: site.route.useTransitions
|
|
26
|
+
}
|
|
27
|
+
};
|
|
12
28
|
return /*#__PURE__*/ jsx(ThemeContext.Provider, {
|
|
13
29
|
value: useMemo(()=>({
|
|
14
30
|
theme,
|
|
@@ -17,23 +33,13 @@ function ClientApp({ initialPageData = null }) {
|
|
|
17
33
|
theme,
|
|
18
34
|
setTheme
|
|
19
35
|
]),
|
|
20
|
-
children: /*#__PURE__*/ jsx(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
data,
|
|
26
|
-
setData
|
|
27
|
-
]),
|
|
28
|
-
children: /*#__PURE__*/ jsx(BrowserRouter, {
|
|
29
|
-
basename: removeTrailingSlash(withBase('/')),
|
|
30
|
-
useTransitions: site.route.useTransitions,
|
|
31
|
-
children: /*#__PURE__*/ jsx(UnheadProvider, {
|
|
32
|
-
head: head,
|
|
33
|
-
children: /*#__PURE__*/ jsx(App, {})
|
|
34
|
-
})
|
|
36
|
+
children: /*#__PURE__*/ jsx(UnheadProvider, {
|
|
37
|
+
head: head,
|
|
38
|
+
children: /*#__PURE__*/ jsx(RouterProvider, {
|
|
39
|
+
router: router,
|
|
40
|
+
...transitionOptions
|
|
35
41
|
})
|
|
36
42
|
})
|
|
37
43
|
});
|
|
38
44
|
}
|
|
39
|
-
export { ClientApp };
|
|
45
|
+
export { ClientApp, createClientRouter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ErrorRoute(): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ErrorLayout } from "@rspress/core/theme";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { useLocation, useRouteError } from "react-router-dom";
|
|
5
|
+
import { useSite } from "./hooks/useSite.js";
|
|
6
|
+
import { withBase } from "./utils.js";
|
|
7
|
+
function ErrorRoute() {
|
|
8
|
+
const error = useRouteError();
|
|
9
|
+
const { pathname } = useLocation();
|
|
10
|
+
const { site } = useSite();
|
|
11
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
12
|
+
const version = site.multiVersion.versions.find((v)=>v === segments[0]);
|
|
13
|
+
const lang = site.locales.find((locale)=>locale.lang === segments[version ? 1 : 0])?.lang || site.lang;
|
|
14
|
+
const prefix = [
|
|
15
|
+
version !== site.multiVersion.default ? version : void 0,
|
|
16
|
+
lang !== site.lang ? lang : void 0
|
|
17
|
+
].filter(Boolean);
|
|
18
|
+
const homeHref = withBase(prefix.length ? `/${prefix.join('/')}/` : '/');
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
console.error('[rspress] Failed to render page:', error);
|
|
21
|
+
}, [
|
|
22
|
+
error
|
|
23
|
+
]);
|
|
24
|
+
return /*#__PURE__*/ jsx(ErrorLayout, {
|
|
25
|
+
error: error,
|
|
26
|
+
lang: lang,
|
|
27
|
+
homeHref: homeHref
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export { ErrorRoute };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import nprogress from "nprogress";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { useLoaderData, useNavigation } from "react-router-dom";
|
|
5
|
+
import { App } from "./App.js";
|
|
6
|
+
import { ErrorRoute } from "./ErrorRoute.js";
|
|
7
|
+
import { PageContext } from "./hooks/usePage.js";
|
|
8
|
+
import { PAGE_ROUTE_ID, pageDataLoader } from "./pageDataLoader.js";
|
|
9
|
+
nprogress.configure({
|
|
10
|
+
showSpinner: false
|
|
11
|
+
});
|
|
12
|
+
function PageRoute() {
|
|
13
|
+
const page = useLoaderData();
|
|
14
|
+
const { state } = useNavigation();
|
|
15
|
+
const [override, setOverride] = useState();
|
|
16
|
+
const data = override?.source === page ? override.data : page;
|
|
17
|
+
const setData = useCallback((data)=>{
|
|
18
|
+
setOverride({
|
|
19
|
+
source: page,
|
|
20
|
+
data
|
|
21
|
+
});
|
|
22
|
+
}, [
|
|
23
|
+
page
|
|
24
|
+
]);
|
|
25
|
+
useEffect(()=>{
|
|
26
|
+
if ('idle' === state) return;
|
|
27
|
+
const timer = setTimeout(()=>nprogress.start(), 200);
|
|
28
|
+
return ()=>{
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
nprogress.done();
|
|
31
|
+
};
|
|
32
|
+
}, [
|
|
33
|
+
state
|
|
34
|
+
]);
|
|
35
|
+
return /*#__PURE__*/ jsx(PageContext.Provider, {
|
|
36
|
+
value: useMemo(()=>({
|
|
37
|
+
data,
|
|
38
|
+
setData
|
|
39
|
+
}), [
|
|
40
|
+
data,
|
|
41
|
+
setData
|
|
42
|
+
]),
|
|
43
|
+
children: /*#__PURE__*/ jsx(App, {})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function createPageRoutes() {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
id: PAGE_ROUTE_ID,
|
|
50
|
+
path: '*',
|
|
51
|
+
loader: pageDataLoader,
|
|
52
|
+
element: /*#__PURE__*/ jsx(PageRoute, {}),
|
|
53
|
+
errorElement: /*#__PURE__*/ jsx(ErrorRoute, {}),
|
|
54
|
+
hydrateFallbackElement: /*#__PURE__*/ jsx(Fragment, {})
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
export { createPageRoutes };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createStaticHandler, createStaticRouter } from "virtual-react-router-server";
|
|
2
|
+
import { createPageRoutes } from "./PageRoute.js";
|
|
3
|
+
import { removeTrailingSlash, withBase } from "./utils.js";
|
|
4
|
+
async function createServerRouter(routePath) {
|
|
5
|
+
const basename = removeTrailingSlash(withBase('/'));
|
|
6
|
+
const { query, dataRoutes } = createStaticHandler(createPageRoutes(), {
|
|
7
|
+
basename
|
|
8
|
+
});
|
|
9
|
+
const context = await query(new Request(new URL(`${basename}${routePath}`, 'http://rspress.local')));
|
|
10
|
+
if (context instanceof Response) throw new Error(`Unexpected response while rendering ${routePath}: ${context.status}`);
|
|
11
|
+
if (context.errors) throw Object.values(context.errors)[0];
|
|
12
|
+
return {
|
|
13
|
+
router: createStaticRouter(dataRoutes, context),
|
|
14
|
+
context
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export { createServerRouter };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
|
-
import { ClientApp } from "./ClientApp.js";
|
|
3
|
+
import { ClientApp, createClientRouter } from "./ClientApp.js";
|
|
4
4
|
import { redirectToCleanUrl } from "./route.js";
|
|
5
5
|
function renderInBrowser() {
|
|
6
6
|
redirectToCleanUrl(window.location, window.history);
|
|
7
7
|
const container = document.getElementById('__rspress_root');
|
|
8
|
-
|
|
8
|
+
const router = createClientRouter();
|
|
9
|
+
createRoot(container).render(/*#__PURE__*/ jsx(ClientApp, {
|
|
10
|
+
router: router
|
|
11
|
+
}));
|
|
9
12
|
}
|
|
10
13
|
renderInBrowser();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
function createExternalStore(initialValue) {
|
|
3
|
+
let value = initialValue;
|
|
4
|
+
const listeners = new Set();
|
|
5
|
+
const getSnapshot = ()=>value;
|
|
6
|
+
const subscribe = (listener)=>{
|
|
7
|
+
listeners.add(listener);
|
|
8
|
+
return ()=>listeners.delete(listener);
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
update (nextValue) {
|
|
12
|
+
value = nextValue;
|
|
13
|
+
for (const listener of listeners)listener();
|
|
14
|
+
},
|
|
15
|
+
useValue () {
|
|
16
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export { createExternalStore };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useGlobalComponents(): ([import("react").ComponentType, object] | import("react").ComponentType)[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import virtual_global_components from "virtual-global-components";
|
|
2
|
+
import { createExternalStore } from "./createExternalStore.js";
|
|
3
|
+
const store = createExternalStore(virtual_global_components);
|
|
4
|
+
function useGlobalComponents() {
|
|
5
|
+
return store.useValue();
|
|
6
|
+
}
|
|
7
|
+
if (import.meta.webpackHot) import.meta.webpackHot.accept('virtual-global-components', ()=>{
|
|
8
|
+
store.update(virtual_global_components);
|
|
9
|
+
});
|
|
10
|
+
export { useGlobalComponents };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
|
-
import
|
|
2
|
+
import { useI18nText } from "./useI18nText.js";
|
|
3
3
|
import { useLang } from "./useLang.js";
|
|
4
4
|
function useI18n() {
|
|
5
5
|
const lang = useLang();
|
|
6
|
+
const i18nTextData = useI18nText();
|
|
6
7
|
return useCallback((key, params)=>{
|
|
7
|
-
const text =
|
|
8
|
+
const text = i18nTextData[key]?.[lang];
|
|
8
9
|
if ('string' != typeof text) throw new Error(`i18n key "${key}" not found for language "${lang}"`);
|
|
9
10
|
return text.replace(/\{\{(\w+)\}\}/g, (_, p1)=>params?.[p1] ?? `${p1}`);
|
|
10
11
|
}, [
|
|
11
|
-
lang
|
|
12
|
+
lang,
|
|
13
|
+
i18nTextData
|
|
12
14
|
]);
|
|
13
15
|
}
|
|
14
16
|
export { useI18n };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useI18nText(): Record<string, Record<string, string>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import virtual_i18n_text from "virtual-i18n-text";
|
|
2
|
+
import { createExternalStore } from "./createExternalStore.js";
|
|
3
|
+
const store = createExternalStore(virtual_i18n_text);
|
|
4
|
+
function useI18nText() {
|
|
5
|
+
return store.useValue();
|
|
6
|
+
}
|
|
7
|
+
if (import.meta.webpackHot) import.meta.webpackHot.accept('virtual-i18n-text', ()=>{
|
|
8
|
+
store.update(virtual_i18n_text);
|
|
9
|
+
});
|
|
10
|
+
export { useI18nText };
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { pageData } from "virtual-page-data";
|
|
1
|
+
import { pageData, searchIndexHash } from "virtual-page-data";
|
|
2
|
+
import { createExternalStore } from "./createExternalStore.js";
|
|
3
|
+
let usePages_pageData = pageData;
|
|
4
|
+
let usePages_searchIndexHash = searchIndexHash;
|
|
5
|
+
const store = createExternalStore(usePages_pageData);
|
|
2
6
|
function usePages() {
|
|
3
7
|
return {
|
|
4
|
-
pages:
|
|
8
|
+
pages: store.useValue().pages
|
|
5
9
|
};
|
|
6
10
|
}
|
|
7
|
-
|
|
11
|
+
if (import.meta.webpackHot) import.meta.webpackHot.accept('virtual-page-data', ()=>{
|
|
12
|
+
usePages_pageData = pageData;
|
|
13
|
+
usePages_searchIndexHash = searchIndexHash;
|
|
14
|
+
store.update(usePages_pageData);
|
|
15
|
+
});
|
|
16
|
+
export { usePages, usePages_pageData as pageData, usePages_searchIndexHash as searchIndexHash };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BeforeSearch, OnSearch, AfterSearch, RenderSearchFunction } from '@rspress/core/theme';
|
|
2
|
+
export interface SearchHooks {
|
|
3
|
+
beforeSearch?: BeforeSearch;
|
|
4
|
+
onSearch?: OnSearch;
|
|
5
|
+
afterSearch?: AfterSearch;
|
|
6
|
+
render?: RenderSearchFunction;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSearchHooks(): SearchHooks;
|