@rspress/core 2.0.21 → 2.0.23

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 (179) hide show
  1. package/bin/rspress.js +3 -1
  2. package/dist/{2711~0.js → a~0.js} +90 -70
  3. package/dist/{8472~0.js → b~0.js} +19 -14
  4. package/dist/cli/index.js +12 -13
  5. package/dist/config/loadConfigFile.d.ts +3 -4
  6. package/dist/config/loadConfigFile.js +13 -17
  7. package/dist/{7748~0.js → d~0.js} +0 -2
  8. package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +8 -0
  9. package/dist/eject-theme/components/Llms/LlmsHint.tsx +11 -3
  10. package/dist/eject-theme/components/Nav/NavMenu.scss +4 -0
  11. package/dist/eject-theme/components/Nav/NavMenu.tsx +20 -13
  12. package/dist/eject-theme/components/Nav/index.tsx +30 -4
  13. package/dist/eject-theme/components/NavHamburger/index.tsx +11 -3
  14. package/dist/eject-theme/components/NavList/context.ts +3 -0
  15. package/dist/eject-theme/components/NavList/index.tsx +24 -0
  16. package/dist/eject-theme/components/NavScreen/NavScreenMenu.test.tsx +59 -0
  17. package/dist/eject-theme/components/NavScreen/NavScreenMenu.tsx +43 -2
  18. package/dist/eject-theme/components/NavScreen/index.scss +0 -6
  19. package/dist/eject-theme/components/NavScreen/index.tsx +20 -3
  20. package/dist/eject-theme/components/ReadPercent/useReadPercent.ts +1 -1
  21. package/dist/eject-theme/components/Search/SearchButton.scss +1 -0
  22. package/dist/eject-theme/components/Search/SearchPanel.scss +51 -12
  23. package/dist/eject-theme/components/Search/SearchPanel.tsx +62 -216
  24. package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +39 -17
  25. package/dist/eject-theme/components/Search/useSearchPanel.ts +217 -0
  26. package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +2 -2
  27. package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
  28. package/dist/eject-theme/components/Steps/index.scss +1 -1
  29. package/dist/eject-theme/components/SwitchAppearance/getClipPath.test.ts +15 -0
  30. package/dist/eject-theme/components/SwitchAppearance/getClipPath.ts +26 -0
  31. package/dist/eject-theme/components/SwitchAppearance/index.tsx +22 -26
  32. package/dist/eject-theme/components/Tabs/index.tsx +14 -14
  33. package/dist/index.js +1 -1
  34. package/dist/node/PluginDriver.d.ts +1 -1
  35. package/dist/node/PluginDriver.js +5 -9
  36. package/dist/node/auto-nav-sidebar/index.js +1 -1
  37. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  38. package/dist/node/auto-nav-sidebar/normalize.js +6 -6
  39. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  40. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  41. package/dist/node/build.d.ts +3 -2
  42. package/dist/node/build.js +9 -3
  43. package/dist/node/constants.js +1 -1
  44. package/dist/node/dev.d.ts +4 -4
  45. package/dist/node/dev.js +8 -6
  46. package/dist/node/eject.js +5 -5
  47. package/dist/node/initRsbuild.d.ts +2 -3
  48. package/dist/node/initRsbuild.js +9 -7
  49. package/dist/node/last-updated/index.js +2 -2
  50. package/dist/node/logger/hint.js +4 -4
  51. package/dist/node/mdx/options.js +1 -1
  52. package/dist/node/mdx/processor.js +3 -3
  53. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  54. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  55. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  56. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  57. package/dist/node/mdx/remarkPlugins/containerSyntax.js +6 -5
  58. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +5 -5
  59. package/dist/node/mdx/remarkPlugins/image.js +5 -5
  60. package/dist/node/mdx/remarkPlugins/link.js +5 -5
  61. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  62. package/dist/node/medium-zoom/index.js +1 -1
  63. package/dist/node/route/RoutePage.js +6 -4
  64. package/dist/node/route/RouteService.js +3 -3
  65. package/dist/node/route/extractPageData.js +20 -7
  66. package/dist/node/route/normalizeRoutePath.js +1 -1
  67. package/dist/node/runtimeModule/i18n.js +5 -5
  68. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  69. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  70. package/dist/node/runtimeModule/searchHooks.js +1 -1
  71. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  72. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  73. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  74. package/dist/node/serve.d.ts +3 -3
  75. package/dist/node/serve.js +10 -4
  76. package/dist/node/ssg/alternateLinks.js +1 -1
  77. package/dist/node/ssg/htmlFile.js +1 -1
  78. package/dist/node/ssg/renderHtmlTemplate.js +4 -3
  79. package/dist/node/ssg/renderPage.js +5 -5
  80. package/dist/node/ssg/renderPageWorker.js +2 -2
  81. package/dist/node/ssg/renderPages.js +6 -6
  82. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  83. package/dist/node/ssg/ssgEnv.js +1 -1
  84. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  85. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  86. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  87. package/dist/node/ssg-md/renderPage.js +5 -5
  88. package/dist/node/ssg-md/renderPages.js +6 -6
  89. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  90. package/dist/node/utils/checkLanguageParity.js +5 -7
  91. package/dist/node/utils/createHash.js +1 -1
  92. package/dist/node/utils/error.js +4 -4
  93. package/dist/node/utils/flattenMdxContent.js +2 -2
  94. package/dist/node/utils/fs.js +1 -1
  95. package/dist/node/utils/getPageKey.js +1 -1
  96. package/dist/node/utils/index.d.ts +1 -1
  97. package/dist/node/utils/reactAlias.js +5 -5
  98. package/dist/node/utils/slash.d.ts +1 -0
  99. package/dist/node/utils/slash.js +4 -0
  100. package/dist/{864~0.js → n~0.js} +42 -41
  101. package/dist/rslib-runtime~0.js +27 -35
  102. package/dist/runtime/App.js +3 -2
  103. package/dist/runtime/hooks/createExternalStore.d.ts +4 -0
  104. package/dist/runtime/hooks/createExternalStore.js +20 -0
  105. package/dist/runtime/hooks/useGlobalComponents.d.ts +1 -0
  106. package/dist/runtime/hooks/useGlobalComponents.js +10 -0
  107. package/dist/runtime/hooks/useI18n.js +5 -3
  108. package/dist/runtime/hooks/useI18nText.d.ts +1 -0
  109. package/dist/runtime/hooks/useI18nText.js +10 -0
  110. package/dist/runtime/hooks/usePages.d.ts +2 -0
  111. package/dist/runtime/hooks/usePages.js +12 -3
  112. package/dist/runtime/hooks/useSearchHooks.d.ts +8 -0
  113. package/dist/runtime/hooks/useSearchHooks.js +14 -0
  114. package/dist/runtime/hooks/useSite.d.ts +1 -0
  115. package/dist/runtime/hooks/useSite.js +9 -2
  116. package/dist/runtime/index.d.ts +3 -1
  117. package/dist/runtime/index.js +5 -1
  118. package/dist/runtime/initPageData.js +10 -10
  119. package/dist/runtime/route.js +5 -5
  120. package/dist/runtime/utils.js +6 -6
  121. package/dist/theme/components/Link/useLinkNavigate.js +1 -1
  122. package/dist/theme/components/Llms/LlmsHint.js +23 -6
  123. package/dist/theme/components/Nav/NavMenu.css +4 -0
  124. package/dist/theme/components/Nav/NavMenu.d.ts +4 -2
  125. package/dist/theme/components/Nav/NavMenu.js +17 -9
  126. package/dist/theme/components/Nav/index.d.ts +7 -1
  127. package/dist/theme/components/Nav/index.js +13 -4
  128. package/dist/theme/components/NavHamburger/index.d.ts +2 -1
  129. package/dist/theme/components/NavHamburger/index.js +8 -2
  130. package/dist/theme/components/NavList/context.d.ts +1 -0
  131. package/dist/theme/components/NavList/context.js +3 -0
  132. package/dist/theme/components/NavList/index.d.ts +6 -0
  133. package/dist/theme/components/NavList/index.js +17 -0
  134. package/dist/theme/components/NavScreen/NavScreenMenu.d.ts +3 -2
  135. package/dist/theme/components/NavScreen/NavScreenMenu.js +42 -6
  136. package/dist/theme/components/NavScreen/index.css +0 -10
  137. package/dist/theme/components/NavScreen/index.d.ts +2 -1
  138. package/dist/theme/components/NavScreen/index.js +11 -3
  139. package/dist/theme/components/PackageManagerTabs/index.js +2 -2
  140. package/dist/theme/components/ReadPercent/useReadPercent.js +1 -0
  141. package/dist/theme/components/Search/SearchButton.css +1 -0
  142. package/dist/theme/components/Search/SearchPanel.css +47 -9
  143. package/dist/theme/components/Search/SearchPanel.js +104 -210
  144. package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +1 -0
  145. package/dist/theme/components/Search/logic/providers/LocalProvider.js +24 -14
  146. package/dist/theme/components/Search/logic/search.js +1 -1
  147. package/dist/theme/components/Search/useSearchPanel.d.ts +23 -0
  148. package/dist/theme/components/Search/useSearchPanel.js +155 -0
  149. package/dist/theme/components/SocialLinks/SocialLink.js +2 -2
  150. package/dist/theme/components/SourceCode/index.js +1 -1
  151. package/dist/theme/components/Steps/index.css +3 -3
  152. package/dist/theme/components/SwitchAppearance/getClipPath.d.ts +8 -0
  153. package/dist/theme/components/SwitchAppearance/getClipPath.js +13 -0
  154. package/dist/theme/components/SwitchAppearance/index.js +9 -7
  155. package/dist/theme/components/Tabs/index.js +4 -4
  156. package/dist/theme/components/Tag/index.js +2 -2
  157. package/dist/theme/index.d.ts +1 -0
  158. package/dist/theme/index.js +1 -0
  159. package/dist/theme/layout/DocLayout/index.js +2 -2
  160. package/dist/theme/layout/Layout/index.js +12 -4
  161. package/dist/theme/logic/useFullTextSearch.js +6 -1
  162. package/dist/theme/logic/utils.d.ts +0 -2
  163. package/dist/theme/logic/utils.js +56 -6
  164. package/dist/theme/styles/vars/shiki-vars.css +1 -1
  165. package/dist/tinypool~0.js +5 -3
  166. package/dist/{4538~0.js → t~0.js} +2 -2
  167. package/package.json +15 -16
  168. package/dist/eject-theme/components/NavScreen/NavScreenMenuOthers.tsx +0 -29
  169. package/dist/node/utils/normalizePath.d.ts +0 -3
  170. package/dist/node/utils/normalizePath.js +0 -10
  171. package/dist/theme/components/NavScreen/NavScreenMenuOthers.d.ts +0 -2
  172. package/dist/theme/components/NavScreen/NavScreenMenuOthers.js +0 -30
  173. package/dist/theme/logic/useHandler.d.ts +0 -6
  174. package/dist/theme/logic/useHandler.js +0 -7
  175. /package/dist/{9857~0.js → 4~0.js} +0 -0
  176. /package/dist/{8016~0.js → i~0.js} +0 -0
  177. /package/dist/{5357~0.js → r~0.js} +0 -0
  178. /package/dist/{102~0.js → t2~0.js} +0 -0
  179. /package/dist/{9940~0.js → tx~0.js} +0 -0
