@rspress/core 2.0.6 → 2.0.8

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 (183) hide show
  1. package/dist/0~execa.js +25 -34
  2. package/dist/{675.js → 7319.js} +17 -0
  3. package/dist/7397.js +1 -1
  4. package/dist/8311.js +1 -1
  5. package/dist/eject-theme/components/Banner/index.tsx +1 -1
  6. package/dist/eject-theme/components/Button/index.tsx +1 -1
  7. package/dist/eject-theme/components/CodeBlock/index.scss +58 -1
  8. package/dist/eject-theme/components/CodeBlock/index.tsx +85 -7
  9. package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +12 -2
  10. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -1
  11. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +15 -15
  12. package/dist/eject-theme/components/DocContent/docComponents/a.tsx +1 -1
  13. package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +5 -1
  14. package/dist/eject-theme/components/DocContent/docComponents/title.tsx +6 -1
  15. package/dist/eject-theme/components/DocContent/index.tsx +1 -1
  16. package/dist/eject-theme/components/DocFooter/index.tsx +1 -1
  17. package/dist/eject-theme/components/EditLink/index.tsx +1 -1
  18. package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -1
  19. package/dist/eject-theme/components/HomeFeature/index.tsx +5 -1
  20. package/dist/eject-theme/components/HomeFooter/index.tsx +1 -1
  21. package/dist/eject-theme/components/HomeHero/index.tsx +1 -1
  22. package/dist/eject-theme/components/HoverGroup/index.tsx +4 -1
  23. package/dist/eject-theme/components/Link/useLinkNavigate.ts +1 -1
  24. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +1 -1
  25. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +1 -1
  26. package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +1 -1
  27. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +1 -1
  28. package/dist/eject-theme/components/Nav/NavMenu.tsx +9 -2
  29. package/dist/eject-theme/components/Nav/index.tsx +1 -1
  30. package/dist/eject-theme/components/NavHamburger/index.tsx +6 -1
  31. package/dist/eject-theme/components/NavScreen/NavScreenAppearance.tsx +1 -1
  32. package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +1 -1
  33. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +5 -1
  34. package/dist/eject-theme/components/NavScreen/NavScreenMenuOthers.tsx +1 -1
  35. package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +1 -1
  36. package/dist/eject-theme/components/NavScreen/index.tsx +1 -1
  37. package/dist/eject-theme/components/NavTitle/index.tsx +1 -1
  38. package/dist/eject-theme/components/Outline/ScrollToTop.tsx +5 -1
  39. package/dist/eject-theme/components/Outline/index.tsx +1 -1
  40. package/dist/eject-theme/components/Overview/index.tsx +1 -1
  41. package/dist/eject-theme/components/OverviewGroup/index.tsx +2 -2
  42. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +1 -1
  43. package/dist/eject-theme/components/PrevNextPage/index.tsx +1 -1
  44. package/dist/eject-theme/components/Root/index.tsx +1 -1
  45. package/dist/eject-theme/components/Search/NoSearchResult.tsx +1 -1
  46. package/dist/eject-theme/components/Search/SearchButton.tsx +1 -1
  47. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -1
  48. package/dist/eject-theme/components/Search/SuggestItem.tsx +1 -1
  49. package/dist/eject-theme/components/Search/index.tsx +1 -1
  50. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +5 -1
  51. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -1
  52. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.tsx +1 -1
  53. package/dist/eject-theme/components/SidebarMenu/index.tsx +1 -1
  54. package/dist/eject-theme/components/SocialLinks/index.tsx +1 -1
  55. package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
  56. package/dist/eject-theme/components/SvgWrapper/index.tsx +1 -1
  57. package/dist/eject-theme/components/SwitchAppearance/index.tsx +1 -1
  58. package/dist/eject-theme/components/Tabs/index.tsx +1 -1
  59. package/dist/eject-theme/components/Tag/index.tsx +1 -1
  60. package/dist/eject-theme/components/Toc/TocItem.tsx +5 -1
  61. package/dist/eject-theme/components/Toc/index.tsx +1 -1
  62. package/dist/node/PluginDriver.js +2 -2
  63. package/dist/node/auto-nav-sidebar/index.js +2 -2
  64. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  65. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  66. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  67. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  68. package/dist/node/eject.js +3 -1
  69. package/dist/node/initRsbuild.js +1 -1
  70. package/dist/node/mdx/options.js +2 -2
  71. package/dist/node/mdx/rehypePlugins/headerAnchor.js +2 -1
  72. package/dist/node/mdx/rehypePlugins/shiki.d.ts +4 -1
  73. package/dist/node/mdx/rehypePlugins/shiki.js +5 -2
  74. package/dist/node/mdx/rehypePlugins/transformers/add-fold.d.ts +12 -0
  75. package/dist/node/mdx/rehypePlugins/transformers/add-fold.js +55 -0
  76. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +1 -0
  77. package/dist/node/mdx/rehypePlugins/transformers/index.js +6 -5
  78. package/dist/node/mdx/remarkPlugins/containerSyntax.js +7 -1
  79. package/dist/node/route/RoutePage.js +1 -1
  80. package/dist/node/route/RouteService.js +1 -1
  81. package/dist/node/route/extractPageData.js +3 -2
  82. package/dist/node/route/normalizeRoutePath.js +1 -1
  83. package/dist/node/runtimeModule/i18n.js +2 -2
  84. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  85. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  86. package/dist/node/runtimeModule/searchHooks.js +1 -1
  87. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  88. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  89. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  90. package/dist/node/serve.js +1 -1
  91. package/dist/node/ssg/renderPages.js +1 -1
  92. package/dist/node/ssg/rsbuildPluginSSG.js +20 -7
  93. package/dist/node/ssg/ssgEnv.js +1 -1
  94. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  95. package/dist/node/ssg-md/llms/llmsTxt.js +3 -2
  96. package/dist/node/ssg-md/renderPage.js +1 -1
  97. package/dist/node/ssg-md/renderPages.js +1 -1
  98. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  99. package/dist/node/utils/checkLanguageParity.js +1 -1
  100. package/dist/node/utils/createHash.js +1 -1
  101. package/dist/node/utils/flattenMdxContent.js +3 -2
  102. package/dist/node/utils/getPageKey.js +1 -1
  103. package/dist/node/utils/normalizePath.js +2 -1
  104. package/dist/node/utils/reactAlias.js +1 -1
  105. package/dist/runtime/hooks/useWindowSize.test.js +10 -10
  106. package/dist/shiki-transformers.js +1 -0
  107. package/dist/theme/components/Banner/index.js +1 -1
  108. package/dist/theme/components/Button/index.js +1 -1
  109. package/dist/theme/components/CodeBlock/index.css +53 -1
  110. package/dist/theme/components/CodeBlock/index.d.ts +8 -3
  111. package/dist/theme/components/CodeBlock/index.js +56 -6
  112. package/dist/theme/components/CodeBlockRuntime/index.d.ts +2 -2
  113. package/dist/theme/components/CodeBlockRuntime/index.js +10 -2
  114. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.css +2 -2
  115. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +1 -1
  116. package/dist/theme/components/CodeButtonGroup/index.css +2 -2
  117. package/dist/theme/components/CodeButtonGroup/index.d.ts +6 -6
  118. package/dist/theme/components/CodeButtonGroup/index.js +10 -10
  119. package/dist/theme/components/DocContent/docComponents/a.js +1 -1
  120. package/dist/theme/components/DocContent/docComponents/pre.d.ts +2 -2
  121. package/dist/theme/components/DocContent/docComponents/pre.js +4 -2
  122. package/dist/theme/components/DocContent/docComponents/title.js +1 -1
  123. package/dist/theme/components/DocContent/index.js +1 -1
  124. package/dist/theme/components/DocFooter/index.js +1 -1
  125. package/dist/theme/components/EditLink/index.js +1 -1
  126. package/dist/theme/components/FallbackHeading/index.js +1 -1
  127. package/dist/theme/components/HomeFeature/index.js +1 -1
  128. package/dist/theme/components/HomeFooter/index.js +1 -1
  129. package/dist/theme/components/HomeHero/index.js +1 -1
  130. package/dist/theme/components/HoverGroup/index.js +4 -1
  131. package/dist/theme/components/Link/useLinkNavigate.d.ts +1 -1
  132. package/dist/theme/components/Llms/LlmsCopyButton.css +4 -4
  133. package/dist/theme/components/Llms/LlmsCopyButton.js +1 -1
  134. package/dist/theme/components/Llms/LlmsCopyRow.js +1 -1
  135. package/dist/theme/components/Llms/LlmsOpenRow.js +1 -1
  136. package/dist/theme/components/Llms/LlmsViewOptions.css +2 -2
  137. package/dist/theme/components/Llms/LlmsViewOptions.js +1 -1
  138. package/dist/theme/components/Nav/NavMenu.d.ts +1 -1
  139. package/dist/theme/components/Nav/NavMenu.js +2 -1
  140. package/dist/theme/components/Nav/index.js +1 -1
  141. package/dist/theme/components/NavHamburger/index.js +1 -1
  142. package/dist/theme/components/NavScreen/NavScreenAppearance.js +1 -1
  143. package/dist/theme/components/NavScreen/NavScreenLangs.js +1 -1
  144. package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +2 -1
  145. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +4 -2
  146. package/dist/theme/components/NavScreen/NavScreenMenuOthers.js +1 -1
  147. package/dist/theme/components/NavScreen/NavScreenVersions.js +1 -1
  148. package/dist/theme/components/NavScreen/index.js +1 -1
  149. package/dist/theme/components/NavTitle/index.js +1 -1
  150. package/dist/theme/components/Outline/ScrollToTop.js +1 -1
  151. package/dist/theme/components/Outline/index.js +1 -1
  152. package/dist/theme/components/Overview/index.d.ts +1 -1
  153. package/dist/theme/components/Overview/index.js +1 -1
  154. package/dist/theme/components/OverviewGroup/index.js +1 -1
  155. package/dist/theme/components/PackageManagerTabs/index.js +1 -1
  156. package/dist/theme/components/PrevNextPage/index.js +1 -1
  157. package/dist/theme/components/Root/index.d.ts +1 -1
  158. package/dist/theme/components/Search/NoSearchResult.js +1 -1
  159. package/dist/theme/components/Search/SearchButton.js +1 -1
  160. package/dist/theme/components/Search/SearchPanel.js +1 -1
  161. package/dist/theme/components/Search/SuggestItem.js +1 -1
  162. package/dist/theme/components/Search/index.js +1 -1
  163. package/dist/theme/components/Sidebar/SidebarGroup.js +1 -1
  164. package/dist/theme/components/Sidebar/SidebarItem.js +1 -1
  165. package/dist/theme/components/Sidebar/SidebarSectionHeader.js +1 -1
  166. package/dist/theme/components/SidebarMenu/index.js +1 -1
  167. package/dist/theme/components/SocialLinks/index.js +1 -1
  168. package/dist/theme/components/SourceCode/index.js +1 -1
  169. package/dist/theme/components/SvgWrapper/index.js +1 -1
  170. package/dist/theme/components/SwitchAppearance/index.js +1 -1
  171. package/dist/theme/components/Tabs/index.js +1 -1
  172. package/dist/theme/components/Tag/index.js +1 -1
  173. package/dist/theme/components/Toc/TocItem.js +1 -1
  174. package/dist/theme/components/Toc/index.js +1 -1
  175. package/dist/theme/layout/DocLayout/index.js +1 -1
  176. package/dist/theme/layout/HomeLayout/index.js +1 -1
  177. package/dist/theme/layout/Layout/index.d.ts +2 -2
  178. package/dist/theme/layout/Layout/index.js +2 -2
  179. package/dist/theme/layout/NotFountLayout/index.js +1 -1
  180. package/dist/theme/styles/base.css +1 -1
  181. package/nav-json-schema.json +3 -0
  182. package/package.json +12 -12
  183. /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../675.js";
