@rspress/core 2.0.0-rc.2 → 2.0.0-rc.3

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 (122) hide show
  1. package/dist/{0~7675.989ee664.js → 0~7675.723d12b2.js} +17 -14
  2. package/dist/{5313.6594aba0.js → 3521.56e42d70.js} +0 -7
  3. package/dist/{5485.2a0273cf.js → 5485.077f14ff.js} +1 -1
  4. package/dist/{7805.cadab34e.js → 9643.f109822d.js} +2 -1
  5. package/dist/_private/react/render.js +17 -4
  6. package/dist/cli/config/loadConfigFile.js +1 -1
  7. package/dist/cli/index.js +1 -1
  8. package/dist/eject-theme/components/Badge/index.scss +1 -0
  9. package/dist/eject-theme/components/Banner/index.tsx +3 -1
  10. package/dist/eject-theme/components/Callout/index.tsx +8 -2
  11. package/dist/eject-theme/components/CodeBlock/index.scss +8 -6
  12. package/dist/eject-theme/components/CodeBlock/index.tsx +4 -0
  13. package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
  14. package/dist/eject-theme/components/DocContent/doc.scss +1 -1
  15. package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
  16. package/dist/eject-theme/components/DocContent/index.tsx +21 -4
  17. package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
  18. package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
  19. package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
  20. package/dist/eject-theme/components/Link/index.tsx +9 -2
  21. package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
  22. package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
  23. package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
  24. package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
  25. package/dist/eject-theme/components/Overview/index.tsx +1 -6
  26. package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
  27. package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +50 -3
  28. package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
  29. package/dist/eject-theme/components/Tabs/index.scss +12 -4
  30. package/dist/eject-theme/components/Tabs/index.tsx +16 -0
  31. package/dist/eject-theme/components/Tag/index.tsx +84 -5
  32. package/dist/index.js +2 -2
  33. package/dist/node/PluginDriver.js +3 -4
  34. package/dist/node/auto-nav-sidebar/index.js +1 -1
  35. package/dist/node/auto-nav-sidebar/normalize.js +11 -9
  36. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  37. package/dist/node/constants.d.ts +1 -0
  38. package/dist/node/constants.js +3 -2
  39. package/dist/node/eject.js +5 -5
  40. package/dist/node/initRsbuild.js +14 -6
  41. package/dist/node/last-updated/index.js +1 -1
  42. package/dist/node/mdx/loader.js +2 -1
  43. package/dist/node/mdx/options.js +7 -4
  44. package/dist/node/mdx/processor.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  46. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -1
  47. package/dist/node/mdx/remarkPlugins/image.js +1 -1
  48. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  49. package/dist/node/route/RouteService.js +1 -1
  50. package/dist/node/route/extractPageData.js +2 -2
  51. package/dist/node/route/normalizeRoutePath.js +1 -1
  52. package/dist/node/runtimeModule/i18n.js +1 -1
  53. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  54. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  55. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  56. package/dist/node/serve.js +1 -1
  57. package/dist/node/ssg/renderPage.js +1 -1
  58. package/dist/node/ssg/renderPageWorker.js +1 -1
  59. package/dist/node/ssg/renderPages.js +2 -2
  60. package/dist/node/ssg/ssgEnv.js +1 -1
  61. package/dist/node/ssg-md/llms/emitLlmsTxt.js +6 -2
  62. package/dist/node/ssg-md/remarkSplitMdx.js +140 -98
  63. package/dist/node/ssg-md/renderPage.js +1 -1
  64. package/dist/node/ssg-md/renderPages.js +1 -1
  65. package/dist/node/utils/createHash.js +1 -1
  66. package/dist/node/utils/error.js +2 -1
  67. package/dist/node/utils/flattenMdxContent.js +2 -2
  68. package/dist/node/utils/normalizePath.js +1 -1
  69. package/dist/node/utils/reactAlias.js +1 -1
  70. package/dist/runtime/initPageData.js +1 -1
  71. package/dist/theme/assets/deprecated.js +18 -0
  72. package/dist/theme/assets/experimental.js +21 -0
  73. package/dist/theme/components/Badge/index.css +1 -0
  74. package/dist/theme/components/Banner/index.js +2 -2
  75. package/dist/theme/components/Callout/index.js +5 -2
  76. package/dist/theme/components/CodeBlock/index.css +7 -6
  77. package/dist/theme/components/CodeBlock/index.js +4 -1
  78. package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
  79. package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
  80. package/dist/theme/components/DocContent/doc.css +1 -1
  81. package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
  82. package/dist/theme/components/DocContent/index.d.ts +11 -2
  83. package/dist/theme/components/DocContent/index.js +6 -5
  84. package/dist/theme/components/DocFooter/index.js +1 -5
  85. package/dist/theme/components/HoverGroup/index.css +3 -3
  86. package/dist/theme/components/LastUpdated/index.d.ts +1 -1
  87. package/dist/theme/components/LastUpdated/index.js +5 -1
  88. package/dist/theme/components/Link/index.d.ts +1 -1
  89. package/dist/theme/components/Link/index.js +8 -2
  90. package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
  91. package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
  92. package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
  93. package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
  94. package/dist/theme/components/Overview/index.d.ts +0 -1
  95. package/dist/theme/components/Overview/index.js +1 -1
  96. package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
  97. package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
  98. package/dist/theme/components/OverviewGroup/index.js +88 -0
  99. package/dist/theme/components/Search/logic/util.test.js +1 -1
  100. package/dist/theme/components/Tabs/index.css +6 -5
  101. package/dist/theme/components/Tabs/index.js +9 -0
  102. package/dist/theme/components/Tag/index.d.ts +3 -0
  103. package/dist/theme/components/Tag/index.js +63 -8
  104. package/dist/theme/hooks/useActiveAnchor.js +1 -1
  105. package/dist/theme/icons.d.ts +26 -24
  106. package/dist/theme/icons.js +5 -1
  107. package/dist/theme/index.d.ts +3 -1
  108. package/dist/theme/index.js +4 -2
  109. package/dist/theme/layout/DocLayout/index.css +0 -2
  110. package/dist/theme/layout/Layout/index.js +1 -2
  111. package/dist/theme/layout/NotFountLayout/index.js +1 -1
  112. package/dist/theme/logic/useAppearance.js +1 -1
  113. package/dist/theme/logic/useMediaQuery.js +1 -1
  114. package/dist/theme/styles/base.css +1 -0
  115. package/dist/theme/styles/shiki.css +9 -3
  116. package/dist/theme/styles/vars/base-vars.css +2 -2
  117. package/dist/theme/styles/vars/code-vars.css +2 -0
  118. package/package.json +14 -14
  119. package/dist/1218.3869bad6.js +0 -2
  120. package/dist/theme/components/Overview/OverviewGroup.js +0 -57
  121. /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
  122. /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
