@rspress/core 2.0.18 → 2.0.19

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 (143) hide show
  1. package/dist/{4538.js → 4538~0.js} +1 -1
  2. package/dist/6305~0.js +3007 -0
  3. package/dist/{3553.js → 8472~0.js} +2 -2
  4. package/dist/{0~execa.js → 864~0.js} +11 -11
  5. package/dist/cli/index.js +13 -40
  6. package/dist/config/defineConfig.d.ts +15 -15
  7. package/dist/config/loadConfigFile.js +1 -1
  8. package/dist/eject-theme/components/HoverGroup/index.scss +16 -0
  9. package/dist/eject-theme/components/HoverGroup/index.tsx +22 -1
  10. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +2 -6
  11. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +2 -5
  12. package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +104 -0
  13. package/dist/eject-theme/components/Llms/LlmsHint.tsx +70 -0
  14. package/dist/eject-theme/components/Llms/getLlmsCopyContent.test.ts +21 -0
  15. package/dist/eject-theme/components/Llms/getLlmsCopyContent.ts +20 -0
  16. package/dist/eject-theme/components/Llms/index.tsx +1 -1
  17. package/dist/eject-theme/components/Nav/NavMenu.scss +16 -0
  18. package/dist/eject-theme/components/Nav/NavMenu.tsx +12 -0
  19. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +18 -2
  20. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +27 -19
  21. package/dist/eject-theme/components/NavScreen/index.scss +4 -0
  22. package/dist/eject-theme/components/Outline/index.scss +4 -0
  23. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +3 -0
  24. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +16 -0
  25. package/dist/eject-theme/components/Sidebar/SidebarItem.test.tsx +51 -0
  26. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +10 -1
  27. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +15 -0
  28. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.tsx +6 -1
  29. package/dist/eject-theme/components/Sidebar/index.tsx +1 -0
  30. package/dist/index.js +1 -1
  31. package/dist/node/PluginDriver.js +1 -1
  32. package/dist/node/auto-nav-sidebar/index.js +1 -1
  33. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  34. package/dist/node/auto-nav-sidebar/normalize.js +39 -10
  35. package/dist/node/auto-nav-sidebar/type.d.ts +7 -0
  36. package/dist/node/auto-nav-sidebar/utils.d.ts +1 -0
  37. package/dist/node/auto-nav-sidebar/utils.js +2 -1
  38. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  39. package/dist/node/constants.d.ts +2 -1
  40. package/dist/node/constants.js +50 -2
  41. package/dist/node/dev.d.ts +2 -1
  42. package/dist/node/dev.js +7 -2
  43. package/dist/node/eject.js +3 -3
  44. package/dist/node/initRsbuild.d.ts +6 -2
  45. package/dist/node/initRsbuild.js +35 -11
  46. package/dist/node/last-updated/index.js +112 -15
  47. package/dist/node/logger/hint.js +2 -2
  48. package/dist/node/mdx/options.js +1 -1
  49. package/dist/node/mdx/processor.js +1 -1
  50. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  51. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  52. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  53. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  54. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
  55. package/dist/node/mdx/remarkPlugins/image.js +3 -3
  56. package/dist/node/mdx/remarkPlugins/link.js +3 -3
  57. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  58. package/dist/node/medium-zoom/index.js +1 -1
  59. package/dist/node/route/RoutePage.js +1 -1
  60. package/dist/node/route/RouteService.js +1 -1
  61. package/dist/node/route/extractPageData.js +3 -15
  62. package/dist/node/route/normalizeRoutePath.js +1 -1
  63. package/dist/node/runtimeModule/i18n.js +3 -3
  64. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  65. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  66. package/dist/node/runtimeModule/searchHooks.js +1 -1
  67. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  68. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  69. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  70. package/dist/node/serve.js +1 -1
  71. package/dist/node/ssg/alternateLinks.js +1 -1
  72. package/dist/node/ssg/htmlFile.js +1 -1
  73. package/dist/node/ssg/renderHtmlTemplate.js +1 -1
  74. package/dist/node/ssg/renderPage.js +3 -3
  75. package/dist/node/ssg/renderPageWorker.js +2 -2
  76. package/dist/node/ssg/renderPages.js +5 -5
  77. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  78. package/dist/node/ssg/ssgEnv.js +1 -1
  79. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  80. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  81. package/dist/node/ssg-md/remarkSplitMdx.js +8 -10
  82. package/dist/node/ssg-md/renderPage.js +3 -3
  83. package/dist/node/ssg-md/renderPages.js +4 -4
  84. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  85. package/dist/node/utils/checkLanguageParity.js +1 -1
  86. package/dist/node/utils/createHash.js +1 -1
  87. package/dist/node/utils/error.js +2 -2
  88. package/dist/node/utils/flattenMdxContent.js +1 -1
  89. package/dist/node/utils/fs.js +1 -1
  90. package/dist/node/utils/getPageKey.js +1 -1
  91. package/dist/node/utils/normalizePath.js +1 -1
  92. package/dist/node/utils/reactAlias.js +3 -3
  93. package/dist/runtime/App.js +7 -4
  94. package/dist/runtime/index.d.ts +1 -0
  95. package/dist/runtime/index.js +1 -0
  96. package/dist/runtime/reactDom.d.ts +19 -0
  97. package/dist/runtime/reactDom.js +5 -0
  98. package/dist/theme/components/HoverGroup/index.css +15 -0
  99. package/dist/theme/components/HoverGroup/index.js +17 -1
  100. package/dist/theme/components/Llms/LlmsCopyButton.js +3 -4
  101. package/dist/theme/components/Llms/LlmsCopyRow.js +2 -3
  102. package/dist/theme/components/Llms/LlmsHint.d.ts +2 -0
  103. package/dist/theme/components/Llms/LlmsHint.js +40 -0
  104. package/dist/theme/components/Llms/getLlmsCopyContent.d.ts +1 -0
  105. package/dist/theme/components/Llms/getLlmsCopyContent.js +14 -0
  106. package/dist/theme/components/Llms/index.d.ts +1 -1
  107. package/dist/theme/components/Llms/index.js +1 -1
  108. package/dist/theme/components/Nav/NavMenu.css +15 -0
  109. package/dist/theme/components/Nav/NavMenu.js +8 -0
  110. package/dist/theme/components/NavScreen/NavScreenMenuItem.css +17 -2
  111. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -22
  112. package/dist/theme/components/NavScreen/index.css +4 -0
  113. package/dist/theme/components/Outline/index.css +4 -0
  114. package/dist/theme/components/Sidebar/SidebarGroup.js +4 -1
  115. package/dist/theme/components/Sidebar/SidebarItem.css +15 -0
  116. package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -1
  117. package/dist/theme/components/Sidebar/SidebarItem.js +7 -2
  118. package/dist/theme/components/Sidebar/SidebarSectionHeader.css +14 -0
  119. package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +2 -1
  120. package/dist/theme/components/Sidebar/SidebarSectionHeader.js +12 -6
  121. package/dist/theme/components/Sidebar/index.js +1 -0
  122. package/dist/theme/index.d.ts +1 -2
  123. package/dist/theme/index.js +1 -2
  124. package/dist/theme/layout/Layout/index.js +1 -2
  125. package/meta-json-schema.json +33 -3
  126. package/nav-json-schema.json +9 -0
  127. package/package.json +15 -20
  128. package/dist/5871.js +0 -7275
  129. package/dist/5871.js.LICENSE.txt +0 -41
  130. package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +0 -23
  131. package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +0 -15
  132. package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +0 -1
  133. package/dist/theme/components/Llms/LlmsHiddenHint.js +0 -18
  134. package/dist/theme/logic/useRedirect4FirstVisit.d.ts +0 -5
  135. package/dist/theme/logic/useRedirect4FirstVisit.js +0 -31
  136. /package/dist/{102.js → 102~0.js} +0 -0
  137. /package/dist/{5357.js → 5357~0.js} +0 -0
  138. /package/dist/{7748.js → 7748~0.js} +0 -0
  139. /package/dist/{0~8016.js → 8016~0.js} +0 -0
  140. /package/dist/{9857.js → 9857~0.js} +0 -0
  141. /package/dist/{9940.js → 9940~0.js} +0 -0
  142. /package/dist/{0~rslib-runtime.js → rslib-runtime~0.js} +0 -0
  143. /package/dist/{0~tinypool.js → tinypool~0.js} +0 -0
