@rspress/core 2.0.0-rc.1 → 2.0.0-rc.3
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.723d12b2.js +1794 -0
- package/dist/3521.56e42d70.js +56 -0
- package/dist/4669.12208c6a.js +2 -0
- package/dist/5485.077f14ff.js +98 -0
- package/dist/6289.c67fe0d5.js +5 -0
- package/dist/8813.9da1f210.js +2 -0
- package/dist/9643.f109822d.js +5 -0
- package/dist/_private/react/render.js +17 -4
- 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/Badge/index.scss +1 -0
- package/dist/eject-theme/components/Banner/index.tsx +6 -5
- package/dist/eject-theme/components/Callout/index.scss +0 -2
- package/dist/eject-theme/components/Callout/index.tsx +8 -2
- package/dist/eject-theme/components/CodeBlock/index.scss +12 -18
- package/dist/eject-theme/components/CodeBlock/index.tsx +10 -1
- package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
- 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 +27 -7
- package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
- package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
- package/dist/eject-theme/components/DocContent/index.tsx +21 -4
- package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
- package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
- package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
- package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
- package/dist/eject-theme/components/Link/index.tsx +22 -6
- package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
- package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +2 -3
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
- package/dist/eject-theme/components/Overview/index.tsx +7 -8
- package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
- package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +51 -5
- 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 +12 -7
- package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
- package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -0
- 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.tsx +6 -4
- package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
- package/dist/eject-theme/components/Tabs/index.scss +31 -26
- package/dist/eject-theme/components/Tabs/index.tsx +16 -0
- package/dist/eject-theme/components/Tag/index.tsx +84 -5
- package/dist/eject-theme/components/Toc/TocItem.scss +3 -3
- 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 +142 -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 +230 -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 +2 -0
- package/dist/node/constants.js +34 -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 +346 -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} +4 -3
- package/dist/node/mdx/options.d.ts +2 -2
- package/dist/node/mdx/options.js +103 -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 +84 -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 +244 -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 +10 -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/initPageData.js +1 -1
- 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/deprecated.js +18 -0
- package/dist/theme/assets/experimental.js +21 -0
- package/dist/theme/components/Badge/index.css +1 -0
- package/dist/theme/components/Banner/index.d.ts +1 -1
- package/dist/theme/components/Banner/index.js +4 -5
- package/dist/theme/components/Callout/index.css +0 -2
- package/dist/theme/components/Callout/index.js +5 -2
- package/dist/theme/components/CodeBlock/index.css +11 -21
- package/dist/theme/components/CodeBlock/index.js +5 -1
- package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
- package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
- 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 +28 -7
- package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
- 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.d.ts +11 -2
- package/dist/theme/components/DocContent/index.js +6 -6
- package/dist/theme/components/DocFooter/index.js +1 -5
- package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
- package/dist/theme/components/HoverGroup/index.css +3 -3
- package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
- package/dist/theme/components/LastUpdated/index.d.ts +1 -1
- package/dist/theme/components/LastUpdated/index.js +5 -1
- package/dist/theme/components/Link/index.d.ts +1 -1
- package/dist/theme/components/Link/index.js +17 -7
- package/dist/theme/components/Nav/NavMenu.js +2 -3
- package/dist/theme/components/NavHamburger/index.js +3 -4
- package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
- package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
- package/dist/theme/components/Overview/index.d.ts +0 -1
- package/dist/theme/components/Overview/index.js +2 -3
- package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
- package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
- package/dist/theme/components/OverviewGroup/index.js +88 -0
- 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 +12 -15
- 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/Search/logic/util.test.js +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
- package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
- package/dist/theme/components/SidebarMenu/index.js +3 -5
- package/dist/theme/components/SocialLinks/index.js +2 -3
- 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 +19 -27
- package/dist/theme/components/Tabs/index.js +9 -0
- package/dist/theme/components/Tag/index.d.ts +3 -0
- package/dist/theme/components/Tag/index.js +63 -8
- package/dist/theme/components/Toc/TocItem.css +2 -3
- package/dist/theme/components/Toc/TocItem.js +1 -0
- package/dist/theme/hooks/useActiveAnchor.js +1 -1
- package/dist/theme/icons.d.ts +27 -0
- package/dist/theme/icons.js +51 -0
- package/dist/theme/index.d.ts +64 -59
- package/dist/theme/index.js +7 -2
- package/dist/theme/layout/DocLayout/index.css +2 -4
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/theme/layout/NotFountLayout/index.js +1 -1
- package/dist/theme/logic/useAppearance.js +1 -1
- package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
- package/dist/theme/logic/useMediaQuery.js +1 -1
- package/dist/theme/styles/base.css +1 -0
- package/dist/theme/styles/scrollbar.css +1 -0
- package/dist/theme/styles/shiki.css +9 -3
- package/dist/theme/styles/vars/base-vars.css +7 -5
- package/dist/theme/styles/vars/code-vars.css +2 -0
- package/dist/theme/styles/vars/home-vars.css +2 -1
- package/package.json +22 -23
- package/dist/3~128.js +0 -74
- package/dist/3~517.js +0 -1786
- package/dist/3~894.js +0 -26
- 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/Overview/OverviewGroup.js +0 -58
- 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/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +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/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
package/dist/3~894.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const __webpack_id__ = "894";
|
|
2
|
-
export const __webpack_ids__ = [
|
|
3
|
-
"894"
|
|
4
|
-
];
|
|
5
|
-
export const __webpack_modules__ = {
|
|
6
|
-
"./src/node/medium-zoom/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
-
pluginMediumZoom: ()=>pluginMediumZoom
|
|
9
|
-
});
|
|
10
|
-
var node_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
|
|
11
|
-
var node_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:url");
|
|
12
|
-
var _rspress_shared__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@rspress/shared");
|
|
13
|
-
function pluginMediumZoom(options = {}) {
|
|
14
|
-
const __dirname = (0, _rspress_shared__WEBPACK_IMPORTED_MODULE_2__.normalizePosixPath)(node_path__WEBPACK_IMPORTED_MODULE_0__["default"].dirname((0, node_url__WEBPACK_IMPORTED_MODULE_1__.fileURLToPath)(import.meta.url)));
|
|
15
|
-
return {
|
|
16
|
-
name: '@rspress/plugin-medium-zoom',
|
|
17
|
-
globalUIComponents: [
|
|
18
|
-
[
|
|
19
|
-
node_path__WEBPACK_IMPORTED_MODULE_0__["default"].join(__dirname, '../static/MediumZoom.tsx'),
|
|
20
|
-
options
|
|
21
|
-
]
|
|
22
|
-
]
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
package/dist/cli.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import node_path from "node:path";
|
|
2
|
-
import { logger } from "@rspress/shared/logger";
|
|
3
|
-
import { cac } from "cac";
|
|
4
|
-
import chokidar from "chokidar";
|
|
5
|
-
import picocolors from "picocolors";
|
|
6
|
-
import promises from "node:fs/promises";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
import { build, dev, serve } from "./index.js";
|
|
9
|
-
import node_fs from "node:fs";
|
|
10
|
-
import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "@rspress/shared/constants";
|
|
11
|
-
var package_namespaceObject = {
|
|
12
|
-
rE: "2.0.0-rc.1"
|
|
13
|
-
};
|
|
14
|
-
const eject_filename = fileURLToPath(import.meta.url);
|
|
15
|
-
const eject_dirname = node_path.dirname(eject_filename);
|
|
16
|
-
let _themeComponentsPathOverride;
|
|
17
|
-
function getThemeComponentsPath() {
|
|
18
|
-
if (_themeComponentsPathOverride) return _themeComponentsPathOverride;
|
|
19
|
-
return node_path.join(eject_dirname, 'eject-theme/components');
|
|
20
|
-
}
|
|
21
|
-
async function getAvailableComponents() {
|
|
22
|
-
return [
|
|
23
|
-
'Banner',
|
|
24
|
-
'Badge',
|
|
25
|
-
'Callout',
|
|
26
|
-
'DocFooter',
|
|
27
|
-
'HomeFeature',
|
|
28
|
-
'HomeHero',
|
|
29
|
-
'HomeBackground',
|
|
30
|
-
'HomeFooter',
|
|
31
|
-
'Toc',
|
|
32
|
-
'Tabs',
|
|
33
|
-
'PackageManagerTabs',
|
|
34
|
-
'PrevNextPage',
|
|
35
|
-
'Overview',
|
|
36
|
-
'SocialLinks',
|
|
37
|
-
'Steps'
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
async function componentExists(componentName) {
|
|
41
|
-
const themePath = getThemeComponentsPath();
|
|
42
|
-
const componentPath = node_path.join(themePath, componentName);
|
|
43
|
-
try {
|
|
44
|
-
const stat = await promises.stat(componentPath);
|
|
45
|
-
return stat.isDirectory();
|
|
46
|
-
} catch {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async function copyDir(src, dest) {
|
|
51
|
-
await promises.mkdir(dest, {
|
|
52
|
-
recursive: true
|
|
53
|
-
});
|
|
54
|
-
const entries = await promises.readdir(src, {
|
|
55
|
-
withFileTypes: true
|
|
56
|
-
});
|
|
57
|
-
for (const entry of entries){
|
|
58
|
-
const srcPath = node_path.join(src, entry.name);
|
|
59
|
-
const destPath = node_path.join(dest, entry.name);
|
|
60
|
-
if (entry.isDirectory()) await copyDir(srcPath, destPath);
|
|
61
|
-
else await promises.copyFile(srcPath, destPath);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async function transformImports(filePath) {
|
|
65
|
-
const content = await promises.readFile(filePath, 'utf-8');
|
|
66
|
-
const transformed = content;
|
|
67
|
-
if (transformed !== content) await promises.writeFile(filePath, transformed, 'utf-8');
|
|
68
|
-
}
|
|
69
|
-
async function transformDirectory(dir) {
|
|
70
|
-
const entries = await promises.readdir(dir, {
|
|
71
|
-
withFileTypes: true
|
|
72
|
-
});
|
|
73
|
-
for (const entry of entries){
|
|
74
|
-
const fullPath = node_path.join(dir, entry.name);
|
|
75
|
-
if (entry.isDirectory()) await transformDirectory(fullPath);
|
|
76
|
-
else if (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx')) await transformImports(fullPath);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async function ejectComponent(componentName, cwd = process.cwd()) {
|
|
80
|
-
const exists = await componentExists(componentName);
|
|
81
|
-
if (!exists) {
|
|
82
|
-
logger.error(`Component ${picocolors.cyan(componentName)} not found in theme.`);
|
|
83
|
-
const available = await getAvailableComponents();
|
|
84
|
-
logger.info(`\nAvailable components:\n${available.map((c)=>` - ${c}`).join('\n')}`);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
const themePath = getThemeComponentsPath();
|
|
88
|
-
const sourceComponentPath = node_path.join(themePath, componentName);
|
|
89
|
-
const destThemePath = node_path.join(cwd, 'theme', 'components');
|
|
90
|
-
const destComponentPath = node_path.join(destThemePath, componentName);
|
|
91
|
-
try {
|
|
92
|
-
await promises.access(destComponentPath);
|
|
93
|
-
logger.warn(`Component ${picocolors.cyan(componentName)} already exists in ${picocolors.yellow(node_path.relative(cwd, destComponentPath))}`);
|
|
94
|
-
logger.info('Overwriting existing component...');
|
|
95
|
-
} catch {}
|
|
96
|
-
try {
|
|
97
|
-
await promises.mkdir(destThemePath, {
|
|
98
|
-
recursive: true
|
|
99
|
-
});
|
|
100
|
-
await copyDir(sourceComponentPath, destComponentPath);
|
|
101
|
-
await transformDirectory(destComponentPath);
|
|
102
|
-
logger.success(`✨ Component ${picocolors.cyan(componentName)} ejected successfully!`);
|
|
103
|
-
logger.info(`Component files copied to: ${picocolors.green(node_path.relative(cwd, destComponentPath))}\nYou can now customize the component. To use it in your theme, you'll need to:\n 1. Re-export it in your custom \`theme/index.tsx\` file\n 2. Edit it by yourself`);
|
|
104
|
-
} catch (error) {
|
|
105
|
-
logger.error(`Failed to eject component: ${error}`);
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async function listComponents() {
|
|
110
|
-
const components = await getAvailableComponents();
|
|
111
|
-
logger.info(`📦 Available components to eject:\n`);
|
|
112
|
-
components.forEach((component)=>{
|
|
113
|
-
logger.info(` ${picocolors.cyan('•')} ${component}`);
|
|
114
|
-
});
|
|
115
|
-
logger.info(`💡 Usage: ${picocolors.dim('rspress eject <ComponentName>')}\n`);
|
|
116
|
-
}
|
|
117
|
-
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
118
|
-
async function loadConfigFile(customConfigFile) {
|
|
119
|
-
const baseDir = process.cwd();
|
|
120
|
-
let configFilePath = '';
|
|
121
|
-
configFilePath = customConfigFile ? node_path.isAbsolute(customConfigFile) ? customConfigFile : node_path.join(baseDir, customConfigFile) : findConfig(node_path.join(baseDir, DEFAULT_CONFIG_NAME));
|
|
122
|
-
if (!configFilePath) {
|
|
123
|
-
logger.info(`No config file found in ${baseDir}`);
|
|
124
|
-
return {
|
|
125
|
-
config: {},
|
|
126
|
-
configFilePath: ''
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
const { loadConfig } = await import("@rsbuild/core");
|
|
130
|
-
const { content } = await loadConfig({
|
|
131
|
-
cwd: node_path.dirname(configFilePath),
|
|
132
|
-
path: configFilePath
|
|
133
|
-
});
|
|
134
|
-
return {
|
|
135
|
-
config: content,
|
|
136
|
-
configFilePath
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function resolveDocRoot(cwd, cliRoot, configRoot) {
|
|
140
|
-
if (cliRoot) return node_path.join(cwd, cliRoot);
|
|
141
|
-
if (configRoot) return node_path.isAbsolute(configRoot) ? configRoot : node_path.join(cwd, configRoot);
|
|
142
|
-
return node_path.join(cwd, 'docs');
|
|
143
|
-
}
|
|
144
|
-
const CONFIG_FILES = [
|
|
145
|
-
'rspress.config.ts',
|
|
146
|
-
'rspress.config.js'
|
|
147
|
-
];
|
|
148
|
-
const META_FILES = [
|
|
149
|
-
'_meta.json',
|
|
150
|
-
'_nav.json'
|
|
151
|
-
];
|
|
152
|
-
const cli = cac('rspress').version(package_namespaceObject.rE).help();
|
|
153
|
-
const landingMessage = `🔥 Rspress v${package_namespaceObject.rE}\n`;
|
|
154
|
-
logger.greet(landingMessage);
|
|
155
|
-
const setNodeEnv = (env)=>{
|
|
156
|
-
process.env.NODE_ENV = env;
|
|
157
|
-
};
|
|
158
|
-
cli.option('-c,--config [config]', 'Specify the path to the config file');
|
|
159
|
-
cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
|
|
160
|
-
setNodeEnv('development');
|
|
161
|
-
let isRestarting = false;
|
|
162
|
-
const cwd = process.cwd();
|
|
163
|
-
let cliWatcher;
|
|
164
|
-
let devServer;
|
|
165
|
-
const startDevServer = async ()=>{
|
|
166
|
-
const { port, host } = options || {};
|
|
167
|
-
const { config, configFilePath } = await loadConfigFile(options?.config);
|
|
168
|
-
config.root = resolveDocRoot(cwd, root, config.root);
|
|
169
|
-
const docDirectory = config.root;
|
|
170
|
-
devServer = await dev({
|
|
171
|
-
appDirectory: cwd,
|
|
172
|
-
docDirectory,
|
|
173
|
-
config,
|
|
174
|
-
configFilePath,
|
|
175
|
-
extraBuilderConfig: {
|
|
176
|
-
server: {
|
|
177
|
-
port,
|
|
178
|
-
host
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
cliWatcher = chokidar.watch([
|
|
183
|
-
`${cwd}/**/{${CONFIG_FILES.join(',')}}`,
|
|
184
|
-
docDirectory
|
|
185
|
-
], {
|
|
186
|
-
ignoreInitial: true,
|
|
187
|
-
ignored: [
|
|
188
|
-
'**/node_modules/**',
|
|
189
|
-
'**/.git/**',
|
|
190
|
-
'**/.DS_Store/**'
|
|
191
|
-
]
|
|
192
|
-
});
|
|
193
|
-
cliWatcher.on('all', async (eventName, filepath)=>{
|
|
194
|
-
const basename = node_path.basename(filepath);
|
|
195
|
-
if ('change' === eventName && META_FILES.includes(basename)) return;
|
|
196
|
-
if ('add' === eventName || 'unlink' === eventName || 'change' === eventName && CONFIG_FILES.includes(basename)) {
|
|
197
|
-
if (isRestarting) return;
|
|
198
|
-
isRestarting = true;
|
|
199
|
-
console.log(`\n✨ ${eventName} ${picocolors.green(node_path.relative(cwd, filepath))}, dev server will restart...\n`);
|
|
200
|
-
await devServer.close();
|
|
201
|
-
await cliWatcher.close();
|
|
202
|
-
await startDevServer();
|
|
203
|
-
isRestarting = false;
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
await startDevServer();
|
|
208
|
-
const exitProcess = async ()=>{
|
|
209
|
-
try {
|
|
210
|
-
await devServer.close();
|
|
211
|
-
await cliWatcher.close();
|
|
212
|
-
} finally{
|
|
213
|
-
process.exit(0);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
process.on('SIGINT', exitProcess);
|
|
217
|
-
process.on('SIGTERM', exitProcess);
|
|
218
|
-
});
|
|
219
|
-
cli.command('build [root]').action(async (root, options)=>{
|
|
220
|
-
setNodeEnv('production');
|
|
221
|
-
const cwd = process.cwd();
|
|
222
|
-
const { config, configFilePath } = await loadConfigFile(options.config);
|
|
223
|
-
config.root = resolveDocRoot(cwd, root, config.root);
|
|
224
|
-
const docDirectory = config.root;
|
|
225
|
-
try {
|
|
226
|
-
await build({
|
|
227
|
-
docDirectory,
|
|
228
|
-
config,
|
|
229
|
-
configFilePath
|
|
230
|
-
});
|
|
231
|
-
} catch (err) {
|
|
232
|
-
logger.error(err);
|
|
233
|
-
process.exit(1);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
|
|
237
|
-
setNodeEnv('production');
|
|
238
|
-
const cwd = process.cwd();
|
|
239
|
-
const { port, host } = options || {};
|
|
240
|
-
const { config, configFilePath } = await loadConfigFile(options?.config);
|
|
241
|
-
config.root = resolveDocRoot(cwd, root, config.root);
|
|
242
|
-
await serve({
|
|
243
|
-
config,
|
|
244
|
-
host,
|
|
245
|
-
port,
|
|
246
|
-
configFilePath
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
cli.command('eject [component]', 'Eject a theme component to customize it').action(async (component)=>{
|
|
250
|
-
if (!component) return void await listComponents();
|
|
251
|
-
const cwd = process.cwd();
|
|
252
|
-
try {
|
|
253
|
-
await ejectComponent(component, cwd);
|
|
254
|
-
} catch (error) {
|
|
255
|
-
logger.error(`Failed to eject component: ${error}`);
|
|
256
|
-
process.exit(1);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
cli.parse();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://github.com/facebook/docusaurus/blob/0306d182407bb98f140cd5ec7481fa9608fe0297/packages/docusaurus/src/ssg/ssgExecutor.ts#L123
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* these codes are copied from
|
|
8
|
-
* @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const detectCustomIcon: (customThemeDir: string) => Promise<Record<string, string>>;
|