@@ -1,6 +1,7 @@
1
- import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.2a0273cf.js";
1
+ import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.077f14ff.js";
2
2
  import { node_path } from "../6289.c67fe0d5.js";
3
- import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../5313.6594aba0.js";
3
+ import { cwd } from "../9643.f109822d.js";
4
+ import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../3521.56e42d70.js";
4
5
  import { removeTrailingSlash, MDX_OR_MD_REGEXP } from "../4669.12208c6a.js";
5
6
  import { createError } from "./utils/error.js";
6
7
  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";
@@ -31,7 +32,7 @@ async function getVirtualModulesFromPlugins(pluginDriver) {
31
32
  return runtimeModule;
32
33
  }
33
34
  async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
34
- const CUSTOM_THEME_DIR = config.themeDir;
35
+ const CUSTOM_THEME_DIR = node_path.isAbsolute(config.themeDir) ? config.themeDir : node_path.join(cwd(), config.themeDir);
35
36
  const outDir = config?.outDir ?? OUTPUT_DIR;
36
37
  const base = config?.base ?? '';
37
38
  const assetPrefix = isProduction() ? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : '';
@@ -217,7 +218,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
217
218
  return options;
218
219
  });
219
220
  chain.resolve.extensions.prepend('.md').prepend('.mdx').prepend('.mjs');
220
- chain.module.rule('css-virtual-module').test(/\.rspress[\\/]runtime[\\/]virtual-global-styles/).merge({
221
+ chain.module.rule('rspress-css-virtual-module').test(/\.rspress[\\/]runtime[\\/]virtual-global-styles/).merge({
221
222
  sideEffects: true
222
223
  });
223
224
  if (isSsg || isSsgMd) chain.optimization.splitChunks({});
@@ -252,6 +253,14 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
252
253
  distPath: {
253
254
  root: outDir
254
255
  }
256
+ },
257
+ tools: {
258
+ rspack: {
259
+ node: {
260
+ __dirname: 'mock',
261
+ __filename: 'mock'
262
+ }
263
+ }
255
264
  }
256
265
  },
