@rspress/core 2.0.0-rc.0 → 2.0.0-rc.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/bin/rspress.js +1 -1
- package/dist/0~7675.989ee664.js +1791 -0
- package/dist/1218.3869bad6.js +2 -0
- package/dist/4669.12208c6a.js +2 -0
- package/dist/5313.6594aba0.js +63 -0
- package/dist/5485.2a0273cf.js +98 -0
- package/dist/6289.c67fe0d5.js +5 -0
- package/dist/7805.cadab34e.js +4 -0
- package/dist/8813.9da1f210.js +2 -0
- package/dist/cli/config/index.js +4 -0
- package/dist/cli/config/loadConfigFile.js +30 -0
- package/dist/cli/index.cb89dbd1.js +3 -0
- package/dist/cli/index.js +122 -0
- package/dist/eject-theme/components/Banner/index.tsx +3 -4
- package/dist/eject-theme/components/Button/index.scss +1 -6
- package/dist/eject-theme/components/Callout/index.scss +0 -2
- package/dist/eject-theme/components/CodeBlock/index.scss +4 -12
- package/dist/eject-theme/components/CodeBlock/index.tsx +6 -1
- package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -3
- package/dist/eject-theme/components/CodeButtonGroup/index.scss +5 -1
- package/dist/eject-theme/components/CodeButtonGroup/index.tsx +1 -3
- package/dist/eject-theme/components/DocContent/doc.scss +30 -9
- package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
- package/dist/eject-theme/components/DocContent/index.tsx +5 -2
- package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
- package/dist/eject-theme/components/HoverGroup/index.scss +5 -1
- package/dist/eject-theme/components/HoverGroup/index.tsx +5 -1
- package/dist/eject-theme/components/Link/index.tsx +43 -9
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +32 -16
- package/dist/eject-theme/components/Nav/NavMenu.scss +1 -0
- package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
- package/dist/eject-theme/components/Nav/NavTitle.scss +11 -0
- package/dist/eject-theme/components/Nav/NavTitle.tsx +1 -0
- package/dist/eject-theme/components/Nav/index.scss +0 -8
- package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +14 -0
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +2 -3
- package/dist/eject-theme/components/Outline/index.scss +0 -1
- package/dist/eject-theme/components/Overview/OverviewGroup.tsx +1 -2
- package/dist/eject-theme/components/Overview/index.tsx +6 -2
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +12 -0
- package/dist/eject-theme/components/PrevNextPage/index.tsx +6 -3
- package/dist/eject-theme/components/Root/index.tsx +58 -0
- package/dist/eject-theme/components/Search/NoSearchResult.tsx +2 -3
- package/dist/eject-theme/components/Search/SearchButton.tsx +3 -4
- package/dist/eject-theme/components/Search/SearchPanel.tsx +14 -9
- package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +12 -8
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +6 -4
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +1 -1
- package/dist/eject-theme/components/SidebarMenu/index.tsx +4 -4
- package/dist/eject-theme/components/SocialLinks/index.tsx +2 -3
- package/dist/eject-theme/components/SourceCode/index.scss +2 -1
- package/dist/eject-theme/components/SourceCode/index.tsx +6 -4
- package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
- package/dist/eject-theme/components/Tabs/index.scss +19 -22
- package/dist/eject-theme/components/Toc/TocItem.scss +8 -4
- package/dist/eject-theme/components/Toc/TocItem.tsx +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -3134
- package/dist/node/PluginDriver.d.ts +1 -1
- package/dist/node/PluginDriver.js +143 -0
- package/dist/node/auto-nav-sidebar/index.js +44 -0
- package/dist/node/auto-nav-sidebar/locales.js +26 -0
- package/dist/node/auto-nav-sidebar/normalize.js +228 -0
- package/dist/node/auto-nav-sidebar/utils.js +68 -0
- package/dist/node/auto-nav-sidebar/walk.js +67 -0
- package/dist/node/build.js +31 -0
- package/dist/node/constants.d.ts +1 -0
- package/dist/node/constants.js +33 -0
- package/dist/node/dev.js +32 -0
- package/dist/node/eject.js +111 -0
- package/dist/node/index.d.ts +5 -5
- package/dist/node/initRsbuild.d.ts +2 -2
- package/dist/node/initRsbuild.js +338 -0
- package/dist/node/last-updated/index.js +28 -0
- package/dist/node/logger/hint.d.ts +1 -1
- package/dist/node/logger/hint.js +85 -0
- package/dist/node/mdx/loader.d.ts +1 -1
- package/dist/node/mdx/loader.e1578c62.js +13 -0
- package/dist/{loader.js → node/mdx/loader.js} +2 -2
- package/dist/node/mdx/options.d.ts +2 -2
- package/dist/node/mdx/options.js +100 -0
- package/dist/node/mdx/processor.d.ts +2 -2
- package/dist/node/mdx/processor.js +71 -0
- package/dist/node/mdx/rehypePlugins/codeMeta.js +10 -0
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +53 -0
- package/dist/node/mdx/rehypePlugins/shiki.js +34 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-lang.js +15 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +22 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-title.js +24 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +22 -0
- package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +5 -5
- package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -0
- package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +41 -0
- package/dist/node/mdx/remarkPlugins/builtin.js +11 -0
- package/dist/node/mdx/remarkPlugins/containerSyntax.js +190 -0
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +66 -0
- package/dist/node/mdx/remarkPlugins/image.js +67 -0
- package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
- package/dist/node/mdx/remarkPlugins/link.js +99 -0
- package/dist/node/mdx/remarkPlugins/toc.js +50 -0
- package/dist/node/mdx/types.d.ts +3 -3
- package/dist/node/medium-zoom/index.d.ts +1 -1
- package/dist/node/medium-zoom/index.js +14 -0
- package/dist/node/route/RoutePage.d.ts +1 -1
- package/dist/node/route/RoutePage.js +61 -0
- package/dist/node/route/RouteService.d.ts +1 -1
- package/dist/node/route/RouteService.js +177 -0
- package/dist/node/route/extractPageData.d.ts +1 -1
- package/dist/node/route/extractPageData.js +112 -0
- package/dist/node/route/normalizeRoutePath.js +54 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +150 -0
- package/dist/node/runtimeModule/globalStyles.d.ts +1 -1
- package/dist/node/runtimeModule/globalStyles.js +12 -0
- package/dist/node/runtimeModule/globalUIComponents.d.ts +1 -1
- package/dist/node/runtimeModule/globalUIComponents.js +25 -0
- package/dist/node/runtimeModule/i18n.d.ts +2 -2
- package/dist/node/runtimeModule/i18n.js +83 -0
- package/dist/node/runtimeModule/pageData/createPageData.d.ts +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +64 -0
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +51 -0
- package/dist/node/runtimeModule/routeList.d.ts +1 -1
- package/dist/node/runtimeModule/routeList.js +7 -0
- package/dist/node/runtimeModule/searchHooks.d.ts +1 -1
- package/dist/node/runtimeModule/searchHooks.js +11 -0
- package/dist/node/runtimeModule/siteData/createSiteData.js +34 -0
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +94 -0
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.d.ts +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +24 -0
- package/dist/node/runtimeModule/socialLinks.d.ts +1 -1
- package/dist/node/runtimeModule/socialLinks.js +8 -0
- package/dist/node/runtimeModule/types.d.ts +2 -2
- package/dist/node/serve.js +23 -0
- package/dist/node/ssg/renderHtmlTemplate.js +33 -0
- package/dist/node/ssg/renderPage.js +34 -0
- package/dist/node/ssg/renderPageWorker.474f9f73.js +2 -0
- package/dist/node/ssg/renderPageWorker.js +15 -0
- package/dist/node/ssg/renderPages.d.ts +1 -1
- package/dist/node/ssg/renderPages.js +105 -0
- package/dist/node/ssg/renderPages.js.LICENSE.txt +4 -0
- package/dist/node/ssg/rsbuildPluginCSR.d.ts +1 -1
- package/dist/node/ssg/rsbuildPluginCSR.js +27 -0
- package/dist/node/ssg/rsbuildPluginSSG.d.ts +1 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +72 -0
- package/dist/node/ssg/ssgEnv.js +33 -0
- package/dist/node/ssg/ssgEnv.js.LICENSE.txt +5 -0
- package/dist/node/ssg-md/llms/emitLlmsTxt.d.ts +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +80 -0
- package/dist/node/ssg-md/llms/llmsTxt.d.ts +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +66 -0
- package/dist/node/ssg-md/react/index.d.ts +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +202 -0
- package/dist/node/ssg-md/renderPage.js +31 -0
- package/dist/node/ssg-md/renderPages.d.ts +1 -1
- package/dist/node/ssg-md/renderPages.js +27 -0
- package/dist/node/ssg-md/rsbuildPluginSSGMD.d.ts +1 -1
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +47 -0
- package/dist/node/utils/applyReplaceRules.js +6 -0
- package/dist/node/utils/checkLanguageParity.js +77 -0
- package/dist/node/utils/createHash.js +5 -0
- package/dist/node/utils/error.d.ts +9 -0
- package/dist/node/utils/error.js +9 -0
- package/dist/node/utils/escapeHeadingIds.js +5 -0
- package/dist/node/utils/flattenMdxContent.js +74 -0
- package/dist/node/utils/fs.js +14 -0
- package/dist/node/utils/getImportAstNode.js +63 -0
- package/dist/node/utils/getPageKey.js +6 -0
- package/dist/node/utils/getSocialIcons.js +32 -0
- package/dist/node/utils/index.d.ts +10 -9
- package/dist/node/utils/normalizePath.js +10 -0
- package/dist/node/utils/reactAlias.d.ts +2 -0
- package/dist/node/utils/reactAlias.js +83 -0
- package/dist/rslib-runtime.99091bf6.js +18 -0
- package/dist/runtime/App.js +2 -2
- package/dist/runtime/ClientApp.d.ts +1 -1
- package/dist/runtime/ClientApp.js +0 -4
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/runtime/ssrServerEntry.js +2 -1
- package/dist/runtime.72d450ac.js +1 -0
- package/dist/runtime.js +3 -2
- package/dist/shiki-transformers.d.ts +1 -1
- package/dist/shiki-transformers.js +6 -120
- package/dist/theme/assets/moon.js +9 -26
- package/dist/theme/components/Banner/index.d.ts +1 -1
- package/dist/theme/components/Banner/index.js +2 -3
- package/dist/theme/components/Button/index.css +1 -1
- package/dist/theme/components/Callout/index.css +0 -2
- package/dist/theme/components/CodeBlock/index.css +4 -15
- package/dist/theme/components/CodeBlock/index.js +1 -0
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +3 -5
- package/dist/theme/components/CodeButtonGroup/index.css +5 -1
- package/dist/theme/components/CodeButtonGroup/index.js +3 -5
- package/dist/theme/components/DocContent/doc.css +30 -8
- package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/table.d.ts +2 -2
- package/dist/theme/components/DocContent/docComponents/table.js +8 -3
- package/dist/theme/components/DocContent/index.js +3 -2
- package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
- package/dist/theme/components/HoverGroup/index.css +5 -1
- package/dist/theme/components/HoverGroup/index.js +1 -0
- package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
- package/dist/theme/components/Link/index.d.ts +18 -1
- package/dist/theme/components/Link/index.js +14 -8
- package/dist/theme/components/Link/useLinkNavigate.d.ts +4 -1
- package/dist/theme/components/Link/useLinkNavigate.js +23 -17
- package/dist/theme/components/Nav/NavMenu.css +1 -0
- package/dist/theme/components/Nav/NavMenu.js +2 -3
- package/dist/theme/components/Nav/NavTitle.css +12 -0
- package/dist/theme/components/Nav/NavTitle.d.ts +1 -0
- package/dist/theme/components/Nav/NavTitle.js +1 -0
- package/dist/theme/components/Nav/index.css +0 -8
- package/dist/theme/components/NavHamburger/index.js +3 -4
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +9 -0
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
- package/dist/theme/components/Outline/index.css +0 -1
- package/dist/theme/components/Overview/OverviewGroup.js +1 -2
- package/dist/theme/components/Overview/index.js +1 -2
- package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/index.js +4 -0
- package/dist/theme/components/PrevNextPage/index.js +3 -4
- package/dist/theme/components/Root/index.d.ts +54 -0
- package/dist/theme/components/Root/index.js +7 -0
- package/dist/theme/components/Search/NoSearchResult.js +2 -3
- package/dist/theme/components/Search/SearchButton.js +3 -4
- package/dist/theme/components/Search/SearchPanel.js +13 -16
- package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
- package/dist/theme/components/Search/SuggestItem.js +7 -11
- package/dist/theme/components/Search/logic/Provider.d.ts +1 -1
- package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +2 -2
- package/dist/theme/components/Search/logic/search.d.ts +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
- package/dist/theme/components/Sidebar/SidebarItem.css +11 -3
- package/dist/theme/components/Sidebar/SidebarItem.js +6 -3
- package/dist/theme/components/Sidebar/SidebarSectionHeader.css +1 -1
- package/dist/theme/components/SidebarMenu/index.js +3 -5
- package/dist/theme/components/SocialLinks/index.js +2 -3
- package/dist/theme/components/SourceCode/index.css +5 -0
- package/dist/theme/components/SourceCode/index.js +2 -4
- package/dist/theme/components/SwitchAppearance/index.js +3 -5
- package/dist/theme/components/Tabs/index.css +13 -22
- package/dist/theme/components/Toc/TocItem.css +7 -4
- package/dist/theme/components/Toc/TocItem.js +1 -0
- package/dist/theme/icons.d.ts +25 -0
- package/dist/theme/icons.js +47 -0
- package/dist/theme/index.d.ts +62 -59
- package/dist/theme/index.js +5 -2
- package/dist/theme/layout/DocLayout/index.css +2 -2
- package/dist/theme/layout/DocLayout/index.js +1 -4
- package/dist/theme/layout/Layout/index.d.ts +1 -1
- package/dist/theme/layout/Layout/index.js +3 -3
- package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
- package/dist/theme/logic/useScrollAfterNav.d.ts +5 -0
- package/dist/theme/logic/{sideEffects.js → useScrollAfterNav.js} +5 -6
- package/dist/theme/logic/useScrollReset.d.ts +5 -0
- package/dist/theme/logic/useScrollReset.js +12 -0
- package/dist/theme/logic/useSetup.js +2 -0
- package/dist/theme/styles/base.css +1 -10
- package/dist/theme/styles/index.d.ts +1 -1
- package/dist/theme/styles/index.js +1 -1
- package/dist/theme/styles/scrollbar.css +1 -0
- package/dist/theme/styles/vars/base-vars.css +5 -3
- package/dist/theme/styles/vars/home-vars.css +4 -2
- package/package.json +19 -20
- package/dist/3~101.js +0 -1786
- package/dist/3~335.js +0 -26
- package/dist/3~395.js +0 -74
- package/dist/cli.js +0 -259
- package/dist/index.js.LICENSE.txt +0 -10
- package/dist/node/auto-nav-sidebar/fixtures/docs/guide/c.d.ts +0 -2
- package/dist/node/auto-nav-sidebar/fixtures/docs-locales/en/guide/c.d.ts +0 -2
- package/dist/node/auto-nav-sidebar/fixtures/docs-locales/zh/guide/c.d.ts +0 -2
- package/dist/node/auto-nav-sidebar/locales.test.d.ts +0 -1
- package/dist/node/auto-nav-sidebar/walk.test.d.ts +0 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/containerSyntax.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/image.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/link.test.d.ts +0 -1
- package/dist/node/route/RouteService.test.d.ts +0 -1
- package/dist/node/route/extractPageData.test.d.ts +0 -1
- package/dist/node/route/fixtures/basic/guide/c.d.ts +0 -2
- package/dist/node/route/normalizeRoutePath.test.d.ts +0 -1
- package/dist/node/runtimeModule/i18n.test.d.ts +0 -1
- package/dist/node/ssg-md/remarkSplitMdx.test.d.ts +0 -4
- package/dist/node/utils/checkLanguageParity.test.d.ts +0 -1
- package/dist/node/utils/detectCustomIcon.d.ts +0 -1
- package/dist/node/utils/detectReactVersion.d.ts +0 -3
- package/dist/processor.js +0 -4539
- package/dist/renderPageWorker.js +0 -196
- package/dist/theme/components/Search/logic/util.test.d.ts +0 -1
- /package/dist/cli/{config.d.ts → config/index.d.ts} +0 -0
- /package/dist/{shiki-transformers.js.LICENSE.txt → node/mdx/rehypePlugins/transformers/meta-highlight.js.LICENSE.txt} +0 -0
- /package/dist/theme/components/{DocContent/FallbackHeading.d.ts → FallbackHeading/index.d.ts} +0 -0
- /package/dist/theme/logic/{sideEffects.d.ts → useSetup.d.ts} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2
|
+
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as __rspack_external_path from "path";
|
|
2
|
+
import { __webpack_require__ } from "./rslib-runtime.99091bf6.js";
|
|
3
|
+
import { matchPath } from "react-router-dom";
|
|
4
|
+
import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
5
|
+
import { glob } from "tinyglobby";
|
|
6
|
+
import { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
|
|
7
|
+
import { chunk, groupBy } from "lodash-es";
|
|
8
|
+
import { compile } from "@rspress/mdx-rs";
|
|
9
|
+
import { htmlToText } from "html-to-text";
|
|
10
|
+
import node_fs, { createReadStream, createWriteStream, readFileSync } from "node:fs";
|
|
11
|
+
import { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
|
|
12
|
+
import { createHash } from "node:crypto";
|
|
13
|
+
import { extname, join } from "./6289.c67fe0d5.js";
|
|
14
|
+
__webpack_require__.add({
|
|
15
|
+
path (module) {
|
|
16
|
+
module.exports = __rspack_external_path;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
|
|
20
|
+
const pluginVirtualModule = (pluginOptions = {})=>({
|
|
21
|
+
name: PLUGIN_VIRTUAL_MODULE_NAME,
|
|
22
|
+
async setup (api) {
|
|
23
|
+
const { virtualModules = {}, tempDir: virtualFolderName = '.rsbuild-virtual-module' } = pluginOptions;
|
|
24
|
+
const TEMP_DIR = join(api.context.rootPath, virtualFolderName);
|
|
25
|
+
const virtualFileAbsolutePaths = Object.keys(virtualModules).map((i)=>{
|
|
26
|
+
let absolutePath = join(TEMP_DIR, i);
|
|
27
|
+
if (!extname(absolutePath)) absolutePath = `${absolutePath}.js`;
|
|
28
|
+
return [
|
|
29
|
+
i,
|
|
30
|
+
absolutePath
|
|
31
|
+
];
|
|
32
|
+
});
|
|
33
|
+
api.modifyBundlerChain((chain, { rspack })=>{
|
|
34
|
+
const pluginId = 'RSBUILD_VIRTUAL_MODULE_PLUGIN';
|
|
35
|
+
const virtualModules = Object.fromEntries(virtualFileAbsolutePaths.map((i)=>[
|
|
36
|
+
i[1],
|
|
37
|
+
''
|
|
38
|
+
]));
|
|
39
|
+
if (chain.plugins.has(pluginId)) chain.plugin(pluginId).tap((options)=>{
|
|
40
|
+
const existingPaths = new Set(Object.keys(options[0] ?? {}));
|
|
41
|
+
const conflictPath = virtualFileAbsolutePaths.find(([, path])=>existingPaths.has(path));
|
|
42
|
+
if (conflictPath) throw new Error(`Virtual module name conflicted: ${conflictPath[0]}`);
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
...options[0],
|
|
46
|
+
...virtualModules
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
});
|
|
50
|
+
else chain.plugin(pluginId).use(rspack.experiments.VirtualModulesPlugin, [
|
|
51
|
+
virtualModules
|
|
52
|
+
]);
|
|
53
|
+
chain.resolve.alias.merge(Object.fromEntries(virtualFileAbsolutePaths));
|
|
54
|
+
});
|
|
55
|
+
for (const [moduleName, absolutePath] of virtualFileAbsolutePaths){
|
|
56
|
+
const handler = virtualModules[moduleName];
|
|
57
|
+
if (handler) api.transform({
|
|
58
|
+
test: absolutePath
|
|
59
|
+
}, handler);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS, PLUGIN_REACT_NAME, chunk, compile, core_rspack, createHash, createReadStream, createWriteStream, glob, groupBy, htmlToText, matchPath, mergeRsbuildConfig, node_fs, pluginReact, pluginVirtualModule, readFileSync };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import node_url, { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import { createHead, transformHtmlTemplate } from "@unhead/react/server";
|
|
4
|
+
var package_namespaceObject = {
|
|
5
|
+
rE: "2.0.0-rc.2"
|
|
6
|
+
};
|
|
7
|
+
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
8
|
+
return new Promise((resolve_, reject_)=>{
|
|
9
|
+
if (void 0 === iterable[Symbol.iterator] && void 0 === iterable[Symbol.asyncIterator]) throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
|
10
|
+
if ('function' != typeof mapper) throw new TypeError('Mapper function is required');
|
|
11
|
+
if (!(Number.isSafeInteger(concurrency) && concurrency >= 1 || concurrency === 1 / 0)) throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
|
12
|
+
const result = [];
|
|
13
|
+
const errors = [];
|
|
14
|
+
const skippedIndexesMap = new Map();
|
|
15
|
+
let isRejected = false;
|
|
16
|
+
let isResolved = false;
|
|
17
|
+
let isIterableDone = false;
|
|
18
|
+
let resolvingCount = 0;
|
|
19
|
+
let currentIndex = 0;
|
|
20
|
+
const iterator = void 0 === iterable[Symbol.iterator] ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
21
|
+
const signalListener = ()=>{
|
|
22
|
+
reject(signal.reason);
|
|
23
|
+
};
|
|
24
|
+
const cleanup = ()=>{
|
|
25
|
+
signal?.removeEventListener('abort', signalListener);
|
|
26
|
+
};
|
|
27
|
+
const resolve = (value)=>{
|
|
28
|
+
resolve_(value);
|
|
29
|
+
cleanup();
|
|
30
|
+
};
|
|
31
|
+
const reject = (reason)=>{
|
|
32
|
+
isRejected = true;
|
|
33
|
+
isResolved = true;
|
|
34
|
+
reject_(reason);
|
|
35
|
+
cleanup();
|
|
36
|
+
};
|
|
37
|
+
if (signal) {
|
|
38
|
+
if (signal.aborted) reject(signal.reason);
|
|
39
|
+
signal.addEventListener('abort', signalListener, {
|
|
40
|
+
once: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const next = async ()=>{
|
|
44
|
+
if (isResolved) return;
|
|
45
|
+
const nextItem = await iterator.next();
|
|
46
|
+
const index = currentIndex;
|
|
47
|
+
currentIndex++;
|
|
48
|
+
if (nextItem.done) {
|
|
49
|
+
isIterableDone = true;
|
|
50
|
+
if (0 === resolvingCount && !isResolved) {
|
|
51
|
+
if (!stopOnError && errors.length > 0) return void reject(new AggregateError(errors));
|
|
52
|
+
isResolved = true;
|
|
53
|
+
if (0 === skippedIndexesMap.size) return void resolve(result);
|
|
54
|
+
const pureResult = [];
|
|
55
|
+
for (const [index, value] of result.entries())if (skippedIndexesMap.get(index) !== pMapSkip) pureResult.push(value);
|
|
56
|
+
resolve(pureResult);
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
resolvingCount++;
|
|
61
|
+
(async ()=>{
|
|
62
|
+
try {
|
|
63
|
+
const element = await nextItem.value;
|
|
64
|
+
if (isResolved) return;
|
|
65
|
+
const value = await mapper(element, index);
|
|
66
|
+
if (value === pMapSkip) skippedIndexesMap.set(index, value);
|
|
67
|
+
result[index] = value;
|
|
68
|
+
resolvingCount--;
|
|
69
|
+
await next();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (stopOnError) reject(error);
|
|
72
|
+
else {
|
|
73
|
+
errors.push(error);
|
|
74
|
+
resolvingCount--;
|
|
75
|
+
try {
|
|
76
|
+
await next();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
reject(error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
};
|
|
84
|
+
(async ()=>{
|
|
85
|
+
for(let index = 0; index < concurrency; index++){
|
|
86
|
+
try {
|
|
87
|
+
await next();
|
|
88
|
+
} catch (error) {
|
|
89
|
+
reject(error);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
if (isIterableDone || isRejected) break;
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const pMapSkip = Symbol('skip');
|
|
98
|
+
export { createHead, createRequire, fileURLToPath, node_url, pMap, package_namespaceObject, pathToFileURL, transformHtmlTemplate };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { logger } from "@rspress/shared/logger";
|
|
2
|
+
import node_path, { extname, join, relative } from "node:path";
|
|
3
|
+
import promises, { mkdir, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import picocolors from "picocolors";
|
|
5
|
+
export { extname, join, logger, mkdir, node_path, picocolors, promises, readFile, readdir, relative, rm, stat, writeFile };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter } from "@rspress/shared/node-utils";
|
|
2
|
+
import node_os, { constants } from "node:os";
|
|
3
|
+
import { createProcessor, nodeTypes } from "@mdx-js/mdx";
|
|
4
|
+
export { constants, createProcessor, extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, nodeTypes, node_os };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../../5313.6594aba0.js";
|
|
2
|
+
import { node_path, logger } from "../../6289.c67fe0d5.js";
|
|
3
|
+
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
4
|
+
async function loadConfigFile(customConfigFile) {
|
|
5
|
+
const baseDir = process.cwd();
|
|
6
|
+
let configFilePath = '';
|
|
7
|
+
configFilePath = customConfigFile ? node_path.isAbsolute(customConfigFile) ? customConfigFile : node_path.join(baseDir, customConfigFile) : findConfig(node_path.join(baseDir, DEFAULT_CONFIG_NAME));
|
|
8
|
+
if (!configFilePath) {
|
|
9
|
+
logger.info(`No config file found in ${baseDir}`);
|
|
10
|
+
return {
|
|
11
|
+
config: {},
|
|
12
|
+
configFilePath: ''
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const { loadConfig } = await import("@rsbuild/core");
|
|
16
|
+
const { content } = await loadConfig({
|
|
17
|
+
cwd: node_path.dirname(configFilePath),
|
|
18
|
+
path: configFilePath
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
config: content,
|
|
22
|
+
configFilePath
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function resolveDocRoot(cwd, cliRoot, configRoot) {
|
|
26
|
+
if (cliRoot) return node_path.join(cwd, cliRoot);
|
|
27
|
+
if (configRoot) return node_path.isAbsolute(configRoot) ? configRoot : node_path.join(cwd, configRoot);
|
|
28
|
+
return node_path.join(cwd, 'docs');
|
|
29
|
+
}
|
|
30
|
+
export { loadConfigFile, resolveDocRoot };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { node_path, logger, join, picocolors } from "../6289.c67fe0d5.js";
|
|
2
|
+
import { chokidar, cac } from "./index.cb89dbd1.js";
|
|
3
|
+
import { package_namespaceObject } from "../5485.2a0273cf.js";
|
|
4
|
+
import { loadConfigFile, resolveDocRoot } from "./config/loadConfigFile.js";
|
|
5
|
+
import { dev } from "../node/dev.js";
|
|
6
|
+
import { PUBLIC_DIR } from "../node/constants.js";
|
|
7
|
+
import { build } from "../node/build.js";
|
|
8
|
+
import { serve } from "../node/serve.js";
|
|
9
|
+
import { listComponents, ejectComponent } from "../node/eject.js";
|
|
10
|
+
const META_FILES = [
|
|
11
|
+
'_meta.json',
|
|
12
|
+
'_nav.json'
|
|
13
|
+
];
|
|
14
|
+
const cli = cac('rspress').version(package_namespaceObject.rE).help();
|
|
15
|
+
const landingMessage = `🔥 Rspress v${package_namespaceObject.rE}\n`;
|
|
16
|
+
logger.greet(landingMessage);
|
|
17
|
+
const setNodeEnv = (env)=>{
|
|
18
|
+
process.env.NODE_ENV = env;
|
|
19
|
+
};
|
|
20
|
+
cli.option('-c,--config [config]', 'Specify the path to the config file');
|
|
21
|
+
cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
|
|
22
|
+
setNodeEnv('development');
|
|
23
|
+
let isRestarting = false;
|
|
24
|
+
const cwd = process.cwd();
|
|
25
|
+
let cliWatcher;
|
|
26
|
+
let devServer;
|
|
27
|
+
const startDevServer = async ()=>{
|
|
28
|
+
const { port, host } = options || {};
|
|
29
|
+
const { config, configFilePath } = await loadConfigFile(options?.config);
|
|
30
|
+
config.root = resolveDocRoot(cwd, root, config.root);
|
|
31
|
+
const docDirectory = config.root;
|
|
32
|
+
devServer = await dev({
|
|
33
|
+
appDirectory: cwd,
|
|
34
|
+
docDirectory,
|
|
35
|
+
config,
|
|
36
|
+
configFilePath,
|
|
37
|
+
extraBuilderConfig: {
|
|
38
|
+
server: {
|
|
39
|
+
port,
|
|
40
|
+
host
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
cliWatcher = chokidar.watch([
|
|
45
|
+
configFilePath,
|
|
46
|
+
docDirectory
|
|
47
|
+
], {
|
|
48
|
+
ignoreInitial: true,
|
|
49
|
+
ignored: [
|
|
50
|
+
'**/node_modules/**',
|
|
51
|
+
'**/.git/**',
|
|
52
|
+
'**/.DS_Store/**',
|
|
53
|
+
join(docDirectory, PUBLIC_DIR)
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
cliWatcher.on('all', async (eventName, filepath)=>{
|
|
57
|
+
const basename = node_path.basename(filepath);
|
|
58
|
+
if ('change' === eventName && META_FILES.includes(basename)) return;
|
|
59
|
+
if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && filepath === configFilePath) {
|
|
60
|
+
if (isRestarting) return;
|
|
61
|
+
isRestarting = true;
|
|
62
|
+
console.log(`\n✨ ${eventName} ${picocolors.green(node_path.relative(cwd, filepath))}, dev server will restart...\n`);
|
|
63
|
+
await devServer.close();
|
|
64
|
+
await cliWatcher.close();
|
|
65
|
+
await startDevServer();
|
|
66
|
+
isRestarting = false;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
await startDevServer();
|
|
71
|
+
const exitProcess = async ()=>{
|
|
72
|
+
try {
|
|
73
|
+
await devServer.close();
|
|
74
|
+
await cliWatcher.close();
|
|
75
|
+
} finally{
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
process.on('SIGINT', exitProcess);
|
|
80
|
+
process.on('SIGTERM', exitProcess);
|
|
81
|
+
});
|
|
82
|
+
cli.command('build [root]').action(async (root, options)=>{
|
|
83
|
+
setNodeEnv('production');
|
|
84
|
+
const cwd = process.cwd();
|
|
85
|
+
const { config, configFilePath } = await loadConfigFile(options.config);
|
|
86
|
+
config.root = resolveDocRoot(cwd, root, config.root);
|
|
87
|
+
const docDirectory = config.root;
|
|
88
|
+
try {
|
|
89
|
+
await build({
|
|
90
|
+
docDirectory,
|
|
91
|
+
config,
|
|
92
|
+
configFilePath
|
|
93
|
+
});
|
|
94
|
+
} catch (err) {
|
|
95
|
+
logger.error(err);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
|
|
100
|
+
setNodeEnv('production');
|
|
101
|
+
const cwd = process.cwd();
|
|
102
|
+
const { port, host } = options || {};
|
|
103
|
+
const { config, configFilePath } = await loadConfigFile(options?.config);
|
|
104
|
+
config.root = resolveDocRoot(cwd, root, config.root);
|
|
105
|
+
await serve({
|
|
106
|
+
config,
|
|
107
|
+
host,
|
|
108
|
+
port,
|
|
109
|
+
configFilePath
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
cli.command('eject [component]', 'Eject a theme component to customize it').action(async (component)=>{
|
|
113
|
+
if (!component) return void await listComponents();
|
|
114
|
+
const cwd = process.cwd();
|
|
115
|
+
try {
|
|
116
|
+
await ejectComponent(component, cwd);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
logger.error(`Failed to eject component: ${error}`);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
cli.parse();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Link, mergeRefs, SvgWrapper } from '@theme';
|
|
2
|
-
import CloseSvg from '@theme-assets/close';
|
|
1
|
+
import { IconClose, Link, mergeRefs, SvgWrapper } from '@theme';
|
|
3
2
|
import clsx from 'clsx';
|
|
4
3
|
import { forwardRef, type ReactNode, useEffect, useState } from 'react';
|
|
5
4
|
import './index.scss';
|
|
@@ -31,7 +30,7 @@ export type BannerProps = {
|
|
|
31
30
|
/**
|
|
32
31
|
* @example
|
|
33
32
|
* // theme/index.tsx
|
|
34
|
-
* import { Layout as BasicLayout, Banner } from '@rspress/core/theme';
|
|
33
|
+
* import { Layout as BasicLayout, Banner } from '@rspress/core/theme-original';
|
|
35
34
|
* import { useLang } from '@rspress/core/runtime';
|
|
36
35
|
* const Layout = () => {
|
|
37
36
|
const lang = useLang();
|
|
@@ -100,7 +99,7 @@ export const Banner = forwardRef<HTMLDivElement, BannerProps>(
|
|
|
100
99
|
{message}
|
|
101
100
|
</Link>
|
|
102
101
|
<SvgWrapper
|
|
103
|
-
icon={
|
|
102
|
+
icon={IconClose}
|
|
104
103
|
onClick={() => {
|
|
105
104
|
setDisable(true);
|
|
106
105
|
if (storage) {
|
|
@@ -36,12 +36,7 @@
|
|
|
36
36
|
opacity: 1;
|
|
37
37
|
color: #fff;
|
|
38
38
|
transition: all 0.3s ease;
|
|
39
|
-
background:
|
|
40
|
-
90deg,
|
|
41
|
-
var(--rp-c-brand-dark) 0%,
|
|
42
|
-
var(--rp-c-brand-dark) 30%,
|
|
43
|
-
#a673ff 100%
|
|
44
|
-
);
|
|
39
|
+
background: var(--rp-home-hero-title-bg);
|
|
45
40
|
|
|
46
41
|
&:hover {
|
|
47
42
|
opacity: 0.8;
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
color: var(--rp-code-block-color);
|
|
26
26
|
background-color: var(--rp-code-block-bg);
|
|
27
27
|
|
|
28
|
+
&__scroll-container {
|
|
29
|
+
overflow-x: auto;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
& :where(pre) {
|
|
29
33
|
outline: none; // avoid focus outline https://github.com/web-infra-dev/rspack/issues/11775
|
|
30
34
|
|
|
@@ -47,18 +51,6 @@
|
|
|
47
51
|
z-index: 1;
|
|
48
52
|
margin: 0;
|
|
49
53
|
background: transparent;
|
|
50
|
-
overflow-x: auto;
|
|
51
|
-
&::-webkit-scrollbar {
|
|
52
|
-
height: 5px;
|
|
53
|
-
width: 5px;
|
|
54
|
-
}
|
|
55
|
-
&::-webkit-scrollbar-corner {
|
|
56
|
-
display: none;
|
|
57
|
-
}
|
|
58
|
-
&::-webkit-scrollbar-thumb {
|
|
59
|
-
background-color: var(--rp-code-block-scroll-bar-bg);
|
|
60
|
-
border-radius: 10px;
|
|
61
|
-
}
|
|
62
54
|
}
|
|
63
55
|
|
|
64
56
|
& :where(code) {
|
|
@@ -87,7 +87,12 @@ export function CodeBlock({
|
|
|
87
87
|
lineNumbersProp && 'rp-codeblock__content--line-numbers',
|
|
88
88
|
)}
|
|
89
89
|
>
|
|
90
|
-
<div
|
|
90
|
+
<div
|
|
91
|
+
className="rp-codeblock__content__scroll-container rp-scrollbar"
|
|
92
|
+
ref={copyElementRef}
|
|
93
|
+
>
|
|
94
|
+
{children}
|
|
95
|
+
</div>
|
|
91
96
|
<CodeButtonGroup
|
|
92
97
|
{...codeButtonGroupProps}
|
|
93
98
|
copyElementRef={copyElementRef}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { SvgWrapper } from '@theme';
|
|
2
|
-
import IconCopy from '@theme-assets/copy';
|
|
3
|
-
import IconSuccess from '@theme-assets/success';
|
|
1
|
+
import { IconCopy, IconSuccess, SvgWrapper } from '@theme';
|
|
4
2
|
import copy from 'copy-to-clipboard';
|
|
5
3
|
import { useRef } from 'react';
|
|
6
4
|
import './CopyCodeButton.scss';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--rp-code-button-group-z-index: 10;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
.rp-codeblock__content:hover .rp-code-button-group__button {
|
|
2
6
|
opacity: 1;
|
|
3
7
|
}
|
|
@@ -6,7 +10,7 @@
|
|
|
6
10
|
position: absolute;
|
|
7
11
|
right: 20px;
|
|
8
12
|
top: 20px;
|
|
9
|
-
z-index:
|
|
13
|
+
z-index: var(--rp-code-button-group-z-index);
|
|
10
14
|
display: flex;
|
|
11
15
|
gap: 10px;
|
|
12
16
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useSite } from '@rspress/core/runtime';
|
|
2
|
-
import { SvgWrapper } from '@theme';
|
|
3
|
-
import IconWrap from '@theme-assets/wrap';
|
|
4
|
-
import IconWrapped from '@theme-assets/wrapped';
|
|
2
|
+
import { IconWrap, IconWrapped, SvgWrapper } from '@theme';
|
|
5
3
|
import clsx from 'clsx';
|
|
6
4
|
import { useRef, useState } from 'react';
|
|
7
5
|
import './index.scss';
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
/* #region */
|
|
8
8
|
&:where(p) {
|
|
9
9
|
margin-top: 1.25rem; /* 20px */
|
|
10
|
-
margin-bottom: 1.25rem;
|
|
10
|
+
margin-bottom: 1.25rem; /* 20px */
|
|
11
|
+
line-height: 1.75rem; /* 28px */
|
|
11
12
|
}
|
|
12
13
|
&:where(strong, b) {
|
|
13
14
|
font-weight: 600;
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
overflow-wrap: break-word;
|
|
36
37
|
|
|
37
38
|
&:hover {
|
|
38
|
-
border-bottom: 1px solid
|
|
39
|
+
border-bottom: 1px solid currentColor;
|
|
39
40
|
opacity: 0.85;
|
|
40
41
|
}
|
|
41
42
|
&[target='_blank'] {
|
|
@@ -96,7 +97,7 @@
|
|
|
96
97
|
&:where(h2) {
|
|
97
98
|
font-size: 1.75rem; // 28px
|
|
98
99
|
margin-top: 3rem; // 48px
|
|
99
|
-
margin-bottom:
|
|
100
|
+
margin-bottom: 1.25rem; // 20px
|
|
100
101
|
}
|
|
101
102
|
&:where(h2:first-of-type)::before {
|
|
102
103
|
content: '';
|
|
@@ -173,22 +174,41 @@
|
|
|
173
174
|
|
|
174
175
|
/* table */
|
|
175
176
|
/* #region */
|
|
177
|
+
&:where(.rp-table-scroll-container) {
|
|
178
|
+
overflow-x: auto;
|
|
179
|
+
}
|
|
176
180
|
&:where(table) {
|
|
177
181
|
width: 100%;
|
|
182
|
+
|
|
183
|
+
table-layout: auto;
|
|
184
|
+
border-collapse: separate;
|
|
185
|
+
border-spacing: 0;
|
|
186
|
+
|
|
187
|
+
border: 1px solid var(--rp-c-divider-light);
|
|
178
188
|
border-radius: var(--rp-radius);
|
|
179
189
|
overflow: hidden;
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
|
|
191
|
+
&::-webkit-scrollbar {
|
|
192
|
+
height: 5px;
|
|
193
|
+
width: 5px;
|
|
194
|
+
}
|
|
195
|
+
&::-webkit-scrollbar-corner {
|
|
196
|
+
display: none;
|
|
197
|
+
}
|
|
198
|
+
&::-webkit-scrollbar-thumb {
|
|
199
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
200
|
+
border-radius: 10px;
|
|
201
|
+
}
|
|
182
202
|
}
|
|
183
203
|
|
|
184
204
|
/* thead */
|
|
185
205
|
&:where(thead) {
|
|
186
206
|
color: var(--rp-c-text-0);
|
|
187
|
-
background: var(--rp-
|
|
207
|
+
background: var(--rp-code-title-bg);
|
|
188
208
|
}
|
|
189
209
|
|
|
190
210
|
&:where(th) {
|
|
191
|
-
padding:
|
|
211
|
+
padding: 0.75rem 1.25rem;
|
|
192
212
|
font-weight: 600;
|
|
193
213
|
font-size: 0.875rem;
|
|
194
214
|
text-align: left;
|
|
@@ -198,11 +218,11 @@
|
|
|
198
218
|
|
|
199
219
|
/* tbody */
|
|
200
220
|
&:where(tbody) {
|
|
201
|
-
background:
|
|
221
|
+
background: var(--rp-c-bg);
|
|
202
222
|
}
|
|
203
223
|
|
|
204
224
|
&:where(td) {
|
|
205
|
-
padding:
|
|
225
|
+
padding: 0.75rem 1.25rem;
|
|
206
226
|
border-bottom: 1px solid var(--rp-c-divider-light);
|
|
207
227
|
|
|
208
228
|
font-size: 0.875rem;
|
|
@@ -234,6 +254,7 @@
|
|
|
234
254
|
padding: 3px 6px;
|
|
235
255
|
border-radius: var(--rp-radius-small);
|
|
236
256
|
background-color: var(--rp-c-text-code-bg);
|
|
257
|
+
border: 1px solid var(--rp-c-text-code-border);
|
|
237
258
|
overflow-wrap: break-word;
|
|
238
259
|
}
|
|
239
260
|
&:where(:not(pre, a) > code) {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ComponentProps, forwardRef } from 'react';
|
|
2
2
|
|
|
3
|
-
export const Table =
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const Table = forwardRef<HTMLTableElement, ComponentProps<'table'>>(
|
|
4
|
+
(props, ref) => {
|
|
5
|
+
return (
|
|
6
|
+
<div className="rp-table-scroll-container rp-scrollbar">
|
|
7
|
+
<table ref={ref} {...props} />
|
|
8
|
+
</div>
|
|
9
|
+
);
|
|
10
|
+
},
|
|
11
|
+
);
|
|
6
12
|
|
|
7
13
|
export const Tr = (props: ComponentProps<'tr'>) => {
|
|
8
14
|
return <tr {...props} />;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { MDXProvider } from '@mdx-js/react';
|
|
2
2
|
import { Content, usePage, useSite } from '@rspress/core/runtime';
|
|
3
|
-
import { Callout, getCustomMDXComponent } from '@theme';
|
|
3
|
+
import { Callout, FallbackHeading, getCustomMDXComponent } from '@theme';
|
|
4
|
+
import { useScrollAfterNav } from '../../logic/useScrollAfterNav';
|
|
5
|
+
|
|
4
6
|
import './doc.scss';
|
|
5
|
-
import { FallbackHeading } from './FallbackHeading';
|
|
6
7
|
|
|
7
8
|
export function FallbackTitle() {
|
|
8
9
|
const { site } = useSite();
|
|
@@ -22,6 +23,8 @@ export function DocContent({
|
|
|
22
23
|
components: Record<string, React.FC<any>> | undefined;
|
|
23
24
|
isOverviewPage?: boolean;
|
|
24
25
|
}) {
|
|
26
|
+
useScrollAfterNav();
|
|
27
|
+
|
|
25
28
|
const mdxComponents = {
|
|
26
29
|
...getCustomMDXComponent(),
|
|
27
30
|
...components,
|
package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx}
RENAMED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { renderInlineMarkdown } from '@theme';
|
|
1
|
+
import { getCustomMDXComponent, renderInlineMarkdown } from '@theme';
|
|
2
2
|
import { slug } from 'github-slugger';
|
|
3
|
-
import {
|
|
4
|
-
import { H1, H2, H3, H4, H5, H6 } from './docComponents/title';
|
|
3
|
+
import { useMemo } from 'react';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const getHeadingMap = () => {
|
|
6
|
+
const { h1, h2, h3, h4, h5, h6 } = getCustomMDXComponent();
|
|
7
|
+
return {
|
|
8
|
+
1: h1,
|
|
9
|
+
2: h2,
|
|
10
|
+
3: h3,
|
|
11
|
+
4: h4,
|
|
12
|
+
5: h5,
|
|
13
|
+
6: h6,
|
|
14
|
+
};
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -28,7 +30,14 @@ export function FallbackHeading({
|
|
|
28
30
|
}) {
|
|
29
31
|
const titleSlug = title && slug(title.trim());
|
|
30
32
|
|
|
31
|
-
const Element =
|
|
33
|
+
const Element = useMemo(() => {
|
|
34
|
+
const headingMap = getHeadingMap();
|
|
35
|
+
return headingMap[level] || headingMap[1];
|
|
36
|
+
}, [level]);
|
|
37
|
+
|
|
38
|
+
const A = useMemo(() => {
|
|
39
|
+
return getCustomMDXComponent().a;
|
|
40
|
+
}, []);
|
|
32
41
|
|
|
33
42
|
return (
|
|
34
43
|
titleSlug && (
|