@rspress/core 2.0.9 → 2.0.11

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 (119) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/3323.js +8 -0
  3. package/dist/{740.js → 5810.js} +127 -139
  4. package/dist/{2240.js → 6162.js} +1 -4
  5. package/dist/8006.js +1 -1
  6. package/dist/8857.js +2 -3
  7. package/dist/cli/index.js +7 -4
  8. package/dist/common-Qw-RoVFD.js +25 -0
  9. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
  10. package/dist/eject-theme/components/DocContent/doc.scss +14 -41
  11. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +1 -2
  12. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +14 -8
  13. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
  14. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +8 -5
  15. package/dist/eject-theme/components/Outline/index.scss +1 -1
  16. package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
  17. package/dist/eject-theme/components/Prompt/index.scss +423 -0
  18. package/dist/eject-theme/components/Prompt/index.tsx +335 -0
  19. package/dist/eject-theme/components/Search/logic/search.ts +10 -5
  20. package/dist/eject-theme/components/Search/logic/util.test.ts +20 -1
  21. package/dist/eject-theme/components/Search/logic/util.ts +4 -1
  22. package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -1
  23. package/dist/entry/process.d.ts +1 -0
  24. package/dist/entry/process.js +65 -0
  25. package/dist/entry/utils.d.ts +7 -0
  26. package/dist/entry/utils.js +2 -0
  27. package/dist/entry/worker.d.ts +1 -0
  28. package/dist/entry/worker.js +74 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -0
  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 +2 -2
  35. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  36. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  37. package/dist/node/eject.js +1 -0
  38. package/dist/node/index.d.ts +1 -0
  39. package/dist/node/initRsbuild.js +1 -1
  40. package/dist/node/mdx/options.js +2 -1
  41. package/dist/node/mdx/processor.js +1 -1
  42. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  43. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  44. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +1 -1
  46. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  47. package/dist/node/mdx/remarkPlugins/fileCodeBlock.d.ts +1 -0
  48. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +9 -4
  49. package/dist/node/mdx/remarkPlugins/image.js +1 -1
  50. package/dist/node/mdx/remarkPlugins/link.js +1 -1
  51. package/dist/node/route/RoutePage.js +1 -1
  52. package/dist/node/route/RouteService.js +1 -1
  53. package/dist/node/route/extractPageData.js +1 -1
  54. package/dist/node/route/normalizeRoutePath.js +1 -1
  55. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +28 -0
  56. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
  57. package/dist/node/runtimeModule/i18n.js +1 -1
  58. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  59. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  60. package/dist/node/runtimeModule/searchHooks.js +1 -1
  61. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  62. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  63. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  64. package/dist/node/serve.js +1 -1
  65. package/dist/node/ssg/renderPages.js +2 -2
  66. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  67. package/dist/node/ssg/ssgEnv.js +1 -1
  68. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  69. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  70. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  71. package/dist/node/ssg-md/renderPage.js +1 -1
  72. package/dist/node/ssg-md/renderPages.js +1 -1
  73. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  74. package/dist/node/utils/checkLanguageParity.js +1 -1
  75. package/dist/node/utils/createHash.js +1 -1
  76. package/dist/node/utils/flattenMdxContent.js +1 -1
  77. package/dist/node/utils/getPageKey.js +1 -1
  78. package/dist/node/utils/reactAlias.js +1 -1
  79. package/dist/runtime/BrowserOnly.d.ts +7 -0
  80. package/dist/runtime/BrowserOnly.js +40 -0
  81. package/dist/runtime/BrowserOnly.test.d.ts +1 -0
  82. package/dist/runtime/index.d.ts +1 -0
  83. package/dist/runtime/index.js +1 -0
  84. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +14 -12
  85. package/dist/theme/components/DocContent/doc.css +13 -21
  86. package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
  87. package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
  88. package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
  89. package/dist/theme/components/Outline/index.css +1 -1
  90. package/dist/theme/components/Prompt/icons.d.ts +10 -0
  91. package/dist/theme/components/Prompt/icons.js +64 -0
  92. package/dist/theme/components/Prompt/index.css +326 -0
  93. package/dist/theme/components/Prompt/index.d.ts +33 -0
  94. package/dist/theme/components/Prompt/index.js +262 -0
  95. package/dist/theme/components/Search/logic/search.js +5 -3
  96. package/dist/theme/components/Search/logic/util.js +2 -1
  97. package/dist/theme/components/SidebarMenu/index.js +2 -1
  98. package/dist/theme/index.d.ts +3 -0
  99. package/dist/theme/index.js +3 -0
  100. package/dist/theme/layout/DocLayout/index.css +9 -1
  101. package/dist/theme/layout/DocLayout/index.js +11 -6
  102. package/dist/theme/logic/copyToClipboard.d.ts +1 -0
  103. package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
  104. package/dist/theme/logic/getCopyableText.d.ts +5 -0
  105. package/dist/theme/logic/getCopyableText.js +52 -0
  106. package/dist/theme/logic/useThemeState.d.ts +5 -10
  107. package/dist/theme/logic/useThemeState.js +15 -20
  108. package/dist/theme/styles/vars/base-vars.css +4 -4
  109. package/dist/utils-B--2TaWv.js +34 -0
  110. package/dist/utils-De75vAgL.js +7 -0
  111. package/package.json +16 -16
  112. package/dist/3425.js +0 -6
  113. package/dist/eject-theme/components/Llms/copy.ts +0 -12
  114. package/dist/runtime/getSidebarDataGroup.test.js +0 -68
  115. package/dist/runtime/hooks/useWindowSize.test.js +0 -36
  116. package/dist/runtime/route.test.js +0 -154
  117. package/dist/runtime/utils.test.js +0 -34
  118. package/dist/theme/components/Llms/copy.d.ts +0 -1
  119. package/dist/theme/components/Search/logic/util.test.js +0 -51
