@rspress/core 2.0.23 → 2.1.0-beta.2
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/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/CdnTabs/index.test.tsx +71 -0
- package/dist/eject-theme/components/CdnTabs/index.tsx +175 -0
- package/dist/eject-theme/components/DocContent/index.tsx +0 -3
- package/dist/eject-theme/components/FallbackHeading/index.tsx +6 -1
- package/dist/eject-theme/components/Link/getHref.ts +1 -0
- package/dist/eject-theme/components/Link/index.tsx +9 -21
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +43 -54
- package/dist/eject-theme/components/NavTitle/index.test.tsx +78 -0
- package/dist/eject-theme/components/NavTitle/index.tsx +9 -5
- package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +79 -1
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +25 -12
- package/dist/eject-theme/components/Search/NoSearchResult.scss +1 -2
- package/dist/eject-theme/components/Search/SearchPanel.scss +75 -63
- package/dist/eject-theme/components/Search/SuggestItem.scss +28 -41
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +4 -1
- package/dist/eject-theme/components/Search/useSearchPanel.ts +103 -36
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +8 -0
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +3 -0
- package/dist/eject-theme/components/SocialLinks/GithubStars.test.tsx +4 -1
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +1 -1
- package/dist/entry/worker.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/node/PluginDriver.d.ts +5 -0
- package/dist/node/PluginDriver.js +17 -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 +19 -7
- 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/mdx/rehypePlugins/headerAnchor.js +1 -0
- package/dist/node/mdx/remarkPlugins/link.js +1 -1
- 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 → i18n/DEFAULT_I18N_TEXT.d.ts} +28 -0
- package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.js → i18n/DEFAULT_I18N_TEXT.js} +28 -0
- package/dist/node/runtimeModule/i18n/getI18nData.d.ts +11 -0
- package/dist/node/runtimeModule/{i18n.js → i18n/getI18nData.js} +35 -22
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.d.ts +5 -0
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +21 -0
- 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.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +3 -3
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +3 -4
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +2 -2
- package/dist/node/serve.js +1 -1
- package/dist/node/sitemap.d.ts +7 -0
- package/dist/node/sitemap.js +86 -0
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +1 -1
- 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 +6 -3
- package/dist/{a~0.js → p~0.js} +23 -18
- package/dist/runtime/App.js +20 -29
- package/dist/runtime/BrowserOnly.d.ts +1 -1
- package/dist/runtime/BrowserOnly.js +53 -20
- package/dist/runtime/ClientApp.d.ts +3 -2
- package/dist/runtime/ClientApp.js +31 -21
- package/dist/runtime/ErrorRoute.d.ts +1 -0
- package/dist/runtime/ErrorRoute.js +30 -0
- package/dist/runtime/NoSSR.d.ts +7 -3
- package/dist/runtime/NoSSR.js +30 -9
- package/dist/runtime/PageRoute.d.ts +2 -0
- package/dist/runtime/PageRoute.js +70 -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/useWebMcp.d.ts +36 -0
- package/dist/runtime/hooks/useWebMcp.js +80 -0
- package/dist/runtime/index.d.ts +6 -3
- package/dist/runtime/index.js +6 -5
- package/dist/runtime/initPageData.d.ts +0 -3
- package/dist/runtime/initPageData.js +9 -45
- package/dist/runtime/pageDataLoader.d.ts +11 -0
- package/dist/runtime/pageDataLoader.js +7 -0
- package/dist/runtime/react.d.ts +5 -0
- package/dist/runtime/react.js +4 -0
- package/dist/runtime/reactDom.d.ts +6 -0
- package/dist/runtime/reactDom.js +2 -1
- package/dist/runtime/socialLinks.d.ts +1 -0
- package/dist/runtime/socialLinks.js +3 -0
- package/dist/runtime/ssrClientEntry.js +14 -6
- package/dist/runtime/ssrMdServerEntry.js +10 -21
- package/dist/runtime/ssrServerEntry.js +10 -21
- package/dist/static/assets/package.json +58 -0
- package/dist/theme/assets/bun.js +101 -0
- package/dist/theme/assets/deno.js +15 -0
- package/dist/theme/assets/jsdelivr.js +53 -0
- package/dist/theme/{components/PackageManagerTabs/icons/Npm.js → assets/npm.js} +4 -4
- package/dist/theme/{components/PackageManagerTabs/icons/Pnpm.js → assets/pnpm.js} +4 -4
- package/dist/theme/assets/unpkg.js +15 -0
- package/dist/theme/assets/yarn.js +22 -0
- package/dist/theme/components/CdnTabs/index.d.ts +10 -0
- package/dist/theme/components/CdnTabs/index.js +146 -0
- package/dist/theme/components/DocContent/index.js +1 -2
- package/dist/theme/components/FallbackHeading/index.js +1 -0
- package/dist/theme/components/Link/index.js +4 -17
- package/dist/theme/components/Link/useLinkNavigate.d.ts +2 -2
- package/dist/theme/components/Link/useLinkNavigate.js +22 -36
- package/dist/theme/components/NavTitle/index.js +10 -5
- package/dist/theme/components/PackageManagerTabs/index.d.ts +2 -0
- package/dist/theme/components/PackageManagerTabs/index.js +22 -12
- package/dist/theme/components/Search/NoSearchResult.css +1 -2
- package/dist/theme/components/Search/SearchPanel.css +72 -51
- package/dist/theme/components/Search/SuggestItem.css +21 -34
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +4 -1
- package/dist/theme/components/Search/useSearchPanel.js +74 -26
- package/dist/theme/components/Sidebar/SidebarItem.css +5 -0
- package/dist/theme/components/Sidebar/SidebarSectionHeader.css +1 -0
- package/dist/theme/components/SocialLinks/GithubStars.js +1 -1
- package/dist/theme/hooks/useDynamicToc.js +27 -34
- 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/icons.d.ts +7 -0
- package/dist/theme/icons.js +15 -1
- package/dist/theme/index.d.ts +6 -2
- package/dist/theme/index.js +6 -2
- 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/layout/Layout/index.js +1 -2
- 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/y~0.js +166 -0
- package/package.json +18 -18
- package/dist/b~0.js +0 -106
- package/dist/eject-theme/components/PackageManagerTabs/icons/Bun.tsx +0 -101
- package/dist/eject-theme/components/PackageManagerTabs/icons/Deno.tsx +0 -18
- package/dist/eject-theme/components/PackageManagerTabs/icons/Npm.tsx +0 -16
- package/dist/eject-theme/components/PackageManagerTabs/icons/Pnpm.tsx +0 -22
- package/dist/eject-theme/components/PackageManagerTabs/icons/Yarn.tsx +0 -18
- package/dist/node/runtimeModule/i18n.d.ts +0 -8
- package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Bun.js +0 -137
- package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Deno.js +0 -15
- package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.js +0 -22
- package/dist/theme/logic/useScrollAfterNav.d.ts +0 -5
- package/dist/theme/logic/useScrollAfterNav.js +0 -35
- package/dist/theme/logic/useScrollReset.d.ts +0 -5
- package/dist/theme/logic/useScrollReset.js +0 -12
package/dist/theme/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { Badge, type BadgeProps } from './components/Badge/index.js';
|
|
|
2
2
|
export { Banner, type BannerProps } from './components/Banner/index.js';
|
|
3
3
|
export { Button, type ButtonProps } from './components/Button/index.js';
|
|
4
4
|
export { Callout, type CalloutProps } from './components/Callout/index.js';
|
|
5
|
+
export { CdnTabs, type CdnName, type CdnTabsProps, } from './components/CdnTabs/index.js';
|
|
5
6
|
export { CodeBlock, type CodeBlockProps } from './components/CodeBlock/index.js';
|
|
6
7
|
export { CodeBlockRuntime, type CodeBlockRuntimeProps, } from './components/CodeBlockRuntime/index.js';
|
|
7
8
|
export { CodeButtonGroup, type CodeButtonGroupProps, useCodeButtonGroup, } from './components/CodeButtonGroup/index.js';
|
|
@@ -54,18 +55,21 @@ export { Tag } from './components/Tag/index.js';
|
|
|
54
55
|
export { Toc } from './components/Toc/index.js';
|
|
55
56
|
export { useActiveAnchor } from './hooks/useActiveAnchor.js';
|
|
56
57
|
export { useDynamicToc, useWatchToc } from './hooks/useDynamicToc.js';
|
|
58
|
+
export { useWebMcpNavigation } from './hooks/useWebMcpNavigation.js';
|
|
59
|
+
export { useWebMcpPageList } from './hooks/useWebMcpPageList.js';
|
|
60
|
+
export { useWebMcpPageReading } from './hooks/useWebMcpPageReading.js';
|
|
61
|
+
export { useWebMcpSiteInfo } from './hooks/useWebMcpSiteInfo.js';
|
|
57
62
|
export * from './icons.js';
|
|
58
63
|
export { DocLayout, type DocLayoutProps } from './layout/DocLayout/index.js';
|
|
59
64
|
export { HomeLayout, type HomeLayoutProps } from './layout/HomeLayout/index.js';
|
|
60
65
|
export { Layout, type LayoutProps } from './layout/Layout/index.js';
|
|
61
66
|
export { NotFoundLayout } from './layout/NotFountLayout/index.js';
|
|
67
|
+
export { ErrorLayout, type ErrorLayoutProps } from './layout/ErrorLayout/index.js';
|
|
62
68
|
export { copyToClipboard } from './logic/copyToClipboard.js';
|
|
63
69
|
export { getCopyableText } from './logic/getCopyableText.js';
|
|
64
70
|
export { mergeRefs } from './logic/mergeRefs.js';
|
|
65
71
|
export { useFullTextSearch } from './logic/useFullTextSearch.js';
|
|
66
72
|
export { usePrevNextPage } from './logic/usePrevNextPage.js';
|
|
67
|
-
export { useScrollAfterNav } from './logic/useScrollAfterNav.js';
|
|
68
|
-
export { useScrollReset } from './logic/useScrollReset.js';
|
|
69
73
|
export { useSetup } from './logic/useSetup.js';
|
|
70
74
|
export { useStorageValue } from './logic/useStorageValue.js';
|
|
71
75
|
export { useThemeState } from './logic/useThemeState.js';
|
package/dist/theme/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { Badge } from "./components/Badge/index.js";
|
|
|
3
3
|
export { Banner } from "./components/Banner/index.js";
|
|
4
4
|
export { Button } from "./components/Button/index.js";
|
|
5
5
|
export { Callout } from "./components/Callout/index.js";
|
|
6
|
+
export { CdnTabs } from "./components/CdnTabs/index.js";
|
|
6
7
|
export { CodeBlock } from "./components/CodeBlock/index.js";
|
|
7
8
|
export { CodeBlockRuntime } from "./components/CodeBlockRuntime/index.js";
|
|
8
9
|
export { CodeButtonGroup, useCodeButtonGroup } from "./components/CodeButtonGroup/index.js";
|
|
@@ -53,17 +54,20 @@ export { Tag } from "./components/Tag/index.js";
|
|
|
53
54
|
export { Toc } from "./components/Toc/index.js";
|
|
54
55
|
export { useActiveAnchor } from "./hooks/useActiveAnchor.js";
|
|
55
56
|
export { useDynamicToc, useWatchToc } from "./hooks/useDynamicToc.js";
|
|
57
|
+
export { useWebMcpNavigation } from "./hooks/useWebMcpNavigation.js";
|
|
58
|
+
export { useWebMcpPageList } from "./hooks/useWebMcpPageList.js";
|
|
59
|
+
export { useWebMcpPageReading } from "./hooks/useWebMcpPageReading.js";
|
|
60
|
+
export { useWebMcpSiteInfo } from "./hooks/useWebMcpSiteInfo.js";
|
|
56
61
|
export { DocLayout } from "./layout/DocLayout/index.js";
|
|
57
62
|
export { HomeLayout } from "./layout/HomeLayout/index.js";
|
|
58
63
|
export { Layout } from "./layout/Layout/index.js";
|
|
59
64
|
export { NotFoundLayout } from "./layout/NotFountLayout/index.js";
|
|
65
|
+
export { ErrorLayout } from "./layout/ErrorLayout/index.js";
|
|
60
66
|
export { copyToClipboard } from "./logic/copyToClipboard.js";
|
|
61
67
|
export { getCopyableText } from "./logic/getCopyableText.js";
|
|
62
68
|
export { mergeRefs } from "./logic/mergeRefs.js";
|
|
63
69
|
export { useFullTextSearch } from "./logic/useFullTextSearch.js";
|
|
64
70
|
export { usePrevNextPage } from "./logic/usePrevNextPage.js";
|
|
65
|
-
export { useScrollAfterNav } from "./logic/useScrollAfterNav.js";
|
|
66
|
-
export { useScrollReset } from "./logic/useScrollReset.js";
|
|
67
71
|
export { useSetup } from "./logic/useSetup.js";
|
|
68
72
|
export { useStorageValue } from "./logic/useStorageValue.js";
|
|
69
73
|
export { useThemeState } from "./logic/useThemeState.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.rp-error {
|
|
2
|
+
min-height: 100dvh;
|
|
3
|
+
padding-top: 20vh;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.rp-error__description {
|
|
7
|
+
max-width: 28rem;
|
|
8
|
+
color: var(--rp-c-text-2);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.rp-error__actions {
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
gap: .75rem;
|
|
15
|
+
display: flex;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.rp-error__actions button {
|
|
19
|
+
font: inherit;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
background: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.rp-error__actions :focus-visible {
|
|
25
|
+
outline: 2px solid var(--rp-c-brand);
|
|
26
|
+
outline-offset: 4px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.rp-error__details {
|
|
30
|
+
border: 1px solid var(--rp-c-divider);
|
|
31
|
+
background: var(--rp-c-bg-soft);
|
|
32
|
+
text-align: left;
|
|
33
|
+
border-radius: .75rem;
|
|
34
|
+
width: 100%;
|
|
35
|
+
max-width: 56rem;
|
|
36
|
+
margin-top: 2.5rem;
|
|
37
|
+
padding: 1rem 1.25rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.rp-error__details summary {
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.rp-error__details pre {
|
|
46
|
+
max-height: 20rem;
|
|
47
|
+
margin-top: 1rem;
|
|
48
|
+
font-size: .8125rem;
|
|
49
|
+
line-height: 1.7;
|
|
50
|
+
overflow: auto;
|
|
51
|
+
}
|
|
52
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '../NotFountLayout/index.scss';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
export interface ErrorLayoutProps {
|
|
4
|
+
error: unknown;
|
|
5
|
+
lang: string;
|
|
6
|
+
homeHref: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function ErrorLayout({ error, lang, homeHref }: ErrorLayoutProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18nText } from "@rspress/core/runtime";
|
|
3
|
+
import { useHead } from "@unhead/react";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { isRouteErrorResponse } from "react-router-dom";
|
|
6
|
+
import "../NotFountLayout/index.css";
|
|
7
|
+
import "./index.css";
|
|
8
|
+
function ErrorLayout({ error, lang, homeHref }) {
|
|
9
|
+
const i18n = useI18nText();
|
|
10
|
+
const title = useRef(null);
|
|
11
|
+
const text = (key, fallback)=>i18n[key]?.[lang] || fallback;
|
|
12
|
+
const heading = text('errorTitleText', 'Something went wrong');
|
|
13
|
+
useHead({
|
|
14
|
+
title: heading
|
|
15
|
+
});
|
|
16
|
+
const response = isRouteErrorResponse(error);
|
|
17
|
+
const details = import.meta.env.DEV ? error instanceof Error ? error.stack || error.message : response ? `${error.status} ${error.statusText}` : 'string' == typeof error ? error : 'Unknown error' : void 0;
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
title.current?.focus();
|
|
20
|
+
}, [
|
|
21
|
+
heading
|
|
22
|
+
]);
|
|
23
|
+
return /*#__PURE__*/ jsxs("main", {
|
|
24
|
+
className: "rp-not-found rp-error",
|
|
25
|
+
"aria-labelledby": "rp-error-title",
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ jsx("p", {
|
|
28
|
+
className: "rp-not-found__error-code",
|
|
29
|
+
children: response ? error.status : 'ERROR'
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ jsx("h1", {
|
|
32
|
+
className: "rp-not-found__title",
|
|
33
|
+
id: "rp-error-title",
|
|
34
|
+
ref: title,
|
|
35
|
+
tabIndex: -1,
|
|
36
|
+
children: heading
|
|
37
|
+
}),
|
|
38
|
+
/*#__PURE__*/ jsx("div", {
|
|
39
|
+
className: "rp-not-found__divider"
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ jsx("p", {
|
|
42
|
+
className: "rp-error__description",
|
|
43
|
+
children: text("errorDescriptionText", 'This page could not be loaded. Try reloading it or return to the home page.')
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ jsxs("div", {
|
|
46
|
+
className: "rp-not-found__action rp-error__actions",
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ jsx("button", {
|
|
49
|
+
type: "button",
|
|
50
|
+
className: "rp-not-found__home-link",
|
|
51
|
+
onClick: ()=>window.location.reload(),
|
|
52
|
+
children: text('reloadPageText', 'Reload page')
|
|
53
|
+
}),
|
|
54
|
+
/*#__PURE__*/ jsx("a", {
|
|
55
|
+
className: "rp-not-found__home-link",
|
|
56
|
+
href: homeHref,
|
|
57
|
+
children: text('takeMeHomeText', 'Take me home')
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
}),
|
|
61
|
+
details && /*#__PURE__*/ jsxs("details", {
|
|
62
|
+
className: "rp-error__details",
|
|
63
|
+
open: true,
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ jsx("summary", {
|
|
66
|
+
children: text('errorDetailsText', 'Error details')
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ jsx("pre", {
|
|
69
|
+
children: details
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export { ErrorLayout };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Content, useFrontmatter, useLocaleSiteData, usePage, useSite } from "@rspress/core/runtime";
|
|
3
|
-
import { DocLayout, HomeLayout as theme_HomeLayout, Nav, NotFoundLayout as theme_NotFoundLayout,
|
|
3
|
+
import { DocLayout, HomeLayout as theme_HomeLayout, Nav, NotFoundLayout as theme_NotFoundLayout, useSetup } from "@rspress/core/theme";
|
|
4
4
|
import { Head, useHead } from "@unhead/react";
|
|
5
5
|
import react, { memo, useMemo } from "react";
|
|
6
6
|
const concatTitle = (title, suffix)=>{
|
|
@@ -60,7 +60,6 @@ const HeadTags = /*#__PURE__*/ memo((props)=>{
|
|
|
60
60
|
});
|
|
61
61
|
const ClientEffects = ()=>{
|
|
62
62
|
useSetup();
|
|
63
|
-
useScrollReset();
|
|
64
63
|
return null;
|
|
65
64
|
};
|
|
66
65
|
function Layout(props) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { WebMcpOptions } from '@rspress/core/runtime';
|
|
2
|
+
import type { PageInfo } from './types.js';
|
|
3
|
+
type Field = {
|
|
4
|
+
type: 'string';
|
|
5
|
+
minLength?: number;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'integer';
|
|
8
|
+
minimum: number;
|
|
9
|
+
maximum?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const queryField: Field;
|
|
12
|
+
export declare const routePathField: Field;
|
|
13
|
+
export declare function toWebMcpSearchResults(groups: {
|
|
14
|
+
group: string;
|
|
15
|
+
result: unknown;
|
|
16
|
+
}[]): {
|
|
17
|
+
group: string;
|
|
18
|
+
results: unknown;
|
|
19
|
+
}[];
|
|
20
|
+
export declare function resolveInternalRoute(value: string, context: {
|
|
21
|
+
origin: string;
|
|
22
|
+
resolveRoute(pathname: string): string | undefined;
|
|
23
|
+
}): string;
|
|
24
|
+
export declare function metadata(page: PageInfo): {
|
|
25
|
+
title: string;
|
|
26
|
+
description: string | undefined;
|
|
27
|
+
routePath: string;
|
|
28
|
+
lang: string;
|
|
29
|
+
version: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function readPage(page: PageInfo, base: string, signal?: AbortSignal, fetcher?: typeof fetch): Promise<{
|
|
32
|
+
title: string;
|
|
33
|
+
description: string | undefined;
|
|
34
|
+
routePath: string;
|
|
35
|
+
lang: string;
|
|
36
|
+
version: string;
|
|
37
|
+
frontmatter: import("@rspress/shared").FrontMatterMeta;
|
|
38
|
+
toc: import("@rspress/shared").Header[];
|
|
39
|
+
markdown: string;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function listPages(pages: PageInfo[], current: Pick<PageInfo, 'lang' | 'version'>, args: Record<string, unknown>): {
|
|
42
|
+
pages: {
|
|
43
|
+
title: string;
|
|
44
|
+
description: string | undefined;
|
|
45
|
+
routePath: string;
|
|
46
|
+
lang: string;
|
|
47
|
+
version: string;
|
|
48
|
+
toc: import("@rspress/shared").Header[];
|
|
49
|
+
}[];
|
|
50
|
+
total: number;
|
|
51
|
+
offset: number;
|
|
52
|
+
limit: number;
|
|
53
|
+
};
|
|
54
|
+
/** Shared validation and defaults for Rspress's built-in tools. */
|
|
55
|
+
export declare function defineTool(name: string, description: string, fields: Record<string, Field>, required: string[], execute: (args: Record<string, unknown>, signal?: AbortSignal) => unknown): WebMcpOptions;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { normalizeHref, removeTrailingSlash } from "@rspress/shared";
|
|
2
|
+
const queryField = {
|
|
3
|
+
type: 'string',
|
|
4
|
+
minLength: 1
|
|
5
|
+
};
|
|
6
|
+
const routePathField = {
|
|
7
|
+
type: 'string',
|
|
8
|
+
minLength: 1
|
|
9
|
+
};
|
|
10
|
+
function toWebMcpSearchResults(groups) {
|
|
11
|
+
return groups.flatMap(({ group, result })=>{
|
|
12
|
+
try {
|
|
13
|
+
const json = JSON.stringify(result, (_key, value)=>{
|
|
14
|
+
if ([
|
|
15
|
+
'function',
|
|
16
|
+
'symbol',
|
|
17
|
+
'bigint'
|
|
18
|
+
].includes(typeof value)) throw new TypeError('Search result is not JSON-serializable.');
|
|
19
|
+
return value;
|
|
20
|
+
});
|
|
21
|
+
return void 0 === json ? [] : [
|
|
22
|
+
{
|
|
23
|
+
group,
|
|
24
|
+
results: JSON.parse(json)
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
} catch {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function argumentsObject(input, fields, required) {
|
|
33
|
+
const value = void 0 === input ? {} : input;
|
|
34
|
+
if (null === value || 'object' != typeof value || Array.isArray(value)) throw new TypeError('Tool arguments must be an object.');
|
|
35
|
+
const args = value;
|
|
36
|
+
for (const key of Object.keys(args))if (!Object.hasOwn(fields, key)) throw new TypeError(`Unknown argument: ${key}`);
|
|
37
|
+
for (const [key, field] of Object.entries(fields)){
|
|
38
|
+
const val = args[key];
|
|
39
|
+
if (void 0 !== val || required.includes(key)) {
|
|
40
|
+
if ('string' === field.type) {
|
|
41
|
+
if ('string' != typeof val || field.minLength && !val.trim()) throw new TypeError(`${key} must be ${field.minLength ? 'a non-empty' : 'a'} string.`);
|
|
42
|
+
} else if ('number' != typeof val || !Number.isSafeInteger(val) || val < field.minimum || void 0 !== field.maximum && val > field.maximum) throw new TypeError(`${key} must be an integer between ${field.minimum} and ${field.maximum ?? Number.MAX_SAFE_INTEGER}.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return args;
|
|
46
|
+
}
|
|
47
|
+
function resolveInternalRoute(value, context) {
|
|
48
|
+
if (!value.startsWith('/') || value.startsWith('//')) throw new TypeError('routePath must be an absolute internal path.');
|
|
49
|
+
const url = new URL(value, context.origin);
|
|
50
|
+
if (url.origin !== context.origin) throw new TypeError('External routes are not allowed.');
|
|
51
|
+
const path = context.resolveRoute(url.pathname);
|
|
52
|
+
if (!path) throw new TypeError(`Unknown internal route: ${url.pathname}`);
|
|
53
|
+
return `${path}${url.search}${url.hash}`;
|
|
54
|
+
}
|
|
55
|
+
function metadata(page) {
|
|
56
|
+
return {
|
|
57
|
+
title: page.title,
|
|
58
|
+
description: page.description,
|
|
59
|
+
routePath: page.routePath,
|
|
60
|
+
lang: page.lang,
|
|
61
|
+
version: page.version
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function readPage(page, base, signal, fetcher = fetch) {
|
|
65
|
+
const url = `${removeTrailingSlash(base)}${normalizeHref(page.routePath, false).replace(/\.html$/, '.md')}`;
|
|
66
|
+
const response = await fetcher(url, {
|
|
67
|
+
signal
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) throw new Error(`Failed to read Markdown for ${page.routePath}: ${response.status}`);
|
|
70
|
+
const markdown = await response.text();
|
|
71
|
+
if (response.headers.get('content-type')?.includes('text/html') || /^\s*(?:<!doctype\s+html|<html[\s>])/i.test(markdown)) throw new Error(`Markdown is unavailable for ${page.routePath}. Serve the output of rspress build with llms enabled.`);
|
|
72
|
+
return {
|
|
73
|
+
...metadata(page),
|
|
74
|
+
frontmatter: page.frontmatter,
|
|
75
|
+
toc: page.toc,
|
|
76
|
+
markdown
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function listPages(pages, current, args) {
|
|
80
|
+
const lang = args.lang ?? current.lang;
|
|
81
|
+
const version = args.version ?? current.version;
|
|
82
|
+
const terms = args.query?.trim().toLowerCase().split(/\s+/) ?? [];
|
|
83
|
+
const matches = pages.filter((page)=>{
|
|
84
|
+
const text = [
|
|
85
|
+
page.title,
|
|
86
|
+
page.description,
|
|
87
|
+
page.routePath,
|
|
88
|
+
...page.toc.map((item)=>item.text)
|
|
89
|
+
].join(' ').toLowerCase();
|
|
90
|
+
return page.lang === lang && page.version === version && terms.every((term)=>text.includes(term));
|
|
91
|
+
});
|
|
92
|
+
const limit = args.limit ?? 50;
|
|
93
|
+
const offset = args.offset ?? 0;
|
|
94
|
+
return {
|
|
95
|
+
pages: matches.slice(offset, offset + limit).map((page)=>({
|
|
96
|
+
...metadata(page),
|
|
97
|
+
toc: page.toc
|
|
98
|
+
})),
|
|
99
|
+
total: matches.length,
|
|
100
|
+
offset,
|
|
101
|
+
limit
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function defineTool(name, description, fields, required, execute) {
|
|
105
|
+
return {
|
|
106
|
+
name: `rspress_${name}`,
|
|
107
|
+
description,
|
|
108
|
+
inputSchema: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: fields,
|
|
111
|
+
required,
|
|
112
|
+
additionalProperties: false
|
|
113
|
+
},
|
|
114
|
+
annotations: {
|
|
115
|
+
readOnlyHint: 'navigate' !== name,
|
|
116
|
+
untrustedContentHint: true
|
|
117
|
+
},
|
|
118
|
+
exposedTo: import.meta.env.WEBMCP_EXPOSED_TO,
|
|
119
|
+
execute: (input, options)=>execute(argumentsObject(input, fields, required), options.signal)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export { defineTool, listPages, metadata, queryField, readPage, resolveInternalRoute, routePathField, toWebMcpSearchResults };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BaseRuntimePageInfo, NavItem, SidebarData } from '@rspress/shared';
|
|
2
|
+
export type PageInfo = Pick<BaseRuntimePageInfo, 'title' | 'description' | 'routePath' | 'lang' | 'version' | 'toc' | 'frontmatter'>;
|
|
3
|
+
export interface SiteInfo {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
base: string;
|
|
7
|
+
siteOrigin: string;
|
|
8
|
+
lang: string;
|
|
9
|
+
version: string;
|
|
10
|
+
locales: {
|
|
11
|
+
lang: string;
|
|
12
|
+
label: string;
|
|
13
|
+
}[];
|
|
14
|
+
versions: string[];
|
|
15
|
+
defaultVersion: string;
|
|
16
|
+
nav: NavItem[];
|
|
17
|
+
sidebar: SidebarData;
|
|
18
|
+
}
|
|
19
|
+
export interface NavigationResult {
|
|
20
|
+
routePath: string;
|
|
21
|
+
page: Pick<PageInfo, 'title' | 'description' | 'lang' | 'version'>;
|
|
22
|
+
sections: {
|
|
23
|
+
title: string;
|
|
24
|
+
depth: number;
|
|
25
|
+
routePath: string;
|
|
26
|
+
}[];
|
|
27
|
+
previousPage: {
|
|
28
|
+
title: string;
|
|
29
|
+
routePath: string;
|
|
30
|
+
} | null;
|
|
31
|
+
nextPage: {
|
|
32
|
+
title: string;
|
|
33
|
+
routePath: string;
|
|
34
|
+
} | null;
|
|
35
|
+
}
|
|
File without changes
|
package/dist/tinypool~0.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { MessageChannel, MessagePort, Worker, receiveMessageOnPort } from "node:worker_threads";
|
|
2
2
|
import { EventEmitterAsyncResource, once } from "node:events";
|
|
3
3
|
import { AsyncResource } from "node:async_hooks";
|
|
4
|
-
import { URL, fileURLToPath } from "node:url";
|
|
5
|
-
import { join } from "node:path";
|
|
4
|
+
import { URL as external_node_url_URL, fileURLToPath } from "node:url";
|
|
6
5
|
import { inspect, types } from "node:util";
|
|
7
6
|
import node_assert from "node:assert";
|
|
8
7
|
import { performance } from "node:perf_hooks";
|
|
9
8
|
import { readFileSync } from "node:fs";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import { availableParallelism } from "node:os";
|
|
10
|
+
import { fork } from "node:child_process";
|
|
12
11
|
const kMovable = Symbol("Tinypool.kMovable");
|
|
13
12
|
const kTransferable = Symbol.for("Tinypool.transferable");
|
|
14
13
|
const kValue = Symbol.for("Tinypool.valueOf");
|
|
@@ -27,42 +26,9 @@ function markMovable(value) {
|
|
|
27
26
|
value: true
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
encoding: "utf8",
|
|
33
|
-
stdio: [
|
|
34
|
-
null,
|
|
35
|
-
null,
|
|
36
|
-
null
|
|
37
|
-
]
|
|
38
|
-
});
|
|
39
|
-
return output;
|
|
40
|
-
}
|
|
41
|
-
let amount;
|
|
42
|
-
try {
|
|
43
|
-
const platform = node_os.platform();
|
|
44
|
-
if ("linux" === platform) {
|
|
45
|
-
const output1 = exec("cat /proc/cpuinfo | grep \"physical id\" | sort |uniq | wc -l");
|
|
46
|
-
const output2 = exec("cat /proc/cpuinfo | grep \"core id\" | sort | uniq | wc -l");
|
|
47
|
-
const physicalCpuAmount = parseInt(output1.trim(), 10);
|
|
48
|
-
const physicalCoreAmount = parseInt(output2.trim(), 10);
|
|
49
|
-
amount = physicalCpuAmount * physicalCoreAmount;
|
|
50
|
-
} else if ("darwin" === platform) {
|
|
51
|
-
const output = exec("sysctl -n hw.physicalcpu_max");
|
|
52
|
-
amount = parseInt(output.trim(), 10);
|
|
53
|
-
} else if ("win32" === platform) throw new Error();
|
|
54
|
-
else {
|
|
55
|
-
const cores = node_os.cpus().filter(function(cpu, index) {
|
|
56
|
-
const hasHyperthreading = cpu.model.includes("Intel");
|
|
57
|
-
const isOdd = index % 2 === 1;
|
|
58
|
-
return !hasHyperthreading || isOdd;
|
|
59
|
-
});
|
|
60
|
-
amount = cores.length;
|
|
61
|
-
}
|
|
62
|
-
} catch {
|
|
63
|
-
amount = node_os.cpus().length;
|
|
29
|
+
function withNullPrototype(source) {
|
|
30
|
+
return Object.assign(Object.create(null), source);
|
|
64
31
|
}
|
|
65
|
-
if (0 === amount) amount = node_os.cpus().length;
|
|
66
32
|
var ThreadWorker = class {
|
|
67
33
|
name = "ThreadWorker";
|
|
68
34
|
runtime = "worker_threads";
|
|
@@ -194,7 +160,7 @@ var ProcessWorker = class {
|
|
|
194
160
|
function hasUnref(stream) {
|
|
195
161
|
return null != stream && "unref" in stream && "function" == typeof stream.unref;
|
|
196
162
|
}
|
|
197
|
-
const cpuCount =
|
|
163
|
+
const cpuCount = availableParallelism();
|
|
198
164
|
function onabort(abortSignal, listener) {
|
|
199
165
|
if ("addEventListener" in abortSignal) abortSignal.addEventListener("abort", listener, {
|
|
200
166
|
once: true
|
|
@@ -285,7 +251,8 @@ var ArrayBufferViewTransferable = class {
|
|
|
285
251
|
};
|
|
286
252
|
let taskIdCounter = 0;
|
|
287
253
|
function maybeFileURLToPath(filename) {
|
|
288
|
-
|
|
254
|
+
if ("string" != typeof filename) return "file:" === filename.protocol ? fileURLToPath(filename) : filename.href;
|
|
255
|
+
return filename.startsWith("file:") ? fileURLToPath(new external_node_url_URL(filename)) : filename;
|
|
289
256
|
}
|
|
290
257
|
var TaskInfo = class extends AsyncResource {
|
|
291
258
|
abortListener = null;
|
|
@@ -508,12 +475,12 @@ var ThreadPool = class {
|
|
|
508
475
|
this.publicInterface = publicInterface;
|
|
509
476
|
this.taskQueue = options.taskQueue || new ArrayTaskQueue();
|
|
510
477
|
const filename = options.filename ? maybeFileURLToPath(options.filename) : null;
|
|
511
|
-
this.options = {
|
|
478
|
+
this.options = withNullPrototype({
|
|
512
479
|
...kDefaultOptions,
|
|
513
480
|
...options,
|
|
514
481
|
filename,
|
|
515
482
|
maxQueue: 0
|
|
516
|
-
};
|
|
483
|
+
});
|
|
517
484
|
if (void 0 !== options.maxThreads && this.options.minThreads >= options.maxThreads) this.options.minThreads = options.maxThreads;
|
|
518
485
|
if (void 0 !== options.minThreads && this.options.maxThreads <= options.minThreads) this.options.maxThreads = options.minThreads;
|
|
519
486
|
if ("auto" === options.maxQueue) this.options.maxQueue = this.options.maxThreads ** 2;
|
|
@@ -559,7 +526,8 @@ var ThreadPool = class {
|
|
|
559
526
|
tinypoolPrivateData,
|
|
560
527
|
this.options.workerData
|
|
561
528
|
],
|
|
562
|
-
trackUnmanagedFds: this.options.trackUnmanagedFds
|
|
529
|
+
trackUnmanagedFds: this.options.trackUnmanagedFds,
|
|
530
|
+
serialization: this.options.serialization
|
|
563
531
|
});
|
|
564
532
|
const onMessage = (message$1)=>{
|
|
565
533
|
const { taskId, result } = message$1;
|
|
@@ -649,7 +617,7 @@ var ThreadPool = class {
|
|
|
649
617
|
const { transferList = [], signal = null, channel } = options;
|
|
650
618
|
if (null == filename) filename = this.options.filename;
|
|
651
619
|
if (null == name) name = this.options.name;
|
|
652
|
-
if ("string" != typeof filename) return Promise.reject(Errors.FilenameNotProvided());
|
|
620
|
+
if ("string" != typeof filename && !(filename instanceof external_node_url_URL)) return Promise.reject(Errors.FilenameNotProvided());
|
|
653
621
|
filename = maybeFileURLToPath(filename);
|
|
654
622
|
let resolve;
|
|
655
623
|
let reject;
|
|
@@ -731,7 +699,8 @@ var ThreadPool = class {
|
|
|
731
699
|
}
|
|
732
700
|
await Promise.all(exitEvents);
|
|
733
701
|
}
|
|
734
|
-
async recycleWorkers(
|
|
702
|
+
async recycleWorkers(_options = {}) {
|
|
703
|
+
const options = withNullPrototype(_options);
|
|
735
704
|
const runtimeChanged = options?.runtime && options.runtime !== this.options.runtime;
|
|
736
705
|
if (options?.runtime) this.options.runtime = options.runtime;
|
|
737
706
|
if (this.options.isolateWorkers && !runtimeChanged) return;
|
|
@@ -748,7 +717,8 @@ var ThreadPool = class {
|
|
|
748
717
|
};
|
|
749
718
|
var Tinypool = class extends EventEmitterAsyncResource {
|
|
750
719
|
#pool;
|
|
751
|
-
constructor(
|
|
720
|
+
constructor(_options = {}){
|
|
721
|
+
const options = withNullPrototype(_options);
|
|
752
722
|
if (void 0 !== options.minThreads && options.minThreads > 0 && options.minThreads < 1) options.minThreads = Math.max(1, Math.floor(options.minThreads * cpuCount));
|
|
753
723
|
if (void 0 !== options.maxThreads && options.maxThreads > 0 && options.maxThreads < 1) options.maxThreads = Math.max(1, Math.floor(options.maxThreads * cpuCount));
|
|
754
724
|
super({
|
|
@@ -759,7 +729,7 @@ var Tinypool = class extends EventEmitterAsyncResource {
|
|
|
759
729
|
this.#pool = new ThreadPool(this, options);
|
|
760
730
|
}
|
|
761
731
|
run(task, options = kDefaultRunOptions) {
|
|
762
|
-
const { transferList, filename, name, signal, runtime, channel } = options;
|
|
732
|
+
const { transferList, filename, name, signal, runtime, channel } = withNullPrototype(options);
|
|
763
733
|
return this.#pool.runTask(task, {
|
|
764
734
|
transferList,
|
|
765
735
|
filename,
|
|
@@ -805,7 +775,7 @@ var Tinypool = class extends EventEmitterAsyncResource {
|
|
|
805
775
|
return process.__tinypool_state__?.workerData || void 0;
|
|
806
776
|
}
|
|
807
777
|
static get version() {
|
|
808
|
-
const { version } = JSON.parse(readFileSync(
|
|
778
|
+
const { version } = JSON.parse(readFileSync(new URL("./static/assets/package.json", import.meta.url), "utf-8"));
|
|
809
779
|
return version;
|
|
810
780
|
}
|
|
811
781
|
static move(val) {
|