package/bin/rspress.js CHANGED
@@ -4,7 +4,9 @@ import nodeModule from 'node:module';
4
4
  // enable on-disk code caching of all modules loaded by Node.js
5
5
  // requires Nodejs >= 22.8.0
6
6
  const { enableCompileCache } = nodeModule;
7
- if (enableCompileCache) {
7
+ const isCI = Boolean(process.env.CI) && process.env.CI !== 'false';
8
+ // Skip CI, where the cache is unlikely to be reused.
9
+ if (enableCompileCache && !isCI) {
8
10
  try {
9
11
  enableCompileCache();
10
12
  } catch {
@@ -1,16 +1,14 @@
1
- import { __webpack_require__ } from "./rslib-runtime~0.js";
1
+ import { rspackRequire, moduleFactories } from "./rslib-runtime~0.js";
2
2
  import { fileURLToPath as external_url_fileURLToPath } from "url";
3
3
  import node_path, { extname, join, relative as external_node_path_relative } from "node:path";
4
4
  import { basename, dirname, isAbsolute, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
5
5
  import * as __rspack_external_fs from "fs";
6
6
  import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
7
7
  import { createRequire as external_module_createRequire } from "module";
8
- import { createRequire as __rspack_createRequire } from "node:module";
9
- const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
10
- __webpack_require__.add({
11
- "../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
12
- const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js");
13
- const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
8
+ moduleFactories.add({
9
+ "../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/index.js" (module) {
10
+ const pico = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/picomatch.js");
11
+ const utils = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js");
14
12
  function picomatch(glob, options, returnState = false) {
15
13
  if (options && (null === options.windows || void 0 === options.windows)) options = {
16
14
  ...options,
@@ -21,7 +19,7 @@ __webpack_require__.add({
21
19
  Object.assign(picomatch, pico);
22
20
  module.exports = picomatch;
23
21
  },
24
- "../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js" (module) {
22
+ "../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js" (module) {
25
23
  const WIN_SLASH = '\\\\/';
26
24
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
27
25
  const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
@@ -184,9 +182,9 @@ __webpack_require__.add({
184
182
  }
185
183
  };
186
184
  },
187
- "../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
188
- const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
189
- const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
185
+ "../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/parse.js" (module) {
186
+ const constants = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js");
187
+ const utils = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js");
190
188
  const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
191
189
  const expandRange = (args, options)=>{
192
190
  if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
@@ -330,7 +328,11 @@ __webpack_require__.add({
330
328
  }
331
329
  }
332
330
  };
333
- const getStarExtglobSequenceOutput = (pattern)=>{
331
+ const buildCharClassStar = (chars)=>{
332
+ const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
333
+ return `${source}*`;
334
+ };
335
+ const getStarExtglobSequenceChars = (pattern)=>{
334
336
  let index = 0;
335
337
  const chars = [];
336
338
  while(index < pattern.length){
@@ -344,8 +346,7 @@ __webpack_require__.add({
344
346
  index += match.end + 1;
345
347
  }
346
348
  if (chars.length < 1) return;
347
- const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
348
- return `${source}*`;
349
+ return chars;
349
350
  };
350
351
  const repeatedExtglobRecursion = (pattern)=>{
351
352
  let depth = 0;
@@ -369,16 +370,34 @@ __webpack_require__.add({
369
370
  risky: true
370
371
  };
371
372
  }
373
+ const safeChars = [];
374
+ let sawStarSequence = false;
375
+ let combinable = true;
372
376
  for (const branch of branches){
373
- const safeOutput = getStarExtglobSequenceOutput(branch);
374
- if (safeOutput) return {
375
- risky: true,
376
- safeOutput
377
- };
377
+ const chars = getStarExtglobSequenceChars(branch);
378
+ if (chars) {
379
+ sawStarSequence = true;
380
+ safeChars.push(...chars);
381
+ continue;
382
+ }
383
+ const literal = normalizeSimpleBranch(branch);
384
+ if (literal && 1 === literal.length) {
385
+ safeChars.push(literal);
386
+ continue;
387
+ }
388
+ combinable = false;
378
389
  if (repeatedExtglobRecursion(branch) > max) return {
379
390
  risky: true
380
391
  };
381
392
  }
393
+ if (sawStarSequence) return combinable ? {
394
+ risky: true,
395
+ safeOutput: buildCharClassStar([
396
+ ...new Set(safeChars)
397
+ ])
398
+ } : {
399
+ risky: true
400
+ };
382
401
  return {
383
402
  risky: false
384
403
  };
@@ -1002,6 +1021,7 @@ __webpack_require__.add({
1002
1021
  rest = rest.slice(3);
1003
1022
  consume('/**', 3);
1004
1023
  }
1024
+ const isEnd = eos() || state.parens > 0 && rest === ')'.repeat(state.parens) && !extglobs.some((extglob)=>'negate' === extglob.type);
1005
1025
  if ('bos' === prior.type && eos()) {
1006
1026
  prev.type = 'globstar';
1007
1027
  prev.value += value;
@@ -1011,7 +1031,7 @@ __webpack_require__.add({
1011
1031
  consume(value);
1012
1032
  continue;
1013
1033
  }
1014
- if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
1034
+ if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && isEnd) {
1015
1035
  state.output = state.output.slice(0, -(prior.output + prev.output).length);
1016
1036
  prior.output = `(?:${prior.output}`;
1017
1037
  prev.type = 'globstar';
@@ -1182,11 +1202,11 @@ __webpack_require__.add({
1182
1202
  };
1183
1203
  module.exports = parse;
1184
1204
  },
1185
- "../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
1186
- const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js");
1187
- const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js");
1188
- const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
1189
- const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
1205
+ "../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/picomatch.js" (module) {
1206
+ const scan = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/scan.js");
1207
+ const parse = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/parse.js");
1208
+ const utils = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js");
1209
+ const constants = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js");
1190
1210
  const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
1191
1211
  const picomatch = (glob, options, returnState = false)=>{
1192
1212
  if (Array.isArray(glob)) {
@@ -1269,9 +1289,11 @@ __webpack_require__.add({
1269
1289
  output
1270
1290
  };
1271
1291
  };
1272
- picomatch.matchBase = (input, glob, options)=>{
1292
+ picomatch.matchBase = (input, glob, options, posix = options && options.windows)=>{
1273
1293
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1274
- return regex.test(utils.basename(input));
1294
+ return regex.test(utils.basename(input, {
1295
+ windows: posix
1296
+ }));
1275
1297
  };
1276
1298
  picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
1277
1299
  picomatch.parse = (pattern, options)=>{
@@ -1315,9 +1337,9 @@ __webpack_require__.add({
1315
1337
  picomatch.constants = constants;
1316
1338
  module.exports = picomatch;
1317
1339
  },
1318
- "../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
1319
- const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
1320
- const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
1340
+ "../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/scan.js" (module) {
1341
+ const utils = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js");
1342
+ const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js");
1321
1343
  const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1322
1344
  const depth = (token)=>{
1323
1345
  if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
@@ -1325,7 +1347,7 @@ __webpack_require__.add({
1325
1347
  const scan = (input, options)=>{
1326
1348
  const opts = options || {};
1327
1349
  const length = input.length - 1;
1328
- const scanToEnd = true === opts.parts || true === opts.scanToEnd;
1350
+ const scanToEnd = true === opts.parts || true === opts.tokens || true === opts.scanToEnd;
1329
1351
  const slashes = [];
1330
1352
  const tokens = [];
1331
1353
  const parts = [];
@@ -1429,14 +1451,18 @@ __webpack_require__.add({
1429
1451
  finished = true;
1430
1452
  if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
1431
1453
  if (true === scanToEnd) {
1454
+ let parens = 0;
1432
1455
  while(true !== eos() && (code = advance())){
1433
1456
  if (code === CHAR_BACKWARD_SLASH) {
1434
1457
  backslashes = token.backslashes = true;
1435
- code = advance();
1458
+ advance();
1459
+ continue;
1460
+ }
1461
+ if (code === CHAR_LEFT_PARENTHESES) {
1462
+ parens++;
1436
1463
  continue;
1437
1464
  }
1438
- if (code === CHAR_RIGHT_PARENTHESES) {
1439
- isGlob = token.isGlob = true;
1465
+ if (code === CHAR_RIGHT_PARENTHESES && 0 === --parens) {
1440
1466
  finished = true;
1441
1467
  break;
1442
1468
  }
@@ -1484,13 +1510,18 @@ __webpack_require__.add({
1484
1510
  if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
1485
1511
  isGlob = token.isGlob = true;
1486
1512
  if (true === scanToEnd) {
1513
+ let parens = 1;
1487
1514
  while(true !== eos() && (code = advance())){
1488
- if (code === CHAR_LEFT_PARENTHESES) {
1515
+ if (code === CHAR_BACKWARD_SLASH) {
1489
1516
  backslashes = token.backslashes = true;
1490
- code = advance();
1517
+ advance();
1518
+ continue;
1519
+ }
1520
+ if (code === CHAR_LEFT_PARENTHESES) {
1521
+ parens++;
1491
1522
  continue;
1492
1523
  }
1493
- if (code === CHAR_RIGHT_PARENTHESES) {
1524
+ if (code === CHAR_RIGHT_PARENTHESES && 0 === --parens) {
1494
1525
  finished = true;
1495
1526
  break;
1496
1527
  }
@@ -1553,7 +1584,7 @@ __webpack_require__.add({
1553
1584
  if (true === opts.parts || true === opts.tokens) {
1554
1585
  let prevIndex;
1555
1586
  for(let idx = 0; idx < slashes.length; idx++){
1556
- const n = prevIndex ? prevIndex + 1 : start;
1587
+ const n = void 0 !== prevIndex ? prevIndex + 1 : start;
1557
1588
  const i = slashes[idx];
1558
1589
  const value = input.slice(n, i);
1559
1590
  if (opts.tokens) {
@@ -1564,18 +1595,19 @@ __webpack_require__.add({
1564
1595
  depth(tokens[idx]);
1565
1596
  state.maxDepth += tokens[idx].depth;
1566
1597
  }
1567
- if (0 !== idx || '' !== value) parts.push(value);
1568
- prevIndex = i;
1569
- }
1570
- if (prevIndex && prevIndex + 1 < input.length) {
1571
- const value = input.slice(prevIndex + 1);
1572
- parts.push(value);
1573
- if (opts.tokens) {
1574
- tokens[tokens.length - 1].value = value;
1575
- depth(tokens[tokens.length - 1]);
1576
- state.maxDepth += tokens[tokens.length - 1].depth;
1598
+ if (i >= start) {
1599
+ parts.push(value);
1600
+ prevIndex = i;
1577
1601
  }
1578
1602
  }
1603
+ const n = void 0 !== prevIndex ? prevIndex + 1 : start;
1604
+ const value = input.slice(n);
1605
+ parts.push(value);
1606
+ if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
1607
+ tokens[tokens.length - 1].value = value;
1608
+ depth(tokens[tokens.length - 1]);
1609
+ state.maxDepth += tokens[tokens.length - 1].depth;
1610
+ }
1579
1611
  state.slashes = slashes;
1580
1612
  state.parts = parts;
1581
1613
  }
@@ -1583,8 +1615,8 @@ __webpack_require__.add({
1583
1615
  };
1584
1616
  module.exports = scan;
1585
1617
  },
1586
- "../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
1587
- const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
1618
+ "../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports) {
1619
+ const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/constants.js");
1588
1620
  exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
1589
1621
  exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
1590
1622
  exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
@@ -1626,18 +1658,6 @@ __webpack_require__.add({
1626
1658
  if ('' === last) return segs[segs.length - 2];
1627
1659
  return last;
1628
1660
  };
1629
- },
1630
- child_process (module) {
1631
- module.exports = __rspack_createRequire_require("child_process");
1632
- },
1633
- "fs?cdbd" (module) {
1634
- module.exports = __rspack_createRequire_require("fs");
1635
- },
1636
- "path?37f5" (module) {
1637
- module.exports = __rspack_createRequire_require("path");
1638
- },
1639
- stream (module) {
1640
- module.exports = __rspack_createRequire_require("stream");
1641
1661
  }
1642
1662
  });
1643
1663
  function toArr(any) {
@@ -2261,7 +2281,7 @@ function joinPathWithRelativePath(root, options) {
2261
2281
  return function(filename, directoryPath) {
2262
2282
  const sameRoot = directoryPath.startsWith(root);
2263
2283
  if (sameRoot) return directoryPath.slice(root.length) + filename;
2264
- return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
2284
+ else return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
2265
2285
  };
2266
2286
  }
2267
2287
  function joinPath(filename) {
@@ -2316,8 +2336,8 @@ function build$5(options) {
2316
2336
  const { excludeFiles, filters, onlyCounts } = options;
2317
2337
  if (excludeFiles) return empty$1;
2318
2338
  if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
2319
- if (onlyCounts) return pushFileCount;
2320
- return pushFile;
2339
+ else if (onlyCounts) return pushFileCount;
2340
+ else return pushFile;
2321
2341
  }
2322
2342
  const getArray = (paths)=>paths;
2323
2343
  const getArrayGroup = ()=>[
@@ -2408,9 +2428,9 @@ function report(error, callback$1, output, suppressErrors) {
2408
2428
  function build$1(options, isSynchronous) {
2409
2429
  const { onlyCounts, group, maxFiles } = options;
2410
2430
  if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
2411
- if (group) return isSynchronous ? groupsSync : groupsAsync;
2412
- if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
2413
- return isSynchronous ? defaultSync : defaultAsync;
2431
+ else if (group) return isSynchronous ? groupsSync : groupsAsync;
2432
+ else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
2433
+ else return isSynchronous ? defaultSync : defaultAsync;
2414
2434
  }
2415
2435
  const readdirOpts = {
2416
2436
  withFileTypes: true
@@ -2716,7 +2736,7 @@ var Builder = class {
2716
2736
  return this;
2717
2737
  }
2718
2738
  };
2719
- const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
2739
+ const picomatch = rspackRequire("../../node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/index.js");
2720
2740
  const isReadonlyArray = Array.isArray;
2721
2741
  const BACKSLASHES = /\\/g;
2722
2742
  const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
@@ -2985,7 +3005,6 @@ async function glob(globInput, options) {
2985
3005
  return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
2986
3006
  }
2987
3007
  export { logger } from "@rspress/shared/logger";
2988
- export { default as node_fs } from "node:fs";
2989
3008
  export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
2990
3009
  export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
2991
3010
  export { createRequire } from "node:module";
@@ -2999,6 +3018,7 @@ export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shar
2999
3018
  export { default as remark_gfm } from "remark-gfm";
3000
3019
  export { default as remark_parse } from "remark-parse";
3001
3020
  export { unified } from "unified";
3021
+ export { default as node_fs } from "node:fs";
3002
3022
  export { createProcessor } from "@mdx-js/mdx";
3003
3023
  export { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
3004
3024
  export { default as node_os } from "node:os";
@@ -1,5 +1,5 @@
1
1
  var package_namespaceObject = {
2
- rE: "2.0.21"
2
+ rE: "2.0.23"
3
3
  };
4
4
  async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
5
5
  return new Promise((resolve_, reject_)=>{
@@ -14,7 +14,7 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
14
14
  let isIterableDone = false;
15
15
  let resolvingCount = 0;
16
16
  let currentIndex = 0;
17
- const iterator = void 0 === iterable[Symbol.iterator] ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
17
+ const iterator = void 0 === iterable[Symbol.asyncIterator] ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
18
18
  const signalListener = ()=>{
19
19
  reject(signal.reason);
20
20
  };
@@ -26,10 +26,12 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
26
26
  cleanup();
27
27
  };
28
28
  const reject = (reason)=>{
29
+ if (isResolved) return;
29
30
  isRejected = true;
30
31
  isResolved = true;
31
32
  reject_(reason);
32
33
  cleanup();
34
+ if (!isIterableDone) closeIterator(iterator);
33
35
  };
34
36
  if (signal) {
35
37
  if (signal.aborted) return void reject(signal.reason);
@@ -39,7 +41,9 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
39
41
  }
40
42
  const next = async ()=>{
41
43
  if (isResolved) return;
42
- const nextItem = await iterator.next();
44
+ const nextItem = isIterableDone ? {
45
+ done: true
46
+ } : await iterator.next();
43
47
  const index = currentIndex;
44
48
  currentIndex++;
45
49
  if (nextItem.done) {
@@ -62,19 +66,15 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
62
66
  const value = await mapper(element, index);
63
67
  if (value === pMapSkip) skippedIndexesMap.set(index, value);
64
68
  result[index] = value;
65
- resolvingCount--;
69
+ } catch (error) {
70
+ if (stopOnError) return void reject(error);
71
+ errors.push(error);
72
+ }
73
+ resolvingCount--;
74
+ try {
66
75
  await next();
67
76
  } catch (error) {
68
- if (stopOnError) reject(error);
69
- else {
70
- errors.push(error);
71
- resolvingCount--;
72
- try {
73
- await next();
74
- } catch (error) {
75
- reject(error);
76
- }
77
- }
77
+ reject(error);
78
78
  }
79
79
  })();
80
80
  };
@@ -92,6 +92,11 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
92
92
  });
93
93
  }
94
94
  const pMapSkip = Symbol('skip');
95
+ async function closeIterator(iterator) {
96
+ try {
97
+ await iterator.return?.();
98
+ } catch {}
99
+ }
95
100
  export { getDefaultDarkModeValue, isDarkModeSwitchEnabled } from "@rspress/shared";
96
101
  export { createRequire } from "node:module";
97
102
  export { default as node_path, isAbsolute, posix, relative, resolve as external_node_path_resolve } from "node:path";
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { logger, cac } from "../2711~0.js";
2
- import { package_namespaceObject } from "../8472~0.js";
1
+ import { logger, cac } from "../a~0.js";
2
+ import { package_namespaceObject } from "../b~0.js";
3
3
  import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
4
4
  import { dev } from "../node/dev.js";
5
5
  import { build } from "../node/build.js";
@@ -19,15 +19,14 @@ function runCLI({ argv = process.argv } = {}) {
19
19
  let devServer;
20
20
  const startDevServer = async ()=>{
21
21
  const { port, host } = options || {};
22
- const { config, configFilePath } = await loadConfigFile(options?.config);
22
+ const configResult = await loadConfigFile(options?.config);
23
+ const { content: config } = configResult;
23
24
  config.root = resolveDocRoot(cwd, root, config.root);
24
25
  if (options?.base) config.base = options.base;
25
26
  const docDirectory = config.root;
26
27
  devServer = await dev({
27
- appDirectory: cwd,
28
28
  docDirectory,
29
- config,
30
- configFilePath,
29
+ config: configResult,
31
30
  extraBuilderConfig: {
32
31
  server: {
33
32
  port,
@@ -60,15 +59,15 @@ function runCLI({ argv = process.argv } = {}) {
60
59
  cli.command('build [root]', 'Build the documentation site for production').option('--base <base>', 'Set the base path and override config.base').action(async (root, options)=>{
61
60
  setNodeEnv('production');
62
61
  const cwd = process.cwd();
63
- const { config, configFilePath } = await loadConfigFile(options.config);
62
+ const configResult = await loadConfigFile(options.config);
63
+ const { content: config } = configResult;
64
64
  config.root = resolveDocRoot(cwd, root, config.root);
65
65
  if (options.base) config.base = options.base;
66
66
  const docDirectory = config.root;
67
67
  try {
68
68
  await build({
69
69
  docDirectory,
70
- config,
71
- configFilePath
70
+ config: configResult
72
71
  });
73
72
  } catch (err) {
74
73
  logger.error(err);
@@ -79,14 +78,14 @@ function runCLI({ argv = process.argv } = {}) {
79
78
  setNodeEnv('production');
80
79
  const cwd = process.cwd();
81
80
  const { port, host } = options || {};
82
- const { config, configFilePath } = await loadConfigFile(options?.config);
81
+ const configResult = await loadConfigFile(options?.config);
82
+ const { content: config } = configResult;
83
83
  config.root = resolveDocRoot(cwd, root, config.root);
84
84
  if (options?.base) config.base = options.base;
85
85
  await serve({
86
- config,
86
+ config: configResult,
87
87
  host,
88
- port,
89
- configFilePath
88
+ port
90
89
  });
91
90
  });
92
91
  cli.command('eject [component]', 'Eject a theme component for customization').action(async (component)=>{
@@ -1,6 +1,5 @@
1
+ import type { LoadConfigResult } from '@rsbuild/core';
1
2
  import type { UserConfig } from '@rspress/shared';
2
- export declare function loadConfigFile(customConfigFile?: string): Promise<{
3
- config: UserConfig;
4
- configFilePath: string;
5
- }>;
3
+ export declare function loadConfigFile(customConfigFile?: string): Promise<LoadConfigResult<UserConfig>>;
4
+ export declare function normalizeConfigResult(config: UserConfig | LoadConfigResult<UserConfig>, configFilePath?: string): LoadConfigResult<UserConfig>;
6
5
  export declare function resolveDocRoot(cwd: string, cliRoot?: string, configRoot?: string): string;
@@ -1,23 +1,19 @@
1
- import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../2711~0.js";
2
- const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
1
+ import { node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../a~0.js";
3
2
  async function loadConfigFile(customConfigFile) {
4
- const baseDir = process.cwd();
5
- const configFilePath = customConfigFile ? node_path.isAbsolute(customConfigFile) ? customConfigFile : node_path.join(baseDir, customConfigFile) : findConfig(node_path.join(baseDir, DEFAULT_CONFIG_NAME));
6
- if (!configFilePath) {
7
- logger.info(`No config file found in ${baseDir}`);
8
- return {
9
- config: {},
10
- configFilePath: ''
11
- };
12
- }
13
3
  const { loadConfig } = await import("@rsbuild/core");
14
- const { content } = await loadConfig({
15
- cwd: node_path.dirname(configFilePath),
16
- path: configFilePath
4
+ const result = await loadConfig({
5
+ path: customConfigFile,
6
+ configFileNames: DEFAULT_CONFIG_EXTENSIONS.map((ext)=>DEFAULT_CONFIG_NAME + ext)
17
7
  });
8
+ if (!result.filePath) logger.info(`No config file found in ${process.cwd()}`);
9
+ return result;
10
+ }
11
+ function normalizeConfigResult(config, configFilePath) {
12
+ if ('content' in config && 'filePath' in config && 'dependencies' in config) return config;
18
13
  return {
19
- config: content,
20
- configFilePath
14
+ content: config,
15
+ filePath: configFilePath || null,
16
+ dependencies: []
21
17
  };
22
18
  }
23
19
  function resolveDocRoot(cwd, cliRoot, configRoot) {
@@ -25,4 +21,4 @@ function resolveDocRoot(cwd, cliRoot, configRoot) {
25
21
  if (configRoot) return node_path.isAbsolute(configRoot) ? configRoot : node_path.join(cwd, configRoot);
26
22
  return node_path.join(cwd, 'docs');
27
23
  }
28
- export { loadConfigFile, resolveDocRoot };
24
+ export { loadConfigFile, normalizeConfigResult, resolveDocRoot };
@@ -1,5 +1,3 @@
1
1
  export { default as github_slugger, slug } from "@rspress/shared/github-slugger";
2
2
  export { extractTextAndId } from "@rspress/shared/node-utils";
3
3
  export { visitChildren } from "unist-util-visit-children";
4
- export { default as node_os } from "node:os";
5
- export { default as node_path } from "node:path";
@@ -1,3 +1,4 @@
1
+ import type React from 'react';
1
2
  import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
3
  import { renderToStaticMarkup } from 'react-dom/server';
3
4
  import { renderToMarkdownString } from 'react-render-to-markdown';
@@ -21,6 +22,7 @@ let page = defaultPage;
21
22
  let site = defaultSite;
22
23
 
23
24
  rs.mock('@rspress/core/runtime', () => ({
25
+ Head: ({ children }: { children?: React.ReactNode }) => <>{children}</>,
24
26
  routePathToMdPath: (path: string) => `/docs${path}index.md`,
25
27
  usePage: () => ({ page }),
26
28
  useSite: () => ({ site }),
@@ -58,6 +60,12 @@ describe('LlmsHint', () => {
58
60
  expect(html).toContain(
59
61
  'For AI agents: the complete documentation index is available at https://example.com/docs/llms.txt, the full documentation bundle is available at https://example.com/docs/llms-full.txt, and this page is available as Markdown at https://example.com/docs/guide/index.md.',
60
62
  );
63
+ expect(html).toContain(
64
+ '<link rel="alternate" type="text/markdown" href="https://example.com/docs/guide/index.md"/>',
65
+ );
66
+ expect(html).toContain(
67
+ '<link rel="describedby" href="https://example.com/docs/llms.txt"/>',
68
+ );
61
69
  });
62
70
 
63
71
  it('renders a blockquote string when SSG_MD is enabled', async () => {
@@ -4,7 +4,9 @@ import {
4
4
  useSite,
5
5
  withBase,
6
6
  withSiteOrigin,
7
+ Head,
7
8
  } from '@rspress/core/runtime';
9
+
8
10
  import type React from 'react';
9
11
 
10
12
  const visuallyHiddenStyle: React.CSSProperties = {
@@ -67,8 +69,14 @@ export function LlmsHint() {
67
69
  });
68
70
 
69
71
  return (
70
- <div className="rp-llms-hint" style={visuallyHiddenStyle}>
71
- {hintText}
72
- </div>
72
+ <>
73
+ <Head>
74
+ <link rel="alternate" type="text/markdown" href={pageMdUrl} />
75
+ <link rel="describedby" href={llmsTxtUrl} />
76
+ </Head>
77
+ <div className="rp-llms-hint" style={visuallyHiddenStyle}>
78
+ {hintText}
79
+ </div>
80
+ </>
73
81
  );
74
82
  }
@@ -6,6 +6,10 @@
6
6
  height: 100%;
7
7
  list-style: none;
8
8
 
9
+ &:empty {
10
+ display: none;
11
+ }
12
+
9
13
  @media (max-width: 1279px) {
10
14
  --rp-nav-menu-item-gap: 24px;
11
15
  }