1
+ import { node_path } from "../../7319.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 "../../675.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../7319.js";
2
2
  import { PUBLIC_DIR } from "../constants.js";
3
3
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
4
4
  import { createError } from "../utils/error.js";
@@ -1,4 +1,4 @@
1
- import { unified, node_path, visit, promises, loadFrontMatter, remark_stringify, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../675.js";
1
+ import { unified, node_path, visit, promises, loadFrontMatter, remark_stringify, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../7319.js";
2
2
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
3
3
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
4
4
  import { importStatementRegex } from "../constants.js";
@@ -158,4 +158,5 @@ async function extractPageData(routeService, options) {
158
158
  }));
159
159
  return pageData;
160
160
  }
161
- export { extractPageData };
161
+ var extractPageData_getPageIndexInfoByRoute = void 0;
162
+ export { extractPageData, extractPageData_getPageIndexInfoByRoute as getPageIndexInfoByRoute };
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../675.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../7319.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,4 +1,4 @@
1
- import { logger, createRequire, join, picocolors } from "../../675.js";
1
+ import { logger, createRequire, join, picocolors } from "../../7319.js";
2
2
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
3
3
  import { createError } from "../utils/error.js";
4
4
  import { pathExists } from "../utils/fs.js";
@@ -29,7 +29,7 @@ async function getI18nData(docConfig, pluginDriver) {
29
29
  delete i18n_require.cache[i18nSourcePath];
30
30
  i18nSourceFromJson = i18n_require(i18nSourcePath);
31
31
  } catch (e) {
32
- logger.debug('getI18nData from i18n.json Failed: \n', e);
32
+ logger.debug('getI18nData from i18n.json Failed: \n', e instanceof Error ? e.message : '');
33
33
  }