@@ -1,5 +1,6 @@
1
1
  export { build } from './build.js';
2
2
  export { dev } from './dev.js';
3
3
  export { remarkFileCodeBlock } from './mdx/remarkPlugins/fileCodeBlock.js';
4
+ export { remarkImage } from './mdx/remarkPlugins/image.js';
4
5
  export { remarkLink } from './mdx/remarkPlugins/link.js';
5
6
  export { serve } from './serve.js';
@@ -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 "../740.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 "../5810.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { PUBLIC_DIR, 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";
@@ -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 "../../2240.js";
1
+ import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../6162.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";
@@ -34,6 +34,7 @@ async function createMDXOptions(options) {
34
34
  remarkFileCodeBlock,
35
35
  {
36
36
  filepath,
37
+ docDirectory,
37
38
  addDependency
38
39
  }
39
40
  ],
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../2240.js";
1
+ import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../6162.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 "../../../2240.js";
1
+ import { visit } from "../../../6162.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 "../../../2240.js";
1
+ import { visit, extractTextAndId, github_slugger, headingRank } from "../../../6162.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 "../../../2240.js";
1
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../6162.js";
2
2
  const cssVariablesTheme = createCssVariablesTheme({
3
3
  name: 'css-variables',
4
4
  variablePrefix: '--shiki-',
@@ -1,4 +1,4 @@
1
- export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold, } from './add-fold.js';
1
+ export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold } from './add-fold.js';
2
2
  export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from './add-lang.js';
3
3
  export { SHIKI_TRANSFORMER_ADD_LINE_NUMBERS, transformerAddLineNumbers, } from './add-line-numbers.js';
4
4
  export { SHIKI_TRANSFORMER_ADD_TITLE, transformerAddTitle } from './add-title.js';
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../../2240.js";
1
+ import { node_path } from "../../../6162.js";
2
2
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
3
3
  const remarkBuiltin = ({ globalComponents })=>(tree)=>{
4
4
  const demos = globalComponents.map((componentPath)=>{
@@ -4,6 +4,7 @@ import type { Plugin } from 'unified';
4
4
  export declare const remarkFileCodeBlock: Plugin<[
5
5
  {
6
6
  filepath: string;
7
+ docDirectory: string;
7
8
  addDependency?: Rspack.LoaderContext['addDependency'];
8
9
  }
9
10
  ], Root>;
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
2
  import "../../../8006.js";
3
- import { visit, node_path, logger, cwd, readFile } from "../../../3425.js";
3
+ import { visit, node_path, logger, cwd, readFile } from "../../../3323.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);
@@ -14,16 +14,16 @@ function parseFileFromMeta(meta) {
14
14
  }
15
15
  return '';
16
16
  }
17
- const remarkFileCodeBlock = ({ filepath, addDependency })=>async (tree)=>{
17
+ const remarkFileCodeBlock = ({ filepath, docDirectory, addDependency })=>async (tree)=>{
18
18
  const promiseList = [];
19
19
  visit(tree, 'code', (node)=>{
20
20
  const { meta, value, lang } = node;
21
21
  const file = parseFileFromMeta(meta ?? '');
22
22
  if (!file) return;
23
23
  const originalMetaForErrorInfo = picocolors_default().cyan(`\`\`\`${lang} ${meta}`);
24
- if (file.startsWith('./') || file.startsWith('../') || file.startsWith('<root>/')) {
24
+ if (file.startsWith('./') || file.startsWith('../') || file.startsWith('/') || file.startsWith('<root>/')) {
25
25
  let resolvedFilePath;
26
- resolvedFilePath = file.startsWith('<root>/') ? node_path.join(cwd(), file.slice(7)) : node_path.join(node_path.dirname(filepath), file);
26
+ resolvedFilePath = file.startsWith('<root>/') ? node_path.join(cwd(), file.slice(7)) : file.startsWith('/') ? node_path.join(docDirectory, file.slice(1)) : node_path.join(node_path.dirname(filepath), file);
27
27
  if ('' !== value.trim()) {
28
28
  logger.error(`${ERROR_PREFIX} ${originalMetaForErrorInfo} The content of file code block should be empty.
29
29
 
@@ -58,6 +58,11 @@ Please use below:
58
58
 
59
59
  or
60
60
 
61
+ \`\`\`tsx file="/path/to/filename"
62
+ \`\`\`
63
+
64
+ or
65
+
61
66
  \`\`\`tsx file="<root>/path/to/filename"
62
67
  \`\`\`
63
68
  `);
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
2
  import "../../../8006.js";
3
- import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../2240.js";
3
+ import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../3323.js";
4
4
  import { createError } from "../../utils/error.js";
5
5
  import { PUBLIC_DIR } from "../../constants.js";
6
6
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
2
  import "../../../8006.js";
3
- import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withBase } from "../../../3425.js";
3
+ import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withBase } from "../../../3323.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 { node_path } from "../../740.js";
1
+ import { node_path } from "../../5810.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 "../../740.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../5810.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, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../740.js";
1
+ import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../5810.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 "../../740.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../5810.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 [
@@ -167,4 +167,32 @@ export declare const DEFAULT_I18N_TEXT: {
167
167
  readonly ko: "홈으로 이동";
168
168
  readonly ru: "Вернуться на главную";
169
169
  };
170
+ readonly promptCopyText: {
171
+ readonly en: "Copy Prompt";
172
+ readonly zh: "复制 Prompt";
173
+ readonly ja: "Prompt をコピー";
174
+ readonly ko: "프롬프트 복사";
175
+ readonly ru: "Скопировать Prompt";
176
+ };
177
+ readonly promptCopiedText: {
178
+ readonly en: "Copied";
179
+ readonly zh: "已复制";
180
+ readonly ja: "コピーしました";
181
+ readonly ko: "복사됨";
182
+ readonly ru: "Скопировано";
183
+ };
184
+ readonly promptExpandText: {
185
+ readonly en: "Expand";
186
+ readonly zh: "展开";
187
+ readonly ja: "展開";
188
+ readonly ko: "펼치기";
189
+ readonly ru: "Развернуть";
190
+ };
191
+ readonly promptCollapseText: {
192
+ readonly en: "Collapse";
193
+ readonly zh: "折叠";
194
+ readonly ja: "折りたたむ";
195
+ readonly ko: "접기";
196
+ readonly ru: "Свернуть";
197
+ };
170
198
  };
@@ -166,6 +166,34 @@ const DEFAULT_I18N_TEXT = {
166
166
  ja: 'ホームに連れてって',
167
167
  ko: '홈으로 이동',
168
168
  ru: 'Вернуться на главную'
169
+ },
170
+ promptCopyText: {
171
+ en: 'Copy Prompt',
172
+ zh: '复制 Prompt',
173
+ ja: 'Prompt をコピー',
174
+ ko: '프롬프트 복사',
175
+ ru: 'Скопировать Prompt'
176
+ },
177
+ promptCopiedText: {
178
+ en: 'Copied',
179
+ zh: '已复制',
180
+ ja: 'コピーしました',
181
+ ko: '복사됨',
182
+ ru: 'Скопировано'
183
+ },
184
+ promptExpandText: {
185
+ en: 'Expand',
186
+ zh: '展开',
187
+ ja: '展開',
188
+ ko: '펼치기',
189
+ ru: 'Развернуть'
190
+ },
191
+ promptCollapseText: {
192
+ en: 'Collapse',
193
+ zh: '折叠',
194
+ ja: '折りたたむ',
195
+ ko: '접기',
196
+ ru: 'Свернуть'
169
197
  }
170
198
  };
171
199
  export { DEFAULT_I18N_TEXT };
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../8006.js";
3
- import { external_node_module_createRequire, join, logger } from "../../740.js";
3
+ import { external_node_module_createRequire, join, logger } from "../../5810.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 "../../../740.js";
1
+ import { SEARCH_INDEX_NAME, groupBy } from "../../../5810.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 "../../../740.js";
1
+ import { logger, pluginVirtualModule } from "../../../5810.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 "../../740.js";
1
+ import { node_path } from "../../5810.js";
2
2
  const searchHookVMPlugin = (context)=>({
3
3
  ["virtual-search-hooks"]: ()=>{
4
4
  const { config } = context;
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../740.js";
1
+ import { getIconUrlPath } from "../../../5810.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 "../../../740.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../5810.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 "../../../740.js";
1
+ import { logger } from "../../../5810.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 "../740.js";
1
+ import { mergeRsbuildConfig } from "../5810.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,7 +1,7 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
3
3
  import "../../8006.js";
4
- import { chunk, logger } from "../../740.js";
4
+ import { chunk, logger } from "../../5810.js";
5
5
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
6
6
  import { pMap } from "../../1688.js";
7
7
  import { renderPage } from "./renderPage.js";
@@ -17,7 +17,7 @@ const routePath2HtmlFileName = (routePath)=>{
17
17
  async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset) {
18
18
  logger.info('Rendering pages...');
19
19
  const startTime = Date.now();
20
- const ssg = config.ssg || true;
20
+ const ssg = config.ssg ?? true;
21
21
  try {
22
22
  const routes = routeService.getRoutes();
23
23
  if (!routeService.isExistRoute('/404')) routes.push({
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../740.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../5810.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 })=>({
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../740.js";
2
+ import { node_os } from "../../5810.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 "../../../740.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../5810.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 "../../../740.js";
1
+ import { normalizeHref, logger, withBase } from "../../../5810.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base) {
4
4
  let url = routePath;
@@ -1,4 +1,4 @@
1
- import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../2240.js";
1
+ import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../6162.js";
2
2
  function remarkSplitMdx(options = {}) {
3
3
  return (tree)=>{
4
4
  const newChildren = [];
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../8006.js";
3
- import { createHead, pathToFileURL, logger } from "../../740.js";
3
+ import { createHead, pathToFileURL, logger } from "../../5810.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,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../8006.js";
3
- import { logger } from "../../740.js";
3
+ import { logger } from "../../5810.js";
4
4
  import { pMap } from "../../1688.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../740.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../5810.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 "../../740.js";
1
+ import { node_path, logger, promises } from "../../5810.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 "../../740.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../5810.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 "../../740.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../5810.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 "../../740.js";
1
+ import { removeLeadingSlash } from "../../5810.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 "../../8006.js";
3
- import { node_path, core_rspack, logger } from "../../740.js";
3
+ import { node_path, core_rspack, logger } from "../../5810.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";
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface BrowserOnlyProps {
3
+ children: () => ReactNode | Promise<ReactNode>;
4
+ fallback?: ReactNode;
5
+ }
6
+ export declare function BrowserOnly(props: BrowserOnlyProps): ReactNode;
7
+ export default BrowserOnly;
@@ -0,0 +1,40 @@
1
+ import { useEffect, useState } from "react";
2
+ function BrowserOnly(props) {
3
+ const { children, fallback = null } = props;
4
+ const [state, setState] = useState({
5
+ status: 'pending',
6
+ children
7
+ });
8
+ useEffect(()=>{
9
+ let isMounted = true;
10
+ setState({
11
+ status: 'pending',
12
+ children
13
+ });
14
+ Promise.resolve().then(()=>children()).then((content)=>{
15
+ if (isMounted) setState({
16
+ status: 'resolved',
17
+ children,
18
+ content
19
+ });
20
+ }, (error)=>{
21
+ if (isMounted) setState({
22
+ status: 'rejected',
23
+ children,
24
+ error
25
+ });
26
+ });
27
+ return ()=>{
28
+ isMounted = false;
29
+ };
30
+ }, [
31
+ children
32
+ ]);
33
+ if (state.children !== children) return fallback;
34
+ if ('rejected' === state.status) throw state.error;
35
+ if ('resolved' === state.status) return state.content;
36
+ return fallback;
37
+ }
38
+ const runtime_BrowserOnly = BrowserOnly;
39
+ export default runtime_BrowserOnly;
40
+ export { BrowserOnly };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref, } from '@rspress/shared';
2
2
  export { Head, useHead } from '@unhead/react';
3
3
  export * from 'react-router-dom';
4
+ export { BrowserOnly, type BrowserOnlyProps } from './BrowserOnly.js';
4
5
  export { Content } from './Content.js';
5
6
  export { useActiveMatcher } from './hooks/useActiveMatcher.js';
6
7
  export { ThemeContext, useDark } from './hooks/useDark.js';
@@ -1,6 +1,7 @@
1
1
  export * from "react-router-dom";
2
2
  export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref } from "@rspress/shared";
3
3
  export { Head, useHead } from "@unhead/react";
4
+ export { BrowserOnly } from "./BrowserOnly.js";
4
5
  export { Content } from "./Content.js";
5
6
  export { useActiveMatcher } from "./hooks/useActiveMatcher.js";
6
7
  export { ThemeContext, useDark } from "./hooks/useDark.js";
@@ -1,21 +1,21 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { IconCopy, IconSuccess, SvgWrapper } from "@rspress/core/theme";
3
- import copy_to_clipboard from "copy-to-clipboard";
2
+ import { IconCopy, IconSuccess, SvgWrapper, copyToClipboard, getCopyableText } from "@rspress/core/theme";
4
3
  import { useRef } from "react";
5
4
  import "./CopyCodeButton.css";
6
5
  import { useI18n } from "@rspress/core/runtime";
7
6
  const timeoutIdMap = new Map();
8
7
  const COPIED_CLASS = 'rp-code-copy-button--copied';
9
- function copyCode(codeBlockElement, copyButtonElement) {
10
- let text = '';
8
+ async function copyCode(codeBlockElement, copyButtonElement) {
11
9
  if (!codeBlockElement) return;
12
- const walk = document.createTreeWalker(codeBlockElement, NodeFilter.SHOW_TEXT, null);
13
- let node = walk.nextNode();
14
- while(node){
15
- if (!node.parentElement.classList.contains('linenumber') && !node.parentElement.closest('.rp-copy-ignore')) text += node.nodeValue;
16
- node = walk.nextNode();
17
- }
18
- const isCopied = copy_to_clipboard(text);
10
+ const text = getCopyableText(codeBlockElement, {
11
+ ignoreClasses: [
12
+ 'linenumber'
13
+ ],
14
+ ignoreSelectors: [
15
+ '.rp-copy-ignore'
16
+ ]
17
+ });
18
+ const isCopied = await copyToClipboard(text);
19
19
  if (isCopied && copyButtonElement) {
20
20
  copyButtonElement.classList.add(COPIED_CLASS);
21
21
  clearTimeout(timeoutIdMap.get(copyButtonElement));
@@ -32,7 +32,9 @@ function CopyCodeButton({ codeBlockRef }) {
32
32
  const t = useI18n();
33
33
  return /*#__PURE__*/ jsxs("button", {
34
34
  className: "rp-code-button-group__button rp-code-copy-button",
35
- onClick: ()=>copyCode(codeBlockRef.current, copyButtonRef.current),
35
+ onClick: ()=>{
36
+ copyCode(codeBlockRef.current, copyButtonRef.current);
37
+ },
36
38
  ref: copyButtonRef,
37
39
  title: t('codeButtonGroupCopyButtonText'),
38
40
  children: [
@@ -151,6 +151,8 @@
151
151
  }
152
152
 
153
153
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(.rp-table-scroll-container) {
154
+ overscroll-behavior-x: contain;
155
+ margin: 1.5rem 0;
154
156
  overflow-x: auto;
155
157
  }
156
158
 
@@ -161,21 +163,12 @@
161
163
  border: var(--rp-code-block-border);
162
164
  border-radius: var(--rp-radius);
163
165
  width: 100%;
166
+ min-width: 100%;
164
167
  overflow: hidden;
165
168
  }
166
169
 
167
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar {
168
- width: 5px;
169
- height: 5px;
170
- }
171
-
172
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar-corner {
173
- display: none;
174
- }
175
-
176
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar-thumb {
177
- background-color: #0000000d;
178
- border-radius: 10px;
170
+ .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table:not(.rp-table-scroll-container > table)) {
171
+ margin: 1.5rem 0;
179
172
  }
180
173
 
181
174
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(thead) {
@@ -186,7 +179,8 @@
186
179
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(th) {
187
180
  text-align: left;
188
181
  border-bottom: 1px solid var(--rp-c-divider-light);
189
- padding: .75rem 1.25rem;
182
+ min-width: 8rem;
183
+ padding: .75rem 1rem;
190
184
  font-size: .875rem;
191
185
  font-weight: 600;
192
186
  position: relative;
@@ -198,15 +192,17 @@
198
192
 
199
193
  .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(td) {
200
194
  border-bottom: 1px solid var(--rp-c-divider-light);
201
- padding: .75rem 1.25rem;
195
+ min-width: 8rem;
196
+ color: var(--rp-c-text-1);
197
+ padding: .75rem 1rem;
202
198
  font-size: .875rem;
203
199
  }
204
200
 
205
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tr) {
206
- transition: background-color .2s;
201
+ .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tbody tr) {
202
+ transition: background-color .2s ease-out;
207
203
  }
208
204
 
209
- .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tr):hover {
205
+ .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tbody tr):hover {
210
206
  background: var(--rp-c-bg-soft);
211
207
  }
212
208
 
@@ -248,7 +244,3 @@
248
244
  background-color: var(--rp-c-bg-mute);
249
245
  }
250
246
 
251
- :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table), :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table tr), :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table td), :where(.rp-dark) .rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table th) {
252
- border-color: var(--rp-c-divider);
253
- }
254
-