@rspress/core 2.0.10 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/3323.js +8 -0
  3. package/dist/{2240.js → 6162.js} +1 -4
  4. package/dist/8006.js +1 -1
  5. package/dist/8857.js +1 -1
  6. package/dist/common-Qw-RoVFD.js +25 -0
  7. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +1 -2
  8. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +1 -2
  9. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +1 -2
  10. package/dist/eject-theme/components/Prompt/icons.tsx +1 -1
  11. package/dist/eject-theme/components/Prompt/index.scss +325 -380
  12. package/dist/eject-theme/components/Search/logic/search.ts +10 -5
  13. package/dist/eject-theme/components/Search/logic/util.test.ts +20 -1
  14. package/dist/eject-theme/components/Search/logic/util.ts +4 -1
  15. package/dist/entry/process.d.ts +1 -0
  16. package/dist/entry/process.js +65 -0
  17. package/dist/entry/utils.d.ts +7 -0
  18. package/dist/entry/utils.js +2 -0
  19. package/dist/entry/worker.d.ts +1 -0
  20. package/dist/entry/worker.js +74 -0
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +1 -0
  23. package/dist/node/PluginDriver.js +1 -1
  24. package/dist/node/auto-nav-sidebar/index.js +1 -1
  25. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  26. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  27. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  28. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  29. package/dist/node/index.d.ts +1 -0
  30. package/dist/node/initRsbuild.js +1 -1
  31. package/dist/node/mdx/options.js +2 -1
  32. package/dist/node/mdx/processor.js +1 -1
  33. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  34. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  35. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  36. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +1 -1
  37. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  38. package/dist/node/mdx/remarkPlugins/fileCodeBlock.d.ts +1 -0
  39. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +9 -4
  40. package/dist/node/mdx/remarkPlugins/image.js +1 -1
  41. package/dist/node/mdx/remarkPlugins/link.js +1 -1
  42. package/dist/node/route/RoutePage.js +1 -1
  43. package/dist/node/route/RouteService.js +1 -1
  44. package/dist/node/route/extractPageData.js +1 -1
  45. package/dist/node/route/normalizeRoutePath.js +1 -1
  46. package/dist/node/runtimeModule/i18n.js +1 -1
  47. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  48. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  49. package/dist/node/runtimeModule/searchHooks.js +1 -1
  50. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  51. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  52. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  53. package/dist/node/serve.js +1 -1
  54. package/dist/node/ssg/renderPages.js +2 -2
  55. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  56. package/dist/node/ssg/ssgEnv.js +1 -1
  57. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  58. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  59. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  60. package/dist/node/ssg-md/renderPage.js +1 -1
  61. package/dist/node/ssg-md/renderPages.js +1 -1
  62. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  63. package/dist/node/utils/checkLanguageParity.js +1 -1
  64. package/dist/node/utils/createHash.js +1 -1
  65. package/dist/node/utils/flattenMdxContent.js +1 -1
  66. package/dist/node/utils/getPageKey.js +1 -1
  67. package/dist/node/utils/reactAlias.js +1 -1
  68. package/dist/runtime/BrowserOnly.d.ts +7 -0
  69. package/dist/runtime/BrowserOnly.js +40 -0
  70. package/dist/runtime/BrowserOnly.test.d.ts +1 -0
  71. package/dist/runtime/index.d.ts +1 -0
  72. package/dist/runtime/index.js +1 -0
  73. package/dist/theme/components/Prompt/icons.js +1 -1
  74. package/dist/theme/components/Prompt/index.css +11 -37
  75. package/dist/theme/components/Search/logic/search.js +5 -3
  76. package/dist/theme/components/Search/logic/util.js +2 -1
  77. package/dist/theme/layout/DocLayout/index.css +4 -0
  78. package/dist/theme/layout/DocLayout/index.js +3 -2
  79. package/dist/theme/logic/useThemeState.d.ts +5 -10
  80. package/dist/theme/logic/useThemeState.js +15 -20
  81. package/dist/utils-B--2TaWv.js +34 -0
  82. package/dist/utils-De75vAgL.js +7 -0
  83. package/package.json +12 -12
  84. package/dist/3425.js +0 -6
  85. package/dist/runtime/getSidebarDataGroup.test.js +0 -68
  86. package/dist/runtime/hooks/useWindowSize.test.js +0 -36
  87. package/dist/runtime/route.test.js +0 -154
  88. package/dist/runtime/utils.test.js +0 -34
  89. package/dist/theme/components/Search/logic/util.test.js +0 -51
  90. /package/dist/{2287.js → 5810.js} +0 -0
