@rspress/core 2.0.8 → 2.0.10

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 (127) hide show
  1. package/dist/0~execa.js +8 -8
  2. package/dist/0~rslib-runtime.js +20 -0
  3. package/dist/0~tinypool.js +828 -0
  4. package/dist/{8311.js → 1688.js} +1 -7
  5. package/dist/{7397.js → 2240.js} +4 -2
  6. package/dist/2287.js +2458 -0
  7. package/dist/{1361.js → 3294.js} +1 -1
  8. package/dist/{1965.js → 3425.js} +0 -1
  9. package/dist/8006.js +77 -0
  10. package/dist/8857.js +4826 -0
  11. package/dist/8857.js.LICENSE.txt +41 -0
  12. package/dist/cli/index.js +14 -7
  13. package/dist/config/loadConfigFile.js +1 -1
  14. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.scss +1 -1
  15. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
  16. package/dist/eject-theme/components/CodeButtonGroup/index.scss +1 -1
  17. package/dist/eject-theme/components/DocContent/doc.scss +16 -41
  18. package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
  19. package/dist/eject-theme/components/Link/useLinkNavigate.ts +4 -1
  20. package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +3 -3
  21. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +13 -6
  22. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
  23. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +7 -3
  24. package/dist/eject-theme/components/Outline/index.scss +1 -1
  25. package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
  26. package/dist/eject-theme/components/Prompt/index.scss +478 -0
  27. package/dist/eject-theme/components/Prompt/index.tsx +335 -0
  28. package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -1
  29. package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -1
  30. package/dist/eject-theme/components/Steps/index.scss +32 -13
  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 +10 -6
  35. package/dist/node/auto-nav-sidebar/utils.js +8 -2
  36. package/dist/node/auto-nav-sidebar/walk.js +2 -8
  37. package/dist/node/constants.js +1 -1
  38. package/dist/node/eject.js +12 -7
  39. package/dist/node/initRsbuild.js +6 -6
  40. package/dist/node/logger/hint.js +9 -6
  41. package/dist/node/mdx/options.js +13 -2
  42. package/dist/node/mdx/processor.js +1 -1
  43. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  44. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  46. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  47. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +6 -2
  48. package/dist/node/mdx/remarkPlugins/image.d.ts +7 -2
  49. package/dist/node/mdx/remarkPlugins/image.js +51 -2
  50. package/dist/node/mdx/remarkPlugins/link.js +7 -3
  51. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  52. package/dist/node/route/RoutePage.js +1 -1
  53. package/dist/node/route/RouteService.js +1 -1
  54. package/dist/node/route/extractPageData.js +75 -26
  55. package/dist/node/route/normalizeRoutePath.js +1 -1
  56. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +28 -0
  57. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
  58. package/dist/node/runtimeModule/i18n.js +10 -6
  59. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  60. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  61. package/dist/node/runtimeModule/searchHooks.js +1 -1
  62. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  63. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  64. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  65. package/dist/node/serve.js +1 -1
  66. package/dist/node/ssg/renderPage.js +8 -4
  67. package/dist/node/ssg/renderPageWorker.js +1 -1
  68. package/dist/node/ssg/renderPages.js +9 -5
  69. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  70. package/dist/node/ssg/ssgEnv.js +1 -1
  71. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  72. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  73. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  74. package/dist/node/ssg-md/renderPage.js +8 -4
  75. package/dist/node/ssg-md/renderPages.js +7 -3
  76. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  77. package/dist/node/utils/checkLanguageParity.js +1 -1
  78. package/dist/node/utils/createHash.js +1 -1
  79. package/dist/node/utils/error.js +5 -2
  80. package/dist/node/utils/flattenMdxContent.js +1 -1
  81. package/dist/node/utils/fs.js +1 -1
  82. package/dist/node/utils/getPageKey.js +1 -1
  83. package/dist/node/utils/normalizePath.js +1 -1
  84. package/dist/node/utils/reactAlias.js +7 -3
  85. package/dist/runtime/App.js +4 -1
  86. package/dist/runtime/index.d.ts +2 -1
  87. package/dist/runtime/index.js +2 -1
  88. package/dist/runtime/initPageData.d.ts +3 -0
  89. package/dist/runtime/initPageData.js +37 -2
  90. package/dist/runtime/ssrClientEntry.js +4 -2
  91. package/dist/theme/assets/success.js +1 -1
  92. package/dist/theme/assets/wrapped.js +1 -1
  93. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.css +1 -1
  94. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +14 -12
  95. package/dist/theme/components/CodeButtonGroup/index.css +1 -1
  96. package/dist/theme/components/DocContent/doc.css +14 -21
  97. package/dist/theme/components/FallbackHeading/index.js +1 -1
  98. package/dist/theme/components/Link/useLinkNavigate.js +3 -2
  99. package/dist/theme/components/Llms/LlmsCopyButton.css +5 -5
  100. package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
  101. package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
  102. package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
  103. package/dist/theme/components/Outline/index.css +1 -1
  104. package/dist/theme/components/Prompt/icons.d.ts +10 -0
  105. package/dist/theme/components/Prompt/icons.js +64 -0
  106. package/dist/theme/components/Prompt/index.css +352 -0
  107. package/dist/theme/components/Prompt/index.d.ts +33 -0
  108. package/dist/theme/components/Prompt/index.js +262 -0
  109. package/dist/theme/components/Search/SearchPanel.js +1 -1
  110. package/dist/theme/components/SidebarMenu/index.js +2 -1
  111. package/dist/theme/components/Steps/index.css +23 -12
  112. package/dist/theme/index.d.ts +3 -0
  113. package/dist/theme/index.js +3 -0
  114. package/dist/theme/layout/DocLayout/index.css +5 -1
  115. package/dist/theme/layout/DocLayout/index.js +8 -4
  116. package/dist/theme/logic/copyToClipboard.d.ts +1 -0
  117. package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
  118. package/dist/theme/logic/getCopyableText.d.ts +5 -0
  119. package/dist/theme/logic/getCopyableText.js +52 -0
  120. package/dist/theme/logic/useThemeState.js +1 -1
  121. package/dist/theme/styles/vars/base-vars.css +4 -4
  122. package/package.json +20 -23
  123. package/dist/4454.js +0 -8
  124. package/dist/7319.js +0 -88
  125. package/dist/8885.js +0 -4
  126. package/dist/eject-theme/components/Llms/copy.ts +0 -12
  127. package/dist/theme/components/Llms/copy.d.ts +0 -1