34
34
  i18nSourceFull = mergeI18nData(i18nSourceFull, i18nSourceFromJson);
35
35
  if ('function' == typeof i18nSource) try {
@@ -1,4 +1,4 @@
1
- import { SEARCH_INDEX_NAME, groupBy } from "../../../675.js";
1
+ import { SEARCH_INDEX_NAME, groupBy } from "../../../7319.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 "../../../675.js";
1
+ import { logger, pluginVirtualModule } from "../../../7319.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 "../../675.js";
1
+ import { node_path } from "../../7319.js";
2
2
  const searchHookVMPlugin = (context)=>({
3
3
  ["virtual-search-hooks"]: ()=>{
4
4
  const { config } = context;
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../675.js";
1
+ import { getIconUrlPath } from "../../../7319.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 "../../../675.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../7319.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 { logger } from "../../../675.js";
1
+ import { logger } from "../../../7319.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 "../675.js";
1
+ import { mergeRsbuildConfig } from "../7319.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
- import { chunk, logger, picocolors } from "../../675.js";
2
+ import { chunk, logger, picocolors } from "../../7319.js";
3
3
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
4
4
  import { pMap } from "../../8311.js";
5
5
  import { renderPage } from "./renderPage.js";
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../675.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../7319.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 })=>({
@@ -7,7 +7,19 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
7
7
  api.onBeforeBuild(()=>{
8
8
  let htmlTemplate = '';
9
9
  let hasError = false;
10
+ const missingIndexHtmlMessage = 'SSG requires an `index.html` as entry, but this file is not emitted successfully in the web target.';
10
11
  const indexHtmlEmittedInWeb = new Promise((resolve, reject)=>{
12
+ let settled = false;
13
+ const resolveOnce = ()=>{
14
+ if (settled) return;
15
+ settled = true;
16
+ resolve();
17
+ };
18
+ const rejectOnce = ()=>{
19
+ if (settled) return;
20
+ settled = true;
21
+ reject(new Error(missingIndexHtmlMessage));
22
+ };
11
23
  api.processAssets({
12
24
  stage: 'report',
13
25
  environments: [
@@ -16,20 +28,20 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
16
28
  }, ({ assets, compilation })=>{
17
29
  if (compilation.errors.length > 0) {
18
30
  hasError = true;
31
+ resolveOnce();
19
32
  return;
20
33
  }
21
34
  for (const [assetName, assetSource] of Object.entries(assets))if ('index.html' === assetName) {
22
35
  htmlTemplate = assetSource.source().toString();
23
36
  compilation.deleteAsset(assetName);
24
- resolve();
25
- break;
37
+ resolveOnce();
38
+ return;
26
39
  }
27
- reject();
40
+ rejectOnce();
28
41
  });
29
42
  }).catch(()=>{
30
- const message = 'SSG requires an `index.html` as entry, but this file is not emitted successfully in the web target.';
31
- logger.error(message);
32
- const error = new Error(message);
43
+ logger.error(missingIndexHtmlMessage);
44
+ const error = new Error(missingIndexHtmlMessage);
33
45
  throw error;
34
46
  });
35
47
  api.processAssets({
@@ -60,6 +72,7 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
60
72
  }
61
73
  }));
62
74
  await indexHtmlEmittedInWeb;
75
+ if (hasError) return;
63
76
  await renderPages(routeService, config, mainCjsAbsolutePath, htmlTemplate, emitAsset);
64
77
  if (!isDebugMode()) await rm(ssgFolderPath, {
65
78
  recursive: true
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../675.js";
2
+ import { node_os } from "../../7319.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 "../../../675.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../7319.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 "../../../675.js";
1
+ import { normalizeHref, logger, withBase } from "../../../7319.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base) {
4
4
  let url = routePath;
@@ -75,4 +75,5 @@ url: ${routePathToMdPath(routePath, base)}
75
75
  }
76
76
  return lines.join('\n');
77
77
  }
78
- export { generateLlmsFullTxt, generateLlmsTxt };
78
+ var llmsTxt_routePathToMdPath = void 0;
79
+ export { generateLlmsFullTxt, generateLlmsTxt, llmsTxt_routePathToMdPath as routePathToMdPath };
@@ -1,4 +1,4 @@
1
- import { createHead, logger, pathToFileURL, picocolors } from "../../675.js";
1
+ import { createHead, logger, pathToFileURL, picocolors } from "../../7319.js";
2
2
  import { hintSSGFailed } from "../logger/hint.js";
3
3
  async function renderPage(route, ssrBundlePath) {
4
4
  let render;
@@ -1,4 +1,4 @@
1
- import { logger, picocolors } from "../../675.js";
1
+ import { logger, picocolors } from "../../7319.js";
2
2
  import { pMap } from "../../8311.js";
3
3
  import { renderPage } from "./renderPage.js";
4
4
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../675.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../7319.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 "../../675.js";
1
+ import { node_path, logger, promises } from "../../7319.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 "../../675.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../7319.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 "../../675.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../7319.js";
2
2
  import { createError } from "./error.js";
3
3
  import { importStatementRegex } from "../constants.js";
4
4
  const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
@@ -68,4 +68,5 @@ async function flattenMdxContent(content, basePath, alias) {
68
68
  deps
69
69
  };
70
70
  }
71
- export { flattenMdxContent };
71
+ var flattenMdxContent_resolveDepPath = void 0;
72
+ export { flattenMdxContent, flattenMdxContent_resolveDepPath as resolveDepPath };
@@ -1,4 +1,4 @@
1
- import { removeLeadingSlash } from "../../675.js";
1
+ import { removeLeadingSlash } from "../../7319.js";
2
2
  function getPageKey(route) {
3
3
  const cleanRoute = removeLeadingSlash(route);
4
4
  return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
@@ -6,4 +6,5 @@ function slash(p) {
6
6
  function normalizePath(id) {
7
7
  return node_path.posix.normalize(isWindows ? slash(id) : id);
8
8
  }
9
- export { normalizePath, slash };
9
+ var normalizePath_isWindows = void 0;
10
+ export { normalizePath, normalizePath_isWindows as isWindows, slash };
@@ -1,4 +1,4 @@
1
- import { node_path, core_rspack, logger, picocolors } from "../../675.js";
1
+ import { node_path, core_rspack, logger, picocolors } from "../../7319.js";
2
2
  import { pathExists, readJson } from "./fs.js";
3
3
  import { PACKAGE_ROOT } from "../constants.js";
4
4
  import { hintReactVersion } from "../logger/hint.js";
@@ -1,29 +1,29 @@
1
- import { readFileSync } from "node:fs";
2
- import { join } from "node:path";
3
1
  import { describe, expect, it } from "@rstest/core";
2
+ import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
3
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
4
4
  describe('useWindowSize', ()=>{
5
5
  it('should have debounce implementation with RESIZE_DEBOUNCE_MS constant', ()=>{
6
- const filePath = join(__dirname, 'useWindowSize.ts');
7
- const fileContent = readFileSync(filePath, 'utf-8');
6
+ const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
7
+ const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
8
8
  expect(fileContent).toContain('const RESIZE_DEBOUNCE_MS = 150');
9
9
  expect(fileContent).toContain('setTimeout');
10
10
  expect(fileContent).toContain('RESIZE_DEBOUNCE_MS');
11
11
  });
12
12
  it('should clear timeout with conditional check', ()=>{
13
- const filePath = join(__dirname, 'useWindowSize.ts');
14
- const fileContent = readFileSync(filePath, 'utf-8');
13
+ const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
14
+ const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
15
15
  expect(fileContent).toContain('if (timeoutId) clearTimeout(timeoutId)');
16
16
  expect(fileContent).not.toContain('clearTimeout(timeoutId!)');
17
17
  });
18
18
  it('should register and cleanup resize event listener', ()=>{
19
- const filePath = join(__dirname, 'useWindowSize.ts');
20
- const fileContent = readFileSync(filePath, 'utf-8');
19
+ const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
20
+ const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
21
21
  expect(fileContent).toContain("addEventListener('resize'");
22
22
  expect(fileContent).toContain("removeEventListener('resize'");
23
23
  });
24
24
  it('should set initial size immediately', ()=>{
25
- const filePath = join(__dirname, 'useWindowSize.ts');
26
- const fileContent = readFileSync(filePath, 'utf-8');
25
+ const filePath = __rspack_external_node_path_c5b9b54f.join(__dirname, 'useWindowSize.ts');
26
+ const fileContent = __rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf-8');
27
27
  const setStateMatch = fileContent.match(/setSize\(\{[^}]+\}\)/g);
28
28
  expect(setStateMatch).toBeTruthy();
29
29
  expect(setStateMatch?.length).toBeGreaterThanOrEqual(2);
@@ -1,4 +1,5 @@
1
1
  import "./node/mdx/rehypePlugins/transformers/index.js";
2
+ export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold } from "./node/mdx/rehypePlugins/transformers/add-fold.js";
2
3
  export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from "./node/mdx/rehypePlugins/transformers/add-lang.js";
3
4
  export { SHIKI_TRANSFORMER_ADD_LINE_NUMBERS, transformerAddLineNumbers } from "./node/mdx/rehypePlugins/transformers/add-line-numbers.js";
4
5
  export { SHIKI_TRANSFORMER_ADD_TITLE, transformerAddTitle } from "./node/mdx/rehypePlugins/transformers/add-title.js";
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { IconClose, Link, SvgWrapper, mergeRefs } from "@theme";
2
+ import { IconClose, Link, SvgWrapper, mergeRefs } from "@rspress/core/theme";
3
3
  import clsx from "clsx";
4
4
  import { forwardRef, useEffect, useState } from "react";
5
5
  import "./index.css";
@@ -1,4 +1,4 @@
1
- import { Link } from "@theme";
1
+ import { Link } from "@rspress/core/theme";
2
2
  import clsx from "clsx";
3
3
  import react from "react";
4
4
  import "./index.css";
@@ -58,7 +58,7 @@
58
58
  display: inline-block;
59
59
  }
60
60
 
61
- .rp-codeblock__content--code-wrap code {
61
+ .rp-codeblock__content--wrap-code code {
62
62
  white-space: pre-wrap !important;
63
63
  word-break: break-all !important;
64
64
  }
@@ -82,3 +82,55 @@
82
82
  width: 3ch;
83
83
  }
84
84
 
85
+ .rp-codeblock__content--scroll {
86
+ overflow-y: auto;
87
+ }
88
+
89
+ .rp-codeblock__content--fold {
90
+ position: relative;
91
+ overflow: hidden;
92
+ }
93
+
94
+ .rp-codeblock__content--fold:after {
95
+ content: "";
96
+ background: linear-gradient(to bottom, transparent, var(--rp-code-block-bg));
97
+ pointer-events: none;
98
+ z-index: 2;
99
+ height: 48px;
100
+ position: absolute;
101
+ bottom: 0;
102
+ left: 0;
103
+ right: 0;
104
+ }
105
+
106
+ .rp-codeblock__fold-btn {
107
+ background-color: var(--rp-code-block-bg);
108
+ width: 100%;
109
+ color: var(--rp-c-text-3);
110
+ cursor: pointer;
111
+ -webkit-user-select: none;
112
+ user-select: none;
113
+ border-radius: 0 0 var(--rp-radius) var(--rp-radius);
114
+ border: none;
115
+ justify-content: center;
116
+ align-items: center;
117
+ padding: 4px 0;
118
+ transition: color .2s, background-color .2s;
119
+ display: flex;
120
+ }
121
+
122
+ .rp-codeblock__fold-btn:hover {
123
+ color: var(--rp-c-text-1);
124
+ background-color: var(--rp-code-title-bg);
125
+ }
126
+
127
+ .rp-codeblock__fold-btn__icon {
128
+ width: 18px;
129
+ height: 18px;
130
+ transition: transform .3s;
131
+ }
132
+
133
+ .rp-codeblock__fold-btn--expanded .rp-codeblock__fold-btn__icon {
134
+ transform: rotate(180deg);
135
+ }
136
+
@@ -1,4 +1,4 @@
1
- import { type CodeButtonGroupProps } from '@theme';
1
+ import { type CodeButtonGroupProps } from '@rspress/core/theme';
2
2
  import './index.scss';
3
3
  export type CodeBlockProps = {
4
4
  title?: string;
@@ -11,8 +11,13 @@ export type CodeBlockProps = {
11
11
  * @default false
12
12
  */
13
13
  lineNumbers?: boolean;
14
+ /**
15
+ * @default false
16
+ */
17
+ fold?: boolean;
18
+ height?: number;
14
19
  containerElementClassName?: string;
15
- codeButtonGroupProps?: Omit<CodeButtonGroupProps, 'preElementRef' | 'codeWrap' | 'toggleCodeWrap'>;
20
+ codeButtonGroupProps?: Omit<CodeButtonGroupProps, 'preElementRef' | 'wrapCode' | 'toggleWrapCode'>;
16
21
  children?: React.ReactNode;
17
22
  };
18
23
  /**
@@ -51,4 +56,4 @@ export type CodeBlockProps = {
51
56
  *</div>
52
57
  *```
53
58
  */
54
- export declare function CodeBlock({ containerElementClassName, title, lang, wrapCode: wrapCodeProp, lineNumbers: lineNumbersProp, codeButtonGroupProps, children, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
59
+ export declare function CodeBlock({ containerElementClassName, title, lang, wrapCode: wrapCodeProp, lineNumbers: lineNumbersProp, fold, height, codeButtonGroupProps, children, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +1,60 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { CodeButtonGroup, useCodeButtonGroup } from "@theme";
2
+ import { CodeButtonGroup, IconArrowDown, SvgWrapper, useCodeButtonGroup } from "@rspress/core/theme";
3
3
  import clsx from "clsx";
4
+ import { useCallback, useEffect, useRef, useState } from "react";
4
5
  import "./index.css";
5
- function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: wrapCodeProp = false, lineNumbers: lineNumbersProp = false, codeButtonGroupProps, children }) {
6
+ const DEFAULT_FOLD_HEIGHT = 300;
7
+ function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: wrapCodeProp = false, lineNumbers: lineNumbersProp = false, fold = false, height, codeButtonGroupProps, children }) {
6
8
  if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
7
9
  children: children
8
10
  });
9
- const { codeWrap, toggleCodeWrap, copyElementRef } = useCodeButtonGroup(wrapCodeProp);
11
+ const { wrapCode: wrapCodeState, toggleWrapCode, copyElementRef } = useCodeButtonGroup(wrapCodeProp);
12
+ const [expanded, setExpanded] = useState(false);
13
+ const [needFold, setNeedFold] = useState(false);
14
+ const hasScroll = !fold && void 0 !== height;
15
+ const codeBlockRef = useRef(null);
16
+ const contentRef = useRef(null);
17
+ useEffect(()=>{
18
+ if (!fold || !contentRef.current) return void setNeedFold(false);
19
+ const foldHeight = height ?? DEFAULT_FOLD_HEIGHT;
20
+ const realHeight = contentRef.current.scrollHeight;
21
+ setNeedFold(realHeight > foldHeight);
22
+ }, [
23
+ fold,
24
+ height
25
+ ]);
26
+ const handleFoldToggle = useCallback(()=>{
27
+ if (expanded) {
28
+ setExpanded(false);
29
+ requestAnimationFrame(()=>{
30
+ if (codeBlockRef.current) {
31
+ const rect = codeBlockRef.current.getBoundingClientRect();
32
+ if (rect.top < 0) window.scrollBy({
33
+ top: rect.top - 16,
34
+ behavior: 'smooth'
35
+ });
36
+ }
37
+ });
38
+ } else setExpanded(true);
39
+ }, [
40
+ expanded
41
+ ]);
10
42
  return /*#__PURE__*/ jsxs("div", {
11
43
  className: clsx('rp-codeblock', `language-${lang}`, containerElementClassName),
44
+ ref: codeBlockRef,
12
45
  children: [
13
46
  title && /*#__PURE__*/ jsx("div", {
14
47
  className: "rp-codeblock__title",
15
48
  children: title
16
49
  }),
17
50
  /*#__PURE__*/ jsxs("div", {
18
- className: clsx('rp-codeblock__content', codeWrap && 'rp-codeblock__content--code-wrap', lineNumbersProp && 'rp-codeblock__content--line-numbers'),
51
+ className: clsx('rp-codeblock__content', wrapCodeState && 'rp-codeblock__content--wrap-code', lineNumbersProp && 'rp-codeblock__content--line-numbers', needFold && !expanded && 'rp-codeblock__content--fold', hasScroll && 'rp-codeblock__content--scroll'),
52
+ style: needFold && !expanded ? {
53
+ maxHeight: `${height ?? DEFAULT_FOLD_HEIGHT}px`
54
+ } : hasScroll ? {
55
+ maxHeight: `${height}px`
56
+ } : void 0,
57
+ ref: contentRef,
19
58
  children: [
20
59
  /*#__PURE__*/ jsx("div", {
21
60
  className: "rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always",
@@ -25,10 +64,21 @@ function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: w
25
64
  /*#__PURE__*/ jsx(CodeButtonGroup, {
26
65
  ...codeButtonGroupProps,
27
66
  copyElementRef: copyElementRef,
28
- codeWrap: codeWrap,
29
- toggleCodeWrap: toggleCodeWrap
67
+ wrapCode: wrapCodeState,
68
+ toggleWrapCode: toggleWrapCode
30
69
  })
31
70
  ]
71
+ }),
72
+ needFold && /*#__PURE__*/ jsx("button", {
73
+ type: "button",
74
+ className: clsx('rp-codeblock__fold-btn', expanded && 'rp-codeblock__fold-btn--expanded'),
75
+ onClick: handleFoldToggle,
76
+ "aria-label": expanded ? 'Collapse code' : 'Expand code',
77
+ "aria-expanded": expanded,
78
+ children: /*#__PURE__*/ jsx(SvgWrapper, {
79
+ icon: IconArrowDown,
80
+ className: "rp-codeblock__fold-btn__icon"
81
+ })
32
82
  })
33
83
  ]
34
84
  });
@@ -1,4 +1,4 @@
1
- import type { CodeBlockProps } from '@theme';
1
+ import type { CodeBlockProps } from '@rspress/core/theme';
2
2
  import { type ReactNode } from 'react';
3
3
  import { type BundledLanguage, type BundledTheme, type CodeToHastOptions } from 'shiki';
4
4
  export interface CodeBlockRuntimeProps extends CodeBlockProps {
@@ -11,4 +11,4 @@ export interface CodeBlockRuntimeProps extends CodeBlockProps {
11
11
  */
12
12
  onRendered?: () => void;
13
13
  }
14
- export declare function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers, }: CodeBlockRuntimeProps): ReactNode;
14
+ export declare function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers, fold, height, }: CodeBlockRuntimeProps): ReactNode;
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { getCustomMDXComponent } from "@theme";
2
+ import { getCustomMDXComponent } from "@rspress/core/theme";
3
3
  import { toJsxRuntime } from "hast-util-to-jsx-runtime";
4
4
  import { Fragment, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { codeToHast, createCssVariablesTheme } from "shiki";
@@ -14,7 +14,7 @@ const useLatest = (value)=>{
14
14
  ref.current = value;
15
15
  return ref;
16
16
  };
17
- function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers }) {
17
+ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers, fold, height }) {
18
18
  const mdxComponents = useMemo(()=>getCustomMDXComponent(), []);
19
19
  const { pre: ShikiPre, code: Code, ...otherMdxComponents } = mdxComponents;
20
20
  const fallback = useMemo(()=>/*#__PURE__*/ jsx(ShikiPre, {
@@ -22,6 +22,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
22
22
  lang: lang,
23
23
  wrapCode: wrapCode,
24
24
  lineNumbers: lineNumbers,
25
+ fold: fold,
26
+ height: height,
25
27
  containerElementClassName: containerElementClassName,
26
28
  codeButtonGroupProps: codeButtonGroupProps,
27
29
  className: "shiki css-variables",
@@ -36,6 +38,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
36
38
  lang,
37
39
  wrapCode,
38
40
  lineNumbers,
41
+ fold,
42
+ height,
39
43
  containerElementClassName,
40
44
  codeButtonGroupProps,
41
45
  code
@@ -63,6 +67,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
63
67
  codeButtonGroupProps: codeButtonGroupProps,
64
68
  wrapCode: wrapCode,
65
69
  lineNumbers: lineNumbers,
70
+ fold: fold,
71
+ height: height,
66
72
  ...props
67
73
  }),
68
74
  code: (props)=>/*#__PURE__*/ jsx(Code, {
@@ -80,6 +86,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
80
86
  containerElementClassName,
81
87
  lang,
82
88
  lineNumbers,
89
+ fold,
90
+ height,
83
91
  shikiOptions,
84
92
  title,
85
93
  wrapCode
@@ -8,7 +8,7 @@
8
8
  position: absolute;
9
9
  top: 50%;
10
10
  left: 50%;
11
- transform: translate(-50%, -50%)scale(0);
11
+ transform: translate(-50%, -50%) scale(0);
12
12
  }
13
13
 
14
14
  .rp-code-copy-button--copied .rp-code-copy-button__icon--copy {
@@ -19,6 +19,6 @@
19
19
  .rp-code-copy-button--copied .rp-code-copy-button__icon--success {
20
20
  opacity: 1;
21
21
  transition-delay: 75ms;
22
- transform: translate(-50%, -50%)scale(1);
22
+ transform: translate(-50%, -50%) scale(1);
23
23
  }
24
24
 
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { IconCopy, IconSuccess, SvgWrapper } from "@theme";
2
+ import { IconCopy, IconSuccess, SvgWrapper } from "@rspress/core/theme";
3
3
  import copy_to_clipboard from "copy-to-clipboard";
4
4
  import { useRef } from "react";
5
5
  import "./CopyCodeButton.css";
@@ -49,7 +49,7 @@
49
49
  position: absolute;
50
50
  top: 50%;
51
51
  left: 50%;
52
- transform: translate(-50%, -50%)scale(0);
52
+ transform: translate(-50%, -50%) scale(0);
53
53
  }
54
54
 
55
55
  .rp-code-wrap-button--wrapped .rp-code-button-group__icon--wrap {
@@ -60,6 +60,6 @@
60
60
  .rp-code-wrap-button--wrapped .rp-code-button-group__icon--wrapped {
61
61
  opacity: 1;
62
62
  transition-delay: 75ms;
63
- transform: translate(-50%, -50%)scale(1);
63
+ transform: translate(-50%, -50%) scale(1);
64
64
  }
65
65