@@ -248,15 +248,17 @@ export class PageSearcher {
248
248
  let statementStartIndex = content.slice(0, queryIndex).lastIndexOf('\n');
249
249
  statementStartIndex =
250
250
  statementStartIndex === -1 ? 0 : statementStartIndex;
251
- const statementEndIndex = content.indexOf(
251
+ let statementEndIndex = content.indexOf(
252
252
  '\n\n',
253
253
  queryIndex + query.length,
254
254
  );
255
+ statementEndIndex =
256
+ statementEndIndex === -1 ? content.length : statementEndIndex;
255
257
  let statement = content.slice(statementStartIndex, statementEndIndex);
256
- if (statement.length > THRESHOLD_CONTENT_LENGTH) {
257
- statement = this.#normalizeStatement(statement, query);
258
- }
259
- const highlightIndex = normalizeTextCase(statement).indexOf(query);
258
+ statement = this.#normalizeStatement(statement, query);
259
+ const highlightIndex = normalizeTextCase(statement).indexOf(
260
+ normalizeTextCase(query),
261
+ );
260
262
  const highlightInfoList = [
261
263
  {
262
264
  start: highlightIndex,
@@ -286,6 +288,9 @@ export class PageSearcher {
286
288
  }
287
289
 
288
290
  #normalizeStatement(statement: string, query: string) {
291
+ if (statement.length <= THRESHOLD_CONTENT_LENGTH) {
292
+ return statement;
293
+ }
289
294
  // If statement is too long, we will only show 120 characters
290
295
  const queryIndex = normalizeTextCase(statement).indexOf(
291
296
  normalizeTextCase(query),
@@ -1,6 +1,6 @@
1
1
  import type { Header } from '@rspress/core';
2
2
  import { describe, expect, test } from '@rstest/core';
3
- import { backTrackHeaders } from './util';
3
+ import { backTrackHeaders, normalizeTextCase } from './util';
4
4
 
5
5
  describe('utils logic', () => {
6
6
  test('back track the headers', () => {
@@ -19,3 +19,22 @@ describe('utils logic', () => {
19
19
  ]);
20
20
  });
21
21
  });
22
+
23
+ describe('normalizeTextCase', () => {
24
+ test('normalize latin text without accents for search', () => {
25
+ expect(normalizeTextCase('CAFÉ')).toBe('cafe');
26
+ });
27
+
28
+ test('normalize japanese text without accents for search', () => {
29
+ expect(normalizeTextCase('ご')).toBe('ご');
30
+ expect(normalizeTextCase('ガ')).toBe('ガ');
31
+ });
32
+
33
+ test('normalize cyrillic text without accents for search', () => {
34
+ expect(normalizeTextCase('ПРИВЕТ')).toBe('привет');
35
+ });
36
+
37
+ test('normalize korean text without accents for search', () => {
38
+ expect(normalizeTextCase('안녕하세요')).toBe('안녕하세요');
39
+ });
40
+ });
@@ -1,6 +1,7 @@
1
1
  import type { Header } from '@rspress/core';
2
2
 
3
3
  const MAX_TITLE_LENGTH = 20;
4
+ const jRegex = /[\u3040-\u309f\u30a0-\u30ff\u31f0-\u31ff]/u;
4
5
  const kRegex = /[\u3131-\u314e|\u314f-\u3163|\uac00-\ud7a3]/u;
5
6
  const cyrillicRegex = /[\u0400-\u04FF]/u;
6
7
 
@@ -46,9 +47,11 @@ export function normalizeTextCase(text: string | number) {
46
47
  }
47
48
 
48
49
  const resultWithoutAccents = textNormalized.replace(/[\u0300-\u036f]/g, '');
49
- if (kRegex.test(String(text))) {
50
+
51
+ if (jRegex.test(String(text)) || kRegex.test(String(text))) {
50
52
  return resultWithoutAccents.normalize('NFC');
51
53
  }
54
+
52
55
  return resultWithoutAccents;
53
56
  }
54
57
 
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,65 @@
1
+ import { stderr, stdout } from "../utils-De75vAgL.js";
2
+ import { getHandler, throwInNextTick } from "../utils-B--2TaWv.js";
3
+ process.__tinypool_state__ = {
4
+ isChildProcess: true,
5
+ isTinypoolWorker: true,
6
+ workerData: null,
7
+ workerId: Number(process.env.TINYPOOL_WORKER_ID)
8
+ };
9
+ const memoryUsage = process.memoryUsage.bind(process);
10
+ const send = process.send.bind(process);
11
+ process.on("message", (message)=>{
12
+ if (!message || !message.__tinypool_worker_message__) return;
13
+ if ("pool" === message.source) {
14
+ const { filename, name } = message;
15
+ (async function() {
16
+ if (null !== filename) await getHandler(filename, name);
17
+ send({
18
+ ready: true,
19
+ source: "pool",
20
+ __tinypool_worker_message__: true
21
+ }, ()=>{});
22
+ })().catch(throwInNextTick);
23
+ return;
24
+ }
25
+ if ("port" === message.source) return void onMessage(message).catch(throwInNextTick);
26
+ throw new Error(`Unexpected TinypoolWorkerMessage ${JSON.stringify(message)}`);
27
+ });
28
+ async function onMessage(message) {
29
+ const { taskId, task, filename, name } = message;
30
+ let response;
31
+ try {
32
+ const handler = await getHandler(filename, name);
33
+ if (null === handler) throw new Error(`No handler function "${name}" exported from "${filename}"`);
34
+ const result = await handler(task);
35
+ response = {
36
+ source: "port",
37
+ __tinypool_worker_message__: true,
38
+ taskId,
39
+ result,
40
+ error: null,
41
+ usedMemory: memoryUsage().heapUsed
42
+ };
43
+ if (stdout()?.writableLength > 0) await new Promise((resolve)=>process.stdout.write("", resolve));
44
+ if (stderr()?.writableLength > 0) await new Promise((resolve)=>process.stderr.write("", resolve));
45
+ } catch (error) {
46
+ response = {
47
+ source: "port",
48
+ __tinypool_worker_message__: true,
49
+ taskId,
50
+ result: null,
51
+ error: serializeError(error),
52
+ usedMemory: memoryUsage().heapUsed
53
+ };
54
+ }
55
+ send(response);
56
+ }
57
+ function serializeError(error) {
58
+ if (error instanceof Error) return {
59
+ ...error,
60
+ name: error.name,
61
+ stack: error.stack,
62
+ message: error.message
63
+ };
64
+ return String(error);
65
+ }
@@ -0,0 +1,7 @@
1
+ //#region src/entry/utils.d.ts
2
+ type Handler = Function;
3
+ declare function getHandler(filename: string, name: string): Promise<Handler | null>;
4
+ declare function throwInNextTick(error: Error): void;
5
+
6
+ //#endregion
7
+ export { getHandler, throwInNextTick };
@@ -0,0 +1,2 @@
1
+ import { getHandler, throwInNextTick } from "../utils-B--2TaWv.js";
2
+ export { getHandler, throwInNextTick };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,74 @@
1
+ import { isMovable, kRequestCountField, kResponseCountField, kTransferable, kValue } from "../common-Qw-RoVFD.js";
2
+ import { stderr, stdout } from "../utils-De75vAgL.js";
3
+ import { getHandler, throwInNextTick } from "../utils-B--2TaWv.js";
4
+ import { parentPort, receiveMessageOnPort, workerData } from "node:worker_threads";
5
+ const [tinypoolPrivateData, workerData$1] = workerData;
6
+ process.__tinypool_state__ = {
7
+ isWorkerThread: true,
8
+ isTinypoolWorker: true,
9
+ workerData: workerData$1,
10
+ workerId: tinypoolPrivateData.workerId
11
+ };
12
+ const memoryUsage = process.memoryUsage.bind(process);
13
+ let useAtomics = "1" !== process.env.PISCINA_DISABLE_ATOMICS;
14
+ parentPort.on("message", (message)=>{
15
+ useAtomics = "1" === process.env.PISCINA_DISABLE_ATOMICS ? false : message.useAtomics;
16
+ const { port, sharedBuffer, filename, name } = message;
17
+ (async function() {
18
+ if (null !== filename) await getHandler(filename, name);
19
+ const readyMessage = {
20
+ ready: true
21
+ };
22
+ parentPort.postMessage(readyMessage);
23
+ port.start();
24
+ port.on("message", onMessage.bind(null, port, sharedBuffer));
25
+ atomicsWaitLoop(port, sharedBuffer);
26
+ })().catch(throwInNextTick);
27
+ });
28
+ let currentTasks = 0;
29
+ let lastSeenRequestCount = 0;
30
+ function atomicsWaitLoop(port, sharedBuffer) {
31
+ if (!useAtomics) return;
32
+ while(0 === currentTasks){
33
+ Atomics.wait(sharedBuffer, kRequestCountField, lastSeenRequestCount);
34
+ lastSeenRequestCount = Atomics.load(sharedBuffer, kRequestCountField);
35
+ let entry;
36
+ while(void 0 !== (entry = receiveMessageOnPort(port)))onMessage(port, sharedBuffer, entry.message);
37
+ }
38
+ }
39
+ function onMessage(port, sharedBuffer, message) {
40
+ currentTasks++;
41
+ const { taskId, task, filename, name } = message;
42
+ (async function() {
43
+ let response;
44
+ let transferList = [];
45
+ try {
46
+ const handler = await getHandler(filename, name);
47
+ if (null === handler) throw new Error(`No handler function "${name}" exported from "${filename}"`);
48
+ let result = await handler(task);
49
+ if (isMovable(result)) {
50
+ transferList = transferList.concat(result[kTransferable]);
51
+ result = result[kValue];
52
+ }
53
+ response = {
54
+ taskId,
55
+ result,
56
+ error: null,
57
+ usedMemory: memoryUsage().heapUsed
58
+ };
59
+ if (stdout()?.writableLength > 0) await new Promise((resolve)=>process.stdout.write("", resolve));
60
+ if (stderr()?.writableLength > 0) await new Promise((resolve)=>process.stderr.write("", resolve));
61
+ } catch (error) {
62
+ response = {
63
+ taskId,
64
+ result: null,
65
+ error,
66
+ usedMemory: memoryUsage().heapUsed
67
+ };
68
+ }
69
+ currentTasks--;
70
+ port.postMessage(response, transferList);
71
+ Atomics.add(sharedBuffer, kResponseCountField, 1);
72
+ atomicsWaitLoop(port, sharedBuffer);
73
+ })().catch(throwInNextTick);
74
+ }
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { getIconUrlPath, getNodeAttribute, mergeDocConfig, } from '@rspress/shar
5
5
  export { matchPath } from 'react-router-dom';
6
6
  export type { UserConfigAsyncFn } from './config/defineConfig.js';
7
7
  export { defineConfig } from './config/defineConfig.js';
8
- export { build, dev, remarkFileCodeBlock, remarkLink, serve } from './node/index.js';
8
+ export { build, dev, remarkFileCodeBlock, remarkImage, remarkLink, serve, } from './node/index.js';
9
9
  export type { CustomLinkMeta, DirSectionHeaderSideMeta, DirSideMeta, DividerSideMeta, FileSideMeta, MetaJson, NavJson, SectionHeaderMeta, SideMeta, SideMetaItem, } from './node/auto-nav-sidebar/type.js';
10
10
  export { PluginDriver } from './node/PluginDriver.js';
11
11
  export { RouteService } from './node/route/RouteService.js';
package/dist/index.js CHANGED
@@ -5,5 +5,6 @@ export { build } from "./node/build.js";
5
5
  export { defineConfig } from "./config/defineConfig.js";
6
6
  export { dev } from "./node/dev.js";
7
7
  export { remarkFileCodeBlock } from "./node/mdx/remarkPlugins/fileCodeBlock.js";
8
+ export { remarkImage } from "./node/mdx/remarkPlugins/image.js";
8
9
  export { remarkLink } from "./node/mdx/remarkPlugins/link.js";
9
10
  export { serve } from "./node/serve.js";
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, node_path, addLeadingSlash } from "../2287.js";
1
+ import { addTrailingSlash, node_path, addLeadingSlash } from "../5810.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
4
4
  class PluginDriver {
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../2287.js";
1
+ import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../5810.js";
2
2
  import { processLocales, combineWalkResult } from "./locales.js";
3
3
  import { walk } from "./walk.js";
4
4
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../2287.js";
1
+ import { node_path } from "../../5810.js";
2
2
  import { walk } from "./walk.js";
3
3
  function combineWalkResult(walks, versions) {
4
4
  return walks.reduce((acc, cur, curIndex)=>({
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../8006.js";
3
- import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../2287.js";
3
+ import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../5810.js";
4
4
  import { createError } from "../utils/error.js";
5
5
  import { PUBLIC_DIR } from "../constants.js";
6
6
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../2287.js";
1
+ import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../5810.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  async function pathExists(path) {
4
4
  try {
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, node_path, promises } from "../../2287.js";
1
+ import { isExternalUrl, node_path, promises } from "../../5810.js";
2
2
  import { pathExists } from "../utils/fs.js";
3
3
  import { readJson } from "./utils.js";
4
4
  import { addRoutePrefix } from "../route/RoutePage.js";
@@ -1,5 +1,6 @@
1
1
  export { build } from './build.js';
2
2
  export { dev } from './dev.js';
3
3
  export { remarkFileCodeBlock } from './mdx/remarkPlugins/fileCodeBlock.js';
4
+ export { remarkImage } from './mdx/remarkPlugins/image.js';
4
5
  export { remarkLink } from './mdx/remarkPlugins/link.js';
5
6
  export { serve } from './serve.js';
@@ -1,4 +1,4 @@
1
- import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash, pluginVirtualModule, pluginReact, MDX_OR_MD_REGEXP } from "../2287.js";
1
+ import { external_node_process_cwd, node_path, external_node_url_fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, external_node_module_createRequire, removeTrailingSlash, pluginVirtualModule, pluginReact, MDX_OR_MD_REGEXP } from "../5810.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { PUBLIC_DIR, CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, inlineThemeScript, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
4
4
  import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
@@ -1,4 +1,4 @@
1
- import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../2240.js";
1
+ import { node_path, rehype_external_links, rehype_raw, remark_cjk_friendly, nodeTypes, remark_gfm, rehype, remark_cjk_friendly_gfm_strikethrough } from "../../6162.js";
2
2
  import { remarkToc } from "./remarkPlugins/toc.js";
3
3
  import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
4
4
  import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
@@ -34,6 +34,7 @@ async function createMDXOptions(options) {
34
34
  remarkFileCodeBlock,
35
35
  {
36
36
  filepath,
37
+ docDirectory,
37
38
  addDependency
38
39
  }
39
40
  ],
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../2240.js";
1
+ import { node_path, extractTextAndId, createProcessor, loadFrontMatter } from "../../6162.js";
2
2
  import { createMDXOptions } from "./options.js";
3
3
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
4
4
  import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
@@ -1,4 +1,4 @@
1
- import { visit } from "../../../2240.js";
1
+ import { visit } from "../../../6162.js";
2
2
  const rehypeCodeMeta = ()=>(tree)=>{
3
3
  visit(tree, 'element', (node)=>{
4
4
  if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
@@ -1,4 +1,4 @@
1
- import { visit, extractTextAndId, github_slugger, headingRank } from "../../../2240.js";
1
+ import { visit, extractTextAndId, github_slugger, headingRank } from "../../../6162.js";
2
2
  const rehypeHeaderAnchor = ()=>{
3
3
  const slugger = new github_slugger();
4
4
  return (tree)=>{
@@ -1,4 +1,4 @@
1
- import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../2240.js";
1
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddFold, createCssVariablesTheme, transformerAddWrapCode } from "../../../6162.js";
2
2
  const cssVariablesTheme = createCssVariablesTheme({
3
3
  name: 'css-variables',
4
4
  variablePrefix: '--shiki-',
@@ -1,4 +1,4 @@
1
- export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold, } from './add-fold.js';
1
+ export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold } from './add-fold.js';
2
2
  export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from './add-lang.js';
3
3
  export { SHIKI_TRANSFORMER_ADD_LINE_NUMBERS, transformerAddLineNumbers, } from './add-line-numbers.js';
4
4
  export { SHIKI_TRANSFORMER_ADD_TITLE, transformerAddTitle } from './add-title.js';
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../../2240.js";
1
+ import { node_path } from "../../../6162.js";
2
2
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
3
3
  const remarkBuiltin = ({ globalComponents })=>(tree)=>{
4
4
  const demos = globalComponents.map((componentPath)=>{
@@ -4,6 +4,7 @@ import type { Plugin } from 'unified';
4
4
  export declare const remarkFileCodeBlock: Plugin<[
5
5
  {
6
6
  filepath: string;
7
+ docDirectory: string;
7
8
  addDependency?: Rspack.LoaderContext['addDependency'];
8
9
  }
9
10
  ], Root>;
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
2
  import "../../../8006.js";
3
- import { visit, node_path, logger, cwd, readFile } from "../../../3425.js";
3
+ import { visit, node_path, logger, cwd, readFile } from "../../../3323.js";
4
4
  import { createError } from "../../utils/error.js";
5
5
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -14,16 +14,16 @@ function parseFileFromMeta(meta) {
14
14
  }
15
15
  return '';
16
16
  }
17
- const remarkFileCodeBlock = ({ filepath, addDependency })=>async (tree)=>{
17
+ const remarkFileCodeBlock = ({ filepath, docDirectory, addDependency })=>async (tree)=>{
18
18
  const promiseList = [];
19
19
  visit(tree, 'code', (node)=>{
20
20
  const { meta, value, lang } = node;
21
21
  const file = parseFileFromMeta(meta ?? '');
22
22
  if (!file) return;
23
23
  const originalMetaForErrorInfo = picocolors_default().cyan(`\`\`\`${lang} ${meta}`);
24
- if (file.startsWith('./') || file.startsWith('../') || file.startsWith('<root>/')) {
24
+ if (file.startsWith('./') || file.startsWith('../') || file.startsWith('/') || file.startsWith('<root>/')) {
25
25
  let resolvedFilePath;
26
- resolvedFilePath = file.startsWith('<root>/') ? node_path.join(cwd(), file.slice(7)) : node_path.join(node_path.dirname(filepath), file);
26
+ resolvedFilePath = file.startsWith('<root>/') ? node_path.join(cwd(), file.slice(7)) : file.startsWith('/') ? node_path.join(docDirectory, file.slice(1)) : node_path.join(node_path.dirname(filepath), file);
27
27
  if ('' !== value.trim()) {
28
28
  logger.error(`${ERROR_PREFIX} ${originalMetaForErrorInfo} The content of file code block should be empty.
29
29
 
@@ -58,6 +58,11 @@ Please use below:
58
58
 
59
59
  or
60
60
 
61
+ \`\`\`tsx file="/path/to/filename"
62
+ \`\`\`
63
+
64
+ or
65
+
61
66
  \`\`\`tsx file="<root>/path/to/filename"
62
67
  \`\`\`
63
68
  `);
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
2
  import "../../../8006.js";
3
- import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../2240.js";
3
+ import { visit, node_path, logger, isDataUrl, existsSync, getNodeAttribute, isExternalUrl, isProduction, parseUrl } from "../../../3323.js";
4
4
  import { createError } from "../../utils/error.js";
5
5
  import { PUBLIC_DIR } from "../../constants.js";
6
6
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../../0~rslib-runtime.js";
2
2
  import "../../../8006.js";
3
- import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withBase } from "../../../3425.js";
3
+ import { normalizeHref, node_path, addLeadingSlash, logger, visit, isExternalUrl, isProduction, parseUrl, withBase } from "../../../3323.js";
4
4
  import { hintRelativeMarkdownLink } from "../../logger/hint.js";
5
5
  import { createError } from "../../utils/error.js";
6
6
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../2287.js";
1
+ import { node_path } from "../../5810.js";
2
2
  import { RouteService } from "./RouteService.js";
3
3
  import { normalizePath, slash } from "../utils/normalizePath.js";
4
4
  import { getPageKey } from "../utils/getPageKey.js";
@@ -1,4 +1,4 @@
1
- import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../2287.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../5810.js";
2
2
  import { PUBLIC_DIR } from "../constants.js";
3
3
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
4
4
  import { createError } from "../utils/error.js";
@@ -1,4 +1,4 @@
1
- import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../2287.js";
1
+ import { unified, node_path, promises, loadFrontMatter, remove, remark_gfm, MDX_OR_MD_REGEXP, remark_parse } from "../../5810.js";
2
2
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
3
3
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
4
4
  import { importStatementRegex } from "../constants.js";
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../2287.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../5810.js";
2
2
  const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
3
3
  const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
4
4
  return [
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../8006.js";
3
- import { external_node_module_createRequire, join, logger } from "../../2287.js";
3
+ import { external_node_module_createRequire, join, logger } from "../../5810.js";
4
4
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
5
5
  import { createError } from "../utils/error.js";
6
6
  import { pathExists } from "../utils/fs.js";
@@ -1,4 +1,4 @@
1
- import { SEARCH_INDEX_NAME, groupBy } from "../../../2287.js";
1
+ import { SEARCH_INDEX_NAME, groupBy } from "../../../5810.js";
2
2
  import { extractPageData } from "../../route/extractPageData.js";
3
3
  import { createHash } from "../../utils/createHash.js";
4
4
  function deletePrivateField(obj) {
@@ -1,4 +1,4 @@
1
- import { logger, pluginVirtualModule } from "../../../2287.js";
1
+ import { logger, pluginVirtualModule } from "../../../5810.js";
2
2
  import { createPageData } from "./createPageData.js";
3
3
  const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
4
4
  const ref = {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../2287.js";
1
+ import { node_path } from "../../5810.js";
2
2
  const searchHookVMPlugin = (context)=>({
3
3
  ["virtual-search-hooks"]: ()=>{
4
4
  const { config } = context;
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../2287.js";
1
+ import { getIconUrlPath } from "../../../5810.js";
2
2
  import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
3
3
  async function createSiteData(userConfig) {
4
4
  const tempSearchObj = Object.assign({}, userConfig.search);
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../2287.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../5810.js";
2
2
  import { getI18nData } from "../i18n.js";
3
3
  import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
4
4
  async function normalizeThemeConfig(docConfig) {
@@ -1,4 +1,4 @@
1
- import { logger } from "../../../2287.js";
1
+ import { logger } from "../../../5810.js";
2
2
  import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
3
3
  import { createSiteData } from "./createSiteData.js";
4
4
  const siteDataVMPlugin = (context)=>{
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../2287.js";
1
+ import { mergeRsbuildConfig } from "../5810.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,7 +1,7 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
3
3
  import "../../8006.js";
4
- import { chunk, logger } from "../../2287.js";
4
+ import { chunk, logger } from "../../5810.js";
5
5
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
6
6
  import { pMap } from "../../1688.js";
7
7
  import { renderPage } from "./renderPage.js";
@@ -17,7 +17,7 @@ const routePath2HtmlFileName = (routePath)=>{
17
17
  async function renderPages(routeService, config, ssrBundlePath, htmlTemplate, emitAsset) {
18
18
  logger.info('Rendering pages...');
19
19
  const startTime = Date.now();
20
- const ssg = config.ssg || true;
20
+ const ssg = config.ssg ?? true;
21
21
  try {
22
22
  const routes = routeService.getRoutes();
23
23
  if (!routeService.isExistRoute('/404')) routes.push({
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../2287.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../5810.js";
2
2
  import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  const rsbuildPluginSSG = ({ routeService, config })=>({
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../2287.js";
2
+ import { node_os } from "../../5810.js";
3
3
  /**
4
4
  * these codes are copied from
5
5
  * @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
@@ -1,4 +1,4 @@
1
- import { matchPath, getSidebarDataGroup } from "../../../2287.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../5810.js";
2
2
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
3
3
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
4
4
  const base = config.base ?? '/';
@@ -1,4 +1,4 @@
1
- import { normalizeHref, logger, withBase } from "../../../2287.js";
1
+ import { normalizeHref, logger, withBase } from "../../../5810.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base) {
4
4
  let url = routePath;
@@ -1,4 +1,4 @@
1
- import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../2240.js";
1
+ import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../6162.js";
2
2
  function remarkSplitMdx(options = {}) {
3
3
  return (tree)=>{
4
4
  const newChildren = [];
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../8006.js";
3
- import { createHead, pathToFileURL, logger } from "../../2287.js";
3
+ import { createHead, pathToFileURL, logger } from "../../5810.js";
4
4
  import { hintSSGFailed } from "../logger/hint.js";
5
5
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../8006.js";
3
- import { logger } from "../../2287.js";
3
+ import { logger } from "../../5810.js";
4
4
  import { pMap } from "../../1688.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";