package/dist/node/dev.js CHANGED
@@ -3,7 +3,8 @@ import { RouteService } from "./route/RouteService.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { checkLanguageParity } from "./utils/checkLanguageParity.js";
5
5
  async function dev(options) {
6
- const { docDirectory, config, extraBuilderConfig, configFilePath } = options;
6
+ const { docDirectory, config, extraBuilderConfig, configFilePath, restart } = options;
7
+ const configFileMeta = config._privateMeta;
7
8
  const isProd = false;
8
9
  const pluginDriver = await PluginDriver.create(config, configFilePath, isProd);
9
10
  const modifiedConfig = await pluginDriver.modifyConfig();
@@ -17,7 +18,11 @@ async function dev(options) {
17
18
  await pluginDriver.routeGenerated(routeService.getRoutes());
18
19
  await pluginDriver.routeServiceGenerated(routeService);
19
20
  await pluginDriver.beforeBuild();
20
- const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, false, extraBuilderConfig);
21
+ const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, false, {
22
+ configFileMeta,
23
+ extraRsbuildConfig: extraBuilderConfig,
24
+ restart
25
+ });
21
26
  rsbuild.onAfterDevCompile(async ()=>{
22
27
  await pluginDriver.afterBuild();
23
28
  });
@@ -1,6 +1,6 @@
1
- import { __webpack_require__ } from "../0~rslib-runtime.js";
2
- import "../4538.js";
3
- import { node_path, logger, promises } from "../5871.js";
1
+ import { __webpack_require__ } from "../rslib-runtime~0.js";
2
+ import "../4538~0.js";
3
+ import { node_path, logger, promises } from "../6305~0.js";
4
4
  import { EJECTED_THEME } from "./constants.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,5 +1,9 @@