257
266
  ...enableSSG && config.ssg ? {
@@ -324,8 +333,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
324
333
  };
325
334
  }
326
335
  async function initRsbuild(rootDir, config, pluginDriver, routeService, enableSSG, extraRsbuildConfig) {
327
- const cwd = process.cwd();
328
- const userDocRoot = node_path.resolve(rootDir || config?.root || cwd);
336
+ const userDocRoot = node_path.resolve(rootDir || config.root);
329
337
  hintBuilderPluginsBreakingChange(config);
330
338
  const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
331
339
  const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver);
@@ -1,4 +1,4 @@
1
- import { execa } from "../../0~7675.989ee664.js";
1
+ import { execa } from "../../0~7675.723d12b2.js";
2
2
  function transform(timestamp, lang) {
3
3
  return new Date(timestamp).toLocaleString(lang || 'zh');
4
4
  }
@@ -14,7 +14,8 @@ async function mdxLoader(source) {
14
14
  docDirectory,
15
15
  config,
16
16
  pluginDriver,
17
- routeService
17
+ routeService,
18
+ addDependency: this.addDependency
18
19
  });
19
20
  callback(null, compileResult);
20
21
  } else {
@@ -1,5 +1,5 @@
1
1
  import { node_path } from "../../6289.c67fe0d5.js";
2
- import { nodeTypes } from "../../7805.cadab34e.js";
2
+ import { nodeTypes } from "../../9643.f109822d.js";
3
3
  import { rehype_external_links, rehype_raw, remark_gfm, rehype } from "./loader.e1578c62.js";
4
4
  import { remarkToc } from "./remarkPlugins/toc.js";
5
5
  import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
@@ -46,7 +46,8 @@ async function createMDXOptions(options) {
46
46
  remarkLinkOptions: {
47
47
  checkDeadLinks: false,
48
48
  autoPrefix: true
49
- }
49
+ },
50
+ __base: config?.base
50
51
  } : {
51
52
  cleanUrls: false,
52
53
  root: docDirectory,
@@ -65,8 +66,10 @@ async function createMDXOptions(options) {
65
66
  globalComponents
66
67
  }
67
68
  ],
68
- ...remarkPluginsFromConfig,
69
- ...remarkPluginsFromPlugins
69
+ ...isSsgMd ? [] : [
70
+ ...remarkPluginsFromConfig,
71
+ ...remarkPluginsFromPlugins
72
+ ]
70
73
  ].filter(Boolean),