@@ -1,5 +1,8 @@
1
- import { picocolors, relative, logger, join, readFile } from "../../8885.js";
1
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
+ import { relative, logger, join, readFile } from "../../8006.js";
2
3
  import { pathExists } from "../utils/fs.js";
4
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
5
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
3
6
  const THEME_DEFAULT_EXPORT_PATTERN = /export\s+default\s+\{/;
4
7
  const THEME_OLD_IMPORT_0 = /from\s+['"]rspress\/theme['"]/;
5
8
  const THEME_OLD_IMPORT_1 = /from\s+['"]@rspress\/core\/theme['"]/;
@@ -27,13 +30,13 @@ async function hintThemeBreakingChange(customThemeDir) {
27
30
  }
28
31
  }
29
32
  }
30
- if (useDefaultExportFilePath) logger.warn(`[Rspress v2] Breaking Change: The "theme/index.tsx" is now using named export from '@rspress/core/theme-original' instead of default export from 'rspress/theme', please update ${picocolors.greenBright(useDefaultExportFilePath)} (https://github.com/web-infra-dev/rspress/discussions/1891#discussioncomment-12422737).\n`, picocolors.redBright(`
33
+ if (useDefaultExportFilePath) logger.warn(`[Rspress v2] Breaking Change: The "theme/index.tsx" is now using named export from '@rspress/core/theme-original' instead of default export from 'rspress/theme', please update ${picocolors_default().greenBright(useDefaultExportFilePath)} (https://github.com/web-infra-dev/rspress/discussions/1891#discussioncomment-12422737).\n`, picocolors_default().redBright(`
31
34
  - import Theme from 'rspress/theme';
32
35
  - export default {
33
36
  - ...Theme,
34
37
  - Layout,
35
38
  - };
36
- - export * from 'rspress/theme';`) + picocolors.greenBright(`
39
+ - export * from 'rspress/theme';`) + picocolors_default().greenBright(`
37
40
  + import { Layout } from '@rspress/core/theme-original';
38
41
 
39
42
  + export { Layout };
@@ -44,10 +47,10 @@ function hintBuilderPluginsBreakingChange(config) {
44
47
  if ('builderPlugins' in config && Array.isArray(config.builderPlugins) && config.builderPlugins.length > 0) {
45
48
  logger.error(`[Rspress v2] The "builderPlugins" option has been renamed to "builderConfig.plugins", please update your config accordingly (https://rspress.rs/api/config/config-build#builderconfigplugins).\n`, `
46
49
  export default defineConfig({
47
- ${picocolors.redBright(` builderPlugins: [
50
+ ${picocolors_default().redBright(` builderPlugins: [
48
51
  pluginFoo()
49
52
  ],`)}
50
- ${picocolors.greenBright(` builderConfig: {
53
+ ${picocolors_default().greenBright(` builderConfig: {
51
54
  plugins: [
52
55
  pluginFoo()
53
56
  ],
@@ -79,7 +82,7 @@ function hintNavJsonChangeThenPanic(metaJson, metaJsonDir, docsDir) {
79
82
  const error = new Error('[Rspress v2] Detected that you are still using top level `_meta.json` to configure the nav, but it has been changed to `_nav.json` in Rspress v2. Please rename the top level `_meta.json` to `_nav.json` accordingly.');
80
83
  logger.error(error);
81
84
  const dir = relative(docsDir, metaJsonDir);
82
- logger.info(`Please rename "${picocolors.greenBright(join(dir, '_meta.json'))}" to "${picocolors.greenBright(join(dir, '_nav.json'))}".`);
85
+ logger.info(`Please rename "${picocolors_default().greenBright(join(dir, '_meta.json'))}" to "${picocolors_default().greenBright(join(dir, '_nav.json'))}".`);
83
86
  process.exit(1);
84
87
  }
85
88
  }
@@ -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 "../../7397.js";
1
+ import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../2240.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";
@@ -55,7 +55,18 @@ async function createMDXOptions(options) {
55
55
  remarkLinkOptions
56
56
  }
57
57
  ],
58
- remarkImage,
58
+ [
59
+ remarkImage,
60
+ isSsgMd ? {
61
+ docDirectory,
62
+ remarkImageOptions: {
63
+ checkDeadImages: false
64
+ }
65
+ } : {
66
+ docDirectory,
67
+ remarkImageOptions: config?.markdown?.image
68
+ }
69
+ ],
59
70
  isSsgMd && [
60
71
  remarkSplitMdx,
61
72
  'object' == typeof config?.llms ? config.llms.remarkSplitMdxOptions : void 0
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../7397.js";
1
+ import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../2240.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 "../../../7397.js";
1
+ import { visit } from "../../../2240.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 "../../../7397.js";
1
+ import { visit, extractTextAndId, github_slugger, headingRank } from "../../../2240.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 "../../../7397.js";
1
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../2240.js";
2
2
  const cssVariablesTheme = createCssVariablesTheme({
3
3
  name: 'css-variables',
4
4
  variablePrefix: '--shiki-',
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../../7397.js";
1
+ import { node_path } from "../../../2240.js";
2
2
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
3
3
  const remarkBuiltin = ({ globalComponents })=>(tree)=>{
4
4
  const demos = globalComponents.map((componentPath)=>{
@@ -1,5 +1,9 @@
1
- import { visit, node_path, logger, cwd, picocolors, readFile } from "../../../1965.js";
1
+ import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
+ import "../../../8006.js";
3
+ import { visit, node_path, logger, cwd, readFile } from "../../../3425.js";
2
4
  import { createError } from "../../utils/error.js";
5
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
3
7
  const ERROR_PREFIX = '[remarkFileCodeBlock]';
4
8
  function parseFileFromMeta(meta) {
5
9
  if (!meta) return '';
@@ -16,7 +20,7 @@ const remarkFileCodeBlock = ({ filepath, addDependency })=>async (tree)=>{
16
20
  const { meta, value, lang } = node;
17
21
  const file = parseFileFromMeta(meta ?? '');
18
22
  if (!file) return;
19
- const originalMetaForErrorInfo = picocolors.cyan(`\`\`\`${lang} ${meta}`);
23
+ const originalMetaForErrorInfo = picocolors_default().cyan(`\`\`\`${lang} ${meta}`);
20
24
  if (file.startsWith('./') || file.startsWith('../') || file.startsWith('<root>/')) {
21
25
  let resolvedFilePath;
22
26
  resolvedFilePath = file.startsWith('<root>/') ? node_path.join(cwd(), file.slice(7)) : node_path.join(node_path.dirname(filepath), file);
@@ -1,3 +1,8 @@
1
+ import { type MarkdownOptions } from '@rspress/shared';
1
2
  import type { Root } from 'mdast';
2
- import type { Plugin } from 'unified';
3
- export declare const remarkImage: Plugin<[], Root>;
3
+ import type { VFile } from 'vfile';
4
+ export declare const remarkImage: ({ docDirectory, remarkImageOptions, lint, }: {
5
+ docDirectory: string;
6
+ remarkImageOptions?: MarkdownOptions["image"];
7
+ lint?: boolean;
8
+ }) => (tree: Root, file: VFile) => void;
@@ -1,10 +1,56 @@
1
- import { isExternalUrl, getNodeAttribute, visit } from "../../../7397.js";
1
+ import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
+ import "../../../8006.js";
3
+ import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../2240.js";
4
+ import { createError } from "../../utils/error.js";
5
+ import { PUBLIC_DIR } from "../../constants.js";
2
6
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
7
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
8
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
3
9
  const normalizeImageUrl = (imageUrl)=>{
4
10
  if (isExternalUrl(imageUrl) || imageUrl.startsWith('/')) return '';
5
11
  return imageUrl;
6
12
  };
7
- const remarkImage = ()=>(tree, _file)=>{
13
+ function image_checkDeadImages(checkDeadImages, deadImages, file, lint) {
14
+ const errorInfos = [];
15
+ const excludes = 'object' == typeof checkDeadImages ? checkDeadImages.excludes : void 0;
16
+ const excludesUrl = Array.isArray(excludes) ? new Set(excludes) : void 0;
17
+ const excludesFn = 'function' == typeof excludes ? excludes : void 0;
18
+ [
19
+ ...deadImages.entries()
20
+ ].forEach(([imageUrl, resolvedPath])=>{
21
+ if (excludesUrl?.has(imageUrl)) return;
22
+ if (excludesFn?.(imageUrl)) return;
23
+ errorInfos.push([
24
+ imageUrl,
25
+ resolvedPath
26
+ ]);
27
+ });
28
+ if (errorInfos.length > 0) {
29
+ const message = `Dead images found${lint ? '' : ` in ${picocolors_default().cyan(file.path)}`}:
30
+ ${errorInfos.map(([imageUrl, resolved])=>` ${picocolors_default().green(`"![..](${imageUrl})"`)} ${picocolors_default().gray(resolved)}`).join('\n')}`;
31
+ if (lint) file.message(message);
32
+ else {
33
+ logger.error(message);
34
+ if (isProduction()) throw createError('Dead image found');
35
+ }
36
+ }
37
+ }
38
+ function resolveImage(imageUrl, filePath, docDirectory, deadImages) {
39
+ if (!imageUrl) return;
40
+ if (isExternalUrl(imageUrl)) return;
41
+ if (isDataUrl(imageUrl)) return;
42
+ const { url } = parseUrl(imageUrl);
43
+ if (url.startsWith('/')) {
44
+ const resolvedPath = node_path.join(docDirectory, PUBLIC_DIR, url);
45
+ if (!existsSync(resolvedPath)) deadImages.set(imageUrl, resolvedPath);
46
+ } else {
47
+ const resolvedPath = node_path.resolve(node_path.dirname(filePath), url);
48
+ if (!existsSync(resolvedPath)) deadImages.set(imageUrl, resolvedPath);
49
+ }
50
+ }
51
+ const remarkImage = ({ docDirectory, remarkImageOptions, lint })=>(tree, file)=>{
52
+ const { checkDeadImages: shouldCheckDeadImages = true } = remarkImageOptions ?? {};
53
+ const deadImages = new Map();
8
54
  const images = [];
9
55
  const getMdxSrcAttribute = (tempVar)=>({
10
56
  type: 'mdxJsxAttribute',
@@ -32,6 +78,7 @@ const remarkImage = ()=>(tree, _file)=>{
32
78
  visit(tree, 'image', (node)=>{
33
79
  const { alt, url } = node;
34
80
  if (!url) return;
81
+ if (shouldCheckDeadImages) resolveImage(url, file.path, docDirectory, deadImages);
35
82
  const imagePath = normalizeImageUrl(url);
36
83
  if (!imagePath) return;
37
84
  const tempVariableName = `image${images.length}`;
@@ -54,6 +101,7 @@ const remarkImage = ()=>(tree, _file)=>{
54
101
  if ('mdxJsxFlowElement' !== node.type && 'mdxJsxTextElement' !== node.type || 'img' !== node.name) return;
55
102
  const srcAttr = getNodeAttribute(node, 'src', true);
56
103
  if ('string' != typeof srcAttr?.value) return;
104
+ if (shouldCheckDeadImages) resolveImage(srcAttr.value, file.path, docDirectory, deadImages);
57
105
  const imagePath = normalizeImageUrl(srcAttr.value);
58
106
  if (!imagePath) return;
59
107
  const tempVariableName = `image${images.length}`;
@@ -61,5 +109,6 @@ const remarkImage = ()=>(tree, _file)=>{
61
109
  images.push(getDefaultImportAstNode(tempVariableName, imagePath));
62
110
  });
63
111
  tree.children.unshift(...images);
112
+ if (shouldCheckDeadImages) image_checkDeadImages(shouldCheckDeadImages, deadImages, file, lint);
64
113
  };
65
114
  export { remarkImage };
@@ -1,6 +1,10 @@
1
- import { normalizeHref, node_path, addLeadingSlash, logger, visit, picocolors, isExternalUrl, isProduction, parseUrl, withBase } from "../../../1965.js";
1
+ import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
+ import "../../../8006.js";
3
+ import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withBase } from "../../../3425.js";
2
4
  import { hintRelativeMarkdownLink } from "../../logger/hint.js";
3
5
  import { createError } from "../../utils/error.js";
6
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
7
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
4
8
  function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
5
9
  const errorInfos = [];
6
10
  const excludes = 'object' == typeof checkDeadLinks ? checkDeadLinks.excludes : void 0;
@@ -20,8 +24,8 @@ function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
20
24
  });
21
25
  if (errorInfos.length > 0) {
22
26
  if (possibleBreakingChange) hintRelativeMarkdownLink();
23
- const message = `Dead links found${lint ? '' : ` in ${picocolors.cyan(file.path)}`}:
24
- ${errorInfos.map(([nodeUrl, link])=>` ${picocolors.green(`"[..](${nodeUrl})"`)} ${picocolors.gray(link)}`).join('\n')}`;
27
+ const message = `Dead links found${lint ? '' : ` in ${picocolors_default().cyan(file.path)}`}:
28
+ ${errorInfos.map(([nodeUrl, link])=>` ${picocolors_default().green(`"[..](${nodeUrl})"`)} ${picocolors_default().gray(link)}`).join('\n')}`;
25
29
  if (lint) file.message(message);
26
30
  else {
27
31
  logger.error(message);
@@ -1,4 +1,4 @@
1
- import { github_slugger, visitChildren, extractTextAndId } from "../../../1361.js";
1
+ import { github_slugger, visitChildren, extractTextAndId } from "../../../3294.js";
2
2
  const extractChildText = (child)=>{
3
3
  if ('link' === child.type) return child.children?.map(extractChildText).join('') ?? '';
4
4
  if ('strong' === child.type) return `**${child.children?.map(extractChildText).join('') ?? ''}**`;
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../7319.js";
1
+ import { node_path } from "../../2287.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 "../../7319.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../2287.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 "../../7319.js";
1
+ import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../2287.js";
2
2
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
3
3
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
4
4
  import { importStatementRegex } from "../constants.js";
@@ -14,17 +14,9 @@ const remarkRemoveCodeBlocks = ()=>(tree)=>{
14
14
  const remarkRemoveImages = ()=>(tree)=>{
15
15
  remove(tree, 'image');
16
16
  };
17
- const remarkStripLinkUrls = ()=>(tree)=>{
18
- visit(tree, 'link', (node)=>{
19
- node.url = '';
20
- });
21
- };
22
- const createProcessor = (searchCodeBlocks)=>unified().use(remark_parse).use(remark_gfm).use(remarkRemoveImages).use(remarkStripLinkUrls).use(searchCodeBlocks ? [] : [
17
+ const createProcessor = (searchCodeBlocks)=>unified().use(remark_parse).use(remark_gfm).use(remarkRemoveImages).use(searchCodeBlocks ? [] : [
23
18
  remarkRemoveCodeBlocks
24
- ]).use(remark_stringify, {
25
- bullet: '-',
26
- listItemIndent: 'one'
27
- });
19
+ ]);
28
20
  const processorWithCode = createProcessor(true);
29
21
  const processorWithoutCode = createProcessor(false);
30
22
  function extractTextFromNode(node) {
@@ -32,6 +24,77 @@ function extractTextFromNode(node) {
32
24
  if ('children' in node && Array.isArray(node.children)) return node.children.map(extractTextFromNode).join('');
33
25
  return '';
34
26
  }
27
+ const SEARCH_SKIP_TYPES = new Set([
28
+ 'image',
29
+ 'imageReference',
30
+ 'definition',
31
+ 'footnoteDefinition',
32
+ 'footnoteReference',
33
+ 'html',
34
+ 'thematicBreak',
35
+ 'mdxJsxFlowElement',
36
+ 'mdxJsxTextElement',
37
+ 'mdxFlowExpression',
38
+ 'mdxTextExpression',
39
+ 'mdxjsEsm'
40
+ ]);
41
+ const SEARCH_BLOCK_TYPES = new Set([
42
+ 'paragraph',
43
+ 'heading',
44
+ 'listItem',
45
+ 'tableRow'
46
+ ]);
47
+ function extractSearchText(node, codeblocks) {
48
+ const { type } = node;
49
+ if (SEARCH_SKIP_TYPES.has(type)) return [];
50
+ if ('code' === type && !codeblocks) return [];
51
+ if ('break' === type) return [
52
+ '\n'
53
+ ];
54
+ if ('text' === type || 'inlineCode' === type) return [
55
+ node.value
56
+ ];
57
+ if ('code' === type) return [
58
+ `\n${node.value}\n`
59
+ ];
60
+ const result = [];
61
+ if ('children' in node) for (const child of node.children)result.push(...extractSearchText(child, codeblocks));
62
+ if (SEARCH_BLOCK_TYPES.has(type)) result.push('\n');
63
+ if ('tableCell' === type) result.push('\t');
64
+ return result;
65
+ }
66
+ function buildSearchContent(tree, rawToc, codeblocks) {
67
+ const parts = [];
68
+ const headingCharIndexes = [];
69
+ let tocIndex = 0;
70
+ let contentLength = 0;
71
+ let skippedFirstH1 = false;
72
+ for (const node of tree.children){
73
+ if ('heading' === node.type && 1 === node.depth && !skippedFirstH1) {
74
+ skippedFirstH1 = true;
75
+ continue;
76
+ }
77
+ const text = extractSearchText(node, codeblocks).join('').replaceAll('\t\n', '\n').trim();
78
+ if (text) {
79
+ if (parts.length > 0) contentLength += 2;
80
+ if ('heading' === node.type && node.depth >= 2 && node.depth < 5) {
81
+ if (tocIndex < rawToc.length) {
82
+ headingCharIndexes.push(contentLength);
83
+ tocIndex++;
84
+ }
85
+ }
86
+ contentLength += text.length;
87
+ parts.push(text);
88
+ }
89
+ }
90
+ return {
91
+ content: parts.join('\n\n'),
92
+ toc: rawToc.map((item, index)=>({
93
+ ...item,
94
+ charIndex: index < headingCharIndexes.length ? headingCharIndexes[index] : -1
95
+ }))
96
+ };
97
+ }
35
98
  const SKIP_NODE_TYPES = new Set([
36
99
  'code',
37
100
  'html',
@@ -121,21 +184,7 @@ async function getPageIndexInfoByRoute(route, options) {
121
184
  }
122
185
  };
123
186
  const processedTree = await processor.run(tree);
124
- let processedContent = String(processor.stringify(processedTree));
125
- if (processedContent.startsWith(`# ${title}`)) processedContent = processedContent.slice(`# ${title}`.length).trimStart();
126
- const toc = rawToc.map((item)=>{
127
- const match = item.id.match(/-(\d+)$/);
128
- const headingPrefix = '#'.repeat(item.depth);
129
- let position = -1;
130
- if (match) for(let i = 0; i < Number(match[1]); i++){
131
- position = processedContent.indexOf(`${headingPrefix} ${item.text}`, position + 1);
132
- if (-1 === position) break;
133
- }
134
- return {
135
- ...item,
136
- charIndex: processedContent.indexOf(`${headingPrefix} ${item.text}`, position + 1)
137
- };
138
- });
187
+ const { content: processedContent, toc } = buildSearchContent(processedTree, rawToc, searchCodeBlocks);
139
188
  return {
140
189
  ...defaultIndexInfo,
141
190
  title: frontmatter.title || title,
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../7319.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../2287.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,8 +1,12 @@
1
- import { logger, createRequire, join, picocolors } from "../../7319.js";
1
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
+ import "../../8006.js";
3
+ import { external_node_module_createRequire, join, logger } from "../../2287.js";
2
4
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
3
5
  import { createError } from "../utils/error.js";
4
6
  import { pathExists } from "../utils/fs.js";
5
- const i18n_require = createRequire(import.meta.url);
7
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
8
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
9
+ const i18n_require = external_node_module_createRequire(import.meta.url);
6
10
  const DEFAULT_I18N_SOURCE_PATH = join(process.cwd(), 'i18n.json');
7
11
  function mergeI18nData(...sources) {
8
12
  const result = {};
@@ -39,7 +43,7 @@ async function getI18nData(docConfig, pluginDriver) {
39
43
  throw e;
40
44
  }
41
45
  else i18nSourceFull = mergeI18nData(i18nSourceFull, i18nSource);
42
- const cyan = picocolors.cyan;
46
+ const cyan = picocolors_default().cyan;
43
47
  const filteredI18nSource = {};
44
48
  for(const key in i18nSourceFull){
45
49
  filteredI18nSource[key] = {};
@@ -50,19 +54,19 @@ async function getI18nData(docConfig, pluginDriver) {
50
54
  if (enText) filteredI18nSource[key][lang] = enText;
51
55
  else {
52
56
  logger.error(`${logPrefix} i18n key ${cyan(key)} has no text for lang ${cyan(lang)}, and no fallback ${cyan('en')} text either.`);
53
- throw createError(`i18n text missing for ${picocolors.cyan(key)}`);
57
+ throw createError(`i18n text missing for ${picocolors_default().cyan(key)}`);
54
58
  }
55
59
  }
56
60
  }
57
61
  if (logKeys.size > 0 && !logged) {
58
62
  logger.warn(`${logPrefix} The following i18n keys are missing for some languages and have fallen back to 'en':
59
- ${picocolors.gray(JSON.stringify(Object.fromEntries([
63
+ ${picocolors_default().gray(JSON.stringify(Object.fromEntries([
60
64
  ...logKeys.keys()
61
65
  ].map((i)=>[
62
66
  i,
63
67
  '...'
64
68
  ])), null, 2))}
65
- You can provide translations via ${picocolors.cyan('i18n.json')} file or ${picocolors.cyan('i18nSource')} config in rspress.config.ts`);
69
+ You can provide translations via ${picocolors_default().cyan('i18n.json')} file or ${picocolors_default().cyan('i18nSource')} config in rspress.config.ts`);
66
70
  logged = true;
67
71
  }
68
72
  return filteredI18nSource;
@@ -1,4 +1,4 @@
1
- import { SEARCH_INDEX_NAME, groupBy } from "../../../7319.js";
1
+ import { SEARCH_INDEX_NAME, groupBy } from "../../../2287.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 "../../../7319.js";
1
+ import { logger, pluginVirtualModule } from "../../../2287.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 "../../7319.js";
1
+ import { node_path } from "../../2287.js";
2
2
  const searchHookVMPlugin = (context)=>({
3
3
  ["virtual-search-hooks"]: ()=>{
4
4
  const { config } = context;
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../7319.js";
1
+ import { getIconUrlPath } from "../../../2287.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 "../../../7319.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../2287.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 "../../../7319.js";
1
+ import { logger } from "../../../2287.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 "../7319.js";
1
+ import { mergeRsbuildConfig } from "../2287.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,6 +1,10 @@
1
- import { createHead, logger, transformHtmlTemplate, pathToFileURL, picocolors } from "../../8311.js";
1
+ import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
+ import "../../8006.js";
3
+ import { createHead, logger, transformHtmlTemplate, pathToFileURL } from "../../1688.js";
2
4
  import { hintSSGFailed } from "../logger/hint.js";
3
5
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
6
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
7
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
4
8
  async function renderPage(route, htmlTemplate, configHead, ssrBundlePath) {
5
9
  let render;
6
10
  try {
@@ -9,7 +13,7 @@ async function renderPage(route, htmlTemplate, configHead, ssrBundlePath) {
9
13
  render = ssrExports.render;
10
14
  } catch (e) {
11
15
  if (e instanceof Error) {
12
- logger.error(`Failed to load SSG bundle: ${picocolors.yellow(ssrBundlePath)}: ${e.message}`);
16
+ logger.error(`Failed to load SSG bundle: ${picocolors_default().yellow(ssrBundlePath)}: ${e.message}`);
13
17
  logger.debug(e);
14
18
  hintSSGFailed();
15
19
  }
@@ -22,8 +26,8 @@ async function renderPage(route, htmlTemplate, configHead, ssrBundlePath) {
22
26
  ({ appHtml } = await render(routePath, head));
23
27
  } catch (e) {
24
28
  if (e instanceof Error) {
25
- logger.error(`Page "${picocolors.yellow(routePath)}" SSG rendering failed.
26
- ${absolutePath ? picocolors.gray(` File: ${absolutePath}\n`) : ''} ${picocolors.gray(e.toString())}`);
29
+ logger.error(`Page "${picocolors_default().yellow(routePath)}" SSG rendering failed.
30
+ ${absolutePath ? picocolors_default().gray(` File: ${absolutePath}\n`) : ''} ${picocolors_default().gray(e.toString())}`);
27
31
  throw e;
28
32
  }
29
33
  }
@@ -1,6 +1,6 @@
1
1
  import { workerData } from "../../9224.js";
2
2
  import { createError } from "../utils/error.js";
3
- import { pMap } from "../../8311.js";
3
+ import { pMap } from "../../1688.js";
4
4
  import { renderPage } from "./renderPage.js";
5
5
  const params = workerData?.[1]?.params;
6
6
  if (!params) throw createError('SSG Worker Thread workerData params missing');