1
- import type { RsbuildConfig, RsbuildInstance } from '@rsbuild/core';
1
+ import type { RestartFn, RsbuildConfig, RsbuildInstance } from '@rsbuild/core';
2
2
  import { type UserConfig } from '@rspress/shared';
3
3
  import type { PluginDriver } from './PluginDriver.js';
4
4
  import type { RouteService } from './route/RouteService.js';
5
- export declare function initRsbuild(rootDir: string, config: UserConfig, pluginDriver: PluginDriver, routeService: RouteService, enableSSG: boolean, extraRsbuildConfig?: RsbuildConfig): Promise<RsbuildInstance>;
5
+ export declare function initRsbuild(rootDir: string, config: UserConfig, pluginDriver: PluginDriver, routeService: RouteService, enableSSG: boolean, options?: {
6
+ configFileMeta?: RsbuildConfig['_privateMeta'];
7
+ extraRsbuildConfig?: RsbuildConfig;
8
+ restart?: RestartFn;
9
+ }): Promise<RsbuildInstance>;
@@ -1,6 +1,6 @@
1
- import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../5871.js";
1
+ import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../6305~0.js";
2
2
  import { createError } from "./utils/error.js";
3
- import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
3
+ import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, getInlineLocaleRedirectScript, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
4
4
  import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
5
5
  import { RouteChunkAssetsPlugin } from "./route/routeChunkAssets.js";
6
6
  import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
@@ -16,7 +16,7 @@ import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
16
16
  import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
17
17
  import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
18
18
  import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
19
- import { package_namespaceObject } from "../3553.js";
19
+ import { package_namespaceObject } from "../8472~0.js";
20
20
  function isPluginIncluded(config, pluginName) {
21
21
  return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
22
22
  }
@@ -37,12 +37,13 @@ async function getVirtualModulesFromPlugins(pluginDriver) {
37
37
  });
38
38
  return runtimeModule;
39
39
  }
