@rspress/core 2.0.13 → 2.0.14

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.
Files changed (77) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/0~rslib-runtime.js +9 -5
  3. package/dist/{2633.js → 4942.js} +12 -9
  4. package/dist/5580.js +2 -2
  5. package/dist/6646.js +3 -0
  6. package/dist/{7275.js → 7261.js} +2 -2
  7. package/dist/cli/index.js +1 -1
  8. package/dist/eject-theme/components/Banner/index.scss +11 -0
  9. package/dist/eject-theme/components/Banner/index.tsx +5 -1
  10. package/dist/eject-theme/components/Link/index.tsx +6 -0
  11. package/dist/eject-theme/components/Outline/index.tsx +0 -6
  12. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -0
  13. package/dist/eject-theme/components/Search/logic/search.ts +15 -16
  14. package/dist/eject-theme/components/SidebarMenu/index.tsx +10 -3
  15. package/dist/eject-theme/components/SidebarMenu/useSidebarMenu.tsx +12 -3
  16. package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +120 -0
  17. package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +5 -0
  18. package/dist/eject-theme/components/SocialLinks/index.scss +17 -0
  19. package/dist/eject-theme/components/Tag/index.test.tsx +55 -0
  20. package/dist/eject-theme/components/Tag/index.tsx +19 -5
  21. package/dist/node/PluginDriver.js +1 -1
  22. package/dist/node/auto-nav-sidebar/index.js +1 -1
  23. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  24. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  25. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  26. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  27. package/dist/node/constants.js +1 -1
  28. package/dist/node/initRsbuild.js +17 -8
  29. package/dist/node/route/RoutePage.js +1 -1
  30. package/dist/node/route/RouteService.js +1 -1
  31. package/dist/node/route/extractPageData.js +1 -1
  32. package/dist/node/route/normalizeRoutePath.js +1 -1
  33. package/dist/node/runtimeModule/i18n.js +1 -1
  34. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  35. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  36. package/dist/node/runtimeModule/searchHooks.js +1 -1
  37. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  38. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  39. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +33 -9
  40. package/dist/node/serve.js +1 -1
  41. package/dist/node/ssg/htmlFile.d.ts +2 -0
  42. package/dist/node/ssg/htmlFile.js +14 -0
  43. package/dist/node/ssg/renderPage.js +1 -1
  44. package/dist/node/ssg/renderPageWorker.d.ts +3 -6
  45. package/dist/node/ssg/renderPageWorker.js +24 -4
  46. package/dist/node/ssg/renderPages.d.ts +1 -1
  47. package/dist/node/ssg/renderPages.js +18 -17
  48. package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
  49. package/dist/node/ssg/ssgEnv.js +1 -1
  50. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  51. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  52. package/dist/node/ssg-md/renderPage.js +1 -1
  53. package/dist/node/ssg-md/renderPages.js +2 -2
  54. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  55. package/dist/node/utils/checkLanguageParity.js +1 -1
  56. package/dist/node/utils/createHash.js +1 -1
  57. package/dist/node/utils/flattenMdxContent.js +1 -1
  58. package/dist/node/utils/getPageKey.js +1 -1
  59. package/dist/node/utils/reactAlias.js +1 -1
  60. package/dist/theme/components/Banner/index.css +11 -0
  61. package/dist/theme/components/Banner/index.js +1 -0
  62. package/dist/theme/components/Link/index.js +6 -0
  63. package/dist/theme/components/Outline/index.js +1 -3
  64. package/dist/theme/components/Search/SearchPanel.js +1 -0
  65. package/dist/theme/components/Search/logic/search.js +12 -7
  66. package/dist/theme/components/SidebarMenu/index.d.ts +3 -0
  67. package/dist/theme/components/SidebarMenu/index.js +4 -3
  68. package/dist/theme/components/SidebarMenu/useSidebarMenu.d.ts +2 -1
  69. package/dist/theme/components/SidebarMenu/useSidebarMenu.js +7 -3
  70. package/dist/theme/components/SocialLinks/GithubStars.d.ts +7 -0
  71. package/dist/theme/components/SocialLinks/GithubStars.js +85 -0
  72. package/dist/theme/components/SocialLinks/SocialLink.js +5 -0
  73. package/dist/theme/components/SocialLinks/index.css +19 -0
  74. package/dist/theme/components/Tag/index.js +9 -5
  75. package/dist/theme/layout/DocLayout/index.js +1 -1
  76. package/package.json +10 -11
  77. package/dist/559.js +0 -1
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, node_path, addLeadingSlash } from "../2633.js";
1
+ import { addTrailingSlash, node_path, addLeadingSlash } from "../4942.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
4
4
  class PluginDriver {
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../2633.js";
1
+ import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../4942.js";
2
2
  import { processLocales, combineWalkResult } from "./locales.js";
3
3
  import { walk } from "./walk.js";
4
4
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../2633.js";
1
+ import { node_path } from "../../4942.js";
2
2
  import { walk } from "./walk.js";
3
3
  function combineWalkResult(walks, versions) {
4
4
  return walks.reduce((acc, cur, curIndex)=>({
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../7986.js";
3
- import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../2633.js";
3
+ import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../4942.js";
4
4
  import { createError } from "../utils/error.js";
5
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
6
6
  import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../2633.js";
1
+ import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../4942.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  async function pathExists(path) {
4
4
  try {
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, node_path, promises } from "../../2633.js";
1
+ import { isExternalUrl, node_path, promises } from "../../4942.js";
2
2
  import { pathExists } from "../utils/fs.js";
3
3
  import { readJson } from "./utils.js";
4
4
  import { addRoutePrefix } from "../route/RoutePage.js";
@@ -1,4 +1,4 @@
1
- import { createRequire, node_path, package_namespaceObject } from "../7275.js";
1
+ import { createRequire, node_path, package_namespaceObject } from "../7261.js";
2
2
  const constants_require = createRequire(import.meta.url);
3
3
  const RSPRESS_VERSION = package_namespaceObject.rE;
4
4
  const APPEARANCE_KEY = 'rspress-theme-appearance';
@@ -1,4 +1,4 @@
1
- import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash, pluginVirtualModule, pluginReact, MDX_OR_MD_REGEXP } from "../2633.js";
1
+ import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash, pluginVirtualModule, pluginReact, MDX_OR_MD_REGEXP } from "../4942.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, inlineThemeScript, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
4
4
  import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
@@ -14,11 +14,18 @@ import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
14
14
  import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
15
15
  import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
16
16
  import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
17
- import { package_namespaceObject } from "../7275.js";
17
+ import { package_namespaceObject } from "../7261.js";
18
18
  function isPluginIncluded(config, pluginName) {
19
19
  return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
20
20
  }
21
21
  const initRsbuild_require = external_node_module_createRequire(import.meta.url);
22
+ const RAW_QUERY_REGEXP = /[?&]raw(?:&|=|$)/;
23
+ const NODE_RSPACK_OPTIMIZATION = {
24
+ concatenateModules: false,
25
+ moduleIds: 'named',
26
+ chunkIds: 'named',
27
+ minimize: false
28
+ };
22
29
  async function getVirtualModulesFromPlugins(pluginDriver) {
23
30
  const runtimeModule = {};
24
31
  const modulesByPlugin = await pluginDriver.addRuntimeModules();
@@ -199,10 +206,10 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
199
206
  const isSsgMd = 'node_md' === environment.name;
200
207
  const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS).oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN);
201
208
  const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
202
- chain.module.rule('MDX').type("javascript/auto").test(MDX_OR_MD_REGEXP).resolve.merge({
209
+ chain.module.rule('mdx').test(MDX_OR_MD_REGEXP).resolve.merge({
203
210
  conditionNames: jsModuleRule.resolve.conditionNames.values(),
204
211
  mainFields: jsModuleRule.resolve.mainFields.values()
205
- }).end().oneOf('MDXCompile').use('builtin:swc-loader').loader('builtin:swc-loader').options(swcLoaderOptions).end().use('mdx-loader').loader(external_node_url_fileURLToPath(new URL('./mdx/loader.js', import.meta.url))).options({
212
+ }).end().oneOf('mdx-raw').type('asset/source').resourceQuery(RAW_QUERY_REGEXP).end().oneOf('mdx').type("javascript/auto").use('builtin:swc-loader').loader('builtin:swc-loader').options(swcLoaderOptions).end().use('mdx-loader').loader(external_node_url_fileURLToPath(new URL('./mdx/loader.js', import.meta.url))).options({
206
213
  config,
207
214
  docDirectory: userDocRoot,
208
215
  routeService,
@@ -291,6 +298,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
291
298
  compressed: true
292
299
  }
293
300
  },
301
+ tools: {
302
+ rspack: {
303
+ optimization: NODE_RSPACK_OPTIMIZATION
304
+ }
305
+ },
294
306
  output: {
295
307
  emitAssets: false,
296
308
  target: 'node',
@@ -310,10 +322,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
310
322
  },
311
323
  tools: {
312
324
  rspack: {
313
- optimization: {
314
- moduleIds: 'named',
315
- chunkIds: 'named'
316
- }
325
+ optimization: NODE_RSPACK_OPTIMIZATION
317
326
  }
318
327
  },
319
328
  source: {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../2633.js";
1
+ import { node_path } from "../../4942.js";
2
2
  import { RouteService } from "./RouteService.js";
3
3
  import { normalizePath, slash } from "../utils/normalizePath.js";
4
4
  import { getPageKey } from "../utils/getPageKey.js";
@@ -1,4 +1,4 @@
1
- import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../2633.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../4942.js";
2
2
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
3
3
  import { createError } from "../utils/error.js";
4
4
  import { getRoutePathParts, normalizeRoutePath, splitRoutePathParts } from "./normalizeRoutePath.js";
@@ -1,4 +1,4 @@
1
- import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../2633.js";
1
+ import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../4942.js";
2
2
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
3
3
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
4
4
  import { importStatementRegex } from "../constants.js";
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../2633.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../4942.js";
2
2
  const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
3
3
  const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
4
4
  return [
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../7986.js";
3
- import { external_node_module_createRequire, join, logger } from "../../2633.js";
3
+ import { external_node_module_createRequire, join, logger } from "../../4942.js";
4
4
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
5
5
  import { createError } from "../utils/error.js";
6
6
  import { pathExists } from "../utils/fs.js";
@@ -1,4 +1,4 @@
1
- import { SEARCH_INDEX_NAME, groupBy } from "../../../2633.js";
1
+ import { SEARCH_INDEX_NAME, groupBy } from "../../../4942.js";
2
2
  import { extractPageData } from "../../route/extractPageData.js";
3
3
  import { createHash } from "../../utils/createHash.js";
4
4
  function deletePrivateField(obj) {
@@ -1,4 +1,4 @@
1
- import { logger, pluginVirtualModule } from "../../../2633.js";
1
+ import { logger, pluginVirtualModule } from "../../../4942.js";
2
2
  import { createPageData } from "./createPageData.js";
3
3
  const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
4
4
  const ref = {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../2633.js";
1
+ import { node_path } from "../../4942.js";
2
2
  const searchHookVMPlugin = (context)=>({
3
3
  ["virtual-search-hooks"]: ()=>{
4
4
  const { config } = context;
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../2633.js";
1
+ import { getIconUrlPath } from "../../../4942.js";
2
2
  import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
3
3
  async function createSiteData(userConfig) {
4
4
  const tempSearchObj = Object.assign({}, userConfig.search);
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../2633.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../4942.js";
2
2
  import { getI18nData } from "../i18n.js";
3
3
  import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
4
4
  async function normalizeThemeConfig(docConfig) {
@@ -1,23 +1,47 @@
1
- import { logger } from "../../../2633.js";
1
+ import { isProduction, logger } from "../../../4942.js";
2
2
  import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
3
3
  import { createSiteData } from "./createSiteData.js";
4
4
  const siteDataVMPlugin = (context)=>{
5
5
  const { config, pluginDriver } = context;
6
+ let siteDataModulePromise;
7
+ const createSiteDataModule = async (metaFileSet = new Set(), mdFileSet = new Set())=>{
8
+ const force = !pluginDriver.haveNavSidebarConfig;
9
+ const now = performance.now();
10
+ try {
11
+ await modifyConfigWithAutoNavSide(config, metaFileSet, mdFileSet, force);
12
+ } finally{
13
+ logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
14
+ }
15
+ const { siteData } = await createSiteData(config);
16
+ return {
17
+ code: `export default ${JSON.stringify(siteData, null, 2)}`,
18
+ metaFileSet,
19
+ mdFileSet
20
+ };
21
+ };
22
+ const getSiteDataModule = (metaFileSet, mdFileSet)=>{
23
+ if (!isProduction()) return createSiteDataModule(metaFileSet, mdFileSet);
24
+ siteDataModulePromise ??= createSiteDataModule(metaFileSet, mdFileSet).catch((error)=>{
25
+ siteDataModulePromise = void 0;
26
+ throw error;
27
+ });
28
+ return siteDataModulePromise;
29
+ };
30
+ const addSiteDataDependencies = (addDependency, metaFileSet, mdFileSet)=>{
31
+ for (const metaFile of metaFileSet)addDependency(metaFile);
32
+ for (const mdFile of mdFileSet)addDependency(mdFile);
33
+ };
6
34
  return {
7
35
  ["virtual-site-data"]: async ({ addDependency })=>{
8
- const force = !pluginDriver.haveNavSidebarConfig;
9
36
  const metaFileSet = new Set();
10
37
  const mdFileSet = new Set();
11
- const now = performance.now();
38
+ let siteDataModule;
12
39
  try {
13
- await modifyConfigWithAutoNavSide(config, metaFileSet, mdFileSet, force);
40
+ siteDataModule = await getSiteDataModule(metaFileSet, mdFileSet);
41
+ return siteDataModule.code;
14
42
  } finally{
15
- for (const metaFile of metaFileSet)addDependency(metaFile);
16
- for (const mdFile of mdFileSet)addDependency(mdFile);
17
- logger.debug(`modifyConfigWithAutoNavSide - size: ${mdFileSet.size} cost: ${performance.now() - now}ms`);
43
+ addSiteDataDependencies(addDependency, siteDataModule?.metaFileSet ?? metaFileSet, siteDataModule?.mdFileSet ?? mdFileSet);
18
44
  }
19
- const { siteData } = await createSiteData(config);
20
- return `export default ${JSON.stringify(siteData, null, 2)}`;
21
45
  }
22
46
  };
23
47
  };
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../2633.js";
1
+ import { mergeRsbuildConfig } from "../4942.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -0,0 +1,2 @@
1
+ export declare const routePath2HtmlFileName: (routePath: string) => string;
2
+ export declare function resolveHtmlFilePath(distPath: string, routePath: string): string;
@@ -0,0 +1,14 @@
1
+ import { external_node_path_resolve, relative, isAbsolute } from "../../7261.js";
2
+ const routePath2HtmlFileName = (routePath)=>{
3
+ let fileName = routePath;
4
+ fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
5
+ return fileName.replace(/^\/+/, '');
6
+ };
7
+ function resolveHtmlFilePath(distPath, routePath) {
8
+ const distPathAbsolute = external_node_path_resolve(distPath);
9
+ const fileAbsolutePath = external_node_path_resolve(distPathAbsolute, routePath2HtmlFileName(routePath));
10
+ const relativePath = relative(distPathAbsolute, fileAbsolutePath);
11
+ if (relativePath.startsWith('..') || isAbsolute(relativePath)) throw new Error(`SSG route path "${routePath}" resolves outside of the output directory.`);
12
+ return fileAbsolutePath;
13
+ }
14
+ export { resolveHtmlFilePath, routePath2HtmlFileName };
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../7986.js";
3
- import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../7275.js";
3
+ import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../7261.js";
4
4
  import { hintSSGFailed } from "../logger/hint.js";
5
5
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
6
6
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,9 +1,6 @@
1
- import type { RouteMeta, UserConfig } from '@rspress/shared';
2
- interface Args {
1
+ import type { RouteMeta } from '@rspress/shared';
2
+ interface WorkerTask {
3
3
  routes: RouteMeta[];
4
- htmlTemplate: string;
5
- head: UserConfig['head'];
6
- ssrBundlePath: string;
7
4
  }
8
- declare const exportWorkerGlueFn: ({ routes }: Args) => Promise<string[]>;
5
+ declare const exportWorkerGlueFn: ({ routes, }: WorkerTask) => Promise<string[]>;
9
6
  export default exportWorkerGlueFn;
@@ -1,15 +1,35 @@
1
- import { workerData } from "../../559.js";
1
+ import { writeFile, mkdir, dirname, workerData } from "../../6646.js";
2
2
  import { createError } from "../utils/error.js";
3
- import { pMap } from "../../7275.js";
3
+ import { resolveHtmlFilePath } from "./htmlFile.js";
4
+ import { pMap } from "../../7261.js";
4
5
  import { renderPage } from "./renderPage.js";
5
6
  const params = workerData?.[1]?.params;
6
7
  if (!params) throw createError('SSG Worker Thread workerData params missing');
7
- const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath } = params;
8
- const exportWorkerGlueFn = async ({ routes })=>pMap(routes, async (route)=>{
8
+ const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath, distPath: distPath } = params;
9
+ async function writeHtmlFile(routePath, html) {
10
+ if (!distPath) return;
11
+ const fileAbsolutePath = resolveHtmlFilePath(distPath, routePath);
12
+ await mkdir(dirname(fileAbsolutePath), {
13
+ recursive: true
14
+ });
15
+ await writeFile(fileAbsolutePath, html);
16
+ }
17
+ const exportWorkerGlueFn = async ({ routes })=>{
18
+ if (distPath) {
19
+ await pMap(routes, async (route)=>{
20
+ const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
21
+ await writeHtmlFile(route.routePath, html);
22
+ }, {
23
+ concurrency: 10
24
+ });
25
+ return [];
26
+ }
27
+ return pMap(routes, async (route)=>{
9
28
  const html = await renderPage(route, htmlTemplate, head, ssrBundlePath);
10
29
  return html;
11
30
  }, {
12
31
  concurrency: 10
13
32
  });
33
+ };
14
34
  const renderPageWorker = exportWorkerGlueFn;
15
35
  export default renderPageWorker;
@@ -1,4 +1,4 @@
1
1
  import type { UserConfig } from '@rspress/shared';
2
2
  import type { RouteService } from '../route/RouteService.js';
3
- export declare function renderPages(routeService: RouteService, config: UserConfig, ssrBundlePath: string, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void): Promise<void>;
3
+ export declare function renderPages(routeService: RouteService, config: UserConfig, ssrBundlePath: string, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void, workerOutputDistPath?: string): Promise<void>;
4
4
  export declare function renderCSRPages(routeService: RouteService, config: UserConfig, htmlTemplate: string, emitAsset: (assetName: string, content: string | Buffer) => void): Promise<void>;
@@ -1,21 +1,16 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
3
3
  import "../../7986.js";
4
- import { chunk, logger } from "../../2633.js";
4
+ import { chunk, logger } from "../../4942.js";
5
5
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
6
- import { pMap } from "../../7275.js";
6
+ import { routePath2HtmlFileName } from "./htmlFile.js";
7
+ import { pMap } from "../../7261.js";
7
8
  import { renderPage } from "./renderPage.js";
8
9
  import { hintSSGFailed } from "../logger/hint.js";
9
10
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
10
11
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
11
12
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
12
- const routePath2HtmlFileName = (routePath)=>{
13
- let fileName = routePath;
14
- fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
15
- return fileName.replace(/^\/+/, '');
16
- };
17
- async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset) {
18
- logger.info('Rendering pages...');
13
+ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset, workerOutputDistPath) {
19
14
  const startTime = Date.now();
20
15
  const ssg = config.ssg ?? true;
21
16
  try {
@@ -48,6 +43,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
48
43
  }
49
44
  if ('object' == typeof ssg && ssg?.experimentalWorker) {
50
45
  const numberOfThreads = getNumberOfThreads(routes.length);
46
+ logger.info(`Rendering pages with experimental SSG worker (${picocolors_default().yellow(numberOfThreads)} threads)...`);
51
47
  const Tinypool = await import("../../0~tinypool.js").then((m)=>m.default);
52
48
  const pool = new Tinypool({
53
49
  filename: new URL('./renderPageWorker.js', import.meta.url).href,
@@ -63,7 +59,8 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
63
59
  params: {
64
60
  htmlTemplate,
65
61
  head: config.head,
66
- ssrBundlePath
62
+ ssrBundlePath,
63
+ distPath: workerOutputDistPath
67
64
  }
68
65
  }
69
66
  });
@@ -71,6 +68,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
71
68
  const htmlList = await pool.run({
72
69
  routes
73
70
  });
71
+ if (workerOutputDistPath) return;
74
72
  for(let i = 0; i < routes.length; i++){
75
73
  const route = routes[i];
76
74
  const html = htmlList[i];
@@ -79,13 +77,16 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
79
77
  }
80
78
  }));
81
79
  await pool.destroy();
82
- } else await pMap(routes, async (route)=>{
83
- const html = await renderPage(route, htmlTemplate, config.head, ssrBundlePath);
84
- const fileName = routePath2HtmlFileName(route.routePath);
85
- emitAsset(fileName, html);
86
- }, {
87
- concurrency: SSGConcurrency()
88
- });
80
+ } else {
81
+ logger.info('Rendering pages...');
82
+ await pMap(routes, async (route)=>{
83
+ const html = await renderPage(route, htmlTemplate, config.head, ssrBundlePath);
84
+ const fileName = routePath2HtmlFileName(route.routePath);
85
+ emitAsset(fileName, html);
86
+ }, {
87
+ concurrency: SSGConcurrency()
88
+ });
89
+ }
89
90
  const totalTime = Date.now() - startTime;
90
91
  logger.success(`Pages rendered in ${picocolors_default().yellow(totalTime)} ms.`);
91
92
  } catch (e) {
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../2633.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../4942.js";
2
2
  import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  const rsbuildPluginSSG = ({ routeService, config })=>({
@@ -73,7 +73,7 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
73
73
  }));
74
74
  await indexHtmlEmittedInWeb;
75
75
  if (hasError) return;
76
- await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset);
76
+ await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset, distPath);
77
77
  if (!isDebugMode()) await rm(ssgFolderPath, {
78
78
  recursive: true
79
79
  });
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../2633.js";
2
+ import { node_os } from "../../4942.js";
3
3
  /**
4
4
  * these codes are copied from
5
5
  * @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
@@ -1,4 +1,4 @@
1
- import { matchPath, getSidebarDataGroup } from "../../../2633.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../4942.js";
2
2
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
3
3
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
4
4
  const base = config.base ?? '/';
@@ -1,4 +1,4 @@
1
- import { normalizeHref, logger, withBase } from "../../../2633.js";
1
+ import { normalizeHref, logger, withBase } from "../../../4942.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base) {
4
4
  let url = routePath;
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../7986.js";
3
- import { createHead, pathToFileURL, logger } from "../../2633.js";
3
+ import { createHead, pathToFileURL, logger } from "../../4942.js";
4
4
  import { hintSSGFailed } from "../logger/hint.js";
5
5
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -1,7 +1,7 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../7986.js";
3
- import { logger } from "../../2633.js";
4
- import { pMap } from "../../7275.js";
3
+ import { logger } from "../../4942.js";
4
+ import { pMap } from "../../7261.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
7
7
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../2633.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../4942.js";
2
2
  import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
@@ -1,4 +1,4 @@
1
- import { node_path, logger, promises } from "../../2633.js";
1
+ import { node_path, logger, promises } from "../../4942.js";
2
2
  import { createError } from "./error.js";
3
3
  function normalizePath(filePath) {
4
4
  return filePath.split(node_path.sep).join('/');
@@ -1,4 +1,4 @@
1
- import { createHash as external_node_crypto_createHash } from "../../2633.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../4942.js";
2
2
  function createHash(str) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, 8);
4
4
  }
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../2633.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../4942.js";
2
2
  import { createError } from "./error.js";
3
3
  import { importStatementRegex } from "../constants.js";
4
4
  const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
@@ -1,4 +1,4 @@
1
- import { removeLeadingSlash } from "../../2633.js";
1
+ import { removeLeadingSlash } from "../../4942.js";
2
2
  function getPageKey(route) {
3
3
  const cleanRoute = removeLeadingSlash(route);
4
4
  return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../7986.js";
3
- import { node_path, core_rspack, logger } from "../../2633.js";
3
+ import { node_path, core_rspack, logger } from "../../4942.js";
4
4
  import { pathExists, readJson } from "./fs.js";
5
5
  import { PACKAGE_ROOT } from "../constants.js";
6
6
  import { hintReactVersion } from "../logger/hint.js";
@@ -6,9 +6,11 @@
6
6
  color: #fff;
7
7
  z-index: 999;
8
8
  background: var(--rp-banner-background);
9
+ box-sizing: border-box;
9
10
  justify-content: center;
10
11
  align-items: center;
11
12
  height: 36px;
13
+ padding: 0 3.5rem;
12
14
  display: flex;
13
15
  position: sticky;
14
16
  top: 0;
@@ -17,8 +19,17 @@
17
19
 
18
20
  .rp-banner__link {
19
21
  color: #fff;
22
+ text-align: center;
23
+ text-overflow: ellipsis;
24
+ white-space: nowrap;
25
+ flex: auto;
26
+ min-width: 0;
27
+ max-width: 100%;
20
28
  font-weight: 700;
29
+ line-height: 36px;
21
30
  text-decoration: none;
31
+ display: block;
32
+ overflow: hidden;
22
33
  }
23
34
 
24
35
  .rp-banner__link:hover {
@@ -25,6 +25,7 @@ const Banner = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
25
25
  /*#__PURE__*/ jsx(Link, {
26
26
  href: href,
27
27
  className: "rp-banner__link",
28
+ title: 'string' == typeof message ? message : void 0,
28
29
  children: message
29
30
  }),
30
31
  /*#__PURE__*/ jsx(SvgWrapper, {
@@ -42,6 +42,9 @@ const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
42
42
  onMouseEnter?.(event);
43
43
  preloadLink(removeBaseHref);
44
44
  },
45
+ onTouchStart: ()=>{
46
+ preloadLink(removeBaseHref);
47
+ },
45
48
  onClick: (e)=>{
46
49
  onClick?.(e);
47
50
  if (0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
@@ -59,6 +62,9 @@ const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
59
62
  onMouseEnter?.(event);
60
63
  preloadLink(removeBaseHref);
61
64
  },
65
+ onTouchStart: ()=>{
66
+ preloadLink(removeBaseHref);
67
+ },
62
68
  onClick: (e)=>{
63
69
  onClick?.(e);
64
70
  if (0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
@@ -1,13 +1,11 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useI18n, useSite } from "@rspress/core/runtime";
3
- import { EditLink, LlmsCopyRow, LlmsOpenRow, ReadPercent, Toc, useDynamicToc } from "@rspress/core/theme";
3
+ import { EditLink, LlmsCopyRow, LlmsOpenRow, ReadPercent, Toc } from "@rspress/core/theme";
4
4
  import "./index.css";
5
5
  import { ScrollToTop } from "./ScrollToTop.js";
6
6
  function Outline() {
7
7
  const t = useI18n();
8
- const headers = useDynamicToc();
9
8
  const { site: { themeConfig: { enableScrollToTop = true, llmsUI } } } = useSite();
10
- if (0 === headers.length) return /*#__PURE__*/ jsx(Fragment, {});
11
9
  const placement = 'object' == typeof llmsUI ? llmsUI?.placement ?? 'title' : 'title';
12
10
  return /*#__PURE__*/ jsxs("div", {
13
11
  className: "rp-outline",
@@ -335,6 +335,7 @@ function SearchPanel({ focused, setFocused }) {
335
335
  "aria-label": "SearchPanelInput",
336
336
  autoComplete: "off",
337
337
  autoFocus: true,
338
+ inputMode: "search",
338
339
  onChange: (e)=>handleQueryChange(e.target.value)
339
340
  }),
340
341
  /*#__PURE__*/ jsx("label", {