71
74
  ...isSsgMd ? {} : {
72
75
  rehypePlugins: [
@@ -1,5 +1,5 @@
1
1
  import { node_path } from "../../6289.c67fe0d5.js";
2
- import { createProcessor, loadFrontMatter, extractTextAndId } from "../../7805.cadab34e.js";
2
+ import { createProcessor, loadFrontMatter, extractTextAndId } from "../../9643.f109822d.js";
3
3
  import { createMDXOptions } from "./options.js";
4
4
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
5
5
  import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
@@ -1,4 +1,4 @@
1
- import { extractTextAndId } from "../../../7805.cadab34e.js";
1
+ import { extractTextAndId } from "../../../9643.f109822d.js";
2
2
  import { github_slugger, headingRank } from "../loader.e1578c62.js";
3
3
  import { visit } from "../../../8813.9da1f210.js";
4
4
  const rehypeHeaderAnchor = ()=>{
@@ -1,5 +1,5 @@
1
1
  import { node_path, logger, picocolors, readFile } from "../../../6289.c67fe0d5.js";
2
- import { cwd } from "../../../1218.3869bad6.js";
2
+ import { cwd } from "../../../9643.f109822d.js";
3
3
  import { visit } from "../../../8813.9da1f210.js";
4
4
  import { createError } from "../../utils/error.js";
5
5
  const ERROR_PREFIX = '[remarkFileCodeBlock]';
@@ -1,5 +1,5 @@
1
1
  import { isExternalUrl } from "../../../4669.12208c6a.js";
2
- import { getNodeAttribute } from "../../../7805.cadab34e.js";
2
+ import { getNodeAttribute } from "../../../9643.f109822d.js";
3
3
  import { visit } from "../../../8813.9da1f210.js";
4
4
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
5
5
  const normalizeImageUrl = (imageUrl)=>{
@@ -1,4 +1,4 @@
1
- import { extractTextAndId } from "../../../7805.cadab34e.js";
1
+ import { extractTextAndId } from "../../../9643.f109822d.js";
2
2
  import { github_slugger, visitChildren } from "../loader.e1578c62.js";
3
3
  const parseToc = (tree)=>{
4
4
  let title = '';
@@ -1,6 +1,6 @@
1
1
  import { node_path, promises } from "../../6289.c67fe0d5.js";
2
2
  import { RSPRESS_TEMP_DIR, removeTrailingSlash, addTrailingSlash } from "../../4669.12208c6a.js";
3
- import { DEFAULT_PAGE_EXTENSIONS, glob } from "../../5313.6594aba0.js";
3
+ import { DEFAULT_PAGE_EXTENSIONS, glob } from "../../3521.56e42d70.js";
4
4
  import { PUBLIC_DIR } from "../constants.js";
5
5
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
6
6
  import { createError } from "../utils/error.js";
@@ -1,7 +1,7 @@
1
1
  import { node_path, promises } from "../../6289.c67fe0d5.js";
2
- import { htmlToText, compile } from "../../5313.6594aba0.js";
2
+ import { htmlToText, compile } from "../../3521.56e42d70.js";
3
3
  import { MDX_OR_MD_REGEXP } from "../../4669.12208c6a.js";
4
- import { loadFrontMatter } from "../../7805.cadab34e.js";
4
+ import { loadFrontMatter } from "../../9643.f109822d.js";
5
5
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
6
6
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
7
7
  import { importStatementRegex } from "../constants.js";
@@ -1,5 +1,5 @@
1
1
  import { addTrailingSlash, addLeadingSlash } from "../../4669.12208c6a.js";
2
- import { DEFAULT_PAGE_EXTENSIONS } from "../../5313.6594aba0.js";
2
+ import { DEFAULT_PAGE_EXTENSIONS } from "../../3521.56e42d70.js";
3
3
  const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
4
4
  const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
5
5
  return [
@@ -1,4 +1,4 @@
1
- import { createRequire } from "../../5485.2a0273cf.js";
1
+ import { createRequire } from "../../5485.077f14ff.js";
2
2
  import { picocolors, join, logger } from "../../6289.c67fe0d5.js";
3
3
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
4
4
  import { createError } from "../utils/error.js";
@@ -1,5 +1,5 @@
1
1
  import { SEARCH_INDEX_NAME } from "../../../4669.12208c6a.js";
2
- import { groupBy } from "../../../5313.6594aba0.js";
2
+ import { groupBy } from "../../../3521.56e42d70.js";
3
3
  import { extractPageData } from "../../route/extractPageData.js";
4
4
  import { createHash } from "../../utils/createHash.js";
5
5
  function deletePrivateField(obj) {
@@ -1,4 +1,4 @@
1
- import { pluginVirtualModule } from "../../../5313.6594aba0.js";
1
+ import { pluginVirtualModule } from "../../../3521.56e42d70.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 { getIconUrlPath } from "../../../7805.cadab34e.js";
1
+ import { getIconUrlPath } from "../../../9643.f109822d.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 { mergeRsbuildConfig } from "../5313.6594aba0.js";
1
+ import { mergeRsbuildConfig } from "../3521.56e42d70.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,4 +1,4 @@
1
- import { transformHtmlTemplate, pathToFileURL, createHead } from "../../5485.2a0273cf.js";
1
+ import { transformHtmlTemplate, pathToFileURL, createHead } from "../../5485.077f14ff.js";
2
2
  import { logger, picocolors } from "../../6289.c67fe0d5.js";
3
3
  import { hintSSGFailed } from "../logger/hint.js";
4
4
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -1,6 +1,6 @@
1
1
  import { workerData } from "./renderPageWorker.474f9f73.js";
2
2
  import { createError } from "../utils/error.js";
3
- import { pMap } from "../../5485.2a0273cf.js";
3
+ import { pMap } from "../../5485.077f14ff.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');
@@ -1,8 +1,8 @@
1
1
  /*! For license information please see renderPages.js.LICENSE.txt */
2
2
  import { logger, picocolors } from "../../6289.c67fe0d5.js";
3
- import { chunk } from "../../5313.6594aba0.js";
3
+ import { chunk } from "../../3521.56e42d70.js";
4
4
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
5
- import { pMap } from "../../5485.2a0273cf.js";
5
+ import { pMap } from "../../5485.077f14ff.js";
6
6
  import { renderPage } from "./renderPage.js";
7
7
  import { hintSSGFailed } from "../logger/hint.js";
8
8
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -1,5 +1,5 @@
1
1
  /*! For license information please see ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../7805.cadab34e.js";
2
+ import { node_os } from "../../9643.f109822d.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,5 +1,5 @@
1
1
  import { getSidebarDataGroup } from "../../../4669.12208c6a.js";
2
- import { matchPath } from "../../../5313.6594aba0.js";
2
+ import { matchPath } from "../../../3521.56e42d70.js";
3
3
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
4
4
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
5
5
  const base = config.base ?? '/';
@@ -30,7 +30,11 @@ async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
30
30
  }));
31
31
  }).flat().filter((i)=>i.activeMatch || i.link) : [];
32
32
  const defaultLang = routeService.getDefaultLang();
33
- await Promise.all(routeService.getLangs().map(async (lang)=>{
33
+ const langs = new Set([
34
+ defaultLang,
35
+ ...routeService.getLangs()
36
+ ]);
37
+ await Promise.all(langs.values().map(async (lang)=>{
34
38
  const navList = noVersionNav.filter((i)=>i.lang === lang);
35
39
  const routeGroups = new Array(navList.length).fill(0).map(()=>[]);
36
40
  const others = [];
@@ -1,18 +1,14 @@
1
1
  import { unified, remark_gfm, remark_mdx, remark_stringify } from "../mdx/loader.e1578c62.js";
2
+ import { visit } from "../../8813.9da1f210.js";
2
3
  function remarkSplitMdx(options = {}) {
3
4
  return (tree)=>{
4
5
  const newChildren = [];
5
- const importMap = buildImportMap(tree);
6
+ const { importMap, importNodes } = buildImportMap(tree);
7
+ newChildren.push(...importNodes);
6
8
  for (const node of tree.children){
7
- if ('mdxjsEsm' === node.type) {
8
- newChildren.push(node);
9
- continue;
10
- }
9
+ if ('mdxjsEsm' === node.type) continue;
11
10
  if ('mdxJsxFlowElement' === node.type || 'mdxJsxTextElement' === node.type) {
12
- const componentName = node.name;
13
- const shouldKeep = shouldKeepJsxElement(componentName, importMap, options);
14
- if (shouldKeep) newChildren.push(node);
15
- else newChildren.push(buildMdxFlowExpressionFragment(node));
11
+ newChildren.push(processJsxElement(node, importMap, options));
16
12
  continue;
17
13
  }
18
14
  const hasJsxChildren = node.children?.some((child)=>'mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type);
@@ -24,25 +20,54 @@ function remarkSplitMdx(options = {}) {
24
20
  attributes: [],
25
21
  children: processedChildren
26
22
  });
27
- } else {
28
- const fragment = buildMdxFlowExpressionFragment(node);
29
- newChildren.push(fragment);
30
- }
23
+ } else newChildren.push(buildMdxFlowExpressionFragment(node));
31
24
  }
32
25
  tree.children = newChildren;
33
26
  };
34
27
  }
28
+ function processJsxElement(node, importMap, options) {
29
+ const processedNode = processJsxChildren(node, importMap, options);
30
+ const componentName = getComponentName(node.name);
31
+ const isMdxFragment = componentName && importMap.get(componentName)?.endsWith('.mdx');
32
+ if (isMdxFragment || shouldKeepJsxElement(node.name, importMap, options)) return processedNode;
33
+ return buildMdxFlowExpressionFragment(processedNode);
34
+ }
35
+ function processJsxChildren(node, importMap, options) {
36
+ if (!node.children || 0 === node.children.length) return node;
37
+ const processedChildren = [];
38
+ let textBuffer = [];
39
+ const flushTextBuffer = ()=>{
40
+ if (0 === textBuffer.length) return;
41
+ const combined = textBuffer.map((child)=>serializeNodeToMarkdown(child)).join('');
42
+ if (combined) processedChildren.push(createTextExpression(combined));
43
+ textBuffer = [];
44
+ };
45
+ for (const child of node.children)if ('mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type) {
46
+ flushTextBuffer();
47
+ processedChildren.push(processJsxElement(child, importMap, options));
48
+ } else textBuffer.push(child);
49
+ flushTextBuffer();
50
+ return {
51
+ ...node,
52
+ children: processedChildren
53
+ };
54
+ }
55
+ function getComponentName(name) {
56
+ if (!name) return null;
57
+ if ('string' == typeof name) {
58
+ const dotIndex = name.indexOf('.');
59
+ if (dotIndex > 0) return name.substring(0, dotIndex);
60
+ return name;
61
+ }
62
+ if ('object' == typeof name) {
63
+ if ('mdxJsxMemberExpression' === name.type || 'mdxJsxNamespacedName' === name.type) return getComponentName(name.object);
64
+ }
65
+ return null;
66
+ }
35
67
  function processMixedContent(parentNode, children, importMap, options) {
36
68
  const result = [];
37
69
  let textBuffer = [];
38
- const getPrefix = ()=>{
39
- if ('heading' === parentNode.type) {
40
- const depth = parentNode.depth || 1;
41
- return `${'#'.repeat(depth)} `;
42
- }
43
- return '';
44
- };
45
- const prefix = getPrefix();
70
+ const prefix = 'heading' === parentNode.type ? `${'#'.repeat(parentNode.depth || 1)} ` : '';
46
71
  let prefixAdded = false;
47
72
  const flushTextBuffer = ()=>{
48
73
  if (textBuffer.length > 0) {
@@ -51,65 +76,16 @@ function processMixedContent(parentNode, children, importMap, options) {
51
76
  combined = prefix + combined;
52
77
  prefixAdded = true;
53
78
  }
54
- if (combined) {
55
- const stringified = JSON.stringify(combined);
56
- result.push({
57
- type: 'mdxTextExpression',
58
- value: stringified,
59
- data: {
60
- estree: {
61
- type: 'Program',
62
- body: [
63
- {
64
- type: 'ExpressionStatement',
65
- expression: {
66
- type: 'Literal',
67
- value: combined,
68
- raw: stringified
69
- }
70
- }
71
- ],
72
- sourceType: 'module'
73
- }
74
- }
75
- });
76
- }
79
+ if (combined) result.push(createTextExpression(combined));
77
80
  textBuffer = [];
78
81
  } else if (!prefixAdded && prefix) {
79
- const trimmedPrefix = prefix.trimEnd();
80
- const stringified = JSON.stringify(trimmedPrefix);
81
- result.push({
82
- type: 'mdxTextExpression',
83
- value: stringified,
84
- data: {
85
- estree: {
86
- type: 'Program',
87
- body: [
88
- {
89
- type: 'ExpressionStatement',
90
- expression: {
91
- type: 'Literal',
92
- value: trimmedPrefix,
93
- raw: stringified
94
- }
95
- }
96
- ],
97
- sourceType: 'module'
98
- }
99
- }
100
- });
82
+ result.push(createTextExpression(prefix.trimEnd()));
101
83
  prefixAdded = true;
102
84
  }
103
85
  };
104
86
  for (const child of children)if ('mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type) {
105
87
  flushTextBuffer();
106
- const componentName = child.name;
107
- const shouldKeep = shouldKeepJsxElement(componentName, importMap, options);
108
- if (shouldKeep) result.push(child);
109
- else {
110
- const fragment = buildMdxFlowExpressionFragment(child);
111
- result.push(fragment);
112
- }
88
+ result.push(processJsxElement(child, importMap, options));
113
89
  } else if ('text' === child.type) textBuffer.push(child.value || '');
114
90
  else {
115
91
  const serialized = serializeNodeToMarkdown(child);
@@ -119,6 +95,9 @@ function processMixedContent(parentNode, children, importMap, options) {
119
95
  return result;
120
96
  }
121
97
  function buildMdxFlowExpressionFragment(node) {
98
+ const children = node.children;
99
+ const hasJsxChildren = children?.some((child)=>'mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type || 'mdxFlowExpression' === child.type || 'mdxTextExpression' === child.type);
100
+ if (hasJsxChildren && ('mdxJsxFlowElement' === node.type || 'mdxJsxTextElement' === node.type)) return buildMixedContentFragment(node, children);
122
101
  const textContent = serializeNodeToMarkdown(node);
123
102
  const stringified = JSON.stringify(textContent);
124
103
  const fragment = {
@@ -143,11 +122,76 @@ function buildMdxFlowExpressionFragment(node) {
143
122
  };
144
123
  return fragment;
145
124
  }
125
+ function buildMixedContentFragment(node, children) {
126
+ const result = [];
127
+ const openingTag = serializeOpeningTag(node);
128
+ if (openingTag) result.push(createTextExpression(openingTag));
129
+ for (const child of children){
130
+ const isJsxOrExpression = 'mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type || 'mdxFlowExpression' === child.type || 'mdxTextExpression' === child.type;
131
+ if (isJsxOrExpression) result.push(child);
132
+ else {
133
+ const text = serializeNodeToMarkdown(child);
134
+ if (text) result.push(createTextExpression(text));
135
+ }
136
+ }
137
+ const closingTag = serializeClosingTag(node);
138
+ if (closingTag) result.push(createTextExpression(closingTag));
139
+ return {
140
+ type: 'mdxJsxFlowElement',
141
+ name: null,
142
+ attributes: [],
143
+ children: result
144
+ };
145
+ }
146
+ function createTextExpression(text) {
147
+ const stringified = JSON.stringify(text);
148
+ return {
149
+ type: 'mdxTextExpression',
150
+ value: stringified,
151
+ data: {
152
+ estree: {
153
+ type: 'Program',
154
+ body: [
155
+ {
156
+ type: 'ExpressionStatement',
157
+ expression: {
158
+ type: 'Literal',
159
+ value: text,
160
+ raw: stringified
161
+ }
162
+ }
163
+ ],
164
+ sourceType: 'module'
165
+ }
166
+ }
167
+ };
168
+ }
169
+ function serializeOpeningTag(node) {
170
+ const name = 'string' == typeof node.name ? node.name : '';
171
+ if (!name) return '';
172
+ const attrs = node.attributes?.map((attr)=>{
173
+ if ('mdxJsxAttribute' !== attr.type) return '';
174
+ const attrName = attr.name;
175
+ if (null === attr.value || void 0 === attr.value) return attrName;
176
+ if ('string' == typeof attr.value) return `${attrName}="${attr.value}"`;
177
+ if ('mdxJsxAttributeValueExpression' === attr.value.type) return `${attrName}={${attr.value.value || ''}}`;
178
+ return '';
179
+ }).filter(Boolean).join(' ');
180
+ return `<${name}${attrs ? ` ${attrs}` : ''}>`;
181
+ }
182
+ function serializeClosingTag(node) {
183
+ const name = 'string' == typeof node.name ? node.name : '';
184
+ if (!name) return '';
185
+ return `</${name}>`;
186
+ }
146
187
  const processor = unified().use(remark_mdx).use(remark_gfm).use(remark_stringify, {
147
188
  bullet: '-',
148
189
  emphasis: '_',
149
190
  fences: true,
150
- incrementListMarker: true
191
+ incrementListMarker: true,
192
+ handlers: {
193
+ mdxjsEsm: ()=>''
194
+ }
151
195
  });
152
196
  function serializeNodeToMarkdown(node) {
153
197
  const tempRoot = {
@@ -161,41 +205,39 @@ function serializeNodeToMarkdown(node) {
161
205
  }
162
206
  function buildImportMap(tree) {
163
207
  const importMap = new Map();
164
- for (const node of tree.children)if ('mdxjsEsm' === node.type && node.data?.estree) {
165
- const estree = node.data.estree;
166
- for (const statement of estree.body)if ('ImportDeclaration' === statement.type) {
208
+ const importNodes = new Set();
209
+ visit(tree, 'mdxjsEsm', (node)=>{
210
+ const estree = node.data?.estree;
211
+ if (!estree) return;
212
+ for (const statement of estree.body){
213
+ if ('ImportDeclaration' !== statement.type) continue;
167
214
  const source = statement.source.value;
168
215
  for (const specifier of statement.specifiers){
169
- let localName = null;
170
- if ('ImportDefaultSpecifier' === specifier.type) localName = specifier.local.name;
171
- else if ('ImportSpecifier' === specifier.type) localName = specifier.local.name;
172
- else if ('ImportNamespaceSpecifier' === specifier.type) localName = specifier.local.name;
173
- if (localName) importMap.set(localName, source);
216
+ const localName = specifier.local?.name;
217
+ if (localName) {
218
+ importMap.set(localName, source);
219
+ importNodes.add(node);
220
+ }
174
221
  }
175
222
  }
176
- }
177
- return importMap;
223
+ });
224
+ return {
225
+ importMap,
226
+ importNodes
227
+ };
178
228
  }
179
- function shouldKeepJsxElement(componentName, importMap, options) {
229
+ function shouldKeepJsxElement(nameField, importMap, options) {
230
+ const componentName = getComponentName(nameField);
180
231
  if (!componentName) return true;
181
232
  const { includes, excludes } = options;
182
- if (!includes && !excludes) return true;
183
233
  const importSource = importMap.get(componentName);
184
- if (importSource?.endsWith('.mdx')) return true;
234
+ if (!includes && !excludes) return true;
185
235
  if (excludes) {
186
- for (const [excludeSpecifiers, excludeSource] of excludes)if (excludeSpecifiers.includes(componentName)) {
187
- if (!importSource || importSource === excludeSource) return false;
188
- }
236
+ for (const [excludeSpecifiers, excludeSource] of excludes)if (excludeSpecifiers.includes(componentName) && (!importSource || importSource === excludeSource)) return false;
189
237
  }
190
238
  if (includes) {
191
- let matchesAnyRule = false;
192
- for (const [includeSpecifiers, includeSource] of includes)if (includeSpecifiers.includes(componentName)) {
193
- if (!importSource || importSource === includeSource) {
194
- matchesAnyRule = true;
195
- break;
196
- }
197
- }
198
- if (!matchesAnyRule) return false;
239
+ for (const [includeSpecifiers, includeSource] of includes)if (includeSpecifiers.includes(componentName) && (!importSource || importSource === includeSource)) return true;
240
+ return false;
199
241
  }
200
242
  return true;
201
243
  }
@@ -1,4 +1,4 @@
1
- import { pathToFileURL, createHead } from "../../5485.2a0273cf.js";
1
+ import { pathToFileURL, createHead } from "../../5485.077f14ff.js";
2
2
  import { logger, picocolors } from "../../6289.c67fe0d5.js";
3
3
  import { hintSSGFailed } from "../logger/hint.js";
4
4
  async function renderPage(route, ssrBundlePath) {
@@ -1,5 +1,5 @@
1
1
  import { logger, picocolors } from "../../6289.c67fe0d5.js";
2
- import { pMap } from "../../5485.2a0273cf.js";
2
+ import { pMap } from "../../5485.077f14ff.js";
3
3
  import { renderPage } from "./renderPage.js";
4
4
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
5
5
  const routePage2MdFilename = (routePath)=>{
@@ -1,4 +1,4 @@
1
- import { createHash as external_node_crypto_createHash } from "../../5313.6594aba0.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../3521.56e42d70.js";
2
2
  function createHash(str) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, 8);
4
4
  }
@@ -1,8 +1,9 @@
1
+ import { picocolors } from "../../6289.c67fe0d5.js";
1
2
  function createError(message, maxStackLines = 5) {
2
3
  const error = new Error(message);
3
4
  if (error.stack) {
4
5
  const lines = error.stack.split('\n');
5
- if (lines.length > maxStackLines + 1) error.stack = `${lines.slice(0, maxStackLines + 1).join('\n')}\n ... (truncated)`;
6
+ if (lines.length > maxStackLines + 1) error.stack = `${lines.slice(0, maxStackLines + 1).map((line)=>picocolors.gray(line)).join('\n')}\n ${picocolors.gray('... (truncated)')}`;
6
7
  }
7
8
  return error;
8
9
  }
@@ -1,6 +1,6 @@
1
- import { node_fs, core_rspack } from "../../5313.6594aba0.js";
1
+ import { node_fs, core_rspack } from "../../3521.56e42d70.js";
2
2
  import { node_path, logger } from "../../6289.c67fe0d5.js";
3
- import { createProcessor } from "../../7805.cadab34e.js";
3
+ import { createProcessor } from "../../9643.f109822d.js";
4
4
  import { MDX_OR_MD_REGEXP } from "../../4669.12208c6a.js";
5
5
  import { createError } from "./error.js";
6
6
  import { importStatementRegex } from "../constants.js";
@@ -1,4 +1,4 @@
1
- import { node_os } from "../../7805.cadab34e.js";
1
+ import { node_os } from "../../9643.f109822d.js";
2
2
  import { node_path } from "../../6289.c67fe0d5.js";
3
3
  const isWindows = 'win32' === node_os.platform();
4
4
  function slash(p) {
@@ -1,5 +1,5 @@
1
1
  import { node_path, logger, picocolors } from "../../6289.c67fe0d5.js";
2
- import { core_rspack } from "../../5313.6594aba0.js";
2
+ import { core_rspack } from "../../3521.56e42d70.js";
3
3
  import { pathExists, readJson } from "./fs.js";
4
4
  import { PACKAGE_ROOT } from "../constants.js";
5
5
  import { hintReactVersion } from "../logger/hint.js";