40
- async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
40
+ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, restart) {
41
41
  const CUSTOM_THEME_DIR = node_path.isAbsolute(config.themeDir) ? config.themeDir : node_path.join(external_node_process_cwd(), config.themeDir);
42
42
  const outDir = config?.outDir ?? OUTPUT_DIR;
43
43
  const base = config?.base ?? '/';
44
44
  const enableLlmsUI = isLlmsUIEnabled(config);
45
45
  const enableLlmsHint = isLlmsHintEnabled(config, enableSSG);
46
+ const localeRedirectScript = getInlineLocaleRedirectScript(config);
46
47
  const assetPrefix = isProduction() ? addTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : '/';
47
48
  const routeChunkAssets = new RouteChunkAssetsPlugin(routeService);
48
49
  const normalizeIcon = (icon)=>{
@@ -114,15 +115,36 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
114
115
  },
115
116
  dev: {
116
117
  lazyCompilation: 'false' !== process.env.RSPRESS_LAZY_COMPILATION,
117
- cliShortcuts: {
118
- custom: (shortcuts)=>shortcuts.filter(({ key })=>'r' !== key)
119
- }
118
+ cliShortcuts: true,
119
+ ...restart ? {
120
+ watchFiles: {
121
+ paths: userDocRoot,
122
+ type: 'restart',
123
+ events: [
124
+ 'add',
125
+ 'unlink'
126
+ ],
127
+ options: {
128
+ ignored: [
129
+ '**/node_modules/**',
130
+ '**/.git/**',
131
+ '**/.DS_Store/**',
132
+ node_path.join(userDocRoot, "public")
133
+ ]
134
+ }
135
+ }
136
+ } : {}
120
137
  },
121
138
  html: {
122
139
  title: config?.title ?? DEFAULT_TITLE,
123
140
  favicon: normalizeIcon(config?.icon),
124
141
  template: TEMPLATE_PATH,
125
142
  tags: [
143
+ localeRedirectScript ? {
144
+ tag: "script",
145
+ children: localeRedirectScript,
146
+ append: false
147
+ } : null,
126
148
  'force-light' !== normalizeDarkMode(config.themeConfig?.darkMode) ? {
127
149
  tag: "script",
128
150
  children: getInlineThemeScript(config.themeConfig?.darkMode),
@@ -164,7 +186,6 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
164
186
  PACKAGE_ROOT
165
187
  ],
166
188
  define: {
167
- 'process.env.TEST': JSON.stringify(process.env.TEST),
168
189
  'import.meta.env.ENABLE_LLMS_UI': JSON.stringify(enableLlmsUI),
169
190
  'import.meta.env.ENABLE_LLMS_HINT': JSON.stringify(enableLlmsHint)
170
191
  }
@@ -355,14 +376,17 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
355
376
  }
356
377
  };
357
378
  }
358
- async function initRsbuild(rootDir, config, pluginDriver, routeService, enableSSG, extraRsbuildConfig) {
379
+ async function initRsbuild(rootDir, config, pluginDriver, routeService, enableSSG, options = {}) {
359
380
  const userDocRoot = node_path.resolve(rootDir || config.root);
360
381
  hintBuilderPluginsBreakingChange(config);
361
382
  const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
362
- const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver);
383
+ const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver, options.restart);
384
+ const rsbuildConfig = mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config.builderConfig || {}, options.extraRsbuildConfig || {});
385
+ if (options.configFileMeta) rsbuildConfig._privateMeta = options.configFileMeta;
363
386
  const rsbuild = await createRsbuild({
364
387
  callerName: 'rspress',
365
- rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config.builderConfig || {}, extraRsbuildConfig || {})
388
+ restart: options.restart,
389
+ rsbuildConfig
366
390
  });
367
391
  return rsbuild;
368
392
  }
@@ -1,33 +1,130 @@
1
- import { execa } from "../../0~execa.js";
1
+ import { node_path, execa } from "../../864~0.js";
2
+ import { slash } from "../utils/normalizePath.js";
2
3
  function transform(timestamp, lang) {
3
4
  return new Date(timestamp).toLocaleString(lang || 'zh');
4
5
  }
5
- async function getGitInfo(filePath) {
6
+ const COMMIT_FORMAT = '--pretty=format:%x00%at%x00%an%x00%ae';
7
+ const ESCAPES = {
8
+ a: '\x07',
9
+ b: '\b',
10
+ t: '\t',
11
+ n: '\n',
12
+ v: '\v',
13
+ f: '\f',
14
+ r: '\r',
15
+ '"': '"',
16
+ '\\': '\\'
17
+ };
18
+ function unquotePath(filePath) {
19
+ if (!filePath.startsWith('"')) return filePath;
20
+ return filePath.slice(1, -1).replace(/\\([0-7]{3}|.)/g, (_, escaped)=>3 === escaped.length ? String.fromCharCode(Number.parseInt(escaped, 8)) : ESCAPES[escaped] ?? escaped);
21
+ }
22
+ function getCommonDir(filePaths) {
23
+ let common = node_path.dirname(filePaths[0]).split(node_path.sep);
24
+ for (const filePath of filePaths.slice(1)){
25
+ const segments = node_path.dirname(filePath).split(node_path.sep);
26
+ let i = 0;
27
+ while(i < common.length && i < segments.length && common[i] === segments[i])i++;
28
+ common = common.slice(0, i);
29
+ }
30
+ return common.length > 1 ? common.join(node_path.sep) : node_path.parse(filePaths[0]).root;
31
+ }
32
+ function getMostCommonParent(filePaths) {
33
+ const counts = new Map();
34
+ let best = '';
35
+ let bestCount = 0;
36
+ for (const filePath of filePaths){
37
+ const dir = node_path.dirname(filePath);
38
+ const count = (counts.get(dir) ?? 0) + 1;
39
+ counts.set(dir, count);
40
+ if (count > bestCount) {
41
+ best = dir;
42
+ bestCount = count;
43
+ }
44
+ }
45
+ return best;
46
+ }
47
+ async function getRepoPrefix(dir) {
6
48
  try {
7
49
  const { stdout } = await execa('git', [
50
+ 'rev-parse',
51
+ '--show-prefix'
52
+ ], {
53
+ cwd: dir
54
+ });
55
+ return stdout.trim();
56
+ } catch (_e) {
57
+ return;
58
+ }
59
+ }
60
+ function stripPrefix(dir, prefix) {
61
+ let root = dir;
62
+ for(let i = prefix.split('/').filter(Boolean).length; i > 0; i--)root = node_path.dirname(root);
63
+ return root;
64
+ }
65
+ async function collectGitInfo(dir) {
66
+ const infoByPath = new Map();
67
+ let stdout;
68
+ try {
69
+ ({ stdout } = await execa('git', [
70
+ '-c',
71
+ 'core.quotePath=false',
8
72
  'log',
9
- '-1',
10
- '--format=%at%n%an%n%ae',
73
+ COMMIT_FORMAT,
74
+ '--name-only',
75
+ '--cc',
76
+ '--no-renames',
11
77
  '--',
12
- filePath
13
- ]);
14
- const [at, an, ae] = stdout.split('\n');
15
- if (!at) return;
16
- return {
17
- timestamp: 1000 * Number(at),
18
- authorName: an ?? '',
19
- authorEmail: ae ?? ''
20
- };
78
+ '.'
79
+ ], {
80
+ cwd: dir
81
+ }));
21
82
  } catch (_e) {
22
- return;
83
+ return infoByPath;
84
+ }
85
+ let commit;
86
+ for (const line of stdout.split('\n')){
87
+ if (line.startsWith('\0')) {
88
+ const [, at, an = '', ae = ''] = line.split('\0');
89
+ commit = {
90
+ timestamp: 1000 * Number(at),
91
+ authorName: an,
92
+ authorEmail: ae
93
+ };
94
+ continue;
95
+ }
96
+ if (!line || !commit) continue;
97
+ const filePath = unquotePath(line);
98
+ if (!infoByPath.has(filePath)) infoByPath.set(filePath, commit);
99
+ }
100
+ return infoByPath;
101
+ }
102
+ async function createLookup(filePaths) {
103
+ if (!filePaths.length) return ()=>void 0;
104
+ let dir = getCommonDir(filePaths);
105
+ let prefix = await getRepoPrefix(dir);
106
+ if (void 0 === prefix) {
107
+ const candidate = getMostCommonParent(filePaths);
108
+ const candidatePrefix = await getRepoPrefix(candidate);
109
+ if (void 0 === candidatePrefix) return ()=>void 0;
110
+ dir = stripPrefix(candidate, candidatePrefix);
111
+ prefix = '';
23
112
  }
113
+ const repoPrefix = prefix;
114
+ const scope = dir;
115
+ const infoByPath = await collectGitInfo(dir);
116
+ return (filePath)=>infoByPath.get(repoPrefix + slash(node_path.relative(scope, filePath)));
24
117
  }
25
118
  function pluginLastUpdated(authorOption = false) {
119
+ let lookup;
26
120
  return {
27
121
  name: '@rspress/plugin-last-updated',
122
+ routeGenerated (routes) {
123
+ lookup = createLookup(routes.map((route)=>route.absolutePath));
124
+ },
28
125
  async extendPageData (pageData) {
29
126
  const { _filepath, lang } = pageData;
30
- const info = await getGitInfo(_filepath);
127
+ const info = (await lookup)?.(_filepath);
31
128
  if (!info) return;
32
129
  pageData.lastUpdatedTime = transform(info.timestamp, lang);
33
130
  if (false === authorOption) return;
@@ -1,5 +1,5 @@
1
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import { relative, logger, join, readFile } from "../../4538.js";
1
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
+ import { relative, logger, join, readFile } from "../../4538~0.js";
3
3
  import { pathExists } from "../utils/fs.js";
4
4
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
5
5
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -1,4 +1,4 @@
1
- import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../9940.js";
1
+ import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../9940~0.js";
2
2
  import { remarkToc } from "./remarkPlugins/toc.js";
3
3
  import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
4
4
  import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../9940.js";
1
+ import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../9940~0.js";
2
2
  import { createMDXOptions } from "./options.js";
3
3
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
4
4
  import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
@@ -1,4 +1,4 @@
1
- import { visit } from "../../../9940.js";
1
+ import { visit } from "../../../9940~0.js";
2
2
  const rehypeCodeMeta = ()=>(tree)=>{
3
3
  visit(tree, 'element', (node)=>{
4
4
  if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
@@ -1,4 +1,4 @@
1
- import { visit, extractTextAndId, github_slugger, headingRank } from "../../../9940.js";
1
+ import { visit, extractTextAndId, github_slugger, headingRank } from "../../../9940~0.js";
2
2
  const rehypeHeaderAnchor = ()=>{
3
3
  const slugger = new github_slugger();
4
4
  return (tree)=>{
@@ -1,4 +1,4 @@
1
- import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../9940.js";
1
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../9940~0.js";
2
2
  const cssVariablesTheme = createCssVariablesTheme({
3
3
  name: 'css-variables',
4
4
  variablePrefix: '--shiki-',
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../../9940.js";
1
+ import { node_path } from "../../../9940~0.js";
2
2
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
3
3
  const remarkBuiltin = ({ globalComponents })=>(tree)=>{
4
4
  const demos = globalComponents.map((componentPath)=>{
@@ -1,6 +1,6 @@
1
- import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
- import "../../../4538.js";
3
- import { visit, node_path, logger, cwd, readFile } from "../../../5357.js";
1
+ import { __webpack_require__ } from "../../../rslib-runtime~0.js";
2
+ import "../../../4538~0.js";
3
+ import { visit, node_path, logger, cwd, readFile } from "../../../5357~0.js";
4
4
  import { createError } from "../../utils/error.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,6 +1,6 @@
1
- import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
- import "../../../4538.js";
3
- import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../5357.js";
1
+ import { __webpack_require__ } from "../../../rslib-runtime~0.js";
2
+ import "../../../4538~0.js";
3
+ import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../5357~0.js";
4
4
  import { createError } from "../../utils/error.js";
5
5
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
6
6
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,6 +1,6 @@
1
- import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
- import "../../../4538.js";
3
- import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, MDX_OR_MD_REGEXP, withBase } from "../../../5357.js";
1
+ import { __webpack_require__ } from "../../../rslib-runtime~0.js";
2
+ import "../../../4538~0.js";
3
+ import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, MDX_OR_MD_REGEXP, withBase } from "../../../5357~0.js";
4
4
  import { hintRelativeMarkdownLink } from "../../logger/hint.js";
5
5
  import { createError } from "../../utils/error.js";
6
6
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,4 +1,4 @@
1
- import { visitChildren, extractTextAndId, github_slugger, slug } from "../../../7748.js";
1
+ import { visitChildren, extractTextAndId, github_slugger, slug } from "../../../7748~0.js";
2
2
  const extractChildText = (child, preserveInlineMarkdown = true)=>{
3
3
  if ('link' === child.type) return child.children?.map((child)=>extractChildText(child, preserveInlineMarkdown)).join('') ?? '';
4
4
  if ('strong' === child.type) {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../0~8016.js";
1
+ import { node_path } from "../../8016~0.js";
2
2
  import { PACKAGE_ROOT } from "../constants.js";
3
3
  function pluginMediumZoom(options = {}) {
4
4
  return {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../5871.js";
1
+ import { node_path } from "../../6305~0.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 "../../5871.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../6305~0.js";
2
2
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
3
3
  import { createError } from "../utils/error.js";
4
4
  import { getRouteChunkName } from "./routeChunkAssets.js";
@@ -1,4 +1,4 @@
1
- import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../5871.js";
1
+ import { unified, node_path, promises, loadFrontMatter, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../6305~0.js";
2
2
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
3
3
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
4
4
  import { importStatementRegex } from "../constants.js";
@@ -8,17 +8,7 @@ function applyReplaceRulesToNestedObject(obj, replaceRules) {
8
8
  else if ('object' == typeof obj[key] && null !== obj[key]) obj[key] = applyReplaceRulesToNestedObject(obj[key], replaceRules);
9
9
  return obj;
10
10
  }
11
- const remarkRemoveCodeBlocks = ()=>(tree)=>{
12
- remove(tree, 'code');
13
- };
14
- const remarkRemoveImages = ()=>(tree)=>{
15
- remove(tree, 'image');
16
- };
17
- const createProcessor = (searchCodeBlocks)=>unified().use(remark_parse).use(remark_gfm).use(remarkRemoveImages).use(searchCodeBlocks ? [] : [
18
- remarkRemoveCodeBlocks
19
- ]);
20
- const processorWithCode = createProcessor(true);
21
- const processorWithoutCode = createProcessor(false);
11
+ const processor = unified().use(remark_parse).use(remark_gfm);
22
12
  function extractTextFromNode(node) {
23
13
  if ('value' in node && 'string' == typeof node.value) return node.value;
24
14
  if ('children' in node && Array.isArray(node.children)) return node.children.map(extractTextFromNode).join('');
@@ -164,7 +154,6 @@ async function getPageIndexInfoByRoute(route, options) {
164
154
  const { flattenContent } = await flattenMdxContent(applyReplaceRules(contentWithoutFrontMatter, replaceRules), route.absolutePath, alias);
165
155
  content = flattenContent.replace(importStatementRegex, '');
166
156
  content = content.replace(/\r\n/g, '\n');
167
- const processor = searchCodeBlocks ? processorWithCode : processorWithoutCode;
168
157
  const tree = processor.parse(content);
169
158
  const { title, toc: rawToc } = parseToc(tree);
170
159
  const extractedDescription = frontmatter.description || !extractDescriptionConfig ? '' : extractDescription(tree);
@@ -183,8 +172,7 @@ async function getPageIndexInfoByRoute(route, options) {
183
172
  __content: void 0
184
173
  }
185
174
  };
186
- const processedTree = await processor.run(tree);
187
- const { content: processedContent, toc } = buildSearchContent(processedTree, rawToc, searchCodeBlocks);
175
+ const { content: processedContent, toc } = buildSearchContent(tree, rawToc, searchCodeBlocks);
188
176
  return {
189
177
  ...defaultIndexInfo,
190
178
  title: frontmatter.title || title,
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../5871.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../6305~0.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
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../4538.js";
3
- import { createRequire, join, logger } from "../../5871.js";
1
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
+ import "../../4538~0.js";
3
+ import { createRequire, join, logger } from "../../6305~0.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 "../../../5871.js";
1
+ import { SEARCH_INDEX_NAME, groupBy } from "../../../6305~0.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 "../../../5871.js";
1
+ import { logger, pluginVirtualModule } from "../../../6305~0.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 "../../5871.js";
1
+ import { node_path } from "../../6305~0.js";
2
2
  const searchHookVMPlugin = (context)=>({
3
3
  ["virtual-search-hooks"]: ()=>{
4
4
  const { config } = context;
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../5871.js";
1
+ import { getIconUrlPath } from "../../../6305~0.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 "../../../5871.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../6305~0.js";
2
2
  import { getI18nData } from "../i18n.js";
3
3
  import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
4
4
  async function normalizeThemeConfig(docConfig) {
@@ -1,4 +1,4 @@
1
- import { isProduction, logger } from "../../../5871.js";
1
+ import { isProduction, logger } from "../../../6305~0.js";
2
2
  import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
3
3
  import { createSiteData } from "./createSiteData.js";
4
4
  const siteDataVMPlugin = (context)=>{
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../5871.js";
1
+ import { mergeRsbuildConfig } from "../6305~0.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,4 +1,4 @@
1
- import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../5871.js";
1
+ import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../6305~0.js";
2
2
  function createAlternateLinksByRoute(routes, config) {
3
3
  const routeGroups = new Map();
4
4
  for (const route of routes){
@@ -1,4 +1,4 @@
1
- import { external_node_path_resolve, relative, isAbsolute } from "../../3553.js";
1
+ import { external_node_path_resolve, relative, isAbsolute } from "../../8472~0.js";
2
2
  const routePath2HtmlFileName = (routePath)=>{
3
3
  let fileName = routePath;
4
4
  fileName = fileName.endsWith('/') ? `${routePath}index.html` : `${routePath}.html`;
@@ -1,4 +1,4 @@
1
- import { posix } from "../../3553.js";
1
+ import { posix } from "../../8472~0.js";
2
2
  import { META_GENERATOR, RSPRESS_VERSION, APP_HTML_MARKER, HEAD_MARKER } from "../constants.js";
3
3
  import { routePath2HtmlFileName } from "./htmlFile.js";
4
4
  import { createError } from "../utils/error.js";
@@ -1,6 +1,6 @@
1
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../4538.js";
3
- import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../3553.js";
1
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
+ import "../../4538~0.js";
3
+ import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../8472~0.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,7 +1,7 @@
1
- import { writeFile, mkdir, dirname, workerData } from "../../9857.js";
1
+ import { writeFile, mkdir, dirname, workerData } from "../../9857~0.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  import { resolveHtmlFilePath } from "./htmlFile.js";
4
- import { pMap } from "../../3553.js";
4
+ import { pMap } from "../../8472~0.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  const params = workerData?.[1]?.params;
7
7
  if (!params) throw createError('SSG Worker Thread workerData params missing');
@@ -1,11 +1,11 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
3
- import "../../4538.js";
4
- import { chunk, logger } from "../../5871.js";
2
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
3
+ import "../../4538~0.js";
4
+ import { chunk, logger } from "../../6305~0.js";
5
5
  import { createAlternateLinksByRoute } from "./alternateLinks.js";
6
6
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
7
7
  import { routePath2HtmlFileName } from "./htmlFile.js";
8
- import { pMap } from "../../3553.js";
8
+ import { pMap } from "../../8472~0.js";
9
9
  import { renderPage } from "./renderPage.js";
10
10
  import { hintSSGFailed } from "../logger/hint.js";
11
11
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -46,7 +46,7 @@ async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, em
46
46
  if ('object' == typeof ssg && ssg?.experimentalWorker) {
47
47
  const numberOfThreads = getNumberOfThreads(routes.length);
48
48
  logger.info(`Rendering pages with experimental SSG worker (${picocolors_default().yellow(numberOfThreads)} threads)...`);
49
- const Tinypool = await import("../../0~tinypool.js").then((m)=>m.default);
49
+ const Tinypool = await import("../../tinypool~0.js").then((m)=>m.default);
50
50
  const pool = new Tinypool({
51
51
  filename: new URL('./renderPageWorker.js', import.meta.url).href,
52
52
  concurrentTasksPerWorker: 1,
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../5871.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../6305~0.js";
2
2
  import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  const rsbuildPluginSSG = ({ routeService, config, routeChunkAssets })=>({
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../5871.js";
2
+ import { node_os } from "../../6305~0.js";
3
3
  /**
4
4
  * these codes are copied from
5
5
  * @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
@@ -1,4 +1,4 @@
1
- import { matchPath, getSidebarDataGroup } from "../../../5871.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../6305~0.js";
2
2
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
3
3
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
4
4
  const base = config.base ?? '/';